@maycombhq/atticus 0.0.0-stage → 2.0.0-beta.10

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 (497) hide show
  1. package/LICENSE +177 -0
  2. package/README.md +17 -2
  3. package/THIRD-PARTY-LICENSES.txt +2607 -0
  4. package/dist/bin.js +47 -0
  5. package/dist/chunk-23M2LUYM.js +55 -0
  6. package/dist/chunk-26PLPSQW.js +48 -0
  7. package/dist/chunk-2G4DFUWJ.js +43 -0
  8. package/dist/chunk-2HMWX4T6.js +226 -0
  9. package/dist/chunk-2KDSXJFJ.js +294 -0
  10. package/dist/chunk-2M6WXO73.js +38 -0
  11. package/dist/chunk-2RX7PI2Y.js +166 -0
  12. package/dist/chunk-2XM6PYQQ.js +199 -0
  13. package/dist/chunk-3G4YI4ZU.js +16 -0
  14. package/dist/chunk-3GTZ2OON.js +362 -0
  15. package/dist/chunk-3QAKDIEU.js +108 -0
  16. package/dist/chunk-47QE246J.js +6115 -0
  17. package/dist/chunk-4GZXS6S2.js +5401 -0
  18. package/dist/chunk-4PJADZRR.js +545 -0
  19. package/dist/chunk-4Q3NN7VF.js +32 -0
  20. package/dist/chunk-4QUQEBFT.js +143 -0
  21. package/dist/chunk-4SKZDI62.js +22 -0
  22. package/dist/chunk-4SVJNVEE.js +80 -0
  23. package/dist/chunk-52R2YXP5.js +80 -0
  24. package/dist/chunk-577AJVRS.js +44694 -0
  25. package/dist/chunk-5F3RJCHB.js +45 -0
  26. package/dist/chunk-5IALSMZ2.js +34 -0
  27. package/dist/chunk-5KTOPOEP.js +174 -0
  28. package/dist/chunk-5MI2SEV5.js +242 -0
  29. package/dist/chunk-5XDNUJ4P.js +2743 -0
  30. package/dist/chunk-5XN76FTF.js +22 -0
  31. package/dist/chunk-5YIBJXGB.js +2007 -0
  32. package/dist/chunk-62YMDXY6.js +38 -0
  33. package/dist/chunk-65C57N7P.js +116 -0
  34. package/dist/chunk-67J3VZBA.js +120 -0
  35. package/dist/chunk-6EDQE7GO.js +27809 -0
  36. package/dist/chunk-6GNS32SI.js +285 -0
  37. package/dist/chunk-6GWHKMQR.js +405 -0
  38. package/dist/chunk-6JLPXDWN.js +7923 -0
  39. package/dist/chunk-6TJCUYC5.js +22 -0
  40. package/dist/chunk-6VBXAGJX.js +234 -0
  41. package/dist/chunk-73VPWF5R.js +415 -0
  42. package/dist/chunk-76WKMA4J.js +14 -0
  43. package/dist/chunk-7DUDLVFJ.js +52 -0
  44. package/dist/chunk-7EFILTCI.js +67 -0
  45. package/dist/chunk-7EKESFWV.js +130 -0
  46. package/dist/chunk-7F2RUWPU.js +101 -0
  47. package/dist/chunk-7GB4ZRE2.js +378 -0
  48. package/dist/chunk-7TGYNOXD.js +189 -0
  49. package/dist/chunk-7UKVYFQ2.js +2078 -0
  50. package/dist/chunk-7URGP4DD.js +102 -0
  51. package/dist/chunk-7YYEKTYF.js +2522 -0
  52. package/dist/chunk-AJJK7GLO.js +252 -0
  53. package/dist/chunk-AKJTKMXU.js +25 -0
  54. package/dist/chunk-APSVL2AI.js +344 -0
  55. package/dist/chunk-AWECWW5Y.js +3206 -0
  56. package/dist/chunk-AY2IUF4K.js +5071 -0
  57. package/dist/chunk-B2VSVN4P.js +34 -0
  58. package/dist/chunk-B3O52AUQ.js +275 -0
  59. package/dist/chunk-B7434AE2.js +104 -0
  60. package/dist/chunk-BDEKREZH.js +155 -0
  61. package/dist/chunk-BJPMKJTL.js +1428 -0
  62. package/dist/chunk-BMCKL3VQ.js +324 -0
  63. package/dist/chunk-BMHGA7WD.js +25 -0
  64. package/dist/chunk-BUYJL3GJ.js +287 -0
  65. package/dist/chunk-BXIX7S7O.js +32 -0
  66. package/dist/chunk-CHC5FKTU.js +26 -0
  67. package/dist/chunk-CITDNDIZ.js +53 -0
  68. package/dist/chunk-CIUHAHM6.js +70 -0
  69. package/dist/chunk-CNKGYDMG.js +334 -0
  70. package/dist/chunk-CRE4BJHM.js +408 -0
  71. package/dist/chunk-D3PO4DOZ.js +261 -0
  72. package/dist/chunk-DAQBIK5G.js +47 -0
  73. package/dist/chunk-DDAHCPGA.js +212 -0
  74. package/dist/chunk-DPHCFZ7W.js +374 -0
  75. package/dist/chunk-DZRQDNPT.js +34 -0
  76. package/dist/chunk-E3JYO547.js +46 -0
  77. package/dist/chunk-E3Z67HRK.js +104 -0
  78. package/dist/chunk-EADP3PEN.js +450 -0
  79. package/dist/chunk-EX6ZXS5K.js +169 -0
  80. package/dist/chunk-EZIUFEN6.js +27 -0
  81. package/dist/chunk-F2FOQLJ7.js +430 -0
  82. package/dist/chunk-F7UQR4ZX.js +149 -0
  83. package/dist/chunk-F7YL2RZ4.js +94 -0
  84. package/dist/chunk-FEZE6NIA.js +69 -0
  85. package/dist/chunk-FJCFYKVO.js +1014 -0
  86. package/dist/chunk-FLOEZA6K.js +29 -0
  87. package/dist/chunk-FMKKVWZD.js +133 -0
  88. package/dist/chunk-FNHSVBRA.js +48 -0
  89. package/dist/chunk-FOGG4AUR.js +114 -0
  90. package/dist/chunk-FPGVOSOG.js +41 -0
  91. package/dist/chunk-FQSRHTTC.js +49 -0
  92. package/dist/chunk-FR7JPYBD.js +182 -0
  93. package/dist/chunk-FTV6I76U.js +211 -0
  94. package/dist/chunk-FV5YFR6I.js +540 -0
  95. package/dist/chunk-FZ2E5LGK.js +54 -0
  96. package/dist/chunk-FZL2HNWP.js +531 -0
  97. package/dist/chunk-G2E5MNYP.js +549 -0
  98. package/dist/chunk-G5SFOH7P.js +256 -0
  99. package/dist/chunk-GFXLPJWY.js +53 -0
  100. package/dist/chunk-GR6YKM55.js +480 -0
  101. package/dist/chunk-GXJVY6WT.js +250 -0
  102. package/dist/chunk-GZ4TKR3Q.js +928 -0
  103. package/dist/chunk-HB6XSGI6.js +131 -0
  104. package/dist/chunk-HE4ZQXZM.js +396 -0
  105. package/dist/chunk-HHUFVJF7.js +1019 -0
  106. package/dist/chunk-HKTUIMH4.js +76 -0
  107. package/dist/chunk-HUZQDKQK.js +48 -0
  108. package/dist/chunk-I7IWQIEB.js +58 -0
  109. package/dist/chunk-IDGSU7JF.js +1496 -0
  110. package/dist/chunk-ILFKECGI.js +69 -0
  111. package/dist/chunk-ISNZYKAS.js +53 -0
  112. package/dist/chunk-IUD3ME4E.js +251 -0
  113. package/dist/chunk-IV7BCWWN.js +101 -0
  114. package/dist/chunk-IZNSAEBX.js +164 -0
  115. package/dist/chunk-J5LHDJU4.js +400 -0
  116. package/dist/chunk-JAA53T23.js +172 -0
  117. package/dist/chunk-JF2NSTFO.js +47 -0
  118. package/dist/chunk-JMSEEBN4.js +41 -0
  119. package/dist/chunk-JQ7XQPQS.js +273 -0
  120. package/dist/chunk-KC5DROFC.js +16667 -0
  121. package/dist/chunk-KIAI6PWL.js +36 -0
  122. package/dist/chunk-KIHOIVST.js +18 -0
  123. package/dist/chunk-KM2FBM3T.js +659 -0
  124. package/dist/chunk-KQDZXGNR.js +14 -0
  125. package/dist/chunk-L4VJ4ETL.js +41 -0
  126. package/dist/chunk-LDKUC2QJ.js +49 -0
  127. package/dist/chunk-LK44ULGI.js +2043 -0
  128. package/dist/chunk-LRS573EX.js +104 -0
  129. package/dist/chunk-LTQANUDH.js +119 -0
  130. package/dist/chunk-LVGBKKSM.js +282 -0
  131. package/dist/chunk-MF7QH4AX.js +162 -0
  132. package/dist/chunk-MGVYVW7Q.js +915 -0
  133. package/dist/chunk-MH5OCRUM.js +240 -0
  134. package/dist/chunk-MKFYQQ5Q.js +36 -0
  135. package/dist/chunk-MKRBG5EF.js +1142 -0
  136. package/dist/chunk-MTAUZW2Z.js +2504 -0
  137. package/dist/chunk-MTEBM4Y4.js +39 -0
  138. package/dist/chunk-N3NBWIYQ.js +48 -0
  139. package/dist/chunk-N4QZJJVB.js +3851 -0
  140. package/dist/chunk-NGPU2ARF.js +1726 -0
  141. package/dist/chunk-NIXVDQVO.js +2929 -0
  142. package/dist/chunk-NNUASOAA.js +34 -0
  143. package/dist/chunk-NPCD54I7.js +226 -0
  144. package/dist/chunk-OEI7LVRP.js +856 -0
  145. package/dist/chunk-OGRWQ562.js +18 -0
  146. package/dist/chunk-OIU657QQ.js +95 -0
  147. package/dist/chunk-OJLRFGBP.js +128 -0
  148. package/dist/chunk-OS7PQ35Z.js +391 -0
  149. package/dist/chunk-OSGQW2Z6.js +104 -0
  150. package/dist/chunk-P3TKKBAH.js +131 -0
  151. package/dist/chunk-PEF5OEMB.js +163 -0
  152. package/dist/chunk-PGKHJYOB.js +706 -0
  153. package/dist/chunk-PIVKU64W.js +688 -0
  154. package/dist/chunk-PKCMRPPB.js +109 -0
  155. package/dist/chunk-QICFHVRW.js +15 -0
  156. package/dist/chunk-QKEFZRHS.js +166 -0
  157. package/dist/chunk-QWVBEK4P.js +113 -0
  158. package/dist/chunk-R4TBNKKC.js +3217 -0
  159. package/dist/chunk-R64GLVBO.js +2919 -0
  160. package/dist/chunk-R6B6XAKK.js +56 -0
  161. package/dist/chunk-R6RY4Q5T.js +51 -0
  162. package/dist/chunk-RK6MKKKP.js +471 -0
  163. package/dist/chunk-ROTY5J2L.js +25 -0
  164. package/dist/chunk-RRVT4MPS.js +150 -0
  165. package/dist/chunk-SS66Q4VE.js +231 -0
  166. package/dist/chunk-T4RTWMJD.js +310 -0
  167. package/dist/chunk-T6USVBEJ.js +105 -0
  168. package/dist/chunk-TM7LC37P.js +4044 -0
  169. package/dist/chunk-TV45EUGM.js +51 -0
  170. package/dist/chunk-TZDSDDSV.js +233 -0
  171. package/dist/chunk-UBWCUP3G.js +55 -0
  172. package/dist/chunk-UF7TAFJM.js +906 -0
  173. package/dist/chunk-UR7RMZ3R.js +19943 -0
  174. package/dist/chunk-UYYN2IUZ.js +1611 -0
  175. package/dist/chunk-V2TH46ZY.js +66 -0
  176. package/dist/chunk-VKMTFIWS.js +315 -0
  177. package/dist/chunk-VOGCSYOI.js +16 -0
  178. package/dist/chunk-W5OYJMBT.js +41 -0
  179. package/dist/chunk-WARBF2KY.js +296 -0
  180. package/dist/chunk-WGZWR4RF.js +130 -0
  181. package/dist/chunk-WLIIQ2A4.js +18 -0
  182. package/dist/chunk-X4W4XXWP.js +134 -0
  183. package/dist/chunk-XB5RFZHH.js +1217 -0
  184. package/dist/chunk-XEG3FE2R.js +766 -0
  185. package/dist/chunk-XIWYUQZQ.js +583 -0
  186. package/dist/chunk-XKS6THI5.js +31 -0
  187. package/dist/chunk-XKZHAD6Y.js +184 -0
  188. package/dist/chunk-XNYNEEBR.js +214 -0
  189. package/dist/chunk-XPCWQXTY.js +37 -0
  190. package/dist/chunk-XPEEICAO.js +325 -0
  191. package/dist/chunk-XQ3YIV5R.js +3507 -0
  192. package/dist/chunk-XRO65C7V.js +1079 -0
  193. package/dist/chunk-XTVDAHH2.js +203 -0
  194. package/dist/chunk-XZRON6IV.js +131 -0
  195. package/dist/chunk-Y4BRGOJR.js +523 -0
  196. package/dist/chunk-Y5PZHS4K.js +3898 -0
  197. package/dist/chunk-Y7KBQ4BD.js +230 -0
  198. package/dist/chunk-YFSSNGLR.js +277 -0
  199. package/dist/chunk-YGKYFMSL.js +60 -0
  200. package/dist/chunk-YGR6OCHQ.js +345 -0
  201. package/dist/chunk-YIEOFHOL.js +30 -0
  202. package/dist/chunk-YLAJAI2W.js +180 -0
  203. package/dist/chunk-YMOJD5BO.js +50 -0
  204. package/dist/chunk-YPBQNJHA.js +33 -0
  205. package/dist/chunk-YPIEYQF4.js +307 -0
  206. package/dist/chunk-YVLMBAYE.js +221 -0
  207. package/dist/chunk-YXJ4XOHF.js +376 -0
  208. package/dist/chunk-ZE3P35DA.js +1247 -0
  209. package/dist/chunk-ZONE6E3Z.js +32 -0
  210. package/dist/chunk-ZP4FJHR4.js +95 -0
  211. package/dist/chunk-ZZXF6OOJ.js +119 -0
  212. package/dist/files.json +1976 -0
  213. package/dist/fixtures/forge/README.md +19 -0
  214. package/dist/fixtures/forge/expected/discrepancies.yaml +54 -0
  215. package/dist/fixtures/forge/expected/inputs.yaml +38 -0
  216. package/dist/fixtures/forge/expected/scan.yaml +342 -0
  217. package/dist/fixtures/forge/inputs/diagrams/forge-context.drawio +23 -0
  218. package/dist/fixtures/forge/inputs/partner-specs/northwind-pay-openapi.yaml +11 -0
  219. package/dist/fixtures/forge/inputs/tickets/ado-stories.json +4 -0
  220. package/dist/fixtures/forge/inputs/tickets/closed-service-requests.json +5 -0
  221. package/dist/fixtures/forge/inputs/wiki/integration-patterns.md +11 -0
  222. package/dist/fixtures/forge/inputs/wiki/ledger-solution-spec.md +9 -0
  223. package/dist/fixtures/forge/inputs/wiki/snow-firewall-request.md +4 -0
  224. package/dist/fixtures/forge/metarepo/judgments/reaches/84af5b6af24f7ca8c23013f3.yaml +17 -0
  225. package/dist/fixtures/forge/metarepo/judgments/reaches/c3917555edebddce8cecb647.yaml +17 -0
  226. package/dist/fixtures/forge/metarepo/judgments/reaches/c5fafd6601f8ca9e34e0bbd0.yaml +17 -0
  227. package/dist/fixtures/forge/metarepo/org-pack/agents/architecture-critic.yaml +9 -0
  228. package/dist/fixtures/forge/metarepo/org-pack/agents/story-writer.yaml +10 -0
  229. package/dist/fixtures/forge/metarepo/org-pack/checklists/architecture.yaml +115 -0
  230. package/dist/fixtures/forge/metarepo/org-pack/dialects/forge.yaml +111 -0
  231. package/dist/fixtures/forge/metarepo/org-pack/gates.yaml +22 -0
  232. package/dist/fixtures/forge/metarepo/org-pack/pack.yaml +11 -0
  233. package/dist/fixtures/forge/metarepo/org-pack/patterns/A.EB.PUB.yaml +12 -0
  234. package/dist/fixtures/forge/metarepo/org-pack/patterns/D.JDBC.yaml +12 -0
  235. package/dist/fixtures/forge/metarepo/org-pack/patterns/S.DIR.BFF.yaml +12 -0
  236. package/dist/fixtures/forge/metarepo/org-pack/patterns/S.GW.SOR.yaml +13 -0
  237. package/dist/fixtures/forge/metarepo/org-pack/patterns/S.GW.VND.yaml +14 -0
  238. package/dist/fixtures/forge/metarepo/org-pack/process/change-templates/feature.md +37 -0
  239. package/dist/fixtures/forge/metarepo/org-pack/process/skills/add-forge-endpoint/SKILL.md +17 -0
  240. package/dist/fixtures/forge/metarepo/org-pack/process/snow/firewall-rule.yaml +14 -0
  241. package/dist/fixtures/forge/metarepo/org-pack/process/snow/gateway-route.yaml +13 -0
  242. package/dist/fixtures/forge/metarepo/org-pack/profiles/forge/profile.yaml +12 -0
  243. package/dist/fixtures/forge/metarepo/org-pack/profiles/forge/repos.manifest.yaml +44 -0
  244. package/dist/fixtures/forge/metarepo/org-pack/roles.yaml +14 -0
  245. package/dist/fixtures/forge/metarepo/org-pack/runtime.yaml +14 -0
  246. package/dist/fixtures/forge/metarepo/org-pack/sources.yaml +3 -0
  247. package/dist/fixtures/forge/repos/forge-events/topics/payments.initiated.yaml +4 -0
  248. package/dist/fixtures/forge/repos/forge-events/topics/transfers.completed.yaml +4 -0
  249. package/dist/fixtures/forge/repos/forge-gateway/proxies/ledger-v1/apiproxy/ledger-v1.xml +3 -0
  250. package/dist/fixtures/forge/repos/forge-gateway/proxies/ledger-v1/apiproxy/policies/SpikeArrest.xml +3 -0
  251. package/dist/fixtures/forge/repos/forge-gateway/proxies/ledger-v1/apiproxy/policies/VerifyOAuth.xml +4 -0
  252. package/dist/fixtures/forge/repos/forge-gateway/proxies/ledger-v1/apiproxy/proxies/default.xml +14 -0
  253. package/dist/fixtures/forge/repos/forge-gateway/proxies/ledger-v1/apiproxy/targets/ledger.xml +5 -0
  254. package/dist/fixtures/forge/repos/forge-infra/alerts/ledger-api.yaml +5 -0
  255. package/dist/fixtures/forge/repos/forge-infra/k8s/ledger-api.yaml +15 -0
  256. package/dist/fixtures/forge/repos/forge-infra/k8s/portal-bff.yaml +7 -0
  257. package/dist/fixtures/forge/repos/forge-infra/terraform/ledger-db.tf +9 -0
  258. package/dist/fixtures/forge/repos/forge-ledger/api/ledger-openapi.yaml +31 -0
  259. package/dist/fixtures/forge/repos/forge-ledger/forge.yaml +4 -0
  260. package/dist/fixtures/forge/repos/forge-ledger/src/main/java/forge/ledger/LedgerEndpoints.java +13 -0
  261. package/dist/fixtures/forge/repos/forge-ledger/src/main/java/forge/ledger/LedgerEvents.java +11 -0
  262. package/dist/fixtures/forge/repos/forge-ledger/src/main/java/forge/ledger/NorthwindClient.java +10 -0
  263. package/dist/fixtures/forge/repos/forge-ledger/src/main/resources/application.yml +3 -0
  264. package/dist/fixtures/forge/repos/forge-ledger/src/main/resources/db/migration/V1__create_account.sql +5 -0
  265. package/dist/fixtures/forge/repos/forge-ledger/src/main/resources/db/migration/V2__create_entry.sql +7 -0
  266. package/dist/fixtures/forge/repos/forge-portal-bff/pom.xml +1 -0
  267. package/dist/fixtures/forge/repos/forge-portal-bff/src/main/java/forge/portal/AuditPublisher.java +12 -0
  268. package/dist/fixtures/forge/repos/forge-portal-bff/src/main/java/forge/portal/BalanceController.java +16 -0
  269. package/dist/fixtures/forge/repos/forge-portal-bff/src/main/java/forge/portal/LedgerClient.java +13 -0
  270. package/dist/fixtures/forge/repos/forge-portal-bff/src/main/java/forge/portal/PaymentEvents.java +13 -0
  271. package/dist/fixtures/forge/repos/forge-portal-bff/src/main/resources/application.yml +8 -0
  272. package/dist/fixtures/forge/repos/forge-portal-ui/package.json +1 -0
  273. package/dist/fixtures/forge/repos/forge-portal-ui/src/api/balance.ts +5 -0
  274. package/dist/fixtures/forge/repos/forge-reports-job/src/main/java/forge/reports/DailyEntriesJob.java +19 -0
  275. package/dist/fixtures/forge/repos/forge-reports-job/src/main/resources/application.yml +3 -0
  276. package/dist/fixtures/forge-change/README.md +41 -0
  277. package/dist/fixtures/forge-change/expected/findings.yaml +301 -0
  278. package/dist/fixtures/forge-change/expected/stories.yaml +101 -0
  279. package/dist/fixtures/forge-change/judgments/personal-data/0b5f3dbf5257a22275d8c74b.yaml +18 -0
  280. package/dist/fixtures/forge-change/judgments/personal-data/2759a66770134c417440bf2d.yaml +18 -0
  281. package/dist/fixtures/forge-change/judgments/personal-data/31b1ea2f14d0737f1aca79fd.yaml +18 -0
  282. package/dist/fixtures/forge-change/judgments/personal-data/49afd70c08228e65ad6ca1ed.yaml +18 -0
  283. package/dist/fixtures/forge-change/judgments/personal-data/761cabcb8a39f5e5866d2dd6.yaml +18 -0
  284. package/dist/fixtures/forge-change/judgments/personal-data/adae902b90cc8ffa0c765145.yaml +18 -0
  285. package/dist/fixtures/forge-change/judgments/personal-data/ba11bb933105ec9493e065dd.yaml +18 -0
  286. package/dist/fixtures/forge-change/judgments/personal-data/bdbcd1cdac3021c68063c3e7.yaml +18 -0
  287. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/brief.md +35 -0
  288. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/change.yaml +120 -0
  289. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/data.md +18 -0
  290. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/design.md +29 -0
  291. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/interfaces.md +17 -0
  292. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/mappings.md +26 -0
  293. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/proposal.md +35 -0
  294. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/snow.md +12 -0
  295. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/specs/transfer-limits/spec.md +19 -0
  296. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/stories/s1-refuse-over-limit.md +17 -0
  297. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/stories/s2-show-remaining.md +16 -0
  298. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/stories/s3-audit-refusals.md +18 -0
  299. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/stories/s4-velocity-check.md +16 -0
  300. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/stories.md +8 -0
  301. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/tasks.md +12 -0
  302. package/dist/fixtures/forge-change/openspec/changes/add-transfer-limit/ux.md +7 -0
  303. package/dist/fixtures/forge-change/org-pack/agents/code-and-test-critic.yaml +13 -0
  304. package/dist/fixtures/forge-change/org-pack/agents/complete-critic.yaml +12 -0
  305. package/dist/fixtures/forge-change/org-pack/agents/safe-critic.yaml +12 -0
  306. package/dist/fixtures/forge-change/org-pack/agents/ship-critic.yaml +11 -0
  307. package/dist/fixtures/forge-change/org-pack/agents/true-critic.yaml +11 -0
  308. package/dist/fixtures/forge-change/org-pack/checklists/review.yaml +54 -0
  309. package/dist/fixtures/forge-change/org-pack/gates.yaml +25 -0
  310. package/dist/fixtures/forge-change/org-pack/teams/team-ledger/checklists/ledger-team.yaml +227 -0
  311. package/dist/fixtures/forge-change/recordings/complete-critic/2ad84f84bf39c1d5412697e69fe23034d6983ec45a00314bf0975e627589a3c5.json +12 -0
  312. package/dist/fixtures/forge-change/recordings/complete-critic/417c98d8e54a4387d0fd93441c49f44c2868958739070d855c1dce0c41e24db3.json +12 -0
  313. package/dist/fixtures/forge-change/recordings/complete-critic/50203ee22e9cb3ef047295edb6538fe7d5695e1e4b139f3c929013dc6ce47021.json +12 -0
  314. package/dist/fixtures/forge-change/recordings/complete-critic/89f18d67f5d9c325bf35e2a9e020f9ddb6ee13b8523315037f0905cc57c040b1.json +12 -0
  315. package/dist/fixtures/forge-change/recordings/complete-critic/b4097867d26ae8eadc8b9efa8cdd86897013358035f0b40086c299a59c4ba121.json +12 -0
  316. package/dist/fixtures/forge-change/recordings/safe-critic/302d06f49664dd67ad2e21ab9cf74c1b0f7d3f750709c6ed8eff2b70983274e2.json +12 -0
  317. package/dist/fixtures/forge-change/recordings/safe-critic/32f1049c9a5ab4a759543290db4644ec6e221cc45fdfdcf06193837c6a8ce0b9.json +12 -0
  318. package/dist/fixtures/forge-change/recordings/safe-critic/4e4a84bfc04b9f26ca4250319a879901ff7a1c081c71e46a117675fee05026b0.json +12 -0
  319. package/dist/fixtures/forge-change/recordings/safe-critic/604af0fcdd6df6b76208fa88305fdc15c37606c2a4d1ae816477e46ac8c2dd04.json +12 -0
  320. package/dist/fixtures/forge-change/recordings/safe-critic/f0bf50af11f14c50d07904f0dffe1c8c20fb0cd89770645a8824c1d30a443955.json +12 -0
  321. package/dist/fixtures/forge-change/recordings/ship-critic/350954b58833b2c04880c67db45a1b328b7fd541d9f0d943b63905b8875488a6.json +12 -0
  322. package/dist/fixtures/forge-change/recordings/ship-critic/4af95c6c96a206777cec9de1f9c2d8c55a36ddc9b8db2f81d6eb83217b835efa.json +12 -0
  323. package/dist/fixtures/forge-change/recordings/ship-critic/76c34522a49cf7587a4e5689a5030d384603fa780b8aba97d27815cbc829683e.json +12 -0
  324. package/dist/fixtures/forge-change/recordings/ship-critic/a3b2cd1ace48587e5994333db03b34c3a0f9dec4f1932f1730ddfb687f6918c8.json +12 -0
  325. package/dist/fixtures/forge-change/recordings/ship-critic/de288a4fa64d0fc20890f9a787080ce6eac5203b7b9b72d884df11e8cf111835.json +12 -0
  326. package/dist/fixtures/forge-change/recordings/story-writer/1ddb00eac2aaf91a5ec5d9dfd220116be9f75aec6546a4a3a3b050ed89af2864.json +12 -0
  327. package/dist/packages/assistant-kit/frameworks-kit/README.md +86 -0
  328. package/dist/packages/assistant-kit/frameworks-kit/checklist.md +11 -0
  329. package/dist/packages/assistant-kit/frameworks-kit/examples/tide-lantern.yaml +56 -0
  330. package/dist/packages/assistant-kit/frameworks-kit/examples/tide-platform.yaml +43 -0
  331. package/dist/packages/assistant-kit/frameworks-kit/prompts/write-framework-model.md +12 -0
  332. package/dist/packages/assistant-kit/kit/README.md +98 -0
  333. package/dist/packages/assistant-kit/kit/c2-reference.md +334 -0
  334. package/dist/packages/assistant-kit/kit/checklist.md +39 -0
  335. package/dist/packages/assistant-kit/kit/examples/house-http-client.yaml +102 -0
  336. package/dist/packages/assistant-kit/kit/examples/tide-apigee.yaml +56 -0
  337. package/dist/packages/assistant-kit/kit/examples/tide-apim.yaml +32 -0
  338. package/dist/packages/assistant-kit/kit/examples/tide-kong.yaml +44 -0
  339. package/dist/packages/assistant-kit/kit/prompts/write-dialect.md +34 -0
  340. package/dist/packages/assistant-kit/kit/worked-example.md +198 -0
  341. package/dist/packages/conformance/sample/README.md +4 -0
  342. package/dist/packages/conformance/sample/inputs/notes.md +3 -0
  343. package/dist/packages/conformance/sample/inputs/systems.csv +3 -0
  344. package/dist/packages/conformance/sample/repo/api/greeter.proto +6 -0
  345. package/dist/packages/conformance/sample/repo/api/openapi.yaml +10 -0
  346. package/dist/packages/conformance/sample/repo/api/schema.graphql +3 -0
  347. package/dist/packages/conformance/sample/repo/db/V1__create_greeting.sql +4 -0
  348. package/dist/packages/conformance/sample/repo/package.json +7 -0
  349. package/dist/packages/conformance/sample/repo/src/main/java/sample/HelloController.java +10 -0
  350. package/dist/packages/conformance/sample/repo/web/app.ts +4 -0
  351. package/dist/packages/evals/datasets/critic-lenses.yaml +62 -0
  352. package/dist/packages/evals/datasets/dialect-writer.yaml +14 -0
  353. package/dist/packages/evals/datasets/feature-namer.yaml +34 -0
  354. package/dist/packages/evals/datasets/glossary-definer.yaml +25 -0
  355. package/dist/packages/evals/datasets/story-writer.yaml +13 -0
  356. package/dist/packages/evals/datasets/template-writer.yaml +16 -0
  357. package/dist/packages/evals/datasets/test-writer.yaml +18 -0
  358. package/dist/packages/executors/reference/reference-executor.mjs +233 -0
  359. package/dist/packages/extractors/dialects/argocd.yaml +45 -0
  360. package/dist/packages/extractors/dialects/fixtures/jaxrs/accounts-service/src/main/java/forge/accounts/AccountResource.java +47 -0
  361. package/dist/packages/extractors/dialects/fixtures/jaxrs/accounts-service/src/main/java/forge/accounts/AuditClient.java +12 -0
  362. package/dist/packages/extractors/dialects/fixtures/jaxrs/accounts-service/src/main/java/forge/accounts/LedgerClient.java +17 -0
  363. package/dist/packages/extractors/dialects/fixtures/micronaut/statements-service/src/main/java/forge/statements/LedgerClient.java +14 -0
  364. package/dist/packages/extractors/dialects/fixtures/micronaut/statements-service/src/main/java/forge/statements/RatesClient.java +11 -0
  365. package/dist/packages/extractors/dialects/fixtures/micronaut/statements-service/src/main/java/forge/statements/StatementController.java +36 -0
  366. package/dist/packages/extractors/dialects/fixtures/micronaut/statements-service/src/main/resources/application.yml +7 -0
  367. package/dist/packages/extractors/dialects/fixtures/quarkus-reactive-messaging/fraud-service/src/main/java/forge/fraud/FraudScorer.java +27 -0
  368. package/dist/packages/extractors/dialects/fixtures/quarkus-reactive-messaging/fraud-service/src/main/resources/application.properties +4 -0
  369. package/dist/packages/extractors/dialects/fixtures/terraform-aws/forge-aws-infra/envs/prod/api.tf +38 -0
  370. package/dist/packages/extractors/dialects/fixtures/terraform-aws/forge-aws-infra/envs/prod/main.tf +95 -0
  371. package/dist/packages/extractors/dialects/fixtures/terraform-aws/forge-aws-infra/envs/prod/terraform.tfvars +1 -0
  372. package/dist/packages/extractors/dialects/fixtures/terraform-aws/forge-aws-infra/envs/prod/variables.tf +4 -0
  373. package/dist/packages/extractors/dialects/fixtures/terraform-azure/forge-azure-infra/main.tf +102 -0
  374. package/dist/packages/extractors/dialects/fixtures/terraform-gcp/forge-gcp-infra/main.tf +51 -0
  375. package/dist/packages/extractors/dialects/harness.yaml +101 -0
  376. package/dist/packages/extractors/dialects/jaxrs.yaml +155 -0
  377. package/dist/packages/extractors/dialects/micronaut.yaml +207 -0
  378. package/dist/packages/extractors/dialects/quarkus-reactive-messaging.yaml +158 -0
  379. package/dist/packages/extractors/dialects/tekton.yaml +71 -0
  380. package/dist/packages/extractors/dialects/terraform-aws.yaml +267 -0
  381. package/dist/packages/extractors/dialects/terraform-azure.yaml +212 -0
  382. package/dist/packages/extractors/dialects/terraform-gcp.yaml +109 -0
  383. package/dist/packages/extractors/grammars/README.md +11 -0
  384. package/dist/packages/extractors/grammars/tree-sitter-groovy.LICENSE +21 -0
  385. package/dist/packages/extractors/grammars/tree-sitter-groovy.wasm +0 -0
  386. package/dist/packages/extractors/grammars/vendored.json +11 -0
  387. package/dist/packages/learn/lessons/architect-diagrams-and-code.yaml +69 -0
  388. package/dist/packages/learn/lessons/business-analyst-story-bar.yaml +94 -0
  389. package/dist/packages/learn/lessons/delivery-lead-release-readiness.yaml +44 -0
  390. package/dist/packages/learn/lessons/designer-features-in-user-words.yaml +57 -0
  391. package/dist/packages/learn/lessons/developer-find-your-way.yaml +60 -0
  392. package/dist/packages/learn/lessons/everyone-first-hour.yaml +74 -0
  393. package/dist/packages/learn/lessons/platform-lead-coverage-and-defences.yaml +58 -0
  394. package/dist/packages/learn/lessons/product-owner-first-change.yaml +167 -0
  395. package/dist/packages/learn/lessons/qa-tests-and-trace.yaml +53 -0
  396. package/dist/packages/learn/lessons/team-lead-initiative.yaml +146 -0
  397. package/dist/packages/naysayer/constitution/constitution.yaml +305 -0
  398. package/dist/packages/naysayer/starter/review.yaml +256 -0
  399. package/dist/packages/sdk/npm/index.js +9780 -0
  400. package/dist/packages/speckit/rules/drift.yaml +78 -0
  401. package/dist/packages/taskrun/rules/conform.yaml +38 -0
  402. package/dist/packages/testgen/rules/trace.yaml +49 -0
  403. package/dist/packages/ui/dist/assets/elk-api-Mo5w5xCa.js +2 -0
  404. package/dist/packages/ui/dist/assets/elk-worker.min--dAJroGl.js +6401 -0
  405. package/dist/packages/ui/dist/assets/elk-worker.min-DdYmS5kP.js +2 -0
  406. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-400-normal-BTotfTJu.woff +0 -0
  407. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-400-normal-DZqxrq2p.woff2 +0 -0
  408. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-500-normal-ByOcLdNv.woff +0 -0
  409. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-500-normal-CocWQlwt.woff2 +0 -0
  410. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-600-normal-71GNu3SW.woff2 +0 -0
  411. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-600-normal-BGq0mW3O.woff +0 -0
  412. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-ext-400-normal-Dsrv2Tcn.woff +0 -0
  413. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-ext-400-normal-g30qAdWV.woff2 +0 -0
  414. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-ext-500-normal-Cs5J6C77.woff2 +0 -0
  415. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-ext-500-normal-DB5PtV2g.woff +0 -0
  416. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-ext-600-normal-Bz0x94Yp.woff +0 -0
  417. package/dist/packages/ui/dist/assets/ibm-plex-sans-cyrillic-ext-600-normal-DUMzJB7m.woff2 +0 -0
  418. package/dist/packages/ui/dist/assets/ibm-plex-sans-greek-400-normal-D9ESIMu3.woff +0 -0
  419. package/dist/packages/ui/dist/assets/ibm-plex-sans-greek-400-normal-_efipK4i.woff2 +0 -0
  420. package/dist/packages/ui/dist/assets/ibm-plex-sans-greek-500-normal-CuWXN6rf.woff +0 -0
  421. package/dist/packages/ui/dist/assets/ibm-plex-sans-greek-500-normal-JMMifIXV.woff2 +0 -0
  422. package/dist/packages/ui/dist/assets/ibm-plex-sans-greek-600-normal-D-CqTdkO.woff +0 -0
  423. package/dist/packages/ui/dist/assets/ibm-plex-sans-greek-600-normal-DzTrcv_p.woff2 +0 -0
  424. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  425. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  426. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  427. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  428. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  429. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  430. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-ext-400-normal-C5H60-Va.woff2 +0 -0
  431. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-ext-400-normal-RBey6euL.woff +0 -0
  432. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-ext-500-normal-D0aIdm-b.woff +0 -0
  433. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-ext-500-normal-DakdToA3.woff2 +0 -0
  434. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-ext-600-normal-DIrixKbi.woff +0 -0
  435. package/dist/packages/ui/dist/assets/ibm-plex-sans-latin-ext-600-normal-DOrvGEcy.woff2 +0 -0
  436. package/dist/packages/ui/dist/assets/ibm-plex-sans-vietnamese-400-normal-DG4YqDda.woff2 +0 -0
  437. package/dist/packages/ui/dist/assets/ibm-plex-sans-vietnamese-400-normal-fK1oJ5dG.woff +0 -0
  438. package/dist/packages/ui/dist/assets/ibm-plex-sans-vietnamese-500-normal-BEb3_waV.woff +0 -0
  439. package/dist/packages/ui/dist/assets/ibm-plex-sans-vietnamese-500-normal-e4dixQRQ.woff2 +0 -0
  440. package/dist/packages/ui/dist/assets/ibm-plex-sans-vietnamese-600-normal-DgdngZtN.woff +0 -0
  441. package/dist/packages/ui/dist/assets/ibm-plex-sans-vietnamese-600-normal-DpPYBSTl.woff2 +0 -0
  442. package/dist/packages/ui/dist/assets/index-Bp3XhPHX.css +1 -0
  443. package/dist/packages/ui/dist/assets/index-DM212ZbV.js +29 -0
  444. package/dist/packages/ui/dist/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  445. package/dist/packages/ui/dist/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  446. package/dist/packages/ui/dist/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
  447. package/dist/packages/ui/dist/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
  448. package/dist/packages/ui/dist/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  449. package/dist/packages/ui/dist/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  450. package/dist/packages/ui/dist/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
  451. package/dist/packages/ui/dist/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
  452. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  453. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  454. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  455. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
  456. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  457. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  458. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
  459. package/dist/packages/ui/dist/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
  460. package/dist/packages/ui/dist/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  461. package/dist/packages/ui/dist/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
  462. package/dist/packages/ui/dist/assets/rajdhani-devanagari-600-normal-BtY48IV_.woff +0 -0
  463. package/dist/packages/ui/dist/assets/rajdhani-devanagari-600-normal-DhS7ScYx.woff2 +0 -0
  464. package/dist/packages/ui/dist/assets/rajdhani-devanagari-700-normal-BQQOj9BB.woff2 +0 -0
  465. package/dist/packages/ui/dist/assets/rajdhani-devanagari-700-normal-DBRwWuxA.woff +0 -0
  466. package/dist/packages/ui/dist/assets/rajdhani-latin-600-normal-CXCVEoA9.woff2 +0 -0
  467. package/dist/packages/ui/dist/assets/rajdhani-latin-600-normal-Dx02qI2_.woff +0 -0
  468. package/dist/packages/ui/dist/assets/rajdhani-latin-700-normal-BPDUZo87.woff2 +0 -0
  469. package/dist/packages/ui/dist/assets/rajdhani-latin-700-normal-e0Uj8ZlN.woff +0 -0
  470. package/dist/packages/ui/dist/assets/rajdhani-latin-ext-600-normal-BleIgkPp.woff +0 -0
  471. package/dist/packages/ui/dist/assets/rajdhani-latin-ext-600-normal-C9ZjJQAt.woff2 +0 -0
  472. package/dist/packages/ui/dist/assets/rajdhani-latin-ext-700-normal-BPaQ7tlD.woff +0 -0
  473. package/dist/packages/ui/dist/assets/rajdhani-latin-ext-700-normal-S6aYESQK.woff2 +0 -0
  474. package/dist/packages/ui/dist/favicon.svg +1 -0
  475. package/dist/packages/ui/dist/index.html +15 -0
  476. package/dist/third-party.json +575 -0
  477. package/dist/vendor/@fission-ai/openspec/bin/openspec.js +85986 -0
  478. package/dist/vendor/@fission-ai/openspec/package.json +82 -0
  479. package/dist/vendor/@fission-ai/openspec/schemas/spec-driven/schema.yaml +248 -0
  480. package/dist/vendor/@fission-ai/openspec/schemas/spec-driven/templates/design.md +21 -0
  481. package/dist/vendor/@fission-ai/openspec/schemas/spec-driven/templates/proposal.md +34 -0
  482. package/dist/vendor/@fission-ai/openspec/schemas/spec-driven/templates/spec.md +13 -0
  483. package/dist/vendor/@fission-ai/openspec/schemas/spec-driven/templates/tasks.md +11 -0
  484. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  485. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  486. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  487. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  488. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  489. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  490. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  491. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  492. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  493. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  494. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  495. package/dist/vendor/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  496. package/dist/vendor/web-tree-sitter/tree-sitter.wasm +0 -0
  497. package/package.json +36 -3
@@ -0,0 +1,766 @@
1
+ import { createRequire as __atticusCreateRequire } from "node:module";
2
+ import { fileURLToPath as __atticusFileURLToPath } from "node:url";
3
+ var require = __atticusCreateRequire(import.meta.url);
4
+ var __atticusUrl = (p) => new URL("./" + p, import.meta.url).href;
5
+ var __atticusPath = (p) => __atticusFileURLToPath(__atticusUrl(p));
6
+ import {
7
+ require_dist
8
+ } from "./chunk-577AJVRS.js";
9
+ import {
10
+ __toESM
11
+ } from "./chunk-TV45EUGM.js";
12
+
13
+ // packages/stubs/dist/spec.js
14
+ var import_yaml = __toESM(require_dist(), 1);
15
+
16
+ // packages/stubs/dist/schema.js
17
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18
+ var isSchema = (s) => typeof s === "object" && s !== null && !Array.isArray(s);
19
+ var types = (s) => {
20
+ const t = s.type === void 0 ? [] : Array.isArray(s.type) ? s.type : [s.type];
21
+ return s.nullable && t.length > 0 && !t.includes("null") ? [...t, "null"] : t;
22
+ };
23
+ var FORMATS = {
24
+ date: {
25
+ test: (s) => /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/.test(s),
26
+ message: "must be a date (YYYY-MM-DD)"
27
+ },
28
+ "date-time": {
29
+ test: (s) => /^\d{4}-\d{2}-\d{2}[Tt ]\d{2}:\d{2}:\d{2}(\.\d+)?([Zz]|[+-]\d{2}:\d{2})$/.test(s) && !Number.isNaN(Date.parse(s)),
30
+ message: "must be a date-time (RFC 3339)"
31
+ },
32
+ uuid: {
33
+ test: (s) => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s),
34
+ message: "must be a UUID"
35
+ },
36
+ email: { test: (s) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s), message: "must be an email address" },
37
+ uri: { test: (s) => /^[a-z][a-z0-9+.-]*:\S*$/i.test(s), message: "must be a URI" },
38
+ ipv4: {
39
+ test: (s) => /^((25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(25[0-5]|2[0-4]\d|1?\d?\d)$/.test(s),
40
+ message: "must be an IPv4 address"
41
+ }
42
+ };
43
+ var TYPE_MESSAGE = {
44
+ string: "must be a string",
45
+ integer: "must be an integer",
46
+ number: "must be a number",
47
+ boolean: "must be true or false",
48
+ object: "must be an object",
49
+ array: "must be an array",
50
+ null: "must be null"
51
+ };
52
+ function hasType(v, t) {
53
+ switch (t) {
54
+ case "string":
55
+ return typeof v === "string";
56
+ case "integer":
57
+ return typeof v === "number" && Number.isInteger(v);
58
+ case "number":
59
+ return typeof v === "number" && Number.isFinite(v);
60
+ case "boolean":
61
+ return typeof v === "boolean";
62
+ case "object":
63
+ return isObj(v);
64
+ case "array":
65
+ return Array.isArray(v);
66
+ case "null":
67
+ return v === null;
68
+ default:
69
+ return true;
70
+ }
71
+ }
72
+ var pointerPart = (k) => k.replace(/~/g, "~0").replace(/\//g, "~1");
73
+ var show = (v) => typeof v === "string" ? v : JSON.stringify(v);
74
+ function validate(value, schema, pointer = "", direction = "request") {
75
+ if (!isSchema(schema))
76
+ return [];
77
+ const errors = [];
78
+ const err = (message, p = pointer) => errors.push({ pointer: p, message });
79
+ for (const sub of schema.allOf ?? [])
80
+ errors.push(...validate(value, sub, pointer, direction));
81
+ const alts = schema.oneOf ?? schema.anyOf;
82
+ if (alts && alts.length > 0 && !alts.some((a) => validate(value, a, pointer, direction).length === 0))
83
+ err("doesn't match any of the allowed shapes");
84
+ const t = types(schema);
85
+ if (t.length > 0 && !t.some((x) => hasType(value, x))) {
86
+ err(TYPE_MESSAGE[t.find((x) => x !== "null") ?? "null"] ?? `must be ${t.join(" or ")}`);
87
+ return errors;
88
+ }
89
+ if (value === null)
90
+ return errors;
91
+ if (schema.const !== void 0 && JSON.stringify(schema.const) !== JSON.stringify(value))
92
+ err(`must be ${show(schema.const)}`);
93
+ if (schema.enum && !schema.enum.some((e) => JSON.stringify(e) === JSON.stringify(value)))
94
+ err(`must be one of ${schema.enum.map(show).join(", ")}`);
95
+ if (typeof value === "string") {
96
+ const f = schema.format ? FORMATS[schema.format] : void 0;
97
+ if (f && !f.test(value))
98
+ err(f.message);
99
+ if (schema.minLength !== void 0 && value.length < schema.minLength)
100
+ err(`must be at least ${schema.minLength} character${schema.minLength === 1 ? "" : "s"} long`);
101
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength)
102
+ err(`must be at most ${schema.maxLength} character${schema.maxLength === 1 ? "" : "s"} long`);
103
+ }
104
+ if (typeof value === "number") {
105
+ if (schema.format === "int32" && (value < -2147483648 || value > 2147483647))
106
+ err("must fit in 32 bits");
107
+ const exMin = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : schema.exclusiveMinimum === true ? schema.minimum : void 0;
108
+ const exMax = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : schema.exclusiveMaximum === true ? schema.maximum : void 0;
109
+ if (exMin !== void 0 && value <= exMin)
110
+ err(`must be more than ${exMin}`);
111
+ else if (schema.minimum !== void 0 && value < schema.minimum)
112
+ err(`must be at least ${schema.minimum}`);
113
+ if (exMax !== void 0 && value >= exMax)
114
+ err(`must be less than ${exMax}`);
115
+ else if (schema.maximum !== void 0 && value > schema.maximum)
116
+ err(`must be at most ${schema.maximum}`);
117
+ }
118
+ if (Array.isArray(value)) {
119
+ if (schema.minItems !== void 0 && value.length < schema.minItems)
120
+ err(`must have at least ${schema.minItems} item${schema.minItems === 1 ? "" : "s"}`);
121
+ if (schema.items)
122
+ value.forEach((v, i) => errors.push(...validate(v, schema.items, `${pointer}/${i}`, direction)));
123
+ }
124
+ if (isObj(value)) {
125
+ const props = schema.properties ?? {};
126
+ const skip = (k) => direction === "request" ? props[k]?.readOnly === true : props[k]?.writeOnly === true;
127
+ for (const k of schema.required ?? [])
128
+ if (value[k] === void 0 && !skip(k))
129
+ err("is required", `${pointer}/${pointerPart(k)}`);
130
+ for (const [k, sub] of Object.entries(props))
131
+ if (value[k] !== void 0)
132
+ errors.push(...validate(value[k], sub, `${pointer}/${pointerPart(k)}`, direction));
133
+ }
134
+ return errors;
135
+ }
136
+ function coerce(text, schema) {
137
+ const t = schema ? types(schema) : [];
138
+ if (t.includes("string") || t.length === 0)
139
+ return text;
140
+ if ((t.includes("integer") || t.includes("number")) && /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(text))
141
+ return Number(text);
142
+ if (t.includes("boolean") && (text === "true" || text === "false"))
143
+ return text === "true";
144
+ if (t.includes("null") && text === "null")
145
+ return null;
146
+ return text;
147
+ }
148
+ var FORMAT_SAMPLES = {
149
+ date: "2024-01-01",
150
+ "date-time": "2024-01-01T00:00:00Z",
151
+ uuid: "00000000-0000-4000-8000-000000000000",
152
+ email: "user@example.com",
153
+ uri: "https://example.com/",
154
+ ipv4: "192.0.2.1",
155
+ byte: "AA=="
156
+ };
157
+ function schemaExample(schema) {
158
+ if (!isSchema(schema))
159
+ return void 0;
160
+ if (schema.example !== void 0)
161
+ return { value: schema.example, source: "schema-example" };
162
+ if (Array.isArray(schema.examples) && schema.examples.length > 0)
163
+ return { value: schema.examples[0], source: "schema-example" };
164
+ if (schema.default !== void 0)
165
+ return { value: schema.default, source: "schema-default" };
166
+ return void 0;
167
+ }
168
+ function generate(schema, depth = 0) {
169
+ if (!isSchema(schema) || depth > 12)
170
+ return null;
171
+ const own = schemaExample(schema);
172
+ if (own)
173
+ return own.value;
174
+ if (schema.const !== void 0)
175
+ return schema.const;
176
+ if (schema.enum && schema.enum.length > 0)
177
+ return schema.enum[0];
178
+ if (schema.allOf && schema.allOf.length > 0) {
179
+ const parts = schema.allOf.map((s) => generate(s, depth + 1));
180
+ const mine = schema.properties ? generate({ ...schema, allOf: void 0 }, depth + 1) : {};
181
+ if (parts.every(isObj) && isObj(mine))
182
+ return Object.assign({}, ...parts, mine);
183
+ return parts[0];
184
+ }
185
+ const alts = schema.oneOf ?? schema.anyOf;
186
+ if (alts && alts.length > 0)
187
+ return generate(alts[0], depth + 1);
188
+ const t = types(schema).find((x) => x !== "null") ?? (schema.properties ? "object" : schema.items ? "array" : void 0);
189
+ switch (t) {
190
+ case "object": {
191
+ const out = {};
192
+ for (const [k, sub] of Object.entries(schema.properties ?? {}))
193
+ if (!sub.writeOnly)
194
+ out[k] = generate(sub, depth + 1);
195
+ return out;
196
+ }
197
+ case "array": {
198
+ const n = Math.max(1, schema.minItems ?? 1);
199
+ return Array.from({ length: n }, () => generate(schema.items, depth + 1));
200
+ }
201
+ case "string": {
202
+ const s = (schema.format && FORMAT_SAMPLES[schema.format]) ?? "string";
203
+ return schema.minLength && s.length < schema.minLength ? s.padEnd(schema.minLength, "x") : s;
204
+ }
205
+ case "integer":
206
+ case "number": {
207
+ let n = schema.minimum ?? (typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : 0);
208
+ if (schema.minimum === void 0 && schema.maximum !== void 0 && schema.maximum < n)
209
+ n = schema.maximum;
210
+ if (schema.exclusiveMinimum === true || typeof schema.exclusiveMinimum === "number")
211
+ n += 1;
212
+ return t === "integer" ? Math.ceil(n) : n;
213
+ }
214
+ case "boolean":
215
+ return true;
216
+ case "null":
217
+ return null;
218
+ default:
219
+ return {};
220
+ }
221
+ }
222
+
223
+ // packages/stubs/dist/spec.js
224
+ var METHODS = ["get", "put", "post", "delete", "patch", "head", "options", "trace"];
225
+ var isObj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
226
+ var isJson = (mediaType) => /(^|\/|\+)json($|;)/i.test(mediaType) || mediaType === "*/*";
227
+ function parseSpec(text) {
228
+ let doc;
229
+ try {
230
+ doc = (0, import_yaml.parse)(text);
231
+ } catch (e) {
232
+ throw new Error(`Can't read the spec: ${e.message.split("\n")[0]}`, { cause: e });
233
+ }
234
+ if (!isObj2(doc))
235
+ throw new Error("This file is not an OpenAPI 3 or Swagger 2.0 spec.");
236
+ return doc;
237
+ }
238
+ function derefAll(doc, warnings) {
239
+ const lookup = (ref) => {
240
+ let cur = doc;
241
+ for (const raw of ref.slice(2).split("/")) {
242
+ const key = decodeURIComponent(raw).replace(/~1/g, "/").replace(/~0/g, "~");
243
+ cur = isObj2(cur) ? cur[key] : void 0;
244
+ }
245
+ return cur;
246
+ };
247
+ const walk = (node, stack) => {
248
+ if (Array.isArray(node))
249
+ return node.map((n) => walk(n, stack));
250
+ if (!isObj2(node))
251
+ return node;
252
+ if (typeof node.$ref === "string") {
253
+ const ref = node.$ref;
254
+ if (!ref.startsWith("#/")) {
255
+ warnings.add(`Can't follow ${ref}: only refs inside the spec are read.`);
256
+ return {};
257
+ }
258
+ if (stack.includes(ref))
259
+ return {};
260
+ const target = lookup(ref);
261
+ if (target === void 0) {
262
+ warnings.add(`${ref} points at nothing.`);
263
+ return {};
264
+ }
265
+ return walk(target, [...stack, ref]);
266
+ }
267
+ const out = {};
268
+ for (const [k, v] of Object.entries(node))
269
+ out[k] = walk(v, stack);
270
+ return out;
271
+ };
272
+ return walk(doc, []);
273
+ }
274
+ function statusOrder(s) {
275
+ if (/^\d{3}$/.test(s))
276
+ return Number(s);
277
+ if (/^[1-5]XX$/i.test(s))
278
+ return Number(s[0]) * 100 + 99.5;
279
+ return 1e3;
280
+ }
281
+ function pickMedia(content) {
282
+ if (!isObj2(content))
283
+ return void 0;
284
+ const entries = Object.entries(content).filter((e) => isObj2(e[1]));
285
+ return entries.find(([m]) => m.toLowerCase() === "application/json") ?? entries.find(([m]) => isJson(m)) ?? entries[0];
286
+ }
287
+ function responseBody(example, examples, schema) {
288
+ const named = {};
289
+ if (isObj2(examples))
290
+ for (const [k, v] of Object.entries(examples))
291
+ named[k] = isObj2(v) && "value" in v ? v.value : v;
292
+ if (example !== void 0)
293
+ return { body: example, example: "example", named };
294
+ const first = Object.values(named)[0];
295
+ if (first !== void 0)
296
+ return { body: first, example: "examples", named };
297
+ const own = schemaExample(schema);
298
+ if (own)
299
+ return { body: own.value, example: own.source, named };
300
+ if (schema)
301
+ return { body: generate(schema), example: "generated", named };
302
+ return { example: "none", named };
303
+ }
304
+ var SCHEMA_KEYS = [
305
+ "type",
306
+ "format",
307
+ "enum",
308
+ "items",
309
+ "minimum",
310
+ "maximum",
311
+ "exclusiveMinimum",
312
+ "exclusiveMaximum",
313
+ "minLength",
314
+ "maxLength",
315
+ "default"
316
+ ];
317
+ var inlineSchema = (p) => Object.fromEntries(SCHEMA_KEYS.filter((k) => p[k] !== void 0).map((k) => [k, p[k]]));
318
+ function basePathsOf(doc, swagger) {
319
+ const raw = [];
320
+ if (swagger) {
321
+ if (typeof doc.basePath === "string")
322
+ raw.push(doc.basePath);
323
+ } else if (Array.isArray(doc.servers)) {
324
+ for (const s of doc.servers) {
325
+ if (!isObj2(s) || typeof s.url !== "string")
326
+ continue;
327
+ const vars = isObj2(s.variables) ? s.variables : {};
328
+ const url = s.url.replace(/\{([^}]+)\}/g, (m, v) => {
329
+ const d = isObj2(vars[v]) ? vars[v].default : void 0;
330
+ return typeof d === "string" ? d : m;
331
+ });
332
+ if (/\{/.test(url))
333
+ continue;
334
+ try {
335
+ raw.push(new URL(url, "http://stub.invalid").pathname);
336
+ } catch {
337
+ }
338
+ }
339
+ }
340
+ return [...new Set(raw.map((p) => p.replace(/\/+$/, "")).filter((p) => p && p !== "/"))].sort();
341
+ }
342
+ function buildStub(spec) {
343
+ const input = typeof spec === "string" ? parseSpec(spec) : spec;
344
+ if (!isObj2(input))
345
+ throw new Error("This file is not an OpenAPI 3 or Swagger 2.0 spec.");
346
+ const swagger = String(input.swagger ?? "") === "2.0";
347
+ if (!swagger && !/^3\./.test(String(input.openapi ?? "")))
348
+ throw new Error("This file is not an OpenAPI 3 or Swagger 2.0 spec.");
349
+ const warnings = /* @__PURE__ */ new Set();
350
+ const doc = derefAll(input, warnings);
351
+ const info = isObj2(doc.info) ? doc.info : {};
352
+ const routes = [];
353
+ const paths = isObj2(doc.paths) ? doc.paths : {};
354
+ const produces = Array.isArray(doc.produces) ? doc.produces.map(String) : [];
355
+ for (const [path, item] of Object.entries(paths)) {
356
+ if (!isObj2(item))
357
+ continue;
358
+ const shared = Array.isArray(item.parameters) ? item.parameters.filter(isObj2) : [];
359
+ for (const m of METHODS) {
360
+ const op = item[m];
361
+ if (!isObj2(op))
362
+ continue;
363
+ const own = Array.isArray(op.parameters) ? op.parameters.filter(isObj2) : [];
364
+ const merged = [
365
+ ...shared.filter((s) => !own.some((o) => o.name === s.name && o.in === s.in)),
366
+ ...own
367
+ ];
368
+ const params = [];
369
+ let body;
370
+ for (const p of merged) {
371
+ const where = String(p.in ?? "");
372
+ if (where === "path" || where === "query" || where === "header") {
373
+ const schema = swagger ? inlineSchema(p) : isObj2(p.schema) ? p.schema : void 0;
374
+ params.push({
375
+ name: String(p.name ?? ""),
376
+ in: where,
377
+ required: where === "path" || p.required === true,
378
+ ...schema ? { schema } : {}
379
+ });
380
+ } else if (where === "body")
381
+ body = {
382
+ required: p.required === true,
383
+ json: true,
384
+ ...isObj2(p.schema) ? { schema: p.schema } : {}
385
+ };
386
+ else if (where === "formData")
387
+ body = { required: p.required === true, json: false };
388
+ }
389
+ if (!swagger && isObj2(op.requestBody)) {
390
+ const media = pickMedia(op.requestBody.content);
391
+ const json = media ? isJson(media[0]) : false;
392
+ body = {
393
+ required: op.requestBody.required === true,
394
+ json,
395
+ ...json && media && isObj2(media[1].schema) ? { schema: media[1].schema } : {}
396
+ };
397
+ }
398
+ const responses = [];
399
+ for (const [status, r] of Object.entries(isObj2(op.responses) ? op.responses : {})) {
400
+ if (!isObj2(r))
401
+ continue;
402
+ const description = typeof r.description === "string" ? r.description : void 0;
403
+ let mediaType;
404
+ let picked;
405
+ if (swagger) {
406
+ const ex = isObj2(r.examples) ? r.examples : {};
407
+ const exType = Object.keys(ex).find((k) => k.toLowerCase() === "application/json") ?? Object.keys(ex).find(isJson);
408
+ const schema = isObj2(r.schema) ? r.schema : void 0;
409
+ mediaType = exType ?? produces.find(isJson) ?? (schema ? "application/json" : void 0);
410
+ picked = exType ? { body: ex[exType], example: "examples", named: {} } : responseBody(void 0, void 0, schema);
411
+ } else {
412
+ const media = pickMedia(r.content);
413
+ mediaType = media?.[0];
414
+ picked = media ? responseBody(media[1].example, media[1].examples, isObj2(media[1].schema) ? media[1].schema : void 0) : responseBody(void 0, void 0, void 0);
415
+ }
416
+ responses.push({
417
+ status: status.toUpperCase() === "DEFAULT" ? "default" : status.toUpperCase(),
418
+ ...description !== void 0 ? { description } : {},
419
+ ...mediaType ? { mediaType } : {},
420
+ ...picked
421
+ });
422
+ }
423
+ responses.sort((a, b) => statusOrder(a.status) - statusOrder(b.status));
424
+ const ok = responses.find((r) => /^2\d\d$/.test(r.status)) ?? responses.find((r) => r.status === "2XX") ?? responses.find((r) => r.status === "default");
425
+ routes.push({
426
+ method: m.toUpperCase(),
427
+ path,
428
+ ...typeof op.operationId === "string" ? { operationId: op.operationId } : {},
429
+ params,
430
+ ...body ? { body } : {},
431
+ responses,
432
+ status: ok && /^\d{3}$/.test(ok.status) ? Number(ok.status) : 200,
433
+ example: ok?.example ?? "none"
434
+ });
435
+ }
436
+ }
437
+ return {
438
+ title: typeof info.title === "string" ? info.title : "Stub",
439
+ ...info.version !== void 0 ? { version: String(info.version) } : {},
440
+ basePaths: basePathsOf(doc, swagger),
441
+ routes: sortRoutes(routes),
442
+ warnings: [...warnings].sort()
443
+ };
444
+ }
445
+ function sortRoutes(routes) {
446
+ return routes.sort((a, b) => a.path === b.path ? a.method < b.method ? -1 : 1 : a.path < b.path ? -1 : 1);
447
+ }
448
+
449
+ // packages/stubs/dist/stub.js
450
+ import { createServer } from "node:http";
451
+ var NO_BODY = /* @__PURE__ */ new Set([204, 205, 304]);
452
+ var IGNORED_HEADERS = /* @__PURE__ */ new Set(["accept", "content-type", "authorization"]);
453
+ var either = (items) => items.length <= 1 ? items[0] ?? "" : `${items.slice(0, -1).join(", ")} or ${items[items.length - 1]}`;
454
+ function compile(route) {
455
+ const parts = route.path.split("/").filter(Boolean);
456
+ let literalSegments = 0;
457
+ let literalChars = 0;
458
+ const segments = parts.map((seg) => {
459
+ const names = [];
460
+ const src = seg.split(/(\{[^}]+\})/).map((piece) => {
461
+ const m = /^\{([^}]+)\}$/.exec(piece);
462
+ if (m) {
463
+ names.push(m[1]);
464
+ return "([^/]+)";
465
+ }
466
+ literalChars += piece.length;
467
+ return piece.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
468
+ }).join("");
469
+ if (names.length === 0)
470
+ literalSegments++;
471
+ return { re: new RegExp(`^${src}$`), names };
472
+ });
473
+ return { route, segments, literalSegments, literalChars };
474
+ }
475
+ function matchPath(c, parts) {
476
+ if (parts.length !== c.segments.length)
477
+ return void 0;
478
+ const params = {};
479
+ for (let i = 0; i < parts.length; i++) {
480
+ const m = c.segments[i].re.exec(parts[i]);
481
+ if (!m)
482
+ return void 0;
483
+ c.segments[i].names.forEach((n, j) => params[n] = m[j + 1]);
484
+ }
485
+ return params;
486
+ }
487
+ function splitPath(pathname) {
488
+ return pathname.split("/").filter(Boolean).map((p) => {
489
+ try {
490
+ return decodeURIComponent(p);
491
+ } catch {
492
+ return p;
493
+ }
494
+ });
495
+ }
496
+ async function readBody(req) {
497
+ if (typeof req[Symbol.asyncIterator] !== "function")
498
+ return "";
499
+ const chunks = [];
500
+ for await (const c of req)
501
+ chunks.push(typeof c === "string" ? Buffer.from(c) : c);
502
+ return Buffer.concat(chunks).toString("utf8");
503
+ }
504
+ var header = (req, name) => {
505
+ const want = name.toLowerCase();
506
+ for (const [k, v] of Object.entries(req.headers))
507
+ if (k.toLowerCase() === want && v !== void 0)
508
+ return Array.isArray(v) ? v.join(", ") : v;
509
+ return void 0;
510
+ };
511
+ function preferences(req) {
512
+ const out = {};
513
+ for (const part of (header(req, "prefer") ?? "").split(/[,;]/)) {
514
+ const eq = part.indexOf("=");
515
+ if (eq > 0)
516
+ out[part.slice(0, eq).trim().toLowerCase()] = part.slice(eq + 1).trim().replace(/^"|"$/g, "");
517
+ }
518
+ return out;
519
+ }
520
+ function send(res, status, body, headers) {
521
+ if (NO_BODY.has(status) || body === void 0) {
522
+ res.writeHead(status, headers);
523
+ res.end();
524
+ return;
525
+ }
526
+ const text = JSON.stringify(body);
527
+ res.writeHead(status, {
528
+ ...headers,
529
+ "content-length": String(Buffer.byteLength(text))
530
+ });
531
+ res.end(text);
532
+ }
533
+ function problem(res, status, body, headers = {}) {
534
+ send(res, status, { type: body.type, title: body.title, status, ...body }, {
535
+ "content-type": "application/problem+json",
536
+ ...headers
537
+ });
538
+ }
539
+ function check(route, pathParams, query, req, text) {
540
+ const errors = [];
541
+ for (const p of route.params) {
542
+ let value;
543
+ if (p.in === "path") {
544
+ const raw = pathParams[p.name];
545
+ if (raw === void 0)
546
+ continue;
547
+ value = coerce(raw, p.schema);
548
+ } else if (p.in === "query") {
549
+ const all = query.getAll(p.name);
550
+ if (all.length === 0) {
551
+ if (p.required)
552
+ errors.push({ in: "query", name: p.name, message: "is required" });
553
+ continue;
554
+ }
555
+ const t = p.schema?.type;
556
+ value = t === "array" || Array.isArray(t) && t.includes("array") ? all.flatMap((v) => v.split(",")).map((v) => coerce(v, p.schema?.items)) : coerce(all[0], p.schema);
557
+ } else {
558
+ if (IGNORED_HEADERS.has(p.name.toLowerCase()))
559
+ continue;
560
+ const raw = header(req, p.name);
561
+ if (raw === void 0) {
562
+ if (p.required)
563
+ errors.push({ in: "header", name: p.name, message: "is required" });
564
+ continue;
565
+ }
566
+ value = coerce(raw, p.schema);
567
+ }
568
+ for (const e of validate(value, p.schema))
569
+ errors.push({ in: p.in, name: p.name, message: e.message });
570
+ }
571
+ const b = route.body;
572
+ if (b) {
573
+ if (text.trim() === "") {
574
+ if (b.required)
575
+ errors.push({ in: "body", pointer: "", message: "is required" });
576
+ } else if (b.json) {
577
+ const type = header(req, "content-type");
578
+ if (type && !/json/i.test(type))
579
+ errors.push({ in: "body", pointer: "", message: "must be sent as application/json" });
580
+ else {
581
+ let value;
582
+ try {
583
+ value = JSON.parse(text);
584
+ } catch {
585
+ errors.push({ in: "body", pointer: "", message: "isn't valid JSON" });
586
+ return errors;
587
+ }
588
+ for (const e of validate(value, b.schema, "", "request"))
589
+ errors.push({ in: "body", pointer: e.pointer, message: e.message });
590
+ }
591
+ }
592
+ }
593
+ return errors;
594
+ }
595
+ function documented(route, code) {
596
+ return route.responses.find((r) => r.status === code) ?? route.responses.find((r) => r.status === `${code[0]}XX`) ?? route.responses.find((r) => r.status === "default");
597
+ }
598
+ function stubHandler(stub) {
599
+ const compiled = stub.routes.map(compile);
600
+ const operations = stub.routes.map((r) => `${r.method} ${r.path}`);
601
+ return async (req, res) => {
602
+ const method = (req.method ?? "GET").toUpperCase();
603
+ const url = new URL(req.url ?? "/", "http://stub.invalid");
604
+ const pathname = url.pathname.replace(/(.)\/+$/, "$1");
605
+ const text = await readBody(req);
606
+ const candidates = [
607
+ pathname,
608
+ ...stub.basePaths.filter((b) => pathname === b || pathname.startsWith(`${b}/`)).map((b) => pathname.slice(b.length) || "/")
609
+ ];
610
+ let hits = [];
611
+ for (const p of candidates) {
612
+ const parts = splitPath(p);
613
+ hits = compiled.flatMap((c) => {
614
+ const params = matchPath(c, parts);
615
+ return params ? [{ c, params }] : [];
616
+ });
617
+ if (hits.length > 0)
618
+ break;
619
+ }
620
+ const specific = (a, b) => b.literalSegments - a.literalSegments || b.literalChars - a.literalChars;
621
+ hits.sort((a, b) => specific(a.c, b.c));
622
+ if (hits.length === 0)
623
+ return problem(res, 404, {
624
+ type: "urn:atticus:stub:no-route",
625
+ title: "No such operation",
626
+ detail: `The spec has no operation for ${method} ${url.pathname}.`,
627
+ instance: url.pathname,
628
+ operations
629
+ });
630
+ const hit = hits.find((h) => h.c.route.method === method);
631
+ if (!hit) {
632
+ const allow = [...new Set(hits.map((h) => h.c.route.method))].sort();
633
+ return problem(res, 405, {
634
+ type: "urn:atticus:stub:method-not-allowed",
635
+ title: "Method not allowed",
636
+ detail: `${hits[0].c.route.path} takes ${either(allow)}, not ${method}.`,
637
+ instance: url.pathname,
638
+ allow
639
+ }, { allow: allow.join(", ") });
640
+ }
641
+ const route = hit.c.route;
642
+ const name = `${route.method} ${route.path}`;
643
+ const errors = check(route, hit.params, url.searchParams, req, text);
644
+ if (errors.length > 0)
645
+ return problem(res, 400, {
646
+ type: "urn:atticus:stub:invalid-request",
647
+ title: "The request doesn't match the spec",
648
+ detail: `${errors.length} problem${errors.length === 1 ? "" : "s"} with ${name}.`,
649
+ instance: url.pathname,
650
+ errors
651
+ });
652
+ const prefs = preferences(req);
653
+ const asked = header(req, "x-stub-status")?.trim() ?? prefs.code;
654
+ let status = route.status;
655
+ let response = documented(route, String(route.status));
656
+ if (asked !== void 0) {
657
+ response = /^[1-5]\d\d$/.test(asked) ? documented(route, asked) : void 0;
658
+ if (!response)
659
+ return problem(res, 400, {
660
+ type: "urn:atticus:stub:unknown-scenario",
661
+ title: "No such response in the spec",
662
+ detail: `${name} documents ${route.responses.map((r) => r.status).join(", ")}, not ${asked}.`,
663
+ instance: url.pathname,
664
+ documented: route.responses.map((r) => r.status)
665
+ });
666
+ status = Number(asked);
667
+ }
668
+ const named = prefs.example !== void 0 ? response?.named[prefs.example] : void 0;
669
+ const body = named ?? response?.body ?? {};
670
+ const mediaType = response?.mediaType && /json/i.test(response.mediaType) ? response.mediaType : "application/json";
671
+ send(res, status, NO_BODY.has(status) ? void 0 : body, {
672
+ ...NO_BODY.has(status) ? {} : { "content-type": mediaType },
673
+ "x-stub-route": name
674
+ });
675
+ };
676
+ }
677
+ function checkStub(stub) {
678
+ return stub.routes.map((r) => ({
679
+ method: r.method,
680
+ path: r.path,
681
+ ...r.operationId ? { operationId: r.operationId } : {},
682
+ status: r.status,
683
+ example: r.example
684
+ }));
685
+ }
686
+ function stubFromCatalog(records, componentOrSystem) {
687
+ const id = componentOrSystem;
688
+ const components = records.filter((r) => r.kind === "Component");
689
+ const isComponent = components.some((c) => c.id === id);
690
+ const isSystem = records.some((r) => r.kind === "System" && r.id === id);
691
+ const endpoints = records.filter((r) => r.kind === "Endpoint");
692
+ const owners = /* @__PURE__ */ new Set([
693
+ id,
694
+ ...isComponent ? [] : components.filter((c) => c.system === id).map((c) => c.id)
695
+ ]);
696
+ if (!isComponent && !isSystem && !endpoints.some((e) => e.component === id))
697
+ throw new Error(`No component or system "${id}" in the catalog.`);
698
+ const mine = endpoints.filter((e) => owners.has(e.component) && e.endpointType === "rest" && e.status !== "retired").sort((a, b) => a.id < b.id ? -1 : 1);
699
+ const seen = /* @__PURE__ */ new Set();
700
+ const routes = [];
701
+ for (const e of mine) {
702
+ const method = (e.method ?? "GET").toUpperCase();
703
+ const key = `${method} ${e.pathOrTopic}`;
704
+ if (seen.has(key))
705
+ continue;
706
+ seen.add(key);
707
+ routes.push({
708
+ method,
709
+ path: e.pathOrTopic,
710
+ operationId: e.id,
711
+ params: [...e.pathOrTopic.matchAll(/\{([^}]+)\}/g)].map((m) => ({
712
+ name: m[1],
713
+ in: "path",
714
+ required: true
715
+ })),
716
+ responses: [{ status: "200", body: {}, example: "catalog", named: {} }],
717
+ status: 200,
718
+ example: "catalog"
719
+ });
720
+ }
721
+ const ids = new Set(mine.map((e) => e.id));
722
+ const basepaths = new Map(records.filter((r) => r.kind === "GatewayRoute").map((r) => [r.id, r.basepath]));
723
+ const basePaths = /* @__PURE__ */ new Set();
724
+ for (const r of records)
725
+ if (r.kind === "Interface" && r.endpoint && ids.has(r.endpoint) && r.route) {
726
+ const b = basepaths.get(r.route)?.replace(/\/+$/, "");
727
+ if (b)
728
+ basePaths.add(b);
729
+ }
730
+ return {
731
+ title: `Catalog stub for ${id}`,
732
+ basePaths: [...basePaths].sort(),
733
+ routes: sortRoutes(routes),
734
+ warnings: []
735
+ };
736
+ }
737
+ async function startStub(handler, o) {
738
+ const host = o.host ?? "127.0.0.1";
739
+ const server = createServer((req, res) => {
740
+ handler(req, res).catch(() => {
741
+ if (!res.headersSent)
742
+ res.writeHead(500, { "content-type": "application/problem+json" });
743
+ res.end(JSON.stringify({ title: "The stub failed", status: 500 }));
744
+ });
745
+ });
746
+ await new Promise((resolve, reject) => {
747
+ server.once("error", reject);
748
+ server.listen(o.port, host, () => resolve());
749
+ });
750
+ const port = server.address().port;
751
+ return {
752
+ url: `http://${host}:${port}`,
753
+ port,
754
+ close: () => new Promise((resolve) => server.close(() => resolve()))
755
+ };
756
+ }
757
+
758
+ export {
759
+ generate,
760
+ parseSpec,
761
+ buildStub,
762
+ stubHandler,
763
+ checkStub,
764
+ stubFromCatalog,
765
+ startStub
766
+ };