// 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> = { atBookmark: "at_bookmark", changedDb: "changed_db", createdAt: "created_at", currentBookmark: "current_bookmark", dumpOptions: "dump_options", fileSize: "file_size", finalBookmark: "final_bookmark", lastRowId: "last_row_id", noData: "no_data", noSchema: "no_schema", numQueries: "num_queries", numTables: "num_tables", outputFormat: "output_format", perPage: "per_page", previousBookmark: "previous_bookmark", primaryLocationHint: "primary_location_hint", readReplication: "read_replication", resultInfo: "result_info", rowsRead: "rows_read", rowsWritten: "rows_written", servedByColo: "served_by_colo", servedByPrimary: "served_by_primary", servedByRegion: "served_by_region", signedUrl: "signed_url", sizeAfter: "size_after", sqlDurationMs: "sql_duration_ms", totalCount: "total_count", uploadUrl: "upload_url", }; export class DatabaseAlreadyExists extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()( "DatabaseAlreadyExists", { code: S.Number, message: S.String, }, ), [{ code: 7502 }], ) {} export class DatabaseNotFound extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("DatabaseNotFound", { code: S.Number, message: S.String, }), [{ code: 7404 }], ) {} export class InternalError extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("InternalError", { code: S.Number, message: S.String, }), [{ code: 7500 }], ) {} export class InvalidObjectIdentifier extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()( "InvalidObjectIdentifier", { code: S.Number, message: S.String, }, ), [{ code: 7003 }], ) {} export class InvalidProperty extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("InvalidProperty", { code: S.Number, message: S.String, }), [{ code: 7400 }], ) {} export class InvalidRequest extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("InvalidRequest", { code: S.Number, message: S.String, }), [{ code: 7400 }], ) {} export class NoHistoryAvailable extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("NoHistoryAvailable", { code: S.Number, message: S.String, }), [{ code: 7500 }], ) {} export class TimestampTooOld extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("TimestampTooOld", { code: S.Number, message: S.String, }), [{ code: 7400 }], ) {} export class UnknownError extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("UnknownError", { code: S.Number, message: S.String, }), [{ code: 0 }], ) {} export type DatabaseCreateRequestJurisdiction = "eu" | "fedramp"; export const DatabaseCreateRequestJurisdiction = /*@__PURE__*/ S.String; export type DatabaseCreateRequestPrimaryLocationHint = | "wnam" | "enam" | "weur" | "eeur" | "apac" | "oc"; export const DatabaseCreateRequestPrimaryLocationHint = /*@__PURE__*/ S.String; export type DatabaseCreateRequestReadReplicationMode = "auto" | "disabled"; export const DatabaseCreateRequestReadReplicationMode = /*@__PURE__*/ S.String; export interface DatabaseCreateRequestReadReplication { /** The read replication mode for the database. Use 'auto' to create replicas and allow D1 automatically place them around the world, or 'disabled' to not use any database replicas (it can take a few hours for all replicas to be deleted). */ mode: DatabaseCreateRequestReadReplicationMode | (string & {}); } export const DatabaseCreateRequestReadReplication = /*@__PURE__*/ S.suspend( () => S.Struct({ mode: DatabaseCreateRequestReadReplicationMode, }), ).annotate({ identifier: "DatabaseCreateRequestReadReplication", }) as any as S.Schema; export interface CreateDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database name. */ name: string; /** Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored. */ jurisdiction?: DatabaseCreateRequestJurisdiction | (string & {}); /** Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. */ primaryLocationHint?: | DatabaseCreateRequestPrimaryLocationHint | (string & {}); /** Configuration for D1 read replication. */ readReplication?: DatabaseCreateRequestReadReplication; } export const CreateDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), name: S.String, jurisdiction: S.optional(DatabaseCreateRequestJurisdiction), primaryLocationHint: S.optional( DatabaseCreateRequestPrimaryLocationHint.pipe( T.Body("primary_location_hint"), ), ), readReplication: S.optional( DatabaseCreateRequestReadReplication.pipe(T.Body("read_replication")), ), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/d1/database", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateDatabaseRequest", }) as any as S.Schema; export type DatabaseCreateResponseJurisdiction = "eu" | "fedramp"; export const DatabaseCreateResponseJurisdiction = /*@__PURE__*/ S.String; export type DatabaseCreateResponseReadReplicationMode = "auto" | "disabled"; export const DatabaseCreateResponseReadReplicationMode = /*@__PURE__*/ S.String; export interface DatabaseCreateResponseReadReplication { /** The read replication mode for the database. Mode 'auto' denotes that D1 creates replicas and automatically places them around the world. Mode 'disabled' denotes that no database replicas are used. */ mode: DatabaseCreateResponseReadReplicationMode; } export const DatabaseCreateResponseReadReplication = /*@__PURE__*/ S.suspend( () => S.Struct({ mode: DatabaseCreateResponseReadReplicationMode, }), ).annotate({ identifier: "DatabaseCreateResponseReadReplication", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface CreateDatabaseResponse { /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdAt?: string | null; /** The D1 database's size, in bytes. */ fileSize?: number | null; /** Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored. */ jurisdiction?: DatabaseCreateResponseJurisdiction | null; /** D1 database name. */ name?: string | null; numTables?: number | null; /** Configuration for D1 read replication. */ readReplication?: DatabaseCreateResponseReadReplication | null; /** D1 database identifier (UUID). */ uuid?: string | null; version?: string | null; } export const CreateDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ createdAt: S.optional(S.NullOr(S.String).pipe(T.Body("created_at"))), fileSize: S.optional(S.NullOr(S.Number).pipe(T.Body("file_size"))), jurisdiction: S.optional(S.NullOr(DatabaseCreateResponseJurisdiction)), name: S.optional(S.NullOr(S.String)), numTables: S.optional(S.NullOr(S.Number).pipe(T.Body("num_tables"))), readReplication: S.optional( S.NullOr(DatabaseCreateResponseReadReplication).pipe( T.Body("read_replication"), ), ), uuid: S.optional(S.NullOr(S.String)), version: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateDatabaseResponse", }) as any as S.Schema; export interface DeleteDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; } export const DeleteDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), }) .pipe( T.Http({ method: "DELETE", uri: "/accounts/{account_id}/d1/database/{database_id}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteDatabaseRequest", }) as any as S.Schema; export type DeleteDatabaseResponse = unknown; export const DeleteDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Unknown.pipe(T.EnvelopePayloadRoot(), T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteDatabaseResponse", }) as any as S.Schema; export type DatabaseExportRequestOutputFormat = "polling"; export const DatabaseExportRequestOutputFormat = /*@__PURE__*/ S.String; export type DatabaseExportRequestDumpOptionsTablesList = Array; export const DatabaseExportRequestDumpOptionsTablesList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export interface DatabaseExportRequestDumpOptions { /** Export only the table definitions, not their contents */ noData?: boolean; /** Export only each table's contents, not its definition */ noSchema?: boolean; /** Filter the export to just one or more tables. Passing an empty array is the same as not passing anything and means: export all tables. */ tables?: DatabaseExportRequestDumpOptionsTablesList; } export const DatabaseExportRequestDumpOptions = /*@__PURE__*/ S.suspend(() => S.Struct({ noData: S.optional(S.Boolean.pipe(T.Body("no_data"))), noSchema: S.optional(S.Boolean.pipe(T.Body("no_schema"))), tables: S.optional(DatabaseExportRequestDumpOptionsTablesList), }), ).annotate({ identifier: "DatabaseExportRequestDumpOptions", }) as any as S.Schema; export interface ExportDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** Specifies that you will poll this endpoint until the export completes */ outputFormat: DatabaseExportRequestOutputFormat | (string & {}); /** To poll an in-progress export, provide the current bookmark (returned by your first polling response) */ currentBookmark?: string; dumpOptions?: DatabaseExportRequestDumpOptions; } export const ExportDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), outputFormat: DatabaseExportRequestOutputFormat.pipe( T.Body("output_format"), ), currentBookmark: S.optional(S.String.pipe(T.Body("current_bookmark"))), dumpOptions: S.optional( DatabaseExportRequestDumpOptions.pipe(T.Body("dump_options")), ), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/d1/database/{database_id}/export", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ExportDatabaseRequest", }) as any as S.Schema; export type DatabaseExportResponseMessagesList = Array; export const DatabaseExportResponseMessagesList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export interface DatabaseExportResponseResult { /** The generated SQL filename. */ filename?: string | null; /** The URL to download the exported SQL. Available for one hour. */ signedUrl?: string | null; } export const DatabaseExportResponseResult = /*@__PURE__*/ S.suspend(() => S.Struct({ filename: S.optional(S.NullOr(S.String)), signedUrl: S.optional(S.NullOr(S.String).pipe(T.Body("signed_url"))), }), ).annotate({ identifier: "DatabaseExportResponseResult", }) as any as S.Schema; export type DatabaseExportResponseStatus = "complete" | "error"; export const DatabaseExportResponseStatus = /*@__PURE__*/ S.String; export type DatabaseExportResponseType = "export"; export const DatabaseExportResponseType = /*@__PURE__*/ S.String; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface ExportDatabaseResponse { /** The current time-travel bookmark for your D1, used to poll for updates. Will not change for the duration of the export task. */ atBookmark?: string | null; /** Only present when status = 'error'. Contains the error message. */ error?: string | null; /** Logs since the last time you polled */ messages?: DatabaseExportResponseMessagesList | null; /** Only present when status = 'complete' */ result?: DatabaseExportResponseResult | null; status?: DatabaseExportResponseStatus | null; success?: boolean | null; type?: DatabaseExportResponseType | null; } export const ExportDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ atBookmark: S.optional(S.NullOr(S.String).pipe(T.Body("at_bookmark"))), error: S.optional(S.NullOr(S.String)), messages: S.optional(S.NullOr(DatabaseExportResponseMessagesList)), result: S.optional(S.NullOr(DatabaseExportResponseResult)), status: S.optional(S.NullOr(DatabaseExportResponseStatus)), success: S.optional(S.NullOr(S.Boolean)), type: S.optional(S.NullOr(DatabaseExportResponseType)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ExportDatabaseResponse", }) as any as S.Schema; export interface GetBookmarkDatabaseTimeTravelRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** An optional ISO 8601 timestamp. If provided, returns the nearest available bookmark at or before this timestamp. If omitted, returns the current bookmark. */ timestamp?: string; } export const GetBookmarkDatabaseTimeTravelRequest = /*@__PURE__*/ S.suspend( () => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), timestamp: S.optional(S.String.pipe(T.Query())), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/d1/database/{database_id}/time_travel/bookmark", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetBookmarkDatabaseTimeTravelRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface GetBookmarkDatabaseTimeTravelResponse { /** A bookmark representing a specific state of the database at a specific point in time. */ bookmark?: string | null; } export const GetBookmarkDatabaseTimeTravelResponse = /*@__PURE__*/ S.suspend( () => S.Struct({ bookmark: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetBookmarkDatabaseTimeTravelResponse", }) as any as S.Schema; export type DatabaseGetRequestFields = | "uuid" | "name" | "created_at" | "version" | "jurisdiction" | "num_tables" | "file_size" | "running_in_region" | "read_replication"; export const DatabaseGetRequestFields = /*@__PURE__*/ S.String; export type DatabaseGetRequestFieldsList = Array< DatabaseGetRequestFields | (string & {}) >; export const DatabaseGetRequestFieldsList = /*@__PURE__*/ S.Array( DatabaseGetRequestFields, ) as any as S.Schema; export interface GetDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** Comma-separated list of fields to include in the response. When omitted, */ fields?: DatabaseGetRequestFieldsList; } export const GetDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), fields: S.optional(DatabaseGetRequestFieldsList.pipe(T.Query())), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/d1/database/{database_id}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetDatabaseRequest", }) as any as S.Schema; export type DatabaseGetResponseJurisdiction = "eu" | "fedramp"; export const DatabaseGetResponseJurisdiction = /*@__PURE__*/ S.String; export type DatabaseGetResponseReadReplicationMode = "auto" | "disabled"; export const DatabaseGetResponseReadReplicationMode = /*@__PURE__*/ S.String; export interface DatabaseGetResponseReadReplication { /** The read replication mode for the database. Mode 'auto' denotes that D1 creates replicas and automatically places them around the world. Mode 'disabled' denotes that no database replicas are used. */ mode: DatabaseGetResponseReadReplicationMode; } export const DatabaseGetResponseReadReplication = /*@__PURE__*/ S.suspend(() => S.Struct({ mode: DatabaseGetResponseReadReplicationMode, }), ).annotate({ identifier: "DatabaseGetResponseReadReplication", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface GetDatabaseResponse { /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdAt?: string | null; /** The D1 database's size, in bytes. */ fileSize?: number | null; /** Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored. */ jurisdiction?: DatabaseGetResponseJurisdiction | null; /** D1 database name. */ name?: string | null; numTables?: number | null; /** Configuration for D1 read replication. */ readReplication?: DatabaseGetResponseReadReplication | null; /** D1 database identifier (UUID). */ uuid?: string | null; version?: string | null; } export const GetDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ createdAt: S.optional(S.NullOr(S.String).pipe(T.Body("created_at"))), fileSize: S.optional(S.NullOr(S.Number).pipe(T.Body("file_size"))), jurisdiction: S.optional(S.NullOr(DatabaseGetResponseJurisdiction)), name: S.optional(S.NullOr(S.String)), numTables: S.optional(S.NullOr(S.Number).pipe(T.Body("num_tables"))), readReplication: S.optional( S.NullOr(DatabaseGetResponseReadReplication).pipe( T.Body("read_replication"), ), ), uuid: S.optional(S.NullOr(S.String)), version: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetDatabaseResponse", }) as any as S.Schema; export type DatabaseImportRequestAction = "init" | "ingest" | "poll"; export const DatabaseImportRequestAction = /*@__PURE__*/ S.String; export interface ImportDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** Indicates you have a new SQL file to upload. */ action: DatabaseImportRequestAction | (string & {}); /** Required when action is 'init' or 'ingest'. An md5 hash of the file you're uploading. Used to check if it already exists, and validate its contents before ingesting. */ etag?: string; /** The filename you have successfully uploaded. */ filename?: string; /** This identifies the currently-running import, checking its status. */ currentBookmark?: string; } export const ImportDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), action: DatabaseImportRequestAction, etag: S.optional(S.String), filename: S.optional(S.String), currentBookmark: S.optional(S.String.pipe(T.Body("current_bookmark"))), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/d1/database/{database_id}/import", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ImportDatabaseRequest", }) as any as S.Schema; export type DatabaseImportResponseMessagesList = Array; export const DatabaseImportResponseMessagesList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export type DatabaseImportResponseResultMetaServedByRegion = | "WNAM" | "ENAM" | "WEUR" | "EEUR" | "APAC" | "OC"; export const DatabaseImportResponseResultMetaServedByRegion = /*@__PURE__*/ S.String; export interface DatabaseImportResponseResultMetaTimings { /** The duration of the SQL query execution inside the database. Does not include any network communication. */ sqlDurationMs?: number | null; } export const DatabaseImportResponseResultMetaTimings = /*@__PURE__*/ S.suspend( () => S.Struct({ sqlDurationMs: S.optional( S.NullOr(S.Number).pipe(T.Body("sql_duration_ms")), ), }), ).annotate({ identifier: "DatabaseImportResponseResultMetaTimings", }) as any as S.Schema; export interface DatabaseImportResponseResultMeta { /** Denotes if the database has been altered in some way, like deleting rows. */ changedDb?: boolean | null; /** Rough indication of how many rows were modified by the query, as provided by SQLite's `sqlite3_total_changes()`. */ changes?: number | null; /** The duration of the SQL query execution inside the database. Does not include any network communication. */ duration?: number | null; /** The row ID of the last inserted row in a table with an `INTEGER PRIMARY KEY` as provided by SQLite. Tables created with `WITHOUT ROWID` do not populate this. */ lastRowId?: number | null; /** Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned). */ rowsRead?: number | null; /** Number of rows written during the SQL query execution, including indices. */ rowsWritten?: number | null; /** The three letters airport code of the colo that handled the query. */ servedByColo?: string | null; /** Denotes if the query has been handled by the database primary instance. */ servedByPrimary?: boolean | null; /** Region location hint of the database instance that handled the query. */ servedByRegion?: DatabaseImportResponseResultMetaServedByRegion | null; /** Size of the database after the query committed, in bytes. */ sizeAfter?: number | null; /** Various durations for the query. */ timings?: DatabaseImportResponseResultMetaTimings | null; } export const DatabaseImportResponseResultMeta = /*@__PURE__*/ S.suspend(() => S.Struct({ changedDb: S.optional(S.NullOr(S.Boolean).pipe(T.Body("changed_db"))), changes: S.optional(S.NullOr(S.Number)), duration: S.optional(S.NullOr(S.Number)), lastRowId: S.optional(S.NullOr(S.Number).pipe(T.Body("last_row_id"))), rowsRead: S.optional(S.NullOr(S.Number).pipe(T.Body("rows_read"))), rowsWritten: S.optional(S.NullOr(S.Number).pipe(T.Body("rows_written"))), servedByColo: S.optional(S.NullOr(S.String).pipe(T.Body("served_by_colo"))), servedByPrimary: S.optional( S.NullOr(S.Boolean).pipe(T.Body("served_by_primary")), ), servedByRegion: S.optional( S.NullOr(DatabaseImportResponseResultMetaServedByRegion).pipe( T.Body("served_by_region"), ), ), sizeAfter: S.optional(S.NullOr(S.Number).pipe(T.Body("size_after"))), timings: S.optional(S.NullOr(DatabaseImportResponseResultMetaTimings)), }), ).annotate({ identifier: "DatabaseImportResponseResultMeta", }) as any as S.Schema; export interface DatabaseImportResponseResult { /** The time-travel bookmark if you need restore your D1 to directly after the import succeeded. */ finalBookmark?: string | null; meta?: DatabaseImportResponseResultMeta | null; /** The total number of queries that were executed during the import. */ numQueries?: number | null; } export const DatabaseImportResponseResult = /*@__PURE__*/ S.suspend(() => S.Struct({ finalBookmark: S.optional( S.NullOr(S.String).pipe(T.Body("final_bookmark")), ), meta: S.optional(S.NullOr(DatabaseImportResponseResultMeta)), numQueries: S.optional(S.NullOr(S.Number).pipe(T.Body("num_queries"))), }), ).annotate({ identifier: "DatabaseImportResponseResult", }) as any as S.Schema; export type DatabaseImportResponseStatus = "complete" | "error"; export const DatabaseImportResponseStatus = /*@__PURE__*/ S.String; export type DatabaseImportResponseType = "import"; export const DatabaseImportResponseType = /*@__PURE__*/ S.String; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface ImportDatabaseResponse { /** The current time-travel bookmark for your D1, used to poll for updates. Will not change for the duration of the import. Only returned if an import process is currently running or recently finished. */ atBookmark?: string | null; /** Only present when status = 'error'. Contains the error message that prevented the import from succeeding. */ error?: string | null; /** Derived from the database ID and etag, to use in avoiding repeated uploads. Only returned when for the 'init' action. */ filename?: string | null; /** Logs since the last time you polled */ messages?: DatabaseImportResponseMessagesList | null; /** Only present when status = 'complete' */ result?: DatabaseImportResponseResult | null; status?: DatabaseImportResponseStatus | null; success?: boolean | null; type?: DatabaseImportResponseType | null; /** The R2 presigned URL to use for uploading. Only returned when for the 'init' action. */ uploadUrl?: string | null; } export const ImportDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ atBookmark: S.optional(S.NullOr(S.String).pipe(T.Body("at_bookmark"))), error: S.optional(S.NullOr(S.String)), filename: S.optional(S.NullOr(S.String)), messages: S.optional(S.NullOr(DatabaseImportResponseMessagesList)), result: S.optional(S.NullOr(DatabaseImportResponseResult)), status: S.optional(S.NullOr(DatabaseImportResponseStatus)), success: S.optional(S.NullOr(S.Boolean)), type: S.optional(S.NullOr(DatabaseImportResponseType)), uploadUrl: S.optional(S.NullOr(S.String).pipe(T.Body("upload_url"))), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ImportDatabaseResponse", }) as any as S.Schema; export interface ListDatabasesRequest { /** Account identifier tag. */ accountId: string; /** a database name to search for. */ name?: string; /** Page number of paginated results. */ page?: number; /** Number of items per page. */ perPage?: number; } export const ListDatabasesRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), name: S.optional(S.String.pipe(T.Query())), 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}/d1/database", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListDatabasesRequest", }) as any as S.Schema; export type DatabaseListResultItemJurisdiction = "eu" | "fedramp"; export const DatabaseListResultItemJurisdiction = /*@__PURE__*/ S.String; export interface DatabaseListResultItem { /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdAt?: string | null; /** Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored. */ jurisdiction?: DatabaseListResultItemJurisdiction | null; /** D1 database name. */ name?: string | null; /** D1 database identifier (UUID). */ uuid?: string | null; version?: string | null; } export const DatabaseListResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ createdAt: S.optional(S.NullOr(S.String).pipe(T.Body("created_at"))), jurisdiction: S.optional(S.NullOr(DatabaseListResultItemJurisdiction)), name: S.optional(S.NullOr(S.String)), uuid: S.optional(S.NullOr(S.String)), version: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "DatabaseListResultItem", }) as any as S.Schema; export type DatabaseListResultList = Array; export const DatabaseListResultList = /*@__PURE__*/ S.Array( DatabaseListResultItem, ) as any as S.Schema; export interface ListDatabasesResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: DatabaseListResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const ListDatabasesResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: DatabaseListResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListDatabasesResponse", }) as any as S.Schema; export type DatabaseEditRequestReadReplicationMode = "auto" | "disabled"; export const DatabaseEditRequestReadReplicationMode = /*@__PURE__*/ S.String; export interface DatabaseEditRequestReadReplication { /** The read replication mode for the database. Use 'auto' to create replicas and allow D1 automatically place them around the world, or 'disabled' to not use any database replicas (it can take a few hours for all replicas to be deleted). */ mode: DatabaseEditRequestReadReplicationMode | (string & {}); } export const DatabaseEditRequestReadReplication = /*@__PURE__*/ S.suspend(() => S.Struct({ mode: DatabaseEditRequestReadReplicationMode, }), ).annotate({ identifier: "DatabaseEditRequestReadReplication", }) as any as S.Schema; export interface PatchDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** Configuration for D1 read replication. */ readReplication?: DatabaseEditRequestReadReplication; } export const PatchDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), readReplication: S.optional( DatabaseEditRequestReadReplication.pipe(T.Body("read_replication")), ), }) .pipe( T.Http({ method: "PATCH", uri: "/accounts/{account_id}/d1/database/{database_id}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "PatchDatabaseRequest", }) as any as S.Schema; export type DatabaseEditResponseJurisdiction = "eu" | "fedramp"; export const DatabaseEditResponseJurisdiction = /*@__PURE__*/ S.String; export type DatabaseEditResponseReadReplicationMode = "auto" | "disabled"; export const DatabaseEditResponseReadReplicationMode = /*@__PURE__*/ S.String; export interface DatabaseEditResponseReadReplication { /** The read replication mode for the database. Mode 'auto' denotes that D1 creates replicas and automatically places them around the world. Mode 'disabled' denotes that no database replicas are used. */ mode: DatabaseEditResponseReadReplicationMode; } export const DatabaseEditResponseReadReplication = /*@__PURE__*/ S.suspend(() => S.Struct({ mode: DatabaseEditResponseReadReplicationMode, }), ).annotate({ identifier: "DatabaseEditResponseReadReplication", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface PatchDatabaseResponse { /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdAt?: string | null; /** The D1 database's size, in bytes. */ fileSize?: number | null; /** Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored. */ jurisdiction?: DatabaseEditResponseJurisdiction | null; /** D1 database name. */ name?: string | null; numTables?: number | null; /** Configuration for D1 read replication. */ readReplication?: DatabaseEditResponseReadReplication | null; /** D1 database identifier (UUID). */ uuid?: string | null; version?: string | null; } export const PatchDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ createdAt: S.optional(S.NullOr(S.String).pipe(T.Body("created_at"))), fileSize: S.optional(S.NullOr(S.Number).pipe(T.Body("file_size"))), jurisdiction: S.optional(S.NullOr(DatabaseEditResponseJurisdiction)), name: S.optional(S.NullOr(S.String)), numTables: S.optional(S.NullOr(S.Number).pipe(T.Body("num_tables"))), readReplication: S.optional( S.NullOr(DatabaseEditResponseReadReplication).pipe( T.Body("read_replication"), ), ), uuid: S.optional(S.NullOr(S.String)), version: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "PatchDatabaseResponse", }) as any as S.Schema; export type DatabaseQueryRequestParamsList = Array; export const DatabaseQueryRequestParamsList = /*@__PURE__*/ S.Array( S.Unknown, ) as any as S.Schema; export type DatabaseQueryRequestBatchItemParamsList = Array; export const DatabaseQueryRequestBatchItemParamsList = /*@__PURE__*/ S.Array( S.Unknown, ) as any as S.Schema; export interface DatabaseQueryRequestBatchItem { /** Your SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch. */ sql: string; params?: DatabaseQueryRequestBatchItemParamsList; } export const DatabaseQueryRequestBatchItem = /*@__PURE__*/ S.suspend(() => S.Struct({ sql: S.String, params: S.optional(DatabaseQueryRequestBatchItemParamsList), }), ).annotate({ identifier: "DatabaseQueryRequestBatchItem", }) as any as S.Schema; export type DatabaseQueryRequestBatchList = Array; export const DatabaseQueryRequestBatchList = /*@__PURE__*/ S.Array( DatabaseQueryRequestBatchItem, ) as any as S.Schema; export interface QueryDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** Your SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch. */ sql?: string; params?: DatabaseQueryRequestParamsList; batch?: DatabaseQueryRequestBatchList; } export const QueryDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), sql: S.optional(S.String), params: S.optional(DatabaseQueryRequestParamsList), batch: S.optional(DatabaseQueryRequestBatchList), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/d1/database/{database_id}/query", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "QueryDatabaseRequest", }) as any as S.Schema; export type DatabaseQueryResultItemMetaServedByRegion = | "WNAM" | "ENAM" | "WEUR" | "EEUR" | "APAC" | "OC"; export const DatabaseQueryResultItemMetaServedByRegion = /*@__PURE__*/ S.String; export type DatabaseQueryResultItemMetaTimings = DatabaseImportResponseResultMetaTimings; export const DatabaseQueryResultItemMetaTimings = DatabaseImportResponseResultMetaTimings; export interface DatabaseQueryResultItemMeta { /** Denotes if the database has been altered in some way, like deleting rows. */ changedDb?: boolean | null; /** Rough indication of how many rows were modified by the query, as provided by SQLite's `sqlite3_total_changes()`. */ changes?: number | null; /** The duration of the SQL query execution inside the database. Does not include any network communication. */ duration?: number | null; /** The row ID of the last inserted row in a table with an `INTEGER PRIMARY KEY` as provided by SQLite. Tables created with `WITHOUT ROWID` do not populate this. */ lastRowId?: number | null; /** Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned). */ rowsRead?: number | null; /** Number of rows written during the SQL query execution, including indices. */ rowsWritten?: number | null; /** The three letters airport code of the colo that handled the query. */ servedByColo?: string | null; /** Denotes if the query has been handled by the database primary instance. */ servedByPrimary?: boolean | null; /** Region location hint of the database instance that handled the query. */ servedByRegion?: DatabaseQueryResultItemMetaServedByRegion | null; /** Size of the database after the query committed, in bytes. */ sizeAfter?: number | null; /** Various durations for the query. */ timings?: DatabaseImportResponseResultMetaTimings | null; } export const DatabaseQueryResultItemMeta = /*@__PURE__*/ S.suspend(() => S.Struct({ changedDb: S.optional(S.NullOr(S.Boolean).pipe(T.Body("changed_db"))), changes: S.optional(S.NullOr(S.Number)), duration: S.optional(S.NullOr(S.Number)), lastRowId: S.optional(S.NullOr(S.Number).pipe(T.Body("last_row_id"))), rowsRead: S.optional(S.NullOr(S.Number).pipe(T.Body("rows_read"))), rowsWritten: S.optional(S.NullOr(S.Number).pipe(T.Body("rows_written"))), servedByColo: S.optional(S.NullOr(S.String).pipe(T.Body("served_by_colo"))), servedByPrimary: S.optional( S.NullOr(S.Boolean).pipe(T.Body("served_by_primary")), ), servedByRegion: S.optional( S.NullOr(DatabaseQueryResultItemMetaServedByRegion).pipe( T.Body("served_by_region"), ), ), sizeAfter: S.optional(S.NullOr(S.Number).pipe(T.Body("size_after"))), timings: S.optional(S.NullOr(DatabaseImportResponseResultMetaTimings)), }), ).annotate({ identifier: "DatabaseQueryResultItemMeta", }) as any as S.Schema; export type DatabaseQueryResultItemResultsList = Array; export const DatabaseQueryResultItemResultsList = /*@__PURE__*/ S.Array( S.Unknown, ) as any as S.Schema; export interface DatabaseQueryResultItem { meta?: DatabaseQueryResultItemMeta | null; results?: DatabaseQueryResultItemResultsList | null; success?: boolean | null; } export const DatabaseQueryResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ meta: S.optional(S.NullOr(DatabaseQueryResultItemMeta)), results: S.optional(S.NullOr(DatabaseQueryResultItemResultsList)), success: S.optional(S.NullOr(S.Boolean)), }), ).annotate({ identifier: "DatabaseQueryResultItem", }) as any as S.Schema; export type DatabaseQueryResultList = Array; export const DatabaseQueryResultList = /*@__PURE__*/ S.Array( DatabaseQueryResultItem, ) as any as S.Schema; export interface QueryDatabaseResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: DatabaseQueryResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const QueryDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: DatabaseQueryResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "QueryDatabaseResponse", }) as any as S.Schema; export type DatabaseRawRequestParamsList = Array; export const DatabaseRawRequestParamsList = /*@__PURE__*/ S.Array( S.Unknown, ) as any as S.Schema; export type DatabaseRawRequestBatchItemParamsList = Array; export const DatabaseRawRequestBatchItemParamsList = /*@__PURE__*/ S.Array( S.Unknown, ) as any as S.Schema; export interface DatabaseRawRequestBatchItem { /** Your SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch. */ sql: string; params?: DatabaseRawRequestBatchItemParamsList; } export const DatabaseRawRequestBatchItem = /*@__PURE__*/ S.suspend(() => S.Struct({ sql: S.String, params: S.optional(DatabaseRawRequestBatchItemParamsList), }), ).annotate({ identifier: "DatabaseRawRequestBatchItem", }) as any as S.Schema; export type DatabaseRawRequestBatchList = Array; export const DatabaseRawRequestBatchList = /*@__PURE__*/ S.Array( DatabaseRawRequestBatchItem, ) as any as S.Schema; export interface RawDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** Your SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch. */ sql?: string; params?: DatabaseRawRequestParamsList; batch?: DatabaseRawRequestBatchList; } export const RawDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), sql: S.optional(S.String), params: S.optional(DatabaseRawRequestParamsList), batch: S.optional(DatabaseRawRequestBatchList), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/d1/database/{database_id}/raw", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "RawDatabaseRequest", }) as any as S.Schema; export type DatabaseRawResultItemMetaServedByRegion = | "WNAM" | "ENAM" | "WEUR" | "EEUR" | "APAC" | "OC"; export const DatabaseRawResultItemMetaServedByRegion = /*@__PURE__*/ S.String; export type DatabaseRawResultItemMetaTimings = DatabaseImportResponseResultMetaTimings; export const DatabaseRawResultItemMetaTimings = DatabaseImportResponseResultMetaTimings; export interface DatabaseRawResultItemMeta { /** Denotes if the database has been altered in some way, like deleting rows. */ changedDb?: boolean | null; /** Rough indication of how many rows were modified by the query, as provided by SQLite's `sqlite3_total_changes()`. */ changes?: number | null; /** The duration of the SQL query execution inside the database. Does not include any network communication. */ duration?: number | null; /** The row ID of the last inserted row in a table with an `INTEGER PRIMARY KEY` as provided by SQLite. Tables created with `WITHOUT ROWID` do not populate this. */ lastRowId?: number | null; /** Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned). */ rowsRead?: number | null; /** Number of rows written during the SQL query execution, including indices. */ rowsWritten?: number | null; /** The three letters airport code of the colo that handled the query. */ servedByColo?: string | null; /** Denotes if the query has been handled by the database primary instance. */ servedByPrimary?: boolean | null; /** Region location hint of the database instance that handled the query. */ servedByRegion?: DatabaseRawResultItemMetaServedByRegion | null; /** Size of the database after the query committed, in bytes. */ sizeAfter?: number | null; /** Various durations for the query. */ timings?: DatabaseImportResponseResultMetaTimings | null; } export const DatabaseRawResultItemMeta = /*@__PURE__*/ S.suspend(() => S.Struct({ changedDb: S.optional(S.NullOr(S.Boolean).pipe(T.Body("changed_db"))), changes: S.optional(S.NullOr(S.Number)), duration: S.optional(S.NullOr(S.Number)), lastRowId: S.optional(S.NullOr(S.Number).pipe(T.Body("last_row_id"))), rowsRead: S.optional(S.NullOr(S.Number).pipe(T.Body("rows_read"))), rowsWritten: S.optional(S.NullOr(S.Number).pipe(T.Body("rows_written"))), servedByColo: S.optional(S.NullOr(S.String).pipe(T.Body("served_by_colo"))), servedByPrimary: S.optional( S.NullOr(S.Boolean).pipe(T.Body("served_by_primary")), ), servedByRegion: S.optional( S.NullOr(DatabaseRawResultItemMetaServedByRegion).pipe( T.Body("served_by_region"), ), ), sizeAfter: S.optional(S.NullOr(S.Number).pipe(T.Body("size_after"))), timings: S.optional(S.NullOr(DatabaseImportResponseResultMetaTimings)), }), ).annotate({ identifier: "DatabaseRawResultItemMeta", }) as any as S.Schema; export type DatabaseRawResultItemResultsColumnsList = Array; export const DatabaseRawResultItemResultsColumnsList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export type DatabaseRawResultItemResultsRowsList = Array; export const DatabaseRawResultItemResultsRowsList = /*@__PURE__*/ S.Array( S.Unknown, ) as any as S.Schema; export interface DatabaseRawResultItemResults { columns?: DatabaseRawResultItemResultsColumnsList | null; rows?: DatabaseRawResultItemResultsRowsList | null; } export const DatabaseRawResultItemResults = /*@__PURE__*/ S.suspend(() => S.Struct({ columns: S.optional(S.NullOr(DatabaseRawResultItemResultsColumnsList)), rows: S.optional(S.NullOr(DatabaseRawResultItemResultsRowsList)), }), ).annotate({ identifier: "DatabaseRawResultItemResults", }) as any as S.Schema; export interface DatabaseRawResultItem { meta?: DatabaseRawResultItemMeta | null; results?: DatabaseRawResultItemResults | null; success?: boolean | null; } export const DatabaseRawResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ meta: S.optional(S.NullOr(DatabaseRawResultItemMeta)), results: S.optional(S.NullOr(DatabaseRawResultItemResults)), success: S.optional(S.NullOr(S.Boolean)), }), ).annotate({ identifier: "DatabaseRawResultItem", }) as any as S.Schema; export type DatabaseRawResultList = Array; export const DatabaseRawResultList = /*@__PURE__*/ S.Array( DatabaseRawResultItem, ) as any as S.Schema; export interface RawDatabaseResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: DatabaseRawResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const RawDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: DatabaseRawResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "RawDatabaseResponse", }) as any as S.Schema; export interface RestoreDatabaseTimeTravelRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** A bookmark to restore the database to. Required if `timestamp` is not provided. */ bookmark?: string; /** An ISO 8601 timestamp to restore the database to. Required if `bookmark` is not provided. */ timestamp?: string; } export const RestoreDatabaseTimeTravelRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), bookmark: S.optional(S.String.pipe(T.Query())), timestamp: S.optional(S.String.pipe(T.Query())), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/d1/database/{database_id}/time_travel/restore", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "RestoreDatabaseTimeTravelRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface RestoreDatabaseTimeTravelResponse { /** The new bookmark representing the state of the database after the restore operation. */ bookmark?: string | null; /** A message describing the result of the restore operation. */ message?: string | null; /** The bookmark representing the state of the database before the restore operation. Can be used to undo the restore if needed. */ previousBookmark?: string | null; } export const RestoreDatabaseTimeTravelResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ bookmark: S.optional(S.NullOr(S.String)), message: S.optional(S.NullOr(S.String)), previousBookmark: S.optional( S.NullOr(S.String).pipe(T.Body("previous_bookmark")), ), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "RestoreDatabaseTimeTravelResponse", }) as any as S.Schema; export type DatabaseUpdateRequestReadReplicationMode = "auto" | "disabled"; export const DatabaseUpdateRequestReadReplicationMode = /*@__PURE__*/ S.String; export interface DatabaseUpdateRequestReadReplication { /** The read replication mode for the database. Use 'auto' to create replicas and allow D1 automatically place them around the world, or 'disabled' to not use any database replicas (it can take a few hours for all replicas to be deleted). */ mode: DatabaseUpdateRequestReadReplicationMode | (string & {}); } export const DatabaseUpdateRequestReadReplication = /*@__PURE__*/ S.suspend( () => S.Struct({ mode: DatabaseUpdateRequestReadReplicationMode, }), ).annotate({ identifier: "DatabaseUpdateRequestReadReplication", }) as any as S.Schema; export interface UpdateDatabaseRequest { /** Account identifier tag. */ accountId: string; /** D1 database identifier (UUID). */ databaseId: string; /** Configuration for D1 read replication. */ readReplication: DatabaseUpdateRequestReadReplication; } export const UpdateDatabaseRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), databaseId: S.String.pipe(T.Label("database_id")), readReplication: DatabaseUpdateRequestReadReplication.pipe( T.Body("read_replication"), ), }) .pipe( T.Http({ method: "PUT", uri: "/accounts/{account_id}/d1/database/{database_id}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "UpdateDatabaseRequest", }) as any as S.Schema; export type DatabaseUpdateResponseJurisdiction = "eu" | "fedramp"; export const DatabaseUpdateResponseJurisdiction = /*@__PURE__*/ S.String; export type DatabaseUpdateResponseReadReplicationMode = "auto" | "disabled"; export const DatabaseUpdateResponseReadReplicationMode = /*@__PURE__*/ S.String; export interface DatabaseUpdateResponseReadReplication { /** The read replication mode for the database. Mode 'auto' denotes that D1 creates replicas and automatically places them around the world. Mode 'disabled' denotes that no database replicas are used. */ mode: DatabaseUpdateResponseReadReplicationMode; } export const DatabaseUpdateResponseReadReplication = /*@__PURE__*/ S.suspend( () => S.Struct({ mode: DatabaseUpdateResponseReadReplicationMode, }), ).annotate({ identifier: "DatabaseUpdateResponseReadReplication", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface UpdateDatabaseResponse { /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdAt?: string | null; /** The D1 database's size, in bytes. */ fileSize?: number | null; /** Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored. */ jurisdiction?: DatabaseUpdateResponseJurisdiction | null; /** D1 database name. */ name?: string | null; numTables?: number | null; /** Configuration for D1 read replication. */ readReplication?: DatabaseUpdateResponseReadReplication | null; /** D1 database identifier (UUID). */ uuid?: string | null; version?: string | null; } export const UpdateDatabaseResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ createdAt: S.optional(S.NullOr(S.String).pipe(T.Body("created_at"))), fileSize: S.optional(S.NullOr(S.Number).pipe(T.Body("file_size"))), jurisdiction: S.optional(S.NullOr(DatabaseUpdateResponseJurisdiction)), name: S.optional(S.NullOr(S.String)), numTables: S.optional(S.NullOr(S.Number).pipe(T.Body("num_tables"))), readReplication: S.optional( S.NullOr(DatabaseUpdateResponseReadReplication).pipe( T.Body("read_replication"), ), ), uuid: S.optional(S.NullOr(S.String)), version: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "UpdateDatabaseResponse", }) as any as S.Schema; export type CreateDatabaseError = | InvalidObjectIdentifier | InvalidProperty | DatabaseAlreadyExists | CloudflareOpError; /** Returns the created D1 database. */ export const createDatabase: API.OperationMethod< CreateDatabaseRequest, CreateDatabaseResponse, CreateDatabaseError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: CreateDatabaseRequest, output: CreateDatabaseResponse, errors: [ InvalidObjectIdentifier, InvalidProperty, DatabaseAlreadyExists, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type DeleteDatabaseError = | InvalidObjectIdentifier | DatabaseNotFound | UnknownError | CloudflareOpError; /** Deletes the specified D1 database. */ export const deleteDatabase: API.OperationMethod< DeleteDatabaseRequest, DeleteDatabaseResponse, DeleteDatabaseError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: DeleteDatabaseRequest, output: DeleteDatabaseResponse, errors: [ InvalidObjectIdentifier, DatabaseNotFound, UnknownError, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type ExportDatabaseError = | InvalidObjectIdentifier | InvalidRequest | DatabaseNotFound | CloudflareOpError; /** Returns a URL where the SQL contents of your D1 can be downloaded. Note: this process may take some time for larger DBs, during which your D1 will be unavailable to serve queries. To avoid blocking your DB unnecessarily, an in-progress export must be continually polled or will automatically cancel. */ export const exportDatabase: API.OperationMethod< ExportDatabaseRequest, ExportDatabaseResponse, ExportDatabaseError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: ExportDatabaseRequest, output: ExportDatabaseResponse, errors: [ InvalidObjectIdentifier, InvalidRequest, DatabaseNotFound, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type GetBookmarkDatabaseTimeTravelError = | InvalidObjectIdentifier | NoHistoryAvailable | TimestampTooOld | DatabaseNotFound | CloudflareOpError; /** Retrieves the current bookmark, or the nearest bookmark at or before a provided timestamp. Bookmarks can be used with the restore endpoint to revert the database to a previous point in time. */ export const getBookmarkDatabaseTimeTravel: API.OperationMethod< GetBookmarkDatabaseTimeTravelRequest, GetBookmarkDatabaseTimeTravelResponse, GetBookmarkDatabaseTimeTravelError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: GetBookmarkDatabaseTimeTravelRequest, output: GetBookmarkDatabaseTimeTravelResponse, errors: [ InvalidObjectIdentifier, NoHistoryAvailable, TimestampTooOld, DatabaseNotFound, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type GetDatabaseError = | InvalidObjectIdentifier | DatabaseNotFound | UnknownError | CloudflareOpError; /** Returns the specified D1 database. */ export const getDatabase: API.OperationMethod< GetDatabaseRequest, GetDatabaseResponse, GetDatabaseError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: GetDatabaseRequest, output: GetDatabaseResponse, errors: [ InvalidObjectIdentifier, DatabaseNotFound, UnknownError, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type ImportDatabaseError = InvalidObjectIdentifier | CloudflareOpError; /** Generates a temporary URL for uploading an SQL file to, then instructing the D1 to import it and polling it for status updates. Imports block the D1 for their duration. */ export const importDatabase: API.OperationMethod< ImportDatabaseRequest, ImportDatabaseResponse, ImportDatabaseError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: ImportDatabaseRequest, output: ImportDatabaseResponse, errors: [InvalidObjectIdentifier, CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type ListDatabasesError = CloudflareOpError; /** Returns a list of D1 databases. */ export const listDatabases: API.PaginatedOperationMethod< ListDatabasesRequest, ListDatabasesResponse, ListDatabasesError, CloudflareOpContext, DatabaseListResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: ListDatabasesRequest, output: ListDatabasesResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "resultInfo.page", items: "result", pageSize: "perPage", } as const, }), cloudflarePaginate, ) as any; export type PatchDatabaseError = | InvalidObjectIdentifier | InternalError | DatabaseNotFound | CloudflareOpError; /** Updates partially the specified D1 database. */ export const patchDatabase: API.OperationMethod< PatchDatabaseRequest, PatchDatabaseResponse, PatchDatabaseError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: PatchDatabaseRequest, output: PatchDatabaseResponse, errors: [ InvalidObjectIdentifier, InternalError, DatabaseNotFound, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type QueryDatabaseError = CloudflareOpError; /** Returns the query result as an object. */ export const queryDatabase: API.PaginatedOperationMethod< QueryDatabaseRequest, QueryDatabaseResponse, QueryDatabaseError, CloudflareOpContext, DatabaseQueryResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: QueryDatabaseRequest, output: QueryDatabaseResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "single", items: "result" } as const, }), cloudflarePaginate, ) as any; export type RawDatabaseError = CloudflareOpError; /** Returns the query result rows as arrays rather than objects. This is a performance-optimized version of the /query endpoint. */ export const rawDatabase: API.PaginatedOperationMethod< RawDatabaseRequest, RawDatabaseResponse, RawDatabaseError, CloudflareOpContext, DatabaseRawResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: RawDatabaseRequest, output: RawDatabaseResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "single", items: "result" } as const, }), cloudflarePaginate, ) as any; export type RestoreDatabaseTimeTravelError = | InvalidObjectIdentifier | NoHistoryAvailable | DatabaseNotFound | InvalidProperty | CloudflareOpError; /** Restores a D1 database to a previous point in time either via a bookmark or a timestamp. */ export const restoreDatabaseTimeTravel: API.OperationMethod< RestoreDatabaseTimeTravelRequest, RestoreDatabaseTimeTravelResponse, RestoreDatabaseTimeTravelError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: RestoreDatabaseTimeTravelRequest, output: RestoreDatabaseTimeTravelResponse, errors: [ InvalidObjectIdentifier, NoHistoryAvailable, DatabaseNotFound, InvalidProperty, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type UpdateDatabaseError = | InvalidObjectIdentifier | InternalError | DatabaseNotFound | CloudflareOpError; /** Updates the specified D1 database. */ export const updateDatabase: API.OperationMethod< UpdateDatabaseRequest, UpdateDatabaseResponse, UpdateDatabaseError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: UpdateDatabaseRequest, output: UpdateDatabaseResponse, errors: [ InvalidObjectIdentifier, InternalError, DatabaseNotFound, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, }));