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
|
@@ -4,6 +4,7 @@ import { createError } from "nuxt/server";
|
|
|
4
4
|
import * as authSchema from "#qarpeo/auth/schema";
|
|
5
5
|
import { getSessionSecret } from "./config.mjs";
|
|
6
6
|
import { useDrizzle } from "./drizzle.mjs";
|
|
7
|
+
import { resolveTableName, resolveIndexName } from "./table-names.mjs";
|
|
7
8
|
const _authCache = /* @__PURE__ */ new Map();
|
|
8
9
|
export function serverAuth(event) {
|
|
9
10
|
const cfEnv = event?.context?.cloudflare?.env;
|
|
@@ -63,7 +64,7 @@ export async function getServerSession(event) {
|
|
|
63
64
|
headers: ev.headers,
|
|
64
65
|
method: ev.method
|
|
65
66
|
});
|
|
66
|
-
return auth.api.getSession({
|
|
67
|
+
return await auth.api.getSession({
|
|
67
68
|
headers: req.headers
|
|
68
69
|
});
|
|
69
70
|
}
|
|
@@ -72,7 +73,8 @@ export async function requireServerSession(event) {
|
|
|
72
73
|
if (!session?.user) {
|
|
73
74
|
throw createError({
|
|
74
75
|
statusCode: 401,
|
|
75
|
-
statusMessage: "Unauthorized"
|
|
76
|
+
statusMessage: "Unauthorized",
|
|
77
|
+
message: "Authentication required"
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
return session;
|
|
@@ -80,14 +82,26 @@ export async function requireServerSession(event) {
|
|
|
80
82
|
import { getD1Binding } from "../../db.mjs";
|
|
81
83
|
import { getQarpeoConfig } from "./config.mjs";
|
|
82
84
|
import { encryptToken } from "./crypto.mjs";
|
|
83
|
-
import { createDeviceSession, setAuthSession } from "./session.mjs";
|
|
85
|
+
import { createDeviceSession, setAuthSession, revokeAllDeviceSessions } from "./session.mjs";
|
|
84
86
|
let ensureAuthTablesPromise = null;
|
|
85
|
-
export async function ensureAuthTables(d1) {
|
|
87
|
+
export async function ensureAuthTables(d1, event) {
|
|
86
88
|
if (!ensureAuthTablesPromise) {
|
|
87
89
|
ensureAuthTablesPromise = (async () => {
|
|
90
|
+
const userTbl = resolveTableName("user", event);
|
|
91
|
+
const accountTbl = resolveTableName("account", event);
|
|
92
|
+
const sessionTbl = resolveTableName("session", event);
|
|
93
|
+
const verificationTbl = resolveTableName("verification", event);
|
|
94
|
+
const twoFactorTbl = resolveTableName("two_factor", event);
|
|
95
|
+
const passkeyTbl = resolveTableName("passkey", event);
|
|
96
|
+
const organizationTbl = resolveTableName("organization", event);
|
|
97
|
+
const memberTbl = resolveTableName("member", event);
|
|
98
|
+
const invitationTbl = resolveTableName("invitation", event);
|
|
99
|
+
const apiTokenTbl = resolveTableName("api_token", event);
|
|
100
|
+
const ssoConnectionTbl = resolveTableName("sso_connection", event);
|
|
101
|
+
const auditLogTbl = resolveTableName("audit_log", event);
|
|
88
102
|
await d1.batch([
|
|
89
103
|
d1.prepare(`
|
|
90
|
-
CREATE TABLE IF NOT EXISTS
|
|
104
|
+
CREATE TABLE IF NOT EXISTS ${userTbl} (
|
|
91
105
|
id TEXT PRIMARY KEY,
|
|
92
106
|
name TEXT NOT NULL,
|
|
93
107
|
email TEXT NOT NULL UNIQUE,
|
|
@@ -99,11 +113,11 @@ export async function ensureAuthTables(d1) {
|
|
|
99
113
|
)
|
|
100
114
|
`),
|
|
101
115
|
d1.prepare(`
|
|
102
|
-
CREATE TABLE IF NOT EXISTS
|
|
116
|
+
CREATE TABLE IF NOT EXISTS ${accountTbl} (
|
|
103
117
|
id TEXT PRIMARY KEY,
|
|
104
118
|
account_id TEXT NOT NULL,
|
|
105
119
|
provider_id TEXT NOT NULL,
|
|
106
|
-
user_id TEXT NOT NULL REFERENCES
|
|
120
|
+
user_id TEXT NOT NULL REFERENCES ${userTbl}(id) ON DELETE CASCADE,
|
|
107
121
|
access_token TEXT,
|
|
108
122
|
refresh_token TEXT,
|
|
109
123
|
id_token TEXT,
|
|
@@ -116,7 +130,7 @@ export async function ensureAuthTables(d1) {
|
|
|
116
130
|
)
|
|
117
131
|
`),
|
|
118
132
|
d1.prepare(`
|
|
119
|
-
CREATE TABLE IF NOT EXISTS
|
|
133
|
+
CREATE TABLE IF NOT EXISTS ${sessionTbl} (
|
|
120
134
|
id TEXT PRIMARY KEY,
|
|
121
135
|
expires_at INTEGER NOT NULL,
|
|
122
136
|
token TEXT NOT NULL UNIQUE,
|
|
@@ -124,11 +138,11 @@ export async function ensureAuthTables(d1) {
|
|
|
124
138
|
updated_at INTEGER NOT NULL,
|
|
125
139
|
ip_address TEXT,
|
|
126
140
|
user_agent TEXT,
|
|
127
|
-
user_id TEXT NOT NULL REFERENCES
|
|
141
|
+
user_id TEXT NOT NULL REFERENCES ${userTbl}(id) ON DELETE CASCADE
|
|
128
142
|
)
|
|
129
143
|
`),
|
|
130
144
|
d1.prepare(`
|
|
131
|
-
CREATE TABLE IF NOT EXISTS
|
|
145
|
+
CREATE TABLE IF NOT EXISTS ${verificationTbl} (
|
|
132
146
|
id TEXT PRIMARY KEY,
|
|
133
147
|
identifier TEXT NOT NULL,
|
|
134
148
|
value TEXT NOT NULL,
|
|
@@ -138,9 +152,9 @@ export async function ensureAuthTables(d1) {
|
|
|
138
152
|
)
|
|
139
153
|
`),
|
|
140
154
|
d1.prepare(`
|
|
141
|
-
CREATE TABLE IF NOT EXISTS
|
|
155
|
+
CREATE TABLE IF NOT EXISTS ${twoFactorTbl} (
|
|
142
156
|
id TEXT PRIMARY KEY,
|
|
143
|
-
user_id TEXT NOT NULL UNIQUE REFERENCES
|
|
157
|
+
user_id TEXT NOT NULL UNIQUE REFERENCES ${userTbl}(id) ON DELETE CASCADE,
|
|
144
158
|
secret TEXT NOT NULL,
|
|
145
159
|
backup_codes TEXT NOT NULL,
|
|
146
160
|
enabled INTEGER DEFAULT 1,
|
|
@@ -148,11 +162,11 @@ export async function ensureAuthTables(d1) {
|
|
|
148
162
|
)
|
|
149
163
|
`),
|
|
150
164
|
d1.prepare(`
|
|
151
|
-
CREATE TABLE IF NOT EXISTS
|
|
165
|
+
CREATE TABLE IF NOT EXISTS ${passkeyTbl} (
|
|
152
166
|
id TEXT PRIMARY KEY,
|
|
153
167
|
name TEXT,
|
|
154
168
|
public_key BLOB NOT NULL,
|
|
155
|
-
user_id TEXT NOT NULL REFERENCES
|
|
169
|
+
user_id TEXT NOT NULL REFERENCES ${userTbl}(id) ON DELETE CASCADE,
|
|
156
170
|
credential_id TEXT NOT NULL UNIQUE,
|
|
157
171
|
counter INTEGER NOT NULL DEFAULT 0,
|
|
158
172
|
device_type TEXT,
|
|
@@ -162,7 +176,7 @@ export async function ensureAuthTables(d1) {
|
|
|
162
176
|
)
|
|
163
177
|
`),
|
|
164
178
|
d1.prepare(`
|
|
165
|
-
CREATE TABLE IF NOT EXISTS
|
|
179
|
+
CREATE TABLE IF NOT EXISTS ${organizationTbl} (
|
|
166
180
|
id TEXT PRIMARY KEY,
|
|
167
181
|
name TEXT NOT NULL,
|
|
168
182
|
slug TEXT NOT NULL UNIQUE,
|
|
@@ -173,19 +187,19 @@ export async function ensureAuthTables(d1) {
|
|
|
173
187
|
)
|
|
174
188
|
`),
|
|
175
189
|
d1.prepare(`
|
|
176
|
-
CREATE TABLE IF NOT EXISTS
|
|
190
|
+
CREATE TABLE IF NOT EXISTS ${memberTbl} (
|
|
177
191
|
id TEXT PRIMARY KEY,
|
|
178
|
-
organization_id TEXT NOT NULL REFERENCES
|
|
179
|
-
user_id TEXT NOT NULL REFERENCES
|
|
192
|
+
organization_id TEXT NOT NULL REFERENCES ${organizationTbl}(id) ON DELETE CASCADE,
|
|
193
|
+
user_id TEXT NOT NULL REFERENCES ${userTbl}(id) ON DELETE CASCADE,
|
|
180
194
|
role TEXT NOT NULL DEFAULT 'member',
|
|
181
195
|
created_at INTEGER NOT NULL,
|
|
182
196
|
UNIQUE(organization_id, user_id)
|
|
183
197
|
)
|
|
184
198
|
`),
|
|
185
199
|
d1.prepare(`
|
|
186
|
-
CREATE TABLE IF NOT EXISTS
|
|
200
|
+
CREATE TABLE IF NOT EXISTS ${invitationTbl} (
|
|
187
201
|
id TEXT PRIMARY KEY,
|
|
188
|
-
organization_id TEXT NOT NULL REFERENCES
|
|
202
|
+
organization_id TEXT NOT NULL REFERENCES ${organizationTbl}(id) ON DELETE CASCADE,
|
|
189
203
|
email TEXT NOT NULL,
|
|
190
204
|
role TEXT NOT NULL DEFAULT 'member',
|
|
191
205
|
token_hash TEXT,
|
|
@@ -195,9 +209,9 @@ export async function ensureAuthTables(d1) {
|
|
|
195
209
|
)
|
|
196
210
|
`),
|
|
197
211
|
d1.prepare(`
|
|
198
|
-
CREATE TABLE IF NOT EXISTS
|
|
212
|
+
CREATE TABLE IF NOT EXISTS ${apiTokenTbl} (
|
|
199
213
|
id TEXT PRIMARY KEY,
|
|
200
|
-
user_id TEXT NOT NULL REFERENCES
|
|
214
|
+
user_id TEXT NOT NULL REFERENCES ${userTbl}(id) ON DELETE CASCADE,
|
|
201
215
|
name TEXT NOT NULL,
|
|
202
216
|
token_hash TEXT NOT NULL,
|
|
203
217
|
scopes TEXT DEFAULT '["*"]',
|
|
@@ -207,9 +221,9 @@ export async function ensureAuthTables(d1) {
|
|
|
207
221
|
)
|
|
208
222
|
`),
|
|
209
223
|
d1.prepare(`
|
|
210
|
-
CREATE TABLE IF NOT EXISTS
|
|
224
|
+
CREATE TABLE IF NOT EXISTS ${ssoConnectionTbl} (
|
|
211
225
|
id TEXT PRIMARY KEY,
|
|
212
|
-
organization_id TEXT REFERENCES
|
|
226
|
+
organization_id TEXT REFERENCES ${organizationTbl}(id) ON DELETE CASCADE,
|
|
213
227
|
provider_type TEXT NOT NULL,
|
|
214
228
|
name TEXT NOT NULL,
|
|
215
229
|
domain TEXT,
|
|
@@ -226,7 +240,7 @@ export async function ensureAuthTables(d1) {
|
|
|
226
240
|
)
|
|
227
241
|
`),
|
|
228
242
|
d1.prepare(`
|
|
229
|
-
CREATE TABLE IF NOT EXISTS
|
|
243
|
+
CREATE TABLE IF NOT EXISTS ${auditLogTbl} (
|
|
230
244
|
id TEXT PRIMARY KEY,
|
|
231
245
|
user_id TEXT,
|
|
232
246
|
action TEXT NOT NULL,
|
|
@@ -240,40 +254,40 @@ export async function ensureAuthTables(d1) {
|
|
|
240
254
|
)
|
|
241
255
|
`),
|
|
242
256
|
// Secondary indexes for hot paths
|
|
243
|
-
d1.prepare(`CREATE INDEX IF NOT EXISTS
|
|
244
|
-
d1.prepare(`CREATE INDEX IF NOT EXISTS
|
|
245
|
-
d1.prepare(`CREATE INDEX IF NOT EXISTS
|
|
246
|
-
d1.prepare(`CREATE INDEX IF NOT EXISTS
|
|
247
|
-
d1.prepare(`CREATE INDEX IF NOT EXISTS
|
|
248
|
-
d1.prepare(`CREATE INDEX IF NOT EXISTS
|
|
257
|
+
d1.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(sessionTbl, "user_id")} ON ${sessionTbl}(user_id)`),
|
|
258
|
+
d1.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(sessionTbl, "token")} ON ${sessionTbl}(token)`),
|
|
259
|
+
d1.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(sessionTbl, "expires_at")} ON ${sessionTbl}(expires_at)`),
|
|
260
|
+
d1.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(accountTbl, "user_id")} ON ${accountTbl}(user_id)`),
|
|
261
|
+
d1.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(memberTbl, "user_id")} ON ${memberTbl}(user_id)`),
|
|
262
|
+
d1.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(memberTbl, "org_id")} ON ${memberTbl}(organization_id)`),
|
|
249
263
|
d1.prepare(
|
|
250
|
-
`CREATE INDEX IF NOT EXISTS
|
|
264
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(apiTokenTbl, "user_id")} ON ${apiTokenTbl}(user_id)`
|
|
251
265
|
),
|
|
252
266
|
d1.prepare(
|
|
253
|
-
`CREATE INDEX IF NOT EXISTS
|
|
267
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(auditLogTbl, "user_id")} ON ${auditLogTbl}(user_id)`
|
|
254
268
|
),
|
|
255
269
|
d1.prepare(
|
|
256
|
-
`CREATE INDEX IF NOT EXISTS
|
|
270
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(auditLogTbl, "action")} ON ${auditLogTbl}(action)`
|
|
257
271
|
),
|
|
258
272
|
d1.prepare(
|
|
259
|
-
`CREATE INDEX IF NOT EXISTS
|
|
273
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(auditLogTbl, "target")} ON ${auditLogTbl}(target_type, target_id)`
|
|
260
274
|
),
|
|
261
275
|
d1.prepare(
|
|
262
|
-
`CREATE INDEX IF NOT EXISTS
|
|
276
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(auditLogTbl, "created_at")} ON ${auditLogTbl}(created_at)`
|
|
263
277
|
)
|
|
264
278
|
]);
|
|
265
279
|
const userColumns = [
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
280
|
+
`ALTER TABLE ${userTbl} ADD COLUMN username TEXT`,
|
|
281
|
+
`ALTER TABLE ${userTbl} ADD COLUMN status TEXT DEFAULT 'active'`,
|
|
282
|
+
`ALTER TABLE ${userTbl} ADD COLUMN bio TEXT`,
|
|
283
|
+
`ALTER TABLE ${userTbl} ADD COLUMN website TEXT`,
|
|
284
|
+
`ALTER TABLE ${userTbl} ADD COLUMN location TEXT`,
|
|
285
|
+
`ALTER TABLE ${userTbl} ADD COLUMN social_links TEXT`,
|
|
286
|
+
`ALTER TABLE ${userTbl} ADD COLUMN public_email TEXT`,
|
|
287
|
+
`ALTER TABLE ${userTbl} ADD COLUMN avatar TEXT`,
|
|
288
|
+
`ALTER TABLE ${userTbl} ADD COLUMN google_id TEXT`,
|
|
289
|
+
`ALTER TABLE ${auditLogTbl} ADD COLUMN ip_address TEXT`,
|
|
290
|
+
`ALTER TABLE ${auditLogTbl} ADD COLUMN user_agent TEXT`
|
|
277
291
|
];
|
|
278
292
|
for (const alterSql of userColumns) {
|
|
279
293
|
try {
|
|
@@ -281,13 +295,6 @@ export async function ensureAuthTables(d1) {
|
|
|
281
295
|
} catch {
|
|
282
296
|
}
|
|
283
297
|
}
|
|
284
|
-
try {
|
|
285
|
-
await d1.prepare(`
|
|
286
|
-
INSERT OR IGNORE INTO user (id, name, email, email_verified, image, role, created_at, updated_at)
|
|
287
|
-
SELECT id, COALESCE(name, email), email, email_verified, avatar_url, role, created_at, updated_at FROM _qarpeo_users
|
|
288
|
-
`).run();
|
|
289
|
-
} catch {
|
|
290
|
-
}
|
|
291
298
|
})().catch((err) => {
|
|
292
299
|
ensureAuthTablesPromise = null;
|
|
293
300
|
throw err;
|
|
@@ -336,27 +343,29 @@ export async function handleOAuthSuccess({
|
|
|
336
343
|
let dbUser = null;
|
|
337
344
|
let isNew = false;
|
|
338
345
|
if (d1 && profile.providerAccountId) {
|
|
339
|
-
const
|
|
346
|
+
const userTbl = resolveTableName("user", event);
|
|
347
|
+
const accountTbl = resolveTableName("account", event);
|
|
348
|
+
const existingAccount = await d1.prepare(`SELECT * FROM ${accountTbl} WHERE provider_id = ? AND account_id = ? LIMIT 1`).bind(provider, profile.providerAccountId).first();
|
|
340
349
|
const encryptedAccessToken = tokens?.access_token ? await encryptToken(tokens.access_token, event) : null;
|
|
341
350
|
const encryptedRefreshToken = tokens?.refresh_token ? await encryptToken(tokens.refresh_token, event) : null;
|
|
342
351
|
if (existingAccount) {
|
|
343
|
-
dbUser = await d1.prepare(
|
|
352
|
+
dbUser = await d1.prepare(`SELECT * FROM ${userTbl} WHERE id = ? LIMIT 1`).bind(existingAccount.user_id).first();
|
|
344
353
|
if (dbUser) {
|
|
345
354
|
await d1.prepare(
|
|
346
|
-
|
|
355
|
+
`UPDATE ${accountTbl} SET access_token = ?, refresh_token = ?, updated_at = ? WHERE id = ?`
|
|
347
356
|
).bind(encryptedAccessToken, encryptedRefreshToken, now, existingAccount.id).run();
|
|
348
|
-
await d1.prepare(
|
|
357
|
+
await d1.prepare(`UPDATE ${userTbl} SET updated_at = ? WHERE id = ?`).bind(now, dbUser.id).run();
|
|
349
358
|
}
|
|
350
359
|
}
|
|
351
360
|
if (!dbUser && profile.email) {
|
|
352
|
-
const existingUser = await d1.prepare(
|
|
361
|
+
const existingUser = await d1.prepare(`SELECT * FROM ${userTbl} WHERE email = ? LIMIT 1`).bind(profile.email).first();
|
|
353
362
|
if (existingUser) {
|
|
354
363
|
const canLink = linkAccounts && Boolean(existingUser.email_verified) && Boolean(profile.emailVerified);
|
|
355
364
|
if (canLink || !linkAccounts) {
|
|
356
365
|
dbUser = existingUser;
|
|
357
366
|
const accountId = crypto.randomUUID();
|
|
358
367
|
await d1.prepare(`
|
|
359
|
-
INSERT INTO
|
|
368
|
+
INSERT INTO ${accountTbl} (id, user_id, provider_id, account_id, access_token, refresh_token, created_at, updated_at)
|
|
360
369
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
361
370
|
`).bind(
|
|
362
371
|
accountId,
|
|
@@ -376,7 +385,7 @@ export async function handleOAuthSuccess({
|
|
|
376
385
|
const userId = crypto.randomUUID();
|
|
377
386
|
const accountId = crypto.randomUUID();
|
|
378
387
|
const userStmt = d1.prepare(`
|
|
379
|
-
INSERT INTO
|
|
388
|
+
INSERT INTO ${userTbl} (id, email, email_verified, name, image, role, created_at, updated_at)
|
|
380
389
|
VALUES (?, ?, ?, ?, ?, 'user', ?, ?)
|
|
381
390
|
`).bind(
|
|
382
391
|
userId,
|
|
@@ -388,7 +397,7 @@ export async function handleOAuthSuccess({
|
|
|
388
397
|
now
|
|
389
398
|
);
|
|
390
399
|
const accountStmt = d1.prepare(`
|
|
391
|
-
INSERT INTO
|
|
400
|
+
INSERT INTO ${accountTbl} (id, user_id, provider_id, account_id, access_token, refresh_token, created_at, updated_at)
|
|
392
401
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
393
402
|
`).bind(
|
|
394
403
|
accountId,
|
|
@@ -474,18 +483,23 @@ export async function deleteUserAccount(event, userId, options = {}) {
|
|
|
474
483
|
d1 = null;
|
|
475
484
|
}
|
|
476
485
|
if (d1) {
|
|
486
|
+
const memberTbl = resolveTableName("member", event);
|
|
487
|
+
const organizationTbl = resolveTableName("organization", event);
|
|
488
|
+
const notificationTbl = resolveTableName("notification", event);
|
|
489
|
+
const pushSubscriptionTbl = resolveTableName("push_subscription", event);
|
|
490
|
+
const userTbl = resolveTableName("user", event);
|
|
477
491
|
const memberships = await d1.prepare(
|
|
478
|
-
|
|
492
|
+
`SELECT m.organization_id, m.role, o.name as org_name FROM ${memberTbl} m LEFT JOIN ${organizationTbl} o ON m.organization_id = o.id WHERE m.user_id = ? AND m.role = 'owner'`
|
|
479
493
|
).bind(userId).all();
|
|
480
494
|
const ownedOrgs = memberships.results || [];
|
|
481
495
|
for (const org of ownedOrgs) {
|
|
482
496
|
const otherOwners = await d1.prepare(
|
|
483
|
-
|
|
497
|
+
`SELECT COUNT(*) as count FROM ${memberTbl} WHERE organization_id = ? AND role = 'owner' AND user_id != ?`
|
|
484
498
|
).bind(org.organization_id, userId).first();
|
|
485
499
|
const otherOwnerCount = Number(otherOwners?.count || 0);
|
|
486
500
|
if (otherOwnerCount === 0) {
|
|
487
501
|
if (options.cascadeOrg) {
|
|
488
|
-
await d1.prepare(
|
|
502
|
+
await d1.prepare(`DELETE FROM ${organizationTbl} WHERE id = ?`).bind(org.organization_id).run();
|
|
489
503
|
} else {
|
|
490
504
|
throw new Error(
|
|
491
505
|
`Cannot delete account: You are the sole owner of organization "${org.org_name || org.organization_id}". Transfer ownership or delete the organization first, or pass cascadeOrg: true.`
|
|
@@ -494,11 +508,15 @@ export async function deleteUserAccount(event, userId, options = {}) {
|
|
|
494
508
|
}
|
|
495
509
|
}
|
|
496
510
|
try {
|
|
497
|
-
await
|
|
498
|
-
|
|
511
|
+
await revokeAllDeviceSessions(event, userId);
|
|
512
|
+
} catch {
|
|
513
|
+
}
|
|
514
|
+
try {
|
|
515
|
+
await d1.prepare(`DELETE FROM ${notificationTbl} WHERE user_id = ?`).bind(userId).run();
|
|
516
|
+
await d1.prepare(`DELETE FROM ${pushSubscriptionTbl} WHERE user_id = ?`).bind(userId).run();
|
|
499
517
|
} catch {
|
|
500
518
|
}
|
|
501
|
-
await d1.prepare(
|
|
519
|
+
await d1.prepare(`DELETE FROM ${userTbl} WHERE id = ?`).bind(userId).run();
|
|
502
520
|
}
|
|
503
521
|
try {
|
|
504
522
|
const nitroApp = globalThis.useNitroApp?.();
|
|
@@ -573,7 +591,7 @@ export async function resolveUserRole(arg1, arg2) {
|
|
|
573
591
|
email = typeof arg2 === "string" ? arg2 : "";
|
|
574
592
|
}
|
|
575
593
|
const normalizedEmail = (email || "").trim().toLowerCase();
|
|
576
|
-
const suggestedRole = getRoleFromEnv(
|
|
594
|
+
const suggestedRole = getRoleFromEnv(normalizedEmail, event);
|
|
577
595
|
if (!normalizedEmail) {
|
|
578
596
|
return {
|
|
579
597
|
exists: false,
|
|
@@ -589,7 +607,7 @@ export async function resolveUserRole(arg1, arg2) {
|
|
|
589
607
|
const bindingName = globalThis.process?.env?.QARPEO_DEFAULT_DB_BINDING || event?.context?.cloudflare?.env?.QARPEO_DEFAULT_DB_BINDING || "DB";
|
|
590
608
|
const d1 = getD1Binding(bindingName, event);
|
|
591
609
|
if (d1) {
|
|
592
|
-
const existingUser = await d1.prepare(
|
|
610
|
+
const existingUser = await d1.prepare(`SELECT * FROM ${resolveTableName("user", event)} WHERE LOWER(email) = LOWER(?) LIMIT 1`).bind(normalizedEmail).first();
|
|
593
611
|
if (existingUser) {
|
|
594
612
|
exists = true;
|
|
595
613
|
currentRole = existingUser.role ? String(existingUser.role) : "user";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type RequestEvent } from "nuxt/server";
|
|
1
|
+
import { type RequestEvent, type EventHandler } from "nuxt/server";
|
|
2
2
|
import type { BotProvider, BotHandlerConfig, BotReplyOptions } from "../../../types";
|
|
3
3
|
/** Verifies a Slack signature (v0=...) against the signing secret with timestamp replay protection. */
|
|
4
4
|
export declare function verifySlackSignature(signingSecret: string, timestamp: string | number, body: string, signature: string): Promise<boolean>;
|
|
5
|
-
/** Verifies a GitHub webhook signature (sha256=...). */
|
|
6
|
-
export declare function
|
|
5
|
+
/** Verifies a GitHub bot webhook signature (sha256=...). */
|
|
6
|
+
export declare function verifyGitHubWebhookSignature(secret: string, body: string, signatureHeader: string): Promise<boolean>;
|
|
7
7
|
/** Verifies a Discord Ed25519 signature using native Web Crypto. */
|
|
8
8
|
export declare function verifyDiscordSignature(publicKeyHex: string, timestamp: string, body: string, signatureHex: string): Promise<boolean>;
|
|
9
9
|
/** Verifies a Telegram secret token against the x-telegram-bot-api-secret-token header. */
|
|
@@ -19,4 +19,20 @@ export declare function sendSlackMessage(target: string, // botToken or response
|
|
|
19
19
|
channelOrPayload: string | Record<string, any>, text?: string, options?: BotReplyOptions): Promise<any>;
|
|
20
20
|
/** Dispatches a message to WhatsApp via Cloud API */
|
|
21
21
|
export declare function sendWhatsAppMessage(accessToken: string, phoneNumberId: string, to: string, text: string): Promise<any>;
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Define an edge bot and webhook handler for Telegram, Slack, Discord, WhatsApp, or GitHub.
|
|
24
|
+
*
|
|
25
|
+
* Automatically validates cryptographic signatures using native Web Crypto, solves platform
|
|
26
|
+
* verification challenges, normalizes inbound messages, and optionally auto-wires into Qarpeo
|
|
27
|
+
* Agents (`useAgent()`).
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // server/routes/bot/telegram.post.ts
|
|
32
|
+
* export default defineBotHandler({
|
|
33
|
+
* provider: "telegram",
|
|
34
|
+
* agent: "support", // Auto-pilot: forwarded to agent, reply sent to user
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function defineBotHandler<TPayload = any>(config: BotHandlerConfig<TPayload>): EventHandler;
|
|
@@ -37,7 +37,7 @@ export async function verifySlackSignature(signingSecret, timestamp, body, signa
|
|
|
37
37
|
const expected = `v0=${hash}`;
|
|
38
38
|
return timingSafeEqualString(signature, expected);
|
|
39
39
|
}
|
|
40
|
-
export async function
|
|
40
|
+
export async function verifyGitHubWebhookSignature(secret, body, signatureHeader) {
|
|
41
41
|
if (!secret || !signatureHeader) return false;
|
|
42
42
|
const hash = await computeHmacSha256Hex(secret, body);
|
|
43
43
|
const expected = `sha256=${hash}`;
|
|
@@ -110,7 +110,7 @@ export async function verifyWebhookSignature(provider, event, rawBody, secret) {
|
|
|
110
110
|
const sec = secret || env.GITHUB_WEBHOOK_SECRET || globalThis.process?.env?.GITHUB_WEBHOOK_SECRET;
|
|
111
111
|
if (!sec) return true;
|
|
112
112
|
const sig = getRequestHeader(event, "x-hub-signature-256") || "";
|
|
113
|
-
return await
|
|
113
|
+
return await verifyGitHubWebhookSignature(sec, rawBody, sig);
|
|
114
114
|
}
|
|
115
115
|
case "whatsapp": {
|
|
116
116
|
const sec = secret || env.WHATSAPP_APP_SECRET || globalThis.process?.env?.WHATSAPP_APP_SECRET;
|
|
@@ -124,7 +124,7 @@ export async function verifyWebhookSignature(provider, event, rawBody, secret) {
|
|
|
124
124
|
if (!sec) return true;
|
|
125
125
|
const sig = getRequestHeader(event, "x-webhook-signature") || getRequestHeader(event, "x-hub-signature-256") || getRequestHeader(event, "authorization")?.replace(/^Bearer\s+/i, "") || "";
|
|
126
126
|
if (sig.startsWith("sha256=")) {
|
|
127
|
-
return await
|
|
127
|
+
return await verifyGitHubWebhookSignature(sec, rawBody, sig);
|
|
128
128
|
}
|
|
129
129
|
return timingSafeEqualString(sec, sig);
|
|
130
130
|
}
|
|
@@ -400,6 +400,10 @@ export function defineBotHandler(config) {
|
|
|
400
400
|
for (const [k, v] of Object.entries(ev.node.req.headers)) {
|
|
401
401
|
headers[k.toLowerCase()] = Array.isArray(v) ? v[0] : v;
|
|
402
402
|
}
|
|
403
|
+
} else if (ev.request?.headers) {
|
|
404
|
+
ev.request.headers.forEach((v, k) => {
|
|
405
|
+
headers[k.toLowerCase()] = v;
|
|
406
|
+
});
|
|
403
407
|
}
|
|
404
408
|
const reply = async (textOrOptions) => {
|
|
405
409
|
const opts = typeof textOrOptions === "string" ? { text: textOrOptions } : textOrOptions;
|
|
@@ -197,15 +197,15 @@ export declare function crawlPage(startUrl: string, options?: CrawlOptions): Pro
|
|
|
197
197
|
* using headless browser rendering.
|
|
198
198
|
*
|
|
199
199
|
* @example
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
200
|
+
* ```ts
|
|
201
|
+
* const { data, contentType } = await renderOgSocialCard({
|
|
202
|
+
* title: "Building Microservices on Cloudflare",
|
|
203
|
+
* description: "Fast RPC, Durable Objects, and Vectorize on the Edge",
|
|
204
|
+
* siteName: "Qarpeo",
|
|
205
|
+
* theme: "dark",
|
|
206
|
+
* })
|
|
207
|
+
* return new Response(data, { headers: { "Content-Type": contentType } })
|
|
208
|
+
* ```
|
|
209
209
|
*/
|
|
210
210
|
export declare function renderOgSocialCard(options: OgSocialCardOptions): Promise<ScreenshotResult>;
|
|
211
211
|
/**
|
|
@@ -213,19 +213,19 @@ export declare function renderOgSocialCard(options: OgSocialCardOptions): Promis
|
|
|
213
213
|
* Rendering.
|
|
214
214
|
*
|
|
215
215
|
* @example
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
216
|
+
* ```ts
|
|
217
|
+
* const { data } = await generateInvoicePdf({
|
|
218
|
+
* invoiceNumber: "INV-2026-0042",
|
|
219
|
+
* issueDate: "2026-11-11",
|
|
220
|
+
* seller: { name: "Acme Cloud Corp", email: "billing@acme.com" },
|
|
221
|
+
* customer: { name: "Client Studios", email: "finance@client.com" },
|
|
222
|
+
* items: [
|
|
223
|
+
* { description: "Edge Compute (Million Requests)", quantity: 50, unitPrice: 0.5 },
|
|
224
|
+
* { description: "Vectorize Storage (GB/mo)", quantity: 10, unitPrice: 5 },
|
|
225
|
+
* ],
|
|
226
|
+
* currency: "$",
|
|
227
|
+
* taxPercent: 10,
|
|
228
|
+
* })
|
|
229
|
+
* ```
|
|
230
230
|
*/
|
|
231
231
|
export declare function generateInvoicePdf(options: GenerateInvoiceOptions): Promise<PdfResult>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { RememberCacheOptions } from "../../../types";
|
|
1
|
+
import type { CachedFunctionOptions, RememberCacheOptions } from "../../../types";
|
|
2
|
+
export type { CachedFunctionOptions, RememberCacheOptions };
|
|
2
3
|
/**
|
|
3
4
|
* Access Nitro's persistent Edge Cache storage. Connected to Cloudflare KV in production and local
|
|
4
5
|
* filesystem (.data/cache) in dev.
|
|
@@ -24,20 +25,40 @@ export declare function purgeCache(pattern?: string): Promise<string[]>;
|
|
|
24
25
|
* Purge all cache items associated with one or more semantic cache tags.
|
|
25
26
|
*
|
|
26
27
|
* @example
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* await purgeCacheTag("posts", "author:123")
|
|
30
|
+
* ```
|
|
30
31
|
*/
|
|
31
32
|
export declare function purgeCacheTag(...tags: string[]): Promise<string[]>;
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
34
|
+
* Factory pattern: define a reusable cached function backed by Cloudflare KV / edge cache.
|
|
35
|
+
* Matches Nitro's `defineCachedFunction` convention with enhanced support for human duration
|
|
36
|
+
* strings ('5m', '1h', '7d'), SWR windows, and semantic tags.
|
|
35
37
|
*
|
|
36
|
-
* @
|
|
37
|
-
*
|
|
38
|
-
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* export const getStats = defineCachedFunction(fetchStats, {
|
|
41
|
+
* key: 'dashboard:stats',
|
|
42
|
+
* maxAge: 60 * 5,
|
|
43
|
+
* })
|
|
44
|
+
* const stats = await getStats()
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function defineCachedFunction<T, Args extends any[] = any[]>(fn: (...args: Args) => Promise<T> | T, options?: CachedFunctionOptions<Args>): (...args: Args) => Promise<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Inline execution: fetch and cache data immediately, or retrieve fresh from cache.
|
|
50
|
+
* Supports inline key/options/fetcher calls or fetcher-first options.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* // Direct inline execution:
|
|
55
|
+
* const stats = await rememberCache('stats', { maxAge: '5m' }, fetchStats)
|
|
56
|
+
* const user = await rememberCache('user:123', '1h', () => fetchUser(123))
|
|
57
|
+
* ```
|
|
39
58
|
*/
|
|
40
|
-
export declare function rememberCache<T>(key: string, ttlOrOptions: number | string | RememberCacheOptions, fetcher: () => Promise<T>): Promise<T>;
|
|
59
|
+
export declare function rememberCache<T>(key: string, ttlOrOptions: number | string | RememberCacheOptions, fetcher: () => Promise<T> | T): Promise<T>;
|
|
60
|
+
export declare function rememberCache<T>(key: string, fetcher: () => Promise<T> | T, ttlOrOptions?: number | string | RememberCacheOptions): Promise<T>;
|
|
61
|
+
export declare function rememberCache<T, Args extends any[] = any[]>(fn: (...args: Args) => Promise<T> | T, options?: RememberCacheOptions<Args>): ((...args: Args) => Promise<T>) & Promise<T>;
|
|
41
62
|
/** Retrieves a typed value from the edge cache if not expired. */
|
|
42
63
|
export declare function getCacheItem<T = unknown>(key: string): Promise<T | null>;
|
|
43
64
|
/** Stores a typed value in the edge cache with an expiration TTL, optional SWR window, and tags. */
|