@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,46 @@
1
+ import { spawn } from "node:child_process";
2
+ import { fileURLToPath } from "node:url";
3
+ /**
4
+ * Running the packaged Python generators.
5
+ *
6
+ * Three verbs shell out to Python — materialize, extract and prepare — and all
7
+ * three need the same three things: the script's path inside the installed
8
+ * package, an interpreter, and a failure translated into a message worth
9
+ * reading. Keeping that here means a fix (a new platform's interpreter name,
10
+ * a clearer error) lands once.
11
+ *
12
+ * The generators are copied to `dist/generators/` at build time and these
13
+ * modules live in `dist/registry/`, so the path is one level up. Resolving it
14
+ * from `import.meta.url` rather than `process.cwd()` is what lets the verbs run
15
+ * from anywhere.
16
+ */
17
+ /** A generator shipped in `dist/generators/`. */
18
+ export function packagedGenerator(fileName) {
19
+ return fileURLToPath(new URL(`../generators/${fileName}`, import.meta.url));
20
+ }
21
+ export function defaultPythonExecutable() {
22
+ return (process.env.UIP_PYTHON_PATH ||
23
+ (process.platform === "win32" ? "python" : "python3"));
24
+ }
25
+ export async function runGenerator(options) {
26
+ const executable = options.pythonExecutable ?? defaultPythonExecutable();
27
+ await new Promise((resolve, reject) => {
28
+ const child = spawn(executable, [options.script, ...options.args], {
29
+ stdio: "inherit",
30
+ });
31
+ child.once("error", (error) => {
32
+ reject(new Error(`Could not start Python with ${executable}: ${error.message}. ` +
33
+ "The connector generators are Python scripts; install Python 3 or " +
34
+ "point UIP_PYTHON_PATH at an interpreter."));
35
+ });
36
+ child.once("exit", (code, signal) => {
37
+ if (code === 0) {
38
+ resolve();
39
+ return;
40
+ }
41
+ reject(new Error(signal
42
+ ? `${options.what} stopped with signal ${signal}`
43
+ : `${options.what} failed with exit code ${code ?? "unknown"}`));
44
+ });
45
+ });
46
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Search an extracted connector library for operations.
3
+ *
4
+ * Ported from the product CLI's `registry-search-service.ts` so discovery lives
5
+ * beside the rest of the authoring verbs. Two deliberate differences from that
6
+ * version:
7
+ *
8
+ * - the library defaults to the cached one, and `--library` overrides it the same
9
+ * way `compile` and `check` take it
10
+ * name it, instead of being resolved from a machine-global snapshot. `pull`
11
+ * defaults to writing one into the project; this verb does not guess where
12
+ * that ended up, it is told;
13
+ * - the result is plain JSON on stdout. The `Result` / `Code` / `Data` envelope
14
+ * is a `uip` convention, and an agent parsing this output does not need it.
15
+ */
16
+ export interface RegistryOperation {
17
+ nodeType: string;
18
+ version: string;
19
+ connectorKey: string;
20
+ label: string;
21
+ activityType: string;
22
+ objectName: string;
23
+ operationName: string;
24
+ /** v1 node definition the compiler consumes. */
25
+ definitionPath: string;
26
+ /** Markdown page describing the operation's fields, when one was found. */
27
+ markdownPath?: string;
28
+ }
29
+ export interface RegistrySearchOptions {
30
+ libraryPath: string;
31
+ markdownPath?: string;
32
+ query?: string;
33
+ connector?: string;
34
+ limit?: number;
35
+ }
36
+ export interface RegistrySearchResult {
37
+ total: number;
38
+ operations: RegistryOperation[];
39
+ }
40
+ export declare const DEFAULT_SEARCH_LIMIT = 20;
41
+ /**
42
+ * Split a query into the words that all have to match.
43
+ *
44
+ * Every token must appear somewhere in the entry, but they may land in
45
+ * different fields and in any order, so a natural phrase works: "salesforce
46
+ * insert record" matches an entry whose connector key carries "salesforce" and
47
+ * whose node type carries "insert-record". Tokens match as substrings, so a
48
+ * word still finds its hyphenated form without normalising separators.
49
+ */
50
+ export declare function queryTokens(query?: string): string[];
51
+ export declare function searchRegistryOperations(options: RegistrySearchOptions): Promise<RegistrySearchResult>;
52
+ export declare function run(argv: string[]): Promise<number>;
@@ -0,0 +1,159 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { resolveLibraryDir } from "./cache.js";
3
+ import { dirname, join } from "node:path";
4
+ export const DEFAULT_SEARCH_LIMIT = 20;
5
+ const USAGE = "Usage: flow-sdk registry search [query] [--library <dir>] [--library-md <dir>] [--connector <key>] [--limit <n>]";
6
+ function text(value) {
7
+ return typeof value === "string" ? value : "";
8
+ }
9
+ /**
10
+ * Split a query into the words that all have to match.
11
+ *
12
+ * Every token must appear somewhere in the entry, but they may land in
13
+ * different fields and in any order, so a natural phrase works: "salesforce
14
+ * insert record" matches an entry whose connector key carries "salesforce" and
15
+ * whose node type carries "insert-record". Tokens match as substrings, so a
16
+ * word still finds its hyphenated form without normalising separators.
17
+ */
18
+ export function queryTokens(query) {
19
+ return (query ?? "")
20
+ .trim()
21
+ .toLowerCase()
22
+ .split(/\s+/)
23
+ .filter((token) => token.length > 0);
24
+ }
25
+ async function isDirectory(path) {
26
+ try {
27
+ return (await stat(path)).isDirectory();
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }
33
+ /**
34
+ * The markdown tree that pairs with `libraryPath`.
35
+ *
36
+ * Explicit `--library-md` wins. Otherwise look for a `library-md` sibling,
37
+ * which is how the materializer lays the two out. When neither exists the
38
+ * results simply carry no `markdownPath` — a missing page is not a reason to
39
+ * refuse a search.
40
+ */
41
+ async function resolveMarkdownRoot(libraryPath, explicit) {
42
+ if (explicit)
43
+ return explicit;
44
+ const sibling = join(dirname(libraryPath), "library-md");
45
+ return (await isDirectory(sibling)) ? sibling : undefined;
46
+ }
47
+ export async function searchRegistryOperations(options) {
48
+ const indexPath = join(options.libraryPath, "index.json");
49
+ let content;
50
+ try {
51
+ content = await readFile(indexPath, "utf-8");
52
+ }
53
+ catch {
54
+ throw new Error(`Could not read ${indexPath}. Run \`flow-sdk registry pull\`, or point` +
55
+ " --library at an extracted connector library.");
56
+ }
57
+ let parsed;
58
+ try {
59
+ parsed = JSON.parse(content);
60
+ }
61
+ catch {
62
+ throw new Error(`${indexPath} is not valid JSON.`);
63
+ }
64
+ if (!parsed || !Array.isArray(parsed.entries)) {
65
+ throw new Error(`${indexPath} is not a valid connector index.`);
66
+ }
67
+ const tokens = queryTokens(options.query);
68
+ const connector = options.connector?.trim().toLowerCase();
69
+ const matches = parsed.entries.filter((entry) => {
70
+ const key = text(entry.connectorKey).toLowerCase();
71
+ if (connector && key !== connector)
72
+ return false;
73
+ if (tokens.length === 0)
74
+ return true;
75
+ // One haystack per entry, so a query may span fields. Matching each field
76
+ // separately meant a caller had to know which field held which word:
77
+ // "salesforce insert record" found nothing, because "salesforce" is in the
78
+ // connector key and "insert record" is in the node type, and no single
79
+ // field contained the whole phrase.
80
+ const haystack = [
81
+ text(entry.label),
82
+ text(entry.nodeType),
83
+ text(entry.objectName),
84
+ text(entry.operationName),
85
+ key,
86
+ ]
87
+ .join(" ")
88
+ .toLowerCase();
89
+ return tokens.every((token) => haystack.includes(token));
90
+ });
91
+ const markdownRoot = await resolveMarkdownRoot(options.libraryPath, options.markdownPath);
92
+ const limit = options.limit ?? DEFAULT_SEARCH_LIMIT;
93
+ const operations = matches.slice(0, limit).map((entry) => {
94
+ const relative = text(entry.path);
95
+ const operation = {
96
+ nodeType: text(entry.nodeType),
97
+ version: text(entry.version),
98
+ connectorKey: text(entry.connectorKey),
99
+ label: text(entry.label),
100
+ activityType: text(entry.activityType),
101
+ objectName: text(entry.objectName),
102
+ operationName: text(entry.operationName),
103
+ definitionPath: join(options.libraryPath, relative.replace(/\.json$/, ".v1def.json")),
104
+ };
105
+ if (markdownRoot) {
106
+ operation.markdownPath = join(markdownRoot, relative.replace(/\.json$/, ".md"));
107
+ }
108
+ return operation;
109
+ });
110
+ return { total: matches.length, operations };
111
+ }
112
+ function value(args, name) {
113
+ const index = args.indexOf(name);
114
+ return index >= 0 ? args[index + 1] : undefined;
115
+ }
116
+ export async function run(argv) {
117
+ // Same resolution as compile and check: named, else the environment, else the
118
+ // shared cache `registry pull` filled. Requiring the flag here while the other
119
+ // verbs defaulted it was the inconsistency an author hit first.
120
+ const libraryPath = resolveLibraryDir(value(argv, "--library"));
121
+ if (!libraryPath) {
122
+ console.error(USAGE);
123
+ return 2;
124
+ }
125
+ const rawLimit = value(argv, "--limit");
126
+ const limit = rawLimit === undefined ? undefined : Number(rawLimit);
127
+ if (limit !== undefined && (!Number.isInteger(limit) || limit <= 0)) {
128
+ console.error(`--limit expects a positive integer, received '${rawLimit}'.`);
129
+ return 2;
130
+ }
131
+ // The query is the one positional: every other token is a flag or its value.
132
+ const flagged = new Set();
133
+ for (const name of ["--library", "--library-md", "--connector", "--limit"]) {
134
+ const index = argv.indexOf(name);
135
+ if (index >= 0) {
136
+ flagged.add(String(index));
137
+ flagged.add(String(index + 1));
138
+ }
139
+ }
140
+ const query = argv
141
+ .filter((_, index) => !flagged.has(String(index)))
142
+ .join(" ")
143
+ .trim();
144
+ try {
145
+ const result = await searchRegistryOperations({
146
+ libraryPath,
147
+ markdownPath: value(argv, "--library-md"),
148
+ query: query || undefined,
149
+ connector: value(argv, "--connector"),
150
+ limit,
151
+ });
152
+ console.log(JSON.stringify(result, null, 2));
153
+ return 0;
154
+ }
155
+ catch (error) {
156
+ console.error(error instanceof Error ? error.message : String(error));
157
+ return 1;
158
+ }
159
+ }
@@ -0,0 +1,165 @@
1
+ /**
2
+ * schema-version — the artifact's FILE-FORMAT version, as something an author
3
+ * can declare and a decompile can PRESERVE.
4
+ *
5
+ * Every artifact family this SDK writes carries a version that describes the
6
+ * DOCUMENT's grammar rather than the author's release: Flow's top-level
7
+ * `version`, Case's top-level `version`, BPMN's `uipath:migrationVersion`. Until
8
+ * now each family pinned exactly one value in its serializer's format profile
9
+ * and overwrote whatever the input said, which is right for greenfield
10
+ * authoring and wrong for the brownfield loop:
11
+ *
12
+ * decompile(a 1.10 flow) -> compile -> a 1.9 flow, with nothing said.
13
+ *
14
+ * That silent rewrite is the hole this module closes. `.schemaVersion(v)` on
15
+ * each builder declares the version the emitted document targets, decompile
16
+ * emits the call so a round-trip re-declares what it read, and the serializer
17
+ * writes what was declared instead of the pin.
18
+ *
19
+ * ## A declared version is a CLAIM, not a switch
20
+ *
21
+ * The rule that shapes this whole module is the one CASE_PARITY §3.8 states for
22
+ * `.version()`: a document's version asserts that the whole document matches
23
+ * that schema. An author writing `.version('30.0.0')` against the old
24
+ * V20-emitting serializer produced an INVALID document, because the claim was
25
+ * false. So `.schemaVersion()` accepts only versions this SDK can actually
26
+ * write — {@link SchemaVersionPolicy.writable}, each row carrying the evidence
27
+ * that says so — and refuses anything else rather than stamping a claim it
28
+ * cannot back. Moving a document BETWEEN versions stays the product's job
29
+ * (`uip maestro flow migrate`), because a hop can carry data repairs this SDK
30
+ * has no way to reproduce.
31
+ *
32
+ * ## Comparing versions
33
+ *
34
+ * `'1.10' < '1.9'` as strings, which is exactly the wrong answer, and the same
35
+ * trap sits in Case's `'30.0.0'` vs `'9.0.0'`. Nothing here compares version
36
+ * strings with `<`; {@link compareSchemaVersions} splits on `.` and compares
37
+ * segments numerically, and every gate goes through it.
38
+ */
39
+ /** The artifact families that carry a schema version. */
40
+ export type ArtifactFamily = 'flow' | 'case' | 'bpmn';
41
+ /** A version this SDK build can WRITE, with the evidence that says it can. */
42
+ export interface WritableSchemaVersion {
43
+ /** The version string, exactly as it appears in the document. */
44
+ version: string;
45
+ /**
46
+ * The version whose emitted bytes this one shares, when it shares any. Two
47
+ * versions are byte-equal for this SDK when the newer schema only re-declares
48
+ * the version literal and its migration hop touches nothing the SDK emits —
49
+ * then writing it is the same output under a different claim.
50
+ */
51
+ sameBytesAs?: string;
52
+ /** Why this SDK can write it. Read from the platform's own schema/migration source, not assumed. */
53
+ evidence: string;
54
+ }
55
+ /**
56
+ * What one family's schema version means, what this SDK can write, and where
57
+ * the platform's own boundary sits.
58
+ */
59
+ export interface SchemaVersionPolicy {
60
+ family: ArtifactFamily;
61
+ /**
62
+ * `'enumerated'` — the platform defines a closed set of grammars and a
63
+ * document's version claims one of them, so only {@link writable} versions
64
+ * may be declared (Flow, Case).
65
+ *
66
+ * `'verbatim'` — the version is a stamp the SDK copies through without
67
+ * varying its emission, so any well-formed value is accepted (BPMN's
68
+ * `uipath:migrationVersion`, a canvas schema generation).
69
+ */
70
+ mode: 'enumerated' | 'verbatim';
71
+ /**
72
+ * What an artifact declares when the author does not. For an enumerated
73
+ * family this is the fleet WRITE FLOOR — the oldest version every deployed
74
+ * reader accepts — not the newest version that exists. `undefined` means the
75
+ * document declares nothing at all (BPMN: an empty
76
+ * `uipath:migrationVersion` fails product validation, so absent beats blank).
77
+ */
78
+ default?: string;
79
+ /**
80
+ * The newest version the platform is known to define, from the family's
81
+ * snapshot. Kept here so the gap between "what we write" and "what exists"
82
+ * is a value the diagnostics can name rather than a comment.
83
+ */
84
+ latestKnown?: string;
85
+ /** Every version this build can write. Empty for a `'verbatim'` family. */
86
+ writable: readonly WritableSchemaVersion[];
87
+ /**
88
+ * One sentence naming what moves a document BETWEEN versions — a product
89
+ * command for Flow, the platform's on-read chain for Case. Free text rather
90
+ * than a command name because the two families answer it differently, and a
91
+ * refusal that names the wrong mechanism is worse than one that names none.
92
+ */
93
+ migration: string;
94
+ /**
95
+ * The builder method that declares it, WITHOUT parentheses (`.schemaVersion`)
96
+ * — every message appends its own argument list, so a value carrying `()`
97
+ * renders as `.schemaVersion()("1.9")`.
98
+ */
99
+ method: string;
100
+ }
101
+ /** True when `value` is shaped like a schema version at all. */
102
+ export declare function isSchemaVersionSyntax(value: unknown): value is string;
103
+ /**
104
+ * Compare two dotted-numeric versions SEGMENT BY SEGMENT: negative when `a` is
105
+ * older, 0 when equal, positive when `a` is newer. A missing segment reads as
106
+ * `0`, so `'1.9'` and `'1.9.0'` compare equal.
107
+ *
108
+ * Throws on a non-version string rather than guessing, because a silent 0 here
109
+ * would make every gate answer "equal" for garbage input.
110
+ */
111
+ export declare function compareSchemaVersions(a: string, b: string): number;
112
+ /** True when `version` is `floor` or newer. The gate every version-conditional step uses. */
113
+ export declare function schemaVersionAtLeast(version: string, floor: string): boolean;
114
+ /** The writable versions, oldest first. */
115
+ export declare function writableSchemaVersions(policy: SchemaVersionPolicy): string[];
116
+ /**
117
+ * True when this build can write `version` for `policy`.
118
+ *
119
+ * A `'verbatim'` family accepts any non-empty stamp, because the SDK copies it
120
+ * through without varying a byte of its emission — refusing an unfamiliar value
121
+ * there would DROP a stamp the platform wrote, which is the loss this whole
122
+ * module exists to stop. Only an empty one is refused, and that is a product
123
+ * rule: an empty `uipath:migrationVersion` fails validation outright, so absent
124
+ * beats blank.
125
+ */
126
+ export declare function isWritableSchemaVersion(policy: SchemaVersionPolicy, version: string): boolean;
127
+ /**
128
+ * Why `requested` cannot be declared, or `undefined` when it can.
129
+ *
130
+ * One message text, shared by the builder's own refusal, `check()`'s
131
+ * diagnostic and the serializer's throw, so an author who hits it in three
132
+ * places reads the same sentence three times instead of three near-misses.
133
+ */
134
+ export declare function schemaVersionRefusal(policy: SchemaVersionPolicy, requested: string): string | undefined;
135
+ /**
136
+ * The version an artifact declares: the author's when they declared one, else
137
+ * the policy default. Throws the shared refusal when it cannot be honoured —
138
+ * called from the serializer, which must not write a claim it cannot back even
139
+ * when `check()` was skipped (`compile --no-check`, `emitFlow`, a direct
140
+ * `serialize()`).
141
+ */
142
+ export declare function resolveSchemaVersion(policy: SchemaVersionPolicy, requested: string | undefined): string | undefined;
143
+ /**
144
+ * What a DECOMPILE should do with the version it just read.
145
+ *
146
+ * Preserving means re-declaring: emit `.schemaVersion(read)` so recompiling
147
+ * writes the version the file had, whatever this SDK's own default is today. It
148
+ * is deliberately emitted even when it equals the default — the point is that a
149
+ * later default bump must not silently upgrade a file that a decompile already
150
+ * captured.
151
+ *
152
+ * When the file declares a version this build cannot write, the honest output
153
+ * is neither a dropped version (today's silent downgrade) nor a call that
154
+ * `compile` would refuse: it is a report. `problem` carries it, for the source's
155
+ * `// TODO:` line and the CLI's stderr — the same shape as the other findings a
156
+ * decompile cannot encode in the chain (an unreachable node, a core version this
157
+ * SDK does not bundle).
158
+ */
159
+ export interface SchemaVersionPreservation {
160
+ /** The builder call to emit, or `undefined` when there is nothing to declare. */
161
+ call?: string;
162
+ /** What could not be preserved, for a `// TODO:` line and stderr. */
163
+ problem?: string;
164
+ }
165
+ export declare function preserveSchemaVersion(policy: SchemaVersionPolicy, declared: unknown): SchemaVersionPreservation;
@@ -0,0 +1,148 @@
1
+ /**
2
+ * schema-version — the artifact's FILE-FORMAT version, as something an author
3
+ * can declare and a decompile can PRESERVE.
4
+ *
5
+ * Every artifact family this SDK writes carries a version that describes the
6
+ * DOCUMENT's grammar rather than the author's release: Flow's top-level
7
+ * `version`, Case's top-level `version`, BPMN's `uipath:migrationVersion`. Until
8
+ * now each family pinned exactly one value in its serializer's format profile
9
+ * and overwrote whatever the input said, which is right for greenfield
10
+ * authoring and wrong for the brownfield loop:
11
+ *
12
+ * decompile(a 1.10 flow) -> compile -> a 1.9 flow, with nothing said.
13
+ *
14
+ * That silent rewrite is the hole this module closes. `.schemaVersion(v)` on
15
+ * each builder declares the version the emitted document targets, decompile
16
+ * emits the call so a round-trip re-declares what it read, and the serializer
17
+ * writes what was declared instead of the pin.
18
+ *
19
+ * ## A declared version is a CLAIM, not a switch
20
+ *
21
+ * The rule that shapes this whole module is the one CASE_PARITY §3.8 states for
22
+ * `.version()`: a document's version asserts that the whole document matches
23
+ * that schema. An author writing `.version('30.0.0')` against the old
24
+ * V20-emitting serializer produced an INVALID document, because the claim was
25
+ * false. So `.schemaVersion()` accepts only versions this SDK can actually
26
+ * write — {@link SchemaVersionPolicy.writable}, each row carrying the evidence
27
+ * that says so — and refuses anything else rather than stamping a claim it
28
+ * cannot back. Moving a document BETWEEN versions stays the product's job
29
+ * (`uip maestro flow migrate`), because a hop can carry data repairs this SDK
30
+ * has no way to reproduce.
31
+ *
32
+ * ## Comparing versions
33
+ *
34
+ * `'1.10' < '1.9'` as strings, which is exactly the wrong answer, and the same
35
+ * trap sits in Case's `'30.0.0'` vs `'9.0.0'`. Nothing here compares version
36
+ * strings with `<`; {@link compareSchemaVersions} splits on `.` and compares
37
+ * segments numerically, and every gate goes through it.
38
+ */
39
+ /** A version string the schema families use: dotted, numeric, e.g. `1.9`, `1.10`, `30.0.0`. */
40
+ const SYNTAX = /^\d+(\.\d+)*$/;
41
+ /** True when `value` is shaped like a schema version at all. */
42
+ export function isSchemaVersionSyntax(value) {
43
+ return typeof value === 'string' && SYNTAX.test(value);
44
+ }
45
+ /**
46
+ * Compare two dotted-numeric versions SEGMENT BY SEGMENT: negative when `a` is
47
+ * older, 0 when equal, positive when `a` is newer. A missing segment reads as
48
+ * `0`, so `'1.9'` and `'1.9.0'` compare equal.
49
+ *
50
+ * Throws on a non-version string rather than guessing, because a silent 0 here
51
+ * would make every gate answer "equal" for garbage input.
52
+ */
53
+ export function compareSchemaVersions(a, b) {
54
+ if (!isSchemaVersionSyntax(a) || !isSchemaVersionSyntax(b)) {
55
+ throw new Error(`compareSchemaVersions: "${a}" / "${b}" is not a dotted-numeric schema version.`);
56
+ }
57
+ const left = a.split('.').map(Number);
58
+ const right = b.split('.').map(Number);
59
+ for (let i = 0; i < Math.max(left.length, right.length); i++) {
60
+ const diff = (left[i] ?? 0) - (right[i] ?? 0);
61
+ if (diff !== 0)
62
+ return diff < 0 ? -1 : 1;
63
+ }
64
+ return 0;
65
+ }
66
+ /** True when `version` is `floor` or newer. The gate every version-conditional step uses. */
67
+ export function schemaVersionAtLeast(version, floor) {
68
+ return compareSchemaVersions(version, floor) >= 0;
69
+ }
70
+ /** The writable versions, oldest first. */
71
+ export function writableSchemaVersions(policy) {
72
+ return policy.writable.map((w) => w.version).sort(compareSchemaVersions);
73
+ }
74
+ /**
75
+ * True when this build can write `version` for `policy`.
76
+ *
77
+ * A `'verbatim'` family accepts any non-empty stamp, because the SDK copies it
78
+ * through without varying a byte of its emission — refusing an unfamiliar value
79
+ * there would DROP a stamp the platform wrote, which is the loss this whole
80
+ * module exists to stop. Only an empty one is refused, and that is a product
81
+ * rule: an empty `uipath:migrationVersion` fails validation outright, so absent
82
+ * beats blank.
83
+ */
84
+ export function isWritableSchemaVersion(policy, version) {
85
+ if (policy.mode === 'verbatim')
86
+ return typeof version === 'string' && version.trim() !== '';
87
+ return policy.writable.some((w) => w.version === version);
88
+ }
89
+ /**
90
+ * Why `requested` cannot be declared, or `undefined` when it can.
91
+ *
92
+ * One message text, shared by the builder's own refusal, `check()`'s
93
+ * diagnostic and the serializer's throw, so an author who hits it in three
94
+ * places reads the same sentence three times instead of three near-misses.
95
+ */
96
+ export function schemaVersionRefusal(policy, requested) {
97
+ const { method, family } = policy;
98
+ if (typeof requested !== 'string' || requested.trim() === '') {
99
+ return `${method}() needs a version string, e.g. ${method}("${policy.default ?? '1.0'}").`;
100
+ }
101
+ if (policy.mode === 'verbatim')
102
+ return undefined;
103
+ if (!isSchemaVersionSyntax(requested)) {
104
+ return `${method}("${requested}") is not a ${family} schema version — those are dotted and numeric, e.g. "${policy.default ?? '1.0'}".`;
105
+ }
106
+ if (isWritableSchemaVersion(policy, requested))
107
+ return undefined;
108
+ const writable = writableSchemaVersions(policy);
109
+ const newest = writable[writable.length - 1];
110
+ const direction = policy.latestKnown !== undefined && schemaVersionAtLeast(requested, policy.latestKnown)
111
+ ? compareSchemaVersions(requested, policy.latestKnown) > 0
112
+ ? `The platform's newest known ${family} schema version is ${policy.latestKnown}, so ${requested} is newer than anything this SDK has read.`
113
+ : `${requested} is the platform's current ${family} schema version, but this SDK build has not been taught to write it.`
114
+ : `${requested} is older than the ${writable.length === 1 ? 'one version' : 'versions'} this build writes.`;
115
+ return (`${method}("${requested}"): this SDK build writes ${family} schema ${writable.join(' / ')}. ${direction} `
116
+ + `A document's version claims that the WHOLE document matches that schema, so declaring one this build cannot emit `
117
+ + `would write a false claim rather than a different document. ${policy.migration}`);
118
+ }
119
+ /**
120
+ * The version an artifact declares: the author's when they declared one, else
121
+ * the policy default. Throws the shared refusal when it cannot be honoured —
122
+ * called from the serializer, which must not write a claim it cannot back even
123
+ * when `check()` was skipped (`compile --no-check`, `emitFlow`, a direct
124
+ * `serialize()`).
125
+ */
126
+ export function resolveSchemaVersion(policy, requested) {
127
+ if (requested === undefined)
128
+ return policy.default;
129
+ const refusal = schemaVersionRefusal(policy, requested);
130
+ if (refusal)
131
+ throw new Error(refusal);
132
+ return requested;
133
+ }
134
+ export function preserveSchemaVersion(policy, declared) {
135
+ if (declared === undefined || declared === null || declared === '')
136
+ return {};
137
+ const version = String(declared);
138
+ if (isWritableSchemaVersion(policy, version)) {
139
+ return { call: `${policy.method}(${JSON.stringify(version)})` };
140
+ }
141
+ const writes = policy.default ?? writableSchemaVersions(policy)[0] ?? 'nothing';
142
+ return {
143
+ problem: `the file declares ${policy.family} schema version ${JSON.stringify(version)}, which this SDK build cannot write, `
144
+ + `so this source does not re-declare it and recompiling writes ${JSON.stringify(String(writes))} instead. `
145
+ + `${policy.migration} Until then, merge the recompiled graph back into the ORIGINAL file, which keeps its own `
146
+ + `declared version.`,
147
+ };
148
+ }
@@ -0,0 +1,64 @@
1
+ import type { BuiltFlow } from './flow-sdk.js';
2
+ import type { Library, ResolvedConnector } from './library.js';
3
+ import type { Bindings } from './bindings.js';
4
+ import { type LookupResolutions, type LookupSpec } from './core/lookups.js';
5
+ /**
6
+ * A compile-time observation that does not stop emission. `check()` has its
7
+ * diagnostics; this is the serializer's own channel for things it can only see
8
+ * once bindings are in hand — today, a connection or folder value that can never
9
+ * be a tenant resource key (`CONNECTION_STUB`).
10
+ */
11
+ export interface SerializeWarning {
12
+ code: string;
13
+ message: string;
14
+ }
15
+ export interface SerializeOpts {
16
+ library?: Library;
17
+ bindings?: Bindings;
18
+ /**
19
+ * Receives each {@link SerializeWarning}. `compile-cli` prints them as
20
+ * `⚠ [CODE] …` after `check()`'s diagnostics; a caller that passes nothing
21
+ * hears nothing, which keeps `serialize()` silent in tests and libraries.
22
+ */
23
+ warn?: (warning: SerializeWarning) => void;
24
+ /**
25
+ * Filled in by `serialize` with the extra files the flow needs beside the
26
+ * `.flow`, relative to it. Today that is one `<source>/agent.json` per inline
27
+ * agent: the node points at that directory and the platform resolves the agent's
28
+ * real configuration there, so a `.flow` shipped without it references a
29
+ * definition that is not on disk.
30
+ *
31
+ * An out-parameter rather than a second return value so no caller that ignores
32
+ * sidecars has to change — but a caller that WRITES the flow has to write these
33
+ * too, which is why `compile-cli` does. `serializeWithSidecars` is the convenient
34
+ * form.
35
+ */
36
+ sidecars?: Array<{
37
+ path: string;
38
+ json: unknown;
39
+ }>;
40
+ }
41
+ /**
42
+ * `serialize`, plus the extra files the flow needs on disk beside it.
43
+ *
44
+ * Use this rather than `serialize` when you are about to WRITE the flow: an inline
45
+ * agent is two artifacts (the node and its `<source>/agent.json`), and a caller that
46
+ * writes only the first emits a flow whose agent definition is missing.
47
+ */
48
+ export declare function serializeWithSidecars(built: BuiltFlow, opts?: SerializeOpts): {
49
+ flow: any;
50
+ sidecars: Array<{
51
+ path: string;
52
+ json: unknown;
53
+ }>;
54
+ };
55
+ export declare function serialize(built: BuiltFlow, opts?: SerializeOpts): any;
56
+ /**
57
+ * What `compile` would refuse these connector inputs with, or `undefined` when it
58
+ * would accept them — the SAME code path `buildConnectorInputs` runs at emit time,
59
+ * so `check` and `compile` cannot disagree about a missing required field, an
60
+ * unknown or mistyped input, or a container part passed as a value. Unresolved
61
+ * lookups are the one thing skipped: `check` already reports them as
62
+ * LOOKUP_UNRESOLVED with the resolution recipe.
63
+ */
64
+ export declare function connectorInputErrors(rc: ResolvedConnector, inputs: Record<string, unknown>, resolutions?: LookupResolutions, lookups?: Readonly<Record<string, LookupSpec>>): string | undefined;