@noodleseed/one 0.46.0 → 0.48.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/assistant-ops.d.ts.map +1 -1
- package/dist/commands/assistant-ops.js +65 -1
- package/dist/commands/assistant-ops.js.map +1 -1
- package/dist/commands/auth-ops.d.ts.map +1 -1
- package/dist/commands/auth-ops.js +28 -4
- package/dist/commands/auth-ops.js.map +1 -1
- package/dist/commands/billing-enforcement-ops.d.ts +2 -0
- package/dist/commands/billing-enforcement-ops.d.ts.map +1 -0
- package/dist/commands/billing-enforcement-ops.js +312 -0
- package/dist/commands/billing-enforcement-ops.js.map +1 -0
- package/dist/commands/billing-metering-ops.d.ts +2 -0
- package/dist/commands/billing-metering-ops.d.ts.map +1 -0
- package/dist/commands/billing-metering-ops.js +128 -0
- package/dist/commands/billing-metering-ops.js.map +1 -0
- package/dist/commands/billing-metering-validation-ops.d.ts +2 -0
- package/dist/commands/billing-metering-validation-ops.d.ts.map +1 -0
- package/dist/commands/billing-metering-validation-ops.js +186 -0
- package/dist/commands/billing-metering-validation-ops.js.map +1 -0
- package/dist/commands/billing-ops.d.ts.map +1 -1
- package/dist/commands/billing-ops.js +6 -0
- package/dist/commands/billing-ops.js.map +1 -1
- package/dist/commands/catalog-data-resources.d.ts.map +1 -1
- package/dist/commands/catalog-data-resources.js +25 -4
- package/dist/commands/catalog-data-resources.js.map +1 -1
- package/dist/commands/catalog-render.d.ts.map +1 -1
- package/dist/commands/catalog-render.js +7 -5
- package/dist/commands/catalog-render.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +10 -1
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/commands/deploy-output.d.ts.map +1 -1
- package/dist/commands/deploy-output.js +4 -0
- package/dist/commands/deploy-output.js.map +1 -1
- package/dist/commands/deploy-version-resolution.d.ts +1 -0
- package/dist/commands/deploy-version-resolution.d.ts.map +1 -1
- package/dist/commands/deploy-version-resolution.js +8 -0
- package/dist/commands/deploy-version-resolution.js.map +1 -1
- package/dist/commands/mcp-apps-chatgpt.d.ts +7 -0
- package/dist/commands/mcp-apps-chatgpt.d.ts.map +1 -0
- package/dist/commands/mcp-apps-chatgpt.js +143 -0
- package/dist/commands/mcp-apps-chatgpt.js.map +1 -0
- package/dist/commands/mcp-apps.d.ts.map +1 -1
- package/dist/commands/mcp-apps.js +2 -114
- package/dist/commands/mcp-apps.js.map +1 -1
- package/dist/deploy-payload-size.d.ts +3 -0
- package/dist/deploy-payload-size.d.ts.map +1 -0
- package/dist/deploy-payload-size.js +29 -0
- package/dist/deploy-payload-size.js.map +1 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +19 -8
- package/dist/deploy.js.map +1 -1
- package/dist/sdk-version-skew.d.ts +3 -0
- package/dist/sdk-version-skew.d.ts.map +1 -0
- package/dist/sdk-version-skew.js +34 -0
- package/dist/sdk-version-skew.js.map +1 -0
- package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +3 -3
- package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.js +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-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-embedded-assistant-ref.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js +10 -2
- package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +5 -0
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.js +1 -0
- package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/artifact/types.d.ts +7 -1
- package/node_modules/@noodle-borg/compiler/dist/artifact/types.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/artifact/types.js +4 -1
- package/node_modules/@noodle-borg/compiler/dist/artifact/types.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +3 -0
- package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +12 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +7 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.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 +40 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/sdk-server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/sdk-server.js +109 -1
- package/node_modules/@noodle-borg/protocol/dist/sdk-server.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.d.ts +10 -3
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.js +69 -5
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/widget/action-wiring-bootstrap.d.ts +3 -0
- package/node_modules/@noodle-borg/protocol/dist/widget/action-wiring-bootstrap.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/widget/action-wiring-bootstrap.js +17 -0
- package/node_modules/@noodle-borg/protocol/dist/widget/action-wiring-bootstrap.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/widget/bootstrap.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/widget/bootstrap.js +8 -16
- package/node_modules/@noodle-borg/protocol/dist/widget/bootstrap.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/widget/interaction-bootstrap.d.ts +3 -0
- package/node_modules/@noodle-borg/protocol/dist/widget/interaction-bootstrap.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/widget/interaction-bootstrap.js +177 -0
- package/node_modules/@noodle-borg/protocol/dist/widget/interaction-bootstrap.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-profile.d.ts +96 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-profile.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-profile.js +198 -0
- package/node_modules/@noodle-borg/service/dist/billing/enforcement-profile.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts +25 -2
- package/node_modules/@noodle-borg/service/dist/billing/integration.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/integration.js +51 -5
- package/node_modules/@noodle-borg/service/dist/billing/integration.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/meter-capacity.d.ts +77 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-capacity.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-capacity.js +202 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-capacity.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation-contract.d.ts +8 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation-contract.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation-contract.js +93 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation-contract.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation.d.ts +76 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation.js +233 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-live-validation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness-health.d.ts +89 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness-health.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness-health.js +191 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness-health.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness.d.ts +99 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness.js +136 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-readiness.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-runtime-config.d.ts +9 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-runtime-config.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-runtime-config.js +24 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-runtime-config.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-validation-epoch.d.ts +75 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-validation-epoch.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-validation-epoch.js +127 -0
- package/node_modules/@noodle-borg/service/dist/billing/meter-validation-epoch.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js +107 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts +18 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js +341 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-enforcement-profile.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-clock.d.ts +3 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-clock.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-clock.js +9 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-clock.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epoch-fixtures.d.ts +13 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epoch-fixtures.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epoch-fixtures.js +102 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epoch-fixtures.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts +41 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js +289 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-epochs.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-evidence-retention.d.ts +16 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-evidence-retention.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-evidence-retention.js +126 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-evidence-retention.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.d.ts +33 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js +436 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-maintenance.d.ts +26 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-maintenance.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-maintenance.js +146 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-maintenance.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-partition.d.ts +8 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-partition.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-partition.js +42 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-partition.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-prepare-preflight.d.ts +8 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-prepare-preflight.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-prepare-preflight.js +44 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-prepare-preflight.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness-live.d.ts +13 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness-live.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness-live.js +189 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness-live.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts +18 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js +342 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-readiness.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.d.ts +27 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js +304 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-reconciliation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-retention.d.ts +22 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-retention.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-retention.js +224 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-retention.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts +33 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.js +173 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-runtime.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-schema.d.ts +7 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-schema.js +50 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-store.d.ts +34 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-store.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-store.js +157 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler-store.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler.d.ts +56 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler.js +264 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-scheduler.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.d.ts +6 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js +414 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-validation.d.ts +43 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-validation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-validation.js +321 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-validation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-lock.d.ts +10 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-lock.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-lock.js +13 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-lock.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-schema.d.ts +6 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-schema.js +248 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-window-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-compaction.d.ts +29 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-compaction.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-compaction.js +240 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-compaction.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-health-schema.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-health-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-health-schema.js +140 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-writer-health-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-migration.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres-migration.js +4 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-migration.js.map +1 -1
- 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 +6 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres-schema.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/postgres.js +3 -0
- package/node_modules/@noodle-borg/service/dist/billing/postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/service-meter-runtime.d.ts +7 -0
- package/node_modules/@noodle-borg/service/dist/billing/service-meter-runtime.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/service-meter-runtime.js +19 -0
- package/node_modules/@noodle-borg/service/dist/billing/service-meter-runtime.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/shadow-meter.d.ts +9 -4
- package/node_modules/@noodle-borg/service/dist/billing/shadow-meter.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/shadow-meter.js +34 -95
- package/node_modules/@noodle-borg/service/dist/billing/shadow-meter.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.d.ts +14 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.js +87 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-observer.d.ts +6 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-observer.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-observer.js +26 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-observer.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing-public.d.ts +16 -0
- package/node_modules/@noodle-borg/service/dist/billing-public.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/billing-public.js +15 -0
- package/node_modules/@noodle-borg/service/dist/billing-public.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/customer-verifier.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/customer-verifier.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/customer-verifier.js +15 -0
- package/node_modules/@noodle-borg/service/dist/customer-verifier.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/http-util.d.ts +13 -0
- package/node_modules/@noodle-borg/service/dist/http-util.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/http-util.js +42 -2
- package/node_modules/@noodle-borg/service/dist/http-util.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/index.d.ts +2 -7
- package/node_modules/@noodle-borg/service/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/index.js +1 -6
- package/node_modules/@noodle-borg/service/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/main.js +3 -0
- package/node_modules/@noodle-borg/service/dist/main.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/options.d.ts +18 -0
- package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/persistence-options.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/persistence-options.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/persistence-options.js +22 -0
- package/node_modules/@noodle-borg/service/dist/persistence-options.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/assistant-dispatch.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/assistant-dispatch.js +10 -1
- package/node_modules/@noodle-borg/service/dist/routes/assistant-dispatch.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/assistant.d.ts +2 -0
- package/node_modules/@noodle-borg/service/dist/routes/assistant.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/assistant.js +85 -0
- package/node_modules/@noodle-borg/service/dist/routes/assistant.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-cohort.d.ts +17 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-cohort.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-cohort.js +145 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-enforcement-cohort.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-readiness.d.ts +15 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-readiness.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-readiness.js +78 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-readiness.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-validation.d.ts +15 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-validation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-validation.js +108 -0
- package/node_modules/@noodle-borg/service/dist/routes/billing-meter-validation.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/commercial-dispatch.d.ts +6 -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 +99 -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 +25 -0
- package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js +35 -0
- package/node_modules/@noodle-borg/service/dist/routes/commercial-service-deps.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js +3 -3
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve-options.d.ts +93 -0
- package/node_modules/@noodle-borg/service/dist/serve-options.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/serve-options.js +2 -0
- package/node_modules/@noodle-borg/service/dist/serve-options.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/serve.d.ts +2 -92
- package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.js +64 -59
- package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service-resource-cleanup.d.ts +22 -0
- package/node_modules/@noodle-borg/service/dist/service-resource-cleanup.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/service-resource-cleanup.js +51 -0
- package/node_modules/@noodle-borg/service/dist/service-resource-cleanup.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.js +10 -21
- package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js +7 -1
- package/node_modules/@noodle-borg/service/dist/store/cloudsql-pool.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-billing.d.ts +6 -2
- package/node_modules/@noodle-borg/service/dist/store/postgres-billing.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-billing.js +11 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-billing.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { insertAuditEvent } from '@noodle-borg/module-audit';
|
|
3
|
+
import { BILLING_METER_RETRY_IDENTITY_VERSION, deriveBillingMeterKeyGeneration, } from './meter-readiness.js';
|
|
4
|
+
import { BILLING_METER_VALIDATION_WRITER_CONTRACT_VERSION, BillingMeterValidationEpochConflictError, BillingMeterValidationEpochResultSchema, billingMeterValidationEpochRequestFingerprint, billingMeterValidationEpochSuccessAudit, normalizeBillingMeterServiceUrl, parseBillingMeterValidationEpochPrepareRequest, parseBillingMeterValidationEpochRetireRequest, } from './meter-validation-epoch.js';
|
|
5
|
+
import { normalizeBillingEmail } from './model.js';
|
|
6
|
+
import { readBillingMeterTransactionTime } from './postgres-meter-clock.js';
|
|
7
|
+
import { validateScalarId } from './postgres-records.js';
|
|
8
|
+
export const BILLING_METER_VALIDATION_EPOCH_LIFECYCLE_LOCK_KEY = 'billing-meter-validation-epoch-lifecycle:v1';
|
|
9
|
+
/** Durable, validation-only lifecycle. It never creates an active meter epoch. */
|
|
10
|
+
export class PostgresBillingMeterValidationEpochStore {
|
|
11
|
+
successAuditMode = 'transactional';
|
|
12
|
+
#pool;
|
|
13
|
+
#options;
|
|
14
|
+
constructor(pool, options) {
|
|
15
|
+
this.#pool = pool;
|
|
16
|
+
this.#options = options;
|
|
17
|
+
}
|
|
18
|
+
prepareValidationEpoch(input) {
|
|
19
|
+
const request = parseBillingMeterValidationEpochPrepareRequest(input.request);
|
|
20
|
+
return this.#mutatePrepare({
|
|
21
|
+
request,
|
|
22
|
+
actor: normalizeActor(input.actor),
|
|
23
|
+
service: normalizeBillingMeterServiceUrl(input.service),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
retireValidationEpoch(input) {
|
|
27
|
+
const request = parseBillingMeterValidationEpochRetireRequest(input.request);
|
|
28
|
+
return this.#mutateRetire({
|
|
29
|
+
request,
|
|
30
|
+
actor: normalizeActor(input.actor),
|
|
31
|
+
service: normalizeBillingMeterServiceUrl(input.service),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async #mutatePrepare(input) {
|
|
35
|
+
const action = 'validation_prepare';
|
|
36
|
+
const fingerprint = billingMeterValidationEpochRequestFingerprint({ action, ...input });
|
|
37
|
+
const idempotencyHash = hashIdempotencyKey(input.request.idempotencyKey);
|
|
38
|
+
const client = await this.#pool.connect();
|
|
39
|
+
try {
|
|
40
|
+
await client.query('BEGIN ISOLATION LEVEL READ COMMITTED');
|
|
41
|
+
await lockLifecycle(client);
|
|
42
|
+
const replay = await findOperation(client, idempotencyHash);
|
|
43
|
+
if (replay !== undefined) {
|
|
44
|
+
const result = replayOperation(replay, action, fingerprint);
|
|
45
|
+
const replayedAt = await readBillingMeterTransactionTime(client);
|
|
46
|
+
await insertAuditEvent(client, billingMeterValidationEpochSuccessAudit(action, result, input.actor), {
|
|
47
|
+
now: () => new Date(replayedAt),
|
|
48
|
+
});
|
|
49
|
+
await client.query('COMMIT');
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
const existing = await client.query(`SELECT id, state FROM billing_meter_epochs
|
|
53
|
+
WHERE state IN ('prepared', 'active')
|
|
54
|
+
ORDER BY state
|
|
55
|
+
FOR UPDATE`);
|
|
56
|
+
if (existing.rows.some((row) => row.state === 'prepared')) {
|
|
57
|
+
throw new BillingMeterValidationEpochConflictError('validation_epoch_already_prepared', 'a validation meter epoch is already prepared under a different idempotency key');
|
|
58
|
+
}
|
|
59
|
+
if (existing.rows.some((row) => row.state === 'active')) {
|
|
60
|
+
throw new BillingMeterValidationEpochConflictError('validation_epoch_state_conflict', 'a validation epoch cannot be prepared while an active meter epoch exists');
|
|
61
|
+
}
|
|
62
|
+
const bindings = this.#prepareBindings();
|
|
63
|
+
if (this.#options.preparePreflight === undefined) {
|
|
64
|
+
throw new BillingMeterValidationEpochConflictError('validation_epoch_configuration_unavailable', 'validation epoch prepare requires fresh writer-session preflight support');
|
|
65
|
+
}
|
|
66
|
+
const preparedAt = await readBillingMeterTransactionTime(client);
|
|
67
|
+
const epochId = `bmev_${(this.#options.id ?? randomUUID)()}`;
|
|
68
|
+
await client.query(`INSERT INTO billing_meter_epochs
|
|
69
|
+
(id, schema_version, state, key_generation, release_sha, retry_identity_version,
|
|
70
|
+
writer_contract_version, prepared_at)
|
|
71
|
+
VALUES ($1, 1, 'prepared', $2, $3, $4, $5, $6)`, [
|
|
72
|
+
epochId,
|
|
73
|
+
bindings.keyGeneration,
|
|
74
|
+
bindings.releaseSha,
|
|
75
|
+
bindings.retryIdentityVersion,
|
|
76
|
+
bindings.writerContractVersion,
|
|
77
|
+
preparedAt,
|
|
78
|
+
]);
|
|
79
|
+
const preflightReady = await this.#options.preparePreflight({
|
|
80
|
+
client,
|
|
81
|
+
epochId,
|
|
82
|
+
bindings,
|
|
83
|
+
});
|
|
84
|
+
if (!preflightReady) {
|
|
85
|
+
throw new BillingMeterValidationEpochConflictError('validation_epoch_configuration_unavailable', 'validation epoch prepare requires fresh compatible writer sessions');
|
|
86
|
+
}
|
|
87
|
+
const result = BillingMeterValidationEpochResultSchema.parse({
|
|
88
|
+
schemaVersion: 1,
|
|
89
|
+
epochId,
|
|
90
|
+
mode: 'validation',
|
|
91
|
+
state: 'prepared',
|
|
92
|
+
replayed: false,
|
|
93
|
+
preparedAt,
|
|
94
|
+
retiredAt: null,
|
|
95
|
+
retryIdentityVersion: bindings.retryIdentityVersion,
|
|
96
|
+
writerContractVersion: bindings.writerContractVersion,
|
|
97
|
+
serviceReleaseSha: bindings.releaseSha,
|
|
98
|
+
meteringMode: 'shadow',
|
|
99
|
+
enforcementMode: 'legacy_unchanged',
|
|
100
|
+
});
|
|
101
|
+
await insertOperation(client, {
|
|
102
|
+
action,
|
|
103
|
+
idempotencyHash,
|
|
104
|
+
fingerprint,
|
|
105
|
+
result,
|
|
106
|
+
actor: input.actor,
|
|
107
|
+
service: input.service,
|
|
108
|
+
reason: input.request.reason,
|
|
109
|
+
createdAt: preparedAt,
|
|
110
|
+
operationId: `bmeo_${(this.#options.id ?? randomUUID)()}`,
|
|
111
|
+
});
|
|
112
|
+
await insertAuditEvent(client, billingMeterValidationEpochSuccessAudit(action, result, input.actor), {
|
|
113
|
+
now: () => new Date(preparedAt),
|
|
114
|
+
});
|
|
115
|
+
await client.query('COMMIT');
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
await rollbackQuietly(client);
|
|
120
|
+
throw translateTransactionError(error);
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
client.release();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async #mutateRetire(input) {
|
|
127
|
+
const action = 'validation_retire';
|
|
128
|
+
const fingerprint = billingMeterValidationEpochRequestFingerprint({ action, ...input });
|
|
129
|
+
const idempotencyHash = hashIdempotencyKey(input.request.idempotencyKey);
|
|
130
|
+
const client = await this.#pool.connect();
|
|
131
|
+
try {
|
|
132
|
+
await client.query('BEGIN ISOLATION LEVEL READ COMMITTED');
|
|
133
|
+
await lockLifecycle(client);
|
|
134
|
+
const replay = await findOperation(client, idempotencyHash);
|
|
135
|
+
if (replay !== undefined) {
|
|
136
|
+
const result = replayOperation(replay, action, fingerprint);
|
|
137
|
+
const replayedAt = await readBillingMeterTransactionTime(client);
|
|
138
|
+
await insertAuditEvent(client, billingMeterValidationEpochSuccessAudit(action, result, input.actor), {
|
|
139
|
+
now: () => new Date(replayedAt),
|
|
140
|
+
});
|
|
141
|
+
await client.query('COMMIT');
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
const epoch = await client.query(`SELECT id, state, key_generation, release_sha, retry_identity_version,
|
|
145
|
+
writer_contract_version, prepared_at, retired_at
|
|
146
|
+
FROM billing_meter_epochs WHERE id = $1 FOR UPDATE`, [input.request.epochId]);
|
|
147
|
+
const row = epoch.rows[0];
|
|
148
|
+
if (row === undefined) {
|
|
149
|
+
throw new BillingMeterValidationEpochConflictError('validation_epoch_not_found', 'billing meter validation epoch does not exist');
|
|
150
|
+
}
|
|
151
|
+
if (row.state !== 'prepared') {
|
|
152
|
+
throw new BillingMeterValidationEpochConflictError('validation_epoch_state_conflict', 'billing meter validation epoch cannot be retired from its current state');
|
|
153
|
+
}
|
|
154
|
+
const retiredAt = await readBillingMeterTransactionTime(client);
|
|
155
|
+
await client.query(`UPDATE billing_meter_epochs SET state = 'retired', retired_at = $2 WHERE id = $1`, [row.id, retiredAt]);
|
|
156
|
+
const result = BillingMeterValidationEpochResultSchema.parse({
|
|
157
|
+
schemaVersion: 1,
|
|
158
|
+
epochId: row.id,
|
|
159
|
+
mode: 'validation',
|
|
160
|
+
state: 'retired',
|
|
161
|
+
replayed: false,
|
|
162
|
+
preparedAt: toIso(row.prepared_at),
|
|
163
|
+
retiredAt,
|
|
164
|
+
retryIdentityVersion: row.retry_identity_version,
|
|
165
|
+
writerContractVersion: row.writer_contract_version,
|
|
166
|
+
serviceReleaseSha: row.release_sha,
|
|
167
|
+
meteringMode: 'shadow',
|
|
168
|
+
enforcementMode: 'legacy_unchanged',
|
|
169
|
+
});
|
|
170
|
+
await insertOperation(client, {
|
|
171
|
+
action,
|
|
172
|
+
idempotencyHash,
|
|
173
|
+
fingerprint,
|
|
174
|
+
result,
|
|
175
|
+
actor: input.actor,
|
|
176
|
+
service: input.service,
|
|
177
|
+
reason: input.request.reason,
|
|
178
|
+
createdAt: retiredAt,
|
|
179
|
+
operationId: `bmeo_${(this.#options.id ?? randomUUID)()}`,
|
|
180
|
+
});
|
|
181
|
+
await insertAuditEvent(client, billingMeterValidationEpochSuccessAudit(action, result, input.actor), {
|
|
182
|
+
now: () => new Date(retiredAt),
|
|
183
|
+
});
|
|
184
|
+
await client.query('COMMIT');
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
await rollbackQuietly(client);
|
|
189
|
+
throw translateTransactionError(error);
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
client.release();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
#prepareBindings() {
|
|
196
|
+
const key = this.#options.billingUsageHmacKey;
|
|
197
|
+
const releaseSha = this.#options.releaseSha;
|
|
198
|
+
const retryIdentityVersion = this.#options.retryIdentityVersion ?? BILLING_METER_RETRY_IDENTITY_VERSION;
|
|
199
|
+
const writerContractVersion = this.#options.writerContractVersion ?? BILLING_METER_VALIDATION_WRITER_CONTRACT_VERSION;
|
|
200
|
+
if (key === undefined || releaseSha === undefined)
|
|
201
|
+
return unavailableBindings();
|
|
202
|
+
let keyGeneration;
|
|
203
|
+
try {
|
|
204
|
+
keyGeneration = deriveBillingMeterKeyGeneration(key);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return unavailableBindings();
|
|
208
|
+
}
|
|
209
|
+
if (!/^[0-9a-f]{40}$/.test(releaseSha) ||
|
|
210
|
+
retryIdentityVersion !== BILLING_METER_RETRY_IDENTITY_VERSION ||
|
|
211
|
+
writerContractVersion !== BILLING_METER_VALIDATION_WRITER_CONTRACT_VERSION) {
|
|
212
|
+
return unavailableBindings();
|
|
213
|
+
}
|
|
214
|
+
return { keyGeneration, releaseSha, retryIdentityVersion, writerContractVersion };
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function normalizeActor(actor) {
|
|
218
|
+
return {
|
|
219
|
+
...actor,
|
|
220
|
+
subject: validateScalarId('billing meter validation actor subject', actor.subject),
|
|
221
|
+
email: normalizeBillingEmail(actor.email),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function unavailableBindings() {
|
|
225
|
+
throw new BillingMeterValidationEpochConflictError('validation_epoch_configuration_unavailable', 'validation epoch prepare requires a valid HMAC key, release SHA, and writer contract');
|
|
226
|
+
}
|
|
227
|
+
function hashIdempotencyKey(value) {
|
|
228
|
+
return createHash('sha256').update(value).digest('hex');
|
|
229
|
+
}
|
|
230
|
+
function lockLifecycle(client) {
|
|
231
|
+
return client.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [
|
|
232
|
+
BILLING_METER_VALIDATION_EPOCH_LIFECYCLE_LOCK_KEY,
|
|
233
|
+
]);
|
|
234
|
+
}
|
|
235
|
+
async function findOperation(client, idempotencyHash) {
|
|
236
|
+
const operation = await client.query(`SELECT action, request_fingerprint, result
|
|
237
|
+
FROM billing_meter_epoch_operations
|
|
238
|
+
WHERE idempotency_key_hash = $1`, [idempotencyHash]);
|
|
239
|
+
return operation.rows[0];
|
|
240
|
+
}
|
|
241
|
+
function replayOperation(row, action, fingerprint) {
|
|
242
|
+
if (row.action !== action || row.request_fingerprint !== fingerprint) {
|
|
243
|
+
throw new BillingMeterValidationEpochConflictError('idempotency_key_conflict', 'idempotency key was already used by a different request or actor');
|
|
244
|
+
}
|
|
245
|
+
const result = BillingMeterValidationEpochResultSchema.parse(row.result);
|
|
246
|
+
return { ...result, replayed: true };
|
|
247
|
+
}
|
|
248
|
+
async function insertOperation(client, input) {
|
|
249
|
+
await client.query(`INSERT INTO billing_meter_epoch_operations
|
|
250
|
+
(operation_id, action, idempotency_key_hash, request_fingerprint, epoch_id, result,
|
|
251
|
+
actor_subject, actor_email, service_origin, reason, created_at)
|
|
252
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)`, [
|
|
253
|
+
input.operationId,
|
|
254
|
+
input.action,
|
|
255
|
+
input.idempotencyHash,
|
|
256
|
+
input.fingerprint,
|
|
257
|
+
input.result.epochId,
|
|
258
|
+
JSON.stringify(input.result),
|
|
259
|
+
input.actor.subject,
|
|
260
|
+
input.actor.email,
|
|
261
|
+
input.service,
|
|
262
|
+
input.reason,
|
|
263
|
+
input.createdAt,
|
|
264
|
+
]);
|
|
265
|
+
}
|
|
266
|
+
function translateTransactionError(error) {
|
|
267
|
+
const code = typeof error === 'object' && error !== null && 'code' in error
|
|
268
|
+
? String(error.code)
|
|
269
|
+
: undefined;
|
|
270
|
+
if (code === '40001' || code === '40P01') {
|
|
271
|
+
return new BillingMeterValidationEpochConflictError('serialization_conflict', 'billing meter validation epoch state changed concurrently; retry the exact request');
|
|
272
|
+
}
|
|
273
|
+
return error;
|
|
274
|
+
}
|
|
275
|
+
function toIso(value) {
|
|
276
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
277
|
+
if (!Number.isFinite(date.getTime()))
|
|
278
|
+
throw new Error('billing meter epoch timestamp is invalid');
|
|
279
|
+
return date.toISOString();
|
|
280
|
+
}
|
|
281
|
+
async function rollbackQuietly(client) {
|
|
282
|
+
try {
|
|
283
|
+
await client.query('ROLLBACK');
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
// Preserve the original transaction failure.
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=postgres-meter-epochs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-epochs.js","sourceRoot":"","sources":["../../src/billing/postgres-meter-epochs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,EACL,oCAAoC,EACpC,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gDAAgD,EAChD,wCAAwC,EAGxC,uCAAuC,EAGvC,6CAA6C,EAC7C,uCAAuC,EACvC,+BAA+B,EAC/B,8CAA8C,EAC9C,6CAA6C,GAC9C,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,iDAAiD,GAC5D,6CAA6C,CAAC;AA0ChD,kFAAkF;AAClF,MAAM,OAAO,wCAAwC;IAC1C,gBAAgB,GAAG,eAAwB,CAAC;IAC5C,KAAK,CAAO;IACZ,QAAQ,CAAkD;IAEnE,YAAY,IAAU,EAAE,OAAwD;QAC9E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG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AAS,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,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAClG,OAAO,IAAI,CAAC,WAAW,EAAE,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,16 @@
|
|
|
1
|
+
import type { PoolClient } from 'pg';
|
|
2
|
+
export declare const BILLING_METER_SCHEDULER_RUN_RETENTION_DAYS = 30;
|
|
3
|
+
export declare const BILLING_METER_OPERATIONAL_EVIDENCE_BATCH_SIZE = 25000;
|
|
4
|
+
export interface BillingMeterOperationalEvidenceCompactionResult {
|
|
5
|
+
readonly reconciliationRunsDeleted: number;
|
|
6
|
+
readonly schedulerRunsDeleted: number;
|
|
7
|
+
readonly maintenanceRunsDeleted: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Bound immutable operational evidence without erasing sticky epoch drift or the last live
|
|
11
|
+
* scheduler state. Per-window reconciliation details expire with their aggregate/window horizon.
|
|
12
|
+
* The caller supplies the database-authored maintenance decision timestamp.
|
|
13
|
+
*/
|
|
14
|
+
export declare function compactBillingMeterOperationalEvidence(client: PoolClient, decisionAt: string): Promise<BillingMeterOperationalEvidenceCompactionResult>;
|
|
15
|
+
export declare function compactBillingMeterMaintenanceEvidence(client: PoolClient, protectedRunId?: string): Promise<number>;
|
|
16
|
+
//# sourceMappingURL=postgres-meter-evidence-retention.d.ts.map
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-evidence-retention.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-evidence-retention.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-meter-evidence-retention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAGrC,eAAO,MAAM,0CAA0C,KAAK,CAAC;AAC7D,eAAO,MAAM,6CAA6C,QAAS,CAAC;AAEpE,MAAM,WAAW,+CAA+C;IAC9D,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,+CAA+C,CAAC,CAgG1D;AAED,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,UAAU,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { BILLING_METER_AGGREGATE_RETENTION_MONTHS } from './meter-readiness.js';
|
|
2
|
+
export const BILLING_METER_SCHEDULER_RUN_RETENTION_DAYS = 30;
|
|
3
|
+
export const BILLING_METER_OPERATIONAL_EVIDENCE_BATCH_SIZE = 25_000;
|
|
4
|
+
/**
|
|
5
|
+
* Bound immutable operational evidence without erasing sticky epoch drift or the last live
|
|
6
|
+
* scheduler state. Per-window reconciliation details expire with their aggregate/window horizon.
|
|
7
|
+
* The caller supplies the database-authored maintenance decision timestamp.
|
|
8
|
+
*/
|
|
9
|
+
export async function compactBillingMeterOperationalEvidence(client, decisionAt) {
|
|
10
|
+
const reconciliations = await client.query(`
|
|
11
|
+
WITH latest_overall AS (
|
|
12
|
+
SELECT DISTINCT ON (epoch_id, window_start, window_end) run_id
|
|
13
|
+
FROM billing_meter_reconciliation_runs
|
|
14
|
+
ORDER BY epoch_id, window_start, window_end,
|
|
15
|
+
sealed DESC, checked_at DESC, run_id DESC
|
|
16
|
+
), latest_failed AS (
|
|
17
|
+
SELECT DISTINCT ON (epoch_id, window_start, window_end) run_id
|
|
18
|
+
FROM billing_meter_reconciliation_runs
|
|
19
|
+
WHERE status = 'failed'
|
|
20
|
+
ORDER BY epoch_id, window_start, window_end, checked_at DESC, run_id DESC
|
|
21
|
+
), retained AS (
|
|
22
|
+
SELECT run_id FROM latest_overall
|
|
23
|
+
UNION
|
|
24
|
+
SELECT run_id FROM latest_failed
|
|
25
|
+
), candidates AS MATERIALIZED (
|
|
26
|
+
SELECT evidence.ctid
|
|
27
|
+
FROM billing_meter_reconciliation_runs AS evidence
|
|
28
|
+
WHERE (
|
|
29
|
+
evidence.window_end +
|
|
30
|
+
interval '${BILLING_METER_AGGREGATE_RETENTION_MONTHS} months' <= $1::timestamptz
|
|
31
|
+
AND NOT EXISTS (
|
|
32
|
+
SELECT 1
|
|
33
|
+
FROM billing_meter_usage_events AS receipt
|
|
34
|
+
WHERE receipt.epoch_id = evidence.epoch_id
|
|
35
|
+
AND receipt.window_start = evidence.window_start
|
|
36
|
+
AND receipt.window_end = evidence.window_end
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
OR NOT EXISTS (
|
|
40
|
+
SELECT 1 FROM retained WHERE retained.run_id = evidence.run_id
|
|
41
|
+
)
|
|
42
|
+
ORDER BY
|
|
43
|
+
(evidence.window_end +
|
|
44
|
+
interval '${BILLING_METER_AGGREGATE_RETENTION_MONTHS} months' > $1::timestamptz),
|
|
45
|
+
evidence.checked_at,
|
|
46
|
+
evidence.run_id
|
|
47
|
+
LIMIT ${BILLING_METER_OPERATIONAL_EVIDENCE_BATCH_SIZE}
|
|
48
|
+
)
|
|
49
|
+
DELETE FROM billing_meter_reconciliation_runs AS evidence
|
|
50
|
+
USING candidates
|
|
51
|
+
WHERE evidence.ctid = candidates.ctid
|
|
52
|
+
`, [decisionAt]);
|
|
53
|
+
const maintenanceRunsDeleted = await compactBillingMeterMaintenanceEvidence(client);
|
|
54
|
+
const schedulerTable = await client.query(`SELECT to_regclass('billing_meter_scheduler_runs') IS NOT NULL AS present`);
|
|
55
|
+
if (schedulerTable.rows[0]?.present !== true) {
|
|
56
|
+
return {
|
|
57
|
+
reconciliationRunsDeleted: safeRowCount(reconciliations.rowCount),
|
|
58
|
+
schedulerRunsDeleted: 0,
|
|
59
|
+
maintenanceRunsDeleted,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const scheduler = await client.query(`WITH latest_completed AS (
|
|
63
|
+
SELECT run_id
|
|
64
|
+
FROM billing_meter_scheduler_runs
|
|
65
|
+
WHERE completed_at IS NOT NULL
|
|
66
|
+
ORDER BY completed_at DESC, run_sequence DESC
|
|
67
|
+
LIMIT 1
|
|
68
|
+
), latest_running AS (
|
|
69
|
+
SELECT run_id
|
|
70
|
+
FROM billing_meter_scheduler_runs
|
|
71
|
+
WHERE status = 'running'
|
|
72
|
+
ORDER BY started_at DESC, run_sequence DESC
|
|
73
|
+
LIMIT 1
|
|
74
|
+
), retained AS (
|
|
75
|
+
SELECT run_id FROM latest_completed
|
|
76
|
+
UNION
|
|
77
|
+
SELECT run_id FROM latest_running
|
|
78
|
+
), candidates AS MATERIALIZED (
|
|
79
|
+
SELECT evidence.ctid
|
|
80
|
+
FROM billing_meter_scheduler_runs AS evidence
|
|
81
|
+
WHERE coalesce(evidence.completed_at, evidence.started_at) <=
|
|
82
|
+
$1::timestamptz - interval '${BILLING_METER_SCHEDULER_RUN_RETENTION_DAYS} days'
|
|
83
|
+
AND NOT EXISTS (
|
|
84
|
+
SELECT 1 FROM retained WHERE retained.run_id = evidence.run_id
|
|
85
|
+
)
|
|
86
|
+
ORDER BY coalesce(evidence.completed_at, evidence.started_at), evidence.run_sequence
|
|
87
|
+
LIMIT ${BILLING_METER_OPERATIONAL_EVIDENCE_BATCH_SIZE}
|
|
88
|
+
)
|
|
89
|
+
DELETE FROM billing_meter_scheduler_runs AS evidence
|
|
90
|
+
USING candidates
|
|
91
|
+
WHERE evidence.ctid = candidates.ctid`, [decisionAt]);
|
|
92
|
+
return {
|
|
93
|
+
reconciliationRunsDeleted: safeRowCount(reconciliations.rowCount),
|
|
94
|
+
schedulerRunsDeleted: safeRowCount(scheduler.rowCount),
|
|
95
|
+
maintenanceRunsDeleted,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export async function compactBillingMeterMaintenanceEvidence(client, protectedRunId) {
|
|
99
|
+
const maintenance = await client.query(`WITH latest_terminal AS (
|
|
100
|
+
SELECT DISTINCT ON (status) run_id
|
|
101
|
+
FROM billing_meter_maintenance_runs
|
|
102
|
+
WHERE status IN ('succeeded', 'failed')
|
|
103
|
+
ORDER BY status, completed_at DESC, started_at DESC, run_id DESC
|
|
104
|
+
), candidates AS MATERIALIZED (
|
|
105
|
+
SELECT evidence.ctid
|
|
106
|
+
FROM billing_meter_maintenance_runs AS evidence
|
|
107
|
+
WHERE evidence.status <> 'running'
|
|
108
|
+
AND ($1::text IS NULL OR evidence.run_id <> $1)
|
|
109
|
+
AND NOT EXISTS (
|
|
110
|
+
SELECT 1 FROM latest_terminal WHERE latest_terminal.run_id = evidence.run_id
|
|
111
|
+
)
|
|
112
|
+
ORDER BY evidence.completed_at, evidence.started_at, evidence.run_id
|
|
113
|
+
LIMIT ${BILLING_METER_OPERATIONAL_EVIDENCE_BATCH_SIZE}
|
|
114
|
+
)
|
|
115
|
+
DELETE FROM billing_meter_maintenance_runs AS evidence
|
|
116
|
+
USING candidates
|
|
117
|
+
WHERE evidence.ctid = candidates.ctid`, [protectedRunId ?? null]);
|
|
118
|
+
return safeRowCount(maintenance.rowCount);
|
|
119
|
+
}
|
|
120
|
+
function safeRowCount(value) {
|
|
121
|
+
if (value === null || !Number.isSafeInteger(value) || value < 0) {
|
|
122
|
+
throw new Error('billing meter evidence compaction returned an invalid row count');
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=postgres-meter-evidence-retention.js.map
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-evidence-retention.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-evidence-retention.js","sourceRoot":"","sources":["../../src/billing/postgres-meter-evidence-retention.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wCAAwC,EAAE,MAAM,sBAAsB,CAAC;AAEhF,MAAM,CAAC,MAAM,0CAA0C,GAAG,EAAE,CAAC;AAC7D,MAAM,CAAC,MAAM,6CAA6C,GAAG,MAAM,CAAC;AAQpE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,MAAkB,EAClB,UAAkB;IAElB,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,KAAK,CACxC;;;;;;;;;;;;;;;;;;;;sBAoBkB,wCAAwC;;;;;;;;;;;;;;uBAcvC,wCAAwC;;;cAGjD,6CAA6C;;;;;GAKxD,EACC,CAAC,UAAU,CAAC,CACb,CAAC;IACF,MAAM,sBAAsB,GAAG,MAAM,sCAAsC,CAAC,MAAM,CAAC,CAAC;IACpF,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,KAAK,CACvC,2EAA2E,CAC5E,CAAC;IACF,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;QAC7C,OAAO;YACL,yBAAyB,EAAE,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC;YACjE,oBAAoB,EAAE,CAAC;YACvB,sBAAsB;SACvB,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,KAAK,CAClC;;;;;;;;;;;;;;;;;;;;6CAoByC,0CAA0C;;;;;eAKxE,6CAA6C;;;;2CAIjB,EACvC,CAAC,UAAU,CAAC,CACb,CAAC;IACF,OAAO;QACL,yBAAyB,EAAE,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC;QACjE,oBAAoB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC;QACtD,sBAAsB;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,MAAkB,EAClB,cAAuB;IAEvB,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,KAAK,CACpC;;;;;;;;;;;;;;cAcU,6CAA6C;;;;0CAIjB,EACtC,CAAC,cAAc,IAAI,IAAI,CAAC,CACzB,CAAC;IACF,OAAO,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,YAAY,CAAC,KAAoB;IACxC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Pool } from 'pg';
|
|
2
|
+
import type { BillingMeterLiveValidationRecordInput, BillingMeterLiveValidationRecordResult, BillingMeterLiveValidationWriter, BillingMeterWriterHealthSnapshot, BillingMeterWriterSessionIdentity } from './meter-live-validation.js';
|
|
3
|
+
import type { BillingMeterValidationEpochPreparePreflight } from './postgres-meter-epochs.js';
|
|
4
|
+
export declare const BILLING_METER_WRITER_SESSION_FRESHNESS_MS: number;
|
|
5
|
+
export interface PostgresBillingMeterLiveValidationWriterOptions {
|
|
6
|
+
readonly retryWindowMs?: number;
|
|
7
|
+
readonly connectionTimeoutMs?: number;
|
|
8
|
+
readonly lockTimeoutMs?: number;
|
|
9
|
+
readonly statementTimeoutMs?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Atomically register one service boot. A compatible already-prepared epoch receives an unarmed candidate
|
|
13
|
+
* baseline in this same lifecycle-locked transaction, including when the replica is otherwise idle.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerPostgresBillingMeterWriterSession(pool: Pool, identity: BillingMeterWriterSessionIdentity, options?: PostgresBillingMeterLiveValidationWriterOptions): Promise<PostgresBillingMeterLiveValidationWriter>;
|
|
16
|
+
/**
|
|
17
|
+
* Lifecycle prepare preflight. It runs after the epoch row is inserted but before that transaction commits.
|
|
18
|
+
* Every currently fresh open session must match, and all receive unarmed candidate baselines before prepare
|
|
19
|
+
* can succeed. Each local mirror establishes its exact zero point in a later fenced arm transaction.
|
|
20
|
+
*/
|
|
21
|
+
export declare const prepareBillingMeterWriterEpochBaselines: BillingMeterValidationEpochPreparePreflight;
|
|
22
|
+
export declare class PostgresBillingMeterLiveValidationWriter implements BillingMeterLiveValidationWriter {
|
|
23
|
+
#private;
|
|
24
|
+
readonly session: BillingMeterWriterSessionIdentity;
|
|
25
|
+
constructor(pool: Pool, session: BillingMeterWriterSessionIdentity, options?: PostgresBillingMeterLiveValidationWriterOptions);
|
|
26
|
+
record(input: BillingMeterLiveValidationRecordInput): Promise<BillingMeterLiveValidationRecordResult>;
|
|
27
|
+
reportHealth(snapshot: BillingMeterWriterHealthSnapshot): Promise<undefined | {
|
|
28
|
+
readonly armEpochId: string;
|
|
29
|
+
}>;
|
|
30
|
+
armEpoch(epochId: string, snapshot: BillingMeterWriterHealthSnapshot): Promise<void>;
|
|
31
|
+
close(snapshot: BillingMeterWriterHealthSnapshot): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=postgres-meter-live-validation.d.ts.map
|
package/node_modules/@noodle-borg/service/dist/billing/postgres-meter-live-validation.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-meter-live-validation.d.ts","sourceRoot":"","sources":["../../src/billing/postgres-meter-live-validation.ts"],"names":[],"mappings":"AAAA,OA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