@noodleseed/one 0.48.0 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/dist/cli.js +6 -6
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/archive-ops.js +1 -1
  4. package/dist/commands/archive-ops.js.map +1 -1
  5. package/dist/commands/auth-metadata-readiness.d.ts +8 -0
  6. package/dist/commands/auth-metadata-readiness.d.ts.map +1 -0
  7. package/dist/commands/auth-metadata-readiness.js +164 -0
  8. package/dist/commands/auth-metadata-readiness.js.map +1 -0
  9. package/dist/commands/auth-ops.d.ts +3 -0
  10. package/dist/commands/auth-ops.d.ts.map +1 -1
  11. package/dist/commands/auth-ops.js +37 -82
  12. package/dist/commands/auth-ops.js.map +1 -1
  13. package/dist/commands/author-loop.d.ts +7 -3
  14. package/dist/commands/author-loop.d.ts.map +1 -1
  15. package/dist/commands/author-loop.js +33 -62
  16. package/dist/commands/author-loop.js.map +1 -1
  17. package/dist/commands/billing-admission-output.d.ts +16 -0
  18. package/dist/commands/billing-admission-output.d.ts.map +1 -0
  19. package/dist/commands/billing-admission-output.js +40 -0
  20. package/dist/commands/billing-admission-output.js.map +1 -0
  21. package/dist/commands/billing-enforcement-activation-args.d.ts +40 -0
  22. package/dist/commands/billing-enforcement-activation-args.d.ts.map +1 -0
  23. package/dist/commands/billing-enforcement-activation-args.js +125 -0
  24. package/dist/commands/billing-enforcement-activation-args.js.map +1 -0
  25. package/dist/commands/billing-enforcement-activation-files.d.ts +11 -0
  26. package/dist/commands/billing-enforcement-activation-files.d.ts.map +1 -0
  27. package/dist/commands/billing-enforcement-activation-files.js +54 -0
  28. package/dist/commands/billing-enforcement-activation-files.js.map +1 -0
  29. package/dist/commands/billing-enforcement-activation-ops.d.ts +2 -0
  30. package/dist/commands/billing-enforcement-activation-ops.d.ts.map +1 -0
  31. package/dist/commands/billing-enforcement-activation-ops.js +283 -0
  32. package/dist/commands/billing-enforcement-activation-ops.js.map +1 -0
  33. package/dist/commands/billing-enforcement-ops.d.ts.map +1 -1
  34. package/dist/commands/billing-enforcement-ops.js +5 -1
  35. package/dist/commands/billing-enforcement-ops.js.map +1 -1
  36. package/dist/commands/billing-read-ops.d.ts.map +1 -1
  37. package/dist/commands/billing-read-ops.js +15 -3
  38. package/dist/commands/billing-read-ops.js.map +1 -1
  39. package/dist/commands/billing-read-view.d.ts +40 -1
  40. package/dist/commands/billing-read-view.d.ts.map +1 -1
  41. package/dist/commands/billing-read-view.js +50 -0
  42. package/dist/commands/billing-read-view.js.map +1 -1
  43. package/dist/commands/catalog-data-resources.d.ts.map +1 -1
  44. package/dist/commands/catalog-data-resources.js +4 -3
  45. package/dist/commands/catalog-data-resources.js.map +1 -1
  46. package/dist/commands/config-values.d.ts.map +1 -1
  47. package/dist/commands/config-values.js +18 -2
  48. package/dist/commands/config-values.js.map +1 -1
  49. package/dist/commands/deploy-ops.d.ts +1 -0
  50. package/dist/commands/deploy-ops.d.ts.map +1 -1
  51. package/dist/commands/deploy-ops.js +5 -0
  52. package/dist/commands/deploy-ops.js.map +1 -1
  53. package/dist/commands/deploy-status-ops.js +1 -1
  54. package/dist/commands/deploy-status-ops.js.map +1 -1
  55. package/dist/commands/devtools.d.ts +1 -1
  56. package/dist/commands/devtools.d.ts.map +1 -1
  57. package/dist/commands/devtools.js +23 -4
  58. package/dist/commands/devtools.js.map +1 -1
  59. package/dist/commands/local-readiness.d.ts +6 -0
  60. package/dist/commands/local-readiness.d.ts.map +1 -0
  61. package/dist/commands/local-readiness.js +48 -0
  62. package/dist/commands/local-readiness.js.map +1 -0
  63. package/dist/commands/shared.d.ts.map +1 -1
  64. package/dist/commands/shared.js +13 -0
  65. package/dist/commands/shared.js.map +1 -1
  66. package/dist/deploy.d.ts +1 -0
  67. package/dist/deploy.d.ts.map +1 -1
  68. package/dist/deploy.js +1 -0
  69. package/dist/deploy.js.map +1 -1
  70. package/dist/local-target.d.ts +16 -0
  71. package/dist/local-target.d.ts.map +1 -0
  72. package/dist/local-target.js +35 -0
  73. package/dist/local-target.js.map +1 -0
  74. package/node_modules/@noodle-borg/agent-kit/dist/skill-connect-refs.d.ts.map +1 -1
  75. package/node_modules/@noodle-borg/agent-kit/dist/skill-connect-refs.js +7 -8
  76. package/node_modules/@noodle-borg/agent-kit/dist/skill-connect-refs.js.map +1 -1
  77. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +1 -1
  78. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
  79. package/node_modules/@noodle-borg/agent-kit/dist/skill-operations-refs.js +1 -1
  80. package/node_modules/@noodle-borg/agent-kit/dist/skill-operations-refs.js.map +1 -1
  81. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  82. package/node_modules/@noodle-borg/auth/dist/discovery.d.ts +11 -3
  83. package/node_modules/@noodle-borg/auth/dist/discovery.d.ts.map +1 -1
  84. package/node_modules/@noodle-borg/auth/dist/discovery.js +42 -7
  85. package/node_modules/@noodle-borg/auth/dist/discovery.js.map +1 -1
  86. package/node_modules/@noodle-borg/auth/dist/index.d.ts +1 -1
  87. package/node_modules/@noodle-borg/auth/dist/index.d.ts.map +1 -1
  88. package/node_modules/@noodle-borg/auth/dist/index.js +1 -1
  89. package/node_modules/@noodle-borg/auth/dist/index.js.map +1 -1
  90. package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
  91. package/node_modules/@noodle-borg/protocol/dist/mapping.js +2 -0
  92. package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
  93. package/node_modules/@noodle-borg/runtime/dist/result.d.ts +3 -1
  94. package/node_modules/@noodle-borg/runtime/dist/result.d.ts.map +1 -1
  95. package/node_modules/@noodle-borg/runtime/dist/result.js.map +1 -1
  96. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.d.ts +10 -0
  97. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.d.ts.map +1 -1
  98. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.js +26 -1
  99. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.js.map +1 -1
  100. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.d.ts +46 -0
  101. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.d.ts.map +1 -0
  102. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.js +111 -0
  103. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.js.map +1 -0
  104. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.d.ts +80 -0
  105. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.d.ts.map +1 -0
  106. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.js +2 -0
  107. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.js.map +1 -0
  108. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.d.ts +18 -0
  109. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.d.ts.map +1 -0
  110. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.js +51 -0
  111. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.js.map +1 -0
  112. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.d.ts +34 -0
  113. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.d.ts.map +1 -0
  114. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.js +125 -0
  115. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.js.map +1 -0
  116. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts +265 -0
  117. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts.map +1 -0
  118. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.js +340 -0
  119. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.js.map +1 -0
  120. package/node_modules/@noodle-borg/service/dist/billing/enforcement-profile.d.ts +1 -1
  121. package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts +15 -3
  122. package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts.map +1 -1
  123. package/node_modules/@noodle-borg/service/dist/billing/integration.js +56 -3
  124. package/node_modules/@noodle-borg/service/dist/billing/integration.js.map +1 -1
  125. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.d.ts +20 -0
  126. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.d.ts.map +1 -0
  127. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.js +121 -0
  128. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.js.map +1 -0
  129. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.d.ts +10 -0
  130. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.d.ts.map +1 -0
  131. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.js +33 -0
  132. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.js.map +1 -0
  133. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.d.ts +25 -0
  134. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.d.ts.map +1 -0
  135. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.js +248 -0
  136. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.js.map +1 -0
  137. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.d.ts +17 -0
  138. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.d.ts.map +1 -0
  139. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.js +278 -0
  140. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.js.map +1 -0
  141. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.d.ts +7 -0
  142. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.d.ts.map +1 -0
  143. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.js +63 -0
  144. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.js.map +1 -0
  145. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.d.ts +6 -0
  146. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.d.ts.map +1 -0
  147. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.js +89 -0
  148. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.js.map +1 -0
  149. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.d.ts +13 -0
  150. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.d.ts.map +1 -0
  151. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.js +193 -0
  152. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.js.map +1 -0
  153. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.d.ts +4 -0
  154. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.d.ts.map +1 -0
  155. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.js +119 -0
  156. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.js.map +1 -0
  157. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.d.ts +65 -0
  158. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.d.ts.map +1 -0
  159. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.js +159 -0
  160. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.js.map +1 -0
  161. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.d.ts +31 -0
  162. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.d.ts.map +1 -0
  163. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.js +247 -0
  164. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.js.map +1 -0
  165. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.d.ts.map +1 -1
  166. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js +40 -0
  167. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js.map +1 -1
  168. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts +1 -0
  169. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts.map +1 -1
  170. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js +45 -22
  171. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js.map +1 -1
  172. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.d.ts +33 -0
  173. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.d.ts.map +1 -0
  174. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.js +158 -0
  175. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.js.map +1 -0
  176. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.d.ts +18 -0
  177. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.d.ts.map +1 -0
  178. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.js +326 -0
  179. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.js.map +1 -0
  180. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts +2 -0
  181. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts.map +1 -1
  182. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js +10 -5
  183. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js.map +1 -1
  184. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js +3 -3
  185. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js.map +1 -1
  186. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts +3 -1
  187. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts.map +1 -1
  188. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js +8 -2
  189. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js.map +1 -1
  190. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js +4 -4
  191. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js.map +1 -1
  192. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts +2 -2
  193. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts.map +1 -1
  194. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.js.map +1 -1
  195. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-store.js +1 -1
  196. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.d.ts.map +1 -1
  197. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js +27 -1
  198. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js.map +1 -1
  199. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.d.ts +33 -0
  200. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.d.ts.map +1 -0
  201. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.js +272 -0
  202. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.js.map +1 -0
  203. package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.d.ts.map +1 -1
  204. package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.js +2 -0
  205. package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.js.map +1 -1
  206. package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts +174 -28
  207. package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts.map +1 -1
  208. package/node_modules/@noodle-borg/service/dist/billing/read-contract.js +51 -6
  209. package/node_modules/@noodle-borg/service/dist/billing/read-contract.js.map +1 -1
  210. package/node_modules/@noodle-borg/service/dist/billing-public.d.ts +3 -0
  211. package/node_modules/@noodle-borg/service/dist/billing-public.d.ts.map +1 -1
  212. package/node_modules/@noodle-borg/service/dist/billing-public.js +3 -0
  213. package/node_modules/@noodle-borg/service/dist/billing-public.js.map +1 -1
  214. package/node_modules/@noodle-borg/service/dist/options.d.ts +14 -2
  215. package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
  216. package/node_modules/@noodle-borg/service/dist/persistence-options.d.ts.map +1 -1
  217. package/node_modules/@noodle-borg/service/dist/persistence-options.js +9 -0
  218. package/node_modules/@noodle-borg/service/dist/persistence-options.js.map +1 -1
  219. package/node_modules/@noodle-borg/service/dist/registry.d.ts +2 -0
  220. package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
  221. package/node_modules/@noodle-borg/service/dist/registry.js +10 -0
  222. package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
  223. package/node_modules/@noodle-borg/service/dist/routes/archive.d.ts.map +1 -1
  224. package/node_modules/@noodle-borg/service/dist/routes/archive.js +18 -1
  225. package/node_modules/@noodle-borg/service/dist/routes/archive.js.map +1 -1
  226. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.d.ts +15 -0
  227. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.d.ts.map +1 -0
  228. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.js +197 -0
  229. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.js.map +1 -0
  230. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.d.ts +15 -0
  231. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.d.ts.map +1 -0
  232. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.js +33 -0
  233. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.js.map +1 -0
  234. package/node_modules/@noodle-borg/service/dist/routes/billing-read.d.ts +2 -0
  235. package/node_modules/@noodle-borg/service/dist/routes/billing-read.d.ts.map +1 -1
  236. package/node_modules/@noodle-borg/service/dist/routes/billing-read.js +203 -41
  237. package/node_modules/@noodle-borg/service/dist/routes/billing-read.js.map +1 -1
  238. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.d.ts +4 -0
  239. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.d.ts.map +1 -1
  240. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.js +25 -0
  241. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.js.map +1 -1
  242. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.d.ts +1 -0
  243. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.d.ts.map +1 -1
  244. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js +9 -1
  245. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js.map +1 -1
  246. package/node_modules/@noodle-borg/service/dist/routes/control-plane.d.ts.map +1 -1
  247. package/node_modules/@noodle-borg/service/dist/routes/control-plane.js +19 -1
  248. package/node_modules/@noodle-borg/service/dist/routes/control-plane.js.map +1 -1
  249. package/node_modules/@noodle-borg/service/dist/routes/rollback.d.ts.map +1 -1
  250. package/node_modules/@noodle-borg/service/dist/routes/rollback.js +19 -1
  251. package/node_modules/@noodle-borg/service/dist/routes/rollback.js.map +1 -1
  252. package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
  253. package/node_modules/@noodle-borg/service/dist/serve.js +41 -1
  254. package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
  255. package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
  256. package/node_modules/@noodle-borg/service/dist/service.js +6 -3
  257. package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
  258. package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js +3 -3
  259. package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js.map +1 -1
  260. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts +5 -7
  261. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts.map +1 -1
  262. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js +71 -0
  263. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js.map +1 -1
  264. package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.d.ts.map +1 -1
  265. package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js +7 -0
  266. package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js.map +1 -1
  267. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.d.ts.map +1 -1
  268. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js +5 -0
  269. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js.map +1 -1
  270. package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts.map +1 -1
  271. package/node_modules/@noodle-borg/service/dist/store/postgres.js +29 -34
  272. package/node_modules/@noodle-borg/service/dist/store/postgres.js.map +1 -1
  273. package/package.json +1 -1
@@ -0,0 +1,121 @@
1
+ import { BILLING_METER_RETRY_IDENTITY_VERSION } from './meter-readiness.js';
2
+ export class BillingAuthoritativeAuthorityInconsistentError extends Error {
3
+ constructor() {
4
+ super('authoritative billing authority is inconsistent');
5
+ this.name = 'BillingAuthoritativeAuthorityInconsistentError';
6
+ }
7
+ }
8
+ /** Caller must hold the shared lifecycle lock for the surrounding read-only or admission transaction. */
9
+ export async function readBillingAuthoritativeAuthorityTx(client, expected) {
10
+ const { rows } = await client.query(`
11
+ SELECT seal.id AS seal_id,
12
+ activation.state AS activation_state,
13
+ activation.generation AS activation_generation,
14
+ activation.cohort_seal_id AS activation_cohort_seal_id,
15
+ activation.active_epoch_id,
16
+ activation.last_epoch_id,
17
+ activation.activation_service_release_sha AS activation_release_sha,
18
+ activation.admission_contract_version AS activation_contract_version,
19
+ activation.activated_at AS activation_activated_at,
20
+ active_epoch.purpose AS active_epoch_purpose,
21
+ active_epoch.state AS active_epoch_state,
22
+ active_epoch.key_generation AS active_epoch_key_generation,
23
+ active_epoch.release_sha AS active_epoch_release_sha,
24
+ active_epoch.retry_identity_version AS active_epoch_retry_identity_version,
25
+ active_epoch.admission_contract_version AS active_epoch_contract_version,
26
+ active_epoch.activated_at AS active_epoch_activated_at,
27
+ active_epoch.reconciliation_failed_at AS active_epoch_reconciliation_failed_at,
28
+ last_epoch.purpose AS last_epoch_purpose,
29
+ last_epoch.state AS last_epoch_state,
30
+ last_epoch.release_sha AS last_epoch_release_sha,
31
+ last_epoch.admission_contract_version AS last_epoch_contract_version,
32
+ last_epoch.activated_at AS last_epoch_activated_at,
33
+ (SELECT count(*)::text FROM billing_meter_epochs
34
+ WHERE purpose = 'authoritative' AND state = 'active') AS authoritative_active_count,
35
+ transaction_timestamp() AS database_time
36
+ FROM billing_enforcement_cohort_seals AS seal
37
+ LEFT JOIN billing_enforcement_activation_state AS activation ON activation.singleton = true
38
+ LEFT JOIN billing_meter_epochs AS active_epoch ON active_epoch.id = activation.active_epoch_id
39
+ LEFT JOIN billing_meter_epochs AS last_epoch ON last_epoch.id = activation.last_epoch_id
40
+ WHERE seal.singleton = true
41
+ `);
42
+ const row = rows[0];
43
+ if (row === undefined)
44
+ return { state: 'unconfigured' };
45
+ return validateAuthority(row, expected);
46
+ }
47
+ function validateAuthority(row, expected) {
48
+ if (row.activation_state === null ||
49
+ row.activation_generation === null ||
50
+ row.activation_cohort_seal_id !== row.seal_id) {
51
+ throw inconsistent();
52
+ }
53
+ const activeCount = persistedCount(row.authoritative_active_count);
54
+ if (row.activation_state === 'not_activated') {
55
+ if (row.activation_generation !== 0 ||
56
+ row.active_epoch_id !== null ||
57
+ row.last_epoch_id !== null ||
58
+ activeCount !== 0) {
59
+ throw inconsistent();
60
+ }
61
+ return { state: 'inactive', reason: 'not_activated' };
62
+ }
63
+ if (row.activation_state === 'rolled_back') {
64
+ if (row.activation_generation < 1 ||
65
+ row.active_epoch_id !== null ||
66
+ row.last_epoch_id === null ||
67
+ row.activation_contract_version !== expected.admissionContractVersion ||
68
+ row.last_epoch_purpose !== 'authoritative' ||
69
+ row.last_epoch_state !== 'retired' ||
70
+ row.last_epoch_contract_version !== expected.admissionContractVersion ||
71
+ row.last_epoch_release_sha !== row.activation_release_sha ||
72
+ !sameInstant(row.last_epoch_activated_at, row.activation_activated_at) ||
73
+ activeCount !== 0) {
74
+ throw inconsistent();
75
+ }
76
+ return { state: 'inactive', reason: 'rolled_back' };
77
+ }
78
+ if (row.activation_state !== 'active' ||
79
+ row.activation_generation < 1 ||
80
+ row.active_epoch_id === null ||
81
+ row.active_epoch_id !== row.last_epoch_id ||
82
+ row.activation_contract_version !== expected.admissionContractVersion ||
83
+ row.active_epoch_purpose !== 'authoritative' ||
84
+ row.active_epoch_state !== 'active' ||
85
+ row.active_epoch_key_generation !== expected.keyGeneration ||
86
+ row.active_epoch_retry_identity_version !== BILLING_METER_RETRY_IDENTITY_VERSION ||
87
+ row.active_epoch_contract_version !== expected.admissionContractVersion ||
88
+ row.active_epoch_release_sha !== row.activation_release_sha ||
89
+ !sameInstant(row.active_epoch_activated_at, row.activation_activated_at) ||
90
+ row.active_epoch_reconciliation_failed_at !== null ||
91
+ activeCount !== 1) {
92
+ throw inconsistent();
93
+ }
94
+ const activatedAt = authorityInstant(row.activation_activated_at);
95
+ if (activatedAt > authorityInstant(row.database_time))
96
+ throw inconsistent();
97
+ return { state: 'active', epochId: row.active_epoch_id, activatedAt };
98
+ }
99
+ function sameInstant(left, right) {
100
+ if (left === null || right === null)
101
+ return false;
102
+ return authorityInstant(left) === authorityInstant(right);
103
+ }
104
+ function authorityInstant(value) {
105
+ if (value === null)
106
+ throw inconsistent();
107
+ const date = value instanceof Date ? value : new Date(value);
108
+ if (!Number.isFinite(date.getTime()))
109
+ throw inconsistent();
110
+ return date.toISOString();
111
+ }
112
+ function persistedCount(value) {
113
+ const parsed = Number(value);
114
+ if (!Number.isSafeInteger(parsed) || parsed < 0)
115
+ throw inconsistent();
116
+ return parsed;
117
+ }
118
+ function inconsistent() {
119
+ return new BillingAuthoritativeAuthorityInconsistentError();
120
+ }
121
+ //# sourceMappingURL=postgres-authoritative-authority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-authoritative-authority.js","sourceRoot":"","sources":["../../src/billing/postgres-authoritative-authority.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAkC5E,MAAM,OAAO,8CAA+C,SAAQ,KAAK;IACvE;QACE,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,gDAAgD,CAAC;IAC/D,CAAC;CACF;AAED,yGAAyG;AACzG,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,MAAkB,EAClB,QAAuF;IAEvF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BjD,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IACxD,OAAO,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,iBAAiB,CACxB,GAAiB,EACjB,QAAuF;IAEvF,IACE,GAAG,CAAC,gBAAgB,KAAK,IAAI;QAC7B,GAAG,CAAC,qBAAqB,KAAK,IAAI;QAClC,GAAG,CAAC,yBAAyB,KAAK,GAAG,CAAC,OAAO,EAC7C,CAAC;QACD,MAAM,YAAY,EAAE,CAAC;IACvB,CAAC;IACD,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,0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O,EAAE,CAAC;QAAE,MAAM,YAAY,EAAE,CAAC;IAC3D,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;QAAE,MAAM,YAAY,EAAE,CAAC;IACtE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY;IACnB,OAAO,IAAI,8CAA8C,EAAE,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { PoolClient } from 'pg';
2
+ /** Count distinct active, unarchived logical org/apps exactly as production-app admission does. */
3
+ export declare function readBillingCommercialProductionAppCountsTx(client: PoolClient, input: {
4
+ readonly billingAccountId: string;
5
+ readonly org: string | null;
6
+ }): Promise<{
7
+ readonly accountActive: number;
8
+ readonly organizationActive?: number;
9
+ }>;
10
+ //# sourceMappingURL=postgres-commercial-enforcement-apps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-commercial-enforcement-apps.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-commercial-enforcement-apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAOrC,mGAAmG;AACnG,wBAAsB,0CAA0C,CAC9D,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE;IAAE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACxE,OAAO,CAAC;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAyBnF"}
@@ -0,0 +1,33 @@
1
+ /** Count distinct active, unarchived logical org/apps exactly as production-app admission does. */
2
+ export async function readBillingCommercialProductionAppCountsTx(client, input) {
3
+ const { rows } = await client.query(`SELECT count(DISTINCT (deployment.org_slug, deployment.app_slug))::text AS account_active,
4
+ count(DISTINCT deployment.app_slug)
5
+ FILTER (WHERE $2::text IS NOT NULL AND deployment.org_slug = $2)::text
6
+ AS organization_active
7
+ FROM org_billing_links AS link
8
+ JOIN deploy_records AS deployment ON deployment.org_slug = link.org_slug
9
+ WHERE link.billing_account_id = $1
10
+ AND link.active
11
+ AND deployment.active
12
+ AND deployment.archived_at IS NULL`, [input.billingAccountId, input.org]);
13
+ const row = rows[0];
14
+ if (row === undefined)
15
+ throw new Error('commercial production-app projection is unavailable');
16
+ const accountActive = persistedCount(row.account_active);
17
+ const organizationActive = persistedCount(row.organization_active);
18
+ if (organizationActive > accountActive) {
19
+ throw new Error('commercial production-app projection is inconsistent');
20
+ }
21
+ return {
22
+ accountActive,
23
+ ...(input.org === null ? {} : { organizationActive }),
24
+ };
25
+ }
26
+ function persistedCount(value) {
27
+ const parsed = Number(value);
28
+ if (!Number.isSafeInteger(parsed) || parsed < 0) {
29
+ throw new Error('commercial production-app count is invalid');
30
+ }
31
+ return parsed;
32
+ }
33
+ //# sourceMappingURL=postgres-commercial-enforcement-apps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-commercial-enforcement-apps.js","sourceRoot":"","sources":["../../src/billing/postgres-commercial-enforcement-apps.ts"],"names":[],"mappings":"AAOA,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,0CAA0C,CAC9D,MAAkB,EAClB,KAAyE;IAEzE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CACjC;;;;;;;;;0CASsC,EACtC,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,GAAG,CAAC,CACpC,CAAC;IACF,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,GAAG,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC9F,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnE,IAAI,kBAAkB,GAAG,aAAa,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO;QACL,aAAa;QACb,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC;KACtD,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { PoolClient } from 'pg';
2
+ import type { BillingCommercialEnforcementUsage, BillingCommercialOrganizationUsage } from './commercial-enforcement-projection.js';
3
+ import type { BillingCommercialUsageEntitlements } from './commercial-entitlements.js';
4
+ type CounterCorruptionReason = 'counter_inconsistent' | 'window_inconsistent';
5
+ export interface BillingCommercialCounterProjection {
6
+ readonly accountUsage: BillingCommercialEnforcementUsage;
7
+ readonly organizationUsage?: BillingCommercialOrganizationUsage;
8
+ }
9
+ export declare class BillingCommercialCounterProjectionError extends Error {
10
+ readonly reason: CounterCorruptionReason;
11
+ constructor(reason: CounterCorruptionReason);
12
+ }
13
+ /** Read and reconcile the pooled account, organization, and receipt counters in one snapshot. */
14
+ export declare function readBillingCommercialCounterProjectionTx(client: PoolClient, input: {
15
+ readonly epochId: string;
16
+ readonly billingAccountId: string;
17
+ readonly org: string | null;
18
+ readonly entitlements: BillingCommercialUsageEntitlements;
19
+ readonly recordedAt: string;
20
+ readonly countingSince: string;
21
+ readonly windowStart: string;
22
+ readonly windowEnd: string;
23
+ }): Promise<BillingCommercialCounterProjection>;
24
+ export {};
25
+ //# sourceMappingURL=postgres-commercial-enforcement-counters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-commercial-enforcement-counters.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-commercial-enforcement-counters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,KAAK,EACV,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAEvF,KAAK,uBAAuB,GAAG,sBAAsB,GAAG,qBAAqB,CAAC;AAqC9E,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,YAAY,EAAE,iCAAiC,CAAC;IACzD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,kCAAkC,CAAC;CACjE;AAED,qBAAa,uCAAwC,SAAQ,KAAK;IAChE,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;gBAE7B,MAAM,EAAE,uBAAuB;CAK5C;AAED,iGAAiG;AACjG,wBAAsB,wCAAwC,CAC5D,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE;IACL,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,kCAAkC,CAAC;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GACA,OAAO,CAAC,kCAAkC,CAAC,CAG7C"}
@@ -0,0 +1,248 @@
1
+ export class BillingCommercialCounterProjectionError extends Error {
2
+ reason;
3
+ constructor(reason) {
4
+ super(`commercial enforcement counter projection is corrupt: ${reason}`);
5
+ this.name = 'BillingCommercialCounterProjectionError';
6
+ this.reason = reason;
7
+ }
8
+ }
9
+ /** Read and reconcile the pooled account, organization, and receipt counters in one snapshot. */
10
+ export async function readBillingCommercialCounterProjectionTx(client, input) {
11
+ const row = await readCounters(client, input);
12
+ return validateCounters(row, input);
13
+ }
14
+ async function readCounters(client, input) {
15
+ const { rows } = await client.query(`SELECT account.billing_account_id AS account_counter_id,
16
+ account.window_end AS account_window_end,
17
+ account.included_calls::text AS account_included_calls,
18
+ account.overage_calls::text AS account_overage_calls,
19
+ account.denied_calls::text AS account_denied_calls,
20
+ account.first_admitted_at AS account_first_admitted_at,
21
+ account.last_admitted_at AS account_last_admitted_at,
22
+ account.updated_at AS account_updated_at,
23
+ organization.org_slug AS org_counter_slug,
24
+ organization.window_end AS org_window_end,
25
+ organization.included_calls::text AS org_included_calls,
26
+ organization.overage_calls::text AS org_overage_calls,
27
+ organization.denied_calls::text AS org_denied_calls,
28
+ organization.first_admitted_at AS org_first_admitted_at,
29
+ organization.last_admitted_at AS org_last_admitted_at,
30
+ organization.updated_at AS org_updated_at,
31
+ organization_totals.counter_count::text AS aggregate_org_counter_count,
32
+ organization_totals.included_calls::text AS aggregate_org_included_calls,
33
+ organization_totals.overage_calls::text AS aggregate_org_overage_calls,
34
+ organization_totals.denied_calls::text AS aggregate_org_denied_calls,
35
+ organization_totals.windows_match AS aggregate_org_windows_match,
36
+ organization_totals.rows_well_formed AS aggregate_org_rows_well_formed,
37
+ organization_totals.first_admitted_at AS aggregate_org_first_admitted_at,
38
+ organization_totals.last_admitted_at AS aggregate_org_last_admitted_at,
39
+ organization_totals.updated_at AS aggregate_org_updated_at,
40
+ meter_window.epoch_id AS meter_epoch_id,
41
+ meter_window.receipt_included_calls::text,
42
+ meter_window.receipt_overage_calls::text,
43
+ meter_window.receipt_denied_calls::text,
44
+ meter_window.first_observed_at AS meter_first_observed_at,
45
+ meter_window.last_observed_at AS meter_last_observed_at,
46
+ meter_window.sealed_at AS meter_sealed_at
47
+ FROM (VALUES (true)) AS singleton(value)
48
+ LEFT JOIN billing_meter_account_windows AS account
49
+ ON account.epoch_id = $1 AND account.billing_account_id = $2
50
+ AND account.window_start = $3
51
+ LEFT JOIN billing_meter_org_windows AS organization
52
+ ON $5::text IS NOT NULL AND organization.epoch_id = $1
53
+ AND organization.billing_account_id = $2 AND organization.org_slug = $5
54
+ AND organization.window_start = $3
55
+ LEFT JOIN LATERAL (
56
+ SELECT count(*) AS counter_count,
57
+ coalesce(sum(included_calls), 0) AS included_calls,
58
+ coalesce(sum(overage_calls), 0) AS overage_calls,
59
+ coalesce(sum(denied_calls), 0) AS denied_calls,
60
+ bool_and(window_end = $4::timestamptz) AS windows_match,
61
+ bool_and(
62
+ included_calls + overage_calls > 0 AND
63
+ first_admitted_at <= last_admitted_at AND
64
+ last_admitted_at <= updated_at
65
+ ) AS rows_well_formed,
66
+ min(first_admitted_at) AS first_admitted_at,
67
+ max(last_admitted_at) AS last_admitted_at,
68
+ max(updated_at) AS updated_at
69
+ FROM billing_meter_org_windows
70
+ WHERE epoch_id = $1 AND billing_account_id = $2 AND window_start = $3
71
+ ) AS organization_totals ON true
72
+ LEFT JOIN billing_meter_windows AS meter_window
73
+ ON meter_window.epoch_id = $1 AND meter_window.window_start = $3
74
+ AND meter_window.window_end = $4`, [input.epochId, input.billingAccountId, input.windowStart, input.windowEnd, input.org]);
75
+ const row = rows[0];
76
+ if (row === undefined)
77
+ throw corrupt('counter_inconsistent');
78
+ return row;
79
+ }
80
+ function validateCounters(row, input) {
81
+ if (input.countingSince < input.windowStart ||
82
+ input.countingSince >= input.windowEnd ||
83
+ input.countingSince > input.recordedAt) {
84
+ throw corrupt('window_inconsistent');
85
+ }
86
+ if (row.meter_sealed_at !== null)
87
+ throw corrupt('window_inconsistent');
88
+ const meterPresent = row.meter_epoch_id !== null;
89
+ const receipt = meterPresent
90
+ ? countTriple(row.receipt_included_calls, row.receipt_overage_calls, row.receipt_denied_calls, 'window_inconsistent')
91
+ : [0, 0, 0];
92
+ if ((!meterPresent &&
93
+ (row.receipt_included_calls !== null ||
94
+ row.receipt_overage_calls !== null ||
95
+ row.receipt_denied_calls !== null)) ||
96
+ receipt[2] !== 0) {
97
+ throw corrupt('window_inconsistent');
98
+ }
99
+ validateObservationSpan(receipt[0] + receipt[1], row.meter_first_observed_at, row.meter_last_observed_at, null, input, 'window_inconsistent');
100
+ const accountPresent = row.account_counter_id !== null;
101
+ const account = accountPresent
102
+ ? countTriple(row.account_included_calls, row.account_overage_calls, row.account_denied_calls, 'counter_inconsistent')
103
+ : [0, 0, 0];
104
+ if (accountPresent) {
105
+ if (!meterPresent ||
106
+ projectionInstant(row.account_window_end, 'counter_inconsistent') !== input.windowEnd) {
107
+ throw corrupt('counter_inconsistent');
108
+ }
109
+ validateObservationSpan(account[0] + account[1], row.account_first_admitted_at, row.account_last_admitted_at, row.account_updated_at, input, 'counter_inconsistent');
110
+ }
111
+ else if (row.account_window_end !== null ||
112
+ row.account_included_calls !== null ||
113
+ row.account_overage_calls !== null ||
114
+ row.account_denied_calls !== null) {
115
+ throw corrupt('counter_inconsistent');
116
+ }
117
+ const aggregateOrgCounterCount = safeCount(row.aggregate_org_counter_count, 'counter_inconsistent');
118
+ const aggregateOrganization = countTriple(row.aggregate_org_included_calls, row.aggregate_org_overage_calls, row.aggregate_org_denied_calls, 'counter_inconsistent');
119
+ if (aggregateOrgCounterCount === 0) {
120
+ if (row.aggregate_org_windows_match !== null ||
121
+ row.aggregate_org_rows_well_formed !== null ||
122
+ row.aggregate_org_first_admitted_at !== null ||
123
+ row.aggregate_org_last_admitted_at !== null ||
124
+ row.aggregate_org_updated_at !== null) {
125
+ throw corrupt('counter_inconsistent');
126
+ }
127
+ }
128
+ else {
129
+ if (!row.aggregate_org_windows_match || !row.aggregate_org_rows_well_formed) {
130
+ throw corrupt('counter_inconsistent');
131
+ }
132
+ validateObservationSpan(aggregateOrganization[0] + aggregateOrganization[1], row.aggregate_org_first_admitted_at, row.aggregate_org_last_admitted_at, row.aggregate_org_updated_at, input, 'counter_inconsistent');
133
+ }
134
+ if (account[2] !== 0 ||
135
+ account[0] > receipt[0] ||
136
+ account[1] > receipt[1] ||
137
+ account[0] !== aggregateOrganization[0] ||
138
+ account[1] !== aggregateOrganization[1] ||
139
+ account[2] !== aggregateOrganization[2] ||
140
+ accountPresent !== aggregateOrgCounterCount > 0 ||
141
+ account[0] > input.entitlements.includedCalls ||
142
+ (!input.entitlements.overageAllowed && account[1] !== 0) ||
143
+ (account[1] > 0 && account[0] !== input.entitlements.includedCalls)) {
144
+ throw corrupt('counter_inconsistent');
145
+ }
146
+ const organizationUsage = input.org === null ? undefined : validateOrganizationUsage(row, account, input);
147
+ const totalUsedCalls = safeSum(account[0], account[1], 'counter_inconsistent');
148
+ return {
149
+ accountUsage: {
150
+ includedLimitCalls: input.entitlements.includedCalls,
151
+ includedUsedCalls: account[0],
152
+ overageUsedCalls: account[1],
153
+ totalUsedCalls,
154
+ includedRemainingCalls: input.entitlements.includedCalls - account[0],
155
+ overageAllowed: input.entitlements.overageAllowed,
156
+ countingSince: input.countingSince,
157
+ windowStart: input.windowStart,
158
+ windowEnd: input.windowEnd,
159
+ resetAt: input.windowEnd,
160
+ },
161
+ ...(organizationUsage === undefined ? {} : { organizationUsage }),
162
+ };
163
+ }
164
+ function validateOrganizationUsage(row, account, input) {
165
+ const orgPresent = row.org_counter_slug !== null;
166
+ const organization = orgPresent
167
+ ? countTriple(row.org_included_calls, row.org_overage_calls, row.org_denied_calls, 'counter_inconsistent')
168
+ : [0, 0, 0];
169
+ if (orgPresent) {
170
+ if (projectionInstant(row.org_window_end, 'counter_inconsistent') !== input.windowEnd) {
171
+ throw corrupt('counter_inconsistent');
172
+ }
173
+ validateObservationSpan(organization[0] + organization[1], row.org_first_admitted_at, row.org_last_admitted_at, row.org_updated_at, input, 'counter_inconsistent');
174
+ }
175
+ else if (row.org_window_end !== null ||
176
+ row.org_included_calls !== null ||
177
+ row.org_overage_calls !== null ||
178
+ row.org_denied_calls !== null) {
179
+ throw corrupt('counter_inconsistent');
180
+ }
181
+ if (organization[2] !== 0 || organization[0] > account[0] || organization[1] > account[1]) {
182
+ throw corrupt('counter_inconsistent');
183
+ }
184
+ return {
185
+ ...contribution(organization[0], organization[1]),
186
+ countingSince: input.countingSince,
187
+ windowStart: input.windowStart,
188
+ windowEnd: input.windowEnd,
189
+ resetAt: input.windowEnd,
190
+ };
191
+ }
192
+ function validateObservationSpan(calls, first, last, updated, window, reason) {
193
+ if (calls === 0) {
194
+ if (first !== null || last !== null || updated !== null)
195
+ throw corrupt(reason);
196
+ return;
197
+ }
198
+ if (first === null || last === null)
199
+ throw corrupt(reason);
200
+ const firstAt = projectionInstant(first, reason);
201
+ const lastAt = projectionInstant(last, reason);
202
+ const updatedAt = updated === null ? lastAt : projectionInstant(updated, reason);
203
+ if (firstAt < window.countingSince ||
204
+ lastAt < firstAt ||
205
+ lastAt >= window.windowEnd ||
206
+ lastAt > window.recordedAt ||
207
+ updatedAt < lastAt ||
208
+ updatedAt >= window.windowEnd ||
209
+ updatedAt > window.recordedAt) {
210
+ throw corrupt(reason);
211
+ }
212
+ }
213
+ function countTriple(included, overage, denied, reason) {
214
+ if (included === null || overage === null || denied === null)
215
+ throw corrupt(reason);
216
+ return [safeCount(included, reason), safeCount(overage, reason), safeCount(denied, reason)];
217
+ }
218
+ function safeCount(value, reason) {
219
+ const parsed = Number(value);
220
+ if (!Number.isSafeInteger(parsed) || parsed < 0)
221
+ throw corrupt(reason);
222
+ return parsed;
223
+ }
224
+ function safeSum(left, right, reason) {
225
+ const sum = left + right;
226
+ if (!Number.isSafeInteger(sum))
227
+ throw corrupt(reason);
228
+ return sum;
229
+ }
230
+ function contribution(includedUsedCalls, overageUsedCalls) {
231
+ return {
232
+ includedUsedCalls,
233
+ overageUsedCalls,
234
+ totalUsedCalls: safeSum(includedUsedCalls, overageUsedCalls, 'counter_inconsistent'),
235
+ };
236
+ }
237
+ function projectionInstant(value, reason) {
238
+ if (value === null)
239
+ throw corrupt(reason);
240
+ const date = value instanceof Date ? value : new Date(value);
241
+ if (!Number.isFinite(date.getTime()))
242
+ throw corrupt(reason);
243
+ return date.toISOString();
244
+ }
245
+ function corrupt(reason) {
246
+ return new BillingCommercialCounterProjectionError(reason);
247
+ }
248
+ //# sourceMappingURL=postgres-commercial-enforcement-counters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-commercial-enforcement-counters.js","sourceRoot":"","sources":["../../src/billing/postgres-commercial-enforcement-counters.ts"],"names":[],"mappings":"AAiDA,MAAM,OAAO,uCAAwC,SAAQ,KAAK;IACvD,MAAM,CAA0B;IAEzC,YAAY,MAA+B;QACzC,KAAK,CAAC,yDAAyD,MAAM,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,yCAAyC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAC5D,MAAkB,EAClB,KASC;IAED,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,OAAO,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,MAAkB,EAClB,KAMC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCA2DmC,EACnC,CAAC,KAAK,CAA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AAC,WAAW,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,OAAO,CAAC,MAA+B;IAC9C,OAAO,IAAI,uCAAuC,CAAC,MAAM,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Pool } from 'pg';
2
+ import type { BillingCommercialEnforcementProjection, BillingCommercialEnforcementProjectionStore, BillingCommercialEnforcementScope, BillingCommercialSnapshotBinding } from './commercial-enforcement-projection.js';
3
+ export interface PostgresBillingCommercialEnforcementProjectionStoreOptions {
4
+ readonly keyGeneration: string;
5
+ readonly admissionContractVersion?: number;
6
+ /** Bounded test/operations override. Default: 1000ms. */
7
+ readonly lockTimeoutMs?: number;
8
+ /** Bounded test/operations override. Default: 2000ms. */
9
+ readonly statementTimeoutMs?: number;
10
+ }
11
+ /** Read-only projection over the same authority, snapshot, and pooled counters used by admission. */
12
+ export declare class PostgresBillingCommercialEnforcementProjectionStore implements BillingCommercialEnforcementProjectionStore {
13
+ #private;
14
+ constructor(pool: Pool, options: PostgresBillingCommercialEnforcementProjectionStoreOptions);
15
+ getCommercialEnforcementProjection(rawScope: BillingCommercialEnforcementScope, expectedSnapshotBinding?: BillingCommercialSnapshotBinding): Promise<BillingCommercialEnforcementProjection>;
16
+ }
17
+ //# sourceMappingURL=postgres-commercial-enforcement-projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-commercial-enforcement-projection.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-commercial-enforcement-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,IAAI,CAAC;AAE3C,OAAO,KAAK,EACV,sCAAsC,EACtC,2CAA2C,EAC3C,iCAAiC,EAEjC,gCAAgC,EACjC,MAAM,wCAAwC,CAAC;AAqBhD,MAAM,WAAW,0DAA0D;IACzE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAC3C,yDAAyD;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,yDAAyD;IACzD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAgDD,qGAAqG;AACrG,qBAAa,mDACX,YAAW,2CAA2C;;gBAQ1C,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,0DAA0D;IAgBrF,kCAAkC,CACtC,QAAQ,EAAE,iCAAiC,EAC3C,uBAAuB,CAAC,EAAE,gCAAgC,GACzD,OAAO,CAAC,sCAAsC,CAAC;CAsFnD"}