@mikara89/cap-storage-prisma 2.2.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +108 -0
  3. package/dist/index.d.ts +8 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +24 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/prisma-cap-client.d.ts +14 -0
  8. package/dist/prisma-cap-client.d.ts.map +1 -0
  9. package/dist/prisma-cap-client.js +3 -0
  10. package/dist/prisma-cap-client.js.map +1 -0
  11. package/dist/prisma-cap-schema.d.ts +6 -0
  12. package/dist/prisma-cap-schema.d.ts.map +1 -0
  13. package/dist/prisma-cap-schema.js +96 -0
  14. package/dist/prisma-cap-schema.js.map +1 -0
  15. package/dist/prisma-publish-storage.d.ts +24 -0
  16. package/dist/prisma-publish-storage.d.ts.map +1 -0
  17. package/dist/prisma-publish-storage.js +187 -0
  18. package/dist/prisma-publish-storage.js.map +1 -0
  19. package/dist/prisma-received-storage.d.ts +22 -0
  20. package/dist/prisma-received-storage.d.ts.map +1 -0
  21. package/dist/prisma-received-storage.js +185 -0
  22. package/dist/prisma-received-storage.js.map +1 -0
  23. package/dist/prisma-storage-capabilities.d.ts +4 -0
  24. package/dist/prisma-storage-capabilities.d.ts.map +1 -0
  25. package/dist/prisma-storage-capabilities.js +23 -0
  26. package/dist/prisma-storage-capabilities.js.map +1 -0
  27. package/dist/prisma-storage-options.d.ts +20 -0
  28. package/dist/prisma-storage-options.d.ts.map +1 -0
  29. package/dist/prisma-storage-options.js +36 -0
  30. package/dist/prisma-storage-options.js.map +1 -0
  31. package/dist/prisma-storage-utils.d.ts +24 -0
  32. package/dist/prisma-storage-utils.d.ts.map +1 -0
  33. package/dist/prisma-storage-utils.js +89 -0
  34. package/dist/prisma-storage-utils.js.map +1 -0
  35. package/dist/prisma-transaction-manager.d.ts +17 -0
  36. package/dist/prisma-transaction-manager.d.ts.map +1 -0
  37. package/dist/prisma-transaction-manager.js +81 -0
  38. package/dist/prisma-transaction-manager.js.map +1 -0
  39. package/package.json +55 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## 2.3.0
4
+
5
+ - Release the framework-free Prisma outbox and inbox adapter as a current
6
+ first-party storage option.
7
+ - Use parameterized raw SQL with `Prisma.TransactionClient`, so applications do
8
+ not need CAP models in their Prisma schema.
9
+ - Support PostgreSQL, MySQL/MariaDB, and SQLite schema initialization and pass
10
+ the shared publish- and received-storage contract suites.
11
+ - Cover PostgreSQL and MySQL claim behavior with DB integration tests; keep
12
+ SQLite as a local and single-process option.
13
+ - Keep shared SQL-core extraction deferred.
14
+
15
+ ## 2.2.0
16
+
17
+ - Add the framework-free Prisma publish and received storage adapter.
18
+ - Add raw-SQL schema initialization for PostgreSQL, MySQL/MariaDB, and SQLite.
19
+ - Add interactive transaction support through `Prisma.TransactionClient`.
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # @mikara89/cap-storage-prisma
2
+
3
+ Framework-free Prisma storage adapter for CAP outbox and inbox persistence.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @mikara89/cap-storage-prisma @prisma/client
9
+ ```
10
+
11
+ Use the generated Prisma Client from your application. The adapter supports
12
+ Prisma providers `postgresql`, `mysql`, and `sqlite`; `postgres` and `mariadb`
13
+ are accepted adapter aliases. Pass the provider explicitly because Prisma does
14
+ not expose a stable public runtime provider API for adapter logic.
15
+
16
+ ## Schema
17
+
18
+ Initialize CAP tables through raw SQL without adding CAP models to your Prisma
19
+ schema:
20
+
21
+ ```ts
22
+ import { initializePrismaCapStorage } from '@mikara89/cap-storage-prisma';
23
+
24
+ await initializePrismaCapStorage(prisma, { provider: 'postgresql' });
25
+ ```
26
+
27
+ Custom table names are supported and validated as SQL identifiers:
28
+
29
+ ```ts
30
+ await initializePrismaCapStorage(prisma, {
31
+ provider: 'postgresql',
32
+ publishTableName: 'cap_publish',
33
+ receivedTableName: 'cap_received',
34
+ });
35
+ ```
36
+
37
+ The helper creates outbox and inbox tables, scheduler indexes, and the unique
38
+ inbox constraint on `group + dedupeKey`. Applications may instead manage
39
+ equivalent tables with their own migrations. Prisma Migrate is not required
40
+ for CAP-owned tables.
41
+
42
+ ## Usage
43
+
44
+ ```ts
45
+ import {
46
+ PrismaPublishStorage,
47
+ PrismaReceivedStorage,
48
+ } from '@mikara89/cap-storage-prisma';
49
+
50
+ const options = { provider: 'postgresql' as const };
51
+ const publishStorage = new PrismaPublishStorage(prisma, options);
52
+ const receivedStorage = new PrismaReceivedStorage(prisma, options);
53
+ ```
54
+
55
+ The adapter uses `$executeRawUnsafe` and `$queryRawUnsafe` with parameterized
56
+ values. It does not use generated model delegates or require CAP models in the
57
+ application schema. Table names are the only dynamic identifiers and are
58
+ strictly validated before quoting.
59
+
60
+ ## Transactions
61
+
62
+ The transaction context is `Prisma.TransactionClient`. Root operations use the
63
+ application's root `PrismaClient`.
64
+
65
+ ```ts
66
+ await prisma.$transaction(async (tx) => {
67
+ await cap.publish('topic', payload, { tx });
68
+ });
69
+ ```
70
+
71
+ An explicit operation context is also supported:
72
+
73
+ ```ts
74
+ await prisma.$transaction(async (tx) => {
75
+ await cap.publish('topic', payload, { ctx: { tx } });
76
+ });
77
+ ```
78
+
79
+ `PrismaTransactionManager` implements
80
+ `CapTransactionManagerPort<Prisma.TransactionClient>`. It maps `timeoutMs` to
81
+ Prisma's interactive transaction timeout and accepts documented Prisma
82
+ isolation names that the selected provider supports. `afterCommit` callbacks
83
+ run after `$transaction` resolves; `afterRollback` callbacks run after it
84
+ rejects. CAP `propagation` and `readOnly` options are currently informational.
85
+
86
+ `savePublishWithTx(event, tx)` remains as deprecated compatibility only. Use
87
+ `savePublish(event, { tx })` through CAP publish options.
88
+
89
+ ## Capabilities
90
+
91
+ Both storage classes implement `CapabilityAwareStoragePort`:
92
+
93
+ - transactions and provider-supported Prisma isolation levels are reported
94
+ - PostgreSQL and MySQL/MariaDB report skip-locked claiming because the adapter
95
+ uses `FOR UPDATE SKIP LOCKED`
96
+ - SQLite reports no safe multi-instance claiming
97
+ - inbox dedupe reports atomic insert-ignore for every supported provider
98
+ - advisory locks and nested transactions are not reported
99
+
100
+ SQLite is intended for local development and tests. Its claiming fallback is
101
+ transactional but is not safe for multi-instance durable dispatch.
102
+
103
+ ## Contract And Database Tests
104
+
105
+ The package runs `definePublishStorageContract` and
106
+ `defineReceivedStorageContract` against SQLite. PostgreSQL and MySQL
107
+ Testcontainers coverage verifies real skip-locked claiming, concurrent inbox
108
+ dedupe, and interactive transaction rollback.
@@ -0,0 +1,8 @@
1
+ export * from './prisma-cap-client';
2
+ export * from './prisma-cap-schema';
3
+ export * from './prisma-publish-storage';
4
+ export * from './prisma-received-storage';
5
+ export * from './prisma-storage-capabilities';
6
+ export * from './prisma-storage-options';
7
+ export * from './prisma-transaction-manager';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./prisma-cap-client"), exports);
18
+ __exportStar(require("./prisma-cap-schema"), exports);
19
+ __exportStar(require("./prisma-publish-storage"), exports);
20
+ __exportStar(require("./prisma-received-storage"), exports);
21
+ __exportStar(require("./prisma-storage-capabilities"), exports);
22
+ __exportStar(require("./prisma-storage-options"), exports);
23
+ __exportStar(require("./prisma-transaction-manager"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,sDAAoC;AACpC,2DAAyC;AACzC,4DAA0C;AAC1C,gEAA8C;AAC9C,2DAAyC;AACzC,+DAA6C"}
@@ -0,0 +1,14 @@
1
+ import type { Prisma } from '@prisma/client';
2
+ export interface PrismaCapExecutor {
3
+ $executeRawUnsafe(query: string, ...values: unknown[]): Promise<number>;
4
+ $queryRawUnsafe<T = unknown>(query: string, ...values: unknown[]): Promise<T>;
5
+ }
6
+ export interface PrismaCapTransactionOptions {
7
+ isolationLevel?: Prisma.TransactionIsolationLevel;
8
+ maxWait?: number;
9
+ timeout?: number;
10
+ }
11
+ export interface PrismaCapClient extends PrismaCapExecutor {
12
+ $transaction<T>(fn: (tx: Prisma.TransactionClient) => Promise<T>, options?: PrismaCapTransactionOptions): Promise<T>;
13
+ }
14
+ //# sourceMappingURL=prisma-cap-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-cap-client.d.ts","sourceRoot":"","sources":["../src/prisma-cap-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExE,eAAe,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC/E;AAED,MAAM,WAAW,2BAA2B;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,yBAAyB,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,YAAY,CAAC,CAAC,EACZ,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EAChD,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,CAAC,CAAC,CAAC;CACf"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=prisma-cap-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-cap-client.js","sourceRoot":"","sources":["../src/prisma-cap-client.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { PrismaCapExecutor } from './prisma-cap-client';
2
+ import { type PrismaStorageOptions } from './prisma-storage-options';
3
+ export type InitializePrismaCapStorageOptions = PrismaStorageOptions;
4
+ export declare function initializePrismaCapStorage(client: PrismaCapExecutor, options: InitializePrismaCapStorageOptions): Promise<void>;
5
+ export declare const createPrismaCapSchema: typeof initializePrismaCapStorage;
6
+ //# sourceMappingURL=prisma-cap-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-cap-schema.d.ts","sourceRoot":"","sources":["../src/prisma-cap-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,0BAA0B,CAAC;AAOlC,MAAM,MAAM,iCAAiC,GAAG,oBAAoB,CAAC;AAErE,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,eAAO,MAAM,qBAAqB,mCAA6B,CAAC"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPrismaCapSchema = void 0;
4
+ exports.initializePrismaCapStorage = initializePrismaCapStorage;
5
+ const prisma_storage_options_1 = require("./prisma-storage-options");
6
+ const prisma_storage_utils_1 = require("./prisma-storage-utils");
7
+ async function initializePrismaCapStorage(client, options) {
8
+ const resolved = (0, prisma_storage_options_1.resolvePrismaStorageOptions)(options);
9
+ await (0, prisma_storage_utils_1.executePrismaSql)(client, publishTableSql(resolved));
10
+ await (0, prisma_storage_utils_1.executePrismaSql)(client, receivedTableSql(resolved));
11
+ await createIndexes(client, resolved);
12
+ }
13
+ exports.createPrismaCapSchema = initializePrismaCapStorage;
14
+ function publishTableSql(options) {
15
+ const q = (identifier) => (0, prisma_storage_utils_1.quotePrismaIdentifier)(options.provider, identifier);
16
+ return `CREATE TABLE IF NOT EXISTS ${q(options.publishTableName)} (
17
+ ${q('id')} VARCHAR(128) PRIMARY KEY,
18
+ ${q('topic')} VARCHAR(255) NOT NULL,
19
+ ${q('payload')} TEXT NOT NULL,
20
+ ${q('headers')} TEXT NULL,
21
+ ${q('retry_count')} INTEGER NOT NULL DEFAULT 0,
22
+ ${q('status')} VARCHAR(32) NOT NULL,
23
+ ${q('next_retry_at')} VARCHAR(64) NULL,
24
+ ${q('last_error')} TEXT NULL,
25
+ ${q('locked_by')} VARCHAR(255) NULL,
26
+ ${q('locked_until')} VARCHAR(64) NULL,
27
+ ${q('published_at')} VARCHAR(64) NULL,
28
+ ${q('created_at')} VARCHAR(64) NOT NULL,
29
+ ${q('updated_at')} VARCHAR(64) NOT NULL
30
+ )`;
31
+ }
32
+ function receivedTableSql(options) {
33
+ const q = (identifier) => (0, prisma_storage_utils_1.quotePrismaIdentifier)(options.provider, identifier);
34
+ return `CREATE TABLE IF NOT EXISTS ${q(options.receivedTableName)} (
35
+ ${q('id')} VARCHAR(128) PRIMARY KEY,
36
+ ${q('topic')} VARCHAR(255) NOT NULL,
37
+ ${q('group')} VARCHAR(255) NOT NULL,
38
+ ${q('message_id')} VARCHAR(255) NOT NULL,
39
+ ${q('dedupe_key')} VARCHAR(512) NOT NULL,
40
+ ${q('payload')} TEXT NOT NULL,
41
+ ${q('headers')} TEXT NULL,
42
+ ${q('processed')} INTEGER NOT NULL DEFAULT 0,
43
+ ${q('retry_count')} INTEGER NOT NULL DEFAULT 0,
44
+ ${q('status')} VARCHAR(32) NOT NULL,
45
+ ${q('last_error')} TEXT NULL,
46
+ ${q('next_retry')} VARCHAR(64) NULL,
47
+ ${q('processed_at')} VARCHAR(64) NULL,
48
+ ${q('created_at')} VARCHAR(64) NOT NULL,
49
+ ${q('updated_at')} VARCHAR(64) NOT NULL,
50
+ UNIQUE (${q('group')}, ${q('dedupe_key')})
51
+ )`;
52
+ }
53
+ async function createIndexes(client, options) {
54
+ const indexes = [
55
+ {
56
+ name: `${options.publishTableName}_status_retry_idx`,
57
+ table: options.publishTableName,
58
+ columns: ['status', 'next_retry_at'],
59
+ },
60
+ {
61
+ name: `${options.publishTableName}_status_lock_idx`,
62
+ table: options.publishTableName,
63
+ columns: ['status', 'locked_until'],
64
+ },
65
+ {
66
+ name: `${options.publishTableName}_topic_idx`,
67
+ table: options.publishTableName,
68
+ columns: ['topic'],
69
+ },
70
+ {
71
+ name: `${options.receivedTableName}_status_retry_idx`,
72
+ table: options.receivedTableName,
73
+ columns: ['status', 'next_retry'],
74
+ },
75
+ {
76
+ name: `${options.receivedTableName}_topic_group_idx`,
77
+ table: options.receivedTableName,
78
+ columns: ['topic', 'group'],
79
+ },
80
+ ];
81
+ for (const index of indexes) {
82
+ if (options.provider === 'mysql') {
83
+ if (await mysqlIndexExists(client, index.table, index.name))
84
+ continue;
85
+ }
86
+ const q = (identifier) => (0, prisma_storage_utils_1.quotePrismaIdentifier)(options.provider, identifier);
87
+ const ifNotExists = options.provider === 'mysql' ? '' : ' IF NOT EXISTS';
88
+ const sql = `CREATE INDEX${ifNotExists} ${q(index.name)} ON ${q(index.table)} (${index.columns.map(q).join(', ')})`;
89
+ await (0, prisma_storage_utils_1.executePrismaSql)(client, sql);
90
+ }
91
+ }
92
+ async function mysqlIndexExists(client, tableName, indexName) {
93
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(client, 'SELECT COUNT(*) AS count FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = ? AND index_name = ?', [tableName, indexName]);
94
+ return Number(rows[0]?.count ?? 0) > 0;
95
+ }
96
+ //# sourceMappingURL=prisma-cap-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-cap-schema.js","sourceRoot":"","sources":["../src/prisma-cap-schema.ts"],"names":[],"mappings":";;;AAcA,gEAQC;AArBD,qEAIkC;AAClC,iEAIgC;AAIzB,KAAK,UAAU,0BAA0B,CAC9C,MAAyB,EACzB,OAA0C;IAE1C,MAAM,QAAQ,GAAG,IAAA,oDAA2B,EAAC,OAAO,CAAC,CAAC;IACtD,MAAM,IAAA,uCAAgB,EAAC,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1D,MAAM,IAAA,uCAAgB,EAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,MAAM,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAEY,QAAA,qBAAqB,GAAG,0BAA0B,CAAC;AAEhE,SAAS,eAAe,CAAC,OAAqC;IAC5D,MAAM,CAAC,GAAG,CAAC,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tD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;QACzE,MAAM,GAAG,GAAG,eAAe,WAAW,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAC7D,KAAK,CAAC,KAAK,CACZ,KAAK,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACzC,MAAM,IAAA,uCAAgB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,MAAyB,EACzB,SAAiB,EACjB,SAAiB;IAEjB,MAAM,IAAI,GAAG,MAAM,IAAA,qCAAc,EAC/B,MAAM,EACN,mIAAmI,EACnI,CAAC,SAAS,EAAE,SAAS,CAAC,CACvB,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Prisma } from '@prisma/client';
2
+ import type { CapOperationContext, CapabilityAwareStoragePort, CapPublishEvent, CapStorageCapabilities, ClaimUnpublishedOptions, DashboardListOptions, DashboardListResult, InitOptions, JsonValue, MarkPublishFailedOptions, PublishStoragePort } from '@mikara89/cap-core';
3
+ import type { PrismaCapClient } from './prisma-cap-client';
4
+ import { type PrismaStorageOptions } from './prisma-storage-options';
5
+ export declare class PrismaPublishStorage implements PublishStoragePort<Prisma.TransactionClient>, CapabilityAwareStoragePort {
6
+ private readonly client;
7
+ private readonly options;
8
+ constructor(client: PrismaCapClient, options: PrismaStorageOptions);
9
+ initialize(options?: InitOptions): Promise<void>;
10
+ savePublish<T extends JsonValue = JsonValue>(event: CapPublishEvent<T>, ctx?: CapOperationContext<Prisma.TransactionClient>): Promise<string>;
11
+ savePublishWithTx<T extends JsonValue = JsonValue>(event: CapPublishEvent<T>, tx: Prisma.TransactionClient): Promise<string>;
12
+ getCapabilities(): CapStorageCapabilities;
13
+ claimUnpublished(options: ClaimUnpublishedOptions): Promise<CapPublishEvent<JsonValue>[]>;
14
+ markPublished(id: string, publishedAt?: Date): Promise<void>;
15
+ markPublishFailed(id: string, error: unknown, options: MarkPublishFailedOptions): Promise<void>;
16
+ releaseExpiredClaims(now: Date): Promise<void>;
17
+ findPublishById(id: string): Promise<CapPublishEvent<JsonValue> | undefined>;
18
+ listPublish(options?: DashboardListOptions): Promise<DashboardListResult<CapPublishEvent<JsonValue>>>;
19
+ private findPublishRowById;
20
+ private publishListFilters;
21
+ private quote;
22
+ private column;
23
+ }
24
+ //# sourceMappingURL=prisma-publish-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-publish-storage.d.ts","sourceRoot":"","sources":["../src/prisma-publish-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AAG9E,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,0BAA0B,CAAC;AA+ClC,qBAAa,oBACX,YACE,kBAAkB,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAC5C,0BAA0B;IAK1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;gBAGpC,MAAM,EAAE,eAAe,EACxC,OAAO,EAAE,oBAAoB;IAKzB,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/C,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EACzB,GAAG,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAClD,OAAO,CAAC,MAAM,CAAC;IAeZ,iBAAiB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EACrD,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,MAAM,CAAC,iBAAiB,GAC3B,OAAO,CAAC,MAAM,CAAC;IAIlB,eAAe,IAAI,sBAAsB;IAInC,gBAAgB,CACpB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC;IAiElC,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,OAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBlE,iBAAiB,CACrB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC;IAmCV,oBAAoB,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB9C,eAAe,CACnB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IAK5C,WAAW,CACf,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;YA6B7C,kBAAkB;IAgBhC,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,MAAM;CAGf"}
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrismaPublishStorage = void 0;
4
+ const prisma_cap_schema_1 = require("./prisma-cap-schema");
5
+ const prisma_storage_capabilities_1 = require("./prisma-storage-capabilities");
6
+ const prisma_storage_options_1 = require("./prisma-storage-options");
7
+ const prisma_storage_utils_1 = require("./prisma-storage-utils");
8
+ const publishColumns = [
9
+ 'id',
10
+ 'topic',
11
+ 'payload',
12
+ 'headers',
13
+ 'retry_count',
14
+ 'status',
15
+ 'next_retry_at',
16
+ 'last_error',
17
+ 'locked_by',
18
+ 'locked_until',
19
+ 'published_at',
20
+ 'created_at',
21
+ 'updated_at',
22
+ ];
23
+ class PrismaPublishStorage {
24
+ constructor(client, options) {
25
+ this.client = client;
26
+ this.options = (0, prisma_storage_options_1.resolvePrismaStorageOptions)(options);
27
+ }
28
+ async initialize(options) {
29
+ if (!(options && (options.autoInit || options.createSchema)))
30
+ return;
31
+ await (0, prisma_cap_schema_1.initializePrismaCapStorage)(this.client, this.options);
32
+ }
33
+ async savePublish(event, ctx) {
34
+ const executor = ctx?.tx ?? this.client;
35
+ const insert = (0, prisma_storage_utils_1.prismaInsertSql)(this.options.provider, this.options.publishTableName, publishColumns, mapPublishToValues(event));
36
+ await (0, prisma_storage_utils_1.executePrismaSql)(executor, insert.sql, insert.values);
37
+ return event.id;
38
+ }
39
+ async savePublishWithTx(event, tx) {
40
+ return this.savePublish(event, { tx });
41
+ }
42
+ getCapabilities() {
43
+ return (0, prisma_storage_capabilities_1.getPrismaStorageCapabilities)(this.options.provider);
44
+ }
45
+ async claimUnpublished(options) {
46
+ return this.client.$transaction(async (tx) => {
47
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
48
+ const alias = 'cap_publish_row';
49
+ const status = this.column(alias, 'status');
50
+ const nextRetryAt = this.column(alias, 'next_retry_at');
51
+ const lockedUntil = this.column(alias, 'locked_until');
52
+ const where = [
53
+ `${status} = ${builder.parameter('pending')}`,
54
+ `(${status} = ${builder.parameter('failed')} AND (${nextRetryAt} IS NULL OR ${nextRetryAt} <= ${builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.now))}))`,
55
+ `(${status} = ${builder.parameter('processing')} AND ${lockedUntil} <= ${builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.now))})`,
56
+ ].join(' OR ');
57
+ const limit = builder.parameter(options.limit);
58
+ const lockClause = this.options.provider === 'sqlite' ? '' : ' FOR UPDATE SKIP LOCKED';
59
+ const sql = `SELECT ${this.quote(alias)}.* FROM ${this.quote(this.options.publishTableName)} AS ${this.quote(alias)} WHERE ${where} ORDER BY ${this.column(alias, 'created_at')} ASC LIMIT ${limit}${lockClause}`;
60
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(tx, sql, builder.values);
61
+ if (rows.length === 0)
62
+ return [];
63
+ const update = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
64
+ const lockedBy = update.parameter(options.lockedBy);
65
+ const lockUntil = update.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.lockUntil));
66
+ const updatedAt = update.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.now));
67
+ const ids = rows.map((row) => update.parameter(row.id)).join(', ');
68
+ await (0, prisma_storage_utils_1.executePrismaSql)(tx, `UPDATE ${this.quote(this.options.publishTableName)} SET ${this.quote('status')} = 'processing', ${this.quote('locked_by')} = ${lockedBy}, ${this.quote('locked_until')} = ${lockUntil}, ${this.quote('updated_at')} = ${updatedAt} WHERE ${this.quote('id')} IN (${ids})`, update.values);
69
+ return rows.map((row) => mapPublishRow({
70
+ ...row,
71
+ status: 'processing',
72
+ locked_by: options.lockedBy,
73
+ locked_until: (0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.lockUntil),
74
+ updated_at: (0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.now),
75
+ }));
76
+ });
77
+ }
78
+ async markPublished(id, publishedAt = new Date()) {
79
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
80
+ const published = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(publishedAt));
81
+ const updated = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(new Date()));
82
+ const eventId = builder.parameter(id);
83
+ await (0, prisma_storage_utils_1.executePrismaSql)(this.client, `UPDATE ${this.quote(this.options.publishTableName)} SET ${this.quote('status')} = 'published', ${this.quote('published_at')} = ${published}, ${this.quote('locked_by')} = NULL, ${this.quote('locked_until')} = NULL, ${this.quote('next_retry_at')} = NULL, ${this.quote('updated_at')} = ${updated} WHERE ${this.quote('id')} = ${eventId}`, builder.values);
84
+ }
85
+ async markPublishFailed(id, error, options) {
86
+ const row = await this.findPublishRowById(this.client, id);
87
+ if (!row)
88
+ return;
89
+ const retryCount = Number(row.retry_count) + 1;
90
+ const status = retryCount >= options.maxRetries ? 'dead_letter' : 'failed';
91
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
92
+ const retry = builder.parameter(retryCount);
93
+ const nextRetry = builder.parameter(status === 'dead_letter' ? null : (0, prisma_storage_utils_1.toPrismaDbDate)(options.nextRetryAt));
94
+ const lastError = builder.parameter(error instanceof Error ? error.message : String(error));
95
+ const updated = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.now));
96
+ const eventId = builder.parameter(id);
97
+ await (0, prisma_storage_utils_1.executePrismaSql)(this.client, `UPDATE ${this.quote(this.options.publishTableName)} SET ${this.quote('retry_count')} = ${retry}, ${this.quote('status')} = '${status}', ${this.quote('next_retry_at')} = ${nextRetry}, ${this.quote('last_error')} = ${lastError}, ${this.quote('locked_by')} = NULL, ${this.quote('locked_until')} = NULL, ${this.quote('updated_at')} = ${updated} WHERE ${this.quote('id')} = ${eventId}`, builder.values);
98
+ }
99
+ async releaseExpiredClaims(now) {
100
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
101
+ const updated = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(now));
102
+ const expires = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(now));
103
+ await (0, prisma_storage_utils_1.executePrismaSql)(this.client, `UPDATE ${this.quote(this.options.publishTableName)} SET ${this.quote('status')} = 'failed', ${this.quote('locked_by')} = NULL, ${this.quote('locked_until')} = NULL, ${this.quote('updated_at')} = ${updated} WHERE ${this.quote('status')} = 'processing' AND ${this.quote('locked_until')} <= ${expires}`, builder.values);
104
+ }
105
+ async findPublishById(id) {
106
+ const row = await this.findPublishRowById(this.client, id);
107
+ return row ? mapPublishRow(row) : undefined;
108
+ }
109
+ async listPublish(options = {}) {
110
+ const filters = this.publishListFilters(options);
111
+ const table = this.quote(this.options.publishTableName);
112
+ const countRows = await (0, prisma_storage_utils_1.queryPrismaSql)(this.client, `SELECT COUNT(*) AS ${this.quote('total')} FROM ${table}${filters.where}`, filters.values);
113
+ const pagination = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider, filters.values);
114
+ const limit = pagination.parameter(options.limit ?? 2_147_483_647);
115
+ const offset = pagination.parameter(options.offset ?? 0);
116
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(this.client, `SELECT * FROM ${table}${filters.where} ORDER BY ${this.quote('created_at')} DESC LIMIT ${limit} OFFSET ${offset}`, pagination.values);
117
+ return {
118
+ items: rows.map(mapPublishRow),
119
+ total: Number(countRows[0]?.total ?? 0),
120
+ };
121
+ }
122
+ async findPublishRowById(executor, id) {
123
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
124
+ const eventId = builder.parameter(id);
125
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(executor, `SELECT * FROM ${this.quote(this.options.publishTableName)} WHERE ${this.quote('id')} = ${eventId} LIMIT 1`, builder.values);
126
+ return rows[0];
127
+ }
128
+ publishListFilters(options) {
129
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
130
+ const clauses = [];
131
+ if (options.topic) {
132
+ clauses.push(`${this.quote('topic')} = ${builder.parameter(options.topic)}`);
133
+ }
134
+ if (options.onlyUnpublished) {
135
+ const now = (0, prisma_storage_utils_1.toRequiredPrismaDbDate)(new Date());
136
+ clauses.push(`(${this.quote('status')} = ${builder.parameter('pending')} OR (${this.quote('status')} = ${builder.parameter('failed')} AND (${this.quote('next_retry_at')} IS NULL OR ${this.quote('next_retry_at')} <= ${builder.parameter(now)})) OR (${this.quote('status')} = ${builder.parameter('processing')} AND ${this.quote('locked_until')} <= ${builder.parameter(now)}))`);
137
+ }
138
+ return {
139
+ where: clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '',
140
+ values: builder.values,
141
+ };
142
+ }
143
+ quote(identifier) {
144
+ return (0, prisma_storage_utils_1.quotePrismaIdentifier)(this.options.provider, identifier);
145
+ }
146
+ column(alias, column) {
147
+ return (0, prisma_storage_utils_1.qualifiedPrismaColumn)(this.options.provider, alias, column);
148
+ }
149
+ }
150
+ exports.PrismaPublishStorage = PrismaPublishStorage;
151
+ function mapPublishToValues(event) {
152
+ const now = (0, prisma_storage_utils_1.toRequiredPrismaDbDate)(new Date());
153
+ return [
154
+ event.id,
155
+ event.topic,
156
+ (0, prisma_storage_utils_1.serializePrismaJson)(event.payload) ?? 'null',
157
+ (0, prisma_storage_utils_1.serializePrismaJson)(event.headers),
158
+ event.retryCount,
159
+ event.status,
160
+ (0, prisma_storage_utils_1.toPrismaDbDate)(event.nextRetryAt),
161
+ event.lastError ?? null,
162
+ event.lockedBy ?? null,
163
+ (0, prisma_storage_utils_1.toPrismaDbDate)(event.lockedUntil),
164
+ (0, prisma_storage_utils_1.toPrismaDbDate)(event.publishedAt),
165
+ (0, prisma_storage_utils_1.toPrismaDbDate)(event.occurredAt) ?? now,
166
+ now,
167
+ ];
168
+ }
169
+ function mapPublishRow(row) {
170
+ return {
171
+ id: row.id,
172
+ topic: row.topic,
173
+ occurredAt: row.created_at,
174
+ payload: (0, prisma_storage_utils_1.deserializePrismaJson)(row.payload),
175
+ headers: row.headers === null
176
+ ? undefined
177
+ : (0, prisma_storage_utils_1.deserializePrismaJson)(row.headers),
178
+ retryCount: Number(row.retry_count),
179
+ status: row.status,
180
+ nextRetryAt: (0, prisma_storage_utils_1.fromPrismaDbDate)(row.next_retry_at),
181
+ lastError: row.last_error,
182
+ lockedBy: row.locked_by,
183
+ lockedUntil: (0, prisma_storage_utils_1.fromPrismaDbDate)(row.locked_until),
184
+ publishedAt: (0, prisma_storage_utils_1.fromPrismaDbDate)(row.published_at),
185
+ };
186
+ }
187
+ //# sourceMappingURL=prisma-publish-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-publish-storage.js","sourceRoot":"","sources":["../src/prisma-publish-storage.ts"],"names":[],"mappings":";;;AAeA,2DAAiE;AACjE,+EAA6E;AAC7E,qEAIkC;AAClC,iEAYgC;AAkBhC,MAAM,cAAc,GAAG;IACrB,IAAI;IACJ,OAAO;IACP,SAAS;IACT,SAAS;IACT,aAAa;IACb,QAAQ;IACR,eAAe;IACf,YAAY;IACZ,WAAW;IACX,cAAc;IACd,cAAc;IACd,YAAY;IACZ,YAAY;CACb,CAAC;AAEF,MAAa,oBAAoB;IAO/B,YACmB,MAAuB,EACxC,OAA6B;QADZ,WAAM,GAAN,MAAM,CAAiB;QAGxC,IAAI,CAAC,OAAO,GAAG,IAAA,oDAA2B,EAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAqB;QACpC,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;YAAE,OAAO;QACrE,MAAM,IAAA,8CAA0B,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,WAAW,CACf,KAAyB,EACzB,GAAmD;QAEnD,MAAM,QAAQ,GAAsB,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC;QAC3D,MAAM,MAAM,GAAG,IAAA,sCAAe,EAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,I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AC;QACnC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,WAAW,EAAE,IAAA,uCAAgB,EAAC,GAAG,CAAC,aAAa,CAAC;QAChD,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,WAAW,EAAE,IAAA,uCAAgB,EAAC,GAAG,CAAC,YAAY,CAAC;QAC/C,WAAW,EAAE,IAAA,uCAAgB,EAAC,GAAG,CAAC,YAAY,CAAC;KAChD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { CapabilityAwareStoragePort, CapReceivedEvent, CapStorageCapabilities, DashboardListOptions, DashboardListResult, InitOptions, JsonValue, MarkReceivedFailedOptions, ReceivedStoragePort, TrySaveReceivedResult } from '@mikara89/cap-core';
2
+ import type { PrismaCapClient } from './prisma-cap-client';
3
+ import { type PrismaStorageOptions } from './prisma-storage-options';
4
+ export declare class PrismaReceivedStorage implements ReceivedStoragePort, CapabilityAwareStoragePort {
5
+ private readonly client;
6
+ private readonly options;
7
+ constructor(client: PrismaCapClient, options: PrismaStorageOptions);
8
+ initialize(options?: InitOptions): Promise<void>;
9
+ trySaveReceived<T extends JsonValue = JsonValue>(event: CapReceivedEvent<T>): Promise<TrySaveReceivedResult<T>>;
10
+ private trySaveReceivedWithExecutor;
11
+ getCapabilities(): CapStorageCapabilities;
12
+ markProcessed(id: string, processedAt?: Date): Promise<void>;
13
+ markReceivedFailed(id: string, error: unknown, options: MarkReceivedFailedOptions): Promise<void>;
14
+ getRetryDue(limit: number, now?: Date): Promise<CapReceivedEvent<JsonValue>[]>;
15
+ findReceivedById(id: string): Promise<CapReceivedEvent<JsonValue> | undefined>;
16
+ listReceived(options?: DashboardListOptions): Promise<DashboardListResult<CapReceivedEvent<JsonValue>>>;
17
+ private findReceivedRowById;
18
+ private findByDedupe;
19
+ private receivedListFilters;
20
+ private quote;
21
+ }
22
+ //# sourceMappingURL=prisma-received-storage.d.ts.map
@@ -0,0 +1 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GAAG,SAAS,CAAC;IAK7C,YAAY,CAChB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;YA6B9C,mBAAmB;YAenB,YAAY;IAoB1B,OAAO,CAAC,mBAAmB;IA2B3B,OAAO,CAAC,KAAK;CAGd"}
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrismaReceivedStorage = void 0;
4
+ const prisma_cap_schema_1 = require("./prisma-cap-schema");
5
+ const prisma_storage_capabilities_1 = require("./prisma-storage-capabilities");
6
+ const prisma_storage_options_1 = require("./prisma-storage-options");
7
+ const prisma_storage_utils_1 = require("./prisma-storage-utils");
8
+ const receivedColumns = [
9
+ 'id',
10
+ 'topic',
11
+ 'group',
12
+ 'message_id',
13
+ 'dedupe_key',
14
+ 'payload',
15
+ 'headers',
16
+ 'processed',
17
+ 'retry_count',
18
+ 'status',
19
+ 'last_error',
20
+ 'next_retry',
21
+ 'processed_at',
22
+ 'created_at',
23
+ 'updated_at',
24
+ ];
25
+ class PrismaReceivedStorage {
26
+ constructor(client, options) {
27
+ this.client = client;
28
+ this.options = (0, prisma_storage_options_1.resolvePrismaStorageOptions)(options);
29
+ }
30
+ async initialize(options) {
31
+ if (!(options && (options.autoInit || options.createSchema)))
32
+ return;
33
+ await (0, prisma_cap_schema_1.initializePrismaCapStorage)(this.client, this.options);
34
+ }
35
+ async trySaveReceived(event) {
36
+ if (this.options.provider === 'mysql') {
37
+ return this.client.$transaction(async (tx) => {
38
+ await (0, prisma_storage_utils_1.queryPrismaSql)(tx, 'SELECT LAST_INSERT_ID(0)');
39
+ return this.trySaveReceivedWithExecutor(event, tx, true);
40
+ });
41
+ }
42
+ return this.trySaveReceivedWithExecutor(event, this.client, false);
43
+ }
44
+ async trySaveReceivedWithExecutor(event, executor, readMySqlDuplicateFlag) {
45
+ const insert = (0, prisma_storage_utils_1.prismaInsertSql)(this.options.provider, this.options.receivedTableName, receivedColumns, mapReceivedToValues(event), 'ignoreDedupe');
46
+ let affected = await (0, prisma_storage_utils_1.executePrismaSql)(executor, insert.sql, insert.values);
47
+ if (readMySqlDuplicateFlag) {
48
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(executor, 'SELECT LAST_INSERT_ID() AS duplicate');
49
+ affected = Number(rows[0]?.duplicate ?? 0) === 0 ? 1 : 0;
50
+ }
51
+ if (affected > 0) {
52
+ return { inserted: true, id: event.id, event };
53
+ }
54
+ const existing = await this.findByDedupe(event.group, event.dedupeKey, executor);
55
+ if (!existing) {
56
+ throw new Error(`Prisma received insert was ignored, but no row exists for group "${event.group}" and dedupe key "${event.dedupeKey}".`);
57
+ }
58
+ return {
59
+ inserted: false,
60
+ id: existing.id,
61
+ event: mapReceivedRow(existing),
62
+ };
63
+ }
64
+ getCapabilities() {
65
+ return (0, prisma_storage_capabilities_1.getPrismaStorageCapabilities)(this.options.provider);
66
+ }
67
+ async markProcessed(id, processedAt = new Date()) {
68
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
69
+ const processed = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(processedAt));
70
+ const updated = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(processedAt));
71
+ const eventId = builder.parameter(id);
72
+ await (0, prisma_storage_utils_1.executePrismaSql)(this.client, `UPDATE ${this.quote(this.options.receivedTableName)} SET ${this.quote('status')} = 'processed', ${this.quote('processed')} = 1, ${this.quote('processed_at')} = ${processed}, ${this.quote('next_retry')} = NULL, ${this.quote('updated_at')} = ${updated} WHERE ${this.quote('id')} = ${eventId}`, builder.values);
73
+ }
74
+ async markReceivedFailed(id, error, options) {
75
+ const row = await this.findReceivedRowById(id);
76
+ if (!row)
77
+ return;
78
+ const retryCount = Number(row.retry_count) + 1;
79
+ const status = retryCount >= options.maxRetries ? 'dead_letter' : 'failed';
80
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
81
+ const retry = builder.parameter(retryCount);
82
+ const nextRetry = builder.parameter(status === 'dead_letter' ? null : (0, prisma_storage_utils_1.toPrismaDbDate)(options.nextRetryAt));
83
+ const lastError = builder.parameter(error instanceof Error ? error.message : String(error));
84
+ const updated = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(options.now));
85
+ const eventId = builder.parameter(id);
86
+ await (0, prisma_storage_utils_1.executePrismaSql)(this.client, `UPDATE ${this.quote(this.options.receivedTableName)} SET ${this.quote('retry_count')} = ${retry}, ${this.quote('status')} = '${status}', ${this.quote('next_retry')} = ${nextRetry}, ${this.quote('last_error')} = ${lastError}, ${this.quote('updated_at')} = ${updated} WHERE ${this.quote('id')} = ${eventId}`, builder.values);
87
+ }
88
+ async getRetryDue(limit, now = new Date()) {
89
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
90
+ const due = builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(now));
91
+ const rowLimit = builder.parameter(limit);
92
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(this.client, `SELECT * FROM ${this.quote(this.options.receivedTableName)} WHERE ${this.quote('status')} = 'failed' AND ${this.quote('next_retry')} <= ${due} ORDER BY ${this.quote('next_retry')} ASC LIMIT ${rowLimit}`, builder.values);
93
+ return rows.map(mapReceivedRow);
94
+ }
95
+ async findReceivedById(id) {
96
+ const row = await this.findReceivedRowById(id);
97
+ return row ? mapReceivedRow(row) : undefined;
98
+ }
99
+ async listReceived(options = {}) {
100
+ const filters = this.receivedListFilters(options);
101
+ const table = this.quote(this.options.receivedTableName);
102
+ const countRows = await (0, prisma_storage_utils_1.queryPrismaSql)(this.client, `SELECT COUNT(*) AS ${this.quote('total')} FROM ${table}${filters.where}`, filters.values);
103
+ const pagination = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider, filters.values);
104
+ const limit = pagination.parameter(options.limit ?? 2_147_483_647);
105
+ const offset = pagination.parameter(options.offset ?? 0);
106
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(this.client, `SELECT * FROM ${table}${filters.where} ORDER BY ${this.quote('created_at')} DESC LIMIT ${limit} OFFSET ${offset}`, pagination.values);
107
+ return {
108
+ items: rows.map(mapReceivedRow),
109
+ total: Number(countRows[0]?.total ?? 0),
110
+ };
111
+ }
112
+ async findReceivedRowById(id) {
113
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
114
+ const eventId = builder.parameter(id);
115
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(this.client, `SELECT * FROM ${this.quote(this.options.receivedTableName)} WHERE ${this.quote('id')} = ${eventId} LIMIT 1`, builder.values);
116
+ return rows[0];
117
+ }
118
+ async findByDedupe(group, dedupeKey, executor = this.client) {
119
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
120
+ const eventGroup = builder.parameter(group);
121
+ const key = builder.parameter(dedupeKey);
122
+ const rows = await (0, prisma_storage_utils_1.queryPrismaSql)(executor, `SELECT * FROM ${this.quote(this.options.receivedTableName)} WHERE ${this.quote('group')} = ${eventGroup} AND ${this.quote('dedupe_key')} = ${key} LIMIT 1`, builder.values);
123
+ return rows[0];
124
+ }
125
+ receivedListFilters(options) {
126
+ const builder = new prisma_storage_utils_1.PrismaSqlBuilder(this.options.provider);
127
+ const clauses = [];
128
+ if (options.topic) {
129
+ clauses.push(`${this.quote('topic')} = ${builder.parameter(options.topic)}`);
130
+ }
131
+ if (options.due) {
132
+ clauses.push(`${this.quote('status')} = 'failed'`);
133
+ clauses.push(`${this.quote('next_retry')} <= ${builder.parameter((0, prisma_storage_utils_1.toRequiredPrismaDbDate)(new Date()))}`);
134
+ }
135
+ return {
136
+ where: clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '',
137
+ values: builder.values,
138
+ };
139
+ }
140
+ quote(identifier) {
141
+ return (0, prisma_storage_utils_1.quotePrismaIdentifier)(this.options.provider, identifier);
142
+ }
143
+ }
144
+ exports.PrismaReceivedStorage = PrismaReceivedStorage;
145
+ function mapReceivedToValues(event) {
146
+ const now = (0, prisma_storage_utils_1.toRequiredPrismaDbDate)(new Date());
147
+ return [
148
+ event.id,
149
+ event.topic,
150
+ event.group,
151
+ event.messageId,
152
+ event.dedupeKey,
153
+ (0, prisma_storage_utils_1.serializePrismaJson)(event.payload) ?? 'null',
154
+ (0, prisma_storage_utils_1.serializePrismaJson)(event.headers),
155
+ (0, prisma_storage_utils_1.prismaBoolean)(event.processed),
156
+ event.retryCount,
157
+ event.status,
158
+ event.lastError ?? null,
159
+ (0, prisma_storage_utils_1.toPrismaDbDate)(event.nextRetry),
160
+ (0, prisma_storage_utils_1.toPrismaDbDate)(event.processedAt),
161
+ (0, prisma_storage_utils_1.toPrismaDbDate)(event.occurredAt) ?? now,
162
+ now,
163
+ ];
164
+ }
165
+ function mapReceivedRow(row) {
166
+ return {
167
+ id: row.id,
168
+ topic: row.topic,
169
+ occurredAt: row.created_at,
170
+ group: row.group,
171
+ messageId: row.message_id,
172
+ dedupeKey: row.dedupe_key,
173
+ payload: (0, prisma_storage_utils_1.deserializePrismaJson)(row.payload),
174
+ headers: row.headers === null
175
+ ? undefined
176
+ : (0, prisma_storage_utils_1.deserializePrismaJson)(row.headers),
177
+ processed: Boolean(row.processed),
178
+ retryCount: Number(row.retry_count),
179
+ status: row.status,
180
+ lastError: row.last_error,
181
+ processedAt: (0, prisma_storage_utils_1.fromPrismaDbDate)(row.processed_at),
182
+ nextRetry: (0, prisma_storage_utils_1.fromPrismaDbDate)(row.next_retry),
183
+ };
184
+ }
185
+ //# sourceMappingURL=prisma-received-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-received-storage.js","sourceRoot":"","sources":["../src/prisma-received-storage.ts"],"names":[],"mappings":";;;AAaA,2DAAiE;AACjE,+EAA6E;AAC7E,qEAIkC;AAClC,iEAYgC;AAoBhC,MAAM,eAAe,GAAG;IACtB,IAAI;IACJ,OAAO;IACP,O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ACzB,OAAO,EAAE,IAAA,4CAAqB,EAAC,GAAG,CAAC,OAAO,CAAC;QAC3C,OAAO,EACL,GAAG,CAAC,OAAO,KAAK,IAAI;YAClB,CAAC,CAAC,SAAS;YACX,CAAC,CAAE,IAAA,4CAAqB,EACpB,GAAG,CAAC,OAAO,CAC+B;QAClD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACjC,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC;QACnC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,WAAW,EAAE,IAAA,uCAAgB,EAAC,GAAG,CAAC,YAAY,CAAC;QAC/C,SAAS,EAAE,IAAA,uCAAgB,EAAC,GAAG,CAAC,UAAU,CAAC;KAC5C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CapStorageCapabilities } from '@mikara89/cap-core';
2
+ import type { PrismaStorageProvider } from './prisma-storage-options';
3
+ export declare function getPrismaStorageCapabilities(provider: PrismaStorageProvider): CapStorageCapabilities;
4
+ //# sourceMappingURL=prisma-storage-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-storage-capabilities.d.ts","sourceRoot":"","sources":["../src/prisma-storage-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGtE,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,qBAAqB,GAC9B,sBAAsB,CAmBxB"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrismaStorageCapabilities = getPrismaStorageCapabilities;
4
+ const prisma_storage_options_1 = require("./prisma-storage-options");
5
+ function getPrismaStorageCapabilities(provider) {
6
+ const resolved = (0, prisma_storage_options_1.resolvePrismaStorageProvider)(provider);
7
+ return {
8
+ transactions: true,
9
+ skipLockedClaiming: resolved !== 'sqlite',
10
+ advisoryLocks: false,
11
+ atomicInsertIgnore: true,
12
+ nestedTransactions: false,
13
+ isolationLevels: resolved === 'sqlite'
14
+ ? ['Serializable']
15
+ : [
16
+ 'ReadUncommitted',
17
+ 'ReadCommitted',
18
+ 'RepeatableRead',
19
+ 'Serializable',
20
+ ],
21
+ };
22
+ }
23
+ //# sourceMappingURL=prisma-storage-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-storage-capabilities.js","sourceRoot":"","sources":["../src/prisma-storage-capabilities.ts"],"names":[],"mappings":";;AAIA,oEAqBC;AAvBD,qEAAwE;AAExE,SAAgB,4BAA4B,CAC1C,QAA+B;IAE/B,MAAM,QAAQ,GAAG,IAAA,qDAA4B,EAAC,QAAQ,CAAC,CAAC;IAExD,OAAO;QACL,YAAY,EAAE,IAAI;QAClB,kBAAkB,EAAE,QAAQ,KAAK,QAAQ;QACzC,aAAa,EAAE,KAAK;QACpB,kBAAkB,EAAE,IAAI;QACxB,kBAAkB,EAAE,KAAK;QACzB,eAAe,EACb,QAAQ,KAAK,QAAQ;YACnB,CAAC,CAAC,CAAC,cAAc,CAAC;YAClB,CAAC,CAAC;gBACE,iBAAiB;gBACjB,eAAe;gBACf,gBAAgB;gBAChB,cAAc;aACf;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ export type PrismaStorageProvider = 'postgresql' | 'postgres' | 'mysql' | 'mariadb' | 'sqlite';
2
+ export type ResolvedPrismaStorageProvider = 'postgresql' | 'mysql' | 'sqlite';
3
+ export interface PrismaStorageOptions {
4
+ provider: PrismaStorageProvider;
5
+ publishTableName?: string;
6
+ receivedTableName?: string;
7
+ }
8
+ export interface ResolvedPrismaStorageOptions {
9
+ provider: ResolvedPrismaStorageProvider;
10
+ publishTableName: string;
11
+ receivedTableName: string;
12
+ }
13
+ export declare const defaultPrismaStorageTableNames: {
14
+ readonly publishTableName: "cap_publish";
15
+ readonly receivedTableName: "cap_received";
16
+ };
17
+ export declare function resolvePrismaStorageOptions(options: PrismaStorageOptions): ResolvedPrismaStorageOptions;
18
+ export declare function resolvePrismaStorageProvider(provider: PrismaStorageProvider): ResolvedPrismaStorageProvider;
19
+ export declare function validatePrismaIdentifier(identifier: string, maxLength?: number): string;
20
+ //# sourceMappingURL=prisma-storage-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-storage-options.d.ts","sourceRoot":"","sources":["../src/prisma-storage-options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,YAAY,GACZ,UAAU,GACV,OAAO,GACP,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,MAAM,6BAA6B,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,qBAAqB,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,6BAA6B,CAAC;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,8BAA8B;;;CAGjC,CAAC;AAEX,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,GAC5B,4BAA4B,CAc9B;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,qBAAqB,GAC9B,6BAA6B,CAI/B;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,SAAS,SAAK,GACb,MAAM,CAYR"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultPrismaStorageTableNames = void 0;
4
+ exports.resolvePrismaStorageOptions = resolvePrismaStorageOptions;
5
+ exports.resolvePrismaStorageProvider = resolvePrismaStorageProvider;
6
+ exports.validatePrismaIdentifier = validatePrismaIdentifier;
7
+ exports.defaultPrismaStorageTableNames = {
8
+ publishTableName: 'cap_publish',
9
+ receivedTableName: 'cap_received',
10
+ };
11
+ function resolvePrismaStorageOptions(options) {
12
+ return {
13
+ provider: resolvePrismaStorageProvider(options.provider),
14
+ publishTableName: validatePrismaIdentifier(options.publishTableName ??
15
+ exports.defaultPrismaStorageTableNames.publishTableName, 40),
16
+ receivedTableName: validatePrismaIdentifier(options.receivedTableName ??
17
+ exports.defaultPrismaStorageTableNames.receivedTableName, 40),
18
+ };
19
+ }
20
+ function resolvePrismaStorageProvider(provider) {
21
+ if (provider === 'postgres')
22
+ return 'postgresql';
23
+ if (provider === 'mariadb')
24
+ return 'mysql';
25
+ return provider;
26
+ }
27
+ function validatePrismaIdentifier(identifier, maxLength = 64) {
28
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(identifier)) {
29
+ throw new Error(`Invalid Prisma storage identifier "${identifier}". Use only letters, numbers, and underscores, starting with a letter or underscore.`);
30
+ }
31
+ if (identifier.length > maxLength) {
32
+ throw new Error(`Invalid Prisma storage identifier "${identifier}": identifiers must be at most ${maxLength} characters.`);
33
+ }
34
+ return identifier;
35
+ }
36
+ //# sourceMappingURL=prisma-storage-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-storage-options.js","sourceRoot":"","sources":["../src/prisma-storage-options.ts"],"names":[],"mappings":";;;AA0BA,kEAgBC;AAED,oEAMC;AAED,4DAeC;AA9CY,QAAA,8BAA8B,GAAG;IAC5C,gBAAgB,EAAE,aAAa;IAC/B,iBAAiB,EAAE,cAAc;CACzB,CAAC;AAEX,SAAgB,2BAA2B,CACzC,OAA6B;IAE7B,OAAO;QACL,QAAQ,EAAE,4BAA4B,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxD,gBAAgB,EAAE,wBAAwB,CACxC,OAAO,CAAC,gBAAgB;YACtB,sCAA8B,CAAC,gBAAgB,EACjD,EAAE,CACH;QACD,iBAAiB,EAAE,wBAAwB,CACzC,OAAO,CAAC,iBAAiB;YACvB,sCAA8B,CAAC,iBAAiB,EAClD,EAAE,CACH;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAC1C,QAA+B;IAE/B,IAAI,QAAQ,KAAK,UAAU;QAAE,OAAO,YAAY,CAAC;IACjD,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IAC3C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,wBAAwB,CACtC,UAAkB,EAClB,SAAS,GAAG,EAAE;IAEd,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CACb,sCAAsC,UAAU,sFAAsF,CACvI,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,sCAAsC,UAAU,kCAAkC,SAAS,cAAc,CAC1G,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { JsonValue } from '@mikara89/cap-core';
2
+ import type { PrismaCapExecutor } from './prisma-cap-client';
3
+ import type { ResolvedPrismaStorageProvider } from './prisma-storage-options';
4
+ export declare class PrismaSqlBuilder {
5
+ private readonly provider;
6
+ readonly values: unknown[];
7
+ constructor(provider: ResolvedPrismaStorageProvider, initialValues?: unknown[]);
8
+ parameter(value: unknown): string;
9
+ }
10
+ export declare function quotePrismaIdentifier(provider: ResolvedPrismaStorageProvider, identifier: string): string;
11
+ export declare function qualifiedPrismaColumn(provider: ResolvedPrismaStorageProvider, alias: string, column: string): string;
12
+ export declare function prismaInsertSql(provider: ResolvedPrismaStorageProvider, tableName: string, columns: string[], values: unknown[], mode?: 'insert' | 'ignoreDedupe'): {
13
+ sql: string;
14
+ values: unknown[];
15
+ };
16
+ export declare function executePrismaSql(executor: PrismaCapExecutor, sql: string, values?: unknown[]): Promise<number>;
17
+ export declare function queryPrismaSql<T>(executor: PrismaCapExecutor, sql: string, values?: unknown[]): Promise<T>;
18
+ export declare function serializePrismaJson(value: unknown): string | null;
19
+ export declare function deserializePrismaJson<T extends JsonValue = JsonValue>(value: unknown): T;
20
+ export declare function toPrismaDbDate(value: Date | string | null | undefined): string | null;
21
+ export declare function toRequiredPrismaDbDate(value: Date | string): string;
22
+ export declare function fromPrismaDbDate(value: unknown): Date | null;
23
+ export declare function prismaBoolean(value: boolean): number;
24
+ //# sourceMappingURL=prisma-storage-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-storage-utils.d.ts","sourceRoot":"","sources":["../src/prisma-storage-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAG9E,qBAAa,gBAAgB;IAIzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAH3B,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;gBAGR,QAAQ,EAAE,6BAA6B,EACxD,aAAa,GAAE,OAAO,EAAO;IAK/B,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;CAIlC;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,6BAA6B,EACvC,UAAU,EAAE,MAAM,GACjB,MAAM,CAGR;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,6BAA6B,EACvC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,6BAA6B,EACvC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,OAAO,EAAE,EACjB,IAAI,GAAE,QAAQ,GAAG,cAAyB,GACzC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CA+BpC;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAO,EAAO,GACrB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,cAAc,CAAC,CAAC,EACpC,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAO,EAAO,GACrB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEjE;AAED,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EACnE,KAAK,EAAE,OAAO,GACb,CAAC,CAIH;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACtC,MAAM,GAAG,IAAI,CAGf;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAS5D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrismaSqlBuilder = void 0;
4
+ exports.quotePrismaIdentifier = quotePrismaIdentifier;
5
+ exports.qualifiedPrismaColumn = qualifiedPrismaColumn;
6
+ exports.prismaInsertSql = prismaInsertSql;
7
+ exports.executePrismaSql = executePrismaSql;
8
+ exports.queryPrismaSql = queryPrismaSql;
9
+ exports.serializePrismaJson = serializePrismaJson;
10
+ exports.deserializePrismaJson = deserializePrismaJson;
11
+ exports.toPrismaDbDate = toPrismaDbDate;
12
+ exports.toRequiredPrismaDbDate = toRequiredPrismaDbDate;
13
+ exports.fromPrismaDbDate = fromPrismaDbDate;
14
+ exports.prismaBoolean = prismaBoolean;
15
+ const prisma_storage_options_1 = require("./prisma-storage-options");
16
+ class PrismaSqlBuilder {
17
+ constructor(provider, initialValues = []) {
18
+ this.provider = provider;
19
+ this.values = [...initialValues];
20
+ }
21
+ parameter(value) {
22
+ this.values.push(value);
23
+ return this.provider === 'postgresql' ? `$${this.values.length}` : '?';
24
+ }
25
+ }
26
+ exports.PrismaSqlBuilder = PrismaSqlBuilder;
27
+ function quotePrismaIdentifier(provider, identifier) {
28
+ const validated = (0, prisma_storage_options_1.validatePrismaIdentifier)(identifier);
29
+ return provider === 'mysql' ? `\`${validated}\`` : `"${validated}"`;
30
+ }
31
+ function qualifiedPrismaColumn(provider, alias, column) {
32
+ return `${quotePrismaIdentifier(provider, alias)}.${quotePrismaIdentifier(provider, column)}`;
33
+ }
34
+ function prismaInsertSql(provider, tableName, columns, values, mode = 'insert') {
35
+ const builder = new PrismaSqlBuilder(provider);
36
+ const quotedColumns = columns
37
+ .map((column) => quotePrismaIdentifier(provider, column))
38
+ .join(', ');
39
+ const placeholders = values
40
+ .map((value) => builder.parameter(value))
41
+ .join(', ');
42
+ const conflict = mode !== 'ignoreDedupe'
43
+ ? ''
44
+ : provider === 'mysql'
45
+ ? ` ON DUPLICATE KEY UPDATE ${quotePrismaIdentifier(provider, 'id')} = IF(LAST_INSERT_ID(1), ${quotePrismaIdentifier(provider, 'id')}, ${quotePrismaIdentifier(provider, 'id')})`
46
+ : ` ON CONFLICT (${quotePrismaIdentifier(provider, 'group')}, ${quotePrismaIdentifier(provider, 'dedupe_key')}) DO NOTHING`;
47
+ return {
48
+ sql: `INSERT INTO ${quotePrismaIdentifier(provider, tableName)} (${quotedColumns}) VALUES (${placeholders})${conflict}`,
49
+ values: builder.values,
50
+ };
51
+ }
52
+ async function executePrismaSql(executor, sql, values = []) {
53
+ return executor.$executeRawUnsafe(sql, ...values);
54
+ }
55
+ async function queryPrismaSql(executor, sql, values = []) {
56
+ return executor.$queryRawUnsafe(sql, ...values);
57
+ }
58
+ function serializePrismaJson(value) {
59
+ return value === undefined ? null : JSON.stringify(value);
60
+ }
61
+ function deserializePrismaJson(value) {
62
+ if (value === null || value === undefined)
63
+ return null;
64
+ if (typeof value !== 'string')
65
+ return value;
66
+ return JSON.parse(value);
67
+ }
68
+ function toPrismaDbDate(value) {
69
+ if (value === null || value === undefined)
70
+ return null;
71
+ return value instanceof Date ? value.toISOString() : value;
72
+ }
73
+ function toRequiredPrismaDbDate(value) {
74
+ return value instanceof Date ? value.toISOString() : value;
75
+ }
76
+ function fromPrismaDbDate(value) {
77
+ if (value === null || value === undefined)
78
+ return null;
79
+ if (value instanceof Date)
80
+ return value;
81
+ if (typeof value === 'string' || typeof value === 'number') {
82
+ return new Date(value);
83
+ }
84
+ throw new Error(`Unsupported date value from Prisma storage: ${typeof value}`);
85
+ }
86
+ function prismaBoolean(value) {
87
+ return value ? 1 : 0;
88
+ }
89
+ //# sourceMappingURL=prisma-storage-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-storage-utils.js","sourceRoot":"","sources":["../src/prisma-storage-utils.ts"],"names":[],"mappings":";;;AAqBA,sDAMC;AAED,sDASC;AAED,0CAqCC;AAED,4CAMC;AAED,wCAMC;AAED,kDAEC;AAED,sDAMC;AAED,wCAKC;AAED,wDAEC;AAED,4CASC;AAED,sCAEC;AAhID,qEAAoE;AAEpE,MAAa,gBAAgB;IAG3B,YACmB,QAAuC,EACxD,gBAA2B,EAAE;QADZ,aAAQ,GAAR,QAAQ,CAA+B;QAGxD,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,KAAc;QACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,C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,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC;AAED,SAAgB,sBAAsB,CAAC,KAAoB;IACzD,OAAO,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC;AAED,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3D,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,IAAI,KAAK,CACb,+CAA+C,OAAO,KAAK,EAAE,CAC9D,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Prisma } from '@prisma/client';
2
+ import { type CapOperationContext, type CapTransactionManagerPort, type CapTransactionOptions } from '@mikara89/cap-core';
3
+ import type { PrismaCapClient } from './prisma-cap-client';
4
+ import type { PrismaStorageOptions } from './prisma-storage-options';
5
+ export declare class PrismaTransactionManager implements CapTransactionManagerPort<Prisma.TransactionClient> {
6
+ private readonly client;
7
+ private readonly options;
8
+ private readonly context;
9
+ constructor(client: PrismaCapClient, options: Pick<PrismaStorageOptions, 'provider'>);
10
+ runInTransaction<T>(options: CapTransactionOptions, fn: (ctx: CapOperationContext<Prisma.TransactionClient>) => Promise<T>): Promise<T>;
11
+ getCurrentContext(): CapOperationContext<Prisma.TransactionClient> | undefined;
12
+ afterCommit(fn: () => void | Promise<void>): void;
13
+ afterRollback(fn: (error: unknown) => void | Promise<void>): void;
14
+ private mapTransactionOptions;
15
+ private mapIsolationLevel;
16
+ }
17
+ //# sourceMappingURL=prisma-transaction-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-transaction-manager.d.ts","sourceRoot":"","sources":["../src/prisma-transaction-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,qBAAa,wBAAyB,YAAW,yBAAyB,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAKhG,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CACgC;gBAGrC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC;IAG5D,gBAAgB,CAAC,CAAC,EACtB,OAAO,EAAE,qBAAqB,EAC9B,EAAE,EAAE,CAAC,GAAG,EAAE,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GACrE,OAAO,CAAC,CAAC,CAAC;IA6Bb,iBAAiB,IACb,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAC7C,SAAS;IAIb,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAQjD,aAAa,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAQjE,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,iBAAiB;CAsB1B"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrismaTransactionManager = void 0;
4
+ const cap_core_1 = require("@mikara89/cap-core");
5
+ const prisma_storage_options_1 = require("./prisma-storage-options");
6
+ class PrismaTransactionManager {
7
+ constructor(client, options) {
8
+ this.client = client;
9
+ this.options = options;
10
+ this.context = new cap_core_1.CapTransactionContext();
11
+ }
12
+ async runInTransaction(options, fn) {
13
+ const afterCommit = [];
14
+ const afterRollback = [];
15
+ try {
16
+ const result = await this.client.$transaction(async (tx) => {
17
+ const ctx = {
18
+ tx,
19
+ metadata: { options },
20
+ afterCommit: (callback) => afterCommit.push(callback),
21
+ afterRollback: (callback) => afterRollback.push(callback),
22
+ };
23
+ return this.context.run(ctx, () => fn(ctx));
24
+ }, this.mapTransactionOptions(options));
25
+ for (const callback of afterCommit) {
26
+ await callback();
27
+ }
28
+ return result;
29
+ }
30
+ catch (err) {
31
+ for (const callback of afterRollback) {
32
+ await callback(err);
33
+ }
34
+ throw err;
35
+ }
36
+ }
37
+ getCurrentContext() {
38
+ return this.context.current();
39
+ }
40
+ afterCommit(fn) {
41
+ const ctx = this.context.current();
42
+ if (!ctx?.afterCommit) {
43
+ throw new Error('No active Prisma transaction context');
44
+ }
45
+ ctx.afterCommit(fn);
46
+ }
47
+ afterRollback(fn) {
48
+ const ctx = this.context.current();
49
+ if (!ctx?.afterRollback) {
50
+ throw new Error('No active Prisma transaction context');
51
+ }
52
+ ctx.afterRollback(fn);
53
+ }
54
+ mapTransactionOptions(options) {
55
+ const mapped = {};
56
+ if (options.timeoutMs !== undefined) {
57
+ mapped.timeout = options.timeoutMs;
58
+ }
59
+ if (options.isolationLevel !== undefined) {
60
+ mapped.isolationLevel = this.mapIsolationLevel(options.isolationLevel);
61
+ }
62
+ return Object.keys(mapped).length > 0 ? mapped : undefined;
63
+ }
64
+ mapIsolationLevel(value) {
65
+ const provider = (0, prisma_storage_options_1.resolvePrismaStorageProvider)(this.options.provider);
66
+ const supported = provider === 'sqlite'
67
+ ? ['Serializable']
68
+ : [
69
+ 'ReadUncommitted',
70
+ 'ReadCommitted',
71
+ 'RepeatableRead',
72
+ 'Serializable',
73
+ ];
74
+ if (!supported.includes(value)) {
75
+ throw new Error(`Prisma provider ${provider} does not support transaction isolation level "${value}". Supported values: ${supported.join(', ')}.`);
76
+ }
77
+ return value;
78
+ }
79
+ }
80
+ exports.PrismaTransactionManager = PrismaTransactionManager;
81
+ //# sourceMappingURL=prisma-transaction-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-transaction-manager.js","sourceRoot":"","sources":["../src/prisma-transaction-manager.ts"],"names":[],"mappings":";;;AACA,iDAK4B;AAM5B,qEAAwE;AAExE,MAAa,wBAAwB;IAInC,YACmB,MAAuB,EACvB,OAA+C;QAD/C,WAAM,GAAN,MAAM,CAAiB;QACvB,YAAO,GAAP,OAAO,CAAwC;QALjD,YAAO,GACtB,IAAI,gCAAqB,EAA4B,CAAC;IAKrD,CAAC;IAEJ,KAAK,CAAC,gBAAgB,CACpB,OAA8B,EAC9B,EAAsE;QAEtE,MAAM,WAAW,GAAsC,EAAE,CAAC;QAC1D,MAAM,aAAa,GAAoD,EAAE,CAAC;QAE1E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;gBACzD,MAAM,GAAG,GAAkD;oBACzD,EAAE;oBACF,QAAQ,EAAE,EAAE,OAAO,EAAE;oBACrB,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;oBACrD,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC;i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YACpC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;QACrC,CAAC;QACD,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,CAAC;IAEO,iBAAiB,CAAC,KAAa;QACrC,MAAM,QAAQ,GAAG,IAAA,qDAA4B,EAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrE,MAAM,SAAS,GACb,QAAQ,KAAK,QAAQ;YACnB,CAAC,CAAC,CAAC,cAAc,CAAC;YAClB,CAAC,CAAC;gBACE,iBAAiB;gBACjB,eAAe;gBACf,gBAAgB;gBAChB,cAAc;aACf,CAAC;QAER,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,mBAAmB,QAAQ,kDAAkD,KAAK,wBAAwB,SAAS,CAAC,IAAI,CACtH,IAAI,CACL,GAAG,CACL,CAAC;QACJ,CAAC;QAED,OAAO,KAAyC,CAAC;IACnD,CAAC;CACF;AApGD,4DAoGC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@mikara89/cap-storage-prisma",
3
+ "version": "2.2.0",
4
+ "description": "Prisma storage adapter for CAP",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "license": "MIT",
8
+ "homepage": "https://mikara89.github.io/cap-nodejs/",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/mikara89/cap-nodejs",
12
+ "directory": "libs/cap-storage-prisma"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/mikara89/cap-nodejs/issues"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "!dist/testing",
20
+ "README.md",
21
+ "CHANGELOG.md"
22
+ ],
23
+ "publishConfig": {
24
+ "registry": "https://registry.npmjs.org/",
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "generate": "prisma generate --schema prisma/schema.prisma",
29
+ "generate:test-clients": "npm run generate && prisma generate --schema prisma/postgresql.prisma && prisma generate --schema prisma/mysql.prisma",
30
+ "build": "npm run generate && tsc -p tsconfig.lib.json",
31
+ "prepack": "npm run build",
32
+ "test": "npm run generate:test-clients && jest",
33
+ "lint": "eslint \"src/**/*.ts\" --fix"
34
+ },
35
+ "peerDependencies": {
36
+ "@mikara89/cap-core": "^2.2.0",
37
+ "@prisma/client": "^6.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@mikara89/cap-core": "file:../cap-core",
41
+ "@mikara89/cap-testing": "file:../cap-testing",
42
+ "@prisma/client": "^6.0.0",
43
+ "@types/node": "^22.0.0",
44
+ "prisma": "^6.0.0",
45
+ "typescript": "^5.7.0"
46
+ },
47
+ "exports": {
48
+ ".": {
49
+ "types": "./dist/index.d.ts",
50
+ "require": "./dist/index.js",
51
+ "default": "./dist/index.js"
52
+ },
53
+ "./package.json": "./package.json"
54
+ }
55
+ }