@sharadox/database-web-library 0.0.0-stage → 0.1.0-database-backup.13

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.
Files changed (105) hide show
  1. package/LICENCA.md +76 -0
  2. package/LICENSE.md +76 -0
  3. package/NOTICE.md +3 -0
  4. package/README.md +151 -2
  5. package/distribution/backup-command/index.d.ts +21 -0
  6. package/distribution/backup-command/index.d.ts.map +1 -0
  7. package/distribution/backup-command/index.js +87 -0
  8. package/distribution/backup-command/index.js.map +1 -0
  9. package/distribution/backup-command/type.d.ts +17 -0
  10. package/distribution/backup-command/type.d.ts.map +1 -0
  11. package/distribution/backup-command/type.js +2 -0
  12. package/distribution/backup-command/type.js.map +1 -0
  13. package/distribution/backup-dump/index.d.ts +20 -0
  14. package/distribution/backup-dump/index.d.ts.map +1 -0
  15. package/distribution/backup-dump/index.js +44 -0
  16. package/distribution/backup-dump/index.js.map +1 -0
  17. package/distribution/backup-dump/type.d.ts +9 -0
  18. package/distribution/backup-dump/type.d.ts.map +1 -0
  19. package/distribution/backup-dump/type.js +2 -0
  20. package/distribution/backup-dump/type.js.map +1 -0
  21. package/distribution/backup-encryption/index.d.ts +17 -0
  22. package/distribution/backup-encryption/index.d.ts.map +1 -0
  23. package/distribution/backup-encryption/index.js +38 -0
  24. package/distribution/backup-encryption/index.js.map +1 -0
  25. package/distribution/backup-storage/index.d.ts +11 -0
  26. package/distribution/backup-storage/index.d.ts.map +1 -0
  27. package/distribution/backup-storage/index.js +27 -0
  28. package/distribution/backup-storage/index.js.map +1 -0
  29. package/distribution/backup-storage/type.d.ts +16 -0
  30. package/distribution/backup-storage/type.d.ts.map +1 -0
  31. package/distribution/backup-storage/type.js +2 -0
  32. package/distribution/backup-storage/type.js.map +1 -0
  33. package/distribution/database/index.d.ts +15 -0
  34. package/distribution/database/index.d.ts.map +1 -0
  35. package/distribution/database/index.js +17 -0
  36. package/distribution/database/index.js.map +1 -0
  37. package/distribution/database-backup/index.d.ts +20 -0
  38. package/distribution/database-backup/index.d.ts.map +1 -0
  39. package/distribution/database-backup/index.js +49 -0
  40. package/distribution/database-backup/index.js.map +1 -0
  41. package/distribution/database-backup/type.d.ts +28 -0
  42. package/distribution/database-backup/type.d.ts.map +1 -0
  43. package/distribution/database-backup/type.js +2 -0
  44. package/distribution/database-backup/type.js.map +1 -0
  45. package/distribution/database-configuration/index.d.ts +10 -0
  46. package/distribution/database-configuration/index.d.ts.map +1 -0
  47. package/distribution/database-configuration/index.js +20 -0
  48. package/distribution/database-configuration/index.js.map +1 -0
  49. package/distribution/database-configuration/type.d.ts +6 -0
  50. package/distribution/database-configuration/type.d.ts.map +1 -0
  51. package/distribution/database-configuration/type.js +2 -0
  52. package/distribution/database-configuration/type.js.map +1 -0
  53. package/distribution/es-lint-plugin/index.d.ts +29 -0
  54. package/distribution/es-lint-plugin/index.d.ts.map +1 -0
  55. package/distribution/es-lint-plugin/index.js +56 -0
  56. package/distribution/es-lint-plugin/index.js.map +1 -0
  57. package/distribution/git-hub-web-identity/index.d.ts +9 -0
  58. package/distribution/git-hub-web-identity/index.d.ts.map +1 -0
  59. package/distribution/git-hub-web-identity/index.js +18 -0
  60. package/distribution/git-hub-web-identity/index.js.map +1 -0
  61. package/distribution/memory-backup-storage/index.d.ts +12 -0
  62. package/distribution/memory-backup-storage/index.d.ts.map +1 -0
  63. package/distribution/memory-backup-storage/index.js +22 -0
  64. package/distribution/memory-backup-storage/index.js.map +1 -0
  65. package/distribution/memory-database/index.d.ts +14 -0
  66. package/distribution/memory-database/index.d.ts.map +1 -0
  67. package/distribution/memory-database/index.js +20 -0
  68. package/distribution/memory-database/index.js.map +1 -0
  69. package/distribution/memory-database/type.d.ts +9 -0
  70. package/distribution/memory-database/type.d.ts.map +1 -0
  71. package/distribution/memory-database/type.js +2 -0
  72. package/distribution/memory-database/type.js.map +1 -0
  73. package/distribution/migration/index.d.ts +13 -0
  74. package/distribution/migration/index.d.ts.map +1 -0
  75. package/distribution/migration/index.js +64 -0
  76. package/distribution/migration/index.js.map +1 -0
  77. package/distribution/migration/type.d.ts +11 -0
  78. package/distribution/migration/type.d.ts.map +1 -0
  79. package/distribution/migration/type.js +2 -0
  80. package/distribution/migration/type.js.map +1 -0
  81. package/distribution/migration-error/index.d.ts +18 -0
  82. package/distribution/migration-error/index.d.ts.map +1 -0
  83. package/distribution/migration-error/index.js +20 -0
  84. package/distribution/migration-error/index.js.map +1 -0
  85. package/distribution/migration-error/type.d.ts +7 -0
  86. package/distribution/migration-error/type.d.ts.map +1 -0
  87. package/distribution/migration-error/type.js +2 -0
  88. package/distribution/migration-error/type.js.map +1 -0
  89. package/distribution/migration-file/index.d.ts +11 -0
  90. package/distribution/migration-file/index.d.ts.map +1 -0
  91. package/distribution/migration-file/index.js +32 -0
  92. package/distribution/migration-file/index.js.map +1 -0
  93. package/distribution/pglite-pool/index.d.ts +15 -0
  94. package/distribution/pglite-pool/index.d.ts.map +1 -0
  95. package/distribution/pglite-pool/index.js +44 -0
  96. package/distribution/pglite-pool/index.js.map +1 -0
  97. package/distribution/restore-drill/index.d.ts +12 -0
  98. package/distribution/restore-drill/index.d.ts.map +1 -0
  99. package/distribution/restore-drill/index.js +35 -0
  100. package/distribution/restore-drill/index.js.map +1 -0
  101. package/distribution/restore-drill/type.d.ts +20 -0
  102. package/distribution/restore-drill/type.d.ts.map +1 -0
  103. package/distribution/restore-drill/type.js +2 -0
  104. package/distribution/restore-drill/type.js.map +1 -0
  105. package/package.json +103 -3
@@ -0,0 +1,64 @@
1
+ import { createHash } from "node:crypto";
2
+ import { sql } from "kysely";
3
+ import { MigrationError } from "@sharadox/database-web-library/migration-error";
4
+ /** A table name `migrate` accepts: plain lowercase, so it never needs quoting. */
5
+ const IDENTIFIER = /^[a-z_][a-z0-9_]{0,62}$/;
6
+ /** Record tables made before every row had an id get one: a UUIDv7 primary key, with names kept unique. */
7
+ async function addRecordIds(transaction, table) {
8
+ const { rows } = await sql `select 1 from information_schema.columns
9
+ where table_schema = current_schema() and table_name = ${table} and column_name = ${"id"}`.execute(transaction);
10
+ if (rows.length > 0)
11
+ return;
12
+ const records = sql.table(table);
13
+ await sql `alter table ${records} drop constraint ${sql.id(`${table}_pkey`)}`.execute(transaction);
14
+ await sql `alter table ${records} add constraint ${sql.id(`${table}_name_key`)} unique (name)`.execute(transaction);
15
+ await sql `alter table ${records}
16
+ add column id uuid primary key default uuidv7() check (uuid_extract_version(id) = 7)`.execute(transaction);
17
+ }
18
+ const checksum = (text) => createHash("sha256").update(text).digest("hex");
19
+ /**
20
+ * Brings a database up to date: applies, in order, the migrations it hasn't applied yet, all in one transaction (all
21
+ * or none) behind a lock (two deployments never migrate at once), and records each with a checksum of its SQL.
22
+ * Forward only: it refuses (`MigrationError`) when an applied migration was edited or removed, or a new one is
23
+ * numbered before one already applied. Returns the names it applied.
24
+ *
25
+ * @example
26
+ * const applied = await migrate(database, await readMigrations(new URL("../../migration/", import.meta.url)));
27
+ */
28
+ export async function migrate(database, migrations, { table = "schema_migration" } = {}) {
29
+ if (!IDENTIFIER.test(table))
30
+ throw new MigrationError("invalid-name", `"${table}" is not a plain table name`);
31
+ const records = sql.table(table);
32
+ return database.transaction().execute(async (transaction) => {
33
+ await sql `select pg_advisory_xact_lock(hashtext(${table}))`.execute(transaction);
34
+ await sql `create table if not exists ${records} (
35
+ id uuid primary key default uuidv7() check (uuid_extract_version(id) = 7),
36
+ name text not null unique,
37
+ checksum text not null,
38
+ applied_at timestamptz not null default now()
39
+ )`.execute(transaction);
40
+ await addRecordIds(transaction, table);
41
+ const applied = (await sql `select name, checksum from ${records} order by name`.execute(transaction)).rows;
42
+ const known = new Map(migrations.map((migration) => [migration.name, migration]));
43
+ for (const record of applied) {
44
+ const migration = known.get(record.name);
45
+ if (!migration)
46
+ throw new MigrationError("missing", `${record.name} was applied but is no longer there`);
47
+ if (checksum(migration.sql) !== record.checksum)
48
+ throw new MigrationError("changed", `${record.name} was changed after it was applied`);
49
+ }
50
+ const done = new Set(applied.map(({ name }) => name));
51
+ const last = applied.at(-1)?.name ?? "";
52
+ const pending = migrations.filter(({ name }) => !done.has(name));
53
+ for (const migration of pending) {
54
+ if (migration.name < last)
55
+ throw new MigrationError("out-of-order", `${migration.name} is numbered before ${last}, already applied`);
56
+ // A migration file is SQL we wrote and reviewed, run as it is: the one place raw SQL is allowed.
57
+ // eslint-disable-next-line @sharadox/database/no-raw-sql
58
+ await sql.raw(migration.sql).execute(transaction);
59
+ await sql `insert into ${records} (name, checksum) values (${migration.name}, ${checksum(migration.sql)})`.execute(transaction);
60
+ }
61
+ return pending.map(({ name }) => name);
62
+ });
63
+ }
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAe,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAGhF,kFAAkF;AAClF,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAE7C,2GAA2G;AAC3G,KAAK,UAAU,YAAY,CAAS,WAA2B,EAAE,KAAa;IAC5E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,GAAG,CAAA;6DACiC,KAAK,sBAAsB,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAClH,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO;IAC5B,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,CAAA,eAAe,OAAO,oBAAoB,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAClG,MAAM,GAAG,CAAA,eAAe,OAAO,mBAAmB,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,WA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ACJ,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** One forward-only change to the database: its name (`0001-account`) and its SQL, one or more statements. */
2
+ export interface Migration {
3
+ name: string;
4
+ sql: string;
5
+ }
6
+ /** Where `migrate` keeps its records. */
7
+ export interface MigrateOptions {
8
+ /** The table that remembers applied migrations (a plain lowercase identifier); `schema_migration` by default. */
9
+ table?: string;
10
+ }
11
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/migration/type.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,iHAAiH;IACjH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/migration/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import type { MigrationErrorCode } from "@sharadox/database-web-library/migration-error/type";
2
+ /**
3
+ * The one error migrations throw when they refuse to run, with a `code` to branch on.
4
+ *
5
+ * @example
6
+ * try {
7
+ * await migrate(database, migrations);
8
+ * } catch (error) {
9
+ * if (error instanceof MigrationError && error.code === "changed") console.error(error.message);
10
+ * }
11
+ */
12
+ export declare class MigrationError extends Error {
13
+ readonly name = "MigrationError";
14
+ /** What went wrong. */
15
+ readonly code: MigrationErrorCode;
16
+ constructor(code: MigrationErrorCode, message: string);
17
+ }
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/migration-error/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAE9F;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAkB,IAAI,oBAAoB;IAC1C,uBAAuB;IACvB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;gBAEtB,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM;CAItD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The one error migrations throw when they refuse to run, with a `code` to branch on.
3
+ *
4
+ * @example
5
+ * try {
6
+ * await migrate(database, migrations);
7
+ * } catch (error) {
8
+ * if (error instanceof MigrationError && error.code === "changed") console.error(error.message);
9
+ * }
10
+ */
11
+ export class MigrationError extends Error {
12
+ name = "MigrationError";
13
+ /** What went wrong. */
14
+ code;
15
+ constructor(code, message) {
16
+ super(message);
17
+ this.code = code;
18
+ }
19
+ }
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/migration-error/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACrB,IAAI,GAAG,gBAAgB,CAAC;IAC1C,uBAAuB;IACd,IAAI,CAAqB;IAElC,YAAY,IAAwB,EAAE,OAAe;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Why migrations were refused: a file name that isn't `<four digits>-<kebab-case>.sql` (`invalid-name`), two
3
+ * files with one number (`duplicate`), an applied migration edited (`changed`) or removed (`missing`), or a new one
4
+ * numbered before one already applied (`out-of-order`).
5
+ */
6
+ export type MigrationErrorCode = "invalid-name" | "duplicate" | "changed" | "missing" | "out-of-order";
7
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/migration-error/type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/migration-error/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { Migration } from "@sharadox/database-web-library/migration/type";
2
+ /**
3
+ * Reads a folder's migrations: every `.sql` file, named `<four digits>-<kebab-case>.sql`, in number order (other
4
+ * files are ignored). Throws `MigrationError` for a badly named `.sql` file or two files with one number.
5
+ *
6
+ * @example
7
+ * const migrations = await readMigrations(new URL("../../migration/", import.meta.url));
8
+ * // [{ name: "0001-account", sql: "create table account (…);" }, …]
9
+ */
10
+ export declare function readMigrations(folder: URL | string): Promise<Migration[]>;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/migration-file/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAK/E;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAc/E"}
@@ -0,0 +1,32 @@
1
+ import { readdir, readFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { MigrationError } from "@sharadox/database-web-library/migration-error";
5
+ /** `0001-account.sql`: four digits, a kebab-case name. */
6
+ const FILE_NAME = /^(\d{4})-[a-z0-9]+(?:-[a-z0-9]+)*\.sql$/;
7
+ /**
8
+ * Reads a folder's migrations: every `.sql` file, named `<four digits>-<kebab-case>.sql`, in number order (other
9
+ * files are ignored). Throws `MigrationError` for a badly named `.sql` file or two files with one number.
10
+ *
11
+ * @example
12
+ * const migrations = await readMigrations(new URL("../../migration/", import.meta.url));
13
+ * // [{ name: "0001-account", sql: "create table account (…);" }, …]
14
+ */
15
+ export async function readMigrations(folder) {
16
+ const directory = typeof folder === "string" ? folder : fileURLToPath(folder);
17
+ const files = (await readdir(directory)).filter((file) => file.endsWith(".sql")).sort();
18
+ const numbers = new Set();
19
+ const migrations = [];
20
+ for (const file of files) {
21
+ const match = FILE_NAME.exec(file);
22
+ if (!match)
23
+ throw new MigrationError("invalid-name", `${file} must be named <four digits>-<kebab-case>.sql`);
24
+ const number = match[1];
25
+ if (numbers.has(number))
26
+ throw new MigrationError("duplicate", `two migrations are numbered ${number}`);
27
+ numbers.add(number);
28
+ migrations.push({ name: file.slice(0, -".sql".length), sql: await readFile(join(directory, file), "utf8") });
29
+ }
30
+ return migrations;
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/migration-file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAGhF,0DAA0D;AAC1D,MAAM,SAAS,GAAG,yCAAyC,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAoB;IACvD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9E,MAAM,KAAK,GAAG,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,cAAc,CAAC,cAAc,EAAE,GAAG,IAAI,+CAA+C,CAAC,CAAC;QAC7G,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACzB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,MAAM,IAAI,cAAc,CAAC,WAAW,EAAE,+BAA+B,MAAM,EAAE,CAAC,CAAC;QACxG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/G,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { PGlite } from "@electric-sql/pglite";
2
+ import type { PostgresPool } from "kysely";
3
+ /**
4
+ * A Kysely `PostgresPool` over one PGlite database (Postgres compiled to WebAssembly, in the same process), for tests
5
+ * and local work without a server. PGlite has a single connection, so connections are handed out one at a time, in
6
+ * the order asked. A query without parameters may hold several statements, as with node-postgres (Postgres's simple
7
+ * protocol); the result is the last statement's.
8
+ *
9
+ * @example
10
+ * import { PGlite } from "@electric-sql/pglite";
11
+ * import { Kysely, PostgresDialect } from "kysely";
12
+ * const database = new Kysely<Schema>({ dialect: new PostgresDialect({ pool: pglitePool(new PGlite()) }) });
13
+ */
14
+ export declare function pglitePool(pglite: PGlite): PostgresPool;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/pglite-pool/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAA2C,MAAM,QAAQ,CAAC;AAapF;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAuBvD"}
@@ -0,0 +1,44 @@
1
+ /** The shape node-postgres gives a result, from PGlite's own. */
2
+ function asPostgresResult(result) {
3
+ return {
4
+ command: (result.command ?? "SELECT"),
5
+ rowCount: result.rowCount ?? result.rows.length,
6
+ rows: result.rows,
7
+ };
8
+ }
9
+ /**
10
+ * A Kysely `PostgresPool` over one PGlite database (Postgres compiled to WebAssembly, in the same process), for tests
11
+ * and local work without a server. PGlite has a single connection, so connections are handed out one at a time, in
12
+ * the order asked. A query without parameters may hold several statements, as with node-postgres (Postgres's simple
13
+ * protocol); the result is the last statement's.
14
+ *
15
+ * @example
16
+ * import { PGlite } from "@electric-sql/pglite";
17
+ * import { Kysely, PostgresDialect } from "kysely";
18
+ * const database = new Kysely<Schema>({ dialect: new PostgresDialect({ pool: pglitePool(new PGlite()) }) });
19
+ */
20
+ export function pglitePool(pglite) {
21
+ let queue = Promise.resolve();
22
+ const client = (release) => ({
23
+ async query(sql, parameters) {
24
+ if (typeof sql !== "string")
25
+ throw new Error("pglitePool: streaming is not supported");
26
+ if (parameters && parameters.length > 0)
27
+ return asPostgresResult(await pglite.query(sql, [...parameters]));
28
+ const results = await pglite.exec(sql);
29
+ return asPostgresResult(results.at(-1));
30
+ },
31
+ release,
32
+ });
33
+ return {
34
+ connect() {
35
+ let release;
36
+ const released = new Promise((resolve) => (release = resolve));
37
+ const turn = queue.then(() => client(release));
38
+ queue = queue.then(() => released);
39
+ return turn;
40
+ },
41
+ end: () => pglite.close(),
42
+ };
43
+ }
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/pglite-pool/index.ts"],"names":[],"mappings":"AAKA,iEAAiE;AACjE,SAAS,gBAAgB,CAAI,MAA4D;IACvF,OAAO;QACL,OAAO,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,QAAQ,CAAY;QAChD,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM;QAC/C,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,IAAI,KAAK,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7C,MAAM,MAAM,GAAG,CAAC,OAAmB,EAAsB,EAAE,CACzD,CAAC;QACC,KAAK,CAAC,KAAK,CAAI,GAAY,EAAE,UAAmC;YAC9D,IAAI,OAAO,GAAG,KAAK,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACvF,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;gBACrC,OAAO,gBAAgB,CAAI,MAAM,MAAM,CAAC,KAAK,CAAI,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC1E,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,OAAO,gBAAgB,CAAI,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAe,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO;KACR,CAAuB,CAAC;IAC3B,OAAO;QACL,OAAO;YACL,IAAI,OAAoB,CAAC;YACzB,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;YACrE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YAC/C,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { RestoreDrillOptions, RestoreDrillResult } from "@sharadox/database-web-library/restore-drill/type";
2
+ /**
3
+ * Proves the newest backup can be restored: checks its SHA-256, decrypts and unpacks it, replays it into an empty
4
+ * Postgres, and compares every table's rows with its manifest. Run it monthly; a backup never restored is a hope.
5
+ *
6
+ * @example
7
+ * const memory = await createMemoryDatabase();
8
+ * const result = await restoreDrill({ storage, key, into: memory.database });
9
+ * if (!result.ok) process.exitCode = 1;
10
+ */
11
+ export declare function restoreDrill({ storage, key, into }: RestoreDrillOptions): Promise<RestoreDrillResult>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/restore-drill/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEjH;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAiB3G"}
@@ -0,0 +1,35 @@
1
+ import { createHash } from "node:crypto";
2
+ import { gunzipSync } from "node:zlib";
3
+ import { sql } from "kysely";
4
+ import { decryptBackup } from "@sharadox/database-web-library/backup-encryption";
5
+ import { restorableSql } from "@sharadox/database-web-library/backup-dump";
6
+ import { tableCounts } from "@sharadox/database-web-library/database-backup";
7
+ /**
8
+ * Proves the newest backup can be restored: checks its SHA-256, decrypts and unpacks it, replays it into an empty
9
+ * Postgres, and compares every table's rows with its manifest. Run it monthly; a backup never restored is a hope.
10
+ *
11
+ * @example
12
+ * const memory = await createMemoryDatabase();
13
+ * const result = await restoreDrill({ storage, key, into: memory.database });
14
+ * if (!result.ok) process.exitCode = 1;
15
+ */
16
+ export async function restoreDrill({ storage, key, into }) {
17
+ const manifests = (await storage.list("")).filter((name) => name.endsWith(".json"));
18
+ const newest = manifests.at(-1);
19
+ if (!newest)
20
+ throw new Error("there is no backup to restore");
21
+ const manifest = JSON.parse(new TextDecoder().decode(await storage.get(newest)));
22
+ const sealed = await storage.get(manifest.file);
23
+ if (createHash("sha256").update(sealed).digest("hex") !== manifest.sha256)
24
+ throw new Error(`${manifest.file} doesn't match its checksum`);
25
+ const dump = new TextDecoder().decode(gunzipSync(decryptBackup(sealed, key)));
26
+ // A dump pg_dump made from our own database: replayed as it is, into a database used for nothing else.
27
+ // eslint-disable-next-line @sharadox/database/no-raw-sql
28
+ await sql.raw(restorableSql(dump)).execute(into);
29
+ const restored = await tableCounts(into);
30
+ const tables = Object.entries(manifest.tables)
31
+ .sort(([first], [second]) => first.localeCompare(second))
32
+ .map(([table, expected]) => ({ table, expected, restored: restored[table] ?? 0 }));
33
+ return { ok: tables.every(({ expected, restored }) => expected === restored), createdAt: manifest.createdAt, tables };
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/restore-drill/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,E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GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;SAC3C,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SACxD,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACrF,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,QAAQ,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;AACxH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { BackupStorage } from "@sharadox/database-web-library/backup-storage/type";
3
+ export interface RestoreDrillOptions {
4
+ storage: BackupStorage;
5
+ /** `BACKUP_ENCRYPTION_KEY`. */
6
+ key: string;
7
+ /** An empty database to restore into (`createMemoryDatabase()`: Postgres 18 in memory). */
8
+ into: Kysely<unknown>;
9
+ }
10
+ /** Whether the newest backup came back whole: every table with the rows its manifest promised. */
11
+ export interface RestoreDrillResult {
12
+ ok: boolean;
13
+ createdAt: string;
14
+ tables: {
15
+ table: string;
16
+ expected: number;
17
+ restored: number;
18
+ }[];
19
+ }
20
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/restore-drill/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AAExF,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,CAAC;IACvB,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;CACvB;AAED,kGAAkG;AAClG,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/restore-drill/type.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,106 @@
1
1
  {
2
2
  "name": "@sharadox/database-web-library",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-database-backup.13",
4
+ "description": "Typed, injection-safe Postgres for web applications: queries, migrations, backups and restore drills.",
5
+ "private": false,
6
+ "license": "SEE LICENSE IN LICENCA.md",
7
+ "author": "Sharadox <contact@sharadox.com>",
8
+ "type": "module",
9
+ "exports": {
10
+ "./*/type": {
11
+ "sharadox-source": "./source/*/type.ts",
12
+ "types": "./distribution/*/type.d.ts"
13
+ },
14
+ "./*": {
15
+ "sharadox-source": [
16
+ "./source/*/index.ts"
17
+ ],
18
+ "types": "./distribution/*/index.d.ts",
19
+ "default": "./distribution/*/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "distribution",
24
+ "LICENCA.md",
25
+ "LICENSE.md",
26
+ "NOTICE.md"
27
+ ],
28
+ "sideEffects": false,
29
+ "engines": {
30
+ "node": ">=26"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "lint-staged": {
36
+ "*.{ts,js,mjs,cjs}": [
37
+ "prettier --write",
38
+ "eslint --fix --max-warnings=0"
39
+ ],
40
+ "*.{json,md,yml,yaml}": "prettier --write"
41
+ },
42
+ "dependencies": {
43
+ "@aws-sdk/client-s3": "^3.1177.0",
44
+ "@aws-sdk/credential-providers": "^3.1177.0",
45
+ "@neondatabase/serverless": "^1.2.0",
46
+ "@sharadox/web-library": "^0.11.1",
47
+ "kysely": "^0.28.19",
48
+ "zod": "^4.6.7"
49
+ },
50
+ "devDependencies": {
51
+ "@electric-sql/pglite": "0.5.16",
52
+ "@sharadox/es-lint-configuration-web-library": "^0.1.3",
53
+ "@sharadox/library-build-web-library": "^0.2.1",
54
+ "@sharadox/prettier-configuration-web-library": "^0.1.2",
55
+ "@sharadox/turborepo-configuration-web-library": "^0.1.4",
56
+ "@sharadox/type-script-configuration-web-library": "^0.2.3",
57
+ "@sharadox/vitest-configuration-web-library": "^0.2.1",
58
+ "@types/node": "^26.6.6",
59
+ "@vitest/coverage-v8": "^5.1.1",
60
+ "eslint": "9.39.5",
61
+ "happy-dom": "^21.0.4",
62
+ "husky": "^9.1.7",
63
+ "lint-staged": "^17.6.2",
64
+ "prettier": "^3.10.1",
65
+ "turbo": "^2.11.13",
66
+ "typedoc": "^0.28.20",
67
+ "typescript": "6.0.3",
68
+ "vitest": "^5.1.1"
69
+ },
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "git+https://github.com/Sharadox/database-web-library.git"
73
+ },
74
+ "homepage": "https://github.com/Sharadox/database-web-library#readme",
75
+ "keywords": [
76
+ "postgres",
77
+ "kysely",
78
+ "neon",
79
+ "migrations",
80
+ "backup",
81
+ "type-safe"
82
+ ],
83
+ "peerDependencies": {
84
+ "@electric-sql/pglite": "^0.5.16",
85
+ "eslint": ">=9"
86
+ },
87
+ "peerDependenciesMeta": {
88
+ "@electric-sql/pglite": {
89
+ "optional": true
90
+ },
91
+ "eslint": {
92
+ "optional": true
93
+ }
94
+ },
95
+ "scripts": {
96
+ "build": "library-build",
97
+ "lint": "eslint --max-warnings=0 .",
98
+ "format": "prettier --write .",
99
+ "format:check": "prettier --check .",
100
+ "type-check": "tsc --noEmit",
101
+ "test:unit": "vitest run --coverage",
102
+ "test:benchmark": "vitest bench --run --passWithNoTests",
103
+ "documentation": "typedoc",
104
+ "verify": "turbo run format:check lint type-check test:unit test:benchmark build"
105
+ }
6
106
  }