@ekrist1/vulse 0.1.6-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +104 -0
- package/dist/admin/client/active-locale.d.ts +3 -0
- package/dist/admin/client/active-locale.d.ts.map +1 -0
- package/dist/admin/client/active-locale.js +14 -0
- package/dist/admin/client/api.d.ts +14 -0
- package/dist/admin/client/api.d.ts.map +1 -0
- package/dist/admin/client/api.js +26 -0
- package/dist/admin/client/form-from-zod.d.ts +2 -0
- package/dist/admin/client/form-from-zod.d.ts.map +1 -0
- package/dist/admin/client/form-from-zod.js +1 -0
- package/dist/admin/client/live-preview-enabled.d.ts +3 -0
- package/dist/admin/client/live-preview-enabled.d.ts.map +1 -0
- package/dist/admin/client/live-preview-enabled.js +6 -0
- package/dist/cli/collection-scaffold.d.ts +14 -0
- package/dist/cli/collection-scaffold.d.ts.map +1 -0
- package/dist/cli/collection-scaffold.js +44 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +74 -0
- package/dist/cli/migrate.d.ts +5 -0
- package/dist/cli/migrate.d.ts.map +1 -0
- package/dist/cli/migrate.js +10 -0
- package/dist/cli/platform.d.ts +12 -0
- package/dist/cli/platform.d.ts.map +1 -0
- package/dist/cli/platform.js +38 -0
- package/dist/cli/seed-admin.d.ts +19 -0
- package/dist/cli/seed-admin.d.ts.map +1 -0
- package/dist/cli/seed-admin.js +59 -0
- package/dist/cli/setup.d.ts +29 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +254 -0
- package/dist/core/access.d.ts +5 -0
- package/dist/core/access.d.ts.map +1 -0
- package/dist/core/access.js +6 -0
- package/dist/core/blocks/schema.d.ts +81 -0
- package/dist/core/blocks/schema.d.ts.map +1 -0
- package/dist/core/blocks/schema.js +54 -0
- package/dist/core/blueprints/code-to-definition.d.ts +6 -0
- package/dist/core/blueprints/code-to-definition.d.ts.map +1 -0
- package/dist/core/blueprints/code-to-definition.js +147 -0
- package/dist/core/blueprints/compile.d.ts +10 -0
- package/dist/core/blueprints/compile.d.ts.map +1 -0
- package/dist/core/blueprints/compile.js +153 -0
- package/dist/core/blueprints/define.d.ts +6 -0
- package/dist/core/blueprints/define.d.ts.map +1 -0
- package/dist/core/blueprints/define.js +8 -0
- package/dist/core/blueprints/definition.d.ts +963 -0
- package/dist/core/blueprints/definition.d.ts.map +1 -0
- package/dist/core/blueprints/definition.js +151 -0
- package/dist/core/blueprints/load.d.ts +11 -0
- package/dist/core/blueprints/load.d.ts.map +1 -0
- package/dist/core/blueprints/load.js +137 -0
- package/dist/core/blueprints/mutations.d.ts +8 -0
- package/dist/core/blueprints/mutations.d.ts.map +1 -0
- package/dist/core/blueprints/mutations.js +191 -0
- package/dist/core/blueprints/preview-path.d.ts +15 -0
- package/dist/core/blueprints/preview-path.d.ts.map +1 -0
- package/dist/core/blueprints/preview-path.js +25 -0
- package/dist/core/blueprints/reflect-fields.d.ts +36 -0
- package/dist/core/blueprints/reflect-fields.d.ts.map +1 -0
- package/dist/core/blueprints/reflect-fields.js +229 -0
- package/dist/core/blueprints/registry.d.ts +9 -0
- package/dist/core/blueprints/registry.d.ts.map +1 -0
- package/dist/core/blueprints/registry.js +11 -0
- package/dist/core/blueprints/seed.d.ts +5 -0
- package/dist/core/blueprints/seed.d.ts.map +1 -0
- package/dist/core/blueprints/seed.js +17 -0
- package/dist/core/blueprints/select-helpers.d.ts +10 -0
- package/dist/core/blueprints/select-helpers.d.ts.map +1 -0
- package/dist/core/blueprints/select-helpers.js +26 -0
- package/dist/core/blueprints/seo.d.ts +41 -0
- package/dist/core/blueprints/seo.d.ts.map +1 -0
- package/dist/core/blueprints/seo.js +125 -0
- package/dist/core/blueprints/types.d.ts +60 -0
- package/dist/core/blueprints/types.d.ts.map +1 -0
- package/dist/core/blueprints/types.js +1 -0
- package/dist/core/blueprints/zod-helpers.d.ts +79 -0
- package/dist/core/blueprints/zod-helpers.d.ts.map +1 -0
- package/dist/core/blueprints/zod-helpers.js +72 -0
- package/dist/core/db.d.ts +7 -0
- package/dist/core/db.d.ts.map +1 -0
- package/dist/core/db.js +8 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +29 -0
- package/dist/core/forms/compile.d.ts +9 -0
- package/dist/core/forms/compile.d.ts.map +1 -0
- package/dist/core/forms/compile.js +80 -0
- package/dist/core/forms/definition.d.ts +226 -0
- package/dist/core/forms/definition.d.ts.map +1 -0
- package/dist/core/forms/definition.js +83 -0
- package/dist/core/forms/rate-limit.d.ts +10 -0
- package/dist/core/forms/rate-limit.d.ts.map +1 -0
- package/dist/core/forms/rate-limit.js +31 -0
- package/dist/core/forms/unique.d.ts +5 -0
- package/dist/core/forms/unique.d.ts.map +1 -0
- package/dist/core/forms/unique.js +30 -0
- package/dist/core/globals/compile.d.ts +13 -0
- package/dist/core/globals/compile.d.ts.map +1 -0
- package/dist/core/globals/compile.js +17 -0
- package/dist/core/globals/definition.d.ts +161 -0
- package/dist/core/globals/definition.d.ts.map +1 -0
- package/dist/core/globals/definition.js +23 -0
- package/dist/core/locales.d.ts +14 -0
- package/dist/core/locales.d.ts.map +1 -0
- package/dist/core/locales.js +35 -0
- package/dist/core/migrations.d.ts +3 -0
- package/dist/core/migrations.d.ts.map +1 -0
- package/dist/core/migrations.js +41 -0
- package/dist/core/parse-content.d.ts +14 -0
- package/dist/core/parse-content.d.ts.map +1 -0
- package/dist/core/parse-content.js +68 -0
- package/dist/core/plugins/definition.d.ts +99 -0
- package/dist/core/plugins/definition.d.ts.map +1 -0
- package/dist/core/plugins/definition.js +10 -0
- package/dist/core/preview-content.d.ts +16 -0
- package/dist/core/preview-content.d.ts.map +1 -0
- package/dist/core/preview-content.js +8 -0
- package/dist/core/repos/entries.d.ts +102 -0
- package/dist/core/repos/entries.d.ts.map +1 -0
- package/dist/core/repos/entries.js +393 -0
- package/dist/core/repos/forms.d.ts +82 -0
- package/dist/core/repos/forms.d.ts.map +1 -0
- package/dist/core/repos/forms.js +199 -0
- package/dist/core/repos/globals.d.ts +31 -0
- package/dist/core/repos/globals.d.ts.map +1 -0
- package/dist/core/repos/globals.js +150 -0
- package/dist/core/repos/media.d.ts +39 -0
- package/dist/core/repos/media.d.ts.map +1 -0
- package/dist/core/repos/media.js +81 -0
- package/dist/core/repos/preview-sessions.d.ts +35 -0
- package/dist/core/repos/preview-sessions.d.ts.map +1 -0
- package/dist/core/repos/preview-sessions.js +85 -0
- package/dist/core/repos/revisions.d.ts +24 -0
- package/dist/core/repos/revisions.d.ts.map +1 -0
- package/dist/core/repos/revisions.js +44 -0
- package/dist/core/repos/settings.d.ts +9 -0
- package/dist/core/repos/settings.d.ts.map +1 -0
- package/dist/core/repos/settings.js +21 -0
- package/dist/core/schema.d.ts +2717 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +220 -0
- package/dist/core/sets/compile.d.ts +8 -0
- package/dist/core/sets/compile.d.ts.map +1 -0
- package/dist/core/sets/compile.js +4 -0
- package/dist/core/sets/definition.d.ts +53 -0
- package/dist/core/sets/definition.d.ts.map +1 -0
- package/dist/core/sets/definition.js +7 -0
- package/dist/core/sets/service.d.ts +13 -0
- package/dist/core/sets/service.d.ts.map +1 -0
- package/dist/core/sets/service.js +68 -0
- package/dist/core/sets/validate-tree.d.ts +4 -0
- package/dist/core/sets/validate-tree.d.ts.map +1 -0
- package/dist/core/sets/validate-tree.js +40 -0
- package/dist/core/slug.d.ts +5 -0
- package/dist/core/slug.d.ts.map +1 -0
- package/dist/core/slug.js +25 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/integration/cron.d.ts +4 -0
- package/dist/integration/cron.d.ts.map +1 -0
- package/dist/integration/cron.js +2 -0
- package/dist/integration/index.d.ts +9 -0
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +63 -0
- package/dist/integration/inject-admin-routes.d.ts +12 -0
- package/dist/integration/inject-admin-routes.d.ts.map +1 -0
- package/dist/integration/inject-admin-routes.js +35 -0
- package/dist/integration/inject-routes.d.ts +11 -0
- package/dist/integration/inject-routes.d.ts.map +1 -0
- package/dist/integration/inject-routes.js +51 -0
- package/dist/integration/install-hook.d.ts +2 -0
- package/dist/integration/install-hook.d.ts.map +1 -0
- package/dist/integration/install-hook.js +74 -0
- package/dist/integration/live-preview-middleware-helpers.d.ts +29 -0
- package/dist/integration/live-preview-middleware-helpers.d.ts.map +1 -0
- package/dist/integration/live-preview-middleware-helpers.js +75 -0
- package/dist/integration/loader-binding.d.ts +6 -0
- package/dist/integration/loader-binding.d.ts.map +1 -0
- package/dist/integration/loader-binding.js +15 -0
- package/dist/integration/middleware.d.ts +2 -0
- package/dist/integration/middleware.d.ts.map +1 -0
- package/dist/integration/middleware.js +51 -0
- package/dist/integration/type-gen.d.ts +2 -0
- package/dist/integration/type-gen.d.ts.map +1 -0
- package/dist/integration/type-gen.js +26 -0
- package/dist/integration/vite-plugin-blueprints.d.ts +3 -0
- package/dist/integration/vite-plugin-blueprints.d.ts.map +1 -0
- package/dist/integration/vite-plugin-blueprints.js +33 -0
- package/dist/integration/wrangler-patch.d.ts +6 -0
- package/dist/integration/wrangler-patch.d.ts.map +1 -0
- package/dist/integration/wrangler-patch.js +18 -0
- package/dist/integration.d.ts +3 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +1 -0
- package/dist/loader.d.ts +3 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +1 -0
- package/dist/package-name.d.ts +3 -0
- package/dist/package-name.d.ts.map +1 -0
- package/dist/package-name.js +2 -0
- package/dist/scaffold/collection-write.d.ts +14 -0
- package/dist/scaffold/collection-write.d.ts.map +1 -0
- package/dist/scaffold/collection-write.js +59 -0
- package/dist/scaffold/collection.d.ts +36 -0
- package/dist/scaffold/collection.d.ts.map +1 -0
- package/dist/scaffold/collection.js +231 -0
- package/dist/server/assets/live-preview-bridge.content.d.ts +2 -0
- package/dist/server/assets/live-preview-bridge.content.d.ts.map +1 -0
- package/dist/server/assets/live-preview-bridge.content.js +2 -0
- package/dist/server/better-auth.d.ts +71 -0
- package/dist/server/better-auth.d.ts.map +1 -0
- package/dist/server/better-auth.js +68 -0
- package/dist/server/cf-images.d.ts +12 -0
- package/dist/server/cf-images.d.ts.map +1 -0
- package/dist/server/cf-images.js +27 -0
- package/dist/server/cron.d.ts +9 -0
- package/dist/server/cron.d.ts.map +1 -0
- package/dist/server/cron.js +26 -0
- package/dist/server/email.d.ts +10 -0
- package/dist/server/email.d.ts.map +1 -0
- package/dist/server/email.js +9 -0
- package/dist/server/endpoints/api-auth.d.ts +5 -0
- package/dist/server/endpoints/api-auth.d.ts.map +1 -0
- package/dist/server/endpoints/api-auth.js +7 -0
- package/dist/server/endpoints/api-vulse-blueprints.d.ts +6 -0
- package/dist/server/endpoints/api-vulse-blueprints.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-blueprints.js +19 -0
- package/dist/server/endpoints/api-vulse-entries-locales.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-entries-locales.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-entries-locales.js +9 -0
- package/dist/server/endpoints/api-vulse-entries-move.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-entries-move.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-entries-move.js +5 -0
- package/dist/server/endpoints/api-vulse-entries-publish.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-entries-publish.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-entries-publish.js +5 -0
- package/dist/server/endpoints/api-vulse-entries-tree.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-entries-tree.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-entries-tree.js +5 -0
- package/dist/server/endpoints/api-vulse-entries.d.ts +6 -0
- package/dist/server/endpoints/api-vulse-entries.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-entries.js +19 -0
- package/dist/server/endpoints/api-vulse-form-handle.d.ts +6 -0
- package/dist/server/endpoints/api-vulse-form-handle.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-form-handle.js +27 -0
- package/dist/server/endpoints/api-vulse-form-public.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-form-public.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-form-public.js +5 -0
- package/dist/server/endpoints/api-vulse-form-submit.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-form-submit.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-form-submit.js +5 -0
- package/dist/server/endpoints/api-vulse-form-upload.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-form-upload.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-form-upload.js +5 -0
- package/dist/server/endpoints/api-vulse-forms.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-forms.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-forms.js +9 -0
- package/dist/server/endpoints/api-vulse-globals-handle.d.ts +5 -0
- package/dist/server/endpoints/api-vulse-globals-handle.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-globals-handle.js +19 -0
- package/dist/server/endpoints/api-vulse-globals-public-handle.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-globals-public-handle.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-globals-public-handle.js +5 -0
- package/dist/server/endpoints/api-vulse-globals-public.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-globals-public.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-globals-public.js +5 -0
- package/dist/server/endpoints/api-vulse-globals-value.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-globals-value.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-globals-value.js +7 -0
- package/dist/server/endpoints/api-vulse-globals.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-globals.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-globals.js +9 -0
- package/dist/server/endpoints/api-vulse-media-file.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-media-file.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-media-file.js +5 -0
- package/dist/server/endpoints/api-vulse-media-id.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-media-id.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-media-id.js +9 -0
- package/dist/server/endpoints/api-vulse-media.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-media.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-media.js +9 -0
- package/dist/server/endpoints/api-vulse-preview-bridge.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-preview-bridge.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-preview-bridge.js +9 -0
- package/dist/server/endpoints/api-vulse-preview-sessions-id.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-preview-sessions-id.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-preview-sessions-id.js +10 -0
- package/dist/server/endpoints/api-vulse-preview-sessions.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-preview-sessions.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-preview-sessions.js +5 -0
- package/dist/server/endpoints/api-vulse-preview-start.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-preview-start.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-preview-start.js +5 -0
- package/dist/server/endpoints/api-vulse-preview-stop.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-preview-stop.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-preview-stop.js +5 -0
- package/dist/server/endpoints/api-vulse-revisions-restore.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-revisions-restore.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-revisions-restore.js +5 -0
- package/dist/server/endpoints/api-vulse-revisions.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-revisions.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-revisions.js +5 -0
- package/dist/server/endpoints/api-vulse-search.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-search.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-search.js +5 -0
- package/dist/server/endpoints/api-vulse-sets.d.ts +6 -0
- package/dist/server/endpoints/api-vulse-sets.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-sets.js +19 -0
- package/dist/server/endpoints/api-vulse-settings.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-settings.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-settings.js +9 -0
- package/dist/server/endpoints/api-vulse-users-id.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-users-id.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-users-id.js +9 -0
- package/dist/server/endpoints/api-vulse-users-reset-password.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-users-reset-password.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-users-reset-password.js +5 -0
- package/dist/server/endpoints/api-vulse-users-role.d.ts +4 -0
- package/dist/server/endpoints/api-vulse-users-role.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-users-role.js +6 -0
- package/dist/server/endpoints/api-vulse-users.d.ts +3 -0
- package/dist/server/endpoints/api-vulse-users.d.ts.map +1 -0
- package/dist/server/endpoints/api-vulse-users.js +5 -0
- package/dist/server/endpoints/with-runtime.d.ts +2 -0
- package/dist/server/endpoints/with-runtime.d.ts.map +1 -0
- package/dist/server/endpoints/with-runtime.js +10 -0
- package/dist/server/env.d.ts +16 -0
- package/dist/server/env.d.ts.map +1 -0
- package/dist/server/env.js +9 -0
- package/dist/server/envelope.d.ts +15 -0
- package/dist/server/envelope.d.ts.map +1 -0
- package/dist/server/envelope.js +16 -0
- package/dist/server/forms/email.d.ts +8 -0
- package/dist/server/forms/email.d.ts.map +1 -0
- package/dist/server/forms/email.js +6 -0
- package/dist/server/forms/process-submission.d.ts +8 -0
- package/dist/server/forms/process-submission.d.ts.map +1 -0
- package/dist/server/forms/process-submission.js +75 -0
- package/dist/server/forms/queue.d.ts +8 -0
- package/dist/server/forms/queue.d.ts.map +1 -0
- package/dist/server/forms/queue.js +17 -0
- package/dist/server/forms/templates.d.ts +9 -0
- package/dist/server/forms/templates.d.ts.map +1 -0
- package/dist/server/forms/templates.js +14 -0
- package/dist/server/forms/webhook.d.ts +2 -0
- package/dist/server/forms/webhook.d.ts.map +1 -0
- package/dist/server/forms/webhook.js +17 -0
- package/dist/server/handler.d.ts +17 -0
- package/dist/server/handler.d.ts.map +1 -0
- package/dist/server/handler.js +45 -0
- package/dist/server/image-probe.d.ts +6 -0
- package/dist/server/image-probe.d.ts.map +1 -0
- package/dist/server/image-probe.js +38 -0
- package/dist/server/loader.d.ts +10 -0
- package/dist/server/loader.d.ts.map +1 -0
- package/dist/server/loader.js +42 -0
- package/dist/server/plugins.d.ts +17 -0
- package/dist/server/plugins.d.ts.map +1 -0
- package/dist/server/plugins.js +134 -0
- package/dist/server/preview.d.ts +7 -0
- package/dist/server/preview.d.ts.map +1 -0
- package/dist/server/preview.js +22 -0
- package/dist/server/r2.d.ts +8 -0
- package/dist/server/r2.d.ts.map +1 -0
- package/dist/server/r2.js +9 -0
- package/dist/server/routes/blueprints.d.ts +10 -0
- package/dist/server/routes/blueprints.d.ts.map +1 -0
- package/dist/server/routes/blueprints.js +46 -0
- package/dist/server/routes/entries.d.ts +16 -0
- package/dist/server/routes/entries.d.ts.map +1 -0
- package/dist/server/routes/entries.js +262 -0
- package/dist/server/routes/form-submit.d.ts +10 -0
- package/dist/server/routes/form-submit.d.ts.map +1 -0
- package/dist/server/routes/form-submit.js +155 -0
- package/dist/server/routes/form-upload.d.ts +11 -0
- package/dist/server/routes/form-upload.d.ts.map +1 -0
- package/dist/server/routes/form-upload.js +87 -0
- package/dist/server/routes/forms.d.ts +14 -0
- package/dist/server/routes/forms.d.ts.map +1 -0
- package/dist/server/routes/forms.js +78 -0
- package/dist/server/routes/globals-public.d.ts +6 -0
- package/dist/server/routes/globals-public.d.ts.map +1 -0
- package/dist/server/routes/globals-public.js +30 -0
- package/dist/server/routes/globals.d.ts +11 -0
- package/dist/server/routes/globals.d.ts.map +1 -0
- package/dist/server/routes/globals.js +84 -0
- package/dist/server/routes/media.d.ts +23 -0
- package/dist/server/routes/media.d.ts.map +1 -0
- package/dist/server/routes/media.js +129 -0
- package/dist/server/routes/preview-sessions.d.ts +9 -0
- package/dist/server/routes/preview-sessions.d.ts.map +1 -0
- package/dist/server/routes/preview-sessions.js +74 -0
- package/dist/server/routes/preview.d.ts +6 -0
- package/dist/server/routes/preview.d.ts.map +1 -0
- package/dist/server/routes/preview.js +37 -0
- package/dist/server/routes/revisions.d.ts +7 -0
- package/dist/server/routes/revisions.d.ts.map +1 -0
- package/dist/server/routes/revisions.js +26 -0
- package/dist/server/routes/search.d.ts +6 -0
- package/dist/server/routes/search.d.ts.map +1 -0
- package/dist/server/routes/search.js +28 -0
- package/dist/server/routes/sets.d.ts +10 -0
- package/dist/server/routes/sets.d.ts.map +1 -0
- package/dist/server/routes/sets.js +33 -0
- package/dist/server/routes/settings.d.ts +7 -0
- package/dist/server/routes/settings.d.ts.map +1 -0
- package/dist/server/routes/settings.js +21 -0
- package/dist/server/routes/users.d.ts +10 -0
- package/dist/server/routes/users.d.ts.map +1 -0
- package/dist/server/routes/users.js +113 -0
- package/dist/server/runtime.d.ts +49 -0
- package/dist/server/runtime.d.ts.map +1 -0
- package/dist/server/runtime.js +69 -0
- package/dist/server/sdk/collections.d.ts +25 -0
- package/dist/server/sdk/collections.d.ts.map +1 -0
- package/dist/server/sdk/collections.js +76 -0
- package/dist/server/sdk/index.d.ts +45 -0
- package/dist/server/sdk/index.d.ts.map +1 -0
- package/dist/server/sdk/index.js +13 -0
- package/dist/server/sdk/media.d.ts +7 -0
- package/dist/server/sdk/media.d.ts.map +1 -0
- package/dist/server/sdk/media.js +9 -0
- package/dist/server/sdk/search.d.ts +19 -0
- package/dist/server/sdk/search.d.ts.map +1 -0
- package/dist/server/sdk/search.js +58 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +6 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/migrations/0000_init.sql +114 -0
- package/migrations/0001_collections_sets.sql +21 -0
- package/migrations/0003_fts.sql +22 -0
- package/migrations/0004_forms.sql +58 -0
- package/migrations/0005_globals.sql +16 -0
- package/migrations/0006_preview_sessions.sql +16 -0
- package/migrations/meta/0000_snapshot.json +672 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +130 -0
- package/src/client/BlockRenderer.astro +40 -0
- package/src/client/BlockRenderer.vue +42 -0
- package/src/client/Node.vue +21 -0
- package/src/client/ProseMirrorRenderer.vue +31 -0
- package/src/client/auth.ts +28 -0
- package/src/client/blocks/Blockquote.vue +12 -0
- package/src/client/blocks/BulletList.vue +12 -0
- package/src/client/blocks/CodeBlock.vue +12 -0
- package/src/client/blocks/Emoji.vue +14 -0
- package/src/client/blocks/HardBreak.vue +1 -0
- package/src/client/blocks/Heading.vue +17 -0
- package/src/client/blocks/ListItem.vue +12 -0
- package/src/client/blocks/OrderedList.vue +12 -0
- package/src/client/blocks/Paragraph.vue +12 -0
- package/src/client/blocks/Text.vue +33 -0
- package/src/client/blocks/VulseAccordion.vue +16 -0
- package/src/client/blocks/VulseAccordionGroup.vue +12 -0
- package/src/client/blocks/VulseCallout.vue +14 -0
- package/src/client/blocks/VulseIframe.vue +65 -0
- package/src/client/blocks/VulseImage.vue +30 -0
- package/src/client/blocks/VulseSet.vue +26 -0
- package/src/client/blocks/VulseVideo.vue +18 -0
- package/src/client/components/ForgotPasswordForm.astro +71 -0
- package/src/client/components/FormRenderer.astro +40 -0
- package/src/client/components/ResetPasswordForm.astro +72 -0
- package/src/client/components/SessionGuard.astro +27 -0
- package/src/client/components/SignInForm.astro +57 -0
- package/src/client/components/SignOutButton.astro +22 -0
- package/src/client/components/SignUpForm.astro +61 -0
- package/src/client/components/VulseImage.vue +25 -0
- package/src/client/embed.ts +52 -0
- package/src/client/index.ts +2 -0
- package/src/client/inject.ts +4 -0
- package/src/client/live-preview-bridge.ts +20 -0
- package/src/client/pm-defaults.ts +38 -0
- package/src/client/pm-types.ts +21 -0
- package/src/client/render-pm-html.ts +154 -0
- package/src/client/url.ts +35 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ValidationError } from '../core/errors.js';
|
|
2
|
+
import { assertValidPluginId, } from '../core/plugins/definition.js';
|
|
3
|
+
import { sendFormEmail } from './forms/email.js';
|
|
4
|
+
const DEFAULT_HOOK_TIMEOUT_MS = 5_000;
|
|
5
|
+
let registeredPlugins = [];
|
|
6
|
+
function orderedPlugins() {
|
|
7
|
+
return [...registeredPlugins].sort((a, b) => {
|
|
8
|
+
const priority = (b.plugin.priority ?? 0) - (a.plugin.priority ?? 0);
|
|
9
|
+
return priority || a.order - b.order;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function setVulsePlugins(plugins = []) {
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
registeredPlugins = plugins.map((plugin, order) => {
|
|
15
|
+
assertValidPluginId(plugin.id);
|
|
16
|
+
if (seen.has(plugin.id))
|
|
17
|
+
throw new Error(`Vulse plugin "${plugin.id}" is registered more than once`);
|
|
18
|
+
seen.add(plugin.id);
|
|
19
|
+
return { plugin, order };
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function getVulsePlugins() {
|
|
23
|
+
return orderedPlugins().map(({ plugin }) => plugin);
|
|
24
|
+
}
|
|
25
|
+
export function __testResetVulsePlugins() {
|
|
26
|
+
registeredPlugins = [];
|
|
27
|
+
}
|
|
28
|
+
function loggerFor(pluginId) {
|
|
29
|
+
return {
|
|
30
|
+
debug: (message, data) => console.debug(`[vulse:${pluginId}] ${message}`, data ?? ''),
|
|
31
|
+
info: (message, data) => console.info(`[vulse:${pluginId}] ${message}`, data ?? ''),
|
|
32
|
+
warn: (message, data) => console.warn(`[vulse:${pluginId}] ${message}`, data ?? ''),
|
|
33
|
+
error: (message, data) => console.error(`[vulse:${pluginId}] ${message}`, data ?? ''),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function pluginContext(pluginId, env) {
|
|
37
|
+
const safeEnv = env ?? {};
|
|
38
|
+
return {
|
|
39
|
+
env: safeEnv,
|
|
40
|
+
logger: loggerFor(pluginId),
|
|
41
|
+
email: {
|
|
42
|
+
send: async (input) => {
|
|
43
|
+
await sendFormEmail(safeEnv, {
|
|
44
|
+
to: input.to,
|
|
45
|
+
subject: input.subject,
|
|
46
|
+
body: input.body ?? input.text ?? input.html ?? '',
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async function withTimeout(promise, pluginId, hookName) {
|
|
53
|
+
let timeout;
|
|
54
|
+
try {
|
|
55
|
+
return await Promise.race([
|
|
56
|
+
promise,
|
|
57
|
+
new Promise((_, reject) => {
|
|
58
|
+
timeout = setTimeout(() => {
|
|
59
|
+
reject(new Error(`Vulse plugin "${pluginId}" hook "${hookName}" timed out`));
|
|
60
|
+
}, DEFAULT_HOOK_TIMEOUT_MS);
|
|
61
|
+
}),
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
if (timeout)
|
|
66
|
+
clearTimeout(timeout);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function invokeHook(plugin, hookName, event, env) {
|
|
70
|
+
const hook = plugin.hooks?.[hookName];
|
|
71
|
+
if (!hook)
|
|
72
|
+
return undefined;
|
|
73
|
+
return await withTimeout(Promise.resolve(hook(event, pluginContext(plugin.id, env))), plugin.id, hookName);
|
|
74
|
+
}
|
|
75
|
+
async function runContinueHook(hookName, event, env) {
|
|
76
|
+
for (const { plugin } of orderedPlugins()) {
|
|
77
|
+
try {
|
|
78
|
+
await invokeHook(plugin, hookName, event, env);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
pluginContext(plugin.id, env).logger.error(`Hook "${hookName}" failed`, err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export async function runFormBeforeSubmitHooks(event, env) {
|
|
86
|
+
let payload = event.payload;
|
|
87
|
+
for (const { plugin } of orderedPlugins()) {
|
|
88
|
+
const result = await invokeHook(plugin, 'form:beforeSubmit', { ...event, payload }, env);
|
|
89
|
+
if (!result)
|
|
90
|
+
continue;
|
|
91
|
+
if (result.action === 'drop') {
|
|
92
|
+
return { action: 'drop', ...(result.reason ? { reason: result.reason } : {}) };
|
|
93
|
+
}
|
|
94
|
+
if (result.action === 'reject') {
|
|
95
|
+
throw new ValidationError(result.message ?? `Submission rejected by plugin "${plugin.id}"`, { plugin: plugin.id });
|
|
96
|
+
}
|
|
97
|
+
if (result.payload)
|
|
98
|
+
payload = result.payload;
|
|
99
|
+
}
|
|
100
|
+
return { action: 'continue', payload };
|
|
101
|
+
}
|
|
102
|
+
export async function runFormAfterSubmitHooks(event, env) {
|
|
103
|
+
await runContinueHook('form:afterSubmit', event, env);
|
|
104
|
+
}
|
|
105
|
+
export async function runFormBeforeProcessHooks(event, env) {
|
|
106
|
+
for (const { plugin } of orderedPlugins()) {
|
|
107
|
+
await invokeHook(plugin, 'form:beforeProcess', event, env);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export async function runFormAfterProcessHooks(event, env) {
|
|
111
|
+
await runContinueHook('form:afterProcess', event, env);
|
|
112
|
+
}
|
|
113
|
+
export async function runAuthUserBeforeCreateHooks(event, env) {
|
|
114
|
+
let user = event.user;
|
|
115
|
+
let changed = false;
|
|
116
|
+
for (const { plugin } of orderedPlugins()) {
|
|
117
|
+
const result = await invokeHook(plugin, 'auth:userBeforeCreate', { user }, env);
|
|
118
|
+
if (result === false)
|
|
119
|
+
return false;
|
|
120
|
+
if (!result)
|
|
121
|
+
continue;
|
|
122
|
+
if (result.action === 'reject') {
|
|
123
|
+
throw new Error(result.message ?? `User rejected by plugin "${plugin.id}"`);
|
|
124
|
+
}
|
|
125
|
+
if (result.data) {
|
|
126
|
+
user = { ...user, ...result.data };
|
|
127
|
+
changed = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return changed ? user : undefined;
|
|
131
|
+
}
|
|
132
|
+
export async function runAuthUserAfterCreateHooks(event, env) {
|
|
133
|
+
await runContinueHook('auth:userAfterCreate', event, env);
|
|
134
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function mintPreviewToken(secret: string, userId: string, ttlSeconds?: number): Promise<string>;
|
|
2
|
+
export declare function verifyPreviewToken(secret: string, token: string): Promise<boolean>;
|
|
3
|
+
export declare function previewSecret(env: {
|
|
4
|
+
VULSE_PREVIEW_SECRET?: string;
|
|
5
|
+
BETTER_AUTH_SECRET: string;
|
|
6
|
+
}): string;
|
|
7
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/server/preview.ts"],"names":[],"mappings":"AAIA,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,SAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5G;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQxF;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAExG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SignJWT, jwtVerify } from 'jose';
|
|
2
|
+
const ALG = 'HS256';
|
|
3
|
+
export async function mintPreviewToken(secret, userId, ttlSeconds = 60 * 60) {
|
|
4
|
+
const key = new TextEncoder().encode(secret);
|
|
5
|
+
return await new SignJWT({ sub: userId, kind: 'vulse-preview' })
|
|
6
|
+
.setProtectedHeader({ alg: ALG })
|
|
7
|
+
.setExpirationTime(Math.floor(Date.now() / 1000) + ttlSeconds)
|
|
8
|
+
.sign(key);
|
|
9
|
+
}
|
|
10
|
+
export async function verifyPreviewToken(secret, token) {
|
|
11
|
+
try {
|
|
12
|
+
const key = new TextEncoder().encode(secret);
|
|
13
|
+
const { payload } = await jwtVerify(token, key);
|
|
14
|
+
return payload.kind === 'vulse-preview';
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function previewSecret(env) {
|
|
21
|
+
return env.VULSE_PREVIEW_SECRET ?? env.BETTER_AUTH_SECRET;
|
|
22
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface UploadContext {
|
|
2
|
+
bucket: R2Bucket;
|
|
3
|
+
}
|
|
4
|
+
export declare function putToR2(ctx: UploadContext, body: ArrayBuffer, mime: string): Promise<{
|
|
5
|
+
key: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function deleteFromR2(ctx: UploadContext, key: string): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=r2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"r2.d.ts","sourceRoot":"","sources":["../../src/server/r2.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAAG,MAAM,EAAE,QAAQ,CAAA;CAAE;AAEnD,wBAAsB,OAAO,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAI3G;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid';
|
|
2
|
+
export async function putToR2(ctx, body, mime) {
|
|
3
|
+
const key = `${new Date().toISOString().slice(0, 10)}/${nanoid()}`;
|
|
4
|
+
await ctx.bucket.put(key, body, { httpMetadata: { contentType: mime } });
|
|
5
|
+
return { key };
|
|
6
|
+
}
|
|
7
|
+
export async function deleteFromR2(ctx, key) {
|
|
8
|
+
await ctx.bucket.delete(key);
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Auth } from '../better-auth.js';
|
|
2
|
+
import type { VulseDb } from '../../core/db.js';
|
|
3
|
+
export declare function blueprintsRoutes(db: VulseDb, auth: Auth): {
|
|
4
|
+
list: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
5
|
+
get: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
6
|
+
create: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
7
|
+
update: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
8
|
+
delete: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=blueprints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blueprints.d.ts","sourceRoot":"","sources":["../../../src/server/routes/blueprints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAkB/C,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;;;;;;EAyCvD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { BlueprintDefinitionSchema, BlueprintDefinitionWithRenamesSchema, } from '../../core/blueprints/definition.js';
|
|
3
|
+
import { createBlueprint, deleteBlueprint, getBlueprintDefinition, listBlueprintDefinitions, updateBlueprint, } from '../../core/blueprints/mutations.js';
|
|
4
|
+
import { _resetRegistry } from '../../core/blueprints/load.js';
|
|
5
|
+
import { _resetRuntime } from '../runtime.js';
|
|
6
|
+
import { defineHandler } from '../handler.js';
|
|
7
|
+
const paramsHandle = z.object({ handle: z.string() });
|
|
8
|
+
export function blueprintsRoutes(db, auth) {
|
|
9
|
+
return {
|
|
10
|
+
list: defineHandler(auth, {}, async () => listBlueprintDefinitions(db)),
|
|
11
|
+
get: defineHandler(auth, { params: paramsHandle }, async ({ params }) => {
|
|
12
|
+
const def = await getBlueprintDefinition(db, params.handle);
|
|
13
|
+
if (!def)
|
|
14
|
+
throw new (await import('../../core/errors.js')).NotFoundError('blueprint not found');
|
|
15
|
+
return def;
|
|
16
|
+
}),
|
|
17
|
+
create: defineHandler(auth, {
|
|
18
|
+
body: BlueprintDefinitionSchema,
|
|
19
|
+
requireRole: ['admin'],
|
|
20
|
+
}, async ({ body }) => {
|
|
21
|
+
const out = await createBlueprint(db, body);
|
|
22
|
+
_resetRegistry();
|
|
23
|
+
_resetRuntime();
|
|
24
|
+
return out;
|
|
25
|
+
}),
|
|
26
|
+
update: defineHandler(auth, {
|
|
27
|
+
params: paramsHandle,
|
|
28
|
+
body: BlueprintDefinitionWithRenamesSchema,
|
|
29
|
+
requireRole: ['admin'],
|
|
30
|
+
}, async ({ params, body }) => {
|
|
31
|
+
const out = await updateBlueprint(db, params.handle, body);
|
|
32
|
+
_resetRegistry();
|
|
33
|
+
_resetRuntime();
|
|
34
|
+
return out;
|
|
35
|
+
}),
|
|
36
|
+
delete: defineHandler(auth, {
|
|
37
|
+
params: paramsHandle,
|
|
38
|
+
requireRole: ['admin'],
|
|
39
|
+
}, async ({ params }) => {
|
|
40
|
+
await deleteBlueprint(db, params.handle);
|
|
41
|
+
_resetRegistry();
|
|
42
|
+
_resetRuntime();
|
|
43
|
+
return null;
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VulseDb } from '../../core/db.js';
|
|
2
|
+
import type { Auth } from '../better-auth.js';
|
|
3
|
+
import type { BlueprintRegistry } from '../../core/blueprints/registry.js';
|
|
4
|
+
export declare function entriesRoutes(db: VulseDb, auth: Auth, reg: BlueprintRegistry): {
|
|
5
|
+
list: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
6
|
+
tree: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
7
|
+
findById: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
8
|
+
listLocales: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
9
|
+
create: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
10
|
+
createLocale: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
11
|
+
update: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
12
|
+
move: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
13
|
+
publish: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
14
|
+
delete: (request: Request, rawParams?: Record<string, string>) => Promise<Response>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../../src/server/routes/entries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAmC1E,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,iBAAiB;;;;;;;;;;;EAwN5E"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { DEFAULT_LOCALE, EntriesRepo } from '../../core/repos/entries.js';
|
|
3
|
+
import { AccessDeniedError, NotFoundError, ValidationError } from '../../core/errors.js';
|
|
4
|
+
import { evaluate } from '../../core/access.js';
|
|
5
|
+
import { parseContent } from '../../core/parse-content.js';
|
|
6
|
+
import { defineHandler } from '../handler.js';
|
|
7
|
+
import { isValidLocaleCode, readLocalesConfig } from '../../core/locales.js';
|
|
8
|
+
/**
|
|
9
|
+
* The URL slug is owned by the entry locale row. If a user schema also declares a
|
|
10
|
+
* `slug` field (common for templates), it is hidden from the form; we mirror
|
|
11
|
+
* the canonical slug into content here so schemas that require it still parse.
|
|
12
|
+
*/
|
|
13
|
+
function withCanonicalSlug(content, slug) {
|
|
14
|
+
if (slug === undefined)
|
|
15
|
+
return content;
|
|
16
|
+
if (content === null || typeof content !== 'object' || Array.isArray(content))
|
|
17
|
+
return content;
|
|
18
|
+
return { ...content, slug };
|
|
19
|
+
}
|
|
20
|
+
const paramsByCollection = z.object({ collection: z.string() });
|
|
21
|
+
const paramsById = z.object({ collection: z.string(), id: z.string() });
|
|
22
|
+
async function resolveLocaleParam(db, raw) {
|
|
23
|
+
const cfg = await readLocalesConfig(db);
|
|
24
|
+
if (!raw || raw === DEFAULT_LOCALE)
|
|
25
|
+
return cfg.defaultLocale;
|
|
26
|
+
if (!isValidLocaleCode(raw))
|
|
27
|
+
throw new ValidationError(`Invalid locale code: ${raw}`);
|
|
28
|
+
if (!cfg.locales.includes(raw)) {
|
|
29
|
+
throw new ValidationError(`Locale '${raw}' is not enabled for this site.`, {
|
|
30
|
+
field: 'locale',
|
|
31
|
+
supported: cfg.locales,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return raw;
|
|
35
|
+
}
|
|
36
|
+
export function entriesRoutes(db, auth, reg) {
|
|
37
|
+
const entries = new EntriesRepo(db);
|
|
38
|
+
function blueprintFor(name) {
|
|
39
|
+
const bp = reg.get(name);
|
|
40
|
+
if (!bp)
|
|
41
|
+
throw new NotFoundError(`Unknown collection: ${name}`);
|
|
42
|
+
return bp;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
list: defineHandler(auth, { params: paramsByCollection }, async ({ params, url, auth: authCtx }) => {
|
|
46
|
+
const bp = blueprintFor(params.collection);
|
|
47
|
+
const locale = await resolveLocaleParam(db, url.searchParams.get('locale'));
|
|
48
|
+
if (!(await evaluate(bp, 'read', { user: authCtx.user }))) {
|
|
49
|
+
return await entries.list({ collection: params.collection, locale, status: 'published' });
|
|
50
|
+
}
|
|
51
|
+
const parentRaw = url.searchParams.get('parentId');
|
|
52
|
+
const parentId = parentRaw === 'root' || parentRaw === '' ? null : parentRaw ?? undefined;
|
|
53
|
+
return await entries.list({
|
|
54
|
+
collection: params.collection,
|
|
55
|
+
locale,
|
|
56
|
+
...(parentId !== undefined ? { parentId } : {}),
|
|
57
|
+
});
|
|
58
|
+
}),
|
|
59
|
+
tree: defineHandler(auth, {
|
|
60
|
+
params: paramsByCollection,
|
|
61
|
+
requireRole: ['admin', 'editor'],
|
|
62
|
+
}, async ({ params, url }) => {
|
|
63
|
+
const bp = blueprintFor(params.collection);
|
|
64
|
+
if (!bp.tree)
|
|
65
|
+
throw new ValidationError('Collection does not support tree structure');
|
|
66
|
+
const locale = await resolveLocaleParam(db, url.searchParams.get('locale'));
|
|
67
|
+
return await entries.tree(params.collection, locale);
|
|
68
|
+
}),
|
|
69
|
+
findById: defineHandler(auth, { params: paramsById }, async ({ params, url, auth: authCtx }) => {
|
|
70
|
+
const bp = blueprintFor(params.collection);
|
|
71
|
+
const locale = await resolveLocaleParam(db, url.searchParams.get('locale'));
|
|
72
|
+
const row = await entries.findById(params.id, locale);
|
|
73
|
+
if (!row)
|
|
74
|
+
throw new NotFoundError(`Entry ${params.id} (${locale}) not found`);
|
|
75
|
+
const allowed = await evaluate(bp, 'read', {
|
|
76
|
+
user: authCtx.user,
|
|
77
|
+
entry: { id: row.id, status: row.status, createdBy: row.createdBy, content: row.content },
|
|
78
|
+
});
|
|
79
|
+
if (!allowed)
|
|
80
|
+
throw new NotFoundError(`Entry ${params.id} not found`);
|
|
81
|
+
return row;
|
|
82
|
+
}),
|
|
83
|
+
listLocales: defineHandler(auth, {
|
|
84
|
+
params: paramsById,
|
|
85
|
+
requireRole: ['admin', 'editor'],
|
|
86
|
+
}, async ({ params }) => {
|
|
87
|
+
blueprintFor(params.collection);
|
|
88
|
+
return await entries.listLocales(params.id);
|
|
89
|
+
}),
|
|
90
|
+
create: defineHandler(auth, {
|
|
91
|
+
params: paramsByCollection,
|
|
92
|
+
body: z.object({
|
|
93
|
+
slug: z.string(),
|
|
94
|
+
content: z.unknown(),
|
|
95
|
+
status: z.enum(['draft', 'published']).optional(),
|
|
96
|
+
parentId: z.string().nullable().optional(),
|
|
97
|
+
locale: z.string().optional(),
|
|
98
|
+
}),
|
|
99
|
+
}, async ({ params, body, auth: authCtx }) => {
|
|
100
|
+
const bp = blueprintFor(params.collection);
|
|
101
|
+
const allowed = await evaluate(bp, 'create', { user: authCtx.user });
|
|
102
|
+
if (!allowed)
|
|
103
|
+
throw new AccessDeniedError('Cannot create');
|
|
104
|
+
if (!authCtx.user)
|
|
105
|
+
throw new AccessDeniedError('Authentication required');
|
|
106
|
+
if (body.parentId && !bp.tree)
|
|
107
|
+
throw new ValidationError('Collection does not support nesting');
|
|
108
|
+
const locale = await resolveLocaleParam(db, body.locale);
|
|
109
|
+
const validated = parseContent(bp.schema, withCanonicalSlug(body.content, body.slug));
|
|
110
|
+
return await entries.create({
|
|
111
|
+
collection: params.collection,
|
|
112
|
+
slug: body.slug,
|
|
113
|
+
content: validated,
|
|
114
|
+
locale,
|
|
115
|
+
...(body.status !== undefined ? { status: body.status } : {}),
|
|
116
|
+
...(body.parentId !== undefined ? { parentId: body.parentId } : {}),
|
|
117
|
+
draftsEnabled: bp.drafts === true,
|
|
118
|
+
createdBy: authCtx.user.id,
|
|
119
|
+
});
|
|
120
|
+
}),
|
|
121
|
+
createLocale: defineHandler(auth, {
|
|
122
|
+
params: paramsById,
|
|
123
|
+
body: z.object({
|
|
124
|
+
locale: z.string(),
|
|
125
|
+
slug: z.string(),
|
|
126
|
+
content: z.unknown(),
|
|
127
|
+
status: z.enum(['draft', 'published']).optional(),
|
|
128
|
+
}),
|
|
129
|
+
}, async ({ params, body, auth: authCtx }) => {
|
|
130
|
+
const bp = blueprintFor(params.collection);
|
|
131
|
+
const allowed = await evaluate(bp, 'create', { user: authCtx.user });
|
|
132
|
+
if (!allowed)
|
|
133
|
+
throw new AccessDeniedError('Cannot create');
|
|
134
|
+
if (!authCtx.user)
|
|
135
|
+
throw new AccessDeniedError('Authentication required');
|
|
136
|
+
const locale = await resolveLocaleParam(db, body.locale);
|
|
137
|
+
const validated = parseContent(bp.schema, withCanonicalSlug(body.content, body.slug));
|
|
138
|
+
return await entries.createLocale(params.id, {
|
|
139
|
+
locale,
|
|
140
|
+
slug: body.slug,
|
|
141
|
+
content: validated,
|
|
142
|
+
updatedBy: authCtx.user.id,
|
|
143
|
+
...(body.status !== undefined ? { status: body.status } : {}),
|
|
144
|
+
draftsEnabled: bp.drafts === true,
|
|
145
|
+
});
|
|
146
|
+
}),
|
|
147
|
+
update: defineHandler(auth, {
|
|
148
|
+
params: paramsById,
|
|
149
|
+
body: z.object({
|
|
150
|
+
slug: z.string().optional(),
|
|
151
|
+
content: z.unknown().optional(),
|
|
152
|
+
status: z.enum(['draft', 'published']).optional(),
|
|
153
|
+
changeSummary: z.string().optional(),
|
|
154
|
+
publish: z.boolean().optional(),
|
|
155
|
+
locale: z.string().optional(),
|
|
156
|
+
}),
|
|
157
|
+
}, async ({ params, body, auth: authCtx }) => {
|
|
158
|
+
const bp = blueprintFor(params.collection);
|
|
159
|
+
const locale = await resolveLocaleParam(db, body.locale);
|
|
160
|
+
const row = await entries.findById(params.id, locale);
|
|
161
|
+
if (!row)
|
|
162
|
+
throw new NotFoundError(`Entry ${params.id} (${locale}) not found`);
|
|
163
|
+
const allowed = await evaluate(bp, 'update', {
|
|
164
|
+
user: authCtx.user,
|
|
165
|
+
entry: { id: row.id, status: row.status, createdBy: row.createdBy, content: row.content },
|
|
166
|
+
});
|
|
167
|
+
if (!allowed)
|
|
168
|
+
throw new AccessDeniedError('Cannot update');
|
|
169
|
+
if (!authCtx.user)
|
|
170
|
+
throw new AccessDeniedError('Authentication required');
|
|
171
|
+
const nextSlug = body.slug ?? row.slug;
|
|
172
|
+
const validated = body.content !== undefined
|
|
173
|
+
? parseContent(bp.schema, withCanonicalSlug(body.content, nextSlug))
|
|
174
|
+
: undefined;
|
|
175
|
+
return await entries.updateWithRevision(params.id, {
|
|
176
|
+
locale,
|
|
177
|
+
...(body.slug !== undefined ? { slug: body.slug } : {}),
|
|
178
|
+
...(validated !== undefined ? { content: validated } : {}),
|
|
179
|
+
...(body.status !== undefined ? { status: body.status } : {}),
|
|
180
|
+
...(body.publish !== undefined ? { publish: body.publish } : {}),
|
|
181
|
+
draftsEnabled: bp.drafts === true,
|
|
182
|
+
updatedBy: authCtx.user.id,
|
|
183
|
+
...(body.changeSummary !== undefined ? { changeSummary: body.changeSummary } : {}),
|
|
184
|
+
});
|
|
185
|
+
}),
|
|
186
|
+
move: defineHandler(auth, {
|
|
187
|
+
params: paramsById,
|
|
188
|
+
body: z.object({
|
|
189
|
+
parentId: z.string().nullable(),
|
|
190
|
+
sortOrder: z.number().int().positive().optional(),
|
|
191
|
+
}),
|
|
192
|
+
}, async ({ params, body, auth: authCtx }) => {
|
|
193
|
+
const bp = blueprintFor(params.collection);
|
|
194
|
+
if (!bp.tree)
|
|
195
|
+
throw new ValidationError('Collection does not support tree structure');
|
|
196
|
+
const shell = await entries.findShellById(params.id);
|
|
197
|
+
if (!shell || shell.collection !== params.collection)
|
|
198
|
+
throw new NotFoundError(`Entry ${params.id} not found`);
|
|
199
|
+
const allowed = await evaluate(bp, 'update', {
|
|
200
|
+
user: authCtx.user,
|
|
201
|
+
entry: { id: shell.id, status: 'draft', createdBy: shell.createdBy, content: {} },
|
|
202
|
+
});
|
|
203
|
+
if (!allowed)
|
|
204
|
+
throw new AccessDeniedError('Cannot move');
|
|
205
|
+
return await entries.move(params.collection, params.id, {
|
|
206
|
+
parentId: body.parentId,
|
|
207
|
+
...(body.sortOrder !== undefined ? { sortOrder: body.sortOrder } : {}),
|
|
208
|
+
});
|
|
209
|
+
}),
|
|
210
|
+
publish: defineHandler(auth, { params: paramsById }, async ({ params, url, auth: authCtx }) => {
|
|
211
|
+
const bp = blueprintFor(params.collection);
|
|
212
|
+
if (!bp.drafts)
|
|
213
|
+
throw new ValidationError('Drafts not enabled for this collection');
|
|
214
|
+
const locale = await resolveLocaleParam(db, url.searchParams.get('locale'));
|
|
215
|
+
const row = await entries.findById(params.id, locale);
|
|
216
|
+
if (!row)
|
|
217
|
+
throw new NotFoundError(`Entry ${params.id} (${locale}) not found`);
|
|
218
|
+
const allowed = await evaluate(bp, 'update', {
|
|
219
|
+
user: authCtx.user,
|
|
220
|
+
entry: { id: row.id, status: row.status, createdBy: row.createdBy, content: row.content },
|
|
221
|
+
});
|
|
222
|
+
if (!allowed)
|
|
223
|
+
throw new AccessDeniedError('Cannot publish');
|
|
224
|
+
if (!authCtx.user)
|
|
225
|
+
throw new AccessDeniedError('Authentication required');
|
|
226
|
+
const content = row.draftContent ?? row.content;
|
|
227
|
+
const validated = parseContent(bp.schema, content);
|
|
228
|
+
return await entries.updateWithRevision(params.id, {
|
|
229
|
+
locale,
|
|
230
|
+
content: validated,
|
|
231
|
+
publish: true,
|
|
232
|
+
draftsEnabled: true,
|
|
233
|
+
updatedBy: authCtx.user.id,
|
|
234
|
+
});
|
|
235
|
+
}),
|
|
236
|
+
delete: defineHandler(auth, { params: paramsById }, async ({ params, url, auth: authCtx }) => {
|
|
237
|
+
const bp = blueprintFor(params.collection);
|
|
238
|
+
const localeParam = url.searchParams.get('locale');
|
|
239
|
+
const shell = await entries.findShellById(params.id);
|
|
240
|
+
if (!shell || shell.collection !== params.collection)
|
|
241
|
+
throw new NotFoundError(`Entry ${params.id} not found`);
|
|
242
|
+
const allowed = await evaluate(bp, 'delete', {
|
|
243
|
+
user: authCtx.user,
|
|
244
|
+
entry: { id: shell.id, status: 'draft', createdBy: shell.createdBy, content: {} },
|
|
245
|
+
});
|
|
246
|
+
if (!allowed)
|
|
247
|
+
throw new AccessDeniedError('Cannot delete');
|
|
248
|
+
if (localeParam) {
|
|
249
|
+
const locale = await resolveLocaleParam(db, localeParam);
|
|
250
|
+
const summaries = await entries.listLocales(params.id);
|
|
251
|
+
if (summaries.length <= 1) {
|
|
252
|
+
await entries.delete(params.id);
|
|
253
|
+
return { deleted: true };
|
|
254
|
+
}
|
|
255
|
+
await entries.deleteLocale(params.id, locale);
|
|
256
|
+
return { deleted: true, locale };
|
|
257
|
+
}
|
|
258
|
+
await entries.delete(params.id);
|
|
259
|
+
return { deleted: true };
|
|
260
|
+
}),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VulseDb } from '../../core/db.js';
|
|
2
|
+
export interface FormSubmitRouteOptions {
|
|
3
|
+
queue?: Queue;
|
|
4
|
+
env?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare function formSubmitRoutes(db: VulseDb, options?: FormSubmitRouteOptions): {
|
|
7
|
+
public: (request: Request, rawParams: Record<string, string>) => Promise<Response>;
|
|
8
|
+
submit: (request: Request, rawParams: Record<string, string>) => Promise<Response>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=form-submit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-submit.d.ts","sourceRoot":"","sources":["../../../src/server/routes/form-submit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAU/C,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,GAAE,sBAA2B;sBAMtD,OAAO,aAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,OAAO,CAAC,QAAQ,CAAC;sBAgC9D,OAAO,aAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,OAAO,CAAC,QAAQ,CAAC;EAkHzF"}
|