@dudousxd/nestjs-durable-store-typeorm 0.1.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/entities.d.ts +37 -0
- package/dist/entities.d.ts.map +1 -0
- package/dist/entities.js +173 -0
- package/dist/entities.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +17 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +70 -0
- package/dist/schema.js.map +1 -0
- package/dist/typeorm-state-store.d.ts +28 -0
- package/dist/typeorm-state-store.d.ts.map +1 -0
- package/dist/typeorm-state-store.js +172 -0
- package/dist/typeorm-state-store.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RunStatus, StepKind } from '@dudousxd/nestjs-durable-core';
|
|
2
|
+
export declare class WorkflowRunEntity {
|
|
3
|
+
id: string;
|
|
4
|
+
workflow: string;
|
|
5
|
+
workflowVersion: string;
|
|
6
|
+
status: RunStatus;
|
|
7
|
+
input?: unknown;
|
|
8
|
+
output?: unknown;
|
|
9
|
+
error?: unknown;
|
|
10
|
+
wakeAt?: Date;
|
|
11
|
+
lockedBy?: string | null;
|
|
12
|
+
lockedUntil?: Date;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
}
|
|
16
|
+
export declare class StepCheckpointEntity {
|
|
17
|
+
runId: string;
|
|
18
|
+
seq: number;
|
|
19
|
+
name: string;
|
|
20
|
+
kind: StepKind;
|
|
21
|
+
stepId: string;
|
|
22
|
+
status: 'completed' | 'failed';
|
|
23
|
+
output?: unknown;
|
|
24
|
+
error?: unknown;
|
|
25
|
+
attempts: number;
|
|
26
|
+
workerGroup?: string | null;
|
|
27
|
+
wakeAt?: Date;
|
|
28
|
+
startedAt: Date;
|
|
29
|
+
finishedAt: Date;
|
|
30
|
+
}
|
|
31
|
+
export declare class SignalWaiterEntity {
|
|
32
|
+
token: string;
|
|
33
|
+
runId: string;
|
|
34
|
+
seq: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const ENTITIES: readonly [typeof WorkflowRunEntity, typeof StepCheckpointEntity, typeof SignalWaiterEntity];
|
|
37
|
+
//# sourceMappingURL=entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzE,qBACa,iBAAiB;IAE5B,EAAE,EAAG,MAAM,CAAC;IAGZ,QAAQ,EAAG,MAAM,CAAC;IAGlB,eAAe,EAAG,MAAM,CAAC;IAGzB,MAAM,EAAG,SAAS,CAAC;IAGnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,IAAI,CAAC;IAGd,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGzB,WAAW,CAAC,EAAE,IAAI,CAAC;IAGnB,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAClB;AAED,qBACa,oBAAoB;IAE/B,KAAK,EAAG,MAAM,CAAC;IAGf,GAAG,EAAG,MAAM,CAAC;IAGb,IAAI,EAAG,MAAM,CAAC;IAGd,IAAI,EAAG,QAAQ,CAAC;IAGhB,MAAM,EAAG,MAAM,CAAC;IAGhB,MAAM,EAAG,WAAW,GAAG,QAAQ,CAAC;IAGhC,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,QAAQ,EAAG,MAAM,CAAC;IAGlB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,MAAM,CAAC,EAAE,IAAI,CAAC;IAGd,SAAS,EAAG,IAAI,CAAC;IAGjB,UAAU,EAAG,IAAI,CAAC;CACnB;AAED,qBACa,kBAAkB;IAE7B,KAAK,EAAG,MAAM,CAAC;IAGf,KAAK,EAAG,MAAM,CAAC;IAGf,GAAG,EAAG,MAAM,CAAC;CACd;AAED,eAAO,MAAM,QAAQ,6FAAyE,CAAC"}
|
package/dist/entities.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ENTITIES = exports.SignalWaiterEntity = exports.StepCheckpointEntity = exports.WorkflowRunEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let WorkflowRunEntity = class WorkflowRunEntity {
|
|
15
|
+
id;
|
|
16
|
+
workflow;
|
|
17
|
+
workflowVersion;
|
|
18
|
+
status;
|
|
19
|
+
input;
|
|
20
|
+
output;
|
|
21
|
+
error;
|
|
22
|
+
wakeAt;
|
|
23
|
+
lockedBy;
|
|
24
|
+
lockedUntil;
|
|
25
|
+
createdAt;
|
|
26
|
+
updatedAt;
|
|
27
|
+
};
|
|
28
|
+
exports.WorkflowRunEntity = WorkflowRunEntity;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.PrimaryColumn)('text'),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], WorkflowRunEntity.prototype, "id", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)('text'),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], WorkflowRunEntity.prototype, "workflow", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)('text'),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], WorkflowRunEntity.prototype, "workflowVersion", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)('text'),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], WorkflowRunEntity.prototype, "status", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true }),
|
|
47
|
+
__metadata("design:type", Object)
|
|
48
|
+
], WorkflowRunEntity.prototype, "input", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true }),
|
|
51
|
+
__metadata("design:type", Object)
|
|
52
|
+
], WorkflowRunEntity.prototype, "output", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true }),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], WorkflowRunEntity.prototype, "error", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
59
|
+
__metadata("design:type", Date)
|
|
60
|
+
], WorkflowRunEntity.prototype, "wakeAt", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typeorm_1.Column)('text', { nullable: true }),
|
|
63
|
+
__metadata("design:type", Object)
|
|
64
|
+
], WorkflowRunEntity.prototype, "lockedBy", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
67
|
+
__metadata("design:type", Date)
|
|
68
|
+
], WorkflowRunEntity.prototype, "lockedUntil", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.Column)(),
|
|
71
|
+
__metadata("design:type", Date)
|
|
72
|
+
], WorkflowRunEntity.prototype, "createdAt", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.Column)(),
|
|
75
|
+
__metadata("design:type", Date)
|
|
76
|
+
], WorkflowRunEntity.prototype, "updatedAt", void 0);
|
|
77
|
+
exports.WorkflowRunEntity = WorkflowRunEntity = __decorate([
|
|
78
|
+
(0, typeorm_1.Entity)({ name: 'durable_workflow_runs' })
|
|
79
|
+
], WorkflowRunEntity);
|
|
80
|
+
let StepCheckpointEntity = class StepCheckpointEntity {
|
|
81
|
+
runId;
|
|
82
|
+
seq;
|
|
83
|
+
name;
|
|
84
|
+
kind;
|
|
85
|
+
stepId;
|
|
86
|
+
status;
|
|
87
|
+
output;
|
|
88
|
+
error;
|
|
89
|
+
attempts;
|
|
90
|
+
workerGroup;
|
|
91
|
+
wakeAt;
|
|
92
|
+
startedAt;
|
|
93
|
+
finishedAt;
|
|
94
|
+
};
|
|
95
|
+
exports.StepCheckpointEntity = StepCheckpointEntity;
|
|
96
|
+
__decorate([
|
|
97
|
+
(0, typeorm_1.PrimaryColumn)('text'),
|
|
98
|
+
__metadata("design:type", String)
|
|
99
|
+
], StepCheckpointEntity.prototype, "runId", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, typeorm_1.PrimaryColumn)('integer'),
|
|
102
|
+
__metadata("design:type", Number)
|
|
103
|
+
], StepCheckpointEntity.prototype, "seq", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, typeorm_1.Column)('text'),
|
|
106
|
+
__metadata("design:type", String)
|
|
107
|
+
], StepCheckpointEntity.prototype, "name", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, typeorm_1.Column)('text'),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], StepCheckpointEntity.prototype, "kind", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, typeorm_1.Column)('text'),
|
|
114
|
+
__metadata("design:type", String)
|
|
115
|
+
], StepCheckpointEntity.prototype, "stepId", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, typeorm_1.Column)('text'),
|
|
118
|
+
__metadata("design:type", String)
|
|
119
|
+
], StepCheckpointEntity.prototype, "status", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true }),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], StepCheckpointEntity.prototype, "output", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true }),
|
|
126
|
+
__metadata("design:type", Object)
|
|
127
|
+
], StepCheckpointEntity.prototype, "error", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, typeorm_1.Column)('integer'),
|
|
130
|
+
__metadata("design:type", Number)
|
|
131
|
+
], StepCheckpointEntity.prototype, "attempts", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
(0, typeorm_1.Column)('text', { nullable: true }),
|
|
134
|
+
__metadata("design:type", Object)
|
|
135
|
+
], StepCheckpointEntity.prototype, "workerGroup", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
138
|
+
__metadata("design:type", Date)
|
|
139
|
+
], StepCheckpointEntity.prototype, "wakeAt", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
(0, typeorm_1.Column)(),
|
|
142
|
+
__metadata("design:type", Date)
|
|
143
|
+
], StepCheckpointEntity.prototype, "startedAt", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, typeorm_1.Column)(),
|
|
146
|
+
__metadata("design:type", Date)
|
|
147
|
+
], StepCheckpointEntity.prototype, "finishedAt", void 0);
|
|
148
|
+
exports.StepCheckpointEntity = StepCheckpointEntity = __decorate([
|
|
149
|
+
(0, typeorm_1.Entity)({ name: 'durable_step_checkpoints' })
|
|
150
|
+
], StepCheckpointEntity);
|
|
151
|
+
let SignalWaiterEntity = class SignalWaiterEntity {
|
|
152
|
+
token;
|
|
153
|
+
runId;
|
|
154
|
+
seq;
|
|
155
|
+
};
|
|
156
|
+
exports.SignalWaiterEntity = SignalWaiterEntity;
|
|
157
|
+
__decorate([
|
|
158
|
+
(0, typeorm_1.PrimaryColumn)('text'),
|
|
159
|
+
__metadata("design:type", String)
|
|
160
|
+
], SignalWaiterEntity.prototype, "token", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
(0, typeorm_1.Column)('text'),
|
|
163
|
+
__metadata("design:type", String)
|
|
164
|
+
], SignalWaiterEntity.prototype, "runId", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
(0, typeorm_1.Column)('integer'),
|
|
167
|
+
__metadata("design:type", Number)
|
|
168
|
+
], SignalWaiterEntity.prototype, "seq", void 0);
|
|
169
|
+
exports.SignalWaiterEntity = SignalWaiterEntity = __decorate([
|
|
170
|
+
(0, typeorm_1.Entity)({ name: 'durable_signal_waiters' })
|
|
171
|
+
], SignalWaiterEntity);
|
|
172
|
+
exports.ENTITIES = [WorkflowRunEntity, StepCheckpointEntity, SignalWaiterEntity];
|
|
173
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAwD;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE5B,EAAE,CAAU;IAGZ,QAAQ,CAAU;IAGlB,eAAe,CAAU;IAGzB,MAAM,CAAa;IAGnB,KAAK,CAAW;IAGhB,MAAM,CAAW;IAGjB,KAAK,CAAW;IAGhB,MAAM,CAAQ;IAGd,QAAQ,CAAiB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C,MAAM,CAAC;;iDACA;AAGf;IADC,IAAA,gBAAM,EAAC,SAAS,CAAC;;+CACL;6BARF,kBAAkB;IAD9B,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;GAC9B,kBAAkB,CAS9B;AAEY,QAAA,QAAQ,GAAG,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,kBAAkB,CAAU,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./entities"), exports);
|
|
18
|
+
__exportStar(require("./schema"), exports);
|
|
19
|
+
__exportStar(require("./typeorm-state-store"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,2CAAyB;AACzB,wDAAsC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DataSource } from 'typeorm';
|
|
2
|
+
/**
|
|
3
|
+
* Idempotently create the durable tables. Safe to run on every boot (auto-schema) and the
|
|
4
|
+
* exact function to call from your own TypeORM migration when you disable auto-schema:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* export class AddDurableTables implements MigrationInterface {
|
|
8
|
+
* async up(q: QueryRunner) { await ensureTypeOrmDurableSchema(q.connection); }
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Dialect-aware (MySQL / MariaDB / Postgres / SQLite): identifiers are quoted per driver, keyed
|
|
13
|
+
* string columns are `varchar` (MySQL can't key a `text` column), and the index is best-effort.
|
|
14
|
+
* Only ever adds the three durable tables — it never touches your other tables.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ensureTypeOrmDurableSchema(dataSource: DataSource): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,0BAA0B,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDtF"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureTypeOrmDurableSchema = ensureTypeOrmDurableSchema;
|
|
4
|
+
/**
|
|
5
|
+
* Idempotently create the durable tables. Safe to run on every boot (auto-schema) and the
|
|
6
|
+
* exact function to call from your own TypeORM migration when you disable auto-schema:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* export class AddDurableTables implements MigrationInterface {
|
|
10
|
+
* async up(q: QueryRunner) { await ensureTypeOrmDurableSchema(q.connection); }
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Dialect-aware (MySQL / MariaDB / Postgres / SQLite): identifiers are quoted per driver, keyed
|
|
15
|
+
* string columns are `varchar` (MySQL can't key a `text` column), and the index is best-effort.
|
|
16
|
+
* Only ever adds the three durable tables — it never touches your other tables.
|
|
17
|
+
*/
|
|
18
|
+
async function ensureTypeOrmDurableSchema(dataSource) {
|
|
19
|
+
const q = (id) => dataSource.driver.escape(id);
|
|
20
|
+
const type = String(dataSource.options.type);
|
|
21
|
+
const isPg = type === 'postgres' || type === 'aurora-postgres';
|
|
22
|
+
const isMysql = type === 'mysql' || type === 'mariadb' || type === 'aurora-mysql';
|
|
23
|
+
// Keyed/short strings must be varchar on MySQL (a `text` PK/index needs a key length); `text`
|
|
24
|
+
// for the free-form JSON payloads. Dates use the dialect's native timestamp type.
|
|
25
|
+
const str = 'varchar(191)';
|
|
26
|
+
const txt = 'text';
|
|
27
|
+
const int = isMysql ? 'int' : 'integer';
|
|
28
|
+
const ts = isPg ? 'timestamptz' : 'datetime';
|
|
29
|
+
const runs = q('durable_workflow_runs');
|
|
30
|
+
const checkpoints = q('durable_step_checkpoints');
|
|
31
|
+
const waiters = q('durable_signal_waiters');
|
|
32
|
+
const tables = [
|
|
33
|
+
`CREATE TABLE IF NOT EXISTS ${runs} (
|
|
34
|
+
${q('id')} ${str} PRIMARY KEY,
|
|
35
|
+
${q('workflow')} ${str} NOT NULL,
|
|
36
|
+
${q('workflowVersion')} ${str} NOT NULL,
|
|
37
|
+
${q('status')} ${str} NOT NULL,
|
|
38
|
+
${q('input')} ${txt}, ${q('output')} ${txt}, ${q('error')} ${txt},
|
|
39
|
+
${q('wakeAt')} ${ts}, ${q('lockedBy')} ${str}, ${q('lockedUntil')} ${ts},
|
|
40
|
+
${q('createdAt')} ${ts} NOT NULL, ${q('updatedAt')} ${ts} NOT NULL
|
|
41
|
+
)`,
|
|
42
|
+
`CREATE TABLE IF NOT EXISTS ${checkpoints} (
|
|
43
|
+
${q('runId')} ${str} NOT NULL, ${q('seq')} ${int} NOT NULL,
|
|
44
|
+
${q('name')} ${str} NOT NULL, ${q('kind')} ${str} NOT NULL, ${q('stepId')} ${str} NOT NULL,
|
|
45
|
+
${q('status')} ${str} NOT NULL, ${q('output')} ${txt}, ${q('error')} ${txt},
|
|
46
|
+
${q('attempts')} ${int} NOT NULL, ${q('workerGroup')} ${str},
|
|
47
|
+
${q('wakeAt')} ${ts}, ${q('startedAt')} ${ts} NOT NULL, ${q('finishedAt')} ${ts} NOT NULL,
|
|
48
|
+
PRIMARY KEY (${q('runId')}, ${q('seq')})
|
|
49
|
+
)`,
|
|
50
|
+
`CREATE TABLE IF NOT EXISTS ${waiters} (
|
|
51
|
+
${q('token')} ${str} PRIMARY KEY, ${q('runId')} ${str} NOT NULL, ${q('seq')} ${int} NOT NULL
|
|
52
|
+
)`,
|
|
53
|
+
];
|
|
54
|
+
const runner = dataSource.createQueryRunner();
|
|
55
|
+
try {
|
|
56
|
+
for (const sql of tables)
|
|
57
|
+
await runner.query(sql);
|
|
58
|
+
// MySQL has no `CREATE INDEX IF NOT EXISTS`; create it best-effort and ignore "already exists".
|
|
59
|
+
try {
|
|
60
|
+
await runner.query(`CREATE INDEX ${q('durable_runs_status_idx')} ON ${runs} (${q('status')}, ${q('wakeAt')})`);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
/* index already exists */
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
await runner.release();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=schema.js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AAE,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClD,gGAAgG;QAChG,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,KAAK,CAChB,gBAAgB,CAAC,CAAC,yBAAyB,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAC3F,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,0BAA0B;QAC5B,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RunQuery, SignalWaiter, StateStore, StepCheckpoint, WorkflowRun } from '@dudousxd/nestjs-durable-core';
|
|
2
|
+
import { type DataSource } from 'typeorm';
|
|
3
|
+
/**
|
|
4
|
+
* TypeORM-backed `StateStore`. Works on any TypeORM driver — Postgres, MySQL, SQLite (tested);
|
|
5
|
+
* timestamps use native datetime columns and `wakeAt` is stored as a datetime too.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TypeOrmStateStore implements StateStore {
|
|
8
|
+
private readonly dataSource;
|
|
9
|
+
constructor(dataSource: DataSource);
|
|
10
|
+
ensureSchema(): Promise<void>;
|
|
11
|
+
private runs;
|
|
12
|
+
private checkpoints;
|
|
13
|
+
private waiters;
|
|
14
|
+
createRun(run: WorkflowRun): Promise<void>;
|
|
15
|
+
updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
|
|
16
|
+
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
17
|
+
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
18
|
+
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
19
|
+
listIncompleteRuns(): Promise<WorkflowRun[]>;
|
|
20
|
+
listDueTimers(nowMs: number): Promise<WorkflowRun[]>;
|
|
21
|
+
tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
|
|
22
|
+
releaseRunLock(runId: string): Promise<void>;
|
|
23
|
+
listRuns(query: RunQuery): Promise<WorkflowRun[]>;
|
|
24
|
+
listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
|
|
25
|
+
putSignalWaiter(waiter: SignalWaiter): Promise<void>;
|
|
26
|
+
takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=typeorm-state-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-state-store.d.ts","sourceRoot":"","sources":["../src/typeorm-state-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,cAAc,EAEd,WAAW,EACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAY,KAAK,UAAU,EAA2B,MAAM,SAAS,CAAC;AAI7E;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,UAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAE7C,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,OAAO,CAAC,IAAI;IAGZ,OAAO,CAAC,WAAW;IAGnB,OAAO,CAAC,OAAO;IAIT,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAKlD,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAKzE,cAAc,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,kBAAkB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAK5C,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAQpD,UAAU,CACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC;IAiBb,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAajD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAKzD,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAOpE"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeOrmStateStore = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const entities_1 = require("./entities");
|
|
6
|
+
const schema_1 = require("./schema");
|
|
7
|
+
/**
|
|
8
|
+
* TypeORM-backed `StateStore`. Works on any TypeORM driver — Postgres, MySQL, SQLite (tested);
|
|
9
|
+
* timestamps use native datetime columns and `wakeAt` is stored as a datetime too.
|
|
10
|
+
*/
|
|
11
|
+
class TypeOrmStateStore {
|
|
12
|
+
dataSource;
|
|
13
|
+
constructor(dataSource) {
|
|
14
|
+
this.dataSource = dataSource;
|
|
15
|
+
}
|
|
16
|
+
async ensureSchema() {
|
|
17
|
+
await (0, schema_1.ensureTypeOrmDurableSchema)(this.dataSource);
|
|
18
|
+
}
|
|
19
|
+
runs() {
|
|
20
|
+
return this.dataSource.getRepository(entities_1.WorkflowRunEntity);
|
|
21
|
+
}
|
|
22
|
+
checkpoints() {
|
|
23
|
+
return this.dataSource.getRepository(entities_1.StepCheckpointEntity);
|
|
24
|
+
}
|
|
25
|
+
waiters() {
|
|
26
|
+
return this.dataSource.getRepository(entities_1.SignalWaiterEntity);
|
|
27
|
+
}
|
|
28
|
+
async createRun(run) {
|
|
29
|
+
await this.runs().save(toRunEntity(run));
|
|
30
|
+
}
|
|
31
|
+
async updateRun(runId, patch) {
|
|
32
|
+
const existing = await this.runs().findOneBy({ id: runId });
|
|
33
|
+
if (!existing)
|
|
34
|
+
throw new Error(`run ${runId} not found`);
|
|
35
|
+
const merged = { ...fromRunEntity(existing), ...patch };
|
|
36
|
+
await this.runs().save(toRunEntity(merged));
|
|
37
|
+
}
|
|
38
|
+
async getRun(runId) {
|
|
39
|
+
const e = await this.runs().findOneBy({ id: runId });
|
|
40
|
+
return e ? fromRunEntity(e) : null;
|
|
41
|
+
}
|
|
42
|
+
async getCheckpoint(runId, seq) {
|
|
43
|
+
const e = await this.checkpoints().findOneBy({ runId, seq });
|
|
44
|
+
return e ? fromCheckpointEntity(e) : null;
|
|
45
|
+
}
|
|
46
|
+
async saveCheckpoint(checkpoint) {
|
|
47
|
+
await this.checkpoints().save(toCheckpointEntity(checkpoint));
|
|
48
|
+
}
|
|
49
|
+
async listIncompleteRuns() {
|
|
50
|
+
const rows = await this.runs().findBy({ status: 'running' });
|
|
51
|
+
return rows.map(fromRunEntity);
|
|
52
|
+
}
|
|
53
|
+
async listDueTimers(nowMs) {
|
|
54
|
+
const rows = await this.runs().findBy({
|
|
55
|
+
status: 'suspended',
|
|
56
|
+
wakeAt: (0, typeorm_1.LessThanOrEqual)(new Date(nowMs)),
|
|
57
|
+
});
|
|
58
|
+
return rows.map(fromRunEntity);
|
|
59
|
+
}
|
|
60
|
+
async tryLockRun(runId, owner, leaseUntilMs, nowMs) {
|
|
61
|
+
const result = await this.runs()
|
|
62
|
+
.createQueryBuilder()
|
|
63
|
+
.update()
|
|
64
|
+
.set({ lockedBy: owner, lockedUntil: new Date(leaseUntilMs) })
|
|
65
|
+
.where({ id: runId })
|
|
66
|
+
.andWhere(new typeorm_1.Brackets((qb) => qb
|
|
67
|
+
.where({ lockedUntil: (0, typeorm_1.IsNull)() })
|
|
68
|
+
.orWhere({ lockedUntil: (0, typeorm_1.LessThanOrEqual)(new Date(nowMs)) })))
|
|
69
|
+
.execute();
|
|
70
|
+
return result.affected === 1;
|
|
71
|
+
}
|
|
72
|
+
async releaseRunLock(runId) {
|
|
73
|
+
await this.runs().update({ id: runId }, { lockedBy: null, lockedUntil: () => 'NULL' });
|
|
74
|
+
}
|
|
75
|
+
async listRuns(query) {
|
|
76
|
+
const where = {};
|
|
77
|
+
if (query.workflow)
|
|
78
|
+
where.workflow = query.workflow;
|
|
79
|
+
if (query.status)
|
|
80
|
+
where.status = query.status;
|
|
81
|
+
const rows = await this.runs().find({
|
|
82
|
+
where,
|
|
83
|
+
take: query.limit,
|
|
84
|
+
skip: query.offset,
|
|
85
|
+
order: { createdAt: 'ASC' },
|
|
86
|
+
});
|
|
87
|
+
return rows.map(fromRunEntity);
|
|
88
|
+
}
|
|
89
|
+
async listCheckpoints(runId) {
|
|
90
|
+
const rows = await this.checkpoints().find({ where: { runId }, order: { seq: 'ASC' } });
|
|
91
|
+
return rows.map(fromCheckpointEntity);
|
|
92
|
+
}
|
|
93
|
+
async putSignalWaiter(waiter) {
|
|
94
|
+
await this.waiters().save({ ...waiter });
|
|
95
|
+
}
|
|
96
|
+
async takeSignalWaiter(token) {
|
|
97
|
+
const e = await this.waiters().findOneBy({ token });
|
|
98
|
+
if (!e)
|
|
99
|
+
return null;
|
|
100
|
+
const waiter = { token: e.token, runId: e.runId, seq: e.seq };
|
|
101
|
+
await this.waiters().delete({ token });
|
|
102
|
+
return waiter;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.TypeOrmStateStore = TypeOrmStateStore;
|
|
106
|
+
function toRunEntity(run) {
|
|
107
|
+
return {
|
|
108
|
+
id: run.id,
|
|
109
|
+
workflow: run.workflow,
|
|
110
|
+
workflowVersion: run.workflowVersion,
|
|
111
|
+
status: run.status,
|
|
112
|
+
input: run.input ?? null,
|
|
113
|
+
output: run.output ?? null,
|
|
114
|
+
error: run.error ?? null,
|
|
115
|
+
wakeAt: run.wakeAt == null ? undefined : new Date(run.wakeAt),
|
|
116
|
+
lockedBy: run.lockedBy ?? null,
|
|
117
|
+
lockedUntil: run.lockedUntil == null ? undefined : new Date(run.lockedUntil),
|
|
118
|
+
createdAt: run.createdAt,
|
|
119
|
+
updatedAt: run.updatedAt,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function fromRunEntity(e) {
|
|
123
|
+
return {
|
|
124
|
+
id: e.id,
|
|
125
|
+
workflow: e.workflow,
|
|
126
|
+
workflowVersion: e.workflowVersion,
|
|
127
|
+
status: e.status,
|
|
128
|
+
input: e.input ?? undefined,
|
|
129
|
+
output: e.output ?? undefined,
|
|
130
|
+
error: (e.error ?? undefined),
|
|
131
|
+
wakeAt: e.wakeAt == null ? undefined : e.wakeAt.getTime(),
|
|
132
|
+
lockedBy: e.lockedBy ?? undefined,
|
|
133
|
+
lockedUntil: e.lockedUntil == null ? undefined : e.lockedUntil.getTime(),
|
|
134
|
+
createdAt: e.createdAt,
|
|
135
|
+
updatedAt: e.updatedAt,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function toCheckpointEntity(cp) {
|
|
139
|
+
return {
|
|
140
|
+
runId: cp.runId,
|
|
141
|
+
seq: cp.seq,
|
|
142
|
+
name: cp.name,
|
|
143
|
+
kind: cp.kind,
|
|
144
|
+
stepId: cp.stepId,
|
|
145
|
+
status: cp.status,
|
|
146
|
+
output: cp.output ?? null,
|
|
147
|
+
error: cp.error ?? null,
|
|
148
|
+
attempts: cp.attempts,
|
|
149
|
+
workerGroup: cp.workerGroup ?? null,
|
|
150
|
+
wakeAt: cp.wakeAt == null ? undefined : new Date(cp.wakeAt),
|
|
151
|
+
startedAt: cp.startedAt,
|
|
152
|
+
finishedAt: cp.finishedAt,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function fromCheckpointEntity(e) {
|
|
156
|
+
return {
|
|
157
|
+
runId: e.runId,
|
|
158
|
+
seq: e.seq,
|
|
159
|
+
name: e.name,
|
|
160
|
+
kind: e.kind,
|
|
161
|
+
stepId: e.stepId,
|
|
162
|
+
status: e.status,
|
|
163
|
+
output: e.output ?? undefined,
|
|
164
|
+
error: (e.error ?? undefined),
|
|
165
|
+
attempts: e.attempts,
|
|
166
|
+
workerGroup: e.workerGroup ?? undefined,
|
|
167
|
+
wakeAt: e.wakeAt == null ? undefined : e.wakeAt.getTime(),
|
|
168
|
+
startedAt: e.startedAt,
|
|
169
|
+
finishedAt: e.finishedAt,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=typeorm-state-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-state-store.js","sourceRoot":"","sources":["../src/typeorm-state-store.ts"],"names":[],"mappings":";;;AAQA,qCAA6E;AAC7E,yCAAyF;AACzF,qCAAsD;AAEtD;;;GAGG;AACH,MAAa,iBAAiB;IACC;IAA7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,KAAK,CAAC,YAAY;QAChB,MAAM,IAAA,mCAA0B,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;IAEO,IAAI;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,4BAAiB,CAAC,CAAC;IAC1D,CAAC;IACO,WAAW;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,+BAAoB,CAAC,CAAC;IAC7D,CAAC;IACO,OAAO;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,6BAAkB,CAAC,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,EAAE,CAAC,SAAS;QACvB,UAAU,EAAE,EAAE,CAAC,UAAU;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,CAAuB;IACnD,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,SAAS;QAC7B,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAA0B;QACtD,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,SAAS;QACvC,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;QACzD,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,UAAU,EAAE,CAAC,CAAC,UAAU;KACzB,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dudousxd/nestjs-durable-store-typeorm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeORM adapter for the nestjs-durable StateStore",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Davide Carvalho",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/DavideCarvalho/nestjs-durable.git",
|
|
10
|
+
"directory": "packages/store-typeorm"
|
|
11
|
+
},
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@dudousxd/nestjs-durable-core": ">=0.1.0 <1.0.0",
|
|
20
|
+
"typeorm": "^0.3.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"better-sqlite3": "11.10.0",
|
|
24
|
+
"reflect-metadata": "0.2.2",
|
|
25
|
+
"typeorm": "0.3.30",
|
|
26
|
+
"typescript": "5.9.3",
|
|
27
|
+
"@dudousxd/nestjs-durable-core": "^0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
32
|
+
}
|
|
33
|
+
}
|