@arki/db 0.1.0 → 0.1.2
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/dist/client/ids.d.ts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/dot.d.ts +28 -12
- package/dist/dot.d.ts.map +1 -1
- package/dist/dot.js +49 -18
- package/dist/dot.js.map +1 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +14 -10
- package/dist/env.js.map +1 -1
- package/package.json +12 -5
- package/src/builder.ts +359 -0
- package/src/bun.ts +58 -0
- package/src/client/README.md +5 -0
- package/src/client/ids.ts +11 -0
- package/src/client/index.ts +11 -0
- package/src/connection-options.ts +49 -0
- package/src/debug.ts +24 -0
- package/src/dot.ts +200 -0
- package/src/env.ts +92 -0
- package/src/factory.ts +47 -0
- package/src/id-factory.ts +172 -0
- package/src/id.ts +12 -0
- package/src/init.bun.ts +58 -0
- package/src/init.ts +48 -0
- package/src/orm.ts +9 -0
- package/src/pg.ts +1 -0
- package/src/runtime-local.ts +48 -0
package/dist/client/ids.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* export type { UserId, OrgId, AssetId } from '@arki/contracts';
|
|
8
8
|
*
|
|
9
|
-
* See
|
|
9
|
+
* See packages/offline/docs/2026-05-16-arki-offline-design.md §3.3.
|
|
10
10
|
*/
|
|
11
11
|
export type {};
|
|
12
12
|
//# sourceMappingURL=ids.d.ts.map
|
package/dist/client/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* No runtime imports are allowed here — this file must remain free of any
|
|
7
7
|
* server-only dependencies (postgres, drizzle-orm connection utilities, etc.).
|
|
8
8
|
*
|
|
9
|
-
* See
|
|
9
|
+
* See packages/offline/docs/2026-05-16-arki-offline-design.md §3.3.
|
|
10
10
|
*/
|
|
11
11
|
export type * from './ids.js';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/dot.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DOT adapter for `@arki/db`.
|
|
3
3
|
*
|
|
4
|
-
* Wraps the Drizzle database initialization as a
|
|
4
|
+
* Wraps the Drizzle database initialization as a DOT pip. The pip
|
|
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
|
-
* (reverse
|
|
7
|
+
* (reverse declaration order).
|
|
8
8
|
*
|
|
9
9
|
* Two drivers are supported:
|
|
10
10
|
* - `'pg'` (default) — `node-postgres` pool. Reads `DB_URL` and the
|
|
@@ -33,6 +33,16 @@
|
|
|
33
33
|
* .boot();
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
+
* To mount a second database scope (e.g. primary + reporting) in the same
|
|
37
|
+
* app, rename the published wire key at the mount site:
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { rename } from '@arki/dot';
|
|
41
|
+
*
|
|
42
|
+
* .use(db({ relations }))
|
|
43
|
+
* .use(rename(db({ driver: 'pglite', memory: true, relations }), { db: 'reportsDb' }, 'reports-db'))
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
36
46
|
* The `@arki/dot` package is an OPTIONAL peer of `@arki/db`. Importing
|
|
37
47
|
* this adapter without `@arki/dot` installed will fail at module load —
|
|
38
48
|
* that is intentional: the adapter only makes sense in a DOT app.
|
|
@@ -40,8 +50,19 @@
|
|
|
40
50
|
import type { AnyRelations, Logger } from 'drizzle-orm';
|
|
41
51
|
import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
|
42
52
|
import type { PgliteDatabase } from 'drizzle-orm/pglite';
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
53
|
+
import type { EmptyShape, Pip } from '@arki/dot/pip';
|
|
54
|
+
import type { PgliteInitOptions } from './runtime-local.js';
|
|
55
|
+
/**
|
|
56
|
+
* Stable error codes thrown by the db pip. Exported so consumers and
|
|
57
|
+
* coding agents can match against them — never parse the message.
|
|
58
|
+
*
|
|
59
|
+
* @see packages/dot/docs/principles.md — principle 1.3 ("errors are part
|
|
60
|
+
* of the API") and principle 4 ("agent-discoverable everywhere").
|
|
61
|
+
*/
|
|
62
|
+
export declare const DB_PIP_ERROR_CODES: {
|
|
63
|
+
/** boot was called without a configured DB_URL (pg driver). */
|
|
64
|
+
readonly dbUrlNotConfigured: "DB_PIP_E001";
|
|
65
|
+
};
|
|
45
66
|
/**
|
|
46
67
|
* Common options shared by all DB driver variants.
|
|
47
68
|
*/
|
|
@@ -50,11 +71,6 @@ type BaseDbDotOptions<TRelations extends AnyRelations> = {
|
|
|
50
71
|
readonly relations: TRelations;
|
|
51
72
|
/** Drizzle logger override — `true`/`false` or a custom `Logger` instance. */
|
|
52
73
|
readonly logger?: boolean | Logger;
|
|
53
|
-
/**
|
|
54
|
-
* Pip name override. Defaults to `'db'`. Use this only when composing
|
|
55
|
-
* multiple database scopes inside the same app (e.g. primary + reporting).
|
|
56
|
-
*/
|
|
57
|
-
readonly name?: string;
|
|
58
74
|
};
|
|
59
75
|
/** Options for the node-postgres driver (the default). */
|
|
60
76
|
export type PgDbDotOptions<TRelations extends AnyRelations> = BaseDbDotOptions<TRelations> & {
|
|
@@ -78,10 +94,10 @@ export type DbServices<TRelations extends AnyRelations, TDriver extends 'pg' | '
|
|
|
78
94
|
};
|
|
79
95
|
/**
|
|
80
96
|
* Build a DOT pip that opens a Drizzle database and publishes it as
|
|
81
|
-
* a service. The kernel calls `dispose` in reverse
|
|
97
|
+
* a service. The kernel calls `dispose` in reverse declaration order to
|
|
82
98
|
* close the underlying pool / PGlite instance.
|
|
83
99
|
*/
|
|
84
|
-
export declare function db<TRelations extends AnyRelations>(options: PgDbDotOptions<TRelations>):
|
|
85
|
-
export declare function db<TRelations extends AnyRelations>(options: PgliteDbDotOptions<TRelations>):
|
|
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'>>;
|
|
86
102
|
export {};
|
|
87
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
|
|
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;AACH,KAAK,gBAAgB,CAAC,UAAU,SAAS,YAAY,IAAI;IACvD,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACpC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,MAAM,cAAc,CAAC,UAAU,SAAS,YAAY,IAAI,gBAAgB,CAAC,UAAU,CAAC,GAAG;IAC3F,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;CACxB,CAAC;AAEF,8CAA8C;AAC9C,MAAM,MAAM,kBAAkB,CAAC,UAAU,SAAS,YAAY,IAAI,gBAAgB,CAAC,UAAU,CAAC,GAC5F,iBAAiB,GAAG;IAClB,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC3B,CAAC;AAEJ,iEAAiE;AACjE,MAAM,MAAM,YAAY,CAAC,UAAU,SAAS,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,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AACjD,wBAAgB,EAAE,CAAC,UAAU,SAAS,YAAY,EAChD,OAAO,EAAE,kBAAkB,CAAC,UAAU,CAAC,GACtC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
package/dist/dot.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DOT adapter for `@arki/db`.
|
|
3
3
|
*
|
|
4
|
-
* Wraps the Drizzle database initialization as a
|
|
4
|
+
* Wraps the Drizzle database initialization as a DOT pip. The pip
|
|
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
|
-
* (reverse
|
|
7
|
+
* (reverse declaration order).
|
|
8
8
|
*
|
|
9
9
|
* Two drivers are supported:
|
|
10
10
|
* - `'pg'` (default) — `node-postgres` pool. Reads `DB_URL` and the
|
|
@@ -33,15 +33,36 @@
|
|
|
33
33
|
* .boot();
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
+
* To mount a second database scope (e.g. primary + reporting) in the same
|
|
37
|
+
* app, rename the published wire key at the mount site:
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { rename } from '@arki/dot';
|
|
41
|
+
*
|
|
42
|
+
* .use(db({ relations }))
|
|
43
|
+
* .use(rename(db({ driver: 'pglite', memory: true, relations }), { db: 'reportsDb' }, 'reports-db'))
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
36
46
|
* The `@arki/dot` package is an OPTIONAL peer of `@arki/db`. Importing
|
|
37
47
|
* this adapter without `@arki/dot` installed will fail at module load —
|
|
38
48
|
* that is intentional: the adapter only makes sense in a DOT app.
|
|
39
49
|
*/
|
|
40
|
-
import {
|
|
50
|
+
import { pip, DotPipError } from '@arki/dot/pip';
|
|
51
|
+
import { env } from './env.js';
|
|
41
52
|
import { createDb } from './factory.js';
|
|
42
53
|
import { initDbRuntimeLocal } from './runtime-local.js';
|
|
54
|
+
/**
|
|
55
|
+
* Stable error codes thrown by the db pip. Exported so consumers and
|
|
56
|
+
* coding agents can match against them — never parse the message.
|
|
57
|
+
*
|
|
58
|
+
* @see packages/dot/docs/principles.md — principle 1.3 ("errors are part
|
|
59
|
+
* of the API") and principle 4 ("agent-discoverable everywhere").
|
|
60
|
+
*/
|
|
61
|
+
export const DB_PIP_ERROR_CODES = {
|
|
62
|
+
/** boot was called without a configured DB_URL (pg driver). */
|
|
63
|
+
dbUrlNotConfigured: 'DB_PIP_E001',
|
|
64
|
+
};
|
|
43
65
|
export function db(options) {
|
|
44
|
-
const name = options.name ?? 'db';
|
|
45
66
|
const driver = options.driver ?? 'pg';
|
|
46
67
|
if (driver === 'pglite') {
|
|
47
68
|
const pgliteOptions = options;
|
|
@@ -50,21 +71,20 @@ export function db(options) {
|
|
|
50
71
|
// it deterministically. `services.db` is the Drizzle handle only —
|
|
51
72
|
// exposing the PGlite client would leak driver-specific surface.
|
|
52
73
|
let pgliteHandle;
|
|
53
|
-
return
|
|
54
|
-
name,
|
|
74
|
+
return pip({
|
|
75
|
+
name: 'db',
|
|
55
76
|
version: '0.1.0',
|
|
56
|
-
provides: ['db'],
|
|
57
77
|
configure(ctx) {
|
|
58
78
|
ctx.registerService('db', 'db');
|
|
59
79
|
},
|
|
60
80
|
async boot() {
|
|
61
81
|
const { db: handle, pglite } = await initDbRuntimeLocal({
|
|
62
|
-
...(pgliteOptions.dataDir
|
|
63
|
-
...(pgliteOptions.memory
|
|
64
|
-
...(pgliteOptions.extensions
|
|
82
|
+
...(pgliteOptions.dataDir === undefined ? {} : { dataDir: pgliteOptions.dataDir }),
|
|
83
|
+
...(pgliteOptions.memory === undefined ? {} : { memory: pgliteOptions.memory }),
|
|
84
|
+
...(pgliteOptions.extensions === undefined ? {} : { extensions: pgliteOptions.extensions }),
|
|
65
85
|
}, { relations: pgliteOptions.relations });
|
|
66
86
|
pgliteHandle = pglite;
|
|
67
|
-
return {
|
|
87
|
+
return { db: handle };
|
|
68
88
|
},
|
|
69
89
|
async dispose() {
|
|
70
90
|
if (pgliteHandle !== undefined) {
|
|
@@ -77,24 +97,35 @@ export function db(options) {
|
|
|
77
97
|
// Node-postgres path: createDb already reads env vars and constructs the
|
|
78
98
|
// pool. Drizzle owns the pool — closing it goes via the `$client.end()`
|
|
79
99
|
// path that node-postgres exposes through Drizzle's handle.
|
|
80
|
-
return
|
|
81
|
-
name,
|
|
100
|
+
return pip({
|
|
101
|
+
name: 'db',
|
|
82
102
|
version: '0.1.0',
|
|
83
|
-
provides: ['db'],
|
|
84
103
|
configure(ctx) {
|
|
85
104
|
ctx.registerService('db', 'db');
|
|
86
105
|
},
|
|
87
106
|
boot() {
|
|
107
|
+
// Validate at the pip boundary so the DOT lifecycle gets a coded
|
|
108
|
+
// error. `createDb` still throws raw `Error` for non-DOT consumers
|
|
109
|
+
// (its public contract is unchanged); the check here makes sure we
|
|
110
|
+
// never reach it without a URL.
|
|
111
|
+
if (env.DB_URL === undefined || env.DB_URL === '') {
|
|
112
|
+
throw new DotPipError({
|
|
113
|
+
code: DB_PIP_ERROR_CODES.dbUrlNotConfigured,
|
|
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',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
88
119
|
const handle = createDb({
|
|
89
120
|
relations: options.relations,
|
|
90
|
-
...(options.logger
|
|
121
|
+
...(options.logger === undefined ? {} : { logger: options.logger }),
|
|
91
122
|
});
|
|
92
|
-
return {
|
|
123
|
+
return { db: handle };
|
|
93
124
|
},
|
|
94
|
-
async dispose({
|
|
125
|
+
async dispose({ db: handle }) {
|
|
95
126
|
// Drizzle exposes the underlying pg.Pool as `$client`. We call its
|
|
96
127
|
// `end()` to drain in-flight queries and close all sockets.
|
|
97
|
-
const pgHandle =
|
|
128
|
+
const pgHandle = handle;
|
|
98
129
|
if (pgHandle.$client !== undefined) {
|
|
99
130
|
await pgHandle.$client.end();
|
|
100
131
|
}
|
package/dist/dot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dot.js","sourceRoot":"","sources":["../src/dot.ts"],"names":[],"mappings":"AAAA
|
|
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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,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,CAA6D,CAAC;AACjE,CAAC"}
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;EAuFd,CAAC"}
|
package/dist/env.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEnv } from '@arki/env/core';
|
|
2
2
|
import { z } from '@arki/contracts';
|
|
3
|
-
export const env =
|
|
4
|
-
|
|
5
|
-
console.error('❌ [@arki/db] Invalid environment variables:\n' +
|
|
6
|
-
issues.map(i => ` ${(i.path ?? []).join('.')}: ${i.message}`).join('\n'));
|
|
7
|
-
throw new Error('Invalid environment variables');
|
|
8
|
-
},
|
|
3
|
+
export const env = defineEnv({
|
|
4
|
+
name: '@arki/db',
|
|
9
5
|
/**
|
|
10
6
|
* Environment variables schema for database services (PostgreSQL)
|
|
11
7
|
*/
|
|
@@ -13,7 +9,9 @@ export const env = createEnv({
|
|
|
13
9
|
// General Configuration
|
|
14
10
|
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
|
15
11
|
// Database Connection - Primary method (connection string)
|
|
16
|
-
//
|
|
12
|
+
// DB_URL is the canonical @arki/db name. DATABASE_URL (PG/Coolify/12-factor
|
|
13
|
+
// standard) is also accepted as a fallback via the runtimeEnv alias below,
|
|
14
|
+
// which resolves to this same `env.DB_URL` field so consumers don't change.
|
|
17
15
|
DB_URL: z.url(),
|
|
18
16
|
// Database Connection - Individual parameters (alternative to DB_URL)
|
|
19
17
|
PGUSER: z.string().optional(),
|
|
@@ -52,7 +50,11 @@ export const env = createEnv({
|
|
|
52
50
|
*/
|
|
53
51
|
runtimeEnv: {
|
|
54
52
|
NODE_ENV: process.env['NODE_ENV'],
|
|
55
|
-
DB_URL
|
|
53
|
+
// Resolve from `DB_URL` (canonical) first, falling back to `DATABASE_URL`
|
|
54
|
+
// (PG/Coolify/12-factor standard) so deployments using the standard name
|
|
55
|
+
// still work. Closes the silent divergence between app schemas keyed on
|
|
56
|
+
// DATABASE_URL and this package's DB_URL schema.
|
|
57
|
+
DB_URL: process.env['DB_URL'] ?? process.env['DATABASE_URL'],
|
|
56
58
|
PGUSER: process.env['PGUSER'],
|
|
57
59
|
PGPASSWORD: process.env['PGPASSWORD'],
|
|
58
60
|
PGHOST: process.env['PGHOST'],
|
|
@@ -72,6 +74,8 @@ export const env = createEnv({
|
|
|
72
74
|
DB_SEED_ON_START: process.env['DB_SEED_ON_START'],
|
|
73
75
|
DB_DROP_ON_START: process.env['DB_DROP_ON_START'],
|
|
74
76
|
},
|
|
75
|
-
|
|
77
|
+
options: {
|
|
78
|
+
skipValidation: !!process.env['SKIP_ENV_VALIDATION'] || !!process.env['CI'] || process.env['NODE_ENV'] === 'test',
|
|
79
|
+
},
|
|
76
80
|
});
|
|
77
81
|
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEpC,MAAM,CAAC,MAAM,GAAG,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
+
"version": "0.1.2",
|
|
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": {
|
|
@@ -98,14 +98,21 @@
|
|
|
98
98
|
},
|
|
99
99
|
"files": [
|
|
100
100
|
"dist/**",
|
|
101
|
+
"src/**",
|
|
102
|
+
"!src/**/*.test.*",
|
|
103
|
+
"!src/**/*.spec.*",
|
|
104
|
+
"!src/**/tests/**",
|
|
105
|
+
"!src/**/test/**",
|
|
106
|
+
"!src/**/__tests__/**",
|
|
101
107
|
"README.md",
|
|
102
108
|
"LICENSE",
|
|
103
109
|
"package.json"
|
|
104
110
|
],
|
|
105
111
|
"dependencies": {
|
|
106
|
-
"@arki/assert": "0.0.
|
|
107
|
-
"@arki/contracts": "0.0.
|
|
108
|
-
"@arki/
|
|
112
|
+
"@arki/assert": "0.0.2",
|
|
113
|
+
"@arki/contracts": "0.0.2",
|
|
114
|
+
"@arki/env": "0.0.3",
|
|
115
|
+
"@arki/log": "0.0.2",
|
|
109
116
|
"@electric-sql/pglite": "^0.4.5",
|
|
110
117
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
111
118
|
"@t3-oss/env-core": "^0.13.10",
|
|
@@ -115,7 +122,7 @@
|
|
|
115
122
|
"zod": "4.3.5"
|
|
116
123
|
},
|
|
117
124
|
"peerDependencies": {
|
|
118
|
-
"@arki/dot": "^0.1.
|
|
125
|
+
"@arki/dot": "^0.1.2"
|
|
119
126
|
},
|
|
120
127
|
"peerDependenciesMeta": {
|
|
121
128
|
"@arki/dot": {
|