@sixb/sqlite 0.1.1 → 0.1.3
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/README.md +18 -13
- package/dist/action-run-storage.d.ts +5 -2
- package/dist/action-run-storage.d.ts.map +1 -1
- package/dist/agents/agent-storage.d.ts +9 -5
- package/dist/agents/agent-storage.d.ts.map +1 -1
- package/dist/agents/checkpoints.d.ts +14 -0
- package/dist/agents/checkpoints.d.ts.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/messages.d.ts +2 -1
- package/dist/agents/messages.d.ts.map +1 -1
- package/dist/agents/rows.d.ts +21 -11
- package/dist/agents/rows.d.ts.map +1 -1
- package/dist/agents/runs.d.ts +3 -2
- package/dist/agents/runs.d.ts.map +1 -1
- package/dist/ai-cost-storage.d.ts +15 -0
- package/dist/ai-cost-storage.d.ts.map +1 -0
- package/dist/ai-usage-storage.d.ts +22 -0
- package/dist/ai-usage-storage.d.ts.map +1 -0
- package/dist/auth-storage/service-accounts.d.ts.map +1 -1
- package/dist/auth-storage/shared.d.ts +1 -10
- package/dist/auth-storage/shared.d.ts.map +1 -1
- package/dist/connector-connection-storage.d.ts +9 -0
- package/dist/connector-connection-storage.d.ts.map +1 -0
- package/dist/execution-storage.d.ts +14 -0
- package/dist/execution-storage.d.ts.map +1 -0
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4633 -1066
- package/dist/index.js.map +33 -28
- package/dist/latest-run-query.d.ts.map +1 -1
- package/dist/migrations.d.ts +0 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/ontology-storage/materialization-session.d.ts +50 -8
- package/dist/ontology-storage/materialization-session.d.ts.map +1 -1
- package/dist/ontology-storage/materialization-state.d.ts +4 -5
- package/dist/ontology-storage/materialization-state.d.ts.map +1 -1
- package/dist/ontology-storage/materialization-writer.d.ts.map +1 -1
- package/dist/ontology-storage/materializations.d.ts +0 -2
- package/dist/ontology-storage/materializations.d.ts.map +1 -1
- package/dist/ontology-storage/outbox.d.ts.map +1 -1
- package/dist/ontology-storage/shared.d.ts +3 -3
- package/dist/ontology-storage/shared.d.ts.map +1 -1
- package/dist/ontology-storage/sources.d.ts.map +1 -1
- package/dist/pipeline-run-storage.d.ts +7 -2
- package/dist/pipeline-run-storage.d.ts.map +1 -1
- package/dist/projection-run-storage.d.ts +9 -2
- package/dist/projection-run-storage.d.ts.map +1 -1
- package/dist/run-list-query.d.ts +1 -1
- package/dist/run-list-query.d.ts.map +1 -1
- package/dist/sync-run-storage.d.ts +7 -2
- package/dist/sync-run-storage.d.ts.map +1 -1
- package/dist/testing.d.ts +6 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/transactions.d.ts +3 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/webhook-run-storage.d.ts +9 -2
- package/dist/webhook-run-storage.d.ts.map +1 -1
- package/dist/workflow-run-storage.d.ts +7 -3
- package/dist/workflow-run-storage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/action-run-storage.ts +51 -74
- package/src/agents/agent-storage.ts +11 -6
- package/src/agents/checkpoints.ts +175 -0
- package/src/agents/index.ts +1 -0
- package/src/agents/messages.ts +59 -0
- package/src/agents/rows.ts +52 -40
- package/src/agents/runs.ts +27 -21
- package/src/ai-cost-storage.ts +744 -0
- package/src/ai-usage-storage.ts +324 -0
- package/src/auth-storage/service-accounts.ts +14 -21
- package/src/auth-storage/shared.ts +0 -22
- package/src/connector-connection-storage.ts +784 -0
- package/src/execution-storage.ts +158 -0
- package/src/index.ts +69 -22
- package/src/latest-run-query.ts +7 -1
- package/src/migrations/004-executions.sql +142 -0
- package/src/migrations/005-workflow-executions.sql +7 -0
- package/src/migrations/006-narrow-ontology-source-root-index.sql +4 -0
- package/src/migrations/007-split-overrides.sql +154 -0
- package/src/migrations/008-action-executions.sql +4 -0
- package/src/migrations/009-agent-executions.sql +115 -0
- package/src/migrations/010-ai-usage-accounting-foundation.sql +74 -0
- package/src/migrations/011-sync-failure-record.sql +22 -0
- package/src/migrations/012-pipeline-failure-record.sql +45 -0
- package/src/migrations/013-workflow-failure-record.sql +45 -0
- package/src/migrations/014-agent-failure-record.sql +59 -0
- package/src/migrations/015-projection-failure-record.sql +20 -0
- package/src/migrations/016-webhook-run-failure-record.sql +19 -0
- package/src/migrations/017-action-failure-record.sql +65 -0
- package/src/migrations/018-ontology-outbox-failure-record.sql +80 -0
- package/src/migrations/019-webhook-delivery-failure-record.sql +62 -0
- package/src/migrations/020-drop-run-usage-projections.sql +7 -0
- package/src/migrations/021-sync-pipeline-executions.sql +101 -0
- package/src/migrations/022-projection-executions.sql +244 -0
- package/src/migrations/023-webhook-executions.sql +51 -0
- package/src/migrations/024-ontology-commit-executions.sql +58 -0
- package/src/migrations/025-connector-connections.sql +257 -0
- package/src/migrations/026-ai-cost-accounting.sql +57 -0
- package/src/migrations/027-agent-context-checkpoints.sql +28 -0
- package/src/migrations/028-object-override-edit-times.sql +3 -0
- package/src/migrations.ts +129 -4
- package/src/ontology-storage/materialization-session.ts +317 -143
- package/src/ontology-storage/materialization-state.ts +323 -112
- package/src/ontology-storage/materialization-writer.ts +145 -67
- package/src/ontology-storage/materializations.ts +67 -141
- package/src/ontology-storage/outbox.ts +10 -3
- package/src/ontology-storage/shared.ts +10 -4
- package/src/ontology-storage/sources.ts +4 -1
- package/src/pipeline-run-storage.ts +128 -43
- package/src/projection-run-storage.ts +209 -97
- package/src/run-list-query.ts +9 -4
- package/src/sync-run-storage.ts +118 -32
- package/src/testing.ts +20 -0
- package/src/transactions.ts +10 -3
- package/src/webhook-run-storage.ts +118 -74
- package/src/workflow-run-storage.ts +117 -131
- package/dist/validation.d.ts +0 -5
- package/dist/validation.d.ts.map +0 -1
- package/dist/webhook-delivery-storage.d.ts +0 -27
- package/dist/webhook-delivery-storage.d.ts.map +0 -1
- package/src/validation.ts +0 -30
- package/src/webhook-delivery-storage.ts +0 -272
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite"
|
|
2
|
+
import { parseSixbFailure } from "@sixb/core/internal/errors"
|
|
2
3
|
import type { ProjectionEntityRef } from "@sixb/core/internal/materialization"
|
|
3
4
|
import { MaterializationConflictError } from "@sixb/core/internal/materialization"
|
|
4
5
|
import type {
|
|
@@ -9,6 +10,7 @@ import type {
|
|
|
9
10
|
OntologySourceRecord,
|
|
10
11
|
StageSourceAssertion,
|
|
11
12
|
} from "@sixb/core/storage"
|
|
13
|
+
import { ONTOLOGY_OUTBOX_FAILURE_CODES } from "@sixb/core/storage"
|
|
12
14
|
|
|
13
15
|
export {
|
|
14
16
|
assertNonblank,
|
|
@@ -30,6 +32,7 @@ export interface SqliteOntologyCommitRow {
|
|
|
30
32
|
readonly id: string
|
|
31
33
|
readonly idempotency_key: string
|
|
32
34
|
readonly request_hash: string
|
|
35
|
+
readonly execution_id: string
|
|
33
36
|
readonly origin_kind: string
|
|
34
37
|
readonly origin_run_id: string | null
|
|
35
38
|
readonly origin_batch_ordinal: number | null
|
|
@@ -83,8 +86,7 @@ export interface SqliteOntologySourceAssertionRow {
|
|
|
83
86
|
readonly assertion: string
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
export interface
|
|
87
|
-
readonly entity_kind: "object" | "link"
|
|
89
|
+
export interface SqliteStoredOverrideRow {
|
|
88
90
|
readonly value: string
|
|
89
91
|
readonly last_commit_id: string
|
|
90
92
|
readonly updated_at: string
|
|
@@ -97,7 +99,7 @@ export interface SqliteOntologyOutboxRow {
|
|
|
97
99
|
readonly lease_id: string | null
|
|
98
100
|
readonly lease_expires_at: string | null
|
|
99
101
|
readonly published_at: string | null
|
|
100
|
-
readonly
|
|
102
|
+
readonly last_failure: string | null
|
|
101
103
|
readonly created_at: string
|
|
102
104
|
}
|
|
103
105
|
|
|
@@ -148,6 +150,7 @@ export function commitRecord(row: SqliteOntologyCommitRow): OntologyCommitRecord
|
|
|
148
150
|
id: row.id,
|
|
149
151
|
idempotencyKey: row.idempotency_key,
|
|
150
152
|
requestHash: row.request_hash,
|
|
153
|
+
executionId: row.execution_id,
|
|
151
154
|
origin: parseJson<OntologyCommitWrite["origin"]>(row.origin),
|
|
152
155
|
...(row.actor === null
|
|
153
156
|
? {}
|
|
@@ -170,7 +173,10 @@ export function outboxRecord(row: SqliteOntologyOutboxRow): OntologyOutboxRecord
|
|
|
170
173
|
leaseId: row.lease_id,
|
|
171
174
|
leaseExpiresAt: row.lease_expires_at,
|
|
172
175
|
publishedAt: row.published_at,
|
|
173
|
-
|
|
176
|
+
lastFailure:
|
|
177
|
+
row.last_failure === null
|
|
178
|
+
? null
|
|
179
|
+
: parseSixbFailure(row.last_failure, ONTOLOGY_OUTBOX_FAILURE_CODES),
|
|
174
180
|
createdAt: row.created_at,
|
|
175
181
|
}
|
|
176
182
|
}
|
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
SummarizeTerminalSourceMaterializationsInput,
|
|
34
34
|
TerminalSourceMaterializationSummary,
|
|
35
35
|
} from "@sixb/core/storage"
|
|
36
|
+
import { yieldSqliteEventLoop } from "../transactions"
|
|
36
37
|
import {
|
|
37
38
|
assertNonblank,
|
|
38
39
|
assertNonnegativeInteger,
|
|
@@ -125,7 +126,7 @@ export class SqliteOntologySourceStorage implements OntologySourceStorage {
|
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
async stageRows(input: StageSourceRowsInput): Promise<StageSourceRowsResult> {
|
|
128
|
-
|
|
129
|
+
const result = await this.runRootOperation(() => {
|
|
129
130
|
assertWriteIdentity(input)
|
|
130
131
|
this.assertExecution(input)
|
|
131
132
|
const manifest = this.requireManifest(
|
|
@@ -146,6 +147,8 @@ export class SqliteOntologySourceStorage implements OntologySourceStorage {
|
|
|
146
147
|
this.insertStageRows(input, pending)
|
|
147
148
|
return { inserted: pending.length, unchanged }
|
|
148
149
|
})
|
|
150
|
+
await yieldSqliteEventLoop()
|
|
151
|
+
return result
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
async markReady(input: MarkSourceMaterializationReadyInput): Promise<OntologySourceRecord> {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite"
|
|
2
|
+
import { parseSixbFailure, serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
3
|
+
import { assertPipelineRunExecution } from "@sixb/core/internal/pipeline-run-storage-provider"
|
|
2
4
|
import type { DatasetVersionRef } from "@sixb/core/lake-storage"
|
|
3
5
|
import type {
|
|
6
|
+
ExecutionStorage,
|
|
4
7
|
FinishPipelineRunInput,
|
|
5
8
|
FinishPipelineStepRunInput,
|
|
6
9
|
ListLatestPipelineRunsInput,
|
|
@@ -9,14 +12,18 @@ import type {
|
|
|
9
12
|
ListPipelineRunsResult,
|
|
10
13
|
ListPipelineStepRunsInput,
|
|
11
14
|
ListPipelineStepRunsResult,
|
|
12
|
-
PipelineRunFailure,
|
|
13
15
|
PipelineRunRecord,
|
|
14
16
|
PipelineRunStorage,
|
|
15
17
|
PipelineStepRunRecord,
|
|
18
|
+
QueuePipelineRunInput,
|
|
16
19
|
StartPipelineRunInput,
|
|
17
20
|
StartPipelineStepRunInput,
|
|
18
21
|
} from "@sixb/core/storage"
|
|
19
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
canRequeuePipelineRunAfterEnqueueFailure,
|
|
24
|
+
PIPELINE_RUN_FAILURE_CODES,
|
|
25
|
+
PipelineRunError,
|
|
26
|
+
} from "@sixb/core/storage"
|
|
20
27
|
import { queryLatestRunsByOwnerId } from "./latest-run-query"
|
|
21
28
|
import { installFreshSqliteSchema } from "./migrations"
|
|
22
29
|
import {
|
|
@@ -33,6 +40,8 @@ import {
|
|
|
33
40
|
} from "./transactions"
|
|
34
41
|
|
|
35
42
|
export interface SqlitePipelineRunStorageOptions {
|
|
43
|
+
/** Execution lookup sharing the same provider transaction. */
|
|
44
|
+
executions: ExecutionStorage
|
|
36
45
|
/** Path to SQLite database file. Defaults to ':memory:' for in-memory database. */
|
|
37
46
|
path?: string
|
|
38
47
|
/** Internal shared connection used by bundled SqliteStorage. */
|
|
@@ -42,18 +51,27 @@ export interface SqlitePipelineRunStorageOptions {
|
|
|
42
51
|
export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
43
52
|
private readonly connection: SqliteStoreConnection
|
|
44
53
|
private readonly db: Database
|
|
54
|
+
private readonly executions: ExecutionStorage
|
|
45
55
|
|
|
46
|
-
constructor(options: SqlitePipelineRunStorageOptions
|
|
56
|
+
constructor(options: SqlitePipelineRunStorageOptions) {
|
|
47
57
|
this.connection = openSqliteStoreConnection(options)
|
|
48
58
|
this.db = this.connection.db
|
|
59
|
+
this.executions = options.executions
|
|
49
60
|
|
|
50
61
|
if (this.connection.installFreshSchema) {
|
|
51
62
|
installFreshSqliteSchema(this.db)
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
async
|
|
56
|
-
const
|
|
66
|
+
async queue(input: QueuePipelineRunInput): Promise<PipelineRunRecord> {
|
|
67
|
+
const queuedAt = input.queuedAt ?? new Date()
|
|
68
|
+
await assertPipelineRunExecution({
|
|
69
|
+
executions: this.executions,
|
|
70
|
+
projectId: input.projectId,
|
|
71
|
+
executionId: input.executionId,
|
|
72
|
+
runId: input.id,
|
|
73
|
+
pipelineId: input.pipelineId,
|
|
74
|
+
})
|
|
57
75
|
|
|
58
76
|
try {
|
|
59
77
|
this.db
|
|
@@ -62,18 +80,25 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
62
80
|
INSERT INTO pipeline_runs (
|
|
63
81
|
project_id,
|
|
64
82
|
id,
|
|
83
|
+
execution_id,
|
|
65
84
|
pipeline_id,
|
|
66
85
|
status,
|
|
86
|
+
queued_at,
|
|
67
87
|
started_at
|
|
68
|
-
) VALUES (?, ?, ?, ?,
|
|
88
|
+
) VALUES (?, ?, ?, ?, ?, ?, NULL)
|
|
69
89
|
`
|
|
70
90
|
)
|
|
71
|
-
.run(
|
|
91
|
+
.run(
|
|
92
|
+
input.projectId,
|
|
93
|
+
input.id,
|
|
94
|
+
input.executionId,
|
|
95
|
+
input.pipelineId,
|
|
96
|
+
"queued",
|
|
97
|
+
queuedAt.toISOString()
|
|
98
|
+
)
|
|
72
99
|
} catch (error) {
|
|
73
100
|
if (isUniqueConstraintError(error)) {
|
|
74
|
-
|
|
75
|
-
`[SixbSqlite] Pipeline run '${input.id}' already exists for project '${input.projectId}'.`
|
|
76
|
-
)
|
|
101
|
+
return this.requeueAfterEnqueueFailure(input, queuedAt)
|
|
77
102
|
}
|
|
78
103
|
|
|
79
104
|
throw error
|
|
@@ -89,6 +114,73 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
89
114
|
return record
|
|
90
115
|
}
|
|
91
116
|
|
|
117
|
+
private async requeueAfterEnqueueFailure(
|
|
118
|
+
input: QueuePipelineRunInput,
|
|
119
|
+
queuedAt: Date
|
|
120
|
+
): Promise<PipelineRunRecord> {
|
|
121
|
+
return this.db.transaction(() => {
|
|
122
|
+
const existing = this.db
|
|
123
|
+
.query("SELECT * FROM pipeline_runs WHERE project_id = ? AND id = ?")
|
|
124
|
+
.get(input.projectId, input.id) as PipelineRunDatabaseRow | null
|
|
125
|
+
if (
|
|
126
|
+
!existing ||
|
|
127
|
+
!canRequeuePipelineRunAfterEnqueueFailure(rowToPipelineRunRecord(existing), input)
|
|
128
|
+
) {
|
|
129
|
+
throw new PipelineRunError(
|
|
130
|
+
`[SixbSqlite] Pipeline run '${input.id}' already exists for project '${input.projectId}'.`
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
this.db
|
|
135
|
+
.query(
|
|
136
|
+
`
|
|
137
|
+
UPDATE pipeline_runs
|
|
138
|
+
SET status = ?, queued_at = ?, started_at = NULL, finished_at = NULL,
|
|
139
|
+
output_dataset_id = NULL, output_version_id = NULL, error = NULL
|
|
140
|
+
WHERE project_id = ? AND id = ?
|
|
141
|
+
`
|
|
142
|
+
)
|
|
143
|
+
.run("queued", queuedAt.toISOString(), input.projectId, input.id)
|
|
144
|
+
|
|
145
|
+
const updated = this.db
|
|
146
|
+
.query("SELECT * FROM pipeline_runs WHERE project_id = ? AND id = ?")
|
|
147
|
+
.get(input.projectId, input.id) as PipelineRunDatabaseRow
|
|
148
|
+
return rowToPipelineRunRecord(updated)
|
|
149
|
+
})()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async start(input: StartPipelineRunInput): Promise<PipelineRunRecord> {
|
|
153
|
+
const result = this.db
|
|
154
|
+
.query(
|
|
155
|
+
`
|
|
156
|
+
UPDATE pipeline_runs
|
|
157
|
+
SET status = ?, started_at = ?, error = NULL
|
|
158
|
+
WHERE project_id = ? AND id = ? AND status = ?
|
|
159
|
+
`
|
|
160
|
+
)
|
|
161
|
+
.run(
|
|
162
|
+
"running",
|
|
163
|
+
(input.startedAt ?? new Date()).toISOString(),
|
|
164
|
+
input.projectId,
|
|
165
|
+
input.id,
|
|
166
|
+
"queued"
|
|
167
|
+
)
|
|
168
|
+
if (result.changes > 0) {
|
|
169
|
+
const record = await this.getById({ projectId: input.projectId, id: input.id })
|
|
170
|
+
if (record) return record
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const existing = await this.getById({ projectId: input.projectId, id: input.id })
|
|
174
|
+
if (!existing) {
|
|
175
|
+
throw new PipelineRunError(
|
|
176
|
+
`[SixbSqlite] Pipeline run '${input.id}' not found for project '${input.projectId}'.`
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
throw new PipelineRunError(
|
|
180
|
+
`[SixbSqlite] Pipeline run '${input.id}' cannot start from status '${existing.status}'.`
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
92
184
|
async finish(input: FinishPipelineRunInput): Promise<PipelineRunRecord> {
|
|
93
185
|
return this.db.transaction(() => {
|
|
94
186
|
const existing = this.db
|
|
@@ -101,9 +193,14 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
101
193
|
)
|
|
102
194
|
}
|
|
103
195
|
|
|
104
|
-
|
|
196
|
+
const enqueueFailure =
|
|
197
|
+
input.status === "failed" && input.error.code === "queue.enqueue_failed"
|
|
198
|
+
if (
|
|
199
|
+
(enqueueFailure && existing.status !== "queued") ||
|
|
200
|
+
(!enqueueFailure && existing.status !== "running")
|
|
201
|
+
) {
|
|
105
202
|
throw new PipelineRunError(
|
|
106
|
-
`[SixbSqlite] Pipeline run '${input.id}'
|
|
203
|
+
`[SixbSqlite] Pipeline run '${input.id}' cannot finish from status '${existing.status}'.`
|
|
107
204
|
)
|
|
108
205
|
}
|
|
109
206
|
|
|
@@ -116,8 +213,7 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
116
213
|
finished_at = ?,
|
|
117
214
|
output_dataset_id = ?,
|
|
118
215
|
output_version_id = ?,
|
|
119
|
-
|
|
120
|
-
error_message = ?
|
|
216
|
+
error = ?
|
|
121
217
|
WHERE project_id = ? AND id = ?
|
|
122
218
|
`
|
|
123
219
|
)
|
|
@@ -126,8 +222,9 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
126
222
|
(input.finishedAt ?? new Date()).toISOString(),
|
|
127
223
|
input.status === "succeeded" ? (input.output?.datasetId ?? null) : null,
|
|
128
224
|
input.status === "succeeded" ? (input.output?.versionId ?? null) : null,
|
|
129
|
-
input.status === "succeeded"
|
|
130
|
-
|
|
225
|
+
input.status === "succeeded" || input.error === undefined
|
|
226
|
+
? null
|
|
227
|
+
: serializeSixbFailure(input.error, PIPELINE_RUN_FAILURE_CODES),
|
|
131
228
|
input.projectId,
|
|
132
229
|
input.id
|
|
133
230
|
)
|
|
@@ -255,8 +352,7 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
255
352
|
finished_at = ?,
|
|
256
353
|
output_version_id = ?,
|
|
257
354
|
rows_written = ?,
|
|
258
|
-
|
|
259
|
-
error_message = ?
|
|
355
|
+
error = ?
|
|
260
356
|
WHERE project_id = ? AND id = ?
|
|
261
357
|
`
|
|
262
358
|
)
|
|
@@ -265,8 +361,9 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
265
361
|
(input.finishedAt ?? new Date()).toISOString(),
|
|
266
362
|
input.status === "succeeded" ? input.output.versionId : null,
|
|
267
363
|
input.rowsWritten ?? existing.rows_written ?? null,
|
|
268
|
-
input.status === "succeeded"
|
|
269
|
-
|
|
364
|
+
input.status === "succeeded" || input.error === undefined
|
|
365
|
+
? null
|
|
366
|
+
: serializeSixbFailure(input.error, PIPELINE_RUN_FAILURE_CODES),
|
|
270
367
|
input.projectId,
|
|
271
368
|
input.id
|
|
272
369
|
)
|
|
@@ -309,7 +406,7 @@ export class SqlitePipelineRunStorage implements PipelineRunStorage {
|
|
|
309
406
|
args.push(...input.pipelineIds)
|
|
310
407
|
}
|
|
311
408
|
|
|
312
|
-
appendRunListFilters(whereClauses, args, input)
|
|
409
|
+
appendRunListFilters(whereClauses, args, input, "COALESCE(started_at, queued_at)")
|
|
313
410
|
|
|
314
411
|
const { rows, total, hasMore } = queryRunList<PipelineRunDatabaseRow>({
|
|
315
412
|
db: this.db,
|
|
@@ -409,27 +506,15 @@ function parseDatasetVersionRefs(value: string): readonly DatasetVersionRef[] {
|
|
|
409
506
|
return JSON.parse(value) as readonly DatasetVersionRef[]
|
|
410
507
|
}
|
|
411
508
|
|
|
412
|
-
function toFailure(row: {
|
|
413
|
-
readonly error_name: string | null
|
|
414
|
-
readonly error_message: string | null
|
|
415
|
-
}): PipelineRunFailure | undefined {
|
|
416
|
-
if (!row.error_message) {
|
|
417
|
-
return undefined
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return {
|
|
421
|
-
name: row.error_name ?? undefined,
|
|
422
|
-
message: row.error_message,
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
509
|
function rowToPipelineRunRecord(row: PipelineRunDatabaseRow): PipelineRunRecord {
|
|
427
510
|
return {
|
|
428
511
|
id: row.id,
|
|
429
512
|
projectId: row.project_id,
|
|
513
|
+
executionId: row.execution_id,
|
|
430
514
|
pipelineId: row.pipeline_id,
|
|
431
515
|
status: row.status,
|
|
432
|
-
|
|
516
|
+
queuedAt: new Date(row.queued_at),
|
|
517
|
+
startedAt: row.started_at ? new Date(row.started_at) : undefined,
|
|
433
518
|
finishedAt: row.finished_at ? new Date(row.finished_at) : undefined,
|
|
434
519
|
output:
|
|
435
520
|
row.output_dataset_id && row.output_version_id
|
|
@@ -438,7 +523,7 @@ function rowToPipelineRunRecord(row: PipelineRunDatabaseRow): PipelineRunRecord
|
|
|
438
523
|
versionId: row.output_version_id,
|
|
439
524
|
}
|
|
440
525
|
: undefined,
|
|
441
|
-
error:
|
|
526
|
+
error: row.error === null ? undefined : parseSixbFailure(row.error, PIPELINE_RUN_FAILURE_CODES),
|
|
442
527
|
}
|
|
443
528
|
}
|
|
444
529
|
|
|
@@ -462,7 +547,7 @@ function rowToPipelineStepRunRecord(row: PipelineStepRunDatabaseRow): PipelineSt
|
|
|
462
547
|
}
|
|
463
548
|
: undefined,
|
|
464
549
|
rowsWritten: row.rows_written ?? undefined,
|
|
465
|
-
error:
|
|
550
|
+
error: row.error === null ? undefined : parseSixbFailure(row.error, PIPELINE_RUN_FAILURE_CODES),
|
|
466
551
|
}
|
|
467
552
|
}
|
|
468
553
|
|
|
@@ -477,14 +562,15 @@ function assertOptionalNonNegativeInteger(value: number | undefined, fieldName:
|
|
|
477
562
|
interface PipelineRunDatabaseRow {
|
|
478
563
|
project_id: string
|
|
479
564
|
id: string
|
|
565
|
+
execution_id: string
|
|
480
566
|
pipeline_id: string
|
|
481
567
|
status: PipelineRunRecord["status"]
|
|
482
|
-
|
|
568
|
+
queued_at: string
|
|
569
|
+
started_at: string | null
|
|
483
570
|
finished_at: string | null
|
|
484
571
|
output_dataset_id: string | null
|
|
485
572
|
output_version_id: string | null
|
|
486
|
-
|
|
487
|
-
error_message: string | null
|
|
573
|
+
error: string | null
|
|
488
574
|
}
|
|
489
575
|
|
|
490
576
|
interface PipelineStepRunDatabaseRow {
|
|
@@ -501,6 +587,5 @@ interface PipelineStepRunDatabaseRow {
|
|
|
501
587
|
inputs: string
|
|
502
588
|
output_version_id: string | null
|
|
503
589
|
rows_written: number | null
|
|
504
|
-
|
|
505
|
-
error_message: string | null
|
|
590
|
+
error: string | null
|
|
506
591
|
}
|