spana-test 0.0.2 → 0.2.0

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 (124) hide show
  1. package/.agents/skills/spana-testing/SKILL.md +304 -0
  2. package/README.md +308 -88
  3. package/dist/agent/index.d.ts +110 -0
  4. package/dist/agent/index.js +25 -0
  5. package/dist/allure-PTTVORQ6.js +124 -0
  6. package/dist/allure-PTTVORQ6.js.map +1 -0
  7. package/dist/android-PAPJJWVN.js +34 -0
  8. package/dist/android-PAPJJWVN.js.map +1 -0
  9. package/dist/chunk-3FSZNKEF.js +62 -0
  10. package/dist/chunk-3FSZNKEF.js.map +1 -0
  11. package/dist/chunk-3YR4GUGE.js +249 -0
  12. package/dist/chunk-3YR4GUGE.js.map +1 -0
  13. package/dist/{discover-XIRJTZ7Z.js → chunk-AEKDFFPJ.js} +12 -5
  14. package/dist/{discover-XIRJTZ7Z.js.map → chunk-AEKDFFPJ.js.map} +1 -1
  15. package/dist/chunk-BF37W5EG.js +125 -0
  16. package/dist/chunk-BF37W5EG.js.map +1 -0
  17. package/dist/chunk-DGUM43GV.js +11 -0
  18. package/dist/chunk-DGUM43GV.js.map +1 -0
  19. package/dist/chunk-EXLUY7KT.js +21 -0
  20. package/dist/chunk-EXLUY7KT.js.map +1 -0
  21. package/dist/chunk-FNDOEMOL.js +62 -0
  22. package/dist/chunk-FNDOEMOL.js.map +1 -0
  23. package/dist/{chunk-CYEDLQJ4.js → chunk-GZK22EIE.js} +76 -102
  24. package/dist/chunk-GZK22EIE.js.map +1 -0
  25. package/dist/chunk-HWFDXIXR.js +183 -0
  26. package/dist/chunk-HWFDXIXR.js.map +1 -0
  27. package/dist/chunk-IJIASIX5.js +314 -0
  28. package/dist/chunk-IJIASIX5.js.map +1 -0
  29. package/dist/chunk-KJPHH2TW.js +168 -0
  30. package/dist/chunk-KJPHH2TW.js.map +1 -0
  31. package/dist/chunk-L7MFJF46.js +137 -0
  32. package/dist/chunk-L7MFJF46.js.map +1 -0
  33. package/dist/chunk-MRH7SK52.js +134 -0
  34. package/dist/chunk-MRH7SK52.js.map +1 -0
  35. package/dist/chunk-P7JQRLP4.js +114 -0
  36. package/dist/chunk-P7JQRLP4.js.map +1 -0
  37. package/dist/chunk-S2XNAKSO.js +1087 -0
  38. package/dist/chunk-S2XNAKSO.js.map +1 -0
  39. package/dist/chunk-S4R4OR7T.js +358 -0
  40. package/dist/chunk-S4R4OR7T.js.map +1 -0
  41. package/dist/chunk-SFBRFB2N.js +277 -0
  42. package/dist/chunk-SFBRFB2N.js.map +1 -0
  43. package/dist/chunk-VNYF5BHX.js +494 -0
  44. package/dist/chunk-VNYF5BHX.js.map +1 -0
  45. package/dist/chunk-WBU34APM.js +38 -0
  46. package/dist/chunk-WBU34APM.js.map +1 -0
  47. package/dist/chunk-WQ4GXUUE.js +2402 -0
  48. package/dist/chunk-WQ4GXUUE.js.map +1 -0
  49. package/dist/chunk-YBZCOQXJ.js +311 -0
  50. package/dist/chunk-YBZCOQXJ.js.map +1 -0
  51. package/dist/cli.js +428 -34
  52. package/dist/cli.js.map +1 -1
  53. package/dist/compiler-74VGKZO6.js +312 -0
  54. package/dist/compiler-74VGKZO6.js.map +1 -0
  55. package/dist/config-loader-BJJ3IJJ7.js +9 -0
  56. package/dist/config-loader-BJJ3IJJ7.js.map +1 -0
  57. package/dist/console-XWKUTP3D.js +164 -0
  58. package/dist/console-XWKUTP3D.js.map +1 -0
  59. package/dist/coordinator-BbUjvvnX.d.ts +383 -0
  60. package/dist/discover-KZKXHZZA.js +14 -0
  61. package/dist/discover-KZKXHZZA.js.map +1 -0
  62. package/dist/doctor-command-T2UX5RV5.js +732 -0
  63. package/dist/doctor-command-T2UX5RV5.js.map +1 -0
  64. package/dist/element-DZ0HyJ3C.d.ts +25 -0
  65. package/dist/flow-BUC9Mf8W.d.ts +128 -0
  66. package/dist/gherkin/steps.d.ts +32 -0
  67. package/dist/gherkin/steps.js +39 -0
  68. package/dist/gherkin/steps.js.map +1 -0
  69. package/dist/{html-GRB34S6X.js → html-GE6Q4DCG.js} +76 -22
  70. package/dist/html-GE6Q4DCG.js.map +1 -0
  71. package/dist/index.d.ts +159 -144
  72. package/dist/index.js +39 -165
  73. package/dist/index.js.map +1 -1
  74. package/dist/init-command-GVMRXIMY.js +121 -0
  75. package/dist/init-command-GVMRXIMY.js.map +1 -0
  76. package/dist/init-flow-command-R76AXF4Z.js +34 -0
  77. package/dist/init-flow-command-R76AXF4Z.js.map +1 -0
  78. package/dist/installer-YZJ4DV3F.js +22 -0
  79. package/dist/installer-YZJ4DV3F.js.map +1 -0
  80. package/dist/ios-ZW6XVNLG.js +50 -0
  81. package/dist/ios-ZW6XVNLG.js.map +1 -0
  82. package/dist/json-KS67BZYU.js +39 -0
  83. package/dist/json-KS67BZYU.js.map +1 -0
  84. package/dist/{junit-NAGZJOGQ.js → junit-HLC62MK6.js} +15 -4
  85. package/dist/junit-HLC62MK6.js.map +1 -0
  86. package/dist/provider-A57C3MU6.js +12 -0
  87. package/dist/provider-A57C3MU6.js.map +1 -0
  88. package/dist/redact-U72BUBBR.js +77 -0
  89. package/dist/redact-U72BUBBR.js.map +1 -0
  90. package/dist/runner-UXNHVVGG.js +20 -0
  91. package/dist/runner-UXNHVVGG.js.map +1 -0
  92. package/dist/server-W7OA3DDN.js +530 -0
  93. package/dist/server-W7OA3DDN.js.map +1 -0
  94. package/dist/session-TMNOKYLG.js +17 -0
  95. package/dist/session-TMNOKYLG.js.map +1 -0
  96. package/dist/studio-command-6VHTHDUK.js +24 -0
  97. package/dist/studio-command-6VHTHDUK.js.map +1 -0
  98. package/dist/test-command-AHMOZLV4.js +2852 -0
  99. package/dist/test-command-AHMOZLV4.js.map +1 -0
  100. package/dist/validator-35624P7S.js +20 -0
  101. package/dist/validator-35624P7S.js.map +1 -0
  102. package/package.json +41 -4
  103. package/studio-dist/assets/index-DC6DIXfl.js +188 -0
  104. package/studio-dist/assets/index-DDKsnBwD.css +1 -0
  105. package/studio-dist/index.html +13 -0
  106. package/dist/chunk-CYEDLQJ4.js.map +0 -1
  107. package/dist/chunk-PVNNKPBW.js +0 -64
  108. package/dist/chunk-PVNNKPBW.js.map +0 -1
  109. package/dist/chunk-VZZH66U5.js +0 -1781
  110. package/dist/chunk-VZZH66U5.js.map +0 -1
  111. package/dist/console-GPV3M3PC.js +0 -71
  112. package/dist/console-GPV3M3PC.js.map +0 -1
  113. package/dist/html-GRB34S6X.js.map +0 -1
  114. package/dist/json-FK2NSRGC.js +0 -20
  115. package/dist/json-FK2NSRGC.js.map +0 -1
  116. package/dist/junit-NAGZJOGQ.js.map +0 -1
  117. package/dist/runner-LBQUCG3K.js +0 -12
  118. package/dist/session-U7VP5J2C.js +0 -122
  119. package/dist/session-U7VP5J2C.js.map +0 -1
  120. package/dist/test-command-WPYLJYIK.js +0 -636
  121. package/dist/test-command-WPYLJYIK.js.map +0 -1
  122. package/dist/validator-J4YSBB66.js +0 -33
  123. package/dist/validator-J4YSBB66.js.map +0 -1
  124. /package/dist/{runner-LBQUCG3K.js.map → agent/index.js.map} +0 -0
@@ -0,0 +1,183 @@
1
+ // src/cli/scaffolds.ts
2
+ var INIT_PRESETS = /* @__PURE__ */ new Set([
3
+ "local-web",
4
+ "local-react-native",
5
+ "browserstack",
6
+ "saucelabs"
7
+ ]);
8
+ var FLOW_STUB_PRESETS = /* @__PURE__ */ new Set(["blank", "smoke", "auth"]);
9
+ function isInitPreset(value) {
10
+ return INIT_PRESETS.has(value);
11
+ }
12
+ function isFlowStubPreset(value) {
13
+ return FLOW_STUB_PRESETS.has(value);
14
+ }
15
+ function examplePlatformsForPreset(preset) {
16
+ switch (preset) {
17
+ case "local-web":
18
+ return ["web"];
19
+ case "local-react-native":
20
+ case "browserstack":
21
+ case "saucelabs":
22
+ return ["android", "ios"];
23
+ }
24
+ }
25
+ function slugifyFlowName(name) {
26
+ return name.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-+|-+$/g, "").replaceAll(/-{2,}/g, "-");
27
+ }
28
+ function generateConfigForPreset(preset) {
29
+ switch (preset) {
30
+ case "local-web":
31
+ return `import { defineConfig } from "spana-test";
32
+
33
+ export default defineConfig({
34
+ apps: {
35
+ web: { url: "http://localhost:3000" },
36
+ },
37
+ platforms: ["web"],
38
+ flowDir: "./flows",
39
+ reporters: ["console"],
40
+ defaults: {
41
+ waitTimeout: 5_000,
42
+ },
43
+ });
44
+ `;
45
+ case "local-react-native":
46
+ return `import { defineConfig } from "spana-test";
47
+
48
+ export default defineConfig({
49
+ apps: {
50
+ android: { packageName: "com.example.myapp" },
51
+ ios: { bundleId: "com.example.myapp" },
52
+ },
53
+ platforms: ["android", "ios"],
54
+ flowDir: "./flows",
55
+ reporters: ["console"],
56
+ defaults: {
57
+ waitTimeout: 5_000,
58
+ },
59
+ });
60
+ `;
61
+ case "browserstack":
62
+ return `import { defineConfig } from "spana-test";
63
+
64
+ export default defineConfig({
65
+ apps: {
66
+ android: { packageName: "com.example.myapp" },
67
+ ios: { bundleId: "com.example.myapp" },
68
+ },
69
+ platforms: ["android", "ios"],
70
+ flowDir: "./flows",
71
+ reporters: ["console", "json"],
72
+ execution: {
73
+ mode: "appium",
74
+ appium: {
75
+ serverUrl: "https://USERNAME:ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",
76
+ browserstack: {
77
+ local: { enabled: true },
78
+ },
79
+ capabilities: {
80
+ "appium:project": "my-spana-project",
81
+ },
82
+ },
83
+ },
84
+ });
85
+ `;
86
+ case "saucelabs":
87
+ return `import { defineConfig } from "spana-test";
88
+
89
+ export default defineConfig({
90
+ apps: {
91
+ android: { packageName: "com.example.myapp" },
92
+ ios: { bundleId: "com.example.myapp" },
93
+ },
94
+ platforms: ["android", "ios"],
95
+ flowDir: "./flows",
96
+ reporters: ["console", "json"],
97
+ execution: {
98
+ mode: "appium",
99
+ appium: {
100
+ serverUrl: "https://USERNAME:ACCESS_KEY@ondemand.us-west-1.saucelabs.com/wd/hub",
101
+ saucelabs: {
102
+ connect: { enabled: true },
103
+ },
104
+ capabilities: {
105
+ "appium:build": "spana-local-build",
106
+ },
107
+ },
108
+ },
109
+ });
110
+ `;
111
+ }
112
+ }
113
+ function generateExampleFlow(platforms) {
114
+ const platformsLiteral = platforms.map((platform) => `"${platform}"`).join(", ");
115
+ return `import { flow } from "spana-test";
116
+
117
+ export default flow(
118
+ "Example - app loads successfully",
119
+ { tags: ["smoke"], platforms: [${platformsLiteral}] },
120
+ async ({ expect }) => {
121
+ // Replace the selector below with one from your app.
122
+ // Run "spana selectors" to discover available selectors.
123
+ await expect({ text: "Hello" }).toBeVisible();
124
+ },
125
+ );
126
+ `;
127
+ }
128
+ function renderFlowConfig(options) {
129
+ const entries = [];
130
+ if (options.tags.length > 0) {
131
+ entries.push(`tags: [${options.tags.map((tag) => `"${tag}"`).join(", ")}]`);
132
+ }
133
+ if (options.platforms.length > 0) {
134
+ entries.push(`platforms: [${options.platforms.map((platform) => `"${platform}"`).join(", ")}]`);
135
+ }
136
+ return entries.length > 0 ? `{ ${entries.join(", ")} }` : null;
137
+ }
138
+ function bodyForPreset(preset) {
139
+ switch (preset) {
140
+ case "blank":
141
+ return ` async ({ app }) => {
142
+ // TODO: add steps for this flow.
143
+ void app;
144
+ },`;
145
+ case "auth":
146
+ return ` async ({ app, expect }) => {
147
+ // TODO: replace the placeholder selectors with stable testIDs or accessibility labels.
148
+ await app.tap({ testID: "login-button" });
149
+ await expect({ text: "Welcome" }).toBeVisible();
150
+ },`;
151
+ case "smoke":
152
+ default:
153
+ return ` async ({ expect }) => {
154
+ // TODO: replace the placeholder selector with one that is stable in your app.
155
+ await expect({ text: "Hello" }).toBeVisible();
156
+ },`;
157
+ }
158
+ }
159
+ function generateFlowStub(options) {
160
+ const preset = options.preset ?? "smoke";
161
+ const tags = [.../* @__PURE__ */ new Set([...options.tags ?? [], ...preset === "smoke" ? ["smoke"] : []])];
162
+ const platforms = options.platforms ?? [];
163
+ const configLiteral = renderFlowConfig({ tags, platforms });
164
+ return `import { flow } from "spana-test";
165
+
166
+ export default flow(
167
+ "${options.name}",
168
+ ${configLiteral ? ` ${configLiteral},
169
+ ` : ""}${bodyForPreset(preset)}
170
+ );
171
+ `;
172
+ }
173
+
174
+ export {
175
+ isInitPreset,
176
+ isFlowStubPreset,
177
+ examplePlatformsForPreset,
178
+ slugifyFlowName,
179
+ generateConfigForPreset,
180
+ generateExampleFlow,
181
+ generateFlowStub
182
+ };
183
+ //# sourceMappingURL=chunk-HWFDXIXR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/scaffolds.ts"],"sourcesContent":["import type { Platform } from \"../schemas/selector.js\";\n\nexport type InitPreset = \"local-web\" | \"local-react-native\" | \"browserstack\" | \"saucelabs\";\nexport type FlowStubPreset = \"blank\" | \"smoke\" | \"auth\";\n\nconst INIT_PRESETS: ReadonlySet<InitPreset> = new Set([\n \"local-web\",\n \"local-react-native\",\n \"browserstack\",\n \"saucelabs\",\n]);\n\nconst FLOW_STUB_PRESETS: ReadonlySet<FlowStubPreset> = new Set([\"blank\", \"smoke\", \"auth\"]);\n\nexport function isInitPreset(value: string): value is InitPreset {\n return INIT_PRESETS.has(value as InitPreset);\n}\n\nexport function isFlowStubPreset(value: string): value is FlowStubPreset {\n return FLOW_STUB_PRESETS.has(value as FlowStubPreset);\n}\n\nexport function examplePlatformsForPreset(preset: InitPreset): Platform[] {\n switch (preset) {\n case \"local-web\":\n return [\"web\"];\n case \"local-react-native\":\n case \"browserstack\":\n case \"saucelabs\":\n return [\"android\", \"ios\"];\n }\n}\n\nexport function slugifyFlowName(name: string): string {\n return name\n .trim()\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/g, \"-\")\n .replaceAll(/^-+|-+$/g, \"\")\n .replaceAll(/-{2,}/g, \"-\");\n}\n\nexport function generateConfigForPreset(preset: InitPreset): string {\n switch (preset) {\n case \"local-web\":\n return `import { defineConfig } from \"spana-test\";\n\nexport default defineConfig({\n apps: {\n web: { url: \"http://localhost:3000\" },\n },\n platforms: [\"web\"],\n flowDir: \"./flows\",\n reporters: [\"console\"],\n defaults: {\n waitTimeout: 5_000,\n },\n});\n`;\n case \"local-react-native\":\n return `import { defineConfig } from \"spana-test\";\n\nexport default defineConfig({\n apps: {\n android: { packageName: \"com.example.myapp\" },\n ios: { bundleId: \"com.example.myapp\" },\n },\n platforms: [\"android\", \"ios\"],\n flowDir: \"./flows\",\n reporters: [\"console\"],\n defaults: {\n waitTimeout: 5_000,\n },\n});\n`;\n case \"browserstack\":\n return `import { defineConfig } from \"spana-test\";\n\nexport default defineConfig({\n apps: {\n android: { packageName: \"com.example.myapp\" },\n ios: { bundleId: \"com.example.myapp\" },\n },\n platforms: [\"android\", \"ios\"],\n flowDir: \"./flows\",\n reporters: [\"console\", \"json\"],\n execution: {\n mode: \"appium\",\n appium: {\n serverUrl: \"https://USERNAME:ACCESS_KEY@hub-cloud.browserstack.com/wd/hub\",\n browserstack: {\n local: { enabled: true },\n },\n capabilities: {\n \"appium:project\": \"my-spana-project\",\n },\n },\n },\n});\n`;\n case \"saucelabs\":\n return `import { defineConfig } from \"spana-test\";\n\nexport default defineConfig({\n apps: {\n android: { packageName: \"com.example.myapp\" },\n ios: { bundleId: \"com.example.myapp\" },\n },\n platforms: [\"android\", \"ios\"],\n flowDir: \"./flows\",\n reporters: [\"console\", \"json\"],\n execution: {\n mode: \"appium\",\n appium: {\n serverUrl: \"https://USERNAME:ACCESS_KEY@ondemand.us-west-1.saucelabs.com/wd/hub\",\n saucelabs: {\n connect: { enabled: true },\n },\n capabilities: {\n \"appium:build\": \"spana-local-build\",\n },\n },\n },\n});\n`;\n }\n}\n\nexport function generateExampleFlow(platforms: Platform[]): string {\n const platformsLiteral = platforms.map((platform) => `\"${platform}\"`).join(\", \");\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"Example - app loads successfully\",\n { tags: [\"smoke\"], platforms: [${platformsLiteral}] },\n async ({ expect }) => {\n // Replace the selector below with one from your app.\n // Run \"spana selectors\" to discover available selectors.\n await expect({ text: \"Hello\" }).toBeVisible();\n },\n);\n`;\n}\n\nfunction renderFlowConfig(options: { tags: string[]; platforms: Platform[] }): string | null {\n const entries: string[] = [];\n if (options.tags.length > 0) {\n entries.push(`tags: [${options.tags.map((tag) => `\"${tag}\"`).join(\", \")}]`);\n }\n if (options.platforms.length > 0) {\n entries.push(`platforms: [${options.platforms.map((platform) => `\"${platform}\"`).join(\", \")}]`);\n }\n return entries.length > 0 ? `{ ${entries.join(\", \")} }` : null;\n}\n\nfunction bodyForPreset(preset: FlowStubPreset): string {\n switch (preset) {\n case \"blank\":\n return ` async ({ app }) => {\n // TODO: add steps for this flow.\n void app;\n },`;\n case \"auth\":\n return ` async ({ app, expect }) => {\n // TODO: replace the placeholder selectors with stable testIDs or accessibility labels.\n await app.tap({ testID: \"login-button\" });\n await expect({ text: \"Welcome\" }).toBeVisible();\n },`;\n case \"smoke\":\n default:\n return ` async ({ expect }) => {\n // TODO: replace the placeholder selector with one that is stable in your app.\n await expect({ text: \"Hello\" }).toBeVisible();\n },`;\n }\n}\n\nexport function generateFlowStub(options: {\n name: string;\n platforms?: Platform[];\n tags?: string[];\n preset?: FlowStubPreset;\n}): string {\n const preset = options.preset ?? \"smoke\";\n const tags = [...new Set([...(options.tags ?? []), ...(preset === \"smoke\" ? [\"smoke\"] : [])])];\n const platforms = options.platforms ?? [];\n const configLiteral = renderFlowConfig({ tags, platforms });\n\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"${options.name}\",\n${configLiteral ? ` ${configLiteral},\\n` : \"\"}${bodyForPreset(preset)}\n);\n`;\n}\n"],"mappings":";AAKA,IAAM,eAAwC,oBAAI,IAAI;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,oBAAiD,oBAAI,IAAI,CAAC,SAAS,SAAS,MAAM,CAAC;AAElF,SAAS,aAAa,OAAoC;AAC/D,SAAO,aAAa,IAAI,KAAmB;AAC7C;AAEO,SAAS,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
+ } from "./chunk-FNDOEMOL.js";
10
+
11
+ // src/core/validator.ts
12
+ import { readFile, stat } from "fs/promises";
13
+ import { dirname, resolve } from "path";
14
+ var FLOWS_DOCS_URL = buildDocsUrl("/writing-tests/flows");
15
+ var GHERKIN_DOCS_URL = buildDocsUrl("/writing-tests/gherkin");
16
+ var VALIDATE_DOCS_URL = buildDocsUrl("/cli/agent-commands");
17
+ function createValidationIssue(file, code, error, suggestedFix, docsUrl = FLOWS_DOCS_URL) {
18
+ return { file, code, error, severity: "error", suggestedFix, docsUrl };
19
+ }
20
+ function createValidationWarning(file, code, message, suggestedFix, docsUrl = FLOWS_DOCS_URL) {
21
+ return { file, code, message, severity: "warning", suggestedFix, docsUrl };
22
+ }
23
+ function isValidationIssue(result) {
24
+ return result.severity === "error";
25
+ }
26
+ function isValidationWarning(result) {
27
+ return result.severity === "warning";
28
+ }
29
+ function summarizeValidationResults(results) {
30
+ let errorCount = 0;
31
+ let warningCount = 0;
32
+ for (const result of results) {
33
+ if (isValidationIssue(result)) {
34
+ errorCount++;
35
+ } else {
36
+ warningCount++;
37
+ }
38
+ }
39
+ return { errorCount, warningCount };
40
+ }
41
+ async function validateFlowFile(filePath) {
42
+ try {
43
+ const absolutePath = resolve(filePath);
44
+ const mod = await import(absolutePath);
45
+ if (!mod.default) {
46
+ return createValidationIssue(
47
+ filePath,
48
+ "MISSING_DEFAULT_EXPORT",
49
+ "No default export found",
50
+ "Export a single default FlowDefinition from this file."
51
+ );
52
+ }
53
+ const def = mod.default;
54
+ if (!def.name || typeof def.fn !== "function") {
55
+ return createValidationIssue(
56
+ filePath,
57
+ "INVALID_FLOW_DEFINITION",
58
+ "Invalid flow definition: missing name or fn",
59
+ "Export a default flow() definition with both a name and an async fn."
60
+ );
61
+ }
62
+ return null;
63
+ } catch (e) {
64
+ return createValidationIssue(
65
+ filePath,
66
+ "FLOW_LOAD_FAILED",
67
+ `Failed to import: ${e instanceof Error ? e.message : String(e)}`,
68
+ "Fix the file's syntax or runtime error, then run `spana validate` again."
69
+ );
70
+ }
71
+ }
72
+ async function validateFlows(paths) {
73
+ const errors = [];
74
+ for (const path of paths) {
75
+ const err = await validateFlowFile(path);
76
+ if (err) errors.push(err);
77
+ }
78
+ return errors;
79
+ }
80
+ var VALID_PLATFORMS = /* @__PURE__ */ new Set(["web", "android", "ios"]);
81
+ var MAX_FLOW_LINES = 80;
82
+ var MAX_NESTING_DEPTH = 3;
83
+ var MAX_CONDITIONAL_OPERATORS = 3;
84
+ async function validateProject(flowDir) {
85
+ const results = [];
86
+ let paths;
87
+ try {
88
+ paths = await discoverFlows(flowDir);
89
+ } catch {
90
+ results.push(
91
+ createValidationIssue(
92
+ flowDir,
93
+ "FLOW_DIRECTORY_MISSING",
94
+ "Flow directory does not exist",
95
+ "Create the flow directory or pass the correct path to `spana validate`.",
96
+ VALIDATE_DOCS_URL
97
+ )
98
+ );
99
+ return results;
100
+ }
101
+ if (paths.length === 0) {
102
+ results.push(
103
+ createValidationIssue(
104
+ flowDir,
105
+ "NO_FLOW_FILES",
106
+ "No flow files found",
107
+ "Add .flow.ts or .feature files under the configured flow directory.",
108
+ VALIDATE_DOCS_URL
109
+ )
110
+ );
111
+ return results;
112
+ }
113
+ const hasFeatureFiles = paths.some((path) => path.endsWith(".feature"));
114
+ if (hasFeatureFiles) {
115
+ const flowDirStats = await stat(resolve(flowDir)).catch(() => null);
116
+ const stepSearchDir = flowDirStats?.isDirectory() ? flowDir : dirname(flowDir);
117
+ const stepPaths = await discoverStepFiles(stepSearchDir);
118
+ if (stepPaths.length > 0) {
119
+ try {
120
+ await loadStepFiles(stepPaths);
121
+ } catch (e) {
122
+ results.push(
123
+ createValidationIssue(
124
+ flowDir,
125
+ "STEP_DEFINITION_LOAD_FAILED",
126
+ `Failed to load step definitions: ${e instanceof Error ? e.message : String(e)}`,
127
+ "Fix the referenced step definition files and ensure they can be imported cleanly.",
128
+ GHERKIN_DOCS_URL
129
+ )
130
+ );
131
+ return results;
132
+ }
133
+ }
134
+ }
135
+ const flowNames = /* @__PURE__ */ new Map();
136
+ for (const p of paths) {
137
+ try {
138
+ const defs = await loadTestSource(p);
139
+ for (const def of defs) {
140
+ if (!def?.name || typeof def.fn !== "function") {
141
+ results.push(
142
+ createValidationIssue(
143
+ p,
144
+ "INVALID_FLOW_DEFINITION",
145
+ "Invalid flow definition: missing name or fn",
146
+ "Export a default flow() definition with both a name and an async fn."
147
+ )
148
+ );
149
+ continue;
150
+ }
151
+ const existing = flowNames.get(def.name);
152
+ if (existing) {
153
+ results.push(
154
+ createValidationIssue(
155
+ p,
156
+ "DUPLICATE_FLOW_NAME",
157
+ `Duplicate flow name "${def.name}" (also in ${existing})`,
158
+ "Give each flow a unique name so reports and CLI filtering stay deterministic."
159
+ )
160
+ );
161
+ } else {
162
+ flowNames.set(def.name, p);
163
+ }
164
+ if (def.config?.platforms) {
165
+ for (const plat of def.config.platforms) {
166
+ if (!VALID_PLATFORMS.has(plat)) {
167
+ results.push(
168
+ createValidationIssue(
169
+ p,
170
+ "INVALID_PLATFORM",
171
+ `Invalid platform "${plat}" - must be web, android, or ios`,
172
+ "Use only `web`, `android`, or `ios` in FlowConfig.platforms."
173
+ )
174
+ );
175
+ }
176
+ }
177
+ }
178
+ }
179
+ if (p.endsWith(".flow.ts") || p.endsWith(".test.ts")) {
180
+ const qualityWarnings = await analyzeFlowFileQuality(p, defs);
181
+ results.push(...qualityWarnings);
182
+ }
183
+ if (p.endsWith(".feature")) {
184
+ const gherkinWarnings = await analyzeGherkinFileQuality(p, defs);
185
+ results.push(...gherkinWarnings);
186
+ }
187
+ } catch (e) {
188
+ results.push(
189
+ createValidationIssue(
190
+ p,
191
+ "FLOW_LOAD_FAILED",
192
+ `Failed to load: ${e instanceof Error ? e.message : String(e)}`,
193
+ "Fix the file's syntax or runtime error, then run `spana validate` again."
194
+ )
195
+ );
196
+ }
197
+ }
198
+ return results;
199
+ }
200
+ async function analyzeFlowFileQuality(filePath, defs) {
201
+ const warnings = [];
202
+ const source = await readFile(filePath, "utf-8");
203
+ const lines = source.split("\n");
204
+ if (lines.length > MAX_FLOW_LINES) {
205
+ warnings.push(
206
+ createValidationWarning(
207
+ filePath,
208
+ "FLOW_TOO_LONG",
209
+ `Flow file has ${lines.length} lines (recommended max: ${MAX_FLOW_LINES}). Long flows are harder for AI agents to refactor safely. Consider extracting helper functions.`,
210
+ "Split long flows into smaller helpers or focused scenarios."
211
+ )
212
+ );
213
+ }
214
+ let maxNesting = 0;
215
+ let currentNesting = 0;
216
+ for (const line of lines) {
217
+ const trimmed = line.trim();
218
+ if (!trimmed || trimmed.startsWith("//")) continue;
219
+ for (const char of line) {
220
+ if (char === "{") currentNesting++;
221
+ if (char === "}") currentNesting--;
222
+ }
223
+ maxNesting = Math.max(maxNesting, currentNesting);
224
+ }
225
+ if (maxNesting > MAX_NESTING_DEPTH) {
226
+ warnings.push(
227
+ createValidationWarning(
228
+ filePath,
229
+ "FLOW_NESTING_TOO_DEEP",
230
+ `Max nesting depth is ${maxNesting} (recommended max: ${MAX_NESTING_DEPTH}). Deep nesting increases AI refactoring break rates. Consider extracting nested blocks into named functions.`,
231
+ "Extract nested control flow into named helper functions."
232
+ )
233
+ );
234
+ }
235
+ const complexConditionalRegex = /(?:\|\||&&)/g;
236
+ let maxConditionalOps = 0;
237
+ for (const line of lines) {
238
+ const matches = line.match(complexConditionalRegex);
239
+ if (matches) {
240
+ maxConditionalOps = Math.max(maxConditionalOps, matches.length);
241
+ }
242
+ }
243
+ if (maxConditionalOps > MAX_CONDITIONAL_OPERATORS) {
244
+ warnings.push(
245
+ createValidationWarning(
246
+ filePath,
247
+ "FLOW_CONDITIONAL_TOO_COMPLEX",
248
+ `Found ${maxConditionalOps} logical operators in a single condition (recommended max: ${MAX_CONDITIONAL_OPERATORS}). Complex conditionals are error-prone for AI edits. Extract into a named predicate function.`,
249
+ "Extract complex conditions into a named predicate helper."
250
+ )
251
+ );
252
+ }
253
+ for (const def of defs) {
254
+ if (!def.name || def.name.trim().length === 0) {
255
+ warnings.push(
256
+ createValidationWarning(
257
+ filePath,
258
+ "FLOW_NAME_EMPTY",
259
+ "Flow has an empty or whitespace-only name. Descriptive names help AI agents understand test intent.",
260
+ "Give the flow a descriptive name that explains the scenario under test."
261
+ )
262
+ );
263
+ }
264
+ if (!def.config?.tags || def.config.tags.length === 0) {
265
+ warnings.push(
266
+ createValidationWarning(
267
+ filePath,
268
+ "FLOW_MISSING_TAGS",
269
+ `Flow "${def.name}" has no tags. Tags make it easier for AI agents to filter and target specific test suites.`,
270
+ "Add tags like `smoke`, `auth`, or `checkout` so flows can be filtered intentionally."
271
+ )
272
+ );
273
+ }
274
+ }
275
+ return warnings;
276
+ }
277
+ async function analyzeGherkinFileQuality(filePath, defs) {
278
+ const warnings = [];
279
+ for (const def of defs) {
280
+ if (!def.name || def.name.trim().length === 0) {
281
+ warnings.push(
282
+ createValidationWarning(
283
+ filePath,
284
+ "GHERKIN_NAME_EMPTY",
285
+ "Gherkin scenario has an empty or whitespace-only name. Clear scenario names improve AI comprehension.",
286
+ "Give each scenario a clear, descriptive title.",
287
+ GHERKIN_DOCS_URL
288
+ )
289
+ );
290
+ }
291
+ if (!def.config?.tags || def.config.tags.length === 0) {
292
+ warnings.push(
293
+ createValidationWarning(
294
+ filePath,
295
+ "GHERKIN_MISSING_TAGS",
296
+ `Gherkin scenario "${def.name}" has no tags. Tags help AI agents filter and organize scenarios.`,
297
+ "Add tags like `@smoke` or `@regression` above the scenario or feature.",
298
+ GHERKIN_DOCS_URL
299
+ )
300
+ );
301
+ }
302
+ }
303
+ return warnings;
304
+ }
305
+
306
+ export {
307
+ isValidationIssue,
308
+ isValidationWarning,
309
+ summarizeValidationResults,
310
+ validateFlowFile,
311
+ validateFlows,
312
+ validateProject
313
+ };
314
+ //# sourceMappingURL=chunk-IJIASIX5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/validator.ts"],"sourcesContent":["import { readFile, stat } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { discoverFlows, discoverStepFiles, loadStepFiles, loadTestSource } from \"./runner.js\";\nimport type { FlowDefinition } from \"../api/flow.js\";\nimport { buildDocsUrl } from \"../machine.js\";\n\nexport type ValidationCode =\n | \"MISSING_DEFAULT_EXPORT\"\n | \"INVALID_FLOW_DEFINITION\"\n | \"FLOW_LOAD_FAILED\"\n | \"FLOW_DIRECTORY_MISSING\"\n | \"NO_FLOW_FILES\"\n | \"STEP_DEFINITION_LOAD_FAILED\"\n | \"DUPLICATE_FLOW_NAME\"\n | \"INVALID_PLATFORM\"\n | \"FLOW_TOO_LONG\"\n | \"FLOW_NESTING_TOO_DEEP\"\n | \"FLOW_CONDITIONAL_TOO_COMPLEX\"\n | \"FLOW_NAME_EMPTY\"\n | \"FLOW_MISSING_TAGS\"\n | \"GHERKIN_NAME_EMPTY\"\n | \"GHERKIN_MISSING_TAGS\";\n\ninterface ValidationBase {\n file: string;\n code: ValidationCode;\n suggestedFix?: string;\n docsUrl?: string;\n}\n\nexport interface ValidationIssue extends ValidationBase {\n error: string;\n severity: \"error\";\n}\n\nexport interface ValidationWarning extends ValidationBase {\n message: string;\n severity: \"warning\";\n}\n\nexport type ValidationResult = ValidationIssue | ValidationWarning;\n\nexport type ValidationError = ValidationIssue;\n\nconst FLOWS_DOCS_URL = buildDocsUrl(\"/writing-tests/flows\");\nconst GHERKIN_DOCS_URL = buildDocsUrl(\"/writing-tests/gherkin\");\nconst VALIDATE_DOCS_URL = buildDocsUrl(\"/cli/agent-commands\");\n\nfunction createValidationIssue(\n file: string,\n code: ValidationCode,\n error: string,\n suggestedFix?: string,\n docsUrl = FLOWS_DOCS_URL,\n): ValidationIssue {\n return { file, code, error, severity: \"error\", suggestedFix, docsUrl };\n}\n\nfunction createValidationWarning(\n file: string,\n code: ValidationCode,\n message: string,\n suggestedFix?: string,\n docsUrl = FLOWS_DOCS_URL,\n): ValidationWarning {\n return { file, code, message, severity: \"warning\", suggestedFix, docsUrl };\n}\n\nexport function isValidationIssue(result: ValidationResult): result is ValidationIssue {\n return result.severity === \"error\";\n}\n\nexport function isValidationWarning(result: ValidationResult): result is ValidationWarning {\n return result.severity === \"warning\";\n}\n\nexport function summarizeValidationResults(results: ValidationResult[]) {\n let errorCount = 0;\n let warningCount = 0;\n\n for (const result of results) {\n if (isValidationIssue(result)) {\n errorCount++;\n } else {\n warningCount++;\n }\n }\n\n return { errorCount, warningCount };\n}\n\nexport async function validateFlowFile(filePath: string): Promise<ValidationIssue | null> {\n try {\n const absolutePath = resolve(filePath);\n const mod = await import(absolutePath);\n if (!mod.default) {\n return createValidationIssue(\n filePath,\n \"MISSING_DEFAULT_EXPORT\",\n \"No default export found\",\n \"Export a single default FlowDefinition from this file.\",\n );\n }\n const def = mod.default;\n if (!def.name || typeof def.fn !== \"function\") {\n return createValidationIssue(\n filePath,\n \"INVALID_FLOW_DEFINITION\",\n \"Invalid flow definition: missing name or fn\",\n \"Export a default flow() definition with both a name and an async fn.\",\n );\n }\n return null;\n } catch (e) {\n return createValidationIssue(\n filePath,\n \"FLOW_LOAD_FAILED\",\n `Failed to import: ${e instanceof Error ? e.message : String(e)}`,\n \"Fix the file's syntax or runtime error, then run `spana validate` again.\",\n );\n }\n}\n\nexport async function validateFlows(paths: string[]): Promise<ValidationIssue[]> {\n const errors: ValidationIssue[] = [];\n for (const path of paths) {\n const err = await validateFlowFile(path);\n if (err) errors.push(err);\n }\n return errors;\n}\n\nconst VALID_PLATFORMS = new Set([\"web\", \"android\", \"ios\"]);\n\nconst MAX_FLOW_LINES = 80;\nconst MAX_NESTING_DEPTH = 3;\nconst MAX_CONDITIONAL_OPERATORS = 3;\n\nexport async function validateProject(flowDir: string): Promise<ValidationResult[]> {\n const results: ValidationResult[] = [];\n\n // Check flow directory exists and has flows\n let paths: string[];\n try {\n paths = await discoverFlows(flowDir);\n } catch {\n results.push(\n createValidationIssue(\n flowDir,\n \"FLOW_DIRECTORY_MISSING\",\n \"Flow directory does not exist\",\n \"Create the flow directory or pass the correct path to `spana validate`.\",\n VALIDATE_DOCS_URL,\n ),\n );\n return results;\n }\n\n if (paths.length === 0) {\n results.push(\n createValidationIssue(\n flowDir,\n \"NO_FLOW_FILES\",\n \"No flow files found\",\n \"Add .flow.ts or .feature files under the configured flow directory.\",\n VALIDATE_DOCS_URL,\n ),\n );\n return results;\n }\n\n const hasFeatureFiles = paths.some((path) => path.endsWith(\".feature\"));\n if (hasFeatureFiles) {\n const flowDirStats = await stat(resolve(flowDir)).catch(() => null);\n const stepSearchDir = flowDirStats?.isDirectory() ? flowDir : dirname(flowDir);\n const stepPaths = await discoverStepFiles(stepSearchDir);\n if (stepPaths.length > 0) {\n try {\n await loadStepFiles(stepPaths);\n } catch (e) {\n results.push(\n createValidationIssue(\n flowDir,\n \"STEP_DEFINITION_LOAD_FAILED\",\n `Failed to load step definitions: ${e instanceof Error ? e.message : String(e)}`,\n \"Fix the referenced step definition files and ensure they can be imported cleanly.\",\n GHERKIN_DOCS_URL,\n ),\n );\n return results;\n }\n }\n }\n\n // Load flows and check for duplicates + invalid platforms + code quality\n const flowNames = new Map<string, string>(); // name -> file\n\n for (const p of paths) {\n try {\n const defs = await loadTestSource(p);\n for (const def of defs) {\n if (!def?.name || typeof def.fn !== \"function\") {\n results.push(\n createValidationIssue(\n p,\n \"INVALID_FLOW_DEFINITION\",\n \"Invalid flow definition: missing name or fn\",\n \"Export a default flow() definition with both a name and an async fn.\",\n ),\n );\n continue;\n }\n\n const existing = flowNames.get(def.name);\n if (existing) {\n results.push(\n createValidationIssue(\n p,\n \"DUPLICATE_FLOW_NAME\",\n `Duplicate flow name \"${def.name}\" (also in ${existing})`,\n \"Give each flow a unique name so reports and CLI filtering stay deterministic.\",\n ),\n );\n } else {\n flowNames.set(def.name, p);\n }\n\n if (def.config?.platforms) {\n for (const plat of def.config.platforms) {\n if (!VALID_PLATFORMS.has(plat)) {\n results.push(\n createValidationIssue(\n p,\n \"INVALID_PLATFORM\",\n `Invalid platform \"${plat}\" - must be web, android, or ios`,\n \"Use only `web`, `android`, or `ios` in FlowConfig.platforms.\",\n ),\n );\n }\n }\n }\n }\n\n // Static analysis for .flow.ts and .test.ts files\n if (p.endsWith(\".flow.ts\") || p.endsWith(\".test.ts\")) {\n const qualityWarnings = await analyzeFlowFileQuality(p, defs);\n results.push(...qualityWarnings);\n }\n\n // Gherkin health checks for .feature files\n if (p.endsWith(\".feature\")) {\n const gherkinWarnings = await analyzeGherkinFileQuality(p, defs);\n results.push(...gherkinWarnings);\n }\n } catch (e) {\n results.push(\n createValidationIssue(\n p,\n \"FLOW_LOAD_FAILED\",\n `Failed to load: ${e instanceof Error ? e.message : String(e)}`,\n \"Fix the file's syntax or runtime error, then run `spana validate` again.\",\n ),\n );\n }\n }\n\n return results;\n}\n\nasync function analyzeFlowFileQuality(\n filePath: string,\n defs: FlowDefinition[],\n): Promise<ValidationWarning[]> {\n const warnings: ValidationWarning[] = [];\n const source = await readFile(filePath, \"utf-8\");\n const lines = source.split(\"\\n\");\n\n if (lines.length > MAX_FLOW_LINES) {\n warnings.push(\n createValidationWarning(\n filePath,\n \"FLOW_TOO_LONG\",\n `Flow file has ${lines.length} lines (recommended max: ${MAX_FLOW_LINES}). Long flows are harder for AI agents to refactor safely. Consider extracting helper functions.`,\n \"Split long flows into smaller helpers or focused scenarios.\",\n ),\n );\n }\n\n let maxNesting = 0;\n let currentNesting = 0;\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"//\")) continue;\n\n for (const char of line) {\n if (char === \"{\") currentNesting++;\n if (char === \"}\") currentNesting--;\n }\n maxNesting = Math.max(maxNesting, currentNesting);\n }\n\n if (maxNesting > MAX_NESTING_DEPTH) {\n warnings.push(\n createValidationWarning(\n filePath,\n \"FLOW_NESTING_TOO_DEEP\",\n `Max nesting depth is ${maxNesting} (recommended max: ${MAX_NESTING_DEPTH}). Deep nesting increases AI refactoring break rates. Consider extracting nested blocks into named functions.`,\n \"Extract nested control flow into named helper functions.\",\n ),\n );\n }\n\n const complexConditionalRegex = /(?:\\|\\||&&)/g;\n let maxConditionalOps = 0;\n for (const line of lines) {\n const matches = line.match(complexConditionalRegex);\n if (matches) {\n maxConditionalOps = Math.max(maxConditionalOps, matches.length);\n }\n }\n\n if (maxConditionalOps > MAX_CONDITIONAL_OPERATORS) {\n warnings.push(\n createValidationWarning(\n filePath,\n \"FLOW_CONDITIONAL_TOO_COMPLEX\",\n `Found ${maxConditionalOps} logical operators in a single condition (recommended max: ${MAX_CONDITIONAL_OPERATORS}). Complex conditionals are error-prone for AI edits. Extract into a named predicate function.`,\n \"Extract complex conditions into a named predicate helper.\",\n ),\n );\n }\n\n for (const def of defs) {\n if (!def.name || def.name.trim().length === 0) {\n warnings.push(\n createValidationWarning(\n filePath,\n \"FLOW_NAME_EMPTY\",\n \"Flow has an empty or whitespace-only name. Descriptive names help AI agents understand test intent.\",\n \"Give the flow a descriptive name that explains the scenario under test.\",\n ),\n );\n }\n\n if (!def.config?.tags || def.config.tags.length === 0) {\n warnings.push(\n createValidationWarning(\n filePath,\n \"FLOW_MISSING_TAGS\",\n `Flow \"${def.name}\" has no tags. Tags make it easier for AI agents to filter and target specific test suites.`,\n \"Add tags like `smoke`, `auth`, or `checkout` so flows can be filtered intentionally.\",\n ),\n );\n }\n }\n\n return warnings;\n}\n\nasync function analyzeGherkinFileQuality(\n filePath: string,\n defs: FlowDefinition[],\n): Promise<ValidationWarning[]> {\n const warnings: ValidationWarning[] = [];\n\n for (const def of defs) {\n if (!def.name || def.name.trim().length === 0) {\n warnings.push(\n createValidationWarning(\n filePath,\n \"GHERKIN_NAME_EMPTY\",\n \"Gherkin scenario has an empty or whitespace-only name. Clear scenario names improve AI comprehension.\",\n \"Give each scenario a clear, descriptive title.\",\n GHERKIN_DOCS_URL,\n ),\n );\n }\n\n if (!def.config?.tags || def.config.tags.length === 0) {\n warnings.push(\n createValidationWarning(\n filePath,\n \"GHERKIN_MISSING_TAGS\",\n `Gherkin scenario \"${def.name}\" has no tags. Tags help AI agents filter and organize scenarios.`,\n \"Add tags like `@smoke` or `@regression` above the scenario or feature.\",\n GHERKIN_DOCS_URL,\n ),\n );\n }\n }\n\n return warnings;\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,UAAU,YAAY;AAC/B,SAAS,SAAS,eAAe;AA2CjC,IAAM,iBAAiB,aAAa,sBAAsB;AAC1D,IAAM,mBAAmB,aAAa,wBAAwB;AAC9D,IAAM,oBAAoB,aAAa,qBAAqB;AAE5D,SAAS,sBACP,MACA,MACA,OACA,cACA,UAAU,gBACO;AACjB,SAAO,EAAE,MAAM,MAAM,OAAO,UAAU,SAAS,cAAc,QAAQ;AACvE;AAEA,SAAS,wBACP,MACA,MACA,SACA,cACA,UAAU,gBACS;AACnB,SAAO,EAAE,MAAM,MAAM,SAAS,UAAU,WAAW,cAAc,QAAQ;AAC3E;AAEO,SAAS,kBAAkB,QAAqD;AACrF,SAAO,OAAO,aAAa;AAC7B;AAEO,SAAS,oBAAoB,QAAuD;AACzF,SAAO,OAAO,aAAa;AAC7B;AAEO,SAAS,2BAA2B,SAA6B;AACtE,MAAI,aAAa;AACjB,MAAI,eAAe;AAEnB,aAAW,UAAU,SAAS;AAC5B,QAAI,kBAAkB,MAAM,GAAG;AAC7B;AAAA,IACF,OAAO;AACL;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,YAAY,aAAa;AACpC;AAEA,eAAsB,iBAAiB,UAAmD;AACxF,MAAI;AACF,UAAM,eAAe,QAAQ,QAAQ;AACrC,UAAM,MAAM,MAAM,OAAO;AACzB,QAAI,CAAC,IAAI,SAAS;AAChB,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,UAAM,MAAM,IAAI;AAChB,QAAI,CAAC,IAAI,QAAQ,OAAO,IAAI,OAAO,YAAY;AAC7C,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT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