@antelopejs/dms-automation 0.7.0 → 0.9.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 +33 -22
- package/dist/cluster/bus.js +8 -6
- package/dist/cluster/bus.js.map +1 -1
- package/dist/cluster/leader.js.map +1 -1
- package/dist/data/procedures-query.d.ts +19 -0
- package/dist/data/procedures-query.js +105 -0
- package/dist/data/procedures-query.js.map +1 -0
- package/dist/data/procedures-table.d.ts +5 -20
- package/dist/data/procedures-table.js +10 -106
- package/dist/data/procedures-table.js.map +1 -1
- package/dist/data/runs-table.d.ts +3 -3
- package/dist/data/runs-table.js.map +1 -1
- package/dist/db/models/automation_template.model.d.ts +13 -13
- package/dist/db/models/automation_template.model.js +13 -14
- package/dist/db/models/automation_template.model.js.map +1 -1
- package/dist/db/models/procedure.model.d.ts +7 -5
- package/dist/db/models/procedure_run.model.d.ts +9 -6
- package/dist/db/models/procedure_run.model.js +8 -8
- package/dist/db/models/procedure_run.model.js.map +1 -1
- package/dist/db/models/stats.model.js.map +1 -1
- package/dist/db/models/type_switch.model.d.ts +7 -5
- package/dist/db/tables/procedure_run.table.d.ts +2 -1
- package/dist/db/tables/procedure_run.table.js.map +1 -1
- package/dist/implementations/dms-automation/index.d.ts +2 -2
- package/dist/implementations/dms-automation/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pages/category.js.map +1 -1
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/procedures.js.map +1 -1
- package/dist/pages/runs.js.map +1 -1
- package/dist/pages/shared.js +1 -1
- package/dist/pages/shared.js.map +1 -1
- package/dist/realtime.d.ts +2 -1
- package/dist/realtime.js.map +1 -1
- package/dist/routes/action-types.d.ts +3 -2
- package/dist/routes/action-types.js.map +1 -1
- package/dist/routes/data-node-types.d.ts +1 -1
- package/dist/routes/deleteConfirm.js +4 -3
- package/dist/routes/deleteConfirm.js.map +1 -1
- package/dist/routes/graphSchema.d.ts +2 -1
- package/dist/routes/graphSchema.js +13 -10
- package/dist/routes/graphSchema.js.map +1 -1
- package/dist/routes/library.d.ts +12 -1
- package/dist/routes/library.js +38 -34
- package/dist/routes/library.js.map +1 -1
- package/dist/routes/procedureChecks.js +5 -5
- package/dist/routes/procedureChecks.js.map +1 -1
- package/dist/routes/procedureRuns.d.ts +3 -3
- package/dist/routes/procedureRuns.js +1 -1
- package/dist/routes/procedureRuns.js.map +1 -1
- package/dist/routes/procedureSchemas.d.ts +7 -6
- package/dist/routes/procedureSchemas.js +4 -2
- package/dist/routes/procedureSchemas.js.map +1 -1
- package/dist/routes/procedures.d.ts +15 -14
- package/dist/routes/procedures.js +2 -1
- package/dist/routes/procedures.js.map +1 -1
- package/dist/routes/requests.d.ts +12 -6
- package/dist/routes/requests.js +2 -1
- package/dist/routes/requests.js.map +1 -1
- package/dist/routes/runs.d.ts +9 -8
- package/dist/routes/runs.js +5 -3
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/stats.js.map +1 -1
- package/dist/routes/templates.d.ts +5 -4
- package/dist/routes/templates.js +2 -1
- package/dist/routes/templates.js.map +1 -1
- package/dist/routes/trigger-types.d.ts +3 -2
- package/dist/routes/trigger-types.js.map +1 -1
- package/dist/routes/typeConfigShared.d.ts +2 -1
- package/dist/routes/typeConfigShared.js.map +1 -1
- package/dist/routes/zodJson.d.ts +3 -0
- package/dist/routes/zodJson.js +21 -0
- package/dist/routes/zodJson.js.map +1 -0
- package/dist/runtime/armErrors.d.ts +0 -1
- package/dist/runtime/armErrors.js +5 -12
- package/dist/runtime/armErrors.js.map +1 -1
- package/dist/runtime/boundRunLog.d.ts +7 -5
- package/dist/runtime/boundRunLog.js +24 -20
- package/dist/runtime/boundRunLog.js.map +1 -1
- package/dist/runtime/builtins/actions/http.d.ts +7 -3
- package/dist/runtime/builtins/actions/http.js +33 -22
- package/dist/runtime/builtins/actions/http.js.map +1 -1
- package/dist/runtime/builtins/actions/log.d.ts +5 -4
- package/dist/runtime/builtins/actions/log.js.map +1 -1
- package/dist/runtime/builtins/data/boolean.d.ts +2 -1
- package/dist/runtime/builtins/data/boolean.js +4 -5
- package/dist/runtime/builtins/data/boolean.js.map +1 -1
- package/dist/runtime/builtins/data/compare.js +8 -10
- package/dist/runtime/builtins/data/compare.js.map +1 -1
- package/dist/runtime/builtins/data/constant.js +1 -1
- package/dist/runtime/builtins/data/constant.js.map +1 -1
- package/dist/runtime/builtins/data/json.js +4 -5
- package/dist/runtime/builtins/data/json.js.map +1 -1
- package/dist/runtime/builtins/data/math.js +4 -4
- package/dist/runtime/builtins/data/math.js.map +1 -1
- package/dist/runtime/builtins/data/object.js +27 -27
- package/dist/runtime/builtins/data/object.js.map +1 -1
- package/dist/runtime/builtins/data/string.js +13 -18
- package/dist/runtime/builtins/data/string.js.map +1 -1
- package/dist/runtime/builtins/nodes/action.js +16 -5
- package/dist/runtime/builtins/nodes/action.js.map +1 -1
- package/dist/runtime/builtins/nodes/data.js +2 -2
- package/dist/runtime/builtins/nodes/data.js.map +1 -1
- package/dist/runtime/builtins/nodes/delay.js +2 -2
- package/dist/runtime/builtins/nodes/delay.js.map +1 -1
- package/dist/runtime/builtins/nodes/forRange.js +2 -2
- package/dist/runtime/builtins/nodes/forRange.js.map +1 -1
- package/dist/runtime/builtins/nodes/foreach.js +2 -2
- package/dist/runtime/builtins/nodes/foreach.js.map +1 -1
- package/dist/runtime/builtins/nodes/groupInput.js +2 -2
- package/dist/runtime/builtins/nodes/groupInput.js.map +1 -1
- package/dist/runtime/builtins/nodes/groupOutput.js +2 -2
- package/dist/runtime/builtins/nodes/groupOutput.js.map +1 -1
- package/dist/runtime/builtins/nodes/if.js +2 -2
- package/dist/runtime/builtins/nodes/if.js.map +1 -1
- package/dist/runtime/builtins/nodes/parallel.js +2 -2
- package/dist/runtime/builtins/nodes/parallel.js.map +1 -1
- package/dist/runtime/builtins/nodes/retry.js +13 -5
- package/dist/runtime/builtins/nodes/retry.js.map +1 -1
- package/dist/runtime/builtins/nodes/setVariable.js +2 -2
- package/dist/runtime/builtins/nodes/setVariable.js.map +1 -1
- package/dist/runtime/builtins/nodes/switch.js +8 -3
- package/dist/runtime/builtins/nodes/switch.js.map +1 -1
- package/dist/runtime/builtins/nodes/trigger.js +2 -2
- package/dist/runtime/builtins/nodes/trigger.js.map +1 -1
- package/dist/runtime/builtins/nodes/tryCatch.js +2 -2
- package/dist/runtime/builtins/nodes/tryCatch.js.map +1 -1
- package/dist/runtime/builtins/triggers/cron.d.ts +4 -3
- package/dist/runtime/builtins/triggers/cron.js +5 -7
- package/dist/runtime/builtins/triggers/cron.js.map +1 -1
- package/dist/runtime/builtins/triggers/webhook.d.ts +11 -7
- package/dist/runtime/builtins/triggers/webhook.js +15 -12
- package/dist/runtime/builtins/triggers/webhook.js.map +1 -1
- package/dist/runtime/declaredProcedures.d.ts +2 -2
- package/dist/runtime/declaredProcedures.js +3 -2
- package/dist/runtime/declaredProcedures.js.map +1 -1
- package/dist/runtime/describe.d.ts +3 -1
- package/dist/runtime/describe.js +14 -13
- package/dist/runtime/describe.js.map +1 -1
- package/dist/runtime/executor.d.ts +2 -1
- package/dist/runtime/executor.js +18 -13
- package/dist/runtime/executor.js.map +1 -1
- package/dist/runtime/flatten.d.ts +1 -1
- package/dist/runtime/flatten.js +1 -1
- package/dist/runtime/flatten.js.map +1 -1
- package/dist/runtime/graphIssues.d.ts +2 -2
- package/dist/runtime/graphIssues.js +39 -32
- package/dist/runtime/graphIssues.js.map +1 -1
- package/dist/runtime/graphVersion.d.ts +1 -1
- package/dist/runtime/graphVersion.js +4 -3
- package/dist/runtime/graphVersion.js.map +1 -1
- package/dist/runtime/nodeKinds.d.ts +6 -5
- package/dist/runtime/nodeKinds.js.map +1 -1
- package/dist/runtime/reconcile.d.ts +3 -0
- package/dist/runtime/reconcile.js +178 -0
- package/dist/runtime/reconcile.js.map +1 -0
- package/dist/runtime/registry.d.ts +3 -3
- package/dist/runtime/resolveInputs.d.ts +13 -8
- package/dist/runtime/resolveInputs.js +18 -18
- package/dist/runtime/resolveInputs.js.map +1 -1
- package/dist/runtime/resolveSubgraph.js +4 -5
- package/dist/runtime/resolveSubgraph.js.map +1 -1
- package/dist/runtime/retention.js.map +1 -1
- package/dist/runtime/runProcedure.d.ts +3 -2
- package/dist/runtime/runProcedure.js +2 -1
- package/dist/runtime/runProcedure.js.map +1 -1
- package/dist/runtime/schedule.js +3 -0
- package/dist/runtime/schedule.js.map +1 -1
- package/dist/runtime/schemaProperties.d.ts +3 -0
- package/dist/runtime/schemaProperties.js +7 -0
- package/dist/runtime/schemaProperties.js.map +1 -0
- package/dist/runtime/serialQueue.d.ts +1 -1
- package/dist/runtime/serialQueue.js +4 -4
- package/dist/runtime/serialQueue.js.map +1 -1
- package/dist/runtime/sideEffects.d.ts +2 -2
- package/dist/runtime/subscriptions.d.ts +6 -4
- package/dist/runtime/subscriptions.js +21 -180
- package/dist/runtime/subscriptions.js.map +1 -1
- package/dist/runtime/subwalk.js.map +1 -1
- package/dist/runtime/templateCacheState.d.ts +6 -0
- package/dist/runtime/templateCacheState.js +10 -0
- package/dist/runtime/templateCacheState.js.map +1 -0
- package/dist/runtime/templateUsages.js +4 -5
- package/dist/runtime/templateUsages.js.map +1 -1
- package/dist/runtime/topo.js +2 -4
- package/dist/runtime/topo.js.map +1 -1
- package/dist/runtime/trace.d.ts +5 -2
- package/dist/runtime/trace.js +27 -17
- package/dist/runtime/trace.js.map +1 -1
- package/dist/runtime/triggerHandles.d.ts +4 -3
- package/dist/runtime/triggerHandles.js +9 -1
- package/dist/runtime/triggerHandles.js.map +1 -1
- package/dist/runtime/typeOrigin.js +12 -1
- package/dist/runtime/typeOrigin.js.map +1 -1
- package/dist/runtime/validate.js.map +1 -1
- package/dist/runtime/validateTemplate.js.map +1 -1
- package/dist/runtime/withTimeout.js.map +1 -1
- package/dist/runtime/wording.js +12 -8
- package/dist/runtime/wording.js.map +1 -1
- package/dist/stats/health-banner.js.map +1 -1
- package/dist/stats/health.js.map +1 -1
- package/dist/stats/kpi.js +1 -1
- package/dist/stats/kpi.js.map +1 -1
- package/dist/stats/overview.js +2 -1
- package/dist/stats/overview.js.map +1 -1
- package/dist/types/dataValue.d.ts +7 -0
- package/dist/types/dataValue.js +56 -0
- package/dist/types/dataValue.js.map +1 -0
- package/dist/types/graph.d.ts +19 -13
- package/dist/types/graph.js +8 -0
- package/dist/types/graph.js.map +1 -1
- package/dist/types/guards.d.ts +8 -0
- package/dist/types/guards.js +35 -0
- package/dist/types/guards.js.map +1 -0
- package/dist/types/runLog.d.ts +8 -7
- package/dist/types/runLog.js.map +1 -1
- package/frontend-vue/app/build/components/editor/EditorBanners.vue +120 -0
- package/frontend-vue/app/build/components/editor/EditorChoiceModal.vue +44 -0
- package/frontend-vue/app/build/components/editor/EditorForkModal.vue +51 -0
- package/frontend-vue/app/build/components/editor/EditorHeader.vue +146 -0
- package/frontend-vue/app/build/components/editor/EditorSaveTemplateModal.vue +105 -0
- package/frontend-vue/app/build/components/editor/NodeInspectorDocs.vue +28 -0
- package/frontend-vue/app/build/components/editor/NodeInspectorRun.vue +48 -0
- package/frontend-vue/app/build/composables/editor/useBuilderMount.ts +129 -0
- package/frontend-vue/app/build/composables/editor/useBuilderSave.ts +256 -0
- package/frontend-vue/app/build/composables/editor/useBuilderShortcuts.ts +270 -0
- package/frontend-vue/app/build/composables/editor/useDraftProblems.ts +288 -0
- package/frontend-vue/app/build/composables/editor/useEditorContext.ts +388 -0
- package/frontend-vue/app/build/composables/editor/useEditorLoad.ts +158 -0
- package/frontend-vue/app/build/composables/editor/useForkToLocal.ts +193 -0
- package/frontend-vue/app/build/composables/editor/useGraphHistory.ts +113 -0
- package/frontend-vue/app/build/composables/editor/useGroupEditing.ts +445 -0
- package/frontend-vue/app/build/composables/editor/usePalette.ts +41 -0
- package/frontend-vue/app/build/composables/editor/useProcedureActions.ts +96 -0
- package/frontend-vue/app/build/composables/editor/useRunOverlay.ts +466 -0
- package/frontend-vue/app/build/composables/editor/useSaveAsTemplate.ts +172 -0
- package/frontend-vue/app/build/composables/editor/useSavedTriggers.ts +100 -0
- package/frontend-vue/app/build/composables/editor/useSubgraphNavigation.ts +270 -0
- package/frontend-vue/app/build/composables/editor/useUnsavedGuards.ts +233 -0
- package/frontend-vue/app/build/composables/graphCanvas/connect.ts +273 -0
- package/frontend-vue/app/build/composables/graphCanvas/edgeEvents.ts +172 -0
- package/frontend-vue/app/build/composables/graphCanvas/edges.ts +55 -0
- package/frontend-vue/app/build/composables/graphCanvas/handles.ts +181 -0
- package/frontend-vue/app/build/composables/graphCanvas/linkMenu.ts +123 -0
- package/frontend-vue/app/build/composables/graphCanvas/nodeData.ts +222 -0
- package/frontend-vue/app/build/composables/graphCanvas/placement.ts +248 -0
- package/frontend-vue/app/build/composables/graphCanvas/selection.ts +150 -0
- package/frontend-vue/app/build/composables/graphCanvas/types.ts +188 -0
- package/frontend-vue/app/build/composables/graphCanvas/view.ts +230 -0
- package/frontend-vue/app/build/types/editor.ts +94 -0
- package/frontend-vue/app/build/utils/editor/apiErrors.ts +74 -0
- package/frontend-vue/app/build/utils/editor/graphShape.ts +68 -0
- package/frontend-vue/app/build/utils/editor/groupPlan.ts +322 -0
- package/frontend-vue/app/build/utils/editor/groupPorts.ts +210 -0
- package/frontend-vue/app/build/utils/editor/keyboard.ts +22 -0
- package/frontend-vue/app/build/utils/inspectorFields.ts +117 -0
- package/frontend-vue/app/build/utils/templates.ts +88 -0
- package/frontend-vue/app/components/AttentionList.vue +2 -6
- package/frontend-vue/app/components/Catalog.vue +2 -1
- package/frontend-vue/app/components/Editor/GraphCanvas.vue +78 -1337
- package/frontend-vue/app/components/Editor/NodeInspector.vue +31 -123
- package/frontend-vue/app/components/Editor.vue +134 -3484
- package/frontend-vue/app/components/Templates.vue +14 -84
- package/frontend-vue/build/backend-boundary.ts +122 -0
- package/frontend-vue/dms.frontend.build.ts +2 -0
- package/frontend-vue/eslint-rules/index.mjs +103 -0
- package/frontend-vue/eslint.config.mjs +15 -0
- package/frontend-vue/package.json +8 -5
- package/frontend-vue/pnpm-lock.yaml +168 -139
- package/frontend-vue/tests/api-error-presentation.test.cjs +254 -0
- package/frontend-vue/tests/helpers/setup.cjs +44 -0
- package/package.json +18 -15
- package/skills/dms-automation/SKILL.md +2 -2
- package/skills/dms-automation/cases.json +58 -0
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue'
|
|
3
3
|
import { isIconName } from './IconPicker.vue'
|
|
4
4
|
import { queryString } from '../utils/automation'
|
|
5
|
+
import {
|
|
6
|
+
schemaTypeOf,
|
|
7
|
+
usageRowsOf,
|
|
8
|
+
type ProcedureSummary,
|
|
9
|
+
type TemplateRow,
|
|
10
|
+
type TemplateUsage,
|
|
11
|
+
type TemplateUsages,
|
|
12
|
+
} from '../build/utils/templates'
|
|
5
13
|
|
|
6
14
|
// The library's templates: reusable groups other procedures place as linked
|
|
7
15
|
// blocks. The detail edits the name, icon and description, lists the ports
|
|
@@ -9,52 +17,6 @@ import { queryString } from '../utils/automation'
|
|
|
9
17
|
// other templates; deleting forks every usage into a local group so they keep
|
|
10
18
|
// working. The picked template is kept in the URL (`?template=`).
|
|
11
19
|
|
|
12
|
-
interface JsonSchema {
|
|
13
|
-
type?: string | string[]
|
|
14
|
-
[key: string]: unknown
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface TemplatePort {
|
|
18
|
-
name: string
|
|
19
|
-
kind: 'data' | 'trigger'
|
|
20
|
-
direction: 'in' | 'out'
|
|
21
|
-
schema?: JsonSchema
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface TemplateRow {
|
|
25
|
-
_id: string
|
|
26
|
-
name: string
|
|
27
|
-
description: string
|
|
28
|
-
icon: string
|
|
29
|
-
ports: TemplatePort[]
|
|
30
|
-
subgraph: unknown
|
|
31
|
-
usageCount?: number
|
|
32
|
-
updated_at?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface TemplateUsage {
|
|
36
|
-
procedureId: string
|
|
37
|
-
nodeId: string
|
|
38
|
-
groupPath: string[]
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface TemplateNesting {
|
|
42
|
-
templateId: string
|
|
43
|
-
nodeId: string
|
|
44
|
-
groupPath: string[]
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface TemplateUsages {
|
|
48
|
-
procedures: TemplateUsage[]
|
|
49
|
-
templates: TemplateNesting[]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface ProcedureSummary {
|
|
53
|
-
procedureId: string
|
|
54
|
-
name: string
|
|
55
|
-
status: 'failing' | 'degraded' | 'healthy' | 'paused' | 'draft'
|
|
56
|
-
}
|
|
57
|
-
|
|
58
20
|
const props = defineProps<{
|
|
59
21
|
apiUrl: string
|
|
60
22
|
builderUrl: string
|
|
@@ -74,6 +36,7 @@ const { $authFetch } = useAuthFetch()
|
|
|
74
36
|
const route = useDmsRoute()
|
|
75
37
|
const router = useDmsRouter()
|
|
76
38
|
const toast = useToast()
|
|
39
|
+
const { presentError } = useApiErrorPresenter()
|
|
77
40
|
const { t } = useI18n()
|
|
78
41
|
const { confirm } = useConfirm()
|
|
79
42
|
|
|
@@ -181,20 +144,7 @@ function backToList() {
|
|
|
181
144
|
}
|
|
182
145
|
|
|
183
146
|
/** One line per procedure or template placing it, with how many times. */
|
|
184
|
-
const usageRows = computed(() =>
|
|
185
|
-
const rows = new Map<string, { kind: 'procedure' | 'template'; id: string; first: TemplateUsage | TemplateNesting; count: number }>()
|
|
186
|
-
for (const usage of usages.value.procedures) {
|
|
187
|
-
const row = rows.get(`p:${usage.procedureId}`)
|
|
188
|
-
if (row) row.count++
|
|
189
|
-
else rows.set(`p:${usage.procedureId}`, { kind: 'procedure', id: usage.procedureId, first: usage, count: 1 })
|
|
190
|
-
}
|
|
191
|
-
for (const nesting of usages.value.templates) {
|
|
192
|
-
const row = rows.get(`t:${nesting.templateId}`)
|
|
193
|
-
if (row) row.count++
|
|
194
|
-
else rows.set(`t:${nesting.templateId}`, { kind: 'template', id: nesting.templateId, first: nesting, count: 1 })
|
|
195
|
-
}
|
|
196
|
-
return [...rows.values()]
|
|
197
|
-
})
|
|
147
|
+
const usageRows = computed(() => usageRowsOf(usages.value))
|
|
198
148
|
|
|
199
149
|
const NAME_ID = 'template-name'
|
|
200
150
|
const NAME_MAX = 200
|
|
@@ -205,8 +155,6 @@ watch(formName, () => fieldErrors.clear('name'))
|
|
|
205
155
|
|
|
206
156
|
interface RefusalBody {
|
|
207
157
|
code?: string
|
|
208
|
-
error?: string
|
|
209
|
-
issues?: { path?: (string | number)[]; message?: string }[]
|
|
210
158
|
}
|
|
211
159
|
|
|
212
160
|
/** The `code` a refused request answered with, if any. */
|
|
@@ -214,13 +162,6 @@ function errorCode(e: unknown): string | undefined {
|
|
|
214
162
|
return (e as { data?: RefusalBody }).data?.code
|
|
215
163
|
}
|
|
216
164
|
|
|
217
|
-
/** What the server said was wrong, rather than the request's raw status line. */
|
|
218
|
-
function errorMessage(e: unknown): string {
|
|
219
|
-
const body = (e as { data?: RefusalBody }).data
|
|
220
|
-
const issues = body?.issues?.map((i) => (i.path?.length ? `${i.path.join('.')}: ${i.message}` : i.message)).filter(Boolean)
|
|
221
|
-
return issues?.length ? issues.join(' · ') : (body?.error ?? describeApiError(e))
|
|
222
|
-
}
|
|
223
|
-
|
|
224
165
|
async function onSave() {
|
|
225
166
|
const s = selected.value
|
|
226
167
|
if (!s) return
|
|
@@ -247,7 +188,7 @@ async function onSave() {
|
|
|
247
188
|
await fieldErrors.setError('name', t('dms_automation.templates.nameTaken'))
|
|
248
189
|
return
|
|
249
190
|
}
|
|
250
|
-
|
|
191
|
+
presentError(e, { fallbackKey: 'dms_automation.templates.saveError' })
|
|
251
192
|
} finally {
|
|
252
193
|
saving.value = false
|
|
253
194
|
}
|
|
@@ -269,7 +210,7 @@ async function onDelete() {
|
|
|
269
210
|
await usagesRead.refresh()
|
|
270
211
|
const fresh = usagesRead.data.value
|
|
271
212
|
if (usagesRead.error.value || !fresh) {
|
|
272
|
-
|
|
213
|
+
presentError(usagesRead.error.value, { fallbackKey: 'dms_automation.templates.deleteError' })
|
|
273
214
|
return
|
|
274
215
|
}
|
|
275
216
|
const count = fresh.procedures.length + fresh.templates.length
|
|
@@ -285,11 +226,8 @@ async function onDelete() {
|
|
|
285
226
|
await $authFetch(`${props.apiUrl}/templates/${s._id}?force=1`, { method: 'DELETE' })
|
|
286
227
|
} catch (e) {
|
|
287
228
|
const kept = errorCode(e) === 'fork-incomplete'
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
description: kept ? t('dms_automation.templates.forkIncompleteHint') : errorMessage(e),
|
|
291
|
-
color: 'error',
|
|
292
|
-
icon: 'i-ph-warning',
|
|
229
|
+
presentError(e, {
|
|
230
|
+
fallbackKey: kept ? 'dms_automation.templates.forkIncompleteHint' : 'dms_automation.templates.deleteError',
|
|
293
231
|
})
|
|
294
232
|
await usagesRead.refresh()
|
|
295
233
|
return
|
|
@@ -311,14 +249,6 @@ function ownersOf(found: TemplateUsages): string {
|
|
|
311
249
|
].filter(Boolean)
|
|
312
250
|
return parts.length === 2 ? t('dms_automation.templates.ownersAnd', { first: parts[0], second: parts[1] }) : parts[0]!
|
|
313
251
|
}
|
|
314
|
-
|
|
315
|
-
function schemaTypeOf(p: TemplatePort): string {
|
|
316
|
-
if (p.kind !== 'data') return '—'
|
|
317
|
-
const type = p.schema?.type
|
|
318
|
-
if (typeof type === 'string') return type
|
|
319
|
-
if (Array.isArray(type)) return type.join(' | ')
|
|
320
|
-
return 'any'
|
|
321
|
-
}
|
|
322
252
|
</script>
|
|
323
253
|
|
|
324
254
|
<template>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
3
|
+
import type { DmsVitePluginEntry } from "#dms/frontend-build";
|
|
4
|
+
|
|
5
|
+
type VitePlugin = Extract<DmsVitePluginEntry, { name: string }>;
|
|
6
|
+
|
|
7
|
+
const BACKEND_PACKAGE = "@antelopejs/dms-automation";
|
|
8
|
+
const BACKEND_SOURCE = "src";
|
|
9
|
+
const QUERY_OR_HASH = /[?#].*$/;
|
|
10
|
+
|
|
11
|
+
const backendRoots = new Map<string, string | null>();
|
|
12
|
+
|
|
13
|
+
/** Whether a parsed manifest names its package. */
|
|
14
|
+
function isNamedManifest(value: unknown): value is { name: string } {
|
|
15
|
+
return (
|
|
16
|
+
typeof value === "object" &&
|
|
17
|
+
value !== null &&
|
|
18
|
+
"name" in value &&
|
|
19
|
+
typeof value.name === "string"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The package name a `package.json` declares, or `undefined`. */
|
|
24
|
+
function packageName(manifest: string): string | undefined {
|
|
25
|
+
try {
|
|
26
|
+
const parsed: unknown = JSON.parse(readFileSync(manifest, "utf8"));
|
|
27
|
+
return isNamedManifest(parsed) ? parsed.name : undefined;
|
|
28
|
+
} catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The directory of the backend package that holds `directory`, or null. */
|
|
34
|
+
function backendRoot(directory: string): string | null {
|
|
35
|
+
const known = backendRoots.get(directory);
|
|
36
|
+
if (known !== undefined) {
|
|
37
|
+
return known;
|
|
38
|
+
}
|
|
39
|
+
const manifest = join(directory, "package.json");
|
|
40
|
+
const parent = dirname(directory);
|
|
41
|
+
let root: string | null = null;
|
|
42
|
+
if (existsSync(manifest)) {
|
|
43
|
+
root = packageName(manifest) === BACKEND_PACKAGE ? directory : null;
|
|
44
|
+
} else if (parent !== directory) {
|
|
45
|
+
root = backendRoot(parent);
|
|
46
|
+
}
|
|
47
|
+
backendRoots.set(directory, root);
|
|
48
|
+
return root;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The real path of a resolved module id when it lies under the `src`
|
|
53
|
+
* directory of the backend package, or `undefined`. The package that owns the
|
|
54
|
+
* file decides, not a path, so the answer is the same in the repository and in
|
|
55
|
+
* the build workspace. Virtual ids and ids that are not files are ignored.
|
|
56
|
+
*/
|
|
57
|
+
function backendSourceFile(id: string): string | undefined {
|
|
58
|
+
const path = id.replace(QUERY_OR_HASH, "");
|
|
59
|
+
if (!isAbsolute(path)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
let real: string;
|
|
63
|
+
try {
|
|
64
|
+
real = realpathSync(path);
|
|
65
|
+
} catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const root = backendRoot(dirname(real));
|
|
69
|
+
if (root === null) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return relative(root, real).split(sep)[0] === BACKEND_SOURCE
|
|
73
|
+
? real
|
|
74
|
+
: undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Fails the build and the dev server when a module of the frontend resolves to
|
|
79
|
+
* a file under the `src` of the backend package: the browser reaches the
|
|
80
|
+
* backend only through its HTTP interface. It checks what the whole resolution
|
|
81
|
+
* chain returns, an id marked external included, so an alias is seen through
|
|
82
|
+
* and a symlink the resolver returns is followed to its real path, and it runs
|
|
83
|
+
* before the other plugins (`enforce: "pre"`). Vite builds workers with their
|
|
84
|
+
* own plugin list, so the plugin adds itself there too.
|
|
85
|
+
*
|
|
86
|
+
* antelopejs-sync writes this file from `@antelopejs/tooling-configs` and
|
|
87
|
+
* restores it on every run: change the plugin in the pack, not here.
|
|
88
|
+
*/
|
|
89
|
+
export function backendBoundary(): VitePlugin {
|
|
90
|
+
return {
|
|
91
|
+
...boundaryCheck(),
|
|
92
|
+
config: () => ({ worker: { plugins: () => [boundaryCheck()] } }),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The check alone, as a worker build runs it. */
|
|
97
|
+
function boundaryCheck(): VitePlugin {
|
|
98
|
+
return {
|
|
99
|
+
name: `${BACKEND_PACKAGE}:backend-boundary`,
|
|
100
|
+
enforce: "pre",
|
|
101
|
+
async resolveId(source, importer, options) {
|
|
102
|
+
const resolved = await this.resolve(source, importer, {
|
|
103
|
+
...options,
|
|
104
|
+
skipSelf: true,
|
|
105
|
+
});
|
|
106
|
+
if (resolved === null) {
|
|
107
|
+
return resolved;
|
|
108
|
+
}
|
|
109
|
+
const file = backendSourceFile(resolved.id);
|
|
110
|
+
if (file === undefined) {
|
|
111
|
+
return resolved;
|
|
112
|
+
}
|
|
113
|
+
const from =
|
|
114
|
+
importer === undefined
|
|
115
|
+
? "an entry point"
|
|
116
|
+
: importer.replace(QUERY_OR_HASH, "");
|
|
117
|
+
return this.error(
|
|
118
|
+
`Backend boundary: ${from} imports ${file}, which is under the src of ${BACKEND_PACKAGE}. The frontend reaches the backend only through its HTTP interface.`,
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { defineDmsFrontendBuild } from "#dms/frontend-build";
|
|
2
|
+
import { backendBoundary } from "./build/backend-boundary.ts";
|
|
2
3
|
|
|
3
4
|
// The layer's public helpers, auto-imported in its own components: nothing is
|
|
4
5
|
// auto-imported from a module that does not list its folders here.
|
|
5
6
|
export default defineDmsFrontendBuild((build) => {
|
|
6
7
|
build.registerAutoImports(["app/composables", "app/utils"]);
|
|
8
|
+
build.registerVitePlugins(() => [backendBoundary()]);
|
|
7
9
|
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const BLANK = /^\s*$/;
|
|
2
|
+
const ROW_TOKEN = /\{\{[^}]*\}\}/g;
|
|
3
|
+
const BARE_BRACES = /\{[^}]*\}/;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The end of what precedes `element` in its parent: the previous sibling that
|
|
7
|
+
* is not blank text, or the parent's start tag.
|
|
8
|
+
*/
|
|
9
|
+
function precedingEnd(element) {
|
|
10
|
+
const siblings = element.parent.children;
|
|
11
|
+
const index = siblings.indexOf(element);
|
|
12
|
+
const previous = siblings
|
|
13
|
+
.slice(0, index)
|
|
14
|
+
.reverse()
|
|
15
|
+
.find((node) => !(node.type === "VText" && BLANK.test(node.value)));
|
|
16
|
+
return previous ? previous.range[1] : element.parent.startTag.range[1];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A comment between the branches of a `v-if` chain hydrates with a mismatch:
|
|
21
|
+
* the development compiler moves it into the next branch, which then renders
|
|
22
|
+
* as a fragment, while the server's production compile drops it and renders
|
|
23
|
+
* the bare element.
|
|
24
|
+
*/
|
|
25
|
+
const noCommentBeforeElse = {
|
|
26
|
+
meta: {
|
|
27
|
+
type: "problem",
|
|
28
|
+
schema: [],
|
|
29
|
+
messages: {
|
|
30
|
+
misplaced:
|
|
31
|
+
"A template comment before `v-else-if` or `v-else` hydrates with a mismatch. Put it inside the branch's element, or into the script.",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
create(context) {
|
|
35
|
+
const { defineTemplateBodyVisitor } = context.sourceCode.parserServices;
|
|
36
|
+
if (!defineTemplateBodyVisitor) return {};
|
|
37
|
+
const comments = context.sourceCode.ast.templateBody?.comments ?? [];
|
|
38
|
+
return defineTemplateBodyVisitor({
|
|
39
|
+
VElement(element) {
|
|
40
|
+
const continues = element.startTag.attributes.some(
|
|
41
|
+
(attribute) =>
|
|
42
|
+
attribute.directive &&
|
|
43
|
+
(attribute.key.name.name === "else" ||
|
|
44
|
+
attribute.key.name.name === "else-if"),
|
|
45
|
+
);
|
|
46
|
+
if (!continues) return;
|
|
47
|
+
const from = precedingEnd(element);
|
|
48
|
+
for (const comment of comments) {
|
|
49
|
+
if (comment.range[0] >= from && comment.range[1] <= element.range[0])
|
|
50
|
+
context.report({ loc: comment.loc, messageId: "misplaced" });
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** The `confirmFrom` call a node makes, if it does. */
|
|
58
|
+
function isConfirmFromCall(node) {
|
|
59
|
+
const { callee } = node;
|
|
60
|
+
return (
|
|
61
|
+
(callee.type === "Identifier" && callee.name === "confirmFrom") ||
|
|
62
|
+
(callee.type === "MemberExpression" &&
|
|
63
|
+
!callee.computed &&
|
|
64
|
+
callee.property.name === "confirmFrom")
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The host's `confirmFrom(url, ...)` fills only the `{{row.X}}` tokens of the
|
|
70
|
+
* URL from its `params`. Any other token (`{id}`) reaches the API as it is,
|
|
71
|
+
* `%7Bid%7D`, and the dialog never opens.
|
|
72
|
+
*/
|
|
73
|
+
const confirmFromRowTokens = {
|
|
74
|
+
meta: {
|
|
75
|
+
type: "problem",
|
|
76
|
+
schema: [],
|
|
77
|
+
messages: {
|
|
78
|
+
bareToken:
|
|
79
|
+
"`confirmFrom` fills only `{{row.X}}` tokens: write the fill-in of this URL as one, or interpolate it.",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
create(context) {
|
|
83
|
+
const check = (node) => {
|
|
84
|
+
const [url] = node.arguments;
|
|
85
|
+
if (!isConfirmFromCall(node) || url?.type !== "TemplateLiteral") return;
|
|
86
|
+
const text = url.quasis.map((part) => part.value.raw).join("");
|
|
87
|
+
if (BARE_BRACES.test(text.replace(ROW_TOKEN, "")))
|
|
88
|
+
context.report({ node: url, messageId: "bareToken" });
|
|
89
|
+
};
|
|
90
|
+
const { defineTemplateBodyVisitor } = context.sourceCode.parserServices;
|
|
91
|
+
const script = { CallExpression: check };
|
|
92
|
+
return defineTemplateBodyVisitor
|
|
93
|
+
? defineTemplateBodyVisitor(script, script)
|
|
94
|
+
: script;
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default {
|
|
99
|
+
rules: {
|
|
100
|
+
"no-comment-before-else": noCommentBeforeElse,
|
|
101
|
+
"confirm-from-row-tokens": confirmFromRowTokens,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
@@ -2,11 +2,16 @@ import eslint from "@eslint/js";
|
|
|
2
2
|
import ts from "typescript-eslint";
|
|
3
3
|
import vue from "eslint-plugin-vue";
|
|
4
4
|
import globals from "globals";
|
|
5
|
+
import automation from "./eslint-rules/index.mjs";
|
|
5
6
|
|
|
6
7
|
export default ts.config(
|
|
7
8
|
{ ignores: ["dist/**", "node_modules/**"] },
|
|
8
9
|
eslint.configs.recommended,
|
|
9
10
|
...vue.configs["flat/essential"],
|
|
11
|
+
{
|
|
12
|
+
files: ["tests/**/*.cjs"],
|
|
13
|
+
languageOptions: { globals: globals.node },
|
|
14
|
+
},
|
|
10
15
|
{
|
|
11
16
|
files: ["**/*.{ts,vue}"],
|
|
12
17
|
languageOptions: {
|
|
@@ -21,4 +26,14 @@ export default ts.config(
|
|
|
21
26
|
},
|
|
22
27
|
},
|
|
23
28
|
{ files: ["**/*.ts"], languageOptions: { parser: ts.parser } },
|
|
29
|
+
{
|
|
30
|
+
files: ["app/**/*.{ts,vue}"],
|
|
31
|
+
plugins: { automation },
|
|
32
|
+
rules: { "automation/confirm-from-row-tokens": "error" },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
files: ["app/**/*.vue"],
|
|
36
|
+
plugins: { automation },
|
|
37
|
+
rules: { "automation/no-comment-before-else": "error" },
|
|
38
|
+
},
|
|
24
39
|
);
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"build": "pnpm --dir \"${DMS_FRONTEND_WORKSPACE:?Set DMS_FRONTEND_WORKSPACE to the generated Inertia workspace}\" build",
|
|
9
9
|
"typecheck": "pnpm --dir \"${DMS_FRONTEND_WORKSPACE:?Set DMS_FRONTEND_WORKSPACE to the generated Inertia workspace}\" typecheck",
|
|
10
10
|
"format": "prettier --write .",
|
|
11
|
-
"
|
|
11
|
+
"test": "node --test tests/*.test.cjs",
|
|
12
|
+
"lint": "eslint . --max-warnings=3 && node node_modules/@antelopejs/dms/frontend-vue/scripts/check-api-error-presentation.mjs app",
|
|
12
13
|
"lint:fix": "eslint . --fix"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
@@ -16,9 +17,9 @@
|
|
|
16
17
|
"vue": "^3.5.18"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@antelopejs/dms": ">=0.
|
|
20
|
-
"@antelopejs/dms-frontend": ">=0.
|
|
21
|
-
"@antelopejs/tooling-configs": ">=0.
|
|
20
|
+
"@antelopejs/dms": ">=0.16.0 <1.0.0",
|
|
21
|
+
"@antelopejs/dms-frontend": ">=0.10.0 <0.11.0",
|
|
22
|
+
"@antelopejs/tooling-configs": ">=0.2.18 <1.0.0",
|
|
22
23
|
"@eslint/js": "^9.0.0",
|
|
23
24
|
"@nuxt/ui": "4.10.0",
|
|
24
25
|
"eslint": "^9.0.0",
|
|
@@ -28,10 +29,12 @@
|
|
|
28
29
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
29
30
|
"typescript": "^5.8.2",
|
|
30
31
|
"typescript-eslint": "^8.0.0",
|
|
32
|
+
"vite": "^8.3.4",
|
|
33
|
+
"vue-eslint-parser": "^10.3.0",
|
|
31
34
|
"vue-tsc": "^3.1.1"
|
|
32
35
|
},
|
|
33
36
|
"engines": {
|
|
34
|
-
"@antelopejs/dms-frontend": ">=0.
|
|
37
|
+
"@antelopejs/dms-frontend": ">=0.10.0 <0.11.0"
|
|
35
38
|
},
|
|
36
39
|
"packageManager": "pnpm@10.6.5"
|
|
37
40
|
}
|