@wildo-ai/saas-backend-lib 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1056) hide show
  1. package/dist/esm/__tests__/fixture-deep-partial.d.ts.map +1 -1
  2. package/dist/esm/__tests__/integration/redis-integration-gate.d.ts.map +1 -1
  3. package/dist/esm/__tests__/setup.d.ts.map +1 -1
  4. package/dist/esm/__tests__/test-container.d.ts.map +1 -1
  5. package/dist/esm/applications/models/applications.backend.schemas.d.ts.map +1 -1
  6. package/dist/esm/applications/seeds/application-metadata-defaults.seeds.d.ts.map +1 -1
  7. package/dist/esm/applications/services/worker-remote-client-factory.backend.service.d.ts.map +1 -1
  8. package/dist/esm/applications/services/worker-remote-client-factory.backend.service.js.map +1 -1
  9. package/dist/esm/base-classes/models/manual-controllers.backend.definition.d.ts.map +1 -1
  10. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js.map +1 -1
  11. package/dist/esm/base-classes/models/repositories.backend.schemas.d.ts.map +1 -1
  12. package/dist/esm/base-classes/services/__tests__/mock-resource-operation-helper.service.d.ts +1 -1
  13. package/dist/esm/base-classes/services/__tests__/mock-resource-operation-helper.service.d.ts.map +1 -1
  14. package/dist/esm/base-classes/services/batches/batches-cronjobs-custom-execution.service.d.ts.map +1 -1
  15. package/dist/esm/base-classes/services/batches/batches-cronjobs-executor.backend.service.d.ts.map +1 -1
  16. package/dist/esm/base-classes/services/batches/batches-cronjobs-resource-execution.backend.service.d.ts.map +1 -1
  17. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.d.ts.map +1 -1
  18. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.js.map +1 -1
  19. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.d.ts.map +1 -1
  20. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js +12 -1
  21. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js.map +1 -1
  22. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.d.ts.map +1 -1
  23. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.js.map +1 -1
  24. package/dist/esm/base-classes/services/batches/resource-retention-sweep.batch.backend.service.d.ts.map +1 -1
  25. package/dist/esm/base-classes/services/batches/suspension-reactivation-sweep.batch.backend.service.d.ts.map +1 -1
  26. package/dist/esm/base-classes/services/controllers/abstract-controller.backend.service.d.ts.map +1 -1
  27. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.d.ts.map +1 -1
  28. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.js.map +1 -1
  29. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.d.ts.map +1 -1
  30. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.js.map +1 -1
  31. package/dist/esm/base-classes/services/controllers/utils/audit-access-fields.backend.utils.d.ts.map +1 -1
  32. package/dist/esm/base-classes/services/controllers/utils/operation-response-serializer.backend.utils.d.ts.map +1 -1
  33. package/dist/esm/base-classes/services/controllers/validate-field-handler.backend.service.d.ts.map +1 -1
  34. package/dist/esm/base-classes/services/repositories/__tests__/method-span-scan.guard-helpers.d.ts.map +1 -1
  35. package/dist/esm/base-classes/services/repositories/__tests__/mock-repositories-registry-handler.service.d.ts.map +1 -1
  36. package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.d.ts.map +1 -1
  37. package/dist/esm/base-classes/services/repositories/http-api/http-api-filter-translation.backend.d.ts.map +1 -1
  38. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.d.ts.map +1 -1
  39. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js +13 -4
  40. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js.map +1 -1
  41. package/dist/esm/base-classes/services/repositories/http-api/http-api-query.backend.d.ts.map +1 -1
  42. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.d.ts.map +1 -1
  43. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js +17 -0
  44. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js.map +1 -1
  45. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.d.ts.map +1 -1
  46. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.js.map +1 -1
  47. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.d.ts.map +1 -1
  48. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.js.map +1 -1
  49. package/dist/esm/base-classes/services/repositories/http-api/http-api-row-projection.backend.d.ts.map +1 -1
  50. package/dist/esm/base-classes/services/repositories/http-api/http-api-subject-erasure-effect.backend.d.ts.map +1 -1
  51. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.d.ts.map +1 -1
  52. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.js.map +1 -1
  53. package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.d.ts.map +1 -1
  54. package/dist/esm/base-classes/services/repositories/http-api/odoo-jsonrpc-compiler.backend.d.ts.map +1 -1
  55. package/dist/esm/base-classes/services/repositories/http-api/rest-json-query-compiler.backend.d.ts.map +1 -1
  56. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.d.ts.map +1 -1
  57. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.js.map +1 -1
  58. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.d.ts.map +1 -1
  59. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.d.ts.map +1 -1
  60. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts +57 -0
  61. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts.map +1 -1
  62. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js +95 -2
  63. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js.map +1 -1
  64. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.d.ts.map +1 -1
  65. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.js.map +1 -1
  66. package/dist/esm/base-classes/services/repositories/repository-guarded-mutation.backend.types.d.ts.map +1 -1
  67. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts +5 -2
  68. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts.map +1 -1
  69. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js +14 -3
  70. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js.map +1 -1
  71. package/dist/esm/base-classes/services/repositories/repository-version-metadata.backend.utils.d.ts.map +1 -1
  72. package/dist/esm/base-classes/services/repositories/resource-write-integrity.backend.d.ts.map +1 -1
  73. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.d.ts +72 -0
  74. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.d.ts.map +1 -0
  75. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.js +88 -0
  76. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.js.map +1 -0
  77. package/dist/esm/base-classes/services/repositories/unique-constraint-conflict-reference.backend.d.ts.map +1 -1
  78. package/dist/esm/base-classes/services/resource-operations-helper.backend.service.d.ts.map +1 -1
  79. package/dist/esm/base-classes/services/services/__tests__/mock-services-registry-handler.service.d.ts.map +1 -1
  80. package/dist/esm/base-classes/services/services/__tests__/mock-system-access.service.d.ts.map +1 -1
  81. package/dist/esm/base-classes/services/services/read-only-field-change.backend.utils.d.ts.map +1 -1
  82. package/dist/esm/base-classes/services/services/resource-operation-audit-emission.backend.utils.d.ts.map +1 -1
  83. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.d.ts.map +1 -1
  84. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.js.map +1 -1
  85. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts.map +1 -1
  86. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts.map +1 -1
  87. package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.d.ts.map +1 -1
  88. package/dist/esm/base-classes/services/services/resource-operation-server-injected-fields.backend.utils.d.ts.map +1 -1
  89. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts.map +1 -1
  90. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts.map +1 -1
  91. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js.map +1 -1
  92. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.d.ts.map +1 -1
  93. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.js.map +1 -1
  94. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts.map +1 -1
  95. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js +44 -6
  96. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js.map +1 -1
  97. package/dist/esm/base-classes/services/services/system-access.backend.service.d.ts.map +1 -1
  98. package/dist/esm/base-classes/services/services/system-access.backend.service.js.map +1 -1
  99. package/dist/esm/base-classes/utils/backend-type-utils.d.ts.map +1 -1
  100. package/dist/esm/base-classes/utils/single-subject-addressing.backend.utils.d.ts.map +1 -1
  101. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.d.ts.map +1 -1
  102. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.js.map +1 -1
  103. package/dist/esm/billing/batches/usage-flush.batch.backend.service.d.ts.map +1 -1
  104. package/dist/esm/billing/batches/usage-flush.batch.backend.service.js.map +1 -1
  105. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.d.ts.map +1 -1
  106. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.js.map +1 -1
  107. package/dist/esm/billing/services/back-office/abstract-billing.backend.service.d.ts.map +1 -1
  108. package/dist/esm/billing/services/back-office/billing-feature-sync.backend.service.d.ts.map +1 -1
  109. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts +1 -1
  110. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts.map +1 -1
  111. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js +5 -4
  112. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js.map +1 -1
  113. package/dist/esm/billing/services/back-office/billing-state.backend.service.d.ts.map +1 -1
  114. package/dist/esm/billing/services/back-office/billing-state.backend.service.js +11 -1
  115. package/dist/esm/billing/services/back-office/billing-state.backend.service.js.map +1 -1
  116. package/dist/esm/billing/services/back-office/billing-subject-erasure-effect.backend.d.ts.map +1 -1
  117. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.d.ts.map +1 -1
  118. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.js.map +1 -1
  119. package/dist/esm/billing/services/back-office/usage-metering.backend.service.d.ts.map +1 -1
  120. package/dist/esm/billing/services/back-office/usage-metering.backend.service.js.map +1 -1
  121. package/dist/esm/billing/services/billing-adapter-registry.backend.d.ts.map +1 -1
  122. package/dist/esm/billing/services/billing-adapter-registry.backend.js.map +1 -1
  123. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.d.ts.map +1 -1
  124. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.js.map +1 -1
  125. package/dist/esm/billing/services/billing.utils.d.ts.map +1 -1
  126. package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.d.ts.map +1 -1
  127. package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.js.map +1 -1
  128. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts +32 -0
  129. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts.map +1 -1
  130. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js +32 -1
  131. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js.map +1 -1
  132. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.d.ts.map +1 -1
  133. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.js.map +1 -1
  134. package/dist/esm/billing/services/custom-impl/credit-pool.custom-ops.custom-impl.backend.service.d.ts.map +1 -1
  135. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.d.ts.map +1 -1
  136. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.js.map +1 -1
  137. package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.d.ts.map +1 -1
  138. package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.js.map +1 -1
  139. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts +9 -6
  140. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts.map +1 -1
  141. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js +9 -6
  142. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js.map +1 -1
  143. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.d.ts.map +1 -1
  144. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.js.map +1 -1
  145. package/dist/esm/billing/services/webhooks/billing-webhook-adapter.backend.service.d.ts.map +1 -1
  146. package/dist/esm/billing/services/webhooks/billing-webhook-capability-handler.backend.service.d.ts.map +1 -1
  147. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.d.ts.map +1 -1
  148. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js +50 -3
  149. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js.map +1 -1
  150. package/dist/esm/billing/testing/billing-test-fixtures.d.ts.map +1 -1
  151. package/dist/esm/billing/testing/mock-billing-provider.d.ts.map +1 -1
  152. package/dist/esm/billing/testing/mock-billing-provider.js.map +1 -1
  153. package/dist/esm/charts/controllers/chart.backend.controller.d.ts.map +1 -1
  154. package/dist/esm/charts/services/chart-registry.backend.service.d.ts +80 -7
  155. package/dist/esm/charts/services/chart-registry.backend.service.d.ts.map +1 -1
  156. package/dist/esm/charts/services/chart-registry.backend.service.js +115 -8
  157. package/dist/esm/charts/services/chart-registry.backend.service.js.map +1 -1
  158. package/dist/esm/companion-exports.d.ts.map +1 -1
  159. package/dist/esm/compliance/audit-trails/audit-logs.custom-impl.backend.service.d.ts.map +1 -1
  160. package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.d.ts.map +1 -1
  161. package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.js.map +1 -1
  162. package/dist/esm/compliance/audit-trails/batches/immudb-audit-reconcile.batch.backend.service.d.ts.map +1 -1
  163. package/dist/esm/compliance/audit-trails/batches/siem-webhook-delivery.batch.backend.service.d.ts.map +1 -1
  164. package/dist/esm/compliance/audit-trails/services/__tests__/mock-audit-logs.service.d.ts.map +1 -1
  165. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.d.ts.map +1 -1
  166. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.js.map +1 -1
  167. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts +107 -4
  168. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts.map +1 -1
  169. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js +176 -5
  170. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js.map +1 -1
  171. package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.d.ts.map +1 -1
  172. package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.js.map +1 -1
  173. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.d.ts.map +1 -1
  174. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.js.map +1 -1
  175. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.d.ts.map +1 -1
  176. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.js.map +1 -1
  177. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.d.ts.map +1 -1
  178. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.js.map +1 -1
  179. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.d.ts.map +1 -1
  180. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js +21 -0
  181. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js.map +1 -1
  182. package/dist/esm/compliance/audit-trails/services/utils/ocsf-class-mapping.backend.utils.d.ts.map +1 -1
  183. package/dist/esm/compliance/audit-trails/services/utils/siem-dictionary.backend.utils.d.ts.map +1 -1
  184. package/dist/esm/compliance/audit-trails/services/utils/siem-ocsf-projection.backend.utils.d.ts.map +1 -1
  185. package/dist/esm/compliance/audit-trails/services/utils/siem-projection-contract.backend.utils.d.ts.map +1 -1
  186. package/dist/esm/compliance/audit-trails/utils/audit-actor.backend.utils.d.ts.map +1 -1
  187. package/dist/esm/compliance/audit-trails/utils/layer2-audit-provider-boot-diagnostic.backend.utils.d.ts.map +1 -1
  188. package/dist/esm/compliance/index.d.ts.map +1 -1
  189. package/dist/esm/compliance/privacy/retention-hide-predicate.backend.d.ts.map +1 -1
  190. package/dist/esm/compliance/privacy/services/subject-erasure-external-effects.backend.service.d.ts.map +1 -1
  191. package/dist/esm/compliance/privacy/services/subject-session-revocation.backend.service.d.ts.map +1 -1
  192. package/dist/esm/config/bootstrap/application-runtime-profile.backend.d.ts.map +1 -1
  193. package/dist/esm/config/bootstrap/application-runtime-profile.backend.js.map +1 -1
  194. package/dist/esm/config/bootstrap/minion-initialization-projection.backend.d.ts.map +1 -1
  195. package/dist/esm/config/bootstrap/runtime-principal-attestation.backend.service.d.ts.map +1 -1
  196. package/dist/esm/config/bootstrap/runtime-principal-attestation.backend.service.js +3 -0
  197. package/dist/esm/config/bootstrap/runtime-principal-attestation.backend.service.js.map +1 -1
  198. package/dist/esm/config/bootstrap/runtime-principal.backend.service.d.ts.map +1 -1
  199. package/dist/esm/config/custom/application-config-controller.backend.service.d.ts.map +1 -1
  200. package/dist/esm/config/models/app-config-secrets.backend.schemas.d.ts.map +1 -1
  201. package/dist/esm/config/models/app-config.backend-authored.definitions.d.ts.map +1 -1
  202. package/dist/esm/config/models/app-config.backend.schemas.d.ts +4 -4
  203. package/dist/esm/config/models/app-config.backend.schemas.d.ts.map +1 -1
  204. package/dist/esm/config/models/app-config.backend.schemas.js.map +1 -1
  205. package/dist/esm/config/models/app-env-config.backend.schemas.d.ts.map +1 -1
  206. package/dist/esm/config/models/apps-manager-transport.backend.definitions.d.ts +36 -0
  207. package/dist/esm/config/models/apps-manager-transport.backend.definitions.d.ts.map +1 -0
  208. package/dist/esm/config/models/apps-manager-transport.backend.definitions.js +36 -0
  209. package/dist/esm/config/models/apps-manager-transport.backend.definitions.js.map +1 -0
  210. package/dist/esm/config/models/config-mutation-boundary.utils.d.ts.map +1 -1
  211. package/dist/esm/config/models/postgresql-env-config.backend.schemas.d.ts.map +1 -1
  212. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.d.ts.map +1 -1
  213. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.js.map +1 -1
  214. package/dist/esm/config/models/runtime-topology.backend.contracts.d.ts.map +1 -1
  215. package/dist/esm/config/services/__tests__/mock-app-configuration.service.d.ts.map +1 -1
  216. package/dist/esm/config/services/app-configuration-loader.backend.service.d.ts.map +1 -1
  217. package/dist/esm/config/services/app-configuration-loader.backend.service.js +3 -0
  218. package/dist/esm/config/services/app-configuration-loader.backend.service.js.map +1 -1
  219. package/dist/esm/config/services/app-configuration.backend.service.d.ts.map +1 -1
  220. package/dist/esm/config/services/app-configuration.backend.service.js.map +1 -1
  221. package/dist/esm/config/services/app-configuration.backend.utils.d.ts.map +1 -1
  222. package/dist/esm/config/services/app-configuration.backend.utils.js.map +1 -1
  223. package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts +12 -0
  224. package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts.map +1 -1
  225. package/dist/esm/config/services/application-startup-config-validator.backend.service.js +28 -0
  226. package/dist/esm/config/services/application-startup-config-validator.backend.service.js.map +1 -1
  227. package/dist/esm/data-seeding/batches/data-seeding-run-cleanup.batch.backend.service.d.ts.map +1 -1
  228. package/dist/esm/data-seeding/batches/data-seeding-scheduled-rerun.batch.backend.service.d.ts.map +1 -1
  229. package/dist/esm/data-seeding/controllers/data-seeding-admin.backend.contracts.d.ts.map +1 -1
  230. package/dist/esm/data-seeding/controllers/data-seeding-admin.backend.controller.d.ts.map +1 -1
  231. package/dist/esm/data-seeding/data-seeding-models.d.ts.map +1 -1
  232. package/dist/esm/data-seeding/models/business-key-resolver.shared.utils.d.ts.map +1 -1
  233. package/dist/esm/data-seeding/models/data-seed-execution-context.shared.types.d.ts.map +1 -1
  234. package/dist/esm/data-seeding/models/data-seed-migrator-runner.shared.utils.d.ts.map +1 -1
  235. package/dist/esm/data-seeding/models/data-seed-reconciler.shared.utils.d.ts.map +1 -1
  236. package/dist/esm/data-seeding/models/data-seed-row-metadata.shared.schemas.d.ts.map +1 -1
  237. package/dist/esm/data-seeding/models/data-seed-row-metadata.shared.utils.d.ts.map +1 -1
  238. package/dist/esm/data-seeding/models/data-seed-run.shared.resources-config.schemas.d.ts.map +1 -1
  239. package/dist/esm/data-seeding/models/data-seed-run.shared.schemas.d.ts.map +1 -1
  240. package/dist/esm/data-seeding/models/data-seed-trigger-mode-matrix.shared.utils.d.ts.map +1 -1
  241. package/dist/esm/data-seeding/models/data-seed.shared.schemas.d.ts.map +1 -1
  242. package/dist/esm/data-seeding/services/data-seed-application-bootstrap.backend.d.ts.map +1 -1
  243. package/dist/esm/data-seeding/services/data-seed-dispatcher.backend.service.d.ts.map +1 -1
  244. package/dist/esm/data-seeding/services/data-seed-registry.backend.service.d.ts.map +1 -1
  245. package/dist/esm/data-seeding/services/data-seed-scope-resolver-registry.backend.service.d.ts.map +1 -1
  246. package/dist/esm/data-seeding/services/engines/additive-seed-engine.backend.service.d.ts.map +1 -1
  247. package/dist/esm/data-seeding/services/engines/lazy-seed-engine.backend.service.d.ts.map +1 -1
  248. package/dist/esm/data-seeding/services/engines/manual-seed-engine.backend.service.d.ts.map +1 -1
  249. package/dist/esm/data-seeding/services/engines/sync-seed-engine.backend.service.d.ts.map +1 -1
  250. package/dist/esm/data-seeding/services/engines/upgrade-seed-engine.backend.service.d.ts.map +1 -1
  251. package/dist/esm/data-seeding/services/shared/data-seed-business-key.shared.utils.d.ts.map +1 -1
  252. package/dist/esm/data-seeding/services/shared/data-seed-error.shared.utils.d.ts.map +1 -1
  253. package/dist/esm/data-seeding/services/shared/data-seed-run-counters.shared.types.d.ts.map +1 -1
  254. package/dist/esm/data-seeding/services/shared/data-seed-run-ledger.backend.d.ts.map +1 -1
  255. package/dist/esm/data-seeding/services/shared/data-seed-scope-anchor.shared.types.d.ts.map +1 -1
  256. package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.d.ts.map +1 -1
  257. package/dist/esm/data-seeding/services/shared/data-seed-scope-resolution.backend.d.ts.map +1 -1
  258. package/dist/esm/databases/models/aggregation.backend.schemas.d.ts.map +1 -1
  259. package/dist/esm/databases/models/databases.backend.schemas.d.ts.map +1 -1
  260. package/dist/esm/databases/models/filter.backend.schemas.d.ts.map +1 -1
  261. package/dist/esm/databases/models/resolve-persistence-adapter.backend.utils.d.ts.map +1 -1
  262. package/dist/esm/databases/models/sql.backend.schemas.d.ts.map +1 -1
  263. package/dist/esm/databases/models/transaction.shared.schemas.d.ts.map +1 -1
  264. package/dist/esm/databases/services/__tests__/mock-mongo-transaction-registry.service.d.ts.map +1 -1
  265. package/dist/esm/databases/services/__tests__/mock-mongodb.service.d.ts.map +1 -1
  266. package/dist/esm/databases/services/__tests__/mock-mongoose-model.service.d.ts.map +1 -1
  267. package/dist/esm/databases/services/__tests__/mock-redis.service.d.ts.map +1 -1
  268. package/dist/esm/databases/services/__tests__/mock-zod-mongoose-schema-convertor.service.d.ts.map +1 -1
  269. package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.d.ts.map +1 -1
  270. package/dist/esm/databases/services/aggregation/aggregation-query.backend.service.d.ts.map +1 -1
  271. package/dist/esm/databases/services/aggregation/computed-measure-evaluator.backend.service.d.ts.map +1 -1
  272. package/dist/esm/databases/services/aggregation/field-access-validator.backend.service.d.ts.map +1 -1
  273. package/dist/esm/databases/services/aggregation/time-series-densifier.backend.service.d.ts.map +1 -1
  274. package/dist/esm/databases/services/aggregation/topn-processor.backend.service.d.ts.map +1 -1
  275. package/dist/esm/databases/services/aggregation/window-function-processor.backend.service.d.ts.map +1 -1
  276. package/dist/esm/databases/services/db-utils.d.ts.map +1 -1
  277. package/dist/esm/databases/services/mongo-aggregation.backend.service.d.ts.map +1 -1
  278. package/dist/esm/databases/services/mongodb.service.d.ts.map +1 -1
  279. package/dist/esm/databases/services/postgresql-aggregation.backend.service.d.ts.map +1 -1
  280. package/dist/esm/databases/services/postgresql-database.backend.service.d.ts.map +1 -1
  281. package/dist/esm/databases/services/postgresql-development-provisioning.backend.d.ts.map +1 -1
  282. package/dist/esm/databases/services/postgresql-filter.backend.service.d.ts.map +1 -1
  283. package/dist/esm/databases/services/postgresql-migration-runner.backend.d.ts.map +1 -1
  284. package/dist/esm/databases/services/postgresql-schema-ddl.backend.d.ts.map +1 -1
  285. package/dist/esm/databases/services/postgresql-schema-migration-sql.backend.d.ts.map +1 -1
  286. package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.d.ts.map +1 -1
  287. package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.js.map +1 -1
  288. package/dist/esm/databases/services/postgresql-schema-plan-lockfile.backend.d.ts.map +1 -1
  289. package/dist/esm/databases/services/redis.service.d.ts.map +1 -1
  290. package/dist/esm/databases/services/resource-persistence-unit-of-work.backend.service.d.ts.map +1 -1
  291. package/dist/esm/databases/services/schema-planning-standalone.backend.d.ts.map +1 -1
  292. package/dist/esm/databases/services/zod-to-mongoose-schema-convertor.backend.service.d.ts.map +1 -1
  293. package/dist/esm/databases/services/zod-to-sql-hybrid-schema.planner.d.ts.map +1 -1
  294. package/dist/esm/databases/utils/postgresql-identifier.backend.utils.d.ts.map +1 -1
  295. package/dist/esm/errors/services/__tests__/mock-error-builder.service.d.ts.map +1 -1
  296. package/dist/esm/errors/services/error-builder.backend.service.d.ts.map +1 -1
  297. package/dist/esm/errors/services/error-builder.backend.service.js.map +1 -1
  298. package/dist/esm/errors/services/error-handler.backend.service.d.ts.map +1 -1
  299. package/dist/esm/errors/services/error-handler.backend.service.js.map +1 -1
  300. package/dist/esm/errors/services/rate-limit.backend.service.d.ts.map +1 -1
  301. package/dist/esm/errors/services/rate-limit.backend.service.js.map +1 -1
  302. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.d.ts.map +1 -1
  303. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.js.map +1 -1
  304. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.d.ts.map +1 -1
  305. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.js.map +1 -1
  306. package/dist/esm/external-data/batches/external-data-pipeline-scheduled-run.batch.backend.service.d.ts.map +1 -1
  307. package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.d.ts.map +1 -1
  308. package/dist/esm/external-data/controllers/external-data-admin.backend.controller.d.ts.map +1 -1
  309. package/dist/esm/external-data/external-data-extraction-source.backend.d.ts.map +1 -1
  310. package/dist/esm/external-data/external-data-models.exports.d.ts.map +1 -1
  311. package/dist/esm/external-data/external-data-pipeline-run.backend.service.d.ts.map +1 -1
  312. package/dist/esm/external-data/external-data-pipeline-run.backend.service.js.map +1 -1
  313. package/dist/esm/external-data/external-data-transform.backend.d.ts.map +1 -1
  314. package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.d.ts.map +1 -1
  315. package/dist/esm/external-providers/models/external-providers.backend.schemas.d.ts.map +1 -1
  316. package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.d.ts.map +1 -1
  317. package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.js.map +1 -1
  318. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts +102 -52
  319. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts.map +1 -1
  320. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js +117 -71
  321. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js.map +1 -1
  322. package/dist/esm/external-providers/operations/provider-operation-request.backend.d.ts.map +1 -1
  323. package/dist/esm/external-providers/operations/provider-operation-request.backend.js.map +1 -1
  324. package/dist/esm/external-providers/operations/provider-request-signing.backend.d.ts.map +1 -1
  325. package/dist/esm/external-providers/operations/provider-request-signing.backend.js +26 -7
  326. package/dist/esm/external-providers/operations/provider-request-signing.backend.js.map +1 -1
  327. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.d.ts.map +1 -1
  328. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.js.map +1 -1
  329. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.d.ts.map +1 -1
  330. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.js.map +1 -1
  331. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.d.ts.map +1 -1
  332. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.js.map +1 -1
  333. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.d.ts.map +1 -1
  334. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.js.map +1 -1
  335. package/dist/esm/external-providers/services/document-extraction.backend.service.d.ts +81 -34
  336. package/dist/esm/external-providers/services/document-extraction.backend.service.d.ts.map +1 -1
  337. package/dist/esm/external-providers/services/document-extraction.backend.service.js +179 -98
  338. package/dist/esm/external-providers/services/document-extraction.backend.service.js.map +1 -1
  339. package/dist/esm/external-providers/services/embeddings.backend.service.d.ts.map +1 -1
  340. package/dist/esm/external-providers/services/embeddings.backend.service.js.map +1 -1
  341. package/dist/esm/external-providers/services/external-api-handler.backend.service.d.ts.map +1 -1
  342. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts +121 -0
  343. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts.map +1 -1
  344. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js +151 -0
  345. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js.map +1 -1
  346. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.d.ts +15 -1
  347. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.d.ts.map +1 -1
  348. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js +60 -4
  349. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js.map +1 -1
  350. package/dist/esm/features/controllers/features.backend.controller.d.ts.map +1 -1
  351. package/dist/esm/features/services/__tests__/mock-feature-definition-registry.service.d.ts.map +1 -1
  352. package/dist/esm/features/services/__tests__/mock-feature-resolution.service.d.ts.map +1 -1
  353. package/dist/esm/features/services/application-features-admin-write-path.custom-impl.backend.service.d.ts.map +1 -1
  354. package/dist/esm/features/services/feature-definition-registry.backend.service.d.ts.map +1 -1
  355. package/dist/esm/features/services/feature-gate.backend.service.d.ts.map +1 -1
  356. package/dist/esm/features/services/feature-resolution.backend.service.d.ts.map +1 -1
  357. package/dist/esm/features/services/organization-features-admin-write-path.custom-impl.backend.service.d.ts.map +1 -1
  358. package/dist/esm/features/services/scope-feature-ledger-relationship.backend.utils.d.ts.map +1 -1
  359. package/dist/esm/features/services/scope-features-cache-invalidation.custom-impl.backend.service.d.ts.map +1 -1
  360. package/dist/esm/features/testing/feature-test-utils.d.ts.map +1 -1
  361. package/dist/esm/files/batches/files-cleanup.batch.backend.service.d.ts.map +1 -1
  362. package/dist/esm/files/constraints/file-analyzers.types.d.ts.map +1 -1
  363. package/dist/esm/files/constraints/file-constraint-resolver-chain.backend.service.d.ts.map +1 -1
  364. package/dist/esm/files/constraints/file-constraint.types.d.ts.map +1 -1
  365. package/dist/esm/files/constraints/file-validation.backend.service.d.ts.map +1 -1
  366. package/dist/esm/files/constraints/resource-field-constraint-resolver.backend.service.d.ts.map +1 -1
  367. package/dist/esm/files/controllers/file.controller.d.ts.map +1 -1
  368. package/dist/esm/files/controllers/file.controller.js.map +1 -1
  369. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.d.ts.map +1 -1
  370. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.js.map +1 -1
  371. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts +37 -0
  372. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts.map +1 -1
  373. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js +221 -21
  374. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js.map +1 -1
  375. package/dist/esm/files/scanning/clamav-scanner.backend.service.d.ts.map +1 -1
  376. package/dist/esm/files/scanning/file-scan.types.d.ts.map +1 -1
  377. package/dist/esm/files/scanning/yara-scanner.backend.service.d.ts.map +1 -1
  378. package/dist/esm/files/scanning/yara-scanner.backend.service.js +20 -2
  379. package/dist/esm/files/scanning/yara-scanner.backend.service.js.map +1 -1
  380. package/dist/esm/files/services/__tests__/mock-file-field-detection.service.d.ts.map +1 -1
  381. package/dist/esm/files/services/__tests__/mock-file-operation-handler.service.d.ts.map +1 -1
  382. package/dist/esm/files/services/__tests__/mock-file-repository.service.d.ts.map +1 -1
  383. package/dist/esm/files/services/file-field-detection.backend.service.d.ts.map +1 -1
  384. package/dist/esm/files/services/file-operation-handler.backend.service.d.ts.map +1 -1
  385. package/dist/esm/files/services/file-operation-handler.backend.service.js.map +1 -1
  386. package/dist/esm/files/services/file-population.backend.service.d.ts.map +1 -1
  387. package/dist/esm/files/services/file-scanning.backend.service.d.ts.map +1 -1
  388. package/dist/esm/files/services/file-scanning.backend.service.js +5 -0
  389. package/dist/esm/files/services/file-scanning.backend.service.js.map +1 -1
  390. package/dist/esm/files/services/file-text-extraction.backend.service.d.ts.map +1 -1
  391. package/dist/esm/files/services/file-text-extraction.backend.service.js +8 -5
  392. package/dist/esm/files/services/file-text-extraction.backend.service.js.map +1 -1
  393. package/dist/esm/files/services/file-upload-grant.backend.service.d.ts.map +1 -1
  394. package/dist/esm/files/services/file-upload-grant.backend.service.js.map +1 -1
  395. package/dist/esm/files/services/files.backend.service.d.ts.map +1 -1
  396. package/dist/esm/files/services/files.backend.service.js +3 -1
  397. package/dist/esm/files/services/files.backend.service.js.map +1 -1
  398. package/dist/esm/files/services/rag-source-field-detection.backend.service.d.ts.map +1 -1
  399. package/dist/esm/files/storage/application-storage-key.backend.utils.d.ts.map +1 -1
  400. package/dist/esm/files/storage/application-storage-key.backend.utils.js.map +1 -1
  401. package/dist/esm/files/storage/file-storage-path-resolver.backend.service.d.ts.map +1 -1
  402. package/dist/esm/files/storage/file-storage-provider.types.d.ts +36 -1
  403. package/dist/esm/files/storage/file-storage-provider.types.d.ts.map +1 -1
  404. package/dist/esm/files/storage/file-storage-provider.types.js.map +1 -1
  405. package/dist/esm/files/storage/file-storage-router.backend.service.d.ts +21 -3
  406. package/dist/esm/files/storage/file-storage-router.backend.service.d.ts.map +1 -1
  407. package/dist/esm/files/storage/file-storage-router.backend.service.js +38 -5
  408. package/dist/esm/files/storage/file-storage-router.backend.service.js.map +1 -1
  409. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.d.ts +87 -0
  410. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.d.ts.map +1 -0
  411. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.js +340 -0
  412. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.js.map +1 -0
  413. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.d.ts.map +1 -1
  414. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.js.map +1 -1
  415. package/dist/esm/files/storage/storage-credential-provider.backend.utils.d.ts.map +1 -1
  416. package/dist/esm/files/storage/storage-platform-sts-credential-resolver.backend.utils.d.ts.map +1 -1
  417. package/dist/esm/files/storage/storage-sts-credential-resolver.backend.utils.d.ts.map +1 -1
  418. package/dist/esm/files/storage/storage-sts-credential-resolver.backend.utils.js +10 -3
  419. package/dist/esm/files/storage/storage-sts-credential-resolver.backend.utils.js.map +1 -1
  420. package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.d.ts.map +1 -1
  421. package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.js.map +1 -1
  422. package/dist/esm/files/utils/file-field-schema-path.backend.utils.d.ts.map +1 -1
  423. package/dist/esm/files/utils/file-field-schema-path.backend.utils.js.map +1 -1
  424. package/dist/esm/files/utils/file-upload.utils.d.ts.map +1 -1
  425. package/dist/esm/files/utils/file-uploader.utils.d.ts.map +1 -1
  426. package/dist/esm/files/utils/file-uploader.utils.js.map +1 -1
  427. package/dist/esm/files/utils/file-validation.utils.d.ts.map +1 -1
  428. package/dist/esm/files/utils/image-derivation.backend.utils.d.ts.map +1 -1
  429. package/dist/esm/files/utils/image-thumbnail.backend.utils.d.ts.map +1 -1
  430. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.d.ts.map +1 -1
  431. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.js.map +1 -1
  432. package/dist/esm/files/utils/rag-source-field-schema-path.backend.utils.d.ts.map +1 -1
  433. package/dist/esm/files/utils/storage-application-identity.backend.utils.d.ts.map +1 -1
  434. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.d.ts.map +1 -1
  435. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.js.map +1 -1
  436. package/dist/esm/flows-actors/a2a/batches/a2a-push-delivery.batch.backend.service.d.ts.map +1 -1
  437. package/dist/esm/flows-actors/a2a/controllers/a2a.controller.d.ts.map +1 -1
  438. package/dist/esm/flows-actors/a2a/controllers/a2a.controller.js.map +1 -1
  439. package/dist/esm/flows-actors/a2a/models/a2a-dialect.backend.schemas.d.ts.map +1 -1
  440. package/dist/esm/flows-actors/a2a/models/a2a-push-notification-delivery.backend.utils.d.ts.map +1 -1
  441. package/dist/esm/flows-actors/a2a/models/a2a-push-notification.backend.schemas.d.ts.map +1 -1
  442. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.d.ts.map +1 -1
  443. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.js.map +1 -1
  444. package/dist/esm/flows-actors/a2a/services/a2a-push-delivery-log.repository.d.ts.map +1 -1
  445. package/dist/esm/flows-actors/a2a/services/a2a-push-dispatcher.backend.service.d.ts.map +1 -1
  446. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.d.ts.map +1 -1
  447. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.js.map +1 -1
  448. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.d.ts.map +1 -1
  449. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.js.map +1 -1
  450. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.d.ts.map +1 -1
  451. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.js.map +1 -1
  452. package/dist/esm/flows-actors/a2a/services/a2a.backend.service.d.ts.map +1 -1
  453. package/dist/esm/flows-actors/a2a/services/a2a.backend.service.js.map +1 -1
  454. package/dist/esm/flows-actors/controllers/flows-actors.controller.d.ts.map +1 -1
  455. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.d.ts.map +1 -1
  456. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.js.map +1 -1
  457. package/dist/esm/flows-actors/models/agent-facets.backend.definitions.d.ts.map +1 -1
  458. package/dist/esm/flows-actors/models/agents.backend.definitions.d.ts.map +1 -1
  459. package/dist/esm/flows-actors/models/core-facets.backend.definitions.d.ts.map +1 -1
  460. package/dist/esm/flows-actors/models/core-facets.backend.definitions.js.map +1 -1
  461. package/dist/esm/flows-actors/models/flows-actors.backend.definitions.d.ts.map +1 -1
  462. package/dist/esm/flows-actors/models/flows-actors.backend.schemas.d.ts.map +1 -1
  463. package/dist/esm/flows-actors/models/flows-actors.backend.schemas.js.map +1 -1
  464. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts +107 -16
  465. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts.map +1 -1
  466. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js +118 -18
  467. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js.map +1 -1
  468. package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.d.ts.map +1 -1
  469. package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.js.map +1 -1
  470. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.d.ts.map +1 -1
  471. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.js.map +1 -1
  472. package/dist/esm/flows-actors/services/__tests__/fixtures/meta-workflow-evaluation-treatment.test-fixture.d.ts.map +1 -1
  473. package/dist/esm/flows-actors/services/actors-system.backend.service.d.ts.map +1 -1
  474. package/dist/esm/flows-actors/services/actors-system.backend.service.js.map +1 -1
  475. package/dist/esm/flows-actors/services/agent-call-trace-sink.backend.d.ts.map +1 -1
  476. package/dist/esm/flows-actors/services/agent-facets.backend.service.d.ts.map +1 -1
  477. package/dist/esm/flows-actors/services/agents.backend.service.d.ts +104 -5
  478. package/dist/esm/flows-actors/services/agents.backend.service.d.ts.map +1 -1
  479. package/dist/esm/flows-actors/services/agents.backend.service.js +263 -31
  480. package/dist/esm/flows-actors/services/agents.backend.service.js.map +1 -1
  481. package/dist/esm/flows-actors/services/context-curation.backend.service.d.ts.map +1 -1
  482. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts +46 -1
  483. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts.map +1 -1
  484. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js +193 -6
  485. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js.map +1 -1
  486. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts.map +1 -1
  487. package/dist/esm/flows-actors/services/flows-actors-registry.service.js.map +1 -1
  488. package/dist/esm/flows-actors/services/flows.backend.services.d.ts.map +1 -1
  489. package/dist/esm/flows-actors/services/flows.backend.services.js.map +1 -1
  490. package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.d.ts.map +1 -1
  491. package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.js.map +1 -1
  492. package/dist/esm/flows-actors/services/mcp-client.backend.service.d.ts.map +1 -1
  493. package/dist/esm/flows-actors/services/mcp-client.backend.service.js +3 -0
  494. package/dist/esm/flows-actors/services/mcp-client.backend.service.js.map +1 -1
  495. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.d.ts +99 -0
  496. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.d.ts.map +1 -0
  497. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.js +155 -0
  498. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.js.map +1 -0
  499. package/dist/esm/flows-actors/services/meta-workflow-evaluation-treatment-compiler.backend.service.d.ts.map +1 -1
  500. package/dist/esm/flows-actors/services/meta-workflow-standard-action-contracts.backend.service.d.ts.map +1 -1
  501. package/dist/esm/flows-actors/services/meta-workflow-standard-evaluation-contracts.backend.service.d.ts.map +1 -1
  502. package/dist/esm/flows-actors/services/meta-workflow-structured-artifact-action-compiler.backend.service.d.ts.map +1 -1
  503. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.d.ts.map +1 -1
  504. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.js.map +1 -1
  505. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts.map +1 -1
  506. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js +9 -0
  507. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js.map +1 -1
  508. package/dist/esm/flows-actors/utils/bounded-subprocess.backend.utils.d.ts.map +1 -1
  509. package/dist/esm/flows-actors/utils/flows-actors-frontend-extractor.utils.d.ts.map +1 -1
  510. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.d.ts.map +1 -1
  511. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.js.map +1 -1
  512. package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.d.ts.map +1 -1
  513. package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.js.map +1 -1
  514. package/dist/esm/flows-actors/utils/prompt-ir-adapters.backend.utils.d.ts.map +1 -1
  515. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.d.ts +77 -0
  516. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.d.ts.map +1 -0
  517. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.js +164 -0
  518. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.js.map +1 -0
  519. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.d.ts +48 -0
  520. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.d.ts.map +1 -0
  521. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.js +101 -0
  522. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.js.map +1 -0
  523. package/dist/esm/guidance/batches/dormancy-detection.batch.backend.service.d.ts.map +1 -1
  524. package/dist/esm/guidance/services/guidance-trigger-evaluator.backend.service.d.ts.map +1 -1
  525. package/dist/esm/guidance/services/lifecycle-custom-implementations.backend.d.ts.map +1 -1
  526. package/dist/esm/guidance/services/lifecycle-evaluator.backend.service.d.ts.map +1 -1
  527. package/dist/esm/guidance/services/lifecycle-scope-id.backend.utils.d.ts.map +1 -1
  528. package/dist/esm/guidance/services/milestone-condition-registry.backend.service.d.ts.map +1 -1
  529. package/dist/esm/guidance/services/milestone-definition-registry.backend.service.d.ts.map +1 -1
  530. package/dist/esm/guidance/services/milestone-evaluator.backend.service.d.ts.map +1 -1
  531. package/dist/esm/guidance/services/milestone-evaluator.backend.service.js.map +1 -1
  532. package/dist/esm/guidance/services/progression-state-store.backend.service.d.ts.map +1 -1
  533. package/dist/esm/guidance/services/progression-state-store.backend.service.js.map +1 -1
  534. package/dist/esm/guidance/services/scoped-state-read-custom-implementations.backend.d.ts.map +1 -1
  535. package/dist/esm/i18n/controllers/i18n-controller.backend.service.d.ts.map +1 -1
  536. package/dist/esm/i18n/controllers/i18n-controller.backend.service.js.map +1 -1
  537. package/dist/esm/i18n/services/i18n.backend.service.d.ts.map +1 -1
  538. package/dist/esm/index.d.ts +0 -1
  539. package/dist/esm/index.d.ts.map +1 -1
  540. package/dist/esm/index.js +0 -1
  541. package/dist/esm/index.js.map +1 -1
  542. package/dist/esm/inject/models/container.d.ts +10 -0
  543. package/dist/esm/inject/models/container.d.ts.map +1 -1
  544. package/dist/esm/inject/models/container.js +49 -1
  545. package/dist/esm/inject/models/container.js.map +1 -1
  546. package/dist/esm/inject/models/service-types.d.ts +3 -0
  547. package/dist/esm/inject/models/service-types.d.ts.map +1 -1
  548. package/dist/esm/inject/models/service-types.js +3 -0
  549. package/dist/esm/inject/models/service-types.js.map +1 -1
  550. package/dist/esm/mcp/controllers/mcp.controller.d.ts.map +1 -1
  551. package/dist/esm/mcp/controllers/mcp.controller.js +50 -3
  552. package/dist/esm/mcp/controllers/mcp.controller.js.map +1 -1
  553. package/dist/esm/mcp/models/mcp-protocol.backend.schemas.d.ts.map +1 -1
  554. package/dist/esm/mcp/models/mcp-tool.backend.schemas.d.ts.map +1 -1
  555. package/dist/esm/mcp/models/mcp-tool.backend.schemas.js.map +1 -1
  556. package/dist/esm/mcp/services/mcp-server.backend.service.d.ts.map +1 -1
  557. package/dist/esm/mcp/services/mcp-server.backend.service.js.map +1 -1
  558. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.d.ts.map +1 -1
  559. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.js.map +1 -1
  560. package/dist/esm/mcp/services/resource-server-instances-registry.backend.service.d.ts.map +1 -1
  561. package/dist/esm/mcp/utils/zod-to-mcp-json-schema.backend.utils.d.ts.map +1 -1
  562. package/dist/esm/meta-workflow-runtime.exports.d.ts.map +1 -1
  563. package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.d.ts.map +1 -1
  564. package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.js.map +1 -1
  565. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.d.ts.map +1 -1
  566. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.js.map +1 -1
  567. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.d.ts.map +1 -1
  568. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.js.map +1 -1
  569. package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.d.ts.map +1 -1
  570. package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.js.map +1 -1
  571. package/dist/esm/monitoring/logger/models/logger.backend.schemas.d.ts.map +1 -1
  572. package/dist/esm/monitoring/logger/models/logger.backend.schemas.js.map +1 -1
  573. package/dist/esm/monitoring/logger/services/__tests__/mock-logger.service.d.ts.map +1 -1
  574. package/dist/esm/monitoring/logger/services/logger.service.d.ts +12 -0
  575. package/dist/esm/monitoring/logger/services/logger.service.d.ts.map +1 -1
  576. package/dist/esm/monitoring/logger/services/logger.service.js +3 -3
  577. package/dist/esm/monitoring/logger/services/logger.service.js.map +1 -1
  578. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.d.ts.map +1 -1
  579. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.js.map +1 -1
  580. package/dist/esm/monitoring/logger/utils/log-value-normalization.backend.utils.d.ts.map +1 -1
  581. package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts +10 -6
  582. package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts.map +1 -1
  583. package/dist/esm/monitoring/observability/audit-observation-emission.backend.js +10 -6
  584. package/dist/esm/monitoring/observability/audit-observation-emission.backend.js.map +1 -1
  585. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts.map +1 -1
  586. package/dist/esm/monitoring/observability/models/observability.backend.schemas.js.map +1 -1
  587. package/dist/esm/monitoring/observability/otel-preload.d.ts.map +1 -1
  588. package/dist/esm/monitoring/observability/otel-sdk-global-handle.d.ts.map +1 -1
  589. package/dist/esm/monitoring/observability/services/__tests__/mock-metrics.service.d.ts.map +1 -1
  590. package/dist/esm/monitoring/observability/services/metrics.service.d.ts.map +1 -1
  591. package/dist/esm/monitoring/observability/services/metrics.service.js.map +1 -1
  592. package/dist/esm/monitoring/observability/services/observability.backend.service.d.ts.map +1 -1
  593. package/dist/esm/notifications/email/components/email-components.d.ts.map +1 -1
  594. package/dist/esm/notifications/email/models/email-template-definition.d.ts.map +1 -1
  595. package/dist/esm/notifications/email/models/email-transport.backend.definitions.d.ts.map +1 -1
  596. package/dist/esm/notifications/email/services/email-batch-send.batch.backend.service.d.ts.map +1 -1
  597. package/dist/esm/notifications/email/services/email-template-registry.backend.service.d.ts.map +1 -1
  598. package/dist/esm/notifications/email/services/email-template-registry.backend.service.js.map +1 -1
  599. package/dist/esm/notifications/email/services/email-template-validator.backend.service.d.ts.map +1 -1
  600. package/dist/esm/notifications/email/services/email-template-validator.backend.service.js.map +1 -1
  601. package/dist/esm/notifications/email/services/email.backend.service.d.ts +47 -6
  602. package/dist/esm/notifications/email/services/email.backend.service.d.ts.map +1 -1
  603. package/dist/esm/notifications/email/services/email.backend.service.js +86 -36
  604. package/dist/esm/notifications/email/services/email.backend.service.js.map +1 -1
  605. package/dist/esm/notifications/email/utils/color-conversion.utils.d.ts.map +1 -1
  606. package/dist/esm/notifications/email/utils/color-conversion.utils.js.map +1 -1
  607. package/dist/esm/notifications/email/utils/interpolate-email-label.utils.d.ts.map +1 -1
  608. package/dist/esm/notifications/email/utils/zod-to-typescript.utils.d.ts.map +1 -1
  609. package/dist/esm/notifications/services/notification-badge.backend.service.d.ts.map +1 -1
  610. package/dist/esm/notifications/services/notification-badge.backend.service.js.map +1 -1
  611. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.d.ts.map +1 -1
  612. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.js.map +1 -1
  613. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.d.ts +32 -0
  614. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.d.ts.map +1 -0
  615. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.js +32 -0
  616. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.js.map +1 -0
  617. package/dist/esm/notifications/sms/services/sms.backend.service.d.ts +64 -10
  618. package/dist/esm/notifications/sms/services/sms.backend.service.d.ts.map +1 -1
  619. package/dist/esm/notifications/sms/services/sms.backend.service.js +277 -82
  620. package/dist/esm/notifications/sms/services/sms.backend.service.js.map +1 -1
  621. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts.map +1 -1
  622. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js.map +1 -1
  623. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.d.ts.map +1 -1
  624. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.js.map +1 -1
  625. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.d.ts.map +1 -1
  626. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.d.ts.map +1 -1
  627. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.js.map +1 -1
  628. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.d.ts.map +1 -1
  629. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.repository.d.ts.map +1 -1
  630. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-dispatcher.backend.service.d.ts.map +1 -1
  631. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-public-key.custom-impl.backend.service.d.ts.map +1 -1
  632. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.d.ts.map +1 -1
  633. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.js.map +1 -1
  634. package/dist/esm/notifications/webhooks/outbound/services/webhook-config.backend.service.d.ts.map +1 -1
  635. package/dist/esm/notifications/webhooks/services/polymorphic-lookup.backend.service.d.ts.map +1 -1
  636. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.d.ts.map +1 -1
  637. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.js.map +1 -1
  638. package/dist/esm/organizations/batches/organization-member-invitation-sweep.batch.backend.service.d.ts.map +1 -1
  639. package/dist/esm/organizations/batches/organization-purge.batch.backend.service.d.ts.map +1 -1
  640. package/dist/esm/organizations/batches/organization-purge.batch.backend.service.js.map +1 -1
  641. package/dist/esm/organizations/services/authority-change-audit.backend.utils.d.ts.map +1 -1
  642. package/dist/esm/organizations/services/invitation-acceptance.backend.utils.d.ts.map +1 -1
  643. package/dist/esm/organizations/services/org-creation-on-registration.backend.utils.d.ts.map +1 -1
  644. package/dist/esm/organizations/services/org-member-roles-validation.backend.utils.d.ts.map +1 -1
  645. package/dist/esm/organizations/services/organization-custom-implementation.backend.service.d.ts.map +1 -1
  646. package/dist/esm/organizations/services/organization-custom-implementation.backend.service.js.map +1 -1
  647. package/dist/esm/organizations/services/organization-deletion-audit.custom-impl.backend.service.d.ts.map +1 -1
  648. package/dist/esm/organizations/services/organization-member-custom-implementation.backend.service.d.ts.map +1 -1
  649. package/dist/esm/organizations/services/organization-onboarding-operation.backend.utils.d.ts.map +1 -1
  650. package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.d.ts.map +1 -1
  651. package/dist/esm/organizations/services/organization-unit-member-custom-implementation.backend.service.d.ts.map +1 -1
  652. package/dist/esm/organizations/services/scim-provisioning-gate.backend.utils.d.ts.map +1 -1
  653. package/dist/esm/organizations/services/user-org-type-grant.backend.utils.d.ts.map +1 -1
  654. package/dist/esm/organizations/services/user-type-revocation-on-org-leave.backend.utils.d.ts.map +1 -1
  655. package/dist/esm/pdf-templates/__tests__/fixtures/tiny-pdf-template.fixture.d.ts.map +1 -1
  656. package/dist/esm/pdf-templates/models/pdf-template-binding.d.ts.map +1 -1
  657. package/dist/esm/pdf-templates/models/pdf-template-definition.d.ts.map +1 -1
  658. package/dist/esm/pdf-templates/services/pdf-generated-file-writer.backend.service.d.ts.map +1 -1
  659. package/dist/esm/pdf-templates/services/pdf-generation-orchestrator.backend.service.d.ts.map +1 -1
  660. package/dist/esm/pdf-templates/services/pdf-renderer.backend.service.d.ts.map +1 -1
  661. package/dist/esm/pdf-templates/services/pdf-template-binding.backend.service.d.ts.map +1 -1
  662. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.d.ts.map +1 -1
  663. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.js.map +1 -1
  664. package/dist/esm/queue/adapters/queue-adapter.backend.binding.d.ts.map +1 -1
  665. package/dist/esm/queue/adapters/queue-adapter.backend.binding.js.map +1 -1
  666. package/dist/esm/queue/adapters/queue-adapter.backend.interface.d.ts.map +1 -1
  667. package/dist/esm/queue/adapters/queue-adapter.backend.interface.js.map +1 -1
  668. package/dist/esm/queue/adapters/queue-adapter.backend.options.d.ts.map +1 -1
  669. package/dist/esm/queue/adapters/queue-adapter.backend.options.js.map +1 -1
  670. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.d.ts.map +1 -1
  671. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.js.map +1 -1
  672. package/dist/esm/queue/apps-crontabs-manager.backend.service.d.ts.map +1 -1
  673. package/dist/esm/queue/cron-job-sync.backend.service.d.ts.map +1 -1
  674. package/dist/esm/queue/domain-queue-consumer.backend.service.d.ts.map +1 -1
  675. package/dist/esm/queue/domain-queue-consumer.backend.service.js.map +1 -1
  676. package/dist/esm/queue/job-completion-registry.backend.service.d.ts.map +1 -1
  677. package/dist/esm/queue/job-consumer.backend.service.d.ts.map +1 -1
  678. package/dist/esm/queue/job-consumer.backend.service.js.map +1 -1
  679. package/dist/esm/queue/job-executor.backend.service.d.ts.map +1 -1
  680. package/dist/esm/queue/job-executor.backend.service.js.map +1 -1
  681. package/dist/esm/queue/job-payload-storage.backend.service.d.ts.map +1 -1
  682. package/dist/esm/queue/job-status-tracking.backend.service.d.ts.map +1 -1
  683. package/dist/esm/queue/queue-monitoring.backend.service.d.ts.map +1 -1
  684. package/dist/esm/queue/queue-monitoring.backend.service.js.map +1 -1
  685. package/dist/esm/queue/queue-worker-initializer.backend.service.d.ts.map +1 -1
  686. package/dist/esm/queue/queue-worker-initializer.backend.service.js.map +1 -1
  687. package/dist/esm/queue/queue.backend.service.d.ts.map +1 -1
  688. package/dist/esm/queue/queue.backend.service.js.map +1 -1
  689. package/dist/esm/queue/scheduled-message-verifier.backend.service.d.ts.map +1 -1
  690. package/dist/esm/queue/worker-shutdown-manager.backend.service.d.ts.map +1 -1
  691. package/dist/esm/queue/worker-shutdown-manager.backend.service.js.map +1 -1
  692. package/dist/esm/rag/batches/rag-embedding-drain.batch.backend.service.d.ts.map +1 -1
  693. package/dist/esm/rag/batches/rag-reconciliation-sweep.batch.backend.service.d.ts.map +1 -1
  694. package/dist/esm/rag/models/rag-chunk-store.backend.types.d.ts.map +1 -1
  695. package/dist/esm/rag/models/rag-retrieval.backend.types.d.ts.map +1 -1
  696. package/dist/esm/rag/services/mongodb-rag-chunk-store.backend.service.d.ts.map +1 -1
  697. package/dist/esm/rag/services/postgresql-rag-chunk-store.backend.service.d.ts.map +1 -1
  698. package/dist/esm/rag/services/rag-chunk-collection.mongodb-ddl.backend.d.ts.map +1 -1
  699. package/dist/esm/rag/services/rag-chunk-retrieval.mongodb-query.backend.d.ts.map +1 -1
  700. package/dist/esm/rag/services/rag-chunk-retrieval.postgresql-query.backend.d.ts.map +1 -1
  701. package/dist/esm/rag/services/rag-chunk-store.backend.service.d.ts.map +1 -1
  702. package/dist/esm/rag/services/rag-chunk-table.postgresql-ddl.backend.d.ts.map +1 -1
  703. package/dist/esm/rag/services/rag-ingestion.backend.service.d.ts.map +1 -1
  704. package/dist/esm/rag/services/rag-retrieval.backend.service.d.ts.map +1 -1
  705. package/dist/esm/rag/utils/rag-chunk-fusion.backend.utils.d.ts.map +1 -1
  706. package/dist/esm/rag/utils/rag-chunk-removal.backend.utils.d.ts.map +1 -1
  707. package/dist/esm/rag/utils/rag-chunk-row-shaping.backend.utils.d.ts.map +1 -1
  708. package/dist/esm/rag/utils/rag-chunking.backend.utils.d.ts.map +1 -1
  709. package/dist/esm/rag/utils/rag-chunking.backend.utils.js.map +1 -1
  710. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.d.ts.map +1 -1
  711. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.js.map +1 -1
  712. package/dist/esm/rag/utils/rag-ingestion-trigger.backend.utils.d.ts.map +1 -1
  713. package/dist/esm/rag/utils/rag-retrieval-scope.backend.utils.d.ts.map +1 -1
  714. package/dist/esm/rag/utils/rag-source-field-value.backend.utils.d.ts.map +1 -1
  715. package/dist/esm/requests/models/api-routes.backend.defintions.d.ts.map +1 -1
  716. package/dist/esm/requests/models/requests.backend.schemas.d.ts.map +1 -1
  717. package/dist/esm/requests/service/platform-mutualized-handler.backend.service.d.ts.map +1 -1
  718. package/dist/esm/requests/service/platform-requests.backend.utils.d.ts.map +1 -1
  719. package/dist/esm/requests/service/remote-client-base.backend.service.d.ts.map +1 -1
  720. package/dist/esm/requests/service/serverless-services-handler.backend.service.d.ts.map +1 -1
  721. package/dist/esm/requests/service/websocket.service.d.ts.map +1 -1
  722. package/dist/esm/requests/service/websocket.service.js +49 -1
  723. package/dist/esm/requests/service/websocket.service.js.map +1 -1
  724. package/dist/esm/resources/backend-resource-registry.exports.d.ts.map +1 -1
  725. package/dist/esm/resources/models/custom-service-implementations.backend.definition.d.ts.map +1 -1
  726. package/dist/esm/resources/models/custom-service-implementations.backend.definition.js +2 -0
  727. package/dist/esm/resources/models/custom-service-implementations.backend.definition.js.map +1 -1
  728. package/dist/esm/resources/models/index.d.ts.map +1 -1
  729. package/dist/esm/resources/models/resources-operations.backend.definitions.d.ts.map +1 -1
  730. package/dist/esm/resources/models/resources-operations.backend.definitions.js.map +1 -1
  731. package/dist/esm/resources/models/resources-relationships.backend.definitions.d.ts.map +1 -1
  732. package/dist/esm/resources/models/resources-relationships.backend.definitions.js.map +1 -1
  733. package/dist/esm/resources/models/resources-types.backend.schemas.d.ts.map +1 -1
  734. package/dist/esm/resources/models/resources-types.backend.schemas.js.map +1 -1
  735. package/dist/esm/resources/models/resources.backend.schemas.d.ts.map +1 -1
  736. package/dist/esm/resources/models/virtual-fields.backend.types.d.ts.map +1 -1
  737. package/dist/esm/resources/services/__tests__/mock-resources-registry.service.d.ts.map +1 -1
  738. package/dist/esm/resources/services/resource-context.backend.service.d.ts.map +1 -1
  739. package/dist/esm/resources/services/resource-id.backend.service.d.ts.map +1 -1
  740. package/dist/esm/resources/services/resource-population.backend.service.d.ts +17 -2
  741. package/dist/esm/resources/services/resource-population.backend.service.d.ts.map +1 -1
  742. package/dist/esm/resources/services/resource-population.backend.service.js +74 -18
  743. package/dist/esm/resources/services/resource-population.backend.service.js.map +1 -1
  744. package/dist/esm/resources/services/resources-registry.backend.service.d.ts +23 -0
  745. package/dist/esm/resources/services/resources-registry.backend.service.d.ts.map +1 -1
  746. package/dist/esm/resources/services/resources-registry.backend.service.js +31 -0
  747. package/dist/esm/resources/services/resources-registry.backend.service.js.map +1 -1
  748. package/dist/esm/resources/services/virtual-fields.backend.service.d.ts.map +1 -1
  749. package/dist/esm/resources/utils/resource-retention.backend.utils.d.ts.map +1 -1
  750. package/dist/esm/runtime/controllers/health-controller.backend.service.d.ts.map +1 -1
  751. package/dist/esm/runtime/controllers/health-controller.backend.service.js.map +1 -1
  752. package/dist/esm/runtime/domain-module.backend.definitions.d.ts.map +1 -1
  753. package/dist/esm/runtime/domain-module.backend.definitions.js.map +1 -1
  754. package/dist/esm/runtime/models/execution-context.backend.schemas.d.ts.map +1 -1
  755. package/dist/esm/runtime/models/request-context.als.backend.d.ts.map +1 -1
  756. package/dist/esm/runtime/models/runtime.backend.schemas.d.ts.map +1 -1
  757. package/dist/esm/runtime/services/execution-context-creator.backend.service.d.ts.map +1 -1
  758. package/dist/esm/runtime/services/execution-context-creator.backend.service.js.map +1 -1
  759. package/dist/esm/runtime/services/execution-context-handler.backend.service.d.ts.map +1 -1
  760. package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.d.ts.map +1 -1
  761. package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.js.map +1 -1
  762. package/dist/esm/runtime/services/http-server.backend.service.d.ts.map +1 -1
  763. package/dist/esm/runtime/services/http-server.backend.service.js +10 -0
  764. package/dist/esm/runtime/services/http-server.backend.service.js.map +1 -1
  765. package/dist/esm/runtime/services/start-application.backend.service.d.ts.map +1 -1
  766. package/dist/esm/runtime/services/start-application.backend.service.js +26 -12
  767. package/dist/esm/runtime/services/start-application.backend.service.js.map +1 -1
  768. package/dist/esm/runtime/services/utils/oauth-body-cap.backend.utils.d.ts.map +1 -1
  769. package/dist/esm/runtime/testing/execution-context-test-fixtures.d.ts.map +1 -1
  770. package/dist/esm/runtime/testing/mock-execution-context-creator.service.d.ts.map +1 -1
  771. package/dist/esm/runtime/utils/application-startup-config-access.backend.utils.d.ts.map +1 -1
  772. package/dist/esm/runtime/utils/feature-gated-core-resource-exclusions.backend.utils.d.ts.map +1 -1
  773. package/dist/esm/runtime/utils/request-client-ip.utils.d.ts.map +1 -1
  774. package/dist/esm/runtime/utils/scan-default-exports.backend.utils.d.ts.map +1 -1
  775. package/dist/esm/security/api-keys/api-key-generation.backend.utils.d.ts.map +1 -1
  776. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.d.ts.map +1 -1
  777. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.js.map +1 -1
  778. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.d.ts.map +1 -1
  779. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.js.map +1 -1
  780. package/dist/esm/security/authentications/controllers/auth-method-management-controller.backend.service.d.ts.map +1 -1
  781. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.d.ts +22 -0
  782. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.d.ts.map +1 -1
  783. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js +84 -0
  784. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js.map +1 -1
  785. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.d.ts.map +1 -1
  786. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.js.map +1 -1
  787. package/dist/esm/security/authentications/models/auth-constants.backend.d.ts.map +1 -1
  788. package/dist/esm/security/authentications/models/authentications.backend.schemas.d.ts.map +1 -1
  789. package/dist/esm/security/authentications/models/authorization-client.backend.schemas.d.ts.map +1 -1
  790. package/dist/esm/security/authentications/models/cimd.backend.schemas.d.ts.map +1 -1
  791. package/dist/esm/security/authentications/models/cimd.backend.schemas.js.map +1 -1
  792. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.d.ts +37 -0
  793. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.d.ts.map +1 -0
  794. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.js +37 -0
  795. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.js.map +1 -0
  796. package/dist/esm/security/authentications/models/identity-persistence-boundaries.backend.d.ts.map +1 -1
  797. package/dist/esm/security/authentications/models/jwt.backend.schemas.d.ts.map +1 -1
  798. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts +15 -0
  799. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts.map +1 -1
  800. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.js.map +1 -1
  801. package/dist/esm/security/authentications/models/saml-authentication.backend.schemas.d.ts.map +1 -1
  802. package/dist/esm/security/authentications/models/sso-connection.backend.schemas.d.ts.map +1 -1
  803. package/dist/esm/security/authentications/models/user-authorization-version.backend.utils.d.ts.map +1 -1
  804. package/dist/esm/security/authentications/seeds/enterprise-config-defaults.seeds.d.ts.map +1 -1
  805. package/dist/esm/security/authentications/services/__tests__/mock-auth-execution-context-factory.service.d.ts.map +1 -1
  806. package/dist/esm/security/authentications/services/__tests__/mock-auth-token-issuer.service.d.ts.map +1 -1
  807. package/dist/esm/security/authentications/services/__tests__/oauth-provider-audit-spies.mock.d.ts.map +1 -1
  808. package/dist/esm/security/authentications/services/admin-config/__tests__/mock-domain-to-org-lookup.service.d.ts.map +1 -1
  809. package/dist/esm/security/authentications/services/admin-config/__tests__/mock-enterprise-user-provisioning.service.d.ts.map +1 -1
  810. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.d.ts.map +1 -1
  811. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.js.map +1 -1
  812. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.d.ts.map +1 -1
  813. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.js.map +1 -1
  814. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.d.ts.map +1 -1
  815. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.js.map +1 -1
  816. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.d.ts.map +1 -1
  817. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.js.map +1 -1
  818. package/dist/esm/security/authentications/services/admin-config/oidc-discovery.backend.service.d.ts.map +1 -1
  819. package/dist/esm/security/authentications/services/admin-config/oidc-discovery.backend.service.js +2 -1
  820. package/dist/esm/security/authentications/services/admin-config/oidc-discovery.backend.service.js.map +1 -1
  821. package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts +9 -2
  822. package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts.map +1 -1
  823. package/dist/esm/security/authentications/services/anonymous-session.backend.service.js +9 -2
  824. package/dist/esm/security/authentications/services/anonymous-session.backend.service.js.map +1 -1
  825. package/dist/esm/security/authentications/services/auth-credential-verifier.backend.service.d.ts.map +1 -1
  826. package/dist/esm/security/authentications/services/auth-execution-context-factory.backend.service.d.ts.map +1 -1
  827. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.d.ts.map +1 -1
  828. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.js.map +1 -1
  829. package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.d.ts.map +1 -1
  830. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts.map +1 -1
  831. package/dist/esm/security/authentications/services/auth-methods/auth-phone-verification.backend.service.d.ts.map +1 -1
  832. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.d.ts.map +1 -1
  833. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.js.map +1 -1
  834. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.d.ts +97 -0
  835. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.d.ts.map +1 -1
  836. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js +218 -26
  837. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js.map +1 -1
  838. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.d.ts +14 -0
  839. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.d.ts.map +1 -1
  840. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js +36 -0
  841. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js.map +1 -1
  842. package/dist/esm/security/authentications/services/auth-methods/saml-assertion-validator.backend.service.d.ts.map +1 -1
  843. package/dist/esm/security/authentications/services/auth-methods/saml-authentication.backend.service.d.ts.map +1 -1
  844. package/dist/esm/security/authentications/services/auth-methods/saml-metadata.backend.service.d.ts.map +1 -1
  845. package/dist/esm/security/authentications/services/auth-methods/saml-replay-guard.backend.service.d.ts.map +1 -1
  846. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.d.ts.map +1 -1
  847. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.js.map +1 -1
  848. package/dist/esm/security/authentications/services/auth-session-store.backend.service.d.ts.map +1 -1
  849. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.d.ts.map +1 -1
  850. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.js.map +1 -1
  851. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.d.ts.map +1 -1
  852. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.js.map +1 -1
  853. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.d.ts.map +1 -1
  854. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.js.map +1 -1
  855. package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.d.ts.map +1 -1
  856. package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.js.map +1 -1
  857. package/dist/esm/security/authentications/services/custom-impls/scim-tokens.custom-impl.backend.service.d.ts.map +1 -1
  858. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.d.ts.map +1 -1
  859. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts.map +1 -1
  860. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js +57 -1
  861. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js.map +1 -1
  862. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.d.ts.map +1 -1
  863. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.js.map +1 -1
  864. package/dist/esm/security/authentications/services/custom-impls/sso-connection.custom-impl.backend.service.d.ts.map +1 -1
  865. package/dist/esm/security/authentications/services/custom-impls/sso-connection.custom-impl.backend.service.js +11 -1
  866. package/dist/esm/security/authentications/services/custom-impls/sso-connection.custom-impl.backend.service.js.map +1 -1
  867. package/dist/esm/security/authentications/services/email-verification-initiator.backend.service.d.ts.map +1 -1
  868. package/dist/esm/security/authentications/services/machine-token-issuer.backend.service.d.ts.map +1 -1
  869. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.d.ts.map +1 -1
  870. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.js.map +1 -1
  871. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.d.ts.map +1 -1
  872. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.js.map +1 -1
  873. package/dist/esm/security/authentications/services/oidc-user-claims.backend.service.d.ts.map +1 -1
  874. package/dist/esm/security/authentications/services/resolve-active-member-orgs.backend.utils.d.ts.map +1 -1
  875. package/dist/esm/security/authentications/services/utils/__tests__/mock-auth-user-lookup.service.d.ts.map +1 -1
  876. package/dist/esm/security/authentications/services/utils/auth-controller.utils.d.ts.map +1 -1
  877. package/dist/esm/security/authentications/services/utils/auth-credential-ops.backend.service.d.ts.map +1 -1
  878. package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.d.ts.map +1 -1
  879. package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.js.map +1 -1
  880. package/dist/esm/security/authentications/services/utils/auth-response-helper.backend.service.d.ts.map +1 -1
  881. package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.d.ts.map +1 -1
  882. package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.js.map +1 -1
  883. package/dist/esm/security/authentications/services/utils/concurrent-session-eviction.backend.utils.d.ts.map +1 -1
  884. package/dist/esm/security/authentications/services/utils/ensure-user-profile.backend.utils.d.ts.map +1 -1
  885. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.d.ts.map +1 -1
  886. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.js.map +1 -1
  887. package/dist/esm/security/authentications/services/utils/machine-auth-rate-limit.backend.utils.d.ts.map +1 -1
  888. package/dist/esm/security/authentications/services/utils/pkce.backend.utils.d.ts.map +1 -1
  889. package/dist/esm/security/authentications/services/utils/saml-java-availability.d.ts.map +1 -1
  890. package/dist/esm/security/authentications/utils/application-auth-policy-audit.backend.utils.d.ts.map +1 -1
  891. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.d.ts.map +1 -1
  892. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.js.map +1 -1
  893. package/dist/esm/security/authentications/utils/one-off-session-lifetime.backend.utils.d.ts.map +1 -1
  894. package/dist/esm/security/authentications/utils/social-oauth2-purpose.backend.utils.d.ts.map +1 -1
  895. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.d.ts +59 -0
  896. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.d.ts.map +1 -0
  897. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.js +111 -0
  898. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.js.map +1 -0
  899. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.d.ts +57 -0
  900. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.d.ts.map +1 -0
  901. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.js +133 -0
  902. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.js.map +1 -0
  903. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.d.ts +41 -0
  904. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.d.ts.map +1 -0
  905. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.js +157 -0
  906. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.js.map +1 -0
  907. package/dist/esm/security/authorizations/application-wide-read-admission.backend.d.ts +84 -0
  908. package/dist/esm/security/authorizations/application-wide-read-admission.backend.d.ts.map +1 -0
  909. package/dist/esm/security/authorizations/application-wide-read-admission.backend.js +99 -0
  910. package/dist/esm/security/authorizations/application-wide-read-admission.backend.js.map +1 -0
  911. package/dist/esm/security/authorizations/authorization-denial-audit.backend.utils.d.ts.map +1 -1
  912. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.d.ts.map +1 -1
  913. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.js.map +1 -1
  914. package/dist/esm/security/authorizations/initiator-organization-confinement.backend.d.ts.map +1 -1
  915. package/dist/esm/security/authorizations/junction-scope-resolution.backend.d.ts.map +1 -1
  916. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.d.ts.map +1 -1
  917. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.js.map +1 -1
  918. package/dist/esm/security/authorizations/organization-unit-narrowing-enforcement.backend.d.ts.map +1 -1
  919. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.d.ts.map +1 -1
  920. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js +20 -181
  921. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js.map +1 -1
  922. package/dist/esm/security/authorizations/privileged-access-review.backend.utils.d.ts.map +1 -1
  923. package/dist/esm/security/authorizations/relationship-foreign-key-filter.backend.d.ts.map +1 -1
  924. package/dist/esm/security/authorizations/role-ceiling.backend.utils.d.ts.map +1 -1
  925. package/dist/esm/security/authorizations/role-ceiling.backend.utils.js.map +1 -1
  926. package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts +40 -0
  927. package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts.map +1 -1
  928. package/dist/esm/security/authorizations/role-conferral.backend.utils.js +43 -1
  929. package/dist/esm/security/authorizations/role-conferral.backend.utils.js.map +1 -1
  930. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts +27 -17
  931. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts.map +1 -1
  932. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js +27 -17
  933. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js.map +1 -1
  934. package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts +72 -0
  935. package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts.map +1 -1
  936. package/dist/esm/security/authorizations/services/authorizations.backend.service.js +153 -10
  937. package/dist/esm/security/authorizations/services/authorizations.backend.service.js.map +1 -1
  938. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts.map +1 -1
  939. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js.map +1 -1
  940. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.d.ts.map +1 -1
  941. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.js.map +1 -1
  942. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts +139 -1
  943. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts.map +1 -1
  944. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js +474 -33
  945. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js.map +1 -1
  946. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts +40 -0
  947. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts.map +1 -1
  948. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.js.map +1 -1
  949. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.d.ts.map +1 -1
  950. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.js.map +1 -1
  951. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts +19 -0
  952. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts.map +1 -1
  953. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js +38 -0
  954. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js.map +1 -1
  955. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.d.ts.map +1 -1
  956. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.js.map +1 -1
  957. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.d.ts.map +1 -1
  958. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js +17 -1
  959. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js.map +1 -1
  960. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts +14 -0
  961. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts.map +1 -1
  962. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js +16 -0
  963. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js.map +1 -1
  964. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.d.ts.map +1 -1
  965. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js +1 -1
  966. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js.map +1 -1
  967. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts +19 -0
  968. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts.map +1 -1
  969. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js +45 -2
  970. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js.map +1 -1
  971. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.d.ts.map +1 -1
  972. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.js.map +1 -1
  973. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts +37 -1
  974. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts.map +1 -1
  975. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.js.map +1 -1
  976. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.d.ts.map +1 -1
  977. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.js.map +1 -1
  978. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.d.ts.map +1 -1
  979. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.js.map +1 -1
  980. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.d.ts +34 -0
  981. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.d.ts.map +1 -0
  982. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.js +39 -0
  983. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.js.map +1 -0
  984. package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.d.ts.map +1 -1
  985. package/dist/esm/security/consumable-tokens/consumable-token-models.exports.d.ts.map +1 -1
  986. package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.d.ts.map +1 -1
  987. package/dist/esm/security/consumable-tokens/models/consumable-tokens.shared.schemas.d.ts.map +1 -1
  988. package/dist/esm/security/consumable-tokens/models/index.d.ts.map +1 -1
  989. package/dist/esm/security/consumable-tokens/services/__tests__/mock-consumable-token.service.d.ts.map +1 -1
  990. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.d.ts.map +1 -1
  991. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.js.map +1 -1
  992. package/dist/esm/security/credential-rotation-grace.backend.utils.d.ts.map +1 -1
  993. package/dist/esm/security/credential-rotation-grace.backend.utils.js.map +1 -1
  994. package/dist/esm/security/jwt/services/auth-jwt-guard.backend.service.d.ts.map +1 -1
  995. package/dist/esm/security/jwt/services/jwt.backend.service.d.ts.map +1 -1
  996. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.d.ts +13 -0
  997. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.d.ts.map +1 -1
  998. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.js +14 -0
  999. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.js.map +1 -1
  1000. package/dist/esm/security/jwt/utils/jwt-verification-error-classification.backend.utils.d.ts.map +1 -1
  1001. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.d.ts.map +1 -1
  1002. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.js.map +1 -1
  1003. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts.map +1 -1
  1004. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js.map +1 -1
  1005. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.d.ts +39 -0
  1006. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.d.ts.map +1 -0
  1007. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.js +60 -0
  1008. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.js.map +1 -0
  1009. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.d.ts +66 -0
  1010. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.d.ts.map +1 -0
  1011. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.js +75 -0
  1012. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.js.map +1 -0
  1013. package/dist/esm/security/scim/controllers/scim.backend.controller.d.ts.map +1 -1
  1014. package/dist/esm/security/scim/controllers/scim.backend.controller.js.map +1 -1
  1015. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.d.ts.map +1 -1
  1016. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.js.map +1 -1
  1017. package/dist/esm/security/scim/utils/scim-attribute-path-resolver.backend.utils.d.ts.map +1 -1
  1018. package/dist/esm/security/scim/utils/scim-filter-parser.d.ts.map +1 -1
  1019. package/dist/esm/security/scim/utils/scim-response-formatter.d.ts.map +1 -1
  1020. package/dist/esm/security/session-invalidation-fence.backend.utils.d.ts.map +1 -1
  1021. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.d.ts.map +1 -1
  1022. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.js.map +1 -1
  1023. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.d.ts.map +1 -1
  1024. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.js.map +1 -1
  1025. package/dist/esm/security/token-invalidation-fence.backend.utils.d.ts.map +1 -1
  1026. package/dist/esm/testing.d.ts.map +1 -1
  1027. package/dist/esm/users/services/inbound-contact-custom-implementation.backend.service.d.ts.map +1 -1
  1028. package/dist/esm/users/services/user-deletion-audit.custom-impl.backend.service.d.ts.map +1 -1
  1029. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts.map +1 -1
  1030. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.d.ts.map +1 -1
  1031. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.js.map +1 -1
  1032. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.d.ts.map +1 -1
  1033. package/dist/esm/users/services/user-self-custom-implementations.backend.d.ts.map +1 -1
  1034. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.d.ts.map +1 -1
  1035. package/dist/tsconfig.build.tsbuildinfo +1 -1
  1036. package/package.json +9 -9
  1037. package/dist/esm/external-providers/services/flow-actor-design.backend.service.d.ts +0 -45
  1038. package/dist/esm/external-providers/services/flow-actor-design.backend.service.d.ts.map +0 -1
  1039. package/dist/esm/external-providers/services/flow-actor-design.backend.service.js +0 -22
  1040. package/dist/esm/external-providers/services/flow-actor-design.backend.service.js.map +0 -1
  1041. package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts +0 -0
  1042. package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts.map +0 -0
  1043. package/dist/esm/notifications/email/models/email-context-provider.interface.js +0 -0
  1044. package/dist/esm/notifications/email/models/email-context-provider.interface.js.map +0 -0
  1045. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts +0 -0
  1046. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts.map +0 -0
  1047. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js +0 -0
  1048. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js.map +0 -0
  1049. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts +0 -0
  1050. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts.map +0 -0
  1051. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js +0 -0
  1052. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js.map +0 -0
  1053. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts +0 -0
  1054. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts.map +0 -0
  1055. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js +0 -0
  1056. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"billing-reconciliation.batch.backend.service.js","sourceRoot":"","sources":["../../../../../src/billing/batches/billing-reconciliation.batch.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iCAAiC,EAAE,MAAM,4FAA4F,CAAC;AAC/I,OAAO,EAAE,4CAA4C,EAAE,MAAM,gFAAgF,CAAC;AAC9I,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAGpF,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEtD,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,2EAA2E;IAC3E,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,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A4C,CAAC,mBAAmB;YACrF,iBAAiB,EAAE,4CAA4C,CAAC,cAAc;SAC/E;QACD,mBAAmB,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;YACjC,cAAc,EAAE,GAAG,CAAsC,kBAAkB,CAAC,4BAA4B,CAAC;SAC1G,CAAC;QACF,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;YACnD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE7B,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;YAE7D;;;;;eAKG;YACH,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACpC,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9D,CAAC;YAED,OAAO;gBACL,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;gBACnD,mCAAmC,EAAE,MAAM,CAAC,mCAAmC;gBAC/E,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;gBACjD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;gBACnD,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;gBACvD,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;gBACvD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;gBACvD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;gBAC5B,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACnC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Billing Reconciliation — the scheduled tick that asks the provider what it actually holds.\n *\n * ## What this batch is for\n *\n * Local billing state is entirely webhook-derived. `StandardBilling_Interface.retrieveSubscription`\n * documents itself as the read for \"reconciliation (if webhook missed)\", and until 2026-09-09 its\n * only callers were inside the webhook router — so the recovery read ran exactly when a webhook\n * DID arrive, and never when one did not. A lost delivery left a stale subscription still granting\n * entitlements, or an invoice that existed only at the provider, with nothing anywhere that could\n * notice.\n *\n * ## Why every number is reported and not just a total\n *\n * `subscriptionsExamined` is a health metric and `subscriptionsDrifted` is an ALARM. A steady\n * non-zero drift count does not mean the sweep is working — it means webhook delivery is failing\n * and the sweep is papering over it, which is a different problem with a different fix. Reporting\n * one number would hide exactly that distinction.\n *\n * ## Failures are per row and the run keeps going\n *\n * One unreachable subscription must not stop the rest of the application from being reconciled: an\n * unreconciled row is picked up by the next tick at no cost, so continuing is free and stopping\n * costs a whole cycle. The same trade the usage flush makes.\n */\n\nimport { z } from 'zod';\nimport { createCustomBatchExecutionService } from '~wildo-backend-lib/base-classes/services/batches/batches-cronjobs-custom-execution.service';\nimport { ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST } from '~wildo-backend-lib/base-classes/services/batches/engine-custom-batch-manifests';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { BillingReconciliationBackendService } from '~wildo-backend-lib/billing/services/back-office/billing-reconciliation.backend.service';\n\nconst BillingReconciliationInputSchema = z.object({});\n\nconst BillingReconciliationOutputSchema = z.object({\n /** Live subscriptions carrying a provider link that this run looked at. */\n subscriptionsExamined: z.number().int().min(0),\n /** Left alone because a local mutation had just touched them — postponed, not skipped forever. */\n subscriptionsSkippedRecentlyMutated: z.number().int().min(0),\n /** Rows that DISAGREED with the provider. Persistently non-zero means webhooks are being lost. */\n subscriptionsDrifted: z.number().int().min(0),\n subscriptionsRepaired: z.number().int().min(0),\n /** Rows whose provider state could not be read. Reported; local state deliberately untouched. */\n subscriptionsUnreadable: z.number().int().min(0),\n billingAccountsExamined: z.number().int().min(0),\n invoicesExamined: z.number().int().min(0),\n /** Invoices that existed at the provider and nowhere locally. Each one is a lost webhook. */\n invoicesRecovered: z.number().int().min(0),\n invoiceStatusesRepaired: z.number().int().min(0),\n errors: z.number().int().min(0),\n durationMs: z.number().int().min(0),\n});\n\nexport function createBillingReconciliationBatch(): ReturnType<typeof createCustomBatchExecutionService> {\n return createCustomBatchExecutionService({\n input: BillingReconciliationInputSchema,\n output: BillingReconciliationOutputSchema,\n batchCronjob_Context: {\n kind: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.kind,\n resourceIdentifier: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.resourceIdentifier,\n operationIdentifier: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.operationIdentifier,\n cronJobExpression: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.cronExpression,\n },\n resolveDependencies: ({ get }) => ({\n reconciliation: get<BillingReconciliationBackendService>(SAAS_SERVICE_TYPES.BillingReconciliationService),\n }),\n doHandle: async (_input, { logger, dependencies }) => {\n const startTime = Date.now();\n\n const result = await dependencies.reconciliation.reconcile();\n\n /*\n * Every line is logged individually rather than only counted, because each one names a\n * specific subscription or invoice. `error` level throughout: a repaired drift is not good\n * news — it is the record that a webhook was lost and that a customer's entitlements were\n * wrong until this tick — and an unreadable subscription is state nobody can vouch for.\n */\n for (const message of result.errors) {\n logger.error('Billing reconciliation finding', { message });\n }\n\n return {\n subscriptionsExamined: result.subscriptionsExamined,\n subscriptionsSkippedRecentlyMutated: result.subscriptionsSkippedRecentlyMutated,\n subscriptionsDrifted: result.subscriptionsDrifted,\n subscriptionsRepaired: result.subscriptionsRepaired,\n subscriptionsUnreadable: result.subscriptionsUnreadable,\n billingAccountsExamined: result.billingAccountsExamined,\n invoicesExamined: result.invoicesExamined,\n invoicesRecovered: result.invoicesRecovered,\n invoiceStatusesRepaired: result.invoiceStatusesRepaired,\n errors: result.errors.length,\n durationMs: Date.now() - startTime,\n };\n },\n });\n}\n"]}
1
+ {"version":3,"file":"billing-reconciliation.batch.backend.service.js","sourceRoot":"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E,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;gBACjD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;gBACnD,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;gBACvD,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;gBACvD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;gBACvD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;gBAC5B,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACnC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Billing Reconciliation — the scheduled tick that asks the provider what it actually holds.\n *\n * ## What this batch is for\n *\n * Local billing state is entirely webhook-derived. `StandardBilling_Interface.retrieveSubscription`\n * documents itself as the read for \"reconciliation (if webhook missed)\", and until 2026-09-09 its\n * only callers were inside the webhook router — so the recovery read ran exactly when a webhook\n * DID arrive, and never when one did not. A lost delivery left a stale subscription still granting\n * entitlements, or an invoice that existed only at the provider, with nothing anywhere that could\n * notice.\n *\n * ## Why every number is reported and not just a total\n *\n * `subscriptionsExamined` is a health metric and `subscriptionsDrifted` is an ALARM. A steady\n * non-zero drift count does not mean the sweep is working — it means webhook delivery is failing\n * and the sweep is papering over it, which is a different problem with a different fix. Reporting\n * one number would hide exactly that distinction.\n *\n * ## Failures are per row and the run keeps going\n *\n * One unreachable subscription must not stop the rest of the application from being reconciled: an\n * unreconciled row is picked up by the next tick at no cost, so continuing is free and stopping\n * costs a whole cycle. The same trade the usage flush makes.\n */\n\nimport { z } from 'zod';\nimport { createCustomBatchExecutionService } from '~wildo-backend-lib/base-classes/services/batches/batches-cronjobs-custom-execution.service';\nimport { ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST } from '~wildo-backend-lib/base-classes/services/batches/engine-custom-batch-manifests';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { BillingReconciliationBackendService } from '~wildo-backend-lib/billing/services/back-office/billing-reconciliation.backend.service';\n\nconst BillingReconciliationInputSchema = z.object({});\n\nconst BillingReconciliationOutputSchema = z.object({\n /** Live subscriptions carrying a provider link that this run looked at. */\n subscriptionsExamined: z.number().int().min(0),\n /** Left alone because a local mutation had just touched them — postponed, not skipped forever. */\n subscriptionsSkippedRecentlyMutated: z.number().int().min(0),\n /** Rows that DISAGREED with the provider. Persistently non-zero means webhooks are being lost. */\n subscriptionsDrifted: z.number().int().min(0),\n subscriptionsRepaired: z.number().int().min(0),\n /** Rows whose provider state could not be read. Reported; local state deliberately untouched. */\n subscriptionsUnreadable: z.number().int().min(0),\n billingAccountsExamined: z.number().int().min(0),\n invoicesExamined: z.number().int().min(0),\n /** Invoices that existed at the provider and nowhere locally. Each one is a lost webhook. */\n invoicesRecovered: z.number().int().min(0),\n invoiceStatusesRepaired: z.number().int().min(0),\n errors: z.number().int().min(0),\n durationMs: z.number().int().min(0),\n});\n\nexport function createBillingReconciliationBatch(): ReturnType<typeof createCustomBatchExecutionService> {\n return createCustomBatchExecutionService({\n input: BillingReconciliationInputSchema,\n output: BillingReconciliationOutputSchema,\n batchCronjob_Context: {\n kind: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.kind,\n resourceIdentifier: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.resourceIdentifier,\n operationIdentifier: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.operationIdentifier,\n cronJobExpression: ENGINE_BILLING_RECONCILIATION_BATCH_MANIFEST.cronExpression,\n },\n resolveDependencies: ({ get }) => ({\n reconciliation: get<BillingReconciliationBackendService>(SAAS_SERVICE_TYPES.BillingReconciliationService),\n }),\n doHandle: async (_input, { logger, dependencies }) => {\n const startTime = Date.now();\n\n const result = await dependencies.reconciliation.reconcile();\n\n /*\n * Every line is logged individually rather than only counted, because each one names a\n * specific subscription or invoice. `error` level throughout: a repaired drift is not good\n * news — it is the record that a webhook was lost and that a customer's entitlements were\n * wrong until this tick — and an unreadable subscription is state nobody can vouch for.\n */\n for (const message of result.errors) {\n logger.error('Billing reconciliation finding', { message });\n }\n\n return {\n subscriptionsExamined: result.subscriptionsExamined,\n subscriptionsSkippedRecentlyMutated: result.subscriptionsSkippedRecentlyMutated,\n subscriptionsDrifted: result.subscriptionsDrifted,\n subscriptionsRepaired: result.subscriptionsRepaired,\n subscriptionsUnreadable: result.subscriptionsUnreadable,\n billingAccountsExamined: result.billingAccountsExamined,\n invoicesExamined: result.invoicesExamined,\n invoicesRecovered: result.invoicesRecovered,\n invoiceStatusesRepaired: result.invoiceStatusesRepaired,\n errors: result.errors.length,\n durationMs: Date.now() - startTime,\n };\n },\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"usage-flush.batch.backend.service.d.ts","sourceRoot":"","sources":["../../../../../src/billing/batches/usage-flush.batch.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAAE,iCAAiC,EAAE,MAAM,4FAA4F,CAAC;AAqB/I,wBAAgB,qBAAqB,IAAI,UAAU,CAAC,OAAO,iCAAiC,CAAC,CAyC5F"}
1
+ {"version":3,"file":"usage-flush.batch.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/billing/batches/usage-flush.batch.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAAE,iCAAiC,EAAE,MAAM,4FAA4F,CAAC;AAqB/I,wBAAgB,qBAAqB,IAAI,UAAU,CAAC,OAAO,iCAAiC,CAAC,CAyC5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"usage-flush.batch.backend.service.js","sourceRoot":"","sources":["../../../../../src/billing/batches/usage-flush.batch.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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,EAAE,iCAAiC,CAAC,kBAAkB;YACxE,mBAAmB,EAAE,iCAAiC,CAAC,mBAAmB;YAC1E,iBAAiB,EAAE,iCAAiC,CAAC,cAAc;SACpE;QACD,mBAAmB,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;YACjC,aAAa,EAAE,GAAG,CAA8B,kBAAkB,CAAC,oBAAoB,CAAC;SACzF,CAAC;QACF,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;YACnD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE7B,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;YAElE;;;;;;;eAOG;YACH,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACpC,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YACjD,CAAC;YAED,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;gBAC5B,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACnC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Usage Flush — reports recorded metered usage to the billing provider.\n *\n * ## What this batch is for\n *\n * It is the LAST HOP to money for every METERED product, and until 2026-09-08 it did not exist.\n * `UsageMeteringBackendService.flushToProvider` had no caller anywhere — not in the engine, not in\n * the platform, not in either dogfood application — so a metered product could be declared, priced\n * and synced to the provider while no usage was ever reported (#415). Everything up to the local\n * `usageRecords` row worked; the hop that turns a row into a charge was missing, and the resources\n * registry's own comment already said no cron called it.\n *\n * ## The cadence here is a CEILING, not the interval\n *\n * Each product authors `metering.flushIntervalMinutes`, and the flush decides PER PRODUCT whether\n * enough time has passed since its oldest pending row. This tick only has to be at least as fast as\n * the fastest interval an author can reasonably want; when nothing is due it costs one indexed query\n * per billing scope returning nothing.\n *\n * A slower default would silently cap every product's authored interval at the tick — which is\n * precisely the defect this issue is about: an authored value the runtime quietly overrides.\n *\n * ## Why the run reports quantities and not only rows\n *\n * Getting metering wrong moves money in BOTH directions and neither direction announces itself: an\n * under-report is revenue that never appears, an over-report is a customer charged twice. A count of\n * ROWS can see neither, because rows carry quantities — ten rows reported can be any amount at all.\n * So the output states what was due and what was sent, and a mismatch is raised as an error rather\n * than left as two numbers a reader is expected to compare.\n *\n * ## Failure is per group, and the run keeps going\n *\n * One account's provider failure must not stop every other account's usage from being reported: an\n * unreported row stays selectable by the next run, so continuing costs nothing and stopping costs a\n * whole cycle. The one exception is a pending set so large it trips the drain's runaway guard, where\n * the scope reports NOTHING deliberately — see `listAllUnreportedRecords`.\n *\n * assurance-control: WILDO.BILLING.USAGE_REPORTING — metered usage recorded against an account is\n * reported to the billing provider on a schedule, and each run reconciles what it sent against what\n * was due.\n */\n\nimport { z } from 'zod';\nimport { createCustomBatchExecutionService } from '~wildo-backend-lib/base-classes/services/batches/batches-cronjobs-custom-execution.service';\nimport { ENGINE_USAGE_FLUSH_BATCH_MANIFEST } from '~wildo-backend-lib/base-classes/services/batches/engine-custom-batch-manifests';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { UsageMeteringBackendService } from '~wildo-backend-lib/billing/services/back-office/usage-metering.backend.service';\n\nconst UsageFlushInputSchema = z.object({});\n\nconst UsageFlushOutputSchema = z.object({\n /** Rows that were DUE this run — not rows pending, which is larger while a product is still waiting. */\n totalRecords: z.number().int().min(0),\n /** Rows successfully marked reported. */\n reported: z.number().int().min(0),\n /** Rows that were not reported, or were reported and could not be marked. */\n failed: z.number().int().min(0),\n /** Quantity of usage that was due, and quantity the provider was told about. Meant to be equal. */\n quantityRecorded: z.number().min(0),\n quantityReported: z.number().min(0),\n errors: z.number().int().min(0),\n durationMs: z.number().int().min(0),\n});\n\nexport function createUsageFlushBatch(): ReturnType<typeof createCustomBatchExecutionService> {\n return createCustomBatchExecutionService({\n input: UsageFlushInputSchema,\n output: UsageFlushOutputSchema,\n batchCronjob_Context: {\n kind: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.kind,\n resourceIdentifier: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.resourceIdentifier,\n operationIdentifier: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.operationIdentifier,\n cronJobExpression: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.cronExpression,\n },\n resolveDependencies: ({ get }) => ({\n usageMetering: get<UsageMeteringBackendService>(SAAS_SERVICE_TYPES.UsageMeteringService),\n }),\n doHandle: async (_input, { logger, dependencies }) => {\n const startTime = Date.now();\n\n const result = await dependencies.usageMetering.flushToProvider();\n\n /*\n * Every error is logged individually rather than only counted, because each one names a\n * specific account and product whose usage did not reach the provider. A count tells an\n * operator that something is wrong; only the line tells them whose money it is.\n *\n * `error` level, not `warn`: unreported usage is revenue that will not be billed unless someone\n * acts, and the reconciliation line among these is the one that says how much.\n */\n for (const message of result.errors) {\n logger.error('Usage flush error', { message });\n }\n\n return {\n totalRecords: result.totalRecords,\n reported: result.reported,\n failed: result.failed,\n quantityRecorded: result.quantityRecorded,\n quantityReported: result.quantityReported,\n errors: result.errors.length,\n durationMs: Date.now() - startTime,\n };\n },\n });\n}\n"]}
1
+ {"version":3,"file":"usage-flush.batch.backend.service.js","sourceRoot":"","sources":["../../../../src/billing/batches/usage-flush.batch.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,CAAC,EAAE,M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B;YAC1E,iBAAiB,EAAE,iCAAiC,CAAC,cAAc;SACpE;QACD,mBAAmB,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;YACjC,aAAa,EAAE,GAAG,CAA8B,kBAAkB,CAAC,oBAAoB,CAAC;SACzF,CAAC;QACF,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;YACnD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE7B,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;YAElE;;;;;;;eAOG;YACH,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACpC,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YACjD,CAAC;YAED,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;gBAC5B,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACnC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Usage Flush — reports recorded metered usage to the billing provider.\n *\n * ## What this batch is for\n *\n * It is the LAST HOP to money for every METERED product, and until 2026-09-08 it did not exist.\n * `UsageMeteringBackendService.flushToProvider` had no caller anywhere — not in the engine, not in\n * the platform, not in either dogfood application — so a metered product could be declared, priced\n * and synced to the provider while no usage was ever reported (#415). Everything up to the local\n * `usageRecords` row worked; the hop that turns a row into a charge was missing, and the resources\n * registry's own comment already said no cron called it.\n *\n * ## The cadence here is a CEILING, not the interval\n *\n * Each product authors `metering.flushIntervalMinutes`, and the flush decides PER PRODUCT whether\n * enough time has passed since its oldest pending row. This tick only has to be at least as fast as\n * the fastest interval an author can reasonably want; when nothing is due it costs one indexed query\n * per billing scope returning nothing.\n *\n * A slower default would silently cap every product's authored interval at the tick — which is\n * precisely the defect this issue is about: an authored value the runtime quietly overrides.\n *\n * ## Why the run reports quantities and not only rows\n *\n * Getting metering wrong moves money in BOTH directions and neither direction announces itself: an\n * under-report is revenue that never appears, an over-report is a customer charged twice. A count of\n * ROWS can see neither, because rows carry quantities — ten rows reported can be any amount at all.\n * So the output states what was due and what was sent, and a mismatch is raised as an error rather\n * than left as two numbers a reader is expected to compare.\n *\n * ## Failure is per group, and the run keeps going\n *\n * One account's provider failure must not stop every other account's usage from being reported: an\n * unreported row stays selectable by the next run, so continuing costs nothing and stopping costs a\n * whole cycle. The one exception is a pending set so large it trips the drain's runaway guard, where\n * the scope reports NOTHING deliberately — see `listAllUnreportedRecords`.\n *\n * assurance-control: WILDO.BILLING.USAGE_REPORTING — metered usage recorded against an account is\n * reported to the billing provider on a schedule, and each run reconciles what it sent against what\n * was due.\n */\n\nimport { z } from 'zod';\nimport { createCustomBatchExecutionService } from '~wildo-backend-lib/base-classes/services/batches/batches-cronjobs-custom-execution.service';\nimport { ENGINE_USAGE_FLUSH_BATCH_MANIFEST } from '~wildo-backend-lib/base-classes/services/batches/engine-custom-batch-manifests';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { UsageMeteringBackendService } from '~wildo-backend-lib/billing/services/back-office/usage-metering.backend.service';\n\nconst UsageFlushInputSchema = z.object({});\n\nconst UsageFlushOutputSchema = z.object({\n /** Rows that were DUE this run — not rows pending, which is larger while a product is still waiting. */\n totalRecords: z.number().int().min(0),\n /** Rows successfully marked reported. */\n reported: z.number().int().min(0),\n /** Rows that were not reported, or were reported and could not be marked. */\n failed: z.number().int().min(0),\n /** Quantity of usage that was due, and quantity the provider was told about. Meant to be equal. */\n quantityRecorded: z.number().min(0),\n quantityReported: z.number().min(0),\n errors: z.number().int().min(0),\n durationMs: z.number().int().min(0),\n});\n\nexport function createUsageFlushBatch(): ReturnType<typeof createCustomBatchExecutionService> {\n return createCustomBatchExecutionService({\n input: UsageFlushInputSchema,\n output: UsageFlushOutputSchema,\n batchCronjob_Context: {\n kind: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.kind,\n resourceIdentifier: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.resourceIdentifier,\n operationIdentifier: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.operationIdentifier,\n cronJobExpression: ENGINE_USAGE_FLUSH_BATCH_MANIFEST.cronExpression,\n },\n resolveDependencies: ({ get }) => ({\n usageMetering: get<UsageMeteringBackendService>(SAAS_SERVICE_TYPES.UsageMeteringService),\n }),\n doHandle: async (_input, { logger, dependencies }) => {\n const startTime = Date.now();\n\n const result = await dependencies.usageMetering.flushToProvider();\n\n /*\n * Every error is logged individually rather than only counted, because each one names a\n * specific account and product whose usage did not reach the provider. A count tells an\n * operator that something is wrong; only the line tells them whose money it is.\n *\n * `error` level, not `warn`: unreported usage is revenue that will not be billed unless someone\n * acts, and the reconciliation line among these is the one that says how much.\n */\n for (const message of result.errors) {\n logger.error('Usage flush error', { message });\n }\n\n return {\n totalRecords: result.totalRecords,\n reported: result.reported,\n failed: result.failed,\n quantityRecorded: result.quantityRecorded,\n quantityReported: result.quantityReported,\n errors: result.errors.length,\n durationMs: Date.now() - startTime,\n };\n },\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"billing-provider-event-settlement.backend.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/billing/models/billing-provider-event-settlement.backend.schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,qBAAqB,EAIrB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAc/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,oCAAoC;;;;;;iBAoC/C,CAAC;AAEH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC;AAElG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gDAAgD,QAAiB,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,oBAAY,wCAAwC;IAClD,QAAQ,aAAa;CACtB;AAED,KAAK,6CAA6C,GAC9C,qBAAqB,CAAC,IAAI,GAC1B,qBAAqB,CAAC,MAAM,GAC5B,qBAAqB,CAAC,MAAM,CAAC;AAWjC,eAAO,MAAM,yEAAyE,GACpF,wBAAwB,oBAAoB,EAAE,KAC7C,qBAAqB,CAAC,SAAS,EAAE,6CAA6C,EAAE,OAAO,oCAAoC,CAwB7H,CAAC"}
1
+ {"version":3,"file":"billing-provider-event-settlement.backend.schemas.d.ts","sourceRoot":"","sources":["../../../../src/billing/models/billing-provider-event-settlement.backend.schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,qBAAqB,EAIrB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAc/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,oCAAoC;;;;;;iBAoC/C,CAAC;AAEH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC;AAElG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gDAAgD,QAAiB,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,oBAAY,wCAAwC;IAClD,QAAQ,aAAa;CACtB;AAED,KAAK,6CAA6C,GAC9C,qBAAqB,CAAC,IAAI,GAC1B,qBAAqB,CAAC,MAAM,GAC5B,qBAAqB,CAAC,MAAM,CAAC;AAWjC,eAAO,MAAM,yEAAyE,GACpF,wBAAwB,oBAAoB,EAAE,KAC7C,qBAAqB,CAAC,SAAS,EAAE,6CAA6C,EAAE,OAAO,oCAAoC,CAwB7H,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"billing-provider-event-settlement.backend.schemas.js","sourceRoot":"","sources":["../../../../../src/billing/models/billing-provider-event-settlement.backend.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,0CAA0C,EAC1C,0BAA0B,EAC1B,4BAA4B,GAG7B,MAAM,uBAAuB,CAAC;AAE/B;;;;;;GAMG;AACH,OAAO,EACL,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,wDAAwD,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3D;;;OAGG;IACH,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE;IAErC;;;;;;;OAOG;IACH,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;IAEzC,4FAA4F;IAC5F,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAE5B;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAC,IAAI,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AAC,MAAM;SAC7B;QAED,uBAAuB,EAAE;YACvB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE;YAC/D,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE;YACjE,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE;SAClE;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { z } from 'zod';\n\nimport {\n CORE_APP_ROLES,\n CoreResourceOperation,\n createResourceConfiguration_Initialization,\n ResourceOperationRiskLevel,\n ResourceOperationVariantType,\n type ResourceConfiguration,\n type ResourceRelationship,\n} from '@wildo-ai/saas-models';\n\n/*\n * entrypoint-closure-waiver: the same crossing (and the same measured result) as\n * `external-data-pipeline-state.backend.schemas` — `resources-types.backend.schemas` is published\n * only by the `./backend-resource-registry` subpath, but no root-exported contract of this module\n * INFERS a type from it: the factory's return type is annotated explicitly and\n * `BillingProviderEventSettlement` is a structural `z.infer`.\n */\nimport {\n BackendResourceFieldIdentifier,\n BackendResourceType,\n} from '../../resources/models/resources-types.backend.schemas';\n\n/**\n * ============================================================================\n * BillingProviderEventSettlement — the DURABLE idempotency ledger for money-affecting\n * billing webhook events\n * ============================================================================\n *\n * ## Why a row, when a `Set` was already there\n *\n * `BillingWebhookEventRouterBackendService` suppressed duplicate `checkout.session.completed`\n * deliveries with a process-local `Set` capped at 10 000 entries. Its own comment named the\n * limitation it could see — \"does not protect against retries delivered to different instances\" —\n * and understated it twice over:\n *\n * - **Multi-instance.** Every provider delivers at-least-once. A retry routed to another replica\n * finds an empty `Set` and tops the credit pool up a second time.\n * - **SINGLE instance.** The LRU eviction means the same replica forgets a session after 10 000\n * others, so a late retry double-grants there too. Nothing about the defect needed two\n * processes.\n * - **Restart.** The `Set` is reconstructed empty on every deploy, and a deploy is the single most\n * likely reason a delivery failed and is being retried.\n *\n * Money that has already been granted cannot be un-granted by a later correction, so the\n * suppression has to live where every replica — and every future replica — can see it. That is a\n * durable row, and the collision has to be a STORE-LEVEL constraint rather than a read-then-write,\n * because two concurrent deliveries both read \"not yet settled\" before either writes.\n *\n * ## Why the claim is the PRIMARY KEY, and carries no secondary unique index\n *\n * `_id` is DERIVED from the claim key ({@link billingProviderEventSettlementId}) rather than minted,\n * so two deliveries of the same provider event compute the same identity and the second INSERT\n * collides on the primary key. Both adapters enforce that natively and identically — MongoDB\n * indexes `_id` implicitly, and the SQL planner emits it as the PRIMARY KEY — so this needs no\n * `.isUnique()` field beside it, and there is no second constraint that could be planned on one\n * adapter and not the other.\n *\n * The digest is 24 hexadecimal characters because that is the ONE identity shape both adapters\n * accept: the zod→mongoose convertor types a top-level `_id` as `Schema.Types.ObjectId`\n * unconditionally (a UUID there produces a row Mongoose cannot hydrate — measured on consumable\n * tokens), while the SQL planner types `_id` as a plain text column. A truncated SHA-256 satisfies\n * both.\n *\n * ## What the row does NOT do\n *\n * It is not a webhook audit log. It records only what a second delivery must be able to ask —\n * *has this already been applied, and if not, is somebody applying it right now?* — plus the\n * `claimKey` in readable form so an operator reading the table can tell which provider event a row\n * belongs to without reversing a digest.\n *\n * REPOSITORY_ONLY on every operation, like its `DataSeedRun` and `ExternalDataPipelineState`\n * siblings: the webhook router is the only writer and there is no reader outside the engine.\n */\nexport const BillingProviderEventSettlementSchema = z.object({\n /**\n * The claim itself, derived from `claimKey` — see the header for why the identity rather than a\n * secondary unique field carries it.\n */\n _id: z.string().min(1).isPrimaryKey(),\n\n /**\n * The claim key in readable form: `<eventType>:<checkout session id or provider event id>`.\n *\n * Stored ALONGSIDE the digest it produced, not instead of it. A digest is unreadable, and an\n * operator asking \"did we settle session cs_live_…?\" needs a column to filter on; a second unique\n * constraint here would be a second thing that must agree with the primary key for no gain, so\n * this is indexed and NOT unique.\n */\n claimKey: z.string().min(1).isDBIndexed(),\n\n /** The provider event type the claim was taken for — `checkout.session.completed` today. */\n eventType: z.string().min(1),\n\n /**\n * When a handler took the claim. Refreshed when a STALE claim is taken over, which is what makes\n * this the lease timestamp rather than a creation timestamp.\n */\n claimedAt: z.date().isDBIndexed(),\n\n /**\n * Set once the money-affecting work COMPLETED. Absent while a handler holds the claim.\n *\n * The distinction is the whole reason the row has two timestamps: a claim with no `appliedAt` is\n * either in flight or was abandoned by a process that died, and only the second case may be\n * re-taken. `{ $exists: false }` is the one presence predicate both adapters answer identically\n * (MongoDB: absent path; PostgreSQL: `IS NULL`), which is why the state is expressed as the\n * absence of a value rather than as a status enum that would need its own vocabulary.\n */\n appliedAt: z.date().isDBIndexed().optional(),\n});\n\nexport type BillingProviderEventSettlement = z.infer<typeof BillingProviderEventSettlementSchema>;\n\n/**\n * How long a claim may be held before another delivery of the same event may take it over.\n *\n * The window exists for exactly one failure: a handler claims, then the process dies before the\n * grant lands. Without a takeover the credit would be lost forever — the row says \"claimed\" and\n * nothing would ever apply it.\n *\n * Fifteen minutes is chosen against the RETRY CADENCE, not against the handler's duration. The\n * handler takes milliseconds, so any value above a few seconds covers the honest in-flight case;\n * what matters at the other end is that the window is comfortably shorter than the interval at\n * which a provider re-delivers a failed event (Stripe backs off to hours over its three-day retry\n * schedule), or the takeover would never get its turn.\n */\nexport const BILLING_PROVIDER_EVENT_SETTLEMENT_CLAIM_LEASE_MS = 15 * 60 * 1000;\n\n/**\n * Derive the durable claim identity for one provider event.\n *\n * SHA-256 truncated to 24 hex characters — see the schema header for why that shape and not a UUID.\n * The truncation leaves 96 bits, so a collision between two DIFFERENT provider events would need\n * on the order of 2^48 of them; a collision would suppress a legitimate grant, which is why the\n * bound is stated rather than assumed.\n */\nexport function billingProviderEventSettlementId(claimKey: string): string {\n return createHash('sha256').update(claimKey).digest('hex').slice(0, 24);\n}\n\nexport enum BillingProviderEventSettlementVariantKey {\n INTERNAL = 'internal',\n}\n\ntype BillingProviderEventSettlement_CoreOperations =\n | CoreResourceOperation.READ\n | CoreResourceOperation.CREATE\n | CoreResourceOperation.UPDATE;\n\nconst internalVariant = () => ({\n variantKey: BillingProviderEventSettlementVariantKey.INTERNAL,\n // The literal annotation keeps the variant inside the discriminated builder union.\n variantType: ResourceOperationVariantType.REPOSITORY_ONLY as ResourceOperationVariantType.REPOSITORY_ONLY,\n isDefault: true,\n roles: [CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN],\n riskLevel: ResourceOperationRiskLevel.LOW,\n});\n\nexport const billingProviderEventSettlementResourceConfiguration_InitializationFactory = (\n resourcesRelationships: ResourceRelationship[],\n): ResourceConfiguration<undefined, BillingProviderEventSettlement_CoreOperations, typeof BillingProviderEventSettlementSchema> => {\n return createResourceConfiguration_Initialization<\n undefined,\n BillingProviderEventSettlement_CoreOperations,\n typeof BillingProviderEventSettlementSchema\n >({\n mainSchema: BillingProviderEventSettlementSchema,\n resourceIdentifier: BackendResourceType.BILLING_PROVIDER_EVENT_SETTLEMENTS,\n resourceFieldIdentifier: BackendResourceFieldIdentifier[BackendResourceType.BILLING_PROVIDER_EVENT_SETTLEMENTS],\n resourceRelationships: resourcesRelationships,\n isSystemResource: true,\n\n coreOperations: [\n CoreResourceOperation.READ,\n CoreResourceOperation.CREATE,\n CoreResourceOperation.UPDATE,\n ],\n\n operationsConfiguration: {\n [CoreResourceOperation.READ]: { variants: [internalVariant()] },\n [CoreResourceOperation.CREATE]: { variants: [internalVariant()] },\n [CoreResourceOperation.UPDATE]: { variants: [internalVariant()] },\n },\n });\n};\n"]}
1
+ {"version":3,"file":"billing-provider-event-settlement.backend.schemas.js","sourceRoot":"","sources":["../../../../src/billing/models/billing-provider-event-settlement.backend.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,0CAA0C,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,GAAG,GAAG,EAAE,CAAC,CAAC;IAC7B,UAAU,EAAE,wCAAwC,CAAC,QAAQ;IAC7D,mFAAmF;IACnF,WAAW,EAAE,4BAA4B,CAAC,eAA+D;IACzG,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,CAAC,cAAc,CAAC,qBAAqB,CAAC;IAC7C,SAAS,EAAE,0BAA0B,CAAC,GAAG;CAC1C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yEAAyE,GAAG,CACvF,sBAA8C,EACgF,EAAE;IAChI,OAAO,0CAA0C,CAI/C;QACA,UAAU,EAAE,oCAAoC;QAChD,kBAAkB,EAAE,mBAAmB,CAAC,kCAAkC;QAC1E,uBAAuB,EAAE,8BAA8B,CAAC,mBAAmB,CAAC,kCAAkC,CAAC;QAC/G,qBAAqB,EAAE,sBAAsB;QAC7C,gBAAgB,EAAE,IAAI;QAEtB,cAAc,EAAE;YACd,qBAAqB,CAAC,IAAI;YAC1B,qBAAqB,CAAC,MAAM;YAC5B,qBAAqB,CAAC,MAAM;SAC7B;QAED,uBAAuB,EAAE;YACvB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE;YAC/D,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE;YACjE,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE;SAClE;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { z } from 'zod';\n\nimport {\n CORE_APP_ROLES,\n CoreResourceOperation,\n createResourceConfiguration_Initialization,\n ResourceOperationRiskLevel,\n ResourceOperationVariantType,\n type ResourceConfiguration,\n type ResourceRelationship,\n} from '@wildo-ai/saas-models';\n\n/*\n * entrypoint-closure-waiver: the same crossing (and the same measured result) as\n * `external-data-pipeline-state.backend.schemas` — `resources-types.backend.schemas` is published\n * only by the `./backend-resource-registry` subpath, but no root-exported contract of this module\n * INFERS a type from it: the factory's return type is annotated explicitly and\n * `BillingProviderEventSettlement` is a structural `z.infer`.\n */\nimport {\n BackendResourceFieldIdentifier,\n BackendResourceType,\n} from '../../resources/models/resources-types.backend.schemas';\n\n/**\n * ============================================================================\n * BillingProviderEventSettlement — the DURABLE idempotency ledger for money-affecting\n * billing webhook events\n * ============================================================================\n *\n * ## Why a row, when a `Set` was already there\n *\n * `BillingWebhookEventRouterBackendService` suppressed duplicate `checkout.session.completed`\n * deliveries with a process-local `Set` capped at 10 000 entries. Its own comment named the\n * limitation it could see — \"does not protect against retries delivered to different instances\" —\n * and understated it twice over:\n *\n * - **Multi-instance.** Every provider delivers at-least-once. A retry routed to another replica\n * finds an empty `Set` and tops the credit pool up a second time.\n * - **SINGLE instance.** The LRU eviction means the same replica forgets a session after 10 000\n * others, so a late retry double-grants there too. Nothing about the defect needed two\n * processes.\n * - **Restart.** The `Set` is reconstructed empty on every deploy, and a deploy is the single most\n * likely reason a delivery failed and is being retried.\n *\n * Money that has already been granted cannot be un-granted by a later correction, so the\n * suppression has to live where every replica — and every future replica — can see it. That is a\n * durable row, and the collision has to be a STORE-LEVEL constraint rather than a read-then-write,\n * because two concurrent deliveries both read \"not yet settled\" before either writes.\n *\n * ## Why the claim is the PRIMARY KEY, and carries no secondary unique index\n *\n * `_id` is DERIVED from the claim key ({@link billingProviderEventSettlementId}) rather than minted,\n * so two deliveries of the same provider event compute the same identity and the second INSERT\n * collides on the primary key. Both adapters enforce that natively and identically — MongoDB\n * indexes `_id` implicitly, and the SQL planner emits it as the PRIMARY KEY — so this needs no\n * `.isUnique()` field beside it, and there is no second constraint that could be planned on one\n * adapter and not the other.\n *\n * The digest is 24 hexadecimal characters because that is the ONE identity shape both adapters\n * accept: the zod→mongoose convertor types a top-level `_id` as `Schema.Types.ObjectId`\n * unconditionally (a UUID there produces a row Mongoose cannot hydrate — measured on consumable\n * tokens), while the SQL planner types `_id` as a plain text column. A truncated SHA-256 satisfies\n * both.\n *\n * ## What the row does NOT do\n *\n * It is not a webhook audit log. It records only what a second delivery must be able to ask —\n * *has this already been applied, and if not, is somebody applying it right now?* — plus the\n * `claimKey` in readable form so an operator reading the table can tell which provider event a row\n * belongs to without reversing a digest.\n *\n * REPOSITORY_ONLY on every operation, like its `DataSeedRun` and `ExternalDataPipelineState`\n * siblings: the webhook router is the only writer and there is no reader outside the engine.\n */\nexport const BillingProviderEventSettlementSchema = z.object({\n /**\n * The claim itself, derived from `claimKey` — see the header for why the identity rather than a\n * secondary unique field carries it.\n */\n _id: z.string().min(1).isPrimaryKey(),\n\n /**\n * The claim key in readable form: `<eventType>:<checkout session id or provider event id>`.\n *\n * Stored ALONGSIDE the digest it produced, not instead of it. A digest is unreadable, and an\n * operator asking \"did we settle session cs_live_…?\" needs a column to filter on; a second unique\n * constraint here would be a second thing that must agree with the primary key for no gain, so\n * this is indexed and NOT unique.\n */\n claimKey: z.string().min(1).isDBIndexed(),\n\n /** The provider event type the claim was taken for — `checkout.session.completed` today. */\n eventType: z.string().min(1),\n\n /**\n * When a handler took the claim. Refreshed when a STALE claim is taken over, which is what makes\n * this the lease timestamp rather than a creation timestamp.\n */\n claimedAt: z.date().isDBIndexed(),\n\n /**\n * Set once the money-affecting work COMPLETED. Absent while a handler holds the claim.\n *\n * The distinction is the whole reason the row has two timestamps: a claim with no `appliedAt` is\n * either in flight or was abandoned by a process that died, and only the second case may be\n * re-taken. `{ $exists: false }` is the one presence predicate both adapters answer identically\n * (MongoDB: absent path; PostgreSQL: `IS NULL`), which is why the state is expressed as the\n * absence of a value rather than as a status enum that would need its own vocabulary.\n */\n appliedAt: z.date().isDBIndexed().optional(),\n});\n\nexport type BillingProviderEventSettlement = z.infer<typeof BillingProviderEventSettlementSchema>;\n\n/**\n * How long a claim may be held before another delivery of the same event may take it over.\n *\n * The window exists for exactly one failure: a handler claims, then the process dies before the\n * grant lands. Without a takeover the credit would be lost forever — the row says \"claimed\" and\n * nothing would ever apply it.\n *\n * Fifteen minutes is chosen against the RETRY CADENCE, not against the handler's duration. The\n * handler takes milliseconds, so any value above a few seconds covers the honest in-flight case;\n * what matters at the other end is that the window is comfortably shorter than the interval at\n * which a provider re-delivers a failed event (Stripe backs off to hours over its three-day retry\n * schedule), or the takeover would never get its turn.\n */\nexport const BILLING_PROVIDER_EVENT_SETTLEMENT_CLAIM_LEASE_MS = 15 * 60 * 1000;\n\n/**\n * Derive the durable claim identity for one provider event.\n *\n * SHA-256 truncated to 24 hex characters — see the schema header for why that shape and not a UUID.\n * The truncation leaves 96 bits, so a collision between two DIFFERENT provider events would need\n * on the order of 2^48 of them; a collision would suppress a legitimate grant, which is why the\n * bound is stated rather than assumed.\n */\nexport function billingProviderEventSettlementId(claimKey: string): string {\n return createHash('sha256').update(claimKey).digest('hex').slice(0, 24);\n}\n\nexport enum BillingProviderEventSettlementVariantKey {\n INTERNAL = 'internal',\n}\n\ntype BillingProviderEventSettlement_CoreOperations =\n | CoreResourceOperation.READ\n | CoreResourceOperation.CREATE\n | CoreResourceOperation.UPDATE;\n\nconst internalVariant = () => ({\n variantKey: BillingProviderEventSettlementVariantKey.INTERNAL,\n // The literal annotation keeps the variant inside the discriminated builder union.\n variantType: ResourceOperationVariantType.REPOSITORY_ONLY as ResourceOperationVariantType.REPOSITORY_ONLY,\n isDefault: true,\n roles: [CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN],\n riskLevel: ResourceOperationRiskLevel.LOW,\n});\n\nexport const billingProviderEventSettlementResourceConfiguration_InitializationFactory = (\n resourcesRelationships: ResourceRelationship[],\n): ResourceConfiguration<undefined, BillingProviderEventSettlement_CoreOperations, typeof BillingProviderEventSettlementSchema> => {\n return createResourceConfiguration_Initialization<\n undefined,\n BillingProviderEventSettlement_CoreOperations,\n typeof BillingProviderEventSettlementSchema\n >({\n mainSchema: BillingProviderEventSettlementSchema,\n resourceIdentifier: BackendResourceType.BILLING_PROVIDER_EVENT_SETTLEMENTS,\n resourceFieldIdentifier: BackendResourceFieldIdentifier[BackendResourceType.BILLING_PROVIDER_EVENT_SETTLEMENTS],\n resourceRelationships: resourcesRelationships,\n isSystemResource: true,\n\n coreOperations: [\n CoreResourceOperation.READ,\n CoreResourceOperation.CREATE,\n CoreResourceOperation.UPDATE,\n ],\n\n operationsConfiguration: {\n [CoreResourceOperation.READ]: { variants: [internalVariant()] },\n [CoreResourceOperation.CREATE]: { variants: [internalVariant()] },\n [CoreResourceOperation.UPDATE]: { variants: [internalVariant()] },\n },\n });\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-billing.backend.service.d.ts","sourceRoot":"","sources":["../../../../../../src/billing/services/back-office/abstract-billing.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EAItB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAEnH,8BACsB,6BAA6B;IAQZ,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa;IAChB,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,qCAAqC;IACnE,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,qCAAqC;IAC/F,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,+BAA+B;IACzE,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,0BAA0B;IAX7G,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAEjF,sEAAsE;IACtE,SAAS,CAAC,eAAe,EAAE,yBAAyB,GAAG,IAAI,CAAQ;IACnE,SAAS,CAAC,aAAa,UAAS;gBAGwB,MAAM,EAAE,aAAa,EACG,gBAAgB,EAAE,qCAAqC,EAChD,uBAAuB,EAAE,qCAAqC,EAC5E,iBAAiB,EAAE,+BAA+B,EACtD,YAAY,EAAE,0BAA0B;IAW7G;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAKvE,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAanC;;;;;;;;;;;;;;;;;;;;OAoBG;cACa,WAAW,CAAC,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAW7H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,SAAS,CAAC,gBAAgB,CACxB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,GAAE,MAAM,GAAG,OAAgB,GAClC,IAAI;CAsBR"}
1
+ {"version":3,"file":"abstract-billing.backend.service.d.ts","sourceRoot":"","sources":["../../../../../src/billing/services/back-office/abstract-billing.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EAItB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,KAAK,EAAE,a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AC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAW7H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,SAAS,CAAC,gBAAgB,CACxB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,GAAE,MAAM,GAAG,OAAgB,GAClC,IAAI;CAsBR"}
@@ -1 +1 @@
1
- {"version":3,"file":"billing-feature-sync.backend.service.d.ts","sourceRoot":"","sources":["../../../../../../src/billing/services/back-office/billing-feature-sync.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAIL,KAAK,aAAa,EAYnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,qGAAqG,CAAC;AACrK,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uDAAuD,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,kFAAkF,CAAC;AAEjI,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,kFAAkF,CAAC;AAChJ,OAAO,EAAE,KAAK,uBAAuB,EAA6B,MAAM,mFAAmF,CAAC;AAU5J,qBACa,gCAAiC,SAAQ,6BAA6B;IAOhB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IAC3D,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAR1D,MAAM,EAAE,aAAa,EACG,gBAAgB,EAAE,qCAAqC,EAChD,uBAAuB,EAAE,qCAAqC,EAC5E,iBAAiB,EAAE,+BAA+B,EACtD,YAAY,EAAE,0BAA0B,EACR,oBAAoB,EAAE,yCAAyC,EACnF,YAAY,EAAE,YAAY,EACxB,gBAAgB,EAAE,gBAAgB,EAClB,eAAe,EAAE,uCAAuC;IASxI;;;;;;;;;;;;OAYG;IACU,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCpH;;;OAGG;IACU,6BAA6B,CACxC,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EACxB,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,aAAa,CAAC;IA6BzB;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAyD7F;;;;;;;;OAQG;IACH,OAAO,CAAC,wBAAwB;IAgEhC;;;;;;;OAOG;YACW,2BAA2B;IA0DzC;;OAEG;YACW,sBAAsB;IAcpC;;;OAGG;YACW,wBAAwB;YAoCxB,iBAAiB;YAcjB,sBAAsB;YAiBtB,UAAU;IAgBxB;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAOpC;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAGhC"}
1
+ {"version":3,"file":"billing-feature-sync.backend.service.d.ts","sourceRoot":"","sources":["../../../../../src/billing/services/back-office/billing-feature-sync.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAIL,KAAK,aAAa,EAYnB,MAAM,uBAAuB,CAA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;OAGG;IACU,6BAA6B,CACxC,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EACxB,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,aAAa,CAAC;IA6BzB;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAyD7F;;;;;;;;OAQG;IACH,OAAO,CAAC,wBAAwB;IAgEhC;;;;;;;OAOG;YACW,2BAA2B;IA0DzC;;OAEG;YACW,sBAAsB;IAcpC;;;OAGG;YACW,wBAAwB;YAoCxB,iBAAiB;YAcjB,sBAAsB;YAiBtB,UAAU;IAgBxB;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAOpC;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAGhC"}
@@ -53,7 +53,7 @@
53
53
  * Wildo never authors an invoice: every `invoiceRefs` row exists because a webhook arrived. So the
54
54
  * missing-invoice repair is a pure insert, and the only field the sweep will UPDATE on an existing
55
55
  * row is `status`, which has exactly one writer and one authority. It never touches `total` — see
56
- * `listInvoices` in the Stripe adapter for the disagreement that avoids.
56
+ * `listInvoices` in the Stripe adapter for why one writer owns that field.
57
57
  *
58
58
  * assurance-control: WILDO.BILLING.PROVIDER_RECONCILIATION — local billing state is compared
59
59
  * against the provider on a schedule, and every divergence is either repaired within the
@@ -1 +1 @@
1
- {"version":3,"file":"billing-reconciliation.backend.service.d.ts","sourceRoot":"","sources":["../../../../../../src/billing/services/back-office/billing-reconciliation.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAGH,OAAO,EAML,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,6BAA6B,EAAE,MAAM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iC9B,wBAAwB;IAgEtC;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAuChC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,WAAW;IAoBnB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;YAeT,yBAAyB;YAoCzB,2BAA2B;YAyD3B,qBAAqB;IAyDnC;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;CAc5B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gCAAgC,EAAE,SAAS,kBAAkB,EAC4B,CAAC"}
1
+ {"version":3,"file":"billing-reconciliation.backend.service.d.ts","sourceRoot":"","sources":["../../../../../src/billing/services/back-office/billing-reconciliation.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAGH,OAAO,EAML,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,6BAA6B,EAAE,MAAM,kFAAkF,CAAC;AAOjI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAMnH;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,QAAiB,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,0CAA0C,gGAM7C,CAAC;AAoBX;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,mCAAmC,EAAE,MAAM,CAAC;IAC5C,sEAAsE;IACtE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kFAAkF;IAClF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,sFAAsF;IACtF,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAMD,qBACa,mCAAoC,SAAQ,6BAA6B;gBAE/C,MAAM,EAAE,aAAa,EACG,gBAAgB,EAAE,qCAAqC,EAChD,uBAAuB,EAAE,qCAAqC,EAC5E,iBAAiB,EAAE,+BAA+B,EACtD,YAAY,EAAE,0BAA0B;IAK7E,UAAU,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3E;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;YAyChD,8BAA8B;YAiC9B,wBAAwB;IAgEtC;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAuChC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,WAAW;IAoBnB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;YAeT,yBAAyB;YAoCzB,2BAA2B;YA0D3B,qBAAqB;IAyDnC;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;CAc5B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gCAAgC,EAAE,SAAS,kBAAkB,EAC4B,CAAC"}
@@ -53,7 +53,7 @@
53
53
  * Wildo never authors an invoice: every `invoiceRefs` row exists because a webhook arrived. So the
54
54
  * missing-invoice repair is a pure insert, and the only field the sweep will UPDATE on an existing
55
55
  * row is `status`, which has exactly one writer and one authority. It never touches `total` — see
56
- * `listInvoices` in the Stripe adapter for the disagreement that avoids.
56
+ * `listInvoices` in the Stripe adapter for why one writer owns that field.
57
57
  *
58
58
  * assurance-control: WILDO.BILLING.PROVIDER_RECONCILIATION — local billing state is compared
59
59
  * against the provider on a schedule, and every divergence is either repaired within the
@@ -379,9 +379,10 @@ let BillingReconciliationBackendService = class BillingReconciliationBackendServ
379
379
  const localInvoice = existing[0];
380
380
  if (localInvoice.status === providerInvoice.status)
381
381
  continue;
382
- // The ONLY field a sweep updates on an existing invoice. `total` is deliberately excluded —
383
- // the webhook router records it from a different provider field, and re-deriving it here
384
- // would make the two writers fight over money on every tick.
382
+ // The ONLY field a sweep updates on an existing invoice. `total` is deliberately excluded, and
383
+ // stays excluded now that the webhook router reads the same provider `total` this sweep does:
384
+ // agreement is not a reason for two writers to both write. Re-deriving it here would bump
385
+ // `updatedAt` and file an audit row for money that did not change, on every tick.
385
386
  const statusUpdate = { status: providerInvoice.status };
386
387
  try {
387
388
  const updateCtx = await this.internalCtx(variants.invoiceRef, CoreResourceOperation.UPDATE);
@@ -1 +1 @@
1
- {"version":3,"file":"billing-reconciliation.backend.service.js","sourceRoot":"","sources":["../../../../../../src/billing/services/back-office/billing-reconciliation.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAKL,qBAAqB,EACrB,kBAAkB,EAClB,uCAAuC,GACxC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAOrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kFAAkF,CAAC;AACjI,OAAO,EAAE,8BAA8B,EAAE,MAAM,wFAAwF,CAAC;AACxI,OAAO,EACL,yBAAyB,GAE1B,MAAM,mFAAmF,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAA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kB,CAAC,MAAM,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,8BAA8B,CAAC,CAAA;IACzD,WAAA,MAAM,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,CAAA;IAChE,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAClD,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;;GANtC,mCAAmC,CAyb/C;;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,8BAA8B,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Billing Reconciliation — asks the provider what it actually holds, and repairs what drifted.\n *\n * ## What this service is for\n *\n * Every local billing fact arrives by WEBHOOK. `StandardBilling_Interface.retrieveSubscription`\n * exists, its own doc comment says \"on-demand retrieval for reconciliation (if webhook missed)\",\n * and until 2026-09-09 the only two callers were inside the webhook router itself — i.e. the\n * recovery read only ever ran when a webhook DID arrive. A delivery that is lost, or that arrives\n * while the application is down and exhausts the provider's retries, left a stale subscription and\n * a missing invoice with nothing anywhere that could notice. That is the whole finding.\n *\n * ## The conflict rule, because a scheduled write to billing state can CORRUPT rather than merely\n * lag\n *\n * Five rules, and each one is a refusal rather than a capability:\n *\n * 1. **Only what the provider is authoritative FOR.** `status`, `currentPeriodStart`,\n * `currentPeriodEnd`, `cancelAtPeriodEnd` and `discount` — exactly the set the webhook path\n * already syncs in `syncSubscriptionFromProvider`, no more. Two writers of one field must agree\n * on which fields they own, or a sweep and a webhook take turns undoing each other.\n *\n * 2. **`items` is NEVER reconciled.** REJECTED ALTERNATIVE: sync items too, since the provider\n * knows them. It races `CHANGE_PLAN` / `ADD_ADDON` / `REMOVE_ADDON`, every one of which calls\n * the provider FIRST and writes local items afterwards — so a sweep reading the provider inside\n * that window and writing items would revert a plan change the customer has already been\n * charged for. The webhook router refuses items for the same reason and says so; a sweep, which\n * runs unprompted and concurrently, has strictly more exposure than it does.\n *\n * 3. **A row a local mutation currently owns is SKIPPED.** Any subscription whose `updatedAt` is\n * inside {@link RECENT_MUTATION_QUIET_PERIOD_MS} is left alone and counted, not written.\n * REJECTED ALTERNATIVE: a compare-and-swap on `updatedAt` at write time. It does not close the\n * window that matters — the read-modify-write starts at the PROVIDER READ, not at the local\n * read, so a snapshot taken before a webhook that has since landed would still satisfy a CAS\n * taken after it. The quiet period addresses the real window, needs no schema change, and costs\n * one skipped row that the next tick picks up.\n *\n * 4. **Nothing is ever DELETED, CANCELLED or CREATED here.** A provider read that fails — including\n * a provider saying the subscription does not exist — is REPORTED and acted on by nobody.\n * REJECTED ALTERNATIVE: mark a subscription `CANCELLED` when the provider cannot find it. A\n * rotated key pointed at the wrong account, a test-vs-live key mix-up, or a provider outage\n * would then cancel every subscription in the application, revoking every entitlement, from a\n * read that told us nothing. Stale entitlements are recoverable by the next successful tick;\n * revoked ones are not.\n *\n * 5. **A row that AGREES is not written.** Comparison happens before any update, because a\n * subscription UPDATE fires the post-operation feature-sync hook — an unconditional write would\n * recompute entitlements for every account on every tick, bump every `updatedAt`, and file an\n * audit row per subscription per tick for a change that did not happen.\n *\n * ## Invoices are INSERT-mostly, which is why they are safe\n *\n * Wildo never authors an invoice: every `invoiceRefs` row exists because a webhook arrived. So the\n * missing-invoice repair is a pure insert, and the only field the sweep will UPDATE on an existing\n * row is `status`, which has exactly one writer and one authority. It never touches `total` — see\n * `listInvoices` in the Stripe adapter for the disagreement that avoids.\n *\n * assurance-control: WILDO.BILLING.PROVIDER_RECONCILIATION — local billing state is compared\n * against the provider on a schedule, and every divergence is either repaired within the\n * provider-authoritative field set or reported.\n */\n\nimport { injectable, inject } from 'inversify';\nimport {\n type BillingAccount,\n type BillingSubscriptionBase,\n type InvoiceRef,\n CoreResourceType,\n CoreResourceOperation,\n SubscriptionStatus,\n deriveTrustedSystemWritePreservedFields,\n} from '@wildo-ai/saas-models';\nimport type { ResourceType } from '@wildo-ai/saas-models';\nimport { currencyMinorUnitDecimals } from '@wildo-ai/zod-decorators';\nimport type {\n StandardBilling_Interface,\n StandardBilling_SubscriptionData,\n StandardBilling_InvoiceData,\n} from '@wildo-ai/external-connectors-models';\nimport type { ServiceOptions } from '~wildo-backend-lib/base-classes/models/repositories.backend.schemas';\nimport { AbstractBillingBackendService } from '~wildo-backend-lib/billing/services/back-office/abstract-billing.backend.service';\nimport { TERMINAL_SUBSCRIPTION_STATUSES } from '~wildo-backend-lib/billing/services/back-office/billing-subject-erasure-effect.backend';\nimport {\n BILLING_SCOPE_TO_VARIANTS,\n type BillingResolvedVariants,\n} from '~wildo-backend-lib/billing/services/custom-impl/billing-custom-impl-utils.backend';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { ServicesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/services/services-registry-handler.backend.service';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport type { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\n\n// =====================================================\n// Policy constants\n// =====================================================\n\n/**\n * How recently a local write must have happened for the sweep to leave a row alone.\n *\n * Ten minutes, and the number is chosen to dominate the widest window a local mutation can hold:\n * a plan change is one provider round-trip plus one local write, so seconds in the ordinary case\n * and at most a request timeout in the worst. Ten minutes buys a wide margin at the cost of one\n * postponed repair — the next tick reconciles the row, and a subscription that has just been\n * written is the least likely one in the application to be stale.\n */\nexport const RECENT_MUTATION_QUIET_PERIOD_MS = 10 * 60 * 1000;\n\n/**\n * The provider-AUTHORITATIVE field set — the only fields a sweep may write on a subscription.\n *\n * Named, exported and iterated rather than spelled out at the comparison site, so the set that\n * gets compared and the set that gets written cannot drift apart. It mirrors\n * `syncSubscriptionFromProvider` in the webhook router exactly; if that grows a field, this list\n * is the other end of the pair and the pin below is what fails.\n */\nexport const PROVIDER_AUTHORITATIVE_SUBSCRIPTION_FIELDS = [\n 'status',\n 'currentPeriodStart',\n 'currentPeriodEnd',\n 'cancelAtPeriodEnd',\n 'discount',\n] as const;\n\n/** How many subscriptions or billing accounts one page reads. */\nconst RECONCILIATION_PAGE_SIZE = 200;\n\n/**\n * Page ceiling per scope. Unlike the usage flush's runaway guard, hitting this is NOT a refusal:\n * reconciliation is idempotent and order-independent, so stopping after N pages reconciles a\n * prefix and leaves the rest for the next tick. It exists to bound one tick's provider calls, not\n * to protect a correctness invariant.\n */\nconst MAX_RECONCILIATION_PAGES = 50;\n\n/** Invoices per customer one tick looks back over. */\nconst INVOICE_LOOKBACK_PAGE_SIZE = 20;\n\n// =====================================================\n// Result\n// =====================================================\n\n/**\n * What one run did — stated as separate counts rather than a single \"reconciled\" number, because\n * the interesting quantity is not how many rows were examined but how many DISAGREED. A healthy\n * application drifts on zero rows; a steady non-zero `subscriptionsRepaired` means webhooks are\n * being lost and the sweep is papering over it.\n */\nexport interface BillingReconciliationResult {\n subscriptionsExamined: number;\n /** Rows left alone because a local mutation had just touched them (rule 3). */\n subscriptionsSkippedRecentlyMutated: number;\n /** Rows where at least one provider-authoritative field disagreed. */\n subscriptionsDrifted: number;\n /** Rows actually written. Equals `subscriptionsDrifted` unless a write failed. */\n subscriptionsRepaired: number;\n /** Rows whose provider state could not be read. Reported, never acted on (rule 4). */\n subscriptionsUnreadable: number;\n billingAccountsExamined: number;\n invoicesExamined: number;\n /** Invoices that existed at the provider and nowhere locally, now recorded. */\n invoicesRecovered: number;\n invoiceStatusesRepaired: number;\n /**\n * One line per drift and per failure, naming the row and the field. A count tells an operator\n * something is wrong; only the line says whose subscription it was.\n */\n errors: string[];\n}\n\n// =====================================================\n// Service\n// =====================================================\n\n@injectable()\nexport class BillingReconciliationBackendService extends AbstractBillingBackendService {\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.ServicesRegistryHandlerService) servicesRegistry: ServicesRegistryHandlerBackendService,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService) executionContextCreator: ExecutionContextCreatorBackendService,\n @inject(SAAS_SERVICE_TYPES.ResourceRegistryService) resourcesRegistry: ResourcesRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService) errorBuilder: ErrorBuilderBackendService,\n ) {\n super(logger, servicesRegistry, executionContextCreator, resourcesRegistry, errorBuilder);\n }\n\n public async initialize(provider: StandardBilling_Interface): Promise<void> {\n if (this.isInitialized) return;\n this.initializeProvider(provider);\n this.logDebug('Billing reconciliation initialized');\n }\n\n // ════════════════════════════════════════════════════════════\n // Public entry point\n // ════════════════════════════════════════════════════════════\n\n /**\n * Reconcile every billing scope against the provider.\n *\n * Returns rather than throws on a provider fault, for the same reason the usage flush does: one\n * account's unreachable subscription must not stop every other account's drift from being\n * repaired, and every row left unreconciled is selectable by the next tick at no cost.\n */\n public async reconcile(): Promise<BillingReconciliationResult> {\n const result: BillingReconciliationResult = {\n subscriptionsExamined: 0,\n subscriptionsSkippedRecentlyMutated: 0,\n subscriptionsDrifted: 0,\n subscriptionsRepaired: 0,\n subscriptionsUnreadable: 0,\n billingAccountsExamined: 0,\n invoicesExamined: 0,\n invoicesRecovered: 0,\n invoiceStatusesRepaired: 0,\n errors: [],\n };\n\n if (!this.billingProvider) {\n result.errors.push('Provider not initialized');\n return result;\n }\n\n for (const [scopeKey, scopeData] of Object.entries(BILLING_SCOPE_TO_VARIANTS)) {\n const variants: BillingResolvedVariants = { scopeKey, ...scopeData };\n try {\n await this.reconcileSubscriptionsForScope(variants, result);\n } catch (error) {\n result.errors.push(`Subscription reconciliation failed for scope ${variants.scopeType}: ${(error as Error).message}`);\n }\n try {\n await this.reconcileInvoicesForScope(variants, result);\n } catch (error) {\n result.errors.push(`Invoice reconciliation failed for scope ${variants.scopeType}: ${(error as Error).message}`);\n }\n }\n\n this.logDebug('Billing reconciliation complete', { ...result, errors: result.errors.length });\n return result;\n }\n\n // ════════════════════════════════════════════════════════════\n // Subscriptions\n // ════════════════════════════════════════════════════════════\n\n private async reconcileSubscriptionsForScope(\n variants: BillingResolvedVariants,\n result: BillingReconciliationResult,\n ): Promise<void> {\n // Context construction stays OUTSIDE the loop's try for the reason `AbstractBillingBackendService`\n // gives: failing to resolve the INTERNAL_CALL path is a wiring fault, never \"no subscriptions\".\n const listCtx = await this.internalCtx(variants.subscription as CoreResourceType, CoreResourceOperation.LIST);\n const quietPeriodCutoff = Date.now() - RECENT_MUTATION_QUIET_PERIOD_MS;\n\n for (let page = 1; page <= MAX_RECONCILIATION_PAGES; page += 1) {\n const subscriptions = await this.servicesRegistry.list<BillingSubscriptionBase>(\n variants.subscription as CoreResourceType,\n listCtx,\n // Terminal subscriptions are excluded on purpose: `CANCELLED` and `INCOMPLETE_EXPIRED` can\n // never become anything else, so re-reading them from the provider forever buys nothing and\n // costs one API call per dead subscription per tick, for the life of the application.\n { status: { $nin: TERMINAL_SUBSCRIPTION_STATUSES } },\n { page, limit: RECONCILIATION_PAGE_SIZE },\n ) as BillingSubscriptionBase[];\n\n for (const subscription of subscriptions) {\n await this.reconcileOneSubscription(variants, subscription, quietPeriodCutoff, result);\n }\n\n if (subscriptions.length < RECONCILIATION_PAGE_SIZE) return;\n }\n\n result.errors.push(\n `Subscription reconciliation stopped after ${MAX_RECONCILIATION_PAGES} pages for scope ${variants.scopeType}. ` +\n `The remaining rows were not examined this tick and will be picked up by the next one.`,\n );\n }\n\n private async reconcileOneSubscription(\n variants: BillingResolvedVariants,\n subscription: BillingSubscriptionBase,\n quietPeriodCutoff: number,\n result: BillingReconciliationResult,\n ): Promise<void> {\n const providerSubscriptionId = subscription.providerSubscriptionId;\n if (!providerSubscriptionId) {\n // A subscription with no provider link is not drift — it is a local row the provider has\n // never heard of, and there is no authority to compare it against.\n return;\n }\n\n result.subscriptionsExamined += 1;\n\n // RULE 3 — a row a local mutation currently owns.\n const updatedAt = subscription.updatedAt ? new Date(subscription.updatedAt).getTime() : 0;\n if (updatedAt > quietPeriodCutoff) {\n result.subscriptionsSkippedRecentlyMutated += 1;\n return;\n }\n\n let providerData: StandardBilling_SubscriptionData;\n try {\n providerData = await this.billingProvider!.retrieveSubscription(providerSubscriptionId);\n } catch (error) {\n // RULE 4 — reported, never acted on. Note in particular that a provider answering \"no such\n // subscription\" lands here and changes nothing.\n result.subscriptionsUnreadable += 1;\n result.errors.push(\n `Subscription ${subscription._id} (provider ${providerSubscriptionId}) could not be read from the provider: ` +\n `${(error as Error).message}. Local state is UNCHANGED — a failed read is not evidence the subscription ended.`,\n );\n return;\n }\n\n const drift = this.computeSubscriptionDrift(subscription, providerData);\n if (Object.keys(drift.updateData).length === 0) return;\n\n result.subscriptionsDrifted += 1;\n result.errors.push(\n `DRIFT REPAIRED — subscription ${subscription._id} (provider ${providerSubscriptionId}) disagreed with the ` +\n `provider on: ${drift.fields.join(', ')}. A webhook for this subscription was very likely never delivered.`,\n );\n\n try {\n const updateCtx = await this.internalCtx(variants.subscription as CoreResourceType, CoreResourceOperation.UPDATE);\n await this.servicesRegistry.update(\n variants.subscription as CoreResourceType,\n updateCtx,\n subscription._id,\n drift.updateData,\n this.trustedWriteOptions(variants.subscription as ResourceType, drift.updateData),\n );\n result.subscriptionsRepaired += 1;\n // Feature sync is NOT called here: the subscription UPDATE post-operation hook fires it, which\n // is the same seam the webhook router relies on. Calling it directly would recompute twice.\n } catch (error) {\n result.errors.push(\n `Failed to write the reconciled state of subscription ${subscription._id}: ${(error as Error).message}`,\n );\n }\n }\n\n /**\n * The comparison, over {@link PROVIDER_AUTHORITATIVE_SUBSCRIPTION_FIELDS} and nothing else.\n *\n * Returns only the fields that actually differ, so the update payload is minimal and the\n * `preserveServerInjectedFields` allowlist derived from it stays minimal with it.\n */\n private computeSubscriptionDrift(\n local: BillingSubscriptionBase,\n provider: StandardBilling_SubscriptionData,\n ): { updateData: Record<string, unknown>; fields: string[] } {\n const providerView: Record<string, unknown> = {\n status: provider.status,\n currentPeriodStart: provider.currentPeriodStart,\n currentPeriodEnd: provider.currentPeriodEnd,\n cancelAtPeriodEnd: provider.cancelAtPeriodEnd,\n // `null` and not `undefined`: a discount that has ENDED must clear the local one, and an\n // omitted key would leave the stale discount in place. Same choice `syncSubscriptionFromProvider`\n // makes, for the same reason.\n discount: provider.discount\n ? {\n providerCouponId: provider.discount.providerCouponId,\n percentOff: provider.discount.percentOff,\n amountOff: provider.discount.amountOff,\n currency: provider.discount.currency,\n duration: provider.discount.duration,\n durationInMonths: provider.discount.durationInMonths,\n end: provider.discount.end,\n }\n : null,\n };\n\n const updateData: Record<string, unknown> = {};\n const fields: string[] = [];\n\n for (const field of PROVIDER_AUTHORITATIVE_SUBSCRIPTION_FIELDS) {\n const localValue = (local as unknown as Record<string, unknown>)[field];\n const providerValue = providerView[field];\n if (this.valuesAgree(localValue, providerValue)) continue;\n updateData[field] = providerValue;\n fields.push(field);\n }\n\n return { updateData, fields };\n }\n\n /**\n * Equality that survives the three shapes these fields actually take.\n *\n * A naive `===` reports drift on EVERY row, forever: `currentPeriodEnd` comes back from the\n * repository as a `Date` instance (or, depending on the adapter and whether the row came through\n * a JSON column or a cache, as an ISO STRING) while the provider hands back a fresh `Date`, and\n * `discount` is an object. A sweep that always sees drift is worse than no sweep — it writes every\n * subscription every tick, recomputes every account's entitlements, and buries a real divergence\n * in a report where every row is listed.\n *\n * Absent and `null` are treated as agreeing: a local row that has never carried a discount and a\n * provider with no discount are the same state, and distinguishing them would write `null` over\n * `undefined` on every discount-free subscription in the application.\n */\n private valuesAgree(local: unknown, provider: unknown): boolean {\n if (local === provider) return true;\n if (local == null && provider == null) return true;\n if (local == null || provider == null) return false;\n // A Date on ONE side and a string on the other. This is the branch that earns its place:\n // two Date INSTANCES are already handled structurally below, but a repository that hands back\n // an ISO string — a JSON column, a serialising adapter, a cached document — against a provider\n // `Date` would otherwise compare unequal on every row, forever, and the sweep would rewrite\n // every subscription on every tick while reporting the whole application as drifted.\n if (local instanceof Date || provider instanceof Date) {\n const localTime = new Date(local as string | number | Date).getTime();\n const providerTime = new Date(provider as string | number | Date).getTime();\n return Number.isFinite(localTime) && Number.isFinite(providerTime) && localTime === providerTime;\n }\n if (typeof local === 'object' && typeof provider === 'object') {\n return this.stableStringify(local) === this.stableStringify(provider);\n }\n return false;\n }\n\n /**\n * Key-order-independent structural comparison for the `discount` object.\n *\n * Key order is not a difference: the local row comes back from a document store or a JSONB column\n * and the provider view is built by an object literal here, so a plain `JSON.stringify` compare\n * would report drift on ordering alone. `undefined` members are dropped so an absent optional and\n * an explicitly-undefined one compare equal, which is the same reading `valuesAgree` takes above.\n */\n private stableStringify(value: unknown): string {\n if (value === null || typeof value !== 'object') return JSON.stringify(value) ?? 'undefined';\n if (value instanceof Date) return `D${value.getTime()}`;\n if (Array.isArray(value)) return `[${value.map(entry => this.stableStringify(entry)).join(',')}]`;\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entryValue]) => entryValue !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, entryValue]) => `${key}:${this.stableStringify(entryValue)}`);\n return `{${entries.join(',')}}`;\n }\n\n // ════════════════════════════════════════════════════════════\n // Invoices\n // ════════════════════════════════════════════════════════════\n\n private async reconcileInvoicesForScope(\n variants: BillingResolvedVariants,\n result: BillingReconciliationResult,\n ): Promise<void> {\n const accountsCtx = await this.internalCtx(variants.billingAccount as CoreResourceType, CoreResourceOperation.LIST);\n\n for (let page = 1; page <= MAX_RECONCILIATION_PAGES; page += 1) {\n const accounts = await this.servicesRegistry.list<BillingAccount>(\n variants.billingAccount as CoreResourceType,\n accountsCtx,\n {},\n { page, limit: RECONCILIATION_PAGE_SIZE },\n ) as BillingAccount[];\n\n for (const account of accounts) {\n const providerCustomerId = (account as unknown as Record<string, unknown>).providerCustomerId as string | undefined;\n if (!providerCustomerId) continue;\n result.billingAccountsExamined += 1;\n try {\n await this.reconcileInvoicesForAccount(variants, account._id, providerCustomerId, result);\n } catch (error) {\n result.errors.push(\n `Invoice reconciliation failed for billing account ${account._id}: ${(error as Error).message}`,\n );\n }\n }\n\n if (accounts.length < RECONCILIATION_PAGE_SIZE) return;\n }\n\n result.errors.push(\n `Invoice reconciliation stopped after ${MAX_RECONCILIATION_PAGES} pages of billing accounts for scope ` +\n `${variants.scopeType}. The remaining accounts will be examined by the next tick.`,\n );\n }\n\n private async reconcileInvoicesForAccount(\n variants: BillingResolvedVariants,\n billingAccountId: string,\n providerCustomerId: string,\n result: BillingReconciliationResult,\n ): Promise<void> {\n const providerInvoices = await this.billingProvider!.listInvoices(providerCustomerId, {\n limit: INVOICE_LOOKBACK_PAGE_SIZE,\n });\n if (providerInvoices.length === 0) return;\n\n const listCtx = await this.internalCtx(variants.invoiceRef as CoreResourceType, CoreResourceOperation.LIST);\n\n for (const providerInvoice of providerInvoices) {\n result.invoicesExamined += 1;\n\n const existing = await this.servicesRegistry.list<InvoiceRef>(\n variants.invoiceRef as CoreResourceType,\n listCtx,\n { providerInvoiceId: providerInvoice.providerInvoiceId },\n { limit: 1 },\n ) as InvoiceRef[];\n\n if (existing.length === 0) {\n await this.recoverMissingInvoice(variants, billingAccountId, providerInvoice, result);\n continue;\n }\n\n const localInvoice = existing[0];\n if (localInvoice.status === providerInvoice.status) continue;\n\n // The ONLY field a sweep updates on an existing invoice. `total` is deliberately excluded —\n // the webhook router records it from a different provider field, and re-deriving it here\n // would make the two writers fight over money on every tick.\n const statusUpdate = { status: providerInvoice.status };\n try {\n const updateCtx = await this.internalCtx(variants.invoiceRef as CoreResourceType, CoreResourceOperation.UPDATE);\n await this.servicesRegistry.update(\n variants.invoiceRef as CoreResourceType,\n updateCtx,\n localInvoice._id,\n statusUpdate,\n this.trustedWriteOptions(variants.invoiceRef as ResourceType, statusUpdate),\n );\n result.invoiceStatusesRepaired += 1;\n result.errors.push(\n `DRIFT REPAIRED — invoice ${localInvoice._id} (provider ${providerInvoice.providerInvoiceId}) was recorded ` +\n `as \"${localInvoice.status}\" and the provider holds \"${providerInvoice.status}\".`,\n );\n } catch (error) {\n result.errors.push(\n `Failed to correct the status of invoice ${localInvoice._id}: ${(error as Error).message}`,\n );\n }\n }\n }\n\n private async recoverMissingInvoice(\n variants: BillingResolvedVariants,\n billingAccountId: string,\n providerInvoice: StandardBilling_InvoiceData,\n result: BillingReconciliationResult,\n ): Promise<void> {\n /*\n * The scale is the CURRENCY's, exactly as the webhook path resolves it (#515). A zero-decimal\n * currency recorded at scale 2 stores a hundredth of the real amount; an unresolvable currency\n * falls back to 2 with a loud line rather than dropping the invoice, because losing the record\n * of an invoice that exists is worse than recording it at a scale somebody can correct.\n */\n const resolvedDecimals = currencyMinorUnitDecimals(providerInvoice.currency.toUpperCase());\n if (resolvedDecimals === undefined) {\n result.errors.push(\n `Recovered invoice ${providerInvoice.providerInvoiceId} at an ASSUMED scale of 2: currency ` +\n `\"${providerInvoice.currency}\" has no resolvable minor unit.`,\n );\n }\n\n const invoiceData: Record<string, unknown> = {\n [variants.billingAccountFkField]: billingAccountId,\n providerInvoiceId: providerInvoice.providerInvoiceId,\n status: providerInvoice.status,\n total: {\n amount: BigInt(Math.trunc(providerInvoice.total)),\n currency: providerInvoice.currency,\n decimals: resolvedDecimals ?? 2,\n },\n hostedInvoiceUrl: providerInvoice.hostedInvoiceUrl,\n invoicePdfUrl: providerInvoice.invoicePdfUrl,\n };\n\n try {\n const createCtx = await this.internalCtx(variants.invoiceRef as CoreResourceType, CoreResourceOperation.CREATE);\n await this.servicesRegistry.create(\n variants.invoiceRef as CoreResourceType,\n createCtx,\n invoiceData,\n this.trustedWriteOptions(variants.invoiceRef as ResourceType, invoiceData, CoreResourceOperation.CREATE),\n );\n result.invoicesRecovered += 1;\n result.errors.push(\n `INVOICE RECOVERED — provider invoice ${providerInvoice.providerInvoiceId} for billing account ` +\n `${billingAccountId} existed at the provider and nowhere locally. Its webhook was never delivered.`,\n );\n } catch (error) {\n result.errors.push(\n `Failed to record recovered invoice ${providerInvoice.providerInvoiceId}: ${(error as Error).message}`,\n );\n }\n }\n\n // ════════════════════════════════════════════════════════════\n // Private — trusted-system write\n // ════════════════════════════════════════════════════════════\n\n /**\n * `ServiceOptions` that re-attach the fields a client-shaped request DTO would strip.\n *\n * The same seam the webhook router and the catalog sync use, and it is not optional here: every\n * period field on a subscription is `.isNotEditable()` and `providerInvoiceId` is\n * `.isBackendOnly()`, so without the allowlist the write \"succeeds\" and persists nothing — a\n * repair that silently repairs nothing, which is the worst possible outcome for a sweep whose\n * whole job is to make local state true.\n */\n private trustedWriteOptions(\n resourceType: ResourceType,\n payload: Record<string, unknown>,\n verb: CoreResourceOperation.CREATE | CoreResourceOperation.UPDATE = CoreResourceOperation.UPDATE,\n ): ServiceOptions {\n const { mainSchema } = this.resourcesRegistry.getResourceConfiguration(resourceType);\n return {\n preserveServerInjectedFields: deriveTrustedSystemWritePreservedFields(\n mainSchema,\n Object.keys(payload),\n verb,\n ),\n };\n }\n}\n\n/**\n * Statuses a reconciliation sweep considers LIVE — everything `TERMINAL_SUBSCRIPTION_STATUSES` does\n * not claim.\n *\n * DERIVED, so the partition is exhaustive by construction and no pin could ever prove it: a member\n * added to the enum lands in the swept half automatically. That default is the right one (a new\n * status is presumed live until someone says otherwise), but it is a default rather than a decision,\n * so the pin beside this asserts the RESULTING MEMBERSHIP literally. Adding an enum member, or\n * moving one across the boundary, reddens it and puts the decision in front of a person — which is\n * the only thing a test can actually contribute here.\n */\nexport const RECONCILED_SUBSCRIPTION_STATUSES: readonly SubscriptionStatus[] =\n Object.values(SubscriptionStatus).filter(status => !TERMINAL_SUBSCRIPTION_STATUSES.includes(status));\n"]}
1
+ {"version":3,"file":"billing-reconciliation.backend.service.js","sourceRoot":"","sources":["../../../../../src/billing/services/back-office/billing-reconciliation.backend.service.ts"],"names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AAe,CAAC,iBAAiB,KAAM,KAAe,CAAC,OAAO,EAAE,CACvG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,iCAAiC;IACjC,+DAA+D;IAE/D;;;;;;;;OAQG;IACK,mBAAmB,CACzB,YAA0B,EAC1B,OAAgC,EAChC,OAAoE,qBAAqB,CAAC,MAAM;QAEhG,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAC;QACrF,OAAO;YACL,4BAA4B,EAAE,uCAAuC,CACnE,UAAU,EACV,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EACpB,IAAI,CACL;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1bY,mCAAmC;IAD/C,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,8BAA8B,CAAC,CAAA;IACzD,WAAA,MAAM,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,CAAA;IAChE,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAClD,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;;GANtC,mCAAmC,CA0b/C;;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,8BAA8B,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Billing Reconciliation — asks the provider what it actually holds, and repairs what drifted.\n *\n * ## What this service is for\n *\n * Every local billing fact arrives by WEBHOOK. `StandardBilling_Interface.retrieveSubscription`\n * exists, its own doc comment says \"on-demand retrieval for reconciliation (if webhook missed)\",\n * and until 2026-09-09 the only two callers were inside the webhook router itself — i.e. the\n * recovery read only ever ran when a webhook DID arrive. A delivery that is lost, or that arrives\n * while the application is down and exhausts the provider's retries, left a stale subscription and\n * a missing invoice with nothing anywhere that could notice. That is the whole finding.\n *\n * ## The conflict rule, because a scheduled write to billing state can CORRUPT rather than merely\n * lag\n *\n * Five rules, and each one is a refusal rather than a capability:\n *\n * 1. **Only what the provider is authoritative FOR.** `status`, `currentPeriodStart`,\n * `currentPeriodEnd`, `cancelAtPeriodEnd` and `discount` — exactly the set the webhook path\n * already syncs in `syncSubscriptionFromProvider`, no more. Two writers of one field must agree\n * on which fields they own, or a sweep and a webhook take turns undoing each other.\n *\n * 2. **`items` is NEVER reconciled.** REJECTED ALTERNATIVE: sync items too, since the provider\n * knows them. It races `CHANGE_PLAN` / `ADD_ADDON` / `REMOVE_ADDON`, every one of which calls\n * the provider FIRST and writes local items afterwards — so a sweep reading the provider inside\n * that window and writing items would revert a plan change the customer has already been\n * charged for. The webhook router refuses items for the same reason and says so; a sweep, which\n * runs unprompted and concurrently, has strictly more exposure than it does.\n *\n * 3. **A row a local mutation currently owns is SKIPPED.** Any subscription whose `updatedAt` is\n * inside {@link RECENT_MUTATION_QUIET_PERIOD_MS} is left alone and counted, not written.\n * REJECTED ALTERNATIVE: a compare-and-swap on `updatedAt` at write time. It does not close the\n * window that matters — the read-modify-write starts at the PROVIDER READ, not at the local\n * read, so a snapshot taken before a webhook that has since landed would still satisfy a CAS\n * taken after it. The quiet period addresses the real window, needs no schema change, and costs\n * one skipped row that the next tick picks up.\n *\n * 4. **Nothing is ever DELETED, CANCELLED or CREATED here.** A provider read that fails — including\n * a provider saying the subscription does not exist — is REPORTED and acted on by nobody.\n * REJECTED ALTERNATIVE: mark a subscription `CANCELLED` when the provider cannot find it. A\n * rotated key pointed at the wrong account, a test-vs-live key mix-up, or a provider outage\n * would then cancel every subscription in the application, revoking every entitlement, from a\n * read that told us nothing. Stale entitlements are recoverable by the next successful tick;\n * revoked ones are not.\n *\n * 5. **A row that AGREES is not written.** Comparison happens before any update, because a\n * subscription UPDATE fires the post-operation feature-sync hook — an unconditional write would\n * recompute entitlements for every account on every tick, bump every `updatedAt`, and file an\n * audit row per subscription per tick for a change that did not happen.\n *\n * ## Invoices are INSERT-mostly, which is why they are safe\n *\n * Wildo never authors an invoice: every `invoiceRefs` row exists because a webhook arrived. So the\n * missing-invoice repair is a pure insert, and the only field the sweep will UPDATE on an existing\n * row is `status`, which has exactly one writer and one authority. It never touches `total` — see\n * `listInvoices` in the Stripe adapter for why one writer owns that field.\n *\n * assurance-control: WILDO.BILLING.PROVIDER_RECONCILIATION — local billing state is compared\n * against the provider on a schedule, and every divergence is either repaired within the\n * provider-authoritative field set or reported.\n */\n\nimport { injectable, inject } from 'inversify';\nimport {\n type BillingAccount,\n type BillingSubscriptionBase,\n type InvoiceRef,\n CoreResourceType,\n CoreResourceOperation,\n SubscriptionStatus,\n deriveTrustedSystemWritePreservedFields,\n} from '@wildo-ai/saas-models';\nimport type { ResourceType } from '@wildo-ai/saas-models';\nimport { currencyMinorUnitDecimals } from '@wildo-ai/zod-decorators';\nimport type {\n StandardBilling_Interface,\n StandardBilling_SubscriptionData,\n StandardBilling_InvoiceData,\n} from '@wildo-ai/external-connectors-models';\nimport type { ServiceOptions } from '~wildo-backend-lib/base-classes/models/repositories.backend.schemas';\nimport { AbstractBillingBackendService } from '~wildo-backend-lib/billing/services/back-office/abstract-billing.backend.service';\nimport { TERMINAL_SUBSCRIPTION_STATUSES } from '~wildo-backend-lib/billing/services/back-office/billing-subject-erasure-effect.backend';\nimport {\n BILLING_SCOPE_TO_VARIANTS,\n type BillingResolvedVariants,\n} from '~wildo-backend-lib/billing/services/custom-impl/billing-custom-impl-utils.backend';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { ServicesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/services/services-registry-handler.backend.service';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport type { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\n\n// =====================================================\n// Policy constants\n// =====================================================\n\n/**\n * How recently a local write must have happened for the sweep to leave a row alone.\n *\n * Ten minutes, and the number is chosen to dominate the widest window a local mutation can hold:\n * a plan change is one provider round-trip plus one local write, so seconds in the ordinary case\n * and at most a request timeout in the worst. Ten minutes buys a wide margin at the cost of one\n * postponed repair — the next tick reconciles the row, and a subscription that has just been\n * written is the least likely one in the application to be stale.\n */\nexport const RECENT_MUTATION_QUIET_PERIOD_MS = 10 * 60 * 1000;\n\n/**\n * The provider-AUTHORITATIVE field set — the only fields a sweep may write on a subscription.\n *\n * Named, exported and iterated rather than spelled out at the comparison site, so the set that\n * gets compared and the set that gets written cannot drift apart. It mirrors\n * `syncSubscriptionFromProvider` in the webhook router exactly; if that grows a field, this list\n * is the other end of the pair and the pin below is what fails.\n */\nexport const PROVIDER_AUTHORITATIVE_SUBSCRIPTION_FIELDS = [\n 'status',\n 'currentPeriodStart',\n 'currentPeriodEnd',\n 'cancelAtPeriodEnd',\n 'discount',\n] as const;\n\n/** How many subscriptions or billing accounts one page reads. */\nconst RECONCILIATION_PAGE_SIZE = 200;\n\n/**\n * Page ceiling per scope. Unlike the usage flush's runaway guard, hitting this is NOT a refusal:\n * reconciliation is idempotent and order-independent, so stopping after N pages reconciles a\n * prefix and leaves the rest for the next tick. It exists to bound one tick's provider calls, not\n * to protect a correctness invariant.\n */\nconst MAX_RECONCILIATION_PAGES = 50;\n\n/** Invoices per customer one tick looks back over. */\nconst INVOICE_LOOKBACK_PAGE_SIZE = 20;\n\n// =====================================================\n// Result\n// =====================================================\n\n/**\n * What one run did — stated as separate counts rather than a single \"reconciled\" number, because\n * the interesting quantity is not how many rows were examined but how many DISAGREED. A healthy\n * application drifts on zero rows; a steady non-zero `subscriptionsRepaired` means webhooks are\n * being lost and the sweep is papering over it.\n */\nexport interface BillingReconciliationResult {\n subscriptionsExamined: number;\n /** Rows left alone because a local mutation had just touched them (rule 3). */\n subscriptionsSkippedRecentlyMutated: number;\n /** Rows where at least one provider-authoritative field disagreed. */\n subscriptionsDrifted: number;\n /** Rows actually written. Equals `subscriptionsDrifted` unless a write failed. */\n subscriptionsRepaired: number;\n /** Rows whose provider state could not be read. Reported, never acted on (rule 4). */\n subscriptionsUnreadable: number;\n billingAccountsExamined: number;\n invoicesExamined: number;\n /** Invoices that existed at the provider and nowhere locally, now recorded. */\n invoicesRecovered: number;\n invoiceStatusesRepaired: number;\n /**\n * One line per drift and per failure, naming the row and the field. A count tells an operator\n * something is wrong; only the line says whose subscription it was.\n */\n errors: string[];\n}\n\n// =====================================================\n// Service\n// =====================================================\n\n@injectable()\nexport class BillingReconciliationBackendService extends AbstractBillingBackendService {\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.ServicesRegistryHandlerService) servicesRegistry: ServicesRegistryHandlerBackendService,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService) executionContextCreator: ExecutionContextCreatorBackendService,\n @inject(SAAS_SERVICE_TYPES.ResourceRegistryService) resourcesRegistry: ResourcesRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService) errorBuilder: ErrorBuilderBackendService,\n ) {\n super(logger, servicesRegistry, executionContextCreator, resourcesRegistry, errorBuilder);\n }\n\n public async initialize(provider: StandardBilling_Interface): Promise<void> {\n if (this.isInitialized) return;\n this.initializeProvider(provider);\n this.logDebug('Billing reconciliation initialized');\n }\n\n // ════════════════════════════════════════════════════════════\n // Public entry point\n // ════════════════════════════════════════════════════════════\n\n /**\n * Reconcile every billing scope against the provider.\n *\n * Returns rather than throws on a provider fault, for the same reason the usage flush does: one\n * account's unreachable subscription must not stop every other account's drift from being\n * repaired, and every row left unreconciled is selectable by the next tick at no cost.\n */\n public async reconcile(): Promise<BillingReconciliationResult> {\n const result: BillingReconciliationResult = {\n subscriptionsExamined: 0,\n subscriptionsSkippedRecentlyMutated: 0,\n subscriptionsDrifted: 0,\n subscriptionsRepaired: 0,\n subscriptionsUnreadable: 0,\n billingAccountsExamined: 0,\n invoicesExamined: 0,\n invoicesRecovered: 0,\n invoiceStatusesRepaired: 0,\n errors: [],\n };\n\n if (!this.billingProvider) {\n result.errors.push('Provider not initialized');\n return result;\n }\n\n for (const [scopeKey, scopeData] of Object.entries(BILLING_SCOPE_TO_VARIANTS)) {\n const variants: BillingResolvedVariants = { scopeKey, ...scopeData };\n try {\n await this.reconcileSubscriptionsForScope(variants, result);\n } catch (error) {\n result.errors.push(`Subscription reconciliation failed for scope ${variants.scopeType}: ${(error as Error).message}`);\n }\n try {\n await this.reconcileInvoicesForScope(variants, result);\n } catch (error) {\n result.errors.push(`Invoice reconciliation failed for scope ${variants.scopeType}: ${(error as Error).message}`);\n }\n }\n\n this.logDebug('Billing reconciliation complete', { ...result, errors: result.errors.length });\n return result;\n }\n\n // ════════════════════════════════════════════════════════════\n // Subscriptions\n // ════════════════════════════════════════════════════════════\n\n private async reconcileSubscriptionsForScope(\n variants: BillingResolvedVariants,\n result: BillingReconciliationResult,\n ): Promise<void> {\n // Context construction stays OUTSIDE the loop's try for the reason `AbstractBillingBackendService`\n // gives: failing to resolve the INTERNAL_CALL path is a wiring fault, never \"no subscriptions\".\n const listCtx = await this.internalCtx(variants.subscription as CoreResourceType, CoreResourceOperation.LIST);\n const quietPeriodCutoff = Date.now() - RECENT_MUTATION_QUIET_PERIOD_MS;\n\n for (let page = 1; page <= MAX_RECONCILIATION_PAGES; page += 1) {\n const subscriptions = await this.servicesRegistry.list<BillingSubscriptionBase>(\n variants.subscription as CoreResourceType,\n listCtx,\n // Terminal subscriptions are excluded on purpose: `CANCELLED` and `INCOMPLETE_EXPIRED` can\n // never become anything else, so re-reading them from the provider forever buys nothing and\n // costs one API call per dead subscription per tick, for the life of the application.\n { status: { $nin: TERMINAL_SUBSCRIPTION_STATUSES } },\n { page, limit: RECONCILIATION_PAGE_SIZE },\n ) as BillingSubscriptionBase[];\n\n for (const subscription of subscriptions) {\n await this.reconcileOneSubscription(variants, subscription, quietPeriodCutoff, result);\n }\n\n if (subscriptions.length < RECONCILIATION_PAGE_SIZE) return;\n }\n\n result.errors.push(\n `Subscription reconciliation stopped after ${MAX_RECONCILIATION_PAGES} pages for scope ${variants.scopeType}. ` +\n `The remaining rows were not examined this tick and will be picked up by the next one.`,\n );\n }\n\n private async reconcileOneSubscription(\n variants: BillingResolvedVariants,\n subscription: BillingSubscriptionBase,\n quietPeriodCutoff: number,\n result: BillingReconciliationResult,\n ): Promise<void> {\n const providerSubscriptionId = subscription.providerSubscriptionId;\n if (!providerSubscriptionId) {\n // A subscription with no provider link is not drift — it is a local row the provider has\n // never heard of, and there is no authority to compare it against.\n return;\n }\n\n result.subscriptionsExamined += 1;\n\n // RULE 3 — a row a local mutation currently owns.\n const updatedAt = subscription.updatedAt ? new Date(subscription.updatedAt).getTime() : 0;\n if (updatedAt > quietPeriodCutoff) {\n result.subscriptionsSkippedRecentlyMutated += 1;\n return;\n }\n\n let providerData: StandardBilling_SubscriptionData;\n try {\n providerData = await this.billingProvider!.retrieveSubscription(providerSubscriptionId);\n } catch (error) {\n // RULE 4 — reported, never acted on. Note in particular that a provider answering \"no such\n // subscription\" lands here and changes nothing.\n result.subscriptionsUnreadable += 1;\n result.errors.push(\n `Subscription ${subscription._id} (provider ${providerSubscriptionId}) could not be read from the provider: ` +\n `${(error as Error).message}. Local state is UNCHANGED — a failed read is not evidence the subscription ended.`,\n );\n return;\n }\n\n const drift = this.computeSubscriptionDrift(subscription, providerData);\n if (Object.keys(drift.updateData).length === 0) return;\n\n result.subscriptionsDrifted += 1;\n result.errors.push(\n `DRIFT REPAIRED — subscription ${subscription._id} (provider ${providerSubscriptionId}) disagreed with the ` +\n `provider on: ${drift.fields.join(', ')}. A webhook for this subscription was very likely never delivered.`,\n );\n\n try {\n const updateCtx = await this.internalCtx(variants.subscription as CoreResourceType, CoreResourceOperation.UPDATE);\n await this.servicesRegistry.update(\n variants.subscription as CoreResourceType,\n updateCtx,\n subscription._id,\n drift.updateData,\n this.trustedWriteOptions(variants.subscription as ResourceType, drift.updateData),\n );\n result.subscriptionsRepaired += 1;\n // Feature sync is NOT called here: the subscription UPDATE post-operation hook fires it, which\n // is the same seam the webhook router relies on. Calling it directly would recompute twice.\n } catch (error) {\n result.errors.push(\n `Failed to write the reconciled state of subscription ${subscription._id}: ${(error as Error).message}`,\n );\n }\n }\n\n /**\n * The comparison, over {@link PROVIDER_AUTHORITATIVE_SUBSCRIPTION_FIELDS} and nothing else.\n *\n * Returns only the fields that actually differ, so the update payload is minimal and the\n * `preserveServerInjectedFields` allowlist derived from it stays minimal with it.\n */\n private computeSubscriptionDrift(\n local: BillingSubscriptionBase,\n provider: StandardBilling_SubscriptionData,\n ): { updateData: Record<string, unknown>; fields: string[] } {\n const providerView: Record<string, unknown> = {\n status: provider.status,\n currentPeriodStart: provider.currentPeriodStart,\n currentPeriodEnd: provider.currentPeriodEnd,\n cancelAtPeriodEnd: provider.cancelAtPeriodEnd,\n // `null` and not `undefined`: a discount that has ENDED must clear the local one, and an\n // omitted key would leave the stale discount in place. Same choice `syncSubscriptionFromProvider`\n // makes, for the same reason.\n discount: provider.discount\n ? {\n providerCouponId: provider.discount.providerCouponId,\n percentOff: provider.discount.percentOff,\n amountOff: provider.discount.amountOff,\n currency: provider.discount.currency,\n duration: provider.discount.duration,\n durationInMonths: provider.discount.durationInMonths,\n end: provider.discount.end,\n }\n : null,\n };\n\n const updateData: Record<string, unknown> = {};\n const fields: string[] = [];\n\n for (const field of PROVIDER_AUTHORITATIVE_SUBSCRIPTION_FIELDS) {\n const localValue = (local as unknown as Record<string, unknown>)[field];\n const providerValue = providerView[field];\n if (this.valuesAgree(localValue, providerValue)) continue;\n updateData[field] = providerValue;\n fields.push(field);\n }\n\n return { updateData, fields };\n }\n\n /**\n * Equality that survives the three shapes these fields actually take.\n *\n * A naive `===` reports drift on EVERY row, forever: `currentPeriodEnd` comes back from the\n * repository as a `Date` instance (or, depending on the adapter and whether the row came through\n * a JSON column or a cache, as an ISO STRING) while the provider hands back a fresh `Date`, and\n * `discount` is an object. A sweep that always sees drift is worse than no sweep — it writes every\n * subscription every tick, recomputes every account's entitlements, and buries a real divergence\n * in a report where every row is listed.\n *\n * Absent and `null` are treated as agreeing: a local row that has never carried a discount and a\n * provider with no discount are the same state, and distinguishing them would write `null` over\n * `undefined` on every discount-free subscription in the application.\n */\n private valuesAgree(local: unknown, provider: unknown): boolean {\n if (local === provider) return true;\n if (local == null && provider == null) return true;\n if (local == null || provider == null) return false;\n // A Date on ONE side and a string on the other. This is the branch that earns its place:\n // two Date INSTANCES are already handled structurally below, but a repository that hands back\n // an ISO string — a JSON column, a serialising adapter, a cached document — against a provider\n // `Date` would otherwise compare unequal on every row, forever, and the sweep would rewrite\n // every subscription on every tick while reporting the whole application as drifted.\n if (local instanceof Date || provider instanceof Date) {\n const localTime = new Date(local as string | number | Date).getTime();\n const providerTime = new Date(provider as string | number | Date).getTime();\n return Number.isFinite(localTime) && Number.isFinite(providerTime) && localTime === providerTime;\n }\n if (typeof local === 'object' && typeof provider === 'object') {\n return this.stableStringify(local) === this.stableStringify(provider);\n }\n return false;\n }\n\n /**\n * Key-order-independent structural comparison for the `discount` object.\n *\n * Key order is not a difference: the local row comes back from a document store or a JSONB column\n * and the provider view is built by an object literal here, so a plain `JSON.stringify` compare\n * would report drift on ordering alone. `undefined` members are dropped so an absent optional and\n * an explicitly-undefined one compare equal, which is the same reading `valuesAgree` takes above.\n */\n private stableStringify(value: unknown): string {\n if (value === null || typeof value !== 'object') return JSON.stringify(value) ?? 'undefined';\n if (value instanceof Date) return `D${value.getTime()}`;\n if (Array.isArray(value)) return `[${value.map(entry => this.stableStringify(entry)).join(',')}]`;\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entryValue]) => entryValue !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, entryValue]) => `${key}:${this.stableStringify(entryValue)}`);\n return `{${entries.join(',')}}`;\n }\n\n // ════════════════════════════════════════════════════════════\n // Invoices\n // ════════════════════════════════════════════════════════════\n\n private async reconcileInvoicesForScope(\n variants: BillingResolvedVariants,\n result: BillingReconciliationResult,\n ): Promise<void> {\n const accountsCtx = await this.internalCtx(variants.billingAccount as CoreResourceType, CoreResourceOperation.LIST);\n\n for (let page = 1; page <= MAX_RECONCILIATION_PAGES; page += 1) {\n const accounts = await this.servicesRegistry.list<BillingAccount>(\n variants.billingAccount as CoreResourceType,\n accountsCtx,\n {},\n { page, limit: RECONCILIATION_PAGE_SIZE },\n ) as BillingAccount[];\n\n for (const account of accounts) {\n const providerCustomerId = (account as unknown as Record<string, unknown>).providerCustomerId as string | undefined;\n if (!providerCustomerId) continue;\n result.billingAccountsExamined += 1;\n try {\n await this.reconcileInvoicesForAccount(variants, account._id, providerCustomerId, result);\n } catch (error) {\n result.errors.push(\n `Invoice reconciliation failed for billing account ${account._id}: ${(error as Error).message}`,\n );\n }\n }\n\n if (accounts.length < RECONCILIATION_PAGE_SIZE) return;\n }\n\n result.errors.push(\n `Invoice reconciliation stopped after ${MAX_RECONCILIATION_PAGES} pages of billing accounts for scope ` +\n `${variants.scopeType}. The remaining accounts will be examined by the next tick.`,\n );\n }\n\n private async reconcileInvoicesForAccount(\n variants: BillingResolvedVariants,\n billingAccountId: string,\n providerCustomerId: string,\n result: BillingReconciliationResult,\n ): Promise<void> {\n const providerInvoices = await this.billingProvider!.listInvoices(providerCustomerId, {\n limit: INVOICE_LOOKBACK_PAGE_SIZE,\n });\n if (providerInvoices.length === 0) return;\n\n const listCtx = await this.internalCtx(variants.invoiceRef as CoreResourceType, CoreResourceOperation.LIST);\n\n for (const providerInvoice of providerInvoices) {\n result.invoicesExamined += 1;\n\n const existing = await this.servicesRegistry.list<InvoiceRef>(\n variants.invoiceRef as CoreResourceType,\n listCtx,\n { providerInvoiceId: providerInvoice.providerInvoiceId },\n { limit: 1 },\n ) as InvoiceRef[];\n\n if (existing.length === 0) {\n await this.recoverMissingInvoice(variants, billingAccountId, providerInvoice, result);\n continue;\n }\n\n const localInvoice = existing[0];\n if (localInvoice.status === providerInvoice.status) continue;\n\n // The ONLY field a sweep updates on an existing invoice. `total` is deliberately excluded, and\n // stays excluded now that the webhook router reads the same provider `total` this sweep does:\n // agreement is not a reason for two writers to both write. Re-deriving it here would bump\n // `updatedAt` and file an audit row for money that did not change, on every tick.\n const statusUpdate = { status: providerInvoice.status };\n try {\n const updateCtx = await this.internalCtx(variants.invoiceRef as CoreResourceType, CoreResourceOperation.UPDATE);\n await this.servicesRegistry.update(\n variants.invoiceRef as CoreResourceType,\n updateCtx,\n localInvoice._id,\n statusUpdate,\n this.trustedWriteOptions(variants.invoiceRef as ResourceType, statusUpdate),\n );\n result.invoiceStatusesRepaired += 1;\n result.errors.push(\n `DRIFT REPAIRED — invoice ${localInvoice._id} (provider ${providerInvoice.providerInvoiceId}) was recorded ` +\n `as \"${localInvoice.status}\" and the provider holds \"${providerInvoice.status}\".`,\n );\n } catch (error) {\n result.errors.push(\n `Failed to correct the status of invoice ${localInvoice._id}: ${(error as Error).message}`,\n );\n }\n }\n }\n\n private async recoverMissingInvoice(\n variants: BillingResolvedVariants,\n billingAccountId: string,\n providerInvoice: StandardBilling_InvoiceData,\n result: BillingReconciliationResult,\n ): Promise<void> {\n /*\n * The scale is the CURRENCY's, exactly as the webhook path resolves it (#515). A zero-decimal\n * currency recorded at scale 2 stores a hundredth of the real amount; an unresolvable currency\n * falls back to 2 with a loud line rather than dropping the invoice, because losing the record\n * of an invoice that exists is worse than recording it at a scale somebody can correct.\n */\n const resolvedDecimals = currencyMinorUnitDecimals(providerInvoice.currency.toUpperCase());\n if (resolvedDecimals === undefined) {\n result.errors.push(\n `Recovered invoice ${providerInvoice.providerInvoiceId} at an ASSUMED scale of 2: currency ` +\n `\"${providerInvoice.currency}\" has no resolvable minor unit.`,\n );\n }\n\n const invoiceData: Record<string, unknown> = {\n [variants.billingAccountFkField]: billingAccountId,\n providerInvoiceId: providerInvoice.providerInvoiceId,\n status: providerInvoice.status,\n total: {\n amount: BigInt(Math.trunc(providerInvoice.total)),\n currency: providerInvoice.currency,\n decimals: resolvedDecimals ?? 2,\n },\n hostedInvoiceUrl: providerInvoice.hostedInvoiceUrl,\n invoicePdfUrl: providerInvoice.invoicePdfUrl,\n };\n\n try {\n const createCtx = await this.internalCtx(variants.invoiceRef as CoreResourceType, CoreResourceOperation.CREATE);\n await this.servicesRegistry.create(\n variants.invoiceRef as CoreResourceType,\n createCtx,\n invoiceData,\n this.trustedWriteOptions(variants.invoiceRef as ResourceType, invoiceData, CoreResourceOperation.CREATE),\n );\n result.invoicesRecovered += 1;\n result.errors.push(\n `INVOICE RECOVERED — provider invoice ${providerInvoice.providerInvoiceId} for billing account ` +\n `${billingAccountId} existed at the provider and nowhere locally. Its webhook was never delivered.`,\n );\n } catch (error) {\n result.errors.push(\n `Failed to record recovered invoice ${providerInvoice.providerInvoiceId}: ${(error as Error).message}`,\n );\n }\n }\n\n // ════════════════════════════════════════════════════════════\n // Private — trusted-system write\n // ════════════════════════════════════════════════════════════\n\n /**\n * `ServiceOptions` that re-attach the fields a client-shaped request DTO would strip.\n *\n * The same seam the webhook router and the catalog sync use, and it is not optional here: every\n * period field on a subscription is `.isNotEditable()` and `providerInvoiceId` is\n * `.isBackendOnly()`, so without the allowlist the write \"succeeds\" and persists nothing — a\n * repair that silently repairs nothing, which is the worst possible outcome for a sweep whose\n * whole job is to make local state true.\n */\n private trustedWriteOptions(\n resourceType: ResourceType,\n payload: Record<string, unknown>,\n verb: CoreResourceOperation.CREATE | CoreResourceOperation.UPDATE = CoreResourceOperation.UPDATE,\n ): ServiceOptions {\n const { mainSchema } = this.resourcesRegistry.getResourceConfiguration(resourceType);\n return {\n preserveServerInjectedFields: deriveTrustedSystemWritePreservedFields(\n mainSchema,\n Object.keys(payload),\n verb,\n ),\n };\n }\n}\n\n/**\n * Statuses a reconciliation sweep considers LIVE — everything `TERMINAL_SUBSCRIPTION_STATUSES` does\n * not claim.\n *\n * DERIVED, so the partition is exhaustive by construction and no pin could ever prove it: a member\n * added to the enum lands in the swept half automatically. That default is the right one (a new\n * status is presumed live until someone says otherwise), but it is a default rather than a decision,\n * so the pin beside this asserts the RESULTING MEMBERSHIP literally. Adding an enum member, or\n * moving one across the boundary, reddens it and puts the decision in front of a person — which is\n * the only thing a test can actually contribute here.\n */\nexport const RECONCILED_SUBSCRIPTION_STATUSES: readonly SubscriptionStatus[] =\n Object.values(SubscriptionStatus).filter(status => !TERMINAL_SUBSCRIPTION_STATUSES.includes(status));\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"billing-state.backend.service.d.ts","sourceRoot":"","sources":["../../../../../../src/billing/services/back-office/billing-state.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAQL,KAAK,oBAAoB,EAIzB,oBAAoB,EAIrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAE5G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iFAAiF,CAAC;AAClI,OAAO,EAAE,6BAA6B,EAAE,MAAM,kFAAkF,CAAC;AACjI,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gFAAgF,CAAC;AAQlI,qBACa,0BAA2B,SAAQ,6BAA6B;IAOxB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBANjD,MAAM,EAAE,aAAa,EACG,gBAAgB,EAAE,qCAAqC,EAChD,uBAAuB,EAAE,qCAAqC,EAC5E,iBAAiB,EAAE,+BAA+B,EACtD,YAAY,EAAE,0BAA0B,EACtB,oBAAoB,EAAE,2BAA2B,EAClD,mBAAmB,EAAE,0BAA0B;IAKlH;;;;;;;;;;;;;OAaG;IACU,QAAQ,CACnB,SAAS,EAAE,oBAAoB,EAC/B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,oBAAoB,EAAE,EACrC,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,oBAAoB,CAAC;YA0ElB,6BAA6B;YAoD7B,kBAAkB;YA4BlB,qBAAqB;YAsBrB,cAAc;YAUd,YAAY;YAUZ,WAAW;YAoBX,cAAc;YA2Bd,eAAe;IAmC7B;;;;;;;;;;OAUG;YACW,mBAAmB;CAuBlC"}
1
+ {"version":3,"file":"billing-state.backend.service.d.ts","sourceRoot":"","sources":["../../../../../src/billing/services/back-office/billing-state.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAQL,KAAK,oBAAoB,EAIzB,oBAAoB,EAIrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAE5G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iFAAiF,CAAC;AAClI,OAAO,EAAE,6BAA6B,EAAE,MAAM,kFAAkF,CAAC;AACjI,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gFAAgF,CAAC;AASlI,qBACa,0BAA2B,SAAQ,6BAA6B;IAOxB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBANjD,MAAM,EAAE,aAAa,EACG,gBAAgB,EAAE,qCAAqC,EAChD,uBAAuB,EAAE,qCAAqC,EAC5E,iBAAiB,EAAE,+BAA+B,EACtD,YAAY,EAAE,0BAA0B,EACtB,oBAAoB,EAAE,2BAA2B,EAClD,mBAAmB,EAAE,0BAA0B;IAKlH;;;;;;;;;;;;;OAaG;IACU,QAAQ,CACnB,SAAS,EAAE,oBAAoB,EAC/B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,oBAAoB,EAAE,EACrC,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,oBAAoB,CAAC;YAqFlB,6BAA6B;YAoD7B,kBAAkB;YA4BlB,qBAAqB;YAsBrB,cAAc;YAUd,YAAY;YAUZ,WAAW;YAoBX,cAAc;YA2Bd,eAAe;IAmC7B;;;;;;;;;;OAUG;YACW,mBAAmB;CAuBlC"}
@@ -25,7 +25,7 @@ import { injectable, inject } from 'inversify';
25
25
  import { CoreResourceType, CoreResourceOperation, SubscriptionStatus, ErrorType, ErrorCustomMessageReference, } from '@wildo-ai/saas-models';
26
26
  import { SAAS_SERVICE_TYPES } from '../../../inject/models/service-types.js';
27
27
  import { AbstractBillingBackendService } from '../../../billing/services/back-office/abstract-billing.backend.service.js';
28
- import { resolveBillingVariantsFromScopeType, } from '../../../billing/services/custom-impl/billing-custom-impl-utils.backend.js';
28
+ import { isProductAcquirable, resolveBillingVariantsFromScopeType, } from '../../../billing/services/custom-impl/billing-custom-impl-utils.backend.js';
29
29
  // ── Service ─────────────────────────────────────────────────────────
30
30
  let BillingStateBackendService = class BillingStateBackendService extends AbstractBillingBackendService {
31
31
  usageMeteringService;
@@ -91,6 +91,15 @@ let BillingStateBackendService = class BillingStateBackendService extends Abstra
91
91
  billingAccountId ? this.getCreditPools(billingAccountId, variants) : {},
92
92
  ]);
93
93
  const products = allProducts.filter((p) => !p.targetScopes || p.targetScopes.includes(scopeType));
94
+ // The ACQUISITION half of catalogue retirement. `products` deliberately keeps every
95
+ // scope-visible row — including retired ones — so a customer already ON a retired plan can
96
+ // still be shown what they hold; this set is what an acquisition surface offers.
97
+ //
98
+ // Derived by `isProductAcquirable`, the SAME predicate `readProductByKey`'s ACQUIRE arm
99
+ // applies, so a plan this set offers is a plan checkout will accept: the listing cannot drift
100
+ // from the gate the way a re-derived `p.isActive` filter can. Total over `products` by
101
+ // construction rather than a second list to keep.
102
+ const acquirableProductKeys = products.filter(isProductAcquirable).map(product => product.key);
94
103
  const activePromotions = await this.getActivePromotions(new Set(products.map(product => product.key)));
95
104
  const usage = billingAccountId
96
105
  ? await this.getUsageSummary(variants, billingAccountId, subscription)
@@ -104,6 +113,7 @@ let BillingStateBackendService = class BillingStateBackendService extends Abstra
104
113
  usage,
105
114
  creditPools,
106
115
  activePromotions,
116
+ acquirableProductKeys,
107
117
  scopeType,
108
118
  };
109
119
  }