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
|
@@ -147,9 +147,7 @@ export class InMemorySqlStorage {
|
|
|
147
147
|
filteredRows = filteredRows.slice(0, limitVal);
|
|
148
148
|
}
|
|
149
149
|
if (/COUNT\s*\(\s*\*\s*\)/i.test(selectFields)) {
|
|
150
|
-
const countRows = [
|
|
151
|
-
{ "count(*)": filteredRows.length, count: filteredRows.length }
|
|
152
|
-
];
|
|
150
|
+
const countRows = [{ "count(*)": filteredRows.length, count: filteredRows.length }];
|
|
153
151
|
return new InMemorySqlStorageCursor(countRows, ["count"], rowsRead, 0);
|
|
154
152
|
}
|
|
155
153
|
let resultRows;
|
|
@@ -173,9 +171,7 @@ export class InMemorySqlStorage {
|
|
|
173
171
|
return new InMemorySqlStorageCursor([], [], 0, 0);
|
|
174
172
|
}
|
|
175
173
|
if (upper.startsWith("UPDATE")) {
|
|
176
|
-
const match = trimmed.match(
|
|
177
|
-
/UPDATE\s+([^\s]+)\s+SET\s+([\s\S]+?)(?:\s+WHERE\s+([\s\S]+))?$/i
|
|
178
|
-
);
|
|
174
|
+
const match = trimmed.match(/UPDATE\s+([^\s]+)\s+SET\s+([\s\S]+?)(?:\s+WHERE\s+([\s\S]+))?$/i);
|
|
179
175
|
if (match) {
|
|
180
176
|
const tableName = match[1].replace(/["`]/g, "").trim().toLowerCase();
|
|
181
177
|
const setClause = match[2].trim();
|
|
@@ -503,10 +499,7 @@ async function dispatchHttpRpc(instance, request) {
|
|
|
503
499
|
const result = await instance[methodName](...args);
|
|
504
500
|
return Response.json({ success: true, result });
|
|
505
501
|
} catch (err) {
|
|
506
|
-
return Response.json(
|
|
507
|
-
{ success: false, error: err?.message || String(err) },
|
|
508
|
-
{ status: 500 }
|
|
509
|
-
);
|
|
502
|
+
return Response.json({ success: false, error: err?.message || String(err) }, { status: 500 });
|
|
510
503
|
}
|
|
511
504
|
}
|
|
512
505
|
function createSimulatedNamespace(bindingNameOrClass) {
|
|
@@ -3,27 +3,27 @@ import type { InboundEmailContext, InboundEmailHandler } from "../../types/email
|
|
|
3
3
|
* Defines an inbound email handler for Cloudflare Email Workers.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* ```ts [server/email/incoming.ts]
|
|
7
|
+
* export default defineEmailHandler(async ({ message, forward, reply }) => {
|
|
8
8
|
* console.log("From:", message.from)
|
|
9
9
|
* console.log("Subject:", message.headers.get("subject"))
|
|
10
10
|
* const text = await message.text()
|
|
11
11
|
*
|
|
12
12
|
* if (message.from.endsWith("@spam.com")) {
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* message.setReject("Spam not accepted")
|
|
14
|
+
* return
|
|
15
15
|
* }
|
|
16
16
|
*
|
|
17
17
|
* await reply({
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* subject: "Received your message",
|
|
19
|
+
* text: "Thank you for contacting us!",
|
|
20
20
|
* })
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
23
|
*/
|
|
24
24
|
export declare function defineEmailHandler(handler: InboundEmailHandler): InboundEmailHandler;
|
|
25
25
|
/**
|
|
26
|
-
* Wraps raw Cloudflare `ForwardableEmailMessage` (or a mock/simulated message)
|
|
27
|
-
*
|
|
26
|
+
* Wraps raw Cloudflare `ForwardableEmailMessage` (or a mock/simulated message) into a typed,
|
|
27
|
+
* convenient InboundEmailContext.
|
|
28
28
|
*/
|
|
29
29
|
export declare function createInboundEmailContext(rawMessage: any, env?: any, ctx?: any): InboundEmailContext;
|
|
@@ -5,9 +5,9 @@ import type { QarpeoUser } from "../../types/auth";
|
|
|
5
5
|
* The admin's original identity is preserved in `session.impersonator`.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { user } = await startImpersonation(event, targetUserId)
|
|
10
|
+
* ```
|
|
11
11
|
*/
|
|
12
12
|
export declare function startImpersonation(event: RequestEvent, targetUserId: string): Promise<{
|
|
13
13
|
success: boolean;
|
|
@@ -17,9 +17,9 @@ export declare function startImpersonation(event: RequestEvent, targetUserId: st
|
|
|
17
17
|
* Stops impersonation and restores the admin's original identity.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const { user } = await stopImpersonation(event)
|
|
22
|
+
* ```
|
|
23
23
|
*/
|
|
24
24
|
export declare function stopImpersonation(event: RequestEvent): Promise<{
|
|
25
25
|
success: boolean;
|
|
@@ -30,12 +30,12 @@ export declare function stopImpersonation(event: RequestEvent): Promise<{
|
|
|
30
30
|
* the SHA-256 hash is stored.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const { token, id } = await createApiToken(event, {
|
|
35
|
+
* name: "CLI Token",
|
|
36
|
+
* scopes: ["read", "write"],
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
39
|
*/
|
|
40
40
|
export declare function createApiToken(event: RequestEvent, input: {
|
|
41
41
|
name: string;
|
|
@@ -67,9 +67,9 @@ export declare function revokeApiToken(event: RequestEvent, tokenId: string): Pr
|
|
|
67
67
|
* token metadata if valid; throws 401 if invalid/expired.
|
|
68
68
|
*
|
|
69
69
|
* @example
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const { user, scopes } = await verifyApiToken(event, rawToken)
|
|
72
|
+
* ```
|
|
73
73
|
*/
|
|
74
74
|
export declare function verifyApiToken(event: RequestEvent, rawToken: string): Promise<{
|
|
75
75
|
user: QarpeoUser;
|
|
@@ -84,9 +84,9 @@ export declare function hasApiTokenScope(scopes: string[], required: string): bo
|
|
|
84
84
|
* no/invalid token. Returns the verified token context.
|
|
85
85
|
*
|
|
86
86
|
* @example
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* const { user, scopes } = await requireApiToken(event, { scope: "read:files" })
|
|
89
|
+
* ```
|
|
90
90
|
*/
|
|
91
91
|
export declare function requireApiToken(event: RequestEvent, options?: {
|
|
92
92
|
scope?: string;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Legacy password hash verification helpers for migrating users from other auth systems.
|
|
3
3
|
*
|
|
4
|
-
* Better Auth uses `scrypt` (via `@noble/hashes/scrypt`) for all new hashes. This module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Better Auth uses `scrypt` (via `@noble/hashes/scrypt`) for all new hashes. This module provides
|
|
5
|
+
* pure-Web-Crypto / pure-JS fallbacks to verify passwords stored in older formats so that users can
|
|
6
|
+
* log in with their existing password, which is then transparently re-hashed to scrypt on
|
|
7
|
+
* successful verification.
|
|
8
8
|
*
|
|
9
9
|
* Supported legacy formats:
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
*
|
|
11
|
+
* - Bcrypt — `$2a$`, `$2b$`, `$2x$`, `$2y$` prefix (requires `bcryptjs` dev dep)
|
|
12
|
+
* - Django PBKDF2-SHA256 — `pbkdf2_sha256$<iterations>$<salt>$<hash>` format (pure Web Crypto)
|
|
13
|
+
* - SHA-1 — 40-char hex (plain SHA-1, common in very old Rails / PHP apps)
|
|
14
|
+
* - MD5 — 32-char hex (plain MD5 — not supported, Web Crypto lacks MD5)
|
|
14
15
|
*
|
|
15
16
|
* Usage in `defineQarpeoAuth`:
|
|
17
|
+
*
|
|
16
18
|
* ```ts
|
|
17
19
|
* emailAndPassword: {
|
|
18
20
|
* verifyLegacyPassword: async (password, hash) => {
|
|
@@ -21,43 +23,37 @@
|
|
|
21
23
|
* }
|
|
22
24
|
* ```
|
|
23
25
|
*/
|
|
24
|
-
/**
|
|
25
|
-
* Returns true if `hash` looks like a bcrypt hash (`$2a$`, `$2b$`, `$2x$`, `$2y$`).
|
|
26
|
-
*/
|
|
26
|
+
/** Returns true if `hash` looks like a bcrypt hash (`$2a$`, `$2b$`, `$2x$`, `$2y$`). */
|
|
27
27
|
export declare function isBcryptHash(hash: string): boolean;
|
|
28
28
|
/**
|
|
29
29
|
* Verifies a password against a bcrypt hash using `bcryptjs` (pure JS, works on CF Workers).
|
|
30
|
-
* Returns `false` if `bcryptjs` is not installed — install it as a dev dependency and add it
|
|
31
|
-
*
|
|
30
|
+
* Returns `false` if `bcryptjs` is not installed — install it as a dev dependency and add it to
|
|
31
|
+
* `optimizeDeps.include` / `noExternal` if needed.
|
|
32
32
|
*/
|
|
33
33
|
export declare function verifyBcrypt(password: string, hash: string): Promise<boolean>;
|
|
34
34
|
/**
|
|
35
|
-
* Returns true if `hash` is a Django-style PBKDF2-SHA256 hash.
|
|
36
|
-
*
|
|
35
|
+
* Returns true if `hash` is a Django-style PBKDF2-SHA256 hash. Format:
|
|
36
|
+
* `pbkdf2_sha256$<iterations>$<salt>$<hash_base64>`
|
|
37
37
|
*/
|
|
38
38
|
export declare function isDjangoPbkdf2Hash(hash: string): boolean;
|
|
39
39
|
/**
|
|
40
|
-
* Verifies a password against a Django PBKDF2-SHA256 hash using the Web Crypto API.
|
|
41
|
-
*
|
|
40
|
+
* Verifies a password against a Django PBKDF2-SHA256 hash using the Web Crypto API. This works
|
|
41
|
+
* without any external library on Cloudflare Workers.
|
|
42
42
|
*/
|
|
43
43
|
export declare function verifyDjangoPbkdf2(password: string, hash: string): Promise<boolean>;
|
|
44
|
-
/**
|
|
45
|
-
* Returns true if `hash` looks like a plain 40-char hex SHA-1 digest.
|
|
46
|
-
*/
|
|
44
|
+
/** Returns true if `hash` looks like a plain 40-char hex SHA-1 digest. */
|
|
47
45
|
export declare function isSha1Hash(hash: string): boolean;
|
|
48
46
|
/**
|
|
49
|
-
* Verifies a password against a plain SHA-1 hex hash using Web Crypto.
|
|
50
|
-
*
|
|
47
|
+
* Verifies a password against a plain SHA-1 hex hash using Web Crypto. Note: SHA-1 is
|
|
48
|
+
* cryptographically broken — this is provided only for migration.
|
|
51
49
|
*/
|
|
52
50
|
export declare function verifySha1(password: string, hash: string): Promise<boolean>;
|
|
53
51
|
export type LegacyHashType = "bcrypt" | "pbkdf2_sha256" | "sha1" | "unknown";
|
|
54
|
-
/**
|
|
55
|
-
* Detects the hash type from the hash string.
|
|
56
|
-
*/
|
|
52
|
+
/** Detects the hash type from the hash string. */
|
|
57
53
|
export declare function detectHashType(hash: string): LegacyHashType;
|
|
58
54
|
/**
|
|
59
|
-
* Verifies a password against any supported legacy hash format.
|
|
60
|
-
*
|
|
55
|
+
* Verifies a password against any supported legacy hash format. Returns `{ valid: boolean; type:
|
|
56
|
+
* LegacyHashType }`.
|
|
61
57
|
*
|
|
62
58
|
* Use this inside `verifyLegacyPassword` callback in `defineQarpeoAuth` options:
|
|
63
59
|
*
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import type { CFEvent } from "../../types/index";
|
|
2
2
|
export interface LockOptions {
|
|
3
3
|
/**
|
|
4
|
-
* Time-to-live for the lock, e.g. "5 minutes", "30 seconds", or milliseconds.
|
|
5
|
-
*
|
|
4
|
+
* Time-to-live for the lock, e.g. "5 minutes", "30 seconds", or milliseconds. Prevents deadlocks
|
|
5
|
+
* if the isolate or worker terminates unexpectedly.
|
|
6
6
|
*
|
|
7
7
|
* @default "5 minutes" (300,000ms)
|
|
8
8
|
*/
|
|
9
9
|
ttl?: string | number;
|
|
10
|
-
/**
|
|
11
|
-
* Optional event context for resolving Cloudflare bindings.
|
|
12
|
-
*/
|
|
10
|
+
/** Optional event context for resolving Cloudflare bindings. */
|
|
13
11
|
event?: CFEvent;
|
|
14
|
-
/**
|
|
15
|
-
* Custom lock token (identifier of the lock holder). Defaults to random UUID.
|
|
16
|
-
*/
|
|
12
|
+
/** Custom lock token (identifier of the lock holder). Defaults to random UUID. */
|
|
17
13
|
token?: string;
|
|
18
14
|
/**
|
|
19
15
|
* Behavior when the lock cannot be acquired:
|
|
16
|
+
*
|
|
20
17
|
* - `"return"` (default): return null / false
|
|
21
18
|
* - `"throw"`: throw a LockConflictError
|
|
22
19
|
*/
|
|
@@ -50,32 +47,32 @@ export declare function acquireLock(key: string, options?: LockOptions): Promise
|
|
|
50
47
|
*/
|
|
51
48
|
export declare function releaseLock(key: string, token: string, event?: CFEvent): Promise<boolean>;
|
|
52
49
|
/**
|
|
53
|
-
* Runs an asynchronous callback within a distributed lock.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
50
|
+
* Runs an asynchronous callback within a distributed lock. Automatically acquires the lock before
|
|
51
|
+
* running and releases it afterwards, ensuring proper cleanup even if the callback throws an
|
|
52
|
+
* error.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const result = await withLock("sync-inventory", { ttl: "2 minutes" }, async () => {
|
|
57
|
+
* return await syncProductsFromShopify()
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
56
60
|
*
|
|
57
61
|
* @param key Unique lock resource key
|
|
58
62
|
* @param optionsOrCallback LockOptions or callback function
|
|
59
63
|
* @param maybeCallback Callback function when options are provided as second argument
|
|
60
64
|
* @returns Result of callback, or `null` if the lock could not be acquired
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* const result = await withLock("sync-inventory", { ttl: "2 minutes" }, async () => {
|
|
65
|
-
* return await syncProductsFromShopify()
|
|
66
|
-
* })
|
|
67
|
-
* ```
|
|
68
65
|
*/
|
|
69
66
|
export declare function withLock<T>(key: string, optionsOrCallback: LockOptions | (() => Promise<T> | T), maybeCallback?: () => Promise<T> | T): Promise<T | null>;
|
|
70
67
|
/**
|
|
71
68
|
* Convenience helper to run a database migration callback with an exclusive distributed lock.
|
|
72
69
|
*
|
|
73
70
|
* @example
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* await withMigrationLock("analytics", { ttl: "10m" }, async () => {
|
|
73
|
+
* await runDrizzleMigrations()
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
79
76
|
*/
|
|
80
77
|
export declare function withMigrationLock<T>(dbName: string, optionsOrCallback: LockOptions | (() => Promise<T> | T), maybeCallback?: () => Promise<T> | T): Promise<T | null>;
|
|
81
78
|
/** Clears all in-memory locks (used during test teardown). */
|
|
@@ -65,22 +65,22 @@ export declare function deliverMailDirect(options: {
|
|
|
65
65
|
* tracking, queue-backed delivery, and dev mailbox capture.
|
|
66
66
|
*
|
|
67
67
|
* @example
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* // Markdown content:
|
|
70
|
+
* await sendMail({
|
|
71
|
+
* to: "user@example.com",
|
|
72
|
+
* subject: "Welcome to Acme",
|
|
73
|
+
* markdown:
|
|
74
|
+
* "# Welcome!\nWe are glad you joined us.\n\n[btn: Go to Dashboard](https://myapp.com)",
|
|
75
|
+
* })
|
|
76
76
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
77
|
+
* // Template:
|
|
78
|
+
* await sendMail({
|
|
79
|
+
* to: "user@example.com",
|
|
80
|
+
* template: "welcome",
|
|
81
|
+
* data: { name: "Alice", actionUrl: "https://myapp.com/dashboard" },
|
|
82
|
+
* })
|
|
83
|
+
* ```
|
|
84
84
|
*/
|
|
85
85
|
export declare function sendMail(request: SendMailRequest, event?: RequestEvent): Promise<MailResult>;
|
|
86
86
|
export interface UseMailReturn {
|
|
@@ -93,10 +93,10 @@ export interface UseMailReturn {
|
|
|
93
93
|
* Access the Qarpeo Transactional Mail client.
|
|
94
94
|
*
|
|
95
95
|
* @example
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* const mail = useMail(event)
|
|
98
|
+
* await mail.send({ to: "user@example.com", subject: "Hello", text: "Welcome" })
|
|
99
|
+
* ```
|
|
100
100
|
*/
|
|
101
101
|
export declare function useMail(event?: RequestEvent): UseMailReturn;
|
|
102
102
|
export { suppressEmail, isEmailSuppressed, unsuppressEmail, listSuppressedEmails, recordSoftBounce, generateUnsubscribeToken, verifyUnsubscribeToken, buildListUnsubscribeHeaders, } from "./mail-suppression";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolveRuntimeBinding } from "../../bindings.mjs";
|
|
2
2
|
import { sendEmail } from "../../email.mjs";
|
|
3
3
|
import { useQueue } from "../../queue.mjs";
|
|
4
|
-
import { renderEmailTemplate, renderMarkdownEmail } from "./email-templates.mjs";
|
|
5
4
|
import { signHmacSha256 } from "./crypto.mjs";
|
|
5
|
+
import { renderEmailTemplate, renderMarkdownEmail } from "./email-templates.mjs";
|
|
6
6
|
import { buildListUnsubscribeHeaders, isEmailSuppressed } from "./mail-suppression.mjs";
|
|
7
7
|
function getSharedMailbox() {
|
|
8
8
|
return globalThis.__qarpeo_dev_mailbox__ ||= [];
|
|
@@ -52,7 +52,9 @@ export async function injectEmailTracking(html, options) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
for (const match of matches) {
|
|
55
|
-
const sig = await signHmacSha256(`${options.messageId}:${match.href}`, options.secret).catch(
|
|
55
|
+
const sig = await signHmacSha256(`${options.messageId}:${match.href}`, options.secret).catch(
|
|
56
|
+
() => ""
|
|
57
|
+
);
|
|
56
58
|
const sigParam = sig ? `&sig=${encodeURIComponent(sig)}` : "";
|
|
57
59
|
const trackUrl = `${base}/__qarpeo/mail/track/click/${encodeURIComponent(options.messageId)}?url=${encodeURIComponent(match.href)}${sigParam}`;
|
|
58
60
|
result = result.replace(match.full, `<a${match.prefix}href="${trackUrl}"${match.suffix}>`);
|
|
@@ -4,7 +4,7 @@ import type { McpServerDefinition, McpTool, McpClient, McpClientOptions } from "
|
|
|
4
4
|
* Converts Qarpeo AgentTool array or record to MCP tool descriptors.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
*
|
|
7
|
+
* const mcpTools = agentToolsToMcpTools({ search: defineTool({ ... }) })
|
|
8
8
|
*/
|
|
9
9
|
export declare function agentToolsToMcpTools(tools: Record<string, AgentTool> | AgentTool[] | undefined): McpTool[];
|
|
10
10
|
/**
|
|
@@ -13,31 +13,31 @@ export declare function agentToolsToMcpTools(tools: Record<string, AgentTool> |
|
|
|
13
13
|
* The returned handler can be used directly in a Nuxt server route:
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* // server/routes/mcp.post.ts
|
|
18
|
+
* export default defineMcpServer({
|
|
19
|
+
* name: "my-mcp",
|
|
20
|
+
* version: "1.0.0",
|
|
21
|
+
* tools: {
|
|
22
|
+
* search: defineTool({
|
|
23
|
+
* description: "Search the database",
|
|
24
|
+
* parameters: { type: "object", properties: { q: { type: "string" } } },
|
|
25
|
+
* execute: async ({ q }) => db.search(q),
|
|
26
|
+
* }),
|
|
27
|
+
* },
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
30
|
*/
|
|
31
31
|
export declare function defineMcpServer(definition: McpServerDefinition): (event: any) => Promise<Response>;
|
|
32
32
|
/**
|
|
33
33
|
* Creates a typed MCP client that sends JSON-RPC 2.0 requests to a remote MCP server.
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const client = createMcpClient("https://mcp.example.com/api/mcp")
|
|
38
|
+
* const tools = await client.getTools()
|
|
39
|
+
* const result = await client.callTool("search", { q: "hello" })
|
|
40
|
+
* ```
|
|
41
41
|
*/
|
|
42
42
|
export declare function createMcpClient(url: string, options?: McpClientOptions): McpClient;
|
|
43
43
|
/** Alias for {@link createMcpClient}. */
|
|
@@ -34,11 +34,7 @@ export function defineMcpServer(definition) {
|
|
|
34
34
|
allowed = false;
|
|
35
35
|
}
|
|
36
36
|
if (!allowed) {
|
|
37
|
-
const errBody = makeErrorResponse(
|
|
38
|
-
null,
|
|
39
|
-
-32001,
|
|
40
|
-
"Unauthorized"
|
|
41
|
-
);
|
|
37
|
+
const errBody = makeErrorResponse(null, -32001, "Unauthorized");
|
|
42
38
|
return new Response(JSON.stringify(errBody), {
|
|
43
39
|
status: 401,
|
|
44
40
|
headers: { "Content-Type": "application/json" }
|
|
@@ -85,19 +81,21 @@ export function defineMcpServer(definition) {
|
|
|
85
81
|
switch (method) {
|
|
86
82
|
// ── initialize ──────────────────────────────────────────────────────
|
|
87
83
|
case "initialize": {
|
|
88
|
-
return jsonRpc(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
return jsonRpc(
|
|
85
|
+
makeOkResponse(id, {
|
|
86
|
+
protocolVersion: "2024-11-05",
|
|
87
|
+
capabilities: {
|
|
88
|
+
tools: {},
|
|
89
|
+
resources: {},
|
|
90
|
+
prompts: {}
|
|
91
|
+
},
|
|
92
|
+
serverInfo: {
|
|
93
|
+
name: definition.name,
|
|
94
|
+
version: definition.version ?? "1.0.0"
|
|
95
|
+
},
|
|
96
|
+
...definition.instructions ? { instructions: definition.instructions } : {}
|
|
97
|
+
})
|
|
98
|
+
);
|
|
101
99
|
}
|
|
102
100
|
// ── tools/list ───────────────────────────────────────────────────────
|
|
103
101
|
case "tools/list": {
|
|
@@ -111,9 +109,7 @@ export function defineMcpServer(definition) {
|
|
|
111
109
|
const toolList = getAvailableTools(definition.tools);
|
|
112
110
|
const tool = toolList.find((t) => t.name === toolName);
|
|
113
111
|
if (!tool) {
|
|
114
|
-
return jsonRpc(
|
|
115
|
-
makeErrorResponse(id, -32602, `Tool not found: ${toolName}`)
|
|
116
|
-
);
|
|
112
|
+
return jsonRpc(makeErrorResponse(id, -32602, `Tool not found: ${toolName}`));
|
|
117
113
|
}
|
|
118
114
|
try {
|
|
119
115
|
const result = await tool.execute(toolArgs);
|
|
@@ -144,14 +140,10 @@ export function defineMcpServer(definition) {
|
|
|
144
140
|
const uri = params?.uri;
|
|
145
141
|
const resource = (definition.resources ?? []).find((r) => r.uri === uri);
|
|
146
142
|
if (!resource) {
|
|
147
|
-
return jsonRpc(
|
|
148
|
-
makeErrorResponse(id, -32602, `Resource not found: ${uri}`)
|
|
149
|
-
);
|
|
143
|
+
return jsonRpc(makeErrorResponse(id, -32602, `Resource not found: ${uri}`));
|
|
150
144
|
}
|
|
151
145
|
if (!resource.read) {
|
|
152
|
-
return jsonRpc(
|
|
153
|
-
makeErrorResponse(id, -32602, `Resource is not readable: ${uri}`)
|
|
154
|
-
);
|
|
146
|
+
return jsonRpc(makeErrorResponse(id, -32602, `Resource is not readable: ${uri}`));
|
|
155
147
|
}
|
|
156
148
|
const contents = await resource.read(uri, event);
|
|
157
149
|
const text = typeof contents === "string" ? contents : JSON.stringify(contents);
|
|
@@ -176,9 +168,7 @@ export function defineMcpServer(definition) {
|
|
|
176
168
|
const promptArgs = params?.arguments ?? {};
|
|
177
169
|
const prompt = (definition.prompts ?? []).find((p) => p.name === promptName);
|
|
178
170
|
if (!prompt) {
|
|
179
|
-
return jsonRpc(
|
|
180
|
-
makeErrorResponse(id, -32602, `Prompt not found: ${promptName}`)
|
|
181
|
-
);
|
|
171
|
+
return jsonRpc(makeErrorResponse(id, -32602, `Prompt not found: ${promptName}`));
|
|
182
172
|
}
|
|
183
173
|
if (!prompt.get) {
|
|
184
174
|
return jsonRpc(
|
|
@@ -195,18 +185,12 @@ export function defineMcpServer(definition) {
|
|
|
195
185
|
}
|
|
196
186
|
// ── unknown method ───────────────────────────────────────────────────
|
|
197
187
|
default: {
|
|
198
|
-
return jsonRpc(
|
|
199
|
-
makeErrorResponse(id, -32601, `Method not found: ${method}`)
|
|
200
|
-
);
|
|
188
|
+
return jsonRpc(makeErrorResponse(id, -32601, `Method not found: ${method}`));
|
|
201
189
|
}
|
|
202
190
|
}
|
|
203
191
|
} catch (err) {
|
|
204
192
|
return jsonRpc(
|
|
205
|
-
makeErrorResponse(
|
|
206
|
-
id,
|
|
207
|
-
-32603,
|
|
208
|
-
`Internal error: ${err?.message ?? String(err)}`
|
|
209
|
-
)
|
|
193
|
+
makeErrorResponse(id, -32603, `Internal error: ${err?.message ?? String(err)}`)
|
|
210
194
|
);
|
|
211
195
|
}
|
|
212
196
|
};
|