@antelopejs/dms-automation 0.2.7 → 0.3.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/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 +111 -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 +101 -45
- package/frontend-vue/app/components/Editor/GraphCanvas.vue +818 -206
- 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 +373 -101
- 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 -6
- 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 -170
- package/frontend-vue/app/components/Catalog/TypeList.vue +0 -203
- package/frontend-vue/app/components/DataNodes.vue +0 -275
- 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
|
@@ -3,12 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.cronTrigger = void 0;
|
|
6
|
+
exports.cronTrigger = exports.DEFAULT_SCHEDULE = void 0;
|
|
7
|
+
exports.cronProblem = cronProblem;
|
|
7
8
|
const node_cron_1 = __importDefault(require("node-cron"));
|
|
9
|
+
const armErrors_1 = require("../../armErrors");
|
|
10
|
+
exports.DEFAULT_SCHEDULE = "0 9 * * 1";
|
|
11
|
+
function cronProblem(expression) {
|
|
12
|
+
if (typeof expression === "string" && node_cron_1.default.validate(expression)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const value = typeof expression === "string" ? expression : "";
|
|
16
|
+
return {
|
|
17
|
+
code: "cronInvalid",
|
|
18
|
+
params: { cron: value },
|
|
19
|
+
message: `invalid cron expression: "${value}"`,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
8
22
|
exports.cronTrigger = {
|
|
9
23
|
id: "schedule.cron",
|
|
10
|
-
name: "
|
|
11
|
-
description: "
|
|
24
|
+
name: "$dms_automation.types.cron.name",
|
|
25
|
+
description: "$dms_automation.types.cron.description",
|
|
12
26
|
icon: "i-ph-clock",
|
|
13
27
|
cluster: "singleton",
|
|
14
28
|
configSchema: {
|
|
@@ -18,7 +32,7 @@ exports.cronTrigger = {
|
|
|
18
32
|
type: "string",
|
|
19
33
|
title: "Schedule (cron expression)",
|
|
20
34
|
description: "Standard cron syntax, e.g. `*/5 * * * *` (every 5 minutes) or `0 9 * * 1` (Mondays at 09:00).",
|
|
21
|
-
default:
|
|
35
|
+
default: exports.DEFAULT_SCHEDULE,
|
|
22
36
|
},
|
|
23
37
|
},
|
|
24
38
|
required: ["cron"],
|
|
@@ -31,9 +45,9 @@ exports.cronTrigger = {
|
|
|
31
45
|
},
|
|
32
46
|
},
|
|
33
47
|
async activate(config, emit) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
const problem = cronProblem(config.cron);
|
|
49
|
+
if (problem)
|
|
50
|
+
throw new armErrors_1.TriggerArmError(problem);
|
|
37
51
|
const task = node_cron_1.default.schedule(config.cron, () => {
|
|
38
52
|
emit({ firedAt: new Date().toISOString() });
|
|
39
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../../../src/runtime/builtins/triggers/cron.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../../../src/runtime/builtins/triggers/cron.ts"],"names":[],"mappings":";;;;;;AAiBA,kCAUC;AA1BD,0DAAqD;AACrD,+CAAkD;AAIrC,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAW5C,SAAgB,WAAW,CAAC,UAAmB;IAC7C,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,mBAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAChE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;QACvB,OAAO,EAAE,6BAA6B,KAAK,GAAG;KAC/C,CAAC;AACJ,CAAC;AAEY,QAAA,WAAW,GAAwC;IAC9D,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,iCAAiC;IACvC,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,4BAA4B;gBACnC,WAAW,EACT,+FAA+F;gBACjG,OAAO,EAAE,wBAAgB;aAC1B;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;QAClB,oBAAoB,EAAE,KAAK;KAC5B;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE;SACjD;KACF;IACD,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI;QACzB,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,OAAO;YAAE,MAAM,IAAI,2BAAe,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YAC3C,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,MAAM;QACrB,MAAM,IAAI,GAAG,MAAmC,CAAC;QACjD,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACvC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -4,8 +4,8 @@ exports.manualTrigger = exports.MANUAL_TRIGGER_ID = void 0;
|
|
|
4
4
|
exports.MANUAL_TRIGGER_ID = "manual";
|
|
5
5
|
exports.manualTrigger = {
|
|
6
6
|
id: exports.MANUAL_TRIGGER_ID,
|
|
7
|
-
name: "
|
|
8
|
-
description: "
|
|
7
|
+
name: "$dms_automation.types.manual.name",
|
|
8
|
+
description: "$dms_automation.types.manual.description",
|
|
9
9
|
icon: "i-ph-play",
|
|
10
10
|
cluster: "replicated",
|
|
11
11
|
configSchema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual.js","sourceRoot":"","sources":["../../../../src/runtime/builtins/triggers/manual.ts"],"names":[],"mappings":";;;AAGa,QAAA,iBAAiB,GAAG,QAAQ,CAAC;AAO7B,QAAA,aAAa,GAAgB;IACxC,EAAE,EAAE,yBAAiB;IACrB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"manual.js","sourceRoot":"","sources":["../../../../src/runtime/builtins/triggers/manual.ts"],"names":[],"mappings":";;;AAGa,QAAA,iBAAiB,GAAG,QAAQ,CAAC;AAO7B,QAAA,aAAa,GAAgB;IACxC,EAAE,EAAE,yBAAiB;IACrB,IAAI,EAAE,mCAAmC;IACzC,WAAW,EAAE,0CAA0C;IACvD,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,YAAY;IACrB,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;QACd,oBAAoB,EAAE,KAAK;KAC5B;IACD,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IAC1B,UAAU,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;CAC3B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TriggerType } from "@antelopejs/interface-dms-automation";
|
|
2
|
+
import type { ConfigProblem } from "../../validate";
|
|
2
3
|
interface WebhookConfig {
|
|
3
4
|
path: string;
|
|
4
5
|
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
@@ -6,9 +7,21 @@ interface WebhookConfig {
|
|
|
6
7
|
interface WebhookOutput {
|
|
7
8
|
method: string;
|
|
8
9
|
headers: Record<string, string | string[] | undefined>;
|
|
9
|
-
query: Record<string, string>;
|
|
10
|
+
query: Record<string, string | string[]>;
|
|
10
11
|
body: unknown;
|
|
11
12
|
params: Record<string, string>;
|
|
12
13
|
}
|
|
14
|
+
export declare function webhookPathProblem(path: unknown): ConfigProblem | undefined;
|
|
15
|
+
export declare function webhookRouteOf(config: Record<string, unknown> | undefined): {
|
|
16
|
+
method: string;
|
|
17
|
+
path: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function webhookRouteConflict(method: string, path: string, ownRouteIds?: ReadonlySet<string>): ConfigProblem | undefined;
|
|
20
|
+
export interface ArmedWebhook {
|
|
21
|
+
config: Record<string, unknown>;
|
|
22
|
+
procedure: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function namedRouteConflict(problem: ConfigProblem, config: Record<string, unknown>, armed: Iterable<ArmedWebhook>): ConfigProblem;
|
|
25
|
+
export declare function armedWebhookRouteIds(): ReadonlySet<string>;
|
|
13
26
|
export declare const webhookTrigger: TriggerType<WebhookConfig, WebhookOutput>;
|
|
14
27
|
export {};
|
|
@@ -1,11 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webhookTrigger = void 0;
|
|
4
|
+
exports.webhookPathProblem = webhookPathProblem;
|
|
5
|
+
exports.webhookRouteOf = webhookRouteOf;
|
|
6
|
+
exports.webhookRouteConflict = webhookRouteConflict;
|
|
7
|
+
exports.namedRouteConflict = namedRouteConflict;
|
|
8
|
+
exports.armedWebhookRouteIds = armedWebhookRouteIds;
|
|
4
9
|
const interface_api_1 = require("@antelopejs/interface-api");
|
|
10
|
+
const armErrors_1 = require("../../armErrors");
|
|
11
|
+
const DEFAULT_METHOD = "POST";
|
|
12
|
+
const RESERVED_PREFIXES = ["/api", "/auth", "/dms", "/modules", "/settings"];
|
|
13
|
+
const PATH_PATTERN = /^\/[A-Za-z0-9._~:/-]*$/;
|
|
14
|
+
const UNSAFE_SEGMENTS = /\/\/|(^|\/)\.\.?(\/|$)/;
|
|
15
|
+
function isReserved(path) {
|
|
16
|
+
const lower = path.toLowerCase();
|
|
17
|
+
return RESERVED_PREFIXES.some((prefix) => lower === prefix || lower.startsWith(`${prefix}/`));
|
|
18
|
+
}
|
|
19
|
+
function webhookPathProblem(path) {
|
|
20
|
+
const value = typeof path === "string" ? path.trim() : "";
|
|
21
|
+
if (!PATH_PATTERN.test(value) || UNSAFE_SEGMENTS.test(value)) {
|
|
22
|
+
return {
|
|
23
|
+
code: "webhookPathInvalid",
|
|
24
|
+
params: { path: value },
|
|
25
|
+
message: `webhook path must start with "/" and use only letters, digits and - . _ ~ : / (got ${JSON.stringify(path ?? "")})`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (isReserved(value)) {
|
|
29
|
+
return {
|
|
30
|
+
code: "webhookPathReserved",
|
|
31
|
+
params: { path: value },
|
|
32
|
+
message: `webhook path ${value} is reserved for the API`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
function webhookRouteOf(config) {
|
|
38
|
+
const method = typeof config?.method === "string" ? config.method : DEFAULT_METHOD;
|
|
39
|
+
const path = typeof config?.path === "string" ? config.path.trim() : "";
|
|
40
|
+
return { method, path: path.length > 1 ? path.replace(/\/+$/, "") : path };
|
|
41
|
+
}
|
|
42
|
+
const armedRoutes = new Set();
|
|
43
|
+
const segmentsOf = (path) => path.split("/").filter(Boolean);
|
|
44
|
+
function pathsOverlap(a, b) {
|
|
45
|
+
const left = segmentsOf(a);
|
|
46
|
+
const right = segmentsOf(b);
|
|
47
|
+
return (left.length === right.length &&
|
|
48
|
+
left.every((segment, i) => {
|
|
49
|
+
const other = right[i] ?? "";
|
|
50
|
+
return (segment === other || segment.startsWith(":") || other.startsWith(":"));
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function webhookRouteConflict(method, path, ownRouteIds = new Set()) {
|
|
54
|
+
const verb = method.toUpperCase();
|
|
55
|
+
const taken = (0, interface_api_1.getRegisteredRouteHandlers)().some(({ id, handler }) => !ownRouteIds.has(id) &&
|
|
56
|
+
handler.mode === "handler" &&
|
|
57
|
+
[verb, "ALL", "*"].includes(handler.method.toUpperCase()) &&
|
|
58
|
+
pathsOverlap(handler.location, path));
|
|
59
|
+
if (!taken)
|
|
60
|
+
return undefined;
|
|
61
|
+
return {
|
|
62
|
+
code: "webhookRouteTaken",
|
|
63
|
+
params: { method: verb, path },
|
|
64
|
+
message: `${verb} ${path} already answers for another route of the server`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function namedRouteConflict(problem, config, armed) {
|
|
68
|
+
if (problem.code !== "webhookRouteTaken")
|
|
69
|
+
return problem;
|
|
70
|
+
const { method, path } = webhookRouteOf(config);
|
|
71
|
+
for (const other of armed) {
|
|
72
|
+
const route = webhookRouteOf(other.config);
|
|
73
|
+
if (route.method !== method || !pathsOverlap(route.path, path))
|
|
74
|
+
continue;
|
|
75
|
+
return {
|
|
76
|
+
code: "webhookPathTaken",
|
|
77
|
+
params: { method, path, procedure: other.procedure },
|
|
78
|
+
message: `${method} ${path} already answers for the procedure "${other.procedure}"`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return problem;
|
|
82
|
+
}
|
|
83
|
+
function armedWebhookRouteIds() {
|
|
84
|
+
return armedRoutes;
|
|
85
|
+
}
|
|
86
|
+
function queryOf(url) {
|
|
87
|
+
const query = {};
|
|
88
|
+
for (const key of new Set(url.searchParams.keys())) {
|
|
89
|
+
const values = url.searchParams.getAll(key);
|
|
90
|
+
query[key] = values.length > 1 ? values : (values[0] ?? "");
|
|
91
|
+
}
|
|
92
|
+
return query;
|
|
93
|
+
}
|
|
94
|
+
function parseBody(text, contentType) {
|
|
95
|
+
if (contentType?.includes("application/x-www-form-urlencoded")) {
|
|
96
|
+
return Object.fromEntries(new URLSearchParams(text));
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
return JSON.parse(text);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return text;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
5
105
|
exports.webhookTrigger = {
|
|
6
106
|
id: "webhook",
|
|
7
|
-
name: "
|
|
8
|
-
description: "
|
|
107
|
+
name: "$dms_automation.types.webhook.name",
|
|
108
|
+
description: "$dms_automation.types.webhook.description",
|
|
9
109
|
icon: "i-ph-webhooks-logo",
|
|
10
110
|
cluster: "replicated",
|
|
11
111
|
configSchema: {
|
|
@@ -18,7 +118,7 @@ exports.webhookTrigger = {
|
|
|
18
118
|
method: {
|
|
19
119
|
type: "string",
|
|
20
120
|
enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
|
|
21
|
-
default:
|
|
121
|
+
default: DEFAULT_METHOD,
|
|
22
122
|
},
|
|
23
123
|
},
|
|
24
124
|
required: ["path"],
|
|
@@ -35,11 +135,10 @@ exports.webhookTrigger = {
|
|
|
35
135
|
},
|
|
36
136
|
},
|
|
37
137
|
async activate(config, emit) {
|
|
38
|
-
const path = (config
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const method = config.method ?? "POST";
|
|
138
|
+
const { method, path } = webhookRouteOf({ ...config });
|
|
139
|
+
const problem = webhookPathProblem(config.path) ?? webhookRouteConflict(method, path);
|
|
140
|
+
if (problem)
|
|
141
|
+
throw new armErrors_1.TriggerArmError(problem);
|
|
43
142
|
const handler = {
|
|
44
143
|
mode: "handler",
|
|
45
144
|
method,
|
|
@@ -48,43 +147,30 @@ exports.webhookTrigger = {
|
|
|
48
147
|
properties: {},
|
|
49
148
|
proto: {},
|
|
50
149
|
callback: async (ctx) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const text = buf.toString("utf8");
|
|
56
|
-
try {
|
|
57
|
-
body = JSON.parse(text);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
body = text;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
}
|
|
66
|
-
const query = {};
|
|
67
|
-
ctx.url.searchParams.forEach((v, k) => {
|
|
68
|
-
query[k] = v;
|
|
69
|
-
});
|
|
150
|
+
const buf = await (0, interface_api_1.ReadBody)(ctx);
|
|
151
|
+
const body = buf.length > 0
|
|
152
|
+
? parseBody(buf.toString("utf8"), ctx.rawRequest.headers["content-type"])
|
|
153
|
+
: undefined;
|
|
70
154
|
emit({
|
|
71
155
|
method: ctx.rawRequest.method ?? method,
|
|
72
156
|
headers: ctx.rawRequest.headers,
|
|
73
|
-
query,
|
|
157
|
+
query: queryOf(ctx.url),
|
|
74
158
|
body,
|
|
75
159
|
params: ctx.routeParameters,
|
|
76
160
|
});
|
|
77
161
|
return new interface_api_1.HTTPResult(200, { ok: true });
|
|
78
162
|
},
|
|
79
163
|
};
|
|
80
|
-
const
|
|
81
|
-
|
|
164
|
+
const routeId = String((0, interface_api_1.RegisterRoute)(handler));
|
|
165
|
+
armedRoutes.add(routeId);
|
|
166
|
+
return { routeId };
|
|
82
167
|
},
|
|
83
168
|
async deactivate(handle) {
|
|
84
169
|
const h = handle;
|
|
85
170
|
if (!h?.routeId)
|
|
86
171
|
return;
|
|
87
172
|
interface_api_1.routesProxy.unregister(h.routeId);
|
|
173
|
+
armedRoutes.delete(h.routeId);
|
|
88
174
|
},
|
|
89
175
|
};
|
|
90
176
|
//# sourceMappingURL=webhook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../../src/runtime/builtins/triggers/webhook.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../../src/runtime/builtins/triggers/webhook.ts"],"names":[],"mappings":";;;AAiDA,gDAiBC;AAMD,wCAQC;AA8BD,oDAmBC;AAaD,gDAiBC;AAGD,oDAEC;AApKD,6DAQmC;AAEnC,+CAAkD;AAoBlD,MAAM,cAAc,GAAG,MAAM,CAAC;AAM9B,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAE7E,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAC9C,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAEjD,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,OAAO,iBAAiB,CAAC,IAAI,CAC3B,CAAC,MAAM,EAAE,E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,GAAG,CAAC,GAAG,CAAC;oBACvB,IAAI;oBACJ,MAAM,EAAE,GAAG,CAAC,eAAe;iBAC5B,CAAC,CAAC;gBAEH,OAAO,IAAI,0BAAU,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAA,6BAAa,EAAC,OAAO,CAAC,CAAC,CAAC;QAC/C,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,EAAE,OAAO,EAA0B,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,MAAM;QACrB,MAAM,CAAC,GAAG,MAAmC,CAAC;QAC9C,IAAI,CAAC,CAAC,EAAE,OAAO;YAAE,OAAO;QACxB,2BAAW,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAClC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type GraphNode, type ProcedureGraph } from "../types/graph";
|
|
2
|
+
export interface StepName {
|
|
3
|
+
nodeId: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
typeName?: string;
|
|
6
|
+
kind?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function labelOf(node: GraphNode): string | undefined;
|
|
9
|
+
export declare function stepName(graph: ProcedureGraph, flatId: string): StepName;
|
|
10
|
+
export declare function stepNamesOf(graph: ProcedureGraph): Record<string, StepName>;
|
|
11
|
+
export declare function stepTitle(name: StepName): string;
|
|
12
|
+
export interface TriggerSummary {
|
|
13
|
+
nodeId: string;
|
|
14
|
+
typeId: string;
|
|
15
|
+
typeName: string;
|
|
16
|
+
method?: string;
|
|
17
|
+
path?: string;
|
|
18
|
+
cron?: string;
|
|
19
|
+
timeZone?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function summarizeTrigger(node: GraphNode): TriggerSummary;
|
|
22
|
+
export declare function triggersOf(graph: ProcedureGraph): TriggerSummary[];
|
|
23
|
+
export declare function parseGraphSafe(raw: string): ProcedureGraph | undefined;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.labelOf = labelOf;
|
|
4
|
+
exports.stepName = stepName;
|
|
5
|
+
exports.stepNamesOf = stepNamesOf;
|
|
6
|
+
exports.stepTitle = stepTitle;
|
|
7
|
+
exports.summarizeTrigger = summarizeTrigger;
|
|
8
|
+
exports.triggersOf = triggersOf;
|
|
9
|
+
exports.parseGraphSafe = parseGraphSafe;
|
|
10
|
+
const graph_1 = require("../types/graph");
|
|
11
|
+
const nodeKinds_1 = require("./nodeKinds");
|
|
12
|
+
const registry_1 = require("./registry");
|
|
13
|
+
const schedule_1 = require("./schedule");
|
|
14
|
+
const FLAT_ID_SEPARATOR = "__";
|
|
15
|
+
const TYPE_LOOKUP = {
|
|
16
|
+
trigger: (id) => registry_1.registry.getTrigger(id),
|
|
17
|
+
action: (id) => registry_1.registry.getAction(id),
|
|
18
|
+
data: (id) => registry_1.registry.getDataNode(id),
|
|
19
|
+
};
|
|
20
|
+
function typeNameOf(node) {
|
|
21
|
+
const lookup = TYPE_LOOKUP[node.kind];
|
|
22
|
+
if (lookup && node.typeId)
|
|
23
|
+
return lookup(node.typeId)?.name ?? node.typeId;
|
|
24
|
+
return nodeKinds_1.nodeKinds.get(node.kind)?.meta.ui?.label;
|
|
25
|
+
}
|
|
26
|
+
function labelOf(node) {
|
|
27
|
+
const label = node.label;
|
|
28
|
+
return typeof label === "string" && label.trim() ? label.trim() : undefined;
|
|
29
|
+
}
|
|
30
|
+
function findStep(graph, flatId) {
|
|
31
|
+
const parts = flatId.split(FLAT_ID_SEPARATOR);
|
|
32
|
+
let current = graph;
|
|
33
|
+
let found;
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
const node = current?.nodes.find((n) => n.id === part);
|
|
36
|
+
if (!node)
|
|
37
|
+
break;
|
|
38
|
+
found = node;
|
|
39
|
+
current = (0, graph_1.isGroupNode)(node) ? node.subgraph : undefined;
|
|
40
|
+
}
|
|
41
|
+
return found;
|
|
42
|
+
}
|
|
43
|
+
function stepName(graph, flatId) {
|
|
44
|
+
const node = findStep(graph, flatId);
|
|
45
|
+
if (!node)
|
|
46
|
+
return { nodeId: flatId };
|
|
47
|
+
const name = { nodeId: flatId, kind: node.kind };
|
|
48
|
+
const label = labelOf(node);
|
|
49
|
+
const typeName = typeNameOf(node);
|
|
50
|
+
if (label)
|
|
51
|
+
name.label = label;
|
|
52
|
+
if (typeName)
|
|
53
|
+
name.typeName = typeName;
|
|
54
|
+
return name;
|
|
55
|
+
}
|
|
56
|
+
const NOT_A_STEP = new Set(["data", "groupInput", "groupOutput"]);
|
|
57
|
+
function stepNamesOf(graph) {
|
|
58
|
+
const names = {};
|
|
59
|
+
const walk = (current, prefix) => {
|
|
60
|
+
for (const node of current.nodes) {
|
|
61
|
+
if (NOT_A_STEP.has(node.kind))
|
|
62
|
+
continue;
|
|
63
|
+
const flatId = `${prefix}${node.id}`;
|
|
64
|
+
names[flatId] = stepName(graph, flatId);
|
|
65
|
+
if ((0, graph_1.isGroupNode)(node) && node.subgraph) {
|
|
66
|
+
walk(node.subgraph, `${flatId}${FLAT_ID_SEPARATOR}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
walk(graph, "");
|
|
71
|
+
return names;
|
|
72
|
+
}
|
|
73
|
+
function stepTitle(name) {
|
|
74
|
+
return name.label ?? name.typeName ?? name.nodeId;
|
|
75
|
+
}
|
|
76
|
+
const DEFAULT_WEBHOOK_METHOD = "POST";
|
|
77
|
+
function configString(node, key) {
|
|
78
|
+
const value = node.config?.[key];
|
|
79
|
+
return typeof value === "string" && value ? value : undefined;
|
|
80
|
+
}
|
|
81
|
+
function summarizeTrigger(node) {
|
|
82
|
+
const typeId = node.typeId ?? "";
|
|
83
|
+
const summary = {
|
|
84
|
+
nodeId: node.id,
|
|
85
|
+
typeId,
|
|
86
|
+
typeName: typeNameOf(node) ?? typeId,
|
|
87
|
+
};
|
|
88
|
+
const path = configString(node, "path");
|
|
89
|
+
const cron = configString(node, "cron");
|
|
90
|
+
if (path) {
|
|
91
|
+
summary.path = path;
|
|
92
|
+
summary.method = configString(node, "method") ?? DEFAULT_WEBHOOK_METHOD;
|
|
93
|
+
}
|
|
94
|
+
if (cron) {
|
|
95
|
+
summary.cron = cron;
|
|
96
|
+
summary.timeZone = (0, schedule_1.scheduleTimeZone)();
|
|
97
|
+
}
|
|
98
|
+
return summary;
|
|
99
|
+
}
|
|
100
|
+
function triggersOf(graph) {
|
|
101
|
+
return graph.nodes
|
|
102
|
+
.filter((n) => n.kind === "trigger" && n.typeId)
|
|
103
|
+
.map(summarizeTrigger);
|
|
104
|
+
}
|
|
105
|
+
function parseGraphSafe(raw) {
|
|
106
|
+
try {
|
|
107
|
+
const graph = JSON.parse(raw);
|
|
108
|
+
return Array.isArray(graph?.nodes) ? graph : undefined;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=describe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/runtime/describe.ts"],"names":[],"mappings":";;AAyCA,0BAGC;AA0BD,4BASC;AAUD,kCAcC;AAGD,8BAEC;AAyBD,4CAkBC;AAGD,gCAIC;AAGD,wCAOC;AAxKD,0CAIwB;AACxB,2CAAwC;AACxC,yCAAsC;AACtC,yCAA8C;AAG9C,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,MAAM,WAAW,GAGb;IACF,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,mBAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;IACxC,MAAM,EA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CAAC;QACpB,OAAO,CAAC,QAAQ,GAAG,IAAA,2BAAgB,GAAE,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAGD,SAAgB,UAAU,CAAC,KAAqB;IAC9C,OAAO,KAAK,CAAC,KAAK;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC;SAC/C,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC3B,CAAC;AAGD,SAAgB,cAAc,CAAC,GAAW;IACxC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAmB,CAAC;QAChD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/runtime/executor.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.run = run;
|
|
4
4
|
require("./builtins");
|
|
5
|
+
const boundRunLog_1 = require("./boundRunLog");
|
|
6
|
+
const describe_1 = require("./describe");
|
|
5
7
|
const flatten_1 = require("./flatten");
|
|
6
8
|
const nodeKinds_1 = require("./nodeKinds");
|
|
7
9
|
const registry_1 = require("./registry");
|
|
@@ -74,6 +76,7 @@ async function run(graph, triggerNodeId, payload, options = {}) {
|
|
|
74
76
|
currentFireId: "",
|
|
75
77
|
cache,
|
|
76
78
|
signal,
|
|
79
|
+
failedAt: new Map(),
|
|
77
80
|
};
|
|
78
81
|
const rootFire = openFire(runCtx, {
|
|
79
82
|
parentFireId: null,
|
|
@@ -119,11 +122,15 @@ async function run(graph, triggerNodeId, payload, options = {}) {
|
|
|
119
122
|
catch (err) {
|
|
120
123
|
const message = err instanceof Error ? err.message : String(err);
|
|
121
124
|
closeFire(runCtx, rootFire);
|
|
122
|
-
|
|
125
|
+
const result = {
|
|
123
126
|
status: "failed",
|
|
124
127
|
errorMessage: message,
|
|
125
128
|
logs: toRunLog(runCtx),
|
|
126
129
|
};
|
|
130
|
+
const failedNodeId = runCtx.failedAt.get(err);
|
|
131
|
+
if (failedNodeId)
|
|
132
|
+
result.failedNodeId = failedNodeId;
|
|
133
|
+
return result;
|
|
127
134
|
}
|
|
128
135
|
appendEntry(runCtx, { source: "exec", level: "info", message: "run ok" });
|
|
129
136
|
closeFire(runCtx, rootFire);
|
|
@@ -147,7 +154,7 @@ async function runSubWalk(subwalk, runCtx) {
|
|
|
147
154
|
const order = subwalk.topoOrder();
|
|
148
155
|
const nodeById = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
149
156
|
const evalDataNode = makeDataNodeEvaluator(graph, nodeById, runCtx);
|
|
150
|
-
const resolveNodeInputs = (n) => (0, resolveInputs_1.resolveInputs)(n, graph.dataEdges, runCtx.cache, evalDataNode);
|
|
157
|
+
const resolveNodeInputs = (n) => (0, resolveInputs_1.resolveInputs)(n, graph.dataEdges, runCtx.cache, evalDataNode, inputDefaults(n));
|
|
151
158
|
for (const nodeId of order) {
|
|
152
159
|
if (runCtx.signal.aborted) {
|
|
153
160
|
throw new DOMException("Aborted", "AbortError");
|
|
@@ -166,8 +173,10 @@ async function runSubWalk(subwalk, runCtx) {
|
|
|
166
173
|
message: "executing",
|
|
167
174
|
node: { id: nodeId, kind: node.kind },
|
|
168
175
|
});
|
|
169
|
-
const
|
|
176
|
+
const nodeStart = Date.now();
|
|
177
|
+
let inputs = {};
|
|
170
178
|
try {
|
|
179
|
+
inputs = resolveNodeInputs(node);
|
|
171
180
|
const entry = nodeKinds_1.nodeKinds.get(node.kind);
|
|
172
181
|
if (!entry) {
|
|
173
182
|
throw new Error(`unsupported node kind "${node.kind}"`);
|
|
@@ -186,17 +195,79 @@ async function runSubWalk(subwalk, runCtx) {
|
|
|
186
195
|
}
|
|
187
196
|
catch (err) {
|
|
188
197
|
const message = err instanceof Error ? err.message : String(err);
|
|
198
|
+
if (!runCtx.failedAt.has(err))
|
|
199
|
+
runCtx.failedAt.set(err, nodeId);
|
|
189
200
|
appendEntry(runCtx, {
|
|
190
201
|
source: "exec",
|
|
191
202
|
level: "error",
|
|
192
203
|
message,
|
|
193
204
|
node: { id: nodeId, kind: node.kind },
|
|
205
|
+
value: {
|
|
206
|
+
durationMs: Date.now() - nodeStart,
|
|
207
|
+
inputs: describeRecord(redacted(inputs, typeOf(node)?.inputSchema)),
|
|
208
|
+
},
|
|
194
209
|
});
|
|
195
210
|
throw err;
|
|
196
211
|
}
|
|
212
|
+
appendEntry(runCtx, {
|
|
213
|
+
source: "exec",
|
|
214
|
+
level: "info",
|
|
215
|
+
message: "executed",
|
|
216
|
+
node: { id: nodeId, kind: node.kind },
|
|
217
|
+
value: {
|
|
218
|
+
durationMs: Date.now() - nodeStart,
|
|
219
|
+
inputs: describeRecord(redacted(inputs, typeOf(node)?.inputSchema)),
|
|
220
|
+
output: describeValue(redacted(runCtx.cache.getOutput(nodeId), typeOf(node)?.outputSchema)),
|
|
221
|
+
},
|
|
222
|
+
});
|
|
197
223
|
subwalk.markExecuted(nodeId);
|
|
198
224
|
}
|
|
199
225
|
}
|
|
226
|
+
function withEmptySources(err, node, inputs, graph, nodeById) {
|
|
227
|
+
if (!(err instanceof Error))
|
|
228
|
+
return err;
|
|
229
|
+
const sources = graph.dataEdges
|
|
230
|
+
.filter((e) => e.to.node === node.id)
|
|
231
|
+
.filter((e) => inputs[e.to.field] === null || inputs[e.to.field] === undefined)
|
|
232
|
+
.map((e) => {
|
|
233
|
+
const source = nodeById.get(e.from.node);
|
|
234
|
+
const name = (source && ((0, describe_1.labelOf)(source) ?? source.typeId ?? source.kind)) ??
|
|
235
|
+
e.from.node;
|
|
236
|
+
return `${e.to.field} comes from ${name} (${e.from.port}), which gave no value`;
|
|
237
|
+
});
|
|
238
|
+
if (sources.length === 0)
|
|
239
|
+
return err;
|
|
240
|
+
return new Error(`${err.message}. ${sources.join("; ")}.`, { cause: err });
|
|
241
|
+
}
|
|
242
|
+
function typeOf(node) {
|
|
243
|
+
if (!node.typeId)
|
|
244
|
+
return undefined;
|
|
245
|
+
if (node.kind === "action")
|
|
246
|
+
return registry_1.registry.getAction(node.typeId);
|
|
247
|
+
if (node.kind === "data")
|
|
248
|
+
return registry_1.registry.getDataNode(node.typeId);
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
function inputDefaults(node) {
|
|
252
|
+
const type = typeOf(node);
|
|
253
|
+
return {
|
|
254
|
+
...(0, resolveInputs_1.schemaDefaults)(type?.inputSchema),
|
|
255
|
+
...(0, resolveInputs_1.schemaDefaults)(type?.configSchema),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function redacted(values, schema) {
|
|
259
|
+
if (!values || typeof values !== "object" || Array.isArray(values)) {
|
|
260
|
+
return values;
|
|
261
|
+
}
|
|
262
|
+
const properties = (schema?.properties ?? {});
|
|
263
|
+
const out = { ...values };
|
|
264
|
+
for (const [name, prop] of Object.entries(properties)) {
|
|
265
|
+
if (prop["x-redact"] === "headers" && name in out) {
|
|
266
|
+
out[name] = (0, boundRunLog_1.redactHeaders)(out[name]);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
200
271
|
function makeNodeCtx(node, subwalk, runCtx, resolveNodeInputs, contState) {
|
|
201
272
|
return {
|
|
202
273
|
procedureId: runCtx.procedureId,
|
|
@@ -269,8 +340,14 @@ function makeDataNodeEvaluator(graph, nodeById, runCtx) {
|
|
|
269
340
|
}
|
|
270
341
|
evalStack.add(nodeId);
|
|
271
342
|
try {
|
|
272
|
-
const inputs = (0, resolveInputs_1.resolveInputs)(dn, graph.dataEdges, runCtx.cache, evaluator);
|
|
273
|
-
|
|
343
|
+
const inputs = (0, resolveInputs_1.resolveInputs)(dn, graph.dataEdges, runCtx.cache, evaluator, inputDefaults(dn));
|
|
344
|
+
let out;
|
|
345
|
+
try {
|
|
346
|
+
out = type.evaluate(inputs);
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
throw withEmptySources(err, dn, inputs, graph, nodeById);
|
|
350
|
+
}
|
|
274
351
|
const deps = graph.dataEdges
|
|
275
352
|
.filter((e) => e.to.node === nodeId)
|
|
276
353
|
.map((e) => e.from.node);
|