@xemahq/biome-database-nest 1.1.0 → 3.0.0

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 (65) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +29 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/adapter.d.ts.map +1 -1
  6. package/dist/lib/adapter.js +5 -5
  7. package/dist/lib/adapter.js.map +1 -1
  8. package/dist/lib/advisory-lock.d.ts +10 -0
  9. package/dist/lib/advisory-lock.d.ts.map +1 -0
  10. package/dist/lib/advisory-lock.js +32 -0
  11. package/dist/lib/advisory-lock.js.map +1 -0
  12. package/dist/lib/bootstrap.d.ts.map +1 -1
  13. package/dist/lib/bootstrap.js +6 -6
  14. package/dist/lib/bootstrap.js.map +1 -1
  15. package/dist/lib/control-plane-discovery.d.ts +2 -2
  16. package/dist/lib/control-plane-discovery.d.ts.map +1 -1
  17. package/dist/lib/control-plane-discovery.js +12 -3
  18. package/dist/lib/control-plane-discovery.js.map +1 -1
  19. package/dist/lib/credential-client.js +2 -2
  20. package/dist/lib/credential-client.js.map +1 -1
  21. package/dist/lib/database-url.d.ts +5 -0
  22. package/dist/lib/database-url.d.ts.map +1 -0
  23. package/dist/lib/database-url.js +54 -0
  24. package/dist/lib/database-url.js.map +1 -0
  25. package/dist/lib/idempotency-record-schema.d.ts +9 -0
  26. package/dist/lib/idempotency-record-schema.d.ts.map +1 -0
  27. package/dist/lib/idempotency-record-schema.js +183 -0
  28. package/dist/lib/idempotency-record-schema.js.map +1 -0
  29. package/dist/lib/nest/data-store-idempotency.service.d.ts +14 -0
  30. package/dist/lib/nest/data-store-idempotency.service.d.ts.map +1 -0
  31. package/dist/lib/nest/data-store-idempotency.service.js +114 -0
  32. package/dist/lib/nest/data-store-idempotency.service.js.map +1 -0
  33. package/dist/lib/operator-migration.d.ts.map +1 -1
  34. package/dist/lib/operator-migration.js +2 -2
  35. package/dist/lib/operator-migration.js.map +1 -1
  36. package/dist/lib/release-intent-schema.d.ts +6 -0
  37. package/dist/lib/release-intent-schema.d.ts.map +1 -0
  38. package/dist/lib/release-intent-schema.js +131 -0
  39. package/dist/lib/release-intent-schema.js.map +1 -0
  40. package/dist/lib/schema-source-reader.d.ts +7 -0
  41. package/dist/lib/schema-source-reader.d.ts.map +1 -0
  42. package/dist/lib/schema-source-reader.js +56 -0
  43. package/dist/lib/schema-source-reader.js.map +1 -0
  44. package/dist/lib/session-timezone.js +3 -3
  45. package/dist/lib/session-timezone.js.map +1 -1
  46. package/dist/testing/index.d.ts +2 -11
  47. package/dist/testing/index.d.ts.map +1 -1
  48. package/dist/testing/index.js +5 -33
  49. package/dist/testing/index.js.map +1 -1
  50. package/dist/testing/prefix-migration.d.ts +3 -0
  51. package/dist/testing/prefix-migration.d.ts.map +1 -0
  52. package/dist/testing/prefix-migration.js +9 -0
  53. package/dist/testing/prefix-migration.js.map +1 -0
  54. package/dist/testing/provision.d.ts +7 -0
  55. package/dist/testing/provision.d.ts.map +1 -0
  56. package/dist/testing/provision.js +13 -0
  57. package/dist/testing/provision.js.map +1 -0
  58. package/dist/testing/test-migrator.d.ts +12 -0
  59. package/dist/testing/test-migrator.d.ts.map +1 -0
  60. package/dist/testing/test-migrator.js +36 -0
  61. package/dist/testing/test-migrator.js.map +1 -0
  62. package/package.json +37 -15
  63. package/prisma-url.d.ts +38 -0
  64. package/prisma-url.js +84 -0
  65. package/xema-peer-facts.json +255 -0
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DatabaseSessionTimeZoneError = exports.DatabaseSessionPath = void 0;
4
4
  exports.assertDatabaseSessionUtc = assertDatabaseSessionUtc;
5
5
  exports.connectVerified = connectVerified;
6
- const platform_common_1 = require("@xemahq/platform-common");
6
+ const database_url_1 = require("./database-url");
7
7
  var DatabaseSessionPath;
8
8
  (function (DatabaseSessionPath) {
9
9
  DatabaseSessionPath["AppPool"] = "app-pool";
@@ -12,7 +12,7 @@ var DatabaseSessionPath;
12
12
  })(DatabaseSessionPath || (exports.DatabaseSessionPath = DatabaseSessionPath = {}));
13
13
  const SHOW_TIME_ZONE_SQL = 'SHOW TimeZone';
14
14
  const ACCEPTED_ZONES = [
15
- platform_common_1.BIOME_DB_SESSION_TIMEZONE.toLowerCase(),
15
+ database_url_1.BIOME_DB_SESSION_TIMEZONE.toLowerCase(),
16
16
  'etc/utc',
17
17
  ];
18
18
  class DatabaseSessionTimeZoneError extends Error {
@@ -58,7 +58,7 @@ async function assertDatabaseSessionUtc(probe, path) {
58
58
  const observed = await showTimeZone(probe);
59
59
  const text = typeof observed === 'string' ? observed : String(observed);
60
60
  if (!ACCEPTED_ZONES.includes(text.toLowerCase())) {
61
- throw new DatabaseSessionTimeZoneError(platform_common_1.BIOME_DB_SESSION_TIMEZONE, text, path);
61
+ throw new DatabaseSessionTimeZoneError(database_url_1.BIOME_DB_SESSION_TIMEZONE, text, path);
62
62
  }
63
63
  }
64
64
  async function connectVerified(client, path) {
@@ -1 +1 @@
1
- {"version":3,"file":"session-timezone.js","sourceRoot":"","sources":["../../src/lib/session-timezone.ts"],"names":[],"mappings":";;;AAyGA,4DAaC;AAYD,0CAWC;AA7ID,6DAAoE;AAMpE,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAE7B,2CAAoB,CAAA;IAEpB,8CAAuB,CAAA;IAEvB,+DAAwC,CAAA;AAC1C,CAAC,EAPW,mBAAmB,mCAAnB,mBAAmB,QAO9B;AAED,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAE3C,MAAM,cAAc,GAAsB;IACxC,2CAAyB,CAAC,WAAW,EAAE;IACvC,SAAS;CACV,CAAC;AASF,MAAa,4BAA6B,SAAQ,KAAK;IAE1C;IACA;IACA;IAHX,YACW,QAAgB,EAChB,QAAgB,EAChB,cAAmC;QAE5C,KAAK,CACH,6BAA6B,cAAc,oBAAoB,QAAQ,IAAI;YACzE,iBAAiB,QAAQ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AC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,4BAA4B,CACpC,wCAAyB,EACzB,IAAI,EACJ,IAAI,CACL,CAAC;IACJ,CAAC;AACH,CAAC;AAYM,KAAK,UAAU,eAAe,CACnC,MAAgC,EAChC,IAAyB;IAEzB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;QACnB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,12 +1,3 @@
1
- import type { SdkOwnedMigrationSet } from '../lib/sdk-owned-migration-set';
2
- export interface TestMigrationTarget {
3
- readonly serviceName: string;
4
- readonly rootDir: string;
5
- readonly url: string;
6
- readonly schema: string;
7
- }
8
- export interface CreateTestMigratorOptions {
9
- readonly sdkOwnedMigrations?: readonly SdkOwnedMigrationSet[];
10
- }
11
- export declare function createTestMigrator(options?: CreateTestMigratorOptions): (target: TestMigrationTarget) => Promise<void>;
1
+ export { withPrefixMigrationDatabase } from './prefix-migration';
2
+ export { createTestMigrator, type CreateTestMigratorOptions, type TestMigrationTarget, } from './test-migrator';
12
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAM3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,yBAAyB;IAExC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC/D;AAWD,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,yBAA8B,GACtC,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CA6BhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC"}
@@ -1,36 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTestMigrator = createTestMigrator;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const biome_migrations_1 = require("../lib/biome-migrations");
7
- const operator_migration_1 = require("../lib/operator-migration");
8
- const SQL_IDENTIFIER = /^[a-z_][a-z0-9_]*$/iu;
9
- function createTestMigrator(options = {}) {
10
- return async (target) => {
11
- const schemaPath = (0, node_path_1.join)(target.rootDir, 'prisma', 'schema.prisma');
12
- if (!(0, node_fs_1.existsSync)(schemaPath)) {
13
- throw new Error(`${target.serviceName}: no Prisma schema at ${schemaPath}. Pass the service root as \`rootDir\` to provisionTestDatabase.`);
14
- }
15
- if (!SQL_IDENTIFIER.test(target.schema)) {
16
- throw new Error(`${target.serviceName}: refusing scratch schema ${JSON.stringify(target.schema)}; it must match ${SQL_IDENTIFIER.source} before it is interpolated into CREATE SCHEMA.`);
17
- }
18
- const database = await (0, operator_migration_1.openOperatorMigrationClient)({
19
- connectionString: target.url,
20
- });
21
- try {
22
- await database.query(`CREATE SCHEMA IF NOT EXISTS "${target.schema}"`);
23
- await (0, biome_migrations_1.runBiomeMigrations)({
24
- database,
25
- workspaceDir: target.rootDir,
26
- connectionUrl: target.url,
27
- label: target.serviceName,
28
- sdkOwnedMigrations: options.sdkOwnedMigrations ?? [],
29
- });
30
- }
31
- finally {
32
- await database.end();
33
- }
34
- };
35
- }
3
+ exports.createTestMigrator = exports.withPrefixMigrationDatabase = void 0;
4
+ var prefix_migration_1 = require("./prefix-migration");
5
+ Object.defineProperty(exports, "withPrefixMigrationDatabase", { enumerable: true, get: function () { return prefix_migration_1.withPrefixMigrationDatabase; } });
6
+ var test_migrator_1 = require("./test-migrator");
7
+ Object.defineProperty(exports, "createTestMigrator", { enumerable: true, get: function () { return test_migrator_1.createTestMigrator; } });
36
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";;AAmCA,gDA+BC;AAlED,qCAAqC;AACrC,yCAAiC;AAEjC,8DAA6D;AAC7D,kEAAwE;AAsBxE,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAS9C,SAAgB,kBAAkB,CAChC,UAAqC,EAAE;IAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;QACnE,IAAI,CAAC,IAAA,oBAAU,EAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,WAAW,yBAAyB,UAAU,kEAAkE,CAC3H,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,WAAW,6BAA6B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,cAAc,CAAC,MAAM,gDAAgD,CACxK,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAA,gDAA2B,EAAC;YACjD,gBAAgB,EAAE,MAAM,CAAC,GAAG;SAC7B,CAAC,CAAC;QACH,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,KAAK,CAAC,gCAAgC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;YACvE,MAAM,IAAA,qCAAkB,EAAC;gBACvB,QAAQ;gBACR,YAAY,EAAE,MAAM,CAAC,OAAO;gBAC5B,aAAa,EAAE,MAAM,CAAC,GAAG;gBACzB,KAAK,EAAE,MAAM,CAAC,WAAW;gBACzB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;aACrD,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";;;AAOA,uDAAiE;AAAxD,+HAAA,2BAA2B,OAAA;AACpC,iDAIyB;AAHvB,mHAAA,kBAAkB,OAAA"}
@@ -0,0 +1,3 @@
1
+ import { type PrefixMigrationFixture } from '@xemahq/pg-test-harness/migration-prefix';
2
+ export declare function withPrefixMigrationDatabase<T>(migrationsRoot: string, migrationName: string, label: string, body: (fixture: PrefixMigrationFixture) => Promise<T>): Promise<T>;
3
+ //# sourceMappingURL=prefix-migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefix-migration.d.ts","sourceRoot":"","sources":["../../src/testing/prefix-migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,0CAA0C,CAAC;AAWlD,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,CAAC,CAAC,GACpD,OAAO,CAAC,CAAC,CAAC,CAQZ"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withPrefixMigrationDatabase = withPrefixMigrationDatabase;
4
+ const migration_prefix_1 = require("@xemahq/pg-test-harness/migration-prefix");
5
+ const operator_migration_ledger_1 = require("../lib/operator-migration-ledger");
6
+ function withPrefixMigrationDatabase(migrationsRoot, migrationName, label, body) {
7
+ return (0, migration_prefix_1.withPrefixMigrationDatabase)(migrationsRoot, migrationName, label, body, { afterPrefix: operator_migration_ledger_1.ensureOperatorMigrationLedger });
8
+ }
9
+ //# sourceMappingURL=prefix-migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefix-migration.js","sourceRoot":"","sources":["../../src/testing/prefix-migration.ts"],"names":[],"mappings":";;AAcA,kEAaC;AA3BD,+EAGkD;AAElD,gFAAiF;AASjF,SAAgB,2BAA2B,CACzC,cAAsB,EACtB,aAAqB,EACrB,KAAa,EACb,IAAqD;IAErD,OAAO,IAAA,8CAAkC,EACvC,cAAc,EACd,aAAa,EACb,KAAK,EACL,IAAI,EACJ,EAAE,WAAW,EAAE,yDAA6B,EAAE,CAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type ProvisionTestDatabaseOptions as HarnessProvisionOptions } from '@xemahq/pg-test-harness';
2
+ import type { SdkOwnedMigrationSet } from '../lib/sdk-owned-migration-set';
3
+ export interface ProvisionBiomeTestDatabaseOptions extends Omit<HarnessProvisionOptions, 'migrate'> {
4
+ sdkOwnedMigrations?: readonly SdkOwnedMigrationSet[];
5
+ }
6
+ export declare function provisionTestDatabase(options: ProvisionBiomeTestDatabaseOptions): Promise<void>;
7
+ //# sourceMappingURL=provision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provision.d.ts","sourceRoot":"","sources":["../../src/testing/provision.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,4BAA4B,IAAI,uBAAuB,EAC7D,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,WAAW,iCACf,SAAQ,IAAI,CAAC,uBAAuB,EAAE,SAAS,CAAC;IAOhD,kBAAkB,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACtD;AAOD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.provisionTestDatabase = provisionTestDatabase;
4
+ const pg_test_harness_1 = require("@xemahq/pg-test-harness");
5
+ const test_migrator_1 = require("./test-migrator");
6
+ function provisionTestDatabase(options) {
7
+ const { sdkOwnedMigrations = [], ...harnessOptions } = options;
8
+ return (0, pg_test_harness_1.provisionTestDatabase)({
9
+ ...harnessOptions,
10
+ migrate: (0, test_migrator_1.createTestMigrator)({ sdkOwnedMigrations }),
11
+ });
12
+ }
13
+ //# sourceMappingURL=provision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provision.js","sourceRoot":"","sources":["../../src/testing/provision.ts"],"names":[],"mappings":";;AAyBA,sDAQC;AAjCD,6DAGiC;AAEjC,mDAAqD;AAoBrD,SAAgB,qBAAqB,CACnC,OAA0C;IAE1C,MAAM,EAAE,kBAAkB,GAAG,EAAE,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IAC/D,OAAO,IAAA,uCAAwB,EAAC;QAC9B,GAAG,cAAc;QACjB,OAAO,EAAE,IAAA,kCAAkB,EAAC,EAAE,kBAAkB,EAAE,CAAC;KACpD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { SdkOwnedMigrationSet } from '../lib/sdk-owned-migration-set';
2
+ export interface TestMigrationTarget {
3
+ readonly serviceName: string;
4
+ readonly rootDir: string;
5
+ readonly url: string;
6
+ readonly schema: string;
7
+ }
8
+ export interface CreateTestMigratorOptions {
9
+ readonly sdkOwnedMigrations?: readonly SdkOwnedMigrationSet[];
10
+ }
11
+ export declare function createTestMigrator(options?: CreateTestMigratorOptions): (target: TestMigrationTarget) => Promise<void>;
12
+ //# sourceMappingURL=test-migrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-migrator.d.ts","sourceRoot":"","sources":["../../src/testing/test-migrator.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAM3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,yBAAyB;IAExC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC/D;AAWD,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,yBAA8B,GACtC,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CA6BhD"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTestMigrator = createTestMigrator;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const biome_migrations_1 = require("../lib/biome-migrations");
7
+ const operator_migration_1 = require("../lib/operator-migration");
8
+ const SQL_IDENTIFIER = /^[a-z_][a-z0-9_]*$/iu;
9
+ function createTestMigrator(options = {}) {
10
+ return async (target) => {
11
+ const schemaPath = (0, node_path_1.join)(target.rootDir, 'prisma', 'schema.prisma');
12
+ if (!(0, node_fs_1.existsSync)(schemaPath)) {
13
+ throw new Error(`${target.serviceName}: no Prisma schema at ${schemaPath}. Pass the service root as \`rootDir\` to provisionTestDatabase.`);
14
+ }
15
+ if (!SQL_IDENTIFIER.test(target.schema)) {
16
+ throw new Error(`${target.serviceName}: refusing scratch schema ${JSON.stringify(target.schema)}; it must match ${SQL_IDENTIFIER.source} before it is interpolated into CREATE SCHEMA.`);
17
+ }
18
+ const database = await (0, operator_migration_1.openOperatorMigrationClient)({
19
+ connectionString: target.url,
20
+ });
21
+ try {
22
+ await database.query(`CREATE SCHEMA IF NOT EXISTS "${target.schema}"`);
23
+ await (0, biome_migrations_1.runBiomeMigrations)({
24
+ database,
25
+ workspaceDir: target.rootDir,
26
+ connectionUrl: target.url,
27
+ label: target.serviceName,
28
+ sdkOwnedMigrations: options.sdkOwnedMigrations ?? [],
29
+ });
30
+ }
31
+ finally {
32
+ await database.end();
33
+ }
34
+ };
35
+ }
36
+ //# sourceMappingURL=test-migrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-migrator.js","sourceRoot":"","sources":["../../src/testing/test-migrator.ts"],"names":[],"mappings":";;AAmCA,gDA+BC;AAlED,qCAAqC;AACrC,yCAAiC;AAEjC,8DAA6D;AAC7D,kEAAwE;AAsBxE,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAS9C,SAAgB,kBAAkB,CAChC,UAAqC,EAAE;IAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;QACnE,IAAI,CAAC,IAAA,oBAAU,EAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,WAAW,yBAAyB,UAAU,kEAAkE,CAC3H,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,WAAW,6BAA6B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,cAAc,CAAC,MAAM,gDAAgD,CACxK,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAA,gDAA2B,EAAC;YACjD,gBAAgB,EAAE,MAAM,CAAC,GAAG;SAC7B,CAAC,CAAC;QACH,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,KAAK,CAAC,gCAAgC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;YACvE,MAAM,IAAA,qCAAkB,EAAC;gBACvB,QAAQ;gBACR,YAAY,EAAE,MAAM,CAAC,OAAO;gBAC5B,aAAa,EAAE,MAAM,CAAC,GAAG;gBACzB,KAAK,EAAE,MAAM,CAAC,WAAW;gBACzB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;aACrD,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/biome-database-nest",
3
- "version": "1.1.0",
3
+ "version": "3.0.0",
4
4
  "description": "Explicit database migration ownership, least-privilege runtime verification, and schema-qualified Prisma wiring for Xema biome services.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
@@ -18,7 +18,10 @@
18
18
  "main": "dist/index.js",
19
19
  "types": "dist/index.d.ts",
20
20
  "files": [
21
- "dist"
21
+ "dist",
22
+ "prisma-url.js",
23
+ "prisma-url.d.ts",
24
+ "xema-peer-facts.json"
22
25
  ],
23
26
  "devDependencies": {
24
27
  "@nestjs/common": "11.1.18",
@@ -30,18 +33,19 @@
30
33
  "@types/node": "25.2.3",
31
34
  "@types/pg": "^8.16.0",
32
35
  "@xemahq/identity-client": "^0.15.5",
33
- "@xemahq/contracts": "^0.79.0",
34
- "@xemahq/pg-test-harness": "^0.3.1",
35
- "@xemahq/platform-common": ">=0.77.0",
36
+ "@xemahq/contracts": "^0.83.0",
37
+ "@xemahq/pg-test-harness": "^0.5.0",
38
+ "@xemahq/platform-common": ">=0.83.0",
36
39
  "eslint": "^9.39.4",
37
40
  "jest": "^30.3.0",
38
41
  "prettier": "3.6.2",
39
42
  "prisma": "7.8.0",
40
43
  "ts-jest": "^29.4.9",
41
44
  "typescript": "5.9.3",
42
- "@xemahq/eslint-config": "0.14.0",
43
- "@xemahq/xema-decorators": "1.0.1",
44
- "@xemahq/service-registry-nest": "1.1.0"
45
+ "@xemahq/eslint-config": "0.14.1",
46
+ "@xemahq/service-registry-nest": "1.1.0",
47
+ "@xemahq/peer-analysis": "0.2.0",
48
+ "@xemahq/xema-decorators": "2.0.0"
45
49
  },
46
50
  "peerDependencies": {
47
51
  "@nestjs/common": "^10 || ^11",
@@ -49,13 +53,19 @@
49
53
  "@prisma/adapter-pg": "^7",
50
54
  "@prisma/client": "^7",
51
55
  "@xemahq/identity-client": ">=0.9.0",
52
- "@xemahq/contracts": ">=0.4.0",
56
+ "@xemahq/contracts": ">=0.82.0",
53
57
  "@xemahq/service-registry-nest": ">=0.12.0",
54
- "@xemahq/platform-common": ">=0.18.0"
58
+ "@xemahq/platform-common": ">=0.47.0",
59
+ "@xemahq/pg-test-harness": ">=0.5.0"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "@xemahq/pg-test-harness": {
63
+ "optional": true
64
+ }
55
65
  },
56
66
  "dependencies": {
57
67
  "@xemahq/migration-runner-prisma": "^0.3.1",
58
- "@xemahq/org-erasure-nest": "^2.0.1",
68
+ "@xemahq/org-erasure-nest": "^3.1.0",
59
69
  "pg": "^8.16.3"
60
70
  },
61
71
  "exports": {
@@ -69,20 +79,32 @@
69
79
  "xema-source": "./src/testing/index.ts",
70
80
  "default": "./dist/testing/index.js"
71
81
  },
82
+ "./testing/provision": {
83
+ "types": "./dist/testing/provision.d.ts",
84
+ "xema-source": "./src/testing/provision.ts",
85
+ "default": "./dist/testing/provision.js"
86
+ },
87
+ "./prisma-url": {
88
+ "types": "./prisma-url.d.ts",
89
+ "default": "./prisma-url.js"
90
+ },
72
91
  "./dist/lib/*": {
73
92
  "types": "./dist/lib/*.d.ts",
74
93
  "default": "./dist/lib/*.js"
75
94
  }
76
95
  },
96
+ "xema": {
97
+ "peerFacts": "./xema-peer-facts.json"
98
+ },
77
99
  "scripts": {
78
- "clean": "rm -rf dist",
79
- "build": "tsc -p tsconfig.build.json",
100
+ "clean": "rm -rf dist xema-peer-facts.json",
101
+ "build": "tsc -p tsconfig.build.json && xema-peer-facts",
80
102
  "format": "prettier --write \"src/**/*.ts\"",
81
103
  "lint": "eslint .",
82
- "test": "jest",
104
+ "test": "jest --config jest.config.ts && jest --config jest.pg.config.ts",
83
105
  "typecheck": "tsc -p tsconfig.json --noEmit"
84
106
  },
85
107
  "xemaRelease": {
86
- "sourceDigest": "sha256:6a5dd5acb427f3601ffafd9f7f634024b4504d3968dd6508b0b4794998130f71"
108
+ "sourceDigest": "sha256:bc1989f3082e141397022ab33df72b9c5ce1eae637eb126ddce463f74aa42366"
87
109
  }
88
110
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Types for the build-free database-URL composition in `./prisma-url.js`.
3
+ *
4
+ * Hand-written rather than emitted, because the module it describes is
5
+ * committed rather than built — see that file's header for why it must be
6
+ * resolvable with no `dist/` present.
7
+ */
8
+
9
+ /** Discrete connection parts, mirroring the standard `DB_*` env contract. */
10
+ export interface BiomeDatabaseUrlParts {
11
+ readonly user?: string | undefined;
12
+ readonly password?: string | undefined;
13
+ readonly host?: string | undefined;
14
+ readonly port?: string | undefined;
15
+ readonly database?: string | undefined;
16
+ /** Per-biome schema for the shared `xema_biomes` DB; omit for dedicated DBs. */
17
+ readonly schema?: string | undefined;
18
+ /** Pre-formed SSL query params (e.g. `sslmode=require&sslrootcert=...`). */
19
+ readonly sslParams?: string | undefined;
20
+ }
21
+
22
+ /**
23
+ * Compose a Postgres connection URL from discrete parts, adding `?schema=` when
24
+ * a per-biome schema is supplied. Returns `null` when any required part is
25
+ * missing — the caller decides whether that is fatal (it is at runtime; it is
26
+ * not for `prisma generate`, which never reads the URL).
27
+ */
28
+ export declare function composeBiomeDatabaseUrl(
29
+ parts: BiomeDatabaseUrlParts,
30
+ ): string | null;
31
+
32
+ /**
33
+ * Convenience over {@link composeBiomeDatabaseUrl} reading the standard `DB_*`
34
+ * env contract. Pass a custom bag for tests; defaults to `process.env`.
35
+ */
36
+ export declare function composeBiomeDatabaseUrlFromEnv(
37
+ env?: NodeJS.ProcessEnv,
38
+ ): string | null;
package/prisma-url.js ADDED
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * THE database-URL composition — and the ONE copy of it in this package.
5
+ *
6
+ * This file is plain CommonJS, committed rather than built, and it imports
7
+ * NOTHING. Every one of those three properties is load-bearing, and none of
8
+ * them is a style choice:
9
+ *
10
+ * - **Committed, not built.** A `prisma.config.ts` is loaded by the Prisma
11
+ * CLI during `postinstall` (`prisma generate`), i.e. BEFORE anything has
12
+ * been compiled. In the aggregator `pnpm.overrides` forces this package to
13
+ * `workspace:*`, so a consumer resolves a LINK to this source tree — where
14
+ * `dist/` is gitignored and does not exist yet. An entry that resolves
15
+ * into `dist/` therefore cannot be imported from a `prisma.config.ts` at
16
+ * all: measured on prisma 7.8.0, the CLI fails at CONFIG LOAD with
17
+ * `Failed to load config file ... Cannot find module .../dist/index.js`,
18
+ * which would break `pnpm install` for every service at once.
19
+ * - **Zero dependencies.** The same postinstall moment has no built
20
+ * first-party graph either. Reaching this file through the package's
21
+ * `xema-source` condition (`src/index.ts`) fails for exactly that reason —
22
+ * it cascades into `@xemahq/contracts/idempotency` and every other
23
+ * first-party import, each of which needs its own `dist`.
24
+ * - **CommonJS.** The package declares no `"type"`, so `.js` here is CJS and
25
+ * `require()`-able by the CLI's config loader without a transpile step.
26
+ *
27
+ * `src/lib/database-url.ts` RE-EXPORTS these functions rather than
28
+ * restating them, so the TypeScript surface every service's `main.ts` already
29
+ * imports and the build-free surface a `prisma.config.ts` imports are the same
30
+ * code. Do not add a second implementation on the TypeScript side: the whole
31
+ * reason this file exists is that 45 services hand-rolled this composition
32
+ * (29 of them in one repository, at 29 DISTINCT sha256), and a 46th copy
33
+ * shipped as the fix would be the defect wearing a fix's costume.
34
+ *
35
+ * What this file deliberately does NOT do: read `DATABASE_URL`, and throw.
36
+ * Both belong at the CALL SITE. A caller decides whether a pre-composed
37
+ * `DATABASE_URL` outranks the discrete parts, and a caller names ITSELF in the
38
+ * error — `null` here means "the parts are not all present", which is fatal at
39
+ * runtime and is NOT fatal for `prisma generate`, which never reads the URL.
40
+ * Deciding either of those here would take the choice away from the one place
41
+ * that can make it correctly.
42
+ */
43
+
44
+ /**
45
+ * Compose a Postgres connection URL from discrete parts, adding `?schema=`
46
+ * when a per-biome schema is supplied. Returns `null` when any required part
47
+ * is missing.
48
+ *
49
+ * @param {import('./prisma-url').BiomeDatabaseUrlParts} parts
50
+ * @returns {string | null}
51
+ */
52
+ function composeBiomeDatabaseUrl(parts) {
53
+ const { user, password, host, port, database, schema, sslParams } = parts;
54
+ if (!user || !password || !host || !port || !database) {
55
+ return null;
56
+ }
57
+ const base = `postgresql://${user}:${encodeURIComponent(
58
+ password,
59
+ )}@${host}:${port}/${database}`;
60
+ const schemaPart = schema ? `schema=${schema}` : null;
61
+ const query = [schemaPart, sslParams].filter(Boolean).join('&');
62
+ return query ? `${base}?${query}` : base;
63
+ }
64
+
65
+ /**
66
+ * Convenience over {@link composeBiomeDatabaseUrl} reading the standard `DB_*`
67
+ * env contract. Pass a custom bag for tests; defaults to `process.env`.
68
+ *
69
+ * @param {NodeJS.ProcessEnv} [env]
70
+ * @returns {string | null}
71
+ */
72
+ function composeBiomeDatabaseUrlFromEnv(env = process.env) {
73
+ return composeBiomeDatabaseUrl({
74
+ user: env.DB_USER,
75
+ password: env.DB_PASSWORD,
76
+ host: env.DB_HOST,
77
+ port: env.DB_PORT,
78
+ database: env.DB_NAME,
79
+ schema: env.DB_SCHEMA,
80
+ sslParams: env.DB_SSL_PARAMS,
81
+ });
82
+ }
83
+
84
+ module.exports = { composeBiomeDatabaseUrl, composeBiomeDatabaseUrlFromEnv };