@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,48 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (canCache)
|
|
31
|
+
cache.set(mod, to);
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
35
|
+
var __exportCjs = (target, getters, setters) => {
|
|
36
|
+
for (var name in getters)
|
|
37
|
+
__defProp(target, name, {
|
|
38
|
+
get: getters[name],
|
|
39
|
+
set: setters[name],
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
45
|
+
|
|
46
|
+
export { __toESM, __commonJS, __exportCjs, __require };
|
|
47
|
+
|
|
48
|
+
//# debugId=6692E9B4C735B07364756E2164756E21
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BusinessRulesApi,
|
|
3
|
+
createApiClient,
|
|
4
|
+
resolveFolder,
|
|
5
|
+
quoteODataStringLiteral
|
|
6
|
+
} from "./tool-8j9f6ns5.js";
|
|
7
|
+
import {
|
|
8
|
+
RulesCommandError2
|
|
9
|
+
} from "./tool-9bz2x04j.js";
|
|
10
|
+
|
|
11
|
+
// src/services/business-rules.ts
|
|
12
|
+
async function resolveRequiredFolder2(options) {
|
|
13
|
+
if (options.folderPath !== undefined && options.folderKey !== undefined) {
|
|
14
|
+
throw new RulesCommandError2("Options --folder-path and --folder-key cannot be used together.", "invalid_argument", "Provide either --folder-path <path> or --folder-key <key>, not both.");
|
|
15
|
+
}
|
|
16
|
+
const folder = await resolveFolder({ folderPath: options.folderPath, folderKey: options.folderKey }, { tenant: options.tenant });
|
|
17
|
+
if (!folder) {
|
|
18
|
+
throw new RulesCommandError2("Missing required option --folder-path or --folder-key.", "invalid_argument", "Provide --folder-path <path> or --folder-key <key>. Run 'uip or folders list' to find folder paths.");
|
|
19
|
+
}
|
|
20
|
+
return folder;
|
|
21
|
+
}
|
|
22
|
+
function createRulesApi2(tenant, folder) {
|
|
23
|
+
return createApiClient(BusinessRulesApi, {
|
|
24
|
+
tenant,
|
|
25
|
+
folderId: folder.id.toString()
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function ruleNotFound2(name, folder) {
|
|
29
|
+
return new RulesCommandError2(`Business rule '${name}' was not found in folder '${folder.path}'.`, "not_found", `Run 'uip rules list --folder-path "${folder.path}"' to see the rules in this folder.`);
|
|
30
|
+
}
|
|
31
|
+
async function findRuleByName2(api, name, folder) {
|
|
32
|
+
const result = await api.businessRulesGet({
|
|
33
|
+
$filter: `Name eq ${quoteODataStringLiteral(name)}`,
|
|
34
|
+
$top: 1
|
|
35
|
+
});
|
|
36
|
+
const rule = result.value?.[0];
|
|
37
|
+
if (!rule) {
|
|
38
|
+
throw ruleNotFound2(name, folder);
|
|
39
|
+
}
|
|
40
|
+
return rule;
|
|
41
|
+
}
|
|
42
|
+
function formatRule2(rule, folder) {
|
|
43
|
+
return {
|
|
44
|
+
Key: rule.id ?? "",
|
|
45
|
+
Name: rule.name,
|
|
46
|
+
FolderPath: folder.path,
|
|
47
|
+
FolderKey: folder.key,
|
|
48
|
+
Description: rule.description ?? "",
|
|
49
|
+
CurrentVersion: rule.currentVersion?.versionNumber ?? ""
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function formatRuleDetail2(rule, folder) {
|
|
53
|
+
return {
|
|
54
|
+
...formatRule2(rule, folder),
|
|
55
|
+
Tags: (rule.tags ?? []).map((tag) => tag.name),
|
|
56
|
+
CreationTime: rule.creationTime,
|
|
57
|
+
LastModificationTime: rule.lastModificationTime
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function formatVersion2(version) {
|
|
61
|
+
return {
|
|
62
|
+
Version: version.versionNumber ?? "",
|
|
63
|
+
IsActive: version.isActive === true,
|
|
64
|
+
CreationTime: version.creationTime
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { resolveRequiredFolder2, createRulesApi2, ruleNotFound2, findRuleByName2, formatRule2, formatRuleDetail2, formatVersion2 };
|
|
69
|
+
|
|
70
|
+
//# debugId=C024EAC7A058890364756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ../../node_modules/@uipath/dmn-editor-utils/dist/chunks/chunk-H6JHU73X.js
|
|
2
|
+
var e = { First: "FIRST", Unique: "UNIQUE", Priority: "PRIORITY", Any: "ANY", Collect: "COLLECT", RuleOrder: "RULE ORDER", OutputOrder: "OUTPUT ORDER" };
|
|
3
|
+
var t = Object.values(e);
|
|
4
|
+
var n = { Sum: "SUM", Min: "MIN", Max: "MAX", Count: "COUNT" };
|
|
5
|
+
var i = Object.values(n);
|
|
6
|
+
var r = ["string", "number", "boolean", "Any", "date", "time", "date and time", "dayTimeDuration", "yearMonthDuration"];
|
|
7
|
+
|
|
8
|
+
export { e, t, n, i, r };
|
|
9
|
+
|
|
10
|
+
//# debugId=D17C84157F7B7FAE64756E2164756E21
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import {
|
|
2
|
+
catchError,
|
|
3
|
+
logger,
|
|
4
|
+
unsupportedSolutionProjectType
|
|
5
|
+
} from "./tool-zbyb1ttx.js";
|
|
6
|
+
|
|
7
|
+
// ../solution-sdk/src/solution-file.ts
|
|
8
|
+
var STUDIO_WEB_PROJECT_TYPE_OVERRIDES = {
|
|
9
|
+
ProcessOrchestration: "processOrchestration"
|
|
10
|
+
};
|
|
11
|
+
function normalizeProjectType(projectType) {
|
|
12
|
+
return STUDIO_WEB_PROJECT_TYPE_OVERRIDES[projectType] ?? projectType;
|
|
13
|
+
}
|
|
14
|
+
function toPortableRelativePath(relativePath) {
|
|
15
|
+
return relativePath.replace(/\\/g, "/");
|
|
16
|
+
}
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
async function createSolutionManifest(fs, solutionDir, solutionName, options = {}) {
|
|
21
|
+
const resolvedDir = fs.path.resolve(solutionDir);
|
|
22
|
+
if (!(options.allowExistingDir && await fs.exists(resolvedDir))) {
|
|
23
|
+
await fs.mkdir(resolvedDir);
|
|
24
|
+
}
|
|
25
|
+
const solutionId = crypto.randomUUID();
|
|
26
|
+
const manifest = {
|
|
27
|
+
DocVersion: "1.0.0",
|
|
28
|
+
StudioMinVersion: "2025.10.0",
|
|
29
|
+
SolutionId: solutionId,
|
|
30
|
+
Projects: []
|
|
31
|
+
};
|
|
32
|
+
const solutionFile = fs.path.join(resolvedDir, `${solutionName}.uipx`);
|
|
33
|
+
await fs.writeFile(solutionFile, `${JSON.stringify(manifest, null, 2)}
|
|
34
|
+
`);
|
|
35
|
+
return {
|
|
36
|
+
solutionDir: resolvedDir,
|
|
37
|
+
solutionFile,
|
|
38
|
+
solutionId
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
var AUTO_SOLUTION_SUFFIX = "Solution";
|
|
42
|
+
async function autoScaffoldSolution(fs, baseDir, projectName) {
|
|
43
|
+
const solutionName = `${projectName}${AUTO_SOLUTION_SUFFIX}`;
|
|
44
|
+
const solutionDir = fs.path.resolve(baseDir, solutionName);
|
|
45
|
+
const expectedSolutionFile = fs.path.join(solutionDir, `${solutionName}.uipx`);
|
|
46
|
+
if (await fs.exists(expectedSolutionFile)) {
|
|
47
|
+
return {
|
|
48
|
+
Name: solutionName,
|
|
49
|
+
Path: solutionDir,
|
|
50
|
+
SolutionFile: expectedSolutionFile
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const { solutionFile } = await createSolutionManifest(fs, solutionDir, solutionName, { allowExistingDir: true });
|
|
54
|
+
return {
|
|
55
|
+
Name: solutionName,
|
|
56
|
+
Path: solutionDir,
|
|
57
|
+
SolutionFile: solutionFile
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function prepareProjectLocation(fs, candidateProjectDir, projectName, options = {}) {
|
|
61
|
+
const resolved = fs.path.resolve(candidateProjectDir);
|
|
62
|
+
if (options.skipRegistration) {
|
|
63
|
+
return { projectDir: resolved };
|
|
64
|
+
}
|
|
65
|
+
const discovery = await findNearestParentUipxFile(fs, resolved);
|
|
66
|
+
if (discovery.status !== "notFound") {
|
|
67
|
+
return { projectDir: resolved };
|
|
68
|
+
}
|
|
69
|
+
const baseDir = fs.path.dirname(resolved);
|
|
70
|
+
const autoCreatedSolution = await autoScaffoldSolution(fs, baseDir, projectName);
|
|
71
|
+
const projectDir = fs.path.join(autoCreatedSolution.Path, projectName);
|
|
72
|
+
await warnIfCandidateDirShadowed(fs, resolved, projectDir);
|
|
73
|
+
return { projectDir, autoCreatedSolution };
|
|
74
|
+
}
|
|
75
|
+
async function warnIfCandidateDirShadowed(fs, candidateDir, projectDir) {
|
|
76
|
+
const [, exists] = await catchError(fs.exists(candidateDir));
|
|
77
|
+
if (!exists) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const [, entries] = await catchError(fs.readdir(candidateDir));
|
|
81
|
+
if (!entries || entries.length === 0) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
logger.warn(`An existing directory "${candidateDir}" was left untouched. ` + `The project was created inside the auto-created solution at "${projectDir}". ` + "Run init from inside an existing solution, or pass --skip-solution-registration, if you meant to use the existing directory.");
|
|
85
|
+
}
|
|
86
|
+
async function tryRegisterProjectInParentSolution(fs, projectDir, options) {
|
|
87
|
+
if (options?.skipRegistration) {
|
|
88
|
+
return {
|
|
89
|
+
Status: "OptedOut",
|
|
90
|
+
Message: "Solution auto-registration skipped (--skip-solution-registration).",
|
|
91
|
+
Instructions: buildOptedOutInstructions(fs.path.resolve(projectDir))
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const [registrationError, registration] = await catchError(registerProjectInParentSolution(fs, projectDir));
|
|
95
|
+
if (registrationError) {
|
|
96
|
+
return {
|
|
97
|
+
Status: "Failed",
|
|
98
|
+
Message: "Project registration failed.",
|
|
99
|
+
Instructions: buildRegistrationFailureInstructions(projectDir, registrationError.message)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return registration;
|
|
103
|
+
}
|
|
104
|
+
async function registerProjectInParentSolution(fs, projectDir) {
|
|
105
|
+
const resolvedProjectDir = fs.path.resolve(projectDir);
|
|
106
|
+
const discovery = await findNearestParentUipxFile(fs, resolvedProjectDir);
|
|
107
|
+
if (discovery.status === "notFound") {
|
|
108
|
+
return {
|
|
109
|
+
Status: "NotInSolution",
|
|
110
|
+
Message: "Project created in standalone mode; no parent .uipx solution found.",
|
|
111
|
+
Instructions: buildStandaloneInstructions(resolvedProjectDir)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (discovery.status === "skipped") {
|
|
115
|
+
return discovery.registration;
|
|
116
|
+
}
|
|
117
|
+
const solutionFile = discovery.solutionFile;
|
|
118
|
+
const solutionDir = fs.path.dirname(solutionFile);
|
|
119
|
+
const relativeProjectDir = fs.path.relative(solutionDir, resolvedProjectDir);
|
|
120
|
+
if (relativeProjectDir === "" || relativeProjectDir.startsWith("..") || fs.path.isAbsolute(relativeProjectDir)) {
|
|
121
|
+
return {
|
|
122
|
+
Status: "Skipped",
|
|
123
|
+
Message: "Project registration skipped.",
|
|
124
|
+
Solution: solutionFile,
|
|
125
|
+
Instructions: `Project must reside within the solution folder.
|
|
126
|
+
Solution: ${solutionDir}
|
|
127
|
+
Project: ${resolvedProjectDir}`
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const [projectFileError, projectFile] = await findProjectFile(fs, resolvedProjectDir);
|
|
131
|
+
if (projectFileError) {
|
|
132
|
+
return {
|
|
133
|
+
Status: "Failed",
|
|
134
|
+
Message: "Project registration failed.",
|
|
135
|
+
Solution: solutionFile,
|
|
136
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, projectFileError.message)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const [projectManifestError, projectManifest] = await readProjectManifest(fs, projectFile.filePath, projectFile.useProjectJson);
|
|
140
|
+
if (projectManifestError) {
|
|
141
|
+
return {
|
|
142
|
+
Status: "Failed",
|
|
143
|
+
Message: "Project registration failed.",
|
|
144
|
+
Solution: solutionFile,
|
|
145
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, projectManifestError.message)
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const unsupportedReason = unsupportedSolutionProjectType(projectManifest.projectType);
|
|
149
|
+
if (unsupportedReason) {
|
|
150
|
+
return {
|
|
151
|
+
Status: "Skipped",
|
|
152
|
+
Message: "Project registration skipped.",
|
|
153
|
+
Solution: solutionFile,
|
|
154
|
+
Instructions: unsupportedReason
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const projectRelativePath = toPortableRelativePath(fs.path.join(relativeProjectDir, projectFile.fileName));
|
|
158
|
+
const [solutionError, solution] = await readSolutionManifest(fs, solutionFile);
|
|
159
|
+
if (solutionError) {
|
|
160
|
+
return {
|
|
161
|
+
Status: "Failed",
|
|
162
|
+
Message: "Project registration failed.",
|
|
163
|
+
Solution: solutionFile,
|
|
164
|
+
Project: projectRelativePath,
|
|
165
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, solutionError.message)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const existingProject = solution.projects.find((project) => toPortableRelativePath(project.ProjectRelativePath) === projectRelativePath);
|
|
169
|
+
if (existingProject) {
|
|
170
|
+
return {
|
|
171
|
+
Status: "AlreadyRegistered",
|
|
172
|
+
Message: "Project already registered in solution.",
|
|
173
|
+
Solution: solutionFile,
|
|
174
|
+
Project: projectRelativePath,
|
|
175
|
+
ProjectId: typeof existingProject.Id === "string" ? existingProject.Id : undefined,
|
|
176
|
+
Instructions: buildRegistrationSuccessInstructions(solutionDir)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const projectId = crypto.randomUUID();
|
|
180
|
+
solution.projects.push({
|
|
181
|
+
Type: normalizeProjectType(projectManifest.projectType),
|
|
182
|
+
ProjectRelativePath: projectRelativePath,
|
|
183
|
+
Id: projectId
|
|
184
|
+
});
|
|
185
|
+
solution.content.Projects = solution.projects;
|
|
186
|
+
const [writeError] = await catchError(fs.writeFile(solutionFile, `${JSON.stringify(solution.content, null, 2)}
|
|
187
|
+
`));
|
|
188
|
+
if (writeError) {
|
|
189
|
+
return {
|
|
190
|
+
Status: "Failed",
|
|
191
|
+
Message: "Project registration failed.",
|
|
192
|
+
Solution: solutionFile,
|
|
193
|
+
Project: projectRelativePath,
|
|
194
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, writeError.message)
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
Status: "Registered",
|
|
199
|
+
Message: "Project registered in parent solution.",
|
|
200
|
+
Solution: solutionFile,
|
|
201
|
+
Project: projectRelativePath,
|
|
202
|
+
ProjectId: projectId,
|
|
203
|
+
Instructions: buildRegistrationSuccessInstructions(solutionDir)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
async function findNearestParentUipxFile(fs, projectDir) {
|
|
207
|
+
let currentDir = fs.path.dirname(fs.path.resolve(projectDir));
|
|
208
|
+
while (true) {
|
|
209
|
+
const [readDirError, entries] = await catchError(fs.readdir(currentDir));
|
|
210
|
+
if (readDirError) {
|
|
211
|
+
return {
|
|
212
|
+
status: "skipped",
|
|
213
|
+
registration: {
|
|
214
|
+
Status: "Failed",
|
|
215
|
+
Message: "Project registration failed.",
|
|
216
|
+
Instructions: buildRegistrationFailureInstructions(projectDir, `Could not inspect parent directory for a solution: ${currentDir}
|
|
217
|
+
${readDirError.message}`)
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const solutionFiles = entries.filter((entry) => entry.endsWith(".uipx"));
|
|
222
|
+
if (solutionFiles.length > 1) {
|
|
223
|
+
return {
|
|
224
|
+
status: "skipped",
|
|
225
|
+
registration: {
|
|
226
|
+
Status: "Skipped",
|
|
227
|
+
Message: "Project registration skipped.",
|
|
228
|
+
Instructions: `Found multiple .uipx files in ${currentDir}: ${solutionFiles.join(", ")}. Run 'uip solution projects add "${projectDir}" <solution.uipx>' to choose one.`
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
if (solutionFiles.length === 1) {
|
|
233
|
+
return {
|
|
234
|
+
status: "found",
|
|
235
|
+
solutionFile: fs.path.join(currentDir, solutionFiles[0])
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const parentDir = fs.path.dirname(currentDir);
|
|
239
|
+
if (parentDir === currentDir) {
|
|
240
|
+
return { status: "notFound" };
|
|
241
|
+
}
|
|
242
|
+
currentDir = parentDir;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function findProjectFile(fs, projectDir) {
|
|
246
|
+
const uiprojPath = fs.path.join(projectDir, "project.uiproj");
|
|
247
|
+
if (await fs.exists(uiprojPath)) {
|
|
248
|
+
return [
|
|
249
|
+
null,
|
|
250
|
+
{
|
|
251
|
+
filePath: uiprojPath,
|
|
252
|
+
fileName: "project.uiproj",
|
|
253
|
+
useProjectJson: false
|
|
254
|
+
}
|
|
255
|
+
];
|
|
256
|
+
}
|
|
257
|
+
const jsonProjectPath = fs.path.join(projectDir, "project.json");
|
|
258
|
+
if (await fs.exists(jsonProjectPath)) {
|
|
259
|
+
return [
|
|
260
|
+
null,
|
|
261
|
+
{
|
|
262
|
+
filePath: jsonProjectPath,
|
|
263
|
+
fileName: "project.json",
|
|
264
|
+
useProjectJson: true
|
|
265
|
+
}
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
return [
|
|
269
|
+
new Error(`No project file found in ${projectDir}. Expected project.uiproj or project.json.`),
|
|
270
|
+
null
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
async function readProjectManifest(fs, filePath, useProjectJson) {
|
|
274
|
+
const [readError, rawContent] = await catchError(fs.readFile(filePath, "utf-8"));
|
|
275
|
+
if (readError || !rawContent) {
|
|
276
|
+
return [readError ?? new Error(`Unable to read ${filePath}.`), null];
|
|
277
|
+
}
|
|
278
|
+
const [parseError, parsed] = catchError(() => JSON.parse(rawContent));
|
|
279
|
+
if (parseError) {
|
|
280
|
+
return [
|
|
281
|
+
new Error(`Invalid JSON in project file: ${parseError.message}`),
|
|
282
|
+
null
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
if (!isRecord(parsed)) {
|
|
286
|
+
return [new Error(`Invalid project file: ${filePath}`), null];
|
|
287
|
+
}
|
|
288
|
+
const designOptions = parsed.designOptions;
|
|
289
|
+
const outputType = useProjectJson && isRecord(designOptions) ? readString(designOptions.outputType) : undefined;
|
|
290
|
+
const projectType = outputType ?? readString(parsed.ProjectType);
|
|
291
|
+
if (!projectType) {
|
|
292
|
+
return [new Error(`ProjectType not found in ${filePath}`), null];
|
|
293
|
+
}
|
|
294
|
+
return [
|
|
295
|
+
null,
|
|
296
|
+
{
|
|
297
|
+
projectType
|
|
298
|
+
}
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
async function readSolutionManifest(fs, solutionFile) {
|
|
302
|
+
const [readError, rawContent] = await catchError(fs.readFile(solutionFile, "utf-8"));
|
|
303
|
+
if (readError || !rawContent) {
|
|
304
|
+
return [
|
|
305
|
+
readError ?? new Error(`Unable to read solution file: ${solutionFile}`),
|
|
306
|
+
null
|
|
307
|
+
];
|
|
308
|
+
}
|
|
309
|
+
const [parseError, parsed] = catchError(() => JSON.parse(rawContent));
|
|
310
|
+
if (parseError) {
|
|
311
|
+
return [
|
|
312
|
+
new Error(`Invalid JSON in solution file: ${parseError.message}`),
|
|
313
|
+
null
|
|
314
|
+
];
|
|
315
|
+
}
|
|
316
|
+
if (!isRecord(parsed)) {
|
|
317
|
+
return [
|
|
318
|
+
new Error(`Invalid solution file: ${solutionFile} must contain a JSON object.`),
|
|
319
|
+
null
|
|
320
|
+
];
|
|
321
|
+
}
|
|
322
|
+
if (!Array.isArray(parsed.Projects)) {
|
|
323
|
+
return [
|
|
324
|
+
new Error(`Invalid solution file: ${solutionFile} must contain a Projects array.`),
|
|
325
|
+
null
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
const projects = [];
|
|
329
|
+
for (const [index, project] of parsed.Projects.entries()) {
|
|
330
|
+
if (!isRecord(project)) {
|
|
331
|
+
return [
|
|
332
|
+
new Error(`Invalid solution file: Projects[${index}] must be an object.`),
|
|
333
|
+
null
|
|
334
|
+
];
|
|
335
|
+
}
|
|
336
|
+
const projectRelativePath = readString(project.ProjectRelativePath);
|
|
337
|
+
if (!projectRelativePath) {
|
|
338
|
+
return [
|
|
339
|
+
new Error(`Invalid solution file: Projects[${index}] is missing ProjectRelativePath. Use 'uip solution projects add' to repair the manifest.`),
|
|
340
|
+
null
|
|
341
|
+
];
|
|
342
|
+
}
|
|
343
|
+
projects.push({
|
|
344
|
+
...project,
|
|
345
|
+
Type: readString(project.Type) ?? "",
|
|
346
|
+
ProjectRelativePath: projectRelativePath,
|
|
347
|
+
Id: readString(project.Id) ?? ""
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return [null, { content: parsed, projects }];
|
|
351
|
+
}
|
|
352
|
+
function readString(value) {
|
|
353
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
354
|
+
}
|
|
355
|
+
function buildRegistrationSuccessInstructions(solutionDir) {
|
|
356
|
+
return [
|
|
357
|
+
"The project is listed in the parent solution manifest.",
|
|
358
|
+
"Packing or uploading the solution will sync solution resources automatically.",
|
|
359
|
+
`To sync resources before packaging, run 'uip solution resources refresh --solution-folder "${solutionDir}"'.`
|
|
360
|
+
].join(`
|
|
361
|
+
`);
|
|
362
|
+
}
|
|
363
|
+
function buildRegistrationFailureInstructions(projectDir, details) {
|
|
364
|
+
return [
|
|
365
|
+
"Automatic solution registration could not complete.",
|
|
366
|
+
`Run 'uip solution projects add "${projectDir}" <solution.uipx>' after checking the project and solution files.`,
|
|
367
|
+
`Details: ${details}`
|
|
368
|
+
].join(`
|
|
369
|
+
`);
|
|
370
|
+
}
|
|
371
|
+
function buildStandaloneInstructions(projectDir) {
|
|
372
|
+
return [
|
|
373
|
+
"No parent solution was found by walking ancestor directories.",
|
|
374
|
+
"Studio Web upload, `flow debug`, and packaging require an enclosing solution.",
|
|
375
|
+
`To link this project to a solution, run 'uip solution init "<SolutionName>"' then 'uip solution projects add "${projectDir}" <SolutionName>.uipx'.`
|
|
376
|
+
].join(`
|
|
377
|
+
`);
|
|
378
|
+
}
|
|
379
|
+
function buildOptedOutInstructions(projectDir) {
|
|
380
|
+
return [
|
|
381
|
+
"Automatic solution registration was skipped because --skip-solution-registration was passed.",
|
|
382
|
+
`To register this project later, run 'uip solution projects add "${projectDir}" <SolutionName>.uipx' from within the solution.`
|
|
383
|
+
].join(`
|
|
384
|
+
`);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export { normalizeProjectType, toPortableRelativePath, prepareProjectLocation, tryRegisterProjectInParentSolution };
|
|
388
|
+
|
|
389
|
+
//# debugId=9F94850867E6D86464756E2164756E21
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
catchError,
|
|
3
|
+
RESULTS,
|
|
4
|
+
OutputFormatter,
|
|
5
|
+
processContext
|
|
6
|
+
} from "./tool-zbyb1ttx.js";
|
|
7
|
+
// package.json
|
|
8
|
+
var package_default = {
|
|
9
|
+
name: "@uipath/rules-tool",
|
|
10
|
+
author: "UiPath",
|
|
11
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
12
|
+
version: "1.204.0",
|
|
13
|
+
description: "Create and manage UiPath Business Rules (DMN) projects.",
|
|
14
|
+
private: false,
|
|
15
|
+
repository: {
|
|
16
|
+
type: "git",
|
|
17
|
+
url: "https://github.com/UiPath/cli.git",
|
|
18
|
+
directory: "packages/rules-tool"
|
|
19
|
+
},
|
|
20
|
+
publishConfig: {
|
|
21
|
+
registry: "https://npm.pkg.github.com/@uipath"
|
|
22
|
+
},
|
|
23
|
+
keywords: [
|
|
24
|
+
"cli-tool"
|
|
25
|
+
],
|
|
26
|
+
type: "module",
|
|
27
|
+
main: "./dist/tool.js",
|
|
28
|
+
exports: {
|
|
29
|
+
".": "./dist/tool.js"
|
|
30
|
+
},
|
|
31
|
+
bin: {
|
|
32
|
+
"rules-tool": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
files: [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
scripts: {
|
|
38
|
+
build: "bun ../../tools/build-tool.ts",
|
|
39
|
+
package: "bun run build && bun pm pack",
|
|
40
|
+
lint: "biome check .",
|
|
41
|
+
"lint:fix": "biome check --write .",
|
|
42
|
+
test: "vitest run",
|
|
43
|
+
"test:coverage": "vitest run --coverage"
|
|
44
|
+
},
|
|
45
|
+
devDependencies: {
|
|
46
|
+
"@types/node": "^25.5.2",
|
|
47
|
+
"@uipath/common": "workspace:*",
|
|
48
|
+
"@uipath/filesystem": "workspace:*",
|
|
49
|
+
"@uipath/maestro-sdk": "workspace:*",
|
|
50
|
+
"@uipath/solution-sdk": "workspace:*",
|
|
51
|
+
commander: "^14.0.3",
|
|
52
|
+
fflate: "^0.8.2",
|
|
53
|
+
typescript: "^7.0.2"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/commands/init.ts
|
|
58
|
+
var RULES_INIT_EXAMPLES = [
|
|
59
|
+
{
|
|
60
|
+
Description: "Create a new business rules project. If the current directory is not already inside a solution, a parent solution named '<project>Solution' is created automatically and the rules project is nested inside it.",
|
|
61
|
+
Command: "uip maestro rules init my-rules-project",
|
|
62
|
+
Output: {
|
|
63
|
+
Code: "RulesInit",
|
|
64
|
+
Data: {
|
|
65
|
+
Status: "Created successfully",
|
|
66
|
+
Path: "/workspace/my-rules-projectSolution/my-rules-project",
|
|
67
|
+
RuleStatus: "Created",
|
|
68
|
+
SolutionRegistration: {
|
|
69
|
+
Status: "Registered",
|
|
70
|
+
Message: "Project registered in parent solution.",
|
|
71
|
+
Solution: "/workspace/my-rules-projectSolution/my-rules-projectSolution.uipx",
|
|
72
|
+
Project: "my-rules-project/project.uiproj",
|
|
73
|
+
ProjectId: "00000000-0000-0000-0000-000000000000",
|
|
74
|
+
Instructions: `The project is listed in the parent solution manifest.
|
|
75
|
+
Packing or uploading the solution will sync solution resources automatically.`
|
|
76
|
+
},
|
|
77
|
+
AutoCreatedSolution: {
|
|
78
|
+
Name: "my-rules-projectSolution",
|
|
79
|
+
Path: "/workspace/my-rules-projectSolution",
|
|
80
|
+
SolutionFile: "/workspace/my-rules-projectSolution/my-rules-projectSolution.uipx"
|
|
81
|
+
},
|
|
82
|
+
ProjectArtifacts: { Created: true },
|
|
83
|
+
NextSteps: `The project is listed in the parent solution manifest.
|
|
84
|
+
Packing or uploading the solution will sync solution resources automatically.`
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
var registerInitCommand = (program) => {
|
|
90
|
+
program.command("init").description("Create a new business rules project seeded with one decision table. If run outside an existing solution, a parent '<name>Solution' is scaffolded automatically and the rules project is created inside it. If run inside an existing solution, the project is added to that solution.").argument("<name>", "Business rules project name").option("--force", "Force initialization even if target directory exists and is not empty").option("--skip-solution-registration", "Do not auto-register this project in the surrounding solution").examples(RULES_INIT_EXAMPLES).trackedAction(processContext, async (name, options) => {
|
|
91
|
+
const { rulesInitAsync } = await import("./rules-init-service-x7paqa63.js");
|
|
92
|
+
const [error, result] = await catchError(rulesInitAsync(name, {
|
|
93
|
+
force: options.force,
|
|
94
|
+
skipRegistration: options.skipSolutionRegistration === true
|
|
95
|
+
}));
|
|
96
|
+
if (error) {
|
|
97
|
+
OutputFormatter.error({
|
|
98
|
+
Result: RESULTS.Failure,
|
|
99
|
+
Message: "Failed to create business rules project",
|
|
100
|
+
Instructions: error.message
|
|
101
|
+
});
|
|
102
|
+
processContext.exit(1);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const data = {
|
|
106
|
+
Status: "Created successfully",
|
|
107
|
+
Path: result.projectDir,
|
|
108
|
+
RuleStatus: result.ruleStatus,
|
|
109
|
+
SolutionRegistration: result.registration
|
|
110
|
+
};
|
|
111
|
+
if (result.autoCreatedSolution) {
|
|
112
|
+
data.AutoCreatedSolution = result.autoCreatedSolution;
|
|
113
|
+
}
|
|
114
|
+
if (result.projectArtifacts) {
|
|
115
|
+
data.ProjectArtifacts = result.projectArtifacts;
|
|
116
|
+
}
|
|
117
|
+
if (result.registration.Instructions) {
|
|
118
|
+
data.NextSteps = result.registration.Instructions;
|
|
119
|
+
}
|
|
120
|
+
OutputFormatter.success({
|
|
121
|
+
Result: RESULTS.Success,
|
|
122
|
+
Code: "RulesInit",
|
|
123
|
+
Data: data
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/tool.ts
|
|
129
|
+
var metadata2 = {
|
|
130
|
+
name: "rules-tool",
|
|
131
|
+
version: package_default.version,
|
|
132
|
+
description: "Create and manage UiPath Business Rules (DMN) projects.",
|
|
133
|
+
commandPrefix: "rules"
|
|
134
|
+
};
|
|
135
|
+
var registerCommands2 = async (program) => {
|
|
136
|
+
registerInitCommand(program);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export { metadata2, registerCommands2 };
|
|
140
|
+
|
|
141
|
+
//# debugId=04D170B1D4E9D59064756E2164756E21
|