@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/migrations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAU3B,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,aAAa,CAAA;AAEjD,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED,eAAO,MAAM,2BAA2B,wBAAwB,CAAA;AAEhE,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,wBAAwB,CAAC,CAE1F;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,OAAO,EAAE,wB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C;CA0DlF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/pg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "PostgreSQL storage provider for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -37,10 +37,13 @@
|
|
|
37
37
|
"prepack": "bun run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@sixb/core": "0.0.1",
|
|
41
40
|
"postgres": "^3.4.5"
|
|
42
41
|
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@sixb/core": "0.1.1"
|
|
44
|
+
},
|
|
43
45
|
"devDependencies": {
|
|
46
|
+
"@sixb/core": "0.1.1",
|
|
44
47
|
"@types/bun": "latest",
|
|
45
48
|
"typescript": "^5.7.0"
|
|
46
49
|
},
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
ALTER TABLE workflow_runs ADD COLUMN output JSONB;
|
|
2
|
+
|
|
3
|
+
UPDATE workflow_runs AS run
|
|
4
|
+
SET output = CASE
|
|
5
|
+
WHEN EXISTS (
|
|
6
|
+
SELECT 1
|
|
7
|
+
FROM workflow_node_runs AS node
|
|
8
|
+
WHERE node.project_id = run.project_id
|
|
9
|
+
AND node.workflow_run_id = run.id
|
|
10
|
+
AND node.status = 'succeeded'
|
|
11
|
+
AND node.node_type <> 'action'
|
|
12
|
+
) THEN COALESCE(
|
|
13
|
+
(
|
|
14
|
+
SELECT node.output
|
|
15
|
+
FROM workflow_node_runs AS node
|
|
16
|
+
WHERE node.project_id = run.project_id
|
|
17
|
+
AND node.workflow_run_id = run.id
|
|
18
|
+
AND node.status = 'succeeded'
|
|
19
|
+
AND node.node_type <> 'action'
|
|
20
|
+
ORDER BY node.node_index DESC, node.id DESC
|
|
21
|
+
LIMIT 1
|
|
22
|
+
),
|
|
23
|
+
'{}'::jsonb
|
|
24
|
+
)
|
|
25
|
+
ELSE run.input
|
|
26
|
+
END
|
|
27
|
+
WHERE run.status = 'succeeded';
|
package/src/migrations.ts
CHANGED
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
step,
|
|
15
15
|
} from "@sixb/core/storage"
|
|
16
16
|
import initialSchemaSql from "./migrations/001-initial-schema.sql" with { type: "text" }
|
|
17
|
+
import workflowRunOutputSql from "./migrations/002-workflow-run-output.sql" with { type: "text" }
|
|
18
|
+
import mergeSyncRunsSql from "./migrations/003-merge-sync-runs.sql" with { type: "text" }
|
|
17
19
|
import type { SQL, SQLClient } from "./pg-client"
|
|
18
20
|
|
|
19
21
|
export interface PostgresMigrationContext {
|
|
@@ -266,7 +268,11 @@ function checksum(value: string): string {
|
|
|
266
268
|
|
|
267
269
|
export const postgresStorageMigrations = defineMigrations<PostgresMigrationContext>({
|
|
268
270
|
adapterId: POSTGRES_STORAGE_ADAPTER_ID,
|
|
269
|
-
steps: [
|
|
271
|
+
steps: [
|
|
272
|
+
pgSql("001-initial-schema", initialSchemaSql),
|
|
273
|
+
pgSql("002-workflow-run-output", workflowRunOutputSql),
|
|
274
|
+
pgSql("003-merge-sync-runs", mergeSyncRunsSql),
|
|
275
|
+
],
|
|
270
276
|
})
|
|
271
277
|
|
|
272
278
|
interface PostgresMigrationRow {
|
|
@@ -78,9 +78,9 @@ export class PgSyncRunStorage implements SyncRunStorage {
|
|
|
78
78
|
`[SixbPg] Sync run '${input.id}' output dataset '${input.output.datasetId}' does not match '${existing.dataset_id}'.`
|
|
79
79
|
)
|
|
80
80
|
}
|
|
81
|
-
if (!input.output &&
|
|
81
|
+
if (!input.output && input.rowsRead !== 0 && existing.mode !== "merge") {
|
|
82
82
|
throw new SyncRunError(
|
|
83
|
-
`[SixbPg] Sync run '${input.id}' may omit its output only for an
|
|
83
|
+
`[SixbPg] Sync run '${input.id}' may omit its output with rows read only for an initial merge no-op.`
|
|
84
84
|
)
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -245,6 +245,7 @@ export class PgWorkflowRunStorage implements WorkflowRunStorage {
|
|
|
245
245
|
SET
|
|
246
246
|
status = ${input.status},
|
|
247
247
|
finished_at = ${input.finishedAt ?? new Date()},
|
|
248
|
+
output = ${serializeRecord(input.output)}::text::jsonb,
|
|
248
249
|
error = ${null},
|
|
249
250
|
execution_token = ${null},
|
|
250
251
|
execution_queue_lease_expires_at = ${null}
|
|
@@ -256,6 +257,7 @@ export class PgWorkflowRunStorage implements WorkflowRunStorage {
|
|
|
256
257
|
SET
|
|
257
258
|
status = ${input.status},
|
|
258
259
|
finished_at = ${input.finishedAt ?? new Date()},
|
|
260
|
+
output = ${null},
|
|
259
261
|
error = ${input.error ?? null},
|
|
260
262
|
execution_token = ${null},
|
|
261
263
|
execution_queue_lease_expires_at = ${null}
|
|
@@ -825,6 +827,7 @@ function rowToWorkflowRunRecord(row: WorkflowRunDatabaseRow): WorkflowRunRecord
|
|
|
825
827
|
workflowId: row.workflow_id,
|
|
826
828
|
status: row.status,
|
|
827
829
|
input: parseRecord(row.input),
|
|
830
|
+
output: row.output ? parseRecord(row.output) : undefined,
|
|
828
831
|
queuedAt: row.queued_at ? new Date(row.queued_at) : undefined,
|
|
829
832
|
startedAt: new Date(row.started_at),
|
|
830
833
|
finishedAt: row.finished_at ? new Date(row.finished_at) : undefined,
|
|
@@ -896,6 +899,7 @@ interface WorkflowRunDatabaseRow {
|
|
|
896
899
|
workflow_id: string
|
|
897
900
|
status: WorkflowRunRecord["status"]
|
|
898
901
|
input: WorkflowIOSnapshot | string
|
|
902
|
+
output: WorkflowIOSnapshot | string | null
|
|
899
903
|
queued_at: Date | string | null
|
|
900
904
|
started_at: Date | string
|
|
901
905
|
finished_at: Date | string | null
|