@xemahq/biome-database-nest 3.0.2 → 5.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.
package/README.md CHANGED
@@ -57,23 +57,7 @@ Every Postgres session must run in UTC. The package verifies this and refuses to
57
57
 
58
58
  ## Testing
59
59
 
60
- `@xemahq/pg-test-harness` (0.5 and later) provisions a scratch database but does not know how to migrate it. `createTestMigrator` from the `/testing` subpath returns the `migrate` callback it needs: the same migration phase a service runs at boot (`runBiomeMigrations`). It applies the service's Prisma migrations from `<rootDir>/prisma`, then the operator-migration ledger and the SDK-owned migrations you list, and verifies every owned table's shape. Running it again on the same schema changes nothing.
61
-
62
- ```ts
63
- // tests/global-setup.ts
64
- import { createTestMigrator } from '@xemahq/biome-database-nest/testing';
65
- import { provisionTestDatabase } from '@xemahq/pg-test-harness';
66
-
67
- export default async function globalSetup(): Promise<void> {
68
- await provisionTestDatabase({
69
- serviceName: 'example',
70
- rootDir: process.cwd(),
71
- migrate: createTestMigrator({ sdkOwnedMigrations: [/* each SDK's migration set */] }),
72
- });
73
- }
74
- ```
75
-
76
- `createTestMigrator(options?)` takes `sdkOwnedMigrations?: readonly SdkOwnedMigrationSet[]` and returns `(target: { serviceName, rootDir, url, schema }) => Promise<void>`. It reads no environment variables.
60
+ Test helpers (the biome migrator for `@xemahq/pg-test-harness` and the prefix-migration fixture) live in the separate `@xemahq/biome-database-nest-testing` package, so this runtime package never references the test harness. Install that package as a `devDependency`.
77
61
 
78
62
  ## Peer requirements
79
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/biome-database-nest",
3
- "version": "3.0.2",
3
+ "version": "5.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)",
@@ -42,10 +42,10 @@
42
42
  "prisma": "7.8.0",
43
43
  "ts-jest": "^29.4.9",
44
44
  "typescript": "5.9.3",
45
- "@xemahq/service-registry-nest": "1.1.0",
46
45
  "@xemahq/xema-decorators": "2.1.0",
46
+ "@xemahq/peer-analysis": "0.2.0",
47
47
  "@xemahq/eslint-config": "0.14.1",
48
- "@xemahq/peer-analysis": "0.2.0"
48
+ "@xemahq/service-registry-nest": "1.1.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@nestjs/common": "^10 || ^11",
@@ -53,15 +53,9 @@
53
53
  "@prisma/adapter-pg": "^7",
54
54
  "@prisma/client": "^7",
55
55
  "@xemahq/identity-client": ">=0.9.0",
56
- "@xemahq/contracts": ">=0.82.0",
56
+ "@xemahq/contracts": ">=0.86.0",
57
57
  "@xemahq/service-registry-nest": ">=0.12.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
- }
58
+ "@xemahq/platform-common": ">=0.47.0"
65
59
  },
66
60
  "dependencies": {
67
61
  "@xemahq/migration-runner-prisma": "^0.3.1",
@@ -74,16 +68,6 @@
74
68
  "xema-source": "./src/index.ts",
75
69
  "default": "./dist/index.js"
76
70
  },
77
- "./testing": {
78
- "types": "./dist/testing/index.d.ts",
79
- "xema-source": "./src/testing/index.ts",
80
- "default": "./dist/testing/index.js"
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
71
  "./prisma-url": {
88
72
  "types": "./prisma-url.d.ts",
89
73
  "default": "./prisma-url.js"
@@ -105,6 +89,6 @@
105
89
  "typecheck": "tsc -p tsconfig.json --noEmit"
106
90
  },
107
91
  "xemaRelease": {
108
- "sourceDigest": "sha256:9008a1df4e5b359b4844cb5c385bde2d7922ab1ac38e4c34236cdebf91fd08c2"
92
+ "sourceDigest": "sha256:b91eef64d1b2fdb0b02badff9a1c05a4341ae71a13517109213c625c15aa6eee"
109
93
  }
110
94
  }
@@ -2,7 +2,7 @@
2
2
  "factsVersion": 1,
3
3
  "package": {
4
4
  "name": "@xemahq/biome-database-nest",
5
- "version": "3.0.2"
5
+ "version": "5.0.0"
6
6
  },
7
7
  "seamTable": {
8
8
  "version": 3,
@@ -1,3 +0,0 @@
1
- export { withPrefixMigrationDatabase } from './prefix-migration';
2
- export { createTestMigrator, type CreateTestMigratorOptions, type TestMigrationTarget, } from './test-migrator';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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; } });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}
@@ -1,3 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,36 +0,0 @@
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
@@ -1 +0,0 @@
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,EA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