qarpeo 0.0.0-alpha.10
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 +102 -0
- package/dist/chunks/auth-schema.mjs +219 -0
- package/dist/chunks/wrangler.mjs +783 -0
- package/dist/cli/index.mjs +1085 -0
- package/dist/dev/env.d.ts +12 -0
- package/dist/dev/wrangler.d.ts +18 -0
- package/dist/module.d.ts +16 -0
- package/dist/module.mjs +4436 -0
- package/dist/runtime/ai.d.ts +25 -0
- package/dist/runtime/ai.mjs +106 -0
- package/dist/runtime/analytics.d.ts +24 -0
- package/dist/runtime/analytics.mjs +38 -0
- package/dist/runtime/app/components/BlobImage.vue +100 -0
- package/dist/runtime/app/components/CMSBlocks.vue +93 -0
- package/dist/runtime/app/components/CMSContent.vue +23 -0
- package/dist/runtime/app/components/CMSImage.vue +49 -0
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -0
- package/dist/runtime/app/components/CMSPreviewBanner.vue +79 -0
- package/dist/runtime/app/components/CMSVersionBanner.vue +49 -0
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +126 -0
- package/dist/runtime/app/components/ContentRenderer.vue +80 -0
- package/dist/runtime/app/components/FileUpload.vue +196 -0
- package/dist/runtime/app/components/ImpersonationBanner.vue +57 -0
- package/dist/runtime/app/components/SignedIn.vue +13 -0
- package/dist/runtime/app/components/SignedOut.vue +13 -0
- package/dist/runtime/app/components/shiki.css +34 -0
- package/dist/runtime/app/composables/analytics.d.ts +125 -0
- package/dist/runtime/app/composables/analytics.mjs +81 -0
- package/dist/runtime/app/composables/api-tokens.d.ts +49 -0
- package/dist/runtime/app/composables/api-tokens.mjs +61 -0
- package/dist/runtime/app/composables/auth.d.ts +50 -0
- package/dist/runtime/app/composables/auth.mjs +101 -0
- package/dist/runtime/app/composables/chat.d.ts +69 -0
- package/dist/runtime/app/composables/chat.mjs +159 -0
- package/dist/runtime/app/composables/cms-preview.d.ts +33 -0
- package/dist/runtime/app/composables/cms-preview.mjs +83 -0
- package/dist/runtime/app/composables/cms.d.ts +307 -0
- package/dist/runtime/app/composables/cms.mjs +355 -0
- package/dist/runtime/app/composables/docs-version.d.ts +35 -0
- package/dist/runtime/app/composables/docs-version.mjs +70 -0
- package/dist/runtime/app/composables/impersonation.d.ts +14 -0
- package/dist/runtime/app/composables/impersonation.mjs +44 -0
- package/dist/runtime/app/composables/notifications.d.ts +35 -0
- package/dist/runtime/app/composables/notifications.mjs +139 -0
- package/dist/runtime/app/composables/organization.d.ts +127 -0
- package/dist/runtime/app/composables/organization.mjs +138 -0
- package/dist/runtime/app/composables/passkey.d.ts +6 -0
- package/dist/runtime/app/composables/passkey.mjs +105 -0
- package/dist/runtime/app/composables/passwordless.d.ts +7 -0
- package/dist/runtime/app/composables/passwordless.mjs +67 -0
- package/dist/runtime/app/composables/payments.d.ts +43 -0
- package/dist/runtime/app/composables/payments.mjs +74 -0
- package/dist/runtime/app/composables/realtime.d.ts +96 -0
- package/dist/runtime/app/composables/realtime.mjs +432 -0
- package/dist/runtime/app/composables/site.d.ts +35 -0
- package/dist/runtime/app/composables/site.mjs +36 -0
- package/dist/runtime/app/composables/storage.d.ts +60 -0
- package/dist/runtime/app/composables/storage.mjs +294 -0
- package/dist/runtime/app/composables/tenant.d.ts +82 -0
- package/dist/runtime/app/composables/tenant.mjs +120 -0
- package/dist/runtime/app/composables/turnstile.d.ts +3 -0
- package/dist/runtime/app/composables/turnstile.mjs +10 -0
- package/dist/runtime/app/composables/two-factor.d.ts +12 -0
- package/dist/runtime/app/composables/two-factor.mjs +65 -0
- package/dist/runtime/app/middleware/auth.global.d.ts +2 -0
- package/dist/runtime/app/middleware/auth.global.mjs +44 -0
- package/dist/runtime/app/pages/cms.vue +2249 -0
- package/dist/runtime/app/pages/devtools/agents.vue +717 -0
- package/dist/runtime/app/pages/devtools/analytics.vue +618 -0
- package/dist/runtime/app/pages/devtools/auth.vue +351 -0
- package/dist/runtime/app/pages/devtools/blob.vue +745 -0
- package/dist/runtime/app/pages/devtools/db.vue +546 -0
- package/dist/runtime/app/pages/devtools/domains.vue +772 -0
- package/dist/runtime/app/pages/devtools/kv.vue +829 -0
- package/dist/runtime/app/pages/devtools/logs.vue +655 -0
- package/dist/runtime/app/pages/devtools/mail.vue +389 -0
- package/dist/runtime/app/pages/devtools/overview.vue +390 -0
- package/dist/runtime/app/pages/devtools/settings.vue +560 -0
- package/dist/runtime/app/pages/devtools.vue +165 -0
- package/dist/runtime/app/plugins/seo.d.ts +2 -0
- package/dist/runtime/app/plugins/seo.mjs +105 -0
- package/dist/runtime/app/plugins/shortcuts.client.d.ts +6 -0
- package/dist/runtime/app/plugins/shortcuts.client.mjs +19 -0
- package/dist/runtime/app/public/sw-notifications.mjs +52 -0
- package/dist/runtime/auth.d.ts +25 -0
- package/dist/runtime/auth.mjs +11 -0
- package/dist/runtime/bindings.d.ts +27 -0
- package/dist/runtime/bindings.mjs +38 -0
- package/dist/runtime/blob.d.ts +26 -0
- package/dist/runtime/blob.mjs +334 -0
- package/dist/runtime/bots.d.ts +1 -0
- package/dist/runtime/bots.mjs +1 -0
- package/dist/runtime/browser.d.ts +21 -0
- package/dist/runtime/browser.mjs +64 -0
- package/dist/runtime/cache.d.ts +19 -0
- package/dist/runtime/cache.mjs +12 -0
- package/dist/runtime/cms.d.ts +2 -0
- package/dist/runtime/cms.mjs +0 -0
- package/dist/runtime/db.d.ts +21 -0
- package/dist/runtime/db.mjs +36 -0
- package/dist/runtime/drizzle.d.ts +11 -0
- package/dist/runtime/drizzle.mjs +18 -0
- package/dist/runtime/email.d.ts +51 -0
- package/dist/runtime/email.mjs +245 -0
- package/dist/runtime/hyperdrive.d.ts +21 -0
- package/dist/runtime/hyperdrive.mjs +49 -0
- package/dist/runtime/index.d.ts +23 -0
- package/dist/runtime/index.mjs +23 -0
- package/dist/runtime/kv.d.ts +16 -0
- package/dist/runtime/kv.mjs +126 -0
- package/dist/runtime/payments.d.ts +2 -0
- package/dist/runtime/payments.mjs +0 -0
- package/dist/runtime/queue.d.ts +21 -0
- package/dist/runtime/queue.mjs +41 -0
- package/dist/runtime/rag.d.ts +1 -0
- package/dist/runtime/rag.mjs +1 -0
- package/dist/runtime/ratelimit.d.ts +21 -0
- package/dist/runtime/ratelimit.mjs +38 -0
- package/dist/runtime/realtime.d.ts +6 -0
- package/dist/runtime/realtime.mjs +13 -0
- package/dist/runtime/server/db/cms-schema.d.ts +651 -0
- package/dist/runtime/server/db/cms-schema.mjs +74 -0
- package/dist/runtime/server/durable-objects/agent.d.ts +14 -0
- package/dist/runtime/server/durable-objects/agent.mjs +571 -0
- package/dist/runtime/server/durable-objects/room.d.ts +34 -0
- package/dist/runtime/server/durable-objects/room.mjs +514 -0
- package/dist/runtime/server/middleware/auth.d.ts +2 -0
- package/dist/runtime/server/middleware/auth.mjs +108 -0
- package/dist/runtime/server/middleware/devtools.d.ts +2 -0
- package/dist/runtime/server/middleware/devtools.mjs +61 -0
- package/dist/runtime/server/middleware/ratelimit.d.ts +2 -0
- package/dist/runtime/server/middleware/ratelimit.mjs +49 -0
- package/dist/runtime/server/middleware/tenancy.d.ts +6 -0
- package/dist/runtime/server/middleware/tenancy.mjs +15 -0
- package/dist/runtime/server/middleware/tracker.d.ts +7 -0
- package/dist/runtime/server/middleware/tracker.mjs +9 -0
- package/dist/runtime/server/plugins/agents.d.ts +7 -0
- package/dist/runtime/server/plugins/agents.mjs +3 -0
- package/dist/runtime/server/plugins/cms.d.ts +7 -0
- package/dist/runtime/server/plugins/cms.mjs +16 -0
- package/dist/runtime/server/plugins/dev-logs.d.ts +1 -0
- package/dist/runtime/server/plugins/dev-logs.mjs +58 -0
- package/dist/runtime/server/plugins/dev-proxy.d.ts +3 -0
- package/dist/runtime/server/plugins/dev-proxy.mjs +21 -0
- package/dist/runtime/server/plugins/env.d.ts +6 -0
- package/dist/runtime/server/plugins/env.mjs +17 -0
- package/dist/runtime/server/plugins/queue.d.ts +6 -0
- package/dist/runtime/server/plugins/queue.mjs +8 -0
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +20 -0
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +110 -0
- package/dist/runtime/server/routes/__qarpeo/agents/clear.post.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/agents/clear.post.mjs +15 -0
- package/dist/runtime/server/routes/__qarpeo/agents/create.post.d.ts +17 -0
- package/dist/runtime/server/routes/__qarpeo/agents/create.post.mjs +47 -0
- package/dist/runtime/server/routes/__qarpeo/agents/history.get.d.ts +15 -0
- package/dist/runtime/server/routes/__qarpeo/agents/history.get.mjs +24 -0
- package/dist/runtime/server/routes/__qarpeo/agents/list.get.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/agents/list.get.mjs +63 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +64 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.mjs +55 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +30 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +73 -0
- package/dist/runtime/server/routes/__qarpeo/auth/revoke-session.post.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/auth/revoke-session.post.mjs +26 -0
- package/dist/runtime/server/routes/__qarpeo/auth/sessions.get.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/auth/sessions.get.mjs +46 -0
- package/dist/runtime/server/routes/__qarpeo/auth/users.get.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/auth/users.get.mjs +65 -0
- package/dist/runtime/server/routes/__qarpeo/blob/files.get.d.ts +22 -0
- package/dist/runtime/server/routes/__qarpeo/blob/files.get.mjs +36 -0
- package/dist/runtime/server/routes/__qarpeo/db/query.post.d.ts +23 -0
- package/dist/runtime/server/routes/__qarpeo/db/query.post.mjs +34 -0
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +31 -0
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +81 -0
- package/dist/runtime/server/routes/__qarpeo/kv/delete.post.d.ts +11 -0
- package/dist/runtime/server/routes/__qarpeo/kv/delete.post.mjs +18 -0
- package/dist/runtime/server/routes/__qarpeo/kv/get.get.d.ts +11 -0
- package/dist/runtime/server/routes/__qarpeo/kv/get.get.mjs +20 -0
- package/dist/runtime/server/routes/__qarpeo/kv/keys.get.d.ts +8 -0
- package/dist/runtime/server/routes/__qarpeo/kv/keys.get.mjs +27 -0
- package/dist/runtime/server/routes/__qarpeo/kv/set.post.d.ts +14 -0
- package/dist/runtime/server/routes/__qarpeo/kv/set.post.mjs +24 -0
- package/dist/runtime/server/routes/__qarpeo/logs.delete.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/logs.delete.mjs +6 -0
- package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/logs.get.mjs +26 -0
- package/dist/runtime/server/routes/__qarpeo/logs.post.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/logs.post.mjs +17 -0
- package/dist/runtime/server/routes/__qarpeo/mail/bounce.post.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/mail/bounce.post.mjs +37 -0
- package/dist/runtime/server/routes/__qarpeo/mail/clear.post.d.ts +4 -0
- package/dist/runtime/server/routes/__qarpeo/mail/clear.post.mjs +6 -0
- package/dist/runtime/server/routes/__qarpeo/mail/inbox.get.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/mail/inbox.get.mjs +7 -0
- package/dist/runtime/server/routes/__qarpeo/mail/send-test.post.d.ts +4 -0
- package/dist/runtime/server/routes/__qarpeo/mail/send-test.post.mjs +29 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +23 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +31 -0
- package/dist/runtime/server/routes/__qarpeo/overview/health.get.d.ts +8 -0
- package/dist/runtime/server/routes/__qarpeo/overview/health.get.mjs +46 -0
- package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +32 -0
- package/dist/runtime/server/routes/__qarpeo/overview.get.mjs +38 -0
- package/dist/runtime/server/routes/__qarpeo/settings/reset-dev-data.post.d.ts +11 -0
- package/dist/runtime/server/routes/__qarpeo/settings/reset-dev-data.post.mjs +84 -0
- package/dist/runtime/server/routes/__qarpeo/settings.get.d.ts +124 -0
- package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +145 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/create.post.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/create.post.mjs +26 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-add.post.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-add.post.mjs +29 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-delete.post.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-delete.post.mjs +21 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-verify.post.d.ts +9 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-verify.post.mjs +21 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/list.get.d.ts +15 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/list.get.mjs +22 -0
- package/dist/runtime/server/routes/agents/[agent]/chat.post.d.ts +2 -0
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +35 -0
- package/dist/runtime/server/routes/agents/[agent]/clear.post.d.ts +4 -0
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +27 -0
- package/dist/runtime/server/routes/agents/[agent]/history.get.d.ts +4 -0
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +27 -0
- package/dist/runtime/server/routes/analytics/events.get.d.ts +3 -0
- package/dist/runtime/server/routes/analytics/events.get.mjs +17 -0
- package/dist/runtime/server/routes/analytics/pageviews.get.d.ts +3 -0
- package/dist/runtime/server/routes/analytics/pageviews.get.mjs +15 -0
- package/dist/runtime/server/routes/analytics/summary.get.d.ts +6 -0
- package/dist/runtime/server/routes/analytics/summary.get.mjs +15 -0
- package/dist/runtime/server/routes/atom.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/atom.xml.get.mjs +76 -0
- package/dist/runtime/server/routes/auth/2fa/disable.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +44 -0
- package/dist/runtime/server/routes/auth/2fa/setup.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/2fa/setup.post.mjs +32 -0
- package/dist/runtime/server/routes/auth/2fa/verify.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +92 -0
- package/dist/runtime/server/routes/auth/[provider]/callback.d.ts +1 -0
- package/dist/runtime/server/routes/auth/[provider]/callback.mjs +1 -0
- package/dist/runtime/server/routes/auth/[provider].d.ts +3 -0
- package/dist/runtime/server/routes/auth/[provider].mjs +95 -0
- package/dist/runtime/server/routes/auth/account.delete.d.ts +5 -0
- package/dist/runtime/server/routes/auth/account.delete.mjs +52 -0
- package/dist/runtime/server/routes/auth/impersonate/start.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/impersonate/start.post.mjs +14 -0
- package/dist/runtime/server/routes/auth/impersonate/stop.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/impersonate/stop.post.mjs +5 -0
- package/dist/runtime/server/routes/auth/logout-all.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/logout-all.post.mjs +16 -0
- package/dist/runtime/server/routes/auth/logout-others.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/logout-others.post.mjs +11 -0
- package/dist/runtime/server/routes/auth/logout.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/logout.post.mjs +17 -0
- package/dist/runtime/server/routes/auth/magic-link/send.post.d.ts +10 -0
- package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +29 -0
- package/dist/runtime/server/routes/auth/magic-link/verify.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +81 -0
- package/dist/runtime/server/routes/auth/organization/create.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/organization/create.post.mjs +10 -0
- package/dist/runtime/server/routes/auth/organization/invite.post.d.ts +9 -0
- package/dist/runtime/server/routes/auth/organization/invite.post.mjs +27 -0
- package/dist/runtime/server/routes/auth/organization/join.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/join.post.mjs +15 -0
- package/dist/runtime/server/routes/auth/organization/list.get.d.ts +5 -0
- package/dist/runtime/server/routes/auth/organization/list.get.mjs +7 -0
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +33 -0
- package/dist/runtime/server/routes/auth/organization/members/index.get.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/members/index.get.mjs +18 -0
- package/dist/runtime/server/routes/auth/organization/mfa.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/mfa.post.mjs +33 -0
- package/dist/runtime/server/routes/auth/organization/sso/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/auth/organization/sso/[id].delete.mjs +28 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.get.mjs +23 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.post.mjs +84 -0
- package/dist/runtime/server/routes/auth/organization/switch.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/switch.post.mjs +14 -0
- package/dist/runtime/server/routes/auth/otp/send.post.d.ts +10 -0
- package/dist/runtime/server/routes/auth/otp/send.post.mjs +29 -0
- package/dist/runtime/server/routes/auth/otp/verify.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/otp/verify.post.mjs +95 -0
- package/dist/runtime/server/routes/auth/sessions/[id].delete.d.ts +5 -0
- package/dist/runtime/server/routes/auth/sessions/[id].delete.mjs +24 -0
- package/dist/runtime/server/routes/auth/sessions.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sessions.get.mjs +11 -0
- package/dist/runtime/server/routes/auth/sso/login.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +94 -0
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +113 -0
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +95 -0
- package/dist/runtime/server/routes/auth/tokens/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/auth/tokens/[id].delete.mjs +13 -0
- package/dist/runtime/server/routes/auth/tokens/create.post.d.ts +9 -0
- package/dist/runtime/server/routes/auth/tokens/create.post.mjs +17 -0
- package/dist/runtime/server/routes/auth/tokens/index.get.d.ts +9 -0
- package/dist/runtime/server/routes/auth/tokens/index.get.mjs +5 -0
- package/dist/runtime/server/routes/auth/turnstile/verify.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/turnstile/verify.post.mjs +15 -0
- package/dist/runtime/server/routes/auth/user.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/user.get.mjs +6 -0
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +17 -0
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +127 -0
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +47 -0
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +88 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.d.ts +8 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.mjs +27 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/publish.post.d.ts +6 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/publish.post.mjs +19 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/review.post.d.ts +6 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/review.post.mjs +33 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].delete.mjs +17 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].put.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].put.mjs +18 -0
- package/dist/runtime/server/routes/cms/[collection]/[slug].get.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/[slug].get.mjs +19 -0
- package/dist/runtime/server/routes/cms/[collection]/atom.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/cms/[collection]/atom.xml.get.mjs +69 -0
- package/dist/runtime/server/routes/cms/[collection]/by-path.get.d.ts +8 -0
- package/dist/runtime/server/routes/cms/[collection]/by-path.get.mjs +23 -0
- package/dist/runtime/server/routes/cms/[collection]/feed.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/cms/[collection]/feed.xml.get.mjs +65 -0
- package/dist/runtime/server/routes/cms/[collection]/index.get.d.ts +7 -0
- package/dist/runtime/server/routes/cms/[collection]/index.get.mjs +15 -0
- package/dist/runtime/server/routes/cms/[collection]/index.post.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/index.post.mjs +23 -0
- package/dist/runtime/server/routes/cms/[collection]/references.get.d.ts +19 -0
- package/dist/runtime/server/routes/cms/[collection]/references.get.mjs +47 -0
- package/dist/runtime/server/routes/cms/[collection]/surroundings.get.d.ts +10 -0
- package/dist/runtime/server/routes/cms/[collection]/surroundings.get.mjs +12 -0
- package/dist/runtime/server/routes/cms/collections/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/[id].delete.mjs +10 -0
- package/dist/runtime/server/routes/cms/collections/[id].put.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/[id].put.mjs +11 -0
- package/dist/runtime/server/routes/cms/collections/index.get.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/index.get.mjs +6 -0
- package/dist/runtime/server/routes/cms/collections/index.post.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/index.post.mjs +19 -0
- package/dist/runtime/server/routes/cms/components/index.get.d.ts +17 -0
- package/dist/runtime/server/routes/cms/components/index.get.mjs +16 -0
- package/dist/runtime/server/routes/cms/deploy.post.d.ts +4 -0
- package/dist/runtime/server/routes/cms/deploy.post.mjs +46 -0
- package/dist/runtime/server/routes/cms/export.post.d.ts +10 -0
- package/dist/runtime/server/routes/cms/export.post.mjs +55 -0
- package/dist/runtime/server/routes/cms/navigation.get.d.ts +8 -0
- package/dist/runtime/server/routes/cms/navigation.get.mjs +36 -0
- package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +9 -0
- package/dist/runtime/server/routes/cms/preview/disable.get.mjs +9 -0
- package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +14 -0
- package/dist/runtime/server/routes/cms/preview/enable.get.mjs +42 -0
- package/dist/runtime/server/routes/cms/publish-scheduled.post.d.ts +11 -0
- package/dist/runtime/server/routes/cms/publish-scheduled.post.mjs +35 -0
- package/dist/runtime/server/routes/cms/search.get.d.ts +13 -0
- package/dist/runtime/server/routes/cms/search.get.mjs +137 -0
- package/dist/runtime/server/routes/cms/sync.post.d.ts +7 -0
- package/dist/runtime/server/routes/cms/sync.post.mjs +18 -0
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +150 -0
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +213 -0
- package/dist/runtime/server/routes/docs/search.get.d.ts +15 -0
- package/dist/runtime/server/routes/docs/search.get.mjs +20 -0
- package/dist/runtime/server/routes/feed.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/feed.xml.get.mjs +73 -0
- package/dist/runtime/server/routes/mail/bounce.post.d.ts +14 -0
- package/dist/runtime/server/routes/mail/bounce.post.mjs +56 -0
- package/dist/runtime/server/routes/mail/inbox/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/mail/inbox/[id].get.mjs +9 -0
- package/dist/runtime/server/routes/mail/inbox.get.d.ts +4 -0
- package/dist/runtime/server/routes/mail/inbox.get.mjs +7 -0
- package/dist/runtime/server/routes/mail/suppressions/[email].delete.d.ts +11 -0
- package/dist/runtime/server/routes/mail/suppressions/[email].delete.mjs +18 -0
- package/dist/runtime/server/routes/mail/suppressions/index.get.d.ts +12 -0
- package/dist/runtime/server/routes/mail/suppressions/index.get.mjs +23 -0
- package/dist/runtime/server/routes/mail/suppressions/index.post.d.ts +10 -0
- package/dist/runtime/server/routes/mail/suppressions/index.post.mjs +23 -0
- package/dist/runtime/server/routes/mail/unsubscribe.d.ts +13 -0
- package/dist/runtime/server/routes/mail/unsubscribe.mjs +91 -0
- package/dist/runtime/server/routes/mail/webhooks.post.d.ts +12 -0
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +71 -0
- package/dist/runtime/server/routes/notifications/[id]/read.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/[id]/read.post.mjs +13 -0
- package/dist/runtime/server/routes/notifications/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/[id].delete.mjs +13 -0
- package/dist/runtime/server/routes/notifications/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/notifications/[id].get.mjs +15 -0
- package/dist/runtime/server/routes/notifications/index.get.d.ts +6 -0
- package/dist/runtime/server/routes/notifications/index.get.mjs +18 -0
- package/dist/runtime/server/routes/notifications/push/subscribe.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/push/subscribe.post.mjs +20 -0
- package/dist/runtime/server/routes/notifications/push/unsubscribe.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/push/unsubscribe.post.mjs +15 -0
- package/dist/runtime/server/routes/notifications/read-all.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/read-all.post.mjs +11 -0
- package/dist/runtime/server/routes/payments/cancel.post.d.ts +7 -0
- package/dist/runtime/server/routes/payments/cancel.post.mjs +9 -0
- package/dist/runtime/server/routes/payments/change-plan.post.d.ts +7 -0
- package/dist/runtime/server/routes/payments/change-plan.post.mjs +12 -0
- package/dist/runtime/server/routes/payments/checkout.post.d.ts +9 -0
- package/dist/runtime/server/routes/payments/checkout.post.mjs +16 -0
- package/dist/runtime/server/routes/payments/pause.post.d.ts +7 -0
- package/dist/runtime/server/routes/payments/pause.post.mjs +9 -0
- package/dist/runtime/server/routes/payments/portal.post.d.ts +5 -0
- package/dist/runtime/server/routes/payments/portal.post.mjs +9 -0
- package/dist/runtime/server/routes/payments/subscription.get.d.ts +6 -0
- package/dist/runtime/server/routes/payments/subscription.get.mjs +9 -0
- package/dist/runtime/server/routes/payments/usage.get.d.ts +12 -0
- package/dist/runtime/server/routes/payments/usage.get.mjs +18 -0
- package/dist/runtime/server/routes/payments/usage.post.d.ts +6 -0
- package/dist/runtime/server/routes/payments/usage.post.mjs +24 -0
- package/dist/runtime/server/routes/payments/webhook.post.d.ts +14 -0
- package/dist/runtime/server/routes/payments/webhook.post.mjs +21 -0
- package/dist/runtime/server/routes/realtime/broadcast.post.d.ts +4 -0
- package/dist/runtime/server/routes/realtime/broadcast.post.mjs +26 -0
- package/dist/runtime/server/routes/realtime/history.delete.d.ts +13 -0
- package/dist/runtime/server/routes/realtime/history.delete.mjs +12 -0
- package/dist/runtime/server/routes/realtime/history.get.d.ts +16 -0
- package/dist/runtime/server/routes/realtime/history.get.mjs +15 -0
- package/dist/runtime/server/routes/realtime/presence.get.d.ts +6 -0
- package/dist/runtime/server/routes/realtime/presence.get.mjs +27 -0
- package/dist/runtime/server/routes/realtime/state.get.d.ts +5 -0
- package/dist/runtime/server/routes/realtime/state.get.mjs +26 -0
- package/dist/runtime/server/routes/realtime/state.post.d.ts +6 -0
- package/dist/runtime/server/routes/realtime/state.post.mjs +37 -0
- package/dist/runtime/server/routes/realtime/ws.get.d.ts +2 -0
- package/dist/runtime/server/routes/realtime/ws.get.mjs +73 -0
- package/dist/runtime/server/routes/robots.txt.get.d.ts +2 -0
- package/dist/runtime/server/routes/robots.txt.get.mjs +41 -0
- package/dist/runtime/server/routes/rss.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/rss.xml.get.mjs +2 -0
- package/dist/runtime/server/routes/sitemap.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +84 -0
- package/dist/runtime/server/routes/storage/file/[...key].delete.d.ts +4 -0
- package/dist/runtime/server/routes/storage/file/[...key].delete.mjs +23 -0
- package/dist/runtime/server/routes/storage/file/[...key].get.d.ts +2 -0
- package/dist/runtime/server/routes/storage/file/[...key].get.mjs +23 -0
- package/dist/runtime/server/routes/storage/files.get.d.ts +14 -0
- package/dist/runtime/server/routes/storage/files.get.mjs +11 -0
- package/dist/runtime/server/routes/storage/presigned.post.d.ts +8 -0
- package/dist/runtime/server/routes/storage/presigned.post.mjs +39 -0
- package/dist/runtime/server/routes/storage/sign.post.d.ts +6 -0
- package/dist/runtime/server/routes/storage/sign.post.mjs +24 -0
- package/dist/runtime/server/routes/storage/upload.post.d.ts +22 -0
- package/dist/runtime/server/routes/storage/upload.post.mjs +96 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +39 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +39 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +20 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +44 -0
- package/dist/runtime/server/routes/tenants/current.get.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/current.get.mjs +6 -0
- package/dist/runtime/server/tasks/cms/publish.d.ts +4 -0
- package/dist/runtime/server/tasks/cms/publish.mjs +18 -0
- package/dist/runtime/server/utils/agent-store.d.ts +24 -0
- package/dist/runtime/server/utils/agent-store.mjs +53 -0
- package/dist/runtime/server/utils/agents-registry-fallback.d.ts +1 -0
- package/dist/runtime/server/utils/agents-registry-fallback.mjs +1 -0
- package/dist/runtime/server/utils/ai.d.ts +119 -0
- package/dist/runtime/server/utils/ai.mjs +607 -0
- package/dist/runtime/server/utils/analytics-query.d.ts +109 -0
- package/dist/runtime/server/utils/analytics-query.mjs +234 -0
- package/dist/runtime/server/utils/auth.d.ts +60 -0
- package/dist/runtime/server/utils/auth.mjs +361 -0
- package/dist/runtime/server/utils/blob-store.d.ts +13 -0
- package/dist/runtime/server/utils/blob-store.mjs +60 -0
- package/dist/runtime/server/utils/bots.d.ts +21 -0
- package/dist/runtime/server/utils/bots.mjs +491 -0
- package/dist/runtime/server/utils/cache.d.ts +33 -0
- package/dist/runtime/server/utils/cache.mjs +128 -0
- package/dist/runtime/server/utils/cms-events.d.ts +17 -0
- package/dist/runtime/server/utils/cms-events.mjs +80 -0
- package/dist/runtime/server/utils/cms-filter.d.ts +3 -0
- package/dist/runtime/server/utils/cms-filter.mjs +34 -0
- package/dist/runtime/server/utils/cms.d.ts +278 -0
- package/dist/runtime/server/utils/cms.mjs +3268 -0
- package/dist/runtime/server/utils/config.d.ts +27 -0
- package/dist/runtime/server/utils/config.mjs +38 -0
- package/dist/runtime/server/utils/context.d.ts +13 -0
- package/dist/runtime/server/utils/context.mjs +98 -0
- package/dist/runtime/server/utils/crypto.d.ts +16 -0
- package/dist/runtime/server/utils/crypto.mjs +56 -0
- package/dist/runtime/server/utils/dev-logs.d.ts +21 -0
- package/dist/runtime/server/utils/dev-logs.mjs +41 -0
- package/dist/runtime/server/utils/dev-proxy.d.ts +1 -0
- package/dist/runtime/server/utils/dev-proxy.mjs +69 -0
- package/dist/runtime/server/utils/domains.d.ts +46 -0
- package/dist/runtime/server/utils/domains.mjs +318 -0
- package/dist/runtime/server/utils/drizzle.d.ts +10 -0
- package/dist/runtime/server/utils/drizzle.mjs +36 -0
- package/dist/runtime/server/utils/email-templates.d.ts +44 -0
- package/dist/runtime/server/utils/email-templates.mjs +373 -0
- package/dist/runtime/server/utils/feed.d.ts +42 -0
- package/dist/runtime/server/utils/feed.mjs +161 -0
- package/dist/runtime/server/utils/impersonation.d.ts +67 -0
- package/dist/runtime/server/utils/impersonation.mjs +298 -0
- package/dist/runtime/server/utils/jobs.d.ts +70 -0
- package/dist/runtime/server/utils/jobs.mjs +125 -0
- package/dist/runtime/server/utils/kv-store.d.ts +9 -0
- package/dist/runtime/server/utils/kv-store.mjs +32 -0
- package/dist/runtime/server/utils/mail-suppression.d.ts +62 -0
- package/dist/runtime/server/utils/mail-suppression.mjs +328 -0
- package/dist/runtime/server/utils/mail.d.ts +90 -0
- package/dist/runtime/server/utils/mail.mjs +366 -0
- package/dist/runtime/server/utils/notifications.d.ts +51 -0
- package/dist/runtime/server/utils/notifications.mjs +215 -0
- package/dist/runtime/server/utils/organization.d.ts +54 -0
- package/dist/runtime/server/utils/organization.mjs +354 -0
- package/dist/runtime/server/utils/passwordless.d.ts +48 -0
- package/dist/runtime/server/utils/passwordless.mjs +179 -0
- package/dist/runtime/server/utils/payments.d.ts +121 -0
- package/dist/runtime/server/utils/payments.mjs +1067 -0
- package/dist/runtime/server/utils/queue-fallback.d.ts +2 -0
- package/dist/runtime/server/utils/queue-fallback.mjs +2 -0
- package/dist/runtime/server/utils/queue.d.ts +4 -0
- package/dist/runtime/server/utils/queue.mjs +3 -0
- package/dist/runtime/server/utils/rag.d.ts +25 -0
- package/dist/runtime/server/utils/rag.mjs +333 -0
- package/dist/runtime/server/utils/ratelimit.d.ts +45 -0
- package/dist/runtime/server/utils/ratelimit.mjs +182 -0
- package/dist/runtime/server/utils/realtime.d.ts +110 -0
- package/dist/runtime/server/utils/realtime.mjs +197 -0
- package/dist/runtime/server/utils/schema-fallback.d.ts +3 -0
- package/dist/runtime/server/utils/schema-fallback.mjs +2 -0
- package/dist/runtime/server/utils/session.d.ts +72 -0
- package/dist/runtime/server/utils/session.mjs +287 -0
- package/dist/runtime/server/utils/sso.d.ts +49 -0
- package/dist/runtime/server/utils/sso.mjs +131 -0
- package/dist/runtime/server/utils/storage.d.ts +111 -0
- package/dist/runtime/server/utils/storage.mjs +654 -0
- package/dist/runtime/server/utils/tenant.d.ts +44 -0
- package/dist/runtime/server/utils/tenant.mjs +285 -0
- package/dist/runtime/server/utils/totp.d.ts +33 -0
- package/dist/runtime/server/utils/totp.mjs +112 -0
- package/dist/runtime/server/utils/tracker.d.ts +72 -0
- package/dist/runtime/server/utils/tracker.mjs +139 -0
- package/dist/runtime/server/utils/turnstile.d.ts +17 -0
- package/dist/runtime/server/utils/turnstile.mjs +68 -0
- package/dist/runtime/server/utils/vapid.d.ts +35 -0
- package/dist/runtime/server/utils/vapid.mjs +211 -0
- package/dist/runtime/storage.d.ts +1 -0
- package/dist/runtime/storage.mjs +0 -0
- package/dist/runtime/types/ai.d.ts +68 -0
- package/dist/runtime/types/ai.mjs +0 -0
- package/dist/runtime/types/analytics.d.ts +30 -0
- package/dist/runtime/types/analytics.mjs +0 -0
- package/dist/runtime/types/auth-globals.d.ts +14 -0
- package/dist/runtime/types/auth.d.ts +153 -0
- package/dist/runtime/types/auth.mjs +0 -0
- package/dist/runtime/types/browser.d.ts +29 -0
- package/dist/runtime/types/browser.mjs +0 -0
- package/dist/runtime/types/d1.d.ts +44 -0
- package/dist/runtime/types/d1.mjs +0 -0
- package/dist/runtime/types/drizzle.d.ts +13 -0
- package/dist/runtime/types/drizzle.mjs +0 -0
- package/dist/runtime/types/durable-object.d.ts +51 -0
- package/dist/runtime/types/durable-object.mjs +0 -0
- package/dist/runtime/types/email.d.ts +66 -0
- package/dist/runtime/types/email.mjs +0 -0
- package/dist/runtime/types/hyperdrive.d.ts +18 -0
- package/dist/runtime/types/hyperdrive.mjs +0 -0
- package/dist/runtime/types/imports.d.ts +58 -0
- package/dist/runtime/types/index.d.ts +156 -0
- package/dist/runtime/types/index.mjs +13 -0
- package/dist/runtime/types/queue.d.ts +67 -0
- package/dist/runtime/types/queue.mjs +0 -0
- package/dist/runtime/types/r2.d.ts +108 -0
- package/dist/runtime/types/r2.mjs +0 -0
- package/dist/runtime/types/ratelimit.d.ts +21 -0
- package/dist/runtime/types/ratelimit.mjs +0 -0
- package/dist/runtime/types/vectorize.d.ts +74 -0
- package/dist/runtime/types/vectorize.mjs +0 -0
- package/dist/runtime/vectorize.d.ts +21 -0
- package/dist/runtime/vectorize.mjs +53 -0
- package/dist/types.d.ts +2750 -0
- package/dist/types.mjs +1 -0
- package/dist/utils/agents.d.ts +8 -0
- package/dist/utils/auth-schema.d.ts +11 -0
- package/dist/utils/bindings.d.ts +16 -0
- package/dist/utils/cms-schema.d.ts +1 -0
- package/dist/utils/cms-sources.d.ts +62 -0
- package/dist/utils/drizzle.d.ts +42 -0
- package/dist/utils/jobs.d.ts +8 -0
- package/dist/utils/local-db.d.ts +28 -0
- package/dist/utils/notifications-schema.d.ts +15 -0
- package/dist/utils/payments-schema.d.ts +11 -0
- package/dist/utils/pkg.d.ts +15 -0
- package/dist/utils/queue.d.ts +8 -0
- package/dist/utils/tenants-schema.d.ts +11 -0
- package/package.json +104 -0
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,4436 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, appendFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { defineNuxtModule, useLogger, createResolver, addVitePlugin, addTemplate, hasNuxtModule, installModule, addNitroPlugin, addImports, addServerImports, addTypeTemplate, updateTemplates, addServerImportsDir, addServerHandler, addRouteMiddleware, addComponent, extendPages, addPlugin } from '@nuxt/kit';
|
|
5
|
+
import { defu } from 'defu';
|
|
6
|
+
import { join, resolve, extname, basename, dirname, normalize, relative } from 'pathe';
|
|
7
|
+
import { h as createWranglerConfig, i as resolveBindingName, c as checkDrizzleVersion, s as scanSchemaExports, b as resolveProjectName, j as findQueueFiles, k as findJobFiles, l as generateDevWranglerConfig, m as applyD1Migrations, f as findSchemaFiles } from './chunks/wrangler.mjs';
|
|
8
|
+
import { generateAuthSchema } from './chunks/auth-schema.mjs';
|
|
9
|
+
export { getActiveAuthTableNames } from './chunks/auth-schema.mjs';
|
|
10
|
+
import { createHash } from 'node:crypto';
|
|
11
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
12
|
+
import { downloadTemplate } from 'giget';
|
|
13
|
+
import { snakeCase, integer, text, index } from 'drizzle-orm/sqlite-core';
|
|
14
|
+
import 'node:child_process';
|
|
15
|
+
import 'drizzle-orm/node-sqlite';
|
|
16
|
+
import 'node:process';
|
|
17
|
+
import 'node:readline/promises';
|
|
18
|
+
|
|
19
|
+
const version = "0.0.0-alpha.10";
|
|
20
|
+
|
|
21
|
+
function ensureDevEnv(rootDir) {
|
|
22
|
+
const envPath = join(rootDir, ".env");
|
|
23
|
+
if (existsSync(envPath)) {
|
|
24
|
+
try {
|
|
25
|
+
let content2 = readFileSync(envPath, "utf8");
|
|
26
|
+
if (content2.includes("NUXT_SESSION_PASSWORD=dev-session-password-must-be-at-least-32-chars-long")) {
|
|
27
|
+
content2 = content2.replace(
|
|
28
|
+
"NUXT_SESSION_PASSWORD=dev-session-password-must-be-at-least-32-chars-long",
|
|
29
|
+
"NUXT_APP_SECRET=dev-app-secret-must-be-at-least-32-chars-long"
|
|
30
|
+
);
|
|
31
|
+
writeFileSync(envPath, content2, "utf8");
|
|
32
|
+
if (process.env.NUXT_SESSION_PASSWORD === "dev-session-password-must-be-at-least-32-chars-long") {
|
|
33
|
+
delete process.env.NUXT_SESSION_PASSWORD;
|
|
34
|
+
}
|
|
35
|
+
process.env.NUXT_APP_SECRET = "dev-app-secret-must-be-at-least-32-chars-long";
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const dummyEntries = {
|
|
41
|
+
CLOUDFLARE_ACCOUNT_ID: "dummy-dev-account-id",
|
|
42
|
+
CLOUDFLARE_API_TOKEN: "dummy-dev-api-token",
|
|
43
|
+
NUXT_APP_SECRET: "dev-app-secret-must-be-at-least-32-chars-long"
|
|
44
|
+
};
|
|
45
|
+
const needsFile = {};
|
|
46
|
+
for (const [key, val] of Object.entries(dummyEntries)) {
|
|
47
|
+
if (!process.env[key]) {
|
|
48
|
+
needsFile[key] = val;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (process.env.NUXT_APP_SECRET || process.env.NUXT_SESSION_PASSWORD) {
|
|
52
|
+
delete needsFile.NUXT_APP_SECRET;
|
|
53
|
+
}
|
|
54
|
+
if (Object.keys(needsFile).length === 0) return;
|
|
55
|
+
let content = "";
|
|
56
|
+
if (existsSync(envPath)) {
|
|
57
|
+
try {
|
|
58
|
+
content = readFileSync(envPath, "utf8");
|
|
59
|
+
} catch {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const toAppend = [];
|
|
64
|
+
for (const [key, val] of Object.entries(needsFile)) {
|
|
65
|
+
if (!content.includes(key)) {
|
|
66
|
+
toAppend.push(`${key}=${val}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (toAppend.length > 0) {
|
|
70
|
+
try {
|
|
71
|
+
appendFileSync(
|
|
72
|
+
envPath,
|
|
73
|
+
`
|
|
74
|
+
# Auto-generated by qarpeo (local dev only)
|
|
75
|
+
${toAppend.join("\n")}
|
|
76
|
+
`
|
|
77
|
+
);
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function findAgentFiles(layers, dirName = "server/agents") {
|
|
84
|
+
const agentsMap = /* @__PURE__ */ new Map();
|
|
85
|
+
for (const layer of layers) {
|
|
86
|
+
const baseDirs = /* @__PURE__ */ new Set();
|
|
87
|
+
if (layer.config?.srcDir) baseDirs.add(layer.config.srcDir);
|
|
88
|
+
if (layer.config?.rootDir) baseDirs.add(layer.config.rootDir);
|
|
89
|
+
if (layer.cwd) baseDirs.add(layer.cwd);
|
|
90
|
+
for (const baseDir of baseDirs) {
|
|
91
|
+
const agentsDir = resolve(baseDir, dirName);
|
|
92
|
+
if (!existsSync(agentsDir)) continue;
|
|
93
|
+
try {
|
|
94
|
+
const entries = readdirSync(agentsDir);
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
const fullPath = join(agentsDir, entry);
|
|
97
|
+
const stat = statSync(fullPath);
|
|
98
|
+
if (stat.isFile() && (entry.endsWith(".ts") || entry.endsWith(".js") || entry.endsWith(".mjs"))) {
|
|
99
|
+
if (entry.endsWith(".d.ts")) continue;
|
|
100
|
+
const ext = extname(entry);
|
|
101
|
+
const name = basename(entry, ext);
|
|
102
|
+
const importPath = fullPath.replace(/\\/g, "/").replace(/\.(ts|js|mjs)$/, "");
|
|
103
|
+
agentsMap.set(name, { name, file: fullPath, importPath });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return Array.from(agentsMap.values());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function matchesSourceFilters(relPath, include, exclude) {
|
|
114
|
+
const p = relPath.replace(/\\/g, "/");
|
|
115
|
+
if (exclude) {
|
|
116
|
+
const list = Array.isArray(exclude) ? exclude : [exclude];
|
|
117
|
+
for (const raw of list) {
|
|
118
|
+
if (!raw) continue;
|
|
119
|
+
try {
|
|
120
|
+
const pattern = raw.replace(/\\/g, "/").replace(/[.+^$\{\}\|\[\]\\]/g, (m) => "\\" + m).replace(/\*\*/g, ".*").replace(/(?<!\.)\*/g, "[^/]*").replace(/\?/g, "[^/]");
|
|
121
|
+
const exRegex = new RegExp(pattern);
|
|
122
|
+
if (exRegex.test(p)) return false;
|
|
123
|
+
} catch {
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (include) {
|
|
128
|
+
const list = Array.isArray(include) ? include : [include];
|
|
129
|
+
let matched = false;
|
|
130
|
+
for (const raw of list) {
|
|
131
|
+
if (!raw) continue;
|
|
132
|
+
try {
|
|
133
|
+
const pattern = raw.replace(/\\/g, "/").replace(/[.+^$\{\}\|\[\]\\]/g, (m) => "\\" + m).replace(/\*\*/g, ".*").replace(/(?<!\.)\*/g, "[^/]*").replace(/\?/g, "[^/]");
|
|
134
|
+
const incRegex = new RegExp(pattern);
|
|
135
|
+
if (incRegex.test(p)) {
|
|
136
|
+
matched = true;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (!matched) return false;
|
|
143
|
+
}
|
|
144
|
+
return p.endsWith(".md");
|
|
145
|
+
}
|
|
146
|
+
const matchesGlobFilter = matchesSourceFilters;
|
|
147
|
+
|
|
148
|
+
function matchPathPatterns(entryPath, patterns) {
|
|
149
|
+
if (!patterns) return false;
|
|
150
|
+
const list = Array.isArray(patterns) ? patterns : [patterns];
|
|
151
|
+
if (!list.length) return false;
|
|
152
|
+
const path = ("/" + entryPath.replace(/\\/g, "/").replace(/^\/+/, "")).replace(/\/+$/, "") || "/";
|
|
153
|
+
let matched = false;
|
|
154
|
+
for (const raw of list) {
|
|
155
|
+
const isNeg = raw.startsWith("!");
|
|
156
|
+
const rawPattern = isNeg ? raw.slice(1) : raw;
|
|
157
|
+
const pattern = ("/" + rawPattern.replace(/\\/g, "/").replace(/^\/+/, "")).replace(/\/+$/, "") || "/";
|
|
158
|
+
let isMatch = false;
|
|
159
|
+
if (pattern.endsWith("/**")) {
|
|
160
|
+
const base = pattern.slice(0, -3) || "/";
|
|
161
|
+
isMatch = path === base || path.startsWith(base + "/");
|
|
162
|
+
} else if (pattern.includes("*") || pattern.includes("?")) {
|
|
163
|
+
const regexStr = "^" + pattern.replace(/[.+^${}()|[\]\\]/g, (m) => "\\" + m).replace(/\*\*/g, ".*").replace(/(?<!\.)\*/g, "[^/]*").replace(/\?/g, "[^/]") + "$";
|
|
164
|
+
isMatch = new RegExp(regexStr).test(path);
|
|
165
|
+
} else {
|
|
166
|
+
isMatch = path === pattern;
|
|
167
|
+
}
|
|
168
|
+
if (isMatch) {
|
|
169
|
+
if (isNeg) return false;
|
|
170
|
+
matched = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return matched;
|
|
174
|
+
}
|
|
175
|
+
function resolveCollectionForPath(entryPath, collectionsConfig, fallbackId = "content") {
|
|
176
|
+
if (collectionsConfig) {
|
|
177
|
+
for (const [colId, colConfig] of Object.entries(collectionsConfig)) {
|
|
178
|
+
if (colConfig.path && matchPathPatterns(entryPath, colConfig.path)) {
|
|
179
|
+
return colId;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return fallbackId;
|
|
184
|
+
}
|
|
185
|
+
function stripOrderPrefix(name) {
|
|
186
|
+
return name.replace(/^(\d+\.)+/, "");
|
|
187
|
+
}
|
|
188
|
+
function isGroupSegment(segment) {
|
|
189
|
+
const stripped = stripOrderPrefix(segment);
|
|
190
|
+
return /^\([^)]+\)$/.test(stripped);
|
|
191
|
+
}
|
|
192
|
+
function extractGroupTitle(segment) {
|
|
193
|
+
const stripped = stripOrderPrefix(segment);
|
|
194
|
+
const inner = stripped.replace(/^\(|\)$/g, "");
|
|
195
|
+
return inner.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
196
|
+
}
|
|
197
|
+
function extractOrderPrefix(name) {
|
|
198
|
+
const match = name.match(/^(\d+)\./);
|
|
199
|
+
return match ? parseInt(match[1], 10) : void 0;
|
|
200
|
+
}
|
|
201
|
+
function isRemoteSource(from) {
|
|
202
|
+
return /^(github:|gh:|gitlab:|bitbucket:|sourcehut:|https?:\/\/)/i.test(from);
|
|
203
|
+
}
|
|
204
|
+
function resolveSourcePrefix(writtenPrefix, fileDirRelToContent) {
|
|
205
|
+
const dirSegments = fileDirRelToContent.replace(/\\/g, "/").split("/").filter(Boolean).filter((seg) => !isGroupSegment(seg)).map(stripOrderPrefix).filter(Boolean);
|
|
206
|
+
const dirPrefix = "/" + dirSegments.join("/");
|
|
207
|
+
const baseDir = dirPrefix === "/" ? "" : dirPrefix;
|
|
208
|
+
if (!writtenPrefix || writtenPrefix === "." || writtenPrefix === "./") {
|
|
209
|
+
return dirPrefix === "" ? "/" : dirPrefix;
|
|
210
|
+
}
|
|
211
|
+
const p = writtenPrefix.replace(/\\/g, "/").trim();
|
|
212
|
+
if (p.startsWith("/")) {
|
|
213
|
+
const cleaned2 = p.split("/").filter(Boolean).filter((seg) => !isGroupSegment(seg)).map(stripOrderPrefix).join("/");
|
|
214
|
+
return "/" + cleaned2;
|
|
215
|
+
}
|
|
216
|
+
const combined = normalize(`${baseDir}/${p}`);
|
|
217
|
+
const cleaned = combined.split("/").filter(Boolean).filter((seg) => !isGroupSegment(seg)).map(stripOrderPrefix).join("/");
|
|
218
|
+
return "/" + cleaned;
|
|
219
|
+
}
|
|
220
|
+
async function discoverSources(contentDir) {
|
|
221
|
+
if (!existsSync(contentDir)) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
const results = [];
|
|
225
|
+
async function walk(currentDir) {
|
|
226
|
+
let entries;
|
|
227
|
+
try {
|
|
228
|
+
entries = await readdir(currentDir, { withFileTypes: true });
|
|
229
|
+
} catch {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
for (const entry of entries) {
|
|
233
|
+
const fullPath = resolve(currentDir, entry.name);
|
|
234
|
+
if (entry.isDirectory()) {
|
|
235
|
+
await walk(fullPath);
|
|
236
|
+
} else if (entry.isFile() && entry.name === ".sources.json") {
|
|
237
|
+
try {
|
|
238
|
+
const raw = await readFile(fullPath, "utf8");
|
|
239
|
+
const parsed = JSON.parse(raw);
|
|
240
|
+
const sourcesList = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.sources) ? parsed.sources : [];
|
|
241
|
+
const fileDirRel = relative(contentDir, currentDir).replace(/\\/g, "/");
|
|
242
|
+
results.push({
|
|
243
|
+
filePath: fullPath,
|
|
244
|
+
fileDirRel: fileDirRel === "." ? "" : fileDirRel,
|
|
245
|
+
sources: sourcesList
|
|
246
|
+
});
|
|
247
|
+
} catch (err) {
|
|
248
|
+
console.warn(`[qarpeo:cms] Error parsing sources file at ${fullPath}:`, err);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
await walk(contentDir);
|
|
254
|
+
return results;
|
|
255
|
+
}
|
|
256
|
+
async function resolveAllCmsSources(options) {
|
|
257
|
+
const { contentDir, rootDir, cacheDir, configSources = [] } = options;
|
|
258
|
+
const discovered = await discoverSources(contentDir);
|
|
259
|
+
const resolvedList = [];
|
|
260
|
+
for (const item of discovered) {
|
|
261
|
+
const sourceFileDir = dirname(item.filePath);
|
|
262
|
+
for (const src of item.sources) {
|
|
263
|
+
if (!src.from) continue;
|
|
264
|
+
const normalizedPrefix = resolveSourcePrefix(src.prefix, item.fileDirRel);
|
|
265
|
+
const priority = typeof src.priority === "number" ? src.priority : 0;
|
|
266
|
+
const order = typeof src.order === "number" ? src.order : extractOrderPrefix(item.fileDirRel) ?? 0;
|
|
267
|
+
let resolvedDir = "";
|
|
268
|
+
if (isRemoteSource(src.from)) {
|
|
269
|
+
const hash = createHash("sha256").update(src.from).digest("hex").slice(0, 12);
|
|
270
|
+
const targetDir = resolve(cacheDir, `qarpeo/cms-sources/source-${hash}`);
|
|
271
|
+
try {
|
|
272
|
+
await downloadTemplate(src.from, {
|
|
273
|
+
dir: targetDir,
|
|
274
|
+
preferOffline: true,
|
|
275
|
+
auth: process.env.GITHUB_TOKEN || process.env.GH_TOKEN
|
|
276
|
+
});
|
|
277
|
+
resolvedDir = targetDir;
|
|
278
|
+
} catch (err) {
|
|
279
|
+
console.warn(
|
|
280
|
+
`[qarpeo:cms] Failed to download remote source "${src.from}":`,
|
|
281
|
+
err?.message || err
|
|
282
|
+
);
|
|
283
|
+
if (existsSync(targetDir)) {
|
|
284
|
+
resolvedDir = targetDir;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
resolvedDir = resolve(sourceFileDir, src.from);
|
|
289
|
+
if (!existsSync(resolvedDir)) {
|
|
290
|
+
const fromRoot = resolve(rootDir, src.from);
|
|
291
|
+
if (existsSync(fromRoot)) {
|
|
292
|
+
resolvedDir = fromRoot;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
resolvedList.push({
|
|
297
|
+
...src,
|
|
298
|
+
resolvedDir,
|
|
299
|
+
normalizedPrefix,
|
|
300
|
+
priority,
|
|
301
|
+
order,
|
|
302
|
+
sourceConfigFile: item.filePath
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
for (const src of configSources) {
|
|
307
|
+
if (!src.from) continue;
|
|
308
|
+
const normalizedPrefix = resolveSourcePrefix(src.prefix, "");
|
|
309
|
+
const priority = typeof src.priority === "number" ? src.priority : 0;
|
|
310
|
+
const order = typeof src.order === "number" ? src.order : 0;
|
|
311
|
+
let resolvedDir = "";
|
|
312
|
+
if (isRemoteSource(src.from)) {
|
|
313
|
+
const hash = createHash("sha256").update(src.from).digest("hex").slice(0, 12);
|
|
314
|
+
const targetDir = resolve(cacheDir, `qarpeo/cms-sources/source-${hash}`);
|
|
315
|
+
try {
|
|
316
|
+
await downloadTemplate(src.from, {
|
|
317
|
+
dir: targetDir,
|
|
318
|
+
preferOffline: true,
|
|
319
|
+
auth: process.env.GITHUB_TOKEN || process.env.GH_TOKEN
|
|
320
|
+
});
|
|
321
|
+
resolvedDir = targetDir;
|
|
322
|
+
} catch (err) {
|
|
323
|
+
console.warn(
|
|
324
|
+
`[qarpeo:cms] Failed to download remote source "${src.from}":`,
|
|
325
|
+
err?.message || err
|
|
326
|
+
);
|
|
327
|
+
if (existsSync(targetDir)) {
|
|
328
|
+
resolvedDir = targetDir;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
resolvedDir = resolve(contentDir, src.from);
|
|
333
|
+
if (!existsSync(resolvedDir)) {
|
|
334
|
+
const fromRoot = resolve(rootDir, src.from);
|
|
335
|
+
if (existsSync(fromRoot)) {
|
|
336
|
+
resolvedDir = fromRoot;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
resolvedList.push({
|
|
341
|
+
...src,
|
|
342
|
+
resolvedDir,
|
|
343
|
+
normalizedPrefix,
|
|
344
|
+
priority,
|
|
345
|
+
order
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
resolvedList.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
|
349
|
+
return resolvedList;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const ALL_PAYMENTS_TABLE_NAMES = [
|
|
353
|
+
"_qarpeo_customers",
|
|
354
|
+
"_qarpeo_subscriptions",
|
|
355
|
+
"_qarpeo_webhook_events",
|
|
356
|
+
"_qarpeo_usage_records"
|
|
357
|
+
];
|
|
358
|
+
function getActivePaymentsTableNames(payments) {
|
|
359
|
+
if (!payments) return [];
|
|
360
|
+
return [...ALL_PAYMENTS_TABLE_NAMES];
|
|
361
|
+
}
|
|
362
|
+
function generatePaymentsSchema(payments) {
|
|
363
|
+
if (!payments) {
|
|
364
|
+
return "// Qarpeo Payments is disabled\nexport default {};\n";
|
|
365
|
+
}
|
|
366
|
+
const lines = [
|
|
367
|
+
`// Auto-generated by qarpeo \u2014 Cloudflare D1 Payments Engine`,
|
|
368
|
+
`// snakeCase.table maps camelCase property names -> snake_case column names automatically`,
|
|
369
|
+
`import { integer, real, text, index, snakeCase } from "drizzle-orm/sqlite-core";`,
|
|
370
|
+
``,
|
|
371
|
+
`// \u2500\u2500\u2500 1. Customers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
372
|
+
`// Maps user (and optional org) to payment provider customer identifiers`,
|
|
373
|
+
`export const customers = snakeCase.table("_qarpeo_customers", {`,
|
|
374
|
+
` id: text().primaryKey(),`,
|
|
375
|
+
` userId: text().notNull(),`,
|
|
376
|
+
` orgId: text(),`,
|
|
377
|
+
` provider: text().notNull().default("stripe"),`,
|
|
378
|
+
` customerId: text().notNull(),`,
|
|
379
|
+
` email: text().notNull(),`,
|
|
380
|
+
` name: text(),`,
|
|
381
|
+
` metadataJson: text().default("{}"),`,
|
|
382
|
+
` createdAt: integer().notNull(),`,
|
|
383
|
+
` updatedAt: integer().notNull(),`,
|
|
384
|
+
`}, (t) => [`,
|
|
385
|
+
` index("_qarpeo_customers_user_idx").on(t.userId),`,
|
|
386
|
+
` index("_qarpeo_customers_customer_idx").on(t.customerId),`,
|
|
387
|
+
` index("_qarpeo_customers_org_idx").on(t.orgId),`,
|
|
388
|
+
`]);`,
|
|
389
|
+
``,
|
|
390
|
+
`// \u2500\u2500\u2500 2. Subscriptions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
391
|
+
`// Active, trialing, past_due, or canceled subscription records from payment provider`,
|
|
392
|
+
`export const subscriptions = snakeCase.table("_qarpeo_subscriptions", {`,
|
|
393
|
+
` id: text().primaryKey(),`,
|
|
394
|
+
` customerId: text().notNull(),`,
|
|
395
|
+
` userId: text().notNull(),`,
|
|
396
|
+
` orgId: text(),`,
|
|
397
|
+
` provider: text().notNull().default("stripe"),`,
|
|
398
|
+
` subscriptionId: text().notNull().unique(),`,
|
|
399
|
+
` planId: text().notNull(),`,
|
|
400
|
+
` priceId: text().notNull(),`,
|
|
401
|
+
` status: text().notNull(),`,
|
|
402
|
+
` quantity: integer().notNull().default(1),`,
|
|
403
|
+
` cancelAtPeriodEnd: integer().notNull().default(0),`,
|
|
404
|
+
` currentPeriodStart: integer().notNull(),`,
|
|
405
|
+
` currentPeriodEnd: integer().notNull(),`,
|
|
406
|
+
` trialEnd: integer(),`,
|
|
407
|
+
` canceledAt: integer(),`,
|
|
408
|
+
` metadataJson: text().default("{}"),`,
|
|
409
|
+
` createdAt: integer().notNull(),`,
|
|
410
|
+
` updatedAt: integer().notNull(),`,
|
|
411
|
+
`}, (t) => [`,
|
|
412
|
+
` index("_qarpeo_subs_user_idx").on(t.userId),`,
|
|
413
|
+
` index("_qarpeo_subs_subscription_idx").on(t.subscriptionId),`,
|
|
414
|
+
` index("_qarpeo_subs_customer_idx").on(t.customerId),`,
|
|
415
|
+
` index("_qarpeo_subs_status_idx").on(t.status),`,
|
|
416
|
+
` index("_qarpeo_subs_org_idx").on(t.orgId),`,
|
|
417
|
+
`]);`,
|
|
418
|
+
``,
|
|
419
|
+
`// \u2500\u2500\u2500 3. Webhook Events (Idempotency) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
420
|
+
`// Prevents duplicate processing of provider webhook retries`,
|
|
421
|
+
`export const webhookEvents = snakeCase.table("_qarpeo_webhook_events", {`,
|
|
422
|
+
` id: text().primaryKey(),`,
|
|
423
|
+
` eventId: text().notNull().unique(),`,
|
|
424
|
+
` provider: text().notNull(),`,
|
|
425
|
+
` eventType: text().notNull(),`,
|
|
426
|
+
` createdAt: integer().notNull(),`,
|
|
427
|
+
`}, (t) => [`,
|
|
428
|
+
` index("_qarpeo_webhook_events_event_idx").on(t.eventId),`,
|
|
429
|
+
`]);`,
|
|
430
|
+
``,
|
|
431
|
+
`// \u2500\u2500\u2500 4. Usage Records (Metered Billing) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
432
|
+
`// Stores fine-grained metered usage consumption events`,
|
|
433
|
+
`export const usageRecords = snakeCase.table("_qarpeo_usage_records", {`,
|
|
434
|
+
` id: text().primaryKey(),`,
|
|
435
|
+
` userId: text(),`,
|
|
436
|
+
` orgId: text(),`,
|
|
437
|
+
` customerId: text(),`,
|
|
438
|
+
` subscriptionId: text(),`,
|
|
439
|
+
` eventName: text().notNull(),`,
|
|
440
|
+
` quantity: real().notNull().default(1),`,
|
|
441
|
+
` action: text().notNull().default("increment"),`,
|
|
442
|
+
` metadataJson: text().default("{}"),`,
|
|
443
|
+
` timestamp: integer().notNull(),`,
|
|
444
|
+
` createdAt: integer().notNull(),`,
|
|
445
|
+
`}, (t) => [`,
|
|
446
|
+
` index("_qarpeo_usage_user_idx").on(t.userId),`,
|
|
447
|
+
` index("_qarpeo_usage_sub_idx").on(t.subscriptionId),`,
|
|
448
|
+
` index("_qarpeo_usage_event_idx").on(t.eventName),`,
|
|
449
|
+
` index("_qarpeo_usage_timestamp_idx").on(t.timestamp),`,
|
|
450
|
+
`]);`,
|
|
451
|
+
``,
|
|
452
|
+
`export default {`,
|
|
453
|
+
` customers,`,
|
|
454
|
+
` subscriptions,`,
|
|
455
|
+
` webhookEvents,`,
|
|
456
|
+
` usageRecords,`,
|
|
457
|
+
`};`,
|
|
458
|
+
``
|
|
459
|
+
];
|
|
460
|
+
return lines.join("\n");
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function getActiveNotificationsTableNames(notifications) {
|
|
464
|
+
if (!notifications) return [];
|
|
465
|
+
const notifTable = (typeof notifications === "object" ? notifications.tableName : void 0) || "_qarpeo_notifications";
|
|
466
|
+
return [notifTable, "_qarpeo_push_subscriptions"];
|
|
467
|
+
}
|
|
468
|
+
function generateNotificationsSchema(notifications) {
|
|
469
|
+
if (!notifications) {
|
|
470
|
+
return "// Qarpeo Notifications is disabled\nexport default {};\n";
|
|
471
|
+
}
|
|
472
|
+
const notifTable = (typeof notifications === "object" ? notifications.tableName : void 0) || "_qarpeo_notifications";
|
|
473
|
+
const pushTable = "_qarpeo_push_subscriptions";
|
|
474
|
+
const lines = [
|
|
475
|
+
`// Auto-generated by qarpeo \u2014 Notifications & Push Subscriptions Engine`,
|
|
476
|
+
`// snakeCase.table maps camelCase property names \u2192 snake_case column names automatically`,
|
|
477
|
+
`import { integer, text, index, snakeCase } from "drizzle-orm/sqlite-core";`,
|
|
478
|
+
``,
|
|
479
|
+
`// \u2500\u2500\u2500 1. In-App Notifications \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
480
|
+
`export const notifications = snakeCase.table("${notifTable}", {`,
|
|
481
|
+
` id: text().primaryKey(),`,
|
|
482
|
+
` userId: text().notNull(),`,
|
|
483
|
+
` tenantId: text(),`,
|
|
484
|
+
` title: text().notNull(),`,
|
|
485
|
+
` body: text(),`,
|
|
486
|
+
` icon: text(),`,
|
|
487
|
+
` actionUrl: text(),`,
|
|
488
|
+
` channels: text().notNull().default('["in-app"]'),`,
|
|
489
|
+
` read: integer().notNull().default(0),`,
|
|
490
|
+
` readAt: integer(),`,
|
|
491
|
+
` createdAt: integer().notNull(),`,
|
|
492
|
+
` metadata: text(),`,
|
|
493
|
+
`}, (t) => [`,
|
|
494
|
+
` index("idx_qarpeo_notifs_user").on(t.userId, t.createdAt),`,
|
|
495
|
+
`]);`,
|
|
496
|
+
``,
|
|
497
|
+
`// \u2500\u2500\u2500 2. Web Push Subscriptions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
498
|
+
`export const pushSubscriptions = snakeCase.table("${pushTable}", {`,
|
|
499
|
+
` endpoint: text().primaryKey(),`,
|
|
500
|
+
` userId: text().notNull(),`,
|
|
501
|
+
` tenantId: text(),`,
|
|
502
|
+
` keysP256dh: text().notNull(),`,
|
|
503
|
+
` keysAuth: text().notNull(),`,
|
|
504
|
+
` createdAt: integer().notNull(),`,
|
|
505
|
+
`}, (t) => [`,
|
|
506
|
+
` index("idx_qarpeo_push_user").on(t.userId),`,
|
|
507
|
+
`]);`
|
|
508
|
+
];
|
|
509
|
+
return lines.join("\n") + "\n";
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const ALL_TENANTS_TABLE_NAMES = ["_qarpeo_tenants", "_qarpeo_domains"];
|
|
513
|
+
function getActiveTenantsTableNames(multitenant) {
|
|
514
|
+
if (!multitenant) return [];
|
|
515
|
+
return [...ALL_TENANTS_TABLE_NAMES];
|
|
516
|
+
}
|
|
517
|
+
function generateTenantsSchema(multitenant) {
|
|
518
|
+
if (!multitenant) {
|
|
519
|
+
return "// Qarpeo Multi-Tenancy is disabled\nexport default {};\n";
|
|
520
|
+
}
|
|
521
|
+
const lines = [
|
|
522
|
+
`// Auto-generated by qarpeo \u2014 Multi-Tenancy & Custom Domains Engine`,
|
|
523
|
+
`// snakeCase.table maps camelCase property names \u2192 snake_case column names automatically`,
|
|
524
|
+
`import { integer, text, index, snakeCase } from "drizzle-orm/sqlite-core";`,
|
|
525
|
+
``,
|
|
526
|
+
`// \u2500\u2500\u2500 1. Tenants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
527
|
+
`// Core tenant records (teams, accounts, sub-organizations)`,
|
|
528
|
+
`export const tenants = snakeCase.table("_qarpeo_tenants", {`,
|
|
529
|
+
` id: text().primaryKey(),`,
|
|
530
|
+
` slug: text().notNull().unique(),`,
|
|
531
|
+
` name: text().notNull(),`,
|
|
532
|
+
` plan: text().default("free"),`,
|
|
533
|
+
` organizationId: text(),`,
|
|
534
|
+
` customDomain: text(),`,
|
|
535
|
+
` logoUrl: text(),`,
|
|
536
|
+
` metadataJson: text().default("{}"),`,
|
|
537
|
+
` createdAt: integer().notNull(),`,
|
|
538
|
+
` updatedAt: integer().notNull(),`,
|
|
539
|
+
`}, (t) => [`,
|
|
540
|
+
` index("_qarpeo_tenants_slug_idx").on(t.slug),`,
|
|
541
|
+
` index("_qarpeo_tenants_org_idx").on(t.organizationId),`,
|
|
542
|
+
` index("_qarpeo_tenants_custom_domain_idx").on(t.customDomain),`,
|
|
543
|
+
`]);`,
|
|
544
|
+
``,
|
|
545
|
+
`// \u2500\u2500\u2500 2. Custom Domains \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
546
|
+
`// Custom hostnames mapped to tenants, verified via Cloudflare for SaaS`,
|
|
547
|
+
`export const domains = snakeCase.table("_qarpeo_domains", {`,
|
|
548
|
+
` id: text().primaryKey(),`,
|
|
549
|
+
` tenantId: text().notNull().references(() => tenants.id, { onDelete: "cascade" }),`,
|
|
550
|
+
` domain: text().notNull().unique(),`,
|
|
551
|
+
` status: text().notNull().default("pending"),`,
|
|
552
|
+
` sslStatus: text().notNull().default("initializing"),`,
|
|
553
|
+
` verificationType: text().default("cname"),`,
|
|
554
|
+
` verificationTarget: text(),`,
|
|
555
|
+
` verificationName: text(),`,
|
|
556
|
+
` verificationValue: text(),`,
|
|
557
|
+
` cloudflareHostnameId: text(),`,
|
|
558
|
+
` errorMessage: text(),`,
|
|
559
|
+
` createdAt: integer().notNull(),`,
|
|
560
|
+
` updatedAt: integer().notNull(),`,
|
|
561
|
+
`}, (t) => [`,
|
|
562
|
+
` index("_qarpeo_domains_tenant_idx").on(t.tenantId),`,
|
|
563
|
+
` index("_qarpeo_domains_domain_idx").on(t.domain),`,
|
|
564
|
+
` index("_qarpeo_domains_status_idx").on(t.status),`,
|
|
565
|
+
`]);`
|
|
566
|
+
];
|
|
567
|
+
return lines.join("\n");
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const ALL_CMS_TABLE_NAMES = [
|
|
571
|
+
"_qarpeo_cms_collections",
|
|
572
|
+
"_qarpeo_cms_entries",
|
|
573
|
+
"_qarpeo_cms_revisions"
|
|
574
|
+
];
|
|
575
|
+
function getActiveCmsTableNames(cms) {
|
|
576
|
+
if (!cms) return [];
|
|
577
|
+
return [...ALL_CMS_TABLE_NAMES];
|
|
578
|
+
}
|
|
579
|
+
const cmsCollections = snakeCase.table("_qarpeo_cms_collections", {
|
|
580
|
+
id: text().primaryKey(),
|
|
581
|
+
tenantId: text(),
|
|
582
|
+
name: text().notNull(),
|
|
583
|
+
description: text(),
|
|
584
|
+
schemaJson: text().notNull().default("{}"),
|
|
585
|
+
source: text().notNull().default("db"),
|
|
586
|
+
order: integer().notNull().default(0),
|
|
587
|
+
createdAt: integer().notNull(),
|
|
588
|
+
updatedAt: integer().notNull()
|
|
589
|
+
});
|
|
590
|
+
const cmsEntries = snakeCase.table(
|
|
591
|
+
"_qarpeo_cms_entries",
|
|
592
|
+
{
|
|
593
|
+
id: text().primaryKey(),
|
|
594
|
+
tenantId: text(),
|
|
595
|
+
collectionId: text().notNull(),
|
|
596
|
+
slug: text().notNull(),
|
|
597
|
+
title: text().notNull(),
|
|
598
|
+
description: text(),
|
|
599
|
+
coverImage: text(),
|
|
600
|
+
tags: text(),
|
|
601
|
+
order: integer().notNull().default(0),
|
|
602
|
+
contentMd: text().notNull().default(""),
|
|
603
|
+
contentHtml: text().notNull().default(""),
|
|
604
|
+
metadataJson: text().default("{}"),
|
|
605
|
+
status: text().notNull().default("draft"),
|
|
606
|
+
source: text().notNull().default("db"),
|
|
607
|
+
path: text(),
|
|
608
|
+
filePath: text(),
|
|
609
|
+
contentHash: text(),
|
|
610
|
+
authorId: text(),
|
|
611
|
+
locale: text().notNull().default("en"),
|
|
612
|
+
version: text().notNull().default("latest"),
|
|
613
|
+
publishedAt: integer(),
|
|
614
|
+
createdAt: integer().notNull(),
|
|
615
|
+
updatedAt: integer().notNull()
|
|
616
|
+
},
|
|
617
|
+
(t) => [
|
|
618
|
+
index("_qarpeo_cms_entries_collection_idx").on(t.collectionId),
|
|
619
|
+
index("_qarpeo_cms_entries_tenant_idx").on(t.tenantId, t.collectionId),
|
|
620
|
+
index("_qarpeo_cms_entries_slug_idx").on(t.collectionId, t.slug),
|
|
621
|
+
index("_qarpeo_cms_entries_status_idx").on(t.status),
|
|
622
|
+
index("_qarpeo_cms_entries_order_idx").on(t.collectionId, t.order),
|
|
623
|
+
index("_qarpeo_cms_entries_path_idx").on(t.collectionId, t.path),
|
|
624
|
+
index("_qarpeo_cms_entries_locale_idx").on(t.collectionId, t.locale),
|
|
625
|
+
index("_qarpeo_cms_entries_path_locale_idx").on(t.path, t.locale),
|
|
626
|
+
index("_qarpeo_cms_entries_published_at_idx").on(t.publishedAt),
|
|
627
|
+
index("_qarpeo_cms_entries_list_idx").on(t.collectionId, t.status, t.publishedAt)
|
|
628
|
+
]
|
|
629
|
+
);
|
|
630
|
+
const cmsRevisions = snakeCase.table(
|
|
631
|
+
"_qarpeo_cms_revisions",
|
|
632
|
+
{
|
|
633
|
+
id: text().primaryKey(),
|
|
634
|
+
entryId: text().notNull(),
|
|
635
|
+
title: text().notNull(),
|
|
636
|
+
contentMd: text().notNull(),
|
|
637
|
+
metadataJson: text().default("{}"),
|
|
638
|
+
authorId: text(),
|
|
639
|
+
createdAt: integer().notNull()
|
|
640
|
+
},
|
|
641
|
+
(t) => [index("_qarpeo_cms_revisions_entry_idx").on(t.entryId, t.createdAt)]
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
const module$1 = defineNuxtModule({
|
|
645
|
+
meta: {
|
|
646
|
+
name: "qarpeo",
|
|
647
|
+
configKey: "qarpeo",
|
|
648
|
+
compatibility: {
|
|
649
|
+
nuxt: ">=4.0.0"
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
defaults: {
|
|
653
|
+
site: {},
|
|
654
|
+
remote: false,
|
|
655
|
+
db: false,
|
|
656
|
+
d1: false,
|
|
657
|
+
blob: false,
|
|
658
|
+
r2: false,
|
|
659
|
+
storage: false,
|
|
660
|
+
kv: false,
|
|
661
|
+
cache: false,
|
|
662
|
+
ai: false,
|
|
663
|
+
vectorize: false,
|
|
664
|
+
queue: false,
|
|
665
|
+
analytics: false,
|
|
666
|
+
ratelimit: false,
|
|
667
|
+
hyperdrive: false,
|
|
668
|
+
browser: false,
|
|
669
|
+
do: false,
|
|
670
|
+
cron: false,
|
|
671
|
+
email: false,
|
|
672
|
+
auth: false,
|
|
673
|
+
cms: false,
|
|
674
|
+
realtime: false,
|
|
675
|
+
payments: false,
|
|
676
|
+
jobs: false,
|
|
677
|
+
agents: false,
|
|
678
|
+
mail: false,
|
|
679
|
+
multitenant: false,
|
|
680
|
+
notifications: false,
|
|
681
|
+
notify: false
|
|
682
|
+
},
|
|
683
|
+
async setup(_options, nuxt) {
|
|
684
|
+
const logger = useLogger("qarpeo");
|
|
685
|
+
const resolver = createResolver(import.meta.url);
|
|
686
|
+
const patchIgnoreInstance = (ig) => {
|
|
687
|
+
if (!ig || ig.__qarpeo_cross_drive_patched) return;
|
|
688
|
+
ig.__qarpeo_cross_drive_patched = true;
|
|
689
|
+
const origIgnores = ig.ignores?.bind(ig);
|
|
690
|
+
if (origIgnores) {
|
|
691
|
+
ig.ignores = (pathname) => {
|
|
692
|
+
if (typeof pathname === "string" && (/^[a-zA-Z]:[/\\]/.test(pathname) || pathname.startsWith("/"))) {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
try {
|
|
696
|
+
return origIgnores(pathname);
|
|
697
|
+
} catch {
|
|
698
|
+
return false;
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
const origTest = ig._test?.bind(ig);
|
|
703
|
+
if (origTest) {
|
|
704
|
+
ig._test = function(pathname, cache, checkUnignored, slices) {
|
|
705
|
+
if (typeof pathname === "string" && (/^[a-zA-Z]:[/\\]/.test(pathname) || pathname.startsWith("/"))) {
|
|
706
|
+
return { ignored: false, unignored: false };
|
|
707
|
+
}
|
|
708
|
+
try {
|
|
709
|
+
return origTest(pathname, cache, checkUnignored, slices);
|
|
710
|
+
} catch {
|
|
711
|
+
return { ignored: false, unignored: false };
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
let _rawIgnore = nuxt._ignore;
|
|
717
|
+
patchIgnoreInstance(_rawIgnore);
|
|
718
|
+
Object.defineProperty(nuxt, "_ignore", {
|
|
719
|
+
configurable: true,
|
|
720
|
+
enumerable: true,
|
|
721
|
+
get() {
|
|
722
|
+
return _rawIgnore;
|
|
723
|
+
},
|
|
724
|
+
set(val) {
|
|
725
|
+
patchIgnoreInstance(val);
|
|
726
|
+
_rawIgnore = val;
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
try {
|
|
730
|
+
const dynamicImport = new Function("m", "return import(m)");
|
|
731
|
+
const ignorePkg = await dynamicImport("ignore").then((m) => m.default || m).catch(() => null);
|
|
732
|
+
if (ignorePkg) {
|
|
733
|
+
const proto = typeof ignorePkg === "function" ? Object.getPrototypeOf(ignorePkg()) : null;
|
|
734
|
+
if (proto && !proto.__qarpeo_cross_drive_patched) {
|
|
735
|
+
proto.__qarpeo_cross_drive_patched = true;
|
|
736
|
+
const origProtoTest = proto._test;
|
|
737
|
+
if (origProtoTest) {
|
|
738
|
+
proto._test = function(pathname, cache, checkUnignored, slices) {
|
|
739
|
+
if (typeof pathname === "string" && (/^[a-zA-Z]:[/\\]/.test(pathname) || pathname.startsWith("/"))) {
|
|
740
|
+
return { ignored: false, unignored: false };
|
|
741
|
+
}
|
|
742
|
+
try {
|
|
743
|
+
return origProtoTest.call(this, pathname, cache, checkUnignored, slices);
|
|
744
|
+
} catch {
|
|
745
|
+
return { ignored: false, unignored: false };
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
const origProtoIgnores = proto.ignores;
|
|
750
|
+
if (origProtoIgnores) {
|
|
751
|
+
proto.ignores = function(pathname) {
|
|
752
|
+
if (typeof pathname === "string" && (/^[a-zA-Z]:[/\\]/.test(pathname) || pathname.startsWith("/"))) {
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
try {
|
|
756
|
+
return origProtoIgnores.call(this, pathname);
|
|
757
|
+
} catch {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
} catch {
|
|
765
|
+
}
|
|
766
|
+
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
|
|
767
|
+
nuxt.options.runtimeConfig.public.qarpeoVersion = version;
|
|
768
|
+
if (nuxt.options.dev) {
|
|
769
|
+
try {
|
|
770
|
+
const { default: EventEmitter } = await import('node:events');
|
|
771
|
+
if (EventEmitter.defaultMaxListeners < 30) {
|
|
772
|
+
EventEmitter.defaultMaxListeners = 30;
|
|
773
|
+
}
|
|
774
|
+
} catch {
|
|
775
|
+
}
|
|
776
|
+
nuxt.hook("listen", (server) => {
|
|
777
|
+
if (server?.setMaxListeners) {
|
|
778
|
+
server.setMaxListeners(Math.max(server.getMaxListeners?.() || 10, 30));
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
const qarpeoConfig = nuxt.options.qarpeo || {};
|
|
783
|
+
const options = defu(qarpeoConfig, _options);
|
|
784
|
+
const contentDirs = [];
|
|
785
|
+
const defaultContentDir = resolve(
|
|
786
|
+
nuxt.options.rootDir,
|
|
787
|
+
typeof options.cms === "object" && options.cms.contentDir ? options.cms.contentDir : "content"
|
|
788
|
+
);
|
|
789
|
+
if (existsSync(defaultContentDir)) {
|
|
790
|
+
contentDirs.push(defaultContentDir.replace(/\\/g, "/"));
|
|
791
|
+
}
|
|
792
|
+
const docsDir = resolve(nuxt.options.rootDir, "docs");
|
|
793
|
+
if (existsSync(docsDir) && !contentDirs.includes(docsDir.replace(/\\/g, "/"))) {
|
|
794
|
+
contentDirs.push(docsDir.replace(/\\/g, "/"));
|
|
795
|
+
}
|
|
796
|
+
if (typeof options.cms === "object" && options.cms.collections) {
|
|
797
|
+
for (const col of Object.values(options.cms.collections)) {
|
|
798
|
+
if (col && typeof col === "object" && col.directory) {
|
|
799
|
+
const colDir = resolve(nuxt.options.rootDir, col.directory).replace(/\\/g, "/");
|
|
800
|
+
if (existsSync(colDir) && !contentDirs.includes(colDir)) {
|
|
801
|
+
contentDirs.push(colDir);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
addVitePlugin({
|
|
807
|
+
name: "qarpeo:tailwind-source",
|
|
808
|
+
enforce: "pre",
|
|
809
|
+
transform(code, id) {
|
|
810
|
+
if (id.includes(".css") && code.includes('@import "tailwindcss"') && !code.includes("qarpeo")) {
|
|
811
|
+
const runtimeAppDir = resolver.resolve("./runtime/app").replace(/\\/g, "/");
|
|
812
|
+
const extraSources = [
|
|
813
|
+
`@source "${runtimeAppDir}";`,
|
|
814
|
+
...contentDirs.map((dir) => `@source "${dir}";`)
|
|
815
|
+
].join("\n");
|
|
816
|
+
return `${code}
|
|
817
|
+
${extraSources}
|
|
818
|
+
`;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
if (options.storage && !options.blob) {
|
|
823
|
+
options.blob = options.storage;
|
|
824
|
+
}
|
|
825
|
+
if (options.cache) {
|
|
826
|
+
options.kv = true;
|
|
827
|
+
}
|
|
828
|
+
if (options.realtime) {
|
|
829
|
+
options.do = true;
|
|
830
|
+
options.kv = true;
|
|
831
|
+
}
|
|
832
|
+
if (options.cms) {
|
|
833
|
+
options.db = options.db || true;
|
|
834
|
+
options.blob = options.blob || true;
|
|
835
|
+
options.auth = options.auth || true;
|
|
836
|
+
options.kv = true;
|
|
837
|
+
if (typeof options.cms === "object" && options.cms.scheduledPublish) {
|
|
838
|
+
options.cron = options.cron || true;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (options.auth) {
|
|
842
|
+
options.db = options.db || true;
|
|
843
|
+
options.kv = true;
|
|
844
|
+
}
|
|
845
|
+
if (options.payments) {
|
|
846
|
+
options.db = options.db || true;
|
|
847
|
+
options.kv = true;
|
|
848
|
+
options.queue = true;
|
|
849
|
+
options.auth = options.auth || true;
|
|
850
|
+
}
|
|
851
|
+
if (options.jobs) {
|
|
852
|
+
options.queue = true;
|
|
853
|
+
}
|
|
854
|
+
if (options.ratelimit) {
|
|
855
|
+
options.kv = true;
|
|
856
|
+
}
|
|
857
|
+
if (options.agents) {
|
|
858
|
+
options.do = true;
|
|
859
|
+
options.ai = true;
|
|
860
|
+
options.vectorize = true;
|
|
861
|
+
options.kv = true;
|
|
862
|
+
}
|
|
863
|
+
if (options.mail) {
|
|
864
|
+
options.email = true;
|
|
865
|
+
if (typeof options.mail === "object" && options.mail.queue) {
|
|
866
|
+
options.queue = true;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (options.multitenant) {
|
|
870
|
+
options.kv = true;
|
|
871
|
+
}
|
|
872
|
+
if (options.notifications || options.notify) {
|
|
873
|
+
options.db = true;
|
|
874
|
+
options.notifications = options.notifications || options.notify;
|
|
875
|
+
}
|
|
876
|
+
nuxt.options.alias["qarpeo/runtime"] = resolver.resolve("./runtime");
|
|
877
|
+
nuxt.options.alias["#qarpeo"] = resolver.resolve("./runtime");
|
|
878
|
+
nuxt.options.alias["qarpeo/auth"] = resolver.resolve("./runtime/auth");
|
|
879
|
+
nuxt.options.alias["#qarpeo/auth"] = resolver.resolve("./runtime/auth");
|
|
880
|
+
nuxt.options.alias["qarpeo/cms"] = resolver.resolve("./runtime/cms");
|
|
881
|
+
nuxt.options.alias["#qarpeo/cms"] = resolver.resolve("./runtime/cms");
|
|
882
|
+
nuxt.options.alias["qarpeo/realtime"] = resolver.resolve("./runtime/realtime");
|
|
883
|
+
nuxt.options.alias["#qarpeo/realtime"] = resolver.resolve("./runtime/realtime");
|
|
884
|
+
nuxt.options.alias["qarpeo/payments"] = resolver.resolve("./runtime/payments");
|
|
885
|
+
nuxt.options.alias["#qarpeo/payments"] = resolver.resolve("./runtime/payments");
|
|
886
|
+
nuxt.options.alias["qarpeo/storage"] = resolver.resolve("./runtime/storage");
|
|
887
|
+
nuxt.options.alias["#qarpeo/storage"] = resolver.resolve("./runtime/storage");
|
|
888
|
+
nuxt.options.alias["qarpeo/notifications"] = resolver.resolve("./runtime/server/utils/notifications");
|
|
889
|
+
nuxt.options.alias["#qarpeo/notifications"] = resolver.resolve("./runtime/server/utils/notifications");
|
|
890
|
+
nuxt.options.alias["qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
|
|
891
|
+
nuxt.options.alias["#qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
|
|
892
|
+
const emptyAgentsTemplate = addTemplate({
|
|
893
|
+
filename: "qarpeo/agents-empty.mjs",
|
|
894
|
+
write: true,
|
|
895
|
+
getContents: () => "export default {};\n"
|
|
896
|
+
});
|
|
897
|
+
nuxt.options.alias["#qarpeo/agents-registry"] = emptyAgentsTemplate.dst;
|
|
898
|
+
function resolvePkgDir(pkg) {
|
|
899
|
+
try {
|
|
900
|
+
const pkgUrl = import.meta.resolve(pkg);
|
|
901
|
+
const filePath = fileURLToPath(pkgUrl);
|
|
902
|
+
let cur = dirname(filePath);
|
|
903
|
+
while (cur && cur !== dirname(cur)) {
|
|
904
|
+
if (existsSync(resolve(cur, "package.json"))) return cur;
|
|
905
|
+
cur = dirname(cur);
|
|
906
|
+
}
|
|
907
|
+
return dirname(filePath);
|
|
908
|
+
} catch {
|
|
909
|
+
const req = createRequire(import.meta.url);
|
|
910
|
+
return dirname(req.resolve(`${pkg}/package.json`));
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
try {
|
|
914
|
+
let resolveShikiDep = function(name) {
|
|
915
|
+
try {
|
|
916
|
+
const req = createRequire(resolve(shikiDir, "package.json"));
|
|
917
|
+
const entry = req.resolve(name);
|
|
918
|
+
let cur = dirname(entry);
|
|
919
|
+
while (cur && cur !== dirname(cur)) {
|
|
920
|
+
if (existsSync(resolve(cur, "package.json"))) return cur;
|
|
921
|
+
cur = dirname(cur);
|
|
922
|
+
}
|
|
923
|
+
return "";
|
|
924
|
+
} catch {
|
|
925
|
+
return "";
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
const drizzleDir = resolvePkgDir("drizzle-orm");
|
|
929
|
+
nuxt.options.alias["drizzle-orm"] = drizzleDir;
|
|
930
|
+
nuxt.options.alias["drizzle-orm/"] = `${drizzleDir}/`;
|
|
931
|
+
const drizzleKitDir = resolvePkgDir("drizzle-kit");
|
|
932
|
+
nuxt.options.alias["drizzle-kit"] = drizzleKitDir;
|
|
933
|
+
nuxt.options.alias["drizzle-kit/"] = `${drizzleKitDir}/`;
|
|
934
|
+
const drizzleSeedDir = resolvePkgDir("drizzle-seed");
|
|
935
|
+
nuxt.options.alias["drizzle-seed"] = drizzleSeedDir;
|
|
936
|
+
nuxt.options.alias["drizzle-seed/"] = `${drizzleSeedDir}/`;
|
|
937
|
+
const authUtilsDir = resolvePkgDir("nuxt-auth-utils");
|
|
938
|
+
nuxt.options.alias["nuxt-auth-utils"] = authUtilsDir;
|
|
939
|
+
nuxt.options.alias["nuxt-auth-utils/"] = `${authUtilsDir}/`;
|
|
940
|
+
const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
|
|
941
|
+
nuxt.options.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
|
|
942
|
+
nuxt.options.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
|
|
943
|
+
nuxt.options.alias["@comark/nuxt/parse"] = resolve(comarkNuxtDir, "dist/parse.js");
|
|
944
|
+
nuxt.options.alias["@comark/nuxt"] = resolve(comarkNuxtDir, "dist/module.js");
|
|
945
|
+
const comarkVueDir = resolvePkgDir("@comark/vue");
|
|
946
|
+
nuxt.options.alias["@comark/vue/vite"] = resolve(comarkVueDir, "dist/vite.js");
|
|
947
|
+
nuxt.options.alias["@comark/vue/utils"] = resolve(comarkVueDir, "dist/utils/index.js");
|
|
948
|
+
nuxt.options.alias["@comark/vue/render"] = resolve(comarkVueDir, "dist/render.js");
|
|
949
|
+
nuxt.options.alias["@comark/vue/parse"] = resolve(comarkVueDir, "dist/parse.js");
|
|
950
|
+
nuxt.options.alias["@comark/vue"] = resolve(comarkVueDir, "dist/index.js");
|
|
951
|
+
const comarkDir = resolvePkgDir("comark");
|
|
952
|
+
nuxt.options.alias["comark/utils"] = resolve(comarkDir, "dist/utils/index.js");
|
|
953
|
+
nuxt.options.alias["comark/render"] = resolve(comarkDir, "dist/render.js");
|
|
954
|
+
nuxt.options.alias["comark/parse"] = resolve(comarkDir, "dist/parse.js");
|
|
955
|
+
nuxt.options.alias["comark/plugins/shiki"] = resolve(comarkDir, "dist/plugins/shiki.js");
|
|
956
|
+
nuxt.options.alias["comark/plugins/shiki.js"] = resolve(comarkDir, "dist/plugins/shiki.js");
|
|
957
|
+
nuxt.options.alias["comark/internal"] = resolve(comarkDir, "dist/internal");
|
|
958
|
+
nuxt.options.alias["comark/internal/"] = `${resolve(comarkDir, "dist/internal")}/`;
|
|
959
|
+
nuxt.options.alias["comark"] = resolve(comarkDir, "dist/index.js");
|
|
960
|
+
const shikiDir = resolvePkgDir("shiki");
|
|
961
|
+
nuxt.options.alias["shiki/engine/javascript"] = resolve(
|
|
962
|
+
shikiDir,
|
|
963
|
+
"dist/engine-javascript.mjs"
|
|
964
|
+
);
|
|
965
|
+
nuxt.options.alias["shiki/engine/oniguruma"] = resolve(shikiDir, "dist/engine-oniguruma.mjs");
|
|
966
|
+
nuxt.options.alias["shiki/core"] = resolve(shikiDir, "dist/core.mjs");
|
|
967
|
+
nuxt.options.alias["shiki/bundle/full"] = resolve(shikiDir, "dist/bundle-full.mjs");
|
|
968
|
+
nuxt.options.alias["shiki/bundle/web"] = resolve(shikiDir, "dist/bundle-web.mjs");
|
|
969
|
+
nuxt.options.alias["shiki/langs"] = resolve(shikiDir, "dist/langs.mjs");
|
|
970
|
+
nuxt.options.alias["shiki/themes"] = resolve(shikiDir, "dist/themes.mjs");
|
|
971
|
+
nuxt.options.alias["shiki/wasm"] = resolve(shikiDir, "dist/wasm.mjs");
|
|
972
|
+
nuxt.options.alias["shiki/dist"] = resolve(shikiDir, "dist");
|
|
973
|
+
nuxt.options.alias["shiki/dist/"] = `${resolve(shikiDir, "dist")}/`;
|
|
974
|
+
nuxt.options.alias["shiki"] = resolve(shikiDir, "dist/index.mjs");
|
|
975
|
+
const langsDir = resolveShikiDep("@shikijs/langs");
|
|
976
|
+
const themesDir = resolveShikiDep("@shikijs/themes");
|
|
977
|
+
const coreDir = resolveShikiDep("@shikijs/core");
|
|
978
|
+
const primitiveDir = resolveShikiDep("@shikijs/primitive");
|
|
979
|
+
const engineJsDir = resolveShikiDep("@shikijs/engine-javascript");
|
|
980
|
+
const typesDir = resolveShikiDep("@shikijs/types");
|
|
981
|
+
const textmateDir = resolveShikiDep("@shikijs/vscode-textmate");
|
|
982
|
+
if (coreDir) {
|
|
983
|
+
nuxt.options.alias["@shikijs/core"] = resolve(coreDir, "dist/index.mjs");
|
|
984
|
+
nuxt.options.alias["@shikijs/core/"] = `${resolve(coreDir, "dist")}/`;
|
|
985
|
+
}
|
|
986
|
+
if (primitiveDir) {
|
|
987
|
+
nuxt.options.alias["@shikijs/primitive"] = resolve(primitiveDir, "dist/index.mjs");
|
|
988
|
+
nuxt.options.alias["@shikijs/primitive/"] = `${resolve(primitiveDir, "dist")}/`;
|
|
989
|
+
}
|
|
990
|
+
if (engineJsDir) {
|
|
991
|
+
nuxt.options.alias["@shikijs/engine-javascript"] = resolve(engineJsDir, "dist/index.mjs");
|
|
992
|
+
}
|
|
993
|
+
if (typesDir) {
|
|
994
|
+
nuxt.options.alias["@shikijs/types"] = resolve(typesDir, "dist/index.mjs");
|
|
995
|
+
nuxt.options.alias["@shikijs/types/"] = `${resolve(typesDir, "dist")}/`;
|
|
996
|
+
}
|
|
997
|
+
if (textmateDir) {
|
|
998
|
+
nuxt.options.alias["@shikijs/vscode-textmate"] = resolve(textmateDir, "dist/index.js");
|
|
999
|
+
}
|
|
1000
|
+
if (langsDir) {
|
|
1001
|
+
nuxt.options.alias["@shikijs/langs"] = resolve(langsDir, "dist/index.mjs");
|
|
1002
|
+
nuxt.options.alias["@shikijs/langs/"] = `${resolve(langsDir, "dist")}/`;
|
|
1003
|
+
try {
|
|
1004
|
+
const files = readdirSync(resolve(langsDir, "dist")).filter((f) => f.endsWith(".mjs"));
|
|
1005
|
+
for (const f of files) {
|
|
1006
|
+
const name = f.replace(/\.mjs$/, "");
|
|
1007
|
+
nuxt.options.alias[`@shikijs/langs/${name}`] = resolve(langsDir, "dist", f);
|
|
1008
|
+
}
|
|
1009
|
+
} catch {
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
if (themesDir) {
|
|
1013
|
+
nuxt.options.alias["@shikijs/themes"] = resolve(themesDir, "dist/index.mjs");
|
|
1014
|
+
nuxt.options.alias["@shikijs/themes/"] = `${resolve(themesDir, "dist")}/`;
|
|
1015
|
+
try {
|
|
1016
|
+
const files = readdirSync(resolve(themesDir, "dist")).filter((f) => f.endsWith(".mjs"));
|
|
1017
|
+
for (const f of files) {
|
|
1018
|
+
const name = f.replace(/\.mjs$/, "");
|
|
1019
|
+
nuxt.options.alias[`@shikijs/themes/${name}`] = resolve(themesDir, "dist", f);
|
|
1020
|
+
}
|
|
1021
|
+
} catch {
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
nuxt.options.build.transpile.push(
|
|
1025
|
+
"shiki",
|
|
1026
|
+
"comark",
|
|
1027
|
+
"@shikijs/core",
|
|
1028
|
+
"@shikijs/primitive",
|
|
1029
|
+
"@shikijs/types",
|
|
1030
|
+
"@shikijs/engine-javascript",
|
|
1031
|
+
"@shikijs/langs",
|
|
1032
|
+
"@shikijs/themes",
|
|
1033
|
+
"@shikijs/vscode-textmate"
|
|
1034
|
+
);
|
|
1035
|
+
nuxt.options.vite = nuxt.options.vite || {};
|
|
1036
|
+
nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {};
|
|
1037
|
+
nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || [];
|
|
1038
|
+
const depsToInclude = [
|
|
1039
|
+
"@comark/vue",
|
|
1040
|
+
"comark",
|
|
1041
|
+
"shiki",
|
|
1042
|
+
"@shikijs/core",
|
|
1043
|
+
"@shikijs/primitive",
|
|
1044
|
+
"@shikijs/types",
|
|
1045
|
+
"@shikijs/engine-javascript"
|
|
1046
|
+
];
|
|
1047
|
+
for (const dep of depsToInclude) {
|
|
1048
|
+
if (!nuxt.options.vite.optimizeDeps.include.includes(dep)) {
|
|
1049
|
+
nuxt.options.vite.optimizeDeps.include.push(dep);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
} catch {
|
|
1053
|
+
}
|
|
1054
|
+
addTemplate({
|
|
1055
|
+
filename: "qarpeo-shiki.css",
|
|
1056
|
+
write: true,
|
|
1057
|
+
getContents: () => {
|
|
1058
|
+
const p = resolver.resolve("./runtime/app/components/shiki.css");
|
|
1059
|
+
return existsSync(p) ? readFileSync(p, "utf8") : "";
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
nuxt.options.css.push("#build/qarpeo-shiki.css");
|
|
1063
|
+
const hasAnyService = Boolean(
|
|
1064
|
+
options.auth || options.blob || options.storage || options.db || options.cache || options.cms || options.realtime || options.payments || options.jobs || options.ratelimit || options.agents || options.mail || options.analytics || options.multitenant || options.kv || options.blob || options.db || options.email || options.ai || options.vectorize || options.queue || options.hyperdrive || options.browser || options.do || options.d1 || options.r2
|
|
1065
|
+
);
|
|
1066
|
+
if (!hasAnyService) {
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
if (options.auth) {
|
|
1070
|
+
const authSecret = process.env.NUXT_APP_SECRET || process.env.NUXT_SESSION_PASSWORD || nuxt.options.runtimeConfig?.appSecret || nuxt.options.runtimeConfig?.session?.password || (typeof options.auth === "object" ? options.auth?.appSecret || options.auth?.session?.secret || options.auth?.session?.password : void 0);
|
|
1071
|
+
if (!authSecret || authSecret.length < 32) {
|
|
1072
|
+
if (!nuxt.options.dev) {
|
|
1073
|
+
logger.warn(
|
|
1074
|
+
"[qarpeo] NUXT_APP_SECRET environment variable is missing or less than 32 characters. Set a secure 32+ character random string for production session encryption (e.g. openssl rand -base64 32)."
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
const authOptions = typeof options.auth === "object" ? options.auth : {};
|
|
1079
|
+
const webAuthnEnabled = Boolean(
|
|
1080
|
+
authOptions.webauthn || authOptions.webAuthn || nuxt.options.auth?.webAuthn
|
|
1081
|
+
);
|
|
1082
|
+
if (webAuthnEnabled) {
|
|
1083
|
+
nuxt.options.auth = defu(nuxt.options.auth || {}, { webAuthn: true });
|
|
1084
|
+
}
|
|
1085
|
+
if (!hasNuxtModule("nuxt-auth-utils")) {
|
|
1086
|
+
const authModuleOptions = webAuthnEnabled ? { webAuthn: true } : {};
|
|
1087
|
+
try {
|
|
1088
|
+
const authModulePath = fileURLToPath(import.meta.resolve("nuxt-auth-utils"));
|
|
1089
|
+
await installModule(authModulePath, authModuleOptions);
|
|
1090
|
+
} catch {
|
|
1091
|
+
await installModule("nuxt-auth-utils", authModuleOptions);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
if (options.cms && !hasNuxtModule("@comark/nuxt")) {
|
|
1096
|
+
try {
|
|
1097
|
+
const comarkModulePath = fileURLToPath(import.meta.resolve("@comark/nuxt"));
|
|
1098
|
+
await installModule(comarkModulePath);
|
|
1099
|
+
} catch {
|
|
1100
|
+
try {
|
|
1101
|
+
await installModule("@comark/nuxt");
|
|
1102
|
+
} catch {
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
if (options.cms) {
|
|
1107
|
+
const cmsOptions = typeof options.cms === "object" ? options.cms : {};
|
|
1108
|
+
const pluginConfig = cmsOptions.plugins || {};
|
|
1109
|
+
const shikiOption = cmsOptions.shiki !== void 0 ? cmsOptions.shiki : pluginConfig.shiki;
|
|
1110
|
+
const shikiEnabled = shikiOption !== false;
|
|
1111
|
+
const publicConfig = nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
|
|
1112
|
+
publicConfig.qarpeo = publicConfig.qarpeo || {};
|
|
1113
|
+
publicConfig.qarpeo.cms = {
|
|
1114
|
+
plugins: {
|
|
1115
|
+
shiki: shikiEnabled ? typeof shikiOption === "object" ? shikiOption : true : false,
|
|
1116
|
+
math: pluginConfig.math === true,
|
|
1117
|
+
mermaid: pluginConfig.mermaid === true
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
if ((options.db || options.d1) && hasNuxtModule("@nuxt/content")) {
|
|
1122
|
+
const contentOpts = nuxt.options.content;
|
|
1123
|
+
if (!contentOpts?.experimental?.sqliteConnector) {
|
|
1124
|
+
nuxt.options.content = defu(contentOpts ?? {}, {
|
|
1125
|
+
experimental: { sqliteConnector: "native" }
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
ensureDevEnv(nuxt.options.rootDir);
|
|
1130
|
+
addTemplate({
|
|
1131
|
+
filename: "wrangler.json",
|
|
1132
|
+
write: true,
|
|
1133
|
+
async getContents() {
|
|
1134
|
+
const config = await createWranglerConfig(nuxt, options);
|
|
1135
|
+
const isRemote = Boolean(options.remote || process.env.QARPEO_CF_REMOTE);
|
|
1136
|
+
const hasToken = Boolean(
|
|
1137
|
+
process.env.CLOUDFLARE_API_TOKEN || process.env.CLOUDFLARE_ACCOUNT_ID
|
|
1138
|
+
);
|
|
1139
|
+
if ((nuxt.options.dev || nuxt.options._prepare) && !isRemote && !hasToken && config.ai) {
|
|
1140
|
+
delete config.ai;
|
|
1141
|
+
}
|
|
1142
|
+
return JSON.stringify(config, null, 2);
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
const configPath = resolve(nuxt.options.buildDir, "wrangler.json");
|
|
1146
|
+
process.env.QARPEO_WRANGLER_CONFIG = configPath;
|
|
1147
|
+
process.env.QARPEO_PERSIST_PATH = resolve(nuxt.options.rootDir, ".wrangler/state/v3");
|
|
1148
|
+
if (options.remote) {
|
|
1149
|
+
process.env.QARPEO_CF_REMOTE = "1";
|
|
1150
|
+
const hasAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.CF_ACCOUNT_ID;
|
|
1151
|
+
if (!hasAccountId) {
|
|
1152
|
+
logger.warn(
|
|
1153
|
+
"[qarpeo] `remote: true` requires a Cloudflare account ID.\n Set CLOUDFLARE_ACCOUNT_ID in your .env file, or run `wrangler login` first."
|
|
1154
|
+
);
|
|
1155
|
+
} else {
|
|
1156
|
+
logger.info(
|
|
1157
|
+
`[qarpeo] Remote dev mode enabled \u2014 connecting to Cloudflare account ${hasAccountId.slice(0, 8)}\u2026`
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
} else {
|
|
1161
|
+
delete process.env.QARPEO_CF_REMOTE;
|
|
1162
|
+
}
|
|
1163
|
+
try {
|
|
1164
|
+
const wranglerUrl = import.meta.resolve("wrangler");
|
|
1165
|
+
process.env.QARPEO_WRANGLER_ENTRY = wranglerUrl;
|
|
1166
|
+
} catch {
|
|
1167
|
+
try {
|
|
1168
|
+
const req = createRequire(import.meta.url);
|
|
1169
|
+
process.env.QARPEO_WRANGLER_ENTRY = req.resolve("wrangler");
|
|
1170
|
+
} catch {
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
if (nuxt.options.dev && !hasNuxtModule("@nuxthub/core") && !nuxt.options._prepare) {
|
|
1174
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/dev-proxy"));
|
|
1175
|
+
}
|
|
1176
|
+
if (options.kv) {
|
|
1177
|
+
process.env.QARPEO_DEFAULT_KV_BINDING = resolveBindingName("kv");
|
|
1178
|
+
}
|
|
1179
|
+
if (options.blob || options.r2) {
|
|
1180
|
+
process.env.QARPEO_DEFAULT_BLOB_BINDING = resolveBindingName("blob");
|
|
1181
|
+
}
|
|
1182
|
+
if (options.db || options.d1) {
|
|
1183
|
+
process.env.QARPEO_DEFAULT_DB_BINDING = resolveBindingName("db", void 0);
|
|
1184
|
+
}
|
|
1185
|
+
if (options.cache) {
|
|
1186
|
+
process.env.QARPEO_DEFAULT_CACHE_BINDING = resolveBindingName("cache");
|
|
1187
|
+
}
|
|
1188
|
+
if (options.ai) {
|
|
1189
|
+
process.env.QARPEO_DEFAULT_AI_BINDING = resolveBindingName("ai");
|
|
1190
|
+
}
|
|
1191
|
+
if (options.vectorize) {
|
|
1192
|
+
process.env.QARPEO_DEFAULT_VECTORIZE_BINDING = resolveBindingName("vectorize");
|
|
1193
|
+
}
|
|
1194
|
+
if (options.queue) {
|
|
1195
|
+
process.env.QARPEO_DEFAULT_QUEUE_BINDING = resolveBindingName("queue");
|
|
1196
|
+
const getQueueFiles = () => findQueueFiles(
|
|
1197
|
+
nuxt.options._layers || [{ cwd: nuxt.options.rootDir, config: nuxt.options }]
|
|
1198
|
+
);
|
|
1199
|
+
const getJobFiles = () => findJobFiles(
|
|
1200
|
+
nuxt.options._layers || [{ cwd: nuxt.options.rootDir, config: nuxt.options }],
|
|
1201
|
+
typeof options.jobs === "object" && options.jobs.dir ? options.jobs.dir : "server/jobs"
|
|
1202
|
+
);
|
|
1203
|
+
const jobsConfig = typeof options.jobs === "object" ? options.jobs : {};
|
|
1204
|
+
const maxRetries = jobsConfig.maxRetries ?? 3;
|
|
1205
|
+
const template = addTemplate({
|
|
1206
|
+
filename: "qarpeo/queue-consumer.ts",
|
|
1207
|
+
write: true,
|
|
1208
|
+
getContents: () => {
|
|
1209
|
+
const queueFiles = getQueueFiles();
|
|
1210
|
+
const jobFiles = options.jobs ? getJobFiles() : [];
|
|
1211
|
+
const hasMailQueue = !!(options.mail && typeof options.mail === "object" && options.mail.queue);
|
|
1212
|
+
if (queueFiles.length === 0 && jobFiles.length === 0 && !hasMailQueue) {
|
|
1213
|
+
return "const queueHandler = null;\nexport default queueHandler;\n";
|
|
1214
|
+
}
|
|
1215
|
+
if (jobFiles.length > 0 || hasMailQueue) {
|
|
1216
|
+
const mailUtilPath = resolver.resolve("./runtime/server/utils/mail").replace(/\\/g, "/");
|
|
1217
|
+
const jobImports = jobFiles.map(
|
|
1218
|
+
(job, idx) => `import * as job_${idx} from "${job.importPath.replace(/\\/g, "/")}";`
|
|
1219
|
+
).join("\n");
|
|
1220
|
+
const jobMapEntries = [
|
|
1221
|
+
...jobFiles.map((job, idx) => ` "${job.name}": job_${idx},`),
|
|
1222
|
+
hasMailQueue ? ` "__qarpeo_mail": { name: "__qarpeo_mail", handler: async (data: any) => { const { deliverMailDirect } = await import("${mailUtilPath}"); await deliverMailDirect(data); } },` : ""
|
|
1223
|
+
].filter(Boolean).join("\n");
|
|
1224
|
+
const customQueueImport = queueFiles.length > 0 ? `import customQueueHandler from "${queueFiles[0].replace(/\\/g, "/").replace(/\.ts$/, "")}";` : "const customQueueHandler = null;";
|
|
1225
|
+
const jobsUtilPath = resolver.resolve("./runtime/server/utils/jobs").replace(/\\/g, "/");
|
|
1226
|
+
return `${jobImports}
|
|
1227
|
+
${customQueueImport}
|
|
1228
|
+
import { runJobsBatch } from "${jobsUtilPath}";
|
|
1229
|
+
|
|
1230
|
+
const jobModules: Record<string, any> = {
|
|
1231
|
+
${jobMapEntries}
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
export default async function (batch: any) {
|
|
1235
|
+
await runJobsBatch(batch, jobModules, {
|
|
1236
|
+
customQueueHandler,
|
|
1237
|
+
maxRetries: ${maxRetries},
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
`;
|
|
1241
|
+
}
|
|
1242
|
+
const importPath = queueFiles[0].replace(/\\/g, "/").replace(/\.ts$/, "");
|
|
1243
|
+
return `import queueHandler from "${importPath}";
|
|
1244
|
+
export default queueHandler;
|
|
1245
|
+
`;
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
nuxt.options.alias["#qarpeo/queue-consumer"] = template.dst;
|
|
1249
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/queue"));
|
|
1250
|
+
}
|
|
1251
|
+
if (options.analytics) {
|
|
1252
|
+
process.env.QARPEO_DEFAULT_ANALYTICS_BINDING = resolveBindingName("analytics");
|
|
1253
|
+
}
|
|
1254
|
+
if (options.ratelimit) {
|
|
1255
|
+
process.env.QARPEO_DEFAULT_RATELIMIT_BINDING = resolveBindingName(
|
|
1256
|
+
"ratelimit",
|
|
1257
|
+
void 0,
|
|
1258
|
+
"RATE_LIMITER"
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
if (options.hyperdrive) {
|
|
1262
|
+
process.env.QARPEO_DEFAULT_HYPERDRIVE_BINDING = resolveBindingName("hyperdrive");
|
|
1263
|
+
}
|
|
1264
|
+
if (options.browser) {
|
|
1265
|
+
process.env.QARPEO_DEFAULT_BROWSER_BINDING = resolveBindingName("browser");
|
|
1266
|
+
}
|
|
1267
|
+
if (options.email) {
|
|
1268
|
+
process.env.QARPEO_DEFAULT_EMAIL_BINDING = resolveBindingName(
|
|
1269
|
+
"email",
|
|
1270
|
+
typeof options.email === "object" ? options.email.binding : void 0,
|
|
1271
|
+
"EMAIL"
|
|
1272
|
+
);
|
|
1273
|
+
let senderIdentities = [];
|
|
1274
|
+
if (typeof options.email === "object" && options.email.from) {
|
|
1275
|
+
const parseSender = (key, raw) => {
|
|
1276
|
+
const trimmed = raw.trim();
|
|
1277
|
+
const match = trimmed.match(/^(?:(?:"?([^"]*)"?\s)?<([^>]+)>|([^<>\s]+))$/);
|
|
1278
|
+
if (match) {
|
|
1279
|
+
const name = match[1]?.trim();
|
|
1280
|
+
const address = (match[2] || match[3] || trimmed).trim();
|
|
1281
|
+
return { key, address, name: name || void 0, label: trimmed };
|
|
1282
|
+
}
|
|
1283
|
+
return { key, address: trimmed, label: trimmed };
|
|
1284
|
+
};
|
|
1285
|
+
if (typeof options.email.from === "string") {
|
|
1286
|
+
process.env.QARPEO_EMAIL_FROM = options.email.from;
|
|
1287
|
+
senderIdentities = [parseSender("default", options.email.from)];
|
|
1288
|
+
} else if (typeof options.email.from === "object") {
|
|
1289
|
+
process.env.QARPEO_EMAIL_SENDERS = JSON.stringify(options.email.from);
|
|
1290
|
+
process.env.QARPEO_EMAIL_FROM = options.email.from.default || Object.values(options.email.from)[0] || "";
|
|
1291
|
+
senderIdentities = Object.entries(options.email.from).map(
|
|
1292
|
+
([key, val]) => parseSender(key, val)
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
const publicConfig = (nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {}).public = nuxt.options.runtimeConfig.public || {};
|
|
1297
|
+
publicConfig.qarpeo = publicConfig.qarpeo || {};
|
|
1298
|
+
publicConfig.qarpeo.email = {
|
|
1299
|
+
senders: senderIdentities
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
const isDrizzle = Boolean(options.db || options.d1);
|
|
1303
|
+
let schemaTemplateDst = "";
|
|
1304
|
+
if (isDrizzle) {
|
|
1305
|
+
const drizzleCheck = checkDrizzleVersion(nuxt.options.rootDir);
|
|
1306
|
+
if (!drizzleCheck.isRC) {
|
|
1307
|
+
throw new Error(drizzleCheck.error);
|
|
1308
|
+
}
|
|
1309
|
+
if (options.auth) {
|
|
1310
|
+
const authSchemaTemplate = addTemplate({
|
|
1311
|
+
filename: "qarpeo/auth-schema.ts",
|
|
1312
|
+
write: true,
|
|
1313
|
+
getContents: () => {
|
|
1314
|
+
return generateAuthSchema(options.auth);
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
nuxt.options.alias["#qarpeo/auth/schema"] = authSchemaTemplate.dst;
|
|
1318
|
+
} else {
|
|
1319
|
+
nuxt.options.alias["#qarpeo/auth/schema"] = resolver.resolve(
|
|
1320
|
+
"./runtime/server/utils/schema-fallback"
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
if (options.cms) {
|
|
1324
|
+
const cmsSchemaTemplate = addTemplate({
|
|
1325
|
+
filename: "qarpeo/cms-schema.ts",
|
|
1326
|
+
write: true,
|
|
1327
|
+
getContents: () => {
|
|
1328
|
+
const cmsSchemaPath = resolver.resolve("./runtime/server/db/cms-schema").replace(/\\/g, "/");
|
|
1329
|
+
return `export { cmsCollections, cmsEntries, cmsRevisions, ALL_CMS_TABLE_NAMES, getActiveCmsTableNames } from "${cmsSchemaPath}";
|
|
1330
|
+
`;
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
nuxt.options.alias["#qarpeo/cms/schema"] = cmsSchemaTemplate.dst;
|
|
1334
|
+
} else {
|
|
1335
|
+
nuxt.options.alias["#qarpeo/cms/schema"] = resolver.resolve(
|
|
1336
|
+
"./runtime/server/utils/schema-fallback"
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
if (options.payments) {
|
|
1340
|
+
const paymentsSchemaTemplate = addTemplate({
|
|
1341
|
+
filename: "qarpeo/payments-schema.ts",
|
|
1342
|
+
write: true,
|
|
1343
|
+
getContents: () => {
|
|
1344
|
+
return generatePaymentsSchema(options.payments);
|
|
1345
|
+
}
|
|
1346
|
+
});
|
|
1347
|
+
nuxt.options.alias["#qarpeo/payments/schema"] = paymentsSchemaTemplate.dst;
|
|
1348
|
+
} else {
|
|
1349
|
+
nuxt.options.alias["#qarpeo/payments/schema"] = resolver.resolve(
|
|
1350
|
+
"./runtime/server/utils/schema-fallback"
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1353
|
+
if (options.notifications || options.notify) {
|
|
1354
|
+
const notifSchemaTemplate = addTemplate({
|
|
1355
|
+
filename: "qarpeo/notifications-schema.ts",
|
|
1356
|
+
write: true,
|
|
1357
|
+
getContents: () => {
|
|
1358
|
+
return generateNotificationsSchema(options.notifications || options.notify);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
nuxt.options.alias["#qarpeo/notifications/schema"] = notifSchemaTemplate.dst;
|
|
1362
|
+
} else {
|
|
1363
|
+
nuxt.options.alias["#qarpeo/notifications/schema"] = resolver.resolve(
|
|
1364
|
+
"./runtime/server/utils/schema-fallback"
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
if (options.multitenant) {
|
|
1368
|
+
const tenantsSchemaTemplate = addTemplate({
|
|
1369
|
+
filename: "qarpeo/tenants-schema.ts",
|
|
1370
|
+
write: true,
|
|
1371
|
+
getContents: () => {
|
|
1372
|
+
return generateTenantsSchema(options.multitenant);
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
nuxt.options.alias["#qarpeo/tenants/schema"] = tenantsSchemaTemplate.dst;
|
|
1376
|
+
} else {
|
|
1377
|
+
nuxt.options.alias["#qarpeo/tenants/schema"] = resolver.resolve(
|
|
1378
|
+
"./runtime/server/utils/schema-fallback"
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
const getSchemaFiles = () => findSchemaFiles(
|
|
1382
|
+
nuxt.options._layers || [{ cwd: nuxt.options.rootDir, config: nuxt.options }]
|
|
1383
|
+
);
|
|
1384
|
+
const template = addTemplate({
|
|
1385
|
+
filename: "qarpeo/schema.ts",
|
|
1386
|
+
write: true,
|
|
1387
|
+
getContents: () => {
|
|
1388
|
+
const schemaFiles2 = getSchemaFiles();
|
|
1389
|
+
const lines = ["// Auto-generated by qarpeo across all Nuxt layers"];
|
|
1390
|
+
if (options.auth) {
|
|
1391
|
+
lines.push(`export * from "#qarpeo/auth/schema";`);
|
|
1392
|
+
}
|
|
1393
|
+
if (options.cms) {
|
|
1394
|
+
lines.push(`export * from "#qarpeo/cms/schema";`);
|
|
1395
|
+
}
|
|
1396
|
+
if (options.payments) {
|
|
1397
|
+
lines.push(`export * from "#qarpeo/payments/schema";`);
|
|
1398
|
+
}
|
|
1399
|
+
if (options.multitenant) {
|
|
1400
|
+
lines.push(`export * from "#qarpeo/tenants/schema";`);
|
|
1401
|
+
}
|
|
1402
|
+
if (options.notifications || options.notify) {
|
|
1403
|
+
lines.push(`export * from "#qarpeo/notifications/schema";`);
|
|
1404
|
+
}
|
|
1405
|
+
for (const file of schemaFiles2) {
|
|
1406
|
+
const importPath = file.replace(/\\/g, "/").replace(/\.ts$/, "");
|
|
1407
|
+
lines.push(`export * from "${importPath}";`);
|
|
1408
|
+
}
|
|
1409
|
+
if (lines.length === 1) {
|
|
1410
|
+
return [
|
|
1411
|
+
"// Auto-generated by qarpeo (empty fallback)",
|
|
1412
|
+
"export default {};",
|
|
1413
|
+
"export const schema = {};"
|
|
1414
|
+
].join("\n");
|
|
1415
|
+
}
|
|
1416
|
+
return lines.join("\n");
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
schemaTemplateDst = template.dst;
|
|
1420
|
+
nuxt.options.alias["#qarpeo/schema"] = schemaTemplateDst;
|
|
1421
|
+
const typesTemplate = addTemplate({
|
|
1422
|
+
filename: "qarpeo/db-types.ts",
|
|
1423
|
+
write: true,
|
|
1424
|
+
getContents: () => {
|
|
1425
|
+
const schemaFiles2 = getSchemaFiles();
|
|
1426
|
+
const { types } = scanSchemaExports(schemaFiles2);
|
|
1427
|
+
if (types.length === 0) {
|
|
1428
|
+
return "// Auto-generated by qarpeo \u2014 no type exports found in schema files\nexport {};\n";
|
|
1429
|
+
}
|
|
1430
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
1431
|
+
for (const { name, file } of types) {
|
|
1432
|
+
const key = file.replace(/\\/g, "/").replace(/\.ts$/, "");
|
|
1433
|
+
const list = byFile.get(key) ?? [];
|
|
1434
|
+
list.push(name);
|
|
1435
|
+
byFile.set(key, list);
|
|
1436
|
+
}
|
|
1437
|
+
const lines = ["// Auto-generated by qarpeo \u2014 type-only re-exports from schema files"];
|
|
1438
|
+
for (const [importPath, names] of byFile) {
|
|
1439
|
+
lines.push(`export type { ${names.join(", ")} } from "${importPath}";`);
|
|
1440
|
+
}
|
|
1441
|
+
return lines.join("\n") + "\n";
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
nuxt.options.alias["#qarpeo/db/types"] = typesTemplate.dst;
|
|
1445
|
+
nuxt.options.alias["qarpeo/db/types"] = typesTemplate.dst;
|
|
1446
|
+
const zodTemplate = addTemplate({
|
|
1447
|
+
filename: "qarpeo/db-zod.ts",
|
|
1448
|
+
write: true,
|
|
1449
|
+
getContents: () => {
|
|
1450
|
+
const schemaFiles2 = getSchemaFiles();
|
|
1451
|
+
const { zod } = scanSchemaExports(schemaFiles2);
|
|
1452
|
+
if (zod.length === 0) {
|
|
1453
|
+
return "// Auto-generated by qarpeo \u2014 no Zod schema exports found in schema files\nexport {};\n";
|
|
1454
|
+
}
|
|
1455
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
1456
|
+
for (const { name, file } of zod) {
|
|
1457
|
+
const key = file.replace(/\\/g, "/").replace(/\.ts$/, "");
|
|
1458
|
+
const list = byFile.get(key) ?? [];
|
|
1459
|
+
list.push(name);
|
|
1460
|
+
byFile.set(key, list);
|
|
1461
|
+
}
|
|
1462
|
+
const lines = ["// Auto-generated by qarpeo \u2014 Zod schema re-exports from schema files"];
|
|
1463
|
+
for (const [importPath, names] of byFile) {
|
|
1464
|
+
lines.push(`export { ${names.join(", ")} } from "${importPath}";`);
|
|
1465
|
+
}
|
|
1466
|
+
return lines.join("\n") + "\n";
|
|
1467
|
+
}
|
|
1468
|
+
});
|
|
1469
|
+
nuxt.options.alias["#qarpeo/db/zod"] = zodTemplate.dst;
|
|
1470
|
+
const schemaFiles = getSchemaFiles();
|
|
1471
|
+
const { zod: zodExports } = scanSchemaExports(schemaFiles);
|
|
1472
|
+
if (zodExports.length > 0) {
|
|
1473
|
+
const uniqueZod = Array.from(new Set(zodExports.map((z) => z.name)));
|
|
1474
|
+
const zodImports = uniqueZod.map((name) => ({
|
|
1475
|
+
name,
|
|
1476
|
+
from: "#qarpeo/db/zod"
|
|
1477
|
+
}));
|
|
1478
|
+
addImports(zodImports);
|
|
1479
|
+
addServerImports(zodImports);
|
|
1480
|
+
}
|
|
1481
|
+
addTypeTemplate(
|
|
1482
|
+
{
|
|
1483
|
+
filename: "types/qarpeo-db.d.ts",
|
|
1484
|
+
write: true,
|
|
1485
|
+
getContents: () => {
|
|
1486
|
+
const schemaFiles2 = getSchemaFiles();
|
|
1487
|
+
const { types } = scanSchemaExports(schemaFiles2);
|
|
1488
|
+
const uniqueNames = Array.from(new Set(types.map((t) => t.name)));
|
|
1489
|
+
if (uniqueNames.length === 0) {
|
|
1490
|
+
return "// Auto-generated by qarpeo \u2014 no schema types found\nexport {};\n";
|
|
1491
|
+
}
|
|
1492
|
+
return [
|
|
1493
|
+
"// Auto-generated by qarpeo \u2014 ambient global database schema types",
|
|
1494
|
+
'import type * as _DBTypes from "#qarpeo/db/types"',
|
|
1495
|
+
"declare global {",
|
|
1496
|
+
...uniqueNames.map((name) => ` type ${name} = _DBTypes.${name}`),
|
|
1497
|
+
"}",
|
|
1498
|
+
"export {}",
|
|
1499
|
+
""
|
|
1500
|
+
].join("\n");
|
|
1501
|
+
}
|
|
1502
|
+
},
|
|
1503
|
+
{ nuxt: true, nitro: true, shared: true, node: true }
|
|
1504
|
+
);
|
|
1505
|
+
if (nuxt.options.dev) {
|
|
1506
|
+
nuxt.hook("builder:watch", async (_event, path) => {
|
|
1507
|
+
const normalized = path.replace(/\\/g, "/");
|
|
1508
|
+
if (normalized.includes("server/db/schema") || normalized.includes("server/database/schema") || normalized.endsWith("server/schema.ts")) {
|
|
1509
|
+
await updateTemplates({
|
|
1510
|
+
filter: (t) => t.filename.startsWith("qarpeo/") || t.filename === "types/qarpeo-db.d.ts"
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
if (options.db || options.d1) {
|
|
1517
|
+
for (const layer of nuxt.options._layers || []) {
|
|
1518
|
+
const dataDir = resolve(layer.cwd || layer.config?.rootDir || "", "server/db/data");
|
|
1519
|
+
if (existsSync(dataDir)) {
|
|
1520
|
+
addServerImportsDir(dataDir);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/env"));
|
|
1525
|
+
nuxt.hook("nitro:config", async (nitroConfig) => {
|
|
1526
|
+
try {
|
|
1527
|
+
let resolveNitroShikiDep = function(name) {
|
|
1528
|
+
try {
|
|
1529
|
+
const req = createRequire(resolve(shikiDir, "package.json"));
|
|
1530
|
+
const entry = req.resolve(name);
|
|
1531
|
+
let cur = dirname(entry);
|
|
1532
|
+
while (cur && cur !== dirname(cur)) {
|
|
1533
|
+
if (existsSync(resolve(cur, "package.json"))) return cur;
|
|
1534
|
+
cur = dirname(cur);
|
|
1535
|
+
}
|
|
1536
|
+
return "";
|
|
1537
|
+
} catch {
|
|
1538
|
+
return "";
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
nitroConfig.alias = nitroConfig.alias || {};
|
|
1542
|
+
const drizzleDir = resolvePkgDir("drizzle-orm");
|
|
1543
|
+
nitroConfig.alias["drizzle-orm"] = drizzleDir;
|
|
1544
|
+
nitroConfig.alias["drizzle-orm/"] = `${drizzleDir}/`;
|
|
1545
|
+
const drizzleKitDir = resolvePkgDir("drizzle-kit");
|
|
1546
|
+
nitroConfig.alias["drizzle-kit"] = drizzleKitDir;
|
|
1547
|
+
nitroConfig.alias["drizzle-kit/"] = `${drizzleKitDir}/`;
|
|
1548
|
+
const drizzleSeedDir = resolvePkgDir("drizzle-seed");
|
|
1549
|
+
nitroConfig.alias["drizzle-seed"] = drizzleSeedDir;
|
|
1550
|
+
nitroConfig.alias["drizzle-seed/"] = `${drizzleSeedDir}/`;
|
|
1551
|
+
const authUtilsDir = resolvePkgDir("nuxt-auth-utils");
|
|
1552
|
+
nitroConfig.alias["nuxt-auth-utils"] = authUtilsDir;
|
|
1553
|
+
nitroConfig.alias["nuxt-auth-utils/"] = `${authUtilsDir}/`;
|
|
1554
|
+
const wranglerDir = resolvePkgDir("wrangler");
|
|
1555
|
+
nitroConfig.alias["wrangler"] = wranglerDir;
|
|
1556
|
+
nitroConfig.alias["wrangler/"] = `${wranglerDir}/`;
|
|
1557
|
+
const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
|
|
1558
|
+
nitroConfig.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
|
|
1559
|
+
nitroConfig.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
|
|
1560
|
+
nitroConfig.alias["@comark/nuxt/parse"] = resolve(comarkNuxtDir, "dist/parse.js");
|
|
1561
|
+
nitroConfig.alias["@comark/nuxt"] = resolve(comarkNuxtDir, "dist/module.js");
|
|
1562
|
+
const comarkVueDir = resolvePkgDir("@comark/vue");
|
|
1563
|
+
nitroConfig.alias["@comark/vue/vite"] = resolve(comarkVueDir, "dist/vite.js");
|
|
1564
|
+
nitroConfig.alias["@comark/vue/utils"] = resolve(comarkVueDir, "dist/utils/index.js");
|
|
1565
|
+
nitroConfig.alias["@comark/vue/render"] = resolve(comarkVueDir, "dist/render.js");
|
|
1566
|
+
nitroConfig.alias["@comark/vue/parse"] = resolve(comarkVueDir, "dist/parse.js");
|
|
1567
|
+
nitroConfig.alias["@comark/vue"] = resolve(comarkVueDir, "dist/index.js");
|
|
1568
|
+
const comarkDir = resolvePkgDir("comark");
|
|
1569
|
+
nitroConfig.alias["comark/utils"] = resolve(comarkDir, "dist/utils/index.js");
|
|
1570
|
+
nitroConfig.alias["comark/render"] = resolve(comarkDir, "dist/render.js");
|
|
1571
|
+
nitroConfig.alias["comark/parse"] = resolve(comarkDir, "dist/parse.js");
|
|
1572
|
+
nitroConfig.alias["comark/plugins/shiki"] = resolve(comarkDir, "dist/plugins/shiki.js");
|
|
1573
|
+
nitroConfig.alias["comark/plugins/shiki.js"] = resolve(comarkDir, "dist/plugins/shiki.js");
|
|
1574
|
+
nitroConfig.alias["comark/internal"] = resolve(comarkDir, "dist/internal");
|
|
1575
|
+
nitroConfig.alias["comark/internal/"] = `${resolve(comarkDir, "dist/internal")}/`;
|
|
1576
|
+
nitroConfig.alias["comark"] = resolve(comarkDir, "dist/index.js");
|
|
1577
|
+
const shikiDir = resolvePkgDir("shiki");
|
|
1578
|
+
nitroConfig.alias["shiki/engine/javascript"] = resolve(
|
|
1579
|
+
shikiDir,
|
|
1580
|
+
"dist/engine-javascript.mjs"
|
|
1581
|
+
);
|
|
1582
|
+
nitroConfig.alias["shiki/engine/oniguruma"] = resolve(shikiDir, "dist/engine-oniguruma.mjs");
|
|
1583
|
+
nitroConfig.alias["shiki/core"] = resolve(shikiDir, "dist/core.mjs");
|
|
1584
|
+
nitroConfig.alias["shiki/bundle/full"] = resolve(shikiDir, "dist/bundle-full.mjs");
|
|
1585
|
+
nitroConfig.alias["shiki/bundle/web"] = resolve(shikiDir, "dist/bundle-web.mjs");
|
|
1586
|
+
nitroConfig.alias["shiki/langs"] = resolve(shikiDir, "dist/langs.mjs");
|
|
1587
|
+
nitroConfig.alias["shiki/themes"] = resolve(shikiDir, "dist/themes.mjs");
|
|
1588
|
+
nitroConfig.alias["shiki/wasm"] = resolve(shikiDir, "dist/wasm.mjs");
|
|
1589
|
+
nitroConfig.alias["shiki/dist"] = resolve(shikiDir, "dist");
|
|
1590
|
+
nitroConfig.alias["shiki/dist/"] = `${resolve(shikiDir, "dist")}/`;
|
|
1591
|
+
nitroConfig.alias["shiki"] = resolve(shikiDir, "dist/index.mjs");
|
|
1592
|
+
const langsDir = resolveNitroShikiDep("@shikijs/langs");
|
|
1593
|
+
const themesDir = resolveNitroShikiDep("@shikijs/themes");
|
|
1594
|
+
const coreDir = resolveNitroShikiDep("@shikijs/core");
|
|
1595
|
+
const primitiveDir = resolveNitroShikiDep("@shikijs/primitive");
|
|
1596
|
+
const engineJsDir = resolveNitroShikiDep("@shikijs/engine-javascript");
|
|
1597
|
+
const typesDir = resolveNitroShikiDep("@shikijs/types");
|
|
1598
|
+
const textmateDir = resolveNitroShikiDep("@shikijs/vscode-textmate");
|
|
1599
|
+
if (coreDir) {
|
|
1600
|
+
nitroConfig.alias["@shikijs/core"] = resolve(coreDir, "dist/index.mjs");
|
|
1601
|
+
nitroConfig.alias["@shikijs/core/"] = `${resolve(coreDir, "dist")}/`;
|
|
1602
|
+
}
|
|
1603
|
+
if (primitiveDir) {
|
|
1604
|
+
nitroConfig.alias["@shikijs/primitive"] = resolve(primitiveDir, "dist/index.mjs");
|
|
1605
|
+
nitroConfig.alias["@shikijs/primitive/"] = `${resolve(primitiveDir, "dist")}/`;
|
|
1606
|
+
}
|
|
1607
|
+
if (engineJsDir) {
|
|
1608
|
+
nitroConfig.alias["@shikijs/engine-javascript"] = resolve(engineJsDir, "dist/index.mjs");
|
|
1609
|
+
}
|
|
1610
|
+
if (typesDir) {
|
|
1611
|
+
nitroConfig.alias["@shikijs/types"] = resolve(typesDir, "dist/index.mjs");
|
|
1612
|
+
nitroConfig.alias["@shikijs/types/"] = `${resolve(typesDir, "dist")}/`;
|
|
1613
|
+
}
|
|
1614
|
+
if (textmateDir) {
|
|
1615
|
+
nitroConfig.alias["@shikijs/vscode-textmate"] = resolve(textmateDir, "dist/index.js");
|
|
1616
|
+
}
|
|
1617
|
+
if (langsDir) {
|
|
1618
|
+
nitroConfig.alias["@shikijs/langs"] = resolve(langsDir, "dist/index.mjs");
|
|
1619
|
+
nitroConfig.alias["@shikijs/langs/"] = `${resolve(langsDir, "dist")}/`;
|
|
1620
|
+
try {
|
|
1621
|
+
const files = readdirSync(resolve(langsDir, "dist")).filter((f) => f.endsWith(".mjs"));
|
|
1622
|
+
for (const f of files) {
|
|
1623
|
+
const name = f.replace(/\.mjs$/, "");
|
|
1624
|
+
nitroConfig.alias[`@shikijs/langs/${name}`] = resolve(langsDir, "dist", f);
|
|
1625
|
+
}
|
|
1626
|
+
} catch {
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
if (themesDir) {
|
|
1630
|
+
nitroConfig.alias["@shikijs/themes"] = resolve(themesDir, "dist/index.mjs");
|
|
1631
|
+
nitroConfig.alias["@shikijs/themes/"] = `${resolve(themesDir, "dist")}/`;
|
|
1632
|
+
try {
|
|
1633
|
+
const files = readdirSync(resolve(themesDir, "dist")).filter((f) => f.endsWith(".mjs"));
|
|
1634
|
+
for (const f of files) {
|
|
1635
|
+
const name = f.replace(/\.mjs$/, "");
|
|
1636
|
+
nitroConfig.alias[`@shikijs/themes/${name}`] = resolve(themesDir, "dist", f);
|
|
1637
|
+
}
|
|
1638
|
+
} catch {
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
} catch {
|
|
1642
|
+
}
|
|
1643
|
+
if (!nuxt.options.dev) {
|
|
1644
|
+
if (!nitroConfig.preset || nitroConfig.preset === "node-server") {
|
|
1645
|
+
nitroConfig.preset = "cloudflare-module";
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
if (options.cron) {
|
|
1649
|
+
nitroConfig.experimental = nitroConfig.experimental || {};
|
|
1650
|
+
nitroConfig.experimental.tasks = true;
|
|
1651
|
+
if (typeof options.cron === "object") {
|
|
1652
|
+
nitroConfig.scheduledTasks = nitroConfig.scheduledTasks || {};
|
|
1653
|
+
for (const [schedule, tasks] of Object.entries(
|
|
1654
|
+
options.cron
|
|
1655
|
+
)) {
|
|
1656
|
+
nitroConfig.scheduledTasks[schedule] = [
|
|
1657
|
+
...nitroConfig.scheduledTasks[schedule] || [],
|
|
1658
|
+
...tasks
|
|
1659
|
+
];
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
const cmsScheduled = typeof options.cms === "object" && options.cms?.scheduledPublish;
|
|
1663
|
+
if (cmsScheduled) {
|
|
1664
|
+
nitroConfig.scheduledTasks = nitroConfig.scheduledTasks || {};
|
|
1665
|
+
nitroConfig.scheduledTasks["*/5 * * * *"] = [
|
|
1666
|
+
...nitroConfig.scheduledTasks["*/5 * * * *"] || [],
|
|
1667
|
+
"cms:publish"
|
|
1668
|
+
];
|
|
1669
|
+
nitroConfig.tasks = nitroConfig.tasks || {};
|
|
1670
|
+
nitroConfig.tasks["cms:publish"] = {
|
|
1671
|
+
handler: resolver.resolve("./runtime/server/tasks/cms/publish"),
|
|
1672
|
+
description: "Publish due scheduled CMS entries"
|
|
1673
|
+
};
|
|
1674
|
+
nitroConfig.cloudflare = nitroConfig.cloudflare || {};
|
|
1675
|
+
nitroConfig.cloudflare.wrangler = nitroConfig.cloudflare.wrangler || {};
|
|
1676
|
+
nitroConfig.cloudflare.wrangler.triggers = nitroConfig.cloudflare.wrangler.triggers || {};
|
|
1677
|
+
const existingCrons = nitroConfig.cloudflare.wrangler.triggers.crons || [];
|
|
1678
|
+
if (!existingCrons.includes("*/5 * * * *")) {
|
|
1679
|
+
nitroConfig.cloudflare.wrangler.triggers.crons = [...existingCrons, "*/5 * * * *"];
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
const projectName = resolveProjectName(nuxt, options);
|
|
1684
|
+
nitroConfig.cloudflare = defu(nitroConfig.cloudflare || {}, {
|
|
1685
|
+
deployConfig: true,
|
|
1686
|
+
nodeCompat: true,
|
|
1687
|
+
wrangler: {
|
|
1688
|
+
name: projectName,
|
|
1689
|
+
observability: { enabled: true }
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
nitroConfig.cloudflare.wrangler = nitroConfig.cloudflare.wrangler || {};
|
|
1693
|
+
nitroConfig.externals = nitroConfig.externals || {};
|
|
1694
|
+
nitroConfig.externals.external = nitroConfig.externals.external || [];
|
|
1695
|
+
if (!nitroConfig.externals.external.includes("wrangler")) {
|
|
1696
|
+
nitroConfig.externals.external.push("wrangler");
|
|
1697
|
+
}
|
|
1698
|
+
nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};
|
|
1699
|
+
if (Array.isArray(nitroConfig.rollupConfig.external)) {
|
|
1700
|
+
if (!nitroConfig.rollupConfig.external.includes("wrangler")) {
|
|
1701
|
+
nitroConfig.rollupConfig.external.push("wrangler");
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
if (options.kv) {
|
|
1705
|
+
const kvBinding = resolveBindingName("kv");
|
|
1706
|
+
nitroConfig.cloudflare.wrangler.kv_namespaces = nitroConfig.cloudflare.wrangler.kv_namespaces || [];
|
|
1707
|
+
if (!nitroConfig.cloudflare.wrangler.kv_namespaces.some((ns) => ns.binding === kvBinding)) {
|
|
1708
|
+
nitroConfig.cloudflare.wrangler.kv_namespaces.push({
|
|
1709
|
+
binding: kvBinding,
|
|
1710
|
+
id: `${kvBinding}_LOCAL_DEV`
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
if (options.blob || options.r2) {
|
|
1715
|
+
const blobBinding = resolveBindingName("blob");
|
|
1716
|
+
const bucketName = `${blobBinding.toLowerCase().replace(/[^a-z0-9-]/g, "-")}-prod`;
|
|
1717
|
+
nitroConfig.cloudflare.wrangler.r2_buckets = nitroConfig.cloudflare.wrangler.r2_buckets || [];
|
|
1718
|
+
if (!nitroConfig.cloudflare.wrangler.r2_buckets.some((b) => b.binding === blobBinding)) {
|
|
1719
|
+
nitroConfig.cloudflare.wrangler.r2_buckets.push({
|
|
1720
|
+
binding: blobBinding,
|
|
1721
|
+
bucket_name: bucketName
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
if (options.db || options.d1) {
|
|
1726
|
+
const dbBinding = resolveBindingName("db", void 0);
|
|
1727
|
+
nitroConfig.cloudflare.wrangler.d1_databases = nitroConfig.cloudflare.wrangler.d1_databases || [];
|
|
1728
|
+
if (!nitroConfig.cloudflare.wrangler.d1_databases.some((d) => d.binding === dbBinding)) {
|
|
1729
|
+
nitroConfig.cloudflare.wrangler.d1_databases.push({
|
|
1730
|
+
binding: dbBinding,
|
|
1731
|
+
database_name: `${dbBinding}_PROD`,
|
|
1732
|
+
database_id: `${dbBinding}_PROD`
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
if (isDrizzle && schemaTemplateDst) {
|
|
1736
|
+
nitroConfig.alias = nitroConfig.alias || {};
|
|
1737
|
+
nitroConfig.alias["#qarpeo/schema"] = schemaTemplateDst;
|
|
1738
|
+
const typesAlias = nuxt.options.alias["#qarpeo/db/types"];
|
|
1739
|
+
const zodAlias = nuxt.options.alias["#qarpeo/db/zod"];
|
|
1740
|
+
if (typesAlias) {
|
|
1741
|
+
nitroConfig.alias["#qarpeo/db/types"] = typesAlias;
|
|
1742
|
+
nitroConfig.alias["qarpeo/db/types"] = typesAlias;
|
|
1743
|
+
}
|
|
1744
|
+
if (zodAlias) {
|
|
1745
|
+
nitroConfig.alias["#qarpeo/db/zod"] = zodAlias;
|
|
1746
|
+
nitroConfig.alias["qarpeo/db/zod"] = zodAlias;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
if (options.queue) {
|
|
1750
|
+
const queueConsumer = nuxt.options.alias["#qarpeo/queue-consumer"];
|
|
1751
|
+
if (queueConsumer) {
|
|
1752
|
+
nitroConfig.alias = nitroConfig.alias || {};
|
|
1753
|
+
nitroConfig.alias["#qarpeo/queue-consumer"] = queueConsumer;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
if (hasNuxtModule("@nuxt/content")) {
|
|
1757
|
+
nitroConfig.runtimeConfig = nitroConfig.runtimeConfig || {};
|
|
1758
|
+
nitroConfig.runtimeConfig.content = nitroConfig.runtimeConfig.content || {};
|
|
1759
|
+
nitroConfig.runtimeConfig.content.database = nitroConfig.runtimeConfig.content.database || { type: "d1", bindingName: dbBinding };
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
if (options.cache) {
|
|
1763
|
+
const cacheConfig = typeof options.cache === "object" ? options.cache : {};
|
|
1764
|
+
const cacheBinding = cacheConfig.binding || resolveBindingName("cache");
|
|
1765
|
+
const cacheBase = cacheConfig.base || "nitro:cache:";
|
|
1766
|
+
nitroConfig.cloudflare.wrangler.kv_namespaces = nitroConfig.cloudflare.wrangler.kv_namespaces || [];
|
|
1767
|
+
if (!nitroConfig.cloudflare.wrangler.kv_namespaces.some(
|
|
1768
|
+
(ns) => ns.binding === cacheBinding
|
|
1769
|
+
)) {
|
|
1770
|
+
nitroConfig.cloudflare.wrangler.kv_namespaces.push({
|
|
1771
|
+
binding: cacheBinding,
|
|
1772
|
+
id: `${cacheBinding}_PROD`
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
const cacheStorageConfig = {
|
|
1776
|
+
driver: nuxt.options.dev ? "fs-lite" : "cloudflare-kv-binding",
|
|
1777
|
+
...nuxt.options.dev ? { base: "./.data/cache" } : { binding: cacheBinding, base: cacheBase }
|
|
1778
|
+
};
|
|
1779
|
+
if ("kv" in nitroConfig || !nitroConfig.storage) {
|
|
1780
|
+
nitroConfig.kv = nitroConfig.kv || {};
|
|
1781
|
+
nitroConfig.kv.cache = cacheStorageConfig;
|
|
1782
|
+
} else {
|
|
1783
|
+
nitroConfig.storage = nitroConfig.storage || {};
|
|
1784
|
+
nitroConfig.storage.cache = cacheStorageConfig;
|
|
1785
|
+
}
|
|
1786
|
+
if (cacheConfig.swr !== false) {
|
|
1787
|
+
const rules = nuxt.options.routeRules = nuxt.options.routeRules || {};
|
|
1788
|
+
for (const [, rule] of Object.entries(rules)) {
|
|
1789
|
+
if (rule?.cache && rule.swr === void 0) {
|
|
1790
|
+
rule.swr = true;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
nitroConfig.runtimeConfig = nitroConfig.runtimeConfig || {};
|
|
1794
|
+
nitroConfig.runtimeConfig.nitro = nitroConfig.runtimeConfig.nitro || {};
|
|
1795
|
+
nitroConfig.runtimeConfig.nitro.defaultCacheOptions = {
|
|
1796
|
+
...nitroConfig.runtimeConfig.nitro.defaultCacheOptions || {},
|
|
1797
|
+
swr: true
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
if (options.ai) {
|
|
1802
|
+
const aiBinding = resolveBindingName("ai");
|
|
1803
|
+
nitroConfig.cloudflare.wrangler.ai = {
|
|
1804
|
+
binding: aiBinding
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
if (options.vectorize) {
|
|
1808
|
+
const vectorizeBinding = resolveBindingName("vectorize");
|
|
1809
|
+
const indexName = `${vectorizeBinding.toLowerCase().replace(/[^a-z0-9-]/g, "-")}-prod`;
|
|
1810
|
+
nitroConfig.cloudflare.wrangler.vectorize = [
|
|
1811
|
+
{
|
|
1812
|
+
binding: vectorizeBinding,
|
|
1813
|
+
index_name: indexName
|
|
1814
|
+
}
|
|
1815
|
+
];
|
|
1816
|
+
}
|
|
1817
|
+
if (options.queue) {
|
|
1818
|
+
const queueBinding = resolveBindingName("queue");
|
|
1819
|
+
const queueName = process.env.QARPEO_QUEUE_NAME || `${queueBinding.toLowerCase().replace(/[^a-z0-9-]/g, "-")}-prod`;
|
|
1820
|
+
nitroConfig.cloudflare.wrangler.queues = nitroConfig.cloudflare.wrangler.queues || {};
|
|
1821
|
+
nitroConfig.cloudflare.wrangler.queues.producers = [
|
|
1822
|
+
{
|
|
1823
|
+
binding: queueBinding,
|
|
1824
|
+
queue: queueName
|
|
1825
|
+
}
|
|
1826
|
+
];
|
|
1827
|
+
const queueFiles = findQueueFiles(
|
|
1828
|
+
nuxt.options._layers || [{ cwd: nuxt.options.rootDir, config: nuxt.options }]
|
|
1829
|
+
);
|
|
1830
|
+
const jobFiles = options.jobs ? findJobFiles(
|
|
1831
|
+
nuxt.options._layers || [{ cwd: nuxt.options.rootDir, config: nuxt.options }],
|
|
1832
|
+
typeof options.jobs === "object" && options.jobs.dir ? options.jobs.dir : "server/jobs"
|
|
1833
|
+
) : [];
|
|
1834
|
+
const hasMailQueue = !!(options.mail && typeof options.mail === "object" && options.mail.queue);
|
|
1835
|
+
if (queueFiles.length > 0 || jobFiles.length > 0 || hasMailQueue) {
|
|
1836
|
+
const jobsConfig = typeof options.jobs === "object" ? options.jobs : {};
|
|
1837
|
+
nitroConfig.cloudflare.wrangler.queues.consumers = [
|
|
1838
|
+
{
|
|
1839
|
+
queue: queueName,
|
|
1840
|
+
max_batch_size: jobsConfig.maxBatchSize ?? 10,
|
|
1841
|
+
max_batch_timeout: jobsConfig.maxBatchTimeout ?? 30
|
|
1842
|
+
}
|
|
1843
|
+
];
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
if (options.analytics) {
|
|
1847
|
+
const analyticsOpts = typeof options.analytics === "object" ? options.analytics : void 0;
|
|
1848
|
+
const analyticsBinding = resolveBindingName("analytics", analyticsOpts?.binding);
|
|
1849
|
+
const datasetName = analyticsOpts?.dataset || process.env.QARPEO_ANALYTICS_DATASET || `${analyticsBinding.toLowerCase().replace(/[^a-z0-9-]/g, "-")}-prod`;
|
|
1850
|
+
nitroConfig.cloudflare.wrangler.analytics_engine_datasets = [
|
|
1851
|
+
{
|
|
1852
|
+
binding: analyticsBinding,
|
|
1853
|
+
dataset: datasetName
|
|
1854
|
+
}
|
|
1855
|
+
];
|
|
1856
|
+
}
|
|
1857
|
+
if (options.ratelimit) {
|
|
1858
|
+
const rateLimitBinding = resolveBindingName("ratelimit", void 0, "RATE_LIMITER");
|
|
1859
|
+
const limit = typeof options.ratelimit === "object" ? options.ratelimit.limit ?? 100 : 100;
|
|
1860
|
+
const period = typeof options.ratelimit === "object" ? options.ratelimit.period ?? 60 : 60;
|
|
1861
|
+
const namespaceId = typeof options.ratelimit === "object" ? options.ratelimit.namespaceId ?? 1001 : 1001;
|
|
1862
|
+
nitroConfig.cloudflare.wrangler.ratelimits = [
|
|
1863
|
+
{
|
|
1864
|
+
name: rateLimitBinding,
|
|
1865
|
+
namespace_id: String(namespaceId),
|
|
1866
|
+
simple: {
|
|
1867
|
+
limit,
|
|
1868
|
+
period
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
];
|
|
1872
|
+
}
|
|
1873
|
+
if (options.hyperdrive) {
|
|
1874
|
+
const binding = resolveBindingName("hyperdrive");
|
|
1875
|
+
const id = process.env.QARPEO_HYPERDRIVE_ID || `${binding}_PROD`;
|
|
1876
|
+
nitroConfig.cloudflare.wrangler.hyperdrive = [
|
|
1877
|
+
{
|
|
1878
|
+
binding,
|
|
1879
|
+
id
|
|
1880
|
+
}
|
|
1881
|
+
];
|
|
1882
|
+
}
|
|
1883
|
+
if (options.browser) {
|
|
1884
|
+
const binding = resolveBindingName("browser");
|
|
1885
|
+
nitroConfig.cloudflare.wrangler.browser = {
|
|
1886
|
+
binding
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
if (options.email) {
|
|
1890
|
+
const emailBinding = resolveBindingName(
|
|
1891
|
+
"email",
|
|
1892
|
+
typeof options.email === "object" ? options.email.binding : void 0,
|
|
1893
|
+
"EMAIL"
|
|
1894
|
+
);
|
|
1895
|
+
nitroConfig.cloudflare.wrangler.send_email = nitroConfig.cloudflare.wrangler.send_email || [];
|
|
1896
|
+
if (!nitroConfig.cloudflare.wrangler.send_email.some((e) => e.name === emailBinding)) {
|
|
1897
|
+
nitroConfig.cloudflare.wrangler.send_email.push({ name: emailBinding });
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
if (options.do || options.realtime || options.agents) {
|
|
1901
|
+
nitroConfig.cloudflare.wrangler.durable_objects = nitroConfig.cloudflare.wrangler.durable_objects || {};
|
|
1902
|
+
nitroConfig.cloudflare.wrangler.durable_objects.bindings = nitroConfig.cloudflare.wrangler.durable_objects.bindings || [];
|
|
1903
|
+
nitroConfig.cloudflare.wrangler.migrations = nitroConfig.cloudflare.wrangler.migrations || [];
|
|
1904
|
+
if (options.realtime || !options.agents && options.do) {
|
|
1905
|
+
const doBinding = resolveBindingName(
|
|
1906
|
+
"do",
|
|
1907
|
+
typeof options.realtime === "object" ? options.realtime.binding : void 0,
|
|
1908
|
+
"QARPEO_ROOM_DO"
|
|
1909
|
+
);
|
|
1910
|
+
if (!nitroConfig.cloudflare.wrangler.durable_objects.bindings.some(
|
|
1911
|
+
(b) => b.name === doBinding
|
|
1912
|
+
)) {
|
|
1913
|
+
nitroConfig.cloudflare.wrangler.durable_objects.bindings.push({
|
|
1914
|
+
name: doBinding,
|
|
1915
|
+
class_name: "QarpeoRoomDO"
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
if (!nitroConfig.cloudflare.wrangler.migrations.some(
|
|
1919
|
+
(m) => m.tag === "v1-realtime-room"
|
|
1920
|
+
)) {
|
|
1921
|
+
nitroConfig.cloudflare.wrangler.migrations.push({
|
|
1922
|
+
tag: "v1-realtime-room",
|
|
1923
|
+
new_classes: ["QarpeoRoomDO"]
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
if (options.agents) {
|
|
1928
|
+
const agentsConfig = typeof options.agents === "object" ? options.agents : {};
|
|
1929
|
+
const agentBinding = agentsConfig.binding || "QARPEO_AGENT_DO";
|
|
1930
|
+
if (!nitroConfig.cloudflare.wrangler.durable_objects.bindings.some(
|
|
1931
|
+
(b) => b.name === agentBinding
|
|
1932
|
+
)) {
|
|
1933
|
+
nitroConfig.cloudflare.wrangler.durable_objects.bindings.push({
|
|
1934
|
+
name: agentBinding,
|
|
1935
|
+
class_name: "QarpeoAgentDO"
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
if (!nitroConfig.cloudflare.wrangler.migrations.some((m) => m.tag === "v1-agent-do")) {
|
|
1939
|
+
nitroConfig.cloudflare.wrangler.migrations.push({
|
|
1940
|
+
tag: "v1-agent-do",
|
|
1941
|
+
new_sqlite_classes: ["QarpeoAgentDO"]
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
const configPath2 = await generateDevWranglerConfig(nuxt, options);
|
|
1947
|
+
nitroConfig.cloudflare.dev = nitroConfig.cloudflare.dev || {};
|
|
1948
|
+
nitroConfig.cloudflare.dev.configPath = configPath2;
|
|
1949
|
+
});
|
|
1950
|
+
if (nuxt.options.dev && isDrizzle) {
|
|
1951
|
+
const dbOption = typeof options.db === "object" ? options.db : {};
|
|
1952
|
+
const shouldAutoMigrate = dbOption.autoMigrate !== false;
|
|
1953
|
+
if (shouldAutoMigrate) {
|
|
1954
|
+
nuxt.hook("ready", () => {
|
|
1955
|
+
const serverDir = nuxt.options.serverDir || resolve(nuxt.options.rootDir, "server");
|
|
1956
|
+
const configPath2 = resolve(nuxt.options.buildDir, "wrangler.json");
|
|
1957
|
+
applyD1Migrations(nuxt.options.rootDir, {
|
|
1958
|
+
wranglerConfigPath: configPath2,
|
|
1959
|
+
serverDir,
|
|
1960
|
+
remote: false,
|
|
1961
|
+
label: "Dev auto-check"
|
|
1962
|
+
});
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
if (!nuxt.options.dev && isDrizzle) {
|
|
1967
|
+
const dbOption = typeof options.db === "object" ? options.db : {};
|
|
1968
|
+
const migrateOnBuild = dbOption.migrateOnBuild;
|
|
1969
|
+
const envFlag = process.env.QARPEO_MIGRATE_ON_BUILD;
|
|
1970
|
+
if (migrateOnBuild || envFlag) {
|
|
1971
|
+
let isRemote = false;
|
|
1972
|
+
if (migrateOnBuild === "remote" || envFlag === "remote") {
|
|
1973
|
+
isRemote = true;
|
|
1974
|
+
} else if (migrateOnBuild === "local" || envFlag === "local") {
|
|
1975
|
+
isRemote = false;
|
|
1976
|
+
} else {
|
|
1977
|
+
isRemote = Boolean(
|
|
1978
|
+
process.env.CI || process.env.CF_PAGES || process.env.CLOUDFLARE_API_TOKEN || process.env.CLOUDFLARE_ACCOUNT_ID || options.remote
|
|
1979
|
+
);
|
|
1980
|
+
}
|
|
1981
|
+
nuxt.hook("nitro:build:before", async () => {
|
|
1982
|
+
const serverDir = nuxt.options.serverDir || resolve(nuxt.options.rootDir, "server");
|
|
1983
|
+
const configPath2 = resolve(nuxt.options.buildDir, "wrangler.json");
|
|
1984
|
+
const ok = applyD1Migrations(nuxt.options.rootDir, {
|
|
1985
|
+
wranglerConfigPath: configPath2,
|
|
1986
|
+
serverDir,
|
|
1987
|
+
remote: isRemote,
|
|
1988
|
+
label: "Build migration"
|
|
1989
|
+
});
|
|
1990
|
+
if (!ok && isRemote) {
|
|
1991
|
+
throw new Error("[qarpeo] Remote D1 database migration failed during build.");
|
|
1992
|
+
}
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
addServerImports([
|
|
1997
|
+
{ name: "getQarpeoConfig", from: resolver.resolve("./runtime/server/utils/config") },
|
|
1998
|
+
{ name: "useQarpeoConfig", from: resolver.resolve("./runtime/server/utils/config") },
|
|
1999
|
+
{ name: "defineBotHandler", from: resolver.resolve("./runtime/server/utils/bots") },
|
|
2000
|
+
{ name: "verifyWebhookSignature", from: resolver.resolve("./runtime/server/utils/bots") },
|
|
2001
|
+
{ name: "createRAGPipeline", from: resolver.resolve("./runtime/server/utils/rag") },
|
|
2002
|
+
{ name: "splitTextIntoChunks", from: resolver.resolve("./runtime/server/utils/rag") }
|
|
2003
|
+
]);
|
|
2004
|
+
if (options.kv) {
|
|
2005
|
+
addServerImports([
|
|
2006
|
+
{
|
|
2007
|
+
name: "kv",
|
|
2008
|
+
from: "qarpeo/runtime"
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
name: "useKV",
|
|
2012
|
+
from: "qarpeo/runtime"
|
|
2013
|
+
},
|
|
2014
|
+
{
|
|
2015
|
+
name: "createKV",
|
|
2016
|
+
from: "qarpeo/runtime"
|
|
2017
|
+
},
|
|
2018
|
+
{
|
|
2019
|
+
name: "getKVBinding",
|
|
2020
|
+
from: "qarpeo/runtime"
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
name: "getKVStorage",
|
|
2024
|
+
from: "qarpeo/runtime"
|
|
2025
|
+
}
|
|
2026
|
+
]);
|
|
2027
|
+
}
|
|
2028
|
+
if (options.blob || options.r2) {
|
|
2029
|
+
addServerImports([
|
|
2030
|
+
{
|
|
2031
|
+
name: "blob",
|
|
2032
|
+
from: "qarpeo/runtime"
|
|
2033
|
+
},
|
|
2034
|
+
{
|
|
2035
|
+
name: "useBlob",
|
|
2036
|
+
from: "qarpeo/runtime"
|
|
2037
|
+
},
|
|
2038
|
+
{
|
|
2039
|
+
name: "createBlob",
|
|
2040
|
+
from: "qarpeo/runtime"
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
name: "getR2Binding",
|
|
2044
|
+
from: "qarpeo/runtime"
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
name: "ensureBlob",
|
|
2048
|
+
from: "qarpeo/runtime"
|
|
2049
|
+
}
|
|
2050
|
+
]);
|
|
2051
|
+
}
|
|
2052
|
+
if (options.db || options.d1) {
|
|
2053
|
+
if (isDrizzle) {
|
|
2054
|
+
addServerImports([
|
|
2055
|
+
{
|
|
2056
|
+
name: "db",
|
|
2057
|
+
from: resolver.resolve("./runtime/server/utils/drizzle")
|
|
2058
|
+
},
|
|
2059
|
+
{
|
|
2060
|
+
name: "d1",
|
|
2061
|
+
from: "qarpeo/runtime"
|
|
2062
|
+
},
|
|
2063
|
+
{
|
|
2064
|
+
name: "useDrizzle",
|
|
2065
|
+
from: resolver.resolve("./runtime/server/utils/drizzle")
|
|
2066
|
+
},
|
|
2067
|
+
{
|
|
2068
|
+
name: "schema",
|
|
2069
|
+
from: resolver.resolve("./runtime/server/utils/drizzle")
|
|
2070
|
+
},
|
|
2071
|
+
{
|
|
2072
|
+
name: "useDB",
|
|
2073
|
+
from: "qarpeo/runtime"
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
name: "useD1",
|
|
2077
|
+
from: "qarpeo/runtime"
|
|
2078
|
+
},
|
|
2079
|
+
{
|
|
2080
|
+
name: "getD1Binding",
|
|
2081
|
+
from: "qarpeo/runtime"
|
|
2082
|
+
},
|
|
2083
|
+
...[
|
|
2084
|
+
"sql",
|
|
2085
|
+
"eq",
|
|
2086
|
+
"ne",
|
|
2087
|
+
"gt",
|
|
2088
|
+
"gte",
|
|
2089
|
+
"lt",
|
|
2090
|
+
"lte",
|
|
2091
|
+
"and",
|
|
2092
|
+
"or",
|
|
2093
|
+
"not",
|
|
2094
|
+
"desc",
|
|
2095
|
+
"asc",
|
|
2096
|
+
"like",
|
|
2097
|
+
"notLike",
|
|
2098
|
+
"ilike",
|
|
2099
|
+
"notIlike",
|
|
2100
|
+
"inArray",
|
|
2101
|
+
"notInArray",
|
|
2102
|
+
"isNull",
|
|
2103
|
+
"isNotNull",
|
|
2104
|
+
"between",
|
|
2105
|
+
"notBetween",
|
|
2106
|
+
"count",
|
|
2107
|
+
"countDistinct",
|
|
2108
|
+
"avg",
|
|
2109
|
+
"max",
|
|
2110
|
+
"min",
|
|
2111
|
+
"sum",
|
|
2112
|
+
"defineRelations"
|
|
2113
|
+
].map((name) => ({ name, from: "drizzle-orm" }))
|
|
2114
|
+
]);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
if (options.cache) {
|
|
2118
|
+
addServerImports([
|
|
2119
|
+
{
|
|
2120
|
+
name: "useCacheStorage",
|
|
2121
|
+
from: resolver.resolve("./runtime/server/utils/cache")
|
|
2122
|
+
},
|
|
2123
|
+
{
|
|
2124
|
+
name: "purgeCache",
|
|
2125
|
+
from: resolver.resolve("./runtime/server/utils/cache")
|
|
2126
|
+
},
|
|
2127
|
+
{
|
|
2128
|
+
name: "rememberCache",
|
|
2129
|
+
from: resolver.resolve("./runtime/server/utils/cache")
|
|
2130
|
+
},
|
|
2131
|
+
{
|
|
2132
|
+
name: "getCacheItem",
|
|
2133
|
+
from: resolver.resolve("./runtime/server/utils/cache")
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
name: "setCacheItem",
|
|
2137
|
+
from: resolver.resolve("./runtime/server/utils/cache")
|
|
2138
|
+
},
|
|
2139
|
+
{
|
|
2140
|
+
name: "removeCacheItem",
|
|
2141
|
+
from: resolver.resolve("./runtime/server/utils/cache")
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
name: "hasCacheItem",
|
|
2145
|
+
from: resolver.resolve("./runtime/server/utils/cache")
|
|
2146
|
+
},
|
|
2147
|
+
{
|
|
2148
|
+
name: "useEdgeCache",
|
|
2149
|
+
from: "qarpeo/runtime"
|
|
2150
|
+
}
|
|
2151
|
+
]);
|
|
2152
|
+
}
|
|
2153
|
+
if (options.ai) {
|
|
2154
|
+
addServerImports([
|
|
2155
|
+
{
|
|
2156
|
+
name: "ai",
|
|
2157
|
+
from: "qarpeo/runtime"
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
name: "useAI",
|
|
2161
|
+
from: "qarpeo/runtime"
|
|
2162
|
+
},
|
|
2163
|
+
{
|
|
2164
|
+
name: "getAIBinding",
|
|
2165
|
+
from: "qarpeo/runtime"
|
|
2166
|
+
}
|
|
2167
|
+
]);
|
|
2168
|
+
if (!options.agents) {
|
|
2169
|
+
addServerImports([
|
|
2170
|
+
{ name: "generateImage", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2171
|
+
{ name: "textToImage", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2172
|
+
{ name: "generateSpeech", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2173
|
+
{ name: "textToSpeech", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2174
|
+
{ name: "transcribeAudio", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2175
|
+
{ name: "speechToText", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2176
|
+
{ name: "generateText", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2177
|
+
{ name: "streamText", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
2178
|
+
{ name: "embedText", from: resolver.resolve("./runtime/server/utils/ai") }
|
|
2179
|
+
]);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
if (options.vectorize) {
|
|
2183
|
+
addServerImports([
|
|
2184
|
+
{
|
|
2185
|
+
name: "vectorize",
|
|
2186
|
+
from: "qarpeo/runtime"
|
|
2187
|
+
},
|
|
2188
|
+
{
|
|
2189
|
+
name: "useVectorize",
|
|
2190
|
+
from: "qarpeo/runtime"
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
name: "getVectorizeBinding",
|
|
2194
|
+
from: "qarpeo/runtime"
|
|
2195
|
+
}
|
|
2196
|
+
]);
|
|
2197
|
+
}
|
|
2198
|
+
if (options.queue || options.jobs) {
|
|
2199
|
+
addServerImports([
|
|
2200
|
+
{
|
|
2201
|
+
name: "queue",
|
|
2202
|
+
from: "qarpeo/runtime"
|
|
2203
|
+
},
|
|
2204
|
+
{
|
|
2205
|
+
name: "useQueue",
|
|
2206
|
+
from: "qarpeo/runtime"
|
|
2207
|
+
},
|
|
2208
|
+
{
|
|
2209
|
+
name: "getQueueBinding",
|
|
2210
|
+
from: "qarpeo/runtime"
|
|
2211
|
+
},
|
|
2212
|
+
{
|
|
2213
|
+
name: "defineQueueHandler",
|
|
2214
|
+
from: resolver.resolve("./runtime/server/utils/queue")
|
|
2215
|
+
},
|
|
2216
|
+
{
|
|
2217
|
+
name: "defineJob",
|
|
2218
|
+
from: resolver.resolve("./runtime/server/utils/jobs")
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
name: "dispatchJob",
|
|
2222
|
+
from: resolver.resolve("./runtime/server/utils/jobs")
|
|
2223
|
+
}
|
|
2224
|
+
]);
|
|
2225
|
+
}
|
|
2226
|
+
if (options.analytics) {
|
|
2227
|
+
addServerImports([
|
|
2228
|
+
{
|
|
2229
|
+
name: "analytics",
|
|
2230
|
+
from: "qarpeo/runtime"
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
name: "useAnalytics",
|
|
2234
|
+
from: "qarpeo/runtime"
|
|
2235
|
+
},
|
|
2236
|
+
{
|
|
2237
|
+
name: "getAnalyticsBinding",
|
|
2238
|
+
from: "qarpeo/runtime"
|
|
2239
|
+
}
|
|
2240
|
+
]);
|
|
2241
|
+
}
|
|
2242
|
+
if (options.ratelimit) {
|
|
2243
|
+
addServerImports([
|
|
2244
|
+
{
|
|
2245
|
+
name: "rateLimit",
|
|
2246
|
+
from: "qarpeo/runtime"
|
|
2247
|
+
},
|
|
2248
|
+
{
|
|
2249
|
+
name: "useRateLimit",
|
|
2250
|
+
from: "qarpeo/runtime"
|
|
2251
|
+
},
|
|
2252
|
+
{
|
|
2253
|
+
name: "getRateLimitBinding",
|
|
2254
|
+
from: "qarpeo/runtime"
|
|
2255
|
+
}
|
|
2256
|
+
]);
|
|
2257
|
+
}
|
|
2258
|
+
if (options.ratelimit) {
|
|
2259
|
+
addServerImports([
|
|
2260
|
+
{
|
|
2261
|
+
name: "checkRateLimit",
|
|
2262
|
+
from: resolver.resolve("./runtime/server/utils/ratelimit")
|
|
2263
|
+
},
|
|
2264
|
+
{
|
|
2265
|
+
name: "assertRateLimit",
|
|
2266
|
+
from: resolver.resolve("./runtime/server/utils/ratelimit")
|
|
2267
|
+
},
|
|
2268
|
+
{
|
|
2269
|
+
name: "getClientIp",
|
|
2270
|
+
from: resolver.resolve("./runtime/server/utils/ratelimit")
|
|
2271
|
+
}
|
|
2272
|
+
]);
|
|
2273
|
+
const ratelimitConfig = typeof options.ratelimit === "object" ? options.ratelimit : {};
|
|
2274
|
+
const appRuntimeConfig = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
2275
|
+
appRuntimeConfig.qarpeo = appRuntimeConfig.qarpeo || {};
|
|
2276
|
+
appRuntimeConfig.qarpeo.ratelimit = {
|
|
2277
|
+
enabled: true,
|
|
2278
|
+
max: ratelimitConfig.max ?? 100,
|
|
2279
|
+
window: ratelimitConfig.window ?? "1m",
|
|
2280
|
+
ipWhitelist: ratelimitConfig.ipWhitelist ?? [],
|
|
2281
|
+
rules: ratelimitConfig.rules ?? {},
|
|
2282
|
+
backend: ratelimitConfig.backend ?? "auto",
|
|
2283
|
+
global: !ratelimitConfig.rules || Object.keys(ratelimitConfig.rules).length === 0
|
|
2284
|
+
};
|
|
2285
|
+
addServerHandler({
|
|
2286
|
+
handler: resolver.resolve("./runtime/server/middleware/ratelimit"),
|
|
2287
|
+
middleware: true,
|
|
2288
|
+
route: "/**"
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
if (options.hyperdrive) {
|
|
2292
|
+
addServerImports([
|
|
2293
|
+
{
|
|
2294
|
+
name: "hyperdrive",
|
|
2295
|
+
from: "qarpeo/runtime"
|
|
2296
|
+
},
|
|
2297
|
+
{
|
|
2298
|
+
name: "useHyperdrive",
|
|
2299
|
+
from: "qarpeo/runtime"
|
|
2300
|
+
},
|
|
2301
|
+
{
|
|
2302
|
+
name: "getHyperdriveBinding",
|
|
2303
|
+
from: "qarpeo/runtime"
|
|
2304
|
+
}
|
|
2305
|
+
]);
|
|
2306
|
+
}
|
|
2307
|
+
if (options.browser) {
|
|
2308
|
+
addServerImports([
|
|
2309
|
+
{
|
|
2310
|
+
name: "browser",
|
|
2311
|
+
from: "qarpeo/runtime"
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
name: "useBrowser",
|
|
2315
|
+
from: "qarpeo/runtime"
|
|
2316
|
+
},
|
|
2317
|
+
{
|
|
2318
|
+
name: "getBrowserBinding",
|
|
2319
|
+
from: "qarpeo/runtime"
|
|
2320
|
+
}
|
|
2321
|
+
]);
|
|
2322
|
+
}
|
|
2323
|
+
if (options.email) {
|
|
2324
|
+
addImports([
|
|
2325
|
+
{
|
|
2326
|
+
name: "useEmailSenders",
|
|
2327
|
+
from: "qarpeo/runtime"
|
|
2328
|
+
}
|
|
2329
|
+
]);
|
|
2330
|
+
addServerImports([
|
|
2331
|
+
{
|
|
2332
|
+
name: "email",
|
|
2333
|
+
from: "qarpeo/runtime"
|
|
2334
|
+
},
|
|
2335
|
+
{
|
|
2336
|
+
name: "sendEmail",
|
|
2337
|
+
from: "qarpeo/runtime"
|
|
2338
|
+
},
|
|
2339
|
+
{
|
|
2340
|
+
name: "useEmail",
|
|
2341
|
+
from: "qarpeo/runtime"
|
|
2342
|
+
},
|
|
2343
|
+
{
|
|
2344
|
+
name: "useEmailSenders",
|
|
2345
|
+
from: "qarpeo/runtime"
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
name: "getEmailBinding",
|
|
2349
|
+
from: "qarpeo/runtime"
|
|
2350
|
+
}
|
|
2351
|
+
]);
|
|
2352
|
+
}
|
|
2353
|
+
if (options.do) {
|
|
2354
|
+
addServerImports([
|
|
2355
|
+
{
|
|
2356
|
+
name: "QarpeoRoomDO",
|
|
2357
|
+
from: resolver.resolve("./runtime/server/durable-objects/room")
|
|
2358
|
+
},
|
|
2359
|
+
{
|
|
2360
|
+
name: "getRoomDurableObject",
|
|
2361
|
+
from: resolver.resolve("./runtime/server/utils/realtime")
|
|
2362
|
+
}
|
|
2363
|
+
]);
|
|
2364
|
+
}
|
|
2365
|
+
if (options.auth) {
|
|
2366
|
+
const authConfig = typeof options.auth === "object" ? options.auth : {};
|
|
2367
|
+
const authPrefix = authConfig.prefix || "/api/auth";
|
|
2368
|
+
const authRules = {};
|
|
2369
|
+
for (const [pattern, rule] of Object.entries(
|
|
2370
|
+
nuxt.options.routeRules || {}
|
|
2371
|
+
)) {
|
|
2372
|
+
if (rule?.auth) {
|
|
2373
|
+
authRules[pattern] = rule.auth;
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
const authRuntimeConfig = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
2377
|
+
authRuntimeConfig.qarpeo = authRuntimeConfig.qarpeo || {};
|
|
2378
|
+
authRuntimeConfig.qarpeo.auth = {
|
|
2379
|
+
...authConfig,
|
|
2380
|
+
prefix: authPrefix,
|
|
2381
|
+
rules: authRules
|
|
2382
|
+
};
|
|
2383
|
+
const publicConfig = authRuntimeConfig.public = authRuntimeConfig.public || {};
|
|
2384
|
+
publicConfig.qarpeo = publicConfig.qarpeo || {};
|
|
2385
|
+
publicConfig.qarpeo.auth = {
|
|
2386
|
+
prefix: authPrefix,
|
|
2387
|
+
redirect: authConfig.redirect,
|
|
2388
|
+
rules: authRules,
|
|
2389
|
+
mfa: authConfig.mfa,
|
|
2390
|
+
turnstile: typeof authConfig.turnstile === "object" ? { siteKey: authConfig.turnstile.siteKey } : void 0
|
|
2391
|
+
};
|
|
2392
|
+
addServerHandler({
|
|
2393
|
+
handler: resolver.resolve("./runtime/server/middleware/auth"),
|
|
2394
|
+
middleware: true,
|
|
2395
|
+
route: "/**"
|
|
2396
|
+
});
|
|
2397
|
+
addRouteMiddleware({
|
|
2398
|
+
name: "qarpeo-auth",
|
|
2399
|
+
path: resolver.resolve("./runtime/app/middleware/auth.global"),
|
|
2400
|
+
global: true
|
|
2401
|
+
});
|
|
2402
|
+
addServerHandler({
|
|
2403
|
+
route: `${authPrefix}/user`,
|
|
2404
|
+
handler: resolver.resolve("./runtime/server/routes/auth/user.get")
|
|
2405
|
+
});
|
|
2406
|
+
addServerHandler({
|
|
2407
|
+
route: `${authPrefix}/logout`,
|
|
2408
|
+
handler: resolver.resolve("./runtime/server/routes/auth/logout.post")
|
|
2409
|
+
});
|
|
2410
|
+
addServerHandler({
|
|
2411
|
+
route: `${authPrefix}/:provider`,
|
|
2412
|
+
handler: resolver.resolve("./runtime/server/routes/auth/[provider]")
|
|
2413
|
+
});
|
|
2414
|
+
addServerHandler({
|
|
2415
|
+
route: `${authPrefix}/:provider/callback`,
|
|
2416
|
+
handler: resolver.resolve("./runtime/server/routes/auth/[provider]/callback")
|
|
2417
|
+
});
|
|
2418
|
+
addServerHandler({
|
|
2419
|
+
route: `${authPrefix}/sessions`,
|
|
2420
|
+
handler: resolver.resolve("./runtime/server/routes/auth/sessions.get")
|
|
2421
|
+
});
|
|
2422
|
+
addServerHandler({
|
|
2423
|
+
route: `${authPrefix}/sessions/:id`,
|
|
2424
|
+
handler: resolver.resolve("./runtime/server/routes/auth/sessions/[id].delete")
|
|
2425
|
+
});
|
|
2426
|
+
addServerHandler({
|
|
2427
|
+
route: `${authPrefix}/logout-all`,
|
|
2428
|
+
handler: resolver.resolve("./runtime/server/routes/auth/logout-all.post")
|
|
2429
|
+
});
|
|
2430
|
+
addServerHandler({
|
|
2431
|
+
route: `${authPrefix}/logout-others`,
|
|
2432
|
+
handler: resolver.resolve("./runtime/server/routes/auth/logout-others.post")
|
|
2433
|
+
});
|
|
2434
|
+
addServerHandler({
|
|
2435
|
+
route: `${authPrefix}/otp/send`,
|
|
2436
|
+
handler: resolver.resolve("./runtime/server/routes/auth/otp/send.post")
|
|
2437
|
+
});
|
|
2438
|
+
addServerHandler({
|
|
2439
|
+
route: `${authPrefix}/otp/verify`,
|
|
2440
|
+
handler: resolver.resolve("./runtime/server/routes/auth/otp/verify.post")
|
|
2441
|
+
});
|
|
2442
|
+
addServerHandler({
|
|
2443
|
+
route: `${authPrefix}/magic-link/send`,
|
|
2444
|
+
handler: resolver.resolve("./runtime/server/routes/auth/magic-link/send.post")
|
|
2445
|
+
});
|
|
2446
|
+
addServerHandler({
|
|
2447
|
+
route: `${authPrefix}/magic-link/verify`,
|
|
2448
|
+
handler: resolver.resolve("./runtime/server/routes/auth/magic-link/verify.get")
|
|
2449
|
+
});
|
|
2450
|
+
addServerHandler({
|
|
2451
|
+
route: `${authPrefix}/2fa/setup`,
|
|
2452
|
+
handler: resolver.resolve("./runtime/server/routes/auth/2fa/setup.post")
|
|
2453
|
+
});
|
|
2454
|
+
addServerHandler({
|
|
2455
|
+
route: `${authPrefix}/2fa/verify`,
|
|
2456
|
+
handler: resolver.resolve("./runtime/server/routes/auth/2fa/verify.post")
|
|
2457
|
+
});
|
|
2458
|
+
addServerHandler({
|
|
2459
|
+
route: `${authPrefix}/2fa/disable`,
|
|
2460
|
+
handler: resolver.resolve("./runtime/server/routes/auth/2fa/disable.post")
|
|
2461
|
+
});
|
|
2462
|
+
addServerHandler({
|
|
2463
|
+
route: `${authPrefix}/webauthn/register/options`,
|
|
2464
|
+
handler: resolver.resolve("./runtime/server/routes/auth/webauthn/register/options.post")
|
|
2465
|
+
});
|
|
2466
|
+
addServerHandler({
|
|
2467
|
+
route: `${authPrefix}/webauthn/register/verify`,
|
|
2468
|
+
handler: resolver.resolve("./runtime/server/routes/auth/webauthn/register/verify.post")
|
|
2469
|
+
});
|
|
2470
|
+
addServerHandler({
|
|
2471
|
+
route: `${authPrefix}/webauthn/login/options`,
|
|
2472
|
+
handler: resolver.resolve("./runtime/server/routes/auth/webauthn/login/options.post")
|
|
2473
|
+
});
|
|
2474
|
+
addServerHandler({
|
|
2475
|
+
route: `${authPrefix}/webauthn/login/verify`,
|
|
2476
|
+
handler: resolver.resolve("./runtime/server/routes/auth/webauthn/login/verify.post")
|
|
2477
|
+
});
|
|
2478
|
+
addServerHandler({
|
|
2479
|
+
route: `${authPrefix}/organization/create`,
|
|
2480
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/create.post")
|
|
2481
|
+
});
|
|
2482
|
+
addServerHandler({
|
|
2483
|
+
route: `${authPrefix}/organization/list`,
|
|
2484
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/list.get")
|
|
2485
|
+
});
|
|
2486
|
+
addServerHandler({
|
|
2487
|
+
route: `${authPrefix}/organization/switch`,
|
|
2488
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/switch.post")
|
|
2489
|
+
});
|
|
2490
|
+
addServerHandler({
|
|
2491
|
+
route: `${authPrefix}/organization/invite`,
|
|
2492
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/invite.post")
|
|
2493
|
+
});
|
|
2494
|
+
addServerHandler({
|
|
2495
|
+
route: `${authPrefix}/organization/join`,
|
|
2496
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/join.post")
|
|
2497
|
+
});
|
|
2498
|
+
addServerHandler({
|
|
2499
|
+
route: `${authPrefix}/organization/members`,
|
|
2500
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/members/index.get")
|
|
2501
|
+
});
|
|
2502
|
+
addServerHandler({
|
|
2503
|
+
route: `${authPrefix}/organization/members/:id`,
|
|
2504
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/members/[id].delete")
|
|
2505
|
+
});
|
|
2506
|
+
addServerHandler({
|
|
2507
|
+
route: `${authPrefix}/impersonate/start`,
|
|
2508
|
+
handler: resolver.resolve("./runtime/server/routes/auth/impersonate/start.post")
|
|
2509
|
+
});
|
|
2510
|
+
addServerHandler({
|
|
2511
|
+
route: `${authPrefix}/impersonate/stop`,
|
|
2512
|
+
handler: resolver.resolve("./runtime/server/routes/auth/impersonate/stop.post")
|
|
2513
|
+
});
|
|
2514
|
+
addServerHandler({
|
|
2515
|
+
route: `${authPrefix}/tokens`,
|
|
2516
|
+
handler: resolver.resolve("./runtime/server/routes/auth/tokens/index.get")
|
|
2517
|
+
});
|
|
2518
|
+
addServerHandler({
|
|
2519
|
+
route: `${authPrefix}/tokens/create`,
|
|
2520
|
+
handler: resolver.resolve("./runtime/server/routes/auth/tokens/create.post")
|
|
2521
|
+
});
|
|
2522
|
+
addServerHandler({
|
|
2523
|
+
route: `${authPrefix}/tokens/:id`,
|
|
2524
|
+
handler: resolver.resolve("./runtime/server/routes/auth/tokens/[id].delete")
|
|
2525
|
+
});
|
|
2526
|
+
addServerHandler({
|
|
2527
|
+
route: `${authPrefix}/account`,
|
|
2528
|
+
method: "delete",
|
|
2529
|
+
handler: resolver.resolve("./runtime/server/routes/auth/account.delete")
|
|
2530
|
+
});
|
|
2531
|
+
addServerHandler({
|
|
2532
|
+
route: `${authPrefix}/turnstile/verify`,
|
|
2533
|
+
method: "post",
|
|
2534
|
+
handler: resolver.resolve("./runtime/server/routes/auth/turnstile/verify.post")
|
|
2535
|
+
});
|
|
2536
|
+
addServerHandler({
|
|
2537
|
+
route: `${authPrefix}/sso/login`,
|
|
2538
|
+
method: "get",
|
|
2539
|
+
handler: resolver.resolve("./runtime/server/routes/auth/sso/login.get")
|
|
2540
|
+
});
|
|
2541
|
+
addServerHandler({
|
|
2542
|
+
route: `${authPrefix}/sso/saml/acs`,
|
|
2543
|
+
method: "post",
|
|
2544
|
+
handler: resolver.resolve("./runtime/server/routes/auth/sso/saml/acs.post")
|
|
2545
|
+
});
|
|
2546
|
+
addServerHandler({
|
|
2547
|
+
route: `${authPrefix}/sso/oidc/callback`,
|
|
2548
|
+
method: "get",
|
|
2549
|
+
handler: resolver.resolve("./runtime/server/routes/auth/sso/oidc/callback.get")
|
|
2550
|
+
});
|
|
2551
|
+
addServerHandler({
|
|
2552
|
+
route: `${authPrefix}/organization/sso`,
|
|
2553
|
+
method: "get",
|
|
2554
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/sso/index.get")
|
|
2555
|
+
});
|
|
2556
|
+
addServerHandler({
|
|
2557
|
+
route: `${authPrefix}/organization/sso`,
|
|
2558
|
+
method: "post",
|
|
2559
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/sso/index.post")
|
|
2560
|
+
});
|
|
2561
|
+
addServerHandler({
|
|
2562
|
+
route: `${authPrefix}/organization/sso/:id`,
|
|
2563
|
+
method: "delete",
|
|
2564
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/sso/[id].delete")
|
|
2565
|
+
});
|
|
2566
|
+
addServerHandler({
|
|
2567
|
+
route: `${authPrefix}/organization/mfa`,
|
|
2568
|
+
method: "post",
|
|
2569
|
+
handler: resolver.resolve("./runtime/server/routes/auth/organization/mfa.post")
|
|
2570
|
+
});
|
|
2571
|
+
addImports([
|
|
2572
|
+
{
|
|
2573
|
+
name: "useAuth",
|
|
2574
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2575
|
+
},
|
|
2576
|
+
{
|
|
2577
|
+
name: "useOrganization",
|
|
2578
|
+
from: resolver.resolve("./runtime/app/composables/organization")
|
|
2579
|
+
},
|
|
2580
|
+
{
|
|
2581
|
+
name: "useImpersonation",
|
|
2582
|
+
from: resolver.resolve("./runtime/app/composables/impersonation")
|
|
2583
|
+
},
|
|
2584
|
+
{
|
|
2585
|
+
name: "useApiTokens",
|
|
2586
|
+
from: resolver.resolve("./runtime/app/composables/api-tokens")
|
|
2587
|
+
},
|
|
2588
|
+
{
|
|
2589
|
+
name: "usePasswordless",
|
|
2590
|
+
from: resolver.resolve("./runtime/app/composables/passwordless")
|
|
2591
|
+
},
|
|
2592
|
+
{
|
|
2593
|
+
name: "useTwoFactor",
|
|
2594
|
+
from: resolver.resolve("./runtime/app/composables/two-factor")
|
|
2595
|
+
},
|
|
2596
|
+
{
|
|
2597
|
+
name: "usePasskey",
|
|
2598
|
+
from: resolver.resolve("./runtime/app/composables/passkey")
|
|
2599
|
+
},
|
|
2600
|
+
{
|
|
2601
|
+
name: "useTurnstile",
|
|
2602
|
+
from: resolver.resolve("./runtime/app/composables/turnstile")
|
|
2603
|
+
}
|
|
2604
|
+
]);
|
|
2605
|
+
addServerImports([
|
|
2606
|
+
{
|
|
2607
|
+
name: "handleOAuthSuccess",
|
|
2608
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
2609
|
+
},
|
|
2610
|
+
{
|
|
2611
|
+
name: "ensureAuthTables",
|
|
2612
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
2613
|
+
},
|
|
2614
|
+
// Phase 3: Session management utilities
|
|
2615
|
+
{
|
|
2616
|
+
name: "getAuthSession",
|
|
2617
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2618
|
+
},
|
|
2619
|
+
{
|
|
2620
|
+
name: "setAuthSession",
|
|
2621
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2622
|
+
},
|
|
2623
|
+
{
|
|
2624
|
+
name: "clearAuthSession",
|
|
2625
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2626
|
+
},
|
|
2627
|
+
{
|
|
2628
|
+
name: "requireAuthSession",
|
|
2629
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2630
|
+
},
|
|
2631
|
+
{
|
|
2632
|
+
name: "createDeviceSession",
|
|
2633
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
name: "listDeviceSessions",
|
|
2637
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
name: "revokeDeviceSession",
|
|
2641
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2642
|
+
},
|
|
2643
|
+
{
|
|
2644
|
+
name: "revokeAllDeviceSessions",
|
|
2645
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2646
|
+
},
|
|
2647
|
+
{
|
|
2648
|
+
name: "revokeOtherDeviceSessions",
|
|
2649
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2650
|
+
},
|
|
2651
|
+
{
|
|
2652
|
+
name: "touchDeviceSession",
|
|
2653
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2654
|
+
},
|
|
2655
|
+
{
|
|
2656
|
+
name: "verifyKVSession",
|
|
2657
|
+
from: resolver.resolve("./runtime/server/utils/session")
|
|
2658
|
+
},
|
|
2659
|
+
// Phase 4: Passwordless utilities
|
|
2660
|
+
{
|
|
2661
|
+
name: "sendOTPCode",
|
|
2662
|
+
from: resolver.resolve("./runtime/server/utils/passwordless")
|
|
2663
|
+
},
|
|
2664
|
+
{
|
|
2665
|
+
name: "verifyOTPCode",
|
|
2666
|
+
from: resolver.resolve("./runtime/server/utils/passwordless")
|
|
2667
|
+
},
|
|
2668
|
+
{
|
|
2669
|
+
name: "sendMagicLink",
|
|
2670
|
+
from: resolver.resolve("./runtime/server/utils/passwordless")
|
|
2671
|
+
},
|
|
2672
|
+
{
|
|
2673
|
+
name: "verifyMagicLinkToken",
|
|
2674
|
+
from: resolver.resolve("./runtime/server/utils/passwordless")
|
|
2675
|
+
},
|
|
2676
|
+
// Phase 4: Two-Factor (TOTP) utilities
|
|
2677
|
+
{
|
|
2678
|
+
name: "generateBase32Secret",
|
|
2679
|
+
from: resolver.resolve("./runtime/server/utils/totp")
|
|
2680
|
+
},
|
|
2681
|
+
{
|
|
2682
|
+
name: "generateTOTPCode",
|
|
2683
|
+
from: resolver.resolve("./runtime/server/utils/totp")
|
|
2684
|
+
},
|
|
2685
|
+
{
|
|
2686
|
+
name: "verifyTOTPCode",
|
|
2687
|
+
from: resolver.resolve("./runtime/server/utils/totp")
|
|
2688
|
+
},
|
|
2689
|
+
{
|
|
2690
|
+
name: "generateBackupCodes",
|
|
2691
|
+
from: resolver.resolve("./runtime/server/utils/totp")
|
|
2692
|
+
},
|
|
2693
|
+
{
|
|
2694
|
+
name: "buildOTPAuthURL",
|
|
2695
|
+
from: resolver.resolve("./runtime/server/utils/totp")
|
|
2696
|
+
},
|
|
2697
|
+
{
|
|
2698
|
+
name: "generateTOTPUrl",
|
|
2699
|
+
from: resolver.resolve("./runtime/server/utils/totp")
|
|
2700
|
+
},
|
|
2701
|
+
// Phase 5: Organization utilities
|
|
2702
|
+
{
|
|
2703
|
+
name: "createOrganization",
|
|
2704
|
+
from: resolver.resolve("./runtime/server/utils/organization")
|
|
2705
|
+
},
|
|
2706
|
+
{
|
|
2707
|
+
name: "listUserOrganizations",
|
|
2708
|
+
from: resolver.resolve("./runtime/server/utils/organization")
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
name: "switchActiveOrganization",
|
|
2712
|
+
from: resolver.resolve("./runtime/server/utils/organization")
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
name: "inviteOrganizationMember",
|
|
2716
|
+
from: resolver.resolve("./runtime/server/utils/organization")
|
|
2717
|
+
},
|
|
2718
|
+
{
|
|
2719
|
+
name: "removeOrganizationMember",
|
|
2720
|
+
from: resolver.resolve("./runtime/server/utils/organization")
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
name: "acceptOrganizationInvitation",
|
|
2724
|
+
from: resolver.resolve("./runtime/server/utils/organization")
|
|
2725
|
+
},
|
|
2726
|
+
{
|
|
2727
|
+
name: "listOrganizationMembers",
|
|
2728
|
+
from: resolver.resolve("./runtime/server/utils/organization")
|
|
2729
|
+
},
|
|
2730
|
+
// Phase 6: Impersonation & PAT utilities
|
|
2731
|
+
{
|
|
2732
|
+
name: "startImpersonation",
|
|
2733
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2734
|
+
},
|
|
2735
|
+
{
|
|
2736
|
+
name: "stopImpersonation",
|
|
2737
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2738
|
+
},
|
|
2739
|
+
{
|
|
2740
|
+
name: "createApiToken",
|
|
2741
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2742
|
+
},
|
|
2743
|
+
{
|
|
2744
|
+
name: "listApiTokens",
|
|
2745
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2746
|
+
},
|
|
2747
|
+
{
|
|
2748
|
+
name: "revokeApiToken",
|
|
2749
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2750
|
+
},
|
|
2751
|
+
// Enterprise Auth utilities
|
|
2752
|
+
{
|
|
2753
|
+
name: "deleteUserAccount",
|
|
2754
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
2755
|
+
},
|
|
2756
|
+
{
|
|
2757
|
+
name: "resolveMfaStatus",
|
|
2758
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
2759
|
+
},
|
|
2760
|
+
{
|
|
2761
|
+
name: "verifyTurnstileToken",
|
|
2762
|
+
from: resolver.resolve("./runtime/server/utils/turnstile")
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
name: "requireTurnstile",
|
|
2766
|
+
from: resolver.resolve("./runtime/server/utils/turnstile")
|
|
2767
|
+
},
|
|
2768
|
+
{
|
|
2769
|
+
name: "buildSAMLAuthnRequestUrl",
|
|
2770
|
+
from: resolver.resolve("./runtime/server/utils/sso")
|
|
2771
|
+
},
|
|
2772
|
+
{
|
|
2773
|
+
name: "parseSAMLResponse",
|
|
2774
|
+
from: resolver.resolve("./runtime/server/utils/sso")
|
|
2775
|
+
},
|
|
2776
|
+
{
|
|
2777
|
+
name: "buildOIDCAuthUrl",
|
|
2778
|
+
from: resolver.resolve("./runtime/server/utils/sso")
|
|
2779
|
+
},
|
|
2780
|
+
{
|
|
2781
|
+
name: "exchangeOIDCCode",
|
|
2782
|
+
from: resolver.resolve("./runtime/server/utils/sso")
|
|
2783
|
+
},
|
|
2784
|
+
{
|
|
2785
|
+
name: "verifyApiToken",
|
|
2786
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2787
|
+
},
|
|
2788
|
+
{
|
|
2789
|
+
name: "requireApiToken",
|
|
2790
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
name: "hasApiTokenScope",
|
|
2794
|
+
from: resolver.resolve("./runtime/server/utils/impersonation")
|
|
2795
|
+
},
|
|
2796
|
+
// Unified server auth helpers (PAT + Session)
|
|
2797
|
+
{
|
|
2798
|
+
name: "requireAuth",
|
|
2799
|
+
from: resolver.resolve("./runtime/server/utils/context")
|
|
2800
|
+
},
|
|
2801
|
+
{
|
|
2802
|
+
name: "getAuthContext",
|
|
2803
|
+
from: resolver.resolve("./runtime/server/utils/context")
|
|
2804
|
+
},
|
|
2805
|
+
{
|
|
2806
|
+
name: "getQarpeoSession",
|
|
2807
|
+
from: resolver.resolve("./runtime/server/utils/context")
|
|
2808
|
+
}
|
|
2809
|
+
]);
|
|
2810
|
+
addComponent({
|
|
2811
|
+
name: "SignedIn",
|
|
2812
|
+
filePath: resolver.resolve("./runtime/app/components/SignedIn")
|
|
2813
|
+
});
|
|
2814
|
+
addComponent({
|
|
2815
|
+
name: "SignedOut",
|
|
2816
|
+
filePath: resolver.resolve("./runtime/app/components/SignedOut")
|
|
2817
|
+
});
|
|
2818
|
+
addComponent({
|
|
2819
|
+
name: "ImpersonationBanner",
|
|
2820
|
+
filePath: resolver.resolve("./runtime/app/components/ImpersonationBanner")
|
|
2821
|
+
});
|
|
2822
|
+
}
|
|
2823
|
+
if (options.blob || options.storage) {
|
|
2824
|
+
const blobConfig = typeof (options.blob || options.storage) === "object" ? options.blob || options.storage : {};
|
|
2825
|
+
const storagePrefix = blobConfig.prefix || "/api/storage";
|
|
2826
|
+
const appRuntimeConfig = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
2827
|
+
appRuntimeConfig.qarpeo = appRuntimeConfig.qarpeo || {};
|
|
2828
|
+
appRuntimeConfig.qarpeo.blob = {
|
|
2829
|
+
...blobConfig,
|
|
2830
|
+
prefix: storagePrefix
|
|
2831
|
+
};
|
|
2832
|
+
appRuntimeConfig.qarpeo.storage = appRuntimeConfig.qarpeo.blob;
|
|
2833
|
+
const publicConfig = appRuntimeConfig.public = appRuntimeConfig.public || {};
|
|
2834
|
+
publicConfig.qarpeo = publicConfig.qarpeo || {};
|
|
2835
|
+
publicConfig.qarpeo.blob = {
|
|
2836
|
+
prefix: storagePrefix,
|
|
2837
|
+
cdnUrl: blobConfig.cdnUrl,
|
|
2838
|
+
maxSize: blobConfig.maxSize || "20MB",
|
|
2839
|
+
allowedTypes: blobConfig.allowedTypes || ["*"],
|
|
2840
|
+
scope: blobConfig.scope || "public",
|
|
2841
|
+
images: blobConfig.images
|
|
2842
|
+
};
|
|
2843
|
+
publicConfig.qarpeo.storage = publicConfig.qarpeo.blob;
|
|
2844
|
+
addServerHandler({
|
|
2845
|
+
route: `${storagePrefix}/upload`,
|
|
2846
|
+
handler: resolver.resolve("./runtime/server/routes/storage/upload.post")
|
|
2847
|
+
});
|
|
2848
|
+
addServerHandler({
|
|
2849
|
+
route: `${storagePrefix}/presigned`,
|
|
2850
|
+
handler: resolver.resolve("./runtime/server/routes/storage/presigned.post")
|
|
2851
|
+
});
|
|
2852
|
+
addServerHandler({
|
|
2853
|
+
route: `${storagePrefix}/files`,
|
|
2854
|
+
handler: resolver.resolve("./runtime/server/routes/storage/files.get")
|
|
2855
|
+
});
|
|
2856
|
+
addServerHandler({
|
|
2857
|
+
route: `${storagePrefix}/sign`,
|
|
2858
|
+
handler: resolver.resolve("./runtime/server/routes/storage/sign.post")
|
|
2859
|
+
});
|
|
2860
|
+
addServerHandler({
|
|
2861
|
+
route: `${storagePrefix}/file/**`,
|
|
2862
|
+
handler: resolver.resolve("./runtime/server/routes/storage/file/[...key].get")
|
|
2863
|
+
});
|
|
2864
|
+
addServerHandler({
|
|
2865
|
+
route: `${storagePrefix}/file/**`,
|
|
2866
|
+
handler: resolver.resolve("./runtime/server/routes/storage/file/[...key].delete")
|
|
2867
|
+
});
|
|
2868
|
+
if (storagePrefix !== "/api/blob") {
|
|
2869
|
+
addServerHandler({
|
|
2870
|
+
route: "/api/blob/upload",
|
|
2871
|
+
handler: resolver.resolve("./runtime/server/routes/storage/upload.post")
|
|
2872
|
+
});
|
|
2873
|
+
addServerHandler({
|
|
2874
|
+
route: "/api/blob/presigned",
|
|
2875
|
+
handler: resolver.resolve("./runtime/server/routes/storage/presigned.post")
|
|
2876
|
+
});
|
|
2877
|
+
addServerHandler({
|
|
2878
|
+
route: "/api/blob/files",
|
|
2879
|
+
handler: resolver.resolve("./runtime/server/routes/storage/files.get")
|
|
2880
|
+
});
|
|
2881
|
+
addServerHandler({
|
|
2882
|
+
route: "/api/blob/sign",
|
|
2883
|
+
handler: resolver.resolve("./runtime/server/routes/storage/sign.post")
|
|
2884
|
+
});
|
|
2885
|
+
addServerHandler({
|
|
2886
|
+
route: "/api/blob/file/**",
|
|
2887
|
+
handler: resolver.resolve("./runtime/server/routes/storage/file/[...key].get")
|
|
2888
|
+
});
|
|
2889
|
+
addServerHandler({
|
|
2890
|
+
route: "/api/blob/file/**",
|
|
2891
|
+
handler: resolver.resolve("./runtime/server/routes/storage/file/[...key].delete")
|
|
2892
|
+
});
|
|
2893
|
+
}
|
|
2894
|
+
addImports([
|
|
2895
|
+
{
|
|
2896
|
+
name: "useStorage",
|
|
2897
|
+
from: resolver.resolve("./runtime/app/composables/storage")
|
|
2898
|
+
},
|
|
2899
|
+
{
|
|
2900
|
+
name: "useUpload",
|
|
2901
|
+
from: resolver.resolve("./runtime/app/composables/storage")
|
|
2902
|
+
},
|
|
2903
|
+
{
|
|
2904
|
+
name: "useBlobUrl",
|
|
2905
|
+
from: resolver.resolve("./runtime/app/composables/storage")
|
|
2906
|
+
},
|
|
2907
|
+
{
|
|
2908
|
+
name: "getBlobUrl",
|
|
2909
|
+
from: resolver.resolve("./runtime/app/composables/storage")
|
|
2910
|
+
}
|
|
2911
|
+
]);
|
|
2912
|
+
addComponent({
|
|
2913
|
+
name: "BlobImage",
|
|
2914
|
+
filePath: resolver.resolve("./runtime/app/components/BlobImage")
|
|
2915
|
+
});
|
|
2916
|
+
addComponent({
|
|
2917
|
+
name: "FileUpload",
|
|
2918
|
+
filePath: resolver.resolve("./runtime/app/components/FileUpload")
|
|
2919
|
+
});
|
|
2920
|
+
addServerImports([
|
|
2921
|
+
{
|
|
2922
|
+
name: "uploadStorageFile",
|
|
2923
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2924
|
+
},
|
|
2925
|
+
{
|
|
2926
|
+
name: "buildStorageUrl",
|
|
2927
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2928
|
+
},
|
|
2929
|
+
{
|
|
2930
|
+
name: "deleteStorageFile",
|
|
2931
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
name: "serveStorageFile",
|
|
2935
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2936
|
+
},
|
|
2937
|
+
{
|
|
2938
|
+
name: "createPresignedUploadTicket",
|
|
2939
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2940
|
+
},
|
|
2941
|
+
{
|
|
2942
|
+
name: "createSignedBlobToken",
|
|
2943
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2944
|
+
},
|
|
2945
|
+
{
|
|
2946
|
+
name: "verifySignedBlobToken",
|
|
2947
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2948
|
+
},
|
|
2949
|
+
{
|
|
2950
|
+
name: "getDownloadUrl",
|
|
2951
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2952
|
+
},
|
|
2953
|
+
{
|
|
2954
|
+
name: "listStorageFiles",
|
|
2955
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2956
|
+
},
|
|
2957
|
+
{
|
|
2958
|
+
name: "getStorageConfig",
|
|
2959
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
2960
|
+
}
|
|
2961
|
+
]);
|
|
2962
|
+
}
|
|
2963
|
+
if (options.cms) {
|
|
2964
|
+
const cmsConfig = typeof options.cms === "object" ? options.cms : {};
|
|
2965
|
+
const cmsApiPath = cmsConfig.apiPath || "/api/cms";
|
|
2966
|
+
const cmsPath = cmsConfig.path || "/cms";
|
|
2967
|
+
const contentDirName = cmsConfig.contentDir || "content";
|
|
2968
|
+
const resolvedContentDir = existsSync(resolve(nuxt.options.rootDir, contentDirName)) ? resolve(nuxt.options.rootDir, contentDirName) : resolve(nuxt.options.srcDir || nuxt.options.rootDir, contentDirName);
|
|
2969
|
+
const cacheDir = nuxt.options.buildDir || resolve(nuxt.options.rootDir, ".nuxt");
|
|
2970
|
+
let resolvedSources = [];
|
|
2971
|
+
try {
|
|
2972
|
+
resolvedSources = await resolveAllCmsSources({
|
|
2973
|
+
contentDir: resolvedContentDir,
|
|
2974
|
+
rootDir: nuxt.options.rootDir,
|
|
2975
|
+
cacheDir,
|
|
2976
|
+
configSources: cmsConfig.sources
|
|
2977
|
+
});
|
|
2978
|
+
} catch (err) {
|
|
2979
|
+
console.warn("[qarpeo:cms] Error resolving CMS sources:", err);
|
|
2980
|
+
}
|
|
2981
|
+
nuxt.options.watch = nuxt.options.watch || [];
|
|
2982
|
+
const externalSourceDirs = [];
|
|
2983
|
+
for (const src of resolvedSources) {
|
|
2984
|
+
if (src.resolvedDir && !src.resolvedDir.includes("node_modules") && !src.resolvedDir.includes(".nuxt")) {
|
|
2985
|
+
nuxt.options.watch.push(src.resolvedDir);
|
|
2986
|
+
if (!src.resolvedDir.startsWith(nuxt.options.rootDir)) {
|
|
2987
|
+
externalSourceDirs.push(src.resolvedDir);
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
if (src.sourceConfigFile) {
|
|
2991
|
+
nuxt.options.watch.push(src.sourceConfigFile);
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
if (nuxt.options.dev && externalSourceDirs.length > 0) {
|
|
2995
|
+
nuxt.options.vite = nuxt.options.vite || {};
|
|
2996
|
+
nuxt.options.vite.server = nuxt.options.vite.server || {};
|
|
2997
|
+
const existingWatch = nuxt.options.vite.server.watch || {};
|
|
2998
|
+
nuxt.options.vite.server.watch = {
|
|
2999
|
+
...existingWatch,
|
|
3000
|
+
followSymlinks: true,
|
|
3001
|
+
// usePolling is a fallback for cross-drive/network paths where native FS events don't fire
|
|
3002
|
+
usePolling: existingWatch.usePolling ?? false
|
|
3003
|
+
};
|
|
3004
|
+
}
|
|
3005
|
+
const appRuntimeConfig = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3006
|
+
appRuntimeConfig.qarpeo = appRuntimeConfig.qarpeo || {};
|
|
3007
|
+
appRuntimeConfig.qarpeo.cms = {
|
|
3008
|
+
...cmsConfig,
|
|
3009
|
+
apiPath: cmsApiPath,
|
|
3010
|
+
path: cmsPath,
|
|
3011
|
+
contentDir: resolvedContentDir,
|
|
3012
|
+
sources: resolvedSources,
|
|
3013
|
+
hybrid: cmsConfig.hybrid !== false,
|
|
3014
|
+
roles: cmsConfig.roles || ["admin", "editor"],
|
|
3015
|
+
revisions: typeof cmsConfig.revisions === "object" ? cmsConfig.revisions : { max: 10 },
|
|
3016
|
+
cache: cmsConfig.cache !== false,
|
|
3017
|
+
collections: cmsConfig.collections || {}
|
|
3018
|
+
};
|
|
3019
|
+
const publicConfig = appRuntimeConfig.public = appRuntimeConfig.public || {};
|
|
3020
|
+
publicConfig.qarpeo = publicConfig.qarpeo || {};
|
|
3021
|
+
publicConfig.qarpeo.cms = {
|
|
3022
|
+
...publicConfig.qarpeo.cms,
|
|
3023
|
+
apiPath: cmsApiPath,
|
|
3024
|
+
path: cmsPath,
|
|
3025
|
+
hasDeployTrigger: Boolean(cmsConfig.deploy),
|
|
3026
|
+
locales: cmsConfig.locales || ["en"],
|
|
3027
|
+
defaultLocale: cmsConfig.defaultLocale || "en",
|
|
3028
|
+
collections: Object.fromEntries(
|
|
3029
|
+
Object.entries(cmsConfig.collections || {}).map(([id, col]) => [
|
|
3030
|
+
id,
|
|
3031
|
+
{
|
|
3032
|
+
name: col.name,
|
|
3033
|
+
mode: col.mode || "db",
|
|
3034
|
+
approval: col.approval ?? cmsConfig.approval,
|
|
3035
|
+
fields: col.fields || {}
|
|
3036
|
+
}
|
|
3037
|
+
])
|
|
3038
|
+
)
|
|
3039
|
+
};
|
|
3040
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/cms"));
|
|
3041
|
+
addServerHandler({
|
|
3042
|
+
route: `${cmsApiPath}/collections`,
|
|
3043
|
+
method: "get",
|
|
3044
|
+
handler: resolver.resolve("./runtime/server/routes/cms/collections/index.get")
|
|
3045
|
+
});
|
|
3046
|
+
addServerHandler({
|
|
3047
|
+
route: `${cmsApiPath}/collections`,
|
|
3048
|
+
method: "post",
|
|
3049
|
+
handler: resolver.resolve("./runtime/server/routes/cms/collections/index.post")
|
|
3050
|
+
});
|
|
3051
|
+
addServerHandler({
|
|
3052
|
+
route: `${cmsApiPath}/collections/:id`,
|
|
3053
|
+
method: "put",
|
|
3054
|
+
handler: resolver.resolve("./runtime/server/routes/cms/collections/[id].put")
|
|
3055
|
+
});
|
|
3056
|
+
addServerHandler({
|
|
3057
|
+
route: `${cmsApiPath}/collections/:id`,
|
|
3058
|
+
method: "delete",
|
|
3059
|
+
handler: resolver.resolve("./runtime/server/routes/cms/collections/[id].delete")
|
|
3060
|
+
});
|
|
3061
|
+
addServerHandler({
|
|
3062
|
+
route: `${cmsApiPath}/components`,
|
|
3063
|
+
method: "get",
|
|
3064
|
+
handler: resolver.resolve("./runtime/server/routes/cms/components/index.get")
|
|
3065
|
+
});
|
|
3066
|
+
addServerHandler({
|
|
3067
|
+
route: `${cmsApiPath}/sync`,
|
|
3068
|
+
method: "post",
|
|
3069
|
+
handler: resolver.resolve("./runtime/server/routes/cms/sync.post")
|
|
3070
|
+
});
|
|
3071
|
+
addServerHandler({
|
|
3072
|
+
route: `${cmsApiPath}/export`,
|
|
3073
|
+
method: "post",
|
|
3074
|
+
handler: resolver.resolve("./runtime/server/routes/cms/export.post")
|
|
3075
|
+
});
|
|
3076
|
+
addServerHandler({
|
|
3077
|
+
route: `${cmsApiPath}/search`,
|
|
3078
|
+
method: "get",
|
|
3079
|
+
handler: resolver.resolve("./runtime/server/routes/cms/search.get")
|
|
3080
|
+
});
|
|
3081
|
+
addServerHandler({
|
|
3082
|
+
route: `${cmsApiPath}/docs/search`,
|
|
3083
|
+
method: "get",
|
|
3084
|
+
handler: resolver.resolve("./runtime/server/routes/docs/search.get")
|
|
3085
|
+
});
|
|
3086
|
+
addServerHandler({
|
|
3087
|
+
route: "/api/docs/search",
|
|
3088
|
+
method: "get",
|
|
3089
|
+
handler: resolver.resolve("./runtime/server/routes/docs/search.get")
|
|
3090
|
+
});
|
|
3091
|
+
addServerHandler({
|
|
3092
|
+
route: `${cmsApiPath}/navigation`,
|
|
3093
|
+
method: "get",
|
|
3094
|
+
handler: resolver.resolve("./runtime/server/routes/cms/navigation.get")
|
|
3095
|
+
});
|
|
3096
|
+
addServerHandler({
|
|
3097
|
+
route: `${cmsApiPath}/:collection/by-path`,
|
|
3098
|
+
method: "get",
|
|
3099
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/by-path.get")
|
|
3100
|
+
});
|
|
3101
|
+
addServerHandler({
|
|
3102
|
+
route: `${cmsApiPath}/:collection/surroundings`,
|
|
3103
|
+
method: "get",
|
|
3104
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/surroundings.get")
|
|
3105
|
+
});
|
|
3106
|
+
addServerHandler({
|
|
3107
|
+
route: `${cmsApiPath}/:collection/feed.xml`,
|
|
3108
|
+
method: "get",
|
|
3109
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/feed.xml.get")
|
|
3110
|
+
});
|
|
3111
|
+
addServerHandler({
|
|
3112
|
+
route: `${cmsApiPath}/:collection/atom.xml`,
|
|
3113
|
+
method: "get",
|
|
3114
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/atom.xml.get")
|
|
3115
|
+
});
|
|
3116
|
+
addServerHandler({
|
|
3117
|
+
route: `${cmsApiPath}/:collection/:id/publish`,
|
|
3118
|
+
method: "post",
|
|
3119
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/[id]/publish.post")
|
|
3120
|
+
});
|
|
3121
|
+
addServerHandler({
|
|
3122
|
+
route: `${cmsApiPath}/:collection/:id/review`,
|
|
3123
|
+
method: "post",
|
|
3124
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/[id]/review.post")
|
|
3125
|
+
});
|
|
3126
|
+
addServerHandler({
|
|
3127
|
+
route: `${cmsApiPath}/deploy`,
|
|
3128
|
+
method: "post",
|
|
3129
|
+
handler: resolver.resolve("./runtime/server/routes/cms/deploy.post")
|
|
3130
|
+
});
|
|
3131
|
+
addServerHandler({
|
|
3132
|
+
route: `${cmsApiPath}/preview/enable`,
|
|
3133
|
+
method: "get",
|
|
3134
|
+
handler: resolver.resolve("./runtime/server/routes/cms/preview/enable.get")
|
|
3135
|
+
});
|
|
3136
|
+
addServerHandler({
|
|
3137
|
+
route: `${cmsApiPath}/preview/disable`,
|
|
3138
|
+
method: "get",
|
|
3139
|
+
handler: resolver.resolve("./runtime/server/routes/cms/preview/disable.get")
|
|
3140
|
+
});
|
|
3141
|
+
addServerHandler({
|
|
3142
|
+
route: `${cmsApiPath}/webhooks/:provider`,
|
|
3143
|
+
method: "post",
|
|
3144
|
+
handler: resolver.resolve("./runtime/server/routes/cms/webhooks/[provider].post")
|
|
3145
|
+
});
|
|
3146
|
+
addServerHandler({
|
|
3147
|
+
route: "/cms/webhooks/:provider",
|
|
3148
|
+
method: "post",
|
|
3149
|
+
handler: resolver.resolve("./runtime/server/routes/cms/webhooks/[provider].post")
|
|
3150
|
+
});
|
|
3151
|
+
addServerHandler({
|
|
3152
|
+
route: `${cmsApiPath}/publish-scheduled`,
|
|
3153
|
+
method: "post",
|
|
3154
|
+
handler: resolver.resolve("./runtime/server/routes/cms/publish-scheduled.post")
|
|
3155
|
+
});
|
|
3156
|
+
addServerHandler({
|
|
3157
|
+
route: `${cmsApiPath}/:collection/:id/preview-token`,
|
|
3158
|
+
method: "post",
|
|
3159
|
+
handler: resolver.resolve(
|
|
3160
|
+
"./runtime/server/routes/cms/[collection]/[id]/preview-token.post"
|
|
3161
|
+
)
|
|
3162
|
+
});
|
|
3163
|
+
addServerHandler({
|
|
3164
|
+
route: `${cmsApiPath}/:collection/:slug`,
|
|
3165
|
+
method: "get",
|
|
3166
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/[slug].get")
|
|
3167
|
+
});
|
|
3168
|
+
addServerHandler({
|
|
3169
|
+
route: `${cmsApiPath}/:collection/:id`,
|
|
3170
|
+
method: "put",
|
|
3171
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/[id].put")
|
|
3172
|
+
});
|
|
3173
|
+
addServerHandler({
|
|
3174
|
+
route: `${cmsApiPath}/:collection/:id`,
|
|
3175
|
+
method: "delete",
|
|
3176
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/[id].delete")
|
|
3177
|
+
});
|
|
3178
|
+
addServerHandler({
|
|
3179
|
+
route: `${cmsApiPath}/:collection`,
|
|
3180
|
+
method: "get",
|
|
3181
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/index.get")
|
|
3182
|
+
});
|
|
3183
|
+
addServerHandler({
|
|
3184
|
+
route: `${cmsApiPath}/:collection`,
|
|
3185
|
+
method: "post",
|
|
3186
|
+
handler: resolver.resolve("./runtime/server/routes/cms/[collection]/index.post")
|
|
3187
|
+
});
|
|
3188
|
+
if (cmsConfig.admin !== false) {
|
|
3189
|
+
extendPages((pages) => {
|
|
3190
|
+
pages.push({
|
|
3191
|
+
name: "qarpeo-cms",
|
|
3192
|
+
path: cmsPath,
|
|
3193
|
+
file: resolver.resolve("./runtime/app/pages/cms.vue"),
|
|
3194
|
+
meta: { layout: false }
|
|
3195
|
+
});
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
addImports([
|
|
3199
|
+
{ name: "useCMS", from: resolver.resolve("./runtime/app/composables/cms") },
|
|
3200
|
+
{
|
|
3201
|
+
name: "queryCollectionNavigation",
|
|
3202
|
+
from: resolver.resolve("./runtime/app/composables/cms")
|
|
3203
|
+
},
|
|
3204
|
+
{ name: "queryCollection", from: resolver.resolve("./runtime/app/composables/cms") },
|
|
3205
|
+
{
|
|
3206
|
+
name: "queryCollectionItemSurroundings",
|
|
3207
|
+
from: resolver.resolve("./runtime/app/composables/cms")
|
|
3208
|
+
},
|
|
3209
|
+
{ name: "useCMSLocale", from: resolver.resolve("./runtime/app/composables/cms") },
|
|
3210
|
+
{ name: "useDocsSearch", from: resolver.resolve("./runtime/app/composables/cms") },
|
|
3211
|
+
{ name: "useDocsVersion", from: resolver.resolve("./runtime/app/composables/docs-version") },
|
|
3212
|
+
{ name: "useCMSPreview", from: resolver.resolve("./runtime/app/composables/cms-preview") }
|
|
3213
|
+
]);
|
|
3214
|
+
addComponent({
|
|
3215
|
+
name: "CMSContent",
|
|
3216
|
+
filePath: resolver.resolve("./runtime/app/components/CMSContent")
|
|
3217
|
+
});
|
|
3218
|
+
addComponent({
|
|
3219
|
+
name: "CMSImage",
|
|
3220
|
+
filePath: resolver.resolve("./runtime/app/components/CMSImage")
|
|
3221
|
+
});
|
|
3222
|
+
addComponent({
|
|
3223
|
+
name: "ContentRenderer",
|
|
3224
|
+
filePath: resolver.resolve("./runtime/app/components/ContentRenderer")
|
|
3225
|
+
});
|
|
3226
|
+
addComponent({
|
|
3227
|
+
name: "CMSBlocks",
|
|
3228
|
+
filePath: resolver.resolve("./runtime/app/components/CMSBlocks")
|
|
3229
|
+
});
|
|
3230
|
+
addComponent({
|
|
3231
|
+
name: "CMSPageBuilder",
|
|
3232
|
+
filePath: resolver.resolve("./runtime/app/components/CMSBlocks")
|
|
3233
|
+
});
|
|
3234
|
+
addComponent({
|
|
3235
|
+
name: "CMSLocaleSwitcher",
|
|
3236
|
+
filePath: resolver.resolve("./runtime/app/components/CMSLocaleSwitcher")
|
|
3237
|
+
});
|
|
3238
|
+
addComponent({
|
|
3239
|
+
name: "CMSVersionSwitcher",
|
|
3240
|
+
filePath: resolver.resolve("./runtime/app/components/CMSVersionSwitcher")
|
|
3241
|
+
});
|
|
3242
|
+
addComponent({
|
|
3243
|
+
name: "DocsVersionSwitcher",
|
|
3244
|
+
filePath: resolver.resolve("./runtime/app/components/CMSVersionSwitcher")
|
|
3245
|
+
});
|
|
3246
|
+
addComponent({
|
|
3247
|
+
name: "CMSVersionBanner",
|
|
3248
|
+
filePath: resolver.resolve("./runtime/app/components/CMSVersionBanner")
|
|
3249
|
+
});
|
|
3250
|
+
addComponent({
|
|
3251
|
+
name: "DocsVersionBanner",
|
|
3252
|
+
filePath: resolver.resolve("./runtime/app/components/CMSVersionBanner")
|
|
3253
|
+
});
|
|
3254
|
+
addComponent({
|
|
3255
|
+
name: "CMSPreviewBanner",
|
|
3256
|
+
filePath: resolver.resolve("./runtime/app/components/CMSPreviewBanner")
|
|
3257
|
+
});
|
|
3258
|
+
addComponent({
|
|
3259
|
+
name: "DocsPreviewBanner",
|
|
3260
|
+
filePath: resolver.resolve("./runtime/app/components/CMSPreviewBanner")
|
|
3261
|
+
});
|
|
3262
|
+
addServerImports([
|
|
3263
|
+
{ name: "getCMSConfig", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3264
|
+
{ name: "getCMSCollection", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3265
|
+
{ name: "queryCMSEntries", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3266
|
+
{ name: "getCMSEntry", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3267
|
+
{ name: "createCMSEntry", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3268
|
+
{ name: "updateCMSEntry", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3269
|
+
{ name: "deleteCMSEntry", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3270
|
+
{ name: "publishCMSEntry", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3271
|
+
{ name: "renderMarkdown", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3272
|
+
{ name: "parseFrontmatter", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3273
|
+
{ name: "generatePreviewToken", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3274
|
+
{ name: "verifyPreviewToken", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3275
|
+
{ name: "seedCollectionsFromConfig", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3276
|
+
{ name: "syncLocalContentFiles", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3277
|
+
{ name: "ensureCMSTables", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3278
|
+
{ name: "ensureCMSSynced", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3279
|
+
{ name: "getCMSEntryByPath", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3280
|
+
{ name: "getCMSEntrySurroundings", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3281
|
+
{ name: "getCMSNavigationTree", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3282
|
+
{ name: "searchDocs", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3283
|
+
{ name: "buildFtsQuery", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3284
|
+
{ name: "rebuildCMSFTS", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3285
|
+
{ name: "verifyGitHubSignature", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3286
|
+
{ name: "invalidateCMSEntryCache", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3287
|
+
{ name: "renderPageMarkdown", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3288
|
+
{ name: "preprocessMDC", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3289
|
+
{ name: "extractTOC", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3290
|
+
{ name: "computeEntryPath", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3291
|
+
{ name: "slugifyHeading", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3292
|
+
{ name: "formatEntryAsMarkdown", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3293
|
+
{ name: "syncEntryToGit", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3294
|
+
{ name: "submitCMSEntryForReview", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3295
|
+
{ name: "rejectCMSEntryReview", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3296
|
+
{ name: "resolveCollectionApproval", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3297
|
+
{ name: "defineCMSComponent", from: resolver.resolve("./runtime/server/utils/cms") },
|
|
3298
|
+
{
|
|
3299
|
+
name: "publishDueScheduledEntries",
|
|
3300
|
+
from: resolver.resolve("./runtime/server/utils/cms")
|
|
3301
|
+
},
|
|
3302
|
+
{ name: "fireCMSWebhooks", from: resolver.resolve("./runtime/server/utils/cms-events") },
|
|
3303
|
+
{
|
|
3304
|
+
name: "fireCMSDeployTrigger",
|
|
3305
|
+
from: resolver.resolve("./runtime/server/utils/cms-events")
|
|
3306
|
+
},
|
|
3307
|
+
{ name: "buildRSSXml", from: resolver.resolve("./runtime/server/utils/feed") },
|
|
3308
|
+
{ name: "buildAtomXml", from: resolver.resolve("./runtime/server/utils/feed") },
|
|
3309
|
+
{ name: "rowToFeedEntry", from: resolver.resolve("./runtime/server/utils/feed") }
|
|
3310
|
+
]);
|
|
3311
|
+
}
|
|
3312
|
+
if (options.realtime || options.agents) {
|
|
3313
|
+
const exportsTemplate = addTemplate({
|
|
3314
|
+
filename: "qarpeo-cloudflare-exports.ts",
|
|
3315
|
+
getContents: () => {
|
|
3316
|
+
const lines = [];
|
|
3317
|
+
if (options.realtime) {
|
|
3318
|
+
lines.push(
|
|
3319
|
+
`export { QarpeoRoomDO } from "${resolver.resolve("./runtime/server/durable-objects/room")}";`
|
|
3320
|
+
);
|
|
3321
|
+
}
|
|
3322
|
+
if (options.agents) {
|
|
3323
|
+
lines.push(`import "#qarpeo/agents-registry";`);
|
|
3324
|
+
lines.push(
|
|
3325
|
+
`export { QarpeoAgentDO } from "${resolver.resolve("./runtime/server/durable-objects/agent")}";`
|
|
3326
|
+
);
|
|
3327
|
+
}
|
|
3328
|
+
return lines.join("\n") + "\n";
|
|
3329
|
+
},
|
|
3330
|
+
write: true
|
|
3331
|
+
});
|
|
3332
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
3333
|
+
nitroConfig.cloudflare = nitroConfig.cloudflare || {};
|
|
3334
|
+
if (!nitroConfig.cloudflare.exports) {
|
|
3335
|
+
nitroConfig.cloudflare.exports = exportsTemplate.dst;
|
|
3336
|
+
}
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3339
|
+
if (options.realtime) {
|
|
3340
|
+
const realtimeConfig = typeof options.realtime === "object" ? options.realtime : {};
|
|
3341
|
+
const realtimePath = realtimeConfig.path || "/api/realtime/ws";
|
|
3342
|
+
const realtimeBinding = realtimeConfig.binding || "QARPEO_ROOM_DO";
|
|
3343
|
+
const rc = nuxt.options.runtimeConfig;
|
|
3344
|
+
rc.qarpeo = rc.qarpeo || {};
|
|
3345
|
+
rc.qarpeo.realtime = {
|
|
3346
|
+
path: realtimePath,
|
|
3347
|
+
binding: realtimeBinding,
|
|
3348
|
+
presence: realtimeConfig.presence !== false,
|
|
3349
|
+
requireAuth: realtimeConfig.requireAuth === true || realtimeConfig.auth === true,
|
|
3350
|
+
heartbeatInterval: realtimeConfig.heartbeatInterval || realtimeConfig.heartbeat || 3e4,
|
|
3351
|
+
maxConnectionsPerRoom: realtimeConfig.maxConnectionsPerRoom || 100,
|
|
3352
|
+
historyLimit: realtimeConfig.historyLimit || 50
|
|
3353
|
+
};
|
|
3354
|
+
addServerHandler({
|
|
3355
|
+
route: realtimePath,
|
|
3356
|
+
method: "get",
|
|
3357
|
+
handler: resolver.resolve("./runtime/server/routes/realtime/ws.get")
|
|
3358
|
+
});
|
|
3359
|
+
addServerHandler({
|
|
3360
|
+
route: "/api/realtime/broadcast",
|
|
3361
|
+
method: "post",
|
|
3362
|
+
handler: resolver.resolve("./runtime/server/routes/realtime/broadcast.post")
|
|
3363
|
+
});
|
|
3364
|
+
addServerHandler({
|
|
3365
|
+
route: "/api/realtime/presence",
|
|
3366
|
+
method: "get",
|
|
3367
|
+
handler: resolver.resolve("./runtime/server/routes/realtime/presence.get")
|
|
3368
|
+
});
|
|
3369
|
+
addServerHandler({
|
|
3370
|
+
route: "/api/realtime/state",
|
|
3371
|
+
method: "get",
|
|
3372
|
+
handler: resolver.resolve("./runtime/server/routes/realtime/state.get")
|
|
3373
|
+
});
|
|
3374
|
+
addServerHandler({
|
|
3375
|
+
route: "/api/realtime/state",
|
|
3376
|
+
method: "post",
|
|
3377
|
+
handler: resolver.resolve("./runtime/server/routes/realtime/state.post")
|
|
3378
|
+
});
|
|
3379
|
+
addServerHandler({
|
|
3380
|
+
route: "/api/realtime/history",
|
|
3381
|
+
method: "get",
|
|
3382
|
+
handler: resolver.resolve("./runtime/server/routes/realtime/history.get")
|
|
3383
|
+
});
|
|
3384
|
+
addServerHandler({
|
|
3385
|
+
route: "/api/realtime/history",
|
|
3386
|
+
method: "delete",
|
|
3387
|
+
handler: resolver.resolve("./runtime/server/routes/realtime/history.delete")
|
|
3388
|
+
});
|
|
3389
|
+
addImports([
|
|
3390
|
+
{
|
|
3391
|
+
name: "useRealtime",
|
|
3392
|
+
from: resolver.resolve("./runtime/app/composables/realtime")
|
|
3393
|
+
},
|
|
3394
|
+
{
|
|
3395
|
+
name: "usePresence",
|
|
3396
|
+
from: resolver.resolve("./runtime/app/composables/realtime")
|
|
3397
|
+
},
|
|
3398
|
+
{
|
|
3399
|
+
name: "useRoomState",
|
|
3400
|
+
from: resolver.resolve("./runtime/app/composables/realtime")
|
|
3401
|
+
}
|
|
3402
|
+
]);
|
|
3403
|
+
addServerImports([
|
|
3404
|
+
{ name: "getRoomDurableObject", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3405
|
+
{ name: "broadcastToRoom", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3406
|
+
{ name: "getRoomPresence", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3407
|
+
{ name: "getRoomHistory", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3408
|
+
{ name: "clearRoomHistory", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3409
|
+
{ name: "getRoomState", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3410
|
+
{ name: "setRoomState", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3411
|
+
{ name: "patchRoomState", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3412
|
+
{ name: "disconnectRoomUser", from: resolver.resolve("./runtime/server/utils/realtime") },
|
|
3413
|
+
{
|
|
3414
|
+
name: "defineRealtimeHandler",
|
|
3415
|
+
from: resolver.resolve("./runtime/server/utils/realtime")
|
|
3416
|
+
},
|
|
3417
|
+
{ name: "QarpeoRoomDO", from: resolver.resolve("./runtime/server/durable-objects/room") }
|
|
3418
|
+
]);
|
|
3419
|
+
}
|
|
3420
|
+
if (options.payments) {
|
|
3421
|
+
const paymentsConfig = typeof options.payments === "object" ? options.payments : {};
|
|
3422
|
+
const paymentsPrefix = paymentsConfig.prefix || "/api/payments";
|
|
3423
|
+
const appRuntimeConfig = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3424
|
+
appRuntimeConfig.qarpeo = appRuntimeConfig.qarpeo || {};
|
|
3425
|
+
appRuntimeConfig.qarpeo.payments = {
|
|
3426
|
+
provider: paymentsConfig.provider || "stripe",
|
|
3427
|
+
secretKey: paymentsConfig.secretKey || "",
|
|
3428
|
+
webhookSecret: paymentsConfig.webhookSecret || "",
|
|
3429
|
+
prefix: paymentsPrefix,
|
|
3430
|
+
plans: paymentsConfig.plans || {},
|
|
3431
|
+
portalReturnUrl: paymentsConfig.portalReturnUrl || "/",
|
|
3432
|
+
checkoutUrls: paymentsConfig.checkoutUrls || {},
|
|
3433
|
+
trialDays: paymentsConfig.trialDays,
|
|
3434
|
+
currency: paymentsConfig.currency,
|
|
3435
|
+
paddle: paymentsConfig.paddle || {}
|
|
3436
|
+
};
|
|
3437
|
+
const publicConfig = appRuntimeConfig.public = appRuntimeConfig.public || {};
|
|
3438
|
+
publicConfig.qarpeo = publicConfig.qarpeo || {};
|
|
3439
|
+
publicConfig.qarpeo.payments = {
|
|
3440
|
+
prefix: paymentsPrefix
|
|
3441
|
+
};
|
|
3442
|
+
addServerHandler({
|
|
3443
|
+
route: `${paymentsPrefix}/webhook`,
|
|
3444
|
+
method: "post",
|
|
3445
|
+
handler: resolver.resolve("./runtime/server/routes/payments/webhook.post")
|
|
3446
|
+
});
|
|
3447
|
+
addServerHandler({
|
|
3448
|
+
route: `${paymentsPrefix}/checkout`,
|
|
3449
|
+
method: "post",
|
|
3450
|
+
handler: resolver.resolve("./runtime/server/routes/payments/checkout.post")
|
|
3451
|
+
});
|
|
3452
|
+
addServerHandler({
|
|
3453
|
+
route: `${paymentsPrefix}/portal`,
|
|
3454
|
+
method: "post",
|
|
3455
|
+
handler: resolver.resolve("./runtime/server/routes/payments/portal.post")
|
|
3456
|
+
});
|
|
3457
|
+
addServerHandler({
|
|
3458
|
+
route: `${paymentsPrefix}/subscription`,
|
|
3459
|
+
method: "get",
|
|
3460
|
+
handler: resolver.resolve("./runtime/server/routes/payments/subscription.get")
|
|
3461
|
+
});
|
|
3462
|
+
addServerHandler({
|
|
3463
|
+
route: `${paymentsPrefix}/cancel`,
|
|
3464
|
+
method: "post",
|
|
3465
|
+
handler: resolver.resolve("./runtime/server/routes/payments/cancel.post")
|
|
3466
|
+
});
|
|
3467
|
+
addServerHandler({
|
|
3468
|
+
route: `${paymentsPrefix}/pause`,
|
|
3469
|
+
method: "post",
|
|
3470
|
+
handler: resolver.resolve("./runtime/server/routes/payments/pause.post")
|
|
3471
|
+
});
|
|
3472
|
+
addServerHandler({
|
|
3473
|
+
route: `${paymentsPrefix}/change-plan`,
|
|
3474
|
+
method: "post",
|
|
3475
|
+
handler: resolver.resolve("./runtime/server/routes/payments/change-plan.post")
|
|
3476
|
+
});
|
|
3477
|
+
addServerHandler({
|
|
3478
|
+
route: `${paymentsPrefix}/usage`,
|
|
3479
|
+
method: "post",
|
|
3480
|
+
handler: resolver.resolve("./runtime/server/routes/payments/usage.post")
|
|
3481
|
+
});
|
|
3482
|
+
addServerHandler({
|
|
3483
|
+
route: `${paymentsPrefix}/usage`,
|
|
3484
|
+
method: "get",
|
|
3485
|
+
handler: resolver.resolve("./runtime/server/routes/payments/usage.get")
|
|
3486
|
+
});
|
|
3487
|
+
addImports([
|
|
3488
|
+
{ name: "useSubscription", from: resolver.resolve("./runtime/app/composables/payments") },
|
|
3489
|
+
{ name: "useCheckout", from: resolver.resolve("./runtime/app/composables/payments") }
|
|
3490
|
+
]);
|
|
3491
|
+
addServerImports([
|
|
3492
|
+
{ name: "getSubscription", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3493
|
+
{ name: "requireSubscription", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3494
|
+
{ name: "getPaymentsConfig", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3495
|
+
{ name: "ensurePaymentsTables", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3496
|
+
{
|
|
3497
|
+
name: "createCheckoutSession",
|
|
3498
|
+
from: resolver.resolve("./runtime/server/utils/payments")
|
|
3499
|
+
},
|
|
3500
|
+
{
|
|
3501
|
+
name: "createCustomerPortalSession",
|
|
3502
|
+
from: resolver.resolve("./runtime/server/utils/payments")
|
|
3503
|
+
},
|
|
3504
|
+
{
|
|
3505
|
+
name: "processPaymentWebhook",
|
|
3506
|
+
from: resolver.resolve("./runtime/server/utils/payments")
|
|
3507
|
+
},
|
|
3508
|
+
{
|
|
3509
|
+
name: "verifyStripeSignature",
|
|
3510
|
+
from: resolver.resolve("./runtime/server/utils/payments")
|
|
3511
|
+
},
|
|
3512
|
+
{
|
|
3513
|
+
name: "verifyLemonSqueezySignature",
|
|
3514
|
+
from: resolver.resolve("./runtime/server/utils/payments")
|
|
3515
|
+
},
|
|
3516
|
+
{ name: "verifyPolarSignature", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3517
|
+
{
|
|
3518
|
+
name: "verifyPaddleSignature",
|
|
3519
|
+
from: resolver.resolve("./runtime/server/utils/payments")
|
|
3520
|
+
},
|
|
3521
|
+
{ name: "reportUsage", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3522
|
+
{ name: "getUsageSummary", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3523
|
+
{ name: "cancelSubscription", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3524
|
+
{ name: "pauseSubscription", from: resolver.resolve("./runtime/server/utils/payments") },
|
|
3525
|
+
{ name: "changePlan", from: resolver.resolve("./runtime/server/utils/payments") }
|
|
3526
|
+
]);
|
|
3527
|
+
}
|
|
3528
|
+
if (options.agents) {
|
|
3529
|
+
const agentsConfig = typeof options.agents === "object" ? options.agents : {};
|
|
3530
|
+
const agentsPath = agentsConfig.path || "/api/agents";
|
|
3531
|
+
const agentsBinding = agentsConfig.binding || "QARPEO_AGENT_DO";
|
|
3532
|
+
const defaultModel = agentsConfig.defaultModel || "@cf/meta/llama-3.3-70b-instruct";
|
|
3533
|
+
const requireAuth = agentsConfig.requireAuth ?? agentsConfig.auth ?? false;
|
|
3534
|
+
const maxSteps = agentsConfig.maxSteps ?? 5;
|
|
3535
|
+
const maxContextMessages = agentsConfig.maxContextMessages ?? 30;
|
|
3536
|
+
const agentFiles = findAgentFiles(
|
|
3537
|
+
nuxt.options._layers || [{ cwd: nuxt.options.rootDir, config: nuxt.options }],
|
|
3538
|
+
agentsConfig.dir || "server/agents"
|
|
3539
|
+
);
|
|
3540
|
+
const rc = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3541
|
+
rc.qarpeo = rc.qarpeo || {};
|
|
3542
|
+
rc.qarpeo.agents = {
|
|
3543
|
+
enabled: true,
|
|
3544
|
+
path: agentsPath,
|
|
3545
|
+
binding: agentsBinding,
|
|
3546
|
+
defaultModel,
|
|
3547
|
+
requireAuth,
|
|
3548
|
+
maxSteps,
|
|
3549
|
+
maxContextMessages,
|
|
3550
|
+
discovered: agentFiles.map((a) => a.name)
|
|
3551
|
+
};
|
|
3552
|
+
const agentsTemplate = addTemplate({
|
|
3553
|
+
filename: "qarpeo/agents.mjs",
|
|
3554
|
+
write: true,
|
|
3555
|
+
getContents: () => {
|
|
3556
|
+
const aiUtilsPath = resolver.resolve("./runtime/server/utils/ai").replace(/\\/g, "/");
|
|
3557
|
+
const lines = [
|
|
3558
|
+
"// Auto-generated by qarpeo agent discovery",
|
|
3559
|
+
`import { registerAgentDefinition } from "${aiUtilsPath}";`
|
|
3560
|
+
];
|
|
3561
|
+
agentFiles.forEach((file, idx) => {
|
|
3562
|
+
lines.push(`import agent_${idx} from "${file.importPath.replace(/\\/g, "/")}";`);
|
|
3563
|
+
lines.push(`if (agent_${idx}) {`);
|
|
3564
|
+
lines.push(` const def = agent_${idx}.default || agent_${idx};`);
|
|
3565
|
+
lines.push(` if (def && typeof def === 'object') registerAgentDefinition(def);`);
|
|
3566
|
+
lines.push(`}`);
|
|
3567
|
+
});
|
|
3568
|
+
lines.push(`export default {};`);
|
|
3569
|
+
return lines.join("\n");
|
|
3570
|
+
}
|
|
3571
|
+
});
|
|
3572
|
+
nuxt.options.alias["#qarpeo/agents-registry"] = agentsTemplate.dst;
|
|
3573
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/agents"));
|
|
3574
|
+
addServerHandler({
|
|
3575
|
+
route: `${agentsPath}/:agent/chat`,
|
|
3576
|
+
method: "post",
|
|
3577
|
+
handler: resolver.resolve("./runtime/server/routes/agents/[agent]/chat.post")
|
|
3578
|
+
});
|
|
3579
|
+
addServerHandler({
|
|
3580
|
+
route: `${agentsPath}/:agent/history`,
|
|
3581
|
+
method: "get",
|
|
3582
|
+
handler: resolver.resolve("./runtime/server/routes/agents/[agent]/history.get")
|
|
3583
|
+
});
|
|
3584
|
+
addServerHandler({
|
|
3585
|
+
route: `${agentsPath}/:agent/clear`,
|
|
3586
|
+
method: "post",
|
|
3587
|
+
handler: resolver.resolve("./runtime/server/routes/agents/[agent]/clear.post")
|
|
3588
|
+
});
|
|
3589
|
+
addImports([
|
|
3590
|
+
{
|
|
3591
|
+
name: "useChat",
|
|
3592
|
+
from: resolver.resolve("./runtime/app/composables/chat")
|
|
3593
|
+
},
|
|
3594
|
+
{
|
|
3595
|
+
name: "useAgentChat",
|
|
3596
|
+
from: resolver.resolve("./runtime/app/composables/chat")
|
|
3597
|
+
}
|
|
3598
|
+
]);
|
|
3599
|
+
addServerImports([
|
|
3600
|
+
{ name: "defineAgent", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3601
|
+
{ name: "defineTool", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3602
|
+
{ name: "registerAgentDefinition", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3603
|
+
{ name: "getAgentDefinition", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3604
|
+
{ name: "getAllAgentDefinitions", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3605
|
+
{ name: "useAgent", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3606
|
+
{ name: "streamText", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3607
|
+
{ name: "generateText", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3608
|
+
{ name: "embedText", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3609
|
+
{ name: "similaritySearch", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3610
|
+
{ name: "generateImage", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3611
|
+
{ name: "textToImage", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3612
|
+
{ name: "generateSpeech", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3613
|
+
{ name: "textToSpeech", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3614
|
+
{ name: "transcribeAudio", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3615
|
+
{ name: "speechToText", from: resolver.resolve("./runtime/server/utils/ai") },
|
|
3616
|
+
{ name: "QarpeoAgentDO", from: resolver.resolve("./runtime/server/durable-objects/agent") }
|
|
3617
|
+
]);
|
|
3618
|
+
}
|
|
3619
|
+
if (options.mail) {
|
|
3620
|
+
const mailConfig = typeof options.mail === "object" ? options.mail : {};
|
|
3621
|
+
const rc = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3622
|
+
rc.qarpeo = rc.qarpeo || {};
|
|
3623
|
+
rc.qarpeo.mail = {
|
|
3624
|
+
enabled: true,
|
|
3625
|
+
provider: mailConfig.provider || "cloudflare",
|
|
3626
|
+
from: mailConfig.from || "",
|
|
3627
|
+
devMailbox: mailConfig.devMailbox !== false,
|
|
3628
|
+
branding: mailConfig.branding || {},
|
|
3629
|
+
queue: mailConfig.queue || false,
|
|
3630
|
+
tracking: mailConfig.tracking || {}
|
|
3631
|
+
};
|
|
3632
|
+
addServerHandler({
|
|
3633
|
+
route: "/api/mail/inbox",
|
|
3634
|
+
method: "get",
|
|
3635
|
+
handler: resolver.resolve("./runtime/server/routes/mail/inbox.get")
|
|
3636
|
+
});
|
|
3637
|
+
addServerHandler({
|
|
3638
|
+
route: "/api/mail/inbox/:id",
|
|
3639
|
+
method: "get",
|
|
3640
|
+
handler: resolver.resolve("./runtime/server/routes/mail/inbox/[id].get")
|
|
3641
|
+
});
|
|
3642
|
+
addServerHandler({
|
|
3643
|
+
route: "/__qarpeo/mail/track/open/:id",
|
|
3644
|
+
method: "get",
|
|
3645
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/mail/track/open/[id].get")
|
|
3646
|
+
});
|
|
3647
|
+
addServerHandler({
|
|
3648
|
+
route: "/__qarpeo/mail/track/click/:id",
|
|
3649
|
+
method: "get",
|
|
3650
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/mail/track/click/[id].get")
|
|
3651
|
+
});
|
|
3652
|
+
addServerHandler({
|
|
3653
|
+
route: "/__qarpeo/mail/bounce",
|
|
3654
|
+
method: "post",
|
|
3655
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/mail/bounce.post")
|
|
3656
|
+
});
|
|
3657
|
+
addServerHandler({
|
|
3658
|
+
route: "/api/mail/bounce",
|
|
3659
|
+
method: "post",
|
|
3660
|
+
handler: resolver.resolve("./runtime/server/routes/mail/bounce.post")
|
|
3661
|
+
});
|
|
3662
|
+
addServerHandler({
|
|
3663
|
+
route: "/api/mail/webhooks",
|
|
3664
|
+
method: "post",
|
|
3665
|
+
handler: resolver.resolve("./runtime/server/routes/mail/webhooks.post")
|
|
3666
|
+
});
|
|
3667
|
+
addServerHandler({
|
|
3668
|
+
route: "/api/mail/unsubscribe",
|
|
3669
|
+
handler: resolver.resolve("./runtime/server/routes/mail/unsubscribe")
|
|
3670
|
+
});
|
|
3671
|
+
addServerHandler({
|
|
3672
|
+
route: "/api/mail/suppressions",
|
|
3673
|
+
method: "get",
|
|
3674
|
+
handler: resolver.resolve("./runtime/server/routes/mail/suppressions/index.get")
|
|
3675
|
+
});
|
|
3676
|
+
addServerHandler({
|
|
3677
|
+
route: "/api/mail/suppressions",
|
|
3678
|
+
method: "post",
|
|
3679
|
+
handler: resolver.resolve("./runtime/server/routes/mail/suppressions/index.post")
|
|
3680
|
+
});
|
|
3681
|
+
addServerHandler({
|
|
3682
|
+
route: "/api/mail/suppressions/:email",
|
|
3683
|
+
method: "delete",
|
|
3684
|
+
handler: resolver.resolve("./runtime/server/routes/mail/suppressions/[email].delete")
|
|
3685
|
+
});
|
|
3686
|
+
addServerImports([
|
|
3687
|
+
{ name: "sendMail", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3688
|
+
{ name: "useMail", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3689
|
+
{ name: "getDevMailbox", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3690
|
+
{ name: "clearDevMailbox", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3691
|
+
{ name: "recordEmailOpen", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3692
|
+
{ name: "recordEmailClick", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3693
|
+
{ name: "recordEmailBounce", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3694
|
+
{ name: "suppressEmail", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3695
|
+
{ name: "isEmailSuppressed", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3696
|
+
{ name: "unsuppressEmail", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3697
|
+
{ name: "listSuppressedEmails", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3698
|
+
{ name: "recordSoftBounce", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3699
|
+
{ name: "generateUnsubscribeToken", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3700
|
+
{ name: "verifyUnsubscribeToken", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3701
|
+
{ name: "buildListUnsubscribeHeaders", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3702
|
+
{ name: "injectEmailTracking", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3703
|
+
{ name: "deliverMailDirect", from: resolver.resolve("./runtime/server/utils/mail") },
|
|
3704
|
+
{
|
|
3705
|
+
name: "renderEmailTemplate",
|
|
3706
|
+
from: resolver.resolve("./runtime/server/utils/email-templates")
|
|
3707
|
+
},
|
|
3708
|
+
{
|
|
3709
|
+
name: "defineEmailTemplate",
|
|
3710
|
+
from: resolver.resolve("./runtime/server/utils/email-templates")
|
|
3711
|
+
},
|
|
3712
|
+
{
|
|
3713
|
+
name: "renderMarkdownEmail",
|
|
3714
|
+
from: resolver.resolve("./runtime/server/utils/email-templates")
|
|
3715
|
+
},
|
|
3716
|
+
{
|
|
3717
|
+
name: "renderEmailButton",
|
|
3718
|
+
from: resolver.resolve("./runtime/server/utils/email-templates")
|
|
3719
|
+
},
|
|
3720
|
+
{
|
|
3721
|
+
name: "renderEmailLayout",
|
|
3722
|
+
from: resolver.resolve("./runtime/server/utils/email-templates")
|
|
3723
|
+
}
|
|
3724
|
+
]);
|
|
3725
|
+
}
|
|
3726
|
+
if (options.analytics) {
|
|
3727
|
+
const analyticsConfig = typeof options.analytics === "object" ? options.analytics : {};
|
|
3728
|
+
const analyticsPath = analyticsConfig.path || "/api/analytics";
|
|
3729
|
+
const bindingName = analyticsConfig.binding || "ANALYTICS";
|
|
3730
|
+
const datasetName = analyticsConfig.dataset || process.env.QARPEO_ANALYTICS_DATASET || `${bindingName.toLowerCase().replace(/[^a-z0-9-]/g, "-")}-prod`;
|
|
3731
|
+
const rc = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3732
|
+
rc.qarpeo = rc.qarpeo || {};
|
|
3733
|
+
rc.qarpeo.analytics = {
|
|
3734
|
+
enabled: true,
|
|
3735
|
+
binding: bindingName,
|
|
3736
|
+
dataset: datasetName,
|
|
3737
|
+
accountId: analyticsConfig.accountId || process.env.CLOUDFLARE_ACCOUNT_ID || process.env.CF_ACCOUNT_ID || "",
|
|
3738
|
+
apiToken: analyticsConfig.apiToken || process.env.CLOUDFLARE_API_TOKEN || process.env.CF_API_TOKEN || "",
|
|
3739
|
+
siteId: analyticsConfig.siteId || "",
|
|
3740
|
+
autoTrack: analyticsConfig.autoTrack !== false,
|
|
3741
|
+
path: analyticsPath
|
|
3742
|
+
};
|
|
3743
|
+
if (analyticsConfig.autoTrack !== false) {
|
|
3744
|
+
addServerHandler({
|
|
3745
|
+
handler: resolver.resolve("./runtime/server/middleware/tracker"),
|
|
3746
|
+
middleware: true,
|
|
3747
|
+
route: "/**"
|
|
3748
|
+
});
|
|
3749
|
+
}
|
|
3750
|
+
addServerHandler({
|
|
3751
|
+
route: `${analyticsPath}/pageviews`,
|
|
3752
|
+
method: "get",
|
|
3753
|
+
handler: resolver.resolve("./runtime/server/routes/analytics/pageviews.get")
|
|
3754
|
+
});
|
|
3755
|
+
addServerHandler({
|
|
3756
|
+
route: `${analyticsPath}/events`,
|
|
3757
|
+
method: "get",
|
|
3758
|
+
handler: resolver.resolve("./runtime/server/routes/analytics/events.get")
|
|
3759
|
+
});
|
|
3760
|
+
addServerHandler({
|
|
3761
|
+
route: `${analyticsPath}/summary`,
|
|
3762
|
+
method: "get",
|
|
3763
|
+
handler: resolver.resolve("./runtime/server/routes/analytics/summary.get")
|
|
3764
|
+
});
|
|
3765
|
+
addImports([
|
|
3766
|
+
{
|
|
3767
|
+
name: "useAnalyticsDashboard",
|
|
3768
|
+
from: resolver.resolve("./runtime/app/composables/analytics")
|
|
3769
|
+
}
|
|
3770
|
+
]);
|
|
3771
|
+
addServerImports([
|
|
3772
|
+
{ name: "trackPageview", from: resolver.resolve("./runtime/server/utils/tracker") },
|
|
3773
|
+
{ name: "trackEvent", from: resolver.resolve("./runtime/server/utils/tracker") },
|
|
3774
|
+
{ name: "useTracker", from: resolver.resolve("./runtime/server/utils/tracker") },
|
|
3775
|
+
{
|
|
3776
|
+
name: "queryAnalytics",
|
|
3777
|
+
from: resolver.resolve("./runtime/server/utils/analytics-query")
|
|
3778
|
+
},
|
|
3779
|
+
{
|
|
3780
|
+
name: "useAnalyticsDashboard",
|
|
3781
|
+
from: resolver.resolve("./runtime/server/utils/analytics-query")
|
|
3782
|
+
}
|
|
3783
|
+
]);
|
|
3784
|
+
}
|
|
3785
|
+
if (options.multitenant) {
|
|
3786
|
+
const multitenantConfig = typeof options.multitenant === "object" ? options.multitenant : {};
|
|
3787
|
+
const tenantsPath = multitenantConfig.path || "/api/tenants";
|
|
3788
|
+
const rc = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3789
|
+
rc.qarpeo = rc.qarpeo || {};
|
|
3790
|
+
rc.qarpeo.multitenant = {
|
|
3791
|
+
enabled: true,
|
|
3792
|
+
rootDomains: multitenantConfig.rootDomains || [],
|
|
3793
|
+
customDomains: multitenantConfig.customDomains !== false,
|
|
3794
|
+
provider: multitenantConfig.provider || "cloudflare",
|
|
3795
|
+
zoneId: multitenantConfig.zoneId || process.env.CLOUDFLARE_ZONE_ID || process.env.CF_ZONE_ID || "",
|
|
3796
|
+
apiToken: multitenantConfig.apiToken || process.env.CLOUDFLARE_API_TOKEN || process.env.CF_API_TOKEN || "",
|
|
3797
|
+
cnameTarget: multitenantConfig.cnameTarget || "cname.qarpeo.com",
|
|
3798
|
+
reservedSlugs: multitenantConfig.reservedSlugs || [],
|
|
3799
|
+
headerName: multitenantConfig.headerName || "x-tenant-id",
|
|
3800
|
+
path: tenantsPath,
|
|
3801
|
+
kvBinding: multitenantConfig.kvBinding || "KV"
|
|
3802
|
+
};
|
|
3803
|
+
addServerHandler({
|
|
3804
|
+
handler: resolver.resolve("./runtime/server/middleware/tenancy"),
|
|
3805
|
+
middleware: true,
|
|
3806
|
+
route: "/**"
|
|
3807
|
+
});
|
|
3808
|
+
addServerHandler({
|
|
3809
|
+
route: `${tenantsPath}/current`,
|
|
3810
|
+
method: "get",
|
|
3811
|
+
handler: resolver.resolve("./runtime/server/routes/tenants/current.get")
|
|
3812
|
+
});
|
|
3813
|
+
addServerHandler({
|
|
3814
|
+
route: `${tenantsPath}/:tenant/domains`,
|
|
3815
|
+
method: "get",
|
|
3816
|
+
handler: resolver.resolve("./runtime/server/routes/tenants/[tenant]/domains/index.get")
|
|
3817
|
+
});
|
|
3818
|
+
addServerHandler({
|
|
3819
|
+
route: `${tenantsPath}/:tenant/domains`,
|
|
3820
|
+
method: "post",
|
|
3821
|
+
handler: resolver.resolve("./runtime/server/routes/tenants/[tenant]/domains/index.post")
|
|
3822
|
+
});
|
|
3823
|
+
addServerHandler({
|
|
3824
|
+
route: `${tenantsPath}/:tenant/domains/:domain/verify`,
|
|
3825
|
+
method: "post",
|
|
3826
|
+
handler: resolver.resolve(
|
|
3827
|
+
"./runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post"
|
|
3828
|
+
)
|
|
3829
|
+
});
|
|
3830
|
+
addServerHandler({
|
|
3831
|
+
route: `${tenantsPath}/:tenant/domains/:domain`,
|
|
3832
|
+
method: "delete",
|
|
3833
|
+
handler: resolver.resolve(
|
|
3834
|
+
"./runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete"
|
|
3835
|
+
)
|
|
3836
|
+
});
|
|
3837
|
+
addImports([
|
|
3838
|
+
{
|
|
3839
|
+
name: "useTenant",
|
|
3840
|
+
from: resolver.resolve("./runtime/app/composables/tenant")
|
|
3841
|
+
}
|
|
3842
|
+
]);
|
|
3843
|
+
addServerImports([
|
|
3844
|
+
{ name: "resolveTenant", from: resolver.resolve("./runtime/server/utils/tenant") },
|
|
3845
|
+
{ name: "getTenant", from: resolver.resolve("./runtime/server/utils/tenant") },
|
|
3846
|
+
{ name: "useTenant", from: resolver.resolve("./runtime/server/utils/tenant") },
|
|
3847
|
+
{ name: "setTenant", from: resolver.resolve("./runtime/server/utils/tenant") },
|
|
3848
|
+
{ name: "getTenantById", from: resolver.resolve("./runtime/server/utils/tenant") },
|
|
3849
|
+
{ name: "getTenantBySlug", from: resolver.resolve("./runtime/server/utils/tenant") },
|
|
3850
|
+
{ name: "saveTenant", from: resolver.resolve("./runtime/server/utils/tenant") },
|
|
3851
|
+
{
|
|
3852
|
+
name: "getTenantByOrganization",
|
|
3853
|
+
from: resolver.resolve("./runtime/server/utils/tenant")
|
|
3854
|
+
},
|
|
3855
|
+
{ name: "registerCustomDomain", from: resolver.resolve("./runtime/server/utils/domains") },
|
|
3856
|
+
{ name: "verifyCustomDomain", from: resolver.resolve("./runtime/server/utils/domains") },
|
|
3857
|
+
{ name: "deleteCustomDomain", from: resolver.resolve("./runtime/server/utils/domains") },
|
|
3858
|
+
{ name: "getCustomDomain", from: resolver.resolve("./runtime/server/utils/domains") },
|
|
3859
|
+
{ name: "listTenantDomains", from: resolver.resolve("./runtime/server/utils/domains") },
|
|
3860
|
+
{ name: "getDomainCache", from: resolver.resolve("./runtime/server/utils/domains") },
|
|
3861
|
+
{ name: "setDomainCache", from: resolver.resolve("./runtime/server/utils/domains") },
|
|
3862
|
+
{ name: "removeDomainCache", from: resolver.resolve("./runtime/server/utils/domains") }
|
|
3863
|
+
]);
|
|
3864
|
+
}
|
|
3865
|
+
const rawSite = options.site || options.seo || {};
|
|
3866
|
+
const siteConfig = typeof rawSite === "object" ? { ...rawSite } : {};
|
|
3867
|
+
if (!siteConfig.name) {
|
|
3868
|
+
siteConfig.name = options.name || nuxt.options.site?.name || void 0;
|
|
3869
|
+
}
|
|
3870
|
+
if (siteConfig.name || siteConfig.url || siteConfig.description) {
|
|
3871
|
+
const siteRc = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3872
|
+
siteRc.public = siteRc.public || {};
|
|
3873
|
+
siteRc.public.qarpeo = siteRc.public.qarpeo || {};
|
|
3874
|
+
siteRc.public.qarpeo.site = siteConfig;
|
|
3875
|
+
addPlugin(resolver.resolve("./runtime/app/plugins/seo"));
|
|
3876
|
+
addImports([
|
|
3877
|
+
{ name: "useSite", from: resolver.resolve("./runtime/app/composables/site") },
|
|
3878
|
+
{ name: "useSiteConfig", from: resolver.resolve("./runtime/app/composables/site") },
|
|
3879
|
+
{ name: "useCanonicalUrl", from: resolver.resolve("./runtime/app/composables/site") },
|
|
3880
|
+
{ name: "defineBreadcrumbs", from: resolver.resolve("./runtime/app/composables/site") }
|
|
3881
|
+
]);
|
|
3882
|
+
if (siteConfig.robots !== false) {
|
|
3883
|
+
addServerHandler({
|
|
3884
|
+
route: "/robots.txt",
|
|
3885
|
+
method: "get",
|
|
3886
|
+
handler: resolver.resolve("./runtime/server/routes/robots.txt.get")
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
if (siteConfig.sitemap !== false) {
|
|
3890
|
+
addServerHandler({
|
|
3891
|
+
route: "/sitemap.xml",
|
|
3892
|
+
method: "get",
|
|
3893
|
+
handler: resolver.resolve("./runtime/server/routes/sitemap.xml.get")
|
|
3894
|
+
});
|
|
3895
|
+
}
|
|
3896
|
+
if (siteConfig.feed !== false) {
|
|
3897
|
+
addServerHandler({
|
|
3898
|
+
route: "/feed.xml",
|
|
3899
|
+
method: "get",
|
|
3900
|
+
handler: resolver.resolve("./runtime/server/routes/feed.xml.get")
|
|
3901
|
+
});
|
|
3902
|
+
addServerHandler({
|
|
3903
|
+
route: "/rss.xml",
|
|
3904
|
+
method: "get",
|
|
3905
|
+
handler: resolver.resolve("./runtime/server/routes/rss.xml.get")
|
|
3906
|
+
});
|
|
3907
|
+
addServerHandler({
|
|
3908
|
+
route: "/atom.xml",
|
|
3909
|
+
method: "get",
|
|
3910
|
+
handler: resolver.resolve("./runtime/server/routes/atom.xml.get")
|
|
3911
|
+
});
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
if (options.notifications || options.notify) {
|
|
3915
|
+
const rawNotif = options.notifications || options.notify;
|
|
3916
|
+
const notifConfig = typeof rawNotif === "object" ? rawNotif : {};
|
|
3917
|
+
const notifRc = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
3918
|
+
notifRc.public = notifRc.public || {};
|
|
3919
|
+
notifRc.public.qarpeo = notifRc.public.qarpeo || {};
|
|
3920
|
+
notifRc.public.qarpeo.notifications = {
|
|
3921
|
+
vapidPublicKey: notifConfig.vapid?.publicKey || process.env.NUXT_VAPID_PUBLIC_KEY || process.env.VAPID_PUBLIC_KEY || ""
|
|
3922
|
+
};
|
|
3923
|
+
if (notifConfig.tableName) {
|
|
3924
|
+
process.env.QARPEO_NOTIFICATIONS_TABLE = notifConfig.tableName;
|
|
3925
|
+
}
|
|
3926
|
+
if (notifConfig.vapid?.publicKey) {
|
|
3927
|
+
process.env.NUXT_VAPID_PUBLIC_KEY = notifConfig.vapid.publicKey;
|
|
3928
|
+
}
|
|
3929
|
+
if (notifConfig.vapid?.privateKey) {
|
|
3930
|
+
process.env.NUXT_VAPID_PRIVATE_KEY = notifConfig.vapid.privateKey;
|
|
3931
|
+
}
|
|
3932
|
+
if (notifConfig.vapid?.subject) {
|
|
3933
|
+
process.env.NUXT_VAPID_SUBJECT = notifConfig.vapid.subject;
|
|
3934
|
+
}
|
|
3935
|
+
if (notifConfig.channels) {
|
|
3936
|
+
process.env.QARPEO_NOTIFICATIONS_DEFAULT_CHANNELS = JSON.stringify(notifConfig.channels);
|
|
3937
|
+
}
|
|
3938
|
+
addImports([
|
|
3939
|
+
{
|
|
3940
|
+
name: "useNotifications",
|
|
3941
|
+
from: resolver.resolve("./runtime/app/composables/notifications")
|
|
3942
|
+
}
|
|
3943
|
+
]);
|
|
3944
|
+
addServerImports([
|
|
3945
|
+
{
|
|
3946
|
+
name: "sendNotification",
|
|
3947
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3948
|
+
},
|
|
3949
|
+
{
|
|
3950
|
+
name: "notify",
|
|
3951
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3952
|
+
},
|
|
3953
|
+
{
|
|
3954
|
+
name: "getNotifications",
|
|
3955
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3956
|
+
},
|
|
3957
|
+
{
|
|
3958
|
+
name: "markNotificationRead",
|
|
3959
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3960
|
+
},
|
|
3961
|
+
{
|
|
3962
|
+
name: "markAllNotificationsRead",
|
|
3963
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3964
|
+
},
|
|
3965
|
+
{
|
|
3966
|
+
name: "deleteNotification",
|
|
3967
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3968
|
+
},
|
|
3969
|
+
{
|
|
3970
|
+
name: "savePushSubscription",
|
|
3971
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3972
|
+
},
|
|
3973
|
+
{
|
|
3974
|
+
name: "removePushSubscription",
|
|
3975
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3976
|
+
},
|
|
3977
|
+
{
|
|
3978
|
+
name: "sendWebPush",
|
|
3979
|
+
from: resolver.resolve("./runtime/server/utils/notifications")
|
|
3980
|
+
},
|
|
3981
|
+
{
|
|
3982
|
+
name: "generateVapidKeys",
|
|
3983
|
+
from: resolver.resolve("./runtime/server/utils/vapid")
|
|
3984
|
+
}
|
|
3985
|
+
]);
|
|
3986
|
+
addServerHandler({
|
|
3987
|
+
route: "/api/notifications",
|
|
3988
|
+
method: "get",
|
|
3989
|
+
handler: resolver.resolve("./runtime/server/routes/notifications/index.get")
|
|
3990
|
+
});
|
|
3991
|
+
addServerHandler({
|
|
3992
|
+
route: "/api/notifications/read-all",
|
|
3993
|
+
method: "post",
|
|
3994
|
+
handler: resolver.resolve("./runtime/server/routes/notifications/read-all.post")
|
|
3995
|
+
});
|
|
3996
|
+
addServerHandler({
|
|
3997
|
+
route: "/api/notifications/push/subscribe",
|
|
3998
|
+
method: "post",
|
|
3999
|
+
handler: resolver.resolve("./runtime/server/routes/notifications/push/subscribe.post")
|
|
4000
|
+
});
|
|
4001
|
+
addServerHandler({
|
|
4002
|
+
route: "/api/notifications/push/unsubscribe",
|
|
4003
|
+
method: "post",
|
|
4004
|
+
handler: resolver.resolve("./runtime/server/routes/notifications/push/unsubscribe.post")
|
|
4005
|
+
});
|
|
4006
|
+
addServerHandler({
|
|
4007
|
+
route: "/api/notifications/:id/read",
|
|
4008
|
+
method: "post",
|
|
4009
|
+
handler: resolver.resolve("./runtime/server/routes/notifications/[id]/read.post")
|
|
4010
|
+
});
|
|
4011
|
+
addServerHandler({
|
|
4012
|
+
route: "/api/notifications/:id",
|
|
4013
|
+
method: "get",
|
|
4014
|
+
handler: resolver.resolve("./runtime/server/routes/notifications/[id].get")
|
|
4015
|
+
});
|
|
4016
|
+
addServerHandler({
|
|
4017
|
+
route: "/api/notifications/:id",
|
|
4018
|
+
method: "delete",
|
|
4019
|
+
handler: resolver.resolve("./runtime/server/routes/notifications/[id].delete")
|
|
4020
|
+
});
|
|
4021
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
4022
|
+
nitroConfig.publicAssets = nitroConfig.publicAssets || [];
|
|
4023
|
+
nitroConfig.publicAssets.push({
|
|
4024
|
+
dir: resolver.resolve("./runtime/app/public"),
|
|
4025
|
+
maxAge: 0
|
|
4026
|
+
});
|
|
4027
|
+
});
|
|
4028
|
+
}
|
|
4029
|
+
const devtoolsRaw = options.devtools;
|
|
4030
|
+
const devtoolsOpts = typeof devtoolsRaw === "boolean" ? { enabled: devtoolsRaw } : devtoolsRaw || {};
|
|
4031
|
+
const isDevtoolsEnabled = Boolean(nuxt.options.dev && devtoolsOpts.enabled !== false);
|
|
4032
|
+
const devtoolsRuntimeConfig = {
|
|
4033
|
+
enabled: isDevtoolsEnabled
|
|
4034
|
+
};
|
|
4035
|
+
const qarpeoRuntimeConfig = {
|
|
4036
|
+
devtools: devtoolsRuntimeConfig,
|
|
4037
|
+
db: options.db || options.d1 ? { enabled: true, binding: "DB" } : { enabled: false },
|
|
4038
|
+
kv: options.kv ? { enabled: true, binding: "KV" } : { enabled: false },
|
|
4039
|
+
blob: options.blob || options.r2 ? { enabled: true, binding: "BLOB" } : { enabled: false },
|
|
4040
|
+
auth: options.auth ? { enabled: true } : { enabled: false },
|
|
4041
|
+
cms: options.cms ? { enabled: true } : { enabled: false },
|
|
4042
|
+
payments: options.payments ? { enabled: true } : { enabled: false },
|
|
4043
|
+
jobs: options.jobs || options.queue ? { enabled: true } : { enabled: false },
|
|
4044
|
+
analytics: options.analytics ? { enabled: true, binding: "ANALYTICS" } : { enabled: false },
|
|
4045
|
+
agents: options.agents ? { enabled: true, binding: "QARPEO_AGENT_DO" } : { enabled: false },
|
|
4046
|
+
mail: options.mail ? { enabled: true } : { enabled: false },
|
|
4047
|
+
multitenant: options.multitenant ? { enabled: true } : { enabled: false },
|
|
4048
|
+
ratelimit: options.ratelimit ? { enabled: true } : { enabled: false },
|
|
4049
|
+
notifications: options.notifications || options.notify ? { enabled: true } : { enabled: false }
|
|
4050
|
+
};
|
|
4051
|
+
const devtoolsPublicConfig = (nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {}).public = nuxt.options.runtimeConfig.public || {};
|
|
4052
|
+
devtoolsPublicConfig.qarpeo = devtoolsPublicConfig.qarpeo || {};
|
|
4053
|
+
for (const [key, val] of Object.entries(qarpeoRuntimeConfig)) {
|
|
4054
|
+
if (devtoolsPublicConfig.qarpeo[key] && typeof devtoolsPublicConfig.qarpeo[key] === "object" && val && typeof val === "object") {
|
|
4055
|
+
devtoolsPublicConfig.qarpeo[key] = {
|
|
4056
|
+
...val,
|
|
4057
|
+
...devtoolsPublicConfig.qarpeo[key]
|
|
4058
|
+
};
|
|
4059
|
+
} else {
|
|
4060
|
+
devtoolsPublicConfig.qarpeo[key] = devtoolsPublicConfig.qarpeo[key] ?? val;
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
const devtoolsPrivateConfig = nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {};
|
|
4064
|
+
devtoolsPrivateConfig.qarpeo = devtoolsPrivateConfig.qarpeo || {};
|
|
4065
|
+
for (const [key, val] of Object.entries(qarpeoRuntimeConfig)) {
|
|
4066
|
+
if (devtoolsPrivateConfig.qarpeo[key] && typeof devtoolsPrivateConfig.qarpeo[key] === "object" && val && typeof val === "object") {
|
|
4067
|
+
devtoolsPrivateConfig.qarpeo[key] = {
|
|
4068
|
+
...val,
|
|
4069
|
+
...devtoolsPrivateConfig.qarpeo[key]
|
|
4070
|
+
};
|
|
4071
|
+
} else {
|
|
4072
|
+
devtoolsPrivateConfig.qarpeo[key] = devtoolsPrivateConfig.qarpeo[key] ?? val;
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
if (isDevtoolsEnabled) {
|
|
4076
|
+
addServerHandler({
|
|
4077
|
+
middleware: true,
|
|
4078
|
+
handler: resolver.resolve("./runtime/server/middleware/devtools")
|
|
4079
|
+
});
|
|
4080
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/dev-logs"));
|
|
4081
|
+
extendPages((pages) => {
|
|
4082
|
+
const devtoolsPages = [
|
|
4083
|
+
{
|
|
4084
|
+
name: "qarpeo-devtools",
|
|
4085
|
+
path: "/_qarpeo/devtools",
|
|
4086
|
+
file: resolver.resolve("./runtime/app/pages/devtools.vue"),
|
|
4087
|
+
meta: { layout: false },
|
|
4088
|
+
children: [
|
|
4089
|
+
{
|
|
4090
|
+
name: "qarpeo-devtools-index",
|
|
4091
|
+
path: "",
|
|
4092
|
+
redirect: "/_qarpeo/devtools/overview"
|
|
4093
|
+
},
|
|
4094
|
+
{
|
|
4095
|
+
name: "qarpeo-devtools-overview",
|
|
4096
|
+
path: "overview",
|
|
4097
|
+
file: resolver.resolve("./runtime/app/pages/devtools/overview.vue"),
|
|
4098
|
+
meta: { layout: false }
|
|
4099
|
+
},
|
|
4100
|
+
{
|
|
4101
|
+
name: "qarpeo-devtools-auth",
|
|
4102
|
+
path: "auth",
|
|
4103
|
+
file: resolver.resolve("./runtime/app/pages/devtools/auth.vue"),
|
|
4104
|
+
meta: { layout: false }
|
|
4105
|
+
},
|
|
4106
|
+
{
|
|
4107
|
+
name: "qarpeo-devtools-db",
|
|
4108
|
+
path: "db",
|
|
4109
|
+
file: resolver.resolve("./runtime/app/pages/devtools/db.vue"),
|
|
4110
|
+
meta: { layout: false }
|
|
4111
|
+
},
|
|
4112
|
+
{
|
|
4113
|
+
name: "qarpeo-devtools-kv",
|
|
4114
|
+
path: "kv",
|
|
4115
|
+
file: resolver.resolve("./runtime/app/pages/devtools/kv.vue"),
|
|
4116
|
+
meta: { layout: false }
|
|
4117
|
+
},
|
|
4118
|
+
{
|
|
4119
|
+
name: "qarpeo-devtools-blob",
|
|
4120
|
+
path: "blob",
|
|
4121
|
+
file: resolver.resolve("./runtime/app/pages/devtools/blob.vue"),
|
|
4122
|
+
meta: { layout: false }
|
|
4123
|
+
},
|
|
4124
|
+
{
|
|
4125
|
+
name: "qarpeo-devtools-domains",
|
|
4126
|
+
path: "domains",
|
|
4127
|
+
file: resolver.resolve("./runtime/app/pages/devtools/domains.vue"),
|
|
4128
|
+
meta: { layout: false }
|
|
4129
|
+
},
|
|
4130
|
+
{
|
|
4131
|
+
name: "qarpeo-devtools-analytics",
|
|
4132
|
+
path: "analytics",
|
|
4133
|
+
file: resolver.resolve("./runtime/app/pages/devtools/analytics.vue"),
|
|
4134
|
+
meta: { layout: false }
|
|
4135
|
+
},
|
|
4136
|
+
{
|
|
4137
|
+
name: "qarpeo-devtools-mail",
|
|
4138
|
+
path: "mail",
|
|
4139
|
+
file: resolver.resolve("./runtime/app/pages/devtools/mail.vue"),
|
|
4140
|
+
meta: { layout: false }
|
|
4141
|
+
},
|
|
4142
|
+
{
|
|
4143
|
+
name: "qarpeo-devtools-agents",
|
|
4144
|
+
path: "agents",
|
|
4145
|
+
file: resolver.resolve("./runtime/app/pages/devtools/agents.vue"),
|
|
4146
|
+
meta: { layout: false }
|
|
4147
|
+
},
|
|
4148
|
+
{
|
|
4149
|
+
name: "qarpeo-devtools-logs",
|
|
4150
|
+
path: "logs",
|
|
4151
|
+
file: resolver.resolve("./runtime/app/pages/devtools/logs.vue"),
|
|
4152
|
+
meta: { layout: false }
|
|
4153
|
+
},
|
|
4154
|
+
{
|
|
4155
|
+
name: "qarpeo-devtools-settings",
|
|
4156
|
+
path: "settings",
|
|
4157
|
+
file: resolver.resolve("./runtime/app/pages/devtools/settings.vue"),
|
|
4158
|
+
meta: { layout: false }
|
|
4159
|
+
}
|
|
4160
|
+
]
|
|
4161
|
+
}
|
|
4162
|
+
];
|
|
4163
|
+
pages.push(...devtoolsPages);
|
|
4164
|
+
});
|
|
4165
|
+
addServerHandler({
|
|
4166
|
+
route: "/_qarpeo/api/overview",
|
|
4167
|
+
method: "get",
|
|
4168
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/overview.get")
|
|
4169
|
+
});
|
|
4170
|
+
addServerHandler({
|
|
4171
|
+
route: "/_qarpeo/api/overview/health",
|
|
4172
|
+
method: "get",
|
|
4173
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/overview/health.get")
|
|
4174
|
+
});
|
|
4175
|
+
addServerHandler({
|
|
4176
|
+
route: "/_qarpeo/api/db/tables",
|
|
4177
|
+
method: "get",
|
|
4178
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/db/tables.get")
|
|
4179
|
+
});
|
|
4180
|
+
addServerHandler({
|
|
4181
|
+
route: "/_qarpeo/api/db/query",
|
|
4182
|
+
method: "post",
|
|
4183
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/db/query.post")
|
|
4184
|
+
});
|
|
4185
|
+
addServerHandler({
|
|
4186
|
+
route: "/_qarpeo/api/kv/keys",
|
|
4187
|
+
method: "get",
|
|
4188
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/kv/keys.get")
|
|
4189
|
+
});
|
|
4190
|
+
addServerHandler({
|
|
4191
|
+
route: "/_qarpeo/api/kv/get",
|
|
4192
|
+
method: "get",
|
|
4193
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/kv/get.get")
|
|
4194
|
+
});
|
|
4195
|
+
addServerHandler({
|
|
4196
|
+
route: "/_qarpeo/api/kv/set",
|
|
4197
|
+
method: "post",
|
|
4198
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/kv/set.post")
|
|
4199
|
+
});
|
|
4200
|
+
addServerHandler({
|
|
4201
|
+
route: "/_qarpeo/api/kv/delete",
|
|
4202
|
+
method: "post",
|
|
4203
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/kv/delete.post")
|
|
4204
|
+
});
|
|
4205
|
+
addServerHandler({
|
|
4206
|
+
route: "/_qarpeo/api/blob/files",
|
|
4207
|
+
method: "get",
|
|
4208
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/blob/files.get")
|
|
4209
|
+
});
|
|
4210
|
+
addServerHandler({
|
|
4211
|
+
route: "/_qarpeo/api/mail/inbox",
|
|
4212
|
+
method: "get",
|
|
4213
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/mail/inbox.get")
|
|
4214
|
+
});
|
|
4215
|
+
addServerHandler({
|
|
4216
|
+
route: "/_qarpeo/api/mail/send-test",
|
|
4217
|
+
method: "post",
|
|
4218
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/mail/send-test.post")
|
|
4219
|
+
});
|
|
4220
|
+
addServerHandler({
|
|
4221
|
+
route: "/_qarpeo/api/mail/clear",
|
|
4222
|
+
method: "post",
|
|
4223
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/mail/clear.post")
|
|
4224
|
+
});
|
|
4225
|
+
addServerHandler({
|
|
4226
|
+
route: "/_qarpeo/api/agents/list",
|
|
4227
|
+
method: "get",
|
|
4228
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/agents/list.get")
|
|
4229
|
+
});
|
|
4230
|
+
addServerHandler({
|
|
4231
|
+
route: "/_qarpeo/api/agents/history",
|
|
4232
|
+
method: "get",
|
|
4233
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/agents/history.get")
|
|
4234
|
+
});
|
|
4235
|
+
addServerHandler({
|
|
4236
|
+
route: "/_qarpeo/api/agents/chat",
|
|
4237
|
+
method: "post",
|
|
4238
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/agents/chat.post")
|
|
4239
|
+
});
|
|
4240
|
+
addServerHandler({
|
|
4241
|
+
route: "/_qarpeo/api/agents/clear",
|
|
4242
|
+
method: "post",
|
|
4243
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/agents/clear.post")
|
|
4244
|
+
});
|
|
4245
|
+
addServerHandler({
|
|
4246
|
+
route: "/_qarpeo/api/agents/create",
|
|
4247
|
+
method: "post",
|
|
4248
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/agents/create.post")
|
|
4249
|
+
});
|
|
4250
|
+
addServerHandler({
|
|
4251
|
+
route: "/_qarpeo/api/logs",
|
|
4252
|
+
method: "get",
|
|
4253
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/logs.get")
|
|
4254
|
+
});
|
|
4255
|
+
addServerHandler({
|
|
4256
|
+
route: "/_qarpeo/api/logs",
|
|
4257
|
+
method: "post",
|
|
4258
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/logs.post")
|
|
4259
|
+
});
|
|
4260
|
+
addServerHandler({
|
|
4261
|
+
route: "/_qarpeo/api/logs",
|
|
4262
|
+
method: "delete",
|
|
4263
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/logs.delete")
|
|
4264
|
+
});
|
|
4265
|
+
addServerHandler({
|
|
4266
|
+
route: "/_qarpeo/api/auth/users",
|
|
4267
|
+
method: "get",
|
|
4268
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/auth/users.get")
|
|
4269
|
+
});
|
|
4270
|
+
addServerHandler({
|
|
4271
|
+
route: "/_qarpeo/api/auth/sessions",
|
|
4272
|
+
method: "get",
|
|
4273
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/auth/sessions.get")
|
|
4274
|
+
});
|
|
4275
|
+
addServerHandler({
|
|
4276
|
+
route: "/_qarpeo/api/auth/revoke-session",
|
|
4277
|
+
method: "post",
|
|
4278
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/auth/revoke-session.post")
|
|
4279
|
+
});
|
|
4280
|
+
addServerHandler({
|
|
4281
|
+
route: "/_qarpeo/api/analytics/summary",
|
|
4282
|
+
method: "get",
|
|
4283
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/analytics/summary.get")
|
|
4284
|
+
});
|
|
4285
|
+
addServerHandler({
|
|
4286
|
+
route: "/_qarpeo/api/analytics/events",
|
|
4287
|
+
method: "get",
|
|
4288
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/analytics/events.get")
|
|
4289
|
+
});
|
|
4290
|
+
addServerHandler({
|
|
4291
|
+
route: "/_qarpeo/api/tenants/list",
|
|
4292
|
+
method: "get",
|
|
4293
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/tenants/list.get")
|
|
4294
|
+
});
|
|
4295
|
+
addServerHandler({
|
|
4296
|
+
route: "/_qarpeo/api/tenants/create",
|
|
4297
|
+
method: "post",
|
|
4298
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/tenants/create.post")
|
|
4299
|
+
});
|
|
4300
|
+
addServerHandler({
|
|
4301
|
+
route: "/_qarpeo/api/tenants/domain-add",
|
|
4302
|
+
method: "post",
|
|
4303
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/tenants/domain-add.post")
|
|
4304
|
+
});
|
|
4305
|
+
addServerHandler({
|
|
4306
|
+
route: "/_qarpeo/api/tenants/domain-verify",
|
|
4307
|
+
method: "post",
|
|
4308
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/tenants/domain-verify.post")
|
|
4309
|
+
});
|
|
4310
|
+
addServerHandler({
|
|
4311
|
+
route: "/_qarpeo/api/tenants/domain-delete",
|
|
4312
|
+
method: "post",
|
|
4313
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/tenants/domain-delete.post")
|
|
4314
|
+
});
|
|
4315
|
+
addServerHandler({
|
|
4316
|
+
route: "/_qarpeo/api/settings",
|
|
4317
|
+
method: "get",
|
|
4318
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/settings.get")
|
|
4319
|
+
});
|
|
4320
|
+
addServerHandler({
|
|
4321
|
+
route: "/_qarpeo/api/settings/reset-dev-data",
|
|
4322
|
+
method: "post",
|
|
4323
|
+
handler: resolver.resolve("./runtime/server/routes/__qarpeo/settings/reset-dev-data.post")
|
|
4324
|
+
});
|
|
4325
|
+
}
|
|
4326
|
+
if (nuxt.options.dev) {
|
|
4327
|
+
const isDb = Boolean(options.db || options.d1);
|
|
4328
|
+
const isKv = Boolean(options.kv);
|
|
4329
|
+
const isBlob = Boolean(options.blob || options.r2);
|
|
4330
|
+
const isAuth = Boolean(options.auth);
|
|
4331
|
+
const isCms = Boolean(options.cms);
|
|
4332
|
+
const devtoolsTabs = [
|
|
4333
|
+
...isDb ? [
|
|
4334
|
+
{
|
|
4335
|
+
id: "qarpeo-db",
|
|
4336
|
+
name: "qarpeo-db",
|
|
4337
|
+
title: "Database",
|
|
4338
|
+
icon: "i-lucide-database",
|
|
4339
|
+
view: { type: "iframe", src: "/_qarpeo/devtools/db" },
|
|
4340
|
+
url: "/_qarpeo/devtools/db",
|
|
4341
|
+
category: "server",
|
|
4342
|
+
groupId: "nuxt"
|
|
4343
|
+
}
|
|
4344
|
+
] : [],
|
|
4345
|
+
...isKv ? [
|
|
4346
|
+
{
|
|
4347
|
+
id: "qarpeo-kv",
|
|
4348
|
+
name: "qarpeo-kv",
|
|
4349
|
+
title: "KV Store",
|
|
4350
|
+
icon: "i-lucide-zap",
|
|
4351
|
+
view: { type: "iframe", src: "/_qarpeo/devtools/kv" },
|
|
4352
|
+
url: "/_qarpeo/devtools/kv",
|
|
4353
|
+
category: "server",
|
|
4354
|
+
groupId: "nuxt"
|
|
4355
|
+
}
|
|
4356
|
+
] : [],
|
|
4357
|
+
...isBlob ? [
|
|
4358
|
+
{
|
|
4359
|
+
id: "qarpeo-blob",
|
|
4360
|
+
name: "qarpeo-blob",
|
|
4361
|
+
title: "Blob Storage",
|
|
4362
|
+
icon: "i-lucide-box",
|
|
4363
|
+
view: { type: "iframe", src: "/_qarpeo/devtools/blob" },
|
|
4364
|
+
url: "/_qarpeo/devtools/blob",
|
|
4365
|
+
category: "server",
|
|
4366
|
+
groupId: "nuxt"
|
|
4367
|
+
}
|
|
4368
|
+
] : [],
|
|
4369
|
+
...isAuth ? [
|
|
4370
|
+
{
|
|
4371
|
+
id: "qarpeo-auth",
|
|
4372
|
+
name: "qarpeo-auth",
|
|
4373
|
+
title: "Auth",
|
|
4374
|
+
icon: "i-lucide-users",
|
|
4375
|
+
view: { type: "iframe", src: "/_qarpeo/devtools/auth" },
|
|
4376
|
+
url: "/_qarpeo/devtools/auth",
|
|
4377
|
+
category: "modules",
|
|
4378
|
+
groupId: "nuxt"
|
|
4379
|
+
}
|
|
4380
|
+
] : [],
|
|
4381
|
+
...isCms ? [
|
|
4382
|
+
{
|
|
4383
|
+
id: "qarpeo-cms",
|
|
4384
|
+
name: "qarpeo-cms",
|
|
4385
|
+
title: "CMS",
|
|
4386
|
+
icon: "i-lucide-file-text",
|
|
4387
|
+
view: { type: "iframe", src: "/cms" },
|
|
4388
|
+
url: "/cms",
|
|
4389
|
+
category: "modules",
|
|
4390
|
+
groupId: "nuxt"
|
|
4391
|
+
}
|
|
4392
|
+
] : [],
|
|
4393
|
+
{
|
|
4394
|
+
id: "qarpeo",
|
|
4395
|
+
name: "qarpeo",
|
|
4396
|
+
title: "Qarpeo",
|
|
4397
|
+
icon: "i-lucide-layers",
|
|
4398
|
+
view: { type: "iframe", src: "/_qarpeo/devtools" },
|
|
4399
|
+
url: "/_qarpeo/devtools",
|
|
4400
|
+
category: "modules",
|
|
4401
|
+
groupId: "nuxt"
|
|
4402
|
+
}
|
|
4403
|
+
];
|
|
4404
|
+
nuxt.hook("devtools:customTabs", (customTabs) => {
|
|
4405
|
+
for (const tab of devtoolsTabs) {
|
|
4406
|
+
customTabs.push({
|
|
4407
|
+
name: tab.name,
|
|
4408
|
+
title: tab.title,
|
|
4409
|
+
icon: tab.icon,
|
|
4410
|
+
view: tab.view,
|
|
4411
|
+
category: tab.category
|
|
4412
|
+
});
|
|
4413
|
+
}
|
|
4414
|
+
});
|
|
4415
|
+
nuxt.hook("devtools:ready", (ctx) => {
|
|
4416
|
+
for (const tab of devtoolsTabs) {
|
|
4417
|
+
ctx.docks?.register?.({
|
|
4418
|
+
id: tab.id,
|
|
4419
|
+
title: tab.title,
|
|
4420
|
+
icon: tab.icon,
|
|
4421
|
+
type: "iframe",
|
|
4422
|
+
url: tab.url,
|
|
4423
|
+
groupId: tab.groupId || "nuxt",
|
|
4424
|
+
category: tab.category
|
|
4425
|
+
});
|
|
4426
|
+
}
|
|
4427
|
+
});
|
|
4428
|
+
}
|
|
4429
|
+
addPlugin({
|
|
4430
|
+
src: resolver.resolve("./runtime/app/plugins/shortcuts.client"),
|
|
4431
|
+
mode: "client"
|
|
4432
|
+
});
|
|
4433
|
+
}
|
|
4434
|
+
});
|
|
4435
|
+
|
|
4436
|
+
export { ALL_CMS_TABLE_NAMES, checkDrizzleVersion, cmsCollections, cmsEntries, cmsRevisions, createWranglerConfig, module$1 as default, discoverSources, extractGroupTitle, extractOrderPrefix, findAgentFiles, findJobFiles, findQueueFiles, findSchemaFiles, generateAuthSchema, generateDevWranglerConfig, generateNotificationsSchema, generatePaymentsSchema, generateTenantsSchema, getActiveCmsTableNames, getActiveNotificationsTableNames, getActivePaymentsTableNames, getActiveTenantsTableNames, isGroupSegment, isRemoteSource, matchPathPatterns, matchesGlobFilter, matchesSourceFilters, resolveAllCmsSources, resolveCollectionForPath, resolveProjectName, resolveSourcePrefix, scanSchemaExports, stripOrderPrefix };
|