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
|
@@ -1,79 +1,28 @@
|
|
|
1
|
+
import { type ComputedRef, type Ref } from "vue";
|
|
1
2
|
import type { QarpeoOrganization, QarpeoMember } from "../../types/auth";
|
|
2
3
|
export type QarpeoUserOrg = QarpeoOrganization & {
|
|
3
4
|
role: string;
|
|
4
5
|
memberId: string;
|
|
5
6
|
};
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
role: import("vue").ComputedRef<string | null>;
|
|
26
|
-
members: import("vue").Ref<{
|
|
27
|
-
id: string;
|
|
28
|
-
organizationId: string;
|
|
29
|
-
userId: string;
|
|
30
|
-
role: "owner" | "admin" | "member" | string;
|
|
31
|
-
createdAt: number;
|
|
32
|
-
user?: {
|
|
33
|
-
[x: string]: any;
|
|
34
|
-
id: string;
|
|
35
|
-
email: string;
|
|
36
|
-
name?: string | null | undefined;
|
|
37
|
-
avatarUrl?: string | null | undefined;
|
|
38
|
-
emailVerified?: boolean | undefined;
|
|
39
|
-
role?: (import("../..").QarpeoRole | string) | undefined;
|
|
40
|
-
} | undefined;
|
|
41
|
-
email?: string | undefined;
|
|
42
|
-
name?: string | undefined;
|
|
43
|
-
avatarUrl?: string | undefined;
|
|
44
|
-
}[], (QarpeoMember & {
|
|
45
|
-
email?: string;
|
|
46
|
-
name?: string;
|
|
47
|
-
avatarUrl?: string;
|
|
48
|
-
})[] | {
|
|
49
|
-
id: string;
|
|
50
|
-
organizationId: string;
|
|
51
|
-
userId: string;
|
|
52
|
-
role: "owner" | "admin" | "member" | string;
|
|
53
|
-
createdAt: number;
|
|
54
|
-
user?: {
|
|
55
|
-
[x: string]: any;
|
|
56
|
-
id: string;
|
|
57
|
-
email: string;
|
|
58
|
-
name?: string | null | undefined;
|
|
59
|
-
avatarUrl?: string | null | undefined;
|
|
60
|
-
emailVerified?: boolean | undefined;
|
|
61
|
-
role?: (import("../..").QarpeoRole | string) | undefined;
|
|
62
|
-
} | undefined;
|
|
63
|
-
email?: string | undefined;
|
|
64
|
-
name?: string | undefined;
|
|
65
|
-
avatarUrl?: string | undefined;
|
|
66
|
-
}[]>;
|
|
67
|
-
loading: import("vue").Ref<boolean, boolean>;
|
|
68
|
-
fetchOrganizations: () => Promise<{
|
|
69
|
-
id: string;
|
|
70
|
-
name: string;
|
|
71
|
-
slug: string;
|
|
72
|
-
logoUrl?: string | null | undefined;
|
|
73
|
-
createdAt: number;
|
|
74
|
-
role: string;
|
|
75
|
-
memberId: string;
|
|
76
|
-
}[]>;
|
|
7
|
+
export interface OrganizationMember extends QarpeoMember {
|
|
8
|
+
email?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
avatarUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UseOrganizationReturn {
|
|
13
|
+
/** Currently active organization for the current session. */
|
|
14
|
+
organization: ComputedRef<QarpeoOrganization | null>;
|
|
15
|
+
/** List of all organizations the current user belongs to. */
|
|
16
|
+
organizations: Ref<QarpeoUserOrg[]>;
|
|
17
|
+
/** Role of the current user in the active organization. */
|
|
18
|
+
role: ComputedRef<string | null>;
|
|
19
|
+
/** Members of the currently active organization. */
|
|
20
|
+
members: Ref<OrganizationMember[]>;
|
|
21
|
+
/** Whether an organization request is in flight. */
|
|
22
|
+
loading: Ref<boolean>;
|
|
23
|
+
/** Fetches all organizations for the authenticated user. */
|
|
24
|
+
fetchOrganizations: () => Promise<QarpeoUserOrg[]>;
|
|
25
|
+
/** Creates a new organization with the current user as owner. */
|
|
77
26
|
createOrganization: (input: {
|
|
78
27
|
name: string;
|
|
79
28
|
slug?: string;
|
|
@@ -82,11 +31,13 @@ export declare function useOrganization(): {
|
|
|
82
31
|
organization: QarpeoOrganization;
|
|
83
32
|
member: QarpeoMember;
|
|
84
33
|
}>;
|
|
34
|
+
/** Switches the active organization context for the session. */
|
|
85
35
|
switchOrganization: (organizationId: string) => Promise<{
|
|
86
36
|
success: boolean;
|
|
87
37
|
organization: QarpeoOrganization;
|
|
88
38
|
role: string;
|
|
89
39
|
}>;
|
|
40
|
+
/** Sends an invitation to join the organization. */
|
|
90
41
|
inviteMember: (input: {
|
|
91
42
|
email: string;
|
|
92
43
|
role?: string;
|
|
@@ -97,31 +48,27 @@ export declare function useOrganization(): {
|
|
|
97
48
|
expiresAt: number;
|
|
98
49
|
inviteUrl: string;
|
|
99
50
|
}>;
|
|
51
|
+
/** Removes a member from the organization. */
|
|
100
52
|
removeMember: (memberId: string, organizationId?: string) => Promise<{
|
|
101
53
|
success: boolean;
|
|
102
54
|
}>;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
userId: string;
|
|
107
|
-
role: "owner" | "admin" | "member" | string;
|
|
108
|
-
createdAt: number;
|
|
109
|
-
user?: {
|
|
110
|
-
[x: string]: any;
|
|
111
|
-
id: string;
|
|
112
|
-
email: string;
|
|
113
|
-
name?: string | null | undefined;
|
|
114
|
-
avatarUrl?: string | null | undefined;
|
|
115
|
-
emailVerified?: boolean | undefined;
|
|
116
|
-
role?: (import("../..").QarpeoRole | string) | undefined;
|
|
117
|
-
} | undefined;
|
|
118
|
-
email?: string | undefined;
|
|
119
|
-
name?: string | undefined;
|
|
120
|
-
avatarUrl?: string | undefined;
|
|
121
|
-
}[]>;
|
|
55
|
+
/** Fetches all members of the specified or active organization. */
|
|
56
|
+
fetchMembers: (organizationId?: string) => Promise<OrganizationMember[]>;
|
|
57
|
+
/** Accepts an invitation token to join an organization. */
|
|
122
58
|
joinOrganization: (token: string) => Promise<{
|
|
123
59
|
success: boolean;
|
|
124
60
|
organizationId: string;
|
|
125
61
|
role: string;
|
|
126
62
|
}>;
|
|
127
|
-
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Headless multi-tenant organization / team management composable.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```vue
|
|
69
|
+
* <script setup lang="ts">
|
|
70
|
+
* const { organization, organizations, switchOrganization, createOrganization } = useOrganization()
|
|
71
|
+
* </script>
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function useOrganization(): UseOrganizationReturn;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { type Ref } from "vue";
|
|
2
|
+
export interface UsePasskeyReturn {
|
|
3
|
+
/** Whether a WebAuthn ceremony is actively in progress. */
|
|
4
|
+
loading: Ref<boolean>;
|
|
5
|
+
/** Error message from the last WebAuthn attempt or null. */
|
|
6
|
+
error: Ref<string | null>;
|
|
7
|
+
/** Triggers WebAuthn credential creation ceremony on the device. */
|
|
8
|
+
registerPasskey: () => Promise<unknown>;
|
|
9
|
+
/** Triggers WebAuthn assertion ceremony on the device to authenticate. */
|
|
10
|
+
loginWithPasskey: () => Promise<unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Headless WebAuthn / Passkey authentication composable supporting FIDO2 biometric authentication.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```vue
|
|
17
|
+
* <script setup lang="ts">
|
|
18
|
+
* const { loginWithPasskey, registerPasskey, loading, error } = usePasskey()
|
|
19
|
+
* </script>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function usePasskey(): UsePasskeyReturn;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { type Ref } from "vue";
|
|
2
|
+
export interface UsePasswordlessReturn {
|
|
3
|
+
/** Whether an OTP or magic link network request is in flight. */
|
|
4
|
+
loading: Ref<boolean>;
|
|
5
|
+
/** Error message from the last request or null. */
|
|
6
|
+
error: Ref<string | null>;
|
|
7
|
+
/** Sends a one-time password code to the target email. */
|
|
8
|
+
sendOtp: (email: string) => Promise<unknown>;
|
|
9
|
+
/** Verifies an OTP code and establishes an authenticated session. */
|
|
10
|
+
verifyOtp: (email: string, code: string) => Promise<unknown>;
|
|
11
|
+
/** Sends a passwordless magic login link to the target email. */
|
|
12
|
+
sendMagicLink: (email: string) => Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Headless passwordless authentication composable supporting Email OTP codes and Magic Links.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```vue
|
|
19
|
+
* <script setup lang="ts">
|
|
20
|
+
* const { sendOtp, verifyOtp, loading, error } = usePasswordless()
|
|
21
|
+
* </script>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function usePasswordless(): UsePasswordlessReturn;
|
|
@@ -1,46 +1,62 @@
|
|
|
1
|
+
import { type ComputedRef } from "vue";
|
|
1
2
|
import type { QarpeoSubscription } from "../../../types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
export interface SubscriptionCheckoutOptions {
|
|
4
|
+
priceId?: string;
|
|
5
|
+
mode?: "subscription" | "payment" | "setup";
|
|
6
|
+
trialDays?: number;
|
|
7
|
+
customerEmail?: string;
|
|
8
|
+
successUrl?: string;
|
|
9
|
+
cancelUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface UseSubscriptionReturn {
|
|
12
|
+
/** Active customer subscription or null. */
|
|
13
|
+
subscription: ComputedRef<QarpeoSubscription | null>;
|
|
14
|
+
/** Whether the customer has an active paid subscription. */
|
|
15
|
+
isSubscribed: ComputedRef<boolean>;
|
|
16
|
+
/** Active subscription plan identifier. */
|
|
17
|
+
plan: ComputedRef<string | null>;
|
|
18
|
+
/** Status of the subscription (e.g. 'active', 'trialing', 'canceled', 'past_due'). */
|
|
19
|
+
status: ComputedRef<string | null>;
|
|
20
|
+
/** Whether subscription data is loading. */
|
|
21
|
+
loading: ComputedRef<boolean>;
|
|
22
|
+
/** Error encountered while fetching subscription data. */
|
|
23
|
+
error: ComputedRef<any>;
|
|
24
|
+
/** Starts a checkout session and redirects the user to the payment provider. */
|
|
25
|
+
checkout: (planId?: string, options?: SubscriptionCheckoutOptions) => Promise<any>;
|
|
26
|
+
/** Opens the Customer Billing Portal for managing payment methods, invoices, and cancellations. */
|
|
24
27
|
openPortal: (options?: {
|
|
25
28
|
returnUrl?: string;
|
|
26
29
|
}) => Promise<any>;
|
|
30
|
+
/** Cancels the active subscription at period end. */
|
|
27
31
|
cancel: (subscriptionId?: string) => Promise<any>;
|
|
32
|
+
/** Changes the subscription to a new plan or price with proration. */
|
|
28
33
|
changePlan: (newPriceId: string, subscriptionId?: string) => Promise<any>;
|
|
34
|
+
/** Records metered usage (API calls, storage GB, compute units, tokens, etc.) */
|
|
29
35
|
reportUsage: (eventName: string, quantity?: number, metadata?: Record<string, any>) => Promise<any>;
|
|
36
|
+
/** Queries metered usage summary for the current user or organization. */
|
|
30
37
|
getUsage: (eventName?: string, options?: {
|
|
31
38
|
since?: number;
|
|
32
39
|
until?: number;
|
|
33
40
|
}) => Promise<any>;
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
/** Refreshes subscription status from the payment provider. */
|
|
42
|
+
refresh: () => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export interface UsePaymentCheckoutReturn {
|
|
45
|
+
/** Starts a checkout session and redirects the user to the payment provider. */
|
|
46
|
+
checkout: (planId?: string, options?: SubscriptionCheckoutOptions) => Promise<any>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Headless subscriptions and billing composable for Stripe, LemonSqueezy, and Polar.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```vue
|
|
53
|
+
* <script setup lang="ts">
|
|
54
|
+
* const { subscription, isSubscribed, checkout, openPortal } = useSubscription()
|
|
55
|
+
* </script>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function useSubscription(): UseSubscriptionReturn;
|
|
36
59
|
/** Convenient standalone composable for initiating one-off or subscription checkout flows. */
|
|
37
|
-
export declare function useCheckout():
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
mode?: "subscription" | "payment" | "setup";
|
|
41
|
-
trialDays?: number;
|
|
42
|
-
customerEmail?: string;
|
|
43
|
-
successUrl?: string;
|
|
44
|
-
cancelUrl?: string;
|
|
45
|
-
}) => Promise<any>;
|
|
46
|
-
};
|
|
60
|
+
export declare function useCheckout(): UsePaymentCheckoutReturn;
|
|
61
|
+
/** Standalone composable for initiating payment/subscription checkout flows. */
|
|
62
|
+
export declare const usePaymentCheckout: () => UsePaymentCheckoutReturn;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type Ref } from "vue";
|
|
2
|
+
export interface UseEventStreamOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Connect immediately when composable is invoked.
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
immediate?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Auto reconnect when connection drops.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
autoReconnect?: boolean | {
|
|
13
|
+
retries?: number;
|
|
14
|
+
delay?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Optional custom event names to listen for in addition to standard "message".
|
|
18
|
+
*/
|
|
19
|
+
events?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Pass credentials (cookies) with the EventSource request.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
withCredentials?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface UseEventStreamReturn<T = any> {
|
|
27
|
+
/**
|
|
28
|
+
* The latest message payload received from the stream.
|
|
29
|
+
* Automatically parsed as JSON if valid, otherwise raw string.
|
|
30
|
+
*/
|
|
31
|
+
data: Ref<T | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Current connection status.
|
|
34
|
+
*/
|
|
35
|
+
status: Ref<"CONNECTING" | "OPEN" | "CLOSED">;
|
|
36
|
+
/**
|
|
37
|
+
* Error object if connection failed.
|
|
38
|
+
*/
|
|
39
|
+
error: Ref<Error | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Last event type received (e.g. "message", "update", "ping").
|
|
42
|
+
*/
|
|
43
|
+
lastEvent: Ref<string | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Last message ID received.
|
|
46
|
+
*/
|
|
47
|
+
lastId: Ref<string | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Manually open or reconnect the event stream.
|
|
50
|
+
*/
|
|
51
|
+
open: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Close the event stream connection.
|
|
54
|
+
*/
|
|
55
|
+
close: () => void;
|
|
56
|
+
/**
|
|
57
|
+
* Register a listener for a specific named SSE event.
|
|
58
|
+
*/
|
|
59
|
+
on: (eventName: string, handler: (payload: any) => void) => () => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Universal Vue composable for subscribing to Server-Sent Events (SSE) live streams.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```vue
|
|
66
|
+
* <script setup lang="ts">
|
|
67
|
+
* const { data, status, close } = useEventStream("/api/live/metrics")
|
|
68
|
+
* </script>
|
|
69
|
+
*
|
|
70
|
+
* <template>
|
|
71
|
+
* <div>Status: {{ status }}</div>
|
|
72
|
+
* <div v-if="data">Live Metric: {{ data.cpu }}%</div>
|
|
73
|
+
* </template>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function useEventStream<T = any>(url: string | Ref<string> | (() => string), options?: UseEventStreamOptions): UseEventStreamReturn<T>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { ref, onBeforeUnmount, unref, watch } from "vue";
|
|
2
|
+
export function useEventStream(url, options = {}) {
|
|
3
|
+
const data = ref(null);
|
|
4
|
+
const status = ref("CLOSED");
|
|
5
|
+
const error = ref(null);
|
|
6
|
+
const lastEvent = ref(null);
|
|
7
|
+
const lastId = ref(null);
|
|
8
|
+
const customListeners = /* @__PURE__ */ new Map();
|
|
9
|
+
let eventSource = null;
|
|
10
|
+
let retryCount = 0;
|
|
11
|
+
let retryTimer = null;
|
|
12
|
+
const getUrl = () => {
|
|
13
|
+
if (typeof url === "function") return url();
|
|
14
|
+
return unref(url);
|
|
15
|
+
};
|
|
16
|
+
function parseData(raw) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(raw);
|
|
19
|
+
} catch {
|
|
20
|
+
return raw;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function dispatchToListeners(eventName, payload) {
|
|
24
|
+
const handlers = customListeners.get(eventName);
|
|
25
|
+
if (handlers) {
|
|
26
|
+
for (const h of handlers) {
|
|
27
|
+
try {
|
|
28
|
+
h(payload);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error(`[qarpeo:useEventStream] Error in listener for "${eventName}":`, e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function close() {
|
|
36
|
+
if (retryTimer) {
|
|
37
|
+
clearTimeout(retryTimer);
|
|
38
|
+
retryTimer = null;
|
|
39
|
+
}
|
|
40
|
+
if (eventSource) {
|
|
41
|
+
eventSource.close();
|
|
42
|
+
eventSource = null;
|
|
43
|
+
}
|
|
44
|
+
status.value = "CLOSED";
|
|
45
|
+
}
|
|
46
|
+
function open() {
|
|
47
|
+
if (import.meta.server) return;
|
|
48
|
+
close();
|
|
49
|
+
const targetUrl = getUrl();
|
|
50
|
+
if (!targetUrl) return;
|
|
51
|
+
status.value = "CONNECTING";
|
|
52
|
+
error.value = null;
|
|
53
|
+
try {
|
|
54
|
+
eventSource = new EventSource(targetUrl, {
|
|
55
|
+
withCredentials: options.withCredentials ?? false
|
|
56
|
+
});
|
|
57
|
+
eventSource.onopen = () => {
|
|
58
|
+
status.value = "OPEN";
|
|
59
|
+
error.value = null;
|
|
60
|
+
retryCount = 0;
|
|
61
|
+
};
|
|
62
|
+
eventSource.onmessage = (e) => {
|
|
63
|
+
lastEvent.value = "message";
|
|
64
|
+
if (e.lastEventId) lastId.value = e.lastEventId;
|
|
65
|
+
const parsed = parseData(e.data);
|
|
66
|
+
data.value = parsed;
|
|
67
|
+
dispatchToListeners("message", parsed);
|
|
68
|
+
};
|
|
69
|
+
eventSource.onerror = (e) => {
|
|
70
|
+
status.value = "CONNECTING";
|
|
71
|
+
error.value = new Error("EventSource connection error");
|
|
72
|
+
const autoReconnect = options.autoReconnect ?? true;
|
|
73
|
+
if (autoReconnect) {
|
|
74
|
+
const maxRetries = typeof autoReconnect === "object" ? autoReconnect.retries ?? 5 : 5;
|
|
75
|
+
const delay = typeof autoReconnect === "object" ? autoReconnect.delay ?? 2e3 : 2e3;
|
|
76
|
+
if (retryCount < maxRetries) {
|
|
77
|
+
retryCount++;
|
|
78
|
+
if (retryTimer) clearTimeout(retryTimer);
|
|
79
|
+
retryTimer = setTimeout(() => {
|
|
80
|
+
if (status.value !== "CLOSED") {
|
|
81
|
+
open();
|
|
82
|
+
}
|
|
83
|
+
}, delay);
|
|
84
|
+
} else {
|
|
85
|
+
close();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
if (options.events?.length) {
|
|
90
|
+
for (const evtName of options.events) {
|
|
91
|
+
eventSource.addEventListener(evtName, (e) => {
|
|
92
|
+
lastEvent.value = evtName;
|
|
93
|
+
if (e.lastEventId) lastId.value = e.lastEventId;
|
|
94
|
+
const parsed = parseData(e.data);
|
|
95
|
+
data.value = parsed;
|
|
96
|
+
dispatchToListeners(evtName, parsed);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
error.value = err;
|
|
102
|
+
status.value = "CLOSED";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function on(eventName, handler) {
|
|
106
|
+
if (!customListeners.has(eventName)) {
|
|
107
|
+
customListeners.set(eventName, /* @__PURE__ */ new Set());
|
|
108
|
+
if (eventSource && eventName !== "message") {
|
|
109
|
+
eventSource.addEventListener(eventName, (e) => {
|
|
110
|
+
lastEvent.value = eventName;
|
|
111
|
+
if (e.lastEventId) lastId.value = e.lastEventId;
|
|
112
|
+
const parsed = parseData(e.data);
|
|
113
|
+
data.value = parsed;
|
|
114
|
+
dispatchToListeners(eventName, parsed);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
customListeners.get(eventName).add(handler);
|
|
119
|
+
return () => {
|
|
120
|
+
const handlers = customListeners.get(eventName);
|
|
121
|
+
if (handlers) {
|
|
122
|
+
handlers.delete(handler);
|
|
123
|
+
if (handlers.size === 0) {
|
|
124
|
+
customListeners.delete(eventName);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (import.meta.client) {
|
|
130
|
+
if (options.immediate !== false) {
|
|
131
|
+
open();
|
|
132
|
+
}
|
|
133
|
+
if (typeof url !== "string") {
|
|
134
|
+
watch(() => getUrl(), () => {
|
|
135
|
+
open();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
onBeforeUnmount(() => {
|
|
139
|
+
close();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
data,
|
|
144
|
+
status,
|
|
145
|
+
error,
|
|
146
|
+
lastEvent,
|
|
147
|
+
lastId,
|
|
148
|
+
open,
|
|
149
|
+
close,
|
|
150
|
+
on
|
|
151
|
+
};
|
|
152
|
+
}
|