@uipath/maestro-builder-sdk 5.2.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.
Files changed (238) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +322 -0
  3. package/dist/bindings-v2.d.ts +37 -0
  4. package/dist/bindings-v2.js +155 -0
  5. package/dist/bindings.d.ts +6 -0
  6. package/dist/bindings.js +6 -0
  7. package/dist/bpmn/bpmn-expr-check.d.ts +41 -0
  8. package/dist/bpmn/bpmn-expr-check.js +218 -0
  9. package/dist/bpmn/bpmn-sdk.d.ts +2257 -0
  10. package/dist/bpmn/bpmn-sdk.js +1476 -0
  11. package/dist/bpmn/check-cli.d.ts +3 -0
  12. package/dist/bpmn/check-cli.js +32 -0
  13. package/dist/bpmn/check.d.ts +25 -0
  14. package/dist/bpmn/check.js +430 -0
  15. package/dist/bpmn/compile-cli.d.ts +3 -0
  16. package/dist/bpmn/compile-cli.js +60 -0
  17. package/dist/bpmn/connector.d.ts +56 -0
  18. package/dist/bpmn/connector.js +199 -0
  19. package/dist/bpmn/decompile-cli.d.ts +8 -0
  20. package/dist/bpmn/decompile-cli.js +54 -0
  21. package/dist/bpmn/decompile.d.ts +6 -0
  22. package/dist/bpmn/decompile.js +1108 -0
  23. package/dist/bpmn/format-profile.d.ts +27 -0
  24. package/dist/bpmn/format-profile.js +11 -0
  25. package/dist/bpmn/intsvc.d.ts +77 -0
  26. package/dist/bpmn/intsvc.js +155 -0
  27. package/dist/bpmn/load.d.ts +4 -0
  28. package/dist/bpmn/load.js +22 -0
  29. package/dist/bpmn/merge-cli.d.ts +3 -0
  30. package/dist/bpmn/merge-cli.js +45 -0
  31. package/dist/bpmn/merge.d.ts +19 -0
  32. package/dist/bpmn/merge.js +293 -0
  33. package/dist/bpmn/registry-types.json +1869 -0
  34. package/dist/bpmn/serialize.d.ts +28 -0
  35. package/dist/bpmn/serialize.js +757 -0
  36. package/dist/bpmn/tidy-cli.d.ts +2 -0
  37. package/dist/bpmn/tidy-cli.js +39 -0
  38. package/dist/bpmn/typed-node.d.ts +382 -0
  39. package/dist/bpmn/typed-node.js +551 -0
  40. package/dist/bpmn/uipath-moddle.v1.json +823 -0
  41. package/dist/bpmn/xml-ranges.d.ts +45 -0
  42. package/dist/bpmn/xml-ranges.js +151 -0
  43. package/dist/case/case-expr-check.d.ts +35 -0
  44. package/dist/case/case-expr-check.js +85 -0
  45. package/dist/case/case-sdk.d.ts +1282 -0
  46. package/dist/case/case-sdk.js +923 -0
  47. package/dist/case/check-cli.d.ts +3 -0
  48. package/dist/case/check-cli.js +31 -0
  49. package/dist/case/check.d.ts +18 -0
  50. package/dist/case/check.js +456 -0
  51. package/dist/case/compile-cli.d.ts +3 -0
  52. package/dist/case/compile-cli.js +291 -0
  53. package/dist/case/decompile-cli.d.ts +9 -0
  54. package/dist/case/decompile-cli.js +117 -0
  55. package/dist/case/decompile.d.ts +187 -0
  56. package/dist/case/decompile.js +1170 -0
  57. package/dist/case/entry-points.d.ts +79 -0
  58. package/dist/case/entry-points.js +118 -0
  59. package/dist/case/format-profile.d.ts +60 -0
  60. package/dist/case/format-profile.js +79 -0
  61. package/dist/case/ids.d.ts +24 -0
  62. package/dist/case/ids.js +76 -0
  63. package/dist/case/load.d.ts +12 -0
  64. package/dist/case/load.js +32 -0
  65. package/dist/case/preserve.d.ts +133 -0
  66. package/dist/case/preserve.js +105 -0
  67. package/dist/case/serialize.d.ts +10 -0
  68. package/dist/case/serialize.js +1414 -0
  69. package/dist/check-cli.d.ts +3 -0
  70. package/dist/check-cli.js +118 -0
  71. package/dist/check.d.ts +146 -0
  72. package/dist/check.js +4898 -0
  73. package/dist/cli/commands/bpmn.d.ts +2 -0
  74. package/dist/cli/commands/bpmn.js +73 -0
  75. package/dist/cli/commands/case.d.ts +2 -0
  76. package/dist/cli/commands/case.js +60 -0
  77. package/dist/cli/commands/flow.d.ts +2 -0
  78. package/dist/cli/commands/flow.js +99 -0
  79. package/dist/cli/commands/registry.d.ts +10 -0
  80. package/dist/cli/commands/registry.js +170 -0
  81. package/dist/cli/common.d.ts +30 -0
  82. package/dist/cli/common.js +92 -0
  83. package/dist/cli/index.d.ts +2 -0
  84. package/dist/cli/index.js +18 -0
  85. package/dist/cli-run.d.ts +2 -0
  86. package/dist/cli-run.js +42 -0
  87. package/dist/compile-cli.d.ts +3 -0
  88. package/dist/compile-cli.js +160 -0
  89. package/dist/config.d.ts +47 -0
  90. package/dist/config.js +201 -0
  91. package/dist/core/actions.d.ts +3244 -0
  92. package/dist/core/actions.js +1062 -0
  93. package/dist/core/binding-messages.d.ts +1 -0
  94. package/dist/core/binding-messages.js +16 -0
  95. package/dist/core/bindings.d.ts +12 -0
  96. package/dist/core/bindings.js +67 -0
  97. package/dist/core/ceql.d.ts +73 -0
  98. package/dist/core/ceql.js +272 -0
  99. package/dist/core/cli-spelling.d.ts +39 -0
  100. package/dist/core/cli-spelling.js +62 -0
  101. package/dist/core/connector-raw-node.d.ts +21 -0
  102. package/dist/core/connector-raw-node.js +47 -0
  103. package/dist/core/connectors.d.ts +184 -0
  104. package/dist/core/connectors.js +128 -0
  105. package/dist/core/expr-check.d.ts +93 -0
  106. package/dist/core/expr-check.js +186 -0
  107. package/dist/core/expr.d.ts +323 -0
  108. package/dist/core/expr.js +400 -0
  109. package/dist/core/index.d.ts +10 -0
  110. package/dist/core/index.js +10 -0
  111. package/dist/core/library.d.ts +440 -0
  112. package/dist/core/library.js +1183 -0
  113. package/dist/core/list-envelope.d.ts +45 -0
  114. package/dist/core/list-envelope.js +97 -0
  115. package/dist/core/lookup-store.d.ts +22 -0
  116. package/dist/core/lookup-store.js +85 -0
  117. package/dist/core/lookups.d.ts +227 -0
  118. package/dist/core/lookups.js +231 -0
  119. package/dist/core/node-classes.d.ts +234 -0
  120. package/dist/core/node-classes.js +158 -0
  121. package/dist/core/script-return.d.ts +68 -0
  122. package/dist/core/script-return.js +197 -0
  123. package/dist/core/stable-id.d.ts +28 -0
  124. package/dist/core/stable-id.js +37 -0
  125. package/dist/core-definitions.json +16249 -0
  126. package/dist/decompile-cli.d.ts +3 -0
  127. package/dist/decompile-cli.js +131 -0
  128. package/dist/decompile.d.ts +138 -0
  129. package/dist/decompile.js +2482 -0
  130. package/dist/emit.d.ts +10 -0
  131. package/dist/emit.js +60 -0
  132. package/dist/event-filters.d.ts +130 -0
  133. package/dist/event-filters.js +137 -0
  134. package/dist/flow-expr-check.d.ts +17 -0
  135. package/dist/flow-expr-check.js +193 -0
  136. package/dist/flow-sdk.d.ts +1341 -0
  137. package/dist/flow-sdk.js +1164 -0
  138. package/dist/flow-variables.d.ts +13 -0
  139. package/dist/flow-variables.js +42 -0
  140. package/dist/format-profile.d.ts +72 -0
  141. package/dist/format-profile.js +97 -0
  142. package/dist/generators/_connections.py +287 -0
  143. package/dist/generators/_events.py +355 -0
  144. package/dist/generators/_lookups.py +114 -0
  145. package/dist/generators/_naming.py +185 -0
  146. package/dist/generators/_objects.py +299 -0
  147. package/dist/generators/_resolve.py +273 -0
  148. package/dist/generators/convert_library_to_md.py +1441 -0
  149. package/dist/generators/extract_library.py +125 -0
  150. package/dist/generators/generate_connectors_ts.py +936 -0
  151. package/dist/generators/generate_library_json.py +2527 -0
  152. package/dist/generators/generate_triggers_ts.py +110 -0
  153. package/dist/generators/materialize_registry.py +155 -0
  154. package/dist/generators/prepare_connector.py +1688 -0
  155. package/dist/index.d.ts +35 -0
  156. package/dist/index.js +35 -0
  157. package/dist/ixp-definition.json +1982 -0
  158. package/dist/library.d.ts +6 -0
  159. package/dist/library.js +6 -0
  160. package/dist/load.d.ts +16 -0
  161. package/dist/load.js +95 -0
  162. package/dist/merge-cli.d.ts +3 -0
  163. package/dist/merge-cli.js +47 -0
  164. package/dist/merge.d.ts +125 -0
  165. package/dist/merge.js +0 -0
  166. package/dist/migrate.d.ts +15 -0
  167. package/dist/migrate.js +245 -0
  168. package/dist/node-runtime.d.ts +3 -0
  169. package/dist/node-runtime.js +22 -0
  170. package/dist/package-name.d.ts +17 -0
  171. package/dist/package-name.js +17 -0
  172. package/dist/ref-resolve.d.ts +77 -0
  173. package/dist/ref-resolve.js +170 -0
  174. package/dist/registry/cache.d.ts +55 -0
  175. package/dist/registry/cache.js +134 -0
  176. package/dist/registry/curated-overlay.d.ts +16 -0
  177. package/dist/registry/curated-overlay.js +62 -0
  178. package/dist/registry/extractor.d.ts +22 -0
  179. package/dist/registry/extractor.js +18 -0
  180. package/dist/registry/materialize-bin.d.ts +2 -0
  181. package/dist/registry/materialize-bin.js +7 -0
  182. package/dist/registry/materialize-cli.d.ts +1 -0
  183. package/dist/registry/materialize-cli.js +46 -0
  184. package/dist/registry/materializer.d.ts +23 -0
  185. package/dist/registry/materializer.js +34 -0
  186. package/dist/registry/path-cli.d.ts +1 -0
  187. package/dist/registry/path-cli.js +56 -0
  188. package/dist/registry/prepare-cli.d.ts +62 -0
  189. package/dist/registry/prepare-cli.js +185 -0
  190. package/dist/registry/pull-cli.d.ts +1 -0
  191. package/dist/registry/pull-cli.js +274 -0
  192. package/dist/registry/python.d.ts +26 -0
  193. package/dist/registry/python.js +46 -0
  194. package/dist/registry/search-cli.d.ts +52 -0
  195. package/dist/registry/search-cli.js +159 -0
  196. package/dist/schema-version.d.ts +165 -0
  197. package/dist/schema-version.js +148 -0
  198. package/dist/serialize.d.ts +64 -0
  199. package/dist/serialize.js +6398 -0
  200. package/lib/README.md +112 -0
  201. package/lib/library-json.samples/index.json +158 -0
  202. package/lib/library-json.samples/invariant-collections.json +83 -0
  203. package/lib/library-json.samples/list-envelopes.json +123 -0
  204. package/lib/library-json.samples/uipath-atlassian-jira/create-issue@1.0.0.json +131 -0
  205. package/lib/library-json.samples/uipath-atlassian-jira/create-issue@1.0.0.v1def.json +306 -0
  206. package/lib/library-json.samples/uipath-atlassian-jira/generic/create_issue/create@1.0.0.json +86 -0
  207. package/lib/library-json.samples/uipath-atlassian-jira/generic/create_issue/create@1.0.0.v1def.json +208 -0
  208. package/lib/library-json.samples/uipath-atlassian-jira/get-issue@1.0.0.json +2040 -0
  209. package/lib/library-json.samples/uipath-atlassian-jira/get-issue@1.0.0.v1def.json +195 -0
  210. package/lib/library-json.samples/uipath-google-vertex/execute-google-vertex-agent@1.0.0.json +169 -0
  211. package/lib/library-json.samples/uipath-google-vertex/execute-google-vertex-agent@1.0.0.v1def.json +209 -0
  212. package/lib/library-json.samples/uipath-http-webhook/event-http-webhook@1.0.0.json +63 -0
  213. package/lib/library-json.samples/uipath-http-webhook/event-http-webhook@1.0.0.v1def.json +262 -0
  214. package/lib/library-json.samples/uipath-http-webhook/trigger-http-webhook@1.0.0.json +63 -0
  215. package/lib/library-json.samples/uipath-http-webhook/trigger-http-webhook@1.0.0.v1def.json +213 -0
  216. package/lib/library-json.samples/uipath-microsoft-azureactivedirectory/list-groups@1.0.0.json +227 -0
  217. package/lib/library-json.samples/uipath-microsoft-azureactivedirectory/list-groups@1.0.0.v1def.json +373 -0
  218. package/lib/library-json.samples/uipath-microsoft-onedrive/event-file-created@1.0.0.json +116 -0
  219. package/lib/library-json.samples/uipath-microsoft-onedrive/event-file-created@1.0.0.v1def.json +369 -0
  220. package/lib/library-json.samples/uipath-microsoft-onedrive/event-list-item-added@1.0.0.json +56 -0
  221. package/lib/library-json.samples/uipath-microsoft-onedrive/event-list-item-added@1.0.0.v1def.json +256 -0
  222. package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-file-created@1.0.0.json +116 -0
  223. package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-file-created@1.0.0.v1def.json +320 -0
  224. package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-list-item-added@1.0.0.json +56 -0
  225. package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-list-item-added@1.0.0.v1def.json +207 -0
  226. package/lib/library-json.samples/uipath-microsoft-outlook365/event-email-received@1.0.0.json +107 -0
  227. package/lib/library-json.samples/uipath-microsoft-outlook365/event-email-received@1.0.0.v1def.json +264 -0
  228. package/lib/library-json.samples/uipath-microsoft-outlook365/send-email@1.0.0.json +142 -0
  229. package/lib/library-json.samples/uipath-microsoft-outlook365/send-email@1.0.0.v1def.json +306 -0
  230. package/lib/library-json.samples/uipath-microsoft-outlook365/trigger-email-received@1.0.0.json +107 -0
  231. package/lib/library-json.samples/uipath-microsoft-outlook365/trigger-email-received@1.0.0.v1def.json +217 -0
  232. package/lib/library-json.samples/uipath-microsoft-powerautomate/invoke-a-microsoft-power-automate-flow@1.0.0.json +85 -0
  233. package/lib/library-json.samples/uipath-microsoft-powerautomate/invoke-a-microsoft-power-automate-flow@1.0.0.v1def.json +209 -0
  234. package/lib/library-json.samples/uipath-salesforce-slack/send-message-to-user@1.0.0.json +755 -0
  235. package/lib/library-json.samples/uipath-salesforce-slack/send-message-to-user@1.0.0.v1def.json +513 -0
  236. package/lib/library-json.samples/uipath-uipath-dataservice/query-entity-records@1.0.0.json +122 -0
  237. package/lib/library-json.samples/uipath-uipath-dataservice/query-entity-records@1.0.0.v1def.json +227 -0
  238. package/package.json +85 -0
@@ -0,0 +1,400 @@
1
+ /**
2
+ * core/expr — Flow-style expressions and type descriptors, shared by every
3
+ * builder SDK (flow, case, bpmn).
4
+ *
5
+ * An expression is either a literal value baked into a node, or a dynamic JS
6
+ * expression the runtime evaluates (a reference to a variable or an upstream
7
+ * node's output). A builder never reads live values — you construct references
8
+ * with these helpers, and nothing runs at author time except graph
9
+ * construction.
10
+ */
11
+ /**
12
+ * A Flow expression. Either a literal value (a constant baked into the node)
13
+ * or a dynamic JS expression that the runtime evaluates (e.g. a reference to a
14
+ * variable or an upstream node's output).
15
+ */
16
+ export class Expr {
17
+ js;
18
+ literal;
19
+ value;
20
+ constructor(js, literal = false, value) {
21
+ this.js = js;
22
+ this.literal = literal;
23
+ this.value = value;
24
+ }
25
+ }
26
+ /**
27
+ * A constant value baked directly into a node input.
28
+ *
29
+ * @param value - The constant, JSON-encoded into the emitted expression.
30
+ * @returns An {@link Expr} carrying the literal.
31
+ */
32
+ export function lit(value) {
33
+ return new Expr(JSON.stringify(value), true, value);
34
+ }
35
+ /**
36
+ * Reference a flow-level variable or input by name → `$vars.<name>`.
37
+ *
38
+ * @param name - The variable or input as declared with `.var(...)` / `.input(...)`.
39
+ * @returns An {@link Expr} reading that variable at run time.
40
+ */
41
+ export function v(name) {
42
+ return new Expr(`$vars.${name}`);
43
+ }
44
+ /** The manual trigger node's default id. */
45
+ export const DEFAULT_TRIGGER_ID = 'start';
46
+ /**
47
+ * Reference a flow input by name → `$vars.<triggerId>.output.<name>`.
48
+ *
49
+ * @remarks
50
+ * NOT an alias of {@link v}: an input is published as the TRIGGER NODE's output,
51
+ * so it is read through the trigger's id rather than as a bare global. Renaming the
52
+ * trigger with `.triggerId(...)` rewrites these references with it.
53
+ *
54
+ * @param name - The input as declared with `.input({ … })`.
55
+ * @returns An {@link Expr} reading that input off the trigger node.
56
+ * @see v
57
+ * @example
58
+ * ```ts
59
+ * .input({ amount: types.number })
60
+ * .step('check', script({ code: `return ${input('amount')} > 100;` }))
61
+ * ```
62
+ */
63
+ export function input(name) {
64
+ // A flow input is published as the TRIGGER NODE's output, not as a bare global:
65
+ // v1 keys an `in` global by `<triggerNodeId>.output.<name>`, and the designer
66
+ // types the expression scope as `{ start: { output: { …inputs } } }`. Emitting
67
+ // `$vars.<name>` produced a reference the designer reports as
68
+ // "Property '<name>' does not exist".
69
+ //
70
+ // `start` is the trigger's id. When a flow renames it, `renameRefs` rewrites
71
+ // these references along with every other node-id reference.
72
+ return new Expr(`$vars.${DEFAULT_TRIGGER_ID}.output.${name}`);
73
+ }
74
+ /**
75
+ * Reference an ENTRY POINT's scoped input: `entryInput('nightly', 'batchDate')`
76
+ * reads `$vars.nightly.output.batchDate` — an input declared on
77
+ * `.entryPoint('nightly', …, { inputs: { batchDate: … } })`. `input(name)`
78
+ * remains the spelling for the DEFAULT root's inputs.
79
+ *
80
+ * @param entryPointId - The `.entryPoint()` id that declared the input.
81
+ * @param name - The input's declared name on that entry point.
82
+ * @returns An expression usable anywhere an `Expr` is accepted.
83
+ */
84
+ export function entryInput(entryPointId, name) {
85
+ return new Expr(`$vars.${entryPointId}.output.${name}`);
86
+ }
87
+ /**
88
+ * Reference an upstream step's output → `$vars.<step>.output[.<path>]`.
89
+ * e.g. `out('fetchRate', 'body.rate')`.
90
+ *
91
+ * @remarks
92
+ * Write the reference this way, or dotted by hand — never through a bracket
93
+ * (`$vars.fetchRate["output"]`, `$vars["fetchRate"].output`). Both of those
94
+ * resolve at run time, so the mistake is invisible, but only the DOTTED form is
95
+ * rewritten on the way out: a subflow copy renames node ids, the queue family
96
+ * publishes its result as `<step>.response`, and a failure envelope resolves per
97
+ * node family. A bracketed read opts out of all three and goes stale the moment
98
+ * one applies. `path` may still bracket INTO the value — `out('rows', 'items')`
99
+ * then `["odd key"]` — because nothing rewrites past the runtime variable.
100
+ *
101
+ * @param step - The step whose result to read, named as it was in `.step(...)`.
102
+ * @param path - A dotted path INTO that result. Omit it for the whole output.
103
+ * @returns An {@link Expr} reading that value at run time.
104
+ * @see ran
105
+ * @see err
106
+ * @enforcedBy VARS_BRACKET_READ Reach a step by a dot, not a bracket — the
107
+ * bracketed spelling is the one the compiler cannot rewrite.
108
+ */
109
+ export function out(step, path) {
110
+ return new Expr(`$vars.${step}.output${path ? '.' + path : ''}`);
111
+ }
112
+ /**
113
+ * Did this step run? → `!!$vars.<step>.output`.
114
+ *
115
+ * @remarks
116
+ * For the shape a `switch` creates: a value is computed in exactly ONE arm, and
117
+ * the step after the join has to read *whichever arm ran*.
118
+ *
119
+ * ```ts
120
+ * .switch('route', [
121
+ * { when: js`${input('direction')} === 'f2i'`, body: (b) => b.step('toInches', script(…)) },
122
+ * { when: js`${input('direction')} === 'i2f'`, body: (b) => b.step('toFeet', script(…)) },
123
+ * ])
124
+ * .return({ result: js`${ran('toInches')} ? ${out('toInches', 'result')} : ${out('toFeet', 'result')}` })
125
+ * ```
126
+ *
127
+ * ### What it means, and what it does NOT
128
+ *
129
+ * It tests **what the step published**, because that is the only thing the
130
+ * platform will answer. The runtime's variable bag is flat and keyed by dotted
131
+ * names: it holds `"toInches.output"`, pre-declared `null` before the step runs
132
+ * and left `null` if the step never runs. So `!!$vars.toInches.output` is false
133
+ * until the arm runs and true after.
134
+ *
135
+ * Two consequences worth knowing before you rely on it:
136
+ *
137
+ * - **A step that RAN but published nothing reads as not-ran.** Ran-ness is
138
+ * output-presence, not execution. A `mock()` placeholder publishes nothing by
139
+ * design, so `ran()` of one is always false — locally and deployed alike.
140
+ * - **Do not test the step itself.** `$vars.toInches ? … : …` is the spelling
141
+ * deployed flows reach for, and it is DEAD: there is no bare `toInches` key in
142
+ * the bag, so it is `undefined` whether or not the step ran, and every guard
143
+ * built on it silently takes the wrong branch. Measured on the product
144
+ * runtime — a flow whose taken arm computed `23` returned `null`, reported
145
+ * `Completed`, and was scored 1.0 by v1's graders
146
+ * (`runs/flow-sdk-g21-2026-08-02/probe-truthiness/RECORD.md`). A green run is
147
+ * not evidence the expression worked.
148
+ *
149
+ * A switch's own `matchedCase` / `matchedCaseId` cannot help either: the format
150
+ * declares them and the server runtime never populates them (measured, same
151
+ * probe family), which is why ran-ness is computed from the output instead.
152
+ *
153
+ * @param step - The step to test, named as it was in `.step(...)`.
154
+ * @returns An {@link Expr} that is true only if the step produced output.
155
+ * @enforcedBy STEP_READ_WITHOUT_OUTPUT Test ran-ness with `ran()`, never a bare
156
+ * `$vars.<step>` — the runtime has no such key, so the guard is always false.
157
+ */
158
+ export function ran(step) {
159
+ return new Expr(`!!$vars.${step}.output`);
160
+ }
161
+ /**
162
+ * Reference a FAILED step's error → `$vars.<step>.error[.<field>]`.
163
+ *
164
+ * @remarks
165
+ * Only meaningful inside that step's `.onError(...)` handler — the platform
166
+ * writes the failure when the node's error boundary fires, and nowhere else.
167
+ * The envelope carries the same fields on every family that publishes one:
168
+ *
169
+ * | field | type | example |
170
+ * |---|---|---|
171
+ * | `code` | string | `'404'` — a STRING even for an HTTP status |
172
+ * | `message` | string | `'Integration Services resource not found'` |
173
+ * | `detail` | string | the whole upstream response |
174
+ * | `category` | string | `'User'` |
175
+ * | `status` | number | `404` |
176
+ * | `response` | unknown | undeclared; `null` in every probe |
177
+ * | `element` | string | undeclared; the id of the step that failed |
178
+ *
179
+ * The last two resolve at run time — measured, a container handler reading
180
+ * `element` came back with the failing body step's id — but they are absent from
181
+ * the declared schema, so `uip maestro flow validate` reports
182
+ * `EXPRESSION_DIAGNOSTIC: Property 'element' does not exist on type
183
+ * '<Step>_Error'` for them. Valid, and noisy: prefer the declared five unless you
184
+ * specifically need one of these.
185
+ *
186
+ * **Which VARIABLE holds it is per node family, and this helper owns that.**
187
+ * Measured on the product (2026-09-10), one debug run per family:
188
+ *
189
+ * | family | envelope in | `<step>.error` is |
190
+ * |---|---|---|
191
+ * | connector (all 3806 of them) | `<step>.error` | the envelope |
192
+ * | `core.action.script` | `<step>.error` | the envelope |
193
+ * | `uipath.pattern.deep-rag` | `<step>.error` | the envelope |
194
+ * | `core.subflow` | `<step>.error` | the envelope |
195
+ * | `core.action.queue.create` | `<step>.error` | the envelope |
196
+ * | `core.action.http.v2` (managed) | `<step>.output` | the boolean `true` |
197
+ * | `core.action.http` (plain, any version) | nowhere — no envelope at all | the boolean `true` |
198
+ *
199
+ * So the author writes one shape, `.error.<field>`, and `serialize` rewrites it
200
+ * to `.output.<field>` for the one family that publishes it there
201
+ * (`errorEnvelopeVar` in `serialize.ts`). Do not hand-write either prefix: which
202
+ * one is right is not a property of the expression, it is a property of the node
203
+ * the step happens to be, and only the builder knows that.
204
+ *
205
+ * The history matters, because this has now been wrong in both directions. It
206
+ * read `.error.<field>` originally; a managed-http debug run showed `.error` was
207
+ * the boolean `true` there and the envelope sat in `.output`, so it was changed
208
+ * to `.output.<field>` for every family — which silently broke the other six,
209
+ * where `.output` is `null` after a failure. Both measurements were right about
210
+ * the family they measured. The fix is not a constant either way.
211
+ *
212
+ * Plain `http({ managed: false })` publishes NO envelope in any version — 1.0.0
213
+ * and the 1.3 that `uip maestro flow migrate` upgrades it to both set
214
+ * `<step>.error = true` and leave `<step>.output` null — so there is nothing for
215
+ * this helper to read. `check` refuses a handler there (HTTP_ONERROR_V1) rather
216
+ * than emitting a read that resolves to nothing.
217
+ *
218
+ * `out('<step>','error')` is still wrong and `check` still refuses it
219
+ * (ERROR_READ_VIA_OUT): the success-path output has no `error` field of its own.
220
+ * Use the boolean `$vars.<step>.error` — `err('<step>')` with no field — to ask
221
+ * *whether* it failed; that reads truthy on every family, the envelope object
222
+ * included.
223
+ *
224
+ * @example
225
+ * **Read the failure inside the step's error handler**
226
+ * ```ts
227
+ * .step('load', script({ code: 'return JSON.parse($vars.start.output.raw);' }))
228
+ * .onError((h) => h.return({ note: tmpl`bad payload: ${err('load', 'message')}` }))
229
+ * ```
230
+ *
231
+ * @example
232
+ * **The same read, without naming the step** — inside a handler the failed step
233
+ * is known, so the handler's own `err` needs only the field, and a step rename
234
+ * cannot leave the read pointing at the wrong node.
235
+ * ```ts
236
+ * .onError((h) => h.return({ note: tmpl`bad payload: ${h.err('message')}` }))
237
+ * ```
238
+ *
239
+ * @param step - The step that FAILED, named as it was in `.step(...)`.
240
+ * @param field - One of the envelope's fields. Omit it to test WHETHER the step
241
+ * failed.
242
+ * @returns An {@link Expr} reading the failure inside an `.onError(...)` handler.
243
+ * @enforcedBy ERROR_READ_VIA_OUT Read an error with `err()`, never
244
+ * `out('<step>', 'error')` — the success output has no `error` field of its own.
245
+ * @enforcedBy ERROR_ENVELOPE_VIA_OUTPUT Inside a handler, the failed step's
246
+ * `.output` is empty; an envelope field read from it resolves to nothing.
247
+ */
248
+ export function err(step, field) {
249
+ // ONE shape for every family. `serialize` rewrites the prefix for the families
250
+ // that publish the envelope elsewhere — see `errorEnvelopeVar`.
251
+ return new Expr(`$vars.${step}.error${field ? '.' + field : ''}`);
252
+ }
253
+ /**
254
+ * Build a raw JS *expression* (a condition or computation).
255
+ * Interpolated `Expr`s contribute their reference; other values are JSON-encoded.
256
+ * e.g. js`${input('from')} !== ${input('to')}` → `$vars.from !== $vars.to`
257
+ *
258
+ * @param strings - The template's literal parts, supplied by the tag call.
259
+ * @param vals - Interpolated values. An {@link Expr} contributes its reference;
260
+ * anything else is JSON-encoded.
261
+ * @returns An {@link Expr} carrying the composed JavaScript expression.
262
+ * @see tmpl
263
+ */
264
+ export function js(strings, ...vals) {
265
+ let out = '';
266
+ strings.forEach((s, i) => {
267
+ out += s;
268
+ if (i < vals.length)
269
+ out += exprText(vals[i]);
270
+ });
271
+ return new Expr(out.trim());
272
+ }
273
+ /**
274
+ * Build a JS *string template* (for URLs, messages, etc.).
275
+ * e.g. tmpl`https://api.rates.io/${input('from')}` →
276
+ * a JS template literal referencing `$vars.from`.
277
+ *
278
+ * @param strings - The template's literal parts, supplied by the tag call.
279
+ * @param vals - Interpolated values, each rendered into the string at run time.
280
+ * @returns An {@link Expr} carrying a JavaScript template literal.
281
+ * @see js
282
+ */
283
+ export function tmpl(strings, ...vals) {
284
+ let body = '';
285
+ strings.forEach((s, i) => {
286
+ body += s.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${');
287
+ if (i < vals.length)
288
+ body += '${' + exprText(vals[i]) + '}';
289
+ });
290
+ return new Expr('`' + body + '`');
291
+ }
292
+ function exprText(val) {
293
+ return val instanceof Expr ? val.js : JSON.stringify(val);
294
+ }
295
+ /**
296
+ * Coerce a raw value or Expr into an Expr.
297
+ *
298
+ * @internal Public for compatibility; not an authoring factory.
299
+ */
300
+ export function toExpr(val) {
301
+ return val instanceof Expr ? val : lit(val);
302
+ }
303
+ // ─── FLAT NAMES — what the platform calls a reference ───────────────────────
304
+ //
305
+ // An inline agent's arguments are named by the platform, not by us: flow-v1's
306
+ // `preDeriveAgentInputDefinitions` scans the agent NODE's prompts for `$vars.*` /
307
+ // `$metadata.*` references and names each derived argument with the reference's
308
+ // FLAT NAME — the path with its dots replaced by `__`. So an `agent.json` that
309
+ // templates `{{input.<something-else>}}` templates against a key that does not
310
+ // exist, and the placeholder reaches the model as literal text (board G-20).
311
+ //
312
+ // The encoding lives here, next to the helpers that BUILD those references, so
313
+ // `check` and `serialize` cannot drift apart about what a reference is called.
314
+ /**
315
+ * flow-v1 flow-schema `utils.ts:70` — the flat-name segment separator.
316
+ *
317
+ * @internal Encoding detail shared by `check` and `serialize`, not an authoring value.
318
+ */
319
+ export const FLAT_SEP = '__';
320
+ /**
321
+ * A JS expression that is EXACTLY one `$vars.*` / `$metadata.*` reference and
322
+ * nothing else — the only shape with a single platform argument to name.
323
+ *
324
+ * The path grammar is flow-v1's `VARIABLE_PATH_PATTERN` verbatim
325
+ * (`services/src/variables/constants.ts:38-44`): an identifier, then any number
326
+ * of `.identifier` / `[0]` selectors. Note what that admits — `.length` is an
327
+ * identifier segment, so both `out('a', 'items[0].id')` and a `….lines.length`
328
+ * read are single references rather than computed expressions.
329
+ */
330
+ const SINGLE_SOURCE_REF = /^\$(vars|metadata)\.([a-zA-Z_]\w*(?:\[\d+\]|\.[a-zA-Z_]\w*)*)$/;
331
+ /** Segment splitter — flow-v1 `encodeFlatName` (`agent-cluster-rewrite.ts:114-117`). */
332
+ const PATH_SEGMENT = /[a-zA-Z_]\w*|\[(\d+)\]/g;
333
+ /**
334
+ * The name the PLATFORM will call this reference by, or `undefined` when the
335
+ * expression is not a single reference (a literal, or a computed expression
336
+ * spanning zero or several references — neither has one argument to name).
337
+ *
338
+ * flow-v1's `encodeFlatName` (`agent-cluster-rewrite.ts:113-121`): split into
339
+ * identifier segments plus bare index numbers and join with `__`; the `$vars.`
340
+ * prefix is dropped, `$metadata` keeps `metadata` as its first segment.
341
+ *
342
+ * ```
343
+ * flatNameOf('$vars.notes') // 'notes'
344
+ * flatNameOf('$vars.normalizeData.output.invoiceNumber') // 'normalizeData__output__invoiceNumber'
345
+ * flatNameOf('$vars.a.output.items[0].id') // 'a__output__items__0__id'
346
+ * flatNameOf('$metadata.jobId') // 'metadata__jobId'
347
+ * flatNameOf('$vars.a.output.x + $vars.b') // undefined — composite
348
+ * ```
349
+ *
350
+ * Accepts the expression with or without the `=js:` prefix a rendered binding
351
+ * carries, so both the authored `Expr.js` and an emitted binding can be asked.
352
+ *
353
+ * @internal Public for compatibility; not an authoring factory.
354
+ */
355
+ export function flatNameOf(expression) {
356
+ return flatNameSegmentsOf(expression)?.join(FLAT_SEP);
357
+ }
358
+ /**
359
+ * {@link flatNameOf}'s segments, before they are joined.
360
+ *
361
+ * Exposed because the JOIN is lossy: `__` is both the separator and a legal
362
+ * character inside an identifier, so a step named `erp__lookup` produces
363
+ * `erp__lookup__output__value`, which decodes back to the wrong path
364
+ * (`erp.lookup.output.value`). v1's own inverse says as much — `decodeFlatName`
365
+ * round-trips "provided variable and node IDs disallow `__`". `check` reads the
366
+ * segments to warn about exactly that.
367
+ *
368
+ * @internal Public for compatibility; not an authoring factory.
369
+ */
370
+ export function flatNameSegmentsOf(expression) {
371
+ const bare = (expression.startsWith('=js:') ? expression.slice(4) : expression).trim();
372
+ const m = SINGLE_SOURCE_REF.exec(bare);
373
+ if (!m)
374
+ return undefined;
375
+ const segments = Array.from(m[2].matchAll(PATH_SEGMENT), (s) => s[1] ?? s[0]);
376
+ return m[1] === 'vars' ? segments : ['metadata', ...segments];
377
+ }
378
+ // ─── Types ──────────────────────────────────────────────────────────────────
379
+ /** Variable type descriptors (map to Flow variable `type` values). */
380
+ export const types = {
381
+ string: 'string',
382
+ number: 'number',
383
+ boolean: 'boolean',
384
+ object: 'object',
385
+ array: 'array',
386
+ file: 'file',
387
+ any: 'any',
388
+ // Case-management type vocabulary (M87): the platform distinguishes numeric
389
+ // widths and date kinds. These map straight to the caseplan variable `type`
390
+ // and drive the entry-points.json type→format projection.
391
+ integer: 'integer',
392
+ float: 'float',
393
+ double: 'double',
394
+ date: 'date',
395
+ datetime: 'datetime',
396
+ // Structured (object/array) case variables persist as `type: 'jsonSchema'` with
397
+ // the shape carried in a JSON-schema `body` (object vs array lives in body.type).
398
+ // Case-only — declare via the `jsonSchema(body)` helper.
399
+ jsonSchema: 'jsonSchema',
400
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * core — the domain-agnostic layer shared by every builder SDK (flow, case,
3
+ * bpmn): expressions, action specs, connector-library resolution, and symbolic
4
+ * binding resolution. Domain builders (flow/, case/, bpmn/) compose these.
5
+ */
6
+ export * from './expr.js';
7
+ export * from './actions.js';
8
+ export * from './connectors.js';
9
+ export * from './library.js';
10
+ export * from './bindings.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * core — the domain-agnostic layer shared by every builder SDK (flow, case,
3
+ * bpmn): expressions, action specs, connector-library resolution, and symbolic
4
+ * binding resolution. Domain builders (flow/, case/, bpmn/) compose these.
5
+ */
6
+ export * from './expr.js';
7
+ export * from './actions.js';
8
+ export * from './connectors.js';
9
+ export * from './library.js';
10
+ export * from './bindings.js';