@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
@@ -0,0 +1,340 @@
1
+ /**
2
+ * `FileStorageAccepted.GOOGLE_DRIVE` — a file storage whose bytes live in a PERSON's Google Drive
3
+ * (#394 P5).
4
+ *
5
+ * Every other storage here is the application's: it holds a credential of its own and every row
6
+ * is reachable with it. This one holds none. A Drive file is reachable through exactly one grant —
7
+ * the delegated OAuth2 token of the person who linked it (a picker's `REMOTE_REFERENCE`) or
8
+ * uploaded it — so the row's `uploadedBy` is the credential key, resolved through the same
9
+ * connected-accounts store and the same admissibility predicate the browser access-token door
10
+ * uses. A reader who is not the linker still reads the file: the application authorizes the ROW,
11
+ * and the storage reads the BYTES as the linker, which is the delegated access the person granted
12
+ * when they connected the account. Each such read is a recorded credential USE.
13
+ *
14
+ * Two decisions, written down because they are not the obvious ones:
15
+ *
16
+ * - `delete` NEVER touches Drive. The application never owned these bytes: a linked file is the
17
+ * person's document, and an uploaded one landed in their Drive under their account. Deleting a
18
+ * person's own document because an application row went away is the irreversible act this
19
+ * repository requires a deliberate door for, and there is no such door yet. So a delete forgets
20
+ * the reference and says so — a stale file in someone's Drive is a nuisance; a vanished one is
21
+ * an incident.
22
+ * - `isConfigured` asks the registry, not the network. There is no application credential to
23
+ * probe with, and a per-person storage is "configured" exactly when the provider admits a
24
+ * USER-owned delegated connection — the condition under which any row could ever be read.
25
+ *
26
+ * Outbound calls go to one fixed vendor host, so they are not SSRF-pinned; each carries a deadline.
27
+ */
28
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
29
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
32
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
33
+ };
34
+ var __metadata = (this && this.__metadata) || function (k, v) {
35
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
36
+ };
37
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
38
+ return function (target, key) { decorator(target, key, paramIndex); }
39
+ };
40
+ import { injectable, inject } from 'inversify';
41
+ import { Readable } from 'stream';
42
+ import { ErrorType, ErrorCustomMessageReference } from '@wildo-ai/saas-models';
43
+ import { FileStorageAccepted, FileUploaderEntityType } from '@wildo-ai/zod-decorators';
44
+ import { SAAS_SERVICE_TYPES } from '../../inject/models/service-types.js';
45
+ import { ErrorBuilderBackendService } from '../../errors/services/error-builder.backend.service.js';
46
+ import { describeCaughtError } from '../../errors/utils/error-log-level-classification.backend.utils.js';
47
+ import { AppConfigurationService } from '../../config/services/app-configuration.backend.service.js';
48
+ import { ExternalProvidersRegistryBackendService } from '../../external-providers/services/external-providers-registry.backend.service.js';
49
+ import { resolveUserDelegatedAccessTokenSlot } from '../../security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.js';
50
+ import { validateContentType, validateFileId, validateSize, validateStream, resolveConfiguredMaxFileSize } from '../../files/utils/file-validation.utils.js';
51
+ import { resolveFileUploaderPrincipal } from '../../files/utils/file-uploader.utils.js';
52
+ /**
53
+ * The provider whose delegated credential this storage reads through: the CATALOGUE `google-drive`
54
+ * provider (`@wildo-ai/providers/google-drive`), whose OAuth2 client a person connects their Drive
55
+ * through under the `drive.file` scope — not the engine `google` SSO provider, which mints no
56
+ * delegated token. The frontend `google-drive` module carries the same ref, so the picker, the
57
+ * access-token door and this storage all name one account.
58
+ */
59
+ export const GOOGLE_DRIVE_CONNECTED_PROVIDER_REF = 'google-drive';
60
+ /** Drive v3, the only host this storage ever talks to. */
61
+ export const GOOGLE_DRIVE_API_ORIGIN = 'https://www.googleapis.com';
62
+ const GOOGLE_DRIVE_FILES_URL = `${GOOGLE_DRIVE_API_ORIGIN}/drive/v3/files`;
63
+ const GOOGLE_DRIVE_UPLOAD_URL = `${GOOGLE_DRIVE_API_ORIGIN}/upload/drive/v3/files`;
64
+ /** Metadata fields read for a link or a metadata call — the FILES row is built from these. */
65
+ const GOOGLE_DRIVE_METADATA_FIELDS = 'id,name,mimeType,size,modifiedTime,md5Checksum';
66
+ /** One deadline for every call; a download of a large file streams past it only once headers arrived. */
67
+ export const GOOGLE_DRIVE_REQUEST_TIMEOUT_MS = 30_000;
68
+ let GoogleDriveStorageProvider = class GoogleDriveStorageProvider {
69
+ logger;
70
+ errorBuilder;
71
+ appConfigService;
72
+ registry;
73
+ userCredentials;
74
+ providerId = FileStorageAccepted.GOOGLE_DRIVE;
75
+ connectedProviderRef = GOOGLE_DRIVE_CONNECTED_PROVIDER_REF;
76
+ /** `delete` forgets the reference and leaves the bytes in the person's Drive — see the header. */
77
+ retainsBytesOnDelete = true;
78
+ logDebug;
79
+ constructor(logger, errorBuilder, appConfigService, registry, userCredentials) {
80
+ this.logger = logger;
81
+ this.errorBuilder = errorBuilder;
82
+ this.appConfigService = appConfigService;
83
+ this.registry = registry;
84
+ this.userCredentials = userCredentials;
85
+ this.logDebug = this.logger.debugByType('GoogleDriveStorageProvider');
86
+ this.logger.setDebugTypeLogging('GoogleDriveStorageProvider', false);
87
+ }
88
+ isConfigured() {
89
+ // A question, never a throw. The storage router asks EVERY bound provider at readiness in EVERY
90
+ // runtime, and a platform service (`platform-crontabs-batches-manager`) never initializes the
91
+ // external-providers registry, so the slot resolution below would trip `ensureInitialized()`
92
+ // and take the whole storage health check down with it — measured 2026-09-09: crontabs
93
+ // answered `/health/ready` 503 forever, logging `external_provider_registry_initialization_failed`
94
+ // every two seconds, from a provider that runtime could not have configured in the first place.
95
+ if (!this.registry.isReady())
96
+ return false;
97
+ return resolveUserDelegatedAccessTokenSlot(this.registry, this.connectedProviderRef).admitted;
98
+ }
99
+ async initialize() {
100
+ // Nothing to open. The "picker listed, storage not configured" diagnostic is NOT here: the
101
+ // router initializes only configured providers, so a warning on this method never runs. It
102
+ // lives in the startup validator's storage collector, which sees every provider with the
103
+ // registry ready (`collectVendorStorageListedWithoutConnectionIssues`).
104
+ this.logDebug('Google Drive storage ready', { configured: this.isConfigured() });
105
+ }
106
+ async healthCheck() {
107
+ // No probe: there is no application-level credential to probe WITH, and a probe as some
108
+ // arbitrary person would be a credential use nobody asked for.
109
+ const configured = this.isConfigured();
110
+ return {
111
+ healthy: configured,
112
+ latency: 0,
113
+ ...(configured ? {} : { error: `Provider '${this.connectedProviderRef}' does not admit a user-owned delegated connection` }),
114
+ };
115
+ }
116
+ async describeRemoteReference(externalId, linker, executionContext) {
117
+ const token = await this.resolveLinkerToken(linker, executionContext);
118
+ const wire = await this.fetchMetadata(externalId, token, executionContext);
119
+ return this.toDescription(wire, externalId, executionContext);
120
+ }
121
+ async upload(fileStream, fileId, mimeType, size, executionContext, options) {
122
+ validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');
123
+ validateContentType(mimeType, this.errorBuilder, executionContext, 'mimeType');
124
+ const maxFileSize = resolveConfiguredMaxFileSize(this.appConfigService.config.storage?.maxFileSize);
125
+ validateSize(size, maxFileSize, this.errorBuilder, executionContext, 'size');
126
+ validateStream(fileStream, this.errorBuilder, executionContext, 'fileStream');
127
+ // An upload lands in the UPLOADER's Drive: the caller is the person, not a row.
128
+ const token = await this.resolveLinkerToken(resolveFileUploaderPrincipal(executionContext) ?? {}, executionContext);
129
+ // Drive's multipart upload wants the whole body; a resumable session would avoid buffering at
130
+ // the cost of two more round trips, and the configured maximum already bounds what is read.
131
+ const bytes = await readAllBounded(fileStream, maxFileSize, () => this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {
132
+ customMessageReference: ErrorCustomMessageReference.VALIDATION,
133
+ context: { message: 'Stream exceeded the configured maximum file size', fileId, maxFileSize },
134
+ }));
135
+ const boundary = `wildo-${fileId}`;
136
+ const metadata = JSON.stringify({ name: options?.fileName ?? fileId, mimeType });
137
+ const body = Buffer.concat([
138
+ Buffer.from(`--${boundary}\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n${metadata}\r\n--${boundary}\r\nContent-Type: ${mimeType}\r\n\r\n`, 'utf8'),
139
+ bytes,
140
+ Buffer.from(`\r\n--${boundary}--`, 'utf8'),
141
+ ]);
142
+ const response = await this.call(`${GOOGLE_DRIVE_UPLOAD_URL}?uploadType=multipart&fields=id&supportsAllDrives=true`, { method: 'POST', headers: { authorization: `Bearer ${token}`, 'content-type': `multipart/related; boundary=${boundary}` }, body }, executionContext, { fileId });
143
+ const wire = (await response.json());
144
+ const storageRef = typeof wire.id === 'string' && wire.id.length > 0 ? wire.id : undefined;
145
+ if (storageRef === undefined) {
146
+ throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {
147
+ customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,
148
+ context: { message: 'Google Drive accepted the upload but returned no file id', fileId },
149
+ });
150
+ }
151
+ this.logDebug('Uploaded to Google Drive', { fileId, storageRef });
152
+ return { storageRef, provider: this.providerId };
153
+ }
154
+ async download(file, executionContext) {
155
+ const externalId = this.requireStorageRef(file, executionContext);
156
+ const token = await this.resolveLinkerToken(file, executionContext);
157
+ // Metadata first: `alt=media` answers with the bytes and a content-type, but the size Drive
158
+ // reports on the media response is not reliable for converted documents, and the row's
159
+ // consumers size their buffers from this result.
160
+ const wire = await this.fetchMetadata(externalId, token, executionContext, file.fileId);
161
+ const description = this.toDescription(wire, externalId, executionContext);
162
+ const response = await this.call(`${GOOGLE_DRIVE_FILES_URL}/${encodeURIComponent(externalId)}?alt=media&supportsAllDrives=true`, { method: 'GET', headers: { authorization: `Bearer ${token}` } }, executionContext, { fileId: file.fileId, storageRef: externalId });
163
+ if (response.body === null) {
164
+ throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {
165
+ customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,
166
+ context: { message: 'Google Drive answered a media request with no body', fileId: file.fileId },
167
+ });
168
+ }
169
+ return {
170
+ stream: Readable.fromWeb(response.body),
171
+ contentType: response.headers.get('content-type') ?? description.contentType,
172
+ size: description.size,
173
+ ...(description.etag !== undefined ? { etag: description.etag } : {}),
174
+ ...(description.lastModified !== undefined ? { lastModified: description.lastModified } : {}),
175
+ };
176
+ }
177
+ async delete(file, _executionContext) {
178
+ // Deliberately no vendor call — see the file header. The reference is forgotten with the row.
179
+ this.logger.info('Google Drive file reference forgotten; the file stays in its owner\'s Drive', {
180
+ fileId: file.fileId,
181
+ storageRef: file.storageRef,
182
+ });
183
+ }
184
+ async getMetadata(file, executionContext) {
185
+ const externalId = this.requireStorageRef(file, executionContext);
186
+ const token = await this.resolveLinkerToken(file, executionContext);
187
+ const wire = await this.fetchMetadata(externalId, token, executionContext, file.fileId);
188
+ const { name: _name, ...metadata } = this.toDescription(wire, externalId, executionContext);
189
+ return metadata;
190
+ }
191
+ // ---------------------------------------------------------------------------
192
+ /**
193
+ * The delegated token of the person a target names. Three refusals, each naming what is
194
+ * missing: the target names no signed-in person; the provider admits no personal connection;
195
+ * the person's connection is gone. Every success is a recorded credential use.
196
+ *
197
+ * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — a person's delegated grant is
198
+ * spent server-side only, only for a file that person linked or uploaded, and only as a
199
+ * recorded use; the token never reaches the reader.
200
+ */
201
+ async resolveLinkerToken(linker, executionContext) {
202
+ const identity = this.requireLinker(linker, executionContext);
203
+ const slot = resolveUserDelegatedAccessTokenSlot(this.registry, this.connectedProviderRef);
204
+ if (slot.admitted === false) {
205
+ throw this.errorBuilder.buildError(ErrorType.CONFIGURATION, executionContext, {
206
+ customMessageReference: ErrorCustomMessageReference.CONFIGURATION,
207
+ context: {
208
+ message: `Google Drive storage needs the '${this.connectedProviderRef}' provider to admit a user-owned delegated connection`,
209
+ refusal: slot.refusal,
210
+ },
211
+ });
212
+ }
213
+ const query = { userId: identity.userId, providerRef: this.connectedProviderRef, secretSlug: slot.secretSlug };
214
+ const resolution = await this.userCredentials.resolveUserCredential(query);
215
+ if (resolution === undefined) {
216
+ throw this.errorBuilder.buildError(ErrorType.AUTHORIZATION, executionContext, {
217
+ customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,
218
+ context: {
219
+ message: `The person this Google Drive file is reachable through has no '${this.connectedProviderRef}' connection`,
220
+ userId: identity.userId,
221
+ },
222
+ });
223
+ }
224
+ await this.userCredentials.recordCredentialUse({ ...query, credentialId: resolution.credentialId });
225
+ return resolution.value;
226
+ }
227
+ requireLinker(linker, executionContext) {
228
+ if (linker.uploadedByEntityType !== FileUploaderEntityType.USER || !linker.uploadedBy) {
229
+ throw this.errorBuilder.buildError(ErrorType.AUTHORIZATION, executionContext, {
230
+ customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,
231
+ context: {
232
+ message: 'A Google Drive file is reachable only through the signed-in person who linked or uploaded it, and this one names none',
233
+ uploadedByEntityType: linker.uploadedByEntityType,
234
+ },
235
+ });
236
+ }
237
+ return { userId: linker.uploadedBy };
238
+ }
239
+ requireStorageRef(file, executionContext) {
240
+ if (!file.storageRef) {
241
+ throw this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {
242
+ customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_REF_INVALID,
243
+ context: { message: 'Google Drive file row carries no storageRef', fileId: file.fileId },
244
+ });
245
+ }
246
+ return file.storageRef;
247
+ }
248
+ async fetchMetadata(externalId, token, executionContext, fileId) {
249
+ const response = await this.call(`${GOOGLE_DRIVE_FILES_URL}/${encodeURIComponent(externalId)}?fields=${encodeURIComponent(GOOGLE_DRIVE_METADATA_FIELDS)}&supportsAllDrives=true`, { method: 'GET', headers: { authorization: `Bearer ${token}` } }, executionContext, { fileId, storageRef: externalId });
250
+ return (await response.json());
251
+ }
252
+ toDescription(wire, externalId, executionContext) {
253
+ const contentType = typeof wire.mimeType === 'string' && wire.mimeType.length > 0 ? wire.mimeType : undefined;
254
+ // Drive reports `size` as a decimal STRING, and omits it for Google-native documents (Docs,
255
+ // Sheets), which have no bytes until exported. A file with no size cannot be linked as a file.
256
+ const size = typeof wire.size === 'string' && /^\d+$/.test(wire.size) ? Number(wire.size)
257
+ : typeof wire.size === 'number' ? wire.size : undefined;
258
+ if (contentType === undefined || size === undefined) {
259
+ throw this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {
260
+ customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_REF_INVALID,
261
+ context: {
262
+ message: contentType === undefined
263
+ ? 'Google Drive reports no MIME type for this file'
264
+ : 'Google Drive reports no byte size for this file — a Google-native document has none until exported',
265
+ storageRef: externalId,
266
+ },
267
+ });
268
+ }
269
+ const lastModified = typeof wire.modifiedTime === 'string' ? new Date(wire.modifiedTime) : undefined;
270
+ return {
271
+ name: typeof wire.name === 'string' && wire.name.length > 0 ? wire.name : externalId,
272
+ contentType,
273
+ size,
274
+ ...(typeof wire.md5Checksum === 'string' ? { etag: wire.md5Checksum } : {}),
275
+ ...(lastModified !== undefined && !Number.isNaN(lastModified.getTime()) ? { lastModified } : {}),
276
+ };
277
+ }
278
+ /** One call shape: fixed host, a deadline, and vendor status codes mapped to this repository's error types. */
279
+ async call(url, init, executionContext, context) {
280
+ let response;
281
+ try {
282
+ response = await fetch(url, {
283
+ method: init.method,
284
+ headers: init.headers,
285
+ ...(init.body === undefined ? {} : { body: new Uint8Array(init.body) }),
286
+ signal: AbortSignal.timeout(GOOGLE_DRIVE_REQUEST_TIMEOUT_MS),
287
+ });
288
+ }
289
+ catch (error) {
290
+ throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {
291
+ customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,
292
+ context: { message: 'Google Drive request failed', ...context, error: describeCaughtError(error) },
293
+ });
294
+ }
295
+ if (response.ok)
296
+ return response;
297
+ if (response.status === 404) {
298
+ throw this.errorBuilder.buildError(ErrorType.NOT_FOUND, executionContext, {
299
+ customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,
300
+ context: { message: 'Google Drive knows no such file for this person', ...context },
301
+ });
302
+ }
303
+ if (response.status === 401 || response.status === 403) {
304
+ throw this.errorBuilder.buildError(ErrorType.AUTHORIZATION, executionContext, {
305
+ customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,
306
+ context: { message: 'Google Drive refused the delegated credential for this file', status: response.status, ...context },
307
+ });
308
+ }
309
+ throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {
310
+ customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,
311
+ context: { message: 'Google Drive answered with an error', status: response.status, ...context },
312
+ });
313
+ }
314
+ };
315
+ GoogleDriveStorageProvider = __decorate([
316
+ injectable(),
317
+ __param(0, inject(SAAS_SERVICE_TYPES.Logger)),
318
+ __param(1, inject(SAAS_SERVICE_TYPES.ErrorBuilderService)),
319
+ __param(2, inject(SAAS_SERVICE_TYPES.AppConfigService)),
320
+ __param(3, inject(SAAS_SERVICE_TYPES.ExternalProvidersRegistryService)),
321
+ __param(4, inject(SAAS_SERVICE_TYPES.UserProviderCredentialResolver)),
322
+ __metadata("design:paramtypes", [Function, ErrorBuilderBackendService,
323
+ AppConfigurationService,
324
+ ExternalProvidersRegistryBackendService, Object])
325
+ ], GoogleDriveStorageProvider);
326
+ export { GoogleDriveStorageProvider };
327
+ /** Drains a stream into one buffer, refusing past `limit` before the whole thing is in memory. */
328
+ async function readAllBounded(stream, limit, overflow) {
329
+ const chunks = [];
330
+ let total = 0;
331
+ for await (const chunk of stream) {
332
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
333
+ total += buffer.length;
334
+ if (total > limit)
335
+ throw overflow();
336
+ chunks.push(buffer);
337
+ }
338
+ return Buffer.concat(chunks);
339
+ }
340
+ //# sourceMappingURL=google-drive-storage-provider.backend.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-drive-storage-provider.backend.service.js","sourceRoot":"","sources":["../../../../src/files/storage/google-drive-storage-provider.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,8EAA8E,CAAC;AACnH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sEAAsE,CAAC;AAE/G,OAAO,EAAE,uCAAuC,EAAE,MAAM,4FAA4F,CAAC;AAErJ,OAAO,EAAE,mCAAmC,EA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CAAC,CAAA;+CAHqB,0BAA0B;QACzB,uBAAuB;QACf,uCAAuC;GAXtH,0BAA0B,CAsStC;;AAED,kGAAkG;AAClG,KAAK,UAAU,cAAc,CAAC,MAAgB,EAAE,KAAa,EAAE,QAAuB;IACpF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAA4B,CAAC,CAAC;QAC1F,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC;QACvB,IAAI,KAAK,GAAG,KAAK;YAAE,MAAM,QAAQ,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * `FileStorageAccepted.GOOGLE_DRIVE` — a file storage whose bytes live in a PERSON's Google Drive\n * (#394 P5).\n *\n * Every other storage here is the application's: it holds a credential of its own and every row\n * is reachable with it. This one holds none. A Drive file is reachable through exactly one grant —\n * the delegated OAuth2 token of the person who linked it (a picker's `REMOTE_REFERENCE`) or\n * uploaded it — so the row's `uploadedBy` is the credential key, resolved through the same\n * connected-accounts store and the same admissibility predicate the browser access-token door\n * uses. A reader who is not the linker still reads the file: the application authorizes the ROW,\n * and the storage reads the BYTES as the linker, which is the delegated access the person granted\n * when they connected the account. Each such read is a recorded credential USE.\n *\n * Two decisions, written down because they are not the obvious ones:\n *\n * - `delete` NEVER touches Drive. The application never owned these bytes: a linked file is the\n * person's document, and an uploaded one landed in their Drive under their account. Deleting a\n * person's own document because an application row went away is the irreversible act this\n * repository requires a deliberate door for, and there is no such door yet. So a delete forgets\n * the reference and says so — a stale file in someone's Drive is a nuisance; a vanished one is\n * an incident.\n * - `isConfigured` asks the registry, not the network. There is no application credential to\n * probe with, and a per-person storage is \"configured\" exactly when the provider admits a\n * USER-owned delegated connection — the condition under which any row could ever be read.\n *\n * Outbound calls go to one fixed vendor host, so they are not SSRF-pinned; each carries a deadline.\n */\n\nimport { injectable, inject } from 'inversify';\nimport { Readable } from 'stream';\nimport type { ReadableStream as WebReadableStream } from 'stream/web';\nimport { ErrorType, ErrorCustomMessageReference } from '@wildo-ai/saas-models';\nimport type { File } from '@wildo-ai/saas-models';\nimport { FileStorageAccepted, FileUploaderEntityType } from '@wildo-ai/zod-decorators';\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 { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\nimport { describeCaughtError } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { AppConfigurationService } from '~wildo-backend-lib/config/services/app-configuration.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport { ExternalProvidersRegistryBackendService } from '~wildo-backend-lib/external-providers/services/external-providers-registry.backend.service';\nimport type { UserProviderCredentialResolverPort } from '~wildo-backend-lib/security/connected-accounts/user-provider-credential-resolver.port';\nimport { resolveUserDelegatedAccessTokenSlot } from '~wildo-backend-lib/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils';\nimport { validateContentType, validateFileId, validateSize, validateStream, resolveConfiguredMaxFileSize } from '~wildo-backend-lib/files/utils/file-validation.utils';\nimport { resolveFileUploaderPrincipal } from '~wildo-backend-lib/files/utils/file-uploader.utils';\nimport type {\n IFileStorageProvider,\n StorageDownloadResult,\n StorageFileMetadata,\n StorageProviderHealthResult,\n StorageRemoteFileDescription,\n StorageUploadOptions,\n StorageUploadResult,\n StoredFileStorageTarget,\n} from './file-storage-provider.types';\n\n/**\n * The provider whose delegated credential this storage reads through: the CATALOGUE `google-drive`\n * provider (`@wildo-ai/providers/google-drive`), whose OAuth2 client a person connects their Drive\n * through under the `drive.file` scope — not the engine `google` SSO provider, which mints no\n * delegated token. The frontend `google-drive` module carries the same ref, so the picker, the\n * access-token door and this storage all name one account.\n */\nexport const GOOGLE_DRIVE_CONNECTED_PROVIDER_REF = 'google-drive';\n\n/** Drive v3, the only host this storage ever talks to. */\nexport const GOOGLE_DRIVE_API_ORIGIN = 'https://www.googleapis.com';\nconst GOOGLE_DRIVE_FILES_URL = `${GOOGLE_DRIVE_API_ORIGIN}/drive/v3/files`;\nconst GOOGLE_DRIVE_UPLOAD_URL = `${GOOGLE_DRIVE_API_ORIGIN}/upload/drive/v3/files`;\n/** Metadata fields read for a link or a metadata call — the FILES row is built from these. */\nconst GOOGLE_DRIVE_METADATA_FIELDS = 'id,name,mimeType,size,modifiedTime,md5Checksum';\n/** One deadline for every call; a download of a large file streams past it only once headers arrived. */\nexport const GOOGLE_DRIVE_REQUEST_TIMEOUT_MS = 30_000;\n\ninterface DriveFileMetadataWire {\n id?: unknown;\n name?: unknown;\n mimeType?: unknown;\n size?: unknown;\n modifiedTime?: unknown;\n md5Checksum?: unknown;\n}\n\n/** The linker a target names, once it has been checked to be a signed-in person. */\ninterface LinkerIdentity {\n readonly userId: string;\n}\n\n@injectable()\nexport class GoogleDriveStorageProvider implements IFileStorageProvider {\n readonly providerId = FileStorageAccepted.GOOGLE_DRIVE;\n readonly connectedProviderRef = GOOGLE_DRIVE_CONNECTED_PROVIDER_REF;\n /** `delete` forgets the reference and leaves the bytes in the person's Drive — see the header. */\n readonly retainsBytesOnDelete = true;\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService) private readonly errorBuilder: ErrorBuilderBackendService,\n @inject(SAAS_SERVICE_TYPES.AppConfigService) private readonly appConfigService: AppConfigurationService,\n @inject(SAAS_SERVICE_TYPES.ExternalProvidersRegistryService) private readonly registry: ExternalProvidersRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.UserProviderCredentialResolver) private readonly userCredentials: UserProviderCredentialResolverPort,\n ) {\n this.logDebug = this.logger.debugByType('GoogleDriveStorageProvider');\n this.logger.setDebugTypeLogging('GoogleDriveStorageProvider', false);\n }\n\n isConfigured(): boolean {\n // A question, never a throw. The storage router asks EVERY bound provider at readiness in EVERY\n // runtime, and a platform service (`platform-crontabs-batches-manager`) never initializes the\n // external-providers registry, so the slot resolution below would trip `ensureInitialized()`\n // and take the whole storage health check down with it — measured 2026-09-09: crontabs\n // answered `/health/ready` 503 forever, logging `external_provider_registry_initialization_failed`\n // every two seconds, from a provider that runtime could not have configured in the first place.\n if (!this.registry.isReady()) return false;\n return resolveUserDelegatedAccessTokenSlot(this.registry, this.connectedProviderRef).admitted;\n }\n\n async initialize(): Promise<void> {\n // Nothing to open. The \"picker listed, storage not configured\" diagnostic is NOT here: the\n // router initializes only configured providers, so a warning on this method never runs. It\n // lives in the startup validator's storage collector, which sees every provider with the\n // registry ready (`collectVendorStorageListedWithoutConnectionIssues`).\n this.logDebug('Google Drive storage ready', { configured: this.isConfigured() });\n }\n\n async healthCheck(): Promise<StorageProviderHealthResult> {\n // No probe: there is no application-level credential to probe WITH, and a probe as some\n // arbitrary person would be a credential use nobody asked for.\n const configured = this.isConfigured();\n return {\n healthy: configured,\n latency: 0,\n ...(configured ? {} : { error: `Provider '${this.connectedProviderRef}' does not admit a user-owned delegated connection` }),\n };\n }\n\n async describeRemoteReference(\n externalId: string,\n linker: Pick<File, 'uploadedBy' | 'uploadedByEntityType'>,\n executionContext: ExecutionContext<any>,\n ): Promise<StorageRemoteFileDescription> {\n const token = await this.resolveLinkerToken(linker, executionContext);\n const wire = await this.fetchMetadata(externalId, token, executionContext);\n return this.toDescription(wire, externalId, executionContext);\n }\n\n async upload(\n fileStream: Readable,\n fileId: string,\n mimeType: string,\n size: number,\n executionContext: ExecutionContext<any>,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult> {\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n validateContentType(mimeType, this.errorBuilder, executionContext, 'mimeType');\n const maxFileSize = resolveConfiguredMaxFileSize(this.appConfigService.config.storage?.maxFileSize);\n validateSize(size, maxFileSize, this.errorBuilder, executionContext, 'size');\n validateStream(fileStream, this.errorBuilder, executionContext, 'fileStream');\n\n // An upload lands in the UPLOADER's Drive: the caller is the person, not a row.\n const token = await this.resolveLinkerToken(resolveFileUploaderPrincipal(executionContext) ?? {}, executionContext);\n\n // Drive's multipart upload wants the whole body; a resumable session would avoid buffering at\n // the cost of two more round trips, and the configured maximum already bounds what is read.\n const bytes = await readAllBounded(fileStream, maxFileSize, () =>\n this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: 'Stream exceeded the configured maximum file size', fileId, maxFileSize },\n }));\n\n const boundary = `wildo-${fileId}`;\n const metadata = JSON.stringify({ name: options?.fileName ?? fileId, mimeType });\n const body = Buffer.concat([\n Buffer.from(`--${boundary}\\r\\nContent-Type: application/json; charset=UTF-8\\r\\n\\r\\n${metadata}\\r\\n--${boundary}\\r\\nContent-Type: ${mimeType}\\r\\n\\r\\n`, 'utf8'),\n bytes,\n Buffer.from(`\\r\\n--${boundary}--`, 'utf8'),\n ]);\n\n const response = await this.call(\n `${GOOGLE_DRIVE_UPLOAD_URL}?uploadType=multipart&fields=id&supportsAllDrives=true`,\n { method: 'POST', headers: { authorization: `Bearer ${token}`, 'content-type': `multipart/related; boundary=${boundary}` }, body },\n executionContext,\n { fileId },\n );\n const wire = (await response.json()) as DriveFileMetadataWire;\n const storageRef = typeof wire.id === 'string' && wire.id.length > 0 ? wire.id : undefined;\n if (storageRef === undefined) {\n throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: 'Google Drive accepted the upload but returned no file id', fileId },\n });\n }\n this.logDebug('Uploaded to Google Drive', { fileId, storageRef });\n return { storageRef, provider: this.providerId };\n }\n\n async download(file: StoredFileStorageTarget, executionContext: ExecutionContext<any>): Promise<StorageDownloadResult> {\n const externalId = this.requireStorageRef(file, executionContext);\n const token = await this.resolveLinkerToken(file, executionContext);\n // Metadata first: `alt=media` answers with the bytes and a content-type, but the size Drive\n // reports on the media response is not reliable for converted documents, and the row's\n // consumers size their buffers from this result.\n const wire = await this.fetchMetadata(externalId, token, executionContext, file.fileId);\n const description = this.toDescription(wire, externalId, executionContext);\n const response = await this.call(\n `${GOOGLE_DRIVE_FILES_URL}/${encodeURIComponent(externalId)}?alt=media&supportsAllDrives=true`,\n { method: 'GET', headers: { authorization: `Bearer ${token}` } },\n executionContext,\n { fileId: file.fileId, storageRef: externalId },\n );\n if (response.body === null) {\n throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: 'Google Drive answered a media request with no body', fileId: file.fileId },\n });\n }\n return {\n stream: Readable.fromWeb(response.body as unknown as WebReadableStream<Uint8Array>),\n contentType: response.headers.get('content-type') ?? description.contentType,\n size: description.size,\n ...(description.etag !== undefined ? { etag: description.etag } : {}),\n ...(description.lastModified !== undefined ? { lastModified: description.lastModified } : {}),\n };\n }\n\n async delete(file: StoredFileStorageTarget, _executionContext: ExecutionContext<any>): Promise<void> {\n // Deliberately no vendor call — see the file header. The reference is forgotten with the row.\n this.logger.info('Google Drive file reference forgotten; the file stays in its owner\\'s Drive', {\n fileId: file.fileId,\n storageRef: file.storageRef,\n });\n }\n\n async getMetadata(file: StoredFileStorageTarget, executionContext: ExecutionContext<any>): Promise<StorageFileMetadata> {\n const externalId = this.requireStorageRef(file, executionContext);\n const token = await this.resolveLinkerToken(file, executionContext);\n const wire = await this.fetchMetadata(externalId, token, executionContext, file.fileId);\n const { name: _name, ...metadata } = this.toDescription(wire, externalId, executionContext);\n return metadata;\n }\n\n // ---------------------------------------------------------------------------\n\n /**\n * The delegated token of the person a target names. Three refusals, each naming what is\n * missing: the target names no signed-in person; the provider admits no personal connection;\n * the person's connection is gone. Every success is a recorded credential use.\n *\n * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — a person's delegated grant is\n * spent server-side only, only for a file that person linked or uploaded, and only as a\n * recorded use; the token never reaches the reader.\n */\n private async resolveLinkerToken(\n linker: Pick<File, 'uploadedBy' | 'uploadedByEntityType'>,\n executionContext: ExecutionContext<any>,\n ): Promise<string> {\n const identity = this.requireLinker(linker, executionContext);\n const slot = resolveUserDelegatedAccessTokenSlot(this.registry, this.connectedProviderRef);\n if (slot.admitted === false) {\n throw this.errorBuilder.buildError(ErrorType.CONFIGURATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message: `Google Drive storage needs the '${this.connectedProviderRef}' provider to admit a user-owned delegated connection`,\n refusal: slot.refusal,\n },\n });\n }\n const query = { userId: identity.userId, providerRef: this.connectedProviderRef, secretSlug: slot.secretSlug };\n const resolution = await this.userCredentials.resolveUserCredential(query);\n if (resolution === undefined) {\n throw this.errorBuilder.buildError(ErrorType.AUTHORIZATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,\n context: {\n message: `The person this Google Drive file is reachable through has no '${this.connectedProviderRef}' connection`,\n userId: identity.userId,\n },\n });\n }\n await this.userCredentials.recordCredentialUse({ ...query, credentialId: resolution.credentialId });\n return resolution.value;\n }\n\n private requireLinker(linker: Pick<File, 'uploadedBy' | 'uploadedByEntityType'>, executionContext: ExecutionContext<any>): LinkerIdentity {\n if (linker.uploadedByEntityType !== FileUploaderEntityType.USER || !linker.uploadedBy) {\n throw this.errorBuilder.buildError(ErrorType.AUTHORIZATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,\n context: {\n message: 'A Google Drive file is reachable only through the signed-in person who linked or uploaded it, and this one names none',\n uploadedByEntityType: linker.uploadedByEntityType,\n },\n });\n }\n return { userId: linker.uploadedBy };\n }\n\n private requireStorageRef(file: StoredFileStorageTarget, executionContext: ExecutionContext<any>): string {\n if (!file.storageRef) {\n throw this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_REF_INVALID,\n context: { message: 'Google Drive file row carries no storageRef', fileId: file.fileId },\n });\n }\n return file.storageRef;\n }\n\n private async fetchMetadata(externalId: string, token: string, executionContext: ExecutionContext<any>, fileId?: string): Promise<DriveFileMetadataWire> {\n const response = await this.call(\n `${GOOGLE_DRIVE_FILES_URL}/${encodeURIComponent(externalId)}?fields=${encodeURIComponent(GOOGLE_DRIVE_METADATA_FIELDS)}&supportsAllDrives=true`,\n { method: 'GET', headers: { authorization: `Bearer ${token}` } },\n executionContext,\n { fileId, storageRef: externalId },\n );\n return (await response.json()) as DriveFileMetadataWire;\n }\n\n private toDescription(wire: DriveFileMetadataWire, externalId: string, executionContext: ExecutionContext<any>): StorageRemoteFileDescription {\n const contentType = typeof wire.mimeType === 'string' && wire.mimeType.length > 0 ? wire.mimeType : undefined;\n // Drive reports `size` as a decimal STRING, and omits it for Google-native documents (Docs,\n // Sheets), which have no bytes until exported. A file with no size cannot be linked as a file.\n const size = typeof wire.size === 'string' && /^\\d+$/.test(wire.size) ? Number(wire.size)\n : typeof wire.size === 'number' ? wire.size : undefined;\n if (contentType === undefined || size === undefined) {\n throw this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_REF_INVALID,\n context: {\n message: contentType === undefined\n ? 'Google Drive reports no MIME type for this file'\n : 'Google Drive reports no byte size for this file — a Google-native document has none until exported',\n storageRef: externalId,\n },\n });\n }\n const lastModified = typeof wire.modifiedTime === 'string' ? new Date(wire.modifiedTime) : undefined;\n return {\n name: typeof wire.name === 'string' && wire.name.length > 0 ? wire.name : externalId,\n contentType,\n size,\n ...(typeof wire.md5Checksum === 'string' ? { etag: wire.md5Checksum } : {}),\n ...(lastModified !== undefined && !Number.isNaN(lastModified.getTime()) ? { lastModified } : {}),\n };\n }\n\n /** One call shape: fixed host, a deadline, and vendor status codes mapped to this repository's error types. */\n private async call(\n url: string,\n init: { method: string; headers: Record<string, string>; body?: Buffer },\n executionContext: ExecutionContext<any>,\n context: Record<string, unknown>,\n ): Promise<Response> {\n let response: Response;\n try {\n response = await fetch(url, {\n method: init.method,\n headers: init.headers,\n ...(init.body === undefined ? {} : { body: new Uint8Array(init.body) }),\n signal: AbortSignal.timeout(GOOGLE_DRIVE_REQUEST_TIMEOUT_MS),\n });\n } catch (error) {\n throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: 'Google Drive request failed', ...context, error: describeCaughtError(error) },\n });\n }\n if (response.ok) return response;\n if (response.status === 404) {\n throw this.errorBuilder.buildError(ErrorType.NOT_FOUND, executionContext, {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,\n context: { message: 'Google Drive knows no such file for this person', ...context },\n });\n }\n if (response.status === 401 || response.status === 403) {\n throw this.errorBuilder.buildError(ErrorType.AUTHORIZATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,\n context: { message: 'Google Drive refused the delegated credential for this file', status: response.status, ...context },\n });\n }\n throw this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, executionContext, {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: 'Google Drive answered with an error', status: response.status, ...context },\n });\n }\n}\n\n/** Drains a stream into one buffer, refusing past `limit` before the whole thing is in memory. */\nasync function readAllBounded(stream: Readable, limit: number, overflow: () => unknown): Promise<Buffer> {\n const chunks: Buffer[] = [];\n let total = 0;\n for await (const chunk of stream) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk as Uint8Array | string);\n total += buffer.length;\n if (total > limit) throw overflow();\n chunks.push(buffer);\n }\n return Buffer.concat(chunks);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"local-directory-storage-provider.backend.service.d.ts","sourceRoot":"","sources":["../../../../../src/files/storage/local-directory-storage-provider.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAE9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,sEAAsE,CAAC;AAC/G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAQ5G,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AAUvC,qBACa,6BAA8B,YAAW,oBAAoB;IAMtE,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAE7B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IATnC,QAAQ,CAAC,UAAU,uCAAuC;IAC1D,OAAO,CAAC,OAAO,CAAuB;gBAInB,MAAM,EAAE,aAAa,EAErB,YAAY,EAAE,0BAA0B,EAExC,gBAAgB,EAAE,uBAAuB;IAG5D;;;;;OAKG;IACH,YAAY,IAAI,OAAO;IAIvB,yFAAyF;IACzF,OAAO,KAAK,iBAAiB,GAE5B;IAEK,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3B,WAAW,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAmBzD,OAAO,CAAC,UAAU;IAkBlB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,iBAAiB;IAqDzB;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,gBAAgB;IAMlB,MAAM,CACV,UAAU,EAAE,QAAQ,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,EACvC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC;IAqCzB,QAAQ,CACZ,IAAI,EAAE,uBAAuB,EAC7B,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,qBAAqB,CAAC;IAgC3B,MAAM,CACV,IAAI,EAAE,uBAAuB,EAC7B,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC;IAoBV,WAAW,CACf,IAAI,EAAE,uBAAuB,EAC7B,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC;IA8B/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,OAAO,CAAC,yBAAyB;YAWnB,iBAAiB;IAkB/B,OAAO,CAAC,mBAAmB;CAuD5B"}
1
+ {"version":3,"file":"local-directory-storage-provider.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/files/storage/local-directory-storage-provider.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,E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B,EAC7B,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,qBAAqB,CAAC;IAgC3B,MAAM,CACV,IAAI,EAAE,uBAAuB,EAC7B,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC;IAoBV,WAAW,CACf,IAAI,EAAE,uBAAuB,EAC7B,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC;IA8B/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,OAAO,CAAC,yBAAyB;YAWnB,iBAAiB;IAkB/B,OAAO,CAAC,mBAAmB;CAuD5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"local-directory-storage-provider.backend.service.js","sourceRoot":"","sources":["../../../../../src/files/storage/local-directory-storage-provider.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,8EAA8E,CAAC;AACnH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sEAAsE,CAAC;AAE/G,OAAO,EAAE,aAAa,EAAE,mBAAmB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**\n * Local Directory Storage Provider\n *\n * IFileStorageProvider implementation backed by the local filesystem.\n * Files are stored under a configurable base directory, at the SAME relative key the\n * Wildo-managed provider would use — `applications/<appId>/files/<storageName>/<scope>/<scopeId>/…`,\n * composed by `application-storage-key.backend.utils`. Path traversal attacks are guarded against\n * by refusing a `.`/`..` segment in the composed key AND by resolving every path and verifying it\n * stays inside the base dir.\n *\n * ## Why the key shape is shared rather than provider-local\n *\n * Until 2026-09-09 this provider composed `[applicationId]/[folderPath]/<leaf>` from the field's\n * declarative binding alone, and included the application id only when the binding asked\n * (`includeApplicationId`, defaulting to `false` here). It therefore emitted NONE of the\n * `<scope>/<scopeId>` segments the managed provider's shape carries, so a deployment routing a\n * `z_file()` field to local storage had no per-tenant prefix to sweep, list or confine against —\n * and nothing failed, because an absent prefix produces no error, only an absent capability.\n *\n * Both providers now call one composer. See `application-storage-key.backend.utils.ts` for the\n * argument and for what deliberately stays provider-local.\n *\n * Configured through `storage.localDirectory.baseDir` in resolved application\n * configuration, which the configuration loader seeds from the\n * `STORAGE_LOCAL_BASE_DIR` environment variable. The provider itself reads\n * configuration, never the environment — see\n * `.claude/plans/application-runtime-topology-delivery.md`.\n */\n\nimport { injectable, inject } from 'inversify';\nimport { Readable } from 'stream';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { pipeline } from 'stream/promises';\nimport { ErrorType, ErrorCustomMessageReference, isWildoBackendError } from '@wildo-ai/saas-models';\nimport { FileStorageAccepted } from '@wildo-ai/zod-decorators';\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 { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\nimport { describeCaughtError } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { AppConfigurationService } from '~wildo-backend-lib/config/services/app-configuration.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport { validateAppId, validateContentType, validateFileId, validateSize, validateStream, resolveConfiguredMaxFileSize } from '~wildo-backend-lib/files/utils/file-validation.utils';\nimport { resolveStorageApplicationIdentity } from '~wildo-backend-lib/files/utils/storage-application-identity.backend.utils';\nimport {\n composeApplicationStorageKey,\n composeStorageLeafPath,\n storageKeyHasTraversalSegment,\n} from './application-storage-key.backend.utils';\nimport type {\n IFileStorageProvider,\n StorageUploadResult,\n StorageUploadOptions,\n StorageDownloadResult,\n StorageFileMetadata,\n StorageProviderHealthResult,\n StoredFileStorageTarget,\n} from './file-storage-provider.types';\n\nconst METADATA_SUFFIX = '.meta.json';\n\ninterface LocalFileMetadataRecord {\n contentType: string;\n size: number;\n createdAt: string;\n}\n\n@injectable()\nexport class LocalDirectoryStorageProvider implements IFileStorageProvider {\n readonly providerId = FileStorageAccepted.LOCAL_DIRECTORY;\n private baseDir: string | null = null;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger)\n private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService)\n private readonly errorBuilder: ErrorBuilderBackendService,\n @inject(SAAS_SERVICE_TYPES.AppConfigService)\n private readonly appConfigService: AppConfigurationService,\n ) {}\n\n /**\n * Reading configuration here can throw `app_configuration_not_initialized`,\n * and that is left unsoftened on purpose: answering `false` for \"configuration\n * is not loaded yet\" is indistinguishable from \"this application has no local\n * storage\", and the router would SKIP the provider in silence.\n */\n isConfigured(): boolean {\n return !!this.configuredBaseDir;\n }\n\n /** The authored filesystem root, or `undefined` when local storage is not configured. */\n private get configuredBaseDir(): string | undefined {\n return this.appConfigService.config.storage?.localDirectory?.baseDir;\n }\n\n async initialize(): Promise<void> {\n const rawDir = this.configuredBaseDir;\n if (!rawDir) {\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message: 'storage.localDirectory.baseDir (from STORAGE_LOCAL_BASE_DIR) is required for local directory storage',\n },\n }\n );\n }\n\n const resolved = path.resolve(rawDir);\n await fs.promises.mkdir(resolved, { recursive: true });\n this.baseDir = resolved;\n }\n\n async healthCheck(): Promise<StorageProviderHealthResult> {\n const startTime = Date.now();\n\n if (!this.baseDir) {\n return { healthy: false, latency: Date.now() - startTime, error: 'Local storage not initialized' };\n }\n\n try {\n await fs.promises.access(this.baseDir, fs.constants.R_OK | fs.constants.W_OK);\n return { healthy: true, latency: Date.now() - startTime };\n } catch (error) {\n return {\n healthy: false,\n latency: Date.now() - startTime,\n error: describeCaughtError(error),\n };\n }\n }\n\n private getBaseDir(): string {\n if (!this.baseDir) {\n const raw = this.configuredBaseDir;\n if (!raw) {\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: { message: 'storage.localDirectory.baseDir (from STORAGE_LOCAL_BASE_DIR) is not configured' },\n }\n );\n }\n this.baseDir = path.resolve(raw);\n }\n return this.baseDir;\n }\n\n /**\n * Compose the relative storage key for an upload.\n *\n * Layout — identical to the managed provider's, minus that provider's bucket prefix:\n * `applications/<applicationId>/files/<storageName>/<scope>/<scopeId>/[folderPath/]<fileName|fileId>`\n *\n * `includeApplicationId` defaults to `true` here, as it does on the managed provider. It used to\n * default to `false` (\"the volume is typically per-app\"), which is exactly what left this provider\n * with no tenant structure: a per-app VOLUME separates applications from each other and separates\n * nothing inside one. Set explicitly to `false` the key collapses to the bare leaf path on BOTH\n * providers — one authored value, one meaning, and the same loss of every prefix operation.\n */\n private composeStorageKey(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: StorageUploadOptions,\n ): string {\n const leafPath = composeStorageLeafPath(fileId, options);\n if (!leafPath) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_KEY_COMPOSITION_FAILED,\n }\n );\n }\n\n // Refused on the LEAF, textually, before any prefix is prepended — and this is load-bearing\n // rather than belt-and-braces. `resolveSafePathFromRelative` below asks \"does the resolved path\n // escape the base directory\", which was the whole guard while a key was one or two segments\n // deep. Under the six-segment tenant prefix a `folderPath: '../../outside'` no longer escapes:\n // it resolves to `applications/<app>/files/_unlinked/outside/…`, still inside the base, so the\n // containment check ADMITS what it used to refuse. What the `..` now buys an attacker is not an\n // escape from the store but an escape from the TENANT prefix — the exact property this key\n // shape exists to provide.\n //\n // The managed provider refuses the same input for the mirror-image reason (its stored-ref prefix\n // check is textual), so one authored value cannot mean two things depending on which provider a\n // deployment binds. `assertNoTraversalSegments` there and this share `storageKeyHasTraversalSegment`.\n if (storageKeyHasTraversalSegment(leafPath)) {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_PATH_TRAVERSAL_DETECTED,\n context: {\n relativePath: leafPath, // diagnostic (log-only)\n },\n }\n );\n }\n\n if (options?.includeApplicationId === false) {\n return leafPath;\n }\n\n return composeApplicationStorageKey({\n applicationId: this.getApplicationId(executionContext),\n leafPath,\n linkedResourceType: options?.linkedResourceType,\n scope: options?.scope,\n });\n }\n\n /**\n * Resolve a safe absolute path from a relative storage ref.\n * Throws if the resolved path escapes the base directory (path traversal guard).\n */\n private resolveSafePathFromRelative(relativePath: string): string {\n const base = this.getBaseDir();\n const filePath = path.resolve(base, relativePath);\n if (!filePath.startsWith(base + path.sep) && filePath !== base) {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_PATH_TRAVERSAL_DETECTED,\n context: {\n relativePath, // diagnostic (log-only)\n },\n }\n );\n }\n return filePath;\n }\n\n private getApplicationId(executionContext: ExecutionContext<any>): string {\n const applicationId = resolveStorageApplicationIdentity(this.appConfigService);\n validateAppId(applicationId, this.errorBuilder, executionContext, 'applicationId');\n return applicationId;\n }\n\n async upload(\n fileStream: Readable,\n fileId: string,\n mimeType: string,\n size: number,\n executionContext: ExecutionContext<any>,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult> {\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n validateContentType(mimeType, this.errorBuilder, executionContext, 'mimeType');\n validateSize(\n size,\n resolveConfiguredMaxFileSize(this.appConfigService.config.storage?.maxFileSize),\n this.errorBuilder,\n executionContext,\n 'size',\n );\n validateStream(fileStream, this.errorBuilder, executionContext, 'fileStream');\n\n const relativePath = this.composeStorageKey(fileId, executionContext, options);\n const filePath = this.resolveSafePathFromRelative(relativePath);\n\n await fs.promises.mkdir(path.dirname(filePath), { recursive: true });\n\n try {\n const writeStream = fs.createWriteStream(filePath);\n await pipeline(fileStream, writeStream);\n } catch (error) {\n this.convertStorageError(error, 'upload', executionContext, {\n fileId,\n provider: this.providerId,\n });\n }\n\n const metadataRecord: LocalFileMetadataRecord = {\n contentType: mimeType,\n size,\n createdAt: new Date().toISOString(),\n };\n await fs.promises.writeFile(filePath + METADATA_SUFFIX, JSON.stringify(metadataRecord), 'utf-8');\n\n return { storageRef: relativePath, provider: this.providerId };\n }\n\n async download(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): Promise<StorageDownloadResult> {\n const filePath = this.resolvePathFromStorageRef(file, executionContext);\n\n try {\n await fs.promises.access(filePath, fs.constants.R_OK);\n } catch {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,\n context: {\n // diagnostic (log-only)\n fileId: file.fileId,\n provider: this.providerId,\n },\n }\n );\n }\n\n const metadata = await this.readLocalMetadata(filePath, file.fileId, executionContext);\n const stat = await fs.promises.stat(filePath);\n const stream = fs.createReadStream(filePath);\n\n return {\n stream,\n contentType: metadata.contentType,\n size: stat.size,\n lastModified: stat.mtime,\n };\n }\n\n async delete(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): Promise<void> {\n const filePath = this.resolvePathFromStorageRef(file, executionContext);\n\n try {\n await fs.promises.unlink(filePath);\n } catch (error: any) {\n if (error.code === 'ENOENT') return;\n this.convertStorageError(error, 'delete', executionContext, {\n fileId: file.fileId,\n provider: this.providerId,\n });\n }\n\n try {\n await fs.promises.unlink(filePath + METADATA_SUFFIX);\n } catch {\n // metadata file already gone — fine\n }\n }\n\n async getMetadata(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): Promise<StorageFileMetadata> {\n const filePath = this.resolvePathFromStorageRef(file, executionContext);\n\n try {\n await fs.promises.access(filePath, fs.constants.R_OK);\n } catch {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,\n context: {\n // diagnostic (log-only)\n fileId: file.fileId,\n provider: this.providerId,\n },\n }\n );\n }\n\n const metadata = await this.readLocalMetadata(filePath, file.fileId, executionContext);\n const stat = await fs.promises.stat(filePath);\n\n return {\n contentType: metadata.contentType,\n size: stat.size,\n lastModified: stat.mtime,\n };\n }\n\n /**\n * Resolve the absolute filesystem path from a persisted storageRef.\n * The ref IS the relative path from baseDir — just validate traversal.\n *\n * ## Already-stored files are NOT moved by the key-shape change, and nothing has to be migrated\n *\n * Every read verb (`download` / `delete` / `getMetadata`) reaches a blob through this method, and\n * with a ref present it uses that ref VERBATIM. A blob written under the old\n * `[applicationId]/[folderPath]/<leaf>` layout therefore stays addressable at exactly the path it\n * was written to: the shape change governs where NEW uploads land, never how an existing row is\n * resolved. No migration, and no compatibility branch, because there is nothing to be compatible\n * with — the persisted ref is the address.\n *\n * ## The no-ref branch is LIVE, and it must track `upload` rather than freeze\n *\n * It looks like a legacy fallback for rows whose `storageRef` never committed. Its real caller is\n * the audit-log archive batch: `archiveArtifactExists` probes `getMetadata` with\n * `fileId: '<folderPath>/<fileName>'` and NO ref, deliberately, so that each provider re-derives\n * the key its own `upload` produced and the batch never re-implements provider path logic. Pin\n * the old composition here and that probe would address a blob the upload no longer writes, so\n * `archiveArtifactExists` would answer `false` forever and every past day would be re-archived on\n * every tick — a silent, unbounded regression with no failing test anywhere.\n *\n * So it composes through the SAME composer, with no resource type and no scope, mirroring the\n * managed provider's `resolveApplicationObjectKey(file.fileId, ctx, undefined)` argument for\n * argument. The parity is pinned in this provider's test suite (`upload` then `getMetadata` with\n * no ref); the batch's own suite uses a fake provider and cannot see it.\n *\n * ## Residual, recorded rather than fixed: a `.`/`..` segment inside a PRESENT ref\n *\n * `composeStorageKey` refuses one on the composition path; this branch does not, and the managed\n * provider's `assertNoTraversalSegments(normalizedStorageRef, …)` does. Two reasons it is left\n * asymmetric, and neither is \"nobody thought about it\":\n *\n * - the containment check below is a real `path.resolve`, not managed's textual `startsWith`, so\n * the class of attack that motivated managed's stored-ref check (a ref that satisfies a textual\n * prefix while pointing elsewhere) is already caught here for anything leaving the base;\n * - a `.` ref legitimately addresses the base directory and is pinned as NOT an authorization\n * refusal (`ADMITS the base directory itself`), which a whole-segment textual check would break.\n *\n * What survives is a ref whose text climbs out of one tenant prefix into another WITHIN the base.\n * Reaching it needs write access to the `storageRef` column — the composition path can no longer\n * produce one — so it is a smaller surface than the one closed above, not the same one. Closing it\n * means deciding what `.` should mean first, which is a separate change.\n */\n private resolvePathFromStorageRef(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): string {\n const ref = file.storageRef;\n if (!ref) {\n return this.resolveSafePathFromRelative(this.composeStorageKey(file.fileId, executionContext));\n }\n return this.resolveSafePathFromRelative(ref);\n }\n\n private async readLocalMetadata(\n filePath: string,\n fileId: string,\n executionContext: ExecutionContext<any>,\n ): Promise<LocalFileMetadataRecord> {\n const metaPath = filePath + METADATA_SUFFIX;\n try {\n const raw = await fs.promises.readFile(metaPath, 'utf-8');\n return JSON.parse(raw) as LocalFileMetadataRecord;\n } catch {\n return {\n contentType: 'application/octet-stream',\n size: 0,\n createdAt: new Date().toISOString(),\n };\n }\n }\n\n private convertStorageError(\n error: unknown,\n operation: 'upload' | 'download' | 'delete' | 'metadata',\n executionContext: ExecutionContext<any> | undefined,\n context: Record<string, unknown>,\n ): never {\n if (isWildoBackendError(error)) {\n throw error;\n }\n\n const errorMessage = describeCaughtError(error);\n const errorCode = (error as any)?.code;\n\n if (errorCode === 'ENOENT') {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,\n context: { operation, ...context }, // diagnostic (log-only)\n }\n );\n }\n\n if (errorCode === 'EACCES' || errorCode === 'EPERM') {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,\n context: { operation, ...context, originalError: errorMessage }, // diagnostic (log-only)\n }\n );\n }\n\n if (errorCode === 'ENOSPC') {\n throw this.errorBuilder.buildError(\n ErrorType.EXTERNAL_SERVICE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: 'Local storage disk full', operation, ...context, originalError: errorMessage },\n }\n );\n }\n\n throw this.errorBuilder.buildError(\n ErrorType.EXTERNAL_SERVICE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: `Local storage operation failed: ${operation}`, operation, ...context, originalError: errorMessage },\n }\n );\n }\n}\n"]}
1
+ {"version":3,"file":"local-directory-storage-provider.backend.service.js","sourceRoot":"","sources":["../../../../src/files/storage/local-directory-storage-provider.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAA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AO,EAAE,EAAE,OAAO,EAAE,mCAAmC,SAAS,EAAE,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE;SACzH,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1bY,6BAA6B;IADzC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAEjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAE9C,WAAA,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;+CADb,0BAA0B;QAEtB,uBAAuB;GAVjD,6BAA6B,CA0bzC","sourcesContent":["/**\n * Local Directory Storage Provider\n *\n * IFileStorageProvider implementation backed by the local filesystem.\n * Files are stored under a configurable base directory, at the SAME relative key the\n * Wildo-managed provider would use — `applications/<appId>/files/<storageName>/<scope>/<scopeId>/…`,\n * composed by `application-storage-key.backend.utils`. Path traversal attacks are guarded against\n * by refusing a `.`/`..` segment in the composed key AND by resolving every path and verifying it\n * stays inside the base dir.\n *\n * ## Why the key shape is shared rather than provider-local\n *\n * Until 2026-09-09 this provider composed `[applicationId]/[folderPath]/<leaf>` from the field's\n * declarative binding alone, and included the application id only when the binding asked\n * (`includeApplicationId`, defaulting to `false` here). It therefore emitted NONE of the\n * `<scope>/<scopeId>` segments the managed provider's shape carries, so a deployment routing a\n * `z_file()` field to local storage had no per-tenant prefix to sweep, list or confine against —\n * and nothing failed, because an absent prefix produces no error, only an absent capability.\n *\n * Both providers now call one composer. See `application-storage-key.backend.utils.ts` for the\n * argument and for what deliberately stays provider-local.\n *\n * Configured through `storage.localDirectory.baseDir` in resolved application\n * configuration, which the configuration loader seeds from the\n * `STORAGE_LOCAL_BASE_DIR` environment variable. The provider itself reads\n * configuration, never the environment — see\n * `.claude/plans/application-runtime-topology-delivery.md`.\n */\n\nimport { injectable, inject } from 'inversify';\nimport { Readable } from 'stream';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { pipeline } from 'stream/promises';\nimport { ErrorType, ErrorCustomMessageReference, isWildoBackendError } from '@wildo-ai/saas-models';\nimport { FileStorageAccepted } from '@wildo-ai/zod-decorators';\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 { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\nimport { describeCaughtError } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { AppConfigurationService } from '~wildo-backend-lib/config/services/app-configuration.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport { validateAppId, validateContentType, validateFileId, validateSize, validateStream, resolveConfiguredMaxFileSize } from '~wildo-backend-lib/files/utils/file-validation.utils';\nimport { resolveStorageApplicationIdentity } from '~wildo-backend-lib/files/utils/storage-application-identity.backend.utils';\nimport {\n composeApplicationStorageKey,\n composeStorageLeafPath,\n storageKeyHasTraversalSegment,\n} from './application-storage-key.backend.utils';\nimport type {\n IFileStorageProvider,\n StorageUploadResult,\n StorageUploadOptions,\n StorageDownloadResult,\n StorageFileMetadata,\n StorageProviderHealthResult,\n StoredFileStorageTarget,\n} from './file-storage-provider.types';\n\nconst METADATA_SUFFIX = '.meta.json';\n\ninterface LocalFileMetadataRecord {\n contentType: string;\n size: number;\n createdAt: string;\n}\n\n@injectable()\nexport class LocalDirectoryStorageProvider implements IFileStorageProvider {\n readonly providerId = FileStorageAccepted.LOCAL_DIRECTORY;\n private baseDir: string | null = null;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger)\n private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService)\n private readonly errorBuilder: ErrorBuilderBackendService,\n @inject(SAAS_SERVICE_TYPES.AppConfigService)\n private readonly appConfigService: AppConfigurationService,\n ) {}\n\n /**\n * Reading configuration here can throw `app_configuration_not_initialized`,\n * and that is left unsoftened on purpose: answering `false` for \"configuration\n * is not loaded yet\" is indistinguishable from \"this application has no local\n * storage\", and the router would SKIP the provider in silence.\n */\n isConfigured(): boolean {\n return !!this.configuredBaseDir;\n }\n\n /** The authored filesystem root, or `undefined` when local storage is not configured. */\n private get configuredBaseDir(): string | undefined {\n return this.appConfigService.config.storage?.localDirectory?.baseDir;\n }\n\n async initialize(): Promise<void> {\n const rawDir = this.configuredBaseDir;\n if (!rawDir) {\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message: 'storage.localDirectory.baseDir (from STORAGE_LOCAL_BASE_DIR) is required for local directory storage',\n },\n }\n );\n }\n\n const resolved = path.resolve(rawDir);\n await fs.promises.mkdir(resolved, { recursive: true });\n this.baseDir = resolved;\n }\n\n async healthCheck(): Promise<StorageProviderHealthResult> {\n const startTime = Date.now();\n\n if (!this.baseDir) {\n return { healthy: false, latency: Date.now() - startTime, error: 'Local storage not initialized' };\n }\n\n try {\n await fs.promises.access(this.baseDir, fs.constants.R_OK | fs.constants.W_OK);\n return { healthy: true, latency: Date.now() - startTime };\n } catch (error) {\n return {\n healthy: false,\n latency: Date.now() - startTime,\n error: describeCaughtError(error),\n };\n }\n }\n\n private getBaseDir(): string {\n if (!this.baseDir) {\n const raw = this.configuredBaseDir;\n if (!raw) {\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: { message: 'storage.localDirectory.baseDir (from STORAGE_LOCAL_BASE_DIR) is not configured' },\n }\n );\n }\n this.baseDir = path.resolve(raw);\n }\n return this.baseDir;\n }\n\n /**\n * Compose the relative storage key for an upload.\n *\n * Layout — identical to the managed provider's, minus that provider's bucket prefix:\n * `applications/<applicationId>/files/<storageName>/<scope>/<scopeId>/[folderPath/]<fileName|fileId>`\n *\n * `includeApplicationId` defaults to `true` here, as it does on the managed provider. It used to\n * default to `false` (\"the volume is typically per-app\"), which is exactly what left this provider\n * with no tenant structure: a per-app VOLUME separates applications from each other and separates\n * nothing inside one. Set explicitly to `false` the key collapses to the bare leaf path on BOTH\n * providers — one authored value, one meaning, and the same loss of every prefix operation.\n */\n private composeStorageKey(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: StorageUploadOptions,\n ): string {\n const leafPath = composeStorageLeafPath(fileId, options);\n if (!leafPath) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_KEY_COMPOSITION_FAILED,\n }\n );\n }\n\n // Refused on the LEAF, textually, before any prefix is prepended — and this is load-bearing\n // rather than belt-and-braces. `resolveSafePathFromRelative` below asks \"does the resolved path\n // escape the base directory\", which was the whole guard while a key was one or two segments\n // deep. Under the six-segment tenant prefix a `folderPath: '../../outside'` no longer escapes:\n // it resolves to `applications/<app>/files/_unlinked/outside/…`, still inside the base, so the\n // containment check ADMITS what it used to refuse. What the `..` now buys an attacker is not an\n // escape from the store but an escape from the TENANT prefix — the exact property this key\n // shape exists to provide.\n //\n // The managed provider refuses the same input for the mirror-image reason (its stored-ref prefix\n // check is textual), so one authored value cannot mean two things depending on which provider a\n // deployment binds. `assertNoTraversalSegments` there and this share `storageKeyHasTraversalSegment`.\n if (storageKeyHasTraversalSegment(leafPath)) {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_PATH_TRAVERSAL_DETECTED,\n context: {\n relativePath: leafPath, // diagnostic (log-only)\n },\n }\n );\n }\n\n if (options?.includeApplicationId === false) {\n return leafPath;\n }\n\n return composeApplicationStorageKey({\n applicationId: this.getApplicationId(executionContext),\n leafPath,\n linkedResourceType: options?.linkedResourceType,\n scope: options?.scope,\n });\n }\n\n /**\n * Resolve a safe absolute path from a relative storage ref.\n * Throws if the resolved path escapes the base directory (path traversal guard).\n */\n private resolveSafePathFromRelative(relativePath: string): string {\n const base = this.getBaseDir();\n const filePath = path.resolve(base, relativePath);\n if (!filePath.startsWith(base + path.sep) && filePath !== base) {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n undefined,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_PATH_TRAVERSAL_DETECTED,\n context: {\n relativePath, // diagnostic (log-only)\n },\n }\n );\n }\n return filePath;\n }\n\n private getApplicationId(executionContext: ExecutionContext<any>): string {\n const applicationId = resolveStorageApplicationIdentity(this.appConfigService);\n validateAppId(applicationId, this.errorBuilder, executionContext, 'applicationId');\n return applicationId;\n }\n\n async upload(\n fileStream: Readable,\n fileId: string,\n mimeType: string,\n size: number,\n executionContext: ExecutionContext<any>,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult> {\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n validateContentType(mimeType, this.errorBuilder, executionContext, 'mimeType');\n validateSize(\n size,\n resolveConfiguredMaxFileSize(this.appConfigService.config.storage?.maxFileSize),\n this.errorBuilder,\n executionContext,\n 'size',\n );\n validateStream(fileStream, this.errorBuilder, executionContext, 'fileStream');\n\n const relativePath = this.composeStorageKey(fileId, executionContext, options);\n const filePath = this.resolveSafePathFromRelative(relativePath);\n\n await fs.promises.mkdir(path.dirname(filePath), { recursive: true });\n\n try {\n const writeStream = fs.createWriteStream(filePath);\n await pipeline(fileStream, writeStream);\n } catch (error) {\n this.convertStorageError(error, 'upload', executionContext, {\n fileId,\n provider: this.providerId,\n });\n }\n\n const metadataRecord: LocalFileMetadataRecord = {\n contentType: mimeType,\n size,\n createdAt: new Date().toISOString(),\n };\n await fs.promises.writeFile(filePath + METADATA_SUFFIX, JSON.stringify(metadataRecord), 'utf-8');\n\n return { storageRef: relativePath, provider: this.providerId };\n }\n\n async download(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): Promise<StorageDownloadResult> {\n const filePath = this.resolvePathFromStorageRef(file, executionContext);\n\n try {\n await fs.promises.access(filePath, fs.constants.R_OK);\n } catch {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,\n context: {\n // diagnostic (log-only)\n fileId: file.fileId,\n provider: this.providerId,\n },\n }\n );\n }\n\n const metadata = await this.readLocalMetadata(filePath, file.fileId, executionContext);\n const stat = await fs.promises.stat(filePath);\n const stream = fs.createReadStream(filePath);\n\n return {\n stream,\n contentType: metadata.contentType,\n size: stat.size,\n lastModified: stat.mtime,\n };\n }\n\n async delete(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): Promise<void> {\n const filePath = this.resolvePathFromStorageRef(file, executionContext);\n\n try {\n await fs.promises.unlink(filePath);\n } catch (error: any) {\n if (error.code === 'ENOENT') return;\n this.convertStorageError(error, 'delete', executionContext, {\n fileId: file.fileId,\n provider: this.providerId,\n });\n }\n\n try {\n await fs.promises.unlink(filePath + METADATA_SUFFIX);\n } catch {\n // metadata file already gone — fine\n }\n }\n\n async getMetadata(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): Promise<StorageFileMetadata> {\n const filePath = this.resolvePathFromStorageRef(file, executionContext);\n\n try {\n await fs.promises.access(filePath, fs.constants.R_OK);\n } catch {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,\n context: {\n // diagnostic (log-only)\n fileId: file.fileId,\n provider: this.providerId,\n },\n }\n );\n }\n\n const metadata = await this.readLocalMetadata(filePath, file.fileId, executionContext);\n const stat = await fs.promises.stat(filePath);\n\n return {\n contentType: metadata.contentType,\n size: stat.size,\n lastModified: stat.mtime,\n };\n }\n\n /**\n * Resolve the absolute filesystem path from a persisted storageRef.\n * The ref IS the relative path from baseDir — just validate traversal.\n *\n * ## Already-stored files are NOT moved by the key-shape change, and nothing has to be migrated\n *\n * Every read verb (`download` / `delete` / `getMetadata`) reaches a blob through this method, and\n * with a ref present it uses that ref VERBATIM. A blob written under the old\n * `[applicationId]/[folderPath]/<leaf>` layout therefore stays addressable at exactly the path it\n * was written to: the shape change governs where NEW uploads land, never how an existing row is\n * resolved. No migration, and no compatibility branch, because there is nothing to be compatible\n * with — the persisted ref is the address.\n *\n * ## The no-ref branch is LIVE, and it must track `upload` rather than freeze\n *\n * It looks like a legacy fallback for rows whose `storageRef` never committed. Its real caller is\n * the audit-log archive batch: `archiveArtifactExists` probes `getMetadata` with\n * `fileId: '<folderPath>/<fileName>'` and NO ref, deliberately, so that each provider re-derives\n * the key its own `upload` produced and the batch never re-implements provider path logic. Pin\n * the old composition here and that probe would address a blob the upload no longer writes, so\n * `archiveArtifactExists` would answer `false` forever and every past day would be re-archived on\n * every tick — a silent, unbounded regression with no failing test anywhere.\n *\n * So it composes through the SAME composer, with no resource type and no scope, mirroring the\n * managed provider's `resolveApplicationObjectKey(file.fileId, ctx, undefined)` argument for\n * argument. The parity is pinned in this provider's test suite (`upload` then `getMetadata` with\n * no ref); the batch's own suite uses a fake provider and cannot see it.\n *\n * ## Residual, recorded rather than fixed: a `.`/`..` segment inside a PRESENT ref\n *\n * `composeStorageKey` refuses one on the composition path; this branch does not, and the managed\n * provider's `assertNoTraversalSegments(normalizedStorageRef, …)` does. Two reasons it is left\n * asymmetric, and neither is \"nobody thought about it\":\n *\n * - the containment check below is a real `path.resolve`, not managed's textual `startsWith`, so\n * the class of attack that motivated managed's stored-ref check (a ref that satisfies a textual\n * prefix while pointing elsewhere) is already caught here for anything leaving the base;\n * - a `.` ref legitimately addresses the base directory and is pinned as NOT an authorization\n * refusal (`ADMITS the base directory itself`), which a whole-segment textual check would break.\n *\n * What survives is a ref whose text climbs out of one tenant prefix into another WITHIN the base.\n * Reaching it needs write access to the `storageRef` column — the composition path can no longer\n * produce one — so it is a smaller surface than the one closed above, not the same one. Closing it\n * means deciding what `.` should mean first, which is a separate change.\n */\n private resolvePathFromStorageRef(\n file: StoredFileStorageTarget,\n executionContext: ExecutionContext<any>,\n ): string {\n const ref = file.storageRef;\n if (!ref) {\n return this.resolveSafePathFromRelative(this.composeStorageKey(file.fileId, executionContext));\n }\n return this.resolveSafePathFromRelative(ref);\n }\n\n private async readLocalMetadata(\n filePath: string,\n fileId: string,\n executionContext: ExecutionContext<any>,\n ): Promise<LocalFileMetadataRecord> {\n const metaPath = filePath + METADATA_SUFFIX;\n try {\n const raw = await fs.promises.readFile(metaPath, 'utf-8');\n return JSON.parse(raw) as LocalFileMetadataRecord;\n } catch {\n return {\n contentType: 'application/octet-stream',\n size: 0,\n createdAt: new Date().toISOString(),\n };\n }\n }\n\n private convertStorageError(\n error: unknown,\n operation: 'upload' | 'download' | 'delete' | 'metadata',\n executionContext: ExecutionContext<any> | undefined,\n context: Record<string, unknown>,\n ): never {\n if (isWildoBackendError(error)) {\n throw error;\n }\n\n const errorMessage = describeCaughtError(error);\n const errorCode = (error as any)?.code;\n\n if (errorCode === 'ENOENT') {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND_IN_STORAGE,\n context: { operation, ...context }, // diagnostic (log-only)\n }\n );\n }\n\n if (errorCode === 'EACCES' || errorCode === 'EPERM') {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_STORAGE_ACCESS_DENIED,\n context: { operation, ...context, originalError: errorMessage }, // diagnostic (log-only)\n }\n );\n }\n\n if (errorCode === 'ENOSPC') {\n throw this.errorBuilder.buildError(\n ErrorType.EXTERNAL_SERVICE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: 'Local storage disk full', operation, ...context, originalError: errorMessage },\n }\n );\n }\n\n throw this.errorBuilder.buildError(\n ErrorType.EXTERNAL_SERVICE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.EXTERNAL_SERVICE,\n context: { message: `Local storage operation failed: ${operation}`, operation, ...context, originalError: errorMessage },\n }\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-credential-provider.backend.utils.d.ts","sourceRoot":"","sources":["../../../../../src/files/storage/storage-credential-provider.backend.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAUlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,yBAAyB;IAKlC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,GAAG;IANtB,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,QAAQ,CAAoD;gBAGjD,OAAO,EAAE,yBAAyB;IACnD,mEAAmE;IAClD,GAAG,GAAE,MAAM,MAAyB;IAGvD;;OAEG;IACU,cAAc,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAyBlE;;;;;OAKG;IACI,oBAAoB,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO;IAI3E,sFAAsF;IAC/E,UAAU,IAAI,IAAI;IAIzB,OAAO,CAAC,eAAe;CAYxB"}
1
+ {"version":3,"file":"storage-credential-provider.backend.utils.d.ts","sourceRoot":"","sources":["../../../../src/files/storage/storage-credential-provider.backend.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAUlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,yBAAyB;IAKlC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,GAAG;IANtB,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,QAAQ,CAAoD;gBAGjD,OAAO,EAAE,yBAAyB;IACnD,mEAAmE;IAClD,GAAG,GAAE,MAAM,MAAyB;IAGvD;;OAEG;IACU,cAAc,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAyBlE;;;;;OAKG;IACI,oBAAoB,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO;IAI3E,sFAAsF;IAC/E,UAAU,IAAI,IAAI;IAIzB,OAAO,CAAC,eAAe;CAYxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-platform-sts-credential-resolver.backend.utils.d.ts","sourceRoot":"","sources":["../../../../../src/files/storage/storage-platform-sts-credential-resolver.backend.utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA8B,yBAAyB,EAAE,MAAM,4EAA4E,CAAC;AAExJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iDAAiD,IAAI,yBAAyB,CA2B7F"}
1
+ {"version":3,"file":"storage-platform-sts-credential-resolver.backend.utils.d.ts","sourceRoot":"","sources":["../../../../src/files/storage/storage-platform-sts-credential-resolver.backend.utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA8B,yBAAyB,EAAE,MAAM,4EAA4E,CAAC;AAExJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iDAAiD,IAAI,yBAAyB,CA2B7F"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-sts-credential-resolver.backend.utils.d.ts","sourceRoot":"","sources":["../../../../../src/files/storage/storage-sts-credential-resolver.backend.utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,4EAA4E,CAAC;AAsGxJ;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAChD,oBAAoB,EAAE,MAAM,MAAM,GACjC,yBAAyB,CAiE3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,GAAG,OAAO,CAAC,OAAO,CAAC,CA+CnB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,0BAA0B,CAkCtF"}
1
+ {"version":3,"file":"storage-sts-credential-resolver.backend.utils.d.ts","sourceRoot":"","sources":["../../../../src/files/storage/storage-sts-credential-resolver.backend.utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,4EAA4E,CAAC;AAsGxJ;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAChD,oBAAoB,EAAE,MAAM,MAAM,GACjC,yBAAyB,CAiE3B;AAYD;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,GAAG,OAAO,CAAC,OAAO,CAAC,CA6CnB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,0BAA0B,CAkCtF"}