alchemy 0.15.9 → 0.15.11
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/aws/function.d.ts +4 -0
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +2 -0
- package/lib/aws/function.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/stripe/price.d.ts +11 -0
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +4 -0
- package/lib/stripe/price.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/aws/function.ts +7 -0
- 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/stripe/price.ts +17 -0
- package/src/util/sleep.ts +8 -0
|
@@ -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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,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 @@
|
|
|
1
|
+
{"version":3,"file":"d1-import.js","sourceRoot":"","sources":["../../src/cloudflare/d1-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAiNzC;;GAEG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAkB,EAClB,OAAgC;IAEhC,yDAAyD;IACzD,IAAI,aAAqB,CAAC;IAC1B,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACxC,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAClC,CAAC;SAAM,IAAI,OAAO,CAAC,OAAO,YAAY,IAAI,EAAE,CAAC;QAC3C,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,mCAAmC;QACnC,aAAa,GAAG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I,EAAE,CACvB,CAAC,MAAM,CAAC;IAET,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,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;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,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"}
|
|
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;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,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"}
|
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,CAAC;AACtD,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,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"}
|
|
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,CAAC;AACtD,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,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"}
|
package/lib/stripe/price.d.ts
CHANGED
|
@@ -78,6 +78,17 @@ export interface PriceProps {
|
|
|
78
78
|
* One of inclusive, exclusive, or unspecified.
|
|
79
79
|
*/
|
|
80
80
|
taxBehavior?: TaxBehavior;
|
|
81
|
+
/**
|
|
82
|
+
* A lookup key to uniquely identify this price.
|
|
83
|
+
* This key can be used to retrieve the price object without needing its ID.
|
|
84
|
+
* It must be unique across all prices in your Stripe account, otherwise creation will fail.
|
|
85
|
+
* If you want to transfer the lookup key from another price, set `transferLookupKey` to true
|
|
86
|
+
*/
|
|
87
|
+
lookupKey?: string;
|
|
88
|
+
/**
|
|
89
|
+
* If set to true, will atomically transfer the lookup key from an existing price to this price.
|
|
90
|
+
*/
|
|
91
|
+
transferLookupKey?: boolean;
|
|
81
92
|
}
|
|
82
93
|
/**
|
|
83
94
|
* Output from the Stripe price
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../src/stripe/price.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEtD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,SAAS,CAAC;IAEzD;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,cAAc,CAAC;CACpE;AAED,KAAK,WAAW,GAAG,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC;AACxD,KAAK,aAAa,GAAG,MAAM,CAAC,iBAAiB,CAAC,aAAa,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,iBAAi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CAAC;IAEpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,KAAM,SAAQ,QAAQ,CAAC,eAAe,CAAC,EAAE,UAAU;IAClE;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IAExB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,KAAK,yFAGR,OAAO,CAAC,KAAK,CAAC,MAChB,MAAM,SACH,UAAU,KAChB,OAAO,CAAC,KAAK,CAAC,CA0GlB,CAAC"}
|
package/lib/stripe/price.js
CHANGED
|
@@ -79,6 +79,8 @@ export const Price = Resource("stripe::Price", async function (id, props) {
|
|
|
79
79
|
active: props.active,
|
|
80
80
|
metadata: props.metadata,
|
|
81
81
|
nickname: props.nickname,
|
|
82
|
+
lookup_key: props.lookupKey,
|
|
83
|
+
transfer_lookup_key: props.transferLookupKey,
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
else {
|
|
@@ -91,6 +93,8 @@ export const Price = Resource("stripe::Price", async function (id, props) {
|
|
|
91
93
|
nickname: props.nickname,
|
|
92
94
|
metadata: props.metadata,
|
|
93
95
|
tax_behavior: props.taxBehavior,
|
|
96
|
+
lookup_key: props.lookupKey,
|
|
97
|
+
transfer_lookup_key: props.transferLookupKey,
|
|
94
98
|
};
|
|
95
99
|
// Add unit amount fields
|
|
96
100
|
if (props.unitAmount !== undefined) {
|
package/lib/stripe/price.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/stripe/price.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/stripe/price.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA0I1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAC3B,eAAe,EACf,KAAK,WAEH,EAAU,EACV,KAAiB;IAEjB,iDAAiD;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,2BAA2B;IAC3B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAElC,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,KAAK,KAAK,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C,OAAO,CAAC,EAAE;YACtE,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,WAAW,IAAI,SAAS;YAC1C,iBAAiB,EAAE,KAAK,CAAC,mBAAmB,IAAI,SAAS;YACzD,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,aAAa,EAAE,KAAK,CAAC,cAA+B;YACpD,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;YACrC,SAAS,EAAE,SAAS;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;YACrC,WAAW,EAAE,KAAK,CAAC,YAA2B;YAC9C,SAAS,EAAE,KAAK,CAAC,OAAO;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAyB;YACrC,SAAS,EAAE,KAAK,CAAC,UAAU,IAAI,SAAS;SACzC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;QACvD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,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"}
|
package/package.json
CHANGED
package/src/aws/function.ts
CHANGED
|
@@ -133,6 +133,11 @@ export interface FunctionProps {
|
|
|
133
133
|
maxAge?: number;
|
|
134
134
|
};
|
|
135
135
|
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Lambda layers for the function. Use the layer ARN
|
|
139
|
+
*/
|
|
140
|
+
layers?: string[];
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
/**
|
|
@@ -371,6 +376,7 @@ export const Function = Resource(
|
|
|
371
376
|
Environment: props.environment
|
|
372
377
|
? { Variables: props.environment }
|
|
373
378
|
: undefined,
|
|
379
|
+
Layers: props.layers,
|
|
374
380
|
}),
|
|
375
381
|
);
|
|
376
382
|
|
|
@@ -551,6 +557,7 @@ export const Function = Resource(
|
|
|
551
557
|
? [props.architecture]
|
|
552
558
|
: [Architecture.x86_64],
|
|
553
559
|
Tags: props.tags,
|
|
560
|
+
Layers: props.layers,
|
|
554
561
|
}),
|
|
555
562
|
);
|
|
556
563
|
break; // Success - exit retry loop
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { CloudflareApi } from "./api.js";
|
|
2
|
+
import {
|
|
3
|
+
exportD1Database,
|
|
4
|
+
type ExportD1DatabaseOptions,
|
|
5
|
+
type ExportD1DatabaseResult,
|
|
6
|
+
} from "./d1-export.js";
|
|
7
|
+
import {
|
|
8
|
+
importD1Database,
|
|
9
|
+
type ImportD1DatabaseOptions,
|
|
10
|
+
type ImportD1DatabaseResult,
|
|
11
|
+
} from "./d1-import.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for cloning a D1 database
|
|
15
|
+
*/
|
|
16
|
+
export interface CloneD1DatabaseOptions {
|
|
17
|
+
/**
|
|
18
|
+
* The ID of the source D1 database to clone from
|
|
19
|
+
*/
|
|
20
|
+
sourceDatabaseId: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The ID of the target D1 database to clone to
|
|
24
|
+
*/
|
|
25
|
+
targetDatabaseId: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Optional export options for the source database
|
|
29
|
+
*/
|
|
30
|
+
exportOptions?: Omit<ExportD1DatabaseOptions, "databaseId">;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Optional import options for the target database
|
|
34
|
+
*/
|
|
35
|
+
importOptions?: Omit<ImportD1DatabaseOptions, "databaseId" | "sqlData">;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Response from the clone D1 database operation
|
|
40
|
+
*/
|
|
41
|
+
export interface CloneD1DatabaseResult {
|
|
42
|
+
/**
|
|
43
|
+
* Result of the export operation
|
|
44
|
+
*/
|
|
45
|
+
exportResult: ExportD1DatabaseResult;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Result of the import operation
|
|
49
|
+
*/
|
|
50
|
+
importResult: ImportD1DatabaseResult;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Whether the clone operation was successful
|
|
54
|
+
*/
|
|
55
|
+
success: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Clones a D1 database by exporting from a source database and importing to a target database.
|
|
60
|
+
* Handles the full workflow:
|
|
61
|
+
* 1. Export source database to get a signed URL
|
|
62
|
+
* 2. Fetch SQL content from the signed URL
|
|
63
|
+
* 3. Import SQL content into the target database
|
|
64
|
+
*
|
|
65
|
+
* @param api The CloudflareApi instance to use for requests
|
|
66
|
+
* @param options Options including source and target database IDs
|
|
67
|
+
* @returns An object containing results from both export and import operations
|
|
68
|
+
* @throws Will throw an error if any part of the clone process fails
|
|
69
|
+
*/
|
|
70
|
+
export async function cloneD1Database(
|
|
71
|
+
api: CloudflareApi,
|
|
72
|
+
options: CloneD1DatabaseOptions,
|
|
73
|
+
): Promise<CloneD1DatabaseResult> {
|
|
74
|
+
const exportResult = await exportD1Database(api, {
|
|
75
|
+
databaseId: options.sourceDatabaseId,
|
|
76
|
+
...options.exportOptions,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!exportResult.success) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Failed to export source database: ${options.sourceDatabaseId}`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Step 2: Fetch SQL content from the signed URL
|
|
86
|
+
const sqlResponse = await fetch(exportResult.signed_url);
|
|
87
|
+
|
|
88
|
+
if (!sqlResponse.ok) {
|
|
89
|
+
throw new Error(`Failed to fetch SQL content: ${sqlResponse.statusText}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const sqlData = await sqlResponse.text();
|
|
93
|
+
|
|
94
|
+
// Step 3: Import SQL content into target database
|
|
95
|
+
const importResult = await importD1Database(api, {
|
|
96
|
+
databaseId: options.targetDatabaseId,
|
|
97
|
+
sqlData,
|
|
98
|
+
filename: exportResult.filename,
|
|
99
|
+
...options.importOptions,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (!importResult.success) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Failed to import to target database: ${options.targetDatabaseId}`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
exportResult,
|
|
110
|
+
importResult,
|
|
111
|
+
success: true,
|
|
112
|
+
};
|
|
113
|
+
}
|