@antelopejs/dms-automation 0.2.6 → 0.3.0
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 +46 -2
- package/dist/data/procedures-table.d.ts +38 -4
- package/dist/data/procedures-table.js +264 -82
- package/dist/data/procedures-table.js.map +1 -1
- package/dist/data/runs-table.d.ts +19 -3
- package/dist/data/runs-table.js +254 -19
- package/dist/data/runs-table.js.map +1 -1
- package/dist/db/index.d.ts +1 -2
- package/dist/db/index.js +1 -2
- package/dist/db/index.js.map +1 -1
- package/dist/db/models/automation_template.model.d.ts +16 -1
- package/dist/db/models/automation_template.model.js +31 -11
- package/dist/db/models/automation_template.model.js.map +1 -1
- package/dist/db/models/index.d.ts +1 -1
- package/dist/db/models/index.js +1 -1
- package/dist/db/models/procedure.model.d.ts +1 -0
- package/dist/db/models/procedure.model.js +7 -0
- package/dist/db/models/procedure.model.js.map +1 -1
- package/dist/db/models/procedure_run.model.d.ts +16 -9
- package/dist/db/models/procedure_run.model.js +96 -17
- package/dist/db/models/procedure_run.model.js.map +1 -1
- package/dist/db/models/stats.model.d.ts +60 -61
- package/dist/db/models/stats.model.js +189 -236
- package/dist/db/models/stats.model.js.map +1 -1
- package/dist/db/models/type_switch.model.d.ts +25 -0
- package/dist/db/models/type_switch.model.js +25 -0
- package/dist/db/models/type_switch.model.js.map +1 -0
- package/dist/db/tables/index.d.ts +1 -2
- package/dist/db/tables/index.js +1 -2
- package/dist/db/tables/index.js.map +1 -1
- package/dist/db/tables/procedure.table.d.ts +6 -0
- package/dist/db/tables/procedure.table.js +24 -0
- package/dist/db/tables/procedure.table.js.map +1 -1
- package/dist/db/tables/procedure_run.table.d.ts +15 -1
- package/dist/db/tables/procedure_run.table.js +54 -0
- package/dist/db/tables/procedure_run.table.js.map +1 -1
- package/dist/db/tables/type_switch.table.d.ts +8 -0
- package/dist/db/tables/{trigger_type_config.table.js → type_switch.table.js} +16 -15
- package/dist/db/tables/type_switch.table.js.map +1 -0
- package/dist/displays/index.d.ts +14 -0
- package/dist/displays/index.js +23 -0
- package/dist/displays/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/pages/builder.d.ts +1 -1
- package/dist/pages/builder.js +10 -3
- package/dist/pages/builder.js.map +1 -1
- package/dist/pages/index.d.ts +2 -1
- package/dist/pages/index.js +2 -1
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/library.d.ts +2 -1
- package/dist/pages/library.js +54 -4
- package/dist/pages/library.js.map +1 -1
- package/dist/pages/overview.d.ts +6 -1
- package/dist/pages/overview.js +121 -2
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/procedures.js +106 -16
- package/dist/pages/procedures.js.map +1 -1
- package/dist/pages/runs.d.ts +4 -1
- package/dist/pages/runs.js +109 -13
- package/dist/pages/runs.js.map +1 -1
- package/dist/pages/shared.d.ts +18 -0
- package/dist/pages/shared.js +238 -0
- package/dist/pages/shared.js.map +1 -0
- package/dist/pages/trace.d.ts +10 -0
- package/dist/pages/trace.js +41 -0
- package/dist/pages/trace.js.map +1 -0
- package/dist/realtime.d.ts +3 -0
- package/dist/realtime.js +14 -0
- package/dist/realtime.js.map +1 -0
- package/dist/routes/action-types.d.ts +2 -14
- package/dist/routes/action-types.js +2 -32
- package/dist/routes/action-types.js.map +1 -1
- package/dist/routes/deleteConfirm.d.ts +3 -0
- package/dist/routes/deleteConfirm.js +64 -0
- package/dist/routes/deleteConfirm.js.map +1 -0
- package/dist/routes/graphSchema.d.ts +3 -90
- package/dist/routes/graphSchema.js +36 -9
- package/dist/routes/graphSchema.js.map +1 -1
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/library.d.ts +40 -0
- package/dist/routes/library.js +147 -0
- package/dist/routes/library.js.map +1 -0
- package/dist/routes/procedureChecks.d.ts +16 -0
- package/dist/routes/procedureChecks.js +72 -0
- package/dist/routes/procedureChecks.js.map +1 -0
- package/dist/routes/procedureRuns.d.ts +21 -0
- package/dist/routes/procedureRuns.js +45 -0
- package/dist/routes/procedureRuns.js.map +1 -0
- package/dist/routes/procedureSchemas.d.ts +107 -0
- package/dist/routes/procedureSchemas.js +61 -0
- package/dist/routes/procedureSchemas.js.map +1 -0
- package/dist/routes/procedures.d.ts +125 -7
- package/dist/routes/procedures.js +363 -67
- package/dist/routes/procedures.js.map +1 -1
- package/dist/routes/requests.d.ts +15 -0
- package/dist/routes/requests.js +35 -0
- package/dist/routes/requests.js.map +1 -0
- package/dist/routes/runs.d.ts +107 -2
- package/dist/routes/runs.js +340 -37
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/stats.d.ts +19 -1
- package/dist/routes/stats.js +160 -4
- package/dist/routes/stats.js.map +1 -1
- package/dist/routes/templates.d.ts +6 -2
- package/dist/routes/templates.js +106 -36
- package/dist/routes/templates.js.map +1 -1
- package/dist/routes/trigger-types.d.ts +2 -15
- package/dist/routes/trigger-types.js +2 -32
- package/dist/routes/trigger-types.js.map +1 -1
- package/dist/routes/typeConfigShared.d.ts +7 -11
- package/dist/routes/typeConfigShared.js +25 -15
- package/dist/routes/typeConfigShared.js.map +1 -1
- package/dist/runtime/armErrors.d.ts +16 -0
- package/dist/runtime/armErrors.js +69 -0
- package/dist/runtime/armErrors.js.map +1 -0
- package/dist/runtime/boundRunLog.d.ts +24 -0
- package/dist/runtime/boundRunLog.js +202 -10
- package/dist/runtime/boundRunLog.js.map +1 -1
- package/dist/runtime/builtins/actions/http.d.ts +10 -1
- package/dist/runtime/builtins/actions/http.js +306 -19
- package/dist/runtime/builtins/actions/http.js.map +1 -1
- package/dist/runtime/builtins/actions/log.js +2 -2
- package/dist/runtime/builtins/actions/log.js.map +1 -1
- package/dist/runtime/builtins/data/boolean.d.ts +1 -0
- package/dist/runtime/builtins/data/boolean.js +18 -10
- package/dist/runtime/builtins/data/boolean.js.map +1 -1
- package/dist/runtime/builtins/data/compare.js +60 -11
- package/dist/runtime/builtins/data/compare.js.map +1 -1
- package/dist/runtime/builtins/data/constant.js +9 -12
- package/dist/runtime/builtins/data/constant.js.map +1 -1
- package/dist/runtime/builtins/data/json.js +4 -4
- package/dist/runtime/builtins/data/json.js.map +1 -1
- package/dist/runtime/builtins/data/math.js +44 -24
- package/dist/runtime/builtins/data/math.js.map +1 -1
- package/dist/runtime/builtins/data/object.js +10 -10
- package/dist/runtime/builtins/data/object.js.map +1 -1
- package/dist/runtime/builtins/data/string.js +31 -20
- package/dist/runtime/builtins/data/string.js.map +1 -1
- package/dist/runtime/builtins/nodes/action.js +4 -0
- package/dist/runtime/builtins/nodes/action.js.map +1 -1
- package/dist/runtime/builtins/nodes/delay.js +1 -1
- package/dist/runtime/builtins/nodes/delay.js.map +1 -1
- package/dist/runtime/builtins/nodes/forRange.d.ts +1 -1
- package/dist/runtime/builtins/nodes/forRange.js +10 -4
- package/dist/runtime/builtins/nodes/forRange.js.map +1 -1
- package/dist/runtime/builtins/nodes/if.js +2 -1
- package/dist/runtime/builtins/nodes/if.js.map +1 -1
- package/dist/runtime/builtins/nodes/parallel.js +9 -2
- package/dist/runtime/builtins/nodes/parallel.js.map +1 -1
- package/dist/runtime/builtins/nodes/retry.js +1 -1
- package/dist/runtime/builtins/nodes/retry.js.map +1 -1
- package/dist/runtime/builtins/nodes/setVariable.js +1 -3
- package/dist/runtime/builtins/nodes/setVariable.js.map +1 -1
- package/dist/runtime/builtins/triggers/cron.d.ts +3 -0
- package/dist/runtime/builtins/triggers/cron.js +21 -7
- package/dist/runtime/builtins/triggers/cron.js.map +1 -1
- package/dist/runtime/builtins/triggers/manual.js +2 -2
- package/dist/runtime/builtins/triggers/manual.js.map +1 -1
- package/dist/runtime/builtins/triggers/webhook.d.ts +14 -1
- package/dist/runtime/builtins/triggers/webhook.js +116 -30
- package/dist/runtime/builtins/triggers/webhook.js.map +1 -1
- package/dist/runtime/describe.d.ts +23 -0
- package/dist/runtime/describe.js +114 -0
- package/dist/runtime/describe.js.map +1 -0
- package/dist/runtime/executionResult.d.ts +1 -0
- package/dist/runtime/executor.js +82 -5
- package/dist/runtime/executor.js.map +1 -1
- package/dist/runtime/graphIssues.d.ts +20 -0
- package/dist/runtime/graphIssues.js +290 -0
- package/dist/runtime/graphIssues.js.map +1 -0
- package/dist/runtime/graphVersion.d.ts +2 -0
- package/dist/runtime/graphVersion.js +43 -0
- package/dist/runtime/graphVersion.js.map +1 -0
- package/dist/runtime/nodeKinds.d.ts +4 -4
- package/dist/runtime/nodeKinds.js +1 -2
- package/dist/runtime/nodeKinds.js.map +1 -1
- package/dist/runtime/registry.d.ts +2 -1
- package/dist/runtime/registry.js +1 -2
- package/dist/runtime/registry.js.map +1 -1
- package/dist/runtime/resolveInputs.d.ts +3 -1
- package/dist/runtime/resolveInputs.js +12 -2
- package/dist/runtime/resolveInputs.js.map +1 -1
- package/dist/runtime/resolveSubgraph.d.ts +12 -1
- package/dist/runtime/resolveSubgraph.js +36 -0
- package/dist/runtime/resolveSubgraph.js.map +1 -1
- package/dist/runtime/retention.d.ts +6 -0
- package/dist/runtime/retention.js +54 -0
- package/dist/runtime/retention.js.map +1 -0
- package/dist/runtime/runProcedure.d.ts +12 -0
- package/dist/runtime/runProcedure.js +130 -0
- package/dist/runtime/runProcedure.js.map +1 -0
- package/dist/runtime/schedule.d.ts +2 -0
- package/dist/runtime/schedule.js +139 -0
- package/dist/runtime/schedule.js.map +1 -0
- package/dist/runtime/subscriptions.d.ts +11 -1
- package/dist/runtime/subscriptions.js +91 -125
- package/dist/runtime/subscriptions.js.map +1 -1
- package/dist/runtime/subwalk.js +2 -3
- package/dist/runtime/subwalk.js.map +1 -1
- package/dist/runtime/templateUsages.d.ts +4 -0
- package/dist/runtime/templateUsages.js +102 -0
- package/dist/runtime/templateUsages.js.map +1 -0
- package/dist/runtime/topo.d.ts +1 -0
- package/dist/runtime/topo.js +23 -0
- package/dist/runtime/topo.js.map +1 -1
- package/dist/runtime/trace.d.ts +44 -0
- package/dist/runtime/trace.js +240 -0
- package/dist/runtime/trace.js.map +1 -0
- package/dist/runtime/typeSwitches.d.ts +3 -0
- package/dist/runtime/typeSwitches.js +27 -0
- package/dist/runtime/typeSwitches.js.map +1 -0
- package/dist/runtime/validate.d.ts +11 -0
- package/dist/runtime/validate.js +118 -61
- package/dist/runtime/validate.js.map +1 -1
- package/dist/runtime/webhookRoutes.d.ts +4 -0
- package/dist/runtime/webhookRoutes.js +68 -0
- package/dist/runtime/webhookRoutes.js.map +1 -0
- package/dist/runtime/withTimeout.d.ts +1 -0
- package/dist/runtime/withTimeout.js +17 -0
- package/dist/runtime/withTimeout.js.map +1 -0
- package/dist/runtime/wording.d.ts +10 -0
- package/dist/runtime/wording.js +118 -0
- package/dist/runtime/wording.js.map +1 -0
- package/dist/stats/health-banner.d.ts +13 -0
- package/dist/stats/health-banner.js +149 -0
- package/dist/stats/health-banner.js.map +1 -0
- package/dist/stats/health.d.ts +49 -0
- package/dist/stats/health.js +130 -0
- package/dist/stats/health.js.map +1 -0
- package/dist/stats/kpi.d.ts +21 -0
- package/dist/stats/kpi.js +101 -0
- package/dist/stats/kpi.js.map +1 -0
- package/dist/stats/overview.d.ts +94 -0
- package/dist/stats/overview.js +244 -0
- package/dist/stats/overview.js.map +1 -0
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.js +1 -2
- package/dist/types/constants.js.map +1 -1
- package/dist/types/runLog.d.ts +2 -0
- package/dist/types/runLog.js +4 -0
- package/dist/types/runLog.js.map +1 -1
- package/frontend-vue/app/components/AttentionList.vue +276 -0
- package/frontend-vue/app/components/Catalog/SchemaTable.vue +127 -0
- package/frontend-vue/app/components/Catalog.vue +457 -0
- package/frontend-vue/app/components/Editor/BottomDock.vue +188 -0
- package/frontend-vue/app/components/Editor/BuilderPalette.vue +105 -44
- package/frontend-vue/app/components/Editor/GraphCanvas.vue +822 -207
- package/frontend-vue/app/components/Editor/GroupPortEditor.vue +29 -18
- package/frontend-vue/app/components/Editor/JsonField.vue +3 -3
- package/frontend-vue/app/components/Editor/NewProcedureDialog.vue +108 -0
- package/frontend-vue/app/components/Editor/NodeInspector.vue +382 -104
- package/frontend-vue/app/components/Editor/ProcedureSwitcher.vue +147 -0
- package/frontend-vue/app/components/Editor/RunNowDialog.vue +145 -0
- package/frontend-vue/app/components/Editor/WiredField.vue +3 -3
- package/frontend-vue/app/components/Editor/nodes/GenericNode.vue +97 -91
- package/frontend-vue/app/components/Editor/nodes/GroupNode.vue +5 -6
- package/frontend-vue/app/components/Editor/nodes/GroupSentinel.vue +3 -2
- package/frontend-vue/app/components/Editor/nodes/styles.ts +14 -18
- package/frontend-vue/app/components/Editor.vue +1894 -705
- package/frontend-vue/app/components/IconPicker.vue +122 -0
- package/frontend-vue/app/components/LiveTopics.vue +20 -0
- package/frontend-vue/app/components/Run/RunCompare.vue +115 -0
- package/frontend-vue/app/components/Run/RunFailure.vue +54 -0
- package/frontend-vue/app/components/Run/RunLogList.vue +167 -0
- package/frontend-vue/app/components/Run/RunPathTaken.vue +139 -0
- package/frontend-vue/app/components/Run/RunPayload.vue +85 -0
- package/frontend-vue/app/components/Run/RunWaterfall.vue +374 -0
- package/frontend-vue/app/components/RunPeek.vue +132 -0
- package/frontend-vue/app/components/RunTrace.vue +462 -0
- package/frontend-vue/app/components/Templates.vue +382 -537
- package/frontend-vue/app/components/WebhookEndpoint.vue +81 -0
- package/frontend-vue/app/composables/useAutomationNodeKinds.ts +23 -6
- package/frontend-vue/app/composables/useAutomationRuns.ts +160 -25
- package/frontend-vue/app/composables/useGraphConnect.ts +103 -51
- package/frontend-vue/app/composables/useRunActions.ts +60 -0
- package/frontend-vue/app/plugins/cell-displays.ts +169 -0
- package/frontend-vue/app/utils/automation.ts +4 -36
- package/frontend-vue/app/utils/describe.ts +252 -0
- package/frontend-vue/app/utils/redactedHeaders.ts +31 -0
- package/frontend-vue/dms.frontend.build.ts +7 -0
- package/frontend-vue/dms.frontend.ts +7 -4
- package/frontend-vue/i18n/locales/dms-automation-en-GB.json +1149 -309
- package/frontend-vue/i18n/locales/dms-automation-fr-FR.json +1154 -314
- package/frontend-vue/package.json +1 -1
- package/package.json +8 -5
- package/dist/db/models/type_config.model.d.ts +0 -47
- package/dist/db/models/type_config.model.js +0 -51
- package/dist/db/models/type_config.model.js.map +0 -1
- package/dist/db/tables/action_type_config.table.d.ts +0 -7
- package/dist/db/tables/action_type_config.table.js +0 -35
- package/dist/db/tables/action_type_config.table.js.map +0 -1
- package/dist/db/tables/trigger_type_config.table.d.ts +0 -7
- package/dist/db/tables/trigger_type_config.table.js.map +0 -1
- package/frontend-vue/app/components/Actions.vue +0 -151
- package/frontend-vue/app/components/Catalog/TypeConfigForm.vue +0 -166
- package/frontend-vue/app/components/Catalog/TypeList.vue +0 -198
- package/frontend-vue/app/components/DataNodes.vue +0 -272
- package/frontend-vue/app/components/Editor/ProcedureList.vue +0 -156
- package/frontend-vue/app/components/Editor/RunsDrawer.vue +0 -312
- package/frontend-vue/app/components/Library.vue +0 -69
- package/frontend-vue/app/components/Overview.vue +0 -503
- package/frontend-vue/app/components/RunDetailDrawer.vue +0 -165
- package/frontend-vue/app/components/RunFireTree.vue +0 -170
- package/frontend-vue/app/components/RunTraceDrawer.vue +0 -59
- package/frontend-vue/app/components/RunsStats.vue +0 -126
- package/frontend-vue/app/components/RunsTimelineDisplay.vue +0 -287
- package/frontend-vue/app/components/Triggers.vue +0 -147
- package/frontend-vue/app/plugins/runs-timeline-display.client.ts +0 -16
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ProcedureGraph } from "../types/graph";
|
|
2
|
+
import type { RunLog } from "../types/runLog";
|
|
3
|
+
import { type StepName } from "./describe";
|
|
4
|
+
type StepStatus = "ok" | "failed" | "running" | "truncated";
|
|
5
|
+
export interface TraceStep {
|
|
6
|
+
nodeId: string;
|
|
7
|
+
name: StepName;
|
|
8
|
+
fireId: string;
|
|
9
|
+
startMs: number;
|
|
10
|
+
durationMs: number | null;
|
|
11
|
+
status: StepStatus;
|
|
12
|
+
error?: string;
|
|
13
|
+
inputs?: unknown;
|
|
14
|
+
output?: unknown;
|
|
15
|
+
depth: number;
|
|
16
|
+
parent?: number;
|
|
17
|
+
port?: string;
|
|
18
|
+
iteration?: number;
|
|
19
|
+
branch?: string;
|
|
20
|
+
handled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
type SkipReason = "branch" | "stopped";
|
|
23
|
+
interface SkippedStep {
|
|
24
|
+
nodeId: string;
|
|
25
|
+
name: StepName;
|
|
26
|
+
reason: SkipReason;
|
|
27
|
+
}
|
|
28
|
+
export interface RunTrace {
|
|
29
|
+
steps: TraceStep[];
|
|
30
|
+
skipped: SkippedStep[];
|
|
31
|
+
edgesTaken: string[];
|
|
32
|
+
truncated?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface TraceOptions {
|
|
35
|
+
outdated?: boolean;
|
|
36
|
+
names?: Record<string, StepName>;
|
|
37
|
+
}
|
|
38
|
+
export interface TriggerSeed {
|
|
39
|
+
nodeId: string;
|
|
40
|
+
payload: unknown;
|
|
41
|
+
}
|
|
42
|
+
export declare function traceOf(graph: ProcedureGraph | undefined, log: RunLog | undefined, trigger?: TriggerSeed, options?: TraceOptions): RunTrace;
|
|
43
|
+
export declare function stepDurations(steps: readonly TraceStep[]): Record<string, number | null>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traceOf = traceOf;
|
|
4
|
+
exports.stepDurations = stepDurations;
|
|
5
|
+
const graph_1 = require("../types/graph");
|
|
6
|
+
const describe_1 = require("./describe");
|
|
7
|
+
const NOT_A_STEP = new Set(["data", "groupInput", "groupOutput"]);
|
|
8
|
+
const FLAT_ID_SEPARATOR = "__";
|
|
9
|
+
const MAIN_PORT = "main";
|
|
10
|
+
const BRANCH_MESSAGE = /^branch: (.+)$/;
|
|
11
|
+
const topLevel = (flatId) => flatId.split(FLAT_ID_SEPARATOR)[0] ?? flatId;
|
|
12
|
+
function triggerStep(log, trigger, name) {
|
|
13
|
+
return {
|
|
14
|
+
nodeId: trigger.nodeId,
|
|
15
|
+
name,
|
|
16
|
+
fireId: log?.fires.find((f) => f.parentFireId === null)?.id ?? "",
|
|
17
|
+
startMs: 0,
|
|
18
|
+
durationMs: 0,
|
|
19
|
+
status: "ok",
|
|
20
|
+
output: { type: typeof trigger.payload, value: trigger.payload },
|
|
21
|
+
depth: 0,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function valueOf(entry) {
|
|
25
|
+
return entry.value && typeof entry.value === "object"
|
|
26
|
+
? entry.value
|
|
27
|
+
: {};
|
|
28
|
+
}
|
|
29
|
+
function closeStep(step, entry, status) {
|
|
30
|
+
const value = valueOf(entry);
|
|
31
|
+
step.status = status;
|
|
32
|
+
step.durationMs = value.durationMs ?? entry.ts - step.startMs;
|
|
33
|
+
if (value.inputs !== undefined)
|
|
34
|
+
step.inputs = value.inputs;
|
|
35
|
+
if (value.output !== undefined)
|
|
36
|
+
step.output = value.output;
|
|
37
|
+
if (status === "failed")
|
|
38
|
+
step.error = entry.message;
|
|
39
|
+
const output = step.output
|
|
40
|
+
?.value;
|
|
41
|
+
if (status === "ok" && step.name.kind === "retry" && output?.error) {
|
|
42
|
+
step.branch = "exhausted";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function depthOf(fires, fireId) {
|
|
46
|
+
let depth = 0;
|
|
47
|
+
let fire = fires.get(fireId);
|
|
48
|
+
while (fire?.parentFireId) {
|
|
49
|
+
depth += 1;
|
|
50
|
+
fire = fires.get(fire.parentFireId);
|
|
51
|
+
}
|
|
52
|
+
return depth;
|
|
53
|
+
}
|
|
54
|
+
function traceOf(graph, log, trigger, options = {}) {
|
|
55
|
+
const name = namer(graph, options);
|
|
56
|
+
const steps = trigger
|
|
57
|
+
? [triggerStep(log, trigger, name(trigger.nodeId, "trigger"))]
|
|
58
|
+
: [];
|
|
59
|
+
readSteps(log, steps, name);
|
|
60
|
+
if (log?.truncated)
|
|
61
|
+
markCut(steps);
|
|
62
|
+
markHandled(steps);
|
|
63
|
+
const shape = options.outdated ? undefined : graph;
|
|
64
|
+
const trace = {
|
|
65
|
+
steps,
|
|
66
|
+
skipped: log?.truncated ? [] : skippedSteps(shape, steps, name),
|
|
67
|
+
edgesTaken: shape ? edgesTaken(shape, steps, log) : [],
|
|
68
|
+
};
|
|
69
|
+
if (log?.truncated)
|
|
70
|
+
trace.truncated = log.truncated;
|
|
71
|
+
return trace;
|
|
72
|
+
}
|
|
73
|
+
function readSteps(log, steps, name) {
|
|
74
|
+
const fires = new Map((log?.fires ?? []).map((f) => [f.id, f]));
|
|
75
|
+
const open = new Map();
|
|
76
|
+
for (const entry of log?.entries ?? []) {
|
|
77
|
+
if (!entry.nodeId)
|
|
78
|
+
continue;
|
|
79
|
+
if (entry.nodeKind && NOT_A_STEP.has(entry.nodeKind))
|
|
80
|
+
continue;
|
|
81
|
+
const key = `${entry.fireId}#${entry.nodeId}`;
|
|
82
|
+
if (entry.source === "log") {
|
|
83
|
+
const branch = BRANCH_MESSAGE.exec(entry.message)?.[1];
|
|
84
|
+
const index = open.get(key);
|
|
85
|
+
if (branch && index !== undefined)
|
|
86
|
+
steps[index].branch = branch;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (entry.message === "executing") {
|
|
90
|
+
open.set(key, steps.push(openStep(entry, fires, open, name)) - 1);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const index = open.get(key);
|
|
94
|
+
if (index === undefined)
|
|
95
|
+
continue;
|
|
96
|
+
if (entry.message === "executed")
|
|
97
|
+
closeStep(steps[index], entry, "ok");
|
|
98
|
+
else if (entry.level === "error") {
|
|
99
|
+
closeStep(steps[index], entry, "failed");
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
continue;
|
|
103
|
+
open.delete(key);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function openStep(entry, fires, open, name) {
|
|
107
|
+
const nodeId = entry.nodeId;
|
|
108
|
+
const step = {
|
|
109
|
+
nodeId,
|
|
110
|
+
name: name(nodeId, entry.nodeKind),
|
|
111
|
+
fireId: entry.fireId,
|
|
112
|
+
startMs: entry.ts,
|
|
113
|
+
durationMs: null,
|
|
114
|
+
status: "running",
|
|
115
|
+
depth: depthOf(fires, entry.fireId),
|
|
116
|
+
};
|
|
117
|
+
const fire = fires.get(entry.fireId);
|
|
118
|
+
if (fire?.parentFireId) {
|
|
119
|
+
const parent = open.get(`${fire.parentFireId}#${fire.sourceNodeId}`);
|
|
120
|
+
if (parent !== undefined)
|
|
121
|
+
step.parent = parent;
|
|
122
|
+
if (fire.port)
|
|
123
|
+
step.port = fire.port;
|
|
124
|
+
if (fire.iteration !== undefined)
|
|
125
|
+
step.iteration = fire.iteration;
|
|
126
|
+
}
|
|
127
|
+
return step;
|
|
128
|
+
}
|
|
129
|
+
function namer(graph, options) {
|
|
130
|
+
const fromGraph = (id) => {
|
|
131
|
+
const found = graph ? (0, describe_1.stepName)(graph, id) : undefined;
|
|
132
|
+
return found?.kind ? found : undefined;
|
|
133
|
+
};
|
|
134
|
+
const fromRun = (id) => options.names?.[id];
|
|
135
|
+
const sources = options.outdated
|
|
136
|
+
? [fromRun, fromGraph]
|
|
137
|
+
: [fromGraph, fromRun];
|
|
138
|
+
return (id, kind) => {
|
|
139
|
+
for (const source of sources) {
|
|
140
|
+
const found = source(id);
|
|
141
|
+
if (found)
|
|
142
|
+
return found;
|
|
143
|
+
}
|
|
144
|
+
return kind ? { nodeId: id, kind } : { nodeId: id };
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function markCut(steps) {
|
|
148
|
+
for (const step of steps)
|
|
149
|
+
if (step.status === "running")
|
|
150
|
+
step.status = "truncated";
|
|
151
|
+
}
|
|
152
|
+
function markHandled(steps) {
|
|
153
|
+
for (const step of steps) {
|
|
154
|
+
if (step.status !== "failed")
|
|
155
|
+
continue;
|
|
156
|
+
let parent = step.parent;
|
|
157
|
+
while (parent !== undefined) {
|
|
158
|
+
if (steps[parent].status === "ok") {
|
|
159
|
+
step.handled = true;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
parent = steps[parent].parent;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function skippedSteps(graph, steps, name) {
|
|
167
|
+
if (!graph)
|
|
168
|
+
return [];
|
|
169
|
+
const reached = new Set(steps.map((s) => topLevel(s.nodeId)));
|
|
170
|
+
const stopped = downstreamOf(graph, steps
|
|
171
|
+
.filter((s) => s.status === "failed" && !s.handled)
|
|
172
|
+
.map((s) => topLevel(s.nodeId)));
|
|
173
|
+
const skipped = graph.nodes
|
|
174
|
+
.filter((n) => !NOT_A_STEP.has(n.kind) && n.kind !== "trigger")
|
|
175
|
+
.filter((n) => !reached.has(n.id))
|
|
176
|
+
.map((n) => ({
|
|
177
|
+
nodeId: n.id,
|
|
178
|
+
name: name(n.id),
|
|
179
|
+
reason: stopped.has(n.id) ? "stopped" : "branch",
|
|
180
|
+
}));
|
|
181
|
+
return [
|
|
182
|
+
...skipped.filter((s) => s.reason === "stopped"),
|
|
183
|
+
...skipped.filter((s) => s.reason === "branch"),
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
function downstreamOf(graph, from) {
|
|
187
|
+
const seen = new Set();
|
|
188
|
+
const queue = [...from];
|
|
189
|
+
while (queue.length) {
|
|
190
|
+
const id = queue.shift();
|
|
191
|
+
for (const edge of graph.triggerEdges) {
|
|
192
|
+
if (edge.from.node !== id || seen.has(edge.to.node))
|
|
193
|
+
continue;
|
|
194
|
+
seen.add(edge.to.node);
|
|
195
|
+
queue.push(edge.to.node);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return seen;
|
|
199
|
+
}
|
|
200
|
+
function edgesTaken(graph, steps, log) {
|
|
201
|
+
const ran = new Set(steps.map((s) => topLevel(s.nodeId)));
|
|
202
|
+
const left = new Map();
|
|
203
|
+
const leave = (nodeId, port) => {
|
|
204
|
+
if (nodeId.includes(FLAT_ID_SEPARATOR))
|
|
205
|
+
return;
|
|
206
|
+
const ports = left.get(nodeId) ?? new Set();
|
|
207
|
+
ports.add(port);
|
|
208
|
+
left.set(nodeId, ports);
|
|
209
|
+
};
|
|
210
|
+
for (const fire of log?.fires ?? []) {
|
|
211
|
+
if (fire.parentFireId && fire.port)
|
|
212
|
+
leave(fire.sourceNodeId, fire.port);
|
|
213
|
+
}
|
|
214
|
+
for (const step of steps) {
|
|
215
|
+
if (step.status === "ok")
|
|
216
|
+
leave(step.nodeId, step.branch ?? MAIN_PORT);
|
|
217
|
+
}
|
|
218
|
+
const groups = new Set(graph.nodes.filter(graph_1.isGroupNode).map((n) => n.id));
|
|
219
|
+
return graph.triggerEdges
|
|
220
|
+
.filter((edge) => {
|
|
221
|
+
if (!ran.has(edge.to.node))
|
|
222
|
+
return false;
|
|
223
|
+
if (groups.has(edge.from.node))
|
|
224
|
+
return ran.has(edge.from.node);
|
|
225
|
+
return left.get(edge.from.node)?.has(edge.from.branch ?? MAIN_PORT);
|
|
226
|
+
})
|
|
227
|
+
.map((edge) => edge.id);
|
|
228
|
+
}
|
|
229
|
+
function stepDurations(steps) {
|
|
230
|
+
const durations = {};
|
|
231
|
+
for (const step of steps) {
|
|
232
|
+
const before = durations[step.nodeId];
|
|
233
|
+
durations[step.nodeId] =
|
|
234
|
+
step.durationMs === null
|
|
235
|
+
? (before ?? null)
|
|
236
|
+
: (before ?? 0) + step.durationMs;
|
|
237
|
+
}
|
|
238
|
+
return durations;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/runtime/trace.ts"],"names":[],"mappings":";;AA2JA,0BAuBC;AA4LD,sCAYC;AA1XD,0CAAkE;AAElE,yCAAqD;AAgFrD,MAAM,UAAU,G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,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YACpB,IAAI,CAAC,UAAU,KAAK,IAAI;gBACtB,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC;gBAClB,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;IACxC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refreshTypeSwitches = refreshTypeSwitches;
|
|
4
|
+
exports.isTriggerTypeDisabled = isTriggerTypeDisabled;
|
|
5
|
+
exports.isActionTypeDisabled = isActionTypeDisabled;
|
|
6
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
7
|
+
const type_switch_model_1 = require("../db/models/type_switch.model");
|
|
8
|
+
const constants_1 = require("../types/constants");
|
|
9
|
+
const disabled = {
|
|
10
|
+
triggers: new Set(),
|
|
11
|
+
actions: new Set(),
|
|
12
|
+
};
|
|
13
|
+
function disabledIds(rows, kind) {
|
|
14
|
+
return new Set(rows.filter((r) => r.kind === kind && !r.enabled).map((r) => r.typeId));
|
|
15
|
+
}
|
|
16
|
+
async function refreshTypeSwitches() {
|
|
17
|
+
const rows = await (0, interface_database_decorators_1.GetModel)(type_switch_model_1.TypeSwitchModel, constants_1.DATABASE_NAME).getAll();
|
|
18
|
+
disabled.triggers = disabledIds(rows, "trigger");
|
|
19
|
+
disabled.actions = disabledIds(rows, "action");
|
|
20
|
+
}
|
|
21
|
+
function isTriggerTypeDisabled(typeId) {
|
|
22
|
+
return disabled.triggers.has(typeId);
|
|
23
|
+
}
|
|
24
|
+
function isActionTypeDisabled(typeId) {
|
|
25
|
+
return disabled.actions.has(typeId);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=typeSwitches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeSwitches.js","sourceRoot":"","sources":["../../src/runtime/typeSwitches.ts"],"names":[],"mappings":";;AA4BA,kDAIC;AAED,sDAEC;AAED,oDAEC;AAxCD,6FAAqE;AACrE,sEAAiE;AAKjE,kDAAmD;AAQnD,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,IAAI,GAAG,EAAU;IAC3B,OAAO,EAAE,IAAI,GAAG,EAAU;CAC3B,CAAC;AAEF,SAAS,WAAW,CAClB,IAA2B,EAC3B,IAAoB;IAEpB,OAAO,IAAI,GAAG,CACZ,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CACvE,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,mBAAmB;IACvC,MAAM,IAAI,GAAG,MAAM,IAAA,wCAAQ,EAAC,mCAAe,EAAE,yBAAa,CAAC,CAAC,MAAM,EAAE,CAAC;IACrE,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACjD,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,SAAgB,qBAAqB,CAAC,MAAc;IAClD,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAc;IACjD,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -7,4 +7,15 @@ export type ValidateResult = {
|
|
|
7
7
|
errors: string[];
|
|
8
8
|
warnings: string[];
|
|
9
9
|
};
|
|
10
|
+
export type ProblemParams = Record<string, string | number>;
|
|
11
|
+
export interface GraphProblem {
|
|
12
|
+
severity: "error" | "warning";
|
|
13
|
+
code: string;
|
|
14
|
+
params: ProblemParams;
|
|
15
|
+
message: string;
|
|
16
|
+
nodeId?: string;
|
|
17
|
+
}
|
|
18
|
+
export type ConfigProblem = Pick<GraphProblem, "code" | "params" | "message">;
|
|
19
|
+
export declare const MAX_GROUP_DEPTH = 20;
|
|
20
|
+
export declare function graphProblems(graph: ProcedureGraph, depth?: number): GraphProblem[];
|
|
10
21
|
export declare function validateGraph(graph: ProcedureGraph): ValidateResult;
|
package/dist/runtime/validate.js
CHANGED
|
@@ -1,28 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_GROUP_DEPTH = void 0;
|
|
4
|
+
exports.graphProblems = graphProblems;
|
|
3
5
|
exports.validateGraph = validateGraph;
|
|
4
6
|
const graph_1 = require("../types/graph");
|
|
5
7
|
const nodeKinds_1 = require("./nodeKinds");
|
|
6
8
|
const topo_1 = require("./topo");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
exports.MAX_GROUP_DEPTH = 20;
|
|
10
|
+
class Problems {
|
|
11
|
+
list = [];
|
|
12
|
+
error(code, params, message, nodeId) {
|
|
13
|
+
this.add("error", code, params, message, nodeId);
|
|
14
|
+
}
|
|
15
|
+
warning(code, params, message, nodeId) {
|
|
16
|
+
this.add("warning", code, params, message, nodeId);
|
|
17
|
+
}
|
|
18
|
+
get hasError() {
|
|
19
|
+
return this.list.some((p) => p.severity === "error");
|
|
20
|
+
}
|
|
21
|
+
add(severity, code, params, message, nodeId) {
|
|
22
|
+
const problem = { severity, code, params, message };
|
|
23
|
+
if (nodeId !== undefined)
|
|
24
|
+
problem.nodeId = nodeId;
|
|
25
|
+
this.list.push(problem);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const quotedList = (ids) => ids.map((id) => `"${id}"`).join(", ");
|
|
29
|
+
function checkDuplicateNodeIds(graph, problems) {
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
const reported = new Set();
|
|
32
|
+
for (const n of graph.nodes) {
|
|
33
|
+
if (seen.has(n.id) && !reported.has(n.id)) {
|
|
34
|
+
reported.add(n.id);
|
|
35
|
+
problems.error("duplicateNodeId", { node: n.id }, `two nodes share the id "${n.id}"`, n.id);
|
|
14
36
|
}
|
|
37
|
+
seen.add(n.id);
|
|
15
38
|
}
|
|
16
|
-
|
|
39
|
+
}
|
|
40
|
+
function checkUnknownNodeRefs(graph, nodeById, problems) {
|
|
41
|
+
const edges = [
|
|
42
|
+
...graph.triggerEdges.map((e) => ({ kind: "trigger", e })),
|
|
43
|
+
...graph.dataEdges.map((e) => ({ kind: "data", e })),
|
|
44
|
+
];
|
|
45
|
+
for (const { kind, e } of edges) {
|
|
17
46
|
if (!nodeById.has(e.from.node)) {
|
|
18
|
-
|
|
47
|
+
problems.error("edgeUnknownSource", { edge: e.id, node: e.from.node }, `${kind} edge ${e.id}: unknown source node "${e.from.node}"`, nodeById.has(e.to.node) ? e.to.node : undefined);
|
|
19
48
|
}
|
|
20
49
|
if (!nodeById.has(e.to.node)) {
|
|
21
|
-
|
|
50
|
+
problems.error("edgeUnknownTarget", { edge: e.id, node: e.to.node }, `${kind} edge ${e.id}: unknown target node "${e.to.node}"`, nodeById.has(e.from.node) ? e.from.node : undefined);
|
|
22
51
|
}
|
|
23
52
|
}
|
|
24
53
|
}
|
|
25
|
-
function checkTriggerDivergence(graph, nodeById,
|
|
54
|
+
function checkTriggerDivergence(graph, nodeById, problems) {
|
|
26
55
|
const outgoingBySource = new Map();
|
|
27
56
|
for (const e of graph.triggerEdges) {
|
|
28
57
|
outgoingBySource.set(e.from.node, (outgoingBySource.get(e.from.node) ?? 0) + 1);
|
|
@@ -36,7 +65,7 @@ function checkTriggerDivergence(graph, nodeById, errors) {
|
|
|
36
65
|
const allowedByRegistry = nodeKinds_1.nodeKinds.mayDiverge(src.kind);
|
|
37
66
|
const allowedByGroup = src.kind === "group" || src.kind === "groupInput";
|
|
38
67
|
if (!allowedByRegistry && !allowedByGroup) {
|
|
39
|
-
|
|
68
|
+
problems.error("triggerDiverges", { node: sourceId, count }, `trigger source cannot diverge: node "${sourceId}" (${src.kind}) has ${count} outgoing trigger edges`, sourceId);
|
|
40
69
|
}
|
|
41
70
|
}
|
|
42
71
|
const ifBranches = new Set(nodeKinds_1.nodeKinds.metaOf("if")?.sidePorts ?? []);
|
|
@@ -46,77 +75,103 @@ function checkTriggerDivergence(graph, nodeById, errors) {
|
|
|
46
75
|
continue;
|
|
47
76
|
if (src.kind === "if" && e.from.branch !== undefined) {
|
|
48
77
|
if (!ifBranches.has(e.from.branch)) {
|
|
49
|
-
|
|
78
|
+
problems.error("ifBranchInvalid", { edge: e.id, branch: e.from.branch }, `trigger edge ${e.id}: if-branch must be one of ${[...ifBranches].map((b) => `"${b}"`).join(" / ")} (got "${e.from.branch}")`, src.id);
|
|
50
79
|
}
|
|
51
80
|
}
|
|
52
81
|
}
|
|
53
82
|
}
|
|
54
|
-
function checkTriggerNodesAreEntryPoints(graph, nodeById,
|
|
83
|
+
function checkTriggerNodesAreEntryPoints(graph, nodeById, problems) {
|
|
55
84
|
for (const e of graph.triggerEdges) {
|
|
56
85
|
const target = nodeById.get(e.to.node);
|
|
57
86
|
if (target?.kind !== "trigger")
|
|
58
87
|
continue;
|
|
59
|
-
|
|
88
|
+
problems.error("triggerTargeted", { edge: e.id, node: target.id }, `trigger edge ${e.id}: node "${target.id}" is a trigger and cannot be the target of a trigger edge (triggers are entry points)`, target.id);
|
|
60
89
|
}
|
|
61
90
|
}
|
|
62
|
-
function checkDataFanIn(graph,
|
|
91
|
+
function checkDataFanIn(graph, problems) {
|
|
63
92
|
const dataTargets = new Map();
|
|
64
93
|
for (const e of graph.dataEdges) {
|
|
65
94
|
const key = `${e.to.node}::${e.to.field}`;
|
|
66
|
-
dataTargets.set(key, (dataTargets.get(key) ??
|
|
95
|
+
dataTargets.set(key, [...(dataTargets.get(key) ?? []), e.to]);
|
|
67
96
|
}
|
|
68
|
-
for (const [key,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
97
|
+
for (const [key, targets] of dataTargets) {
|
|
98
|
+
const target = targets[0];
|
|
99
|
+
if (targets.length < 2 || !target)
|
|
100
|
+
continue;
|
|
101
|
+
problems.error("dataFanIn", { node: target.node, field: target.field }, `data field has more than one source: ${key}`, target.node);
|
|
72
102
|
}
|
|
73
103
|
}
|
|
74
|
-
function checkTriggerCycles(graph,
|
|
75
|
-
if (graph.triggerEdges.length === 0 ||
|
|
104
|
+
function checkTriggerCycles(graph, problems) {
|
|
105
|
+
if (graph.triggerEdges.length === 0 || problems.hasError)
|
|
76
106
|
return;
|
|
77
107
|
const allReferencedNodes = new Set();
|
|
78
108
|
for (const e of graph.triggerEdges) {
|
|
79
109
|
allReferencedNodes.add(e.from.node);
|
|
80
110
|
allReferencedNodes.add(e.to.node);
|
|
81
111
|
}
|
|
82
|
-
if ((0, topo_1.kahn)(graph, allReferencedNodes)
|
|
83
|
-
|
|
84
|
-
|
|
112
|
+
if ((0, topo_1.kahn)(graph, allReferencedNodes) !== null)
|
|
113
|
+
return;
|
|
114
|
+
const nodes = (0, topo_1.cycleMembers)(allReferencedNodes, graph.triggerEdges.map((e) => [e.from.node, e.to.node]));
|
|
115
|
+
problems.error("triggerCycle", { nodes: nodes.join(", ") }, `cycle detected in trigger edges: ${quotedList(nodes)}`, nodes[0]);
|
|
85
116
|
}
|
|
86
|
-
function
|
|
87
|
-
const
|
|
88
|
-
const
|
|
117
|
+
function checkDataCycles(graph, nodeById, problems) {
|
|
118
|
+
const isData = (id) => nodeById.get(id)?.kind === "data";
|
|
119
|
+
const edges = graph.dataEdges
|
|
120
|
+
.filter((e) => isData(e.from.node) && isData(e.to.node))
|
|
121
|
+
.map((e) => [e.from.node, e.to.node]);
|
|
122
|
+
if (edges.length === 0)
|
|
123
|
+
return;
|
|
124
|
+
const nodes = (0, topo_1.cycleMembers)(edges.flatMap(([from, to]) => [from, to]), edges);
|
|
125
|
+
if (nodes.length === 0)
|
|
126
|
+
return;
|
|
127
|
+
problems.error("dataCycle", { nodes: nodes.join(", ") }, `cycle detected in data edges: ${quotedList(nodes)}`, nodes[0]);
|
|
128
|
+
}
|
|
129
|
+
function graphProblems(graph, depth = 0) {
|
|
130
|
+
const problems = new Problems();
|
|
89
131
|
const nodeById = new Map();
|
|
90
132
|
for (const n of graph.nodes)
|
|
91
133
|
nodeById.set(n.id, n);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
134
|
+
checkDuplicateNodeIds(graph, problems);
|
|
135
|
+
checkUnknownNodeRefs(graph, nodeById, problems);
|
|
136
|
+
checkTriggerDivergence(graph, nodeById, problems);
|
|
137
|
+
checkTriggerNodesAreEntryPoints(graph, nodeById, problems);
|
|
138
|
+
checkDataFanIn(graph, problems);
|
|
139
|
+
checkTriggerCycles(graph, problems);
|
|
140
|
+
checkDataCycles(graph, nodeById, problems);
|
|
97
141
|
for (const node of graph.nodes) {
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
142
|
+
if (depth > 0 && node.kind === "trigger") {
|
|
143
|
+
problems.error("nestedTrigger", { node: node.id }, `node "${node.id}" is a trigger inside a group (triggers must live at the top level)`, node.id);
|
|
144
|
+
}
|
|
145
|
+
if ((0, graph_1.isGroupNode)(node))
|
|
146
|
+
validateGroupNode(node, depth, problems);
|
|
101
147
|
}
|
|
148
|
+
return problems.list;
|
|
149
|
+
}
|
|
150
|
+
function validateGraph(graph) {
|
|
151
|
+
const problems = graphProblems(graph);
|
|
152
|
+
const messagesOf = (severity) => problems.filter((p) => p.severity === severity).map((p) => p.message);
|
|
153
|
+
const errors = messagesOf("error");
|
|
154
|
+
const warnings = messagesOf("warning");
|
|
102
155
|
return errors.length === 0
|
|
103
156
|
? { ok: true, warnings }
|
|
104
157
|
: { ok: false, errors, warnings };
|
|
105
158
|
}
|
|
106
|
-
function validateGroupBodySource(node,
|
|
159
|
+
function validateGroupBodySource(node, problems) {
|
|
160
|
+
const id = node.id;
|
|
107
161
|
const hasTemplate = node.templateId !== undefined;
|
|
108
162
|
const hasSubgraph = node.subgraph !== undefined;
|
|
109
163
|
if (hasTemplate && hasSubgraph) {
|
|
110
|
-
|
|
164
|
+
problems.error("groupBodyBoth", { group: id }, `group "${id}": exactly one of templateId / subgraph must be set (both are set)`, id);
|
|
111
165
|
return false;
|
|
112
166
|
}
|
|
113
167
|
if (!hasTemplate && !hasSubgraph) {
|
|
114
|
-
|
|
168
|
+
problems.error("groupBodyNone", { group: id }, `group "${id}": exactly one of templateId / subgraph must be set (neither is set)`, id);
|
|
115
169
|
return false;
|
|
116
170
|
}
|
|
117
171
|
return true;
|
|
118
172
|
}
|
|
119
|
-
function validateGroupPortNames(node,
|
|
173
|
+
function validateGroupPortNames(node, problems) {
|
|
174
|
+
const id = node.id;
|
|
120
175
|
const portSeen = new Map();
|
|
121
176
|
for (const p of node.ports) {
|
|
122
177
|
const key = `${p.kind}/${p.direction}/${p.name}`;
|
|
@@ -124,62 +179,64 @@ function validateGroupPortNames(node, id, errors) {
|
|
|
124
179
|
}
|
|
125
180
|
for (const [key, count] of portSeen) {
|
|
126
181
|
if (count > 1) {
|
|
127
|
-
|
|
182
|
+
problems.error("groupDuplicatePort", { group: id, port: key }, `group "${id}": duplicate port (${key}) — port names must be unique within a direction+kind`, id);
|
|
128
183
|
}
|
|
129
184
|
}
|
|
130
185
|
}
|
|
131
|
-
function validateGroupSentinels(subgraph, id,
|
|
186
|
+
function validateGroupSentinels(subgraph, id, problems) {
|
|
132
187
|
const groupInputs = subgraph.nodes.filter((n) => n.kind === "groupInput");
|
|
133
188
|
const groupOutputs = subgraph.nodes.filter((n) => n.kind === "groupOutput");
|
|
134
189
|
if (groupInputs.length !== 1) {
|
|
135
|
-
|
|
190
|
+
problems.error("groupInputCount", { group: id, count: groupInputs.length }, `group "${id}": subgraph must contain exactly one groupInput node (found ${groupInputs.length})`, id);
|
|
136
191
|
}
|
|
137
192
|
if (groupOutputs.length !== 1) {
|
|
138
|
-
|
|
193
|
+
problems.error("groupOutputCount", { group: id, count: groupOutputs.length }, `group "${id}": subgraph must contain exactly one groupOutput node (found ${groupOutputs.length})`, id);
|
|
139
194
|
}
|
|
140
195
|
return {
|
|
141
196
|
groupInputCount: groupInputs.length,
|
|
142
197
|
groupOutputId: groupOutputs.length === 1 ? groupOutputs[0].id : undefined,
|
|
143
198
|
};
|
|
144
199
|
}
|
|
145
|
-
function validateGroupDataOutWiring(node, subgraph, groupOutputId,
|
|
200
|
+
function validateGroupDataOutWiring(node, subgraph, groupOutputId, problems) {
|
|
146
201
|
const id = node.id;
|
|
147
202
|
for (const p of node.ports) {
|
|
148
203
|
if (p.kind !== "data" || p.direction !== "out")
|
|
149
204
|
continue;
|
|
150
205
|
const incoming = subgraph.dataEdges.filter((e) => e.to.node === groupOutputId && e.to.field === p.name);
|
|
151
206
|
if (incoming.length === 0) {
|
|
152
|
-
|
|
207
|
+
problems.warning("groupOutputUnwired", { group: id, port: p.name }, `group "${id}": data-out port "${p.name}" has no incoming data edge to groupOutput`, id);
|
|
153
208
|
}
|
|
154
209
|
else if (incoming.length > 1) {
|
|
155
|
-
|
|
210
|
+
problems.error("groupOutputMultiple", { group: id, port: p.name, count: incoming.length }, `group "${id}": data-out port "${p.name}" has ${incoming.length} incoming data edges to groupOutput (expected exactly one)`, id);
|
|
156
211
|
}
|
|
157
212
|
}
|
|
158
213
|
}
|
|
159
|
-
function validateGroupNode(node,
|
|
214
|
+
function validateGroupNode(node, depth, problems) {
|
|
160
215
|
const id = node.id;
|
|
161
|
-
if (!validateGroupBodySource(node,
|
|
216
|
+
if (!validateGroupBodySource(node, problems))
|
|
162
217
|
return;
|
|
163
|
-
validateGroupPortNames(node,
|
|
218
|
+
validateGroupPortNames(node, problems);
|
|
164
219
|
const hasTriggerIn = node.ports.some((p) => p.kind === "trigger" && p.direction === "in");
|
|
165
220
|
if (!hasTriggerIn) {
|
|
166
|
-
|
|
221
|
+
problems.error("groupNoTriggerIn", { group: id }, `group "${id}": must declare at least one trigger-input port (otherwise the group can never start)`, id);
|
|
167
222
|
}
|
|
168
223
|
const subgraph = node.subgraph;
|
|
169
224
|
if (node.templateId !== undefined || !subgraph)
|
|
170
225
|
return;
|
|
171
|
-
const { groupInputCount, groupOutputId } = validateGroupSentinels(subgraph, id,
|
|
226
|
+
const { groupInputCount, groupOutputId } = validateGroupSentinels(subgraph, id, problems);
|
|
172
227
|
if (groupInputCount === 1 && groupOutputId !== undefined) {
|
|
173
|
-
validateGroupDataOutWiring(node, subgraph, groupOutputId,
|
|
228
|
+
validateGroupDataOutWiring(node, subgraph, groupOutputId, problems);
|
|
174
229
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
errors.push(`group:${id} > ${e}`);
|
|
179
|
-
}
|
|
230
|
+
if (depth + 1 > exports.MAX_GROUP_DEPTH) {
|
|
231
|
+
problems.error("groupTooDeep", { group: id, max: exports.MAX_GROUP_DEPTH }, `group "${id}": groups are nested more than ${exports.MAX_GROUP_DEPTH} levels deep`, id);
|
|
232
|
+
return;
|
|
180
233
|
}
|
|
181
|
-
for (const
|
|
182
|
-
|
|
234
|
+
for (const inner of graphProblems(subgraph, depth + 1)) {
|
|
235
|
+
problems.list.push({
|
|
236
|
+
...inner,
|
|
237
|
+
message: `group:${id} > ${inner.message}`,
|
|
238
|
+
nodeId: id,
|
|
239
|
+
});
|
|
183
240
|
}
|
|
184
241
|
}
|
|
185
242
|
//# sourceMappingURL=validate.js.map
|