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
|
@@ -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
|
};
|
|
@@ -5,14 +5,17 @@ import type { NotificationRecord, PushSubscriptionRecord, SendNotificationReques
|
|
|
5
5
|
* channel.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* await sendNotification(
|
|
10
|
+
* {
|
|
11
|
+
* userId: "user_123",
|
|
12
|
+
* title: "Order Shipped",
|
|
13
|
+
* body: "Your order #42 has been shipped!",
|
|
14
|
+
* channels: ["in-app", "email"],
|
|
15
|
+
* },
|
|
16
|
+
* event,
|
|
17
|
+
* )
|
|
18
|
+
* ```
|
|
16
19
|
*/
|
|
17
20
|
export declare function sendNotification(request: SendNotificationRequest, event?: RequestEvent): Promise<void>;
|
|
18
21
|
/** Alias for sendNotification */
|
|
@@ -27,12 +30,16 @@ export interface GetNotificationsOptions {
|
|
|
27
30
|
* Get paginated notifications for a user from D1.
|
|
28
31
|
*
|
|
29
32
|
* @example
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const { notifications, total, unread } = await getNotifications(
|
|
35
|
+
* user.id,
|
|
36
|
+
* {
|
|
37
|
+
* limit: 10,
|
|
38
|
+
* unreadOnly: true,
|
|
39
|
+
* },
|
|
40
|
+
* event,
|
|
41
|
+
* )
|
|
42
|
+
* ```
|
|
36
43
|
*/
|
|
37
44
|
export declare function getNotifications(userId: string, options?: GetNotificationsOptions, event?: RequestEvent): Promise<{
|
|
38
45
|
notifications: NotificationRecord[];
|
|
@@ -43,66 +50,70 @@ export declare function getNotifications(userId: string, options?: GetNotificati
|
|
|
43
50
|
* Get a single notification by ID, scoped to user.
|
|
44
51
|
*
|
|
45
52
|
* @example
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* const notification = await getNotification(notificationId, user.id, event)
|
|
55
|
+
* ```
|
|
49
56
|
*/
|
|
50
57
|
export declare function getNotification(id: string, userId: string, event?: RequestEvent): Promise<NotificationRecord | null>;
|
|
51
58
|
/**
|
|
52
59
|
* Mark a single notification as read.
|
|
53
60
|
*
|
|
54
61
|
* @example
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* await markNotificationRead(notificationId, user.id, event)
|
|
64
|
+
* ```
|
|
58
65
|
*/
|
|
59
66
|
export declare function markNotificationRead(id: string, userId: string, event?: RequestEvent): Promise<void>;
|
|
60
67
|
/**
|
|
61
68
|
* Mark all notifications as read for a user.
|
|
62
69
|
*
|
|
63
70
|
* @example
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* await markAllNotificationsRead(user.id, event)
|
|
73
|
+
* ```
|
|
67
74
|
*/
|
|
68
75
|
export declare function markAllNotificationsRead(userId: string, event?: RequestEvent, tenantId?: string): Promise<void>;
|
|
69
76
|
/**
|
|
70
77
|
* Delete a notification.
|
|
71
78
|
*
|
|
72
79
|
* @example
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* await deleteNotification(notificationId, user.id, event)
|
|
82
|
+
* ```
|
|
76
83
|
*/
|
|
77
84
|
export declare function deleteNotification(id: string, userId: string, event?: RequestEvent): Promise<void>;
|
|
78
85
|
/**
|
|
79
86
|
* Save a Web Push subscription for a user.
|
|
80
87
|
*
|
|
81
88
|
* @example
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* await savePushSubscription(user.id, subscription, undefined, event)
|
|
91
|
+
* ```
|
|
85
92
|
*/
|
|
86
93
|
export declare function savePushSubscription(userId: string, subscription: PushSubscriptionRecord, tenantId?: string, event?: RequestEvent): Promise<void>;
|
|
87
94
|
/**
|
|
88
95
|
* Remove a Web Push subscription by endpoint, optionally scoped to user.
|
|
89
96
|
*
|
|
90
97
|
* @example
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* await removePushSubscription(subscription.endpoint, event, user.id)
|
|
100
|
+
* ```
|
|
94
101
|
*/
|
|
95
102
|
export declare function removePushSubscription(endpoint: string, event?: RequestEvent, userId?: string): Promise<void>;
|
|
96
103
|
/**
|
|
97
104
|
* Send a Web Push notification to all subscriptions for a user.
|
|
98
105
|
*
|
|
99
106
|
* @example
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* await sendWebPush(
|
|
109
|
+
* user.id,
|
|
110
|
+
* {
|
|
111
|
+
* title: "New Message",
|
|
112
|
+
* body: "Alice sent you a direct message.",
|
|
113
|
+
* },
|
|
114
|
+
* event,
|
|
115
|
+
* )
|
|
116
|
+
* ```
|
|
106
117
|
*/
|
|
107
118
|
export declare function sendWebPush(userId: string, payload: {
|
|
108
119
|
title: string;
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
* built-in `/auth/[provider]` routes.
|
|
9
9
|
*/
|
|
10
10
|
import { type RequestEvent } from "nuxt/server";
|
|
11
|
-
/**
|
|
12
|
-
* @internal User profile returned by Google OAuth userinfo endpoint.
|
|
13
|
-
*/
|
|
11
|
+
/** @internal User profile returned by Google OAuth userinfo endpoint. */
|
|
14
12
|
export interface OAuthGoogleUser {
|
|
15
13
|
sub: string;
|
|
16
14
|
email: string;
|
|
@@ -21,9 +19,7 @@ export interface OAuthGoogleUser {
|
|
|
21
19
|
family_name?: string;
|
|
22
20
|
[key: string]: any;
|
|
23
21
|
}
|
|
24
|
-
/**
|
|
25
|
-
* @internal Payload passed to internal onSuccess callback.
|
|
26
|
-
*/
|
|
22
|
+
/** @internal Payload passed to internal onSuccess callback. */
|
|
27
23
|
export interface OAuthSuccessPayload<T = OAuthGoogleUser> {
|
|
28
24
|
user: T;
|
|
29
25
|
tokens: {
|
|
@@ -36,9 +32,7 @@ export interface OAuthSuccessPayload<T = OAuthGoogleUser> {
|
|
|
36
32
|
[key: string]: any;
|
|
37
33
|
};
|
|
38
34
|
}
|
|
39
|
-
/**
|
|
40
|
-
* @internal Configuration options for internal Google OAuth event handler.
|
|
41
|
-
*/
|
|
35
|
+
/** @internal Configuration options for internal Google OAuth event handler. */
|
|
42
36
|
export interface DefineOAuthGoogleOptions {
|
|
43
37
|
onSuccess: (event: RequestEvent, payload: OAuthSuccessPayload<OAuthGoogleUser>) => unknown | Promise<unknown>;
|
|
44
38
|
onError?: (event: RequestEvent, error: unknown) => unknown | Promise<unknown>;
|
|
@@ -6,12 +6,12 @@ export { slugify };
|
|
|
6
6
|
* Creates a new organization with the current authenticated user as "owner".
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const { organization, member } = await createOrganization(event, {
|
|
11
|
+
* name: "Acme Corp",
|
|
12
|
+
* slug: "acme",
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
15
|
*/
|
|
16
16
|
export declare function createOrganization(event: RequestEvent, input: {
|
|
17
17
|
name: string;
|
|
@@ -25,9 +25,9 @@ export declare function createOrganization(event: RequestEvent, input: {
|
|
|
25
25
|
* Lists all organizations the authenticated user belongs to.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const orgs = await listUserOrganizations(event, user.id)
|
|
30
|
+
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare function listUserOrganizations(event: RequestEvent, userId: string): Promise<Array<QarpeoOrganization & {
|
|
33
33
|
role: string;
|
|
@@ -37,9 +37,9 @@ export declare function listUserOrganizations(event: RequestEvent, userId: strin
|
|
|
37
37
|
* Switches the active organization for the current user's session.
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const res = await switchActiveOrganization(event, "org_123")
|
|
42
|
+
* ```
|
|
43
43
|
*/
|
|
44
44
|
export declare function switchActiveOrganization(event: RequestEvent, organizationId: string): Promise<{
|
|
45
45
|
success: boolean;
|
|
@@ -50,13 +50,13 @@ export declare function switchActiveOrganization(event: RequestEvent, organizati
|
|
|
50
50
|
* Invites a new member to an organization via email.
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* const invite = await inviteOrganizationMember(event, {
|
|
55
|
+
* organizationId: "org_123",
|
|
56
|
+
* email: "colleague@example.com",
|
|
57
|
+
* role: "member",
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
60
|
*/
|
|
61
61
|
export declare function inviteOrganizationMember(event: RequestEvent, input: {
|
|
62
62
|
organizationId: string;
|
|
@@ -74,9 +74,9 @@ export declare function inviteOrganizationMember(event: RequestEvent, input: {
|
|
|
74
74
|
* Removes a member from an organization.
|
|
75
75
|
*
|
|
76
76
|
* @example
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* await removeOrganizationMember(event, { organizationId: "org_123", memberId: "mem_456" })
|
|
79
|
+
* ```
|
|
80
80
|
*/
|
|
81
81
|
export declare function removeOrganizationMember(event: RequestEvent, input: {
|
|
82
82
|
organizationId: string;
|
|
@@ -88,9 +88,9 @@ export declare function removeOrganizationMember(event: RequestEvent, input: {
|
|
|
88
88
|
* Accepts an invitation token and adds user as a member.
|
|
89
89
|
*
|
|
90
90
|
* @example
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* const res = await acceptOrganizationInvitation(event, "raw-invite-token")
|
|
93
|
+
* ```
|
|
94
94
|
*/
|
|
95
95
|
export declare function acceptOrganizationInvitation(event: RequestEvent, token: string): Promise<{
|
|
96
96
|
success: boolean;
|
|
@@ -101,9 +101,9 @@ export declare function acceptOrganizationInvitation(event: RequestEvent, token:
|
|
|
101
101
|
* Lists all members for a given organization (requires organization membership).
|
|
102
102
|
*
|
|
103
103
|
* @example
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* const members = await listOrganizationMembers(event, "org_123")
|
|
106
|
+
* ```
|
|
107
107
|
*/
|
|
108
108
|
export declare function listOrganizationMembers(event: RequestEvent, organizationId: string): Promise<Array<QarpeoMember & {
|
|
109
109
|
email?: string;
|
|
@@ -56,7 +56,9 @@ export async function createOrganization(event, input) {
|
|
|
56
56
|
createdAt: now
|
|
57
57
|
};
|
|
58
58
|
await d1.batch([
|
|
59
|
-
d1.prepare(
|
|
59
|
+
d1.prepare(
|
|
60
|
+
`INSERT INTO ${orgTbl(event)} (id, name, slug, logo, created_at) VALUES (?, ?, ?, ?, ?)`
|
|
61
|
+
).bind(
|
|
60
62
|
organization.id,
|
|
61
63
|
organization.name,
|
|
62
64
|
organization.slug,
|
|
@@ -104,7 +106,9 @@ export async function switchActiveOrganization(event, organizationId) {
|
|
|
104
106
|
}
|
|
105
107
|
const d1 = getD1(event);
|
|
106
108
|
await ensureAuthTables(d1);
|
|
107
|
-
const member = await d1.prepare(
|
|
109
|
+
const member = await d1.prepare(
|
|
110
|
+
`SELECT id, role FROM ${memberTbl(event)} WHERE organization_id = ? AND user_id = ? LIMIT 1`
|
|
111
|
+
).bind(organizationId, user.id).first();
|
|
108
112
|
if (!member) {
|
|
109
113
|
throw createError({
|
|
110
114
|
statusCode: 403,
|
|
@@ -153,7 +157,9 @@ export async function inviteOrganizationMember(event, input) {
|
|
|
153
157
|
}
|
|
154
158
|
const d1 = getD1(event);
|
|
155
159
|
await ensureAuthTables(d1);
|
|
156
|
-
const callerMember = await d1.prepare(
|
|
160
|
+
const callerMember = await d1.prepare(
|
|
161
|
+
`SELECT role FROM ${memberTbl(event)} WHERE organization_id = ? AND user_id = ? LIMIT 1`
|
|
162
|
+
).bind(input.organizationId, user.id).first();
|
|
157
163
|
if (!callerMember || !["owner", "admin"].includes(callerMember.role)) {
|
|
158
164
|
throw createError({
|
|
159
165
|
statusCode: 403,
|
|
@@ -268,7 +274,9 @@ export async function removeOrganizationMember(event, input) {
|
|
|
268
274
|
}
|
|
269
275
|
const d1 = getD1(event);
|
|
270
276
|
await ensureAuthTables(d1);
|
|
271
|
-
const callerMember = await d1.prepare(
|
|
277
|
+
const callerMember = await d1.prepare(
|
|
278
|
+
`SELECT id, role FROM ${memberTbl(event)} WHERE organization_id = ? AND user_id = ? LIMIT 1`
|
|
279
|
+
).bind(input.organizationId, user.id).first();
|
|
272
280
|
if (!callerMember) {
|
|
273
281
|
throw createError({
|
|
274
282
|
statusCode: 403,
|
|
@@ -306,7 +314,9 @@ export async function removeOrganizationMember(event, input) {
|
|
|
306
314
|
});
|
|
307
315
|
}
|
|
308
316
|
if (targetMember.role === "owner") {
|
|
309
|
-
const ownerCount = await d1.prepare(
|
|
317
|
+
const ownerCount = await d1.prepare(
|
|
318
|
+
`SELECT count(*) as count FROM ${memberTbl(event)} WHERE organization_id = ? AND role = 'owner'`
|
|
319
|
+
).bind(input.organizationId).first();
|
|
310
320
|
if ((ownerCount?.count || 0) <= 1) {
|
|
311
321
|
throw createError({
|
|
312
322
|
statusCode: 400,
|
|
@@ -30,36 +30,36 @@ export interface VerifyMagicLinkResult {
|
|
|
30
30
|
* Sends a one-time password (OTP) verification code to the specified email address.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const result = await sendOTPCode(event, "user@example.com")
|
|
35
|
+
* if (result.sent) {
|
|
36
|
+
* console.log("OTP code sent successfully, expires at", result.expiresAt)
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
39
|
*/
|
|
40
40
|
export declare function sendOTPCode(event: RequestEvent, email: string, options?: SendOTPOptions): Promise<SendOTPResult>;
|
|
41
41
|
/**
|
|
42
42
|
* Verifies a submitted OTP code for an email address against KV.
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const result = await verifyOTPCode(event, "user@example.com", "123456")
|
|
47
|
+
* if (result.valid) {
|
|
48
|
+
* console.log("OTP successfully verified")
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
51
|
*/
|
|
52
52
|
export declare function verifyOTPCode(event: RequestEvent, email: string, code: string): Promise<VerifyOTPResult>;
|
|
53
53
|
/**
|
|
54
54
|
* Sends a passwordless magic sign-in link to the specified email address.
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* const result = await sendMagicLink(event, "user@example.com")
|
|
59
|
+
* if (result.sent) {
|
|
60
|
+
* console.log("Magic link sent successfully")
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
63
|
*/
|
|
64
64
|
export declare function sendMagicLink(event: RequestEvent, email: string, options?: {
|
|
65
65
|
ttl?: number;
|
|
@@ -68,11 +68,11 @@ export declare function sendMagicLink(event: RequestEvent, email: string, option
|
|
|
68
68
|
* Verifies and consumes a passwordless magic sign-in link token.
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* const result = await verifyMagicLinkToken(event, token)
|
|
73
|
+
* if (result.valid) {
|
|
74
|
+
* console.log("Verified email:", result.email)
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
77
|
*/
|
|
78
78
|
export declare function verifyMagicLinkToken(event: RequestEvent, token: string): Promise<VerifyMagicLinkResult>;
|
|
@@ -5,13 +5,13 @@ import type { CreateCheckoutOptions } from "../../../../types";
|
|
|
5
5
|
* Workers using standard `fetch`.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { url } = await createCheckoutSession(event, {
|
|
10
|
+
* planId: "pro_monthly",
|
|
11
|
+
* successUrl: "https://example.com/billing?success=true",
|
|
12
|
+
* cancelUrl: "https://example.com/pricing",
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
15
|
*/
|
|
16
16
|
export declare function createCheckoutSession(event: RequestEvent, options: CreateCheckoutOptions): Promise<{
|
|
17
17
|
id: string;
|
|
@@ -21,11 +21,11 @@ export declare function createCheckoutSession(event: RequestEvent, options: Crea
|
|
|
21
21
|
* Creates a Customer Billing Portal session for the current user.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const { url } = await createCustomerPortalSession(event, {
|
|
26
|
+
* returnUrl: "https://example.com/settings/billing",
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
29
|
*/
|
|
30
30
|
export declare function createCustomerPortalSession(event: RequestEvent, options?: {
|
|
31
31
|
returnUrl?: string;
|
|
@@ -53,9 +53,7 @@ export async function createCheckoutSession(event, options) {
|
|
|
53
53
|
if (config.provider === "stripe") {
|
|
54
54
|
let customerId = null;
|
|
55
55
|
if (user?.id) {
|
|
56
|
-
const cust = await db.prepare(
|
|
57
|
-
`SELECT customer_id FROM ${ct} WHERE user_id = ? AND provider = 'stripe' LIMIT 1`
|
|
58
|
-
).bind(user.id).first();
|
|
56
|
+
const cust = await db.prepare(`SELECT customer_id FROM ${ct} WHERE user_id = ? AND provider = 'stripe' LIMIT 1`).bind(user.id).first();
|
|
59
57
|
if (cust) customerId = cust.customer_id;
|
|
60
58
|
}
|
|
61
59
|
const mode = options.mode || "subscription";
|
|
@@ -37,9 +37,9 @@ export interface PaymentWebhookListenerPayload {
|
|
|
37
37
|
}
|
|
38
38
|
export type PaymentWebhookListener = (payload: PaymentWebhookListenerPayload) => void | Promise<void>;
|
|
39
39
|
/**
|
|
40
|
-
* Registers a server-side listener for verified payment webhook events.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* Registers a server-side listener for verified payment webhook events. Used by higher-level
|
|
41
|
+
* modules (such as Store) to reconcile orders without creating a compile-time dependency from
|
|
42
|
+
* Payments to App modules.
|
|
43
43
|
*/
|
|
44
44
|
export declare function registerPaymentWebhookListener(listener: PaymentWebhookListener): () => void;
|
|
45
45
|
export declare function notifyPaymentWebhookListeners(info: PaymentWebhookListenerPayload): Promise<void>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Verifies Paddle Billing webhook signature (Paddle-Signature header: `ts=TIMESTAMP;h1=HMAC_HEX`)
|
|
3
|
+
* with replay protection
|
|
4
|
+
*/
|
|
2
5
|
export declare function verifyPaddleSignature(rawBody: string, signatureHeader: string | null | undefined, secret: string, toleranceSec?: number): Promise<boolean>;
|
|
3
6
|
export declare function handlePaddleWebhookEvent(db: any, ct: string, st: string, payload: any, now: number): Promise<{
|
|
4
7
|
eventType: string;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Verifies Polar webhook signature (webhook-signature header with optional Standard Webhooks
|
|
3
|
+
* headers)
|
|
4
|
+
*/
|
|
2
5
|
export declare function verifyPolarSignature(rawBody: string, signatureHeader: string | null | undefined, secret: string, options?: {
|
|
3
6
|
timestamp?: string | null;
|
|
4
7
|
webhookId?: string | null;
|
|
@@ -22,7 +22,9 @@ export async function verifyStripeSignature(rawBody, signatureHeader, secret, to
|
|
|
22
22
|
}
|
|
23
23
|
const payload = `${timestamp}.${rawBody}`;
|
|
24
24
|
const expectedSignature = await computeHmacSha256(secret, payload);
|
|
25
|
-
return signatures.some(
|
|
25
|
+
return signatures.some(
|
|
26
|
+
(sig) => timingSafeEqualString(sig.toLowerCase(), expectedSignature.toLowerCase())
|
|
27
|
+
);
|
|
26
28
|
}
|
|
27
29
|
export async function handleStripeWebhookEvent(db, ct, st, payload, now) {
|
|
28
30
|
const eventType = payload.type;
|
|
@@ -138,9 +140,7 @@ export async function handleStripeWebhookEvent(db, ct, st, payload, now) {
|
|
|
138
140
|
const subId = obj.subscription;
|
|
139
141
|
if (subId) {
|
|
140
142
|
affectedSubId = subId;
|
|
141
|
-
await db.prepare(
|
|
142
|
-
`UPDATE ${st} SET status = 'active', updated_at = ? WHERE subscription_id = ?`
|
|
143
|
-
).bind(now, subId).run();
|
|
143
|
+
await db.prepare(`UPDATE ${st} SET status = 'active', updated_at = ? WHERE subscription_id = ?`).bind(now, subId).run();
|
|
144
144
|
}
|
|
145
145
|
break;
|
|
146
146
|
}
|
|
@@ -148,9 +148,7 @@ export async function handleStripeWebhookEvent(db, ct, st, payload, now) {
|
|
|
148
148
|
const subId = obj.subscription;
|
|
149
149
|
if (subId) {
|
|
150
150
|
affectedSubId = subId;
|
|
151
|
-
await db.prepare(
|
|
152
|
-
`UPDATE ${st} SET status = 'past_due', updated_at = ? WHERE subscription_id = ?`
|
|
153
|
-
).bind(now, subId).run();
|
|
151
|
+
await db.prepare(`UPDATE ${st} SET status = 'past_due', updated_at = ? WHERE subscription_id = ?`).bind(now, subId).run();
|
|
154
152
|
}
|
|
155
153
|
break;
|
|
156
154
|
}
|