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
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { createError } from "nuxt/server";
|
|
2
2
|
export function assertSafeCmsSlug(slug) {
|
|
3
3
|
if (typeof slug !== "string" || !slug.trim()) {
|
|
4
|
-
throw createError({
|
|
4
|
+
throw createError({
|
|
5
|
+
statusCode: 400,
|
|
6
|
+
message: "Slug is required and must be a non-empty string"
|
|
7
|
+
});
|
|
5
8
|
}
|
|
6
9
|
const trimmed = slug.trim();
|
|
7
10
|
if (trimmed.length > 256) {
|
|
8
11
|
throw createError({ statusCode: 400, message: "Slug exceeds maximum length of 256 characters" });
|
|
9
12
|
}
|
|
10
13
|
if (trimmed.includes("\\") || trimmed.includes("..") || /[\x00-\x1f\x7f]/.test(trimmed)) {
|
|
11
|
-
throw createError({
|
|
14
|
+
throw createError({
|
|
15
|
+
statusCode: 400,
|
|
16
|
+
message: "Slug contains invalid characters or path traversal sequences"
|
|
17
|
+
});
|
|
12
18
|
}
|
|
13
19
|
if (trimmed.startsWith("/") || trimmed.endsWith("/") || trimmed.startsWith(".") || trimmed.endsWith(".")) {
|
|
14
20
|
throw createError({ statusCode: 400, message: "Slug cannot start or end with slashes or dots" });
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { createError } from "nuxt/server";
|
|
2
2
|
import { resolveTableName } from "../table-names.mjs";
|
|
3
|
-
import {
|
|
4
|
-
getCMSDb,
|
|
5
|
-
getCMSConfig,
|
|
6
|
-
getCMSTenantId,
|
|
7
|
-
cmsCollectionTbl,
|
|
8
|
-
cmsEntryTbl
|
|
9
|
-
} from "./common.mjs";
|
|
3
|
+
import { getCMSDb, getCMSConfig, getCMSTenantId, cmsCollectionTbl, cmsEntryTbl } from "./common.mjs";
|
|
10
4
|
import { getCMSEntry } from "./queries.mjs";
|
|
11
5
|
const userTbl = (e) => resolveTableName("user", e);
|
|
12
6
|
export function isReferenceValue(v) {
|
|
@@ -8,8 +8,8 @@ export declare function registerEnsureCMSSynced(fn: (event: RequestEvent) => Pro
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function buildFtsQuery(query: string, operator?: "AND" | "OR"): string;
|
|
10
10
|
/**
|
|
11
|
-
* Rebuilds the FTS5 virtual table from current `cms_entry` records. Can be used after
|
|
12
|
-
*
|
|
11
|
+
* Rebuilds the FTS5 virtual table from current `cms_entry` records. Can be used after schema
|
|
12
|
+
* migrations or to re-index all content.
|
|
13
13
|
*/
|
|
14
14
|
export declare function rebuildCMSFTS(event?: RequestEvent): Promise<{
|
|
15
15
|
total: number;
|
|
@@ -9,6 +9,7 @@ Install it with: pnpm add yaml`
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
import { getKVBinding } from "../../../kv.mjs";
|
|
12
|
+
import { resolveReferenceFieldsFromFrontmatter } from "../cms.mjs";
|
|
12
13
|
import { resolveIndexName } from "../table-names.mjs";
|
|
13
14
|
import {
|
|
14
15
|
getCMSDb,
|
|
@@ -36,7 +37,6 @@ import {
|
|
|
36
37
|
extractTOC
|
|
37
38
|
} from "./path.mjs";
|
|
38
39
|
import { registerEnsureCMSSynced } from "./search.mjs";
|
|
39
|
-
import { resolveReferenceFieldsFromFrontmatter } from "../cms.mjs";
|
|
40
40
|
let ensureCMSTablesPromise = null;
|
|
41
41
|
export async function ensureCMSTables(event) {
|
|
42
42
|
const db = getCMSDb(event);
|
|
@@ -768,7 +768,9 @@ export async function syncLocalContentFiles(event, contentDir, collectionsConfig
|
|
|
768
768
|
now
|
|
769
769
|
).run();
|
|
770
770
|
} else if (folderSchema?.fields && existingCol.schema_json !== initialFields && existingCol.source === "file") {
|
|
771
|
-
await db.prepare(
|
|
771
|
+
await db.prepare(
|
|
772
|
+
`UPDATE ${cmsCollectionTbl(event)} SET schema_json = ?, updated_at = ? WHERE id = ?`
|
|
773
|
+
).bind(initialFields, now, collectionId).run();
|
|
772
774
|
}
|
|
773
775
|
if (meta.isSingleDataFile) {
|
|
774
776
|
const filePath = meta.directory;
|
|
@@ -42,8 +42,8 @@ export declare function deleteCMSCategory(event: RequestEvent, id: string): Prom
|
|
|
42
42
|
deletedId: string;
|
|
43
43
|
}>;
|
|
44
44
|
/**
|
|
45
|
-
* Synchronizes tags into the `cms_tag` table and updates usage count. Handles addition,
|
|
46
|
-
*
|
|
45
|
+
* Synchronizes tags into the `cms_tag` table and updates usage count. Handles addition, updates, or
|
|
46
|
+
* removal of tags on an entry.
|
|
47
47
|
*/
|
|
48
48
|
export declare function syncCMSEntryTags(event: RequestEvent, oldTagsString?: string | null, newTagsString?: string | null): Promise<void>;
|
|
49
49
|
export declare function queryCMSTags(event?: RequestEvent): Promise<any>;
|
|
@@ -12,4 +12,4 @@ export { formatEntryAsMarkdown, projectCMSEntry, rowToEntry, queryCMSEntries, ge
|
|
|
12
12
|
export { getCollectionFields, defineCMSComponent, resolveReference, resolveReferenceFieldsFromFrontmatter, } from "./cms/references";
|
|
13
13
|
export { invalidateCMSEntryCache } from "./cms/cache";
|
|
14
14
|
export { createCMSEntry, updateCMSEntry, deleteCMSEntry, publishCMSEntry, publishDueScheduledEntries, submitCMSEntryForReview, rejectCMSEntryReview, } from "./cms/mutations";
|
|
15
|
-
export { pruneRevisions, listCMSRevisions, restoreCMSRevision
|
|
15
|
+
export { pruneRevisions, listCMSRevisions, restoreCMSRevision } from "./cms/revisions";
|
|
@@ -31,8 +31,4 @@ export {
|
|
|
31
31
|
submitCMSEntryForReview,
|
|
32
32
|
rejectCMSEntryReview
|
|
33
33
|
} from "./cms/mutations.mjs";
|
|
34
|
-
export {
|
|
35
|
-
pruneRevisions,
|
|
36
|
-
listCMSRevisions,
|
|
37
|
-
restoreCMSRevision
|
|
38
|
-
} from "./cms/revisions.mjs";
|
|
34
|
+
export { pruneRevisions, listCMSRevisions, restoreCMSRevision } from "./cms/revisions.mjs";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Comment content filter — blocks adult website links and banned keywords.
|
|
3
3
|
*
|
|
4
4
|
* Design decisions:
|
|
5
|
+
*
|
|
5
6
|
* - O(1) Set<string> hash lookup for adult domain matching (no loop over list)
|
|
6
7
|
* - Adult TLD regex catches millions of sites not in the explicit set
|
|
7
8
|
* - Obfuscation normalization: handles [dot], (dot), [.], zero-width chars
|
|
@@ -27,19 +28,20 @@ export interface ModerationCheckResult {
|
|
|
27
28
|
valid: boolean;
|
|
28
29
|
violation?: ModerationViolation;
|
|
29
30
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Normalizes obfuscation and extracts all URLs + apex domains from the comment.
|
|
32
|
-
*/
|
|
31
|
+
/** Normalizes obfuscation and extracts all URLs + apex domains from the comment. */
|
|
33
32
|
export declare function extractUrlsAndDomains(content: string): ExtractedContent;
|
|
34
33
|
/**
|
|
35
|
-
* Pure checker: inspects comment text against moderation rules and returns
|
|
36
|
-
*
|
|
34
|
+
* Pure checker: inspects comment text against moderation rules and returns a ModerationCheckResult
|
|
35
|
+
* without throwing.
|
|
37
36
|
*/
|
|
38
37
|
export declare function checkCommentContent(content: string, cfg: CommentsModerationConfig): ModerationCheckResult;
|
|
39
38
|
/**
|
|
40
39
|
* Validates comment content against moderation rules.
|
|
41
|
-
*
|
|
42
|
-
* - If action is "
|
|
40
|
+
*
|
|
41
|
+
* - If action is "reject" (default) and a violation is found, throws createError({ statusCode: 400
|
|
42
|
+
* }).
|
|
43
|
+
* - If action is "quarantine" and a violation is found, returns { valid: false, violation } without
|
|
44
|
+
* throwing.
|
|
43
45
|
* - If valid, returns { valid: true }.
|
|
44
46
|
*/
|
|
45
47
|
export declare function validateCommentContent(content: string, cfg: CommentsModerationConfig): ModerationCheckResult;
|
|
@@ -75,32 +75,35 @@ export declare function getCommentsConfig(event?: RequestEvent): CommentsOptions
|
|
|
75
75
|
prefix?: string;
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
|
-
* Extracts the integer sequence number from a materialized path segment.
|
|
79
|
-
*
|
|
78
|
+
* Extracts the integer sequence number from a materialized path segment. Handles both hardened
|
|
79
|
+
* segments (e.g. "000005_x9y2" -> 5) and legacy 4-digit segments ("0004" -> 4).
|
|
80
80
|
*/
|
|
81
81
|
export declare function extractSegmentIndex(segment: string): number;
|
|
82
82
|
/**
|
|
83
|
-
* Builds a materialized path for a new comment.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
83
|
+
* Builds a materialized path for a new comment. Formats segments with 6-digit zero padding and a
|
|
84
|
+
* unique 4-character tiebreaker (e.g. /000001_a1b2/) to guarantee collision-free subtree indexing
|
|
85
|
+
* even during concurrent posts.
|
|
86
86
|
*/
|
|
87
87
|
export declare function buildPath(parentPath: string, siblingIndex: number): string;
|
|
88
88
|
/**
|
|
89
|
-
* Creates all three comments tables if they do not already exist.
|
|
90
|
-
*
|
|
91
|
-
*
|
|
89
|
+
* Creates all three comments tables if they do not already exist. Uses a module-level promise cache
|
|
90
|
+
* so the 10+ SQL statements only execute once per Worker isolate — subsequent calls are free
|
|
91
|
+
* no-ops.
|
|
92
92
|
*/
|
|
93
93
|
export declare function ensureCommentsTables(event?: RequestEvent): Promise<void>;
|
|
94
94
|
/**
|
|
95
95
|
* Fetches comments for a target URN. Supports flat or threaded (nested replies) output.
|
|
96
96
|
*
|
|
97
97
|
* @example
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* const { comments, total } = await queryComments(
|
|
100
|
+
* {
|
|
101
|
+
* targetUrn: "urn:qarpeo:blog:hello-world",
|
|
102
|
+
* threaded: true,
|
|
103
|
+
* },
|
|
104
|
+
* event,
|
|
105
|
+
* )
|
|
106
|
+
* ```
|
|
104
107
|
*/
|
|
105
108
|
export declare function queryComments(opts: QueryCommentsOptions, event?: RequestEvent): Promise<{
|
|
106
109
|
comments: Comment[];
|
|
@@ -110,81 +113,91 @@ export declare function queryComments(opts: QueryCommentsOptions, event?: Reques
|
|
|
110
113
|
* Fetches a single comment by ID.
|
|
111
114
|
*
|
|
112
115
|
* @example
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* const comment = await getComment("cmt_123", event)
|
|
118
|
+
* ```
|
|
116
119
|
*/
|
|
117
120
|
export declare function getComment(id: string, event?: RequestEvent): Promise<Comment | null>;
|
|
118
121
|
/**
|
|
119
|
-
* Creates a new comment with rate limiting, auth checks, length validation,
|
|
120
|
-
*
|
|
122
|
+
* Creates a new comment with rate limiting, auth checks, length validation, materialized path
|
|
123
|
+
* threading, and avatar generation.
|
|
121
124
|
*
|
|
122
125
|
* @example
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* const comment = await createComment(
|
|
128
|
+
* {
|
|
129
|
+
* targetUrn: "urn:qarpeo:blog:hello-world",
|
|
130
|
+
* authorName: "Alice",
|
|
131
|
+
* content: "Great post!",
|
|
132
|
+
* },
|
|
133
|
+
* event,
|
|
134
|
+
* )
|
|
135
|
+
* ```
|
|
130
136
|
*/
|
|
131
137
|
export declare function createComment(input: CreateCommentInput, event?: RequestEvent): Promise<Comment>;
|
|
132
138
|
/**
|
|
133
139
|
* Updates the moderation status of a comment (approved, spam, pending, deleted).
|
|
134
140
|
*
|
|
135
141
|
* @example
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* const updated = await updateCommentStatus("cmt_123", "approved", event)
|
|
144
|
+
* ```
|
|
139
145
|
*/
|
|
140
146
|
export declare function updateCommentStatus(id: string, status: CommentStatus, event?: RequestEvent): Promise<Comment | null>;
|
|
141
147
|
/**
|
|
142
|
-
* Soft-deletes a comment, retaining tree structure.
|
|
143
|
-
*
|
|
144
|
-
* Content is replaced with "[deleted]" at read time.
|
|
148
|
+
* Soft-deletes a comment, retaining tree structure. Sets `deletedAt`, `status = "deleted"`, and
|
|
149
|
+
* clears PII fields. Content is replaced with "[deleted]" at read time.
|
|
145
150
|
*
|
|
146
151
|
* @example
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
152
|
+
* ```ts
|
|
153
|
+
* await deleteComment("cmt_123", event)
|
|
154
|
+
* ```
|
|
150
155
|
*/
|
|
151
156
|
export declare function deleteComment(id: string, event?: RequestEvent): Promise<void>;
|
|
152
157
|
/**
|
|
153
|
-
* Moderates multiple comments in a single operation.
|
|
154
|
-
*
|
|
158
|
+
* Moderates multiple comments in a single operation. Supports "approve", "spam", and "delete"
|
|
159
|
+
* actions.
|
|
155
160
|
*
|
|
156
161
|
* @example
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
162
|
+
* ```ts
|
|
163
|
+
* await batchModerateComments(
|
|
164
|
+
* {
|
|
165
|
+
* ids: ["cmt_1", "cmt_2"],
|
|
166
|
+
* action: "approve",
|
|
167
|
+
* },
|
|
168
|
+
* event,
|
|
169
|
+
* )
|
|
170
|
+
* ```
|
|
163
171
|
*/
|
|
164
172
|
export declare function batchModerateComments(input: BatchModerateInput, event?: RequestEvent): Promise<BatchModerateResult>;
|
|
165
173
|
/**
|
|
166
|
-
* Submits a community report for a comment.
|
|
167
|
-
*
|
|
174
|
+
* Submits a community report for a comment. Auto-hides the comment when the report count exceeds
|
|
175
|
+
* the configured threshold.
|
|
168
176
|
*
|
|
169
177
|
* @example
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
178
|
+
* ```ts
|
|
179
|
+
* await reportComment("cmt_123", "spam", { note: "Repeated advertising" }, event)
|
|
180
|
+
* ```
|
|
173
181
|
*/
|
|
174
182
|
export declare function reportComment(commentId: string, reason: ReportReason, opts?: {
|
|
175
183
|
note?: string;
|
|
176
184
|
userId?: string;
|
|
177
185
|
}, event?: RequestEvent): Promise<CommentReport>;
|
|
178
186
|
/**
|
|
179
|
-
* Toggles a reaction on a comment (adds if not present, removes if already reacted).
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @returns The updated reaction counts map.
|
|
187
|
+
* Toggles a reaction on a comment (adds if not present, removes if already reacted). Updates the
|
|
188
|
+
* `reaction_counts` JSON denormalisation on the comment row.
|
|
183
189
|
*
|
|
184
190
|
* @example
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* const { added, reactionCounts } = await reactToComment(
|
|
193
|
+
* "cmt_123",
|
|
194
|
+
* "👍",
|
|
195
|
+
* { userId: "u_1" },
|
|
196
|
+
* event,
|
|
197
|
+
* )
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* @returns The updated reaction counts map.
|
|
188
201
|
*/
|
|
189
202
|
export declare function reactToComment(commentId: string, reaction: string, opts?: {
|
|
190
203
|
userId?: string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createError, getRequestHeader } from "nuxt/server";
|
|
2
2
|
import { getCloudflareEnv } from "../../bindings.mjs";
|
|
3
|
+
import { validateCommentContent } from "./comments-filter.mjs";
|
|
3
4
|
import { getQarpeoConfig } from "./config.mjs";
|
|
4
|
-
import { assertRateLimit } from "./ratelimit.mjs";
|
|
5
|
-
import { requireTurnstile } from "./turnstile.mjs";
|
|
6
5
|
import { getAuthContext } from "./context.mjs";
|
|
7
6
|
import { nanoid } from "./crypto.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { validateTargetUrn } from "./urn.mjs";
|
|
10
|
-
import { resolveTableName, resolveIndexName } from "./table-names.mjs";
|
|
7
|
+
import { assertRateLimit } from "./ratelimit.mjs";
|
|
11
8
|
import { escapeHtml } from "./string.mjs";
|
|
9
|
+
import { resolveTableName, resolveIndexName } from "./table-names.mjs";
|
|
12
10
|
import { getTenant } from "./tenant.mjs";
|
|
11
|
+
import { requireTurnstile } from "./turnstile.mjs";
|
|
12
|
+
import { validateTargetUrn } from "./urn.mjs";
|
|
13
13
|
export { isValidTargetUrn, validateTargetUrn } from "./urn.mjs";
|
|
14
14
|
function getD1(event) {
|
|
15
15
|
const env = getCloudflareEnv(event);
|
|
@@ -391,7 +391,7 @@ export async function createComment(input, event) {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
let commentMetadata = { ...input.metadata
|
|
394
|
+
let commentMetadata = { ...input.metadata };
|
|
395
395
|
if (isQuarantined && moderationViolation) {
|
|
396
396
|
status = "spam";
|
|
397
397
|
commentMetadata = {
|
|
@@ -498,7 +498,9 @@ export async function batchModerateComments(input, event) {
|
|
|
498
498
|
const t = getTable(event);
|
|
499
499
|
const now = Date.now();
|
|
500
500
|
const placeholders = cappedIds.map(() => "?").join(", ");
|
|
501
|
-
await db.prepare(
|
|
501
|
+
await db.prepare(
|
|
502
|
+
`UPDATE ${t} SET status = ?, updated_at = ? WHERE id IN (${placeholders})${tenantClause}`
|
|
503
|
+
).bind(newStatus, now, ...cappedIds, ...tenantBinds).run();
|
|
502
504
|
return { success: true, count: cappedIds.length };
|
|
503
505
|
}
|
|
504
506
|
export async function reportComment(commentId, reason, opts, event) {
|
|
@@ -525,9 +527,19 @@ export async function reportComment(commentId, reason, opts, event) {
|
|
|
525
527
|
`UPDATE ${getTable(event)} SET report_count = report_count + 1, updated_at = ? WHERE id = ? RETURNING report_count`
|
|
526
528
|
).bind(now, commentId).first();
|
|
527
529
|
if ((updated?.report_count ?? 0) >= getAutoHideThreshold(event)) {
|
|
528
|
-
await db.prepare(
|
|
530
|
+
await db.prepare(
|
|
531
|
+
`UPDATE ${getTable(event)} SET status = 'spam', updated_at = ? WHERE id = ? AND status = 'approved'`
|
|
532
|
+
).bind(now, commentId).run();
|
|
529
533
|
}
|
|
530
|
-
return {
|
|
534
|
+
return {
|
|
535
|
+
id,
|
|
536
|
+
commentId,
|
|
537
|
+
reporterIp: ip,
|
|
538
|
+
reporterUserId: opts?.userId,
|
|
539
|
+
reason,
|
|
540
|
+
note: opts?.note,
|
|
541
|
+
createdAt: now
|
|
542
|
+
};
|
|
531
543
|
}
|
|
532
544
|
export async function reactToComment(commentId, reaction, opts, event) {
|
|
533
545
|
const db = getD1(event);
|
|
@@ -25,7 +25,7 @@ export declare function getQarpeoConfig(event?: RequestEvent): QarpeoRuntimeConf
|
|
|
25
25
|
/** Alias for getQarpeoConfig */
|
|
26
26
|
export declare const useQarpeoConfig: typeof getQarpeoConfig;
|
|
27
27
|
/**
|
|
28
|
-
* Returns the application secret (NUXT_APP_SECRET) from runtime config or Cloudflare bindings.
|
|
29
|
-
*
|
|
28
|
+
* Returns the application secret (NUXT_APP_SECRET) from runtime config or Cloudflare bindings. Used
|
|
29
|
+
* for HMAC signing where we need a root secret key.
|
|
30
30
|
*/
|
|
31
31
|
export declare function getSessionSecret(event?: RequestEvent, fallback?: string): string;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { type RequestEvent } from "nuxt/server";
|
|
2
2
|
import { type ResolvedPermissions } from "./rbac";
|
|
3
3
|
/**
|
|
4
|
-
* Enforces that the current request has `console:access`.
|
|
5
|
-
*
|
|
4
|
+
* Enforces that the current request has `console:access`. Throws 401 if unauthenticated, 403 if
|
|
5
|
+
* denied.
|
|
6
6
|
*/
|
|
7
7
|
export declare function requireConsoleAccess(event: RequestEvent): Promise<ResolvedPermissions>;
|
|
8
|
-
/**
|
|
9
|
-
* Checks whether the current request has `console:access` without throwing.
|
|
10
|
-
*/
|
|
8
|
+
/** Checks whether the current request has `console:access` without throwing. */
|
|
11
9
|
export declare function hasConsoleAccess(event: RequestEvent): Promise<boolean>;
|
|
12
10
|
/**
|
|
13
11
|
* Enforces `console:access` AND the specified module/action permission(s).
|
|
@@ -7,10 +7,10 @@ export declare function getQarpeoSession(event: RequestEvent): Promise<QarpeoSes
|
|
|
7
7
|
* (qp_live_...) and cookie sessions. Returns null if unauthenticated (never throws).
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const auth = await getAuthContext(event)
|
|
12
|
+
* if (auth) console.log("User:", auth.user.email, "IsAdmin:", auth.isAdmin)
|
|
13
|
+
* ```
|
|
14
14
|
*/
|
|
15
15
|
export declare function getAuthContext(event: RequestEvent): Promise<QarpeoAuthContext | null>;
|
|
16
16
|
/**
|
|
@@ -18,11 +18,11 @@ export declare function getAuthContext(event: RequestEvent): Promise<QarpeoAuthC
|
|
|
18
18
|
* gates, and organization gates. Throws 401 or 403 on failure.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* export default defineEventHandler(async (event) => {
|
|
23
|
+
* const { user, isAdmin } = await requireAuth(event, { role: "admin" })
|
|
24
|
+
* return { message: `Hello ${user.name}` }
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
27
|
*/
|
|
28
28
|
export declare function requireAuth(event: RequestEvent, options?: RequireAuthOptions): Promise<QarpeoAuthContext>;
|
|
@@ -7,9 +7,9 @@ import type { RequestEvent } from "nuxt/server";
|
|
|
7
7
|
* in naive implementations that return early on `a.length !== b.length`.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const valid = timingSafeEqualString(sigA, sigB)
|
|
12
|
+
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare function timingSafeEqualString(a: string, b: string): boolean;
|
|
15
15
|
/** Alias for timingSafeEqualString */
|
|
@@ -18,9 +18,9 @@ export declare const constantTimeEqual: typeof timingSafeEqualString;
|
|
|
18
18
|
* Generates a cryptographically secure URL-friendly unique identifier using Web Crypto.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const id = nanoid() // "V1StGXR8_Z5jdHi6B-myT"
|
|
23
|
+
* ```
|
|
24
24
|
*/
|
|
25
25
|
export declare function nanoid(size?: number): string;
|
|
26
26
|
/**
|
|
@@ -28,9 +28,9 @@ export declare function nanoid(size?: number): string;
|
|
|
28
28
|
* value is prefixed with `enc:` followed by the hex-encoded `iv ‖ ciphertext`.
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const ciphertext = await encryptToken(accessToken, event)
|
|
33
|
+
* ```
|
|
34
34
|
*/
|
|
35
35
|
export declare function encryptToken(plaintext: string, event?: RequestEvent): Promise<string>;
|
|
36
36
|
/**
|
|
@@ -38,27 +38,27 @@ export declare function encryptToken(plaintext: string, event?: RequestEvent): P
|
|
|
38
38
|
* returned as-is. Decryption failures resolve to an empty string.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const plaintext = await decryptToken(ciphertext, event)
|
|
43
|
+
* ```
|
|
44
44
|
*/
|
|
45
45
|
export declare function decryptToken(ciphertext: string, event?: RequestEvent): Promise<string>;
|
|
46
46
|
/**
|
|
47
|
-
* Computes an HMAC-SHA256 hex signature using standard Web Crypto.
|
|
48
|
-
*
|
|
47
|
+
* Computes an HMAC-SHA256 hex signature using standard Web Crypto. Used for tamper-proof download
|
|
48
|
+
* URLs, signed query parameters, and webhooks.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const signature = await signHmacSha256("payload-data", event)
|
|
53
|
+
* ```
|
|
54
54
|
*/
|
|
55
55
|
export declare function signHmacSha256(data: string, secretOrEvent?: string | RequestEvent): Promise<string>;
|
|
56
56
|
/**
|
|
57
57
|
* Verifies an HMAC-SHA256 hex signature in constant time.
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* const isValid = await verifyHmacSha256("payload-data", signature, event)
|
|
62
|
+
* ```
|
|
63
63
|
*/
|
|
64
64
|
export declare function verifyHmacSha256(data: string, signature: string, secretOrEvent?: string | RequestEvent): Promise<boolean>;
|
|
@@ -255,7 +255,9 @@ export async function getCustomDomain(rawDomain, event) {
|
|
|
255
255
|
try {
|
|
256
256
|
const db = event?.context?.db;
|
|
257
257
|
if (db) {
|
|
258
|
-
const rows = await db.all(`SELECT * FROM ${domainTbl(event)} WHERE domain = ? LIMIT 1`, [
|
|
258
|
+
const rows = await db.all(`SELECT * FROM ${domainTbl(event)} WHERE domain = ? LIMIT 1`, [
|
|
259
|
+
domain
|
|
260
|
+
]);
|
|
259
261
|
if (rows?.[0]) {
|
|
260
262
|
const row = rows[0];
|
|
261
263
|
const rec = {
|
|
@@ -7,20 +7,16 @@ export interface UseDrizzleOptions<S extends Record<string, unknown> = typeof _s
|
|
|
7
7
|
event?: CFEvent;
|
|
8
8
|
/**
|
|
9
9
|
* Route reads to Cloudflare D1 Read Replicas:
|
|
10
|
+
*
|
|
10
11
|
* - `true`: routes to nearest replica using "first-unconstrained" session
|
|
11
12
|
* - `"first-unconstrained"`: reads from nearest replica immediately
|
|
12
13
|
* - `"first-primary"`: first query routed to primary, subsequent reads routed to replica
|
|
13
14
|
* - `string`: bookmark token string to guarantee sequential consistency
|
|
14
15
|
*/
|
|
15
16
|
replica?: boolean | "first-unconstrained" | "first-primary" | string;
|
|
16
|
-
/**
|
|
17
|
-
* Optional Cloudflare D1 session bookmark token.
|
|
18
|
-
*/
|
|
17
|
+
/** Optional Cloudflare D1 session bookmark token. */
|
|
19
18
|
bookmark?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Automatically fallback to primary database if replica read fails.
|
|
22
|
-
* Default: `true`.
|
|
23
|
-
*/
|
|
19
|
+
/** Automatically fallback to primary database if replica read fails. Default: `true`. */
|
|
24
20
|
fallbackToPrimary?: boolean;
|
|
25
21
|
}
|
|
26
22
|
/** Access a typed Drizzle ORM client connected to Cloudflare D1 or PostgreSQL. */
|
|
@@ -29,24 +25,24 @@ export declare function useDrizzle<S extends Record<string, unknown> = typeof _s
|
|
|
29
25
|
* Primary typed database accessor for Cloudflare D1 or PostgreSQL.
|
|
30
26
|
*
|
|
31
27
|
* @example
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Default primary D1 database
|
|
30
|
+
* const db = useDb()
|
|
31
|
+
* const users = await db.query.users.findMany()
|
|
36
32
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
33
|
+
* // Secondary D1 database (e.g. db/d1-analytics/ or ANALYTICS_DB)
|
|
34
|
+
* const analytics = useDb("analytics")
|
|
39
35
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
36
|
+
* // Cloudflare D1 Read Replica routing (reads route to replica, writes route to primary)
|
|
37
|
+
* const readDb = useDb({ replica: true })
|
|
38
|
+
* const users = await readDb.query.users.findMany()
|
|
43
39
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
40
|
+
* // Named database with read replica and sequential consistency bookmark
|
|
41
|
+
* const analyticsReplica = useDb("analytics", { replica: true, bookmark: "bm_123" })
|
|
46
42
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
43
|
+
* // PostgreSQL via Hyperdrive
|
|
44
|
+
* const warehouse = useDb("postgres")
|
|
45
|
+
* ```
|
|
50
46
|
*/
|
|
51
47
|
export declare function useDb<S extends Record<string, unknown> = typeof _schema>(options?: UseDrizzleOptions<S>): QarpeoDrizzleDB<InferDrizzleRelations<S>>;
|
|
52
48
|
export declare function useDb<S extends Record<string, unknown> = typeof _schema>(bindingName?: string, eventOrOptions?: CFEvent | UseDrizzleOptions<S>): QarpeoDrizzleDB<InferDrizzleRelations<S>>;
|
|
@@ -58,10 +54,13 @@ export declare const d1Db: QarpeoDrizzleDB<import("drizzle-orm").ExtractTablesWi
|
|
|
58
54
|
* Creates a lazily-evaluated Proxy around a named database binding.
|
|
59
55
|
*
|
|
60
56
|
* @example
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* export const d1AnalyticsDb = createDbProxy("analytics")
|
|
59
|
+
* ```
|
|
64
60
|
*/
|
|
65
61
|
export declare function createDbProxy(name?: string): QarpeoDrizzleDB<SchemaRelations>;
|
|
66
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* All exported tables, views, and relations from your schema (e.g. `db/d1/schema/` or
|
|
64
|
+
* `db/schema.ts`).
|
|
65
|
+
*/
|
|
67
66
|
export declare const schema: typeof _schema;
|