@uipath/rules-tool 1.204.0-preview.249 → 1.204.0-preview.254

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 (154) hide show
  1. package/dist/DmnFactory-VWZOSZHH-jkpbxz3n.js +42 -0
  2. package/dist/DmnModelTypes-ATR7FVKZ-jp35cecy.js +18 -0
  3. package/dist/KieDmnMarshaller-6TTUU5B4-47q50gk4.js +20 -0
  4. package/dist/THIRD-PARTY-NOTICES.md +1085 -0
  5. package/dist/business-rules-bnr581tz.js +26 -0
  6. package/dist/{constants-za5vbzp8.js → constants-9pa118cj.js} +17 -10
  7. package/dist/{embedded-file-reader-wmsg31a8.js → embedded-file-reader-rf2g1kfj.js} +4 -1
  8. package/dist/first-party-service-sd8yaf73.js +27 -0
  9. package/dist/hitPolicyResult-4WDHTX4A-gk103w84.js +33 -0
  10. package/dist/index-2hzp9b97.js +116 -0
  11. package/dist/index-34pj9f36.js +48 -0
  12. package/dist/{index-zdwhfpt1.js → index-4c4exdzw.js} +370 -406
  13. package/dist/index-dqa169gp.js +25 -0
  14. package/dist/{index-we6zjs66.js → index-fs1nd5ap.js} +40 -4
  15. package/dist/{index-nzr4mx5p.js → index-sby22td6.js} +22 -2
  16. package/dist/{index-7wc0g78k.js → index-t4mx1a5e.js} +5 -2
  17. package/dist/index.js +9 -8
  18. package/dist/{jmespath-ab6tdc42.js → jmespath-231m3hyn.js} +1 -1
  19. package/dist/{js-yaml-a2bk27p6.js → js-yaml-88tdqrtd.js} +3 -1
  20. package/dist/rule-catalog-5gzpe93c.js +46 -0
  21. package/dist/rules-command-error-20gp2dv9.js +14 -0
  22. package/dist/{rules-debug-service-h1ahd6p3.js → rules-debug-service-yvh448xp.js} +36 -35
  23. package/dist/{rules-init-service-y678kjje.js → rules-init-service-ewahc0vh.js} +16 -12
  24. package/dist/{rules-refresh-service-btn64j8j.js → rules-refresh-service-jgk2kq9d.js} +14 -13
  25. package/dist/{rules-validate-service-sppr4x13.js → rules-validate-service-mr2fk58k.js} +13 -10
  26. package/dist/{tool-97x3zjcm.js → tool-19b4ect0.js} +158 -113
  27. package/dist/{tool-epsr41wx.js → tool-1de529jm.js} +3 -12
  28. package/dist/{tool-7xmarr97.js → tool-2cky8jwp.js} +2578 -1777
  29. package/dist/{tool-x67kek1m.js → tool-2qj74g14.js} +12 -652
  30. package/dist/{tool-0bthsb3x.js → tool-4dfpdepw.js} +15 -15
  31. package/dist/tool-53w8skv5.js +262 -0
  32. package/dist/tool-7haj67tr.js +19 -0
  33. package/dist/{tool-e1mmqsjr.js → tool-8h4er38s.js} +411 -396
  34. package/dist/{tool-2trg1fpx.js → tool-8qy8pkp4.js} +8 -8
  35. package/dist/tool-av4mmsef.js +73 -0
  36. package/dist/{tool-6sqt4zrx.js → tool-cgmy94zt.js} +32 -29
  37. package/dist/{tool-8j9f6ns5.js → tool-eymjx05p.js} +11 -11
  38. package/dist/{tool-mm1x18d6.js → tool-gdtpsdn7.js} +28 -223
  39. package/dist/tool-m41px07w.js +49 -0
  40. package/dist/{tool-k2s349kn.js → tool-mkn83w88.js} +17 -14
  41. package/dist/tool-pm3ewdxc.js +1115 -0
  42. package/dist/{tool-6rp0gx98.js → tool-tkcx6png.js} +107 -127
  43. package/dist/{tool-1dycs173.js → tool-wmh645tm.js} +202 -194
  44. package/dist/tool.js +8 -7
  45. package/package.json +2 -15
  46. package/dist/DmnFactory-SG3RP3T3-cr8e7mxz.js +0 -8
  47. package/dist/DmnFactory-VWZOSZHH-azx0zqcn.js +0 -8
  48. package/dist/DmnModelTypes-ATR7FVKZ-vkv7n0jn.js +0 -8
  49. package/dist/KieDmnMarshaller-6TTUU5B4-rsxhvw7a.js +0 -8
  50. package/dist/business-rules-d51977r1.js +0 -25
  51. package/dist/business-rules-dekge24t.js +0 -23
  52. package/dist/business-rules-ew76mbwg.js +0 -25
  53. package/dist/business-rules-jmwx05k2.js +0 -25
  54. package/dist/business-rules-zpzqxyce.js +0 -26
  55. package/dist/constants-4r8pfr16.js +0 -22
  56. package/dist/embedded-file-reader-0228j82a.js +0 -111
  57. package/dist/first-party-service-1qa6cp4d.js +0 -8
  58. package/dist/first-party-service-28dkctkz.js +0 -8
  59. package/dist/first-party-service-4fsz3cnj.js +0 -8
  60. package/dist/first-party-service-ahcc6xc6.js +0 -8
  61. package/dist/first-party-service-y1ccmsvp.js +0 -8
  62. package/dist/first-party-service-zpr1q3nd.js +0 -8
  63. package/dist/hitPolicyResult-4WDHTX4A-dbtkgpqp.js +0 -12
  64. package/dist/index-2zxy6zgp.js +0 -23
  65. package/dist/index-3nx77wfh.js +0 -23
  66. package/dist/index-43zg1wqe.js +0 -19621
  67. package/dist/index-47jera73.js +0 -23
  68. package/dist/index-70jn7cz1.js +0 -19631
  69. package/dist/index-8kb5kc5y.js +0 -24
  70. package/dist/index-97yad7ms.js +0 -8
  71. package/dist/index-dfn83hxf.js +0 -14
  72. package/dist/index-e301h23h.js +0 -24
  73. package/dist/index-frd259yv.js +0 -24
  74. package/dist/index-gc7cw2jh.js +0 -23
  75. package/dist/index-gya2v502.js +0 -8
  76. package/dist/index-hb3gk1wf.js +0 -24
  77. package/dist/index-nsnfdqd5.js +0 -24
  78. package/dist/index-vffktc0w.js +0 -166
  79. package/dist/index-xymrydfw.js +0 -3095
  80. package/dist/index-z2qk2qn6.js +0 -24
  81. package/dist/index-zecwgvg7.js +0 -23
  82. package/dist/rule-catalog-a5w86qns.js +0 -43
  83. package/dist/rule-catalog-etpf962f.js +0 -69
  84. package/dist/rule-catalog-q5cr17hf.js +0 -58
  85. package/dist/rule-catalog-vc98yg4n.js +0 -43
  86. package/dist/rule-catalog-z3h66kh5.js +0 -56
  87. package/dist/rules-command-error-10qmb5w7.js +0 -13
  88. package/dist/rules-command-error-5bdv4bcx.js +0 -13
  89. package/dist/rules-command-error-cmssf0w4.js +0 -13
  90. package/dist/rules-command-error-fsm3b1mv.js +0 -13
  91. package/dist/rules-debug-service-5rcdh3pj.js +0 -192
  92. package/dist/rules-debug-service-8q7mkd0r.js +0 -199
  93. package/dist/rules-debug-service-b9j29ejz.js +0 -192
  94. package/dist/rules-debug-service-v3jr3r1n.js +0 -192
  95. package/dist/rules-init-service-3c2yfa7p.js +0 -687
  96. package/dist/rules-init-service-3wgd9cqp.js +0 -100
  97. package/dist/rules-init-service-8fqytxq0.js +0 -685
  98. package/dist/rules-init-service-pspt7sje.js +0 -100
  99. package/dist/rules-init-service-sbtzw93j.js +0 -102
  100. package/dist/rules-init-service-x7paqa63.js +0 -687
  101. package/dist/rules-init-service-y7qzmxx0.js +0 -102
  102. package/dist/rules-refresh-service-4xxj6ex6.js +0 -65
  103. package/dist/rules-refresh-service-ba5jk1y9.js +0 -65
  104. package/dist/rules-refresh-service-qkmphj53.js +0 -65
  105. package/dist/rules-validate-service-dmgnfne7.js +0 -60
  106. package/dist/rules-validate-service-hk2d006t.js +0 -60
  107. package/dist/rules-validate-service-xp05n2d9.js +0 -60
  108. package/dist/tool-1pkqxwwd.js +0 -17472
  109. package/dist/tool-24mr6g8c.js +0 -1556
  110. package/dist/tool-39fmkx2d.js +0 -611
  111. package/dist/tool-3e2q1x2y.js +0 -6578
  112. package/dist/tool-3j0747gg.js +0 -17077
  113. package/dist/tool-4z7zcq4z.js +0 -6058
  114. package/dist/tool-56smnjrh.js +0 -73
  115. package/dist/tool-5qygptrc.js +0 -6171
  116. package/dist/tool-5xx6x8pe.js +0 -6596
  117. package/dist/tool-7fkrd618.js +0 -1556
  118. package/dist/tool-89xzeteg.js +0 -361
  119. package/dist/tool-911s9czz.js +0 -570
  120. package/dist/tool-9bz2x04j.js +0 -40
  121. package/dist/tool-akh7nnqs.js +0 -704
  122. package/dist/tool-axfzew45.js +0 -1555
  123. package/dist/tool-b71jq9pt.js +0 -389
  124. package/dist/tool-bfj846v8.js +0 -141
  125. package/dist/tool-bvmc017m.js +0 -96
  126. package/dist/tool-bykz5ryf.js +0 -454
  127. package/dist/tool-c76qb8ap.js +0 -17052
  128. package/dist/tool-ca15515v.js +0 -570
  129. package/dist/tool-f9qs255w.js +0 -70
  130. package/dist/tool-ga79rety.js +0 -389
  131. package/dist/tool-gb547mcn.js +0 -141
  132. package/dist/tool-gta9rr4h.js +0 -68
  133. package/dist/tool-h2dfnxdq.js +0 -6486
  134. package/dist/tool-hg6vr5y9.js +0 -3769
  135. package/dist/tool-hgvnm4vh.js +0 -1843
  136. package/dist/tool-hjbf9aay.js +0 -571
  137. package/dist/tool-k5jm64n3.js +0 -5650
  138. package/dist/tool-ketztpgf.js +0 -73
  139. package/dist/tool-n1d88ryb.js +0 -6396
  140. package/dist/tool-nmqpwh9m.js +0 -6166
  141. package/dist/tool-pb80pswx.js +0 -73
  142. package/dist/tool-pcsgwpfw.js +0 -40
  143. package/dist/tool-q3c1bjyb.js +0 -454
  144. package/dist/tool-rwp1skmf.js +0 -40
  145. package/dist/tool-s3fbt22r.js +0 -454
  146. package/dist/tool-tmbst1r8.js +0 -68
  147. package/dist/tool-v6w109p0.js +0 -455
  148. package/dist/tool-w2js05qv.js +0 -389
  149. package/dist/tool-x89947ah.js +0 -17052
  150. package/dist/tool-xhksjdka.js +0 -4005
  151. package/dist/tool-yv3t4gg5.js +0 -108
  152. package/dist/tool-zbyb1ttx.js +0 -5650
  153. /package/dist/{tool-fbqnqf9k.js → tool-jd313s2x.js} +0 -0
  154. /package/dist/{tool-vyx8fpft.js → tool-qgqscsjc.js} +0 -0
@@ -1,199 +0,0 @@
1
- import {
2
- getAuthContext,
3
- PersonalWorkspacesApi,
4
- createApiClient
5
- } from "./tool-8j9f6ns5.js";
6
- import {
7
- getFileSystem,
8
- catchError,
9
- logger
10
- } from "./tool-5qygptrc.js";
11
- import {
12
- buildSolutionPackageFromDir,
13
- uploadOrOverwriteSolution
14
- } from "./tool-axfzew45.js";
15
- import {
16
- RulesCommandError2,
17
- isJsonObject2
18
- } from "./tool-9bz2x04j.js";
19
- import {
20
- resolveRequiredFolder2
21
- } from "./tool-f9qs255w.js";
22
- import {
23
- findSolutionFile,
24
- updateSolutionFile
25
- } from "./tool-s3fbt22r.js";
26
- import {
27
- readRulesProjectNameAsync
28
- } from "./tool-gta9rr4h.js";
29
-
30
- // src/services/rules-engine-client.ts
31
- var DEBUG_EVALUATE_PATH = "/v1/business-rules/debug/evaluate";
32
- var DEFAULT_TIMEOUT_SECONDS = 120;
33
-
34
- class RulesEngineHttpError extends Error {
35
- status;
36
- constructor(status, message) {
37
- super(message);
38
- this.status = status;
39
- this.name = "RulesEngineHttpError";
40
- }
41
- }
42
- async function assertBusinessRulesServiceAsync(config, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
43
- const [error] = await catchError(postDebugEvaluate(config, {}, timeoutSeconds));
44
- if (error && !(error instanceof RulesEngineHttpError && error.status === 400)) {
45
- throw error;
46
- }
47
- }
48
- async function evaluateRuleDebugAsync(config, request, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
49
- return postDebugEvaluate(config, request, timeoutSeconds);
50
- }
51
- async function postDebugEvaluate(config, request, timeoutSeconds) {
52
- const url = `${config.baseUrl}/${encodeURIComponent(config.organizationId)}/${encodeURIComponent(config.tenantName)}/businessrules_${DEBUG_EVALUATE_PATH}`;
53
- const [fetchError, response] = await catchError(fetch(url, {
54
- method: "POST",
55
- headers: {
56
- Authorization: `Bearer ${config.authToken}`,
57
- Accept: "application/json",
58
- "Content-Type": "application/json",
59
- ...config.folderKey ? { "x-uipath-folderkey": config.folderKey } : {}
60
- },
61
- body: JSON.stringify(request),
62
- signal: AbortSignal.timeout(timeoutSeconds * 1000)
63
- }));
64
- if (fetchError?.name === "TimeoutError") {
65
- throw new RulesCommandError2(`The rules engine did not answer within ${timeoutSeconds} seconds.`, "timeout", "Run the command again, or pass a larger --timeout.", "RetryLater");
66
- }
67
- if (fetchError) {
68
- throw fetchError;
69
- }
70
- if (!response.ok) {
71
- throw await engineFailure(response, config.tenantName);
72
- }
73
- return await response.json();
74
- }
75
- async function engineFailure(response, tenantName) {
76
- const text = await response.text().catch(() => "");
77
- if (response.status === 404 && /Service: businessrules not found in Organization/i.test(text)) {
78
- return new RulesCommandError2(`Business Rules is not enabled on tenant '${tenantName}'.`, "configuration_error", "Ask your UiPath contact to enable Business Rules for this tenant, or switch to a tenant that has it with 'uip login tenant set <tenant-name>'.");
79
- }
80
- const [, body] = catchError(() => JSON.parse(text));
81
- const error = isJsonObject2(body) && isJsonObject2(body.error) ? body.error : {};
82
- if (error.code === "STUDIO_FORBIDDEN") {
83
- return new RulesCommandError2("Studio Web did not let the rules engine read the uploaded project.", "permission_denied", "Check in Studio Web that your account can open the uploaded solution.");
84
- }
85
- const message = typeof error.message === "string" ? error.message : "The rules engine request failed.";
86
- return new RulesEngineHttpError(response.status, typeof error.code === "string" ? `${message} (${error.code})` : message);
87
- }
88
-
89
- // src/services/rules-debug-service.ts
90
- async function debugRuleProjectAsync(projectPath, options) {
91
- assertFolderOnlyWithExplain(options);
92
- const inputs = [{ id: "1", data: await parseInput(options.inputs) }];
93
- const fs = getFileSystem();
94
- const projectDir = fs.path.resolve(projectPath);
95
- const projectName = await readRulesProjectName(projectDir);
96
- const solutionDir = fs.path.resolve(projectDir, "..");
97
- await assertSolutionFolder(solutionDir);
98
- const { config, organizationName } = await loggedInContext(options.loginValidity);
99
- await assertBusinessRulesServiceAsync(config, options.timeout);
100
- const folderKey = await traceFolderKey(options);
101
- const existingSolutionId = (await findSolutionFile(fs, projectDir))?.solutionId;
102
- logger.info(`Uploading the solution of '${projectName}' to Studio Web...`);
103
- const uisPath = await buildSolutionPackageFromDir(fs, solutionDir);
104
- const [uploadError, upload] = await catchError(uploadOrOverwriteSolution(config, organizationName, uisPath, existingSolutionId, fs));
105
- await fs.rm(uisPath).catch(() => {
106
- return;
107
- });
108
- if (uploadError) {
109
- throw uploadError;
110
- }
111
- if (upload.id !== existingSolutionId) {
112
- await updateSolutionFile(fs, projectDir, upload.id);
113
- }
114
- const project = upload.projects.find((p) => p.name === projectName);
115
- if (!project) {
116
- throw new RulesCommandError2(`Studio Web returned no project named '${projectName}' for the uploaded solution.`, "not_found", "Check that the project is listed in the solution's .uipx, then run the command again.");
117
- }
118
- logger.info(`Evaluating against Studio Web project ${project.id}...`);
119
- const response = await evaluateRuleDebugAsync({ ...config, folderKey }, { projectId: project.id, explain: options.explain, inputs }, options.timeout);
120
- return {
121
- solutionId: upload.id,
122
- projectId: project.id,
123
- studioWebUrl: studioWebDesignerUrl(config.baseUrl, organizationName, project.id, upload.id),
124
- response
125
- };
126
- }
127
- async function parseInput(raw) {
128
- if (raw === undefined || raw === "") {
129
- return {};
130
- }
131
- const filePath = raw.startsWith("@") ? raw.slice(1) : undefined;
132
- const [readError, text] = filePath === undefined ? [undefined, raw] : await catchError(getFileSystem().readFile(filePath, "utf-8"));
133
- if (readError || text === null) {
134
- throw new RulesCommandError2(`Input file '${filePath}' could not be read: ${readError?.message ?? "file not found"}.`, "invalid_argument", "Pass --inputs as a JSON object or @file.json pointing at an existing file.");
135
- }
136
- const [parseError, parsed] = catchError(() => JSON.parse(text));
137
- if (parseError || !isJsonObject2(parsed)) {
138
- throw new RulesCommandError2(parseError ? `--inputs is not valid JSON: ${parseError.message}` : "--inputs must be a JSON object of input values.", "invalid_argument", `Pass --inputs '{"<input>": <value>}' or @file.json holding one such object.`);
139
- }
140
- return parsed;
141
- }
142
- function studioWebDesignerUrl(baseUrl, organizationName, projectId, solutionId) {
143
- return `${baseUrl}/${encodeURIComponent(organizationName)}/studio_/designer/${encodeURIComponent(projectId)}?solutionId=${encodeURIComponent(solutionId)}`;
144
- }
145
- async function readRulesProjectName(projectDir) {
146
- const name = await readRulesProjectNameAsync(projectDir);
147
- if (!name) {
148
- throw new RulesCommandError2(`${projectDir}/project.uiproj has no Name.`, "invalid_argument", "Set Name in project.uiproj to the rules project's name, as 'uip rules init' writes it.");
149
- }
150
- return name;
151
- }
152
- async function assertSolutionFolder(solutionDir) {
153
- const [, entries] = await catchError(getFileSystem().readdir(solutionDir));
154
- if (!entries?.some((entry) => entry.endsWith(".uipx"))) {
155
- throw new RulesCommandError2(`${solutionDir} holds no .uipx, so the rules project is not inside a solution.`, "invalid_argument", "Pass a rules project that sits directly inside its solution folder, as 'uip rules init' creates it.");
156
- }
157
- }
158
- async function loggedInContext(loginValidity) {
159
- const auth = await getAuthContext({
160
- ensureTokenValidityMinutes: loginValidity,
161
- requireOrganizationId: true,
162
- requireOrganizationName: true,
163
- requireTenantName: true
164
- });
165
- return {
166
- config: {
167
- baseUrl: auth.baseUrl,
168
- organizationId: auth.organizationId,
169
- tenantName: auth.tenantName,
170
- tenantId: auth.tenantId,
171
- authToken: auth.accessToken
172
- },
173
- organizationName: auth.organizationName
174
- };
175
- }
176
- function assertFolderOnlyWithExplain(options) {
177
- if (!options.explain && (options.folderPath !== undefined || options.folderKey !== undefined)) {
178
- throw new RulesCommandError2("--folder-path and --folder-key set the folder the --explain trace is published into, so they need --explain.", "invalid_argument", "Add --explain to trace the run into that folder, or drop the folder option.");
179
- }
180
- }
181
- async function traceFolderKey(options) {
182
- if (options.folderPath !== undefined || options.folderKey !== undefined) {
183
- return (await resolveRequiredFolder2(options)).key;
184
- }
185
- if (!options.explain) {
186
- return;
187
- }
188
- const api = await createApiClient(PersonalWorkspacesApi, {});
189
- const personal = await api.personalWorkspacesGetPersonalWorkspace();
190
- if (!personal?.key) {
191
- throw new RulesCommandError2("Could not find your personal workspace to publish the trace into.", "invalid_argument", "Pass --folder-path <path> or --folder-key <key> to publish the trace into a folder you can read.");
192
- }
193
- return personal.key;
194
- }
195
- export {
196
- debugRuleProjectAsync
197
- };
198
-
199
- //# debugId=4A5827A5FC49620264756E2164756E21
@@ -1,192 +0,0 @@
1
- import {
2
- getAuthContext,
3
- PersonalWorkspacesApi,
4
- createApiClient
5
- } from "./tool-n1d88ryb.js";
6
- import {
7
- getFileSystem,
8
- catchError,
9
- logger
10
- } from "./tool-6rp0gx98.js";
11
- import {
12
- buildSolutionPackageFromDir,
13
- uploadOrOverwriteSolution
14
- } from "./tool-7fkrd618.js";
15
- import {
16
- RulesCommandError2,
17
- isJsonObject2
18
- } from "./tool-rwp1skmf.js";
19
- import {
20
- assertOneFolderOption2,
21
- resolveRequiredFolder2
22
- } from "./tool-ketztpgf.js";
23
- import {
24
- findSolutionFile,
25
- updateSolutionFile
26
- } from "./tool-q3c1bjyb.js";
27
- import {
28
- readRulesProjectNameAsync
29
- } from "./tool-k2s349kn.js";
30
-
31
- // src/services/rules-engine-client.ts
32
- var DEBUG_EVALUATE_PATH = "/v1/business-rules/debug/evaluate";
33
- var DEFAULT_TIMEOUT_SECONDS = 120;
34
-
35
- class RulesEngineHttpError extends Error {
36
- status;
37
- constructor(status, message) {
38
- super(message);
39
- this.status = status;
40
- this.name = "RulesEngineHttpError";
41
- }
42
- }
43
- async function assertBusinessRulesServiceAsync(config, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
44
- const [error] = await catchError(postDebugEvaluate(config, {}, timeoutSeconds));
45
- if (error && !(error instanceof RulesEngineHttpError && error.status === 400)) {
46
- throw error;
47
- }
48
- }
49
- async function evaluateRuleDebugAsync(config, request, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
50
- return postDebugEvaluate(config, request, timeoutSeconds);
51
- }
52
- async function postDebugEvaluate(config, request, timeoutSeconds) {
53
- const url = `${config.baseUrl}/${encodeURIComponent(config.organizationId)}/${encodeURIComponent(config.tenantName)}/businessrules_${DEBUG_EVALUATE_PATH}`;
54
- const [fetchError, response] = await catchError(fetch(url, {
55
- method: "POST",
56
- headers: {
57
- Authorization: `Bearer ${config.authToken}`,
58
- Accept: "application/json",
59
- "Content-Type": "application/json",
60
- ...config.folderKey ? { "x-uipath-folderkey": config.folderKey } : {}
61
- },
62
- body: JSON.stringify(request),
63
- signal: AbortSignal.timeout(timeoutSeconds * 1000)
64
- }));
65
- if (fetchError?.name === "TimeoutError") {
66
- throw new RulesCommandError2(`The rules engine did not answer within ${timeoutSeconds} seconds.`, "timeout", "Run the command again, or pass a larger --timeout.", "RetryLater");
67
- }
68
- if (fetchError) {
69
- throw fetchError;
70
- }
71
- if (!response.ok) {
72
- throw await engineFailure(response, config.tenantName);
73
- }
74
- return await response.json();
75
- }
76
- async function engineFailure(response, tenantName) {
77
- const text = await response.text().catch(() => "");
78
- if (response.status === 404 && /Service: businessrules not found in Organization/i.test(text)) {
79
- return new RulesCommandError2(`Business Rules is not enabled on tenant '${tenantName}'.`, "configuration_error", "Ask your UiPath contact to enable Business Rules for this tenant, or switch to a tenant that has it with 'uip login tenant set <tenant-name>'.");
80
- }
81
- const [, body] = catchError(() => JSON.parse(text));
82
- const error = isJsonObject2(body) && isJsonObject2(body.error) ? body.error : {};
83
- if (error.code === "STUDIO_FORBIDDEN") {
84
- return new RulesCommandError2("Studio Web did not let the rules engine read the uploaded project.", "permission_denied", "Check in Studio Web that your account can open the uploaded solution.");
85
- }
86
- const message = typeof error.message === "string" ? error.message : "The rules engine request failed.";
87
- return new RulesEngineHttpError(response.status, typeof error.code === "string" ? `${message} (${error.code})` : message);
88
- }
89
-
90
- // src/services/rules-debug-service.ts
91
- async function debugRuleProjectAsync(projectPath, options) {
92
- assertOneFolderOption2(options);
93
- const inputs = [{ id: "1", data: await parseInput(options.inputs) }];
94
- const fs = getFileSystem();
95
- const projectDir = fs.path.resolve(projectPath);
96
- const projectName = await readRulesProjectName(projectDir);
97
- const solutionDir = fs.path.resolve(projectDir, "..");
98
- await assertSolutionFolder(solutionDir);
99
- const { config, organizationName } = await loggedInContext(options.loginValidity);
100
- await assertBusinessRulesServiceAsync(config, options.timeout);
101
- const folderKey = await evaluationFolderKey(options);
102
- const existingSolutionId = (await findSolutionFile(fs, projectDir))?.solutionId;
103
- logger.info(`Uploading the solution of '${projectName}' to Studio Web...`);
104
- const uisPath = await buildSolutionPackageFromDir(fs, solutionDir);
105
- const [uploadError, upload] = await catchError(uploadOrOverwriteSolution(config, organizationName, uisPath, existingSolutionId, fs));
106
- await fs.rm(uisPath).catch(() => {
107
- return;
108
- });
109
- if (uploadError) {
110
- throw uploadError;
111
- }
112
- if (upload.id !== existingSolutionId) {
113
- await updateSolutionFile(fs, projectDir, upload.id);
114
- }
115
- const project = upload.projects.find((p) => p.name === projectName);
116
- if (!project) {
117
- throw new RulesCommandError2(`Studio Web returned no project named '${projectName}' for the uploaded solution.`, "not_found", "Check that the project is listed in the solution's .uipx, then run the command again.");
118
- }
119
- logger.info(`Evaluating against Studio Web project ${project.id}...`);
120
- const response = await evaluateRuleDebugAsync({ ...config, folderKey }, { projectId: project.id, explain: options.explain, inputs }, options.timeout);
121
- return {
122
- solutionId: upload.id,
123
- projectId: project.id,
124
- studioWebUrl: studioWebDesignerUrl(config.baseUrl, organizationName, project.id, upload.id),
125
- response
126
- };
127
- }
128
- async function parseInput(raw) {
129
- if (raw === undefined || raw === "") {
130
- return {};
131
- }
132
- const filePath = raw.startsWith("@") ? raw.slice(1) : undefined;
133
- const [readError, text] = filePath === undefined ? [undefined, raw] : await catchError(getFileSystem().readFile(filePath, "utf-8"));
134
- if (readError || text === null) {
135
- throw new RulesCommandError2(`Input file '${filePath}' could not be read: ${readError?.message ?? "file not found"}.`, "invalid_argument", "Pass --inputs as a JSON object or @file.json pointing at an existing file.");
136
- }
137
- const [parseError, parsed] = catchError(() => JSON.parse(text));
138
- if (parseError || !isJsonObject2(parsed)) {
139
- throw new RulesCommandError2(parseError ? `--inputs is not valid JSON: ${parseError.message}` : "--inputs must be a JSON object of input values.", "invalid_argument", `Pass --inputs '{"<input>": <value>}' or @file.json holding one such object.`);
140
- }
141
- return parsed;
142
- }
143
- function studioWebDesignerUrl(baseUrl, organizationName, projectId, solutionId) {
144
- return `${baseUrl}/${encodeURIComponent(organizationName)}/studio_/designer/${encodeURIComponent(projectId)}?solutionId=${encodeURIComponent(solutionId)}`;
145
- }
146
- async function readRulesProjectName(projectDir) {
147
- const name = await readRulesProjectNameAsync(projectDir);
148
- if (!name) {
149
- throw new RulesCommandError2(`${projectDir}/project.uiproj has no Name.`, "invalid_argument", "Set Name in project.uiproj to the rules project's name, as 'uip rules init' writes it.");
150
- }
151
- return name;
152
- }
153
- async function assertSolutionFolder(solutionDir) {
154
- const [, entries] = await catchError(getFileSystem().readdir(solutionDir));
155
- if (!entries?.some((entry) => entry.endsWith(".uipx"))) {
156
- throw new RulesCommandError2(`${solutionDir} holds no .uipx, so the rules project is not inside a solution.`, "invalid_argument", "Pass a rules project that sits directly inside its solution folder, as 'uip rules init' creates it.");
157
- }
158
- }
159
- async function loggedInContext(loginValidity) {
160
- const auth = await getAuthContext({
161
- ensureTokenValidityMinutes: loginValidity,
162
- requireOrganizationId: true,
163
- requireOrganizationName: true,
164
- requireTenantName: true
165
- });
166
- return {
167
- config: {
168
- baseUrl: auth.baseUrl,
169
- organizationId: auth.organizationId,
170
- tenantName: auth.tenantName,
171
- tenantId: auth.tenantId,
172
- authToken: auth.accessToken
173
- },
174
- organizationName: auth.organizationName
175
- };
176
- }
177
- async function evaluationFolderKey(options) {
178
- if (options.folderPath !== undefined || options.folderKey !== undefined) {
179
- return (await resolveRequiredFolder2(options)).key;
180
- }
181
- const api = await createApiClient(PersonalWorkspacesApi, {});
182
- const personal = await api.personalWorkspacesGetPersonalWorkspace();
183
- if (!personal?.key) {
184
- throw new RulesCommandError2("Could not find your personal workspace to run the rules engine in.", "invalid_argument", "Pass --folder-path <path> or --folder-key <key> to run in a folder you can read.");
185
- }
186
- return personal.key;
187
- }
188
- export {
189
- debugRuleProjectAsync
190
- };
191
-
192
- //# debugId=D45024320EEC44A364756E2164756E21
@@ -1,192 +0,0 @@
1
- import {
2
- getAuthContext,
3
- PersonalWorkspacesApi,
4
- createApiClient
5
- } from "./tool-hg6vr5y9.js";
6
- import {
7
- getFileSystem,
8
- catchError,
9
- logger
10
- } from "./tool-5xx6x8pe.js";
11
- import {
12
- buildSolutionPackageFromDir,
13
- uploadOrOverwriteSolution
14
- } from "./tool-hgvnm4vh.js";
15
- import {
16
- RulesCommandError2,
17
- isJsonObject2
18
- } from "./tool-2trg1fpx.js";
19
- import {
20
- assertOneFolderOption2,
21
- resolveRequiredFolder2
22
- } from "./tool-pb80pswx.js";
23
- import {
24
- findSolutionFile,
25
- updateSolutionFile
26
- } from "./tool-v6w109p0.js";
27
- import {
28
- readRulesProjectNameAsync
29
- } from "./tool-yv3t4gg5.js";
30
-
31
- // src/services/rules-engine-client.ts
32
- var DEBUG_EVALUATE_PATH = "/v1/business-rules/debug/evaluate";
33
- var DEFAULT_TIMEOUT_SECONDS = 120;
34
-
35
- class RulesEngineHttpError extends Error {
36
- status;
37
- constructor(status, message) {
38
- super(message);
39
- this.status = status;
40
- this.name = "RulesEngineHttpError";
41
- }
42
- }
43
- async function assertBusinessRulesServiceAsync(config, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
44
- const [error] = await catchError(postDebugEvaluate(config, {}, timeoutSeconds));
45
- if (error && !(error instanceof RulesEngineHttpError && error.status === 400)) {
46
- throw error;
47
- }
48
- }
49
- async function evaluateRuleDebugAsync(config, request, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
50
- return postDebugEvaluate(config, request, timeoutSeconds);
51
- }
52
- async function postDebugEvaluate(config, request, timeoutSeconds) {
53
- const url = `${config.baseUrl}/${encodeURIComponent(config.organizationId)}/${encodeURIComponent(config.tenantName)}/businessrules_${DEBUG_EVALUATE_PATH}`;
54
- const [fetchError, response] = await catchError(fetch(url, {
55
- method: "POST",
56
- headers: {
57
- Authorization: `Bearer ${config.authToken}`,
58
- Accept: "application/json",
59
- "Content-Type": "application/json",
60
- ...config.folderKey ? { "x-uipath-folderkey": config.folderKey } : {}
61
- },
62
- body: JSON.stringify(request),
63
- signal: AbortSignal.timeout(timeoutSeconds * 1000)
64
- }));
65
- if (fetchError?.name === "TimeoutError") {
66
- throw new RulesCommandError2(`The rules engine did not answer within ${timeoutSeconds} seconds.`, "timeout", "Run the command again, or pass a larger --timeout.", "RetryLater");
67
- }
68
- if (fetchError) {
69
- throw fetchError;
70
- }
71
- if (!response.ok) {
72
- throw await engineFailure(response, config.tenantName);
73
- }
74
- return await response.json();
75
- }
76
- async function engineFailure(response, tenantName) {
77
- const text = await response.text().catch(() => "");
78
- if (response.status === 404 && /Service: businessrules not found in Organization/i.test(text)) {
79
- return new RulesCommandError2(`Business Rules is not enabled on tenant '${tenantName}'.`, "configuration_error", "Ask your UiPath contact to enable Business Rules for this tenant, or switch to a tenant that has it with 'uip login tenant set <tenant-name>'.");
80
- }
81
- const [, body] = catchError(() => JSON.parse(text));
82
- const error = isJsonObject2(body) && isJsonObject2(body.error) ? body.error : {};
83
- if (error.code === "STUDIO_FORBIDDEN") {
84
- return new RulesCommandError2("Studio Web did not let the rules engine read the uploaded project.", "permission_denied", "Check in Studio Web that your account can open the uploaded solution.");
85
- }
86
- const message = typeof error.message === "string" ? error.message : "The rules engine request failed.";
87
- return new RulesEngineHttpError(response.status, typeof error.code === "string" ? `${message} (${error.code})` : message);
88
- }
89
-
90
- // src/services/rules-debug-service.ts
91
- async function debugRuleProjectAsync(projectPath, options) {
92
- assertOneFolderOption2(options);
93
- const input = await parseInput(options.inputs);
94
- const fs = getFileSystem();
95
- const projectDir = fs.path.resolve(projectPath);
96
- const projectName = await readRulesProjectName(projectDir);
97
- const solutionDir = fs.path.resolve(projectDir, "..");
98
- await assertSolutionFolder(solutionDir);
99
- const { config, organizationName } = await loggedInContext(options.loginValidity);
100
- await assertBusinessRulesServiceAsync(config, options.timeout);
101
- const folderKey = await evaluationFolderKey(options);
102
- const existingSolutionId = (await findSolutionFile(fs, projectDir))?.solutionId;
103
- logger.info(`Uploading the solution of '${projectName}' to Studio Web...`);
104
- const uisPath = await buildSolutionPackageFromDir(fs, solutionDir);
105
- const [uploadError, upload] = await catchError(uploadOrOverwriteSolution(config, organizationName, uisPath, existingSolutionId, fs));
106
- await fs.rm(uisPath).catch(() => {
107
- return;
108
- });
109
- if (uploadError) {
110
- throw uploadError;
111
- }
112
- if (upload.id !== existingSolutionId) {
113
- await updateSolutionFile(fs, projectDir, upload.id);
114
- }
115
- const project = upload.projects.find((p) => p.name === projectName);
116
- if (!project) {
117
- throw new RulesCommandError2(`Studio Web returned no project named '${projectName}' for the uploaded solution.`, "not_found", "Check that the project is listed in the solution's .uipx, then run the command again.");
118
- }
119
- logger.info(`Evaluating against Studio Web project ${project.id}...`);
120
- const response = await evaluateRuleDebugAsync({ ...config, folderKey }, { projectId: project.id, input }, options.timeout);
121
- return {
122
- solutionId: upload.id,
123
- projectId: project.id,
124
- studioWebUrl: studioWebDesignerUrl(config.baseUrl, organizationName, project.id, upload.id),
125
- response
126
- };
127
- }
128
- async function parseInput(raw) {
129
- if (raw === undefined || raw === "") {
130
- return {};
131
- }
132
- const filePath = raw.startsWith("@") ? raw.slice(1) : undefined;
133
- const [readError, text] = filePath === undefined ? [undefined, raw] : await catchError(getFileSystem().readFile(filePath, "utf-8"));
134
- if (readError || text === null) {
135
- throw new RulesCommandError2(`Input file '${filePath}' could not be read: ${readError?.message ?? "file not found"}.`, "invalid_argument", "Pass --inputs as a JSON object or @file.json pointing at an existing file.");
136
- }
137
- const [parseError, parsed] = catchError(() => JSON.parse(text));
138
- if (parseError || !isJsonObject2(parsed)) {
139
- throw new RulesCommandError2(parseError ? `--inputs is not valid JSON: ${parseError.message}` : "--inputs must be a JSON object of input values.", "invalid_argument", `Pass --inputs '{"<input>": <value>}' or @file.json holding one such object.`);
140
- }
141
- return parsed;
142
- }
143
- function studioWebDesignerUrl(baseUrl, organizationName, projectId, solutionId) {
144
- return `${baseUrl}/${encodeURIComponent(organizationName)}/studio_/designer/${encodeURIComponent(projectId)}?solutionId=${encodeURIComponent(solutionId)}`;
145
- }
146
- async function readRulesProjectName(projectDir) {
147
- const name = await readRulesProjectNameAsync(projectDir);
148
- if (!name) {
149
- throw new RulesCommandError2(`${projectDir}/project.uiproj has no Name.`, "invalid_argument", "Set Name in project.uiproj to the rules project's name, as 'uip rules init' writes it.");
150
- }
151
- return name;
152
- }
153
- async function assertSolutionFolder(solutionDir) {
154
- const [, entries] = await catchError(getFileSystem().readdir(solutionDir));
155
- if (!entries?.some((entry) => entry.endsWith(".uipx"))) {
156
- throw new RulesCommandError2(`${solutionDir} holds no .uipx, so the rules project is not inside a solution.`, "invalid_argument", "Pass a rules project that sits directly inside its solution folder, as 'uip rules init' creates it.");
157
- }
158
- }
159
- async function loggedInContext(loginValidity) {
160
- const auth = await getAuthContext({
161
- ensureTokenValidityMinutes: loginValidity,
162
- requireOrganizationId: true,
163
- requireOrganizationName: true,
164
- requireTenantName: true
165
- });
166
- return {
167
- config: {
168
- baseUrl: auth.baseUrl,
169
- organizationId: auth.organizationId,
170
- tenantName: auth.tenantName,
171
- tenantId: auth.tenantId,
172
- authToken: auth.accessToken
173
- },
174
- organizationName: auth.organizationName
175
- };
176
- }
177
- async function evaluationFolderKey(options) {
178
- if (options.folderPath !== undefined || options.folderKey !== undefined) {
179
- return (await resolveRequiredFolder2(options)).key;
180
- }
181
- const api = await createApiClient(PersonalWorkspacesApi, {});
182
- const personal = await api.personalWorkspacesGetPersonalWorkspace();
183
- if (!personal?.key) {
184
- throw new RulesCommandError2("Could not find your personal workspace to run the rules engine in.", "invalid_argument", "Pass --folder-path <path> or --folder-key <key> to run in a folder you can read.");
185
- }
186
- return personal.key;
187
- }
188
- export {
189
- debugRuleProjectAsync
190
- };
191
-
192
- //# debugId=FDF5F3639609B6B364756E2164756E21