Skip to main content

Cloudflare/d1

@webframp/cloudflare/d1v2026.10.21.1· Apache-2.0· 5d agoBEHAVIORS
01README

Cloudflare D1 serverless SQL databases — databases, queries

02Release Notes

2026.10.21.1

Changed: The README and the apiToken description now lead with a vault. Store the token with swamp vault put cloudflare API_TOKEN and set apiToken to ${{ vault.get("cloudflare", "API_TOKEN") }}. The CLOUDFLARE_API_TOKEN environment variable still works as a fallback, but swamp does not redact it, so it is no longer recommended. The missing-token error now says the same.

Fixed: Create methods whose response carries no id wrote every result to one instance named created, so each call overwrote the previous one. They now name the instance by the response's id or uuid when present, else by the path parameter that scopes the call, else by a hash of the request arguments (secret arguments left out). Affected: create_database and create_d1_export_database.

Upgrade note: Results earlier versions wrote to the created instance stay there; new runs write under the new names.

03Behaviors1
@webframp/cloudflare/d1v2026.10.21.1cloudflare/d1.ts

Global Arguments

ArgumentTypeDescription
apiToken?stringCloudflare API token. Wire it with ${{ vault.get("cloudflare", "API_TOKEN") }}; never pass the literal token. The CLOUDFLARE_API_TOKEN environment variable is read as a fallback, but it is not redacted and is not recommended.
accountIdstringCloudflare account ID
fn list_databases(name?: string, page?: number, per_page?: number)
List D1 Databases
ArgumentTypeDescription
name?string
page?number
per_page?number
fn create_database(jurisdiction?: unknown, name: unknown, primary_location_hint?: unknown, read_replication?: unknown)
Create D1 Database
ArgumentTypeDescription
jurisdiction?unknown
nameunknown
primary_location_hint?unknown
read_replication?unknown
fn get_database(database_id: string, fields?: string)
Get D1 Database
ArgumentTypeDescription
database_idstring
fields?stringComma-separated list of fields to include in the response. When omitted, all fields are returned.
fn update_database(database_id: string, read_replication: unknown)
Update D1 Database
ArgumentTypeDescription
database_idstring
read_replicationunknown
fn update_partial_database(database_id: string, read_replication?: unknown)
Update D1 Database partially
ArgumentTypeDescription
database_idstring
read_replication?unknown
fn delete_database(database_id: string)
Delete D1 Database
ArgumentTypeDescription
database_idstring
fn create_d1_export_database(database_id: string, current_bookmark?: string, dump_options?: object, output_format: enum)
Export D1 Database as SQL
ArgumentTypeDescription
database_idstring
current_bookmark?string
dump_options?object
output_formatenumSpecifies that you will poll this endpoint until the export completes
fn d1_import_database(database_id: string, body: union)
Import SQL into your D1 Database
ArgumentTypeDescription
database_idstring
bodyunion
fn d1_query_database(database_id: string, body: union)
Query D1 Database
ArgumentTypeDescription
database_idstring
bodyunionA single query object or a batch query object
fn d1_raw_database_query(database_id: string, body: union)
Raw D1 Database query
ArgumentTypeDescription
database_idstring
bodyunionA single query object or a batch query object
fn get_bookmark(database_id: string, timestamp?: string)
Get D1 database bookmark
ArgumentTypeDescription
database_idstring
timestamp?stringAn optional ISO 8601 timestamp. If provided, returns the nearest available bookmark at or before this timestamp. If omitted, returns the current bookmark.
fn d1_time_travel_restore(database_id: string, bookmark?: string, timestamp?: string)
Restore D1 Database to a bookmark or point in time
ArgumentTypeDescription
database_idstring
bookmark?stringA bookmark to restore the database to. Required if `timestamp` is not provided.
timestamp?stringAn ISO 8601 timestamp to restore the database to. Required if `bookmark` is not provided.

Resources

databases(infinite)— List D1 Databases
database(infinite)— Create D1 Database
partial_database(infinite)— Update D1 Database partially
d1_export_database(infinite)— Export D1 Database as SQL
d1_import_database(infinite)— Import SQL into your D1 Database
d1_query_database(infinite)— Query D1 Database
d1_raw_database_query(infinite)— Raw D1 Database query
bookmark(infinite)— Get D1 database bookmark
d1_time_travel_restore(infinite)— Restore D1 Database to a bookmark or point in time
04Previous Versions11
2026.10.14.1Apache-2.0(was none)

2026.10.14.1

Fixed: Methods that write a singleton resource failed on current swamp with Data name 'latest' is reserved for internal use.

Changed: Singleton get and action methods now write their data under d1_import_database-current, d1_query_database-current, d1_raw_database_query-current, d1_time_travel_restore-current instead of latest. Anything that read data.latest("<model>", "latest") or queried name == "latest" must use the new name.

Upgrade note: Data previously stored under latest is not migrated; re-run the method to populate the new name. No attribute schemas changed.

Added: The manifest now declares license: Apache-2.0 (SPDX). The registry quality rubric scores a declared license separately from the bundled LICENSE.md.

2026.09.18.1

2026.09.18.1

Upgrade note: Normalized npm:zod dependency version to 4.6.5 across the repo. No behavioral changes in this extension.

2026.09.17.2

2026.09.17.2

No changes to this extension's methods. Regenerated to refresh the shared _lib/api.ts helper library after PR #427 review fixes to cfApiPaginatedCursor (used by r2, kv, durable-objects, and workers-ai, but emitted into every extension's api.ts since it's part of the shared template).

2026.09.15.1

2026.09.15.1

Changed: Bump zod 4.4.3 → 4.6.5

2026.08.28.2

Hardened codegen: instance names sanitized against path traversal; 429 rate-limit retry with Retry-After; string schema patterns emit regex validation; output schemas passthrough unknown fields; apiToken now optional and vault-wireable with CLOUDFLARE_API_TOKEN env fallback.

2026.08.28.2

2026.08.28.2

Hardened codegen: instance names sanitized against path traversal; 429 rate-limit retry with Retry-After; string schema patterns emit regex validation; output schemas passthrough unknown fields; apiToken now optional and vault-wireable with CLOUDFLARE_API_TOKEN env fallback.

2026.08.28.1

2026.08.28.1

Changed: Normalized the extension license to Apache-2.0 and corrected the copyright holder to "Sean Escriva". Extensions that previously shipped an MIT LICENSE.md are now Apache-2.0, consistent with the repository root and every other extension. No code or behavioral changes.

Upgrade note: License text only. No API, schema, or runtime behavior changed.

2026.08.26.2

Fixed: Restored inline npm:zod@4.4.3 import specifiers so the registry quality scorer can resolve dependencies and score the extension. An earlier release used a bare "zod" import-map specifier, which published but scored as unscored.

Changed: Retained explicit compilerOptions.strict in deno.json. No behavioral or schema changes.

2026.08.26.2

2026.08.26.2

Fixed: Restored inline npm:zod@4.4.3 import specifiers so the registry quality scorer can resolve dependencies and score the extension. An earlier release used a bare "zod" import-map specifier, which published but scored as unscored.

Changed: Retained explicit compilerOptions.strict in deno.json. No behavioral or schema changes.

2026.08.24.1

2026.08.24.1

Added: Output metadata attributes for observability.

  • durationMs: Method execution duration in milliseconds.
  • collectedBy: Extension name that produced the data.
  • fetchedAt: ISO 8601 timestamp when data was fetched (added to resources that previously lacked it).
2026.08.21.1

2026.08.21.1

Changed: Error messages for API failures and invalid input are now specific instead of generic.

  • Every method that calls the Cloudflare API now wraps failures with the operation and the database/account ID involved, instead of surfacing the raw SDK error with no context.
  • All methods that take a database_id now reject an empty value up front with a clear validation error, instead of sending a malformed request to the Cloudflare API.
  • create_database now validates that name is present before calling the API, instead of letting Cloudflare reject the request with a generic error.
  • d1_time_travel_restore now requires either bookmark or timestamp to be supplied, instead of silently sending a restore request with neither and letting Cloudflare reject it.

Upgrade note: No behavioral change for valid requests. Callers relying on an empty database_id, a missing name on create, or a restore request with neither bookmark nor timestamp to fail inside the Cloudflare API call will now get an immediate, descriptive validation error instead.

2026.07.27.1

2026.07.27.1

Fixed: Regenerated from scripts/cloudflare-codegen after two generator bugs were repaired (webframp/swamp-extensions#284).

  1. Methods referencing an undeclared path parameter did not compile. The generator derived a method's arguments schema and execute signature from the OpenAPI parameters list, but built the request URL from the path template. Where the Cloudflare spec omits a declaration for a {placeholder} — which it does in several places — the result was a method with arguments: z.object({}) and an unused _args parameter whose body still interpolated args.<name>. Those methods failed type checking and were uncallable even if they had compiled, because the argument was never declared. Path-template placeholders are now unioned into the declared parameters, so the schema, the signature, and the body agree.

  2. Generated tests could request a URL the mock server did not serve. Test arguments merged the request-body fixture over the path-parameter values, so a body property sharing a name with a path parameter (commonly id) substituted its own example value into the URL. The request then missed the mock and failed with Cloudflare API error: Not found. Path parameters now take precedence, matching what the generated model already does by excluding path-parameter names from the request body.

Upgrade note: No API surface change and no method was added or removed. If this extension type-checked and tested cleanly before, its behavior is unchanged and only the version moved. Extensions that previously failed deno check or deno task test now pass.

2026.07.19.1

2026.07.19.1

Added: Initial code-generated release of @webframp/cloudflare/d1 with 12 methods covering the Cloudflare d1 API surface.

05Stats
A
100 / 100
Downloads
34
Archive size
16.4 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License2/2earned
  • Verified public repository2/2earned
06Platforms
07Labels