@zeroxsolutions/db 7.0.0 → 8.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
@@ -458,10 +458,14 @@ import {
458
458
  } from '@zeroxsolutions/db/testing';
459
459
  import * as schema from './lib/db/index.js';
460
460
 
461
+ // The engine THIS package deploys, written down once here. It is asked for rather than defaulted:
462
+ // only you know which major your deployment runs, and a container started on another one passes.
463
+ const POSTGRES_IMAGE = 'postgres:17-alpine';
464
+
461
465
  let database: DisposablePostgres<typeof schema>;
462
466
 
463
467
  beforeAll(async () => {
464
- database = await startDisposablePostgres(schema);
468
+ database = await startDisposablePostgres(schema, POSTGRES_IMAGE);
465
469
  }, CONTAINER_TIMEOUT_MS);
466
470
 
467
471
  afterAll(async () => {
@@ -474,8 +478,8 @@ binding - takes `database.connectionString` and hands that to its test pool inst
474
478
 
475
479
  | Export | What it is |
476
480
  | ------ | ---------- |
477
- | `startDisposablePostgres(schema, image?)` | Starts the container, creates `schema` in it, and returns a Drizzle client typed against it, the `connectionString` it dialled, and the `stop()` that tears it down |
478
- | `POSTGRES_IMAGE` | `postgres:18-alpine`, the default `image` - the one place the engine version is written down, so a container started by hand takes it from here too |
481
+ | `startDisposablePostgres(schema, image)` | Starts the container, creates `schema` in it, and returns a Drizzle client typed against it, the `connectionString` it dialled, and the `stop()` that tears it down |
482
+ | `POSTGRES_IMAGE` | `postgres:18-alpine`, the engine this package's own specs run on. Yours is your own to name: `image` takes no default, so a forgotten argument is a typecheck failure rather than a suite that quietly ran a major you do not deploy |
479
483
  | `CONTAINER_TIMEOUT_MS` | 180s, for the hook that starts a container: an image pull on a cold machine outruns vitest's 5s default |
480
484
  | `fakeUuidV7` | Random bits in a v7 layout: it passes a v7 check, and is not time-ordered like a minted id |
481
485
 
@@ -1,7 +1,8 @@
1
1
  import { type PostgresJsDatabase } from 'drizzle-orm/postgres-js';
2
2
  /**
3
- * The Postgres engine every test starting a container runs against - the one place the version is written down.
4
- * The major tracks the deployed engine, which nothing in this workspace pins: iac carries only a connection string.
3
+ * The Postgres engine this package's own container-starting specs run against.
4
+ * A consumer names its own instead: which engine a context runs is that context's fact, and its major
5
+ * tracks what that context deploys, not what this package happens to test on.
5
6
  */
6
7
  export declare const POSTGRES_IMAGE = "postgres:18-alpine";
7
8
  /** Pulling the image on a cold machine costs far more than vitest's 5s default timeout. */
@@ -20,7 +21,9 @@ export interface DisposablePostgres<TSchema extends Record<string, unknown>> {
20
21
  * Starts a Postgres container, creates `schema` inside it, and returns a client typed against it
21
22
  * plus the address it dialled.
22
23
  * @param schema - the drizzle tables and relations to create; the module namespace of a schema barrel.
23
- * @param image - the Postgres image to run, defaulting to {@link POSTGRES_IMAGE}.
24
+ * @param image - the Postgres image to run. It carries no default because only the caller knows which
25
+ * engine its own deployment runs: a default would let a forgotten argument run a whole suite against
26
+ * another major, passing, and reading afterwards like the engine that caller chose.
24
27
  */
25
- export declare function startDisposablePostgres<TSchema extends Record<string, unknown>>(schema: TSchema, image?: string): Promise<DisposablePostgres<TSchema>>;
28
+ export declare function startDisposablePostgres<TSchema extends Record<string, unknown>>(schema: TSchema, image: string): Promise<DisposablePostgres<TSchema>>;
26
29
  //# sourceMappingURL=disposable-postgres.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"disposable-postgres.d.ts","sourceRoot":"","sources":["../../src/testing/disposable-postgres.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG3E;;;GAGG;AACH,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,SAAU,CAAC;AAE5C,8FAA8F;AAC9F,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzE,EAAE,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAChC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnF,MAAM,EAAE,OAAO,EACf,KAAK,GAAE,MAAuB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAiBtC"}
1
+ {"version":3,"file":"disposable-postgres.d.ts","sourceRoot":"","sources":["../../src/testing/disposable-postgres.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG3E;;;;GAIG;AACH,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,SAAU,CAAC;AAE5C,8FAA8F;AAC9F,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzE,EAAE,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAChC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnF,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAiBtC"}
@@ -3,8 +3,9 @@ import { generateDrizzleJson, generateMigration } from 'drizzle-kit/api';
3
3
  import { drizzle } from 'drizzle-orm/postgres-js';
4
4
  import postgres from 'postgres';
5
5
  /**
6
- * The Postgres engine every test starting a container runs against - the one place the version is written down.
7
- * The major tracks the deployed engine, which nothing in this workspace pins: iac carries only a connection string.
6
+ * The Postgres engine this package's own container-starting specs run against.
7
+ * A consumer names its own instead: which engine a context runs is that context's fact, and its major
8
+ * tracks what that context deploys, not what this package happens to test on.
8
9
  */
9
10
  export const POSTGRES_IMAGE = 'postgres:18-alpine';
10
11
  /** Pulling the image on a cold machine costs far more than vitest's 5s default timeout. */
@@ -13,9 +14,11 @@ export const CONTAINER_TIMEOUT_MS = 180_000;
13
14
  * Starts a Postgres container, creates `schema` inside it, and returns a client typed against it
14
15
  * plus the address it dialled.
15
16
  * @param schema - the drizzle tables and relations to create; the module namespace of a schema barrel.
16
- * @param image - the Postgres image to run, defaulting to {@link POSTGRES_IMAGE}.
17
+ * @param image - the Postgres image to run. It carries no default because only the caller knows which
18
+ * engine its own deployment runs: a default would let a forgotten argument run a whole suite against
19
+ * another major, passing, and reading afterwards like the engine that caller chose.
17
20
  */
18
- export async function startDisposablePostgres(schema, image = POSTGRES_IMAGE) {
21
+ export async function startDisposablePostgres(schema, image) {
19
22
  const container = await new PostgreSqlContainer(image).start();
20
23
  const connectionString = container.getConnectionUri();
21
24
  const client = postgres(connectionString);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeroxsolutions/db",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "description": "Generic Drizzle toolkit - the id column and audit timestamps a table takes, a base repository, the unit-of-work and transactional outbox impls, and the filter/sort/pagination query helpers, for PostgreSQL (postgres-js) and Cloudflare D1; ships no domain schema. Shared across ZeroXSolutions services.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -37,8 +37,8 @@
37
37
  "dependencies": {
38
38
  "tslib": "^2.3.0",
39
39
  "uuid": "^14.0.1",
40
- "@zeroxsolutions/query": "0.5.1",
41
- "@zeroxsolutions/cosmic": "0.3.4"
40
+ "@zeroxsolutions/cosmic": "0.3.4",
41
+ "@zeroxsolutions/query": "0.5.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@testcontainers/postgresql": "^12.1.0",