@sixb/server 0.2.6 → 0.2.7
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/run-token.d.ts.map +1 -1
- package/dist/index.js +75 -35
- package/dist/index.js.map +22 -22
- package/dist/routes/actions.d.ts +2 -0
- package/dist/routes/actions.d.ts.map +1 -1
- package/dist/routes/agent-approvals.d.ts +1 -1
- package/dist/routes/agents.d.ts +14 -14
- package/dist/routes/connectors.d.ts +2 -0
- package/dist/routes/connectors.d.ts.map +1 -1
- package/dist/routes/datasets.d.ts +2 -0
- package/dist/routes/datasets.d.ts.map +1 -1
- package/dist/routes/observed-agent-threads.d.ts +2 -2
- package/dist/routes/ontology.d.ts +2 -0
- package/dist/routes/ontology.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +2 -0
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +6 -0
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/rules.d.ts +2 -0
- package/dist/routes/rules.d.ts.map +1 -1
- package/dist/routes/status.d.ts +1 -1
- package/dist/routes/syncs.d.ts +2 -0
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +2 -0
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/schemas/actions.d.ts +6 -0
- package/dist/schemas/actions.d.ts.map +1 -1
- package/dist/schemas/agents.d.ts +62 -62
- package/dist/schemas/common.d.ts +5 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/connectors.d.ts +3 -0
- package/dist/schemas/connectors.d.ts.map +1 -1
- package/dist/schemas/datasets.d.ts +3 -0
- package/dist/schemas/datasets.d.ts.map +1 -1
- package/dist/schemas/ontology.d.ts +3 -0
- package/dist/schemas/ontology.d.ts.map +1 -1
- package/dist/schemas/pipelines.d.ts +3 -0
- package/dist/schemas/pipelines.d.ts.map +1 -1
- package/dist/schemas/projections.d.ts +33 -0
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/rules.d.ts +3 -0
- package/dist/schemas/rules.d.ts.map +1 -1
- package/dist/schemas/status.d.ts +2 -2
- package/dist/schemas/syncs.d.ts +3 -0
- package/dist/schemas/syncs.d.ts.map +1 -1
- package/dist/schemas/workflows.d.ts +3 -0
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/auth/run-token.ts +59 -9
- package/src/routes/actions.ts +7 -3
- package/src/routes/connectors.ts +1 -0
- package/src/routes/datasets.ts +11 -3
- package/src/routes/ontology.ts +17 -3
- package/src/routes/pipelines.ts +13 -3
- package/src/routes/projections.ts +14 -9
- package/src/routes/rules.ts +9 -3
- package/src/routes/syncs.ts +4 -0
- package/src/routes/workflows.ts +13 -3
- package/src/schemas/actions.ts +7 -1
- package/src/schemas/common.ts +9 -0
- package/src/schemas/connectors.ts +2 -1
- package/src/schemas/datasets.ts +2 -1
- package/src/schemas/ontology.ts +2 -0
- package/src/schemas/pipelines.ts +2 -1
- package/src/schemas/projections.ts +4 -1
- package/src/schemas/rules.ts +2 -0
- package/src/schemas/syncs.ts +2 -1
- package/src/schemas/workflows.ts +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-token.d.ts","sourceRoot":"","sources":["../../src/auth/run-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"run-token.d.ts","sourceRoot":"","sources":["../../src/auth/run-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAa9C,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,oBAAoB,CAAA;AAG3B,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAczE,sFAAsF;AACtF,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAEjE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,YAAY,EAAE,wBAAwB,CAAA;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAA;CACzE;AAED,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAIpE;AAKD;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IAClD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuC5B"}
|
package/dist/index.js
CHANGED
|
@@ -837,6 +837,7 @@ class ServerAuthGuard {
|
|
|
837
837
|
|
|
838
838
|
// src/auth/run-token.ts
|
|
839
839
|
import {
|
|
840
|
+
AGENT_RUN_HEADER,
|
|
840
841
|
AgentRunScopeError,
|
|
841
842
|
agentRunTokenRunId,
|
|
842
843
|
findAgentApiRoute as findAgentApiRoute2,
|
|
@@ -885,6 +886,7 @@ function codedErrorResponseSchema(codes) {
|
|
|
885
886
|
});
|
|
886
887
|
}
|
|
887
888
|
var RedactionsSchema = z.record(z.object({ reason: z.literal("missing_clearance") }));
|
|
889
|
+
var DefinitionFolderSchema = z.string().optional().describe("Folder below the definition's directory, such as `raw/erp`; absent at its top.");
|
|
888
890
|
var SuccessResponseSchema = z.object({ success: z.boolean() });
|
|
889
891
|
var PrincipalSchema = z.object({
|
|
890
892
|
type: z.enum(["user", "serviceAccount", "system"]),
|
|
@@ -997,6 +999,7 @@ var ActionSchema = z2.object({
|
|
|
997
999
|
});
|
|
998
1000
|
var ObjectTypeSchema = z2.object({
|
|
999
1001
|
id: z2.string(),
|
|
1002
|
+
folder: DefinitionFolderSchema,
|
|
1000
1003
|
name: z2.string(),
|
|
1001
1004
|
description: z2.string().optional(),
|
|
1002
1005
|
extends: z2.string().optional(),
|
|
@@ -1050,6 +1053,7 @@ var ActionRequestFailedResponseSchema = codedErrorResponseSchema(SIXB_ERROR_CODE
|
|
|
1050
1053
|
var RuntimeStoppingResponseSchema = codedErrorResponseSchema(["runtime.stopping"]);
|
|
1051
1054
|
var ActionCatalogItemSchema = z3.object({
|
|
1052
1055
|
id: z3.string(),
|
|
1056
|
+
folder: DefinitionFolderSchema,
|
|
1053
1057
|
name: z3.string(),
|
|
1054
1058
|
description: z3.string().optional(),
|
|
1055
1059
|
objectTypeId: z3.string().optional(),
|
|
@@ -2576,6 +2580,7 @@ var WorkflowInterventionSchema = z10.object({
|
|
|
2576
2580
|
});
|
|
2577
2581
|
var WorkflowSchema = z10.object({
|
|
2578
2582
|
id: z10.string(),
|
|
2583
|
+
folder: DefinitionFolderSchema,
|
|
2579
2584
|
input: WorkflowIOSnapshotSchema,
|
|
2580
2585
|
triggers: z10.array(WorkflowTriggerSchema),
|
|
2581
2586
|
nodes: z10.array(WorkflowNodeSchema),
|
|
@@ -2971,7 +2976,7 @@ async function resolveRunTokenRequest(input) {
|
|
|
2971
2976
|
if (!isAllowedAgentApiRequest(method, path)) {
|
|
2972
2977
|
return deny(403, `A run token cannot call ${method} ${path}.`);
|
|
2973
2978
|
}
|
|
2974
|
-
const resolved = await resolveRunState(host, input.token);
|
|
2979
|
+
const resolved = await resolveRunState(host, input.token, request.headers.get(AGENT_RUN_HEADER) ?? undefined);
|
|
2975
2980
|
if (resolved.kind === "deny")
|
|
2976
2981
|
return resolved;
|
|
2977
2982
|
const { state, run } = resolved;
|
|
@@ -3016,7 +3021,7 @@ async function runPolicyRefusal(host, input) {
|
|
|
3016
3021
|
}
|
|
3017
3022
|
return;
|
|
3018
3023
|
}
|
|
3019
|
-
async function resolveRunState(host, token) {
|
|
3024
|
+
async function resolveRunState(host, token, actingRunId) {
|
|
3020
3025
|
const agentStorage = host.storage.agents;
|
|
3021
3026
|
const workflowRuns = host.storage.workflowRuns;
|
|
3022
3027
|
if (!agentStorage && !workflowRuns) {
|
|
@@ -3025,15 +3030,23 @@ async function resolveRunState(host, token) {
|
|
|
3025
3030
|
const runId = agentRunTokenRunId(token);
|
|
3026
3031
|
const storedAgentRun = runId ? await agentStorage?.runs.getById({ projectId: host.id, id: runId }) : undefined;
|
|
3027
3032
|
const workflowRun = runId && !storedAgentRun ? await workflowRuns?.agentNodes.getByNodeRunId({ projectId: host.id, nodeRunId: runId }) : undefined;
|
|
3028
|
-
const
|
|
3029
|
-
if (!runId || !
|
|
3033
|
+
const tokenState = toRunState(storedAgentRun ?? null, workflowRun ?? null);
|
|
3034
|
+
if (!runId || !tokenState || tokenState.run.status !== "running" || "cancelRequestedAt" in tokenState.run && tokenState.run.cancelRequestedAt || !tokenState.run.execution || tokenState.run.execution.queueLeaseExpiresAt.getTime() <= Date.now() || !isValidAgentRunToken({
|
|
3030
3035
|
projectId: host.id,
|
|
3031
3036
|
runId,
|
|
3032
|
-
executionToken:
|
|
3037
|
+
executionToken: tokenState.run.execution.token,
|
|
3033
3038
|
token
|
|
3034
3039
|
})) {
|
|
3035
3040
|
return deny(403, "The run token is not valid: its run has ended, moved or been stopped.");
|
|
3036
3041
|
}
|
|
3042
|
+
let runState = tokenState;
|
|
3043
|
+
if (actingRunId !== undefined && actingRunId !== runId) {
|
|
3044
|
+
const child = await childActingFor(host, tokenState, actingRunId);
|
|
3045
|
+
if (!child) {
|
|
3046
|
+
return deny(403, `The run token cannot act as run '${actingRunId}': only as a sub-agent of its own run still at work.`);
|
|
3047
|
+
}
|
|
3048
|
+
runState = child;
|
|
3049
|
+
}
|
|
3037
3050
|
let scope;
|
|
3038
3051
|
try {
|
|
3039
3052
|
scope = await resolveAgentRunExecutionScope(host, {
|
|
@@ -3090,6 +3103,15 @@ function toRunState(storedRun, workflowRun) {
|
|
|
3090
3103
|
actorId: workflowRun.actorId
|
|
3091
3104
|
};
|
|
3092
3105
|
}
|
|
3106
|
+
async function childActingFor(host, parent, childRunId) {
|
|
3107
|
+
if (!parent.agentRun)
|
|
3108
|
+
return null;
|
|
3109
|
+
const child = await host.storage.agents?.runs.getById({ projectId: host.id, id: childRunId });
|
|
3110
|
+
if (child?.kind !== "subagent" || child.parentRunId !== parent.runId || child.status !== "running" || child.cancelRequestedAt || !child.execution) {
|
|
3111
|
+
return null;
|
|
3112
|
+
}
|
|
3113
|
+
return toRunState(child, null);
|
|
3114
|
+
}
|
|
3093
3115
|
function scopeErrorResponse(error) {
|
|
3094
3116
|
switch (error.code) {
|
|
3095
3117
|
case "execution_unavailable":
|
|
@@ -3879,9 +3901,10 @@ function registerActionRunRoutes(app, host) {
|
|
|
3879
3901
|
|
|
3880
3902
|
// src/routes/actions.ts
|
|
3881
3903
|
import { schemaFieldsToJsonSchema } from "@sixb/core/internal/ontology";
|
|
3882
|
-
function serializeAction(action) {
|
|
3904
|
+
function serializeAction(action, folder) {
|
|
3883
3905
|
return ActionCatalogItemSchema.parse({
|
|
3884
3906
|
id: action.id,
|
|
3907
|
+
folder,
|
|
3885
3908
|
name: action.id,
|
|
3886
3909
|
description: action.description,
|
|
3887
3910
|
...action.binding.kind === "object" ? { objectTypeId: action.binding.objectTypeId } : {},
|
|
@@ -3899,7 +3922,7 @@ function serializeAction(action) {
|
|
|
3899
3922
|
}
|
|
3900
3923
|
function serializeActionDetail(action, host) {
|
|
3901
3924
|
return ActionDetailSchema.parse({
|
|
3902
|
-
...serializeAction(action),
|
|
3925
|
+
...serializeAction(action, host.definitions.folders.actions?.get(action.id)),
|
|
3903
3926
|
inputSchema: schemaFieldsToJsonSchema({
|
|
3904
3927
|
fields: action.params,
|
|
3905
3928
|
valueTypesById: host.definitions.ontology.getValueTypesById()
|
|
@@ -3909,7 +3932,7 @@ function serializeActionDetail(action, host) {
|
|
|
3909
3932
|
function registerActionRoutes(app, host) {
|
|
3910
3933
|
return app.get("/api/actions", async (context) => {
|
|
3911
3934
|
const actions = requireRequestSixb(context).actions.list();
|
|
3912
|
-
return actions.map(serializeAction);
|
|
3935
|
+
return actions.map((action) => serializeAction(action, host.definitions.folders.actions?.get(action.id)));
|
|
3913
3936
|
}, {
|
|
3914
3937
|
response: { 200: ActionCatalogItemSchema.array() },
|
|
3915
3938
|
detail: {
|
|
@@ -8034,6 +8057,7 @@ var DatasetLatestVersionSummarySchema = z19.object({
|
|
|
8034
8057
|
});
|
|
8035
8058
|
var DatasetCatalogItemSchema = DatasetDefinitionSchema.extend({
|
|
8036
8059
|
kind: z19.literal("dataset"),
|
|
8060
|
+
folder: DefinitionFolderSchema,
|
|
8037
8061
|
materialized: z19.boolean(),
|
|
8038
8062
|
latestVersion: DatasetLatestVersionSummarySchema.nullable(),
|
|
8039
8063
|
syncIds: z19.array(z19.string()),
|
|
@@ -11587,6 +11611,7 @@ var ConnectorWebhookSchema = z26.object({
|
|
|
11587
11611
|
});
|
|
11588
11612
|
var ConnectorSchema = z26.object({
|
|
11589
11613
|
id: z26.string(),
|
|
11614
|
+
folder: DefinitionFolderSchema,
|
|
11590
11615
|
type: z26.string(),
|
|
11591
11616
|
connection: z26.object({ authentication: z26.literal("oauth2") }).nullable(),
|
|
11592
11617
|
syncIds: z26.array(z26.string()),
|
|
@@ -12131,6 +12156,7 @@ import { isOAuthConnectorDefinition as isOAuthConnectorDefinition2 } from "@sixb
|
|
|
12131
12156
|
function serializeConnector(connector, host, execution) {
|
|
12132
12157
|
return {
|
|
12133
12158
|
id: connector.id,
|
|
12159
|
+
folder: host.definitions.folders.connectors?.get(connector.id),
|
|
12134
12160
|
type: connector.adapter.type,
|
|
12135
12161
|
connection: isOAuthConnectorDefinition2(connector) ? { authentication: "oauth2" } : null,
|
|
12136
12162
|
syncIds: execution.syncs.list().filter((sync) => sync.connector.id === connector.id).map((sync) => sync.id),
|
|
@@ -12271,9 +12297,10 @@ function serializeLatestVersionSummary(summary) {
|
|
|
12271
12297
|
rowCount: summary.rowCount
|
|
12272
12298
|
};
|
|
12273
12299
|
}
|
|
12274
|
-
function serializeDatasetCatalogItem(dataset, state, references) {
|
|
12300
|
+
function serializeDatasetCatalogItem(dataset, state, references, folder) {
|
|
12275
12301
|
return DatasetCatalogItemSchema.parse({
|
|
12276
12302
|
...dataset,
|
|
12303
|
+
folder,
|
|
12277
12304
|
materialized: state?.materialized ?? false,
|
|
12278
12305
|
latestVersion: state?.latestVersion ? serializeLatestVersionSummary(state.latestVersion) : null,
|
|
12279
12306
|
syncIds: references.syncIds,
|
|
@@ -12286,7 +12313,7 @@ async function serializeDatasetCatalogItems(host, definitions, sixb) {
|
|
|
12286
12313
|
const references = buildDatasetReferenceIndex(sixb);
|
|
12287
12314
|
const states = await host.lakeStorage.listDatasetCatalogState(definitions.map((d) => d.id));
|
|
12288
12315
|
const stateByDatasetId = new Map(states.map((state) => [state.datasetId, state]));
|
|
12289
|
-
return definitions.map((definition) => serializeDatasetCatalogItem(definition, stateByDatasetId.get(definition.id), references.get(definition.id) ?? EMPTY_DATASET_REFERENCES));
|
|
12316
|
+
return definitions.map((definition) => serializeDatasetCatalogItem(definition, stateByDatasetId.get(definition.id), references.get(definition.id) ?? EMPTY_DATASET_REFERENCES, host.definitions.folders.datasets?.get(definition.id)));
|
|
12290
12317
|
}
|
|
12291
12318
|
function requireDataset(sixb, datasetId) {
|
|
12292
12319
|
const dataset = sixb.datasets.getById(datasetId);
|
|
@@ -12335,7 +12362,7 @@ function registerDatasetRoutes(app, host) {
|
|
|
12335
12362
|
const dataset = requireDataset(sixb, params.datasetId);
|
|
12336
12363
|
const [state] = await host.lakeStorage.listDatasetCatalogState([dataset.id]);
|
|
12337
12364
|
const references = buildDatasetReferenceIndex(sixb).get(dataset.id);
|
|
12338
|
-
return serializeDatasetCatalogItem(dataset, state, references ?? EMPTY_DATASET_REFERENCES);
|
|
12365
|
+
return serializeDatasetCatalogItem(dataset, state, references ?? EMPTY_DATASET_REFERENCES, host.definitions.folders.datasets?.get(dataset.id));
|
|
12339
12366
|
} catch (error) {
|
|
12340
12367
|
return handleRouteError(error, set);
|
|
12341
12368
|
}
|
|
@@ -13842,9 +13869,10 @@ function serializeSearch(search) {
|
|
|
13842
13869
|
])) : undefined
|
|
13843
13870
|
};
|
|
13844
13871
|
}
|
|
13845
|
-
function serializeObjectType(execution, valueTypesById, objectType) {
|
|
13872
|
+
function serializeObjectType(execution, valueTypesById, objectType, folder) {
|
|
13846
13873
|
return {
|
|
13847
13874
|
id: objectType.id,
|
|
13875
|
+
folder,
|
|
13848
13876
|
name: objectType.name,
|
|
13849
13877
|
description: objectType.description,
|
|
13850
13878
|
extends: objectType.extends,
|
|
@@ -13879,7 +13907,7 @@ function registerOntologyRoutes(app, host) {
|
|
|
13879
13907
|
return app.get("/api/object-types", async (context) => {
|
|
13880
13908
|
const sixb = requireRequestSixb(context);
|
|
13881
13909
|
const valueTypesById = host.definitions.ontology.getValueTypesById();
|
|
13882
|
-
return sixb.objects.listTypes().map((objectType) => serializeObjectType(sixb, valueTypesById, objectType));
|
|
13910
|
+
return sixb.objects.listTypes().map((objectType) => serializeObjectType(sixb, valueTypesById, objectType, host.definitions.folders.objectTypes?.get(objectType.id)));
|
|
13883
13911
|
}, {
|
|
13884
13912
|
response: { 200: ObjectTypeSchema.array() },
|
|
13885
13913
|
detail: {
|
|
@@ -13896,7 +13924,7 @@ function registerOntologyRoutes(app, host) {
|
|
|
13896
13924
|
set.status = 404;
|
|
13897
13925
|
return { error: "Object type not found" };
|
|
13898
13926
|
}
|
|
13899
|
-
return serializeObjectType(sixb, host.definitions.ontology.getValueTypesById(), objectType);
|
|
13927
|
+
return serializeObjectType(sixb, host.definitions.ontology.getValueTypesById(), objectType, host.definitions.folders.objectTypes?.get(objectType.id));
|
|
13900
13928
|
}, {
|
|
13901
13929
|
params: ObjectTypeParamsSchema,
|
|
13902
13930
|
response: { 200: ObjectTypeSchema, 404: ErrorResponseSchema },
|
|
@@ -13995,6 +14023,7 @@ var PipelineStepSchema = z31.object({
|
|
|
13995
14023
|
});
|
|
13996
14024
|
var PipelineSchema = z31.object({
|
|
13997
14025
|
id: z31.string(),
|
|
14026
|
+
folder: DefinitionFolderSchema,
|
|
13998
14027
|
triggers: z31.array(PipelineTriggerSchema),
|
|
13999
14028
|
graph: z31.object({
|
|
14000
14029
|
kind: z31.literal("sequence"),
|
|
@@ -14079,9 +14108,10 @@ async function getLatestPipelineRuns(sixb, pipelineIds) {
|
|
|
14079
14108
|
const result = await sixb.pipelines.runs.listLatest(pipelineIds);
|
|
14080
14109
|
return new Map(result.runs.map((run) => [run.pipelineId, serializePipelineRun(run)]));
|
|
14081
14110
|
}
|
|
14082
|
-
function serializePipeline(pipeline, latestRun) {
|
|
14111
|
+
function serializePipeline(pipeline, latestRun, folder) {
|
|
14083
14112
|
return PipelineSchema.parse({
|
|
14084
14113
|
id: pipeline.id,
|
|
14114
|
+
folder,
|
|
14085
14115
|
triggers: pipeline.triggers,
|
|
14086
14116
|
graph: {
|
|
14087
14117
|
kind: pipeline.graph.kind,
|
|
@@ -14107,7 +14137,7 @@ function registerPipelineRoutes(app, host) {
|
|
|
14107
14137
|
const sixb = requireRequestSixb(context);
|
|
14108
14138
|
const pipelines = sixb.pipelines.list();
|
|
14109
14139
|
const latestRuns = await getLatestPipelineRuns(sixb, pipelines.map((pipeline) => pipeline.id));
|
|
14110
|
-
return pipelines.map((pipeline) => serializePipeline(pipeline, latestRuns.get(pipeline.id) ?? null));
|
|
14140
|
+
return pipelines.map((pipeline) => serializePipeline(pipeline, latestRuns.get(pipeline.id) ?? null, host.definitions.folders.pipelines?.get(pipeline.id)));
|
|
14111
14141
|
}, {
|
|
14112
14142
|
response: { 200: PipelineSchema.array() },
|
|
14113
14143
|
detail: {
|
|
@@ -14124,7 +14154,7 @@ function registerPipelineRoutes(app, host) {
|
|
|
14124
14154
|
set.status = 404;
|
|
14125
14155
|
return { error: "Pipeline not found" };
|
|
14126
14156
|
}
|
|
14127
|
-
return serializePipeline(pipeline, await getLatestPipelineRun(sixb, pipeline.id));
|
|
14157
|
+
return serializePipeline(pipeline, await getLatestPipelineRun(sixb, pipeline.id), host.definitions.folders.pipelines?.get(pipeline.id));
|
|
14128
14158
|
}, {
|
|
14129
14159
|
params: PipelineParamsSchema,
|
|
14130
14160
|
response: { 200: PipelineSchema, 404: ErrorResponseSchema },
|
|
@@ -14348,6 +14378,7 @@ var SourceEditConflictResolutionSchema = z33.union([
|
|
|
14348
14378
|
var ObjectProjectionSchema = z33.object({
|
|
14349
14379
|
_tag: z33.literal("ObjectProjectionDefinition"),
|
|
14350
14380
|
id: z33.string(),
|
|
14381
|
+
folder: DefinitionFolderSchema,
|
|
14351
14382
|
objectTypeId: z33.string(),
|
|
14352
14383
|
datasetId: z33.string(),
|
|
14353
14384
|
properties: z33.record(z33.string()),
|
|
@@ -14360,6 +14391,7 @@ var ObjectProjectionSchema = z33.object({
|
|
|
14360
14391
|
var LinkProjectionSchema = z33.object({
|
|
14361
14392
|
_tag: z33.literal("LinkProjectionDefinition"),
|
|
14362
14393
|
id: z33.string(),
|
|
14394
|
+
folder: DefinitionFolderSchema,
|
|
14363
14395
|
linkId: z33.string(),
|
|
14364
14396
|
sourceObjectTypeId: z33.string(),
|
|
14365
14397
|
targetObjectTypeId: z33.string(),
|
|
@@ -14371,6 +14403,7 @@ var LinkProjectionSchema = z33.object({
|
|
|
14371
14403
|
var TelemetryProjectionSchema = z33.object({
|
|
14372
14404
|
_tag: z33.literal("TelemetryProjectionDefinition"),
|
|
14373
14405
|
id: z33.string(),
|
|
14406
|
+
folder: DefinitionFolderSchema,
|
|
14374
14407
|
objectTypeId: z33.string(),
|
|
14375
14408
|
datasetId: z33.string(),
|
|
14376
14409
|
objectIdField: z33.string(),
|
|
@@ -14453,22 +14486,24 @@ function projectionCatalogIds(catalog) {
|
|
|
14453
14486
|
...catalog.telemetryProjections
|
|
14454
14487
|
].map((projection) => projection.id);
|
|
14455
14488
|
}
|
|
14456
|
-
function serializeProjection(projection, latestRuns) {
|
|
14489
|
+
function serializeProjection(projection, latestRuns, folders) {
|
|
14457
14490
|
const latestRun = latestRuns.get(projection.id) ?? null;
|
|
14491
|
+
const folder = folders?.get(projection.id);
|
|
14458
14492
|
if (projection._tag === "ObjectProjectionDefinition") {
|
|
14459
14493
|
return {
|
|
14460
14494
|
...projection,
|
|
14495
|
+
folder,
|
|
14461
14496
|
conflictResolution: projection.conflictResolution ?? { strategy: "editsWin" },
|
|
14462
14497
|
latestRun
|
|
14463
14498
|
};
|
|
14464
14499
|
}
|
|
14465
|
-
return { ...projection, latestRun };
|
|
14500
|
+
return { ...projection, folder, latestRun };
|
|
14466
14501
|
}
|
|
14467
|
-
function serializeProjectionCatalog(catalog, latestRuns) {
|
|
14502
|
+
function serializeProjectionCatalog(catalog, latestRuns, folders) {
|
|
14468
14503
|
return {
|
|
14469
|
-
objectProjections: catalog.objectProjections.map((projection) => serializeProjection(projection, latestRuns)),
|
|
14470
|
-
linkProjections: catalog.linkProjections.map((projection) => serializeProjection(projection, latestRuns)),
|
|
14471
|
-
telemetryProjections: catalog.telemetryProjections.map((projection) => serializeProjection(projection, latestRuns))
|
|
14504
|
+
objectProjections: catalog.objectProjections.map((projection) => serializeProjection(projection, latestRuns, folders)),
|
|
14505
|
+
linkProjections: catalog.linkProjections.map((projection) => serializeProjection(projection, latestRuns, folders)),
|
|
14506
|
+
telemetryProjections: catalog.telemetryProjections.map((projection) => serializeProjection(projection, latestRuns, folders))
|
|
14472
14507
|
};
|
|
14473
14508
|
}
|
|
14474
14509
|
function registerProjectionRoutes(app, host) {
|
|
@@ -14476,7 +14511,7 @@ function registerProjectionRoutes(app, host) {
|
|
|
14476
14511
|
const sixb = requireRequestSixb(context);
|
|
14477
14512
|
const catalog = listViewableProjections(sixb);
|
|
14478
14513
|
const latestRuns = await getLatestProjectionRuns(sixb, projectionCatalogIds(catalog));
|
|
14479
|
-
return serializeProjectionCatalog(catalog, latestRuns);
|
|
14514
|
+
return serializeProjectionCatalog(catalog, latestRuns, host.definitions.folders.projections);
|
|
14480
14515
|
}, {
|
|
14481
14516
|
response: { 200: ProjectionListResponseSchema },
|
|
14482
14517
|
detail: {
|
|
@@ -14493,7 +14528,7 @@ function registerProjectionRoutes(app, host) {
|
|
|
14493
14528
|
return { error: `Projection '${params.projectionId}' not found` };
|
|
14494
14529
|
}
|
|
14495
14530
|
const latestRuns = await getLatestProjectionRuns(sixb, [found.id]);
|
|
14496
|
-
return serializeProjection(found, latestRuns);
|
|
14531
|
+
return serializeProjection(found, latestRuns, host.definitions.folders.projections);
|
|
14497
14532
|
}, {
|
|
14498
14533
|
params: ProjectionParamsSchema,
|
|
14499
14534
|
response: { 200: ProjectionResponseSchema, 404: ErrorResponseSchema },
|
|
@@ -14648,6 +14683,7 @@ var RuleEventDependencySchema = z34.union([
|
|
|
14648
14683
|
var RuleSchema = z34.object({
|
|
14649
14684
|
kind: z34.literal("rule"),
|
|
14650
14685
|
id: z34.string(),
|
|
14686
|
+
folder: DefinitionFolderSchema,
|
|
14651
14687
|
subject: RuleSubjectSchema,
|
|
14652
14688
|
predicate: RulePredicateSchema,
|
|
14653
14689
|
dependencies: z34.array(RuleEventDependencySchema)
|
|
@@ -14665,9 +14701,10 @@ var RuleStateListResponseSchema = z34.object({
|
|
|
14665
14701
|
});
|
|
14666
14702
|
|
|
14667
14703
|
// src/routes/rules.ts
|
|
14668
|
-
function serializeRule(rule) {
|
|
14704
|
+
function serializeRule(rule, folder) {
|
|
14669
14705
|
return RuleSchema.parse({
|
|
14670
14706
|
...rule,
|
|
14707
|
+
folder,
|
|
14671
14708
|
dependencies: deriveRuleEventDependencies(rule)
|
|
14672
14709
|
});
|
|
14673
14710
|
}
|
|
@@ -14676,7 +14713,7 @@ function serializeRuleState(state) {
|
|
|
14676
14713
|
}
|
|
14677
14714
|
function registerRuleRoutes(app, host) {
|
|
14678
14715
|
return app.get("/api/rules", (context) => {
|
|
14679
|
-
return requireRequestSixb(context).rules.list().map(serializeRule);
|
|
14716
|
+
return requireRequestSixb(context).rules.list().map((rule) => serializeRule(rule, host.definitions.folders.rules?.get(rule.id)));
|
|
14680
14717
|
}, {
|
|
14681
14718
|
response: { 200: RuleSchema.array() },
|
|
14682
14719
|
detail: {
|
|
@@ -14691,7 +14728,7 @@ function registerRuleRoutes(app, host) {
|
|
|
14691
14728
|
set.status = 404;
|
|
14692
14729
|
return { error: "Rule not found" };
|
|
14693
14730
|
}
|
|
14694
|
-
return serializeRule(rule);
|
|
14731
|
+
return serializeRule(rule, host.definitions.folders.rules?.get(rule.id));
|
|
14695
14732
|
}, {
|
|
14696
14733
|
params: RuleParamsSchema,
|
|
14697
14734
|
response: { 200: RuleSchema, 404: ErrorResponseSchema },
|
|
@@ -15376,6 +15413,7 @@ var SyncAccountSummarySchema = z38.object({
|
|
|
15376
15413
|
});
|
|
15377
15414
|
var SyncSchema = z38.object({
|
|
15378
15415
|
id: z38.string(),
|
|
15416
|
+
folder: DefinitionFolderSchema,
|
|
15379
15417
|
mode: SyncModeSchema,
|
|
15380
15418
|
connector: z38.object({
|
|
15381
15419
|
id: z38.string(),
|
|
@@ -15486,9 +15524,10 @@ function summarizeSyncAccounts(syncId, accounts) {
|
|
|
15486
15524
|
...lastSyncedAt === undefined ? {} : { lastSyncedAt: toIsoString(lastSyncedAt) }
|
|
15487
15525
|
};
|
|
15488
15526
|
}
|
|
15489
|
-
function serializeSync(sync, latestRun, accounts) {
|
|
15527
|
+
function serializeSync(sync, latestRun, folder, accounts) {
|
|
15490
15528
|
return SyncSchema.parse({
|
|
15491
15529
|
id: sync.id,
|
|
15530
|
+
folder,
|
|
15492
15531
|
mode: sync.config.mode,
|
|
15493
15532
|
connector: {
|
|
15494
15533
|
id: sync.connector.id,
|
|
@@ -15509,7 +15548,7 @@ function registerSyncRoutes(app, host) {
|
|
|
15509
15548
|
const syncs = sixb.syncs.list();
|
|
15510
15549
|
const latestRuns = await getLatestSyncRuns(sixb, syncs.map((sync) => sync.id));
|
|
15511
15550
|
const accountsOf = connectorAccounts(sixb);
|
|
15512
|
-
return Promise.all(syncs.map(async (sync) => serializeSync(sync, latestRuns.get(sync.id) ?? null, await summarizeAccounts(sync, accountsOf))));
|
|
15551
|
+
return Promise.all(syncs.map(async (sync) => serializeSync(sync, latestRuns.get(sync.id) ?? null, host.definitions.folders.syncs?.get(sync.id), await summarizeAccounts(sync, accountsOf))));
|
|
15513
15552
|
}, {
|
|
15514
15553
|
response: { 200: SyncSchema.array() },
|
|
15515
15554
|
detail: {
|
|
@@ -15526,7 +15565,7 @@ function registerSyncRoutes(app, host) {
|
|
|
15526
15565
|
set.status = 404;
|
|
15527
15566
|
return { error: "Sync not found" };
|
|
15528
15567
|
}
|
|
15529
|
-
return serializeSync(sync, await getLatestSyncRun(sixb, sync.id), await summarizeAccounts(sync, connectorAccounts(sixb)));
|
|
15568
|
+
return serializeSync(sync, await getLatestSyncRun(sixb, sync.id), host.definitions.folders.syncs?.get(sync.id), await summarizeAccounts(sync, connectorAccounts(sixb)));
|
|
15530
15569
|
}, {
|
|
15531
15570
|
params: SyncParamsSchema,
|
|
15532
15571
|
response: { 200: SyncSchema, 404: ErrorResponseSchema },
|
|
@@ -16203,9 +16242,10 @@ async function getLatestWorkflowRuns(sixb, workflowIds) {
|
|
|
16203
16242
|
const result = await sixb.workflows.runs.listLatest(workflowIds);
|
|
16204
16243
|
return new Map(result.runs.map((run) => [run.workflowId, serializeWorkflowRunSummary(run)]));
|
|
16205
16244
|
}
|
|
16206
|
-
function serializeWorkflow(workflow, latestRun) {
|
|
16245
|
+
function serializeWorkflow(workflow, latestRun, folder) {
|
|
16207
16246
|
return WorkflowSchema.parse({
|
|
16208
16247
|
id: workflow.id,
|
|
16248
|
+
folder,
|
|
16209
16249
|
input: workflow.input,
|
|
16210
16250
|
triggers: workflow.triggers,
|
|
16211
16251
|
nodes: workflow.nodes.map((node) => {
|
|
@@ -16376,7 +16416,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
16376
16416
|
const sixb = requireRequestSixb(context);
|
|
16377
16417
|
const workflows = sixb.workflows.list();
|
|
16378
16418
|
const latestRuns = await getLatestWorkflowRuns(sixb, workflows.map((workflow) => workflow.id));
|
|
16379
|
-
return workflows.map((workflow) => serializeWorkflow(workflow, latestRuns.get(workflow.id) ?? null));
|
|
16419
|
+
return workflows.map((workflow) => serializeWorkflow(workflow, latestRuns.get(workflow.id) ?? null, host.definitions.folders.workflows?.get(workflow.id)));
|
|
16380
16420
|
}, {
|
|
16381
16421
|
response: { 200: WorkflowSchema.array() },
|
|
16382
16422
|
detail: {
|
|
@@ -16393,7 +16433,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
16393
16433
|
set.status = 404;
|
|
16394
16434
|
return { error: "Workflow not found" };
|
|
16395
16435
|
}
|
|
16396
|
-
return serializeWorkflow(workflow, await getLatestWorkflowRun(sixb, workflow.id));
|
|
16436
|
+
return serializeWorkflow(workflow, await getLatestWorkflowRun(sixb, workflow.id), host.definitions.folders.workflows?.get(workflow.id));
|
|
16397
16437
|
}, {
|
|
16398
16438
|
params: WorkflowParamsSchema,
|
|
16399
16439
|
response: { 200: WorkflowSchema, 404: ErrorResponseSchema },
|
|
@@ -22609,4 +22649,4 @@ export {
|
|
|
22609
22649
|
requestTimingOptionsFromEnv
|
|
22610
22650
|
};
|
|
22611
22651
|
|
|
22612
|
-
//# debugId=
|
|
22652
|
+
//# debugId=0351BBB652D7396764756E2164756E21
|