trxa-tool 0.0.0-stage → 0.1.1

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 (60) hide show
  1. package/.claude/skills/replay-trxa-testplan/SKILL.md +627 -0
  2. package/LICENSE +120 -0
  3. package/MANUAL.md +548 -0
  4. package/README.md +67 -3
  5. package/STUDIO.md +319 -0
  6. package/dist/analyze.d.ts +58 -0
  7. package/dist/analyze.js +122 -0
  8. package/dist/bpm.d.ts +40 -0
  9. package/dist/bpm.js +60 -0
  10. package/dist/build-test-script.d.ts +24 -0
  11. package/dist/build-test-script.js +40 -0
  12. package/dist/csv.d.ts +1 -0
  13. package/dist/csv.js +11 -0
  14. package/dist/extract.d.ts +14 -0
  15. package/dist/extract.js +34 -0
  16. package/dist/fixture-schema.d.ts +12 -0
  17. package/dist/fixture-schema.js +28 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.js +814 -0
  20. package/dist/library-archive.d.ts +37 -0
  21. package/dist/library-archive.js +106 -0
  22. package/dist/mapping.d.ts +25 -0
  23. package/dist/mapping.js +390 -0
  24. package/dist/normalize.d.ts +21 -0
  25. package/dist/normalize.js +43 -0
  26. package/dist/parse.d.ts +3 -0
  27. package/dist/parse.js +233 -0
  28. package/dist/plan-runner.d.ts +27 -0
  29. package/dist/plan-runner.js +36 -0
  30. package/dist/plan-schema.d.ts +27 -0
  31. package/dist/plan-schema.js +45 -0
  32. package/dist/planrun-schema.d.ts +45 -0
  33. package/dist/planrun-schema.js +87 -0
  34. package/dist/planrun.d.ts +20 -0
  35. package/dist/planrun.js +46 -0
  36. package/dist/report-schema.d.ts +83 -0
  37. package/dist/report-schema.js +89 -0
  38. package/dist/report.d.ts +42 -0
  39. package/dist/report.js +70 -0
  40. package/dist/schema.d.ts +96 -0
  41. package/dist/schema.js +10 -0
  42. package/dist/scrub.d.ts +44 -0
  43. package/dist/scrub.js +166 -0
  44. package/dist/suggest-inputs.d.ts +19 -0
  45. package/dist/suggest-inputs.js +92 -0
  46. package/dist/suite-runner.d.ts +59 -0
  47. package/dist/suite-runner.js +198 -0
  48. package/dist/suite-schema.d.ts +59 -0
  49. package/dist/suite-schema.js +95 -0
  50. package/dist/testcase-schema.d.ts +102 -0
  51. package/dist/testcase-schema.js +132 -0
  52. package/dist/token-usage.d.ts +38 -0
  53. package/dist/token-usage.js +95 -0
  54. package/package.json +58 -6
  55. package/studio/client-dist/assets/index-CgWhGkEn.js +24 -0
  56. package/studio/client-dist/assets/index-CwAUMVCL.css +1 -0
  57. package/studio/client-dist/axtr-icon.svg +5 -0
  58. package/studio/client-dist/favicon.svg +5 -0
  59. package/studio/client-dist/index.html +14 -0
  60. package/studio/server/dist/index.js +1938 -0
package/dist/bpm.js ADDED
@@ -0,0 +1,60 @@
1
+ import JSZip from "jszip";
2
+ import { XMLParser } from "fast-xml-parser";
3
+ function asArray(v) {
4
+ if (v === undefined)
5
+ return [];
6
+ return Array.isArray(v) ? v : [v];
7
+ }
8
+ function parseProcessStepXml(xml) {
9
+ const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: "" });
10
+ const doc = parser.parse(xml);
11
+ const tasks = asArray(doc.Activities?.Task);
12
+ return {
13
+ tasks: tasks.map((t) => ({
14
+ id: String(t.Id ?? ""),
15
+ aotName: String(t.AOTName ?? ""),
16
+ objectType: String(t.ObjectType ?? ""),
17
+ configurationKey: String(t.ConfigurationKey ?? ""),
18
+ layer: String(t.Layer ?? ""),
19
+ model: String(t.Model ?? ""),
20
+ sequence: Number(t.Sequence ?? 0),
21
+ security: asArray(t.Permissions?.Security).map((s) => ({
22
+ roleName: String(s.RoleName ?? ""),
23
+ roleDisplayName: String(s.RoleDisplayName ?? ""),
24
+ dutyName: String(s.DutyName ?? ""),
25
+ dutyDisplayName: String(s.DutyDisplayName ?? ""),
26
+ privilegeName: String(s.PrivilegeName ?? ""),
27
+ privilegeDisplayName: String(s.PrivilegeDisplayName ?? ""),
28
+ accessLevel: String(s.AccessLevel ?? ""),
29
+ isValidRole: String(s.IsValidRole ?? "").toLowerCase() === "true",
30
+ })),
31
+ connectsTo: asArray(t.Connections?.Connection).map((c) => String(c.Target ?? "")),
32
+ })),
33
+ };
34
+ }
35
+ /** Parses the nested BPMPackage.ax7bpm bytes extracted from a .axtr file. Returns null if absent. */
36
+ export async function parseBpmPackage(bytes) {
37
+ if (!bytes)
38
+ return null;
39
+ const zip = await JSZip.loadAsync(bytes);
40
+ // The backslash variant is defensive, not confirmed live: every recording checked so far uses
41
+ // "/", but zip entry names are just stored strings (no path-separator normalization is
42
+ // guaranteed across the tools that can produce a BPMPackage.ax7bpm), so this is here in case a
43
+ // Windows-authored zip ever stores "Recording\ProcessStep.xml" literally instead.
44
+ const entry = zip.file("Recording/ProcessStep.xml") ?? zip.file("Recording\\ProcessStep.xml") ?? null;
45
+ if (!entry)
46
+ return null;
47
+ const xml = await entry.async("string");
48
+ return parseProcessStepXml(xml);
49
+ }
50
+ /** Every distinct privilege that appears across all tasks -- a starting point for a security preflight check. */
51
+ export function distinctPrivileges(pkg) {
52
+ const set = new Set();
53
+ for (const task of pkg.tasks) {
54
+ for (const sec of task.security) {
55
+ if (sec.privilegeName)
56
+ set.add(sec.privilegeName);
57
+ }
58
+ }
59
+ return [...set];
60
+ }
@@ -0,0 +1,24 @@
1
+ import { type TestScript } from "./normalize.js";
2
+ /** Mechanics only, no hints -- the raw shape mapStep/suggestInputs operate on. */
3
+ export declare function loadTestScript(axtrPath: string): Promise<TestScript>;
4
+ /** Full `testscript.json` shape: mechanics plus per-step hints and security info. */
5
+ export declare function buildTestScript(axtrPath: string): Promise<{
6
+ name: string;
7
+ canonicalId: string;
8
+ description: string;
9
+ steps: {
10
+ sequence: number;
11
+ description: string;
12
+ formName: string | null;
13
+ nodeType: "Scope" | "MenuItemUserAction" | "CommandUserAction" | "PropertyUserAction" | "Unknown";
14
+ node: import("./schema.js").RecordingNode;
15
+ hint: import("./mapping.js").McpToolHint | null;
16
+ }[];
17
+ security: {
18
+ requiredPrivileges: string[];
19
+ formsVisited: {
20
+ aotName: string;
21
+ objectType: string;
22
+ }[];
23
+ } | null;
24
+ }>;
@@ -0,0 +1,40 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { extractAxtr } from "./extract.js";
3
+ import { parseRecordingXml } from "./parse.js";
4
+ import { normalizeRecording } from "./normalize.js";
5
+ import { mapStep } from "./mapping.js";
6
+ import { parseBpmPackage, distinctPrivileges } from "./bpm.js";
7
+ /** Mechanics only, no hints -- the raw shape mapStep/suggestInputs operate on. */
8
+ export async function loadTestScript(axtrPath) {
9
+ const bytes = await readFile(axtrPath);
10
+ const extracted = await extractAxtr(bytes);
11
+ const recording = parseRecordingXml(extracted.recordingXml);
12
+ return normalizeRecording(recording);
13
+ }
14
+ /** Full `testscript.json` shape: mechanics plus per-step hints and security info. */
15
+ export async function buildTestScript(axtrPath) {
16
+ const bytes = await readFile(axtrPath);
17
+ const extracted = await extractAxtr(bytes);
18
+ const recording = parseRecordingXml(extracted.recordingXml);
19
+ const script = normalizeRecording(recording);
20
+ const bpm = await parseBpmPackage(extracted.bpmPackageBytes);
21
+ return {
22
+ name: script.name,
23
+ canonicalId: script.canonicalId,
24
+ description: script.description,
25
+ steps: script.steps.map((step) => ({
26
+ sequence: step.sequence,
27
+ description: step.description,
28
+ formName: step.formName,
29
+ nodeType: step.node.kind,
30
+ node: step.node,
31
+ hint: mapStep(step),
32
+ })),
33
+ security: bpm
34
+ ? {
35
+ requiredPrivileges: distinctPrivileges(bpm),
36
+ formsVisited: bpm.tasks.map((t) => ({ aotName: t.aotName, objectType: t.objectType })),
37
+ }
38
+ : null,
39
+ };
40
+ }
package/dist/csv.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function toCsv(header: string[], rows: string[][]): string;
package/dist/csv.js ADDED
@@ -0,0 +1,11 @@
1
+ /** Minimal RFC4180 CSV writer -- no dependency needed for the handful of columns this repo emits. */
2
+ function escapeCell(value) {
3
+ if (/[",\r\n]/.test(value)) {
4
+ return `"${value.replace(/"/g, '""')}"`;
5
+ }
6
+ return value;
7
+ }
8
+ export function toCsv(header, rows) {
9
+ const lines = [header, ...rows].map((row) => row.map(escapeCell).join(","));
10
+ return lines.join("\r\n") + "\r\n";
11
+ }
@@ -0,0 +1,14 @@
1
+ export declare const RECORDING_ENTRY = "Recording.xml";
2
+ export declare const RESOURCE_ENTRY = "recording_resource.xml";
3
+ export declare const BPM_ENTRY = "BPMPackage.ax7bpm";
4
+ export interface ExtractedAxtr {
5
+ recordingXml: string;
6
+ resourceXml: string | null;
7
+ /** Raw bytes of the nested BPMPackage.ax7bpm zip, if present. Parsed separately by bpm.ts. */
8
+ bpmPackageBytes: Buffer | null;
9
+ }
10
+ /**
11
+ * Unzips a .axtr file (confirmed to be a plain ZIP via its PK\x03\x04 header) and pulls out
12
+ * the entries D365FO's own UserSecGovTaskRecorderUtil::GetRecordingFromPackage reads.
13
+ */
14
+ export declare function extractAxtr(fileBytes: Buffer): Promise<ExtractedAxtr>;
@@ -0,0 +1,34 @@
1
+ import JSZip from "jszip";
2
+ export const RECORDING_ENTRY = "Recording.xml";
3
+ export const RESOURCE_ENTRY = "recording_resource.xml";
4
+ export const BPM_ENTRY = "BPMPackage.ax7bpm";
5
+ /**
6
+ * Unzips a .axtr file (confirmed to be a plain ZIP via its PK\x03\x04 header) and pulls out
7
+ * the entries D365FO's own UserSecGovTaskRecorderUtil::GetRecordingFromPackage reads.
8
+ */
9
+ export async function extractAxtr(fileBytes) {
10
+ const zip = await JSZip.loadAsync(fileBytes);
11
+ const recordingEntry = findEntry(zip, RECORDING_ENTRY);
12
+ if (!recordingEntry) {
13
+ throw new Error(`.axtr package does not contain a ${RECORDING_ENTRY} entry`);
14
+ }
15
+ const resourceEntry = findEntry(zip, RESOURCE_ENTRY);
16
+ const bpmEntry = findEntry(zip, BPM_ENTRY);
17
+ return {
18
+ recordingXml: await recordingEntry.async("string"),
19
+ resourceXml: resourceEntry ? await resourceEntry.async("string") : null,
20
+ bpmPackageBytes: bpmEntry ? await bpmEntry.async("nodebuffer") : null,
21
+ };
22
+ }
23
+ /** Case-insensitive fallback is defensive, not confirmed live: every `.axtr` checked so far uses
24
+ * the exact casing in `RECORDING_ENTRY`/`RESOURCE_ENTRY`/`BPM_ENTRY` above. Zip entry names are
25
+ * just stored strings with no case-folding guarantee across whatever tool produced the archive,
26
+ * so this exists in case one ever doesn't match exactly -- same rationale as `bpm.ts`'s backslash
27
+ * path fallback. */
28
+ function findEntry(zip, name) {
29
+ const exact = zip.file(name);
30
+ if (exact)
31
+ return exact;
32
+ const match = Object.values(zip.files).find((f) => !f.dir && f.name.toLowerCase() === name.toLowerCase());
33
+ return match ?? null;
34
+ }
@@ -0,0 +1,12 @@
1
+ /** Concrete input values for a TestCase's `inputs`, kept separate so the same test
2
+ * case can run against different data (e.g. "US company" vs "EU company") without editing it. */
3
+ export interface Fixture {
4
+ testCaseId: string;
5
+ name: string;
6
+ /** Short free-text description shown alongside `name` in Studio's Fixtures list (e.g. "EU
7
+ * vendor, small item") -- distinct from `name`, which stays a filename-safe identifier
8
+ * referenced by suites' `inputBindings`. Purely descriptive; nothing resolves against it. */
9
+ description: string;
10
+ values: Record<string, string>;
11
+ }
12
+ export declare function validateFixture(value: unknown): Fixture;
@@ -0,0 +1,28 @@
1
+ function fail(field, reason) {
2
+ throw new Error(`Invalid Fixture: ${field} ${reason}`);
3
+ }
4
+ function assertString(value, field) {
5
+ if (typeof value !== "string" || value.length === 0)
6
+ fail(field, "must be a non-empty string");
7
+ }
8
+ export function validateFixture(value) {
9
+ if (typeof value !== "object" || value === null)
10
+ fail("fixture", "must be an object");
11
+ const v = value;
12
+ assertString(v.testCaseId, "testCaseId");
13
+ assertString(v.name, "name");
14
+ assertString(v.description, "description");
15
+ if (typeof v.values !== "object" || v.values === null || Array.isArray(v.values)) {
16
+ fail("values", "must be an object mapping param names to string values");
17
+ }
18
+ for (const [key, val] of Object.entries(v.values)) {
19
+ if (typeof val !== "string")
20
+ fail(`values.${key}`, "must be a string");
21
+ }
22
+ return {
23
+ testCaseId: v.testCaseId,
24
+ name: v.name,
25
+ description: v.description,
26
+ values: v.values,
27
+ };
28
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { loadTestScript, buildTestScript } from "./build-test-script.js";
3
+ export { loadTestScript, buildTestScript };