@sixb/pg 0.0.1 → 0.1.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.js +47 -4
- package/dist/index.js.map +5 -5
- package/dist/migrations.d.ts.map +1 -1
- package/dist/pg-workflow-run-storage.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/migrations/002-workflow-run-output.sql +27 -0
- package/src/migrations/003-merge-sync-runs.sql +3 -0
- package/src/migrations.ts +7 -1
- package/src/pg-sync-run-storage.ts +2 -2
- package/src/pg-workflow-run-storage.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -4068,6 +4068,42 @@ CREATE INDEX idx_agent_messages_project_thread_role
|
|
|
4068
4068
|
ON agent_messages (project_id, thread_id, role, seq);
|
|
4069
4069
|
`;
|
|
4070
4070
|
|
|
4071
|
+
// src/migrations/002-workflow-run-output.sql
|
|
4072
|
+
var _002_workflow_run_output_default = `ALTER TABLE workflow_runs ADD COLUMN output JSONB;
|
|
4073
|
+
|
|
4074
|
+
UPDATE workflow_runs AS run
|
|
4075
|
+
SET output = CASE
|
|
4076
|
+
WHEN EXISTS (
|
|
4077
|
+
SELECT 1
|
|
4078
|
+
FROM workflow_node_runs AS node
|
|
4079
|
+
WHERE node.project_id = run.project_id
|
|
4080
|
+
AND node.workflow_run_id = run.id
|
|
4081
|
+
AND node.status = 'succeeded'
|
|
4082
|
+
AND node.node_type <> 'action'
|
|
4083
|
+
) THEN COALESCE(
|
|
4084
|
+
(
|
|
4085
|
+
SELECT node.output
|
|
4086
|
+
FROM workflow_node_runs AS node
|
|
4087
|
+
WHERE node.project_id = run.project_id
|
|
4088
|
+
AND node.workflow_run_id = run.id
|
|
4089
|
+
AND node.status = 'succeeded'
|
|
4090
|
+
AND node.node_type <> 'action'
|
|
4091
|
+
ORDER BY node.node_index DESC, node.id DESC
|
|
4092
|
+
LIMIT 1
|
|
4093
|
+
),
|
|
4094
|
+
'{}'::jsonb
|
|
4095
|
+
)
|
|
4096
|
+
ELSE run.input
|
|
4097
|
+
END
|
|
4098
|
+
WHERE run.status = 'succeeded';
|
|
4099
|
+
`;
|
|
4100
|
+
|
|
4101
|
+
// src/migrations/003-merge-sync-runs.sql
|
|
4102
|
+
var _003_merge_sync_runs_default = `ALTER TABLE sync_runs
|
|
4103
|
+
DROP CONSTRAINT sync_runs_mode_check,
|
|
4104
|
+
ADD CONSTRAINT sync_runs_mode_check CHECK (mode IN ('snapshot', 'append', 'merge'));
|
|
4105
|
+
`;
|
|
4106
|
+
|
|
4071
4107
|
// src/migrations.ts
|
|
4072
4108
|
var POSTGRES_STORAGE_ADAPTER_ID = "SixbPostgresStorage";
|
|
4073
4109
|
function pgSql(id, sqlText) {
|
|
@@ -4242,7 +4278,11 @@ function checksum(value) {
|
|
|
4242
4278
|
}
|
|
4243
4279
|
var postgresStorageMigrations = defineMigrations({
|
|
4244
4280
|
adapterId: POSTGRES_STORAGE_ADAPTER_ID,
|
|
4245
|
-
steps: [
|
|
4281
|
+
steps: [
|
|
4282
|
+
pgSql("001-initial-schema", _001_initial_schema_default),
|
|
4283
|
+
pgSql("002-workflow-run-output", _002_workflow_run_output_default),
|
|
4284
|
+
pgSql("003-merge-sync-runs", _003_merge_sync_runs_default)
|
|
4285
|
+
]
|
|
4246
4286
|
});
|
|
4247
4287
|
|
|
4248
4288
|
// src/ontology-storage/shared.ts
|
|
@@ -10261,8 +10301,8 @@ class PgSyncRunStorage {
|
|
|
10261
10301
|
if (input.output && input.output.datasetId !== existing.dataset_id) {
|
|
10262
10302
|
throw new SyncRunError(`[SixbPg] Sync run '${input.id}' output dataset '${input.output.datasetId}' does not match '${existing.dataset_id}'.`);
|
|
10263
10303
|
}
|
|
10264
|
-
if (!input.output &&
|
|
10265
|
-
throw new SyncRunError(`[SixbPg] Sync run '${input.id}' may omit its output only for an
|
|
10304
|
+
if (!input.output && input.rowsRead !== 0 && existing.mode !== "merge") {
|
|
10305
|
+
throw new SyncRunError(`[SixbPg] Sync run '${input.id}' may omit its output with rows read only for an initial merge no-op.`);
|
|
10266
10306
|
}
|
|
10267
10307
|
}
|
|
10268
10308
|
const [updated] = input.status === "succeeded" ? await tx`
|
|
@@ -11183,6 +11223,7 @@ class PgWorkflowRunStorage {
|
|
|
11183
11223
|
SET
|
|
11184
11224
|
status = ${input.status},
|
|
11185
11225
|
finished_at = ${input.finishedAt ?? new Date},
|
|
11226
|
+
output = ${serializeRecord2(input.output)}::text::jsonb,
|
|
11186
11227
|
error = ${null},
|
|
11187
11228
|
execution_token = ${null},
|
|
11188
11229
|
execution_queue_lease_expires_at = ${null}
|
|
@@ -11193,6 +11234,7 @@ class PgWorkflowRunStorage {
|
|
|
11193
11234
|
SET
|
|
11194
11235
|
status = ${input.status},
|
|
11195
11236
|
finished_at = ${input.finishedAt ?? new Date},
|
|
11237
|
+
output = ${null},
|
|
11196
11238
|
error = ${input.error ?? null},
|
|
11197
11239
|
execution_token = ${null},
|
|
11198
11240
|
execution_queue_lease_expires_at = ${null}
|
|
@@ -11662,6 +11704,7 @@ function rowToWorkflowRunRecord(row) {
|
|
|
11662
11704
|
workflowId: row.workflow_id,
|
|
11663
11705
|
status: row.status,
|
|
11664
11706
|
input: parseRecord2(row.input),
|
|
11707
|
+
output: row.output ? parseRecord2(row.output) : undefined,
|
|
11665
11708
|
queuedAt: row.queued_at ? new Date(row.queued_at) : undefined,
|
|
11666
11709
|
startedAt: new Date(row.started_at),
|
|
11667
11710
|
finishedAt: row.finished_at ? new Date(row.finished_at) : undefined,
|
|
@@ -11954,4 +11997,4 @@ export {
|
|
|
11954
11997
|
PostgresStorage
|
|
11955
11998
|
};
|
|
11956
11999
|
|
|
11957
|
-
//# debugId=
|
|
12000
|
+
//# debugId=DB9036A2B767549A64756E2164756E21
|