@uipath/case-tool 1.203.0-preview.205 → 1.204.0-preview.206

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 (85) hide show
  1. package/README.md +6 -1
  2. package/dist/THIRD-PARTY-NOTICES.md +48 -9
  3. package/dist/authoring-0hr88kff.js +623 -0
  4. package/dist/{case-api-v6cjyrfw.js → case-api-gdaj9469.js} +5 -5
  5. package/dist/case-bindings-service-c2mze9vj.js +476 -0
  6. package/dist/{case-debug-studio-web-service-shg84pn8.js → case-debug-studio-web-service-cc0vj7md.js} +11 -10
  7. package/dist/case-described-io-service-cpe5h2ks.js +132 -0
  8. package/dist/{case-format-service-q345a2fd.js → case-format-service-qwyjyt0y.js} +2 -2
  9. package/dist/{case-pack-service-29rza2q2.js → case-pack-service-47yrvmg0.js} +11 -11
  10. package/dist/case-shape-reader-mw58avr0.js +13 -0
  11. package/dist/case-splice-service-9zvw19ca.js +312 -0
  12. package/dist/{case-validate-service-2n2bqc1g.js → case-validate-service-vrvx19c1.js} +415 -1449
  13. package/dist/{connector-enrichment-service-h662r92z.js → connector-enrichment-service-rg87npf0.js} +20 -18
  14. package/dist/{connector-lookup-service-y7x6xsc6.js → connector-lookup-service-c49pvfwb.js} +7 -7
  15. package/dist/{connector-task-spec-qm6q8qma.js → connector-task-spec-t3tjeeqt.js} +86 -26
  16. package/dist/{debug-service-8x087xxt.js → debug-service-vf5mw0nr.js} +3 -3
  17. package/dist/{embedded-file-reader-0sjt4nkj.js → embedded-file-reader-v8c2yj2a.js} +2 -2
  18. package/dist/{enrichment-service-7vbxcwge.js → enrichment-service-78b0gqck.js} +8 -7
  19. package/dist/index-hhsf00x8.js +15 -0
  20. package/dist/{index-fz4ttsde.js → index-j2r3jb6c.js} +5 -3
  21. package/dist/{index-jxj2jz45.js → index-rgw7caht.js} +416 -87
  22. package/dist/{index-k4xz16db.js → index-wmffgzmr.js} +12522 -7316
  23. package/dist/{index-va9sm89y.js → index-ynnr55wk.js} +59 -27
  24. package/dist/index.js +15 -11
  25. package/dist/{input-reader-pnh948bq.js → input-reader-bb0ptk2v.js} +2 -2
  26. package/dist/migration-diagnosis-ag2sgd1e.js +71 -0
  27. package/dist/{node-strategy-gc4sg6a2.js → node-strategy-5pz40tee.js} +1 -1
  28. package/dist/{node-sync-service-mehbp4qq.js → node-sync-service-xw3tpfj5.js} +6 -6
  29. package/dist/out-target-1f4n9vqb.js +70 -0
  30. package/dist/{packager-tool-wefb1zw3.js → packager-tool-0p3td5zv.js} +8 -7
  31. package/dist/packager-tool-21qfsbxn.js +17 -0
  32. package/dist/{strict-sdd-audit-8e2fh9jg.js → packager-tool-4e56rmwe.js} +2771 -1746
  33. package/dist/{packager-tool-sfkyb4kz.js → packager-tool-4rqd21wc.js} +194 -2
  34. package/dist/packager-tool-57pzrd0g.js +32 -0
  35. package/dist/{packager-tool-kpcjnxd1.js → packager-tool-58kx79ta.js} +586 -113
  36. package/dist/{packager-tool-hrdan5ms.js → packager-tool-5qghkdd0.js} +2 -2
  37. package/dist/packager-tool-5qp9xza1.js +10 -0
  38. package/dist/packager-tool-8a9yqfq7.js +76 -0
  39. package/dist/{packager-tool-40vq60aa.js → packager-tool-8mpxsyje.js} +4 -4
  40. package/dist/{packager-tool-e3k5gzd3.js → packager-tool-a6wztj6y.js} +669 -100
  41. package/dist/{packager-tool-p0zh9hw6.js → packager-tool-ayevyw80.js} +5 -5
  42. package/dist/packager-tool-b250k6w4.js +75 -0
  43. package/dist/packager-tool-bfgdz1zh.js +73 -0
  44. package/dist/{packager-tool-p7jgrm5r.js → packager-tool-cmwets3m.js} +1 -1
  45. package/dist/{packager-tool-d4sjk46c.js → packager-tool-cv05dwac.js} +18 -21
  46. package/dist/packager-tool-d7jjng8a.js +21 -0
  47. package/dist/packager-tool-dthjwajc.js +13 -0
  48. package/dist/{packager-tool-zcsm7dsj.js → packager-tool-e760vtgg.js} +4 -4
  49. package/dist/packager-tool-f78ntj5g.js +228 -0
  50. package/dist/{packager-tool-2xfyykm0.js → packager-tool-ggbvxvey.js} +320 -200
  51. package/dist/{packager-tool-6karkrc8.js → packager-tool-jx0yq0b5.js} +6 -6
  52. package/dist/{packager-tool-cg2j4rma.js → packager-tool-kacqd7h7.js} +4 -4
  53. package/dist/packager-tool-mknccck5.js +24 -0
  54. package/dist/{packager-tool-sv0d6wb6.js → packager-tool-nj4seavy.js} +7 -3
  55. package/dist/{packager-tool-adcaxdhs.js → packager-tool-paepfv5d.js} +1 -1
  56. package/dist/{packager-tool-052kvydg.js → packager-tool-pm646ag4.js} +1 -1
  57. package/dist/{packager-tool-dd8bq6az.js → packager-tool-rgpdaxbx.js} +548 -108
  58. package/dist/{packager-tool-8q7vzh65.js → packager-tool-s3e2kepj.js} +455 -13
  59. package/dist/{packager-tool-r84ng21s.js → packager-tool-sag9gz55.js} +3 -1
  60. package/dist/{packager-tool-0mj06yen.js → packager-tool-sq931c23.js} +5 -22
  61. package/dist/{packager-tool-yrsrzz1a.js → packager-tool-v99ygh9f.js} +23 -8
  62. package/dist/packager-tool-wj9d9mqe.js +267 -0
  63. package/dist/{packager-tool-hz1mz8fs.js → packager-tool-wjaya2k2.js} +2 -2
  64. package/dist/packager-tool-xcd87qyx.js +44 -0
  65. package/dist/{packager-tool-0v3s8r01.js → packager-tool-xdxr3ync.js} +4 -2
  66. package/dist/{packager-tool-61hxhgeg.js → packager-tool-xkgq5fkf.js} +3 -3
  67. package/dist/packager-tool.js +6 -6
  68. package/dist/{project-artifacts-8snev67g.js → project-artifacts-wzrhketn.js} +1 -1
  69. package/dist/resolved-check-p99hysaw.js +50 -0
  70. package/dist/{resourcesSyncService-pmfwz9cd.js → resourcesSyncService-1ezvhcbc.js} +25 -18
  71. package/dist/rule-group-members-zje7n3kf.js +76 -0
  72. package/dist/sdd-convert-service-gp9733qv.js +1962 -0
  73. package/dist/{sdd-lookup-x08j9g9m.js → sdd-lookup-vpjej1kt.js} +2 -2
  74. package/dist/sdd-resolve-service-4hx64x3z.js +288 -0
  75. package/dist/strict-case-rules-ksy8q7pg.js +731 -0
  76. package/dist/strict-entry-points-v14d7y50.js +124 -0
  77. package/dist/strict-sdd-audit-k6hh0mbr.js +23 -0
  78. package/dist/task-selector-8bjn35dv.js +57 -0
  79. package/dist/tool.js +15 -11
  80. package/dist/{trigger-enrichment-service-xexg7qbk.js → trigger-enrichment-service-pjw5ysny.js} +41 -23
  81. package/package.json +2 -2
  82. package/dist/authoring-kngaggwm.js +0 -360
  83. package/dist/case-bindings-service-1wxfghzd.js +0 -240
  84. package/dist/packager-tool-83qnybab.js +0 -1564
  85. package/dist/strict-case-rules-x6t0vb40.js +0 -409
@@ -1,360 +0,0 @@
1
- import {
2
- resolveMaestroRegistry
3
- } from "./packager-tool-hrdan5ms.js";
4
- import {
5
- OutputFormatter,
6
- RESULTS,
7
- getOutputFormat,
8
- getOutputFormatExplicit,
9
- processContext
10
- } from "./packager-tool-kpcjnxd1.js";
11
- import {
12
- getFileSystem
13
- } from "./packager-tool-0v3s8r01.js";
14
- import"./packager-tool-1yh8g550.js";
15
-
16
- // ../builder-sdk/src/argv.ts
17
- function addValue(argv, flag, value) {
18
- if (typeof value === "string") {
19
- argv.push(flag, value);
20
- }
21
- }
22
-
23
- // ../builder-sdk/src/delegate.ts
24
- import { spawn } from "node:child_process";
25
- import { createRequire } from "node:module";
26
- var FLOW_SDK_PACKAGES = [
27
- { name: "@uipath/maestro-builder-sdk", minimumVersion: "4.0.0" },
28
- { name: "@uipath/flow-sdk", minimumVersion: "1.1.0" }
29
- ];
30
- function commandLabel(family, verb) {
31
- return `uip maestro ${family} ${verb}`;
32
- }
33
- function fail(message, instructions) {
34
- OutputFormatter.error({
35
- Result: RESULTS.Failure,
36
- Message: message,
37
- Instructions: instructions
38
- });
39
- return 1;
40
- }
41
- function parseVersion(version) {
42
- const match = /^(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version);
43
- if (!match)
44
- return null;
45
- return [
46
- Number(match[1]),
47
- Number(match[2]),
48
- Number(match[3]),
49
- match[4] !== undefined
50
- ];
51
- }
52
- function versionMeetsFloor(version, floor) {
53
- const installed = parseVersion(version);
54
- const minimum = parseVersion(floor);
55
- if (!installed || !minimum)
56
- return false;
57
- for (let index = 0;index < 3; index++) {
58
- if (installed[index] !== minimum[index]) {
59
- return installed[index] > minimum[index];
60
- }
61
- }
62
- return !installed[3] || minimum[3];
63
- }
64
- async function runChild(cliPath, args, cwd, label) {
65
- return await new Promise((resolve) => {
66
- const child = spawn("node", [cliPath, ...args], {
67
- cwd,
68
- env: process.env,
69
- stdio: "inherit"
70
- });
71
- child.once("error", (error) => {
72
- resolve(fail(`${label}: ${error.message}`, "Check that node is on PATH, then retry."));
73
- });
74
- child.once("exit", (code, signal) => {
75
- if (code !== null) {
76
- resolve(code);
77
- return;
78
- }
79
- resolve(fail(`${label}: SDK process ended with signal ${signal ?? "unknown"}.`, "Retry the command."));
80
- });
81
- });
82
- }
83
- function upgradeInstructions() {
84
- const [current, legacy] = FLOW_SDK_PACKAGES;
85
- return `npm install --save-dev ${current.name}` + ` (the previous name ${legacy.name} also works and needs an .npmrc` + ` routing @uipath to https://npm.pkg.github.com/).`;
86
- }
87
- async function resolveFlowSdk(workspace, label) {
88
- const fs = getFileSystem();
89
- const require2 = createRequire(import.meta.url);
90
- let firstFailure;
91
- for (const candidate of FLOW_SDK_PACKAGES) {
92
- let packagePath;
93
- try {
94
- packagePath = require2.resolve(`${candidate.name}/package.json`, {
95
- paths: [workspace]
96
- });
97
- } catch {
98
- continue;
99
- }
100
- const packageText = await fs.readFile(packagePath, "utf-8");
101
- if (packageText === null) {
102
- firstFailure ??= {
103
- ok: false,
104
- message: `${label}: could not read ${packagePath}.`,
105
- instructions: `Reinstall ${candidate.name}, then retry.`
106
- };
107
- continue;
108
- }
109
- let version = "";
110
- let bin = {};
111
- try {
112
- const parsed = JSON.parse(packageText);
113
- version = typeof parsed.version === "string" ? parsed.version : "";
114
- if (parsed.bin && typeof parsed.bin === "object") {
115
- for (const [name, target] of Object.entries(parsed.bin)) {
116
- if (typeof target === "string")
117
- bin[name] = target;
118
- }
119
- }
120
- } catch {
121
- version = "";
122
- bin = {};
123
- }
124
- if (!versionMeetsFloor(version, candidate.minimumVersion)) {
125
- firstFailure ??= {
126
- ok: false,
127
- message: `${label}: found ${candidate.name} ${version || "with no valid version"}; need >= ${candidate.minimumVersion}.`,
128
- instructions: upgradeInstructions()
129
- };
130
- continue;
131
- }
132
- return {
133
- ok: true,
134
- packageDir: fs.path.dirname(packagePath),
135
- version,
136
- bin
137
- };
138
- }
139
- return firstFailure ?? {
140
- ok: false,
141
- message: `${label}: ${FLOW_SDK_PACKAGES[0].name} is not installed in this workspace.`,
142
- instructions: upgradeInstructions()
143
- };
144
- }
145
- async function delegateToFlowSdk({
146
- family,
147
- commandVerb,
148
- sdkVerb = commandVerb,
149
- argv,
150
- cwd,
151
- requiresSdkBin
152
- }) {
153
- const fs = getFileSystem();
154
- const workspace = cwd ?? fs.env.cwd();
155
- const label = commandLabel(family, commandVerb);
156
- const resolution = await resolveFlowSdk(workspace, label);
157
- if (!resolution.ok) {
158
- return fail(resolution.message, resolution.instructions);
159
- }
160
- if (requiresSdkBin && !(requiresSdkBin in resolution.bin)) {
161
- return fail(`${label}: the installed builder SDK (${resolution.version}) does not provide this command.`, upgradeInstructions());
162
- }
163
- const cliPath = fs.path.join(resolution.packageDir, "dist", "cli", "index.js");
164
- return await runChild(cliPath, [family, sdkVerb, ...argv], workspace, label);
165
- }
166
-
167
- // ../builder-sdk/src/examples.ts
168
- function sdkCliExample(description, command, message) {
169
- return [
170
- {
171
- Description: description,
172
- Command: command,
173
- Output: {
174
- Code: "SdkCliOutput",
175
- Data: { Message: message }
176
- }
177
- }
178
- ];
179
- }
180
-
181
- // ../builder-sdk/src/library-option.ts
182
- async function resolveLibraryOption(explicit) {
183
- if (explicit !== undefined)
184
- return explicit;
185
- if (getFileSystem().env.getenv("FLOW_SDK_LIBRARY_JSON"))
186
- return;
187
- const registry = await resolveMaestroRegistry();
188
- return registry?.libraryJson;
189
- }
190
-
191
- // ../builder-sdk/src/commands/check.ts
192
- var CHECK_EXAMPLES = {
193
- flow: { input: "Order.flow.ts", message: "✓ no issues" },
194
- case: { input: "Claims.case.ts", message: "check: OK" },
195
- bpmn: { input: "Approval.bpmn.ts", message: "check: ok." }
196
- };
197
- var registerCheckCommand = (program, family) => {
198
- const command = program.previewCommand("check <input>").description("Run the authoring-time SDK analyzer on source or an artifact.").option("--source", "Check authored TypeScript").option("--compiled", "Check the compiled artifact");
199
- if (family === "flow") {
200
- command.option("--library <dir>", "Connector library directory (defaults to $FLOW_SDK_LIBRARY_JSON, else the pulled library)").option("--json", "Print compiled-check diagnostics as JSON").option("--uip", "Resolve missing schemas with the UiPath CLI").option("--max-errors <count>", "Stop after this many compiled-check errors").option("--script-determinism", "Check script blocks for non-deterministic calls").option("--quiet", "Suppress warnings and information");
201
- }
202
- const example = CHECK_EXAMPLES[family];
203
- command.examples(sdkCliExample(`Check a ${family} source file before compiling it`, `uip maestro ${family} check ${example.input} --source`, example.message)).trackedAction(processContext, async (input, options) => {
204
- const argv = [input];
205
- if (options.source)
206
- argv.push("--source");
207
- if (options.compiled)
208
- argv.push("--compiled");
209
- addValue(argv, "--library", await resolveLibraryOption(options.library));
210
- if (options.json || getOutputFormatExplicit() && getOutputFormat() === "json")
211
- argv.push("--json");
212
- if (options.uip)
213
- argv.push("--uip");
214
- addValue(argv, "--max-errors", options.maxErrors);
215
- if (options.scriptDeterminism)
216
- argv.push("--script-determinism");
217
- if (options.quiet)
218
- argv.push("--quiet");
219
- const code = await delegateToFlowSdk({
220
- family,
221
- commandVerb: "check",
222
- argv
223
- });
224
- if (code !== 0)
225
- processContext.exit(code);
226
- });
227
- };
228
- // ../builder-sdk/src/commands/compile.ts
229
- var COMPILE_EXAMPLES = {
230
- flow: {
231
- source: "Order.flow.ts",
232
- output: "Order.flow",
233
- message: "compile: wrote Order.flow (3 nodes, 2 edges)"
234
- },
235
- case: {
236
- source: "Claims.case.ts",
237
- output: "caseplan.json",
238
- message: "compile: wrote caseplan.json (3 stage(s))"
239
- },
240
- bpmn: {
241
- source: "Approval.bpmn.ts",
242
- output: "Approval.bpmn",
243
- message: "compile: wrote Approval.bpmn (4 element(s))"
244
- }
245
- };
246
- var registerCompileCommand = (program, family) => {
247
- const command = program.previewCommand("compile <source>").description(`Compile authored TypeScript to a ${family} artifact.`).option("-o, --output <file>", "Output artifact path").option("--library <dir>", "Connector library directory (defaults to the pulled registry)").option("--bindings <file>", "bindings.json path");
248
- if (family !== "bpmn") {
249
- command.option("--connectors-local <dir>", "Connection-resolved connector overlay");
250
- }
251
- if (family === "flow") {
252
- command.option("--no-check", "Skip the source-level check");
253
- }
254
- const example = COMPILE_EXAMPLES[family];
255
- command.examples(sdkCliExample(`Compile a ${family} source file to an artifact`, `uip maestro ${family} compile ${example.source} --output ${example.output}`, example.message)).trackedAction(processContext, async (source, options) => {
256
- const argv = [source];
257
- addValue(argv, "-o", options.output);
258
- addValue(argv, "--library", await resolveLibraryOption(options.library));
259
- addValue(argv, "--bindings", options.bindings);
260
- addValue(argv, "--connectors-local", options.connectorsLocal);
261
- if (options.check === false)
262
- argv.push("--no-check");
263
- const code = await delegateToFlowSdk({
264
- family,
265
- commandVerb: "compile",
266
- argv
267
- });
268
- if (code !== 0)
269
- processContext.exit(code);
270
- });
271
- };
272
- // ../builder-sdk/src/commands/decompile.ts
273
- var DECOMPILE_EXAMPLES = {
274
- flow: {
275
- input: "Order.flow",
276
- output: "Order.flow.ts",
277
- message: "flow-decompile: wrote Order.flow.ts"
278
- },
279
- case: {
280
- input: "caseplan.json",
281
- output: "Claims.case.ts",
282
- message: "decompile: wrote Claims.case.ts"
283
- }
284
- };
285
- var registerDecompileCommand = (program, family) => {
286
- const command = program.previewCommand("decompile <input>").description(`Convert a ${family === "flow" ? ".flow" : "caseplan.json"} artifact to authored TypeScript.`).option("-o, --output <file>", `Output ${family === "flow" ? ".flow.ts" : ".case.ts"} path`).option("--import <specifier>", "SDK import specifier in generated source");
287
- if (family === "flow") {
288
- command.option("--strict", "Fail on unsupported constructs");
289
- } else {
290
- command.option("--library <dir>", "Connector library directory (defaults to the pulled registry)").option("--best-effort", "Emit a marked repair scaffold for unsupported constructs");
291
- }
292
- command.option("--no-pipeline", "Do not emit a brownfield pipeline helper");
293
- const example = DECOMPILE_EXAMPLES[family];
294
- command.examples(sdkCliExample(`Convert a ${family} artifact back to authored TypeScript`, `uip maestro ${family} decompile ${example.input} --output ${example.output}`, example.message)).trackedAction(processContext, async (input, options) => {
295
- const argv = [input];
296
- addValue(argv, "-o", options.output);
297
- addValue(argv, "--import", options.import);
298
- if (family === "case") {
299
- addValue(argv, "--library", await resolveLibraryOption(options.library));
300
- }
301
- if (options.strict)
302
- argv.push("--strict");
303
- if (options.bestEffort)
304
- argv.push("--best-effort");
305
- if (options.pipeline === false)
306
- argv.push("--no-pipeline");
307
- const code = await delegateToFlowSdk({
308
- family,
309
- commandVerb: "decompile",
310
- argv
311
- });
312
- if (code !== 0)
313
- processContext.exit(code);
314
- });
315
- };
316
- // ../builder-sdk/src/commands/merge.ts
317
- var MERGE_EXAMPLES = {
318
- flow: {
319
- description: "Merge edited authored content into the original Flow artifact",
320
- command: "uip maestro flow merge Original.flow Edited.flow --output Merged.flow --baseline Baseline.flow",
321
- message: "flow-merge: wrote Merged.flow (3 nodes, 2 edges)"
322
- },
323
- case: {
324
- description: "Merge edited authored content into the original Case artifact",
325
- command: "uip maestro case merge original.caseplan.json edited.caseplan.json --output merged.caseplan.json",
326
- message: "case-merge: wrote merged.caseplan.json (3 stage(s))"
327
- }
328
- };
329
- var registerMergeCommand = (program, family) => {
330
- const command = program.previewCommand("merge <original> <edited>").description(`Merge an edited ${family} with its original artifact.`).option("-o, --output <file>", "Merged output path");
331
- if (family === "flow") {
332
- command.option("--baseline <file>", "Compiled pristine decompile");
333
- }
334
- const example = MERGE_EXAMPLES[family];
335
- command.examples(sdkCliExample(example.description, example.command, example.message)).trackedAction(processContext, async (original, edited, options) => {
336
- const argv = [original, edited];
337
- addValue(argv, "-o", options.output);
338
- addValue(argv, "--baseline", options.baseline);
339
- const code = await delegateToFlowSdk({
340
- family,
341
- commandVerb: "merge",
342
- argv,
343
- ...family === "case" ? { requiresSdkBin: "case-merge" } : {}
344
- });
345
- if (code !== 0)
346
- processContext.exit(code);
347
- });
348
- };
349
- // src/commands/authoring.ts
350
- var registerCaseAuthoringCommands = (program) => {
351
- registerCompileCommand(program, "case");
352
- registerCheckCommand(program, "case");
353
- registerDecompileCommand(program, "case");
354
- registerMergeCommand(program, "case");
355
- };
356
- export {
357
- registerCaseAuthoringCommands
358
- };
359
-
360
- //# debugId=5B5A575BDF4CDC1964756E2164756E21
@@ -1,240 +0,0 @@
1
- import {
2
- catchError
3
- } from "./packager-tool-kpcjnxd1.js";
4
- import {
5
- getFileSystem
6
- } from "./packager-tool-0v3s8r01.js";
7
- import"./packager-tool-1yh8g550.js";
8
-
9
- // src/services/bindings-v2.ts
10
- var BINDINGS_V2_FILE_NAME = "bindings_v2.json";
11
- var BINDINGS_V2_VERSION = "2.0";
12
- var CONNECTION_ID_PROPERTY = "ConnectionId";
13
- var FOLDER_KEY_PROPERTY = "folderKey";
14
- var byCodeUnit = (left, right) => {
15
- if (left < right)
16
- return -1;
17
- return left > right ? 1 : 0;
18
- };
19
- var sortBindingsV2Resources = (resources) => [...resources].sort((a, b) => byCodeUnit(a.resource, b.resource) || byCodeUnit(a.key, b.key));
20
- var serializeBindingsV2File = (resources) => {
21
- const file = {
22
- version: BINDINGS_V2_VERSION,
23
- resources: sortBindingsV2Resources(resources)
24
- };
25
- return `${JSON.stringify(file, null, 2)}
26
- `;
27
- };
28
- var readBindingsV2Resources = (raw) => {
29
- const [error, parsed] = catchError(() => JSON.parse(raw));
30
- if (error)
31
- return;
32
- if (parsed === null || typeof parsed !== "object")
33
- return;
34
- const resources = parsed.resources;
35
- if (!Array.isArray(resources))
36
- return;
37
- return resources.filter((entry) => entry !== null && typeof entry === "object" && typeof entry.key === "string");
38
- };
39
- var identity = (entry) => `${entry.resource}:${entry.key}`;
40
- var diffBindingsV2 = (expected, actual) => {
41
- const expectedByKey = new Map(expected.map((e) => [identity(e), e]));
42
- const actualByKey = new Map(actual.map((e) => [identity(e), e]));
43
- const missing = [];
44
- const changed = [];
45
- for (const [key, entry] of expectedByKey) {
46
- const found = actualByKey.get(key);
47
- if (found === undefined) {
48
- missing.push(entry.key);
49
- } else if (JSON.stringify(found) !== JSON.stringify(entry)) {
50
- changed.push(entry.key);
51
- }
52
- }
53
- const extra = [...actualByKey.values()].filter((entry) => !expectedByKey.has(identity(entry))).map((entry) => entry.key);
54
- const alphabetically = (left, right) => left.localeCompare(right);
55
- return {
56
- missing: missing.sort(alphabetically),
57
- extra: extra.sort(alphabetically),
58
- changed: changed.sort(alphabetically)
59
- };
60
- };
61
- var hasBindingsV2Difference = (difference) => difference.missing.length > 0 || difference.extra.length > 0 || difference.changed.length > 0;
62
-
63
- // src/services/case-bindings-service.ts
64
- var asBinding = (value) => {
65
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
66
- return;
67
- }
68
- const record = value;
69
- return typeof record.id === "string" && typeof record.resource === "string" && typeof record.resourceKey === "string" && record.resourceKey !== "" && typeof record.propertyAttribute === "string" && (record.default === undefined || typeof record.default === "string") ? value : undefined;
70
- };
71
- var CONNECTION_RESOURCE = "Connection";
72
- var NAME_ATTRIBUTE = "name";
73
- var FOLDER_PATH_ATTRIBUTE = "folderPath";
74
- var SOLUTION_FOLDER_PREFIX = "solution_folder.";
75
- var SOLUTION_FOLDER_SENTINEL = "solution_folder";
76
- var BINDING_REFERENCE_PREFIX = "=bindings.";
77
- var CONNECTOR_KEY_ENTRY = "connectorKey";
78
- var CONNECTION_ENTRY = "connection";
79
- var readConnectorContext = (value) => {
80
- if (!Array.isArray(value))
81
- return;
82
- const byName = new Map;
83
- for (const entry of value) {
84
- if (entry === null || typeof entry !== "object" || Array.isArray(entry))
85
- return;
86
- const { name, value: entryValue } = entry;
87
- if (typeof name !== "string")
88
- return;
89
- if (typeof entryValue === "string")
90
- byName.set(name, entryValue);
91
- }
92
- return byName.has(CONNECTOR_KEY_ENTRY) ? byName : undefined;
93
- };
94
- var collectConnectorKeys = (document) => {
95
- const byBindingId = new Map;
96
- const visit = (node) => {
97
- if (Array.isArray(node)) {
98
- const context = readConnectorContext(node);
99
- const connection = context?.get(CONNECTION_ENTRY);
100
- const connectorKey = context?.get(CONNECTOR_KEY_ENTRY);
101
- if (connectorKey !== undefined && connection?.startsWith(BINDING_REFERENCE_PREFIX) === true) {
102
- byBindingId.set(connection.slice(BINDING_REFERENCE_PREFIX.length), connectorKey);
103
- }
104
- for (const item of node)
105
- visit(item);
106
- return;
107
- }
108
- if (node === null || typeof node !== "object")
109
- return;
110
- for (const value of Object.values(node))
111
- visit(value);
112
- };
113
- visit(document);
114
- return byBindingId;
115
- };
116
- var attributeDefault = (group, attribute) => group.find((binding) => binding.propertyAttribute === attribute)?.default;
117
- var connectionEntry = (group, connectorKeys) => {
118
- const key = group[0].resourceKey;
119
- const value = {
120
- [CONNECTION_ID_PROPERTY]: {
121
- defaultValue: attributeDefault(group, CONNECTION_ID_PROPERTY) ?? key
122
- }
123
- };
124
- const folderKey = attributeDefault(group, FOLDER_KEY_PROPERTY);
125
- if (folderKey !== undefined) {
126
- value[FOLDER_KEY_PROPERTY] = { defaultValue: folderKey };
127
- }
128
- const connector = group.map((binding) => connectorKeys.get(binding.id)).find((found) => found !== undefined);
129
- return {
130
- resource: CONNECTION_RESOURCE,
131
- key,
132
- value,
133
- ...connector !== undefined && { metadata: { connector } }
134
- };
135
- };
136
- var resourceEntry = (group) => {
137
- const key = group[0].resourceKey;
138
- const value = {};
139
- const name = attributeDefault(group, NAME_ATTRIBUTE);
140
- if (name !== undefined)
141
- value.name = { defaultValue: name };
142
- const folderPath = key.startsWith(SOLUTION_FOLDER_PREFIX) ? SOLUTION_FOLDER_SENTINEL : attributeDefault(group, FOLDER_PATH_ATTRIBUTE);
143
- if (folderPath !== undefined) {
144
- value.folderPath = { defaultValue: folderPath };
145
- }
146
- const subType = group.find((binding) => binding.resourceSubType !== undefined)?.resourceSubType;
147
- return {
148
- resource: group[0].resource,
149
- key,
150
- value,
151
- ...subType !== undefined && { metadata: { subType } }
152
- };
153
- };
154
- var deriveCaseBindingsV2 = (document) => {
155
- const connectorKeys = collectConnectorKeys(document);
156
- const groups = new Map;
157
- for (const entry of Array.isArray(document.bindings) ? document.bindings : []) {
158
- const binding = asBinding(entry);
159
- if (binding === undefined)
160
- continue;
161
- const groupKey = `${binding.resource}:${binding.resourceKey}`;
162
- const group = groups.get(groupKey);
163
- if (group === undefined)
164
- groups.set(groupKey, [binding]);
165
- else
166
- group.push(binding);
167
- }
168
- return [...groups.values()].map((group) => group[0].resource === CONNECTION_RESOURCE ? connectionEntry(group, connectorKeys) : resourceEntry(group));
169
- };
170
- var bindingsV2PathFor = (casePlanPath) => {
171
- const fs = getFileSystem();
172
- return fs.path.join(fs.path.dirname(fs.path.resolve(casePlanPath)), BINDINGS_V2_FILE_NAME);
173
- };
174
- var compareCaseBindingsV2 = async (casePlanPath, document) => {
175
- const fs = getFileSystem();
176
- const path = bindingsV2PathFor(casePlanPath);
177
- const expected = deriveCaseBindingsV2(document);
178
- const expectedCount = expected.length;
179
- if (!await fs.exists(path))
180
- return { status: "absent", path, expectedCount };
181
- const [readError, raw] = await catchError(fs.readFile(path, "utf-8"));
182
- if (readError || raw == null)
183
- return { status: "unreadable", path, expectedCount };
184
- const actual = readBindingsV2Resources(raw);
185
- if (actual === undefined)
186
- return { status: "unreadable", path, expectedCount };
187
- const difference = diffBindingsV2(expected, actual);
188
- return hasBindingsV2Difference(difference) ? { status: "differs", path, expectedCount, difference } : { status: "match", path, expectedCount };
189
- };
190
- var syncCaseBindings = async (casePlanPath) => {
191
- const fs = getFileSystem();
192
- const resolved = fs.path.resolve(casePlanPath);
193
- if (!await fs.exists(resolved)) {
194
- return {
195
- ok: false,
196
- message: `Case plan file not found: ${resolved}`,
197
- instructions: "Pass the path to an existing caseplan JSON file, for example 'uip maestro case bindings sync case.json'."
198
- };
199
- }
200
- const [readError, raw] = await catchError(fs.readFile(resolved, "utf-8"));
201
- if (readError || raw == null) {
202
- return {
203
- ok: false,
204
- message: `Failed to read case plan: ${readError?.message ?? "empty content"}`,
205
- instructions: `Verify read permissions on ${resolved}.`
206
- };
207
- }
208
- const [parseError, document] = catchError(() => JSON.parse(raw));
209
- if (parseError || document == null || typeof document !== "object" || Array.isArray(document)) {
210
- return {
211
- ok: false,
212
- message: `Case plan is not valid JSON: ${parseError?.message ?? "not a JSON object"}`,
213
- instructions: `Verify the contents of ${resolved}.`
214
- };
215
- }
216
- const resources = deriveCaseBindingsV2(document);
217
- const path = bindingsV2PathFor(resolved);
218
- const [writeError] = await catchError(fs.writeFile(path, serializeBindingsV2File(resources)));
219
- if (writeError) {
220
- return {
221
- ok: false,
222
- message: `Failed to write bindings file: ${writeError.message}`,
223
- instructions: `Verify write permissions on ${fs.path.dirname(path)}.`
224
- };
225
- }
226
- return {
227
- ok: true,
228
- path,
229
- resourceCount: resources.length,
230
- connectionCount: resources.filter((entry) => entry.resource === CONNECTION_RESOURCE).length
231
- };
232
- };
233
- export {
234
- bindingsV2PathFor,
235
- compareCaseBindingsV2,
236
- deriveCaseBindingsV2,
237
- syncCaseBindings
238
- };
239
-
240
- //# debugId=45E172EC16BB003D64756E2164756E21