@plune-ai/cairn 0.5.0 → 0.7.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 (193) hide show
  1. package/README.md +10 -4
  2. package/dist/agent/finalize.d.ts +4 -0
  3. package/dist/agent/finalize.d.ts.map +1 -1
  4. package/dist/agent/finalize.js +8 -1
  5. package/dist/agent/finalize.js.map +1 -1
  6. package/dist/agent/graph.d.ts +17 -0
  7. package/dist/agent/graph.d.ts.map +1 -1
  8. package/dist/agent/graph.js +36 -6
  9. package/dist/agent/graph.js.map +1 -1
  10. package/dist/agent/index.d.ts +22 -0
  11. package/dist/agent/index.d.ts.map +1 -1
  12. package/dist/agent/index.js +143 -51
  13. package/dist/agent/index.js.map +1 -1
  14. package/dist/agent/summary.d.ts +14 -0
  15. package/dist/agent/summary.d.ts.map +1 -1
  16. package/dist/agent/summary.js +15 -0
  17. package/dist/agent/summary.js.map +1 -1
  18. package/dist/analyze/index.d.ts +2 -0
  19. package/dist/analyze/index.d.ts.map +1 -1
  20. package/dist/analyze/index.js +1 -0
  21. package/dist/analyze/index.js.map +1 -1
  22. package/dist/api/adversarial.d.ts +38 -0
  23. package/dist/api/adversarial.d.ts.map +1 -0
  24. package/dist/api/adversarial.js +175 -0
  25. package/dist/api/adversarial.js.map +1 -0
  26. package/dist/api/cases.d.ts +109 -0
  27. package/dist/api/cases.d.ts.map +1 -0
  28. package/dist/api/cases.js +256 -0
  29. package/dist/api/cases.js.map +1 -0
  30. package/dist/api/coverage.d.ts +51 -0
  31. package/dist/api/coverage.d.ts.map +1 -0
  32. package/dist/api/coverage.js +80 -0
  33. package/dist/api/coverage.js.map +1 -0
  34. package/dist/api/openapi.d.ts +84 -0
  35. package/dist/api/openapi.d.ts.map +1 -0
  36. package/dist/api/openapi.js +119 -0
  37. package/dist/api/openapi.js.map +1 -0
  38. package/dist/api/runner.d.ts +58 -0
  39. package/dist/api/runner.d.ts.map +1 -0
  40. package/dist/api/runner.js +285 -0
  41. package/dist/api/runner.js.map +1 -0
  42. package/dist/api/scenario-runner.d.ts +22 -0
  43. package/dist/api/scenario-runner.d.ts.map +1 -0
  44. package/dist/api/scenario-runner.js +132 -0
  45. package/dist/api/scenario-runner.js.map +1 -0
  46. package/dist/api/scenarios.d.ts +31 -0
  47. package/dist/api/scenarios.d.ts.map +1 -0
  48. package/dist/api/scenarios.js +71 -0
  49. package/dist/api/scenarios.js.map +1 -0
  50. package/dist/api/testcase-docs.d.ts +12 -0
  51. package/dist/api/testcase-docs.d.ts.map +1 -0
  52. package/dist/api/testcase-docs.js +22 -0
  53. package/dist/api/testcase-docs.js.map +1 -0
  54. package/dist/artifacts/contract.d.ts +62 -0
  55. package/dist/artifacts/contract.d.ts.map +1 -0
  56. package/dist/artifacts/contract.js +58 -0
  57. package/dist/artifacts/contract.js.map +1 -0
  58. package/dist/artifacts/index.d.ts +2 -0
  59. package/dist/artifacts/index.d.ts.map +1 -1
  60. package/dist/artifacts/index.js +3 -0
  61. package/dist/artifacts/index.js.map +1 -1
  62. package/dist/artifacts/report.d.ts +21 -0
  63. package/dist/artifacts/report.d.ts.map +1 -1
  64. package/dist/artifacts/report.js +49 -0
  65. package/dist/artifacts/report.js.map +1 -1
  66. package/dist/artifacts/testcase-md.d.ts +29 -0
  67. package/dist/artifacts/testcase-md.d.ts.map +1 -1
  68. package/dist/artifacts/testcase-md.js +69 -1
  69. package/dist/artifacts/testcase-md.js.map +1 -1
  70. package/dist/checklist/index.d.ts +7 -0
  71. package/dist/checklist/index.d.ts.map +1 -1
  72. package/dist/checklist/index.js +14 -0
  73. package/dist/checklist/index.js.map +1 -1
  74. package/dist/ci/github.d.ts +83 -0
  75. package/dist/ci/github.d.ts.map +1 -0
  76. package/dist/ci/github.js +104 -0
  77. package/dist/ci/github.js.map +1 -0
  78. package/dist/ci/index.d.ts +14 -0
  79. package/dist/ci/index.d.ts.map +1 -0
  80. package/dist/ci/index.js +35 -0
  81. package/dist/ci/index.js.map +1 -0
  82. package/dist/ci/inputs.d.ts +93 -0
  83. package/dist/ci/inputs.d.ts.map +1 -0
  84. package/dist/ci/inputs.js +100 -0
  85. package/dist/ci/inputs.js.map +1 -0
  86. package/dist/ci/run.d.ts +51 -0
  87. package/dist/ci/run.d.ts.map +1 -0
  88. package/dist/ci/run.js +207 -0
  89. package/dist/ci/run.js.map +1 -0
  90. package/dist/ci/summary.d.ts +42 -0
  91. package/dist/ci/summary.d.ts.map +1 -0
  92. package/dist/ci/summary.js +45 -0
  93. package/dist/ci/summary.js.map +1 -0
  94. package/dist/cli/index.d.ts.map +1 -1
  95. package/dist/cli/index.js +45 -4
  96. package/dist/cli/index.js.map +1 -1
  97. package/dist/codegen/index.d.ts +13 -1
  98. package/dist/codegen/index.d.ts.map +1 -1
  99. package/dist/codegen/index.js +75 -0
  100. package/dist/codegen/index.js.map +1 -1
  101. package/dist/config/index.d.ts.map +1 -1
  102. package/dist/config/index.js +9 -0
  103. package/dist/config/index.js.map +1 -1
  104. package/dist/config/profiles.d.ts +6 -0
  105. package/dist/config/profiles.d.ts.map +1 -1
  106. package/dist/config/profiles.js +13 -0
  107. package/dist/config/profiles.js.map +1 -1
  108. package/dist/config/schema.d.ts +6 -0
  109. package/dist/config/schema.d.ts.map +1 -1
  110. package/dist/core/modalities/api.d.ts +27 -0
  111. package/dist/core/modalities/api.d.ts.map +1 -0
  112. package/dist/core/modalities/api.js +330 -0
  113. package/dist/core/modalities/api.js.map +1 -0
  114. package/dist/core/modalities/explore.d.ts.map +1 -1
  115. package/dist/core/modalities/explore.js +9 -1
  116. package/dist/core/modalities/explore.js.map +1 -1
  117. package/dist/core/registry.d.ts.map +1 -1
  118. package/dist/core/registry.js +4 -1
  119. package/dist/core/registry.js.map +1 -1
  120. package/dist/design/critique.d.ts.map +1 -1
  121. package/dist/design/critique.js +3 -0
  122. package/dist/design/critique.js.map +1 -1
  123. package/dist/design/index.d.ts +2 -0
  124. package/dist/design/index.d.ts.map +1 -1
  125. package/dist/design/index.js +5 -0
  126. package/dist/design/index.js.map +1 -1
  127. package/dist/design/schema.d.ts +3 -0
  128. package/dist/design/schema.d.ts.map +1 -1
  129. package/dist/design/schema.js.map +1 -1
  130. package/dist/documentarian/index.d.ts +53 -0
  131. package/dist/documentarian/index.d.ts.map +1 -0
  132. package/dist/documentarian/index.js +135 -0
  133. package/dist/documentarian/index.js.map +1 -0
  134. package/dist/eval/gap-cases.d.ts.map +1 -1
  135. package/dist/eval/gap-cases.js +2 -0
  136. package/dist/eval/gap-cases.js.map +1 -1
  137. package/dist/index.d.ts +2 -1
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/knowledge/index.d.ts +30 -4
  140. package/dist/knowledge/index.d.ts.map +1 -1
  141. package/dist/knowledge/index.js +80 -22
  142. package/dist/knowledge/index.js.map +1 -1
  143. package/dist/llm/index.d.ts +2 -2
  144. package/dist/llm/index.d.ts.map +1 -1
  145. package/dist/llm/index.js +1 -1
  146. package/dist/llm/index.js.map +1 -1
  147. package/dist/llm/routing.d.ts.map +1 -1
  148. package/dist/llm/routing.js +8 -2
  149. package/dist/llm/routing.js.map +1 -1
  150. package/dist/llm/structured.d.ts +22 -0
  151. package/dist/llm/structured.d.ts.map +1 -1
  152. package/dist/llm/structured.js +42 -0
  153. package/dist/llm/structured.js.map +1 -1
  154. package/dist/mcp/server.d.ts +9 -0
  155. package/dist/mcp/server.d.ts.map +1 -0
  156. package/dist/mcp/server.js +49 -0
  157. package/dist/mcp/server.js.map +1 -0
  158. package/dist/mcp/tools.d.ts +149 -0
  159. package/dist/mcp/tools.d.ts.map +1 -0
  160. package/dist/mcp/tools.js +138 -0
  161. package/dist/mcp/tools.js.map +1 -0
  162. package/dist/project/index.d.ts +70 -0
  163. package/dist/project/index.d.ts.map +1 -0
  164. package/dist/project/index.js +173 -0
  165. package/dist/project/index.js.map +1 -0
  166. package/dist/prompts/local/identify-elements.d.ts +1 -1
  167. package/dist/prompts/local/identify-elements.d.ts.map +1 -1
  168. package/dist/prompts/local/identify-elements.js +5 -2
  169. package/dist/prompts/local/identify-elements.js.map +1 -1
  170. package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
  171. package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
  172. package/dist/prompts/local/qa-testcase-from-ui.js +2 -0
  173. package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
  174. package/dist/tui/hooks/use-runs.d.ts.map +1 -1
  175. package/dist/tui/hooks/use-runs.js +4 -1
  176. package/dist/tui/hooks/use-runs.js.map +1 -1
  177. package/dist/tui/screens/runs-list-screen.d.ts.map +1 -1
  178. package/dist/tui/screens/runs-list-screen.js +3 -1
  179. package/dist/tui/screens/runs-list-screen.js.map +1 -1
  180. package/dist/tui/screens/summary-screen.d.ts.map +1 -1
  181. package/dist/tui/screens/summary-screen.js +1 -1
  182. package/dist/tui/screens/summary-screen.js.map +1 -1
  183. package/dist/tui/types.d.ts +7 -1
  184. package/dist/tui/types.d.ts.map +1 -1
  185. package/dist/validate/index.d.ts +7 -3
  186. package/dist/validate/index.d.ts.map +1 -1
  187. package/dist/validate/index.js +22 -3
  188. package/dist/validate/index.js.map +1 -1
  189. package/dist/validate/runner.d.ts +61 -1
  190. package/dist/validate/runner.d.ts.map +1 -1
  191. package/dist/validate/runner.js +67 -4
  192. package/dist/validate/runner.js.map +1 -1
  193. package/package.json +5 -1
@@ -0,0 +1,38 @@
1
+ /**
2
+ * BORROW-07 (#95) — adversarial API testing styles, borrowed conceptually from testomatio/explorbot's
3
+ * Chief+Curler (4 named styles: normal/curious/psycho/hacker) and AZANIR/qa-skills' OWASP WSTG payload
4
+ * set (both harvested via BORROW-08, #96). Explorbot's own styles are LLM-driven — Chief plans and
5
+ * Curler composes each request's literal payload at generation time, with no deterministic
6
+ * style→value mapping anywhere to port. This ports the TAXONOMY only, translated into cairn's
7
+ * existing schema-driven, no-LLM case generation (same "no LLM" reasoning as API-2/API-8).
8
+ *
9
+ * - normal — happy path. Already always-generated (API-2) — this module doesn't re-emit it as a
10
+ * separate case; the CLI layer just tags the existing base cases when "normal" is requested.
11
+ * - curious — exhaustive VALID coverage: a case with every param (not just required), and one case
12
+ * per additional declared enum value. Body completeness needed no new code — `synth()` (`cases.ts`)
13
+ * already includes every synthesisable property regardless of required-ness.
14
+ * - psycho — invalid/malformed/extreme input: a SQL-injection case, an XSS case, a boundary-numeric
15
+ * case (each targeting the first suitable body property), plus API-8's existing negative case
16
+ * (missing-required-field / wrong-type), re-tagged rather than reimplemented.
17
+ * - hacker — ships only the deterministic, single-request slice: strip auth from an otherwise-valid
18
+ * request, expect rejection. IDOR / privilege-escalation-via-response-replay are genuinely
19
+ * stateful/multi-request in explorbot's own implementation (≥2 identities, resource chaining,
20
+ * reading prior responses) — closer to API-9's scenario-chain machinery than a single case, so
21
+ * they're a follow-up, not shipped here.
22
+ *
23
+ * Every case is tagged `adversarialStyle` (+ `wstgId` where a specific OWASP WSTG test ID applies) so
24
+ * it flows through the existing run/report/coverage/ATC pipeline untouched — a distinct category, not
25
+ * a parallel one (same principle API-8's `type: "Negative"` established). Coverage (API-6,
26
+ * `computeApiCoverage`) needs no changes — it's endpoint/status-driven, not case-count-driven.
27
+ */
28
+ import { type ApiCase } from "./cases.js";
29
+ import type { ApiModel } from "./openapi.js";
30
+ export type AdversarialStyle = "normal" | "curious" | "psycho" | "hacker";
31
+ export declare const ADVERSARIAL_STYLES: readonly AdversarialStyle[];
32
+ /**
33
+ * Generate `curious`/`psycho`/`hacker` adversarial cases for the requested styles ("normal" is a
34
+ * no-op here — see module doc). Cases are additive, meant to sit alongside the always-generated
35
+ * happy-path cases in the same flat array (same pattern as API-8's `--negative`).
36
+ */
37
+ export declare function generateAdversarialCases(model: ApiModel, styles: readonly AdversarialStyle[]): ApiCase[];
38
+ //# sourceMappingURL=adversarial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adversarial.d.ts","sourceRoot":"","sources":["../../src/api/adversarial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EASL,KAAK,OAAO,EAEb,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC1E,eAAO,MAAM,kBAAkB,EAAE,SAAS,gBAAgB,EAA8C,CAAC;AAQzG;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAAG,OAAO,EAAE,CAMxG"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * BORROW-07 (#95) — adversarial API testing styles, borrowed conceptually from testomatio/explorbot's
3
+ * Chief+Curler (4 named styles: normal/curious/psycho/hacker) and AZANIR/qa-skills' OWASP WSTG payload
4
+ * set (both harvested via BORROW-08, #96). Explorbot's own styles are LLM-driven — Chief plans and
5
+ * Curler composes each request's literal payload at generation time, with no deterministic
6
+ * style→value mapping anywhere to port. This ports the TAXONOMY only, translated into cairn's
7
+ * existing schema-driven, no-LLM case generation (same "no LLM" reasoning as API-2/API-8).
8
+ *
9
+ * - normal — happy path. Already always-generated (API-2) — this module doesn't re-emit it as a
10
+ * separate case; the CLI layer just tags the existing base cases when "normal" is requested.
11
+ * - curious — exhaustive VALID coverage: a case with every param (not just required), and one case
12
+ * per additional declared enum value. Body completeness needed no new code — `synth()` (`cases.ts`)
13
+ * already includes every synthesisable property regardless of required-ness.
14
+ * - psycho — invalid/malformed/extreme input: a SQL-injection case, an XSS case, a boundary-numeric
15
+ * case (each targeting the first suitable body property), plus API-8's existing negative case
16
+ * (missing-required-field / wrong-type), re-tagged rather than reimplemented.
17
+ * - hacker — ships only the deterministic, single-request slice: strip auth from an otherwise-valid
18
+ * request, expect rejection. IDOR / privilege-escalation-via-response-replay are genuinely
19
+ * stateful/multi-request in explorbot's own implementation (≥2 identities, resource chaining,
20
+ * reading prior responses) — closer to API-9's scenario-chain machinery than a single case, so
21
+ * they're a follow-up, not shipped here.
22
+ *
23
+ * Every case is tagged `adversarialStyle` (+ `wstgId` where a specific OWASP WSTG test ID applies) so
24
+ * it flows through the existing run/report/coverage/ATC pipeline untouched — a distinct category, not
25
+ * a parallel one (same principle API-8's `type: "Negative"` established). Coverage (API-6,
26
+ * `computeApiCoverage`) needs no changes — it's endpoint/status-driven, not case-count-driven.
27
+ */
28
+ import { apiEndpointKey, corruptibleProps, enumProps, generateNegativeCases, pickErrorSchema, pickErrorStatus, synthAllParams, toCase, } from "./cases.js";
29
+ export const ADVERSARIAL_STYLES = ["normal", "curious", "psycho", "hacker"];
30
+ /** Known-safe (non-destructive) payloads, per qa-skills' own convention: verify rejection/sanitisation
31
+ * happened, never assert that an attack actually succeeded. */
32
+ const SQLI_PAYLOAD = "' OR '1'='1";
33
+ const XSS_PAYLOAD = "<script>alert(1)</script>";
34
+ const BOUNDARY_INTEGER = Number.MAX_SAFE_INTEGER;
35
+ /**
36
+ * Generate `curious`/`psycho`/`hacker` adversarial cases for the requested styles ("normal" is a
37
+ * no-op here — see module doc). Cases are additive, meant to sit alongside the always-generated
38
+ * happy-path cases in the same flat array (same pattern as API-8's `--negative`).
39
+ */
40
+ export function generateAdversarialCases(model, styles) {
41
+ const cases = [];
42
+ if (styles.includes("curious"))
43
+ cases.push(...model.endpoints.flatMap(toCuriousCases));
44
+ if (styles.includes("psycho"))
45
+ cases.push(...model.endpoints.flatMap(toPsychoCases), ...reusedNegativeCases(model, "psycho"));
46
+ if (styles.includes("hacker"))
47
+ cases.push(...model.endpoints.map(toHackerCase).filter((c) => c !== undefined));
48
+ return cases;
49
+ }
50
+ /**
51
+ * Exhaustive-valid-data cases for one operation (`curious`): a full-params variant (only when the op
52
+ * actually has an optional param to add) and one case per additional declared enum value (only when
53
+ * the body schema actually declares one) — an operation with neither contributes nothing, same
54
+ * "nothing to add, skip" convention as API-8's negative cases.
55
+ */
56
+ function toCuriousCases(e) {
57
+ const base = toCase(e);
58
+ const cases = [];
59
+ if (e.parameters.some((p) => !p.required)) {
60
+ cases.push({
61
+ ...base,
62
+ name: `${apiEndpointKey(e)} (curious: all params)`,
63
+ params: synthAllParams(e),
64
+ adversarialStyle: "curious",
65
+ technique: "equivalence-partitioning",
66
+ rationale: `Exhaustive-coverage case (curious style) for ${e.method} ${e.path}: exercises every ` +
67
+ `parameter, including optional ones the happy path omits, still with schema-valid values.`,
68
+ });
69
+ }
70
+ for (const [prop, values] of enumProps(e.requestBody?.schema)) {
71
+ for (const value of values.slice(1)) {
72
+ const body = { ...base.body, [prop]: value };
73
+ cases.push({
74
+ ...base,
75
+ name: `${apiEndpointKey(e)} (curious: ${prop}=${String(value)})`,
76
+ body,
77
+ adversarialStyle: "curious",
78
+ technique: "equivalence-partitioning",
79
+ rationale: `Exhaustive-coverage case (curious style) for ${e.method} ${e.path}: sends "${prop}" as the ` +
80
+ `declared enum value ${JSON.stringify(value)} (the happy path only exercises the first).`,
81
+ });
82
+ }
83
+ }
84
+ return cases;
85
+ }
86
+ /**
87
+ * Invalid/malformed/extreme-input cases for one operation (`psycho`): SQL injection and XSS in the
88
+ * first string body property, an extreme boundary value in the first numeric one — each only when
89
+ * such a property actually exists. Missing-required-field/wrong-type is NOT reimplemented here;
90
+ * `reusedNegativeCases` re-tags API-8's existing negative case instead.
91
+ */
92
+ function toPsychoCases(e) {
93
+ const base = toCase(e);
94
+ if (base.body === undefined || typeof base.body !== "object")
95
+ return [];
96
+ const props = corruptibleProps(e.requestBody?.schema);
97
+ const stringProp = props.find(([, type]) => type === "string");
98
+ const numericProp = props.find(([, type]) => type === "integer" || type === "number");
99
+ const expectedStatus = pickErrorStatus(e);
100
+ const expectedSchema = pickErrorSchema(e, expectedStatus);
101
+ const cases = [];
102
+ if (stringProp) {
103
+ const [name] = stringProp;
104
+ cases.push(psychoCase(e, base, "sqli", name, SQLI_PAYLOAD, expectedStatus, expectedSchema, "WSTG-INPV-05", `sends a SQL-injection payload in "${name}", expecting the API to reject or sanitise it ` +
105
+ `(${expectedStatus}) rather than execute it`));
106
+ cases.push(psychoCase(e, base, "xss", name, XSS_PAYLOAD, expectedStatus, expectedSchema, "WSTG-INPV-01", `sends an XSS payload in "${name}", expecting the API to reject or sanitise it ` +
107
+ `(${expectedStatus}) rather than reflect it unescaped`));
108
+ }
109
+ if (numericProp) {
110
+ const [name] = numericProp;
111
+ cases.push(psychoCase(e, base, "boundary", name, BOUNDARY_INTEGER, expectedStatus, expectedSchema, undefined, `sends an extreme boundary value (${BOUNDARY_INTEGER}) for "${name}", expecting the API to ` +
112
+ `reject it (${expectedStatus}) rather than accept an out-of-range number`));
113
+ }
114
+ return cases;
115
+ }
116
+ function psychoCase(e, base, attack, prop, value, expectedStatus, expectedSchema, wstgId, rationale) {
117
+ const body = { ...base.body, [prop]: value };
118
+ const technique = wstgId ? "error-guessing" : "boundary-value";
119
+ return {
120
+ ...base,
121
+ name: `${apiEndpointKey(e)} (psycho: ${attack})`,
122
+ body,
123
+ expectedStatus,
124
+ expectedSchema,
125
+ type: "Negative", // expects rejection, same category as an API-8 negative case
126
+ adversarialStyle: "psycho",
127
+ technique,
128
+ ...(wstgId ? { wstgId } : {}),
129
+ rationale: `Adversarial case (psycho style${wstgId ? `, ${wstgId}` : ""}) for ${e.method} ${e.path}: ${rationale}.`,
130
+ };
131
+ }
132
+ /**
133
+ * A declared 401, else 403 — the specific "auth rejection" codes — over `pickErrorStatus`'s generic
134
+ * "lowest declared 4xx" (bug #154): an operation can legitimately declare an unrelated 4xx (e.g. a
135
+ * `404` for "resource not found") that has nothing to do with authentication, and reusing that here
136
+ * would expect the wrong failure mode from a server that's actually enforcing auth correctly.
137
+ */
138
+ function pickAuthRejectionStatus(e) {
139
+ const auth = e.responses.find((r) => r.status === "401") ?? e.responses.find((r) => r.status === "403");
140
+ return auth?.status ?? pickErrorStatus(e);
141
+ }
142
+ /**
143
+ * Auth-header-stripped case for one operation (`hacker`, deterministic subset — see module doc): only
144
+ * for operations that actually declare `security`, since a public operation has nothing to strip.
145
+ */
146
+ function toHackerCase(e) {
147
+ if (e.security.length === 0)
148
+ return undefined;
149
+ const base = toCase(e);
150
+ const expectedStatus = pickAuthRejectionStatus(e);
151
+ return {
152
+ ...base,
153
+ name: `${apiEndpointKey(e)} (hacker: no-auth)`,
154
+ expectedStatus,
155
+ expectedSchema: pickErrorSchema(e, expectedStatus),
156
+ type: "Negative", // expects rejection, same category as an API-8 negative case
157
+ adversarialStyle: "hacker",
158
+ wstgId: "WSTG-ATHN-04",
159
+ stripAuth: true,
160
+ technique: "error-guessing",
161
+ rationale: `Adversarial case (hacker style, WSTG-ATHN-04) for ${e.method} ${e.path}: resends the ` +
162
+ `happy-path request with authentication stripped, expecting the API to reject it ` +
163
+ `(${expectedStatus}) rather than allow unauthenticated access.`,
164
+ };
165
+ }
166
+ /** Re-tag API-8's existing negative cases (missing-required-field / wrong-type) as the given
167
+ * adversarial style, rather than reimplementing the same "corrupt one property" logic. Renamed (not
168
+ * just re-tagged) so a case list stays unique-by-name even when `--negative` and `--adversarial` are
169
+ * both passed and would otherwise generate the identical underlying case twice — `renderApiCases`
170
+ * already shows the style as its own `[psycho]` tag, so the name suffix here is a plain disambiguator
171
+ * rather than repeating that same bracket. */
172
+ function reusedNegativeCases(model, style) {
173
+ return generateNegativeCases(model).map((c) => ({ ...c, name: `${c.name}, reused`, adversarialStyle: style }));
174
+ }
175
+ //# sourceMappingURL=adversarial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adversarial.js","sourceRoot":"","sources":["../../src/api/adversarial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,cAAc,EACd,MAAM,GAGP,MAAM,YAAY,CAAC;AAIpB,MAAM,CAAC,MAAM,kBAAkB,GAAgC,CAAC,QAAQ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AAe,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,CAAc;IAClC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,cAAc,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,oBAAoB;QAC9C,cAAc;QACd,cAAc,EAAE,eAAe,CAAC,CAAC,EAAE,cAAc,CAAC;QAClD,IAAI,EAAE,UAAU,EAAE,6DAA6D;QAC/E,gBAAgB,EAAE,QAAQ;QAC1B,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,gBAAgB;QAC3B,SAAS,EACP,qDAAqD,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,gBAAgB;YACvF,kFAAkF;YAClF,IAAI,cAAc,6CAA6C;KAClE,CAAC;AACJ,CAAC;AAED;;;;;8CAK8C;AAC9C,SAAS,mBAAmB,CAAC,KAAe,EAAE,KAAuB;IACnE,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACjH,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * C1-04 / API-2 (#132) — baseline happy-path case generation from the {@link ApiModel} (API-1).
3
+ *
4
+ * One nominal case per operation: required params + a request body synthesised straight from the
5
+ * (already-dereferenced) JSON schema, paired with the operation's declared success response.
6
+ *
7
+ * No LLM here — and that is the point. Happy-path values follow mechanically from the schema
8
+ * (`example` → `default` → `enum` → type), so synthesis is pure and deterministic (same spec → same
9
+ * cases). The provider abstraction (`StructuredInvoke`) stays available for later, fuzzier slices
10
+ * (negative / boundary cases, API-3+); the DoD's "any LLM use is mockable" holds vacuously because
11
+ * this slice uses none. No runner either — that is API-3.
12
+ *
13
+ * API-5 (#135): every case also carries a `technique` + `rationale` — the same ISO/IEC/IEEE 29119-4
14
+ * methodology tagging web cases carry (`design/schema.ts`) — so the emitted ATC artifact states WHY
15
+ * the case exists, not just what it sends.
16
+ */
17
+ import type { z } from "zod";
18
+ import type { TestTechniqueSchema, TestTypeSchema } from "../design/schema.js";
19
+ import type { ApiEndpoint, ApiLink, ApiModel } from "./openapi.js";
20
+ /** ISO/IEC/IEEE 29119-4 technique — shared enum with web cases (`design/schema.ts`). */
21
+ export type ApiCaseTechnique = z.infer<typeof TestTechniqueSchema>;
22
+ /** Positive (valid path) | Negative (invalid/erroneous) — shared enum with web cases (API-8, #145). */
23
+ export type ApiCaseType = z.infer<typeof TestTypeSchema>;
24
+ /**
25
+ * The stable key an operation is identified by across the model/cases/results/coverage — same rule
26
+ * everywhere (API-6, #136): `operationId` if declared, else `METHOD path`.
27
+ */
28
+ export declare function apiEndpointKey(e: {
29
+ method: string;
30
+ path: string;
31
+ operationId?: string;
32
+ }): string;
33
+ /** Values synthesised for an operation's parameters, grouped by location. */
34
+ export interface ApiCaseParams {
35
+ path: Record<string, unknown>;
36
+ query: Record<string, unknown>;
37
+ header: Record<string, unknown>;
38
+ cookie: Record<string, unknown>;
39
+ }
40
+ /** One generated happy-path case: what to send, and the success response to expect. */
41
+ export interface ApiCase {
42
+ /** `operationId` if present, else `METHOD path` — stable per operation. */
43
+ name: string;
44
+ /** Content-derived identity, stable ACROSS runs — see `artifacts/contract.ts`. Stamped once where
45
+ * the full case set is assembled, so every generator (happy, negative, adversarial) gets one
46
+ * without each having to remember; absent only on a case that never reached that point. */
47
+ stableId?: string;
48
+ method: string;
49
+ path: string;
50
+ operationId?: string;
51
+ /** Required params with schema-synthesised values (optional params are omitted — nominal path). */
52
+ params: ApiCaseParams;
53
+ /** Request body synthesised from the body schema, if the operation declares one. */
54
+ body?: unknown;
55
+ /** Declared success status this case expects ("200"/"201"/"204"/"default"…). */
56
+ expectedStatus: string;
57
+ /** Schema of the expected success body, if that response carries one. */
58
+ expectedSchema?: unknown;
59
+ /** Positive (happy-path) | Negative (contract-violating) — API-8 (#145) distinct case category. */
60
+ type: ApiCaseType;
61
+ /** ISO/IEC/IEEE 29119-4 technique this case embodies (API-5 methodology tagging). */
62
+ technique: ApiCaseTechnique;
63
+ /** Why this case exists / what it covers — the coverage rationale (API-5). */
64
+ rationale: string;
65
+ /** Declared `links` on this case's success response (API-9, #146), if the spec has any. A scenario
66
+ * runner (`scenario-runner.ts`) prefers these over its same-name-field capture heuristic. */
67
+ responseLinks?: Record<string, ApiLink>;
68
+ /** The media type `body` was synthesised from (API-10, #150) — the operation's first declared
69
+ * `requestBody.mediaTypes` entry. The runner encodes as `multipart/form-data` when this says so,
70
+ * JSON otherwise (including when the operation declares no body at all). */
71
+ bodyMediaType?: string;
72
+ /** Which adversarial style (BORROW-07, #95) generated this case, if any. */
73
+ adversarialStyle?: "normal" | "curious" | "psycho" | "hacker";
74
+ /** OWASP WSTG test ID this case exercises (BORROW-07, #95), when one specifically applies. */
75
+ wstgId?: string;
76
+ /** Send this request with auth headers stripped (BORROW-07, #95 `hacker` style) — the runner skips
77
+ * merging `RunnerOptions.auth.headers` when true, instead of the normal always-applied behaviour. */
78
+ stripAuth?: boolean;
79
+ }
80
+ /** Generate one baseline happy-path case per operation, in the model's (deterministic) order. */
81
+ export declare function generateApiCases(model: ApiModel): ApiCase[];
82
+ /**
83
+ * C1-04 / API-8 (#145) — one negative-schema case per operation that has a request contract worth
84
+ * violating: corrupt a request-body property to the wrong JSON type, or (bodyless operations) omit a
85
+ * required non-path parameter. An operation with neither (e.g. `GET /health`) has nothing to violate
86
+ * and is skipped — a forced violation would just be noise, not a contract check.
87
+ */
88
+ export declare function generateNegativeCases(model: ApiModel): ApiCase[];
89
+ /** ALL params (required AND optional) with schema-synthesised values — the "curious" adversarial
90
+ * style's full-coverage variant of `synthRequiredParams` (BORROW-07, #95): optional params get
91
+ * exercised too, instead of the happy path's omit-if-optional convention. */
92
+ export declare function synthAllParams(e: ApiEndpoint): ApiCaseParams;
93
+ /** Body-schema properties that declare an `enum` with more than one value — the "curious" style's
94
+ * one-case-per-additional-value expansion needs the full list (the happy path's `synth()` only ever
95
+ * sends the first). */
96
+ export declare function enumProps(schema: unknown): [string, unknown[]][];
97
+ /** Build the happy-path case for one operation (API-9, #146: also reused by `scenarios.ts` per step —
98
+ * a scenario step is a normal case whose path params get overwritten with captured values at run time). */
99
+ export declare function toCase(e: ApiEndpoint): ApiCase;
100
+ /** Body-schema properties whose declared (primitive) type we can flip to something invalid — reused
101
+ * by the "psycho"/"hacker" adversarial styles (BORROW-07, #95) to target a string/numeric property. */
102
+ export declare function corruptibleProps(schema: unknown): [string, string][];
103
+ /** The lowest declared 4xx status, else the generic "4XX" range (matched by the runner's `statusMatches`).
104
+ * Reused by the "psycho"/"hacker" adversarial styles (BORROW-07, #95) — same "expect rejection"
105
+ * convention as a negative case. */
106
+ export declare function pickErrorStatus(e: ApiEndpoint): string;
107
+ /** The declared response schema for an EXACT status match, if the case picked one (not the "4XX" fallback). */
108
+ export declare function pickErrorSchema(e: ApiEndpoint, expectedStatus: string): unknown;
109
+ //# sourceMappingURL=cases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cases.d.ts","sourceRoot":"","sources":["../../src/api/cases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAY,MAAM,cAAc,CAAC;AAE7E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a,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC;;gFAE4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC9D,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;yGACqG;IACrG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,iGAAiG;AACjG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,EAAE,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,EAAE,CAEhE;AAaD;;6EAE6E;AAC7E,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,aAAa,CAI5D;AAED;;uBAEuB;AACvB,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAOhE;AAED;2GAC2G;AAC3G,wBAAgB,MAAM,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAsB9C;AAED;uGACuG;AACvG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAQpE;AAiBD;;oCAEoC;AACpC,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAGtD;AAED,+GAA+G;AAC/G,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAE/E"}
@@ -0,0 +1,256 @@
1
+ /**
2
+ * The stable key an operation is identified by across the model/cases/results/coverage — same rule
3
+ * everywhere (API-6, #136): `operationId` if declared, else `METHOD path`.
4
+ */
5
+ export function apiEndpointKey(e) {
6
+ return e.operationId ?? `${e.method} ${e.path}`;
7
+ }
8
+ /** Generate one baseline happy-path case per operation, in the model's (deterministic) order. */
9
+ export function generateApiCases(model) {
10
+ return model.endpoints.map(toCase);
11
+ }
12
+ /**
13
+ * C1-04 / API-8 (#145) — one negative-schema case per operation that has a request contract worth
14
+ * violating: corrupt a request-body property to the wrong JSON type, or (bodyless operations) omit a
15
+ * required non-path parameter. An operation with neither (e.g. `GET /health`) has nothing to violate
16
+ * and is skipped — a forced violation would just be noise, not a contract check.
17
+ */
18
+ export function generateNegativeCases(model) {
19
+ return model.endpoints.map(toNegativeCase).filter((c) => c !== undefined);
20
+ }
21
+ /** Required params (as sent for the nominal happy path), optionally dropping one to violate it. */
22
+ function synthRequiredParams(e, omit) {
23
+ const params = { path: {}, query: {}, header: {}, cookie: {} };
24
+ for (const p of e.parameters) {
25
+ if (!p.required)
26
+ continue;
27
+ if (omit && p.in === omit.in && p.name === omit.name)
28
+ continue;
29
+ params[p.in][p.name] = synth(p.schema);
30
+ }
31
+ return params;
32
+ }
33
+ /** ALL params (required AND optional) with schema-synthesised values — the "curious" adversarial
34
+ * style's full-coverage variant of `synthRequiredParams` (BORROW-07, #95): optional params get
35
+ * exercised too, instead of the happy path's omit-if-optional convention. */
36
+ export function synthAllParams(e) {
37
+ const params = { path: {}, query: {}, header: {}, cookie: {} };
38
+ for (const p of e.parameters)
39
+ params[p.in][p.name] = synth(p.schema);
40
+ return params;
41
+ }
42
+ /** Body-schema properties that declare an `enum` with more than one value — the "curious" style's
43
+ * one-case-per-additional-value expansion needs the full list (the happy path's `synth()` only ever
44
+ * sends the first). */
45
+ export function enumProps(schema) {
46
+ if (!schema || typeof schema !== "object")
47
+ return [];
48
+ const out = [];
49
+ for (const [name, sub] of Object.entries(schema.properties ?? {})) {
50
+ if (sub.enum && sub.enum.length > 1)
51
+ out.push([name, sub.enum]);
52
+ }
53
+ return out;
54
+ }
55
+ /** Build the happy-path case for one operation (API-9, #146: also reused by `scenarios.ts` per step —
56
+ * a scenario step is a normal case whose path params get overwritten with captured values at run time). */
57
+ export function toCase(e) {
58
+ const success = pickSuccess(e);
59
+ const expectedStatus = success?.status ?? "200";
60
+ return {
61
+ name: apiEndpointKey(e),
62
+ method: e.method,
63
+ path: e.path,
64
+ operationId: e.operationId,
65
+ params: synthRequiredParams(e),
66
+ body: e.requestBody?.schema !== undefined ? synth(e.requestBody.schema) : undefined,
67
+ expectedStatus,
68
+ expectedSchema: success?.schema,
69
+ ...(success?.links ? { responseLinks: success.links } : {}),
70
+ ...(e.requestBody?.mediaTypes[0] !== undefined ? { bodyMediaType: e.requestBody.mediaTypes[0] } : {}),
71
+ type: "Positive",
72
+ // Nominal happy-path = the valid equivalence class for this operation's inputs (ISO 29119-4).
73
+ technique: "equivalence-partitioning",
74
+ rationale: `Happy-path case in the valid equivalence class for ${e.method} ${e.path}: exercises the ` +
75
+ `required parameters/body with schema-valid values and asserts the declared success response ` +
76
+ `(${expectedStatus}).`,
77
+ };
78
+ }
79
+ /** Body-schema properties whose declared (primitive) type we can flip to something invalid — reused
80
+ * by the "psycho"/"hacker" adversarial styles (BORROW-07, #95) to target a string/numeric property. */
81
+ export function corruptibleProps(schema) {
82
+ if (!schema || typeof schema !== "object")
83
+ return [];
84
+ const out = [];
85
+ for (const [name, sub] of Object.entries(schema.properties ?? {})) {
86
+ const type = Array.isArray(sub.type) ? sub.type.find((t) => t !== "null") : sub.type;
87
+ if (typeof type === "string")
88
+ out.push([name, type]);
89
+ }
90
+ return out;
91
+ }
92
+ /** A JSON value of a different type than `type` — always a contract violation for that property. */
93
+ function wrongTypeValue(type) {
94
+ switch (type) {
95
+ case "string":
96
+ return 42;
97
+ case "integer":
98
+ case "number":
99
+ return "not-a-number";
100
+ case "boolean":
101
+ return "not-a-boolean";
102
+ default:
103
+ return "not-a-valid-value"; // array/object/other
104
+ }
105
+ }
106
+ /** The lowest declared 4xx status, else the generic "4XX" range (matched by the runner's `statusMatches`).
107
+ * Reused by the "psycho"/"hacker" adversarial styles (BORROW-07, #95) — same "expect rejection"
108
+ * convention as a negative case. */
109
+ export function pickErrorStatus(e) {
110
+ const fourXX = e.responses.filter((r) => /^4\d\d$/.test(r.status)).sort((a, b) => a.status.localeCompare(b.status));
111
+ return fourXX[0]?.status ?? "4XX";
112
+ }
113
+ /** The declared response schema for an EXACT status match, if the case picked one (not the "4XX" fallback). */
114
+ export function pickErrorSchema(e, expectedStatus) {
115
+ return e.responses.find((r) => r.status === expectedStatus)?.schema;
116
+ }
117
+ function buildNegativeCase(e, input, violation) {
118
+ const expectedStatus = pickErrorStatus(e);
119
+ return {
120
+ name: `${apiEndpointKey(e)} (negative)`,
121
+ method: e.method,
122
+ path: e.path,
123
+ operationId: e.operationId,
124
+ params: input.params,
125
+ body: input.body,
126
+ expectedStatus,
127
+ expectedSchema: pickErrorSchema(e, expectedStatus),
128
+ type: "Negative",
129
+ // Deliberately-invalid input, chosen from experience of common contract violations (ISO 29119-4).
130
+ technique: "error-guessing",
131
+ rationale: `Negative-schema case for ${e.method} ${e.path}: ${violation}, expecting the API to reject the ` +
132
+ `request (${expectedStatus}) rather than accept it.`,
133
+ };
134
+ }
135
+ function toNegativeCase(e) {
136
+ const bodySchema = e.requestBody?.schema;
137
+ if (bodySchema) {
138
+ const [prop] = corruptibleProps(bodySchema);
139
+ if (prop) {
140
+ const [name, type] = prop;
141
+ const body = synth(bodySchema);
142
+ body[name] = wrongTypeValue(type);
143
+ return buildNegativeCase(e, { body, params: synthRequiredParams(e) }, `sends "${name}" as the wrong type in the request body (expected ${type})`);
144
+ }
145
+ }
146
+ const nonPathRequired = e.parameters.find((p) => p.required && p.in !== "path");
147
+ if (nonPathRequired) {
148
+ return buildNegativeCase(e, { params: synthRequiredParams(e, nonPathRequired) }, `omits the required ${nonPathRequired.in} param "${nonPathRequired.name}"`);
149
+ }
150
+ return undefined; // nothing in this operation's contract is worth violating
151
+ }
152
+ /** The declared success response: the lowest 2xx, else `default`, else the first declared. */
153
+ function pickSuccess(e) {
154
+ const twoXX = e.responses.filter((r) => /^2\d\d$/.test(r.status)).sort((a, b) => a.status.localeCompare(b.status));
155
+ return twoXX[0] ?? e.responses.find((r) => r.status === "default") ?? e.responses[0];
156
+ }
157
+ /**
158
+ * Synthesise one valid value for a (dereferenced) JSON schema, respecting `example`/`default`/`enum`,
159
+ * types, `required` and `format`. `seen` guards the object cycles swagger-parser leaves behind for
160
+ * circular `$ref`s (e.g. `Pet.friends: Pet[]`) so recursion terminates.
161
+ */
162
+ function synth(schema, seen = new Set()) {
163
+ if (!schema || typeof schema !== "object")
164
+ return undefined;
165
+ const s = schema;
166
+ // Explicit values win, in spec-precedence order.
167
+ if (s.example !== undefined)
168
+ return s.example;
169
+ if (s.default !== undefined)
170
+ return s.default;
171
+ if (s.enum && s.enum.length)
172
+ return s.enum[0];
173
+ // Composition: allOf = merge all subschemas; one/anyOf = take the first branch.
174
+ if (s.allOf?.length)
175
+ return synth(mergeAllOf(s.allOf), seen);
176
+ if (s.oneOf?.length)
177
+ return synth(s.oneOf[0], seen);
178
+ if (s.anyOf?.length)
179
+ return synth(s.anyOf[0], seen);
180
+ const type = Array.isArray(s.type) ? s.type.find((t) => t !== "null") : s.type;
181
+ // Objects/arrays recurse — stop if we re-enter the same schema node (circular ref).
182
+ if (type === "object" || s.properties) {
183
+ if (seen.has(s))
184
+ return undefined;
185
+ return synthObject(s, new Set(seen).add(s));
186
+ }
187
+ if (type === "array") {
188
+ if (seen.has(s))
189
+ return [];
190
+ return s.items ? [synth(s.items, new Set(seen).add(s))].filter((v) => v !== undefined) : [];
191
+ }
192
+ switch (type) {
193
+ case "string":
194
+ // `format: binary` (e.g. a multipart file field) needs real bytes, not the literal word "string".
195
+ return s.format === "binary" ? synthBinary() : synthString(s.format);
196
+ case "integer":
197
+ case "number":
198
+ return s.minimum ?? 0;
199
+ case "boolean":
200
+ return true;
201
+ default:
202
+ return undefined; // untyped/unknown schema → omit
203
+ }
204
+ }
205
+ function synthObject(s, seen) {
206
+ const required = new Set(s.required ?? []);
207
+ const out = {};
208
+ for (const [key, sub] of Object.entries(s.properties ?? {})) {
209
+ const v = synth(sub, seen);
210
+ if (v !== undefined)
211
+ out[key] = v;
212
+ // A required field whose schema we couldn't synthesise (e.g. circular) still has to be present.
213
+ else if (required.has(key))
214
+ out[key] = null;
215
+ }
216
+ return out;
217
+ }
218
+ /** Shallow-merge `allOf` members into one object schema (enough for happy-path bodies). */
219
+ function mergeAllOf(parts) {
220
+ const merged = { type: "object", properties: {}, required: [] };
221
+ for (const p of parts) {
222
+ Object.assign(merged.properties, p.properties ?? {});
223
+ if (p.required)
224
+ merged.required.push(...p.required);
225
+ }
226
+ return merged;
227
+ }
228
+ /** A small in-memory placeholder for a `format: binary` property (API-10, #150) — real bytes so a
229
+ * multipart file field has actual "file" content to send; the runner (`runner.ts`) recognises a
230
+ * `Buffer` value and encodes it as a file part instead of a stringified form field. */
231
+ function synthBinary() {
232
+ return Buffer.from("cairn placeholder file content");
233
+ }
234
+ /** A format-appropriate sample string (valid for the common OpenAPI string formats). */
235
+ function synthString(format) {
236
+ switch (format) {
237
+ case "email":
238
+ return "user@example.com";
239
+ case "uuid":
240
+ return "00000000-0000-0000-0000-000000000000";
241
+ case "date":
242
+ return "2024-01-01";
243
+ case "date-time":
244
+ return "2024-01-01T00:00:00Z";
245
+ case "uri":
246
+ case "url":
247
+ return "https://example.com";
248
+ case "hostname":
249
+ return "example.com";
250
+ case "ipv4":
251
+ return "127.0.0.1";
252
+ default:
253
+ return "string";
254
+ }
255
+ }
256
+ //# sourceMappingURL=cases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cases.js","sourceRoot":"","sources":["../../src/api/cases.ts"],"names":[],"mappings":"AA0BA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,CAAyD;IACtF,OAAO,CAAC,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC;AAmDD,iGAAiG;AACjG,MAAM,UAAU,gBAAgB,CAAC,KAAe;IAC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