qarpeo 0.4.13 → 0.4.14
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 +12 -6
- package/dist/apps/cms.d.ts +1 -1
- package/dist/apps/comments.d.ts +1 -1
- package/dist/apps/payments.d.ts +1 -1
- package/dist/apps/store.d.ts +1 -1
- package/dist/chunks/{manifest.get.mjs → tools.mjs} +445 -430
- package/dist/cli/index.mjs +756 -746
- package/dist/core/aliases.d.ts +1 -1
- package/dist/core/context.d.ts +1 -1
- package/dist/core/d1-migrate.d.ts +1 -1
- package/dist/core/devtools.d.ts +1 -1
- package/dist/core/nitro.d.ts +1 -1
- package/dist/core/schema.d.ts +1 -1
- package/dist/core/server-utils.d.ts +1 -1
- package/dist/core/wrangler.d.ts +1 -1
- package/dist/fate/index.d.ts +8 -8
- package/dist/fate/index.mjs +3 -1
- package/dist/features/agents.d.ts +1 -1
- package/dist/features/auth.d.ts +1 -1
- package/dist/features/bots.d.ts +1 -1
- package/dist/features/console.d.ts +1 -1
- package/dist/features/fate.d.ts +1 -1
- package/dist/features/mail.d.ts +1 -1
- package/dist/features/mcp.d.ts +1 -1
- package/dist/features/multitenant.d.ts +1 -1
- package/dist/features/notifications.d.ts +1 -1
- package/dist/features/realtime.d.ts +1 -1
- package/dist/features/studio.d.ts +4 -0
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +5139 -5067
- package/dist/primitives/ai.d.ts +1 -1
- package/dist/primitives/analytics.d.ts +1 -1
- package/dist/primitives/blob.d.ts +1 -1
- package/dist/primitives/browser.d.ts +1 -1
- package/dist/primitives/cache.d.ts +1 -1
- package/dist/primitives/d1.d.ts +1 -1
- package/dist/primitives/do.d.ts +1 -1
- package/dist/primitives/email.d.ts +1 -1
- package/dist/primitives/hyperdrive.d.ts +1 -1
- package/dist/primitives/kv.d.ts +1 -1
- package/dist/primitives/queue.d.ts +1 -1
- package/dist/primitives/ratelimit.d.ts +1 -1
- package/dist/primitives/vectorize.d.ts +1 -1
- package/dist/primitives/workflows.d.ts +1 -1
- package/dist/runtime/ai.mjs +4 -1
- package/dist/runtime/app/components/CMSEditor.vue +439 -0
- package/dist/runtime/app/components/CMSEditorImageNode.vue +90 -0
- package/dist/runtime/app/components/CMSEditorLinkPopover.vue +120 -0
- package/dist/runtime/app/components/QDropZone.vue +327 -0
- package/dist/runtime/app/components/QImageCropper.vue +658 -0
- package/dist/runtime/app/components/QImageStudio.vue +300 -0
- package/dist/runtime/app/components/QImg.vue +7 -4
- package/dist/runtime/app/composables/analytics.d.ts +8 -8
- package/dist/runtime/app/composables/api-tokens.d.ts +5 -5
- package/dist/runtime/app/composables/auth.d.ts +23 -19
- package/dist/runtime/app/composables/chat.d.ts +7 -6
- package/dist/runtime/app/composables/cms-preview.d.ts +7 -8
- package/dist/runtime/app/composables/cms.d.ts +6 -6
- package/dist/runtime/app/composables/comments.d.ts +5 -5
- package/dist/runtime/app/composables/comments.mjs +7 -4
- package/dist/runtime/app/composables/console.d.ts +6 -14
- package/dist/runtime/app/composables/docs-version.d.ts +8 -8
- package/dist/runtime/app/composables/impersonation.d.ts +5 -5
- package/dist/runtime/app/composables/organization.d.ts +5 -5
- package/dist/runtime/app/composables/passkey.d.ts +5 -5
- package/dist/runtime/app/composables/passwordless.d.ts +5 -5
- package/dist/runtime/app/composables/payments.d.ts +5 -5
- package/dist/runtime/app/composables/rbac.d.ts +5 -5
- package/dist/runtime/app/composables/site.d.ts +2 -2
- package/dist/runtime/app/composables/sse.d.ts +20 -33
- package/dist/runtime/app/composables/sse.mjs +6 -3
- package/dist/runtime/app/composables/storage.d.ts +6 -8
- package/dist/runtime/app/composables/store.d.ts +37 -36
- package/dist/runtime/app/composables/store.mjs +7 -6
- package/dist/runtime/app/composables/studio.d.ts +59 -0
- package/dist/runtime/app/composables/studio.mjs +129 -0
- package/dist/runtime/app/composables/tenant.d.ts +7 -7
- package/dist/runtime/app/composables/turnstile.d.ts +5 -5
- package/dist/runtime/app/composables/two-factor.d.ts +5 -5
- package/dist/runtime/app/pages/devtools/notifications.vue +1 -6
- package/dist/runtime/app/plugins/pwa.mjs +1 -3
- package/dist/runtime/app/utils/cms-editor.d.ts +25 -0
- package/dist/runtime/app/utils/cms-editor.mjs +43 -0
- package/dist/runtime/auth.d.ts +9 -9
- package/dist/runtime/blob.d.ts +1 -3
- package/dist/runtime/blob.mjs +3 -1
- package/dist/runtime/cache.d.ts +8 -6
- package/dist/runtime/cache.mjs +8 -11
- package/dist/runtime/db.d.ts +4 -3
- package/dist/runtime/drizzle.d.ts +2 -1
- package/dist/runtime/drizzle.mjs +2 -2
- package/dist/runtime/queue.d.ts +1 -0
- package/dist/runtime/replica.d.ts +6 -10
- package/dist/runtime/replica.mjs +3 -1
- package/dist/runtime/schema-mysql.d.ts +16 -32
- package/dist/runtime/schema-pg.d.ts +15 -31
- package/dist/runtime/schema-shared.d.ts +20 -17
- package/dist/runtime/schema.d.ts +21 -33
- package/dist/runtime/server/durable-objects/agent.mjs +4 -1
- package/dist/runtime/server/durable-objects/room.d.ts +4 -6
- package/dist/runtime/server/durable-objects/room.mjs +18 -8
- package/dist/runtime/server/plugins/comments.d.ts +2 -3
- package/dist/runtime/server/plugins/email-inbound.d.ts +1 -3
- package/dist/runtime/server/plugins/store.d.ts +2 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.mjs +10 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.mjs +10 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.mjs +7 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.mjs +15 -4
- package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.mjs +13 -4
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.d.ts +3 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.mjs +22 -6
- package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.d.ts +6 -5
- package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.mjs +14 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.mjs +7 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/users.get.d.ts +6 -5
- package/dist/runtime/server/routes/__qarpeo/cloud/users.get.mjs +1 -3
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +2 -2
- package/dist/runtime/server/routes/__qarpeo/manifest.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/og.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/me.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.mjs +1 -5
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/rbac/users.post.d.ts +2 -2
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +1 -6
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +1 -6
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +1 -6
- package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +5 -1
- package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +7 -1
- package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/otp/send.post.mjs +1 -1
- package/dist/runtime/server/routes/cms/search.get.mjs +2 -6
- package/dist/runtime/server/routes/comments/[id]/report.post.mjs +1 -4
- package/dist/runtime/server/routes/comments/[id].patch.mjs +1 -4
- package/dist/runtime/server/routes/comments/batch.post.mjs +1 -3
- package/dist/runtime/server/routes/comments/index.post.mjs +1 -5
- package/dist/runtime/server/routes/fate.mjs +1 -1
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +1 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
- package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +5 -6
- package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +1 -1
- package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +1 -1
- package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +1 -1
- package/dist/runtime/server/routes/store/currencies.get.mjs +1 -4
- package/dist/runtime/server/routes/store/orders/[id].get.mjs +1 -1
- package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +13 -4
- package/dist/runtime/server/routes/store/orders/index.get.mjs +1 -1
- package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +2 -1
- package/dist/runtime/server/routes/store/tax/calculate.post.mjs +12 -3
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +4 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +4 -1
- package/dist/runtime/server/utils/ai.d.ts +38 -35
- package/dist/runtime/server/utils/ai.mjs +7 -11
- package/dist/runtime/server/utils/analytics-query.d.ts +4 -4
- package/dist/runtime/server/utils/auth.d.ts +25 -25
- package/dist/runtime/server/utils/auth.mjs +22 -8
- package/dist/runtime/server/utils/bots.d.ts +7 -7
- package/dist/runtime/server/utils/browser-utils.d.ts +26 -27
- package/dist/runtime/server/utils/cache.d.ts +20 -20
- package/dist/runtime/server/utils/cms/collections.mjs +1 -6
- package/dist/runtime/server/utils/cms/common.mjs +1 -0
- package/dist/runtime/server/utils/cms/markdown.d.ts +2 -2
- package/dist/runtime/server/utils/cms/markdown.mjs +5 -5
- package/dist/runtime/server/utils/cms/mutations.mjs +8 -23
- package/dist/runtime/server/utils/cms/navigation.mjs +4 -4
- package/dist/runtime/server/utils/cms/path.d.ts +1 -0
- package/dist/runtime/server/utils/cms/path.mjs +8 -2
- package/dist/runtime/server/utils/cms/references.mjs +1 -7
- package/dist/runtime/server/utils/cms/search.d.ts +2 -2
- package/dist/runtime/server/utils/cms/sync.mjs +4 -2
- package/dist/runtime/server/utils/cms/taxonomy.d.ts +2 -2
- package/dist/runtime/server/utils/cms.d.ts +1 -1
- package/dist/runtime/server/utils/cms.mjs +1 -5
- package/dist/runtime/server/utils/comments-filter.d.ts +9 -7
- package/dist/runtime/server/utils/comments.d.ts +68 -55
- package/dist/runtime/server/utils/comments.mjs +21 -9
- package/dist/runtime/server/utils/config.d.ts +2 -2
- package/dist/runtime/server/utils/console.d.ts +3 -5
- package/dist/runtime/server/utils/context.d.ts +10 -10
- package/dist/runtime/server/utils/crypto.d.ts +20 -20
- package/dist/runtime/server/utils/domains.mjs +3 -1
- package/dist/runtime/server/utils/drizzle.d.ts +24 -25
- package/dist/runtime/server/utils/drizzle.mjs +17 -17
- package/dist/runtime/server/utils/durable-object.d.ts +27 -25
- package/dist/runtime/server/utils/durable-object.mjs +3 -10
- package/dist/runtime/server/utils/email-inbound.d.ts +10 -10
- package/dist/runtime/server/utils/impersonation.d.ts +18 -18
- package/dist/runtime/server/utils/legacy-hash.d.ts +23 -27
- package/dist/runtime/server/utils/lock.d.ts +20 -23
- package/dist/runtime/server/utils/mail.d.ts +19 -19
- package/dist/runtime/server/utils/mail.mjs +4 -2
- package/dist/runtime/server/utils/mcp.d.ts +20 -20
- package/dist/runtime/server/utils/mcp.mjs +22 -38
- package/dist/runtime/server/utils/notifications.d.ts +49 -38
- package/dist/runtime/server/utils/oauth.d.ts +3 -9
- package/dist/runtime/server/utils/organization.d.ts +28 -28
- package/dist/runtime/server/utils/organization.mjs +15 -5
- package/dist/runtime/server/utils/passwordless.d.ts +24 -24
- package/dist/runtime/server/utils/payments/checkout.d.ts +12 -12
- package/dist/runtime/server/utils/payments/checkout.mjs +1 -3
- package/dist/runtime/server/utils/payments/common.d.ts +3 -3
- package/dist/runtime/server/utils/payments/paddle.d.ts +4 -1
- package/dist/runtime/server/utils/payments/polar.d.ts +4 -1
- package/dist/runtime/server/utils/payments/stripe.mjs +5 -7
- package/dist/runtime/server/utils/payments/subscriptions.d.ts +14 -14
- package/dist/runtime/server/utils/payments/subscriptions.mjs +2 -6
- package/dist/runtime/server/utils/payments/usage.mjs +1 -3
- package/dist/runtime/server/utils/payments/webhooks.mjs +2 -2
- package/dist/runtime/server/utils/queue.d.ts +54 -58
- package/dist/runtime/server/utils/queue.mjs +2 -6
- package/dist/runtime/server/utils/rag.d.ts +23 -23
- package/dist/runtime/server/utils/rag.mjs +10 -5
- package/dist/runtime/server/utils/ratelimit.d.ts +21 -18
- package/dist/runtime/server/utils/rbac.d.ts +13 -15
- package/dist/runtime/server/utils/rbac.mjs +44 -10
- package/dist/runtime/server/utils/realtime.d.ts +53 -52
- package/dist/runtime/server/utils/role-env.d.ts +5 -4
- package/dist/runtime/server/utils/scheduled-task.d.ts +14 -15
- package/dist/runtime/server/utils/session.d.ts +40 -40
- package/dist/runtime/server/utils/sse.d.ts +23 -33
- package/dist/runtime/server/utils/sse.mjs +5 -14
- package/dist/runtime/server/utils/sso.mjs +3 -1
- package/dist/runtime/server/utils/storage.d.ts +20 -22
- package/dist/runtime/server/utils/storage.mjs +2 -2
- package/dist/runtime/server/utils/store/cart.d.ts +5 -3
- package/dist/runtime/server/utils/store/cart.mjs +14 -10
- package/dist/runtime/server/utils/store/checkout.mjs +4 -1
- package/dist/runtime/server/utils/store/common.d.ts +1 -1
- package/dist/runtime/server/utils/store/common.mjs +36 -12
- package/dist/runtime/server/utils/store/inventory.mjs +3 -1
- package/dist/runtime/server/utils/store/orders.mjs +32 -24
- package/dist/runtime/server/utils/store-localization.d.ts +9 -27
- package/dist/runtime/server/utils/store-localization.mjs +3 -3
- package/dist/runtime/server/utils/table-names.d.ts +15 -15
- package/dist/runtime/server/utils/table-names.mjs +1 -1
- package/dist/runtime/server/utils/tenant.d.ts +12 -12
- package/dist/runtime/server/utils/tenant.mjs +7 -4
- package/dist/runtime/server/utils/totp.d.ts +18 -18
- package/dist/runtime/server/utils/tracker.d.ts +5 -5
- package/dist/runtime/server/utils/turnstile.d.ts +9 -9
- package/dist/runtime/server/utils/urn.d.ts +5 -8
- package/dist/runtime/server/utils/workflows.d.ts +30 -31
- package/dist/runtime/server/utils/workflows.mjs +2 -4
- package/dist/runtime/server.d.ts +2 -2
- package/dist/runtime/service.d.ts +10 -10
- package/dist/runtime/test-utils.d.ts +10 -10
- package/dist/runtime/test-utils.mjs +9 -2
- package/dist/runtime/types/ai.d.ts +14 -14
- package/dist/runtime/types/d1.d.ts +6 -11
- package/dist/runtime/types/durable-object.d.ts +4 -8
- package/dist/runtime/types/email.d.ts +3 -9
- package/dist/runtime/types/index.d.ts +15 -21
- package/dist/runtime/types/r2.d.ts +5 -5
- package/dist/runtime/types/workflows.d.ts +5 -6
- package/dist/runtime/workflows.d.ts +1 -3
- package/dist/types/ai.d.ts +10 -17
- package/dist/types/auth.d.ts +5 -3
- package/dist/types/cache.d.ts +7 -7
- package/dist/types/cms.d.ts +30 -5
- package/dist/types/comments.d.ts +23 -21
- package/dist/types/console.d.ts +1 -3
- package/dist/types/db.d.ts +7 -7
- package/dist/types/index.d.ts +1 -0
- package/dist/types/options.d.ts +36 -24
- package/dist/types/site.d.ts +8 -2
- package/dist/types/storage.d.ts +2 -1
- package/dist/types/store-options.d.ts +10 -26
- package/dist/types/studio.d.ts +79 -0
- package/dist/utils/bots.d.ts +7 -3
- package/dist/utils/cms-table-names.d.ts +1 -1
- package/dist/utils/drizzle.d.ts +13 -14
- package/dist/utils/email-inbound.d.ts +4 -4
- package/dist/utils/features.d.ts +19 -5
- package/dist/utils/mcp.d.ts +1 -0
- package/dist/utils/migration-lock.d.ts +15 -29
- package/dist/utils/pkg.d.ts +6 -7
- package/dist/utils/schema-diff.d.ts +7 -11
- package/dist/utils/store-schema.d.ts +4 -6
- package/dist/utils/tools.d.ts +3 -3
- package/package.json +55 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { QueueMessage, QueueMessageBatch, DeadLetterPayload, QueueRetryBackoffStrategy, QueueRetryBackoffConfig, QueueRouterOptions } from "../../types/queue";
|
|
2
2
|
export type { QueueMessage, QueueMessageBatch, DeadLetterPayload, QueueRetryBackoffStrategy, QueueRetryBackoffConfig, QueueRoutingRule, QueueRouterOptions, } from "../../types/queue";
|
|
3
3
|
/**
|
|
4
|
-
* Thrown inside a queue handler to indicate a fatal, non-retryable error
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Thrown inside a queue handler to indicate a fatal, non-retryable error (e.g. malformed JSON,
|
|
5
|
+
* unrecoverable data corruption). Bypasses remaining retry attempts and routes immediately to the
|
|
6
|
+
* Dead Letter Queue.
|
|
7
7
|
*/
|
|
8
8
|
export declare class FatalQueueError extends Error {
|
|
9
9
|
readonly details?: any | undefined;
|
|
@@ -28,8 +28,8 @@ export interface QueueConsumerContext {
|
|
|
28
28
|
delaySeconds?: number;
|
|
29
29
|
}) => void;
|
|
30
30
|
/**
|
|
31
|
-
* Reject the message immediately as a non-retryable fatal error, routing it directly
|
|
32
|
-
*
|
|
31
|
+
* Reject the message immediately as a non-retryable fatal error, routing it directly to the Dead
|
|
32
|
+
* Letter Queue without consuming remaining attempts.
|
|
33
33
|
*/
|
|
34
34
|
reject: (reason?: string) => Promise<void>;
|
|
35
35
|
/** Forward this message payload directly to a Dead Letter Queue */
|
|
@@ -60,15 +60,13 @@ export interface QueueConsumerOptions<T = any> {
|
|
|
60
60
|
* ;(attempt) => Math.min(3600, Math.pow(2, attempt) * 5)
|
|
61
61
|
*/
|
|
62
62
|
retryDelaySeconds?: number | ((attempt: number) => number);
|
|
63
|
-
/**
|
|
64
|
-
* Backoff retry configuration (exponential, linear, or custom with jitter).
|
|
65
|
-
*/
|
|
63
|
+
/** Backoff retry configuration (exponential, linear, or custom with jitter). */
|
|
66
64
|
retryBackoff?: QueueRetryBackoffStrategy | QueueRetryBackoffConfig;
|
|
67
65
|
/** Cloudflare Queue binding or queue name to route permanently failed messages to. */
|
|
68
66
|
deadLetterQueue?: string;
|
|
69
67
|
/**
|
|
70
|
-
* Optional secondary fallback hook called if delivery to `deadLetterQueue` fails
|
|
71
|
-
*
|
|
68
|
+
* Optional secondary fallback hook called if delivery to `deadLetterQueue` fails or if custom
|
|
69
|
+
* persistence is needed.
|
|
72
70
|
*/
|
|
73
71
|
dlqFallback?: (payload: DeadLetterPayload<T>) => Promise<void> | void;
|
|
74
72
|
/** Callback hook executed when a message exceeds maxRetries and is about to be dead-lettered. */
|
|
@@ -89,60 +87,58 @@ export interface QueueConsumer<T = any> {
|
|
|
89
87
|
/** Calculates backoff retry delay taking into account strategy, factor, and jitter. */
|
|
90
88
|
export declare function calculateRetryDelay(attempt: number, config?: number | QueueRetryBackoffStrategy | QueueRetryBackoffConfig, error?: Error): number | undefined;
|
|
91
89
|
/**
|
|
92
|
-
* Define a typed Cloudflare Queue consumer with automatic batch chunking, retry tracking,
|
|
93
|
-
*
|
|
90
|
+
* Define a typed Cloudflare Queue consumer with automatic batch chunking, retry tracking, and Dead
|
|
91
|
+
* Letter Queue (DLQ) routing.
|
|
94
92
|
*
|
|
95
93
|
* @example
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* // server/queues/orders.ts
|
|
96
|
+
* export default defineQueueConsumer({
|
|
97
|
+
* batchSize: 5,
|
|
98
|
+
* maxRetries: 3,
|
|
99
|
+
* retryBackoff: { strategy: "exponential", initialDelay: 5 },
|
|
100
|
+
* deadLetterQueue: "ORDERS_DLQ",
|
|
101
|
+
* async handler(message, ctx) {
|
|
102
|
+
* if (!message.body.id) {
|
|
103
|
+
* throw new FatalQueueError("Missing order ID")
|
|
104
|
+
* }
|
|
105
|
+
* await processOrder(message.body)
|
|
106
|
+
* },
|
|
107
|
+
* async onDeadLetter(message, err) {
|
|
108
|
+
* console.error(`Order ${message.id} sent to DLQ:`, err.message)
|
|
109
|
+
* },
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
114
112
|
*/
|
|
115
113
|
export declare function defineQueueConsumer<T = any>(optionsOrHandler: QueueConsumerOptions<T> | QueueMessageHandler<T> | QueueBatchHandler<T>, maybeOptions?: Omit<QueueConsumerOptions<T>, "handler">): QueueConsumer<T>;
|
|
116
114
|
/** Backward-compatible alias for defineQueueConsumer. */
|
|
117
115
|
export declare const defineQueueHandler: typeof defineQueueConsumer;
|
|
118
|
-
/**
|
|
119
|
-
* Define a typed Cloudflare Queue consumer matching Void Cloud (`void/queues`) syntax.
|
|
120
|
-
*/
|
|
116
|
+
/** Define a typed Cloudflare Queue consumer matching Void Cloud (`void/queues`) syntax. */
|
|
121
117
|
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
118
|
/**
|
|
123
119
|
* Defines an advanced multi-queue and content-based queue router.
|
|
124
120
|
*
|
|
125
|
-
* Routes incoming batches/messages by queue name patterns or message body predicates,
|
|
126
|
-
*
|
|
121
|
+
* Routes incoming batches/messages by queue name patterns or message body predicates, with
|
|
122
|
+
* automated Dead Letter Queue fallbacks.
|
|
127
123
|
*
|
|
128
124
|
* @example
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* export default defineQueueRouter({
|
|
127
|
+
* // 1. By exact queue name or wildcard pattern
|
|
128
|
+
* orders: ordersConsumer,
|
|
129
|
+
* "emails-*": emailsConsumer,
|
|
134
130
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
131
|
+
* // 2. Content-based rules
|
|
132
|
+
* routes: [
|
|
133
|
+
* { match: (msg) => msg.body?.event === "checkout.completed", handler: checkoutHandler },
|
|
134
|
+
* { match: { type: "payment" }, handler: paymentHandler },
|
|
135
|
+
* ],
|
|
140
136
|
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
137
|
+
* // 3. Catch-all fallback
|
|
138
|
+
* default: defaultHandler,
|
|
139
|
+
* deadLetterQueue: "UNROUTED_DLQ",
|
|
140
|
+
* })
|
|
141
|
+
* ```
|
|
146
142
|
*/
|
|
147
143
|
export declare function defineQueueRouter<T = any>(routerOptions: QueueRouterOptions<T>): QueueConsumer<T>;
|
|
148
144
|
export interface ReplayDeadLetterOptions<T = any> {
|
|
@@ -165,14 +161,14 @@ export interface ReplayDeadLetterOptions<T = any> {
|
|
|
165
161
|
* Replays dead-letter messages back to the primary or target queue.
|
|
166
162
|
*
|
|
167
163
|
* @example
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const result = await replayDeadLetterQueue({
|
|
166
|
+
* dlq: "ORDERS_DLQ",
|
|
167
|
+
* target: "ORDERS",
|
|
168
|
+
* messages: dlqBatch.messages,
|
|
169
|
+
* filter: (msg) => msg.attempts < 5,
|
|
170
|
+
* })
|
|
171
|
+
* ```
|
|
176
172
|
*/
|
|
177
173
|
export declare function replayDeadLetterQueue<T = any>(options: ReplayDeadLetterOptions<T>): Promise<{
|
|
178
174
|
replayed: number;
|
|
@@ -30,7 +30,7 @@ export function calculateRetryDelay(attempt, config, error) {
|
|
|
30
30
|
if (strategy === "linear") {
|
|
31
31
|
delay = initial * attempt;
|
|
32
32
|
} else if (strategy === "exponential") {
|
|
33
|
-
delay = initial *
|
|
33
|
+
delay = initial * factor ** Math.max(0, attempt - 1);
|
|
34
34
|
} else if (strategy === "fixed") {
|
|
35
35
|
delay = initial;
|
|
36
36
|
}
|
|
@@ -216,11 +216,7 @@ export function defineQueueConsumer(optionsOrHandler, maybeOptions) {
|
|
|
216
216
|
message.retry(delaySeconds !== void 0 ? { delaySeconds } : void 0);
|
|
217
217
|
} else {
|
|
218
218
|
try {
|
|
219
|
-
await sendToDeadLetter(
|
|
220
|
-
options.deadLetterQueue,
|
|
221
|
-
err?.message || String(err),
|
|
222
|
-
err
|
|
223
|
-
);
|
|
219
|
+
await sendToDeadLetter(options.deadLetterQueue, err?.message || String(err), err);
|
|
224
220
|
if (typeof options.onDeadLetter === "function") {
|
|
225
221
|
try {
|
|
226
222
|
await options.onDeadLetter(message, err, messageContext);
|
|
@@ -5,28 +5,28 @@ export type { ChunkOptions, RAGDocument, RAGChunk, RAGChunkMatch, RAGPipelineCon
|
|
|
5
5
|
* boundaries.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const chunks = splitTextIntoChunks("Long document content...", {
|
|
10
|
+
* chunkSize: 500,
|
|
11
|
+
* chunkOverlap: 50,
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
14
|
*/
|
|
15
15
|
export declare function splitTextIntoChunks(text: string, options?: ChunkOptions): string[];
|
|
16
16
|
export declare function createRAGPipeline(config?: RAGPipelineConfig): RAGPipeline;
|
|
17
17
|
/**
|
|
18
18
|
* Creates an AutoRAG edge engine instance backed by Workers AI and Vectorize.
|
|
19
19
|
*
|
|
20
|
-
* Automatically handles text chunking, embedding generation via Workers AI,
|
|
21
|
-
*
|
|
20
|
+
* Automatically handles text chunking, embedding generation via Workers AI, Vectorize ingestion,
|
|
21
|
+
* and semantic query matching with zero pipeline boilerplate.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const customAutoRag = createAutoRag({
|
|
26
|
+
* binding: "VECTORIZE_DOCS",
|
|
27
|
+
* embeddingModel: "@cf/baai/bge-base-en-v1.5",
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
30
|
*/
|
|
31
31
|
export declare function createAutoRag(config?: RAGPipelineConfig): AutoRag;
|
|
32
32
|
/**
|
|
@@ -35,18 +35,18 @@ export declare function createAutoRag(config?: RAGPipelineConfig): AutoRag;
|
|
|
35
35
|
* Provides high-level zero-pipeline ingestion and semantic search:
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { autorag } from "qarpeo/server"
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* // Ingest text
|
|
42
|
+
* await autorag.index("Qarpeo is a Cloudflare edge framework...")
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
44
|
+
* // Search knowledge
|
|
45
|
+
* const { matches, contextText } = await autorag.search("What is Qarpeo?")
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* // Grounded Q&A
|
|
48
|
+
* const { answer, sources } = await autorag.answer("What is Qarpeo?")
|
|
49
|
+
* ```
|
|
50
50
|
*/
|
|
51
51
|
export declare const autorag: AutoRag;
|
|
52
52
|
/** Alias for {@link createAutoRag}. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getVectorizeBinding } from "../../vectorize.mjs";
|
|
2
1
|
import { getR2Binding } from "../../blob.mjs";
|
|
2
|
+
import { getVectorizeBinding } from "../../vectorize.mjs";
|
|
3
3
|
import { embedText, generateText, defineTool } from "./ai.mjs";
|
|
4
4
|
const GLOBAL_RAG_KEY = "__qarpeo_dev_mock_rag__";
|
|
5
5
|
function getDevMockRAGStore() {
|
|
@@ -257,9 +257,7 @@ export function createRAGPipeline(config) {
|
|
|
257
257
|
if (namespace && item.namespace !== namespace) continue;
|
|
258
258
|
const sim = cosineSimilarity(queryVector, item.vector);
|
|
259
259
|
const queryWords = queryText.toLowerCase().split(/\s+/).filter((w) => w.length > 2);
|
|
260
|
-
const matchCount = queryWords.filter(
|
|
261
|
-
(w) => item.text.toLowerCase().includes(w)
|
|
262
|
-
).length;
|
|
260
|
+
const matchCount = queryWords.filter((w) => item.text.toLowerCase().includes(w)).length;
|
|
263
261
|
const keywordScore = queryWords.length > 0 ? matchCount / queryWords.length * 0.9 : 0;
|
|
264
262
|
const score = Math.max(sim, keywordScore);
|
|
265
263
|
if (score >= minScore) {
|
|
@@ -456,7 +454,14 @@ export function createAutoRag(config) {
|
|
|
456
454
|
async syncR2(options) {
|
|
457
455
|
const bucketName = options?.bucket || "BUCKET";
|
|
458
456
|
const prefix = options?.prefix;
|
|
459
|
-
const allowedExts = options?.extensions || [
|
|
457
|
+
const allowedExts = options?.extensions || [
|
|
458
|
+
".md",
|
|
459
|
+
".txt",
|
|
460
|
+
".json",
|
|
461
|
+
".csv",
|
|
462
|
+
".html",
|
|
463
|
+
".markdown"
|
|
464
|
+
];
|
|
460
465
|
const errors = [];
|
|
461
466
|
let indexedCount = 0;
|
|
462
467
|
let skippedCount = 0;
|
|
@@ -30,12 +30,12 @@ export declare function getClientIp(event: RequestEvent | any): string;
|
|
|
30
30
|
* Evaluates whether a request or key is within the allowed rate limit.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const res = await checkRateLimit(event, { max: 10, window: "1m" })
|
|
35
|
+
* if (!res.success) {
|
|
36
|
+
* // exceeded
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
39
|
*/
|
|
40
40
|
export declare function checkRateLimit(eventOrKey: RequestEvent | string | any, options?: CheckRateLimitOptions): Promise<RateLimitCheckResult>;
|
|
41
41
|
/**
|
|
@@ -43,9 +43,9 @@ export declare function checkRateLimit(eventOrKey: RequestEvent | string | any,
|
|
|
43
43
|
* rate limit headers and throws an HTTP 429 error.
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* await assertRateLimit(event, { max: 5, window: "1m" })
|
|
48
|
+
* ```
|
|
49
49
|
*/
|
|
50
50
|
export declare function assertRateLimit(eventOrKey: RequestEvent | string | any, options?: CheckRateLimitOptions): Promise<RateLimitCheckResult>;
|
|
51
51
|
export interface RateLimitHandlerOptions extends CheckRateLimitOptions {
|
|
@@ -62,14 +62,17 @@ export interface RateLimitHandlerOptions extends CheckRateLimitOptions {
|
|
|
62
62
|
* Higher-order event handler for Nitro/Nuxt that automatically applies edge rate limiting.
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* export default defineRateLimitedEventHandler(
|
|
67
|
+
* {
|
|
68
|
+
* max: 5,
|
|
69
|
+
* window: "1m",
|
|
70
|
+
* message: "Slow down! Maximum 5 requests per minute allowed.",
|
|
71
|
+
* },
|
|
72
|
+
* async (event) => {
|
|
73
|
+
* return { message: "Hello world" }
|
|
74
|
+
* },
|
|
75
|
+
* )
|
|
76
|
+
* ```
|
|
74
77
|
*/
|
|
75
78
|
export declare function defineRateLimitedEventHandler<T = any>(optionsOrHandler: RateLimitHandlerOptions | ((event: RequestEvent) => Promise<T> | T), maybeHandler?: (event: RequestEvent) => Promise<T> | T): (event: RequestEvent) => Promise<T>;
|
|
@@ -23,30 +23,26 @@ export interface ResolvedPermissions {
|
|
|
23
23
|
allow: string[];
|
|
24
24
|
deny: string[];
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Standard capability catalog across Qarpeo Console & API modules.
|
|
28
|
-
*/
|
|
26
|
+
/** Standard capability catalog across Qarpeo Console & API modules. */
|
|
29
27
|
export declare const PERMISSION_CATALOG: ReadonlyArray<{
|
|
30
28
|
key: string;
|
|
31
29
|
module: "console" | "cms" | "store" | "comments" | "media" | "users" | "roles";
|
|
32
30
|
description: string;
|
|
33
31
|
}>;
|
|
34
32
|
/**
|
|
35
|
-
* Built-in default roles. `super` is immutable (`["*"]`).
|
|
36
|
-
*
|
|
33
|
+
* Built-in default roles. `super` is immutable (`["*"]`). All other roles can be overridden in D1
|
|
34
|
+
* by `super` (or a delegated `roles:manage` user).
|
|
37
35
|
*/
|
|
38
36
|
export declare const DEFAULT_ROLE_DEFINITIONS: Readonly<Record<string, RoleDefinition>>;
|
|
39
37
|
export declare function invalidateRbacCache(userId?: string): void;
|
|
40
38
|
/**
|
|
41
|
-
* Checks if a list of granted permissions (supporting `*` and `module:*` wildcards)
|
|
42
|
-
*
|
|
39
|
+
* Checks if a list of granted permissions (supporting `*` and `module:*` wildcards) satisfies
|
|
40
|
+
* `requiredPermission`.
|
|
43
41
|
*/
|
|
44
42
|
export declare function matchPermission(granted: ReadonlyArray<string>, requiredPermission: string): boolean;
|
|
45
43
|
/** Ensures `role` and `user_permission` tables exist in D1. */
|
|
46
44
|
export declare function ensureRbacTables(d1?: any, event?: RequestEvent): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Resolves a user's effective roles and permission overrides (Deny-first, Fail-closed).
|
|
49
|
-
*/
|
|
45
|
+
/** Resolves a user's effective roles and permission overrides (Deny-first, Fail-closed). */
|
|
50
46
|
export declare function resolveUserPermissions(user: {
|
|
51
47
|
id: string;
|
|
52
48
|
email?: string | null;
|
|
@@ -57,16 +53,18 @@ export declare function evaluatePermission(resolved: ResolvedPermissions, permis
|
|
|
57
53
|
/** Checks if the current authenticated user has `permission` (returns false if unauthenticated). */
|
|
58
54
|
export declare function hasPermission(event: RequestEvent, permission: string): Promise<boolean>;
|
|
59
55
|
/**
|
|
60
|
-
* Enforces that the current request is authenticated and holds `permission`.
|
|
61
|
-
*
|
|
56
|
+
* Enforces that the current request is authenticated and holds `permission`. Throws 401 if
|
|
57
|
+
* unauthenticated, 403 if denied.
|
|
62
58
|
*/
|
|
63
59
|
export declare function requirePermission(event: RequestEvent, permission: string): Promise<ResolvedPermissions>;
|
|
64
60
|
/** Lists all built-in + D1-overridden + custom roles. */
|
|
65
61
|
export declare function listRoles(event?: RequestEvent): Promise<RoleDefinition[]>;
|
|
66
62
|
/**
|
|
67
63
|
* Creates or updates a role in D1.
|
|
64
|
+
*
|
|
68
65
|
* - `super` is immutable and cannot be modified.
|
|
69
|
-
* - Non-`super` actors with `roles:manage` cannot grant `*`, `roles:manage`, or permissions they do
|
|
66
|
+
* - Non-`super` actors with `roles:manage` cannot grant `*`, `roles:manage`, or permissions they do
|
|
67
|
+
* not hold.
|
|
70
68
|
*/
|
|
71
69
|
export declare function upsertRole(event: RequestEvent, input: {
|
|
72
70
|
id: string;
|
|
@@ -79,8 +77,8 @@ export declare function deleteRole(event: RequestEvent, roleId: string): Promise
|
|
|
79
77
|
reset: boolean;
|
|
80
78
|
}>;
|
|
81
79
|
/**
|
|
82
|
-
* Sets per-user `extraRoles`, `allow`, and `deny` overrides in D1.
|
|
83
|
-
*
|
|
80
|
+
* Sets per-user `extraRoles`, `allow`, and `deny` overrides in D1. Non-`super` actors cannot assign
|
|
81
|
+
* `super`, `*`, `roles:manage`, or permissions they do not hold.
|
|
84
82
|
*/
|
|
85
83
|
export declare function setUserPermissions(event: RequestEvent, targetUserId: string, input: {
|
|
86
84
|
extraRoles?: string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createError } from "nuxt/server";
|
|
2
2
|
import { getD1Binding } from "../../index.mjs";
|
|
3
|
-
import { getRoleFromEnv } from "./role-env.mjs";
|
|
4
3
|
import { getAuthContext } from "./context.mjs";
|
|
4
|
+
import { getRoleFromEnv } from "./role-env.mjs";
|
|
5
5
|
import { resolveTableName } from "./table-names.mjs";
|
|
6
6
|
export const PERMISSION_CATALOG = [
|
|
7
7
|
{ key: "console:access", module: "console", description: "Access the /console workspace" },
|
|
@@ -10,16 +10,32 @@ export const PERMISSION_CATALOG = [
|
|
|
10
10
|
{ key: "cms:publish", module: "cms", description: "Publish or unpublish CMS entries" },
|
|
11
11
|
{ key: "cms:delete", module: "cms", description: "Delete CMS entries" },
|
|
12
12
|
{ key: "store:read", module: "store", description: "View store products and orders" },
|
|
13
|
-
{
|
|
13
|
+
{
|
|
14
|
+
key: "store:products.write",
|
|
15
|
+
module: "store",
|
|
16
|
+
description: "Create and edit products/variants"
|
|
17
|
+
},
|
|
14
18
|
{ key: "store:orders.manage", module: "store", description: "Fulfill and update order status" },
|
|
15
19
|
{ key: "store:refunds", module: "store", description: "Issue order refunds" },
|
|
16
20
|
{ key: "comments:read", module: "comments", description: "View comments and moderation queue" },
|
|
17
|
-
{
|
|
21
|
+
{
|
|
22
|
+
key: "comments:moderate",
|
|
23
|
+
module: "comments",
|
|
24
|
+
description: "Approve, mark spam, or delete comments"
|
|
25
|
+
},
|
|
18
26
|
{ key: "media:upload", module: "media", description: "Upload files to R2 media library" },
|
|
19
27
|
{ key: "media:delete", module: "media", description: "Delete files from R2 media library" },
|
|
20
28
|
{ key: "users:read", module: "users", description: "View users and staff list" },
|
|
21
|
-
{
|
|
22
|
-
|
|
29
|
+
{
|
|
30
|
+
key: "users:manage",
|
|
31
|
+
module: "users",
|
|
32
|
+
description: "Ban/unban users, revoke sessions, assign roles"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: "roles:manage",
|
|
36
|
+
module: "roles",
|
|
37
|
+
description: "Create/edit custom roles and user permissions"
|
|
38
|
+
}
|
|
23
39
|
];
|
|
24
40
|
export const DEFAULT_ROLE_DEFINITIONS = {
|
|
25
41
|
super: {
|
|
@@ -34,7 +50,15 @@ export const DEFAULT_ROLE_DEFINITIONS = {
|
|
|
34
50
|
id: "admin",
|
|
35
51
|
name: "Admin",
|
|
36
52
|
description: "Manage CMS, Store, Comments, Media, and Users.",
|
|
37
|
-
permissions: [
|
|
53
|
+
permissions: [
|
|
54
|
+
"console:access",
|
|
55
|
+
"cms:*",
|
|
56
|
+
"store:*",
|
|
57
|
+
"comments:*",
|
|
58
|
+
"media:*",
|
|
59
|
+
"users:read",
|
|
60
|
+
"users:manage"
|
|
61
|
+
],
|
|
38
62
|
isSystem: true
|
|
39
63
|
},
|
|
40
64
|
cms_editor: {
|
|
@@ -89,7 +113,8 @@ export function invalidateRbacCache(userId) {
|
|
|
89
113
|
else _userPermCache.clear();
|
|
90
114
|
}
|
|
91
115
|
function safeParseArray(raw) {
|
|
92
|
-
if (Array.isArray(raw))
|
|
116
|
+
if (Array.isArray(raw))
|
|
117
|
+
return raw.filter((v) => typeof v === "string" && v.length > 0);
|
|
93
118
|
if (typeof raw !== "string" || !raw.trim()) return [];
|
|
94
119
|
try {
|
|
95
120
|
const parsed = JSON.parse(raw);
|
|
@@ -298,7 +323,11 @@ export async function upsertRole(event, input) {
|
|
|
298
323
|
const actor = await requirePermission(event, "roles:manage");
|
|
299
324
|
const roleId = input.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g, "");
|
|
300
325
|
if (!roleId) {
|
|
301
|
-
throw createError({
|
|
326
|
+
throw createError({
|
|
327
|
+
statusCode: 400,
|
|
328
|
+
statusMessage: "Bad Request",
|
|
329
|
+
message: "Invalid role id."
|
|
330
|
+
});
|
|
302
331
|
}
|
|
303
332
|
if (roleId === "super") {
|
|
304
333
|
throw createError({
|
|
@@ -321,7 +350,10 @@ export async function upsertRole(event, input) {
|
|
|
321
350
|
}
|
|
322
351
|
const db = getD1Binding(event);
|
|
323
352
|
if (!db) {
|
|
324
|
-
throw createError({
|
|
353
|
+
throw createError({
|
|
354
|
+
statusCode: 500,
|
|
355
|
+
message: "D1 database binding is required to save roles."
|
|
356
|
+
});
|
|
325
357
|
}
|
|
326
358
|
await ensureRbacTables(db, event);
|
|
327
359
|
const roleTbl = resolveTableName("role", event);
|
|
@@ -374,7 +406,9 @@ export async function deleteRole(event, roleId) {
|
|
|
374
406
|
}
|
|
375
407
|
export async function setUserPermissions(event, targetUserId, input) {
|
|
376
408
|
const actor = await requirePermission(event, "roles:manage");
|
|
377
|
-
const extraRoles = Array.from(
|
|
409
|
+
const extraRoles = Array.from(
|
|
410
|
+
new Set((input.extraRoles || []).map((r) => r.trim()).filter(Boolean))
|
|
411
|
+
);
|
|
378
412
|
const allow = Array.from(new Set((input.allow || []).map((p) => p.trim()).filter(Boolean)));
|
|
379
413
|
const deny = Array.from(new Set((input.deny || []).map((p) => p.trim()).filter(Boolean)));
|
|
380
414
|
if (extraRoles.includes("super")) {
|