@noodleseed/one 0.48.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/dist/commands/archive-ops.js +1 -1
  2. package/dist/commands/archive-ops.js.map +1 -1
  3. package/dist/commands/billing-admission-output.d.ts +16 -0
  4. package/dist/commands/billing-admission-output.d.ts.map +1 -0
  5. package/dist/commands/billing-admission-output.js +40 -0
  6. package/dist/commands/billing-admission-output.js.map +1 -0
  7. package/dist/commands/billing-enforcement-activation-args.d.ts +40 -0
  8. package/dist/commands/billing-enforcement-activation-args.d.ts.map +1 -0
  9. package/dist/commands/billing-enforcement-activation-args.js +125 -0
  10. package/dist/commands/billing-enforcement-activation-args.js.map +1 -0
  11. package/dist/commands/billing-enforcement-activation-files.d.ts +11 -0
  12. package/dist/commands/billing-enforcement-activation-files.d.ts.map +1 -0
  13. package/dist/commands/billing-enforcement-activation-files.js +54 -0
  14. package/dist/commands/billing-enforcement-activation-files.js.map +1 -0
  15. package/dist/commands/billing-enforcement-activation-ops.d.ts +2 -0
  16. package/dist/commands/billing-enforcement-activation-ops.d.ts.map +1 -0
  17. package/dist/commands/billing-enforcement-activation-ops.js +283 -0
  18. package/dist/commands/billing-enforcement-activation-ops.js.map +1 -0
  19. package/dist/commands/billing-enforcement-ops.d.ts.map +1 -1
  20. package/dist/commands/billing-enforcement-ops.js +5 -1
  21. package/dist/commands/billing-enforcement-ops.js.map +1 -1
  22. package/dist/commands/billing-read-ops.d.ts.map +1 -1
  23. package/dist/commands/billing-read-ops.js +15 -3
  24. package/dist/commands/billing-read-ops.js.map +1 -1
  25. package/dist/commands/billing-read-view.d.ts +40 -1
  26. package/dist/commands/billing-read-view.d.ts.map +1 -1
  27. package/dist/commands/billing-read-view.js +50 -0
  28. package/dist/commands/billing-read-view.js.map +1 -1
  29. package/dist/commands/catalog-data-resources.d.ts.map +1 -1
  30. package/dist/commands/catalog-data-resources.js +4 -3
  31. package/dist/commands/catalog-data-resources.js.map +1 -1
  32. package/dist/commands/deploy-ops.d.ts +1 -0
  33. package/dist/commands/deploy-ops.d.ts.map +1 -1
  34. package/dist/commands/deploy-ops.js +5 -0
  35. package/dist/commands/deploy-ops.js.map +1 -1
  36. package/dist/commands/deploy-status-ops.js +1 -1
  37. package/dist/commands/deploy-status-ops.js.map +1 -1
  38. package/dist/commands/shared.d.ts.map +1 -1
  39. package/dist/commands/shared.js +13 -0
  40. package/dist/commands/shared.js.map +1 -1
  41. package/dist/deploy.d.ts +1 -0
  42. package/dist/deploy.d.ts.map +1 -1
  43. package/dist/deploy.js +1 -0
  44. package/dist/deploy.js.map +1 -1
  45. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  46. package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
  47. package/node_modules/@noodle-borg/protocol/dist/mapping.js +2 -0
  48. package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
  49. package/node_modules/@noodle-borg/runtime/dist/result.d.ts +3 -1
  50. package/node_modules/@noodle-borg/runtime/dist/result.d.ts.map +1 -1
  51. package/node_modules/@noodle-borg/runtime/dist/result.js.map +1 -1
  52. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.d.ts +10 -0
  53. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.d.ts.map +1 -1
  54. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.js +26 -1
  55. package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.js.map +1 -1
  56. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.d.ts +46 -0
  57. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.d.ts.map +1 -0
  58. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.js +111 -0
  59. package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.js.map +1 -0
  60. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.d.ts +80 -0
  61. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.d.ts.map +1 -0
  62. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.js +2 -0
  63. package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.js.map +1 -0
  64. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.d.ts +18 -0
  65. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.d.ts.map +1 -0
  66. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.js +51 -0
  67. package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.js.map +1 -0
  68. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.d.ts +34 -0
  69. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.d.ts.map +1 -0
  70. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.js +125 -0
  71. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.js.map +1 -0
  72. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts +265 -0
  73. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts.map +1 -0
  74. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.js +340 -0
  75. package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.js.map +1 -0
  76. package/node_modules/@noodle-borg/service/dist/billing/enforcement-profile.d.ts +1 -1
  77. package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts +15 -3
  78. package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts.map +1 -1
  79. package/node_modules/@noodle-borg/service/dist/billing/integration.js +56 -3
  80. package/node_modules/@noodle-borg/service/dist/billing/integration.js.map +1 -1
  81. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.d.ts +20 -0
  82. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.d.ts.map +1 -0
  83. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.js +121 -0
  84. package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.js.map +1 -0
  85. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.d.ts +10 -0
  86. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.d.ts.map +1 -0
  87. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.js +33 -0
  88. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.js.map +1 -0
  89. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.d.ts +25 -0
  90. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.d.ts.map +1 -0
  91. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.js +248 -0
  92. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.js.map +1 -0
  93. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.d.ts +17 -0
  94. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.d.ts.map +1 -0
  95. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.js +278 -0
  96. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.js.map +1 -0
  97. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.d.ts +7 -0
  98. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.d.ts.map +1 -0
  99. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.js +63 -0
  100. package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.js.map +1 -0
  101. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.d.ts +6 -0
  102. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.d.ts.map +1 -0
  103. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.js +89 -0
  104. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.js.map +1 -0
  105. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.d.ts +13 -0
  106. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.d.ts.map +1 -0
  107. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.js +193 -0
  108. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.js.map +1 -0
  109. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.d.ts +4 -0
  110. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.d.ts.map +1 -0
  111. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.js +119 -0
  112. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.js.map +1 -0
  113. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.d.ts +65 -0
  114. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.d.ts.map +1 -0
  115. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.js +159 -0
  116. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.js.map +1 -0
  117. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.d.ts +31 -0
  118. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.d.ts.map +1 -0
  119. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.js +247 -0
  120. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.js.map +1 -0
  121. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.d.ts.map +1 -1
  122. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js +40 -0
  123. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js.map +1 -1
  124. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts +1 -0
  125. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts.map +1 -1
  126. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js +45 -22
  127. package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js.map +1 -1
  128. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.d.ts +33 -0
  129. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.d.ts.map +1 -0
  130. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.js +158 -0
  131. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.js.map +1 -0
  132. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.d.ts +18 -0
  133. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.d.ts.map +1 -0
  134. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.js +326 -0
  135. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.js.map +1 -0
  136. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts +2 -0
  137. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts.map +1 -1
  138. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js +10 -5
  139. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js.map +1 -1
  140. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js +3 -3
  141. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js.map +1 -1
  142. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts +3 -1
  143. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts.map +1 -1
  144. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js +8 -2
  145. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js.map +1 -1
  146. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js +4 -4
  147. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js.map +1 -1
  148. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts +2 -2
  149. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts.map +1 -1
  150. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.js.map +1 -1
  151. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-store.js +1 -1
  152. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.d.ts.map +1 -1
  153. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js +27 -1
  154. package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js.map +1 -1
  155. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.d.ts +33 -0
  156. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.d.ts.map +1 -0
  157. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.js +272 -0
  158. package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.js.map +1 -0
  159. package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.d.ts.map +1 -1
  160. package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.js +2 -0
  161. package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.js.map +1 -1
  162. package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts +174 -28
  163. package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts.map +1 -1
  164. package/node_modules/@noodle-borg/service/dist/billing/read-contract.js +51 -6
  165. package/node_modules/@noodle-borg/service/dist/billing/read-contract.js.map +1 -1
  166. package/node_modules/@noodle-borg/service/dist/billing-public.d.ts +3 -0
  167. package/node_modules/@noodle-borg/service/dist/billing-public.d.ts.map +1 -1
  168. package/node_modules/@noodle-borg/service/dist/billing-public.js +3 -0
  169. package/node_modules/@noodle-borg/service/dist/billing-public.js.map +1 -1
  170. package/node_modules/@noodle-borg/service/dist/options.d.ts +14 -2
  171. package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
  172. package/node_modules/@noodle-borg/service/dist/persistence-options.d.ts.map +1 -1
  173. package/node_modules/@noodle-borg/service/dist/persistence-options.js +9 -0
  174. package/node_modules/@noodle-borg/service/dist/persistence-options.js.map +1 -1
  175. package/node_modules/@noodle-borg/service/dist/registry.d.ts +2 -0
  176. package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
  177. package/node_modules/@noodle-borg/service/dist/registry.js +10 -0
  178. package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
  179. package/node_modules/@noodle-borg/service/dist/routes/archive.d.ts.map +1 -1
  180. package/node_modules/@noodle-borg/service/dist/routes/archive.js +18 -1
  181. package/node_modules/@noodle-borg/service/dist/routes/archive.js.map +1 -1
  182. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.d.ts +15 -0
  183. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.d.ts.map +1 -0
  184. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.js +197 -0
  185. package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.js.map +1 -0
  186. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.d.ts +15 -0
  187. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.d.ts.map +1 -0
  188. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.js +33 -0
  189. package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.js.map +1 -0
  190. package/node_modules/@noodle-borg/service/dist/routes/billing-read.d.ts +2 -0
  191. package/node_modules/@noodle-borg/service/dist/routes/billing-read.d.ts.map +1 -1
  192. package/node_modules/@noodle-borg/service/dist/routes/billing-read.js +203 -41
  193. package/node_modules/@noodle-borg/service/dist/routes/billing-read.js.map +1 -1
  194. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.d.ts +4 -0
  195. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.d.ts.map +1 -1
  196. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.js +25 -0
  197. package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.js.map +1 -1
  198. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.d.ts +1 -0
  199. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.d.ts.map +1 -1
  200. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js +9 -1
  201. package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js.map +1 -1
  202. package/node_modules/@noodle-borg/service/dist/routes/control-plane.d.ts.map +1 -1
  203. package/node_modules/@noodle-borg/service/dist/routes/control-plane.js +19 -1
  204. package/node_modules/@noodle-borg/service/dist/routes/control-plane.js.map +1 -1
  205. package/node_modules/@noodle-borg/service/dist/routes/rollback.d.ts.map +1 -1
  206. package/node_modules/@noodle-borg/service/dist/routes/rollback.js +19 -1
  207. package/node_modules/@noodle-borg/service/dist/routes/rollback.js.map +1 -1
  208. package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
  209. package/node_modules/@noodle-borg/service/dist/serve.js +41 -1
  210. package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
  211. package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
  212. package/node_modules/@noodle-borg/service/dist/service.js +6 -3
  213. package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
  214. package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js +3 -3
  215. package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js.map +1 -1
  216. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts +5 -7
  217. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts.map +1 -1
  218. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js +71 -0
  219. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js.map +1 -1
  220. package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.d.ts.map +1 -1
  221. package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js +7 -0
  222. package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js.map +1 -1
  223. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.d.ts.map +1 -1
  224. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js +5 -0
  225. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js.map +1 -1
  226. package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts.map +1 -1
  227. package/node_modules/@noodle-borg/service/dist/store/postgres.js +29 -34
  228. package/node_modules/@noodle-borg/service/dist/store/postgres.js.map +1 -1
  229. package/package.json +1 -1
@@ -0,0 +1,272 @@
1
+ import { parseBillingCommercialFreeV1Entitlements } from './commercial-entitlements.js';
2
+ import { billingContentChecksum } from './model.js';
3
+ /**
4
+ * This exact deployed lock identity is shared with validation-epoch lifecycle operations. Keeping the
5
+ * value stable makes old and new service revisions serialize during a rolling enforcement cutover.
6
+ */
7
+ export const BILLING_ENFORCEMENT_LIFECYCLE_LOCK_KEY = 'billing-meter-validation-epoch-lifecycle:v1';
8
+ const PRODUCTION_APP_ADMISSION_CONTRACT_VERSION = 1;
9
+ export class BillingProductionAppAdmissionError extends Error {
10
+ code;
11
+ constructor(code) {
12
+ super(code === 'production_app_limit_exceeded'
13
+ ? 'the billing account production-app limit is full'
14
+ : 'billing enforcement is temporarily unavailable');
15
+ this.name = 'BillingProductionAppAdmissionError';
16
+ this.code = code;
17
+ }
18
+ }
19
+ /** Acquire before any billing, deploy-run, or deploy-record row lock in an app-state mutation. */
20
+ export async function lockBillingEnforcementLifecycleSharedTx(client) {
21
+ await client.query('SELECT pg_advisory_xact_lock_shared(hashtextextended($1, 0))', [
22
+ BILLING_ENFORCEMENT_LIFECYCLE_LOCK_KEY,
23
+ ]);
24
+ }
25
+ /**
26
+ * Resolve commercial authority and acquire the payer-scoped serialization lock. The returned lock remains
27
+ * held until the caller's transaction ends, so a later capacity check and app activation are one decision.
28
+ */
29
+ export async function prepareProductionAppAdmissionTx(client, input) {
30
+ const authority = await readAuthority(client);
31
+ if (authority === undefined)
32
+ return { kind: 'bypass' };
33
+ let authorityMode;
34
+ try {
35
+ authorityMode = validateAuthority(authority);
36
+ }
37
+ catch (error) {
38
+ if (error instanceof BillingProductionAppAdmissionError) {
39
+ const context = await resolveProductionAppAdmissionTx(client, input);
40
+ if (context.kind === 'bypass')
41
+ return context;
42
+ }
43
+ throw error;
44
+ }
45
+ if (authorityMode === 'bypass')
46
+ return { kind: 'bypass' };
47
+ return resolveProductionAppAdmissionTx(client, input);
48
+ }
49
+ async function resolveProductionAppAdmissionTx(client, input) {
50
+ const initialLink = await client.query(`SELECT billing_account_id
51
+ FROM org_billing_links
52
+ WHERE org_slug = $1 AND active`, [input.org]);
53
+ const initialAccountId = initialLink.rows[0]?.billing_account_id;
54
+ if (initialAccountId === undefined)
55
+ throw unavailable();
56
+ await client.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [
57
+ `billing-production-app-capacity:${initialAccountId}`,
58
+ ]);
59
+ const resolution = await client.query(`SELECT link.billing_account_id, account.state AS account_state,
60
+ account.created_at AS account_created_at,
61
+ profile.mode, profile.source AS profile_source,
62
+ profile.cohort_seal_id AS profile_cohort_seal_id,
63
+ profile.effective_from AS profile_effective_from,
64
+ seal.id AS cohort_seal_id, seal.sealed_at AS cohort_sealed_at,
65
+ snapshot.id AS snapshot_id, snapshot.version AS snapshot_version,
66
+ snapshot.plan_version_id AS snapshot_plan_version_id,
67
+ snapshot.verification_status AS snapshot_verification_status,
68
+ snapshot.effective_from AS snapshot_effective_from,
69
+ snapshot.monthly_usage_anchor AS snapshot_monthly_usage_anchor,
70
+ snapshot.entitlements,
71
+ snapshot.content_checksum AS snapshot_content_checksum
72
+ FROM org_billing_links AS link
73
+ JOIN billing_accounts AS account ON account.id = link.billing_account_id
74
+ JOIN billing_account_active_snapshots AS active_snapshot
75
+ ON active_snapshot.billing_account_id = link.billing_account_id
76
+ JOIN billing_entitlement_snapshots AS snapshot
77
+ ON snapshot.billing_account_id = active_snapshot.billing_account_id
78
+ AND snapshot.id = active_snapshot.snapshot_id
79
+ JOIN billing_account_active_enforcement_profiles AS active_profile
80
+ ON active_profile.billing_account_id = link.billing_account_id
81
+ JOIN billing_account_enforcement_profiles AS profile
82
+ ON profile.billing_account_id = active_profile.billing_account_id
83
+ AND profile.version = active_profile.profile_version
84
+ JOIN billing_enforcement_cohort_seals AS seal ON seal.singleton = true
85
+ WHERE link.org_slug = $1
86
+ AND link.active
87
+ FOR SHARE OF link, account, active_snapshot, snapshot, active_profile, profile, seal`, [input.org]);
88
+ const row = resolution.rows[0];
89
+ if (row === undefined || row.billing_account_id !== initialAccountId)
90
+ throw unavailable();
91
+ validateBillingResolution(row);
92
+ if (row.mode === 'legacy_internal_exempt')
93
+ return { kind: 'bypass' };
94
+ const entitlements = parseBillingCommercialFreeV1Entitlements(row.entitlements);
95
+ return {
96
+ kind: 'enforced',
97
+ billingAccountId: row.billing_account_id,
98
+ org: input.org,
99
+ app: input.app,
100
+ limit: entitlements.productionAppLimit,
101
+ };
102
+ }
103
+ /** Check a prospective logical-app activation while the context's payer lock is still held. */
104
+ export async function assertProductionAppCapacityTx(client, context) {
105
+ if (context.kind === 'bypass')
106
+ return;
107
+ const current = await client.query(`SELECT EXISTS (
108
+ SELECT 1
109
+ FROM deploy_records
110
+ WHERE org_slug = $1 AND app_slug = $2 AND active AND archived_at IS NULL
111
+ ) AS active`, [context.org, context.app]);
112
+ if (current.rows[0]?.active === true)
113
+ return;
114
+ const footprint = await client.query(`SELECT count(*)::text AS active
115
+ FROM (
116
+ SELECT DISTINCT deployment.org_slug, deployment.app_slug
117
+ FROM org_billing_links AS link
118
+ JOIN deploy_records AS deployment ON deployment.org_slug = link.org_slug
119
+ WHERE link.billing_account_id = $1
120
+ AND link.active
121
+ AND deployment.active
122
+ AND deployment.archived_at IS NULL
123
+ ) AS active_apps`, [context.billingAccountId]);
124
+ const active = persistedCount(footprint.rows[0]?.active);
125
+ if (active >= context.limit) {
126
+ throw new BillingProductionAppAdmissionError('production_app_limit_exceeded');
127
+ }
128
+ }
129
+ async function readAuthority(client) {
130
+ const { rows } = await client.query(`
131
+ SELECT seal.id AS seal_id,
132
+ activation.state AS activation_state,
133
+ activation.generation AS activation_generation,
134
+ activation.cohort_seal_id AS activation_cohort_seal_id,
135
+ activation.active_epoch_id,
136
+ activation.last_epoch_id,
137
+ activation.activation_service_release_sha AS activation_release_sha,
138
+ activation.admission_contract_version AS activation_contract_version,
139
+ activation.activated_at AS activation_activated_at,
140
+ active_epoch.purpose AS active_epoch_purpose,
141
+ active_epoch.state AS active_epoch_state,
142
+ active_epoch.release_sha AS active_epoch_release_sha,
143
+ active_epoch.admission_contract_version AS active_epoch_contract_version,
144
+ active_epoch.activated_at AS active_epoch_activated_at,
145
+ active_epoch.reconciliation_failed_at AS active_epoch_reconciliation_failed_at,
146
+ last_epoch.purpose AS last_epoch_purpose,
147
+ last_epoch.state AS last_epoch_state,
148
+ last_epoch.release_sha AS last_epoch_release_sha,
149
+ last_epoch.admission_contract_version AS last_epoch_contract_version,
150
+ last_epoch.activated_at AS last_epoch_activated_at,
151
+ (SELECT count(*)::text
152
+ FROM billing_meter_epochs
153
+ WHERE purpose = 'authoritative' AND state = 'active') AS authoritative_active_count
154
+ FROM billing_enforcement_cohort_seals AS seal
155
+ LEFT JOIN billing_enforcement_activation_state AS activation ON activation.singleton = true
156
+ LEFT JOIN billing_meter_epochs AS active_epoch ON active_epoch.id = activation.active_epoch_id
157
+ LEFT JOIN billing_meter_epochs AS last_epoch ON last_epoch.id = activation.last_epoch_id
158
+ WHERE seal.singleton = true
159
+ `);
160
+ return rows[0];
161
+ }
162
+ function validateAuthority(row) {
163
+ if (row.activation_state === null ||
164
+ row.activation_cohort_seal_id !== row.seal_id ||
165
+ row.activation_generation === null) {
166
+ throw unavailable();
167
+ }
168
+ const authoritativeActiveCount = persistedCount(row.authoritative_active_count);
169
+ if (row.activation_state === 'not_activated') {
170
+ if (row.activation_generation !== 0 ||
171
+ row.active_epoch_id !== null ||
172
+ row.last_epoch_id !== null ||
173
+ authoritativeActiveCount !== 0) {
174
+ throw unavailable();
175
+ }
176
+ return 'bypass';
177
+ }
178
+ if (row.activation_state === 'rolled_back') {
179
+ if (row.activation_generation < 1 ||
180
+ row.active_epoch_id !== null ||
181
+ row.last_epoch_id === null ||
182
+ row.activation_contract_version !== PRODUCTION_APP_ADMISSION_CONTRACT_VERSION ||
183
+ row.last_epoch_purpose !== 'authoritative' ||
184
+ row.last_epoch_state !== 'retired' ||
185
+ row.last_epoch_contract_version !== PRODUCTION_APP_ADMISSION_CONTRACT_VERSION ||
186
+ row.last_epoch_release_sha !== row.activation_release_sha ||
187
+ !sameInstant(row.last_epoch_activated_at, row.activation_activated_at) ||
188
+ authoritativeActiveCount !== 0) {
189
+ throw unavailable();
190
+ }
191
+ return 'bypass';
192
+ }
193
+ if (row.activation_state !== 'active' ||
194
+ row.activation_generation < 1 ||
195
+ row.active_epoch_id === null ||
196
+ row.active_epoch_id !== row.last_epoch_id ||
197
+ row.activation_contract_version !== PRODUCTION_APP_ADMISSION_CONTRACT_VERSION ||
198
+ row.active_epoch_purpose !== 'authoritative' ||
199
+ row.active_epoch_state !== 'active' ||
200
+ row.active_epoch_contract_version !== PRODUCTION_APP_ADMISSION_CONTRACT_VERSION ||
201
+ row.active_epoch_release_sha !== row.activation_release_sha ||
202
+ !sameInstant(row.active_epoch_activated_at, row.activation_activated_at) ||
203
+ row.active_epoch_reconciliation_failed_at !== null ||
204
+ authoritativeActiveCount !== 1) {
205
+ throw unavailable();
206
+ }
207
+ return 'enforce';
208
+ }
209
+ function validateBillingResolution(row) {
210
+ const profileEffectiveFrom = persistedInstant(row.profile_effective_from);
211
+ const cohortSealedAt = persistedInstant(row.cohort_sealed_at);
212
+ const validLegacyProfile = row.mode === 'legacy_internal_exempt' &&
213
+ row.profile_source === 'legacy_cohort_seal' &&
214
+ profileEffectiveFrom === cohortSealedAt;
215
+ const validEnforcedProfile = row.mode === 'enforced' &&
216
+ row.profile_source === 'post_seal_account' &&
217
+ profileEffectiveFrom >= cohortSealedAt;
218
+ if (row.account_state !== 'active' ||
219
+ row.profile_cohort_seal_id !== row.cohort_seal_id ||
220
+ (!validLegacyProfile && !validEnforcedProfile) ||
221
+ row.snapshot_verification_status !== 'verified' ||
222
+ !Number.isSafeInteger(row.snapshot_version) ||
223
+ row.snapshot_version < 1) {
224
+ throw unavailable();
225
+ }
226
+ const effectiveFrom = persistedInstant(row.snapshot_effective_from);
227
+ const monthlyUsageAnchor = persistedInstant(row.snapshot_monthly_usage_anchor);
228
+ const expectedChecksum = billingContentChecksum({
229
+ billingAccountId: row.billing_account_id,
230
+ version: row.snapshot_version,
231
+ planVersionId: row.snapshot_plan_version_id,
232
+ effectiveFrom,
233
+ monthlyUsageAnchor,
234
+ entitlements: row.entitlements,
235
+ });
236
+ if (row.snapshot_content_checksum !== expectedChecksum)
237
+ throw unavailable();
238
+ if (row.mode === 'enforced') {
239
+ try {
240
+ parseBillingCommercialFreeV1Entitlements(row.entitlements);
241
+ }
242
+ catch {
243
+ throw unavailable();
244
+ }
245
+ }
246
+ }
247
+ function sameInstant(left, right) {
248
+ if (left === null || right === null)
249
+ return false;
250
+ try {
251
+ return persistedInstant(left) === persistedInstant(right);
252
+ }
253
+ catch {
254
+ return false;
255
+ }
256
+ }
257
+ function persistedInstant(value) {
258
+ const date = value instanceof Date ? value : new Date(value);
259
+ if (!Number.isFinite(date.getTime()))
260
+ throw unavailable();
261
+ return date.toISOString();
262
+ }
263
+ function persistedCount(value) {
264
+ const parsed = value === undefined ? Number.NaN : Number(value);
265
+ if (!Number.isSafeInteger(parsed) || parsed < 0)
266
+ throw unavailable();
267
+ return parsed;
268
+ }
269
+ function unavailable() {
270
+ return new BillingProductionAppAdmissionError('billing_enforcement_unavailable');
271
+ }
272
+ //# sourceMappingURL=postgres-production-app-admission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-production-app-admission.js","sourceRoot":"","sources":["../../src/billing/postgres-production-app-admission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wCAAwC,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,6CAA6C,CAAC;AAEpG,MAAM,yCAAyC,GAAG,CAAC,CAAC;AAMpD,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAClD,IAAI,CAAyC;IAEtD,YAAY,IAA4C;QACtD,KAAK,CACH,IAAI,KAAK,+BAA+B;YACtC,CAAC,CAAC,kDAAkD;YACpD,CAAC,CAAC,gDAAgD,CACrD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oCAAoC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAwDD,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAAC,MAAkB;IAC9E,MAAM,MAAM,CAAC,KAAK,CAAC,8DAA8D,EAAE;QACjF,sCAAsC;KACvC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,MAAkB,EAClB,KAAqD;IAErD,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACvD,IAAI,aAAmC,CAAC;IACxC,IAAI,CAAC;QACH,aAAa,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,kCAAkC,EAAE,CAAC;YACxD,MAAM,OAAO,GAAG,MAAM,+BAA+B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACrE,IAAI,OAAO,CAAC,IAAI,KAAK,Q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yB;IAC/C,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;QAAE,MAAM,WAAW,EAAE,CAAC;IACrE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,IAAI,kCAAkC,CAAC,iCAAiC,CAAC,CAAC;AACnF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-schema.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAO/B,2FAA2F;AAC3F,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAoSnE"}
1
+ {"version":3,"file":"postgres-schema.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAQ/B,2FAA2F;AAC3F,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAqSnE"}
@@ -1,4 +1,5 @@
1
1
  import { FREE_PLAN_VERSION } from './model.js';
2
+ import { ensureBillingEnforcementActivationSchema } from './postgres-enforcement-activation-schema.js';
2
3
  import { ensureBillingEnforcementProfileSchema } from './postgres-enforcement-profile-schema.js';
3
4
  import { ensureAuthoritativeMeterSchema } from './postgres-meter-schema.js';
4
5
  import { ensureBillingMeterWriterHealthSchema } from './postgres-meter-writer-health-schema.js';
@@ -202,6 +203,7 @@ export async function ensureBillingSchema(pool) {
202
203
  await ensureAuthoritativeMeterSchema(pool);
203
204
  await ensureBillingMeterWriterHealthSchema(pool);
204
205
  await ensureBillingEnforcementProfileSchema(pool);
206
+ await ensureBillingEnforcementActivationSchema(pool);
205
207
  await pool.query(`
206
208
  CREATE TABLE IF NOT EXISTS billing_legacy_migration_preparations (
207
209
  id text PRIMARY KEY,
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-schema.js","sourceRoot":"","sources":["../../src/billing/postgres-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AACjG,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,oCAAoC,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,EAAuB,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAU;IAClD,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;GAWhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;GAOhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;GAOhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;GAUhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;GAGhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;GAGhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;GAqBhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;GAkBhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;GAOhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;GAWhB,CAAC,CAAC;IACH,MAAM,IAA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,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;GAGhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;GAWhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;GAShB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;GAShB,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,KAAK,CACd;;;iCAG6B,EAC7B;QACE,iBAAiB,CAAC,EAAE;QACpB,iBAAiB,CAAC,QAAQ;QAC1B,iBAAiB,CAAC,OAAO;QACzB,iBAAiB,CAAC,aAAa;QAC/B,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC;QAC9C,iBAAiB,CAAC,eAAe;QACjC,iBAAiB,CAAC,SAAS;KAC5B,CACF,CAAC;IACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAC/B,mDAAmD,EACnD,CAAC,iBAAiB,CAAC,EAAE,CAAC,CACvB,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,IACE,aAAa,KAAK,SAAS;QAC3B,aAAa,CAAC,eAAe,KAAK,iBAAiB,CAAC,eAAe,EACnE,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;AACH,CAAC"}
@@ -4,19 +4,37 @@ export declare const BillingPlanSummarySchema: z.ZodObject<{
4
4
  code: z.ZodString;
5
5
  version: z.ZodNumber;
6
6
  }, z.core.$strict>;
7
- export declare const BillingEnforcementStateSchema: z.ZodObject<{
7
+ export declare const BillingEnforcementStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
8
  state: z.ZodLiteral<"legacy_unchanged">;
9
- }, z.core.$strict>;
10
- export declare const BillingMeteringSummarySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ }, z.core.$strict>, z.ZodObject<{
10
+ state: z.ZodLiteral<"exempt">;
11
+ reason: z.ZodLiteral<"legacy_internal">;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ state: z.ZodLiteral<"inactive">;
14
+ reason: z.ZodEnum<{
15
+ not_activated: "not_activated";
16
+ rolled_back: "rolled_back";
17
+ }>;
18
+ }, z.core.$strict>, z.ZodObject<{
19
+ state: z.ZodLiteral<"active">;
20
+ mode: z.ZodLiteral<"authoritative">;
21
+ }, z.core.$strict>, z.ZodObject<{
22
+ state: z.ZodLiteral<"unavailable">;
23
+ }, z.core.$strict>], "state">;
24
+ export declare const BillingMeteringSummarySchema: z.ZodUnion<readonly [z.ZodObject<{
11
25
  state: z.ZodLiteral<"not_started">;
12
26
  }, z.core.$strict>, z.ZodObject<{
13
27
  state: z.ZodLiteral<"reporting">;
14
28
  mode: z.ZodLiteral<"shadow">;
15
29
  coverage: z.ZodLiteral<"partial">;
30
+ }, z.core.$strict>, z.ZodObject<{
31
+ state: z.ZodLiteral<"reporting">;
32
+ mode: z.ZodLiteral<"authoritative">;
33
+ coverage: z.ZodLiteral<"complete">;
16
34
  }, z.core.$strict>, z.ZodObject<{
17
35
  state: z.ZodLiteral<"unavailable">;
18
- }, z.core.$strict>], "state">;
19
- export declare const BillingAccountMeteringDetailSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
36
+ }, z.core.$strict>]>;
37
+ export declare const BillingAccountMeteringDetailSchema: z.ZodUnion<readonly [z.ZodObject<{
20
38
  state: z.ZodLiteral<"not_started">;
21
39
  usedMcpCalls: z.ZodNull;
22
40
  remainingMcpCalls: z.ZodNull;
@@ -30,6 +48,18 @@ export declare const BillingAccountMeteringDetailSchema: z.ZodDiscriminatedUnion
30
48
  observedSince: z.ZodString;
31
49
  windowStart: z.ZodString;
32
50
  windowEnd: z.ZodString;
51
+ }, z.core.$strict>, z.ZodObject<{
52
+ state: z.ZodLiteral<"reporting">;
53
+ mode: z.ZodLiteral<"authoritative">;
54
+ coverage: z.ZodLiteral<"complete">;
55
+ usedMcpCalls: z.ZodNumber;
56
+ includedUsedMcpCalls: z.ZodNumber;
57
+ overageUsedMcpCalls: z.ZodNumber;
58
+ remainingMcpCalls: z.ZodNumber;
59
+ countingSince: z.ZodString;
60
+ windowStart: z.ZodString;
61
+ windowEnd: z.ZodString;
62
+ resetAt: z.ZodString;
33
63
  }, z.core.$strict>, z.ZodObject<{
34
64
  remainingMcpCalls: z.ZodNull;
35
65
  state: z.ZodLiteral<"unavailable">;
@@ -43,8 +73,8 @@ export declare const BillingAccountMeteringDetailSchema: z.ZodDiscriminatedUnion
43
73
  observedSince: z.ZodNullable<z.ZodString>;
44
74
  windowStart: z.ZodNullable<z.ZodString>;
45
75
  windowEnd: z.ZodNullable<z.ZodString>;
46
- }, z.core.$strict>], "state">;
47
- export declare const BillingOrgMeteringDetailSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
76
+ }, z.core.$strict>]>;
77
+ export declare const BillingOrgMeteringDetailSchema: z.ZodUnion<readonly [z.ZodObject<{
48
78
  state: z.ZodLiteral<"not_started">;
49
79
  }, z.core.$strict>, z.ZodObject<{
50
80
  state: z.ZodLiteral<"reporting">;
@@ -54,6 +84,17 @@ export declare const BillingOrgMeteringDetailSchema: z.ZodDiscriminatedUnion<[z.
54
84
  observedSince: z.ZodString;
55
85
  windowStart: z.ZodString;
56
86
  windowEnd: z.ZodString;
87
+ }, z.core.$strict>, z.ZodObject<{
88
+ state: z.ZodLiteral<"reporting">;
89
+ mode: z.ZodLiteral<"authoritative">;
90
+ coverage: z.ZodLiteral<"complete">;
91
+ attributedMcpCalls: z.ZodNumber;
92
+ includedAttributedMcpCalls: z.ZodNumber;
93
+ overageAttributedMcpCalls: z.ZodNumber;
94
+ countingSince: z.ZodString;
95
+ windowStart: z.ZodString;
96
+ windowEnd: z.ZodString;
97
+ resetAt: z.ZodString;
57
98
  }, z.core.$strict>, z.ZodObject<{
58
99
  state: z.ZodLiteral<"unavailable">;
59
100
  reason: z.ZodEnum<{
@@ -66,7 +107,7 @@ export declare const BillingOrgMeteringDetailSchema: z.ZodDiscriminatedUnion<[z.
66
107
  observedSince: z.ZodNullable<z.ZodString>;
67
108
  windowStart: z.ZodNullable<z.ZodString>;
68
109
  windowEnd: z.ZodNullable<z.ZodString>;
69
- }, z.core.$strict>], "state">;
110
+ }, z.core.$strict>]>;
70
111
  export declare const BillingProductionAppsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
71
112
  state: z.ZodLiteral<"reporting">;
72
113
  active: z.ZodNumber;
@@ -96,18 +137,36 @@ export declare const BillingAccountSummarySchema: z.ZodObject<{
96
137
  version: z.ZodNumber;
97
138
  }, z.core.$strict>>;
98
139
  linkedOrganizationCount: z.ZodNumber;
99
- enforcement: z.ZodObject<{
140
+ enforcement: z.ZodDiscriminatedUnion<[z.ZodObject<{
100
141
  state: z.ZodLiteral<"legacy_unchanged">;
101
- }, z.core.$strict>;
102
- metering: z.ZodDiscriminatedUnion<[z.ZodObject<{
142
+ }, z.core.$strict>, z.ZodObject<{
143
+ state: z.ZodLiteral<"exempt">;
144
+ reason: z.ZodLiteral<"legacy_internal">;
145
+ }, z.core.$strict>, z.ZodObject<{
146
+ state: z.ZodLiteral<"inactive">;
147
+ reason: z.ZodEnum<{
148
+ not_activated: "not_activated";
149
+ rolled_back: "rolled_back";
150
+ }>;
151
+ }, z.core.$strict>, z.ZodObject<{
152
+ state: z.ZodLiteral<"active">;
153
+ mode: z.ZodLiteral<"authoritative">;
154
+ }, z.core.$strict>, z.ZodObject<{
155
+ state: z.ZodLiteral<"unavailable">;
156
+ }, z.core.$strict>], "state">;
157
+ metering: z.ZodUnion<readonly [z.ZodObject<{
103
158
  state: z.ZodLiteral<"not_started">;
104
159
  }, z.core.$strict>, z.ZodObject<{
105
160
  state: z.ZodLiteral<"reporting">;
106
161
  mode: z.ZodLiteral<"shadow">;
107
162
  coverage: z.ZodLiteral<"partial">;
163
+ }, z.core.$strict>, z.ZodObject<{
164
+ state: z.ZodLiteral<"reporting">;
165
+ mode: z.ZodLiteral<"authoritative">;
166
+ coverage: z.ZodLiteral<"complete">;
108
167
  }, z.core.$strict>, z.ZodObject<{
109
168
  state: z.ZodLiteral<"unavailable">;
110
- }, z.core.$strict>], "state">;
169
+ }, z.core.$strict>]>;
111
170
  }, z.core.$strict>;
112
171
  export declare const BillingAccountsListResponseSchema: z.ZodObject<{
113
172
  ok: z.ZodLiteral<true>;
@@ -132,18 +191,36 @@ export declare const BillingAccountsListResponseSchema: z.ZodObject<{
132
191
  version: z.ZodNumber;
133
192
  }, z.core.$strict>>;
134
193
  linkedOrganizationCount: z.ZodNumber;
135
- enforcement: z.ZodObject<{
194
+ enforcement: z.ZodDiscriminatedUnion<[z.ZodObject<{
136
195
  state: z.ZodLiteral<"legacy_unchanged">;
137
- }, z.core.$strict>;
138
- metering: z.ZodDiscriminatedUnion<[z.ZodObject<{
196
+ }, z.core.$strict>, z.ZodObject<{
197
+ state: z.ZodLiteral<"exempt">;
198
+ reason: z.ZodLiteral<"legacy_internal">;
199
+ }, z.core.$strict>, z.ZodObject<{
200
+ state: z.ZodLiteral<"inactive">;
201
+ reason: z.ZodEnum<{
202
+ not_activated: "not_activated";
203
+ rolled_back: "rolled_back";
204
+ }>;
205
+ }, z.core.$strict>, z.ZodObject<{
206
+ state: z.ZodLiteral<"active">;
207
+ mode: z.ZodLiteral<"authoritative">;
208
+ }, z.core.$strict>, z.ZodObject<{
209
+ state: z.ZodLiteral<"unavailable">;
210
+ }, z.core.$strict>], "state">;
211
+ metering: z.ZodUnion<readonly [z.ZodObject<{
139
212
  state: z.ZodLiteral<"not_started">;
140
213
  }, z.core.$strict>, z.ZodObject<{
141
214
  state: z.ZodLiteral<"reporting">;
142
215
  mode: z.ZodLiteral<"shadow">;
143
216
  coverage: z.ZodLiteral<"partial">;
217
+ }, z.core.$strict>, z.ZodObject<{
218
+ state: z.ZodLiteral<"reporting">;
219
+ mode: z.ZodLiteral<"authoritative">;
220
+ coverage: z.ZodLiteral<"complete">;
144
221
  }, z.core.$strict>, z.ZodObject<{
145
222
  state: z.ZodLiteral<"unavailable">;
146
- }, z.core.$strict>], "state">;
223
+ }, z.core.$strict>]>;
147
224
  }, z.core.$strict>>;
148
225
  }, z.core.$strict>;
149
226
  }, z.core.$strict>;
@@ -228,18 +305,36 @@ export declare const BillingAccountResponseSchema: z.ZodObject<{
228
305
  version: z.ZodNumber;
229
306
  }, z.core.$strict>>;
230
307
  linkedOrganizationCount: z.ZodNumber;
231
- enforcement: z.ZodObject<{
308
+ enforcement: z.ZodDiscriminatedUnion<[z.ZodObject<{
232
309
  state: z.ZodLiteral<"legacy_unchanged">;
233
- }, z.core.$strict>;
234
- metering: z.ZodDiscriminatedUnion<[z.ZodObject<{
310
+ }, z.core.$strict>, z.ZodObject<{
311
+ state: z.ZodLiteral<"exempt">;
312
+ reason: z.ZodLiteral<"legacy_internal">;
313
+ }, z.core.$strict>, z.ZodObject<{
314
+ state: z.ZodLiteral<"inactive">;
315
+ reason: z.ZodEnum<{
316
+ not_activated: "not_activated";
317
+ rolled_back: "rolled_back";
318
+ }>;
319
+ }, z.core.$strict>, z.ZodObject<{
320
+ state: z.ZodLiteral<"active">;
321
+ mode: z.ZodLiteral<"authoritative">;
322
+ }, z.core.$strict>, z.ZodObject<{
323
+ state: z.ZodLiteral<"unavailable">;
324
+ }, z.core.$strict>], "state">;
325
+ metering: z.ZodUnion<readonly [z.ZodObject<{
235
326
  state: z.ZodLiteral<"not_started">;
236
327
  }, z.core.$strict>, z.ZodObject<{
237
328
  state: z.ZodLiteral<"reporting">;
238
329
  mode: z.ZodLiteral<"shadow">;
239
330
  coverage: z.ZodLiteral<"partial">;
331
+ }, z.core.$strict>, z.ZodObject<{
332
+ state: z.ZodLiteral<"reporting">;
333
+ mode: z.ZodLiteral<"authoritative">;
334
+ coverage: z.ZodLiteral<"complete">;
240
335
  }, z.core.$strict>, z.ZodObject<{
241
336
  state: z.ZodLiteral<"unavailable">;
242
- }, z.core.$strict>], "state">;
337
+ }, z.core.$strict>]>;
243
338
  }, z.core.$strict>;
244
339
  entitlement: z.ZodNullable<z.ZodObject<{
245
340
  snapshotId: z.ZodString;
@@ -274,10 +369,24 @@ export declare const BillingAccountResponseSchema: z.ZodObject<{
274
369
  relationship: z.ZodLiteral<"external">;
275
370
  }, z.core.$strict>], "relationship">;
276
371
  }, z.core.$strict>>;
277
- enforcement: z.ZodObject<{
372
+ enforcement: z.ZodDiscriminatedUnion<[z.ZodObject<{
278
373
  state: z.ZodLiteral<"legacy_unchanged">;
279
- }, z.core.$strict>;
280
- metering: z.ZodDiscriminatedUnion<[z.ZodObject<{
374
+ }, z.core.$strict>, z.ZodObject<{
375
+ state: z.ZodLiteral<"exempt">;
376
+ reason: z.ZodLiteral<"legacy_internal">;
377
+ }, z.core.$strict>, z.ZodObject<{
378
+ state: z.ZodLiteral<"inactive">;
379
+ reason: z.ZodEnum<{
380
+ not_activated: "not_activated";
381
+ rolled_back: "rolled_back";
382
+ }>;
383
+ }, z.core.$strict>, z.ZodObject<{
384
+ state: z.ZodLiteral<"active">;
385
+ mode: z.ZodLiteral<"authoritative">;
386
+ }, z.core.$strict>, z.ZodObject<{
387
+ state: z.ZodLiteral<"unavailable">;
388
+ }, z.core.$strict>], "state">;
389
+ metering: z.ZodUnion<readonly [z.ZodObject<{
281
390
  state: z.ZodLiteral<"not_started">;
282
391
  usedMcpCalls: z.ZodNull;
283
392
  remainingMcpCalls: z.ZodNull;
@@ -291,6 +400,18 @@ export declare const BillingAccountResponseSchema: z.ZodObject<{
291
400
  observedSince: z.ZodString;
292
401
  windowStart: z.ZodString;
293
402
  windowEnd: z.ZodString;
403
+ }, z.core.$strict>, z.ZodObject<{
404
+ state: z.ZodLiteral<"reporting">;
405
+ mode: z.ZodLiteral<"authoritative">;
406
+ coverage: z.ZodLiteral<"complete">;
407
+ usedMcpCalls: z.ZodNumber;
408
+ includedUsedMcpCalls: z.ZodNumber;
409
+ overageUsedMcpCalls: z.ZodNumber;
410
+ remainingMcpCalls: z.ZodNumber;
411
+ countingSince: z.ZodString;
412
+ windowStart: z.ZodString;
413
+ windowEnd: z.ZodString;
414
+ resetAt: z.ZodString;
294
415
  }, z.core.$strict>, z.ZodObject<{
295
416
  remainingMcpCalls: z.ZodNull;
296
417
  state: z.ZodLiteral<"unavailable">;
@@ -304,7 +425,7 @@ export declare const BillingAccountResponseSchema: z.ZodObject<{
304
425
  observedSince: z.ZodNullable<z.ZodString>;
305
426
  windowStart: z.ZodNullable<z.ZodString>;
306
427
  windowEnd: z.ZodNullable<z.ZodString>;
307
- }, z.core.$strict>], "state">;
428
+ }, z.core.$strict>]>;
308
429
  productionApps: z.ZodDiscriminatedUnion<[z.ZodObject<{
309
430
  state: z.ZodLiteral<"reporting">;
310
431
  active: z.ZodNumber;
@@ -344,10 +465,24 @@ export declare const OrgBillingResponseSchema: z.ZodObject<{
344
465
  effectiveFrom: z.ZodString;
345
466
  }, z.core.$strict>;
346
467
  entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodString, z.ZodNull]>>;
347
- enforcement: z.ZodObject<{
468
+ enforcement: z.ZodDiscriminatedUnion<[z.ZodObject<{
348
469
  state: z.ZodLiteral<"legacy_unchanged">;
349
- }, z.core.$strict>;
350
- metering: z.ZodDiscriminatedUnion<[z.ZodObject<{
470
+ }, z.core.$strict>, z.ZodObject<{
471
+ state: z.ZodLiteral<"exempt">;
472
+ reason: z.ZodLiteral<"legacy_internal">;
473
+ }, z.core.$strict>, z.ZodObject<{
474
+ state: z.ZodLiteral<"inactive">;
475
+ reason: z.ZodEnum<{
476
+ not_activated: "not_activated";
477
+ rolled_back: "rolled_back";
478
+ }>;
479
+ }, z.core.$strict>, z.ZodObject<{
480
+ state: z.ZodLiteral<"active">;
481
+ mode: z.ZodLiteral<"authoritative">;
482
+ }, z.core.$strict>, z.ZodObject<{
483
+ state: z.ZodLiteral<"unavailable">;
484
+ }, z.core.$strict>], "state">;
485
+ metering: z.ZodUnion<readonly [z.ZodObject<{
351
486
  state: z.ZodLiteral<"not_started">;
352
487
  }, z.core.$strict>, z.ZodObject<{
353
488
  state: z.ZodLiteral<"reporting">;
@@ -357,6 +492,17 @@ export declare const OrgBillingResponseSchema: z.ZodObject<{
357
492
  observedSince: z.ZodString;
358
493
  windowStart: z.ZodString;
359
494
  windowEnd: z.ZodString;
495
+ }, z.core.$strict>, z.ZodObject<{
496
+ state: z.ZodLiteral<"reporting">;
497
+ mode: z.ZodLiteral<"authoritative">;
498
+ coverage: z.ZodLiteral<"complete">;
499
+ attributedMcpCalls: z.ZodNumber;
500
+ includedAttributedMcpCalls: z.ZodNumber;
501
+ overageAttributedMcpCalls: z.ZodNumber;
502
+ countingSince: z.ZodString;
503
+ windowStart: z.ZodString;
504
+ windowEnd: z.ZodString;
505
+ resetAt: z.ZodString;
360
506
  }, z.core.$strict>, z.ZodObject<{
361
507
  state: z.ZodLiteral<"unavailable">;
362
508
  reason: z.ZodEnum<{
@@ -369,7 +515,7 @@ export declare const OrgBillingResponseSchema: z.ZodObject<{
369
515
  observedSince: z.ZodNullable<z.ZodString>;
370
516
  windowStart: z.ZodNullable<z.ZodString>;
371
517
  windowEnd: z.ZodNullable<z.ZodString>;
372
- }, z.core.$strict>], "state">;
518
+ }, z.core.$strict>]>;
373
519
  productionApps: z.ZodDiscriminatedUnion<[z.ZodObject<{
374
520
  state: z.ZodLiteral<"reporting">;
375
521
  active: z.ZodNumber;
@@ -1 +1 @@
1
- {"version":3,"file":"read-contract.d.ts","sourceRoot":"","sources":["../../src/billing/read-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,yBAAyB,oGAAsD,CAAC;AAE7F,eAAO,MAAM,wBAAwB;;;kBAK1B,CAAC;AAEZ,eAAO,MAAM,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