@aglyn/tenant-data-admin 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +7 -0
- package/jest.integration.config.d.ts +39 -0
- package/jest.integration.setup.d.ts +17 -0
- package/package.json +51 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +18 -0
- package/src/index.js.map +1 -0
- package/src/lib/render-cache.d.ts +184 -0
- package/src/lib/render-cache.js +198 -0
- package/src/lib/render-cache.js.map +1 -0
- package/src/lib/server/account-addresses.d.ts +160 -0
- package/src/lib/server/account-addresses.js +311 -0
- package/src/lib/server/account-addresses.js.map +1 -0
- package/src/lib/server/account-emails.d.ts +219 -0
- package/src/lib/server/account-emails.js +640 -0
- package/src/lib/server/account-emails.js.map +1 -0
- package/src/lib/server/admin-audit.d.ts +180 -0
- package/src/lib/server/admin-audit.js +233 -0
- package/src/lib/server/admin-audit.js.map +1 -0
- package/src/lib/server/analytics-retention.d.ts +63 -0
- package/src/lib/server/analytics-retention.js +66 -0
- package/src/lib/server/analytics-retention.js.map +1 -0
- package/src/lib/server/api-http.d.ts +159 -0
- package/src/lib/server/api-http.js +230 -0
- package/src/lib/server/api-http.js.map +1 -0
- package/src/lib/server/api-keys.d.ts +117 -0
- package/src/lib/server/api-keys.js +298 -0
- package/src/lib/server/api-keys.js.map +1 -0
- package/src/lib/server/auth-handoff.d.ts +165 -0
- package/src/lib/server/auth-handoff.js +482 -0
- package/src/lib/server/auth-handoff.js.map +1 -0
- package/src/lib/server/auth-pools.d.ts +246 -0
- package/src/lib/server/auth-pools.js +551 -0
- package/src/lib/server/auth-pools.js.map +1 -0
- package/src/lib/server/billing-addons.d.ts +171 -0
- package/src/lib/server/billing-addons.js +277 -0
- package/src/lib/server/billing-addons.js.map +1 -0
- package/src/lib/server/campaign-attribution-store.d.ts +55 -0
- package/src/lib/server/campaign-attribution-store.js +95 -0
- package/src/lib/server/campaign-attribution-store.js.map +1 -0
- package/src/lib/server/campaign-conversion-attribution.d.ts +205 -0
- package/src/lib/server/campaign-conversion-attribution.js +279 -0
- package/src/lib/server/campaign-conversion-attribution.js.map +1 -0
- package/src/lib/server/client-error-report.d.ts +301 -0
- package/src/lib/server/client-error-report.js +755 -0
- package/src/lib/server/client-error-report.js.map +1 -0
- package/src/lib/server/connect-account-status.d.ts +74 -0
- package/src/lib/server/connect-account-status.js +94 -0
- package/src/lib/server/connect-account-status.js.map +1 -0
- package/src/lib/server/connect-payout-failure.d.ts +103 -0
- package/src/lib/server/connect-payout-failure.js +127 -0
- package/src/lib/server/connect-payout-failure.js.map +1 -0
- package/src/lib/server/console-api-rate-limit.d.ts +81 -0
- package/src/lib/server/console-api-rate-limit.js +111 -0
- package/src/lib/server/console-api-rate-limit.js.map +1 -0
- package/src/lib/server/console-domains.d.ts +326 -0
- package/src/lib/server/console-domains.js +779 -0
- package/src/lib/server/console-domains.js.map +1 -0
- package/src/lib/server/consume-once.d.ts +91 -0
- package/src/lib/server/consume-once.js +96 -0
- package/src/lib/server/consume-once.js.map +1 -0
- package/src/lib/server/contact-company-link.d.ts +85 -0
- package/src/lib/server/contact-company-link.js +105 -0
- package/src/lib/server/contact-company-link.js.map +1 -0
- package/src/lib/server/contact-email-engagement.d.ts +32 -0
- package/src/lib/server/contact-email-engagement.js +145 -0
- package/src/lib/server/contact-email-engagement.js.map +1 -0
- package/src/lib/server/contact-email-index.d.ts +56 -0
- package/src/lib/server/contact-email-index.js +158 -0
- package/src/lib/server/contact-email-index.js.map +1 -0
- package/src/lib/server/contact-lifecycle-floor.d.ts +89 -0
- package/src/lib/server/contact-lifecycle-floor.js +88 -0
- package/src/lib/server/contact-lifecycle-floor.js.map +1 -0
- package/src/lib/server/contact-merge.d.ts +55 -0
- package/src/lib/server/contact-merge.js +279 -0
- package/src/lib/server/contact-merge.js.map +1 -0
- package/src/lib/server/contact-suppression.d.ts +153 -0
- package/src/lib/server/contact-suppression.js +259 -0
- package/src/lib/server/contact-suppression.js.map +1 -0
- package/src/lib/server/crm-booking-activity.d.ts +86 -0
- package/src/lib/server/crm-booking-activity.js +251 -0
- package/src/lib/server/crm-booking-activity.js.map +1 -0
- package/src/lib/server/crm-email-activity.d.ts +112 -0
- package/src/lib/server/crm-email-activity.js +143 -0
- package/src/lib/server/crm-email-activity.js.map +1 -0
- package/src/lib/server/crm-inbound-email.d.ts +145 -0
- package/src/lib/server/crm-inbound-email.js +287 -0
- package/src/lib/server/crm-inbound-email.js.map +1 -0
- package/src/lib/server/crm-next-activity.d.ts +74 -0
- package/src/lib/server/crm-next-activity.js +194 -0
- package/src/lib/server/crm-next-activity.js.map +1 -0
- package/src/lib/server/crm-records.d.ts +144 -0
- package/src/lib/server/crm-records.js +218 -0
- package/src/lib/server/crm-records.js.map +1 -0
- package/src/lib/server/csp-aggregate.d.ts +62 -0
- package/src/lib/server/csp-aggregate.js +276 -0
- package/src/lib/server/csp-aggregate.js.map +1 -0
- package/src/lib/server/data-storage-gate.d.ts +66 -0
- package/src/lib/server/data-storage-gate.js +48 -0
- package/src/lib/server/data-storage-gate.js.map +1 -0
- package/src/lib/server/dataset-live-pages.d.ts +179 -0
- package/src/lib/server/dataset-live-pages.js +421 -0
- package/src/lib/server/dataset-live-pages.js.map +1 -0
- package/src/lib/server/dns-probe.d.ts +53 -0
- package/src/lib/server/dns-probe.js +184 -0
- package/src/lib/server/dns-probe.js.map +1 -0
- package/src/lib/server/document-id.d.ts +29 -0
- package/src/lib/server/document-id.js +100 -0
- package/src/lib/server/document-id.js.map +1 -0
- package/src/lib/server/domain-provider-vercel.d.ts +33 -0
- package/src/lib/server/domain-provider-vercel.js +298 -0
- package/src/lib/server/domain-provider-vercel.js.map +1 -0
- package/src/lib/server/domain-provider-webhook.d.ts +73 -0
- package/src/lib/server/domain-provider-webhook.js +223 -0
- package/src/lib/server/domain-provider-webhook.js.map +1 -0
- package/src/lib/server/domain-provider-wildcard.d.ts +54 -0
- package/src/lib/server/domain-provider-wildcard.js +163 -0
- package/src/lib/server/domain-provider-wildcard.js.map +1 -0
- package/src/lib/server/domain-provider.d.ts +197 -0
- package/src/lib/server/domain-provider.js +221 -0
- package/src/lib/server/domain-provider.js.map +1 -0
- package/src/lib/server/duplicate-activity.d.ts +54 -0
- package/src/lib/server/duplicate-activity.js +67 -0
- package/src/lib/server/duplicate-activity.js.map +1 -0
- package/src/lib/server/duplicate-resource.d.ts +55 -0
- package/src/lib/server/duplicate-resource.js +474 -0
- package/src/lib/server/duplicate-resource.js.map +1 -0
- package/src/lib/server/dynamic-list-materialize.d.ts +153 -0
- package/src/lib/server/dynamic-list-materialize.js +581 -0
- package/src/lib/server/dynamic-list-materialize.js.map +1 -0
- package/src/lib/server/edit-access-authz.d.ts +56 -0
- package/src/lib/server/edit-access-authz.js +107 -0
- package/src/lib/server/edit-access-authz.js.map +1 -0
- package/src/lib/server/edit-access-token.d.ts +72 -0
- package/src/lib/server/edit-access-token.js +116 -0
- package/src/lib/server/edit-access-token.js.map +1 -0
- package/src/lib/server/edit-hint-token.d.ts +83 -0
- package/src/lib/server/edit-hint-token.js +119 -0
- package/src/lib/server/edit-hint-token.js.map +1 -0
- package/src/lib/server/email-delivery-log.d.ts +509 -0
- package/src/lib/server/email-delivery-log.js +1043 -0
- package/src/lib/server/email-delivery-log.js.map +1 -0
- package/src/lib/server/email-flow-gate.d.ts +80 -0
- package/src/lib/server/email-flow-gate.js +153 -0
- package/src/lib/server/email-flow-gate.js.map +1 -0
- package/src/lib/server/email-marketing-gate.d.ts +333 -0
- package/src/lib/server/email-marketing-gate.js +639 -0
- package/src/lib/server/email-marketing-gate.js.map +1 -0
- package/src/lib/server/email-metering.d.ts +293 -0
- package/src/lib/server/email-metering.js +359 -0
- package/src/lib/server/email-metering.js.map +1 -0
- package/src/lib/server/email-revenue-attribution.d.ts +185 -0
- package/src/lib/server/email-revenue-attribution.js +300 -0
- package/src/lib/server/email-revenue-attribution.js.map +1 -0
- package/src/lib/server/email-send-rate.d.ts +232 -0
- package/src/lib/server/email-send-rate.js +417 -0
- package/src/lib/server/email-send-rate.js.map +1 -0
- package/src/lib/server/email-sender-reputation.d.ts +317 -0
- package/src/lib/server/email-sender-reputation.js +464 -0
- package/src/lib/server/email-sender-reputation.js.map +1 -0
- package/src/lib/server/email-suppression.d.ts +490 -0
- package/src/lib/server/email-suppression.js +648 -0
- package/src/lib/server/email-suppression.js.map +1 -0
- package/src/lib/server/email-topic-confirmation.d.ts +150 -0
- package/src/lib/server/email-topic-confirmation.js +272 -0
- package/src/lib/server/email-topic-confirmation.js.map +1 -0
- package/src/lib/server/email-unsubscribe-link.d.ts +174 -0
- package/src/lib/server/email-unsubscribe-link.js +236 -0
- package/src/lib/server/email-unsubscribe-link.js.map +1 -0
- package/src/lib/server/erase-person.d.ts +116 -0
- package/src/lib/server/erase-person.js +272 -0
- package/src/lib/server/erase-person.js.map +1 -0
- package/src/lib/server/erase.d.ts +458 -0
- package/src/lib/server/erase.js +1506 -0
- package/src/lib/server/erase.js.map +1 -0
- package/src/lib/server/firebase-admin.d.ts +71 -0
- package/src/lib/server/firebase-admin.js +343 -0
- package/src/lib/server/firebase-admin.js.map +1 -0
- package/src/lib/server/form-dataset-binding-token.d.ts +35 -0
- package/src/lib/server/form-dataset-binding-token.js +107 -0
- package/src/lib/server/form-dataset-binding-token.js.map +1 -0
- package/src/lib/server/free-workspace-cap.d.ts +201 -0
- package/src/lib/server/free-workspace-cap.js +404 -0
- package/src/lib/server/free-workspace-cap.js.map +1 -0
- package/src/lib/server/ga4-measurement-protocol.d.ts +256 -0
- package/src/lib/server/ga4-measurement-protocol.js +558 -0
- package/src/lib/server/ga4-measurement-protocol.js.map +1 -0
- package/src/lib/server/host-email-tokens.d.ts +47 -0
- package/src/lib/server/host-email-tokens.js +72 -0
- package/src/lib/server/host-email-tokens.js.map +1 -0
- package/src/lib/server/host-memberships.d.ts +54 -0
- package/src/lib/server/host-memberships.js +194 -0
- package/src/lib/server/host-memberships.js.map +1 -0
- package/src/lib/server/host-sending-domain.d.ts +292 -0
- package/src/lib/server/host-sending-domain.js +451 -0
- package/src/lib/server/host-sending-domain.js.map +1 -0
- package/src/lib/server/host-visitor-records.d.ts +150 -0
- package/src/lib/server/host-visitor-records.js +262 -0
- package/src/lib/server/host-visitor-records.js.map +1 -0
- package/src/lib/server/id-token-refusal.d.ts +28 -0
- package/src/lib/server/id-token-refusal.js +111 -0
- package/src/lib/server/id-token-refusal.js.map +1 -0
- package/src/lib/server/legal-acceptance.d.ts +214 -0
- package/src/lib/server/legal-acceptance.js +305 -0
- package/src/lib/server/legal-acceptance.js.map +1 -0
- package/src/lib/server/list-members.d.ts +211 -0
- package/src/lib/server/list-members.js +176 -0
- package/src/lib/server/list-members.js.map +1 -0
- package/src/lib/server/live-page-usage.d.ts +202 -0
- package/src/lib/server/live-page-usage.js +300 -0
- package/src/lib/server/live-page-usage.js.map +1 -0
- package/src/lib/server/lockdown.d.ts +313 -0
- package/src/lib/server/lockdown.js +643 -0
- package/src/lib/server/lockdown.js.map +1 -0
- package/src/lib/server/media-cdn-rate-limit.d.ts +188 -0
- package/src/lib/server/media-cdn-rate-limit.js +204 -0
- package/src/lib/server/media-cdn-rate-limit.js.map +1 -0
- package/src/lib/server/media-delivery.d.ts +267 -0
- package/src/lib/server/media-delivery.js +485 -0
- package/src/lib/server/media-delivery.js.map +1 -0
- package/src/lib/server/media-download-tokens.d.ts +161 -0
- package/src/lib/server/media-download-tokens.js +386 -0
- package/src/lib/server/media-download-tokens.js.map +1 -0
- package/src/lib/server/media-quarantine.d.ts +127 -0
- package/src/lib/server/media-quarantine.js +170 -0
- package/src/lib/server/media-quarantine.js.map +1 -0
- package/src/lib/server/media-signing.d.ts +126 -0
- package/src/lib/server/media-signing.js +159 -0
- package/src/lib/server/media-signing.js.map +1 -0
- package/src/lib/server/media-storage-path.d.ts +96 -0
- package/src/lib/server/media-storage-path.js +111 -0
- package/src/lib/server/media-storage-path.js.map +1 -0
- package/src/lib/server/media-strong-digest.d.ts +85 -0
- package/src/lib/server/media-strong-digest.js +190 -0
- package/src/lib/server/media-strong-digest.js.map +1 -0
- package/src/lib/server/media-tombstone.d.ts +276 -0
- package/src/lib/server/media-tombstone.js +421 -0
- package/src/lib/server/media-tombstone.js.map +1 -0
- package/src/lib/server/media-variants.d.ts +309 -0
- package/src/lib/server/media-variants.js +428 -0
- package/src/lib/server/media-variants.js.map +1 -0
- package/src/lib/server/member-email-aliases.d.ts +180 -0
- package/src/lib/server/member-email-aliases.js +420 -0
- package/src/lib/server/member-email-aliases.js.map +1 -0
- package/src/lib/server/member-photo.d.ts +88 -0
- package/src/lib/server/member-photo.js +185 -0
- package/src/lib/server/member-photo.js.map +1 -0
- package/src/lib/server/membership-recover-throttle.d.ts +211 -0
- package/src/lib/server/membership-recover-throttle.js +231 -0
- package/src/lib/server/membership-recover-throttle.js.map +1 -0
- package/src/lib/server/notifications.d.ts +55 -0
- package/src/lib/server/notifications.js +134 -0
- package/src/lib/server/notifications.js.map +1 -0
- package/src/lib/server/org-billing.d.ts +97 -0
- package/src/lib/server/org-billing.js +236 -0
- package/src/lib/server/org-billing.js.map +1 -0
- package/src/lib/server/organizations.d.ts +837 -0
- package/src/lib/server/organizations.js +1814 -0
- package/src/lib/server/organizations.js.map +1 -0
- package/src/lib/server/password-reset-throttle.d.ts +84 -0
- package/src/lib/server/password-reset-throttle.js +102 -0
- package/src/lib/server/password-reset-throttle.js.map +1 -0
- package/src/lib/server/personal-data-export.d.ts +241 -0
- package/src/lib/server/personal-data-export.js +858 -0
- package/src/lib/server/personal-data-export.js.map +1 -0
- package/src/lib/server/platform-domain-names.d.ts +62 -0
- package/src/lib/server/platform-domain-names.js +197 -0
- package/src/lib/server/platform-domain-names.js.map +1 -0
- package/src/lib/server/platform-marketing-consent.d.ts +133 -0
- package/src/lib/server/platform-marketing-consent.js +209 -0
- package/src/lib/server/platform-marketing-consent.js.map +1 -0
- package/src/lib/server/rate-limit-store.d.ts +702 -0
- package/src/lib/server/rate-limit-store.js +1220 -0
- package/src/lib/server/rate-limit-store.js.map +1 -0
- package/src/lib/server/realm-plugins.d.ts +67 -0
- package/src/lib/server/realm-plugins.js +250 -0
- package/src/lib/server/realm-plugins.js.map +1 -0
- package/src/lib/server/recaptcha-allowlist.d.ts +90 -0
- package/src/lib/server/recaptcha-allowlist.js +409 -0
- package/src/lib/server/recaptcha-allowlist.js.map +1 -0
- package/src/lib/server/release-flags.d.ts +105 -0
- package/src/lib/server/release-flags.js +183 -0
- package/src/lib/server/release-flags.js.map +1 -0
- package/src/lib/server/replay-erasures.d.ts +126 -0
- package/src/lib/server/replay-erasures.js +217 -0
- package/src/lib/server/replay-erasures.js.map +1 -0
- package/src/lib/server/resolve-people.d.ts +66 -0
- package/src/lib/server/resolve-people.js +112 -0
- package/src/lib/server/resolve-people.js.map +1 -0
- package/src/lib/server/safe-equal.d.ts +45 -0
- package/src/lib/server/safe-equal.js +58 -0
- package/src/lib/server/safe-equal.js.map +1 -0
- package/src/lib/server/sending-domain-debt.d.ts +127 -0
- package/src/lib/server/sending-domain-debt.js +268 -0
- package/src/lib/server/sending-domain-debt.js.map +1 -0
- package/src/lib/server/sending-domain-recheck.d.ts +151 -0
- package/src/lib/server/sending-domain-recheck.js +253 -0
- package/src/lib/server/sending-domain-recheck.js.map +1 -0
- package/src/lib/server/sending-domains.d.ts +364 -0
- package/src/lib/server/sending-domains.js +683 -0
- package/src/lib/server/sending-domains.js.map +1 -0
- package/src/lib/server/serve-media-cdn.d.ts +433 -0
- package/src/lib/server/serve-media-cdn.js +1370 -0
- package/src/lib/server/serve-media-cdn.js.map +1 -0
- package/src/lib/server/serve-plugin-fetch.d.ts +61 -0
- package/src/lib/server/serve-plugin-fetch.js +294 -0
- package/src/lib/server/serve-plugin-fetch.js.map +1 -0
- package/src/lib/server/sms-keywords.d.ts +63 -0
- package/src/lib/server/sms-keywords.js +146 -0
- package/src/lib/server/sms-keywords.js.map +1 -0
- package/src/lib/server/sso-break-glass-owners.d.ts +91 -0
- package/src/lib/server/sso-break-glass-owners.js +227 -0
- package/src/lib/server/sso-break-glass-owners.js.map +1 -0
- package/src/lib/server/sso-domain-policy.d.ts +140 -0
- package/src/lib/server/sso-domain-policy.js +239 -0
- package/src/lib/server/sso-domain-policy.js.map +1 -0
- package/src/lib/server/sso-drift-logic.d.ts +106 -0
- package/src/lib/server/sso-drift-logic.js +95 -0
- package/src/lib/server/sso-drift-logic.js.map +1 -0
- package/src/lib/server/sso-enforcement.d.ts +204 -0
- package/src/lib/server/sso-enforcement.js +309 -0
- package/src/lib/server/sso-enforcement.js.map +1 -0
- package/src/lib/server/sso-provisioning.d.ts +320 -0
- package/src/lib/server/sso-provisioning.js +715 -0
- package/src/lib/server/sso-provisioning.js.map +1 -0
- package/src/lib/server/staff-alert-email.d.ts +41 -0
- package/src/lib/server/staff-alert-email.js +63 -0
- package/src/lib/server/staff-alert-email.js.map +1 -0
- package/src/lib/server/stripe-account-mode.d.ts +156 -0
- package/src/lib/server/stripe-account-mode.js +162 -0
- package/src/lib/server/stripe-account-mode.js.map +1 -0
- package/src/lib/server/tenant-write-lockdown.d.ts +131 -0
- package/src/lib/server/tenant-write-lockdown.js +176 -0
- package/src/lib/server/tenant-write-lockdown.js.map +1 -0
- package/src/lib/server/test-firestore.d.ts +45 -0
- package/src/lib/server/test-firestore.js +124 -0
- package/src/lib/server/test-firestore.js.map +1 -0
- package/src/lib/server/token-revocation.d.ts +140 -0
- package/src/lib/server/token-revocation.js +255 -0
- package/src/lib/server/token-revocation.js.map +1 -0
- package/src/lib/server/update-existing.d.ts +32 -0
- package/src/lib/server/update-existing.js +73 -0
- package/src/lib/server/update-existing.js.map +1 -0
- package/src/lib/server/upload-cors-reconcile.d.ts +118 -0
- package/src/lib/server/upload-cors-reconcile.js +234 -0
- package/src/lib/server/upload-cors-reconcile.js.map +1 -0
- package/src/lib/server/upsert-contact.d.ts +262 -0
- package/src/lib/server/upsert-contact.js +546 -0
- package/src/lib/server/upsert-contact.js.map +1 -0
- package/src/lib/server/usage-invoice.d.ts +203 -0
- package/src/lib/server/usage-invoice.js +397 -0
- package/src/lib/server/usage-invoice.js.map +1 -0
- package/src/lib/server/user-profiles.d.ts +151 -0
- package/src/lib/server/user-profiles.js +364 -0
- package/src/lib/server/user-profiles.js.map +1 -0
- package/src/lib/server/vercel-drain-signature.d.ts +30 -0
- package/src/lib/server/vercel-drain-signature.js +61 -0
- package/src/lib/server/vercel-drain-signature.js.map +1 -0
- package/src/lib/server/vercel-log-drain.d.ts +259 -0
- package/src/lib/server/vercel-log-drain.js +479 -0
- package/src/lib/server/vercel-log-drain.js.map +1 -0
- package/src/lib/server/verify-email-cooldown.d.ts +102 -0
- package/src/lib/server/verify-email-cooldown.js +114 -0
- package/src/lib/server/verify-email-cooldown.js.map +1 -0
- package/src/lib/server/visitor-write-rate-limit.d.ts +87 -0
- package/src/lib/server/visitor-write-rate-limit.js +117 -0
- package/src/lib/server/visitor-write-rate-limit.js.map +1 -0
- package/src/lib/server/workspace-domains.d.ts +156 -0
- package/src/lib/server/workspace-domains.js +271 -0
- package/src/lib/server/workspace-domains.js.map +1 -0
- package/src/tenancy.d.ts +115 -0
- package/src/tenancy.js +142 -0
- package/src/tenancy.js.map +1 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { FieldValue, Timestamp } from "firebase-admin/firestore";
|
|
18
|
+
import { checkQuota } from "@aglyn/aglyn/server";
|
|
19
|
+
import { removeMediaDeliveryCopies, withoutMediaDeliveryCopies } from "./media-delivery.js";
|
|
20
|
+
/**
|
|
21
|
+
* What a DAM delete has to leave behind for an undo to be possible at all
|
|
22
|
+
* (AGL-1467).
|
|
23
|
+
*
|
|
24
|
+
* ## The gap this closes
|
|
25
|
+
*
|
|
26
|
+
* The bucket has soft-delete on with a **seven-day** retention, so the bytes
|
|
27
|
+
* of a deleted asset really are still there. That was only ever half of an
|
|
28
|
+
* undo, and AGL-1461 shipped honest copy rather than a button because of the
|
|
29
|
+
* other half: `/api/media/upload`'s DELETE branch hard-deleted the Firestore
|
|
30
|
+
* document. After it ran, nothing in the product knew the asset's id, file
|
|
31
|
+
* name, folder, tags, alt text, description, custom metadata, `visibleTo`
|
|
32
|
+
* scope tokens, `cdnPath` or `variants` — and `File.restore()` needs a
|
|
33
|
+
* **generation number** that nobody had captured. Surviving bytes with no
|
|
34
|
+
* address are not a recovery story. On 2026-08-13 two files deleted in error
|
|
35
|
+
* came back only because an unrelated analysis document happened to have
|
|
36
|
+
* recorded their ids; a customer has no such document.
|
|
37
|
+
*
|
|
38
|
+
* A tombstone is the three facts that make the bytes addressable again:
|
|
39
|
+
*
|
|
40
|
+
* 1. the media document verbatim, as it was at the moment of the delete;
|
|
41
|
+
* 2. the **generation** of the storage object and of every CDN variant,
|
|
42
|
+
* read BEFORE the delete — afterwards there is no live object to ask;
|
|
43
|
+
* 3. `sizeBytes`, so the counter decrement can be reversed by exactly the
|
|
44
|
+
* amount it moved rather than by a recomputation that can drift.
|
|
45
|
+
*
|
|
46
|
+
* ## Where it lives, and why that is the whole erasure answer
|
|
47
|
+
*
|
|
48
|
+
* `{hosts|orgs}/{scopeId}/mediaTombstones/{mediaId}` — a subcollection of the
|
|
49
|
+
* scope that owned the asset, never a top-level collection keyed by media id.
|
|
50
|
+
*
|
|
51
|
+
* This is the load-bearing choice. `eraseHost` ends in
|
|
52
|
+
* `recursiveDelete(hostRef)` and `eraseOrg` ends in `recursiveDelete(orgRef)`,
|
|
53
|
+
* and a path-scoped cascade takes every subcollection under the path with it.
|
|
54
|
+
* Put the tombstones there and an erasure removes them with no new code — put
|
|
55
|
+
* them in a top-level `mediaTombstones/{id}` with an `orgId` field and they
|
|
56
|
+
* become exactly the shape AGL-1444 and AGL-1448 had to go back and wire by
|
|
57
|
+
* hand: a collection the cascade is structurally blind to, holding a verbatim
|
|
58
|
+
* copy of customer content, surviving the request that promised it was gone.
|
|
59
|
+
* A tombstone is customer data. It has to die with the customer.
|
|
60
|
+
*
|
|
61
|
+
* (The property is asserted rather than assumed —
|
|
62
|
+
* `erase-media-tombstones.emulator.spec.ts` erases a host and an org that each
|
|
63
|
+
* hold one and looks for the survivor.)
|
|
64
|
+
*
|
|
65
|
+
* ## Retention: the same seven days as the bytes, and not a day more
|
|
66
|
+
*
|
|
67
|
+
* `expiresAt` is stamped at `MEDIA_TOMBSTONE_RETENTION_MS` past the delete,
|
|
68
|
+
* which is the bucket's soft-delete window exactly. Both other numbers are
|
|
69
|
+
* wrong for the same reason from opposite directions: a shorter tombstone
|
|
70
|
+
* strands recoverable bytes with no address, which is today's defect made
|
|
71
|
+
* smaller, and a longer one can only ever produce a failed restore while
|
|
72
|
+
* holding a copy of a customer's asset for no reachable purpose. AGL-1443 is
|
|
73
|
+
* open on precisely that — a durable copy of customer data whose retention
|
|
74
|
+
* nobody chose — and this must not become a second instance of it.
|
|
75
|
+
*
|
|
76
|
+
* The field is enforced two ways, because neither alone is enough. A Firestore
|
|
77
|
+
* TTL policy on `mediaTombstones.expiresAt` reaps them (see
|
|
78
|
+
* `docs/FIRESTORE_MANUAL_CONFIG.md`), and TTL deletion is explicitly not
|
|
79
|
+
* prompt — so `restoreMediaFromTombstone` treats an expired tombstone as
|
|
80
|
+
* absent and deletes it on sight rather than trusting the sweeper.
|
|
81
|
+
*/ /** The subcollection, under the scope that owned the asset. */ export const MEDIA_TOMBSTONE_COLLECTION = 'mediaTombstones';
|
|
82
|
+
/**
|
|
83
|
+
* How long a tombstone lives: the bucket's soft-delete retention, exactly.
|
|
84
|
+
*
|
|
85
|
+
* Changing this without changing the bucket policy breaks the invariant the
|
|
86
|
+
* whole module rests on — see the header.
|
|
87
|
+
*/ export const MEDIA_TOMBSTONE_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
88
|
+
/** Days, for the copy that has to name the window to a person. */ export const MEDIA_TOMBSTONE_RETENTION_DAYS = Math.round(MEDIA_TOMBSTONE_RETENTION_MS / (24 * 60 * 60 * 1000));
|
|
89
|
+
/** When a tombstone written now stops being useful. */ export function mediaTombstoneExpiry(deletedAtMs) {
|
|
90
|
+
return deletedAtMs + MEDIA_TOMBSTONE_RETENTION_MS;
|
|
91
|
+
}
|
|
92
|
+
/** Milliseconds out of a Firestore Timestamp or a plain number. */ function toMillis(value) {
|
|
93
|
+
const timestamp = value;
|
|
94
|
+
if (typeof (timestamp == null ? void 0 : timestamp.toMillis) === 'function') return timestamp.toMillis();
|
|
95
|
+
return Number(value != null ? value : 0);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Whether the bytes this tombstone addresses are past the bucket's window.
|
|
99
|
+
*
|
|
100
|
+
* Missing or unreadable reads as EXPIRED, which is the safe direction: the
|
|
101
|
+
* failure mode of a false positive is a refusal with a clear message, and the
|
|
102
|
+
* failure mode of a false negative is a restore that half-succeeds against
|
|
103
|
+
* bytes the bucket has already reaped.
|
|
104
|
+
*/ export function isMediaTombstoneExpired(tombstone, nowMs) {
|
|
105
|
+
return !(toMillis(tombstone.expiresAt) > nowMs);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Read the generation of each object, best-effort (AGL-1467).
|
|
109
|
+
*
|
|
110
|
+
* Must run BEFORE the delete. Once the object is soft-deleted there is no live
|
|
111
|
+
* generation to read, and the number is the only handle `restore()` takes —
|
|
112
|
+
* this is the single fact whose absence made undo impossible rather than
|
|
113
|
+
* merely unbuilt.
|
|
114
|
+
*
|
|
115
|
+
* A failure here degrades the tombstone to its document half rather than
|
|
116
|
+
* failing the delete: an author who asked for a file to go must not be told
|
|
117
|
+
* "no" because a metadata read timed out.
|
|
118
|
+
*/ export async function captureObjectGenerations(bucket, paths) {
|
|
119
|
+
return Promise.all(paths.map(async (path)=>{
|
|
120
|
+
try {
|
|
121
|
+
const response = await bucket.file(path).getMetadata();
|
|
122
|
+
const metadata = Array.isArray(response) ? response[0] : response;
|
|
123
|
+
const generation = metadata == null ? void 0 : metadata.generation;
|
|
124
|
+
return {
|
|
125
|
+
path,
|
|
126
|
+
generation: generation === undefined || generation === null ? null : String(generation)
|
|
127
|
+
};
|
|
128
|
+
} catch (unused) {
|
|
129
|
+
return {
|
|
130
|
+
path,
|
|
131
|
+
generation: null
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Removes the delivery provider's copies of a deleted asset (AGL-2824).
|
|
138
|
+
*
|
|
139
|
+
* Unlike the bucket's objects they are not kept for a restore — a restore
|
|
140
|
+
* copies the video again — and no tombstone records them. The library is
|
|
141
|
+
* read off the scope reference (`hosts/{id}` or `orgs/{id}`). Nothing runs
|
|
142
|
+
* when no provider is configured to store, and a failure is logged rather
|
|
143
|
+
* than answered, like the object deletes beside it.
|
|
144
|
+
*/ async function removeDeliveryCopies(scopeRef, mediaId) {
|
|
145
|
+
var _scopeRef_parent;
|
|
146
|
+
const collection = (_scopeRef_parent = scopeRef.parent) == null ? void 0 : _scopeRef_parent.id;
|
|
147
|
+
if (collection !== 'hosts' && collection !== 'orgs') return;
|
|
148
|
+
await removeMediaDeliveryCopies({
|
|
149
|
+
asset: {
|
|
150
|
+
collection,
|
|
151
|
+
scopeId: scopeRef.id,
|
|
152
|
+
mediaId
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Delete a media document and leave a tombstone behind, in one commit.
|
|
158
|
+
*
|
|
159
|
+
* **The invariant: the media document is never destroyed except in the same
|
|
160
|
+
* transaction that writes its tombstone and moves the counter.** All three
|
|
161
|
+
* belong to one commit, so there is no interleaving in which the document is
|
|
162
|
+
* gone and the record of it is not — which is the state the product was
|
|
163
|
+
* permanently in before this issue.
|
|
164
|
+
*
|
|
165
|
+
* The object delete happens AFTER that commit, deliberately, and the ordering
|
|
166
|
+
* is a choice between two partial failures:
|
|
167
|
+
*
|
|
168
|
+
* - object first: a failed commit leaves a live document pointing at bytes
|
|
169
|
+
* that are already soft-deleted — a broken asset in the library that
|
|
170
|
+
* nothing detects;
|
|
171
|
+
* - commit first: a failed object delete leaves a tombstone whose object is
|
|
172
|
+
* still live, which `restoreMediaFromTombstone` handles by skipping the
|
|
173
|
+
* restore for an object that is already there.
|
|
174
|
+
*
|
|
175
|
+
* The second is recoverable by the code in this file. The first is not
|
|
176
|
+
* recoverable by anything.
|
|
177
|
+
*/ export async function deleteMediaWithTombstone(options) {
|
|
178
|
+
var _options_nowMs, _snapshot_get, _snapshot_get1, _snapshot_get2;
|
|
179
|
+
const { scopeRef, bucket, mediaId, objectPath, uid } = options;
|
|
180
|
+
const nowMs = (_options_nowMs = options.nowMs) != null ? _options_nowMs : Date.now();
|
|
181
|
+
const mediaRef = scopeRef.collection('media').doc(mediaId);
|
|
182
|
+
const snapshot = await mediaRef.get();
|
|
183
|
+
if (!snapshot.exists) {
|
|
184
|
+
// No document, so nothing to record and nothing to restore to. The object
|
|
185
|
+
// sweep below still runs: an orphan object is exactly what this branch is
|
|
186
|
+
// for, and it predates the tombstone.
|
|
187
|
+
await bucket.file(objectPath).delete().catch(()=>undefined);
|
|
188
|
+
await removeDeliveryCopies(scopeRef, mediaId);
|
|
189
|
+
return {
|
|
190
|
+
deleted: false
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const variantWidths = (_snapshot_get = snapshot.get('variants')) != null ? _snapshot_get : [];
|
|
194
|
+
const variantPaths = variantWidths.map((width)=>`${objectPath}__w${width}.webp`);
|
|
195
|
+
// BEFORE the delete — the whole point. See `captureObjectGenerations`.
|
|
196
|
+
const objects = await captureObjectGenerations(bucket, [
|
|
197
|
+
objectPath,
|
|
198
|
+
...variantPaths
|
|
199
|
+
]);
|
|
200
|
+
const sizeBytes = Number((_snapshot_get1 = snapshot.get('sizeBytes')) != null ? _snapshot_get1 : 0);
|
|
201
|
+
const fileName = String((_snapshot_get2 = snapshot.get('fileName')) != null ? _snapshot_get2 : mediaId);
|
|
202
|
+
const expiresAt = mediaTombstoneExpiry(nowMs);
|
|
203
|
+
const tombstoneRef = scopeRef.collection(MEDIA_TOMBSTONE_COLLECTION).doc(mediaId);
|
|
204
|
+
const counterRef = scopeRef.collection('counters').doc('media');
|
|
205
|
+
const committed = await scopeRef.firestore.runTransaction(async (transaction)=>{
|
|
206
|
+
var _fresh_data, _data_sizeBytes, _data_fileName;
|
|
207
|
+
const fresh = await transaction.get(mediaRef);
|
|
208
|
+
// Someone else deleted it between the read above and here. Their commit
|
|
209
|
+
// wrote the tombstone; ours must not write a second one over it.
|
|
210
|
+
if (!fresh.exists) return false;
|
|
211
|
+
const data = (_fresh_data = fresh.data()) != null ? _fresh_data : {};
|
|
212
|
+
const tombstone = {
|
|
213
|
+
media: data,
|
|
214
|
+
objects,
|
|
215
|
+
sizeBytes: Number((_data_sizeBytes = data['sizeBytes']) != null ? _data_sizeBytes : sizeBytes) || 0,
|
|
216
|
+
fileName: String((_data_fileName = data['fileName']) != null ? _data_fileName : fileName),
|
|
217
|
+
deletedBy: uid,
|
|
218
|
+
deletedAt: Timestamp.fromMillis(nowMs),
|
|
219
|
+
// Timestamp, not a number: the TTL policy on
|
|
220
|
+
// `mediaTombstones.expiresAt` cannot key on anything else.
|
|
221
|
+
expiresAt: Timestamp.fromMillis(expiresAt)
|
|
222
|
+
};
|
|
223
|
+
transaction.set(tombstoneRef, tombstone);
|
|
224
|
+
transaction.delete(mediaRef);
|
|
225
|
+
transaction.set(counterRef, {
|
|
226
|
+
bytes: FieldValue.increment(-tombstone.sizeBytes),
|
|
227
|
+
count: FieldValue.increment(-1)
|
|
228
|
+
}, {
|
|
229
|
+
merge: true
|
|
230
|
+
});
|
|
231
|
+
return true;
|
|
232
|
+
});
|
|
233
|
+
// Object and variants last, best-effort, exactly as before — the bucket
|
|
234
|
+
// keeps them for the retention window either way.
|
|
235
|
+
await bucket.file(objectPath).delete().catch(()=>undefined);
|
|
236
|
+
await Promise.all(variantPaths.map((path)=>bucket.file(path).delete().catch(()=>undefined)));
|
|
237
|
+
await removeDeliveryCopies(scopeRef, mediaId);
|
|
238
|
+
if (!committed) return {
|
|
239
|
+
deleted: false
|
|
240
|
+
};
|
|
241
|
+
return {
|
|
242
|
+
deleted: true,
|
|
243
|
+
tombstone: {
|
|
244
|
+
mediaId,
|
|
245
|
+
expiresAt,
|
|
246
|
+
fileName
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Why a restore cannot proceed, decided without touching Storage (AGL-1467).
|
|
252
|
+
*
|
|
253
|
+
* Pure, because these are the answers a person actually sees and the two
|
|
254
|
+
* interesting ones are cheap to get wrong: an expired tombstone must fail
|
|
255
|
+
* CLEANLY rather than half-succeed against bytes the bucket has already
|
|
256
|
+
* reaped, and a restore that would breach the plan must say so rather than
|
|
257
|
+
* push the counter past the limit in silence.
|
|
258
|
+
*
|
|
259
|
+
* ## The quota call
|
|
260
|
+
*
|
|
261
|
+
* A restore re-adds real bytes, so it is gated exactly like an upload —
|
|
262
|
+
* `storagePerHostMb`, same off-by-one — and REFUSED when it would breach the
|
|
263
|
+
* plan. Waiving it would let delete-then-restore launder an over-quota
|
|
264
|
+
* library, which is the AGL-1471/AGL-1279 shape (a limit evaluated at a moment
|
|
265
|
+
* the caller controls). Refusing is safe precisely because the tombstone
|
|
266
|
+
* outlives the refusal: the asset is still restorable for the rest of the
|
|
267
|
+
* window once space is freed, which is what makes "no, and here is why"
|
|
268
|
+
* an honest answer rather than a loss.
|
|
269
|
+
*
|
|
270
|
+
* Note what is NOT metered: the soft-deleted bytes themselves. They sit in the
|
|
271
|
+
* bucket for seven days at Aglyn's cost, and counting them would mean deleting
|
|
272
|
+
* a file did not free space until a week later — which breaks the one action
|
|
273
|
+
* an author takes when they hit the wall. The window is the price of offering
|
|
274
|
+
* undo, not an allocation to bill back.
|
|
275
|
+
*/ export function mediaRestoreRefusal(options) {
|
|
276
|
+
var _tombstone_sizeBytes;
|
|
277
|
+
const { tombstone, nowMs, usedBytes, billing } = options;
|
|
278
|
+
if (isMediaTombstoneExpired(tombstone, nowMs)) {
|
|
279
|
+
return {
|
|
280
|
+
status: 410,
|
|
281
|
+
message: `"${tombstone.fileName}" was deleted more than ` + `${MEDIA_TOMBSTONE_RETENTION_DAYS} days ago, so its file is no ` + 'longer recoverable.'
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const usedMb = (usedBytes + Number((_tombstone_sizeBytes = tombstone.sizeBytes) != null ? _tombstone_sizeBytes : 0)) / (1024 * 1024);
|
|
285
|
+
const quota = checkQuota(billing, 'storagePerHostMb', Math.ceil(usedMb) - 1);
|
|
286
|
+
if (!quota.allowed) {
|
|
287
|
+
return {
|
|
288
|
+
status: 403,
|
|
289
|
+
message: `Restoring "${tombstone.fileName}" would put this library over its ` + `storage limit (${quota.limit} MB). Free up space and try again — ` + 'the file stays restorable until the window closes.'
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Put a deleted asset back: object, variants, document and counters.
|
|
296
|
+
*
|
|
297
|
+
* Order is the same argument as the delete, run backwards. Bytes first, then
|
|
298
|
+
* the commit — so the only partial state this can leave is an object restored
|
|
299
|
+
* with no document, which the tombstone (still present, because the commit is
|
|
300
|
+
* what consumes it) makes a retry away from finished. The reverse order would
|
|
301
|
+
* publish a document whose bytes may never arrive.
|
|
302
|
+
*
|
|
303
|
+
* The commit itself carries the document write, the tombstone delete and both
|
|
304
|
+
* counter increments together, and it re-reads the tombstone inside the
|
|
305
|
+
* transaction. That re-read is what makes a double-click harmless: the second
|
|
306
|
+
* transaction finds no tombstone, commits nothing, and the caller is told the
|
|
307
|
+
* file is already back rather than being charged for it twice.
|
|
308
|
+
*/ export async function restoreMediaFromTombstone(options) {
|
|
309
|
+
var _options_nowMs, _counter_get;
|
|
310
|
+
const { scopeRef, bucket, mediaId, billing } = options;
|
|
311
|
+
const nowMs = (_options_nowMs = options.nowMs) != null ? _options_nowMs : Date.now();
|
|
312
|
+
const mediaRef = scopeRef.collection('media').doc(mediaId);
|
|
313
|
+
const tombstoneRef = scopeRef.collection(MEDIA_TOMBSTONE_COLLECTION).doc(mediaId);
|
|
314
|
+
const counterRef = scopeRef.collection('counters').doc('media');
|
|
315
|
+
const tombstoneSnapshot = await tombstoneRef.get();
|
|
316
|
+
if (!tombstoneSnapshot.exists) {
|
|
317
|
+
// Either it was never written, or the window closed and the TTL swept it.
|
|
318
|
+
// Both are the same fact to the caller, and neither is an error state the
|
|
319
|
+
// product can act on.
|
|
320
|
+
const media = await mediaRef.get();
|
|
321
|
+
if (media.exists) {
|
|
322
|
+
var _media_get;
|
|
323
|
+
return {
|
|
324
|
+
ok: true,
|
|
325
|
+
status: 200,
|
|
326
|
+
message: 'That file is already back in the library.',
|
|
327
|
+
fileName: String((_media_get = media.get('fileName')) != null ? _media_get : mediaId)
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
ok: false,
|
|
332
|
+
status: 404,
|
|
333
|
+
message: 'That file can no longer be restored.'
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
const tombstone = tombstoneSnapshot.data();
|
|
337
|
+
const counter = await counterRef.get();
|
|
338
|
+
const usedBytes = Number((_counter_get = counter.get('bytes')) != null ? _counter_get : 0);
|
|
339
|
+
const refusal = mediaRestoreRefusal({
|
|
340
|
+
tombstone,
|
|
341
|
+
nowMs,
|
|
342
|
+
usedBytes,
|
|
343
|
+
billing
|
|
344
|
+
});
|
|
345
|
+
if (refusal) {
|
|
346
|
+
// An expired tombstone is dead weight — a copy of customer data whose only
|
|
347
|
+
// possible future is this refusal. Reap it here rather than waiting on a
|
|
348
|
+
// TTL sweep that is documented as unprompt.
|
|
349
|
+
if (refusal.status === 410) {
|
|
350
|
+
await tombstoneRef.delete().catch(()=>undefined);
|
|
351
|
+
}
|
|
352
|
+
return _extends({
|
|
353
|
+
ok: false
|
|
354
|
+
}, refusal, {
|
|
355
|
+
fileName: tombstone.fileName
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
const objects = Array.isArray(tombstone.objects) ? tombstone.objects : [];
|
|
359
|
+
const [primary, ...variants] = objects;
|
|
360
|
+
const restoreObject = async (object)=>{
|
|
361
|
+
if (!(object == null ? void 0 : object.generation)) return false;
|
|
362
|
+
const file = bucket.file(object.path);
|
|
363
|
+
// Already live — the delete's object sweep is best-effort, so this is a
|
|
364
|
+
// real branch, not a defensive one. `restore()` on a live generation is
|
|
365
|
+
// not a no-op, so the check has to come first.
|
|
366
|
+
const existing = await file.exists().catch(()=>[
|
|
367
|
+
false
|
|
368
|
+
]);
|
|
369
|
+
if (Array.isArray(existing) ? existing[0] : existing) return true;
|
|
370
|
+
await file.restore({
|
|
371
|
+
generation: Number(object.generation)
|
|
372
|
+
});
|
|
373
|
+
return true;
|
|
374
|
+
};
|
|
375
|
+
if (primary) {
|
|
376
|
+
try {
|
|
377
|
+
await restoreObject(primary);
|
|
378
|
+
} catch (error) {
|
|
379
|
+
console.error(`restoreMediaFromTombstone: object restore failed for ${mediaId}`, error);
|
|
380
|
+
return {
|
|
381
|
+
ok: false,
|
|
382
|
+
status: 502,
|
|
383
|
+
message: `"${tombstone.fileName}" could not be restored — its file could ` + 'not be recovered from storage. Nothing was changed.',
|
|
384
|
+
fileName: tombstone.fileName
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
// Variants are derived artifacts the platform can regenerate, and the upload
|
|
389
|
+
// path already refuses to fail an asset for them. Same call here.
|
|
390
|
+
for (const variant of variants){
|
|
391
|
+
await restoreObject(variant).catch((error)=>{
|
|
392
|
+
console.error(`restoreMediaFromTombstone: variant ${variant == null ? void 0 : variant.path} failed`, error);
|
|
393
|
+
return false;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
const restored = await scopeRef.firestore.runTransaction(async (transaction)=>{
|
|
397
|
+
var _record_sizeBytes;
|
|
398
|
+
const fresh = await transaction.get(tombstoneRef);
|
|
399
|
+
if (!fresh.exists) return false;
|
|
400
|
+
const record = fresh.data();
|
|
401
|
+
// Without its delivery copy record: the delete removed those copies,
|
|
402
|
+
// and a record of them would name objects that are gone (AGL-2824).
|
|
403
|
+
transaction.set(mediaRef, withoutMediaDeliveryCopies(record.media));
|
|
404
|
+
transaction.delete(tombstoneRef);
|
|
405
|
+
transaction.set(counterRef, {
|
|
406
|
+
bytes: FieldValue.increment(Number((_record_sizeBytes = record.sizeBytes) != null ? _record_sizeBytes : 0)),
|
|
407
|
+
count: FieldValue.increment(1)
|
|
408
|
+
}, {
|
|
409
|
+
merge: true
|
|
410
|
+
});
|
|
411
|
+
return true;
|
|
412
|
+
});
|
|
413
|
+
return {
|
|
414
|
+
ok: true,
|
|
415
|
+
status: 200,
|
|
416
|
+
message: restored ? `Restored "${tombstone.fileName}".` : 'That file is already back in the library.',
|
|
417
|
+
fileName: tombstone.fileName
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
//# sourceMappingURL=media-tombstone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/media-tombstone.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FieldValue, Timestamp } from 'firebase-admin/firestore'\nimport { checkQuota } from '@aglyn/aglyn/server'\nimport {\n removeMediaDeliveryCopies,\n withoutMediaDeliveryCopies,\n} from './media-delivery'\n\n/**\n * What a DAM delete has to leave behind for an undo to be possible at all\n * (AGL-1467).\n *\n * ## The gap this closes\n *\n * The bucket has soft-delete on with a **seven-day** retention, so the bytes\n * of a deleted asset really are still there. That was only ever half of an\n * undo, and AGL-1461 shipped honest copy rather than a button because of the\n * other half: `/api/media/upload`'s DELETE branch hard-deleted the Firestore\n * document. After it ran, nothing in the product knew the asset's id, file\n * name, folder, tags, alt text, description, custom metadata, `visibleTo`\n * scope tokens, `cdnPath` or `variants` — and `File.restore()` needs a\n * **generation number** that nobody had captured. Surviving bytes with no\n * address are not a recovery story. On 2026-08-13 two files deleted in error\n * came back only because an unrelated analysis document happened to have\n * recorded their ids; a customer has no such document.\n *\n * A tombstone is the three facts that make the bytes addressable again:\n *\n * 1. the media document verbatim, as it was at the moment of the delete;\n * 2. the **generation** of the storage object and of every CDN variant,\n * read BEFORE the delete — afterwards there is no live object to ask;\n * 3. `sizeBytes`, so the counter decrement can be reversed by exactly the\n * amount it moved rather than by a recomputation that can drift.\n *\n * ## Where it lives, and why that is the whole erasure answer\n *\n * `{hosts|orgs}/{scopeId}/mediaTombstones/{mediaId}` — a subcollection of the\n * scope that owned the asset, never a top-level collection keyed by media id.\n *\n * This is the load-bearing choice. `eraseHost` ends in\n * `recursiveDelete(hostRef)` and `eraseOrg` ends in `recursiveDelete(orgRef)`,\n * and a path-scoped cascade takes every subcollection under the path with it.\n * Put the tombstones there and an erasure removes them with no new code — put\n * them in a top-level `mediaTombstones/{id}` with an `orgId` field and they\n * become exactly the shape AGL-1444 and AGL-1448 had to go back and wire by\n * hand: a collection the cascade is structurally blind to, holding a verbatim\n * copy of customer content, surviving the request that promised it was gone.\n * A tombstone is customer data. It has to die with the customer.\n *\n * (The property is asserted rather than assumed —\n * `erase-media-tombstones.emulator.spec.ts` erases a host and an org that each\n * hold one and looks for the survivor.)\n *\n * ## Retention: the same seven days as the bytes, and not a day more\n *\n * `expiresAt` is stamped at `MEDIA_TOMBSTONE_RETENTION_MS` past the delete,\n * which is the bucket's soft-delete window exactly. Both other numbers are\n * wrong for the same reason from opposite directions: a shorter tombstone\n * strands recoverable bytes with no address, which is today's defect made\n * smaller, and a longer one can only ever produce a failed restore while\n * holding a copy of a customer's asset for no reachable purpose. AGL-1443 is\n * open on precisely that — a durable copy of customer data whose retention\n * nobody chose — and this must not become a second instance of it.\n *\n * The field is enforced two ways, because neither alone is enough. A Firestore\n * TTL policy on `mediaTombstones.expiresAt` reaps them (see\n * `docs/FIRESTORE_MANUAL_CONFIG.md`), and TTL deletion is explicitly not\n * prompt — so `restoreMediaFromTombstone` treats an expired tombstone as\n * absent and deletes it on sight rather than trusting the sweeper.\n */\n\n/** The subcollection, under the scope that owned the asset. */\nexport const MEDIA_TOMBSTONE_COLLECTION = 'mediaTombstones'\n\n/**\n * How long a tombstone lives: the bucket's soft-delete retention, exactly.\n *\n * Changing this without changing the bucket policy breaks the invariant the\n * whole module rests on — see the header.\n */\nexport const MEDIA_TOMBSTONE_RETENTION_MS = 7 * 24 * 60 * 60 * 1000\n\n/** Days, for the copy that has to name the window to a person. */\nexport const MEDIA_TOMBSTONE_RETENTION_DAYS = Math.round(\n MEDIA_TOMBSTONE_RETENTION_MS / (24 * 60 * 60 * 1000),\n)\n\n/**\n * One deleted object and the generation that addresses it.\n *\n * `generation` is nullable on purpose: reading it is a Storage round-trip that\n * can fail, and an asset whose object was ALREADY missing (replaced, swept,\n * never written) must still produce a tombstone — the document half of the\n * restore is worth having on its own. A null generation means \"nothing to\n * restore here\", not \"restore failed\".\n */\nexport interface MediaObjectGeneration {\n path: string\n generation: string | null\n}\n\n/** The stored tombstone document. */\nexport interface MediaTombstoneDoc {\n /** The media document verbatim, exactly as the delete found it. */\n media: Record<string, unknown>\n /** Primary object first, then every CDN variant. */\n objects: MediaObjectGeneration[]\n /** The counter decrement to reverse, taken from the document. */\n sizeBytes: number\n fileName: string\n deletedBy: string\n deletedAt: Timestamp | number\n /**\n * Hard bound — see the header. Written as a **Timestamp**, which the TTL\n * policy requires (a number field cannot carry one, which is why\n * `bookings.expiresAtMs` is documented as not a TTL target). Read through\n * `isMediaTombstoneExpired`, which takes either form so a hand-written\n * fixture and the real write are both legible.\n */\n expiresAt: Timestamp | number\n}\n\n/**\n * The slice of `File` this module needs; the real one satisfies it.\n *\n * `restore` takes a NUMBER because the SDK's `RestoreOptions` does, while the\n * tombstone stores the generation as a string — a GCS generation is a\n * microsecond timestamp (~1.7e15), comfortably inside a double, but a string\n * is what survives JSON, a Firestore round-trip and a log line without anyone\n * having to reason about that. The conversion happens once, at the call.\n */\nexport interface TombstoneStorageFile {\n getMetadata(): Promise<any>\n delete(): Promise<any>\n exists(): Promise<any>\n restore(options: { generation: number }): Promise<any>\n}\n\n/** The slice of `Bucket` this module needs. */\nexport interface TombstoneStorageBucket {\n file(path: string): TombstoneStorageFile\n}\n\n/** When a tombstone written now stops being useful. */\nexport function mediaTombstoneExpiry(deletedAtMs: number): number {\n return deletedAtMs + MEDIA_TOMBSTONE_RETENTION_MS\n}\n\n/** Milliseconds out of a Firestore Timestamp or a plain number. */\nfunction toMillis(value: unknown): number {\n const timestamp = value as { toMillis?: () => number }\n if (typeof timestamp?.toMillis === 'function') return timestamp.toMillis()\n return Number(value ?? 0)\n}\n\n/**\n * Whether the bytes this tombstone addresses are past the bucket's window.\n *\n * Missing or unreadable reads as EXPIRED, which is the safe direction: the\n * failure mode of a false positive is a refusal with a clear message, and the\n * failure mode of a false negative is a restore that half-succeeds against\n * bytes the bucket has already reaped.\n */\nexport function isMediaTombstoneExpired(\n tombstone: Pick<MediaTombstoneDoc, 'expiresAt'>,\n nowMs: number,\n): boolean {\n return !(toMillis(tombstone.expiresAt) > nowMs)\n}\n\n/**\n * Read the generation of each object, best-effort (AGL-1467).\n *\n * Must run BEFORE the delete. Once the object is soft-deleted there is no live\n * generation to read, and the number is the only handle `restore()` takes —\n * this is the single fact whose absence made undo impossible rather than\n * merely unbuilt.\n *\n * A failure here degrades the tombstone to its document half rather than\n * failing the delete: an author who asked for a file to go must not be told\n * \"no\" because a metadata read timed out.\n */\nexport async function captureObjectGenerations(\n bucket: TombstoneStorageBucket,\n paths: readonly string[],\n): Promise<MediaObjectGeneration[]> {\n return Promise.all(\n paths.map(async (path) => {\n try {\n const response = await bucket.file(path).getMetadata()\n const metadata = Array.isArray(response) ? response[0] : response\n const generation = metadata?.generation\n return {\n path,\n generation:\n generation === undefined || generation === null\n ? null\n : String(generation),\n }\n } catch {\n return { path, generation: null }\n }\n }),\n )\n}\n\n/**\n * Removes the delivery provider's copies of a deleted asset (AGL-2824).\n *\n * Unlike the bucket's objects they are not kept for a restore — a restore\n * copies the video again — and no tombstone records them. The library is\n * read off the scope reference (`hosts/{id}` or `orgs/{id}`). Nothing runs\n * when no provider is configured to store, and a failure is logged rather\n * than answered, like the object deletes beside it.\n */\nasync function removeDeliveryCopies(\n scopeRef: FirebaseFirestore.DocumentReference,\n mediaId: string,\n): Promise<void> {\n const collection = scopeRef.parent?.id\n if (collection !== 'hosts' && collection !== 'orgs') return\n await removeMediaDeliveryCopies({\n asset: { collection, scopeId: scopeRef.id, mediaId },\n })\n}\n\nexport interface DeleteMediaResult {\n /** False when there was no document to delete (already gone). */\n deleted: boolean\n /** Present when a tombstone was written — the id is the media id. */\n tombstone?: { mediaId: string; expiresAt: number; fileName: string }\n}\n\n/**\n * Delete a media document and leave a tombstone behind, in one commit.\n *\n * **The invariant: the media document is never destroyed except in the same\n * transaction that writes its tombstone and moves the counter.** All three\n * belong to one commit, so there is no interleaving in which the document is\n * gone and the record of it is not — which is the state the product was\n * permanently in before this issue.\n *\n * The object delete happens AFTER that commit, deliberately, and the ordering\n * is a choice between two partial failures:\n *\n * - object first: a failed commit leaves a live document pointing at bytes\n * that are already soft-deleted — a broken asset in the library that\n * nothing detects;\n * - commit first: a failed object delete leaves a tombstone whose object is\n * still live, which `restoreMediaFromTombstone` handles by skipping the\n * restore for an object that is already there.\n *\n * The second is recoverable by the code in this file. The first is not\n * recoverable by anything.\n */\nexport async function deleteMediaWithTombstone(options: {\n scopeRef: FirebaseFirestore.DocumentReference\n bucket: TombstoneStorageBucket\n mediaId: string\n /** Path of the primary object, resolved by the caller (legacy fallback). */\n objectPath: string\n /** Who asked — an erasure record with no actor is half a record. */\n uid: string\n nowMs?: number\n}): Promise<DeleteMediaResult> {\n const { scopeRef, bucket, mediaId, objectPath, uid } = options\n const nowMs = options.nowMs ?? Date.now()\n const mediaRef = scopeRef.collection('media').doc(mediaId)\n const snapshot = await mediaRef.get()\n if (!snapshot.exists) {\n // No document, so nothing to record and nothing to restore to. The object\n // sweep below still runs: an orphan object is exactly what this branch is\n // for, and it predates the tombstone.\n await bucket.file(objectPath).delete().catch(() => undefined)\n await removeDeliveryCopies(scopeRef, mediaId)\n return { deleted: false }\n }\n\n const variantWidths: number[] = snapshot.get('variants') ?? []\n const variantPaths = variantWidths.map(\n (width) => `${objectPath}__w${width}.webp`,\n )\n // BEFORE the delete — the whole point. See `captureObjectGenerations`.\n const objects = await captureObjectGenerations(bucket, [\n objectPath,\n ...variantPaths,\n ])\n\n const sizeBytes = Number(snapshot.get('sizeBytes') ?? 0)\n const fileName = String(snapshot.get('fileName') ?? mediaId)\n const expiresAt = mediaTombstoneExpiry(nowMs)\n const tombstoneRef = scopeRef\n .collection(MEDIA_TOMBSTONE_COLLECTION)\n .doc(mediaId)\n const counterRef = scopeRef.collection('counters').doc('media')\n\n const committed = await scopeRef.firestore.runTransaction(\n async (transaction) => {\n const fresh = await transaction.get(mediaRef)\n // Someone else deleted it between the read above and here. Their commit\n // wrote the tombstone; ours must not write a second one over it.\n if (!fresh.exists) return false\n const data = (fresh.data() ?? {}) as Record<string, unknown>\n const tombstone: MediaTombstoneDoc = {\n media: data,\n objects,\n sizeBytes: Number(data['sizeBytes'] ?? sizeBytes) || 0,\n fileName: String(data['fileName'] ?? fileName),\n deletedBy: uid,\n deletedAt: Timestamp.fromMillis(nowMs),\n // Timestamp, not a number: the TTL policy on\n // `mediaTombstones.expiresAt` cannot key on anything else.\n expiresAt: Timestamp.fromMillis(expiresAt),\n }\n transaction.set(tombstoneRef, tombstone)\n transaction.delete(mediaRef)\n transaction.set(\n counterRef,\n {\n bytes: FieldValue.increment(-tombstone.sizeBytes),\n count: FieldValue.increment(-1),\n },\n { merge: true },\n )\n return true\n },\n )\n\n // Object and variants last, best-effort, exactly as before — the bucket\n // keeps them for the retention window either way.\n await bucket.file(objectPath).delete().catch(() => undefined)\n await Promise.all(\n variantPaths.map((path) =>\n bucket.file(path).delete().catch(() => undefined),\n ),\n )\n await removeDeliveryCopies(scopeRef, mediaId)\n\n if (!committed) return { deleted: false }\n return { deleted: true, tombstone: { mediaId, expiresAt, fileName } }\n}\n\nexport interface RestoreMediaResult {\n ok: boolean\n /** HTTP status the route should answer with. */\n status: number\n /** A real sentence for a person — never a bare code. */\n message: string\n fileName?: string\n}\n\n/**\n * Why a restore cannot proceed, decided without touching Storage (AGL-1467).\n *\n * Pure, because these are the answers a person actually sees and the two\n * interesting ones are cheap to get wrong: an expired tombstone must fail\n * CLEANLY rather than half-succeed against bytes the bucket has already\n * reaped, and a restore that would breach the plan must say so rather than\n * push the counter past the limit in silence.\n *\n * ## The quota call\n *\n * A restore re-adds real bytes, so it is gated exactly like an upload —\n * `storagePerHostMb`, same off-by-one — and REFUSED when it would breach the\n * plan. Waiving it would let delete-then-restore launder an over-quota\n * library, which is the AGL-1471/AGL-1279 shape (a limit evaluated at a moment\n * the caller controls). Refusing is safe precisely because the tombstone\n * outlives the refusal: the asset is still restorable for the rest of the\n * window once space is freed, which is what makes \"no, and here is why\"\n * an honest answer rather than a loss.\n *\n * Note what is NOT metered: the soft-deleted bytes themselves. They sit in the\n * bucket for seven days at Aglyn's cost, and counting them would mean deleting\n * a file did not free space until a week later — which breaks the one action\n * an author takes when they hit the wall. The window is the price of offering\n * undo, not an allocation to bill back.\n */\nexport function mediaRestoreRefusal(options: {\n tombstone: Pick<MediaTombstoneDoc, 'expiresAt' | 'sizeBytes' | 'fileName'>\n nowMs: number\n /** Counter bytes as they stand now, with the asset already removed. */\n usedBytes: number\n billing: Record<string, unknown> | undefined\n}): { status: number; message: string } | null {\n const { tombstone, nowMs, usedBytes, billing } = options\n if (isMediaTombstoneExpired(tombstone, nowMs)) {\n return {\n status: 410,\n message:\n `\"${tombstone.fileName}\" was deleted more than ` +\n `${MEDIA_TOMBSTONE_RETENTION_DAYS} days ago, so its file is no ` +\n 'longer recoverable.',\n }\n }\n const usedMb = (usedBytes + Number(tombstone.sizeBytes ?? 0)) / (1024 * 1024)\n const quota = checkQuota(\n billing as never,\n 'storagePerHostMb',\n Math.ceil(usedMb) - 1,\n )\n if (!quota.allowed) {\n return {\n status: 403,\n message:\n `Restoring \"${tombstone.fileName}\" would put this library over its ` +\n `storage limit (${quota.limit} MB). Free up space and try again — ` +\n 'the file stays restorable until the window closes.',\n }\n }\n return null\n}\n\n/**\n * Put a deleted asset back: object, variants, document and counters.\n *\n * Order is the same argument as the delete, run backwards. Bytes first, then\n * the commit — so the only partial state this can leave is an object restored\n * with no document, which the tombstone (still present, because the commit is\n * what consumes it) makes a retry away from finished. The reverse order would\n * publish a document whose bytes may never arrive.\n *\n * The commit itself carries the document write, the tombstone delete and both\n * counter increments together, and it re-reads the tombstone inside the\n * transaction. That re-read is what makes a double-click harmless: the second\n * transaction finds no tombstone, commits nothing, and the caller is told the\n * file is already back rather than being charged for it twice.\n */\nexport async function restoreMediaFromTombstone(options: {\n scopeRef: FirebaseFirestore.DocumentReference\n bucket: TombstoneStorageBucket\n mediaId: string\n billing: Record<string, unknown> | undefined\n nowMs?: number\n}): Promise<RestoreMediaResult> {\n const { scopeRef, bucket, mediaId, billing } = options\n const nowMs = options.nowMs ?? Date.now()\n const mediaRef = scopeRef.collection('media').doc(mediaId)\n const tombstoneRef = scopeRef\n .collection(MEDIA_TOMBSTONE_COLLECTION)\n .doc(mediaId)\n const counterRef = scopeRef.collection('counters').doc('media')\n\n const tombstoneSnapshot = await tombstoneRef.get()\n if (!tombstoneSnapshot.exists) {\n // Either it was never written, or the window closed and the TTL swept it.\n // Both are the same fact to the caller, and neither is an error state the\n // product can act on.\n const media = await mediaRef.get()\n if (media.exists) {\n return {\n ok: true,\n status: 200,\n message: 'That file is already back in the library.',\n fileName: String(media.get('fileName') ?? mediaId),\n }\n }\n return {\n ok: false,\n status: 404,\n message: 'That file can no longer be restored.',\n }\n }\n\n const tombstone = tombstoneSnapshot.data() as MediaTombstoneDoc\n const counter = await counterRef.get()\n const usedBytes = Number(counter.get('bytes') ?? 0)\n const refusal = mediaRestoreRefusal({\n tombstone,\n nowMs,\n usedBytes,\n billing,\n })\n if (refusal) {\n // An expired tombstone is dead weight — a copy of customer data whose only\n // possible future is this refusal. Reap it here rather than waiting on a\n // TTL sweep that is documented as unprompt.\n if (refusal.status === 410) {\n await tombstoneRef.delete().catch(() => undefined)\n }\n return { ok: false, ...refusal, fileName: tombstone.fileName }\n }\n\n const objects = Array.isArray(tombstone.objects) ? tombstone.objects : []\n const [primary, ...variants] = objects\n const restoreObject = async (\n object: MediaObjectGeneration,\n ): Promise<boolean> => {\n if (!object?.generation) return false\n const file = bucket.file(object.path)\n // Already live — the delete's object sweep is best-effort, so this is a\n // real branch, not a defensive one. `restore()` on a live generation is\n // not a no-op, so the check has to come first.\n const existing = await file.exists().catch(() => [false])\n if (Array.isArray(existing) ? existing[0] : existing) return true\n await file.restore({ generation: Number(object.generation) })\n return true\n }\n\n if (primary) {\n try {\n await restoreObject(primary)\n } catch (error) {\n console.error(\n `restoreMediaFromTombstone: object restore failed for ${mediaId}`,\n error,\n )\n return {\n ok: false,\n status: 502,\n message:\n `\"${tombstone.fileName}\" could not be restored — its file could ` +\n 'not be recovered from storage. Nothing was changed.',\n fileName: tombstone.fileName,\n }\n }\n }\n // Variants are derived artifacts the platform can regenerate, and the upload\n // path already refuses to fail an asset for them. Same call here.\n for (const variant of variants) {\n await restoreObject(variant).catch((error) => {\n console.error(\n `restoreMediaFromTombstone: variant ${variant?.path} failed`,\n error,\n )\n return false\n })\n }\n\n const restored = await scopeRef.firestore.runTransaction(\n async (transaction) => {\n const fresh = await transaction.get(tombstoneRef)\n if (!fresh.exists) return false\n const record = fresh.data() as MediaTombstoneDoc\n // Without its delivery copy record: the delete removed those copies,\n // and a record of them would name objects that are gone (AGL-2824).\n transaction.set(mediaRef, withoutMediaDeliveryCopies(record.media))\n transaction.delete(tombstoneRef)\n transaction.set(\n counterRef,\n {\n bytes: FieldValue.increment(Number(record.sizeBytes ?? 0)),\n count: FieldValue.increment(1),\n },\n { merge: true },\n )\n return true\n },\n )\n\n return {\n ok: true,\n status: 200,\n message: restored\n ? `Restored \"${tombstone.fileName}\".`\n : 'That file is already back in the library.',\n fileName: tombstone.fileName,\n }\n}\n"],"names":["FieldValue","Timestamp","checkQuota","removeMediaDeliveryCopies","withoutMediaDeliveryCopies","MEDIA_TOMBSTONE_COLLECTION","MEDIA_TOMBSTONE_RETENTION_MS","MEDIA_TOMBSTONE_RETENTION_DAYS","Math","round","mediaTombstoneExpiry","deletedAtMs","toMillis","value","timestamp","Number","isMediaTombstoneExpired","tombstone","nowMs","expiresAt","captureObjectGenerations","bucket","paths","Promise","all","map","path","response","file","getMetadata","metadata","Array","isArray","generation","undefined","String","removeDeliveryCopies","scopeRef","mediaId","collection","parent","id","asset","scopeId","deleteMediaWithTombstone","options","snapshot","objectPath","uid","Date","now","mediaRef","doc","get","exists","delete","catch","deleted","variantWidths","variantPaths","width","objects","sizeBytes","fileName","tombstoneRef","counterRef","committed","firestore","runTransaction","transaction","fresh","data","media","deletedBy","deletedAt","fromMillis","set","bytes","increment","count","merge","mediaRestoreRefusal","usedBytes","billing","status","message","usedMb","quota","ceil","allowed","limit","restoreMediaFromTombstone","counter","tombstoneSnapshot","ok","refusal","primary","variants","restoreObject","object","existing","restore","error","console","variant","restored","record"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,EAAEC,SAAS,QAAQ,2BAA0B;AAChE,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SACEC,yBAAyB,EACzBC,0BAA0B,QACrB,sBAAkB;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DC,GAED,6DAA6D,GAC7D,OAAO,MAAMC,6BAA6B,kBAAiB;AAE3D;;;;;CAKC,GACD,OAAO,MAAMC,+BAA+B,IAAI,KAAK,KAAK,KAAK,KAAI;AAEnE,gEAAgE,GAChE,OAAO,MAAMC,iCAAiCC,KAAKC,KAAK,CACtDH,+BAAgC,CAAA,KAAK,KAAK,KAAK,IAAG,GACnD;AA0DD,qDAAqD,GACrD,OAAO,SAASI,qBAAqBC,WAAmB;IACtD,OAAOA,cAAcL;AACvB;AAEA,iEAAiE,GACjE,SAASM,SAASC,KAAc;IAC9B,MAAMC,YAAYD;IAClB,IAAI,QAAOC,6BAAAA,UAAWF,QAAQ,MAAK,YAAY,OAAOE,UAAUF,QAAQ;IACxE,OAAOG,OAAOF,gBAAAA,QAAS;AACzB;AAEA;;;;;;;CAOC,GACD,OAAO,SAASG,wBACdC,SAA+C,EAC/CC,KAAa;IAEb,OAAO,CAAEN,CAAAA,SAASK,UAAUE,SAAS,IAAID,KAAI;AAC/C;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,eAAeE,yBACpBC,MAA8B,EAC9BC,KAAwB;IAExB,OAAOC,QAAQC,GAAG,CAChBF,MAAMG,GAAG,CAAC,O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