qarpeo 0.1.35 → 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 -5118
- 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 +3 -3
- 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 +406 -1288
- 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,266 @@
|
|
|
1
|
+
import { integer, real, text, index, uniqueIndex, snakeCase } from "drizzle-orm/sqlite-core";
|
|
2
|
+
import { resolveTableName, resolveIndexName } from "../utils/table-names.mjs";
|
|
3
|
+
export const ALL_STORE_TABLE_NAMES = [
|
|
4
|
+
"store_product",
|
|
5
|
+
"store_product_variant",
|
|
6
|
+
"store_inventory",
|
|
7
|
+
"store_category",
|
|
8
|
+
"store_cart",
|
|
9
|
+
"store_cart_item",
|
|
10
|
+
"store_order",
|
|
11
|
+
"store_order_item",
|
|
12
|
+
"store_discount",
|
|
13
|
+
"store_customer_address"
|
|
14
|
+
];
|
|
15
|
+
export function getActiveStoreTableNames(store, prefixOrOptions) {
|
|
16
|
+
if (!store) return [];
|
|
17
|
+
const resolvedPrefix = prefixOrOptions !== void 0 ? prefixOrOptions : typeof store === "object" && store.tablePrefix !== void 0 ? store.tablePrefix : void 0;
|
|
18
|
+
return ALL_STORE_TABLE_NAMES.map((name) => resolveTableName(name, resolvedPrefix));
|
|
19
|
+
}
|
|
20
|
+
const productTbl = resolveTableName("store_product");
|
|
21
|
+
const variantTbl = resolveTableName("store_product_variant");
|
|
22
|
+
const inventoryTbl = resolveTableName("store_inventory");
|
|
23
|
+
const categoryTbl = resolveTableName("store_category");
|
|
24
|
+
const cartTbl = resolveTableName("store_cart");
|
|
25
|
+
const cartItemTbl = resolveTableName("store_cart_item");
|
|
26
|
+
const orderTbl = resolveTableName("store_order");
|
|
27
|
+
const orderItemTbl = resolveTableName("store_order_item");
|
|
28
|
+
const discountTbl = resolveTableName("store_discount");
|
|
29
|
+
const addressTbl = resolveTableName("store_customer_address");
|
|
30
|
+
export const storeProduct = snakeCase.table(
|
|
31
|
+
productTbl,
|
|
32
|
+
{
|
|
33
|
+
id: text().primaryKey(),
|
|
34
|
+
tenantId: text(),
|
|
35
|
+
slug: text().notNull(),
|
|
36
|
+
title: text().notNull(),
|
|
37
|
+
description: text(),
|
|
38
|
+
status: text().notNull().default("draft"),
|
|
39
|
+
type: text().notNull().default("physical"),
|
|
40
|
+
basePrice: integer().notNull(),
|
|
41
|
+
currency: text().notNull().default("USD"),
|
|
42
|
+
categoryId: text(),
|
|
43
|
+
imagesJson: text().notNull().default("[]"),
|
|
44
|
+
metadataJson: text().notNull().default("{}"),
|
|
45
|
+
createdAt: integer().notNull(),
|
|
46
|
+
updatedAt: integer().notNull()
|
|
47
|
+
},
|
|
48
|
+
(t) => [
|
|
49
|
+
uniqueIndex(resolveIndexName(productTbl, "unique_slug")).on(t.tenantId, t.slug),
|
|
50
|
+
index(resolveIndexName(productTbl, "status")).on(t.status),
|
|
51
|
+
index(resolveIndexName(productTbl, "category")).on(t.categoryId),
|
|
52
|
+
index(resolveIndexName(productTbl, "tenant")).on(t.tenantId)
|
|
53
|
+
]
|
|
54
|
+
);
|
|
55
|
+
export const storeProductVariant = snakeCase.table(
|
|
56
|
+
variantTbl,
|
|
57
|
+
{
|
|
58
|
+
id: text().primaryKey(),
|
|
59
|
+
productId: text().notNull(),
|
|
60
|
+
sku: text().notNull(),
|
|
61
|
+
title: text().notNull(),
|
|
62
|
+
optionsJson: text().notNull().default("{}"),
|
|
63
|
+
priceOverride: integer(),
|
|
64
|
+
weight: real(),
|
|
65
|
+
barcode: text(),
|
|
66
|
+
image: text(),
|
|
67
|
+
createdAt: integer().notNull(),
|
|
68
|
+
updatedAt: integer().notNull()
|
|
69
|
+
},
|
|
70
|
+
(t) => [
|
|
71
|
+
index(resolveIndexName(variantTbl, "product")).on(t.productId),
|
|
72
|
+
index(resolveIndexName(variantTbl, "sku")).on(t.sku)
|
|
73
|
+
]
|
|
74
|
+
);
|
|
75
|
+
export const storeInventory = snakeCase.table(
|
|
76
|
+
inventoryTbl,
|
|
77
|
+
{
|
|
78
|
+
id: text().primaryKey(),
|
|
79
|
+
variantId: text().notNull(),
|
|
80
|
+
productId: text().notNull(),
|
|
81
|
+
stockQuantity: integer().notNull().default(0),
|
|
82
|
+
reservedQuantity: integer().notNull().default(0),
|
|
83
|
+
allowBackorder: integer().notNull().default(0),
|
|
84
|
+
lowStockThreshold: integer().notNull().default(5),
|
|
85
|
+
createdAt: integer().notNull(),
|
|
86
|
+
updatedAt: integer().notNull()
|
|
87
|
+
},
|
|
88
|
+
(t) => [
|
|
89
|
+
uniqueIndex(resolveIndexName(inventoryTbl, "variant")).on(t.variantId),
|
|
90
|
+
index(resolveIndexName(inventoryTbl, "product")).on(t.productId)
|
|
91
|
+
]
|
|
92
|
+
);
|
|
93
|
+
export const storeCategory = snakeCase.table(
|
|
94
|
+
categoryTbl,
|
|
95
|
+
{
|
|
96
|
+
id: text().primaryKey(),
|
|
97
|
+
tenantId: text(),
|
|
98
|
+
slug: text().notNull(),
|
|
99
|
+
name: text().notNull(),
|
|
100
|
+
description: text(),
|
|
101
|
+
image: text(),
|
|
102
|
+
parentId: text(),
|
|
103
|
+
order: integer().notNull().default(0),
|
|
104
|
+
metadataJson: text().notNull().default("{}"),
|
|
105
|
+
createdAt: integer().notNull(),
|
|
106
|
+
updatedAt: integer().notNull()
|
|
107
|
+
},
|
|
108
|
+
(t) => [
|
|
109
|
+
uniqueIndex(resolveIndexName(categoryTbl, "unique_slug")).on(t.tenantId, t.slug),
|
|
110
|
+
index(resolveIndexName(categoryTbl, "parent")).on(t.parentId),
|
|
111
|
+
index(resolveIndexName(categoryTbl, "tenant")).on(t.tenantId)
|
|
112
|
+
]
|
|
113
|
+
);
|
|
114
|
+
export const storeCart = snakeCase.table(
|
|
115
|
+
cartTbl,
|
|
116
|
+
{
|
|
117
|
+
id: text().primaryKey(),
|
|
118
|
+
tenantId: text(),
|
|
119
|
+
userId: text(),
|
|
120
|
+
sessionToken: text().notNull(),
|
|
121
|
+
currency: text().notNull().default("USD"),
|
|
122
|
+
couponCode: text(),
|
|
123
|
+
metadataJson: text().notNull().default("{}"),
|
|
124
|
+
expiresAt: integer().notNull(),
|
|
125
|
+
createdAt: integer().notNull(),
|
|
126
|
+
updatedAt: integer().notNull()
|
|
127
|
+
},
|
|
128
|
+
(t) => [
|
|
129
|
+
uniqueIndex(resolveIndexName(cartTbl, "session")).on(t.sessionToken),
|
|
130
|
+
index(resolveIndexName(cartTbl, "user")).on(t.userId),
|
|
131
|
+
index(resolveIndexName(cartTbl, "expires")).on(t.expiresAt)
|
|
132
|
+
]
|
|
133
|
+
);
|
|
134
|
+
export const storeCartItem = snakeCase.table(
|
|
135
|
+
cartItemTbl,
|
|
136
|
+
{
|
|
137
|
+
id: text().primaryKey(),
|
|
138
|
+
cartId: text().notNull(),
|
|
139
|
+
productId: text().notNull(),
|
|
140
|
+
variantId: text().notNull(),
|
|
141
|
+
quantity: integer().notNull().default(1),
|
|
142
|
+
customAttributesJson: text().notNull().default("{}"),
|
|
143
|
+
createdAt: integer().notNull(),
|
|
144
|
+
updatedAt: integer().notNull()
|
|
145
|
+
},
|
|
146
|
+
(t) => [
|
|
147
|
+
index(resolveIndexName(cartItemTbl, "cart")).on(t.cartId),
|
|
148
|
+
index(resolveIndexName(cartItemTbl, "variant")).on(t.variantId)
|
|
149
|
+
]
|
|
150
|
+
);
|
|
151
|
+
export const storeOrder = snakeCase.table(
|
|
152
|
+
orderTbl,
|
|
153
|
+
{
|
|
154
|
+
id: text().primaryKey(),
|
|
155
|
+
tenantId: text(),
|
|
156
|
+
orderNumber: text().notNull(),
|
|
157
|
+
userId: text(),
|
|
158
|
+
customerEmail: text().notNull(),
|
|
159
|
+
customerName: text(),
|
|
160
|
+
status: text().notNull().default("pending"),
|
|
161
|
+
currency: text().notNull().default("USD"),
|
|
162
|
+
subtotal: integer().notNull(),
|
|
163
|
+
taxTotal: integer().notNull().default(0),
|
|
164
|
+
shippingTotal: integer().notNull().default(0),
|
|
165
|
+
discountTotal: integer().notNull().default(0),
|
|
166
|
+
total: integer().notNull(),
|
|
167
|
+
paymentProvider: text(),
|
|
168
|
+
paymentIntentId: text(),
|
|
169
|
+
shippingAddressJson: text().notNull().default("{}"),
|
|
170
|
+
billingAddressJson: text().notNull().default("{}"),
|
|
171
|
+
metadataJson: text().notNull().default("{}"),
|
|
172
|
+
paidAt: integer(),
|
|
173
|
+
shippedAt: integer(),
|
|
174
|
+
deliveredAt: integer(),
|
|
175
|
+
cancelledAt: integer(),
|
|
176
|
+
refundedAt: integer(),
|
|
177
|
+
createdAt: integer().notNull(),
|
|
178
|
+
updatedAt: integer().notNull()
|
|
179
|
+
},
|
|
180
|
+
(t) => [
|
|
181
|
+
uniqueIndex(resolveIndexName(orderTbl, "unique_number")).on(t.tenantId, t.orderNumber),
|
|
182
|
+
index(resolveIndexName(orderTbl, "user")).on(t.userId),
|
|
183
|
+
index(resolveIndexName(orderTbl, "email")).on(t.customerEmail),
|
|
184
|
+
index(resolveIndexName(orderTbl, "status")).on(t.status),
|
|
185
|
+
index(resolveIndexName(orderTbl, "created")).on(t.createdAt)
|
|
186
|
+
]
|
|
187
|
+
);
|
|
188
|
+
export const storeOrderItem = snakeCase.table(
|
|
189
|
+
orderItemTbl,
|
|
190
|
+
{
|
|
191
|
+
id: text().primaryKey(),
|
|
192
|
+
orderId: text().notNull(),
|
|
193
|
+
productId: text().notNull(),
|
|
194
|
+
variantId: text().notNull(),
|
|
195
|
+
sku: text().notNull(),
|
|
196
|
+
title: text().notNull(),
|
|
197
|
+
unitPrice: integer().notNull(),
|
|
198
|
+
quantity: integer().notNull().default(1),
|
|
199
|
+
totalPrice: integer().notNull(),
|
|
200
|
+
isDigital: integer().notNull().default(0),
|
|
201
|
+
downloadKey: text(),
|
|
202
|
+
metadataJson: text().notNull().default("{}"),
|
|
203
|
+
createdAt: integer().notNull()
|
|
204
|
+
},
|
|
205
|
+
(t) => [
|
|
206
|
+
index(resolveIndexName(orderItemTbl, "order")).on(t.orderId),
|
|
207
|
+
index(resolveIndexName(orderItemTbl, "variant")).on(t.variantId)
|
|
208
|
+
]
|
|
209
|
+
);
|
|
210
|
+
export const storeDiscount = snakeCase.table(
|
|
211
|
+
discountTbl,
|
|
212
|
+
{
|
|
213
|
+
id: text().primaryKey(),
|
|
214
|
+
tenantId: text(),
|
|
215
|
+
code: text().notNull(),
|
|
216
|
+
type: text().notNull().default("percentage"),
|
|
217
|
+
value: integer().notNull(),
|
|
218
|
+
minOrderAmount: integer().notNull().default(0),
|
|
219
|
+
maxUses: integer(),
|
|
220
|
+
usedCount: integer().notNull().default(0),
|
|
221
|
+
startsAt: integer(),
|
|
222
|
+
expiresAt: integer(),
|
|
223
|
+
isActive: integer().notNull().default(1),
|
|
224
|
+
metadataJson: text().notNull().default("{}"),
|
|
225
|
+
createdAt: integer().notNull(),
|
|
226
|
+
updatedAt: integer().notNull()
|
|
227
|
+
},
|
|
228
|
+
(t) => [
|
|
229
|
+
uniqueIndex(resolveIndexName(discountTbl, "unique_code")).on(t.tenantId, t.code),
|
|
230
|
+
index(resolveIndexName(discountTbl, "active")).on(t.isActive)
|
|
231
|
+
]
|
|
232
|
+
);
|
|
233
|
+
export const storeCustomerAddress = snakeCase.table(
|
|
234
|
+
addressTbl,
|
|
235
|
+
{
|
|
236
|
+
id: text().primaryKey(),
|
|
237
|
+
userId: text().notNull(),
|
|
238
|
+
type: text().notNull().default("shipping"),
|
|
239
|
+
name: text().notNull(),
|
|
240
|
+
company: text(),
|
|
241
|
+
line1: text().notNull(),
|
|
242
|
+
line2: text(),
|
|
243
|
+
city: text().notNull(),
|
|
244
|
+
state: text(),
|
|
245
|
+
postalCode: text().notNull(),
|
|
246
|
+
country: text().notNull(),
|
|
247
|
+
phone: text(),
|
|
248
|
+
isDefault: integer().notNull().default(0),
|
|
249
|
+
createdAt: integer().notNull(),
|
|
250
|
+
updatedAt: integer().notNull()
|
|
251
|
+
},
|
|
252
|
+
(t) => [
|
|
253
|
+
index(resolveIndexName(addressTbl, "user")).on(t.userId),
|
|
254
|
+
index(resolveIndexName(addressTbl, "type")).on(t.type)
|
|
255
|
+
]
|
|
256
|
+
);
|
|
257
|
+
export const storeProducts = storeProduct;
|
|
258
|
+
export const storeProductVariants = storeProductVariant;
|
|
259
|
+
export const storeInventories = storeInventory;
|
|
260
|
+
export const storeCategories = storeCategory;
|
|
261
|
+
export const storeCarts = storeCart;
|
|
262
|
+
export const storeCartItems = storeCartItem;
|
|
263
|
+
export const storeOrders = storeOrder;
|
|
264
|
+
export const storeOrderItems = storeOrderItem;
|
|
265
|
+
export const storeDiscounts = storeDiscount;
|
|
266
|
+
export const storeCustomerAddresses = storeCustomerAddress;
|
|
@@ -161,10 +161,28 @@ export class QarpeoAgentDO {
|
|
|
161
161
|
const pathname = url.pathname;
|
|
162
162
|
try {
|
|
163
163
|
if (request.method === "GET" && pathname.endsWith("/history")) {
|
|
164
|
+
if (this.ctx.storage?.sql) {
|
|
165
|
+
try {
|
|
166
|
+
this.ctx.storage.sql.exec(
|
|
167
|
+
"CREATE TABLE IF NOT EXISTS messages (id TEXT PRIMARY KEY, role TEXT, content TEXT, createdAt INTEGER)"
|
|
168
|
+
);
|
|
169
|
+
const rows = this.ctx.storage.sql.exec("SELECT * FROM messages ORDER BY createdAt ASC").toArray();
|
|
170
|
+
if (rows.length > 0) {
|
|
171
|
+
return Response.json({ messages: rows });
|
|
172
|
+
}
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
175
|
+
}
|
|
164
176
|
const messages = await this.ctx.storage.get("messages") || [];
|
|
165
177
|
return Response.json({ messages });
|
|
166
178
|
}
|
|
167
179
|
if (request.method === "POST" && pathname.endsWith("/clear")) {
|
|
180
|
+
if (this.ctx.storage?.sql) {
|
|
181
|
+
try {
|
|
182
|
+
this.ctx.storage.sql.exec("DELETE FROM messages");
|
|
183
|
+
} catch {
|
|
184
|
+
}
|
|
185
|
+
}
|
|
168
186
|
await this.ctx.storage.delete("messages");
|
|
169
187
|
return Response.json({ success: true, messages: [] });
|
|
170
188
|
}
|
|
@@ -562,6 +580,23 @@ data: ${JSON.stringify(data)}
|
|
|
562
580
|
createdAt: Date.now()
|
|
563
581
|
};
|
|
564
582
|
messages.push(assistantMsg);
|
|
583
|
+
if (this.ctx.storage?.sql) {
|
|
584
|
+
try {
|
|
585
|
+
this.ctx.storage.sql.exec(
|
|
586
|
+
"CREATE TABLE IF NOT EXISTS messages (id TEXT PRIMARY KEY, role TEXT, content TEXT, createdAt INTEGER)"
|
|
587
|
+
);
|
|
588
|
+
for (const m of messages) {
|
|
589
|
+
this.ctx.storage.sql.exec(
|
|
590
|
+
"INSERT OR REPLACE INTO messages (id, role, content, createdAt) VALUES (?, ?, ?, ?)",
|
|
591
|
+
m.id || `msg_${Date.now()}`,
|
|
592
|
+
m.role,
|
|
593
|
+
m.content,
|
|
594
|
+
m.createdAt || Date.now()
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
} catch {
|
|
598
|
+
}
|
|
599
|
+
}
|
|
565
600
|
await this.ctx.storage.put("messages", messages);
|
|
566
601
|
return Response.json({
|
|
567
602
|
id: assistantMsg.id,
|
|
@@ -13,7 +13,7 @@ function matchRouteRule(path, rules) {
|
|
|
13
13
|
for (const [pattern, rule] of Object.entries(rules)) {
|
|
14
14
|
if (!rule) continue;
|
|
15
15
|
if (getOrCompileRouteRegex(pattern).test(path)) {
|
|
16
|
-
return rule;
|
|
16
|
+
return { pattern, rule };
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
return null;
|
|
@@ -23,9 +23,9 @@ export default defineEventHandler(async (event) => {
|
|
|
23
23
|
if (!ratelimitConfig || ratelimitConfig.enabled === false) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
+
const clientIp = getClientIp(event);
|
|
26
27
|
if (Array.isArray(ratelimitConfig.ipWhitelist) && ratelimitConfig.ipWhitelist.length > 0) {
|
|
27
|
-
|
|
28
|
-
if (ratelimitConfig.ipWhitelist.includes(ip)) {
|
|
28
|
+
if (ratelimitConfig.ipWhitelist.includes(clientIp)) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -36,12 +36,13 @@ export default defineEventHandler(async (event) => {
|
|
|
36
36
|
pathname = event.path || "/";
|
|
37
37
|
}
|
|
38
38
|
const rules = ratelimitConfig.rules || {};
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
39
|
+
const matched = matchRouteRule(pathname, rules);
|
|
40
|
+
if (matched) {
|
|
41
|
+
const key = matched.rule.key ? `${matched.rule.key}:${clientIp}` : `rule:${matched.pattern}:${clientIp}`;
|
|
41
42
|
await assertRateLimit(event, {
|
|
42
|
-
max:
|
|
43
|
-
window:
|
|
44
|
-
key
|
|
43
|
+
max: matched.rule.max ?? ratelimitConfig.max ?? 100,
|
|
44
|
+
window: matched.rule.window ?? ratelimitConfig.window ?? "1m",
|
|
45
|
+
key,
|
|
45
46
|
backend: ratelimitConfig.backend
|
|
46
47
|
});
|
|
47
48
|
return;
|
|
@@ -50,6 +51,7 @@ export default defineEventHandler(async (event) => {
|
|
|
50
51
|
await assertRateLimit(event, {
|
|
51
52
|
max: ratelimitConfig.max,
|
|
52
53
|
window: ratelimitConfig.window ?? "1m",
|
|
54
|
+
key: `global:${clientIp}`,
|
|
53
55
|
backend: ratelimitConfig.backend
|
|
54
56
|
});
|
|
55
57
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NitroApp } from "nitro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Nitro server plugin for Qarpeo Comments.
|
|
4
|
+
* Pre-warms database tables on request lifecycle so individual route handlers
|
|
5
|
+
* do not need to repeat DDL checks.
|
|
6
|
+
*/
|
|
7
|
+
export default function (nitroApp: NitroApp): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import inboundHandler from "#qarpeo/email-inbound-handler";
|
|
2
|
+
import { setCloudflareEnv } from "../../bindings.mjs";
|
|
3
|
+
import { createInboundEmailContext } from "../utils/email-inbound.mjs";
|
|
4
|
+
export default function(nitroApp) {
|
|
5
|
+
if (typeof inboundHandler === "function") {
|
|
6
|
+
nitroApp.hooks?.hook("cloudflare:email", async (eventPayload) => {
|
|
7
|
+
const message = eventPayload?.message || eventPayload;
|
|
8
|
+
const env = eventPayload?.env || globalThis?.__env__;
|
|
9
|
+
const context = eventPayload?.context || eventPayload?.ctx;
|
|
10
|
+
if (env) {
|
|
11
|
+
setCloudflareEnv(env);
|
|
12
|
+
}
|
|
13
|
+
const emailContext = createInboundEmailContext(message, env, context);
|
|
14
|
+
await inboundHandler(emailContext);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NitroApp } from "nitro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Nitro server plugin for Qarpeo Store App.
|
|
4
|
+
* Pre-warms database tables on request lifecycle with module-level promise caching
|
|
5
|
+
* so individual route handlers do not need to repeat DDL checks.
|
|
6
|
+
*/
|
|
7
|
+
export default function (nitroApp: NitroApp): void;
|
|
@@ -55,7 +55,7 @@ export default defineEventHandler(async (event) => {
|
|
|
55
55
|
]
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
|
-
name: "
|
|
58
|
+
name: "cms_entry",
|
|
59
59
|
rows: 5,
|
|
60
60
|
columns: [
|
|
61
61
|
{ name: "id", type: "TEXT", notNull: true, primaryKey: true },
|
|
@@ -67,7 +67,7 @@ export default defineEventHandler(async (event) => {
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
|
-
name: "
|
|
70
|
+
name: "domain",
|
|
71
71
|
rows: 1,
|
|
72
72
|
columns: [
|
|
73
73
|
{ name: "id", type: "TEXT", notNull: true, primaryKey: true },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler } from "nuxt/server";
|
|
2
2
|
import { getCloudflareEnv } from "../../bindings.mjs";
|
|
3
3
|
import { buildAtomXml, formatISO8601, rowToFeedEntry } from "../utils/feed.mjs";
|
|
4
|
+
import { resolveTableName } from "../utils/table-names.mjs";
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
5
6
|
const runtimeConfig = globalThis.__NUXT_RUNTIME_CONFIG__ || {};
|
|
6
7
|
const site = runtimeConfig.public?.qarpeo?.site || {};
|
|
@@ -26,7 +27,8 @@ export default defineEventHandler(async (event) => {
|
|
|
26
27
|
const env = getCloudflareEnv(event);
|
|
27
28
|
const d1Binding = env.DB || env.DATABASE || env.d1;
|
|
28
29
|
if (d1Binding && typeof d1Binding.prepare === "function") {
|
|
29
|
-
|
|
30
|
+
const entryTbl = resolveTableName("cms_entry", event);
|
|
31
|
+
let query = `SELECT id, slug, path, collection, title, description, tags, published_at, created_at, updated_at, author_id FROM ${entryTbl} WHERE status = 'published' AND visibility = 'public'`;
|
|
30
32
|
const params = [];
|
|
31
33
|
if (feedConfig.collections?.length) {
|
|
32
34
|
const placeholders = feedConfig.collections.map(() => "?").join(", ");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
2
|
import { getD1Binding } from "../../../../db.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { decryptToken } from "../../../utils/crypto.mjs";
|
|
4
|
+
import { requireAuthSession, revokeOtherDeviceSessions, setAuthSession } from "../../../utils/session.mjs";
|
|
4
5
|
import { verifyTOTPCode } from "../../../utils/totp.mjs";
|
|
5
6
|
export default defineEventHandler(async (event) => {
|
|
6
7
|
const session = await requireAuthSession(event);
|
|
@@ -27,7 +28,7 @@ export default defineEventHandler(async (event) => {
|
|
|
27
28
|
message: "2FA is not enabled for this account"
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
const isValid = await verifyTOTPCode(twoFactorRecord.secret, code);
|
|
31
|
+
const isValid = await verifyTOTPCode(await decryptToken(twoFactorRecord.secret, event), code);
|
|
31
32
|
if (!isValid) {
|
|
32
33
|
throw createError({
|
|
33
34
|
statusCode: 400,
|
|
@@ -40,5 +41,15 @@ export default defineEventHandler(async (event) => {
|
|
|
40
41
|
} catch (err) {
|
|
41
42
|
console.warn("[qarpeo] Failed to disable 2FA in D1:", err.message);
|
|
42
43
|
}
|
|
44
|
+
const currentSessionId = session?.sessionId;
|
|
45
|
+
if (user.id && currentSessionId) {
|
|
46
|
+
await revokeOtherDeviceSessions(event, user.id, currentSessionId);
|
|
47
|
+
}
|
|
48
|
+
if (session?.mfaVerified) {
|
|
49
|
+
await setAuthSession(event, {
|
|
50
|
+
...session,
|
|
51
|
+
mfaVerified: false
|
|
52
|
+
});
|
|
53
|
+
}
|
|
43
54
|
return { disabled: true };
|
|
44
55
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineEventHandler, createError, useRuntimeConfig } from "nuxt/server";
|
|
2
2
|
import { getKVBinding } from "../../../../kv.mjs";
|
|
3
|
+
import { encryptToken } from "../../../utils/crypto.mjs";
|
|
3
4
|
import { requireAuthSession } from "../../../utils/session.mjs";
|
|
4
5
|
import { generateBase32Secret, generateBackupCodes, generateTOTPUrl } from "../../../utils/totp.mjs";
|
|
5
6
|
export default defineEventHandler(async (event) => {
|
|
@@ -19,9 +20,14 @@ export default defineEventHandler(async (event) => {
|
|
|
19
20
|
});
|
|
20
21
|
try {
|
|
21
22
|
const kv = getKVBinding("KV", event);
|
|
22
|
-
await
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const encryptedSecret = await encryptToken(secret, event);
|
|
24
|
+
await kv.put(
|
|
25
|
+
`2fa:setup:${user.id}`,
|
|
26
|
+
JSON.stringify({ secret: encryptedSecret, backupCodes: hashedCodes }),
|
|
27
|
+
{
|
|
28
|
+
expirationTtl: 600
|
|
29
|
+
}
|
|
30
|
+
);
|
|
25
31
|
} catch {
|
|
26
32
|
}
|
|
27
33
|
return {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
2
|
import { getD1Binding } from "../../../../db.mjs";
|
|
3
3
|
import { getKVBinding } from "../../../../kv.mjs";
|
|
4
|
+
import { decryptToken, encryptToken } from "../../../utils/crypto.mjs";
|
|
5
|
+
import { assertRateLimit } from "../../../utils/ratelimit.mjs";
|
|
4
6
|
import { requireAuthSession, setAuthSession } from "../../../utils/session.mjs";
|
|
5
7
|
import { hashBackupCode, verifyTOTPCode } from "../../../utils/totp.mjs";
|
|
6
8
|
export default defineEventHandler(async (event) => {
|
|
@@ -9,6 +11,12 @@ export default defineEventHandler(async (event) => {
|
|
|
9
11
|
if (!user || !user.id) {
|
|
10
12
|
throw createError({ statusCode: 401, statusMessage: "Unauthorized" });
|
|
11
13
|
}
|
|
14
|
+
await assertRateLimit(event, {
|
|
15
|
+
key: `2fa:verify:${user.id}`,
|
|
16
|
+
max: 5,
|
|
17
|
+
window: "60s",
|
|
18
|
+
message: "Too many 2FA verification attempts. Please wait 1 minute before trying again."
|
|
19
|
+
});
|
|
12
20
|
const body = await readBody(event);
|
|
13
21
|
const code = body?.code;
|
|
14
22
|
if (!code || typeof code !== "string") {
|
|
@@ -28,7 +36,7 @@ export default defineEventHandler(async (event) => {
|
|
|
28
36
|
const kv = getKVBinding("KV", event);
|
|
29
37
|
const setupData = await kv.get(`2fa:setup:${user.id}`, { type: "json" });
|
|
30
38
|
if (setupData?.secret) {
|
|
31
|
-
secret = setupData.secret;
|
|
39
|
+
secret = await decryptToken(setupData.secret, event);
|
|
32
40
|
backupCodes = setupData.backupCodes || [];
|
|
33
41
|
}
|
|
34
42
|
} catch {
|
|
@@ -38,7 +46,7 @@ export default defineEventHandler(async (event) => {
|
|
|
38
46
|
try {
|
|
39
47
|
const existing = await d1.prepare("SELECT * FROM two_factor WHERE user_id = ? AND enabled = 1 LIMIT 1").bind(user.id).first();
|
|
40
48
|
if (existing?.secret) {
|
|
41
|
-
secret = existing.secret;
|
|
49
|
+
secret = await decryptToken(existing.secret, event);
|
|
42
50
|
isExisting = true;
|
|
43
51
|
}
|
|
44
52
|
} catch {
|
|
@@ -70,7 +78,7 @@ export default defineEventHandler(async (event) => {
|
|
|
70
78
|
INSERT INTO two_factor (id, user_id, secret, backup_codes, enabled, created_at)
|
|
71
79
|
VALUES (?, ?, ?, ?, 1, ?)
|
|
72
80
|
ON CONFLICT(user_id) DO UPDATE SET secret = excluded.secret, backup_codes = excluded.backup_codes, enabled = 1
|
|
73
|
-
`).bind(id, user.id, secret, JSON.stringify(hashedBackupCodes), now).run();
|
|
81
|
+
`).bind(id, user.id, await encryptToken(secret, event), JSON.stringify(hashedBackupCodes), now).run();
|
|
74
82
|
try {
|
|
75
83
|
const kv = getKVBinding("KV", event);
|
|
76
84
|
await kv.delete(`2fa:setup:${user.id}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
2
|
import { deleteUserAccount } from "../../utils/auth.mjs";
|
|
3
3
|
import { getQarpeoConfig } from "../../utils/config.mjs";
|
|
4
|
-
import { requireAuthSession, clearAuthSession } from "../../utils/session.mjs";
|
|
4
|
+
import { requireAuthSession, clearAuthSession, revokeAllDeviceSessions } from "../../utils/session.mjs";
|
|
5
5
|
import { requireTurnstile } from "../../utils/turnstile.mjs";
|
|
6
6
|
export default defineEventHandler(async (event) => {
|
|
7
7
|
const session = await requireAuthSession(event);
|
|
@@ -34,6 +34,7 @@ export default defineEventHandler(async (event) => {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
|
+
await revokeAllDeviceSessions(event, user.id);
|
|
37
38
|
await deleteUserAccount(event, user.id, {
|
|
38
39
|
cascadeOrg: Boolean(body.cascadeOrg || deletionConfig.allowOrgCascade && body.confirm)
|
|
39
40
|
});
|
|
@@ -4,7 +4,7 @@ import { requireAuthSession } from "../../utils/session.mjs";
|
|
|
4
4
|
export default defineEventHandler(async (event) => {
|
|
5
5
|
const session = await requireAuthSession(event);
|
|
6
6
|
const role = session.user?.role;
|
|
7
|
-
if (role !== "admin" && role !== "
|
|
7
|
+
if (role !== "admin" && role !== "super") {
|
|
8
8
|
throw createError({ statusCode: 403, statusMessage: "Forbidden" });
|
|
9
9
|
}
|
|
10
10
|
const query = getQuery(event);
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
declare const _default: import("nuxt/server").EventHandler<Promise<
|
|
2
|
-
sent: boolean;
|
|
3
|
-
expiresAt: number;
|
|
4
|
-
error: string;
|
|
5
|
-
} | {
|
|
6
|
-
sent: boolean;
|
|
7
|
-
expiresAt: number;
|
|
8
|
-
error?: undefined;
|
|
9
|
-
}>>;
|
|
1
|
+
declare const _default: import("nuxt/server").EventHandler<Promise<import("../../../utils/passwordless").SendMagicLinkResult>>;
|
|
10
2
|
export default _default;
|
|
@@ -2,6 +2,7 @@ import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
|
2
2
|
import { getQarpeoConfig } from "../../../utils/config.mjs";
|
|
3
3
|
import { sendMagicLink } from "../../../utils/passwordless.mjs";
|
|
4
4
|
import { requireTurnstile } from "../../../utils/turnstile.mjs";
|
|
5
|
+
import { assertRateLimit, getClientIp } from "../../../utils/ratelimit.mjs";
|
|
5
6
|
export default defineEventHandler(async (event) => {
|
|
6
7
|
const body = await readBody(event);
|
|
7
8
|
const email = body?.email;
|
|
@@ -17,6 +18,13 @@ export default defineEventHandler(async (event) => {
|
|
|
17
18
|
if (turnstileProtect) {
|
|
18
19
|
await requireTurnstile(event, body?.turnstileToken);
|
|
19
20
|
}
|
|
21
|
+
const ip = getClientIp(event);
|
|
22
|
+
await assertRateLimit(event, {
|
|
23
|
+
key: `auth:magic:send:ip:${ip}`,
|
|
24
|
+
max: 10,
|
|
25
|
+
window: "10m",
|
|
26
|
+
message: "Too many magic link requests from this IP address. Please try again later."
|
|
27
|
+
});
|
|
20
28
|
const result = await sendMagicLink(event, email);
|
|
21
29
|
if (!result.sent) {
|
|
22
30
|
throw createError({
|
|
@@ -23,6 +23,6 @@ export default defineEventHandler(async (event) => {
|
|
|
23
23
|
message: "Only organization owners and admins can delete SSO connections."
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
await d1.prepare("DELETE FROM
|
|
26
|
+
await d1.prepare("DELETE FROM sso_connection WHERE id = ? AND organization_id = ?").bind(connectionId, orgId).run();
|
|
27
27
|
return { success: true };
|
|
28
28
|
});
|
|
@@ -15,7 +15,7 @@ export default defineEventHandler(async (event) => {
|
|
|
15
15
|
const d1 = getD1Binding(bindingName, event);
|
|
16
16
|
const connections = await d1.prepare(`
|
|
17
17
|
SELECT id, organization_id, provider_type, name, domain, client_id, issuer, sso_url, token_url, userinfo_url, enabled, created_at, updated_at
|
|
18
|
-
FROM
|
|
18
|
+
FROM sso_connection
|
|
19
19
|
WHERE organization_id = ?
|
|
20
20
|
ORDER BY created_at DESC
|
|
21
21
|
`).bind(orgId).all();
|