@arki/db 0.1.4 → 0.1.6

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
@@ -74,6 +74,69 @@ const idFactory = createIdFactory('post_');
74
74
  const postId = idFactory.next();
75
75
  ```
76
76
 
77
+ ## Feature-owned schema composition
78
+
79
+ The schema has a different lifetime than runtime services: `drizzle-kit`
80
+ imports tables statically, and `Db = typeof db` must exist before any DOT
81
+ pip runs. Schema is therefore **module-composed, never runtime-contributed**.
82
+ The layout:
83
+
84
+ ```text
85
+ features/orders/tables.ts — LEAF: pgTable/pgEnum definitions; imports nothing from core/
86
+ core/schema.ts — composeSchema(ordersTables, billingTables, …)
87
+ core/relations.ts — defineRelations(schema, …) — one app-level file, NOT sharded
88
+ core/db.ts — type only: Db = ReturnType<typeof buildDb>['db']
89
+ ```
90
+
91
+ ```ts
92
+ import { composeSchema } from '@arki/db';
93
+
94
+ // Each feature exports a named record from its tables.ts leaf:
95
+ export const ordersTables = { orders, orderItems, orderStatusEnum };
96
+
97
+ // The app composes — a typed identity: runtime is Object.assign, the type
98
+ // is the exact intersection. A duplicate table key is a COMPILE error
99
+ // (the parameter type collapses to a named error object) AND a runtime
100
+ // `DB_COMPOSITION_E001`, so drizzle sees a plain, collision-free object.
101
+ export const schema = composeSchema(ordersTables, billingTables);
102
+ ```
103
+
104
+ Point `drizzle-kit` at the leaves — no aggregation entrypoint needed, and
105
+ enums are scanned per file (no aliased re-export tricks):
106
+
107
+ ```ts
108
+ // drizzle.config.ts
109
+ export default defineConfig({
110
+ schema: ['./src/features/**/tables.ts'],
111
+ // …
112
+ });
113
+ ```
114
+
115
+ The layering rule that keeps the module graph a DAG: `tables.ts` imports
116
+ nothing from `core/`; `core/schema.ts` imports only leaves; feature code
117
+ imports its own leaves plus the app's pip factory.
118
+
119
+ ### Cross-feature transactions: `createUnitOfWork`
120
+
121
+ Feature services built at boot capture the singleton `db` — calling them
122
+ inside a transaction would silently escape it. Cross-feature writes go
123
+ through a typed unit of work instead:
124
+
125
+ ```ts
126
+ import { createUnitOfWork } from '@arki/db';
127
+
128
+ // Feature tx factories are STATIC exports: (tx: Database) => scoped repos.
129
+ const uow = createUnitOfWork(db, {
130
+ orders: createOrdersTx,
131
+ billing: createBillingTx,
132
+ });
133
+
134
+ await uow(async tx => {
135
+ await tx.orders.create('ord_1');
136
+ await tx.billing.charge(500); // one transaction, both features, inferred types
137
+ });
138
+ ```
139
+
77
140
  ## Subpath exports
78
141
 
79
142
  - `@arki/db` / `@arki/db/init` — `createDb`, `initDb`, `initDbWithOptions`. Under Bun, `./init` resolves to a Bun-native SQL driver.
@@ -0,0 +1,33 @@
1
+ export declare const DB_COMPOSITION_ERROR_CODES: {
2
+ readonly duplicateSchemaKey: "DB_COMPOSITION_E001";
3
+ };
4
+ export declare class DbCompositionError extends Error {
5
+ readonly code: (typeof DB_COMPOSITION_ERROR_CODES)[keyof typeof DB_COMPOSITION_ERROR_CODES];
6
+ constructor(args: {
7
+ readonly code: (typeof DB_COMPOSITION_ERROR_CODES)[keyof typeof DB_COMPOSITION_ERROR_CODES];
8
+ readonly message: string;
9
+ });
10
+ }
11
+ type SchemaSlice = Record<string, unknown>;
12
+ type UnionToIntersection<T> = (T extends unknown ? (value: T) => void : never) extends (value: infer I) => void ? I : never;
13
+ type DuplicateKeys<TSlices extends readonly SchemaSlice[], TSeen extends PropertyKey = never> = TSlices extends readonly [
14
+ infer Head,
15
+ ...infer Tail
16
+ ] ? Head extends SchemaSlice ? Tail extends readonly SchemaSlice[] ? (keyof Head & TSeen) | DuplicateKeys<Tail, TSeen | keyof Head> : keyof Head & TSeen : never : never;
17
+ type DuplicateSchemaError<TKeys extends PropertyKey> = {
18
+ readonly 'ARKI_DB: duplicate schema keys': TKeys;
19
+ };
20
+ export type ComposedSchema<TSlices extends readonly SchemaSlice[]> = UnionToIntersection<TSlices[number]>;
21
+ export declare function composeSchema<const TSlices extends readonly SchemaSlice[]>(...slices: DuplicateKeys<TSlices> extends never ? TSlices : readonly [DuplicateSchemaError<DuplicateKeys<TSlices>>]): ComposedSchema<TSlices>;
22
+ export type TransactionalDb<TTransaction> = {
23
+ transaction<TResult>(fn: (tx: TTransaction) => Promise<TResult>): Promise<TResult>;
24
+ };
25
+ export type UnitOfWorkScopes<TFactories extends Record<string, (tx: never) => unknown>> = {
26
+ readonly [K in keyof TFactories]: ReturnType<TFactories[K]>;
27
+ };
28
+ export type UnitOfWork<TScopes> = <TResult>(fn: (scopes: TScopes) => Promise<TResult> | TResult) => Promise<TResult>;
29
+ export declare function createUnitOfWork<TTransaction, const TFactories extends Record<string, (tx: TTransaction) => unknown>>(db: TransactionalDb<TTransaction>, factories: TFactories): UnitOfWork<{
30
+ readonly [K in keyof TFactories]: ReturnType<TFactories[K]>;
31
+ }>;
32
+ export {};
33
+ //# sourceMappingURL=composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B;;CAE7B,CAAC;AAEX,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;gBAEhF,IAAI,EAAE;QAChB,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;QAC5F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B;CAKF;AAED,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,GAC3G,CAAC,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AAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,OAAO,IAAI,CAAC,OAAO,EACxC,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,KAChD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,wBAAgB,gBAAgB,CAC9B,YAAY,EACZ,KAAK,CAAC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC,EAEtE,EAAE,EAAE,eAAe,CAAC,YAAY,CAAC,EACjC,SAAS,EAAE,UAAU,GACpB,UAAU,CAAC;IACZ,QAAQ,EAAE,CAAC,IAAI,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC,CASD"}
@@ -0,0 +1,38 @@
1
+ export const DB_COMPOSITION_ERROR_CODES = {
2
+ duplicateSchemaKey: 'DB_COMPOSITION_E001',
3
+ };
4
+ export class DbCompositionError extends Error {
5
+ code;
6
+ constructor(args) {
7
+ super(args.message);
8
+ this.name = 'DbCompositionError';
9
+ this.code = args.code;
10
+ }
11
+ }
12
+ export function composeSchema(...slices) {
13
+ const seen = new Set();
14
+ const schema = {};
15
+ for (const slice of slices) {
16
+ for (const key of Object.keys(slice)) {
17
+ if (seen.has(key)) {
18
+ throw new DbCompositionError({
19
+ code: DB_COMPOSITION_ERROR_CODES.duplicateSchemaKey,
20
+ message: `[db] schema key "${key}" is provided by more than one schema slice.`,
21
+ });
22
+ }
23
+ seen.add(key);
24
+ schema[key] = slice[key];
25
+ }
26
+ }
27
+ return schema;
28
+ }
29
+ export function createUnitOfWork(db, factories) {
30
+ return async (fn) => db.transaction(async (tx) => {
31
+ const scopes = {};
32
+ for (const [name, factory] of Object.entries(factories)) {
33
+ scopes[name] = factory(tx);
34
+ }
35
+ return fn(scopes);
36
+ });
37
+ }
38
+ //# s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M,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,EAAE,CAAC,MAAyE,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACP,CAAC"}
package/dist/dot.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * DOT adapter for `@arki/db`.
3
3
  *
4
- * Wraps the Drizzle database initialization as a DOT pip. The pip
4
+ * Wraps the Drizzle database initialization as a DOT plugin. The plugin
5
5
  * opens a database connection in `boot`, publishes the Drizzle handle as
6
6
  * `services.db`, and tears down the underlying client in `dispose`
7
7
  * (reverse declaration order).
@@ -50,18 +50,18 @@
50
50
  import type { AnyRelations, Logger } from 'drizzle-orm';
51
51
  import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
52
52
  import type { PgliteDatabase } from 'drizzle-orm/pglite';
53
- import type { EmptyShape, Pip } from '@arki/dot/pip';
53
+ import type { EmptyShape, Plugin } from '@arki/dot/plugin';
54
54
  import type { PgliteInitOptions } from './runtime-local.js';
55
55
  /**
56
- * Stable error codes thrown by the db pip. Exported so consumers and
56
+ * Stable error codes thrown by the db plugin. Exported so consumers and
57
57
  * coding agents can match against them — never parse the message.
58
58
  *
59
59
  * @see packages/dot/docs/principles.md — principle 1.3 ("errors are part
60
60
  * of the API") and principle 4 ("agent-discoverable everywhere").
61
61
  */
62
- export declare const DB_PIP_ERROR_CODES: {
62
+ export declare const DB_PLUGIN_ERROR_CODES: {
63
63
  /** boot was called without a configured DB_URL (pg driver). */
64
- readonly dbUrlNotConfigured: "DB_PIP_E001";
64
+ readonly dbUrlNotConfigured: "DB_PLUGIN_E001";
65
65
  };
66
66
  /**
67
67
  * Common options shared by all DB driver variants.
@@ -93,11 +93,11 @@ export type DbServices<TRelations extends AnyRelations, TDriver extends 'pg' | '
93
93
  readonly db: TDriver extends 'pglite' ? PgliteDatabase<TRelations> : NodePgDatabase<TRelations>;
94
94
  };
95
95
  /**
96
- * Build a DOT pip that opens a Drizzle database and publishes it as
96
+ * Build a DOT plugin that opens a Drizzle database and publishes it as
97
97
  * a service. The kernel calls `dispose` in reverse declaration order to
98
98
  * close the underlying pool / PGlite instance.
99
99
  */
100
- export declare function db<TRelations extends AnyRelations>(options: PgDbDotOptions<TRelations>): Pip<EmptyShape, DbServices<TRelations, 'pg'>>;
101
- export declare function db<TRelations extends AnyRelations>(options: PgliteDbDotOptions<TRelations>): Pip<EmptyShape, DbServices<TRelations, 'pglite'>>;
100
+ export declare function db<TRelations extends AnyRelations>(options: PgDbDotOptions<TRelations>): Plugin<EmptyShape, DbServices<TRelations, 'pg'>>;
101
+ export declare function db<TRelations extends AnyRelations>(options: PgliteDbDotOptions<TRelations>): Plugin<EmptyShape, DbServices<TRelations, 'pglite'>>;
102
102
  export {};
103
103
  //# sourceMappingURL=dot.d.ts.map
package/dist/dot.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dot.d.ts","sourceRoot":"","sources":["../src/dot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAK5D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;IAC7B,+DAA+D;;CAEvD,CAAC;AAEX;;GAEG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YAAY,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAExH;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,UAAU,SAAS,YAAY,EAAE,OAAO,SAAS,IAAI,GAAG,QAAQ,GAAG,IAAI,IAAI;IAChG,QAAQ,CAAC,EAAE,EAAE,OAAO,SAAS,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;CACjG,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,EAAE,CAAC,UAAU,SAAS,YAAY,EAChD,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,GAClC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AACpD,wBAAgB,EAAE,CAAC,UAAU,SAAS,YAAY,EAChD,OAAO,EAAE,kBAAkB,CAAC,UAAU,CAAC,GACtC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC"}
package/dist/dot.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * DOT adapter for `@arki/db`.
3
3
  *
4
- * Wraps the Drizzle database initialization as a DOT pip. The pip
4
+ * Wraps the Drizzle database initialization as a DOT plugin. The plugin
5
5
  * opens a database connection in `boot`, publishes the Drizzle handle as
6
6
  * `services.db`, and tears down the underlying client in `dispose`
7
7
  * (reverse declaration order).
@@ -47,20 +47,20 @@
47
47
  * this adapter without `@arki/dot` installed will fail at module load —
48
48
  * that is intentional: the adapter only makes sense in a DOT app.
49
49
  */
50
- import { pip, DotPipError } from '@arki/dot/pip';
50
+ import { plugin, DotPluginError } from '@arki/dot/plugin';
51
51
  import { env } from './env.js';
52
52
  import { createDb } from './factory.js';
53
53
  import { initDbRuntimeLocal } from './runtime-local.js';
54
54
  /**
55
- * Stable error codes thrown by the db pip. Exported so consumers and
55
+ * Stable error codes thrown by the db plugin. Exported so consumers and
56
56
  * coding agents can match against them — never parse the message.
57
57
  *
58
58
  * @see packages/dot/docs/principles.md — principle 1.3 ("errors are part
59
59
  * of the API") and principle 4 ("agent-discoverable everywhere").
60
60
  */
61
- export const DB_PIP_ERROR_CODES = {
61
+ export const DB_PLUGIN_ERROR_CODES = {
62
62
  /** boot was called without a configured DB_URL (pg driver). */
63
- dbUrlNotConfigured: 'DB_PIP_E001',
63
+ dbUrlNotConfigured: 'DB_PLUGIN_E001',
64
64
  };
65
65
  export function db(options) {
66
66
  const driver = options.driver ?? 'pg';
@@ -71,7 +71,7 @@ export function db(options) {
71
71
  // it deterministically. `services.db` is the Drizzle handle only —
72
72
  // exposing the PGlite client would leak driver-specific surface.
73
73
  let pgliteHandle;
74
- return pip({
74
+ return plugin({
75
75
  name: 'db',
76
76
  version: '0.1.0',
77
77
  configure(ctx) {
@@ -97,23 +97,23 @@ export function db(options) {
97
97
  // Node-postgres path: createDb already reads env vars and constructs the
98
98
  // pool. Drizzle owns the pool — closing it goes via the `$client.end()`
99
99
  // path that node-postgres exposes through Drizzle's handle.
100
- return pip({
100
+ return plugin({
101
101
  name: 'db',
102
102
  version: '0.1.0',
103
103
  configure(ctx) {
104
104
  ctx.registerService('db', 'db');
105
105
  },
106
106
  boot() {
107
- // Validate at the pip boundary so the DOT lifecycle gets a coded
107
+ // Validate at the plugin boundary so the DOT lifecycle gets a coded
108
108
  // error. `createDb` still throws raw `Error` for non-DOT consumers
109
109
  // (its public contract is unchanged); the check here makes sure we
110
110
  // never reach it without a URL.
111
111
  if (env.DB_URL === undefined || env.DB_URL === '') {
112
- throw new DotPipError({
113
- code: DB_PIP_ERROR_CODES.dbUrlNotConfigured,
112
+ throw new DotPluginError({
113
+ code: DB_PLUGIN_ERROR_CODES.dbUrlNotConfigured,
114
114
  message: '[db] DB_URL is not configured.',
115
- remediation: 'Set DB_URL in the environment before booting the app, or switch the pip to the pglite driver for in-process databases.',
116
- docsUrl: 'https://arki.dev/dot/errors/db-pip-e001',
115
+ remediation: 'Set DB_URL in the environment before booting the app, or switch the plugin to the pglite driver for in-process databases.',
116
+ docsUrl: 'https://arki.dev/dot/errors/db-plugin-e001',
117
117
  });
118
118
  }
119
119
  const handle = createDb({
package/dist/dot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dot.js","sourceRoot":"","sources":["../src/dot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAOH,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,+DAA+D;IAC/D,kBAAkB,EAAE,aAAa;CACzB,CAAC;AAgDX,MAAM,UAAU,EAAE,CAChB,OAAiC;IAEjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC;IAEtC,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,MAAM,aAAa,GAAG,OAAyC,CAAC;QAChE,sEAAsE;QACtE,uEAAuE;QACvE,mEAAmE;QACnE,iEAAiE;QACjE,IAAI,YAAwD,CAAC;QAC7D,OAAO,GAAG,CAAC;YACT,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,OAAO;YAChB,SAAS,CAAC,GAAG;gBACX,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAClC,CAAC;YACD,KAAK,CAAC,IAAI;gBACR,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,kBAAkB,CACrD;oBACE,GAAG,CAAC,aAAa,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CA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Z,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,OAAO;QAChB,SAAS,CAAC,GAAG;YACX,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,IAAI;YACF,oEAAoE;YACpE,mEAAmE;YACnE,mEAAmE;YACnE,gCAAgC;YAChC,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;gBAClD,MAAM,IAAI,cAAc,CAAC;oBACvB,IAAI,EAAE,qBAAqB,CAAC,kBAAkB;oBAC9C,OAAO,EAAE,gCAAgC;oBACzC,WAAW,EACT,2HAA2H;oBAC7H,OAAO,EAAE,4CAA4C;iBACtD,CAAC,CAAC;YACL,CAAC;YACD,MAAM,MAAM,GAAG,QAAQ,CAAa;gBAClC,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;aACpE,CAAC,CAAC;YACH,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE;YAC1B,mEAAmE;YACnE,4DAA4D;YAC5D,MAAM,QAAQ,GAAG,MAEhB,CAAC;YACF,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBACnC,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YAC/B,CAAC;QACH,CAAC;KACF,CAAgE,CAAC;AACpE,CAAC"}
@@ -22,4 +22,6 @@ export declare const initDbWithOptions: <TRelations extends AnyRelations>(poolCo
22
22
  };
23
23
  export { createDb } from './factory.js';
24
24
  export { getDbConnectionOptions, getDbConnectionParams } from './connection-options.js';
25
+ export { DB_COMPOSITION_ERROR_CODES, DbCompositionError, composeSchema, createUnitOfWork, } from './composition.js';
26
+ export type { ComposedSchema, TransactionalDb, UnitOfWork, UnitOfWorkScopes, } from './composition.js';
25
27
  //# sourceMappingURL=init.bun.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.bun.d.ts","sourceRoot":"","sources":["../src/init.bun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAM1B,eAAO,MAAM,MAAM,GAAI,UAAU,SAAS,YAAY,EACpD,kBAAkB,MAAM,EACxB,QAAQ,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,GAAG;IAAE,SAAS,EAAE,UAAU,CAAA;CAAE;;CAUnF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,SAAS,YAAY,EAC/D,YAAY;IACV,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,EACD,QAAQ,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,GAAG;IAAE,SAAS,EAAE,UAAU,CAAA;CAAE;;CAoBnF,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"init.bun.d.ts","sourceRoot":"","sources":["../src/init.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27
  export { createDb } from './factory.js';
28
28
  export { getDbConnectionOptions, getDbConnectionParams } from './connection-options.js';
29
+ export { DB_COMPOSITION_ERROR_CODES, DbCompositionError, composeSchema, createUnitOfWork, } from './composition.js';
29
30
  //# sourceMappingURL=init.bun.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.bun.js","sourceRoot":"","sources":["../src/init.bun.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,SAAS,CAAC,4DAA4D,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,gBAAwB,EACxB,MAAkF,EAClF,EAAE;IACF,SAAS,CAAC,sEAAsE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEnG,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzC,MAAM,EAAE,GAAG,OAAO,CAAa,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtD,SAAS,CAAC,8CAA8C,CAAC,CAAC;IAE1D,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UASC,EACD,MAAkF,EAClF,EAAE;IACF,SAAS,CAAC,kFAAkF,EAC1F,UAAU,CAAC,GAAG,IAAI,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB;QACxC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACtC,CAAC,CAAC,IAAI,GAAG,CAAC;YACN,QAAQ,EAAE,UAAU,CAAC,IAAI;YACzB,IAAI,EA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C,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB;QACxC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACtC,CAAC,CAAC,IAAI,GAAG,CAAC;YACN,QAAQ,EAAE,UAAU,CAAC,IAAI;YACzB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,QAAQ,EAAE,UAAU,CAAC,IAAI;YACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ;SAC9B,CAAC,CAAC;IAEP,MAAM,EAAE,GAAG,OAAO,CAAa,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtD,SAAS,CAAC,gEAAgE,CAAC,CAAC;IAE5E,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
package/dist/init.d.ts CHANGED
@@ -13,4 +13,6 @@ export declare const initDbWithOptions: <TRelations extends AnyRelations>(poolCo
13
13
  };
14
14
  export { createDb } from './factory.js';
15
15
  export { getDbConnectionOptions, getDbConnectionParams } from './connection-options.js';
16
+ export { DB_COMPOSITION_ERROR_CODES, DbCompositionError, composeSchema, createUnitOfWork, } from './composition.js';
17
+ export type { ComposedSchema, TransactionalDb, UnitOfWork, UnitOfWorkScopes, } from './composition.js';
16
18
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,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E;;CAenF,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
package/dist/init.js CHANGED
@@ -21,4 +21,5 @@ export const initDbWithOptions = (poolConfig, config) => {
21
21
  };
22
22
  export { createDb } from './factory.js';
23
23
  export { getDbConnectionOptions, getDbConnectionParams } from './connection-options.js';
24
+ export { DB_COMPOSITION_ERROR_CODES, DbCompositionError, composeSchema, createUnitOfWork, } from './composition.js';
24
25
  //# sourceMappingURL=init.js.map
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;AACrB,SAAS,CAAC,oDAAoD,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,gBAAwB,EACxB,MAAkF,EAClF,EAAE;IACF,SAAS,CAAC,kEAAkE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/F,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC;QACtB,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,EAAE,GAAG,OAAO,CAAa,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,SAAS,CAAC,0CAA0C,CAAC,CAAC;IAEtD,OAAO,EA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AEtD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAsB,EACtB,MAAkF,EAClF,EAAE;IACF,SAAS,CACP,8EAA8E,EAC9E,UAAU,CAAC,GAAG,IAAI,CAAC,EACnB,UAAU,CAAC,GAAG,IAAI,EAAE,EACpB,CAAC,CAAC,MAAM,CAAC,MAAM,CAChB,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;IAEpC,MAAM,EAAE,GAAG,OAAO,CAAa,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,SAAS,CAAC,4DAA4D,CAAC,CAAC;IAExE,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arki/db",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Drizzle ORM repositories and database helpers for ARKI — Postgres + PGlite runtimes, projection builder, branded ID factory, and env-aware connection pooling.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -110,8 +110,8 @@
110
110
  ],
111
111
  "dependencies": {
112
112
  "@arki/assert": "0.0.2",
113
- "@arki/contracts": "0.0.2",
114
- "@arki/env": "0.0.5",
113
+ "@arki/contracts": "0.0.3",
114
+ "@arki/env": "0.0.7",
115
115
  "@arki/log": "0.0.2",
116
116
  "@electric-sql/pglite": "^0.4.5",
117
117
  "@paralleldrive/cuid2": "^3.3.0",
@@ -122,7 +122,7 @@
122
122
  "zod": "4.3.5"
123
123
  },
124
124
  "peerDependencies": {
125
- "@arki/dot": "^0.2.0"
125
+ "@arki/dot": "^0.4.0"
126
126
  },
127
127
  "peerDependenciesMeta": {
128
128
  "@arki/dot": {
@@ -0,0 +1,92 @@
1
+ export const DB_COMPOSITION_ERROR_CODES = {
2
+ duplicateSchemaKey: 'DB_COMPOSITION_E001',
3
+ } as const;
4
+
5
+ export class DbCompositionError extends Error {
6
+ readonly code: (typeof DB_COMPOSITION_ERROR_CODES)[keyof typeof DB_COMPOSITION_ERROR_CODES];
7
+
8
+ constructor(args: {
9
+ readonly code: (typeof DB_COMPOSITION_ERROR_CODES)[keyof typeof DB_COMPOSITION_ERROR_CODES];
10
+ readonly message: string;
11
+ }) {
12
+ super(args.message);
13
+ this.name = 'DbCompositionError';
14
+ this.code = args.code;
15
+ }
16
+ }
17
+
18
+ type SchemaSlice = Record<string, unknown>;
19
+
20
+ type UnionToIntersection<T> = (T extends unknown ? (value: T) => void : never) extends (value: infer I) => void
21
+ ? I
22
+ : never;
23
+
24
+ type DuplicateKeys<TSlices extends readonly SchemaSlice[], TSeen extends PropertyKey = never> = TSlices extends readonly [
25
+ infer Head,
26
+ ...infer Tail,
27
+ ]
28
+ ? Head extends SchemaSlice
29
+ ? Tail extends readonly SchemaSlice[]
30
+ ? (keyof Head & TSeen) | DuplicateKeys<Tail, TSeen | keyof Head>
31
+ : keyof Head & TSeen
32
+ : never
33
+ : never;
34
+
35
+ type DuplicateSchemaError<TKeys extends PropertyKey> = {
36
+ readonly 'ARKI_DB: duplicate schema keys': TKeys;
37
+ };
38
+
39
+ export type ComposedSchema<TSlices extends readonly SchemaSlice[]> = UnionToIntersection<TSlices[number]>;
40
+
41
+ export function composeSchema<const TSlices extends readonly SchemaSlice[]>(
42
+ ...slices: DuplicateKeys<TSlices> extends never ? TSlices : readonly [DuplicateSchemaError<DuplicateKeys<TSlices>>]
43
+ ): ComposedSchema<TSlices> {
44
+ const seen = new Set<string>();
45
+ const schema: SchemaSlice = {};
46
+
47
+ for (const slice of slices as readonly SchemaSlice[]) {
48
+ for (const key of Object.keys(slice)) {
49
+ if (seen.has(key)) {
50
+ throw new DbCompositionError({
51
+ code: DB_COMPOSITION_ERROR_CODES.duplicateSchemaKey,
52
+ message: `[db] schema key "${key}" is provided by more than one schema slice.`,
53
+ });
54
+ }
55
+ seen.add(key);
56
+ schema[key] = slice[key];
57
+ }
58
+ }
59
+
60
+ return schema as ComposedSchema<TSlices>;
61
+ }
62
+
63
+ export type TransactionalDb<TTransaction> = {
64
+ transaction<TResult>(fn: (tx: TTransaction) => Promise<TResult>): Promise<TResult>;
65
+ };
66
+
67
+ export type UnitOfWorkScopes<TFactories extends Record<string, (tx: never) => unknown>> = {
68
+ readonly [K in keyof TFactories]: ReturnType<TFactories[K]>;
69
+ };
70
+
71
+ export type UnitOfWork<TScopes> = <TResult>(
72
+ fn: (scopes: TScopes) => Promise<TResult> | TResult,
73
+ ) => Promise<TResult>;
74
+
75
+ export function createUnitOfWork<
76
+ TTransaction,
77
+ const TFactories extends Record<string, (tx: TTransaction) => unknown>,
78
+ >(
79
+ db: TransactionalDb<TTransaction>,
80
+ factories: TFactories,
81
+ ): UnitOfWork<{
82
+ readonly [K in keyof TFactories]: ReturnType<TFactories[K]>;
83
+ }> {
84
+ return async fn =>
85
+ db.transaction(async tx => {
86
+ const scopes: Record<string, unknown> = {};
87
+ for (const [name, factory] of Object.entries(factories)) {
88
+ scopes[name] = factory(tx);
89
+ }
90
+ return fn(scopes as { readonly [K in keyof TFactories]: ReturnType<TFactories[K]> });
91
+ });
92
+ }
package/src/dot.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * DOT adapter for `@arki/db`.
3
3
  *
4
- * Wraps the Drizzle database initialization as a DOT pip. The pip
4
+ * Wraps the Drizzle database initialization as a DOT plugin. The plugin
5
5
  * opens a database connection in `boot`, publishes the Drizzle handle as
6
6
  * `services.db`, and tears down the underlying client in `dispose`
7
7
  * (reverse declaration order).
@@ -52,8 +52,8 @@ import type { AnyRelations, Logger } from 'drizzle-orm';
52
52
  import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
53
53
  import type { PgliteDatabase } from 'drizzle-orm/pglite';
54
54
 
55
- import type { EmptyShape, Pip } from '@arki/dot/pip';
56
- import { pip, DotPipError } from '@arki/dot/pip';
55
+ import type { EmptyShape, Plugin } from '@arki/dot/plugin';
56
+ import { plugin, DotPluginError } from '@arki/dot/plugin';
57
57
 
58
58
  import type { PgliteInitOptions } from './runtime-local.js';
59
59
  import { env } from './env.js';
@@ -61,15 +61,15 @@ import { createDb } from './factory.js';
61
61
  import { initDbRuntimeLocal } from './runtime-local.js';
62
62
 
63
63
  /**
64
- * Stable error codes thrown by the db pip. Exported so consumers and
64
+ * Stable error codes thrown by the db plugin. Exported so consumers and
65
65
  * coding agents can match against them — never parse the message.
66
66
  *
67
67
  * @see packages/dot/docs/principles.md — principle 1.3 ("errors are part
68
68
  * of the API") and principle 4 ("agent-discoverable everywhere").
69
69
  */
70
- export const DB_PIP_ERROR_CODES = {
70
+ export const DB_PLUGIN_ERROR_CODES = {
71
71
  /** boot was called without a configured DB_URL (pg driver). */
72
- dbUrlNotConfigured: 'DB_PIP_E001',
72
+ dbUrlNotConfigured: 'DB_PLUGIN_E001',
73
73
  } as const;
74
74
 
75
75
  /**
@@ -108,19 +108,19 @@ export type DbServices<TRelations extends AnyRelations, TDriver extends 'pg' | '
108
108
  };
109
109
 
110
110
  /**
111
- * Build a DOT pip that opens a Drizzle database and publishes it as
111
+ * Build a DOT plugin that opens a Drizzle database and publishes it as
112
112
  * a service. The kernel calls `dispose` in reverse declaration order to
113
113
  * close the underlying pool / PGlite instance.
114
114
  */
115
115
  export function db<TRelations extends AnyRelations>(
116
116
  options: PgDbDotOptions<TRelations>,
117
- ): Pip<EmptyShape, DbServices<TRelations, 'pg'>>;
117
+ ): Plugin<EmptyShape, DbServices<TRelations, 'pg'>>;
118
118
  export function db<TRelations extends AnyRelations>(
119
119
  options: PgliteDbDotOptions<TRelations>,
120
- ): Pip<EmptyShape, DbServices<TRelations, 'pglite'>>;
120
+ ): Plugin<EmptyShape, DbServices<TRelations, 'pglite'>>;
121
121
  export function db<TRelations extends AnyRelations>(
122
122
  options: DbDotOptions<TRelations>,
123
- ): Pip<EmptyShape, DbServices<TRelations, 'pg' | 'pglite'>> {
123
+ ): Plugin<EmptyShape, DbServices<TRelations, 'pg' | 'pglite'>> {
124
124
  const driver = options.driver ?? 'pg';
125
125
 
126
126
  if (driver === 'pglite') {
@@ -130,7 +130,7 @@ export function db<TRelations extends AnyRelations>(
130
130
  // it deterministically. `services.db` is the Drizzle handle only —
131
131
  // exposing the PGlite client would leak driver-specific surface.
132
132
  let pgliteHandle: { close: () => Promise<void> } | undefined;
133
- return pip({
133
+ return plugin({
134
134
  name: 'db',
135
135
  version: '0.1.0',
136
136
  configure(ctx) {
@@ -154,30 +154,30 @@ export function db<TRelations extends AnyRelations>(
154
154
  pgliteHandle = undefined;
155
155
  }
156
156
  },
157
- }) as Pip<EmptyShape, DbServices<TRelations, 'pg' | 'pglite'>>;
157
+ }) as Plugin<EmptyShape, DbServices<TRelations, 'pg' | 'pglite'>>;
158
158
  }
159
159
 
160
160
  // Node-postgres path: createDb already reads env vars and constructs the
161
161
  // pool. Drizzle owns the pool — closing it goes via the `$client.end()`
162
162
  // path that node-postgres exposes through Drizzle's handle.
163
- return pip({
163
+ return plugin({
164
164
  name: 'db',
165
165
  version: '0.1.0',
166
166
  configure(ctx) {
167
167
  ctx.registerService('db', 'db');
168
168
  },
169
169
  boot(): DbServices<TRelations, 'pg'> {
170
- // Validate at the pip boundary so the DOT lifecycle gets a coded
170
+ // Validate at the plugin boundary so the DOT lifecycle gets a coded
171
171
  // error. `createDb` still throws raw `Error` for non-DOT consumers
172
172
  // (its public contract is unchanged); the check here makes sure we
173
173
  // never reach it without a URL.
174
174
  if (env.DB_URL === undefined || env.DB_URL === '') {
175
- throw new DotPipError({
176
- code: DB_PIP_ERROR_CODES.dbUrlNotConfigured,
175
+ throw new DotPluginError({
176
+ code: DB_PLUGIN_ERROR_CODES.dbUrlNotConfigured,
177
177
  message: '[db] DB_URL is not configured.',
178
178
  remediation:
179
- 'Set DB_URL in the environment before booting the app, or switch the pip to the pglite driver for in-process databases.',
180
- docsUrl: 'https://arki.dev/dot/errors/db-pip-e001',
179
+ 'Set DB_URL in the environment before booting the app, or switch the plugin to the pglite driver for in-process databases.',
180
+ docsUrl: 'https://arki.dev/dot/errors/db-plugin-e001',
181
181
  });
182
182
  }
183
183
  const handle = createDb<TRelations>({
@@ -196,5 +196,5 @@ export function db<TRelations extends AnyRelations>(
196
196
  await pgHandle.$client.end();
197
197
  }
198
198
  },
199
- }) as Pip<EmptyShape, DbServices<TRelations, 'pg' | 'pglite'>>;
199
+ }) as Plugin<EmptyShape, DbServices<TRelations, 'pg' | 'pglite'>>;
200
200
  }
package/src/init.bun.ts CHANGED
@@ -56,3 +56,15 @@ export const initDbWithOptions = <TRelations extends AnyRelations>(
56
56
 
57
57
  export { createDb } from './factory.js';
58
58
  export { getDbConnectionOptions, getDbConnectionParams } from './connection-options.js';
59
+ export {
60
+ DB_COMPOSITION_ERROR_CODES,
61
+ DbCompositionError,
62
+ composeSchema,
63
+ createUnitOfWork,
64
+ } from './composition.js';
65
+ export type {
66
+ ComposedSchema,
67
+ TransactionalDb,
68
+ UnitOfWork,
69
+ UnitOfWorkScopes,
70
+ } from './composition.js';
package/src/init.ts CHANGED
@@ -46,3 +46,15 @@ export const initDbWithOptions = <TRelations extends AnyRelations>(
46
46
 
47
47
  export { createDb } from './factory.js';
48
48
  export { getDbConnectionOptions, getDbConnectionParams } from './connection-options.js';
49
+ export {
50
+ DB_COMPOSITION_ERROR_CODES,
51
+ DbCompositionError,
52
+ composeSchema,
53
+ createUnitOfWork,
54
+ } from './composition.js';
55
+ export type {
56
+ ComposedSchema,
57
+ TransactionalDb,
58
+ UnitOfWork,
59
+ UnitOfWorkScopes,
60
+ } from './composition.js';