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
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import type { QueueMessage, QueueMessageBatch } from "../../types/queue";
|
|
2
|
-
export type { QueueMessage, QueueMessageBatch } from "../../types/queue";
|
|
1
|
+
import type { QueueMessage, QueueMessageBatch, DeadLetterPayload, QueueRetryBackoffStrategy, QueueRetryBackoffConfig, QueueRouterOptions } from "../../types/queue";
|
|
2
|
+
export type { QueueMessage, QueueMessageBatch, DeadLetterPayload, QueueRetryBackoffStrategy, QueueRetryBackoffConfig, QueueRoutingRule, QueueRouterOptions, } from "../../types/queue";
|
|
3
|
+
/**
|
|
4
|
+
* Thrown inside a queue handler to indicate a fatal, non-retryable error
|
|
5
|
+
* (e.g. malformed JSON, unrecoverable data corruption).
|
|
6
|
+
* Bypasses remaining retry attempts and routes immediately to the Dead Letter Queue.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FatalQueueError extends Error {
|
|
9
|
+
readonly details?: any | undefined;
|
|
10
|
+
readonly isFatal = true;
|
|
11
|
+
constructor(message: string, details?: any | undefined);
|
|
12
|
+
}
|
|
13
|
+
/** Alias for FatalQueueError */
|
|
14
|
+
export declare const NonRetryableError: typeof FatalQueueError;
|
|
3
15
|
export interface QueueConsumerContext {
|
|
4
16
|
/** Name of the queue that received this message or batch */
|
|
5
17
|
queue: string;
|
|
@@ -15,8 +27,13 @@ export interface QueueConsumerContext {
|
|
|
15
27
|
retry: (options?: {
|
|
16
28
|
delaySeconds?: number;
|
|
17
29
|
}) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Reject the message immediately as a non-retryable fatal error, routing it directly
|
|
32
|
+
* to the Dead Letter Queue without consuming remaining attempts.
|
|
33
|
+
*/
|
|
34
|
+
reject: (reason?: string) => Promise<void>;
|
|
18
35
|
/** Forward this message payload directly to a Dead Letter Queue */
|
|
19
|
-
sendToDeadLetter: (dlqBindingOrName?: string, reason?: string) => Promise<void>;
|
|
36
|
+
sendToDeadLetter: (dlqBindingOrName?: string, reason?: string, error?: Error) => Promise<void>;
|
|
20
37
|
}
|
|
21
38
|
export type QueueMessageHandler<T = any> = (message: QueueMessage<T>, context: QueueConsumerContext) => Promise<void> | void;
|
|
22
39
|
export type QueueBatchHandler<T = any> = (batch: QueueMessageBatch<T>, context: QueueConsumerContext) => Promise<void> | void;
|
|
@@ -43,8 +60,17 @@ export interface QueueConsumerOptions<T = any> {
|
|
|
43
60
|
* ;(attempt) => Math.min(3600, Math.pow(2, attempt) * 5)
|
|
44
61
|
*/
|
|
45
62
|
retryDelaySeconds?: number | ((attempt: number) => number);
|
|
63
|
+
/**
|
|
64
|
+
* Backoff retry configuration (exponential, linear, or custom with jitter).
|
|
65
|
+
*/
|
|
66
|
+
retryBackoff?: QueueRetryBackoffStrategy | QueueRetryBackoffConfig;
|
|
46
67
|
/** Cloudflare Queue binding or queue name to route permanently failed messages to. */
|
|
47
68
|
deadLetterQueue?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Optional secondary fallback hook called if delivery to `deadLetterQueue` fails
|
|
71
|
+
* or if custom persistence is needed.
|
|
72
|
+
*/
|
|
73
|
+
dlqFallback?: (payload: DeadLetterPayload<T>) => Promise<void> | void;
|
|
48
74
|
/** Callback hook executed when a message exceeds maxRetries and is about to be dead-lettered. */
|
|
49
75
|
onDeadLetter?: (message: QueueMessage<T>, error: Error, context: QueueConsumerContext) => Promise<void> | void;
|
|
50
76
|
/**
|
|
@@ -60,27 +86,94 @@ export interface QueueConsumer<T = any> {
|
|
|
60
86
|
options: QueueConsumerOptions<T>;
|
|
61
87
|
(batch: QueueMessageBatch<T>, env?: any, ctx?: any): Promise<void>;
|
|
62
88
|
}
|
|
89
|
+
/** Calculates backoff retry delay taking into account strategy, factor, and jitter. */
|
|
90
|
+
export declare function calculateRetryDelay(attempt: number, config?: number | QueueRetryBackoffStrategy | QueueRetryBackoffConfig, error?: Error): number | undefined;
|
|
63
91
|
/**
|
|
64
|
-
* Define a typed Cloudflare Queue consumer with automatic batch chunking, retry tracking,
|
|
65
|
-
* Letter Queue (DLQ) routing.
|
|
92
|
+
* Define a typed Cloudflare Queue consumer with automatic batch chunking, retry tracking,
|
|
93
|
+
* and Dead Letter Queue (DLQ) routing.
|
|
66
94
|
*
|
|
67
95
|
* @example
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* // server/queues/orders.ts
|
|
98
|
+
* export default defineQueueConsumer({
|
|
71
99
|
* batchSize: 5,
|
|
72
100
|
* maxRetries: 3,
|
|
101
|
+
* retryBackoff: { strategy: "exponential", initialDelay: 5 },
|
|
73
102
|
* deadLetterQueue: "ORDERS_DLQ",
|
|
74
103
|
* async handler(message, ctx) {
|
|
75
|
-
*
|
|
76
|
-
*
|
|
104
|
+
* if (!message.body.id) {
|
|
105
|
+
* throw new FatalQueueError("Missing order ID")
|
|
106
|
+
* }
|
|
107
|
+
* await processOrder(message.body)
|
|
77
108
|
* },
|
|
78
109
|
* async onDeadLetter(message, err) {
|
|
79
|
-
*
|
|
110
|
+
* console.error(`Order ${message.id} sent to DLQ:`, err.message)
|
|
80
111
|
* },
|
|
81
|
-
*
|
|
82
|
-
*
|
|
112
|
+
* })
|
|
113
|
+
* ```
|
|
83
114
|
*/
|
|
84
115
|
export declare function defineQueueConsumer<T = any>(optionsOrHandler: QueueConsumerOptions<T> | QueueMessageHandler<T> | QueueBatchHandler<T>, maybeOptions?: Omit<QueueConsumerOptions<T>, "handler">): QueueConsumer<T>;
|
|
85
116
|
/** Backward-compatible alias for defineQueueConsumer. */
|
|
86
117
|
export declare const defineQueueHandler: typeof defineQueueConsumer;
|
|
118
|
+
/**
|
|
119
|
+
* Define a typed Cloudflare Queue consumer matching Void Cloud (`void/queues`) syntax.
|
|
120
|
+
*/
|
|
121
|
+
export declare function defineQueue<T = any>(handlerOrOptions: QueueConsumerOptions<T> | ((batch: QueueMessageBatch<T>, env?: any, ctx?: any) => Promise<void> | void), maybeOptions?: Omit<QueueConsumerOptions<T>, "batchHandler">): QueueConsumer<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Defines an advanced multi-queue and content-based queue router.
|
|
124
|
+
*
|
|
125
|
+
* Routes incoming batches/messages by queue name patterns or message body predicates,
|
|
126
|
+
* with automated Dead Letter Queue fallbacks.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* export default defineQueueRouter({
|
|
131
|
+
* // 1. By exact queue name or wildcard pattern
|
|
132
|
+
* "orders": ordersConsumer,
|
|
133
|
+
* "emails-*": emailsConsumer,
|
|
134
|
+
*
|
|
135
|
+
* // 2. Content-based rules
|
|
136
|
+
* routes: [
|
|
137
|
+
* { match: (msg) => msg.body?.event === "checkout.completed", handler: checkoutHandler },
|
|
138
|
+
* { match: { type: "payment" }, handler: paymentHandler },
|
|
139
|
+
* ],
|
|
140
|
+
*
|
|
141
|
+
* // 3. Catch-all fallback
|
|
142
|
+
* default: defaultHandler,
|
|
143
|
+
* deadLetterQueue: "UNROUTED_DLQ",
|
|
144
|
+
* })
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare function defineQueueRouter<T = any>(routerOptions: QueueRouterOptions<T>): QueueConsumer<T>;
|
|
148
|
+
export interface ReplayDeadLetterOptions<T = any> {
|
|
149
|
+
/** The source DLQ queue binding or name */
|
|
150
|
+
dlq: string;
|
|
151
|
+
/** The target queue binding or name to replay messages to */
|
|
152
|
+
target: string;
|
|
153
|
+
/** If invoked inside a DLQ queue handler, the batch messages to redeliver */
|
|
154
|
+
messages?: readonly QueueMessage<T>[] | QueueMessage<T>[];
|
|
155
|
+
/** Optional filter predicate */
|
|
156
|
+
filter?: (payload: DeadLetterPayload<T> | T) => boolean;
|
|
157
|
+
/** Optional transformation on the body before redelivery */
|
|
158
|
+
transform?: (payload: DeadLetterPayload<T> | T) => any;
|
|
159
|
+
/** Delay in seconds for redelivery */
|
|
160
|
+
delaySeconds?: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Replays dead-letter messages back to the primary or target queue.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* const result = await replayDeadLetterQueue({
|
|
168
|
+
* dlq: "ORDERS_DLQ",
|
|
169
|
+
* target: "ORDERS",
|
|
170
|
+
* messages: dlqBatch.messages,
|
|
171
|
+
* filter: (msg) => msg.attempts < 5,
|
|
172
|
+
* })
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare function replayDeadLetterQueue<T = any>(options: ReplayDeadLetterOptions<T>): Promise<{
|
|
176
|
+
replayed: number;
|
|
177
|
+
skipped: number;
|
|
178
|
+
failed: number;
|
|
179
|
+
}>;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { setCloudflareEnv } from "../../bindings.mjs";
|
|
2
2
|
import { useQueue } from "../../queue.mjs";
|
|
3
|
+
export class FatalQueueError extends Error {
|
|
4
|
+
constructor(message, details) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.details = details;
|
|
7
|
+
this.name = "FatalQueueError";
|
|
8
|
+
}
|
|
9
|
+
isFatal = true;
|
|
10
|
+
}
|
|
11
|
+
export const NonRetryableError = FatalQueueError;
|
|
3
12
|
function chunkArray(items, size) {
|
|
4
13
|
const chunks = [];
|
|
5
14
|
const safeSize = Math.max(1, size);
|
|
@@ -8,6 +17,29 @@ function chunkArray(items, size) {
|
|
|
8
17
|
}
|
|
9
18
|
return chunks;
|
|
10
19
|
}
|
|
20
|
+
export function calculateRetryDelay(attempt, config, error) {
|
|
21
|
+
if (config === void 0) return void 0;
|
|
22
|
+
if (typeof config === "number") return config;
|
|
23
|
+
if (typeof config === "function") return config(attempt, error);
|
|
24
|
+
const cfg = typeof config === "object" ? config : { strategy: config };
|
|
25
|
+
const strategy = cfg.strategy || "exponential";
|
|
26
|
+
const initial = cfg.initialDelay ?? 5;
|
|
27
|
+
const max = cfg.maxDelay ?? 3600;
|
|
28
|
+
const factor = cfg.factor ?? 2;
|
|
29
|
+
let delay = initial;
|
|
30
|
+
if (strategy === "linear") {
|
|
31
|
+
delay = initial * attempt;
|
|
32
|
+
} else if (strategy === "exponential") {
|
|
33
|
+
delay = initial * Math.pow(factor, Math.max(0, attempt - 1));
|
|
34
|
+
} else if (strategy === "fixed") {
|
|
35
|
+
delay = initial;
|
|
36
|
+
}
|
|
37
|
+
if (cfg.jitter !== false) {
|
|
38
|
+
const jitterAmount = delay * 0.25 * Math.random();
|
|
39
|
+
delay += jitterAmount;
|
|
40
|
+
}
|
|
41
|
+
return Math.min(max, Math.round(delay));
|
|
42
|
+
}
|
|
11
43
|
export function defineQueueConsumer(optionsOrHandler, maybeOptions) {
|
|
12
44
|
const options = typeof optionsOrHandler === "function" ? {
|
|
13
45
|
handler: optionsOrHandler,
|
|
@@ -36,21 +68,42 @@ export function defineQueueConsumer(optionsOrHandler, maybeOptions) {
|
|
|
36
68
|
waitUntil,
|
|
37
69
|
ack: () => batch.ackAll(),
|
|
38
70
|
retry: (opts) => batch.retryAll(opts),
|
|
39
|
-
|
|
71
|
+
reject: async (reason) => {
|
|
72
|
+
await batchContext.sendToDeadLetter(void 0, reason);
|
|
73
|
+
batch.ackAll();
|
|
74
|
+
},
|
|
75
|
+
sendToDeadLetter: async (dlqBindingOrName, reason, error) => {
|
|
40
76
|
const targetDlq = dlqBindingOrName || options.deadLetterQueue;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const requests = batch.messages.map((m) => ({
|
|
44
|
-
body: {
|
|
77
|
+
const requests = batch.messages.map((m) => {
|
|
78
|
+
const payload = {
|
|
45
79
|
originalId: m.id,
|
|
46
80
|
queue: batch.queue,
|
|
47
81
|
body: m.body,
|
|
48
82
|
attempts: m.attempts,
|
|
49
83
|
reason: reason || "Manual batch dead-letter routing",
|
|
84
|
+
errorName: error?.name,
|
|
85
|
+
stack: error?.stack,
|
|
50
86
|
failedAt: Date.now()
|
|
87
|
+
};
|
|
88
|
+
return { body: payload };
|
|
89
|
+
});
|
|
90
|
+
if (targetDlq) {
|
|
91
|
+
try {
|
|
92
|
+
const dlq = useQueue(targetDlq);
|
|
93
|
+
await dlq.sendBatch(requests);
|
|
94
|
+
return;
|
|
95
|
+
} catch (dlqErr) {
|
|
96
|
+
console.error(`[qarpeo:queue] Failed batch routing to DLQ "${targetDlq}":`, dlqErr);
|
|
51
97
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
98
|
+
}
|
|
99
|
+
if (options.dlqFallback) {
|
|
100
|
+
for (const req of requests) {
|
|
101
|
+
try {
|
|
102
|
+
await options.dlqFallback(req.body);
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
54
107
|
}
|
|
55
108
|
};
|
|
56
109
|
await options.batchHandler(batch, batchContext);
|
|
@@ -67,21 +120,45 @@ export function defineQueueConsumer(optionsOrHandler, maybeOptions) {
|
|
|
67
120
|
const attempts = message.attempts || 1;
|
|
68
121
|
let acknowledged = false;
|
|
69
122
|
let retried = false;
|
|
70
|
-
|
|
123
|
+
let rejected = false;
|
|
124
|
+
const sendToDeadLetter = async (dlqBindingOrName, reason, error) => {
|
|
71
125
|
const targetDlq = dlqBindingOrName || options.deadLetterQueue;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
126
|
+
const payload = {
|
|
127
|
+
originalId: message.id,
|
|
128
|
+
queue: batch.queue,
|
|
129
|
+
body: message.body,
|
|
130
|
+
attempts,
|
|
131
|
+
reason: reason || "Dead letter routing",
|
|
132
|
+
errorName: error?.name,
|
|
133
|
+
stack: error?.stack,
|
|
134
|
+
failedAt: Date.now()
|
|
135
|
+
};
|
|
136
|
+
if (targetDlq) {
|
|
137
|
+
try {
|
|
138
|
+
const dlq = useQueue(targetDlq);
|
|
139
|
+
await dlq.send(payload);
|
|
140
|
+
return;
|
|
141
|
+
} catch (dlqErr) {
|
|
142
|
+
console.error(
|
|
143
|
+
`[qarpeo:queue] Failed routing message ${message.id} to DLQ "${targetDlq}":`,
|
|
144
|
+
dlqErr
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (options.dlqFallback) {
|
|
149
|
+
try {
|
|
150
|
+
await options.dlqFallback(payload);
|
|
151
|
+
} catch (fallbackErr) {
|
|
152
|
+
console.error(
|
|
153
|
+
`[qarpeo:queue] DLQ fallback hook failed for message ${message.id}:`,
|
|
154
|
+
fallbackErr
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
console.warn(
|
|
159
|
+
`[qarpeo:queue:dlq-unhandled] Dead-letter message without DLQ target:`,
|
|
160
|
+
JSON.stringify(payload)
|
|
161
|
+
);
|
|
85
162
|
}
|
|
86
163
|
};
|
|
87
164
|
const messageContext = {
|
|
@@ -97,19 +174,35 @@ export function defineQueueConsumer(optionsOrHandler, maybeOptions) {
|
|
|
97
174
|
retried = true;
|
|
98
175
|
message.retry(opts);
|
|
99
176
|
},
|
|
177
|
+
reject: async (reason) => {
|
|
178
|
+
rejected = true;
|
|
179
|
+
acknowledged = true;
|
|
180
|
+
await sendToDeadLetter(options.deadLetterQueue, reason);
|
|
181
|
+
if (typeof options.onDeadLetter === "function") {
|
|
182
|
+
await options.onDeadLetter(
|
|
183
|
+
message,
|
|
184
|
+
new FatalQueueError(reason || "Explicit message rejection"),
|
|
185
|
+
messageContext
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
message.ack();
|
|
189
|
+
},
|
|
100
190
|
sendToDeadLetter
|
|
101
191
|
};
|
|
102
192
|
try {
|
|
103
193
|
await handler(message, messageContext);
|
|
104
|
-
if (!acknowledged && !retried) {
|
|
194
|
+
if (!acknowledged && !retried && !rejected) {
|
|
105
195
|
message.ack();
|
|
106
196
|
acknowledged = true;
|
|
107
197
|
}
|
|
108
198
|
} catch (err) {
|
|
109
|
-
if (acknowledged || retried) return;
|
|
110
|
-
|
|
199
|
+
if (acknowledged || retried || rejected) return;
|
|
200
|
+
const isFatal = err instanceof FatalQueueError || err?.isFatal === true || err?.name === "FatalQueueError";
|
|
201
|
+
if (!isFatal && attempts < maxRetries) {
|
|
111
202
|
let delaySeconds;
|
|
112
|
-
if (
|
|
203
|
+
if (options.retryBackoff !== void 0) {
|
|
204
|
+
delaySeconds = calculateRetryDelay(attempts, options.retryBackoff, err);
|
|
205
|
+
} else if (typeof options.retryDelaySeconds === "function") {
|
|
113
206
|
delaySeconds = options.retryDelaySeconds(attempts);
|
|
114
207
|
} else if (typeof options.retryDelaySeconds === "number") {
|
|
115
208
|
delaySeconds = options.retryDelaySeconds;
|
|
@@ -117,9 +210,11 @@ export function defineQueueConsumer(optionsOrHandler, maybeOptions) {
|
|
|
117
210
|
retried = true;
|
|
118
211
|
message.retry(delaySeconds !== void 0 ? { delaySeconds } : void 0);
|
|
119
212
|
} else {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
213
|
+
await sendToDeadLetter(
|
|
214
|
+
options.deadLetterQueue,
|
|
215
|
+
err?.message || String(err),
|
|
216
|
+
err
|
|
217
|
+
);
|
|
123
218
|
if (typeof options.onDeadLetter === "function") {
|
|
124
219
|
try {
|
|
125
220
|
await options.onDeadLetter(message, err, messageContext);
|
|
@@ -140,3 +235,193 @@ export function defineQueueConsumer(optionsOrHandler, maybeOptions) {
|
|
|
140
235
|
return consumerFn;
|
|
141
236
|
}
|
|
142
237
|
export const defineQueueHandler = defineQueueConsumer;
|
|
238
|
+
export function defineQueue(handlerOrOptions, maybeOptions) {
|
|
239
|
+
if (typeof handlerOrOptions === "function") {
|
|
240
|
+
return defineQueueConsumer({
|
|
241
|
+
batchHandler: handlerOrOptions,
|
|
242
|
+
...maybeOptions
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return defineQueueConsumer(handlerOrOptions, maybeOptions);
|
|
246
|
+
}
|
|
247
|
+
function matchesPattern(str, pattern) {
|
|
248
|
+
if (pattern === "*" || pattern === str) return true;
|
|
249
|
+
if (pattern.includes("*")) {
|
|
250
|
+
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
251
|
+
return new RegExp(`^${escaped}$`, "i").test(str);
|
|
252
|
+
}
|
|
253
|
+
return str.toLowerCase() === pattern.toLowerCase();
|
|
254
|
+
}
|
|
255
|
+
function matchesPredicate(body, match) {
|
|
256
|
+
if (!body || typeof body !== "object") return false;
|
|
257
|
+
for (const [k, v] of Object.entries(match)) {
|
|
258
|
+
if (body[k] !== v) return false;
|
|
259
|
+
}
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
export function defineQueueRouter(routerOptions) {
|
|
263
|
+
const routerFn = async function(batch, env, ctx) {
|
|
264
|
+
if (!batch || !Array.isArray(batch.messages)) return;
|
|
265
|
+
if (env) {
|
|
266
|
+
setCloudflareEnv(env);
|
|
267
|
+
}
|
|
268
|
+
const queueName = batch.queue || "";
|
|
269
|
+
for (const [key, handler] of Object.entries(routerOptions)) {
|
|
270
|
+
if (key === "routes" || key === "default" || key === "deadLetterQueue") continue;
|
|
271
|
+
if (typeof handler === "function" && matchesPattern(queueName, key)) {
|
|
272
|
+
await handler(batch, env, ctx);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const routes = routerOptions.routes || [];
|
|
277
|
+
if (routes.length > 0) {
|
|
278
|
+
const unhandled = [];
|
|
279
|
+
for (const msg of batch.messages) {
|
|
280
|
+
let matched = false;
|
|
281
|
+
for (const rule of routes) {
|
|
282
|
+
const isMatch = typeof rule.match === "function" ? rule.match(msg) : matchesPredicate(msg.body, rule.match);
|
|
283
|
+
if (isMatch) {
|
|
284
|
+
matched = true;
|
|
285
|
+
const fakeBatch = {
|
|
286
|
+
queue: batch.queue,
|
|
287
|
+
messages: [msg],
|
|
288
|
+
ackAll: () => msg.ack(),
|
|
289
|
+
retryAll: (opts) => msg.retry(opts)
|
|
290
|
+
};
|
|
291
|
+
if (typeof rule.handler.__isQueueConsumer === "boolean") {
|
|
292
|
+
await rule.handler(fakeBatch, env, ctx);
|
|
293
|
+
} else {
|
|
294
|
+
const fakeContext = {
|
|
295
|
+
queue: batch.queue,
|
|
296
|
+
env,
|
|
297
|
+
executionContext: ctx,
|
|
298
|
+
waitUntil: (p) => ctx?.waitUntil?.(p),
|
|
299
|
+
ack: () => msg.ack(),
|
|
300
|
+
retry: (opts) => msg.retry(opts),
|
|
301
|
+
reject: async (r) => {
|
|
302
|
+
if (routerOptions.deadLetterQueue) {
|
|
303
|
+
const dlq = useQueue(routerOptions.deadLetterQueue);
|
|
304
|
+
await dlq.send({
|
|
305
|
+
originalId: msg.id,
|
|
306
|
+
queue: batch.queue,
|
|
307
|
+
body: msg.body,
|
|
308
|
+
attempts: msg.attempts,
|
|
309
|
+
reason: r || "Content-route rejection",
|
|
310
|
+
failedAt: Date.now()
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
msg.ack();
|
|
314
|
+
},
|
|
315
|
+
sendToDeadLetter: async (target, r) => {
|
|
316
|
+
const targetDlq = target || routerOptions.deadLetterQueue;
|
|
317
|
+
if (targetDlq) {
|
|
318
|
+
const dlq = useQueue(targetDlq);
|
|
319
|
+
await dlq.send({
|
|
320
|
+
originalId: msg.id,
|
|
321
|
+
queue: batch.queue,
|
|
322
|
+
body: msg.body,
|
|
323
|
+
attempts: msg.attempts,
|
|
324
|
+
reason: r || "DLQ routing",
|
|
325
|
+
failedAt: Date.now()
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
await rule.handler(msg, fakeContext);
|
|
331
|
+
msg.ack();
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (!matched) {
|
|
337
|
+
unhandled.push(msg);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (unhandled.length === 0) return;
|
|
341
|
+
if (typeof routerOptions.default === "function") {
|
|
342
|
+
const unhandledBatch = {
|
|
343
|
+
queue: batch.queue,
|
|
344
|
+
messages: unhandled,
|
|
345
|
+
ackAll: () => unhandled.forEach((m) => m.ack()),
|
|
346
|
+
retryAll: (opts) => unhandled.forEach((m) => m.retry(opts))
|
|
347
|
+
};
|
|
348
|
+
await routerOptions.default(unhandledBatch, env, ctx);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (routerOptions.deadLetterQueue) {
|
|
352
|
+
const dlq = useQueue(routerOptions.deadLetterQueue);
|
|
353
|
+
await dlq.sendBatch(
|
|
354
|
+
unhandled.map((m) => ({
|
|
355
|
+
body: {
|
|
356
|
+
originalId: m.id,
|
|
357
|
+
queue: batch.queue,
|
|
358
|
+
body: m.body,
|
|
359
|
+
attempts: m.attempts,
|
|
360
|
+
reason: "No matching route found in queue router",
|
|
361
|
+
failedAt: Date.now()
|
|
362
|
+
}
|
|
363
|
+
}))
|
|
364
|
+
);
|
|
365
|
+
unhandled.forEach((m) => m.ack());
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
unhandled.forEach((m) => m.ack());
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (typeof routerOptions.default === "function") {
|
|
372
|
+
await routerOptions.default(batch, env, ctx);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (routerOptions.deadLetterQueue) {
|
|
376
|
+
const dlq = useQueue(routerOptions.deadLetterQueue);
|
|
377
|
+
await dlq.sendBatch(
|
|
378
|
+
batch.messages.map((m) => ({
|
|
379
|
+
body: {
|
|
380
|
+
originalId: m.id,
|
|
381
|
+
queue: batch.queue,
|
|
382
|
+
body: m.body,
|
|
383
|
+
attempts: m.attempts,
|
|
384
|
+
reason: `No consumer configured for queue "${queueName}"`,
|
|
385
|
+
failedAt: Date.now()
|
|
386
|
+
}
|
|
387
|
+
}))
|
|
388
|
+
);
|
|
389
|
+
batch.ackAll();
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
batch.ackAll();
|
|
393
|
+
};
|
|
394
|
+
routerFn.__isQueueConsumer = true;
|
|
395
|
+
routerFn.options = { queue: "*" };
|
|
396
|
+
return routerFn;
|
|
397
|
+
}
|
|
398
|
+
export async function replayDeadLetterQueue(options) {
|
|
399
|
+
let replayed = 0;
|
|
400
|
+
let skipped = 0;
|
|
401
|
+
let failed = 0;
|
|
402
|
+
const targetQueue = useQueue(options.target);
|
|
403
|
+
if (options.messages && Array.isArray(options.messages)) {
|
|
404
|
+
for (const msg of options.messages) {
|
|
405
|
+
try {
|
|
406
|
+
const payload = msg.body;
|
|
407
|
+
if (options.filter && !options.filter(payload)) {
|
|
408
|
+
skipped++;
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
let bodyToResend = payload && typeof payload === "object" && "originalId" in payload && "body" in payload ? payload.body : payload;
|
|
412
|
+
if (typeof options.transform === "function") {
|
|
413
|
+
bodyToResend = options.transform(bodyToResend);
|
|
414
|
+
}
|
|
415
|
+
await targetQueue.send(bodyToResend, {
|
|
416
|
+
delaySeconds: options.delaySeconds
|
|
417
|
+
});
|
|
418
|
+
msg.ack();
|
|
419
|
+
replayed++;
|
|
420
|
+
} catch (err) {
|
|
421
|
+
failed++;
|
|
422
|
+
console.error(`[qarpeo:queue:replay] Failed replaying message ${msg.id}:`, err);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return { replayed, skipped, failed };
|
|
427
|
+
}
|
|
@@ -1,25 +1,53 @@
|
|
|
1
|
-
import type { ChunkOptions, RAGPipelineConfig, RAGPipeline } from "../../../types";
|
|
2
|
-
export type { ChunkOptions, RAGDocument, RAGChunk, RAGChunkMatch, RAGPipelineConfig, RAGQueryOptions, RAGContextResult, RAGAnswerOptions, RAGAnswerResult, RAGPipeline, } from "../../../types";
|
|
1
|
+
import type { ChunkOptions, RAGPipelineConfig, RAGPipeline, AutoRag } from "../../../types";
|
|
2
|
+
export type { ChunkOptions, RAGDocument, RAGChunk, RAGChunkMatch, RAGPipelineConfig, RAGQueryOptions, RAGContextResult, RAGAnswerOptions, RAGAnswerResult, RAGPipeline, AutoRag, AutoRagIndexable, AutoRagIndexInput, AutoRagIndexOptions, AutoRagIndexResult, AutoRagSearchOptions, AutoRagSearchResult, AutoRagAnswerOptions, AutoRagAnswerResult, AutoRagSyncR2Options, AutoRagSyncR2Result, } from "../../../types";
|
|
3
3
|
/**
|
|
4
4
|
* Splits raw text into overlapping contextual chunks respecting paragraph, sentence, and word
|
|
5
5
|
* boundaries.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const chunks = splitTextIntoChunks("Long document content...", {
|
|
10
|
+
* chunkSize: 500,
|
|
11
|
+
* chunkOverlap: 50,
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
6
14
|
*/
|
|
7
15
|
export declare function splitTextIntoChunks(text: string, options?: ChunkOptions): string[];
|
|
16
|
+
export declare function createRAGPipeline(config?: RAGPipelineConfig): RAGPipeline;
|
|
8
17
|
/**
|
|
9
|
-
* Creates an edge
|
|
10
|
-
*
|
|
18
|
+
* Creates an AutoRAG edge engine instance backed by Workers AI and Vectorize.
|
|
19
|
+
*
|
|
20
|
+
* Automatically handles text chunking, embedding generation via Workers AI,
|
|
21
|
+
* Vectorize ingestion, and semantic query matching with zero pipeline boilerplate.
|
|
11
22
|
*
|
|
12
23
|
* @example
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const customAutoRag = createAutoRag({
|
|
26
|
+
* binding: "VECTORIZE_DOCS",
|
|
27
|
+
* embeddingModel: "@cf/baai/bge-base-en-v1.5",
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAutoRag(config?: RAGPipelineConfig): AutoRag;
|
|
32
|
+
/**
|
|
33
|
+
* Global default AutoRAG edge singleton.
|
|
18
34
|
*
|
|
19
|
-
*
|
|
20
|
-
* await docsRAG.indexDocument({ id: "auth-guide", text: "..." })
|
|
35
|
+
* Provides high-level zero-pipeline ingestion and semantic search:
|
|
21
36
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { autorag } from "qarpeo/server"
|
|
40
|
+
*
|
|
41
|
+
* // Ingest text
|
|
42
|
+
* await autorag.index("Qarpeo is a Cloudflare edge framework...")
|
|
43
|
+
*
|
|
44
|
+
* // Search knowledge
|
|
45
|
+
* const { matches, contextText } = await autorag.search("What is Qarpeo?")
|
|
46
|
+
*
|
|
47
|
+
* // Grounded Q&A
|
|
48
|
+
* const { answer, sources } = await autorag.answer("What is Qarpeo?")
|
|
49
|
+
* ```
|
|
24
50
|
*/
|
|
25
|
-
export declare
|
|
51
|
+
export declare const autorag: AutoRag;
|
|
52
|
+
/** Alias for {@link createAutoRag}. */
|
|
53
|
+
export declare const useAutoRag: typeof createAutoRag;
|