create-freeholder 0.0.0-bootstrap.0 → 0.2.0-beta.2
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/README.md +30 -2
- package/dist/index.d.ts +72 -0
- package/dist/index.js +672 -0
- package/dist/template/.changeset/README.md +8 -0
- package/dist/template/.changeset/access-from-grants.md +14 -0
- package/dist/template/.changeset/accounting-exports.md +32 -0
- package/dist/template/.changeset/ad-creatives.md +33 -0
- package/dist/template/.changeset/ad-inventory.md +19 -0
- package/dist/template/.changeset/ad-measurement.md +10 -0
- package/dist/template/.changeset/ad-third-party.md +9 -0
- package/dist/template/.changeset/admin-ads.md +9 -0
- package/dist/template/.changeset/admin-documents.md +7 -0
- package/dist/template/.changeset/admin-loyalty.md +9 -0
- package/dist/template/.changeset/admin-referrals.md +9 -0
- package/dist/template/.changeset/admin-shell.md +16 -0
- package/dist/template/.changeset/adversarial-cms-boundaries.md +8 -0
- package/dist/template/.changeset/adversarial-customer-invariants.md +7 -0
- package/dist/template/.changeset/adversarial-customer-privacy.md +13 -0
- package/dist/template/.changeset/adversarial-platform-safety.md +15 -0
- package/dist/template/.changeset/agent-approval-inbox.md +5 -0
- package/dist/template/.changeset/agent-autonomy-writes.md +5 -0
- package/dist/template/.changeset/agent-budgets.md +5 -0
- package/dist/template/.changeset/agent-catalogue.md +22 -0
- package/dist/template/.changeset/agent-f04.md +6 -0
- package/dist/template/.changeset/agent-injection-hardening.md +5 -0
- package/dist/template/.changeset/agent-pause-kill-switch.md +5 -0
- package/dist/template/.changeset/agent-playbooks.md +5 -0
- package/dist/template/.changeset/agent-run-live.md +5 -0
- package/dist/template/.changeset/agent-work-board.md +5 -0
- package/dist/template/.changeset/agents-inbound.md +31 -0
- package/dist/template/.changeset/agents-model.md +27 -0
- package/dist/template/.changeset/alt-text-suggestions.md +8 -0
- package/dist/template/.changeset/analytics-governance.md +7 -0
- package/dist/template/.changeset/analytics-proxy-origin.md +8 -0
- package/dist/template/.changeset/analytics.md +10 -0
- package/dist/template/.changeset/apache-license.md +15 -0
- package/dist/template/.changeset/api-keys.md +19 -0
- package/dist/template/.changeset/arabic-rtl-catalog.md +23 -0
- package/dist/template/.changeset/assistant-grounding.md +10 -0
- package/dist/template/.changeset/assistant-guardrails.md +11 -0
- package/dist/template/.changeset/attested-facts-and-corrections.md +11 -0
- package/dist/template/.changeset/audit-search-and-proof.md +34 -0
- package/dist/template/.changeset/autofill-safety.md +22 -0
- package/dist/template/.changeset/automation-guardrails.md +9 -0
- package/dist/template/.changeset/automation-runtime.md +9 -0
- package/dist/template/.changeset/automations-builder.md +9 -0
- package/dist/template/.changeset/availability-resolver.md +29 -0
- package/dist/template/.changeset/availability.md +23 -0
- package/dist/template/.changeset/booking-audiences.md +24 -0
- package/dist/template/.changeset/booking-race-message.md +15 -0
- package/dist/template/.changeset/bookings.md +28 -0
- package/dist/template/.changeset/boot-in-request-graph.md +7 -0
- package/dist/template/.changeset/bot-detection.md +9 -0
- package/dist/template/.changeset/briefing-delivery.md +21 -0
- package/dist/template/.changeset/briefing-sections.md +22 -0
- package/dist/template/.changeset/browser-journeys.md +8 -0
- package/dist/template/.changeset/builder-code-lane.md +25 -0
- package/dist/template/.changeset/business-presets.md +8 -0
- package/dist/template/.changeset/business-settings-and-csrf.md +17 -0
- package/dist/template/.changeset/c11-08-restore-drill.md +20 -0
- package/dist/template/.changeset/c11-12-f04-axe.md +8 -0
- package/dist/template/.changeset/c11-14-retention.md +8 -0
- package/dist/template/.changeset/c11-14-search.md +11 -0
- package/dist/template/.changeset/c11-journeys.md +7 -0
- package/dist/template/.changeset/c11-ops.md +8 -0
- package/dist/template/.changeset/c11-quality.md +8 -0
- package/dist/template/.changeset/c1111-reference-acceptance.md +8 -0
- package/dist/template/.changeset/c1111-reference-target-closure.md +8 -0
- package/dist/template/.changeset/c224-inline-canvas.md +13 -0
- package/dist/template/.changeset/c224-merchandising-blocks.md +19 -0
- package/dist/template/.changeset/c225-canvas-caret-swap.md +5 -0
- package/dist/template/.changeset/c225-canvas-drag-drop.md +5 -0
- package/dist/template/.changeset/c225-canvas-media-tools.md +5 -0
- package/dist/template/.changeset/c225-store-sections.md +5 -0
- package/dist/template/.changeset/c313-live-paradise-acceptance.md +8 -0
- package/dist/template/.changeset/c324-storefront-parity.md +5 -0
- package/dist/template/.changeset/c6-11-events-evidence.md +14 -0
- package/dist/template/.changeset/caddy-domain-env.md +7 -0
- package/dist/template/.changeset/calculators-and-coverage.md +13 -0
- package/dist/template/.changeset/calculators-localized-evidence.md +11 -0
- package/dist/template/.changeset/calendar-oauth.md +5 -0
- package/dist/template/.changeset/calendars.md +26 -0
- package/dist/template/.changeset/campaign-broadcasts.md +34 -0
- package/dist/template/.changeset/canonical-two-factor-envelope.md +7 -0
- package/dist/template/.changeset/capture-chunk-integrity.md +5 -0
- package/dist/template/.changeset/cart-capability-authorization.md +10 -0
- package/dist/template/.changeset/cart-contact-authority.md +5 -0
- package/dist/template/.changeset/catalog-checkout-milestones.md +8 -0
- package/dist/template/.changeset/catalog-quality-rtl.md +12 -0
- package/dist/template/.changeset/change-password.md +8 -0
- package/dist/template/.changeset/ci-minio-quay.md +6 -0
- package/dist/template/.changeset/client-documents.md +11 -0
- package/dist/template/.changeset/client-galleries.md +7 -0
- package/dist/template/.changeset/client-gallery-delivery-audit.md +9 -0
- package/dist/template/.changeset/client-readiness-security.md +7 -0
- package/dist/template/.changeset/close-world-class-storefront.md +27 -0
- package/dist/template/.changeset/cms-a11y-hints.md +5 -0
- package/dist/template/.changeset/cms-author-history.md +8 -0
- package/dist/template/.changeset/cms-blocks.md +8 -0
- package/dist/template/.changeset/cms-cache-budgets.md +5 -0
- package/dist/template/.changeset/cms-chrome-sections.md +8 -0
- package/dist/template/.changeset/cms-collab-presence-comments.md +7 -0
- package/dist/template/.changeset/cms-content-lifecycle.md +9 -0
- package/dist/template/.changeset/cms-design-tokens.md +5 -0
- package/dist/template/.changeset/cms-editor.md +8 -0
- package/dist/template/.changeset/cms-email-editor.md +5 -0
- package/dist/template/.changeset/cms-entity-layouts.md +5 -0
- package/dist/template/.changeset/cms-experiment-reporting.md +5 -0
- package/dist/template/.changeset/cms-experiments.md +5 -0
- package/dist/template/.changeset/cms-locale-workflow.md +5 -0
- package/dist/template/.changeset/cms-plugin-proof.md +5 -0
- package/dist/template/.changeset/cms-rich-editor-foundations.md +8 -0
- package/dist/template/.changeset/cms-section-instances.md +5 -0
- package/dist/template/.changeset/cms-surface-blocks.md +9 -0
- package/dist/template/.changeset/cms-templates.md +5 -0
- package/dist/template/.changeset/collections-taxonomy.md +5 -0
- package/dist/template/.changeset/commerce-advanced-money.md +16 -0
- package/dist/template/.changeset/commerce-carts-orders.md +9 -0
- package/dist/template/.changeset/commerce-catalog-merchandising.md +5 -0
- package/dist/template/.changeset/commerce-edge-contracts.md +5 -0
- package/dist/template/.changeset/commerce-fulfillment.md +9 -0
- package/dist/template/.changeset/commerce-inventory-ledger.md +9 -0
- package/dist/template/.changeset/commerce-invoice-admin.md +5 -0
- package/dist/template/.changeset/commerce-money-foundation.md +5 -0
- package/dist/template/.changeset/commerce-payment-providers.md +8 -0
- package/dist/template/.changeset/commerce-pos.md +8 -0
- package/dist/template/.changeset/commerce-procurement.md +9 -0
- package/dist/template/.changeset/commerce-product-lifecycle.md +16 -0
- package/dist/template/.changeset/commerce-promotions.md +8 -0
- package/dist/template/.changeset/commerce-provider-parity.md +10 -0
- package/dist/template/.changeset/commerce-relations-breaks.md +5 -0
- package/dist/template/.changeset/commerce-service-offerings.md +11 -0
- package/dist/template/.changeset/commerce-shipping-rates.md +9 -0
- package/dist/template/.changeset/commerce-tax-templates.md +5 -0
- package/dist/template/.changeset/commerce-variant-matrices.md +5 -0
- package/dist/template/.changeset/community-rooms.md +7 -0
- package/dist/template/.changeset/complete-demo-scenarios.md +10 -0
- package/dist/template/.changeset/completion-honesty.md +10 -0
- package/dist/template/.changeset/config.json +11 -0
- package/dist/template/.changeset/connection-grants.md +5 -0
- package/dist/template/.changeset/consent-gated-media.md +13 -0
- package/dist/template/.changeset/consent-is-evidence.md +13 -0
- package/dist/template/.changeset/contact-data-depth.md +16 -0
- package/dist/template/.changeset/contact-duplicate-review.md +17 -0
- package/dist/template/.changeset/contact-import.md +26 -0
- package/dist/template/.changeset/contact-merge-ui.md +8 -0
- package/dist/template/.changeset/contact-privacy-rights.md +18 -0
- package/dist/template/.changeset/contacts-admin.md +15 -0
- package/dist/template/.changeset/contacts-create-human-only.md +5 -0
- package/dist/template/.changeset/content-security-policy.md +8 -0
- package/dist/template/.changeset/contract-templates.md +22 -0
- package/dist/template/.changeset/contribute-channel.md +5 -0
- package/dist/template/.changeset/contribute-status-replies.md +5 -0
- package/dist/template/.changeset/conversations.md +20 -0
- package/dist/template/.changeset/core-jobs.md +9 -0
- package/dist/template/.changeset/core-runs.md +7 -0
- package/dist/template/.changeset/core-seo.md +10 -0
- package/dist/template/.changeset/create-freeholder-setup.md +8 -0
- package/dist/template/.changeset/credential-encryption.md +26 -0
- package/dist/template/.changeset/custom-field-options-default.md +8 -0
- package/dist/template/.changeset/customer-booking-screens.md +9 -0
- package/dist/template/.changeset/customer-dependency-security.md +5 -0
- package/dist/template/.changeset/customer-gallery-foundation.md +8 -0
- package/dist/template/.changeset/customer-invoice-payments.md +5 -0
- package/dist/template/.changeset/customer-magic-links.md +12 -0
- package/dist/template/.changeset/customer-mobile-contracts.md +6 -0
- package/dist/template/.changeset/customer-reply-and-account.md +7 -0
- package/dist/template/.changeset/customer-self-service.md +12 -0
- package/dist/template/.changeset/customization-seams.md +7 -0
- package/dist/template/.changeset/daily-briefing.md +27 -0
- package/dist/template/.changeset/daily-private-rooms.md +8 -0
- package/dist/template/.changeset/daily-update-check.md +6 -0
- package/dist/template/.changeset/danger-token-integrity.md +5 -0
- package/dist/template/.changeset/demo-same-droplet.md +12 -0
- package/dist/template/.changeset/dependency-security-policy.md +7 -0
- package/dist/template/.changeset/deploy-script-stdin.md +5 -0
- package/dist/template/.changeset/design-system-and-setup.md +17 -0
- package/dist/template/.changeset/deterministic-demo-scenarios.md +5 -0
- package/dist/template/.changeset/digitalocean-droplet-recipe.md +15 -0
- package/dist/template/.changeset/doc-claim-mapping.md +5 -0
- package/dist/template/.changeset/docs-availability.md +7 -0
- package/dist/template/.changeset/doctor.md +9 -0
- package/dist/template/.changeset/done.md +8 -0
- package/dist/template/.changeset/droplet-backup-cron-env.md +10 -0
- package/dist/template/.changeset/dunning.md +10 -0
- package/dist/template/.changeset/durable-provider-work.md +10 -0
- package/dist/template/.changeset/editor-preview-local-draft.md +5 -0
- package/dist/template/.changeset/editor-publish-autosave-race.md +5 -0
- package/dist/template/.changeset/embeds-with-backlinks.md +7 -0
- package/dist/template/.changeset/enforced-service-area-coverage.md +5 -0
- package/dist/template/.changeset/events-newsletters-seo.md +5 -0
- package/dist/template/.changeset/executable-tier-one-portability.md +5 -0
- package/dist/template/.changeset/expo-customer-app.md +10 -0
- package/dist/template/.changeset/external-calendar-sync.md +20 -0
- package/dist/template/.changeset/f-matrix-2026-09-16.md +17 -0
- package/dist/template/.changeset/f-matrix.md +9 -0
- package/dist/template/.changeset/f04-journey-screens.md +11 -0
- package/dist/template/.changeset/faceted-browse-storefront-search.md +5 -0
- package/dist/template/.changeset/first-party-plugin-surfaces.md +8 -0
- package/dist/template/.changeset/fork-lane.md +11 -0
- package/dist/template/.changeset/form-builder.md +26 -0
- package/dist/template/.changeset/forms-get-public-projection.md +13 -0
- package/dist/template/.changeset/forms-module.md +10 -0
- package/dist/template/.changeset/freeholder-app-init.md +10 -0
- package/dist/template/.changeset/front-site-assistant.md +29 -0
- package/dist/template/.changeset/gallery-approval-rounds.md +8 -0
- package/dist/template/.changeset/gallery-archive-delivery.md +13 -0
- package/dist/template/.changeset/gallery-download-policy.md +8 -0
- package/dist/template/.changeset/gallery-partner-share.md +8 -0
- package/dist/template/.changeset/gallery-proofing.md +9 -0
- package/dist/template/.changeset/gallery-sales.md +11 -0
- package/dist/template/.changeset/gate-hardening.md +5 -0
- package/dist/template/.changeset/generate-alt-text-without-open-transactions.md +9 -0
- package/dist/template/.changeset/graceful-job-shutdown.md +8 -0
- package/dist/template/.changeset/help-centre.md +16 -0
- package/dist/template/.changeset/honest-error-states.md +5 -0
- package/dist/template/.changeset/host-executor-drills.md +5 -0
- package/dist/template/.changeset/host-image-identity.md +5 -0
- package/dist/template/.changeset/host-updater-migration-lane.md +5 -0
- package/dist/template/.changeset/http-api.md +23 -0
- package/dist/template/.changeset/http-edge-auth-routes.md +14 -0
- package/dist/template/.changeset/ics-and-calendar-writeback.md +19 -0
- package/dist/template/.changeset/ics-feed-500.md +7 -0
- package/dist/template/.changeset/import-replace-rollback.md +5 -0
- package/dist/template/.changeset/inbox.md +24 -0
- package/dist/template/.changeset/intake-waivers-and-reminders.md +26 -0
- package/dist/template/.changeset/internal-service-boundary.md +9 -0
- package/dist/template/.changeset/job-operations.md +14 -0
- package/dist/template/.changeset/job-runtime-health.md +9 -0
- package/dist/template/.changeset/leftover-f04.md +8 -0
- package/dist/template/.changeset/light-and-dark.md +12 -0
- package/dist/template/.changeset/living-contract.md +5 -0
- package/dist/template/.changeset/locale-driven-customer-surfaces.md +14 -0
- package/dist/template/.changeset/locale-routing.md +10 -0
- package/dist/template/.changeset/locations-and-nap.md +29 -0
- package/dist/template/.changeset/loyalty-points.md +17 -0
- package/dist/template/.changeset/loyalty-tiers-rewards.md +20 -0
- package/dist/template/.changeset/mail-adapter-completion.md +20 -0
- package/dist/template/.changeset/mail-and-reset.md +10 -0
- package/dist/template/.changeset/mail-contacts.md +28 -0
- package/dist/template/.changeset/mail-delivery-boundary.md +10 -0
- package/dist/template/.changeset/managed-agent-loop.md +5 -0
- package/dist/template/.changeset/marketplace-channel-sync.md +7 -0
- package/dist/template/.changeset/mcp-server.md +20 -0
- package/dist/template/.changeset/media-and-canvas.md +8 -0
- package/dist/template/.changeset/media-capture-review.md +8 -0
- package/dist/template/.changeset/media-capture-sessions.md +5 -0
- package/dist/template/.changeset/media-delete-and-inline-editing.md +7 -0
- package/dist/template/.changeset/media-lifecycle.md +9 -0
- package/dist/template/.changeset/media-phone-ingest.md +8 -0
- package/dist/template/.changeset/memberships.md +37 -0
- package/dist/template/.changeset/message-templates.md +9 -0
- package/dist/template/.changeset/mobile-app-package.md +10 -0
- package/dist/template/.changeset/mobile-capture-batches.md +9 -0
- package/dist/template/.changeset/mobile-dependency-security.md +5 -0
- package/dist/template/.changeset/mobile-screens.md +10 -0
- package/dist/template/.changeset/mobile-store-ci.md +11 -0
- package/dist/template/.changeset/mobile-v2-deferral.md +12 -0
- package/dist/template/.changeset/n1-schema.md +6 -0
- package/dist/template/.changeset/named-roles-grants.md +10 -0
- package/dist/template/.changeset/native-customer-invoices.md +9 -0
- package/dist/template/.changeset/native-gallery-proofing.md +6 -0
- package/dist/template/.changeset/next-critical-advisories.md +6 -0
- package/dist/template/.changeset/no-double-booking.md +13 -0
- package/dist/template/.changeset/no-live-phone-example.md +5 -0
- package/dist/template/.changeset/note-task-recovery.md +9 -0
- package/dist/template/.changeset/notes.md +22 -0
- package/dist/template/.changeset/notification-fanout-inbox.md +17 -0
- package/dist/template/.changeset/on-danger-token.md +9 -0
- package/dist/template/.changeset/one-answer-to-who.md +24 -0
- package/dist/template/.changeset/open-source-demo-only.md +7 -0
- package/dist/template/.changeset/order-read-authorization.md +10 -0
- package/dist/template/.changeset/outbox-dead-letters.md +13 -0
- package/dist/template/.changeset/owner-agent-launch.md +4 -0
- package/dist/template/.changeset/owner-authored-assessments.md +15 -0
- package/dist/template/.changeset/owner-companion.md +10 -0
- package/dist/template/.changeset/owner-content-builder.md +21 -0
- package/dist/template/.changeset/owner-facing-helper.md +5 -0
- package/dist/template/.changeset/owner-storage-recording-import.md +8 -0
- package/dist/template/.changeset/ownership-recovery.md +5 -0
- package/dist/template/.changeset/ownership.md +8 -0
- package/dist/template/.changeset/package-artifact-integrity.md +9 -0
- package/dist/template/.changeset/paradise-comms-adapter.md +5 -0
- package/dist/template/.changeset/patch-uuid-buffer-advisory.md +7 -0
- package/dist/template/.changeset/paywalls.md +10 -0
- package/dist/template/.changeset/perf-harness-windows.md +11 -0
- package/dist/template/.changeset/perf-measurement-families.md +8 -0
- package/dist/template/.changeset/phase-0-foundations.md +7 -0
- package/dist/template/.changeset/pipelines.md +21 -0
- package/dist/template/.changeset/plan-evidence-gate.md +7 -0
- package/dist/template/.changeset/plan-proof-clause.md +9 -0
- package/dist/template/.changeset/plan-provider-pivot-2026-09-27.md +20 -0
- package/dist/template/.changeset/plan-world-class-commerce-editor-2026-09-29.md +21 -0
- package/dist/template/.changeset/playbook-schedules.md +21 -0
- package/dist/template/.changeset/playground-hardening.md +5 -0
- package/dist/template/.changeset/plugin-contract.md +5 -0
- package/dist/template/.changeset/popups.md +37 -0
- package/dist/template/.changeset/portable-plugins.md +5 -0
- package/dist/template/.changeset/portal-rooms.md +16 -0
- package/dist/template/.changeset/portal-shell.md +11 -0
- package/dist/template/.changeset/print-on-demand-fulfillment.md +7 -0
- package/dist/template/.changeset/printify-live-fulfillment.md +11 -0
- package/dist/template/.changeset/private-location-access.md +10 -0
- package/dist/template/.changeset/private-mobile-cache.md +6 -0
- package/dist/template/.changeset/private-note-access.md +8 -0
- package/dist/template/.changeset/privileged-two-factor.md +11 -0
- package/dist/template/.changeset/product-completion-plan.md +10 -0
- package/dist/template/.changeset/product-gift-share.md +7 -0
- package/dist/template/.changeset/project-case-studies.md +7 -0
- package/dist/template/.changeset/projects.md +24 -0
- package/dist/template/.changeset/provider-recording-erasure.md +8 -0
- package/dist/template/.changeset/provider-workflows-without-open-transactions.md +15 -0
- package/dist/template/.changeset/public-beta-2.md +4 -0
- package/dist/template/.changeset/public-beta-preparation.md +4 -0
- package/dist/template/.changeset/public-cart-checkout-confirmation.md +5 -0
- package/dist/template/.changeset/public-entity-drafts.md +6 -0
- package/dist/template/.changeset/public-gates.md +9 -0
- package/dist/template/.changeset/public-playground-host-updates.md +10 -0
- package/dist/template/.changeset/public-project-portfolios.md +7 -0
- package/dist/template/.changeset/publish-image.md +7 -0
- package/dist/template/.changeset/purge-without-open-transactions.md +9 -0
- package/dist/template/.changeset/push-notifications.md +11 -0
- package/dist/template/.changeset/queue-performance-clock.md +8 -0
- package/dist/template/.changeset/quote-conversion.md +22 -0
- package/dist/template/.changeset/quote-partner-share.md +7 -0
- package/dist/template/.changeset/quotes.md +22 -0
- package/dist/template/.changeset/real-browser-accessibility.md +7 -0
- package/dist/template/.changeset/recipe-bootstrap-fixes.md +9 -0
- package/dist/template/.changeset/recipe-update-backup-gate.md +5 -0
- package/dist/template/.changeset/recipient-messaging-policy.md +8 -0
- package/dist/template/.changeset/record-search-orders-subscriptions-gifts.md +8 -0
- package/dist/template/.changeset/record-studio-permissions.md +7 -0
- package/dist/template/.changeset/record-trash-every-row.md +9 -0
- package/dist/template/.changeset/recurring-invoices.md +24 -0
- package/dist/template/.changeset/referral-attribution.md +20 -0
- package/dist/template/.changeset/referral-commissions.md +11 -0
- package/dist/template/.changeset/register-stored-original-without-open-transactions.md +7 -0
- package/dist/template/.changeset/release-channels.md +7 -0
- package/dist/template/.changeset/remove-forced-builder-credit.md +5 -0
- package/dist/template/.changeset/rentals.md +22 -0
- package/dist/template/.changeset/reports-you-will-read.md +31 -0
- package/dist/template/.changeset/rescan-without-open-transactions.md +9 -0
- package/dist/template/.changeset/retire-stale-handoffs.md +7 -0
- package/dist/template/.changeset/reviews.md +11 -0
- package/dist/template/.changeset/rich-link-url-allowlist.md +5 -0
- package/dist/template/.changeset/role-guidance.md +5 -0
- package/dist/template/.changeset/rule-strong-token.md +13 -0
- package/dist/template/.changeset/saved-views.md +19 -0
- package/dist/template/.changeset/schema-baseline.md +12 -0
- package/dist/template/.changeset/scoring.md +23 -0
- package/dist/template/.changeset/security-parsing-and-recovery.md +8 -0
- package/dist/template/.changeset/seed-demo.md +8 -0
- package/dist/template/.changeset/seeded-development-home.md +5 -0
- package/dist/template/.changeset/segments.md +21 -0
- package/dist/template/.changeset/self-building-scope.md +12 -0
- package/dist/template/.changeset/seo-riba-surface.md +11 -0
- package/dist/template/.changeset/service-output-schemas.md +5 -0
- package/dist/template/.changeset/session-device-management.md +11 -0
- package/dist/template/.changeset/sharing-in-the-dna.md +32 -0
- package/dist/template/.changeset/ship-replit-storage-sdk.md +5 -0
- package/dist/template/.changeset/shopify-live-channel.md +12 -0
- package/dist/template/.changeset/shopify-refund-reconciliation.md +8 -0
- package/dist/template/.changeset/signed-candidate-history.md +4 -0
- package/dist/template/.changeset/signed-release-feed.md +6 -0
- package/dist/template/.changeset/signup-contact-import.md +5 -0
- package/dist/template/.changeset/site-live-chat.md +5 -0
- package/dist/template/.changeset/sms-consent-boundary.md +8 -0
- package/dist/template/.changeset/sms-registration.md +25 -0
- package/dist/template/.changeset/sms-templates-keywords-mms.md +5 -0
- package/dist/template/.changeset/sms.md +27 -0
- package/dist/template/.changeset/social-composer.md +9 -0
- package/dist/template/.changeset/social-connections.md +10 -0
- package/dist/template/.changeset/social-gbp.md +7 -0
- package/dist/template/.changeset/social-ingest.md +8 -0
- package/dist/template/.changeset/social-onboarding.md +8 -0
- package/dist/template/.changeset/source-first-start.md +5 -0
- package/dist/template/.changeset/source-map-security-floor.md +4 -0
- package/dist/template/.changeset/source-provenance.md +16 -0
- package/dist/template/.changeset/spine-and-service-registry.md +21 -0
- package/dist/template/.changeset/stable-release-publication.md +10 -0
- package/dist/template/.changeset/staff-invitations.md +13 -0
- package/dist/template/.changeset/standalone-artifact-boundary.md +5 -0
- package/dist/template/.changeset/standing-debts-1.md +10 -0
- package/dist/template/.changeset/storage-adapters.md +12 -0
- package/dist/template/.changeset/subscription-billing.md +12 -0
- package/dist/template/.changeset/supplier-agreement-search.md +8 -0
- package/dist/template/.changeset/supply-chain-release-gate.md +11 -0
- package/dist/template/.changeset/tasks.md +20 -0
- package/dist/template/.changeset/tax-adapter-seam.md +5 -0
- package/dist/template/.changeset/third-party-batch-2.md +28 -0
- package/dist/template/.changeset/third-party-findings-batch-1.md +27 -0
- package/dist/template/.changeset/tidy-sites-drop.md +9 -0
- package/dist/template/.changeset/time-entries.md +24 -0
- package/dist/template/.changeset/transaction-composition-integrity.md +22 -0
- package/dist/template/.changeset/transactional-jobs.md +15 -0
- package/dist/template/.changeset/translation-admin.md +26 -0
- package/dist/template/.changeset/translation-draft-honesty.md +5 -0
- package/dist/template/.changeset/typed-sdk.md +7 -0
- package/dist/template/.changeset/unified-calendar.md +23 -0
- package/dist/template/.changeset/update-admin.md +12 -0
- package/dist/template/.changeset/update-apply.md +6 -0
- package/dist/template/.changeset/update-cli.md +10 -0
- package/dist/template/.changeset/update-escalation.md +11 -0
- package/dist/template/.changeset/update-policy.md +6 -0
- package/dist/template/.changeset/update-preflight.md +6 -0
- package/dist/template/.changeset/update-status.md +10 -0
- package/dist/template/.changeset/update-targets.md +10 -0
- package/dist/template/.changeset/upgrade-gates.md +9 -0
- package/dist/template/.changeset/uploads-without-open-transactions.md +9 -0
- package/dist/template/.changeset/versioned-release.md +10 -0
- package/dist/template/.changeset/visit-to-paid-funnel.md +27 -0
- package/dist/template/.changeset/visual-drag.md +6 -0
- package/dist/template/.changeset/voice-video-rooms.md +8 -0
- package/dist/template/.changeset/voicevideo-credential-expiry.md +8 -0
- package/dist/template/.changeset/waitlists-groups-and-policy.md +27 -0
- package/dist/template/.changeset/watermark-backfill-without-open-transactions.md +9 -0
- package/dist/template/.changeset/watermarked-proof-renditions.md +8 -0
- package/dist/template/.changeset/webauthn-14.md +7 -0
- package/dist/template/.changeset/webhook-pinned-transport.md +5 -0
- package/dist/template/.changeset/webhooks.md +22 -0
- package/dist/template/.changeset/wevibesites-colophon.md +7 -0
- package/dist/template/.changeset/workflow-record-search.md +8 -0
- package/dist/template/.changeset/workforce-adapter-family.md +5 -0
- package/dist/template/.changeset/www-canonical-redirect.md +7 -0
- package/dist/template/.dockerignore +16 -0
- package/dist/template/.env.example +215 -0
- package/dist/template/.github/PULL_REQUEST_TEMPLATE.md +19 -0
- package/dist/template/.github/actions/setup-project/action.yml +15 -0
- package/dist/template/.github/dependabot.yml +27 -0
- package/dist/template/.github/workflows/ci.yml +501 -0
- package/dist/template/.github/workflows/eas.yml +51 -0
- package/dist/template/.github/workflows/mirror-ci-images.yml +62 -0
- package/dist/template/.github/workflows/publish-image.yml +214 -0
- package/dist/template/.github/workflows/publish-packages.yml +75 -0
- package/dist/template/.github/workflows/security-scheduled.yml +47 -0
- package/dist/template/.node-version +1 -0
- package/dist/template/.railway/railway.ts +43 -0
- package/dist/template/.replit +15 -0
- package/dist/template/AGENTS.md +34 -0
- package/dist/template/CLAUDE.md +62 -0
- package/dist/template/CODE_OF_CONDUCT.md +134 -0
- package/dist/template/CONTRIBUTING.md +100 -0
- package/dist/template/DCO.md +42 -0
- package/dist/template/Dockerfile +48 -0
- package/dist/template/LICENSE +202 -0
- package/dist/template/LICENSING.md +61 -0
- package/dist/template/MASTER.md +10261 -0
- package/dist/template/README.md +122 -0
- package/dist/template/SECURITY.md +152 -0
- package/dist/template/app/(admin)/action-helpers.ts +21 -0
- package/dist/template/app/(admin)/actions.ts +1529 -0
- package/dist/template/app/(admin)/admin/AdminGuidanceHelp.tsx +38 -0
- package/dist/template/app/(admin)/admin/AdminNav.tsx +303 -0
- package/dist/template/app/(admin)/admin/BlockEditor.tsx +2993 -0
- package/dist/template/app/(admin)/admin/ConversationsPanel.tsx +124 -0
- package/dist/template/app/(admin)/admin/NotesPanel.tsx +161 -0
- package/dist/template/app/(admin)/admin/PreviewCanvas.tsx +583 -0
- package/dist/template/app/(admin)/admin/RichField.tsx +107 -0
- package/dist/template/app/(admin)/admin/ScorePanel.tsx +117 -0
- package/dist/template/app/(admin)/admin/SignOutButton.tsx +19 -0
- package/dist/template/app/(admin)/admin/ViewBar.tsx +162 -0
- package/dist/template/app/(admin)/admin/access/page.tsx +214 -0
- package/dist/template/app/(admin)/admin/ads/page.tsx +827 -0
- package/dist/template/app/(admin)/admin/agreements/[id]/page.tsx +148 -0
- package/dist/template/app/(admin)/admin/agreements/page.tsx +288 -0
- package/dist/template/app/(admin)/admin/appointments/[id]/page.tsx +522 -0
- package/dist/template/app/(admin)/admin/appointments/page.tsx +215 -0
- package/dist/template/app/(admin)/admin/assessments/BandEditor.tsx +295 -0
- package/dist/template/app/(admin)/admin/assessments/EscalationEditor.tsx +229 -0
- package/dist/template/app/(admin)/admin/assessments/PublishControls.tsx +76 -0
- package/dist/template/app/(admin)/admin/assessments/QuestionBuilder.tsx +489 -0
- package/dist/template/app/(admin)/admin/assessments/[id]/edit/page.tsx +64 -0
- package/dist/template/app/(admin)/admin/assessments/[id]/page.tsx +166 -0
- package/dist/template/app/(admin)/admin/assessments/labels.ts +106 -0
- package/dist/template/app/(admin)/admin/assessments/new/page.tsx +42 -0
- package/dist/template/app/(admin)/admin/assessments/page.tsx +95 -0
- package/dist/template/app/(admin)/admin/assistant/page.tsx +741 -0
- package/dist/template/app/(admin)/admin/automations/[id]/page.tsx +595 -0
- package/dist/template/app/(admin)/admin/automations/page.tsx +153 -0
- package/dist/template/app/(admin)/admin/blog/actions.ts +21 -0
- package/dist/template/app/(admin)/admin/blog/page.tsx +13 -0
- package/dist/template/app/(admin)/admin/briefing/page.tsx +179 -0
- package/dist/template/app/(admin)/admin/builder/page.tsx +205 -0
- package/dist/template/app/(admin)/admin/builder/proposals/[id]/page.tsx +88 -0
- package/dist/template/app/(admin)/admin/calculators/CalculatorBuilder.tsx +573 -0
- package/dist/template/app/(admin)/admin/calculators/CalculatorPublish.tsx +65 -0
- package/dist/template/app/(admin)/admin/calculators/[id]/page.tsx +75 -0
- package/dist/template/app/(admin)/admin/calculators/labels.ts +51 -0
- package/dist/template/app/(admin)/admin/calculators/new/page.tsx +35 -0
- package/dist/template/app/(admin)/admin/calculators/page.tsx +87 -0
- package/dist/template/app/(admin)/admin/calendar/page.tsx +326 -0
- package/dist/template/app/(admin)/admin/calendars/[id]/page.tsx +255 -0
- package/dist/template/app/(admin)/admin/calendars/audiences/page.tsx +256 -0
- package/dist/template/app/(admin)/admin/calendars/page.tsx +261 -0
- package/dist/template/app/(admin)/admin/calendars/waitlist/page.tsx +236 -0
- package/dist/template/app/(admin)/admin/carts/[id]/page.tsx +219 -0
- package/dist/template/app/(admin)/admin/carts/page.tsx +107 -0
- package/dist/template/app/(admin)/admin/collections/[id]/page.tsx +259 -0
- package/dist/template/app/(admin)/admin/collections/page.tsx +134 -0
- package/dist/template/app/(admin)/admin/community/page.tsx +293 -0
- package/dist/template/app/(admin)/admin/connect/ConnectForm.tsx +52 -0
- package/dist/template/app/(admin)/admin/connect/actions.ts +29 -0
- package/dist/template/app/(admin)/admin/connect/page.tsx +17 -0
- package/dist/template/app/(admin)/admin/contacts/ContactForm.tsx +287 -0
- package/dist/template/app/(admin)/admin/contacts/CustomFieldInputs.tsx +101 -0
- package/dist/template/app/(admin)/admin/contacts/[id]/MergePanel.tsx +113 -0
- package/dist/template/app/(admin)/admin/contacts/[id]/RelationshipPanel.tsx +234 -0
- package/dist/template/app/(admin)/admin/contacts/[id]/page.tsx +388 -0
- package/dist/template/app/(admin)/admin/contacts/contactLabels.ts +112 -0
- package/dist/template/app/(admin)/admin/contacts/duplicates/DuplicateReview.tsx +335 -0
- package/dist/template/app/(admin)/admin/contacts/duplicates/page.tsx +196 -0
- package/dist/template/app/(admin)/admin/contacts/fields/CustomFieldManager.tsx +199 -0
- package/dist/template/app/(admin)/admin/contacts/fields/page.tsx +58 -0
- package/dist/template/app/(admin)/admin/contacts/new/page.tsx +51 -0
- package/dist/template/app/(admin)/admin/contacts/organizations/OrganizationForm.tsx +144 -0
- package/dist/template/app/(admin)/admin/contacts/organizations/[id]/page.tsx +80 -0
- package/dist/template/app/(admin)/admin/contacts/organizations/labels.ts +26 -0
- package/dist/template/app/(admin)/admin/contacts/organizations/new/page.tsx +35 -0
- package/dist/template/app/(admin)/admin/contacts/organizations/page.tsx +140 -0
- package/dist/template/app/(admin)/admin/contacts/page.tsx +341 -0
- package/dist/template/app/(admin)/admin/contacts/privacy/PrivacyActionForm.tsx +59 -0
- package/dist/template/app/(admin)/admin/contacts/privacy/[id]/page.tsx +188 -0
- package/dist/template/app/(admin)/admin/contacts/privacy/page.tsx +241 -0
- package/dist/template/app/(admin)/admin/contribute/ContributeForms.tsx +190 -0
- package/dist/template/app/(admin)/admin/contribute/[id]/page.tsx +111 -0
- package/dist/template/app/(admin)/admin/contribute/page.tsx +114 -0
- package/dist/template/app/(admin)/admin/demos/page.tsx +174 -0
- package/dist/template/app/(admin)/admin/describeAction.ts +38 -0
- package/dist/template/app/(admin)/admin/design/DesignForm.tsx +206 -0
- package/dist/template/app/(admin)/admin/design/page.tsx +79 -0
- package/dist/template/app/(admin)/admin/documents/[id]/page.tsx +331 -0
- package/dist/template/app/(admin)/admin/documents/page.tsx +127 -0
- package/dist/template/app/(admin)/admin/editorLabels.ts +288 -0
- package/dist/template/app/(admin)/admin/events/[id]/page.tsx +192 -0
- package/dist/template/app/(admin)/admin/events/page.tsx +75 -0
- package/dist/template/app/(admin)/admin/experiments/page.tsx +71 -0
- package/dist/template/app/(admin)/admin/facts/FactForms.tsx +223 -0
- package/dist/template/app/(admin)/admin/facts/[key]/page.tsx +145 -0
- package/dist/template/app/(admin)/admin/facts/labels.ts +32 -0
- package/dist/template/app/(admin)/admin/facts/page.tsx +97 -0
- package/dist/template/app/(admin)/admin/forms/FieldBuilder.tsx +410 -0
- package/dist/template/app/(admin)/admin/forms/[id]/edit/page.tsx +87 -0
- package/dist/template/app/(admin)/admin/forms/[id]/page.tsx +198 -0
- package/dist/template/app/(admin)/admin/forms/builderLabels.ts +55 -0
- package/dist/template/app/(admin)/admin/forms/new/page.tsx +47 -0
- package/dist/template/app/(admin)/admin/forms/page.tsx +104 -0
- package/dist/template/app/(admin)/admin/fulfillment/page.tsx +87 -0
- package/dist/template/app/(admin)/admin/galleries/[id]/page.tsx +457 -0
- package/dist/template/app/(admin)/admin/galleries/page.tsx +132 -0
- package/dist/template/app/(admin)/admin/gifts/page.tsx +152 -0
- package/dist/template/app/(admin)/admin/guard.ts +59 -0
- package/dist/template/app/(admin)/admin/guidance/page.tsx +58 -0
- package/dist/template/app/(admin)/admin/health/page.tsx +141 -0
- package/dist/template/app/(admin)/admin/hire/page.tsx +228 -0
- package/dist/template/app/(admin)/admin/imports/ImportForms.tsx +167 -0
- package/dist/template/app/(admin)/admin/imports/[id]/page.tsx +65 -0
- package/dist/template/app/(admin)/admin/imports/contacts/[id]/page.tsx +273 -0
- package/dist/template/app/(admin)/admin/imports/contacts/page.tsx +212 -0
- package/dist/template/app/(admin)/admin/imports/page.tsx +68 -0
- package/dist/template/app/(admin)/admin/inbox/[id]/page.tsx +232 -0
- package/dist/template/app/(admin)/admin/inbox/page.tsx +306 -0
- package/dist/template/app/(admin)/admin/inventory/page.tsx +273 -0
- package/dist/template/app/(admin)/admin/invitations/InvitationManager.tsx +369 -0
- package/dist/template/app/(admin)/admin/invitations/page.tsx +102 -0
- package/dist/template/app/(admin)/admin/invoices/[id]/page.tsx +474 -0
- package/dist/template/app/(admin)/admin/invoices/format.ts +43 -0
- package/dist/template/app/(admin)/admin/invoices/new/page.tsx +206 -0
- package/dist/template/app/(admin)/admin/invoices/page.tsx +136 -0
- package/dist/template/app/(admin)/admin/invoices/recurring/page.tsx +227 -0
- package/dist/template/app/(admin)/admin/invoices/tax/page.tsx +378 -0
- package/dist/template/app/(admin)/admin/jobs/JobActionForm.tsx +54 -0
- package/dist/template/app/(admin)/admin/jobs/[name]/[id]/page.tsx +183 -0
- package/dist/template/app/(admin)/admin/jobs/outbox/[id]/page.tsx +130 -0
- package/dist/template/app/(admin)/admin/jobs/outbox/page.tsx +145 -0
- package/dist/template/app/(admin)/admin/jobs/page.tsx +221 -0
- package/dist/template/app/(admin)/admin/layout.tsx +194 -0
- package/dist/template/app/(admin)/admin/locations/DeleteButton.tsx +47 -0
- package/dist/template/app/(admin)/admin/locations/HoursForm.tsx +122 -0
- package/dist/template/app/(admin)/admin/locations/LocationForm.tsx +249 -0
- package/dist/template/app/(admin)/admin/locations/PrimaryButton.tsx +30 -0
- package/dist/template/app/(admin)/admin/locations/ServiceAreaForm.tsx +223 -0
- package/dist/template/app/(admin)/admin/locations/[id]/page.tsx +142 -0
- package/dist/template/app/(admin)/admin/locations/labels.ts +112 -0
- package/dist/template/app/(admin)/admin/locations/page.tsx +121 -0
- package/dist/template/app/(admin)/admin/loyalty/page.tsx +496 -0
- package/dist/template/app/(admin)/admin/marketplace/page.tsx +158 -0
- package/dist/template/app/(admin)/admin/media/AltTextForm.tsx +160 -0
- package/dist/template/app/(admin)/admin/media/DeleteAssetButton.tsx +74 -0
- package/dist/template/app/(admin)/admin/media/FocalPointForm.tsx +64 -0
- package/dist/template/app/(admin)/admin/media/RecordStudio.tsx +326 -0
- package/dist/template/app/(admin)/admin/media/TrashActions.tsx +100 -0
- package/dist/template/app/(admin)/admin/media/UploadForm.tsx +164 -0
- package/dist/template/app/(admin)/admin/media/page.tsx +415 -0
- package/dist/template/app/(admin)/admin/media/record/page.tsx +145 -0
- package/dist/template/app/(admin)/admin/media/upload-client.ts +313 -0
- package/dist/template/app/(admin)/admin/messaging/page.tsx +426 -0
- package/dist/template/app/(admin)/admin/newsletters/[id]/page.tsx +149 -0
- package/dist/template/app/(admin)/admin/newsletters/broadcasts/[id]/page.tsx +250 -0
- package/dist/template/app/(admin)/admin/newsletters/broadcasts/page.tsx +192 -0
- package/dist/template/app/(admin)/admin/newsletters/page.tsx +78 -0
- package/dist/template/app/(admin)/admin/newsletters/templates/page.tsx +254 -0
- package/dist/template/app/(admin)/admin/notifications/NotificationControls.tsx +197 -0
- package/dist/template/app/(admin)/admin/notifications/page.tsx +334 -0
- package/dist/template/app/(admin)/admin/orders/[id]/page.tsx +318 -0
- package/dist/template/app/(admin)/admin/orders/page.tsx +64 -0
- package/dist/template/app/(admin)/admin/page.tsx +159 -0
- package/dist/template/app/(admin)/admin/pages/SeedSiteButton.tsx +20 -0
- package/dist/template/app/(admin)/admin/pages/[id]/CopyPreviewLink.tsx +45 -0
- package/dist/template/app/(admin)/admin/pages/[id]/PageComments.tsx +242 -0
- package/dist/template/app/(admin)/admin/pages/[id]/PageEditor.tsx +105 -0
- package/dist/template/app/(admin)/admin/pages/[id]/PageLifecycle.tsx +210 -0
- package/dist/template/app/(admin)/admin/pages/[id]/PagePresence.tsx +63 -0
- package/dist/template/app/(admin)/admin/pages/[id]/PublishToggle.tsx +27 -0
- package/dist/template/app/(admin)/admin/pages/[id]/RevisionList.tsx +115 -0
- package/dist/template/app/(admin)/admin/pages/[id]/page.tsx +337 -0
- package/dist/template/app/(admin)/admin/pages/new/NewPageForm.tsx +65 -0
- package/dist/template/app/(admin)/admin/pages/new/page.tsx +45 -0
- package/dist/template/app/(admin)/admin/pages/page.tsx +171 -0
- package/dist/template/app/(admin)/admin/payments/page.tsx +203 -0
- package/dist/template/app/(admin)/admin/paywalls/page.tsx +199 -0
- package/dist/template/app/(admin)/admin/pipeline/page.tsx +313 -0
- package/dist/template/app/(admin)/admin/plugins/PluginForms.tsx +158 -0
- package/dist/template/app/(admin)/admin/plugins/page.tsx +150 -0
- package/dist/template/app/(admin)/admin/popups/[id]/PopupEditor.tsx +39 -0
- package/dist/template/app/(admin)/admin/popups/[id]/page.tsx +430 -0
- package/dist/template/app/(admin)/admin/popups/page.tsx +230 -0
- package/dist/template/app/(admin)/admin/pos/page.tsx +153 -0
- package/dist/template/app/(admin)/admin/price-lists/page.tsx +150 -0
- package/dist/template/app/(admin)/admin/print-on-demand/page.tsx +144 -0
- package/dist/template/app/(admin)/admin/procurement/page.tsx +208 -0
- package/dist/template/app/(admin)/admin/products/[id]/ProductEditor.tsx +61 -0
- package/dist/template/app/(admin)/admin/products/[id]/page.tsx +807 -0
- package/dist/template/app/(admin)/admin/products/new/page.tsx +55 -0
- package/dist/template/app/(admin)/admin/products/page.tsx +108 -0
- package/dist/template/app/(admin)/admin/projects/[id]/ProjectEditor.tsx +41 -0
- package/dist/template/app/(admin)/admin/projects/[id]/page.tsx +785 -0
- package/dist/template/app/(admin)/admin/projects/collections/[id]/page.tsx +166 -0
- package/dist/template/app/(admin)/admin/projects/collections/page.tsx +101 -0
- package/dist/template/app/(admin)/admin/projects/page.tsx +156 -0
- package/dist/template/app/(admin)/admin/promotions/page.tsx +206 -0
- package/dist/template/app/(admin)/admin/quotes/[id]/ConvertQuoteForm.tsx +34 -0
- package/dist/template/app/(admin)/admin/quotes/[id]/page.tsx +265 -0
- package/dist/template/app/(admin)/admin/quotes/page.tsx +193 -0
- package/dist/template/app/(admin)/admin/redirects/page.tsx +114 -0
- package/dist/template/app/(admin)/admin/referrals/page.tsx +464 -0
- package/dist/template/app/(admin)/admin/referrals/payouts/[id]/csv/route.ts +42 -0
- package/dist/template/app/(admin)/admin/reports/exports/[runId]/download/route.ts +41 -0
- package/dist/template/app/(admin)/admin/reports/exports/page.tsx +524 -0
- package/dist/template/app/(admin)/admin/reports/page.tsx +423 -0
- package/dist/template/app/(admin)/admin/retention/page.tsx +148 -0
- package/dist/template/app/(admin)/admin/returns/page.tsx +141 -0
- package/dist/template/app/(admin)/admin/reviews/page.tsx +250 -0
- package/dist/template/app/(admin)/admin/roles/RoleManager.tsx +381 -0
- package/dist/template/app/(admin)/admin/roles/page.tsx +78 -0
- package/dist/template/app/(admin)/admin/scoring/page.tsx +236 -0
- package/dist/template/app/(admin)/admin/search/page.tsx +137 -0
- package/dist/template/app/(admin)/admin/sections/[key]/SectionEditor.tsx +35 -0
- package/dist/template/app/(admin)/admin/sections/[key]/page.tsx +72 -0
- package/dist/template/app/(admin)/admin/sections/page.tsx +129 -0
- package/dist/template/app/(admin)/admin/segments/page.tsx +272 -0
- package/dist/template/app/(admin)/admin/settings/ApiKeysCard.tsx +268 -0
- package/dist/template/app/(admin)/admin/settings/MailSettingsCard.tsx +796 -0
- package/dist/template/app/(admin)/admin/settings/PasswordForm.tsx +86 -0
- package/dist/template/app/(admin)/admin/settings/SettingsForm.tsx +206 -0
- package/dist/template/app/(admin)/admin/settings/WebhooksCard.tsx +292 -0
- package/dist/template/app/(admin)/admin/settings/page.tsx +483 -0
- package/dist/template/app/(admin)/admin/sharing/page.tsx +426 -0
- package/dist/template/app/(admin)/admin/shipping/page.tsx +144 -0
- package/dist/template/app/(admin)/admin/social/page.tsx +544 -0
- package/dist/template/app/(admin)/admin/subscriptions/[id]/page.tsx +41 -0
- package/dist/template/app/(admin)/admin/subscriptions/page.tsx +491 -0
- package/dist/template/app/(admin)/admin/tasks/page.tsx +312 -0
- package/dist/template/app/(admin)/admin/templates/[key]/CreateFromTemplateForm.tsx +47 -0
- package/dist/template/app/(admin)/admin/templates/[key]/EmailInboxPreview.tsx +65 -0
- package/dist/template/app/(admin)/admin/templates/[key]/TemplateEditor.tsx +37 -0
- package/dist/template/app/(admin)/admin/templates/[key]/page.tsx +128 -0
- package/dist/template/app/(admin)/admin/templates/page.tsx +63 -0
- package/dist/template/app/(admin)/admin/time/page.tsx +328 -0
- package/dist/template/app/(admin)/admin/traffic/funnel/page.tsx +184 -0
- package/dist/template/app/(admin)/admin/traffic/page.tsx +409 -0
- package/dist/template/app/(admin)/admin/translations/TranslationEditor.tsx +166 -0
- package/dist/template/app/(admin)/admin/translations/[locale]/[id]/page.tsx +151 -0
- package/dist/template/app/(admin)/admin/translations/page.tsx +189 -0
- package/dist/template/app/(admin)/admin/trash/page.tsx +108 -0
- package/dist/template/app/(admin)/admin/updates/UpdateActionForm.tsx +72 -0
- package/dist/template/app/(admin)/admin/updates/page.tsx +520 -0
- package/dist/template/app/(admin)/admin/voice-video/GuestInvite.tsx +39 -0
- package/dist/template/app/(admin)/admin/voice-video/HostJoin.tsx +26 -0
- package/dist/template/app/(admin)/admin/voice-video/VerifyConnection.tsx +28 -0
- package/dist/template/app/(admin)/admin/voice-video/page.tsx +372 -0
- package/dist/template/app/(admin)/admin/work/LiveRun.tsx +112 -0
- package/dist/template/app/(admin)/admin/work/WorkForms.tsx +310 -0
- package/dist/template/app/(admin)/admin/work/[id]/page.tsx +248 -0
- package/dist/template/app/(admin)/admin/work/approvals/page.tsx +151 -0
- package/dist/template/app/(admin)/admin/work/page.tsx +349 -0
- package/dist/template/app/(admin)/admin/work/playbooks/PlaybookForms.tsx +139 -0
- package/dist/template/app/(admin)/admin/work/playbooks/page.tsx +285 -0
- package/dist/template/app/(admin)/admin/work/spend/page.tsx +126 -0
- package/dist/template/app/(admin)/ads-actions.ts +355 -0
- package/dist/template/app/(admin)/advanced-money-actions.ts +163 -0
- package/dist/template/app/(admin)/analytics-actions.ts +70 -0
- package/dist/template/app/(admin)/approval-actions.ts +57 -0
- package/dist/template/app/(admin)/assessments-actions.ts +224 -0
- package/dist/template/app/(admin)/assistant-actions.ts +184 -0
- package/dist/template/app/(admin)/audience-actions.ts +139 -0
- package/dist/template/app/(admin)/automation-actions.ts +347 -0
- package/dist/template/app/(admin)/availability-actions.ts +99 -0
- package/dist/template/app/(admin)/booking-actions.ts +295 -0
- package/dist/template/app/(admin)/briefing-actions.ts +46 -0
- package/dist/template/app/(admin)/broadcast-actions.ts +155 -0
- package/dist/template/app/(admin)/builder-actions.ts +92 -0
- package/dist/template/app/(admin)/calculators-actions.ts +127 -0
- package/dist/template/app/(admin)/calendar-actions.ts +96 -0
- package/dist/template/app/(admin)/capture-actions.ts +191 -0
- package/dist/template/app/(admin)/catalog-actions.ts +1054 -0
- package/dist/template/app/(admin)/cms-actions.ts +637 -0
- package/dist/template/app/(admin)/connection-actions.ts +72 -0
- package/dist/template/app/(admin)/contact-import-actions.ts +158 -0
- package/dist/template/app/(admin)/contract-actions.ts +138 -0
- package/dist/template/app/(admin)/contribute-actions.ts +145 -0
- package/dist/template/app/(admin)/demo-actions.ts +49 -0
- package/dist/template/app/(admin)/design-actions.ts +71 -0
- package/dist/template/app/(admin)/document-actions.ts +153 -0
- package/dist/template/app/(admin)/entitlement-actions.ts +92 -0
- package/dist/template/app/(admin)/event-actions.ts +109 -0
- package/dist/template/app/(admin)/export-actions.ts +122 -0
- package/dist/template/app/(admin)/facts-actions.ts +135 -0
- package/dist/template/app/(admin)/first-party-plugin-actions.ts +475 -0
- package/dist/template/app/(admin)/forgot/ForgotForm.tsx +54 -0
- package/dist/template/app/(admin)/forgot/page.tsx +78 -0
- package/dist/template/app/(admin)/forms-actions.ts +108 -0
- package/dist/template/app/(admin)/gallery-actions.ts +227 -0
- package/dist/template/app/(admin)/guidance-actions.ts +55 -0
- package/dist/template/app/(admin)/import-actions.ts +142 -0
- package/dist/template/app/(admin)/inbox-actions.ts +146 -0
- package/dist/template/app/(admin)/invitation-actions.ts +139 -0
- package/dist/template/app/(admin)/invite/AcceptInvitationForm.tsx +71 -0
- package/dist/template/app/(admin)/invite/page.tsx +110 -0
- package/dist/template/app/(admin)/invoice-actions.ts +357 -0
- package/dist/template/app/(admin)/login/PasskeySignIn.tsx +32 -0
- package/dist/template/app/(admin)/login/SignInForm.tsx +61 -0
- package/dist/template/app/(admin)/login/page.tsx +96 -0
- package/dist/template/app/(admin)/login/verify/VerifyLogin.tsx +80 -0
- package/dist/template/app/(admin)/login/verify/page.tsx +46 -0
- package/dist/template/app/(admin)/loyalty-actions.ts +208 -0
- package/dist/template/app/(admin)/media-actions.ts +203 -0
- package/dist/template/app/(admin)/messaging-actions.ts +173 -0
- package/dist/template/app/(admin)/newsletter-actions.ts +98 -0
- package/dist/template/app/(admin)/note-actions.ts +114 -0
- package/dist/template/app/(admin)/notification-actions.ts +113 -0
- package/dist/template/app/(admin)/payment-actions.ts +118 -0
- package/dist/template/app/(admin)/paywall-actions.ts +77 -0
- package/dist/template/app/(admin)/pipeline-actions.ts +123 -0
- package/dist/template/app/(admin)/playbook-actions.ts +202 -0
- package/dist/template/app/(admin)/plugin-actions.ts +112 -0
- package/dist/template/app/(admin)/popup-actions.ts +169 -0
- package/dist/template/app/(admin)/project-actions.ts +476 -0
- package/dist/template/app/(admin)/quote-actions.ts +148 -0
- package/dist/template/app/(admin)/read-helpers.ts +21 -0
- package/dist/template/app/(admin)/recurring-actions.ts +116 -0
- package/dist/template/app/(admin)/referral-actions.ts +187 -0
- package/dist/template/app/(admin)/rental-actions.ts +75 -0
- package/dist/template/app/(admin)/report-actions.ts +63 -0
- package/dist/template/app/(admin)/reset/ResetForm.tsx +68 -0
- package/dist/template/app/(admin)/reset/page.tsx +74 -0
- package/dist/template/app/(admin)/reset-actions.ts +59 -0
- package/dist/template/app/(admin)/retention-actions.ts +64 -0
- package/dist/template/app/(admin)/review-actions.ts +83 -0
- package/dist/template/app/(admin)/scoring-actions.ts +109 -0
- package/dist/template/app/(admin)/security/SecurityControls.tsx +240 -0
- package/dist/template/app/(admin)/security/labels.ts +24 -0
- package/dist/template/app/(admin)/security/page.tsx +51 -0
- package/dist/template/app/(admin)/security/verify/StepUpForm.tsx +69 -0
- package/dist/template/app/(admin)/security/verify/page.tsx +44 -0
- package/dist/template/app/(admin)/security-actions.ts +285 -0
- package/dist/template/app/(admin)/segment-actions.ts +144 -0
- package/dist/template/app/(admin)/seo-actions.ts +61 -0
- package/dist/template/app/(admin)/settings-module-actions.ts +37 -0
- package/dist/template/app/(admin)/share-actions.ts +116 -0
- package/dist/template/app/(admin)/social-actions.ts +211 -0
- package/dist/template/app/(admin)/subscription-actions.ts +154 -0
- package/dist/template/app/(admin)/task-actions.ts +118 -0
- package/dist/template/app/(admin)/template-actions.ts +92 -0
- package/dist/template/app/(admin)/time-actions.ts +175 -0
- package/dist/template/app/(admin)/translation-actions.ts +107 -0
- package/dist/template/app/(admin)/trash-actions.ts +89 -0
- package/dist/template/app/(admin)/view-actions.ts +111 -0
- package/dist/template/app/(admin)/work-actions.ts +274 -0
- package/dist/template/app/(preview)/canvas-bridge.ts +885 -0
- package/dist/template/app/(preview)/layout.tsx +193 -0
- package/dist/template/app/(preview)/preview/page/[id]/page.tsx +63 -0
- package/dist/template/app/(preview)/preview/popup/[id]/page.tsx +59 -0
- package/dist/template/app/(preview)/preview/product/[id]/page.tsx +41 -0
- package/dist/template/app/(preview)/preview/project/[id]/page.tsx +41 -0
- package/dist/template/app/(preview)/preview/section/[key]/page.tsx +63 -0
- package/dist/template/app/(preview)/preview/share/[token]/page.tsx +48 -0
- package/dist/template/app/(preview)/preview/template/[key]/page.tsx +57 -0
- package/dist/template/app/(public)/AnalyticsConsentControl.tsx +92 -0
- package/dist/template/app/(public)/AnalyticsRuntime.tsx +85 -0
- package/dist/template/app/(public)/NativeShare.tsx +48 -0
- package/dist/template/app/(public)/ShareBar.tsx +101 -0
- package/dist/template/app/(public)/[[...slug]]/alternates.ts +59 -0
- package/dist/template/app/(public)/[[...slug]]/page.tsx +541 -0
- package/dist/template/app/(public)/[[...slug]]/pageview.ts +88 -0
- package/dist/template/app/(public)/assessment-actions.ts +86 -0
- package/dist/template/app/(public)/book/actions.ts +38 -0
- package/dist/template/app/(public)/book/page.tsx +64 -0
- package/dist/template/app/(public)/browse/FacetPanel.tsx +285 -0
- package/dist/template/app/(public)/browse/SearchBox.tsx +42 -0
- package/dist/template/app/(public)/browse/SortLinks.tsx +58 -0
- package/dist/template/app/(public)/browse-params.ts +336 -0
- package/dist/template/app/(public)/buy/AddToCart.tsx +123 -0
- package/dist/template/app/(public)/buy/buy-actions.ts +96 -0
- package/dist/template/app/(public)/c/[slug]/CollectionGrid.tsx +130 -0
- package/dist/template/app/(public)/c/[slug]/page.tsx +344 -0
- package/dist/template/app/(public)/cart/cart-actions.ts +103 -0
- package/dist/template/app/(public)/cart/page.tsx +235 -0
- package/dist/template/app/(public)/checkout/DeliveryMethods.tsx +109 -0
- package/dist/template/app/(public)/checkout/checkout-actions.ts +183 -0
- package/dist/template/app/(public)/checkout/page.tsx +363 -0
- package/dist/template/app/(public)/community/[slug]/page.tsx +261 -0
- package/dist/template/app/(public)/community-actions.ts +108 -0
- package/dist/template/app/(public)/contribute/page.tsx +153 -0
- package/dist/template/app/(public)/contribute-actions.ts +48 -0
- package/dist/template/app/(public)/form-actions.ts +69 -0
- package/dist/template/app/(public)/gift-actions.ts +33 -0
- package/dist/template/app/(public)/gifts/[slug]/page.tsx +102 -0
- package/dist/template/app/(public)/inbound-actions.ts +114 -0
- package/dist/template/app/(public)/layout.tsx +225 -0
- package/dist/template/app/(public)/memberships/actions.ts +23 -0
- package/dist/template/app/(public)/memberships/page.tsx +27 -0
- package/dist/template/app/(public)/newsletter-actions.ts +32 -0
- package/dist/template/app/(public)/orders/confirm/page.tsx +173 -0
- package/dist/template/app/(public)/search/page.tsx +233 -0
- package/dist/template/app/(public)/share-actions.ts +70 -0
- package/dist/template/app/(public)/shopper-cart.ts +98 -0
- package/dist/template/app/.well-known/freeholder/route.ts +94 -0
- package/dist/template/app/README.md +30 -0
- package/dist/template/app/ads.txt/route.ts +18 -0
- package/dist/template/app/api/ads/third-party-consent/route.ts +64 -0
- package/dist/template/app/api/ads/view/route.ts +58 -0
- package/dist/template/app/api/analytics/consent/route.ts +168 -0
- package/dist/template/app/api/analytics/export/route.ts +36 -0
- package/dist/template/app/api/analytics/vitals/route.ts +62 -0
- package/dist/template/app/api/auth/login/route.ts +31 -0
- package/dist/template/app/api/auth/login/verify/route.ts +66 -0
- package/dist/template/app/api/auth/logout/route.ts +18 -0
- package/dist/template/app/api/auth/session/route.ts +57 -0
- package/dist/template/app/api/chat/assistant/route.ts +51 -0
- package/dist/template/app/api/chat/route.ts +82 -0
- package/dist/template/app/api/cms/defaults/route.ts +20 -0
- package/dist/template/app/api/connections/calendar/[provider]/callback/route.ts +117 -0
- package/dist/template/app/api/connections/mail-read/[provider]/callback/route.ts +114 -0
- package/dist/template/app/api/connections/signup-contacts/[provider]/callback/route.ts +58 -0
- package/dist/template/app/api/doctor/route.ts +34 -0
- package/dist/template/app/api/health/live/route.ts +11 -0
- package/dist/template/app/api/health/route.ts +56 -0
- package/dist/template/app/api/mail/oauth/[provider]/callback/route.ts +80 -0
- package/dist/template/app/api/mail/webhooks/postmark/route.ts +7 -0
- package/dist/template/app/api/mail/webhooks/resend/route.ts +7 -0
- package/dist/template/app/api/mail/webhooks/ses/route.ts +7 -0
- package/dist/template/app/api/mcp/route.ts +42 -0
- package/dist/template/app/api/media/route.ts +58 -0
- package/dist/template/app/api/media/uploads/abort/route.ts +6 -0
- package/dist/template/app/api/media/uploads/complete/route.ts +6 -0
- package/dist/template/app/api/media/uploads/parts/route.ts +6 -0
- package/dist/template/app/api/media/uploads/route.ts +7 -0
- package/dist/template/app/api/openapi.json/route.ts +38 -0
- package/dist/template/app/api/payments/webhooks/flutterwave/route.ts +6 -0
- package/dist/template/app/api/payments/webhooks/mollie/route.ts +6 -0
- package/dist/template/app/api/payments/webhooks/paypal/route.ts +6 -0
- package/dist/template/app/api/payments/webhooks/paystack/route.ts +6 -0
- package/dist/template/app/api/payments/webhooks/razorpay/route.ts +6 -0
- package/dist/template/app/api/payments/webhooks/square/route.ts +6 -0
- package/dist/template/app/api/payments/webhooks/stripe/route.ts +6 -0
- package/dist/template/app/api/plugins/voice-video/webhooks/paradise/route.ts +45 -0
- package/dist/template/app/api/popups/route.ts +141 -0
- package/dist/template/app/api/security/csp-report/route.ts +50 -0
- package/dist/template/app/api/setup/owner/route.ts +19 -0
- package/dist/template/app/api/sms/webhooks/twilio/route.ts +6 -0
- package/dist/template/app/api/social/[provider]/callback/route.ts +70 -0
- package/dist/template/app/api/v1/[service]/route.ts +22 -0
- package/dist/template/app/app-ads.txt/route.ts +18 -0
- package/dist/template/app/capture/[token]/page.tsx +71 -0
- package/dist/template/app/embed/booking/page.tsx +7 -0
- package/dist/template/app/embed/gallery/[slug]/page.tsx +52 -0
- package/dist/template/app/embed/layout.tsx +13 -0
- package/dist/template/app/embed/newsletter/[id]/page.tsx +65 -0
- package/dist/template/app/embed/newsletter/actions.ts +25 -0
- package/dist/template/app/embed/reviews/page.tsx +51 -0
- package/dist/template/app/feeds/[kind]/route.ts +39 -0
- package/dist/template/app/g/[slug]/archive/route.ts +41 -0
- package/dist/template/app/g/[slug]/download/[itemId]/route.ts +39 -0
- package/dist/template/app/g/[slug]/page.tsx +331 -0
- package/dist/template/app/g/[slug]/view/[itemId]/route.ts +51 -0
- package/dist/template/app/g/actions.ts +211 -0
- package/dist/template/app/gift/[token]/page.tsx +61 -0
- package/dist/template/app/globals.css +148 -0
- package/dist/template/app/go/ad/route.ts +113 -0
- package/dist/template/app/i18n.ts +73 -0
- package/dist/template/app/ics/bookings/[token]/route.ts +42 -0
- package/dist/template/app/ics/calendars/[token]/route.ts +44 -0
- package/dist/template/app/ics/events/[slug]/route.ts +23 -0
- package/dist/template/app/indexnow-key/route.ts +25 -0
- package/dist/template/app/layout.tsx +66 -0
- package/dist/template/app/llms-full.txt/route.ts +14 -0
- package/dist/template/app/llms.txt/route.ts +102 -0
- package/dist/template/app/manifest.ts +69 -0
- package/dist/template/app/media/[...key]/route.ts +48 -0
- package/dist/template/app/media/download/[id]/route.ts +48 -0
- package/dist/template/app/newsletters/confirm/route.ts +26 -0
- package/dist/template/app/not-found.tsx +29 -0
- package/dist/template/app/og/[[...slug]]/route.tsx +54 -0
- package/dist/template/app/og/og-template.tsx +81 -0
- package/dist/template/app/playground/actions.ts +18 -0
- package/dist/template/app/playground/page.tsx +29 -0
- package/dist/template/app/portal/(account)/[section]/page.tsx +113 -0
- package/dist/template/app/portal/(account)/layout.tsx +108 -0
- package/dist/template/app/portal/(account)/messages/[id]/page.tsx +120 -0
- package/dist/template/app/portal/(account)/page.tsx +112 -0
- package/dist/template/app/portal/(account)/profile/page.tsx +139 -0
- package/dist/template/app/portal/(account)/records/[section]/[id]/actions.ts +25 -0
- package/dist/template/app/portal/(account)/records/[section]/[id]/page.tsx +24 -0
- package/dist/template/app/portal/(account)/subscriptions/[id]/page.tsx +169 -0
- package/dist/template/app/portal/PortalLocaleChooser.tsx +69 -0
- package/dist/template/app/portal/actions.ts +323 -0
- package/dist/template/app/portal/agreements/[token]/page.tsx +151 -0
- package/dist/template/app/portal/agreements/actions.ts +81 -0
- package/dist/template/app/portal/appointments/[token]/intake/page.tsx +98 -0
- package/dist/template/app/portal/appointments/[token]/page.tsx +210 -0
- package/dist/template/app/portal/appointments/actions.ts +131 -0
- package/dist/template/app/portal/appointments/moved/page.tsx +30 -0
- package/dist/template/app/portal/contact-import/DeviceContactPicker.tsx +119 -0
- package/dist/template/app/portal/contact-import/[id]/page.tsx +170 -0
- package/dist/template/app/portal/contact-import/actions.ts +193 -0
- package/dist/template/app/portal/contact-import/page.tsx +298 -0
- package/dist/template/app/portal/files/[id]/route.ts +50 -0
- package/dist/template/app/portal/invoices/InvoiceView.tsx +64 -0
- package/dist/template/app/portal/invoices/PaymentButton.tsx +10 -0
- package/dist/template/app/portal/invoices/[id]/page.tsx +37 -0
- package/dist/template/app/portal/invoices/actions.ts +52 -0
- package/dist/template/app/portal/invoices/confirmation/[token]/page.tsx +41 -0
- package/dist/template/app/portal/invoices/loading.tsx +7 -0
- package/dist/template/app/portal/login/MagicLinkForm.tsx +30 -0
- package/dist/template/app/portal/login/page.tsx +76 -0
- package/dist/template/app/portal/magic/confirm/ConfirmMagicLink.tsx +24 -0
- package/dist/template/app/portal/magic/confirm/page.tsx +46 -0
- package/dist/template/app/portal/magic/route.ts +36 -0
- package/dist/template/app/portal/message-actions.ts +51 -0
- package/dist/template/app/portal/privacy/PortalPrivacyCentre.tsx +209 -0
- package/dist/template/app/portal/privacy/page.tsx +147 -0
- package/dist/template/app/portal/quotes/[token]/page.tsx +324 -0
- package/dist/template/app/portal/quotes/accepted/page.tsx +30 -0
- package/dist/template/app/portal/quotes/actions.ts +145 -0
- package/dist/template/app/portal/quotes/partner/[token]/page.tsx +128 -0
- package/dist/template/app/portal/registry/actions.ts +34 -0
- package/dist/template/app/portal/registry/page.tsx +81 -0
- package/dist/template/app/portal/subscription-actions.ts +69 -0
- package/dist/template/app/privacy/artifacts/[id]/route.ts +38 -0
- package/dist/template/app/registry/[token]/page.tsx +67 -0
- package/dist/template/app/report-exports/[token]/route.ts +45 -0
- package/dist/template/app/robots.txt/route.ts +18 -0
- package/dist/template/app/s/[ref]/route.ts +41 -0
- package/dist/template/app/setup/OwnerForm.tsx +87 -0
- package/dist/template/app/setup/Steps.tsx +55 -0
- package/dist/template/app/setup/access.ts +15 -0
- package/dist/template/app/setup/actions.ts +203 -0
- package/dist/template/app/setup/business/BusinessForm.tsx +170 -0
- package/dist/template/app/setup/business/page.tsx +41 -0
- package/dist/template/app/setup/businessLabels.ts +113 -0
- package/dist/template/app/setup/done/DoneForm.tsx +33 -0
- package/dist/template/app/setup/done/MailReadiness.tsx +137 -0
- package/dist/template/app/setup/done/page.tsx +90 -0
- package/dist/template/app/setup/layout.tsx +48 -0
- package/dist/template/app/setup/location/LocationStepForm.tsx +110 -0
- package/dist/template/app/setup/location/page.tsx +61 -0
- package/dist/template/app/setup/page.tsx +50 -0
- package/dist/template/app/setup/security/page.tsx +29 -0
- package/dist/template/app/share/route.ts +60 -0
- package/dist/template/app/sitemap.xml/route.ts +31 -0
- package/dist/template/app/sitemaps/[locale]/route.ts +56 -0
- package/dist/template/app/source/route.ts +67 -0
- package/dist/template/app/theme.ts +54 -0
- package/dist/template/app/themeLabels.ts +26 -0
- package/dist/template/app/unsubscribe/route.ts +49 -0
- package/dist/template/db/README.md +21 -0
- package/dist/template/db/migrations/0000_reviewed-baseline.sql +7342 -0
- package/dist/template/db/migrations/0001_community_rooms.sql +46 -0
- package/dist/template/db/migrations/0002_voice_video_rooms.sql +41 -0
- package/dist/template/db/migrations/0003_print_on_demand_fulfillment.sql +21 -0
- package/dist/template/db/migrations/0004_marketplace_channel_sync.sql +23 -0
- package/dist/template/db/migrations/0005_retention_policies.sql +14 -0
- package/dist/template/db/migrations/0006_contact_pagination.sql +5 -0
- package/dist/template/db/migrations/0007_marketplace_sync_lease.sql +6 -0
- package/dist/template/db/migrations/0008_printify_live_fulfillment.sql +21 -0
- package/dist/template/db/migrations/0009_daily_voice_video.sql +14 -0
- package/dist/template/db/migrations/0010_note_task_trash.sql +10 -0
- package/dist/template/db/migrations/0011_record_trash.sql +22 -0
- package/dist/template/db/migrations/0012_owner_storage_refunds.sql +41 -0
- package/dist/template/db/migrations/0013_assessments.sql +119 -0
- package/dist/template/db/migrations/0014_attestations.sql +67 -0
- package/dist/template/db/migrations/0015_media_consents.sql +108 -0
- package/dist/template/db/migrations/0016_calculators.sql +31 -0
- package/dist/template/db/migrations/0017_postal_service_areas.sql +22 -0
- package/dist/template/db/migrations/0018_area_delivery_windows.sql +17 -0
- package/dist/template/db/migrations/0019_paradise_voice_video.sql +15 -0
- package/dist/template/db/migrations/0020_collections.sql +54 -0
- package/dist/template/db/migrations/0021_order_payment_milestones.sql +21 -0
- package/dist/template/db/migrations/0022_customer_surfaces.sql +31 -0
- package/dist/template/db/migrations/0023_gallery_private_delivery.sql +13 -0
- package/dist/template/db/migrations/0024_broadcast_unsubscribe.sql +11 -0
- package/dist/template/db/migrations/meta/0000_snapshot.json +53876 -0
- package/dist/template/db/migrations/meta/_journal.json +181 -0
- package/dist/template/deploy/README.md +130 -0
- package/dist/template/deploy/accessibility-testing.md +77 -0
- package/dist/template/deploy/agent-launch.md +129 -0
- package/dist/template/deploy/alt-text-suggestions.md +75 -0
- package/dist/template/deploy/analytics-governance.md +81 -0
- package/dist/template/deploy/app-store-privacy.md +82 -0
- package/dist/template/deploy/background-jobs.md +229 -0
- package/dist/template/deploy/browser-journeys.md +78 -0
- package/dist/template/deploy/c11-08-restore-drill-2026-09-28.log +41 -0
- package/dist/template/deploy/c11-08-restore-summary.md +113 -0
- package/dist/template/deploy/c224-editor-ux-audit-2026-09-29.md +120 -0
- package/dist/template/deploy/c313-live-acceptance-2026-09-28.log +219 -0
- package/dist/template/deploy/c313-live-acceptance-2026-09-28.md +83 -0
- package/dist/template/deploy/c324-storefront-parity-2026-09-29.md +168 -0
- package/dist/template/deploy/catalog-cart-access.md +35 -0
- package/dist/template/deploy/catalog-checkout-milestones.md +56 -0
- package/dist/template/deploy/ci-release-gate.md +83 -0
- package/dist/template/deploy/client-readiness.md +49 -0
- package/dist/template/deploy/commerce-catalog.md +119 -0
- package/dist/template/deploy/commerce-money.md +191 -0
- package/dist/template/deploy/commerce-payments.md +226 -0
- package/dist/template/deploy/content-security-policy.md +84 -0
- package/dist/template/deploy/contribute.md +37 -0
- package/dist/template/deploy/customer-locales.md +82 -0
- package/dist/template/deploy/customer-surfaces-2026-10-07.md +90 -0
- package/dist/template/deploy/customization-seams.md +18 -0
- package/dist/template/deploy/demo-scenarios.md +96 -0
- package/dist/template/deploy/digitalocean-app/.env.example +15 -0
- package/dist/template/deploy/digitalocean-app/README.md +26 -0
- package/dist/template/deploy/digitalocean-app/infra/app.yaml +75 -0
- package/dist/template/deploy/digitalocean-app/migrate.md +10 -0
- package/dist/template/deploy/digitalocean-app/recipe.yaml +40 -0
- package/dist/template/deploy/digitalocean-app/verify.md +10 -0
- package/dist/template/deploy/digitalocean-droplet/.env.example +21 -0
- package/dist/template/deploy/digitalocean-droplet/README.md +145 -0
- package/dist/template/deploy/digitalocean-droplet/deploy.md +89 -0
- package/dist/template/deploy/digitalocean-droplet/infra/Caddyfile +12 -0
- package/dist/template/deploy/digitalocean-droplet/infra/backup.sh +52 -0
- package/dist/template/deploy/digitalocean-droplet/infra/cloud-init.yml +46 -0
- package/dist/template/deploy/digitalocean-droplet/infra/compose.yml +65 -0
- package/dist/template/deploy/digitalocean-droplet/migrate.md +9 -0
- package/dist/template/deploy/digitalocean-droplet/recipe.yaml +47 -0
- package/dist/template/deploy/digitalocean-droplet/verify.md +117 -0
- package/dist/template/deploy/doc-claim-mapping.md +261 -0
- package/dist/template/deploy/docker-selfhost/.env.example +15 -0
- package/dist/template/deploy/docker-selfhost/README.md +28 -0
- package/dist/template/deploy/docker-selfhost/docker-updater/Caddyfile +9 -0
- package/dist/template/deploy/docker-selfhost/docker-updater/README.md +121 -0
- package/dist/template/deploy/docker-selfhost/docker-updater/compose.yml +64 -0
- package/dist/template/deploy/docker-selfhost/docker-updater/config.example.json +10 -0
- package/dist/template/deploy/docker-selfhost/docker-updater/freeholder-update-check.service +11 -0
- package/dist/template/deploy/docker-selfhost/docker-updater/freeholder-update-check.timer +10 -0
- package/dist/template/deploy/docker-selfhost/docker-updater/freeholder-updater.service +20 -0
- package/dist/template/deploy/docker-selfhost/infra/compose.yml +41 -0
- package/dist/template/deploy/docker-selfhost/migrate.md +9 -0
- package/dist/template/deploy/docker-selfhost/playground/README.md +76 -0
- package/dist/template/deploy/docker-selfhost/playground/compose.proxy-overlay.yml +14 -0
- package/dist/template/deploy/docker-selfhost/playground/compose.yml +59 -0
- package/dist/template/deploy/docker-selfhost/playground/demo.freeholder.ai.caddy +10 -0
- package/dist/template/deploy/docker-selfhost/playground/freeholder-playground-reset.service +10 -0
- package/dist/template/deploy/docker-selfhost/playground/freeholder-playground-reset.timer +10 -0
- package/dist/template/deploy/docker-selfhost/playground/reset.sh +17 -0
- package/dist/template/deploy/docker-selfhost/recipe.yaml +42 -0
- package/dist/template/deploy/docker-selfhost/verify.md +9 -0
- package/dist/template/deploy/edge-adapters.md +58 -0
- package/dist/template/deploy/event-outbox.md +80 -0
- package/dist/template/deploy/f-criteria-matrix.md +4649 -0
- package/dist/template/deploy/first-party-plugins.md +219 -0
- package/dist/template/deploy/fork-lane.md +93 -0
- package/dist/template/deploy/host-updater.example.json +23 -0
- package/dist/template/deploy/host-updater.md +107 -0
- package/dist/template/deploy/mail-delivery.md +205 -0
- package/dist/template/deploy/media-lifecycle.md +129 -0
- package/dist/template/deploy/migration-runbook.md +117 -0
- package/dist/template/deploy/n1-schema.md +34 -0
- package/dist/template/deploy/notification-fanout.md +92 -0
- package/dist/template/deploy/ownership-recovery.md +193 -0
- package/dist/template/deploy/perf-reference-run-2026-09-27.log +432 -0
- package/dist/template/deploy/performance-measurements.md +234 -0
- package/dist/template/deploy/play-data-safety.md +73 -0
- package/dist/template/deploy/privacy-rights.md +148 -0
- package/dist/template/deploy/provider-recording-erasure.md +102 -0
- package/dist/template/deploy/push-notifications.md +92 -0
- package/dist/template/deploy/railway/.env.example +15 -0
- package/dist/template/deploy/railway/README.md +24 -0
- package/dist/template/deploy/railway/migrate.md +10 -0
- package/dist/template/deploy/railway/recipe.yaml +35 -0
- package/dist/template/deploy/railway/verify.md +9 -0
- package/dist/template/deploy/recipe-verification.md +23 -0
- package/dist/template/deploy/record-trash.md +115 -0
- package/dist/template/deploy/release-channels.md +27 -0
- package/dist/template/deploy/release-feed.md +53 -0
- package/dist/template/deploy/release-notes-2026-09-14.md +86 -0
- package/dist/template/deploy/release-notes-2026-09-15.md +52 -0
- package/dist/template/deploy/release-notes-2026-09-16.md +114 -0
- package/dist/template/deploy/release-notes-2026-09-26.md +209 -0
- package/dist/template/deploy/release-notes-2026-09-27.md +47 -0
- package/dist/template/deploy/release-notes-2026-09-28.md +142 -0
- package/dist/template/deploy/release-notes-2026-09-29.md +138 -0
- package/dist/template/deploy/release-notes-2026-09-30.md +50 -0
- package/dist/template/deploy/release-notes-2026-10-01.md +112 -0
- package/dist/template/deploy/release-readiness.md +46 -0
- package/dist/template/deploy/render/.env.example +15 -0
- package/dist/template/deploy/render/README.md +22 -0
- package/dist/template/deploy/render/migrate.md +10 -0
- package/dist/template/deploy/render/recipe.yaml +40 -0
- package/dist/template/deploy/render/verify.md +9 -0
- package/dist/template/deploy/replit/.env.example +10 -0
- package/dist/template/deploy/replit/README.md +29 -0
- package/dist/template/deploy/replit/migrate.md +10 -0
- package/dist/template/deploy/replit/recipe.yaml +40 -0
- package/dist/template/deploy/replit/verify.md +10 -0
- package/dist/template/deploy/role-guidance.md +77 -0
- package/dist/template/deploy/spec-reconciliation.md +188 -0
- package/dist/template/deploy/stable-acceptance-2026-10-05.md +168 -0
- package/dist/template/deploy/update-admin.md +83 -0
- package/dist/template/deploy/update-apply.md +48 -0
- package/dist/template/deploy/update-checks.md +27 -0
- package/dist/template/deploy/update-escalation.md +71 -0
- package/dist/template/deploy/update-policy.md +20 -0
- package/dist/template/deploy/update-preflight.md +19 -0
- package/dist/template/deploy/update-status.md +78 -0
- package/dist/template/deploy/update-targets.md +90 -0
- package/dist/template/deploy/webhook-delivery.md +36 -0
- package/dist/template/drizzle.config.ts +24 -0
- package/dist/template/eslint.config.mjs +241 -0
- package/dist/template/freeholder.config.ts +11 -0
- package/dist/template/gitignore.template +48 -0
- package/dist/template/instrumentation.node.ts +113 -0
- package/dist/template/instrumentation.ts +23 -0
- package/dist/template/locales/README.md +68 -0
- package/dist/template/locales/ar.json +7090 -0
- package/dist/template/locales/en.json +7090 -0
- package/dist/template/locales/es.json +7090 -0
- package/dist/template/locales/fr.json +7090 -0
- package/dist/template/next.config.ts +166 -0
- package/dist/template/package.json +98 -0
- package/dist/template/packages/README.md +31 -0
- package/dist/template/packages/cli/LICENSE +202 -0
- package/dist/template/packages/cli/README.md +63 -0
- package/dist/template/packages/cli/package.json +29 -0
- package/dist/template/packages/cli/src/index.ts +355 -0
- package/dist/template/packages/cli/tsconfig.json +15 -0
- package/dist/template/packages/create-freeholder/LICENSE +202 -0
- package/dist/template/packages/create-freeholder/README.md +31 -0
- package/dist/template/packages/create-freeholder/package.json +29 -0
- package/dist/template/packages/create-freeholder/scripts/build.mjs +151 -0
- package/dist/template/packages/create-freeholder/src/index.ts +789 -0
- package/dist/template/packages/create-freeholder/tsconfig.json +15 -0
- package/dist/template/packages/freeholder-app/LICENSE +202 -0
- package/dist/template/packages/freeholder-app/README.md +72 -0
- package/dist/template/packages/freeholder-app/package.json +29 -0
- package/dist/template/packages/freeholder-app/src/assets.ts +320 -0
- package/dist/template/packages/freeholder-app/src/branding.ts +134 -0
- package/dist/template/packages/freeholder-app/src/config.ts +163 -0
- package/dist/template/packages/freeholder-app/src/index.ts +158 -0
- package/dist/template/packages/freeholder-app/src/init.ts +230 -0
- package/dist/template/packages/freeholder-app/src/png.ts +214 -0
- package/dist/template/packages/freeholder-app/tsconfig.json +15 -0
- package/dist/template/packages/mobile-app/LICENSE +202 -0
- package/dist/template/packages/mobile-app/README.md +137 -0
- package/dist/template/packages/mobile-app/package.json +34 -0
- package/dist/template/packages/mobile-app/src/branding.ts +91 -0
- package/dist/template/packages/mobile-app/src/cached-discovery.ts +36 -0
- package/dist/template/packages/mobile-app/src/capture-batches.ts +558 -0
- package/dist/template/packages/mobile-app/src/capture.ts +262 -0
- package/dist/template/packages/mobile-app/src/deep-links.ts +246 -0
- package/dist/template/packages/mobile-app/src/discovery.ts +195 -0
- package/dist/template/packages/mobile-app/src/format.ts +10 -0
- package/dist/template/packages/mobile-app/src/index.ts +122 -0
- package/dist/template/packages/mobile-app/src/messages.generated.ts +677 -0
- package/dist/template/packages/mobile-app/src/offline.ts +183 -0
- package/dist/template/packages/mobile-app/src/private-cache.ts +113 -0
- package/dist/template/packages/mobile-app/src/screens.ts +411 -0
- package/dist/template/packages/mobile-app/src/session.ts +317 -0
- package/dist/template/packages/mobile-app/src/strings.ts +11 -0
- package/dist/template/packages/mobile-app/src/transport.ts +50 -0
- package/dist/template/packages/mobile-app/tsconfig.json +15 -0
- package/dist/template/packages/plugin-kit/LICENSE +202 -0
- package/dist/template/packages/plugin-kit/README.md +11 -0
- package/dist/template/packages/plugin-kit/package.json +37 -0
- package/dist/template/packages/plugin-kit/src/contract.ts +169 -0
- package/dist/template/packages/plugin-kit/src/harness.ts +40 -0
- package/dist/template/packages/plugin-kit/src/importer.ts +37 -0
- package/dist/template/packages/plugin-kit/src/index.ts +41 -0
- package/dist/template/packages/plugin-kit/src/scaffold.ts +54 -0
- package/dist/template/packages/plugin-kit/src/semver.ts +78 -0
- package/dist/template/packages/plugin-kit/tsconfig.json +15 -0
- package/dist/template/packages/sdk/LICENSE +202 -0
- package/dist/template/packages/sdk/README.md +38 -0
- package/dist/template/packages/sdk/package.json +37 -0
- package/dist/template/packages/sdk/src/generated.ts +8557 -0
- package/dist/template/packages/sdk/src/index.ts +178 -0
- package/dist/template/packages/sdk/src/version.ts +4 -0
- package/dist/template/packages/sdk/test/generated.test.mjs +20 -0
- package/dist/template/packages/sdk/tsconfig.json +15 -0
- package/dist/template/packages/templates/LICENSE +202 -0
- package/dist/template/packages/templates/README.md +17 -0
- package/dist/template/packages/templates/package.json +37 -0
- package/dist/template/packages/templates/src/presets.ts +377 -0
- package/dist/template/packages/templates/tsconfig.json +14 -0
- package/dist/template/playwright.a11y.config.ts +109 -0
- package/dist/template/plugins/community/manifest.ts +19 -0
- package/dist/template/plugins/community/plugin.json +10 -0
- package/dist/template/plugins/community/schema.ts +116 -0
- package/dist/template/plugins/community/service.ts +996 -0
- package/dist/template/plugins/community/tables.ts +9 -0
- package/dist/template/plugins/gift-registry/manifest.ts +16 -0
- package/dist/template/plugins/gift-registry/plugin.json +10 -0
- package/dist/template/plugins/gift-registry/schema.ts +44 -0
- package/dist/template/plugins/gift-registry/service.ts +347 -0
- package/dist/template/plugins/gift-registry/tables.ts +3 -0
- package/dist/template/plugins/marketplace/adapter.ts +159 -0
- package/dist/template/plugins/marketplace/jobs.ts +37 -0
- package/dist/template/plugins/marketplace/manifest.ts +20 -0
- package/dist/template/plugins/marketplace/plugin.json +10 -0
- package/dist/template/plugins/marketplace/schema.ts +75 -0
- package/dist/template/plugins/marketplace/service.ts +642 -0
- package/dist/template/plugins/marketplace/shopify.ts +174 -0
- package/dist/template/plugins/marketplace/tables.ts +3 -0
- package/dist/template/plugins/print-on-demand/adapter.ts +86 -0
- package/dist/template/plugins/print-on-demand/jobs.ts +29 -0
- package/dist/template/plugins/print-on-demand/manifest.ts +21 -0
- package/dist/template/plugins/print-on-demand/plugin.json +10 -0
- package/dist/template/plugins/print-on-demand/printify.ts +139 -0
- package/dist/template/plugins/print-on-demand/schema.ts +54 -0
- package/dist/template/plugins/print-on-demand/service.ts +531 -0
- package/dist/template/plugins/print-on-demand/tables.ts +3 -0
- package/dist/template/plugins/social-fixture/adapter.ts +35 -0
- package/dist/template/plugins/social-fixture/manifest.ts +18 -0
- package/dist/template/plugins/social-fixture/plugin.json +10 -0
- package/dist/template/plugins/social-fixture/service.ts +9 -0
- package/dist/template/plugins/voice-video/adapter.ts +183 -0
- package/dist/template/plugins/voice-video/daily.ts +262 -0
- package/dist/template/plugins/voice-video/erasure.ts +93 -0
- package/dist/template/plugins/voice-video/jobs.ts +79 -0
- package/dist/template/plugins/voice-video/manifest.ts +34 -0
- package/dist/template/plugins/voice-video/paradise-provider.ts +157 -0
- package/dist/template/plugins/voice-video/paradise.ts +325 -0
- package/dist/template/plugins/voice-video/plugin.json +10 -0
- package/dist/template/plugins/voice-video/schema.ts +105 -0
- package/dist/template/plugins/voice-video/service.ts +1019 -0
- package/dist/template/plugins/voice-video/settings.ts +128 -0
- package/dist/template/plugins/voice-video/tables.ts +3 -0
- package/dist/template/plugins/voice-video/webhook.ts +134 -0
- package/dist/template/pnpm-lock.yaml +5386 -0
- package/dist/template/pnpm-workspace.yaml +81 -0
- package/dist/template/postcss.config.mjs +7 -0
- package/dist/template/proxy.ts +284 -0
- package/dist/template/public/fonts/OFL-JetBrains-Mono.txt +93 -0
- package/dist/template/public/fonts/OFL-Schibsted-Grotesk.txt +93 -0
- package/dist/template/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/dist/template/public/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/dist/template/public/fonts/schibsted-grotesk-latin-ext.woff2 +0 -0
- package/dist/template/public/fonts/schibsted-grotesk-latin.woff2 +0 -0
- package/dist/template/render.yaml +46 -0
- package/dist/template/replit.nix +9 -0
- package/dist/template/scripts/README.md +69 -0
- package/dist/template/scripts/a11y-smoke.d.mts +24 -0
- package/dist/template/scripts/a11y-smoke.mjs +163 -0
- package/dist/template/scripts/changelog-gate.mjs +63 -0
- package/dist/template/scripts/contract-evidence.d.mts +8 -0
- package/dist/template/scripts/contract-evidence.mjs +18 -0
- package/dist/template/scripts/dependency-audit.d.mts +18 -0
- package/dist/template/scripts/dependency-audit.mjs +315 -0
- package/dist/template/scripts/deploy-droplet-remote.sh +138 -0
- package/dist/template/scripts/deploy-droplet.d.mts +59 -0
- package/dist/template/scripts/deploy-droplet.mjs +322 -0
- package/dist/template/scripts/docker-updater.py +524 -0
- package/dist/template/scripts/doctor.d.mts +3 -0
- package/dist/template/scripts/doctor.mjs +199 -0
- package/dist/template/scripts/f-matrix.d.mts +53 -0
- package/dist/template/scripts/f-matrix.mjs +298 -0
- package/dist/template/scripts/fast-gates.mjs +128 -0
- package/dist/template/scripts/generate-changelog.d.mts +16 -0
- package/dist/template/scripts/generate-changelog.mjs +95 -0
- package/dist/template/scripts/generate-mobile-messages.mjs +12 -0
- package/dist/template/scripts/generate-sdk.mjs +54 -0
- package/dist/template/scripts/host-updater.py +365 -0
- package/dist/template/scripts/launch-prepare.d.mts +14 -0
- package/dist/template/scripts/launch-prepare.mjs +93 -0
- package/dist/template/scripts/license-headers.mjs +169 -0
- package/dist/template/scripts/media-transfer.d.mts +19 -0
- package/dist/template/scripts/media-transfer.mjs +144 -0
- package/dist/template/scripts/mobile-store-gate.d.mts +72 -0
- package/dist/template/scripts/mobile-store-gate.mjs +569 -0
- package/dist/template/scripts/owner-password.mjs +107 -0
- package/dist/template/scripts/ownership-drill.d.mts +20 -0
- package/dist/template/scripts/ownership-drill.mjs +237 -0
- package/dist/template/scripts/ownership-export.mjs +46 -0
- package/dist/template/scripts/package-artifact-gate.mjs +291 -0
- package/dist/template/scripts/performance-budgets.d.mts +53 -0
- package/dist/template/scripts/performance-budgets.mjs +311 -0
- package/dist/template/scripts/plan-gate.d.mts +38 -0
- package/dist/template/scripts/plan-gate.mjs +515 -0
- package/dist/template/scripts/playground-gate.sh +47 -0
- package/dist/template/scripts/prepare-do-app-spec.d.mts +6 -0
- package/dist/template/scripts/prepare-do-app-spec.mjs +70 -0
- package/dist/template/scripts/public-gates.sh +186 -0
- package/dist/template/scripts/recipe-matrix.sh +141 -0
- package/dist/template/scripts/recipe-update-actions.mjs +157 -0
- package/dist/template/scripts/release-feed.d.mts +49 -0
- package/dist/template/scripts/release-feed.mjs +215 -0
- package/dist/template/scripts/release-history.d.mts +3 -0
- package/dist/template/scripts/release-history.mjs +27 -0
- package/dist/template/scripts/release-packages.d.mts +13 -0
- package/dist/template/scripts/release-packages.mjs +153 -0
- package/dist/template/scripts/release-publication.d.mts +7 -0
- package/dist/template/scripts/release-publication.mjs +58 -0
- package/dist/template/scripts/resolve-append-conflicts.mjs +132 -0
- package/dist/template/scripts/runtime-balanced-sequencer.ts +178 -0
- package/dist/template/scripts/schema-baseline-identity.d.mts +35 -0
- package/dist/template/scripts/schema-baseline-identity.mjs +373 -0
- package/dist/template/scripts/schema-compat-gate.d.mts +44 -0
- package/dist/template/scripts/schema-compat-gate.mjs +264 -0
- package/dist/template/scripts/seo-gate.d.mts +31 -0
- package/dist/template/scripts/seo-gate.mjs +326 -0
- package/dist/template/scripts/standalone-artifact-gate.mjs +163 -0
- package/dist/template/scripts/start-browser-server.mjs +29 -0
- package/dist/template/scripts/start-replit.mjs +16 -0
- package/dist/template/scripts/start.mjs +7 -0
- package/dist/template/scripts/upgrade-gate.sh +134 -0
- package/dist/template/scripts/verify-dependency-attestation.d.mts +13 -0
- package/dist/template/scripts/verify-dependency-attestation.mjs +93 -0
- package/dist/template/scripts/workflow-integrity-gate.d.mts +6 -0
- package/dist/template/scripts/workflow-integrity-gate.mjs +190 -0
- package/dist/template/security/adversarial-audit-2026-10-08.md +111 -0
- package/dist/template/security/client-readiness-audit-2026-09-21.md +273 -0
- package/dist/template/security/dependency-audit-exceptions.json +3 -0
- package/dist/template/security/independent-review-packet.md +369 -0
- package/dist/template/security/project-audit-2026-09-13.md +127 -0
- package/dist/template/seed/README.md +86 -0
- package/dist/template/seed/demo/content.ts +812 -0
- package/dist/template/src/README.md +19 -0
- package/dist/template/src/adapters/agent/index.ts +35 -0
- package/dist/template/src/adapters/agent/pm-brain.ts +125 -0
- package/dist/template/src/adapters/agent/types.ts +39 -0
- package/dist/template/src/adapters/agent/workforce-anthropic.ts +191 -0
- package/dist/template/src/adapters/agent/workforce-openai.ts +182 -0
- package/dist/template/src/adapters/agent/workforce-types.ts +80 -0
- package/dist/template/src/adapters/agent/workforce.ts +93 -0
- package/dist/template/src/adapters/ai/anthropic.ts +176 -0
- package/dist/template/src/adapters/ai/index.ts +41 -0
- package/dist/template/src/adapters/ai/none.ts +14 -0
- package/dist/template/src/adapters/ai/openai.ts +132 -0
- package/dist/template/src/adapters/ai/types.ts +28 -0
- package/dist/template/src/adapters/alt-text/index.ts +77 -0
- package/dist/template/src/adapters/alt-text/openai.ts +143 -0
- package/dist/template/src/adapters/alt-text/types.ts +30 -0
- package/dist/template/src/adapters/calendar/index.ts +12 -0
- package/dist/template/src/adapters/calendar/none.ts +18 -0
- package/dist/template/src/adapters/calendar/types.ts +43 -0
- package/dist/template/src/adapters/carrier/index.ts +12 -0
- package/dist/template/src/adapters/carrier/none.ts +18 -0
- package/dist/template/src/adapters/carrier/types.ts +60 -0
- package/dist/template/src/adapters/git/github.ts +82 -0
- package/dist/template/src/adapters/mail/console.ts +46 -0
- package/dist/template/src/adapters/mail/gmail.ts +44 -0
- package/dist/template/src/adapters/mail/http.ts +88 -0
- package/dist/template/src/adapters/mail/index.ts +255 -0
- package/dist/template/src/adapters/mail/mime.ts +57 -0
- package/dist/template/src/adapters/mail/none.ts +18 -0
- package/dist/template/src/adapters/mail/outlook.ts +71 -0
- package/dist/template/src/adapters/mail/postmark.ts +105 -0
- package/dist/template/src/adapters/mail/resend.ts +86 -0
- package/dist/template/src/adapters/mail/ses.ts +114 -0
- package/dist/template/src/adapters/mail/smtp.ts +85 -0
- package/dist/template/src/adapters/mail/types.ts +79 -0
- package/dist/template/src/adapters/malware/clamav.ts +90 -0
- package/dist/template/src/adapters/malware/index.ts +43 -0
- package/dist/template/src/adapters/malware/none.ts +16 -0
- package/dist/template/src/adapters/malware/types.ts +28 -0
- package/dist/template/src/adapters/notifications/index.ts +27 -0
- package/dist/template/src/adapters/notifications/none.ts +27 -0
- package/dist/template/src/adapters/notifications/types.ts +36 -0
- package/dist/template/src/adapters/payments/currency.ts +50 -0
- package/dist/template/src/adapters/payments/flutterwave.ts +239 -0
- package/dist/template/src/adapters/payments/http.ts +82 -0
- package/dist/template/src/adapters/payments/index.ts +42 -0
- package/dist/template/src/adapters/payments/manual.ts +59 -0
- package/dist/template/src/adapters/payments/mollie.ts +239 -0
- package/dist/template/src/adapters/payments/none.ts +38 -0
- package/dist/template/src/adapters/payments/paypal.ts +518 -0
- package/dist/template/src/adapters/payments/paystack.ts +206 -0
- package/dist/template/src/adapters/payments/provider-helpers.ts +122 -0
- package/dist/template/src/adapters/payments/providers.ts +31 -0
- package/dist/template/src/adapters/payments/razorpay.ts +246 -0
- package/dist/template/src/adapters/payments/square.ts +251 -0
- package/dist/template/src/adapters/payments/stripe.ts +462 -0
- package/dist/template/src/adapters/payments/types.ts +244 -0
- package/dist/template/src/adapters/point-of-sale/index.ts +21 -0
- package/dist/template/src/adapters/point-of-sale/manual.ts +35 -0
- package/dist/template/src/adapters/point-of-sale/none.ts +18 -0
- package/dist/template/src/adapters/point-of-sale/stripe.ts +112 -0
- package/dist/template/src/adapters/point-of-sale/types.ts +43 -0
- package/dist/template/src/adapters/registry.ts +46 -0
- package/dist/template/src/adapters/sms/index.ts +30 -0
- package/dist/template/src/adapters/sms/none.ts +24 -0
- package/dist/template/src/adapters/sms/twilio.ts +410 -0
- package/dist/template/src/adapters/sms/types.ts +140 -0
- package/dist/template/src/adapters/social/factory.ts +370 -0
- package/dist/template/src/adapters/social/http.ts +109 -0
- package/dist/template/src/adapters/social/index.ts +15 -0
- package/dist/template/src/adapters/social/media.ts +53 -0
- package/dist/template/src/adapters/social/networks.ts +174 -0
- package/dist/template/src/adapters/social/none.ts +37 -0
- package/dist/template/src/adapters/social/types.ts +130 -0
- package/dist/template/src/adapters/storage/index.ts +82 -0
- package/dist/template/src/adapters/storage/local.ts +164 -0
- package/dist/template/src/adapters/storage/replit.ts +114 -0
- package/dist/template/src/adapters/storage/s3.ts +298 -0
- package/dist/template/src/adapters/storage/types.ts +138 -0
- package/dist/template/src/adapters/tax/index.ts +10 -0
- package/dist/template/src/adapters/tax/none.ts +14 -0
- package/dist/template/src/adapters/tax/types.ts +60 -0
- package/dist/template/src/adapters/types.ts +60 -0
- package/dist/template/src/core/agents/budget-alerts.ts +73 -0
- package/dist/template/src/core/agents/budget.ts +162 -0
- package/dist/template/src/core/agents/cron.ts +77 -0
- package/dist/template/src/core/agents/envelope.ts +68 -0
- package/dist/template/src/core/agents/execution.ts +639 -0
- package/dist/template/src/core/agents/managed.ts +586 -0
- package/dist/template/src/core/agents/playbook-events.ts +77 -0
- package/dist/template/src/core/agents/playbook-params.ts +121 -0
- package/dist/template/src/core/agents/playbook-schedule.ts +305 -0
- package/dist/template/src/core/agents/playbooks.ts +579 -0
- package/dist/template/src/core/agents/previews.ts +86 -0
- package/dist/template/src/core/agents/pricing.ts +111 -0
- package/dist/template/src/core/agents/schema.ts +329 -0
- package/dist/template/src/core/agents/service.ts +1382 -0
- package/dist/template/src/core/agents/writes.ts +407 -0
- package/dist/template/src/core/api/dispatch.ts +131 -0
- package/dist/template/src/core/api/openapi.ts +246 -0
- package/dist/template/src/core/apikeys/profiles.ts +24 -0
- package/dist/template/src/core/apikeys/schema.ts +87 -0
- package/dist/template/src/core/apikeys/service.ts +245 -0
- package/dist/template/src/core/apikeys/tokens.ts +130 -0
- package/dist/template/src/core/attestations/schema.ts +118 -0
- package/dist/template/src/core/attestations/service.ts +354 -0
- package/dist/template/src/core/auth/bootstrap.ts +22 -0
- package/dist/template/src/core/auth/magic-links/service.ts +272 -0
- package/dist/template/src/core/auth/passwords.ts +52 -0
- package/dist/template/src/core/auth/reset.ts +238 -0
- package/dist/template/src/core/auth/schema.ts +318 -0
- package/dist/template/src/core/auth/service.ts +345 -0
- package/dist/template/src/core/auth/session-management/service.ts +314 -0
- package/dist/template/src/core/auth/sessions.ts +280 -0
- package/dist/template/src/core/auth/two-factor-crypto.ts +172 -0
- package/dist/template/src/core/auth/two-factor.ts +863 -0
- package/dist/template/src/core/automations/core-verbs.ts +86 -0
- package/dist/template/src/core/automations/verbs.ts +121 -0
- package/dist/template/src/core/boot.ts +231 -0
- package/dist/template/src/core/briefing/contributors.ts +288 -0
- package/dist/template/src/core/briefing/playbook-section.ts +136 -0
- package/dist/template/src/core/briefing/registry.ts +155 -0
- package/dist/template/src/core/briefing/schema.ts +124 -0
- package/dist/template/src/core/briefing/service.ts +425 -0
- package/dist/template/src/core/briefing/update.ts +24 -0
- package/dist/template/src/core/catalogue/schema.ts +136 -0
- package/dist/template/src/core/catalogue/service.ts +724 -0
- package/dist/template/src/core/config.test.ts +62 -0
- package/dist/template/src/core/config.ts +69 -0
- package/dist/template/src/core/connections/busy.ts +190 -0
- package/dist/template/src/core/connections/calendar-oauth.ts +323 -0
- package/dist/template/src/core/connections/calendar-providers.ts +352 -0
- package/dist/template/src/core/connections/calendar-sync.ts +558 -0
- package/dist/template/src/core/connections/calendar-write.ts +194 -0
- package/dist/template/src/core/connections/crypto.ts +200 -0
- package/dist/template/src/core/connections/grants.ts +322 -0
- package/dist/template/src/core/connections/mail-import.ts +380 -0
- package/dist/template/src/core/connections/mail-providers.ts +184 -0
- package/dist/template/src/core/connections/mail-read-oauth.ts +296 -0
- package/dist/template/src/core/connections/oauth-core.ts +472 -0
- package/dist/template/src/core/connections/schema.ts +250 -0
- package/dist/template/src/core/connections/service.ts +606 -0
- package/dist/template/src/core/contacts/custom-fields.ts +287 -0
- package/dist/template/src/core/contacts/duplicates.ts +359 -0
- package/dist/template/src/core/contacts/funnel.ts +30 -0
- package/dist/template/src/core/contacts/lifecycle.ts +91 -0
- package/dist/template/src/core/contacts/organizations.ts +214 -0
- package/dist/template/src/core/contacts/relationships.ts +477 -0
- package/dist/template/src/core/contacts/schema.ts +300 -0
- package/dist/template/src/core/contacts/service.ts +1401 -0
- package/dist/template/src/core/contract/json-schema.ts +39 -0
- package/dist/template/src/core/contract/projections.ts +58 -0
- package/dist/template/src/core/contract/sdk.ts +287 -0
- package/dist/template/src/core/contract.ts +20 -0
- package/dist/template/src/core/contribute/deliver.ts +274 -0
- package/dist/template/src/core/contribute/schema.ts +163 -0
- package/dist/template/src/core/contribute/service.ts +1072 -0
- package/dist/template/src/core/dates/cadence.ts +73 -0
- package/dist/template/src/core/db/columns.ts +32 -0
- package/dist/template/src/core/db/errors.ts +66 -0
- package/dist/template/src/core/db/index.ts +90 -0
- package/dist/template/src/core/demo/fixtures.ts +441 -0
- package/dist/template/src/core/demo/handler.ts +89 -0
- package/dist/template/src/core/demo/playground-policy.ts +73 -0
- package/dist/template/src/core/demo/playground.ts +55 -0
- package/dist/template/src/core/demo/schema.ts +135 -0
- package/dist/template/src/core/demo/service.ts +673 -0
- package/dist/template/src/core/design/read.ts +9 -0
- package/dist/template/src/core/design/schema.ts +33 -0
- package/dist/template/src/core/design/service.ts +280 -0
- package/dist/template/src/core/design/theme.ts +45 -0
- package/dist/template/src/core/design/tokens.ts +355 -0
- package/dist/template/src/core/discovery.ts +116 -0
- package/dist/template/src/core/doctor/index.ts +1169 -0
- package/dist/template/src/core/doctor/service.ts +44 -0
- package/dist/template/src/core/entitlements/access.ts +478 -0
- package/dist/template/src/core/entitlements/schema.ts +163 -0
- package/dist/template/src/core/entitlements/service.ts +590 -0
- package/dist/template/src/core/env.test.ts +148 -0
- package/dist/template/src/core/env.ts +442 -0
- package/dist/template/src/core/events/catalogue.ts +61 -0
- package/dist/template/src/core/events/index.ts +138 -0
- package/dist/template/src/core/events/outbox-service.ts +198 -0
- package/dist/template/src/core/events/outbox.ts +474 -0
- package/dist/template/src/core/events/schema.ts +152 -0
- package/dist/template/src/core/events/service.ts +37 -0
- package/dist/template/src/core/funnel/stages.ts +106 -0
- package/dist/template/src/core/guidance/definitions.ts +276 -0
- package/dist/template/src/core/guidance/schema.ts +107 -0
- package/dist/template/src/core/guidance/service.ts +530 -0
- package/dist/template/src/core/http/actor.ts +115 -0
- package/dist/template/src/core/http/body.ts +96 -0
- package/dist/template/src/core/http/cookies.ts +88 -0
- package/dist/template/src/core/http/csp.ts +118 -0
- package/dist/template/src/core/http/csrf.ts +89 -0
- package/dist/template/src/core/http/headers.ts +33 -0
- package/dist/template/src/core/http/inline-json.ts +20 -0
- package/dist/template/src/core/http/pinned-download.ts +118 -0
- package/dist/template/src/core/http/request-metadata.ts +48 -0
- package/dist/template/src/core/http/respond.ts +82 -0
- package/dist/template/src/core/http/route.ts +83 -0
- package/dist/template/src/core/i18n/customer.ts +187 -0
- package/dist/template/src/core/i18n/index.ts +286 -0
- package/dist/template/src/core/i18n/schema.ts +59 -0
- package/dist/template/src/core/i18n/service.ts +339 -0
- package/dist/template/src/core/i18n/zoned.ts +96 -0
- package/dist/template/src/core/ics.ts +260 -0
- package/dist/template/src/core/import/contacts-schema.ts +237 -0
- package/dist/template/src/core/import/contacts-service.ts +923 -0
- package/dist/template/src/core/import/contract.ts +135 -0
- package/dist/template/src/core/import/csv.ts +190 -0
- package/dist/template/src/core/import/parsers.ts +217 -0
- package/dist/template/src/core/import/service.ts +606 -0
- package/dist/template/src/core/import/signup-contact-providers.ts +219 -0
- package/dist/template/src/core/import/signup-contact-service.ts +1077 -0
- package/dist/template/src/core/import/vcard.ts +77 -0
- package/dist/template/src/core/invitations/service.ts +656 -0
- package/dist/template/src/core/jobs/core-jobs.ts +1000 -0
- package/dist/template/src/core/jobs/health.ts +264 -0
- package/dist/template/src/core/jobs/index.ts +926 -0
- package/dist/template/src/core/jobs/schema.ts +111 -0
- package/dist/template/src/core/jobs/service.ts +269 -0
- package/dist/template/src/core/locations/coverage.ts +152 -0
- package/dist/template/src/core/locations/jsonld.ts +155 -0
- package/dist/template/src/core/locations/nap.ts +159 -0
- package/dist/template/src/core/locations/read.ts +15 -0
- package/dist/template/src/core/locations/schema.ts +257 -0
- package/dist/template/src/core/locations/service.ts +667 -0
- package/dist/template/src/core/mail/link-confirmation.ts +31 -0
- package/dist/template/src/core/mail/oauth.ts +351 -0
- package/dist/template/src/core/mail/outbox-crypto.ts +73 -0
- package/dist/template/src/core/mail/route.ts +27 -0
- package/dist/template/src/core/mail/schema.ts +359 -0
- package/dist/template/src/core/mail/service.ts +1407 -0
- package/dist/template/src/core/mail/webhooks.ts +735 -0
- package/dist/template/src/core/manifest.ts +173 -0
- package/dist/template/src/core/media/capture.ts +1191 -0
- package/dist/template/src/core/media/framing.ts +265 -0
- package/dist/template/src/core/media/schema.ts +388 -0
- package/dist/template/src/core/media/service.ts +3321 -0
- package/dist/template/src/core/media/validation.ts +264 -0
- package/dist/template/src/core/media/variants.ts +213 -0
- package/dist/template/src/core/media/watermark.ts +158 -0
- package/dist/template/src/core/messaging/chat-cookie.ts +30 -0
- package/dist/template/src/core/messaging/chat.ts +424 -0
- package/dist/template/src/core/messaging/consent.ts +390 -0
- package/dist/template/src/core/messaging/inbox.ts +602 -0
- package/dist/template/src/core/messaging/keywords.ts +540 -0
- package/dist/template/src/core/messaging/numbers-schema.ts +126 -0
- package/dist/template/src/core/messaging/policy-schema.ts +84 -0
- package/dist/template/src/core/messaging/policy.ts +575 -0
- package/dist/template/src/core/messaging/portal.ts +30 -0
- package/dist/template/src/core/messaging/purpose.ts +12 -0
- package/dist/template/src/core/messaging/registration.ts +235 -0
- package/dist/template/src/core/messaging/schema.ts +433 -0
- package/dist/template/src/core/messaging/service.ts +805 -0
- package/dist/template/src/core/messaging/sms.ts +1052 -0
- package/dist/template/src/core/messaging/webhook-route.ts +118 -0
- package/dist/template/src/core/migrate.ts +57 -0
- package/dist/template/src/core/module.ts +105 -0
- package/dist/template/src/core/notes/schema.ts +140 -0
- package/dist/template/src/core/notes/service.ts +513 -0
- package/dist/template/src/core/notifications/devices.ts +149 -0
- package/dist/template/src/core/notifications/schema.ts +389 -0
- package/dist/template/src/core/notifications/service.ts +1863 -0
- package/dist/template/src/core/onboarding/contract.ts +130 -0
- package/dist/template/src/core/onboarding/index.ts +213 -0
- package/dist/template/src/core/onboarding/registry.ts +295 -0
- package/dist/template/src/core/paywalls/evaluate.ts +266 -0
- package/dist/template/src/core/paywalls/schema.ts +105 -0
- package/dist/template/src/core/paywalls/service.ts +223 -0
- package/dist/template/src/core/platform.ts +19 -0
- package/dist/template/src/core/plugin.ts +68 -0
- package/dist/template/src/core/plugins/integrity.ts +51 -0
- package/dist/template/src/core/plugins/isolate.ts +49 -0
- package/dist/template/src/core/plugins/registry.ts +70 -0
- package/dist/template/src/core/plugins/schema.ts +96 -0
- package/dist/template/src/core/plugins/service.ts +472 -0
- package/dist/template/src/core/plugins/spine.ts +172 -0
- package/dist/template/src/core/portability/archive.ts +77 -0
- package/dist/template/src/core/portability/ownership-export.d.mts +56 -0
- package/dist/template/src/core/portability/ownership-export.mjs +548 -0
- package/dist/template/src/core/portability/service.ts +119 -0
- package/dist/template/src/core/portal/record-service.ts +38 -0
- package/dist/template/src/core/portal/return-path.ts +9 -0
- package/dist/template/src/core/portal/sections.ts +101 -0
- package/dist/template/src/core/portal/service.ts +202 -0
- package/dist/template/src/core/portal/sign-in.ts +30 -0
- package/dist/template/src/core/privacy/media-consent.ts +328 -0
- package/dist/template/src/core/privacy/publish-veto.ts +59 -0
- package/dist/template/src/core/privacy/schema.ts +320 -0
- package/dist/template/src/core/privacy/service.ts +1935 -0
- package/dist/template/src/core/provenance/service.ts +174 -0
- package/dist/template/src/core/recipes.ts +15 -0
- package/dist/template/src/core/reporting/csv.ts +102 -0
- package/dist/template/src/core/reporting/dimensions.ts +114 -0
- package/dist/template/src/core/retention/apply.ts +47 -0
- package/dist/template/src/core/retention/holds.ts +45 -0
- package/dist/template/src/core/retention/registry.ts +190 -0
- package/dist/template/src/core/retention/schema.ts +34 -0
- package/dist/template/src/core/retention/service.ts +109 -0
- package/dist/template/src/core/retention/sources.ts +42 -0
- package/dist/template/src/core/rewards/issue.ts +100 -0
- package/dist/template/src/core/roles/defaults.ts +161 -0
- package/dist/template/src/core/roles/service.ts +375 -0
- package/dist/template/src/core/runs/schema.ts +290 -0
- package/dist/template/src/core/runs/spine.ts +72 -0
- package/dist/template/src/core/runtime/shutdown.ts +55 -0
- package/dist/template/src/core/runtime.ts +45 -0
- package/dist/template/src/core/scheduling/audience-schema.ts +179 -0
- package/dist/template/src/core/scheduling/audiences.ts +504 -0
- package/dist/template/src/core/scheduling/availability-service.ts +354 -0
- package/dist/template/src/core/scheduling/availability.ts +213 -0
- package/dist/template/src/core/scheduling/bookings.ts +1252 -0
- package/dist/template/src/core/scheduling/funnel.ts +30 -0
- package/dist/template/src/core/scheduling/ics-service.ts +355 -0
- package/dist/template/src/core/scheduling/policy.ts +253 -0
- package/dist/template/src/core/scheduling/portal.ts +50 -0
- package/dist/template/src/core/scheduling/reminders.ts +352 -0
- package/dist/template/src/core/scheduling/requirements.ts +307 -0
- package/dist/template/src/core/scheduling/resolver-service.ts +206 -0
- package/dist/template/src/core/scheduling/resolver.ts +564 -0
- package/dist/template/src/core/scheduling/schema.ts +618 -0
- package/dist/template/src/core/scheduling/service.ts +474 -0
- package/dist/template/src/core/scheduling/waitlist.ts +678 -0
- package/dist/template/src/core/scheduling/writeback.ts +213 -0
- package/dist/template/src/core/scoring/schema.ts +147 -0
- package/dist/template/src/core/scoring/service.ts +602 -0
- package/dist/template/src/core/search/registry.ts +155 -0
- package/dist/template/src/core/search/service.ts +81 -0
- package/dist/template/src/core/search/sources.ts +195 -0
- package/dist/template/src/core/security/csp-reports.ts +256 -0
- package/dist/template/src/core/security/rate-limit.ts +117 -0
- package/dist/template/src/core/security/schema.ts +60 -0
- package/dist/template/src/core/segments/fields.ts +376 -0
- package/dist/template/src/core/segments/schema.ts +112 -0
- package/dist/template/src/core/segments/service.ts +731 -0
- package/dist/template/src/core/seo/classify.ts +56 -0
- package/dist/template/src/core/seo/entities.ts +61 -0
- package/dist/template/src/core/seo/feeds.ts +77 -0
- package/dist/template/src/core/seo/indexnow.ts +110 -0
- package/dist/template/src/core/seo/jsonld.ts +307 -0
- package/dist/template/src/core/seo/meta.ts +84 -0
- package/dist/template/src/core/seo/origin.ts +55 -0
- package/dist/template/src/core/seo/schema.ts +41 -0
- package/dist/template/src/core/seo/service.ts +171 -0
- package/dist/template/src/core/seo/sitemap.ts +185 -0
- package/dist/template/src/core/service.ts +747 -0
- package/dist/template/src/core/services.ts +242 -0
- package/dist/template/src/core/settings/defaults.ts +129 -0
- package/dist/template/src/core/settings/read.ts +24 -0
- package/dist/template/src/core/settings/schema.ts +81 -0
- package/dist/template/src/core/settings/service.ts +407 -0
- package/dist/template/src/core/settings/setup.ts +41 -0
- package/dist/template/src/core/spine/facts.ts +141 -0
- package/dist/template/src/core/subjects.ts +95 -0
- package/dist/template/src/core/tables.ts +180 -0
- package/dist/template/src/core/tasks/schema.ts +174 -0
- package/dist/template/src/core/tasks/service.ts +634 -0
- package/dist/template/src/core/trash.ts +278 -0
- package/dist/template/src/core/update/apply.ts +58 -0
- package/dist/template/src/core/update/catalog.ts +222 -0
- package/dist/template/src/core/update/channels.ts +39 -0
- package/dist/template/src/core/update/check.ts +107 -0
- package/dist/template/src/core/update/escalate-job.ts +111 -0
- package/dist/template/src/core/update/escalation.ts +131 -0
- package/dist/template/src/core/update/feed.ts +80 -0
- package/dist/template/src/core/update/fork-delivery.ts +102 -0
- package/dist/template/src/core/update/fork-merge.ts +195 -0
- package/dist/template/src/core/update/fork.ts +217 -0
- package/dist/template/src/core/update/host.ts +59 -0
- package/dist/template/src/core/update/integrity.ts +118 -0
- package/dist/template/src/core/update/keys.ts +29 -0
- package/dist/template/src/core/update/policy.ts +111 -0
- package/dist/template/src/core/update/preflight.ts +258 -0
- package/dist/template/src/core/update/release-declaration.json +19 -0
- package/dist/template/src/core/update/release-validation.d.mts +5 -0
- package/dist/template/src/core/update/release-validation.mjs +29 -0
- package/dist/template/src/core/update/release-version.d.mts +4 -0
- package/dist/template/src/core/update/release-version.mjs +36 -0
- package/dist/template/src/core/update/release.ts +97 -0
- package/dist/template/src/core/update/schema.ts +172 -0
- package/dist/template/src/core/update/seams.ts +70 -0
- package/dist/template/src/core/update/service.ts +1075 -0
- package/dist/template/src/core/update/targets.ts +425 -0
- package/dist/template/src/core/update/this-release.ts +12 -0
- package/dist/template/src/core/update/trusted-release-keys.json +7 -0
- package/dist/template/src/core/views/entities.ts +48 -0
- package/dist/template/src/core/views/registry.ts +121 -0
- package/dist/template/src/core/views/schema.ts +82 -0
- package/dist/template/src/core/views/service.ts +388 -0
- package/dist/template/src/core/webhooks/address.ts +57 -0
- package/dist/template/src/core/webhooks/deliver.ts +255 -0
- package/dist/template/src/core/webhooks/schema.ts +128 -0
- package/dist/template/src/core/webhooks/service.ts +532 -0
- package/dist/template/src/core/webhooks/sign.ts +169 -0
- package/dist/template/src/core/webhooks/transport.ts +180 -0
- package/dist/template/src/mcp/server.ts +372 -0
- package/dist/template/src/mcp/tools.ts +182 -0
- package/dist/template/src/modules/ads/AdBeacon.tsx +76 -0
- package/dist/template/src/modules/ads/ThirdPartyConsent.tsx +45 -0
- package/dist/template/src/modules/ads/ads-txt.ts +60 -0
- package/dist/template/src/modules/ads/blocks.tsx +246 -0
- package/dist/template/src/modules/ads/clicks.ts +162 -0
- package/dist/template/src/modules/ads/jobs.ts +17 -0
- package/dist/template/src/modules/ads/manifest.ts +48 -0
- package/dist/template/src/modules/ads/pacing.ts +47 -0
- package/dist/template/src/modules/ads/schema.ts +360 -0
- package/dist/template/src/modules/ads/select.ts +235 -0
- package/dist/template/src/modules/ads/service.ts +2082 -0
- package/dist/template/src/modules/ads/stats.ts +209 -0
- package/dist/template/src/modules/ads/tables.ts +13 -0
- package/dist/template/src/modules/ads/tags.ts +98 -0
- package/dist/template/src/modules/ads/targeting.ts +0 -0
- package/dist/template/src/modules/ads/viewability.ts +39 -0
- package/dist/template/src/modules/analytics/classify.ts +128 -0
- package/dist/template/src/modules/analytics/experiments.ts +197 -0
- package/dist/template/src/modules/analytics/funnel-service.ts +201 -0
- package/dist/template/src/modules/analytics/funnel.ts +40 -0
- package/dist/template/src/modules/analytics/manifest.ts +37 -0
- package/dist/template/src/modules/analytics/read.ts +17 -0
- package/dist/template/src/modules/analytics/schema.ts +142 -0
- package/dist/template/src/modules/analytics/service.ts +1380 -0
- package/dist/template/src/modules/analytics/settings.ts +44 -0
- package/dist/template/src/modules/analytics/tables.ts +4 -0
- package/dist/template/src/modules/analytics/visitor.ts +91 -0
- package/dist/template/src/modules/assessments/block.tsx +200 -0
- package/dist/template/src/modules/assessments/blocks.ts +11 -0
- package/dist/template/src/modules/assessments/manifest.ts +27 -0
- package/dist/template/src/modules/assessments/onboarding.ts +45 -0
- package/dist/template/src/modules/assessments/questions.ts +134 -0
- package/dist/template/src/modules/assessments/schema.ts +201 -0
- package/dist/template/src/modules/assessments/scoring.ts +99 -0
- package/dist/template/src/modules/assessments/service.ts +1225 -0
- package/dist/template/src/modules/assessments/tables.ts +9 -0
- package/dist/template/src/modules/assistant/actions.ts +191 -0
- package/dist/template/src/modules/assistant/contract.ts +48 -0
- package/dist/template/src/modules/assistant/corpus.ts +137 -0
- package/dist/template/src/modules/assistant/embed.ts +40 -0
- package/dist/template/src/modules/assistant/guardrails.ts +220 -0
- package/dist/template/src/modules/assistant/jobs.ts +17 -0
- package/dist/template/src/modules/assistant/limits.ts +219 -0
- package/dist/template/src/modules/assistant/manifest.ts +43 -0
- package/dist/template/src/modules/assistant/prompt.ts +168 -0
- package/dist/template/src/modules/assistant/provider.ts +100 -0
- package/dist/template/src/modules/assistant/retrieve.ts +67 -0
- package/dist/template/src/modules/assistant/schema.ts +336 -0
- package/dist/template/src/modules/assistant/service.ts +1276 -0
- package/dist/template/src/modules/assistant/tables.ts +11 -0
- package/dist/template/src/modules/assistant/text.ts +42 -0
- package/dist/template/src/modules/automations/engine.ts +350 -0
- package/dist/template/src/modules/automations/graph.ts +325 -0
- package/dist/template/src/modules/automations/guardrail-service.ts +68 -0
- package/dist/template/src/modules/automations/guardrails.ts +211 -0
- package/dist/template/src/modules/automations/manifest.ts +37 -0
- package/dist/template/src/modules/automations/runtime.ts +771 -0
- package/dist/template/src/modules/automations/schema.ts +192 -0
- package/dist/template/src/modules/automations/service.ts +584 -0
- package/dist/template/src/modules/automations/tables.ts +8 -0
- package/dist/template/src/modules/builder/code-delivery.ts +131 -0
- package/dist/template/src/modules/builder/code-gates.ts +374 -0
- package/dist/template/src/modules/builder/code-service.ts +508 -0
- package/dist/template/src/modules/builder/manifest.ts +14 -0
- package/dist/template/src/modules/builder/schema.ts +135 -0
- package/dist/template/src/modules/builder/service.ts +758 -0
- package/dist/template/src/modules/builder/tables.ts +3 -0
- package/dist/template/src/modules/calculators/formula.ts +197 -0
- package/dist/template/src/modules/calculators/manifest.ts +19 -0
- package/dist/template/src/modules/calculators/schema.ts +65 -0
- package/dist/template/src/modules/calculators/service.ts +455 -0
- package/dist/template/src/modules/calculators/tables.ts +4 -0
- package/dist/template/src/modules/catalog/browse.ts +835 -0
- package/dist/template/src/modules/catalog/cart-access.ts +37 -0
- package/dist/template/src/modules/catalog/cart.ts +1066 -0
- package/dist/template/src/modules/catalog/checkout-policy.ts +80 -0
- package/dist/template/src/modules/catalog/collections.ts +856 -0
- package/dist/template/src/modules/catalog/contract.ts +180 -0
- package/dist/template/src/modules/catalog/cookies.ts +14 -0
- package/dist/template/src/modules/catalog/demo.ts +108 -0
- package/dist/template/src/modules/catalog/fulfillment.ts +978 -0
- package/dist/template/src/modules/catalog/funnel.ts +46 -0
- package/dist/template/src/modules/catalog/inventory.ts +900 -0
- package/dist/template/src/modules/catalog/jobs.ts +74 -0
- package/dist/template/src/modules/catalog/manifest.ts +76 -0
- package/dist/template/src/modules/catalog/merchandising.ts +529 -0
- package/dist/template/src/modules/catalog/offerings.ts +735 -0
- package/dist/template/src/modules/catalog/onboarding.ts +33 -0
- package/dist/template/src/modules/catalog/orders.ts +698 -0
- package/dist/template/src/modules/catalog/portal.ts +36 -0
- package/dist/template/src/modules/catalog/price-breaks.ts +144 -0
- package/dist/template/src/modules/catalog/pricing.ts +590 -0
- package/dist/template/src/modules/catalog/procurement.ts +689 -0
- package/dist/template/src/modules/catalog/promo-quote.ts +53 -0
- package/dist/template/src/modules/catalog/promotions.ts +784 -0
- package/dist/template/src/modules/catalog/public-booking.ts +132 -0
- package/dist/template/src/modules/catalog/public-pages.ts +173 -0
- package/dist/template/src/modules/catalog/relations.ts +430 -0
- package/dist/template/src/modules/catalog/reporting.ts +66 -0
- package/dist/template/src/modules/catalog/reward-issuer.ts +73 -0
- package/dist/template/src/modules/catalog/schema.ts +1672 -0
- package/dist/template/src/modules/catalog/segment-fields.ts +52 -0
- package/dist/template/src/modules/catalog/service.ts +1055 -0
- package/dist/template/src/modules/catalog/shipping-quote.ts +205 -0
- package/dist/template/src/modules/catalog/shipping.ts +324 -0
- package/dist/template/src/modules/catalog/storefront.ts +524 -0
- package/dist/template/src/modules/catalog/tables.ts +57 -0
- package/dist/template/src/modules/catalog/tokens.ts +26 -0
- package/dist/template/src/modules/catalog/variants.ts +581 -0
- package/dist/template/src/modules/cms/a11y-hints.ts +258 -0
- package/dist/template/src/modules/cms/blocks/SiteChatClient.tsx +233 -0
- package/dist/template/src/modules/cms/blocks/edit.ts +295 -0
- package/dist/template/src/modules/cms/blocks/fields.ts +208 -0
- package/dist/template/src/modules/cms/blocks/help.tsx +241 -0
- package/dist/template/src/modules/cms/blocks/html.ts +84 -0
- package/dist/template/src/modules/cms/blocks/library.tsx +1226 -0
- package/dist/template/src/modules/cms/blocks/merchandising.tsx +721 -0
- package/dist/template/src/modules/cms/blocks/move.ts +115 -0
- package/dist/template/src/modules/cms/blocks/registry.ts +296 -0
- package/dist/template/src/modules/cms/blocks/rich-render.tsx +44 -0
- package/dist/template/src/modules/cms/blocks/rich.ts +312 -0
- package/dist/template/src/modules/cms/blocks/social.ts +38 -0
- package/dist/template/src/modules/cms/blocks/store-sections.tsx +465 -0
- package/dist/template/src/modules/cms/blocks/surfaces.tsx +1031 -0
- package/dist/template/src/modules/cms/blocks/types.ts +241 -0
- package/dist/template/src/modules/cms/blog.tsx +51 -0
- package/dist/template/src/modules/cms/budgets.ts +52 -0
- package/dist/template/src/modules/cms/cache.ts +49 -0
- package/dist/template/src/modules/cms/chrome-nav.ts +53 -0
- package/dist/template/src/modules/cms/collaboration.ts +433 -0
- package/dist/template/src/modules/cms/defaults.ts +110 -0
- package/dist/template/src/modules/cms/email-render.ts +161 -0
- package/dist/template/src/modules/cms/email-service.ts +112 -0
- package/dist/template/src/modules/cms/experiments.ts +108 -0
- package/dist/template/src/modules/cms/help-service.ts +417 -0
- package/dist/template/src/modules/cms/history.ts +106 -0
- package/dist/template/src/modules/cms/inbound.ts +106 -0
- package/dist/template/src/modules/cms/jobs.ts +28 -0
- package/dist/template/src/modules/cms/layout-service.ts +327 -0
- package/dist/template/src/modules/cms/lifecycle.ts +780 -0
- package/dist/template/src/modules/cms/locations.ts +288 -0
- package/dist/template/src/modules/cms/manifest.ts +76 -0
- package/dist/template/src/modules/cms/onboarding.ts +53 -0
- package/dist/template/src/modules/cms/read.ts +27 -0
- package/dist/template/src/modules/cms/render.tsx +135 -0
- package/dist/template/src/modules/cms/schema.ts +387 -0
- package/dist/template/src/modules/cms/section-instances.ts +96 -0
- package/dist/template/src/modules/cms/section-service.ts +263 -0
- package/dist/template/src/modules/cms/service.ts +1815 -0
- package/dist/template/src/modules/cms/sms-template-service.ts +273 -0
- package/dist/template/src/modules/cms/tables.ts +14 -0
- package/dist/template/src/modules/cms/template-service.ts +374 -0
- package/dist/template/src/modules/cms/templates.ts +320 -0
- package/dist/template/src/modules/cms/translate.ts +212 -0
- package/dist/template/src/modules/cms/translation-workflow.ts +235 -0
- package/dist/template/src/modules/contracts/manifest.ts +27 -0
- package/dist/template/src/modules/contracts/portal.ts +27 -0
- package/dist/template/src/modules/contracts/schema.ts +174 -0
- package/dist/template/src/modules/contracts/service.ts +608 -0
- package/dist/template/src/modules/contracts/tables.ts +3 -0
- package/dist/template/src/modules/contracts/template-service.ts +458 -0
- package/dist/template/src/modules/contracts/templates.ts +83 -0
- package/dist/template/src/modules/crm/manifest.ts +30 -0
- package/dist/template/src/modules/crm/schema.ts +209 -0
- package/dist/template/src/modules/crm/service.ts +918 -0
- package/dist/template/src/modules/crm/tables.ts +3 -0
- package/dist/template/src/modules/documents/manifest.ts +29 -0
- package/dist/template/src/modules/documents/portal.ts +41 -0
- package/dist/template/src/modules/documents/schema.ts +243 -0
- package/dist/template/src/modules/documents/service.ts +879 -0
- package/dist/template/src/modules/documents/tables.ts +9 -0
- package/dist/template/src/modules/documents/tokens.ts +33 -0
- package/dist/template/src/modules/events/blocks.tsx +82 -0
- package/dist/template/src/modules/events/ics.ts +47 -0
- package/dist/template/src/modules/events/manifest.ts +26 -0
- package/dist/template/src/modules/events/onboarding.ts +47 -0
- package/dist/template/src/modules/events/public-pages.ts +140 -0
- package/dist/template/src/modules/events/schema.ts +149 -0
- package/dist/template/src/modules/events/service.ts +907 -0
- package/dist/template/src/modules/events/tables.ts +3 -0
- package/dist/template/src/modules/forms/antispam.ts +163 -0
- package/dist/template/src/modules/forms/block.tsx +275 -0
- package/dist/template/src/modules/forms/blocks.ts +11 -0
- package/dist/template/src/modules/forms/briefing.ts +92 -0
- package/dist/template/src/modules/forms/fieldKey.ts +43 -0
- package/dist/template/src/modules/forms/fields.ts +165 -0
- package/dist/template/src/modules/forms/manifest.ts +46 -0
- package/dist/template/src/modules/forms/onboarding.ts +53 -0
- package/dist/template/src/modules/forms/schema.ts +97 -0
- package/dist/template/src/modules/forms/service.ts +905 -0
- package/dist/template/src/modules/forms/tables.ts +4 -0
- package/dist/template/src/modules/galleries/archive.ts +181 -0
- package/dist/template/src/modules/galleries/cookies.ts +24 -0
- package/dist/template/src/modules/galleries/demo.ts +105 -0
- package/dist/template/src/modules/galleries/jobs.ts +49 -0
- package/dist/template/src/modules/galleries/manifest.ts +33 -0
- package/dist/template/src/modules/galleries/onboarding.ts +33 -0
- package/dist/template/src/modules/galleries/schema.ts +442 -0
- package/dist/template/src/modules/galleries/service.ts +2970 -0
- package/dist/template/src/modules/galleries/tables.ts +13 -0
- package/dist/template/src/modules/galleries/tokens.ts +30 -0
- package/dist/template/src/modules/index.ts +96 -0
- package/dist/template/src/modules/invoicing/advanced-money-service.ts +1071 -0
- package/dist/template/src/modules/invoicing/briefing.ts +73 -0
- package/dist/template/src/modules/invoicing/checkout-requirements.ts +19 -0
- package/dist/template/src/modules/invoicing/contract.ts +541 -0
- package/dist/template/src/modules/invoicing/customer-service.ts +336 -0
- package/dist/template/src/modules/invoicing/customer-tokens.ts +43 -0
- package/dist/template/src/modules/invoicing/demo.ts +114 -0
- package/dist/template/src/modules/invoicing/funnel.ts +67 -0
- package/dist/template/src/modules/invoicing/invoice-service.ts +1467 -0
- package/dist/template/src/modules/invoicing/manifest.ts +58 -0
- package/dist/template/src/modules/invoicing/money.ts +88 -0
- package/dist/template/src/modules/invoicing/onboarding.ts +33 -0
- package/dist/template/src/modules/invoicing/payment-plan-ledger.ts +115 -0
- package/dist/template/src/modules/invoicing/payment-provider-service.ts +873 -0
- package/dist/template/src/modules/invoicing/payment-webhook-route.ts +53 -0
- package/dist/template/src/modules/invoicing/portal.ts +29 -0
- package/dist/template/src/modules/invoicing/pos-service.ts +275 -0
- package/dist/template/src/modules/invoicing/recurring-schema.ts +125 -0
- package/dist/template/src/modules/invoicing/recurring-service.ts +608 -0
- package/dist/template/src/modules/invoicing/reporting.ts +39 -0
- package/dist/template/src/modules/invoicing/schema.ts +862 -0
- package/dist/template/src/modules/invoicing/service.ts +37 -0
- package/dist/template/src/modules/invoicing/tables.ts +33 -0
- package/dist/template/src/modules/invoicing/tax-engine.ts +214 -0
- package/dist/template/src/modules/invoicing/tax-service.ts +716 -0
- package/dist/template/src/modules/invoicing/tax-templates.ts +316 -0
- package/dist/template/src/modules/local-plugins.ts +15 -0
- package/dist/template/src/modules/loyalty/jobs.ts +224 -0
- package/dist/template/src/modules/loyalty/manifest.ts +58 -0
- package/dist/template/src/modules/loyalty/rewards-service.ts +607 -0
- package/dist/template/src/modules/loyalty/schema.ts +333 -0
- package/dist/template/src/modules/loyalty/service.ts +922 -0
- package/dist/template/src/modules/loyalty/spine.ts +97 -0
- package/dist/template/src/modules/loyalty/tables.ts +12 -0
- package/dist/template/src/modules/newsletters/blocks.tsx +128 -0
- package/dist/template/src/modules/newsletters/broadcast-schema.ts +166 -0
- package/dist/template/src/modules/newsletters/broadcast-service.ts +806 -0
- package/dist/template/src/modules/newsletters/jobs.ts +29 -0
- package/dist/template/src/modules/newsletters/manifest.ts +39 -0
- package/dist/template/src/modules/newsletters/public-pages.ts +128 -0
- package/dist/template/src/modules/newsletters/schema.ts +134 -0
- package/dist/template/src/modules/newsletters/service.ts +708 -0
- package/dist/template/src/modules/newsletters/tables.ts +9 -0
- package/dist/template/src/modules/newsletters/template-schema.ts +92 -0
- package/dist/template/src/modules/newsletters/template-service.ts +368 -0
- package/dist/template/src/modules/popups/PopupSurface.tsx +401 -0
- package/dist/template/src/modules/popups/http.ts +26 -0
- package/dist/template/src/modules/popups/manifest.ts +42 -0
- package/dist/template/src/modules/popups/mount.tsx +89 -0
- package/dist/template/src/modules/popups/schema.ts +252 -0
- package/dist/template/src/modules/popups/service.ts +948 -0
- package/dist/template/src/modules/popups/tables.ts +4 -0
- package/dist/template/src/modules/popups/tally.ts +194 -0
- package/dist/template/src/modules/popups/targeting.ts +206 -0
- package/dist/template/src/modules/projects/blocks.tsx +444 -0
- package/dist/template/src/modules/projects/consent-gate.ts +104 -0
- package/dist/template/src/modules/projects/jobs.ts +24 -0
- package/dist/template/src/modules/projects/manifest.ts +33 -0
- package/dist/template/src/modules/projects/portal.ts +32 -0
- package/dist/template/src/modules/projects/portfolio-service.ts +712 -0
- package/dist/template/src/modules/projects/publishing-service.ts +782 -0
- package/dist/template/src/modules/projects/schema.ts +437 -0
- package/dist/template/src/modules/projects/service.ts +1055 -0
- package/dist/template/src/modules/projects/tables.ts +12 -0
- package/dist/template/src/modules/projects/time-schema.ts +166 -0
- package/dist/template/src/modules/projects/time-service.ts +631 -0
- package/dist/template/src/modules/proof/blocks.tsx +34 -0
- package/dist/template/src/modules/proof/manifest.ts +24 -0
- package/dist/template/src/modules/proof/schema.ts +21 -0
- package/dist/template/src/modules/proof/seed.ts +11 -0
- package/dist/template/src/modules/proof/service.ts +74 -0
- package/dist/template/src/modules/proof/tables.ts +3 -0
- package/dist/template/src/modules/quotes/conversion.ts +425 -0
- package/dist/template/src/modules/quotes/cookies.ts +9 -0
- package/dist/template/src/modules/quotes/demo.ts +99 -0
- package/dist/template/src/modules/quotes/funnel.ts +44 -0
- package/dist/template/src/modules/quotes/manifest.ts +34 -0
- package/dist/template/src/modules/quotes/onboarding.ts +33 -0
- package/dist/template/src/modules/quotes/portal.ts +46 -0
- package/dist/template/src/modules/quotes/schema.ts +250 -0
- package/dist/template/src/modules/quotes/service.ts +1554 -0
- package/dist/template/src/modules/quotes/tables.ts +9 -0
- package/dist/template/src/modules/quotes/tokens.ts +28 -0
- package/dist/template/src/modules/quotes/view-entity.ts +20 -0
- package/dist/template/src/modules/referrals/attribution-service.ts +134 -0
- package/dist/template/src/modules/referrals/attribution.ts +99 -0
- package/dist/template/src/modules/referrals/commission-service.ts +1114 -0
- package/dist/template/src/modules/referrals/commission.ts +150 -0
- package/dist/template/src/modules/referrals/jobs.ts +32 -0
- package/dist/template/src/modules/referrals/manifest.ts +53 -0
- package/dist/template/src/modules/referrals/portal.ts +37 -0
- package/dist/template/src/modules/referrals/schema.ts +421 -0
- package/dist/template/src/modules/referrals/service.ts +619 -0
- package/dist/template/src/modules/referrals/spine.ts +92 -0
- package/dist/template/src/modules/referrals/tables.ts +13 -0
- package/dist/template/src/modules/referrals/tokens.ts +28 -0
- package/dist/template/src/modules/rentals/manifest.ts +26 -0
- package/dist/template/src/modules/rentals/portal.ts +34 -0
- package/dist/template/src/modules/rentals/pricing.ts +150 -0
- package/dist/template/src/modules/rentals/schema.ts +210 -0
- package/dist/template/src/modules/rentals/service.ts +759 -0
- package/dist/template/src/modules/rentals/tables.ts +3 -0
- package/dist/template/src/modules/reporting/demo.ts +88 -0
- package/dist/template/src/modules/reporting/export-schema.ts +319 -0
- package/dist/template/src/modules/reporting/export-service.ts +1224 -0
- package/dist/template/src/modules/reporting/export-shapes.ts +429 -0
- package/dist/template/src/modules/reporting/export-tokens.ts +23 -0
- package/dist/template/src/modules/reporting/jobs.ts +117 -0
- package/dist/template/src/modules/reporting/manifest.ts +34 -0
- package/dist/template/src/modules/reporting/onboarding.ts +33 -0
- package/dist/template/src/modules/reporting/schema.ts +48 -0
- package/dist/template/src/modules/reporting/service.ts +540 -0
- package/dist/template/src/modules/reporting/tables.ts +4 -0
- package/dist/template/src/modules/reviews/blocks.tsx +97 -0
- package/dist/template/src/modules/reviews/manifest.ts +26 -0
- package/dist/template/src/modules/reviews/schema.ts +182 -0
- package/dist/template/src/modules/reviews/service.ts +663 -0
- package/dist/template/src/modules/reviews/tables.ts +3 -0
- package/dist/template/src/modules/reviews/tokens.ts +22 -0
- package/dist/template/src/modules/seed/boot.ts +94 -0
- package/dist/template/src/modules/seed/manifest.ts +24 -0
- package/dist/template/src/modules/seed/onboarding.ts +276 -0
- package/dist/template/src/modules/seed/preset-install.ts +181 -0
- package/dist/template/src/modules/seed/service.ts +260 -0
- package/dist/template/src/modules/share/embeds.ts +54 -0
- package/dist/template/src/modules/share/intents.ts +126 -0
- package/dist/template/src/modules/share/links.ts +164 -0
- package/dist/template/src/modules/share/manifest.ts +34 -0
- package/dist/template/src/modules/share/schema.ts +130 -0
- package/dist/template/src/modules/share/service.ts +697 -0
- package/dist/template/src/modules/share/tables.ts +4 -0
- package/dist/template/src/modules/social/capabilities.ts +71 -0
- package/dist/template/src/modules/social/compose.ts +825 -0
- package/dist/template/src/modules/social/contract.ts +59 -0
- package/dist/template/src/modules/social/gbp.ts +570 -0
- package/dist/template/src/modules/social/ingest.ts +727 -0
- package/dist/template/src/modules/social/jobs.ts +125 -0
- package/dist/template/src/modules/social/manifest.ts +34 -0
- package/dist/template/src/modules/social/oauth.ts +300 -0
- package/dist/template/src/modules/social/onboarding.ts +45 -0
- package/dist/template/src/modules/social/policy.ts +48 -0
- package/dist/template/src/modules/social/render.ts +135 -0
- package/dist/template/src/modules/social/schema.ts +322 -0
- package/dist/template/src/modules/social/service.ts +660 -0
- package/dist/template/src/modules/social/tables.ts +13 -0
- package/dist/template/src/modules/subscriptions/billing.ts +1042 -0
- package/dist/template/src/modules/subscriptions/jobs.ts +52 -0
- package/dist/template/src/modules/subscriptions/manifest.ts +34 -0
- package/dist/template/src/modules/subscriptions/portal.ts +34 -0
- package/dist/template/src/modules/subscriptions/public-signup.ts +124 -0
- package/dist/template/src/modules/subscriptions/schema.ts +294 -0
- package/dist/template/src/modules/subscriptions/service.ts +1659 -0
- package/dist/template/src/modules/subscriptions/tables.ts +3 -0
- package/dist/template/src/ui/GuidancePanel.tsx +200 -0
- package/dist/template/src/ui/ShareCopyButton.tsx +28 -0
- package/dist/template/src/ui/SkipLink.tsx +21 -0
- package/dist/template/src/ui/ThemeToggle.tsx +79 -0
- package/dist/template/src/ui/primitives.tsx +269 -0
- package/dist/template/tests/README.md +5 -0
- package/dist/template/tests/adapters/social-conformance.test.ts +71 -0
- package/dist/template/tests/browser/accessibility.spec.ts +793 -0
- package/dist/template/tests/browser/agent-launch.spec.ts +110 -0
- package/dist/template/tests/browser/assessments.spec.ts +188 -0
- package/dist/template/tests/browser/c11-01-visitor-to-paid.spec.ts +281 -0
- package/dist/template/tests/browser/c11-04-capture.spec.ts +80 -0
- package/dist/template/tests/browser/calculators.spec.ts +196 -0
- package/dist/template/tests/browser/cart-access.spec.ts +42 -0
- package/dist/template/tests/browser/customer-surfaces.spec.ts +115 -0
- package/dist/template/tests/browser/database.ts +60 -0
- package/dist/template/tests/browser/demo-scenarios.spec.ts +117 -0
- package/dist/template/tests/browser/editor-drag-drop.spec.ts +259 -0
- package/dist/template/tests/browser/editor-inline-editing.spec.ts +186 -0
- package/dist/template/tests/browser/editor-media-tools.spec.ts +231 -0
- package/dist/template/tests/browser/editor-store-sections.spec.ts +391 -0
- package/dist/template/tests/browser/events.spec.ts +195 -0
- package/dist/template/tests/browser/facts.spec.ts +140 -0
- package/dist/template/tests/browser/first-party-plugins.spec.ts +161 -0
- package/dist/template/tests/browser/guidance.spec.ts +148 -0
- package/dist/template/tests/browser/journeys.spec.ts +662 -0
- package/dist/template/tests/browser/location-access.spec.ts +59 -0
- package/dist/template/tests/browser/media-consent.spec.ts +93 -0
- package/dist/template/tests/browser/owner-session.ts +53 -0
- package/dist/template/tests/browser/playground.spec.ts +151 -0
- package/dist/template/tests/browser/provider-erasure.spec.ts +50 -0
- package/dist/template/tests/browser/record-search.spec.ts +107 -0
- package/dist/template/tests/browser/record-trash.spec.ts +127 -0
- package/dist/template/tests/browser/storefront-checkout.spec.ts +272 -0
- package/dist/template/tests/browser/storefront-merch-blocks.spec.ts +319 -0
- package/dist/template/tests/browser/workflow-search.spec.ts +53 -0
- package/dist/template/tests/core/a11y-smoke.test.ts +92 -0
- package/dist/template/tests/core/admin-journey-screens.test.ts +143 -0
- package/dist/template/tests/core/advanced-money.test.ts +232 -0
- package/dist/template/tests/core/adversarial-gallery-privacy.test.ts +185 -0
- package/dist/template/tests/core/adversarial-portal-privacy.test.ts +93 -0
- package/dist/template/tests/core/agent-launch.test.ts +74 -0
- package/dist/template/tests/core/agents-approvals.test.ts +168 -0
- package/dist/template/tests/core/agents-autonomy.test.ts +364 -0
- package/dist/template/tests/core/agents-board.test.ts +111 -0
- package/dist/template/tests/core/agents-budgets.test.ts +329 -0
- package/dist/template/tests/core/agents-inbound.test.ts +535 -0
- package/dist/template/tests/core/agents-injection.test.ts +351 -0
- package/dist/template/tests/core/agents-managed-loop.test.ts +261 -0
- package/dist/template/tests/core/agents-pause.test.ts +183 -0
- package/dist/template/tests/core/agents-playbooks.test.ts +285 -0
- package/dist/template/tests/core/agents-run.test.ts +119 -0
- package/dist/template/tests/core/agents-schedule.test.ts +231 -0
- package/dist/template/tests/core/agents-workforce-adapter.test.ts +359 -0
- package/dist/template/tests/core/agents.test.ts +436 -0
- package/dist/template/tests/core/alt-text-adapter.test.ts +97 -0
- package/dist/template/tests/core/analytics-consent.test.ts +272 -0
- package/dist/template/tests/core/analytics-experiments.test.ts +63 -0
- package/dist/template/tests/core/analytics-governance-migration.test.ts +28 -0
- package/dist/template/tests/core/analytics.test.ts +660 -0
- package/dist/template/tests/core/api.test.ts +338 -0
- package/dist/template/tests/core/apikeys.test.ts +366 -0
- package/dist/template/tests/core/attestations.test.ts +311 -0
- package/dist/template/tests/core/audit-labels.test.ts +37 -0
- package/dist/template/tests/core/autofill-safety.test.ts +279 -0
- package/dist/template/tests/core/availability.test.ts +389 -0
- package/dist/template/tests/core/booking-audiences.test.ts +334 -0
- package/dist/template/tests/core/booking-concurrency.test.ts +288 -0
- package/dist/template/tests/core/bookings.test.ts +343 -0
- package/dist/template/tests/core/boot.test.ts +195 -0
- package/dist/template/tests/core/bootstrap-security.test.ts +38 -0
- package/dist/template/tests/core/briefing-contributors.test.ts +200 -0
- package/dist/template/tests/core/briefing-playbooks.test.ts +171 -0
- package/dist/template/tests/core/briefing.test.ts +298 -0
- package/dist/template/tests/core/browse-storefront.test.ts +561 -0
- package/dist/template/tests/core/builder-authority.test.ts +205 -0
- package/dist/template/tests/core/builder-code-lane.test.ts +213 -0
- package/dist/template/tests/core/builder-content-lane.test.ts +249 -0
- package/dist/template/tests/core/c11-02-catalog-journey.test.ts +227 -0
- package/dist/template/tests/core/c11-03-booking-journey.test.ts +422 -0
- package/dist/template/tests/core/c11-04-gallery-social-journey.test.ts +310 -0
- package/dist/template/tests/core/c11-05-subscription-journey.test.ts +193 -0
- package/dist/template/tests/core/c11-06-agent-journey.test.ts +208 -0
- package/dist/template/tests/core/c11-07-mail-calendar-journey.test.ts +179 -0
- package/dist/template/tests/core/c11-08-install-update-journey.test.ts +166 -0
- package/dist/template/tests/core/c11-13-failure-drills.test.ts +446 -0
- package/dist/template/tests/core/c11-14-retention.test.ts +320 -0
- package/dist/template/tests/core/c11-14-search.test.ts +527 -0
- package/dist/template/tests/core/calendar-busy.test.ts +198 -0
- package/dist/template/tests/core/calendar-oauth-callback.test.ts +154 -0
- package/dist/template/tests/core/calendar-oauth.test.ts +312 -0
- package/dist/template/tests/core/calendar-sync.test.ts +363 -0
- package/dist/template/tests/core/calendars.test.ts +267 -0
- package/dist/template/tests/core/cart-access.test.ts +107 -0
- package/dist/template/tests/core/cart-storefront.test.ts +507 -0
- package/dist/template/tests/core/catalog-browse.test.ts +587 -0
- package/dist/template/tests/core/catalog-carts.test.ts +150 -0
- package/dist/template/tests/core/catalog-collections.test.ts +454 -0
- package/dist/template/tests/core/catalog-fulfillment.test.ts +191 -0
- package/dist/template/tests/core/catalog-inventory.test.ts +198 -0
- package/dist/template/tests/core/catalog-merchandising.test.ts +107 -0
- package/dist/template/tests/core/catalog-offerings.test.ts +213 -0
- package/dist/template/tests/core/catalog-orders.test.ts +279 -0
- package/dist/template/tests/core/catalog-pricing.test.ts +85 -0
- package/dist/template/tests/core/catalog-procurement.test.ts +154 -0
- package/dist/template/tests/core/catalog-promotions.test.ts +109 -0
- package/dist/template/tests/core/catalog-public-pages.test.ts +73 -0
- package/dist/template/tests/core/catalog-relations.test.ts +79 -0
- package/dist/template/tests/core/catalog-variants.test.ts +113 -0
- package/dist/template/tests/core/catalog.test.ts +233 -0
- package/dist/template/tests/core/catalogue.test.ts +300 -0
- package/dist/template/tests/core/change-password.test.ts +164 -0
- package/dist/template/tests/core/changelog-output.test.ts +33 -0
- package/dist/template/tests/core/checkout-policy.test.ts +34 -0
- package/dist/template/tests/core/client-galleries.test.ts +609 -0
- package/dist/template/tests/core/client-readiness-security.test.ts +136 -0
- package/dist/template/tests/core/cms-a11y.test.ts +157 -0
- package/dist/template/tests/core/cms-blocks.test.ts +283 -0
- package/dist/template/tests/core/cms-cache.test.ts +121 -0
- package/dist/template/tests/core/cms-chrome.test.ts +114 -0
- package/dist/template/tests/core/cms-collaboration.test.ts +196 -0
- package/dist/template/tests/core/cms-drafts.test.ts +78 -0
- package/dist/template/tests/core/cms-email.test.ts +71 -0
- package/dist/template/tests/core/cms-experiments.test.ts +109 -0
- package/dist/template/tests/core/cms-fields.test.ts +137 -0
- package/dist/template/tests/core/cms-history.test.ts +34 -0
- package/dist/template/tests/core/cms-layouts.test.ts +110 -0
- package/dist/template/tests/core/cms-lifecycle.test.ts +267 -0
- package/dist/template/tests/core/cms-move.test.ts +101 -0
- package/dist/template/tests/core/cms-plugin-proof.test.ts +56 -0
- package/dist/template/tests/core/cms-public-boundary.test.ts +85 -0
- package/dist/template/tests/core/cms-rich.test.ts +144 -0
- package/dist/template/tests/core/cms-sections.test.ts +139 -0
- package/dist/template/tests/core/cms-service.test.ts +358 -0
- package/dist/template/tests/core/cms-surfaces.test.ts +117 -0
- package/dist/template/tests/core/cms-templates.test.ts +115 -0
- package/dist/template/tests/core/cms-translation-workflow.test.ts +88 -0
- package/dist/template/tests/core/collections-storefront.test.ts +328 -0
- package/dist/template/tests/core/colour-literals.test.ts +73 -0
- package/dist/template/tests/core/community-rooms.test.ts +324 -0
- package/dist/template/tests/core/connection-grants.test.ts +209 -0
- package/dist/template/tests/core/connections.test.ts +435 -0
- package/dist/template/tests/core/consent-publish-surfaces.test.ts +577 -0
- package/dist/template/tests/core/contact-data-depth.test.ts +426 -0
- package/dist/template/tests/core/contact-duplicate-review.test.ts +357 -0
- package/dist/template/tests/core/contact-import.test.ts +404 -0
- package/dist/template/tests/core/contact-privacy-rights.test.ts +636 -0
- package/dist/template/tests/core/contacts-read.test.ts +165 -0
- package/dist/template/tests/core/contract-evidence.test.ts +43 -0
- package/dist/template/tests/core/contract-projections.test.ts +47 -0
- package/dist/template/tests/core/contract-templates.test.ts +270 -0
- package/dist/template/tests/core/contribute.test.ts +497 -0
- package/dist/template/tests/core/conversations.test.ts +381 -0
- package/dist/template/tests/core/coverage-enforcement.test.ts +296 -0
- package/dist/template/tests/core/coverage.test.ts +308 -0
- package/dist/template/tests/core/create-freeholder.test.ts +307 -0
- package/dist/template/tests/core/csp-migration.test.ts +30 -0
- package/dist/template/tests/core/csp-reports.test.ts +150 -0
- package/dist/template/tests/core/csp.test.ts +194 -0
- package/dist/template/tests/core/csrf.test.ts +139 -0
- package/dist/template/tests/core/customer-galleries.test.ts +137 -0
- package/dist/template/tests/core/customer-invoices.test.ts +235 -0
- package/dist/template/tests/core/customer-locale-migration.test.ts +40 -0
- package/dist/template/tests/core/customer-locale-ui.test.ts +39 -0
- package/dist/template/tests/core/customer-locale.test.ts +85 -0
- package/dist/template/tests/core/customer-magic-links.test.ts +281 -0
- package/dist/template/tests/core/customer-reply.test.ts +155 -0
- package/dist/template/tests/core/customer-return-path.test.ts +11 -0
- package/dist/template/tests/core/daily-adapter.test.ts +185 -0
- package/dist/template/tests/core/daily-flow.test.ts +94 -0
- package/dist/template/tests/core/daily-import.test.ts +206 -0
- package/dist/template/tests/core/dashboard.test.ts +147 -0
- package/dist/template/tests/core/db-errors.test.ts +52 -0
- package/dist/template/tests/core/deferred-erasure.test.ts +124 -0
- package/dist/template/tests/core/demo-migration.test.ts +39 -0
- package/dist/template/tests/core/demo-paths.test.ts +49 -0
- package/dist/template/tests/core/demo-scenarios.test.ts +200 -0
- package/dist/template/tests/core/dependency-attestation.test.ts +84 -0
- package/dist/template/tests/core/dependency-audit.test.ts +124 -0
- package/dist/template/tests/core/deploy-droplet.test.ts +323 -0
- package/dist/template/tests/core/deploy-recipe.test.ts +134 -0
- package/dist/template/tests/core/design-tokens.test.ts +113 -0
- package/dist/template/tests/core/doc-claim-mapping.test.ts +167 -0
- package/dist/template/tests/core/docs-availability.test.ts +94 -0
- package/dist/template/tests/core/doctor-script.test.ts +16 -0
- package/dist/template/tests/core/doctor.test.ts +220 -0
- package/dist/template/tests/core/edge-adapters.test.ts +220 -0
- package/dist/template/tests/core/editor-canvas-drag.test.ts +348 -0
- package/dist/template/tests/core/editor-inline-edit.test.ts +416 -0
- package/dist/template/tests/core/editor-media-tools.test.ts +450 -0
- package/dist/template/tests/core/editor-preview-bridge.test.ts +428 -0
- package/dist/template/tests/core/editor-preview-draft.test.ts +226 -0
- package/dist/template/tests/core/editor-reorder.test.ts +339 -0
- package/dist/template/tests/core/editor-store-sections.test.ts +476 -0
- package/dist/template/tests/core/embeds.test.ts +60 -0
- package/dist/template/tests/core/entitlements.test.ts +312 -0
- package/dist/template/tests/core/events.test.ts +113 -0
- package/dist/template/tests/core/f-matrix.test.ts +206 -0
- package/dist/template/tests/core/f04-remaining-screens.test.ts +258 -0
- package/dist/template/tests/core/first-party-plugins.test.ts +783 -0
- package/dist/template/tests/core/forms.test.ts +446 -0
- package/dist/template/tests/core/freeholder-app-init.test.ts +504 -0
- package/dist/template/tests/core/gallery-archive.test.ts +265 -0
- package/dist/template/tests/core/gallery-delivery-routes.test.ts +72 -0
- package/dist/template/tests/core/gallery-partner-share.test.ts +320 -0
- package/dist/template/tests/core/gallery-proofing.test.ts +311 -0
- package/dist/template/tests/core/gallery-rounds.test.ts +291 -0
- package/dist/template/tests/core/gallery-sales.test.ts +309 -0
- package/dist/template/tests/core/guidance-definitions.test.ts +135 -0
- package/dist/template/tests/core/guidance-ui.test.ts +92 -0
- package/dist/template/tests/core/guidance.test.ts +309 -0
- package/dist/template/tests/core/host-update-socket.test.ts +121 -0
- package/dist/template/tests/core/host-updater-recipe.test.ts +68 -0
- package/dist/template/tests/core/http-auth.test.ts +286 -0
- package/dist/template/tests/core/http-body-boundary.test.ts +69 -0
- package/dist/template/tests/core/http.test.ts +284 -0
- package/dist/template/tests/core/i18n-gate.test.ts +440 -0
- package/dist/template/tests/core/i18n.test.ts +190 -0
- package/dist/template/tests/core/ics-and-writeback.test.ts +446 -0
- package/dist/template/tests/core/importers.test.ts +102 -0
- package/dist/template/tests/core/inbox.test.ts +304 -0
- package/dist/template/tests/core/inline-script-safety.test.ts +41 -0
- package/dist/template/tests/core/instrumentation-boundary.test.ts +16 -0
- package/dist/template/tests/core/intake-waivers-reminders.test.ts +533 -0
- package/dist/template/tests/core/internal-services.test.ts +298 -0
- package/dist/template/tests/core/invitations.test.ts +341 -0
- package/dist/template/tests/core/invoice-admin.test.ts +41 -0
- package/dist/template/tests/core/invoicing-pos.test.ts +107 -0
- package/dist/template/tests/core/invoicing.test.ts +776 -0
- package/dist/template/tests/core/job-runtime-health.test.ts +123 -0
- package/dist/template/tests/core/locale-quality.test.ts +107 -0
- package/dist/template/tests/core/locale-routing.test.ts +321 -0
- package/dist/template/tests/core/locations.test.ts +599 -0
- package/dist/template/tests/core/long-running-service-boundary.test.ts +216 -0
- package/dist/template/tests/core/mail-adapters.test.ts +423 -0
- package/dist/template/tests/core/mail-import.test.ts +325 -0
- package/dist/template/tests/core/mail-migration.test.ts +163 -0
- package/dist/template/tests/core/mail-oauth-callback.test.ts +159 -0
- package/dist/template/tests/core/mail-oauth.test.ts +447 -0
- package/dist/template/tests/core/mail-outbox-crypto.test.ts +88 -0
- package/dist/template/tests/core/mail-read-oauth-callback.test.ts +111 -0
- package/dist/template/tests/core/mail-service.test.ts +644 -0
- package/dist/template/tests/core/mail-ui.test.ts +206 -0
- package/dist/template/tests/core/mail-webhooks.test.ts +454 -0
- package/dist/template/tests/core/malware.test.ts +85 -0
- package/dist/template/tests/core/marketplace-claims.test.ts +68 -0
- package/dist/template/tests/core/mcp-input-schema.test.ts +18 -0
- package/dist/template/tests/core/mcp.test.ts +459 -0
- package/dist/template/tests/core/media-capture.test.ts +345 -0
- package/dist/template/tests/core/media-consent.test.ts +357 -0
- package/dist/template/tests/core/media-framing.test.ts +210 -0
- package/dist/template/tests/core/media-transfer.test.ts +48 -0
- package/dist/template/tests/core/media-watermark.test.ts +308 -0
- package/dist/template/tests/core/media.test.ts +1446 -0
- package/dist/template/tests/core/merch-blocks.test.ts +465 -0
- package/dist/template/tests/core/merge-completeness.test.ts +228 -0
- package/dist/template/tests/core/migrate.test.ts +75 -0
- package/dist/template/tests/core/migration-journal.test.ts +59 -0
- package/dist/template/tests/core/mobile-app-shell.test.ts +238 -0
- package/dist/template/tests/core/mobile-app.test.ts +728 -0
- package/dist/template/tests/core/mobile-capture-batches.test.ts +223 -0
- package/dist/template/tests/core/mobile-private-cache.test.ts +339 -0
- package/dist/template/tests/core/mobile-screens.test.ts +362 -0
- package/dist/template/tests/core/mobile-store-gate.test.ts +310 -0
- package/dist/template/tests/core/module.test.ts +60 -0
- package/dist/template/tests/core/money-arithmetic.test.ts +279 -0
- package/dist/template/tests/core/newsletters.test.ts +178 -0
- package/dist/template/tests/core/notes.test.ts +338 -0
- package/dist/template/tests/core/notification-migration.test.ts +174 -0
- package/dist/template/tests/core/notification-ui.test.ts +97 -0
- package/dist/template/tests/core/notifications.test.ts +510 -0
- package/dist/template/tests/core/onboarding-contract.test.ts +133 -0
- package/dist/template/tests/core/outbound-boundaries.test.ts +29 -0
- package/dist/template/tests/core/outbox.test.ts +407 -0
- package/dist/template/tests/core/owner-password-script.test.ts +106 -0
- package/dist/template/tests/core/ownership-export.test.ts +273 -0
- package/dist/template/tests/core/page-editor-publish.test.ts +94 -0
- package/dist/template/tests/core/paradise-adapter.test.ts +177 -0
- package/dist/template/tests/core/paradise-flow.test.ts +350 -0
- package/dist/template/tests/core/paradise-webhook.test.ts +148 -0
- package/dist/template/tests/core/password-reset.test.ts +289 -0
- package/dist/template/tests/core/passwords.test.ts +57 -0
- package/dist/template/tests/core/payment-adapters.test.ts +604 -0
- package/dist/template/tests/core/payment-provider-service.test.ts +226 -0
- package/dist/template/tests/core/paywalls.test.ts +358 -0
- package/dist/template/tests/core/performance-budgets.test.ts +332 -0
- package/dist/template/tests/core/performance-measurement-families.test.ts +296 -0
- package/dist/template/tests/core/pipelines.test.ts +382 -0
- package/dist/template/tests/core/plan-gate.test.ts +251 -0
- package/dist/template/tests/core/playground.test.ts +412 -0
- package/dist/template/tests/core/plugin-claims.test.ts +41 -0
- package/dist/template/tests/core/plugin-contract.test.ts +149 -0
- package/dist/template/tests/core/plugin-provider-boundary.test.ts +35 -0
- package/dist/template/tests/core/plugin-scaffold.test.ts +27 -0
- package/dist/template/tests/core/plugins-lifecycle.test.ts +196 -0
- package/dist/template/tests/core/portability.test.ts +58 -0
- package/dist/template/tests/core/portal-rooms.test.ts +280 -0
- package/dist/template/tests/core/portal-shell.test.ts +116 -0
- package/dist/template/tests/core/pos-adapters.test.ts +78 -0
- package/dist/template/tests/core/price-breaks.test.ts +63 -0
- package/dist/template/tests/core/printify-adapter.test.ts +85 -0
- package/dist/template/tests/core/printify-fulfillment.test.ts +149 -0
- package/dist/template/tests/core/product-gift-share.test.ts +116 -0
- package/dist/template/tests/core/project-case-studies.test.ts +277 -0
- package/dist/template/tests/core/project-portfolios.test.ts +197 -0
- package/dist/template/tests/core/projects.test.ts +292 -0
- package/dist/template/tests/core/promo-quote.test.ts +51 -0
- package/dist/template/tests/core/proxy-locale.test.ts +55 -0
- package/dist/template/tests/core/public-entity-drafts.test.ts +166 -0
- package/dist/template/tests/core/push-devices.test.ts +147 -0
- package/dist/template/tests/core/quote-conversion.test.ts +291 -0
- package/dist/template/tests/core/quote-partner-share.test.ts +192 -0
- package/dist/template/tests/core/quotes.test.ts +357 -0
- package/dist/template/tests/core/rate-limit.test.ts +216 -0
- package/dist/template/tests/core/recipes.test.ts +212 -0
- package/dist/template/tests/core/record-participation.test.ts +121 -0
- package/dist/template/tests/core/record-trash-families.test.ts +321 -0
- package/dist/template/tests/core/record-trash.test.ts +154 -0
- package/dist/template/tests/core/recurring-invoices.test.ts +284 -0
- package/dist/template/tests/core/registry-completeness.test.ts +143 -0
- package/dist/template/tests/core/release-history.test.ts +47 -0
- package/dist/template/tests/core/release-packages.test.ts +35 -0
- package/dist/template/tests/core/release-publication.test.ts +69 -0
- package/dist/template/tests/core/rentals.test.ts +408 -0
- package/dist/template/tests/core/resolver.test.ts +481 -0
- package/dist/template/tests/core/reviews.test.ts +229 -0
- package/dist/template/tests/core/roles.test.ts +199 -0
- package/dist/template/tests/core/route-boot.test.ts +64 -0
- package/dist/template/tests/core/runtime-balanced-sequencer.test.ts +117 -0
- package/dist/template/tests/core/runtime-shutdown.test.ts +58 -0
- package/dist/template/tests/core/runtime-version-integrity.test.ts +43 -0
- package/dist/template/tests/core/saved-views.test.ts +271 -0
- package/dist/template/tests/core/schema-baseline-identity.test.ts +70 -0
- package/dist/template/tests/core/schema-compat-gate.test.ts +172 -0
- package/dist/template/tests/core/scoring.test.ts +364 -0
- package/dist/template/tests/core/sdk-generation.test.ts +55 -0
- package/dist/template/tests/core/sdk-schema.test.ts +106 -0
- package/dist/template/tests/core/sdk.test.ts +181 -0
- package/dist/template/tests/core/security-headers.test.ts +41 -0
- package/dist/template/tests/core/seed-demo.test.ts +355 -0
- package/dist/template/tests/core/segments.test.ts +528 -0
- package/dist/template/tests/core/seo-gate.test.ts +193 -0
- package/dist/template/tests/core/seo-public-entities.test.ts +105 -0
- package/dist/template/tests/core/seo-surface.test.ts +279 -0
- package/dist/template/tests/core/seo.test.ts +277 -0
- package/dist/template/tests/core/service-composition.test.ts +248 -0
- package/dist/template/tests/core/service-output.test.ts +48 -0
- package/dist/template/tests/core/service.test.ts +394 -0
- package/dist/template/tests/core/session-management.test.ts +223 -0
- package/dist/template/tests/core/settings.test.ts +421 -0
- package/dist/template/tests/core/shipping-quote.test.ts +105 -0
- package/dist/template/tests/core/shopify-adapter.test.ts +121 -0
- package/dist/template/tests/core/shopify-refunds.test.ts +177 -0
- package/dist/template/tests/core/shopify-sync.test.ts +62 -0
- package/dist/template/tests/core/signup-contact-import.test.ts +383 -0
- package/dist/template/tests/core/site-chat.test.ts +250 -0
- package/dist/template/tests/core/sms-consent.test.ts +295 -0
- package/dist/template/tests/core/sms-keywords.test.ts +139 -0
- package/dist/template/tests/core/sms-policy.test.ts +348 -0
- package/dist/template/tests/core/sms-registration.test.ts +304 -0
- package/dist/template/tests/core/sms-templates.test.ts +61 -0
- package/dist/template/tests/core/sms.test.ts +563 -0
- package/dist/template/tests/core/social-http.test.ts +91 -0
- package/dist/template/tests/core/spec-reconciliation.test.ts +62 -0
- package/dist/template/tests/core/spine.test.ts +682 -0
- package/dist/template/tests/core/standalone-artifact.test.ts +40 -0
- package/dist/template/tests/core/storage.test.ts +360 -0
- package/dist/template/tests/core/store-sections.test.ts +466 -0
- package/dist/template/tests/core/storefront-commerce.test.ts +431 -0
- package/dist/template/tests/core/tasks.test.ts +356 -0
- package/dist/template/tests/core/tax-templates.test.ts +129 -0
- package/dist/template/tests/core/templates.test.ts +148 -0
- package/dist/template/tests/core/theme.test.ts +64 -0
- package/dist/template/tests/core/time-entries.test.ts +343 -0
- package/dist/template/tests/core/tokens.test.ts +167 -0
- package/dist/template/tests/core/transactional-jobs.test.ts +590 -0
- package/dist/template/tests/core/two-factor.test.ts +297 -0
- package/dist/template/tests/core/update-admin.test.ts +103 -0
- package/dist/template/tests/core/update-apply.test.ts +34 -0
- package/dist/template/tests/core/update-catalog.test.ts +172 -0
- package/dist/template/tests/core/update-check.test.ts +114 -0
- package/dist/template/tests/core/update-cli.test.ts +119 -0
- package/dist/template/tests/core/update-escalation.test.ts +178 -0
- package/dist/template/tests/core/update-feed.test.ts +104 -0
- package/dist/template/tests/core/update-fork.test.ts +244 -0
- package/dist/template/tests/core/update-policy.test.ts +73 -0
- package/dist/template/tests/core/update-preflight.test.ts +59 -0
- package/dist/template/tests/core/update-release.test.ts +127 -0
- package/dist/template/tests/core/update-seams.test.ts +94 -0
- package/dist/template/tests/core/update-targets.test.ts +325 -0
- package/dist/template/tests/core/upgrade-gate.test.ts +36 -0
- package/dist/template/tests/core/waitlists-and-policy.test.ts +544 -0
- package/dist/template/tests/core/webhooks.test.ts +742 -0
- package/dist/template/tests/core/workflow-integrity.test.ts +142 -0
- package/dist/template/tests/core/zoned.test.ts +84 -0
- package/dist/template/tests/fixtures/c1019-chain.catalog +6597 -0
- package/dist/template/tests/fixtures/locales.ts +55 -0
- package/dist/template/tests/fixtures/sample-plugin/README.md +3 -0
- package/dist/template/tests/fixtures/sample-plugin/plugin.json +10 -0
- package/dist/template/tests/helpers/booking-time.ts +11 -0
- package/dist/template/tests/helpers/database-lock.ts +18 -0
- package/dist/template/tests/helpers/mail.ts +17 -0
- package/dist/template/tests/helpers/performance-boot.ts +194 -0
- package/dist/template/tests/helpers/performance-browser.ts +684 -0
- package/dist/template/tests/helpers/performance-migration.ts +165 -0
- package/dist/template/tests/helpers/performance.ts +203 -0
- package/dist/template/tests/helpers/queue-performance.ts +62 -0
- package/dist/template/tests/helpers/spine.ts +93 -0
- package/dist/template/tests/host/test_docker_updater.py +630 -0
- package/dist/template/tests/host/test_host_updater.py +430 -0
- package/dist/template/tests/modules/ads-measurement.test.ts +360 -0
- package/dist/template/tests/modules/ads-serving.test.ts +694 -0
- package/dist/template/tests/modules/ads-third-party.test.ts +353 -0
- package/dist/template/tests/modules/ads.test.ts +377 -0
- package/dist/template/tests/modules/adversarial-customer-privacy.test.ts +88 -0
- package/dist/template/tests/modules/assessments.test.ts +581 -0
- package/dist/template/tests/modules/assistant-grounding.test.ts +182 -0
- package/dist/template/tests/modules/assistant-guardrails.test.ts +341 -0
- package/dist/template/tests/modules/assistant.test.ts +665 -0
- package/dist/template/tests/modules/automations-guardrails.test.ts +319 -0
- package/dist/template/tests/modules/automations-runtime.test.ts +467 -0
- package/dist/template/tests/modules/automations.test.ts +426 -0
- package/dist/template/tests/modules/broadcasts.test.ts +769 -0
- package/dist/template/tests/modules/calculators.test.ts +407 -0
- package/dist/template/tests/modules/customer-surfaces.test.ts +223 -0
- package/dist/template/tests/modules/documents.test.ts +401 -0
- package/dist/template/tests/modules/form-fields.test.ts +73 -0
- package/dist/template/tests/modules/funnel.test.ts +208 -0
- package/dist/template/tests/modules/help-centre.test.ts +285 -0
- package/dist/template/tests/modules/location-pages.test.ts +232 -0
- package/dist/template/tests/modules/loyalty-rewards.test.ts +490 -0
- package/dist/template/tests/modules/loyalty.test.ts +484 -0
- package/dist/template/tests/modules/one-audience.test.ts +263 -0
- package/dist/template/tests/modules/popups.test.ts +769 -0
- package/dist/template/tests/modules/referrals-commission.test.ts +740 -0
- package/dist/template/tests/modules/referrals.test.ts +349 -0
- package/dist/template/tests/modules/reporting-exports.test.ts +1082 -0
- package/dist/template/tests/modules/reporting.test.ts +384 -0
- package/dist/template/tests/modules/share.test.ts +431 -0
- package/dist/template/tests/modules/social-composer.test.ts +251 -0
- package/dist/template/tests/modules/social-gbp.test.ts +281 -0
- package/dist/template/tests/modules/social-ingest.test.ts +295 -0
- package/dist/template/tests/modules/social-onboarding.test.ts +109 -0
- package/dist/template/tests/modules/social.test.ts +289 -0
- package/dist/template/tests/modules/subscription-billing.test.ts +483 -0
- package/dist/template/tests/modules/subscriptions.test.ts +582 -0
- package/dist/template/tests/modules/templates.test.ts +358 -0
- package/dist/template/tests/modules/translate.test.ts +128 -0
- package/dist/template/tests/setup/migrate.ts +20 -0
- package/dist/template/tsconfig.json +54 -0
- package/dist/template/vitest.config.ts +91 -0
- package/dist/template-manifest.json +12746 -0
- package/package.json +22 -7
|
@@ -0,0 +1,3321 @@
|
|
|
1
|
+
// Copyright (C) 2026 Tony Aly
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Media services (MASTER.md §3 core/media, §4.5, §18).
|
|
4
|
+
//
|
|
5
|
+
// The only door to the asset library. Uploading writes bytes to the storage
|
|
6
|
+
// adapter and a row to the database, in that order and deliberately: an object
|
|
7
|
+
// with no row is litter a sweep can find, whereas a row with no object is a
|
|
8
|
+
// broken image on a customer's screen.
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { and, count, desc, eq, inArray, lt, ne, sql } from "drizzle-orm";
|
|
11
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
12
|
+
import { listed, okResult, row, timestamp, uuid } from "@/core/contract";
|
|
13
|
+
import { db, type Database } from "@/core/db";
|
|
14
|
+
import {
|
|
15
|
+
assets,
|
|
16
|
+
mediaAltTextSuggestions,
|
|
17
|
+
mediaObjects,
|
|
18
|
+
mediaUploads,
|
|
19
|
+
} from "@/core/media/schema";
|
|
20
|
+
import {
|
|
21
|
+
actorString,
|
|
22
|
+
defineOrchestratedService,
|
|
23
|
+
defineService,
|
|
24
|
+
ServiceError,
|
|
25
|
+
type Actor,
|
|
26
|
+
type ServiceContext,
|
|
27
|
+
type Tx,
|
|
28
|
+
} from "@/core/service";
|
|
29
|
+
import { storage } from "@/adapters/storage";
|
|
30
|
+
import {
|
|
31
|
+
storageKey,
|
|
32
|
+
type MultipartPart,
|
|
33
|
+
} from "@/adapters/storage/types";
|
|
34
|
+
import { malwareScanner, type MalwareScanResult } from "@/adapters/malware";
|
|
35
|
+
import {
|
|
36
|
+
altTextSuggester,
|
|
37
|
+
AltTextSuggestionError,
|
|
38
|
+
} from "@/adapters/alt-text";
|
|
39
|
+
import {
|
|
40
|
+
expectedKind,
|
|
41
|
+
MEDIA_LIMITS,
|
|
42
|
+
MediaValidationError,
|
|
43
|
+
PROXY_UPLOAD_LIMIT,
|
|
44
|
+
SIGNATURE_BYTES,
|
|
45
|
+
mediaSignatureSample,
|
|
46
|
+
validateMediaFile,
|
|
47
|
+
type MediaKind,
|
|
48
|
+
} from "@/core/media/validation";
|
|
49
|
+
import captureServices from "./capture";
|
|
50
|
+
import {
|
|
51
|
+
allRenditionKeys,
|
|
52
|
+
buildRenditions,
|
|
53
|
+
isRasterImage,
|
|
54
|
+
publicRenditions,
|
|
55
|
+
readImageFacts,
|
|
56
|
+
toVariantSet,
|
|
57
|
+
withWatermarked,
|
|
58
|
+
type VariantFormat,
|
|
59
|
+
type VariantSet,
|
|
60
|
+
} from "@/core/media/variants";
|
|
61
|
+
import { buildWatermarked, type WatermarkMark } from "@/core/media/watermark";
|
|
62
|
+
import { designSettings } from "@/core/design/schema";
|
|
63
|
+
import { businessProfile } from "@/core/settings/schema";
|
|
64
|
+
|
|
65
|
+
const assetRow = row({
|
|
66
|
+
id: uuid,
|
|
67
|
+
kind: z.enum(["image", "video", "doc", "audio"]),
|
|
68
|
+
storageKey: z.string(),
|
|
69
|
+
filename: z.string(),
|
|
70
|
+
mime: z.string(),
|
|
71
|
+
legacyBytes: z.number().int(),
|
|
72
|
+
bytes: z.number(),
|
|
73
|
+
width: z.number().int().nullable(),
|
|
74
|
+
height: z.number().int().nullable(),
|
|
75
|
+
durationSeconds: z.number().int().nullable(),
|
|
76
|
+
variants: z.unknown(),
|
|
77
|
+
altText: z.string().nullable(),
|
|
78
|
+
blurhash: z.string().nullable(),
|
|
79
|
+
status: z.enum(["processing", "ready", "quarantined", "failed", "trashed"]),
|
|
80
|
+
scanStatus: z.enum(["pending", "clean", "not_configured", "infected", "error"]),
|
|
81
|
+
scanEngine: z.string().nullable(),
|
|
82
|
+
scanMessage: z.string().nullable(),
|
|
83
|
+
scannedAt: timestamp.nullable(),
|
|
84
|
+
checksumSha256: z.string().nullable(),
|
|
85
|
+
metadata: z.unknown(),
|
|
86
|
+
provenance: z.unknown(),
|
|
87
|
+
source: z.enum(["upload", "import", "generated", "migration", "capture"]),
|
|
88
|
+
uploadedBy: z.string().nullable(),
|
|
89
|
+
focalX: z.number().int(),
|
|
90
|
+
focalY: z.number().int(),
|
|
91
|
+
deletedAt: timestamp.nullable(),
|
|
92
|
+
purgeAfter: timestamp.nullable(),
|
|
93
|
+
createdAt: timestamp,
|
|
94
|
+
updatedAt: timestamp,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const suggestionRow = row({
|
|
98
|
+
id: uuid,
|
|
99
|
+
assetId: uuid,
|
|
100
|
+
status: z.enum(["ready", "accepted", "dismissed", "superseded"]),
|
|
101
|
+
suggestion: z.string(),
|
|
102
|
+
provider: z.string(),
|
|
103
|
+
model: z.string(),
|
|
104
|
+
promptVersion: z.string(),
|
|
105
|
+
sourceChecksum: z.string(),
|
|
106
|
+
authoredAltTextAtRequest: z.string().nullable(),
|
|
107
|
+
requestedBy: z.string(),
|
|
108
|
+
reviewedBy: z.string().nullable(),
|
|
109
|
+
reviewedAt: timestamp.nullable(),
|
|
110
|
+
createdAt: timestamp,
|
|
111
|
+
updatedAt: timestamp,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const suggestionProviderState = {
|
|
115
|
+
available: z.boolean(),
|
|
116
|
+
provider: z.string(),
|
|
117
|
+
model: z.string().nullable(),
|
|
118
|
+
unavailableReason: z.string().nullable(),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const completeUploadResult = z.union([
|
|
122
|
+
z.object({ ok: z.literal(true), asset: assetRow.nullable() }),
|
|
123
|
+
z.object({ ok: z.literal(false), message: z.string() }),
|
|
124
|
+
]);
|
|
125
|
+
|
|
126
|
+
const UPLOAD_TTL_MS = 24 * 60 * 60 * 1000;
|
|
127
|
+
const TRASH_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
128
|
+
export const MULTIPART_PART_BYTES = 8 * 1024 * 1024;
|
|
129
|
+
const MAX_MULTIPART_PARTS = 10_000;
|
|
130
|
+
const LEGACY_MAX_BYTES = 2_147_483_647;
|
|
131
|
+
const ALT_TEXT_PROMPT_VERSION = "accessible-image-v1";
|
|
132
|
+
|
|
133
|
+
const sourceSchema = z.enum(["upload", "import", "generated", "migration", "capture"]);
|
|
134
|
+
const provenanceSchema = z
|
|
135
|
+
.object({
|
|
136
|
+
sourceUrl: z.string().url().max(2_048).optional(),
|
|
137
|
+
capturedAt: z.string().datetime().optional(),
|
|
138
|
+
lastModifiedAt: z.string().datetime().optional(),
|
|
139
|
+
note: z.string().trim().max(500).optional(),
|
|
140
|
+
captureToken: z.string().trim().min(16).max(128).optional(),
|
|
141
|
+
captureSessionId: z.string().uuid().optional(),
|
|
142
|
+
})
|
|
143
|
+
.default({});
|
|
144
|
+
const mediaMetadataSchema = z
|
|
145
|
+
.object({
|
|
146
|
+
width: z.number().int().positive().max(100_000).optional(),
|
|
147
|
+
height: z.number().int().positive().max(100_000).optional(),
|
|
148
|
+
durationSeconds: z.number().int().nonnegative().max(31_536_000).optional(),
|
|
149
|
+
pageCount: z.number().int().positive().max(1_000_000).optional(),
|
|
150
|
+
codec: z.string().trim().max(100).optional(),
|
|
151
|
+
trimStartMs: z.number().int().min(0).max(31_536_000_000).optional(),
|
|
152
|
+
trimEndMs: z.number().int().min(0).max(31_536_000_000).optional(),
|
|
153
|
+
})
|
|
154
|
+
.default({});
|
|
155
|
+
|
|
156
|
+
function serviceValidation(error: unknown): never {
|
|
157
|
+
if (error instanceof MediaValidationError) {
|
|
158
|
+
throw new ServiceError("validation", error.message);
|
|
159
|
+
}
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function userOwnsUpload(actor: Actor, uploadedBy: string | null): boolean {
|
|
164
|
+
return actor.kind === "system" ||
|
|
165
|
+
(actor.kind === "user" &&
|
|
166
|
+
(actor.role === "owner" || actorString(actor) === uploadedBy));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function requireUploadAccess(actor: Actor, uploadedBy: string | null): void {
|
|
170
|
+
if (actor.kind === "anonymous" && uploadedBy?.startsWith("capture:")) return;
|
|
171
|
+
if (!userOwnsUpload(actor, uploadedBy)) {
|
|
172
|
+
throw new ServiceError("not_found", "That upload is not here.");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function trackPendingObject(input: {
|
|
177
|
+
key: string;
|
|
178
|
+
contentType: string;
|
|
179
|
+
role: "original" | "variant" | "staged";
|
|
180
|
+
bytes?: number;
|
|
181
|
+
uploadId?: string;
|
|
182
|
+
}): Promise<void> {
|
|
183
|
+
await db()
|
|
184
|
+
.insert(mediaObjects)
|
|
185
|
+
.values({
|
|
186
|
+
key: input.key,
|
|
187
|
+
contentType: input.contentType,
|
|
188
|
+
role: input.role,
|
|
189
|
+
bytes: input.bytes,
|
|
190
|
+
uploadId: input.uploadId,
|
|
191
|
+
state: "pending",
|
|
192
|
+
})
|
|
193
|
+
.onConflictDoUpdate({
|
|
194
|
+
target: mediaObjects.key,
|
|
195
|
+
set: {
|
|
196
|
+
contentType: input.contentType,
|
|
197
|
+
role: input.role,
|
|
198
|
+
bytes: input.bytes,
|
|
199
|
+
uploadId: input.uploadId,
|
|
200
|
+
state: "pending",
|
|
201
|
+
assetId: null,
|
|
202
|
+
updatedAt: new Date(),
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function putTrackedObject(input: {
|
|
208
|
+
key: string;
|
|
209
|
+
body: Uint8Array<ArrayBuffer>;
|
|
210
|
+
contentType: string;
|
|
211
|
+
role: "original" | "variant";
|
|
212
|
+
uploadId?: string;
|
|
213
|
+
}): Promise<void> {
|
|
214
|
+
await trackPendingObject({ ...input, bytes: input.body.byteLength });
|
|
215
|
+
try {
|
|
216
|
+
await storage().put(input.key, input.body, input.contentType);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
await db().delete(mediaObjects).where(eq(mediaObjects.key, input.key));
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async function putTrackedObjects(
|
|
224
|
+
inputs: Array<{
|
|
225
|
+
key: string;
|
|
226
|
+
body: Uint8Array<ArrayBuffer>;
|
|
227
|
+
contentType: string;
|
|
228
|
+
role: "variant";
|
|
229
|
+
uploadId?: string;
|
|
230
|
+
}>,
|
|
231
|
+
): Promise<void> {
|
|
232
|
+
if (inputs.length === 0) return;
|
|
233
|
+
const keys = inputs.map((input) => input.key);
|
|
234
|
+
await db()
|
|
235
|
+
.insert(mediaObjects)
|
|
236
|
+
.values(
|
|
237
|
+
inputs.map((input) => ({
|
|
238
|
+
key: input.key,
|
|
239
|
+
contentType: input.contentType,
|
|
240
|
+
role: input.role,
|
|
241
|
+
bytes: input.body.byteLength,
|
|
242
|
+
uploadId: input.uploadId,
|
|
243
|
+
state: "pending" as const,
|
|
244
|
+
})),
|
|
245
|
+
)
|
|
246
|
+
.onConflictDoNothing();
|
|
247
|
+
try {
|
|
248
|
+
await Promise.all(
|
|
249
|
+
inputs.map((input) =>
|
|
250
|
+
storage().put(input.key, input.body, input.contentType),
|
|
251
|
+
),
|
|
252
|
+
);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
await db().delete(mediaObjects).where(inArray(mediaObjects.key, keys));
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async function attachObjects(
|
|
260
|
+
tx: Tx,
|
|
261
|
+
keys: string[],
|
|
262
|
+
assetId: string,
|
|
263
|
+
): Promise<void> {
|
|
264
|
+
if (keys.length === 0) return;
|
|
265
|
+
await tx
|
|
266
|
+
.update(mediaObjects)
|
|
267
|
+
.set({ assetId, state: "attached", updatedAt: new Date() })
|
|
268
|
+
.where(inArray(mediaObjects.key, keys));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
async function sha256Stream(
|
|
272
|
+
body: AsyncIterable<Uint8Array<ArrayBuffer>>,
|
|
273
|
+
): Promise<string> {
|
|
274
|
+
const hash = createHash("sha256");
|
|
275
|
+
for await (const chunk of body) hash.update(chunk);
|
|
276
|
+
return hash.digest("hex");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function scanStoredAndHash(
|
|
280
|
+
key: string,
|
|
281
|
+
filename: string,
|
|
282
|
+
contentType: string,
|
|
283
|
+
bytes: number,
|
|
284
|
+
): Promise<{ scan: MalwareScanResult; checksumSha256: string }> {
|
|
285
|
+
const source = await storage().stream(key);
|
|
286
|
+
if (!source) throw new Error(`storage: ${key} disappeared before scanning`);
|
|
287
|
+
const scanner = malwareScanner();
|
|
288
|
+
if (scanner.id === "none") {
|
|
289
|
+
const scan = await scanner.scan({ filename, contentType, bytes, body: source });
|
|
290
|
+
return { scan, checksumSha256: await sha256Stream(source) };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const hash = createHash("sha256");
|
|
294
|
+
let hashedBytes = 0;
|
|
295
|
+
const hashingBody = (async function* () {
|
|
296
|
+
for await (const chunk of source) {
|
|
297
|
+
hash.update(chunk);
|
|
298
|
+
hashedBytes += chunk.byteLength;
|
|
299
|
+
yield chunk;
|
|
300
|
+
}
|
|
301
|
+
})();
|
|
302
|
+
const scan = await scanner.scan({
|
|
303
|
+
filename,
|
|
304
|
+
contentType,
|
|
305
|
+
bytes,
|
|
306
|
+
body: hashingBody,
|
|
307
|
+
});
|
|
308
|
+
if (hashedBytes === bytes) {
|
|
309
|
+
return { scan, checksumSha256: hash.digest("hex") };
|
|
310
|
+
}
|
|
311
|
+
// A scanner can fail before consuming the stream. Quarantine truth and the
|
|
312
|
+
// original's digest are independent, so finish the digest with a fresh read.
|
|
313
|
+
const retry = await storage().stream(key);
|
|
314
|
+
if (!retry) throw new Error(`storage: ${key} disappeared before hashing`);
|
|
315
|
+
return { scan, checksumSha256: await sha256Stream(retry) };
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function bodyOnce(bytes: Uint8Array<ArrayBuffer>) {
|
|
319
|
+
return (async function* () {
|
|
320
|
+
yield bytes;
|
|
321
|
+
})();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async function scanBytes(
|
|
325
|
+
bytes: Uint8Array<ArrayBuffer>,
|
|
326
|
+
filename: string,
|
|
327
|
+
contentType: string,
|
|
328
|
+
): Promise<MalwareScanResult> {
|
|
329
|
+
return malwareScanner().scan({
|
|
330
|
+
filename,
|
|
331
|
+
contentType,
|
|
332
|
+
bytes: bytes.byteLength,
|
|
333
|
+
body: bodyOnce(bytes),
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async function scanStored(
|
|
338
|
+
key: string,
|
|
339
|
+
filename: string,
|
|
340
|
+
contentType: string,
|
|
341
|
+
bytes: number,
|
|
342
|
+
): Promise<MalwareScanResult> {
|
|
343
|
+
const body = await storage().stream(key);
|
|
344
|
+
if (!body) throw new Error(`storage: ${key} disappeared before scanning`);
|
|
345
|
+
return malwareScanner().scan({ filename, contentType, bytes, body });
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function scanFields(scan: MalwareScanResult) {
|
|
349
|
+
return {
|
|
350
|
+
scanStatus: scan.status,
|
|
351
|
+
scanEngine: scan.engine,
|
|
352
|
+
scanMessage: scan.message ?? null,
|
|
353
|
+
scannedAt: scan.status === "not_configured" ? null : new Date(),
|
|
354
|
+
status:
|
|
355
|
+
scan.status === "infected" || scan.status === "error"
|
|
356
|
+
? ("quarantined" as const)
|
|
357
|
+
: ("ready" as const),
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function safeProvenance(
|
|
362
|
+
ctx: ServiceContext,
|
|
363
|
+
source: z.output<typeof sourceSchema>,
|
|
364
|
+
supplied: z.output<typeof provenanceSchema>,
|
|
365
|
+
method: "proxy" | "direct_multipart",
|
|
366
|
+
) {
|
|
367
|
+
return {
|
|
368
|
+
...supplied,
|
|
369
|
+
source,
|
|
370
|
+
method,
|
|
371
|
+
introducedBy: actorString(ctx.actor),
|
|
372
|
+
receivedAt: new Date().toISOString(),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
interface CreateAssetInput {
|
|
377
|
+
filename: string;
|
|
378
|
+
mime: string;
|
|
379
|
+
kind: MediaKind;
|
|
380
|
+
bytes: number;
|
|
381
|
+
body?: Uint8Array<ArrayBuffer>;
|
|
382
|
+
key: string;
|
|
383
|
+
altText?: string;
|
|
384
|
+
source: z.output<typeof sourceSchema>;
|
|
385
|
+
provenance: Record<string, unknown>;
|
|
386
|
+
metadata: z.output<typeof mediaMetadataSchema>;
|
|
387
|
+
scan: MalwareScanResult;
|
|
388
|
+
checksumSha256: string;
|
|
389
|
+
uploadId?: string;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* The mark this install stamps proofs with: the brand logo when one is set,
|
|
394
|
+
* the business name otherwise (C8.04). Undefined before setup has named the
|
|
395
|
+
* business — there is nothing to mark with yet, and an unnamed watermark is
|
|
396
|
+
* worse than none.
|
|
397
|
+
*/
|
|
398
|
+
async function watermarkMarkFrom(
|
|
399
|
+
reader: { select: Database["select"] },
|
|
400
|
+
): Promise<{ text: string; logoKey: string | null } | undefined> {
|
|
401
|
+
const [business] = await reader
|
|
402
|
+
.select({ name: businessProfile.name })
|
|
403
|
+
.from(businessProfile)
|
|
404
|
+
.limit(1);
|
|
405
|
+
if (!business?.name) return undefined;
|
|
406
|
+
const [design] = await reader
|
|
407
|
+
.select({ logoAssetId: designSettings.logoAssetId })
|
|
408
|
+
.from(designSettings)
|
|
409
|
+
.limit(1);
|
|
410
|
+
if (!design?.logoAssetId) return { text: business.name, logoKey: null };
|
|
411
|
+
const [asset] = await reader
|
|
412
|
+
.select({ storageKey: assets.storageKey })
|
|
413
|
+
.from(assets)
|
|
414
|
+
.where(eq(assets.id, design.logoAssetId))
|
|
415
|
+
.limit(1);
|
|
416
|
+
return { text: business.name, logoKey: asset?.storageKey ?? null };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** Brand mark for orchestrators: DB snapshot, then logo bytes with no tx held. */
|
|
420
|
+
async function loadWatermarkMark(): Promise<WatermarkMark | undefined> {
|
|
421
|
+
const source = await watermarkMarkFrom(db());
|
|
422
|
+
if (!source) return undefined;
|
|
423
|
+
let logo: Uint8Array<ArrayBuffer> | undefined;
|
|
424
|
+
if (source.logoKey) logo = (await storage().get(source.logoKey)) ?? undefined;
|
|
425
|
+
return { logo, text: source.text };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
interface PreparedOriginal {
|
|
429
|
+
facts?: { width: number; height: number };
|
|
430
|
+
variants: VariantSet | Record<string, never>;
|
|
431
|
+
trackedKeys: string[];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
async function prepareDerivedObjects(
|
|
435
|
+
input: {
|
|
436
|
+
key: string;
|
|
437
|
+
kind: MediaKind;
|
|
438
|
+
scan: MalwareScanResult;
|
|
439
|
+
body?: Uint8Array<ArrayBuffer>;
|
|
440
|
+
uploadId?: string;
|
|
441
|
+
},
|
|
442
|
+
mark: WatermarkMark | undefined,
|
|
443
|
+
): Promise<PreparedOriginal> {
|
|
444
|
+
const scan = scanFields(input.scan);
|
|
445
|
+
const trackedKeys = [input.key];
|
|
446
|
+
let facts: Awaited<ReturnType<typeof readImageFacts>>;
|
|
447
|
+
let variants: VariantSet = {};
|
|
448
|
+
if (input.kind === "image" && scan.status === "ready") {
|
|
449
|
+
const body = input.body ?? (await storage().get(input.key));
|
|
450
|
+
if (!body) throw new Error(`storage: ${input.key} disappeared during processing`);
|
|
451
|
+
facts = await readImageFacts(body);
|
|
452
|
+
if (!facts) {
|
|
453
|
+
throw new MediaValidationError(
|
|
454
|
+
"The image signature is recognized, but the image data is damaged.",
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
const built = await buildRenditions(body, facts, (format, width) =>
|
|
458
|
+
`${input.key}.${width}.${format}`,
|
|
459
|
+
);
|
|
460
|
+
await putTrackedObjects(
|
|
461
|
+
built.map((rendition) => ({
|
|
462
|
+
key: rendition.key,
|
|
463
|
+
body: rendition.body,
|
|
464
|
+
contentType: rendition.contentType,
|
|
465
|
+
role: "variant" as const,
|
|
466
|
+
uploadId: input.uploadId,
|
|
467
|
+
})),
|
|
468
|
+
);
|
|
469
|
+
trackedKeys.push(...built.map((rendition) => rendition.key));
|
|
470
|
+
variants = toVariantSet(built);
|
|
471
|
+
|
|
472
|
+
// Marked renditions are built here, with the ladder, so serving a proof
|
|
473
|
+
// is a key lookup rather than an image job on the client's first view.
|
|
474
|
+
const marked = mark
|
|
475
|
+
? await buildWatermarked(body, facts, mark, (format, width) =>
|
|
476
|
+
`${input.key}.wm.${width}.${format}`,
|
|
477
|
+
)
|
|
478
|
+
: [];
|
|
479
|
+
if (marked.length) {
|
|
480
|
+
await putTrackedObjects(
|
|
481
|
+
marked.map((rendition) => ({
|
|
482
|
+
key: rendition.key,
|
|
483
|
+
body: rendition.body,
|
|
484
|
+
contentType: rendition.contentType,
|
|
485
|
+
role: "variant" as const,
|
|
486
|
+
uploadId: input.uploadId,
|
|
487
|
+
})),
|
|
488
|
+
);
|
|
489
|
+
trackedKeys.push(...marked.map((rendition) => rendition.key));
|
|
490
|
+
variants = withWatermarked(variants, marked);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return { facts, variants, trackedKeys };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
async function insertPreparedAsset(
|
|
497
|
+
input: CreateAssetInput,
|
|
498
|
+
prepared: PreparedOriginal,
|
|
499
|
+
ctx: ServiceContext,
|
|
500
|
+
) {
|
|
501
|
+
const scan = scanFields(input.scan);
|
|
502
|
+
const [asset] = await ctx.tx
|
|
503
|
+
.insert(assets)
|
|
504
|
+
.values({
|
|
505
|
+
kind: input.kind,
|
|
506
|
+
storageKey: input.key,
|
|
507
|
+
filename: input.filename,
|
|
508
|
+
mime: input.mime,
|
|
509
|
+
bytes: input.bytes,
|
|
510
|
+
legacyBytes: Math.min(input.bytes, LEGACY_MAX_BYTES),
|
|
511
|
+
width: prepared.facts?.width ?? input.metadata.width,
|
|
512
|
+
height: prepared.facts?.height ?? input.metadata.height,
|
|
513
|
+
durationSeconds: input.metadata.durationSeconds,
|
|
514
|
+
variants: prepared.variants,
|
|
515
|
+
altText: input.altText,
|
|
516
|
+
checksumSha256: input.checksumSha256,
|
|
517
|
+
metadata: input.metadata,
|
|
518
|
+
provenance: input.provenance,
|
|
519
|
+
source: input.source,
|
|
520
|
+
uploadedBy: actorString(ctx.actor),
|
|
521
|
+
...scan,
|
|
522
|
+
})
|
|
523
|
+
.returning();
|
|
524
|
+
await ctx.tx
|
|
525
|
+
.update(mediaObjects)
|
|
526
|
+
.set({
|
|
527
|
+
role: "original",
|
|
528
|
+
bytes: input.bytes,
|
|
529
|
+
contentType: input.mime,
|
|
530
|
+
updatedAt: new Date(),
|
|
531
|
+
})
|
|
532
|
+
.where(eq(mediaObjects.key, input.key));
|
|
533
|
+
await attachObjects(ctx.tx, prepared.trackedKeys, asset!.id);
|
|
534
|
+
if (input.uploadId) {
|
|
535
|
+
await ctx.tx
|
|
536
|
+
.update(mediaUploads)
|
|
537
|
+
.set({
|
|
538
|
+
state: "complete",
|
|
539
|
+
assetId: asset!.id,
|
|
540
|
+
detectedMime: input.mime,
|
|
541
|
+
completedAt: new Date(),
|
|
542
|
+
updatedAt: new Date(),
|
|
543
|
+
})
|
|
544
|
+
.where(eq(mediaUploads.id, input.uploadId));
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
ctx.setSubject("asset", asset!.id);
|
|
548
|
+
ctx.queueEvent("media.uploaded", {
|
|
549
|
+
assetId: asset!.id,
|
|
550
|
+
kind: asset!.kind,
|
|
551
|
+
scanStatus: asset!.scanStatus,
|
|
552
|
+
});
|
|
553
|
+
return asset!;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const proxyUploadInput = z.object({
|
|
557
|
+
filename: z.string().min(1).max(255),
|
|
558
|
+
contentType: z.string().min(1).max(255),
|
|
559
|
+
bytes: z.instanceof(Uint8Array),
|
|
560
|
+
altText: z.string().max(500).optional(),
|
|
561
|
+
uploadId: z.string().uuid().optional(),
|
|
562
|
+
source: sourceSchema.default("upload"),
|
|
563
|
+
provenance: provenanceSchema,
|
|
564
|
+
metadata: mediaMetadataSchema,
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
const claimProxyUpload = defineService({
|
|
568
|
+
name: "media.claimProxyUpload",
|
|
569
|
+
summary: "Authorize a proxied upload reservation before scanner and storage work.",
|
|
570
|
+
kind: "mutation",
|
|
571
|
+
permission: "public",
|
|
572
|
+
external: false,
|
|
573
|
+
writeClass: "write",
|
|
574
|
+
input: z.object({
|
|
575
|
+
uploadId: z.string().uuid(),
|
|
576
|
+
filename: z.string().min(1).max(255),
|
|
577
|
+
bytes: z.number().int().positive(),
|
|
578
|
+
}),
|
|
579
|
+
output: z.object({
|
|
580
|
+
key: z.string(),
|
|
581
|
+
uploadId: uuid,
|
|
582
|
+
asset: assetRow.nullable(),
|
|
583
|
+
}),
|
|
584
|
+
handler: async (input, ctx) => {
|
|
585
|
+
const [session] = await ctx.tx
|
|
586
|
+
.select()
|
|
587
|
+
.from(mediaUploads)
|
|
588
|
+
.where(eq(mediaUploads.id, input.uploadId))
|
|
589
|
+
.limit(1)
|
|
590
|
+
.for("update");
|
|
591
|
+
if (!session || session.strategy !== "proxy") {
|
|
592
|
+
throw new ServiceError("not_found", "That upload is not here.");
|
|
593
|
+
}
|
|
594
|
+
requireUploadAccess(ctx.actor, session.uploadedBy);
|
|
595
|
+
if (session.state === "complete" && session.assetId) {
|
|
596
|
+
const [asset] = await ctx.tx
|
|
597
|
+
.select()
|
|
598
|
+
.from(assets)
|
|
599
|
+
.where(eq(assets.id, session.assetId))
|
|
600
|
+
.limit(1);
|
|
601
|
+
if (asset) {
|
|
602
|
+
return { key: session.storageKey, uploadId: session.id, asset };
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (session.expiresAt <= new Date()) {
|
|
606
|
+
throw new ServiceError("conflict", "That upload reservation has expired.");
|
|
607
|
+
}
|
|
608
|
+
if (!["created", "processing"].includes(session.state)) {
|
|
609
|
+
throw new ServiceError("conflict", "That upload is no longer accepting bytes.");
|
|
610
|
+
}
|
|
611
|
+
if (
|
|
612
|
+
session.filename !== input.filename ||
|
|
613
|
+
session.expectedBytes !== input.bytes
|
|
614
|
+
) {
|
|
615
|
+
throw new ServiceError(
|
|
616
|
+
"validation",
|
|
617
|
+
"The selected file no longer matches the upload reservation.",
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
if (session.state === "created") {
|
|
621
|
+
await ctx.tx
|
|
622
|
+
.update(mediaUploads)
|
|
623
|
+
.set({ state: "processing", updatedAt: new Date() })
|
|
624
|
+
.where(eq(mediaUploads.id, session.id));
|
|
625
|
+
}
|
|
626
|
+
return { key: session.storageKey, uploadId: session.id, asset: null };
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const applyStoredOriginal = defineService({
|
|
631
|
+
name: "media.applyStoredOriginal",
|
|
632
|
+
summary: "Attach a scanned original and its derived objects as a library asset.",
|
|
633
|
+
kind: "mutation",
|
|
634
|
+
permission: "public",
|
|
635
|
+
external: false,
|
|
636
|
+
writeClass: "write",
|
|
637
|
+
input: z.object({
|
|
638
|
+
filename: z.string().min(1).max(255),
|
|
639
|
+
mime: z.string().min(1).max(255),
|
|
640
|
+
kind: z.enum(["image", "video", "doc", "audio"]),
|
|
641
|
+
bytes: z.number(),
|
|
642
|
+
key: z.string().min(1),
|
|
643
|
+
altText: z.string().max(500).optional(),
|
|
644
|
+
source: sourceSchema,
|
|
645
|
+
provenance: provenanceSchema,
|
|
646
|
+
metadata: mediaMetadataSchema,
|
|
647
|
+
scan: z.object({
|
|
648
|
+
status: z.enum(["clean", "infected", "not_configured", "error"]),
|
|
649
|
+
engine: z.string(),
|
|
650
|
+
message: z.string().optional(),
|
|
651
|
+
}),
|
|
652
|
+
checksumSha256: z.string().min(1),
|
|
653
|
+
uploadId: z.string().uuid().optional(),
|
|
654
|
+
method: z.enum(["proxy", "direct_multipart"]),
|
|
655
|
+
variants: z.unknown(),
|
|
656
|
+
trackedKeys: z.array(z.string().min(1)).min(1).max(64),
|
|
657
|
+
width: z.number().int().nullable().optional(),
|
|
658
|
+
height: z.number().int().nullable().optional(),
|
|
659
|
+
}),
|
|
660
|
+
output: assetRow,
|
|
661
|
+
handler: async (input, ctx) => {
|
|
662
|
+
if (input.uploadId) {
|
|
663
|
+
const session = await lockedUploadSession(ctx.tx, input.uploadId);
|
|
664
|
+
if (!session) throw new ServiceError("not_found", "That upload is not here.");
|
|
665
|
+
requireUploadAccess(ctx.actor, session.uploadedBy);
|
|
666
|
+
if (session.state === "complete" && session.assetId) {
|
|
667
|
+
const [asset] = await ctx.tx
|
|
668
|
+
.select()
|
|
669
|
+
.from(assets)
|
|
670
|
+
.where(eq(assets.id, session.assetId))
|
|
671
|
+
.limit(1);
|
|
672
|
+
if (asset) return asset;
|
|
673
|
+
}
|
|
674
|
+
if (["aborted", "expired", "failed"].includes(session.state)) {
|
|
675
|
+
throw new ServiceError(
|
|
676
|
+
"conflict",
|
|
677
|
+
"That upload can no longer become a library file.",
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return insertPreparedAsset(
|
|
682
|
+
{
|
|
683
|
+
filename: input.filename,
|
|
684
|
+
mime: input.mime,
|
|
685
|
+
kind: input.kind,
|
|
686
|
+
bytes: input.bytes,
|
|
687
|
+
key: input.key,
|
|
688
|
+
altText: input.altText,
|
|
689
|
+
source: input.source,
|
|
690
|
+
provenance: safeProvenance(ctx, input.source, input.provenance, input.method),
|
|
691
|
+
metadata: input.metadata,
|
|
692
|
+
scan: input.scan,
|
|
693
|
+
checksumSha256: input.checksumSha256,
|
|
694
|
+
uploadId: input.uploadId,
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
facts:
|
|
698
|
+
input.width != null && input.height != null
|
|
699
|
+
? { width: input.width, height: input.height }
|
|
700
|
+
: undefined,
|
|
701
|
+
variants: (input.variants ?? {}),
|
|
702
|
+
trackedKeys: input.trackedKeys,
|
|
703
|
+
},
|
|
704
|
+
ctx,
|
|
705
|
+
);
|
|
706
|
+
},
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
export const uploadAsset = defineOrchestratedService({
|
|
710
|
+
name: "media.upload",
|
|
711
|
+
summary: "Validate and store a bounded proxied upload.",
|
|
712
|
+
kind: "mutation",
|
|
713
|
+
permission: "public",
|
|
714
|
+
writeClass: "write",
|
|
715
|
+
input: proxyUploadInput,
|
|
716
|
+
output: assetRow,
|
|
717
|
+
handler: async (input, actor) => {
|
|
718
|
+
if (
|
|
719
|
+
actor.kind === "anonymous" &&
|
|
720
|
+
!input.uploadId &&
|
|
721
|
+
!input.provenance.captureToken &&
|
|
722
|
+
!input.provenance.captureSessionId
|
|
723
|
+
) {
|
|
724
|
+
throw new ServiceError("permission", "Sign in or use an upload link.");
|
|
725
|
+
}
|
|
726
|
+
const body = input.bytes;
|
|
727
|
+
if (body.byteLength > PROXY_UPLOAD_LIMIT) {
|
|
728
|
+
throw new ServiceError(
|
|
729
|
+
"validation",
|
|
730
|
+
"Files larger than 25 MB use the resumable direct-upload path.",
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
try {
|
|
734
|
+
const validated = validateMediaFile({
|
|
735
|
+
filename: input.filename,
|
|
736
|
+
declaredMime: input.contentType,
|
|
737
|
+
bytes: body.byteLength,
|
|
738
|
+
prefix: mediaSignatureSample(
|
|
739
|
+
body.subarray(0, SIGNATURE_BYTES),
|
|
740
|
+
body.byteLength > SIGNATURE_BYTES
|
|
741
|
+
? body.subarray(Math.max(SIGNATURE_BYTES, body.byteLength - SIGNATURE_BYTES))
|
|
742
|
+
: new Uint8Array(),
|
|
743
|
+
),
|
|
744
|
+
});
|
|
745
|
+
let key = storageKey(input.filename, new Date(), randomUUID().slice(0, 8));
|
|
746
|
+
let uploadId = input.uploadId;
|
|
747
|
+
if (input.uploadId) {
|
|
748
|
+
const claimed = await claimProxyUpload.call(
|
|
749
|
+
{
|
|
750
|
+
uploadId: input.uploadId,
|
|
751
|
+
filename: input.filename,
|
|
752
|
+
bytes: body.byteLength,
|
|
753
|
+
},
|
|
754
|
+
actor,
|
|
755
|
+
);
|
|
756
|
+
if (claimed.asset) return claimed.asset;
|
|
757
|
+
key = claimed.key;
|
|
758
|
+
uploadId = claimed.uploadId;
|
|
759
|
+
}
|
|
760
|
+
const scan = await scanBytes(body, input.filename, validated.mime);
|
|
761
|
+
if (
|
|
762
|
+
storage().id === "s3" && storage().isPublic &&
|
|
763
|
+
(scan.status === "infected" || scan.status === "error")
|
|
764
|
+
) {
|
|
765
|
+
throw new ServiceError(
|
|
766
|
+
"validation",
|
|
767
|
+
"The scanner did not clear this file, and public storage cannot quarantine it safely.",
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
await putTrackedObject({
|
|
771
|
+
key,
|
|
772
|
+
body,
|
|
773
|
+
contentType: validated.mime,
|
|
774
|
+
role: "original",
|
|
775
|
+
uploadId,
|
|
776
|
+
});
|
|
777
|
+
const prepared = await prepareDerivedObjects(
|
|
778
|
+
{
|
|
779
|
+
key,
|
|
780
|
+
kind: validated.kind,
|
|
781
|
+
scan,
|
|
782
|
+
body,
|
|
783
|
+
uploadId,
|
|
784
|
+
},
|
|
785
|
+
await loadWatermarkMark(),
|
|
786
|
+
);
|
|
787
|
+
return applyStoredOriginal.call(
|
|
788
|
+
{
|
|
789
|
+
filename: input.filename,
|
|
790
|
+
mime: validated.mime,
|
|
791
|
+
kind: validated.kind,
|
|
792
|
+
bytes: body.byteLength,
|
|
793
|
+
key,
|
|
794
|
+
altText: input.altText,
|
|
795
|
+
source: input.source,
|
|
796
|
+
provenance: input.provenance,
|
|
797
|
+
metadata: input.metadata,
|
|
798
|
+
scan,
|
|
799
|
+
checksumSha256: createHash("sha256").update(body).digest("hex"),
|
|
800
|
+
uploadId,
|
|
801
|
+
method: "proxy",
|
|
802
|
+
variants: prepared.variants,
|
|
803
|
+
trackedKeys: prepared.trackedKeys,
|
|
804
|
+
width: prepared.facts?.width ?? null,
|
|
805
|
+
height: prepared.facts?.height ?? null,
|
|
806
|
+
},
|
|
807
|
+
actor,
|
|
808
|
+
);
|
|
809
|
+
} catch (error) {
|
|
810
|
+
return serviceValidation(error);
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
const uploadIntent = z.object({
|
|
816
|
+
filename: z.string().min(1).max(255),
|
|
817
|
+
contentType: z.string().min(1).max(255),
|
|
818
|
+
bytes: z.number().int().positive().max(MEDIA_LIMITS.video),
|
|
819
|
+
altText: z.string().max(500).optional(),
|
|
820
|
+
source: sourceSchema.default("upload"),
|
|
821
|
+
provenance: provenanceSchema,
|
|
822
|
+
metadata: mediaMetadataSchema,
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
const beginUploadOutput = z.object({
|
|
826
|
+
id: uuid,
|
|
827
|
+
strategy: z.enum(["direct_multipart", "proxy"]),
|
|
828
|
+
partSize: z.number().int().nullable(),
|
|
829
|
+
partCount: z.number().int().nullable(),
|
|
830
|
+
expiresAt: timestamp,
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
const beginUploadApply = defineService({
|
|
834
|
+
name: "media.beginUploadApply",
|
|
835
|
+
summary: "Record a reserved upload after the storage provider has accepted it.",
|
|
836
|
+
kind: "mutation",
|
|
837
|
+
permission: "public",
|
|
838
|
+
external: false,
|
|
839
|
+
writeClass: "write",
|
|
840
|
+
input: uploadIntent.extend({
|
|
841
|
+
key: z.string().min(1),
|
|
842
|
+
strategy: z.enum(["direct_multipart", "proxy"]),
|
|
843
|
+
providerUploadId: z.string().min(1).optional(),
|
|
844
|
+
}),
|
|
845
|
+
output: beginUploadOutput,
|
|
846
|
+
handler: async (input, ctx) => {
|
|
847
|
+
const [session] = await ctx.tx
|
|
848
|
+
.insert(mediaUploads)
|
|
849
|
+
.values({
|
|
850
|
+
strategy: input.strategy,
|
|
851
|
+
storageKey: input.key,
|
|
852
|
+
filename: input.filename,
|
|
853
|
+
declaredMime: input.contentType,
|
|
854
|
+
expectedBytes: input.bytes,
|
|
855
|
+
providerUploadId: input.providerUploadId,
|
|
856
|
+
uploadedBy: input.provenance.captureToken
|
|
857
|
+
? `capture:${input.provenance.captureToken}`
|
|
858
|
+
: actorString(ctx.actor),
|
|
859
|
+
source: input.provenance.captureToken ? "capture" : input.source,
|
|
860
|
+
provenance: input.provenance,
|
|
861
|
+
mediaMetadata: input.metadata,
|
|
862
|
+
expiresAt: new Date(Date.now() + UPLOAD_TTL_MS),
|
|
863
|
+
})
|
|
864
|
+
.returning();
|
|
865
|
+
await ctx.tx.insert(mediaObjects).values({
|
|
866
|
+
key: input.key,
|
|
867
|
+
uploadId: session!.id,
|
|
868
|
+
role: "staged",
|
|
869
|
+
state: "pending",
|
|
870
|
+
contentType: input.contentType,
|
|
871
|
+
});
|
|
872
|
+
ctx.setSubject("mediaUpload", session!.id);
|
|
873
|
+
return {
|
|
874
|
+
id: session!.id,
|
|
875
|
+
strategy: input.strategy,
|
|
876
|
+
partSize: input.strategy === "direct_multipart" ? MULTIPART_PART_BYTES : null,
|
|
877
|
+
partCount:
|
|
878
|
+
input.strategy === "direct_multipart"
|
|
879
|
+
? Math.ceil(input.bytes / MULTIPART_PART_BYTES)
|
|
880
|
+
: null,
|
|
881
|
+
expiresAt: session!.expiresAt,
|
|
882
|
+
};
|
|
883
|
+
},
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
/** Reserve a durable upload and choose the capability the active adapter has. */
|
|
887
|
+
export const beginUpload = defineOrchestratedService({
|
|
888
|
+
name: "media.beginUpload",
|
|
889
|
+
summary: "Reserve a resumable direct upload or bounded proxy fallback.",
|
|
890
|
+
kind: "mutation",
|
|
891
|
+
permission: "public",
|
|
892
|
+
writeClass: "write",
|
|
893
|
+
input: uploadIntent,
|
|
894
|
+
output: beginUploadOutput,
|
|
895
|
+
handler: async (input, actor) => {
|
|
896
|
+
if (actor.kind === "anonymous" && !input.provenance.captureToken) {
|
|
897
|
+
throw new ServiceError("permission", "Sign in or use an upload link.");
|
|
898
|
+
}
|
|
899
|
+
let kind: MediaKind;
|
|
900
|
+
try {
|
|
901
|
+
kind = expectedKind(input.filename, input.contentType);
|
|
902
|
+
} catch (error) {
|
|
903
|
+
return serviceValidation(error);
|
|
904
|
+
}
|
|
905
|
+
if (/[\u0000-\u001f/\\]/.test(input.filename)) {
|
|
906
|
+
throw new ServiceError("validation", "The filename contains unsafe characters.");
|
|
907
|
+
}
|
|
908
|
+
if (input.bytes > MEDIA_LIMITS[kind]) {
|
|
909
|
+
throw new ServiceError(
|
|
910
|
+
"validation",
|
|
911
|
+
`That ${kind} file is larger than ${Math.floor(MEDIA_LIMITS[kind] / 1024 / 1024)} MB.`,
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
const store = storage();
|
|
916
|
+
const strategy = store.directMultipart
|
|
917
|
+
? ("direct_multipart" as const)
|
|
918
|
+
: ("proxy" as const);
|
|
919
|
+
if (strategy === "proxy" && input.bytes > PROXY_UPLOAD_LIMIT) {
|
|
920
|
+
throw new ServiceError(
|
|
921
|
+
"validation",
|
|
922
|
+
"This storage adapter cannot accept that file through the 25 MB proxy. Configure S3-compatible storage for resumable direct uploads.",
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
const key = storageKey(input.filename, new Date(), randomUUID().slice(0, 8));
|
|
927
|
+
let providerUploadId: string | undefined;
|
|
928
|
+
try {
|
|
929
|
+
if (store.directMultipart) {
|
|
930
|
+
providerUploadId = (
|
|
931
|
+
await store.directMultipart.create(key, input.contentType)
|
|
932
|
+
).uploadId;
|
|
933
|
+
}
|
|
934
|
+
return await beginUploadApply.call(
|
|
935
|
+
{
|
|
936
|
+
...input,
|
|
937
|
+
key,
|
|
938
|
+
strategy,
|
|
939
|
+
providerUploadId,
|
|
940
|
+
},
|
|
941
|
+
actor,
|
|
942
|
+
);
|
|
943
|
+
} catch (error) {
|
|
944
|
+
if (providerUploadId && store.directMultipart) {
|
|
945
|
+
await store.directMultipart.abort(key, providerUploadId).catch(() => undefined);
|
|
946
|
+
}
|
|
947
|
+
throw error;
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
});
|
|
951
|
+
|
|
952
|
+
async function uploadSession(tx: Tx, id: string) {
|
|
953
|
+
const [session] = await tx
|
|
954
|
+
.select()
|
|
955
|
+
.from(mediaUploads)
|
|
956
|
+
.where(eq(mediaUploads.id, id))
|
|
957
|
+
.limit(1);
|
|
958
|
+
return session;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
async function lockedUploadSession(tx: Tx, id: string) {
|
|
962
|
+
const [session] = await tx
|
|
963
|
+
.select()
|
|
964
|
+
.from(mediaUploads)
|
|
965
|
+
.where(eq(mediaUploads.id, id))
|
|
966
|
+
.limit(1)
|
|
967
|
+
.for("update");
|
|
968
|
+
return session;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
async function assetForCompletedUpload(
|
|
972
|
+
tx: Tx,
|
|
973
|
+
session: typeof mediaUploads.$inferSelect,
|
|
974
|
+
) {
|
|
975
|
+
if (!session.assetId) return undefined;
|
|
976
|
+
const [asset] = await tx
|
|
977
|
+
.select()
|
|
978
|
+
.from(assets)
|
|
979
|
+
.where(eq(assets.id, session.assetId))
|
|
980
|
+
.limit(1);
|
|
981
|
+
return asset;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
const uploadStatusOutput = z.object({
|
|
985
|
+
id: uuid,
|
|
986
|
+
strategy: z.enum(["direct_multipart", "proxy"]),
|
|
987
|
+
state: z.enum([
|
|
988
|
+
"created",
|
|
989
|
+
"uploading",
|
|
990
|
+
"uploaded",
|
|
991
|
+
"processing",
|
|
992
|
+
"complete",
|
|
993
|
+
"failed",
|
|
994
|
+
"aborted",
|
|
995
|
+
"expired",
|
|
996
|
+
]),
|
|
997
|
+
filename: z.string(),
|
|
998
|
+
contentType: z.string(),
|
|
999
|
+
expectedBytes: z.number(),
|
|
1000
|
+
partSize: z.number().int().nullable(),
|
|
1001
|
+
partCount: z.number().int().nullable(),
|
|
1002
|
+
parts: listed(
|
|
1003
|
+
z.object({
|
|
1004
|
+
partNumber: z.number().int(),
|
|
1005
|
+
etag: z.string(),
|
|
1006
|
+
bytes: z.number().optional(),
|
|
1007
|
+
}),
|
|
1008
|
+
),
|
|
1009
|
+
assetId: uuid.nullable(),
|
|
1010
|
+
failureReason: z.string().nullable(),
|
|
1011
|
+
expiresAt: timestamp,
|
|
1012
|
+
storageKey: z.string(),
|
|
1013
|
+
providerUploadId: z.string().nullable(),
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
const uploadStatusSource = defineService({
|
|
1017
|
+
name: "media.uploadStatusSource",
|
|
1018
|
+
summary: "Authorize and snapshot an upload reservation before listing provider parts.",
|
|
1019
|
+
kind: "query",
|
|
1020
|
+
permission: "public",
|
|
1021
|
+
external: false,
|
|
1022
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1023
|
+
output: uploadStatusOutput.omit({ parts: true }),
|
|
1024
|
+
handler: async (input, ctx) => {
|
|
1025
|
+
const session = await uploadSession(ctx.tx, input.id);
|
|
1026
|
+
if (!session) throw new ServiceError("not_found", "That upload is not here.");
|
|
1027
|
+
requireUploadAccess(ctx.actor, session.uploadedBy);
|
|
1028
|
+
return {
|
|
1029
|
+
id: session.id,
|
|
1030
|
+
strategy: session.strategy,
|
|
1031
|
+
state: session.state,
|
|
1032
|
+
filename: session.filename,
|
|
1033
|
+
contentType: session.declaredMime,
|
|
1034
|
+
expectedBytes: session.expectedBytes,
|
|
1035
|
+
partSize:
|
|
1036
|
+
session.strategy === "direct_multipart" ? MULTIPART_PART_BYTES : null,
|
|
1037
|
+
partCount:
|
|
1038
|
+
session.strategy === "direct_multipart"
|
|
1039
|
+
? Math.ceil(session.expectedBytes / MULTIPART_PART_BYTES)
|
|
1040
|
+
: null,
|
|
1041
|
+
assetId: session.assetId,
|
|
1042
|
+
failureReason: session.failureReason,
|
|
1043
|
+
expiresAt: session.expiresAt,
|
|
1044
|
+
storageKey: session.storageKey,
|
|
1045
|
+
providerUploadId: session.providerUploadId,
|
|
1046
|
+
};
|
|
1047
|
+
},
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
export const uploadStatus = defineOrchestratedService({
|
|
1051
|
+
name: "media.uploadStatus",
|
|
1052
|
+
summary: "Report durable progress for an interrupted upload.",
|
|
1053
|
+
kind: "query",
|
|
1054
|
+
permission: "public",
|
|
1055
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1056
|
+
output: uploadStatusOutput.omit({ storageKey: true, providerUploadId: true }),
|
|
1057
|
+
handler: async (input, actor) => {
|
|
1058
|
+
const session = await uploadStatusSource.call(input, actor);
|
|
1059
|
+
let parts: MultipartPart[] = [];
|
|
1060
|
+
if (
|
|
1061
|
+
session.strategy === "direct_multipart" &&
|
|
1062
|
+
session.providerUploadId &&
|
|
1063
|
+
!["complete", "failed", "aborted", "expired"].includes(session.state)
|
|
1064
|
+
) {
|
|
1065
|
+
const multipart = storage().directMultipart;
|
|
1066
|
+
if (multipart) {
|
|
1067
|
+
parts = await multipart.listParts(
|
|
1068
|
+
session.storageKey,
|
|
1069
|
+
session.providerUploadId,
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return {
|
|
1074
|
+
id: session.id,
|
|
1075
|
+
strategy: session.strategy,
|
|
1076
|
+
state: session.state,
|
|
1077
|
+
filename: session.filename,
|
|
1078
|
+
contentType: session.contentType,
|
|
1079
|
+
expectedBytes: session.expectedBytes,
|
|
1080
|
+
partSize: session.partSize,
|
|
1081
|
+
partCount: session.partCount,
|
|
1082
|
+
parts,
|
|
1083
|
+
assetId: session.assetId,
|
|
1084
|
+
failureReason: session.failureReason,
|
|
1085
|
+
expiresAt: session.expiresAt,
|
|
1086
|
+
};
|
|
1087
|
+
},
|
|
1088
|
+
});
|
|
1089
|
+
|
|
1090
|
+
const signUploadClaim = defineService({
|
|
1091
|
+
name: "media.signUploadClaim",
|
|
1092
|
+
summary: "Mark a direct upload as accepting parts before signing provider URLs.",
|
|
1093
|
+
kind: "mutation",
|
|
1094
|
+
permission: "public",
|
|
1095
|
+
external: false,
|
|
1096
|
+
writeClass: "write",
|
|
1097
|
+
input: z.object({
|
|
1098
|
+
id: z.string().uuid(),
|
|
1099
|
+
partNumbers: z.array(z.number().int().min(1).max(MAX_MULTIPART_PARTS)).min(1).max(25),
|
|
1100
|
+
}),
|
|
1101
|
+
output: z.object({
|
|
1102
|
+
storageKey: z.string(),
|
|
1103
|
+
providerUploadId: z.string(),
|
|
1104
|
+
expiresAt: timestamp,
|
|
1105
|
+
partNumbers: z.array(z.number().int()),
|
|
1106
|
+
}),
|
|
1107
|
+
handler: async (input, ctx) => {
|
|
1108
|
+
const session = await lockedUploadSession(ctx.tx, input.id);
|
|
1109
|
+
if (!session || session.strategy !== "direct_multipart") {
|
|
1110
|
+
throw new ServiceError("not_found", "That direct upload is not here.");
|
|
1111
|
+
}
|
|
1112
|
+
requireUploadAccess(ctx.actor, session.uploadedBy);
|
|
1113
|
+
if (session.expiresAt <= new Date()) {
|
|
1114
|
+
throw new ServiceError("conflict", "That upload reservation has expired.");
|
|
1115
|
+
}
|
|
1116
|
+
if (!["created", "uploading"].includes(session.state)) {
|
|
1117
|
+
throw new ServiceError("conflict", "That upload is no longer accepting parts.");
|
|
1118
|
+
}
|
|
1119
|
+
if (!session.providerUploadId) {
|
|
1120
|
+
throw new ServiceError("conflict", "Direct uploads are unavailable.");
|
|
1121
|
+
}
|
|
1122
|
+
const partCount = Math.ceil(session.expectedBytes / MULTIPART_PART_BYTES);
|
|
1123
|
+
const partNumbers = [...new Set(input.partNumbers)].sort((a, b) => a - b);
|
|
1124
|
+
if (partNumbers.some((part) => part > partCount)) {
|
|
1125
|
+
throw new ServiceError("validation", "A requested upload part is outside the file.");
|
|
1126
|
+
}
|
|
1127
|
+
if (session.state === "created") {
|
|
1128
|
+
await ctx.tx
|
|
1129
|
+
.update(mediaUploads)
|
|
1130
|
+
.set({ state: "uploading", updatedAt: new Date() })
|
|
1131
|
+
.where(eq(mediaUploads.id, session.id));
|
|
1132
|
+
}
|
|
1133
|
+
ctx.setSubject("mediaUpload", session.id);
|
|
1134
|
+
return {
|
|
1135
|
+
storageKey: session.storageKey,
|
|
1136
|
+
providerUploadId: session.providerUploadId,
|
|
1137
|
+
expiresAt: session.expiresAt,
|
|
1138
|
+
partNumbers,
|
|
1139
|
+
};
|
|
1140
|
+
},
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1143
|
+
export const signUploadParts = defineOrchestratedService({
|
|
1144
|
+
name: "media.signUploadParts",
|
|
1145
|
+
summary: "Sign a bounded set of direct multipart upload requests.",
|
|
1146
|
+
kind: "mutation",
|
|
1147
|
+
permission: "public",
|
|
1148
|
+
writeClass: "write",
|
|
1149
|
+
input: z.object({
|
|
1150
|
+
id: z.string().uuid(),
|
|
1151
|
+
partNumbers: z.array(z.number().int().min(1).max(MAX_MULTIPART_PARTS)).min(1).max(25),
|
|
1152
|
+
}),
|
|
1153
|
+
output: z.object({
|
|
1154
|
+
parts: listed(
|
|
1155
|
+
z.object({
|
|
1156
|
+
partNumber: z.number().int(),
|
|
1157
|
+
url: z.string(),
|
|
1158
|
+
method: z.literal("PUT"),
|
|
1159
|
+
}),
|
|
1160
|
+
),
|
|
1161
|
+
expiresAt: timestamp,
|
|
1162
|
+
}),
|
|
1163
|
+
handler: async (input, actor) => {
|
|
1164
|
+
const claimed = await signUploadClaim.call(input, actor);
|
|
1165
|
+
const multipart = storage().directMultipart;
|
|
1166
|
+
if (!multipart) {
|
|
1167
|
+
throw new ServiceError("conflict", "Direct uploads are unavailable.");
|
|
1168
|
+
}
|
|
1169
|
+
const signed = await Promise.all(
|
|
1170
|
+
claimed.partNumbers.map(async (partNumber) => ({
|
|
1171
|
+
partNumber,
|
|
1172
|
+
...(await multipart.signPart(
|
|
1173
|
+
claimed.storageKey,
|
|
1174
|
+
claimed.providerUploadId,
|
|
1175
|
+
partNumber,
|
|
1176
|
+
)),
|
|
1177
|
+
})),
|
|
1178
|
+
);
|
|
1179
|
+
return { parts: signed, expiresAt: claimed.expiresAt };
|
|
1180
|
+
},
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
const failDirectUpload = defineService({
|
|
1184
|
+
name: "media.failDirectUpload",
|
|
1185
|
+
summary: "Record that a direct upload failed validation after provider work.",
|
|
1186
|
+
kind: "mutation",
|
|
1187
|
+
permission: "public",
|
|
1188
|
+
external: false,
|
|
1189
|
+
writeClass: "write",
|
|
1190
|
+
input: z.object({
|
|
1191
|
+
id: z.string().uuid(),
|
|
1192
|
+
storageKey: z.string().min(1),
|
|
1193
|
+
message: z.string().min(1).max(500),
|
|
1194
|
+
}),
|
|
1195
|
+
output: z.object({ ok: z.literal(false), message: z.string() }),
|
|
1196
|
+
handler: async (input, ctx) => {
|
|
1197
|
+
const session = await lockedUploadSession(ctx.tx, input.id);
|
|
1198
|
+
if (!session) throw new ServiceError("not_found", "That upload is not here.");
|
|
1199
|
+
requireUploadAccess(ctx.actor, session.uploadedBy);
|
|
1200
|
+
if (session.state === "failed") {
|
|
1201
|
+
return {
|
|
1202
|
+
ok: false as const,
|
|
1203
|
+
message: session.failureReason ?? input.message,
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
if (session.state === "complete") {
|
|
1207
|
+
throw new ServiceError("conflict", "That upload already became a library file.");
|
|
1208
|
+
}
|
|
1209
|
+
await ctx.tx.delete(mediaObjects).where(eq(mediaObjects.key, input.storageKey));
|
|
1210
|
+
await ctx.tx
|
|
1211
|
+
.update(mediaUploads)
|
|
1212
|
+
.set({ state: "failed", failureReason: input.message, updatedAt: new Date() })
|
|
1213
|
+
.where(eq(mediaUploads.id, session.id));
|
|
1214
|
+
ctx.setSubject("mediaUpload", session.id);
|
|
1215
|
+
return { ok: false as const, message: input.message };
|
|
1216
|
+
},
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
const applyCaptureComplete = defineService({
|
|
1220
|
+
name: "media.applyCaptureComplete",
|
|
1221
|
+
summary: "Hold a finished direct upload on a capture session and close the reservation.",
|
|
1222
|
+
kind: "mutation",
|
|
1223
|
+
permission: "public",
|
|
1224
|
+
external: false,
|
|
1225
|
+
writeClass: "write",
|
|
1226
|
+
input: z.object({
|
|
1227
|
+
uploadId: z.string().uuid(),
|
|
1228
|
+
token: z.string().optional(),
|
|
1229
|
+
sessionId: z.string().uuid().optional(),
|
|
1230
|
+
filename: z.string().min(1).max(255),
|
|
1231
|
+
contentType: z.string().min(1).max(255),
|
|
1232
|
+
key: z.string().min(1),
|
|
1233
|
+
bytes: z.number().int().positive(),
|
|
1234
|
+
checksumSha256: z.string().length(64).optional(),
|
|
1235
|
+
detectedMime: z.string().min(1),
|
|
1236
|
+
}),
|
|
1237
|
+
output: completeUploadResult,
|
|
1238
|
+
handler: async (input, ctx) => {
|
|
1239
|
+
const { stageCompletedUpload } = await import("./capture");
|
|
1240
|
+
await ctx.callAsSystem(stageCompletedUpload, {
|
|
1241
|
+
uploadId: input.uploadId,
|
|
1242
|
+
token: input.token,
|
|
1243
|
+
sessionId: input.sessionId,
|
|
1244
|
+
filename: input.filename,
|
|
1245
|
+
contentType: input.contentType,
|
|
1246
|
+
key: input.key,
|
|
1247
|
+
bytes: input.bytes,
|
|
1248
|
+
checksumSha256: input.checksumSha256,
|
|
1249
|
+
});
|
|
1250
|
+
await ctx.tx
|
|
1251
|
+
.update(mediaUploads)
|
|
1252
|
+
.set({
|
|
1253
|
+
state: "complete",
|
|
1254
|
+
detectedMime: input.detectedMime,
|
|
1255
|
+
completedAt: new Date(),
|
|
1256
|
+
updatedAt: new Date(),
|
|
1257
|
+
})
|
|
1258
|
+
.where(eq(mediaUploads.id, input.uploadId));
|
|
1259
|
+
return { ok: true as const, asset: null };
|
|
1260
|
+
},
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
const multipartPartSchema = z.object({
|
|
1264
|
+
partNumber: z.number().int().min(1).max(MAX_MULTIPART_PARTS),
|
|
1265
|
+
etag: z.string().trim().min(1).max(256),
|
|
1266
|
+
});
|
|
1267
|
+
|
|
1268
|
+
const completeUploadSource = defineService({
|
|
1269
|
+
name: "media.completeUploadSource",
|
|
1270
|
+
summary: "Authorize a direct upload before assembling and scanning stored bytes.",
|
|
1271
|
+
kind: "query",
|
|
1272
|
+
permission: "public",
|
|
1273
|
+
external: false,
|
|
1274
|
+
input: z.object({
|
|
1275
|
+
id: z.string().uuid(),
|
|
1276
|
+
parts: z.array(multipartPartSchema).min(1).max(MAX_MULTIPART_PARTS),
|
|
1277
|
+
}),
|
|
1278
|
+
output: z.union([
|
|
1279
|
+
z.object({ kind: z.literal("done"), result: completeUploadResult }),
|
|
1280
|
+
z.object({
|
|
1281
|
+
kind: z.literal("open"),
|
|
1282
|
+
id: uuid,
|
|
1283
|
+
storageKey: z.string(),
|
|
1284
|
+
filename: z.string(),
|
|
1285
|
+
declaredMime: z.string(),
|
|
1286
|
+
expectedBytes: z.number(),
|
|
1287
|
+
providerUploadId: z.string(),
|
|
1288
|
+
source: sourceSchema,
|
|
1289
|
+
provenance: provenanceSchema,
|
|
1290
|
+
metadata: mediaMetadataSchema,
|
|
1291
|
+
parts: z.array(multipartPartSchema),
|
|
1292
|
+
}),
|
|
1293
|
+
]),
|
|
1294
|
+
handler: async (input, ctx) => {
|
|
1295
|
+
const session = await uploadSession(ctx.tx, input.id);
|
|
1296
|
+
if (!session || session.strategy !== "direct_multipart") {
|
|
1297
|
+
throw new ServiceError("not_found", "That direct upload is not here.");
|
|
1298
|
+
}
|
|
1299
|
+
requireUploadAccess(ctx.actor, session.uploadedBy);
|
|
1300
|
+
if (session.state === "complete") {
|
|
1301
|
+
const asset = await assetForCompletedUpload(ctx.tx, session);
|
|
1302
|
+
if (asset) return { kind: "done" as const, result: { ok: true as const, asset } };
|
|
1303
|
+
const provenance = session.provenance as { captureToken?: string; captureSessionId?: string };
|
|
1304
|
+
if (provenance.captureToken || provenance.captureSessionId) {
|
|
1305
|
+
return { kind: "done" as const, result: { ok: true as const, asset: null } };
|
|
1306
|
+
}
|
|
1307
|
+
throw new ServiceError(
|
|
1308
|
+
"conflict",
|
|
1309
|
+
"That upload completed without a recoverable asset record.",
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
if (session.state === "failed") {
|
|
1313
|
+
return {
|
|
1314
|
+
kind: "done" as const,
|
|
1315
|
+
result: {
|
|
1316
|
+
ok: false as const,
|
|
1317
|
+
message: session.failureReason ?? "That upload failed validation.",
|
|
1318
|
+
},
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
if (session.expiresAt <= new Date()) {
|
|
1322
|
+
throw new ServiceError("conflict", "That upload reservation has expired.");
|
|
1323
|
+
}
|
|
1324
|
+
if (!["created", "uploading", "processing"].includes(session.state)) {
|
|
1325
|
+
throw new ServiceError("conflict", "That upload cannot be completed again.");
|
|
1326
|
+
}
|
|
1327
|
+
if (!session.providerUploadId) {
|
|
1328
|
+
throw new ServiceError("conflict", "Direct uploads are unavailable.");
|
|
1329
|
+
}
|
|
1330
|
+
const expectedParts = Math.ceil(session.expectedBytes / MULTIPART_PART_BYTES);
|
|
1331
|
+
const parts = [...input.parts].sort((a, b) => a.partNumber - b.partNumber);
|
|
1332
|
+
if (
|
|
1333
|
+
parts.length !== expectedParts ||
|
|
1334
|
+
parts.some((part, index) => part.partNumber !== index + 1)
|
|
1335
|
+
) {
|
|
1336
|
+
throw new ServiceError(
|
|
1337
|
+
"validation",
|
|
1338
|
+
`This file requires exactly ${expectedParts} ordered upload parts.`,
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
return {
|
|
1342
|
+
kind: "open" as const,
|
|
1343
|
+
id: session.id,
|
|
1344
|
+
storageKey: session.storageKey,
|
|
1345
|
+
filename: session.filename,
|
|
1346
|
+
declaredMime: session.declaredMime,
|
|
1347
|
+
expectedBytes: session.expectedBytes,
|
|
1348
|
+
providerUploadId: session.providerUploadId,
|
|
1349
|
+
source: session.source,
|
|
1350
|
+
provenance: session.provenance as z.output<typeof provenanceSchema>,
|
|
1351
|
+
metadata: session.mediaMetadata as z.output<typeof mediaMetadataSchema>,
|
|
1352
|
+
parts,
|
|
1353
|
+
};
|
|
1354
|
+
},
|
|
1355
|
+
});
|
|
1356
|
+
|
|
1357
|
+
export const completeUpload = defineOrchestratedService({
|
|
1358
|
+
name: "media.completeUpload",
|
|
1359
|
+
summary: "Assemble, validate, scan, and register a direct upload.",
|
|
1360
|
+
kind: "mutation",
|
|
1361
|
+
permission: "public",
|
|
1362
|
+
writeClass: "write",
|
|
1363
|
+
input: z.object({
|
|
1364
|
+
id: z.string().uuid(),
|
|
1365
|
+
parts: z.array(multipartPartSchema).min(1).max(MAX_MULTIPART_PARTS),
|
|
1366
|
+
altText: z.string().max(500).optional(),
|
|
1367
|
+
}),
|
|
1368
|
+
output: completeUploadResult,
|
|
1369
|
+
handler: async (input, actor) => {
|
|
1370
|
+
const source = await completeUploadSource.call(
|
|
1371
|
+
{ id: input.id, parts: input.parts },
|
|
1372
|
+
actor,
|
|
1373
|
+
);
|
|
1374
|
+
if (source.kind === "done") return source.result;
|
|
1375
|
+
const multipart = storage().directMultipart;
|
|
1376
|
+
if (!multipart) {
|
|
1377
|
+
throw new ServiceError("conflict", "Direct uploads are unavailable.");
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// If the object store completed the upload but the process died before the
|
|
1381
|
+
// database apply committed, HEAD turns the retry into recovery.
|
|
1382
|
+
const completed =
|
|
1383
|
+
(await storage().head(source.storageKey)) ??
|
|
1384
|
+
(await multipart.complete(
|
|
1385
|
+
source.storageKey,
|
|
1386
|
+
source.providerUploadId,
|
|
1387
|
+
source.parts,
|
|
1388
|
+
));
|
|
1389
|
+
const fail = async (message: string) => {
|
|
1390
|
+
await storage().delete(source.storageKey).catch(() => undefined);
|
|
1391
|
+
return failDirectUpload.call(
|
|
1392
|
+
{ id: source.id, storageKey: source.storageKey, message },
|
|
1393
|
+
actor,
|
|
1394
|
+
);
|
|
1395
|
+
};
|
|
1396
|
+
if (completed.bytes !== source.expectedBytes) {
|
|
1397
|
+
return fail(
|
|
1398
|
+
`The object store received ${completed.bytes} bytes; ${source.expectedBytes} were expected.`,
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
const prefix = await storage().readRange(
|
|
1403
|
+
source.storageKey,
|
|
1404
|
+
0,
|
|
1405
|
+
SIGNATURE_BYTES - 1,
|
|
1406
|
+
);
|
|
1407
|
+
const suffixStart = Math.max(0, completed.bytes - SIGNATURE_BYTES);
|
|
1408
|
+
const suffix = suffixStart > 0
|
|
1409
|
+
? await storage().readRange(
|
|
1410
|
+
source.storageKey,
|
|
1411
|
+
suffixStart,
|
|
1412
|
+
completed.bytes - 1,
|
|
1413
|
+
)
|
|
1414
|
+
: undefined;
|
|
1415
|
+
try {
|
|
1416
|
+
const validated = validateMediaFile({
|
|
1417
|
+
filename: source.filename,
|
|
1418
|
+
declaredMime: source.declaredMime,
|
|
1419
|
+
bytes: completed.bytes,
|
|
1420
|
+
prefix: mediaSignatureSample(
|
|
1421
|
+
prefix ?? new Uint8Array(),
|
|
1422
|
+
suffix ?? new Uint8Array(),
|
|
1423
|
+
),
|
|
1424
|
+
});
|
|
1425
|
+
const verified = await scanStoredAndHash(
|
|
1426
|
+
source.storageKey,
|
|
1427
|
+
source.filename,
|
|
1428
|
+
validated.mime,
|
|
1429
|
+
completed.bytes,
|
|
1430
|
+
);
|
|
1431
|
+
const provenance = source.provenance;
|
|
1432
|
+
if (provenance.captureToken || provenance.captureSessionId) {
|
|
1433
|
+
return applyCaptureComplete.call(
|
|
1434
|
+
{
|
|
1435
|
+
uploadId: source.id,
|
|
1436
|
+
token: provenance.captureToken,
|
|
1437
|
+
sessionId: provenance.captureSessionId,
|
|
1438
|
+
filename: source.filename,
|
|
1439
|
+
contentType: validated.mime,
|
|
1440
|
+
key: source.storageKey,
|
|
1441
|
+
bytes: completed.bytes,
|
|
1442
|
+
checksumSha256: verified.checksumSha256,
|
|
1443
|
+
detectedMime: validated.mime,
|
|
1444
|
+
},
|
|
1445
|
+
actor,
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
const prepared = await prepareDerivedObjects(
|
|
1449
|
+
{
|
|
1450
|
+
key: source.storageKey,
|
|
1451
|
+
kind: validated.kind,
|
|
1452
|
+
scan: verified.scan,
|
|
1453
|
+
uploadId: source.id,
|
|
1454
|
+
},
|
|
1455
|
+
await loadWatermarkMark(),
|
|
1456
|
+
);
|
|
1457
|
+
const asset = await applyStoredOriginal.call(
|
|
1458
|
+
{
|
|
1459
|
+
filename: source.filename,
|
|
1460
|
+
mime: validated.mime,
|
|
1461
|
+
kind: validated.kind,
|
|
1462
|
+
bytes: completed.bytes,
|
|
1463
|
+
key: source.storageKey,
|
|
1464
|
+
altText: input.altText,
|
|
1465
|
+
source: source.source,
|
|
1466
|
+
provenance,
|
|
1467
|
+
metadata: source.metadata,
|
|
1468
|
+
scan: verified.scan,
|
|
1469
|
+
checksumSha256: verified.checksumSha256,
|
|
1470
|
+
uploadId: source.id,
|
|
1471
|
+
method: "direct_multipart",
|
|
1472
|
+
variants: prepared.variants,
|
|
1473
|
+
trackedKeys: prepared.trackedKeys,
|
|
1474
|
+
width: prepared.facts?.width ?? null,
|
|
1475
|
+
height: prepared.facts?.height ?? null,
|
|
1476
|
+
},
|
|
1477
|
+
actor,
|
|
1478
|
+
);
|
|
1479
|
+
return { ok: true as const, asset };
|
|
1480
|
+
} catch (error) {
|
|
1481
|
+
if (error instanceof MediaValidationError) {
|
|
1482
|
+
return fail(error.message);
|
|
1483
|
+
}
|
|
1484
|
+
throw error;
|
|
1485
|
+
}
|
|
1486
|
+
},
|
|
1487
|
+
});
|
|
1488
|
+
|
|
1489
|
+
export const registerStoredOriginal = defineOrchestratedService({
|
|
1490
|
+
name: "media.registerStoredOriginal",
|
|
1491
|
+
summary: "Turn an already-stored original into a library Asset.",
|
|
1492
|
+
kind: "mutation",
|
|
1493
|
+
permission: "system",
|
|
1494
|
+
writeClass: "write",
|
|
1495
|
+
input: z.object({
|
|
1496
|
+
key: z.string().min(1).max(500),
|
|
1497
|
+
filename: z.string().min(1).max(255),
|
|
1498
|
+
contentType: z.string().min(1).max(255),
|
|
1499
|
+
bytes: z.number().int().positive(),
|
|
1500
|
+
altText: z.string().max(500).optional(),
|
|
1501
|
+
source: sourceSchema.default("capture"),
|
|
1502
|
+
provenance: provenanceSchema,
|
|
1503
|
+
metadata: mediaMetadataSchema,
|
|
1504
|
+
checksumSha256: z.string().length(64).optional(),
|
|
1505
|
+
}),
|
|
1506
|
+
output: assetRow,
|
|
1507
|
+
handler: async (input, actor) => {
|
|
1508
|
+
const head = await storage().head(input.key);
|
|
1509
|
+
if (!head) throw new ServiceError("not_found", "The staged file is gone.");
|
|
1510
|
+
const prefix = await storage().readRange(input.key, 0, SIGNATURE_BYTES - 1);
|
|
1511
|
+
const suffixStart = Math.max(0, input.bytes - SIGNATURE_BYTES);
|
|
1512
|
+
const suffix =
|
|
1513
|
+
suffixStart > 0
|
|
1514
|
+
? await storage().readRange(input.key, suffixStart, input.bytes - 1)
|
|
1515
|
+
: undefined;
|
|
1516
|
+
try {
|
|
1517
|
+
const validated = validateMediaFile({
|
|
1518
|
+
filename: input.filename,
|
|
1519
|
+
declaredMime: input.contentType,
|
|
1520
|
+
bytes: input.bytes,
|
|
1521
|
+
prefix: mediaSignatureSample(prefix ?? new Uint8Array(), suffix ?? new Uint8Array()),
|
|
1522
|
+
});
|
|
1523
|
+
const verified = await scanStoredAndHash(
|
|
1524
|
+
input.key,
|
|
1525
|
+
input.filename,
|
|
1526
|
+
validated.mime,
|
|
1527
|
+
input.bytes,
|
|
1528
|
+
);
|
|
1529
|
+
const prepared = await prepareDerivedObjects(
|
|
1530
|
+
{
|
|
1531
|
+
key: input.key,
|
|
1532
|
+
kind: validated.kind,
|
|
1533
|
+
scan: verified.scan,
|
|
1534
|
+
},
|
|
1535
|
+
await loadWatermarkMark(),
|
|
1536
|
+
);
|
|
1537
|
+
return applyStoredOriginal.call(
|
|
1538
|
+
{
|
|
1539
|
+
filename: input.filename,
|
|
1540
|
+
mime: validated.mime,
|
|
1541
|
+
kind: validated.kind,
|
|
1542
|
+
bytes: input.bytes,
|
|
1543
|
+
key: input.key,
|
|
1544
|
+
altText: input.altText,
|
|
1545
|
+
source: input.source,
|
|
1546
|
+
provenance: input.provenance,
|
|
1547
|
+
metadata: input.metadata,
|
|
1548
|
+
scan: verified.scan,
|
|
1549
|
+
checksumSha256: input.checksumSha256 ?? verified.checksumSha256,
|
|
1550
|
+
method: "proxy",
|
|
1551
|
+
variants: prepared.variants,
|
|
1552
|
+
trackedKeys: prepared.trackedKeys,
|
|
1553
|
+
width: prepared.facts?.width ?? null,
|
|
1554
|
+
height: prepared.facts?.height ?? null,
|
|
1555
|
+
},
|
|
1556
|
+
actor,
|
|
1557
|
+
);
|
|
1558
|
+
} catch (error) {
|
|
1559
|
+
return serviceValidation(error);
|
|
1560
|
+
}
|
|
1561
|
+
},
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
const abortUploadClaim = defineService({
|
|
1565
|
+
name: "media.abortUploadClaim",
|
|
1566
|
+
summary: "Mark an unfinished upload aborted before deleting provider bytes.",
|
|
1567
|
+
kind: "mutation",
|
|
1568
|
+
permission: "public",
|
|
1569
|
+
external: false,
|
|
1570
|
+
writeClass: "write",
|
|
1571
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1572
|
+
output: z.object({
|
|
1573
|
+
alreadyTerminal: z.boolean(),
|
|
1574
|
+
storageKey: z.string(),
|
|
1575
|
+
providerUploadId: z.string().nullable(),
|
|
1576
|
+
}),
|
|
1577
|
+
handler: async (input, ctx) => {
|
|
1578
|
+
const session = await lockedUploadSession(ctx.tx, input.id);
|
|
1579
|
+
if (!session) throw new ServiceError("not_found", "That upload is not here.");
|
|
1580
|
+
requireUploadAccess(ctx.actor, session.uploadedBy);
|
|
1581
|
+
if (["complete", "failed", "aborted", "expired"].includes(session.state)) {
|
|
1582
|
+
return {
|
|
1583
|
+
alreadyTerminal: true,
|
|
1584
|
+
storageKey: session.storageKey,
|
|
1585
|
+
providerUploadId: session.providerUploadId,
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
await ctx.tx
|
|
1589
|
+
.update(mediaUploads)
|
|
1590
|
+
.set({ state: "aborted", completedAt: new Date(), updatedAt: new Date() })
|
|
1591
|
+
.where(eq(mediaUploads.id, session.id));
|
|
1592
|
+
ctx.setSubject("mediaUpload", session.id);
|
|
1593
|
+
return {
|
|
1594
|
+
alreadyTerminal: false,
|
|
1595
|
+
storageKey: session.storageKey,
|
|
1596
|
+
providerUploadId: session.providerUploadId,
|
|
1597
|
+
};
|
|
1598
|
+
},
|
|
1599
|
+
});
|
|
1600
|
+
|
|
1601
|
+
const abortUploadApply = defineService({
|
|
1602
|
+
name: "media.abortUploadApply",
|
|
1603
|
+
summary: "Drop the staged object ledger after provider bytes are gone.",
|
|
1604
|
+
kind: "mutation",
|
|
1605
|
+
permission: "public",
|
|
1606
|
+
external: false,
|
|
1607
|
+
writeClass: "write",
|
|
1608
|
+
input: z.object({ id: z.string().uuid(), storageKey: z.string().min(1) }),
|
|
1609
|
+
output: okResult,
|
|
1610
|
+
handler: async (input, ctx) => {
|
|
1611
|
+
await ctx.tx.delete(mediaObjects).where(eq(mediaObjects.key, input.storageKey));
|
|
1612
|
+
ctx.setSubject("mediaUpload", input.id);
|
|
1613
|
+
return { ok: true };
|
|
1614
|
+
},
|
|
1615
|
+
});
|
|
1616
|
+
|
|
1617
|
+
export const abortUpload = defineOrchestratedService({
|
|
1618
|
+
name: "media.abortUpload",
|
|
1619
|
+
summary: "Abort an unfinished upload and remove its staged bytes.",
|
|
1620
|
+
kind: "mutation",
|
|
1621
|
+
permission: "public",
|
|
1622
|
+
writeClass: "write",
|
|
1623
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1624
|
+
output: okResult,
|
|
1625
|
+
handler: async (input, actor) => {
|
|
1626
|
+
const claimed = await abortUploadClaim.call(input, actor);
|
|
1627
|
+
if (claimed.alreadyTerminal) return { ok: true };
|
|
1628
|
+
const multipart = storage().directMultipart;
|
|
1629
|
+
if (multipart && claimed.providerUploadId) {
|
|
1630
|
+
await multipart.abort(claimed.storageKey, claimed.providerUploadId);
|
|
1631
|
+
}
|
|
1632
|
+
await storage().delete(claimed.storageKey);
|
|
1633
|
+
return abortUploadApply.call(
|
|
1634
|
+
{ id: input.id, storageKey: claimed.storageKey },
|
|
1635
|
+
actor,
|
|
1636
|
+
);
|
|
1637
|
+
},
|
|
1638
|
+
});
|
|
1639
|
+
|
|
1640
|
+
export const listAssets = defineService({
|
|
1641
|
+
name: "media.list",
|
|
1642
|
+
summary: "The asset library, newest first.",
|
|
1643
|
+
kind: "query",
|
|
1644
|
+
permission: "scoped",
|
|
1645
|
+
input: z.object({
|
|
1646
|
+
kind: z.enum(["image", "video", "doc", "audio"]).optional(),
|
|
1647
|
+
status: z
|
|
1648
|
+
.enum(["processing", "ready", "quarantined", "failed", "trashed"])
|
|
1649
|
+
.optional(),
|
|
1650
|
+
includeUnavailable: z.boolean().default(false),
|
|
1651
|
+
includeTrashed: z.boolean().default(false),
|
|
1652
|
+
limit: z.number().int().min(1).max(100).default(50),
|
|
1653
|
+
offset: z.number().int().min(0).default(0),
|
|
1654
|
+
}),
|
|
1655
|
+
output: z.object({
|
|
1656
|
+
rows: listed(assetRow),
|
|
1657
|
+
total: z.number(),
|
|
1658
|
+
}),
|
|
1659
|
+
handler: async (input, ctx) => {
|
|
1660
|
+
const visibility = input.status
|
|
1661
|
+
? eq(assets.status, input.status)
|
|
1662
|
+
: input.includeTrashed
|
|
1663
|
+
? undefined
|
|
1664
|
+
: input.includeUnavailable
|
|
1665
|
+
? ne(assets.status, "trashed")
|
|
1666
|
+
: eq(assets.status, "ready");
|
|
1667
|
+
const where = input.kind
|
|
1668
|
+
? and(eq(assets.kind, input.kind), visibility)
|
|
1669
|
+
: visibility;
|
|
1670
|
+
const rows = await ctx.tx
|
|
1671
|
+
.select()
|
|
1672
|
+
.from(assets)
|
|
1673
|
+
.where(where)
|
|
1674
|
+
.orderBy(desc(assets.createdAt))
|
|
1675
|
+
.limit(input.limit)
|
|
1676
|
+
.offset(input.offset);
|
|
1677
|
+
const [totals] = await ctx.tx
|
|
1678
|
+
.select({ n: count() })
|
|
1679
|
+
.from(assets)
|
|
1680
|
+
.where(where);
|
|
1681
|
+
return { rows, total: totals?.n ?? 0 };
|
|
1682
|
+
},
|
|
1683
|
+
});
|
|
1684
|
+
|
|
1685
|
+
export const getAsset = defineService({
|
|
1686
|
+
name: "media.get",
|
|
1687
|
+
summary: "One asset by id.",
|
|
1688
|
+
kind: "query",
|
|
1689
|
+
permission: "scoped",
|
|
1690
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1691
|
+
output: assetRow,
|
|
1692
|
+
handler: async (input, ctx) => {
|
|
1693
|
+
const [asset] = await ctx.tx
|
|
1694
|
+
.select()
|
|
1695
|
+
.from(assets)
|
|
1696
|
+
.where(eq(assets.id, input.id))
|
|
1697
|
+
.limit(1);
|
|
1698
|
+
if (!asset) throw new ServiceError("not_found", "That file is not here.");
|
|
1699
|
+
return asset;
|
|
1700
|
+
},
|
|
1701
|
+
});
|
|
1702
|
+
|
|
1703
|
+
export interface ResolvedSource {
|
|
1704
|
+
format: VariantFormat;
|
|
1705
|
+
/** A `srcset` value: "url 400w, url 800w". */
|
|
1706
|
+
srcset: string;
|
|
1707
|
+
type: string;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
export interface ResolvedImage {
|
|
1711
|
+
src: string;
|
|
1712
|
+
sources: ResolvedSource[];
|
|
1713
|
+
width: number | null;
|
|
1714
|
+
height: number | null;
|
|
1715
|
+
altText: string | null;
|
|
1716
|
+
/** The subject's position, basis points 0..10000 (§4.5 crop anchor). */
|
|
1717
|
+
focalX: number;
|
|
1718
|
+
focalY: number;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* Everything a public page needs to render an asset (§5, §36).
|
|
1723
|
+
*
|
|
1724
|
+
* Public, because it is what draws an image on a page a visitor is reading —
|
|
1725
|
+
* and it returns URLs rather than bytes, so a public bucket is served straight
|
|
1726
|
+
* from the CDN and a private one through a signed link, without the caller
|
|
1727
|
+
* knowing which it is.
|
|
1728
|
+
*/
|
|
1729
|
+
export const resolveImage = defineService({
|
|
1730
|
+
name: "media.resolveImage",
|
|
1731
|
+
summary: "URLs and dimensions for rendering one image.",
|
|
1732
|
+
kind: "query",
|
|
1733
|
+
permission: "public",
|
|
1734
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1735
|
+
output: z
|
|
1736
|
+
.object({
|
|
1737
|
+
src: z.string(),
|
|
1738
|
+
sources: listed(
|
|
1739
|
+
z.object({
|
|
1740
|
+
format: z.string(),
|
|
1741
|
+
srcset: z.string(),
|
|
1742
|
+
type: z.string(),
|
|
1743
|
+
}),
|
|
1744
|
+
),
|
|
1745
|
+
width: z.number().int().nullable(),
|
|
1746
|
+
height: z.number().int().nullable(),
|
|
1747
|
+
altText: z.string().nullable(),
|
|
1748
|
+
focalX: z.number().int(),
|
|
1749
|
+
focalY: z.number().int(),
|
|
1750
|
+
})
|
|
1751
|
+
.nullable(),
|
|
1752
|
+
handler: async (input, ctx): Promise<ResolvedImage | null> => {
|
|
1753
|
+
const [asset] = await ctx.tx
|
|
1754
|
+
.select()
|
|
1755
|
+
.from(assets)
|
|
1756
|
+
.where(eq(assets.id, input.id))
|
|
1757
|
+
.limit(1);
|
|
1758
|
+
// Null rather than an error: a block pointing at a deleted asset should
|
|
1759
|
+
// leave a gap in a page, never take the page down.
|
|
1760
|
+
if (!asset || asset.kind !== "image" || asset.status !== "ready") return null;
|
|
1761
|
+
if (asset.isPrivate) {
|
|
1762
|
+
try { await ctx.call(privateAssetDownloadAccess, {}); }
|
|
1763
|
+
catch (error) { if (error instanceof ServiceError && error.code === "permission") return null; throw error; }
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
const store = storage();
|
|
1767
|
+
const variants = asset.variants as VariantSet;
|
|
1768
|
+
const sources: ResolvedSource[] = [];
|
|
1769
|
+
// publicRenditions, not Object.entries: a watermarked rendition is stored
|
|
1770
|
+
// on the same row and must never become a source on a public page.
|
|
1771
|
+
for (const [format, renditions] of publicRenditions(variants)) {
|
|
1772
|
+
const entries = await Promise.all(
|
|
1773
|
+
renditions.map(async (r) => `${await store.url(r.key)} ${r.width}w`),
|
|
1774
|
+
);
|
|
1775
|
+
sources.push({
|
|
1776
|
+
format,
|
|
1777
|
+
srcset: entries.join(", "),
|
|
1778
|
+
type: `image/${format}`,
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
return {
|
|
1783
|
+
src: await store.url(asset.storageKey, { contentType: asset.mime }),
|
|
1784
|
+
sources,
|
|
1785
|
+
width: asset.width,
|
|
1786
|
+
height: asset.height,
|
|
1787
|
+
altText: asset.altText,
|
|
1788
|
+
focalX: asset.focalX,
|
|
1789
|
+
focalY: asset.focalY,
|
|
1790
|
+
};
|
|
1791
|
+
},
|
|
1792
|
+
});
|
|
1793
|
+
|
|
1794
|
+
export interface ResolvedAsset {
|
|
1795
|
+
id: string;
|
|
1796
|
+
kind: "video" | "doc" | "audio";
|
|
1797
|
+
src: string;
|
|
1798
|
+
mime: string;
|
|
1799
|
+
filename: string;
|
|
1800
|
+
bytes: number;
|
|
1801
|
+
width: number | null;
|
|
1802
|
+
height: number | null;
|
|
1803
|
+
durationSeconds: number | null;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
/** Ready non-image media for a public block or an owner preview. */
|
|
1807
|
+
export const resolveAsset = defineService({
|
|
1808
|
+
name: "media.resolveAsset",
|
|
1809
|
+
summary: "Resolve a ready video, audio file, or document.",
|
|
1810
|
+
kind: "query",
|
|
1811
|
+
permission: "public",
|
|
1812
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1813
|
+
output: z
|
|
1814
|
+
.object({
|
|
1815
|
+
id: uuid,
|
|
1816
|
+
kind: z.enum(["video", "doc", "audio"]),
|
|
1817
|
+
src: z.string(),
|
|
1818
|
+
mime: z.string(),
|
|
1819
|
+
filename: z.string(),
|
|
1820
|
+
bytes: z.number(),
|
|
1821
|
+
width: z.number().int().nullable(),
|
|
1822
|
+
height: z.number().int().nullable(),
|
|
1823
|
+
durationSeconds: z.number().int().nullable(),
|
|
1824
|
+
})
|
|
1825
|
+
.nullable(),
|
|
1826
|
+
handler: async (input, ctx): Promise<ResolvedAsset | null> => {
|
|
1827
|
+
const [asset] = await ctx.tx
|
|
1828
|
+
.select()
|
|
1829
|
+
.from(assets)
|
|
1830
|
+
.where(eq(assets.id, input.id))
|
|
1831
|
+
.limit(1);
|
|
1832
|
+
if (!asset || asset.kind === "image" || asset.status !== "ready") return null;
|
|
1833
|
+
if (asset.isPrivate) {
|
|
1834
|
+
try { await ctx.call(privateAssetDownloadAccess, {}); }
|
|
1835
|
+
catch (error) { if (error instanceof ServiceError && error.code === "permission") return null; throw error; }
|
|
1836
|
+
}
|
|
1837
|
+
return {
|
|
1838
|
+
id: asset.id,
|
|
1839
|
+
kind: asset.kind,
|
|
1840
|
+
src:
|
|
1841
|
+
asset.kind === "doc"
|
|
1842
|
+
? `/media/download/${asset.id}`
|
|
1843
|
+
: await storage().url(asset.storageKey, { contentType: asset.mime }),
|
|
1844
|
+
mime: asset.mime,
|
|
1845
|
+
filename: asset.filename,
|
|
1846
|
+
bytes: asset.bytes,
|
|
1847
|
+
width: asset.width,
|
|
1848
|
+
height: asset.height,
|
|
1849
|
+
durationSeconds: asset.durationSeconds,
|
|
1850
|
+
};
|
|
1851
|
+
},
|
|
1852
|
+
});
|
|
1853
|
+
|
|
1854
|
+
const privateAssetDownloadAccess = defineService({
|
|
1855
|
+
name: "media.privateAssetDownloadAccess", summary: "Require library access before downloading a private client asset.", kind: "query", permission: "scoped", external: false,
|
|
1856
|
+
input: z.object({}), output: z.object({ allowed: z.literal(true) }), handler: async () => ({ allowed: true as const }),
|
|
1857
|
+
});
|
|
1858
|
+
|
|
1859
|
+
export const authorizeAssetDownload = defineService({
|
|
1860
|
+
name: "media.authorizeAssetDownload",
|
|
1861
|
+
summary: "Authorize a public file or a staff download of a private client document.",
|
|
1862
|
+
kind: "query",
|
|
1863
|
+
permission: "public",
|
|
1864
|
+
input: z.object({ id: z.string().uuid() }),
|
|
1865
|
+
output: row({
|
|
1866
|
+
storageKey: z.string(),
|
|
1867
|
+
filename: z.string(),
|
|
1868
|
+
mime: z.string(),
|
|
1869
|
+
bytes: z.number(),
|
|
1870
|
+
}).nullable(),
|
|
1871
|
+
handler: async (input, ctx) => {
|
|
1872
|
+
const [asset] = await ctx.tx
|
|
1873
|
+
.select({
|
|
1874
|
+
isPrivate: assets.isPrivate,
|
|
1875
|
+
storageKey: assets.storageKey,
|
|
1876
|
+
filename: assets.filename,
|
|
1877
|
+
mime: assets.mime,
|
|
1878
|
+
bytes: assets.bytes,
|
|
1879
|
+
})
|
|
1880
|
+
.from(assets)
|
|
1881
|
+
.where(
|
|
1882
|
+
and(
|
|
1883
|
+
eq(assets.id, input.id),
|
|
1884
|
+
eq(assets.kind, "doc"),
|
|
1885
|
+
eq(assets.status, "ready"),
|
|
1886
|
+
),
|
|
1887
|
+
)
|
|
1888
|
+
.limit(1);
|
|
1889
|
+
if (asset?.isPrivate) await ctx.call(privateAssetDownloadAccess, {});
|
|
1890
|
+
if (!asset) return null;
|
|
1891
|
+
const { isPrivate: _private, ...safe } = asset;
|
|
1892
|
+
return safe;
|
|
1893
|
+
},
|
|
1894
|
+
});
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* The app-served storage route asks this before returning any bytes. A known
|
|
1898
|
+
* URL therefore stops working as soon as an asset is trashed or quarantined.
|
|
1899
|
+
*/
|
|
1900
|
+
export const authorizeObjectDelivery = defineService({
|
|
1901
|
+
name: "media.authorizeObjectDelivery",
|
|
1902
|
+
summary: "Authorize delivery of one ready asset object.",
|
|
1903
|
+
kind: "query",
|
|
1904
|
+
permission: "public",
|
|
1905
|
+
input: z.object({
|
|
1906
|
+
key: z
|
|
1907
|
+
.string()
|
|
1908
|
+
.min(1)
|
|
1909
|
+
.max(1_024)
|
|
1910
|
+
.refine((key) => !key.includes("..") && !key.startsWith("/")),
|
|
1911
|
+
}),
|
|
1912
|
+
output: row({
|
|
1913
|
+
contentType: z.string(),
|
|
1914
|
+
filename: z.string(),
|
|
1915
|
+
kind: z.enum(["image", "video", "doc", "audio"]),
|
|
1916
|
+
}).nullable(),
|
|
1917
|
+
handler: async (input, ctx) => {
|
|
1918
|
+
const [object] = await ctx.tx
|
|
1919
|
+
.select({
|
|
1920
|
+
contentType: mediaObjects.contentType,
|
|
1921
|
+
filename: assets.filename,
|
|
1922
|
+
kind: assets.kind,
|
|
1923
|
+
})
|
|
1924
|
+
.from(mediaObjects)
|
|
1925
|
+
.innerJoin(assets, eq(mediaObjects.assetId, assets.id))
|
|
1926
|
+
.where(
|
|
1927
|
+
and(
|
|
1928
|
+
eq(mediaObjects.key, input.key),
|
|
1929
|
+
eq(mediaObjects.state, "attached"),
|
|
1930
|
+
eq(assets.status, "ready"),
|
|
1931
|
+
eq(assets.isPrivate, false),
|
|
1932
|
+
),
|
|
1933
|
+
)
|
|
1934
|
+
.limit(1);
|
|
1935
|
+
return object ?? null;
|
|
1936
|
+
},
|
|
1937
|
+
});
|
|
1938
|
+
|
|
1939
|
+
const watermarkBackfillSource = row({
|
|
1940
|
+
id: uuid,
|
|
1941
|
+
storageKey: z.string(),
|
|
1942
|
+
mime: z.string(),
|
|
1943
|
+
variants: z.unknown(),
|
|
1944
|
+
});
|
|
1945
|
+
|
|
1946
|
+
const watermarkedRendition = z.object({
|
|
1947
|
+
width: z.number().int().positive(),
|
|
1948
|
+
height: z.number().int().positive(),
|
|
1949
|
+
bytes: z.number(),
|
|
1950
|
+
key: z.string().min(1),
|
|
1951
|
+
});
|
|
1952
|
+
|
|
1953
|
+
function alreadyWatermarked(variants: unknown): boolean {
|
|
1954
|
+
return Boolean(
|
|
1955
|
+
variants && typeof variants === "object" && "watermarked" in variants,
|
|
1956
|
+
);
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
const listWatermarkBackfill = defineService({
|
|
1960
|
+
name: "media.listWatermarkBackfill",
|
|
1961
|
+
summary: "Snapshot unmarked ready images for one backfill batch.",
|
|
1962
|
+
kind: "query",
|
|
1963
|
+
permission: "system",
|
|
1964
|
+
input: z.object({ limit: z.number().int().min(1).max(100) }),
|
|
1965
|
+
output: listed(watermarkBackfillSource),
|
|
1966
|
+
handler: async (input, ctx) => {
|
|
1967
|
+
return ctx.tx
|
|
1968
|
+
.select({
|
|
1969
|
+
id: assets.id,
|
|
1970
|
+
storageKey: assets.storageKey,
|
|
1971
|
+
mime: assets.mime,
|
|
1972
|
+
variants: assets.variants,
|
|
1973
|
+
})
|
|
1974
|
+
.from(assets)
|
|
1975
|
+
.where(
|
|
1976
|
+
and(
|
|
1977
|
+
eq(assets.kind, "image"),
|
|
1978
|
+
eq(assets.status, "ready"),
|
|
1979
|
+
sql`not (${assets.variants} ? 'watermarked')`,
|
|
1980
|
+
),
|
|
1981
|
+
)
|
|
1982
|
+
.limit(input.limit);
|
|
1983
|
+
},
|
|
1984
|
+
});
|
|
1985
|
+
|
|
1986
|
+
const applyWatermarkBackfill = defineService({
|
|
1987
|
+
name: "media.applyWatermarkBackfill",
|
|
1988
|
+
summary: "Attach one asset's watermarked renditions after storage work.",
|
|
1989
|
+
kind: "mutation",
|
|
1990
|
+
permission: "system",
|
|
1991
|
+
writeClass: "write",
|
|
1992
|
+
input: z.object({
|
|
1993
|
+
id: uuid,
|
|
1994
|
+
storageKey: z.string().min(1),
|
|
1995
|
+
mime: z.string().min(1),
|
|
1996
|
+
variantKeys: z.array(z.string().min(1)).max(64),
|
|
1997
|
+
watermarked: z.object({
|
|
1998
|
+
avif: z.array(watermarkedRendition).optional(),
|
|
1999
|
+
webp: z.array(watermarkedRendition).optional(),
|
|
2000
|
+
}),
|
|
2001
|
+
}),
|
|
2002
|
+
output: z.object({ attached: z.boolean() }),
|
|
2003
|
+
handler: async (input, ctx) => {
|
|
2004
|
+
const [current] = await ctx.tx
|
|
2005
|
+
.select()
|
|
2006
|
+
.from(assets)
|
|
2007
|
+
.where(eq(assets.id, input.id))
|
|
2008
|
+
.limit(1)
|
|
2009
|
+
.for("update");
|
|
2010
|
+
if (
|
|
2011
|
+
!current ||
|
|
2012
|
+
current.status !== "ready" ||
|
|
2013
|
+
current.kind !== "image" ||
|
|
2014
|
+
current.storageKey !== input.storageKey ||
|
|
2015
|
+
current.mime !== input.mime ||
|
|
2016
|
+
alreadyWatermarked(current.variants)
|
|
2017
|
+
) {
|
|
2018
|
+
// Storage may already have written pending objects. Leave them
|
|
2019
|
+
// sweepable rather than attaching marks to a file that moved on.
|
|
2020
|
+
return { attached: false };
|
|
2021
|
+
}
|
|
2022
|
+
const currentSet = current.variants as VariantSet;
|
|
2023
|
+
if (input.variantKeys.length > 0) {
|
|
2024
|
+
await attachObjects(ctx.tx, input.variantKeys, current.id);
|
|
2025
|
+
}
|
|
2026
|
+
await ctx.tx
|
|
2027
|
+
.update(assets)
|
|
2028
|
+
.set({
|
|
2029
|
+
variants: { ...currentSet, watermarked: input.watermarked },
|
|
2030
|
+
updatedAt: new Date(),
|
|
2031
|
+
})
|
|
2032
|
+
.where(eq(assets.id, current.id));
|
|
2033
|
+
ctx.setSubject("asset", current.id);
|
|
2034
|
+
return { attached: input.variantKeys.length > 0 };
|
|
2035
|
+
},
|
|
2036
|
+
});
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* Add the marks that did not exist when a photograph was uploaded (C8.04).
|
|
2040
|
+
*
|
|
2041
|
+
* Watermarked renditions are built on upload, which leaves every image
|
|
2042
|
+
* already in the library unmarked — and a gallery that refuses to serve an
|
|
2043
|
+
* unmarked file would render an empty grid the first time an owner ticks
|
|
2044
|
+
* "watermark" on work they delivered last year. This walks that backlog a
|
|
2045
|
+
* batch at a time, one durable asset at a time: storage I/O is outside the
|
|
2046
|
+
* short list/apply transactions, and a losing apply leaves only sweepable
|
|
2047
|
+
* pending objects.
|
|
2048
|
+
*
|
|
2049
|
+
* An image that cannot be marked records an empty `watermarked` set rather
|
|
2050
|
+
* than nothing, so the next batch moves past it instead of retrying the
|
|
2051
|
+
* same unmarkable file forever.
|
|
2052
|
+
*/
|
|
2053
|
+
export const backfillWatermarks = defineOrchestratedService({
|
|
2054
|
+
name: "media.backfillWatermarks",
|
|
2055
|
+
summary: "Add missing watermarked renditions to images already in the library.",
|
|
2056
|
+
kind: "mutation",
|
|
2057
|
+
permission: "system",
|
|
2058
|
+
writeClass: "write",
|
|
2059
|
+
input: z.object({ limit: z.number().int().min(1).max(100).default(20) }),
|
|
2060
|
+
output: row({ marked: z.number().int(), skipped: z.number().int() }),
|
|
2061
|
+
handler: async (input, actor) => {
|
|
2062
|
+
const mark = await loadWatermarkMark();
|
|
2063
|
+
if (!mark) return { marked: 0, skipped: 0 };
|
|
2064
|
+
const candidates = await listWatermarkBackfill.call(
|
|
2065
|
+
{ limit: input.limit },
|
|
2066
|
+
actor,
|
|
2067
|
+
);
|
|
2068
|
+
|
|
2069
|
+
let marked = 0;
|
|
2070
|
+
let skipped = 0;
|
|
2071
|
+
for (const asset of candidates) {
|
|
2072
|
+
const body = isRasterImage(asset.mime)
|
|
2073
|
+
? await storage().get(asset.storageKey)
|
|
2074
|
+
: undefined;
|
|
2075
|
+
const facts = body ? await readImageFacts(body) : undefined;
|
|
2076
|
+
const built =
|
|
2077
|
+
body && facts
|
|
2078
|
+
? await buildWatermarked(body, facts, mark, (format, width) =>
|
|
2079
|
+
`${asset.storageKey}.wm.${width}.${format}`,
|
|
2080
|
+
)
|
|
2081
|
+
: [];
|
|
2082
|
+
if (built.length > 0) {
|
|
2083
|
+
await putTrackedObjects(
|
|
2084
|
+
built.map((rendition) => ({
|
|
2085
|
+
key: rendition.key,
|
|
2086
|
+
body: rendition.body,
|
|
2087
|
+
contentType: rendition.contentType,
|
|
2088
|
+
role: "variant" as const,
|
|
2089
|
+
})),
|
|
2090
|
+
);
|
|
2091
|
+
}
|
|
2092
|
+
const result = await applyWatermarkBackfill.call(
|
|
2093
|
+
{
|
|
2094
|
+
id: asset.id,
|
|
2095
|
+
storageKey: asset.storageKey,
|
|
2096
|
+
mime: asset.mime,
|
|
2097
|
+
variantKeys: built.map((rendition) => rendition.key),
|
|
2098
|
+
watermarked: withWatermarked({}, built).watermarked ?? {},
|
|
2099
|
+
},
|
|
2100
|
+
actor,
|
|
2101
|
+
);
|
|
2102
|
+
if (result.attached) marked += 1;
|
|
2103
|
+
else skipped += 1;
|
|
2104
|
+
}
|
|
2105
|
+
return { marked, skipped };
|
|
2106
|
+
},
|
|
2107
|
+
});
|
|
2108
|
+
|
|
2109
|
+
export const setAltText = defineService({
|
|
2110
|
+
name: "media.setAltText",
|
|
2111
|
+
summary: "Describe an image for people who cannot see it.",
|
|
2112
|
+
kind: "mutation",
|
|
2113
|
+
permission: "scoped",
|
|
2114
|
+
input: z.object({
|
|
2115
|
+
id: z.string().uuid(),
|
|
2116
|
+
altText: z.string().max(500),
|
|
2117
|
+
}),
|
|
2118
|
+
output: assetRow,
|
|
2119
|
+
handler: async (input, ctx) => {
|
|
2120
|
+
const [existing] = await ctx.tx
|
|
2121
|
+
.select({ kind: assets.kind })
|
|
2122
|
+
.from(assets)
|
|
2123
|
+
.where(eq(assets.id, input.id))
|
|
2124
|
+
.limit(1);
|
|
2125
|
+
if (!existing) throw new ServiceError("not_found", "That file is not here.");
|
|
2126
|
+
if (existing.kind !== "image") {
|
|
2127
|
+
throw new ServiceError("validation", "Only images use alternative text.");
|
|
2128
|
+
}
|
|
2129
|
+
const now = new Date();
|
|
2130
|
+
const [asset] = await ctx.tx
|
|
2131
|
+
.update(assets)
|
|
2132
|
+
.set({ altText: input.altText, updatedAt: now })
|
|
2133
|
+
.where(eq(assets.id, input.id))
|
|
2134
|
+
.returning();
|
|
2135
|
+
if (!asset) throw new ServiceError("not_found", "That file is not here.");
|
|
2136
|
+
// A person or agent authored new text outside the suggestion review. Any
|
|
2137
|
+
// proposal still on screen is now stale and may never overwrite it.
|
|
2138
|
+
await ctx.tx
|
|
2139
|
+
.update(mediaAltTextSuggestions)
|
|
2140
|
+
.set({
|
|
2141
|
+
status: "superseded",
|
|
2142
|
+
reviewedBy: actorString(ctx.actor),
|
|
2143
|
+
reviewedAt: now,
|
|
2144
|
+
updatedAt: now,
|
|
2145
|
+
})
|
|
2146
|
+
.where(
|
|
2147
|
+
and(
|
|
2148
|
+
eq(mediaAltTextSuggestions.assetId, asset.id),
|
|
2149
|
+
eq(mediaAltTextSuggestions.status, "ready"),
|
|
2150
|
+
),
|
|
2151
|
+
);
|
|
2152
|
+
ctx.setSubject("asset", asset.id);
|
|
2153
|
+
return asset;
|
|
2154
|
+
},
|
|
2155
|
+
});
|
|
2156
|
+
|
|
2157
|
+
function requireHumanReview(actor: Actor): void {
|
|
2158
|
+
if (actor.kind !== "user") {
|
|
2159
|
+
throw new ServiceError(
|
|
2160
|
+
"permission",
|
|
2161
|
+
"Sign in as a person to review generated alternative text.",
|
|
2162
|
+
);
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
type AltTextSuggestionSource = Pick<
|
|
2167
|
+
typeof assets.$inferSelect,
|
|
2168
|
+
"id" | "storageKey" | "mime" | "variants" | "checksumSha256" | "altText"
|
|
2169
|
+
>;
|
|
2170
|
+
|
|
2171
|
+
const altTextSuggestionSource = z.object({
|
|
2172
|
+
id: uuid,
|
|
2173
|
+
storageKey: z.string(),
|
|
2174
|
+
mime: z.string(),
|
|
2175
|
+
variants: z.unknown(),
|
|
2176
|
+
checksumSha256: z.string().nullable(),
|
|
2177
|
+
altText: z.string().nullable(),
|
|
2178
|
+
});
|
|
2179
|
+
|
|
2180
|
+
function sourceIdentity(asset: {
|
|
2181
|
+
checksumSha256: string | null;
|
|
2182
|
+
storageKey: string;
|
|
2183
|
+
}): string {
|
|
2184
|
+
return asset.checksumSha256 ?? `storage:${asset.storageKey}`;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
async function suggestionPreview(asset: AltTextSuggestionSource): Promise<{
|
|
2188
|
+
image: Uint8Array<ArrayBuffer>;
|
|
2189
|
+
contentType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
|
|
2190
|
+
}> {
|
|
2191
|
+
const variants = asset.variants as VariantSet;
|
|
2192
|
+
const webp = variants.webp ?? [];
|
|
2193
|
+
const rendition = webp.find((candidate) => candidate.width >= 800) ?? webp.at(-1);
|
|
2194
|
+
if (rendition) {
|
|
2195
|
+
const image = await storage().get(rendition.key);
|
|
2196
|
+
if (image) return { image, contentType: "image/webp" };
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
const supported = ["image/jpeg", "image/png", "image/gif", "image/webp"] as const;
|
|
2200
|
+
const contentType = supported.find((candidate) => candidate === asset.mime);
|
|
2201
|
+
if (!contentType) {
|
|
2202
|
+
throw new ServiceError(
|
|
2203
|
+
"conflict",
|
|
2204
|
+
"This image has no safe provider-compatible preview. Rescan it to rebuild renditions, then try again.",
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
const image = await storage().get(asset.storageKey);
|
|
2208
|
+
if (!image) throw new ServiceError("not_found", "That image file is missing.");
|
|
2209
|
+
return { image, contentType };
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
/** Provider readiness plus the one proposal awaiting a person's decision. */
|
|
2213
|
+
export const altTextSuggestionState = defineService({
|
|
2214
|
+
name: "media.altTextSuggestionState",
|
|
2215
|
+
summary: "Show provider readiness and the pending alt-text suggestion.",
|
|
2216
|
+
kind: "query",
|
|
2217
|
+
permission: "scoped",
|
|
2218
|
+
input: z.object({ id: z.string().uuid() }),
|
|
2219
|
+
output: z.object({
|
|
2220
|
+
...suggestionProviderState,
|
|
2221
|
+
suggestion: suggestionRow.nullable(),
|
|
2222
|
+
}),
|
|
2223
|
+
handler: async (input, ctx) => {
|
|
2224
|
+
const [asset] = await ctx.tx
|
|
2225
|
+
.select({ id: assets.id, kind: assets.kind })
|
|
2226
|
+
.from(assets)
|
|
2227
|
+
.where(eq(assets.id, input.id))
|
|
2228
|
+
.limit(1);
|
|
2229
|
+
if (!asset) throw new ServiceError("not_found", "That file is not here.");
|
|
2230
|
+
if (asset.kind !== "image") {
|
|
2231
|
+
throw new ServiceError("validation", "Only images use alternative text.");
|
|
2232
|
+
}
|
|
2233
|
+
const [suggestion] = await ctx.tx
|
|
2234
|
+
.select()
|
|
2235
|
+
.from(mediaAltTextSuggestions)
|
|
2236
|
+
.where(
|
|
2237
|
+
and(
|
|
2238
|
+
eq(mediaAltTextSuggestions.assetId, asset.id),
|
|
2239
|
+
eq(mediaAltTextSuggestions.status, "ready"),
|
|
2240
|
+
),
|
|
2241
|
+
)
|
|
2242
|
+
.orderBy(desc(mediaAltTextSuggestions.createdAt))
|
|
2243
|
+
.limit(1);
|
|
2244
|
+
const provider = altTextSuggester();
|
|
2245
|
+
return {
|
|
2246
|
+
available: provider.available,
|
|
2247
|
+
provider: provider.id,
|
|
2248
|
+
model: provider.model ?? null,
|
|
2249
|
+
unavailableReason: provider.unavailableReason ?? null,
|
|
2250
|
+
suggestion: suggestion ?? null,
|
|
2251
|
+
};
|
|
2252
|
+
},
|
|
2253
|
+
});
|
|
2254
|
+
|
|
2255
|
+
/** One provider status and pending proposals for a media-library page. */
|
|
2256
|
+
export const listAltTextSuggestionStates = defineService({
|
|
2257
|
+
name: "media.listAltTextSuggestionStates",
|
|
2258
|
+
summary: "List pending alt-text suggestions for a set of images.",
|
|
2259
|
+
kind: "query",
|
|
2260
|
+
permission: "scoped",
|
|
2261
|
+
input: z.object({
|
|
2262
|
+
ids: z.array(z.string().uuid()).min(1).max(100),
|
|
2263
|
+
}),
|
|
2264
|
+
output: z.object({
|
|
2265
|
+
...suggestionProviderState,
|
|
2266
|
+
suggestions: listed(suggestionRow),
|
|
2267
|
+
}),
|
|
2268
|
+
handler: async (input, ctx) => {
|
|
2269
|
+
const suggestions = await ctx.tx
|
|
2270
|
+
.select()
|
|
2271
|
+
.from(mediaAltTextSuggestions)
|
|
2272
|
+
.where(
|
|
2273
|
+
and(
|
|
2274
|
+
inArray(mediaAltTextSuggestions.assetId, input.ids),
|
|
2275
|
+
eq(mediaAltTextSuggestions.status, "ready"),
|
|
2276
|
+
),
|
|
2277
|
+
)
|
|
2278
|
+
.orderBy(desc(mediaAltTextSuggestions.createdAt));
|
|
2279
|
+
const provider = altTextSuggester();
|
|
2280
|
+
return {
|
|
2281
|
+
available: provider.available,
|
|
2282
|
+
provider: provider.id,
|
|
2283
|
+
model: provider.model ?? null,
|
|
2284
|
+
unavailableReason: provider.unavailableReason ?? null,
|
|
2285
|
+
suggestions,
|
|
2286
|
+
};
|
|
2287
|
+
},
|
|
2288
|
+
});
|
|
2289
|
+
|
|
2290
|
+
/**
|
|
2291
|
+
* Generate only a proposal. This operation cannot write `assets.alt_text` and
|
|
2292
|
+
* is unavailable to API keys because each call can have provider cost and the
|
|
2293
|
+
* workflow is intentionally initiated by a person looking at the image.
|
|
2294
|
+
*/
|
|
2295
|
+
const altTextSuggestionSourceService = defineService({
|
|
2296
|
+
name: "media.altTextSuggestionSource",
|
|
2297
|
+
summary: "Authorize and snapshot an image before provider-assisted alt-text generation.",
|
|
2298
|
+
kind: "query",
|
|
2299
|
+
permission: "scoped",
|
|
2300
|
+
agentCallable: false,
|
|
2301
|
+
external: false,
|
|
2302
|
+
input: z.object({ id: z.string().uuid() }),
|
|
2303
|
+
output: altTextSuggestionSource,
|
|
2304
|
+
handler: async (input, ctx) => {
|
|
2305
|
+
requireHumanReview(ctx.actor);
|
|
2306
|
+
const [asset] = await ctx.tx
|
|
2307
|
+
.select()
|
|
2308
|
+
.from(assets)
|
|
2309
|
+
.where(eq(assets.id, input.id))
|
|
2310
|
+
.limit(1);
|
|
2311
|
+
if (!asset || asset.status === "trashed") {
|
|
2312
|
+
throw new ServiceError("not_found", "That image is not here.");
|
|
2313
|
+
}
|
|
2314
|
+
if (asset.kind !== "image" || asset.status !== "ready") {
|
|
2315
|
+
throw new ServiceError(
|
|
2316
|
+
"conflict",
|
|
2317
|
+
"Only a ready, verified image can be sent for an alt-text suggestion.",
|
|
2318
|
+
);
|
|
2319
|
+
}
|
|
2320
|
+
return asset;
|
|
2321
|
+
},
|
|
2322
|
+
});
|
|
2323
|
+
|
|
2324
|
+
const applyAltTextSuggestion = defineService({
|
|
2325
|
+
name: "media.applyAltTextSuggestion",
|
|
2326
|
+
summary: "Revalidate an image and atomically store a provider-generated alt-text proposal.",
|
|
2327
|
+
kind: "mutation",
|
|
2328
|
+
permission: "scoped",
|
|
2329
|
+
agentCallable: false,
|
|
2330
|
+
external: false,
|
|
2331
|
+
writeClass: "write",
|
|
2332
|
+
input: z.object({
|
|
2333
|
+
id: z.string().uuid(),
|
|
2334
|
+
suggestion: z.string().trim().min(1).max(500),
|
|
2335
|
+
provider: z.string().min(1),
|
|
2336
|
+
model: z.string().min(1),
|
|
2337
|
+
sourceChecksum: z.string().min(1),
|
|
2338
|
+
authoredAltTextAtRequest: z.string().nullable(),
|
|
2339
|
+
}),
|
|
2340
|
+
output: suggestionRow,
|
|
2341
|
+
handler: async (input, ctx) => {
|
|
2342
|
+
requireHumanReview(ctx.actor);
|
|
2343
|
+
const now = new Date();
|
|
2344
|
+
const reviewer = actorString(ctx.actor);
|
|
2345
|
+
// The provider runs outside this transaction. Re-lock and compare its
|
|
2346
|
+
// source snapshot so newer image bytes or authored text always win.
|
|
2347
|
+
const [currentAsset] = await ctx.tx
|
|
2348
|
+
.select()
|
|
2349
|
+
.from(assets)
|
|
2350
|
+
.where(eq(assets.id, input.id))
|
|
2351
|
+
.limit(1)
|
|
2352
|
+
.for("update");
|
|
2353
|
+
if (
|
|
2354
|
+
!currentAsset ||
|
|
2355
|
+
currentAsset.status !== "ready" ||
|
|
2356
|
+
currentAsset.kind !== "image" ||
|
|
2357
|
+
sourceIdentity(currentAsset) !== input.sourceChecksum ||
|
|
2358
|
+
currentAsset.altText !== input.authoredAltTextAtRequest
|
|
2359
|
+
) {
|
|
2360
|
+
throw new ServiceError(
|
|
2361
|
+
"conflict",
|
|
2362
|
+
"The image or its authored alt text changed while the suggestion was generated. Nothing was overwritten; try again from the current image.",
|
|
2363
|
+
);
|
|
2364
|
+
}
|
|
2365
|
+
await ctx.tx
|
|
2366
|
+
.update(mediaAltTextSuggestions)
|
|
2367
|
+
.set({
|
|
2368
|
+
status: "superseded",
|
|
2369
|
+
reviewedBy: reviewer,
|
|
2370
|
+
reviewedAt: now,
|
|
2371
|
+
updatedAt: now,
|
|
2372
|
+
})
|
|
2373
|
+
.where(
|
|
2374
|
+
and(
|
|
2375
|
+
eq(mediaAltTextSuggestions.assetId, currentAsset.id),
|
|
2376
|
+
eq(mediaAltTextSuggestions.status, "ready"),
|
|
2377
|
+
),
|
|
2378
|
+
);
|
|
2379
|
+
const [stored] = await ctx.tx
|
|
2380
|
+
.insert(mediaAltTextSuggestions)
|
|
2381
|
+
.values({
|
|
2382
|
+
assetId: currentAsset.id,
|
|
2383
|
+
suggestion: input.suggestion,
|
|
2384
|
+
provider: input.provider,
|
|
2385
|
+
model: input.model,
|
|
2386
|
+
promptVersion: ALT_TEXT_PROMPT_VERSION,
|
|
2387
|
+
sourceChecksum: input.sourceChecksum,
|
|
2388
|
+
authoredAltTextAtRequest: input.authoredAltTextAtRequest,
|
|
2389
|
+
requestedBy: reviewer,
|
|
2390
|
+
})
|
|
2391
|
+
.returning();
|
|
2392
|
+
ctx.setSubject("asset", currentAsset.id);
|
|
2393
|
+
ctx.queueEvent("media.altTextSuggested", {
|
|
2394
|
+
assetId: currentAsset.id,
|
|
2395
|
+
suggestionId: stored!.id,
|
|
2396
|
+
provider: stored!.provider,
|
|
2397
|
+
model: stored!.model,
|
|
2398
|
+
});
|
|
2399
|
+
return stored!;
|
|
2400
|
+
},
|
|
2401
|
+
});
|
|
2402
|
+
|
|
2403
|
+
export const generateAltTextSuggestion = defineOrchestratedService({
|
|
2404
|
+
name: "media.generateAltTextSuggestion",
|
|
2405
|
+
summary: "Generate an image description for explicit human review.",
|
|
2406
|
+
kind: "mutation",
|
|
2407
|
+
permission: "scoped",
|
|
2408
|
+
agentCallable: false,
|
|
2409
|
+
writeClass: "write",
|
|
2410
|
+
rateLimit: {
|
|
2411
|
+
windowSeconds: 60 * 60,
|
|
2412
|
+
limit: 5,
|
|
2413
|
+
subject: (input) => input.id,
|
|
2414
|
+
message: "That image has had several suggestions generated recently. Review one or try again later.",
|
|
2415
|
+
},
|
|
2416
|
+
input: z.object({ id: z.string().uuid() }),
|
|
2417
|
+
output: suggestionRow,
|
|
2418
|
+
handler: async (input, actor) => {
|
|
2419
|
+
requireHumanReview(actor);
|
|
2420
|
+
const asset = await altTextSuggestionSourceService.call(input, actor);
|
|
2421
|
+
const provider = altTextSuggester();
|
|
2422
|
+
if (!provider.available) {
|
|
2423
|
+
throw new ServiceError(
|
|
2424
|
+
"conflict",
|
|
2425
|
+
provider.unavailableReason ?? "Generated alt text is not configured.",
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
const preview = await suggestionPreview(asset);
|
|
2429
|
+
let generated;
|
|
2430
|
+
try {
|
|
2431
|
+
generated = await provider.suggest(preview);
|
|
2432
|
+
} catch (error) {
|
|
2433
|
+
if (error instanceof AltTextSuggestionError) {
|
|
2434
|
+
throw new ServiceError("conflict", error.message);
|
|
2435
|
+
}
|
|
2436
|
+
throw new ServiceError(
|
|
2437
|
+
"conflict",
|
|
2438
|
+
"The alt-text provider could not produce a suggestion. Try again in a moment.",
|
|
2439
|
+
);
|
|
2440
|
+
}
|
|
2441
|
+
const suggestion = generated.text.replace(/\s+/g, " ").trim();
|
|
2442
|
+
if (!suggestion || suggestion.length > 500) {
|
|
2443
|
+
throw new ServiceError(
|
|
2444
|
+
"conflict",
|
|
2445
|
+
"The provider returned a suggestion that cannot be reviewed safely.",
|
|
2446
|
+
);
|
|
2447
|
+
}
|
|
2448
|
+
return applyAltTextSuggestion.call(
|
|
2449
|
+
{
|
|
2450
|
+
id: asset.id,
|
|
2451
|
+
suggestion,
|
|
2452
|
+
provider: generated.provider,
|
|
2453
|
+
model: generated.model,
|
|
2454
|
+
sourceChecksum: sourceIdentity(asset),
|
|
2455
|
+
authoredAltTextAtRequest: asset.altText,
|
|
2456
|
+
},
|
|
2457
|
+
actor,
|
|
2458
|
+
);
|
|
2459
|
+
},
|
|
2460
|
+
});
|
|
2461
|
+
|
|
2462
|
+
export const acceptAltTextSuggestion = defineService({
|
|
2463
|
+
name: "media.acceptAltTextSuggestion",
|
|
2464
|
+
summary: "Accept or edit a generated image description after human review.",
|
|
2465
|
+
kind: "mutation",
|
|
2466
|
+
permission: "scoped",
|
|
2467
|
+
agentCallable: false,
|
|
2468
|
+
input: z.object({
|
|
2469
|
+
id: z.string().uuid(),
|
|
2470
|
+
suggestionId: z.string().uuid(),
|
|
2471
|
+
altText: z.string().trim().min(1).max(500),
|
|
2472
|
+
}),
|
|
2473
|
+
output: assetRow,
|
|
2474
|
+
handler: async (input, ctx) => {
|
|
2475
|
+
requireHumanReview(ctx.actor);
|
|
2476
|
+
const [asset] = await ctx.tx
|
|
2477
|
+
.select()
|
|
2478
|
+
.from(assets)
|
|
2479
|
+
.where(eq(assets.id, input.id))
|
|
2480
|
+
.limit(1)
|
|
2481
|
+
.for("update");
|
|
2482
|
+
const [suggestion] = await ctx.tx
|
|
2483
|
+
.select()
|
|
2484
|
+
.from(mediaAltTextSuggestions)
|
|
2485
|
+
.where(eq(mediaAltTextSuggestions.id, input.suggestionId))
|
|
2486
|
+
.limit(1)
|
|
2487
|
+
.for("update");
|
|
2488
|
+
if (!asset || asset.kind !== "image" || suggestion?.assetId !== asset.id) {
|
|
2489
|
+
throw new ServiceError("not_found", "That alt-text suggestion is not here.");
|
|
2490
|
+
}
|
|
2491
|
+
if (asset.status !== "ready") {
|
|
2492
|
+
throw new ServiceError(
|
|
2493
|
+
"conflict",
|
|
2494
|
+
"Only a ready, verified image can receive reviewed alternative text.",
|
|
2495
|
+
);
|
|
2496
|
+
}
|
|
2497
|
+
if (suggestion.status !== "ready") {
|
|
2498
|
+
throw new ServiceError("conflict", "That suggestion has already been reviewed.");
|
|
2499
|
+
}
|
|
2500
|
+
if (
|
|
2501
|
+
suggestion.sourceChecksum !== sourceIdentity(asset) ||
|
|
2502
|
+
suggestion.authoredAltTextAtRequest !== asset.altText
|
|
2503
|
+
) {
|
|
2504
|
+
throw new ServiceError(
|
|
2505
|
+
"conflict",
|
|
2506
|
+
"The image or its authored alt text changed after this suggestion was generated. Generate a fresh suggestion instead.",
|
|
2507
|
+
);
|
|
2508
|
+
}
|
|
2509
|
+
const now = new Date();
|
|
2510
|
+
const reviewer = actorString(ctx.actor);
|
|
2511
|
+
const [updated] = await ctx.tx
|
|
2512
|
+
.update(assets)
|
|
2513
|
+
.set({ altText: input.altText, updatedAt: now })
|
|
2514
|
+
.where(eq(assets.id, asset.id))
|
|
2515
|
+
.returning();
|
|
2516
|
+
await ctx.tx
|
|
2517
|
+
.update(mediaAltTextSuggestions)
|
|
2518
|
+
.set({
|
|
2519
|
+
status: "accepted",
|
|
2520
|
+
reviewedBy: reviewer,
|
|
2521
|
+
reviewedAt: now,
|
|
2522
|
+
updatedAt: now,
|
|
2523
|
+
})
|
|
2524
|
+
.where(eq(mediaAltTextSuggestions.id, suggestion.id));
|
|
2525
|
+
ctx.setSubject("asset", asset.id);
|
|
2526
|
+
ctx.queueEvent("media.altTextAccepted", {
|
|
2527
|
+
assetId: asset.id,
|
|
2528
|
+
suggestionId: suggestion.id,
|
|
2529
|
+
edited: input.altText !== suggestion.suggestion,
|
|
2530
|
+
});
|
|
2531
|
+
return updated!;
|
|
2532
|
+
},
|
|
2533
|
+
});
|
|
2534
|
+
|
|
2535
|
+
export const dismissAltTextSuggestion = defineService({
|
|
2536
|
+
name: "media.dismissAltTextSuggestion",
|
|
2537
|
+
summary: "Dismiss a generated image description after human review.",
|
|
2538
|
+
kind: "mutation",
|
|
2539
|
+
permission: "scoped",
|
|
2540
|
+
agentCallable: false,
|
|
2541
|
+
input: z.object({ id: z.string().uuid(), suggestionId: z.string().uuid() }),
|
|
2542
|
+
output: okResult,
|
|
2543
|
+
handler: async (input, ctx) => {
|
|
2544
|
+
requireHumanReview(ctx.actor);
|
|
2545
|
+
const [suggestion] = await ctx.tx
|
|
2546
|
+
.select()
|
|
2547
|
+
.from(mediaAltTextSuggestions)
|
|
2548
|
+
.where(eq(mediaAltTextSuggestions.id, input.suggestionId))
|
|
2549
|
+
.limit(1)
|
|
2550
|
+
.for("update");
|
|
2551
|
+
if (suggestion?.assetId !== input.id || suggestion.status !== "ready") {
|
|
2552
|
+
throw new ServiceError("not_found", "That pending suggestion is not here.");
|
|
2553
|
+
}
|
|
2554
|
+
const now = new Date();
|
|
2555
|
+
await ctx.tx
|
|
2556
|
+
.update(mediaAltTextSuggestions)
|
|
2557
|
+
.set({
|
|
2558
|
+
status: "dismissed",
|
|
2559
|
+
reviewedBy: actorString(ctx.actor),
|
|
2560
|
+
reviewedAt: now,
|
|
2561
|
+
updatedAt: now,
|
|
2562
|
+
})
|
|
2563
|
+
.where(eq(mediaAltTextSuggestions.id, suggestion.id));
|
|
2564
|
+
ctx.setSubject("asset", input.id);
|
|
2565
|
+
ctx.queueEvent("media.altTextDismissed", {
|
|
2566
|
+
assetId: input.id,
|
|
2567
|
+
suggestionId: suggestion.id,
|
|
2568
|
+
});
|
|
2569
|
+
return { ok: true };
|
|
2570
|
+
},
|
|
2571
|
+
});
|
|
2572
|
+
|
|
2573
|
+
export const setFocalPoint = defineService({
|
|
2574
|
+
name: "media.setFocalPoint",
|
|
2575
|
+
summary: "Set the image crop anchor in basis points.",
|
|
2576
|
+
kind: "mutation",
|
|
2577
|
+
permission: "scoped",
|
|
2578
|
+
input: z.object({
|
|
2579
|
+
id: z.string().uuid(),
|
|
2580
|
+
x: z.number().int().min(0).max(10_000),
|
|
2581
|
+
y: z.number().int().min(0).max(10_000),
|
|
2582
|
+
}),
|
|
2583
|
+
output: assetRow,
|
|
2584
|
+
handler: async (input, ctx) => {
|
|
2585
|
+
const [asset] = await ctx.tx
|
|
2586
|
+
.update(assets)
|
|
2587
|
+
.set({ focalX: input.x, focalY: input.y, updatedAt: new Date() })
|
|
2588
|
+
.where(and(eq(assets.id, input.id), eq(assets.kind, "image")))
|
|
2589
|
+
.returning();
|
|
2590
|
+
if (!asset) throw new ServiceError("not_found", "That image is not here.");
|
|
2591
|
+
ctx.setSubject("asset", asset.id);
|
|
2592
|
+
return asset;
|
|
2593
|
+
},
|
|
2594
|
+
});
|
|
2595
|
+
|
|
2596
|
+
export const updateAssetDetails = defineService({
|
|
2597
|
+
name: "media.updateDetails",
|
|
2598
|
+
summary: "Update safe media metadata and provenance notes.",
|
|
2599
|
+
kind: "mutation",
|
|
2600
|
+
permission: "scoped",
|
|
2601
|
+
input: z.object({
|
|
2602
|
+
id: z.string().uuid(),
|
|
2603
|
+
metadata: mediaMetadataSchema.optional(),
|
|
2604
|
+
provenance: provenanceSchema.optional(),
|
|
2605
|
+
}),
|
|
2606
|
+
output: assetRow,
|
|
2607
|
+
handler: async (input, ctx) => {
|
|
2608
|
+
const [existing] = await ctx.tx
|
|
2609
|
+
.select()
|
|
2610
|
+
.from(assets)
|
|
2611
|
+
.where(eq(assets.id, input.id))
|
|
2612
|
+
.limit(1);
|
|
2613
|
+
if (!existing) throw new ServiceError("not_found", "That file is not here.");
|
|
2614
|
+
const metadata = {
|
|
2615
|
+
...(existing.metadata as Record<string, unknown>),
|
|
2616
|
+
...(input.metadata ?? {}),
|
|
2617
|
+
};
|
|
2618
|
+
const provenance = {
|
|
2619
|
+
...(existing.provenance as Record<string, unknown>),
|
|
2620
|
+
...(input.provenance ?? {}),
|
|
2621
|
+
lastEditedBy: actorString(ctx.actor),
|
|
2622
|
+
lastEditedAt: new Date().toISOString(),
|
|
2623
|
+
};
|
|
2624
|
+
const [asset] = await ctx.tx
|
|
2625
|
+
.update(assets)
|
|
2626
|
+
.set({
|
|
2627
|
+
metadata,
|
|
2628
|
+
provenance,
|
|
2629
|
+
width: input.metadata?.width ?? existing.width,
|
|
2630
|
+
height: input.metadata?.height ?? existing.height,
|
|
2631
|
+
durationSeconds:
|
|
2632
|
+
input.metadata?.durationSeconds ?? existing.durationSeconds,
|
|
2633
|
+
updatedAt: new Date(),
|
|
2634
|
+
})
|
|
2635
|
+
.where(eq(assets.id, existing.id))
|
|
2636
|
+
.returning();
|
|
2637
|
+
ctx.setSubject("asset", existing.id);
|
|
2638
|
+
return asset!;
|
|
2639
|
+
},
|
|
2640
|
+
});
|
|
2641
|
+
|
|
2642
|
+
/**
|
|
2643
|
+
* Where an asset is still being used.
|
|
2644
|
+
*
|
|
2645
|
+
* Deleting a file that a page still points at leaves a gap on that page. The
|
|
2646
|
+
* block handles it — `resolveImage` answers null and the block renders
|
|
2647
|
+
* nothing, so a live site never breaks — but an owner deserves to know before
|
|
2648
|
+
* rather than discover after.
|
|
2649
|
+
*
|
|
2650
|
+
* The jsonpath `$.**` walks the whole block tree, so an image nested inside a
|
|
2651
|
+
* columns block is found as readily as one at the top level.
|
|
2652
|
+
*
|
|
2653
|
+
* cms owns those tables, which is why this reaches them through a raw query
|
|
2654
|
+
* rather than importing their schema: core must not depend on a module (§11).
|
|
2655
|
+
* The cost is that this string knows two table names — a narrow, deliberate
|
|
2656
|
+
* exception, and the alternative is core importing downward.
|
|
2657
|
+
*/
|
|
2658
|
+
export const assetUsage = defineService({
|
|
2659
|
+
name: "media.usage",
|
|
2660
|
+
summary: "How many pages and sections still reference a file.",
|
|
2661
|
+
kind: "query",
|
|
2662
|
+
permission: "scoped",
|
|
2663
|
+
input: z.object({ id: z.string().uuid() }),
|
|
2664
|
+
output: z.object({
|
|
2665
|
+
pages: z.number(),
|
|
2666
|
+
sections: z.number(),
|
|
2667
|
+
}),
|
|
2668
|
+
handler: async (input, ctx) => {
|
|
2669
|
+
// The id travels as a jsonpath *variable* rather than being concatenated
|
|
2670
|
+
// into the expression: the path stays a constant, and a value that is not
|
|
2671
|
+
// a uuid can only ever fail to match rather than change the query.
|
|
2672
|
+
const vars = sql`jsonb_build_object('id', ${input.id}::text)`;
|
|
2673
|
+
const path = sql`'$.** ? (@.assetId == $id)'::jsonpath`;
|
|
2674
|
+
const counts = await ctx.tx.execute<{ pages: number; sections: number }>(sql`
|
|
2675
|
+
select
|
|
2676
|
+
(select count(*) from pages
|
|
2677
|
+
where jsonb_path_exists(blocks, ${path}, ${vars})) as pages,
|
|
2678
|
+
(select count(*) from sections
|
|
2679
|
+
where jsonb_path_exists(blocks, ${path}, ${vars})) as sections
|
|
2680
|
+
`);
|
|
2681
|
+
const row = counts[0];
|
|
2682
|
+
return {
|
|
2683
|
+
pages: Number(row?.pages ?? 0),
|
|
2684
|
+
sections: Number(row?.sections ?? 0),
|
|
2685
|
+
};
|
|
2686
|
+
},
|
|
2687
|
+
});
|
|
2688
|
+
|
|
2689
|
+
/** Hide immediately while retaining every byte for one-action recovery. */
|
|
2690
|
+
export const trashAsset = defineService({
|
|
2691
|
+
name: "media.trash",
|
|
2692
|
+
summary: "Move a file to recoverable trash for thirty days.",
|
|
2693
|
+
kind: "mutation",
|
|
2694
|
+
permission: "scoped",
|
|
2695
|
+
input: z.object({ id: z.string().uuid() }),
|
|
2696
|
+
output: assetRow,
|
|
2697
|
+
handler: async (input, ctx) => {
|
|
2698
|
+
const [asset] = await ctx.tx
|
|
2699
|
+
.select()
|
|
2700
|
+
.from(assets)
|
|
2701
|
+
.where(eq(assets.id, input.id))
|
|
2702
|
+
.limit(1);
|
|
2703
|
+
if (!asset) throw new ServiceError("not_found", "That file is not here.");
|
|
2704
|
+
|
|
2705
|
+
if (asset.status === "trashed") return asset;
|
|
2706
|
+
const now = new Date();
|
|
2707
|
+
const [trashed] = await ctx.tx
|
|
2708
|
+
.update(assets)
|
|
2709
|
+
.set({
|
|
2710
|
+
status: "trashed",
|
|
2711
|
+
deletedAt: now,
|
|
2712
|
+
purgeAfter: new Date(now.getTime() + TRASH_RETENTION_MS),
|
|
2713
|
+
updatedAt: now,
|
|
2714
|
+
})
|
|
2715
|
+
.where(eq(assets.id, asset.id))
|
|
2716
|
+
.returning();
|
|
2717
|
+
ctx.setSubject("asset", asset.id);
|
|
2718
|
+
ctx.queueEvent("media.trashed", {
|
|
2719
|
+
assetId: asset.id,
|
|
2720
|
+
purgeAfter: trashed!.purgeAfter!.toISOString(),
|
|
2721
|
+
});
|
|
2722
|
+
return trashed!;
|
|
2723
|
+
},
|
|
2724
|
+
});
|
|
2725
|
+
|
|
2726
|
+
/** Compatibility for existing server-action imports; deletion is now trash. */
|
|
2727
|
+
export const deleteAsset = trashAsset;
|
|
2728
|
+
|
|
2729
|
+
export const restoreAsset = defineService({
|
|
2730
|
+
name: "media.restore",
|
|
2731
|
+
summary: "Restore a file from recoverable trash.",
|
|
2732
|
+
kind: "mutation",
|
|
2733
|
+
permission: "scoped",
|
|
2734
|
+
input: z.object({ id: z.string().uuid() }),
|
|
2735
|
+
output: assetRow,
|
|
2736
|
+
handler: async (input, ctx) => {
|
|
2737
|
+
const [existing] = await ctx.tx
|
|
2738
|
+
.select()
|
|
2739
|
+
.from(assets)
|
|
2740
|
+
.where(eq(assets.id, input.id))
|
|
2741
|
+
.limit(1);
|
|
2742
|
+
if (!existing || existing.status !== "trashed") {
|
|
2743
|
+
throw new ServiceError("not_found", "That trashed file is not here.");
|
|
2744
|
+
}
|
|
2745
|
+
const status =
|
|
2746
|
+
existing.scanStatus === "infected" || existing.scanStatus === "error"
|
|
2747
|
+
? ("quarantined" as const)
|
|
2748
|
+
: ("ready" as const);
|
|
2749
|
+
const [restored] = await ctx.tx
|
|
2750
|
+
.update(assets)
|
|
2751
|
+
.set({
|
|
2752
|
+
status,
|
|
2753
|
+
deletedAt: null,
|
|
2754
|
+
purgeAfter: null,
|
|
2755
|
+
updatedAt: new Date(),
|
|
2756
|
+
})
|
|
2757
|
+
.where(eq(assets.id, existing.id))
|
|
2758
|
+
.returning();
|
|
2759
|
+
ctx.setSubject("asset", existing.id);
|
|
2760
|
+
ctx.queueEvent("media.restored", { assetId: existing.id });
|
|
2761
|
+
return restored!;
|
|
2762
|
+
},
|
|
2763
|
+
});
|
|
2764
|
+
|
|
2765
|
+
function contentTypeForPurgeKey(
|
|
2766
|
+
key: string,
|
|
2767
|
+
asset: typeof assets.$inferSelect,
|
|
2768
|
+
): string {
|
|
2769
|
+
if (key === asset.storageKey) return asset.mime;
|
|
2770
|
+
if (key.endsWith(".webp")) return "image/webp";
|
|
2771
|
+
if (key.endsWith(".avif")) return "image/avif";
|
|
2772
|
+
return asset.mime;
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
function collectPurgeKeys(asset: typeof assets.$inferSelect, inventoryKeys: string[]): string[] {
|
|
2776
|
+
const keys = new Set(inventoryKeys);
|
|
2777
|
+
keys.add(asset.storageKey);
|
|
2778
|
+
for (const key of allRenditionKeys(asset.variants as VariantSet)) keys.add(key);
|
|
2779
|
+
return [...keys];
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
/**
|
|
2783
|
+
* Make the library row disappear first. Bytes stay as pending objects so a
|
|
2784
|
+
* crash after this commit is sweepable litter, never a visible file with
|
|
2785
|
+
* missing originals.
|
|
2786
|
+
*/
|
|
2787
|
+
async function claimPurge(
|
|
2788
|
+
tx: Tx,
|
|
2789
|
+
asset: typeof assets.$inferSelect,
|
|
2790
|
+
): Promise<{ assetId: string; keys: string[] }> {
|
|
2791
|
+
const inventory = await tx
|
|
2792
|
+
.select({ key: mediaObjects.key })
|
|
2793
|
+
.from(mediaObjects)
|
|
2794
|
+
.where(eq(mediaObjects.assetId, asset.id));
|
|
2795
|
+
const keys = collectPurgeKeys(
|
|
2796
|
+
asset,
|
|
2797
|
+
inventory.map((row) => row.key),
|
|
2798
|
+
);
|
|
2799
|
+
if (inventory.length > 0) {
|
|
2800
|
+
await tx
|
|
2801
|
+
.update(mediaObjects)
|
|
2802
|
+
.set({ assetId: null, state: "pending", updatedAt: new Date() })
|
|
2803
|
+
.where(eq(mediaObjects.assetId, asset.id));
|
|
2804
|
+
}
|
|
2805
|
+
const tracked = new Set(inventory.map((row) => row.key));
|
|
2806
|
+
const untracked = keys.filter((key) => !tracked.has(key));
|
|
2807
|
+
if (untracked.length > 0) {
|
|
2808
|
+
await tx
|
|
2809
|
+
.insert(mediaObjects)
|
|
2810
|
+
.values(
|
|
2811
|
+
untracked.map((key) => ({
|
|
2812
|
+
key,
|
|
2813
|
+
contentType: contentTypeForPurgeKey(key, asset),
|
|
2814
|
+
role:
|
|
2815
|
+
key === asset.storageKey
|
|
2816
|
+
? ("original" as const)
|
|
2817
|
+
: ("variant" as const),
|
|
2818
|
+
state: "pending" as const,
|
|
2819
|
+
})),
|
|
2820
|
+
)
|
|
2821
|
+
.onConflictDoNothing();
|
|
2822
|
+
}
|
|
2823
|
+
await tx.delete(assets).where(eq(assets.id, asset.id));
|
|
2824
|
+
return { assetId: asset.id, keys };
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
async function deleteStoredKeys(keys: string[]): Promise<void> {
|
|
2828
|
+
for (const key of keys) {
|
|
2829
|
+
try {
|
|
2830
|
+
await storage().delete(key);
|
|
2831
|
+
} catch {
|
|
2832
|
+
// The row is already gone. A failed delete stays as a pending object
|
|
2833
|
+
// the orphan sweep can finish; throwing here would look like the
|
|
2834
|
+
// library file survived when it did not.
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
const purgeClaimOutput = z.object({
|
|
2840
|
+
assetId: uuid,
|
|
2841
|
+
keys: z.array(z.string().min(1)),
|
|
2842
|
+
});
|
|
2843
|
+
|
|
2844
|
+
const purgeClaim = defineService({
|
|
2845
|
+
name: "media.purgeClaim",
|
|
2846
|
+
summary: "Hide a trashed file from the library before its bytes are deleted.",
|
|
2847
|
+
kind: "mutation",
|
|
2848
|
+
permission: "scoped",
|
|
2849
|
+
external: false,
|
|
2850
|
+
writeClass: "write",
|
|
2851
|
+
input: z.object({ id: z.string().uuid(), confirmation: z.string().max(255) }),
|
|
2852
|
+
output: purgeClaimOutput,
|
|
2853
|
+
handler: async (input, ctx) => {
|
|
2854
|
+
if (
|
|
2855
|
+
ctx.actor.kind !== "system" &&
|
|
2856
|
+
(ctx.actor.kind !== "user" || ctx.actor.role !== "owner")
|
|
2857
|
+
) {
|
|
2858
|
+
throw new ServiceError(
|
|
2859
|
+
"permission",
|
|
2860
|
+
"Only the owner can permanently purge media.",
|
|
2861
|
+
);
|
|
2862
|
+
}
|
|
2863
|
+
const [asset] = await ctx.tx
|
|
2864
|
+
.select()
|
|
2865
|
+
.from(assets)
|
|
2866
|
+
.where(eq(assets.id, input.id))
|
|
2867
|
+
.limit(1)
|
|
2868
|
+
.for("update");
|
|
2869
|
+
if (!asset || asset.status !== "trashed") {
|
|
2870
|
+
throw new ServiceError("not_found", "That trashed file is not here.");
|
|
2871
|
+
}
|
|
2872
|
+
if (input.confirmation !== asset.filename) {
|
|
2873
|
+
throw new ServiceError(
|
|
2874
|
+
"validation",
|
|
2875
|
+
"Type the exact filename to confirm permanent deletion.",
|
|
2876
|
+
);
|
|
2877
|
+
}
|
|
2878
|
+
const result = await claimPurge(ctx.tx, asset);
|
|
2879
|
+
ctx.setSubject("asset", result.assetId);
|
|
2880
|
+
ctx.queueEvent("media.purged", {
|
|
2881
|
+
assetId: result.assetId,
|
|
2882
|
+
objects: result.keys.length,
|
|
2883
|
+
});
|
|
2884
|
+
return result;
|
|
2885
|
+
},
|
|
2886
|
+
});
|
|
2887
|
+
|
|
2888
|
+
const purgeExpiredClaim = defineService({
|
|
2889
|
+
name: "media.purgeExpiredClaim",
|
|
2890
|
+
summary: "Hide expired trash from the library before its bytes are deleted.",
|
|
2891
|
+
kind: "mutation",
|
|
2892
|
+
permission: "system",
|
|
2893
|
+
writeClass: "write",
|
|
2894
|
+
input: z.object({
|
|
2895
|
+
id: z.string().uuid(),
|
|
2896
|
+
asOf: z.string().datetime().optional(),
|
|
2897
|
+
}),
|
|
2898
|
+
output: purgeClaimOutput,
|
|
2899
|
+
handler: async (input, ctx) => {
|
|
2900
|
+
if (ctx.actor.kind !== "system") {
|
|
2901
|
+
throw new ServiceError("permission", "Only lifecycle maintenance can run this operation.");
|
|
2902
|
+
}
|
|
2903
|
+
const [asset] = await ctx.tx
|
|
2904
|
+
.select()
|
|
2905
|
+
.from(assets)
|
|
2906
|
+
.where(eq(assets.id, input.id))
|
|
2907
|
+
.limit(1)
|
|
2908
|
+
.for("update");
|
|
2909
|
+
if (
|
|
2910
|
+
!asset ||
|
|
2911
|
+
asset.status !== "trashed" ||
|
|
2912
|
+
!asset.purgeAfter ||
|
|
2913
|
+
asset.purgeAfter > (input.asOf ? new Date(input.asOf) : new Date())
|
|
2914
|
+
) {
|
|
2915
|
+
throw new ServiceError("conflict", "That asset is not due for purge.");
|
|
2916
|
+
}
|
|
2917
|
+
const result = await claimPurge(ctx.tx, asset);
|
|
2918
|
+
ctx.setSubject("asset", result.assetId);
|
|
2919
|
+
ctx.queueEvent("media.purged", {
|
|
2920
|
+
assetId: result.assetId,
|
|
2921
|
+
objects: result.keys.length,
|
|
2922
|
+
});
|
|
2923
|
+
return result;
|
|
2924
|
+
},
|
|
2925
|
+
});
|
|
2926
|
+
|
|
2927
|
+
const purgeApply = defineService({
|
|
2928
|
+
name: "media.purgeApply",
|
|
2929
|
+
summary: "Drop pending object rows after purge has deleted provider bytes.",
|
|
2930
|
+
kind: "mutation",
|
|
2931
|
+
permission: "scoped",
|
|
2932
|
+
external: false,
|
|
2933
|
+
writeClass: "write",
|
|
2934
|
+
input: z.object({ keys: z.array(z.string().min(1)).max(256) }),
|
|
2935
|
+
output: okResult,
|
|
2936
|
+
handler: async (input, ctx) => {
|
|
2937
|
+
if (input.keys.length === 0) return { ok: true as const };
|
|
2938
|
+
await ctx.tx
|
|
2939
|
+
.delete(mediaObjects)
|
|
2940
|
+
.where(
|
|
2941
|
+
and(inArray(mediaObjects.key, input.keys), eq(mediaObjects.state, "pending")),
|
|
2942
|
+
);
|
|
2943
|
+
return { ok: true as const };
|
|
2944
|
+
},
|
|
2945
|
+
});
|
|
2946
|
+
|
|
2947
|
+
export const purgeAsset = defineOrchestratedService({
|
|
2948
|
+
name: "media.purge",
|
|
2949
|
+
summary: "Permanently purge one trashed file after typed owner confirmation.",
|
|
2950
|
+
kind: "mutation",
|
|
2951
|
+
permission: "scoped",
|
|
2952
|
+
stepUp: true,
|
|
2953
|
+
writeClass: "write",
|
|
2954
|
+
input: z.object({ id: z.string().uuid(), confirmation: z.string().max(255) }),
|
|
2955
|
+
output: z.object({
|
|
2956
|
+
ok: z.literal(true),
|
|
2957
|
+
assetId: uuid,
|
|
2958
|
+
objects: z.number().int(),
|
|
2959
|
+
}),
|
|
2960
|
+
handler: async (input, actor) => {
|
|
2961
|
+
const claimed = await purgeClaim.call(input, actor);
|
|
2962
|
+
await deleteStoredKeys(claimed.keys);
|
|
2963
|
+
await purgeApply.call({ keys: claimed.keys }, actor);
|
|
2964
|
+
return { ok: true as const, assetId: claimed.assetId, objects: claimed.keys.length };
|
|
2965
|
+
},
|
|
2966
|
+
});
|
|
2967
|
+
|
|
2968
|
+
/** Scheduler-only purge lane; still goes through audit and event invariants. */
|
|
2969
|
+
export const purgeExpiredAsset = defineOrchestratedService({
|
|
2970
|
+
name: "media.purgeExpired",
|
|
2971
|
+
summary: "Purge one asset after its recoverable trash window expires.",
|
|
2972
|
+
kind: "mutation",
|
|
2973
|
+
permission: "system",
|
|
2974
|
+
writeClass: "write",
|
|
2975
|
+
input: z.object({
|
|
2976
|
+
id: z.string().uuid(),
|
|
2977
|
+
asOf: z.string().datetime().optional(),
|
|
2978
|
+
}),
|
|
2979
|
+
output: z.object({
|
|
2980
|
+
assetId: uuid,
|
|
2981
|
+
objects: z.number().int(),
|
|
2982
|
+
}),
|
|
2983
|
+
handler: async (input, actor) => {
|
|
2984
|
+
const claimed = await purgeExpiredClaim.call(input, actor);
|
|
2985
|
+
await deleteStoredKeys(claimed.keys);
|
|
2986
|
+
await purgeApply.call({ keys: claimed.keys }, actor);
|
|
2987
|
+
return { assetId: claimed.assetId, objects: claimed.keys.length };
|
|
2988
|
+
},
|
|
2989
|
+
});
|
|
2990
|
+
|
|
2991
|
+
const rescanSource = z.object({
|
|
2992
|
+
id: uuid,
|
|
2993
|
+
storageKey: z.string(),
|
|
2994
|
+
filename: z.string(),
|
|
2995
|
+
mime: z.string(),
|
|
2996
|
+
bytes: z.number(),
|
|
2997
|
+
kind: z.enum(["image", "video", "doc", "audio"]),
|
|
2998
|
+
status: z.enum(["processing", "ready", "quarantined", "failed", "trashed"]),
|
|
2999
|
+
variants: z.unknown(),
|
|
3000
|
+
checksumSha256: z.string().nullable(),
|
|
3001
|
+
width: z.number().int().nullable(),
|
|
3002
|
+
height: z.number().int().nullable(),
|
|
3003
|
+
});
|
|
3004
|
+
|
|
3005
|
+
const rescanSourceService = defineService({
|
|
3006
|
+
name: "media.rescanSource",
|
|
3007
|
+
summary: "Authorize and snapshot a file before scanning it again.",
|
|
3008
|
+
kind: "query",
|
|
3009
|
+
permission: "scoped",
|
|
3010
|
+
external: false,
|
|
3011
|
+
input: z.object({ id: z.string().uuid() }),
|
|
3012
|
+
output: rescanSource,
|
|
3013
|
+
handler: async (input, ctx) => {
|
|
3014
|
+
const [asset] = await ctx.tx
|
|
3015
|
+
.select()
|
|
3016
|
+
.from(assets)
|
|
3017
|
+
.where(eq(assets.id, input.id))
|
|
3018
|
+
.limit(1);
|
|
3019
|
+
if (!asset || asset.status === "trashed") {
|
|
3020
|
+
throw new ServiceError("not_found", "That file is not here.");
|
|
3021
|
+
}
|
|
3022
|
+
return asset;
|
|
3023
|
+
},
|
|
3024
|
+
});
|
|
3025
|
+
|
|
3026
|
+
const applyRescan = defineService({
|
|
3027
|
+
name: "media.applyRescan",
|
|
3028
|
+
summary: "Revalidate a file and atomically store a completed rescan.",
|
|
3029
|
+
kind: "mutation",
|
|
3030
|
+
permission: "scoped",
|
|
3031
|
+
external: false,
|
|
3032
|
+
writeClass: "write",
|
|
3033
|
+
input: z.object({
|
|
3034
|
+
id: z.string().uuid(),
|
|
3035
|
+
sourceChecksum: z.string().min(1),
|
|
3036
|
+
storageKey: z.string().min(1),
|
|
3037
|
+
bytes: z.number(),
|
|
3038
|
+
mime: z.string().min(1),
|
|
3039
|
+
scanStatus: z.enum(["pending", "clean", "not_configured", "infected", "error"]),
|
|
3040
|
+
scanEngine: z.string().nullable(),
|
|
3041
|
+
scanMessage: z.string().nullable(),
|
|
3042
|
+
scannedAt: timestamp.nullable(),
|
|
3043
|
+
status: z.enum(["processing", "ready", "quarantined", "failed", "trashed"]),
|
|
3044
|
+
variantKeys: z.array(z.string().min(1)).max(64),
|
|
3045
|
+
variants: z.unknown(),
|
|
3046
|
+
width: z.number().int().nullable(),
|
|
3047
|
+
height: z.number().int().nullable(),
|
|
3048
|
+
}),
|
|
3049
|
+
output: assetRow,
|
|
3050
|
+
handler: async (input, ctx) => {
|
|
3051
|
+
// Scanner and storage work ran outside this transaction. Re-lock and
|
|
3052
|
+
// compare the source snapshot so a concurrent edit always wins, and so
|
|
3053
|
+
// newly written renditions stay sweepable pending objects instead of
|
|
3054
|
+
// attaching to a file that is no longer the one we scanned.
|
|
3055
|
+
const [current] = await ctx.tx
|
|
3056
|
+
.select()
|
|
3057
|
+
.from(assets)
|
|
3058
|
+
.where(eq(assets.id, input.id))
|
|
3059
|
+
.limit(1)
|
|
3060
|
+
.for("update");
|
|
3061
|
+
if (!current || current.status === "trashed") {
|
|
3062
|
+
throw new ServiceError("not_found", "That file is not here.");
|
|
3063
|
+
}
|
|
3064
|
+
if (
|
|
3065
|
+
sourceIdentity(current) !== input.sourceChecksum ||
|
|
3066
|
+
current.storageKey !== input.storageKey ||
|
|
3067
|
+
current.bytes !== input.bytes ||
|
|
3068
|
+
current.mime !== input.mime
|
|
3069
|
+
) {
|
|
3070
|
+
throw new ServiceError(
|
|
3071
|
+
"conflict",
|
|
3072
|
+
"The file changed while it was being scanned. Nothing was overwritten; try again from the current file.",
|
|
3073
|
+
);
|
|
3074
|
+
}
|
|
3075
|
+
const currentVariants = current.variants as VariantSet;
|
|
3076
|
+
const attachKeys =
|
|
3077
|
+
input.variantKeys.length > 0 && Object.keys(currentVariants).length === 0
|
|
3078
|
+
? input.variantKeys
|
|
3079
|
+
: [];
|
|
3080
|
+
if (attachKeys.length > 0) {
|
|
3081
|
+
await attachObjects(ctx.tx, attachKeys, current.id);
|
|
3082
|
+
}
|
|
3083
|
+
const [updated] = await ctx.tx
|
|
3084
|
+
.update(assets)
|
|
3085
|
+
.set({
|
|
3086
|
+
scanStatus: input.scanStatus,
|
|
3087
|
+
scanEngine: input.scanEngine,
|
|
3088
|
+
scanMessage: input.scanMessage,
|
|
3089
|
+
scannedAt: input.scannedAt,
|
|
3090
|
+
status: input.status,
|
|
3091
|
+
variants: attachKeys.length > 0 ? input.variants : current.variants,
|
|
3092
|
+
width: attachKeys.length > 0 ? input.width : current.width,
|
|
3093
|
+
height: attachKeys.length > 0 ? input.height : current.height,
|
|
3094
|
+
updatedAt: new Date(),
|
|
3095
|
+
})
|
|
3096
|
+
.where(eq(assets.id, current.id))
|
|
3097
|
+
.returning();
|
|
3098
|
+
ctx.setSubject("asset", current.id);
|
|
3099
|
+
ctx.queueEvent("media.scanned", {
|
|
3100
|
+
assetId: current.id,
|
|
3101
|
+
scanStatus: updated!.scanStatus,
|
|
3102
|
+
});
|
|
3103
|
+
return updated!;
|
|
3104
|
+
},
|
|
3105
|
+
});
|
|
3106
|
+
|
|
3107
|
+
export const rescanAsset = defineOrchestratedService({
|
|
3108
|
+
name: "media.rescan",
|
|
3109
|
+
summary: "Run the configured malware scanner against an original again.",
|
|
3110
|
+
kind: "mutation",
|
|
3111
|
+
permission: "scoped",
|
|
3112
|
+
writeClass: "write",
|
|
3113
|
+
input: z.object({ id: z.string().uuid() }),
|
|
3114
|
+
output: assetRow,
|
|
3115
|
+
handler: async (input, actor) => {
|
|
3116
|
+
const asset = await rescanSourceService.call(input, actor);
|
|
3117
|
+
let scan;
|
|
3118
|
+
try {
|
|
3119
|
+
scan = await scanStored(
|
|
3120
|
+
asset.storageKey,
|
|
3121
|
+
asset.filename,
|
|
3122
|
+
asset.mime,
|
|
3123
|
+
asset.bytes,
|
|
3124
|
+
);
|
|
3125
|
+
} catch {
|
|
3126
|
+
throw new ServiceError(
|
|
3127
|
+
"conflict",
|
|
3128
|
+
"The original file is missing or could not be scanned.",
|
|
3129
|
+
);
|
|
3130
|
+
}
|
|
3131
|
+
const fields = scanFields(scan);
|
|
3132
|
+
const status =
|
|
3133
|
+
scan.status === "not_configured" && asset.status === "quarantined"
|
|
3134
|
+
? ("quarantined" as const)
|
|
3135
|
+
: fields.status;
|
|
3136
|
+
let variants = asset.variants;
|
|
3137
|
+
let width = asset.width;
|
|
3138
|
+
let height = asset.height;
|
|
3139
|
+
const variantKeys: string[] = [];
|
|
3140
|
+
if (
|
|
3141
|
+
status === "ready" &&
|
|
3142
|
+
asset.kind === "image" &&
|
|
3143
|
+
Object.keys(asset.variants as VariantSet).length === 0
|
|
3144
|
+
) {
|
|
3145
|
+
const body = await storage().get(asset.storageKey);
|
|
3146
|
+
const facts = body ? await readImageFacts(body) : undefined;
|
|
3147
|
+
if (!body || !facts) {
|
|
3148
|
+
throw new ServiceError(
|
|
3149
|
+
"validation",
|
|
3150
|
+
"The original image is missing or damaged and cannot be released.",
|
|
3151
|
+
);
|
|
3152
|
+
}
|
|
3153
|
+
const built = await buildRenditions(body, facts, (format, size) =>
|
|
3154
|
+
`${asset.storageKey}.${size}.${format}`,
|
|
3155
|
+
);
|
|
3156
|
+
await putTrackedObjects(
|
|
3157
|
+
built.map((rendition) => ({
|
|
3158
|
+
key: rendition.key,
|
|
3159
|
+
body: rendition.body,
|
|
3160
|
+
contentType: rendition.contentType,
|
|
3161
|
+
role: "variant" as const,
|
|
3162
|
+
})),
|
|
3163
|
+
);
|
|
3164
|
+
variantKeys.push(...built.map((rendition) => rendition.key));
|
|
3165
|
+
variants = toVariantSet(built);
|
|
3166
|
+
width = facts.width;
|
|
3167
|
+
height = facts.height;
|
|
3168
|
+
}
|
|
3169
|
+
return applyRescan.call(
|
|
3170
|
+
{
|
|
3171
|
+
id: asset.id,
|
|
3172
|
+
sourceChecksum: sourceIdentity(asset),
|
|
3173
|
+
storageKey: asset.storageKey,
|
|
3174
|
+
bytes: asset.bytes,
|
|
3175
|
+
mime: asset.mime,
|
|
3176
|
+
...fields,
|
|
3177
|
+
status,
|
|
3178
|
+
variantKeys,
|
|
3179
|
+
variants,
|
|
3180
|
+
width,
|
|
3181
|
+
height,
|
|
3182
|
+
},
|
|
3183
|
+
actor,
|
|
3184
|
+
);
|
|
3185
|
+
},
|
|
3186
|
+
});
|
|
3187
|
+
|
|
3188
|
+
/** Scheduled lifecycle work. These return evidence for the job history. */
|
|
3189
|
+
export async function purgeExpiredMedia(now = new Date()): Promise<number> {
|
|
3190
|
+
const due = await db()
|
|
3191
|
+
.select()
|
|
3192
|
+
.from(assets)
|
|
3193
|
+
.where(and(eq(assets.status, "trashed"), lt(assets.purgeAfter, now)))
|
|
3194
|
+
.limit(100);
|
|
3195
|
+
for (const asset of due) {
|
|
3196
|
+
await purgeExpiredAsset.call(
|
|
3197
|
+
{ id: asset.id, asOf: now.toISOString() },
|
|
3198
|
+
{ kind: "system" },
|
|
3199
|
+
);
|
|
3200
|
+
}
|
|
3201
|
+
return due.length;
|
|
3202
|
+
}
|
|
3203
|
+
|
|
3204
|
+
export async function cleanupOrphanedMedia(now = new Date()): Promise<{
|
|
3205
|
+
expiredUploads: number;
|
|
3206
|
+
orphanedObjects: number;
|
|
3207
|
+
prunedSessions: number;
|
|
3208
|
+
}> {
|
|
3209
|
+
const store = storage();
|
|
3210
|
+
const expired = await db()
|
|
3211
|
+
.select()
|
|
3212
|
+
.from(mediaUploads)
|
|
3213
|
+
.where(
|
|
3214
|
+
and(
|
|
3215
|
+
lt(mediaUploads.expiresAt, now),
|
|
3216
|
+
inArray(mediaUploads.state, [
|
|
3217
|
+
"created",
|
|
3218
|
+
"uploading",
|
|
3219
|
+
"uploaded",
|
|
3220
|
+
"processing",
|
|
3221
|
+
]),
|
|
3222
|
+
),
|
|
3223
|
+
)
|
|
3224
|
+
.limit(100);
|
|
3225
|
+
for (const upload of expired) {
|
|
3226
|
+
if (store.directMultipart && upload.providerUploadId) {
|
|
3227
|
+
await store.directMultipart.abort(
|
|
3228
|
+
upload.storageKey,
|
|
3229
|
+
upload.providerUploadId,
|
|
3230
|
+
);
|
|
3231
|
+
}
|
|
3232
|
+
await store.delete(upload.storageKey);
|
|
3233
|
+
await db().transaction(async (tx) => {
|
|
3234
|
+
await tx.delete(mediaObjects).where(eq(mediaObjects.uploadId, upload.id));
|
|
3235
|
+
await tx
|
|
3236
|
+
.update(mediaUploads)
|
|
3237
|
+
.set({ state: "expired", completedAt: now, updatedAt: now })
|
|
3238
|
+
.where(eq(mediaUploads.id, upload.id));
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
const cutoff = new Date(now.getTime() - UPLOAD_TTL_MS);
|
|
3243
|
+
const orphans = await db()
|
|
3244
|
+
.select()
|
|
3245
|
+
.from(mediaObjects)
|
|
3246
|
+
.where(
|
|
3247
|
+
and(eq(mediaObjects.state, "pending"), lt(mediaObjects.createdAt, cutoff)),
|
|
3248
|
+
)
|
|
3249
|
+
.limit(500);
|
|
3250
|
+
for (const object of orphans) {
|
|
3251
|
+
await store.delete(object.key);
|
|
3252
|
+
await db().delete(mediaObjects).where(eq(mediaObjects.key, object.key));
|
|
3253
|
+
}
|
|
3254
|
+
const terminalCutoff = new Date(now.getTime() - TRASH_RETENTION_MS);
|
|
3255
|
+
const pruned = await db()
|
|
3256
|
+
.delete(mediaUploads)
|
|
3257
|
+
.where(
|
|
3258
|
+
and(
|
|
3259
|
+
inArray(mediaUploads.state, ["complete", "failed", "aborted", "expired"]),
|
|
3260
|
+
lt(mediaUploads.updatedAt, terminalCutoff),
|
|
3261
|
+
),
|
|
3262
|
+
)
|
|
3263
|
+
.returning({ id: mediaUploads.id });
|
|
3264
|
+
return {
|
|
3265
|
+
expiredUploads: expired.length,
|
|
3266
|
+
orphanedObjects: orphans.length,
|
|
3267
|
+
prunedSessions: pruned.length,
|
|
3268
|
+
};
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
export default [
|
|
3272
|
+
uploadAsset,
|
|
3273
|
+
claimProxyUpload,
|
|
3274
|
+
applyStoredOriginal,
|
|
3275
|
+
beginUpload,
|
|
3276
|
+
beginUploadApply,
|
|
3277
|
+
uploadStatus,
|
|
3278
|
+
uploadStatusSource,
|
|
3279
|
+
signUploadParts,
|
|
3280
|
+
signUploadClaim,
|
|
3281
|
+
completeUpload,
|
|
3282
|
+
completeUploadSource,
|
|
3283
|
+
failDirectUpload,
|
|
3284
|
+
applyCaptureComplete,
|
|
3285
|
+
registerStoredOriginal,
|
|
3286
|
+
abortUpload,
|
|
3287
|
+
abortUploadClaim,
|
|
3288
|
+
abortUploadApply,
|
|
3289
|
+
listAssets,
|
|
3290
|
+
getAsset,
|
|
3291
|
+
resolveImage,
|
|
3292
|
+
resolveAsset,
|
|
3293
|
+
privateAssetDownloadAccess,
|
|
3294
|
+
authorizeAssetDownload,
|
|
3295
|
+
authorizeObjectDelivery,
|
|
3296
|
+
backfillWatermarks,
|
|
3297
|
+
listWatermarkBackfill,
|
|
3298
|
+
applyWatermarkBackfill,
|
|
3299
|
+
assetUsage,
|
|
3300
|
+
altTextSuggestionState,
|
|
3301
|
+
listAltTextSuggestionStates,
|
|
3302
|
+
generateAltTextSuggestion,
|
|
3303
|
+
altTextSuggestionSourceService,
|
|
3304
|
+
applyAltTextSuggestion,
|
|
3305
|
+
acceptAltTextSuggestion,
|
|
3306
|
+
dismissAltTextSuggestion,
|
|
3307
|
+
setAltText,
|
|
3308
|
+
setFocalPoint,
|
|
3309
|
+
updateAssetDetails,
|
|
3310
|
+
trashAsset,
|
|
3311
|
+
restoreAsset,
|
|
3312
|
+
purgeAsset,
|
|
3313
|
+
purgeClaim,
|
|
3314
|
+
purgeExpiredAsset,
|
|
3315
|
+
purgeExpiredClaim,
|
|
3316
|
+
purgeApply,
|
|
3317
|
+
rescanAsset,
|
|
3318
|
+
rescanSourceService,
|
|
3319
|
+
applyRescan,
|
|
3320
|
+
...captureServices,
|
|
3321
|
+
];
|