/**
 * Cloudflare QUEUES API
 *
 * Generated from Cloudflare TypeScript SDK.
 * DO NOT EDIT - regenerate with: bun scripts/generate.ts --service queues
 */
import * as Schema from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import {} from "../errors.js";
// =============================================================================
// Errors
// =============================================================================
export class ConsumerAlreadyExists extends Schema.TaggedErrorClass()("ConsumerAlreadyExists", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ConsumerAlreadyExists, [{ code: 11004 }]);
export class ConsumerNotFound extends Schema.TaggedErrorClass()("ConsumerNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ConsumerNotFound, [
    { code: 10013 },
    { code: 10105 },
    { code: 11006 },
]);
export class InvalidMessageBody extends Schema.TaggedErrorClass()("InvalidMessageBody", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidMessageBody, [{ code: 10207 }, { code: 10013 }]);
export class InvalidQueueId extends Schema.TaggedErrorClass()("InvalidQueueId", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidQueueId, [{ code: 10107 }]);
export class InvalidQueueName extends Schema.TaggedErrorClass()("InvalidQueueName", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidQueueName, [{ code: 11003 }]);
export class InvalidRequestBody extends Schema.TaggedErrorClass()("InvalidRequestBody", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidRequestBody, [{ code: 10026 }]);
export class InvalidRoute extends Schema.TaggedErrorClass()("InvalidRoute", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidRoute, [{ code: 7003 }]);
export class QueueAlreadyExists extends Schema.TaggedErrorClass()("QueueAlreadyExists", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(QueueAlreadyExists, [{ code: 11009 }]);
export class QueueHandlerMissing extends Schema.TaggedErrorClass()("QueueHandlerMissing", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(QueueHandlerMissing, [
    { code: 11001 },
    { status: 400, message: { includes: "queue handler is missing" } },
]);
export class QueueNotFound extends Schema.TaggedErrorClass()("QueueNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(QueueNotFound, [
    { code: 11000 },
    { code: 0, message: { includes: "Queue does not exist" } },
]);
export class UnrecognizedEventType extends Schema.TaggedErrorClass()("UnrecognizedEventType", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(UnrecognizedEventType, [
    { code: 0, message: { includes: "Unrecognized event types" } },
]);
export class WorkerNotFound extends Schema.TaggedErrorClass()("WorkerNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(WorkerNotFound, [{ code: 10007 }]);
export const GetConsumerRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    consumerId: Schema.String.pipe(T.HttpPath("consumerId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/queues/{queueId}/consumers/{consumerId}",
}));
export const GetConsumerResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Union([
    Schema.Struct({
        consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        settings: Schema.optional(Schema.Union([
            Schema.Struct({
                batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                batchSize: "batch_size",
                maxConcurrency: "max_concurrency",
                maxRetries: "max_retries",
                maxWaitTimeMs: "max_wait_time_ms",
                retryDelay: "retry_delay",
            })),
            Schema.Null,
        ])),
        type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
    }).pipe(Schema.encodeKeys({
        consumerId: "consumer_id",
        createdOn: "created_on",
        queueId: "queue_id",
        script: "script",
        settings: "settings",
        type: "type",
    })),
    Schema.Struct({
        consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        settings: Schema.optional(Schema.Union([
            Schema.Struct({
                batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                batchSize: "batch_size",
                maxRetries: "max_retries",
                retryDelay: "retry_delay",
                visibilityTimeoutMs: "visibility_timeout_ms",
            })),
            Schema.Null,
        ])),
        type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
    }).pipe(Schema.encodeKeys({
        consumerId: "consumer_id",
        createdOn: "created_on",
        queueId: "queue_id",
        settings: "settings",
        type: "type",
    })),
]).pipe(T.ResponsePath("result"));
export const getConsumer = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetConsumerRequest,
    output: GetConsumerResponse,
    errors: [InvalidRequestBody, QueueNotFound, ConsumerNotFound, InvalidRoute],
}));
export const ListConsumersRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/queues/{queueId}/consumers",
}));
export const ListConsumersResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Union([
        Schema.Struct({
            consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            settings: Schema.optional(Schema.Union([
                Schema.Struct({
                    batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                }).pipe(Schema.encodeKeys({
                    batchSize: "batch_size",
                    maxConcurrency: "max_concurrency",
                    maxRetries: "max_retries",
                    maxWaitTimeMs: "max_wait_time_ms",
                    retryDelay: "retry_delay",
                })),
                Schema.Null,
            ])),
            type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
        }).pipe(Schema.encodeKeys({
            consumerId: "consumer_id",
            createdOn: "created_on",
            queueId: "queue_id",
            script: "script",
            settings: "settings",
            type: "type",
        })),
        Schema.Struct({
            consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            settings: Schema.optional(Schema.Union([
                Schema.Struct({
                    batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                }).pipe(Schema.encodeKeys({
                    batchSize: "batch_size",
                    maxRetries: "max_retries",
                    retryDelay: "retry_delay",
                    visibilityTimeoutMs: "visibility_timeout_ms",
                })),
                Schema.Null,
            ])),
            type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
        }).pipe(Schema.encodeKeys({
            consumerId: "consumer_id",
            createdOn: "created_on",
            queueId: "queue_id",
            settings: "settings",
            type: "type",
        })),
    ])),
});
export const listConsumers = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListConsumersRequest,
    output: ListConsumersResponse,
    errors: [InvalidRequestBody, QueueNotFound, InvalidRoute],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const CreateConsumerRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    deadLetterQueue: Schema.optional(Schema.String),
    scriptName: Schema.optional(Schema.String),
    settings: Schema.optional(Schema.Struct({
        batchSize: Schema.optional(Schema.Number),
        maxConcurrency: Schema.optional(Schema.Number),
        maxRetries: Schema.optional(Schema.Number),
        maxWaitTimeMs: Schema.optional(Schema.Number),
        retryDelay: Schema.optional(Schema.Number),
    }).pipe(Schema.encodeKeys({
        batchSize: "batch_size",
        maxConcurrency: "max_concurrency",
        maxRetries: "max_retries",
        maxWaitTimeMs: "max_wait_time_ms",
        retryDelay: "retry_delay",
    }))),
    type: Schema.Literals(["worker", "http_pull"]),
}).pipe(Schema.encodeKeys({
    deadLetterQueue: "dead_letter_queue",
    scriptName: "script_name",
    settings: "settings",
    type: "type",
}), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/queues/{queueId}/consumers",
}));
export const CreateConsumerResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Union([
    Schema.Struct({
        consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        settings: Schema.optional(Schema.Union([
            Schema.Struct({
                batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                batchSize: "batch_size",
                maxConcurrency: "max_concurrency",
                maxRetries: "max_retries",
                maxWaitTimeMs: "max_wait_time_ms",
                retryDelay: "retry_delay",
            })),
            Schema.Null,
        ])),
        type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
    }).pipe(Schema.encodeKeys({
        consumerId: "consumer_id",
        createdOn: "created_on",
        queueId: "queue_id",
        script: "script",
        settings: "settings",
        type: "type",
    })),
    Schema.Struct({
        consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        settings: Schema.optional(Schema.Union([
            Schema.Struct({
                batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                batchSize: "batch_size",
                maxRetries: "max_retries",
                retryDelay: "retry_delay",
                visibilityTimeoutMs: "visibility_timeout_ms",
            })),
            Schema.Null,
        ])),
        type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
    }).pipe(Schema.encodeKeys({
        consumerId: "consumer_id",
        createdOn: "created_on",
        queueId: "queue_id",
        settings: "settings",
        type: "type",
    })),
]).pipe(T.ResponsePath("result"));
export const createConsumer = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateConsumerRequest,
    output: CreateConsumerResponse,
    errors: [
        InvalidRequestBody,
        QueueNotFound,
        QueueHandlerMissing,
        ConsumerAlreadyExists,
        WorkerNotFound,
        InvalidRoute,
    ],
}));
export const UpdateConsumerRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    consumerId: Schema.String.pipe(T.HttpPath("consumerId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    deadLetterQueue: Schema.optional(Schema.String),
    scriptName: Schema.optional(Schema.String),
    settings: Schema.optional(Schema.Struct({
        batchSize: Schema.optional(Schema.Number),
        maxConcurrency: Schema.optional(Schema.Number),
        maxRetries: Schema.optional(Schema.Number),
        maxWaitTimeMs: Schema.optional(Schema.Number),
        retryDelay: Schema.optional(Schema.Number),
    }).pipe(Schema.encodeKeys({
        batchSize: "batch_size",
        maxConcurrency: "max_concurrency",
        maxRetries: "max_retries",
        maxWaitTimeMs: "max_wait_time_ms",
        retryDelay: "retry_delay",
    }))),
    type: Schema.optional(Schema.Literal("worker")),
}).pipe(Schema.encodeKeys({
    deadLetterQueue: "dead_letter_queue",
    scriptName: "script_name",
    settings: "settings",
    type: "type",
}), T.Http({
    method: "PUT",
    path: "/accounts/{account_id}/queues/{queueId}/consumers/{consumerId}",
}));
export const UpdateConsumerResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Union([
    Schema.Struct({
        consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        settings: Schema.optional(Schema.Union([
            Schema.Struct({
                batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                batchSize: "batch_size",
                maxConcurrency: "max_concurrency",
                maxRetries: "max_retries",
                maxWaitTimeMs: "max_wait_time_ms",
                retryDelay: "retry_delay",
            })),
            Schema.Null,
        ])),
        type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
    }).pipe(Schema.encodeKeys({
        consumerId: "consumer_id",
        createdOn: "created_on",
        queueId: "queue_id",
        script: "script",
        settings: "settings",
        type: "type",
    })),
    Schema.Struct({
        consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        settings: Schema.optional(Schema.Union([
            Schema.Struct({
                batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                batchSize: "batch_size",
                maxRetries: "max_retries",
                retryDelay: "retry_delay",
                visibilityTimeoutMs: "visibility_timeout_ms",
            })),
            Schema.Null,
        ])),
        type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
    }).pipe(Schema.encodeKeys({
        consumerId: "consumer_id",
        createdOn: "created_on",
        queueId: "queue_id",
        settings: "settings",
        type: "type",
    })),
]).pipe(T.ResponsePath("result"));
export const updateConsumer = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateConsumerRequest,
    output: UpdateConsumerResponse,
    errors: [
        InvalidRequestBody,
        QueueNotFound,
        QueueHandlerMissing,
        ConsumerNotFound,
        WorkerNotFound,
        InvalidRoute,
    ],
}));
export const DeleteConsumerRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    consumerId: Schema.String.pipe(T.HttpPath("consumerId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/queues/{queueId}/consumers/{consumerId}",
}));
export const DeleteConsumerResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    errors: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        Schema.Null,
    ])),
    messages: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    success: Schema.optional(Schema.Union([Schema.Literal(true), Schema.Null])),
});
export const deleteConsumer = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteConsumerRequest,
    output: DeleteConsumerResponse,
    errors: [InvalidRequestBody, QueueNotFound, ConsumerNotFound, InvalidRoute],
}));
export const BulkPushMessagesRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    delaySeconds: Schema.optional(Schema.Number),
    messages: Schema.optional(Schema.Array(Schema.Union([
        Schema.Struct({
            body: Schema.optional(Schema.String),
            contentType: Schema.optional(Schema.Literal("text")),
            delaySeconds: Schema.optional(Schema.Number),
        }).pipe(Schema.encodeKeys({
            body: "body",
            contentType: "content_type",
            delaySeconds: "delay_seconds",
        })),
        Schema.Struct({
            body: Schema.optional(Schema.Unknown),
            contentType: Schema.optional(Schema.Literal("json")),
            delaySeconds: Schema.optional(Schema.Number),
        }).pipe(Schema.encodeKeys({
            body: "body",
            contentType: "content_type",
            delaySeconds: "delay_seconds",
        })),
    ]))),
}).pipe(Schema.encodeKeys({ delaySeconds: "delay_seconds", messages: "messages" }), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/queues/{queueId}/messages/batch",
}));
export const BulkPushMessagesResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    errors: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        Schema.Null,
    ])),
    messages: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    success: Schema.optional(Schema.Union([Schema.Literal(true), Schema.Null])),
});
export const bulkPushMessages = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: BulkPushMessagesRequest,
    output: BulkPushMessagesResponse,
    errors: [InvalidMessageBody, InvalidQueueId, InvalidRoute],
}));
export const PullMessageRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    batchSize: Schema.optional(Schema.Number),
    visibilityTimeoutMs: Schema.optional(Schema.Number),
}).pipe(Schema.encodeKeys({
    batchSize: "batch_size",
    visibilityTimeoutMs: "visibility_timeout_ms",
}), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/queues/{queueId}/messages/pull",
}));
export const PullMessageResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    messageBacklogCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    messages: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            attempts: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            body: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            leaseId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            metadata: Schema.optional(Schema.Union([Schema.Unknown, Schema.Null])),
            timestampMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            id: "id",
            attempts: "attempts",
            body: "body",
            leaseId: "lease_id",
            metadata: "metadata",
            timestampMs: "timestamp_ms",
        }))),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    messageBacklogCount: "message_backlog_count",
    messages: "messages",
}))
    .pipe(T.ResponsePath("result"));
export const pullMessage = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PullMessageRequest,
    output: PullMessageResponse,
    errors: [InvalidRequestBody, InvalidQueueId, QueueNotFound, InvalidRoute],
}));
export const PushMessageRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    body: Schema.optional(Schema.String),
    contentType: Schema.optional(Schema.Literal("text")),
    delaySeconds: Schema.optional(Schema.Number),
}).pipe(Schema.encodeKeys({
    body: "body",
    contentType: "content_type",
    delaySeconds: "delay_seconds",
}), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/queues/{queueId}/messages",
}));
export const PushMessageResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    errors: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        Schema.Null,
    ])),
    messages: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    success: Schema.optional(Schema.Union([Schema.Literal(true), Schema.Null])),
});
export const pushMessage = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PushMessageRequest,
    output: PushMessageResponse,
    errors: [InvalidMessageBody, InvalidQueueId, InvalidRoute],
}));
export const AckMessageRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    acks: Schema.optional(Schema.Array(Schema.Struct({
        leaseId: Schema.optional(Schema.String),
    }).pipe(Schema.encodeKeys({ leaseId: "lease_id" })))),
    retries: Schema.optional(Schema.Array(Schema.Struct({
        delaySeconds: Schema.optional(Schema.Number),
        leaseId: Schema.optional(Schema.String),
    }).pipe(Schema.encodeKeys({
        delaySeconds: "delay_seconds",
        leaseId: "lease_id",
    })))),
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/queues/{queueId}/messages/ack",
}));
export const AckMessageResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    ackCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    retryCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    warnings: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const ackMessage = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: AckMessageRequest,
    output: AckMessageResponse,
    errors: [InvalidRequestBody, InvalidQueueId, QueueNotFound, InvalidRoute],
}));
export const StartPurgeRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    deleteMessagesPermanently: Schema.optional(Schema.Boolean),
}).pipe(Schema.encodeKeys({
    deleteMessagesPermanently: "delete_messages_permanently",
}), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/queues/{queueId}/purge",
}));
export const StartPurgeResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    consumers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxConcurrency: "max_concurrency",
                        maxRetries: "max_retries",
                        maxWaitTimeMs: "max_wait_time_ms",
                        retryDelay: "retry_delay",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                script: "script",
                settings: "settings",
                type: "type",
            })),
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxRetries: "max_retries",
                        retryDelay: "retry_delay",
                        visibilityTimeoutMs: "visibility_timeout_ms",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                settings: "settings",
                type: "type",
            })),
        ])),
        Schema.Null,
    ])),
    consumersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modifiedOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    producers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }),
            Schema.Struct({
                bucketName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("r2_bucket"), Schema.Null])),
            }).pipe(Schema.encodeKeys({ bucketName: "bucket_name", type: "type" })),
        ])),
        Schema.Null,
    ])),
    producersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    queueName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    settings: Schema.optional(Schema.Union([
        Schema.Struct({
            deliveryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            deliveryPaused: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            messageRetentionPeriod: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            deliveryDelay: "delivery_delay",
            deliveryPaused: "delivery_paused",
            messageRetentionPeriod: "message_retention_period",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    consumers: "consumers",
    consumersTotalCount: "consumers_total_count",
    createdOn: "created_on",
    modifiedOn: "modified_on",
    producers: "producers",
    producersTotalCount: "producers_total_count",
    queueId: "queue_id",
    queueName: "queue_name",
    settings: "settings",
}))
    .pipe(T.ResponsePath("result"));
export const startPurge = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: StartPurgeRequest,
    output: StartPurgeResponse,
    errors: [InvalidQueueId, InvalidRoute],
}));
export const StatusPurgeRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/queues/{queueId}/purge",
}));
export const StatusPurgeResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    completed: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    startedAt: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({ completed: "completed", startedAt: "started_at" }))
    .pipe(T.ResponsePath("result"));
export const statusPurge = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: StatusPurgeRequest,
    output: StatusPurgeResponse,
    errors: [InvalidQueueId, InvalidRoute],
}));
export const GetQueueRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/queues/{queueId}" }));
export const GetQueueResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    consumers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxConcurrency: "max_concurrency",
                        maxRetries: "max_retries",
                        maxWaitTimeMs: "max_wait_time_ms",
                        retryDelay: "retry_delay",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                script: "script",
                settings: "settings",
                type: "type",
            })),
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxRetries: "max_retries",
                        retryDelay: "retry_delay",
                        visibilityTimeoutMs: "visibility_timeout_ms",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                settings: "settings",
                type: "type",
            })),
        ])),
        Schema.Null,
    ])),
    consumersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modifiedOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    producers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }),
            Schema.Struct({
                bucketName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("r2_bucket"), Schema.Null])),
            }).pipe(Schema.encodeKeys({ bucketName: "bucket_name", type: "type" })),
        ])),
        Schema.Null,
    ])),
    producersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    queueName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    settings: Schema.optional(Schema.Union([
        Schema.Struct({
            deliveryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            deliveryPaused: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            messageRetentionPeriod: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            deliveryDelay: "delivery_delay",
            deliveryPaused: "delivery_paused",
            messageRetentionPeriod: "message_retention_period",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    consumers: "consumers",
    consumersTotalCount: "consumers_total_count",
    createdOn: "created_on",
    modifiedOn: "modified_on",
    producers: "producers",
    producersTotalCount: "producers_total_count",
    queueId: "queue_id",
    queueName: "queue_name",
    settings: "settings",
}))
    .pipe(T.ResponsePath("result"));
export const getQueue = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetQueueRequest,
    output: GetQueueResponse,
    errors: [QueueNotFound, InvalidRoute],
}));
export const ListQueuesRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/queues" }));
export const ListQueuesResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        consumers: Schema.optional(Schema.Union([
            Schema.Array(Schema.Union([
                Schema.Struct({
                    consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    settings: Schema.optional(Schema.Union([
                        Schema.Struct({
                            batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                            maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                            maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                            maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                            retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        }).pipe(Schema.encodeKeys({
                            batchSize: "batch_size",
                            maxConcurrency: "max_concurrency",
                            maxRetries: "max_retries",
                            maxWaitTimeMs: "max_wait_time_ms",
                            retryDelay: "retry_delay",
                        })),
                        Schema.Null,
                    ])),
                    type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
                }).pipe(Schema.encodeKeys({
                    consumerId: "consumer_id",
                    createdOn: "created_on",
                    queueId: "queue_id",
                    script: "script",
                    settings: "settings",
                    type: "type",
                })),
                Schema.Struct({
                    consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    settings: Schema.optional(Schema.Union([
                        Schema.Struct({
                            batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                            maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                            retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                            visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        }).pipe(Schema.encodeKeys({
                            batchSize: "batch_size",
                            maxRetries: "max_retries",
                            retryDelay: "retry_delay",
                            visibilityTimeoutMs: "visibility_timeout_ms",
                        })),
                        Schema.Null,
                    ])),
                    type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
                }).pipe(Schema.encodeKeys({
                    consumerId: "consumer_id",
                    createdOn: "created_on",
                    queueId: "queue_id",
                    settings: "settings",
                    type: "type",
                })),
            ])),
            Schema.Null,
        ])),
        consumersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        modifiedOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        producers: Schema.optional(Schema.Union([
            Schema.Array(Schema.Union([
                Schema.Struct({
                    script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
                }),
                Schema.Struct({
                    bucketName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                    type: Schema.optional(Schema.Union([Schema.Literal("r2_bucket"), Schema.Null])),
                }).pipe(Schema.encodeKeys({ bucketName: "bucket_name", type: "type" })),
            ])),
            Schema.Null,
        ])),
        producersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        queueName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        settings: Schema.optional(Schema.Union([
            Schema.Struct({
                deliveryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                deliveryPaused: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
                messageRetentionPeriod: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                deliveryDelay: "delivery_delay",
                deliveryPaused: "delivery_paused",
                messageRetentionPeriod: "message_retention_period",
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        consumers: "consumers",
        consumersTotalCount: "consumers_total_count",
        createdOn: "created_on",
        modifiedOn: "modified_on",
        producers: "producers",
        producersTotalCount: "producers_total_count",
        queueId: "queue_id",
        queueName: "queue_name",
        settings: "settings",
    }))),
});
export const listQueues = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListQueuesRequest,
    output: ListQueuesResponse,
    errors: [InvalidRoute],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const CreateQueueRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    queueName: Schema.String,
}).pipe(Schema.encodeKeys({ queueName: "queue_name" }), T.Http({ method: "POST", path: "/accounts/{account_id}/queues" }));
export const CreateQueueResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    consumers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxConcurrency: "max_concurrency",
                        maxRetries: "max_retries",
                        maxWaitTimeMs: "max_wait_time_ms",
                        retryDelay: "retry_delay",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                script: "script",
                settings: "settings",
                type: "type",
            })),
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxRetries: "max_retries",
                        retryDelay: "retry_delay",
                        visibilityTimeoutMs: "visibility_timeout_ms",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                settings: "settings",
                type: "type",
            })),
        ])),
        Schema.Null,
    ])),
    consumersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modifiedOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    producers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }),
            Schema.Struct({
                bucketName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("r2_bucket"), Schema.Null])),
            }).pipe(Schema.encodeKeys({ bucketName: "bucket_name", type: "type" })),
        ])),
        Schema.Null,
    ])),
    producersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    queueName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    settings: Schema.optional(Schema.Union([
        Schema.Struct({
            deliveryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            deliveryPaused: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            messageRetentionPeriod: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            deliveryDelay: "delivery_delay",
            deliveryPaused: "delivery_paused",
            messageRetentionPeriod: "message_retention_period",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    consumers: "consumers",
    consumersTotalCount: "consumers_total_count",
    createdOn: "created_on",
    modifiedOn: "modified_on",
    producers: "producers",
    producersTotalCount: "producers_total_count",
    queueId: "queue_id",
    queueName: "queue_name",
    settings: "settings",
}))
    .pipe(T.ResponsePath("result"));
export const createQueue = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateQueueRequest,
    output: CreateQueueResponse,
    errors: [QueueAlreadyExists, InvalidQueueName, InvalidRoute],
}));
export const UpdateQueueRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    queueName: Schema.optional(Schema.String),
    settings: Schema.optional(Schema.Struct({
        deliveryDelay: Schema.optional(Schema.Number),
        deliveryPaused: Schema.optional(Schema.Boolean),
        messageRetentionPeriod: Schema.optional(Schema.Number),
    }).pipe(Schema.encodeKeys({
        deliveryDelay: "delivery_delay",
        deliveryPaused: "delivery_paused",
        messageRetentionPeriod: "message_retention_period",
    }))),
}).pipe(Schema.encodeKeys({ queueName: "queue_name", settings: "settings" }), T.Http({ method: "PUT", path: "/accounts/{account_id}/queues/{queueId}" }));
export const UpdateQueueResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    consumers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxConcurrency: "max_concurrency",
                        maxRetries: "max_retries",
                        maxWaitTimeMs: "max_wait_time_ms",
                        retryDelay: "retry_delay",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                script: "script",
                settings: "settings",
                type: "type",
            })),
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxRetries: "max_retries",
                        retryDelay: "retry_delay",
                        visibilityTimeoutMs: "visibility_timeout_ms",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                settings: "settings",
                type: "type",
            })),
        ])),
        Schema.Null,
    ])),
    consumersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modifiedOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    producers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }),
            Schema.Struct({
                bucketName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("r2_bucket"), Schema.Null])),
            }).pipe(Schema.encodeKeys({ bucketName: "bucket_name", type: "type" })),
        ])),
        Schema.Null,
    ])),
    producersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    queueName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    settings: Schema.optional(Schema.Union([
        Schema.Struct({
            deliveryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            deliveryPaused: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            messageRetentionPeriod: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            deliveryDelay: "delivery_delay",
            deliveryPaused: "delivery_paused",
            messageRetentionPeriod: "message_retention_period",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    consumers: "consumers",
    consumersTotalCount: "consumers_total_count",
    createdOn: "created_on",
    modifiedOn: "modified_on",
    producers: "producers",
    producersTotalCount: "producers_total_count",
    queueId: "queue_id",
    queueName: "queue_name",
    settings: "settings",
}))
    .pipe(T.ResponsePath("result"));
export const updateQueue = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateQueueRequest,
    output: UpdateQueueResponse,
    errors: [InvalidQueueName, QueueNotFound, InvalidRoute],
}));
export const PatchQueueRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    queueName: Schema.optional(Schema.String),
    settings: Schema.optional(Schema.Struct({
        deliveryDelay: Schema.optional(Schema.Number),
        deliveryPaused: Schema.optional(Schema.Boolean),
        messageRetentionPeriod: Schema.optional(Schema.Number),
    }).pipe(Schema.encodeKeys({
        deliveryDelay: "delivery_delay",
        deliveryPaused: "delivery_paused",
        messageRetentionPeriod: "message_retention_period",
    }))),
}).pipe(Schema.encodeKeys({ queueName: "queue_name", settings: "settings" }), T.Http({ method: "PATCH", path: "/accounts/{account_id}/queues/{queueId}" }));
export const PatchQueueResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    consumers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxConcurrency: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxWaitTimeMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxConcurrency: "max_concurrency",
                        maxRetries: "max_retries",
                        maxWaitTimeMs: "max_wait_time_ms",
                        retryDelay: "retry_delay",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                script: "script",
                settings: "settings",
                type: "type",
            })),
            Schema.Struct({
                consumerId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                settings: Schema.optional(Schema.Union([
                    Schema.Struct({
                        batchSize: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        maxRetries: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        retryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        visibilityTimeoutMs: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                    }).pipe(Schema.encodeKeys({
                        batchSize: "batch_size",
                        maxRetries: "max_retries",
                        retryDelay: "retry_delay",
                        visibilityTimeoutMs: "visibility_timeout_ms",
                    })),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([Schema.Literal("http_pull"), Schema.Null])),
            }).pipe(Schema.encodeKeys({
                consumerId: "consumer_id",
                createdOn: "created_on",
                queueId: "queue_id",
                settings: "settings",
                type: "type",
            })),
        ])),
        Schema.Null,
    ])),
    consumersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    createdOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modifiedOn: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    producers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Union([
            Schema.Struct({
                script: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("worker"), Schema.Null])),
            }),
            Schema.Struct({
                bucketName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("r2_bucket"), Schema.Null])),
            }).pipe(Schema.encodeKeys({ bucketName: "bucket_name", type: "type" })),
        ])),
        Schema.Null,
    ])),
    producersTotalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    queueId: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    queueName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    settings: Schema.optional(Schema.Union([
        Schema.Struct({
            deliveryDelay: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            deliveryPaused: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            messageRetentionPeriod: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            deliveryDelay: "delivery_delay",
            deliveryPaused: "delivery_paused",
            messageRetentionPeriod: "message_retention_period",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    consumers: "consumers",
    consumersTotalCount: "consumers_total_count",
    createdOn: "created_on",
    modifiedOn: "modified_on",
    producers: "producers",
    producersTotalCount: "producers_total_count",
    queueId: "queue_id",
    queueName: "queue_name",
    settings: "settings",
}))
    .pipe(T.ResponsePath("result"));
export const patchQueue = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PatchQueueRequest,
    output: PatchQueueResponse,
    errors: [QueueNotFound, InvalidRoute],
}));
export const DeleteQueueRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    queueId: Schema.String.pipe(T.HttpPath("queueId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "DELETE", path: "/accounts/{account_id}/queues/{queueId}" }));
export const DeleteQueueResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    errors: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        Schema.Null,
    ])),
    messages: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    success: Schema.optional(Schema.Union([Schema.Literal(true), Schema.Null])),
});
export const deleteQueue = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteQueueRequest,
    output: DeleteQueueResponse,
    errors: [QueueNotFound, InvalidRoute],
}));
export const GetSubscriptionRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    subscriptionId: Schema.String.pipe(T.HttpPath("subscriptionId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/event_subscriptions/subscriptions/{subscriptionId}",
}));
export const GetSubscriptionResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdAt: Schema.String,
    destination: Schema.Struct({
        queueId: Schema.String,
        type: Schema.Literal("queues.queue"),
    }).pipe(Schema.encodeKeys({ queueId: "queue_id", type: "type" })),
    enabled: Schema.Boolean,
    events: Schema.Array(Schema.String),
    modifiedAt: Schema.String,
    name: Schema.String,
    source: Schema.Union([
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("images"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("kv"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("r2"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("superSlurper"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("vectorize"), Schema.Null])),
        }),
        Schema.Struct({
            modelName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            type: Schema.optional(Schema.Union([Schema.Literal("workersAi.model"), Schema.Null])),
        }).pipe(Schema.encodeKeys({ modelName: "model_name", type: "type" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workersBuilds.worker"), Schema.Null])),
            workerName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workerName: "worker_name" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workflows.workflow"), Schema.Null])),
            workflowName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workflowName: "workflow_name" })),
    ]),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdAt: "created_at",
    destination: "destination",
    enabled: "enabled",
    events: "events",
    modifiedAt: "modified_at",
    name: "name",
    source: "source",
}))
    .pipe(T.ResponsePath("result"));
export const getSubscription = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetSubscriptionRequest,
    output: GetSubscriptionResponse,
    errors: [UnrecognizedEventType],
}));
export const ListSubscriptionsRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    page: Schema.optional(Schema.Number).pipe(T.HttpQuery("page")),
    perPage: Schema.optional(Schema.Number).pipe(T.HttpQuery("per_page")),
    direction: Schema.optional(Schema.Literals(["asc", "desc"])).pipe(T.HttpQuery("direction")),
    order: Schema.optional(Schema.Literals(["created_at", "name", "enabled", "source"])).pipe(T.HttpQuery("order")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/event_subscriptions/subscriptions",
}));
export const ListSubscriptionsResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        id: Schema.String,
        createdAt: Schema.String,
        destination: Schema.Struct({
            queueId: Schema.String,
            type: Schema.Literal("queues.queue"),
        }).pipe(Schema.encodeKeys({ queueId: "queue_id", type: "type" })),
        enabled: Schema.Boolean,
        events: Schema.Array(Schema.String),
        modifiedAt: Schema.String,
        name: Schema.String,
        source: Schema.Union([
            Schema.Struct({
                type: Schema.optional(Schema.Union([Schema.Literal("images"), Schema.Null])),
            }),
            Schema.Struct({
                type: Schema.optional(Schema.Union([Schema.Literal("kv"), Schema.Null])),
            }),
            Schema.Struct({
                type: Schema.optional(Schema.Union([Schema.Literal("r2"), Schema.Null])),
            }),
            Schema.Struct({
                type: Schema.optional(Schema.Union([Schema.Literal("superSlurper"), Schema.Null])),
            }),
            Schema.Struct({
                type: Schema.optional(Schema.Union([Schema.Literal("vectorize"), Schema.Null])),
            }),
            Schema.Struct({
                modelName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                type: Schema.optional(Schema.Union([Schema.Literal("workersAi.model"), Schema.Null])),
            }).pipe(Schema.encodeKeys({ modelName: "model_name", type: "type" })),
            Schema.Struct({
                type: Schema.optional(Schema.Union([
                    Schema.Literal("workersBuilds.worker"),
                    Schema.Null,
                ])),
                workerName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            }).pipe(Schema.encodeKeys({ type: "type", workerName: "worker_name" })),
            Schema.Struct({
                type: Schema.optional(Schema.Union([Schema.Literal("workflows.workflow"), Schema.Null])),
                workflowName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            }).pipe(Schema.encodeKeys({ type: "type", workflowName: "workflow_name" })),
        ]),
    }).pipe(Schema.encodeKeys({
        id: "id",
        createdAt: "created_at",
        destination: "destination",
        enabled: "enabled",
        events: "events",
        modifiedAt: "modified_at",
        name: "name",
        source: "source",
    }))),
    resultInfo: Schema.optional(Schema.Union([
        Schema.Struct({
            count: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            page: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            perPage: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            totalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            count: "count",
            page: "page",
            perPage: "per_page",
            totalCount: "total_count",
        })),
        Schema.Null,
    ])),
}).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" }));
export const listSubscriptions = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListSubscriptionsRequest,
    output: ListSubscriptionsResponse,
    errors: [],
    pagination: {
        mode: "page",
        inputToken: "page",
        outputToken: "resultInfo.page",
        items: "result",
        pageSize: "perPage",
    },
}));
export const CreateSubscriptionRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    destination: Schema.optional(Schema.Struct({
        queueId: Schema.String,
        type: Schema.Literal("queues.queue"),
    }).pipe(Schema.encodeKeys({ queueId: "queue_id", type: "type" }))),
    enabled: Schema.optional(Schema.Boolean),
    events: Schema.optional(Schema.Array(Schema.String)),
    name: Schema.optional(Schema.String),
    source: Schema.optional(Schema.Union([
        Schema.Struct({
            type: Schema.optional(Schema.Literal("images")),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Literal("kv")),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Literal("r2")),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Literal("superSlurper")),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Literal("vectorize")),
        }),
        Schema.Struct({
            modelName: Schema.optional(Schema.String),
            type: Schema.optional(Schema.Literal("workersAi.model")),
        }).pipe(Schema.encodeKeys({ modelName: "model_name", type: "type" })),
        Schema.Struct({
            type: Schema.optional(Schema.Literal("workersBuilds.worker")),
            workerName: Schema.optional(Schema.String),
        }).pipe(Schema.encodeKeys({ type: "type", workerName: "worker_name" })),
        Schema.Struct({
            type: Schema.optional(Schema.Literal("workflows.workflow")),
            workflowName: Schema.optional(Schema.String),
        }).pipe(Schema.encodeKeys({ type: "type", workflowName: "workflow_name" })),
    ])),
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/event_subscriptions/subscriptions",
}));
export const CreateSubscriptionResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdAt: Schema.String,
    destination: Schema.Struct({
        queueId: Schema.String,
        type: Schema.Literal("queues.queue"),
    }).pipe(Schema.encodeKeys({ queueId: "queue_id", type: "type" })),
    enabled: Schema.Boolean,
    events: Schema.Array(Schema.String),
    modifiedAt: Schema.String,
    name: Schema.String,
    source: Schema.Union([
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("images"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("kv"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("r2"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("superSlurper"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("vectorize"), Schema.Null])),
        }),
        Schema.Struct({
            modelName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            type: Schema.optional(Schema.Union([Schema.Literal("workersAi.model"), Schema.Null])),
        }).pipe(Schema.encodeKeys({ modelName: "model_name", type: "type" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workersBuilds.worker"), Schema.Null])),
            workerName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workerName: "worker_name" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workflows.workflow"), Schema.Null])),
            workflowName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workflowName: "workflow_name" })),
    ]),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdAt: "created_at",
    destination: "destination",
    enabled: "enabled",
    events: "events",
    modifiedAt: "modified_at",
    name: "name",
    source: "source",
}))
    .pipe(T.ResponsePath("result"));
export const createSubscription = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateSubscriptionRequest,
    output: CreateSubscriptionResponse,
    errors: [UnrecognizedEventType],
}));
export const PatchSubscriptionRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    subscriptionId: Schema.String.pipe(T.HttpPath("subscriptionId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    destination: Schema.optional(Schema.Struct({
        queueId: Schema.String,
        type: Schema.Literal("queues.queue"),
    }).pipe(Schema.encodeKeys({ queueId: "queue_id", type: "type" }))),
    enabled: Schema.optional(Schema.Boolean),
    events: Schema.optional(Schema.Array(Schema.String)),
    name: Schema.optional(Schema.String),
}).pipe(T.Http({
    method: "PATCH",
    path: "/accounts/{account_id}/event_subscriptions/subscriptions/{subscriptionId}",
}));
export const PatchSubscriptionResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdAt: Schema.String,
    destination: Schema.Struct({
        queueId: Schema.String,
        type: Schema.Literal("queues.queue"),
    }).pipe(Schema.encodeKeys({ queueId: "queue_id", type: "type" })),
    enabled: Schema.Boolean,
    events: Schema.Array(Schema.String),
    modifiedAt: Schema.String,
    name: Schema.String,
    source: Schema.Union([
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("images"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("kv"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("r2"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("superSlurper"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("vectorize"), Schema.Null])),
        }),
        Schema.Struct({
            modelName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            type: Schema.optional(Schema.Union([Schema.Literal("workersAi.model"), Schema.Null])),
        }).pipe(Schema.encodeKeys({ modelName: "model_name", type: "type" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workersBuilds.worker"), Schema.Null])),
            workerName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workerName: "worker_name" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workflows.workflow"), Schema.Null])),
            workflowName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workflowName: "workflow_name" })),
    ]),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdAt: "created_at",
    destination: "destination",
    enabled: "enabled",
    events: "events",
    modifiedAt: "modified_at",
    name: "name",
    source: "source",
}))
    .pipe(T.ResponsePath("result"));
export const patchSubscription = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PatchSubscriptionRequest,
    output: PatchSubscriptionResponse,
    errors: [UnrecognizedEventType],
}));
export const DeleteSubscriptionRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    subscriptionId: Schema.String.pipe(T.HttpPath("subscriptionId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/event_subscriptions/subscriptions/{subscriptionId}",
}));
export const DeleteSubscriptionResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdAt: Schema.String,
    destination: Schema.Struct({
        queueId: Schema.String,
        type: Schema.Literal("queues.queue"),
    }).pipe(Schema.encodeKeys({ queueId: "queue_id", type: "type" })),
    enabled: Schema.Boolean,
    events: Schema.Array(Schema.String),
    modifiedAt: Schema.String,
    name: Schema.String,
    source: Schema.Union([
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("images"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("kv"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("r2"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("superSlurper"), Schema.Null])),
        }),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("vectorize"), Schema.Null])),
        }),
        Schema.Struct({
            modelName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            type: Schema.optional(Schema.Union([Schema.Literal("workersAi.model"), Schema.Null])),
        }).pipe(Schema.encodeKeys({ modelName: "model_name", type: "type" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workersBuilds.worker"), Schema.Null])),
            workerName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workerName: "worker_name" })),
        Schema.Struct({
            type: Schema.optional(Schema.Union([Schema.Literal("workflows.workflow"), Schema.Null])),
            workflowName: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({ type: "type", workflowName: "workflow_name" })),
    ]),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdAt: "created_at",
    destination: "destination",
    enabled: "enabled",
    events: "events",
    modifiedAt: "modified_at",
    name: "name",
    source: "source",
}))
    .pipe(T.ResponsePath("result"));
export const deleteSubscription = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteSubscriptionRequest,
    output: DeleteSubscriptionResponse,
    errors: [UnrecognizedEventType],
}));
//# sourceMappingURL=queues.js.map