@ddd-ts-kit/drizzle 0.89.0 → 0.91.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.fr.md +8 -2
- package/README.md +6 -1
- package/dist/postgres/processes/drizzle-process-store.d.ts +18 -3
- package/dist/postgres/processes/drizzle-process-store.d.ts.map +1 -1
- package/dist/postgres/processes/drizzle-process-store.js +16 -7
- package/dist/postgres/processes/drizzle-process-store.js.map +1 -1
- package/dist/postgres/processes/processes-table.d.ts +21 -1
- package/dist/postgres/processes/processes-table.d.ts.map +1 -1
- package/dist/postgres/processes/processes-table.js +7 -2
- package/dist/postgres/processes/processes-table.js.map +1 -1
- package/package.json +5 -5
package/README.fr.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](README.md) · **Français**
|
|
2
|
-
<!-- translation-of: README.md sha256:
|
|
2
|
+
<!-- translation-of: README.md sha256:c08abec48ed9ea50 -->
|
|
3
3
|
|
|
4
4
|
# @ddd-ts-kit/drizzle
|
|
5
5
|
|
|
@@ -967,7 +967,7 @@ const unitOfWork = createDrizzleUnitOfWork(db);
|
|
|
967
967
|
export const kernel = kernelModule({
|
|
968
968
|
unitOfWork,
|
|
969
969
|
jobStore: new DrizzleJobStore(unitOfWork, schedulingJobs),
|
|
970
|
-
processStore: new DrizzleProcessStore(unitOfWork, schedulingProcesses),
|
|
970
|
+
processStore: new DrizzleProcessStore(unitOfWork, { table: schedulingProcesses }),
|
|
971
971
|
});
|
|
972
972
|
```
|
|
973
973
|
|
|
@@ -984,6 +984,12 @@ ne change aucune ligne lève `ConcurrencyError`, dans la transaction de l'étape
|
|
|
984
984
|
`processStoreContract`. L'exemple de [Jobs en arrière-plan](#jobs-en-arrière-plan) le lie avec
|
|
985
985
|
`kernelModule({ processStore })`.
|
|
986
986
|
|
|
987
|
+
Avec `tenant` (l'`ExecutionScope`), le store garde chaque instance dans le tenant du travail qui
|
|
988
|
+
l'enregistre : la table repère aussi une ligne par son tenant, le texte vide hors de tout tenant,
|
|
989
|
+
si bien que deux tenants peuvent utiliser la même clé de corrélation ; une instance d'un autre
|
|
990
|
+
tenant n'est ni trouvée ni modifiée, et un travail qui ne nomme aucun tenant est refusé par
|
|
991
|
+
`NoCurrentTenantError`.
|
|
992
|
+
|
|
987
993
|
## Tester un adaptateur
|
|
988
994
|
|
|
989
995
|
L'unité de travail de ce *package* passe `unitOfWorkContract`, et ses stores
|
package/README.md
CHANGED
|
@@ -939,7 +939,7 @@ const unitOfWork = createDrizzleUnitOfWork(db);
|
|
|
939
939
|
export const kernel = kernelModule({
|
|
940
940
|
unitOfWork,
|
|
941
941
|
jobStore: new DrizzleJobStore(unitOfWork, schedulingJobs),
|
|
942
|
-
processStore: new DrizzleProcessStore(unitOfWork, schedulingProcesses),
|
|
942
|
+
processStore: new DrizzleProcessStore(unitOfWork, { table: schedulingProcesses }),
|
|
943
943
|
});
|
|
944
944
|
```
|
|
945
945
|
|
|
@@ -955,6 +955,11 @@ save inserts, a next one updates at the previous version, and a save that change
|
|
|
955
955
|
`ConcurrencyError`, in the transaction of the step. It passes `processStoreContract`. The
|
|
956
956
|
sample of [Background jobs](#background-jobs) binds it with `kernelModule({ processStore })`.
|
|
957
957
|
|
|
958
|
+
With `tenant` (the `ExecutionScope`), the store keeps each instance in the tenant of the work that
|
|
959
|
+
saves it: the table keys a row by its tenant too, the empty text outside any, so two tenants may
|
|
960
|
+
use the same correlation key; an instance of another tenant is neither found nor changed, and
|
|
961
|
+
work that names no tenant is refused with `NoCurrentTenantError`.
|
|
962
|
+
|
|
958
963
|
## Testing an adapter
|
|
959
964
|
|
|
960
965
|
The unit of work of this package passes `unitOfWorkContract`, and its stores
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { type TablesRelationalConfig } from 'drizzle-orm';
|
|
2
2
|
import type { PgQueryResultHKT } from 'drizzle-orm/pg-core';
|
|
3
|
-
import { type ProcessStore, type StoredProcess } from '@ddd-ts-kit/kernel';
|
|
3
|
+
import { type ExecutionScope, type ProcessStore, type StoredProcess } from '@ddd-ts-kit/kernel';
|
|
4
4
|
import type { DrizzleContext } from '../unit-of-work/drizzle-context.js';
|
|
5
5
|
import { type ProcessesTable } from './processes-table.js';
|
|
6
|
+
export interface DrizzleProcessStoreOptions {
|
|
7
|
+
/** Default `processesTable()`, in the public schema. */
|
|
8
|
+
readonly table?: ProcessesTable;
|
|
9
|
+
/**
|
|
10
|
+
* Keeps each instance in the tenant of the work that saves it, in `tenant_id`: a step loads and
|
|
11
|
+
* changes the instances of its own tenant only, two tenants may use the same correlation key,
|
|
12
|
+
* and work that names no tenant is refused (`NoCurrentTenantError`). Left out, the instances
|
|
13
|
+
* are those of no tenant.
|
|
14
|
+
*/
|
|
15
|
+
readonly tenant?: ExecutionScope;
|
|
16
|
+
}
|
|
6
17
|
/**
|
|
7
18
|
* The instances of the process managers in PostgreSQL, on the executor of the context: a first
|
|
8
19
|
* save inserts, ignoring a row a concurrent first save wrote; a next one updates the row at the
|
|
9
|
-
* previous version; a save that changes no row is refused with `ConcurrencyError`.
|
|
20
|
+
* previous version; a save that changes no row is refused with `ConcurrencyError`. With `tenant`,
|
|
21
|
+
* an instance of another tenant is neither found nor changed, whoever knows its key.
|
|
10
22
|
*/
|
|
11
23
|
export declare class DrizzleProcessStore<Q extends PgQueryResultHKT, F extends Record<string, unknown>, S extends TablesRelationalConfig> implements ProcessStore {
|
|
12
24
|
private readonly context;
|
|
13
25
|
private readonly processes;
|
|
14
|
-
|
|
26
|
+
private readonly tenant;
|
|
27
|
+
constructor(context: DrizzleContext<Q, F, S>, options?: DrizzleProcessStoreOptions);
|
|
15
28
|
load(name: string, id: string): Promise<StoredProcess | undefined>;
|
|
16
29
|
save(process: StoredProcess): Promise<void>;
|
|
17
30
|
private insert;
|
|
18
31
|
private update;
|
|
32
|
+
/** The empty text outside any tenant, as the table keeps it. */
|
|
33
|
+
private tenantOfWork;
|
|
19
34
|
}
|
|
20
35
|
//# sourceMappingURL=drizzle-process-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drizzle-process-store.d.ts","sourceRoot":"","sources":["../../../src/postgres/processes/drizzle-process-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"drizzle-process-store.d.ts","sourceRoot":"","sources":["../../../src/postgres/processes/drizzle-process-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExE,MAAM,WAAW,0BAA0B;IACzC,wDAAwD;IACxD,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;CAClC;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB,CAC9B,CAAC,SAAS,gBAAgB,EAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,sBAAsB,CAChC,YAAW,YAAY;IAOrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAE3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IAEpD,YACmB,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACjD,OAAO,GAAE,0BAA+B,EAIzC;IAEK,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAevE;IAEK,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhD;YAEa,MAAM;YAaN,MAAM;IAqBpB,gEAAgE;IAChE,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { and, eq } from 'drizzle-orm';
|
|
2
|
-
import { ConcurrencyError } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { ConcurrencyError, tenantScopeOf, } from '@ddd-ts-kit/kernel';
|
|
3
3
|
import { processesTable } from './processes-table.js';
|
|
4
4
|
/**
|
|
5
5
|
* The instances of the process managers in PostgreSQL, on the executor of the context: a first
|
|
6
6
|
* save inserts, ignoring a row a concurrent first save wrote; a next one updates the row at the
|
|
7
|
-
* previous version; a save that changes no row is refused with `ConcurrencyError`.
|
|
7
|
+
* previous version; a save that changes no row is refused with `ConcurrencyError`. With `tenant`,
|
|
8
|
+
* an instance of another tenant is neither found nor changed, whoever knows its key.
|
|
8
9
|
*/
|
|
9
10
|
export class DrizzleProcessStore {
|
|
10
11
|
context;
|
|
11
12
|
processes;
|
|
12
|
-
|
|
13
|
+
tenant;
|
|
14
|
+
constructor(context, options = {}) {
|
|
13
15
|
this.context = context;
|
|
14
|
-
this.processes = table ?? processesTable();
|
|
16
|
+
this.processes = options.table ?? processesTable();
|
|
17
|
+
this.tenant = options.tenant;
|
|
15
18
|
}
|
|
16
19
|
async load(name, id) {
|
|
17
20
|
const { processes } = this;
|
|
@@ -24,7 +27,7 @@ export class DrizzleProcessStore {
|
|
|
24
27
|
timeouts: processes.timeouts,
|
|
25
28
|
})
|
|
26
29
|
.from(processes)
|
|
27
|
-
.where(and(eq(processes.name, name), eq(processes.id, id)));
|
|
30
|
+
.where(and(eq(processes.tenantId, this.tenantOfWork()), eq(processes.name, name), eq(processes.id, id)));
|
|
28
31
|
return row === undefined ? undefined : { name, id, ...row, timeouts: { ...row.timeouts } };
|
|
29
32
|
}
|
|
30
33
|
async save(process) {
|
|
@@ -34,23 +37,29 @@ export class DrizzleProcessStore {
|
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
async insert({ name, id, state, version, ended, timeouts }) {
|
|
40
|
+
const tenantId = this.tenantOfWork();
|
|
37
41
|
const inserted = await this.context
|
|
38
42
|
.executor()
|
|
39
43
|
.insert(this.processes)
|
|
40
|
-
.values({ name, id, state, version, ended, timeouts })
|
|
44
|
+
.values({ tenantId, name, id, state, version, ended, timeouts })
|
|
41
45
|
.onConflictDoNothing()
|
|
42
46
|
.returning({ id: this.processes.id });
|
|
43
47
|
return inserted.length;
|
|
44
48
|
}
|
|
45
49
|
async update({ name, id, state, version, ended, timeouts }) {
|
|
46
50
|
const { processes } = this;
|
|
51
|
+
const tenantId = this.tenantOfWork();
|
|
47
52
|
const updated = await this.context
|
|
48
53
|
.executor()
|
|
49
54
|
.update(processes)
|
|
50
55
|
.set({ state, version, ended, timeouts, updatedAt: new Date() })
|
|
51
|
-
.where(and(eq(processes.name, name), eq(processes.id, id), eq(processes.version, version - 1)))
|
|
56
|
+
.where(and(eq(processes.tenantId, tenantId), eq(processes.name, name), eq(processes.id, id), eq(processes.version, version - 1)))
|
|
52
57
|
.returning({ id: processes.id });
|
|
53
58
|
return updated.length;
|
|
54
59
|
}
|
|
60
|
+
/** The empty text outside any tenant, as the table keeps it. */
|
|
61
|
+
tenantOfWork() {
|
|
62
|
+
return this.tenant === undefined ? '' : tenantScopeOf(this.tenant).tenantId;
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
//# sourceMappingURL=drizzle-process-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drizzle-process-store.js","sourceRoot":"","sources":["../../../src/postgres/processes/drizzle-process-store.ts"],"names":[],"mappings":"AAAA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EAAE,QAAQ,EAAiB;QAC/E,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAErC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO;aAC/B,QAAQ,EAAE;aACV,MAAM,CAAC,SAAS,CAAC;aACjB,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC;aAC/D,KAAK,CACJ,GAAG,CACD,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAChC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EACxB,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EACpB,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,CACnC,CACF;aACA,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QAEnC,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC;IAED,gEAAgE;IACxD,YAAY;QAClB,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
export type ProcessesTable = ReturnType<typeof processesTable>;
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* The instances of the process managers of a context, to include in the schema files drizzle-kit
|
|
4
|
+
* reads: one row per tenant, process and correlation key, the tenant empty outside any tenant.
|
|
5
|
+
*/
|
|
3
6
|
export declare function processesTable(schemaName?: string): import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
7
|
name: "process_instances";
|
|
5
8
|
schema: string | undefined;
|
|
6
9
|
columns: {
|
|
10
|
+
tenantId: import("drizzle-orm/pg-core").PgColumn<{
|
|
11
|
+
name: "tenant_id";
|
|
12
|
+
tableName: "process_instances";
|
|
13
|
+
dataType: "string";
|
|
14
|
+
columnType: "PgText";
|
|
15
|
+
data: string;
|
|
16
|
+
driverParam: string;
|
|
17
|
+
notNull: true;
|
|
18
|
+
hasDefault: true;
|
|
19
|
+
isPrimaryKey: false;
|
|
20
|
+
isAutoincrement: false;
|
|
21
|
+
hasRuntimeDefault: false;
|
|
22
|
+
enumValues: [string, ...string[]];
|
|
23
|
+
baseColumn: never;
|
|
24
|
+
identity: undefined;
|
|
25
|
+
generated: undefined;
|
|
26
|
+
}, {}, {}>;
|
|
7
27
|
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
28
|
name: "name";
|
|
9
29
|
tableName: "process_instances";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processes-table.d.ts","sourceRoot":"","sources":["../../../src/postgres/processes/processes-table.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAE/D
|
|
1
|
+
{"version":3,"file":"processes-table.d.ts","sourceRoot":"","sources":["../../../src/postgres/processes/processes-table.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgBjD"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { boolean, integer, jsonb, primaryKey, text } from 'drizzle-orm/pg-core';
|
|
2
2
|
import { instant } from '../columns/instant.js';
|
|
3
3
|
import { tableIn } from '../schema/table-in.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The instances of the process managers of a context, to include in the schema files drizzle-kit
|
|
6
|
+
* reads: one row per tenant, process and correlation key, the tenant empty outside any tenant.
|
|
7
|
+
*/
|
|
5
8
|
export function processesTable(schemaName) {
|
|
6
9
|
return tableIn(schemaName)('process_instances', {
|
|
10
|
+
/** The empty text outside any tenant: a null could not be part of the primary key. */
|
|
11
|
+
tenantId: text('tenant_id').notNull().default(''),
|
|
7
12
|
name: text('name').notNull(),
|
|
8
13
|
id: text('id').notNull(),
|
|
9
14
|
state: jsonb('state'),
|
|
@@ -11,6 +16,6 @@ export function processesTable(schemaName) {
|
|
|
11
16
|
ended: boolean('ended').notNull().default(false),
|
|
12
17
|
timeouts: jsonb('timeouts').$type().notNull(),
|
|
13
18
|
updatedAt: instant('updated_at').notNull().defaultNow(),
|
|
14
|
-
}, (table) => [primaryKey({ columns: [table.name, table.id] })]);
|
|
19
|
+
}, (table) => [primaryKey({ columns: [table.tenantId, table.name, table.id] })]);
|
|
15
20
|
}
|
|
16
21
|
//# sourceMappingURL=processes-table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processes-table.js","sourceRoot":"","sources":["../../../src/postgres/processes/processes-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C
|
|
1
|
+
{"version":3,"file":"processes-table.js","sourceRoot":"","sources":["../../../src/postgres/processes/processes-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,UAAmB;IAChD,OAAO,OAAO,CAAC,UAAU,CAAC,CACxB,mBAAmB,EACnB;QACE,sFAAsF;QACtF,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;QAC5B,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE;QACxB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;QACrC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QAChD,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAA0B,CAAC,OAAO,EAAE;QACrE,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;KACxD,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/drizzle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.0",
|
|
4
4
|
"description": "Drizzle adapters for the kernel ports on PostgreSQL: unit of work, transactional outbox store, processed-event store, event store, background job store, process store, one schema per context.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddd",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@ddd-ts-kit/kernel": "0.
|
|
43
|
-
"@ddd-ts-kit/events": "0.
|
|
44
|
-
"@ddd-ts-kit/scheduling": "0.
|
|
42
|
+
"@ddd-ts-kit/kernel": "0.91.0",
|
|
43
|
+
"@ddd-ts-kit/events": "0.91.0",
|
|
44
|
+
"@ddd-ts-kit/scheduling": "0.91.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"drizzle-orm": ">=0.40.0"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"drizzle-orm": "latest",
|
|
51
51
|
"@electric-sql/pglite": "0.5.10",
|
|
52
|
-
"@ddd-ts-kit/testing": "0.
|
|
52
|
+
"@ddd-ts-kit/testing": "0.91.0",
|
|
53
53
|
"pg": "^8.23.1",
|
|
54
54
|
"@types/pg": "^8.23.1"
|
|
55
55
|
}
|