@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.
- package/dist/cli.js +6 -6
- package/dist/cli.js.map +1 -1
- package/dist/commands/archive-ops.js +1 -1
- package/dist/commands/archive-ops.js.map +1 -1
- package/dist/commands/auth-metadata-readiness.d.ts +8 -0
- package/dist/commands/auth-metadata-readiness.d.ts.map +1 -0
- package/dist/commands/auth-metadata-readiness.js +164 -0
- package/dist/commands/auth-metadata-readiness.js.map +1 -0
- package/dist/commands/auth-ops.d.ts +3 -0
- package/dist/commands/auth-ops.d.ts.map +1 -1
- package/dist/commands/auth-ops.js +37 -82
- package/dist/commands/auth-ops.js.map +1 -1
- package/dist/commands/author-loop.d.ts +7 -3
- package/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +33 -62
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/billing-admission-output.d.ts +16 -0
- package/dist/commands/billing-admission-output.d.ts.map +1 -0
- package/dist/commands/billing-admission-output.js +40 -0
- package/dist/commands/billing-admission-output.js.map +1 -0
- package/dist/commands/billing-enforcement-activation-args.d.ts +40 -0
- package/dist/commands/billing-enforcement-activation-args.d.ts.map +1 -0
- package/dist/commands/billing-enforcement-activation-args.js +125 -0
- package/dist/commands/billing-enforcement-activation-args.js.map +1 -0
- package/dist/commands/billing-enforcement-activation-files.d.ts +11 -0
- package/dist/commands/billing-enforcement-activation-files.d.ts.map +1 -0
- package/dist/commands/billing-enforcement-activation-files.js +54 -0
- package/dist/commands/billing-enforcement-activation-files.js.map +1 -0
- package/dist/commands/billing-enforcement-activation-ops.d.ts +2 -0
- package/dist/commands/billing-enforcement-activation-ops.d.ts.map +1 -0
- package/dist/commands/billing-enforcement-activation-ops.js +283 -0
- package/dist/commands/billing-enforcement-activation-ops.js.map +1 -0
- package/dist/commands/billing-enforcement-ops.d.ts.map +1 -1
- package/dist/commands/billing-enforcement-ops.js +5 -1
- package/dist/commands/billing-enforcement-ops.js.map +1 -1
- package/dist/commands/billing-read-ops.d.ts.map +1 -1
- package/dist/commands/billing-read-ops.js +15 -3
- package/dist/commands/billing-read-ops.js.map +1 -1
- package/dist/commands/billing-read-view.d.ts +40 -1
- package/dist/commands/billing-read-view.d.ts.map +1 -1
- package/dist/commands/billing-read-view.js +50 -0
- package/dist/commands/billing-read-view.js.map +1 -1
- package/dist/commands/catalog-data-resources.d.ts.map +1 -1
- package/dist/commands/catalog-data-resources.js +4 -3
- package/dist/commands/catalog-data-resources.js.map +1 -1
- package/dist/commands/config-values.d.ts.map +1 -1
- package/dist/commands/config-values.js +18 -2
- package/dist/commands/config-values.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts +1 -0
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +5 -0
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/commands/deploy-status-ops.js +1 -1
- package/dist/commands/deploy-status-ops.js.map +1 -1
- package/dist/commands/devtools.d.ts +1 -1
- package/dist/commands/devtools.d.ts.map +1 -1
- package/dist/commands/devtools.js +23 -4
- package/dist/commands/devtools.js.map +1 -1
- package/dist/commands/local-readiness.d.ts +6 -0
- package/dist/commands/local-readiness.d.ts.map +1 -0
- package/dist/commands/local-readiness.js +48 -0
- package/dist/commands/local-readiness.js.map +1 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +13 -0
- package/dist/commands/shared.js.map +1 -1
- package/dist/deploy.d.ts +1 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +1 -0
- package/dist/deploy.js.map +1 -1
- package/dist/local-target.d.ts +16 -0
- package/dist/local-target.d.ts.map +1 -0
- package/dist/local-target.js +35 -0
- package/dist/local-target.js.map +1 -0
- package/node_modules/@noodle-borg/agent-kit/dist/skill-connect-refs.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-connect-refs.js +7 -8
- package/node_modules/@noodle-borg/agent-kit/dist/skill-connect-refs.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-operations-refs.js +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-operations-refs.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/auth/dist/discovery.d.ts +11 -3
- package/node_modules/@noodle-borg/auth/dist/discovery.d.ts.map +1 -1
- package/node_modules/@noodle-borg/auth/dist/discovery.js +42 -7
- package/node_modules/@noodle-borg/auth/dist/discovery.js.map +1 -1
- package/node_modules/@noodle-borg/auth/dist/index.d.ts +1 -1
- package/node_modules/@noodle-borg/auth/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/auth/dist/index.js +1 -1
- package/node_modules/@noodle-borg/auth/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js +2 -0
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/@noodle-borg/runtime/dist/result.d.ts +3 -1
- package/node_modules/@noodle-borg/runtime/dist/result.d.ts.map +1 -1
- package/node_modules/@noodle-borg/runtime/dist/result.js.map +1 -1
- package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.d.ts +10 -0
- package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.d.ts.map +1 -1
- package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.js +26 -1
- package/node_modules/@noodle-borg/runtime/dist/tool-dispatch.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.d.ts +46 -0
- package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.js +111 -0
- package/node_modules/@noodle-borg/service/dist/billing/authoritative-admission.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.d.ts +80 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.js +2 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-enforcement-projection.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.d.ts +18 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.js +51 -0
- package/node_modules/@noodle-borg/service/dist/billing/commercial-entitlements.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.d.ts +34 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.js +125 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation-support.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts +265 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.js +340 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-activation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-profile.d.ts +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts +15 -3
- package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/integration.js +56 -3
- package/node_modules/@noodle-borg/service/dist/billing/integration.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.d.ts +20 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.js +121 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-authoritative-authority.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.d.ts +10 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.js +33 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-apps.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.d.ts +25 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.js +248 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-counters.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.d.ts +17 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.js +278 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-projection.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.d.ts +7 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.js +63 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-commercial-enforcement-transaction.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.d.ts +6 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.js +89 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-locks.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.d.ts +13 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.js +193 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-preflight.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.js +119 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.d.ts +65 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.js +159 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation-support.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.d.ts +31 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.js +247 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-activation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js +40 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js +45 -22
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.d.ts +33 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.js +158 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.d.ts +18 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.js +326 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts +2 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js +10 -5
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js +3 -3
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts +3 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js +8 -2
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js +4 -4
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts +2 -2
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-store.js +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js +27 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.d.ts +33 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.js +272 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-production-app-admission.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.js +2 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts +174 -28
- package/node_modules/@noodle-borg/service/dist/billing/read-contract.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/read-contract.js +51 -6
- package/node_modules/@noodle-borg/service/dist/billing/read-contract.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing-public.d.ts +3 -0
- package/node_modules/@noodle-borg/service/dist/billing-public.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing-public.js +3 -0
- package/node_modules/@noodle-borg/service/dist/billing-public.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/options.d.ts +14 -2
- package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/persistence-options.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/persistence-options.js +9 -0
- package/node_modules/@noodle-borg/service/dist/persistence-options.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry.d.ts +2 -0
- package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry.js +10 -0
- package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/archive.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/archive.js +18 -1
- package/node_modules/@noodle-borg/service/dist/routes/archive.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.d.ts +15 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.js +197 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-activation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.d.ts +15 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.js +33 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-production-app-response.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-read.d.ts +2 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-read.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/billing-read.js +203 -41
- package/node_modules/@noodle-borg/service/dist/routes/billing-read.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.js +25 -0
- package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js +9 -1
- package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js +19 -1
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/rollback.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/rollback.js +19 -1
- package/node_modules/@noodle-borg/service/dist/routes/rollback.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.js +41 -1
- package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.js +6 -3
- package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js +3 -3
- package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts +5 -7
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js +71 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js +7 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js +5 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.js +29 -34
- package/node_modules/@noodle-borg/service/dist/store/postgres.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { BillingAuthoritativeAdmissionUnavailableError, BillingAuthoritativeIdempotencyConflictError, } from './authoritative-admission.js';
|
|
3
|
+
import { BILLING_METER_AGGREGATE_RETENTION_MONTHS, BILLING_METER_EXACT_KEY_TOMBSTONE_RETENTION_DAYS, BILLING_METER_RECEIPT_RETENTION_DAYS, } from './meter-readiness.js';
|
|
4
|
+
export async function lockAuthoritativeDedupeIdentity(client, epochId, input) {
|
|
5
|
+
const value = input.identity.highConfidenceKeyHash;
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return;
|
|
8
|
+
await client.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [
|
|
9
|
+
`billing-authoritative-dedupe:v1:${epochId}:exact:${value}`,
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
export async function findAuthoritativeDuplicate(client, input) {
|
|
13
|
+
const exactKey = input.input.identity.highConfidenceKeyHash;
|
|
14
|
+
if (exactKey !== undefined) {
|
|
15
|
+
const { rows } = await client.query(`SELECT event_id, classification, semantic_fingerprint, window_end
|
|
16
|
+
FROM billing_meter_exact_key_tombstones
|
|
17
|
+
WHERE epoch_id = $1 AND key_hash = decode($2, 'hex')`, [input.epochId, exactKey]);
|
|
18
|
+
const prior = rows[0];
|
|
19
|
+
if (prior === undefined)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (!prior.semantic_fingerprint.equals(Buffer.from(input.input.identity.semanticFingerprint, 'hex'))) {
|
|
22
|
+
throw new BillingAuthoritativeIdempotencyConflictError();
|
|
23
|
+
}
|
|
24
|
+
return duplicateResult(prior);
|
|
25
|
+
}
|
|
26
|
+
// Sessionless/public invocations cannot be partitioned reliably across people behind the same client.
|
|
27
|
+
// Their bounded fingerprint remains useful receipt metadata, but it must never suppress execution.
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function duplicateResult(row) {
|
|
31
|
+
if (row.classification !== 'included' && row.classification !== 'overage')
|
|
32
|
+
throw unavailable();
|
|
33
|
+
return { classification: row.classification, resetAt: toIso(row.window_end) };
|
|
34
|
+
}
|
|
35
|
+
export async function readAuthoritativeIncludedCalls(client, input) {
|
|
36
|
+
const { rows } = await client.query(`SELECT included_calls::text, window_end
|
|
37
|
+
FROM billing_meter_account_windows
|
|
38
|
+
WHERE epoch_id = $1 AND billing_account_id = $2 AND window_start = $3
|
|
39
|
+
FOR UPDATE`, [input.epochId, input.billingAccountId, input.windowStart]);
|
|
40
|
+
const row = rows[0];
|
|
41
|
+
if (row === undefined)
|
|
42
|
+
return 0;
|
|
43
|
+
if (toIso(row.window_end) !== input.windowEnd)
|
|
44
|
+
throw unavailable();
|
|
45
|
+
return persistedCount(row.included_calls);
|
|
46
|
+
}
|
|
47
|
+
export async function recordAuthoritativeAdmission(client, input) {
|
|
48
|
+
const eventId = `bmae_${randomUUID()}`;
|
|
49
|
+
await client.query(`INSERT INTO billing_meter_usage_events
|
|
50
|
+
(event_id, epoch_id, mode, high_confidence_key_hash, fallback_fingerprint,
|
|
51
|
+
semantic_fingerprint, classification, billing_account_id, org_slug, app_slug,
|
|
52
|
+
environment, deployment_id, link_version, snapshot_id, snapshot_version, admitted_at,
|
|
53
|
+
window_start, window_end, recorded_at, retention_until)
|
|
54
|
+
VALUES
|
|
55
|
+
($1, $2, 'authoritative', decode($3, 'hex'), decode($4, 'hex'), decode($5, 'hex'),
|
|
56
|
+
$6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18,
|
|
57
|
+
$17::timestamptz + interval '${BILLING_METER_RECEIPT_RETENTION_DAYS} days')`, [
|
|
58
|
+
eventId,
|
|
59
|
+
input.epochId,
|
|
60
|
+
input.input.identity.highConfidenceKeyHash ?? null,
|
|
61
|
+
input.input.identity.fallbackFingerprint,
|
|
62
|
+
input.input.identity.semanticFingerprint,
|
|
63
|
+
input.classification,
|
|
64
|
+
input.attribution.billing_account_id,
|
|
65
|
+
input.input.org,
|
|
66
|
+
input.input.app,
|
|
67
|
+
input.input.environment,
|
|
68
|
+
input.input.deploymentId,
|
|
69
|
+
input.attribution.link_version,
|
|
70
|
+
input.attribution.snapshot_id,
|
|
71
|
+
input.attribution.snapshot_version,
|
|
72
|
+
input.recordedAt,
|
|
73
|
+
input.windowStart,
|
|
74
|
+
input.windowEnd,
|
|
75
|
+
input.recordedAt,
|
|
76
|
+
]);
|
|
77
|
+
if (input.input.identity.highConfidenceKeyHash !== undefined) {
|
|
78
|
+
await client.query(`INSERT INTO billing_meter_exact_key_tombstones
|
|
79
|
+
(epoch_id, key_hash, semantic_fingerprint, event_id, classification, window_end,
|
|
80
|
+
created_at, retention_until)
|
|
81
|
+
VALUES
|
|
82
|
+
($1, decode($2, 'hex'), decode($3, 'hex'), $4, $5, $6, $7,
|
|
83
|
+
$6::timestamptz + interval '${BILLING_METER_EXACT_KEY_TOMBSTONE_RETENTION_DAYS} days')`, [
|
|
84
|
+
input.epochId,
|
|
85
|
+
input.input.identity.highConfidenceKeyHash,
|
|
86
|
+
input.input.identity.semanticFingerprint,
|
|
87
|
+
eventId,
|
|
88
|
+
input.classification,
|
|
89
|
+
input.windowEnd,
|
|
90
|
+
input.recordedAt,
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
const increments = input.classification === 'included' ? [1, 0] : [0, 1];
|
|
94
|
+
const account = await upsertCounter(client, {
|
|
95
|
+
table: 'billing_meter_account_windows',
|
|
96
|
+
conflict: 'epoch_id, billing_account_id, window_start',
|
|
97
|
+
columns: ['epoch_id', 'billing_account_id', 'window_start'],
|
|
98
|
+
values: [input.epochId, input.attribution.billing_account_id, input.windowStart],
|
|
99
|
+
windowEnd: input.windowEnd,
|
|
100
|
+
increments,
|
|
101
|
+
admittedAt: input.recordedAt,
|
|
102
|
+
});
|
|
103
|
+
const organization = await upsertCounter(client, {
|
|
104
|
+
table: 'billing_meter_org_windows',
|
|
105
|
+
conflict: 'epoch_id, billing_account_id, org_slug, window_start',
|
|
106
|
+
columns: ['epoch_id', 'billing_account_id', 'org_slug', 'window_start'],
|
|
107
|
+
values: [
|
|
108
|
+
input.epochId,
|
|
109
|
+
input.attribution.billing_account_id,
|
|
110
|
+
input.input.org,
|
|
111
|
+
input.windowStart,
|
|
112
|
+
],
|
|
113
|
+
windowEnd: input.windowEnd,
|
|
114
|
+
increments,
|
|
115
|
+
admittedAt: input.recordedAt,
|
|
116
|
+
});
|
|
117
|
+
if (!account || !organization)
|
|
118
|
+
throw unavailable();
|
|
119
|
+
}
|
|
120
|
+
async function upsertCounter(client, input) {
|
|
121
|
+
const prefix = input.values.map((_, index) => `$${index + 1}`).join(', ');
|
|
122
|
+
const offset = input.values.length;
|
|
123
|
+
const result = await client.query(`INSERT INTO ${input.table}
|
|
124
|
+
(${input.columns.join(', ')}, window_end, included_calls, overage_calls, denied_calls,
|
|
125
|
+
first_admitted_at, last_admitted_at, updated_at, retention_until)
|
|
126
|
+
VALUES
|
|
127
|
+
(${prefix}, $${offset + 1}, $${offset + 2}, $${offset + 3}, 0,
|
|
128
|
+
$${offset + 4}, $${offset + 4}, $${offset + 4},
|
|
129
|
+
$${offset + 1}::timestamptz + interval '${BILLING_METER_AGGREGATE_RETENTION_MONTHS} months')
|
|
130
|
+
ON CONFLICT (${input.conflict}) DO UPDATE SET
|
|
131
|
+
included_calls = ${input.table}.included_calls + EXCLUDED.included_calls,
|
|
132
|
+
overage_calls = ${input.table}.overage_calls + EXCLUDED.overage_calls,
|
|
133
|
+
first_admitted_at = LEAST(
|
|
134
|
+
${input.table}.first_admitted_at,
|
|
135
|
+
EXCLUDED.first_admitted_at
|
|
136
|
+
),
|
|
137
|
+
last_admitted_at = GREATEST(${input.table}.last_admitted_at, EXCLUDED.last_admitted_at),
|
|
138
|
+
updated_at = GREATEST(${input.table}.updated_at, EXCLUDED.updated_at)
|
|
139
|
+
WHERE ${input.table}.window_end = EXCLUDED.window_end
|
|
140
|
+
RETURNING 1`, [...input.values, input.windowEnd, input.increments[0], input.increments[1], input.admittedAt]);
|
|
141
|
+
return result.rowCount === 1;
|
|
142
|
+
}
|
|
143
|
+
function persistedCount(value) {
|
|
144
|
+
const parsed = Number(value);
|
|
145
|
+
if (!Number.isSafeInteger(parsed) || parsed < 0)
|
|
146
|
+
throw unavailable();
|
|
147
|
+
return parsed;
|
|
148
|
+
}
|
|
149
|
+
function toIso(value) {
|
|
150
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
151
|
+
if (!Number.isFinite(date.getTime()))
|
|
152
|
+
throw unavailable();
|
|
153
|
+
return date.toISOString();
|
|
154
|
+
}
|
|
155
|
+
function unavailable() {
|
|
156
|
+
return new BillingAuthoritativeAdmissionUnavailableError();
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=postgres-meter-admission-ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-admission-ledger.js","sourceRoot":"","sources":["../../src/billing/postgres-meter-admission-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAEL,6CAA6C,EAC7C,4CAA4C,GAC7C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,wCAAwC,EACxC,gDAAgD,EAChD,oCAAoC,GACrC,MAAM,sBAAsB,CAAC;AAgB9B,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,MAAkB,EAClB,OAAe,EACf,KAAyC;IAEzC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACnD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO;IAChC,MAAM,MAAM,CAAC,KAAK,CAAC,uDAAuD,EAAE;QAC1E,mCAAmC,OAAO,UAAU,KAAK,EAAE;KAC5D,CAAC,CAAC;AACL,CAAC;AAED,MAAM,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AAC;IAC7B,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,KAAK,CAAC,KAAoB;IACjC,MAAM,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAAE,MAAM,WAAW,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,IAAI,6CAA6C,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Pool } from 'pg';
|
|
2
|
+
import { type BillingAuthoritativeAdmissionInput, type BillingAuthoritativeAdmissionResult, type BillingAuthoritativeAdmissionStore } from './authoritative-admission.js';
|
|
3
|
+
export interface PostgresBillingAuthoritativeAdmissionStoreOptions {
|
|
4
|
+
/** One-way key-generation marker; never the raw HMAC key. */
|
|
5
|
+
readonly keyGeneration: string;
|
|
6
|
+
readonly admissionContractVersion?: number;
|
|
7
|
+
/** Bounded test/operations override. Default: 1000ms. */
|
|
8
|
+
readonly lockTimeoutMs?: number;
|
|
9
|
+
/** Bounded test/operations override. Default: 2000ms. */
|
|
10
|
+
readonly statementTimeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
/** The one transactional authority for pooled monthly call admission. */
|
|
13
|
+
export declare class PostgresBillingAuthoritativeAdmissionStore implements BillingAuthoritativeAdmissionStore {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(pool: Pool, options: PostgresBillingAuthoritativeAdmissionStoreOptions);
|
|
16
|
+
admit(rawInput: BillingAuthoritativeAdmissionInput): Promise<BillingAuthoritativeAdmissionResult>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=postgres-meter-admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-admission.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-meter-admission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,IAAI,CAAC;AAE3C,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACxC,KAAK,kCAAkC,EAGxC,MAAM,8BAA8B,CAAC;AAsBtC,MAAM,WAAW,iDAAiD;IAChE,6DAA6D;IAC7D,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;AAmCD,yEAAyE;AACzE,qBAAa,0CACX,YAAW,kCAAkC;;gBAQjC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,iDAAiD;IAmB5E,KAAK,CACT,QAAQ,EAAE,kCAAkC,GAC3C,OAAO,CAAC,mCAAmC,CAAC;CAqIhD"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { DEPLOYMENT_ID_PATTERN, validateSlug } from '../store/validate.js';
|
|
2
|
+
import { BillingAuthoritativeAdmissionUnavailableError, BillingAuthoritativeIdempotencyConflictError, } from './authoritative-admission.js';
|
|
3
|
+
import { BillingCommercialEntitlementError, parseBillingCommercialFreeV1Entitlements, } from './commercial-entitlements.js';
|
|
4
|
+
import { BILLING_AUTHORITATIVE_ADMISSION_CONTRACT_VERSION } from './enforcement-activation.js';
|
|
5
|
+
import { billingContentChecksum } from './model.js';
|
|
6
|
+
import { BillingAuthoritativeAuthorityInconsistentError, readBillingAuthoritativeAuthorityTx, } from './postgres-authoritative-authority.js';
|
|
7
|
+
import { findAuthoritativeDuplicate, lockAuthoritativeDedupeIdentity, readAuthoritativeIncludedCalls, recordAuthoritativeAdmission, } from './postgres-meter-admission-ledger.js';
|
|
8
|
+
import { readBillingMeterTransactionTime } from './postgres-meter-clock.js';
|
|
9
|
+
import { BILLING_METER_VALIDATION_EPOCH_LIFECYCLE_LOCK_KEY } from './postgres-meter-epochs.js';
|
|
10
|
+
import { resolveUtcMonthlyUsageWindow } from './usage-window.js';
|
|
11
|
+
const DEFAULT_LOCK_TIMEOUT_MS = 1_000;
|
|
12
|
+
const DEFAULT_STATEMENT_TIMEOUT_MS = 2_000;
|
|
13
|
+
/** The one transactional authority for pooled monthly call admission. */
|
|
14
|
+
export class PostgresBillingAuthoritativeAdmissionStore {
|
|
15
|
+
#pool;
|
|
16
|
+
#keyGeneration;
|
|
17
|
+
#admissionContractVersion;
|
|
18
|
+
#lockTimeoutMs;
|
|
19
|
+
#statementTimeoutMs;
|
|
20
|
+
constructor(pool, options) {
|
|
21
|
+
this.#pool = pool;
|
|
22
|
+
this.#keyGeneration = validateFingerprint('billing meter key generation', options.keyGeneration);
|
|
23
|
+
this.#admissionContractVersion = validateAdmissionContractVersion(options.admissionContractVersion ?? BILLING_AUTHORITATIVE_ADMISSION_CONTRACT_VERSION);
|
|
24
|
+
this.#lockTimeoutMs = boundedTimeout('billing authoritative admission lock timeout', options.lockTimeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS);
|
|
25
|
+
this.#statementTimeoutMs = boundedTimeout('billing authoritative admission statement timeout', options.statementTimeoutMs ?? DEFAULT_STATEMENT_TIMEOUT_MS);
|
|
26
|
+
}
|
|
27
|
+
async admit(rawInput) {
|
|
28
|
+
const input = normalizeInput(rawInput);
|
|
29
|
+
const client = await this.#pool.connect();
|
|
30
|
+
try {
|
|
31
|
+
await client.query('BEGIN ISOLATION LEVEL READ COMMITTED');
|
|
32
|
+
await client.query(`SELECT set_config('lock_timeout', $1, true),
|
|
33
|
+
set_config('statement_timeout', $2, true)`, [`${this.#lockTimeoutMs}ms`, `${this.#statementTimeoutMs}ms`]);
|
|
34
|
+
await client.query('SELECT pg_advisory_xact_lock_shared(hashtextextended($1, 0))', [
|
|
35
|
+
BILLING_METER_VALIDATION_EPOCH_LIFECYCLE_LOCK_KEY,
|
|
36
|
+
]);
|
|
37
|
+
let authority;
|
|
38
|
+
try {
|
|
39
|
+
authority = await readBillingAuthoritativeAuthorityTx(client, {
|
|
40
|
+
keyGeneration: this.#keyGeneration,
|
|
41
|
+
admissionContractVersion: this.#admissionContractVersion,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error instanceof BillingAuthoritativeAuthorityInconsistentError &&
|
|
46
|
+
(await proveLegacyExemption(client, input.org))) {
|
|
47
|
+
await client.query('COMMIT');
|
|
48
|
+
return { outcome: 'bypass', reason: 'legacy_internal_exempt' };
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
if (authority.state === 'unconfigured') {
|
|
53
|
+
await client.query('COMMIT');
|
|
54
|
+
return { outcome: 'bypass', reason: 'cohort_unsealed' };
|
|
55
|
+
}
|
|
56
|
+
if (authority.state === 'inactive') {
|
|
57
|
+
await client.query('COMMIT');
|
|
58
|
+
return { outcome: 'bypass', reason: authority.reason };
|
|
59
|
+
}
|
|
60
|
+
const recordedAt = await readBillingMeterTransactionTime(client);
|
|
61
|
+
const initialAttribution = await readAttribution(client, input.org, false);
|
|
62
|
+
if (initialAttribution === undefined)
|
|
63
|
+
throw unavailable();
|
|
64
|
+
validateAttribution(initialAttribution);
|
|
65
|
+
const initialWindow = resolveUtcMonthlyUsageWindow(toIso(initialAttribution.monthly_usage_anchor), recordedAt);
|
|
66
|
+
if (initialAttribution.profile_mode === 'legacy_internal_exempt') {
|
|
67
|
+
const lockedExemption = await readAttribution(client, input.org, true);
|
|
68
|
+
if (lockedExemption === undefined ||
|
|
69
|
+
!validAttribution(lockedExemption) ||
|
|
70
|
+
!sameAttribution(initialAttribution, lockedExemption)) {
|
|
71
|
+
throw unavailable();
|
|
72
|
+
}
|
|
73
|
+
await client.query('COMMIT');
|
|
74
|
+
return { outcome: 'bypass', reason: 'legacy_internal_exempt' };
|
|
75
|
+
}
|
|
76
|
+
await lockAuthoritativeDedupeIdentity(client, authority.epochId, input);
|
|
77
|
+
await client.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [
|
|
78
|
+
accountWindowLockKey(authority.epochId, initialAttribution.billing_account_id, initialWindow.start),
|
|
79
|
+
]);
|
|
80
|
+
const attribution = await readAttribution(client, input.org, true);
|
|
81
|
+
if (attribution === undefined ||
|
|
82
|
+
!validAttribution(attribution) ||
|
|
83
|
+
!sameAttribution(initialAttribution, attribution)) {
|
|
84
|
+
throw unavailable();
|
|
85
|
+
}
|
|
86
|
+
if (attribution.profile_mode === 'legacy_internal_exempt') {
|
|
87
|
+
await client.query('COMMIT');
|
|
88
|
+
return { outcome: 'bypass', reason: 'legacy_internal_exempt' };
|
|
89
|
+
}
|
|
90
|
+
if (attribution.profile_mode !== 'enforced')
|
|
91
|
+
throw unavailable();
|
|
92
|
+
const entitlements = parseBillingCommercialFreeV1Entitlements(attribution.entitlements);
|
|
93
|
+
const duplicate = await findAuthoritativeDuplicate(client, {
|
|
94
|
+
epochId: authority.epochId,
|
|
95
|
+
input,
|
|
96
|
+
});
|
|
97
|
+
if (duplicate !== undefined) {
|
|
98
|
+
await client.query('COMMIT');
|
|
99
|
+
return {
|
|
100
|
+
outcome: 'admitted',
|
|
101
|
+
receiptOutcome: 'duplicate',
|
|
102
|
+
classification: duplicate.classification,
|
|
103
|
+
resetAt: duplicate.resetAt,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const includedCalls = await readAuthoritativeIncludedCalls(client, {
|
|
107
|
+
epochId: authority.epochId,
|
|
108
|
+
billingAccountId: attribution.billing_account_id,
|
|
109
|
+
windowStart: initialWindow.start,
|
|
110
|
+
windowEnd: initialWindow.end,
|
|
111
|
+
});
|
|
112
|
+
if (includedCalls >= entitlements.includedCalls && !entitlements.overageAllowed) {
|
|
113
|
+
await client.query('COMMIT');
|
|
114
|
+
return {
|
|
115
|
+
outcome: 'denied',
|
|
116
|
+
reason: 'billing_usage_limit_exceeded',
|
|
117
|
+
resetAt: initialWindow.end,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const classification = includedCalls < entitlements.includedCalls ? 'included' : 'overage';
|
|
121
|
+
await recordAuthoritativeAdmission(client, {
|
|
122
|
+
epochId: authority.epochId,
|
|
123
|
+
input,
|
|
124
|
+
attribution,
|
|
125
|
+
classification,
|
|
126
|
+
recordedAt,
|
|
127
|
+
windowStart: initialWindow.start,
|
|
128
|
+
windowEnd: initialWindow.end,
|
|
129
|
+
});
|
|
130
|
+
await client.query('COMMIT');
|
|
131
|
+
return {
|
|
132
|
+
outcome: 'admitted',
|
|
133
|
+
receiptOutcome: 'recorded',
|
|
134
|
+
classification,
|
|
135
|
+
resetAt: initialWindow.end,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
await rollbackQuietly(client);
|
|
140
|
+
throw translateAdmissionError(error);
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
client.release();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function proveLegacyExemption(client, org) {
|
|
148
|
+
const initial = await readAttribution(client, org, false);
|
|
149
|
+
if (initial === undefined)
|
|
150
|
+
return false;
|
|
151
|
+
validateAttribution(initial);
|
|
152
|
+
if (initial.profile_mode !== 'legacy_internal_exempt')
|
|
153
|
+
return false;
|
|
154
|
+
const locked = await readAttribution(client, org, true);
|
|
155
|
+
if (locked === undefined || !validAttribution(locked) || !sameAttribution(initial, locked)) {
|
|
156
|
+
throw unavailable();
|
|
157
|
+
}
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
async function readAttribution(client, org, lock) {
|
|
161
|
+
const { rows } = await client.query(`SELECT link.billing_account_id, link.version AS link_version,
|
|
162
|
+
account.state AS account_state, account.created_at AS account_created_at,
|
|
163
|
+
snapshot.id AS snapshot_id, snapshot.version AS snapshot_version,
|
|
164
|
+
snapshot.plan_version_id AS snapshot_plan_version_id,
|
|
165
|
+
snapshot.verification_status AS snapshot_verification_status,
|
|
166
|
+
snapshot.effective_from AS snapshot_effective_from,
|
|
167
|
+
snapshot.monthly_usage_anchor, snapshot.entitlements,
|
|
168
|
+
snapshot.content_checksum AS snapshot_content_checksum,
|
|
169
|
+
profile.version AS profile_version, profile.mode AS profile_mode,
|
|
170
|
+
profile.source AS profile_source,
|
|
171
|
+
profile.cohort_seal_id AS profile_cohort_seal_id,
|
|
172
|
+
profile.effective_from AS profile_effective_from,
|
|
173
|
+
seal.id AS cohort_seal_id, seal.sealed_at AS cohort_sealed_at
|
|
174
|
+
FROM org_billing_links AS link
|
|
175
|
+
JOIN billing_accounts AS account ON account.id = link.billing_account_id
|
|
176
|
+
JOIN billing_account_active_snapshots AS active_snapshot
|
|
177
|
+
ON active_snapshot.billing_account_id = link.billing_account_id
|
|
178
|
+
JOIN billing_entitlement_snapshots AS snapshot
|
|
179
|
+
ON snapshot.billing_account_id = active_snapshot.billing_account_id
|
|
180
|
+
AND snapshot.id = active_snapshot.snapshot_id
|
|
181
|
+
JOIN billing_account_active_enforcement_profiles AS active_profile
|
|
182
|
+
ON active_profile.billing_account_id = link.billing_account_id
|
|
183
|
+
JOIN billing_account_enforcement_profiles AS profile
|
|
184
|
+
ON profile.billing_account_id = active_profile.billing_account_id
|
|
185
|
+
AND profile.version = active_profile.profile_version
|
|
186
|
+
JOIN billing_enforcement_cohort_seals AS seal ON seal.singleton = true
|
|
187
|
+
WHERE link.org_slug = $1 AND link.active
|
|
188
|
+
${lock ? 'FOR SHARE OF link, account, active_snapshot, snapshot, active_profile, profile, seal' : ''}`, [org]);
|
|
189
|
+
return rows[0];
|
|
190
|
+
}
|
|
191
|
+
function sameAttribution(initial, locked) {
|
|
192
|
+
return (initial.billing_account_id === locked.billing_account_id &&
|
|
193
|
+
initial.link_version === locked.link_version &&
|
|
194
|
+
initial.account_state === locked.account_state &&
|
|
195
|
+
toIso(initial.account_created_at) === toIso(locked.account_created_at) &&
|
|
196
|
+
initial.snapshot_id === locked.snapshot_id &&
|
|
197
|
+
initial.snapshot_version === locked.snapshot_version &&
|
|
198
|
+
initial.snapshot_plan_version_id === locked.snapshot_plan_version_id &&
|
|
199
|
+
initial.snapshot_verification_status === locked.snapshot_verification_status &&
|
|
200
|
+
toIso(initial.snapshot_effective_from) === toIso(locked.snapshot_effective_from) &&
|
|
201
|
+
initial.snapshot_content_checksum === locked.snapshot_content_checksum &&
|
|
202
|
+
toIso(initial.monthly_usage_anchor) === toIso(locked.monthly_usage_anchor) &&
|
|
203
|
+
initial.profile_version === locked.profile_version &&
|
|
204
|
+
initial.profile_mode === locked.profile_mode &&
|
|
205
|
+
initial.profile_source === locked.profile_source &&
|
|
206
|
+
initial.profile_cohort_seal_id === locked.profile_cohort_seal_id &&
|
|
207
|
+
toIso(initial.profile_effective_from) === toIso(locked.profile_effective_from) &&
|
|
208
|
+
initial.cohort_seal_id === locked.cohort_seal_id &&
|
|
209
|
+
toIso(initial.cohort_sealed_at) === toIso(locked.cohort_sealed_at));
|
|
210
|
+
}
|
|
211
|
+
function validateAttribution(row) {
|
|
212
|
+
const profileEffectiveFrom = toIso(row.profile_effective_from);
|
|
213
|
+
const cohortSealedAt = toIso(row.cohort_sealed_at);
|
|
214
|
+
const validLegacyProfile = row.profile_mode === 'legacy_internal_exempt' &&
|
|
215
|
+
row.profile_source === 'legacy_cohort_seal' &&
|
|
216
|
+
profileEffectiveFrom === cohortSealedAt;
|
|
217
|
+
const validEnforcedProfile = row.profile_mode === 'enforced' &&
|
|
218
|
+
row.profile_source === 'post_seal_account' &&
|
|
219
|
+
profileEffectiveFrom >= cohortSealedAt;
|
|
220
|
+
if (row.account_state !== 'active' ||
|
|
221
|
+
row.profile_cohort_seal_id !== row.cohort_seal_id ||
|
|
222
|
+
(!validLegacyProfile && !validEnforcedProfile) ||
|
|
223
|
+
row.snapshot_verification_status !== 'verified' ||
|
|
224
|
+
!Number.isSafeInteger(row.snapshot_version) ||
|
|
225
|
+
row.snapshot_version < 1) {
|
|
226
|
+
throw unavailable();
|
|
227
|
+
}
|
|
228
|
+
const effectiveFrom = toIso(row.snapshot_effective_from);
|
|
229
|
+
const monthlyUsageAnchor = toIso(row.monthly_usage_anchor);
|
|
230
|
+
const expectedChecksum = billingContentChecksum({
|
|
231
|
+
billingAccountId: row.billing_account_id,
|
|
232
|
+
version: row.snapshot_version,
|
|
233
|
+
planVersionId: row.snapshot_plan_version_id,
|
|
234
|
+
effectiveFrom,
|
|
235
|
+
monthlyUsageAnchor,
|
|
236
|
+
entitlements: row.entitlements,
|
|
237
|
+
});
|
|
238
|
+
if (row.snapshot_content_checksum !== expectedChecksum)
|
|
239
|
+
throw unavailable();
|
|
240
|
+
}
|
|
241
|
+
function validAttribution(row) {
|
|
242
|
+
try {
|
|
243
|
+
validateAttribution(row);
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
if (error instanceof BillingAuthoritativeAdmissionUnavailableError)
|
|
248
|
+
return false;
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function normalizeInput(input) {
|
|
253
|
+
const deploymentId = input.deploymentId.trim();
|
|
254
|
+
if (deploymentId.length === 0 ||
|
|
255
|
+
deploymentId.length > 256 ||
|
|
256
|
+
!DEPLOYMENT_ID_PATTERN.test(deploymentId)) {
|
|
257
|
+
throw new Error('deployment id must be a bounded lowercase identifier');
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
org: validateSlug('org', input.org),
|
|
261
|
+
app: validateSlug('app', input.app),
|
|
262
|
+
environment: validateSlug('env', input.environment),
|
|
263
|
+
deploymentId,
|
|
264
|
+
identity: {
|
|
265
|
+
...(input.identity.highConfidenceKeyHash === undefined
|
|
266
|
+
? {}
|
|
267
|
+
: {
|
|
268
|
+
highConfidenceKeyHash: validateFingerprint('high-confidence execution key hash', input.identity.highConfidenceKeyHash),
|
|
269
|
+
}),
|
|
270
|
+
fallbackFingerprint: validateFingerprint('fallback fingerprint', input.identity.fallbackFingerprint),
|
|
271
|
+
semanticFingerprint: validateFingerprint('semantic fingerprint', input.identity.semanticFingerprint),
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function accountWindowLockKey(epochId, accountId, windowStart) {
|
|
276
|
+
return `billing-authoritative-account-window:v1:${epochId}:${accountId}:${windowStart}`;
|
|
277
|
+
}
|
|
278
|
+
function validateFingerprint(label, value) {
|
|
279
|
+
if (!/^[0-9a-f]{64}$/.test(value))
|
|
280
|
+
throw new Error(`${label} must be a SHA-256 digest`);
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
function validateAdmissionContractVersion(value) {
|
|
284
|
+
if (value !== BILLING_AUTHORITATIVE_ADMISSION_CONTRACT_VERSION) {
|
|
285
|
+
throw new Error('billing authoritative admission contract version is unsupported');
|
|
286
|
+
}
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
289
|
+
function boundedTimeout(label, value) {
|
|
290
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > 5_000) {
|
|
291
|
+
throw new Error(`${label} must be between 1 and 5000 milliseconds`);
|
|
292
|
+
}
|
|
293
|
+
return value;
|
|
294
|
+
}
|
|
295
|
+
function translateAdmissionError(error) {
|
|
296
|
+
if (error instanceof BillingAuthoritativeAuthorityInconsistentError)
|
|
297
|
+
return unavailable();
|
|
298
|
+
if (error instanceof BillingCommercialEntitlementError)
|
|
299
|
+
return unavailable();
|
|
300
|
+
if (error instanceof BillingAuthoritativeAdmissionUnavailableError ||
|
|
301
|
+
error instanceof BillingAuthoritativeIdempotencyConflictError) {
|
|
302
|
+
return error;
|
|
303
|
+
}
|
|
304
|
+
const code = typeof error === 'object' && error !== null && 'code' in error
|
|
305
|
+
? String(error.code)
|
|
306
|
+
: undefined;
|
|
307
|
+
return code === '55P03' || code === '57014' ? unavailable() : error;
|
|
308
|
+
}
|
|
309
|
+
function toIso(value) {
|
|
310
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
311
|
+
if (!Number.isFinite(date.getTime()))
|
|
312
|
+
throw unavailable();
|
|
313
|
+
return date.toISOString();
|
|
314
|
+
}
|
|
315
|
+
function unavailable() {
|
|
316
|
+
return new BillingAuthoritativeAdmissionUnavailableError();
|
|
317
|
+
}
|
|
318
|
+
async function rollbackQuietly(client) {
|
|
319
|
+
try {
|
|
320
|
+
await client.query('ROLLBACK');
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
// Preserve the authoritative admission error.
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=postgres-meter-admission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-admission.js","sourceRoot":"","sources":["../../src/billing/postgres-meter-admission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAIL,6CAA6C,EAC7C,4CAA4C,GAC7C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iCAAiC,EACjC,wCAAwC,GACzC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gDAAgD,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAEL,8CAA8C,EAC9C,mCAAmC,GACpC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,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CAAC;IACf,CAAC;IACD,MAAM,IAAI,GACR,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK;QAC5D,CAAC,CAAC,MAAM,CAAE,KAAoC,CAAC,IAAI,CAAC;QACpD,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACtE,CAAC;AAED,SAAS,KAAK,CAAC,KAAoB;IACjC,MAAM,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAAE,MAAM,WAAW,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,IAAI,6CAA6C,EAAE,CAAC;AAC7D,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,MAAkB;IAC/C,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,8CAA8C;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Pool, PoolClient } from 'pg';
|
|
2
2
|
import type { ControlPlaneIdentity } from '../auth/deploy-gate.js';
|
|
3
3
|
import { type BillingMeterValidationEpochPrepareRequest, type BillingMeterValidationEpochResult, type BillingMeterValidationEpochRetireRequest, type BillingMeterValidationEpochStore } from './meter-validation-epoch.js';
|
|
4
|
+
export declare const BILLING_METER_EPOCH_LIFECYCLE_LOCK_KEY = "billing-meter-validation-epoch-lifecycle:v1";
|
|
5
|
+
/** @deprecated Existing consumers retain this name; both constants use the same cross-version lock. */
|
|
4
6
|
export declare const BILLING_METER_VALIDATION_EPOCH_LIFECYCLE_LOCK_KEY = "billing-meter-validation-epoch-lifecycle:v1";
|
|
5
7
|
export interface BillingMeterValidationEpochPrepareBindings {
|
|
6
8
|
readonly keyGeneration: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-meter-epochs.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-meter-epochs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"postgres-meter-epochs.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-meter-epochs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAMnE,OAAO,EAGL,KAAK,yCAAyC,EAC9C,KAAK,iCAAiC,EAEtC,KAAK,wCAAwC,EAC7C,KAAK,gCAAgC,EAMtC,MAAM,6BAA6B,CAAC;AAKrC,eAAO,MAAM,sCAAsC,gDAAgD,CAAC;AACpG,uGAAuG;AACvG,eAAO,MAAM,iDAAiD,gDACtB,CAAC;AAEzC,MAAM,WAAW,0CAA0C;IACzD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC;AAED,MAAM,MAAM,2CAA2C,GAAG,CAAC,KAAK,EAAE;IAChE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,0CAA0C,CAAC;CAC/D,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvB,MAAM,WAAW,+CAA+C;IAC9D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,mGAAmG;IACnG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,2CAA2C,CAAC;IACxE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B;AAmBD,kFAAkF;AAClF,qBAAa,wCAAyC,YAAW,gCAAgC;;IAC/F,QAAQ,CAAC,gBAAgB,EAAG,eAAe,CAAU;gBAIzC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,+CAA+C;IAKhF,sBAAsB,CAAC,KAAK,EAAE;QAC5B,QAAQ,CAAC,OAAO,EAAE,yCAAyC,CAAC;QAC5D,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;QACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAS9C,qBAAqB,CAAC,KAAK,EAAE;QAC3B,QAAQ,CAAC,OAAO,EAAE,wCAAwC,CAAC;QAC3D,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;QACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,GAAG,OAAO,CAAC,iCAAiC,CAAC;CAyP/C"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
2
|
import { insertAuditEvent } from '@noodle-borg/module-audit';
|
|
3
|
+
import { BILLING_AUTHORITATIVE_ADMISSION_CONTRACT_VERSION } from './enforcement-activation.js';
|
|
3
4
|
import { BILLING_METER_RETRY_IDENTITY_VERSION, deriveBillingMeterKeyGeneration, } from './meter-readiness.js';
|
|
4
5
|
import { BILLING_METER_VALIDATION_WRITER_CONTRACT_VERSION, BillingMeterValidationEpochConflictError, BillingMeterValidationEpochResultSchema, billingMeterValidationEpochRequestFingerprint, billingMeterValidationEpochSuccessAudit, normalizeBillingMeterServiceUrl, parseBillingMeterValidationEpochPrepareRequest, parseBillingMeterValidationEpochRetireRequest, } from './meter-validation-epoch.js';
|
|
5
6
|
import { normalizeBillingEmail } from './model.js';
|
|
6
7
|
import { readBillingMeterTransactionTime } from './postgres-meter-clock.js';
|
|
7
8
|
import { validateScalarId } from './postgres-records.js';
|
|
8
|
-
export const
|
|
9
|
+
export const BILLING_METER_EPOCH_LIFECYCLE_LOCK_KEY = 'billing-meter-validation-epoch-lifecycle:v1';
|
|
10
|
+
/** @deprecated Existing consumers retain this name; both constants use the same cross-version lock. */
|
|
11
|
+
export const BILLING_METER_VALIDATION_EPOCH_LIFECYCLE_LOCK_KEY = BILLING_METER_EPOCH_LIFECYCLE_LOCK_KEY;
|
|
9
12
|
/** Durable, validation-only lifecycle. It never creates an active meter epoch. */
|
|
10
13
|
export class PostgresBillingMeterValidationEpochStore {
|
|
11
14
|
successAuditMode = 'transactional';
|
|
@@ -66,14 +69,16 @@ export class PostgresBillingMeterValidationEpochStore {
|
|
|
66
69
|
const preparedAt = await readBillingMeterTransactionTime(client);
|
|
67
70
|
const epochId = `bmev_${(this.#options.id ?? randomUUID)()}`;
|
|
68
71
|
await client.query(`INSERT INTO billing_meter_epochs
|
|
69
|
-
(id, schema_version, state, key_generation, release_sha,
|
|
70
|
-
writer_contract_version,
|
|
71
|
-
|
|
72
|
+
(id, schema_version, purpose, state, key_generation, release_sha,
|
|
73
|
+
retry_identity_version, writer_contract_version, admission_contract_version,
|
|
74
|
+
prepared_at)
|
|
75
|
+
VALUES ($1, 1, 'validation', 'prepared', $2, $3, $4, $5, $6, $7)`, [
|
|
72
76
|
epochId,
|
|
73
77
|
bindings.keyGeneration,
|
|
74
78
|
bindings.releaseSha,
|
|
75
79
|
bindings.retryIdentityVersion,
|
|
76
80
|
bindings.writerContractVersion,
|
|
81
|
+
BILLING_AUTHORITATIVE_ADMISSION_CONTRACT_VERSION,
|
|
77
82
|
preparedAt,
|
|
78
83
|
]);
|
|
79
84
|
const preflightReady = await this.#options.preparePreflight({
|
|
@@ -229,7 +234,7 @@ function hashIdempotencyKey(value) {
|
|
|
229
234
|
}
|
|
230
235
|
function lockLifecycle(client) {
|
|
231
236
|
return client.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [
|
|
232
|
-
|
|
237
|
+
BILLING_METER_EPOCH_LIFECYCLE_LOCK_KEY,
|
|
233
238
|
]);
|
|
234
239
|
}
|
|
235
240
|
async function findOperation(client, idempotencyHash) {
|