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
|
@@ -42,7 +42,7 @@ export function useDrizzle(bindingNameOrOptions, eventOrOptions) {
|
|
|
42
42
|
let postgresLib;
|
|
43
43
|
let drizzlePostgres;
|
|
44
44
|
try {
|
|
45
|
-
const req = globalThis.require || (
|
|
45
|
+
const req = globalThis.require || (globalThis.process !== void 0 && typeof require !== "undefined" ? require : void 0);
|
|
46
46
|
if (req) {
|
|
47
47
|
const pgMod = req("postgres");
|
|
48
48
|
postgresLib = pgMod?.default || pgMod;
|
|
@@ -90,7 +90,7 @@ Ensure your Hyperdrive binding exposes a connectionString (or set DATABASE_URL).
|
|
|
90
90
|
let mysqlLib;
|
|
91
91
|
let drizzleMysql;
|
|
92
92
|
try {
|
|
93
|
-
const req = globalThis.require || (
|
|
93
|
+
const req = globalThis.require || (globalThis.process !== void 0 && typeof require !== "undefined" ? require : void 0);
|
|
94
94
|
if (req) {
|
|
95
95
|
mysqlLib = req("mysql2/promise");
|
|
96
96
|
drizzleMysql = req("drizzle-orm/mysql2").drizzle;
|
|
@@ -152,7 +152,10 @@ Install it with: pnpm add mysql2`
|
|
|
152
152
|
let instance = isDefaultSchema ? drizzleCache.get(d1) : void 0;
|
|
153
153
|
if (!instance) {
|
|
154
154
|
const relations = defineRelations(activeSchema);
|
|
155
|
-
const rawDrizzle = drizzleD1(d1, {
|
|
155
|
+
const rawDrizzle = drizzleD1(d1, {
|
|
156
|
+
relations,
|
|
157
|
+
schema: activeSchema
|
|
158
|
+
});
|
|
156
159
|
instance = Object.assign(rawDrizzle, {
|
|
157
160
|
raw: (bName) => getD1Binding(bName || resolvedBinding, event),
|
|
158
161
|
getBookmark: () => d1.getBookmark?.() ?? null,
|
|
@@ -186,21 +189,18 @@ export const db = new Proxy(
|
|
|
186
189
|
);
|
|
187
190
|
export const d1Db = db;
|
|
188
191
|
export function createDbProxy(name) {
|
|
189
|
-
return new Proxy(
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (typeof val === "function") {
|
|
199
|
-
return val.bind(instance);
|
|
200
|
-
}
|
|
201
|
-
return val;
|
|
192
|
+
return new Proxy({}, {
|
|
193
|
+
get(_target, prop) {
|
|
194
|
+
if (prop === "raw") {
|
|
195
|
+
return (bindingName) => getD1Binding(bindingName || name);
|
|
196
|
+
}
|
|
197
|
+
const instance = useDrizzle(name);
|
|
198
|
+
const val = instance[prop];
|
|
199
|
+
if (typeof val === "function") {
|
|
200
|
+
return val.bind(instance);
|
|
202
201
|
}
|
|
202
|
+
return val;
|
|
203
203
|
}
|
|
204
|
-
);
|
|
204
|
+
});
|
|
205
205
|
}
|
|
206
206
|
export const schema = _schema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CFEvent } from "../../types/index";
|
|
2
1
|
import type { DurableObjectId, DurableObjectNamespace, DurableObjectStorage, DurableObjectState, DurableObjectRPCStub, DurableObjectDefinition, DurableObjectClass, SqlStorage, SqlStorageCursor } from "../../types/durable-object";
|
|
2
|
+
import type { CFEvent } from "../../types/index";
|
|
3
3
|
export type { DurableObjectId, DurableObjectStub, DurableObjectNamespace, DurableObjectStorage, DurableObjectState, DurableObjectContext, DurableObjectRPCStub, DurableObjectDefinition, DurableObjectClass, DurableObjectsOptions, SqlStorage, SqlStorageCursor, } from "../../types/durable-object";
|
|
4
4
|
export declare class InMemorySqlStorageCursor<T = Record<string, any>> implements SqlStorageCursor<T> {
|
|
5
5
|
private readonly rows;
|
|
@@ -56,35 +56,37 @@ export declare function clearDurableObjectStore(): void;
|
|
|
56
56
|
/**
|
|
57
57
|
* Defines a modern Cloudflare Durable Object with Remote Procedure Call (RPC) support.
|
|
58
58
|
*
|
|
59
|
-
* Supports both object-literal syntax (with `this.storage`, `this.state`, and `this.env`)
|
|
60
|
-
*
|
|
59
|
+
* Supports both object-literal syntax (with `this.storage`, `this.state`, and `this.env`) and class
|
|
60
|
+
* syntax.
|
|
61
61
|
*
|
|
62
|
-
* @example
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* @example
|
|
63
|
+
* Object-literal syntax with RPC methods:
|
|
64
|
+
* ```ts
|
|
65
|
+
* export default defineDurableObject({
|
|
65
66
|
* async increment(by: number = 1) {
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
* const current = (await this.storage.get<number>("count")) || 0
|
|
68
|
+
* const next = current + by
|
|
69
|
+
* await this.storage.put("count", next)
|
|
70
|
+
* return next
|
|
70
71
|
* },
|
|
71
72
|
* async getCount() {
|
|
72
|
-
*
|
|
73
|
+
* return (await this.storage.get<number>("count")) || 0
|
|
73
74
|
* }
|
|
74
|
-
*
|
|
75
|
-
*
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
76
77
|
*
|
|
77
|
-
* @example
|
|
78
|
-
*
|
|
79
|
-
*
|
|
78
|
+
* @example
|
|
79
|
+
* Class syntax:
|
|
80
|
+
* ```ts
|
|
81
|
+
* export default defineDurableObject(class CounterDO {
|
|
80
82
|
* constructor(public state: DurableObjectState, public env: Record<string, any>) {}
|
|
81
83
|
* async increment(by: number = 1) {
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
84
|
+
* const current = (await this.state.storage.get<number>("count")) || 0
|
|
85
|
+
* await this.state.storage.put("count", current + by)
|
|
86
|
+
* return current + by
|
|
85
87
|
* }
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
+
* })
|
|
89
|
+
* ```
|
|
88
90
|
*/
|
|
89
91
|
export declare function defineDurableObject<T extends Record<string, any>>(definitionOrClass: DurableObjectDefinition<T>): DurableObjectClass<T>;
|
|
90
92
|
/**
|
|
@@ -98,9 +100,9 @@ export declare function getDurableObjectNamespace<T = Record<string, any>>(bindi
|
|
|
98
100
|
* Access a modern typed Durable Object RPC stub by binding name and ID or name.
|
|
99
101
|
*
|
|
100
102
|
* @example
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* const counter = useDurableObject<CounterDO>("COUNTER", "user_42", event)
|
|
105
|
+
* const count = await counter.increment(5) // Direct RPC call!
|
|
106
|
+
* ```
|
|
105
107
|
*/
|
|
106
108
|
export declare function useDurableObject<T = Record<string, any>>(bindingName: string | DurableObjectClass<T>, idOrName: string | DurableObjectId, event?: CFEvent): DurableObjectRPCStub<T>;
|
|
@@ -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}. */
|