@vertesia/common 1.6.0-dev.20260923.085325Z → 1.6.0-dev.20261004.085740Z

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 (405) hide show
  1. package/lib/access-control-values.d.ts +2 -2
  2. package/lib/access-control-values.d.ts.map +1 -1
  3. package/lib/access-control-values.js +2 -2
  4. package/lib/access-control-values.js.map +1 -1
  5. package/lib/access-control.d.ts +7 -8
  6. package/lib/access-control.d.ts.map +1 -1
  7. package/lib/access-control.js +5 -0
  8. package/lib/access-control.js.map +1 -1
  9. package/lib/analytics.d.ts +6 -7
  10. package/lib/analytics.d.ts.map +1 -1
  11. package/lib/api-contract/components.generated.json +1389 -45
  12. package/lib/api-schemas/access-control.d.ts +33 -10
  13. package/lib/api-schemas/access-control.d.ts.map +1 -1
  14. package/lib/api-schemas/access-control.js +7 -6
  15. package/lib/api-schemas/access-control.js.map +1 -1
  16. package/lib/api-schemas/account.d.ts +5 -4
  17. package/lib/api-schemas/account.d.ts.map +1 -1
  18. package/lib/api-schemas/account.js.map +1 -1
  19. package/lib/api-schemas/agent-budget.d.ts +15 -0
  20. package/lib/api-schemas/agent-budget.d.ts.map +1 -0
  21. package/lib/api-schemas/agent-budget.js +55 -0
  22. package/lib/api-schemas/agent-budget.js.map +1 -0
  23. package/lib/api-schemas/agent-runs.d.ts +1525 -100
  24. package/lib/api-schemas/agent-runs.d.ts.map +1 -1
  25. package/lib/api-schemas/agent-runs.js +60 -28
  26. package/lib/api-schemas/agent-runs.js.map +1 -1
  27. package/lib/api-schemas/apikey.d.ts +11 -10
  28. package/lib/api-schemas/apikey.d.ts.map +1 -1
  29. package/lib/api-schemas/apikey.js.map +1 -1
  30. package/lib/api-schemas/app-lifecycle.d.ts +13 -0
  31. package/lib/api-schemas/app-lifecycle.d.ts.map +1 -1
  32. package/lib/api-schemas/app-lifecycle.js +4 -0
  33. package/lib/api-schemas/app-lifecycle.js.map +1 -1
  34. package/lib/api-schemas/app-runtime.d.ts +1821 -108
  35. package/lib/api-schemas/app-runtime.d.ts.map +1 -1
  36. package/lib/api-schemas/audit-trail.d.ts +20 -0
  37. package/lib/api-schemas/audit-trail.d.ts.map +1 -1
  38. package/lib/api-schemas/audit-trail.js +7 -1
  39. package/lib/api-schemas/audit-trail.js.map +1 -1
  40. package/lib/api-schemas/content.d.ts +665 -30
  41. package/lib/api-schemas/content.d.ts.map +1 -1
  42. package/lib/api-schemas/content.js +47 -0
  43. package/lib/api-schemas/content.js.map +1 -1
  44. package/lib/api-schemas/cost-analytics.d.ts +18 -0
  45. package/lib/api-schemas/cost-analytics.d.ts.map +1 -1
  46. package/lib/api-schemas/cost-analytics.js +31 -2
  47. package/lib/api-schemas/cost-analytics.js.map +1 -1
  48. package/lib/api-schemas/document-processing.d.ts +381 -18
  49. package/lib/api-schemas/document-processing.d.ts.map +1 -1
  50. package/lib/api-schemas/environment.d.ts +0 -5
  51. package/lib/api-schemas/environment.d.ts.map +1 -1
  52. package/lib/api-schemas/environment.js +0 -1
  53. package/lib/api-schemas/environment.js.map +1 -1
  54. package/lib/api-schemas/events.d.ts +1143 -54
  55. package/lib/api-schemas/events.d.ts.map +1 -1
  56. package/lib/api-schemas/group.d.ts +2 -1
  57. package/lib/api-schemas/group.d.ts.map +1 -1
  58. package/lib/api-schemas/group.js.map +1 -1
  59. package/lib/api-schemas/index.d.ts +1 -0
  60. package/lib/api-schemas/index.d.ts.map +1 -1
  61. package/lib/api-schemas/index.js +1 -0
  62. package/lib/api-schemas/index.js.map +1 -1
  63. package/lib/api-schemas/inference-profile.d.ts +5017 -0
  64. package/lib/api-schemas/inference-profile.d.ts.map +1 -0
  65. package/lib/api-schemas/inference-profile.js +135 -0
  66. package/lib/api-schemas/inference-profile.js.map +1 -0
  67. package/lib/api-schemas/integrations.d.ts +6 -6
  68. package/lib/api-schemas/interaction.d.ts +34391 -703
  69. package/lib/api-schemas/interaction.d.ts.map +1 -1
  70. package/lib/api-schemas/interaction.js +34 -1
  71. package/lib/api-schemas/interaction.js.map +1 -1
  72. package/lib/api-schemas/invites.d.ts +10 -9
  73. package/lib/api-schemas/invites.d.ts.map +1 -1
  74. package/lib/api-schemas/invites.js.map +1 -1
  75. package/lib/api-schemas/process.d.ts +653 -34
  76. package/lib/api-schemas/process.d.ts.map +1 -1
  77. package/lib/api-schemas/process.js +66 -0
  78. package/lib/api-schemas/process.js.map +1 -1
  79. package/lib/api-schemas/project-configuration.d.ts +1323 -62
  80. package/lib/api-schemas/project-configuration.d.ts.map +1 -1
  81. package/lib/api-schemas/project-configuration.js +15 -1
  82. package/lib/api-schemas/project-configuration.js.map +1 -1
  83. package/lib/api-schemas/project.d.ts +2031 -116
  84. package/lib/api-schemas/project.d.ts.map +1 -1
  85. package/lib/api-schemas/project.js +9 -1
  86. package/lib/api-schemas/project.js.map +1 -1
  87. package/lib/api-schemas/quota.d.ts +7 -6
  88. package/lib/api-schemas/quota.d.ts.map +1 -1
  89. package/lib/api-schemas/quota.js.map +1 -1
  90. package/lib/api-schemas/registry.d.ts +27820 -35892
  91. package/lib/api-schemas/registry.d.ts.map +1 -1
  92. package/lib/api-schemas/registry.js +55 -5
  93. package/lib/api-schemas/registry.js.map +1 -1
  94. package/lib/api-schemas/run-budget.d.ts +52 -0
  95. package/lib/api-schemas/run-budget.d.ts.map +1 -0
  96. package/lib/api-schemas/run-budget.js +55 -0
  97. package/lib/api-schemas/run-budget.js.map +1 -0
  98. package/lib/api-schemas/store.d.ts +6388 -338
  99. package/lib/api-schemas/store.d.ts.map +1 -1
  100. package/lib/api-schemas/store.js +11 -0
  101. package/lib/api-schemas/store.js.map +1 -1
  102. package/lib/api-schemas/user.d.ts +9 -8
  103. package/lib/api-schemas/user.d.ts.map +1 -1
  104. package/lib/api-schemas/user.js.map +1 -1
  105. package/lib/api-schemas/view-execution.d.ts +8 -0
  106. package/lib/api-schemas/view-execution.d.ts.map +1 -1
  107. package/lib/api-schemas/views.d.ts +14 -0
  108. package/lib/api-schemas/views.d.ts.map +1 -1
  109. package/lib/api-schemas/workflow-runs.d.ts +335 -12
  110. package/lib/api-schemas/workflow-runs.d.ts.map +1 -1
  111. package/lib/api-schemas/workflow-runs.js +2 -0
  112. package/lib/api-schemas/workflow-runs.js.map +1 -1
  113. package/lib/apikey.d.ts +30 -25
  114. package/lib/apikey.d.ts.map +1 -1
  115. package/lib/apikey.js.map +1 -1
  116. package/lib/apps.d.ts +116 -121
  117. package/lib/apps.d.ts.map +1 -1
  118. package/lib/apps.js.map +1 -1
  119. package/lib/audit-trail.d.ts +17 -18
  120. package/lib/audit-trail.d.ts.map +1 -1
  121. package/lib/audit-trail.js +2 -0
  122. package/lib/audit-trail.js.map +1 -1
  123. package/lib/browser-credentials.d.ts +11 -12
  124. package/lib/browser-credentials.d.ts.map +1 -1
  125. package/lib/common.d.ts +17 -24
  126. package/lib/common.d.ts.map +1 -1
  127. package/lib/content-query.d.ts +3 -4
  128. package/lib/content-query.d.ts.map +1 -1
  129. package/lib/cost-analytics.d.ts +13 -21
  130. package/lib/cost-analytics.d.ts.map +1 -1
  131. package/lib/cost-analytics.js +0 -7
  132. package/lib/cost-analytics.js.map +1 -1
  133. package/lib/data-platform.d.ts +79 -88
  134. package/lib/data-platform.d.ts.map +1 -1
  135. package/lib/data-platform.js.map +1 -1
  136. package/lib/delegation.d.ts +4 -5
  137. package/lib/delegation.d.ts.map +1 -1
  138. package/lib/email.d.ts +15 -17
  139. package/lib/email.d.ts.map +1 -1
  140. package/lib/email.js.map +1 -1
  141. package/lib/embeddings.d.ts +25 -26
  142. package/lib/embeddings.d.ts.map +1 -1
  143. package/lib/environment.d.ts +16 -17
  144. package/lib/environment.d.ts.map +1 -1
  145. package/lib/environment.js.map +1 -1
  146. package/lib/facets.d.ts +3 -4
  147. package/lib/facets.d.ts.map +1 -1
  148. package/lib/group.d.ts +6 -7
  149. package/lib/group.d.ts.map +1 -1
  150. package/lib/group.js.map +1 -1
  151. package/lib/index.d.ts +3 -1
  152. package/lib/index.d.ts.map +1 -1
  153. package/lib/index.js.map +1 -1
  154. package/lib/inference-profile.d.ts +17 -0
  155. package/lib/inference-profile.d.ts.map +1 -0
  156. package/lib/inference-profile.js +2 -0
  157. package/lib/inference-profile.js.map +1 -0
  158. package/lib/integrations.d.ts +19 -20
  159. package/lib/integrations.d.ts.map +1 -1
  160. package/lib/integrations.js.map +1 -1
  161. package/lib/interaction.d.ts +68 -73
  162. package/lib/interaction.d.ts.map +1 -1
  163. package/lib/interaction.js.map +1 -1
  164. package/lib/meters.d.ts +4 -5
  165. package/lib/meters.d.ts.map +1 -1
  166. package/lib/oauth-server.d.ts +40 -41
  167. package/lib/oauth-server.d.ts.map +1 -1
  168. package/lib/oauth.d.ts +9 -10
  169. package/lib/oauth.d.ts.map +1 -1
  170. package/lib/payload.d.ts +11 -14
  171. package/lib/payload.d.ts.map +1 -1
  172. package/lib/pending-asks.d.ts +8 -13
  173. package/lib/pending-asks.d.ts.map +1 -1
  174. package/lib/pending-asks.js +0 -4
  175. package/lib/pending-asks.js.map +1 -1
  176. package/lib/platform-event.d.ts +48 -51
  177. package/lib/platform-event.d.ts.map +1 -1
  178. package/lib/platform-event.js.map +1 -1
  179. package/lib/principal-context.d.ts +3 -3
  180. package/lib/principal-context.d.ts.map +1 -1
  181. package/lib/project.d.ts +42 -43
  182. package/lib/project.d.ts.map +1 -1
  183. package/lib/project.js.map +1 -1
  184. package/lib/prompt.d.ts +14 -16
  185. package/lib/prompt.d.ts.map +1 -1
  186. package/lib/prompt.js.map +1 -1
  187. package/lib/query.d.ts +10 -13
  188. package/lib/query.d.ts.map +1 -1
  189. package/lib/rate-limiter.d.ts +7 -11
  190. package/lib/rate-limiter.d.ts.map +1 -1
  191. package/lib/refs.d.ts +2 -3
  192. package/lib/refs.d.ts.map +1 -1
  193. package/lib/refs.js.map +1 -1
  194. package/lib/roles/types.d.ts +5 -6
  195. package/lib/roles/types.d.ts.map +1 -1
  196. package/lib/roles/types.js.map +1 -1
  197. package/lib/run-budget.d.ts +8 -0
  198. package/lib/run-budget.d.ts.map +1 -0
  199. package/lib/run-budget.js +2 -0
  200. package/lib/run-budget.js.map +1 -0
  201. package/lib/runs.d.ts +9 -10
  202. package/lib/runs.d.ts.map +1 -1
  203. package/lib/secrets.d.ts +20 -21
  204. package/lib/secrets.d.ts.map +1 -1
  205. package/lib/store/agent-approval.d.ts +4 -5
  206. package/lib/store/agent-approval.d.ts.map +1 -1
  207. package/lib/store/agent-approval.js.map +1 -1
  208. package/lib/store/agent-run.d.ts +50 -52
  209. package/lib/store/agent-run.d.ts.map +1 -1
  210. package/lib/store/agent-run.js.map +1 -1
  211. package/lib/store/collections.d.ts +11 -12
  212. package/lib/store/collections.d.ts.map +1 -1
  213. package/lib/store/collections.js.map +1 -1
  214. package/lib/store/conversation-state.d.ts +14 -8
  215. package/lib/store/conversation-state.d.ts.map +1 -1
  216. package/lib/store/doc-analyzer.d.ts +7 -8
  217. package/lib/store/doc-analyzer.d.ts.map +1 -1
  218. package/lib/store/dsl-workflow.d.ts +10 -12
  219. package/lib/store/dsl-workflow.d.ts.map +1 -1
  220. package/lib/store/dsl-workflow.js.map +1 -1
  221. package/lib/store/duration.d.ts +12 -0
  222. package/lib/store/duration.d.ts.map +1 -0
  223. package/lib/store/duration.js +2 -0
  224. package/lib/store/duration.js.map +1 -0
  225. package/lib/store/grounded-extraction.d.ts +6 -7
  226. package/lib/store/grounded-extraction.d.ts.map +1 -1
  227. package/lib/store/intake-policy-schema.generated.d.ts.map +1 -1
  228. package/lib/store/intake-policy-schema.generated.js +143 -2
  229. package/lib/store/intake-policy-schema.generated.js.map +1 -1
  230. package/lib/store/process.d.ts +70 -69
  231. package/lib/store/process.d.ts.map +1 -1
  232. package/lib/store/process.js.map +1 -1
  233. package/lib/store/rendering.d.ts +6 -12
  234. package/lib/store/rendering.d.ts.map +1 -1
  235. package/lib/store/rendering.js +0 -5
  236. package/lib/store/rendering.js.map +1 -1
  237. package/lib/store/signals.d.ts +43 -0
  238. package/lib/store/signals.d.ts.map +1 -1
  239. package/lib/store/signals.js +6 -1
  240. package/lib/store/signals.js.map +1 -1
  241. package/lib/store/store.d.ts +92 -91
  242. package/lib/store/store.d.ts.map +1 -1
  243. package/lib/store/store.js.map +1 -1
  244. package/lib/store/task.d.ts +10 -14
  245. package/lib/store/task.d.ts.map +1 -1
  246. package/lib/store/workflow.d.ts +35 -41
  247. package/lib/store/workflow.d.ts.map +1 -1
  248. package/lib/store/workflow.js.map +1 -1
  249. package/lib/sts-token-types.d.ts +14 -19
  250. package/lib/sts-token-types.d.ts.map +1 -1
  251. package/lib/tools.d.ts +12 -13
  252. package/lib/tools.d.ts.map +1 -1
  253. package/lib/transient-tokens.d.ts +3 -3
  254. package/lib/transient-tokens.d.ts.map +1 -1
  255. package/lib/user.d.ts +17 -20
  256. package/lib/user.d.ts.map +1 -1
  257. package/lib/user.js.map +1 -1
  258. package/lib/vertesia-common.js +2 -2
  259. package/lib/vertesia-common.js.map +1 -1
  260. package/lib/views.d.ts +61 -64
  261. package/lib/views.d.ts.map +1 -1
  262. package/lib/views.js.map +1 -1
  263. package/lib/wire-types.generated.d.ts +11231 -0
  264. package/lib/wire-types.generated.d.ts.map +1 -0
  265. package/lib/wire-types.generated.js +4 -0
  266. package/lib/wire-types.generated.js.map +1 -0
  267. package/lib/workflow-analytics.d.ts +21 -19
  268. package/lib/workflow-analytics.d.ts.map +1 -1
  269. package/lib/workflow-analytics.js +2 -2
  270. package/lib/workflow-analytics.js.map +1 -1
  271. package/package.json +15 -10
  272. package/src/access-control-values.ts +2 -2
  273. package/src/access-control.ts +7 -15
  274. package/src/analytics.ts +6 -13
  275. package/src/api-contract/components.generated.json +1389 -45
  276. package/src/api-schemas/access-control.ts +18 -16
  277. package/src/api-schemas/account.ts +5 -4
  278. package/src/api-schemas/agent-budget.ts +60 -0
  279. package/src/api-schemas/agent-runs.ts +63 -27
  280. package/src/api-schemas/apikey.ts +11 -10
  281. package/src/api-schemas/app-lifecycle.ts +5 -0
  282. package/src/api-schemas/audit-trail.ts +7 -1
  283. package/src/api-schemas/content.ts +55 -0
  284. package/src/api-schemas/cost-analytics.ts +34 -2
  285. package/src/api-schemas/environment.ts +0 -1
  286. package/src/api-schemas/group.ts +2 -1
  287. package/src/api-schemas/index.ts +1 -0
  288. package/src/api-schemas/inference-profile.ts +151 -0
  289. package/src/api-schemas/interaction.ts +40 -1
  290. package/src/api-schemas/invites.ts +10 -9
  291. package/src/api-schemas/process.ts +78 -2
  292. package/src/api-schemas/project-configuration.ts +19 -1
  293. package/src/api-schemas/project.ts +19 -10
  294. package/src/api-schemas/quota.ts +7 -6
  295. package/src/api-schemas/registry.ts +131 -33
  296. package/src/api-schemas/run-budget.ts +60 -0
  297. package/src/api-schemas/store.ts +12 -0
  298. package/src/api-schemas/user.ts +9 -8
  299. package/src/api-schemas/workflow-runs.ts +2 -0
  300. package/src/apikey.ts +30 -39
  301. package/src/apps.ts +116 -239
  302. package/src/audit-trail.ts +18 -33
  303. package/src/browser-credentials.ts +11 -23
  304. package/src/common.ts +17 -37
  305. package/src/content-query.ts +3 -4
  306. package/src/cost-analytics.ts +13 -35
  307. package/src/data-platform.ts +79 -168
  308. package/src/delegation.ts +4 -9
  309. package/src/email.ts +15 -29
  310. package/src/embeddings.ts +25 -51
  311. package/src/environment.ts +16 -33
  312. package/src/facets.ts +3 -4
  313. package/src/group.ts +6 -13
  314. package/src/index.ts +27 -0
  315. package/src/inference-profile.ts +20 -0
  316. package/src/integrations.ts +21 -41
  317. package/src/interaction.ts +68 -137
  318. package/src/meters.ts +4 -9
  319. package/src/oauth-server.ts +40 -81
  320. package/src/oauth.ts +9 -19
  321. package/src/payload.ts +11 -25
  322. package/src/pending-asks.ts +8 -22
  323. package/src/platform-event.ts +48 -97
  324. package/src/principal-context.ts +3 -3
  325. package/src/project.ts +43 -86
  326. package/src/prompt.ts +14 -31
  327. package/src/query.ts +10 -20
  328. package/src/rate-limiter.ts +7 -19
  329. package/src/refs.ts +2 -3
  330. package/src/roles/types.ts +5 -11
  331. package/src/run-budget.ts +8 -0
  332. package/src/runs.ts +9 -19
  333. package/src/secrets.ts +20 -41
  334. package/src/store/agent-approval.ts +4 -9
  335. package/src/store/agent-run.ts +53 -99
  336. package/src/store/collections.ts +11 -23
  337. package/src/store/conversation-state.ts +15 -15
  338. package/src/store/doc-analyzer.ts +7 -15
  339. package/src/store/dsl-workflow.ts +10 -23
  340. package/src/store/duration.ts +45 -0
  341. package/src/store/grounded-extraction.ts +6 -13
  342. package/src/store/intake-policy-schema.generated.ts +148 -2
  343. package/src/store/process.ts +70 -140
  344. package/src/store/rendering.ts +6 -19
  345. package/src/store/signals.ts +48 -0
  346. package/src/store/store.ts +92 -181
  347. package/src/store/task.ts +10 -24
  348. package/src/store/workflow.ts +35 -71
  349. package/src/sts-token-types.ts +14 -33
  350. package/src/tools.ts +12 -25
  351. package/src/transient-tokens.ts +3 -3
  352. package/src/user.ts +17 -39
  353. package/src/views.ts +61 -125
  354. package/src/wire-types.generated.ts +11889 -0
  355. package/src/workflow-analytics.ts +21 -19
  356. package/src/agent-resources.test.ts +0 -89
  357. package/src/api-contract/components.contract.test.ts +0 -99
  358. package/src/api-schemas/access-control.contract.test.ts +0 -209
  359. package/src/api-schemas/account-apikey.test.ts +0 -60
  360. package/src/api-schemas/account.contract.test.ts +0 -319
  361. package/src/api-schemas/adapter-edge-cases.test.ts +0 -499
  362. package/src/api-schemas/agent-communication.contract.test.ts +0 -90
  363. package/src/api-schemas/agent-history.contract.test.ts +0 -42
  364. package/src/api-schemas/agent-runs.contract.test.ts +0 -240
  365. package/src/api-schemas/api-discriminators.test.ts +0 -185
  366. package/src/api-schemas/apikey.contract.test.ts +0 -270
  367. package/src/api-schemas/app-delete-summary.contract.test.ts +0 -67
  368. package/src/api-schemas/bulk-operation.contract.test.ts +0 -39
  369. package/src/api-schemas/bundle-isolation.test.ts +0 -44
  370. package/src/api-schemas/commands.contract.test.ts +0 -51
  371. package/src/api-schemas/cost-analytics.contract.test.ts +0 -64
  372. package/src/api-schemas/dashboard.contract.test.ts +0 -138
  373. package/src/api-schemas/data-store.contract.test.ts +0 -97
  374. package/src/api-schemas/document-processing.contract.test.ts +0 -76
  375. package/src/api-schemas/emit-json-schema.test.ts +0 -36
  376. package/src/api-schemas/environment.contract.test.ts +0 -202
  377. package/src/api-schemas/group.contract.test.ts +0 -205
  378. package/src/api-schemas/indexing.contract.test.ts +0 -122
  379. package/src/api-schemas/interaction.contract.test.ts +0 -307
  380. package/src/api-schemas/invites.contract.test.ts +0 -268
  381. package/src/api-schemas/llumiverse.contract.test.ts +0 -179
  382. package/src/api-schemas/mcp-api-key.contract.test.ts +0 -125
  383. package/src/api-schemas/oauth.contract.test.ts +0 -181
  384. package/src/api-schemas/parameters.test.ts +0 -402
  385. package/src/api-schemas/process.contract.test.ts +0 -115
  386. package/src/api-schemas/project.contract.test.ts +0 -472
  387. package/src/api-schemas/pruning-limits.test.ts +0 -189
  388. package/src/api-schemas/quota.contract.test.ts +0 -147
  389. package/src/api-schemas/registry-groups.test.ts +0 -99
  390. package/src/api-schemas/response-pruning.test.ts +0 -260
  391. package/src/api-schemas/store.contract.test.ts +0 -378
  392. package/src/api-schemas/sts.contract.test.ts +0 -112
  393. package/src/api-schemas/user.contract.test.ts +0 -197
  394. package/src/api-schemas/views.contract.test.ts +0 -112
  395. package/src/api-schemas/zeno-response-contracts.test.ts +0 -380
  396. package/src/apps.test.ts +0 -89
  397. package/src/oauth-scopes.test.ts +0 -15
  398. package/src/roles.test.ts +0 -33
  399. package/src/schema-for-extraction.test.ts +0 -191
  400. package/src/store/agent-approval.test.ts +0 -18
  401. package/src/store/content-type-editing.test.ts +0 -17
  402. package/src/store/ms.d.ts +0 -42
  403. package/src/store/schedule.test.ts +0 -59
  404. package/src/store/workflow.test.ts +0 -640
  405. package/src/versions.test.ts +0 -13
@@ -1,319 +0,0 @@
1
- import { Ajv2020 } from 'ajv/dist/2020.js';
2
- import { describe, expect, it } from 'vitest';
3
- import type { StripeBillingStatusResponse } from '../meters.js';
4
- import { type Account, BillingMethod, type QuotaTier, type UpdateAccountPayload } from '../user.js';
5
- import { type JsonObject, SchemaAdapterError, toOpenApiComponents } from './adapter.js';
6
- import { ApiSchemaComponents, apiComponentRef, validateApiRequest, validateApiResponse } from './registry.js';
7
-
8
- /** Exact type identity — `extends` in both directions is too weak (any/unknown slip through). */
9
- type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false;
10
- /**
11
- * Mutual assignability. Weaker than {@link Equals}, and the right assertion when comparing a
12
- * derived type against a hand-written enum or interface: TypeScript keeps those nominally
13
- * distinct even when structurally interchangeable, and interchangeable is what consumers need.
14
- * `[A] extends [B]` rather than `A extends B` so unions do not distribute.
15
- */
16
- type MutuallyAssignable<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
17
- function assertType<T extends true>(_ok: T): void {}
18
-
19
- /**
20
- * Compiles a component through an OpenAPI-shaped envelope, so the pointer AJV resolves is the
21
- * exact pointer the spec publishes. An isolated component cannot resolve
22
- * `#/components/schemas/*` on its own.
23
- *
24
- * `strictSchema: false` (not `strict: false`) keeps AJV's type and tuple checks active while
25
- * tolerating the `components` envelope keyword.
26
- */
27
- function compile(name: string, components: Readonly<Record<string, JsonObject>> = ApiSchemaComponents) {
28
- const ajv = new Ajv2020({ strictSchema: false, allErrors: true });
29
- ajv.addSchema({ $id: 'vertesia://openapi', components: { schemas: components } });
30
- return ajv.compile({ $ref: `vertesia://openapi${apiComponentRef(name as never)}` });
31
- }
32
-
33
- const VALID_ACCOUNT = {
34
- id: 'acc_1',
35
- name: 'Acme',
36
- email_domains: ['acme.com'],
37
- onboarding: { completed: true, completed_at: '2026-07-29T10:00:00.000Z' },
38
- datacenter: 'gcp',
39
- account_type: 'customer',
40
- billing: { method: 'stripe', stripe_customer_id: 'cus_1' },
41
- created_by: 'u1',
42
- updated_by: 'u1',
43
- created_at: '2026-07-29T10:00:00.000Z',
44
- updated_at: '2026-07-29T10:00:00.000Z',
45
- };
46
-
47
- describe('gate 1 — the schema is the single source of truth for the public types', () => {
48
- it('publishes the exact schema-derived type, not a hand-written twin', () => {
49
- // `Equals`, not assignability: two structurally similar declarations would satisfy
50
- // assignability while still being free to drift. Identity is the property that makes the
51
- // schema the source of truth — there is only one definition to change.
52
- expect(true).toBe(true);
53
- });
54
-
55
- it('resolves a nested component reference to its concrete property type', () => {
56
- // The whole point of schema-first: this must not degrade to `unknown`. The enum survives
57
- // as the shared `BillingMethod` enum rather than a bare literal union, which is what keeps
58
- // it interchangeable with the value consumers already import.
59
- assertType<MutuallyAssignable<Account['billing']['method'], BillingMethod>>(true);
60
- assertType<Equals<Account['billing']['stripe_customer_id'], string | undefined>>(true);
61
- assertType<Equals<Account['email_domains'], string[]>>(true);
62
- assertType<Equals<Account['quota_tier'], QuotaTier | undefined>>(true);
63
- assertType<Equals<Account['onboarding']['completed_at'], string | undefined>>(true);
64
- expect(true).toBe(true);
65
- });
66
-
67
- it('narrows the Stripe union on its discriminator', () => {
68
- // The flat shape gave consumers `portal_url?` and `reason?` with no way to know which was
69
- // populated. Narrowing on `status` is the behaviour a client actually needs, and it only
70
- // exists because the type comes from the discriminated union the schema declares.
71
- const enabled: StripeBillingStatusResponse = {
72
- status: 'enabled',
73
- billing_method: BillingMethod.stripe,
74
- portal_url: 'https://billing.stripe.com/p/session_1',
75
- };
76
- if (enabled.status === 'enabled') {
77
- assertType<Equals<typeof enabled.portal_url, string | null>>(true);
78
- expect(enabled.portal_url).toBe('https://billing.stripe.com/p/session_1');
79
- }
80
-
81
- const disabled: StripeBillingStatusResponse = {
82
- status: 'disabled',
83
- billing_method: null,
84
- reason: 'No billing method configured',
85
- };
86
- if (disabled.status === 'disabled') {
87
- assertType<Equals<typeof disabled.reason, string>>(true);
88
- expect(disabled.reason).toBe('No billing method configured');
89
- }
90
- });
91
- });
92
-
93
- describe('gate 2 — canonical schemas carry stable OpenAPI component references', () => {
94
- it('publishes the registered component graph without migration-era names', () => {
95
- const names = Object.keys(ApiSchemaComponents);
96
- expect(new Set(names).size).toBe(names.length);
97
- expect(names).toEqual(expect.arrayContaining(['Account', 'AccountBilling', 'StripeBillingStatusResponse']));
98
- expect(names.some((name) => name.startsWith('Partial_'))).toBe(false);
99
- });
100
- it('emits only #/components/schemas pointers', () => {
101
- const serialized = JSON.stringify(ApiSchemaComponents);
102
- expect(serialized).not.toContain('#/$defs/');
103
- expect(serialized).not.toContain('$schema');
104
- expect(serialized).not.toContain('"$defs"');
105
- for (const ref of serialized.matchAll(/"\$ref":"([^"]+)"/g)) {
106
- expect(ref[1]).toMatch(/^#\/components\/schemas\/[A-Za-z0-9_]+$/);
107
- }
108
- });
109
-
110
- it('shares one AccountBilling component across both referencing schemas', () => {
111
- const fromAccount = (ApiSchemaComponents.Account.properties as JsonObject).billing;
112
- const fromPayload = (ApiSchemaComponents.UpdateAccountPayload.properties as JsonObject).billing;
113
- expect(fromAccount).toEqual({ $ref: '#/components/schemas/AccountBilling' });
114
- expect(fromPayload).toEqual({ $ref: '#/components/schemas/AccountBilling' });
115
- });
116
-
117
- it('synthesizes a discriminator for the Stripe billing union', () => {
118
- const union = ApiSchemaComponents.StripeBillingStatusResponse;
119
- expect(union.oneOf).toEqual([
120
- { $ref: '#/components/schemas/StripeBillingEnabled' },
121
- { $ref: '#/components/schemas/StripeBillingDisabled' },
122
- ]);
123
- expect(union.discriminator).toEqual({
124
- propertyName: 'status',
125
- mapping: {
126
- enabled: '#/components/schemas/StripeBillingEnabled',
127
- disabled: '#/components/schemas/StripeBillingDisabled',
128
- },
129
- });
130
- });
131
- });
132
-
133
- describe('gate 3 — AJV validates the same canonical objects that are published', () => {
134
- it('accepts a valid account and rejects a bad enum', () => {
135
- const validate = compile('Account');
136
- expect(validate(VALID_ACCOUNT)).toBe(true);
137
- expect(validate({ ...VALID_ACCOUNT, billing: { method: 'paypal' } })).toBe(false);
138
- });
139
-
140
- it('rejects a missing required field', () => {
141
- const validate = compile('Account');
142
- const { email_domains: _dropped, ...incomplete } = VALID_ACCOUNT;
143
- expect(validate(incomplete)).toBe(false);
144
- });
145
-
146
- it('enforces the discriminated union per branch', () => {
147
- const validate = compile('StripeBillingStatusResponse');
148
- expect(validate({ status: 'enabled', billing_method: 'stripe', portal_url: 'https://x' })).toBe(true);
149
- expect(validate({ status: 'enabled', billing_method: 'stripe', portal_url: null })).toBe(true);
150
- expect(validate({ status: 'disabled', billing_method: null, reason: 'No billing method' })).toBe(true);
151
- // The flattened interface allowed this; a real discriminated union does not.
152
- expect(validate({ status: 'enabled', billing_method: 'stripe', reason: 'nope' })).toBe(false);
153
- });
154
- });
155
-
156
- describe('gates 4 & 5 — unknown-field behaviour and no mutation', () => {
157
- it('reports an unknown request field without removing it', () => {
158
- // `UpdateAccountPayload` is published closed, as it always has been, so an extra property
159
- // is a contract violation. AJV must SAY SO rather than quietly delete it: a removal mode
160
- // would make the server accept a body the published schema declares invalid, which is a
161
- // silent disagreement between the spec and the code enforcing it.
162
- expect(ApiSchemaComponents.UpdateAccountPayload.additionalProperties).toBe(false);
163
- const validate = compile('UpdateAccountPayload');
164
- const payload: Record<string, unknown> = { name: 'Acme', rogue_field: 42 };
165
- expect(validate(payload)).toBe(false);
166
- expect(payload.rogue_field).toBe(42);
167
- });
168
-
169
- it('never mutates a response payload during validation', () => {
170
- const validate = compile('Account');
171
- const response = structuredClone({ ...VALID_ACCOUNT, legacy_extra: 'still here' });
172
- const pristine = structuredClone(response);
173
- // Invalid against the closed component — and left exactly as it was. Removing the extra
174
- // is response PRUNING's job, an explicit call with its own policy, never a side effect of
175
- // asking whether a payload conforms.
176
- expect(validate(response)).toBe(false);
177
- expect(response).toEqual(pristine);
178
- });
179
-
180
- it('rejects unknown fields only where a component opts in to strict', () => {
181
- const components = toOpenApiComponents(
182
- { Strict: { type: 'object', properties: { a: { type: 'string' } }, required: ['a'] } },
183
- { strictComponents: new Set(['Strict']) },
184
- );
185
- expect(components.Strict.additionalProperties).toBe(false);
186
- const ajv = new Ajv2020({ strictSchema: false });
187
- ajv.addSchema({ $id: 'vertesia://openapi', components: { schemas: components } });
188
- const validate = ajv.compile({ $ref: 'vertesia://openapi#/components/schemas/Strict' });
189
- const payload = { a: 'x', extra: 1 };
190
- expect(validate(payload)).toBe(false);
191
- expect(payload.extra).toBe(1); // rejected, not stripped
192
- });
193
- });
194
-
195
- describe('gate 7 — the adapter is library-neutral', () => {
196
- it('hoists typebox-style nested $id subschemas', () => {
197
- // TypeBox embeds the schema value (which is what preserves Static<> inference) and marks
198
- // it with $id; the adapter lifts it, exactly as it lifts zod's $defs.
199
- const components = toOpenApiComponents({
200
- Account: {
201
- type: 'object',
202
- properties: {
203
- billing: { $id: 'AccountBilling', type: 'object', properties: { method: { type: 'string' } } },
204
- history: {
205
- type: 'array',
206
- items: { $id: 'AccountBilling', type: 'object', properties: { method: { type: 'string' } } },
207
- },
208
- },
209
- },
210
- });
211
- expect(Object.keys(components).sort()).toEqual(['Account', 'AccountBilling']);
212
- const props = components.Account.properties as JsonObject;
213
- expect(props.billing).toEqual({ $ref: '#/components/schemas/AccountBilling' });
214
- expect((props.history as JsonObject).items).toEqual({ $ref: '#/components/schemas/AccountBilling' });
215
- });
216
-
217
- it('rewrites a root self-reference to its component pointer', () => {
218
- // zod emits `{"$ref": "#"}` for recursion, which would point at the whole OpenAPI
219
- // document once embedded under components.
220
- const components = toOpenApiComponents({
221
- Node: {
222
- type: 'object',
223
- properties: { name: { type: 'string' }, children: { type: 'array', items: { $ref: '#' } } },
224
- },
225
- });
226
- const props = components.Node.properties as JsonObject;
227
- expect((props.children as JsonObject).items).toEqual({ $ref: '#/components/schemas/Node' });
228
- });
229
-
230
- it('does not mutate its input', () => {
231
- const input = { A: { type: 'object', properties: { b: { $id: 'B', type: 'string' } } } };
232
- const pristine = structuredClone(input);
233
- toOpenApiComponents(input);
234
- expect(input).toEqual(pristine);
235
- });
236
-
237
- it('rejects two different schemas claiming the same component name', () => {
238
- expect(() =>
239
- toOpenApiComponents({
240
- A: { type: 'object', properties: { x: { $id: 'Dup', type: 'string' } } },
241
- B: { type: 'object', properties: { y: { $id: 'Dup', type: 'number' } } },
242
- }),
243
- ).toThrow(SchemaAdapterError);
244
- });
245
- });
246
-
247
- describe('gate 8 — runtime enforcement uses the published components', () => {
248
- it('rejects a request body that violates the published component, without mutating it', () => {
249
- const payload: Record<string, unknown> = { name: 'Acme', rogue_field: 42 };
250
- const result = validateApiRequest('UpdateAccountPayload', payload);
251
-
252
- expect(result.valid).toBe(false);
253
- if (!result.valid) {
254
- expect(result.errors.join(' ')).toContain('additional properties');
255
- }
256
- // Reported, not deleted: removing it would make the server accept a body its own published
257
- // schema calls invalid.
258
- expect(payload.rogue_field).toBe(42);
259
- });
260
-
261
- it('accepts a conforming request body and hands back the component type', () => {
262
- const result = validateApiRequest('UpdateAccountPayload', {
263
- name: 'Acme',
264
- billing: { method: 'stripe' },
265
- });
266
-
267
- expect(result.valid).toBe(true);
268
- if (result.valid) {
269
- // Typed as the component only on the valid branch, so a body missing required fields
270
- // can never be typed as complete.
271
- assertType<Equals<typeof result.data, UpdateAccountPayload>>(true);
272
- expect(result.data.name).toBe('Acme');
273
- }
274
- });
275
-
276
- it('no longer accepts quota_tier, which the handler never applied', () => {
277
- // Documented-but-ignored is the drift this work removes. The tier is written through the
278
- // admin quota API; accepting it here would eventually invite a "fix" that lets an account
279
- // admin raise their own rate limits.
280
- expect(validateApiRequest('UpdateAccountPayload', { quota_tier: 'enterprise' }).valid).toBe(false);
281
- expect(ApiSchemaComponents.UpdateAccountPayload.properties).not.toHaveProperty('quota_tier');
282
- });
283
-
284
- it('enforces date-time formats, which AJV ignores without ajv-formats', () => {
285
- // Registering the format package is what turns `format: date-time` from documentation into
286
- // a check. Without it this payload would pass and the contract would be a suggestion.
287
- const invalid = { ...VALID_ACCOUNT, created_at: 'yesterday' };
288
- expect(validateApiResponse('Account', invalid).valid).toBe(false);
289
- expect(validateApiResponse('Account', VALID_ACCOUNT).valid).toBe(true);
290
- });
291
-
292
- it('rejects a native Date where the schema declares a date-time string', () => {
293
- // Response validation runs on the object before Koa serializes it, so a mapper that passed
294
- // a Mongoose `Date` straight through would produce correct wire bytes and still be wrong
295
- // here. That is precisely the bug the mapper's date normalization prevents.
296
- const withDate = { ...VALID_ACCOUNT, created_at: new Date('2026-07-29T10:00:00.000Z') };
297
- expect(validateApiResponse('Account', withDate).valid).toBe(false);
298
- });
299
-
300
- it('honours the Stripe discriminator, which the generated Go client does not', () => {
301
- // The one backstop the Go client cannot provide. Its oneOf decoder picks a branch by
302
- // required-property presence and never reads `status`, so it happily decodes the first
303
- // payload below as the *enabled* branch (see openapi/go/tests). AJV does honour `const`,
304
- // which is what lets the server detect its own drift: routing every branch of the handler
305
- // through checkResponseContract turns "the server never emits a contradictory payload"
306
- // from an assumption into something that shows up in the logs when it stops being true.
307
- const enabled = { status: 'enabled', billing_method: 'stripe', portal_url: 'https://x' };
308
- const disabled = { status: 'disabled', billing_method: null, reason: 'No billing method' };
309
- expect(validateApiResponse('StripeBillingStatusResponse', enabled).valid).toBe(true);
310
- expect(validateApiResponse('StripeBillingStatusResponse', disabled).valid).toBe(true);
311
-
312
- // Enabled body, disabled discriminator: matches neither branch.
313
- expect(validateApiResponse('StripeBillingStatusResponse', { ...enabled, status: 'disabled' }).valid).toBe(
314
- false,
315
- );
316
- // Both branches' required properties: a real oneOf must match exactly one.
317
- expect(validateApiResponse('StripeBillingStatusResponse', { ...enabled, reason: 'nope' }).valid).toBe(false);
318
- });
319
- });