@prisma-idb/client-idb 0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idb-orm-zCRkkD_D.d.mts","names":[],"sources":["../src/core/types.ts","../src/core/executor.ts","../src/core/model-accessor.ts","../src/core/store-state.ts","../src/core/grouped-accessor.ts","../src/core/store-accessor.ts","../src/core/idb-orm.ts"],"mappings":";;;;;;;;;;;;;KAsBK,SAAS,aAAa;WAA6B;aAAmB,kBAAkB;;IACzF,SAAS;WAAuB,cAAc;IAC5C,UAAU,eAAe,qBACvB,IACA,eAAe,qBACjB,eAAe,qBACjB,eAAe;;;;;;KASP,cAAc,SAAS;;;;;;;;;;;;KAiB9B,mBAAmB,aAAa,2BAA2B,iBAAiB,2BAA2B;KAEvG,kBAAkB,WAAW,iDAAiD,2BAA2B,aAC1G,0BACA,mBAAmB,mBAAmB,0BACpC,wBAAwB,mBAAmB,0BAC5B,WAAW,mBAAmB,WAAW,aAAa,mBAAmB,WAAW,WAAW,QAC5G,0BACF;;;;;;;KAQD,kBAAkB,aAAa,0BAA0B,iBAAiB,0BAA0B;KAEpG,iBAAiB,WAAW,iDAAiD,0BAA0B,aACxG,0BACA,kBAAkB,mBAAmB,0BACnC,wBAAwB,kBAAkB,0BAC3B,WAAW,kBAAkB,WAAW,aAAa,kBAAkB,WAAW,WAAW,QAC1G,0BACF;;KAKM,gBAAgB,WAAW,4BAA4B,kBAAkB,WAAW;;;;;;;;KAWpF,YAAY,WAAW,wCACvB,WAAW,gBAAgB,WAAW,cAAc,gBAAgB,WAAW,WAAW;;;;;;;;KAY1F,aAAa,WAAW,4BAA4B,wBAAwB,SAAS,aAC7F,SAAS,WAAW;EAAqB;IAAW,eAAe;;IACjE,mBACE;;;;;;;;KAYI,QAAQ,WAAW,4BAC7B,aAAa,WAAW,yBAAyB,kBAAkB,WAAW,aAC1E,kBAAkB,WAAW,WAAW,aAAa,W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,gBAAgB,WAAW;;;;;EAMvC,UAAU,MAAM,YAAY,WAAW,eAAe,oBAAoB,gBAAgB,WAAW;;;;;EAMrG,YAAY,MAAM,YAAY,WAAW,eAAe;;;;;EAMxD,aAAa,oBAAoB,gBAAgB,WAAW;;;;;EAM5D,eAAe;;;;;;;;;;;EAYf,SAAS;;;;;;;;;;;;;;;;KCrUC,aAAa,kBAAkB,SAAS,2BAGxC,oBAAoB,qBAAqB,mBAAmB;EACpE,aAAa;IAEX,iBAAiB,WAAW;;;;UAOjB,cAAc,kBAAkB;;WAEtC,UAAU;;;;;;;WAOV,UAAU;;;;;;;;;;;;;;;;;;;;;;;iBA0BL,OAAO,kBAAkB,aAAa,SAAS,cAAc,aAAa,aAAa"}
@@ -0,0 +1,122 @@
1
+ import { c as withMutationScope, t as idbOrm } from "./idb-orm-Cupnnwum.mjs";
2
+ import { IdbAdapter } from "@prisma-idb/adapter-idb/runtime";
3
+ import { createIDBRuntimeDriver } from "@prisma-idb/driver-idb/runtime";
4
+ import { createIdbRuntime } from "@prisma-idb/runtime-idb/runtime";
5
+ import { idbCodecLookup } from "@prisma-idb/target-idb/runtime";
6
+ //#region src/core/idb-client.ts
7
+ /**
8
+ * Creates a typed IDB client from a contract and a database name.
9
+ *
10
+ * Assembles the full runtime stack (driver → adapter → runtime → ORM) internally.
11
+ * Equivalent to `postgres({ contract, url })` in `@prisma/orm-postgres/runtime`.
12
+ *
13
+ * The IDB database version is not exposed — it is managed by the migration runner
14
+ * per ADR 001. The driver opens at the current database version, which is correct
15
+ * for a runtime that only reads/writes (no DDL).
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { createIdbClient } from '@prisma-idb/client-idb/client';
20
+ * import contract from './contract';
21
+ *
22
+ * export const db = createIdbClient({ contract, dbName: 'my-app' });
23
+ *
24
+ * // Later:
25
+ * const users = await db.orm.users.all().toArray();
26
+ * ```
27
+ */
28
+ function createIdbClient(options) {
29
+ const driver = createIDBRuntimeDriver(options.dbName, void 0, options.factory !== void 0 ? { factory: options.factory } : void 0).create();
30
+ const adapter = new IdbAdapter(idbCodecLookup);
31
+ const runtime = createIdbRuntime({
32
+ adapter,
33
+ driver,
34
+ contract: options.contract,
35
+ ...options.middleware !== void 0 && options.middleware.length > 0 ? { middleware: options.middleware } : {}
36
+ });
37
+ return {
38
+ orm: idbOrm({
39
+ contract: options.contract,
40
+ executor: runtime
41
+ }),
42
+ withTransaction: (storeNames, fn) => withMutationScope(runtime, storeNames, fn),
43
+ verifyMarker: () => runtime.verifyMarker(),
44
+ async close() {
45
+ await runtime.close();
46
+ },
47
+ [Symbol.asyncDispose]() {
48
+ return this.close();
49
+ }
50
+ };
51
+ }
52
+ //#endregion
53
+ //#region src/core/managed-client.ts
54
+ /**
55
+ * Wraps `open` (a client factory, e.g. `() => createAutoMigratingIdbClient({...})`)
56
+ * with a module-scoped singleton: `get()` opens once and caches the result,
57
+ * `close()` releases it, `reset()` closes and wipes the underlying database.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { createManagedIdbClient } from '@prisma-idb/client-idb/client';
62
+ *
63
+ * const db = createManagedIdbClient(
64
+ * () => createAutoMigratingIdbClient({ contractSpace, dbName: 'my-app' }),
65
+ * { dbName: 'my-app' }
66
+ * );
67
+ *
68
+ * const client = await db.get();
69
+ * // ... on logout:
70
+ * await db.reset();
71
+ * ```
72
+ */
73
+ function createManagedIdbClient(open, options) {
74
+ const { dbName, idbFactory = indexedDB } = options;
75
+ let client = null;
76
+ let clientPromise = null;
77
+ let resetPromise = null;
78
+ async function get() {
79
+ if (resetPromise) await resetPromise;
80
+ if (client) return client;
81
+ clientPromise ??= open().catch((err) => {
82
+ clientPromise = null;
83
+ throw err;
84
+ });
85
+ const fresh = await clientPromise;
86
+ client = fresh;
87
+ return fresh;
88
+ }
89
+ async function close() {
90
+ if (!client) return;
91
+ await client.close();
92
+ client = null;
93
+ clientPromise = null;
94
+ }
95
+ async function reset() {
96
+ if (resetPromise) return resetPromise;
97
+ resetPromise = (async () => {
98
+ if (clientPromise) await clientPromise.catch(() => {});
99
+ await close();
100
+ await new Promise((resolve, reject) => {
101
+ const req = idbFactory.deleteDatabase(dbName);
102
+ req.onsuccess = () => resolve();
103
+ req.onerror = () => reject(req.error);
104
+ req.onblocked = () => {};
105
+ });
106
+ })();
107
+ try {
108
+ await resetPromise;
109
+ } finally {
110
+ resetPromise = null;
111
+ }
112
+ }
113
+ return {
114
+ get,
115
+ close,
116
+ reset
117
+ };
118
+ }
119
+ //#endregion
120
+ export { createIdbClient as n, createManagedIdbClient as t };
121
+
122
+ //# sourceMappingURL=managed-client-B_8JZM3h.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-client-B_8JZM3h.mjs","names":[],"sources":["../src/core/idb-client.ts","../src/core/managed-client.ts"],"sourcesContent":["import { IdbAdapter } from \"@prisma-idb/adapter-idb/runtime\";\nimport { createIDBRuntimeDriver } from \"@prisma-idb/driver-idb/runtime\";\nimport type { IdbTransactionScope } from \"@prisma-idb/driver-idb/runtime\";\nimport type { IdbMiddleware } from \"@prisma-idb/runtime-idb/runtime\";\nimport { createIdbRuntime } from \"@prisma-idb/runtime-idb/runtime\";\nimport { idbCodecLookup } from \"@prisma-idb/target-idb/runtime\";\nimport { withMutationScope } from \"./mutation-scope\";\nimport { idbOrm } from \"./idb-orm\";\nimport type { IdbOrmClient } from \"./idb-orm\";\nimport type { IdbContract } from \"./types\";\n\nexport interface IdbClientOptions<TContract extends IdbContract> {\n readonly contract: TContract;\n readonly dbName: string;\n // No version — the migration runner owns the IDB version integer (ADR 001).\n /** IDB factory override — primarily for tests and custom browser realms. */\n readonly factory?: IDBFactory;\n readonly middleware?: readonly IdbMiddleware[];\n}\n\nexport interface IdbClient<TContract extends IdbContract> {\n readonly orm: IdbOrmClient<TContract>;\n /**\n * Run `fn` inside a single multi-store readwrite IDB transaction.\n *\n * Opens the transaction, passes an `IdbTransactionScope` to `fn`, then\n * commits on success or rolls back on error. Equivalent to calling\n * `withMutationScope(runtime, storeNames, fn)`.\n *\n * Useful from test harnesses and from any caller that has an `IdbClient`\n * but not the raw runtime reference.\n */\n withTransaction<T>(storeNames: string[], fn: (scope: IdbTransactionScope) => Promise<T>): Promise<T>;\n verifyMarker(): Promise<boolean>;\n close(): Promise<void>;\n [Symbol.asyncDispose](): Promise<void>;\n}\n\n/**\n * Creates a typed IDB client from a contract and a database name.\n *\n * Assembles the full runtime stack (driver → adapter → runtime → ORM) internally.\n * Equivalent to `postgres({ contract, url })` in `@prisma/orm-postgres/runtime`.\n *\n * The IDB database version is not exposed — it is managed by the migration runner\n * per ADR 001. The driver opens at the current database version, which is correct\n * for a runtime that only reads/writes (no DDL).\n *\n * @example\n * ```ts\n * import { createIdbClient } from '@prisma-idb/client-idb/client';\n * import contract from './contract';\n *\n * export const db = createIdbClient({ contract, dbName: 'my-app' });\n *\n * // Later:\n * const users = await db.orm.users.all().toArray();\n * ```\n */\nexport function createIdbClient<TContract extends IdbContract>(\n options: IdbClientOptions<TContract>\n): IdbClient<TContract> {\n const driver = createIDBRuntimeDriver(\n options.dbName,\n undefined,\n options.factory !== undefined ? { factory: options.factory } : undefined\n ).create();\n const adapter = new IdbAdapter(idbCodecLookup);\n const runtime = createIdbRuntime({\n adapter,\n driver,\n contract: options.contract as Record<string, unknown>,\n ...(options.middleware !== undefined && options.middleware.length > 0 ? { middleware: options.middleware } : {}),\n });\n const orm = idbOrm({ contract: options.contract, executor: runtime });\n\n return {\n orm,\n withTransaction: <T>(storeNames: string[], fn: (scope: IdbTransactionScope) => Promise<T>) =>\n withMutationScope(runtime, storeNames, fn),\n verifyMarker: () => runtime.verifyMarker(),\n async close() {\n await runtime.close();\n },\n [Symbol.asyncDispose]() {\n return this.close();\n },\n };\n}\n","/**\n * `createManagedIdbClient` — a singleton, race-safe wrapper around any IDB\n * client factory (`createIdbClient`, `createAutoMigratingIdbClient`, or a\n * sync-extension factory like `createAutoMigratingSyncIdbClient` — anything\n * returning a `close(): Promise<void>`-shaped client).\n *\n * Every consumer of this package that wants a module-level singleton client\n * plus a \"wipe local data\" reset (e.g. on logout) needs the same race-safety:\n * `reset()` must never call `indexedDB.deleteDatabase` while a `get()` open\n * is still in flight, since a still-opening connection would block (or worse,\n * leave a stale handle once that open resolves after the delete). This was\n * previously hand-rolled per app with diverging correctness; see ADR-less\n * discussion in the kanban example's `db.ts` history.\n */\n\nexport interface ManagedIdbClientOptions {\n /** IDB database name — passed to `indexedDB.deleteDatabase` on `reset()`. */\n readonly dbName: string;\n /** IDB factory override — primarily for tests. Defaults to `indexedDB`. */\n readonly idbFactory?: IDBFactory;\n}\n\nexport interface ManagedIdbClient<TClient> {\n /** Opens the client on first call and caches it; concurrent calls share one open. */\n get(): Promise<TClient>;\n /** Closes the cached client, if any. Safe to call when nothing is open. */\n close(): Promise<void>;\n /**\n * Closes and deletes the database — waits out any `get()` open already in\n * flight first. `onblocked` (another tab still has the DB open) is NOT\n * terminal — per spec, the delete request stays pending, and still fires\n * `onsuccess` once every blocking connection closes — so this promise\n * stays pending through it too, settling only once `deleteDatabase`\n * actually reaches `onsuccess` or `onerror`. Neither resolving early\n * (claims success before the old data is actually gone) nor rejecting\n * early (reports failure on a delete that may still succeed) would be\n * accurate.\n */\n reset(): Promise<void>;\n}\n\n/**\n * Wraps `open` (a client factory, e.g. `() => createAutoMigratingIdbClient({...})`)\n * with a module-scoped singleton: `get()` opens once and caches the result,\n * `close()` releases it, `reset()` closes and wipes the underlying database.\n *\n * @example\n * ```ts\n * import { createManagedIdbClient } from '@prisma-idb/client-idb/client';\n *\n * const db = createManagedIdbClient(\n * () => createAutoMigratingIdbClient({ contractSpace, dbName: 'my-app' }),\n * { dbName: 'my-app' }\n * );\n *\n * const client = await db.get();\n * // ... on logout:\n * await db.reset();\n * ```\n */\nexport function createManagedIdbClient<TClient extends { close(): Promise<void> }>(\n open: () => Promise<TClient>,\n options: ManagedIdbClientOptions\n): ManagedIdbClient<TClient> {\n const { dbName, idbFactory = indexedDB } = options;\n\n let client: TClient | null = null;\n let clientPromise: Promise<TClient> | null = null;\n // Gate between get() and reset() — set synchronously (no `await` before\n // either reads/writes it) so the two never interleave: see module doc comment.\n let resetPromise: Promise<void> | null = null;\n\n async function get(): Promise<TClient> {\n if (resetPromise) await resetPromise;\n if (client) return client;\n clientPromise ??= open().catch((err: unknown) => {\n // Clear on rejection so a later get() call retries instead of\n // re-awaiting the same rejected promise forever.\n clientPromise = null;\n throw err;\n });\n\n const fresh = await clientPromise;\n client = fresh;\n return fresh;\n }\n\n async function close(): Promise<void> {\n if (!client) return;\n await client.close();\n client = null;\n clientPromise = null;\n }\n\n async function reset(): Promise<void> {\n if (resetPromise) return resetPromise;\n resetPromise = (async () => {\n if (clientPromise) await clientPromise.catch(() => {});\n await close();\n await new Promise<void>((resolve, reject) => {\n const req = idbFactory.deleteDatabase(dbName);\n req.onsuccess = () => resolve();\n req.onerror = () => reject(req.error as Error);\n // Deliberately no-op: `onblocked` only means the request is waiting\n // on another open connection, not that it failed — `onsuccess` (or\n // `onerror`) still fires later once that connection closes. Settling\n // here either way would misreport the outcome; see the `reset()`\n // doc comment above.\n req.onblocked = () => {};\n });\n })();\n try {\n await resetPromise;\n } finally {\n resetPromise = null;\n }\n }\n\n return { get, close, reset };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,SAAgB,gBACd,SACsB;CACtB,MAAM,SAAS,uBACb,QAAQ,QACR,KAAA,GACA,QAAQ,YAAY,KAAA,IAAY,EAAE,SAAS,QAAQ,QAAQ,IAAI,KAAA,CACjE,CAAC,CAAC,OAAO;CACT,MAAM,UAAU,IAAI,WAAW,cAAc;CAC7C,MAAM,UAAU,iBAAiB;EAC/B;EACA;EACA,UAAU,QAAQ;EAClB,GAAI,QAAQ,eAAe,KAAA,KAAa,QAAQ,WAAW,SAAS,IAAI,EAAE,YAAY,QAAQ,WAAW,IAAI,CAAC;CAChH,CAAC;CAGD,OAAO;EACL,KAHU,OAAO;GAAE,UAAU,QAAQ;GAAU,UAAU;EAAQ,CAG/D;EACF,kBAAqB,YAAsB,OACzC,kBAAkB,SAAS,YAAY,EAAE;EAC3C,oBAAoB,QAAQ,aAAa;EACzC,MAAM,QAAQ;GACZ,MAAM,QAAQ,MAAM;EACtB;EACA,CAAC,OAAO,gBAAgB;GACtB,OAAO,KAAK,MAAM;EACpB;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;AC5BA,SAAgB,uBACd,MACA,SAC2B;CAC3B,MAAM,EAAE,QAAQ,aAAa,cAAc;CAE3C,IAAI,SAAyB;CAC7B,IAAI,gBAAyC;CAG7C,IAAI,eAAqC;CAEzC,eAAe,MAAwB;EACrC,IAAI,cAAc,MAAM;EACxB,IAAI,QAAQ,OAAO;EACnB,kBAAkB,KAAK,CAAC,CAAC,OAAO,QAAiB;GAG/C,gBAAgB;GAChB,MAAM;EACR,CAAC;EAED,MAAM,QAAQ,MAAM;EACpB,SAAS;EACT,OAAO;CACT;CAEA,eAAe,QAAuB;EACpC,IAAI,CAAC,QAAQ;EACb,MAAM,OAAO,MAAM;EACnB,SAAS;EACT,gBAAgB;CAClB;CAEA,eAAe,QAAuB;EACpC,IAAI,cAAc,OAAO;EACzB,gBAAgB,YAAY;GAC1B,IAAI,eAAe,MAAM,cAAc,YAAY,CAAC,CAAC;GACrD,MAAM,MAAM;GACZ,MAAM,IAAI,SAAe,SAAS,WAAW;IAC3C,MAAM,MAAM,WAAW,eAAe,MAAM;IAC5C,IAAI,kBAAkB,QAAQ;IAC9B,IAAI,gBAAgB,OAAO,IAAI,KAAc;IAM7C,IAAI,kBAAkB,CAAC;GACzB,CAAC;EACH,EAAA,CAAG;EACH,IAAI;GACF,MAAM;EACR,UAAU;GACR,eAAe;EACjB;CACF;CAEA,OAAO;EAAE;EAAK;EAAO;CAAM;AAC7B"}
@@ -0,0 +1,115 @@
1
+ import { b as IdbContract, t as IdbOrmClient } from "./idb-orm-zCRkkD_D.mjs";
2
+ import { IdbTransactionScope } from "@prisma-idb/driver-idb/runtime";
3
+ import { IdbMiddleware } from "@prisma-idb/runtime-idb/runtime";
4
+ //#region src/core/idb-client.d.ts
5
+ interface IdbClientOptions<TContract extends IdbContract> {
6
+ readonly contract: TContract;
7
+ readonly dbName: string;
8
+ /** IDB factory override — primarily for tests and custom browser realms. */
9
+ readonly factory?: IDBFactory;
10
+ readonly middleware?: readonly IdbMiddleware[];
11
+ }
12
+ interface IdbClient<TContract extends IdbContract> {
13
+ readonly orm: IdbOrmClient<TContract>;
14
+ /**
15
+ * Run `fn` inside a single multi-store readwrite IDB transaction.
16
+ *
17
+ * Opens the transaction, passes an `IdbTransactionScope` to `fn`, then
18
+ * commits on success or rolls back on error. Equivalent to calling
19
+ * `withMutationScope(runtime, storeNames, fn)`.
20
+ *
21
+ * Useful from test harnesses and from any caller that has an `IdbClient`
22
+ * but not the raw runtime reference.
23
+ */
24
+ withTransaction<T>(storeNames: string[], fn: (scope: IdbTransactionScope) => Promise<T>): Promise<T>;
25
+ verifyMarker(): Promise<boolean>;
26
+ close(): Promise<void>;
27
+ [Symbol.asyncDispose](): Promise<void>;
28
+ }
29
+ /**
30
+ * Creates a typed IDB client from a contract and a database name.
31
+ *
32
+ * Assembles the full runtime stack (driver → adapter → runtime → ORM) internally.
33
+ * Equivalent to `postgres({ contract, url })` in `@prisma/orm-postgres/runtime`.
34
+ *
35
+ * The IDB database version is not exposed — it is managed by the migration runner
36
+ * per ADR 001. The driver opens at the current database version, which is correct
37
+ * for a runtime that only reads/writes (no DDL).
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { createIdbClient } from '@prisma-idb/client-idb/client';
42
+ * import contract from './contract';
43
+ *
44
+ * export const db = createIdbClient({ contract, dbName: 'my-app' });
45
+ *
46
+ * // Later:
47
+ * const users = await db.orm.users.all().toArray();
48
+ * ```
49
+ */
50
+ declare function createIdbClient<TContract extends IdbContract>(options: IdbClientOptions<TContract>): IdbClient<TContract>;
51
+ //#endregion
52
+ //#region src/core/managed-client.d.ts
53
+ /**
54
+ * `createManagedIdbClient` — a singleton, race-safe wrapper around any IDB
55
+ * client factory (`createIdbClient`, `createAutoMigratingIdbClient`, or a
56
+ * sync-extension factory like `createAutoMigratingSyncIdbClient` — anything
57
+ * returning a `close(): Promise<void>`-shaped client).
58
+ *
59
+ * Every consumer of this package that wants a module-level singleton client
60
+ * plus a "wipe local data" reset (e.g. on logout) needs the same race-safety:
61
+ * `reset()` must never call `indexedDB.deleteDatabase` while a `get()` open
62
+ * is still in flight, since a still-opening connection would block (or worse,
63
+ * leave a stale handle once that open resolves after the delete). This was
64
+ * previously hand-rolled per app with diverging correctness; see ADR-less
65
+ * discussion in the kanban example's `db.ts` history.
66
+ */
67
+ interface ManagedIdbClientOptions {
68
+ /** IDB database name — passed to `indexedDB.deleteDatabase` on `reset()`. */
69
+ readonly dbName: string;
70
+ /** IDB factory override — primarily for tests. Defaults to `indexedDB`. */
71
+ readonly idbFactory?: IDBFactory;
72
+ }
73
+ interface ManagedIdbClient<TClient> {
74
+ /** Opens the client on first call and caches it; concurrent calls share one open. */
75
+ get(): Promise<TClient>;
76
+ /** Closes the cached client, if any. Safe to call when nothing is open. */
77
+ close(): Promise<void>;
78
+ /**
79
+ * Closes and deletes the database — waits out any `get()` open already in
80
+ * flight first. `onblocked` (another tab still has the DB open) is NOT
81
+ * terminal — per spec, the delete request stays pending, and still fires
82
+ * `onsuccess` once every blocking connection closes — so this promise
83
+ * stays pending through it too, settling only once `deleteDatabase`
84
+ * actually reaches `onsuccess` or `onerror`. Neither resolving early
85
+ * (claims success before the old data is actually gone) nor rejecting
86
+ * early (reports failure on a delete that may still succeed) would be
87
+ * accurate.
88
+ */
89
+ reset(): Promise<void>;
90
+ }
91
+ /**
92
+ * Wraps `open` (a client factory, e.g. `() => createAutoMigratingIdbClient({...})`)
93
+ * with a module-scoped singleton: `get()` opens once and caches the result,
94
+ * `close()` releases it, `reset()` closes and wipes the underlying database.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { createManagedIdbClient } from '@prisma-idb/client-idb/client';
99
+ *
100
+ * const db = createManagedIdbClient(
101
+ * () => createAutoMigratingIdbClient({ contractSpace, dbName: 'my-app' }),
102
+ * { dbName: 'my-app' }
103
+ * );
104
+ *
105
+ * const client = await db.get();
106
+ * // ... on logout:
107
+ * await db.reset();
108
+ * ```
109
+ */
110
+ declare function createManagedIdbClient<TClient extends {
111
+ close(): Promise<void>;
112
+ }>(open: () => Promise<TClient>, options: ManagedIdbClientOptions): ManagedIdbClient<TClient>;
113
+ //#endregion
114
+ export { IdbClientOptions as a, IdbClient as i, ManagedIdbClientOptions as n, createIdbClient as o, createManagedIdbClient as r, ManagedIdbClient as t };
115
+ //# sourceMappingURL=managed-client-kdyHm72t.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-client-kdyHm72t.d.mts","names":[],"sources":["../src/core/idb-client.ts","../src/core/managed-client.ts"],"mappings":";;;;UAWiB,iBAAiB,kBAAkB;WACzC,UAAU;WACV;;WAGA,UAAU;WACV,sBAAsB;;UAGhB,UAAU,kBAAkB;WAClC,KAAK,aAAa;;;;;;;;;;;EAW3B,gBAAgB,GAAG,sBAAsB,KAAK,OAAO,wBAAwB,QAAQ,KAAK,QAAQ;EAClG,gBAAgB;EAChB,SAAS;GACR,OAAO,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;iBAwBX,gBAAgB,kBAAkB,aAChD,SAAS,iBAAiB,aACzB,UAAU;;;;;;;;;;;;;;;;;UC9CI;;WAEN;;WAEA,aAAa;;UAGP,iBAAiB;;EAEhC,OAAO,QAAQ;;EAEf,SAAS;;;;;;;;;;;;EAYT,SAAS;;;;;;;;;;;;;;;;;;;;;iBAsBK,uBAAuB;EAAkB,SAAS;GAChE,YAAY,QAAQ,UACpB,SAAS,0BACR,iBAAiB"}
package/dist/orm.d.mts ADDED
@@ -0,0 +1,85 @@
1
+ import { A as MutationUpdateInput, B as SelectedRow, C as IncludeFields, D as KeyType, E as IncludedRow, F as ReferenceRelKeys, H as WhereFilter, I as RelatedModelOf, L as RelationMutationConnect, M as NumericFieldNames, N as OrderBySpec, O as ModelKeyPath, P as PatchInput, R as RelationMutationCreate, S as IdbRelationMutator, T as IncludeSpec, U as getKeyPath, V as SortDirection, W as getStoreName, _ as IdbAggregateResult, a as IdbStoreAccessor, b as IdbContract, c as IdbGroupedAccessor, d as IdbModelAccessor, f as IdbQueryExecutor, g as IdbAggregateBuilder, h as DefaultModelRow, i as IdbIncludeRefinementAccessor, j as NoIncludes, k as MutationCreateInput, l as IdbIncludeScalar, m as CreateInput, n as IdbOrmOptions, o as WhereCallback, p as AggregateFn, r as idbOrm, s as GroupedResultRow, t as IdbOrmClient, u as IdbFieldAccessor, v as IdbAggregateSelector, w as IncludeMarker, x as IdbRelationMutation, y as IdbAggregateSpec, z as RelationMutationDisconnect } from "./idb-orm-zCRkkD_D.mjs";
2
+ import { IdbAndExpr, IdbAndExpr as IdbAndExpr$1, IdbFieldFilter, IdbFilterExpr, IdbFilterExpr as IdbFilterExpr$1, IdbFilterOp, IdbNotExpr, IdbNotExpr as IdbNotExpr$1, IdbNullCheckExpr, IdbOrExpr, IdbOrExpr as IdbOrExpr$1 } from "@prisma-idb/adapter-idb/runtime";
3
+ import { IdbTransactionScope } from "@prisma-idb/driver-idb/runtime";
4
+ //#region src/core/filters.d.ts
5
+ /** Variadic AND. `and()` (no args) is vacuously true. */
6
+ declare function and(...exprs: ReadonlyArray<IdbFilterExpr$1>): IdbAndExpr$1;
7
+ /** Variadic OR. `or()` (no args) is vacuously false. */
8
+ declare function or(...exprs: ReadonlyArray<IdbFilterExpr$1>): IdbOrExpr$1;
9
+ /** Logical NOT. */
10
+ declare function not(expr: IdbFilterExpr$1): IdbNotExpr$1;
11
+ //#endregion
12
+ //#region src/core/mutation-scope.d.ts
13
+ /**
14
+ * Extends the basic {@link IdbQueryExecutor} with multi-store transaction
15
+ * support. `IdbRuntime` satisfies this interface — `runtime.transaction()`
16
+ * delegates to `driver.transaction()` which opens the IDB transaction.
17
+ */
18
+ interface IdbQueryExecutorWithTransaction extends IdbQueryExecutor {
19
+ /**
20
+ * Open a multi-store IDB transaction and return a scope object.
21
+ *
22
+ * The returned scope's `execute()` runs `IdbAtomicPlan`s directly inside
23
+ * the transaction — no new transaction is opened per call, and the
24
+ * middleware chain is bypassed. `commit()` resolves when `tx.oncomplete`
25
+ * fires; `rollback()` calls `tx.abort()`.
26
+ */
27
+ transaction(storeNames: string[], mode?: IDBTransactionMode): Promise<IdbTransactionScope>;
28
+ }
29
+ /**
30
+ * Run a callback inside a single multi-store IDB readwrite transaction.
31
+ *
32
+ * Opens the transaction, passes the `IdbTransactionScope` to `run`, then:
33
+ * - On success: awaits `scope.commit()` (waits for `tx.oncomplete`).
34
+ * - On error: calls `scope.rollback()` and rethrows.
35
+ *
36
+ * The callback receives the low-level scope, not the ORM accessor.
37
+ * Use this for multi-store atomic writes that span several object stores.
38
+ */
39
+ declare function withMutationScope<T>(executor: IdbQueryExecutorWithTransaction, storeNames: string[], run: (scope: IdbTransactionScope) => Promise<T>): Promise<T>;
40
+ //#endregion
41
+ //#region src/core/relation-mutator.d.ts
42
+ declare function createRelationMutator<TContract extends IdbContract, ModelName extends string>(): IdbRelationMutator<TContract, ModelName>;
43
+ declare function isRelationMutationDescriptor(value: unknown): value is IdbRelationMutation<IdbContract, string>;
44
+ declare function isRelationMutationCallback(value: unknown): value is (mutator: IdbRelationMutator<IdbContract, string>) => IdbRelationMutation<IdbContract, string>;
45
+ //#endregion
46
+ //#region src/core/mutation-executor.d.ts
47
+ /**
48
+ * Returns true if `data` contains at least one field that is both a known
49
+ * relation name for `modelName` and a function (a mutation callback).
50
+ */
51
+ declare function hasNestedMutationCallbacks(contract: IdbContract, modelName: string, data: Record<string, unknown>): boolean;
52
+ /**
53
+ * Transitively walks the `onDelete` cascade graph from `modelName`, collecting
54
+ * every store a recursive delete might touch. `cascade` edges are walked
55
+ * further (a cascaded child's own children may themselves cascade);
56
+ * `restrict`/`setNull`/`setDefault` edges still need their store added (each
57
+ * is read or written once) but don't recurse further, since none of them
58
+ * delete the child row. Guarded by a model-level visited set — required
59
+ * because IDB must declare every store a transaction might touch before it
60
+ * opens, so this static walk must terminate even on a self-referential model
61
+ * or a cycle of mutually-cascading models.
62
+ */
63
+ declare function collectDeleteStoreNames(contract: IdbContract, modelName: string): string[];
64
+ /**
65
+ * Enforces every `onDelete` action declared on `modelName`'s child relations
66
+ * against one specific `row` about to be deleted. `cascade` recurses into
67
+ * each matched child's own `onDelete` relations *before* deleting it — so a
68
+ * multi-hop chain (`User --cascade--> Post --cascade--> Comment`) is fully
69
+ * torn down, and a `restrict` several hops deep still aborts the whole
70
+ * transaction (recursing before deleting means the delete never happens if a
71
+ * deeper hop throws). `setNull`/`setDefault` are leaf actions: the child row
72
+ * survives, so recursion never continues past them.
73
+ *
74
+ * `visited` (keyed by `storeName::key`) guards against row-level cycles — two
75
+ * specific rows whose FKs point at each other through a self-referential or
76
+ * mutually-cascading relation graph. Callers should leave it at its default
77
+ * (a fresh `Set` per top-level call) so independent rows deleted in the same
78
+ * `deleteAll()` batch don't cross-suppress each other's cascades; it's only
79
+ * ever passed explicitly by this function's own recursive calls, to keep one
80
+ * shared guard across a single row's full recursive descent.
81
+ */
82
+ declare function applyReferentialActionsForRow(scope: IdbTransactionScope, contract: IdbContract, modelName: string, row: Record<string, unknown>, visited?: Set<string>): Promise<void>;
83
+ //#endregion
84
+ export { type AggregateFn, type CreateInput, type DefaultModelRow, type GroupedResultRow, type IdbAggregateBuilder, type IdbAggregateResult, type IdbAggregateSelector, type IdbAggregateSpec, type IdbAndExpr, type IdbContract, type IdbFieldAccessor, type IdbFieldFilter, type IdbFilterExpr, type IdbFilterOp, type IdbGroupedAccessor, type IdbIncludeRefinementAccessor, type IdbIncludeScalar, type IdbModelAccessor, type IdbNotExpr, type IdbNullCheckExpr, type IdbOrExpr, type IdbOrmClient, type IdbOrmOptions, type IdbQueryExecutor, type IdbQueryExecutorWithTransaction, type IdbRelationMutation, type IdbRelationMutator, type IdbStoreAccessor, type IncludeFields, type IncludeMarker, type IncludeSpec, type IncludedRow, type KeyType, type ModelKeyPath, type MutationCreateInput, type MutationUpdateInput, type NoIncludes, type NumericFieldNames, type OrderBySpec, type PatchInput, type ReferenceRelKeys, type RelatedModelOf, type RelationMutationConnect, type RelationMutationCreate, type RelationMutationDisconnect, type SelectedRow, type SortDirection, type WhereCallback, type WhereFilter, and, applyReferentialActionsForRow, collectDeleteStoreNames, createRelationMutator, getKeyPath, getStoreName, hasNestedMutationCallbacks, idbOrm, isRelationMutationCallback, isRelationMutationDescriptor, not, or, withMutationScope };
85
+ //# sourceMappingURL=orm.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orm.d.mts","names":[],"sources":["../src/core/filters.ts","../src/core/mutation-scope.ts","../src/core/relation-mutator.ts","../src/core/mutation-executor.ts"],"mappings":";;;;;iBAqBgB,OAAO,OAAO,cAAc,mBAAiB;;iBAK7C,MAAM,OAAO,cAAc,mBAAiB;;iBAK5C,IAAI,MAAM,kBAAgB;;;;;;;;UCFzB,wCAAwC;;;;;;;;;EASvD,YAAY,sBAAsB,OAAO,qBAAqB,QAAQ;;;;;;;;;;;;iBAelD,kBAAkB,GACtC,UAAU,iCACV,sBACA,MAAM,OAAO,wBAAwB,QAAQ,KAC5C,QAAQ;;;iBC/BK,sBAAsB,kBAAkB,aAAa,6BAA6B,mBAChG,WACA;iBAsBc,6BAA6B,iBAAiB,SAAS,oBAAoB;iBAM3E,2BACd,iBACC,UAAU,SAAS,mBAAmB,yBAAyB,oBAAoB;;;;;;;iBC0EtE,2BACd,UAAU,aACV,mBACA,MAAM;;;;;;;;;;;;iBAymCQ,wBAAwB,UAAU,aAAa;;;;;;;;;;;;;;;;;;;iBAuCzC,8BACpB,OAAO,qBACP,UAAU,aACV,mBACA,KAAK,yBACL,UAAS,cACR"}
package/dist/orm.mjs ADDED
@@ -0,0 +1,28 @@
1
+ import { a as createRelationMutator, c as withMutationScope, i as hasNestedMutationCallbacks, l as getKeyPath, n as applyReferentialActionsForRow, o as isRelationMutationCallback, r as collectDeleteStoreNames, s as isRelationMutationDescriptor, t as idbOrm, u as getStoreName } from "./idb-orm-Cupnnwum.mjs";
2
+ import { andExpr, notExpr, orExpr } from "@prisma-idb/adapter-idb/runtime";
3
+ //#region src/core/filters.ts
4
+ /**
5
+ * User-facing logical combinators for the IDB ORM.
6
+ *
7
+ * `and(a, b, ...)`, `or(a, b, ...)`, `not(e)` — thin wrappers over the
8
+ * frozen factory helpers in `adapter-idb` that exist so callers don't
9
+ * have to import from the adapter package directly. Mirrors the
10
+ * `where { AND, OR, NOT }` shape Prisma users are already familiar with,
11
+ * exposed as plain functions to keep the AST construction explicit.
12
+ */
13
+ /** Variadic AND. `and()` (no args) is vacuously true. */
14
+ function and(...exprs) {
15
+ return andExpr(exprs);
16
+ }
17
+ /** Variadic OR. `or()` (no args) is vacuously false. */
18
+ function or(...exprs) {
19
+ return orExpr(exprs);
20
+ }
21
+ /** Logical NOT. */
22
+ function not(expr) {
23
+ return notExpr(expr);
24
+ }
25
+ //#endregion
26
+ export { and, applyReferentialActionsForRow, collectDeleteStoreNames, createRelationMutator, getKeyPath, getStoreName, hasNestedMutationCallbacks, idbOrm, isRelationMutationCallback, isRelationMutationDescriptor, not, or, withMutationScope };
27
+
28
+ //# sourceMappingURL=orm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orm.mjs","names":[],"sources":["../src/core/filters.ts"],"sourcesContent":["/**\n * User-facing logical combinators for the IDB ORM.\n *\n * `and(a, b, ...)`, `or(a, b, ...)`, `not(e)` — thin wrappers over the\n * frozen factory helpers in `adapter-idb` that exist so callers don't\n * have to import from the adapter package directly. Mirrors the\n * `where { AND, OR, NOT }` shape Prisma users are already familiar with,\n * exposed as plain functions to keep the AST construction explicit.\n */\n\nimport {\n andExpr,\n notExpr,\n orExpr,\n type IdbAndExpr,\n type IdbFilterExpr,\n type IdbNotExpr,\n type IdbOrExpr,\n} from \"@prisma-idb/adapter-idb/runtime\";\n\n/** Variadic AND. `and()` (no args) is vacuously true. */\nexport function and(...exprs: ReadonlyArray<IdbFilterExpr>): IdbAndExpr {\n return andExpr(exprs);\n}\n\n/** Variadic OR. `or()` (no args) is vacuously false. */\nexport function or(...exprs: ReadonlyArray<IdbFilterExpr>): IdbOrExpr {\n return orExpr(exprs);\n}\n\n/** Logical NOT. */\nexport function not(expr: IdbFilterExpr): IdbNotExpr {\n return notExpr(expr);\n}\n"],"mappings":";;;;;;;;;;;;;AAqBA,SAAgB,IAAI,GAAG,OAAiD;CACtE,OAAO,QAAQ,KAAK;AACtB;;AAGA,SAAgB,GAAG,GAAG,OAAgD;CACpE,OAAO,OAAO,KAAK;AACrB;;AAGA,SAAgB,IAAI,MAAiC;CACnD,OAAO,QAAQ,IAAI;AACrB"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@prisma-idb/client-idb",
3
+ "version": "0.0.0",
4
+ "description": "Prisma 8 IDB family — ORM client (idbOrm typed query builder)",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "keywords": [
10
+ "prisma",
11
+ "prisma-8",
12
+ "indexeddb",
13
+ "offline-first",
14
+ "idb",
15
+ "orm"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/prisma-idb/prisma-idb.git",
20
+ "directory": "packages/prisma-orm/client-idb"
21
+ },
22
+ "homepage": "https://prisma-idb.dev/",
23
+ "bugs": {
24
+ "url": "https://github.com/prisma-idb/prisma-idb/issues"
25
+ },
26
+ "type": "module",
27
+ "exports": {
28
+ "./orm": "./dist/orm.mjs",
29
+ "./client": "./dist/client.mjs",
30
+ "./client-auto": "./dist/client-auto.mjs",
31
+ "./package.json": "./package.json"
32
+ },
33
+ "dependencies": {
34
+ "@prisma/orm-framework": "8.0.0-rc.5",
35
+ "@prisma-idb/adapter-idb": "0.0.0",
36
+ "@prisma-idb/runtime-idb": "0.0.0",
37
+ "@prisma-idb/target-idb": "0.0.0",
38
+ "@prisma-idb/driver-idb": "0.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@prisma/cli-engine": "0.2.0",
42
+ "@prisma/orm-toolchain": "8.0.0-rc.5",
43
+ "fake-indexeddb": "^6.2.5",
44
+ "tsdown": "^0.22.14",
45
+ "typescript": "^6.0.3",
46
+ "vitest": "^4.1.10",
47
+ "@prisma-idb/family-idb": "0.0.0"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "scripts": {
53
+ "build": "tsdown",
54
+ "dev": "tsdown --watch",
55
+ "check": "tsc --noEmit",
56
+ "test": "vitest run",
57
+ "lint": "prettier --check . && eslint .",
58
+ "format": "prettier --write ."
59
+ }
60
+ }