@wildo-ai/saas-backend-lib 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/applications/services/worker-remote-client-factory.backend.service.d.ts.map +1 -1
- package/dist/esm/applications/services/worker-remote-client-factory.backend.service.js +19 -1
- package/dist/esm/applications/services/worker-remote-client-factory.backend.service.js.map +1 -1
- package/dist/esm/base-classes/models/manual-controllers.backend.definition.d.ts.map +1 -1
- package/dist/esm/base-classes/models/manual-controllers.backend.definition.js +4 -0
- package/dist/esm/base-classes/models/manual-controllers.backend.definition.js.map +1 -1
- package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.d.ts +35 -0
- package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.d.ts.map +1 -0
- package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.js +111 -0
- package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.js.map +1 -0
- package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.d.ts +50 -0
- package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.d.ts.map +1 -0
- package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js +199 -0
- package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js.map +1 -0
- package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.d.ts +111 -0
- package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.d.ts.map +1 -1
- package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.js +140 -0
- package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.js.map +1 -1
- package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.d.ts +14 -3
- package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.js +138 -24
- package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.d.ts +3 -1
- package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.js +8 -3
- package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.d.ts +11 -0
- package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.js +11 -2
- package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.d.ts +124 -13
- package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js +207 -21
- package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.d.ts +60 -8
- package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js +174 -26
- package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.d.ts +48 -4
- package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.js +102 -30
- package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.d.ts +55 -0
- package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.d.ts.map +1 -0
- package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.js +114 -0
- package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.js.map +1 -0
- package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.d.ts +89 -14
- package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.js +84 -11
- package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.js +16 -0
- package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.d.ts +20 -6
- package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.js +96 -32
- package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.d.ts +3 -1
- package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.js +32 -7
- package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.d.ts +8 -5
- package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts +80 -0
- package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js +298 -23
- package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.d.ts +71 -1
- package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.js +85 -5
- package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts +21 -0
- package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js +146 -4
- package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.d.ts +22 -0
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.d.ts +3 -26
- package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.js +3 -68
- package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js +4 -1
- package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.d.ts +11 -0
- package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.js +39 -5
- package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.js.map +1 -1
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts +181 -2
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js +533 -43
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/services/system-access.backend.service.d.ts +36 -3
- package/dist/esm/base-classes/services/services/system-access.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/system-access.backend.service.js +70 -8
- package/dist/esm/base-classes/services/services/system-access.backend.service.js.map +1 -1
- package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.d.ts +28 -0
- package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.d.ts.map +1 -0
- package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.js +90 -0
- package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.js.map +1 -0
- package/dist/esm/billing/batches/usage-flush.batch.backend.service.d.ts +44 -0
- package/dist/esm/billing/batches/usage-flush.batch.backend.service.d.ts.map +1 -0
- package/dist/esm/billing/batches/usage-flush.batch.backend.service.js +99 -0
- package/dist/esm/billing/batches/usage-flush.batch.backend.service.js.map +1 -0
- package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.d.ts +91 -0
- package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.d.ts.map +1 -0
- package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.js +152 -0
- package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.js.map +1 -0
- package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts +186 -0
- package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts.map +1 -0
- package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js +474 -0
- package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js.map +1 -0
- package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.d.ts +100 -0
- package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.d.ts.map +1 -1
- package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.js +209 -6
- package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.js.map +1 -1
- package/dist/esm/billing/services/back-office/usage-metering.backend.service.d.ts +200 -4
- package/dist/esm/billing/services/back-office/usage-metering.backend.service.d.ts.map +1 -1
- package/dist/esm/billing/services/back-office/usage-metering.backend.service.js +593 -64
- package/dist/esm/billing/services/back-office/usage-metering.backend.service.js.map +1 -1
- package/dist/esm/billing/services/billing-adapter-registry.backend.d.ts +36 -0
- package/dist/esm/billing/services/billing-adapter-registry.backend.d.ts.map +1 -0
- package/dist/esm/billing/services/billing-adapter-registry.backend.js +83 -0
- package/dist/esm/billing/services/billing-adapter-registry.backend.js.map +1 -0
- package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.d.ts +9 -0
- package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.d.ts.map +1 -1
- package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.js +11 -1
- package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.js.map +1 -1
- package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.js +54 -13
- package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts +38 -1
- package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts.map +1 -1
- package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js +67 -2
- package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js.map +1 -1
- package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.d.ts +30 -1
- package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.d.ts.map +1 -1
- package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.js +43 -1
- package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.js.map +1 -1
- package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.d.ts +11 -3
- package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.js +30 -16
- package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.js +104 -25
- package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts +18 -1
- package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts.map +1 -1
- package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js +106 -2
- package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js.map +1 -1
- package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.d.ts +52 -0
- package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.d.ts.map +1 -0
- package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.js +74 -0
- package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.js.map +1 -0
- package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.d.ts +104 -11
- package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.d.ts.map +1 -1
- package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js +260 -26
- package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js.map +1 -1
- package/dist/esm/billing/testing/mock-billing-provider.d.ts +30 -1
- package/dist/esm/billing/testing/mock-billing-provider.d.ts.map +1 -1
- package/dist/esm/billing/testing/mock-billing-provider.js +25 -0
- package/dist/esm/billing/testing/mock-billing-provider.js.map +1 -1
- package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.js +11 -4
- package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.js.map +1 -1
- package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.d.ts +263 -13
- package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.js +376 -58
- package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.js.map +1 -1
- package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts +264 -7
- package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js +414 -5
- package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js.map +1 -1
- package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.js +7 -1
- package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.js.map +1 -1
- package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.d.ts +16 -0
- package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.d.ts.map +1 -0
- package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.js +140 -0
- package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.js.map +1 -0
- package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.d.ts +42 -0
- package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.js +65 -6
- package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.js.map +1 -1
- package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.d.ts +110 -0
- package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.d.ts.map +1 -0
- package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.js +192 -0
- package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.js.map +1 -0
- package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js +45 -0
- package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js.map +1 -1
- package/dist/esm/config/bootstrap/application-runtime-profile.backend.d.ts +5 -0
- package/dist/esm/config/bootstrap/application-runtime-profile.backend.d.ts.map +1 -1
- package/dist/esm/config/bootstrap/application-runtime-profile.backend.js +6 -0
- package/dist/esm/config/bootstrap/application-runtime-profile.backend.js.map +1 -1
- package/dist/esm/config/custom/application-config-controller.backend.service.d.ts.map +1 -1
- package/dist/esm/config/custom/application-config-controller.backend.service.js +7 -1
- package/dist/esm/config/custom/application-config-controller.backend.service.js.map +1 -1
- package/dist/esm/config/models/app-config.backend.schemas.d.ts +146 -46
- package/dist/esm/config/models/app-config.backend.schemas.d.ts.map +1 -1
- package/dist/esm/config/models/app-config.backend.schemas.js +121 -12
- package/dist/esm/config/models/app-config.backend.schemas.js.map +1 -1
- package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.d.ts +38 -15
- package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.d.ts.map +1 -1
- package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.js +17 -2
- package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.js.map +1 -1
- package/dist/esm/config/services/app-configuration-loader.backend.service.d.ts +0 -1
- package/dist/esm/config/services/app-configuration-loader.backend.service.d.ts.map +1 -1
- package/dist/esm/config/services/app-configuration-loader.backend.service.js +68 -76
- package/dist/esm/config/services/app-configuration-loader.backend.service.js.map +1 -1
- package/dist/esm/config/services/app-configuration.backend.service.d.ts.map +1 -1
- package/dist/esm/config/services/app-configuration.backend.service.js +23 -1
- package/dist/esm/config/services/app-configuration.backend.service.js.map +1 -1
- package/dist/esm/config/services/app-configuration.backend.utils.d.ts +43 -1
- package/dist/esm/config/services/app-configuration.backend.utils.d.ts.map +1 -1
- package/dist/esm/config/services/app-configuration.backend.utils.js +52 -3
- package/dist/esm/config/services/app-configuration.backend.utils.js.map +1 -1
- package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts +25 -0
- package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts.map +1 -1
- package/dist/esm/config/services/application-startup-config-validator.backend.service.js +41 -1
- package/dist/esm/config/services/application-startup-config-validator.backend.service.js.map +1 -1
- package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.d.ts +2 -2
- package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.js +2 -2
- package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.js.map +1 -1
- package/dist/esm/databases/models/filter.backend.schemas.js +2 -2
- package/dist/esm/databases/models/filter.backend.schemas.js.map +1 -1
- package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.d.ts.map +1 -1
- package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.js +20 -1
- package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.js.map +1 -1
- package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.d.ts.map +1 -1
- package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.js +48 -0
- package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.js.map +1 -1
- package/dist/esm/databases/services/redis.service.d.ts +27 -0
- package/dist/esm/databases/services/redis.service.d.ts.map +1 -1
- package/dist/esm/databases/services/redis.service.js +29 -0
- package/dist/esm/databases/services/redis.service.js.map +1 -1
- package/dist/esm/errors/services/error-builder.backend.service.d.ts +13 -1
- package/dist/esm/errors/services/error-builder.backend.service.d.ts.map +1 -1
- package/dist/esm/errors/services/error-builder.backend.service.js +13 -1
- package/dist/esm/errors/services/error-builder.backend.service.js.map +1 -1
- package/dist/esm/errors/services/error-handler.backend.service.d.ts +70 -7
- package/dist/esm/errors/services/error-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/errors/services/error-handler.backend.service.js +134 -8
- package/dist/esm/errors/services/error-handler.backend.service.js.map +1 -1
- package/dist/esm/errors/services/rate-limit.backend.service.d.ts +66 -0
- package/dist/esm/errors/services/rate-limit.backend.service.d.ts.map +1 -1
- package/dist/esm/errors/services/rate-limit.backend.service.js +102 -25
- package/dist/esm/errors/services/rate-limit.backend.service.js.map +1 -1
- package/dist/esm/errors/utils/error-log-level-classification.backend.utils.d.ts +5 -0
- package/dist/esm/errors/utils/error-log-level-classification.backend.utils.d.ts.map +1 -1
- package/dist/esm/errors/utils/error-log-level-classification.backend.utils.js +25 -0
- package/dist/esm/errors/utils/error-log-level-classification.backend.utils.js.map +1 -1
- package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.d.ts +33 -0
- package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.d.ts.map +1 -1
- package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.js +40 -0
- package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.js.map +1 -1
- package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.d.ts +41 -0
- package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.d.ts.map +1 -0
- package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.js +40 -0
- package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.js.map +1 -0
- package/dist/esm/external-data/controllers/external-data-admin.backend.controller.d.ts +64 -0
- package/dist/esm/external-data/controllers/external-data-admin.backend.controller.d.ts.map +1 -0
- package/dist/esm/external-data/controllers/external-data-admin.backend.controller.js +193 -0
- package/dist/esm/external-data/controllers/external-data-admin.backend.controller.js.map +1 -0
- package/dist/esm/external-data/external-data-pipeline-run.backend.service.d.ts +72 -4
- package/dist/esm/external-data/external-data-pipeline-run.backend.service.d.ts.map +1 -1
- package/dist/esm/external-data/external-data-pipeline-run.backend.service.js +60 -19
- package/dist/esm/external-data/external-data-pipeline-run.backend.service.js.map +1 -1
- package/dist/esm/external-data/external-data-transform.backend.d.ts.map +1 -1
- package/dist/esm/external-data/external-data-transform.backend.js +7 -1
- package/dist/esm/external-data/external-data-transform.backend.js.map +1 -1
- package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.d.ts +2 -0
- package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.d.ts.map +1 -1
- package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.js +13 -0
- package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.js.map +1 -1
- package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.d.ts +4 -2
- package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.d.ts.map +1 -1
- package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.js.map +1 -1
- package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts +256 -0
- package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts.map +1 -0
- package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js +333 -0
- package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js.map +1 -0
- package/dist/esm/external-providers/operations/provider-operation-request.backend.d.ts +56 -0
- package/dist/esm/external-providers/operations/provider-operation-request.backend.d.ts.map +1 -0
- package/dist/esm/external-providers/operations/provider-operation-request.backend.js +211 -0
- package/dist/esm/external-providers/operations/provider-operation-request.backend.js.map +1 -0
- package/dist/esm/external-providers/operations/provider-request-signing.backend.d.ts +45 -0
- package/dist/esm/external-providers/operations/provider-request-signing.backend.d.ts.map +1 -0
- package/dist/esm/external-providers/operations/provider-request-signing.backend.js +216 -0
- package/dist/esm/external-providers/operations/provider-request-signing.backend.js.map +1 -0
- package/dist/esm/external-providers/operations/provider-rest-call-client.backend.d.ts +56 -0
- package/dist/esm/external-providers/operations/provider-rest-call-client.backend.d.ts.map +1 -0
- package/dist/esm/external-providers/operations/provider-rest-call-client.backend.js +78 -0
- package/dist/esm/external-providers/operations/provider-rest-call-client.backend.js.map +1 -0
- package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.d.ts +1 -1
- package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.js +2 -2
- package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.js.map +1 -1
- package/dist/esm/external-providers/services/backend-provider-loader.backend.service.d.ts +89 -0
- package/dist/esm/external-providers/services/backend-provider-loader.backend.service.d.ts.map +1 -0
- package/dist/esm/external-providers/services/backend-provider-loader.backend.service.js +164 -0
- package/dist/esm/external-providers/services/backend-provider-loader.backend.service.js.map +1 -0
- package/dist/esm/external-providers/services/backend-provider-registry.backend.service.d.ts +26 -27
- package/dist/esm/external-providers/services/backend-provider-registry.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/backend-provider-registry.backend.service.js +50 -64
- package/dist/esm/external-providers/services/backend-provider-registry.backend.service.js.map +1 -1
- package/dist/esm/external-providers/services/document-extraction.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/document-extraction.backend.service.js +3 -3
- package/dist/esm/external-providers/services/document-extraction.backend.service.js.map +1 -1
- package/dist/esm/external-providers/services/embeddings.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/embeddings.backend.service.js +4 -4
- package/dist/esm/external-providers/services/embeddings.backend.service.js.map +1 -1
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts +306 -7
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.js +539 -45
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.js.map +1 -1
- package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js +25 -2
- package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js.map +1 -1
- package/dist/esm/files/controllers/file.controller.d.ts +24 -1
- package/dist/esm/files/controllers/file.controller.d.ts.map +1 -1
- package/dist/esm/files/controllers/file.controller.js +83 -11
- package/dist/esm/files/controllers/file.controller.js.map +1 -1
- package/dist/esm/files/handlers/file-upload-route-locals.backend.types.d.ts +17 -0
- package/dist/esm/files/handlers/file-upload-route-locals.backend.types.d.ts.map +1 -0
- package/dist/esm/files/handlers/file-upload-route-locals.backend.types.js +1 -0
- package/dist/esm/files/handlers/file-upload-route-locals.backend.types.js.map +1 -0
- package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts +5 -1
- package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js +76 -13
- package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js.map +1 -1
- package/dist/esm/files/services/file-operation-handler.backend.service.d.ts +18 -0
- package/dist/esm/files/services/file-operation-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/files/services/file-operation-handler.backend.service.js +36 -28
- package/dist/esm/files/services/file-operation-handler.backend.service.js.map +1 -1
- package/dist/esm/files/services/file-scanning.backend.service.d.ts +94 -9
- package/dist/esm/files/services/file-scanning.backend.service.d.ts.map +1 -1
- package/dist/esm/files/services/file-scanning.backend.service.js +197 -17
- package/dist/esm/files/services/file-scanning.backend.service.js.map +1 -1
- package/dist/esm/files/services/file-text-extraction.backend.service.d.ts +60 -1
- package/dist/esm/files/services/file-text-extraction.backend.service.d.ts.map +1 -1
- package/dist/esm/files/services/file-text-extraction.backend.service.js +167 -8
- package/dist/esm/files/services/file-text-extraction.backend.service.js.map +1 -1
- package/dist/esm/files/services/file-upload-grant.backend.service.d.ts +214 -0
- package/dist/esm/files/services/file-upload-grant.backend.service.d.ts.map +1 -0
- package/dist/esm/files/services/file-upload-grant.backend.service.js +566 -0
- package/dist/esm/files/services/file-upload-grant.backend.service.js.map +1 -0
- package/dist/esm/files/services/files.backend.service.d.ts +87 -0
- package/dist/esm/files/services/files.backend.service.d.ts.map +1 -1
- package/dist/esm/files/services/files.backend.service.js +252 -19
- package/dist/esm/files/services/files.backend.service.js.map +1 -1
- package/dist/esm/files/storage/application-storage-key.backend.utils.d.ts +109 -0
- package/dist/esm/files/storage/application-storage-key.backend.utils.d.ts.map +1 -0
- package/dist/esm/files/storage/application-storage-key.backend.utils.js +123 -0
- package/dist/esm/files/storage/application-storage-key.backend.utils.js.map +1 -0
- package/dist/esm/files/storage/file-storage-provider.types.d.ts +16 -10
- package/dist/esm/files/storage/file-storage-provider.types.d.ts.map +1 -1
- package/dist/esm/files/storage/file-storage-provider.types.js.map +1 -1
- package/dist/esm/files/storage/local-directory-storage-provider.backend.service.d.ts +67 -8
- package/dist/esm/files/storage/local-directory-storage-provider.backend.service.d.ts.map +1 -1
- package/dist/esm/files/storage/local-directory-storage-provider.backend.service.js +101 -28
- package/dist/esm/files/storage/local-directory-storage-provider.backend.service.js.map +1 -1
- package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.d.ts.map +1 -1
- package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.js +8 -55
- package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.js.map +1 -1
- package/dist/esm/files/utils/file-field-schema-path.backend.utils.d.ts.map +1 -1
- package/dist/esm/files/utils/file-field-schema-path.backend.utils.js +20 -0
- package/dist/esm/files/utils/file-field-schema-path.backend.utils.js.map +1 -1
- package/dist/esm/files/utils/file-uploader.utils.d.ts.map +1 -1
- package/dist/esm/files/utils/file-uploader.utils.js +12 -0
- package/dist/esm/files/utils/file-uploader.utils.js.map +1 -1
- package/dist/esm/files/utils/office-document-text-extraction.backend.utils.d.ts +86 -0
- package/dist/esm/files/utils/office-document-text-extraction.backend.utils.d.ts.map +1 -0
- package/dist/esm/files/utils/office-document-text-extraction.backend.utils.js +288 -0
- package/dist/esm/files/utils/office-document-text-extraction.backend.utils.js.map +1 -0
- package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.d.ts +15 -0
- package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.js +76 -5
- package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/a2a/controllers/a2a.controller.d.ts.map +1 -1
- package/dist/esm/flows-actors/a2a/controllers/a2a.controller.js +6 -1
- package/dist/esm/flows-actors/a2a/controllers/a2a.controller.js.map +1 -1
- package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.d.ts +60 -0
- package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.js +63 -0
- package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.js.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.d.ts +74 -0
- package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.js +200 -44
- package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.d.ts +7 -1
- package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.js +53 -1
- package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.d.ts +18 -0
- package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.js +18 -0
- package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a.backend.service.d.ts +12 -7
- package/dist/esm/flows-actors/a2a/services/a2a.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/a2a/services/a2a.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.d.ts +0 -13
- package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.d.ts.map +1 -1
- package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.js +14 -22
- package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.js.map +1 -1
- package/dist/esm/flows-actors/models/core-facets.backend.definitions.d.ts +8 -3
- package/dist/esm/flows-actors/models/core-facets.backend.definitions.d.ts.map +1 -1
- package/dist/esm/flows-actors/models/core-facets.backend.definitions.js +25 -15
- package/dist/esm/flows-actors/models/core-facets.backend.definitions.js.map +1 -1
- package/dist/esm/flows-actors/models/flows-actors.backend.schemas.d.ts +13 -1
- package/dist/esm/flows-actors/models/flows-actors.backend.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/models/flows-actors.backend.schemas.js.map +1 -1
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts +88 -8
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts.map +1 -1
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.js +333 -31
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.js.map +1 -1
- package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.d.ts.map +1 -1
- package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.js +4 -2
- package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.js.map +1 -1
- package/dist/esm/flows-actors/models/mcp-client.backend.definitions.d.ts +113 -0
- package/dist/esm/flows-actors/models/mcp-client.backend.definitions.d.ts.map +1 -0
- package/dist/esm/flows-actors/models/mcp-client.backend.definitions.js +62 -0
- package/dist/esm/flows-actors/models/mcp-client.backend.definitions.js.map +1 -0
- package/dist/esm/flows-actors/services/actors-system.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/actors-system.backend.service.js +0 -2
- package/dist/esm/flows-actors/services/actors-system.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/agents.backend.service.d.ts +107 -1
- package/dist/esm/flows-actors/services/agents.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/agents.backend.service.js +519 -56
- package/dist/esm/flows-actors/services/agents.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts +5 -1
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.js +79 -16
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts +34 -5
- package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/flows-actors-registry.service.js +154 -20
- package/dist/esm/flows-actors/services/flows-actors-registry.service.js.map +1 -1
- package/dist/esm/flows-actors/services/flows.backend.services.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/flows.backend.services.js +27 -23
- package/dist/esm/flows-actors/services/flows.backend.services.js.map +1 -1
- package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.js +7 -1
- package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.js.map +1 -1
- package/dist/esm/flows-actors/services/mcp-client.backend.service.d.ts +90 -0
- package/dist/esm/flows-actors/services/mcp-client.backend.service.d.ts.map +1 -0
- package/dist/esm/flows-actors/services/mcp-client.backend.service.js +368 -0
- package/dist/esm/flows-actors/services/mcp-client.backend.service.js.map +1 -0
- package/dist/esm/flows-actors/services/prompt-compiler.backend.service.d.ts +9 -5
- package/dist/esm/flows-actors/services/prompt-compiler.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/prompt-compiler.backend.service.js +12 -17
- package/dist/esm/flows-actors/services/prompt-compiler.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts +151 -41
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts.map +1 -1
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js +308 -143
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js.map +1 -1
- package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.d.ts +0 -207
- package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.d.ts.map +1 -1
- package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.js +8 -243
- package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.js.map +1 -1
- package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.d.ts.map +1 -1
- package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.js.map +1 -1
- package/dist/esm/guidance/services/milestone-evaluator.backend.service.d.ts +9 -14
- package/dist/esm/guidance/services/milestone-evaluator.backend.service.d.ts.map +1 -1
- package/dist/esm/guidance/services/milestone-evaluator.backend.service.js +18 -89
- package/dist/esm/guidance/services/milestone-evaluator.backend.service.js.map +1 -1
- package/dist/esm/guidance/services/progression-state-store.backend.service.d.ts +86 -0
- package/dist/esm/guidance/services/progression-state-store.backend.service.d.ts.map +1 -0
- package/dist/esm/guidance/services/progression-state-store.backend.service.js +155 -0
- package/dist/esm/guidance/services/progression-state-store.backend.service.js.map +1 -0
- package/dist/esm/i18n/controllers/i18n-controller.backend.service.d.ts +10 -0
- package/dist/esm/i18n/controllers/i18n-controller.backend.service.d.ts.map +1 -1
- package/dist/esm/i18n/controllers/i18n-controller.backend.service.js +55 -5
- package/dist/esm/i18n/controllers/i18n-controller.backend.service.js.map +1 -1
- package/dist/esm/index.d.ts +15 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +45 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/inject/models/container.d.ts.map +1 -1
- package/dist/esm/inject/models/container.js +82 -10
- package/dist/esm/inject/models/container.js.map +1 -1
- package/dist/esm/inject/models/service-types.d.ts +20 -3
- package/dist/esm/inject/models/service-types.d.ts.map +1 -1
- package/dist/esm/inject/models/service-types.js +21 -3
- package/dist/esm/inject/models/service-types.js.map +1 -1
- package/dist/esm/mcp/controllers/mcp.controller.d.ts.map +1 -1
- package/dist/esm/mcp/controllers/mcp.controller.js +32 -4
- package/dist/esm/mcp/controllers/mcp.controller.js.map +1 -1
- package/dist/esm/mcp/models/mcp-tool.backend.schemas.d.ts +34 -0
- package/dist/esm/mcp/models/mcp-tool.backend.schemas.d.ts.map +1 -1
- package/dist/esm/mcp/models/mcp-tool.backend.schemas.js +42 -0
- package/dist/esm/mcp/models/mcp-tool.backend.schemas.js.map +1 -1
- package/dist/esm/mcp/services/mcp-server.backend.service.d.ts +84 -1
- package/dist/esm/mcp/services/mcp-server.backend.service.d.ts.map +1 -1
- package/dist/esm/mcp/services/mcp-server.backend.service.js +235 -11
- package/dist/esm/mcp/services/mcp-server.backend.service.js.map +1 -1
- package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.d.ts +64 -2
- package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.d.ts.map +1 -1
- package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.js +152 -6
- package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.js.map +1 -1
- package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.d.ts.map +1 -1
- package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.js +49 -4
- package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.js.map +1 -1
- package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.d.ts +66 -0
- package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.d.ts.map +1 -0
- package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.js +199 -0
- package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.js.map +1 -0
- package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.d.ts +149 -13
- package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.d.ts.map +1 -1
- package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.js +411 -19
- package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.js.map +1 -1
- package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.d.ts +11 -2
- package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.d.ts.map +1 -1
- package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.js.map +1 -1
- package/dist/esm/monitoring/logger/models/logger.backend.schemas.d.ts +28 -9
- package/dist/esm/monitoring/logger/models/logger.backend.schemas.d.ts.map +1 -1
- package/dist/esm/monitoring/logger/models/logger.backend.schemas.js +30 -10
- package/dist/esm/monitoring/logger/models/logger.backend.schemas.js.map +1 -1
- package/dist/esm/monitoring/logger/services/logger.service.d.ts +12 -0
- package/dist/esm/monitoring/logger/services/logger.service.d.ts.map +1 -1
- package/dist/esm/monitoring/logger/services/logger.service.js +52 -11
- package/dist/esm/monitoring/logger/services/logger.service.js.map +1 -1
- package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.d.ts +62 -0
- package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.d.ts.map +1 -0
- package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.js +78 -0
- package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.js.map +1 -0
- package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts +309 -0
- package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts.map +1 -0
- package/dist/esm/monitoring/observability/audit-observation-emission.backend.js +385 -0
- package/dist/esm/monitoring/observability/audit-observation-emission.backend.js.map +1 -0
- package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts +1 -0
- package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts.map +1 -1
- package/dist/esm/monitoring/observability/models/observability.backend.schemas.js.map +1 -1
- package/dist/esm/monitoring/observability/services/metrics.service.d.ts +21 -0
- package/dist/esm/monitoring/observability/services/metrics.service.d.ts.map +1 -1
- package/dist/esm/monitoring/observability/services/metrics.service.js +38 -0
- package/dist/esm/monitoring/observability/services/metrics.service.js.map +1 -1
- package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts +0 -80
- package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts.map +0 -1
- package/dist/esm/notifications/email/models/email-context-provider.interface.js +0 -25
- package/dist/esm/notifications/email/models/email-context-provider.interface.js.map +0 -1
- package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts +0 -49
- package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts.map +0 -1
- package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js +0 -141
- package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js.map +0 -1
- package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts +0 -37
- package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts.map +0 -1
- package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js +0 -121
- package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js.map +0 -1
- package/dist/esm/notifications/email/services/email-template-registry.backend.service.d.ts +66 -1
- package/dist/esm/notifications/email/services/email-template-registry.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/email/services/email-template-registry.backend.service.js +105 -10
- package/dist/esm/notifications/email/services/email-template-registry.backend.service.js.map +1 -1
- package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts +0 -58
- package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts.map +0 -1
- package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js +0 -223
- package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js.map +0 -1
- package/dist/esm/notifications/email/services/email-template-validator.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/email/services/email-template-validator.backend.service.js +10 -1
- package/dist/esm/notifications/email/services/email-template-validator.backend.service.js.map +1 -1
- package/dist/esm/notifications/email/services/email.backend.service.d.ts +60 -4
- package/dist/esm/notifications/email/services/email.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/email/services/email.backend.service.js +145 -43
- package/dist/esm/notifications/email/services/email.backend.service.js.map +1 -1
- package/dist/esm/notifications/email/utils/color-conversion.utils.d.ts +0 -1
- package/dist/esm/notifications/email/utils/color-conversion.utils.d.ts.map +1 -1
- package/dist/esm/notifications/email/utils/color-conversion.utils.js.map +1 -1
- package/dist/esm/notifications/services/notification-badge.backend.service.d.ts +142 -21
- package/dist/esm/notifications/services/notification-badge.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/services/notification-badge.backend.service.js +283 -58
- package/dist/esm/notifications/services/notification-badge.backend.service.js.map +1 -1
- package/dist/esm/notifications/services/notifications-dispatcher.backend.service.d.ts +108 -13
- package/dist/esm/notifications/services/notifications-dispatcher.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/services/notifications-dispatcher.backend.service.js +432 -101
- package/dist/esm/notifications/services/notifications-dispatcher.backend.service.js.map +1 -1
- package/dist/esm/notifications/sms/services/sms.backend.service.d.ts +2 -2
- package/dist/esm/notifications/sms/services/sms.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/sms/services/sms.backend.service.js +5 -5
- package/dist/esm/notifications/sms/services/sms.backend.service.js.map +1 -1
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts +117 -5
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js +164 -6
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.d.ts +0 -6
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.js +54 -7
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.js.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.d.ts +5 -5
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.js +14 -13
- package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.js.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.d.ts +2 -1
- package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.js +18 -8
- package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.js.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.js +20 -18
- package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.d.ts +16 -0
- package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.js +18 -0
- package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.js.map +1 -1
- package/dist/esm/organizations/batches/organization-purge.batch.backend.service.d.ts +2 -2
- package/dist/esm/organizations/batches/organization-purge.batch.backend.service.js +2 -2
- package/dist/esm/organizations/batches/organization-purge.batch.backend.service.js.map +1 -1
- package/dist/esm/organizations/services/organization-custom-implementation.backend.service.d.ts.map +1 -1
- package/dist/esm/organizations/services/organization-custom-implementation.backend.service.js +63 -2
- package/dist/esm/organizations/services/organization-custom-implementation.backend.service.js.map +1 -1
- package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.d.ts.map +1 -1
- package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.js +4 -1
- package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.js.map +1 -1
- package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.d.ts +66 -0
- package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.d.ts.map +1 -0
- package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.js +257 -0
- package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.js.map +1 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.binding.d.ts +12 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.binding.d.ts.map +1 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.binding.js +47 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.binding.js.map +1 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.interface.d.ts +87 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.interface.d.ts.map +1 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.interface.js +1 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.interface.js.map +1 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.options.d.ts +31 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.options.d.ts.map +1 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.options.js +13 -0
- package/dist/esm/queue/adapters/queue-adapter.backend.options.js.map +1 -0
- package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.d.ts +19 -25
- package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.js +33 -0
- package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.js.map +1 -1
- package/dist/esm/queue/domain-queue-consumer.backend.service.d.ts +2 -2
- package/dist/esm/queue/domain-queue-consumer.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/domain-queue-consumer.backend.service.js +1 -4
- package/dist/esm/queue/domain-queue-consumer.backend.service.js.map +1 -1
- package/dist/esm/queue/job-consumer.backend.service.d.ts +2 -2
- package/dist/esm/queue/job-consumer.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/job-consumer.backend.service.js +1 -4
- package/dist/esm/queue/job-consumer.backend.service.js.map +1 -1
- package/dist/esm/queue/job-executor.backend.service.d.ts +2 -2
- package/dist/esm/queue/job-executor.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/job-executor.backend.service.js +1 -4
- package/dist/esm/queue/job-executor.backend.service.js.map +1 -1
- package/dist/esm/queue/queue-monitoring.backend.service.d.ts +8 -4
- package/dist/esm/queue/queue-monitoring.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/queue-monitoring.backend.service.js +25 -17
- package/dist/esm/queue/queue-monitoring.backend.service.js.map +1 -1
- package/dist/esm/queue/queue-worker-initializer.backend.service.d.ts +16 -1
- package/dist/esm/queue/queue-worker-initializer.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/queue-worker-initializer.backend.service.js +16 -1
- package/dist/esm/queue/queue-worker-initializer.backend.service.js.map +1 -1
- package/dist/esm/queue/queue.backend.service.d.ts +3 -3
- package/dist/esm/queue/queue.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/queue.backend.service.js +26 -4
- package/dist/esm/queue/queue.backend.service.js.map +1 -1
- package/dist/esm/queue/worker-shutdown-manager.backend.service.d.ts +2 -2
- package/dist/esm/queue/worker-shutdown-manager.backend.service.d.ts.map +1 -1
- package/dist/esm/queue/worker-shutdown-manager.backend.service.js +18 -3
- package/dist/esm/queue/worker-shutdown-manager.backend.service.js.map +1 -1
- package/dist/esm/rag/utils/rag-chunking.backend.utils.d.ts +50 -25
- package/dist/esm/rag/utils/rag-chunking.backend.utils.d.ts.map +1 -1
- package/dist/esm/rag/utils/rag-chunking.backend.utils.js +147 -39
- package/dist/esm/rag/utils/rag-chunking.backend.utils.js.map +1 -1
- package/dist/esm/rag/utils/rag-context-assembly.backend.utils.d.ts +12 -3
- package/dist/esm/rag/utils/rag-context-assembly.backend.utils.d.ts.map +1 -1
- package/dist/esm/rag/utils/rag-context-assembly.backend.utils.js +12 -3
- package/dist/esm/rag/utils/rag-context-assembly.backend.utils.js.map +1 -1
- package/dist/esm/requests/service/websocket.service.d.ts +9 -0
- package/dist/esm/requests/service/websocket.service.d.ts.map +1 -1
- package/dist/esm/requests/service/websocket.service.js +88 -15
- package/dist/esm/requests/service/websocket.service.js.map +1 -1
- package/dist/esm/resources/models/custom-service-implementations.backend.definition.d.ts.map +1 -1
- package/dist/esm/resources/models/custom-service-implementations.backend.definition.js +16 -2
- package/dist/esm/resources/models/custom-service-implementations.backend.definition.js.map +1 -1
- package/dist/esm/resources/models/resources-operations.backend.definitions.d.ts.map +1 -1
- package/dist/esm/resources/models/resources-operations.backend.definitions.js +2 -0
- package/dist/esm/resources/models/resources-operations.backend.definitions.js.map +1 -1
- package/dist/esm/resources/models/resources-relationships.backend.definitions.d.ts.map +1 -1
- package/dist/esm/resources/models/resources-relationships.backend.definitions.js +14 -0
- package/dist/esm/resources/models/resources-relationships.backend.definitions.js.map +1 -1
- package/dist/esm/resources/models/resources-types.backend.schemas.d.ts +2 -1
- package/dist/esm/resources/models/resources-types.backend.schemas.d.ts.map +1 -1
- package/dist/esm/resources/models/resources-types.backend.schemas.js +8 -0
- package/dist/esm/resources/models/resources-types.backend.schemas.js.map +1 -1
- package/dist/esm/resources/services/resource-id.backend.service.js +3 -3
- package/dist/esm/resources/services/resource-id.backend.service.js.map +1 -1
- package/dist/esm/resources/services/resources-registry.backend.service.d.ts +60 -5
- package/dist/esm/resources/services/resources-registry.backend.service.d.ts.map +1 -1
- package/dist/esm/resources/services/resources-registry.backend.service.js +91 -7
- package/dist/esm/resources/services/resources-registry.backend.service.js.map +1 -1
- package/dist/esm/runtime/controllers/health-controller.backend.service.d.ts +36 -3
- package/dist/esm/runtime/controllers/health-controller.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/controllers/health-controller.backend.service.js +32 -10
- package/dist/esm/runtime/controllers/health-controller.backend.service.js.map +1 -1
- package/dist/esm/runtime/domain-module.backend.definitions.d.ts +24 -0
- package/dist/esm/runtime/domain-module.backend.definitions.d.ts.map +1 -1
- package/dist/esm/runtime/domain-module.backend.definitions.js +24 -0
- package/dist/esm/runtime/domain-module.backend.definitions.js.map +1 -1
- package/dist/esm/runtime/services/execution-context-creator.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/services/execution-context-creator.backend.service.js +13 -7
- package/dist/esm/runtime/services/execution-context-creator.backend.service.js.map +1 -1
- package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.d.ts +51 -0
- package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.d.ts.map +1 -1
- package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.js.map +1 -1
- package/dist/esm/runtime/services/http-server.backend.service.d.ts +26 -0
- package/dist/esm/runtime/services/http-server.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/services/http-server.backend.service.js +181 -1
- package/dist/esm/runtime/services/http-server.backend.service.js.map +1 -1
- package/dist/esm/runtime/services/start-application.backend.service.d.ts +47 -1
- package/dist/esm/runtime/services/start-application.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/services/start-application.backend.service.js +343 -77
- package/dist/esm/runtime/services/start-application.backend.service.js.map +1 -1
- package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.d.ts +15 -0
- package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.js +28 -0
- package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.d.ts +5 -1
- package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.js +24 -4
- package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js +29 -4
- package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.d.ts +114 -0
- package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.js +354 -3
- package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/models/cimd.backend.schemas.d.ts +1 -0
- package/dist/esm/security/authentications/models/cimd.backend.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/models/cimd.backend.schemas.js +22 -0
- package/dist/esm/security/authentications/models/cimd.backend.schemas.js.map +1 -1
- package/dist/esm/security/authentications/models/jwt.backend.schemas.d.ts +3 -23
- package/dist/esm/security/authentications/models/jwt.backend.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/models/jwt.backend.schemas.js +20 -45
- package/dist/esm/security/authentications/models/jwt.backend.schemas.js.map +1 -1
- package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts +15 -0
- package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.js.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.d.ts +0 -2
- package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.js +23 -14
- package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.js.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.d.ts +0 -1
- package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.js +15 -12
- package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.d.ts +113 -3
- package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.js +207 -30
- package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.d.ts +95 -2
- package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.js +153 -9
- package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts +190 -0
- package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/anonymous-session.backend.service.js +377 -53
- package/dist/esm/security/authentications/services/anonymous-session.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.d.ts +9 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.js +77 -2
- package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.js +5 -3
- package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.d.ts +41 -0
- package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.js +202 -23
- package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js +42 -1
- package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js +34 -4
- package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.d.ts +29 -5
- package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.js +77 -5
- package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.d.ts +41 -1
- package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.js +87 -4
- package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.d.ts +43 -1
- package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.js +277 -97
- package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.d.ts +28 -5
- package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.js +72 -12
- package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.js +3 -0
- package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.js.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts +28 -0
- package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts.map +1 -0
- package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js +283 -0
- package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js.map +1 -0
- package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.d.ts +4 -3
- package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.js +4 -3
- package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.d.ts +35 -0
- package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.js +111 -21
- package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.d.ts +14 -1
- package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.js +49 -8
- package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.js +4 -0
- package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.js.map +1 -1
- package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.js +6 -0
- package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.d.ts +37 -1
- package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.js +51 -0
- package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.js.map +1 -1
- package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.d.ts +41 -0
- package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.js +45 -0
- package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.js.map +1 -1
- package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.d.ts +116 -0
- package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.d.ts.map +1 -0
- package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.js +162 -0
- package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.js.map +1 -0
- package/dist/esm/security/authorizations/initiator-organization-confinement.backend.d.ts.map +1 -1
- package/dist/esm/security/authorizations/initiator-organization-confinement.backend.js +24 -1
- package/dist/esm/security/authorizations/initiator-organization-confinement.backend.js.map +1 -1
- package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.d.ts +20 -20
- package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.js +27 -28
- package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.js.map +1 -1
- package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js +77 -3
- package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js.map +1 -1
- package/dist/esm/security/authorizations/privileged-access-review.backend.utils.d.ts +117 -0
- package/dist/esm/security/authorizations/privileged-access-review.backend.utils.d.ts.map +1 -0
- package/dist/esm/security/authorizations/privileged-access-review.backend.utils.js +104 -0
- package/dist/esm/security/authorizations/privileged-access-review.backend.utils.js.map +1 -0
- package/dist/esm/security/authorizations/role-ceiling.backend.utils.d.ts +4 -0
- package/dist/esm/security/authorizations/role-ceiling.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/authorizations/role-ceiling.backend.utils.js +4 -0
- package/dist/esm/security/authorizations/role-ceiling.backend.utils.js.map +1 -1
- package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts +93 -0
- package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts.map +1 -0
- package/dist/esm/security/authorizations/role-conferral.backend.utils.js +95 -0
- package/dist/esm/security/authorizations/role-conferral.backend.utils.js.map +1 -0
- package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts +124 -1
- package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts.map +1 -1
- package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js +142 -5
- package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js.map +1 -1
- package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts +175 -14
- package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authorizations/services/authorizations.backend.service.js +385 -49
- package/dist/esm/security/authorizations/services/authorizations.backend.service.js.map +1 -1
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts +6 -14
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js +13 -22
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js.map +1 -1
- package/dist/esm/security/connected-accounts/connection-target-authorization.backend.d.ts +60 -0
- package/dist/esm/security/connected-accounts/connection-target-authorization.backend.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/connection-target-authorization.backend.js +79 -0
- package/dist/esm/security/connected-accounts/connection-target-authorization.backend.js.map +1 -0
- package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts +161 -0
- package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js +512 -0
- package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js.map +1 -0
- package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts +59 -0
- package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.js +22 -0
- package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.js.map +1 -0
- package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.d.ts +44 -0
- package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.js +20 -0
- package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.js.map +1 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts +191 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js +385 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js.map +1 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.d.ts +41 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.js +358 -0
- package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.js.map +1 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.d.ts +160 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js +266 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js.map +1 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts +111 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js +107 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js.map +1 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.d.ts +54 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js +153 -0
- package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js.map +1 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts +195 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js +387 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js.map +1 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.d.ts +45 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.js +291 -0
- package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.js.map +1 -0
- package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts +62 -0
- package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.js +29 -0
- package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.js.map +1 -0
- package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.d.ts +127 -0
- package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.js +277 -0
- package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.js.map +1 -0
- package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.d.ts +66 -0
- package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.js +75 -0
- package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.js.map +1 -0
- package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.d.ts +18 -1
- package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.d.ts.map +1 -1
- package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.js +110 -74
- package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.js.map +1 -1
- package/dist/esm/security/consumable-tokens/consumable-token-models.exports.d.ts +22 -0
- package/dist/esm/security/consumable-tokens/consumable-token-models.exports.d.ts.map +1 -0
- package/dist/esm/security/consumable-tokens/consumable-token-models.exports.js +22 -0
- package/dist/esm/security/consumable-tokens/consumable-token-models.exports.js.map +1 -0
- package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.d.ts +17 -3
- package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.js +12 -0
- package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.js.map +1 -1
- package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.d.ts +41 -3
- package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.d.ts.map +1 -1
- package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.js +83 -20
- package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.js.map +1 -1
- package/dist/esm/security/credential-rotation-grace.backend.utils.d.ts +9 -4
- package/dist/esm/security/credential-rotation-grace.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/credential-rotation-grace.backend.utils.js +9 -4
- package/dist/esm/security/credential-rotation-grace.backend.utils.js.map +1 -1
- package/dist/esm/security/jwt/services/jwt.backend.service.d.ts.map +1 -1
- package/dist/esm/security/jwt/services/jwt.backend.service.js +1 -18
- package/dist/esm/security/jwt/services/jwt.backend.service.js.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.d.ts +26 -0
- package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.js +43 -0
- package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.js.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts +8 -1
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js +49 -0
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/security/scim/controllers/scim.backend.controller.d.ts.map +1 -1
- package/dist/esm/security/scim/controllers/scim.backend.controller.js +17 -5
- package/dist/esm/security/scim/controllers/scim.backend.controller.js.map +1 -1
- package/dist/esm/security/scim/models/scim-protocol.backend.schemas.d.ts +67 -29
- package/dist/esm/security/scim/models/scim-protocol.backend.schemas.d.ts.map +1 -1
- package/dist/esm/security/scim/models/scim-protocol.backend.schemas.js +47 -25
- package/dist/esm/security/scim/models/scim-protocol.backend.schemas.js.map +1 -1
- package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.d.ts +10 -2
- package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.js +10 -2
- package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.js.map +1 -1
- package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.d.ts +143 -0
- package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.d.ts.map +1 -0
- package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.js +258 -0
- package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.js.map +1 -0
- package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.d.ts +39 -0
- package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.d.ts.map +1 -0
- package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.js +159 -0
- package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +17 -9
- package/dist/esm/.builder.pid +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.backend.service.js","sourceRoot":"","sources":["../../../../../src/files/services/files.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAgB,SAAS,EAAE,2BAA2B,EAAsD,oBAAoB,E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AC,CAAA;IAEzD,WAAA,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;IAE5C,WAAA,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAE3C,WAAA,MAAM,CAAC,kBAAkB,CAAC,oCAAoC,CAAC,CAAA;IAC/D,WAAA,QAAQ,EAAE,CAAA;IAOV,WAAA,MAAM,CAAC,kBAAkB,CAAC,8BAA8B,CAAC,CAAA;IACzD,WAAA,QAAQ,EAAE,CAAA;IAEV,YAAA,MAAM,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAA;IAC/C,YAAA,QAAQ,EAAE,CAAA;+CAzBoB,0BAA0B;QAErB,+BAA+B;QAE5B,yCAAyC;QAEtC,qCAAqC;QAErC,qCAAqC;QAE3C,+BAA+B;QAEhC,uBAAuB;QAGT,2CAA2C;GAtBnF,mBAAmB,CAg/D/B","sourcesContent":["/**\n * Files Backend Service\n *\n * Manages file metadata and coordinates with storage providers (MinIO/S3).\n * Files are stored in external storage, this service tracks metadata in MongoDB.\n *\n * Features:\n * - File upload coordination\n * - File metadata management\n * - File linking to resources\n * - File access authorization\n * - File lifecycle management (status tracking)\n */\n\nimport { injectable, inject, optional } from 'inversify';\nimport type { Response, NextFunction } from 'express';\nimport type { Readable } from 'stream';\nimport { CoreResourceOperation, CoreResourceType, ResourceType, ErrorType, ErrorCustomMessageReference, FileUploaderEntityType, type FileUploaderOwnership, ResourcePrimaryScope, PRIMARY_SCOPE_TO_FIELD_IDENTIFIER, CORE_APP_ROLES, Resources_SharedUtils, isWildoBackendError, WildoHeaderKeys } from '@wildo-ai/saas-models';\nimport { File, FileStatus, FILE_STATUS_TRANSITIONS, FileScopeIdentifiers, FileScopeUtils, FileServeVariant, ERASED_FILE_NAME_PLACEHOLDER } from '@wildo-ai/saas-models';\nimport { resolveFileDisplayNature, type FileDisplayNature, type 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, projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport { ResourceOperationHelperBackendService } from '~wildo-backend-lib/base-classes/services/resource-operations-helper.backend.service';\nimport type { BackendResourceRepository } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport { RepositoryOptions } from '~wildo-backend-lib/base-classes/models/repositories.backend.schemas';\nimport { validateFileId, validateResourceId, validateResourceType, validateFieldName, validateSize, validateUploadedBy, validateUploadedByEntityType, validateOrganizationId, validateContentType, resolveConfiguredMaxFileSize, validateStream } from '~wildo-backend-lib/files/utils/file-validation.utils';\nimport { setContentDispositionHeader } from '~wildo-backend-lib/files/utils/file-upload.utils';\nimport { resolveFileUploaderPrincipal } from '~wildo-backend-lib/files/utils/file-uploader.utils';\nimport { generateImageThumbnail, collectStreamToBuffer, isThumbnailableImage, THUMBNAIL_SOURCE_MAX_BYTES } from '~wildo-backend-lib/files/utils/image-thumbnail.backend.utils';\nimport { AppConfigurationService } from '~wildo-backend-lib/config/services/app-configuration.backend.service';\nimport { FileStorageRouterBackendService } from '~wildo-backend-lib/files/storage/file-storage-router.backend.service';\nimport type { IFileStorageProvider, StorageUploadResult } from '~wildo-backend-lib/files/storage/file-storage-provider.types';\nimport { ResourcePersistenceUnitOfWorkBackendService } from '~wildo-backend-lib/databases/services/resource-persistence-unit-of-work.backend.service';\nimport type { ResourcePersistenceResourceStore } from '~wildo-backend-lib/databases/services/resource-persistence-unit-of-work.backend.service';\nimport type { RagSourceFieldDetectionBackendService } from '~wildo-backend-lib/files/services/rag-source-field-detection.backend.service';\nimport type { RagChunkStoreBackendService } from '~wildo-backend-lib/rag/services/rag-chunk-store.backend.service';\nimport { scheduleRagChunkRemovalForFields } from '~wildo-backend-lib/rag/utils/rag-chunk-removal.backend.utils';\n\n/**\n * Content-Security-Policy applied to EVERY file-byte response (see\n * `FilesBackendService.streamFileToResponse`). `default-src 'none'` blocks all\n * subresource loads + inline/script execution; `sandbox` (with NO `allow-*`\n * tokens) drops the response into a fully-restricted sandbox if it is navigated\n * to directly at the top level — so an attacker-uploaded HTML/SVG can never run\n * script, submit a form, or navigate. Media loaded via `<img>`/`<video>` is\n * unaffected: those are governed by the EMBEDDING page's CSP, not this response's.\n * Same pattern GitHub/Dropbox use for user-uploaded content.\n */\nconst FILE_SERVE_CONTENT_SECURITY_POLICY = \"default-src 'none'; sandbox\";\n\n/**\n * Media types that must NEVER be served `inline`, even when a preview is\n * requested, because a browser parses them into an ACTIVE document context that\n * can execute script (the classic stored-XSS-via-upload vector). They are forced\n * to `attachment` (download) instead. Safe media (`image/*` except SVG, `video/*`,\n * `audio/*`, `application/pdf`) keep the requested `inline` disposition.\n * Matched against the leading media type only (`; charset=…` params ignored).\n */\nconst DANGEROUS_INLINE_CONTENT_TYPES = new Set<string>([\n 'text/html',\n 'application/xhtml+xml',\n 'image/svg+xml',\n]);\n\n/** True when `contentType` must not be rendered inline (see the set above). */\nfunction isDangerousInlineContentType(contentType: string | undefined): boolean {\n if (!contentType) return false;\n const mediaType = contentType.split(';', 1)[0]!.trim().toLowerCase();\n return DANGEROUS_INLINE_CONTENT_TYPES.has(mediaType);\n}\n\n/**\n * Cache policy for a generated thumbnail response: `private` (auth-gated bytes —\n * never a shared/CDN cache), fresh for a day, and `immutable` because a thumbnail is\n * fully determined by the file's id + version. The response ETag encodes both, so a\n * client holding a still-fresh thumbnail never revalidates; replacing the underlying\n * image bumps `updatedAt`, which changes the ETag and busts the cache. Applied ONLY\n * to the thumbnail path — the original-bytes path relies on the storage\n * ETag/Last-Modified it already forwards.\n */\nconst THUMBNAIL_CACHE_CONTROL = 'private, max-age=86400, immutable';\n\n@injectable()\nexport class FilesBackendService {\n protected logDebug: (message: string, context?: Record<string, unknown>) => void;\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.ResourceRegistryService)\n private readonly resourcesRegistry: ResourcesRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.RepositoriesRegistryHandlerService)\n private readonly repositoriesRegistry: RepositoriesRegistryHandlerBackendService,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService)\n private readonly executionContextCreator: ExecutionContextCreatorBackendService,\n @inject(SAAS_SERVICE_TYPES.ResourceOperationHelperService)\n private readonly resourceOperationHelper: ResourceOperationHelperBackendService,\n @inject(SAAS_SERVICE_TYPES.FileStorageRouter)\n private readonly fileStorageRouter: FileStorageRouterBackendService,\n @inject(SAAS_SERVICE_TYPES.AppConfigService)\n private readonly appConfigService: AppConfigurationService,\n @inject(SAAS_SERVICE_TYPES.ResourcePersistenceUnitOfWorkService)\n @optional()\n private readonly resourcePersistenceUnitOfWork?: ResourcePersistenceUnitOfWorkBackendService,\n // RAG derived-data tier (plan D3): file link/unlink/delete/erase mutate WHICH file backs a\n // FILE_EXTRACTION `.ragSource()` field, so the affected field's chunk set is removed in the same\n // decision (seam helper below). `@optional()` keeps minimal test containers constructing — the\n // seams no-op without the pair, and the startup capability probe owns refusing a real\n // application whose RAG-source resources have no usable store.\n @inject(SAAS_SERVICE_TYPES.RagSourceFieldDetectionService)\n @optional()\n private readonly ragSourceFieldDetection?: RagSourceFieldDetectionBackendService,\n @inject(SAAS_SERVICE_TYPES.RagChunkStoreService)\n @optional()\n private readonly ragChunkStore?: RagChunkStoreBackendService,\n ) {\n this.logDebug = this.logger.debugByType('FilesBackendService');\n this.logger.setDebugTypeLogging('FilesBackendService', false);\n\n this.logDebug('FilesBackendService initialized');\n }\n\n /**\n * Get the files repository for internal operations.\n * Lazy getter to ensure repository is initialized.\n */\n private get filesRepository(): BackendResourceRepository<any, any, any> {\n return this.repositoriesRegistry.getRepositoryOrThrow(CoreResourceType.FILES, {} as ExecutionContext<any>);\n }\n\n private getDefaultStorageProvider(): IFileStorageProvider {\n return this.fileStorageRouter.getDefaultProvider();\n }\n\n public getStorageProviderForFile(\n file: Pick<File, 'fileId' | 'storageProvider' | 'storageRef'>,\n executionContext: ExecutionContext<any>,\n ): IFileStorageProvider {\n if (!file.storageProvider) {\n this.logDebug('Falling back to default storage provider for legacy file row', {\n fileId: file.fileId,\n });\n return this.getDefaultStorageProvider();\n }\n\n const provider = this.fileStorageRouter.getProviderById(file.storageProvider);\n if (!provider) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'No registered storage provider matches the persisted file routing',\n fileId: file.fileId,\n storageProvider: file.storageProvider,\n },\n }\n );\n }\n\n return provider;\n }\n\n /**\n * Stream a file's bytes from its storage provider to an Express response.\n *\n * Shared streaming seam used by BOTH the global `FileController` download route\n * and the resource-integrated file **serve** route. Callers own authorization\n * BEFORE invoking this (the global controller via file-scope/token checks; the\n * resource serve route via the parent resource's READ authorization + a\n * link-ownership assertion) — this method performs NO authorization, it only\n * pipes bytes and manages the stream/response lifecycle.\n *\n * Sets Content-Type / Content-Length / ETag / Last-Modified from the storage\n * download result, and Content-Disposition from `disposition` (`inline` for\n * preview surfaces like avatars/PDFs, `attachment` for forced downloads).\n * Registers stream/response error + close handlers before piping so an\n * immediate storage error is caught and the source stream is always destroyed\n * on client disconnect.\n *\n * @param file - The file record (already fetched + authorized by the caller).\n * @param res - Express response to pipe into.\n * @param executionContext - Context for storage-provider resolution/errors.\n * @param options.disposition - `inline` (default) or `attachment`.\n * @param options.next - Express `next` to forward pre-header stream errors.\n * @param options.variant - `original` (default) streams the stored bytes as-is;\n * `thumbnail` delegates to `serveImageThumbnail` for eligible raster images.\n * Non-images, oversized sources, and resize failures transparently fall through\n * to the original-bytes streaming path — a preview request never hard-fails.\n */\n public async streamFileToResponse(\n file: File,\n res: Response,\n executionContext: ExecutionContext<any> | undefined,\n options?: { disposition?: 'inline' | 'attachment'; next?: NextFunction; variant?: FileServeVariant },\n ): Promise<void> {\n const disposition = options?.disposition ?? 'inline';\n const next = options?.next;\n const variant = options?.variant ?? FileServeVariant.ORIGINAL;\n\n // ── THUMBNAIL VARIANT — a preview surface asked for a downscaled rendition.\n // Only raster images within the memory-safe size ceiling are transformed; every\n // other case (non-image, oversized, or a resize failure inside\n // `serveImageThumbnail`) serves the ORIGINAL bytes via the streaming path below.\n // Gated on the RECORDED `mimeType`/`size` so the decision costs no storage round-trip.\n const canThumbnail =\n variant === FileServeVariant.THUMBNAIL &&\n isThumbnailableImage(file.mimeType) &&\n (file.size ?? 0) > 0 &&\n (file.size ?? 0) <= THUMBNAIL_SOURCE_MAX_BYTES;\n if (canThumbnail) {\n await this.serveImageThumbnail(file, res, executionContext, next);\n return;\n }\n\n this.logDebug('Streaming file to response', { fileId: file.fileId, disposition });\n\n let stream: Readable | null = null;\n\n try {\n const storageProvider = this.getStorageProviderForFile(file, executionContext as any);\n const downloadResult = await storageProvider.download(file, executionContext as any);\n stream = downloadResult.stream;\n\n // Validate stream before use (ensures stream is readable and not destroyed).\n validateStream(stream, this.errorBuilder, executionContext as any, 'downloadStream');\n\n // Storage metadata is more accurate than the DB copy for transport headers.\n if (res.headersSent) {\n this.logger.warn('Response headers already sent, cannot set file response headers', {\n fileId: file.fileId,\n });\n } else {\n const contentType = downloadResult.contentType || file.mimeType;\n res.setHeader(WildoHeaderKeys.CONTENT_TYPE, contentType);\n\n // ── SECURITY (untrusted bytes) — file content is user-uploaded and must\n // NEVER be able to execute as stored XSS. Two always-on response defenses:\n // 1. `X-Content-Type-Options: nosniff` — the browser must honour the\n // declared Content-Type and not MIME-sniff a body into executable HTML.\n // 2. file-serve CSP (`default-src 'none'; sandbox`) — even a directly\n // navigated HTML/SVG runs no script (see the const's doc above).\n // These are cheap, unconditional, and safe for legitimate media.\n // Standard lowercase HTTP header names, set as literals here (rather than via\n // the cross-package WildoHeaderKeys registry) to keep this untrusted-bytes\n // serving seam self-contained — see the `FILE_SERVE_CONTENT_SECURITY_POLICY` doc.\n res.setHeader('x-content-type-options', 'nosniff');\n res.setHeader('content-security-policy', FILE_SERVE_CONTENT_SECURITY_POLICY);\n\n const contentLength = downloadResult.size > 0 ? downloadResult.size : (file.size || 0);\n if (contentLength > 0) {\n res.setHeader(WildoHeaderKeys.CONTENT_LENGTH, contentLength.toString());\n }\n\n // ── SECURITY (disposition) — a `preview` (inline) request is only honoured\n // for SAFE media; script-capable types (html/xhtml/svg) are forced to\n // `attachment` so the browser downloads rather than renders them in a\n // document context. Belt-and-braces with nosniff + CSP above.\n const effectiveDisposition =\n disposition === 'inline' && isDangerousInlineContentType(contentType)\n ? 'attachment'\n : disposition;\n const filename = file.originalFilename || file.fileId || 'file';\n setContentDispositionHeader(res, filename, effectiveDisposition);\n\n // ETag / Last-Modified are standard HTTP headers (not platform headers).\n if (downloadResult.etag) {\n res.setHeader(WildoHeaderKeys.ETAG, downloadResult.etag);\n }\n if (downloadResult.lastModified) {\n res.setHeader(WildoHeaderKeys.LAST_MODIFIED, downloadResult.lastModified.toUTCString());\n }\n }\n\n // Register error handlers BEFORE piping so immediate errors are caught.\n stream.on('error', (error) => {\n this.logger.error('Stream error while serving file from storage', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n if (!res.headersSent) {\n if (next) {\n next(error);\n return;\n }\n res.status(500).end();\n } else if (stream && !stream.destroyed) {\n stream.destroy();\n }\n });\n\n res.on('error', (error) => {\n this.logger.error('Response error while streaming file', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n if (stream && !stream.destroyed) {\n stream.destroy();\n }\n });\n\n // Client disconnect / response finished → destroy the source stream.\n res.on('close', () => {\n if (stream && !stream.destroyed) {\n stream.destroy();\n }\n });\n\n stream.pipe(res);\n } catch (error) {\n if (stream && !stream.destroyed) {\n try {\n stream.destroy();\n } catch (destroyError) {\n this.logger.warn('Failed to destroy stream during error cleanup', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(destroyError),\n originalError: describeCaughtError(error),\n });\n }\n }\n\n this.logger.error('Failed to stream file from storage', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n throw error;\n }\n }\n\n /**\n * Serve a downscaled `webp` thumbnail of a raster image — the `?variant=thumbnail`\n * path of {@link streamFileToResponse}.\n *\n * Unlike the original-bytes path, this BUFFERS the source in memory to hand it to\n * libvips. Callers MUST gate on {@link isThumbnailableImage} + a size ceiling\n * before delegating here (see `streamFileToResponse`). On any resize failure the\n * ORIGINAL bytes (already buffered) are returned with their real content-type, so a\n * corrupt/edge-case image degrades to \"full image\" rather than a 500.\n *\n * Applies the SAME untrusted-bytes hardening as the streaming path (`nosniff` +\n * file-serve CSP) plus an immutable, version-keyed cache policy so the resize cost\n * is paid at most once per (file, version) per client.\n *\n * @param file - The image file record (already fetched + authorized by the caller).\n * @param res - Express response to write the encoded thumbnail into.\n * @param executionContext - Context for storage-provider resolution/errors.\n * @param next - Express `next` to forward pre-header errors to the error middleware.\n */\n private async serveImageThumbnail(\n file: File,\n res: Response,\n executionContext: ExecutionContext<any> | undefined,\n next: NextFunction | undefined,\n ): Promise<void> {\n this.logDebug('Serving image thumbnail', { fileId: file.fileId, size: file.size });\n\n try {\n const storageProvider = this.getStorageProviderForFile(file, executionContext as any);\n const downloadResult = await storageProvider.download(file, executionContext as any);\n const stream = downloadResult.stream;\n validateStream(stream, this.errorBuilder, executionContext as any, 'thumbnailSourceStream');\n\n // BUFFER the full source (this path can't stream — libvips needs the bytes).\n // The cap is a defensive backstop; the caller already pre-filtered on file.size.\n const sourceBuffer = await collectStreamToBuffer(stream, THUMBNAIL_SOURCE_MAX_BYTES);\n const thumbnail = await generateImageThumbnail(sourceBuffer);\n\n if (res.headersSent) {\n this.logger.warn('Response headers already sent, cannot serve thumbnail', {\n fileId: file.fileId,\n });\n return;\n }\n\n // Resize failure → serve the ORIGINAL bytes we already hold (degrade to full\n // image, never a 500). Only reachable for raster images (caller-gated).\n const body = thumbnail ? thumbnail.data : sourceBuffer;\n const contentType = thumbnail\n ? thumbnail.contentType\n : downloadResult.contentType || file.mimeType;\n if (!thumbnail) {\n this.logger.warn('Thumbnail generation failed; serving original image bytes', {\n fileId: file.fileId,\n mimeType: file.mimeType,\n });\n }\n\n // ── SECURITY (untrusted bytes) — identical to the streaming path: honour the\n // declared type (nosniff) and neutralise any directly-navigated document\n // (file-serve CSP). A generated webp is inert; the original-bytes fallback is a\n // raster image, so `inline` is always safe here (html/svg never reach this method).\n res.setHeader(WildoHeaderKeys.CONTENT_TYPE, contentType);\n res.setHeader('x-content-type-options', 'nosniff');\n res.setHeader('content-security-policy', FILE_SERVE_CONTENT_SECURITY_POLICY);\n res.setHeader(WildoHeaderKeys.CONTENT_LENGTH, body.length.toString());\n\n // Immutable, version-keyed cache — see `THUMBNAIL_CACHE_CONTROL`. `updatedAt`\n // participates in the ETag so replacing the image busts stale copies.\n res.setHeader(WildoHeaderKeys.CACHE_CONTROL, THUMBNAIL_CACHE_CONTROL);\n const version = file.updatedAt instanceof Date ? file.updatedAt.getTime() : '';\n res.setHeader(WildoHeaderKeys.ETAG, `\"thumb-${file.fileId}-${version}\"`);\n\n const filename = file.originalFilename || file.fileId || 'file';\n setContentDispositionHeader(res, filename, 'inline');\n\n res.end(body);\n } catch (error) {\n this.logger.error('Failed to serve image thumbnail', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n if (!res.headersSent) {\n if (next) {\n next(error as Error);\n return;\n }\n res.status(500).end();\n return;\n }\n throw error;\n }\n }\n\n /**\n * Build the internal execution context for a FILES (`REPOSITORY_ONLY`) repository\n * operation invoked as a side effect of an originating request (a resource CREATE\n * that generates a PDF, an upload handler, a link, a cleanup pass).\n *\n * The originating context carries two distinct concerns; this routes each correctly:\n *\n * - **Identity (`initiatorIds`) stays application-only.** The builder produces an\n * `INTERNALLY_INITIATED_REQUEST`, whose `ExecutionContext` invariant forbids the\n * user's `organizationId` / `userId` on `initiatorIds` (only `applicationId`).\n * Forwarding the user's full identity here 500'd every user-initiated file write.\n * `applicationId` is seeded from the originating context (or the single app tenant)\n * for a second reason: the FILES resource is APPLICATION-scoped, so a missing\n * `applicationId` would trigger `populateApplicationIdIfNeeded`'s internal\n * APPLICATION read, which would apply this op's scope map and fail (the APPLICATIONS\n * schema has no `organizationId`). Seeding it skips that read.\n * - **Scope (`scopeFields` → `contextResourcesFieldIdentifier`) carries the file's own\n * tenant scope.** A FILES record's `organizationId` / `userId` are scope fields that\n * the create DTO strips and `enrichDataWithContext` re-injects from the context map;\n * they are SECONDARY scopes (FILES' primary scope is `applicationId`), so they are\n * not auto-re-injected. Callers that know the file's scope (CREATE) pass it here so\n * the record is correctly tenant-scoped and `authorizeFileAccess` later matches the\n * caller's org; by-id operations omit it (they resolve by `_id`).\n *\n * `createForInternalRepositoryOperation` resolves the FILES `REPOSITORY_ONLY`\n * operation `REPOSITORY_ONLY`-preferred (URL-fallback); the URL-only resolver would\n * throw `RESOURCES_REGISTRY_OPERATION_PATH_NOT_FOUND` for the non-URL-bearing FILES\n * resource.\n */\n private async createInternalExecutionContext(\n operation: CoreResourceOperation,\n providedContext: ExecutionContext<any>,\n scopeFields?: Map<string, string>,\n ): Promise<ExecutionContext<any>> {\n const applicationId = providedContext.applicationId ?? this.appConfigService.applicationId;\n\n return this.executionContextCreator.createForInternalRepositoryOperation({\n resourceType: CoreResourceType.FILES,\n operationIdentifier: operation,\n initiatorIds: applicationId ? { applicationId } : null,\n contextResourcesFieldIdentifier: scopeFields,\n initiatorRoles: [\n {\n roles: [CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN],\n relatedPrimaryScope: ResourcePrimaryScope.APPLICATION,\n },\n ],\n });\n }\n\n /**\n * Create a new file record with status PENDING.\n * Called before upload starts to reserve the fileId.\n *\n * Scope can be provided at creation time (when known) or derived later\n * when linking to a resource via linkFileToResource().\n *\n * @param fileData - Initial file data (filename, mimeType, size, etc.)\n * @param executionContext - Execution context for authorization\n * @param options - Repository options\n * @returns Created file record with fileId\n */\n async createFile(\n fileData: {\n filename: string;\n originalFilename: string;\n mimeType: string;\n size: number;\n extension?: string;\n checksum?: string;\n /** Resolved storage provider. Falls back to default when omitted. */\n storageProvider?: FileStorageAccepted;\n // Scope identifiers - segregated (not hierarchical)\n // If not provided, will be derived when linking to resource\n scope?: FileScopeIdentifiers;\n // Legacy: organizationId for backward compatibility\n // Use scope.organizationId instead for new code\n organizationId?: string;\n } & FileUploaderOwnership,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n // Validate inputs (CRITICAL: Prevents invalid data propagation)\n const maxFileSize = resolveConfiguredMaxFileSize(this.appConfigService.config.storage?.maxFileSize);\n validateContentType(fileData.mimeType, this.errorBuilder, executionContext, 'mimeType');\n validateSize(fileData.size, maxFileSize, this.errorBuilder, executionContext, 'size');\n const hasExplicitUploadedBy = fileData.uploadedBy !== undefined;\n const hasExplicitUploaderEntityType = fileData.uploadedByEntityType !== undefined;\n if (hasExplicitUploadedBy !== hasExplicitUploaderEntityType) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_UPLOADER_FIELDS_INCONSISTENT,\n context: {\n // diagnostic (log-only)\n uploadedBy: fileData.uploadedBy,\n uploadedByEntityType: fileData.uploadedByEntityType,\n },\n }\n );\n }\n\n if (hasExplicitUploadedBy && hasExplicitUploaderEntityType) {\n validateUploadedBy(fileData.uploadedBy, this.errorBuilder, executionContext, 'uploadedBy');\n validateUploadedByEntityType(fileData.uploadedByEntityType, this.errorBuilder, executionContext, 'uploadedByEntityType');\n }\n\n // Validate scope if provided\n if (fileData.scope && !FileScopeUtils.validate(fileData.scope)) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_INVALID,\n context: {\n scope: fileData.scope, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Derive organizationId from scope or use legacy field\n const organizationId = fileData.scope?.organizationId || fileData.organizationId;\n if (organizationId) {\n validateOrganizationId(organizationId, this.errorBuilder, executionContext, 'organizationId');\n }\n\n // Derive applicationId from scope (always set after schema fix) or fall back to execution context.\n // applicationId is the top-level tenant isolation field — always required on every file record.\n const accessScope = this.deriveAccessScope(executionContext);\n const applicationId = fileData.scope?.applicationId ?? accessScope.applicationId;\n if (!applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n }\n );\n }\n\n this.logDebug('Creating file record', {\n filename: fileData.filename,\n primaryScope: fileData.scope?.primaryScope,\n organizationId,\n });\n\n // Extract extension from filename if not provided\n const extension = fileData.extension || this.extractExtension(fileData.originalFilename);\n\n // NOTE (insert-first): the file's identity is the Mongo-generated `_id` (surfaced\n // externally as the `fileId` virtual). `storageKey` embeds that identity, so it can\n // only be derived AFTER the row exists — it is computed + persisted in a follow-up\n // update below, not at insert time. (Previously a `fileId` was pre-generated here and\n // stored as a second identity, which both diverged from `_id` and — being a stripped\n // `excludeFromCreate` primary key — failed Mongoose's required-path validation.)\n const resolvedStorageProviderId = fileData.storageProvider ?? this.getDefaultStorageProvider().providerId;\n\n const derivedUploader = resolveFileUploaderPrincipal(executionContext);\n const uploaderPrincipal = hasExplicitUploadedBy && hasExplicitUploaderEntityType\n ? {\n uploadedBy: fileData.uploadedBy!,\n uploadedByEntityType: fileData.uploadedByEntityType!,\n }\n : derivedUploader;\n\n if (hasExplicitUploadedBy && hasExplicitUploaderEntityType\n && derivedUploader\n && (\n fileData.uploadedBy !== derivedUploader.uploadedBy\n || fileData.uploadedByEntityType !== derivedUploader.uploadedByEntityType\n )\n ) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_UPLOADER_MISMATCH,\n context: {\n // diagnostic (log-only)\n uploadedBy: fileData.uploadedBy,\n uploadedByEntityType: fileData.uploadedByEntityType,\n derivedUploadedBy: derivedUploader.uploadedBy,\n derivedUploadedByEntityType: derivedUploader.uploadedByEntityType,\n },\n }\n );\n }\n\n // Prepare file record data. No `fileId` (it is the virtual projection of the\n // Mongo-generated `_id`) and no `storageKey` (derived from `_id`, set post-insert).\n const fileRecord: Partial<File> = {\n filename: fileData.filename,\n originalFilename: fileData.originalFilename,\n mimeType: fileData.mimeType,\n size: fileData.size,\n extension: extension || undefined,\n checksum: fileData.checksum,\n storageProvider: resolvedStorageProviderId,\n status: FileStatus.PENDING,\n uploadedBy: uploaderPrincipal?.uploadedBy,\n uploadedByEntityType: uploaderPrincipal?.uploadedByEntityType,\n // Scope identifiers (segregated)\n primaryScope: fileData.scope?.primaryScope,\n applicationId,\n organizationId: organizationId,\n userId: fileData.scope?.userId,\n };\n\n // Create internal execution context for repository operation\n // Carry the file's OWN tenant scope (per its `primaryScope`) into the internal\n // context so the `organizationId` / `userId` scope fields — stripped from the FILES\n // create DTO and re-injected from the context map — land on the record. Sourced from\n // the explicit `fileData.scope` (already correct for the file's primaryScope: org for\n // ORGANIZATIONS, user-only for USER_SELF, neither for APPLICATION), so no spurious\n // scope is set. Without this the file is scope-less and `authorizeFileAccess` denies it.\n const createScopeFields = new Map<string, string>();\n if (fileData.scope?.organizationId) {\n createScopeFields.set('organizationId', fileData.scope.organizationId);\n }\n if (fileData.scope?.userId) {\n createScopeFields.set('userId', fileData.scope.userId);\n }\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.CREATE,\n executionContext,\n createScopeFields\n );\n\n // The file is persisted as TWO writes — insert (Mongo assigns `_id`, surfaced via the\n // `fileId` virtual) then a storageKey update derived from that identity. They MUST be\n // atomic: a crash between them would otherwise commit a `storageKey`-less row (the\n // pre-transaction design's regression). The wrapping transaction below makes them so.\n const persistFileWithStorageKey = async (\n writeOptions: RepositoryOptions | undefined,\n ): Promise<File> => {\n // Create file record via repository. Mongo generates `_id`; the `fileId` virtual\n // projects it, so `createdFile.fileId === String(_id)`.\n const createdFile = await this.filesRepository.create<File>(\n internalContext,\n fileRecord as File,\n writeOptions\n );\n\n // Now that the identity (`_id`, surfaced as `fileId`) exists, derive the storageKey and\n // persist it. This preserves the historical contract that a created file always carries a\n // storageKey — scope-derived when a scope is known at creation, else the bare identity\n // (`fileId`) as a fallback (re-derived with the full scope path by `linkFileToResource`\n // once the file is linked).\n const storageKey = fileData.scope\n ? FileScopeUtils.buildStoragePath(fileData.scope, createdFile.fileId)\n : createdFile.fileId;\n const withStorageKey = await this.filesRepository.update<File>(\n internalContext,\n { _id: createdFile.fileId },\n { storageKey } as Partial<File>,\n writeOptions\n );\n\n if (!withStorageKey) {\n // The row was just created under this same context and transaction, so a missing match\n // here is unexpected (e.g. a contextual-filter mismatch). Surface it rather than\n // silently returning a storageKey-less file: the file row still exists, but the gap is\n // logged.\n this.logger.warn?.('File record created but storageKey could not be persisted', {\n fileId: createdFile.fileId,\n });\n this.logDebug('File record created', { fileId: createdFile.fileId });\n return createdFile;\n }\n\n this.logDebug('File record created', { fileId: withStorageKey.fileId });\n return withStorageKey;\n };\n\n // Make the insert + storageKey update atomic. If the caller already supplied an active\n // transaction on the FILES store (e.g. file work cascaded from a resource mutation), both\n // writes join it; otherwise open a self-contained one so a crash between the two writes\n // cannot leave a storageKey-less row. `nestedBehavior: 'reuse'` is a safety net for an\n // ambient (AsyncLocalStorage-tracked) transaction not threaded through `options`.\n //\n // The store is resolved from the FILES resource rather than named: this used to read\n // `=== PersistenceAdapter.MONGODB` and open on `this.mongoDBService`, which is correct only\n // while FILES sits on MongoDB and inverts in silence the day it moves — the row would be\n // written by the FILES repository on one connection while the \"atomicity\" wrapping it came\n // from another.\n const filesStore = this.getFilesStore(executionContext);\n if (options?.transaction?.databaseType === filesStore.persistenceAdapter) {\n return persistFileWithStorageKey(options);\n }\n return filesStore.databaseService.executeTransaction(\n (transactionContext) => persistFileWithStorageKey({ ...options, transaction: transactionContext }),\n { nestedBehavior: 'reuse' }\n );\n }\n\n /**\n * The transaction-owning service for the FILES store.\n *\n * Resolved through the persistence unit of work, which is the one place that holds both\n * every adapter's database service and the resource → adapter mapping. Re-deriving either\n * here is what produced the `mongoDBService`-by-name coupling this replaced.\n *\n * Throws rather than degrading: every caller uses the returned service to establish\n * atomicity across two writes, and continuing without a transaction would leave exactly\n * the storageKey-less row the transaction exists to prevent — silently.\n */\n private getFilesStore(executionContext: ExecutionContext<any>): ResourcePersistenceResourceStore {\n const filesStore = this.resourcePersistenceUnitOfWork?.getDatabaseServiceForResource(\n CoreResourceType.FILES,\n );\n\n if (!filesStore) {\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message: 'No database service is available for the FILES resource store',\n resourceType: CoreResourceType.FILES,\n unitOfWorkBound: Boolean(this.resourcePersistenceUnitOfWork),\n },\n }\n );\n }\n\n return filesStore;\n }\n\n /**\n * Get file metadata by fileId.\n *\n * @param fileId - File identifier\n * @param executionContext - Execution context for authorization\n * @returns File metadata or null if not found\n */\n async getFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File | null> {\n this.logDebug('Getting file record', { fileId });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.READ,\n executionContext\n );\n\n // Read file record via repository. `fileId` is the `_id` virtual projection, so the\n // collection filter keys on `_id` (virtuals are not queryable).\n const file = await this.filesRepository.read<File>(\n internalContext,\n { _id: fileId },\n options\n );\n\n if (!file) {\n this.logDebug('File not found', { fileId });\n return null;\n }\n\n // Check authorization. A system-cascade file teardown (subject erasure) reaches this via\n // deleteFile/eraseFile/unlinkFileFromResource on an identity-less EC that would deny the subject's\n // OWN file; it forwards the owner it already verified at the listing gate through\n // `options.authoritativeFileScope`, so the deletion gate authorizes against that owner instead of\n // the empty EC. Every other (user-facing) caller leaves it undefined ⇒ authorize against the EC.\n const hasAccess = await this.authorizeFileAccess(file, executionContext, options?.authoritativeFileScope);\n if (!hasAccess) {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_ACCESS_DENIED,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n return file;\n }\n\n /**\n * Get multiple files by their IDs.\n *\n * @param fileIds - Array of file identifiers\n * @param executionContext - Execution context for authorization\n * @returns Array of file metadata\n */\n async batchGetFiles(\n fileIds: string[],\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File[]> {\n this.logDebug('Batch getting file records', { fileIds, count: fileIds.length });\n\n if (fileIds.length === 0) {\n return [];\n }\n\n // Filter and validate fileIds format before query — an optimization that avoids querying\n // for ids that cannot exist.\n //\n // `isValidResourceId` accepts BOTH ObjectId and UUID, so this is already adapter-neutral.\n // The previous comment claimed an \"ObjectId regex pattern\", which would have made this a\n // blocker for moving FILES to PostgreSQL (uuid ids). It reads as a coupling and is not one.\n const validFileIds = fileIds.filter(\n (id) => typeof id === 'string' && id.trim() !== '' && Resources_SharedUtils.isValidResourceId(id.trim())\n );\n\n // Early return if no valid fileIds after filtering\n if (validFileIds.length === 0) {\n return [];\n }\n\n const accessibleScopeFilter = this.buildAccessibleScopeFilter(executionContext);\n if (!accessibleScopeFilter) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n fileIdsCount: fileIds.length, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.READ,\n executionContext\n );\n\n // Add the narrowest tenant-aware filter we can BEFORE fetching.\n // This prevents cross-tenant prefetches for app-scoped files while preserving\n // legacy org-scoped rows until all persisted file records carry primaryScope.\n const files = await this.filesRepository.list<File>(\n internalContext,\n {\n // `fileId` values are `_id` strings (the virtual projection); query on `_id`.\n _id: { $in: validFileIds },\n ...accessibleScopeFilter,\n },\n options\n );\n\n // Filter by authorization\n const authorizedFiles: File[] = [];\n for (const file of files) {\n const hasAccess = await this.authorizeFileAccess(file, executionContext);\n if (hasAccess) {\n authorizedFiles.push(file);\n }\n }\n\n this.logDebug('Batch get completed', { requested: fileIds.length, found: files.length, authorized: authorizedFiles.length });\n return authorizedFiles;\n }\n\n /**\n * Update file status (e.g., PENDING -> UPLOADED, UPLOADED -> LINKED).\n *\n * @param fileId - File identifier\n * @param status - New status\n * @param executionContext - Execution context for authorization\n * @returns Updated file record\n */\n async updateFileStatus(\n fileId: string,\n status: FileStatus,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions,\n storagePlacement?: StorageUploadResult,\n ): Promise<File> {\n this.logDebug('Updating file status', { fileId, status });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Get current file record\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n const allowedTransitions = FILE_STATUS_TRANSITIONS[currentFile.status];\n if (!allowedTransitions?.includes(status)) {\n throw this.errorBuilder.buildError(\n ErrorType.BUSINESS_RULE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_INVALID_STATUS_TRANSITION,\n context: {\n // diagnostic (log-only)\n fileId,\n currentStatus: currentFile.status,\n requestedStatus: status,\n allowedTransitions,\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // Update file status via repository. `fileId` is the `_id` virtual projection, so the\n // collection filter keys on `_id` (virtuals are not queryable).\n const updatedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n {\n status,\n ...(storagePlacement\n ? {\n storageProvider: storagePlacement.provider,\n storageRef: storagePlacement.storageRef,\n }\n : {}),\n updatedAt: new Date(),\n } as Partial<File>,\n options\n );\n\n if (!updatedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to update file status',\n fileId,\n status,\n },\n }\n );\n }\n\n this.logDebug('File status updated', { fileId, oldStatus: currentFile.status, newStatus: status });\n return updatedFile;\n }\n\n /**\n * RAG removal seam — FILE-BINDING MUTATION. A link, unlink, delete or erase changes WHICH file (if\n * any) backs a `(resourceType, resourceId, fieldName)` tuple, so any chunks derived from the\n * PREVIOUS binding's extracted text are stale the moment the write lands and must not stay\n * retrievable (re-indexing from the new binding is Phase 3's write path; deletion is this phase's\n * whole job). No-op unless the tuple names a declared `.ragSource()` field — the intersection and\n * the shared failure/transaction contract (post-commit when `options` carries a transaction, inline\n * otherwise, log-at-ERROR never throw) live in `rag-chunk-removal.backend.utils.ts`.\n */\n private async runRagChunkRemovalForFileBinding(\n binding: { resourceType?: string | null; resourceId?: string | null; fieldName?: string | null },\n seam: string,\n options?: RepositoryOptions,\n ): Promise<void> {\n if (!this.ragChunkStore || !this.ragSourceFieldDetection) return;\n const { resourceType, resourceId, fieldName } = binding;\n if (!resourceType || !resourceId || !fieldName) return;\n await scheduleRagChunkRemovalForFields(\n {\n ragChunkStore: this.ragChunkStore,\n ragSourceFieldDetection: this.ragSourceFieldDetection,\n logger: this.logger,\n },\n {\n resourceType: resourceType as ResourceType,\n resourceIds: [resourceId],\n affectedFieldNames: [fieldName],\n seam,\n transaction: options?.transaction,\n },\n );\n }\n\n /**\n * Link a file to a resource (resource-integrated uploads).\n * Updates file status to LINKED, stores resource reference, and derives scope\n * from the parent resource's resourcePrimaryScope.\n *\n * Scope derivation:\n * - APPLICATION: applicationId from execution context\n * - ORGANIZATIONS: organizationId from execution context\n * - USER_SELF: userId + applicationId from execution context (no org — separate scope axis)\n *\n * @param fileId - File identifier\n * @param resourceType - Resource type\n * @param resourceId - Resource identifier\n * @param fieldName - Field name on the resource\n * @param executionContext - Execution context for authorization\n * @returns Updated file record\n */\n async linkFileToResource(\n fileId: string,\n resourceType: ResourceType,\n resourceId: string,\n fieldName: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Linking file to resource', { fileId, resourceType, resourceId, fieldName });\n\n // Validate inputs (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n validateResourceId(resourceId, this.errorBuilder, executionContext, 'resourceId');\n validateResourceType(resourceType, this.errorBuilder, executionContext, 'resourceType');\n validateFieldName(fieldName, this.errorBuilder, executionContext, 'fieldName');\n\n // Derive scope from parent resource's resourcePrimaryScope\n const derivedScope = this.deriveScopeFromParentResource(resourceType, executionContext);\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // CRITICAL: Use atomic update with status filter to prevent race conditions (Decision 2.4: Option A)\n // The repository's update() method internally uses findOneAndUpdate, so it's atomic\n // Filter includes status check: only updates if file is in UPLOADED status\n // This ensures no race condition between check and update\n\n /**\n * Updates file status, link fields, and scope atomically.\n *\n * @note MongoDB updates are atomic, so partial updates are not possible.\n * If the update fails, the entire operation fails atomically.\n */\n const updatedFile = await this.filesRepository.update<File>(\n internalContext,\n {\n _id: fileId,\n status: { $in: [FileStatus.UPLOADED, FileStatus.CLEAN] },\n },\n {\n linkedResourceType: resourceType,\n linkedResourceId: resourceId,\n linkedFieldName: fieldName,\n status: FileStatus.LINKED,\n updatedAt: new Date(),\n // Scope derived from parent resource\n primaryScope: derivedScope.primaryScope,\n applicationId: derivedScope.applicationId,\n organizationId: derivedScope.organizationId,\n userId: derivedScope.userId,\n // Update storageKey if scope wasn't set at creation time\n storageKey: FileScopeUtils.buildStoragePath(derivedScope, fileId),\n } as Partial<File>,\n options\n );\n\n if (!updatedFile) {\n // File was not in a linkable status (race condition or already linked)\n // Re-fetch to determine the reason and throw appropriate error\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Check if already linked to same resource (idempotent case)\n if (currentFile.status === FileStatus.LINKED &&\n currentFile.linkedResourceType === resourceType &&\n currentFile.linkedResourceId === resourceId &&\n currentFile.linkedFieldName === fieldName) {\n // Already linked to same resource - idempotent, return current file\n this.logDebug('File already linked to same resource (idempotent)', {\n fileId,\n resourceType,\n resourceId,\n fieldName,\n });\n return currentFile;\n }\n\n // Check if already linked to different resource (error case)\n if (currentFile.status === FileStatus.LINKED) {\n throw this.errorBuilder.buildError(\n ErrorType.BUSINESS_RULE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_ALREADY_LINKED,\n context: {\n // diagnostic (log-only)\n fileId,\n currentLinkedResourceType: currentFile.linkedResourceType,\n currentLinkedResourceId: currentFile.linkedResourceId,\n currentLinkedFieldName: currentFile.linkedFieldName,\n requestedResourceType: resourceType,\n requestedResourceId: resourceId,\n requestedFieldName: fieldName,\n },\n }\n );\n }\n\n // Wrong status (not UPLOADED)\n throw this.errorBuilder.buildError(\n ErrorType.BUSINESS_RULE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_IN_UPLOADED_STATUS,\n context: {\n // diagnostic (log-only)\n fileId,\n fileStatus: currentFile.status,\n expectedStatus: FileStatus.UPLOADED,\n resourceType,\n resourceId,\n },\n }\n );\n }\n\n // RAG removal seam — a (re-)link binds a NEW file to the tuple, so chunks derived from whatever\n // backed it before are stale and must not survive the re-link (plan §Removal-seam inventory).\n await this.runRagChunkRemovalForFileBinding(\n { resourceType, resourceId, fieldName },\n 'file-link',\n options,\n );\n\n this.logDebug('File linked to resource', { fileId, resourceType, resourceId });\n return updatedFile;\n }\n\n /**\n * Unlink a file from a resource.\n * Updates file status to ORPHANED and clears resource link fields.\n *\n * Note: Due to Mongoose behavior, optional fields set to `undefined` are ignored in updates.\n * We attempt to clear linked resource fields, but if schema validation prevents this,\n * the status change to ORPHANED is the authoritative indicator that the file is unlinked.\n *\n * @param fileId - File identifier\n * @param executionContext - Execution context for authorization\n * @returns Updated file record\n */\n async unlinkFileFromResource(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Unlinking file from resource', { fileId });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Get current file record\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // Update file to remove resource link and set status to ORPHANED\n // Note: Mongoose ignores undefined values in updates, and optional string fields don't accept null.\n // The status change to ORPHANED is the authoritative indicator that the file is no longer linked.\n // The linked resource fields may remain in the database but are considered stale/invalid when status is ORPHANED.\n // Future enhancement: If explicit field clearing is required, consider using MongoDB $unset operator\n // via direct Mongoose model access or repository enhancement.\n const updateData: Partial<File> = {\n status: FileStatus.ORPHANED,\n updatedAt: new Date(),\n };\n\n /**\n * Updates file status and clears link fields atomically.\n *\n * @note MongoDB updates are atomic, so partial updates are not possible.\n * If the update fails, the entire operation fails atomically.\n */\n const updatedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n updateData,\n options\n );\n\n if (!updatedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to unlink file from resource',\n fileId,\n },\n }\n );\n }\n\n // RAG removal seam — the tuple no longer has a backing file; its extracted-text chunks go with\n // the binding. The tuple is read from the PRE-unlink row (the write above clears/staleness-marks it).\n await this.runRagChunkRemovalForFileBinding(\n {\n resourceType: currentFile.linkedResourceType,\n resourceId: currentFile.linkedResourceId,\n fieldName: currentFile.linkedFieldName,\n },\n 'file-unlink',\n options,\n );\n\n this.logDebug('File unlinked from resource', { fileId });\n return updatedFile;\n }\n\n /**\n * Delete a file (soft delete - marks as DELETED).\n * Physical deletion from storage happens in cleanup batch job.\n *\n * @param fileId - File identifier\n * @param executionContext - Execution context for authorization\n * @returns Deleted file record\n */\n async deleteFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Soft deleting file record', { fileId });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Get current file record\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // Soft delete: update status and set deletedAt\n\n /**\n * Updates file status to DELETED atomically.\n *\n * @note MongoDB updates are atomic, so partial updates are not possible.\n * If the update fails, the entire operation fails atomically.\n */\n const deletedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n {\n status: FileStatus.DELETED,\n deletedAt: new Date(),\n updatedAt: new Date(),\n } as Partial<File>,\n options\n );\n\n if (!deletedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to delete file',\n fileId,\n },\n }\n );\n }\n\n // RAG removal seam — a DELETED file no longer backs its linked field (the cleanup batch will\n // hard-delete the bytes), so text extracted from it must stop being retrievable now. A file that\n // was never linked to a RAG-source field no-ops. Beyond the plan's link/unlink rows, wired\n // deliberately: the row-delete and impersonalize seams cover the ORCHESTRATED deleteFile calls,\n // but a direct deleteFile on a linked file reaches neither.\n await this.runRagChunkRemovalForFileBinding(\n {\n resourceType: currentFile.linkedResourceType,\n resourceId: currentFile.linkedResourceId,\n fieldName: currentFile.linkedFieldName,\n },\n 'file-delete',\n options,\n );\n\n this.logDebug('File soft deleted', { fileId });\n return deletedFile;\n }\n\n /**\n * ERASE a file for privacy (gate **G-FILE**) — a soft delete that also scrubs the file row's OWN\n * personal data, in one write.\n *\n * Deliberately distinct from {@link deleteFile} rather than a flag on it, because the two mean\n * different things and must not drift:\n * - `deleteFile` is a LIFECYCLE delete. The row is on its way out but its provenance\n * (`originalFilename`, `uploadedBy`) is still legitimate history — an admin auditing \"who\n * uploaded what, and what happened to it\" needs exactly those fields.\n * - `eraseFile` is a PRIVACY erasure. The filename IS personal data (`passport-jane-doe.pdf`\n * identifies its subject as surely as the bytes do), and so is the uploader link. Keeping them\n * for the weeks until the cleanup batch runs means the erasure only *looks* complete.\n *\n * `filename` / `originalFilename` are REQUIRED (`min(1)`), so they are overwritten with the shared\n * {@link ERASED_FILE_NAME_PLACEHOLDER} constant rather than nulled — nulling would need a schema\n * reshape and would make every erased file distinguishable from every other by its emptiness.\n * `uploadedBy` and `uploadedByEntityType` are cleared TOGETHER: the schema's `validateUploaderPair`\n * refinement requires both or neither, and clearing one alone would make the row unwritable.\n *\n * The blob itself is removed by the existing cleanup batch, exactly as for `deleteFile` — an erasure\n * must never mix a DB rollback with non-transactional storage side effects.\n *\n * Idempotent: erasing an already-erased file rewrites the same terminal values.\n */\n async eraseFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Erasing file record for privacy', { fileId });\n\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n const erasedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n {\n status: FileStatus.DELETED,\n deletedAt: new Date(),\n updatedAt: new Date(),\n filename: ERASED_FILE_NAME_PLACEHOLDER,\n originalFilename: ERASED_FILE_NAME_PLACEHOLDER,\n uploadedBy: undefined,\n uploadedByEntityType: undefined,\n } as Partial<File>,\n options\n );\n\n if (!erasedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to erase file',\n fileId,\n },\n }\n );\n }\n\n // RAG removal seam — a privacy erasure of the file makes any text extracted from it exactly the\n // personal data the erasure exists to remove; the chunk set goes in the same decision. Usually\n // redundant with the impersonalize seam that invoked this erasure (idempotent), and load-bearing\n // for a DIRECT eraseFile call, which reaches no other seam.\n await this.runRagChunkRemovalForFileBinding(\n {\n resourceType: currentFile.linkedResourceType,\n resourceId: currentFile.linkedResourceId,\n fieldName: currentFile.linkedFieldName,\n },\n 'file-erase',\n options,\n );\n\n this.logDebug('File erased', { fileId });\n return erasedFile;\n }\n\n /**\n * Permanently delete a file by removing the blob first, then deleting the\n * metadata row. This is intentionally reserved for post-commit cleanup flows\n * such as the cleanup batch, not inline resource transactions.\n */\n async hardDeleteFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Hard deleting file record and storage', { fileId });\n\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n const readContext = await this.createInternalExecutionContext(\n CoreResourceOperation.READ,\n executionContext\n );\n const currentFile = await this.filesRepository.read<File>(\n readContext,\n { _id: fileId },\n options\n );\n\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Hard-delete now flows through the storage provider seam so future slices can\n // swap backend resolution without reopening the cleanup contract.\n try {\n const storageProvider = this.getStorageProviderForFile(currentFile, executionContext);\n await storageProvider.delete(currentFile, executionContext);\n } catch (error) {\n if (!isWildoBackendError(error) || error.type !== ErrorType.NOT_FOUND) {\n throw error;\n }\n\n this.logDebug('File blob already missing during hard delete, continuing metadata cleanup', {\n fileId,\n });\n }\n\n const deleteContext = await this.createInternalExecutionContext(\n CoreResourceOperation.DELETE,\n executionContext\n );\n const deletedFileId = await this.filesRepository.delete(\n deleteContext,\n { _id: fileId },\n options\n );\n\n if (!deletedFileId) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to hard delete file',\n fileId,\n },\n }\n );\n }\n\n this.logDebug('File hard deleted from storage and metadata', { fileId });\n return currentFile;\n }\n\n /**\n * List files for a specific resource.\n *\n * @param resourceType - Resource type\n * @param resourceId - Resource identifier\n * @param fieldName - Optional field name filter\n * @param executionContext - Execution context for authorization\n * @returns Array of file metadata\n */\n async listFilesForResource(\n resourceType: ResourceType,\n resourceId: string,\n fieldName: string | undefined,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File[]> {\n if (!executionContext) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n {} as ExecutionContext<any>,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Execution context is required for listFilesForResource',\n },\n }\n );\n }\n\n this.logDebug('Listing files for resource', { resourceType, resourceId, fieldName });\n\n // Validate inputs (CRITICAL: Prevents query injection and database errors)\n validateResourceId(resourceId, this.errorBuilder, executionContext, 'resourceId');\n validateResourceType(resourceType, this.errorBuilder, executionContext, 'resourceType');\n if (fieldName) {\n validateFieldName(fieldName, this.errorBuilder, executionContext, 'fieldName');\n }\n\n // A system-cascade file teardown (subject erasure, cross-scope delete) runs on an\n // internally_initiated_request EC, whose constructor FORBIDS user/organization identity on\n // `initiatorIds` — only `applicationId` is allowed. So `deriveScopeFromParentResource` cannot read\n // the owner from the EC and would fail closed with FILE_SCOPE_IDENTIFIER_MISSING, aborting the\n // whole erasure transaction before the subject is scrubbed. The resource ROW being torn down\n // carries its OWN scope FK (a USER_SELF row's `userId`, an org-scoped row's `organizationId`) — the\n // authoritative owner of that row's files. Read it and hand it to the scope derivation as a\n // fallback. This is the single chokepoint every delete/impersonalize/deleteMany file teardown funnels\n // through, so the recovery is unbypassable rather than threaded through each cascade site. It costs\n // one extra read ONLY on the system path — an ordinary request already carries the owner on its EC,\n // so `loadParentResourceRowForScopeFallback` returns undefined and performs no read.\n const parentResourceRowForScope = await this.loadParentResourceRowForScopeFallback(\n resourceType,\n resourceId,\n executionContext,\n options,\n );\n const derivedScope = this.deriveScopeFromParentResource(resourceType, executionContext, parentResourceRowForScope);\n const scopeFilter = this.buildFilterForFileScope(derivedScope);\n if (!scopeFilter) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_DERIVATION_FAILED,\n }\n );\n }\n\n // Build filter\n // Be defensive against malformed persisted rows where link metadata was\n // written but status drifted from LINKED. Delete-time cleanup must still be\n // able to discover those rows by parent ownership.\n const filter: any = {\n linkedResourceType: resourceType,\n linkedResourceId: resourceId,\n status: {\n $in: [FileStatus.LINKED, FileStatus.UPLOADED, FileStatus.CLEAN],\n },\n ...scopeFilter,\n };\n\n if (fieldName) {\n filter.linkedFieldName = fieldName;\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.LIST,\n executionContext\n );\n\n // Apply the linked resource's derived scope to the repository query before fetch.\n // This keeps app-scoped parents from going through an org-only path.\n const files = await this.filesRepository.list<File>(\n internalContext,\n filter,\n options\n );\n\n // Filter by authorization — against the SCOPE WE DERIVED (the parent resource's owner), not the raw\n // EC. `listFilesForResource` is exclusively a system-cascade file-teardown path (delete/impersonalize),\n // whose EC carries no owner identity; deriving the access scope from that EC would deny the subject's\n // OWN file and silently retain PII. `derivedScope` is the authoritative owner (from the row on the\n // system path, from the EC on any owner-bearing path) and is exactly what the file query above was\n // scoped by, so this re-confirms that scoping rather than trusting the empty EC.\n const authorizedFiles: File[] = [];\n for (const file of files) {\n const hasAccess = await this.authorizeFileAccess(file, executionContext, {\n applicationId: derivedScope.applicationId,\n organizationId: derivedScope.organizationId,\n userId: derivedScope.userId,\n });\n if (hasAccess) {\n authorizedFiles.push(file);\n }\n }\n\n this.logDebug('List files for resource completed', { resourceType, resourceId, found: files.length, authorized: authorizedFiles.length });\n return authorizedFiles;\n }\n\n /**\n * Authorize file access based on file's primaryScope.\n *\n * Access rules by primaryScope:\n * - APPLICATION: User must have access to the application\n * - ORGANIZATIONS: User must belong to the organization\n * - USER_SELF: User must be the owner (userId match) — no org check (separate scope axis)\n *\n * Fallback (no primaryScope): Uses legacy organizationId match\n *\n * @param file - File record\n * @param executionContext - Execution context for authorization\n * @returns true if access is allowed\n */\n async authorizeFileAccess(\n file: File,\n executionContext: ExecutionContext<any>,\n /**\n * The AUTHORITATIVE owner to check the file against, supplied ONLY by the system-cascade teardown\n * path ({@link listFilesForResource}, whose sole callers are the delete/impersonalize file teardown).\n * That path runs on an identity-less `internally_initiated_request` EC, so `deriveAccessScope` yields\n * no owner and this check would deny the SUBJECT'S OWN file — silently retaining PII while the erasure\n * reports success. The teardown has already resolved the owner from the row being torn down (the same\n * value the file query was scoped by), so authorizing against it re-confirms the query's own scoping\n * rather than trusting the empty EC. A present EC owner always wins for every other caller — this\n * override is `undefined` on the two non-teardown callers, so their behaviour is unchanged.\n */\n authoritativeScopeOverride?: { applicationId?: string; organizationId?: string; userId?: string },\n ): Promise<boolean> {\n const accessScope = authoritativeScopeOverride ?? this.deriveAccessScope(executionContext);\n\n // Legacy scope-less rows are tolerated only when they still carry a concrete\n // organization owner. Missing organization ownership is treated as malformed\n // persisted data and must fail closed.\n if (!file.primaryScope) {\n if (!file.organizationId || !accessScope.organizationId) {\n this.logDebug('File access denied: missing organization ownership on legacy file', {\n fileOrganizationId: file.organizationId,\n requestOrganizationId: accessScope.organizationId,\n });\n return false;\n }\n\n if (file.organizationId !== accessScope.organizationId) {\n this.logDebug('File access denied: organization mismatch (legacy)', {\n fileOrganizationId: file.organizationId,\n requestOrganizationId: accessScope.organizationId,\n });\n return false;\n }\n return true;\n }\n\n // Scope-based authorization\n switch (file.primaryScope) {\n case ResourcePrimaryScope.APPLICATION:\n if (!file.applicationId || file.applicationId !== accessScope.applicationId) {\n this.logDebug('File access denied: application mismatch', {\n fileApplicationId: file.applicationId,\n requestApplicationId: accessScope.applicationId,\n });\n return false;\n }\n return true;\n\n case ResourcePrimaryScope.ORGANIZATIONS:\n // ORGANIZATIONS scope: user must belong to the organization\n if (file.organizationId !== accessScope.organizationId) {\n this.logDebug('File access denied: organization mismatch', {\n fileOrganizationId: file.organizationId,\n requestOrganizationId: accessScope.organizationId,\n });\n return false;\n }\n return true;\n\n case ResourcePrimaryScope.USER_SELF:\n // USER_SELF scope: access is granted iff the caller IS the owner. USER_SELF and\n // ORGANIZATIONS are independent primary-scope axes, so there is NO org check here —\n // a self-owned file carries no org. `applicationId` tenant isolation is enforced\n // upstream (batchGetFiles / access-scope resolution).\n if (file.userId !== accessScope.userId) {\n this.logDebug('File access denied: user mismatch', {\n fileUserId: file.userId,\n requestUserId: accessScope.userId,\n });\n return false;\n }\n return true;\n\n default:\n // Unknown scope - deny access\n this.logDebug('File access denied: unknown primaryScope', {\n primaryScope: file.primaryScope,\n });\n return false;\n }\n }\n\n /**\n * Convert File record to FileMetadata response format.\n * Used by the getMetadata endpoint.\n *\n * @param file - File record\n * @returns FileMetadata object\n */\n toMetadataResponse(file: File): {\n fileId: string;\n filename: string;\n size: number;\n mimeType: string;\n extension?: string;\n checksum?: string;\n url?: string;\n thumbnailUrl?: string;\n nature: FileDisplayNature;\n width?: number;\n height?: number;\n duration?: number;\n pageCount?: number;\n uploadedAt: Date;\n uploadedBy?: string;\n uploadedByEntityType?: FileUploaderEntityType;\n } {\n // Infer nature from MIME type if not stored on the file record\n // Uses the shared resolveFileDisplayNature() utility (single source of truth)\n const nature: FileDisplayNature = (file.nature as FileDisplayNature) ?? resolveFileDisplayNature(undefined, file.mimeType);\n\n return {\n fileId: file.fileId,\n filename: file.originalFilename || file.filename,\n size: file.size,\n mimeType: file.mimeType,\n extension: file.extension,\n checksum: file.checksum,\n url: file.url,\n thumbnailUrl: file.thumbnailUrl,\n nature,\n width: file.width,\n height: file.height,\n duration: file.duration,\n pageCount: file.pageCount,\n uploadedAt: file.uploadedAt,\n uploadedBy: file.uploadedBy,\n uploadedByEntityType: file.uploadedByEntityType,\n };\n }\n\n /**\n * Derive access scope from execution context.\n * Extracts all scope identifiers for authorization checks.\n *\n * @param executionContext - Execution context\n * @returns Access scope information with all identifiers\n */\n protected deriveAccessScope(executionContext: ExecutionContext<any>): {\n applicationId?: string;\n organizationId?: string;\n userId?: string;\n } {\n const organizationId = this.resourceOperationHelper.getInitiatorId(executionContext, 'organization');\n const userId = this.resourceOperationHelper.getInitiatorId(executionContext, 'user');\n // Fall back to the single backend application's id when the execution context\n // doesn't carry one (e.g. a USER_REQUEST EC, whose initiatorIds hold org/user but\n // not applicationId). Mirrors `PdfGeneratedFileWriterBackendService` — there is\n // exactly one application per backend, so `appConfigService.applicationId` is the\n // correct anchor for `applicationId`-scoped file resolution + access checks.\n const applicationId = executionContext.applicationId || this.appConfigService.applicationId;\n\n return {\n applicationId,\n organizationId,\n userId,\n };\n }\n\n /**\n * Build the narrowest repository filter we can from the caller's accessible scope.\n * This keeps prefetching tenant-aware even before per-row authorization runs.\n */\n protected buildAccessibleScopeFilter(executionContext: ExecutionContext<any>): Record<string, unknown> | null {\n const accessScope = this.deriveAccessScope(executionContext);\n const scopeBranches: Record<string, unknown>[] = [];\n\n if (accessScope.applicationId) {\n scopeBranches.push({\n primaryScope: ResourcePrimaryScope.APPLICATION,\n applicationId: accessScope.applicationId,\n });\n }\n\n if (accessScope.organizationId) {\n // Keep legacy org-only rows reachable until all file rows carry primaryScope.\n scopeBranches.push({\n organizationId: accessScope.organizationId,\n });\n }\n\n if (scopeBranches.length === 0) {\n return null;\n }\n\n return scopeBranches.length === 1 ? scopeBranches[0] : { $or: scopeBranches };\n }\n\n protected buildFilterForFileScope(scope: FileScopeIdentifiers): Record<string, unknown> | null {\n switch (scope.primaryScope) {\n case ResourcePrimaryScope.APPLICATION:\n return scope.applicationId\n ? {\n primaryScope: ResourcePrimaryScope.APPLICATION,\n applicationId: scope.applicationId,\n }\n : null;\n case ResourcePrimaryScope.ORGANIZATIONS:\n return scope.organizationId\n ? {\n organizationId: scope.organizationId,\n }\n : null;\n case ResourcePrimaryScope.USER_SELF:\n // USER_SELF files are keyed by owner (userId) only — no org (separation of concern).\n return scope.userId\n ? {\n primaryScope: ResourcePrimaryScope.USER_SELF,\n userId: scope.userId,\n }\n : null;\n default:\n return null;\n }\n }\n\n /**\n * Recover a scoped resource's owner from the ROW when the EC cannot supply it — the system-cascade\n * file-teardown path (subject erasure, cross-scope delete). Such a cascade runs on an\n * `internally_initiated_request` EC, whose constructor is fail-closed and REJECTS user/organization\n * identity on `initiatorIds` (only `applicationId` is allowed), because the initiator of a system\n * operation is the SYSTEM, not the org/user being targeted. So {@link deriveScopeFromParentResource}\n * has no owner to read from the EC and fails closed with FILE_SCOPE_IDENTIFIER_MISSING — which,\n * inside an erasure, rolls back the whole transaction before the subject is scrubbed.\n *\n * Returns `undefined` — and performs NO read — whenever the EC already carries the owner (every\n * ordinary request, and any APPLICATION-scoped resource, whose id is always available from the single\n * backend). Only a genuinely owner-less EC over a USER_SELF/ORGANIZATIONS resource triggers the read,\n * so the hot path is unchanged.\n *\n * Fail-open to `undefined` on any obstacle (missing repository, no READ support, absent row, read\n * error): the caller then runs the EC-only derivation, which still fails closed exactly as before.\n * This helper only ADDS a recovery; it never weakens the existing guard.\n */\n private async loadParentResourceRowForScopeFallback(\n resourceType: ResourceType,\n resourceId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions,\n ): Promise<Record<string, unknown> | undefined> {\n const primaryScope =\n this.resourcesRegistry.getResourceConfiguration(resourceType)?.resourcePrimaryScope\n ?? ResourcePrimaryScope.ORGANIZATIONS;\n\n const accessScope = this.deriveAccessScope(executionContext);\n const ecAlreadyCarriesOwner =\n primaryScope === ResourcePrimaryScope.APPLICATION\n || (primaryScope === ResourcePrimaryScope.USER_SELF && !!accessScope.userId)\n || (primaryScope === ResourcePrimaryScope.ORGANIZATIONS && !!accessScope.organizationId);\n if (ecAlreadyCarriesOwner) {\n return undefined;\n }\n\n const repository = this.repositoriesRegistry.getRepository(resourceType);\n if (!repository?.supportsOperation(CoreResourceOperation.READ)) {\n return undefined;\n }\n\n try {\n const row = await repository.read<Record<string, unknown>>(executionContext, resourceId, options);\n return row ?? undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Derive file scope from parent resource's resourcePrimaryScope.\n *\n * Scope derivation rules:\n * - APPLICATION: sets applicationId from execution context\n * - ORGANIZATIONS: sets organizationId from execution context (or the row's own FK — system cascade)\n * - USER_SELF: sets userId + applicationId from execution context (no org — separate scope axis; or\n * the row's own FK — system cascade)\n *\n * @param resourceType - Parent resource type\n * @param executionContext - Execution context for scope values\n * @param parentResourceRow - The row being torn down; its own scope FK is used as a FALLBACK owner\n * only when the EC carries none (system cascade). A present EC owner always wins.\n * @returns FileScopeIdentifiers derived from parent resource\n */\n protected deriveScopeFromParentResource(\n resourceType: ResourceType,\n executionContext: ExecutionContext<any>,\n /**\n * The resource row being torn down, supplied ONLY by system-cascade paths whose EC carries no\n * owner identity (see the caller comment in {@link listFilesForResource}). Its own scope FK is the\n * authoritative owner of the row's files. Used strictly as a FALLBACK: a present EC owner always\n * wins, so every ordinary request behaves exactly as before this parameter existed.\n */\n parentResourceRow?: Record<string, unknown>,\n ): FileScopeIdentifiers {\n // Get parent resource configuration to find its primaryScope\n const resourceConfig = this.resourcesRegistry.getResourceConfiguration(resourceType);\n\n // Get primaryScope from resource configuration\n // Default to ORGANIZATIONS if not specified\n const primaryScope = resourceConfig?.resourcePrimaryScope || ResourcePrimaryScope.ORGANIZATIONS;\n\n const accessScope = this.deriveAccessScope(executionContext);\n\n // The row's value for its OWN primary-scope FK — `userId` for USER_SELF, `organizationId` for\n // ORGANIZATIONS — resolved through the single named mapping so it can never drift from the write\n // path. Stored FKs are ObjectIds; normalize to the string form the EC-derived scope also uses.\n const rowScopeFieldIdentifier = PRIMARY_SCOPE_TO_FIELD_IDENTIFIER[primaryScope];\n const rowScopeRaw = parentResourceRow?.[rowScopeFieldIdentifier];\n const rowScopeValue = rowScopeRaw != null ? String(rowScopeRaw) : undefined;\n\n switch (primaryScope) {\n case ResourcePrimaryScope.APPLICATION:\n if (!accessScope.applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n return {\n primaryScope: ResourcePrimaryScope.APPLICATION,\n applicationId: accessScope.applicationId,\n };\n\n case ResourcePrimaryScope.ORGANIZATIONS: {\n // EC owner wins; fall back to the torn-down row's own organization FK for a system cascade.\n const organizationId = accessScope.organizationId ?? rowScopeValue;\n if (!organizationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n if (!accessScope.applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n return {\n primaryScope: ResourcePrimaryScope.ORGANIZATIONS,\n applicationId: accessScope.applicationId,\n organizationId,\n };\n }\n\n case ResourcePrimaryScope.USER_SELF: {\n // USER_SELF and ORGANIZATIONS are independent primary-scope axes (separation of\n // concern): a self-owned file is owned by the USER, not an org. Require user\n // (owner) + applicationId (tenant/bucket anchor); never read/persist an org.\n // EC owner wins; fall back to the torn-down row's own user FK for a system cascade — the\n // subject-erasure path, whose EC is forbidden from carrying the user identity.\n const userId = accessScope.userId ?? rowScopeValue;\n if (!userId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n if (!accessScope.applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n return {\n primaryScope: ResourcePrimaryScope.USER_SELF,\n applicationId: accessScope.applicationId,\n userId,\n };\n }\n\n default:\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message: 'File scope derivation only supports APPLICATION, ORGANIZATIONS, and USER_SELF resources',\n resourceType,\n primaryScope,\n },\n }\n );\n }\n }\n\n /**\n * Extract file extension from filename.\n *\n * @param filename - Filename with or without extension\n * @returns Extension without dot, or empty string if none\n */\n private extractExtension(filename: string): string {\n const lastDot = filename.lastIndexOf('.');\n if (lastDot === -1 || lastDot === filename.length - 1) {\n return '';\n }\n return filename.substring(lastDot + 1).toLowerCase();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"files.backend.service.js","sourceRoot":"","sources":["../../../../../src/files/services/files.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAgB,SAAS,EAAE,2BAA2B,EAAsD,oBAAoB,EAAE,iCAAiC,EAAE,cAAc,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5V,OAAO,EAAQ,UAAU,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,0BAA0B,EAAwB,cAAc,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC5N,OAAO,EAAE,wBAAwB,EAAoD,MAAM,0BAA0B,CAAC;AACtH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,C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stored in external storage, this service tracks metadata in MongoDB.\n *\n * Features:\n * - File upload coordination\n * - File metadata management\n * - File linking to resources\n * - File access authorization\n * - File lifecycle management (status tracking)\n */\n\nimport { injectable, inject, optional } from 'inversify';\nimport type { Response, NextFunction } from 'express';\nimport type { Readable } from 'stream';\nimport { CoreResourceOperation, CoreResourceType, ResourceType, ErrorType, ErrorCustomMessageReference, FileUploaderEntityType, type FileUploaderOwnership, ResourcePrimaryScope, PRIMARY_SCOPE_TO_FIELD_IDENTIFIER, CORE_APP_ROLES, Resources_SharedUtils, isOrganizationWideRoleInfo, isWildoBackendError, WildoHeaderKeys } from '@wildo-ai/saas-models';\nimport { File, FileStatus, FILE_STATUS_TRANSITIONS, FILE_LINKABLE_STATUSES, FILE_DOWNLOADABLE_STATUSES, FileScopeIdentifiers, FileScopeUtils, FileServeVariant, ERASED_FILE_NAME_PLACEHOLDER } from '@wildo-ai/saas-models';\nimport { resolveFileDisplayNature, type FileDisplayNature, type 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, projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport { ResourceOperationHelperBackendService } from '~wildo-backend-lib/base-classes/services/resource-operations-helper.backend.service';\nimport type { BackendResourceRepository } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport { RepositoryOptions } from '~wildo-backend-lib/base-classes/models/repositories.backend.schemas';\nimport { validateFileId, validateResourceId, validateResourceType, validateFieldName, validateSize, validateUploadedBy, validateUploadedByEntityType, validateOrganizationId, validateContentType, resolveConfiguredMaxFileSize, validateStream } from '~wildo-backend-lib/files/utils/file-validation.utils';\nimport { setContentDispositionHeader } from '~wildo-backend-lib/files/utils/file-upload.utils';\nimport { resolveFileUploaderPrincipal } from '~wildo-backend-lib/files/utils/file-uploader.utils';\nimport { generateImageThumbnail, collectStreamToBuffer, isThumbnailableImage, THUMBNAIL_SOURCE_MAX_BYTES } from '~wildo-backend-lib/files/utils/image-thumbnail.backend.utils';\nimport { getFileFieldSchemaMetadataByPath } from '~wildo-backend-lib/files/utils/file-field-schema-path.backend.utils';\nimport { AppConfigurationService } from '~wildo-backend-lib/config/services/app-configuration.backend.service';\nimport { FileStorageRouterBackendService } from '~wildo-backend-lib/files/storage/file-storage-router.backend.service';\nimport type { IFileStorageProvider, StorageUploadResult } from '~wildo-backend-lib/files/storage/file-storage-provider.types';\nimport { ResourcePersistenceUnitOfWorkBackendService } from '~wildo-backend-lib/databases/services/resource-persistence-unit-of-work.backend.service';\nimport type { ResourcePersistenceResourceStore } from '~wildo-backend-lib/databases/services/resource-persistence-unit-of-work.backend.service';\nimport type { RagSourceFieldDetectionBackendService } from '~wildo-backend-lib/files/services/rag-source-field-detection.backend.service';\nimport type { RagChunkStoreBackendService } from '~wildo-backend-lib/rag/services/rag-chunk-store.backend.service';\nimport { scheduleRagChunkRemovalForFields } from '~wildo-backend-lib/rag/utils/rag-chunk-removal.backend.utils';\n\n/**\n * Content-Security-Policy applied to EVERY file-byte response (see\n * `FilesBackendService.streamFileToResponse`). `default-src 'none'` blocks all\n * subresource loads + inline/script execution; `sandbox` (with NO `allow-*`\n * tokens) drops the response into a fully-restricted sandbox if it is navigated\n * to directly at the top level — so an attacker-uploaded HTML/SVG can never run\n * script, submit a form, or navigate. Media loaded via `<img>`/`<video>` is\n * unaffected: those are governed by the EMBEDDING page's CSP, not this response's.\n * Same pattern GitHub/Dropbox use for user-uploaded content.\n */\nconst FILE_SERVE_CONTENT_SECURITY_POLICY = \"default-src 'none'; sandbox\";\n\n/**\n * Media types that must NEVER be served `inline`, even when a preview is\n * requested, because a browser parses them into an ACTIVE document context that\n * can execute script (the classic stored-XSS-via-upload vector). They are forced\n * to `attachment` (download) instead. Safe media (`image/*` except SVG, `video/*`,\n * `audio/*`, `application/pdf`) keep the requested `inline` disposition.\n * Matched against the leading media type only (`; charset=…` params ignored).\n */\nconst DANGEROUS_INLINE_CONTENT_TYPES = new Set<string>([\n 'text/html',\n 'application/xhtml+xml',\n 'image/svg+xml',\n]);\n\n/** True when `contentType` must not be rendered inline (see the set above). */\nfunction isDangerousInlineContentType(contentType: string | undefined): boolean {\n if (!contentType) return false;\n const mediaType = contentType.split(';', 1)[0]!.trim().toLowerCase();\n return DANGEROUS_INLINE_CONTENT_TYPES.has(mediaType);\n}\n\n/**\n * Cache policy for a generated thumbnail response: `private` (auth-gated bytes —\n * never a shared/CDN cache), fresh for a day, and `immutable` because a thumbnail is\n * fully determined by the file's id + version. The response ETag encodes both, so a\n * client holding a still-fresh thumbnail never revalidates; replacing the underlying\n * image bumps `updatedAt`, which changes the ETag and busts the cache. Applied ONLY\n * to the thumbnail path — the original-bytes path relies on the storage\n * ETag/Last-Modified it already forwards.\n */\nconst THUMBNAIL_CACHE_CONTROL = 'private, max-age=86400, immutable';\n\n@injectable()\nexport class FilesBackendService {\n protected logDebug: (message: string, context?: Record<string, unknown>) => void;\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.ResourceRegistryService)\n private readonly resourcesRegistry: ResourcesRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.RepositoriesRegistryHandlerService)\n private readonly repositoriesRegistry: RepositoriesRegistryHandlerBackendService,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService)\n private readonly executionContextCreator: ExecutionContextCreatorBackendService,\n @inject(SAAS_SERVICE_TYPES.ResourceOperationHelperService)\n private readonly resourceOperationHelper: ResourceOperationHelperBackendService,\n @inject(SAAS_SERVICE_TYPES.FileStorageRouter)\n private readonly fileStorageRouter: FileStorageRouterBackendService,\n @inject(SAAS_SERVICE_TYPES.AppConfigService)\n private readonly appConfigService: AppConfigurationService,\n @inject(SAAS_SERVICE_TYPES.ResourcePersistenceUnitOfWorkService)\n @optional()\n private readonly resourcePersistenceUnitOfWork?: ResourcePersistenceUnitOfWorkBackendService,\n // RAG derived-data tier (plan D3): file link/unlink/delete/erase mutate WHICH file backs a\n // FILE_EXTRACTION `.ragSource()` field, so the affected field's chunk set is removed in the same\n // decision (seam helper below). `@optional()` keeps minimal test containers constructing — the\n // seams no-op without the pair, and the startup capability probe owns refusing a real\n // application whose RAG-source resources have no usable store.\n @inject(SAAS_SERVICE_TYPES.RagSourceFieldDetectionService)\n @optional()\n private readonly ragSourceFieldDetection?: RagSourceFieldDetectionBackendService,\n @inject(SAAS_SERVICE_TYPES.RagChunkStoreService)\n @optional()\n private readonly ragChunkStore?: RagChunkStoreBackendService,\n ) {\n this.logDebug = this.logger.debugByType('FilesBackendService');\n this.logger.setDebugTypeLogging('FilesBackendService', false);\n\n this.logDebug('FilesBackendService initialized');\n }\n\n /**\n * Get the files repository for internal operations.\n * Lazy getter to ensure repository is initialized.\n */\n private get filesRepository(): BackendResourceRepository<any, any, any> {\n return this.repositoriesRegistry.getRepositoryOrThrow(CoreResourceType.FILES, {} as ExecutionContext<any>);\n }\n\n private getDefaultStorageProvider(): IFileStorageProvider {\n return this.fileStorageRouter.getDefaultProvider();\n }\n\n public getStorageProviderForFile(\n file: Pick<File, 'fileId' | 'storageProvider' | 'storageRef'>,\n executionContext: ExecutionContext<any>,\n ): IFileStorageProvider {\n if (!file.storageProvider) {\n this.logDebug('Falling back to default storage provider for legacy file row', {\n fileId: file.fileId,\n });\n return this.getDefaultStorageProvider();\n }\n\n const provider = this.fileStorageRouter.getProviderById(file.storageProvider);\n if (!provider) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'No registered storage provider matches the persisted file routing',\n fileId: file.fileId,\n storageProvider: file.storageProvider,\n },\n }\n );\n }\n\n return provider;\n }\n\n /**\n * Stream a file's bytes from its storage provider to an Express response.\n *\n * Shared streaming seam used by BOTH the global `FileController` download route\n * and the resource-integrated file **serve** route. Callers own authorization\n * BEFORE invoking this (the global controller via file-scope/token checks; the\n * resource serve route via the parent resource's READ authorization + a\n * link-ownership assertion) — this method performs NO authorization, it only\n * pipes bytes and manages the stream/response lifecycle.\n *\n * Sets Content-Type / Content-Length / ETag / Last-Modified from the storage\n * download result, and Content-Disposition from `disposition` (`inline` for\n * preview surfaces like avatars/PDFs, `attachment` for forced downloads).\n * Registers stream/response error + close handlers before piping so an\n * immediate storage error is caught and the source stream is always destroyed\n * on client disconnect.\n *\n * @param file - The file record (already fetched + authorized by the caller).\n * @param res - Express response to pipe into.\n * @param executionContext - Context for storage-provider resolution/errors.\n * @param options.disposition - `inline` (default) or `attachment`.\n * @param options.next - Express `next` to forward pre-header stream errors.\n * @param options.variant - `original` (default) streams the stored bytes as-is;\n * `thumbnail` delegates to `serveImageThumbnail` for eligible raster images.\n * Non-images, oversized sources, and resize failures transparently fall through\n * to the original-bytes streaming path — a preview request never hard-fails.\n */\n public async streamFileToResponse(\n file: File,\n res: Response,\n executionContext: ExecutionContext<any> | undefined,\n options?: { disposition?: 'inline' | 'attachment'; next?: NextFunction; variant?: FileServeVariant },\n ): Promise<void> {\n const disposition = options?.disposition ?? 'inline';\n const next = options?.next;\n const variant = options?.variant ?? FileServeVariant.ORIGINAL;\n\n // ── THUMBNAIL VARIANT — a preview surface asked for a downscaled rendition.\n //\n // TWO refusals, and they are deliberately NOT the same shape (#478):\n //\n // 1. The field SUPPRESSED derived renditions (`imageConstraints.generateThumbnails: false`).\n // This is a declared intent — cost, or privacy on a sensitive image — so it REFUSES.\n // Falling through to the original bytes, which is what every other ineligible case does,\n // would serve the FULL-SIZE image to a caller who asked for a small one: the exact\n // outcome an author suppressing thumbnails is trying to prevent. A control that degrades\n // into serving more data than was asked for is worse than no control.\n //\n // 2. The file cannot be thumbnailed (non-image, zero-size, oversized, or a resize failure\n // inside `serveImageThumbnail`). Nothing was declared about it, so the original bytes are\n // the honest answer and a preview request never hard-fails.\n //\n // Both gates read RECORDED state — the field's declared metadata and the file's own\n // `mimeType`/`size` — so neither costs a storage round-trip.\n if (variant === FileServeVariant.THUMBNAIL && !this.fieldPermitsDerivedRenditions(file)) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext as any,\n {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: {\n message: 'This file field suppresses derived renditions; request the original variant instead.',\n fileId: file.fileId,\n linkedResourceType: file.linkedResourceType,\n linkedFieldName: file.linkedFieldName,\n },\n },\n );\n }\n\n const canThumbnail =\n variant === FileServeVariant.THUMBNAIL &&\n isThumbnailableImage(file.mimeType) &&\n (file.size ?? 0) > 0 &&\n (file.size ?? 0) <= THUMBNAIL_SOURCE_MAX_BYTES;\n if (canThumbnail) {\n await this.serveImageThumbnail(file, res, executionContext, next);\n return;\n }\n\n this.logDebug('Streaming file to response', { fileId: file.fileId, disposition });\n\n let stream: Readable | null = null;\n\n try {\n const storageProvider = this.getStorageProviderForFile(file, executionContext as any);\n const downloadResult = await storageProvider.download(file, executionContext as any);\n stream = downloadResult.stream;\n\n // Validate stream before use (ensures stream is readable and not destroyed).\n validateStream(stream, this.errorBuilder, executionContext as any, 'downloadStream');\n\n // Storage metadata is more accurate than the DB copy for transport headers.\n if (res.headersSent) {\n this.logger.warn('Response headers already sent, cannot set file response headers', {\n fileId: file.fileId,\n });\n } else {\n const contentType = downloadResult.contentType || file.mimeType;\n res.setHeader(WildoHeaderKeys.CONTENT_TYPE, contentType);\n\n // ── SECURITY (untrusted bytes) — file content is user-uploaded and must\n // NEVER be able to execute as stored XSS. Two always-on response defenses:\n // 1. `X-Content-Type-Options: nosniff` — the browser must honour the\n // declared Content-Type and not MIME-sniff a body into executable HTML.\n // 2. file-serve CSP (`default-src 'none'; sandbox`) — even a directly\n // navigated HTML/SVG runs no script (see the const's doc above).\n // These are cheap, unconditional, and safe for legitimate media.\n // Standard lowercase HTTP header names, set as literals here (rather than via\n // the cross-package WildoHeaderKeys registry) to keep this untrusted-bytes\n // serving seam self-contained — see the `FILE_SERVE_CONTENT_SECURITY_POLICY` doc.\n res.setHeader('x-content-type-options', 'nosniff');\n res.setHeader('content-security-policy', FILE_SERVE_CONTENT_SECURITY_POLICY);\n\n const contentLength = downloadResult.size > 0 ? downloadResult.size : (file.size || 0);\n if (contentLength > 0) {\n res.setHeader(WildoHeaderKeys.CONTENT_LENGTH, contentLength.toString());\n }\n\n // ── SECURITY (disposition) — a `preview` (inline) request is only honoured\n // for SAFE media; script-capable types (html/xhtml/svg) are forced to\n // `attachment` so the browser downloads rather than renders them in a\n // document context. Belt-and-braces with nosniff + CSP above.\n const effectiveDisposition =\n disposition === 'inline' && isDangerousInlineContentType(contentType)\n ? 'attachment'\n : disposition;\n const filename = file.originalFilename || file.fileId || 'file';\n setContentDispositionHeader(res, filename, effectiveDisposition);\n\n // ETag / Last-Modified are standard HTTP headers (not platform headers).\n if (downloadResult.etag) {\n res.setHeader(WildoHeaderKeys.ETAG, downloadResult.etag);\n }\n if (downloadResult.lastModified) {\n res.setHeader(WildoHeaderKeys.LAST_MODIFIED, downloadResult.lastModified.toUTCString());\n }\n }\n\n // Register error handlers BEFORE piping so immediate errors are caught.\n stream.on('error', (error) => {\n this.logger.error('Stream error while serving file from storage', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n if (!res.headersSent) {\n if (next) {\n next(error);\n return;\n }\n res.status(500).end();\n } else if (stream && !stream.destroyed) {\n stream.destroy();\n }\n });\n\n res.on('error', (error) => {\n this.logger.error('Response error while streaming file', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n if (stream && !stream.destroyed) {\n stream.destroy();\n }\n });\n\n // Client disconnect / response finished → destroy the source stream.\n res.on('close', () => {\n if (stream && !stream.destroyed) {\n stream.destroy();\n }\n });\n\n stream.pipe(res);\n } catch (error) {\n if (stream && !stream.destroyed) {\n try {\n stream.destroy();\n } catch (destroyError) {\n this.logger.warn('Failed to destroy stream during error cleanup', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(destroyError),\n originalError: describeCaughtError(error),\n });\n }\n }\n\n this.logger.error('Failed to stream file from storage', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n throw error;\n }\n }\n\n /**\n * Does the DECLARING field permit derived renditions of this file?\n *\n * Reads `imageConstraints.generateThumbnails` off the file field's own schema metadata,\n * resolved from the file's recorded `linkedResourceType` + `linkedFieldName`. Until #478 the\n * flag was declared, set on the framework's own user-avatar field, and read by nothing — every\n * eligible raster image got a rendition whether or not its author had asked for one, and an\n * author who set it `false` for cost or privacy got thumbnails and no error. It degraded in the\n * PERMISSIVE direction, which is why it was worth wiring rather than deleting.\n *\n * ## Absence means PERMIT, at three different levels, and each is deliberate\n *\n * A file with no `linkedResourceType`/`linkedFieldName` (a standalone upload), a field the\n * registry cannot resolve, a field with no `imageConstraints`, or `imageConstraints` with no\n * `generateThumbnails` — all permit. Only an EXPLICIT `false` suppresses. The flag is opt-OUT:\n * nobody has declared it today except to say `true`, and a resolution failure must not become a\n * silent refusal on a preview surface that works now.\n *\n * The `{ sizes: [...] }` form counts as permission. Its sizes are not honoured — the derivation\n * has one fixed longest-edge — so it is truthy-permits here and nothing more; an author reading\n * this should not expect their sizes to reach the renderer.\n */\n private fieldPermitsDerivedRenditions(file: File): boolean {\n const resourceType = file.linkedResourceType;\n const fieldName = file.linkedFieldName;\n if (!resourceType || !fieldName) {\n return true;\n }\n\n const resourceConfig = this.resourcesRegistry.getResourceConfiguration(resourceType as ResourceType);\n if (!resourceConfig?.mainSchema) {\n return true;\n }\n\n let resolved: ReturnType<typeof getFileFieldSchemaMetadataByPath>;\n try {\n resolved = getFileFieldSchemaMetadataByPath(resourceConfig.mainSchema, fieldName);\n } catch (error) {\n // The walker throws on schema shapes it refuses to descend (plain unions, dynamic\n // containers). That is a question about the SCHEMA, not about this file's permission —\n // serving a preview is the safe answer, and the walker's own consumers report the shape.\n this.logDebug('Could not resolve file field metadata for the rendition gate; permitting', {\n fileId: file.fileId,\n resourceType,\n fieldName,\n ...projectCaughtErrorLogFields(error),\n });\n return true;\n }\n\n return resolved?.fileMetadata.imageConstraints?.generateThumbnails !== false;\n }\n\n /**\n * Serve a downscaled `webp` thumbnail of a raster image — the `?variant=thumbnail`\n * path of {@link streamFileToResponse}.\n *\n * Unlike the original-bytes path, this BUFFERS the source in memory to hand it to\n * libvips. Callers MUST gate on {@link isThumbnailableImage} + a size ceiling\n * before delegating here (see `streamFileToResponse`). On any resize failure the\n * ORIGINAL bytes (already buffered) are returned with their real content-type, so a\n * corrupt/edge-case image degrades to \"full image\" rather than a 500.\n *\n * Applies the SAME untrusted-bytes hardening as the streaming path (`nosniff` +\n * file-serve CSP) plus an immutable, version-keyed cache policy so the resize cost\n * is paid at most once per (file, version) per client.\n *\n * @param file - The image file record (already fetched + authorized by the caller).\n * @param res - Express response to write the encoded thumbnail into.\n * @param executionContext - Context for storage-provider resolution/errors.\n * @param next - Express `next` to forward pre-header errors to the error middleware.\n */\n private async serveImageThumbnail(\n file: File,\n res: Response,\n executionContext: ExecutionContext<any> | undefined,\n next: NextFunction | undefined,\n ): Promise<void> {\n this.logDebug('Serving image thumbnail', { fileId: file.fileId, size: file.size });\n\n try {\n const storageProvider = this.getStorageProviderForFile(file, executionContext as any);\n const downloadResult = await storageProvider.download(file, executionContext as any);\n const stream = downloadResult.stream;\n validateStream(stream, this.errorBuilder, executionContext as any, 'thumbnailSourceStream');\n\n // BUFFER the full source (this path can't stream — libvips needs the bytes).\n // The cap is a defensive backstop; the caller already pre-filtered on file.size.\n const sourceBuffer = await collectStreamToBuffer(stream, THUMBNAIL_SOURCE_MAX_BYTES);\n const thumbnail = await generateImageThumbnail(sourceBuffer);\n\n if (res.headersSent) {\n this.logger.warn('Response headers already sent, cannot serve thumbnail', {\n fileId: file.fileId,\n });\n return;\n }\n\n // Resize failure → serve the ORIGINAL bytes we already hold (degrade to full\n // image, never a 500). Only reachable for raster images (caller-gated).\n const body = thumbnail ? thumbnail.data : sourceBuffer;\n const contentType = thumbnail\n ? thumbnail.contentType\n : downloadResult.contentType || file.mimeType;\n if (!thumbnail) {\n this.logger.warn('Thumbnail generation failed; serving original image bytes', {\n fileId: file.fileId,\n mimeType: file.mimeType,\n });\n }\n\n // ── SECURITY (untrusted bytes) — identical to the streaming path: honour the\n // declared type (nosniff) and neutralise any directly-navigated document\n // (file-serve CSP). A generated webp is inert; the original-bytes fallback is a\n // raster image, so `inline` is always safe here (html/svg never reach this method).\n res.setHeader(WildoHeaderKeys.CONTENT_TYPE, contentType);\n res.setHeader('x-content-type-options', 'nosniff');\n res.setHeader('content-security-policy', FILE_SERVE_CONTENT_SECURITY_POLICY);\n res.setHeader(WildoHeaderKeys.CONTENT_LENGTH, body.length.toString());\n\n // Immutable, version-keyed cache — see `THUMBNAIL_CACHE_CONTROL`. `updatedAt`\n // participates in the ETag so replacing the image busts stale copies.\n res.setHeader(WildoHeaderKeys.CACHE_CONTROL, THUMBNAIL_CACHE_CONTROL);\n const version = file.updatedAt instanceof Date ? file.updatedAt.getTime() : '';\n res.setHeader(WildoHeaderKeys.ETAG, `\"thumb-${file.fileId}-${version}\"`);\n\n const filename = file.originalFilename || file.fileId || 'file';\n setContentDispositionHeader(res, filename, 'inline');\n\n res.end(body);\n } catch (error) {\n this.logger.error('Failed to serve image thumbnail', {\n fileId: file.fileId,\n ...projectCaughtErrorLogFields(error),\n });\n if (!res.headersSent) {\n if (next) {\n next(error as Error);\n return;\n }\n res.status(500).end();\n return;\n }\n throw error;\n }\n }\n\n /**\n * Build the internal execution context for a FILES (`REPOSITORY_ONLY`) repository\n * operation invoked as a side effect of an originating request (a resource CREATE\n * that generates a PDF, an upload handler, a link, a cleanup pass).\n *\n * The originating context carries two distinct concerns; this routes each correctly:\n *\n * - **Identity (`initiatorIds`) stays application-only.** The builder produces an\n * `INTERNALLY_INITIATED_REQUEST`, whose `ExecutionContext` invariant forbids the\n * user's `organizationId` / `userId` on `initiatorIds` (only `applicationId`).\n * Forwarding the user's full identity here 500'd every user-initiated file write.\n * `applicationId` is seeded from the originating context (or the single app tenant)\n * for a second reason: the FILES resource is APPLICATION-scoped, so a missing\n * `applicationId` would trigger `populateApplicationIdIfNeeded`'s internal\n * APPLICATION read, which would apply this op's scope map and fail (the APPLICATIONS\n * schema has no `organizationId`). Seeding it skips that read.\n * - **Scope (`scopeFields` → `contextResourcesFieldIdentifier`) carries the file's own\n * tenant scope.** A FILES record's `organizationId` / `userId` are scope fields that\n * the create DTO strips and `enrichDataWithContext` re-injects from the context map;\n * they are SECONDARY scopes (FILES' primary scope is `applicationId`), so they are\n * not auto-re-injected. Callers that know the file's scope (CREATE) pass it here so\n * the record is correctly tenant-scoped and `authorizeFileAccess` later matches the\n * caller's org; by-id operations omit it (they resolve by `_id`).\n *\n * `createForInternalRepositoryOperation` resolves the FILES `REPOSITORY_ONLY`\n * operation `REPOSITORY_ONLY`-preferred (URL-fallback); the URL-only resolver would\n * throw `RESOURCES_REGISTRY_OPERATION_PATH_NOT_FOUND` for the non-URL-bearing FILES\n * resource.\n */\n private async createInternalExecutionContext(\n operation: CoreResourceOperation,\n providedContext: ExecutionContext<any>,\n scopeFields?: Map<string, string>,\n ): Promise<ExecutionContext<any>> {\n const applicationId = providedContext.applicationId ?? this.appConfigService.applicationId;\n\n return this.executionContextCreator.createForInternalRepositoryOperation({\n resourceType: CoreResourceType.FILES,\n operationIdentifier: operation,\n initiatorIds: applicationId ? { applicationId } : null,\n contextResourcesFieldIdentifier: scopeFields,\n initiatorRoles: [\n {\n roles: [CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN],\n relatedPrimaryScope: ResourcePrimaryScope.APPLICATION,\n },\n ],\n });\n }\n\n /**\n * Create a new file record with status PENDING.\n * Called before upload starts to reserve the fileId.\n *\n * Scope can be provided at creation time (when known) or derived later\n * when linking to a resource via linkFileToResource().\n *\n * @param fileData - Initial file data (filename, mimeType, size, etc.)\n * @param executionContext - Execution context for authorization\n * @param options - Repository options\n * @returns Created file record with fileId\n */\n async createFile(\n fileData: {\n filename: string;\n originalFilename: string;\n mimeType: string;\n size: number;\n extension?: string;\n checksum?: string;\n /** Resolved storage provider. Falls back to default when omitted. */\n storageProvider?: FileStorageAccepted;\n // Scope identifiers - segregated (not hierarchical)\n // If not provided, will be derived when linking to resource\n scope?: FileScopeIdentifiers;\n // Legacy: organizationId for backward compatibility\n // Use scope.organizationId instead for new code\n organizationId?: string;\n } & FileUploaderOwnership,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n // Validate inputs (CRITICAL: Prevents invalid data propagation)\n const maxFileSize = resolveConfiguredMaxFileSize(this.appConfigService.config.storage?.maxFileSize);\n validateContentType(fileData.mimeType, this.errorBuilder, executionContext, 'mimeType');\n validateSize(fileData.size, maxFileSize, this.errorBuilder, executionContext, 'size');\n const hasExplicitUploadedBy = fileData.uploadedBy !== undefined;\n const hasExplicitUploaderEntityType = fileData.uploadedByEntityType !== undefined;\n if (hasExplicitUploadedBy !== hasExplicitUploaderEntityType) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_UPLOADER_FIELDS_INCONSISTENT,\n context: {\n // diagnostic (log-only)\n uploadedBy: fileData.uploadedBy,\n uploadedByEntityType: fileData.uploadedByEntityType,\n },\n }\n );\n }\n\n if (hasExplicitUploadedBy && hasExplicitUploaderEntityType) {\n validateUploadedBy(fileData.uploadedBy, this.errorBuilder, executionContext, 'uploadedBy');\n validateUploadedByEntityType(fileData.uploadedByEntityType, this.errorBuilder, executionContext, 'uploadedByEntityType');\n }\n\n // Validate scope if provided\n if (fileData.scope && !FileScopeUtils.validate(fileData.scope)) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_INVALID,\n context: {\n scope: fileData.scope, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Derive organizationId from scope or use legacy field\n const organizationId = fileData.scope?.organizationId || fileData.organizationId;\n if (organizationId) {\n validateOrganizationId(organizationId, this.errorBuilder, executionContext, 'organizationId');\n }\n\n // Derive applicationId from scope (always set after schema fix) or fall back to execution context.\n // applicationId is the top-level tenant isolation field — always required on every file record.\n const accessScope = this.deriveAccessScope(executionContext);\n const applicationId = fileData.scope?.applicationId ?? accessScope.applicationId;\n if (!applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n }\n );\n }\n\n this.logDebug('Creating file record', {\n filename: fileData.filename,\n primaryScope: fileData.scope?.primaryScope,\n organizationId,\n });\n\n // Extract extension from filename if not provided\n const extension = fileData.extension || this.extractExtension(fileData.originalFilename);\n\n // NOTE (insert-first): the file's identity is the Mongo-generated `_id` (surfaced\n // externally as the `fileId` virtual). `storageKey` embeds that identity, so it can\n // only be derived AFTER the row exists — it is computed + persisted in a follow-up\n // update below, not at insert time. (Previously a `fileId` was pre-generated here and\n // stored as a second identity, which both diverged from `_id` and — being a stripped\n // `excludeFromCreate` primary key — failed Mongoose's required-path validation.)\n const resolvedStorageProviderId = fileData.storageProvider ?? this.getDefaultStorageProvider().providerId;\n\n const derivedUploader = resolveFileUploaderPrincipal(executionContext);\n const uploaderPrincipal = hasExplicitUploadedBy && hasExplicitUploaderEntityType\n ? {\n uploadedBy: fileData.uploadedBy!,\n uploadedByEntityType: fileData.uploadedByEntityType!,\n }\n : derivedUploader;\n\n if (hasExplicitUploadedBy && hasExplicitUploaderEntityType\n && derivedUploader\n && (\n fileData.uploadedBy !== derivedUploader.uploadedBy\n || fileData.uploadedByEntityType !== derivedUploader.uploadedByEntityType\n )\n ) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_UPLOADER_MISMATCH,\n context: {\n // diagnostic (log-only)\n uploadedBy: fileData.uploadedBy,\n uploadedByEntityType: fileData.uploadedByEntityType,\n derivedUploadedBy: derivedUploader.uploadedBy,\n derivedUploadedByEntityType: derivedUploader.uploadedByEntityType,\n },\n }\n );\n }\n\n // Prepare file record data. No `fileId` (it is the virtual projection of the\n // Mongo-generated `_id`) and no `storageKey` (derived from `_id`, set post-insert).\n const fileRecord: Partial<File> = {\n filename: fileData.filename,\n originalFilename: fileData.originalFilename,\n mimeType: fileData.mimeType,\n size: fileData.size,\n extension: extension || undefined,\n checksum: fileData.checksum,\n storageProvider: resolvedStorageProviderId,\n status: FileStatus.PENDING,\n uploadedBy: uploaderPrincipal?.uploadedBy,\n uploadedByEntityType: uploaderPrincipal?.uploadedByEntityType,\n // Scope identifiers (segregated)\n primaryScope: fileData.scope?.primaryScope,\n applicationId,\n organizationId: organizationId,\n userId: fileData.scope?.userId,\n };\n\n // Create internal execution context for repository operation\n // Carry the file's OWN tenant scope (per its `primaryScope`) into the internal\n // context so the `organizationId` / `userId` scope fields — stripped from the FILES\n // create DTO and re-injected from the context map — land on the record. Sourced from\n // the explicit `fileData.scope` (already correct for the file's primaryScope: org for\n // ORGANIZATIONS, user-only for USER_SELF, neither for APPLICATION), so no spurious\n // scope is set. Without this the file is scope-less and `authorizeFileAccess` denies it.\n const createScopeFields = new Map<string, string>();\n if (fileData.scope?.organizationId) {\n createScopeFields.set('organizationId', fileData.scope.organizationId);\n }\n if (fileData.scope?.userId) {\n createScopeFields.set('userId', fileData.scope.userId);\n }\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.CREATE,\n executionContext,\n createScopeFields\n );\n\n // The file is persisted as TWO writes — insert (Mongo assigns `_id`, surfaced via the\n // `fileId` virtual) then a storageKey update derived from that identity. They MUST be\n // atomic: a crash between them would otherwise commit a `storageKey`-less row (the\n // pre-transaction design's regression). The wrapping transaction below makes them so.\n const persistFileWithStorageKey = async (\n writeOptions: RepositoryOptions | undefined,\n ): Promise<File> => {\n // Create file record via repository. Mongo generates `_id`; the `fileId` virtual\n // projects it, so `createdFile.fileId === String(_id)`.\n const createdFile = await this.filesRepository.create<File>(\n internalContext,\n fileRecord as File,\n writeOptions\n );\n\n // Now that the identity (`_id`, surfaced as `fileId`) exists, derive the storageKey and\n // persist it. This preserves the historical contract that a created file always carries a\n // storageKey — scope-derived when a scope is known at creation, else the bare identity\n // (`fileId`) as a fallback (re-derived with the full scope path by `linkFileToResource`\n // once the file is linked).\n const storageKey = fileData.scope\n ? FileScopeUtils.buildStoragePath(fileData.scope, createdFile.fileId)\n : createdFile.fileId;\n const withStorageKey = await this.filesRepository.update<File>(\n internalContext,\n { _id: createdFile.fileId },\n { storageKey } as Partial<File>,\n writeOptions\n );\n\n if (!withStorageKey) {\n // The row was just created under this same context and transaction, so a missing match\n // here is unexpected (e.g. a contextual-filter mismatch). Surface it rather than\n // silently returning a storageKey-less file: the file row still exists, but the gap is\n // logged.\n this.logger.warn?.('File record created but storageKey could not be persisted', {\n fileId: createdFile.fileId,\n });\n this.logDebug('File record created', { fileId: createdFile.fileId });\n return createdFile;\n }\n\n this.logDebug('File record created', { fileId: withStorageKey.fileId });\n return withStorageKey;\n };\n\n // Make the insert + storageKey update atomic. If the caller already supplied an active\n // transaction on the FILES store (e.g. file work cascaded from a resource mutation), both\n // writes join it; otherwise open a self-contained one so a crash between the two writes\n // cannot leave a storageKey-less row. `nestedBehavior: 'reuse'` is a safety net for an\n // ambient (AsyncLocalStorage-tracked) transaction not threaded through `options`.\n //\n // The store is resolved from the FILES resource rather than named: this used to read\n // `=== PersistenceAdapter.MONGODB` and open on `this.mongoDBService`, which is correct only\n // while FILES sits on MongoDB and inverts in silence the day it moves — the row would be\n // written by the FILES repository on one connection while the \"atomicity\" wrapping it came\n // from another.\n const filesStore = this.getFilesStore(executionContext);\n if (options?.transaction?.databaseType === filesStore.persistenceAdapter) {\n return persistFileWithStorageKey(options);\n }\n return filesStore.databaseService.executeTransaction(\n (transactionContext) => persistFileWithStorageKey({ ...options, transaction: transactionContext }),\n { nestedBehavior: 'reuse' }\n );\n }\n\n /**\n * The transaction-owning service for the FILES store.\n *\n * Resolved through the persistence unit of work, which is the one place that holds both\n * every adapter's database service and the resource → adapter mapping. Re-deriving either\n * here is what produced the `mongoDBService`-by-name coupling this replaced.\n *\n * Throws rather than degrading: every caller uses the returned service to establish\n * atomicity across two writes, and continuing without a transaction would leave exactly\n * the storageKey-less row the transaction exists to prevent — silently.\n */\n private getFilesStore(executionContext: ExecutionContext<any>): ResourcePersistenceResourceStore {\n const filesStore = this.resourcePersistenceUnitOfWork?.getDatabaseServiceForResource(\n CoreResourceType.FILES,\n );\n\n if (!filesStore) {\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message: 'No database service is available for the FILES resource store',\n resourceType: CoreResourceType.FILES,\n unitOfWorkBound: Boolean(this.resourcePersistenceUnitOfWork),\n },\n }\n );\n }\n\n return filesStore;\n }\n\n /**\n * Get file metadata by fileId.\n *\n * @param fileId - File identifier\n * @param executionContext - Execution context for authorization\n * @returns File metadata or null if not found\n */\n async getFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File | null> {\n this.logDebug('Getting file record', { fileId });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.READ,\n executionContext\n );\n\n // Read file record via repository. `fileId` is the `_id` virtual projection, so the\n // collection filter keys on `_id` (virtuals are not queryable).\n const file = await this.filesRepository.read<File>(\n internalContext,\n { _id: fileId },\n options\n );\n\n if (!file) {\n this.logDebug('File not found', { fileId });\n return null;\n }\n\n // Check authorization. A system-cascade file teardown (subject erasure) reaches this via\n // deleteFile/eraseFile/unlinkFileFromResource on an identity-less EC that would deny the subject's\n // OWN file; it forwards the owner it already verified at the listing gate through\n // `options.authoritativeFileScope`, so the deletion gate authorizes against that owner instead of\n // the empty EC. Every other (user-facing) caller leaves it undefined ⇒ authorize against the EC.\n const hasAccess = await this.authorizeFileAccess(file, executionContext, options?.authoritativeFileScope);\n if (!hasAccess) {\n throw this.errorBuilder.buildError(\n ErrorType.AUTHORIZATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_ACCESS_DENIED,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n return file;\n }\n\n /**\n * Get multiple files by their IDs.\n *\n * @param fileIds - Array of file identifiers\n * @param executionContext - Execution context for authorization\n * @returns Array of file metadata\n */\n async batchGetFiles(\n fileIds: string[],\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File[]> {\n this.logDebug('Batch getting file records', { fileIds, count: fileIds.length });\n\n if (fileIds.length === 0) {\n return [];\n }\n\n // Filter and validate fileIds format before query — an optimization that avoids querying\n // for ids that cannot exist.\n //\n // `isValidResourceId` accepts BOTH ObjectId and UUID, so this is already adapter-neutral.\n // The previous comment claimed an \"ObjectId regex pattern\", which would have made this a\n // blocker for moving FILES to PostgreSQL (uuid ids). It reads as a coupling and is not one.\n const validFileIds = fileIds.filter(\n (id) => typeof id === 'string' && id.trim() !== '' && Resources_SharedUtils.isValidResourceId(id.trim())\n );\n\n // Early return if no valid fileIds after filtering\n if (validFileIds.length === 0) {\n return [];\n }\n\n const accessibleScopeFilter = this.buildAccessibleScopeFilter(executionContext);\n if (!accessibleScopeFilter) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n fileIdsCount: fileIds.length, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.READ,\n executionContext\n );\n\n // Add the narrowest tenant-aware filter we can BEFORE fetching.\n // This prevents cross-tenant prefetches for app-scoped files while preserving\n // legacy org-scoped rows until all persisted file records carry primaryScope.\n const files = await this.filesRepository.list<File>(\n internalContext,\n {\n // `fileId` values are `_id` strings (the virtual projection); query on `_id`.\n _id: { $in: validFileIds },\n ...accessibleScopeFilter,\n },\n options\n );\n\n // Filter by authorization\n const authorizedFiles: File[] = [];\n for (const file of files) {\n const hasAccess = await this.authorizeFileAccess(file, executionContext);\n if (hasAccess) {\n authorizedFiles.push(file);\n }\n }\n\n this.logDebug('Batch get completed', { requested: fileIds.length, found: files.length, authorized: authorizedFiles.length });\n return authorizedFiles;\n }\n\n /**\n * Read a file's BYTES for a system-initiated outbound send — today, an email attachment (#429).\n *\n * ## Why this lives here and not in the caller\n *\n * Everything it has to get right is file knowledge: which statuses may be served, how a file is\n * authorized against a scope, and which storage provider holds the bytes. A caller that assembled\n * those itself would be a second, drifting copy of three decisions this service owns — and the\n * one most dangerous to copy is the status gate, because getting it wrong means attaching an\n * INFECTED file to an outbound email.\n *\n * ## It REFUSES rather than skipping, and that is the whole point\n *\n * The defect this closes is a SILENT drop: `attachmentFileIds` was declared and read by nothing,\n * so a caller supplying an attachment got a successful send and an attachment-less email. A\n * resolution that quietly omitted a file it could not serve would be the same defect wearing\n * error handling, so every rejection throws and names the file.\n *\n * ## Authorization: the `authoritativeScopeOverride` this reuses was built for exactly this shape\n *\n * A system send carries no user principal, and an identity-less execution context derives no\n * owner — `authorizeFileAccess` records that trap in its own JSDoc, where an empty context would\n * have denied the subject's own file during erasure teardown. So the caller's scope is passed\n * explicitly, the same way the teardown path passes the owner it already resolved. The scope is\n * NOT optional: without it there is no tenancy confinement, and an attachment path that reads any\n * file by id is a read-anything primitive wearing an email envelope.\n *\n * @param fileIds - The file ids to resolve, in the order the caller supplied them.\n * @param scope - The AUTHORITATIVE owner every file is authorized against. An organization-scoped\n * send passes its `organizationId`; an application-scoped one passes `applicationId` only, and\n * then only application-scoped files resolve.\n * @returns One entry per requested id, in the requested order, carrying the bytes.\n * @throws When a file is unknown, is in a status that is not servable, is outside the scope, or\n * cannot be read from its storage provider.\n */\n async readFilesForOutboundAttachment(\n fileIds: readonly string[],\n scope: { applicationId?: string; organizationId?: string; userId?: string },\n ): Promise<Array<{ fileId: string; filename: string; mimeType: string; bytes: Buffer }>> {\n if (fileIds.length === 0) {\n return [];\n }\n\n const applicationId = scope.applicationId ?? this.appConfigService.applicationId ?? undefined;\n const executionContext = await this.executionContextCreator.createForInternalRepositoryOperation({\n resourceType: CoreResourceType.FILES,\n operationIdentifier: CoreResourceOperation.READ,\n initiatorIds: {\n ...(applicationId ? { applicationId } : {}),\n ...(scope.organizationId ? { organizationId: scope.organizationId } : {}),\n ...(scope.userId ? { userId: scope.userId } : {}),\n },\n initiatorRoles: [\n {\n roles: [CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN],\n relatedPrimaryScope: ResourcePrimaryScope.APPLICATION,\n },\n ],\n });\n\n const files = await this.filesRepository.list<File>(\n executionContext,\n { _id: { $in: [...fileIds] } },\n );\n const filesById = new Map<string, File>(files.map((file): [string, File] => [file.fileId, file]));\n\n const resolved: Array<{ fileId: string; filename: string; mimeType: string; bytes: Buffer }> = [];\n for (const fileId of fileIds) {\n const file = filesById.get(fileId);\n if (!file) {\n throw this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: 'Attachment file not found', fileId },\n });\n }\n\n // The SAME authority the download route uses. INFECTED, SCANNING, PENDING, FAILED and\n // DELETED are all outside it, so none of them can leave the system as an attachment.\n if (!FILE_DOWNLOADABLE_STATUSES.has(file.status)) {\n throw this.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: 'Attachment file is not in a servable status', fileId, status: file.status },\n });\n }\n\n const authorized = await this.authorizeFileAccess(file, executionContext, scope);\n if (!authorized) {\n throw this.errorBuilder.buildError(ErrorType.AUTHORIZATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.AUTHORIZATION,\n context: { message: 'Attachment file is outside the sending scope', fileId },\n });\n }\n\n const provider = this.getStorageProviderForFile(file, executionContext);\n const download = await provider.download(\n { fileId: file.fileId, storageRef: file.storageRef, storageProvider: file.storageProvider },\n executionContext,\n );\n const chunks: Buffer[] = [];\n for await (const chunk of download.stream) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n\n resolved.push({\n fileId: file.fileId,\n filename: file.filename,\n mimeType: file.mimeType,\n bytes: Buffer.concat(chunks),\n });\n }\n\n return resolved;\n }\n\n /**\n * Update file status (e.g., PENDING -> UPLOADED, UPLOADED -> LINKED).\n *\n * @param fileId - File identifier\n * @param status - New status\n * @param executionContext - Execution context for authorization\n * @returns Updated file record\n */\n async updateFileStatus(\n fileId: string,\n status: FileStatus,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions,\n storagePlacement?: StorageUploadResult,\n ): Promise<File> {\n this.logDebug('Updating file status', { fileId, status });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Get current file record\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n const allowedTransitions = FILE_STATUS_TRANSITIONS[currentFile.status];\n if (!allowedTransitions?.includes(status)) {\n throw this.errorBuilder.buildError(\n ErrorType.BUSINESS_RULE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_INVALID_STATUS_TRANSITION,\n context: {\n // diagnostic (log-only)\n fileId,\n currentStatus: currentFile.status,\n requestedStatus: status,\n allowedTransitions,\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // Update file status via repository. `fileId` is the `_id` virtual projection, so the\n // collection filter keys on `_id` (virtuals are not queryable).\n const updatedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n {\n status,\n ...(storagePlacement\n ? {\n storageProvider: storagePlacement.provider,\n storageRef: storagePlacement.storageRef,\n }\n : {}),\n updatedAt: new Date(),\n } as Partial<File>,\n options\n );\n\n if (!updatedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to update file status',\n fileId,\n status,\n },\n }\n );\n }\n\n this.logDebug('File status updated', { fileId, oldStatus: currentFile.status, newStatus: status });\n return updatedFile;\n }\n\n /**\n * RAG removal seam — FILE-BINDING MUTATION. A link, unlink, delete or erase changes WHICH file (if\n * any) backs a `(resourceType, resourceId, fieldName)` tuple, so any chunks derived from the\n * PREVIOUS binding's extracted text are stale the moment the write lands and must not stay\n * retrievable (re-indexing from the new binding is Phase 3's write path; deletion is this phase's\n * whole job). No-op unless the tuple names a declared `.ragSource()` field — the intersection and\n * the shared failure/transaction contract (post-commit when `options` carries a transaction, inline\n * otherwise, log-at-ERROR never throw) live in `rag-chunk-removal.backend.utils.ts`.\n */\n private async runRagChunkRemovalForFileBinding(\n binding: { resourceType?: string | null; resourceId?: string | null; fieldName?: string | null },\n seam: string,\n options?: RepositoryOptions,\n ): Promise<void> {\n if (!this.ragChunkStore || !this.ragSourceFieldDetection) return;\n const { resourceType, resourceId, fieldName } = binding;\n if (!resourceType || !resourceId || !fieldName) return;\n await scheduleRagChunkRemovalForFields(\n {\n ragChunkStore: this.ragChunkStore,\n ragSourceFieldDetection: this.ragSourceFieldDetection,\n logger: this.logger,\n },\n {\n resourceType: resourceType as ResourceType,\n resourceIds: [resourceId],\n affectedFieldNames: [fieldName],\n seam,\n transaction: options?.transaction,\n },\n );\n }\n\n /**\n * Link a file to a resource (resource-integrated uploads).\n * Updates file status to LINKED, stores resource reference, and derives scope\n * from the parent resource's resourcePrimaryScope.\n *\n * Scope derivation:\n * - APPLICATION: applicationId from execution context\n * - ORGANIZATIONS: organizationId from execution context\n * - USER_SELF: userId + applicationId from execution context (no org — separate scope axis)\n *\n * @param fileId - File identifier\n * @param resourceType - Resource type\n * @param resourceId - Resource identifier\n * @param fieldName - Field name on the resource\n * @param executionContext - Execution context for authorization\n * @returns Updated file record\n */\n async linkFileToResource(\n fileId: string,\n resourceType: ResourceType,\n resourceId: string,\n fieldName: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Linking file to resource', { fileId, resourceType, resourceId, fieldName });\n\n // Validate inputs (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n validateResourceId(resourceId, this.errorBuilder, executionContext, 'resourceId');\n validateResourceType(resourceType, this.errorBuilder, executionContext, 'resourceType');\n validateFieldName(fieldName, this.errorBuilder, executionContext, 'fieldName');\n\n // Derive scope from parent resource's resourcePrimaryScope\n const derivedScope = this.deriveScopeFromParentResource(resourceType, executionContext);\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // CRITICAL: Use atomic update with status filter to prevent race conditions (Decision 2.4: Option A)\n // The repository's update() method internally uses findOneAndUpdate, so it's atomic\n // Filter includes status check: only updates if file is in UPLOADED status\n // This ensures no race condition between check and update\n\n /**\n * Updates file status, link fields, and scope atomically.\n *\n * @note MongoDB updates are atomic, so partial updates are not possible.\n * If the update fails, the entire operation fails atomically.\n */\n const updatedFile = await this.filesRepository.update<File>(\n internalContext,\n {\n _id: fileId,\n // The linkable set is the same one the link-time validators consult (issue #320) — one copy.\n status: { $in: [...FILE_LINKABLE_STATUSES] },\n },\n {\n linkedResourceType: resourceType,\n linkedResourceId: resourceId,\n linkedFieldName: fieldName,\n status: FileStatus.LINKED,\n updatedAt: new Date(),\n // Scope derived from parent resource\n primaryScope: derivedScope.primaryScope,\n applicationId: derivedScope.applicationId,\n organizationId: derivedScope.organizationId,\n userId: derivedScope.userId,\n // Update storageKey if scope wasn't set at creation time\n storageKey: FileScopeUtils.buildStoragePath(derivedScope, fileId),\n } as Partial<File>,\n options\n );\n\n if (!updatedFile) {\n // File was not in a linkable status (race condition or already linked)\n // Re-fetch to determine the reason and throw appropriate error\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Check if already linked to same resource (idempotent case)\n if (currentFile.status === FileStatus.LINKED &&\n currentFile.linkedResourceType === resourceType &&\n currentFile.linkedResourceId === resourceId &&\n currentFile.linkedFieldName === fieldName) {\n // Already linked to same resource - idempotent, return current file\n this.logDebug('File already linked to same resource (idempotent)', {\n fileId,\n resourceType,\n resourceId,\n fieldName,\n });\n return currentFile;\n }\n\n // Check if already linked to different resource (error case)\n if (currentFile.status === FileStatus.LINKED) {\n throw this.errorBuilder.buildError(\n ErrorType.BUSINESS_RULE,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_ALREADY_LINKED,\n context: {\n // diagnostic (log-only)\n fileId,\n currentLinkedResourceType: currentFile.linkedResourceType,\n currentLinkedResourceId: currentFile.linkedResourceId,\n currentLinkedFieldName: currentFile.linkedFieldName,\n requestedResourceType: resourceType,\n requestedResourceId: resourceId,\n requestedFieldName: fieldName,\n },\n }\n );\n }\n\n // Not a linkable status. The guarded update above admits exactly FILE_LINKABLE_STATUSES, so\n // reaching here means the row is outside that set (or moved out of it between read and write).\n // SCANNING is named on its own: the file is not wrong, only not yet known to be safe — retry.\n throw this.errorBuilder.buildError(\n ErrorType.BUSINESS_RULE,\n executionContext,\n {\n customMessageReference: currentFile.status === FileStatus.SCANNING\n ? ErrorCustomMessageReference.FILE_SCAN_IN_PROGRESS\n : ErrorCustomMessageReference.FILE_NOT_LINKABLE,\n context: {\n // diagnostic (log-only)\n fileId,\n fileStatus: currentFile.status,\n linkableStatuses: [...FILE_LINKABLE_STATUSES],\n resourceType,\n resourceId,\n },\n }\n );\n }\n\n // RAG removal seam — a (re-)link binds a NEW file to the tuple, so chunks derived from whatever\n // backed it before are stale and must not survive the re-link (plan §Removal-seam inventory).\n await this.runRagChunkRemovalForFileBinding(\n { resourceType, resourceId, fieldName },\n 'file-link',\n options,\n );\n\n this.logDebug('File linked to resource', { fileId, resourceType, resourceId });\n return updatedFile;\n }\n\n /**\n * Unlink a file from a resource.\n * Updates file status to ORPHANED and clears resource link fields.\n *\n * Note: Due to Mongoose behavior, optional fields set to `undefined` are ignored in updates.\n * We attempt to clear linked resource fields, but if schema validation prevents this,\n * the status change to ORPHANED is the authoritative indicator that the file is unlinked.\n *\n * @param fileId - File identifier\n * @param executionContext - Execution context for authorization\n * @returns Updated file record\n */\n async unlinkFileFromResource(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Unlinking file from resource', { fileId });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Get current file record\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // Update file to remove resource link and set status to ORPHANED\n // Note: Mongoose ignores undefined values in updates, and optional string fields don't accept null.\n // The status change to ORPHANED is the authoritative indicator that the file is no longer linked.\n // The linked resource fields may remain in the database but are considered stale/invalid when status is ORPHANED.\n // Future enhancement: If explicit field clearing is required, consider using MongoDB $unset operator\n // via direct Mongoose model access or repository enhancement.\n const updateData: Partial<File> = {\n status: FileStatus.ORPHANED,\n updatedAt: new Date(),\n };\n\n /**\n * Updates file status and clears link fields atomically.\n *\n * @note MongoDB updates are atomic, so partial updates are not possible.\n * If the update fails, the entire operation fails atomically.\n */\n const updatedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n updateData,\n options\n );\n\n if (!updatedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to unlink file from resource',\n fileId,\n },\n }\n );\n }\n\n // RAG removal seam — the tuple no longer has a backing file; its extracted-text chunks go with\n // the binding. The tuple is read from the PRE-unlink row (the write above clears/staleness-marks it).\n await this.runRagChunkRemovalForFileBinding(\n {\n resourceType: currentFile.linkedResourceType,\n resourceId: currentFile.linkedResourceId,\n fieldName: currentFile.linkedFieldName,\n },\n 'file-unlink',\n options,\n );\n\n this.logDebug('File unlinked from resource', { fileId });\n return updatedFile;\n }\n\n /**\n * Delete a file (soft delete - marks as DELETED).\n * Physical deletion from storage happens in cleanup batch job.\n *\n * @param fileId - File identifier\n * @param executionContext - Execution context for authorization\n * @returns Deleted file record\n */\n async deleteFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Soft deleting file record', { fileId });\n\n // Validate fileId format (CRITICAL: Prevents query injection and database errors)\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n // Get current file record\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n // Soft delete: update status and set deletedAt\n\n /**\n * Updates file status to DELETED atomically.\n *\n * @note MongoDB updates are atomic, so partial updates are not possible.\n * If the update fails, the entire operation fails atomically.\n */\n const deletedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n {\n status: FileStatus.DELETED,\n deletedAt: new Date(),\n updatedAt: new Date(),\n } as Partial<File>,\n options\n );\n\n if (!deletedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to delete file',\n fileId,\n },\n }\n );\n }\n\n // RAG removal seam — a DELETED file no longer backs its linked field (the cleanup batch will\n // hard-delete the bytes), so text extracted from it must stop being retrievable now. A file that\n // was never linked to a RAG-source field no-ops. Beyond the plan's link/unlink rows, wired\n // deliberately: the row-delete and impersonalize seams cover the ORCHESTRATED deleteFile calls,\n // but a direct deleteFile on a linked file reaches neither.\n await this.runRagChunkRemovalForFileBinding(\n {\n resourceType: currentFile.linkedResourceType,\n resourceId: currentFile.linkedResourceId,\n fieldName: currentFile.linkedFieldName,\n },\n 'file-delete',\n options,\n );\n\n this.logDebug('File soft deleted', { fileId });\n return deletedFile;\n }\n\n /**\n * ERASE a file for privacy (gate **G-FILE**) — a soft delete that also scrubs the file row's OWN\n * personal data, in one write.\n *\n * Deliberately distinct from {@link deleteFile} rather than a flag on it, because the two mean\n * different things and must not drift:\n * - `deleteFile` is a LIFECYCLE delete. The row is on its way out but its provenance\n * (`originalFilename`, `uploadedBy`) is still legitimate history — an admin auditing \"who\n * uploaded what, and what happened to it\" needs exactly those fields.\n * - `eraseFile` is a PRIVACY erasure. The filename IS personal data (`passport-jane-doe.pdf`\n * identifies its subject as surely as the bytes do), and so is the uploader link. Keeping them\n * for the weeks until the cleanup batch runs means the erasure only *looks* complete.\n *\n * `filename` / `originalFilename` are REQUIRED (`min(1)`), so they are overwritten with the shared\n * {@link ERASED_FILE_NAME_PLACEHOLDER} constant rather than nulled — nulling would need a schema\n * reshape and would make every erased file distinguishable from every other by its emptiness.\n * `uploadedBy` and `uploadedByEntityType` are cleared TOGETHER: the schema's `validateUploaderPair`\n * refinement requires both or neither, and clearing one alone would make the row unwritable.\n *\n * The blob itself is removed by the existing cleanup batch, exactly as for `deleteFile` — an erasure\n * must never mix a DB rollback with non-transactional storage side effects.\n *\n * Idempotent: erasing an already-erased file rewrites the same terminal values.\n */\n async eraseFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Erasing file record for privacy', { fileId });\n\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n const currentFile = await this.getFile(fileId, executionContext, options);\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.UPDATE,\n executionContext\n );\n\n const erasedFile = await this.filesRepository.update<File>(\n internalContext,\n { _id: fileId },\n {\n status: FileStatus.DELETED,\n deletedAt: new Date(),\n updatedAt: new Date(),\n filename: ERASED_FILE_NAME_PLACEHOLDER,\n originalFilename: ERASED_FILE_NAME_PLACEHOLDER,\n uploadedBy: undefined,\n uploadedByEntityType: undefined,\n } as Partial<File>,\n options\n );\n\n if (!erasedFile) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to erase file',\n fileId,\n },\n }\n );\n }\n\n // RAG removal seam — a privacy erasure of the file makes any text extracted from it exactly the\n // personal data the erasure exists to remove; the chunk set goes in the same decision. Usually\n // redundant with the impersonalize seam that invoked this erasure (idempotent), and load-bearing\n // for a DIRECT eraseFile call, which reaches no other seam.\n await this.runRagChunkRemovalForFileBinding(\n {\n resourceType: currentFile.linkedResourceType,\n resourceId: currentFile.linkedResourceId,\n fieldName: currentFile.linkedFieldName,\n },\n 'file-erase',\n options,\n );\n\n this.logDebug('File erased', { fileId });\n return erasedFile;\n }\n\n /**\n * Permanently delete a file by removing the blob first, then deleting the\n * metadata row. This is intentionally reserved for post-commit cleanup flows\n * such as the cleanup batch, not inline resource transactions.\n */\n async hardDeleteFile(\n fileId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File> {\n this.logDebug('Hard deleting file record and storage', { fileId });\n\n validateFileId(fileId, this.errorBuilder, executionContext, 'fileId');\n\n const readContext = await this.createInternalExecutionContext(\n CoreResourceOperation.READ,\n executionContext\n );\n const currentFile = await this.filesRepository.read<File>(\n readContext,\n { _id: fileId },\n options\n );\n\n if (!currentFile) {\n throw this.errorBuilder.buildError(\n ErrorType.NOT_FOUND,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_NOT_FOUND,\n context: {\n fileId, // diagnostic (log-only)\n },\n }\n );\n }\n\n // Hard-delete now flows through the storage provider seam so future slices can\n // swap backend resolution without reopening the cleanup contract.\n try {\n const storageProvider = this.getStorageProviderForFile(currentFile, executionContext);\n await storageProvider.delete(currentFile, executionContext);\n } catch (error) {\n if (!isWildoBackendError(error) || error.type !== ErrorType.NOT_FOUND) {\n throw error;\n }\n\n this.logDebug('File blob already missing during hard delete, continuing metadata cleanup', {\n fileId,\n });\n }\n\n const deleteContext = await this.createInternalExecutionContext(\n CoreResourceOperation.DELETE,\n executionContext\n );\n const deletedFileId = await this.filesRepository.delete(\n deleteContext,\n { _id: fileId },\n options\n );\n\n if (!deletedFileId) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Failed to hard delete file',\n fileId,\n },\n }\n );\n }\n\n this.logDebug('File hard deleted from storage and metadata', { fileId });\n return currentFile;\n }\n\n /**\n * List files for a specific resource.\n *\n * @param resourceType - Resource type\n * @param resourceId - Resource identifier\n * @param fieldName - Optional field name filter\n * @param executionContext - Execution context for authorization\n * @returns Array of file metadata\n */\n async listFilesForResource(\n resourceType: ResourceType,\n resourceId: string,\n fieldName: string | undefined,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions\n ): Promise<File[]> {\n if (!executionContext) {\n throw this.errorBuilder.buildError(\n ErrorType.INTERNAL,\n {} as ExecutionContext<any>,\n {\n customMessageReference: ErrorCustomMessageReference.INTERNAL,\n context: {\n message: 'Execution context is required for listFilesForResource',\n },\n }\n );\n }\n\n this.logDebug('Listing files for resource', { resourceType, resourceId, fieldName });\n\n // Validate inputs (CRITICAL: Prevents query injection and database errors)\n validateResourceId(resourceId, this.errorBuilder, executionContext, 'resourceId');\n validateResourceType(resourceType, this.errorBuilder, executionContext, 'resourceType');\n if (fieldName) {\n validateFieldName(fieldName, this.errorBuilder, executionContext, 'fieldName');\n }\n\n // A system-cascade file teardown (subject erasure, cross-scope delete) runs on an\n // internally_initiated_request EC, whose constructor FORBIDS user/organization identity on\n // `initiatorIds` — only `applicationId` is allowed. So `deriveScopeFromParentResource` cannot read\n // the owner from the EC and would fail closed with FILE_SCOPE_IDENTIFIER_MISSING, aborting the\n // whole erasure transaction before the subject is scrubbed. The resource ROW being torn down\n // carries its OWN scope FK (a USER_SELF row's `userId`, an org-scoped row's `organizationId`) — the\n // authoritative owner of that row's files. Read it and hand it to the scope derivation as a\n // fallback. This is the single chokepoint every delete/impersonalize/deleteMany file teardown funnels\n // through, so the recovery is unbypassable rather than threaded through each cascade site. It costs\n // one extra read ONLY on the system path — an ordinary request already carries the owner on its EC,\n // so `loadParentResourceRowForScopeFallback` returns undefined and performs no read.\n const parentResourceRowForScope = await this.loadParentResourceRowForScopeFallback(\n resourceType,\n resourceId,\n executionContext,\n options,\n );\n const derivedScope = this.deriveScopeFromParentResource(resourceType, executionContext, parentResourceRowForScope);\n const scopeFilter = this.buildFilterForFileScope(derivedScope);\n if (!scopeFilter) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_DERIVATION_FAILED,\n }\n );\n }\n\n // Build filter\n // Be defensive against malformed persisted rows where link metadata was\n // written but status drifted from LINKED. Delete-time cleanup must still be\n // able to discover those rows by parent ownership.\n const filter: any = {\n linkedResourceType: resourceType,\n linkedResourceId: resourceId,\n status: {\n $in: [FileStatus.LINKED, FileStatus.UPLOADED, FileStatus.CLEAN],\n },\n ...scopeFilter,\n };\n\n if (fieldName) {\n filter.linkedFieldName = fieldName;\n }\n\n // Create internal execution context for repository operation\n const internalContext = await this.createInternalExecutionContext(\n CoreResourceOperation.LIST,\n executionContext\n );\n\n // Apply the linked resource's derived scope to the repository query before fetch.\n // This keeps app-scoped parents from going through an org-only path.\n const files = await this.filesRepository.list<File>(\n internalContext,\n filter,\n options\n );\n\n // Filter by authorization — against the SCOPE WE DERIVED (the parent resource's owner), not the raw\n // EC. `listFilesForResource` is exclusively a system-cascade file-teardown path (delete/impersonalize),\n // whose EC carries no owner identity; deriving the access scope from that EC would deny the subject's\n // OWN file and silently retain PII. `derivedScope` is the authoritative owner (from the row on the\n // system path, from the EC on any owner-bearing path) and is exactly what the file query above was\n // scoped by, so this re-confirms that scoping rather than trusting the empty EC.\n const authorizedFiles: File[] = [];\n for (const file of files) {\n const hasAccess = await this.authorizeFileAccess(file, executionContext, {\n applicationId: derivedScope.applicationId,\n organizationId: derivedScope.organizationId,\n userId: derivedScope.userId,\n });\n if (hasAccess) {\n authorizedFiles.push(file);\n }\n }\n\n this.logDebug('List files for resource completed', { resourceType, resourceId, found: files.length, authorized: authorizedFiles.length });\n return authorizedFiles;\n }\n\n /**\n * Authorize file access based on file's primaryScope.\n *\n * Access rules by primaryScope:\n * - APPLICATION: User must have access to the application\n * - ORGANIZATIONS: User must belong to the organization\n * - USER_SELF: User must be the owner (userId match) — no org check (separate scope axis)\n *\n * Fallback (no primaryScope): Uses legacy organizationId match\n *\n * @param file - File record\n * @param executionContext - Execution context for authorization\n * @returns true if access is allowed\n */\n async authorizeFileAccess(\n file: File,\n executionContext: ExecutionContext<any>,\n /**\n * The AUTHORITATIVE owner to check the file against, supplied ONLY by the system-cascade teardown\n * path ({@link listFilesForResource}, whose sole callers are the delete/impersonalize file teardown).\n * That path runs on an identity-less `internally_initiated_request` EC, so `deriveAccessScope` yields\n * no owner and this check would deny the SUBJECT'S OWN file — silently retaining PII while the erasure\n * reports success. The teardown has already resolved the owner from the row being torn down (the same\n * value the file query was scoped by), so authorizing against it re-confirms the query's own scoping\n * rather than trusting the empty EC. A present EC owner always wins for every other caller — this\n * override is `undefined` on the two non-teardown callers, so their behaviour is unchanged.\n */\n authoritativeScopeOverride?: { applicationId?: string; organizationId?: string; userId?: string },\n ): Promise<boolean> {\n const accessScope = authoritativeScopeOverride ?? this.deriveAccessScope(executionContext);\n\n // Legacy scope-less rows are tolerated only when they still carry a concrete\n // organization owner. Missing organization ownership is treated as malformed\n // persisted data and must fail closed.\n if (!file.primaryScope) {\n if (!file.organizationId || !accessScope.organizationId) {\n this.logDebug('File access denied: missing organization ownership on legacy file', {\n fileOrganizationId: file.organizationId,\n requestOrganizationId: accessScope.organizationId,\n });\n return false;\n }\n\n if (file.organizationId !== accessScope.organizationId) {\n this.logDebug('File access denied: organization mismatch (legacy)', {\n fileOrganizationId: file.organizationId,\n requestOrganizationId: accessScope.organizationId,\n });\n return false;\n }\n return true;\n }\n\n // Scope-based authorization\n switch (file.primaryScope) {\n case ResourcePrimaryScope.APPLICATION:\n if (!file.applicationId || file.applicationId !== accessScope.applicationId) {\n this.logDebug('File access denied: application mismatch', {\n fileApplicationId: file.applicationId,\n requestApplicationId: accessScope.applicationId,\n });\n return false;\n }\n return true;\n\n case ResourcePrimaryScope.ORGANIZATIONS: {\n // The caller is ACTING IN an organization: it must be the file's. Unchanged, and deliberately\n // not widened — a principal acting in organization A must not reach organization B's file\n // through this route merely because it also belongs to B. The acting scope is the confinement.\n if (accessScope.organizationId) {\n if (file.organizationId !== accessScope.organizationId) {\n this.logDebug('File access denied: organization mismatch', {\n fileOrganizationId: file.organizationId,\n requestOrganizationId: accessScope.organizationId,\n });\n return false;\n }\n return true;\n }\n\n /*\n * No acting organization — ask the MEMBERSHIP question instead of denying.\n *\n * The four global file routes (`/files/:fileId` and friends) build their execution context from\n * a URL that carries no parameters, and `extractInitiatorIds` populates `initiatorIds.organizationId`\n * only from URL critical params. So the context holds `userId` and nothing else, this comparison\n * ran against `undefined`, and every ORGANIZATIONS-scoped file 404'd for its own owner (#68) —\n * taking `DisplayFieldFile`'s metadata band with it, since that band loads from this endpoint.\n *\n * The row already names its organization, so the open question is not WHICH organization but\n * whether the caller belongs to it. That is answered from `initiatorRoles`, which the request\n * cannot author for itself — `execution-context-creator` builds it from memberships, and only\n * from `OrganizationMemberStatus.ACTIVE` ones, so a suspended member contributes no entry here.\n *\n * A caller-supplied `?organizationId=` is deliberately NOT consulted: that resolution exists only\n * on the manual-controller path, and reading a tenant identity off the request is the shape this\n * check exists to refuse.\n */\n return this.callerHoldsOrganizationWideMembership(file.organizationId, executionContext);\n }\n\n case ResourcePrimaryScope.USER_SELF:\n // USER_SELF scope: access is granted iff the caller IS the owner. USER_SELF and\n // ORGANIZATIONS are independent primary-scope axes, so there is NO org check here —\n // a self-owned file carries no org. `applicationId` tenant isolation is enforced\n // upstream (batchGetFiles / access-scope resolution).\n if (file.userId !== accessScope.userId) {\n this.logDebug('File access denied: user mismatch', {\n fileUserId: file.userId,\n requestUserId: accessScope.userId,\n });\n return false;\n }\n return true;\n\n default:\n // Unknown scope - deny access\n this.logDebug('File access denied: unknown primaryScope', {\n primaryScope: file.primaryScope,\n });\n return false;\n }\n }\n\n /**\n * Convert File record to FileMetadata response format.\n * Used by the getMetadata endpoint.\n *\n * @param file - File record\n * @returns FileMetadata object\n */\n toMetadataResponse(file: File): {\n fileId: string;\n filename: string;\n size: number;\n mimeType: string;\n extension?: string;\n checksum?: string;\n url?: string;\n thumbnailUrl?: string;\n nature: FileDisplayNature;\n width?: number;\n height?: number;\n duration?: number;\n pageCount?: number;\n uploadedAt: Date;\n uploadedBy?: string;\n uploadedByEntityType?: FileUploaderEntityType;\n } {\n // Infer nature from MIME type if not stored on the file record\n // Uses the shared resolveFileDisplayNature() utility (single source of truth)\n const nature: FileDisplayNature = (file.nature as FileDisplayNature) ?? resolveFileDisplayNature(undefined, file.mimeType);\n\n return {\n fileId: file.fileId,\n filename: file.originalFilename || file.filename,\n size: file.size,\n mimeType: file.mimeType,\n extension: file.extension,\n checksum: file.checksum,\n url: file.url,\n thumbnailUrl: file.thumbnailUrl,\n nature,\n width: file.width,\n height: file.height,\n duration: file.duration,\n pageCount: file.pageCount,\n uploadedAt: file.uploadedAt,\n uploadedBy: file.uploadedBy,\n uploadedByEntityType: file.uploadedByEntityType,\n };\n }\n\n /**\n * Derive access scope from execution context.\n * Extracts all scope identifiers for authorization checks.\n *\n * @param executionContext - Execution context\n * @returns Access scope information with all identifiers\n */\n /**\n * Does the caller hold ORGANIZATION-WIDE membership of this exact organization?\n *\n * Answered only from `initiatorRoles`, the one input a request cannot author for itself.\n *\n * **A unit-scoped entry does not count, and that is a decision rather than an oversight.**\n * `ExecutionContext_RoleInfo.organizationUnitId` marks a grant that is live authority inside ONE unit,\n * and its own schema is explicit that reading such an entry as tenant-wide is \"a privilege escalation,\n * not a convenience\". Membership of the tenant is arguably implied either way — a unit member is a\n * member — but this route serves a file scoped to the WHOLE organization, so the narrower reading is\n * the safe one and {@link isOrganizationWideRoleInfo} is the single definition of it. If a unit-scoped\n * caller should reach an organization-scoped file, argue it and change it here, once.\n *\n * A platform administrator who is not a member gets nothing from this, which is also deliberate: the\n * cross-tenant admission model is per-operation-variant (`admitsCrossTenantPlatformAdministration` plus\n * a usable platform-access grant), these controller routes are not resource operations, and granting\n * reach by position in the request path is exactly the ambient privilege that model removed.\n */\n private callerHoldsOrganizationWideMembership(fileOrganizationId: string | undefined, executionContext: ExecutionContext<any>): boolean {\n if (!fileOrganizationId) {\n this.logDebug('File access denied: organization-scoped file carries no organization owner');\n return false;\n }\n const membership = (executionContext.initiatorRoles ?? []).find(\n (roleInfo) =>\n roleInfo.relatedPrimaryScope === ResourcePrimaryScope.ORGANIZATIONS &&\n isOrganizationWideRoleInfo(roleInfo) &&\n roleInfo.relatedResourceId === fileOrganizationId,\n );\n if (!membership) {\n this.logDebug('File access denied: caller holds no organization-wide membership of the file\\'s organization', {\n fileOrganizationId,\n });\n return false;\n }\n return true;\n }\n\n protected deriveAccessScope(executionContext: ExecutionContext<any>): {\n applicationId?: string;\n organizationId?: string;\n userId?: string;\n } {\n const organizationId = this.resourceOperationHelper.getInitiatorId(executionContext, 'organization');\n const userId = this.resourceOperationHelper.getInitiatorId(executionContext, 'user');\n // Fall back to the single backend application's id when the execution context\n // doesn't carry one (e.g. a USER_REQUEST EC, whose initiatorIds hold org/user but\n // not applicationId). Mirrors `PdfGeneratedFileWriterBackendService` — there is\n // exactly one application per backend, so `appConfigService.applicationId` is the\n // correct anchor for `applicationId`-scoped file resolution + access checks.\n const applicationId = executionContext.applicationId || this.appConfigService.applicationId;\n\n return {\n applicationId,\n organizationId,\n userId,\n };\n }\n\n /**\n * Build the narrowest repository filter we can from the caller's accessible scope.\n * This keeps prefetching tenant-aware even before per-row authorization runs.\n */\n protected buildAccessibleScopeFilter(executionContext: ExecutionContext<any>): Record<string, unknown> | null {\n const accessScope = this.deriveAccessScope(executionContext);\n const scopeBranches: Record<string, unknown>[] = [];\n\n if (accessScope.applicationId) {\n scopeBranches.push({\n primaryScope: ResourcePrimaryScope.APPLICATION,\n applicationId: accessScope.applicationId,\n });\n }\n\n if (accessScope.organizationId) {\n // Keep legacy org-only rows reachable until all file rows carry primaryScope.\n scopeBranches.push({\n organizationId: accessScope.organizationId,\n });\n }\n\n if (scopeBranches.length === 0) {\n return null;\n }\n\n return scopeBranches.length === 1 ? scopeBranches[0] : { $or: scopeBranches };\n }\n\n protected buildFilterForFileScope(scope: FileScopeIdentifiers): Record<string, unknown> | null {\n switch (scope.primaryScope) {\n case ResourcePrimaryScope.APPLICATION:\n return scope.applicationId\n ? {\n primaryScope: ResourcePrimaryScope.APPLICATION,\n applicationId: scope.applicationId,\n }\n : null;\n case ResourcePrimaryScope.ORGANIZATIONS:\n return scope.organizationId\n ? {\n organizationId: scope.organizationId,\n }\n : null;\n case ResourcePrimaryScope.USER_SELF:\n // USER_SELF files are keyed by owner (userId) only — no org (separation of concern).\n return scope.userId\n ? {\n primaryScope: ResourcePrimaryScope.USER_SELF,\n userId: scope.userId,\n }\n : null;\n default:\n return null;\n }\n }\n\n /**\n * Recover a scoped resource's owner from the ROW when the EC cannot supply it — the system-cascade\n * file-teardown path (subject erasure, cross-scope delete). Such a cascade runs on an\n * `internally_initiated_request` EC, whose constructor is fail-closed and REJECTS user/organization\n * identity on `initiatorIds` (only `applicationId` is allowed), because the initiator of a system\n * operation is the SYSTEM, not the org/user being targeted. So {@link deriveScopeFromParentResource}\n * has no owner to read from the EC and fails closed with FILE_SCOPE_IDENTIFIER_MISSING — which,\n * inside an erasure, rolls back the whole transaction before the subject is scrubbed.\n *\n * Returns `undefined` — and performs NO read — whenever the EC already carries the owner (every\n * ordinary request, and any APPLICATION-scoped resource, whose id is always available from the single\n * backend). Only a genuinely owner-less EC over a USER_SELF/ORGANIZATIONS resource triggers the read,\n * so the hot path is unchanged.\n *\n * Fail-open to `undefined` on any obstacle (missing repository, no READ support, absent row, read\n * error): the caller then runs the EC-only derivation, which still fails closed exactly as before.\n * This helper only ADDS a recovery; it never weakens the existing guard.\n */\n private async loadParentResourceRowForScopeFallback(\n resourceType: ResourceType,\n resourceId: string,\n executionContext: ExecutionContext<any>,\n options?: RepositoryOptions,\n ): Promise<Record<string, unknown> | undefined> {\n const primaryScope =\n this.resourcesRegistry.getResourceConfiguration(resourceType)?.resourcePrimaryScope\n ?? ResourcePrimaryScope.ORGANIZATIONS;\n\n const accessScope = this.deriveAccessScope(executionContext);\n const ecAlreadyCarriesOwner =\n primaryScope === ResourcePrimaryScope.APPLICATION\n || (primaryScope === ResourcePrimaryScope.USER_SELF && !!accessScope.userId)\n || (primaryScope === ResourcePrimaryScope.ORGANIZATIONS && !!accessScope.organizationId);\n if (ecAlreadyCarriesOwner) {\n return undefined;\n }\n\n const repository = this.repositoriesRegistry.getRepository(resourceType);\n if (!repository?.supportsOperation(CoreResourceOperation.READ)) {\n return undefined;\n }\n\n try {\n const row = await repository.read<Record<string, unknown>>(executionContext, resourceId, options);\n return row ?? undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Derive file scope from parent resource's resourcePrimaryScope.\n *\n * Scope derivation rules:\n * - APPLICATION: sets applicationId from execution context\n * - ORGANIZATIONS: sets organizationId from execution context (or the row's own FK — system cascade)\n * - USER_SELF: sets userId + applicationId from execution context (no org — separate scope axis; or\n * the row's own FK — system cascade)\n *\n * @param resourceType - Parent resource type\n * @param executionContext - Execution context for scope values\n * @param parentResourceRow - The row being torn down; its own scope FK is used as a FALLBACK owner\n * only when the EC carries none (system cascade). A present EC owner always wins.\n * @returns FileScopeIdentifiers derived from parent resource\n */\n protected deriveScopeFromParentResource(\n resourceType: ResourceType,\n executionContext: ExecutionContext<any>,\n /**\n * The resource row being torn down, supplied ONLY by system-cascade paths whose EC carries no\n * owner identity (see the caller comment in {@link listFilesForResource}). Its own scope FK is the\n * authoritative owner of the row's files. Used strictly as a FALLBACK: a present EC owner always\n * wins, so every ordinary request behaves exactly as before this parameter existed.\n */\n parentResourceRow?: Record<string, unknown>,\n ): FileScopeIdentifiers {\n // Get parent resource configuration to find its primaryScope\n const resourceConfig = this.resourcesRegistry.getResourceConfiguration(resourceType);\n\n // Get primaryScope from resource configuration\n // Default to ORGANIZATIONS if not specified\n const primaryScope = resourceConfig?.resourcePrimaryScope || ResourcePrimaryScope.ORGANIZATIONS;\n\n const accessScope = this.deriveAccessScope(executionContext);\n\n // The row's value for its OWN primary-scope FK — `userId` for USER_SELF, `organizationId` for\n // ORGANIZATIONS — resolved through the single named mapping so it can never drift from the write\n // path. Stored FKs are ObjectIds; normalize to the string form the EC-derived scope also uses.\n const rowScopeFieldIdentifier = PRIMARY_SCOPE_TO_FIELD_IDENTIFIER[primaryScope];\n const rowScopeRaw = parentResourceRow?.[rowScopeFieldIdentifier];\n const rowScopeValue = rowScopeRaw != null ? String(rowScopeRaw) : undefined;\n\n switch (primaryScope) {\n case ResourcePrimaryScope.APPLICATION:\n if (!accessScope.applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n return {\n primaryScope: ResourcePrimaryScope.APPLICATION,\n applicationId: accessScope.applicationId,\n };\n\n case ResourcePrimaryScope.ORGANIZATIONS: {\n // EC owner wins; fall back to the torn-down row's own organization FK for a system cascade.\n const organizationId = accessScope.organizationId ?? rowScopeValue;\n if (!organizationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n if (!accessScope.applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n return {\n primaryScope: ResourcePrimaryScope.ORGANIZATIONS,\n applicationId: accessScope.applicationId,\n organizationId,\n };\n }\n\n case ResourcePrimaryScope.USER_SELF: {\n // USER_SELF and ORGANIZATIONS are independent primary-scope axes (separation of\n // concern): a self-owned file is owned by the USER, not an org. Require user\n // (owner) + applicationId (tenant/bucket anchor); never read/persist an org.\n // EC owner wins; fall back to the torn-down row's own user FK for a system cascade — the\n // subject-erasure path, whose EC is forbidden from carrying the user identity.\n const userId = accessScope.userId ?? rowScopeValue;\n if (!userId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n if (!accessScope.applicationId) {\n throw this.errorBuilder.buildError(\n ErrorType.VALIDATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.FILE_SCOPE_IDENTIFIER_MISSING,\n context: {\n resourceType, // diagnostic (log-only)\n },\n }\n );\n }\n return {\n primaryScope: ResourcePrimaryScope.USER_SELF,\n applicationId: accessScope.applicationId,\n userId,\n };\n }\n\n default:\n throw this.errorBuilder.buildError(\n ErrorType.CONFIGURATION,\n executionContext,\n {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message: 'File scope derivation only supports APPLICATION, ORGANIZATIONS, and USER_SELF resources',\n resourceType,\n primaryScope,\n },\n }\n );\n }\n }\n\n /**\n * Extract file extension from filename.\n *\n * @param filename - Filename with or without extension\n * @returns Extension without dot, or empty string if none\n */\n private extractExtension(filename: string): string {\n const lastDot = filename.lastIndexOf('.');\n if (lastDot === -1 || lastDot === filename.length - 1) {\n return '';\n }\n return filename.substring(lastDot + 1).toLowerCase();\n }\n}\n"]}
|