@dudousxd/nestjs-durable-store-mikro-orm 0.10.0 → 0.11.1
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 +270 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -7
- package/dist/index.d.ts +41 -7
- package/dist/index.js +269 -311
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,18 +2,17 @@ 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 {
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5
|
+
import { EntitySchema } from "@mikro-orm/core";
|
|
6
|
+
function snakeCase(property) {
|
|
7
|
+
return property.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
11
8
|
}
|
|
12
|
-
__name(
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
9
|
+
__name(snakeCase, "snakeCase");
|
|
10
|
+
function columnNamer(naming) {
|
|
11
|
+
if (naming === "snake_case") return snakeCase;
|
|
12
|
+
if (naming === "preserve") return (property) => property;
|
|
13
|
+
return naming;
|
|
15
14
|
}
|
|
16
|
-
__name(
|
|
15
|
+
__name(columnNamer, "columnNamer");
|
|
17
16
|
var WorkflowRunEntity = class {
|
|
18
17
|
static {
|
|
19
18
|
__name(this, "WorkflowRunEntity");
|
|
@@ -34,110 +33,6 @@ var WorkflowRunEntity = class {
|
|
|
34
33
|
createdAt;
|
|
35
34
|
updatedAt;
|
|
36
35
|
};
|
|
37
|
-
_ts_decorate([
|
|
38
|
-
PrimaryKey({
|
|
39
|
-
type: "string"
|
|
40
|
-
}),
|
|
41
|
-
_ts_metadata("design:type", String)
|
|
42
|
-
], WorkflowRunEntity.prototype, "id", void 0);
|
|
43
|
-
_ts_decorate([
|
|
44
|
-
Property({
|
|
45
|
-
type: "string"
|
|
46
|
-
}),
|
|
47
|
-
_ts_metadata("design:type", String)
|
|
48
|
-
], WorkflowRunEntity.prototype, "workflow", void 0);
|
|
49
|
-
_ts_decorate([
|
|
50
|
-
Property({
|
|
51
|
-
type: "string"
|
|
52
|
-
}),
|
|
53
|
-
_ts_metadata("design:type", String)
|
|
54
|
-
], WorkflowRunEntity.prototype, "workflowVersion", void 0);
|
|
55
|
-
_ts_decorate([
|
|
56
|
-
Property({
|
|
57
|
-
type: "string"
|
|
58
|
-
}),
|
|
59
|
-
_ts_metadata("design:type", typeof RunStatus === "undefined" ? Object : RunStatus)
|
|
60
|
-
], WorkflowRunEntity.prototype, "status", void 0);
|
|
61
|
-
_ts_decorate([
|
|
62
|
-
Property({
|
|
63
|
-
type: "json",
|
|
64
|
-
nullable: true
|
|
65
|
-
}),
|
|
66
|
-
_ts_metadata("design:type", Object)
|
|
67
|
-
], WorkflowRunEntity.prototype, "input", void 0);
|
|
68
|
-
_ts_decorate([
|
|
69
|
-
Property({
|
|
70
|
-
type: "json",
|
|
71
|
-
nullable: true
|
|
72
|
-
}),
|
|
73
|
-
_ts_metadata("design:type", Object)
|
|
74
|
-
], WorkflowRunEntity.prototype, "output", void 0);
|
|
75
|
-
_ts_decorate([
|
|
76
|
-
Property({
|
|
77
|
-
type: "json",
|
|
78
|
-
nullable: true
|
|
79
|
-
}),
|
|
80
|
-
_ts_metadata("design:type", Object)
|
|
81
|
-
], WorkflowRunEntity.prototype, "error", void 0);
|
|
82
|
-
_ts_decorate([
|
|
83
|
-
Property({
|
|
84
|
-
type: "Date",
|
|
85
|
-
nullable: true
|
|
86
|
-
}),
|
|
87
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
88
|
-
], WorkflowRunEntity.prototype, "wakeAt", void 0);
|
|
89
|
-
_ts_decorate([
|
|
90
|
-
Property({
|
|
91
|
-
type: "string",
|
|
92
|
-
nullable: true
|
|
93
|
-
}),
|
|
94
|
-
_ts_metadata("design:type", String)
|
|
95
|
-
], WorkflowRunEntity.prototype, "lockedBy", void 0);
|
|
96
|
-
_ts_decorate([
|
|
97
|
-
Property({
|
|
98
|
-
type: "Date",
|
|
99
|
-
nullable: true
|
|
100
|
-
}),
|
|
101
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
102
|
-
], WorkflowRunEntity.prototype, "lockedUntil", void 0);
|
|
103
|
-
_ts_decorate([
|
|
104
|
-
Property({
|
|
105
|
-
type: "integer",
|
|
106
|
-
nullable: true
|
|
107
|
-
}),
|
|
108
|
-
_ts_metadata("design:type", Number)
|
|
109
|
-
], WorkflowRunEntity.prototype, "recoveryAttempts", void 0);
|
|
110
|
-
_ts_decorate([
|
|
111
|
-
Property({
|
|
112
|
-
type: "json",
|
|
113
|
-
nullable: true
|
|
114
|
-
}),
|
|
115
|
-
_ts_metadata("design:type", Object)
|
|
116
|
-
], WorkflowRunEntity.prototype, "tags", void 0);
|
|
117
|
-
_ts_decorate([
|
|
118
|
-
Property({
|
|
119
|
-
type: "json",
|
|
120
|
-
nullable: true
|
|
121
|
-
}),
|
|
122
|
-
_ts_metadata("design:type", Object)
|
|
123
|
-
], WorkflowRunEntity.prototype, "searchAttributes", void 0);
|
|
124
|
-
_ts_decorate([
|
|
125
|
-
Property({
|
|
126
|
-
type: "Date"
|
|
127
|
-
}),
|
|
128
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
129
|
-
], WorkflowRunEntity.prototype, "createdAt", void 0);
|
|
130
|
-
_ts_decorate([
|
|
131
|
-
Property({
|
|
132
|
-
type: "Date"
|
|
133
|
-
}),
|
|
134
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
135
|
-
], WorkflowRunEntity.prototype, "updatedAt", void 0);
|
|
136
|
-
WorkflowRunEntity = _ts_decorate([
|
|
137
|
-
Entity({
|
|
138
|
-
tableName: "durable_workflow_runs"
|
|
139
|
-
})
|
|
140
|
-
], WorkflowRunEntity);
|
|
141
36
|
var StepCheckpointEntity = class {
|
|
142
37
|
static {
|
|
143
38
|
__name(this, "StepCheckpointEntity");
|
|
@@ -159,114 +54,6 @@ var StepCheckpointEntity = class {
|
|
|
159
54
|
startedAt;
|
|
160
55
|
finishedAt;
|
|
161
56
|
};
|
|
162
|
-
_ts_decorate([
|
|
163
|
-
PrimaryKey({
|
|
164
|
-
type: "string"
|
|
165
|
-
}),
|
|
166
|
-
_ts_metadata("design:type", String)
|
|
167
|
-
], StepCheckpointEntity.prototype, "runId", void 0);
|
|
168
|
-
_ts_decorate([
|
|
169
|
-
PrimaryKey({
|
|
170
|
-
type: "integer"
|
|
171
|
-
}),
|
|
172
|
-
_ts_metadata("design:type", Number)
|
|
173
|
-
], StepCheckpointEntity.prototype, "seq", void 0);
|
|
174
|
-
_ts_decorate([
|
|
175
|
-
Property({
|
|
176
|
-
type: "string"
|
|
177
|
-
}),
|
|
178
|
-
_ts_metadata("design:type", String)
|
|
179
|
-
], StepCheckpointEntity.prototype, "name", void 0);
|
|
180
|
-
_ts_decorate([
|
|
181
|
-
Property({
|
|
182
|
-
type: "string"
|
|
183
|
-
}),
|
|
184
|
-
_ts_metadata("design:type", typeof StepKind === "undefined" ? Object : StepKind)
|
|
185
|
-
], StepCheckpointEntity.prototype, "kind", void 0);
|
|
186
|
-
_ts_decorate([
|
|
187
|
-
Property({
|
|
188
|
-
type: "string"
|
|
189
|
-
}),
|
|
190
|
-
_ts_metadata("design:type", String)
|
|
191
|
-
], StepCheckpointEntity.prototype, "stepId", void 0);
|
|
192
|
-
_ts_decorate([
|
|
193
|
-
Property({
|
|
194
|
-
type: "string"
|
|
195
|
-
}),
|
|
196
|
-
_ts_metadata("design:type", String)
|
|
197
|
-
], StepCheckpointEntity.prototype, "status", void 0);
|
|
198
|
-
_ts_decorate([
|
|
199
|
-
Property({
|
|
200
|
-
type: "json",
|
|
201
|
-
nullable: true
|
|
202
|
-
}),
|
|
203
|
-
_ts_metadata("design:type", Object)
|
|
204
|
-
], StepCheckpointEntity.prototype, "input", void 0);
|
|
205
|
-
_ts_decorate([
|
|
206
|
-
Property({
|
|
207
|
-
type: "json",
|
|
208
|
-
nullable: true
|
|
209
|
-
}),
|
|
210
|
-
_ts_metadata("design:type", Object)
|
|
211
|
-
], StepCheckpointEntity.prototype, "output", void 0);
|
|
212
|
-
_ts_decorate([
|
|
213
|
-
Property({
|
|
214
|
-
type: "json",
|
|
215
|
-
nullable: true
|
|
216
|
-
}),
|
|
217
|
-
_ts_metadata("design:type", Object)
|
|
218
|
-
], StepCheckpointEntity.prototype, "error", void 0);
|
|
219
|
-
_ts_decorate([
|
|
220
|
-
Property({
|
|
221
|
-
type: "json",
|
|
222
|
-
nullable: true
|
|
223
|
-
}),
|
|
224
|
-
_ts_metadata("design:type", Object)
|
|
225
|
-
], StepCheckpointEntity.prototype, "events", void 0);
|
|
226
|
-
_ts_decorate([
|
|
227
|
-
Property({
|
|
228
|
-
type: "integer"
|
|
229
|
-
}),
|
|
230
|
-
_ts_metadata("design:type", Number)
|
|
231
|
-
], StepCheckpointEntity.prototype, "attempts", void 0);
|
|
232
|
-
_ts_decorate([
|
|
233
|
-
Property({
|
|
234
|
-
type: "string",
|
|
235
|
-
nullable: true
|
|
236
|
-
}),
|
|
237
|
-
_ts_metadata("design:type", String)
|
|
238
|
-
], StepCheckpointEntity.prototype, "workerGroup", void 0);
|
|
239
|
-
_ts_decorate([
|
|
240
|
-
Property({
|
|
241
|
-
type: "Date",
|
|
242
|
-
nullable: true
|
|
243
|
-
}),
|
|
244
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
245
|
-
], StepCheckpointEntity.prototype, "wakeAt", void 0);
|
|
246
|
-
_ts_decorate([
|
|
247
|
-
Property({
|
|
248
|
-
type: "Date",
|
|
249
|
-
nullable: true
|
|
250
|
-
}),
|
|
251
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
252
|
-
], StepCheckpointEntity.prototype, "enqueuedAt", void 0);
|
|
253
|
-
_ts_decorate([
|
|
254
|
-
Property({
|
|
255
|
-
type: "Date"
|
|
256
|
-
}),
|
|
257
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
258
|
-
], StepCheckpointEntity.prototype, "startedAt", void 0);
|
|
259
|
-
_ts_decorate([
|
|
260
|
-
Property({
|
|
261
|
-
type: "Date"
|
|
262
|
-
}),
|
|
263
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
264
|
-
], StepCheckpointEntity.prototype, "finishedAt", void 0);
|
|
265
|
-
StepCheckpointEntity = _ts_decorate([
|
|
266
|
-
Entity({
|
|
267
|
-
tableName: "durable_step_checkpoints"
|
|
268
|
-
})
|
|
269
|
-
], StepCheckpointEntity);
|
|
270
57
|
var RunAttributeEntity = class {
|
|
271
58
|
static {
|
|
272
59
|
__name(this, "RunAttributeEntity");
|
|
@@ -274,40 +61,8 @@ var RunAttributeEntity = class {
|
|
|
274
61
|
runId;
|
|
275
62
|
key;
|
|
276
63
|
strValue;
|
|
277
|
-
// `float`/`double` is portable across SQLite/MySQL/Postgres for numeric range scans.
|
|
278
64
|
numValue;
|
|
279
65
|
};
|
|
280
|
-
_ts_decorate([
|
|
281
|
-
PrimaryKey({
|
|
282
|
-
type: "string"
|
|
283
|
-
}),
|
|
284
|
-
_ts_metadata("design:type", String)
|
|
285
|
-
], RunAttributeEntity.prototype, "runId", void 0);
|
|
286
|
-
_ts_decorate([
|
|
287
|
-
PrimaryKey({
|
|
288
|
-
type: "string"
|
|
289
|
-
}),
|
|
290
|
-
_ts_metadata("design:type", String)
|
|
291
|
-
], RunAttributeEntity.prototype, "key", void 0);
|
|
292
|
-
_ts_decorate([
|
|
293
|
-
Property({
|
|
294
|
-
type: "string",
|
|
295
|
-
nullable: true
|
|
296
|
-
}),
|
|
297
|
-
_ts_metadata("design:type", Object)
|
|
298
|
-
], RunAttributeEntity.prototype, "strValue", void 0);
|
|
299
|
-
_ts_decorate([
|
|
300
|
-
Property({
|
|
301
|
-
type: "float",
|
|
302
|
-
nullable: true
|
|
303
|
-
}),
|
|
304
|
-
_ts_metadata("design:type", Object)
|
|
305
|
-
], RunAttributeEntity.prototype, "numValue", void 0);
|
|
306
|
-
RunAttributeEntity = _ts_decorate([
|
|
307
|
-
Entity({
|
|
308
|
-
tableName: "durable_run_attributes"
|
|
309
|
-
})
|
|
310
|
-
], RunAttributeEntity);
|
|
311
66
|
var SignalWaiterEntity = class {
|
|
312
67
|
static {
|
|
313
68
|
__name(this, "SignalWaiterEntity");
|
|
@@ -316,29 +71,6 @@ var SignalWaiterEntity = class {
|
|
|
316
71
|
runId;
|
|
317
72
|
seq;
|
|
318
73
|
};
|
|
319
|
-
_ts_decorate([
|
|
320
|
-
PrimaryKey({
|
|
321
|
-
type: "string"
|
|
322
|
-
}),
|
|
323
|
-
_ts_metadata("design:type", String)
|
|
324
|
-
], SignalWaiterEntity.prototype, "token", void 0);
|
|
325
|
-
_ts_decorate([
|
|
326
|
-
Property({
|
|
327
|
-
type: "string"
|
|
328
|
-
}),
|
|
329
|
-
_ts_metadata("design:type", String)
|
|
330
|
-
], SignalWaiterEntity.prototype, "runId", void 0);
|
|
331
|
-
_ts_decorate([
|
|
332
|
-
Property({
|
|
333
|
-
type: "integer"
|
|
334
|
-
}),
|
|
335
|
-
_ts_metadata("design:type", Number)
|
|
336
|
-
], SignalWaiterEntity.prototype, "seq", void 0);
|
|
337
|
-
SignalWaiterEntity = _ts_decorate([
|
|
338
|
-
Entity({
|
|
339
|
-
tableName: "durable_signal_waiters"
|
|
340
|
-
})
|
|
341
|
-
], SignalWaiterEntity);
|
|
342
74
|
var BufferedSignalEntity = class {
|
|
343
75
|
static {
|
|
344
76
|
__name(this, "BufferedSignalEntity");
|
|
@@ -347,48 +79,273 @@ var BufferedSignalEntity = class {
|
|
|
347
79
|
token;
|
|
348
80
|
payload;
|
|
349
81
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
82
|
+
function durableEntities(options = {}) {
|
|
83
|
+
const col = columnNamer(options.naming ?? "snake_case");
|
|
84
|
+
const workflowRuns = new EntitySchema({
|
|
85
|
+
class: WorkflowRunEntity,
|
|
86
|
+
tableName: "durable_workflow_runs",
|
|
87
|
+
properties: {
|
|
88
|
+
id: {
|
|
89
|
+
type: "string",
|
|
90
|
+
primary: true,
|
|
91
|
+
fieldName: col("id")
|
|
92
|
+
},
|
|
93
|
+
workflow: {
|
|
94
|
+
type: "string",
|
|
95
|
+
fieldName: col("workflow")
|
|
96
|
+
},
|
|
97
|
+
workflowVersion: {
|
|
98
|
+
type: "string",
|
|
99
|
+
fieldName: col("workflowVersion")
|
|
100
|
+
},
|
|
101
|
+
status: {
|
|
102
|
+
type: "string",
|
|
103
|
+
fieldName: col("status")
|
|
104
|
+
},
|
|
105
|
+
input: {
|
|
106
|
+
type: "json",
|
|
107
|
+
nullable: true,
|
|
108
|
+
fieldName: col("input")
|
|
109
|
+
},
|
|
110
|
+
output: {
|
|
111
|
+
type: "json",
|
|
112
|
+
nullable: true,
|
|
113
|
+
fieldName: col("output")
|
|
114
|
+
},
|
|
115
|
+
error: {
|
|
116
|
+
type: "json",
|
|
117
|
+
nullable: true,
|
|
118
|
+
fieldName: col("error")
|
|
119
|
+
},
|
|
120
|
+
wakeAt: {
|
|
121
|
+
type: "Date",
|
|
122
|
+
nullable: true,
|
|
123
|
+
fieldName: col("wakeAt")
|
|
124
|
+
},
|
|
125
|
+
lockedBy: {
|
|
126
|
+
type: "string",
|
|
127
|
+
nullable: true,
|
|
128
|
+
fieldName: col("lockedBy")
|
|
129
|
+
},
|
|
130
|
+
lockedUntil: {
|
|
131
|
+
type: "Date",
|
|
132
|
+
nullable: true,
|
|
133
|
+
fieldName: col("lockedUntil")
|
|
134
|
+
},
|
|
135
|
+
recoveryAttempts: {
|
|
136
|
+
type: "integer",
|
|
137
|
+
nullable: true,
|
|
138
|
+
fieldName: col("recoveryAttempts")
|
|
139
|
+
},
|
|
140
|
+
tags: {
|
|
141
|
+
type: "json",
|
|
142
|
+
nullable: true,
|
|
143
|
+
fieldName: col("tags")
|
|
144
|
+
},
|
|
145
|
+
searchAttributes: {
|
|
146
|
+
type: "json",
|
|
147
|
+
nullable: true,
|
|
148
|
+
fieldName: col("searchAttributes")
|
|
149
|
+
},
|
|
150
|
+
createdAt: {
|
|
151
|
+
type: "Date",
|
|
152
|
+
fieldName: col("createdAt")
|
|
153
|
+
},
|
|
154
|
+
updatedAt: {
|
|
155
|
+
type: "Date",
|
|
156
|
+
fieldName: col("updatedAt")
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const stepCheckpoints = new EntitySchema({
|
|
161
|
+
class: StepCheckpointEntity,
|
|
162
|
+
tableName: "durable_step_checkpoints",
|
|
163
|
+
properties: {
|
|
164
|
+
runId: {
|
|
165
|
+
type: "string",
|
|
166
|
+
primary: true,
|
|
167
|
+
fieldName: col("runId")
|
|
168
|
+
},
|
|
169
|
+
seq: {
|
|
170
|
+
type: "integer",
|
|
171
|
+
primary: true,
|
|
172
|
+
fieldName: col("seq")
|
|
173
|
+
},
|
|
174
|
+
name: {
|
|
175
|
+
type: "string",
|
|
176
|
+
fieldName: col("name")
|
|
177
|
+
},
|
|
178
|
+
kind: {
|
|
179
|
+
type: "string",
|
|
180
|
+
fieldName: col("kind")
|
|
181
|
+
},
|
|
182
|
+
stepId: {
|
|
183
|
+
type: "string",
|
|
184
|
+
fieldName: col("stepId")
|
|
185
|
+
},
|
|
186
|
+
status: {
|
|
187
|
+
type: "string",
|
|
188
|
+
fieldName: col("status")
|
|
189
|
+
},
|
|
190
|
+
input: {
|
|
191
|
+
type: "json",
|
|
192
|
+
nullable: true,
|
|
193
|
+
fieldName: col("input")
|
|
194
|
+
},
|
|
195
|
+
output: {
|
|
196
|
+
type: "json",
|
|
197
|
+
nullable: true,
|
|
198
|
+
fieldName: col("output")
|
|
199
|
+
},
|
|
200
|
+
error: {
|
|
201
|
+
type: "json",
|
|
202
|
+
nullable: true,
|
|
203
|
+
fieldName: col("error")
|
|
204
|
+
},
|
|
205
|
+
events: {
|
|
206
|
+
type: "json",
|
|
207
|
+
nullable: true,
|
|
208
|
+
fieldName: col("events")
|
|
209
|
+
},
|
|
210
|
+
attempts: {
|
|
211
|
+
type: "integer",
|
|
212
|
+
fieldName: col("attempts")
|
|
213
|
+
},
|
|
214
|
+
workerGroup: {
|
|
215
|
+
type: "string",
|
|
216
|
+
nullable: true,
|
|
217
|
+
fieldName: col("workerGroup")
|
|
218
|
+
},
|
|
219
|
+
wakeAt: {
|
|
220
|
+
type: "Date",
|
|
221
|
+
nullable: true,
|
|
222
|
+
fieldName: col("wakeAt")
|
|
223
|
+
},
|
|
224
|
+
enqueuedAt: {
|
|
225
|
+
type: "Date",
|
|
226
|
+
nullable: true,
|
|
227
|
+
fieldName: col("enqueuedAt")
|
|
228
|
+
},
|
|
229
|
+
startedAt: {
|
|
230
|
+
type: "Date",
|
|
231
|
+
fieldName: col("startedAt")
|
|
232
|
+
},
|
|
233
|
+
finishedAt: {
|
|
234
|
+
type: "Date",
|
|
235
|
+
fieldName: col("finishedAt")
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
const runAttributes = new EntitySchema({
|
|
240
|
+
class: RunAttributeEntity,
|
|
241
|
+
tableName: "durable_run_attributes",
|
|
242
|
+
properties: {
|
|
243
|
+
runId: {
|
|
244
|
+
type: "string",
|
|
245
|
+
primary: true,
|
|
246
|
+
fieldName: col("runId")
|
|
247
|
+
},
|
|
248
|
+
key: {
|
|
249
|
+
type: "string",
|
|
250
|
+
primary: true,
|
|
251
|
+
fieldName: col("key")
|
|
252
|
+
},
|
|
253
|
+
strValue: {
|
|
254
|
+
type: "string",
|
|
255
|
+
nullable: true,
|
|
256
|
+
fieldName: col("strValue")
|
|
257
|
+
},
|
|
258
|
+
// `float`/`double` is portable across SQLite/MySQL/Postgres for numeric range scans.
|
|
259
|
+
numValue: {
|
|
260
|
+
type: "float",
|
|
261
|
+
nullable: true,
|
|
262
|
+
fieldName: col("numValue")
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
const signalWaiters = new EntitySchema({
|
|
267
|
+
class: SignalWaiterEntity,
|
|
268
|
+
tableName: "durable_signal_waiters",
|
|
269
|
+
properties: {
|
|
270
|
+
token: {
|
|
271
|
+
type: "string",
|
|
272
|
+
primary: true,
|
|
273
|
+
fieldName: col("token")
|
|
274
|
+
},
|
|
275
|
+
runId: {
|
|
276
|
+
type: "string",
|
|
277
|
+
fieldName: col("runId")
|
|
278
|
+
},
|
|
279
|
+
seq: {
|
|
280
|
+
type: "integer",
|
|
281
|
+
fieldName: col("seq")
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
const bufferedSignals = new EntitySchema({
|
|
286
|
+
class: BufferedSignalEntity,
|
|
287
|
+
tableName: "durable_buffered_signals",
|
|
288
|
+
properties: {
|
|
289
|
+
id: {
|
|
290
|
+
type: "integer",
|
|
291
|
+
primary: true,
|
|
292
|
+
autoincrement: true,
|
|
293
|
+
fieldName: col("id")
|
|
294
|
+
},
|
|
295
|
+
token: {
|
|
296
|
+
type: "string",
|
|
297
|
+
index: true,
|
|
298
|
+
fieldName: col("token")
|
|
299
|
+
},
|
|
300
|
+
payload: {
|
|
301
|
+
type: "json",
|
|
302
|
+
nullable: true,
|
|
303
|
+
fieldName: col("payload")
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
return [
|
|
308
|
+
workflowRuns,
|
|
309
|
+
stepCheckpoints,
|
|
310
|
+
runAttributes,
|
|
311
|
+
signalWaiters,
|
|
312
|
+
bufferedSignals
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
__name(durableEntities, "durableEntities");
|
|
316
|
+
var ENTITIES = durableEntities();
|
|
383
317
|
|
|
384
318
|
// src/mikro-orm-state-store.ts
|
|
385
319
|
import { attributeColumnFor, attributeOperand, normalizeAttributeRows, sqlComparator } from "@dudousxd/nestjs-durable-core";
|
|
386
320
|
|
|
387
321
|
// src/schema.ts
|
|
322
|
+
var DURABLE_TABLE_NAMES = /* @__PURE__ */ new Set([
|
|
323
|
+
"durable_workflow_runs",
|
|
324
|
+
"durable_step_checkpoints",
|
|
325
|
+
"durable_run_attributes",
|
|
326
|
+
"durable_signal_waiters",
|
|
327
|
+
"durable_buffered_signals"
|
|
328
|
+
]);
|
|
329
|
+
function targetTable(statement) {
|
|
330
|
+
const match = statement.match(/^(?:create|alter)\s+table\s+(?:if\s+not\s+exists\s+)?[`"']?([\w$]+)[`"']?/i);
|
|
331
|
+
return match?.[1]?.toLowerCase();
|
|
332
|
+
}
|
|
333
|
+
__name(targetTable, "targetTable");
|
|
388
334
|
async function ensureMikroOrmDurableSchema(orm) {
|
|
389
|
-
await orm.schema.
|
|
335
|
+
const sql = await orm.schema.getUpdateSchemaSQL({
|
|
390
336
|
safe: true
|
|
391
337
|
});
|
|
338
|
+
const ours = sql.split(";").map((statement) => statement.trim()).filter((statement) => {
|
|
339
|
+
const table = targetTable(statement);
|
|
340
|
+
return table !== void 0 && DURABLE_TABLE_NAMES.has(table);
|
|
341
|
+
});
|
|
342
|
+
if (ours.length === 0) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const connection = orm.em.getConnection();
|
|
346
|
+
for (const statement of ours) {
|
|
347
|
+
await connection.execute(statement);
|
|
348
|
+
}
|
|
392
349
|
}
|
|
393
350
|
__name(ensureMikroOrmDurableSchema, "ensureMikroOrmDurableSchema");
|
|
394
351
|
|
|
@@ -825,6 +782,7 @@ export {
|
|
|
825
782
|
SignalWaiterEntity,
|
|
826
783
|
StepCheckpointEntity,
|
|
827
784
|
WorkflowRunEntity,
|
|
785
|
+
durableEntities,
|
|
828
786
|
ensureMikroOrmDurableSchema
|
|
829
787
|
};
|
|
830
788
|
//# sourceMappingURL=index.js.map
|