qarpeo 0.4.13 → 0.4.15
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 +197 -191
- 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 +5451 -5249
- 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 +52 -36
- package/dist/runtime/app/composables/store.mjs +70 -11
- 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/products/index.get.mjs +2 -0
- 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/vendor.d.ts +11 -1
- package/dist/runtime/server/utils/store/vendor.mjs +47 -0
- 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/store.d.ts +7 -0
- 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 +31 -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/overridable-routes.d.ts +12 -0
- 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
|
@@ -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. */
|
|
@@ -5,13 +5,12 @@ import { getAIBinding } from "../../ai.mjs";
|
|
|
5
5
|
import { getCloudflareEnv } from "../../bindings.mjs";
|
|
6
6
|
import { getR2Binding } from "../../blob.mjs";
|
|
7
7
|
import { getVectorizeBinding } from "../../vectorize.mjs";
|
|
8
|
-
const GLOBAL_AGENT_REGISTRY_KEY = "__qarpeo_agent_registry__";
|
|
9
8
|
function getAgentRegistry() {
|
|
10
9
|
const g = globalThis;
|
|
11
|
-
if (!g
|
|
12
|
-
g
|
|
10
|
+
if (!g.__qarpeo_agent_registry__) {
|
|
11
|
+
g.__qarpeo_agent_registry__ = /* @__PURE__ */ new Map();
|
|
13
12
|
}
|
|
14
|
-
return g
|
|
13
|
+
return g.__qarpeo_agent_registry__;
|
|
15
14
|
}
|
|
16
15
|
export function registerAgentDefinition(definition) {
|
|
17
16
|
if (definition && definition.name) {
|
|
@@ -24,13 +23,12 @@ export function getAgentDefinition(name) {
|
|
|
24
23
|
export function getAllAgentDefinitions() {
|
|
25
24
|
return Array.from(getAgentRegistry().values());
|
|
26
25
|
}
|
|
27
|
-
const GLOBAL_TOOL_REGISTRY_KEY = "__qarpeo_tool_registry__";
|
|
28
26
|
function getToolRegistry() {
|
|
29
27
|
const g = globalThis;
|
|
30
|
-
if (!g
|
|
31
|
-
g
|
|
28
|
+
if (!g.__qarpeo_tool_registry__) {
|
|
29
|
+
g.__qarpeo_tool_registry__ = /* @__PURE__ */ new Map();
|
|
32
30
|
}
|
|
33
|
-
return g
|
|
31
|
+
return g.__qarpeo_tool_registry__;
|
|
34
32
|
}
|
|
35
33
|
export function registerGlobalTool(name, tool) {
|
|
36
34
|
if (name && tool) {
|
|
@@ -283,9 +281,7 @@ export async function similaritySearch(indexName, query, options) {
|
|
|
283
281
|
return results.matches || [];
|
|
284
282
|
}
|
|
285
283
|
export function isZodSchema(schema) {
|
|
286
|
-
return Boolean(
|
|
287
|
-
schema && typeof schema === "object" && typeof schema.safeParse === "function"
|
|
288
|
-
);
|
|
284
|
+
return Boolean(schema && typeof schema === "object" && typeof schema.safeParse === "function");
|
|
289
285
|
}
|
|
290
286
|
export function schemaToJsonSchema(schema) {
|
|
291
287
|
if (!schema) {
|
|
@@ -56,9 +56,9 @@ export interface AnalyticsDashboard {
|
|
|
56
56
|
* schema written by `trackPageview()` / `trackEvent()`.
|
|
57
57
|
*
|
|
58
58
|
* @example
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const dash = useAnalyticsDashboard({ accountId, apiToken, dataset: "analytics-prod" })
|
|
61
|
+
* const { total, series } = await dash.pageviews("7d")
|
|
62
|
+
* ```
|
|
63
63
|
*/
|
|
64
64
|
export declare function useAnalyticsDashboard(options?: DashboardOptions): AnalyticsDashboard;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RequestEvent } from "nuxt/server";
|
|
2
2
|
export { type QarpeoRole, getRoleFromEnv } from "./role-env";
|
|
3
|
-
import { type QarpeoRole } from "./role-env";
|
|
4
3
|
import type { QarpeoSession } from "../../types/auth";
|
|
4
|
+
import { type QarpeoRole } from "./role-env";
|
|
5
5
|
/**
|
|
6
6
|
* Returns a memoized Better Auth instance connected to Cloudflare D1 via Drizzle. The instance is
|
|
7
7
|
* cached by secret value within the isolate lifetime to avoid re-initialising plugins, adapters and
|
|
@@ -14,24 +14,24 @@ export declare function serverAuth(event?: RequestEvent): any;
|
|
|
14
14
|
export declare const createAuth: typeof serverAuth;
|
|
15
15
|
export declare const useServerAuth: typeof serverAuth;
|
|
16
16
|
/**
|
|
17
|
-
* Fetches the current session from Better Auth on the server.
|
|
18
|
-
*
|
|
17
|
+
* Fetches the current session from Better Auth on the server. Returns null if the request is
|
|
18
|
+
* unauthenticated.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const session = await getServerSession(event)
|
|
23
|
+
* if (session) console.log("User:", session.user.email)
|
|
24
|
+
* ```
|
|
25
25
|
*/
|
|
26
26
|
export declare function getServerSession(event: RequestEvent): Promise<QarpeoSession | null>;
|
|
27
27
|
/**
|
|
28
28
|
* Enforces authenticated server session. Throws HTTP 401 if user is unauthenticated.
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const session = await requireServerSession(event)
|
|
33
|
+
* // session.user is guaranteed to exist
|
|
34
|
+
* ```
|
|
35
35
|
*/
|
|
36
36
|
export declare function requireServerSession(event: RequestEvent): Promise<QarpeoSession>;
|
|
37
37
|
/** Ensures Better Auth core tables (user, account, session, verification, etc.) exist in D1. */
|
|
@@ -94,6 +94,7 @@ export declare function resolveMfaStatus(d1: any, user: {
|
|
|
94
94
|
}>;
|
|
95
95
|
/**
|
|
96
96
|
* Role tiers recognized by Qarpeo role resolution:
|
|
97
|
+
*
|
|
97
98
|
* - 'super': Full system & tenant control, owner of the instance
|
|
98
99
|
* - 'admin': Administrative operations (content, users, settings)
|
|
99
100
|
* - 'moderator': Moderation capabilities (comments, reviews, submissions)
|
|
@@ -111,25 +112,24 @@ export interface ResolveUserRoleResult {
|
|
|
111
112
|
user?: any | null;
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
114
|
-
* Preflight utility to inspect user registration status and suggested role before creating an
|
|
115
|
+
* Preflight utility to inspect user registration status and suggested role before creating an
|
|
116
|
+
* account.
|
|
115
117
|
*
|
|
116
|
-
* Informs developers whether the email already exists in D1 and what role it maps to
|
|
117
|
-
*
|
|
118
|
+
* Informs developers whether the email already exists in D1 and what role it maps to according to
|
|
119
|
+
* environment configuration (QARPEO_*_EMAILS).
|
|
118
120
|
*
|
|
119
|
-
* Developers retain full programmatic control over role assignment and user creation.
|
|
120
|
-
*
|
|
121
|
+
* Developers retain full programmatic control over role assignment and user creation. Supports both
|
|
122
|
+
* `(event, email)` (standard Nuxt/Nitro convention) and `(email, event?)`.
|
|
121
123
|
*
|
|
122
124
|
* @example
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* const { exists, suggestedRole } = await resolveUserRole(event, email)
|
|
127
|
+
* if (!exists) {
|
|
128
|
+
* await createUser({ email, role: suggestedRole })
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
129
131
|
*/
|
|
130
132
|
export declare function resolveUserRole(event: RequestEvent, email: string): Promise<ResolveUserRoleResult>;
|
|
131
133
|
export declare function resolveUserRole(email: string, event?: RequestEvent): Promise<ResolveUserRoleResult>;
|
|
132
|
-
/**
|
|
133
|
-
* Alias for resolveUserRole.
|
|
134
|
-
*/
|
|
134
|
+
/** Alias for resolveUserRole. */
|
|
135
135
|
export declare const checkIfExistsBeforeCreate: typeof resolveUserRole;
|
|
@@ -4,10 +4,10 @@ import { hashPassword, verifyPassword } from "better-auth/crypto";
|
|
|
4
4
|
import { createError } from "nuxt/server";
|
|
5
5
|
import * as authSchema from "#qarpeo/auth/schema";
|
|
6
6
|
export { getRoleFromEnv } from "./role-env.mjs";
|
|
7
|
-
import { getRoleFromEnv as getRoleFromEnv2 } from "./role-env.mjs";
|
|
8
7
|
import { getSessionSecret } from "./config.mjs";
|
|
9
8
|
import { useDrizzle } from "./drizzle.mjs";
|
|
10
9
|
import { detectHashType, verifyLegacyPassword } from "./legacy-hash.mjs";
|
|
10
|
+
import { getRoleFromEnv as getRoleFromEnv2 } from "./role-env.mjs";
|
|
11
11
|
import { resolveTableName, resolveIndexName } from "./table-names.mjs";
|
|
12
12
|
const _authCache = /* @__PURE__ */ new Map();
|
|
13
13
|
export function serverAuth(event) {
|
|
@@ -282,12 +282,24 @@ export async function ensureAuthTables(d1, event) {
|
|
|
282
282
|
)
|
|
283
283
|
`),
|
|
284
284
|
// Secondary indexes for hot paths
|
|
285
|
-
d1.prepare(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
d1.prepare(
|
|
289
|
-
|
|
290
|
-
|
|
285
|
+
d1.prepare(
|
|
286
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(sessionTbl, "user_id")} ON ${sessionTbl}(user_id)`
|
|
287
|
+
),
|
|
288
|
+
d1.prepare(
|
|
289
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(sessionTbl, "token")} ON ${sessionTbl}(token)`
|
|
290
|
+
),
|
|
291
|
+
d1.prepare(
|
|
292
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(sessionTbl, "expires_at")} ON ${sessionTbl}(expires_at)`
|
|
293
|
+
),
|
|
294
|
+
d1.prepare(
|
|
295
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(accountTbl, "user_id")} ON ${accountTbl}(user_id)`
|
|
296
|
+
),
|
|
297
|
+
d1.prepare(
|
|
298
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(memberTbl, "user_id")} ON ${memberTbl}(user_id)`
|
|
299
|
+
),
|
|
300
|
+
d1.prepare(
|
|
301
|
+
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(memberTbl, "org_id")} ON ${memberTbl}(organization_id)`
|
|
302
|
+
),
|
|
291
303
|
d1.prepare(
|
|
292
304
|
`CREATE INDEX IF NOT EXISTS ${resolveIndexName(apiTokenTbl, "user_id")} ON ${apiTokenTbl}(user_id)`
|
|
293
305
|
),
|
|
@@ -603,7 +615,9 @@ export async function resolveUserRole(arg1, arg2) {
|
|
|
603
615
|
const bindingName = globalThis.process?.env?.QARPEO_DEFAULT_DB_BINDING || event?.context?.cloudflare?.env?.QARPEO_DEFAULT_DB_BINDING || "DB";
|
|
604
616
|
const d1 = getD1Binding(bindingName, event);
|
|
605
617
|
if (d1) {
|
|
606
|
-
const existingUser = await d1.prepare(
|
|
618
|
+
const existingUser = await d1.prepare(
|
|
619
|
+
`SELECT * FROM ${resolveTableName("user", event)} WHERE LOWER(email) = LOWER(?) LIMIT 1`
|
|
620
|
+
).bind(normalizedEmail).first();
|
|
607
621
|
if (existingUser) {
|
|
608
622
|
exists = true;
|
|
609
623
|
currentRole = existingUser.role ? String(existingUser.role) : "user";
|
|
@@ -27,12 +27,12 @@ export declare function sendWhatsAppMessage(accessToken: string, phoneNumberId:
|
|
|
27
27
|
* Agents (`useAgent()`).
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* // server/routes/bot/telegram.post.ts
|
|
32
|
+
* export default defineBotHandler({
|
|
33
|
+
* provider: "telegram",
|
|
34
|
+
* agent: "support", // Auto-pilot: forwarded to agent, reply sent to user
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare function defineBotHandler<TPayload = any>(config: BotHandlerConfig<TPayload>): EventHandler;
|
|
@@ -155,13 +155,12 @@ export interface PdfResult {
|
|
|
155
155
|
/** Whether this was produced by the dev-mode mock (no real browser). */
|
|
156
156
|
mock?: boolean;
|
|
157
157
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Detects whether a string target is inline HTML rather than a URL.
|
|
160
|
-
*/
|
|
158
|
+
/** Detects whether a string target is inline HTML rather than a URL. */
|
|
161
159
|
export declare function isHtmlTarget(input: string): boolean;
|
|
162
160
|
/**
|
|
163
161
|
* Validates a browser target URL against Server-Side Request Forgery (SSRF) and protocol injection.
|
|
164
|
-
* Throws 400 Bad Request if the target URL is invalid, uses a forbidden scheme, or points to
|
|
162
|
+
* Throws 400 Bad Request if the target URL is invalid, uses a forbidden scheme, or points to
|
|
163
|
+
* private/internal networks.
|
|
165
164
|
*/
|
|
166
165
|
export declare function assertSafeBrowserUrl(url: string): URL;
|
|
167
166
|
/**
|
|
@@ -206,15 +205,15 @@ export declare function crawlPage(startUrl: string, options?: CrawlOptions): Pro
|
|
|
206
205
|
* using headless browser rendering.
|
|
207
206
|
*
|
|
208
207
|
* @example
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
208
|
+
* ```ts
|
|
209
|
+
* const { data, contentType } = await renderOgSocialCard({
|
|
210
|
+
* title: "Building Microservices on Cloudflare",
|
|
211
|
+
* description: "Fast RPC, Durable Objects, and Vectorize on the Edge",
|
|
212
|
+
* siteName: "Qarpeo",
|
|
213
|
+
* theme: "dark",
|
|
214
|
+
* })
|
|
215
|
+
* return new Response(data, { headers: { "Content-Type": contentType } })
|
|
216
|
+
* ```
|
|
218
217
|
*/
|
|
219
218
|
export declare function renderOgSocialCard(options: OgSocialCardOptions): Promise<ScreenshotResult>;
|
|
220
219
|
/**
|
|
@@ -222,19 +221,19 @@ export declare function renderOgSocialCard(options: OgSocialCardOptions): Promis
|
|
|
222
221
|
* Rendering.
|
|
223
222
|
*
|
|
224
223
|
* @example
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* const { data } = await generateInvoicePdf({
|
|
226
|
+
* invoiceNumber: "INV-2026-0042",
|
|
227
|
+
* issueDate: "2026-11-11",
|
|
228
|
+
* seller: { name: "Acme Cloud Corp", email: "billing@acme.com" },
|
|
229
|
+
* customer: { name: "Client Studios", email: "finance@client.com" },
|
|
230
|
+
* items: [
|
|
231
|
+
* { description: "Edge Compute (Million Requests)", quantity: 50, unitPrice: 0.5 },
|
|
232
|
+
* { description: "Vectorize Storage (GB/mo)", quantity: 10, unitPrice: 5 },
|
|
233
|
+
* ],
|
|
234
|
+
* currency: "$",
|
|
235
|
+
* taxPercent: 10,
|
|
236
|
+
* })
|
|
237
|
+
* ```
|
|
239
238
|
*/
|
|
240
239
|
export declare function generateInvoicePdf(options: GenerateInvoiceOptions): Promise<PdfResult>;
|
|
@@ -25,36 +25,36 @@ export declare function purgeCache(pattern?: string): Promise<string[]>;
|
|
|
25
25
|
* Purge all cache items associated with one or more semantic cache tags.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* await purgeCacheTag("posts", "author:123")
|
|
30
|
+
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare function purgeCacheTag(...tags: string[]): Promise<string[]>;
|
|
33
33
|
/**
|
|
34
|
-
* Factory pattern: define a reusable cached function backed by Cloudflare KV / edge cache.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Factory pattern: define a reusable cached function backed by Cloudflare KV / edge cache. Matches
|
|
35
|
+
* Nitro's `defineCachedFunction` convention with enhanced support for human duration strings ('5m',
|
|
36
|
+
* '1h', '7d'), SWR windows, and semantic tags.
|
|
37
37
|
*
|
|
38
38
|
* @example
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* export const getStats = defineCachedFunction(fetchStats, {
|
|
41
|
+
* key: "dashboard:stats",
|
|
42
|
+
* maxAge: 60 * 5,
|
|
43
|
+
* })
|
|
44
|
+
* const stats = await getStats()
|
|
45
|
+
* ```
|
|
46
46
|
*/
|
|
47
47
|
export declare function defineCachedFunction<T, Args extends any[] = any[]>(fn: (...args: Args) => Promise<T> | T, options?: CachedFunctionOptions<Args>): (...args: Args) => Promise<T>;
|
|
48
48
|
/**
|
|
49
|
-
* Inline execution: fetch and cache data immediately, or retrieve fresh from cache.
|
|
50
|
-
*
|
|
49
|
+
* Inline execution: fetch and cache data immediately, or retrieve fresh from cache. Supports inline
|
|
50
|
+
* key/options/fetcher calls or fetcher-first options.
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* // Direct inline execution:
|
|
55
|
+
* const stats = await rememberCache("stats", { maxAge: "5m" }, fetchStats)
|
|
56
|
+
* const user = await rememberCache("user:123", "1h", () => fetchUser(123))
|
|
57
|
+
* ```
|
|
58
58
|
*/
|
|
59
59
|
export declare function rememberCache<T>(key: string, ttlOrOptions: number | string | RememberCacheOptions, fetcher: () => Promise<T> | T): Promise<T>;
|
|
60
60
|
export declare function rememberCache<T>(key: string, fetcher: () => Promise<T> | T, ttlOrOptions?: number | string | RememberCacheOptions): Promise<T>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { createError } from "nuxt/server";
|
|
2
2
|
import { getKVBinding } from "../../../kv.mjs";
|
|
3
|
-
import {
|
|
4
|
-
getCMSDb,
|
|
5
|
-
getCMSConfig,
|
|
6
|
-
getCMSTenantPrefix,
|
|
7
|
-
cmsCollectionTbl
|
|
8
|
-
} from "./common.mjs";
|
|
3
|
+
import { getCMSDb, getCMSConfig, getCMSTenantPrefix, cmsCollectionTbl } from "./common.mjs";
|
|
9
4
|
import { ensureCMSSynced } from "./sync.mjs";
|
|
10
5
|
export function rowToCollection(row, config) {
|
|
11
6
|
let fields;
|
|
@@ -49,6 +49,7 @@ export function getCMSConfig(event) {
|
|
|
49
49
|
comments: cfg.comments || { autoApprove: false },
|
|
50
50
|
revisions: cfg.revisions || { max: 10 },
|
|
51
51
|
cache: cfg.cache !== false,
|
|
52
|
+
editor: cfg.editor ?? false,
|
|
52
53
|
collections: cfg.collections || {},
|
|
53
54
|
components: cfg.components || {},
|
|
54
55
|
sources: cfg.sources || [],
|
|
@@ -2,8 +2,8 @@ import { type RequestEvent } from "nuxt/server";
|
|
|
2
2
|
/** Parses markdown to Comark AST document ({ nodes, frontmatter, meta }). */
|
|
3
3
|
export declare function parseMarkdownAST(md: string, event?: RequestEvent): Promise<any>;
|
|
4
4
|
/**
|
|
5
|
-
* Strips active scripting elements and event handlers from rendered HTML
|
|
6
|
-
*
|
|
5
|
+
* Strips active scripting elements and event handlers from rendered HTML to prevent stored XSS
|
|
6
|
+
* attacks when rendered via v-html.
|
|
7
7
|
*/
|
|
8
8
|
export declare function sanitizeHtml(html: string): string;
|
|
9
9
|
/** Parses markdown and renders to both AST and HTML in a single pass. */
|
|
@@ -2,10 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { useRuntimeConfig } from "nuxt/server";
|
|
3
3
|
import { getQarpeoConfig } from "../config.mjs";
|
|
4
4
|
function _requireComark() {
|
|
5
|
-
return Promise.all([
|
|
6
|
-
import("comark"),
|
|
7
|
-
import("comark/render")
|
|
8
|
-
]).then(([comarkMod, renderMod]) => ({
|
|
5
|
+
return Promise.all([import("comark"), import("comark/render")]).then(([comarkMod, renderMod]) => ({
|
|
9
6
|
parseMarkdown: comarkMod.parseMarkdown,
|
|
10
7
|
render: renderMod.render
|
|
11
8
|
})).catch(() => {
|
|
@@ -68,7 +65,10 @@ export async function parseMarkdownAST(md, event) {
|
|
|
68
65
|
}
|
|
69
66
|
export function sanitizeHtml(html) {
|
|
70
67
|
if (!html) return "";
|
|
71
|
-
return html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, "").replace(/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi, "").replace(/<embed\b[^>]*>/gi, "").replace(/<applet\b[^<]*(?:(?!<\/applet>)<[^<]*)*<\/applet>/gi, "").replace(/<meta\b[^>]*>/gi, "").replace(/<base\b[^>]*>/gi, "").replace(/<form\b[^<]*(?:(?!<\/form>)<[^<]*)*<\/form>/gi, "").replace(/\s+on[a-zA-Z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(
|
|
68
|
+
return html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, "").replace(/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi, "").replace(/<embed\b[^>]*>/gi, "").replace(/<applet\b[^<]*(?:(?!<\/applet>)<[^<]*)*<\/applet>/gi, "").replace(/<meta\b[^>]*>/gi, "").replace(/<base\b[^>]*>/gi, "").replace(/<form\b[^<]*(?:(?!<\/form>)<[^<]*)*<\/form>/gi, "").replace(/\s+on[a-zA-Z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(
|
|
69
|
+
/(href|src|formaction)\s*=\s*["']?\s*(?:javascript|vbscript|data(?!\s*:\s*image)):[^"'>\s]*/gi,
|
|
70
|
+
'$1="#"'
|
|
71
|
+
);
|
|
72
72
|
}
|
|
73
73
|
export async function processMarkdown(md, event) {
|
|
74
74
|
if (!md) return { ast: { nodes: [], frontmatter: {}, meta: {} }, html: "" };
|
|
@@ -132,11 +132,7 @@ export async function createCMSEntry(event, collectionId, data) {
|
|
|
132
132
|
entry.contentHash = gitResult.contentHash || null;
|
|
133
133
|
entry.source = "file";
|
|
134
134
|
}
|
|
135
|
-
await invalidateCMSEntryCache(
|
|
136
|
-
event,
|
|
137
|
-
collectionId,
|
|
138
|
-
[slug, entry.id].filter(Boolean)
|
|
139
|
-
);
|
|
135
|
+
await invalidateCMSEntryCache(event, collectionId, [slug, entry.id].filter(Boolean));
|
|
140
136
|
await syncCMSEntryTags(event, null, data.tags ?? null).catch(() => {
|
|
141
137
|
});
|
|
142
138
|
fireCMSWebhooks(getCMSConfig(event), collectionId, "create", entry).catch(console.warn);
|
|
@@ -260,12 +256,9 @@ export async function updateCMSEntry(event, entryId, data) {
|
|
|
260
256
|
await invalidateCMSEntryCache(
|
|
261
257
|
event,
|
|
262
258
|
updatedEntry.collectionId,
|
|
263
|
-
[
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
existing.slug,
|
|
267
|
-
existing.id
|
|
268
|
-
].filter(Boolean)
|
|
259
|
+
[updatedEntry.slug, updatedEntry.id, existing.slug, existing.id].filter(
|
|
260
|
+
Boolean
|
|
261
|
+
)
|
|
269
262
|
);
|
|
270
263
|
await syncCMSEntryTags(
|
|
271
264
|
event,
|
|
@@ -417,12 +410,9 @@ export async function publishCMSEntry(event, entryId, targetStatus, targetPublis
|
|
|
417
410
|
await invalidateCMSEntryCache(
|
|
418
411
|
event,
|
|
419
412
|
collectionId,
|
|
420
|
-
[
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
existing.slug,
|
|
424
|
-
existing.id
|
|
425
|
-
].filter(Boolean)
|
|
413
|
+
[updated.slug, updated.id, existing.slug, existing.id].filter(
|
|
414
|
+
Boolean
|
|
415
|
+
)
|
|
426
416
|
);
|
|
427
417
|
await syncEntryToGit(
|
|
428
418
|
event,
|
|
@@ -464,12 +454,7 @@ export async function publishDueScheduledEntries(event) {
|
|
|
464
454
|
await invalidateCMSEntryCache(
|
|
465
455
|
event,
|
|
466
456
|
collectionId,
|
|
467
|
-
[
|
|
468
|
-
entry.slug,
|
|
469
|
-
entry.id,
|
|
470
|
-
row.slug,
|
|
471
|
-
row.id
|
|
472
|
-
].filter(Boolean)
|
|
457
|
+
[entry.slug, entry.id, row.slug, row.id].filter(Boolean)
|
|
473
458
|
);
|
|
474
459
|
await syncEntryToGit(event, collectionId, entry, "publish").catch(console.warn);
|
|
475
460
|
fireCMSWebhooks(config, collectionId, "publish", entry).catch(console.warn);
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { getCookie } from "nuxt/server";
|
|
2
|
-
import { getAuthContext } from "../context.mjs";
|
|
3
|
-
import { getCMSDb, getCMSConfig, getCMSTenantId, cmsEntryTbl } from "./common.mjs";
|
|
4
|
-
import { parseMarkdownAST } from "./markdown.mjs";
|
|
5
|
-
import { verifyPreviewToken } from "./preview.mjs";
|
|
6
2
|
import {
|
|
7
3
|
projectCMSEntry,
|
|
8
4
|
ensureCMSSynced,
|
|
@@ -10,6 +6,10 @@ import {
|
|
|
10
6
|
listCMSCollections,
|
|
11
7
|
queryCMSEntries
|
|
12
8
|
} from "../cms.mjs";
|
|
9
|
+
import { getAuthContext } from "../context.mjs";
|
|
10
|
+
import { getCMSDb, getCMSConfig, getCMSTenantId, cmsEntryTbl } from "./common.mjs";
|
|
11
|
+
import { parseMarkdownAST } from "./markdown.mjs";
|
|
12
|
+
import { verifyPreviewToken } from "./preview.mjs";
|
|
13
13
|
export async function getCMSEntryByPath(event, collectionId, path, locale, options = {}) {
|
|
14
14
|
await ensureCMSSynced(event);
|
|
15
15
|
const db = getCMSDb(event);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CMSHeadingLink } from "../../../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Asserts that a CMS slug is safe and valid:
|
|
4
|
+
*
|
|
4
5
|
* - Must be a non-empty string <= 256 chars
|
|
5
6
|
* - Cannot start or end with slash or dot
|
|
6
7
|
* - Cannot contain backslashes, directory traversal (".."), or control characters
|