alchemy 2.0.0-beta.21 → 2.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/alchemy.js +1 -1
- package/bin/alchemy.js.map +1 -1
- package/lib/Cloudflare/D1/D1Clone.d.ts +13 -0
- package/lib/Cloudflare/D1/D1Clone.d.ts.map +1 -0
- package/lib/Cloudflare/D1/D1Clone.js +31 -0
- package/lib/Cloudflare/D1/D1Clone.js.map +1 -0
- package/lib/Cloudflare/D1/D1Database.d.ts +150 -5
- package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Database.js +253 -0
- package/lib/Cloudflare/D1/D1Database.js.map +1 -1
- package/lib/Cloudflare/D1/D1Export.d.ts +24 -0
- package/lib/Cloudflare/D1/D1Export.d.ts.map +1 -0
- package/lib/Cloudflare/D1/D1Export.js +34 -0
- package/lib/Cloudflare/D1/D1Export.js.map +1 -0
- package/lib/Cloudflare/D1/D1Import.d.ts +21 -0
- package/lib/Cloudflare/D1/D1Import.d.ts.map +1 -0
- package/lib/Cloudflare/D1/D1Import.js +87 -0
- package/lib/Cloudflare/D1/D1Import.js.map +1 -0
- package/lib/Cloudflare/D1/D1Migrations.d.ts +16 -0
- package/lib/Cloudflare/D1/D1Migrations.d.ts.map +1 -0
- package/lib/Cloudflare/D1/D1Migrations.js +110 -0
- package/lib/Cloudflare/D1/D1Migrations.js.map +1 -0
- package/lib/Cloudflare/D1/D1SqlFile.d.ts +20 -0
- package/lib/Cloudflare/D1/D1SqlFile.d.ts.map +1 -0
- package/lib/Cloudflare/D1/D1SqlFile.js +46 -0
- package/lib/Cloudflare/D1/D1SqlFile.js.map +1 -0
- package/lib/Cloudflare/Providers.d.ts +1 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Cloudflare/D1/D1Clone.ts +42 -0
- package/src/Cloudflare/D1/D1Database.ts +386 -3
- package/src/Cloudflare/D1/D1Export.ts +70 -0
- package/src/Cloudflare/D1/D1Import.ts +156 -0
- package/src/Cloudflare/D1/D1Migrations.ts +229 -0
- package/src/Cloudflare/D1/D1SqlFile.ts +57 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
export interface CloneD1DatabaseOptions {
|
|
3
|
+
accountId: string;
|
|
4
|
+
sourceDatabaseId: string;
|
|
5
|
+
targetDatabaseId: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Clone a D1 database by exporting from the source and importing into the
|
|
9
|
+
* target. Fetches the SQL dump from the export's signed URL and streams the
|
|
10
|
+
* payload through the import flow.
|
|
11
|
+
*/
|
|
12
|
+
export declare const cloneD1Database: (options: CloneD1DatabaseOptions) => Effect.Effect<import("./D1Import.ts").ImportD1DatabaseResult, import("@distilled.cloud/axiom").ConfigError | import("@distilled.cloud/axiom").Unauthorized | import("@distilled.cloud/axiom").TooManyRequests | import("@distilled.cloud/axiom").InternalServerError | import("@distilled.cloud/axiom").BadGateway | import("@distilled.cloud/axiom").ServiceUnavailable | import("@distilled.cloud/axiom").GatewayTimeout | import("@distilled.cloud/cloudflare").CloudflareHttpError | import("@distilled.cloud/cloudflare").CloudflareParseError | import("@distilled.cloud/cloudflare").UnknownCloudflareError | import("@distilled.cloud/cloudflare").OAuthRefreshError | import("@distilled.cloud/cloudflare/d1").InvalidObjectIdentifier | import("@distilled.cloud/cloudflare/d1").InvalidRequest | import("@distilled.cloud/cloudflare/d1").DatabaseNotFound, any>;
|
|
13
|
+
//# sourceMappingURL=D1Clone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"D1Clone.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/D1/D1Clone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,sBAAsB,g1BAwB3D,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
3
|
+
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
4
|
+
import { exportD1Database } from "./D1Export.js";
|
|
5
|
+
import { importD1Database } from "./D1Import.js";
|
|
6
|
+
/**
|
|
7
|
+
* Clone a D1 database by exporting from the source and importing into the
|
|
8
|
+
* target. Fetches the SQL dump from the export's signed URL and streams the
|
|
9
|
+
* payload through the import flow.
|
|
10
|
+
*/
|
|
11
|
+
export const cloneD1Database = (options) => Effect.gen(function* () {
|
|
12
|
+
const exportResult = yield* exportD1Database({
|
|
13
|
+
accountId: options.accountId,
|
|
14
|
+
databaseId: options.sourceDatabaseId,
|
|
15
|
+
});
|
|
16
|
+
const client = yield* HttpClient.HttpClient;
|
|
17
|
+
const dumpRes = yield* client
|
|
18
|
+
.execute(HttpClientRequest.get(exportResult.signedUrl))
|
|
19
|
+
.pipe(Effect.orDie);
|
|
20
|
+
if (dumpRes.status < 200 || dumpRes.status >= 300) {
|
|
21
|
+
return yield* Effect.die(`Failed to fetch D1 export dump (${dumpRes.status})`);
|
|
22
|
+
}
|
|
23
|
+
const sqlData = yield* dumpRes.text.pipe(Effect.orDie);
|
|
24
|
+
return yield* importD1Database({
|
|
25
|
+
accountId: options.accountId,
|
|
26
|
+
databaseId: options.targetDatabaseId,
|
|
27
|
+
sqlData,
|
|
28
|
+
filename: exportResult.filename,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=D1Clone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"D1Clone.js","sourceRoot":"","sources":["../../../src/C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AAQ,EAAE,YAAY,CAAC,QAAQ;KAChC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as Provider from "../../Provider.ts";
|
|
2
2
|
import { Resource } from "../../Resource.ts";
|
|
3
|
-
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
4
3
|
import type { Providers } from "../Providers.ts";
|
|
5
4
|
export type Jurisdiction = "default" | "eu" | "fedramp";
|
|
6
5
|
export type PrimaryLocationHint = "wnam" | "enam" | "weur" | "eeur" | "apac" | "oc";
|
|
6
|
+
export type CloneSource = D1Database | {
|
|
7
|
+
databaseId: string;
|
|
8
|
+
} | {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
7
11
|
export type DatabaseProps = {
|
|
8
12
|
/**
|
|
9
13
|
* Name of the database. If omitted, a unique name will be generated.
|
|
@@ -11,20 +15,72 @@ export type DatabaseProps = {
|
|
|
11
15
|
*/
|
|
12
16
|
name?: string;
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* Region in which the primary copy of the data is stored. Cannot be
|
|
19
|
+
* changed after creation — updating this property triggers a replacement.
|
|
20
|
+
*
|
|
21
|
+
* - `wnam` — Western North America
|
|
22
|
+
* - `enam` — Eastern North America
|
|
23
|
+
* - `weur` — Western Europe
|
|
24
|
+
* - `eeur` — Eastern Europe
|
|
25
|
+
* - `apac` — Asia Pacific
|
|
26
|
+
* - `oc` — Oceania
|
|
15
27
|
*/
|
|
16
28
|
primaryLocationHint?: PrimaryLocationHint;
|
|
17
29
|
/**
|
|
18
|
-
* Read replication configuration.
|
|
30
|
+
* Read replication configuration. The only mutable property after
|
|
31
|
+
* creation; toggling `mode` triggers an in-place update.
|
|
32
|
+
*
|
|
33
|
+
* @default { mode: "disabled" }
|
|
19
34
|
*/
|
|
20
35
|
readReplication?: {
|
|
21
36
|
mode: "auto" | "disabled";
|
|
22
37
|
};
|
|
23
38
|
/**
|
|
24
|
-
* Jurisdiction
|
|
39
|
+
* Jurisdiction in which the database data is guaranteed to be stored.
|
|
40
|
+
* Cannot be changed after creation.
|
|
41
|
+
*
|
|
25
42
|
* @default "default"
|
|
26
43
|
*/
|
|
27
44
|
jurisdiction?: Jurisdiction;
|
|
45
|
+
/**
|
|
46
|
+
* Directory containing `.sql` migration files. Files are sorted by their
|
|
47
|
+
* numeric prefix (e.g. `0001_init.sql`, `0002_add_users.sql`) and applied
|
|
48
|
+
* in order. Pending migrations are detected on each deploy and applied as
|
|
49
|
+
* part of `update`. Equivalent to wrangler's `migrations_dir`.
|
|
50
|
+
*/
|
|
51
|
+
migrationsDir?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Name of the table used to track applied migrations. Useful for
|
|
54
|
+
* compatibility with frameworks that expect a specific name (e.g.
|
|
55
|
+
* `drizzle_migrations`).
|
|
56
|
+
*
|
|
57
|
+
* The table schema is the wrangler-compatible
|
|
58
|
+
* `(id TEXT PRIMARY KEY, name TEXT, applied_at TEXT)`. A pre-existing
|
|
59
|
+
* legacy 2-column table is migrated in place.
|
|
60
|
+
*
|
|
61
|
+
* @default "d1_migrations"
|
|
62
|
+
*/
|
|
63
|
+
migrationsTable?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Paths to additional `.sql` files to import after migrations are
|
|
66
|
+
* applied. Each file is uploaded via Cloudflare's D1 import API and
|
|
67
|
+
* hashed; only files whose contents change are re-imported on subsequent
|
|
68
|
+
* deploys.
|
|
69
|
+
*
|
|
70
|
+
* @see https://developers.cloudflare.com/d1/best-practices/import-export-data/
|
|
71
|
+
*/
|
|
72
|
+
importFiles?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Clone data from an existing database during creation by exporting the
|
|
75
|
+
* source and importing it into the new database. Only applied during the
|
|
76
|
+
* `create` phase.
|
|
77
|
+
*
|
|
78
|
+
* Accepts:
|
|
79
|
+
* - another `D1Database` resource (uses its `databaseId`)
|
|
80
|
+
* - `{ databaseId }` — clone by explicit UUID
|
|
81
|
+
* - `{ name }` — look up the source by name and clone it
|
|
82
|
+
*/
|
|
83
|
+
clone?: CloneSource;
|
|
28
84
|
};
|
|
29
85
|
export type D1Database = Resource<"Cloudflare.D1Database", DatabaseProps, {
|
|
30
86
|
databaseId: string;
|
|
@@ -34,6 +90,10 @@ export type D1Database = Resource<"Cloudflare.D1Database", DatabaseProps, {
|
|
|
34
90
|
mode: "auto" | "disabled";
|
|
35
91
|
} | undefined;
|
|
36
92
|
accountId: string;
|
|
93
|
+
migrationsDir: string | undefined;
|
|
94
|
+
migrationsTable: string | undefined;
|
|
95
|
+
migrationsHashes: Record<string, string>;
|
|
96
|
+
importHashes: Record<string, string>;
|
|
37
97
|
}, never, Providers>;
|
|
38
98
|
/**
|
|
39
99
|
* A Cloudflare D1 serverless SQL database built on SQLite.
|
|
@@ -48,12 +108,95 @@ export type D1Database = Resource<"Cloudflare.D1Database", DatabaseProps, {
|
|
|
48
108
|
* ```
|
|
49
109
|
*
|
|
50
110
|
* @example Database with location hint
|
|
111
|
+
* The primary copy of the data is stored in the chosen region; reads can be
|
|
112
|
+
* served closer to users when read replication is enabled.
|
|
51
113
|
* ```typescript
|
|
52
114
|
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
53
115
|
* primaryLocationHint: "wnam",
|
|
54
116
|
* });
|
|
55
117
|
* ```
|
|
56
118
|
*
|
|
119
|
+
* @example Database with read replication
|
|
120
|
+
* Read replication is the only mutable property after creation — toggling it
|
|
121
|
+
* triggers an update rather than a replacement.
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
124
|
+
* readReplication: { mode: "auto" },
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @example Database in a specific jurisdiction
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
131
|
+
* jurisdiction: "eu",
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @section Migrations
|
|
136
|
+
* Point `migrationsDir` at a folder of `.sql` files. Files are sorted by
|
|
137
|
+
* numeric prefix (e.g. `0001_`, `0002_`) and applied in order. Already-applied
|
|
138
|
+
* migrations are skipped on subsequent deploys; new files are detected
|
|
139
|
+
* automatically and applied as part of the next update.
|
|
140
|
+
*
|
|
141
|
+
* Migration tracking uses the wrangler-compatible
|
|
142
|
+
* `(id TEXT PRIMARY KEY, name TEXT, applied_at TEXT)` schema. The resource
|
|
143
|
+
* also detects and upgrades a legacy 2-column tracking table in place if one
|
|
144
|
+
* already exists.
|
|
145
|
+
*
|
|
146
|
+
* @example Apply migrations from a directory
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
149
|
+
* migrationsDir: "./migrations",
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* @example Custom migrations table (e.g. for Drizzle)
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
156
|
+
* migrationsDir: "./migrations",
|
|
157
|
+
* migrationsTable: "drizzle_migrations",
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @section Importing SQL
|
|
162
|
+
* Use `importFiles` to seed the database with raw `.sql` files via Cloudflare's
|
|
163
|
+
* D1 import API. Each file is hashed; only files whose contents change are
|
|
164
|
+
* re-imported on subsequent deploys.
|
|
165
|
+
*
|
|
166
|
+
* @example Seed a database with SQL files
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
169
|
+
* importFiles: ["./seed/users.sql", "./seed/posts.sql"],
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @section Cloning a Database
|
|
174
|
+
* `clone` performs a full export → import from a source database during
|
|
175
|
+
* creation. It accepts a `D1Database` resource, a `{ databaseId }`, or a
|
|
176
|
+
* `{ name }` to look up by name.
|
|
177
|
+
*
|
|
178
|
+
* @example Clone by passing the source resource directly
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const source = yield* Cloudflare.D1Database("source-db");
|
|
181
|
+
* const cloned = yield* Cloudflare.D1Database("cloned-db", {
|
|
182
|
+
* clone: source,
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @example Clone by databaseId
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const cloned = yield* Cloudflare.D1Database("cloned-db", {
|
|
189
|
+
* clone: { databaseId: "abcdef12-3456-7890-abcd-ef1234567890" },
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example Clone by name
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const cloned = yield* Cloudflare.D1Database("cloned-db", {
|
|
196
|
+
* clone: { name: "source-db" },
|
|
197
|
+
* });
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
57
200
|
* @section Binding to a Worker
|
|
58
201
|
* @example Using D1 inside a Worker
|
|
59
202
|
* ```typescript
|
|
@@ -69,7 +212,9 @@ export type D1Database = Resource<"Cloudflare.D1Database", DatabaseProps, {
|
|
|
69
212
|
* .bind(newId, name)
|
|
70
213
|
* .run();
|
|
71
214
|
* ```
|
|
215
|
+
*
|
|
216
|
+
* @see https://developers.cloudflare.com/d1/
|
|
72
217
|
*/
|
|
73
218
|
export declare const D1Database: import("../../Resource.ts").ResourceClass<D1Database>;
|
|
74
|
-
export declare const DatabaseProvider: () => import("effect/Layer").Layer<Provider.Provider<D1Database>, never,
|
|
219
|
+
export declare const DatabaseProvider: () => import("effect/Layer").Layer<Provider.Provider<D1Database>, never, any>;
|
|
75
220
|
//# sourceMappingURL=D1Database.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1Database.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/D1/D1Database.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,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EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,GAAG,SAAS,CAAC;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,EACD,KAAK,EACL,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuHG;AACH,eAAO,MAAM,UAAU,uDAAgD,CAAC;AAExE,eAAO,MAAM,gBAAgB,+EAoP1B,CAAC"}
|
|
@@ -5,6 +5,11 @@ import { createPhysicalName } from "../../PhysicalName.js";
|
|
|
5
5
|
import * as Provider from "../../Provider.js";
|
|
6
6
|
import { Resource } from "../../Resource.js";
|
|
7
7
|
import { CloudflareEnvironment } from "../CloudflareEnvironment.js";
|
|
8
|
+
import { cloneD1Database } from "./D1Clone.js";
|
|
9
|
+
import { importD1Database } from "./D1Import.js";
|
|
10
|
+
import { applyMigrations } from "./D1Migrations.js";
|
|
11
|
+
import { listSqlFiles, readSqlFile } from "./D1SqlFile.js";
|
|
12
|
+
const DEFAULT_MIGRATIONS_TABLE = "d1_migrations";
|
|
8
13
|
/**
|
|
9
14
|
* A Cloudflare D1 serverless SQL database built on SQLite.
|
|
10
15
|
*
|
|
@@ -18,12 +23,95 @@ import { CloudflareEnvironment } from "../CloudflareEnvironment.js";
|
|
|
18
23
|
* ```
|
|
19
24
|
*
|
|
20
25
|
* @example Database with location hint
|
|
26
|
+
* The primary copy of the data is stored in the chosen region; reads can be
|
|
27
|
+
* served closer to users when read replication is enabled.
|
|
21
28
|
* ```typescript
|
|
22
29
|
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
23
30
|
* primaryLocationHint: "wnam",
|
|
24
31
|
* });
|
|
25
32
|
* ```
|
|
26
33
|
*
|
|
34
|
+
* @example Database with read replication
|
|
35
|
+
* Read replication is the only mutable property after creation — toggling it
|
|
36
|
+
* triggers an update rather than a replacement.
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
39
|
+
* readReplication: { mode: "auto" },
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Database in a specific jurisdiction
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
46
|
+
* jurisdiction: "eu",
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @section Migrations
|
|
51
|
+
* Point `migrationsDir` at a folder of `.sql` files. Files are sorted by
|
|
52
|
+
* numeric prefix (e.g. `0001_`, `0002_`) and applied in order. Already-applied
|
|
53
|
+
* migrations are skipped on subsequent deploys; new files are detected
|
|
54
|
+
* automatically and applied as part of the next update.
|
|
55
|
+
*
|
|
56
|
+
* Migration tracking uses the wrangler-compatible
|
|
57
|
+
* `(id TEXT PRIMARY KEY, name TEXT, applied_at TEXT)` schema. The resource
|
|
58
|
+
* also detects and upgrades a legacy 2-column tracking table in place if one
|
|
59
|
+
* already exists.
|
|
60
|
+
*
|
|
61
|
+
* @example Apply migrations from a directory
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
64
|
+
* migrationsDir: "./migrations",
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example Custom migrations table (e.g. for Drizzle)
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
71
|
+
* migrationsDir: "./migrations",
|
|
72
|
+
* migrationsTable: "drizzle_migrations",
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @section Importing SQL
|
|
77
|
+
* Use `importFiles` to seed the database with raw `.sql` files via Cloudflare's
|
|
78
|
+
* D1 import API. Each file is hashed; only files whose contents change are
|
|
79
|
+
* re-imported on subsequent deploys.
|
|
80
|
+
*
|
|
81
|
+
* @example Seed a database with SQL files
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const db = yield* Cloudflare.D1Database("my-db", {
|
|
84
|
+
* importFiles: ["./seed/users.sql", "./seed/posts.sql"],
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @section Cloning a Database
|
|
89
|
+
* `clone` performs a full export → import from a source database during
|
|
90
|
+
* creation. It accepts a `D1Database` resource, a `{ databaseId }`, or a
|
|
91
|
+
* `{ name }` to look up by name.
|
|
92
|
+
*
|
|
93
|
+
* @example Clone by passing the source resource directly
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const source = yield* Cloudflare.D1Database("source-db");
|
|
96
|
+
* const cloned = yield* Cloudflare.D1Database("cloned-db", {
|
|
97
|
+
* clone: source,
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @example Clone by databaseId
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const cloned = yield* Cloudflare.D1Database("cloned-db", {
|
|
104
|
+
* clone: { databaseId: "abcdef12-3456-7890-abcd-ef1234567890" },
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example Clone by name
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const cloned = yield* Cloudflare.D1Database("cloned-db", {
|
|
111
|
+
* clone: { name: "source-db" },
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
27
115
|
* @section Binding to a Worker
|
|
28
116
|
* @example Using D1 inside a Worker
|
|
29
117
|
* ```typescript
|
|
@@ -39,6 +127,8 @@ import { CloudflareEnvironment } from "../CloudflareEnvironment.js";
|
|
|
39
127
|
* .bind(newId, name)
|
|
40
128
|
* .run();
|
|
41
129
|
* ```
|
|
130
|
+
*
|
|
131
|
+
* @see https://developers.cloudflare.com/d1/
|
|
42
132
|
*/
|
|
43
133
|
export const D1Database = Resource("Cloudflare.D1Database");
|
|
44
134
|
export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(function* () {
|
|
@@ -48,6 +138,8 @@ export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(fun
|
|
|
48
138
|
const patchDb = yield* d1.patchDatabase;
|
|
49
139
|
const deleteDb = yield* d1.deleteDatabase;
|
|
50
140
|
const listDbs = yield* d1.listDatabases;
|
|
141
|
+
// rootDir for resolving relative `importFiles` paths
|
|
142
|
+
const rootDir = process.cwd();
|
|
51
143
|
const createDatabaseName = (id, name) => Effect.gen(function* () {
|
|
52
144
|
return name ?? (yield* createPhysicalName({ id }));
|
|
53
145
|
});
|
|
@@ -77,6 +169,31 @@ export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(fun
|
|
|
77
169
|
if (oldReplicationMode !== newReplicationMode) {
|
|
78
170
|
return { action: "update" };
|
|
79
171
|
}
|
|
172
|
+
// Detect migration/import file drift.
|
|
173
|
+
if (news.migrationsDir) {
|
|
174
|
+
const newHashes = yield* hashMigrations(news.migrationsDir);
|
|
175
|
+
const oldHashes = output?.migrationsHashes ?? {};
|
|
176
|
+
if (!recordsEqual(newHashes, oldHashes)) {
|
|
177
|
+
return { action: "update" };
|
|
178
|
+
}
|
|
179
|
+
if ((news.migrationsTable ?? DEFAULT_MIGRATIONS_TABLE) !==
|
|
180
|
+
(output?.migrationsTable ?? DEFAULT_MIGRATIONS_TABLE)) {
|
|
181
|
+
return { action: "update" };
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else if (output?.migrationsHashes &&
|
|
185
|
+
Object.keys(output.migrationsHashes).length > 0) {
|
|
186
|
+
// migrationsDir was removed but state still tracks migrations: nothing
|
|
187
|
+
// to do remotely (we never un-apply), but no diff needed either.
|
|
188
|
+
}
|
|
189
|
+
if (news.importFiles?.length) {
|
|
190
|
+
const newHashes = yield* hashImports(news.importFiles, rootDir);
|
|
191
|
+
const oldHashes = output?.importHashes ?? {};
|
|
192
|
+
if (!recordsEqual(newHashes, oldHashes)) {
|
|
193
|
+
return { action: "update" };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
80
197
|
}),
|
|
81
198
|
read: Effect.fn(function* ({ id, output, olds }) {
|
|
82
199
|
if (output?.databaseId) {
|
|
@@ -89,6 +206,10 @@ export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(fun
|
|
|
89
206
|
jurisdiction: output.jurisdiction,
|
|
90
207
|
readReplication: db.readReplication ?? undefined,
|
|
91
208
|
accountId: output.accountId,
|
|
209
|
+
migrationsDir: output.migrationsDir,
|
|
210
|
+
migrationsTable: output.migrationsTable,
|
|
211
|
+
migrationsHashes: output.migrationsHashes,
|
|
212
|
+
importHashes: output.importHashes,
|
|
92
213
|
})), Effect.catchTag("DatabaseNotFound", () => Effect.succeed(undefined)));
|
|
93
214
|
}
|
|
94
215
|
const name = yield* createDatabaseName(id, olds?.name);
|
|
@@ -101,6 +222,10 @@ export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(fun
|
|
|
101
222
|
jurisdiction: (olds?.jurisdiction ?? "default"),
|
|
102
223
|
readReplication: olds?.readReplication,
|
|
103
224
|
accountId,
|
|
225
|
+
migrationsDir: olds?.migrationsDir,
|
|
226
|
+
migrationsTable: olds?.migrationsTable,
|
|
227
|
+
migrationsHashes: {},
|
|
228
|
+
importHashes: {},
|
|
104
229
|
};
|
|
105
230
|
}
|
|
106
231
|
return undefined;
|
|
@@ -129,12 +254,31 @@ export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(fun
|
|
|
129
254
|
readReplication: news.readReplication,
|
|
130
255
|
});
|
|
131
256
|
}
|
|
257
|
+
if (news.clone) {
|
|
258
|
+
const sourceId = yield* resolveCloneSource(news.clone, accountId, listDbs);
|
|
259
|
+
yield* cloneD1Database({
|
|
260
|
+
accountId,
|
|
261
|
+
sourceDatabaseId: sourceId,
|
|
262
|
+
targetDatabaseId: databaseId,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
const migrationsTable = news.migrationsTable ?? DEFAULT_MIGRATIONS_TABLE;
|
|
266
|
+
const migrationsHashes = news.migrationsDir
|
|
267
|
+
? yield* runMigrations(accountId, databaseId, news.migrationsDir, migrationsTable)
|
|
268
|
+
: {};
|
|
269
|
+
const importHashes = news.importFiles?.length
|
|
270
|
+
? yield* runImports(accountId, databaseId, news.importFiles, rootDir, {})
|
|
271
|
+
: {};
|
|
132
272
|
return {
|
|
133
273
|
databaseId,
|
|
134
274
|
databaseName: db.name ?? name,
|
|
135
275
|
jurisdiction,
|
|
136
276
|
readReplication: news.readReplication,
|
|
137
277
|
accountId,
|
|
278
|
+
migrationsDir: news.migrationsDir,
|
|
279
|
+
migrationsTable: news.migrationsDir ? migrationsTable : undefined,
|
|
280
|
+
migrationsHashes,
|
|
281
|
+
importHashes,
|
|
138
282
|
};
|
|
139
283
|
}),
|
|
140
284
|
update: Effect.fn(function* ({ news = {}, output }) {
|
|
@@ -144,12 +288,25 @@ export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(fun
|
|
|
144
288
|
databaseId: output.databaseId,
|
|
145
289
|
readReplication: { mode: replicationMode },
|
|
146
290
|
});
|
|
291
|
+
const migrationsTable = news.migrationsTable ??
|
|
292
|
+
output.migrationsTable ??
|
|
293
|
+
DEFAULT_MIGRATIONS_TABLE;
|
|
294
|
+
const migrationsHashes = news.migrationsDir
|
|
295
|
+
? yield* runMigrations(output.accountId, output.databaseId, news.migrationsDir, migrationsTable)
|
|
296
|
+
: output.migrationsHashes;
|
|
297
|
+
const importHashes = news.importFiles?.length
|
|
298
|
+
? yield* runImports(output.accountId, output.databaseId, news.importFiles, rootDir, output.importHashes ?? {})
|
|
299
|
+
: {};
|
|
147
300
|
return {
|
|
148
301
|
databaseId: updated.uuid ?? output.databaseId,
|
|
149
302
|
databaseName: updated.name ?? output.databaseName,
|
|
150
303
|
jurisdiction: output.jurisdiction,
|
|
151
304
|
readReplication: news.readReplication,
|
|
152
305
|
accountId: output.accountId,
|
|
306
|
+
migrationsDir: news.migrationsDir,
|
|
307
|
+
migrationsTable: news.migrationsDir ? migrationsTable : undefined,
|
|
308
|
+
migrationsHashes,
|
|
309
|
+
importHashes,
|
|
153
310
|
};
|
|
154
311
|
}),
|
|
155
312
|
delete: Effect.fn(function* ({ output }) {
|
|
@@ -160,4 +317,100 @@ export const DatabaseProvider = () => Provider.effect(D1Database, Effect.gen(fun
|
|
|
160
317
|
}),
|
|
161
318
|
};
|
|
162
319
|
}));
|
|
320
|
+
/**
|
|
321
|
+
* Resolve a clone source spec into a concrete database UUID. Looks up by
|
|
322
|
+
* name through `listDatabases` when only a name is provided.
|
|
323
|
+
*/
|
|
324
|
+
const resolveCloneSource = (source, accountId, listDbs) => Effect.gen(function* () {
|
|
325
|
+
if ("databaseId" in source && source.databaseId) {
|
|
326
|
+
// At lifecycle time, Output<string> attributes have resolved to strings.
|
|
327
|
+
return source.databaseId;
|
|
328
|
+
}
|
|
329
|
+
if ("name" in source && source.name) {
|
|
330
|
+
const name = source.name;
|
|
331
|
+
const dbs = yield* listDbs({ accountId, name });
|
|
332
|
+
const match = dbs.result.find((db) => db.name === name);
|
|
333
|
+
if (!match?.uuid) {
|
|
334
|
+
return yield* Effect.die(`Source database "${name}" not found for cloning`);
|
|
335
|
+
}
|
|
336
|
+
return match.uuid;
|
|
337
|
+
}
|
|
338
|
+
return yield* Effect.die("Invalid clone source: must provide databaseId or name");
|
|
339
|
+
});
|
|
340
|
+
/**
|
|
341
|
+
* Read all migration files from `migrationsDir`, run pending migrations,
|
|
342
|
+
* and return the per-file content hashes for state tracking.
|
|
343
|
+
*/
|
|
344
|
+
const runMigrations = (accountId, databaseId, migrationsDir, migrationsTable) => Effect.gen(function* () {
|
|
345
|
+
const files = yield* listSqlFiles(migrationsDir);
|
|
346
|
+
if (files.length > 0) {
|
|
347
|
+
yield* applyMigrations({
|
|
348
|
+
accountId,
|
|
349
|
+
databaseId,
|
|
350
|
+
migrationsTable,
|
|
351
|
+
migrationsFiles: files,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
const hashes = {};
|
|
355
|
+
for (const file of files)
|
|
356
|
+
hashes[file.id] = file.hash;
|
|
357
|
+
return hashes;
|
|
358
|
+
});
|
|
359
|
+
/**
|
|
360
|
+
* Read each `importFiles` entry and run it through the D1 import flow,
|
|
361
|
+
* skipping files whose hash matches the previously-imported hash.
|
|
362
|
+
*/
|
|
363
|
+
const runImports = (accountId, databaseId, importFiles, rootDir, previous) => Effect.gen(function* () {
|
|
364
|
+
const hashes = { ...previous };
|
|
365
|
+
for (const filePath of importFiles) {
|
|
366
|
+
const file = yield* readSqlFile(rootDir, filePath);
|
|
367
|
+
if (previous[filePath] === file.hash) {
|
|
368
|
+
hashes[filePath] = file.hash;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
yield* importD1Database({
|
|
372
|
+
accountId,
|
|
373
|
+
databaseId,
|
|
374
|
+
sqlData: file.sql,
|
|
375
|
+
filename: file.id,
|
|
376
|
+
});
|
|
377
|
+
hashes[filePath] = file.hash;
|
|
378
|
+
}
|
|
379
|
+
// Drop entries for files no longer listed.
|
|
380
|
+
const tracked = new Set(importFiles);
|
|
381
|
+
for (const key of Object.keys(hashes)) {
|
|
382
|
+
if (!tracked.has(key))
|
|
383
|
+
delete hashes[key];
|
|
384
|
+
}
|
|
385
|
+
return hashes;
|
|
386
|
+
});
|
|
387
|
+
/**
|
|
388
|
+
* Hash all `.sql` files in `migrationsDir` without applying them; used by
|
|
389
|
+
* `diff` to detect drift relative to previously-applied state.
|
|
390
|
+
*/
|
|
391
|
+
const hashMigrations = (migrationsDir) => listSqlFiles(migrationsDir).pipe(Effect.map((files) => {
|
|
392
|
+
const hashes = {};
|
|
393
|
+
for (const file of files)
|
|
394
|
+
hashes[file.id] = file.hash;
|
|
395
|
+
return hashes;
|
|
396
|
+
}));
|
|
397
|
+
const hashImports = (importFiles, rootDir) => Effect.gen(function* () {
|
|
398
|
+
const hashes = {};
|
|
399
|
+
for (const filePath of importFiles) {
|
|
400
|
+
const file = yield* readSqlFile(rootDir, filePath);
|
|
401
|
+
hashes[filePath] = file.hash;
|
|
402
|
+
}
|
|
403
|
+
return hashes;
|
|
404
|
+
});
|
|
405
|
+
const recordsEqual = (a, b) => {
|
|
406
|
+
const aKeys = Object.keys(a);
|
|
407
|
+
const bKeys = Object.keys(b);
|
|
408
|
+
if (aKeys.length !== bKeys.length)
|
|
409
|
+
return false;
|
|
410
|
+
for (const k of aKeys) {
|
|
411
|
+
if (a[k] !== b[k])
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
return true;
|
|
415
|
+
};
|
|
163
416
|
//# sourceMappingURL=D1Database.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1Database.js","sourceRoot":"","sources":["../../../src/Cloudflare/D1/D1Database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAiDpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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/cloudflare/d1";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
4
|
+
import type { Credentials } from "@distilled.cloud/cloudflare/Credentials";
|
|
5
|
+
export interface ExportD1DatabaseOptions {
|
|
6
|
+
accountId: string;
|
|
7
|
+
databaseId: string;
|
|
8
|
+
dumpOptions?: {
|
|
9
|
+
tables?: string[];
|
|
10
|
+
noSchema?: boolean;
|
|
11
|
+
noData?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ExportD1DatabaseResult {
|
|
15
|
+
filename: string;
|
|
16
|
+
signedUrl: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Initiates an export of a Cloudflare D1 database and returns a signed
|
|
20
|
+
* download URL. Recursively polls with the bookmark until the export
|
|
21
|
+
* completes or fails.
|
|
22
|
+
*/
|
|
23
|
+
export declare const exportD1Database: (options: ExportD1DatabaseOptions) => Effect.Effect<ExportD1DatabaseResult, d1.ExportDatabaseError, Credentials | HttpClient.HttpClient>;
|
|
24
|
+
//# sourceMappingURL=D1Export.d.ts.map
|