import {z} from 'zod' export type SinkStatusIn = 'enabled' | 'disabled'; export type AzureBlobStorageConfigIn = {accessKey?: (string | null) | undefined, account: string, container: string}; export type OtelTracingConfigIn = {headers?: {[key: string]: string} | undefined, url: string}; export type SinkHttpConfigIn = {headers?: {[key: string]: string} | undefined, key?: (string | null) | undefined, url: string}; export type S3ConfigIn = {accessKeyId?: (string | null) | undefined, bucket: string, endpointUrl?: (string | null) | undefined, externalId?: (string | null) | undefined, region?: (string | null) | undefined, roleArn?: (string | null) | undefined, secretAccessKey?: (string | null) | undefined}; export type GoogleCloudStorageConfigIn = {bucket: string, credentials: string}; export type GoogleCloudPubSubConfigIn = {credentials: string, projectId: string, topicId: string}; export type SqsConfigIn = {accessKeyId?: (string | null) | undefined, endpointUrl?: (string | null) | undefined, externalId?: (string | null) | undefined, queueUrl: string, region?: (string | null) | undefined, roleArn?: (string | null) | undefined, secretAccessKey?: (string | null) | undefined}; export type SnsConfigIn = {accessKeyId?: (string | null) | undefined, endpointUrl?: (string | null) | undefined, externalId?: (string | null) | undefined, region?: (string | null) | undefined, roleArn?: (string | null) | undefined, secretAccessKey?: (string | null) | undefined, topicArn: string}; export type BigQueryConfigIn = {credentials: string, datasetId: string, projectId: string, tableId: string}; export type ClickhouseConfigIn = {database?: string | undefined, password?: (string | null) | undefined, tableName: string, url: string, username?: (string | null) | undefined}; export type EventBridgeConfigIn = {accessKeyId?: (string | null) | undefined, detailType?: string | undefined, eventBusName: string, externalId?: (string | null) | undefined, region?: (string | null) | undefined, roleArn?: (string | null) | undefined, secretAccessKey?: (string | null) | undefined}; export type SnowflakeConfigIn = {accountIdentifier: string, dbName?: string | undefined, privateKey?: (string | null) | undefined, schemaName?: string | undefined, tableName?: string | undefined, userId: string}; export type RabbitMqConfigIn = {mandatory?: boolean | undefined, routingKey: string, uri: string}; export type RedshiftConfigIn = {accessKeyId?: (string | null) | undefined, clusterIdentifier?: (string | null) | undefined, dbName?: string | undefined, dbUser?: (string | null) | undefined, externalId?: (string | null) | undefined, region?: (string | null) | undefined, roleArn?: (string | null) | undefined, schemaName?: (string | null) | undefined, secretAccessKey?: (string | null) | undefined, tableName?: string | undefined, workgroupName?: (string | null) | undefined}; export type PostgresConfigIn = {password?: (string | null) | undefined, sslRootCert?: (string | null) | undefined, tableName: string, url: string}; export type ElasticSearchOperation = 'index' | 'create'; export type ElasticSearchConfigIn = {apiKey?: (string | null) | undefined, indexName: string, operation?: ElasticSearchOperation | undefined, refresh?: boolean | undefined, url: string}; export type PostHogConfigIn = {domain: string, projectToken: string}; export type SegmentSinkConfigIn = {host: string, writeKey: string}; export type StreamSinkIn = {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, type: 'poller'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: AzureBlobStorageConfigIn, type: 'azureBlobStorage'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: OtelTracingConfigIn, type: 'otelTracing'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: SinkHttpConfigIn, type: 'http'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: S3ConfigIn, type: 'amazonS3'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: GoogleCloudStorageConfigIn, type: 'googleCloudStorage'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: GoogleCloudPubSubConfigIn, type: 'googleCloudPubSub'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: SqsConfigIn, type: 'sqs'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: SnsConfigIn, type: 'sns'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: BigQueryConfigIn, type: 'bigQuery'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: ClickhouseConfigIn, type: 'clickhouse'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: EventBridgeConfigIn, type: 'eventBridge'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: SnowflakeConfigIn, type: 'snowflake'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: RabbitMqConfigIn, type: 'rabbitMq'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: RedshiftConfigIn, type: 'redshift'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: PostgresConfigIn, type: 'postgres'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: ElasticSearchConfigIn, type: 'elasticSearch'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: PostHogConfigIn, type: 'postHog'} | {batchSize?: number | undefined, channels?: Array | undefined, eventTypes?: Array | undefined, maxWaitSecs?: number | undefined, metadata?: {[key: string]: string} | undefined, status?: SinkStatusIn | undefined, uid?: (string | null) | undefined, config: SegmentSinkConfigIn, type: 'segment'}; export type UpdateApiApiV1StreamStreamIdSinkSinkIdArgs = {stream_id: string, sink_id: string, body: StreamSinkIn}; export type UpdateApiApiV1StreamStreamIdSinkSinkIdOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const sinkStatus = z.enum(["enabled", "paused", "disabled", "retrying"]); export const azureBlobStorageConfigOut = z.object({account: z.string(), container: z.string()}); export const endpointHeadersOut = z.object({headers: z.record(z.string(), z.string()), sensitive: z.array(z.string())}); export const otelTracingConfigOut = z.object({headers: endpointHeadersOut, url: z.string()}); export const sinkHttpConfigOut = z.object({headers: endpointHeadersOut, url: z.string()}); export const s3ConfigOut = z.object({accessKeyId: z.string().nullable().optional(), bucket: z.string(), endpointUrl: z.string().nullable().optional(), externalId: z.string().nullable().optional(), region: z.string(), roleArn: z.string().nullable().optional()}); export const snowflakeConfigOut = z.object({accountIdentifier: z.string(), dbName: z.string().max(512).optional(), schemaName: z.string().max(512).optional(), tableName: z.string().max(512).optional(), userId: z.string()}); export const googleCloudStorageConfigOut = z.object({bucket: z.string()}); export const googleCloudPubSubConfigOut = z.object({projectId: z.string(), topicId: z.string()}); export const redshiftConfigOut = z.object({accessKeyId: z.string().nullable().optional(), clusterIdentifier: z.string().nullable().optional(), dbName: z.string().max(512).optional(), dbUser: z.string().nullable().optional(), externalId: z.string().nullable().optional(), region: z.string(), roleArn: z.string().nullable().optional(), schemaName: z.string().max(512).nullable().optional(), tableName: z.string().max(512).optional(), workgroupName: z.string().nullable().optional()}); export const bigQueryConfigOut = z.object({datasetId: z.string(), projectId: z.string(), tableId: z.string()}); export const clickhouseConfigOut = z.object({database: z.string(), tableName: z.string(), url: z.string(), username: z.string()}); export const rabbitMqConfigOut = z.object({mandatory: z.boolean(), routingKey: z.string(), uri: z.string()}); export const sqsConfigOut = z.object({accessKeyId: z.string().nullable().optional(), endpointUrl: z.string().nullable().optional(), externalId: z.string().nullable().optional(), queueUrl: z.string(), region: z.string(), roleArn: z.string().nullable().optional()}); export const eventBridgeConfigOut = z.object({accessKeyId: z.string().nullable().optional(), detailType: z.string().max(128), eventBusName: z.string(), externalId: z.string().nullable().optional(), region: z.string(), roleArn: z.string().nullable().optional()}); export const snsConfigOut = z.object({accessKeyId: z.string().nullable().optional(), externalId: z.string().nullable().optional(), region: z.string(), roleArn: z.string().nullable().optional(), topicArn: z.string()}); export const postgresConfigOut = z.object({sslRootCert: z.string().nullable().optional(), tableName: z.string(), url: z.string()}); export const elasticSearchOperation = z.enum(["index", "create"]); export const elasticSearchConfigOut = z.object({indexName: z.string(), operation: elasticSearchOperation, refresh: z.boolean(), url: z.string()}); export const postHogConfigOut = z.object({domain: z.string()}); export const segmentSinkConfigOut = z.object({host: z.string()}); export const streamSinkOut = z.discriminatedUnion("type", [z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), type: z.literal("poller")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), type: z.literal("pollingEndpoint")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: azureBlobStorageConfigOut, type: z.literal("azureBlobStorage")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: otelTracingConfigOut, type: z.literal("otelTracing")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: sinkHttpConfigOut, type: z.literal("http")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: s3ConfigOut, type: z.literal("amazonS3")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: snowflakeConfigOut, type: z.literal("snowflake")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: googleCloudStorageConfigOut, type: z.literal("googleCloudStorage")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: googleCloudPubSubConfigOut, type: z.literal("googleCloudPubSub")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: redshiftConfigOut, type: z.literal("redshift")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: bigQueryConfigOut, type: z.literal("bigQuery")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: clickhouseConfigOut, type: z.literal("clickhouse")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: rabbitMqConfigOut, type: z.literal("rabbitMq")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: sqsConfigOut, type: z.literal("sqs")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: eventBridgeConfigOut, type: z.literal("eventBridge")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: snsConfigOut, type: z.literal("sns")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: postgresConfigOut, type: z.literal("postgres")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: elasticSearchConfigOut, type: z.literal("elasticSearch")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: postHogConfigOut, type: z.literal("postHog")}), z.object({batchSize: z.number().int(), channels: z.array(z.string().max(128)).optional(), createdAt: z.string(), currentIterator: z.string(), eventTypes: z.array(z.string().max(256)).optional(), failureReason: z.string().nullable().optional(), id: z.string().min(26).max(27), maxWaitSecs: z.number().int(), metadata: z.record(z.string(), z.string()), nextRetryAt: z.string().nullable().optional(), status: sinkStatus, uid: z.string().min(1).max(60).nullable().optional(), updatedAt: z.string(), config: segmentSinkConfigOut, type: z.literal("segment")})]); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Upsert Sink * * PUT /api/v1/stream/{stream_id}/sink/{sink_id} */ export const updateApiApiV1StreamStreamIdSinkSinkId = async (args: UpdateApiApiV1StreamStreamIdSinkSinkIdArgs, options?: UpdateApiApiV1StreamStreamIdSinkSinkIdOptions) => { const {baseUrl = "https://api.eu.svix.com", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/stream/${encodeURIComponent(String(args.stream_id))}/sink/${encodeURIComponent(String(args.sink_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(streamSinkOut, await res.json()) };