@sixb/server 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/auth/scope.d.ts +18 -8
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/files/content.d.ts +11 -0
- package/dist/files/content.d.ts.map +1 -1
- package/dist/index.js +2115 -2081
- package/dist/index.js.map +15 -15
- package/dist/routes/action-runs.d.ts.map +1 -1
- package/dist/routes/agent-api-gateway.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +21 -21
- package/dist/routes/auth.d.ts +6 -6
- package/dist/routes/datasets.d.ts +7 -5
- package/dist/routes/datasets.d.ts.map +1 -1
- package/dist/routes/events.d.ts +1 -1
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/links.d.ts +6 -0
- package/dist/routes/links.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +2 -2
- package/dist/routes/objects.d.ts +3 -0
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/ontology.d.ts +24 -24
- package/dist/routes/pipelines.d.ts +4 -0
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/syncs.d.ts +7 -5
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/telemetry.d.ts +3 -0
- package/dist/routes/telemetry.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +61 -62
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +10 -10
- package/dist/schemas/agents.d.ts +84 -84
- package/dist/schemas/auth.d.ts +26 -26
- package/dist/schemas/datasets.d.ts +27 -21
- package/dist/schemas/datasets.d.ts.map +1 -1
- package/dist/schemas/events.d.ts +12 -12
- package/dist/schemas/logs.d.ts +18 -18
- package/dist/schemas/ontology.d.ts +88 -88
- package/dist/schemas/pipelines.d.ts +36 -0
- package/dist/schemas/pipelines.d.ts.map +1 -1
- package/dist/schemas/syncs.d.ts +23 -16
- package/dist/schemas/syncs.d.ts.map +1 -1
- package/dist/schemas/workflows.d.ts +299 -246
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/utils/http.d.ts.map +1 -1
- package/package.json +8 -5
- package/src/auth/scope.ts +16 -2
- package/src/files/content.ts +11 -0
- package/src/routes/action-runs.ts +10 -3
- package/src/routes/agent-api-gateway.ts +46 -4
- package/src/routes/files.ts +2 -1
- package/src/routes/links.ts +1 -0
- package/src/routes/workflows.ts +39 -16
- package/src/schemas/datasets.ts +3 -2
- package/src/schemas/pipelines.ts +1 -25
- package/src/schemas/syncs.ts +3 -2
- package/src/schemas/workflows.ts +27 -20
- package/src/server.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/schemas/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/schemas/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,wBAAwB,+GAA4B,CAAA;AAEjE,eAAO,MAAM,oBAAoB;;;;;;EAE/B,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;EAE3C,CAAA;AAEF,eAAO,MAAM,uBAAuB,iFAOlC,CAAA;AAEF,eAAO,MAAM,gCAAgC,6DAK3C,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;EAQlC,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa3C,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;;GAI3B,CAAA;AAEd,eAAO,MAAM,+BAA+B;;;;;;;;;EAG1C,CAAA;AAEF,eAAO,MAAM,2BAA2B,8DAA2B,CAAA;AAEnE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEnD,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;EAK3C,CAAA"}
|
package/dist/utils/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAQA,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,CAE/C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAWrE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAW9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACjC,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAGnB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAChC;IACD,KAAK,EAAE,MAAM,CAAA;CACd,CAmCA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "HTTP and WebSocket API server for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -32,15 +32,18 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@elysiajs/cors": "^1.2.0",
|
|
34
34
|
"@elysiajs/openapi": "^1.4.0",
|
|
35
|
-
"@sixb/core": "0.0.1",
|
|
36
35
|
"elysia": "^1.2.0",
|
|
37
36
|
"zod": "^3.24.0",
|
|
38
37
|
"zod-to-json-schema": "^3.24.0"
|
|
39
38
|
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@sixb/core": "0.1.1"
|
|
41
|
+
},
|
|
40
42
|
"devDependencies": {
|
|
41
|
-
"@sixb/auth-magic-link": "0.
|
|
42
|
-
"@sixb/auth-oidc": "0.
|
|
43
|
-
"@sixb/
|
|
43
|
+
"@sixb/auth-magic-link": "0.1.1",
|
|
44
|
+
"@sixb/auth-oidc": "0.1.1",
|
|
45
|
+
"@sixb/core": "0.1.1",
|
|
46
|
+
"@sixb/sqlite": "0.1.1",
|
|
44
47
|
"@types/bun": "latest",
|
|
45
48
|
"typescript": "^5.7.0"
|
|
46
49
|
},
|
package/src/auth/scope.ts
CHANGED
|
@@ -32,6 +32,10 @@ export interface RequestAuthState {
|
|
|
32
32
|
readonly scoped: ScopedSixb<readonly OntologySource[]> | null
|
|
33
33
|
/** Present for requests proxied through the run-scoped agent API gateway. */
|
|
34
34
|
readonly agentRun?: AgentRunRecord
|
|
35
|
+
/** Identifies which kind of active agent execution owns a gateway request. */
|
|
36
|
+
readonly agentExecution?:
|
|
37
|
+
| { readonly kind: "conversation"; readonly runId: string }
|
|
38
|
+
| { readonly kind: "workflow"; readonly nodeRunId: string }
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
const internalRequestAuthState = new WeakMap<Request, RequestAuthState>()
|
|
@@ -59,6 +63,16 @@ export function consumeInternalRequestAuthState(request: Request): RequestAuthSt
|
|
|
59
63
|
* point until route registration carries the derived context type.
|
|
60
64
|
*/
|
|
61
65
|
export function requestAuthState(context: unknown): RequestAuthState {
|
|
62
|
-
const {
|
|
63
|
-
|
|
66
|
+
const {
|
|
67
|
+
authz = null,
|
|
68
|
+
scoped = null,
|
|
69
|
+
agentRun,
|
|
70
|
+
agentExecution,
|
|
71
|
+
} = context as Partial<RequestAuthState>
|
|
72
|
+
return {
|
|
73
|
+
authz,
|
|
74
|
+
scoped,
|
|
75
|
+
...(agentRun === undefined ? {} : { agentRun }),
|
|
76
|
+
...(agentExecution === undefined ? {} : { agentExecution }),
|
|
77
|
+
}
|
|
64
78
|
}
|
package/src/files/content.ts
CHANGED
|
@@ -53,6 +53,17 @@ export interface FileContentResponsesOptions {
|
|
|
53
53
|
readonly optionalStorage?: boolean
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export function handleFileContentQueryValidationError(context: {
|
|
57
|
+
readonly code: string | number
|
|
58
|
+
readonly error: { readonly type?: string }
|
|
59
|
+
readonly set: { status?: number | string }
|
|
60
|
+
}): { readonly error: string } | undefined {
|
|
61
|
+
if (context.code !== "VALIDATION" || context.error.type !== "query") return
|
|
62
|
+
|
|
63
|
+
context.set.status = 400
|
|
64
|
+
return { error: "Invalid file content query" }
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
export function fileContentGetResponses(options: FileContentResponsesOptions = {}) {
|
|
57
68
|
return {
|
|
58
69
|
200: {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
createContextualFileContentResponse,
|
|
10
10
|
fileContentGetResponses,
|
|
11
11
|
fileContentHeadResponses,
|
|
12
|
+
handleFileContentQueryValidationError,
|
|
12
13
|
} from "../files/content"
|
|
13
14
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
14
15
|
import {
|
|
@@ -32,7 +33,10 @@ const ActionRunFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
|
32
33
|
path: z
|
|
33
34
|
.string()
|
|
34
35
|
.min(1)
|
|
35
|
-
.regex(
|
|
36
|
+
.regex(
|
|
37
|
+
/^\/(?:params|writeback\/result)(?:\/|$)/,
|
|
38
|
+
"Action run file content paths must start with /params/ or /writeback/result/"
|
|
39
|
+
),
|
|
36
40
|
})
|
|
37
41
|
|
|
38
42
|
function serializeActionRunSummary(
|
|
@@ -164,6 +168,7 @@ export function registerActionRunRoutes(app: Elysia, sixb: Sixb<readonly Ontolog
|
|
|
164
168
|
summary: "List action run history",
|
|
165
169
|
tags: [OPENAPI_TAGS.actionRuns.name],
|
|
166
170
|
operationId: "listActionRuns",
|
|
171
|
+
security: bearerSecurityRequirement("listActionRuns"),
|
|
167
172
|
},
|
|
168
173
|
}
|
|
169
174
|
)
|
|
@@ -210,7 +215,8 @@ export function registerActionRunRoutes(app: Elysia, sixb: Sixb<readonly Ontolog
|
|
|
210
215
|
(context) => actionRunFileContentResponse(sixb, context),
|
|
211
216
|
{
|
|
212
217
|
params: ActionRunIdParamsSchema,
|
|
213
|
-
query:
|
|
218
|
+
query: ActionRunFileContentQuerySchema,
|
|
219
|
+
error: handleFileContentQueryValidationError,
|
|
214
220
|
detail: {
|
|
215
221
|
summary: "Get action run file content",
|
|
216
222
|
tags: ["Actions"],
|
|
@@ -225,7 +231,8 @@ export function registerActionRunRoutes(app: Elysia, sixb: Sixb<readonly Ontolog
|
|
|
225
231
|
(context) => actionRunFileContentResponse(sixb, context, { head: true }),
|
|
226
232
|
{
|
|
227
233
|
params: ActionRunIdParamsSchema,
|
|
228
|
-
query:
|
|
234
|
+
query: ActionRunFileContentQuerySchema,
|
|
235
|
+
error: handleFileContentQueryValidationError,
|
|
229
236
|
detail: {
|
|
230
237
|
summary: "Head action run file content",
|
|
231
238
|
tags: ["Actions"],
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { normalizeRoutePath, pathSegmentsFor } from "@sixb/core/internal/http"
|
|
9
9
|
import type { Elysia } from "elysia"
|
|
10
10
|
import { registerInternalRequestAuthState } from "../auth/scope"
|
|
11
|
+
import { DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES } from "./files"
|
|
11
12
|
|
|
12
13
|
const MAX_AGENT_API_BODY_BYTES = 1_000_000
|
|
13
14
|
const HOP_BY_HOP_RESPONSE_HEADERS = new Set([
|
|
@@ -74,10 +75,22 @@ async function handleAgentApiGatewayRequest(input: {
|
|
|
74
75
|
if (authState instanceof Response) {
|
|
75
76
|
return authState
|
|
76
77
|
}
|
|
78
|
+
if (
|
|
79
|
+
authState.agentExecution.kind === "workflow" &&
|
|
80
|
+
input.request.method === "POST" &&
|
|
81
|
+
matchesWorkflowRunStart(upstreamPath)
|
|
82
|
+
) {
|
|
83
|
+
return jsonError(409, "Workflow agent nodes cannot start another workflow run.")
|
|
84
|
+
}
|
|
77
85
|
|
|
78
86
|
let body: ArrayBuffer | undefined
|
|
79
87
|
try {
|
|
80
|
-
body = await readRequestBody(
|
|
88
|
+
body = await readRequestBody(
|
|
89
|
+
input.request,
|
|
90
|
+
isSimpleFileUpload(input.request.method, upstreamPath)
|
|
91
|
+
? DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES
|
|
92
|
+
: MAX_AGENT_API_BODY_BYTES
|
|
93
|
+
)
|
|
81
94
|
} catch (error) {
|
|
82
95
|
if (error instanceof PayloadTooLargeError) {
|
|
83
96
|
return jsonError(413, error.message)
|
|
@@ -124,8 +137,14 @@ async function resolveAgentRunAuthState(
|
|
|
124
137
|
nodeRunId: input.runId,
|
|
125
138
|
})
|
|
126
139
|
const run = conversationalRun ?? workflowRun
|
|
140
|
+
const agentExecution = conversationalRun
|
|
141
|
+
? ({ kind: "conversation", runId: conversationalRun.id } as const)
|
|
142
|
+
: workflowRun
|
|
143
|
+
? ({ kind: "workflow", nodeRunId: workflowRun.nodeRunId } as const)
|
|
144
|
+
: null
|
|
127
145
|
if (
|
|
128
146
|
!run ||
|
|
147
|
+
!agentExecution ||
|
|
129
148
|
run.status !== "running" ||
|
|
130
149
|
!run.execution ||
|
|
131
150
|
run.execution.queueLeaseExpiresAt.getTime() <= Date.now() ||
|
|
@@ -143,6 +162,7 @@ async function resolveAgentRunAuthState(
|
|
|
143
162
|
return {
|
|
144
163
|
authz: null,
|
|
145
164
|
scoped: null,
|
|
165
|
+
agentExecution,
|
|
146
166
|
...(conversationalRun ? { agentRun: conversationalRun } : {}),
|
|
147
167
|
}
|
|
148
168
|
}
|
|
@@ -179,6 +199,7 @@ async function resolveAgentRunAuthState(
|
|
|
179
199
|
return {
|
|
180
200
|
authz,
|
|
181
201
|
scoped: sixb.as(authz),
|
|
202
|
+
agentExecution,
|
|
182
203
|
...(conversationalRun ? { agentRun: conversationalRun } : {}),
|
|
183
204
|
}
|
|
184
205
|
}
|
|
@@ -220,7 +241,10 @@ function copyHeader(source: Headers, target: Headers, name: string): void {
|
|
|
220
241
|
}
|
|
221
242
|
}
|
|
222
243
|
|
|
223
|
-
async function readRequestBody(
|
|
244
|
+
async function readRequestBody(
|
|
245
|
+
request: Request,
|
|
246
|
+
maxBytes: number
|
|
247
|
+
): Promise<ArrayBuffer | undefined> {
|
|
224
248
|
if (!request.body || request.method === "GET" || request.method === "HEAD") {
|
|
225
249
|
return undefined
|
|
226
250
|
}
|
|
@@ -233,8 +257,12 @@ async function readRequestBody(request: Request): Promise<ArrayBuffer | undefine
|
|
|
233
257
|
const { done, value } = await reader.read()
|
|
234
258
|
if (done) break
|
|
235
259
|
total += value.byteLength
|
|
236
|
-
if (total >
|
|
237
|
-
throw new PayloadTooLargeError(
|
|
260
|
+
if (total > maxBytes) {
|
|
261
|
+
throw new PayloadTooLargeError(
|
|
262
|
+
maxBytes === MAX_AGENT_API_BODY_BYTES
|
|
263
|
+
? "Agent API gateway request body exceeds 1MB."
|
|
264
|
+
: `Agent API gateway file upload request body exceeds the ${maxBytes} byte limit.`
|
|
265
|
+
)
|
|
238
266
|
}
|
|
239
267
|
chunks.push(value)
|
|
240
268
|
}
|
|
@@ -242,6 +270,20 @@ async function readRequestBody(request: Request): Promise<ArrayBuffer | undefine
|
|
|
242
270
|
return concatChunks(chunks, total)
|
|
243
271
|
}
|
|
244
272
|
|
|
273
|
+
function isSimpleFileUpload(method: string, pathname: string): boolean {
|
|
274
|
+
return method === "POST" && normalizeRoutePath(pathname) === "/api/files"
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function matchesWorkflowRunStart(pathname: string): boolean {
|
|
278
|
+
const segments = pathSegmentsFor(pathname)
|
|
279
|
+
return (
|
|
280
|
+
segments.length === 4 &&
|
|
281
|
+
segments[0] === "api" &&
|
|
282
|
+
segments[1] === "workflows" &&
|
|
283
|
+
segments[3] === "runs"
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
245
287
|
function concatChunks(chunks: readonly Uint8Array[], total: number): ArrayBuffer {
|
|
246
288
|
const buffer = new ArrayBuffer(total)
|
|
247
289
|
const result = new Uint8Array(buffer)
|
package/src/routes/files.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
FileUploadSessionError,
|
|
16
16
|
} from "@sixb/core/storage"
|
|
17
17
|
import type { Elysia } from "elysia"
|
|
18
|
+
import { bearerSecurityRequirement } from "../auth/access-token-boundary"
|
|
18
19
|
import { requestAuthState } from "../auth/scope"
|
|
19
20
|
import { SIXB_CSRF_SECURITY_REQUIREMENT } from "../openapi/security"
|
|
20
21
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
@@ -102,7 +103,7 @@ export function registerFileRoutes(app: Elysia, sixb: Sixb<readonly OntologySour
|
|
|
102
103
|
summary: "Upload a file",
|
|
103
104
|
tags: [OPENAPI_TAGS.files.name],
|
|
104
105
|
operationId: "uploadFileRaw",
|
|
105
|
-
security:
|
|
106
|
+
security: bearerSecurityRequirement("uploadFileRaw"),
|
|
106
107
|
requestBody: {
|
|
107
108
|
required: true,
|
|
108
109
|
content: {
|
package/src/routes/links.ts
CHANGED
package/src/routes/workflows.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
createContextualFileContentResponse,
|
|
28
28
|
fileContentGetResponses,
|
|
29
29
|
fileContentHeadResponses,
|
|
30
|
+
handleFileContentQueryValidationError,
|
|
30
31
|
} from "../files/content"
|
|
31
32
|
import { SIXB_CSRF_SECURITY_REQUIREMENT } from "../openapi/security"
|
|
32
33
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
@@ -65,7 +66,10 @@ const WorkflowRunFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
|
65
66
|
path: z
|
|
66
67
|
.string()
|
|
67
68
|
.min(1)
|
|
68
|
-
.regex(
|
|
69
|
+
.regex(
|
|
70
|
+
/^\/(?:input|output)(?:\/|$)/,
|
|
71
|
+
"Workflow run file content paths must start with /input/ or /output/"
|
|
72
|
+
),
|
|
69
73
|
})
|
|
70
74
|
|
|
71
75
|
const WorkflowNodeFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
@@ -82,13 +86,12 @@ const WorkflowNodeFileContentParamsSchema = WorkflowRunParamsSchema.extend({
|
|
|
82
86
|
nodeKey: z.string().min(1),
|
|
83
87
|
})
|
|
84
88
|
|
|
85
|
-
function
|
|
89
|
+
function serializeWorkflowRunSummary(run: WorkflowRunRecord) {
|
|
86
90
|
return {
|
|
87
91
|
id: run.id,
|
|
88
92
|
projectId: run.projectId,
|
|
89
93
|
workflowId: run.workflowId,
|
|
90
94
|
status: run.status,
|
|
91
|
-
input: run.input,
|
|
92
95
|
queuedAt: run.queuedAt ? toIsoString(run.queuedAt) : undefined,
|
|
93
96
|
startedAt: toIsoString(run.startedAt),
|
|
94
97
|
finishedAt: run.finishedAt ? toIsoString(run.finishedAt) : undefined,
|
|
@@ -97,7 +100,15 @@ function serializeWorkflowRun(run: WorkflowRunRecord) {
|
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
function serializeWorkflowRunDetail(run: WorkflowRunRecord) {
|
|
104
|
+
return {
|
|
105
|
+
...serializeWorkflowRunSummary(run),
|
|
106
|
+
input: run.input,
|
|
107
|
+
output: run.output,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type SerializedWorkflowRun = ReturnType<typeof serializeWorkflowRunSummary>
|
|
101
112
|
|
|
102
113
|
function serializeWorkflowNodeRun(
|
|
103
114
|
node: WorkflowNodeRunRecord,
|
|
@@ -235,7 +246,7 @@ async function workflowRunFileContentResponse(
|
|
|
235
246
|
return null
|
|
236
247
|
}
|
|
237
248
|
|
|
238
|
-
return
|
|
249
|
+
return serializeWorkflowRunDetail(run)
|
|
239
250
|
},
|
|
240
251
|
})
|
|
241
252
|
}
|
|
@@ -302,7 +313,7 @@ async function getLatestWorkflowRun(
|
|
|
302
313
|
})
|
|
303
314
|
|
|
304
315
|
const [latest] = result.runs
|
|
305
|
-
return latest ?
|
|
316
|
+
return latest ? serializeWorkflowRunSummary(latest) : null
|
|
306
317
|
}
|
|
307
318
|
|
|
308
319
|
async function getLatestWorkflowRuns(
|
|
@@ -319,7 +330,7 @@ async function getLatestWorkflowRuns(
|
|
|
319
330
|
workflowIds,
|
|
320
331
|
})
|
|
321
332
|
|
|
322
|
-
return new Map(result.runs.map((run) => [run.workflowId,
|
|
333
|
+
return new Map(result.runs.map((run) => [run.workflowId, serializeWorkflowRunSummary(run)]))
|
|
323
334
|
}
|
|
324
335
|
|
|
325
336
|
function serializeWorkflow(
|
|
@@ -938,7 +949,7 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
938
949
|
})
|
|
939
950
|
|
|
940
951
|
return {
|
|
941
|
-
runs: result.runs.map(
|
|
952
|
+
runs: result.runs.map(serializeWorkflowRunSummary),
|
|
942
953
|
hasMore: result.hasMore,
|
|
943
954
|
total: result.total,
|
|
944
955
|
}
|
|
@@ -957,6 +968,7 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
957
968
|
summary: "List workflow run history",
|
|
958
969
|
tags: [OPENAPI_TAGS.workflowRuns.name],
|
|
959
970
|
operationId: "listWorkflowRuns",
|
|
971
|
+
security: bearerSecurityRequirement("listWorkflowRuns"),
|
|
960
972
|
},
|
|
961
973
|
}
|
|
962
974
|
)
|
|
@@ -964,7 +976,7 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
964
976
|
"/api/workflow-runs/:runId",
|
|
965
977
|
async (context) => {
|
|
966
978
|
const { params, set } = context
|
|
967
|
-
const { authz, scoped } = requestAuthState(context)
|
|
979
|
+
const { agentExecution, authz, scoped } = requestAuthState(context)
|
|
968
980
|
try {
|
|
969
981
|
const storage = sixb.storage.workflowRuns
|
|
970
982
|
if (!storage) {
|
|
@@ -977,6 +989,12 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
977
989
|
return { error: "Workflow run not found" }
|
|
978
990
|
}
|
|
979
991
|
|
|
992
|
+
const serializedRun = serializeWorkflowRunDetail(run)
|
|
993
|
+
|
|
994
|
+
if (agentExecution) {
|
|
995
|
+
return WorkflowRunDetailResponseSchema.parse({ run: serializedRun, nodes: [] })
|
|
996
|
+
}
|
|
997
|
+
|
|
980
998
|
const nodes = await storage.nodes.list({
|
|
981
999
|
projectId: sixb.id,
|
|
982
1000
|
workflowRunId: run.id,
|
|
@@ -984,7 +1002,7 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
984
1002
|
})
|
|
985
1003
|
|
|
986
1004
|
return WorkflowRunDetailResponseSchema.parse({
|
|
987
|
-
run:
|
|
1005
|
+
run: serializedRun,
|
|
988
1006
|
nodes: await Promise.all(
|
|
989
1007
|
nodes.nodes.map((node) => serializeWorkflowNodeWithExecution(storage, node))
|
|
990
1008
|
),
|
|
@@ -1005,6 +1023,7 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
1005
1023
|
summary: "Get workflow run detail",
|
|
1006
1024
|
tags: [OPENAPI_TAGS.workflowRuns.name],
|
|
1007
1025
|
operationId: "getWorkflowRun",
|
|
1026
|
+
security: bearerSecurityRequirement("getWorkflowRun"),
|
|
1008
1027
|
},
|
|
1009
1028
|
}
|
|
1010
1029
|
)
|
|
@@ -1092,7 +1111,7 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
1092
1111
|
})
|
|
1093
1112
|
if (existing.status === "cancelled") {
|
|
1094
1113
|
return CancelWorkflowRunResponseSchema.parse({
|
|
1095
|
-
run:
|
|
1114
|
+
run: serializeWorkflowRunDetail(existing),
|
|
1096
1115
|
nodes: await Promise.all(
|
|
1097
1116
|
listed.nodes.map((node) => serializeWorkflowNodeWithExecution(storage, node))
|
|
1098
1117
|
),
|
|
@@ -1189,7 +1208,7 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
1189
1208
|
order: "asc",
|
|
1190
1209
|
})
|
|
1191
1210
|
return CancelWorkflowRunResponseSchema.parse({
|
|
1192
|
-
run:
|
|
1211
|
+
run: serializeWorkflowRunDetail(result.run),
|
|
1193
1212
|
nodes: await Promise.all(
|
|
1194
1213
|
nodes.nodes.map((node) => serializeWorkflowNodeWithExecution(storage, node))
|
|
1195
1214
|
),
|
|
@@ -1220,7 +1239,8 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
1220
1239
|
(context) => workflowRunFileContentResponse(sixb, context),
|
|
1221
1240
|
{
|
|
1222
1241
|
params: WorkflowRunParamsSchema,
|
|
1223
|
-
query:
|
|
1242
|
+
query: WorkflowRunFileContentQuerySchema,
|
|
1243
|
+
error: handleFileContentQueryValidationError,
|
|
1224
1244
|
detail: {
|
|
1225
1245
|
summary: "Get workflow run file content",
|
|
1226
1246
|
tags: ["Workflows"],
|
|
@@ -1235,7 +1255,8 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
1235
1255
|
(context) => workflowRunFileContentResponse(sixb, context, { head: true }),
|
|
1236
1256
|
{
|
|
1237
1257
|
params: WorkflowRunParamsSchema,
|
|
1238
|
-
query:
|
|
1258
|
+
query: WorkflowRunFileContentQuerySchema,
|
|
1259
|
+
error: handleFileContentQueryValidationError,
|
|
1239
1260
|
detail: {
|
|
1240
1261
|
summary: "Head workflow run file content",
|
|
1241
1262
|
tags: ["Workflows"],
|
|
@@ -1250,7 +1271,8 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
1250
1271
|
(context) => workflowNodeFileContentResponse(sixb, context),
|
|
1251
1272
|
{
|
|
1252
1273
|
params: WorkflowNodeFileContentParamsSchema,
|
|
1253
|
-
query:
|
|
1274
|
+
query: WorkflowNodeFileContentQuerySchema,
|
|
1275
|
+
error: handleFileContentQueryValidationError,
|
|
1254
1276
|
detail: {
|
|
1255
1277
|
summary: "Get workflow node run file content",
|
|
1256
1278
|
tags: ["Workflows"],
|
|
@@ -1265,7 +1287,8 @@ export function registerWorkflowRoutes(app: Elysia, sixb: Sixb<readonly Ontology
|
|
|
1265
1287
|
(context) => workflowNodeFileContentResponse(sixb, context, { head: true }),
|
|
1266
1288
|
{
|
|
1267
1289
|
params: WorkflowNodeFileContentParamsSchema,
|
|
1268
|
-
query:
|
|
1290
|
+
query: WorkflowNodeFileContentQuerySchema,
|
|
1291
|
+
error: handleFileContentQueryValidationError,
|
|
1269
1292
|
detail: {
|
|
1270
1293
|
summary: "Head workflow node run file content",
|
|
1271
1294
|
tags: ["Workflows"],
|
package/src/schemas/datasets.ts
CHANGED
|
@@ -42,6 +42,7 @@ export const DatasetSchema = z.object({
|
|
|
42
42
|
export const DatasetDefinitionSchema = z.object({
|
|
43
43
|
id: z.string(),
|
|
44
44
|
description: z.string().optional(),
|
|
45
|
+
primaryKey: z.union([z.string(), z.array(z.string()).min(2)]).optional(),
|
|
45
46
|
partitionBy: z.array(z.string()).optional(),
|
|
46
47
|
schema: DatasetSchema,
|
|
47
48
|
})
|
|
@@ -61,7 +62,7 @@ export const DatasetVersionSchema = z.object({
|
|
|
61
62
|
datasetId: z.string(),
|
|
62
63
|
versionId: z.string(),
|
|
63
64
|
parentVersionId: z.string().optional(),
|
|
64
|
-
mode: z.enum(["snapshot", "append", "schema"]),
|
|
65
|
+
mode: z.enum(["snapshot", "append", "merge", "schema"]),
|
|
65
66
|
createdAt: z.string(),
|
|
66
67
|
schema: DatasetSchema,
|
|
67
68
|
producer: DatasetProducerSchema.optional(),
|
|
@@ -73,7 +74,7 @@ export const DatasetVersionSchema = z.object({
|
|
|
73
74
|
export const DatasetLatestVersionSummarySchema = z.object({
|
|
74
75
|
datasetId: z.string(),
|
|
75
76
|
versionId: z.string(),
|
|
76
|
-
mode: z.enum(["snapshot", "append", "schema"]),
|
|
77
|
+
mode: z.enum(["snapshot", "append", "merge", "schema"]),
|
|
77
78
|
createdAt: z.string(),
|
|
78
79
|
rowCount: z.number().optional(),
|
|
79
80
|
})
|
package/src/schemas/pipelines.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod"
|
|
2
|
+
import { DatasetDefinitionSchema } from "./datasets"
|
|
2
3
|
|
|
3
4
|
export const PipelineParamsSchema = z.object({
|
|
4
5
|
pipelineId: z.string().min(1),
|
|
@@ -25,31 +26,6 @@ const DatasetVersionRefSchema = z.object({
|
|
|
25
26
|
versionId: z.string(),
|
|
26
27
|
})
|
|
27
28
|
|
|
28
|
-
const DatasetColumnSchema = z.object({
|
|
29
|
-
name: z.string(),
|
|
30
|
-
type: z.enum([
|
|
31
|
-
"string",
|
|
32
|
-
"boolean",
|
|
33
|
-
"int64",
|
|
34
|
-
"float64",
|
|
35
|
-
"decimal",
|
|
36
|
-
"date",
|
|
37
|
-
"timestamp",
|
|
38
|
-
"json",
|
|
39
|
-
"fileRef",
|
|
40
|
-
]),
|
|
41
|
-
nullable: z.boolean().optional(),
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
const DatasetDefinitionSchema = z.object({
|
|
45
|
-
id: z.string(),
|
|
46
|
-
description: z.string().optional(),
|
|
47
|
-
partitionBy: z.array(z.string()).optional(),
|
|
48
|
-
schema: z.object({
|
|
49
|
-
columns: z.array(DatasetColumnSchema),
|
|
50
|
-
}),
|
|
51
|
-
})
|
|
52
|
-
|
|
53
29
|
const PipelineTriggerSchema = z.object({
|
|
54
30
|
type: z.literal("schedule"),
|
|
55
31
|
scheduleId: z.string(),
|
package/src/schemas/syncs.ts
CHANGED
|
@@ -6,6 +6,7 @@ export const SyncParamsSchema = z.object({
|
|
|
6
6
|
})
|
|
7
7
|
|
|
8
8
|
export const SyncRunStatusSchema = z.enum(["running", "succeeded", "failed", "cancelled"])
|
|
9
|
+
const SyncModeSchema = z.enum(["snapshot", "append", "merge"])
|
|
9
10
|
|
|
10
11
|
export const SyncRunsQuerySchema = z.object({
|
|
11
12
|
syncId: z.string().optional(),
|
|
@@ -33,7 +34,7 @@ export const SyncRunSchema = z.object({
|
|
|
33
34
|
projectId: z.string(),
|
|
34
35
|
syncId: z.string(),
|
|
35
36
|
datasetId: z.string(),
|
|
36
|
-
mode:
|
|
37
|
+
mode: SyncModeSchema,
|
|
37
38
|
status: SyncRunStatusSchema,
|
|
38
39
|
startedAt: z.string(),
|
|
39
40
|
finishedAt: z.string().optional(),
|
|
@@ -56,7 +57,7 @@ export const SyncRunSchema = z.object({
|
|
|
56
57
|
|
|
57
58
|
export const SyncSchema = z.object({
|
|
58
59
|
id: z.string(),
|
|
59
|
-
mode:
|
|
60
|
+
mode: SyncModeSchema,
|
|
60
61
|
connector: z.object({
|
|
61
62
|
id: z.string(),
|
|
62
63
|
type: z.string(),
|