@dudousxd/nestjs-durable-store-mikro-orm 0.10.0 → 0.11.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 CHANGED
@@ -28,23 +28,23 @@ __export(index_exports, {
28
28
  SignalWaiterEntity: () => SignalWaiterEntity,
29
29
  StepCheckpointEntity: () => StepCheckpointEntity,
30
30
  WorkflowRunEntity: () => WorkflowRunEntity,
31
+ durableEntities: () => durableEntities,
31
32
  ensureMikroOrmDurableSchema: () => ensureMikroOrmDurableSchema
32
33
  });
33
34
  module.exports = __toCommonJS(index_exports);
34
35
 
35
36
  // src/entities.ts
36
- var import_legacy = require("@mikro-orm/decorators/legacy");
37
- function _ts_decorate(decorators, target, key, desc) {
38
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
39
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
40
- 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;
41
- return c > 3 && r && Object.defineProperty(target, key, r), r;
37
+ var import_core = require("@mikro-orm/core");
38
+ function snakeCase(property) {
39
+ return property.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
42
40
  }
43
- __name(_ts_decorate, "_ts_decorate");
44
- function _ts_metadata(k, v) {
45
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
41
+ __name(snakeCase, "snakeCase");
42
+ function columnNamer(naming) {
43
+ if (naming === "snake_case") return snakeCase;
44
+ if (naming === "preserve") return (property) => property;
45
+ return naming;
46
46
  }
47
- __name(_ts_metadata, "_ts_metadata");
47
+ __name(columnNamer, "columnNamer");
48
48
  var WorkflowRunEntity = class {
49
49
  static {
50
50
  __name(this, "WorkflowRunEntity");
@@ -65,110 +65,6 @@ var WorkflowRunEntity = class {
65
65
  createdAt;
66
66
  updatedAt;
67
67
  };
68
- _ts_decorate([
69
- (0, import_legacy.PrimaryKey)({
70
- type: "string"
71
- }),
72
- _ts_metadata("design:type", String)
73
- ], WorkflowRunEntity.prototype, "id", void 0);
74
- _ts_decorate([
75
- (0, import_legacy.Property)({
76
- type: "string"
77
- }),
78
- _ts_metadata("design:type", String)
79
- ], WorkflowRunEntity.prototype, "workflow", void 0);
80
- _ts_decorate([
81
- (0, import_legacy.Property)({
82
- type: "string"
83
- }),
84
- _ts_metadata("design:type", String)
85
- ], WorkflowRunEntity.prototype, "workflowVersion", void 0);
86
- _ts_decorate([
87
- (0, import_legacy.Property)({
88
- type: "string"
89
- }),
90
- _ts_metadata("design:type", typeof RunStatus === "undefined" ? Object : RunStatus)
91
- ], WorkflowRunEntity.prototype, "status", void 0);
92
- _ts_decorate([
93
- (0, import_legacy.Property)({
94
- type: "json",
95
- nullable: true
96
- }),
97
- _ts_metadata("design:type", Object)
98
- ], WorkflowRunEntity.prototype, "input", void 0);
99
- _ts_decorate([
100
- (0, import_legacy.Property)({
101
- type: "json",
102
- nullable: true
103
- }),
104
- _ts_metadata("design:type", Object)
105
- ], WorkflowRunEntity.prototype, "output", void 0);
106
- _ts_decorate([
107
- (0, import_legacy.Property)({
108
- type: "json",
109
- nullable: true
110
- }),
111
- _ts_metadata("design:type", Object)
112
- ], WorkflowRunEntity.prototype, "error", void 0);
113
- _ts_decorate([
114
- (0, import_legacy.Property)({
115
- type: "Date",
116
- nullable: true
117
- }),
118
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
119
- ], WorkflowRunEntity.prototype, "wakeAt", void 0);
120
- _ts_decorate([
121
- (0, import_legacy.Property)({
122
- type: "string",
123
- nullable: true
124
- }),
125
- _ts_metadata("design:type", String)
126
- ], WorkflowRunEntity.prototype, "lockedBy", void 0);
127
- _ts_decorate([
128
- (0, import_legacy.Property)({
129
- type: "Date",
130
- nullable: true
131
- }),
132
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
133
- ], WorkflowRunEntity.prototype, "lockedUntil", void 0);
134
- _ts_decorate([
135
- (0, import_legacy.Property)({
136
- type: "integer",
137
- nullable: true
138
- }),
139
- _ts_metadata("design:type", Number)
140
- ], WorkflowRunEntity.prototype, "recoveryAttempts", void 0);
141
- _ts_decorate([
142
- (0, import_legacy.Property)({
143
- type: "json",
144
- nullable: true
145
- }),
146
- _ts_metadata("design:type", Object)
147
- ], WorkflowRunEntity.prototype, "tags", void 0);
148
- _ts_decorate([
149
- (0, import_legacy.Property)({
150
- type: "json",
151
- nullable: true
152
- }),
153
- _ts_metadata("design:type", Object)
154
- ], WorkflowRunEntity.prototype, "searchAttributes", void 0);
155
- _ts_decorate([
156
- (0, import_legacy.Property)({
157
- type: "Date"
158
- }),
159
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
160
- ], WorkflowRunEntity.prototype, "createdAt", void 0);
161
- _ts_decorate([
162
- (0, import_legacy.Property)({
163
- type: "Date"
164
- }),
165
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
166
- ], WorkflowRunEntity.prototype, "updatedAt", void 0);
167
- WorkflowRunEntity = _ts_decorate([
168
- (0, import_legacy.Entity)({
169
- tableName: "durable_workflow_runs"
170
- })
171
- ], WorkflowRunEntity);
172
68
  var StepCheckpointEntity = class {
173
69
  static {
174
70
  __name(this, "StepCheckpointEntity");
@@ -190,114 +86,6 @@ var StepCheckpointEntity = class {
190
86
  startedAt;
191
87
  finishedAt;
192
88
  };
193
- _ts_decorate([
194
- (0, import_legacy.PrimaryKey)({
195
- type: "string"
196
- }),
197
- _ts_metadata("design:type", String)
198
- ], StepCheckpointEntity.prototype, "runId", void 0);
199
- _ts_decorate([
200
- (0, import_legacy.PrimaryKey)({
201
- type: "integer"
202
- }),
203
- _ts_metadata("design:type", Number)
204
- ], StepCheckpointEntity.prototype, "seq", void 0);
205
- _ts_decorate([
206
- (0, import_legacy.Property)({
207
- type: "string"
208
- }),
209
- _ts_metadata("design:type", String)
210
- ], StepCheckpointEntity.prototype, "name", void 0);
211
- _ts_decorate([
212
- (0, import_legacy.Property)({
213
- type: "string"
214
- }),
215
- _ts_metadata("design:type", typeof StepKind === "undefined" ? Object : StepKind)
216
- ], StepCheckpointEntity.prototype, "kind", void 0);
217
- _ts_decorate([
218
- (0, import_legacy.Property)({
219
- type: "string"
220
- }),
221
- _ts_metadata("design:type", String)
222
- ], StepCheckpointEntity.prototype, "stepId", void 0);
223
- _ts_decorate([
224
- (0, import_legacy.Property)({
225
- type: "string"
226
- }),
227
- _ts_metadata("design:type", String)
228
- ], StepCheckpointEntity.prototype, "status", void 0);
229
- _ts_decorate([
230
- (0, import_legacy.Property)({
231
- type: "json",
232
- nullable: true
233
- }),
234
- _ts_metadata("design:type", Object)
235
- ], StepCheckpointEntity.prototype, "input", void 0);
236
- _ts_decorate([
237
- (0, import_legacy.Property)({
238
- type: "json",
239
- nullable: true
240
- }),
241
- _ts_metadata("design:type", Object)
242
- ], StepCheckpointEntity.prototype, "output", void 0);
243
- _ts_decorate([
244
- (0, import_legacy.Property)({
245
- type: "json",
246
- nullable: true
247
- }),
248
- _ts_metadata("design:type", Object)
249
- ], StepCheckpointEntity.prototype, "error", void 0);
250
- _ts_decorate([
251
- (0, import_legacy.Property)({
252
- type: "json",
253
- nullable: true
254
- }),
255
- _ts_metadata("design:type", Object)
256
- ], StepCheckpointEntity.prototype, "events", void 0);
257
- _ts_decorate([
258
- (0, import_legacy.Property)({
259
- type: "integer"
260
- }),
261
- _ts_metadata("design:type", Number)
262
- ], StepCheckpointEntity.prototype, "attempts", void 0);
263
- _ts_decorate([
264
- (0, import_legacy.Property)({
265
- type: "string",
266
- nullable: true
267
- }),
268
- _ts_metadata("design:type", String)
269
- ], StepCheckpointEntity.prototype, "workerGroup", void 0);
270
- _ts_decorate([
271
- (0, import_legacy.Property)({
272
- type: "Date",
273
- nullable: true
274
- }),
275
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
276
- ], StepCheckpointEntity.prototype, "wakeAt", void 0);
277
- _ts_decorate([
278
- (0, import_legacy.Property)({
279
- type: "Date",
280
- nullable: true
281
- }),
282
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
283
- ], StepCheckpointEntity.prototype, "enqueuedAt", void 0);
284
- _ts_decorate([
285
- (0, import_legacy.Property)({
286
- type: "Date"
287
- }),
288
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
289
- ], StepCheckpointEntity.prototype, "startedAt", void 0);
290
- _ts_decorate([
291
- (0, import_legacy.Property)({
292
- type: "Date"
293
- }),
294
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
295
- ], StepCheckpointEntity.prototype, "finishedAt", void 0);
296
- StepCheckpointEntity = _ts_decorate([
297
- (0, import_legacy.Entity)({
298
- tableName: "durable_step_checkpoints"
299
- })
300
- ], StepCheckpointEntity);
301
89
  var RunAttributeEntity = class {
302
90
  static {
303
91
  __name(this, "RunAttributeEntity");
@@ -305,40 +93,8 @@ var RunAttributeEntity = class {
305
93
  runId;
306
94
  key;
307
95
  strValue;
308
- // `float`/`double` is portable across SQLite/MySQL/Postgres for numeric range scans.
309
96
  numValue;
310
97
  };
311
- _ts_decorate([
312
- (0, import_legacy.PrimaryKey)({
313
- type: "string"
314
- }),
315
- _ts_metadata("design:type", String)
316
- ], RunAttributeEntity.prototype, "runId", void 0);
317
- _ts_decorate([
318
- (0, import_legacy.PrimaryKey)({
319
- type: "string"
320
- }),
321
- _ts_metadata("design:type", String)
322
- ], RunAttributeEntity.prototype, "key", void 0);
323
- _ts_decorate([
324
- (0, import_legacy.Property)({
325
- type: "string",
326
- nullable: true
327
- }),
328
- _ts_metadata("design:type", Object)
329
- ], RunAttributeEntity.prototype, "strValue", void 0);
330
- _ts_decorate([
331
- (0, import_legacy.Property)({
332
- type: "float",
333
- nullable: true
334
- }),
335
- _ts_metadata("design:type", Object)
336
- ], RunAttributeEntity.prototype, "numValue", void 0);
337
- RunAttributeEntity = _ts_decorate([
338
- (0, import_legacy.Entity)({
339
- tableName: "durable_run_attributes"
340
- })
341
- ], RunAttributeEntity);
342
98
  var SignalWaiterEntity = class {
343
99
  static {
344
100
  __name(this, "SignalWaiterEntity");
@@ -347,29 +103,6 @@ var SignalWaiterEntity = class {
347
103
  runId;
348
104
  seq;
349
105
  };
350
- _ts_decorate([
351
- (0, import_legacy.PrimaryKey)({
352
- type: "string"
353
- }),
354
- _ts_metadata("design:type", String)
355
- ], SignalWaiterEntity.prototype, "token", void 0);
356
- _ts_decorate([
357
- (0, import_legacy.Property)({
358
- type: "string"
359
- }),
360
- _ts_metadata("design:type", String)
361
- ], SignalWaiterEntity.prototype, "runId", void 0);
362
- _ts_decorate([
363
- (0, import_legacy.Property)({
364
- type: "integer"
365
- }),
366
- _ts_metadata("design:type", Number)
367
- ], SignalWaiterEntity.prototype, "seq", void 0);
368
- SignalWaiterEntity = _ts_decorate([
369
- (0, import_legacy.Entity)({
370
- tableName: "durable_signal_waiters"
371
- })
372
- ], SignalWaiterEntity);
373
106
  var BufferedSignalEntity = class {
374
107
  static {
375
108
  __name(this, "BufferedSignalEntity");
@@ -378,39 +111,241 @@ var BufferedSignalEntity = class {
378
111
  token;
379
112
  payload;
380
113
  };
381
- _ts_decorate([
382
- (0, import_legacy.PrimaryKey)({
383
- autoincrement: true,
384
- type: "integer"
385
- }),
386
- _ts_metadata("design:type", Number)
387
- ], BufferedSignalEntity.prototype, "id", void 0);
388
- _ts_decorate([
389
- (0, import_legacy.Property)({
390
- index: true,
391
- type: "string"
392
- }),
393
- _ts_metadata("design:type", String)
394
- ], BufferedSignalEntity.prototype, "token", void 0);
395
- _ts_decorate([
396
- (0, import_legacy.Property)({
397
- type: "json",
398
- nullable: true
399
- }),
400
- _ts_metadata("design:type", Object)
401
- ], BufferedSignalEntity.prototype, "payload", void 0);
402
- BufferedSignalEntity = _ts_decorate([
403
- (0, import_legacy.Entity)({
404
- tableName: "durable_buffered_signals"
405
- })
406
- ], BufferedSignalEntity);
407
- var ENTITIES = [
408
- WorkflowRunEntity,
409
- StepCheckpointEntity,
410
- RunAttributeEntity,
411
- SignalWaiterEntity,
412
- BufferedSignalEntity
413
- ];
114
+ function durableEntities(options = {}) {
115
+ const col = columnNamer(options.naming ?? "snake_case");
116
+ const workflowRuns = new import_core.EntitySchema({
117
+ class: WorkflowRunEntity,
118
+ tableName: "durable_workflow_runs",
119
+ properties: {
120
+ id: {
121
+ type: "string",
122
+ primary: true,
123
+ fieldName: col("id")
124
+ },
125
+ workflow: {
126
+ type: "string",
127
+ fieldName: col("workflow")
128
+ },
129
+ workflowVersion: {
130
+ type: "string",
131
+ fieldName: col("workflowVersion")
132
+ },
133
+ status: {
134
+ type: "string",
135
+ fieldName: col("status")
136
+ },
137
+ input: {
138
+ type: "json",
139
+ nullable: true,
140
+ fieldName: col("input")
141
+ },
142
+ output: {
143
+ type: "json",
144
+ nullable: true,
145
+ fieldName: col("output")
146
+ },
147
+ error: {
148
+ type: "json",
149
+ nullable: true,
150
+ fieldName: col("error")
151
+ },
152
+ wakeAt: {
153
+ type: "Date",
154
+ nullable: true,
155
+ fieldName: col("wakeAt")
156
+ },
157
+ lockedBy: {
158
+ type: "string",
159
+ nullable: true,
160
+ fieldName: col("lockedBy")
161
+ },
162
+ lockedUntil: {
163
+ type: "Date",
164
+ nullable: true,
165
+ fieldName: col("lockedUntil")
166
+ },
167
+ recoveryAttempts: {
168
+ type: "integer",
169
+ nullable: true,
170
+ fieldName: col("recoveryAttempts")
171
+ },
172
+ tags: {
173
+ type: "json",
174
+ nullable: true,
175
+ fieldName: col("tags")
176
+ },
177
+ searchAttributes: {
178
+ type: "json",
179
+ nullable: true,
180
+ fieldName: col("searchAttributes")
181
+ },
182
+ createdAt: {
183
+ type: "Date",
184
+ fieldName: col("createdAt")
185
+ },
186
+ updatedAt: {
187
+ type: "Date",
188
+ fieldName: col("updatedAt")
189
+ }
190
+ }
191
+ });
192
+ const stepCheckpoints = new import_core.EntitySchema({
193
+ class: StepCheckpointEntity,
194
+ tableName: "durable_step_checkpoints",
195
+ properties: {
196
+ runId: {
197
+ type: "string",
198
+ primary: true,
199
+ fieldName: col("runId")
200
+ },
201
+ seq: {
202
+ type: "integer",
203
+ primary: true,
204
+ fieldName: col("seq")
205
+ },
206
+ name: {
207
+ type: "string",
208
+ fieldName: col("name")
209
+ },
210
+ kind: {
211
+ type: "string",
212
+ fieldName: col("kind")
213
+ },
214
+ stepId: {
215
+ type: "string",
216
+ fieldName: col("stepId")
217
+ },
218
+ status: {
219
+ type: "string",
220
+ fieldName: col("status")
221
+ },
222
+ input: {
223
+ type: "json",
224
+ nullable: true,
225
+ fieldName: col("input")
226
+ },
227
+ output: {
228
+ type: "json",
229
+ nullable: true,
230
+ fieldName: col("output")
231
+ },
232
+ error: {
233
+ type: "json",
234
+ nullable: true,
235
+ fieldName: col("error")
236
+ },
237
+ events: {
238
+ type: "json",
239
+ nullable: true,
240
+ fieldName: col("events")
241
+ },
242
+ attempts: {
243
+ type: "integer",
244
+ fieldName: col("attempts")
245
+ },
246
+ workerGroup: {
247
+ type: "string",
248
+ nullable: true,
249
+ fieldName: col("workerGroup")
250
+ },
251
+ wakeAt: {
252
+ type: "Date",
253
+ nullable: true,
254
+ fieldName: col("wakeAt")
255
+ },
256
+ enqueuedAt: {
257
+ type: "Date",
258
+ nullable: true,
259
+ fieldName: col("enqueuedAt")
260
+ },
261
+ startedAt: {
262
+ type: "Date",
263
+ fieldName: col("startedAt")
264
+ },
265
+ finishedAt: {
266
+ type: "Date",
267
+ fieldName: col("finishedAt")
268
+ }
269
+ }
270
+ });
271
+ const runAttributes = new import_core.EntitySchema({
272
+ class: RunAttributeEntity,
273
+ tableName: "durable_run_attributes",
274
+ properties: {
275
+ runId: {
276
+ type: "string",
277
+ primary: true,
278
+ fieldName: col("runId")
279
+ },
280
+ key: {
281
+ type: "string",
282
+ primary: true,
283
+ fieldName: col("key")
284
+ },
285
+ strValue: {
286
+ type: "string",
287
+ nullable: true,
288
+ fieldName: col("strValue")
289
+ },
290
+ // `float`/`double` is portable across SQLite/MySQL/Postgres for numeric range scans.
291
+ numValue: {
292
+ type: "float",
293
+ nullable: true,
294
+ fieldName: col("numValue")
295
+ }
296
+ }
297
+ });
298
+ const signalWaiters = new import_core.EntitySchema({
299
+ class: SignalWaiterEntity,
300
+ tableName: "durable_signal_waiters",
301
+ properties: {
302
+ token: {
303
+ type: "string",
304
+ primary: true,
305
+ fieldName: col("token")
306
+ },
307
+ runId: {
308
+ type: "string",
309
+ fieldName: col("runId")
310
+ },
311
+ seq: {
312
+ type: "integer",
313
+ fieldName: col("seq")
314
+ }
315
+ }
316
+ });
317
+ const bufferedSignals = new import_core.EntitySchema({
318
+ class: BufferedSignalEntity,
319
+ tableName: "durable_buffered_signals",
320
+ properties: {
321
+ id: {
322
+ type: "integer",
323
+ primary: true,
324
+ autoincrement: true,
325
+ fieldName: col("id")
326
+ },
327
+ token: {
328
+ type: "string",
329
+ index: true,
330
+ fieldName: col("token")
331
+ },
332
+ payload: {
333
+ type: "json",
334
+ nullable: true,
335
+ fieldName: col("payload")
336
+ }
337
+ }
338
+ });
339
+ return [
340
+ workflowRuns,
341
+ stepCheckpoints,
342
+ runAttributes,
343
+ signalWaiters,
344
+ bufferedSignals
345
+ ];
346
+ }
347
+ __name(durableEntities, "durableEntities");
348
+ var ENTITIES = durableEntities();
414
349
 
415
350
  // src/mikro-orm-state-store.ts
416
351
  var import_nestjs_durable_core = require("@dudousxd/nestjs-durable-core");
@@ -857,6 +792,7 @@ __name(fromCheckpointEntity, "fromCheckpointEntity");
857
792
  SignalWaiterEntity,
858
793
  StepCheckpointEntity,
859
794
  WorkflowRunEntity,
795
+ durableEntities,
860
796
  ensureMikroOrmDurableSchema
861
797
  });
862
798
  //# sourceMappingURL=index.cjs.map