@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,45 @@
1
+ /** One measured operation. `envelope: null` is the BARE array. */
2
+ export interface ListEnvelopeRow {
3
+ nodeType: string;
4
+ /** When present, the row applies only to that object of a GENERIC operation. */
5
+ objectName?: string;
6
+ /** `null` = the array itself; a string = the single field that holds it. */
7
+ envelope: string | null;
8
+ /** A1 debug-record read · A2 product-runtime record · A3 executing archived run. */
9
+ tier: string;
10
+ source: string;
11
+ measuredAt?: string;
12
+ /**
13
+ * What `uip is resources run` hands back, when it differs from the runtime
14
+ * shape. Recorded on eight rows; no current reader consumes it — it exists for
15
+ * a dispatcher that needs to normalise between the CLI and the platform.
16
+ */
17
+ cliShape?: string;
18
+ }
19
+ /**
20
+ * Every declared row, from `<libraryDir>/list-envelopes.json`. An absent file is
21
+ * an empty ledger — every operation undeclared — which is what a library built
22
+ * before this card, or a bare fixture library, looks like.
23
+ */
24
+ export declare function loadListEnvelopes(libraryDir: string | undefined): ListEnvelopeRow[];
25
+ /**
26
+ * The row for one operation, or `undefined` when it is undeclared.
27
+ *
28
+ * A row naming an `objectName` applies to that object ALONE — the evidence was a
29
+ * reading of that object, and a generic operation covers up to 197 of them. A row
30
+ * without one applies to every object of the node type. Exact match wins.
31
+ */
32
+ export declare function lookupListEnvelope(rows: ListEnvelopeRow[], nodeType: string, objectName?: string): ListEnvelopeRow | undefined;
33
+ /**
34
+ * Convenience for the readers that hold a library dir rather than the rows.
35
+ * `{ declared: false }` and `{ declared: true, envelope: null }` are DIFFERENT
36
+ * answers and every caller must keep them apart: the first means "behave as
37
+ * before", the second means "this operation is measured, and it is bare".
38
+ */
39
+ export declare function envelopeOf(libraryDir: string | undefined, nodeType: string, objectName?: string): {
40
+ declared: false;
41
+ } | {
42
+ declared: true;
43
+ envelope: string | null;
44
+ row: ListEnvelopeRow;
45
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * list-envelope — read the LIST-ENVELOPE LEDGER that sits beside the connector
3
+ * library's `index.json`.
4
+ *
5
+ * ## What the ledger answers
6
+ *
7
+ * A connector LIST operation's node output is either the array itself (**bare**,
8
+ * `envelope: null`) or that array inside a one-field wrapper object
9
+ * (`envelope: "records"` ⇒ `{records: […]}`). **Nothing in the library declares
10
+ * which**: `outputSchema.fields` describes ONE record either way, and the two
11
+ * operations that declare no fields at all sit on opposite sides of what the
12
+ * corpus guessed ([#156](https://github.com/UiPath/flow-builder-sdk/issues/156)).
13
+ * It cannot be derived, so it is measured and written down — one row per
14
+ * operation, each carrying the evidence that put it there.
15
+ *
16
+ * ## The rule this file exists to enforce
17
+ *
18
+ * **An operation with no row is UNDECLARED, and undeclared means every reader
19
+ * behaves exactly as it did before the ledger existed.** The emitter declares no
20
+ * container, and a reader must go on treating an unknown name on a list output as
21
+ * a possible wrapper. 2,149 of the shipped library's 7,029 entries are List
22
+ * operations and the ledger holds eight — that ratio is the design, not a gap.
23
+ * It grows on demand, one measurement at a time.
24
+ *
25
+ * Measured 2026-08-02 (card G13, eight `flow debug` / product-runtime readings):
26
+ * every operation measured so far is **bare**, including both the corpus called
27
+ * wrappers. The ledger's own `$comment` carries the mechanism and the evidence
28
+ * tiers; this module only reads it.
29
+ *
30
+ * If a second reader is ever needed outside this package, copy this one rather
31
+ * than sharing it through a new package boundary: a 40-line JSON reader is the
32
+ * cheaper half. The LEDGER is the single source of truth — the readers are
33
+ * interchangeable.
34
+ */
35
+ import { readFileSync, existsSync } from 'node:fs';
36
+ import { join } from 'node:path';
37
+ const CACHE = new Map();
38
+ /**
39
+ * Every declared row, from `<libraryDir>/list-envelopes.json`. An absent file is
40
+ * an empty ledger — every operation undeclared — which is what a library built
41
+ * before this card, or a bare fixture library, looks like.
42
+ */
43
+ export function loadListEnvelopes(libraryDir) {
44
+ if (!libraryDir)
45
+ return [];
46
+ const cached = CACHE.get(libraryDir);
47
+ if (cached)
48
+ return cached;
49
+ let rows = [];
50
+ const file = join(libraryDir, 'list-envelopes.json');
51
+ if (existsSync(file)) {
52
+ try {
53
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
54
+ if (Array.isArray(parsed.operations))
55
+ rows = parsed.operations;
56
+ }
57
+ catch {
58
+ // A malformed ledger reads as an EMPTY one rather than throwing: the
59
+ // permissive path is the pre-ledger behaviour, so the worst case of a bad
60
+ // edit is losing the exactness, never breaking a compile.
61
+ rows = [];
62
+ }
63
+ }
64
+ CACHE.set(libraryDir, rows);
65
+ return rows;
66
+ }
67
+ /**
68
+ * The row for one operation, or `undefined` when it is undeclared.
69
+ *
70
+ * A row naming an `objectName` applies to that object ALONE — the evidence was a
71
+ * reading of that object, and a generic operation covers up to 197 of them. A row
72
+ * without one applies to every object of the node type. Exact match wins.
73
+ */
74
+ export function lookupListEnvelope(rows, nodeType, objectName) {
75
+ let loose;
76
+ for (const r of rows) {
77
+ if (r.nodeType !== nodeType)
78
+ continue;
79
+ if (r.objectName === undefined) {
80
+ loose ??= r;
81
+ continue;
82
+ }
83
+ if (objectName !== undefined && r.objectName === objectName)
84
+ return r;
85
+ }
86
+ return loose;
87
+ }
88
+ /**
89
+ * Convenience for the readers that hold a library dir rather than the rows.
90
+ * `{ declared: false }` and `{ declared: true, envelope: null }` are DIFFERENT
91
+ * answers and every caller must keep them apart: the first means "behave as
92
+ * before", the second means "this operation is measured, and it is bare".
93
+ */
94
+ export function envelopeOf(libraryDir, nodeType, objectName) {
95
+ const row = lookupListEnvelope(loadListEnvelopes(libraryDir), nodeType, objectName);
96
+ return row ? { declared: true, envelope: row.envelope ?? null, row } : { declared: false };
97
+ }
@@ -0,0 +1,22 @@
1
+ import type { LookupResolutions } from './lookups.js';
2
+ /**
3
+ * Load `<overlayDir>/resolutions.json`, or an empty map.
4
+ *
5
+ * An absent or malformed file reads as EMPTY rather than throwing, matching
6
+ * `loadListEnvelopes`. The consequence of an empty map is not a wrong artifact
7
+ * — it is a compile error naming the `prepare` command to run, which is the
8
+ * behaviour an author wants from a missing resolution anyway.
9
+ */
10
+ export declare function loadLookupResolutions(overlayDir: string | undefined): LookupResolutions;
11
+ /**
12
+ * The invariant-collection ledger's `objectName` set, from a library dir.
13
+ *
14
+ * Absent or malformed reads as EMPTY, which is the permissive direction: an
15
+ * unlisted collection is treated as a real lookup, which is never wrong — only
16
+ * occasionally ceremonial. The opposite default would drop the helper from a
17
+ * genuinely connection-scoped field.
18
+ *
19
+ * @param libraryDir - A `library-json` directory, or the local overlay.
20
+ * @returns Every `objectName` declared connector-invariant.
21
+ */
22
+ export declare function loadInvariantCollections(libraryDir: string | undefined): Set<string>;
@@ -0,0 +1,85 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ /**
4
+ * core/lookup-store — the two on-disk side-tables the lookup surface reads.
5
+ *
6
+ * SEPARATE FROM `core/lookups.ts` ON PURPOSE. That module is re-exported from
7
+ * `flow-sdk.ts`, which is the authoring entry point: a `.flow.ts` imports it,
8
+ * and so does anything type-checking one. The moment it imported `node:fs`,
9
+ * every consumer needed `@types/node` on hand to compile a flow — which broke a
10
+ * generated-trigger gate that had deliberately been checking the authoring
11
+ * surface with a bare tsconfig.
12
+ *
13
+ * Authoring needs the TYPES and the `lookup()` factory; only the compilers and
14
+ * the CLIs need to read files. Keeping the split makes that structural rather
15
+ * than a thing to remember.
16
+ */
17
+ const RESOLUTION_CACHE = new Map();
18
+ /**
19
+ * Load `<overlayDir>/resolutions.json`, or an empty map.
20
+ *
21
+ * An absent or malformed file reads as EMPTY rather than throwing, matching
22
+ * `loadListEnvelopes`. The consequence of an empty map is not a wrong artifact
23
+ * — it is a compile error naming the `prepare` command to run, which is the
24
+ * behaviour an author wants from a missing resolution anyway.
25
+ */
26
+ export function loadLookupResolutions(overlayDir) {
27
+ if (!overlayDir)
28
+ return {};
29
+ const cached = RESOLUTION_CACHE.get(overlayDir);
30
+ if (cached)
31
+ return cached;
32
+ let rows = {};
33
+ const file = join(overlayDir, 'resolutions.json');
34
+ if (existsSync(file)) {
35
+ try {
36
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
37
+ if (parsed.resolutions && typeof parsed.resolutions === 'object') {
38
+ rows = parsed.resolutions;
39
+ }
40
+ }
41
+ catch {
42
+ rows = {};
43
+ }
44
+ }
45
+ RESOLUTION_CACHE.set(overlayDir, rows);
46
+ return rows;
47
+ }
48
+ /**
49
+ * The invariant-collection ledger's `objectName` set, from a library dir.
50
+ *
51
+ * Absent or malformed reads as EMPTY, which is the permissive direction: an
52
+ * unlisted collection is treated as a real lookup, which is never wrong — only
53
+ * occasionally ceremonial. The opposite default would drop the helper from a
54
+ * genuinely connection-scoped field.
55
+ *
56
+ * @param libraryDir - A `library-json` directory, or the local overlay.
57
+ * @returns Every `objectName` declared connector-invariant.
58
+ */
59
+ export function loadInvariantCollections(libraryDir) {
60
+ if (!libraryDir)
61
+ return new Set();
62
+ const cached = INVARIANT_CACHE.get(libraryDir);
63
+ if (cached)
64
+ return cached;
65
+ const out = new Set();
66
+ const file = join(libraryDir, 'invariant-collections.json');
67
+ if (existsSync(file)) {
68
+ try {
69
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
70
+ if (Array.isArray(parsed.collections)) {
71
+ for (const row of parsed.collections) {
72
+ const name = row?.objectName;
73
+ if (typeof name === 'string')
74
+ out.add(name);
75
+ }
76
+ }
77
+ }
78
+ catch {
79
+ /* an empty ledger — see above */
80
+ }
81
+ }
82
+ INVARIANT_CACHE.set(libraryDir, out);
83
+ return out;
84
+ }
85
+ const INVARIANT_CACHE = new Map();
@@ -0,0 +1,227 @@
1
+ /** How `prepare` should retrieve the collection, chosen from the metadata. */
2
+ export type LookupStrategy =
3
+ /** `filterPattern` present — substitute `{filter}` and issue one request. */
4
+ 'filter'
5
+ /** No server-side filter — page the collection and match client-side. */
6
+ | 'scan'
7
+ /** `childPath` present — the collection is a tree to walk. */
8
+ | 'tree'
9
+ /** `dependsOn` present — another field must resolve first. */
10
+ | 'dependent';
11
+ /**
12
+ * One lookup field's retrieval contract, generated from `reference`.
13
+ *
14
+ * This is DATA on the descriptor, not a type surface. The generator's existing
15
+ * scale guards (`TS_MAX_TYPE_DEPTH`, `TS_MAX_FIELD_COUNT_PER_ENTRY`) exist
16
+ * because NetSuite already pushes `tsc`, and a thousand more *type* surfaces
17
+ * would make that worse for no gain. The one place types are derived from it —
18
+ * {@link LookupBuilder}'s alias methods — is a mapped type over an object
19
+ * literal that is only instantiated at a call site, so it costs nothing on the
20
+ * modules nobody imports.
21
+ */
22
+ export interface LookupSpec {
23
+ /** The collection holding the records, e.g. `curated_users`. */
24
+ objectName?: string;
25
+ /** The path to call, filter included, e.g. `/curated_users?fields=id`. */
26
+ path: string;
27
+ /** Every field the collection can be searched by. */
28
+ by: readonly string[];
29
+ /** The field whose value is sent to the connector, e.g. `id`. */
30
+ value: string;
31
+ /** `{ byEmail: 'profile.email' }` — only for names with an unambiguous alias. */
32
+ aliases: Readonly<Record<string, string>>;
33
+ strategy: LookupStrategy;
34
+ /** For `strategy: 'dependent'`, the fields that must resolve first. */
35
+ dependsOn?: readonly string[];
36
+ }
37
+ /**
38
+ * An unresolved lookup: what `.byEmail(…)` returns.
39
+ *
40
+ * Deliberately a plain branded object rather than an `Expr`. An `Expr` renders
41
+ * to a runtime expression string and would silently reach the wire; this must
42
+ * not render at all until something has resolved it, so it carries no `render`
43
+ * and `renderDeep` refuses it.
44
+ */
45
+ export interface LookupToken {
46
+ readonly __lookup: {
47
+ readonly nodeType: string;
48
+ readonly field: string;
49
+ readonly by: string;
50
+ readonly value: unknown;
51
+ };
52
+ }
53
+ /** True when `v` is an unresolved {@link LookupToken}. */
54
+ export declare function isLookupToken(v: unknown): v is LookupToken;
55
+ /**
56
+ * The identity of one resolution, as `prepare` records it and `compile` reads it.
57
+ *
58
+ * JSON-encoded rather than delimiter-joined because every component is
59
+ * author-supplied text: a real name containing the delimiter would collide two
60
+ * distinct resolutions onto one key, and the symptom would be a flow compiled
61
+ * with the wrong person's id.
62
+ */
63
+ export declare function lookupKey(nodeType: string, field: string, by: string, value: unknown): string;
64
+ /** What `lookup(...)` returns: the generic form plus any generated aliases. */
65
+ export type LookupBuilder<S extends LookupSpec | undefined = undefined> = S extends LookupSpec ? {
66
+ by(name: S['by'][number], value: unknown): LookupToken;
67
+ } & {
68
+ [K in keyof S['aliases']]: (value: unknown) => LookupToken;
69
+ } : {
70
+ by(name: string, value: unknown): LookupToken;
71
+ };
72
+ /**
73
+ * The descriptor shape `lookup()` needs — a nodeType plus its lookup table.
74
+ *
75
+ * @internal Structural constraint for the overload; not an authoring surface.
76
+ */
77
+ interface LookupBearing {
78
+ nodeType: string;
79
+ lookups?: Readonly<Record<string, LookupSpec>>;
80
+ }
81
+ /**
82
+ * A trigger descriptor that DOES carry a lookup table.
83
+ *
84
+ * `lookups` is required here so a descriptor without one still falls through to
85
+ * the loose event overload rather than being typed against an empty table.
86
+ *
87
+ * @internal Structural constraint for the overload; not an authoring surface.
88
+ */
89
+ interface EventLookupBearing {
90
+ connector: string;
91
+ event: string;
92
+ nodeType?: undefined;
93
+ lookups: Readonly<Record<string, LookupSpec>>;
94
+ }
95
+ /**
96
+ * Begin resolving a lookup field on a generated descriptor.
97
+ *
98
+ * @param descriptor - A generated operation carrying a `lookups` table.
99
+ * @param field - The lookup field, e.g. `'channel'`.
100
+ * @returns A builder exposing `.by(name, value)` and one method per generated alias.
101
+ */
102
+ export declare function lookup<D extends LookupBearing, F extends keyof NonNullable<D['lookups']> & string>(descriptor: D, field: F): LookupBuilder<NonNullable<D['lookups']>[F] extends LookupSpec ? NonNullable<D['lookups']>[F] : never>;
103
+ /**
104
+ * Begin resolving a lookup field addressed by connector key and action.
105
+ *
106
+ * @remarks
107
+ * The string form exists because Generic CRUD operations are authored from the
108
+ * library by object rather than through a descriptor — and the generic half of
109
+ * the library carries 710 of the 1,365 lookup fields, so a descriptor-only
110
+ * helper would miss the majority of its own surface.
111
+ *
112
+ * It gives up exactly what `connector(key, action, …)` already gives up beside
113
+ * `connector(descriptor, …)`: the field name is unchecked until `check` runs,
114
+ * and there are no typed aliases, so only the generic `.by(name, value)` is
115
+ * available. A consistent trade rather than a new one.
116
+ *
117
+ * @param key - The connector library key, e.g. `'uipath-salesforce-slack'`.
118
+ * @param action - The operation id, e.g. `'send-message-to-user'`.
119
+ * @param field - The lookup field, e.g. `'channel'`.
120
+ * @returns A builder exposing `.by(name, value)`.
121
+ */
122
+ export declare function lookup(key: string, action: string, field: string): LookupBuilder;
123
+ /**
124
+ * Begin resolving a `where` parameter on a trigger descriptor that carries a
125
+ * lookup table.
126
+ *
127
+ * @remarks
128
+ * An event parameter holding an id is resolved exactly as a connector input is,
129
+ * against the same `reference` block, so a generated trigger descriptor carries
130
+ * the same `lookups` table and earns the same aliases —
131
+ * `lookup(EmailReceived, 'parentFolderId').byDisplayName('Inbox')`.
132
+ *
133
+ * @param descriptor - A trigger descriptor carrying a `lookups` table.
134
+ * @param field - The event parameter, e.g. `'parentFolderId'`.
135
+ * @returns A builder exposing `.by(name, value)` and one method per generated alias.
136
+ */
137
+ export declare function lookup<D extends EventLookupBearing, F extends keyof D['lookups'] & string>(descriptor: D, field: F): LookupBuilder<D['lookups'][F] extends LookupSpec ? D['lookups'][F] : never>;
138
+ /**
139
+ * Begin resolving a `where` parameter on a connector-EVENT descriptor.
140
+ *
141
+ * @remarks
142
+ * A trigger descriptor carries `connector` + `event`, never a `nodeType`. The
143
+ * token is keyed under the EVENT-form node type
144
+ * (`uipath.connector.event.<connector>.<event>`), which is the form `prepare`
145
+ * records resolutions under and the form both node roles resolve to. A
146
+ * descriptor that ships no `lookups` table — an event nothing has described, or
147
+ * one whose parameters hold no ids — offers only the generic
148
+ * `.by(name, value)`, same trade as the string form: the `by` is checked by
149
+ * `prepare`, not here.
150
+ *
151
+ * @param descriptor - A trigger descriptor (or `{ connector, event }` literal).
152
+ * @param field - The event parameter, e.g. `'parentFolderId'`.
153
+ * @returns A builder exposing `.by(name, value)`.
154
+ */
155
+ export declare function lookup(descriptor: {
156
+ connector: string;
157
+ event: string;
158
+ nodeType?: undefined;
159
+ }, field: string): LookupBuilder;
160
+ /** One recorded resolution, as `connectors-local/resolutions.json` stores it. */
161
+ export interface LookupResolution {
162
+ nodeType: string;
163
+ field: string;
164
+ by: string;
165
+ /** The human-meaningful value the author wrote. */
166
+ match: string;
167
+ /** The opaque id the connector wants. */
168
+ value: string;
169
+ }
170
+ /** Every recorded resolution, keyed by {@link lookupKey}. */
171
+ export type LookupResolutions = Readonly<Record<string, LookupResolution>>;
172
+ /**
173
+ * The recorded id for a token, or `undefined`.
174
+ *
175
+ * @param token - The unresolved lookup.
176
+ * @param resolutions - Everything `prepare --resolve` has recorded.
177
+ * @returns The connector-facing id, when this exact `(nodeType, field, by, value)` was resolved.
178
+ */
179
+ export declare function resolvedValue(token: LookupToken, resolutions: LookupResolutions): string | undefined;
180
+ /**
181
+ * The message for a lookup nothing has resolved — the command that fixes it.
182
+ *
183
+ * A missing resolution is the same class of error as a missing schema, and it
184
+ * reads the same way on purpose: name the thing, then print the one command.
185
+ *
186
+ * @param token - The unresolved lookup.
187
+ * @returns A diagnostic whose last line can be pasted into a shell.
188
+ */
189
+ export declare function unresolvedLookupMessage(token: LookupToken): string;
190
+ type RawReference = {
191
+ objectName?: string;
192
+ path?: string;
193
+ lookupNames?: string[];
194
+ lookupValue?: string;
195
+ filterPattern?: string;
196
+ childPath?: string;
197
+ dependsOn?: string[];
198
+ } | undefined;
199
+ /**
200
+ * The {@link LookupSpec} for one field, or `undefined` when it earns no helper.
201
+ *
202
+ * @param reference - The field's raw registry `reference` block.
203
+ * @param invariant - `objectName`s the ledger declares connector-invariant.
204
+ * @returns The spec a `.by*` helper would be generated from, or `undefined`.
205
+ */
206
+ export declare function lookupSpecOf(reference: RawReference, invariant?: ReadonlySet<string>): LookupSpec | undefined;
207
+ /**
208
+ * Refuse a lookup token where the family cannot resolve one.
209
+ *
210
+ * `lookup()` is a FLOW surface today: only `serialize.ts` substitutes a
211
+ * recorded resolution, and only `check.ts` reports an unresolved one. Case and
212
+ * BPMN pass connector input values straight into their emitted payload, so a
213
+ * token reaching either one is embedded verbatim — a `.case` carrying
214
+ * `{"__lookup": {…}}` where the connector expects an id.
215
+ *
216
+ * That is silent wrongness, which is the failure this whole surface exists to
217
+ * remove; emitting it from the tool that removes it would be the worst possible
218
+ * outcome. Until Case and BPMN read `resolutions.json` too, they refuse the
219
+ * token and say so.
220
+ *
221
+ * @param value - A connector input value.
222
+ * @param family - The authoring family, for the message.
223
+ * @param field - The input name, for the message.
224
+ * @throws If `value` is an unresolved {@link LookupToken}.
225
+ */
226
+ export declare function refuseLookupToken(value: unknown, family: string, field: string): void;
227
+ export {};