@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.
- package/dist/commands/archive-ops.js +1 -1
- package/dist/commands/archive-ops.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/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/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/node_modules/@noodle-borg/agent-kit/package.json +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,247 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { insertAuditEvent } from '@noodle-borg/module-audit';
|
|
3
|
+
import { BILLING_AUTHORITATIVE_ADMISSION_CONTRACT_VERSION, BillingEnforcementActivationConflictError, BillingEnforcementActivationMutationResultSchema, BillingEnforcementActivationPreviewSchema, billingEnforcementActivationApprovalChecksum, billingEnforcementActivationRequestFingerprint, billingEnforcementActivationSuccessAudit, normalizeActivationServiceUrl, parseBillingEnforcementActivateRequest, parseBillingEnforcementRollbackRequest, } from './enforcement-activation.js';
|
|
4
|
+
import { BILLING_ENFORCEMENT_ACTIVATION_LOCK_TIMEOUT_MS, validateActivationLockTimeout, withBillingEnforcementActivationTransaction, } from './postgres-enforcement-activation-locks.js';
|
|
5
|
+
import { assertActivationConfiguration, assertExpectedInactiveState, assertValidationEpochBindings, findOperation, hashIdempotencyKey, insertOperation, normalizeActor, replayOperation, requireActivationState, requireActiveAuthoritativeEpoch, requirePreparedValidationEpoch, rollbackQuietly, stateRowToStatus, toIso, validateAdmissionContractVersion, validateReleaseSha, writeSuccessAudit, } from './postgres-enforcement-activation-support.js';
|
|
6
|
+
import { readBillingMeterTransactionTime } from './postgres-meter-clock.js';
|
|
7
|
+
/** PostgreSQL-only protected lifecycle. The callback performs readiness checks on this store's transaction. */
|
|
8
|
+
export class PostgresBillingEnforcementActivationStore {
|
|
9
|
+
successAuditMode = 'transactional';
|
|
10
|
+
#pool;
|
|
11
|
+
#currentReleaseSha;
|
|
12
|
+
#admissionContractVersion;
|
|
13
|
+
#preflight;
|
|
14
|
+
#lockTimeoutMs;
|
|
15
|
+
#id;
|
|
16
|
+
constructor(pool, options) {
|
|
17
|
+
this.#pool = pool;
|
|
18
|
+
this.#currentReleaseSha = validateReleaseSha(options.currentReleaseSha);
|
|
19
|
+
this.#admissionContractVersion = validateAdmissionContractVersion(options.admissionContractVersion ?? BILLING_AUTHORITATIVE_ADMISSION_CONTRACT_VERSION);
|
|
20
|
+
this.#preflight = options.preflight;
|
|
21
|
+
this.#lockTimeoutMs = validateActivationLockTimeout(options.lockTimeoutMs ?? BILLING_ENFORCEMENT_ACTIVATION_LOCK_TIMEOUT_MS);
|
|
22
|
+
this.#id = options.id ?? randomUUID;
|
|
23
|
+
}
|
|
24
|
+
async getActivationStatus() {
|
|
25
|
+
const client = await this.#pool.connect();
|
|
26
|
+
try {
|
|
27
|
+
await client.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');
|
|
28
|
+
const state = await requireActivationState(client, false);
|
|
29
|
+
const status = stateRowToStatus(state);
|
|
30
|
+
await client.query('COMMIT');
|
|
31
|
+
return status;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
await rollbackQuietly(client);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
client.release();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async previewActivation(input) {
|
|
42
|
+
const approval = input.approval;
|
|
43
|
+
const client = await this.#pool.connect();
|
|
44
|
+
try {
|
|
45
|
+
await client.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');
|
|
46
|
+
const checkedAt = await readBillingMeterTransactionTime(client);
|
|
47
|
+
const preview = BillingEnforcementActivationPreviewSchema.parse(await this.#preflight({ client, approval, checkedAt }));
|
|
48
|
+
await client.query('COMMIT');
|
|
49
|
+
return preview;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
await rollbackQuietly(client);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
client.release();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
activateEnforcement(input) {
|
|
60
|
+
const request = parseBillingEnforcementActivateRequest(input.request);
|
|
61
|
+
const actor = normalizeActor(input.actor);
|
|
62
|
+
const service = normalizeActivationServiceUrl(input.service);
|
|
63
|
+
return this.#activate({ request, actor, service });
|
|
64
|
+
}
|
|
65
|
+
rollbackEnforcement(input) {
|
|
66
|
+
const request = parseBillingEnforcementRollbackRequest(input.request);
|
|
67
|
+
const actor = normalizeActor(input.actor);
|
|
68
|
+
const service = normalizeActivationServiceUrl(input.service);
|
|
69
|
+
return this.#rollback({ request, actor, service });
|
|
70
|
+
}
|
|
71
|
+
async #activate(input) {
|
|
72
|
+
const action = 'activate';
|
|
73
|
+
const fingerprint = billingEnforcementActivationRequestFingerprint({ action, ...input });
|
|
74
|
+
const idempotencyHash = hashIdempotencyKey(input.request.idempotencyKey);
|
|
75
|
+
return withBillingEnforcementActivationTransaction(this.#pool, this.#lockTimeoutMs, async (client) => {
|
|
76
|
+
const replay = await findOperation(client, idempotencyHash);
|
|
77
|
+
if (replay !== undefined) {
|
|
78
|
+
const result = replayOperation(replay, action, fingerprint);
|
|
79
|
+
await writeSuccessAudit(client, result, input.actor);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
assertActivationConfiguration(input.request.approval, {
|
|
83
|
+
service: input.service,
|
|
84
|
+
releaseSha: this.#currentReleaseSha,
|
|
85
|
+
});
|
|
86
|
+
const state = await requireActivationState(client, true);
|
|
87
|
+
assertExpectedInactiveState(state, input.request.approval);
|
|
88
|
+
const validationEpoch = await requirePreparedValidationEpoch(client, input.request.approval.expectedValidationEpochId);
|
|
89
|
+
assertValidationEpochBindings(validationEpoch, {
|
|
90
|
+
releaseSha: this.#currentReleaseSha,
|
|
91
|
+
admissionContractVersion: this.#admissionContractVersion,
|
|
92
|
+
});
|
|
93
|
+
const checkedAt = await readBillingMeterTransactionTime(client);
|
|
94
|
+
const preview = BillingEnforcementActivationPreviewSchema.parse(await this.#preflight({
|
|
95
|
+
client,
|
|
96
|
+
approval: input.request.approval,
|
|
97
|
+
checkedAt,
|
|
98
|
+
}));
|
|
99
|
+
if (!preview.ready) {
|
|
100
|
+
throw new BillingEnforcementActivationConflictError('activation_preflight_blocked', 'billing enforcement activation prerequisites are blocked');
|
|
101
|
+
}
|
|
102
|
+
if (preview.previewChecksum !== input.request.expectedPreviewChecksum) {
|
|
103
|
+
throw new BillingEnforcementActivationConflictError('activation_preview_changed', 'billing enforcement activation preview changed; review a fresh preview');
|
|
104
|
+
}
|
|
105
|
+
const approvalChecksum = billingEnforcementActivationApprovalChecksum(input.request.approval);
|
|
106
|
+
if (preview.approvalChecksum !== approvalChecksum) {
|
|
107
|
+
throw new BillingEnforcementActivationConflictError('activation_preview_changed', 'billing enforcement activation approval no longer matches its preview');
|
|
108
|
+
}
|
|
109
|
+
const activatedAt = checkedAt;
|
|
110
|
+
const activeEpochId = `bmea_${this.#id()}`;
|
|
111
|
+
const generation = state.generation + 1;
|
|
112
|
+
await client.query(`UPDATE billing_meter_epochs
|
|
113
|
+
SET state = 'retired', retired_at = $2
|
|
114
|
+
WHERE id = $1 AND purpose = 'validation' AND state = 'prepared'`, [validationEpoch.id, activatedAt]);
|
|
115
|
+
await client.query(`INSERT INTO billing_meter_epochs
|
|
116
|
+
(id, schema_version, purpose, state, key_generation, release_sha,
|
|
117
|
+
retry_identity_version, writer_contract_version, admission_contract_version,
|
|
118
|
+
prepared_at, activated_at)
|
|
119
|
+
VALUES ($1, 1, 'authoritative', 'active', $2, $3, $4, $5, $6, $7, $7)`, [
|
|
120
|
+
activeEpochId,
|
|
121
|
+
validationEpoch.key_generation,
|
|
122
|
+
this.#currentReleaseSha,
|
|
123
|
+
validationEpoch.retry_identity_version,
|
|
124
|
+
validationEpoch.writer_contract_version,
|
|
125
|
+
this.#admissionContractVersion,
|
|
126
|
+
activatedAt,
|
|
127
|
+
]);
|
|
128
|
+
const stateUpdate = await client.query(`UPDATE billing_enforcement_activation_state
|
|
129
|
+
SET state = 'active', generation = $1, active_epoch_id = $2, last_epoch_id = $2,
|
|
130
|
+
activated_at = $3, rolled_back_at = NULL,
|
|
131
|
+
activation_service_release_sha = $4, admission_contract_version = $5,
|
|
132
|
+
approval_checksum = $6, updated_at = $3
|
|
133
|
+
WHERE singleton = true AND state = $7 AND generation = $8`, [
|
|
134
|
+
generation,
|
|
135
|
+
activeEpochId,
|
|
136
|
+
activatedAt,
|
|
137
|
+
this.#currentReleaseSha,
|
|
138
|
+
this.#admissionContractVersion,
|
|
139
|
+
approvalChecksum,
|
|
140
|
+
input.request.approval.expectedState,
|
|
141
|
+
input.request.approval.expectedGeneration,
|
|
142
|
+
]);
|
|
143
|
+
if (stateUpdate.rowCount !== 1) {
|
|
144
|
+
throw new BillingEnforcementActivationConflictError('activation_state_conflict', 'billing enforcement activation state changed concurrently');
|
|
145
|
+
}
|
|
146
|
+
const result = BillingEnforcementActivationMutationResultSchema.parse({
|
|
147
|
+
schemaVersion: 1,
|
|
148
|
+
action,
|
|
149
|
+
state: 'active',
|
|
150
|
+
generation,
|
|
151
|
+
replayed: false,
|
|
152
|
+
cohortSealId: state.cohort_seal_id,
|
|
153
|
+
activeEpochId,
|
|
154
|
+
lastEpochId: activeEpochId,
|
|
155
|
+
retiredValidationEpochId: validationEpoch.id,
|
|
156
|
+
activatedAt,
|
|
157
|
+
rolledBackAt: null,
|
|
158
|
+
activationServiceReleaseSha: this.#currentReleaseSha,
|
|
159
|
+
admissionContractVersion: this.#admissionContractVersion,
|
|
160
|
+
approvalChecksum,
|
|
161
|
+
previewChecksum: preview.previewChecksum,
|
|
162
|
+
});
|
|
163
|
+
await insertOperation(client, {
|
|
164
|
+
result,
|
|
165
|
+
idempotencyHash,
|
|
166
|
+
fingerprint,
|
|
167
|
+
actor: input.actor,
|
|
168
|
+
service: input.service,
|
|
169
|
+
reason: input.request.reason,
|
|
170
|
+
validationEpochId: validationEpoch.id,
|
|
171
|
+
createdAt: activatedAt,
|
|
172
|
+
operationId: `beao_${this.#id()}`,
|
|
173
|
+
});
|
|
174
|
+
await insertAuditEvent(client, billingEnforcementActivationSuccessAudit(result, input.actor), {
|
|
175
|
+
now: () => new Date(activatedAt),
|
|
176
|
+
});
|
|
177
|
+
return result;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
async #rollback(input) {
|
|
181
|
+
const action = 'rollback';
|
|
182
|
+
const fingerprint = billingEnforcementActivationRequestFingerprint({ action, ...input });
|
|
183
|
+
const idempotencyHash = hashIdempotencyKey(input.request.idempotencyKey);
|
|
184
|
+
return withBillingEnforcementActivationTransaction(this.#pool, this.#lockTimeoutMs, async (client) => {
|
|
185
|
+
const replay = await findOperation(client, idempotencyHash);
|
|
186
|
+
if (replay !== undefined) {
|
|
187
|
+
const result = replayOperation(replay, action, fingerprint);
|
|
188
|
+
await writeSuccessAudit(client, result, input.actor);
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
const state = await requireActivationState(client, true);
|
|
192
|
+
if (state.state !== input.request.expectedState ||
|
|
193
|
+
state.generation !== input.request.expectedGeneration ||
|
|
194
|
+
state.active_epoch_id !== input.request.expectedEpochId ||
|
|
195
|
+
state.last_epoch_id !== input.request.expectedEpochId ||
|
|
196
|
+
state.activated_at === null ||
|
|
197
|
+
state.activation_service_release_sha === null ||
|
|
198
|
+
state.admission_contract_version === null ||
|
|
199
|
+
state.approval_checksum === null) {
|
|
200
|
+
throw new BillingEnforcementActivationConflictError('activation_state_conflict', 'billing enforcement rollback target is not the current active generation');
|
|
201
|
+
}
|
|
202
|
+
const epoch = await requireActiveAuthoritativeEpoch(client, input.request.expectedEpochId);
|
|
203
|
+
const rolledBackAt = await readBillingMeterTransactionTime(client);
|
|
204
|
+
await client.query(`UPDATE billing_meter_epochs SET state = 'retired', retired_at = $2
|
|
205
|
+
WHERE id = $1 AND purpose = 'authoritative' AND state = 'active'`, [epoch.id, rolledBackAt]);
|
|
206
|
+
const stateUpdate = await client.query(`UPDATE billing_enforcement_activation_state
|
|
207
|
+
SET state = 'rolled_back', active_epoch_id = NULL, rolled_back_at = $2, updated_at = $2
|
|
208
|
+
WHERE singleton = true AND state = 'active' AND generation = $3 AND active_epoch_id = $1`, [epoch.id, rolledBackAt, state.generation]);
|
|
209
|
+
if (stateUpdate.rowCount !== 1) {
|
|
210
|
+
throw new BillingEnforcementActivationConflictError('activation_state_conflict', 'billing enforcement activation state changed concurrently');
|
|
211
|
+
}
|
|
212
|
+
const result = BillingEnforcementActivationMutationResultSchema.parse({
|
|
213
|
+
schemaVersion: 1,
|
|
214
|
+
action,
|
|
215
|
+
state: 'rolled_back',
|
|
216
|
+
generation: state.generation,
|
|
217
|
+
replayed: false,
|
|
218
|
+
cohortSealId: state.cohort_seal_id,
|
|
219
|
+
activeEpochId: null,
|
|
220
|
+
lastEpochId: epoch.id,
|
|
221
|
+
retiredValidationEpochId: null,
|
|
222
|
+
activatedAt: toIso(state.activated_at),
|
|
223
|
+
rolledBackAt,
|
|
224
|
+
activationServiceReleaseSha: state.activation_service_release_sha,
|
|
225
|
+
admissionContractVersion: state.admission_contract_version,
|
|
226
|
+
approvalChecksum: state.approval_checksum,
|
|
227
|
+
previewChecksum: null,
|
|
228
|
+
});
|
|
229
|
+
await insertOperation(client, {
|
|
230
|
+
result,
|
|
231
|
+
idempotencyHash,
|
|
232
|
+
fingerprint,
|
|
233
|
+
actor: input.actor,
|
|
234
|
+
service: input.service,
|
|
235
|
+
reason: input.request.reason,
|
|
236
|
+
validationEpochId: null,
|
|
237
|
+
createdAt: rolledBackAt,
|
|
238
|
+
operationId: `beao_${this.#id()}`,
|
|
239
|
+
});
|
|
240
|
+
await insertAuditEvent(client, billingEnforcementActivationSuccessAudit(result, input.actor), {
|
|
241
|
+
now: () => new Date(rolledBackAt),
|
|
242
|
+
});
|
|
243
|
+
return result;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=postgres-enforcement-activation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-enforcement-activation.js","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-activation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,EACL,gDAAgD,EAGhD,yCAAyC,EAEzC,gDAAgD,EAGhD,yCAAyC,EAIzC,4CAA4C,EAC5C,8CAA8C,EAC9C,wCAAwC,EACxC,6BAA6B,EAC7B,sCAAsC,EACtC,sCAAsC,G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,CAAC;CACF"}
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enforcement-profile-schema.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-profile-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,qGAAqG;AACrG,wBAAsB,qCAAqC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"postgres-enforcement-profile-schema.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-profile-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,qGAAqG;AACrG,wBAAsB,qCAAqC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAgJrF"}
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js
CHANGED
|
@@ -42,6 +42,46 @@ export async function ensureBillingEnforcementProfileSchema(pool) {
|
|
|
42
42
|
REFERENCES billing_account_enforcement_profiles(billing_account_id, version)
|
|
43
43
|
ON DELETE RESTRICT
|
|
44
44
|
)
|
|
45
|
+
`);
|
|
46
|
+
await pool.query(`
|
|
47
|
+
CREATE OR REPLACE FUNCTION reject_billing_enforcement_profile_mutation()
|
|
48
|
+
RETURNS trigger LANGUAGE plpgsql AS $$
|
|
49
|
+
BEGIN
|
|
50
|
+
RAISE EXCEPTION 'billing enforcement profiles are append-only' USING ERRCODE = '55000';
|
|
51
|
+
END
|
|
52
|
+
$$
|
|
53
|
+
`);
|
|
54
|
+
await pool.query(`
|
|
55
|
+
DO $billing_enforcement_profile_immutability$
|
|
56
|
+
BEGIN
|
|
57
|
+
IF NOT EXISTS (
|
|
58
|
+
SELECT 1 FROM pg_trigger
|
|
59
|
+
WHERE tgname = 'billing_enforcement_profiles_append_only'
|
|
60
|
+
AND tgrelid = 'billing_account_enforcement_profiles'::regclass
|
|
61
|
+
AND NOT tgisinternal
|
|
62
|
+
) THEN
|
|
63
|
+
CREATE TRIGGER billing_enforcement_profiles_append_only
|
|
64
|
+
BEFORE UPDATE OR DELETE ON billing_account_enforcement_profiles
|
|
65
|
+
FOR EACH ROW EXECUTE FUNCTION reject_billing_enforcement_profile_mutation();
|
|
66
|
+
END IF;
|
|
67
|
+
END
|
|
68
|
+
$billing_enforcement_profile_immutability$
|
|
69
|
+
`);
|
|
70
|
+
await pool.query(`
|
|
71
|
+
DO $billing_enforcement_profile_pointer_immutability$
|
|
72
|
+
BEGIN
|
|
73
|
+
IF NOT EXISTS (
|
|
74
|
+
SELECT 1 FROM pg_trigger
|
|
75
|
+
WHERE tgname = 'billing_enforcement_profile_pointers_append_only'
|
|
76
|
+
AND tgrelid = 'billing_account_active_enforcement_profiles'::regclass
|
|
77
|
+
AND NOT tgisinternal
|
|
78
|
+
) THEN
|
|
79
|
+
CREATE TRIGGER billing_enforcement_profile_pointers_append_only
|
|
80
|
+
BEFORE UPDATE OR DELETE ON billing_account_active_enforcement_profiles
|
|
81
|
+
FOR EACH ROW EXECUTE FUNCTION reject_billing_enforcement_profile_mutation();
|
|
82
|
+
END IF;
|
|
83
|
+
END
|
|
84
|
+
$billing_enforcement_profile_pointer_immutability$
|
|
45
85
|
`);
|
|
46
86
|
await pool.query(`
|
|
47
87
|
CREATE TABLE IF NOT EXISTS billing_enforcement_cohort_operations (
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enforcement-profile-schema.js","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-profile-schema.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,MAAM,CAAC,KAAK,UAAU,qCAAqC,CAAC,IAAU;IACpE,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;GAehB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;GAiBhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;GAQhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;GAchB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;GAgBhB,CAAC,CAAC;AACL,CAAC"}
|
|
1
|
+
{"version":3,"file":"postgres-enforcement-profile-schema.js","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-profile-schema.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,MAAM,CAAC,KAAK,UAAU,qCAAqC,CAAC,IAAU;IACpE,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;GAehB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;GAiBhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;GAQhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;GAOhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;GAehB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;GAehB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;GAchB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BhB,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;GAgBhB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -15,4 +15,5 @@ export declare function sealEnforcementCohortRow(pool: Pool, input: {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function ensurePostSealBillingAccountEnforcementProfileTx(client: PoolClient, billingAccountId: string): Promise<BillingAccountEnforcementProfileRecord | undefined>;
|
|
17
17
|
export declare function requireBillingAccountEnforcementProfileIfSealedTx(client: PoolClient, billingAccountId: string): Promise<void>;
|
|
18
|
+
export declare function readEnforcementCohortStatusTx(queryable: Pool | PoolClient): Promise<BillingEnforcementCohortStatusResponse>;
|
|
18
19
|
//# sourceMappingURL=postgres-enforcement-profile.d.ts.map
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enforcement-profile.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-profile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,IAAI,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAEL,KAAK,sCAAsC,EAE3C,KAAK,mCAAmC,EACxC,KAAK,oCAAoC,EAEzC,KAAK,sCAAsC,EAM5C,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,6CAA6C,uDACJ,CAAC;AA6BvD,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,sCAAsC,CAAC,CAajD;AAED,wBAAgB,4CAA4C,CAC1D,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,sCAAsC,GAAG,SAAS,CAAC,CAK7D;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,KAAK,EAAE;IACL,QAAQ,CAAC,OAAO,EAAE,mCAAmC,CAAC;IACtD,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GACA,OAAO,CAAC,oCAAoC,CAAC,CA4H/C;AAED;;;GAGG;AACH,wBAAsB,gDAAgD,CACpE,MAAM,EAAE,UAAU,EAClB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,sCAAsC,GAAG,SAAS,CAAC,CAsB7D;AAED,wBAAsB,iDAAiD,CACrE,MAAM,EAAE,UAAU,EAClB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
1
|
+
{"version":3,"file":"postgres-enforcement-profile.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-profile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,IAAI,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAEL,KAAK,sCAAsC,EAE3C,KAAK,mCAAmC,EACxC,KAAK,oCAAoC,EAEzC,KAAK,sCAAsC,EAM5C,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,6CAA6C,uDACJ,CAAC;AA6BvD,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,sCAAsC,CAAC,CAajD;AAED,wBAAgB,4CAA4C,CAC1D,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,sCAAsC,GAAG,SAAS,CAAC,CAK7D;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,KAAK,EAAE;IACL,QAAQ,CAAC,OAAO,EAAE,mCAAmC,CAAC;IACtD,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GACA,OAAO,CAAC,oCAAoC,CAAC,CA4H/C;AAED;;;GAGG;AACH,wBAAsB,gDAAgD,CACpE,MAAM,EAAE,UAAU,EAClB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,sCAAsC,GAAG,SAAS,CAAC,CAsB7D;AAED,wBAAsB,iDAAiD,CACrE,MAAM,EAAE,UAAU,EAClB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,IAAI,GAAG,UAAU,GAC3B,OAAO,CAAC,sCAAsC,CAAC,CA2DjD"}
|
|
@@ -9,7 +9,7 @@ export async function getEnforcementCohortStatusRow(pool) {
|
|
|
9
9
|
const client = await pool.connect();
|
|
10
10
|
try {
|
|
11
11
|
await client.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');
|
|
12
|
-
const response = await
|
|
12
|
+
const response = await readEnforcementCohortStatusTx(client);
|
|
13
13
|
await client.query('COMMIT');
|
|
14
14
|
return response;
|
|
15
15
|
}
|
|
@@ -92,7 +92,7 @@ export async function sealEnforcementCohortRow(pool, input) {
|
|
|
92
92
|
SELECT billing_account_id, version
|
|
93
93
|
FROM billing_account_enforcement_profiles
|
|
94
94
|
WHERE cohort_seal_id = $1`, [sealId]);
|
|
95
|
-
const status = await
|
|
95
|
+
const status = await readEnforcementCohortStatusTx(client);
|
|
96
96
|
if (status.state !== 'sealed' ||
|
|
97
97
|
status.sealId !== sealId ||
|
|
98
98
|
status.billingAccountCount !== profiles.rowCount ||
|
|
@@ -158,22 +158,40 @@ export async function requireBillingAccountEnforcementProfileIfSealedTx(client,
|
|
|
158
158
|
throw new Error('default billing account is incomplete');
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
async function
|
|
161
|
+
export async function readEnforcementCohortStatusTx(queryable) {
|
|
162
162
|
const seal = await findSeal(queryable);
|
|
163
163
|
const counts = await queryable.query(`
|
|
164
164
|
SELECT
|
|
165
|
-
count(
|
|
166
|
-
count(
|
|
167
|
-
count(*) FILTER (WHERE
|
|
165
|
+
count(account_id)::text AS billing_account_count,
|
|
166
|
+
count(valid_mode)::text AS profiled_account_count,
|
|
167
|
+
count(*) FILTER (WHERE valid_mode = 'legacy_internal_exempt')::text
|
|
168
168
|
AS legacy_internal_exempt_account_count,
|
|
169
|
-
count(*) FILTER (WHERE
|
|
170
|
-
count(*) FILTER (WHERE
|
|
171
|
-
FROM
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
count(*) FILTER (WHERE valid_mode = 'enforced')::text AS enforced_account_count,
|
|
170
|
+
count(*) FILTER (WHERE valid_mode IS NULL)::text AS unprofiled_account_count
|
|
171
|
+
FROM (
|
|
172
|
+
SELECT account.id AS account_id,
|
|
173
|
+
CASE
|
|
174
|
+
WHEN profile.cohort_seal_id = seal.id AND (
|
|
175
|
+
(
|
|
176
|
+
profile.mode = 'legacy_internal_exempt' AND
|
|
177
|
+
profile.source = 'legacy_cohort_seal' AND
|
|
178
|
+
profile.effective_from = seal.sealed_at
|
|
179
|
+
) OR (
|
|
180
|
+
profile.mode = 'enforced' AND
|
|
181
|
+
profile.source = 'post_seal_account' AND
|
|
182
|
+
profile.effective_from >= seal.sealed_at
|
|
183
|
+
)
|
|
184
|
+
) THEN profile.mode
|
|
185
|
+
ELSE NULL
|
|
186
|
+
END AS valid_mode
|
|
187
|
+
FROM billing_accounts AS account
|
|
188
|
+
LEFT JOIN billing_account_active_enforcement_profiles AS active
|
|
189
|
+
ON active.billing_account_id = account.id
|
|
190
|
+
LEFT JOIN billing_account_enforcement_profiles AS profile
|
|
191
|
+
ON profile.billing_account_id = active.billing_account_id
|
|
192
|
+
AND profile.version = active.profile_version
|
|
193
|
+
LEFT JOIN billing_enforcement_cohort_seals AS seal ON seal.singleton = true
|
|
194
|
+
) AS classified_accounts
|
|
177
195
|
`);
|
|
178
196
|
const attributionBlockerCount = await countAttributionBlockers(queryable);
|
|
179
197
|
const row = counts.rows[0];
|
|
@@ -215,14 +233,19 @@ async function countAttributionBlockers(queryable) {
|
|
|
215
233
|
JOIN orgs AS org ON org.slug = link.org_slug
|
|
216
234
|
WHERE org.slug <> 'local'
|
|
217
235
|
AND link.active
|
|
218
|
-
AND
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
236
|
+
AND (
|
|
237
|
+
NOT EXISTS (
|
|
238
|
+
SELECT 1 FROM billing_accounts AS account
|
|
239
|
+
WHERE account.id = link.billing_account_id AND account.state = 'active'
|
|
240
|
+
) OR NOT EXISTS (
|
|
241
|
+
SELECT 1
|
|
242
|
+
FROM billing_account_active_snapshots AS active
|
|
243
|
+
JOIN billing_entitlement_snapshots AS snapshot
|
|
244
|
+
ON snapshot.billing_account_id = active.billing_account_id
|
|
245
|
+
AND snapshot.id = active.snapshot_id
|
|
246
|
+
WHERE active.billing_account_id = link.billing_account_id
|
|
247
|
+
AND snapshot.verification_status = 'verified'
|
|
248
|
+
)
|
|
226
249
|
)
|
|
227
250
|
) AS blockers
|
|
228
251
|
`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enforcement-profile.js","sourceRoot":"","sources":["../../src/billing/postgres-enforcement-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,EACL,+BAA+B,EAE/B,qCAAqC,EAGrC,0CAA0C,EAE1C,4CAA4C,EAC5C,0CAA0C,EAC1C,oCAAoC,EACpC,qCAAqC,EACrC,wCAAwC,GACzC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,6C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,CAAC;AAC5B,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,6CAA6C;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PoolClient } from 'pg';
|
|
2
|
+
import { type BillingAuthoritativeAdmissionInput } from './authoritative-admission.js';
|
|
3
|
+
interface AuthoritativeLedgerAttribution {
|
|
4
|
+
readonly billing_account_id: string;
|
|
5
|
+
readonly link_version: number;
|
|
6
|
+
readonly snapshot_id: string;
|
|
7
|
+
readonly snapshot_version: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function lockAuthoritativeDedupeIdentity(client: PoolClient, epochId: string, input: BillingAuthoritativeAdmissionInput): Promise<void>;
|
|
10
|
+
export declare function findAuthoritativeDuplicate(client: PoolClient, input: {
|
|
11
|
+
readonly epochId: string;
|
|
12
|
+
readonly input: BillingAuthoritativeAdmissionInput;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
readonly classification: 'included' | 'overage';
|
|
15
|
+
readonly resetAt: string;
|
|
16
|
+
} | undefined>;
|
|
17
|
+
export declare function readAuthoritativeIncludedCalls(client: PoolClient, input: {
|
|
18
|
+
readonly epochId: string;
|
|
19
|
+
readonly billingAccountId: string;
|
|
20
|
+
readonly windowStart: string;
|
|
21
|
+
readonly windowEnd: string;
|
|
22
|
+
}): Promise<number>;
|
|
23
|
+
export declare function recordAuthoritativeAdmission(client: PoolClient, input: {
|
|
24
|
+
readonly epochId: string;
|
|
25
|
+
readonly input: BillingAuthoritativeAdmissionInput;
|
|
26
|
+
readonly attribution: AuthoritativeLedgerAttribution;
|
|
27
|
+
readonly classification: 'included' | 'overage';
|
|
28
|
+
readonly recordedAt: string;
|
|
29
|
+
readonly windowStart: string;
|
|
30
|
+
readonly windowEnd: string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=postgres-meter-admission-ledger.d.ts.map
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-admission-ledger.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-admission-ledger.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-meter-admission-ledger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EACL,KAAK,kCAAkC,EAGxC,MAAM,8BAA8B,CAAC;AAOtC,UAAU,8BAA8B;IACtC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AASD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,kCAAkC,GACxC,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE;IACL,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,kCAAkC,CAAC;CACpD,GACA,OAAO,CACR;IAAE,QAAQ,CAAC,cAAc,EAAE,UAAU,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAC1F,CAuBA;AAUD,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE;IACL,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC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