@cardonjs/backups 0.0.0-stage → 0.3.2
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/FORMAT.md +147 -0
- package/LICENSE +21 -0
- package/README.md +1237 -2
- package/dist/copy.d.ts +175 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +863 -0
- package/dist/copy.js.map +1 -0
- package/dist/encryption.d.ts +203 -0
- package/dist/encryption.d.ts.map +1 -0
- package/dist/encryption.js +609 -0
- package/dist/encryption.js.map +1 -0
- package/dist/export.d.ts +201 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +447 -0
- package/dist/export.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +28 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +97 -0
- package/dist/keys.js.map +1 -0
- package/dist/metadata.d.ts +49 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +51 -0
- package/dist/metadata.js.map +1 -0
- package/dist/restore.d.ts +97 -0
- package/dist/restore.d.ts.map +1 -0
- package/dist/restore.js +276 -0
- package/dist/restore.js.map +1 -0
- package/dist/retention.d.ts +153 -0
- package/dist/retention.d.ts.map +1 -0
- package/dist/retention.js +295 -0
- package/dist/retention.js.map +1 -0
- package/dist/run.d.ts +94 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +129 -0
- package/dist/run.js.map +1 -0
- package/dist/sniff.d.ts +15 -0
- package/dist/sniff.d.ts.map +1 -0
- package/dist/sniff.js +47 -0
- package/dist/sniff.js.map +1 -0
- package/dist/workflow.d.ts +102 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +298 -0
- package/dist/workflow.js.map +1 -0
- package/llms.txt +249 -0
- package/package.json +76 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","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,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG;gBACrD,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAC5C,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,IAAmB,CAAC;QACxB,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,SAAS;QACT,UAAU;QACV,MAAM;QACN,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,QAAQ;YACjB,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC/B,MAAM,IAAI,SAAS,CAAC,8DAA8D,CAAC,CAAC;YACtF,CAAC;YACD,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@cardonjs/backups`: Cloudflare's D1 export streamed into R2 (optionally encrypted on the way),
|
|
3
|
+
* retention, the backup keys and `decryptBackup`. Runs on Workers (the copy streams through the
|
|
4
|
+
* R2 binding); `decryptBackup` runs on Node too. The Workflow is at
|
|
5
|
+
* `@cardonjs/backups/workflow` and the restore check, for Node, at `@cardonjs/backups/restore`.
|
|
6
|
+
*/
|
|
7
|
+
export { type CopyExportOptions, type CopyFailureReason, type CopyResult, copyExport, } from "./copy.js";
|
|
8
|
+
export { type AuthenticatedHeader, BackupDecryptError, type BackupDecryptionOptions, type BackupDecryptReason, type BackupEncryption, type BackupEncryptionInfo, type BackupEncryptionOptions, type BackupIdentity, backupEncryption, claimedKeyId, type DecryptBackupStream, decryptBackup, ENCRYPTION_SCHEME, type EncryptionScheme, type ExpectedBackup, encryptedSize, KEY_ID_PROBE_BYTES, MAX_PLAINTEXT_SIZE, } from "./encryption.js";
|
|
9
|
+
export { type D1Exporter, type D1ExportOptions, type DownloadFailureReason, type DownloadOptions, type DownloadResult, d1Export, type ExportFailure, type ExportFailureReason, type ExportPending, type ExportPollResult, type ExportReady, type ExportStartResult, isValidBookmark, isValidDatabaseId, } from "./export.js";
|
|
10
|
+
export { assertValidPrefix, backupInstanceId, backupKey, parseBackupKey } from "./keys.js";
|
|
11
|
+
export { DIGEST_SUFFIX, digestKey, METADATA } from "./metadata.js";
|
|
12
|
+
export { assertValidRetention, type BackupEntry, dayOf, isoWeekOf, type ListBackupsResult, type ListedBackup, listBackups, monthOf, type OrphanDigest, type PruneOptions, type PruneRefusal, PruneRefusedError, type PruneResult, planRetention, pruneBackups, type Retention, type RetentionPlan, } from "./retention.js";
|
|
13
|
+
export { type RunBackupOptions, type RunBackupResult, runBackup } from "./run.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,mBAAmB,EACxB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,gBAAgB,EAChB,YAAY,EACZ,KAAK,mBAAmB,EACxB,aAAa,EACb,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,eAAe,EACf,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,EACL,SAAS,EACT,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,WAAW,EACX,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,iBAAiB,EACjB,KAAK,WAAW,EAChB,aAAa,EACb,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@cardonjs/backups`: Cloudflare's D1 export streamed into R2 (optionally encrypted on the way),
|
|
3
|
+
* retention, the backup keys and `decryptBackup`. Runs on Workers (the copy streams through the
|
|
4
|
+
* R2 binding); `decryptBackup` runs on Node too. The Workflow is at
|
|
5
|
+
* `@cardonjs/backups/workflow` and the restore check, for Node, at `@cardonjs/backups/restore`.
|
|
6
|
+
*/
|
|
7
|
+
export { copyExport, } from "./copy.js";
|
|
8
|
+
export { BackupDecryptError, backupEncryption, claimedKeyId, decryptBackup, ENCRYPTION_SCHEME, encryptedSize, KEY_ID_PROBE_BYTES, MAX_PLAINTEXT_SIZE, } from "./encryption.js";
|
|
9
|
+
export { d1Export, isValidBookmark, isValidDatabaseId, } from "./export.js";
|
|
10
|
+
export { assertValidPrefix, backupInstanceId, backupKey, parseBackupKey } from "./keys.js";
|
|
11
|
+
export { DIGEST_SUFFIX, digestKey, METADATA } from "./metadata.js";
|
|
12
|
+
export { assertValidRetention, dayOf, isoWeekOf, listBackups, monthOf, PruneRefusedError, planRetention, pruneBackups, } from "./retention.js";
|
|
13
|
+
export { runBackup } from "./run.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAIL,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,kBAAkB,EAOlB,gBAAgB,EAChB,YAAY,EAEZ,aAAa,EACb,iBAAiB,EAGjB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,QAAQ,EAOR,eAAe,EACf,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EACL,oBAAoB,EAEpB,KAAK,EACL,SAAS,EAGT,WAAW,EACX,OAAO,EAIP,iBAAiB,EAEjB,aAAa,EACb,YAAY,GAGb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA+C,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup keys: `<prefix>/<yyyy>/<mm>/<yyyy-mm-ddThh-mm-ssZ>.sql`, in UTC. Built only here, from a
|
|
3
|
+
* date and a validated prefix; retention recognises exactly this pattern and nothing else.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Checks a prefix such as `d1/main`: 1 to 8 segments of letters, digits, `-` and `_`, joined by
|
|
7
|
+
* `/`, without a leading or trailing `/`, at most 256 characters. Throws a `TypeError` that never
|
|
8
|
+
* includes the value.
|
|
9
|
+
*/
|
|
10
|
+
export declare function assertValidPrefix(prefix: unknown, where?: string): asserts prefix is string;
|
|
11
|
+
/**
|
|
12
|
+
* The key of a backup taken at `at` (UTC, to the second):
|
|
13
|
+
* `backupKey("d1/main", new Date("2026-11-20T03:00:05Z"))` →
|
|
14
|
+
* `d1/main/2026/11/2026-11-20T03-00-05Z.sql`. Years 1000 to 9999 only.
|
|
15
|
+
*/
|
|
16
|
+
export declare function backupKey(prefix: string, at: Date): string;
|
|
17
|
+
/**
|
|
18
|
+
* The moment a key under `prefix` stands for, or `null` when the key is not exactly one this
|
|
19
|
+
* package builds: another prefix (`d1/main2/…` is not under `d1/main`), a deeper path, another
|
|
20
|
+
* extension, a folder that disagrees with the file name, or a date that does not exist
|
|
21
|
+
* (`2026-02-30`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseBackupKey(prefix: string, key: string): Date | null;
|
|
24
|
+
/** The instance id for a daily backup: `backup-2026-11-20` (UTC). */
|
|
25
|
+
export declare function backupInstanceId(at: Date, name?: string): string;
|
|
26
|
+
/** The moment of a backup key under any valid prefix, or `null` (see `parseBackupKey`). */
|
|
27
|
+
export declare function parseKeyAnyPrefix(key: unknown): Date | null;
|
|
28
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAY9F;AAQD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,GAAG,MAAM,CAW1D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAYvE;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,SAAW,GAAG,MAAM,CAQlE;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAW3D"}
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup keys: `<prefix>/<yyyy>/<mm>/<yyyy-mm-ddThh-mm-ssZ>.sql`, in UTC. Built only here, from a
|
|
3
|
+
* date and a validated prefix; retention recognises exactly this pattern and nothing else.
|
|
4
|
+
*/
|
|
5
|
+
/** One prefix segment: letters, digits, `-` and `_` (no dots, so no `..`). */
|
|
6
|
+
const SEGMENT = /^[A-Za-z0-9_-]{1,64}$/;
|
|
7
|
+
const MAX_PREFIX_LENGTH = 256;
|
|
8
|
+
const MAX_SEGMENTS = 8;
|
|
9
|
+
/** What follows `<prefix>/` in a backup key. */
|
|
10
|
+
const KEY_TAIL = /^(\d{4})\/(\d{2})\/(\d{4})-(\d{2})-(\d{2})T(\d{2})-(\d{2})-(\d{2})Z\.sql$/;
|
|
11
|
+
/**
|
|
12
|
+
* Checks a prefix such as `d1/main`: 1 to 8 segments of letters, digits, `-` and `_`, joined by
|
|
13
|
+
* `/`, without a leading or trailing `/`, at most 256 characters. Throws a `TypeError` that never
|
|
14
|
+
* includes the value.
|
|
15
|
+
*/
|
|
16
|
+
export function assertValidPrefix(prefix, where = "backups") {
|
|
17
|
+
const problem = typeof prefix !== "string"
|
|
18
|
+
? "must be a string"
|
|
19
|
+
: prefix.length === 0 || prefix.length > MAX_PREFIX_LENGTH
|
|
20
|
+
? `must be 1 to ${MAX_PREFIX_LENGTH} characters`
|
|
21
|
+
: prefix.split("/").length > MAX_SEGMENTS
|
|
22
|
+
? `must have at most ${MAX_SEGMENTS} segments`
|
|
23
|
+
: prefix.split("/").every((segment) => SEGMENT.test(segment))
|
|
24
|
+
? undefined
|
|
25
|
+
: "must be segments of letters, digits, '-' and '_' joined by '/' (e.g. \"d1/main\")";
|
|
26
|
+
if (problem !== undefined)
|
|
27
|
+
throw new TypeError(`${where}: prefix ${problem}.`);
|
|
28
|
+
}
|
|
29
|
+
function isValidDate(value) {
|
|
30
|
+
return value instanceof Date && Number.isFinite(value.getTime());
|
|
31
|
+
}
|
|
32
|
+
const pad = (n, width = 2) => String(n).padStart(width, "0");
|
|
33
|
+
/**
|
|
34
|
+
* The key of a backup taken at `at` (UTC, to the second):
|
|
35
|
+
* `backupKey("d1/main", new Date("2026-11-20T03:00:05Z"))` →
|
|
36
|
+
* `d1/main/2026/11/2026-11-20T03-00-05Z.sql`. Years 1000 to 9999 only.
|
|
37
|
+
*/
|
|
38
|
+
export function backupKey(prefix, at) {
|
|
39
|
+
assertValidPrefix(prefix, "backupKey");
|
|
40
|
+
if (!isValidDate(at))
|
|
41
|
+
throw new TypeError("backupKey: at must be a valid Date.");
|
|
42
|
+
const year = at.getUTCFullYear();
|
|
43
|
+
if (year < 1000 || year > 9999)
|
|
44
|
+
throw new TypeError("backupKey: the year must have 4 digits.");
|
|
45
|
+
const yyyy = pad(year, 4);
|
|
46
|
+
const mm = pad(at.getUTCMonth() + 1);
|
|
47
|
+
const stamp = `${yyyy}-${mm}-${pad(at.getUTCDate())}T${pad(at.getUTCHours())}-${pad(at.getUTCMinutes())}-${pad(at.getUTCSeconds())}Z`;
|
|
48
|
+
return `${prefix}/${yyyy}/${mm}/${stamp}.sql`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The moment a key under `prefix` stands for, or `null` when the key is not exactly one this
|
|
52
|
+
* package builds: another prefix (`d1/main2/…` is not under `d1/main`), a deeper path, another
|
|
53
|
+
* extension, a folder that disagrees with the file name, or a date that does not exist
|
|
54
|
+
* (`2026-02-30`).
|
|
55
|
+
*/
|
|
56
|
+
export function parseBackupKey(prefix, key) {
|
|
57
|
+
assertValidPrefix(prefix, "parseBackupKey");
|
|
58
|
+
if (typeof key !== "string" || !key.startsWith(`${prefix}/`))
|
|
59
|
+
return null;
|
|
60
|
+
const match = KEY_TAIL.exec(key.slice(prefix.length + 1));
|
|
61
|
+
if (match === null)
|
|
62
|
+
return null;
|
|
63
|
+
const [, folderYear, folderMonth, year, month, day, hours, minutes, seconds] = match;
|
|
64
|
+
if (folderYear !== year || folderMonth !== month)
|
|
65
|
+
return null;
|
|
66
|
+
const at = new Date(`${year}-${month}-${day}T${hours}:${minutes}:${seconds}Z`);
|
|
67
|
+
// `Date` rolls invalid dates over (Feb 30 → Mar 2): the key must round-trip exactly.
|
|
68
|
+
if (!isValidDate(at) || backupKey(prefix, at) !== key)
|
|
69
|
+
return null;
|
|
70
|
+
return at;
|
|
71
|
+
}
|
|
72
|
+
/** The instance id for a daily backup: `backup-2026-11-20` (UTC). */
|
|
73
|
+
export function backupInstanceId(at, name = "backup") {
|
|
74
|
+
if (!isValidDate(at))
|
|
75
|
+
throw new TypeError("backupInstanceId: at must be a valid Date.");
|
|
76
|
+
if (typeof name !== "string" || !/^[A-Za-z0-9_-]{1,80}$/.test(name)) {
|
|
77
|
+
throw new TypeError("backupInstanceId: name must be 1 to 80 letters, digits, '-' or '_' characters.");
|
|
78
|
+
}
|
|
79
|
+
return `${name}-${at.toISOString().slice(0, 10)}`;
|
|
80
|
+
}
|
|
81
|
+
/** The moment of a backup key under any valid prefix, or `null` (see `parseBackupKey`). */
|
|
82
|
+
export function parseKeyAnyPrefix(key) {
|
|
83
|
+
if (typeof key !== "string")
|
|
84
|
+
return null;
|
|
85
|
+
const match = /^(.+)\/\d{4}\/\d{2}\/[^/]+$/.exec(key);
|
|
86
|
+
if (match === null)
|
|
87
|
+
return null;
|
|
88
|
+
const prefix = match[1];
|
|
89
|
+
try {
|
|
90
|
+
assertValidPrefix(prefix);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return parseBackupKey(prefix, key);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8EAA8E;AAC9E,MAAM,OAAO,GAAG,uBAAuB,CAAC;AACxC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,gDAAgD;AAChD,MAAM,QAAQ,GAAG,2EAA2E,CAAC;AAE7F;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe,EAAE,KAAK,GAAG,SAAS;IAClE,MAAM,OAAO,GACX,OAAO,MAAM,KAAK,QAAQ;QACxB,CAAC,CAAC,kBAAkB;QACpB,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,iBAAiB;YACxD,CAAC,CAAC,gBAAgB,iBAAiB,aAAa;YAChD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,YAAY;gBACvC,CAAC,CAAC,qBAAqB,YAAY,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,EAAE,IAAI,GAAG,QAAQ;IACxD,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;IACxF,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,SAAS,CACjB,gFAAgF,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,KAAK,GAAG,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAW,CAAC;IAClC,IAAI,CAAC;QACH,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** The custom metadata keys every backup object carries. */
|
|
2
|
+
export declare const METADATA: {
|
|
3
|
+
/** `"1"`: written by this package. Retention only touches objects with it. */
|
|
4
|
+
readonly marker: "cardon-backup";
|
|
5
|
+
/** The bookmark the export reported when the dump was downloaded (its point in time). */
|
|
6
|
+
readonly bookmark: "bookmark";
|
|
7
|
+
/**
|
|
8
|
+
* The backup run that wrote the object (`copyExport`'s `run`): fixed before the first export
|
|
9
|
+
* starts and the same across retries and restarted exports, so reuse matches on it and never
|
|
10
|
+
* on a bookmark (a restarted export has another one).
|
|
11
|
+
*/
|
|
12
|
+
readonly run: "run";
|
|
13
|
+
readonly databaseId: "database-id";
|
|
14
|
+
/** ISO 8601, the moment the key stands for. */
|
|
15
|
+
readonly createdAt: "created-at";
|
|
16
|
+
/**
|
|
17
|
+
* The object's size in bytes (the encrypted size for an encrypted backup), when it was known
|
|
18
|
+
* before the upload (absent for a multipart upload of unknown length).
|
|
19
|
+
*/
|
|
20
|
+
readonly bytes: "bytes";
|
|
21
|
+
/** `"d1"` or `"sqlite3"` (see `d1Export`'s `format`). */
|
|
22
|
+
readonly format: "format";
|
|
23
|
+
/**
|
|
24
|
+
* On the digest sidecar only: the identity of the exact dump object it was written for, as R2
|
|
25
|
+
* returned it from the dump's `put` or multipart `complete` (`version:<version>`, or
|
|
26
|
+
* `etag:<etag>` where R2 gives no version). Reuse compares it with the object at the key, so a
|
|
27
|
+
* sidecar never vouches for another write of the same key (an earlier export's late `put`).
|
|
28
|
+
*/
|
|
29
|
+
readonly dumpObject: "dump-object";
|
|
30
|
+
/**
|
|
31
|
+
* On an encrypted backup and its sidecar: the scheme (`aes-256-gcm-stream-v1`). Absent on a
|
|
32
|
+
* plain one. Says how it was encrypted, never with what.
|
|
33
|
+
*/
|
|
34
|
+
readonly encryption: "encryption";
|
|
35
|
+
/** On an encrypted backup and its sidecar: the id of the configured key (not secret). */
|
|
36
|
+
readonly keyId: "key-id";
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The digest sidecar of a backup is `<key>.sha256`: the SHA-256 of the stored object (the
|
|
40
|
+
* ciphertext, for an encrypted backup) as 64 hex characters, written after the dump was stored
|
|
41
|
+
* and checked, with the same metadata marker, bookmark, run, database id and encryption scheme
|
|
42
|
+
* and key id, plus the dump object's identity (`dump-object`). Never counted as a backup;
|
|
43
|
+
* retention deletes it with its dump. It detects
|
|
44
|
+
* corruption, not tampering: whoever can rewrite the dump can rewrite its sidecar too.
|
|
45
|
+
*/
|
|
46
|
+
export declare const DIGEST_SUFFIX = ".sha256";
|
|
47
|
+
/** The key of the digest sidecar of the backup at `key`. */
|
|
48
|
+
export declare function digestKey(key: string): string;
|
|
49
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,eAAO,MAAM,QAAQ;IACnB,8EAA8E;aAC9E,MAAM,EAAE,eAAe;IACvB,yFAAyF;aACzF,QAAQ,EAAE,UAAU;IACpB;;;;OAIG;aACH,GAAG,EAAE,KAAK;aACV,UAAU,EAAE,aAAa;IACzB,+CAA+C;aAC/C,SAAS,EAAE,YAAY;IACvB;;;OAGG;aACH,KAAK,EAAE,OAAO;IACd,yDAAyD;aACzD,MAAM,EAAE,QAAQ;IAChB;;;;;OAKG;aACH,UAAU,EAAE,aAAa;IACzB;;;OAGG;aACH,UAAU,EAAE,YAAY;IACxB,yFAAyF;aACzF,KAAK,EAAE,QAAQ;CACP,CAAC;AAEX;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** The custom metadata keys every backup object carries. */
|
|
2
|
+
export const METADATA = {
|
|
3
|
+
/** `"1"`: written by this package. Retention only touches objects with it. */
|
|
4
|
+
marker: "cardon-backup",
|
|
5
|
+
/** The bookmark the export reported when the dump was downloaded (its point in time). */
|
|
6
|
+
bookmark: "bookmark",
|
|
7
|
+
/**
|
|
8
|
+
* The backup run that wrote the object (`copyExport`'s `run`): fixed before the first export
|
|
9
|
+
* starts and the same across retries and restarted exports, so reuse matches on it and never
|
|
10
|
+
* on a bookmark (a restarted export has another one).
|
|
11
|
+
*/
|
|
12
|
+
run: "run",
|
|
13
|
+
databaseId: "database-id",
|
|
14
|
+
/** ISO 8601, the moment the key stands for. */
|
|
15
|
+
createdAt: "created-at",
|
|
16
|
+
/**
|
|
17
|
+
* The object's size in bytes (the encrypted size for an encrypted backup), when it was known
|
|
18
|
+
* before the upload (absent for a multipart upload of unknown length).
|
|
19
|
+
*/
|
|
20
|
+
bytes: "bytes",
|
|
21
|
+
/** `"d1"` or `"sqlite3"` (see `d1Export`'s `format`). */
|
|
22
|
+
format: "format",
|
|
23
|
+
/**
|
|
24
|
+
* On the digest sidecar only: the identity of the exact dump object it was written for, as R2
|
|
25
|
+
* returned it from the dump's `put` or multipart `complete` (`version:<version>`, or
|
|
26
|
+
* `etag:<etag>` where R2 gives no version). Reuse compares it with the object at the key, so a
|
|
27
|
+
* sidecar never vouches for another write of the same key (an earlier export's late `put`).
|
|
28
|
+
*/
|
|
29
|
+
dumpObject: "dump-object",
|
|
30
|
+
/**
|
|
31
|
+
* On an encrypted backup and its sidecar: the scheme (`aes-256-gcm-stream-v1`). Absent on a
|
|
32
|
+
* plain one. Says how it was encrypted, never with what.
|
|
33
|
+
*/
|
|
34
|
+
encryption: "encryption",
|
|
35
|
+
/** On an encrypted backup and its sidecar: the id of the configured key (not secret). */
|
|
36
|
+
keyId: "key-id",
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The digest sidecar of a backup is `<key>.sha256`: the SHA-256 of the stored object (the
|
|
40
|
+
* ciphertext, for an encrypted backup) as 64 hex characters, written after the dump was stored
|
|
41
|
+
* and checked, with the same metadata marker, bookmark, run, database id and encryption scheme
|
|
42
|
+
* and key id, plus the dump object's identity (`dump-object`). Never counted as a backup;
|
|
43
|
+
* retention deletes it with its dump. It detects
|
|
44
|
+
* corruption, not tampering: whoever can rewrite the dump can rewrite its sidecar too.
|
|
45
|
+
*/
|
|
46
|
+
export const DIGEST_SUFFIX = ".sha256";
|
|
47
|
+
/** The key of the digest sidecar of the backup at `key`. */
|
|
48
|
+
export function digestKey(key) {
|
|
49
|
+
return `${key}${DIGEST_SUFFIX}`;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,8EAA8E;IAC9E,MAAM,EAAE,eAAe;IACvB,yFAAyF;IACzF,QAAQ,EAAE,UAAU;IACpB;;;;OAIG;IACH,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,aAAa;IACzB,+CAA+C;IAC/C,SAAS,EAAE,YAAY;IACvB;;;OAGG;IACH,KAAK,EAAE,OAAO;IACd,yDAAyD;IACzD,MAAM,EAAE,QAAQ;IAChB;;;;;OAKG;IACH,UAAU,EAAE,aAAa;IACzB;;;OAGG;IACH,UAAU,EAAE,YAAY;IACxB,yFAAyF;IACzF,KAAK,EAAE,QAAQ;CACP,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,4DAA4D;AAC5D,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,GAAG,GAAG,GAAG,aAAa,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type BackupDecryptionOptions, type BackupEncryption, type BackupEncryptionInfo } from "./encryption.js";
|
|
2
|
+
/**
|
|
3
|
+
* A dump's statements, ready for `db.batch`: split as Wrangler splits SQL files (comments
|
|
4
|
+
* dropped, strings and trigger bodies kept whole), without `BEGIN TRANSACTION` / `COMMIT`.
|
|
5
|
+
* Throws for a dump made with `format: "sqlite3"` (it writes `sqlite_schema` directly, which D1
|
|
6
|
+
* refuses).
|
|
7
|
+
*/
|
|
8
|
+
export declare function restoreStatements(sql: string): string[];
|
|
9
|
+
export interface RestoreCheckOptions {
|
|
10
|
+
/** The dump's size in bytes as recorded (the object's size or its `bytes` metadata). */
|
|
11
|
+
readonly bytes?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The dump's SHA-256 as recorded when it was copied (64 hex characters). Against tampering,
|
|
14
|
+
* take it from outside the bucket (the Workflow instance's output, a log line); the content of
|
|
15
|
+
* `<key>.sha256`, stored next to the dump, only detects corruption.
|
|
16
|
+
*/
|
|
17
|
+
readonly sha256?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The backup is encrypted: decrypt it with these keys (`backupEncryption(…)`, or `{ keys }`;
|
|
20
|
+
* `current` is not needed) before loading. `bytes` and `sha256` are still of the bytes given
|
|
21
|
+
* (the encrypted object, as recorded). Without it, an encrypted backup is refused
|
|
22
|
+
* (`BackupDecryptError`, reason `encrypted`); with it, a plain one is (`not_encrypted`).
|
|
23
|
+
* Present, it must hold keys: `null` or `undefined` is a `TypeError`, never "plain".
|
|
24
|
+
*/
|
|
25
|
+
readonly encryption?: BackupEncryption | BackupDecryptionOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Encrypted backups only: the R2 key the file was downloaded from. Its authenticated header
|
|
28
|
+
* must name it, or the check fails with `BackupDecryptError` `wrong_backup` (an authentic
|
|
29
|
+
* backup of another date or prefix under the same key). Pass it.
|
|
30
|
+
*/
|
|
31
|
+
readonly key?: string;
|
|
32
|
+
/** Encrypted backups only: the D1 database id the backup must be of (as `key`). */
|
|
33
|
+
readonly databaseId?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface RestoredTable {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** `INSERT` statements for the table in the dump (D1 writes one row per statement). */
|
|
38
|
+
readonly expectedRows: number;
|
|
39
|
+
/** Rows in the table after loading; `null` when the table is missing. */
|
|
40
|
+
readonly loadedRows: number | null;
|
|
41
|
+
}
|
|
42
|
+
export interface RestoreReport {
|
|
43
|
+
/** `true` when every table is there with its rows, and the size and digest given match. */
|
|
44
|
+
readonly ok: boolean;
|
|
45
|
+
/** The SHA-256 of the dump's bytes as given (a string as UTF-8), 64 hex characters. */
|
|
46
|
+
readonly sha256: string;
|
|
47
|
+
readonly statements: number;
|
|
48
|
+
readonly tables: readonly RestoredTable[];
|
|
49
|
+
/** What differs, one line each (table names and numbers only, never row data). */
|
|
50
|
+
readonly problems: readonly string[];
|
|
51
|
+
/** Scheme and key id of an encrypted backup (from its header); absent for a plain one. */
|
|
52
|
+
readonly encryption?: BackupEncryptionInfo;
|
|
53
|
+
/**
|
|
54
|
+
* An encrypted backup's authenticated header: the database id and object key it was written
|
|
55
|
+
* for, and which of them were checked against `databaseId` / `key` (absent for a plain one).
|
|
56
|
+
*/
|
|
57
|
+
readonly identity?: {
|
|
58
|
+
readonly databaseId: string;
|
|
59
|
+
readonly key: string;
|
|
60
|
+
readonly checked: {
|
|
61
|
+
readonly databaseId: boolean;
|
|
62
|
+
readonly key: boolean;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Loads `dump` (a dump from this package) into `db`, a **new, empty, local** D1 database (from
|
|
68
|
+
* `startBindings` in a test, say), then compares each table's rows with the dump's `INSERT`s,
|
|
69
|
+
* the dump's size with `bytes` and its SHA-256 with `sha256` when given.
|
|
70
|
+
*
|
|
71
|
+
* Pass the file's **bytes** (`await readFile(path)`, a `Uint8Array` or an `ArrayBuffer`): the
|
|
72
|
+
* size and digest are computed on them. A string is encoded as UTF-8 first, so it cannot prove
|
|
73
|
+
* byte equality when the dump holds invalid UTF-8 (a TEXT value can): reading the file as text
|
|
74
|
+
* replaces those bytes, and the digest then differs from the recorded one.
|
|
75
|
+
*
|
|
76
|
+
* What it proves: the dump loads, every table it creates has the rows it inserts, and (with
|
|
77
|
+
* `bytes` and `sha256`) the file is the one that was copied. What it does not: that Cloudflare's
|
|
78
|
+
* dump was complete. A dump cut at a statement boundary loads cleanly and its counts agree with
|
|
79
|
+
* themselves; only a digest recorded at copy time shows it changed since, and nothing here can
|
|
80
|
+
* show it was short when Cloudflare produced it.
|
|
81
|
+
*
|
|
82
|
+
* An encrypted backup: pass its bytes and `encryption` (the keys). It is decrypted first, failing
|
|
83
|
+
* closed with a `BackupDecryptError` (a fixed message and a `reason`: `authentication_failed`,
|
|
84
|
+
* `unknown_key`, `truncated`, `not_encrypted`…) before the database is touched; `bytes` and
|
|
85
|
+
* `sha256` are compared with the encrypted bytes given, which is what the copy recorded. Without
|
|
86
|
+
* `encryption`, an encrypted backup is refused (`reason: "encrypted"`). The decrypted dump is
|
|
87
|
+
* held in memory, as a plain one is. Pass `key` (the R2 key you downloaded) and `databaseId`:
|
|
88
|
+
* the authenticated header must name them (`wrong_backup` otherwise), and `report.identity`
|
|
89
|
+
* says what the header names and which of the two were checked.
|
|
90
|
+
*
|
|
91
|
+
* Throws when `db` already has tables (an empty production database would pass this guard: use
|
|
92
|
+
* a local one only), or when the dump does not load. That error names the statements and SQLite's
|
|
93
|
+
* result code only, and has no `cause`: the database's own error may quote SQL from the dump (row
|
|
94
|
+
* data).
|
|
95
|
+
*/
|
|
96
|
+
export declare function checkRestore(db: D1Database, dump: string | Uint8Array | ArrayBuffer, options?: RestoreCheckOptions): Promise<RestoreReport>;
|
|
97
|
+
//# sourceMappingURL=restore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../src/restore.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAK1B,MAAM,iBAAiB,CAAC;AA8CzB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CASvD;AAED,MAAM,WAAW,mBAAmB;IAClC,wFAAwF;IACxF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE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