@protobase/ui 0.113.0 → 0.114.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/dist/account/messages.d.ts +2 -2
- package/dist/app/app.d.ts +4 -1
- package/dist/app/app.js +9 -7
- package/dist/app/change-confirm/messages.d.ts +2 -2
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/displays/virtual-cards.js +1 -0
- package/dist/app/embedded-list/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/first-frame.d.ts +13 -0
- package/dist/app/first-frame.js +23 -0
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/gallery-layout.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/index.html +0 -17
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/main.js +19 -7
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-mode/shown-layout.d.ts +1 -1
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/record-row/record-row.d.ts +3 -2
- package/dist/app/record-row/record-row.js +43 -27
- package/dist/app/record-row/row-window.d.ts +11 -0
- package/dist/app/record-row/row-window.js +15 -2
- package/dist/app/refresh-mark.d.ts +2 -1
- package/dist/app/refresh-mark.js +3 -1
- package/dist/app/related-cards/messages.d.ts +2 -2
- package/dist/app/reveal-when-loaded.d.ts +8 -2
- package/dist/app/reveal-when-loaded.js +12 -5
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app/splash-hold.d.ts +0 -1
- package/dist/app/splash-hold.js +1 -1
- package/dist/app/start-screen.d.ts +0 -9
- package/dist/app/start-screen.js +1 -10
- package/dist/app/ui-ready.d.ts +11 -0
- package/dist/app/ui-ready.js +12 -0
- package/dist/app-shell/app-shell.js +3 -1
- package/dist/app-shell/close-sidebar.d.ts +10 -0
- package/dist/app-shell/close-sidebar.js +17 -0
- package/dist/app-shell/drawer.d.ts +7 -1
- package/dist/app-shell/drawer.js +26 -7
- package/dist/app-shell/index.d.ts +2 -1
- package/dist/app-shell/index.js +2 -1
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/app-shell/top-bar.js +4 -4
- package/dist/assistant-dock/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/calls/messages.d.ts +2 -2
- package/dist/compact-table/messages.d.ts +2 -2
- package/dist/data/query-keys.d.ts +6 -0
- package/dist/data/query-keys.js +10 -0
- package/dist/data/start-cache/cached-plugins.d.ts +6 -0
- package/dist/data/start-cache/cached-plugins.js +10 -0
- package/dist/data-grid/column-spec.d.ts +1 -1
- package/dist/data-grid/data-grid.js +1 -0
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/data-grid/row-source.d.ts +5 -0
- package/dist/data-grid/use-paged-rows.d.ts +5 -3
- package/dist/data-grid/use-paged-rows.js +21 -6
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/focus-page/messages.d.ts +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/live/grid-loader.d.ts +1 -0
- package/dist/live/grid-loader.js +3 -1
- package/dist/live/use-live-rows.js +1 -0
- package/dist/mailbox/messages.d.ts +2 -2
- package/dist/mocks/customers.d.ts +1 -1
- package/dist/mocks/invoices.d.ts +1 -1
- package/dist/mocks/orders.d.ts +3 -3
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/members-page.js +13 -7
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/organizations/use-organizations.d.ts +4 -1
- package/dist/organizations/use-organizations.js +25 -19
- package/dist/package.js +1 -1
- package/dist/plugins/plugin-source.d.ts +24 -4
- package/dist/plugins/plugin-source.js +48 -14
- package/dist/plugins/use-plugin-loads.d.ts +3 -1
- package/dist/plugins/use-plugin-loads.js +24 -7
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/primitives/skeleton.js +1 -0
- package/dist/record-view/messages.d.ts +2 -2
- package/dist/roles/use-active-role.d.ts +4 -1
- package/dist/roles/use-active-role.js +18 -13
- package/dist/shell/assets/api-provider-BJJrOoO4.js +2 -0
- package/dist/shell/assets/app-VoTi41IN.js +16 -0
- package/dist/shell/assets/badge-OU9hb6yQ.js +2 -0
- package/dist/shell/assets/checkbox-DFfK432Y.js +2 -0
- package/dist/shell/assets/createLucideIcon-DGm8SdFI.js +2 -0
- package/dist/shell/assets/display-value-CIH2qfgQ.js +2 -0
- package/dist/shell/assets/{field-badge-3QmjR1r3.js → field-badge-DX2Mc_fH.js} +2 -2
- package/dist/shell/assets/{graph-view-BcbWbnHO.js → graph-view-CY9LPr0B.js} +2 -2
- package/dist/shell/assets/{html-viewer-tGtSpy9M.js → html-viewer-BPGMH_GA.js} +2 -2
- package/dist/shell/assets/{in-place-form-B0EkP4B1.js → in-place-form-RWSQGEg4.js} +2 -2
- package/dist/shell/assets/index-Bzb-O7ER.js +2 -0
- package/dist/shell/assets/index-HnFovy2Q.css +2 -0
- package/dist/shell/assets/{intl-cache-bXVNV0Yq.js → intl-cache-D4doUjK1.js} +2 -2
- package/dist/shell/assets/{lib-d3-interpolate-Cl0dHO4f.js → lib-d3-interpolate-D3u38iyJ.js} +2 -2
- package/dist/shell/assets/{lib-d3-transition-DUHAGQ8z.js → lib-d3-transition-BUpPvFvt.js} +2 -2
- package/dist/shell/assets/{lib-d3-zoom-gQh2osrj.js → lib-d3-zoom-BF7SPKNh.js} +2 -2
- package/dist/shell/assets/{lib-vis.gl-react-maplibre-CU7gWYjg.js → lib-vis.gl-react-maplibre-C7-0xNFC.js} +2 -2
- package/dist/shell/assets/{lib-xyflow-react-DGg_5r7u.js → lib-xyflow-react-CKyW7szC.js} +2 -2
- package/dist/shell/assets/maplibre-9ViQO48S.js +2 -0
- package/dist/shell/assets/{markdown-content-DHKbAJjx.js → markdown-content-DTB9RQDs.js} +2 -2
- package/dist/shell/assets/{record-map-nGRmsk6x.js → record-map-CVqCWtfe.js} +2 -2
- package/dist/shell/assets/{records-map-D2flyaz3.js → records-map-ClYSxrVR.js} +2 -2
- package/dist/shell/assets/{run-trace-view-DfrAPeum.js → run-trace-view-CN16MiXg.js} +2 -2
- package/dist/shell/assets/search-picker-BGpvJQRD.js +2 -0
- package/dist/shell/assets/shared-protobase-ui-BC8LqGQB.js +2 -0
- package/dist/shell/assets/step-catalog-CZY0ZpCC.js +2 -0
- package/dist/shell/assets/step-panel-DhD80lsJ.js +2 -0
- package/dist/shell/assets/use-app-address-B4Uk3nWy.js +2 -0
- package/dist/shell/assets/{use-meta-BqEqOLNe.js → use-meta-D5kYywHm.js} +2 -2
- package/dist/shell/assets/{use-sibling-page-CiuiG-Tz.js → use-sibling-page-BJ81HcOP.js} +3 -3
- package/dist/shell/assets/value-badge-Dpd8dRqq.js +2 -0
- package/dist/shell/assets/{vendor-WWp_xlp2.js → vendor-3etemhgS.js} +4 -4
- package/dist/shell/assets/{workflow-canvas-DMP7SDWX.js → workflow-canvas-C1nGpi5w.js} +2 -2
- package/dist/shell/assets/{workflow-graph-editor-xpV8_qEl.js → workflow-graph-editor-DAJa4lq6.js} +2 -2
- package/dist/shell/assets/workflow-workbench-HramVZEJ.js +4 -0
- package/dist/shell/assets/{workflows-Bku4o2su.js → workflows-DlvOln9v.js} +2 -2
- package/dist/shell/assets/{workflows-start-kl7rSSay.js → workflows-start-QUKfwFqf.js} +2 -2
- package/dist/shell/index.html +16 -19
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/api-provider-BJJrOoO4.js.map +1 -0
- package/dist/shell-source-maps/assets/app-VoTi41IN.js.map +1 -0
- package/dist/shell-source-maps/assets/{badge-ChHXC28D.js.map → badge-OU9hb6yQ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{checkbox-COOOlJPG.js.map → checkbox-DFfK432Y.js.map} +1 -1
- package/dist/shell-source-maps/assets/createLucideIcon-DGm8SdFI.js.map +1 -0
- package/dist/shell-source-maps/assets/display-value-CIH2qfgQ.js.map +1 -0
- package/dist/shell-source-maps/assets/{field-badge-3QmjR1r3.js.map → field-badge-DX2Mc_fH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-BcbWbnHO.js.map → graph-view-CY9LPr0B.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-tGtSpy9M.js.map → html-viewer-BPGMH_GA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{in-place-form-B0EkP4B1.js.map → in-place-form-RWSQGEg4.js.map} +1 -1
- package/dist/shell-source-maps/assets/index-Bzb-O7ER.js.map +1 -0
- package/dist/shell-source-maps/assets/{intl-cache-bXVNV0Yq.js.map → intl-cache-D4doUjK1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-d3-interpolate-Cl0dHO4f.js.map → lib-d3-interpolate-D3u38iyJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-d3-transition-DUHAGQ8z.js.map → lib-d3-transition-BUpPvFvt.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-d3-zoom-gQh2osrj.js.map → lib-d3-zoom-BF7SPKNh.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-vis.gl-react-maplibre-CU7gWYjg.js.map → lib-vis.gl-react-maplibre-C7-0xNFC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-xyflow-react-DGg_5r7u.js.map → lib-xyflow-react-CKyW7szC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-Y7X50Jfk.js.map → maplibre-9ViQO48S.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-DHKbAJjx.js.map → markdown-content-DTB9RQDs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-nGRmsk6x.js.map → record-map-CVqCWtfe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-D2flyaz3.js.map → records-map-ClYSxrVR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-DfrAPeum.js.map → run-trace-view-CN16MiXg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{search-picker-CJcJetBh.js.map → search-picker-BGpvJQRD.js.map} +1 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-BC8LqGQB.js.map +1 -0
- package/dist/shell-source-maps/assets/{step-catalog-ZvQOXfSh.js.map → step-catalog-CZY0ZpCC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-B1yHz7OC.js.map → step-panel-DhD80lsJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-app-address-B6k3dkV0.js.map → use-app-address-B4Uk3nWy.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-meta-BqEqOLNe.js.map → use-meta-D5kYywHm.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-sibling-page-CiuiG-Tz.js.map → use-sibling-page-BJ81HcOP.js.map} +1 -1
- package/dist/shell-source-maps/assets/{value-badge-BKLV4otJ.js.map → value-badge-Dpd8dRqq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{vendor-WWp_xlp2.js.map → vendor-3etemhgS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-DMP7SDWX.js.map → workflow-canvas-C1nGpi5w.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-xpV8_qEl.js.map → workflow-graph-editor-DAJa4lq6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-Djdd_ODh.js.map → workflow-workbench-HramVZEJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflows-Bku4o2su.js.map → workflows-DlvOln9v.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflows-start-kl7rSSay.js.map → workflows-start-QUKfwFqf.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/styles.css +14 -0
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
- package/dist/app/hold-start-for-first-loads.d.ts +0 -12
- package/dist/app/hold-start-for-first-loads.js +0 -43
- package/dist/shell/assets/api-provider-CcDtTh0D.js +0 -2
- package/dist/shell/assets/app-DG30qs8Q.js +0 -16
- package/dist/shell/assets/badge-ChHXC28D.js +0 -2
- package/dist/shell/assets/checkbox-COOOlJPG.js +0 -2
- package/dist/shell/assets/display-value-fDiKbfJO.js +0 -2
- package/dist/shell/assets/index-BkCaPeOq.css +0 -2
- package/dist/shell/assets/index-CZ013UoE.js +0 -2
- package/dist/shell/assets/maplibre-Y7X50Jfk.js +0 -2
- package/dist/shell/assets/messages-ClKBpZlk.js +0 -2
- package/dist/shell/assets/search-picker-CJcJetBh.js +0 -2
- package/dist/shell/assets/shared-protobase-ui-CVwqj5Cp.js +0 -2
- package/dist/shell/assets/step-catalog-ZvQOXfSh.js +0 -2
- package/dist/shell/assets/step-panel-B1yHz7OC.js +0 -2
- package/dist/shell/assets/use-app-address-B6k3dkV0.js +0 -2
- package/dist/shell/assets/value-badge-BKLV4otJ.js +0 -2
- package/dist/shell/assets/workflow-workbench-Djdd_ODh.js +0 -4
- package/dist/shell-source-maps/assets/api-provider-CcDtTh0D.js.map +0 -1
- package/dist/shell-source-maps/assets/app-DG30qs8Q.js.map +0 -1
- package/dist/shell-source-maps/assets/display-value-fDiKbfJO.js.map +0 -1
- package/dist/shell-source-maps/assets/index-CZ013UoE.js.map +0 -1
- package/dist/shell-source-maps/assets/messages-ClKBpZlk.js.map +0 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-CVwqj5Cp.js.map +0 -1
package/dist/shell-source-maps/assets/{workflows-Bku4o2su.js.map → workflows-DlvOln9v.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows-Bku4o2su.js","names":["isObject","Ajv","n","a","t","templateExpressions","expressionReads","builtInFunctions","require_ajv","expressionSource","taskResource","innerMachine","orderOf","pinType","readText","blocksOutsideBlocks","inputSchema","tasksOutsideBlocks","customStepOf","limits","parse","referenceSchema","parseReference","argumentsOf","schemaAt","allStates","pinTypeText","fits","isObject$1","value","jsonPathFields","awsFields","stateProblems","states","name","state","where","path","found","field","message","config","inner","awsProblems","machine","definition","import_ajv","expression","errorNames","assign","retrier","schemaFor","sequence","order","common","flow","nextOrEnd","catcher","recovery","extra","required","type","properties","machineFields","flowStates","sequenceStates","definitionSchema","dataflowDefinitionSchema","fieldPath","parts","part","ajv","validators","located","all","pointer","index","error","data","choices","schemaProblems","validate","problems","seen","errors","text","branch","other","key","triggerProblems","input","trigger","unavailable","check","triggers","problem","stateExpressions","add","base","after","rule","assignedNames","names","edges","reachable","queue","edge","reachedFrom","stack","start","reservedVariables","contextReads","statesFields","startsWith","prefix","contextProblem","rest","read","token","steps","held","expressionParsed","parsed","source","readProblems","reads","firstOfItem","place","inBlock","visible","resources","usedConnections","types","connectionOf","connectionProblems","used","passedOn","own","along","visibleVariables","outer","later","target","variable","units","cacheSeconds","ttl","match","secretArguments","blockProblems","depth","nestingDepth","deepest","item","most","child","depthProblems","isObject","pinProblems","schemas","mismatch","reference","taken","walk","readsOf","innerNames","assigners","by","machineDependencies","dependencies","from","step","dependsOn","dependencyCycle","visit","next","dataflowVisible","dataflowProblems","first","earlier","cycle","missingArguments","needed","options","given","waitProblems","custom","waits","timeout","machineProblems","scope","reached","task","missing","wholeProblems","checkDefinition","bytes","deep","aws","shape","document","stepStatuses","compareOps","isConditionPart","side","plainStep","referenceOf","node","operandOf","chainOf","op","isRegex","partOf","sides","sideOf","pattern","operand","lhs","rhs","quoted","operandText","sideText","partText","parent","conditionValue","conditionParts","valueOf","selectOf","cases","at","test","when","then","otherwise","selectValue","selectParts","reachedAvoiding","avoid","readVariables","machineWarnings","warnings","assigned","warned","wait","reader","definitionWarnings","resultRead","heldBackLog"],"sources":["../../../../workflows/src/definition/check-aws.ts","../../../../workflows/src/definition/schema.ts","../../../../workflows/src/definition/problem.ts","../../../../workflows/src/definition/check-schema.ts","../../../../workflows/src/definition/check-trigger.ts","../../../../workflows/src/definition/expression-fields.ts","../../../../workflows/src/definition/graph.ts","../../../../workflows/src/definition/names.ts","../../../../workflows/src/definition/check-reads.ts","../../../../workflows/src/definition/used-connections.ts","../../../../workflows/src/definition/visible.ts","../../../../workflows/src/run/cache/cache-ttl.ts","../../../../workflows/src/definition/check-block.ts","../../../../workflows/src/nesting.ts","../../../../workflows/src/definition/depth-problems.ts","../../../../workflows/src/definition/pins/check-pins.ts","../../../../workflows/src/definition/dataflow/dependencies.ts","../../../../workflows/src/definition/dataflow/check-dataflow.ts","../../../../workflows/src/definition/check-definition.ts","../../../../workflows/src/definition/pins/conditions.ts","../../../../workflows/src/definition/check-warnings.ts","../../../../workflows/src/run/rerun.ts","../../../../workflows/src/run/replay.ts"],"sourcesContent":["import type { Problem } from './problem'\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\n// The fields of the States Language's JSONPath, which the named-reads profile writes in JSONata as Arguments, Output and Assign\nconst jsonPathFields = ['InputPath', 'Parameters', 'ResultSelector', 'ResultPath', 'OutputPath', 'ItemsPath']\n// What Step Functions runs that this app does not, by field\nconst awsFields: Record<string, string> = {\n ItemReader: \"is a distributed Map's reader, which does not run here; give the Map its Items\",\n ItemBatcher: \"is a distributed Map's batcher, which does not run here\",\n ResultWriter: \"is a distributed Map's writer, which does not run here\",\n ToleratedFailureCount: \"is a distributed Map's, which does not run here\",\n ToleratedFailurePercentage: \"is a distributed Map's, which does not run here\",\n Credentials: 'does not run here: a step signs in through the connection its type declares',\n}\n\nconst stateProblems = (states: unknown, path: string[]): Problem[] => {\n if (!isObject(states)) return []\n return Object.entries(states).flatMap(([name, state]): Problem[] => {\n if (!isObject(state)) return []\n const where = [...path, name].join('/')\n const found: Problem[] = []\n if (state.Type === 'Parallel') found.push({ state: where, field: 'Type', message: 'is Parallel, which does not run here yet; in data order, states that read nothing of each other run at once' })\n if (typeof state.Resource === 'string' && state.Resource.startsWith('arn:')) {\n found.push({ state: where, field: 'Resource', message: `is a Step Functions service (${state.Resource}), which does not run here: write the step with one of this app's step types, such as app:http for an HTTP request` })\n }\n for (const field of jsonPathFields) if (state[field] !== undefined) found.push({ state: where, field, message: 'is JSONPath, which does not run here; write the state in JSONata, with Arguments, Output and Assign' })\n for (const [field, message] of Object.entries(awsFields)) if (state[field] !== undefined) found.push({ state: where, field, message })\n const config = isObject(state.ItemProcessor) ? state.ItemProcessor.ProcessorConfig : undefined\n if (isObject(config) && config.Mode === 'DISTRIBUTED') found.push({ state: where, field: 'ItemProcessor.ProcessorConfig.Mode', message: 'is DISTRIBUTED, which does not run here; a Map runs its items inline' })\n for (const inner of ['ItemProcessor', 'Processor', 'Iterator']) if (isObject(state[inner])) found.push(...stateProblems((state[inner] as Record<string, unknown>).States, [...path, name]))\n return found\n })\n}\n\n/**\n * What a state machine from Step Functions holds that this app does not run, each named: JSONPath (its query\n * language by default), its service tasks, the HTTP task included, Parallel, a distributed Map, credentials and a whole-run\n * timeout. Empty for a machine this app can check further.\n */\nexport const awsProblems = (definition: unknown): Problem[] => {\n const machine = isObject(definition) && isObject(definition.stateMachine) ? definition.stateMachine : undefined\n if (!machine) return []\n const found: Problem[] = []\n if (machine.QueryLanguage !== 'JSONata') found.push({ field: 'stateMachine.QueryLanguage', message: `is ${machine.QueryLanguage === undefined ? 'missing, so the machine is JSONPath, the default of Step Functions' : JSON.stringify(machine.QueryLanguage)}; only JSONata machines run here: set \"QueryLanguage\": \"JSONata\" and write its states in JSONata` })\n if (machine.TimeoutSeconds !== undefined) found.push({ field: 'stateMachine.TimeoutSeconds', message: \"is a whole run's timeout, which does not run here; give each Task its TimeoutSeconds\" })\n return [...found, ...stateProblems(machine.States, [])]\n}\n","import { limits } from '../limits'\nimport type { Order } from './types'\n\nconst expression = { type: 'string', pattern: '^\\\\{%[\\\\s\\\\S]*%\\\\}$' }\nconst name = { type: 'string', minLength: 1, maxLength: 80 }\nconst errorNames = { type: 'array', minItems: 1, items: { type: 'string', minLength: 1 } }\nconst assign = { type: 'object', propertyNames: { pattern: '^[A-Za-z][A-Za-z0-9_]*$' } }\n\nconst retrier = {\n type: 'object',\n additionalProperties: false,\n required: ['ErrorEquals'],\n properties: {\n ErrorEquals: errorNames,\n IntervalSeconds: { type: 'integer', minimum: 1, maximum: limits.retryDelaySeconds },\n MaxAttempts: { type: 'integer', minimum: 0, maximum: limits.retryAttempts },\n BackoffRate: { type: 'number', minimum: 1, maximum: 10 },\n MaxDelaySeconds: { type: 'integer', minimum: 1, maximum: limits.retryDelaySeconds },\n },\n}\n\n/**\n * The JSON Schema of a workflow definition in one order: its trigger, and a state machine in the States Language with\n * JSONata expressions, in the named-reads profile. In sequence order every state names its `Next` or `End` and the\n * machine its `StartAt`, as the States Language has them; in data order none does, a state may have a `Condition`,\n * a catcher has no `Next`, and there is no Choice or Succeed. It checks the shape; `checkDefinition` also checks the\n * edges and what each expression reads.\n */\nconst schemaFor = (order: Order) => {\n const sequence = order === 'sequence'\n const common = { Type: {}, Comment: { type: 'string' }, Output: {}, Assign: assign, QueryLanguage: { const: 'JSONata' }, ...(!sequence && { Condition: expression }) }\n const flow = sequence ? { Next: name, End: { const: true } } : {}\n const nextOrEnd = sequence ? { oneOf: [{ required: ['Next'], not: { required: ['End'] } }, { required: ['End'], not: { required: ['Next'] } }] } : {}\n const catcher = { type: 'object', additionalProperties: false, required: ['ErrorEquals', ...(sequence ? ['Next'] : [])], properties: { ErrorEquals: errorNames, ...(sequence && { Next: name }), Output: {}, Assign: assign } }\n const recovery = { Retry: { type: 'array', items: retrier }, Catch: { type: 'array', items: catcher } }\n const state = (type: string, properties: Record<string, unknown>, { required = [], ...extra }: { required?: string[]; [key: string]: unknown } = {}) => ({\n type: 'object',\n additionalProperties: false,\n required: ['Type', ...required],\n ...extra,\n properties: { ...common, Type: { const: type }, ...properties },\n })\n const machine = sequence\n ? { type: 'object', required: ['StartAt', 'States'], properties: { StartAt: name, Comment: { type: 'string' }, States: { type: 'object', minProperties: 1, propertyNames: name, additionalProperties: { $ref: '#/definitions/state' } } } }\n : { type: 'object', required: ['States'], properties: { Comment: { type: 'string' }, States: { type: 'object', minProperties: 1, propertyNames: name, additionalProperties: { $ref: '#/definitions/state' } } } }\n // A state machine Step Functions exports may carry its Version, which runs nothing\n const machineFields = { ...(sequence && { StartAt: {} }), States: {}, Comment: {}, Version: { type: 'string' } }\n const flowStates = [\n state('Pass', flow, nextOrEnd),\n state('Task', { ...flow, ...recovery, Resource: name, Arguments: {}, TimeoutSeconds: { type: 'integer', minimum: 1, maximum: limits.waitingTaskTimeoutSeconds }, HeartbeatSeconds: { type: 'integer', minimum: 1, maximum: limits.waitingTaskTimeoutSeconds }, Cache: { type: 'boolean' } }, { required: ['Resource'], ...nextOrEnd }),\n state('Wait', { ...flow, Seconds: { anyOf: [{ type: 'integer', minimum: 0, maximum: limits.waitSeconds }, expression] }, Timestamp: { type: 'string' } }, {\n allOf: [nextOrEnd, { oneOf: [{ required: ['Seconds'] }, { required: ['Timestamp'] }] }],\n }),\n // Fail ends the run with an error, so it has no Output or Assign.\n { type: 'object', additionalProperties: false, required: ['Type'], properties: { Type: { const: 'Fail' }, Comment: { type: 'string' }, QueryLanguage: { const: 'JSONata' }, ...(!sequence && { Condition: expression }), Error: { type: 'string' }, Cause: { type: 'string' } } },\n state('Map', {\n ...flow,\n ...recovery,\n Items: {},\n ItemProcessor: { $ref: '#/definitions/processor' },\n MaxConcurrency: { type: 'integer', minimum: 0, maximum: limits.mapConcurrency },\n }, { required: ['ItemProcessor', 'Items'], ...nextOrEnd }),\n state('Block', {\n ...flow,\n ...recovery,\n Arguments: {},\n Processor: { $ref: '#/definitions/machine' },\n // Ttl's text is checked by checkDefinition, as a step type's cache time to live is.\n Cache: { type: 'object', additionalProperties: false, required: ['Ttl'], properties: { Ttl: { type: ['integer', 'string'] }, Key: {} } },\n }, { required: ['Processor', 'Cache'], ...nextOrEnd }),\n ]\n // A Choice goes on by its rules and a Succeed ends the run: in data order a Condition and the run's end say both.\n const sequenceStates = sequence\n ? [\n state('Choice', {\n Choices: {\n type: 'array',\n minItems: 1,\n items: { type: 'object', additionalProperties: false, required: ['Condition', 'Next'], properties: { Condition: expression, Next: name, Comment: { type: 'string' }, Output: {}, Assign: assign } },\n },\n Default: name,\n }, { required: ['Choices'] }),\n { type: 'object', additionalProperties: false, required: ['Type'], properties: { Type: { const: 'Succeed' }, Comment: { type: 'string' }, Output: {}, QueryLanguage: { const: 'JSONata' } } },\n ]\n : []\n return {\n $schema: 'http://json-schema.org/draft-07/schema#',\n $id: `https://docs.protobase.net/schemas/workflow-definition${sequence ? '' : '-data'}.json`,\n $ref: '#/definitions/definition',\n definitions: {\n machine,\n definition: {\n type: 'object',\n additionalProperties: false,\n required: ['trigger', 'stateMachine'],\n properties: { trigger: { $ref: '#/definitions/trigger' }, order: { enum: ['sequence', 'data'] }, stateMachine: { $ref: '#/definitions/stateMachine' }, connections: { $ref: '#/definitions/connections' }, trace: { enum: ['all', 'failed', 'none'] } },\n },\n // The account each connection `<plugin>:<connection>` the definition's types sign in with goes through, by its id.\n connections: {\n type: 'object',\n propertyNames: { pattern: '^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$' },\n additionalProperties: { type: 'string', minLength: 1, maxLength: 255 },\n },\n trigger: {\n type: 'object',\n minProperties: 1,\n maxProperties: 1,\n // `manual`, which takes no input, or a trigger type `<plugin>:<key>` with its input; the plugin's schema checks that.\n propertyNames: { pattern: '^(manual|[a-z][a-z0-9_]*:[a-z][a-z0-9_]*(\\\\.[a-z][a-z0-9_]*)*)$' },\n properties: { manual: { type: 'object', maxProperties: 0 } },\n additionalProperties: { type: 'object' },\n },\n stateMachine: {\n allOf: [{ $ref: '#/definitions/machine' }],\n required: ['QueryLanguage'],\n properties: { QueryLanguage: { const: 'JSONata' }, ...machineFields },\n additionalProperties: false,\n },\n processor: {\n allOf: [{ $ref: '#/definitions/machine' }],\n properties: { ProcessorConfig: { type: 'object', additionalProperties: false, properties: { Mode: { const: 'INLINE' } } }, ...machineFields },\n additionalProperties: false,\n },\n state: { type: 'object', required: ['Type'], discriminator: { propertyName: 'Type' }, oneOf: [...flowStates, ...sequenceStates] },\n },\n }\n}\n\n/** The JSON Schema of a workflow definition whose states run in sequence, the States Language's own order. */\nexport const definitionSchema = schemaFor('sequence')\n\n/** The JSON Schema of a workflow definition whose states run in the order their reads give: `\"order\": \"data\"`. */\nexport const dataflowDefinitionSchema = schemaFor('data')\n","/**\n * Why a definition cannot be saved. `state` is the state's path: its name, or names joined by `/` inside a Map's item\n * processor or a Parallel's branch (`Each/Fetch`, `Both/1/Mail`); `field` is the field within it, such as `Retry[0].IntervalSeconds`.\n */\nexport type Problem = { state?: string; field?: string; message: string }\n\n/** A problem as one line: `State \"Fetch\", field \"Arguments.url\": ...`. */\nexport const problemText = ({ state, field, message }: Problem) => {\n const where = [state !== undefined && `state \"${state}\"`, field !== undefined && `field \"${field}\"`].filter(Boolean).join(', ')\n if (!where) return message\n return `${where.charAt(0).toUpperCase()}${where.slice(1)}: ${message}`\n}\n\n/** A field path as `Retry[0].IntervalSeconds`. */\nexport const fieldPath = (parts: readonly (string | number)[]) =>\n parts.reduce<string>((path, part) => (typeof part === 'number' || /^\\d+$/.test(part) ? `${path}[${part}]` : path ? `${path}.${part}` : part), '')\n","import { Ajv, type ErrorObject } from 'ajv'\nimport { dataflowDefinitionSchema, definitionSchema } from './schema'\nimport { fieldPath, type Problem } from './problem'\n\nconst ajv = new Ajv({ allErrors: true, discriminator: true, strict: false })\nconst validators = { sequence: ajv.compile(definitionSchema), data: ajv.compile(dataflowDefinitionSchema) }\n\n// `/stateMachine/States/Each/ItemProcessor/States/Fetch/Retry/0` (or a Block's `Processor`) as the state `Each/Fetch` and its field `Retry[0]`;\n// `/trigger/schedule` as the field `trigger.schedule`.\nconst located = (pointer: string): Pick<Problem, 'state' | 'field'> => {\n const all = pointer.split('/').slice(1).map((part) => part.replaceAll('~1', '/').replaceAll('~0', '~'))\n const parts = all[0] === 'stateMachine' && all[1] === 'States' ? all.slice(1) : all\n const state: string[] = []\n let field: string[] = []\n for (let index = 0; index < parts.length; index++) {\n const part = parts[index]!\n if (part === 'States' && index + 1 < parts.length) {\n state.push(parts[++index]!)\n field = []\n } else if ((part === 'ItemProcessor' || part === 'Processor') && parts[index + 1] === 'States') {\n continue\n } else {\n field.push(part)\n }\n }\n return { ...(state.length > 0 && { state: state.join('/') }), ...(field.length > 0 && { field: fieldPath(field) }) }\n}\n\nconst message = (error: ErrorObject, data: boolean) => {\n if (error.keyword === 'additionalProperties' && data && ['Next', 'End', 'StartAt'].includes(String(error.params.additionalProperty))) return `${error.params.additionalProperty} is not a field in dataflow order, where a state runs once the states it reads from have ended`\n if (error.keyword === 'additionalProperties' && !data && error.params.additionalProperty === 'Condition') return 'Condition is a field only in dataflow order (\"order\": \"data\"); in sequence order a Choice decides'\n if (error.keyword === 'additionalProperties') return `${error.params.additionalProperty} is not a field here`\n if (error.keyword === 'required') return `${error.params.missingProperty} is missing`\n if (error.keyword === 'minItems') return `is missing; it needs at least ${String(error.params.limit)}`\n if (error.keyword === 'const') return `must be ${JSON.stringify(error.params.allowedValue)}`\n if (error.keyword === 'discriminator') return data ? 'must be one of Task, Pass, Map, Block, Wait and Fail; in dataflow order a Condition takes the place of Choice, and the run ends when no state is left to run' : 'must be one of Task, Choice, Pass, Map, Block, Wait, Succeed and Fail'\n if (error.keyword === 'pattern' && error.instancePath === '/trigger') return 'names a trigger type <plugin>:<key>, such as app:record, or manual'\n if (error.keyword === 'pattern' && error.instancePath.endsWith('/Assign')) return 'names a variable with letters, digits and _, starting with a letter'\n if (error.keyword === 'pattern') return 'must be an expression written as {% ... %}'\n if (error.keyword === 'maxProperties' && error.instancePath === '/trigger/manual') return 'takes no input'\n if (error.keyword === 'maxProperties' || error.keyword === 'minProperties') return error.instancePath === '/trigger' ? 'holds exactly one trigger: a trigger type such as app:record, or manual' : (error.message ?? 'is not valid')\n if (error.keyword === 'oneOf' && error.schemaPath.endsWith('/oneOf')) return 'needs exactly one of these'\n return error.message ?? 'is not valid'\n}\n\n// The `oneOf` of Next or End, Seconds or Timestamp, says only \"must match exactly one schema\": name the fields instead.\nconst choices: Record<string, string> = { Next: 'needs either Next or End', Seconds: 'needs either Seconds or Timestamp' }\n\n/** The ways a definition does not fit the schema of its order, each with the state and field it is about. */\nexport const schemaProblems = (definition: unknown): Problem[] => {\n const data = typeof definition === 'object' && definition !== null && (definition as { order?: unknown }).order === 'data'\n const validate = data ? validators.data : validators.sequence\n if (validate(definition)) return []\n const problems: Problem[] = []\n const seen = new Set<string>()\n const errors = validate.errors ?? []\n for (const error of errors) {\n // A \"required\" inside the oneOf of a state's Next or End only explains that oneOf's failure, reported in its place.\n if (error.keyword === 'required' && /(oneOf|allOf)\\/\\d+\\/oneOf\\/\\d+\\/required$/.test(error.schemaPath)) continue\n if (error.keyword === 'not') continue\n const where = { ...located(error.instancePath), ...(error.keyword === 'discriminator' && { field: 'Type' }) }\n let text = message(error, data)\n if (error.keyword === 'oneOf') {\n const branch = errors.find((other) => other.instancePath === error.instancePath && other.schemaPath.startsWith(error.schemaPath.replace(/\\/oneOf$/, '/oneOf/')) && other.keyword === 'required')\n text = choices[String(branch?.params.missingProperty)] ?? text\n }\n const key = `${where.state}|${where.field}|${text}`\n if (seen.has(key)) continue\n seen.add(key)\n problems.push({ ...where, message: text })\n }\n return problems\n}\n","import type { Problem } from './problem'\nimport type { Trigger } from './types'\n\n/** Checks a trigger type's input: each problem's field is relative to the input, such as `cron`. */\nexport type TriggerCheck = (input: Record<string, unknown>) => { field?: string; message: string }[]\n\n/**\n * What the schema cannot check of a trigger: that its type is one the app has and can run, `unavailable` holding why\n * it cannot by type, and its input against that type.\n */\nexport const triggerProblems = (trigger: Trigger, triggers: Readonly<Record<string, TriggerCheck>>, unavailable: Readonly<Record<string, string>> = {}): Problem[] => {\n const [type, input] = Object.entries(trigger)[0]!\n if (type === 'manual') return Object.keys(input).length === 0 ? [] : [{ field: 'trigger.manual', message: 'takes no input' }]\n if (Object.hasOwn(unavailable, type)) return [{ field: 'trigger', message: `\"${type}\" cannot run in this app: ${unavailable[type]}` }]\n const check = triggers[type]\n if (!check) return [{ field: 'trigger', message: `\"${type}\" is not a trigger type; use manual or one of ${Object.keys(triggers).join(', ')}` }]\n return check(input).map((problem) => ({ field: `trigger.${type}${problem.field ? `.${problem.field}` : ''}`, message: problem.message }))\n}\n","import { templateExpressions } from './expressions'\nimport { fieldPath } from './problem'\nimport type { State } from './types'\n\n/** Which `$states` field an expression may read where it is: the Task's, Map's or Block's result, a caught error. */\nexport type ExpressionPlace = 'state' | 'result' | 'error'\n\n/** Every expression of a state, with its field and the place it is evaluated in. */\nexport const stateExpressions = (state: State) => {\n const found: { field: string; source: string; place: ExpressionPlace }[] = []\n const add = (value: unknown, base: (string | number)[], place: ExpressionPlace) => {\n for (const { path, source } of templateExpressions(value, base)) found.push({ field: fieldPath(path), source, place })\n }\n // A Task or Map shapes its result with Output and Assign; the other states have no result.\n const after: ExpressionPlace = state.Type === 'Task' || state.Type === 'Map' || state.Type === 'Block' ? 'result' : 'state'\n // In dataflow order, before the state runs\n add(state.Condition, ['Condition'], 'state')\n if (state.Type === 'Fail') {\n add(state.Error, ['Error'], 'state')\n add(state.Cause, ['Cause'], 'state')\n return found\n }\n add(state.Output, ['Output'], after)\n if ('Assign' in state) add(state.Assign, ['Assign'], after)\n if (state.Type === 'Task') add(state.Arguments, ['Arguments'], 'state')\n if (state.Type === 'Map') add(state.Items, ['Items'], 'state')\n if (state.Type === 'Block') {\n add(state.Arguments, ['Arguments'], 'state')\n add(state.Cache?.Key, ['Cache', 'Key'], 'state')\n }\n if (state.Type === 'Wait') {\n add(state.Seconds, ['Seconds'], 'state')\n add(state.Timestamp, ['Timestamp'], 'state')\n }\n if (state.Type === 'Choice') {\n state.Choices.forEach((rule, index) => {\n add(rule.Condition, ['Choices', index, 'Condition'], 'state')\n add(rule.Output, ['Choices', index, 'Output'], 'state')\n add(rule.Assign, ['Choices', index, 'Assign'], 'state')\n })\n }\n if ('Catch' in state) {\n state.Catch?.forEach((catcher, index) => {\n add(catcher.Output, ['Catch', index, 'Output'], 'error')\n add(catcher.Assign, ['Catch', index, 'Assign'], 'error')\n })\n }\n return found\n}\n\n/** The variables a state assigns, in its own Assign, its choice rules' and its catchers'. */\nexport const assignedNames = (state: State) => {\n const names: string[] = []\n if ('Assign' in state && state.Assign) names.push(...Object.keys(state.Assign))\n if (state.Type === 'Choice') for (const rule of state.Choices) names.push(...Object.keys(rule.Assign ?? {}))\n if ('Catch' in state) for (const catcher of state.Catch ?? []) names.push(...Object.keys(catcher.Assign ?? {}))\n return names\n}\n","import type { Machine, State } from './types'\n\n/** The states a state may go to next, each with the field that names it. */\nexport const edges = (state: State): { field: string; target: string }[] => {\n const found: { field: string; target: string }[] = []\n if ('Next' in state && state.Next !== undefined) found.push({ field: 'Next', target: state.Next })\n if (state.Type === 'Choice') {\n state.Choices.forEach((rule, index) => found.push({ field: `Choices[${index}].Next`, target: rule.Next }))\n if (state.Default !== undefined) found.push({ field: 'Default', target: state.Default })\n }\n if ('Catch' in state) state.Catch?.forEach((catcher, index) => catcher.Next !== undefined && found.push({ field: `Catch[${index}].Next`, target: catcher.Next }))\n return found\n}\n\n/** The names of the states reached from `StartAt` along the edges. */\nexport const reachable = (machine: Machine) => {\n const seen = new Set<string>()\n const queue = [machine.StartAt]\n while (queue.length > 0) {\n const name = queue.pop()!\n const state = machine.States[name]\n if (seen.has(name) || !state) continue\n seen.add(name)\n for (const edge of edges(state)) queue.push(edge.target)\n }\n return seen\n}\n\n/** The states reached from `start` along the edges, `start` itself included. */\nexport const reachedFrom = (machine: Machine, start: string) => {\n const seen = new Set<string>()\n const stack = [start]\n while (stack.length > 0) {\n const name = stack.pop()!\n const state = machine.States[name]\n if (seen.has(name) || !state) continue\n seen.add(name)\n stack.push(...edges(state).map((edge) => edge.target))\n }\n return seen\n}\n","/** Variables a definition cannot assign: `$states`, which the runner gives each expression. */\nexport const reservedVariables = new Set(['states'])\n\n/**\n * What an expression may read of `$states.context`, as name paths: the run's input and start time, and a secret by its\n * name (`Secrets.<NAME>`, the name required).\n */\nexport const contextReads = [['Execution', 'Input'], ['Execution', 'StartTime'], ['Secrets']] as const\n","import { expressionReads } from './reads'\nimport { parse } from './expressions'\nimport { contextReads } from './names'\nimport type { ExpressionPlace } from './expression-fields'\nimport { limits } from '../limits'\n\n// What `$states` holds at each place beside its context: the Task's or Map's result after it ran, the error a catcher caught.\nconst statesFields: Record<ExpressionPlace, string> = { state: '', result: 'result', error: 'errorOutput' }\n\nconst startsWith = (path: readonly string[], prefix: readonly string[]) => prefix.every((name, index) => path[index] === name)\n\n// Why a read of `$states.context` is refused: the input, the start time and a secret by name are all it holds, in\n// dataflow order each state's status by its name, `steps`, and in a waiting Task's Arguments its try's token, `token`.\nconst contextProblem = (path: readonly string[], steps: ReadonlySet<string> | undefined, token: boolean) => {\n const rest = path.slice(1)\n if (startsWith(rest, ['Secrets'])) return rest.length >= 2 ? undefined : 'reads $states.context.Secrets as a whole; read one secret by its name, such as $states.context.Secrets.API_TOKEN'\n if (contextReads.some((read) => startsWith(rest, read))) return undefined\n if (startsWith(rest, ['Task'])) {\n if (!token) return \"reads $states.context.Task, which only the Arguments of a Task whose Resource ends in .waitForTaskToken read, as $states.context.Task.Token\"\n return startsWith(rest, ['Task', 'Token']) && rest.length === 2 ? undefined : 'reads $states.context.Task, whose only field is Token'\n }\n if (steps && startsWith(rest, ['Steps'])) {\n if (rest[1] === undefined) return 'reads $states.context.Steps as a whole; read one state\\'s status by its name, such as $states.context.Steps.Save.Status'\n return steps.has(rest[1]) ? undefined : `reads $states.context.Steps.${rest[1]}, but there is no state ${rest[1]} here or around it`\n }\n const held = steps ? 'Execution.Input, Execution.StartTime, Secrets.<NAME> and Steps.<state>' : 'Execution.Input, Execution.StartTime and Secrets.<NAME>'\n return `reads $states.${path.join('.')}; $states.context holds only ${held}`\n}\n\n/** The reads of an expression, or undefined when it does not parse. */\nexport const expressionParsed = (source: string) => {\n const parsed = parse(source)\n return 'error' in parsed ? undefined : expressionReads(parsed.expression)\n}\n\n/**\n * Why an expression breaks the named-reads profile, if it does: it must parse, read no implicit input, read\n * `$states.input` only in the first state of a Map's item processor, read of `$states.context` only the run's input,\n * start time and secrets by name (inside a Block, not the start time), with `token` a waiting Task's token too, and\n * read only variables a state that can run before it assigns.\n */\nexport const readProblems = (source: string, { place, visible, firstOfItem, inBlock = false, steps, token = false }: { place: ExpressionPlace; visible: ReadonlySet<string>; firstOfItem: boolean; inBlock?: boolean; steps?: ReadonlySet<string>; token?: boolean }) => {\n if (source.length > limits.expressionLength) return [`is ${source.length} characters long, more than the ${limits.expressionLength} an expression may be`]\n const parsed = parse(source)\n if ('error' in parsed) return [`does not parse: ${parsed.error.message}${parsed.error.position === undefined ? '' : ` (at character ${parsed.error.position})`}`]\n const reads = expressionReads(parsed.expression)\n const problems: string[] = []\n if (reads.input) problems.push(\"reads the state's input; read the run's input as $states.context.Execution.Input and an earlier result by the variable a state assigned it to\")\n for (const path of reads.states) {\n const [field = ''] = path\n if (field === 'input' && firstOfItem) continue\n if (field !== '' && field === statesFields[place]) continue\n if (field === 'context' && inBlock && startsWith(path, ['context', 'Execution', 'StartTime'])) problems.push(\"reads $states.context.Execution.StartTime, which inside a Block is its own run's start, not part of what it is cached by\")\n else if (field === 'context') {\n const problem = contextProblem(path, steps, token)\n if (problem) problems.push(problem)\n } else if (field === 'input') problems.push(\"reads $states.input, which only the first state of a Map's item processor may read (as the item)\")\n else if (field === '') problems.push('reads $states as a whole; read one of its fields')\n else problems.push(`reads $states.${field}, which is not there${place === 'state' ? '' : ` (here: $states.${statesFields[place]})`}`)\n }\n for (const name of reads.variables) if (!visible.has(name)) problems.push(`reads $${name}, which no state that can run before it assigns`)\n if (reads.evaluates) problems.push('uses $eval, whose reads cannot be checked')\n return [...new Set(problems)]\n}\n","import type { Problem } from './problem'\nimport { allStates } from './inner'\nimport { taskResource } from './task-resource'\nimport type { Definition, Machine } from './types'\n\n/** Every Task's step type, the ones inside Maps and Blocks too. */\nexport const resources = (machine: Machine): string[] => allStates(machine).flatMap(([, state]) => (state.Type === 'Task' ? [taskResource(state.Resource).type] : []))\n\n/**\n * The connections `<plugin>:<connection>` a definition's trigger and steps sign in with, given the connection each\n * type uses by its id (`connectionOf`).\n */\nexport const usedConnections = (definition: Definition, connectionOf: Readonly<Record<string, string>>) => {\n const types = [Object.keys(definition.trigger)[0]!, ...resources(definition.stateMachine)]\n return new Set(types.flatMap((type) => (Object.hasOwn(connectionOf, type) ? [connectionOf[type]!] : [])))\n}\n\n/** A binding in `connections` that none of the definition's types signs in with. */\nexport const connectionProblems = (definition: Definition, connectionOf: Readonly<Record<string, string>>): Problem[] => {\n const used = usedConnections(definition, connectionOf)\n return Object.keys(definition.connections ?? {})\n .filter((key) => !used.has(key))\n .map((key) => ({ field: `connections.${key}`, message: `no trigger or step of this workflow signs in with \"${key}\"; remove it` }))\n}\n","import { reachedFrom } from './graph'\nimport type { Machine, State } from './types'\n\n// The variables each edge of a state carries on, as the runner assigns them: a Choice rule's Assign (else the state's)\n// along its Next, the state's own along Next and Default, and a catcher's along its Next.\nconst passedOn = (state: State) => {\n const own = Object.keys(('Assign' in state && state.Assign) || {})\n const along: { target: string; names: string[] }[] = []\n if ('Next' in state && state.Next !== undefined) along.push({ target: state.Next, names: own })\n if (state.Type === 'Choice') {\n for (const rule of state.Choices) along.push({ target: rule.Next, names: Object.keys(rule.Assign ?? state.Assign ?? {}) })\n if (state.Default !== undefined) along.push({ target: state.Default, names: own })\n }\n if ('Catch' in state) for (const catcher of state.Catch ?? []) if (catcher.Next !== undefined) along.push({ target: catcher.Next, names: Object.keys(catcher.Assign ?? {}) })\n return along\n}\n\n/**\n * The variables each state of a machine may read: those of the outer scopes, and each one assigned on an edge some path\n * from `StartAt` takes before it. A state's own Assign takes effect from the next state on, and only along the edges\n * that assign it: a Choice rule's along its Next, a catcher's along its own.\n */\nexport const visibleVariables = (machine: Machine, outer: ReadonlySet<string>) => {\n const visible = new Map(Object.keys(machine.States).map((name) => [name, new Set(outer)]))\n for (const state of Object.values(machine.States)) {\n for (const { target, names } of passedOn(state)) {\n if (names.length === 0) continue\n for (const later of reachedFrom(machine, target)) for (const variable of names) visible.get(later)?.add(variable)\n }\n }\n return visible\n}\n","import { limits } from '../../limits'\n\nconst units: Record<string, number> = { second: 1, minute: 60, hour: 3600, day: 86_400 }\n\n/**\n * The seconds a cache entry serves, from a number of seconds or text such as `10 minutes`, at most\n * `limits.cacheMaxSeconds`; undefined for anything else, zero and below included, so such an entry is never written.\n */\nexport const cacheSeconds = (ttl: unknown): number | undefined => {\n if (typeof ttl === 'number') return Number.isFinite(ttl) && ttl >= 1 ? Math.min(Math.floor(ttl), limits.cacheMaxSeconds) : undefined\n if (typeof ttl !== 'string') return\n const match = /^(\\d+) (second|minute|hour|day)s?$/.exec(ttl.trim())\n if (!match) return\n return cacheSeconds(Number(match[1]) * units[match[2]!]!)\n}\n","import { cacheSeconds } from '../run/cache/cache-ttl'\nimport { limits } from '../limits'\nimport { templateExpressions } from './expressions'\nimport { fieldPath, type Problem } from './problem'\nimport { expressionParsed } from './check-reads'\nimport type { BlockState } from './types'\n\n// A secret passed to a block would be kept in its run's input: the block reads it itself, by name, when it runs.\nconst secretArguments = (state: BlockState, where: string): Problem[] =>\n [...templateExpressions(state.Arguments, ['Arguments']), ...templateExpressions(state.Cache.Key, ['Cache', 'Key'])].flatMap(({ path, source }) => {\n const reads = expressionParsed(source)\n if (!reads?.states.some((read) => read[0] === 'context' && read[1] === 'Secrets')) return []\n return [{ state: where, field: fieldPath(path), message: 'reads a secret, which a block would keep in its run; read it inside the block as $states.context.Secrets.<NAME>' }]\n })\n\n/**\n * Why a Block cannot be saved beside what every state is checked for: a time to live that is no duration of up to 30\n * days, Arguments or a Key that read a secret, and more Blocks around it than `limits.blockDepth`.\n */\nexport const blockProblems = (state: BlockState, where: string, depth: number): Problem[] => {\n const problems: Problem[] = []\n if (cacheSeconds(state.Cache.Ttl) === undefined) problems.push({ state: where, field: 'Cache.Ttl', message: `is no time to live: give seconds from 1, or text such as \"10 minutes\", \"1 hour\" or \"2 days\", at most ${limits.cacheMaxSeconds / 86_400} days` })\n if (depth > limits.blockDepth) problems.push({ state: where, message: `is inside ${depth - 1} other Blocks, more than the ${limits.blockDepth - 1} a Block may be in` })\n return [...problems, ...secretArguments(state, where)]\n}\n","/**\n * How deeply a value's arrays and objects nest, walked with a stack of its own so no value can overflow the call stack;\n * it stops counting once past `most`, returning `most + 1`.\n */\nexport const nestingDepth = (value: unknown, most: number) => {\n let deepest = 0\n const stack: [unknown, number][] = [[value, 0]]\n while (stack.length > 0) {\n const [item, depth] = stack.pop()!\n if (typeof item !== 'object' || item === null) continue\n if (depth + 1 > most) return most + 1\n deepest = Math.max(deepest, depth + 1)\n for (const child of Object.values(item)) stack.push([child, depth + 1])\n }\n return deepest\n}\n","import { limits } from '../limits'\nimport { nestingDepth } from '../nesting'\nimport type { Problem } from './problem'\n\n/** The problem of a definition, or a state machine, nesting past `limits.definitionDepth`, found without recursion; empty within it. */\nexport const depthProblems = (value: unknown): Problem[] => {\n if (nestingDepth(value, limits.definitionDepth) <= limits.definitionDepth) return []\n return [{ message: `The definition nests more than ${limits.definitionDepth} levels of arrays and objects` }]\n}\n","import type { Problem } from '../problem'\nimport type { Definition } from '../types'\nimport { pinType, fits, pinTypeText } from './pin-type'\nimport { argumentsOf, blocksOutsideBlocks, inputSchema, referenceSchema, tasksOutsideBlocks, type PinSchemas } from './pin-sources'\nimport { parseReference, readText } from './references'\nimport { schemaAt } from './resolve-schema'\n\ntype JsonSchema = Record<string, unknown>\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * Where a Task's argument, or a field at any depth of an argument written as an object, is one read by name of a value\n * whose type does not fit what the step type takes there, as a wire between pins of those types is refused: a problem\n * naming both. A read of a value of any type, or into an input of any type, fits.\n */\nexport const pinProblems = (definition: Definition, schemas: PinSchemas): Problem[] => [\n ...tasksOutsideBlocks(definition.stateMachine).flatMap(({ path, state }) => {\n const input = inputSchema(state, schemas)\n if (!input) return []\n const mismatch = (value: unknown, target: JsonSchema | undefined, field: string[]): Problem[] => {\n const reference = parseReference(value)\n if (!reference || !target) return []\n const source = pinType(referenceSchema(definition, reference, schemas))\n const taken = pinType(target)\n if (fits(source, taken)) return []\n return [{ state: path, field: ['Arguments', ...field].join('.'), message: `reads ${readText(reference)}, ${pinTypeText(source)}, where ${field.join('.')} takes ${pinTypeText(taken)}` }]\n }\n // Each value of an object down to its reads, against the schema at its place\n const walk = (value: unknown, target: JsonSchema | undefined, field: string[]): Problem[] =>\n isObject(value) ? Object.entries(value).flatMap(([name, inner]) => walk(inner, schemaAt(target, [name]), [...field, name])) : mismatch(value, target, field)\n return Object.entries(argumentsOf(state)).flatMap(([key, value]) => walk(value, schemaAt(input, [key]), [key]))\n }),\n // A Block's steps are checked as a workflow of their own, as they run, reading the variables they assign; their\n // input is the Block's Arguments, of any type\n ...blocksOutsideBlocks(definition.stateMachine).flatMap(({ path, state }) =>\n pinProblems({ trigger: { manual: {} }, stateMachine: { ...state.Processor, QueryLanguage: 'JSONata' } }, schemas).map((problem) => ({ ...problem, ...(problem.state !== undefined && { state: `${path}/${problem.state}` }) })),\n ),\n]\n","import { expressionReads } from '../reads'\nimport { parse } from '../expressions'\nimport { assignedNames, stateExpressions } from '../expression-fields'\nimport { innerMachine } from '../inner'\nimport type { Machine, State } from '../types'\n\n/**\n * What a state of a dataflow machine runs after: the states whose variables it reads (`data`), and those whose\n * `$states.context.Steps.<name>` it reads (`status`), of which `handled` are those its `Condition` reads, which take\n * the default skip away for them.\n */\nexport type Dependencies = { data: Set<string>; status: Set<string>; handled: Set<string> }\n\ntype Read = { variables: string[]; steps: string[]; condition: boolean }\n\n// The variables and the Steps entries each expression of a state reads, a Map's item processor's reads of the scopes\n// around it included, as its items run only once those have ended; an item's Condition that reads a status handles it\n// for the Map, which then runs so that Condition can. A Block's steps read only its own input.\nconst readsOf = (state: State): Read[] => {\n const found: Read[] = []\n for (const { field, source } of stateExpressions(state)) {\n const parsed = parse(source)\n if ('error' in parsed) continue\n const reads = expressionReads(parsed.expression)\n const steps = reads.states.filter((path) => path[0] === 'context' && path[1] === 'Steps' && path[2] !== undefined).map((path) => path[2]!)\n found.push({ variables: [...reads.variables], steps, condition: field === 'Condition' })\n }\n const inner = state.Type === 'Map' ? innerMachine(state) : undefined\n if (inner) {\n const own = new Set(Object.values(inner.States).flatMap(assignedNames))\n const innerNames = new Set(Object.keys(inner.States))\n for (const read of Object.values(inner.States).flatMap(readsOf)) {\n found.push({ variables: read.variables.filter((name) => !own.has(name)), steps: read.steps.filter((name) => !innerNames.has(name)), condition: read.condition })\n }\n }\n return found\n}\n\n/** The state of `machine` that assigns each variable, by the variable; a variable two states assign maps to the first. */\nexport const assigners = (machine: Machine) => {\n const by = new Map<string, string>()\n for (const [name, state] of Object.entries(machine.States)) for (const variable of assignedNames(state)) if (!by.has(variable)) by.set(variable, name)\n return by\n}\n\n/** Each state's dependencies on the other states of its dataflow machine, by name. Reads of the scopes around it are not among them. */\nexport const machineDependencies = (machine: Machine): Map<string, Dependencies> => {\n const by = assigners(machine)\n return new Map(\n Object.entries(machine.States).map(([name, state]) => {\n const dependencies: Dependencies = { data: new Set(), status: new Set(), handled: new Set() }\n for (const read of readsOf(state)) {\n for (const variable of read.variables) {\n const from = by.get(variable)\n if (from !== undefined) dependencies.data.add(from)\n }\n for (const step of read.steps) {\n if (!Object.hasOwn(machine.States, step)) continue\n dependencies.status.add(step)\n if (read.condition) dependencies.handled.add(step)\n }\n }\n return [name, dependencies]\n }),\n )\n}\n\n/** Every state a state depends on, data and status alike. */\nexport const dependsOn = (dependencies: Dependencies) => new Set([...dependencies.data, ...dependencies.status])\n\n/** A cycle among the dependencies, as the state names around it with the first again at the end; none when there is none. */\nexport const dependencyCycle = (dependencies: ReadonlyMap<string, Dependencies>): string[] | undefined => {\n const state = new Map<string, 'open' | 'done'>()\n const path: string[] = []\n const visit = (name: string): string[] | undefined => {\n if (state.get(name) === 'done') return\n if (state.get(name) === 'open') return [...path.slice(path.indexOf(name)), name]\n state.set(name, 'open')\n path.push(name)\n for (const next of dependsOn(dependencies.get(name) ?? { data: new Set(), status: new Set(), handled: new Set() })) {\n const found = visit(next)\n if (found) return found\n }\n path.pop()\n state.set(name, 'done')\n return\n }\n for (const name of dependencies.keys()) {\n const found = visit(name)\n if (found) return found\n }\n return\n}\n","import { assignedNames } from '../expression-fields'\nimport type { Problem } from '../problem'\nimport type { Machine } from '../types'\nimport { dependencyCycle, machineDependencies } from './dependencies'\n\n/**\n * The variables each state of a dataflow machine may read: those of the scopes around it, and each one another state of\n * the machine assigns, which makes that state one it runs after. A state does not read its own.\n */\nexport const dataflowVisible = (machine: Machine, outer: ReadonlySet<string>) => {\n const all = Object.entries(machine.States).map(([name, state]) => [name, assignedNames(state)] as const)\n return new Map(all.map(([name, own]) => [name, new Set([...outer, ...all.flatMap(([other, names]) => (other === name ? [] : names)).filter((variable) => !own.includes(variable))])]))\n}\n\n/**\n * What a dataflow machine needs beside its states' own checks: each variable assigned by one state alone, so a read names\n * the one state it runs after, and no state that runs after itself through the states it reads from.\n */\nexport const dataflowProblems = (machine: Machine, where: (name: string) => string): Problem[] => {\n const problems: Problem[] = []\n const first = new Map<string, string>()\n for (const [name, state] of Object.entries(machine.States)) {\n for (const variable of new Set(assignedNames(state))) {\n const earlier = first.get(variable)\n if (earlier === undefined) first.set(variable, name)\n else problems.push({ state: where(name), field: 'Assign', message: `assigns $${variable}, which ${earlier} assigns already; in dataflow order each variable has one state that assigns it` })\n }\n }\n const cycle = dependencyCycle(machineDependencies(machine))\n if (cycle) problems.push({ state: where(cycle[0]!), message: `runs after itself: ${cycle.join(' reads ')}; a state cannot read what runs after it` })\n return problems\n}\n","import { awsProblems } from './check-aws'\nimport { schemaProblems } from './check-schema'\nimport { triggerProblems, type TriggerCheck } from './check-trigger'\nimport { assignedNames, stateExpressions } from './expression-fields'\nimport { expressionSource } from './expressions'\nimport { edges, reachable } from './graph'\nimport { reservedVariables } from './names'\nimport type { Problem } from './problem'\nimport { builtInFunctions } from './reads'\nimport { readProblems } from './check-reads'\nimport { connectionProblems } from './used-connections'\nimport type { Definition, Machine, TaskState } from './types'\nimport { visibleVariables } from './visible'\nimport { blockProblems } from './check-block'\nimport { allStates } from './inner'\nimport { limits } from '../limits'\nimport { depthProblems } from './depth-problems'\nimport { pinProblems } from './pins/check-pins'\nimport type { PinSchemas } from './pins/pin-sources'\nimport { dataflowProblems, dataflowVisible } from './dataflow/check-dataflow'\nimport { orderOf } from './types'\nimport { taskResource } from './task-resource'\nimport { customStepOf } from '../plugin/custom-step-id'\n\n/**\n * What a definition is checked against beside the language: the step types (Task resources) the app has, the\n * arguments each needs (`required`, by step type), its trigger types, each with the check of its input, and why the\n * app cannot run a type it knows (`unavailable`, by step or trigger type), and the connection `<plugin>:<connection>`\n * each type that signs in uses (`connections`, by step or trigger type); without it the bindings are not checked.\n * With `pins`, the types' input and output schemas and the app's records, an argument that reads a value by name is\n * checked to take that value's type. `versioned` names the latest version of each step type kept by version, by its id\n * without one, such as `custom:invoice` for `custom:invoice:3`: a Task that names no version is refused naming it.\n */\nexport type CheckOptions = {\n resources: readonly string[]\n required?: Readonly<Record<string, readonly string[]>>\n triggers: Readonly<Record<string, TriggerCheck>>\n unavailable?: Readonly<Record<string, string>>\n connections?: Readonly<Record<string, string>>\n pins?: PinSchemas\n versioned?: Readonly<Record<string, string>>\n}\n\n// `blocks`: how many Blocks the machine is inside; `data`: whether its states run in dataflow order, and `steps` the\n// names of the states around it whose status its states may read.\ntype Scope = { path: string[]; outer: ReadonlySet<string>; item: boolean; blocks: number; data: boolean; steps: ReadonlySet<string> }\n\n// The arguments a Task's step type needs and its Arguments leave out; none when Arguments is one expression, whose\n// value is known only when it runs.\nconst missingArguments = (state: TaskState, options: CheckOptions) => {\n const needed = options.required?.[taskResource(state.Resource).type] ?? []\n if (expressionSource(state.Arguments) !== undefined) return []\n const given = typeof state.Arguments === 'object' && state.Arguments !== null ? (state.Arguments as Record<string, unknown>) : {}\n return needed.filter((name) => given[name] === undefined || given[name] === '')\n}\n\n// A Task runs its step type within 300 seconds; one that waits for an outside result may wait longer, its heartbeats\n// coming more often than its timeout, and hands its work off on every try, so it caches nothing. A custom step waits\n// for its runner as such a Task does, 300 seconds by default, and so takes no suffix.\nconst waitProblems = (state: TaskState): Omit<Problem, 'state'>[] => {\n const { type, waits } = taskResource(state.Resource)\n const custom = customStepOf(type) !== undefined\n if (custom && waits) return [{ field: 'Resource', message: `ends in .waitForTaskToken, but ${type} is a custom step, which waits for the runner that runs it already: write ${type}` }]\n if (!waits && !custom) {\n return [\n ...(state.TimeoutSeconds !== undefined && state.TimeoutSeconds > limits.taskTimeoutSeconds ? [{ field: 'TimeoutSeconds', message: `is ${state.TimeoutSeconds}, more than the ${limits.taskTimeoutSeconds} seconds a step type runs; only a Task whose Resource ends in .waitForTaskToken waits longer` }] : []),\n ...(state.HeartbeatSeconds !== undefined ? [{ field: 'HeartbeatSeconds', message: 'is for a Task whose Resource ends in .waitForTaskToken, whose outside executor sends heartbeats; this step type ends or fails within its TimeoutSeconds' }] : []),\n ]\n }\n const timeout = state.TimeoutSeconds ?? (custom ? limits.taskTimeoutSeconds : limits.waitingTaskTimeoutSeconds)\n return [\n ...(state.HeartbeatSeconds !== undefined && state.HeartbeatSeconds >= timeout ? [{ field: 'HeartbeatSeconds', message: `is ${state.HeartbeatSeconds}, which must be less than the Task's TimeoutSeconds (${timeout})` }] : []),\n ...(state.Cache === true ? [{ field: 'Cache', message: custom ? 'is true, but a custom step runs on a runner on every try and caches nothing' : 'is true, but a Task that waits for an outside result hands its work off on every try and caches nothing' }] : []),\n ]\n}\n\nconst machineProblems = (machine: Machine, scope: Scope, options: CheckOptions): Problem[] => {\n const problems: Problem[] = []\n const where = (name: string) => [...scope.path, name].join('/')\n const prefix = scope.path.length > 0 ? { state: scope.path.join('/') } : {}\n const names = Object.keys(machine.States)\n const { data } = scope\n // In dataflow order a machine has no start: each state starts once the states it reads from have ended\n const start = machine.StartAt === undefined ? undefined : machine.States[machine.StartAt]\n if (!data && !start) problems.push({ ...prefix, field: 'StartAt', message: `names \"${machine.StartAt}\", which is not a state here` })\n const visible = data ? dataflowVisible(machine, scope.outer) : visibleVariables(machine, scope.outer)\n const reached = data ? undefined : reachable(machine)\n const steps = new Set([...scope.steps, ...names])\n\n for (const name of names) {\n const state = machine.States[name]!\n if (reached && !reached.has(name) && start) problems.push({ state: where(name), message: `is never reached from \"${machine.StartAt}\"` })\n for (const edge of edges(state)) {\n if (!machine.States[edge.target]) problems.push({ state: where(name), field: edge.field, message: `names \"${edge.target}\", which is not a state here` })\n }\n for (const variable of assignedNames(state)) {\n if (reservedVariables.has(variable) || builtInFunctions.has(variable)) problems.push({ state: where(name), field: 'Assign', message: `cannot assign $${variable}, a name the runner or JSONata keeps` })\n if (scope.outer.has(variable)) problems.push({ state: where(name), field: 'Assign', message: `cannot assign $${variable}, which an outer state assigns already` })\n }\n const task = state.Type === 'Task' ? taskResource(state.Resource) : undefined\n if (task && options.unavailable && Object.hasOwn(options.unavailable, task.type)) {\n problems.push({ state: where(name), field: 'Resource', message: `\"${task.type}\" cannot run in this app: ${options.unavailable[task.type]}` })\n } else if (task && options.versioned && Object.hasOwn(options.versioned, task.type)) {\n problems.push({ state: where(name), field: 'Resource', message: `\"${task.type}\" names no version: write ${options.versioned[task.type]}` })\n } else if (task && !options.resources.includes(task.type)) {\n problems.push({ state: where(name), field: 'Resource', message: `\"${task.type}\" is not a step type; use one of ${options.resources.join(', ')}${task.waits ? ', followed by .waitForTaskToken' : ''}` })\n }\n if (state.Type === 'Task') for (const missing of missingArguments(state, options)) problems.push({ state: where(name), field: `Arguments.${missing}`, message: `is missing; ${task!.type} needs it` })\n if (state.Type === 'Task') for (const problem of waitProblems(state)) problems.push({ state: where(name), ...problem })\n // In dataflow order every state of an item's machine starts from the item, which it reads as $states.input\n const firstOfItem = scope.item && (data || name === machine.StartAt)\n for (const { field, source, place } of stateExpressions(state)) {\n const token = Boolean(task?.waits) && /^Arguments($|[.[])/.test(field)\n for (const message of readProblems(source, { place, visible: visible.get(name)!, firstOfItem, inBlock: scope.blocks > 0, token, ...(data && { steps }) })) problems.push({ state: where(name), field, message })\n }\n if (state.Type === 'Map') problems.push(...machineProblems(state.ItemProcessor, { ...scope, path: [...scope.path, name], outer: visible.get(name)!, item: true, steps }, options))\n // A Block's steps run as a run of their own: they read its input, never the variables around it.\n if (state.Type === 'Block') {\n problems.push(...blockProblems(state, where(name), scope.blocks + 1))\n problems.push(...machineProblems(state.Processor, { path: [...scope.path, name], outer: new Set(), item: false, blocks: scope.blocks + 1, data, steps: new Set() }, options))\n }\n }\n if (data) problems.push(...dataflowProblems(machine, where))\n return problems\n}\n\nconst wholeProblems = (definition: Definition): Problem[] => {\n const names = allStates(definition.stateMachine).map(([name]) => name)\n const problems: Problem[] = []\n if (names.length > limits.states) problems.push({ field: 'stateMachine.States', message: `holds ${names.length} states, more than the ${limits.states} a workflow may have` })\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) problems.push({ state: name, message: 'is a state name used twice; names are unique across the whole state machine, Maps and Blocks included' })\n seen.add(name)\n }\n return problems\n}\n\n/**\n * Why a definition cannot be saved, as it is checked on every save: its size and nesting, its shape against `definitionSchema`, its\n * trigger and the connections it binds, then each edge, each Task's step type and what each expression reads, in the named-reads profile. Empty when\n * it can be saved.\n */\nexport const checkDefinition = (definition: unknown, options: CheckOptions): Problem[] => {\n const bytes = new TextEncoder().encode(JSON.stringify(definition) ?? '').length\n if (bytes > limits.definitionBytes) return [{ message: `The definition is ${bytes} bytes as JSON, more than the ${limits.definitionBytes} a workflow may have` }]\n const deep = depthProblems(definition)\n if (deep.length > 0) return deep\n // What Step Functions runs and this app does not, named, before the shape a standard document would otherwise miss\n const aws = awsProblems(definition)\n if (aws.length > 0) return aws\n const shape = schemaProblems(definition)\n if (shape.length > 0) return shape\n const document = definition as Definition\n return [...triggerProblems(document.trigger, options.triggers, options.unavailable), ...(options.connections ? connectionProblems(document, options.connections) : []), ...wholeProblems(document), ...machineProblems(document.stateMachine, { path: [], outer: new Set(), item: false, blocks: 0, data: orderOf(document) === 'data', steps: new Set() }, options), ...(options.pins ? pinProblems(document, options.pins) : [])]\n}\n","import { expressionSource, parse } from '../expressions'\nimport { readText, type Reference } from './references'\n\n/** A Comparison's operator, as JSONata writes it: Equals, Not equals, Greater and Less. */\nexport type CompareOp = '=' | '!=' | '>' | '<'\n\n/** A value a condition node takes: one read by name, or a value of its own. */\nexport type ConditionOperand = { read: Reference } | { value: string | number | boolean }\n\n/** A regular expression a Matches node tests text against: its source and its flags, `i` and `m`, as JSONata writes `/source/flags`. */\nexport type ConditionPattern = { pattern: string; flags: string }\n\n/**\n * A Condition taken apart into the editor's nodes: a Comparison of two values, a Matches of text against a pattern\n * (`$contains`), an All of or an Any of two conditions or more (`and`, `or`), or a Not of one, where a condition is\n * another of these or a value of its own or read by name.\n */\nexport type ConditionPart =\n | { kind: 'compare'; op: CompareOp; sides: [ConditionOperand, ConditionOperand] }\n | { kind: 'matches'; sides: [ConditionOperand, ConditionPattern] }\n | { kind: 'logic'; op: 'and' | 'or'; sides: ConditionSide[] }\n | { kind: 'not'; sides: [ConditionSide] }\n\n/** What a condition node's input takes: a node of its own, or a value. */\nexport type ConditionSide = ConditionPart | ConditionOperand\n\n/** What any input of a condition node holds: a side, or a Matches node's pattern. */\nexport type ConditionInput = ConditionSide | ConditionPattern\n\n/** What a step's status can be, as `$states.context.Steps.<name>.Status` reads it. */\nexport const stepStatuses = ['SUCCEEDED', 'FAILED', 'TIMED_OUT', 'ABORTED', 'SKIPPED'] as const\n\nconst compareOps: readonly string[] = ['=', '!=', '>', '<']\n\n/** Whether a side is a node of its own rather than a value. */\nexport const isConditionPart = (side: ConditionInput): side is ConditionPart => 'kind' in side\n\ntype Node = { type: string; value?: unknown; steps?: Node[]; lhs?: Node; rhs?: Node; expressions?: Node[]; arguments?: Node[]; procedure?: Node; [key: string]: unknown }\n\n// A step of a path read by name, which says nothing but its name\nconst plainStep = (step: Node) => Object.keys(step).every((key) => key === 'type' || key === 'value' || key === 'position')\n\n// The read a path or a variable is, as references read them: the run's input, a step's status or a variable\nconst referenceOf = (node: Node): Reference | undefined => {\n if (node.type === 'variable' && plainStep(node) && typeof node.value === 'string' && node.value !== '' && node.value !== 'states') return { base: { variable: node.value }, path: [] }\n if (node.type !== 'path' || !node.steps || !node.steps.every(plainStep)) return\n const [first, ...rest] = node.steps\n if (first?.type !== 'variable' || typeof first.value !== 'string' || !rest.every((step) => step.type === 'name' && typeof step.value === 'string')) return\n const names = rest.map((step) => step.value as string)\n if (first.value !== 'states') return first.value === '' ? undefined : { base: { variable: first.value }, path: names }\n if (names[0] === 'context' && names[1] === 'Steps' && names.length > 2) return { base: { step: names[2]! }, path: names.slice(3) }\n if (names[0] === 'context' && names[1] === 'Execution' && names[2] === 'Input') return { base: { input: true }, path: names.slice(3) }\n return\n}\n\nconst operandOf = (node: Node): ConditionOperand | undefined => {\n if (node.type === 'string' || node.type === 'number' || (node.type === 'value' && typeof node.value === 'boolean')) return { value: node.value as string | number | boolean }\n const read = referenceOf(node)\n return read && { read }\n}\n\n// The conditions a chain of one operator joins, `a and b and c` as three: JSONata takes its left side first, so the\n// chain goes down its left sides; one in brackets is a node of its own\nconst chainOf = (node: Node, op: string): Node[] => (node.type === 'binary' && node.value === op ? [...chainOf(node.lhs!, op), node.rhs!] : [node])\n\nconst isRegex = (value: unknown): value is RegExp => value instanceof RegExp\n\nconst partOf = (node: Node): ConditionPart | undefined => {\n if (node.type === 'block' && node.expressions?.length === 1) return partOf(node.expressions[0]!)\n if (node.type === 'binary' && (node.value === 'and' || node.value === 'or')) {\n const sides = chainOf(node, node.value).map(sideOf)\n return sides.every((side) => side !== undefined) ? { kind: 'logic', op: node.value, sides: sides as ConditionSide[] } : undefined\n }\n const [text, pattern] = node.arguments ?? []\n if (node.type === 'function' && node.procedure?.type === 'variable' && node.procedure.value === 'contains' && node.arguments?.length === 2 && pattern?.type === 'regex' && isRegex(pattern.value)) {\n const operand = operandOf(text!)\n // JSONata gives every regular expression the g flag, which it does not write\n return operand && { kind: 'matches', sides: [operand, { pattern: pattern.value.source, flags: pattern.value.flags.replace('g', '') }] }\n }\n if (node.type === 'binary' && compareOps.includes(node.value as string)) {\n const [lhs, rhs] = [operandOf(node.lhs!), operandOf(node.rhs!)]\n return lhs && rhs && { kind: 'compare', op: node.value as CompareOp, sides: [lhs, rhs] }\n }\n if (node.type === 'function' && node.procedure?.type === 'variable' && node.procedure.value === 'not' && node.arguments?.length === 1) {\n const side = sideOf(node.arguments[0]!)\n return side && { kind: 'not', sides: [side] }\n }\n return\n}\n\n// An And's, an Or's or a Not's input: a node of its own, true or false, or a read\nconst sideOf = (node: Node): ConditionSide | undefined => {\n const part = partOf(node)\n if (part) return part\n const operand = operandOf(node)\n return operand && ('read' in operand || typeof operand.value === 'boolean') ? operand : undefined\n}\n\n// Text JSONata reads as it is between single quotes, which it has no escape for; any other in double quotes, as JSON writes it\nconst quoted = (value: string) => (/^[^'\\\\\\x00-\\x1f]*$/.test(value) ? `'${value}'` : JSON.stringify(value))\n\nconst operandText = (operand: ConditionOperand) => {\n if ('read' in operand) return readText(operand.read)\n return typeof operand.value === 'string' ? quoted(operand.value) : String(operand.value)\n}\n\n// JSONata binds a comparison closer than And, and And closer than Or. A chain of one operator is one node, so a node of\n// that operator inside it was in brackets\nconst sideText = (side: ConditionSide, parent: 'and' | 'or') => {\n if (!isConditionPart(side)) return operandText(side)\n const text = partText(side)\n if (side.kind !== 'logic') return text\n return side.op === parent || (parent === 'and' && side.op === 'or') ? `(${text})` : text\n}\n\nconst partText = (part: ConditionPart): string => {\n if (part.kind === 'compare') return `${operandText(part.sides[0])} ${part.op} ${operandText(part.sides[1])}`\n if (part.kind === 'matches') return `$contains(${operandText(part.sides[0])}, /${part.sides[1].pattern}/${part.sides[1].flags})`\n if (part.kind === 'logic') return part.sides.map((side) => sideText(side, part.op)).join(` ${part.op} `)\n const [side] = part.sides\n return `$not(${isConditionPart(side) ? partText(side) : operandText(side)})`\n}\n\n/** The Condition a node and what it takes write: `{% $states.context.Steps.Save.Status = 'SUCCEEDED' %}`. */\nexport const conditionValue = (part: ConditionPart) => `{% ${partText(part)} %}`\n\n/**\n * A Condition taken apart into nodes, when it is a Comparison, a Matches, an All of, an Any of or a Not of values and\n * reads by name and\n * writing those nodes back gives it exactly as it is; undefined for any other, such as one that computes, or is spaced\n * or bracketed otherwise, which stays an expression, so no Condition is ever rewritten.\n */\nexport const conditionParts = (value: unknown): ConditionPart | undefined => {\n const source = expressionSource(value)\n if (source === undefined) return\n const parsed = parse(source)\n if ('error' in parsed) return\n const part = partOf(parsed.expression.ast() as Node)\n return part && conditionValue(part) === value ? part : undefined\n}\n\n/** A value a Select gives or compares with: text, a number, or true or false. */\nexport type SelectValue = string | number | boolean\n\n/**\n * A value chosen by another, which a Select node draws: the value it looks at, read by name or one of its own, a case\n * per value it can be with what it gives then, and what it gives for any other. JSONata writes it as a chain of\n * conditionals: `$topic = 'sales' ? 'sales@example.com' : $topic = 'support' ? 'help@example.com' : 'info@example.com'`.\n */\nexport type SelectPart = { operand: ConditionOperand; cases: { when: SelectValue; then: SelectValue }[]; otherwise: SelectValue }\n\nconst valueOf = (node: Node | undefined): SelectValue | undefined => {\n if (!node) return\n const operand = operandOf(node)\n return operand && 'value' in operand ? operand.value : undefined\n}\n\nconst selectOf = (node: Node): SelectPart | undefined => {\n const cases: SelectPart['cases'] = []\n let operand: ConditionOperand | undefined\n let at: Node | undefined = node\n // Each conditional of the chain compares the same value with one of its own, and gives one of its own\n while (at?.type === 'condition') {\n const test = at.condition as Node | undefined\n if (test?.type !== 'binary' || test.value !== '=') return\n const read = operandOf(test.lhs!)\n const [when, then] = [valueOf(test.rhs), valueOf(at.then as Node | undefined)]\n if (!read || when === undefined || then === undefined) return\n if (operand && operandText(operand) !== operandText(read)) return\n operand = read\n cases.push({ when, then })\n at = at.else as Node | undefined\n }\n const otherwise = valueOf(at)\n return operand && otherwise !== undefined ? { operand, cases, otherwise } : undefined\n}\n\n/** The value a Select node and what it holds write: `{% $topic = 'sales' ? 'sales@example.com' : 'info@example.com' %}`. */\nexport const selectValue = ({ operand, cases, otherwise }: SelectPart) => {\n const read = operandText(operand)\n const text = (value: SelectValue) => operandText({ value })\n return `{% ${[...cases.map(({ when, then }) => `${read} = ${text(when)} ? ${text(then)}`), text(otherwise)].join(' : ')} %}`\n}\n\n/**\n * A value taken apart into a Select node, when it is a chain of conditionals that compare one value with values of\n * their own and give values of their own, and writing the node back gives it exactly as it is; undefined for any other.\n */\nexport const selectParts = (value: unknown): SelectPart | undefined => {\n const source = expressionSource(value)\n if (source === undefined) return\n const parsed = parse(source)\n if ('error' in parsed) return\n const part = selectOf(parsed.expression.ast() as Node)\n return part && selectValue(part) === value ? part : undefined\n}\n","import { expressionParsed } from './check-reads'\nimport { stateExpressions } from './expression-fields'\nimport { edges } from './graph'\nimport { innerMachine } from './inner'\nimport type { Problem } from './problem'\nimport type { Definition, Machine, State } from './types'\n\n// The states reached from `start` along the edges, without passing through `avoid`, which assigns its variables anew.\nconst reachedAvoiding = (machine: Machine, start: string, avoid: string) => {\n const seen = new Set<string>()\n const stack = [start]\n while (stack.length > 0) {\n const name = stack.pop()!\n const state = machine.States[name]\n if (seen.has(name) || name === avoid || !state) continue\n seen.add(name)\n stack.push(...edges(state).map((edge) => edge.target))\n }\n return seen\n}\n\n// The variables a state reads: its own expressions', and those of the states of a Map inside it, which see its variables.\nconst readVariables = (state: State): Set<string> => {\n const names = new Set(stateExpressions(state).flatMap(({ source }) => [...(expressionParsed(source)?.variables ?? [])]))\n if (state.Type === 'Map') for (const inner of Object.values(state.ItemProcessor?.States ?? {})) for (const name of readVariables(inner)) names.add(name)\n return names\n}\n\nconst machineWarnings = (machine: Machine, path: string[]): Problem[] => {\n const where = (name: string) => [...path, name].join('/')\n const warnings: Problem[] = []\n for (const [name, state] of Object.entries(machine.States)) {\n const inner = innerMachine(state)\n if (inner) warnings.push(...machineWarnings(inner, [...path, name]))\n if (state.Type !== 'Block' || state.Next === undefined || !state.Assign) continue\n const assigned = new Set(Object.keys(state.Assign))\n const waits = [...reachedAvoiding(machine, state.Next, name)].filter((other) => machine.States[other]!.Type === 'Wait')\n const warned = new Set<string>()\n for (const wait of waits) {\n const after = machine.States[wait]!\n if (!('Next' in after) || after.Next === undefined) continue\n for (const reader of reachedAvoiding(machine, after.Next, name)) {\n const read = [...readVariables(machine.States[reader]!)].filter((variable) => assigned.has(variable))\n if (read.length === 0 || warned.has(reader)) continue\n warned.add(reader)\n const names = read.map((variable) => `$${variable}`).join(', ')\n warnings.push({ state: where(reader), message: `reads ${names} after the Wait \"${wait}\", and the Block \"${name}\" set it before that Wait. If it holds something that expires, such as a signed link, it may have expired by then: set it after the Wait instead. If it holds what the block stored, you can leave it.` })\n }\n }\n }\n return warnings\n}\n\n/**\n * What a save goes through with but its author should know, each on the state it concerns: a state that reads, after a\n * Wait, a variable a Block assigned before it, whose value may have expired by then. It reads a draft as it stands, so an\n * editor can show them before the definition can be saved.\n */\nexport const definitionWarnings = (definition: Definition): Problem[] => machineWarnings(definition.stateMachine, [])\n","import { expressionSource } from '../definition/expressions'\nimport type { Machine, Order } from '../definition/types'\nimport type { Checkpoint } from './port'\n\n/** What a re-run reads of a failed run's checkpoint to know where its scope goes on. */\nexport type EarlierCheckpoint = Pick<Checkpoint, 'scope' | 'next'>\n\n// The machine a scope runs: the run's own, the item processor of each Map its scope names, as `innerScope` writes it,\n// or in data order a state of its own, its name as `scopeOf` writes it, which no Map item's part can be, since a name\n// is written URI-encoded, without brackets.\nconst itemPart = /^(.*)\\.\\d+\\[\\d+\\]$/\nconst machineOf = (machine: Machine, scope: string, order: Order): Machine | string => {\n if (scope === '') return machine\n let inner = machine\n for (const part of scope.split('/')) {\n const item = itemPart.exec(part)\n const name = decodeURIComponent(item ? item[1]! : part)\n const state = inner.States[name]\n if (!item) {\n if (order !== 'data') return `The run goes on at state \"${name}\" as data order runs it, and the workflow now runs in sequence`\n if (!state) return `The run goes on at state \"${name}\", which the workflow no longer has`\n inner = { States: { [name]: state } }\n continue\n }\n if (state?.Type !== 'Map') return `The run goes on in the Map \"${name}\"${scope.includes('/') ? ` of ${scope}` : ''}, which the workflow no longer has`\n inner = state.ItemProcessor\n }\n return inner\n}\n\n/**\n * The problem with re-running a failed run whose scopes stand at `checkpoints` on `machine`, the workflow's version\n * now, in `order`: a scope that would go on at a state, or in a Map, the version does not have, or one of the other\n * order; undefined when there is none.\n * Scopes that ended stay as they ran.\n * A re-run goes on from each scope's last checkpoint, as a run does after a crash: the steps since run again, the\n * recorded ones before it never.\n */\nexport const rerunProblem = (machine: Machine, checkpoints: readonly EarlierCheckpoint[], order: Order = 'sequence') => {\n // The order a run ran in, which its scopes tell: the run's own scope and a Map item's outermost run in sequence, a\n // state's name in data order. A run of the other order would start its states anew, running their writes again.\n const ranIn = checkpoints.some(({ scope }) => scope !== '' && !itemPart.test(scope.split('/')[0]!)) ? 'data' : 'sequence'\n if (checkpoints.length > 0 && ranIn !== order) return `The run ran in ${ranIn} order, and the workflow now runs in ${order} order; switch it back to re-run it`\n for (const { scope, next } of checkpoints) {\n // A scope that ended, such as a finished Map item, is history and stays as it ran.\n if (next === null) continue\n const inner = machineOf(machine, scope, order)\n if (typeof inner === 'string') return inner\n if (!Object.hasOwn(inner.States, next)) return `The run goes on at state \"${next}\"${scope ? ` in ${scope}` : ''}, which the workflow no longer has`\n }\n return\n}\n\n/** A failed run's checkpoint as its re-run, started at `clock`, takes it up: the state it goes on at from its first try, now. */\nexport const rerunCheckpoint = <C extends Checkpoint>({ resumeAt: _, ...checkpoint }: C, clock: Date) => ({ ...checkpoint, attempt: 1, failures: [], clock })\n\n/** How a state keeps its whole result in a variable. */\nexport const resultRead = '{% $states.result %}'\n\n/**\n * What a kept step assigned, with each variable its state has on the version a re-run runs that keeps its whole result\n * holding that result, whatever it held then: a step kept as it ran still gives what a later step now reads from it, and\n * nothing runs again for it. Its other variables stay as they ran, and so does all a step that did not succeed assigned.\n * The step's output is its whole result only where its state in `ran`, the version the earlier run ran, had no `Output`:\n * a step whose result was shaped then keeps what it assigned, as nothing knows its whole result any more.\n */\nexport const keptAssigned = (machine: Machine, ran: Machine, step: { scope: string; state: string; status: string; output?: unknown; assigned?: unknown }) => {\n // A step that failed into a catcher gave an error, not its result, and assigned what the catcher says\n const state = step.scope === '' && step.status === 'succeeded' ? machine.States[step.state] : undefined\n const before = ran.States[step.state]\n const assign = state && 'Assign' in state ? (state.Assign as Record<string, unknown> | undefined) : undefined\n if (!state || !assign || !before || ('Output' in before && before.Output !== undefined)) return undefined\n const assigned = (step.assigned ?? {}) as Record<string, unknown>\n const whole = Object.keys(assign).filter((name) => expressionSource(assign[name])?.trim() === '$states.result' && JSON.stringify(assigned[name]) !== JSON.stringify(step.output))\n return whole.length === 0 ? undefined : { ...assigned, ...Object.fromEntries(whole.map((name) => [name, step.output])) }\n}\n","import type { Machine, State } from '../definition/types'\nimport type { SegmentContext, StateResult } from './context'\nimport type { StepLog, TaskHandler } from './port'\nimport { mapNames, visitKey } from './replay-match'\nimport type { Replay } from './replay-of'\n\n/** The log line of a step a replay held back, which the run's page marks it by. */\nexport const heldBackLog = 'Not sent: replay'\n\n/** Whether a replay holds back this call: anything but its type saying `false`, it writes. */\nexport const heldBack = (context: SegmentContext, handler: TaskHandler | undefined, args: unknown) => Boolean(context.replay) && handler?.writes?.(args) !== false\n\n/** The replayed run's state of this name in the scope of these Map names. */\nconst stateIn = (machine: Machine, maps: readonly string[], name: string): State | undefined => {\n let inner: Machine | undefined = machine\n for (const map of maps) {\n const state: State | undefined = inner?.States[map]\n inner = state?.Type === 'Map' ? state.ItemProcessor : undefined\n }\n return inner?.States[name]\n}\n\n/**\n * What a held-back step takes from the replayed run's step of the same state and visit of it in the same scope, as\n * `logical` names it by visits: its\n * error, or its result, which only a Task or Block that did not shape it with `Output` saved as it was. Undefined when that\n * run has no such step, its step was still retrying, or saved its result shaped.\n */\nexport const replayedOutcome = (replay: Replay, at: { scope: string; logical: string; visit: number; name: string }) => {\n const step = replay.outcomes.get(visitKey(at.logical, at.name, at.visit))\n if (!step || step.status === 'retrying') return\n if (step.status !== 'succeeded') return { failure: { Error: step.error ?? 'States.Runtime', Cause: step.cause ?? '' } }\n const state = stateIn(replay.machine, mapNames(at.scope), at.name)\n if ((state?.Type !== 'Task' && state?.Type !== 'Block') || state.Output !== undefined) return\n return { result: step.output ?? null }\n}\n\n/** A held-back step the replayed run gave nothing for: a null output, on to its next state. */\nexport const emptyTask = (state: { Next?: string }, input: unknown, logs: StepLog[]): StateResult => ({ kind: 'step', status: 'succeeded', next: state.Next ?? null, input, output: null, logs })\n"],"mappings":"uqBAEA,IAAMA,EAAY,GAAqD,OAAO6B,GAAU,YAAYA,GAAkB,CAAC,MAAM,QAAQA,CAAK,EAGpIC,GAAiB,CAAC,YAAa,aAAc,iBAAkB,aAAc,aAAc,WAAW,EAEtGC,GAAoC,CACxC,WAAY,iFACZ,YAAa,0DACb,aAAc,yDACd,sBAAuB,kDACvB,2BAA4B,kDAC5B,YAAa,6EACf,EAEMC,GAAiB,EAAiB,IACjChC,EAASiC,CAAM,EACb,OAAO,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AC,ECDvGyM,GAAa,uBClDbC,GAAc","debugId":"64bb8a36-b2e1-433e-937e-fa87fe77dabe"}
|
|
1
|
+
{"version":3,"file":"workflows-DlvOln9v.js","names":["isObject","Ajv","n","a","t","templateExpressions","expressionReads","builtInFunctions","require_ajv","expressionSource","taskResource","innerMachine","orderOf","pinType","readText","blocksOutsideBlocks","inputSchema","tasksOutsideBlocks","customStepOf","limits","parse","referenceSchema","parseReference","argumentsOf","schemaAt","allStates","pinTypeText","fits","isObject$1","value","jsonPathFields","awsFields","stateProblems","states","name","state","where","path","found","field","message","config","inner","awsProblems","machine","definition","import_ajv","expression","errorNames","assign","retrier","schemaFor","sequence","order","common","flow","nextOrEnd","catcher","recovery","extra","required","type","properties","machineFields","flowStates","sequenceStates","definitionSchema","dataflowDefinitionSchema","fieldPath","parts","part","ajv","validators","located","all","pointer","index","error","data","choices","schemaProblems","validate","problems","seen","errors","text","branch","other","key","triggerProblems","input","trigger","unavailable","check","triggers","problem","stateExpressions","add","base","after","rule","assignedNames","names","edges","reachable","queue","edge","reachedFrom","stack","start","reservedVariables","contextReads","statesFields","startsWith","prefix","contextProblem","rest","read","token","steps","held","expressionParsed","parsed","source","readProblems","reads","firstOfItem","place","inBlock","visible","resources","usedConnections","types","connectionOf","connectionProblems","used","passedOn","own","along","visibleVariables","outer","later","target","variable","units","cacheSeconds","ttl","match","secretArguments","blockProblems","depth","nestingDepth","deepest","item","most","child","depthProblems","isObject","pinProblems","schemas","mismatch","reference","taken","walk","readsOf","innerNames","assigners","by","machineDependencies","dependencies","from","step","dependsOn","dependencyCycle","visit","next","dataflowVisible","dataflowProblems","first","earlier","cycle","missingArguments","needed","options","given","waitProblems","custom","waits","timeout","machineProblems","scope","reached","task","missing","wholeProblems","checkDefinition","bytes","deep","aws","shape","document","stepStatuses","compareOps","isConditionPart","side","plainStep","referenceOf","node","operandOf","chainOf","op","isRegex","partOf","sides","sideOf","pattern","operand","lhs","rhs","quoted","operandText","sideText","partText","parent","conditionValue","conditionParts","valueOf","selectOf","cases","at","test","when","then","otherwise","selectValue","selectParts","reachedAvoiding","avoid","readVariables","machineWarnings","warnings","assigned","warned","wait","reader","definitionWarnings","resultRead","heldBackLog"],"sources":["../../../../workflows/src/definition/check-aws.ts","../../../../workflows/src/definition/schema.ts","../../../../workflows/src/definition/problem.ts","../../../../workflows/src/definition/check-schema.ts","../../../../workflows/src/definition/check-trigger.ts","../../../../workflows/src/definition/expression-fields.ts","../../../../workflows/src/definition/graph.ts","../../../../workflows/src/definition/names.ts","../../../../workflows/src/definition/check-reads.ts","../../../../workflows/src/definition/used-connections.ts","../../../../workflows/src/definition/visible.ts","../../../../workflows/src/run/cache/cache-ttl.ts","../../../../workflows/src/definition/check-block.ts","../../../../workflows/src/nesting.ts","../../../../workflows/src/definition/depth-problems.ts","../../../../workflows/src/definition/pins/check-pins.ts","../../../../workflows/src/definition/dataflow/dependencies.ts","../../../../workflows/src/definition/dataflow/check-dataflow.ts","../../../../workflows/src/definition/check-definition.ts","../../../../workflows/src/definition/pins/conditions.ts","../../../../workflows/src/definition/check-warnings.ts","../../../../workflows/src/run/rerun.ts","../../../../workflows/src/run/replay.ts"],"sourcesContent":["import type { Problem } from './problem'\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\n// The fields of the States Language's JSONPath, which the named-reads profile writes in JSONata as Arguments, Output and Assign\nconst jsonPathFields = ['InputPath', 'Parameters', 'ResultSelector', 'ResultPath', 'OutputPath', 'ItemsPath']\n// What Step Functions runs that this app does not, by field\nconst awsFields: Record<string, string> = {\n ItemReader: \"is a distributed Map's reader, which does not run here; give the Map its Items\",\n ItemBatcher: \"is a distributed Map's batcher, which does not run here\",\n ResultWriter: \"is a distributed Map's writer, which does not run here\",\n ToleratedFailureCount: \"is a distributed Map's, which does not run here\",\n ToleratedFailurePercentage: \"is a distributed Map's, which does not run here\",\n Credentials: 'does not run here: a step signs in through the connection its type declares',\n}\n\nconst stateProblems = (states: unknown, path: string[]): Problem[] => {\n if (!isObject(states)) return []\n return Object.entries(states).flatMap(([name, state]): Problem[] => {\n if (!isObject(state)) return []\n const where = [...path, name].join('/')\n const found: Problem[] = []\n if (state.Type === 'Parallel') found.push({ state: where, field: 'Type', message: 'is Parallel, which does not run here yet; in data order, states that read nothing of each other run at once' })\n if (typeof state.Resource === 'string' && state.Resource.startsWith('arn:')) {\n found.push({ state: where, field: 'Resource', message: `is a Step Functions service (${state.Resource}), which does not run here: write the step with one of this app's step types, such as app:http for an HTTP request` })\n }\n for (const field of jsonPathFields) if (state[field] !== undefined) found.push({ state: where, field, message: 'is JSONPath, which does not run here; write the state in JSONata, with Arguments, Output and Assign' })\n for (const [field, message] of Object.entries(awsFields)) if (state[field] !== undefined) found.push({ state: where, field, message })\n const config = isObject(state.ItemProcessor) ? state.ItemProcessor.ProcessorConfig : undefined\n if (isObject(config) && config.Mode === 'DISTRIBUTED') found.push({ state: where, field: 'ItemProcessor.ProcessorConfig.Mode', message: 'is DISTRIBUTED, which does not run here; a Map runs its items inline' })\n for (const inner of ['ItemProcessor', 'Processor', 'Iterator']) if (isObject(state[inner])) found.push(...stateProblems((state[inner] as Record<string, unknown>).States, [...path, name]))\n return found\n })\n}\n\n/**\n * What a state machine from Step Functions holds that this app does not run, each named: JSONPath (its query\n * language by default), its service tasks, the HTTP task included, Parallel, a distributed Map, credentials and a whole-run\n * timeout. Empty for a machine this app can check further.\n */\nexport const awsProblems = (definition: unknown): Problem[] => {\n const machine = isObject(definition) && isObject(definition.stateMachine) ? definition.stateMachine : undefined\n if (!machine) return []\n const found: Problem[] = []\n if (machine.QueryLanguage !== 'JSONata') found.push({ field: 'stateMachine.QueryLanguage', message: `is ${machine.QueryLanguage === undefined ? 'missing, so the machine is JSONPath, the default of Step Functions' : JSON.stringify(machine.QueryLanguage)}; only JSONata machines run here: set \"QueryLanguage\": \"JSONata\" and write its states in JSONata` })\n if (machine.TimeoutSeconds !== undefined) found.push({ field: 'stateMachine.TimeoutSeconds', message: \"is a whole run's timeout, which does not run here; give each Task its TimeoutSeconds\" })\n return [...found, ...stateProblems(machine.States, [])]\n}\n","import { limits } from '../limits'\nimport type { Order } from './types'\n\nconst expression = { type: 'string', pattern: '^\\\\{%[\\\\s\\\\S]*%\\\\}$' }\nconst name = { type: 'string', minLength: 1, maxLength: 80 }\nconst errorNames = { type: 'array', minItems: 1, items: { type: 'string', minLength: 1 } }\nconst assign = { type: 'object', propertyNames: { pattern: '^[A-Za-z][A-Za-z0-9_]*$' } }\n\nconst retrier = {\n type: 'object',\n additionalProperties: false,\n required: ['ErrorEquals'],\n properties: {\n ErrorEquals: errorNames,\n IntervalSeconds: { type: 'integer', minimum: 1, maximum: limits.retryDelaySeconds },\n MaxAttempts: { type: 'integer', minimum: 0, maximum: limits.retryAttempts },\n BackoffRate: { type: 'number', minimum: 1, maximum: 10 },\n MaxDelaySeconds: { type: 'integer', minimum: 1, maximum: limits.retryDelaySeconds },\n },\n}\n\n/**\n * The JSON Schema of a workflow definition in one order: its trigger, and a state machine in the States Language with\n * JSONata expressions, in the named-reads profile. In sequence order every state names its `Next` or `End` and the\n * machine its `StartAt`, as the States Language has them; in data order none does, a state may have a `Condition`,\n * a catcher has no `Next`, and there is no Choice or Succeed. It checks the shape; `checkDefinition` also checks the\n * edges and what each expression reads.\n */\nconst schemaFor = (order: Order) => {\n const sequence = order === 'sequence'\n const common = { Type: {}, Comment: { type: 'string' }, Output: {}, Assign: assign, QueryLanguage: { const: 'JSONata' }, ...(!sequence && { Condition: expression }) }\n const flow = sequence ? { Next: name, End: { const: true } } : {}\n const nextOrEnd = sequence ? { oneOf: [{ required: ['Next'], not: { required: ['End'] } }, { required: ['End'], not: { required: ['Next'] } }] } : {}\n const catcher = { type: 'object', additionalProperties: false, required: ['ErrorEquals', ...(sequence ? ['Next'] : [])], properties: { ErrorEquals: errorNames, ...(sequence && { Next: name }), Output: {}, Assign: assign } }\n const recovery = { Retry: { type: 'array', items: retrier }, Catch: { type: 'array', items: catcher } }\n const state = (type: string, properties: Record<string, unknown>, { required = [], ...extra }: { required?: string[]; [key: string]: unknown } = {}) => ({\n type: 'object',\n additionalProperties: false,\n required: ['Type', ...required],\n ...extra,\n properties: { ...common, Type: { const: type }, ...properties },\n })\n const machine = sequence\n ? { type: 'object', required: ['StartAt', 'States'], properties: { StartAt: name, Comment: { type: 'string' }, States: { type: 'object', minProperties: 1, propertyNames: name, additionalProperties: { $ref: '#/definitions/state' } } } }\n : { type: 'object', required: ['States'], properties: { Comment: { type: 'string' }, States: { type: 'object', minProperties: 1, propertyNames: name, additionalProperties: { $ref: '#/definitions/state' } } } }\n // A state machine Step Functions exports may carry its Version, which runs nothing\n const machineFields = { ...(sequence && { StartAt: {} }), States: {}, Comment: {}, Version: { type: 'string' } }\n const flowStates = [\n state('Pass', flow, nextOrEnd),\n state('Task', { ...flow, ...recovery, Resource: name, Arguments: {}, TimeoutSeconds: { type: 'integer', minimum: 1, maximum: limits.waitingTaskTimeoutSeconds }, HeartbeatSeconds: { type: 'integer', minimum: 1, maximum: limits.waitingTaskTimeoutSeconds }, Cache: { type: 'boolean' } }, { required: ['Resource'], ...nextOrEnd }),\n state('Wait', { ...flow, Seconds: { anyOf: [{ type: 'integer', minimum: 0, maximum: limits.waitSeconds }, expression] }, Timestamp: { type: 'string' } }, {\n allOf: [nextOrEnd, { oneOf: [{ required: ['Seconds'] }, { required: ['Timestamp'] }] }],\n }),\n // Fail ends the run with an error, so it has no Output or Assign.\n { type: 'object', additionalProperties: false, required: ['Type'], properties: { Type: { const: 'Fail' }, Comment: { type: 'string' }, QueryLanguage: { const: 'JSONata' }, ...(!sequence && { Condition: expression }), Error: { type: 'string' }, Cause: { type: 'string' } } },\n state('Map', {\n ...flow,\n ...recovery,\n Items: {},\n ItemProcessor: { $ref: '#/definitions/processor' },\n MaxConcurrency: { type: 'integer', minimum: 0, maximum: limits.mapConcurrency },\n }, { required: ['ItemProcessor', 'Items'], ...nextOrEnd }),\n state('Block', {\n ...flow,\n ...recovery,\n Arguments: {},\n Processor: { $ref: '#/definitions/machine' },\n // Ttl's text is checked by checkDefinition, as a step type's cache time to live is.\n Cache: { type: 'object', additionalProperties: false, required: ['Ttl'], properties: { Ttl: { type: ['integer', 'string'] }, Key: {} } },\n }, { required: ['Processor', 'Cache'], ...nextOrEnd }),\n ]\n // A Choice goes on by its rules and a Succeed ends the run: in data order a Condition and the run's end say both.\n const sequenceStates = sequence\n ? [\n state('Choice', {\n Choices: {\n type: 'array',\n minItems: 1,\n items: { type: 'object', additionalProperties: false, required: ['Condition', 'Next'], properties: { Condition: expression, Next: name, Comment: { type: 'string' }, Output: {}, Assign: assign } },\n },\n Default: name,\n }, { required: ['Choices'] }),\n { type: 'object', additionalProperties: false, required: ['Type'], properties: { Type: { const: 'Succeed' }, Comment: { type: 'string' }, Output: {}, QueryLanguage: { const: 'JSONata' } } },\n ]\n : []\n return {\n $schema: 'http://json-schema.org/draft-07/schema#',\n $id: `https://docs.protobase.net/schemas/workflow-definition${sequence ? '' : '-data'}.json`,\n $ref: '#/definitions/definition',\n definitions: {\n machine,\n definition: {\n type: 'object',\n additionalProperties: false,\n required: ['trigger', 'stateMachine'],\n properties: { trigger: { $ref: '#/definitions/trigger' }, order: { enum: ['sequence', 'data'] }, stateMachine: { $ref: '#/definitions/stateMachine' }, connections: { $ref: '#/definitions/connections' }, trace: { enum: ['all', 'failed', 'none'] } },\n },\n // The account each connection `<plugin>:<connection>` the definition's types sign in with goes through, by its id.\n connections: {\n type: 'object',\n propertyNames: { pattern: '^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$' },\n additionalProperties: { type: 'string', minLength: 1, maxLength: 255 },\n },\n trigger: {\n type: 'object',\n minProperties: 1,\n maxProperties: 1,\n // `manual`, which takes no input, or a trigger type `<plugin>:<key>` with its input; the plugin's schema checks that.\n propertyNames: { pattern: '^(manual|[a-z][a-z0-9_]*:[a-z][a-z0-9_]*(\\\\.[a-z][a-z0-9_]*)*)$' },\n properties: { manual: { type: 'object', maxProperties: 0 } },\n additionalProperties: { type: 'object' },\n },\n stateMachine: {\n allOf: [{ $ref: '#/definitions/machine' }],\n required: ['QueryLanguage'],\n properties: { QueryLanguage: { const: 'JSONata' }, ...machineFields },\n additionalProperties: false,\n },\n processor: {\n allOf: [{ $ref: '#/definitions/machine' }],\n properties: { ProcessorConfig: { type: 'object', additionalProperties: false, properties: { Mode: { const: 'INLINE' } } }, ...machineFields },\n additionalProperties: false,\n },\n state: { type: 'object', required: ['Type'], discriminator: { propertyName: 'Type' }, oneOf: [...flowStates, ...sequenceStates] },\n },\n }\n}\n\n/** The JSON Schema of a workflow definition whose states run in sequence, the States Language's own order. */\nexport const definitionSchema = schemaFor('sequence')\n\n/** The JSON Schema of a workflow definition whose states run in the order their reads give: `\"order\": \"data\"`. */\nexport const dataflowDefinitionSchema = schemaFor('data')\n","/**\n * Why a definition cannot be saved. `state` is the state's path: its name, or names joined by `/` inside a Map's item\n * processor or a Parallel's branch (`Each/Fetch`, `Both/1/Mail`); `field` is the field within it, such as `Retry[0].IntervalSeconds`.\n */\nexport type Problem = { state?: string; field?: string; message: string }\n\n/** A problem as one line: `State \"Fetch\", field \"Arguments.url\": ...`. */\nexport const problemText = ({ state, field, message }: Problem) => {\n const where = [state !== undefined && `state \"${state}\"`, field !== undefined && `field \"${field}\"`].filter(Boolean).join(', ')\n if (!where) return message\n return `${where.charAt(0).toUpperCase()}${where.slice(1)}: ${message}`\n}\n\n/** A field path as `Retry[0].IntervalSeconds`. */\nexport const fieldPath = (parts: readonly (string | number)[]) =>\n parts.reduce<string>((path, part) => (typeof part === 'number' || /^\\d+$/.test(part) ? `${path}[${part}]` : path ? `${path}.${part}` : part), '')\n","import { Ajv, type ErrorObject } from 'ajv'\nimport { dataflowDefinitionSchema, definitionSchema } from './schema'\nimport { fieldPath, type Problem } from './problem'\n\nconst ajv = new Ajv({ allErrors: true, discriminator: true, strict: false })\nconst validators = { sequence: ajv.compile(definitionSchema), data: ajv.compile(dataflowDefinitionSchema) }\n\n// `/stateMachine/States/Each/ItemProcessor/States/Fetch/Retry/0` (or a Block's `Processor`) as the state `Each/Fetch` and its field `Retry[0]`;\n// `/trigger/schedule` as the field `trigger.schedule`.\nconst located = (pointer: string): Pick<Problem, 'state' | 'field'> => {\n const all = pointer.split('/').slice(1).map((part) => part.replaceAll('~1', '/').replaceAll('~0', '~'))\n const parts = all[0] === 'stateMachine' && all[1] === 'States' ? all.slice(1) : all\n const state: string[] = []\n let field: string[] = []\n for (let index = 0; index < parts.length; index++) {\n const part = parts[index]!\n if (part === 'States' && index + 1 < parts.length) {\n state.push(parts[++index]!)\n field = []\n } else if ((part === 'ItemProcessor' || part === 'Processor') && parts[index + 1] === 'States') {\n continue\n } else {\n field.push(part)\n }\n }\n return { ...(state.length > 0 && { state: state.join('/') }), ...(field.length > 0 && { field: fieldPath(field) }) }\n}\n\nconst message = (error: ErrorObject, data: boolean) => {\n if (error.keyword === 'additionalProperties' && data && ['Next', 'End', 'StartAt'].includes(String(error.params.additionalProperty))) return `${error.params.additionalProperty} is not a field in dataflow order, where a state runs once the states it reads from have ended`\n if (error.keyword === 'additionalProperties' && !data && error.params.additionalProperty === 'Condition') return 'Condition is a field only in dataflow order (\"order\": \"data\"); in sequence order a Choice decides'\n if (error.keyword === 'additionalProperties') return `${error.params.additionalProperty} is not a field here`\n if (error.keyword === 'required') return `${error.params.missingProperty} is missing`\n if (error.keyword === 'minItems') return `is missing; it needs at least ${String(error.params.limit)}`\n if (error.keyword === 'const') return `must be ${JSON.stringify(error.params.allowedValue)}`\n if (error.keyword === 'discriminator') return data ? 'must be one of Task, Pass, Map, Block, Wait and Fail; in dataflow order a Condition takes the place of Choice, and the run ends when no state is left to run' : 'must be one of Task, Choice, Pass, Map, Block, Wait, Succeed and Fail'\n if (error.keyword === 'pattern' && error.instancePath === '/trigger') return 'names a trigger type <plugin>:<key>, such as app:record, or manual'\n if (error.keyword === 'pattern' && error.instancePath.endsWith('/Assign')) return 'names a variable with letters, digits and _, starting with a letter'\n if (error.keyword === 'pattern') return 'must be an expression written as {% ... %}'\n if (error.keyword === 'maxProperties' && error.instancePath === '/trigger/manual') return 'takes no input'\n if (error.keyword === 'maxProperties' || error.keyword === 'minProperties') return error.instancePath === '/trigger' ? 'holds exactly one trigger: a trigger type such as app:record, or manual' : (error.message ?? 'is not valid')\n if (error.keyword === 'oneOf' && error.schemaPath.endsWith('/oneOf')) return 'needs exactly one of these'\n return error.message ?? 'is not valid'\n}\n\n// The `oneOf` of Next or End, Seconds or Timestamp, says only \"must match exactly one schema\": name the fields instead.\nconst choices: Record<string, string> = { Next: 'needs either Next or End', Seconds: 'needs either Seconds or Timestamp' }\n\n/** The ways a definition does not fit the schema of its order, each with the state and field it is about. */\nexport const schemaProblems = (definition: unknown): Problem[] => {\n const data = typeof definition === 'object' && definition !== null && (definition as { order?: unknown }).order === 'data'\n const validate = data ? validators.data : validators.sequence\n if (validate(definition)) return []\n const problems: Problem[] = []\n const seen = new Set<string>()\n const errors = validate.errors ?? []\n for (const error of errors) {\n // A \"required\" inside the oneOf of a state's Next or End only explains that oneOf's failure, reported in its place.\n if (error.keyword === 'required' && /(oneOf|allOf)\\/\\d+\\/oneOf\\/\\d+\\/required$/.test(error.schemaPath)) continue\n if (error.keyword === 'not') continue\n const where = { ...located(error.instancePath), ...(error.keyword === 'discriminator' && { field: 'Type' }) }\n let text = message(error, data)\n if (error.keyword === 'oneOf') {\n const branch = errors.find((other) => other.instancePath === error.instancePath && other.schemaPath.startsWith(error.schemaPath.replace(/\\/oneOf$/, '/oneOf/')) && other.keyword === 'required')\n text = choices[String(branch?.params.missingProperty)] ?? text\n }\n const key = `${where.state}|${where.field}|${text}`\n if (seen.has(key)) continue\n seen.add(key)\n problems.push({ ...where, message: text })\n }\n return problems\n}\n","import type { Problem } from './problem'\nimport type { Trigger } from './types'\n\n/** Checks a trigger type's input: each problem's field is relative to the input, such as `cron`. */\nexport type TriggerCheck = (input: Record<string, unknown>) => { field?: string; message: string }[]\n\n/**\n * What the schema cannot check of a trigger: that its type is one the app has and can run, `unavailable` holding why\n * it cannot by type, and its input against that type.\n */\nexport const triggerProblems = (trigger: Trigger, triggers: Readonly<Record<string, TriggerCheck>>, unavailable: Readonly<Record<string, string>> = {}): Problem[] => {\n const [type, input] = Object.entries(trigger)[0]!\n if (type === 'manual') return Object.keys(input).length === 0 ? [] : [{ field: 'trigger.manual', message: 'takes no input' }]\n if (Object.hasOwn(unavailable, type)) return [{ field: 'trigger', message: `\"${type}\" cannot run in this app: ${unavailable[type]}` }]\n const check = triggers[type]\n if (!check) return [{ field: 'trigger', message: `\"${type}\" is not a trigger type; use manual or one of ${Object.keys(triggers).join(', ')}` }]\n return check(input).map((problem) => ({ field: `trigger.${type}${problem.field ? `.${problem.field}` : ''}`, message: problem.message }))\n}\n","import { templateExpressions } from './expressions'\nimport { fieldPath } from './problem'\nimport type { State } from './types'\n\n/** Which `$states` field an expression may read where it is: the Task's, Map's or Block's result, a caught error. */\nexport type ExpressionPlace = 'state' | 'result' | 'error'\n\n/** Every expression of a state, with its field and the place it is evaluated in. */\nexport const stateExpressions = (state: State) => {\n const found: { field: string; source: string; place: ExpressionPlace }[] = []\n const add = (value: unknown, base: (string | number)[], place: ExpressionPlace) => {\n for (const { path, source } of templateExpressions(value, base)) found.push({ field: fieldPath(path), source, place })\n }\n // A Task or Map shapes its result with Output and Assign; the other states have no result.\n const after: ExpressionPlace = state.Type === 'Task' || state.Type === 'Map' || state.Type === 'Block' ? 'result' : 'state'\n // In dataflow order, before the state runs\n add(state.Condition, ['Condition'], 'state')\n if (state.Type === 'Fail') {\n add(state.Error, ['Error'], 'state')\n add(state.Cause, ['Cause'], 'state')\n return found\n }\n add(state.Output, ['Output'], after)\n if ('Assign' in state) add(state.Assign, ['Assign'], after)\n if (state.Type === 'Task') add(state.Arguments, ['Arguments'], 'state')\n if (state.Type === 'Map') add(state.Items, ['Items'], 'state')\n if (state.Type === 'Block') {\n add(state.Arguments, ['Arguments'], 'state')\n add(state.Cache?.Key, ['Cache', 'Key'], 'state')\n }\n if (state.Type === 'Wait') {\n add(state.Seconds, ['Seconds'], 'state')\n add(state.Timestamp, ['Timestamp'], 'state')\n }\n if (state.Type === 'Choice') {\n state.Choices.forEach((rule, index) => {\n add(rule.Condition, ['Choices', index, 'Condition'], 'state')\n add(rule.Output, ['Choices', index, 'Output'], 'state')\n add(rule.Assign, ['Choices', index, 'Assign'], 'state')\n })\n }\n if ('Catch' in state) {\n state.Catch?.forEach((catcher, index) => {\n add(catcher.Output, ['Catch', index, 'Output'], 'error')\n add(catcher.Assign, ['Catch', index, 'Assign'], 'error')\n })\n }\n return found\n}\n\n/** The variables a state assigns, in its own Assign, its choice rules' and its catchers'. */\nexport const assignedNames = (state: State) => {\n const names: string[] = []\n if ('Assign' in state && state.Assign) names.push(...Object.keys(state.Assign))\n if (state.Type === 'Choice') for (const rule of state.Choices) names.push(...Object.keys(rule.Assign ?? {}))\n if ('Catch' in state) for (const catcher of state.Catch ?? []) names.push(...Object.keys(catcher.Assign ?? {}))\n return names\n}\n","import type { Machine, State } from './types'\n\n/** The states a state may go to next, each with the field that names it. */\nexport const edges = (state: State): { field: string; target: string }[] => {\n const found: { field: string; target: string }[] = []\n if ('Next' in state && state.Next !== undefined) found.push({ field: 'Next', target: state.Next })\n if (state.Type === 'Choice') {\n state.Choices.forEach((rule, index) => found.push({ field: `Choices[${index}].Next`, target: rule.Next }))\n if (state.Default !== undefined) found.push({ field: 'Default', target: state.Default })\n }\n if ('Catch' in state) state.Catch?.forEach((catcher, index) => catcher.Next !== undefined && found.push({ field: `Catch[${index}].Next`, target: catcher.Next }))\n return found\n}\n\n/** The names of the states reached from `StartAt` along the edges. */\nexport const reachable = (machine: Machine) => {\n const seen = new Set<string>()\n const queue = [machine.StartAt]\n while (queue.length > 0) {\n const name = queue.pop()!\n const state = machine.States[name]\n if (seen.has(name) || !state) continue\n seen.add(name)\n for (const edge of edges(state)) queue.push(edge.target)\n }\n return seen\n}\n\n/** The states reached from `start` along the edges, `start` itself included. */\nexport const reachedFrom = (machine: Machine, start: string) => {\n const seen = new Set<string>()\n const stack = [start]\n while (stack.length > 0) {\n const name = stack.pop()!\n const state = machine.States[name]\n if (seen.has(name) || !state) continue\n seen.add(name)\n stack.push(...edges(state).map((edge) => edge.target))\n }\n return seen\n}\n","/** Variables a definition cannot assign: `$states`, which the runner gives each expression. */\nexport const reservedVariables = new Set(['states'])\n\n/**\n * What an expression may read of `$states.context`, as name paths: the run's input and start time, and a secret by its\n * name (`Secrets.<NAME>`, the name required).\n */\nexport const contextReads = [['Execution', 'Input'], ['Execution', 'StartTime'], ['Secrets']] as const\n","import { expressionReads } from './reads'\nimport { parse } from './expressions'\nimport { contextReads } from './names'\nimport type { ExpressionPlace } from './expression-fields'\nimport { limits } from '../limits'\n\n// What `$states` holds at each place beside its context: the Task's or Map's result after it ran, the error a catcher caught.\nconst statesFields: Record<ExpressionPlace, string> = { state: '', result: 'result', error: 'errorOutput' }\n\nconst startsWith = (path: readonly string[], prefix: readonly string[]) => prefix.every((name, index) => path[index] === name)\n\n// Why a read of `$states.context` is refused: the input, the start time and a secret by name are all it holds, in\n// dataflow order each state's status by its name, `steps`, and in a waiting Task's Arguments its try's token, `token`.\nconst contextProblem = (path: readonly string[], steps: ReadonlySet<string> | undefined, token: boolean) => {\n const rest = path.slice(1)\n if (startsWith(rest, ['Secrets'])) return rest.length >= 2 ? undefined : 'reads $states.context.Secrets as a whole; read one secret by its name, such as $states.context.Secrets.API_TOKEN'\n if (contextReads.some((read) => startsWith(rest, read))) return undefined\n if (startsWith(rest, ['Task'])) {\n if (!token) return \"reads $states.context.Task, which only the Arguments of a Task whose Resource ends in .waitForTaskToken read, as $states.context.Task.Token\"\n return startsWith(rest, ['Task', 'Token']) && rest.length === 2 ? undefined : 'reads $states.context.Task, whose only field is Token'\n }\n if (steps && startsWith(rest, ['Steps'])) {\n if (rest[1] === undefined) return 'reads $states.context.Steps as a whole; read one state\\'s status by its name, such as $states.context.Steps.Save.Status'\n return steps.has(rest[1]) ? undefined : `reads $states.context.Steps.${rest[1]}, but there is no state ${rest[1]} here or around it`\n }\n const held = steps ? 'Execution.Input, Execution.StartTime, Secrets.<NAME> and Steps.<state>' : 'Execution.Input, Execution.StartTime and Secrets.<NAME>'\n return `reads $states.${path.join('.')}; $states.context holds only ${held}`\n}\n\n/** The reads of an expression, or undefined when it does not parse. */\nexport const expressionParsed = (source: string) => {\n const parsed = parse(source)\n return 'error' in parsed ? undefined : expressionReads(parsed.expression)\n}\n\n/**\n * Why an expression breaks the named-reads profile, if it does: it must parse, read no implicit input, read\n * `$states.input` only in the first state of a Map's item processor, read of `$states.context` only the run's input,\n * start time and secrets by name (inside a Block, not the start time), with `token` a waiting Task's token too, and\n * read only variables a state that can run before it assigns.\n */\nexport const readProblems = (source: string, { place, visible, firstOfItem, inBlock = false, steps, token = false }: { place: ExpressionPlace; visible: ReadonlySet<string>; firstOfItem: boolean; inBlock?: boolean; steps?: ReadonlySet<string>; token?: boolean }) => {\n if (source.length > limits.expressionLength) return [`is ${source.length} characters long, more than the ${limits.expressionLength} an expression may be`]\n const parsed = parse(source)\n if ('error' in parsed) return [`does not parse: ${parsed.error.message}${parsed.error.position === undefined ? '' : ` (at character ${parsed.error.position})`}`]\n const reads = expressionReads(parsed.expression)\n const problems: string[] = []\n if (reads.input) problems.push(\"reads the state's input; read the run's input as $states.context.Execution.Input and an earlier result by the variable a state assigned it to\")\n for (const path of reads.states) {\n const [field = ''] = path\n if (field === 'input' && firstOfItem) continue\n if (field !== '' && field === statesFields[place]) continue\n if (field === 'context' && inBlock && startsWith(path, ['context', 'Execution', 'StartTime'])) problems.push(\"reads $states.context.Execution.StartTime, which inside a Block is its own run's start, not part of what it is cached by\")\n else if (field === 'context') {\n const problem = contextProblem(path, steps, token)\n if (problem) problems.push(problem)\n } else if (field === 'input') problems.push(\"reads $states.input, which only the first state of a Map's item processor may read (as the item)\")\n else if (field === '') problems.push('reads $states as a whole; read one of its fields')\n else problems.push(`reads $states.${field}, which is not there${place === 'state' ? '' : ` (here: $states.${statesFields[place]})`}`)\n }\n for (const name of reads.variables) if (!visible.has(name)) problems.push(`reads $${name}, which no state that can run before it assigns`)\n if (reads.evaluates) problems.push('uses $eval, whose reads cannot be checked')\n return [...new Set(problems)]\n}\n","import type { Problem } from './problem'\nimport { allStates } from './inner'\nimport { taskResource } from './task-resource'\nimport type { Definition, Machine } from './types'\n\n/** Every Task's step type, the ones inside Maps and Blocks too. */\nexport const resources = (machine: Machine): string[] => allStates(machine).flatMap(([, state]) => (state.Type === 'Task' ? [taskResource(state.Resource).type] : []))\n\n/**\n * The connections `<plugin>:<connection>` a definition's trigger and steps sign in with, given the connection each\n * type uses by its id (`connectionOf`).\n */\nexport const usedConnections = (definition: Definition, connectionOf: Readonly<Record<string, string>>) => {\n const types = [Object.keys(definition.trigger)[0]!, ...resources(definition.stateMachine)]\n return new Set(types.flatMap((type) => (Object.hasOwn(connectionOf, type) ? [connectionOf[type]!] : [])))\n}\n\n/** A binding in `connections` that none of the definition's types signs in with. */\nexport const connectionProblems = (definition: Definition, connectionOf: Readonly<Record<string, string>>): Problem[] => {\n const used = usedConnections(definition, connectionOf)\n return Object.keys(definition.connections ?? {})\n .filter((key) => !used.has(key))\n .map((key) => ({ field: `connections.${key}`, message: `no trigger or step of this workflow signs in with \"${key}\"; remove it` }))\n}\n","import { reachedFrom } from './graph'\nimport type { Machine, State } from './types'\n\n// The variables each edge of a state carries on, as the runner assigns them: a Choice rule's Assign (else the state's)\n// along its Next, the state's own along Next and Default, and a catcher's along its Next.\nconst passedOn = (state: State) => {\n const own = Object.keys(('Assign' in state && state.Assign) || {})\n const along: { target: string; names: string[] }[] = []\n if ('Next' in state && state.Next !== undefined) along.push({ target: state.Next, names: own })\n if (state.Type === 'Choice') {\n for (const rule of state.Choices) along.push({ target: rule.Next, names: Object.keys(rule.Assign ?? state.Assign ?? {}) })\n if (state.Default !== undefined) along.push({ target: state.Default, names: own })\n }\n if ('Catch' in state) for (const catcher of state.Catch ?? []) if (catcher.Next !== undefined) along.push({ target: catcher.Next, names: Object.keys(catcher.Assign ?? {}) })\n return along\n}\n\n/**\n * The variables each state of a machine may read: those of the outer scopes, and each one assigned on an edge some path\n * from `StartAt` takes before it. A state's own Assign takes effect from the next state on, and only along the edges\n * that assign it: a Choice rule's along its Next, a catcher's along its own.\n */\nexport const visibleVariables = (machine: Machine, outer: ReadonlySet<string>) => {\n const visible = new Map(Object.keys(machine.States).map((name) => [name, new Set(outer)]))\n for (const state of Object.values(machine.States)) {\n for (const { target, names } of passedOn(state)) {\n if (names.length === 0) continue\n for (const later of reachedFrom(machine, target)) for (const variable of names) visible.get(later)?.add(variable)\n }\n }\n return visible\n}\n","import { limits } from '../../limits'\n\nconst units: Record<string, number> = { second: 1, minute: 60, hour: 3600, day: 86_400 }\n\n/**\n * The seconds a cache entry serves, from a number of seconds or text such as `10 minutes`, at most\n * `limits.cacheMaxSeconds`; undefined for anything else, zero and below included, so such an entry is never written.\n */\nexport const cacheSeconds = (ttl: unknown): number | undefined => {\n if (typeof ttl === 'number') return Number.isFinite(ttl) && ttl >= 1 ? Math.min(Math.floor(ttl), limits.cacheMaxSeconds) : undefined\n if (typeof ttl !== 'string') return\n const match = /^(\\d+) (second|minute|hour|day)s?$/.exec(ttl.trim())\n if (!match) return\n return cacheSeconds(Number(match[1]) * units[match[2]!]!)\n}\n","import { cacheSeconds } from '../run/cache/cache-ttl'\nimport { limits } from '../limits'\nimport { templateExpressions } from './expressions'\nimport { fieldPath, type Problem } from './problem'\nimport { expressionParsed } from './check-reads'\nimport type { BlockState } from './types'\n\n// A secret passed to a block would be kept in its run's input: the block reads it itself, by name, when it runs.\nconst secretArguments = (state: BlockState, where: string): Problem[] =>\n [...templateExpressions(state.Arguments, ['Arguments']), ...templateExpressions(state.Cache.Key, ['Cache', 'Key'])].flatMap(({ path, source }) => {\n const reads = expressionParsed(source)\n if (!reads?.states.some((read) => read[0] === 'context' && read[1] === 'Secrets')) return []\n return [{ state: where, field: fieldPath(path), message: 'reads a secret, which a block would keep in its run; read it inside the block as $states.context.Secrets.<NAME>' }]\n })\n\n/**\n * Why a Block cannot be saved beside what every state is checked for: a time to live that is no duration of up to 30\n * days, Arguments or a Key that read a secret, and more Blocks around it than `limits.blockDepth`.\n */\nexport const blockProblems = (state: BlockState, where: string, depth: number): Problem[] => {\n const problems: Problem[] = []\n if (cacheSeconds(state.Cache.Ttl) === undefined) problems.push({ state: where, field: 'Cache.Ttl', message: `is no time to live: give seconds from 1, or text such as \"10 minutes\", \"1 hour\" or \"2 days\", at most ${limits.cacheMaxSeconds / 86_400} days` })\n if (depth > limits.blockDepth) problems.push({ state: where, message: `is inside ${depth - 1} other Blocks, more than the ${limits.blockDepth - 1} a Block may be in` })\n return [...problems, ...secretArguments(state, where)]\n}\n","/**\n * How deeply a value's arrays and objects nest, walked with a stack of its own so no value can overflow the call stack;\n * it stops counting once past `most`, returning `most + 1`.\n */\nexport const nestingDepth = (value: unknown, most: number) => {\n let deepest = 0\n const stack: [unknown, number][] = [[value, 0]]\n while (stack.length > 0) {\n const [item, depth] = stack.pop()!\n if (typeof item !== 'object' || item === null) continue\n if (depth + 1 > most) return most + 1\n deepest = Math.max(deepest, depth + 1)\n for (const child of Object.values(item)) stack.push([child, depth + 1])\n }\n return deepest\n}\n","import { limits } from '../limits'\nimport { nestingDepth } from '../nesting'\nimport type { Problem } from './problem'\n\n/** The problem of a definition, or a state machine, nesting past `limits.definitionDepth`, found without recursion; empty within it. */\nexport const depthProblems = (value: unknown): Problem[] => {\n if (nestingDepth(value, limits.definitionDepth) <= limits.definitionDepth) return []\n return [{ message: `The definition nests more than ${limits.definitionDepth} levels of arrays and objects` }]\n}\n","import type { Problem } from '../problem'\nimport type { Definition } from '../types'\nimport { pinType, fits, pinTypeText } from './pin-type'\nimport { argumentsOf, blocksOutsideBlocks, inputSchema, referenceSchema, tasksOutsideBlocks, type PinSchemas } from './pin-sources'\nimport { parseReference, readText } from './references'\nimport { schemaAt } from './resolve-schema'\n\ntype JsonSchema = Record<string, unknown>\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * Where a Task's argument, or a field at any depth of an argument written as an object, is one read by name of a value\n * whose type does not fit what the step type takes there, as a wire between pins of those types is refused: a problem\n * naming both. A read of a value of any type, or into an input of any type, fits.\n */\nexport const pinProblems = (definition: Definition, schemas: PinSchemas): Problem[] => [\n ...tasksOutsideBlocks(definition.stateMachine).flatMap(({ path, state }) => {\n const input = inputSchema(state, schemas)\n if (!input) return []\n const mismatch = (value: unknown, target: JsonSchema | undefined, field: string[]): Problem[] => {\n const reference = parseReference(value)\n if (!reference || !target) return []\n const source = pinType(referenceSchema(definition, reference, schemas))\n const taken = pinType(target)\n if (fits(source, taken)) return []\n return [{ state: path, field: ['Arguments', ...field].join('.'), message: `reads ${readText(reference)}, ${pinTypeText(source)}, where ${field.join('.')} takes ${pinTypeText(taken)}` }]\n }\n // Each value of an object down to its reads, against the schema at its place\n const walk = (value: unknown, target: JsonSchema | undefined, field: string[]): Problem[] =>\n isObject(value) ? Object.entries(value).flatMap(([name, inner]) => walk(inner, schemaAt(target, [name]), [...field, name])) : mismatch(value, target, field)\n return Object.entries(argumentsOf(state)).flatMap(([key, value]) => walk(value, schemaAt(input, [key]), [key]))\n }),\n // A Block's steps are checked as a workflow of their own, as they run, reading the variables they assign; their\n // input is the Block's Arguments, of any type\n ...blocksOutsideBlocks(definition.stateMachine).flatMap(({ path, state }) =>\n pinProblems({ trigger: { manual: {} }, stateMachine: { ...state.Processor, QueryLanguage: 'JSONata' } }, schemas).map((problem) => ({ ...problem, ...(problem.state !== undefined && { state: `${path}/${problem.state}` }) })),\n ),\n]\n","import { expressionReads } from '../reads'\nimport { parse } from '../expressions'\nimport { assignedNames, stateExpressions } from '../expression-fields'\nimport { innerMachine } from '../inner'\nimport type { Machine, State } from '../types'\n\n/**\n * What a state of a dataflow machine runs after: the states whose variables it reads (`data`), and those whose\n * `$states.context.Steps.<name>` it reads (`status`), of which `handled` are those its `Condition` reads, which take\n * the default skip away for them.\n */\nexport type Dependencies = { data: Set<string>; status: Set<string>; handled: Set<string> }\n\ntype Read = { variables: string[]; steps: string[]; condition: boolean }\n\n// The variables and the Steps entries each expression of a state reads, a Map's item processor's reads of the scopes\n// around it included, as its items run only once those have ended; an item's Condition that reads a status handles it\n// for the Map, which then runs so that Condition can. A Block's steps read only its own input.\nconst readsOf = (state: State): Read[] => {\n const found: Read[] = []\n for (const { field, source } of stateExpressions(state)) {\n const parsed = parse(source)\n if ('error' in parsed) continue\n const reads = expressionReads(parsed.expression)\n const steps = reads.states.filter((path) => path[0] === 'context' && path[1] === 'Steps' && path[2] !== undefined).map((path) => path[2]!)\n found.push({ variables: [...reads.variables], steps, condition: field === 'Condition' })\n }\n const inner = state.Type === 'Map' ? innerMachine(state) : undefined\n if (inner) {\n const own = new Set(Object.values(inner.States).flatMap(assignedNames))\n const innerNames = new Set(Object.keys(inner.States))\n for (const read of Object.values(inner.States).flatMap(readsOf)) {\n found.push({ variables: read.variables.filter((name) => !own.has(name)), steps: read.steps.filter((name) => !innerNames.has(name)), condition: read.condition })\n }\n }\n return found\n}\n\n/** The state of `machine` that assigns each variable, by the variable; a variable two states assign maps to the first. */\nexport const assigners = (machine: Machine) => {\n const by = new Map<string, string>()\n for (const [name, state] of Object.entries(machine.States)) for (const variable of assignedNames(state)) if (!by.has(variable)) by.set(variable, name)\n return by\n}\n\n/** Each state's dependencies on the other states of its dataflow machine, by name. Reads of the scopes around it are not among them. */\nexport const machineDependencies = (machine: Machine): Map<string, Dependencies> => {\n const by = assigners(machine)\n return new Map(\n Object.entries(machine.States).map(([name, state]) => {\n const dependencies: Dependencies = { data: new Set(), status: new Set(), handled: new Set() }\n for (const read of readsOf(state)) {\n for (const variable of read.variables) {\n const from = by.get(variable)\n if (from !== undefined) dependencies.data.add(from)\n }\n for (const step of read.steps) {\n if (!Object.hasOwn(machine.States, step)) continue\n dependencies.status.add(step)\n if (read.condition) dependencies.handled.add(step)\n }\n }\n return [name, dependencies]\n }),\n )\n}\n\n/** Every state a state depends on, data and status alike. */\nexport const dependsOn = (dependencies: Dependencies) => new Set([...dependencies.data, ...dependencies.status])\n\n/** A cycle among the dependencies, as the state names around it with the first again at the end; none when there is none. */\nexport const dependencyCycle = (dependencies: ReadonlyMap<string, Dependencies>): string[] | undefined => {\n const state = new Map<string, 'open' | 'done'>()\n const path: string[] = []\n const visit = (name: string): string[] | undefined => {\n if (state.get(name) === 'done') return\n if (state.get(name) === 'open') return [...path.slice(path.indexOf(name)), name]\n state.set(name, 'open')\n path.push(name)\n for (const next of dependsOn(dependencies.get(name) ?? { data: new Set(), status: new Set(), handled: new Set() })) {\n const found = visit(next)\n if (found) return found\n }\n path.pop()\n state.set(name, 'done')\n return\n }\n for (const name of dependencies.keys()) {\n const found = visit(name)\n if (found) return found\n }\n return\n}\n","import { assignedNames } from '../expression-fields'\nimport type { Problem } from '../problem'\nimport type { Machine } from '../types'\nimport { dependencyCycle, machineDependencies } from './dependencies'\n\n/**\n * The variables each state of a dataflow machine may read: those of the scopes around it, and each one another state of\n * the machine assigns, which makes that state one it runs after. A state does not read its own.\n */\nexport const dataflowVisible = (machine: Machine, outer: ReadonlySet<string>) => {\n const all = Object.entries(machine.States).map(([name, state]) => [name, assignedNames(state)] as const)\n return new Map(all.map(([name, own]) => [name, new Set([...outer, ...all.flatMap(([other, names]) => (other === name ? [] : names)).filter((variable) => !own.includes(variable))])]))\n}\n\n/**\n * What a dataflow machine needs beside its states' own checks: each variable assigned by one state alone, so a read names\n * the one state it runs after, and no state that runs after itself through the states it reads from.\n */\nexport const dataflowProblems = (machine: Machine, where: (name: string) => string): Problem[] => {\n const problems: Problem[] = []\n const first = new Map<string, string>()\n for (const [name, state] of Object.entries(machine.States)) {\n for (const variable of new Set(assignedNames(state))) {\n const earlier = first.get(variable)\n if (earlier === undefined) first.set(variable, name)\n else problems.push({ state: where(name), field: 'Assign', message: `assigns $${variable}, which ${earlier} assigns already; in dataflow order each variable has one state that assigns it` })\n }\n }\n const cycle = dependencyCycle(machineDependencies(machine))\n if (cycle) problems.push({ state: where(cycle[0]!), message: `runs after itself: ${cycle.join(' reads ')}; a state cannot read what runs after it` })\n return problems\n}\n","import { awsProblems } from './check-aws'\nimport { schemaProblems } from './check-schema'\nimport { triggerProblems, type TriggerCheck } from './check-trigger'\nimport { assignedNames, stateExpressions } from './expression-fields'\nimport { expressionSource } from './expressions'\nimport { edges, reachable } from './graph'\nimport { reservedVariables } from './names'\nimport type { Problem } from './problem'\nimport { builtInFunctions } from './reads'\nimport { readProblems } from './check-reads'\nimport { connectionProblems } from './used-connections'\nimport type { Definition, Machine, TaskState } from './types'\nimport { visibleVariables } from './visible'\nimport { blockProblems } from './check-block'\nimport { allStates } from './inner'\nimport { limits } from '../limits'\nimport { depthProblems } from './depth-problems'\nimport { pinProblems } from './pins/check-pins'\nimport type { PinSchemas } from './pins/pin-sources'\nimport { dataflowProblems, dataflowVisible } from './dataflow/check-dataflow'\nimport { orderOf } from './types'\nimport { taskResource } from './task-resource'\nimport { customStepOf } from '../plugin/custom-step-id'\n\n/**\n * What a definition is checked against beside the language: the step types (Task resources) the app has, the\n * arguments each needs (`required`, by step type), its trigger types, each with the check of its input, and why the\n * app cannot run a type it knows (`unavailable`, by step or trigger type), and the connection `<plugin>:<connection>`\n * each type that signs in uses (`connections`, by step or trigger type); without it the bindings are not checked.\n * With `pins`, the types' input and output schemas and the app's records, an argument that reads a value by name is\n * checked to take that value's type. `versioned` names the latest version of each step type kept by version, by its id\n * without one, such as `custom:invoice` for `custom:invoice:3`: a Task that names no version is refused naming it.\n */\nexport type CheckOptions = {\n resources: readonly string[]\n required?: Readonly<Record<string, readonly string[]>>\n triggers: Readonly<Record<string, TriggerCheck>>\n unavailable?: Readonly<Record<string, string>>\n connections?: Readonly<Record<string, string>>\n pins?: PinSchemas\n versioned?: Readonly<Record<string, string>>\n}\n\n// `blocks`: how many Blocks the machine is inside; `data`: whether its states run in dataflow order, and `steps` the\n// names of the states around it whose status its states may read.\ntype Scope = { path: string[]; outer: ReadonlySet<string>; item: boolean; blocks: number; data: boolean; steps: ReadonlySet<string> }\n\n// The arguments a Task's step type needs and its Arguments leave out; none when Arguments is one expression, whose\n// value is known only when it runs.\nconst missingArguments = (state: TaskState, options: CheckOptions) => {\n const needed = options.required?.[taskResource(state.Resource).type] ?? []\n if (expressionSource(state.Arguments) !== undefined) return []\n const given = typeof state.Arguments === 'object' && state.Arguments !== null ? (state.Arguments as Record<string, unknown>) : {}\n return needed.filter((name) => given[name] === undefined || given[name] === '')\n}\n\n// A Task runs its step type within 300 seconds; one that waits for an outside result may wait longer, its heartbeats\n// coming more often than its timeout, and hands its work off on every try, so it caches nothing. A custom step waits\n// for its runner as such a Task does, 300 seconds by default, and so takes no suffix.\nconst waitProblems = (state: TaskState): Omit<Problem, 'state'>[] => {\n const { type, waits } = taskResource(state.Resource)\n const custom = customStepOf(type) !== undefined\n if (custom && waits) return [{ field: 'Resource', message: `ends in .waitForTaskToken, but ${type} is a custom step, which waits for the runner that runs it already: write ${type}` }]\n if (!waits && !custom) {\n return [\n ...(state.TimeoutSeconds !== undefined && state.TimeoutSeconds > limits.taskTimeoutSeconds ? [{ field: 'TimeoutSeconds', message: `is ${state.TimeoutSeconds}, more than the ${limits.taskTimeoutSeconds} seconds a step type runs; only a Task whose Resource ends in .waitForTaskToken waits longer` }] : []),\n ...(state.HeartbeatSeconds !== undefined ? [{ field: 'HeartbeatSeconds', message: 'is for a Task whose Resource ends in .waitForTaskToken, whose outside executor sends heartbeats; this step type ends or fails within its TimeoutSeconds' }] : []),\n ]\n }\n const timeout = state.TimeoutSeconds ?? (custom ? limits.taskTimeoutSeconds : limits.waitingTaskTimeoutSeconds)\n return [\n ...(state.HeartbeatSeconds !== undefined && state.HeartbeatSeconds >= timeout ? [{ field: 'HeartbeatSeconds', message: `is ${state.HeartbeatSeconds}, which must be less than the Task's TimeoutSeconds (${timeout})` }] : []),\n ...(state.Cache === true ? [{ field: 'Cache', message: custom ? 'is true, but a custom step runs on a runner on every try and caches nothing' : 'is true, but a Task that waits for an outside result hands its work off on every try and caches nothing' }] : []),\n ]\n}\n\nconst machineProblems = (machine: Machine, scope: Scope, options: CheckOptions): Problem[] => {\n const problems: Problem[] = []\n const where = (name: string) => [...scope.path, name].join('/')\n const prefix = scope.path.length > 0 ? { state: scope.path.join('/') } : {}\n const names = Object.keys(machine.States)\n const { data } = scope\n // In dataflow order a machine has no start: each state starts once the states it reads from have ended\n const start = machine.StartAt === undefined ? undefined : machine.States[machine.StartAt]\n if (!data && !start) problems.push({ ...prefix, field: 'StartAt', message: `names \"${machine.StartAt}\", which is not a state here` })\n const visible = data ? dataflowVisible(machine, scope.outer) : visibleVariables(machine, scope.outer)\n const reached = data ? undefined : reachable(machine)\n const steps = new Set([...scope.steps, ...names])\n\n for (const name of names) {\n const state = machine.States[name]!\n if (reached && !reached.has(name) && start) problems.push({ state: where(name), message: `is never reached from \"${machine.StartAt}\"` })\n for (const edge of edges(state)) {\n if (!machine.States[edge.target]) problems.push({ state: where(name), field: edge.field, message: `names \"${edge.target}\", which is not a state here` })\n }\n for (const variable of assignedNames(state)) {\n if (reservedVariables.has(variable) || builtInFunctions.has(variable)) problems.push({ state: where(name), field: 'Assign', message: `cannot assign $${variable}, a name the runner or JSONata keeps` })\n if (scope.outer.has(variable)) problems.push({ state: where(name), field: 'Assign', message: `cannot assign $${variable}, which an outer state assigns already` })\n }\n const task = state.Type === 'Task' ? taskResource(state.Resource) : undefined\n if (task && options.unavailable && Object.hasOwn(options.unavailable, task.type)) {\n problems.push({ state: where(name), field: 'Resource', message: `\"${task.type}\" cannot run in this app: ${options.unavailable[task.type]}` })\n } else if (task && options.versioned && Object.hasOwn(options.versioned, task.type)) {\n problems.push({ state: where(name), field: 'Resource', message: `\"${task.type}\" names no version: write ${options.versioned[task.type]}` })\n } else if (task && !options.resources.includes(task.type)) {\n problems.push({ state: where(name), field: 'Resource', message: `\"${task.type}\" is not a step type; use one of ${options.resources.join(', ')}${task.waits ? ', followed by .waitForTaskToken' : ''}` })\n }\n if (state.Type === 'Task') for (const missing of missingArguments(state, options)) problems.push({ state: where(name), field: `Arguments.${missing}`, message: `is missing; ${task!.type} needs it` })\n if (state.Type === 'Task') for (const problem of waitProblems(state)) problems.push({ state: where(name), ...problem })\n // In dataflow order every state of an item's machine starts from the item, which it reads as $states.input\n const firstOfItem = scope.item && (data || name === machine.StartAt)\n for (const { field, source, place } of stateExpressions(state)) {\n const token = Boolean(task?.waits) && /^Arguments($|[.[])/.test(field)\n for (const message of readProblems(source, { place, visible: visible.get(name)!, firstOfItem, inBlock: scope.blocks > 0, token, ...(data && { steps }) })) problems.push({ state: where(name), field, message })\n }\n if (state.Type === 'Map') problems.push(...machineProblems(state.ItemProcessor, { ...scope, path: [...scope.path, name], outer: visible.get(name)!, item: true, steps }, options))\n // A Block's steps run as a run of their own: they read its input, never the variables around it.\n if (state.Type === 'Block') {\n problems.push(...blockProblems(state, where(name), scope.blocks + 1))\n problems.push(...machineProblems(state.Processor, { path: [...scope.path, name], outer: new Set(), item: false, blocks: scope.blocks + 1, data, steps: new Set() }, options))\n }\n }\n if (data) problems.push(...dataflowProblems(machine, where))\n return problems\n}\n\nconst wholeProblems = (definition: Definition): Problem[] => {\n const names = allStates(definition.stateMachine).map(([name]) => name)\n const problems: Problem[] = []\n if (names.length > limits.states) problems.push({ field: 'stateMachine.States', message: `holds ${names.length} states, more than the ${limits.states} a workflow may have` })\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) problems.push({ state: name, message: 'is a state name used twice; names are unique across the whole state machine, Maps and Blocks included' })\n seen.add(name)\n }\n return problems\n}\n\n/**\n * Why a definition cannot be saved, as it is checked on every save: its size and nesting, its shape against `definitionSchema`, its\n * trigger and the connections it binds, then each edge, each Task's step type and what each expression reads, in the named-reads profile. Empty when\n * it can be saved.\n */\nexport const checkDefinition = (definition: unknown, options: CheckOptions): Problem[] => {\n const bytes = new TextEncoder().encode(JSON.stringify(definition) ?? '').length\n if (bytes > limits.definitionBytes) return [{ message: `The definition is ${bytes} bytes as JSON, more than the ${limits.definitionBytes} a workflow may have` }]\n const deep = depthProblems(definition)\n if (deep.length > 0) return deep\n // What Step Functions runs and this app does not, named, before the shape a standard document would otherwise miss\n const aws = awsProblems(definition)\n if (aws.length > 0) return aws\n const shape = schemaProblems(definition)\n if (shape.length > 0) return shape\n const document = definition as Definition\n return [...triggerProblems(document.trigger, options.triggers, options.unavailable), ...(options.connections ? connectionProblems(document, options.connections) : []), ...wholeProblems(document), ...machineProblems(document.stateMachine, { path: [], outer: new Set(), item: false, blocks: 0, data: orderOf(document) === 'data', steps: new Set() }, options), ...(options.pins ? pinProblems(document, options.pins) : [])]\n}\n","import { expressionSource, parse } from '../expressions'\nimport { readText, type Reference } from './references'\n\n/** A Comparison's operator, as JSONata writes it: Equals, Not equals, Greater and Less. */\nexport type CompareOp = '=' | '!=' | '>' | '<'\n\n/** A value a condition node takes: one read by name, or a value of its own. */\nexport type ConditionOperand = { read: Reference } | { value: string | number | boolean }\n\n/** A regular expression a Matches node tests text against: its source and its flags, `i` and `m`, as JSONata writes `/source/flags`. */\nexport type ConditionPattern = { pattern: string; flags: string }\n\n/**\n * A Condition taken apart into the editor's nodes: a Comparison of two values, a Matches of text against a pattern\n * (`$contains`), an All of or an Any of two conditions or more (`and`, `or`), or a Not of one, where a condition is\n * another of these or a value of its own or read by name.\n */\nexport type ConditionPart =\n | { kind: 'compare'; op: CompareOp; sides: [ConditionOperand, ConditionOperand] }\n | { kind: 'matches'; sides: [ConditionOperand, ConditionPattern] }\n | { kind: 'logic'; op: 'and' | 'or'; sides: ConditionSide[] }\n | { kind: 'not'; sides: [ConditionSide] }\n\n/** What a condition node's input takes: a node of its own, or a value. */\nexport type ConditionSide = ConditionPart | ConditionOperand\n\n/** What any input of a condition node holds: a side, or a Matches node's pattern. */\nexport type ConditionInput = ConditionSide | ConditionPattern\n\n/** What a step's status can be, as `$states.context.Steps.<name>.Status` reads it. */\nexport const stepStatuses = ['SUCCEEDED', 'FAILED', 'TIMED_OUT', 'ABORTED', 'SKIPPED'] as const\n\nconst compareOps: readonly string[] = ['=', '!=', '>', '<']\n\n/** Whether a side is a node of its own rather than a value. */\nexport const isConditionPart = (side: ConditionInput): side is ConditionPart => 'kind' in side\n\ntype Node = { type: string; value?: unknown; steps?: Node[]; lhs?: Node; rhs?: Node; expressions?: Node[]; arguments?: Node[]; procedure?: Node; [key: string]: unknown }\n\n// A step of a path read by name, which says nothing but its name\nconst plainStep = (step: Node) => Object.keys(step).every((key) => key === 'type' || key === 'value' || key === 'position')\n\n// The read a path or a variable is, as references read them: the run's input, a step's status or a variable\nconst referenceOf = (node: Node): Reference | undefined => {\n if (node.type === 'variable' && plainStep(node) && typeof node.value === 'string' && node.value !== '' && node.value !== 'states') return { base: { variable: node.value }, path: [] }\n if (node.type !== 'path' || !node.steps || !node.steps.every(plainStep)) return\n const [first, ...rest] = node.steps\n if (first?.type !== 'variable' || typeof first.value !== 'string' || !rest.every((step) => step.type === 'name' && typeof step.value === 'string')) return\n const names = rest.map((step) => step.value as string)\n if (first.value !== 'states') return first.value === '' ? undefined : { base: { variable: first.value }, path: names }\n if (names[0] === 'context' && names[1] === 'Steps' && names.length > 2) return { base: { step: names[2]! }, path: names.slice(3) }\n if (names[0] === 'context' && names[1] === 'Execution' && names[2] === 'Input') return { base: { input: true }, path: names.slice(3) }\n return\n}\n\nconst operandOf = (node: Node): ConditionOperand | undefined => {\n if (node.type === 'string' || node.type === 'number' || (node.type === 'value' && typeof node.value === 'boolean')) return { value: node.value as string | number | boolean }\n const read = referenceOf(node)\n return read && { read }\n}\n\n// The conditions a chain of one operator joins, `a and b and c` as three: JSONata takes its left side first, so the\n// chain goes down its left sides; one in brackets is a node of its own\nconst chainOf = (node: Node, op: string): Node[] => (node.type === 'binary' && node.value === op ? [...chainOf(node.lhs!, op), node.rhs!] : [node])\n\nconst isRegex = (value: unknown): value is RegExp => value instanceof RegExp\n\nconst partOf = (node: Node): ConditionPart | undefined => {\n if (node.type === 'block' && node.expressions?.length === 1) return partOf(node.expressions[0]!)\n if (node.type === 'binary' && (node.value === 'and' || node.value === 'or')) {\n const sides = chainOf(node, node.value).map(sideOf)\n return sides.every((side) => side !== undefined) ? { kind: 'logic', op: node.value, sides: sides as ConditionSide[] } : undefined\n }\n const [text, pattern] = node.arguments ?? []\n if (node.type === 'function' && node.procedure?.type === 'variable' && node.procedure.value === 'contains' && node.arguments?.length === 2 && pattern?.type === 'regex' && isRegex(pattern.value)) {\n const operand = operandOf(text!)\n // JSONata gives every regular expression the g flag, which it does not write\n return operand && { kind: 'matches', sides: [operand, { pattern: pattern.value.source, flags: pattern.value.flags.replace('g', '') }] }\n }\n if (node.type === 'binary' && compareOps.includes(node.value as string)) {\n const [lhs, rhs] = [operandOf(node.lhs!), operandOf(node.rhs!)]\n return lhs && rhs && { kind: 'compare', op: node.value as CompareOp, sides: [lhs, rhs] }\n }\n if (node.type === 'function' && node.procedure?.type === 'variable' && node.procedure.value === 'not' && node.arguments?.length === 1) {\n const side = sideOf(node.arguments[0]!)\n return side && { kind: 'not', sides: [side] }\n }\n return\n}\n\n// An And's, an Or's or a Not's input: a node of its own, true or false, or a read\nconst sideOf = (node: Node): ConditionSide | undefined => {\n const part = partOf(node)\n if (part) return part\n const operand = operandOf(node)\n return operand && ('read' in operand || typeof operand.value === 'boolean') ? operand : undefined\n}\n\n// Text JSONata reads as it is between single quotes, which it has no escape for; any other in double quotes, as JSON writes it\nconst quoted = (value: string) => (/^[^'\\\\\\x00-\\x1f]*$/.test(value) ? `'${value}'` : JSON.stringify(value))\n\nconst operandText = (operand: ConditionOperand) => {\n if ('read' in operand) return readText(operand.read)\n return typeof operand.value === 'string' ? quoted(operand.value) : String(operand.value)\n}\n\n// JSONata binds a comparison closer than And, and And closer than Or. A chain of one operator is one node, so a node of\n// that operator inside it was in brackets\nconst sideText = (side: ConditionSide, parent: 'and' | 'or') => {\n if (!isConditionPart(side)) return operandText(side)\n const text = partText(side)\n if (side.kind !== 'logic') return text\n return side.op === parent || (parent === 'and' && side.op === 'or') ? `(${text})` : text\n}\n\nconst partText = (part: ConditionPart): string => {\n if (part.kind === 'compare') return `${operandText(part.sides[0])} ${part.op} ${operandText(part.sides[1])}`\n if (part.kind === 'matches') return `$contains(${operandText(part.sides[0])}, /${part.sides[1].pattern}/${part.sides[1].flags})`\n if (part.kind === 'logic') return part.sides.map((side) => sideText(side, part.op)).join(` ${part.op} `)\n const [side] = part.sides\n return `$not(${isConditionPart(side) ? partText(side) : operandText(side)})`\n}\n\n/** The Condition a node and what it takes write: `{% $states.context.Steps.Save.Status = 'SUCCEEDED' %}`. */\nexport const conditionValue = (part: ConditionPart) => `{% ${partText(part)} %}`\n\n/**\n * A Condition taken apart into nodes, when it is a Comparison, a Matches, an All of, an Any of or a Not of values and\n * reads by name and\n * writing those nodes back gives it exactly as it is; undefined for any other, such as one that computes, or is spaced\n * or bracketed otherwise, which stays an expression, so no Condition is ever rewritten.\n */\nexport const conditionParts = (value: unknown): ConditionPart | undefined => {\n const source = expressionSource(value)\n if (source === undefined) return\n const parsed = parse(source)\n if ('error' in parsed) return\n const part = partOf(parsed.expression.ast() as Node)\n return part && conditionValue(part) === value ? part : undefined\n}\n\n/** A value a Select gives or compares with: text, a number, or true or false. */\nexport type SelectValue = string | number | boolean\n\n/**\n * A value chosen by another, which a Select node draws: the value it looks at, read by name or one of its own, a case\n * per value it can be with what it gives then, and what it gives for any other. JSONata writes it as a chain of\n * conditionals: `$topic = 'sales' ? 'sales@example.com' : $topic = 'support' ? 'help@example.com' : 'info@example.com'`.\n */\nexport type SelectPart = { operand: ConditionOperand; cases: { when: SelectValue; then: SelectValue }[]; otherwise: SelectValue }\n\nconst valueOf = (node: Node | undefined): SelectValue | undefined => {\n if (!node) return\n const operand = operandOf(node)\n return operand && 'value' in operand ? operand.value : undefined\n}\n\nconst selectOf = (node: Node): SelectPart | undefined => {\n const cases: SelectPart['cases'] = []\n let operand: ConditionOperand | undefined\n let at: Node | undefined = node\n // Each conditional of the chain compares the same value with one of its own, and gives one of its own\n while (at?.type === 'condition') {\n const test = at.condition as Node | undefined\n if (test?.type !== 'binary' || test.value !== '=') return\n const read = operandOf(test.lhs!)\n const [when, then] = [valueOf(test.rhs), valueOf(at.then as Node | undefined)]\n if (!read || when === undefined || then === undefined) return\n if (operand && operandText(operand) !== operandText(read)) return\n operand = read\n cases.push({ when, then })\n at = at.else as Node | undefined\n }\n const otherwise = valueOf(at)\n return operand && otherwise !== undefined ? { operand, cases, otherwise } : undefined\n}\n\n/** The value a Select node and what it holds write: `{% $topic = 'sales' ? 'sales@example.com' : 'info@example.com' %}`. */\nexport const selectValue = ({ operand, cases, otherwise }: SelectPart) => {\n const read = operandText(operand)\n const text = (value: SelectValue) => operandText({ value })\n return `{% ${[...cases.map(({ when, then }) => `${read} = ${text(when)} ? ${text(then)}`), text(otherwise)].join(' : ')} %}`\n}\n\n/**\n * A value taken apart into a Select node, when it is a chain of conditionals that compare one value with values of\n * their own and give values of their own, and writing the node back gives it exactly as it is; undefined for any other.\n */\nexport const selectParts = (value: unknown): SelectPart | undefined => {\n const source = expressionSource(value)\n if (source === undefined) return\n const parsed = parse(source)\n if ('error' in parsed) return\n const part = selectOf(parsed.expression.ast() as Node)\n return part && selectValue(part) === value ? part : undefined\n}\n","import { expressionParsed } from './check-reads'\nimport { stateExpressions } from './expression-fields'\nimport { edges } from './graph'\nimport { innerMachine } from './inner'\nimport type { Problem } from './problem'\nimport type { Definition, Machine, State } from './types'\n\n// The states reached from `start` along the edges, without passing through `avoid`, which assigns its variables anew.\nconst reachedAvoiding = (machine: Machine, start: string, avoid: string) => {\n const seen = new Set<string>()\n const stack = [start]\n while (stack.length > 0) {\n const name = stack.pop()!\n const state = machine.States[name]\n if (seen.has(name) || name === avoid || !state) continue\n seen.add(name)\n stack.push(...edges(state).map((edge) => edge.target))\n }\n return seen\n}\n\n// The variables a state reads: its own expressions', and those of the states of a Map inside it, which see its variables.\nconst readVariables = (state: State): Set<string> => {\n const names = new Set(stateExpressions(state).flatMap(({ source }) => [...(expressionParsed(source)?.variables ?? [])]))\n if (state.Type === 'Map') for (const inner of Object.values(state.ItemProcessor?.States ?? {})) for (const name of readVariables(inner)) names.add(name)\n return names\n}\n\nconst machineWarnings = (machine: Machine, path: string[]): Problem[] => {\n const where = (name: string) => [...path, name].join('/')\n const warnings: Problem[] = []\n for (const [name, state] of Object.entries(machine.States)) {\n const inner = innerMachine(state)\n if (inner) warnings.push(...machineWarnings(inner, [...path, name]))\n if (state.Type !== 'Block' || state.Next === undefined || !state.Assign) continue\n const assigned = new Set(Object.keys(state.Assign))\n const waits = [...reachedAvoiding(machine, state.Next, name)].filter((other) => machine.States[other]!.Type === 'Wait')\n const warned = new Set<string>()\n for (const wait of waits) {\n const after = machine.States[wait]!\n if (!('Next' in after) || after.Next === undefined) continue\n for (const reader of reachedAvoiding(machine, after.Next, name)) {\n const read = [...readVariables(machine.States[reader]!)].filter((variable) => assigned.has(variable))\n if (read.length === 0 || warned.has(reader)) continue\n warned.add(reader)\n const names = read.map((variable) => `$${variable}`).join(', ')\n warnings.push({ state: where(reader), message: `reads ${names} after the Wait \"${wait}\", and the Block \"${name}\" set it before that Wait. If it holds something that expires, such as a signed link, it may have expired by then: set it after the Wait instead. If it holds what the block stored, you can leave it.` })\n }\n }\n }\n return warnings\n}\n\n/**\n * What a save goes through with but its author should know, each on the state it concerns: a state that reads, after a\n * Wait, a variable a Block assigned before it, whose value may have expired by then. It reads a draft as it stands, so an\n * editor can show them before the definition can be saved.\n */\nexport const definitionWarnings = (definition: Definition): Problem[] => machineWarnings(definition.stateMachine, [])\n","import { expressionSource } from '../definition/expressions'\nimport type { Machine, Order } from '../definition/types'\nimport type { Checkpoint } from './port'\n\n/** What a re-run reads of a failed run's checkpoint to know where its scope goes on. */\nexport type EarlierCheckpoint = Pick<Checkpoint, 'scope' | 'next'>\n\n// The machine a scope runs: the run's own, the item processor of each Map its scope names, as `innerScope` writes it,\n// or in data order a state of its own, its name as `scopeOf` writes it, which no Map item's part can be, since a name\n// is written URI-encoded, without brackets.\nconst itemPart = /^(.*)\\.\\d+\\[\\d+\\]$/\nconst machineOf = (machine: Machine, scope: string, order: Order): Machine | string => {\n if (scope === '') return machine\n let inner = machine\n for (const part of scope.split('/')) {\n const item = itemPart.exec(part)\n const name = decodeURIComponent(item ? item[1]! : part)\n const state = inner.States[name]\n if (!item) {\n if (order !== 'data') return `The run goes on at state \"${name}\" as data order runs it, and the workflow now runs in sequence`\n if (!state) return `The run goes on at state \"${name}\", which the workflow no longer has`\n inner = { States: { [name]: state } }\n continue\n }\n if (state?.Type !== 'Map') return `The run goes on in the Map \"${name}\"${scope.includes('/') ? ` of ${scope}` : ''}, which the workflow no longer has`\n inner = state.ItemProcessor\n }\n return inner\n}\n\n/**\n * The problem with re-running a failed run whose scopes stand at `checkpoints` on `machine`, the workflow's version\n * now, in `order`: a scope that would go on at a state, or in a Map, the version does not have, or one of the other\n * order; undefined when there is none.\n * Scopes that ended stay as they ran.\n * A re-run goes on from each scope's last checkpoint, as a run does after a crash: the steps since run again, the\n * recorded ones before it never.\n */\nexport const rerunProblem = (machine: Machine, checkpoints: readonly EarlierCheckpoint[], order: Order = 'sequence') => {\n // The order a run ran in, which its scopes tell: the run's own scope and a Map item's outermost run in sequence, a\n // state's name in data order. A run of the other order would start its states anew, running their writes again.\n const ranIn = checkpoints.some(({ scope }) => scope !== '' && !itemPart.test(scope.split('/')[0]!)) ? 'data' : 'sequence'\n if (checkpoints.length > 0 && ranIn !== order) return `The run ran in ${ranIn} order, and the workflow now runs in ${order} order; switch it back to re-run it`\n for (const { scope, next } of checkpoints) {\n // A scope that ended, such as a finished Map item, is history and stays as it ran.\n if (next === null) continue\n const inner = machineOf(machine, scope, order)\n if (typeof inner === 'string') return inner\n if (!Object.hasOwn(inner.States, next)) return `The run goes on at state \"${next}\"${scope ? ` in ${scope}` : ''}, which the workflow no longer has`\n }\n return\n}\n\n/** A failed run's checkpoint as its re-run, started at `clock`, takes it up: the state it goes on at from its first try, now. */\nexport const rerunCheckpoint = <C extends Checkpoint>({ resumeAt: _, ...checkpoint }: C, clock: Date) => ({ ...checkpoint, attempt: 1, failures: [], clock })\n\n/** How a state keeps its whole result in a variable. */\nexport const resultRead = '{% $states.result %}'\n\n/**\n * What a kept step assigned, with each variable its state has on the version a re-run runs that keeps its whole result\n * holding that result, whatever it held then: a step kept as it ran still gives what a later step now reads from it, and\n * nothing runs again for it. Its other variables stay as they ran, and so does all a step that did not succeed assigned.\n * The step's output is its whole result only where its state in `ran`, the version the earlier run ran, had no `Output`:\n * a step whose result was shaped then keeps what it assigned, as nothing knows its whole result any more.\n */\nexport const keptAssigned = (machine: Machine, ran: Machine, step: { scope: string; state: string; status: string; output?: unknown; assigned?: unknown }) => {\n // A step that failed into a catcher gave an error, not its result, and assigned what the catcher says\n const state = step.scope === '' && step.status === 'succeeded' ? machine.States[step.state] : undefined\n const before = ran.States[step.state]\n const assign = state && 'Assign' in state ? (state.Assign as Record<string, unknown> | undefined) : undefined\n if (!state || !assign || !before || ('Output' in before && before.Output !== undefined)) return undefined\n const assigned = (step.assigned ?? {}) as Record<string, unknown>\n const whole = Object.keys(assign).filter((name) => expressionSource(assign[name])?.trim() === '$states.result' && JSON.stringify(assigned[name]) !== JSON.stringify(step.output))\n return whole.length === 0 ? undefined : { ...assigned, ...Object.fromEntries(whole.map((name) => [name, step.output])) }\n}\n","import type { Machine, State } from '../definition/types'\nimport type { SegmentContext, StateResult } from './context'\nimport type { StepLog, TaskHandler } from './port'\nimport { mapNames, visitKey } from './replay-match'\nimport type { Replay } from './replay-of'\n\n/** The log line of a step a replay held back, which the run's page marks it by. */\nexport const heldBackLog = 'Not sent: replay'\n\n/** Whether a replay holds back this call: anything but its type saying `false`, it writes. */\nexport const heldBack = (context: SegmentContext, handler: TaskHandler | undefined, args: unknown) => Boolean(context.replay) && handler?.writes?.(args) !== false\n\n/** The replayed run's state of this name in the scope of these Map names. */\nconst stateIn = (machine: Machine, maps: readonly string[], name: string): State | undefined => {\n let inner: Machine | undefined = machine\n for (const map of maps) {\n const state: State | undefined = inner?.States[map]\n inner = state?.Type === 'Map' ? state.ItemProcessor : undefined\n }\n return inner?.States[name]\n}\n\n/**\n * What a held-back step takes from the replayed run's step of the same state and visit of it in the same scope, as\n * `logical` names it by visits: its\n * error, or its result, which only a Task or Block that did not shape it with `Output` saved as it was. Undefined when that\n * run has no such step, its step was still retrying, or saved its result shaped.\n */\nexport const replayedOutcome = (replay: Replay, at: { scope: string; logical: string; visit: number; name: string }) => {\n const step = replay.outcomes.get(visitKey(at.logical, at.name, at.visit))\n if (!step || step.status === 'retrying') return\n if (step.status !== 'succeeded') return { failure: { Error: step.error ?? 'States.Runtime', Cause: step.cause ?? '' } }\n const state = stateIn(replay.machine, mapNames(at.scope), at.name)\n if ((state?.Type !== 'Task' && state?.Type !== 'Block') || state.Output !== undefined) return\n return { result: step.output ?? null }\n}\n\n/** A held-back step the replayed run gave nothing for: a null output, on to its next state. */\nexport const emptyTask = (state: { Next?: string }, input: unknown, logs: StepLog[]): StateResult => ({ kind: 'step', status: 'succeeded', next: state.Next ?? null, input, output: null, logs })\n"],"mappings":"uqBAEA,IAAMA,EAAY,GAAqD,OAAO6B,GAAU,YAAYA,GAAkB,CAAC,MAAM,QAAQA,CAAK,EAGpIC,GAAiB,CAAC,YAAa,aAAc,iBAAkB,aAAc,aAAc,WAAW,EAEtGC,GAAoC,CACxC,WAAY,iFACZ,YAAa,0DACb,aAAc,yDACd,sBAAuB,kDACvB,2BAA4B,kDAC5B,YAAa,6EACf,EAEMC,GAAiB,EAAiB,IACjChC,EAASiC,CAAM,EACb,OAAO,QAAQA,CAAM,CAAC,CAAC,SAAS,CAACC,EAAMC,KAAsB,CAClE,GAAI,CAACnC,EAASmC,CAAK,EAAG,MAAO,CAAC,EAC9B,IAAMC,EAAQ,CAAC,GAAGC,EAAMH,CAAI,CAAC,CAAC,KAAK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