@uipath/rules-tool 0.0.0-stage → 1.204.0-preview.249
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.
- package/LICENSE.txt +3 -0
- package/README.md +80 -2
- package/dist/DmnFactory-SG3RP3T3-cr8e7mxz.js +8 -0
- package/dist/DmnFactory-VWZOSZHH-azx0zqcn.js +8 -0
- package/dist/DmnModelTypes-ATR7FVKZ-vkv7n0jn.js +8 -0
- package/dist/KieDmnMarshaller-6TTUU5B4-rsxhvw7a.js +8 -0
- package/dist/business-rules-d51977r1.js +25 -0
- package/dist/business-rules-dekge24t.js +23 -0
- package/dist/business-rules-ew76mbwg.js +25 -0
- package/dist/business-rules-jmwx05k2.js +25 -0
- package/dist/business-rules-zpzqxyce.js +26 -0
- package/dist/constants-4r8pfr16.js +22 -0
- package/dist/constants-za5vbzp8.js +22 -0
- package/dist/embedded-file-reader-0228j82a.js +111 -0
- package/dist/embedded-file-reader-wmsg31a8.js +111 -0
- package/dist/first-party-service-1qa6cp4d.js +8 -0
- package/dist/first-party-service-28dkctkz.js +8 -0
- package/dist/first-party-service-4fsz3cnj.js +8 -0
- package/dist/first-party-service-ahcc6xc6.js +8 -0
- package/dist/first-party-service-y1ccmsvp.js +8 -0
- package/dist/first-party-service-zpr1q3nd.js +8 -0
- package/dist/hitPolicyResult-4WDHTX4A-dbtkgpqp.js +12 -0
- package/dist/index-2zxy6zgp.js +23 -0
- package/dist/index-3nx77wfh.js +23 -0
- package/dist/index-43zg1wqe.js +19621 -0
- package/dist/index-47jera73.js +23 -0
- package/dist/index-70jn7cz1.js +19631 -0
- package/dist/index-7wc0g78k.js +14 -0
- package/dist/index-8kb5kc5y.js +24 -0
- package/dist/index-97yad7ms.js +8 -0
- package/dist/index-dfn83hxf.js +14 -0
- package/dist/index-e301h23h.js +24 -0
- package/dist/index-frd259yv.js +24 -0
- package/dist/index-gc7cw2jh.js +23 -0
- package/dist/index-gya2v502.js +8 -0
- package/dist/index-hb3gk1wf.js +24 -0
- package/dist/index-nsnfdqd5.js +24 -0
- package/dist/index-nzr4mx5p.js +614 -0
- package/dist/index-vffktc0w.js +166 -0
- package/dist/index-we6zjs66.js +164 -0
- package/dist/index-xymrydfw.js +3095 -0
- package/dist/index-z2qk2qn6.js +24 -0
- package/dist/index-zdwhfpt1.js +3071 -0
- package/dist/index-zecwgvg7.js +23 -0
- package/dist/index.js +16 -0
- package/dist/jmespath-ab6tdc42.js +1485 -0
- package/dist/js-yaml-a2bk27p6.js +3151 -0
- package/dist/rule-catalog-a5w86qns.js +43 -0
- package/dist/rule-catalog-etpf962f.js +69 -0
- package/dist/rule-catalog-q5cr17hf.js +58 -0
- package/dist/rule-catalog-vc98yg4n.js +43 -0
- package/dist/rule-catalog-z3h66kh5.js +56 -0
- package/dist/rules-command-error-10qmb5w7.js +13 -0
- package/dist/rules-command-error-5bdv4bcx.js +13 -0
- package/dist/rules-command-error-cmssf0w4.js +13 -0
- package/dist/rules-command-error-fsm3b1mv.js +13 -0
- package/dist/rules-debug-service-5rcdh3pj.js +192 -0
- package/dist/rules-debug-service-8q7mkd0r.js +199 -0
- package/dist/rules-debug-service-b9j29ejz.js +192 -0
- package/dist/rules-debug-service-h1ahd6p3.js +192 -0
- package/dist/rules-debug-service-v3jr3r1n.js +192 -0
- package/dist/rules-init-service-3c2yfa7p.js +687 -0
- package/dist/rules-init-service-3wgd9cqp.js +100 -0
- package/dist/rules-init-service-8fqytxq0.js +685 -0
- package/dist/rules-init-service-pspt7sje.js +100 -0
- package/dist/rules-init-service-sbtzw93j.js +102 -0
- package/dist/rules-init-service-x7paqa63.js +687 -0
- package/dist/rules-init-service-y678kjje.js +100 -0
- package/dist/rules-init-service-y7qzmxx0.js +102 -0
- package/dist/rules-refresh-service-4xxj6ex6.js +65 -0
- package/dist/rules-refresh-service-ba5jk1y9.js +65 -0
- package/dist/rules-refresh-service-btn64j8j.js +65 -0
- package/dist/rules-refresh-service-qkmphj53.js +65 -0
- package/dist/rules-validate-service-dmgnfne7.js +60 -0
- package/dist/rules-validate-service-hk2d006t.js +60 -0
- package/dist/rules-validate-service-sppr4x13.js +60 -0
- package/dist/rules-validate-service-xp05n2d9.js +60 -0
- package/dist/tool-0bthsb3x.js +55 -0
- package/dist/tool-1dycs173.js +4014 -0
- package/dist/tool-1pkqxwwd.js +17472 -0
- package/dist/tool-24mr6g8c.js +1556 -0
- package/dist/tool-2trg1fpx.js +40 -0
- package/dist/tool-39fmkx2d.js +611 -0
- package/dist/tool-3e2q1x2y.js +6578 -0
- package/dist/tool-3j0747gg.js +17077 -0
- package/dist/tool-4z7zcq4z.js +6058 -0
- package/dist/tool-56smnjrh.js +73 -0
- package/dist/tool-5qygptrc.js +6171 -0
- package/dist/tool-5xx6x8pe.js +6596 -0
- package/dist/tool-6rp0gx98.js +6578 -0
- package/dist/tool-6sqt4zrx.js +571 -0
- package/dist/tool-7fkrd618.js +1556 -0
- package/dist/tool-7xmarr97.js +17077 -0
- package/dist/tool-89xzeteg.js +361 -0
- package/dist/tool-8j9f6ns5.js +6396 -0
- package/dist/tool-911s9czz.js +570 -0
- package/dist/tool-97x3zjcm.js +709 -0
- package/dist/tool-9bz2x04j.js +40 -0
- package/dist/tool-akh7nnqs.js +704 -0
- package/dist/tool-axfzew45.js +1555 -0
- package/dist/tool-b71jq9pt.js +389 -0
- package/dist/tool-bfj846v8.js +141 -0
- package/dist/tool-bvmc017m.js +96 -0
- package/dist/tool-bykz5ryf.js +454 -0
- package/dist/tool-c76qb8ap.js +17052 -0
- package/dist/tool-ca15515v.js +570 -0
- package/dist/tool-e1mmqsjr.js +11048 -0
- package/dist/tool-epsr41wx.js +48 -0
- package/dist/tool-f9qs255w.js +70 -0
- package/dist/tool-fbqnqf9k.js +10 -0
- package/dist/tool-ga79rety.js +389 -0
- package/dist/tool-gb547mcn.js +141 -0
- package/dist/tool-gta9rr4h.js +68 -0
- package/dist/tool-h2dfnxdq.js +6486 -0
- package/dist/tool-hg6vr5y9.js +3769 -0
- package/dist/tool-hgvnm4vh.js +1843 -0
- package/dist/tool-hjbf9aay.js +571 -0
- package/dist/tool-k2s349kn.js +108 -0
- package/dist/tool-k5jm64n3.js +5650 -0
- package/dist/tool-ketztpgf.js +73 -0
- package/dist/tool-mm1x18d6.js +537 -0
- package/dist/tool-n1d88ryb.js +6396 -0
- package/dist/tool-nmqpwh9m.js +6166 -0
- package/dist/tool-pb80pswx.js +73 -0
- package/dist/tool-pcsgwpfw.js +40 -0
- package/dist/tool-q3c1bjyb.js +454 -0
- package/dist/tool-rwp1skmf.js +40 -0
- package/dist/tool-s3fbt22r.js +454 -0
- package/dist/tool-tmbst1r8.js +68 -0
- package/dist/tool-v6w109p0.js +455 -0
- package/dist/tool-vyx8fpft.js +46 -0
- package/dist/tool-w2js05qv.js +389 -0
- package/dist/tool-x67kek1m.js +1838 -0
- package/dist/tool-x89947ah.js +17052 -0
- package/dist/tool-xhksjdka.js +4005 -0
- package/dist/tool-yv3t4gg5.js +108 -0
- package/dist/tool-zbyb1ttx.js +5650 -0
- package/dist/tool.js +11 -0
- package/package.json +43 -5
|
@@ -0,0 +1,192 @@
|
|
|
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
|