alchemy 0.15.10 → 0.15.12
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/lib/cloudflare/account-api-token.d.ts +36 -19
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js +34 -26
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/d1-clone.d.ts +55 -0
- package/lib/cloudflare/d1-clone.d.ts.map +1 -0
- package/lib/cloudflare/d1-clone.js +45 -0
- package/lib/cloudflare/d1-clone.js.map +1 -0
- package/lib/cloudflare/d1-database.d.ts +36 -1
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +73 -9
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/d1-export.d.ts +63 -0
- package/lib/cloudflare/d1-export.d.ts.map +1 -0
- package/lib/cloudflare/d1-export.js +50 -0
- package/lib/cloudflare/d1-export.js.map +1 -0
- package/lib/cloudflare/d1-import.d.ts +112 -0
- package/lib/cloudflare/d1-import.d.ts.map +1 -0
- package/lib/cloudflare/d1-import.js +143 -0
- package/lib/cloudflare/d1-import.js.map +1 -0
- package/lib/cloudflare/index.d.ts +3 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +3 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/permission-groups.d.ts +2 -0
- package/lib/cloudflare/permission-groups.d.ts.map +1 -1
- package/lib/cloudflare/permission-groups.js.map +1 -1
- package/lib/util/sleep.d.ts +7 -0
- package/lib/util/sleep.d.ts.map +1 -0
- package/lib/util/sleep.js +9 -0
- package/lib/util/sleep.js.map +1 -0
- package/package.json +1 -1
- package/src/cloudflare/account-api-token.ts +72 -36
- package/src/cloudflare/d1-clone.ts +113 -0
- package/src/cloudflare/d1-database.ts +99 -15
- package/src/cloudflare/d1-export.ts +173 -0
- package/src/cloudflare/d1-import.ts +406 -0
- package/src/cloudflare/index.ts +3 -0
- package/src/cloudflare/permission-groups.ts +8 -0
- package/src/util/sleep.ts +8 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CloudflareApi } from "./api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for exporting a D1 database
|
|
4
|
+
*/
|
|
5
|
+
export interface ExportD1DatabaseOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The ID of the D1 database to export
|
|
8
|
+
*/
|
|
9
|
+
databaseId: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional dump options to control what is exported
|
|
12
|
+
*/
|
|
13
|
+
dumpOptions?: {
|
|
14
|
+
/**
|
|
15
|
+
* Optional list of tables to export
|
|
16
|
+
*/
|
|
17
|
+
tables?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Whether to exclude schema in the export
|
|
20
|
+
*/
|
|
21
|
+
no_schema?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to exclude data in the export
|
|
24
|
+
*/
|
|
25
|
+
no_data?: boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Response from the export D1 database operation
|
|
30
|
+
*/
|
|
31
|
+
export interface ExportD1DatabaseResult {
|
|
32
|
+
/**
|
|
33
|
+
* The filename of the exported database
|
|
34
|
+
*/
|
|
35
|
+
filename: string;
|
|
36
|
+
/**
|
|
37
|
+
* The signed URL for downloading the exported database
|
|
38
|
+
*/
|
|
39
|
+
signed_url: string;
|
|
40
|
+
/**
|
|
41
|
+
* The status of the export operation
|
|
42
|
+
*/
|
|
43
|
+
status: "complete";
|
|
44
|
+
/**
|
|
45
|
+
* Whether the export operation was successful
|
|
46
|
+
*/
|
|
47
|
+
success: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initiates an export of a Cloudflare D1 database and returns a download URL.
|
|
51
|
+
* Implements recursive polling with bookmark handling, similar to wrangler.
|
|
52
|
+
* Waits indefinitely until the export process completes or fails.
|
|
53
|
+
*
|
|
54
|
+
* Based on Cloudflare API:
|
|
55
|
+
* https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/export/
|
|
56
|
+
* and wrangler implementation.
|
|
57
|
+
*
|
|
58
|
+
* @param options Options including the database ID and optional dump parameters.
|
|
59
|
+
* @returns An object containing the download URL, filename, and status upon completion.
|
|
60
|
+
* @throws Will throw an error if the API call fails or the export process reports an error.
|
|
61
|
+
*/
|
|
62
|
+
export declare function exportD1Database(api: CloudflareApi, options: ExportD1DatabaseOptions, currentBookmark?: string): Promise<ExportD1DatabaseResult>;
|
|
63
|
+
//# sourceMappingURL=d1-export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d1-export.d.ts","sourceRoot":"","sources":["../../src/cloudflare/d1-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAElB;;WAEG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QAEpB;;WAEG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAuDD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,uBAAuB,EAChC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,sBAAsB,CAAC,CA6CjC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initiates an export of a Cloudflare D1 database and returns a download URL.
|
|
3
|
+
* Implements recursive polling with bookmark handling, similar to wrangler.
|
|
4
|
+
* Waits indefinitely until the export process completes or fails.
|
|
5
|
+
*
|
|
6
|
+
* Based on Cloudflare API:
|
|
7
|
+
* https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/export/
|
|
8
|
+
* and wrangler implementation.
|
|
9
|
+
*
|
|
10
|
+
* @param options Options including the database ID and optional dump parameters.
|
|
11
|
+
* @returns An object containing the download URL, filename, and status upon completion.
|
|
12
|
+
* @throws Will throw an error if the API call fails or the export process reports an error.
|
|
13
|
+
*/
|
|
14
|
+
export async function exportD1Database(api, options, currentBookmark) {
|
|
15
|
+
const response = await api.post(`/accounts/${api.accountId}/d1/database/${options.databaseId}/export`, {
|
|
16
|
+
output_format: "polling",
|
|
17
|
+
dump_options: options.dumpOptions || {},
|
|
18
|
+
current_bookmark: currentBookmark,
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
const errorData = (await response.json());
|
|
22
|
+
throw new Error(`Failed to export D1 database: ${errorData.error || errorData.errors?.[0]?.message || "Unknown error"}`);
|
|
23
|
+
}
|
|
24
|
+
const { result: data } = (await response.json());
|
|
25
|
+
if (!data.success) {
|
|
26
|
+
throw new Error(data.error || "Unknown error during D1 export");
|
|
27
|
+
}
|
|
28
|
+
// Log messages for visibility
|
|
29
|
+
if (data.messages && data.messages.length > 0) {
|
|
30
|
+
for (const message of data.messages) {
|
|
31
|
+
console.log(`D1 Export: ${message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (data.status === "complete" && data.result) {
|
|
35
|
+
return {
|
|
36
|
+
filename: data.result.filename,
|
|
37
|
+
signed_url: data.result.signed_url,
|
|
38
|
+
status: data.status,
|
|
39
|
+
success: data.success,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else if (data.status === "error") {
|
|
43
|
+
throw new Error(data.error || "Error during D1 export");
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Continue polling with bookmark
|
|
47
|
+
return exportD1Database(api, options, data.at_bookmark);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=d1-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d1-export.js","sourceRoot":"","sources":["../../src/cloudflare/d1-export.ts"],"names":[],"mappings":"AA8GA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAkB,EAClB,OAAgC,EAChC,eAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,CAC7B,aAAa,GAAG,CAAC,SAAS,gBAAgB,OAAO,CAAC,UAAU,SAAS,EACrE;QACE,aAAa,EAAE,SAAS;QACxB,YAAY,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;QACvC,gBAAgB,EAAE,eAAe;KAClC,CACF,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA4B,CAAC;QACrE,MAAM,IAAI,KAAK,CACb,iCAAiC,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,eAAe,EAAE,CACxG,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAE9C,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,gCAAgC,CAAC,CAAC;IAClE,CAAC;IAED,8BAA8B;IAC9B,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9C,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;YAClC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;SAAM,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,wBAAwB,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,iCAAiC;QACjC,OAAO,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { CloudflareApi } from "./api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for importing SQL into a D1 database
|
|
4
|
+
*/
|
|
5
|
+
export interface ImportD1DatabaseOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The ID of the D1 database to import into
|
|
8
|
+
*/
|
|
9
|
+
databaseId: string;
|
|
10
|
+
/**
|
|
11
|
+
* The SQL file data to upload
|
|
12
|
+
*/
|
|
13
|
+
sqlData: Blob | BufferSource | string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional custom filename for the imported SQL
|
|
16
|
+
*/
|
|
17
|
+
filename?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Response from the import D1 database operation
|
|
21
|
+
*/
|
|
22
|
+
export interface ImportD1DatabaseResult {
|
|
23
|
+
/**
|
|
24
|
+
* The filename of the imported database
|
|
25
|
+
*/
|
|
26
|
+
filename: string;
|
|
27
|
+
/**
|
|
28
|
+
* Additional result information from the import operation
|
|
29
|
+
*/
|
|
30
|
+
result: {
|
|
31
|
+
/**
|
|
32
|
+
* Final bookmark used during import
|
|
33
|
+
*/
|
|
34
|
+
final_bookmark?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Metadata about the import operation
|
|
37
|
+
*/
|
|
38
|
+
meta: {
|
|
39
|
+
/**
|
|
40
|
+
* Whether the database was changed
|
|
41
|
+
*/
|
|
42
|
+
changed_db: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Number of changes made
|
|
45
|
+
*/
|
|
46
|
+
changes: number;
|
|
47
|
+
/**
|
|
48
|
+
* Duration of the operation
|
|
49
|
+
*/
|
|
50
|
+
duration: number;
|
|
51
|
+
/**
|
|
52
|
+
* ID of the last row
|
|
53
|
+
*/
|
|
54
|
+
last_row_id: number;
|
|
55
|
+
/**
|
|
56
|
+
* Number of rows read
|
|
57
|
+
*/
|
|
58
|
+
rows_read: number;
|
|
59
|
+
/**
|
|
60
|
+
* Number of rows written
|
|
61
|
+
*/
|
|
62
|
+
rows_written: number;
|
|
63
|
+
/**
|
|
64
|
+
* Whether served by primary
|
|
65
|
+
*/
|
|
66
|
+
served_by_primary: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Region that served the request
|
|
69
|
+
*/
|
|
70
|
+
served_by_region: string;
|
|
71
|
+
/**
|
|
72
|
+
* Size after import
|
|
73
|
+
*/
|
|
74
|
+
size_after: number;
|
|
75
|
+
/**
|
|
76
|
+
* Timing information
|
|
77
|
+
*/
|
|
78
|
+
timings: {
|
|
79
|
+
/**
|
|
80
|
+
* SQL execution duration in milliseconds
|
|
81
|
+
*/
|
|
82
|
+
sql_duration_ms: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Number of queries executed
|
|
87
|
+
*/
|
|
88
|
+
num_queries: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The status of the import operation
|
|
92
|
+
*/
|
|
93
|
+
status: "complete";
|
|
94
|
+
/**
|
|
95
|
+
* Whether the import operation was successful
|
|
96
|
+
*/
|
|
97
|
+
success: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Initiates an import of SQL into a Cloudflare D1 database.
|
|
101
|
+
* Implements a flow to get an upload URL, upload the SQL file, and poll for status updates.
|
|
102
|
+
*
|
|
103
|
+
* Based on Cloudflare API:
|
|
104
|
+
* https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/import/
|
|
105
|
+
*
|
|
106
|
+
* @param api The CloudflareApi instance to use for requests
|
|
107
|
+
* @param options Options including the database ID and SQL data to import
|
|
108
|
+
* @returns An object containing the import results and status upon completion
|
|
109
|
+
* @throws Will throw an error if the API call fails or the import process reports an error
|
|
110
|
+
*/
|
|
111
|
+
export declare function importD1Database(api: CloudflareApi, options: ImportD1DatabaseOptions): Promise<ImportD1DatabaseResult>;
|
|
112
|
+
//# sourceMappingURL=d1-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d1-import.d.ts","sourceRoot":"","sources":["../../src/cloudflare/d1-import.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,IAAI,GAAG,YAAY,GAAG,MAAM,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE;QACN;;WAEG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB;;WAEG;QACH,IAAI,EAAE;YACJ;;eAEG;YACH,UAAU,EAAE,OAAO,CAAC;YAEpB;;eAEG;YACH,OAAO,EAAE,MAAM,CAAC;YAEhB;;eAEG;YACH,QAAQ,EAAE,MAAM,CAAC;YAEjB;;eAEG;YACH,WAAW,EAAE,MAAM,CAAC;YAEpB;;eAEG;YACH,SAAS,EAAE,MAAM,CAAC;YAElB;;eAEG;YACH,YAAY,EAAE,MAAM,CAAC;YAErB;;eAEG;YACH,iBAAiB,EAAE,OAAO,CAAC;YAE3B;;eAEG;YACH,gBAAgB,EAAE,MAAM,CAAC;YAEzB;;eAEG;YACH,UAAU,EAAE,MAAM,CAAC;YAEnB;;eAEG;YACH,OAAO,EAAE;gBACP;;mBAEG;gBACH,eAAe,EAAE,MAAM,CAAC;aACzB,CAAC;SACH,CAAC;QAEF;;WAEG;QACH,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAoGD;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAiFjC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Calculates MD5 hash for a string
|
|
4
|
+
*/
|
|
5
|
+
function getMd5Hash(data) {
|
|
6
|
+
return createHash("md5").update(data).digest("hex");
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Initiates an import of SQL into a Cloudflare D1 database.
|
|
10
|
+
* Implements a flow to get an upload URL, upload the SQL file, and poll for status updates.
|
|
11
|
+
*
|
|
12
|
+
* Based on Cloudflare API:
|
|
13
|
+
* https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/import/
|
|
14
|
+
*
|
|
15
|
+
* @param api The CloudflareApi instance to use for requests
|
|
16
|
+
* @param options Options including the database ID and SQL data to import
|
|
17
|
+
* @returns An object containing the import results and status upon completion
|
|
18
|
+
* @throws Will throw an error if the API call fails or the import process reports an error
|
|
19
|
+
*/
|
|
20
|
+
export async function importD1Database(api, options) {
|
|
21
|
+
// Convert data to string for hashing if it's not already
|
|
22
|
+
let sqlDataString;
|
|
23
|
+
if (typeof options.sqlData === "string") {
|
|
24
|
+
sqlDataString = options.sqlData;
|
|
25
|
+
}
|
|
26
|
+
else if (options.sqlData instanceof Blob) {
|
|
27
|
+
sqlDataString = await options.sqlData.text();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// BufferSource (ArrayBuffer, etc.)
|
|
31
|
+
sqlDataString = new TextDecoder().decode(options.sqlData);
|
|
32
|
+
}
|
|
33
|
+
// Calculate MD5 hash of SQL data
|
|
34
|
+
const etag = getMd5Hash(sqlDataString);
|
|
35
|
+
// Step 1: Initialize the import process to get an upload URL
|
|
36
|
+
const initResponse = await api.post(`/accounts/${api.accountId}/d1/database/${options.databaseId}/import`, {
|
|
37
|
+
action: "init",
|
|
38
|
+
etag,
|
|
39
|
+
});
|
|
40
|
+
if (!initResponse.ok) {
|
|
41
|
+
const errorData = (await initResponse.json());
|
|
42
|
+
throw new Error(`Failed to initialize D1 database import: ${errorData.error || errorData.errors?.[0]?.message || "Unknown error"}`);
|
|
43
|
+
}
|
|
44
|
+
const initData = (await initResponse.json());
|
|
45
|
+
const uploadResult = initData.result;
|
|
46
|
+
if (!uploadResult.success || !uploadResult.upload_url) {
|
|
47
|
+
throw new Error(uploadResult.error || "Failed to get upload URL for D1 import");
|
|
48
|
+
}
|
|
49
|
+
// Step 2: Upload the SQL file
|
|
50
|
+
await uploadSqlFile(uploadResult.upload_url, options.sqlData, options.filename || uploadResult.filename);
|
|
51
|
+
// Step 3: Ingest the uploaded file
|
|
52
|
+
const ingestResponse = await api.post(`/accounts/${api.accountId}/d1/database/${options.databaseId}/import`, {
|
|
53
|
+
action: "ingest",
|
|
54
|
+
etag,
|
|
55
|
+
filename: uploadResult.filename,
|
|
56
|
+
});
|
|
57
|
+
if (!ingestResponse.ok) {
|
|
58
|
+
const errorData = (await ingestResponse.json());
|
|
59
|
+
throw new Error(`Failed to ingest D1 database upload: ${errorData.error || errorData.errors?.[0]?.message || "Unknown error"}`);
|
|
60
|
+
}
|
|
61
|
+
const ingestData = (await ingestResponse.json());
|
|
62
|
+
const ingestResult = ingestData.result;
|
|
63
|
+
if (!ingestResult.success) {
|
|
64
|
+
throw new Error(ingestResult.error || "Failed to start ingestion for D1 import");
|
|
65
|
+
}
|
|
66
|
+
if (!ingestResult.at_bookmark) {
|
|
67
|
+
throw new Error("Ingest response did not contain a bookmark for polling");
|
|
68
|
+
}
|
|
69
|
+
// Step 4: Poll for status
|
|
70
|
+
return pollImportStatus(api, options.databaseId, ingestResult.at_bookmark);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Uploads an SQL file to the provided URL
|
|
74
|
+
*/
|
|
75
|
+
async function uploadSqlFile(uploadUrl, sqlData, filename) {
|
|
76
|
+
// Convert data to the right format if needed
|
|
77
|
+
let blob;
|
|
78
|
+
if (typeof sqlData === "string") {
|
|
79
|
+
blob = new Blob([sqlData], { type: "application/sql" });
|
|
80
|
+
}
|
|
81
|
+
else if (sqlData instanceof Blob) {
|
|
82
|
+
blob = sqlData;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// BufferSource (ArrayBuffer, etc.)
|
|
86
|
+
blob = new Blob([sqlData], { type: "application/sql" });
|
|
87
|
+
}
|
|
88
|
+
// Create a FormData object with the file
|
|
89
|
+
const formData = new FormData();
|
|
90
|
+
formData.append("file", blob, filename || "import.sql");
|
|
91
|
+
const response = await fetch(uploadUrl, {
|
|
92
|
+
method: "PUT",
|
|
93
|
+
body: blob,
|
|
94
|
+
headers: {
|
|
95
|
+
"Content-Type": "application/sql",
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
if (!response.ok) {
|
|
99
|
+
throw new Error(`Failed to upload SQL file: ${response.statusText}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Polls for the import status with the provided bookmark
|
|
104
|
+
*/
|
|
105
|
+
async function pollImportStatus(api, databaseId, bookmark) {
|
|
106
|
+
if (!bookmark) {
|
|
107
|
+
throw new Error("Cannot poll an import without a bookmark");
|
|
108
|
+
}
|
|
109
|
+
const response = await api.post(`/accounts/${api.accountId}/d1/database/${databaseId}/import`, {
|
|
110
|
+
action: "poll",
|
|
111
|
+
current_bookmark: bookmark,
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const errorData = (await response.json());
|
|
115
|
+
throw new Error(`Failed to poll D1 import status: ${errorData.error || errorData.errors?.[0]?.message || "Unknown error"}`);
|
|
116
|
+
}
|
|
117
|
+
const data = (await response.json()).result;
|
|
118
|
+
if (!data.success) {
|
|
119
|
+
throw new Error(data.error || "Unknown error during D1 import");
|
|
120
|
+
}
|
|
121
|
+
// Log messages for visibility
|
|
122
|
+
if (data.messages && data.messages.length > 0) {
|
|
123
|
+
for (const message of data.messages) {
|
|
124
|
+
console.log(`D1 Import: ${message}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (data.status === "complete" && data.result) {
|
|
128
|
+
return {
|
|
129
|
+
filename: data.filename || "import.sql",
|
|
130
|
+
result: data.result,
|
|
131
|
+
status: data.status,
|
|
132
|
+
success: data.success,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
else if (data.status === "error") {
|
|
136
|
+
throw new Error(data.error || "Error during D1 import");
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Continue polling with bookmark
|
|
140
|
+
return pollImportStatus(api, databaseId, data.at_bookmark);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=d1-import.js.map
|
|
@@ -0,0 +1 @@
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AQ,EAAE,IAAI,CAAC,QAAQ,IAAI,YAAY;YACvC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;SAAM,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,wBAAwB,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,iCAAiC;QACjC,OAAO,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -11,7 +11,10 @@ export * from "./bucket.js";
|
|
|
11
11
|
export * from "./bundle/external.js";
|
|
12
12
|
export * from "./bundle/local-dev-cloudflare-shim.js";
|
|
13
13
|
export * from "./custom-domain.js";
|
|
14
|
+
export * from "./d1-clone.js";
|
|
14
15
|
export * from "./d1-database.js";
|
|
16
|
+
export * from "./d1-export.js";
|
|
17
|
+
export * from "./d1-import.js";
|
|
15
18
|
export * from "./dns-records.js";
|
|
16
19
|
export * from "./durable-object-namespace.js";
|
|
17
20
|
export * from "./hyperdrive.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uCAAuC,CAAC;AACtD,cAAc,oBAAoB,CAAC;A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,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
|
package/lib/cloudflare/index.js
CHANGED
|
@@ -11,7 +11,10 @@ export * from "./bucket.js";
|
|
|
11
11
|
export * from "./bundle/external.js";
|
|
12
12
|
export * from "./bundle/local-dev-cloudflare-shim.js";
|
|
13
13
|
export * from "./custom-domain.js";
|
|
14
|
+
export * from "./d1-clone.js";
|
|
14
15
|
export * from "./d1-database.js";
|
|
16
|
+
export * from "./d1-export.js";
|
|
17
|
+
export * from "./d1-import.js";
|
|
15
18
|
export * from "./dns-records.js";
|
|
16
19
|
export * from "./durable-object-namespace.js";
|
|
17
20
|
export * from "./hyperdrive.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uCAAuC,C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ChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
|
|
@@ -18,6 +18,8 @@ export interface PermissionGroup {
|
|
|
18
18
|
*/
|
|
19
19
|
scopes: string[];
|
|
20
20
|
}
|
|
21
|
+
export type PermissionGroupName = R2PermissionGroups;
|
|
22
|
+
export type R2PermissionGroups = "Workers R2 Storage Write" | "Workers R2 Storage Read" | "Workers R2 Storage Bucket Item Write" | "Workers R2 Storage Bucket Item Read";
|
|
21
23
|
/**
|
|
22
24
|
* All Cloudflare permission groups mapped by name to ID
|
|
23
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-groups.d.ts","sourceRoot":"","sources":["../../src/cloudflare/permission-groups.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,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Ae,CAAC;IAE5C;;;OAGG;IACH,yBAAyB,EAAE,eAAe,CAAC;IAE3C;;OAEG;IACH,sCAAsC,EAAE,eAAe,CAAC;IAExD;;OAEG;IACH,qCAAqC,EAAE,eAAe,CAAC;IAEvD;;OAEG;IACH,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,gBAAgB,yFAGnB,OAAO,CAAC,gBAAgB,CAAC,MAC3B,MAAM,YACD,oBAAoB,KAC5B,OAAO,CAAC,gBAAgB,CAAC,CAkC7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-groups.js","sourceRoot":"","sources":["../../src/cloudflare/permission-groups.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAA6B,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"permission-groups.js","sourceRoot":"","sources":["../../src/cloudflare/permission-groups.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAA6B,MAAM,UAAU,CAAC;AA0E1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CACtC,8BAA8B,EAC9B,KAAK,WAEH,EAAU,EACV,UAAgC,EAAE;IAElC,8CAA8C;IAC9C,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,wBAAwB;IACxB,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE/C,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAC5B,aAAa,GAAG,CAAC,SAAS,2BAA2B,CACtD,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,sCAAsC,QAAQ,CAAC,UAAU,EAAE,CAC5D,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA6B,CAAC;IAEjE,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,eAAe,EAAE,CACtE,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CACT,MAAM,CAAC,WAAW,CAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAC5B,CACtB,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pauses execution for a specified number of milliseconds.
|
|
3
|
+
* @param ms The number of milliseconds to sleep.
|
|
4
|
+
* @returns A promise that resolves after the specified time.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=sleep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/util/sleep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pauses execution for a specified number of milliseconds.
|
|
3
|
+
* @param ms The number of milliseconds to sleep.
|
|
4
|
+
* @returns A promise that resolves after the specified time.
|
|
5
|
+
*/
|
|
6
|
+
export function sleep(ms) {
|
|
7
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=sleep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/util/sleep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|