@dudousxd/nestjs-durable-store-mikro-orm 0.22.0 → 0.23.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/dist/index.cjs +69 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -2
- package/dist/index.d.ts +36 -2
- package/dist/index.js +56 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import * as _mikro_orm_core from '@mikro-orm/core';
|
|
2
|
-
import { EntitySchema, MikroORM } from '@mikro-orm/core';
|
|
2
|
+
import { EntityRepository, EntityRepositoryType, EntitySchema, MikroORM } from '@mikro-orm/core';
|
|
3
3
|
import { StepKind, RunStatus, StateStore, WorkflowRun, RetentionPolicy, StepCheckpoint, RunQuery, RunFacetQuery, RunFacetRow, SignalWaiter } from '@dudousxd/nestjs-durable-core';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Custom repositories for the durable entities, so a host app can `@InjectRepository`/inject a
|
|
7
|
+
* `WorkflowRunRepository` by type instead of repeating `em.find(WorkflowRunEntity, …)` with the
|
|
8
|
+
* entity class as the first argument everywhere.
|
|
9
|
+
*
|
|
10
|
+
* They are wired per-schema inside `durableEntities()` (not with a decorator), because that factory
|
|
11
|
+
* can be called more than once with different column naming and each call must produce schemas that
|
|
12
|
+
* still point at these classes. Each entity also declares `[EntityRepositoryType]`, which is what
|
|
13
|
+
* makes `em.getRepository(WorkflowRunEntity)` resolve to the specific type rather than the base
|
|
14
|
+
* `EntityRepository`.
|
|
15
|
+
*
|
|
16
|
+
* The bodies are intentionally empty: the durable engine's own queries go through
|
|
17
|
+
* `MikroOrmStateStore`, and a durable-owned query added here would be a second, unversioned read
|
|
18
|
+
* path over the same tables. They exist as an injectable, correctly-typed handle for host code.
|
|
19
|
+
*/
|
|
20
|
+
declare class WorkflowRunRepository extends EntityRepository<WorkflowRunEntity> {
|
|
21
|
+
}
|
|
22
|
+
declare class StepCheckpointRepository extends EntityRepository<StepCheckpointEntity> {
|
|
23
|
+
}
|
|
24
|
+
declare class RunAttributeRepository extends EntityRepository<RunAttributeEntity> {
|
|
25
|
+
}
|
|
26
|
+
declare class SignalWaiterRepository extends EntityRepository<SignalWaiterEntity> {
|
|
27
|
+
}
|
|
28
|
+
declare class BufferedSignalRepository extends EntityRepository<BufferedSignalEntity> {
|
|
29
|
+
}
|
|
30
|
+
declare class BufferedEventRepository extends EntityRepository<BufferedEventEntity> {
|
|
31
|
+
}
|
|
32
|
+
|
|
5
33
|
/**
|
|
6
34
|
* How property names map to physical column names. The durable tables are adapter-agnostic: a run
|
|
7
35
|
* written by one store adapter must be readable by another, so every adapter has to agree on the
|
|
@@ -16,6 +44,7 @@ import { StepKind, RunStatus, StateStore, WorkflowRun, RetentionPolicy, StepChec
|
|
|
16
44
|
*/
|
|
17
45
|
type DurableColumnNaming = 'snake_case' | 'preserve' | ((property: string) => string);
|
|
18
46
|
declare class WorkflowRunEntity {
|
|
47
|
+
[EntityRepositoryType]?: WorkflowRunRepository;
|
|
19
48
|
id: string;
|
|
20
49
|
workflow: string;
|
|
21
50
|
workflowVersion: string;
|
|
@@ -37,6 +66,7 @@ declare class WorkflowRunEntity {
|
|
|
37
66
|
updatedAt: Date;
|
|
38
67
|
}
|
|
39
68
|
declare class StepCheckpointEntity {
|
|
69
|
+
[EntityRepositoryType]?: StepCheckpointRepository;
|
|
40
70
|
runId: string;
|
|
41
71
|
seq: number;
|
|
42
72
|
name: string;
|
|
@@ -62,18 +92,21 @@ declare class StepCheckpointEntity {
|
|
|
62
92
|
* `numValue`, strings/booleans in `strValue` (booleans as "true"/"false"); see normalizeAttributeRows.
|
|
63
93
|
*/
|
|
64
94
|
declare class RunAttributeEntity {
|
|
95
|
+
[EntityRepositoryType]?: RunAttributeRepository;
|
|
65
96
|
runId: string;
|
|
66
97
|
key: string;
|
|
67
98
|
strValue?: string | null;
|
|
68
99
|
numValue?: number | null;
|
|
69
100
|
}
|
|
70
101
|
declare class SignalWaiterEntity {
|
|
102
|
+
[EntityRepositoryType]?: SignalWaiterRepository;
|
|
71
103
|
token: string;
|
|
72
104
|
runId: string;
|
|
73
105
|
seq: number;
|
|
74
106
|
parallelGroup?: string | null;
|
|
75
107
|
}
|
|
76
108
|
declare class BufferedSignalEntity {
|
|
109
|
+
[EntityRepositoryType]?: BufferedSignalRepository;
|
|
77
110
|
id: number;
|
|
78
111
|
token: string;
|
|
79
112
|
payload?: unknown;
|
|
@@ -82,6 +115,7 @@ declare class BufferedSignalEntity {
|
|
|
82
115
|
* caller-minted `id` (a uuid, not autoincrement — `removeBufferedEvent` targets it directly), not by
|
|
83
116
|
* `runId`: events are name-based pub/sub, not tied to any one run. */
|
|
84
117
|
declare class BufferedEventEntity {
|
|
118
|
+
[EntityRepositoryType]?: BufferedEventRepository;
|
|
85
119
|
id: string;
|
|
86
120
|
name: string;
|
|
87
121
|
payload?: unknown;
|
|
@@ -254,4 +288,4 @@ declare function durableManagedTables(): string[];
|
|
|
254
288
|
*/
|
|
255
289
|
declare function ensureMikroOrmDurableSchema(orm: MikroORM): Promise<void>;
|
|
256
290
|
|
|
257
|
-
export { BufferedEventEntity, BufferedSignalEntity, type DurableColumnNaming, ENTITIES, MikroOrmStateStore, type MikroOrmStateStoreOptions, RunAttributeEntity, SignalWaiterEntity, StepCheckpointEntity, WorkflowRunEntity, durableEntities, durableManagedTables, ensureMikroOrmDurableSchema };
|
|
291
|
+
export { BufferedEventEntity, BufferedEventRepository, BufferedSignalEntity, BufferedSignalRepository, type DurableColumnNaming, ENTITIES, MikroOrmStateStore, type MikroOrmStateStoreOptions, RunAttributeEntity, RunAttributeRepository, SignalWaiterEntity, SignalWaiterRepository, StepCheckpointEntity, StepCheckpointRepository, WorkflowRunEntity, WorkflowRunRepository, durableEntities, durableManagedTables, ensureMikroOrmDurableSchema };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,42 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/entities.ts
|
|
5
|
-
import { EntitySchema } from "@mikro-orm/core";
|
|
5
|
+
import { EntityRepositoryType, EntitySchema } from "@mikro-orm/core";
|
|
6
|
+
|
|
7
|
+
// src/repositories.ts
|
|
8
|
+
import { EntityRepository } from "@mikro-orm/core";
|
|
9
|
+
var WorkflowRunRepository = class extends EntityRepository {
|
|
10
|
+
static {
|
|
11
|
+
__name(this, "WorkflowRunRepository");
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var StepCheckpointRepository = class extends EntityRepository {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "StepCheckpointRepository");
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var RunAttributeRepository = class extends EntityRepository {
|
|
20
|
+
static {
|
|
21
|
+
__name(this, "RunAttributeRepository");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var SignalWaiterRepository = class extends EntityRepository {
|
|
25
|
+
static {
|
|
26
|
+
__name(this, "SignalWaiterRepository");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var BufferedSignalRepository = class extends EntityRepository {
|
|
30
|
+
static {
|
|
31
|
+
__name(this, "BufferedSignalRepository");
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var BufferedEventRepository = class extends EntityRepository {
|
|
35
|
+
static {
|
|
36
|
+
__name(this, "BufferedEventRepository");
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/entities.ts
|
|
6
41
|
function snakeCase(property) {
|
|
7
42
|
return property.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
8
43
|
}
|
|
@@ -17,6 +52,7 @@ var WorkflowRunEntity = class {
|
|
|
17
52
|
static {
|
|
18
53
|
__name(this, "WorkflowRunEntity");
|
|
19
54
|
}
|
|
55
|
+
[EntityRepositoryType];
|
|
20
56
|
id;
|
|
21
57
|
workflow;
|
|
22
58
|
workflowVersion;
|
|
@@ -41,6 +77,7 @@ var StepCheckpointEntity = class {
|
|
|
41
77
|
static {
|
|
42
78
|
__name(this, "StepCheckpointEntity");
|
|
43
79
|
}
|
|
80
|
+
[EntityRepositoryType];
|
|
44
81
|
runId;
|
|
45
82
|
seq;
|
|
46
83
|
name;
|
|
@@ -63,6 +100,7 @@ var RunAttributeEntity = class {
|
|
|
63
100
|
static {
|
|
64
101
|
__name(this, "RunAttributeEntity");
|
|
65
102
|
}
|
|
103
|
+
[EntityRepositoryType];
|
|
66
104
|
runId;
|
|
67
105
|
key;
|
|
68
106
|
strValue;
|
|
@@ -72,6 +110,7 @@ var SignalWaiterEntity = class {
|
|
|
72
110
|
static {
|
|
73
111
|
__name(this, "SignalWaiterEntity");
|
|
74
112
|
}
|
|
113
|
+
[EntityRepositoryType];
|
|
75
114
|
token;
|
|
76
115
|
runId;
|
|
77
116
|
seq;
|
|
@@ -81,6 +120,7 @@ var BufferedSignalEntity = class {
|
|
|
81
120
|
static {
|
|
82
121
|
__name(this, "BufferedSignalEntity");
|
|
83
122
|
}
|
|
123
|
+
[EntityRepositoryType];
|
|
84
124
|
id;
|
|
85
125
|
token;
|
|
86
126
|
payload;
|
|
@@ -89,6 +129,7 @@ var BufferedEventEntity = class {
|
|
|
89
129
|
static {
|
|
90
130
|
__name(this, "BufferedEventEntity");
|
|
91
131
|
}
|
|
132
|
+
[EntityRepositoryType];
|
|
92
133
|
id;
|
|
93
134
|
name;
|
|
94
135
|
payload;
|
|
@@ -106,6 +147,9 @@ function durableEntities(options = {}) {
|
|
|
106
147
|
const workflowRuns = new EntitySchema({
|
|
107
148
|
class: WorkflowRunEntity,
|
|
108
149
|
tableName: "durable_workflow_runs",
|
|
150
|
+
// Wired per schema rather than once on the class: `durableEntities` can be called again with a
|
|
151
|
+
// different `naming`, and each call builds a distinct EntitySchema over the same class.
|
|
152
|
+
repository: /* @__PURE__ */ __name(() => WorkflowRunRepository, "repository"),
|
|
109
153
|
// Global filter: confines every read to the tenant's namespace when the store is scoped.
|
|
110
154
|
// The `cond` returns `{}` (no-op) when the `namespace` arg is `undefined`, so an unscoped
|
|
111
155
|
// (operator / control-plane) store sees all rows unchanged — existing behaviour is preserved.
|
|
@@ -269,6 +313,7 @@ function durableEntities(options = {}) {
|
|
|
269
313
|
const stepCheckpoints = new EntitySchema({
|
|
270
314
|
class: StepCheckpointEntity,
|
|
271
315
|
tableName: "durable_step_checkpoints",
|
|
316
|
+
repository: /* @__PURE__ */ __name(() => StepCheckpointRepository, "repository"),
|
|
272
317
|
properties: {
|
|
273
318
|
runId: {
|
|
274
319
|
type: "string",
|
|
@@ -357,6 +402,7 @@ function durableEntities(options = {}) {
|
|
|
357
402
|
const runAttributes = new EntitySchema({
|
|
358
403
|
class: RunAttributeEntity,
|
|
359
404
|
tableName: "durable_run_attributes",
|
|
405
|
+
repository: /* @__PURE__ */ __name(() => RunAttributeRepository, "repository"),
|
|
360
406
|
// The search-attribute EXISTS join (see the class docstring) pushes equality/range predicates down
|
|
361
407
|
// onto `(key, numValue)` / `(key, strValue)`; mirror the Prisma adapter so those scans stay indexed.
|
|
362
408
|
indexes: [
|
|
@@ -402,6 +448,7 @@ function durableEntities(options = {}) {
|
|
|
402
448
|
const signalWaiters = new EntitySchema({
|
|
403
449
|
class: SignalWaiterEntity,
|
|
404
450
|
tableName: "durable_signal_waiters",
|
|
451
|
+
repository: /* @__PURE__ */ __name(() => SignalWaiterRepository, "repository"),
|
|
405
452
|
properties: {
|
|
406
453
|
token: {
|
|
407
454
|
type: "string",
|
|
@@ -429,6 +476,7 @@ function durableEntities(options = {}) {
|
|
|
429
476
|
const bufferedSignals = new EntitySchema({
|
|
430
477
|
class: BufferedSignalEntity,
|
|
431
478
|
tableName: "durable_buffered_signals",
|
|
479
|
+
repository: /* @__PURE__ */ __name(() => BufferedSignalRepository, "repository"),
|
|
432
480
|
properties: {
|
|
433
481
|
id: {
|
|
434
482
|
type: "integer",
|
|
@@ -451,6 +499,7 @@ function durableEntities(options = {}) {
|
|
|
451
499
|
const bufferedEvents = new EntitySchema({
|
|
452
500
|
class: BufferedEventEntity,
|
|
453
501
|
tableName: "durable_buffered_events",
|
|
502
|
+
repository: /* @__PURE__ */ __name(() => BufferedEventRepository, "repository"),
|
|
454
503
|
// `(name, publishedAt)` serves both `listBufferedEvents`'s name-scoped scan and its oldest-first
|
|
455
504
|
// ordering in one index.
|
|
456
505
|
indexes: [
|
|
@@ -1361,13 +1410,19 @@ function fromCheckpointEntity(e) {
|
|
|
1361
1410
|
__name(fromCheckpointEntity, "fromCheckpointEntity");
|
|
1362
1411
|
export {
|
|
1363
1412
|
BufferedEventEntity,
|
|
1413
|
+
BufferedEventRepository,
|
|
1364
1414
|
BufferedSignalEntity,
|
|
1415
|
+
BufferedSignalRepository,
|
|
1365
1416
|
ENTITIES,
|
|
1366
1417
|
MikroOrmStateStore,
|
|
1367
1418
|
RunAttributeEntity,
|
|
1419
|
+
RunAttributeRepository,
|
|
1368
1420
|
SignalWaiterEntity,
|
|
1421
|
+
SignalWaiterRepository,
|
|
1369
1422
|
StepCheckpointEntity,
|
|
1423
|
+
StepCheckpointRepository,
|
|
1370
1424
|
WorkflowRunEntity,
|
|
1425
|
+
WorkflowRunRepository,
|
|
1371
1426
|
durableEntities,
|
|
1372
1427
|
durableManagedTables,
|
|
1373
1428
|
ensureMikroOrmDurableSchema
|