node-cqrs 1.2.0-beta.0 → 1.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +29 -9
- package/dist/cjs/postgresql/AbstractPostgresqlAccessor.js +83 -0
- package/dist/cjs/postgresql/AbstractPostgresqlAccessor.js.map +1 -0
- package/dist/cjs/postgresql/AbstractPostgresqlObjectProjection.js +36 -0
- package/dist/cjs/postgresql/AbstractPostgresqlObjectProjection.js.map +1 -0
- package/dist/cjs/postgresql/AbstractPostgresqlView.js +53 -0
- package/dist/cjs/postgresql/AbstractPostgresqlView.js.map +1 -0
- package/dist/cjs/postgresql/IContainer.js +3 -0
- package/dist/cjs/postgresql/IContainer.js.map +1 -0
- package/dist/cjs/postgresql/PostgresqlConnection.js +3 -0
- package/dist/cjs/postgresql/PostgresqlConnection.js.map +1 -0
- package/dist/cjs/postgresql/PostgresqlEventLocker.js +127 -0
- package/dist/cjs/postgresql/PostgresqlEventLocker.js.map +1 -0
- package/dist/cjs/postgresql/PostgresqlEventStorage.js +315 -0
- package/dist/cjs/postgresql/PostgresqlEventStorage.js.map +1 -0
- package/dist/cjs/postgresql/PostgresqlObjectStorage.js +137 -0
- package/dist/cjs/postgresql/PostgresqlObjectStorage.js.map +1 -0
- package/dist/cjs/postgresql/PostgresqlObjectView.js +46 -0
- package/dist/cjs/postgresql/PostgresqlObjectView.js.map +1 -0
- package/dist/cjs/postgresql/PostgresqlProjectionDataParams.js +3 -0
- package/dist/cjs/postgresql/PostgresqlProjectionDataParams.js.map +1 -0
- package/dist/cjs/postgresql/PostgresqlViewLocker.js +151 -0
- package/dist/cjs/postgresql/PostgresqlViewLocker.js.map +1 -0
- package/dist/cjs/postgresql/index.js +29 -0
- package/dist/cjs/postgresql/index.js.map +1 -0
- package/dist/cjs/postgresql/utils/getEventId.js +14 -0
- package/dist/cjs/postgresql/utils/getEventId.js.map +1 -0
- package/dist/cjs/postgresql/utils/index.js +19 -0
- package/dist/cjs/postgresql/utils/index.js.map +1 -0
- package/dist/cjs/postgresql/utils/quoteIdentifier.js +14 -0
- package/dist/cjs/postgresql/utils/quoteIdentifier.js.map +1 -0
- package/dist/cjs/sqlite/SqliteEventStorage.js +66 -36
- package/dist/cjs/sqlite/SqliteEventStorage.js.map +1 -1
- package/dist/esm/postgresql/AbstractPostgresqlAccessor.js +79 -0
- package/dist/esm/postgresql/AbstractPostgresqlAccessor.js.map +1 -0
- package/dist/esm/postgresql/AbstractPostgresqlObjectProjection.js +32 -0
- package/dist/esm/postgresql/AbstractPostgresqlObjectProjection.js.map +1 -0
- package/dist/esm/postgresql/AbstractPostgresqlView.js +49 -0
- package/dist/esm/postgresql/AbstractPostgresqlView.js.map +1 -0
- package/dist/esm/postgresql/IContainer.js +2 -0
- package/dist/esm/postgresql/IContainer.js.map +1 -0
- package/dist/esm/postgresql/PostgresqlConnection.js +2 -0
- package/dist/esm/postgresql/PostgresqlConnection.js.map +1 -0
- package/dist/esm/postgresql/PostgresqlEventLocker.js +123 -0
- package/dist/esm/postgresql/PostgresqlEventLocker.js.map +1 -0
- package/dist/esm/postgresql/PostgresqlEventStorage.js +311 -0
- package/dist/esm/postgresql/PostgresqlEventStorage.js.map +1 -0
- package/dist/esm/postgresql/PostgresqlObjectStorage.js +133 -0
- package/dist/esm/postgresql/PostgresqlObjectStorage.js.map +1 -0
- package/dist/esm/postgresql/PostgresqlObjectView.js +42 -0
- package/dist/esm/postgresql/PostgresqlObjectView.js.map +1 -0
- package/dist/esm/postgresql/PostgresqlProjectionDataParams.js +2 -0
- package/dist/esm/postgresql/PostgresqlProjectionDataParams.js.map +1 -0
- package/dist/esm/postgresql/PostgresqlViewLocker.js +147 -0
- package/dist/esm/postgresql/PostgresqlViewLocker.js.map +1 -0
- package/dist/esm/postgresql/index.js +13 -0
- package/dist/esm/postgresql/index.js.map +1 -0
- package/dist/esm/postgresql/utils/getEventId.js +10 -0
- package/dist/esm/postgresql/utils/getEventId.js.map +1 -0
- package/dist/esm/postgresql/utils/index.js +3 -0
- package/dist/esm/postgresql/utils/index.js.map +1 -0
- package/dist/esm/postgresql/utils/quoteIdentifier.js +11 -0
- package/dist/esm/postgresql/utils/quoteIdentifier.js.map +1 -0
- package/dist/esm/sqlite/SqliteEventStorage.js +66 -36
- package/dist/esm/sqlite/SqliteEventStorage.js.map +1 -1
- package/dist/types/postgresql/AbstractPostgresqlAccessor.d.ts +29 -0
- package/dist/types/postgresql/AbstractPostgresqlObjectProjection.d.ts +12 -0
- package/dist/types/postgresql/AbstractPostgresqlView.d.ts +23 -0
- package/dist/types/postgresql/IContainer.d.ts +12 -0
- package/dist/types/postgresql/PostgresqlConnection.d.ts +7 -0
- package/dist/types/postgresql/PostgresqlEventLocker.d.ts +39 -0
- package/dist/types/postgresql/PostgresqlEventStorage.d.ts +23 -0
- package/dist/types/postgresql/PostgresqlObjectStorage.d.ts +29 -0
- package/dist/types/postgresql/PostgresqlObjectView.d.ts +19 -0
- package/dist/types/postgresql/PostgresqlProjectionDataParams.d.ts +14 -0
- package/dist/types/postgresql/PostgresqlViewLocker.d.ts +41 -0
- package/dist/types/postgresql/index.d.ts +12 -0
- package/dist/types/postgresql/utils/getEventId.d.ts +5 -0
- package/dist/types/postgresql/utils/index.d.ts +2 -0
- package/dist/types/postgresql/utils/quoteIdentifier.d.ts +1 -0
- package/package.json +20 -5
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IContainer } from 'node-cqrs';
|
|
2
|
+
import type { IViewLocker } from '../interfaces/index.ts';
|
|
3
|
+
import type { PostgresqlConnection } from './PostgresqlConnection.ts';
|
|
4
|
+
import type { PostgresqlProjectionDataParams } from './PostgresqlProjectionDataParams.ts';
|
|
5
|
+
import { AbstractPostgresqlAccessor } from './AbstractPostgresqlAccessor.ts';
|
|
6
|
+
export type PostgresqlViewLockerParams = PostgresqlProjectionDataParams & {
|
|
7
|
+
/**
|
|
8
|
+
* (Optional) PostgreSQL table name where view locks and the latest event are stored.
|
|
9
|
+
*
|
|
10
|
+
* @default PostgresqlViewLocker.DEFAULT_TABLE
|
|
11
|
+
*/
|
|
12
|
+
viewLockTableName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* (Optional) Time-to-live (TTL) duration (in milliseconds) for which a view remains locked.
|
|
15
|
+
* The lock is automatically prolonged while still held by this instance.
|
|
16
|
+
*
|
|
17
|
+
* @default PostgresqlViewLocker.DEFAULT_VIEW_LOCK_TTL
|
|
18
|
+
*/
|
|
19
|
+
viewLockTtl?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* PostgreSQL-backed implementation of IViewLocker.
|
|
23
|
+
*
|
|
24
|
+
* Uses a row with token + locked_till semantics to acquire a distributed view lock.
|
|
25
|
+
* The lock is automatically prolonged at half the TTL interval to prevent expiration
|
|
26
|
+
* while processing is in progress.
|
|
27
|
+
*/
|
|
28
|
+
export declare class PostgresqlViewLocker extends AbstractPostgresqlAccessor implements IViewLocker {
|
|
29
|
+
#private;
|
|
30
|
+
static DEFAULT_VIEW_LOCK_TTL: number;
|
|
31
|
+
static DEFAULT_TABLE: string;
|
|
32
|
+
constructor(o: Partial<Pick<IContainer, 'viewModelPostgresqlDb' | 'viewModelPostgresqlDbFactory' | 'logger'>> & PostgresqlViewLockerParams);
|
|
33
|
+
protected initialize(db: PostgresqlConnection): Promise<void>;
|
|
34
|
+
get ready(): boolean;
|
|
35
|
+
lock(): Promise<boolean>;
|
|
36
|
+
private scheduleLockProlongation;
|
|
37
|
+
private cancelLockProlongation;
|
|
38
|
+
private prolongLock;
|
|
39
|
+
unlock(): Promise<void>;
|
|
40
|
+
once(event: 'ready'): Promise<void>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './IContainer.ts';
|
|
2
|
+
export * from './AbstractPostgresqlAccessor.ts';
|
|
3
|
+
export * from './AbstractPostgresqlObjectProjection.ts';
|
|
4
|
+
export * from './AbstractPostgresqlView.ts';
|
|
5
|
+
export * from './PostgresqlConnection.ts';
|
|
6
|
+
export * from './PostgresqlEventStorage.ts';
|
|
7
|
+
export * from './PostgresqlEventLocker.ts';
|
|
8
|
+
export * from './PostgresqlObjectStorage.ts';
|
|
9
|
+
export * from './PostgresqlObjectView.ts';
|
|
10
|
+
export * from './PostgresqlProjectionDataParams.ts';
|
|
11
|
+
export * from './PostgresqlViewLocker.ts';
|
|
12
|
+
export * from './utils/index.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function quoteIdentifier(identifier: string): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-cqrs",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "TypeScript CQRS/Event Sourcing toolkit for Node.js with DI, sagas, projections, and optional Worker, RabbitMQ, and
|
|
3
|
+
"version": "1.3.0-alpha.0",
|
|
4
|
+
"description": "TypeScript CQRS/Event Sourcing toolkit for Node.js with DI, sagas, projections, and optional Worker, RabbitMQ, SQLite, MongoDB, and PostgreSQL adapters",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cqrs",
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
"worker-threads",
|
|
20
20
|
"rabbitmq",
|
|
21
21
|
"sqlite",
|
|
22
|
-
"
|
|
22
|
+
"mongodb",
|
|
23
|
+
"redis",
|
|
24
|
+
"postgresql"
|
|
23
25
|
],
|
|
24
26
|
"repository": {
|
|
25
27
|
"type": "git",
|
|
@@ -62,6 +64,11 @@
|
|
|
62
64
|
"types": "./dist/types/mongodb/index.d.ts",
|
|
63
65
|
"require": "./dist/cjs/mongodb/index.js",
|
|
64
66
|
"import": "./dist/esm/mongodb/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./postgresql": {
|
|
69
|
+
"types": "./dist/types/postgresql/index.d.ts",
|
|
70
|
+
"require": "./dist/cjs/postgresql/index.js",
|
|
71
|
+
"import": "./dist/esm/postgresql/index.js"
|
|
65
72
|
}
|
|
66
73
|
},
|
|
67
74
|
"directories": {
|
|
@@ -87,6 +94,7 @@
|
|
|
87
94
|
"example:redis": "node examples/redis/index.ts",
|
|
88
95
|
"example:mongodb-eventstore": "node examples/mongodb-eventstore/index.ts",
|
|
89
96
|
"example:mongodb-views": "node examples/mongodb-views/index.ts",
|
|
97
|
+
"example:postgresql": "node examples/postgresql/index.ts",
|
|
90
98
|
"example:browser": "npm run build:browser && echo \"\nOpen ./examples/browser/index.html in your browser (check DevTools console)\n\"",
|
|
91
99
|
"pretest:examples": "npm run build:cjs",
|
|
92
100
|
"test:examples": "jest --roots='<rootDir>/examples'",
|
|
@@ -95,6 +103,7 @@
|
|
|
95
103
|
"test:sqlite": "jest --verbose --roots='<rootDir>/tests/integration/sqlite'",
|
|
96
104
|
"test:redis": "jest --verbose --roots='<rootDir>/tests/integration/redis'",
|
|
97
105
|
"test:mongodb": "jest --verbose --roots='<rootDir>/tests/integration/mongodb'",
|
|
106
|
+
"test:postgresql": "jest --verbose --roots='<rootDir>/tests/integration/postgresql'",
|
|
98
107
|
"pretest:workers": "npm run build:cjs",
|
|
99
108
|
"test:workers": "jest --verbose --roots='<rootDir>/tests/integration/workers'",
|
|
100
109
|
"changelog": "conventional-changelog -n ./scripts/changelog/index.cjs -r 0 > CHANGELOG.md",
|
|
@@ -135,10 +144,10 @@
|
|
|
135
144
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
136
145
|
"@rollup/plugin-terser": "^1.0.0",
|
|
137
146
|
"@types/amqplib": "^0.10.8",
|
|
138
|
-
"ioredis": "^5.0.0",
|
|
139
147
|
"@types/better-sqlite3": "^7.6.13",
|
|
140
148
|
"@types/jest": "^29.5.14",
|
|
141
149
|
"@types/node": "^25.5.0",
|
|
150
|
+
"@types/pg": "^8.20.0",
|
|
142
151
|
"@typescript-eslint/eslint-plugin": "^8.29.0",
|
|
143
152
|
"@typescript-eslint/parser": "^8.29.0",
|
|
144
153
|
"amqplib": "^0.10.9",
|
|
@@ -148,8 +157,10 @@
|
|
|
148
157
|
"eslint": "^9.39.4",
|
|
149
158
|
"eslint-plugin-jest": "^28.14.0",
|
|
150
159
|
"globals": "^17.4.0",
|
|
160
|
+
"ioredis": "^5.0.0",
|
|
151
161
|
"jest": "^29.7.0",
|
|
152
162
|
"mongodb": "^6.21.0",
|
|
163
|
+
"pg": "^8.21.0",
|
|
153
164
|
"rollup": "^4.59.0",
|
|
154
165
|
"ts-jest": "^29.4.6",
|
|
155
166
|
"ts-node": "^10.9.2",
|
|
@@ -162,7 +173,8 @@
|
|
|
162
173
|
"better-sqlite3": "^12.6.2",
|
|
163
174
|
"comlink": "^4.4.2",
|
|
164
175
|
"ioredis": "^5.0.0",
|
|
165
|
-
"mongodb": "^6.0.0"
|
|
176
|
+
"mongodb": "^6.0.0",
|
|
177
|
+
"pg": "^8.0.0"
|
|
166
178
|
},
|
|
167
179
|
"peerDependenciesMeta": {
|
|
168
180
|
"better-sqlite3": {
|
|
@@ -180,6 +192,9 @@
|
|
|
180
192
|
"mongodb": {
|
|
181
193
|
"optional": true
|
|
182
194
|
},
|
|
195
|
+
"pg": {
|
|
196
|
+
"optional": true
|
|
197
|
+
},
|
|
183
198
|
"@opentelemetry/api": {
|
|
184
199
|
"optional": true
|
|
185
200
|
}
|