@cqrs-ddd/mikro-orm 0.3.0 → 0.4.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/README.md +4 -1
- package/dist/cache/cache-entry.js +8 -14
- package/dist/cache/cache-entry.js.map +1 -1
- package/dist/cache/mikro-orm.cache.d.ts +1 -1
- package/dist/cache/mikro-orm.cache.d.ts.map +1 -1
- package/dist/cache/mikro-orm.cache.js +15 -19
- package/dist/cache/mikro-orm.cache.js.map +1 -1
- package/dist/concurrency/assert-autocommit.js +1 -4
- package/dist/concurrency/assert-autocommit.js.map +1 -1
- package/dist/concurrency/conditioned-write.js +4 -7
- package/dist/concurrency/conditioned-write.js.map +1 -1
- package/dist/concurrency/optimistic-delete.d.ts +1 -1
- package/dist/concurrency/optimistic-delete.d.ts.map +1 -1
- package/dist/concurrency/optimistic-delete.js +5 -8
- package/dist/concurrency/optimistic-delete.js.map +1 -1
- package/dist/concurrency/optimistic-update.d.ts +1 -1
- package/dist/concurrency/optimistic-update.d.ts.map +1 -1
- package/dist/concurrency/optimistic-update.js +5 -8
- package/dist/concurrency/optimistic-update.js.map +1 -1
- package/dist/errors/mikro-orm.dialect.js +3 -7
- package/dist/errors/mikro-orm.dialect.js.map +1 -1
- package/dist/errors/transient-error.js +4 -8
- package/dist/errors/transient-error.js.map +1 -1
- package/dist/helpers/sql-identifier.js +1 -4
- package/dist/helpers/sql-identifier.js.map +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -29
- package/dist/index.js.map +1 -1
- package/dist/interfaces/entity-manager-source.js +1 -2
- package/dist/interfaces/entity-manager-source.js.map +1 -1
- package/dist/mapping/root-entity.properties.d.ts +1 -1
- package/dist/mapping/root-entity.properties.d.ts.map +1 -1
- package/dist/mapping/root-entity.properties.js +5 -9
- package/dist/mapping/root-entity.properties.js.map +1 -1
- package/dist/mapping/unix-timestamp.type.js +2 -6
- package/dist/mapping/unix-timestamp.type.js.map +1 -1
- package/dist/repository/aggregate.repository.d.ts +1 -1
- package/dist/repository/aggregate.repository.d.ts.map +1 -1
- package/dist/repository/aggregate.repository.js +5 -9
- package/dist/repository/aggregate.repository.js.map +1 -1
- package/dist/tenancy/tenant-store.d.ts +1 -1
- package/dist/tenancy/tenant-store.d.ts.map +1 -1
- package/dist/tenancy/tenant-store.js +1 -5
- package/dist/tenancy/tenant-store.js.map +1 -1
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -30,9 +30,12 @@ on no framework: it works in a plain Node service and in a NestJS application.
|
|
|
30
30
|
pnpm add @cqrs-ddd/mikro-orm @cqrs-ddd/core @mikro-orm/core
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
Requires Node.js 22.17 or later, as MikroORM 7 does. `@cqrs-ddd/core` `^0.
|
|
33
|
+
Requires Node.js 22.17 or later, as MikroORM 7 does. `@cqrs-ddd/core` `^0.4.0` and `@mikro-orm/core` `^7.2.1` are peer
|
|
34
34
|
dependencies; add the MikroORM driver you use, such as `@mikro-orm/postgresql`.
|
|
35
35
|
|
|
36
|
+
Published as an ES module; a CommonJS application loads it with `require()`. Coming from
|
|
37
|
+
0.3.x, see [Upgrading from 0.3.x](https://github.com/aristoteliss/nestjs-pipeline#upgrading-from-03x).
|
|
38
|
+
|
|
36
39
|
## Entity manager source
|
|
37
40
|
|
|
38
41
|
The adapters take an `IEntityManagerSource`, an object with an `em` property, and read
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.createCacheTableSql = createCacheTableSql;
|
|
6
|
-
exports.createCacheEntrySchema = createCacheEntrySchema;
|
|
7
|
-
const core_1 = require("@mikro-orm/core");
|
|
8
|
-
const sql_identifier_1 = require("../helpers/sql-identifier");
|
|
2
|
+
import { EntitySchema } from '@mikro-orm/core';
|
|
3
|
+
import { isSqlIdentifier } from '../helpers/sql-identifier.js';
|
|
9
4
|
/**
|
|
10
5
|
* One row of the {@link MikroOrmCache} table.
|
|
11
6
|
*
|
|
@@ -13,15 +8,14 @@ const sql_identifier_1 = require("../helpers/sql-identifier");
|
|
|
13
8
|
* `expiresAt` is epoch milliseconds, or `null` for no expiry; `revision` is the
|
|
14
9
|
* decimal revision token that fences concurrent fills.
|
|
15
10
|
*/
|
|
16
|
-
class CacheEntry {
|
|
11
|
+
export class CacheEntry {
|
|
17
12
|
key;
|
|
18
13
|
value;
|
|
19
14
|
expiresAt;
|
|
20
15
|
revision;
|
|
21
16
|
}
|
|
22
|
-
exports.CacheEntry = CacheEntry;
|
|
23
17
|
function assertSafeTable(table) {
|
|
24
|
-
if (!
|
|
18
|
+
if (!isSqlIdentifier(table, { qualified: true })) {
|
|
25
19
|
throw new Error(`Invalid cache table name "${table}". ` +
|
|
26
20
|
'Use an unquoted identifier like "cache" or "schema.cache".');
|
|
27
21
|
}
|
|
@@ -42,7 +36,7 @@ function assertSafeTable(table) {
|
|
|
42
36
|
* await orm.em.getConnection().execute(createCacheTableSql());
|
|
43
37
|
* ```
|
|
44
38
|
*/
|
|
45
|
-
function createCacheTableSql(table = 'cache') {
|
|
39
|
+
export function createCacheTableSql(table = 'cache') {
|
|
46
40
|
const name = assertSafeTable(table);
|
|
47
41
|
const index = `${name.slice(name.lastIndexOf('.') + 1)}_expires_at_idx`;
|
|
48
42
|
return `CREATE TABLE IF NOT EXISTS ${name} (
|
|
@@ -62,10 +56,10 @@ CREATE INDEX IF NOT EXISTS ${index} ON ${name} (expires_at);`;
|
|
|
62
56
|
*
|
|
63
57
|
* @param table - Table name, optionally schema-qualified. Default `'cache'`.
|
|
64
58
|
*/
|
|
65
|
-
function createCacheEntrySchema(table = 'cache') {
|
|
59
|
+
export function createCacheEntrySchema(table = 'cache') {
|
|
66
60
|
const safe = assertSafeTable(table);
|
|
67
61
|
const index = `${safe.slice(safe.lastIndexOf('.') + 1)}_expires_at_idx`;
|
|
68
|
-
return new
|
|
62
|
+
return new EntitySchema({
|
|
69
63
|
class: CacheEntry,
|
|
70
64
|
tableName: safe,
|
|
71
65
|
properties: {
|
|
@@ -88,5 +82,5 @@ function createCacheEntrySchema(table = 'cache') {
|
|
|
88
82
|
});
|
|
89
83
|
}
|
|
90
84
|
/** {@link createCacheEntrySchema} for the default `cache` table. */
|
|
91
|
-
|
|
85
|
+
export const CacheEntrySchema = createCacheEntrySchema();
|
|
92
86
|
//# sourceMappingURL=cache-entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-entry.js","sourceRoot":"","sources":["../../src/cache/cache-entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache-entry.js","sourceRoot":"","sources":["../../src/cache/cache-entry.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IACrB,GAAG,CAAU;IACb,KAAK,CAAU;IACf,SAAS,CAAiB;IAC1B,QAAQ,CAAU;CACnB;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CACb,6BAA6B,KAAK,KAAK;YACrC,4DAA4D,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAK,GAAG,OAAO;IACjD,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAC;IACxE,OAAO,8BAA8B,IAAI;;;;;;6BAMd,KAAK,OAAO,IAAI,gBAAgB,CAAC;AAC9D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAK,GAAG,OAAO;IAEf,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAC;IACxE,OAAO,IAAI,YAAY,CAAa;QAClC,KAAK,EAAE,UAAU;QACjB,SAAS,EAAE,IAAI;QACf,UAAU,EAAE;YACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;YACnD,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACvB,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,QAAQ;gBACpB,SAAS,EAAE,YAAY;gBACvB,QAAQ,EAAE,IAAI;aACf;YACD,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE;SAChE;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,KAAK;gBACX,UAAU,EAAE,CAAC,WAAW,CAAC;aAC1B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CacheFillOptions, type CacheSetOptions, type CacheStateEntry, type IVersionedCache } from '@cqrs-ddd/core/application';
|
|
2
2
|
import type { ICacheLogger } from '@cqrs-ddd/core/persistence';
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/core';
|
|
4
|
-
import type { IEntityManagerSource } from '../interfaces/entity-manager-source';
|
|
4
|
+
import type { IEntityManagerSource } from '../interfaces/entity-manager-source.js';
|
|
5
5
|
/**
|
|
6
6
|
* An {@link IEntityManagerSource} that can also run work in a transaction.
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mikro-orm.cache.d.ts","sourceRoot":"","sources":["../../src/cache/mikro-orm.cache.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mikro-orm.cache.d.ts","sourceRoot":"","sources":["../../src/cache/mikro-orm.cache.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAenF;;;;;;;GAOG;AACH,MAAM,WAAW,iCACf,SAAQ,oBAAoB;IAC5B,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACvE;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,gGAAgG;IAChG,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH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d/core/persistence");
|
|
7
|
-
const cache_entry_1 = require("./cache-entry");
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { consoleCacheLogger, safeWarn } from '@cqrs-ddd/core/persistence';
|
|
4
|
+
import { CacheEntry } from './cache-entry.js';
|
|
8
5
|
/**
|
|
9
6
|
* Reads the committed row inside a CAS transaction, bypassing the identity map
|
|
10
7
|
* so a concurrent writer's revision is always observed.
|
|
11
8
|
*/
|
|
12
9
|
function readCommittedEntry(em, key) {
|
|
13
|
-
return em.findOne(
|
|
10
|
+
return em.findOne(CacheEntry, { key }, { refresh: true, disableIdentityMap: true });
|
|
14
11
|
}
|
|
15
12
|
/**
|
|
16
13
|
* Upper bound on compare-and-set re-reads. Each iteration only repeats after a
|
|
@@ -46,7 +43,7 @@ class CacheCasExhaustedError extends Error {
|
|
|
46
43
|
* }
|
|
47
44
|
* ```
|
|
48
45
|
*/
|
|
49
|
-
class MikroOrmCache {
|
|
46
|
+
export class MikroOrmCache {
|
|
50
47
|
store;
|
|
51
48
|
isVersioned = true;
|
|
52
49
|
logger;
|
|
@@ -54,14 +51,14 @@ class MikroOrmCache {
|
|
|
54
51
|
constructor(store, options) {
|
|
55
52
|
this.store = store;
|
|
56
53
|
this.defaultTtlMs = options?.defaultTtlMs ?? 60_000;
|
|
57
|
-
this.logger = options?.logger ??
|
|
54
|
+
this.logger = options?.logger ?? consoleCacheLogger('MikroOrmCache');
|
|
58
55
|
}
|
|
59
56
|
/**
|
|
60
57
|
* Observes the current key state and its revision token.
|
|
61
58
|
* Reads bypass the identity map to guarantee authoritative persistence visibility.
|
|
62
59
|
*/
|
|
63
60
|
async readState(key) {
|
|
64
|
-
const entry = await this.store.em.findOne(
|
|
61
|
+
const entry = await this.store.em.findOne(CacheEntry, { key }, { disableIdentityMap: true });
|
|
65
62
|
if (!entry) {
|
|
66
63
|
return { status: 'miss', revision: '0' };
|
|
67
64
|
}
|
|
@@ -89,7 +86,7 @@ class MikroOrmCache {
|
|
|
89
86
|
if (!existing) {
|
|
90
87
|
// `onConflictAction: 'ignore'` keeps a lost insert race from aborting
|
|
91
88
|
// the surrounding transaction, so the loop can re-read and retry.
|
|
92
|
-
await em.upsert(
|
|
89
|
+
await em.upsert(CacheEntry, { key, value: '', expiresAt: null, revision: '1' }, { onConflictAction: 'ignore' });
|
|
93
90
|
const inserted = await readCommittedEntry(em, key);
|
|
94
91
|
if (inserted && (inserted.revision ?? '0').toString() === '1') {
|
|
95
92
|
return '1';
|
|
@@ -98,7 +95,7 @@ class MikroOrmCache {
|
|
|
98
95
|
}
|
|
99
96
|
const currentRev = (existing.revision ?? '0').toString();
|
|
100
97
|
const nextRevision = (BigInt(currentRev) + 1n).toString();
|
|
101
|
-
const affected = await em.nativeUpdate(
|
|
98
|
+
const affected = await em.nativeUpdate(CacheEntry, { key, revision: existing.revision }, {
|
|
102
99
|
value: '',
|
|
103
100
|
expiresAt: null,
|
|
104
101
|
revision: nextRevision,
|
|
@@ -123,14 +120,14 @@ class MikroOrmCache {
|
|
|
123
120
|
if (observedRevision === '0') {
|
|
124
121
|
const existing = await readCommittedEntry(em, key);
|
|
125
122
|
if (!existing) {
|
|
126
|
-
await em.upsert(
|
|
123
|
+
await em.upsert(CacheEntry, { key, value: serialized, expiresAt, revision: '1' }, { onConflictAction: 'ignore' });
|
|
127
124
|
const inserted = await readCommittedEntry(em, key);
|
|
128
125
|
// A competing writer won the insert; this fill observed revision 0
|
|
129
126
|
// and must not overwrite it.
|
|
130
127
|
return inserted !== null && inserted.value === serialized;
|
|
131
128
|
}
|
|
132
129
|
if ((existing.revision ?? '0').toString() === '0') {
|
|
133
|
-
const affected = await em.nativeUpdate(
|
|
130
|
+
const affected = await em.nativeUpdate(CacheEntry, { key, revision: existing.revision }, {
|
|
134
131
|
value: serialized,
|
|
135
132
|
expiresAt,
|
|
136
133
|
revision: '1',
|
|
@@ -139,7 +136,7 @@ class MikroOrmCache {
|
|
|
139
136
|
}
|
|
140
137
|
return false;
|
|
141
138
|
}
|
|
142
|
-
const affected = await em.nativeUpdate(
|
|
139
|
+
const affected = await em.nativeUpdate(CacheEntry, { key, revision: observedRevision }, {
|
|
143
140
|
value: serialized,
|
|
144
141
|
expiresAt,
|
|
145
142
|
revision: nextRevision,
|
|
@@ -166,7 +163,7 @@ class MikroOrmCache {
|
|
|
166
163
|
for (let attempt = 0; attempt < MAX_CAS_ATTEMPTS; attempt++) {
|
|
167
164
|
const existing = await readCommittedEntry(em, key);
|
|
168
165
|
if (!existing) {
|
|
169
|
-
await em.upsert(
|
|
166
|
+
await em.upsert(CacheEntry, { key, value: serialized, expiresAt, revision: '1' }, { onConflictAction: 'ignore' });
|
|
170
167
|
continue;
|
|
171
168
|
}
|
|
172
169
|
if (isNewer && existing.value) {
|
|
@@ -177,7 +174,7 @@ class MikroOrmCache {
|
|
|
177
174
|
}
|
|
178
175
|
catch {
|
|
179
176
|
// An unparsable entry is treated as absent so the CAS update can heal corrupted data.
|
|
180
|
-
|
|
177
|
+
safeWarn(this.logger, `Failed to parse cached value (key digest: ${createHash('sha256').update(key).digest('hex')}); treating as absent.`);
|
|
181
178
|
}
|
|
182
179
|
if (parsed !== undefined && isNewer(parsed, value)) {
|
|
183
180
|
return;
|
|
@@ -186,7 +183,7 @@ class MikroOrmCache {
|
|
|
186
183
|
}
|
|
187
184
|
const currentRev = (existing.revision ?? '0').toString();
|
|
188
185
|
const nextRevision = (BigInt(currentRev) + 1n).toString();
|
|
189
|
-
const affected = await em.nativeUpdate(
|
|
186
|
+
const affected = await em.nativeUpdate(CacheEntry, { key, revision: existing.revision }, {
|
|
190
187
|
value: serialized,
|
|
191
188
|
expiresAt,
|
|
192
189
|
revision: nextRevision,
|
|
@@ -205,5 +202,4 @@ class MikroOrmCache {
|
|
|
205
202
|
await this.invalidate(key);
|
|
206
203
|
}
|
|
207
204
|
}
|
|
208
|
-
exports.MikroOrmCache = MikroOrmCache;
|
|
209
205
|
//# sourceMappingURL=mikro-orm.cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mikro-orm.cache.js","sourceRoot":"","sources":["../../src/cache/mikro-orm.cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mikro-orm.cache.js","sourceRoot":"","sources":["../../src/cache/mikro-orm.cache.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQzC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,SAAS,kBAAkB,CAAC,EAAiB,EAAE,GAAW;IACxD,OAAO,EAAE,CAAC,OAAO,CACf,UAAU,EACV,EAAE,GAAG,EAAE,EACP,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAC5C,CAAC;AACJ,CAAC;AA0BD;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,0DAA0D;AAC1D,MAAM,sBAAuB,SAAQ,KAAK;IACxC,YAAY,SAAiB,EAAE,GAAW;QACxC,KAAK,CACH,iBAAiB,SAAS,0BAA0B,GAAG,WAAW,gBAAgB,YAAY,CAC/F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,aAAa;IAOL,KAAK;IANf,WAAW,GAAG,IAAa,CAAC;IAEpB,MAAM,CAAe;IACrB,YAAY,CAAS;IAEtC,YACmB,KAAwC,EACzD,OAA8B;qBADb,KAAK;QAGtB,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,MAAM,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACvE,CAAC;IAED;;;OAGG;IACH,KAAK,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F,IAAI,QAAQ,GAAG,CAAC;oBAAE,OAAO;YAC3B,CAAC;YAED,MAAM,IAAI,sBAAsB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertAutocommit = assertAutocommit;
|
|
4
1
|
/**
|
|
5
2
|
* Rejects an externally active transaction before a write that reports durable
|
|
6
3
|
* success.
|
|
@@ -19,7 +16,7 @@ exports.assertAutocommit = assertAutocommit;
|
|
|
19
16
|
* @param operation Name used in the error message, e.g. `'optimisticDelete'`.
|
|
20
17
|
* @throws {Error} When `em` is inside an active transaction.
|
|
21
18
|
*/
|
|
22
|
-
function assertAutocommit(em, operation) {
|
|
19
|
+
export function assertAutocommit(em, operation) {
|
|
23
20
|
if (em.isInTransaction()) {
|
|
24
21
|
throw new Error(`${operation} requires autocommit; external transactions need commit hooks.`);
|
|
25
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-autocommit.js","sourceRoot":"","sources":["../../src/concurrency/assert-autocommit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assert-autocommit.js","sourceRoot":"","sources":["../../src/concurrency/assert-autocommit.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAiB,EAAE,SAAiB;IACnE,IAAI,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,GAAG,SAAS,gEAAgE,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
exports.expectOneRow = expectOneRow;
|
|
5
|
-
const domain_1 = require("@cqrs-ddd/core/domain");
|
|
2
|
+
import { ConcurrencyConflictError, EntityNotFoundException, } from '@cqrs-ddd/core/domain';
|
|
6
3
|
/**
|
|
7
4
|
* Checks the row count of a write filtered on `{ id, version }`: one row is
|
|
8
5
|
* success; none is diagnosed with one refreshed read on the same manager as
|
|
@@ -12,14 +9,14 @@ const domain_1 = require("@cqrs-ddd/core/domain");
|
|
|
12
9
|
* @throws {ConcurrencyConflictError} No row matched because the version diverged.
|
|
13
10
|
* @throws {Error} More than one row was affected.
|
|
14
11
|
*/
|
|
15
|
-
async function expectOneRow(affected, em, entityType, { id, expectedVersion }, entityName, verb) {
|
|
12
|
+
export async function expectOneRow(affected, em, entityType, { id, expectedVersion }, entityName, verb) {
|
|
16
13
|
if (affected === 1)
|
|
17
14
|
return;
|
|
18
15
|
if (affected === 0) {
|
|
19
16
|
const existing = await em.findOne(entityType, { id }, { refresh: true });
|
|
20
17
|
if (!existing)
|
|
21
|
-
throw new
|
|
22
|
-
throw new
|
|
18
|
+
throw new EntityNotFoundException(entityName, id);
|
|
19
|
+
throw new ConcurrencyConflictError(entityName, id, expectedVersion, existing.version);
|
|
23
20
|
}
|
|
24
21
|
throw new Error(`Expected one ${verb} ${entityName}, received ${affected}.`);
|
|
25
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditioned-write.js","sourceRoot":"","sources":["../../src/concurrency/conditioned-write.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conditioned-write.js","sourceRoot":"","sources":["../../src/concurrency/conditioned-write.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAgB/B;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,EAAiB,EACjB,UAA+B,EAC/B,EAAE,EAAE,EAAE,eAAe,EAAkB,EACvC,UAAkB,EAClB,IAA2B;IAE3B,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO;IAC3B,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,OAAO,CAC/B,UAAU,EACV,EAAE,EAAE,EAA0B,EAC9B,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;QACF,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACjE,MAAM,IAAI,wBAAwB,CAChC,UAAU,EACV,EAAE,EACF,eAAe,EACf,QAAQ,CAAC,OAAO,CACjB,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,IAAI,UAAU,cAAc,QAAQ,GAAG,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityManager, EntityName } from '@mikro-orm/core';
|
|
2
|
-
import { type VersionedAggregate } from './conditioned-write';
|
|
2
|
+
import { type VersionedAggregate } from './conditioned-write.js';
|
|
3
3
|
/**
|
|
4
4
|
* Executes a single version-conditioned, autocommitted `DELETE` on an aggregate.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistic-delete.d.ts","sourceRoot":"","sources":["../../src/concurrency/optimistic-delete.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"optimistic-delete.d.ts","sourceRoot":"","sources":["../../src/concurrency/optimistic-delete.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,SAAS,kBAAkB,EACvE,EAAE,EAAE,aAAa,EACjB,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAC/B,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const assert_autocommit_1 = require("./assert-autocommit");
|
|
6
|
-
const conditioned_write_1 = require("./conditioned-write");
|
|
2
|
+
import { assertAutocommit } from './assert-autocommit.js';
|
|
3
|
+
import { expectOneRow } from './conditioned-write.js';
|
|
7
4
|
/**
|
|
8
5
|
* Executes a single version-conditioned, autocommitted `DELETE` on an aggregate.
|
|
9
6
|
*
|
|
@@ -52,8 +49,8 @@ const conditioned_write_1 = require("./conditioned-write");
|
|
|
52
49
|
* }
|
|
53
50
|
* ```
|
|
54
51
|
*/
|
|
55
|
-
async function optimisticDelete(em, entityType, aggregate, entityName) {
|
|
56
|
-
|
|
52
|
+
export async function optimisticDelete(em, entityType, aggregate, entityName) {
|
|
53
|
+
assertAutocommit(em, 'optimisticDelete');
|
|
57
54
|
const row = {
|
|
58
55
|
id: aggregate.id,
|
|
59
56
|
expectedVersion: aggregate.getExpectedVersion(),
|
|
@@ -62,6 +59,6 @@ async function optimisticDelete(em, entityType, aggregate, entityName) {
|
|
|
62
59
|
id: row.id,
|
|
63
60
|
version: row.expectedVersion,
|
|
64
61
|
});
|
|
65
|
-
await
|
|
62
|
+
await expectOneRow(affected, em, entityType, row, entityName, 'deleted');
|
|
66
63
|
}
|
|
67
64
|
//# sourceMappingURL=optimistic-delete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistic-delete.js","sourceRoot":"","sources":["../../src/concurrency/optimistic-delete.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optimistic-delete.js","sourceRoot":"","sources":["../../src/concurrency/optimistic-delete.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,EAAiB,EACjB,UAA+B,EAC/B,SAAkB,EAClB,UAAkB;IAElB,gBAAgB,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACzC,MAAM,GAAG,GAAG;QACV,EAAE,EAAE,SAAS,CAAC,EAAE;QAChB,eAAe,EAAE,SAAS,CAAC,kBAAkB,EAAE;KAChD,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE;QACjD,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,OAAO,EAAE,GAAG,CAAC,eAAe;KACL,CAAC,CAAC;IAC3B,MAAM,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityData, EntityManager, EntityName } from '@mikro-orm/core';
|
|
2
|
-
import { type VersionedAggregate } from './conditioned-write';
|
|
2
|
+
import { type VersionedAggregate } from './conditioned-write.js';
|
|
3
3
|
/**
|
|
4
4
|
* Executes a single, version-conditioned, autocommitted SQL `UPDATE` statement on an aggregate entity.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistic-update.d.ts","sourceRoot":"","sources":["../../src/concurrency/optimistic-update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"optimistic-update.d.ts","sourceRoot":"","sources":["../../src/concurrency/optimistic-update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,SAAS,kBAAkB,EACvE,EAAE,EAAE,aAAa,EACjB,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAC/B,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const assert_autocommit_1 = require("./assert-autocommit");
|
|
6
|
-
const conditioned_write_1 = require("./conditioned-write");
|
|
2
|
+
import { assertAutocommit } from './assert-autocommit.js';
|
|
3
|
+
import { expectOneRow } from './conditioned-write.js';
|
|
7
4
|
/**
|
|
8
5
|
* Executes a single, version-conditioned, autocommitted SQL `UPDATE` statement on an aggregate entity.
|
|
9
6
|
*
|
|
@@ -51,10 +48,10 @@ const conditioned_write_1 = require("./conditioned-write");
|
|
|
51
48
|
* }
|
|
52
49
|
* ```
|
|
53
50
|
*/
|
|
54
|
-
async function optimisticUpdate(em, entityType, entity, data, entityName) {
|
|
55
|
-
|
|
51
|
+
export async function optimisticUpdate(em, entityType, entity, data, entityName) {
|
|
52
|
+
assertAutocommit(em, 'optimisticUpdate');
|
|
56
53
|
const row = { id: entity.id, expectedVersion: entity.getExpectedVersion() };
|
|
57
54
|
const affected = await em.nativeUpdate(entityType, { id: row.id, version: row.expectedVersion }, { ...data, version: entity.version });
|
|
58
|
-
await
|
|
55
|
+
await expectOneRow(affected, em, entityType, row, entityName, 'updated');
|
|
59
56
|
}
|
|
60
57
|
//# sourceMappingURL=optimistic-update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistic-update.js","sourceRoot":"","sources":["../../src/concurrency/optimistic-update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optimistic-update.js","sourceRoot":"","sources":["../../src/concurrency/optimistic-update.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAQtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,EAAiB,EACjB,UAA+B,EAC/B,MAAe,EACf,IAAyB,EACzB,UAAkB;IAElB,gBAAgB,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACzC,MAAM,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,kBAAkB,EAAE,EAAE,CAAC;IAC5E,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,YAAY,CACpC,UAAU,EACV,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,eAAe,EAA0B,EACpE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAyB,CAC5D,CAAC;IACF,MAAM,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
exports.MikroOrmDialect = void 0;
|
|
5
|
-
const core_1 = require("@mikro-orm/core");
|
|
2
|
+
import { UniqueConstraintViolationException, } from '@mikro-orm/core';
|
|
6
3
|
const SQLITE_COLUMNS = /UNIQUE constraint failed: (.+)$/m;
|
|
7
4
|
function constraintsOf(meta, naming) {
|
|
8
5
|
const describe = (key, properties, name) => {
|
|
@@ -63,7 +60,7 @@ function assertDistinctColumns(meta, constraints) {
|
|
|
63
60
|
* setPersistenceDialect(new MikroOrmDialect(orm));
|
|
64
61
|
* ```
|
|
65
62
|
*/
|
|
66
|
-
class MikroOrmDialect {
|
|
63
|
+
export class MikroOrmDialect {
|
|
67
64
|
constraints = new Map();
|
|
68
65
|
metadata;
|
|
69
66
|
constructor(orm) {
|
|
@@ -78,7 +75,7 @@ class MikroOrmDialect {
|
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
uniqueViolation(error, entity) {
|
|
81
|
-
if (!(error instanceof
|
|
78
|
+
if (!(error instanceof UniqueConstraintViolationException))
|
|
82
79
|
return undefined;
|
|
83
80
|
const meta = this.metadata.find(entity.constructor);
|
|
84
81
|
const constraints = meta ? this.constraints.get(meta) : undefined;
|
|
@@ -92,5 +89,4 @@ class MikroOrmDialect {
|
|
|
92
89
|
return constraints.find((unique) => unique.columns === columns)?.key;
|
|
93
90
|
}
|
|
94
91
|
}
|
|
95
|
-
exports.MikroOrmDialect = MikroOrmDialect;
|
|
96
92
|
//# sourceMappingURL=mikro-orm.dialect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mikro-orm.dialect.js","sourceRoot":"","sources":["../../src/errors/mikro-orm.dialect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mikro-orm.dialect.js","sourceRoot":"","sources":["../../src/errors/mikro-orm.dialect.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAGtE,OAAO,EAKL,kCAAkC,GACnC,MAAM,iBAAiB,CAAC;AAWzB,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAE1D,SAAS,aAAa,CACpB,IAAoB,EACpB,MAAsB;IAEtB,MAAM,QAAQ,GAAG,CACf,GAAW,EACX,UAAoB,EACpB,IAAwB,EACN,EAAE;QACpB,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAC/B,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,CACnD,CAAC;QACF,OAAO;YACL,GAAG;YACH,IAAI,EAAE,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;YAChE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;SACxE,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;SAC/C,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;SACrC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChB,QAAQ,CACN,QAAQ,CAAC,IAAI,EACb,CAAC,QAAQ,CAAC,IAAI,CAAC,EACf,OAAO,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAClE,CAC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,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/D,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,EAAE,GAAG,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
exports.isTransientPersistenceError = isTransientPersistenceError;
|
|
5
|
-
exports.mapPersistenceError = mapPersistenceError;
|
|
6
|
-
const domain_1 = require("@cqrs-ddd/core/domain");
|
|
2
|
+
import { TransientOperationError } from '@cqrs-ddd/core/domain';
|
|
7
3
|
const TRANSIENT_CODES = new Set([
|
|
8
4
|
'40001', // PostgreSQL serialization failure
|
|
9
5
|
'40P01', // PostgreSQL deadlock
|
|
@@ -36,7 +32,7 @@ const TRANSIENT_CODES = new Set([
|
|
|
36
32
|
* or when its `name` is `TaskCancelledError` or `TimeoutError`. A wrapped error
|
|
37
33
|
* is classified through its `cause` chain, which may be cyclic.
|
|
38
34
|
*/
|
|
39
|
-
function isTransientPersistenceError(error) {
|
|
35
|
+
export function isTransientPersistenceError(error) {
|
|
40
36
|
const seen = new Set();
|
|
41
37
|
let current = error;
|
|
42
38
|
while (current && typeof current === 'object' && !seen.has(current)) {
|
|
@@ -89,9 +85,9 @@ function isTransientPersistenceError(error) {
|
|
|
89
85
|
* }
|
|
90
86
|
* ```
|
|
91
87
|
*/
|
|
92
|
-
function mapPersistenceError(error, operation) {
|
|
88
|
+
export function mapPersistenceError(error, operation) {
|
|
93
89
|
return isTransientPersistenceError(error)
|
|
94
|
-
? new
|
|
90
|
+
? new TransientOperationError(`Transient persistence failure while ${operation}.`, { cause: error })
|
|
95
91
|
: error;
|
|
96
92
|
}
|
|
97
93
|
//# sourceMappingURL=transient-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transient-error.js","sourceRoot":"","sources":["../../src/errors/transient-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transient-error.js","sourceRoot":"","sources":["../../src/errors/transient-error.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,OAAO,EAAE,mCAAmC;IAC5C,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EAAE,gCAAgC;IACzC,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,gCAAgC;IACzC,cAAc;IACd,YAAY;IACZ,cAAc;IACd,aAAa;IACb,OAAO;IACP,WAAW;IACX,aAAa;IACb,eAAe;CAChB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACxD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,OAAO,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACpE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,MAAM,SAAS,GAAG,OAIjB,CAAC;QACF,MAAM,IAAI,GAAG,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,IACE,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;YACzB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,wCAAwC;YACjE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,yCAAyC;UAC/D,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IACE,SAAS,CAAC,IAAI,KAAK,oBAAoB;YACvC,SAAS,CAAC,IAAI,KAAK,cAAc,EACjC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC;IAC5B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAc,EACd,SAAiB;IAEjB,OAAO,2BAA2B,CAAC,KAAK,CAAC;QACvC,CAAC,CAAC,IAAI,uBAAuB,CACzB,uCAAuC,SAAS,GAAG,EACnD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB;QACH,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.isSqlIdentifier = isSqlIdentifier;
|
|
5
2
|
const NAME = '[A-Za-z_][A-Za-z0-9_]*';
|
|
6
3
|
const UNQUALIFIED = new RegExp(`^${NAME}$`);
|
|
7
4
|
const QUALIFIED = new RegExp(`^${NAME}(\\.${NAME})?$`);
|
|
@@ -17,7 +14,7 @@ const QUALIFIED = new RegExp(`^${NAME}(\\.${NAME})?$`);
|
|
|
17
14
|
* isSqlIdentifier('app.cache', { qualified: true }); // true
|
|
18
15
|
* ```
|
|
19
16
|
*/
|
|
20
|
-
function isSqlIdentifier(name, options = {}) {
|
|
17
|
+
export function isSqlIdentifier(name, options = {}) {
|
|
21
18
|
return (options.qualified ? QUALIFIED : UNQUALIFIED).test(name);
|
|
22
19
|
}
|
|
23
20
|
//# sourceMappingURL=sql-identifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-identifier.js","sourceRoot":"","sources":["../../src/helpers/sql-identifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql-identifier.js","sourceRoot":"","sources":["../../src/helpers/sql-identifier.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;AAC5C,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,CAAC,CAAC;AAQvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAAO,GAAyB,EAAE;IAElC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from './cache/cache-entry';
|
|
2
|
-
export * from './cache/mikro-orm.cache';
|
|
3
|
-
export * from './concurrency/assert-autocommit';
|
|
4
|
-
export * from './concurrency/optimistic-delete';
|
|
5
|
-
export * from './concurrency/optimistic-update';
|
|
6
|
-
export * from './errors/mikro-orm.dialect';
|
|
7
|
-
export * from './errors/transient-error';
|
|
8
|
-
export * from './helpers/sql-identifier';
|
|
9
|
-
export * from './interfaces/entity-manager-source';
|
|
10
|
-
export * from './mapping/root-entity.properties';
|
|
11
|
-
export * from './mapping/unix-timestamp.type';
|
|
12
|
-
export * from './repository/aggregate.repository';
|
|
13
|
-
export * from './tenancy/tenant-store';
|
|
1
|
+
export * from './cache/cache-entry.js';
|
|
2
|
+
export * from './cache/mikro-orm.cache.js';
|
|
3
|
+
export * from './concurrency/assert-autocommit.js';
|
|
4
|
+
export * from './concurrency/optimistic-delete.js';
|
|
5
|
+
export * from './concurrency/optimistic-update.js';
|
|
6
|
+
export * from './errors/mikro-orm.dialect.js';
|
|
7
|
+
export * from './errors/transient-error.js';
|
|
8
|
+
export * from './helpers/sql-identifier.js';
|
|
9
|
+
export * from './interfaces/entity-manager-source.js';
|
|
10
|
+
export * from './mapping/root-entity.properties.js';
|
|
11
|
+
export * from './mapping/unix-timestamp.type.js';
|
|
12
|
+
export * from './repository/aggregate.repository.js';
|
|
13
|
+
export * from './tenancy/tenant-store.js';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./cache/cache-entry"), exports);
|
|
19
|
-
__exportStar(require("./cache/mikro-orm.cache"), exports);
|
|
20
|
-
__exportStar(require("./concurrency/assert-autocommit"), exports);
|
|
21
|
-
__exportStar(require("./concurrency/optimistic-delete"), exports);
|
|
22
|
-
__exportStar(require("./concurrency/optimistic-update"), exports);
|
|
23
|
-
__exportStar(require("./errors/mikro-orm.dialect"), exports);
|
|
24
|
-
__exportStar(require("./errors/transient-error"), exports);
|
|
25
|
-
__exportStar(require("./helpers/sql-identifier"), exports);
|
|
26
|
-
__exportStar(require("./interfaces/entity-manager-source"), exports);
|
|
27
|
-
__exportStar(require("./mapping/root-entity.properties"), exports);
|
|
28
|
-
__exportStar(require("./mapping/unix-timestamp.type"), exports);
|
|
29
|
-
__exportStar(require("./repository/aggregate.repository"), exports);
|
|
30
|
-
__exportStar(require("./tenancy/tenant-store"), exports);
|
|
2
|
+
export * from './cache/cache-entry.js';
|
|
3
|
+
export * from './cache/mikro-orm.cache.js';
|
|
4
|
+
export * from './concurrency/assert-autocommit.js';
|
|
5
|
+
export * from './concurrency/optimistic-delete.js';
|
|
6
|
+
export * from './concurrency/optimistic-update.js';
|
|
7
|
+
export * from './errors/mikro-orm.dialect.js';
|
|
8
|
+
export * from './errors/transient-error.js';
|
|
9
|
+
export * from './helpers/sql-identifier.js';
|
|
10
|
+
export * from './interfaces/entity-manager-source.js';
|
|
11
|
+
export * from './mapping/root-entity.properties.js';
|
|
12
|
+
export * from './mapping/unix-timestamp.type.js';
|
|
13
|
+
export * from './repository/aggregate.repository.js';
|
|
14
|
+
export * from './tenancy/tenant-store.js';
|
|
31
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-manager-source.js","sourceRoot":"","sources":["../../src/interfaces/entity-manager-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity-manager-source.js","sourceRoot":"","sources":["../../src/interfaces/entity-manager-source.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-entity.properties.d.ts","sourceRoot":"","sources":["../../src/mapping/root-entity.properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"root-entity.properties.d.ts","sourceRoot":"","sources":["../../src/mapping/root-entity.properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,sBAAsB;IACtB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,iBAAsB;aAEhE,EAAE;iBACA,IAAI,EAAE,QAAQ;iBACd,OAAO;iBACP,SAAS;iBACT,QAAQ;;aAEV,SAAS;iBACP,IAAI;iBACJ,SAAS;iBACT,QAAQ;;aAEV,SAAS;iBACP,IAAI;iBACJ,SAAS;iBACT,QAAQ;;EAGb;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAY;aAE9C,IAAI,EAAE,QAAQ;aACd,SAAS;aACT,OAAO,EAAE,CAAC;aACV,QAAQ;aACR,OAAO;EAEV"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
|
|
4
|
-
exports.rootEntityProperties = rootEntityProperties;
|
|
5
|
-
exports.versionProperty = versionProperty;
|
|
6
|
-
const unix_timestamp_type_1 = require("./unix-timestamp.type");
|
|
2
|
+
import { UnixTimestampType } from './unix-timestamp.type.js';
|
|
7
3
|
/**
|
|
8
4
|
* Identity and timestamp columns shared by every `RootEntity` schema, mapped
|
|
9
5
|
* through the entity's private hydration setters (`accessor: true`). Timestamps
|
|
@@ -25,7 +21,7 @@ const unix_timestamp_type_1 = require("./unix-timestamp.type");
|
|
|
25
21
|
* });
|
|
26
22
|
* ```
|
|
27
23
|
*/
|
|
28
|
-
function rootEntityProperties(columns = {}) {
|
|
24
|
+
export function rootEntityProperties(columns = {}) {
|
|
29
25
|
return {
|
|
30
26
|
id: {
|
|
31
27
|
type: 'string',
|
|
@@ -34,12 +30,12 @@ function rootEntityProperties(columns = {}) {
|
|
|
34
30
|
accessor: true,
|
|
35
31
|
},
|
|
36
32
|
createdAt: {
|
|
37
|
-
type:
|
|
33
|
+
type: UnixTimestampType,
|
|
38
34
|
fieldName: columns.createdAt ?? 'created_at',
|
|
39
35
|
accessor: true,
|
|
40
36
|
},
|
|
41
37
|
updatedAt: {
|
|
42
|
-
type:
|
|
38
|
+
type: UnixTimestampType,
|
|
43
39
|
fieldName: columns.updatedAt ?? 'updated_at',
|
|
44
40
|
accessor: true,
|
|
45
41
|
},
|
|
@@ -51,7 +47,7 @@ function rootEntityProperties(columns = {}) {
|
|
|
51
47
|
*
|
|
52
48
|
* @param column - Column name. Default `'version'`.
|
|
53
49
|
*/
|
|
54
|
-
function versionProperty(column = 'version') {
|
|
50
|
+
export function versionProperty(column = 'version') {
|
|
55
51
|
return {
|
|
56
52
|
type: 'number',
|
|
57
53
|
fieldName: column,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-entity.properties.js","sourceRoot":"","sources":["../../src/mapping/root-entity.properties.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"root-entity.properties.js","sourceRoot":"","sources":["../../src/mapping/root-entity.properties.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAY7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAO,GAAsB,EAAE;IAClE,OAAO;QACL,EAAE,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,IAAI;YAC7B,QAAQ,EAAE,IAAI;SACf;QACD,SAAS,EAAE;YACT,IAAI,EAAE,iBAAiB;YACvB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,YAAY;YAC5C,QAAQ,EAAE,IAAI;SACf;QACD,SAAS,EAAE;YACT,IAAI,EAAE,iBAAiB;YACvB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,YAAY;YAC5C,QAAQ,EAAE,IAAI;SACf;KACO,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAM,GAAG,SAAS;IAChD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,MAAM;QACjB,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACL,CAAC;AACb,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnixTimestampType = void 0;
|
|
4
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
5
|
-
|
|
2
|
+
import { Type, } from '@mikro-orm/core';
|
|
6
3
|
/**
|
|
7
4
|
* Converts a timestamp value to epoch milliseconds, or throws.
|
|
8
5
|
*
|
|
@@ -35,7 +32,7 @@ function toEpochMilliseconds(value) {
|
|
|
35
32
|
* valid time throws a `TypeError` rather than being stored or returned as
|
|
36
33
|
* `NaN`.
|
|
37
34
|
*/
|
|
38
|
-
class UnixTimestampType extends
|
|
35
|
+
export class UnixTimestampType extends Type {
|
|
39
36
|
convertToDatabaseValue(value, _platform, _context) {
|
|
40
37
|
if (value == null)
|
|
41
38
|
return value;
|
|
@@ -51,5 +48,4 @@ class UnixTimestampType extends core_1.Type {
|
|
|
51
48
|
return platform ? platform.getBigIntTypeDeclarationSQL(prop) : 'bigint';
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
exports.UnixTimestampType = UnixTimestampType;
|
|
55
51
|
//# sourceMappingURL=unix-timestamp.type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unix-timestamp.type.js","sourceRoot":"","sources":["../../src/mapping/unix-timestamp.type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unix-timestamp.type.js","sourceRoot":"","sources":["../../src/mapping/unix-timestamp.type.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAIL,IAAI,GACL,MAAM,iBAAiB,CAAC;AAIzB;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC;IAC9B,IAAI,KAAK,YAAY,IAAI;QAAE,YAAY,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;SACrD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,YAAY,GAAG,KAAK,CAAC;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CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC1E,CAAC;CACF"}
|
|
@@ -2,7 +2,7 @@ import type { ICache, IWriteSideAggregateRepository } from '@cqrs-ddd/core/appli
|
|
|
2
2
|
import type { RootEntity, RootEntitySnapshot } from '@cqrs-ddd/core/domain';
|
|
3
3
|
import { CommandRepository } from '@cqrs-ddd/core/persistence';
|
|
4
4
|
import type { EntityName } from '@mikro-orm/core';
|
|
5
|
-
import type { IEntityManagerSource } from '../interfaces/entity-manager-source';
|
|
5
|
+
import type { IEntityManagerSource } from '../interfaces/entity-manager-source.js';
|
|
6
6
|
/**
|
|
7
7
|
* Base class for the command repositories that load and save an existing aggregate.
|
|
8
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.repository.d.ts","sourceRoot":"","sources":["../../src/repository/aggregate.repository.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EACL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"aggregate.repository.d.ts","sourceRoot":"","sources":["../../src/repository/aggregate.repository.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EACL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,8BAAsB,mBAAmB,CACrC,SAAS,SAAS,OAAO,CAAC,kBAAkB,CAAC,EAC7C,OAAO,SAAS,UAAU,CAAC,SAAS,CAAC,EACrC,OAAO,GAAG,OAAO,CAEnB,SAAQ,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CACrD,YAAW,6BAA6B,CAAC,OAAO,CAAC;IAI/C,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,oBAAoB;IAC9C,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM;IACxC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO;IALhE,YACE,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,EACL,KAAK,EAAE,oBAAoB,EAC3B,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO,EAG/D;IAED;;;;;;;;;;;OAWG;IAYG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAalD;CACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -9,10 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
9
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
10
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const persistence_1 = require("@cqrs-ddd/core/persistence");
|
|
15
|
-
const transient_error_1 = require("../errors/transient-error");
|
|
11
|
+
import { CommandRepository, MapPersistenceErrors, } from '@cqrs-ddd/core/persistence';
|
|
12
|
+
import { mapPersistenceError } from '../errors/transient-error.js';
|
|
16
13
|
/**
|
|
17
14
|
* Base class for the command repositories that load and save an existing aggregate.
|
|
18
15
|
*
|
|
@@ -55,7 +52,7 @@ const transient_error_1 = require("../errors/transient-error");
|
|
|
55
52
|
* }
|
|
56
53
|
* ```
|
|
57
54
|
*/
|
|
58
|
-
class AggregateRepository extends
|
|
55
|
+
export class AggregateRepository extends CommandRepository {
|
|
59
56
|
store;
|
|
60
57
|
entityClass;
|
|
61
58
|
aggregateName;
|
|
@@ -88,12 +85,11 @@ class AggregateRepository extends persistence_1.CommandRepository {
|
|
|
88
85
|
return this.hydrateFn(snapshot);
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
|
-
exports.AggregateRepository = AggregateRepository;
|
|
92
88
|
__decorate([
|
|
93
|
-
|
|
89
|
+
MapPersistenceErrors({
|
|
94
90
|
entity: ([id]) => id,
|
|
95
91
|
otherwise(error, id) {
|
|
96
|
-
return
|
|
92
|
+
return mapPersistenceError(error, `loading ${this.aggregateName} ${id}`);
|
|
97
93
|
},
|
|
98
94
|
}),
|
|
99
95
|
__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.repository.js","sourceRoot":"","sources":["../../src/repository/aggregate.repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aggregate.repository.js","sourceRoot":"","sources":["../../src/repository/aggregate.repository.ts"],"names":[],"mappings":"AAAA,sEAAsE;;;;;;;;;;AAOtE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAgB,mBAKpB,SAAQ,iBAA8C;IAKjC,KAAK;IACL,WAAW;IACX,aAAa;IACb,SAAS;IAL9B,YACE,KAAwB,EACL,KAA2B,EAC3B,WAAgC,EAChC,aAAqB,EACrB,SAA2C;QAE9D,KAAK,CAAC,KAAK,CAAC,CAAC;qBALM,KAAK;2BACL,WAAW;6BACX,aAAa;yBACb,SAAS;IAG9B,CAAC;IAED;;;;;;;;;;;OAWG;IAYG,AAAN,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CACxC,IAAI,CAAC,WAAW,EAChB,EAAE,EAAE,EAA0B,EAC9B,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAe,CAAC;QAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;CACF;AAdO;IAXL,oBAAoB,CAKnB;QACA,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE;QACpB,SAAS,CAAC,KAAK,EAAE,EAAE;YACjB,OAAO,mBAAmB,CAAC,KAAK,EAAE,WAAW,IAAI,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC;KACF,CAAC;;;;mDAcD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityManager, MikroORM } from '@mikro-orm/core';
|
|
2
|
-
import type { IEntityManagerSource } from '../interfaces/entity-manager-source';
|
|
2
|
+
import type { IEntityManagerSource } from '../interfaces/entity-manager-source.js';
|
|
3
3
|
/**
|
|
4
4
|
* How tenants are kept apart: `'database'` — one ORM per tenant, each on its own
|
|
5
5
|
* database; `'schema'` — one ORM, each tenant a schema of its database.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-store.d.ts","sourceRoot":"","sources":["../../src/tenancy/tenant-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tenant-store.d.ts","sourceRoot":"","sources":["../../src/tenancy/tenant-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEpD,sCAAsC;AACtC,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,MAAM,IAAI,MAAM,CAAC;IACjB,kFAAkF;IAClF,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B,SAAS,EAAE,eAAe,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAW,CAAC,QAAQ,SAAS,aAAa,GAAG,aAAa,CACrE,YAAW,oBAAoB;IAInB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAExD,YAA6B,OAAO,EAAE,kBAAkB,EAAI;IAE5D;;;;;OAKG;IACH,IAAI,EAAE,IAAI,QAAQ,CASjB;IAED;;;;;;;;;OASG;IACG,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAIrE;IAED,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,QAAQ;CAcjB"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TenantStore = void 0;
|
|
5
2
|
/**
|
|
6
3
|
* The `EntityManager` source of a multi-tenant application: `em` and
|
|
7
4
|
* `transactional()` always act on the active tenant's database or schema, for
|
|
@@ -24,7 +21,7 @@ exports.TenantStore = void 0;
|
|
|
24
21
|
* const repository = new UpdateUserRepository(cache, store);
|
|
25
22
|
* ```
|
|
26
23
|
*/
|
|
27
|
-
class TenantStore {
|
|
24
|
+
export class TenantStore {
|
|
28
25
|
options;
|
|
29
26
|
owners = new WeakMap();
|
|
30
27
|
constructor(options) {
|
|
@@ -79,7 +76,6 @@ class TenantStore {
|
|
|
79
76
|
context.getDriver() === orm.em.getDriver());
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
|
-
exports.TenantStore = TenantStore;
|
|
83
79
|
function contextOf(orm) {
|
|
84
80
|
try {
|
|
85
81
|
return orm.em.getContext(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-store.js","sourceRoot":"","sources":["../../src/tenancy/tenant-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tenant-store.js","sourceRoot":"","sources":["../../src/tenancy/tenant-store.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAoBtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,WAAW;IAKO,OAAO;IAFnB,MAAM,GAAG,IAAI,OAAO,EAAkB,CAAC;IAExD,YAA6B,OAA2B;uBAA3B,OAAO;IAAuB,CAAC;IAE5D;;;;;OAKG;IACH,IAAI,EAAE;QACJ,MAAM,MAAM,GAAG,IAA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C;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAEO,QAAQ,CACd,OAAsB,EACtB,GAAa,EACb,MAAc;QAEd,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,CACL,OAAO,KAAK,GAAG,CAAC,EAAE;YAClB,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,CAAC;YACzC,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC;YAC3D,OAAO,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;YAC7B,OAAO,CAAC,SAAS,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,CAC3C,CAAC;IACJ,CAAC;CACF;AAED,SAAS,SAAS,CAAC,GAAa;IAC9B,IAAI,CAAC;QACH,OAAO,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cqrs-ddd/mikro-orm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MikroORM persistence adapters for @cqrs-ddd/core: authoritative aggregate loading, version-conditioned writes, a revision-fenced cache and root-entity schema mapping.",
|
|
5
5
|
"author": "Aristotelis",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"engines": {
|
|
8
9
|
"node": ">=22.17.0"
|
|
9
10
|
},
|
|
@@ -24,6 +25,13 @@
|
|
|
24
25
|
"optimistic-concurrency",
|
|
25
26
|
"cache"
|
|
26
27
|
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
27
35
|
"main": "dist/index.js",
|
|
28
36
|
"types": "dist/index.d.ts",
|
|
29
37
|
"files": [
|
|
@@ -37,14 +45,14 @@
|
|
|
37
45
|
},
|
|
38
46
|
"peerDependencies": {
|
|
39
47
|
"@mikro-orm/core": "^7.2.1",
|
|
40
|
-
"@cqrs-ddd/core": "^0.
|
|
48
|
+
"@cqrs-ddd/core": "^0.4.0"
|
|
41
49
|
},
|
|
42
50
|
"devDependencies": {
|
|
43
51
|
"@mikro-orm/core": "^7.2.1",
|
|
44
52
|
"@vitest/coverage-v8": "^5.0.2",
|
|
45
53
|
"typescript": "^7.0.2",
|
|
46
54
|
"vitest": "^5.0.2",
|
|
47
|
-
"@cqrs-ddd/core": "^0.
|
|
55
|
+
"@cqrs-ddd/core": "^0.4.0"
|
|
48
56
|
},
|
|
49
57
|
"scripts": {
|
|
50
58
|
"build": "tsc -p tsconfig.build.json",
|