qarpeo 0.1.34 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -26
- package/dist/apps/cms.d.ts +4 -0
- package/dist/apps/comments.d.ts +4 -0
- package/dist/apps/payments.d.ts +4 -0
- package/dist/apps/store.d.ts +4 -0
- package/dist/chunks/auth-schema.mjs +169 -30
- package/dist/chunks/tools.mjs +1680 -0
- package/dist/cli/index.mjs +1256 -221
- package/dist/core/aliases.d.ts +5 -0
- package/dist/core/context.d.ts +10 -0
- package/dist/core/cross-drive.d.ts +2 -0
- package/dist/core/d1-migrate.d.ts +4 -0
- package/dist/core/devtools.d.ts +4 -0
- package/dist/core/nitro.d.ts +4 -0
- package/dist/core/schema.d.ts +4 -0
- package/dist/core/server-utils.d.ts +4 -0
- package/dist/core/wrangler.d.ts +4 -0
- package/dist/dev/wrangler.d.ts +1 -0
- package/dist/fate/index.d.ts +8 -8
- package/dist/features/agents.d.ts +4 -0
- package/dist/features/auth.d.ts +4 -0
- package/dist/features/bots.d.ts +4 -0
- package/dist/features/fate.d.ts +4 -0
- package/dist/features/mail.d.ts +4 -0
- package/dist/features/mcp.d.ts +4 -0
- package/dist/features/multitenant.d.ts +4 -0
- package/dist/features/notifications.d.ts +4 -0
- package/dist/features/realtime.d.ts +4 -0
- package/dist/module.d.ts +10 -2
- package/dist/module.mjs +6313 -5114
- package/dist/primitives/ai.d.ts +4 -0
- package/dist/primitives/analytics.d.ts +4 -0
- package/dist/primitives/blob.d.ts +4 -0
- package/dist/primitives/browser.d.ts +4 -0
- package/dist/primitives/cache.d.ts +4 -0
- package/dist/primitives/d1.d.ts +4 -0
- package/dist/primitives/do.d.ts +4 -0
- package/dist/primitives/email.d.ts +4 -0
- package/dist/primitives/hyperdrive.d.ts +4 -0
- package/dist/primitives/kv.d.ts +4 -0
- package/dist/primitives/queue.d.ts +4 -0
- package/dist/primitives/ratelimit.d.ts +4 -0
- package/dist/primitives/vectorize.d.ts +4 -0
- package/dist/primitives/workflows.d.ts +4 -0
- package/dist/runtime/ai.d.ts +3 -3
- package/dist/runtime/ai.mjs +8 -1
- package/dist/runtime/app/components/RealtimeCursors.vue +2 -2
- package/dist/runtime/app/composables/ai.d.ts +56 -29
- package/dist/runtime/app/composables/analytics.d.ts +26 -106
- package/dist/runtime/app/composables/api-tokens.d.ts +31 -34
- package/dist/runtime/app/composables/auth.d.ts +147 -51
- package/dist/runtime/app/composables/auth.mjs +0 -7
- package/dist/runtime/app/composables/chat.d.ts +38 -35
- package/dist/runtime/app/composables/cms-preview.d.ts +30 -25
- package/dist/runtime/app/composables/cms.d.ts +57 -282
- package/dist/runtime/app/composables/cms.mjs +0 -35
- package/dist/runtime/app/composables/comments.d.ts +32 -5
- package/dist/runtime/app/composables/comments.mjs +29 -1
- package/dist/runtime/app/composables/docs-version.d.ts +25 -28
- package/dist/runtime/app/composables/impersonation.d.ts +22 -5
- package/dist/runtime/app/composables/organization.d.ts +38 -91
- package/dist/runtime/app/composables/passkey.d.ts +22 -6
- package/dist/runtime/app/composables/passwordless.d.ts +24 -7
- package/dist/runtime/app/composables/payments.d.ts +50 -34
- package/dist/runtime/app/composables/payments.mjs +1 -0
- package/dist/runtime/app/composables/sse.d.ts +76 -0
- package/dist/runtime/app/composables/sse.mjs +152 -0
- package/dist/runtime/app/composables/storage.d.ts +53 -65
- package/dist/runtime/app/composables/storage.mjs +17 -0
- package/dist/runtime/app/composables/store.d.ts +198 -0
- package/dist/runtime/app/composables/store.mjs +414 -0
- package/dist/runtime/app/composables/tenant.d.ts +31 -72
- package/dist/runtime/app/composables/turnstile.d.ts +16 -3
- package/dist/runtime/app/composables/two-factor.d.ts +23 -6
- package/dist/runtime/app/pages/devtools/notifications.vue +30 -27
- package/dist/runtime/app/pages/devtools/realtime.vue +19 -31
- package/dist/runtime/app/pages/devtools.vue +0 -7
- package/dist/runtime/auth.d.ts +9 -9
- package/dist/runtime/blob.d.ts +10 -1
- package/dist/runtime/blob.mjs +83 -0
- package/dist/runtime/cache.d.ts +48 -0
- package/dist/runtime/cache.mjs +92 -0
- package/dist/runtime/comments.d.ts +4 -0
- package/dist/runtime/comments.mjs +2 -0
- package/dist/runtime/db.d.ts +21 -1
- package/dist/runtime/db.mjs +54 -0
- package/dist/runtime/drizzle.d.ts +4 -2
- package/dist/runtime/drizzle.mjs +68 -1
- package/dist/runtime/durable-object.d.ts +2 -0
- package/dist/runtime/durable-object.mjs +2 -0
- package/dist/runtime/email.d.ts +1 -1
- package/dist/runtime/email.mjs +1 -1
- package/dist/runtime/kv.mjs +50 -1
- package/dist/runtime/mcp.d.ts +2 -0
- package/dist/runtime/mcp.mjs +2 -0
- package/dist/runtime/queue.d.ts +12 -2
- package/dist/runtime/queue.mjs +19 -1
- package/dist/runtime/ratelimit.d.ts +1 -0
- package/dist/runtime/ratelimit.mjs +7 -0
- package/dist/runtime/schema.d.ts +313 -0
- package/dist/runtime/schema.mjs +259 -0
- package/dist/runtime/server/db/cms-schema.d.ts +1225 -171
- package/dist/runtime/server/db/cms-schema.mjs +69 -70
- package/dist/runtime/server/db/store-schema.d.ts +4344 -0
- package/dist/runtime/server/db/store-schema.mjs +266 -0
- package/dist/runtime/server/durable-objects/agent.mjs +35 -0
- package/dist/runtime/server/durable-objects/room.mjs +0 -1
- package/dist/runtime/server/middleware/ratelimit.mjs +10 -8
- package/dist/runtime/server/plugins/comments.d.ts +7 -0
- package/dist/runtime/server/plugins/comments.mjs +7 -0
- package/dist/runtime/server/plugins/email-inbound.d.ts +5 -0
- package/dist/runtime/server/plugins/email-inbound.mjs +17 -0
- package/dist/runtime/server/plugins/store.d.ts +7 -0
- package/dist/runtime/server/plugins/store.mjs +7 -0
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +2 -2
- package/dist/runtime/server/routes/atom.xml.get.mjs +3 -1
- package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +13 -2
- package/dist/runtime/server/routes/auth/2fa/setup.post.mjs +9 -3
- package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +11 -3
- package/dist/runtime/server/routes/auth/account.delete.mjs +2 -1
- package/dist/runtime/server/routes/auth/audit-logs.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/magic-link/send.post.d.ts +1 -9
- package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +8 -0
- package/dist/runtime/server/routes/auth/organization/sso/[id].delete.mjs +1 -1
- package/dist/runtime/server/routes/auth/organization/sso/index.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/organization/sso/index.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/otp/send.post.d.ts +1 -9
- package/dist/runtime/server/routes/auth/otp/send.post.mjs +8 -0
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +3 -3
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +2 -2
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +2 -2
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +1 -1
- package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.mjs +1 -1
- package/dist/runtime/server/routes/cms/[collection]/atom.xml.get.mjs +3 -1
- package/dist/runtime/server/routes/cms/[collection]/feed.xml.get.mjs +3 -1
- package/dist/runtime/server/routes/cms/bookmarks/[id].delete.mjs +1 -1
- package/dist/runtime/server/routes/cms/bookmarks/check.post.mjs +1 -1
- package/dist/runtime/server/routes/cms/bookmarks/index.get.mjs +1 -1
- package/dist/runtime/server/routes/cms/bookmarks/index.post.mjs +1 -1
- package/dist/runtime/server/routes/cms/deploy.post.mjs +1 -1
- package/dist/runtime/server/routes/cms/export.post.mjs +4 -3
- package/dist/runtime/server/routes/cms/search.get.mjs +7 -5
- package/dist/runtime/server/routes/cms/sync.post.mjs +2 -1
- package/dist/runtime/server/routes/comments/[id]/react.post.mjs +1 -2
- package/dist/runtime/server/routes/comments/[id]/report.post.d.ts +1 -1
- package/dist/runtime/server/routes/comments/[id]/report.post.mjs +0 -2
- package/dist/runtime/server/routes/comments/[id].delete.mjs +8 -4
- package/dist/runtime/server/routes/comments/[id].get.d.ts +1 -1
- package/dist/runtime/server/routes/comments/[id].get.mjs +1 -2
- package/dist/runtime/server/routes/comments/[id].patch.d.ts +1 -1
- package/dist/runtime/server/routes/comments/[id].patch.mjs +6 -3
- package/dist/runtime/server/routes/comments/batch.post.d.ts +2 -0
- package/dist/runtime/server/routes/comments/batch.post.mjs +33 -0
- package/dist/runtime/server/routes/comments/index.get.d.ts +1 -1
- package/dist/runtime/server/routes/comments/index.get.mjs +6 -4
- package/dist/runtime/server/routes/comments/index.post.d.ts +1 -1
- package/dist/runtime/server/routes/comments/index.post.mjs +6 -2
- package/dist/runtime/server/routes/feed.xml.get.mjs +3 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +3 -1
- package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +17 -0
- package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +29 -0
- package/dist/runtime/server/routes/store/cart/index.delete.d.ts +6 -0
- package/dist/runtime/server/routes/store/cart/index.delete.mjs +11 -0
- package/dist/runtime/server/routes/store/cart/index.get.d.ts +5 -0
- package/dist/runtime/server/routes/store/cart/index.get.mjs +14 -0
- package/dist/runtime/server/routes/store/cart/items/[id].delete.d.ts +6 -0
- package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +25 -0
- package/dist/runtime/server/routes/store/cart/items/[id].patch.d.ts +6 -0
- package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +29 -0
- package/dist/runtime/server/routes/store/cart/items.post.d.ts +6 -0
- package/dist/runtime/server/routes/store/cart/items.post.mjs +36 -0
- package/dist/runtime/server/routes/store/categories/index.get.d.ts +2 -0
- package/dist/runtime/server/routes/store/categories/index.get.mjs +8 -0
- package/dist/runtime/server/routes/store/checkout.post.d.ts +6 -0
- package/dist/runtime/server/routes/store/checkout.post.mjs +21 -0
- package/dist/runtime/server/routes/store/coupons/apply.post.d.ts +7 -0
- package/dist/runtime/server/routes/store/coupons/apply.post.mjs +18 -0
- package/dist/runtime/server/routes/store/currencies.get.d.ts +15 -0
- package/dist/runtime/server/routes/store/currencies.get.mjs +13 -0
- package/dist/runtime/server/routes/store/orders/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/store/orders/[id].get.mjs +26 -0
- package/dist/runtime/server/routes/store/orders/download/[token].get.d.ts +7 -0
- package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +57 -0
- package/dist/runtime/server/routes/store/orders/index.get.d.ts +5 -0
- package/dist/runtime/server/routes/store/orders/index.get.mjs +30 -0
- package/dist/runtime/server/routes/store/products/[slug].get.d.ts +2 -0
- package/dist/runtime/server/routes/store/products/[slug].get.mjs +18 -0
- package/dist/runtime/server/routes/store/products/index.get.d.ts +5 -0
- package/dist/runtime/server/routes/store/products/index.get.mjs +33 -0
- package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +9 -0
- package/dist/runtime/server/routes/store/tax/calculate.post.mjs +18 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +14 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +14 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +24 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +6 -0
- package/dist/runtime/server/utils/ai.d.ts +146 -21
- package/dist/runtime/server/utils/ai.mjs +406 -11
- package/dist/runtime/server/utils/analytics-query.d.ts +13 -58
- package/dist/runtime/server/utils/audit.d.ts +5 -4
- package/dist/runtime/server/utils/audit.mjs +25 -14
- package/dist/runtime/server/utils/auth.d.ts +29 -12
- package/dist/runtime/server/utils/auth.mjs +88 -70
- package/dist/runtime/server/utils/bots.d.ts +20 -4
- package/dist/runtime/server/utils/bots.mjs +7 -3
- package/dist/runtime/server/utils/browser-utils.d.ts +23 -23
- package/dist/runtime/server/utils/cache.d.ts +31 -10
- package/dist/runtime/server/utils/cache.mjs +130 -53
- package/dist/runtime/server/utils/cms/collections.d.ts +23 -0
- package/dist/runtime/server/utils/cms/collections.mjs +143 -0
- package/dist/runtime/server/utils/cms/common.d.ts +9 -0
- package/dist/runtime/server/utils/cms/common.mjs +28 -0
- package/dist/runtime/server/utils/cms/git.mjs +2 -2
- package/dist/runtime/server/utils/cms/navigation.d.ts +46 -0
- package/dist/runtime/server/utils/cms/navigation.mjs +683 -0
- package/dist/runtime/server/utils/cms/preview.d.ts +11 -0
- package/dist/runtime/server/utils/cms/preview.mjs +50 -0
- package/dist/runtime/server/utils/cms/search.d.ts +1 -1
- package/dist/runtime/server/utils/cms/search.mjs +11 -7
- package/dist/runtime/server/utils/cms/sync.d.ts +34 -0
- package/dist/runtime/server/utils/cms/sync.mjs +1082 -0
- package/dist/runtime/server/utils/cms/taxonomy.d.ts +103 -0
- package/dist/runtime/server/utils/cms/taxonomy.mjs +348 -0
- package/dist/runtime/server/utils/cms.d.ts +13 -249
- package/dist/runtime/server/utils/cms.mjs +108 -2350
- package/dist/runtime/server/utils/comments-filter.d.ts +45 -0
- package/dist/runtime/server/utils/comments-filter.mjs +541 -0
- package/dist/runtime/server/utils/comments.d.ts +71 -0
- package/dist/runtime/server/utils/comments.mjs +137 -61
- package/dist/runtime/server/utils/config.d.ts +4 -3
- package/dist/runtime/server/utils/config.mjs +7 -6
- package/dist/runtime/server/utils/context.d.ts +14 -0
- package/dist/runtime/server/utils/context.mjs +2 -2
- package/dist/runtime/server/utils/crypto.d.ts +44 -5
- package/dist/runtime/server/utils/crypto.mjs +18 -0
- package/dist/runtime/server/utils/domains.mjs +9 -5
- package/dist/runtime/server/utils/drizzle.d.ts +35 -3
- package/dist/runtime/server/utils/drizzle.mjs +115 -6
- package/dist/runtime/server/utils/durable-object.d.ts +106 -0
- package/dist/runtime/server/utils/durable-object.mjs +628 -0
- package/dist/runtime/server/utils/email-inbound.d.ts +29 -0
- package/dist/runtime/server/utils/email-inbound.mjs +76 -0
- package/dist/runtime/server/utils/impersonation.d.ts +32 -2
- package/dist/runtime/server/utils/impersonation.mjs +16 -13
- package/dist/runtime/server/utils/lock.d.ts +71 -0
- package/dist/runtime/server/utils/lock.mjs +139 -0
- package/dist/runtime/server/utils/mail-suppression.mjs +7 -7
- package/dist/runtime/server/utils/mail.d.ts +30 -19
- package/dist/runtime/server/utils/mcp.d.ts +44 -0
- package/dist/runtime/server/utils/mcp.mjs +308 -0
- package/dist/runtime/server/utils/notifications.d.ts +72 -7
- package/dist/runtime/server/utils/notifications.mjs +67 -55
- package/dist/runtime/server/utils/oauth.d.ts +27 -4
- package/dist/runtime/server/utils/organization.d.ts +63 -7
- package/dist/runtime/server/utils/organization.mjs +26 -21
- package/dist/runtime/server/utils/passwordless.d.ts +62 -33
- package/dist/runtime/server/utils/payments.d.ts +51 -12
- package/dist/runtime/server/utils/payments.mjs +472 -282
- package/dist/runtime/server/utils/queue.d.ts +106 -13
- package/dist/runtime/server/utils/queue.mjs +313 -28
- package/dist/runtime/server/utils/rag.d.ts +42 -14
- package/dist/runtime/server/utils/rag.mjs +169 -4
- package/dist/runtime/server/utils/ratelimit.d.ts +34 -5
- package/dist/runtime/server/utils/ratelimit.mjs +95 -14
- package/dist/runtime/server/utils/realtime.d.ts +68 -52
- package/dist/runtime/server/utils/scheduled-task.d.ts +42 -1
- package/dist/runtime/server/utils/scheduled-task.mjs +29 -0
- package/dist/runtime/server/utils/schema-fallback.d.ts +1 -1
- package/dist/runtime/server/utils/schema-fallback.mjs +1 -1
- package/dist/runtime/server/utils/session.d.ts +84 -10
- package/dist/runtime/server/utils/session.mjs +12 -10
- package/dist/runtime/server/utils/sse.d.ts +75 -0
- package/dist/runtime/server/utils/sse.mjs +147 -0
- package/dist/runtime/server/utils/sso.d.ts +1 -1
- package/dist/runtime/server/utils/storage.d.ts +53 -4
- package/dist/runtime/server/utils/storage.mjs +15 -11
- package/dist/runtime/server/utils/store-localization.d.ts +51 -0
- package/dist/runtime/server/utils/store-localization.mjs +417 -0
- package/dist/runtime/server/utils/store.d.ts +207 -0
- package/dist/runtime/server/utils/store.mjs +2227 -0
- package/dist/runtime/server/utils/table-names.d.ts +51 -0
- package/dist/runtime/server/utils/table-names.mjs +69 -0
- package/dist/runtime/server/utils/tenant.d.ts +26 -2
- package/dist/runtime/server/utils/tenant.mjs +16 -12
- package/dist/runtime/server/utils/tools-registry-fallback.d.ts +1 -0
- package/dist/runtime/server/utils/tools-registry-fallback.mjs +1 -0
- package/dist/runtime/server/utils/totp.d.ts +45 -2
- package/dist/runtime/server/utils/tracker.d.ts +10 -11
- package/dist/runtime/server/utils/turnstile.d.ts +16 -1
- package/dist/runtime/server/utils/workflows.d.ts +92 -0
- package/dist/runtime/server/utils/workflows.mjs +299 -0
- package/dist/runtime/server.d.ts +8 -1
- package/dist/runtime/server.mjs +8 -5
- package/dist/runtime/service.d.ts +10 -10
- package/dist/runtime/storage.d.ts +1 -0
- package/dist/runtime/storage.mjs +1 -0
- package/dist/runtime/store.d.ts +4 -0
- package/dist/runtime/store.mjs +2 -0
- package/dist/runtime/test-utils.d.ts +11 -10
- package/dist/runtime/test-utils.mjs +64 -4
- package/dist/runtime/types/ai.d.ts +21 -2
- package/dist/runtime/types/d1.d.ts +17 -0
- package/dist/runtime/types/drizzle.d.ts +2 -2
- package/dist/runtime/types/durable-object.d.ts +62 -2
- package/dist/runtime/types/email.d.ts +46 -0
- package/dist/runtime/types/imports.d.ts +6 -1
- package/dist/runtime/types/index.d.ts +58 -0
- package/dist/runtime/types/index.mjs +3 -0
- package/dist/runtime/types/mcp.d.ts +83 -0
- package/dist/runtime/types/mcp.mjs +0 -0
- package/dist/runtime/types/queue.d.ts +36 -0
- package/dist/runtime/types/r2.d.ts +41 -0
- package/dist/runtime/types/store.d.ts +313 -0
- package/dist/runtime/types/store.mjs +0 -0
- package/dist/runtime/types/workflows.d.ts +98 -0
- package/dist/runtime/types/workflows.mjs +0 -0
- package/dist/runtime/workflows.d.ts +5 -0
- package/dist/runtime/workflows.mjs +2 -0
- package/dist/types/ai.d.ts +721 -0
- package/dist/types/cms.d.ts +710 -0
- package/dist/types.d.ts +430 -1292
- package/dist/utils/auth-schema.d.ts +3 -2
- package/dist/utils/bots.d.ts +20 -0
- package/dist/utils/comments-schema.d.ts +5 -4
- package/dist/utils/drizzle.d.ts +83 -3
- package/dist/utils/durable-objects.d.ts +10 -0
- package/dist/utils/email-inbound.d.ts +10 -0
- package/dist/utils/local-db.d.ts +1 -3
- package/dist/utils/mcp.d.ts +24 -0
- package/dist/utils/notifications-schema.d.ts +5 -4
- package/dist/utils/payments-schema.d.ts +4 -3
- package/dist/utils/store-schema.d.ts +14 -0
- package/dist/utils/table-names.d.ts +1 -0
- package/dist/utils/tenants-schema.d.ts +4 -3
- package/dist/utils/tools.d.ts +20 -0
- package/dist/utils/workflows.d.ts +8 -0
- package/package.json +34 -4
- package/dist/chunks/wrangler.mjs +0 -897
- package/dist/runtime/app/components/AuthRegister.vue +0 -306
- package/dist/runtime/app/components/AuthSessionsList.vue +0 -137
- package/dist/runtime/app/components/AuthSignIn.vue +0 -298
- package/dist/runtime/app/components/CMSBookmarkButton.vue +0 -59
- package/dist/runtime/app/components/CMSImage.vue +0 -47
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +0 -110
- package/dist/runtime/app/components/CMSNewsletter.vue +0 -81
- package/dist/runtime/app/components/CMSPreviewBanner.vue +0 -83
- package/dist/runtime/app/components/CMSTableOfContents.vue +0 -84
- package/dist/runtime/app/components/CMSVersionBanner.vue +0 -53
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +0 -140
- package/dist/runtime/app/components/Comments.vue +0 -411
- package/dist/runtime/app/components/FileUpload.vue +0 -200
- package/dist/runtime/app/components/ImpersonationBanner.vue +0 -61
- package/dist/runtime/app/components/NotificationBell.vue +0 -263
- package/dist/runtime/app/components/NotificationList.vue +0 -205
- package/dist/runtime/app/components/NotificationPrompt.vue +0 -133
- package/dist/runtime/app/components/PricingGated.vue +0 -81
- package/dist/runtime/app/components/PricingTable.vue +0 -274
- package/dist/runtime/app/components/RealtimeChat.vue +0 -164
- package/dist/runtime/app/components/RealtimePresence.vue +0 -129
- package/dist/runtime/app/components/RealtimeStatus.vue +0 -79
- package/dist/runtime/app/components/SubscriptionCard.vue +0 -207
- package/dist/runtime/app/components/UserProfile.vue +0 -558
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
|
+
import { getAuthContext } from "../../utils/context.mjs";
|
|
3
|
+
import { getStorageConfig } from "../../utils/storage.mjs";
|
|
4
|
+
import { createBlob } from "../../../blob.mjs";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const config = getStorageConfig(event);
|
|
7
|
+
const body = await readBody(event) || {};
|
|
8
|
+
const pathname = body.pathname || body.key || body.filename || body.name;
|
|
9
|
+
if (!pathname) {
|
|
10
|
+
throw createError({
|
|
11
|
+
statusCode: 400,
|
|
12
|
+
statusMessage: "Bad Request",
|
|
13
|
+
message: "pathname is required"
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const authCtx = await getAuthContext(event).catch(() => null);
|
|
17
|
+
if (!config.allowAnonymousUploads && !authCtx?.user) {
|
|
18
|
+
throw createError({
|
|
19
|
+
statusCode: 401,
|
|
20
|
+
statusMessage: "Unauthorized",
|
|
21
|
+
message: "Authentication required to generate a presigned R2 upload URL"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const blobClient = createBlob(void 0, event);
|
|
25
|
+
return await blobClient.createUploadUrl(pathname, {
|
|
26
|
+
expiresIn: body.expiresIn,
|
|
27
|
+
contentType: body.contentType || body.type
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineEventHandler, getRequestHeader, getCookie } from "nuxt/server";
|
|
2
|
+
import { getOrCreateStoreCart, clearStoreCart, calculateStoreCartTotals } from "../../../utils/store.mjs";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const token = getRequestHeader(event, "x-cart-session") || getCookie(event, "qarpeo_cart_session") || void 0;
|
|
5
|
+
const cart = await getOrCreateStoreCart(token, event);
|
|
6
|
+
await clearStoreCart(cart.id, event);
|
|
7
|
+
cart.items = [];
|
|
8
|
+
cart.couponCode = null;
|
|
9
|
+
const totals = await calculateStoreCartTotals(cart.id, event);
|
|
10
|
+
return { success: true, cart, totals };
|
|
11
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineEventHandler, getRequestHeader, getCookie, setCookie } from "nuxt/server";
|
|
2
|
+
import { getOrCreateStoreCart, calculateStoreCartTotals } from "../../../utils/store.mjs";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const token = getRequestHeader(event, "x-cart-session") || getCookie(event, "qarpeo_cart_session") || void 0;
|
|
5
|
+
const cart = await getOrCreateStoreCart(token, event);
|
|
6
|
+
setCookie(event, "qarpeo_cart_session", cart.sessionToken, {
|
|
7
|
+
maxAge: 30 * 86400,
|
|
8
|
+
path: "/",
|
|
9
|
+
httpOnly: false,
|
|
10
|
+
sameSite: "lax"
|
|
11
|
+
});
|
|
12
|
+
const totals = await calculateStoreCartTotals(cart.id, event);
|
|
13
|
+
return { cart, totals };
|
|
14
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam, createError } from "nuxt/server";
|
|
2
|
+
import {
|
|
3
|
+
removeStoreCartItem,
|
|
4
|
+
calculateStoreCartTotals,
|
|
5
|
+
getStoreCart,
|
|
6
|
+
storeCartItemTbl
|
|
7
|
+
} from "../../../../utils/store.mjs";
|
|
8
|
+
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
9
|
+
export default defineEventHandler(async (event) => {
|
|
10
|
+
const itemId = getRouterParam(event, "id");
|
|
11
|
+
if (!itemId) {
|
|
12
|
+
throw createError({ statusCode: 400, statusMessage: "Item ID is required." });
|
|
13
|
+
}
|
|
14
|
+
const env = getCloudflareEnv(event);
|
|
15
|
+
const db = env[env.QARPEO_DEFAULT_DB_BINDING || "DB"] || env.DB;
|
|
16
|
+
const itemRow = await db.prepare(`SELECT cart_id FROM ${storeCartItemTbl(event)} WHERE id = ?`).bind(itemId).first();
|
|
17
|
+
if (!itemRow) {
|
|
18
|
+
throw createError({ statusCode: 404, statusMessage: "Cart item not found." });
|
|
19
|
+
}
|
|
20
|
+
const cartId = itemRow.cart_id;
|
|
21
|
+
await removeStoreCartItem(itemId, event);
|
|
22
|
+
const cart = await getStoreCart(cartId, event);
|
|
23
|
+
const totals = await calculateStoreCartTotals(cartId, event);
|
|
24
|
+
return { success: true, cart, totals };
|
|
25
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineEventHandler, readBody, getRouterParam, createError } from "nuxt/server";
|
|
2
|
+
import {
|
|
3
|
+
updateStoreCartItem,
|
|
4
|
+
calculateStoreCartTotals,
|
|
5
|
+
getStoreCart,
|
|
6
|
+
storeCartItemTbl
|
|
7
|
+
} from "../../../../utils/store.mjs";
|
|
8
|
+
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
9
|
+
export default defineEventHandler(async (event) => {
|
|
10
|
+
const itemId = getRouterParam(event, "id");
|
|
11
|
+
if (!itemId) {
|
|
12
|
+
throw createError({ statusCode: 400, statusMessage: "Item ID is required." });
|
|
13
|
+
}
|
|
14
|
+
const body = await readBody(event).catch(() => ({})) || {};
|
|
15
|
+
const quantity = Number(body.quantity);
|
|
16
|
+
if (isNaN(quantity)) {
|
|
17
|
+
throw createError({ statusCode: 400, statusMessage: "Valid quantity is required." });
|
|
18
|
+
}
|
|
19
|
+
const env = getCloudflareEnv(event);
|
|
20
|
+
const db = env[env.QARPEO_DEFAULT_DB_BINDING || "DB"] || env.DB;
|
|
21
|
+
const itemRow = await db.prepare(`SELECT cart_id FROM ${storeCartItemTbl(event)} WHERE id = ?`).bind(itemId).first();
|
|
22
|
+
if (!itemRow) {
|
|
23
|
+
throw createError({ statusCode: 404, statusMessage: "Cart item not found." });
|
|
24
|
+
}
|
|
25
|
+
const item = await updateStoreCartItem(itemId, quantity, event);
|
|
26
|
+
const cart = await getStoreCart(itemRow.cart_id, event);
|
|
27
|
+
const totals = await calculateStoreCartTotals(itemRow.cart_id, event);
|
|
28
|
+
return { item, cart, totals };
|
|
29
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineEventHandler, readBody, getRequestHeader, getCookie, createError } from "nuxt/server";
|
|
2
|
+
import {
|
|
3
|
+
getOrCreateStoreCart,
|
|
4
|
+
addToStoreCart,
|
|
5
|
+
calculateStoreCartTotals,
|
|
6
|
+
getStoreCart
|
|
7
|
+
} from "../../../utils/store.mjs";
|
|
8
|
+
export default defineEventHandler(async (event) => {
|
|
9
|
+
const body = await readBody(event).catch(() => ({})) || {};
|
|
10
|
+
const { productId, variantId, quantity = 1, customAttributes = {} } = body;
|
|
11
|
+
if (!productId || !variantId) {
|
|
12
|
+
throw createError({
|
|
13
|
+
statusCode: 400,
|
|
14
|
+
statusMessage: "productId and variantId are required."
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const token = body.sessionToken || getRequestHeader(event, "x-cart-session") || getCookie(event, "qarpeo_cart_session") || void 0;
|
|
18
|
+
let cartId = body.cartId;
|
|
19
|
+
if (!cartId) {
|
|
20
|
+
const cart = await getOrCreateStoreCart(token, event);
|
|
21
|
+
cartId = cart.id;
|
|
22
|
+
}
|
|
23
|
+
const item = await addToStoreCart(
|
|
24
|
+
cartId,
|
|
25
|
+
{
|
|
26
|
+
productId,
|
|
27
|
+
variantId,
|
|
28
|
+
quantity: Math.max(1, Number(quantity) || 1),
|
|
29
|
+
customAttributes
|
|
30
|
+
},
|
|
31
|
+
event
|
|
32
|
+
);
|
|
33
|
+
const updatedCart = await getStoreCart(cartId, event);
|
|
34
|
+
const totals = await calculateStoreCartTotals(cartId, event);
|
|
35
|
+
return { item, cart: updatedCart, totals };
|
|
36
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from "nuxt/server";
|
|
2
|
+
import { queryStoreCategories } from "../../../utils/store.mjs";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const query = getQuery(event);
|
|
5
|
+
const parentId = query.parentId !== void 0 ? query.parentId ? String(query.parentId) : null : void 0;
|
|
6
|
+
const tenantId = query.tenantId ? String(query.tenantId) : void 0;
|
|
7
|
+
return queryStoreCategories({ parentId, tenantId }, event);
|
|
8
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
|
+
import { createStoreCheckoutSession } from "../../utils/store.mjs";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const body = await readBody(event).catch(() => ({})) || {};
|
|
5
|
+
const { cartId, customerEmail, customerName, shippingAddress, billingAddress, successUrl, cancelUrl } = body;
|
|
6
|
+
if (!cartId) {
|
|
7
|
+
throw createError({ statusCode: 400, statusMessage: "cartId is required for checkout." });
|
|
8
|
+
}
|
|
9
|
+
return createStoreCheckoutSession(
|
|
10
|
+
cartId,
|
|
11
|
+
{
|
|
12
|
+
customerEmail,
|
|
13
|
+
customerName,
|
|
14
|
+
shippingAddress,
|
|
15
|
+
billingAddress,
|
|
16
|
+
successUrl,
|
|
17
|
+
cancelUrl
|
|
18
|
+
},
|
|
19
|
+
event
|
|
20
|
+
);
|
|
21
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
|
+
import { applyStoreDiscount, getStoreCart } from "../../../utils/store.mjs";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const body = await readBody(event).catch(() => ({})) || {};
|
|
5
|
+
const { cartId, code } = body;
|
|
6
|
+
if (!cartId || !code) {
|
|
7
|
+
throw createError({
|
|
8
|
+
statusCode: 400,
|
|
9
|
+
statusMessage: "cartId and coupon code are required."
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const result = await applyStoreDiscount(cartId, String(code).trim(), event);
|
|
13
|
+
const cart = await getStoreCart(cartId, event);
|
|
14
|
+
return {
|
|
15
|
+
...result,
|
|
16
|
+
cart
|
|
17
|
+
};
|
|
18
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GET /api/store/currencies
|
|
3
|
+
*
|
|
4
|
+
* Returns all supported currencies with their current FX rates.
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: import("nuxt/server").EventHandler<{
|
|
7
|
+
currencies: {
|
|
8
|
+
rate: number;
|
|
9
|
+
symbol: string;
|
|
10
|
+
name: string;
|
|
11
|
+
code: string;
|
|
12
|
+
decimals: number;
|
|
13
|
+
}[];
|
|
14
|
+
}>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineEventHandler } from "nuxt/server";
|
|
2
|
+
import {
|
|
3
|
+
SUPPORTED_STORE_CURRENCIES,
|
|
4
|
+
DEFAULT_STORE_RATES
|
|
5
|
+
} from "../../utils/store-localization.mjs";
|
|
6
|
+
export default defineEventHandler((_event) => {
|
|
7
|
+
return {
|
|
8
|
+
currencies: Object.values(SUPPORTED_STORE_CURRENCIES).map((c) => ({
|
|
9
|
+
...c,
|
|
10
|
+
rate: DEFAULT_STORE_RATES[c.code] ?? 1
|
|
11
|
+
}))
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam, createError } from "nuxt/server";
|
|
2
|
+
import { getStoreOrder } from "../../../utils/store.mjs";
|
|
3
|
+
import { getAuthContext } from "../../../utils/context.mjs";
|
|
4
|
+
import { getTenant } from "../../../utils/tenant.mjs";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const id = getRouterParam(event, "id");
|
|
7
|
+
if (!id) {
|
|
8
|
+
throw createError({ statusCode: 400, statusMessage: "Order ID is required." });
|
|
9
|
+
}
|
|
10
|
+
const order = await getStoreOrder(id, event);
|
|
11
|
+
if (!order) {
|
|
12
|
+
throw createError({ statusCode: 404, statusMessage: "Order not found." });
|
|
13
|
+
}
|
|
14
|
+
const activeTenant = getTenant(event);
|
|
15
|
+
if (activeTenant && order.tenantId && order.tenantId !== activeTenant.id) {
|
|
16
|
+
throw createError({ statusCode: 404, statusMessage: "Order not found." });
|
|
17
|
+
}
|
|
18
|
+
const auth = await getAuthContext(event).catch(() => null);
|
|
19
|
+
const isOwner = auth?.user?.id && order.userId === auth.user.id;
|
|
20
|
+
const isEmailMatch = auth?.user?.email && order.customerEmail.toLowerCase() === auth.user.email.toLowerCase();
|
|
21
|
+
const isAdmin = auth?.user?.role === "admin" || auth?.user?.role === "super" || auth?.user?.role === "staff";
|
|
22
|
+
if (!isOwner && !isEmailMatch && !isAdmin) {
|
|
23
|
+
throw createError({ statusCode: 403, statusMessage: "Unauthorized to access this order." });
|
|
24
|
+
}
|
|
25
|
+
return order;
|
|
26
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam, getQuery, createError, sendRedirect } from "nuxt/server";
|
|
2
|
+
import { storeOrderItemTbl, storeOrderTbl } from "../../../../utils/store.mjs";
|
|
3
|
+
import { verifyHmacSha256 } from "../../../../utils/crypto.mjs";
|
|
4
|
+
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const token = getRouterParam(event, "token");
|
|
7
|
+
if (!token) {
|
|
8
|
+
throw createError({ statusCode: 400, statusMessage: "Download token is required." });
|
|
9
|
+
}
|
|
10
|
+
const query = getQuery(event);
|
|
11
|
+
const expires = Number(query.expires);
|
|
12
|
+
const sig = typeof query.sig === "string" ? query.sig : "";
|
|
13
|
+
if (!expires || Number.isNaN(expires) || !sig) {
|
|
14
|
+
throw createError({ statusCode: 400, statusMessage: "Signed expiration and signature are required." });
|
|
15
|
+
}
|
|
16
|
+
if (Date.now() > expires) {
|
|
17
|
+
throw createError({ statusCode: 410, statusMessage: "Download link has expired." });
|
|
18
|
+
}
|
|
19
|
+
const isValidSig = await verifyHmacSha256(`${token}:${expires}`, sig, event);
|
|
20
|
+
if (!isValidSig) {
|
|
21
|
+
throw createError({ statusCode: 403, statusMessage: "Invalid or forged download signature." });
|
|
22
|
+
}
|
|
23
|
+
const env = getCloudflareEnv(event);
|
|
24
|
+
const db = env[env.QARPEO_DEFAULT_DB_BINDING || "DB"] || env.DB;
|
|
25
|
+
const itemTbl = storeOrderItemTbl(event);
|
|
26
|
+
const orderTbl = storeOrderTbl(event);
|
|
27
|
+
const item = await db.prepare(
|
|
28
|
+
`SELECT i.*, o.status as order_status
|
|
29
|
+
FROM ${itemTbl} i
|
|
30
|
+
JOIN ${orderTbl} o ON o.id = i.order_id
|
|
31
|
+
WHERE i.download_key = ? AND i.is_digital = 1`
|
|
32
|
+
).bind(token).first();
|
|
33
|
+
if (!item) {
|
|
34
|
+
throw createError({ statusCode: 404, statusMessage: "Digital item not found." });
|
|
35
|
+
}
|
|
36
|
+
if (item.order_status !== "paid" && item.order_status !== "delivered") {
|
|
37
|
+
throw createError({
|
|
38
|
+
statusCode: 403,
|
|
39
|
+
statusMessage: "Order payment has not been confirmed for digital delivery."
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (item.metadata_json) {
|
|
43
|
+
try {
|
|
44
|
+
const meta = JSON.parse(item.metadata_json);
|
|
45
|
+
if (meta.downloadUrl) {
|
|
46
|
+
return sendRedirect(event, meta.downloadUrl, 302);
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
title: item.title,
|
|
54
|
+
message: "Digital product download authorized.",
|
|
55
|
+
sku: item.sku
|
|
56
|
+
};
|
|
57
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, createError } from "nuxt/server";
|
|
2
|
+
import { queryStoreOrders } from "../../../utils/store.mjs";
|
|
3
|
+
import { getAuthContext } from "../../../utils/context.mjs";
|
|
4
|
+
import { getTenant } from "../../../utils/tenant.mjs";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const auth = await getAuthContext(event).catch(() => null);
|
|
7
|
+
if (!auth?.user?.id) {
|
|
8
|
+
throw createError({ statusCode: 401, statusMessage: "Authentication required to view orders." });
|
|
9
|
+
}
|
|
10
|
+
const query = getQuery(event);
|
|
11
|
+
const isAdmin = auth.user.role === "admin" || auth.user.role === "super" || auth.user.role === "staff";
|
|
12
|
+
const userId = isAdmin && query.userId ? String(query.userId) : auth.user.id;
|
|
13
|
+
const customerEmail = isAdmin && query.email ? String(query.email) : void 0;
|
|
14
|
+
const status = query.status ? String(query.status) : void 0;
|
|
15
|
+
const limit = Math.min(Number(query.limit) || 20, 100);
|
|
16
|
+
const offset = Number(query.offset) || 0;
|
|
17
|
+
const activeTenant = getTenant(event);
|
|
18
|
+
const tenantId = activeTenant ? activeTenant.id : query.tenantId ? String(query.tenantId) : void 0;
|
|
19
|
+
return queryStoreOrders(
|
|
20
|
+
{
|
|
21
|
+
userId,
|
|
22
|
+
customerEmail,
|
|
23
|
+
status,
|
|
24
|
+
tenantId,
|
|
25
|
+
limit,
|
|
26
|
+
offset
|
|
27
|
+
},
|
|
28
|
+
event
|
|
29
|
+
);
|
|
30
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam, createError } from "nuxt/server";
|
|
2
|
+
import { getStoreProduct } from "../../../utils/store.mjs";
|
|
3
|
+
import { getTenant } from "../../../utils/tenant.mjs";
|
|
4
|
+
export default defineEventHandler(async (event) => {
|
|
5
|
+
const slug = getRouterParam(event, "slug");
|
|
6
|
+
if (!slug) {
|
|
7
|
+
throw createError({ statusCode: 400, statusMessage: "Product slug is required." });
|
|
8
|
+
}
|
|
9
|
+
const product = await getStoreProduct(slug, event);
|
|
10
|
+
if (!product) {
|
|
11
|
+
throw createError({ statusCode: 404, statusMessage: "Product not found." });
|
|
12
|
+
}
|
|
13
|
+
const activeTenant = getTenant(event);
|
|
14
|
+
if (activeTenant && product.tenantId && product.tenantId !== activeTenant.id) {
|
|
15
|
+
throw createError({ statusCode: 404, statusMessage: "Product not found." });
|
|
16
|
+
}
|
|
17
|
+
return product;
|
|
18
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from "nuxt/server";
|
|
2
|
+
import { queryStoreProducts } from "../../../utils/store.mjs";
|
|
3
|
+
import { getTenant } from "../../../utils/tenant.mjs";
|
|
4
|
+
export default defineEventHandler(async (event) => {
|
|
5
|
+
const query = getQuery(event);
|
|
6
|
+
const limit = Math.min(Number(query.limit) || 20, 100);
|
|
7
|
+
const offset = Number(query.offset) || 0;
|
|
8
|
+
const search = query.search ? String(query.search).trim() : void 0;
|
|
9
|
+
const categoryId = query.category ? String(query.category) : void 0;
|
|
10
|
+
const type = query.type ? String(query.type) : void 0;
|
|
11
|
+
const sortBy = query.sortBy ? String(query.sortBy) : void 0;
|
|
12
|
+
const activeTenant = getTenant(event);
|
|
13
|
+
const tenantId = activeTenant ? activeTenant.id : query.tenantId ? String(query.tenantId) : void 0;
|
|
14
|
+
const minPrice = query.minPrice !== void 0 && query.minPrice !== "" ? Number(query.minPrice) : void 0;
|
|
15
|
+
const maxPrice = query.maxPrice !== void 0 && query.maxPrice !== "" ? Number(query.maxPrice) : void 0;
|
|
16
|
+
const inStockOnly = query.inStockOnly === "true" || query.inStockOnly === true || query.inStockOnly === "1" ? true : void 0;
|
|
17
|
+
return queryStoreProducts(
|
|
18
|
+
{
|
|
19
|
+
search,
|
|
20
|
+
categoryId,
|
|
21
|
+
type,
|
|
22
|
+
sortBy,
|
|
23
|
+
minPrice,
|
|
24
|
+
maxPrice,
|
|
25
|
+
inStockOnly,
|
|
26
|
+
limit,
|
|
27
|
+
offset,
|
|
28
|
+
tenantId,
|
|
29
|
+
status: "active"
|
|
30
|
+
},
|
|
31
|
+
event
|
|
32
|
+
);
|
|
33
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POST /api/store/tax/calculate
|
|
3
|
+
*
|
|
4
|
+
* Body: { subtotal: number, country: string, state?: string, vatNumber?: string, isDigital?: boolean, shippingTotal?: number }
|
|
5
|
+
*
|
|
6
|
+
* Returns StoreTaxResult with breakdown.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("nuxt/server").EventHandler<Promise<import("../../../..").StoreTaxResult>>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
|
+
import { calculateStoreTax } from "../../../utils/store-localization.mjs";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const body = await readBody(event).catch(() => null);
|
|
5
|
+
if (typeof body?.subtotal !== "number" || typeof body?.country !== "string") {
|
|
6
|
+
throw createError({ statusCode: 400, statusMessage: "subtotal (number) and country (string) are required" });
|
|
7
|
+
}
|
|
8
|
+
const input = {
|
|
9
|
+
subtotal: body.subtotal,
|
|
10
|
+
country: body.country,
|
|
11
|
+
state: body.state,
|
|
12
|
+
vatNumber: body.vatNumber,
|
|
13
|
+
isDigital: body.isDigital ?? false,
|
|
14
|
+
shippingTotal: body.shippingTotal ?? 0
|
|
15
|
+
};
|
|
16
|
+
const result = calculateStoreTax(input);
|
|
17
|
+
return result;
|
|
18
|
+
});
|
|
@@ -9,6 +9,10 @@ export default defineEventHandler(async (event) => {
|
|
|
9
9
|
if (!userId) {
|
|
10
10
|
throw createError({ statusCode: 401, message: "Authentication required." });
|
|
11
11
|
}
|
|
12
|
+
const tenantParam = getRouterParam(event, "tenant");
|
|
13
|
+
if (!tenantParam) {
|
|
14
|
+
throw createError({ statusCode: 400, message: "Missing tenant identifier." });
|
|
15
|
+
}
|
|
12
16
|
const domain = getRouterParam(event, "domain");
|
|
13
17
|
if (!domain) {
|
|
14
18
|
throw createError({ statusCode: 400, message: "Missing domain parameter." });
|
|
@@ -16,7 +20,10 @@ export default defineEventHandler(async (event) => {
|
|
|
16
20
|
const domainRecord = await getCustomDomain(domain, event);
|
|
17
21
|
if (domainRecord) {
|
|
18
22
|
const tenant = await getTenantById(domainRecord.tenantId, event);
|
|
19
|
-
if (tenant
|
|
23
|
+
if (!tenant || tenant.id !== tenantParam && tenant.slug !== tenantParam) {
|
|
24
|
+
throw createError({ statusCode: 403, message: "Tenant mismatch: domain does not belong to this tenant." });
|
|
25
|
+
}
|
|
26
|
+
if (tenant.organizationId) {
|
|
20
27
|
try {
|
|
21
28
|
const bindingName = globalThis.process?.env?.QARPEO_DEFAULT_DB_BINDING || "DB";
|
|
22
29
|
const d1 = getD1Binding(bindingName, event);
|
|
@@ -29,7 +36,13 @@ export default defineEventHandler(async (event) => {
|
|
|
29
36
|
}
|
|
30
37
|
} catch (err) {
|
|
31
38
|
if (err.statusCode === 403) throw err;
|
|
39
|
+
throw createError({ statusCode: 500, message: "Authorization check failed." });
|
|
32
40
|
}
|
|
41
|
+
} else {
|
|
42
|
+
throw createError({
|
|
43
|
+
statusCode: 403,
|
|
44
|
+
message: "Tenant has no organization; domain management requires an organization."
|
|
45
|
+
});
|
|
33
46
|
}
|
|
34
47
|
}
|
|
35
48
|
const result = await deleteCustomDomain(domain, event);
|
|
@@ -9,6 +9,10 @@ export default defineEventHandler(async (event) => {
|
|
|
9
9
|
if (!userId) {
|
|
10
10
|
throw createError({ statusCode: 401, message: "Authentication required." });
|
|
11
11
|
}
|
|
12
|
+
const tenantParam = getRouterParam(event, "tenant");
|
|
13
|
+
if (!tenantParam) {
|
|
14
|
+
throw createError({ statusCode: 400, message: "Missing tenant identifier." });
|
|
15
|
+
}
|
|
12
16
|
const domain = getRouterParam(event, "domain");
|
|
13
17
|
if (!domain) {
|
|
14
18
|
throw createError({ statusCode: 400, message: "Missing domain parameter." });
|
|
@@ -16,7 +20,10 @@ export default defineEventHandler(async (event) => {
|
|
|
16
20
|
const domainRecord = await getCustomDomain(domain, event);
|
|
17
21
|
if (domainRecord) {
|
|
18
22
|
const tenant = await getTenantById(domainRecord.tenantId, event);
|
|
19
|
-
if (tenant
|
|
23
|
+
if (!tenant || tenant.id !== tenantParam && tenant.slug !== tenantParam) {
|
|
24
|
+
throw createError({ statusCode: 403, message: "Tenant mismatch: domain does not belong to this tenant." });
|
|
25
|
+
}
|
|
26
|
+
if (tenant.organizationId) {
|
|
20
27
|
try {
|
|
21
28
|
const bindingName = globalThis.process?.env?.QARPEO_DEFAULT_DB_BINDING || "DB";
|
|
22
29
|
const d1 = getD1Binding(bindingName, event);
|
|
@@ -29,7 +36,13 @@ export default defineEventHandler(async (event) => {
|
|
|
29
36
|
}
|
|
30
37
|
} catch (err) {
|
|
31
38
|
if (err.statusCode === 403) throw err;
|
|
39
|
+
throw createError({ statusCode: 500, message: "Authorization check failed." });
|
|
32
40
|
}
|
|
41
|
+
} else {
|
|
42
|
+
throw createError({
|
|
43
|
+
statusCode: 403,
|
|
44
|
+
message: "Tenant has no organization; domain management requires an organization."
|
|
45
|
+
});
|
|
33
46
|
}
|
|
34
47
|
}
|
|
35
48
|
const record = await verifyCustomDomain(domain, event);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { defineEventHandler, getRouterParam, createError } from "nuxt/server";
|
|
2
|
+
import { getD1Binding } from "../../../../../db.mjs";
|
|
2
3
|
import { listTenantDomains } from "../../../../utils/domains.mjs";
|
|
3
4
|
import { getAuthSession } from "../../../../utils/session.mjs";
|
|
4
5
|
import { getTenantById, getTenantBySlug } from "../../../../utils/tenant.mjs";
|
|
5
6
|
export default defineEventHandler(async (event) => {
|
|
6
7
|
const session = await getAuthSession(event).catch(() => null);
|
|
7
|
-
|
|
8
|
+
const userId = session?.user?.id;
|
|
9
|
+
if (!userId) {
|
|
8
10
|
throw createError({ statusCode: 401, message: "Authentication required." });
|
|
9
11
|
}
|
|
10
12
|
const tenantParam = getRouterParam(event, "tenant");
|
|
@@ -15,6 +17,27 @@ export default defineEventHandler(async (event) => {
|
|
|
15
17
|
if (!tenant) {
|
|
16
18
|
throw createError({ statusCode: 404, message: `Tenant "${tenantParam}" not found.` });
|
|
17
19
|
}
|
|
20
|
+
if (tenant.organizationId) {
|
|
21
|
+
try {
|
|
22
|
+
const bindingName = globalThis.process?.env?.QARPEO_DEFAULT_DB_BINDING || "DB";
|
|
23
|
+
const d1 = getD1Binding(bindingName, event);
|
|
24
|
+
const membership = await d1.prepare("SELECT role FROM member WHERE organization_id = ? AND user_id = ? LIMIT 1").bind(tenant.organizationId, userId).first();
|
|
25
|
+
if (!membership || !["owner", "admin"].includes(membership.role)) {
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: 403,
|
|
28
|
+
message: "Forbidden: insufficient permissions for this tenant."
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
if (err.statusCode === 403) throw err;
|
|
33
|
+
throw createError({ statusCode: 500, message: "Authorization check failed." });
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
throw createError({
|
|
37
|
+
statusCode: 403,
|
|
38
|
+
message: "Tenant has no organization; domain management requires an organization."
|
|
39
|
+
});
|
|
40
|
+
}
|
|
18
41
|
const domains = await listTenantDomains(tenant.id, event);
|
|
19
42
|
return { domains };
|
|
20
43
|
});
|