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,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GET /__qarpeo/rbac/me
|
|
3
3
|
*
|
|
4
|
-
* Returns the current authenticated user's resolved roles, effective role
|
|
5
|
-
*
|
|
4
|
+
* Returns the current authenticated user's resolved roles, effective role permissions, and per-user
|
|
5
|
+
* `allow` / `deny` overrides for client UI checks (`useCan`).
|
|
6
6
|
*/
|
|
7
7
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
8
8
|
authenticated: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DELETE /__qarpeo/rbac/roles?id=<roleId>
|
|
3
3
|
*
|
|
4
|
-
* Deletes a custom role or resets an overridden built-in role back to code defaults.
|
|
5
|
-
*
|
|
4
|
+
* Deletes a custom role or resets an overridden built-in role back to code defaults. Requires
|
|
5
|
+
* `roles:manage` (or `super`).
|
|
6
6
|
*/
|
|
7
7
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
8
8
|
reset: boolean;
|
|
@@ -5,7 +5,11 @@ export default defineEventHandler(async (event) => {
|
|
|
5
5
|
const body = await readBody(event).catch(() => ({}));
|
|
6
6
|
const roleId = typeof qs?.id === "string" && qs.id.trim() || typeof body?.id === "string" && body.id.trim() || "";
|
|
7
7
|
if (!roleId) {
|
|
8
|
-
throw createError({
|
|
8
|
+
throw createError({
|
|
9
|
+
statusCode: 400,
|
|
10
|
+
statusMessage: "Bad Request",
|
|
11
|
+
message: "role id is required."
|
|
12
|
+
});
|
|
9
13
|
}
|
|
10
14
|
const result = await deleteRole(event, roleId);
|
|
11
15
|
return { ok: true, id: roleId, ...result };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GET /__qarpeo/rbac/roles
|
|
3
3
|
*
|
|
4
|
-
* Lists all built-in + D1-overridden + custom roles and the standard permission catalog.
|
|
5
|
-
*
|
|
4
|
+
* Lists all built-in + D1-overridden + custom roles and the standard permission catalog. Requires
|
|
5
|
+
* `roles:manage` (or `super`).
|
|
6
6
|
*/
|
|
7
7
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
8
8
|
ok: boolean;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler } from "nuxt/server";
|
|
2
|
-
import {
|
|
3
|
-
listRoles,
|
|
4
|
-
PERMISSION_CATALOG,
|
|
5
|
-
requirePermission
|
|
6
|
-
} from "../../../utils/rbac.mjs";
|
|
2
|
+
import { listRoles, PERMISSION_CATALOG, requirePermission } from "../../../utils/rbac.mjs";
|
|
7
3
|
export default defineEventHandler(async (event) => {
|
|
8
4
|
await requirePermission(event, "roles:manage");
|
|
9
5
|
const roles = await listRoles(event);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* POST /__qarpeo/rbac/roles
|
|
3
3
|
*
|
|
4
|
-
* Creates or updates a role's permissions in D1.
|
|
5
|
-
*
|
|
4
|
+
* Creates or updates a role's permissions in D1. Requires `roles:manage` (or `super`). `super`
|
|
5
|
+
* itself is immutable.
|
|
6
6
|
*/
|
|
7
7
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
8
8
|
ok: boolean;
|
|
@@ -4,7 +4,11 @@ export default defineEventHandler(async (event) => {
|
|
|
4
4
|
const body = await readBody(event).catch(() => ({}));
|
|
5
5
|
const id = typeof body?.id === "string" ? body.id.trim() : "";
|
|
6
6
|
if (!id) {
|
|
7
|
-
throw createError({
|
|
7
|
+
throw createError({
|
|
8
|
+
statusCode: 400,
|
|
9
|
+
statusMessage: "Bad Request",
|
|
10
|
+
message: "role id is required."
|
|
11
|
+
});
|
|
8
12
|
}
|
|
9
13
|
const role = await upsertRole(event, {
|
|
10
14
|
id,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* POST /__qarpeo/rbac/users
|
|
3
3
|
*
|
|
4
|
-
* Updates per-user `extraRoles`, `allow`, and `deny` permission overrides in D1.
|
|
5
|
-
*
|
|
4
|
+
* Updates per-user `extraRoles`, `allow`, and `deny` permission overrides in D1. Requires
|
|
5
|
+
* `roles:manage` (or `super`).
|
|
6
6
|
*/
|
|
7
7
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
8
8
|
userId: string;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineEventHandler,
|
|
3
|
-
getRouterParam,
|
|
4
|
-
readBody,
|
|
5
|
-
createError
|
|
6
|
-
} from "nuxt/server";
|
|
1
|
+
import { defineEventHandler, getRouterParam, readBody, createError } from "nuxt/server";
|
|
7
2
|
import { useAgent, resolveAgentInstanceId } from "../../../utils/ai.mjs";
|
|
8
3
|
import { getQarpeoConfig } from "../../../utils/config.mjs";
|
|
9
4
|
import { getAuthSession } from "../../../utils/session.mjs";
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineEventHandler,
|
|
3
|
-
getRouterParam,
|
|
4
|
-
readBody,
|
|
5
|
-
createError
|
|
6
|
-
} from "nuxt/server";
|
|
1
|
+
import { defineEventHandler, getRouterParam, readBody, createError } from "nuxt/server";
|
|
7
2
|
import { useAgent, resolveAgentInstanceId } from "../../../utils/ai.mjs";
|
|
8
3
|
import { getQarpeoConfig } from "../../../utils/config.mjs";
|
|
9
4
|
import { getAuthSession } from "../../../utils/session.mjs";
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineEventHandler,
|
|
3
|
-
getRouterParam,
|
|
4
|
-
getQuery,
|
|
5
|
-
createError
|
|
6
|
-
} from "nuxt/server";
|
|
1
|
+
import { defineEventHandler, getRouterParam, getQuery, createError } from "nuxt/server";
|
|
7
2
|
import { useAgent, resolveAgentInstanceId } from "../../../utils/ai.mjs";
|
|
8
3
|
import { getQarpeoConfig } from "../../../utils/config.mjs";
|
|
9
4
|
import { getAuthSession } from "../../../utils/session.mjs";
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
2
|
import { getD1Binding } from "../../../../db.mjs";
|
|
3
3
|
import { decryptToken } from "../../../utils/crypto.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
requireAuthSession,
|
|
6
|
+
revokeOtherDeviceSessions,
|
|
7
|
+
setAuthSession
|
|
8
|
+
} from "../../../utils/session.mjs";
|
|
5
9
|
import { resolveTableName } from "../../../utils/table-names.mjs";
|
|
6
10
|
import { verifyTOTPCode } from "../../../utils/totp.mjs";
|
|
7
11
|
export default defineEventHandler(async (event) => {
|
|
@@ -87,7 +87,13 @@ export default defineEventHandler(async (event) => {
|
|
|
87
87
|
INSERT INTO ${twoFactorTbl} (id, user_id, secret, backup_codes, enabled, created_at)
|
|
88
88
|
VALUES (?, ?, ?, ?, 1, ?)
|
|
89
89
|
ON CONFLICT(user_id) DO UPDATE SET secret = excluded.secret, backup_codes = excluded.backup_codes, enabled = 1
|
|
90
|
-
`).bind(
|
|
90
|
+
`).bind(
|
|
91
|
+
id,
|
|
92
|
+
user.id,
|
|
93
|
+
await encryptToken(secret, event),
|
|
94
|
+
JSON.stringify(hashedBackupCodes),
|
|
95
|
+
now
|
|
96
|
+
).run();
|
|
91
97
|
try {
|
|
92
98
|
const kv = getKVBinding("KV", event);
|
|
93
99
|
await kv.delete(`2fa:setup:${user.id}`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
2
|
import { getQarpeoConfig } from "../../../utils/config.mjs";
|
|
3
3
|
import { sendMagicLink } from "../../../utils/passwordless.mjs";
|
|
4
|
-
import { requireTurnstile } from "../../../utils/turnstile.mjs";
|
|
5
4
|
import { assertRateLimit, getClientIp } from "../../../utils/ratelimit.mjs";
|
|
5
|
+
import { requireTurnstile } from "../../../utils/turnstile.mjs";
|
|
6
6
|
export default defineEventHandler(async (event) => {
|
|
7
7
|
const body = await readBody(event);
|
|
8
8
|
const email = body?.email;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
2
|
import { getQarpeoConfig } from "../../../utils/config.mjs";
|
|
3
3
|
import { sendOTPCode } from "../../../utils/passwordless.mjs";
|
|
4
|
-
import { requireTurnstile } from "../../../utils/turnstile.mjs";
|
|
5
4
|
import { assertRateLimit, getClientIp } from "../../../utils/ratelimit.mjs";
|
|
5
|
+
import { requireTurnstile } from "../../../utils/turnstile.mjs";
|
|
6
6
|
export default defineEventHandler(async (event) => {
|
|
7
7
|
const body = await readBody(event);
|
|
8
8
|
const email = body?.email;
|
|
@@ -64,18 +64,14 @@ export default defineEventHandler(async (event) => {
|
|
|
64
64
|
try {
|
|
65
65
|
const ftsQuery = buildFtsQuery(q, "AND");
|
|
66
66
|
if (ftsQuery) {
|
|
67
|
-
const ftsRes = await db.prepare(
|
|
68
|
-
`SELECT id FROM ${ftsTbl} WHERE ${ftsTbl} MATCH ? ORDER BY rank LIMIT 100`
|
|
69
|
-
).bind(ftsQuery).all();
|
|
67
|
+
const ftsRes = await db.prepare(`SELECT id FROM ${ftsTbl} WHERE ${ftsTbl} MATCH ? ORDER BY rank LIMIT 100`).bind(ftsQuery).all();
|
|
70
68
|
const ids = (ftsRes.results || []).map((r) => r.id).filter(Boolean);
|
|
71
69
|
if (ids.length > 0) {
|
|
72
70
|
ftsMatchedIds = ids;
|
|
73
71
|
} else {
|
|
74
72
|
const ftsOrQuery = buildFtsQuery(q, "OR");
|
|
75
73
|
if (ftsOrQuery && ftsOrQuery !== ftsQuery) {
|
|
76
|
-
const orRes = await db.prepare(
|
|
77
|
-
`SELECT id FROM ${ftsTbl} WHERE ${ftsTbl} MATCH ? ORDER BY rank LIMIT 100`
|
|
78
|
-
).bind(ftsOrQuery).all();
|
|
74
|
+
const orRes = await db.prepare(`SELECT id FROM ${ftsTbl} WHERE ${ftsTbl} MATCH ? ORDER BY rank LIMIT 100`).bind(ftsOrQuery).all();
|
|
79
75
|
const orIds = (orRes.results || []).map((r) => r.id).filter(Boolean);
|
|
80
76
|
if (orIds.length > 0) {
|
|
81
77
|
ftsMatchedIds = orIds;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getRouterParam, readBody } from "nuxt/server";
|
|
2
|
-
import {
|
|
3
|
-
getComment,
|
|
4
|
-
reportComment
|
|
5
|
-
} from "../../../utils/comments.mjs";
|
|
2
|
+
import { getComment, reportComment } from "../../../utils/comments.mjs";
|
|
6
3
|
import { getAuthContext } from "../../../utils/context.mjs";
|
|
7
4
|
import { assertRateLimit } from "../../../utils/ratelimit.mjs";
|
|
8
5
|
const ALLOWED_REASONS = [
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getRouterParam, readBody } from "nuxt/server";
|
|
2
|
-
import {
|
|
3
|
-
getComment,
|
|
4
|
-
updateCommentStatus
|
|
5
|
-
} from "../../utils/comments.mjs";
|
|
2
|
+
import { getComment, updateCommentStatus } from "../../utils/comments.mjs";
|
|
6
3
|
import { getAuthContext } from "../../utils/context.mjs";
|
|
7
4
|
import { getTenant } from "../../utils/tenant.mjs";
|
|
8
5
|
export default defineEventHandler(async (event) => {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { createError, defineEventHandler, readBody } from "nuxt/server";
|
|
2
|
-
import {
|
|
3
|
-
batchModerateComments
|
|
4
|
-
} from "../../utils/comments.mjs";
|
|
2
|
+
import { batchModerateComments } from "../../utils/comments.mjs";
|
|
5
3
|
import { getAuthContext } from "../../utils/context.mjs";
|
|
6
4
|
const ALLOWED_ACTIONS = ["approve", "spam", "delete"];
|
|
7
5
|
export default defineEventHandler(async (event) => {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { createError, defineEventHandler, readBody } from "nuxt/server";
|
|
2
|
-
import {
|
|
3
|
-
createComment,
|
|
4
|
-
validateTargetUrn,
|
|
5
|
-
getCommentsConfig
|
|
6
|
-
} from "../../utils/comments.mjs";
|
|
2
|
+
import { createComment, validateTargetUrn, getCommentsConfig } from "../../utils/comments.mjs";
|
|
7
3
|
import { getAuthContext } from "../../utils/context.mjs";
|
|
8
4
|
import { getTenant } from "../../utils/tenant.mjs";
|
|
9
5
|
export default defineEventHandler(async (event) => {
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
createError,
|
|
6
6
|
useRuntimeConfig
|
|
7
7
|
} from "nuxt/server";
|
|
8
|
-
import { getAuthSession } from "../utils/session.mjs";
|
|
9
8
|
import { fateViews } from "#qarpeo/fate/views";
|
|
9
|
+
import { getAuthSession } from "../utils/session.mjs";
|
|
10
10
|
let _fateHandler;
|
|
11
11
|
async function getFateHandler() {
|
|
12
12
|
if (_fateHandler) return _fateHandler;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getQuery, getRequestHeader, readBody } from "nuxt/server";
|
|
2
2
|
import { getQarpeoConfig } from "../../utils/config.mjs";
|
|
3
3
|
import { timingSafeEqualString } from "../../utils/crypto.mjs";
|
|
4
|
-
import { sanitizeUrl } from "../../utils/string.mjs";
|
|
5
4
|
import {
|
|
6
5
|
recordEmailBounce,
|
|
7
6
|
recordEmailClick,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
recordSoftBounce,
|
|
10
9
|
suppressEmail
|
|
11
10
|
} from "../../utils/mail.mjs";
|
|
11
|
+
import { sanitizeUrl } from "../../utils/string.mjs";
|
|
12
12
|
export default defineEventHandler(async (event) => {
|
|
13
13
|
const mailConfig = getQarpeoConfig(event).mail || {};
|
|
14
14
|
const webhookSecret = mailConfig.webhookSecret || globalThis.process?.env?.QARPEO_MAIL_WEBHOOK_SECRET;
|
|
@@ -105,7 +105,8 @@ export default defineEventHandler(async (event) => {
|
|
|
105
105
|
`;
|
|
106
106
|
if (img.title) entry += ` <image:title>${escapeXml(img.title)}</image:title>
|
|
107
107
|
`;
|
|
108
|
-
if (img.caption)
|
|
108
|
+
if (img.caption)
|
|
109
|
+
entry += ` <image:caption>${escapeXml(img.caption)}</image:caption>
|
|
109
110
|
`;
|
|
110
111
|
entry += ` </image:image>
|
|
111
112
|
`;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* POST /api/storage/presigned-r2
|
|
3
3
|
*
|
|
4
|
-
* Generates a **true R2 presigned URL** so the client can PUT a file directly to
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* native R2 presigned URL instead.
|
|
4
|
+
* Generates a **true R2 presigned URL** so the client can PUT a file directly to Cloudflare R2
|
|
5
|
+
* without routing the bytes through the Worker. The endpoint mirrors the security model of
|
|
6
|
+
* `presigned.post.ts` (HMAC-ticket) but returns a native R2 presigned URL instead.
|
|
8
7
|
*
|
|
9
|
-
* Body: { pathname: string, contentType?: string, expiresIn?: string | number }
|
|
10
|
-
*
|
|
8
|
+
* Body: { pathname: string, contentType?: string, expiresIn?: string | number } Response: { url:
|
|
9
|
+
* string, key: string, expiresAt: number }
|
|
11
10
|
*/
|
|
12
11
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
13
12
|
url: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from "nuxt/server";
|
|
2
|
+
import { createBlob } from "../../../blob.mjs";
|
|
2
3
|
import { getAuthContext } from "../../utils/context.mjs";
|
|
3
4
|
import { getStorageConfig } from "../../utils/storage.mjs";
|
|
4
|
-
import { createBlob } from "../../../blob.mjs";
|
|
5
5
|
export default defineEventHandler(async (event) => {
|
|
6
6
|
const config = getStorageConfig(event);
|
|
7
7
|
const body = await readBody(event) || {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler, getRouterParam, createError } from "nuxt/server";
|
|
2
|
+
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
2
3
|
import {
|
|
3
4
|
resolveStoreCart,
|
|
4
5
|
removeStoreCartItem,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
getStoreCart,
|
|
7
8
|
storeCartItemTbl
|
|
8
9
|
} from "../../../../utils/store/index.mjs";
|
|
9
|
-
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
10
10
|
export default defineEventHandler(async (event) => {
|
|
11
11
|
const itemId = getRouterParam(event, "id");
|
|
12
12
|
if (!itemId) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, getRouterParam, createError } from "nuxt/server";
|
|
2
|
+
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
2
3
|
import {
|
|
3
4
|
resolveStoreCart,
|
|
4
5
|
updateStoreCartItem,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
getStoreCart,
|
|
7
8
|
storeCartItemTbl
|
|
8
9
|
} from "../../../../utils/store/index.mjs";
|
|
9
|
-
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
10
10
|
export default defineEventHandler(async (event) => {
|
|
11
11
|
const itemId = getRouterParam(event, "id");
|
|
12
12
|
if (!itemId) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler } from "nuxt/server";
|
|
2
|
-
import {
|
|
3
|
-
SUPPORTED_STORE_CURRENCIES,
|
|
4
|
-
DEFAULT_STORE_RATES
|
|
5
|
-
} from "../../utils/store-localization.mjs";
|
|
2
|
+
import { SUPPORTED_STORE_CURRENCIES, DEFAULT_STORE_RATES } from "../../utils/store-localization.mjs";
|
|
6
3
|
export default defineEventHandler((_event) => {
|
|
7
4
|
return {
|
|
8
5
|
currencies: Object.values(SUPPORTED_STORE_CURRENCIES).map((c) => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineEventHandler, getRouterParam, createError } from "nuxt/server";
|
|
2
|
-
import { getStoreOrder } from "../../../utils/store/index.mjs";
|
|
3
2
|
import { getAuthContext } from "../../../utils/context.mjs";
|
|
3
|
+
import { getStoreOrder } from "../../../utils/store/index.mjs";
|
|
4
4
|
import { getTenant } from "../../../utils/tenant.mjs";
|
|
5
5
|
export default defineEventHandler(async (event) => {
|
|
6
6
|
const id = getRouterParam(event, "id");
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
defineEventHandler,
|
|
3
|
+
getRouterParam,
|
|
4
|
+
getQuery,
|
|
5
|
+
createError,
|
|
6
|
+
sendRedirect
|
|
7
|
+
} from "nuxt/server";
|
|
4
8
|
import { getCloudflareEnv } from "../../../../../bindings.mjs";
|
|
9
|
+
import { verifyHmacSha256 } from "../../../../utils/crypto.mjs";
|
|
10
|
+
import { storeOrderItemTbl, storeOrderTbl } from "../../../../utils/store/index.mjs";
|
|
5
11
|
export default defineEventHandler(async (event) => {
|
|
6
12
|
const token = getRouterParam(event, "token");
|
|
7
13
|
if (!token) {
|
|
@@ -11,7 +17,10 @@ export default defineEventHandler(async (event) => {
|
|
|
11
17
|
const expires = Number(query.expires);
|
|
12
18
|
const sig = typeof query.sig === "string" ? query.sig : "";
|
|
13
19
|
if (!expires || Number.isNaN(expires) || !sig) {
|
|
14
|
-
throw createError({
|
|
20
|
+
throw createError({
|
|
21
|
+
statusCode: 400,
|
|
22
|
+
statusMessage: "Signed expiration and signature are required."
|
|
23
|
+
});
|
|
15
24
|
}
|
|
16
25
|
if (Date.now() > expires) {
|
|
17
26
|
throw createError({ statusCode: 410, statusMessage: "Download link has expired." });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineEventHandler, getQuery, createError } from "nuxt/server";
|
|
2
|
-
import { queryStoreOrders } from "../../../utils/store/index.mjs";
|
|
3
2
|
import { getAuthContext } from "../../../utils/context.mjs";
|
|
3
|
+
import { queryStoreOrders } from "../../../utils/store/index.mjs";
|
|
4
4
|
import { getTenant } from "../../../utils/tenant.mjs";
|
|
5
5
|
export default defineEventHandler(async (event) => {
|
|
6
6
|
const auth = await getAuthContext(event).catch(() => null);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* POST /api/store/tax/calculate
|
|
3
3
|
*
|
|
4
|
-
* Body: { subtotal: number, country: string, state?: string, vatNumber?: string, isDigital?:
|
|
4
|
+
* Body: { subtotal: number, country: string, state?: string, vatNumber?: string, isDigital?:
|
|
5
|
+
* boolean, shippingTotal?: number }
|
|
5
6
|
*
|
|
6
7
|
* Returns StoreTaxResult with breakdown.
|
|
7
8
|
*/
|
|
@@ -3,13 +3,22 @@ import { calculateStoreTax } from "../../../utils/store-localization.mjs";
|
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
4
|
const body = await readBody(event).catch(() => null);
|
|
5
5
|
if (typeof body?.subtotal !== "number" || typeof body?.country !== "string") {
|
|
6
|
-
throw createError({
|
|
6
|
+
throw createError({
|
|
7
|
+
statusCode: 400,
|
|
8
|
+
statusMessage: "subtotal (number) and country (string) are required"
|
|
9
|
+
});
|
|
7
10
|
}
|
|
8
11
|
if (body.subtotal < 0 || !Number.isFinite(body.subtotal)) {
|
|
9
|
-
throw createError({
|
|
12
|
+
throw createError({
|
|
13
|
+
statusCode: 400,
|
|
14
|
+
statusMessage: "subtotal must be a positive finite number"
|
|
15
|
+
});
|
|
10
16
|
}
|
|
11
17
|
if (body.shippingTotal !== void 0 && (body.shippingTotal < 0 || !Number.isFinite(body.shippingTotal))) {
|
|
12
|
-
throw createError({
|
|
18
|
+
throw createError({
|
|
19
|
+
statusCode: 400,
|
|
20
|
+
statusMessage: "shippingTotal must be a positive finite number"
|
|
21
|
+
});
|
|
13
22
|
}
|
|
14
23
|
const cleanCountry = body.country.trim().toUpperCase();
|
|
15
24
|
if (!cleanCountry || !/^[A-Z]{2,3}$/.test(cleanCountry)) {
|
|
@@ -23,7 +23,10 @@ export default defineEventHandler(async (event) => {
|
|
|
23
23
|
}
|
|
24
24
|
const tenant = await getTenantById(domainRecord.tenantId, event) || await getTenantBySlug(domainRecord.tenantId, event);
|
|
25
25
|
if (!tenant || tenant.id !== tenantParam && tenant.slug !== tenantParam) {
|
|
26
|
-
throw createError({
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: 403,
|
|
28
|
+
message: "Tenant mismatch: domain does not belong to this tenant."
|
|
29
|
+
});
|
|
27
30
|
}
|
|
28
31
|
if (tenant.organizationId) {
|
|
29
32
|
try {
|
|
@@ -23,7 +23,10 @@ export default defineEventHandler(async (event) => {
|
|
|
23
23
|
}
|
|
24
24
|
const tenant = await getTenantById(domainRecord.tenantId, event) || await getTenantBySlug(domainRecord.tenantId, event);
|
|
25
25
|
if (!tenant || tenant.id !== tenantParam && tenant.slug !== tenantParam) {
|
|
26
|
-
throw createError({
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: 403,
|
|
28
|
+
message: "Tenant mismatch: domain does not belong to this tenant."
|
|
29
|
+
});
|
|
27
30
|
}
|
|
28
31
|
if (tenant.organizationId) {
|
|
29
32
|
try {
|
|
@@ -2,7 +2,7 @@ import "#qarpeo/agents-registry";
|
|
|
2
2
|
import "#qarpeo/tools-registry";
|
|
3
3
|
import type { RequestEvent } from "nuxt/server";
|
|
4
4
|
import type { AgentDefinition, AgentMessage, AgentTool, StreamTextOptions, GenerateObjectOptions, GenerateObjectResult, DurableObjectStub, GenerateImageOptions, GenerateImageResult, GenerateSpeechOptions, GenerateSpeechResult, TranscribeAudioInput, TranscribeAudioOptions, TranscribeAudioResult } from "../../../types";
|
|
5
|
-
export type { GenerateObjectOptions, GenerateObjectResult
|
|
5
|
+
export type { GenerateObjectOptions, GenerateObjectResult } from "../../../types";
|
|
6
6
|
/** Registers an agent definition in the shared server runtime registry. */
|
|
7
7
|
export declare function registerAgentDefinition(definition: AgentDefinition): void;
|
|
8
8
|
/** Retrieves a registered agent definition by its unique name. */
|
|
@@ -10,9 +10,8 @@ export declare function getAgentDefinition(name: string): AgentDefinition | unde
|
|
|
10
10
|
/** Retrieves all currently registered agent definitions. */
|
|
11
11
|
export declare function getAllAgentDefinitions(): AgentDefinition[];
|
|
12
12
|
/**
|
|
13
|
-
* Registers a named tool into the shared server-side global tool registry.
|
|
14
|
-
*
|
|
15
|
-
* every export found in `server/tools/`.
|
|
13
|
+
* Registers a named tool into the shared server-side global tool registry. Called automatically by
|
|
14
|
+
* the generated `#qarpeo/tools-registry` module for every export found in `server/tools/`.
|
|
16
15
|
*/
|
|
17
16
|
export declare function registerGlobalTool(name: string, tool: AgentTool): void;
|
|
18
17
|
/**
|
|
@@ -23,8 +22,8 @@ export declare function registerGlobalTool(name: string, tool: AgentTool): void;
|
|
|
23
22
|
*/
|
|
24
23
|
export declare function getGlobalTool(name: string): AgentTool | undefined;
|
|
25
24
|
/**
|
|
26
|
-
* Retrieves all tools registered in the global tool registry (from `server/tools/`).
|
|
27
|
-
*
|
|
25
|
+
* Retrieves all tools registered in the global tool registry (from `server/tools/`). Useful for
|
|
26
|
+
* passing all shared tools to an agent definition.
|
|
28
27
|
*
|
|
29
28
|
* @example
|
|
30
29
|
* export default defineAgent({
|
|
@@ -81,6 +80,7 @@ export interface ExtractedToolCall {
|
|
|
81
80
|
export declare function normalizeTools(toolsInput?: Record<string, AgentTool> | AgentTool[]): Map<string, AgentTool>;
|
|
82
81
|
/**
|
|
83
82
|
* Robustly parses tool calls from Workers AI responses, JSON schemas, or tool payloads. Supports:
|
|
83
|
+
*
|
|
84
84
|
* 1. Workers AI / OpenAI native tool_calls array
|
|
85
85
|
* 2. Llama 3.1/3.3 <tool_call> tags
|
|
86
86
|
* 3. Markdown ```json code blocks
|
|
@@ -134,19 +134,19 @@ export declare function resolveAiGateway(optsGateway?: {
|
|
|
134
134
|
cacheTtl?: number;
|
|
135
135
|
} | undefined;
|
|
136
136
|
/**
|
|
137
|
-
* Safely resolves the namespaced Durable Object instance ID for an agent session.
|
|
138
|
-
*
|
|
139
|
-
*
|
|
137
|
+
* Safely resolves the namespaced Durable Object instance ID for an agent session. Enforces strict
|
|
138
|
+
* user isolation: authenticated users are locked to their own `usr_<userId>__` namespace,
|
|
139
|
+
* preventing cross-user session enumeration or hijacking.
|
|
140
140
|
*/
|
|
141
141
|
export declare function resolveAgentInstanceId(userId?: string | null, rawId?: unknown): string;
|
|
142
142
|
/**
|
|
143
143
|
* Accesses an Edge AI Agent backed by Cloudflare Durable Objects.
|
|
144
144
|
*
|
|
145
145
|
* @example
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
146
|
+
* ```ts
|
|
147
|
+
* const agent = useAgent("support", "user_123")
|
|
148
|
+
* const res = await agent.chat("How do I reset my password?")
|
|
149
|
+
* ```
|
|
150
150
|
*/
|
|
151
151
|
export declare function useAgent(agentName: string, id?: string, event?: RequestEvent): UseAgentReturn;
|
|
152
152
|
/**
|
|
@@ -174,43 +174,46 @@ export declare function similaritySearch(indexName: string, query: string, optio
|
|
|
174
174
|
/** Detects whether an input schema is a Zod schema. */
|
|
175
175
|
export declare function isZodSchema(schema: any): boolean;
|
|
176
176
|
/**
|
|
177
|
-
* Converts a Zod schema or plain JSON schema into a valid JSON Schema object
|
|
178
|
-
*
|
|
177
|
+
* Converts a Zod schema or plain JSON schema into a valid JSON Schema object suitable for
|
|
178
|
+
* Cloudflare Workers AI constrained decoding (response_format).
|
|
179
179
|
*/
|
|
180
180
|
export declare function schemaToJsonSchema(schema: any): Record<string, any>;
|
|
181
181
|
/**
|
|
182
|
-
* Robustly extracts and parses a JSON object or array from a model response string.
|
|
183
|
-
*
|
|
182
|
+
* Robustly extracts and parses a JSON object or array from a model response string. Strips markdown
|
|
183
|
+
* code fences (`json ... `) and handles leading/trailing prose.
|
|
184
184
|
*/
|
|
185
185
|
export declare function extractJsonObject(input: any): any;
|
|
186
186
|
/**
|
|
187
|
-
* Synthesizes a valid default mock object conforming to a JSON Schema.
|
|
188
|
-
*
|
|
187
|
+
* Synthesizes a valid default mock object conforming to a JSON Schema. Used during local
|
|
188
|
+
* development and testing when no Cloudflare AI token is present.
|
|
189
189
|
*/
|
|
190
190
|
export declare function synthesizeMockFromSchema(jsonSchema: Record<string, any>): any;
|
|
191
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Generate a complete text response using Cloudflare Workers AI with optional autonomous tool
|
|
193
|
+
* calling.
|
|
194
|
+
*/
|
|
192
195
|
export declare function generateText(options: StreamTextOptions): Promise<string>;
|
|
193
196
|
/**
|
|
194
|
-
* Generates a structured, strongly-typed JSON object using Cloudflare Workers AI
|
|
195
|
-
*
|
|
197
|
+
* Generates a structured, strongly-typed JSON object using Cloudflare Workers AI constrained
|
|
198
|
+
* decoding (JSON schema) and schema validation.
|
|
196
199
|
*
|
|
197
200
|
* Supports Zod schemas (`z.object({...})`) or plain JSON schemas.
|
|
198
201
|
*
|
|
199
202
|
* @example
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* import { z } from "zod"
|
|
205
|
+
* import { ai } from "qarpeo/server"
|
|
203
206
|
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
207
|
+
* const profile = await ai.generateObject({
|
|
208
|
+
* prompt: "Extract user info: Alice Smith, 29 years old, loves hiking and photography",
|
|
209
|
+
* schema: z.object({
|
|
210
|
+
* name: z.string(),
|
|
211
|
+
* age: z.number(),
|
|
212
|
+
* interests: z.array(z.string()),
|
|
213
|
+
* }),
|
|
214
|
+
* })
|
|
215
|
+
* console.log(profile.object.name) // "Alice Smith"
|
|
216
|
+
* ```
|
|
214
217
|
*/
|
|
215
218
|
export declare function generateObject<T = any>(options: GenerateObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
216
219
|
/** Stream text directly via Server-Sent Events using Cloudflare Workers AI. */
|