@tomflow/proflow-task-store-sqlite 0.1.1 → 0.1.2
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/CHANGELOG.md +6 -0
- package/dist/deployment/adapter.d.ts +213 -25
- package/dist/deployment/adapter.js +114 -19
- package/dist/deployment/descriptor.d.ts +1 -1
- package/dist/deployment/descriptor.js +1 -1
- package/package.json +2 -2
- package/proflow.module.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,47 +1,235 @@
|
|
|
1
|
+
export declare function createBehaviorAdapter(config?: Record<string, string>): {
|
|
2
|
+
describe: () => {
|
|
3
|
+
result: {
|
|
4
|
+
contract: "deployment.result.v1";
|
|
5
|
+
ok: boolean;
|
|
6
|
+
status: "SUCCEEDED";
|
|
7
|
+
moduleRef: "task-store-sqlite";
|
|
8
|
+
moduleVersion: "0.1.2";
|
|
9
|
+
checks?: unknown[];
|
|
10
|
+
};
|
|
11
|
+
observedEffects: never[];
|
|
12
|
+
};
|
|
13
|
+
preflight: () => {
|
|
14
|
+
result: {
|
|
15
|
+
contract: "deployment.result.v1";
|
|
16
|
+
ok: boolean;
|
|
17
|
+
status: "SUCCEEDED";
|
|
18
|
+
moduleRef: "task-store-sqlite";
|
|
19
|
+
moduleVersion: "0.1.2";
|
|
20
|
+
checks?: unknown[];
|
|
21
|
+
} | {
|
|
22
|
+
contract: "deployment.result.v1";
|
|
23
|
+
ok: boolean;
|
|
24
|
+
status: "ACTION_REQUIRED";
|
|
25
|
+
moduleRef: "task-store-sqlite";
|
|
26
|
+
moduleVersion: "0.1.2";
|
|
27
|
+
actionRequired: {
|
|
28
|
+
action: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
checks?: unknown[];
|
|
32
|
+
} | {
|
|
33
|
+
contract: "deployment.result.v1";
|
|
34
|
+
ok: boolean;
|
|
35
|
+
status: "BLOCKED";
|
|
36
|
+
moduleRef: "task-store-sqlite";
|
|
37
|
+
moduleVersion: "0.1.2";
|
|
38
|
+
error: {
|
|
39
|
+
code: "VERIFY_FAILED";
|
|
40
|
+
message: string;
|
|
41
|
+
retryable: boolean;
|
|
42
|
+
};
|
|
43
|
+
checks?: unknown[];
|
|
44
|
+
};
|
|
45
|
+
observedEffects: never[];
|
|
46
|
+
};
|
|
47
|
+
verify: () => {
|
|
48
|
+
result: {
|
|
49
|
+
contract: "deployment.result.v1";
|
|
50
|
+
ok: boolean;
|
|
51
|
+
status: "SUCCEEDED";
|
|
52
|
+
moduleRef: "task-store-sqlite";
|
|
53
|
+
moduleVersion: "0.1.2";
|
|
54
|
+
checks?: unknown[];
|
|
55
|
+
} | {
|
|
56
|
+
contract: "deployment.result.v1";
|
|
57
|
+
ok: boolean;
|
|
58
|
+
status: "ACTION_REQUIRED";
|
|
59
|
+
moduleRef: "task-store-sqlite";
|
|
60
|
+
moduleVersion: "0.1.2";
|
|
61
|
+
actionRequired: {
|
|
62
|
+
action: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
checks?: unknown[];
|
|
66
|
+
} | {
|
|
67
|
+
contract: "deployment.result.v1";
|
|
68
|
+
ok: boolean;
|
|
69
|
+
status: "BLOCKED";
|
|
70
|
+
moduleRef: "task-store-sqlite";
|
|
71
|
+
moduleVersion: "0.1.2";
|
|
72
|
+
error: {
|
|
73
|
+
code: "VERIFY_FAILED";
|
|
74
|
+
message: string;
|
|
75
|
+
retryable: boolean;
|
|
76
|
+
};
|
|
77
|
+
checks?: unknown[];
|
|
78
|
+
};
|
|
79
|
+
observedEffects: never[];
|
|
80
|
+
};
|
|
81
|
+
doctor: () => {
|
|
82
|
+
result: {
|
|
83
|
+
contract: "deployment.result.v1";
|
|
84
|
+
ok: boolean;
|
|
85
|
+
status: "SUCCEEDED";
|
|
86
|
+
moduleRef: "task-store-sqlite";
|
|
87
|
+
moduleVersion: "0.1.2";
|
|
88
|
+
checks?: unknown[];
|
|
89
|
+
} | {
|
|
90
|
+
contract: "deployment.result.v1";
|
|
91
|
+
ok: boolean;
|
|
92
|
+
status: "ACTION_REQUIRED";
|
|
93
|
+
moduleRef: "task-store-sqlite";
|
|
94
|
+
moduleVersion: "0.1.2";
|
|
95
|
+
actionRequired: {
|
|
96
|
+
action: string;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
checks?: unknown[];
|
|
100
|
+
} | {
|
|
101
|
+
contract: "deployment.result.v1";
|
|
102
|
+
ok: boolean;
|
|
103
|
+
status: "BLOCKED";
|
|
104
|
+
moduleRef: "task-store-sqlite";
|
|
105
|
+
moduleVersion: "0.1.2";
|
|
106
|
+
error: {
|
|
107
|
+
code: "VERIFY_FAILED";
|
|
108
|
+
message: string;
|
|
109
|
+
retryable: boolean;
|
|
110
|
+
};
|
|
111
|
+
checks?: unknown[];
|
|
112
|
+
};
|
|
113
|
+
observedEffects: never[];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
1
116
|
export declare const behaviorAdapter: {
|
|
2
|
-
|
|
117
|
+
describe: () => {
|
|
3
118
|
result: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
119
|
+
contract: "deployment.result.v1";
|
|
120
|
+
ok: boolean;
|
|
121
|
+
status: "SUCCEEDED";
|
|
122
|
+
moduleRef: "task-store-sqlite";
|
|
123
|
+
moduleVersion: "0.1.2";
|
|
124
|
+
checks?: unknown[];
|
|
9
125
|
};
|
|
10
126
|
observedEffects: never[];
|
|
11
127
|
};
|
|
12
|
-
|
|
128
|
+
preflight: () => {
|
|
13
129
|
result: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
130
|
+
contract: "deployment.result.v1";
|
|
131
|
+
ok: boolean;
|
|
132
|
+
status: "SUCCEEDED";
|
|
133
|
+
moduleRef: "task-store-sqlite";
|
|
134
|
+
moduleVersion: "0.1.2";
|
|
135
|
+
checks?: unknown[];
|
|
136
|
+
} | {
|
|
137
|
+
contract: "deployment.result.v1";
|
|
138
|
+
ok: boolean;
|
|
139
|
+
status: "ACTION_REQUIRED";
|
|
140
|
+
moduleRef: "task-store-sqlite";
|
|
141
|
+
moduleVersion: "0.1.2";
|
|
142
|
+
actionRequired: {
|
|
143
|
+
action: string;
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
checks?: unknown[];
|
|
147
|
+
} | {
|
|
148
|
+
contract: "deployment.result.v1";
|
|
149
|
+
ok: boolean;
|
|
150
|
+
status: "BLOCKED";
|
|
151
|
+
moduleRef: "task-store-sqlite";
|
|
152
|
+
moduleVersion: "0.1.2";
|
|
153
|
+
error: {
|
|
154
|
+
code: "VERIFY_FAILED";
|
|
155
|
+
message: string;
|
|
156
|
+
retryable: boolean;
|
|
157
|
+
};
|
|
158
|
+
checks?: unknown[];
|
|
19
159
|
};
|
|
20
160
|
observedEffects: never[];
|
|
21
161
|
};
|
|
22
|
-
|
|
162
|
+
verify: () => {
|
|
23
163
|
result: {
|
|
24
164
|
contract: "deployment.result.v1";
|
|
25
|
-
ok:
|
|
165
|
+
ok: boolean;
|
|
26
166
|
status: "SUCCEEDED";
|
|
27
167
|
moduleRef: "task-store-sqlite";
|
|
28
|
-
moduleVersion: "0.1.
|
|
29
|
-
checks
|
|
30
|
-
|
|
31
|
-
|
|
168
|
+
moduleVersion: "0.1.2";
|
|
169
|
+
checks?: unknown[];
|
|
170
|
+
} | {
|
|
171
|
+
contract: "deployment.result.v1";
|
|
172
|
+
ok: boolean;
|
|
173
|
+
status: "ACTION_REQUIRED";
|
|
174
|
+
moduleRef: "task-store-sqlite";
|
|
175
|
+
moduleVersion: "0.1.2";
|
|
176
|
+
actionRequired: {
|
|
177
|
+
action: string;
|
|
178
|
+
description: string;
|
|
179
|
+
};
|
|
180
|
+
checks?: unknown[];
|
|
181
|
+
} | {
|
|
182
|
+
contract: "deployment.result.v1";
|
|
183
|
+
ok: boolean;
|
|
184
|
+
status: "BLOCKED";
|
|
185
|
+
moduleRef: "task-store-sqlite";
|
|
186
|
+
moduleVersion: "0.1.2";
|
|
187
|
+
error: {
|
|
188
|
+
code: "VERIFY_FAILED";
|
|
32
189
|
message: string;
|
|
33
|
-
|
|
190
|
+
retryable: boolean;
|
|
191
|
+
};
|
|
192
|
+
checks?: unknown[];
|
|
34
193
|
};
|
|
35
194
|
observedEffects: never[];
|
|
36
195
|
};
|
|
37
|
-
|
|
196
|
+
doctor: () => {
|
|
38
197
|
result: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
198
|
+
contract: "deployment.result.v1";
|
|
199
|
+
ok: boolean;
|
|
200
|
+
status: "SUCCEEDED";
|
|
201
|
+
moduleRef: "task-store-sqlite";
|
|
202
|
+
moduleVersion: "0.1.2";
|
|
203
|
+
checks?: unknown[];
|
|
204
|
+
} | {
|
|
205
|
+
contract: "deployment.result.v1";
|
|
206
|
+
ok: boolean;
|
|
207
|
+
status: "ACTION_REQUIRED";
|
|
208
|
+
moduleRef: "task-store-sqlite";
|
|
209
|
+
moduleVersion: "0.1.2";
|
|
210
|
+
actionRequired: {
|
|
211
|
+
action: string;
|
|
212
|
+
description: string;
|
|
213
|
+
};
|
|
214
|
+
checks?: unknown[];
|
|
215
|
+
} | {
|
|
216
|
+
contract: "deployment.result.v1";
|
|
217
|
+
ok: boolean;
|
|
218
|
+
status: "BLOCKED";
|
|
219
|
+
moduleRef: "task-store-sqlite";
|
|
220
|
+
moduleVersion: "0.1.2";
|
|
221
|
+
error: {
|
|
222
|
+
code: "VERIFY_FAILED";
|
|
223
|
+
message: string;
|
|
224
|
+
retryable: boolean;
|
|
225
|
+
};
|
|
226
|
+
checks?: unknown[];
|
|
44
227
|
};
|
|
45
228
|
observedEffects: never[];
|
|
46
229
|
};
|
|
47
230
|
};
|
|
231
|
+
export declare function createProductionBinding(input: {
|
|
232
|
+
config: Record<string, string>;
|
|
233
|
+
}): {
|
|
234
|
+
behaviorAdapter: Record<string, unknown>;
|
|
235
|
+
};
|
|
@@ -1,26 +1,121 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { DatabaseSync } from "node:sqlite";
|
|
1
3
|
import { descriptor } from "./descriptor.js";
|
|
2
|
-
const
|
|
4
|
+
const REQUIRED_TABLES = [
|
|
5
|
+
"schema_migrations",
|
|
6
|
+
"task_groups",
|
|
7
|
+
"tasks",
|
|
8
|
+
"nodes",
|
|
9
|
+
"task_role_bindings",
|
|
10
|
+
"node_execution_history",
|
|
11
|
+
"task_documents",
|
|
12
|
+
"task_messages",
|
|
13
|
+
"task_events",
|
|
14
|
+
"idempotency_records",
|
|
15
|
+
];
|
|
16
|
+
const success = (checks) => ({
|
|
3
17
|
contract: "deployment.result.v1",
|
|
4
18
|
ok: true,
|
|
5
19
|
status: "SUCCEEDED",
|
|
6
20
|
moduleRef: descriptor.moduleRef,
|
|
7
21
|
moduleVersion: descriptor.moduleVersion,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
...(checks === undefined ? {} : { checks }),
|
|
23
|
+
});
|
|
24
|
+
const actionRequired = (description, checks) => ({
|
|
25
|
+
contract: "deployment.result.v1",
|
|
26
|
+
ok: false,
|
|
27
|
+
status: "ACTION_REQUIRED",
|
|
28
|
+
moduleRef: descriptor.moduleRef,
|
|
29
|
+
moduleVersion: descriptor.moduleVersion,
|
|
30
|
+
actionRequired: { action: "configure-task-store", description },
|
|
31
|
+
...(checks === undefined ? {} : { checks }),
|
|
32
|
+
});
|
|
33
|
+
const blocked = (message, checks) => ({
|
|
34
|
+
contract: "deployment.result.v1",
|
|
35
|
+
ok: false,
|
|
36
|
+
status: "BLOCKED",
|
|
37
|
+
moduleRef: descriptor.moduleRef,
|
|
38
|
+
moduleVersion: descriptor.moduleVersion,
|
|
39
|
+
error: { code: "VERIFY_FAILED", message, retryable: true },
|
|
40
|
+
...(checks === undefined ? {} : { checks }),
|
|
41
|
+
});
|
|
42
|
+
function inspect(databasePath) {
|
|
43
|
+
if (!databasePath)
|
|
44
|
+
return { ok: false, message: "databasePath is required" };
|
|
45
|
+
if (!existsSync(databasePath)) {
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
message: `Task SQLite database does not exist at ${databasePath}`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
let database;
|
|
52
|
+
try {
|
|
53
|
+
database = new DatabaseSync(databasePath, { readOnly: true });
|
|
54
|
+
const integrity = database.prepare("PRAGMA integrity_check").get();
|
|
55
|
+
const tables = new Set(database
|
|
56
|
+
.prepare("SELECT name FROM sqlite_master WHERE type='table'")
|
|
57
|
+
.all().map((row) => row.name));
|
|
58
|
+
const missing = REQUIRED_TABLES.filter((table) => !tables.has(table));
|
|
59
|
+
if (integrity?.integrity_check !== "ok") {
|
|
60
|
+
return {
|
|
61
|
+
ok: false,
|
|
62
|
+
message: `SQLite integrity_check returned ${integrity?.integrity_check ?? "unknown"}`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (missing.length > 0) {
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
message: `Task SQLite schema is missing tables: ${missing.join(", ")}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
ok: true,
|
|
73
|
+
message: "Task SQLite schema is present and integrity_check is ok",
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
ok: false,
|
|
79
|
+
message: error instanceof Error
|
|
80
|
+
? error.message
|
|
81
|
+
: "Task SQLite reality could not be read",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
database?.close();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function createBehaviorAdapter(config = {}) {
|
|
89
|
+
const resultForReality = (reality, checks) => reality.ok
|
|
90
|
+
? success(checks)
|
|
91
|
+
: config.databasePath
|
|
92
|
+
? blocked(reality.message, checks)
|
|
93
|
+
: actionRequired(reality.message, checks);
|
|
94
|
+
return {
|
|
95
|
+
describe: () => ({ result: success(), observedEffects: [] }),
|
|
96
|
+
preflight: () => {
|
|
97
|
+
const reality = inspect(config.databasePath);
|
|
98
|
+
return { result: resultForReality(reality), observedEffects: [] };
|
|
99
|
+
},
|
|
100
|
+
verify: () => {
|
|
101
|
+
const reality = inspect(config.databasePath);
|
|
102
|
+
const check = {
|
|
103
|
+
id: "sqlite-integrity-pass",
|
|
104
|
+
status: reality.ok ? "PASS" : "FAIL",
|
|
105
|
+
message: reality.message,
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
result: resultForReality(reality, [check]),
|
|
109
|
+
observedEffects: [],
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
doctor: () => {
|
|
113
|
+
const reality = inspect(config.databasePath);
|
|
114
|
+
return { result: resultForReality(reality), observedEffects: [] };
|
|
22
115
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export const behaviorAdapter = createBehaviorAdapter();
|
|
119
|
+
export function createProductionBinding(input) {
|
|
120
|
+
return { behaviorAdapter: createBehaviorAdapter(input.config) };
|
|
121
|
+
}
|
|
@@ -3,7 +3,7 @@ export declare const descriptor: {
|
|
|
3
3
|
readonly contractVersion: "1.0.0";
|
|
4
4
|
readonly moduleRef: "task-store-sqlite";
|
|
5
5
|
readonly packageName: "@tomflow/proflow-task-store-sqlite";
|
|
6
|
-
readonly moduleVersion: "0.1.
|
|
6
|
+
readonly moduleVersion: "0.1.2";
|
|
7
7
|
readonly kind: "library";
|
|
8
8
|
readonly templateVersion: "1.0.0";
|
|
9
9
|
readonly platformCompatibility: ">=1.0.0 <2.0.0";
|
|
@@ -3,7 +3,7 @@ export const descriptor = {
|
|
|
3
3
|
contractVersion: "1.0.0",
|
|
4
4
|
moduleRef: "task-store-sqlite",
|
|
5
5
|
packageName: "@tomflow/proflow-task-store-sqlite",
|
|
6
|
-
moduleVersion: "0.1.
|
|
6
|
+
moduleVersion: "0.1.2",
|
|
7
7
|
kind: "library",
|
|
8
8
|
templateVersion: "1.0.0",
|
|
9
9
|
platformCompatibility: ">=1.0.0 <2.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomflow/proflow-task-store-sqlite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@tomflow/proflow-task-orchestration": "^0.1.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@tomflow/proflow-task-migration-runner": "^0.1.
|
|
26
|
+
"@tomflow/proflow-task-migration-runner": "^0.1.2"
|
|
27
27
|
},
|
|
28
28
|
"description": "Provides the node:sqlite store and repository adapters for Task-owned structured facts.",
|
|
29
29
|
"keywords": [
|
package/proflow.module.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"contractVersion": "1.0.0",
|
|
4
4
|
"moduleRef": "task-store-sqlite",
|
|
5
5
|
"packageName": "@tomflow/proflow-task-store-sqlite",
|
|
6
|
-
"moduleVersion": "0.1.
|
|
6
|
+
"moduleVersion": "0.1.2",
|
|
7
7
|
"kind": "library",
|
|
8
8
|
"templateVersion": "1.0.0",
|
|
9
9
|
"platformCompatibility": ">=1.0.0 <2.0.0",
|