// AUTO-GENERATED by scripts/generate.ts from .generated-specs. Do not edit. import * as S from "@distilled.cloud/core/schema"; import * as API from "@distilled.cloud/core/api"; import * as T from "../traits.ts"; import { CloudflareProtocol, CloudflarePaginatedProtocol, type CloudflareOpError, type CloudflareOpContext, } from "../protocol.ts"; import { cloudflarePaginate, ResultInfo } from "../pagination.ts"; import { CloudflareError, CloudflareRateLimited } from "../errors.ts"; import * as Retry from "../retry.ts"; export type { CloudflareOpError, CloudflareOpContext }; /** Fallback camelCase→wire mapping for opaque content (mined from the distilled SDK). */ const KEY_DICTIONARY: Record> = { perPage: "per_page", resultInfo: "result_info", totalCount: "total_count", useSqlite: "use_sqlite", }; export class InvalidIdentifier extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("InvalidIdentifier", { code: S.Number, message: S.String, }), [{ code: 7003 }], ) {} export class MalformedParameter extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("MalformedParameter", { code: S.Number, message: S.String, }), [{ code: 10077 }], ) {} export class NamespaceNotFound extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("NamespaceNotFound", { code: S.Number, message: S.String, }), [{ code: 10066 }], ) {} export interface ListNamespaceObjectsRequest { /** Identifier. */ accountId: string; /** ID of the namespace. */ id: string; /** Opaque token indicating the position from which to continue when requesting the next set of records. A valid value for the cursor can be obtained from the cursors object in the result_info structure. */ cursor?: string; /** The number of objects to return. The cursor attribute may be used to iterate over the next batch of objects if there are more than the limit. */ limit?: number; } export const ListNamespaceObjectsRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), id: S.String.pipe(T.Label()), cursor: S.optional(S.String.pipe(T.Query())), limit: S.optional(S.Number.pipe(T.Query())), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListNamespaceObjectsRequest", }) as any as S.Schema; export interface NamespacesObjectsListResultItem { /** ID of the Durable Object. */ id?: string | null; /** Whether the Durable Object has stored data. */ hasStoredData?: boolean | null; } export const NamespacesObjectsListResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ id: S.optional(S.NullOr(S.String)), hasStoredData: S.optional(S.NullOr(S.Boolean)), }), ).annotate({ identifier: "NamespacesObjectsListResultItem", }) as any as S.Schema; export type NamespacesObjectsListResultList = Array; export const NamespacesObjectsListResultList = /*@__PURE__*/ S.Array( NamespacesObjectsListResultItem, ) as any as S.Schema; export interface ListNamespaceObjectsResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: NamespacesObjectsListResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const ListNamespaceObjectsResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: NamespacesObjectsListResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListNamespaceObjectsResponse", }) as any as S.Schema; export interface ListNamespacesRequest { /** Identifier. */ accountId: string; /** Current page. */ page?: number; /** Items per-page. */ perPage?: number; } export const ListNamespacesRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), page: S.optional(S.Number.pipe(T.Query())), perPage: S.optional(S.Number.pipe(T.Query("per_page"))), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/workers/durable_objects/namespaces", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListNamespacesRequest", }) as any as S.Schema; export interface NamespacesListResultItem { id?: string | null; class?: string | null; name?: string | null; script?: string | null; useSqlite?: boolean | null; } export const NamespacesListResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ id: S.optional(S.NullOr(S.String)), class: S.optional(S.NullOr(S.String)), name: S.optional(S.NullOr(S.String)), script: S.optional(S.NullOr(S.String)), useSqlite: S.optional(S.NullOr(S.Boolean).pipe(T.Body("use_sqlite"))), }), ).annotate({ identifier: "NamespacesListResultItem", }) as any as S.Schema; export type NamespacesListResultList = Array; export const NamespacesListResultList = /*@__PURE__*/ S.Array( NamespacesListResultItem, ) as any as S.Schema; export interface ListNamespacesResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: NamespacesListResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const ListNamespacesResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: NamespacesListResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListNamespacesResponse", }) as any as S.Schema; export type ListNamespaceObjectsError = | NamespaceNotFound | InvalidIdentifier | MalformedParameter | CloudflareOpError; /** Returns the Durable Objects in a given namespace. */ export const listNamespaceObjects: API.PaginatedOperationMethod< ListNamespaceObjectsRequest, ListNamespaceObjectsResponse, ListNamespaceObjectsError, CloudflareOpContext, NamespacesObjectsListResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: ListNamespaceObjectsRequest, output: ListNamespaceObjectsResponse, errors: [ NamespaceNotFound, InvalidIdentifier, MalformedParameter, CloudflareRateLimited, CloudflareError, ], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "cursor", inputToken: "cursor", outputToken: "resultInfo.cursors.after", items: "result", } as const, }), cloudflarePaginate, ) as any; export type ListNamespacesError = InvalidIdentifier | CloudflareOpError; /** Returns the Durable Object namespaces owned by an account. */ export const listNamespaces: API.PaginatedOperationMethod< ListNamespacesRequest, ListNamespacesResponse, ListNamespacesError, CloudflareOpContext, NamespacesListResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: ListNamespacesRequest, output: ListNamespacesResponse, errors: [InvalidIdentifier, CloudflareRateLimited, CloudflareError], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "resultInfo.page", items: "result", pageSize: "perPage", } as const, }), cloudflarePaginate, ) as any;