@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,34 @@
1
+ import { packagedGenerator, runGenerator } from "./python.js";
2
+ import { applyCuratedOverlay } from "./curated-overlay.js";
3
+ import { PACKAGE_NAME } from "../package-name.js";
4
+ export async function materializeRegistry(options) {
5
+ // The product CLI downloads the raw registry archive and delegates directly
6
+ // to this API. Apply the SDK's curated corrections here so every caller gets
7
+ // the same resolvable library as the standalone flow-sdk pull command,
8
+ // including connector start-trigger definitions absent from the raw dump.
9
+ await applyCuratedOverlay(options.libraryJsonPath);
10
+ const args = [
11
+ "--library-json",
12
+ options.libraryJsonPath,
13
+ "--import",
14
+ options.connectorImport ?? PACKAGE_NAME,
15
+ ];
16
+ if (options.libraryMarkdownPath) {
17
+ args.push("--library-md", options.libraryMarkdownPath);
18
+ }
19
+ if (options.connectorsPath) {
20
+ args.push("--connectors", options.connectorsPath);
21
+ }
22
+ if (options.connectorSubset && options.connectorSubset.length > 0) {
23
+ args.push("--connector-subset", options.connectorSubset.join(","));
24
+ }
25
+ if (options.triggersPath) {
26
+ args.push("--triggers", options.triggersPath);
27
+ }
28
+ await runGenerator({
29
+ script: options.generatorPath ?? packagedGenerator("materialize_registry.py"),
30
+ args,
31
+ pythonExecutable: options.pythonExecutable,
32
+ what: "Registry materialization",
33
+ });
34
+ }
@@ -0,0 +1 @@
1
+ export declare function run(argv: string[]): Promise<number>;
@@ -0,0 +1,56 @@
1
+ import { join } from "node:path";
2
+ import { CURRENT_LINK, currentEntrySha, libraryCacheRoot, resolveCachedLibrary, resolveCachedMarkdown, } from "./cache.js";
3
+ /**
4
+ * Say where the connector library is.
5
+ *
6
+ * The library moved out of the project into a shared cache, which means a script
7
+ * or an agent can no longer assume `./library`. Something has to answer "where is
8
+ * it", and printing a bare path is what makes that usable from a shell:
9
+ *
10
+ * FLOW_SDK_LIBRARY_MD="$(npx flow-sdk registry path --library-md)"
11
+ *
12
+ * `uip maestro registry path` reported the same thing before it was removed;
13
+ * this is its replacement, on the CLI that now owns the library.
14
+ */
15
+ const USAGE = [
16
+ "Usage: flow-sdk registry path [--library-json | --library-md | --root | --sha]",
17
+ "",
18
+ " With no flag, prints all of them as JSON. With one, prints just that value,",
19
+ " unquoted, for use in a shell.",
20
+ ].join("\n");
21
+ export async function run(argv) {
22
+ if (argv.includes("--help") || argv.includes("-h")) {
23
+ console.log(USAGE);
24
+ return 0;
25
+ }
26
+ const root = libraryCacheRoot();
27
+ const libraryJson = resolveCachedLibrary();
28
+ const libraryMarkdown = resolveCachedMarkdown();
29
+ const sha256 = currentEntrySha();
30
+ const single = (value) => {
31
+ if (!value) {
32
+ console.error("No connector library in the cache yet. Run `flow-sdk registry pull`.");
33
+ return 1;
34
+ }
35
+ console.log(value);
36
+ return 0;
37
+ };
38
+ if (argv.includes("--library-json"))
39
+ return single(libraryJson);
40
+ if (argv.includes("--library-md"))
41
+ return single(libraryMarkdown);
42
+ if (argv.includes("--root"))
43
+ return single(root);
44
+ if (argv.includes("--sha"))
45
+ return single(sha256);
46
+ console.log(JSON.stringify({
47
+ root,
48
+ current: join(root, CURRENT_LINK),
49
+ sha256: sha256 ?? null,
50
+ libraryJson: libraryJson ?? null,
51
+ libraryMarkdown: libraryMarkdown ?? null,
52
+ }, null, 2));
53
+ // Not an error: a caller asking for the whole picture is entitled to be told
54
+ // the cache is empty, rather than getting a non-zero exit for a plain report.
55
+ return 0;
56
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Fetch one operation's connection-resolved schema into a local overlay.
3
+ *
4
+ * The published library is tenant-agnostic, which is what lets it ship — and
5
+ * also what it cannot know: a Salesforce custom object, the fields a Jira
6
+ * project and issue type select, a ServiceNow table that exists on one tenant.
7
+ * Those need a connection, so they cannot be in the archive `pull` downloads.
8
+ *
9
+ * This writes what the archive is missing into `./connectors-local/`, which the
10
+ * compilers pick up on their own and union over the library — it can add fields,
11
+ * never remove ones that already worked. Without it a connector whose schema
12
+ * depends on a connection cannot be compiled at all: the fields discovered from
13
+ * a live `describe` have nowhere to go, and `compile` rejects them as unknown.
14
+ *
15
+ * Needs the `uip` CLI on PATH and logged in. The tenant calls go through it —
16
+ * `uip maestro flow registry get`, `uip is resources list/describe` — because
17
+ * `uip` is the tenant client and this only orchestrates it.
18
+ */
19
+ export interface PrepareConnectorOptions {
20
+ connectorKey: string;
21
+ action: string;
22
+ /** Omit to discover it from `uip is connections list`. */
23
+ connectionId?: string;
24
+ /** Pick the connection by name when several match. */
25
+ connection?: string;
26
+ /** bindings file to add the discovered connection to. */
27
+ bindings?: string;
28
+ bindConnection?: string;
29
+ bindFolder?: string;
30
+ noBindings?: boolean;
31
+ /** One connection-discovered object, for a Generic action. */
32
+ objectName?: string;
33
+ /** Every connection-discovered object. Mutually exclusive with objectName. */
34
+ allObjects?: boolean;
35
+ /** Parent-field values that select the schema, as `name=value`. */
36
+ fields?: string[];
37
+ /** Lookup resolutions, as `field:by=value`. Repeatable. */
38
+ resolve?: string[];
39
+ /** Re-resolve lookups already recorded, instead of leaving them alone. */
40
+ refreshLookups?: boolean;
41
+ outPath?: string;
42
+ version?: string;
43
+ connectorImport?: string;
44
+ jsonOnly?: boolean;
45
+ /** The `.flow.ts` whose import should be repointed at the prepared descriptor. */
46
+ source?: string;
47
+ /** Print the import line instead of editing the source. */
48
+ noSourceRewrite?: boolean;
49
+ pythonExecutable?: string;
50
+ /** Override used by tests and source checkouts. */
51
+ generatorPath?: string;
52
+ }
53
+ /** The generator's argv for these options. Exported to be tested directly. */
54
+ export declare function generatorArgs(options: PrepareConnectorOptions): string[];
55
+ export declare function prepareConnector(options: PrepareConnectorOptions): Promise<void>;
56
+ /**
57
+ * Options for this argv, or null when it does not name a connector, an action
58
+ * and a connection. Split out from `run` so the parsing can be tested without
59
+ * an interpreter.
60
+ */
61
+ export declare function parseArgs(argv: string[]): PrepareConnectorOptions | null;
62
+ export declare function run(argv: string[]): Promise<number>;
@@ -0,0 +1,185 @@
1
+ import { packagedGenerator, runGenerator } from "./python.js";
2
+ import { PACKAGE_NAME } from "../package-name.js";
3
+ // This mirrors the generator's own flags one for one, so a `--version` here is
4
+ // the connector's version, not the package's. The umbrella CLI spells that
5
+ // `--connector-version`, because commander's program-level version option
6
+ // shadows a subcommand's; it translates before calling `run`.
7
+ /** What a generated descriptor imports from. The generator's own default is a
8
+ * relative path that only resolves inside a source checkout. */
9
+ const DEFAULT_CONNECTOR_IMPORT = PACKAGE_NAME;
10
+ const USAGE = [
11
+ "Usage: flow-sdk registry prepare <connector-key> <action> [--connection-id <id>]",
12
+ " [--connection <name>] [--bindings <file>] [--no-bindings]",
13
+ " [--object <name> | --all-objects] [-f NAME=VALUE ...]",
14
+ " [--resolve FIELD:BY=VALUE ...] [--refresh-lookups]",
15
+ " [--out <dir>] [--version <v>] [--import <specifier>]",
16
+ " [--json-only] [--source <flow.ts>] [--no-source-rewrite]",
17
+ " [--python <exe>]",
18
+ ].join("\n");
19
+ /** The generator's argv for these options. Exported to be tested directly. */
20
+ export function generatorArgs(options) {
21
+ const args = [options.connectorKey, options.action];
22
+ if (options.connectionId)
23
+ args.push("--connection-id", options.connectionId);
24
+ if (options.connection)
25
+ args.push("--connection", options.connection);
26
+ if (options.bindings)
27
+ args.push("--bindings", options.bindings);
28
+ if (options.bindConnection)
29
+ args.push("--bind-connection", options.bindConnection);
30
+ if (options.bindFolder)
31
+ args.push("--bind-folder", options.bindFolder);
32
+ if (options.noBindings)
33
+ args.push("--no-bindings");
34
+ if (options.objectName)
35
+ args.push("--object", options.objectName);
36
+ if (options.allObjects)
37
+ args.push("--all-objects");
38
+ for (const field of options.fields ?? [])
39
+ args.push("-f", field);
40
+ for (const one of options.resolve ?? [])
41
+ args.push("--resolve", one);
42
+ if (options.refreshLookups)
43
+ args.push("--refresh-lookups");
44
+ if (options.outPath)
45
+ args.push("--out", options.outPath);
46
+ if (options.version)
47
+ args.push("--version", options.version);
48
+ // Always sent, because the generator's own default is `../sdk/flow-sdk.js` —
49
+ // a relative path that resolves in the eval image's checkout and nowhere else.
50
+ // The legacy `prepare-connector` shim hard-coded this; nothing else does, so
51
+ // omitting it emits a descriptor whose import line resolves to nothing.
52
+ // Matches materializer.ts, which defaults the same specifier.
53
+ args.push("--import", options.connectorImport ?? DEFAULT_CONNECTOR_IMPORT);
54
+ if (options.jsonOnly)
55
+ args.push("--json-only");
56
+ if (options.source)
57
+ args.push("--source", options.source);
58
+ if (options.noSourceRewrite)
59
+ args.push("--no-source-rewrite");
60
+ return args;
61
+ }
62
+ export async function prepareConnector(options) {
63
+ const args = generatorArgs(options);
64
+ await runGenerator({
65
+ script: options.generatorPath ?? packagedGenerator("prepare_connector.py"),
66
+ args,
67
+ pythonExecutable: options.pythonExecutable,
68
+ what: "Preparing the connector",
69
+ });
70
+ }
71
+ function value(args, name) {
72
+ const index = args.indexOf(name);
73
+ return index >= 0 ? args[index + 1] : undefined;
74
+ }
75
+ /** Every value given for a repeatable flag, in order. */
76
+ function repeated(args, name) {
77
+ const collected = [];
78
+ args.forEach((arg, index) => {
79
+ if (arg === name) {
80
+ const next = args[index + 1];
81
+ if (next !== undefined)
82
+ collected.push(next);
83
+ }
84
+ });
85
+ return collected;
86
+ }
87
+ /** Every `-f`/`--field` value, in the order given — the flag repeats. */
88
+ function fields(args) {
89
+ const collected = [];
90
+ args.forEach((arg, index) => {
91
+ if (arg === "-f" || arg === "--field") {
92
+ const next = args[index + 1];
93
+ if (next !== undefined)
94
+ collected.push(next);
95
+ }
96
+ });
97
+ return collected;
98
+ }
99
+ /**
100
+ * Options for this argv, or null when it does not name a connector, an action
101
+ * and a connection. Split out from `run` so the parsing can be tested without
102
+ * an interpreter.
103
+ */
104
+ export function parseArgs(argv) {
105
+ // The two positionals are whatever is left once flags and their values are
106
+ // accounted for, so they can appear before or after the flags.
107
+ const consumed = new Set();
108
+ for (const name of [
109
+ "--connection-id",
110
+ "--connection",
111
+ "--bindings",
112
+ "--bind-connection",
113
+ "--bind-folder",
114
+ "--object",
115
+ "--out",
116
+ "--version",
117
+ "--import",
118
+ "--source",
119
+ "--python",
120
+ "--generator",
121
+ "-f",
122
+ "--field",
123
+ "--resolve",
124
+ ]) {
125
+ argv.forEach((arg, index) => {
126
+ if (arg === name) {
127
+ consumed.add(index);
128
+ consumed.add(index + 1);
129
+ }
130
+ });
131
+ }
132
+ ["--all-objects", "--json-only", "--refresh-lookups", "--no-bindings",
133
+ "--no-source-rewrite"].forEach((flag) => {
134
+ const index = argv.indexOf(flag);
135
+ if (index >= 0)
136
+ consumed.add(index);
137
+ });
138
+ const positionals = argv.filter((_, index) => !consumed.has(index));
139
+ // `--connection-id` is no longer required: without one the generator
140
+ // discovers the connection itself and writes bindings.json.
141
+ if (positionals.length !== 2)
142
+ return null;
143
+ return {
144
+ connectorKey: positionals[0],
145
+ action: positionals[1],
146
+ connectionId: value(argv, "--connection-id"),
147
+ connection: value(argv, "--connection"),
148
+ bindings: value(argv, "--bindings"),
149
+ bindConnection: value(argv, "--bind-connection"),
150
+ bindFolder: value(argv, "--bind-folder"),
151
+ noBindings: argv.includes("--no-bindings"),
152
+ objectName: value(argv, "--object"),
153
+ allObjects: argv.includes("--all-objects"),
154
+ fields: fields(argv),
155
+ resolve: repeated(argv, "--resolve"),
156
+ refreshLookups: argv.includes("--refresh-lookups"),
157
+ outPath: value(argv, "--out"),
158
+ version: value(argv, "--version"),
159
+ connectorImport: value(argv, "--import"),
160
+ jsonOnly: argv.includes("--json-only"),
161
+ source: value(argv, "--source"),
162
+ noSourceRewrite: argv.includes("--no-source-rewrite"),
163
+ pythonExecutable: value(argv, "--python"),
164
+ generatorPath: value(argv, "--generator"),
165
+ };
166
+ }
167
+ export async function run(argv) {
168
+ if (argv.includes("--help") || argv.includes("-h")) {
169
+ console.log(USAGE);
170
+ return 0;
171
+ }
172
+ const options = parseArgs(argv);
173
+ if (!options) {
174
+ console.error(USAGE);
175
+ return 2;
176
+ }
177
+ try {
178
+ await prepareConnector(options);
179
+ return 0;
180
+ }
181
+ catch (error) {
182
+ console.error(error instanceof Error ? error.message : String(error));
183
+ return 1;
184
+ }
185
+ }
@@ -0,0 +1 @@
1
+ export declare function run(argv: string[]): Promise<number>;
@@ -0,0 +1,274 @@
1
+ import { createHash } from "node:crypto";
2
+ import { mkdir, readFile, rename, rm, stat, symlink, writeFile, } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { CURRENT_LINK, LIBRARY_JSON_DIR, LIBRARY_MARKDOWN_DIR, cacheEntry, libraryCacheRoot, referencedConnectorKeys, } from "./cache.js";
5
+ import { extractLibrary } from "./extractor.js";
6
+ import { materializeRegistry } from "./materializer.js";
7
+ import { curatedOverlayIdentity } from "./curated-overlay.js";
8
+ /**
9
+ * Fetch the published connector library into the shared cache, and generate the
10
+ * typed descriptors a project imports.
11
+ *
12
+ * The library and its markdown go to `~/.uipath/cache/flow-sdk/library/<sha256>/`
13
+ * and `current` is pointed at them, because both trees are a pure function of the
14
+ * archive plus this SDK version's curated corrections: two projects that pull
15
+ * the same inputs produce byte-identical output, so a copy per project cost
16
+ * 159 MB for nothing. A pull refreshes the one copy and every project sees it.
17
+ *
18
+ * The project gets only `connectors/`, and only for the connectors it actually
19
+ * references — an author imports those by relative path, so they cannot live in
20
+ * the cache, but the other 29 modules were never going to be imported either.
21
+ *
22
+ * `--library` and `--library-md` still name destinations, for a caller that wants
23
+ * the trees somewhere specific instead of in the cache.
24
+ */
25
+ const DEFAULT_URL = "https://download.uipath.com/maestro/registry/library-json.zip";
26
+ /** Provenance for a cache entry, written inside its library-json. */
27
+ const SOURCE_FILE = ".registry-source.json";
28
+ const USAGE = [
29
+ "Usage: flow-sdk registry pull [--connectors <dir>] [--connector <key>]...",
30
+ " [--library <dir>] [--library-md <dir>]",
31
+ " [--url <url>] [--archive <zip>] [--force]",
32
+ " [--import <specifier>] [--triggers <path>] [--python <exe>]",
33
+ " [--root <prefix>] [--extractor <path>] [--generator <path>]",
34
+ ].join("\n");
35
+ function value(args, name) {
36
+ const index = args.indexOf(name);
37
+ return index >= 0 ? args[index + 1] : undefined;
38
+ }
39
+ function has(args, name) {
40
+ return args.includes(name);
41
+ }
42
+ /** Every `--connector` value; the flag repeats. */
43
+ function repeated(args, name) {
44
+ const values = [];
45
+ args.forEach((arg, index) => {
46
+ if (arg === name && args[index + 1] !== undefined) {
47
+ values.push(args[index + 1]);
48
+ }
49
+ });
50
+ return values;
51
+ }
52
+ /** The sha256 a `.sha256` sidecar declares, rejecting anything that is not one. */
53
+ function expectedChecksum(body) {
54
+ const hash = body.trim().split(/\s+/, 1)[0]?.toLowerCase();
55
+ if (!hash || !/^[a-f0-9]{64}$/.test(hash)) {
56
+ // A proxy or portal serving an HTML error page reaches here. Failing on the
57
+ // shape means that shows up as a bad checksum response rather than as a
58
+ // mismatch against a "hash" that was really a login page.
59
+ throw new Error("The connector library checksum response is not a sha256.");
60
+ }
61
+ return hash;
62
+ }
63
+ async function isFile(path) {
64
+ try {
65
+ return (await stat(path)).isFile();
66
+ }
67
+ catch {
68
+ return false;
69
+ }
70
+ }
71
+ async function isDirectory(path) {
72
+ try {
73
+ return (await stat(path)).isDirectory();
74
+ }
75
+ catch {
76
+ return false;
77
+ }
78
+ }
79
+ async function download(url) {
80
+ const response = await fetch(url);
81
+ if (!response.ok) {
82
+ throw new Error(`Could not download ${url}: HTTP ${response.status} ${response.statusText}`);
83
+ }
84
+ return new Uint8Array(await response.arrayBuffer());
85
+ }
86
+ /**
87
+ * Node's built-in fetch ignores HTTP(S)_PROXY unless told otherwise, and it
88
+ * fails in a way that looks like the server is down. Say so up front, and name
89
+ * both ways out, rather than let a proxied user debug a timeout.
90
+ */
91
+ function warnAboutProxy() {
92
+ const proxy = process.env.HTTPS_PROXY ??
93
+ process.env.https_proxy ??
94
+ process.env.HTTP_PROXY ??
95
+ process.env.http_proxy;
96
+ if (!proxy)
97
+ return;
98
+ console.error(`registry pull: a proxy is set (${proxy}) and Node's fetch does not use it by default.\n` +
99
+ " If the download fails, either run with NODE_USE_ENV_PROXY=1 (Node 24+),\n" +
100
+ " or fetch the zip yourself and pass --archive <path>.");
101
+ }
102
+ async function resolveArchive(argv, cacheDir, force) {
103
+ const local = value(argv, "--archive");
104
+ if (local) {
105
+ // The caller's own file: no sidecar to check it against, and demanding one
106
+ // would defeat the escape hatch this exists to be. It is hashed anyway, so
107
+ // it still gets a cache entry of its own.
108
+ if (!(await isFile(local))) {
109
+ throw new Error(`No such archive: ${local}`);
110
+ }
111
+ return { path: local };
112
+ }
113
+ const url = value(argv, "--url") ?? DEFAULT_URL;
114
+ warnAboutProxy();
115
+ const checksumResponse = await fetch(`${url}.sha256`);
116
+ if (!checksumResponse.ok) {
117
+ throw new Error(`Could not download ${url}.sha256: HTTP ${checksumResponse.status} ${checksumResponse.statusText}`);
118
+ }
119
+ const expected = expectedChecksum(await checksumResponse.text());
120
+ await mkdir(cacheDir, { recursive: true });
121
+ const cached = join(cacheDir, `${expected}.zip`);
122
+ if (!force && (await isFile(cached))) {
123
+ console.error(`registry pull: reusing cached ${expected.slice(0, 12)}…`);
124
+ return { path: cached, checksum: expected, url };
125
+ }
126
+ const archive = await download(url);
127
+ const actual = createHash("sha256").update(archive).digest("hex");
128
+ if (actual !== expected) {
129
+ throw new Error(`Connector library checksum mismatch: expected ${expected}, received ${actual}.`);
130
+ }
131
+ // Write through a temp name so a killed run cannot leave a half file under a
132
+ // hash that claims to describe it.
133
+ const temporary = `${cached}.tmp-${process.pid}`;
134
+ await writeFile(temporary, archive);
135
+ await rename(temporary, cached);
136
+ return { path: cached, checksum: expected, url };
137
+ }
138
+ /** A `--archive` has no sidecar, so its identity is the bytes themselves. */
139
+ async function archiveIdentity(archive) {
140
+ if (archive.checksum)
141
+ return archive.checksum;
142
+ return createHash("sha256").update(await readFile(archive.path)).digest("hex");
143
+ }
144
+ /** The extracted library is a function of both the dump and SDK corrections. */
145
+ function libraryIdentity(archiveSha256, overlaySha256) {
146
+ return createHash("sha256")
147
+ .update(archiveSha256)
148
+ .update("\0")
149
+ .update(overlaySha256)
150
+ .digest("hex");
151
+ }
152
+ async function isCurrentLibrary(libraryPath, sha256) {
153
+ if (!(await isFile(join(libraryPath, "index.json"))))
154
+ return false;
155
+ try {
156
+ const source = JSON.parse(await readFile(join(libraryPath, SOURCE_FILE), "utf8"));
157
+ return source.sha256 === sha256;
158
+ }
159
+ catch {
160
+ return false;
161
+ }
162
+ }
163
+ async function writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256) {
164
+ await writeFile(join(libraryPath, SOURCE_FILE), `${JSON.stringify({
165
+ sha256,
166
+ archiveSha256,
167
+ overlaySha256,
168
+ url: archive.url ?? null,
169
+ archive: archive.checksum ? undefined : archive.path,
170
+ pulledAt: new Date().toISOString(),
171
+ }, null, 2)}\n`);
172
+ }
173
+ /**
174
+ * Point `current` at an entry, replacing whatever it named.
175
+ *
176
+ * Written to a temp name and renamed, so a reader never sees the link missing —
177
+ * `rename` over an existing symlink is atomic, while unlink-then-create leaves a
178
+ * window where a concurrent compile finds nothing.
179
+ */
180
+ async function pointCurrentAt(root, sha256) {
181
+ const link = join(root, CURRENT_LINK);
182
+ const temporary = `${link}.tmp-${process.pid}`;
183
+ await rm(temporary, { recursive: true, force: true });
184
+ await symlink(sha256, temporary, "junction");
185
+ await rename(temporary, link);
186
+ }
187
+ export async function run(argv) {
188
+ if (has(argv, "--help") || has(argv, "-h")) {
189
+ console.log(USAGE);
190
+ return 0;
191
+ }
192
+ const cacheDir = libraryCacheRoot();
193
+ const force = has(argv, "--force");
194
+ const pythonExecutable = value(argv, "--python");
195
+ const connectorsPath = value(argv, "--connectors") ?? "connectors";
196
+ try {
197
+ const archive = await resolveArchive(argv, cacheDir, force);
198
+ const archiveSha256 = await archiveIdentity(archive);
199
+ const overlaySha256 = await curatedOverlayIdentity();
200
+ const sha256 = libraryIdentity(archiveSha256, overlaySha256);
201
+ const entry = cacheEntry(sha256, cacheDir);
202
+ // Destination overrides: a caller can still put the trees somewhere of their
203
+ // own choosing instead of in the cache.
204
+ const libraryPath = value(argv, "--library") ?? join(entry, LIBRARY_JSON_DIR);
205
+ const markdownPath = value(argv, "--library-md") ?? join(entry, LIBRARY_MARKDOWN_DIR);
206
+ const haveLibrary = !force && (await isCurrentLibrary(libraryPath, sha256));
207
+ if (haveLibrary) {
208
+ console.error(`registry pull: library ${sha256.slice(0, 12)}… already extracted`);
209
+ }
210
+ else {
211
+ // Unpack beside the target and swap, so a failure leaves whatever was
212
+ // already there rather than half of a new one.
213
+ const staging = `${libraryPath}.tmp-${process.pid}`;
214
+ await rm(staging, { recursive: true, force: true });
215
+ await extractLibrary({
216
+ archivePath: archive.path,
217
+ destinationPath: staging,
218
+ root: value(argv, "--root"),
219
+ pythonExecutable,
220
+ extractorPath: value(argv, "--extractor"),
221
+ });
222
+ await rm(libraryPath, { recursive: true, force: true });
223
+ await mkdir(join(libraryPath, ".."), { recursive: true });
224
+ await rename(staging, libraryPath);
225
+ await writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256);
226
+ }
227
+ // Which descriptors this project will actually import. Generating all 30
228
+ // costs 1.1 MB in someone's repository for operations they never call.
229
+ const named = repeated(argv, "--connector");
230
+ const referenced = named.length > 0 ? named : referencedConnectorKeys(".");
231
+ // Generate only what is missing. The Markdown is 2,472 pages and a pure
232
+ // function of the library JSON, so regenerating it to add one descriptor is
233
+ // pure waste — and it is what the first run of this design did.
234
+ const haveMarkdown = !force && haveLibrary && (await isFile(join(markdownPath, "index.json")));
235
+ if (haveMarkdown) {
236
+ console.error(`registry pull: markdown ${sha256.slice(0, 12)}… already generated`);
237
+ }
238
+ const wantMarkdown = !haveMarkdown;
239
+ const wantConnectors = referenced.length > 0;
240
+ if (wantMarkdown || wantConnectors) {
241
+ await materializeRegistry({
242
+ libraryJsonPath: libraryPath,
243
+ libraryMarkdownPath: wantMarkdown ? markdownPath : undefined,
244
+ connectorsPath: wantConnectors ? connectorsPath : undefined,
245
+ connectorSubset: referenced,
246
+ connectorImport: value(argv, "--import"),
247
+ pythonExecutable,
248
+ triggersPath: value(argv, "--triggers"),
249
+ generatorPath: value(argv, "--generator"),
250
+ });
251
+ }
252
+ if (!(await isFile(join(markdownPath, "index.json")))) {
253
+ throw new Error(`Registry materialization did not produce ${join(markdownPath, "index.json")}.`);
254
+ }
255
+ if (!value(argv, "--library")) {
256
+ await pointCurrentAt(cacheDir, sha256);
257
+ }
258
+ console.error(`registry pull: ${sha256.slice(0, 12)}… ready in ${cacheDir}` +
259
+ (value(argv, "--library") ? "" : ` (current -> ${sha256.slice(0, 12)}…)`));
260
+ if (referenced.length > 0) {
261
+ console.error(`registry pull: generated ${connectorsPath}/ for ${referenced.join(", ")}`);
262
+ }
263
+ else {
264
+ console.error("registry pull: no connector referenced by this project yet, so no " +
265
+ "descriptors were generated. Name one with `--connector <key>`, or " +
266
+ "author the step and pull again.");
267
+ }
268
+ return 0;
269
+ }
270
+ catch (error) {
271
+ console.error(error instanceof Error ? error.message : String(error));
272
+ return 1;
273
+ }
274
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Running the packaged Python generators.
3
+ *
4
+ * Three verbs shell out to Python — materialize, extract and prepare — and all
5
+ * three need the same three things: the script's path inside the installed
6
+ * package, an interpreter, and a failure translated into a message worth
7
+ * reading. Keeping that here means a fix (a new platform's interpreter name,
8
+ * a clearer error) lands once.
9
+ *
10
+ * The generators are copied to `dist/generators/` at build time and these
11
+ * modules live in `dist/registry/`, so the path is one level up. Resolving it
12
+ * from `import.meta.url` rather than `process.cwd()` is what lets the verbs run
13
+ * from anywhere.
14
+ */
15
+ /** A generator shipped in `dist/generators/`. */
16
+ export declare function packagedGenerator(fileName: string): string;
17
+ export declare function defaultPythonExecutable(): string;
18
+ export interface RunGeneratorOptions {
19
+ /** Script path — usually `packagedGenerator(...)`, overridable for checkouts. */
20
+ script: string;
21
+ args: string[];
22
+ pythonExecutable?: string;
23
+ /** Names the step in failure messages, e.g. "Registry materialization". */
24
+ what: string;
25
+ }
26
+ export declare function runGenerator(options: RunGeneratorOptions): Promise<void>;