qarpeo 0.3.5 → 0.4.1
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/dist/chunks/{tools.mjs → manifest.get.mjs} +229 -3
- package/dist/cli/index.mjs +74 -5
- package/dist/features/console.d.ts +4 -0
- package/dist/module.mjs +299 -57
- package/dist/runtime/app/components/{BlobImage.vue → QImg.vue} +5 -4
- package/dist/runtime/app/composables/console.d.ts +60 -0
- package/dist/runtime/app/composables/console.mjs +169 -0
- package/dist/runtime/app/composables/pwa.d.ts +34 -0
- package/dist/runtime/app/composables/pwa.mjs +86 -0
- package/dist/runtime/app/composables/rbac.d.ts +33 -0
- package/dist/runtime/app/composables/rbac.mjs +60 -0
- package/dist/runtime/app/composables/site.d.ts +73 -0
- package/dist/runtime/app/composables/site.mjs +174 -1
- package/dist/runtime/app/middleware/console.global.d.ts +2 -0
- package/dist/runtime/app/middleware/console.global.mjs +37 -0
- package/dist/runtime/app/plugins/pwa.client.d.ts +2 -0
- package/dist/runtime/app/plugins/pwa.client.mjs +28 -0
- package/dist/runtime/app/plugins/pwa.d.ts +2 -0
- package/dist/runtime/app/plugins/pwa.mjs +42 -0
- package/dist/runtime/app/plugins/seo.mjs +39 -10
- package/dist/runtime/schema.d.ts +32 -12
- package/dist/runtime/schema.mjs +47 -125
- package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.d.ts +13 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.mjs +46 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.d.ts +22 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.mjs +40 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.d.ts +20 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.mjs +52 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.d.ts +26 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.mjs +80 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.d.ts +16 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.mjs +30 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.d.ts +21 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.mjs +49 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.d.ts +22 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.mjs +65 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.d.ts +12 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.mjs +17 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.d.ts +22 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.mjs +87 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.d.ts +25 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.mjs +119 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/users.post.d.ts +19 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/users.post.mjs +86 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.d.ts +21 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.mjs +91 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.d.ts +13 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.mjs +49 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.d.ts +43 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.mjs +111 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/overview.get.d.ts +22 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/overview.get.mjs +44 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.d.ts +9 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.mjs +27 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.d.ts +23 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.mjs +56 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.d.ts +21 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.mjs +50 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.d.ts +12 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.mjs +24 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.d.ts +26 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.mjs +40 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/users.get.d.ts +39 -0
- package/dist/runtime/server/routes/__qarpeo/cloud/users.get.mjs +69 -0
- package/dist/runtime/server/routes/__qarpeo/manifest.get.d.ts +39 -0
- package/dist/runtime/server/routes/__qarpeo/manifest.get.mjs +226 -0
- package/dist/runtime/server/routes/__qarpeo/og.get.d.ts +15 -0
- package/dist/runtime/server/routes/__qarpeo/og.get.mjs +109 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/me.get.d.ts +26 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/me.get.mjs +23 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.d.ts +12 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.mjs +12 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.d.ts +16 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.mjs +15 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.d.ts +11 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.mjs +16 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/users.post.d.ts +14 -0
- package/dist/runtime/server/routes/__qarpeo/rbac/users.post.mjs +19 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.d.ts +2 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.mjs +31 -0
- package/dist/runtime/server/routes/robots.txt.get.mjs +20 -4
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +47 -6
- package/dist/runtime/server/routes/sw.js.get.d.ts +8 -0
- package/dist/runtime/server/routes/sw.js.get.mjs +141 -0
- package/dist/runtime/server/utils/auth.d.ts +2 -14
- package/dist/runtime/server/utils/auth.mjs +32 -36
- package/dist/runtime/server/utils/cloud-auth.d.ts +8 -0
- package/dist/runtime/server/utils/cloud-auth.mjs +23 -0
- package/dist/runtime/server/utils/console.d.ts +19 -0
- package/dist/runtime/server/utils/console.mjs +34 -0
- package/dist/runtime/server/utils/legacy-hash.d.ts +76 -0
- package/dist/runtime/server/utils/legacy-hash.mjs +96 -0
- package/dist/runtime/server/utils/rbac.d.ts +89 -0
- package/dist/runtime/server/utils/rbac.mjs +427 -0
- package/dist/runtime/server/utils/role-env.d.ts +19 -0
- package/dist/runtime/server/utils/role-env.mjs +34 -0
- package/dist/runtime/server.d.ts +2 -0
- package/dist/runtime/server.mjs +2 -0
- package/dist/types/console.d.ts +67 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/options.d.ts +9 -0
- package/dist/types/site.d.ts +102 -0
- package/dist/types/storage.d.ts +5 -11
- package/package.json +1 -1
- package/dist/runtime/providers/qarpeo.d.ts +0 -23
- package/dist/runtime/providers/qarpeo.mjs +0 -46
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from "nuxt/server";
|
|
2
|
+
import { getD1Binding } from "../../../../../index.mjs";
|
|
3
|
+
import { verifyCloudSecret } from "../../../../utils/cloud-auth.mjs";
|
|
4
|
+
import { resolveTableName } from "../../../../utils/table-names.mjs";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
verifyCloudSecret(event);
|
|
7
|
+
const d1 = getD1Binding(event);
|
|
8
|
+
if (!d1) {
|
|
9
|
+
return { ok: false, error: "D1 unavailable", products: [], total: 0 };
|
|
10
|
+
}
|
|
11
|
+
const qs = getQuery(event);
|
|
12
|
+
const page = Math.max(1, parseInt(String(qs.page || "1"), 10));
|
|
13
|
+
const limit = Math.min(100, Math.max(1, parseInt(String(qs.limit || "25"), 10)));
|
|
14
|
+
const q = typeof qs.q === "string" ? qs.q.trim() : "";
|
|
15
|
+
const offset = (page - 1) * limit;
|
|
16
|
+
const productTable = resolveTableName("store_product").replace(/"/g, "");
|
|
17
|
+
try {
|
|
18
|
+
const whereClause = q ? `WHERE title LIKE ?1 OR slug LIKE ?1` : "";
|
|
19
|
+
const bindings = q ? [`%${q}%`] : [];
|
|
20
|
+
const countRow = await d1.prepare(`SELECT COUNT(*) as total FROM "${productTable}" ${whereClause}`).bind(...bindings).first();
|
|
21
|
+
const rows = await d1.prepare(
|
|
22
|
+
`SELECT id, slug, title, status, type, base_price, currency, created_at, updated_at
|
|
23
|
+
FROM "${productTable}"
|
|
24
|
+
${whereClause}
|
|
25
|
+
ORDER BY updated_at DESC
|
|
26
|
+
LIMIT ?${bindings.length + 1} OFFSET ?${bindings.length + 2}`
|
|
27
|
+
).bind(...bindings, limit, offset).all().then((r) => r.results ?? []);
|
|
28
|
+
const total = typeof countRow?.total === "number" ? countRow.total : Number(countRow?.total ?? 0);
|
|
29
|
+
return {
|
|
30
|
+
ok: true,
|
|
31
|
+
products: rows.map((p) => ({
|
|
32
|
+
id: p.id,
|
|
33
|
+
slug: p.slug,
|
|
34
|
+
title: p.title,
|
|
35
|
+
status: p.status,
|
|
36
|
+
type: p.type,
|
|
37
|
+
basePrice: Number(p.base_price ?? 0),
|
|
38
|
+
currency: p.currency || "USD",
|
|
39
|
+
createdAt: p.created_at,
|
|
40
|
+
updatedAt: p.updated_at
|
|
41
|
+
})),
|
|
42
|
+
total,
|
|
43
|
+
page,
|
|
44
|
+
limit,
|
|
45
|
+
pages: Math.ceil(total / limit)
|
|
46
|
+
};
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return { ok: false, error: err?.message || "Query failed", products: [], total: 0 };
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POST /__qarpeo/cloud/tasks/run
|
|
3
|
+
*
|
|
4
|
+
* Manually triggers a Nitro scheduled task by name from Qarpeo Cloud.
|
|
5
|
+
* Requires `Authorization: Bearer <QARPEO_CLOUD_SECRET>`.
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
8
|
+
ok: boolean;
|
|
9
|
+
task: string;
|
|
10
|
+
result: any;
|
|
11
|
+
}>>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createError, defineEventHandler, readBody } from "nuxt/server";
|
|
2
|
+
import { verifyCloudSecret } from "../../../../utils/cloud-auth.mjs";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
verifyCloudSecret(event);
|
|
5
|
+
const body = await readBody(event);
|
|
6
|
+
const taskName = typeof body?.task === "string" ? body.task.trim() : "";
|
|
7
|
+
if (!taskName) {
|
|
8
|
+
throw createError({
|
|
9
|
+
statusCode: 400,
|
|
10
|
+
statusMessage: "Bad Request",
|
|
11
|
+
message: "task name is required."
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const runTask = event.$runTask || event.context?.nitro?.runTask || globalThis.__nitro?.runTask;
|
|
15
|
+
if (typeof runTask !== "function") {
|
|
16
|
+
throw createError({
|
|
17
|
+
statusCode: 501,
|
|
18
|
+
statusMessage: "Not Implemented",
|
|
19
|
+
message: "Nitro task runner is not available on this Worker."
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const result = await runTask(taskName, { payload: body?.payload ?? {} });
|
|
23
|
+
return { ok: true, task: taskName, result };
|
|
24
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POST /__qarpeo/cloud/users/action
|
|
3
|
+
* Body: `{ userId: string, action: "set-role" | "ban" | "unban" | "revoke-sessions", role?: string }`
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
6
|
+
ok: boolean;
|
|
7
|
+
userId: string;
|
|
8
|
+
action: "revoke-sessions";
|
|
9
|
+
role?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
userId: string;
|
|
13
|
+
action: "ban";
|
|
14
|
+
role: string;
|
|
15
|
+
} | {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
userId: string;
|
|
18
|
+
action: "unban";
|
|
19
|
+
role: string;
|
|
20
|
+
} | {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
userId: string;
|
|
23
|
+
action: "set-role" | undefined;
|
|
24
|
+
role: string;
|
|
25
|
+
}>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createError, defineEventHandler, readBody } from "nuxt/server";
|
|
2
|
+
import { getD1Binding } from "../../../../../index.mjs";
|
|
3
|
+
import { verifyCloudSecret } from "../../../../utils/cloud-auth.mjs";
|
|
4
|
+
import { resolveTableName } from "../../../../utils/table-names.mjs";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
verifyCloudSecret(event);
|
|
7
|
+
const body = await readBody(event);
|
|
8
|
+
const userId = typeof body?.userId === "string" ? body.userId.trim() : "";
|
|
9
|
+
const action = body?.action;
|
|
10
|
+
if (!userId || !["set-role", "ban", "unban", "revoke-sessions"].includes(action ?? "")) {
|
|
11
|
+
throw createError({
|
|
12
|
+
statusCode: 400,
|
|
13
|
+
statusMessage: "Bad Request",
|
|
14
|
+
message: "userId and action (set-role | ban | unban | revoke-sessions) are required."
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const d1 = getD1Binding(event);
|
|
18
|
+
if (!d1) {
|
|
19
|
+
throw createError({ statusCode: 500, statusMessage: "Internal Server Error", message: "D1 unavailable" });
|
|
20
|
+
}
|
|
21
|
+
const userTable = resolveTableName("user").replace(/"/g, "");
|
|
22
|
+
const sessionTable = resolveTableName("session").replace(/"/g, "");
|
|
23
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
24
|
+
if (action === "revoke-sessions") {
|
|
25
|
+
await d1.prepare(`DELETE FROM "${sessionTable}" WHERE user_id = ?1`).bind(userId).run();
|
|
26
|
+
return { ok: true, userId, action };
|
|
27
|
+
}
|
|
28
|
+
if (action === "ban") {
|
|
29
|
+
await d1.prepare(`UPDATE "${userTable}" SET role = 'banned', updated_at = ?1 WHERE id = ?2`).bind(now, userId).run();
|
|
30
|
+
await d1.prepare(`DELETE FROM "${sessionTable}" WHERE user_id = ?1`).bind(userId).run();
|
|
31
|
+
return { ok: true, userId, action, role: "banned" };
|
|
32
|
+
}
|
|
33
|
+
if (action === "unban") {
|
|
34
|
+
await d1.prepare(`UPDATE "${userTable}" SET role = 'user', updated_at = ?1 WHERE id = ?2`).bind(now, userId).run();
|
|
35
|
+
return { ok: true, userId, action, role: "user" };
|
|
36
|
+
}
|
|
37
|
+
const role = typeof body?.role === "string" && body.role.trim() ? body.role.trim() : "user";
|
|
38
|
+
await d1.prepare(`UPDATE "${userTable}" SET role = ?1, updated_at = ?2 WHERE id = ?3`).bind(role, now, userId).run();
|
|
39
|
+
return { ok: true, userId, action, role };
|
|
40
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GET /__qarpeo/cloud/users
|
|
3
|
+
*
|
|
4
|
+
* Returns a paginated list of auth users for the Qarpeo Cloud Auth Dashboard.
|
|
5
|
+
* Requires `Authorization: Bearer <QARPEO_CLOUD_SECRET>`.
|
|
6
|
+
*
|
|
7
|
+
* Query params:
|
|
8
|
+
* - page (default 1)
|
|
9
|
+
* - limit (default 25, max 100)
|
|
10
|
+
* - q (optional email/name search substring)
|
|
11
|
+
*/
|
|
12
|
+
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
13
|
+
ok: boolean;
|
|
14
|
+
users: {
|
|
15
|
+
id: any;
|
|
16
|
+
name: any;
|
|
17
|
+
email: any;
|
|
18
|
+
emailVerified: boolean;
|
|
19
|
+
role: any;
|
|
20
|
+
provider: any;
|
|
21
|
+
sessionCount: number;
|
|
22
|
+
createdAt: any;
|
|
23
|
+
updatedAt: any;
|
|
24
|
+
}[];
|
|
25
|
+
total: any;
|
|
26
|
+
page: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
pages: number;
|
|
29
|
+
error?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
ok: boolean;
|
|
32
|
+
error: any;
|
|
33
|
+
users: never[];
|
|
34
|
+
total: number;
|
|
35
|
+
page?: undefined;
|
|
36
|
+
limit?: undefined;
|
|
37
|
+
pages?: undefined;
|
|
38
|
+
}>>;
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from "nuxt/server";
|
|
2
|
+
import { getD1Binding } from "../../../../index.mjs";
|
|
3
|
+
import { verifyCloudSecret } from "../../../utils/cloud-auth.mjs";
|
|
4
|
+
import { resolveTableName } from "../../../utils/table-names.mjs";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
verifyCloudSecret(event);
|
|
7
|
+
const d1 = getD1Binding(event);
|
|
8
|
+
if (!d1) {
|
|
9
|
+
return { ok: false, error: "D1 binding not available", users: [], total: 0 };
|
|
10
|
+
}
|
|
11
|
+
const qs = getQuery(event);
|
|
12
|
+
const page = Math.max(1, parseInt(String(qs.page || "1"), 10));
|
|
13
|
+
const limit = Math.min(100, Math.max(1, parseInt(String(qs.limit || "25"), 10)));
|
|
14
|
+
const q = typeof qs.q === "string" ? qs.q.trim() : "";
|
|
15
|
+
const offset = (page - 1) * limit;
|
|
16
|
+
const userTable = resolveTableName("user").replace(/"/g, "");
|
|
17
|
+
const sessionTable = resolveTableName("session").replace(/"/g, "");
|
|
18
|
+
const accountTable = resolveTableName("account").replace(/"/g, "");
|
|
19
|
+
try {
|
|
20
|
+
let countRow;
|
|
21
|
+
let rows;
|
|
22
|
+
if (q) {
|
|
23
|
+
const pattern = `%${q}%`;
|
|
24
|
+
countRow = await d1.prepare(
|
|
25
|
+
`SELECT COUNT(*) as total FROM "${userTable}" WHERE email LIKE ?1 OR name LIKE ?1`
|
|
26
|
+
).bind(pattern).first();
|
|
27
|
+
rows = await d1.prepare(
|
|
28
|
+
`SELECT u.id, u.name, u.email, u.email_verified, u.role, u.created_at, u.updated_at,
|
|
29
|
+
(SELECT COUNT(*) FROM "${sessionTable}" s WHERE s.user_id = u.id) as session_count,
|
|
30
|
+
(SELECT provider_id FROM "${accountTable}" a WHERE a.user_id = u.id LIMIT 1) as provider
|
|
31
|
+
FROM "${userTable}" u
|
|
32
|
+
WHERE u.email LIKE ?1 OR u.name LIKE ?1
|
|
33
|
+
ORDER BY u.created_at DESC
|
|
34
|
+
LIMIT ?2 OFFSET ?3`
|
|
35
|
+
).bind(pattern, limit, offset).all().then((r) => r.results ?? []);
|
|
36
|
+
} else {
|
|
37
|
+
countRow = await d1.prepare(`SELECT COUNT(*) as total FROM "${userTable}"`).first();
|
|
38
|
+
rows = await d1.prepare(
|
|
39
|
+
`SELECT u.id, u.name, u.email, u.email_verified, u.role, u.created_at, u.updated_at,
|
|
40
|
+
(SELECT COUNT(*) FROM "${sessionTable}" s WHERE s.user_id = u.id) as session_count,
|
|
41
|
+
(SELECT provider_id FROM "${accountTable}" a WHERE a.user_id = u.id LIMIT 1) as provider
|
|
42
|
+
FROM "${userTable}" u
|
|
43
|
+
ORDER BY u.created_at DESC
|
|
44
|
+
LIMIT ?1 OFFSET ?2`
|
|
45
|
+
).bind(limit, offset).all().then((r) => r.results ?? []);
|
|
46
|
+
}
|
|
47
|
+
const total = typeof countRow?.total === "number" ? countRow.total : Number(countRow?.total ?? 0);
|
|
48
|
+
return {
|
|
49
|
+
ok: true,
|
|
50
|
+
users: rows.map((u) => ({
|
|
51
|
+
id: u.id,
|
|
52
|
+
name: u.name,
|
|
53
|
+
email: u.email,
|
|
54
|
+
emailVerified: Boolean(u.email_verified),
|
|
55
|
+
role: u.role,
|
|
56
|
+
provider: u.provider || "credential",
|
|
57
|
+
sessionCount: Number(u.session_count ?? 0),
|
|
58
|
+
createdAt: u.created_at,
|
|
59
|
+
updatedAt: u.updated_at
|
|
60
|
+
})),
|
|
61
|
+
total,
|
|
62
|
+
page,
|
|
63
|
+
limit,
|
|
64
|
+
pages: Math.ceil(total / limit)
|
|
65
|
+
};
|
|
66
|
+
} catch (err) {
|
|
67
|
+
return { ok: false, error: err?.message || "Query failed", users: [], total: 0 };
|
|
68
|
+
}
|
|
69
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { QarpeoOptions } from "../../../../types";
|
|
2
|
+
export interface ManifestBindingSpec {
|
|
3
|
+
type: "d1" | "kv_namespace" | "r2_bucket" | "ai" | "vectorize" | "queue" | "hyperdrive" | "durable_object_namespace" | "browser" | "analytics_engine";
|
|
4
|
+
name: string;
|
|
5
|
+
feature: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ManifestSecretSpec {
|
|
9
|
+
key: string;
|
|
10
|
+
feature: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
description: string;
|
|
13
|
+
generatable?: "secret" | "vapid";
|
|
14
|
+
}
|
|
15
|
+
export interface QarpeoCloudManifest {
|
|
16
|
+
qarpeoVersion: string;
|
|
17
|
+
workerName: string | null;
|
|
18
|
+
features: Record<string, boolean>;
|
|
19
|
+
expectedBindings: ManifestBindingSpec[];
|
|
20
|
+
expectedSecrets: ManifestSecretSpec[];
|
|
21
|
+
endpoints: {
|
|
22
|
+
robots?: string;
|
|
23
|
+
sitemap?: string;
|
|
24
|
+
manifest?: string;
|
|
25
|
+
sw?: string;
|
|
26
|
+
og?: string;
|
|
27
|
+
};
|
|
28
|
+
liveEnvPresence?: {
|
|
29
|
+
bindings: Record<string, boolean>;
|
|
30
|
+
secrets: Record<string, boolean>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Builds a safe, secret-free structural manifest of Qarpeo features, expected Cloudflare
|
|
35
|
+
* bindings, expected secret keys, and well-known endpoints for Qarpeo Cloud inspection.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildQarpeoManifest(options: QarpeoOptions, qarpeoVersion?: string): QarpeoCloudManifest;
|
|
38
|
+
declare const _default: import("nuxt/server").EventHandler<Response>;
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { defineEventHandler, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
export function buildQarpeoManifest(options, qarpeoVersion = "0.0.0") {
|
|
3
|
+
const opts = options;
|
|
4
|
+
const hasDb = Boolean(opts.db || opts.d1);
|
|
5
|
+
const hasKv = Boolean(opts.kv);
|
|
6
|
+
const hasBlob = Boolean(opts.blob || opts.r2);
|
|
7
|
+
const hasAi = Boolean(opts.ai);
|
|
8
|
+
const hasVectorize = Boolean(opts.vectorize);
|
|
9
|
+
const hasQueue = Boolean(opts.queue);
|
|
10
|
+
const hasHyperdrive = Boolean(opts.hyperdrive);
|
|
11
|
+
const hasBrowser = Boolean(opts.browser);
|
|
12
|
+
const hasAnalytics = Boolean(opts.analytics);
|
|
13
|
+
const hasDo = Boolean(opts.do || opts.agents);
|
|
14
|
+
const hasAuth = Boolean(opts.auth);
|
|
15
|
+
const hasEmail = Boolean(opts.email || opts.mail);
|
|
16
|
+
const hasPayments = Boolean(opts.payments);
|
|
17
|
+
const hasNotifications = Boolean(opts.notifications || opts.notify);
|
|
18
|
+
const hasComments = Boolean(opts.comments);
|
|
19
|
+
const hasCms = Boolean(opts.cms);
|
|
20
|
+
const hasStore = Boolean(opts.store);
|
|
21
|
+
const hasAgents = Boolean(opts.agents);
|
|
22
|
+
const hasMultitenant = Boolean(opts.multitenant);
|
|
23
|
+
const hasSite = Boolean(opts.site || opts.seo);
|
|
24
|
+
const hasPwa = Boolean(opts.pwa || typeof opts.site === "object" && opts.site?.pwa);
|
|
25
|
+
const features = {
|
|
26
|
+
db: hasDb,
|
|
27
|
+
kv: hasKv,
|
|
28
|
+
blob: hasBlob,
|
|
29
|
+
ai: hasAi,
|
|
30
|
+
vectorize: hasVectorize,
|
|
31
|
+
queue: hasQueue,
|
|
32
|
+
workflows: Boolean(opts.workflows),
|
|
33
|
+
hyperdrive: hasHyperdrive,
|
|
34
|
+
browser: hasBrowser,
|
|
35
|
+
analytics: hasAnalytics,
|
|
36
|
+
ratelimit: Boolean(opts.ratelimit),
|
|
37
|
+
do: hasDo,
|
|
38
|
+
auth: hasAuth,
|
|
39
|
+
email: hasEmail,
|
|
40
|
+
payments: hasPayments,
|
|
41
|
+
notifications: hasNotifications,
|
|
42
|
+
comments: hasComments,
|
|
43
|
+
cms: hasCms,
|
|
44
|
+
store: hasStore,
|
|
45
|
+
agents: hasAgents,
|
|
46
|
+
multitenant: hasMultitenant,
|
|
47
|
+
site: hasSite,
|
|
48
|
+
pwa: hasPwa
|
|
49
|
+
};
|
|
50
|
+
const expectedBindings = [];
|
|
51
|
+
if (hasDb) {
|
|
52
|
+
expectedBindings.push({
|
|
53
|
+
type: "d1",
|
|
54
|
+
name: typeof opts.db === "object" && opts.db.binding ? opts.db.binding : "DB",
|
|
55
|
+
feature: "db",
|
|
56
|
+
required: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (hasKv) {
|
|
60
|
+
expectedBindings.push({
|
|
61
|
+
type: "kv_namespace",
|
|
62
|
+
name: typeof opts.kv === "object" && opts.kv.binding ? opts.kv.binding : "KV",
|
|
63
|
+
feature: "kv",
|
|
64
|
+
required: true
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (hasBlob) {
|
|
68
|
+
expectedBindings.push({
|
|
69
|
+
type: "r2_bucket",
|
|
70
|
+
name: typeof opts.blob === "object" && opts.blob.binding ? opts.blob.binding : "BLOB",
|
|
71
|
+
feature: "blob",
|
|
72
|
+
required: true
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (hasAi) {
|
|
76
|
+
expectedBindings.push({ type: "ai", name: "AI", feature: "ai", required: true });
|
|
77
|
+
}
|
|
78
|
+
if (hasVectorize) {
|
|
79
|
+
expectedBindings.push({
|
|
80
|
+
type: "vectorize",
|
|
81
|
+
name: typeof opts.vectorize === "object" && opts.vectorize.binding ? opts.vectorize.binding : "VECTORIZE",
|
|
82
|
+
feature: "vectorize",
|
|
83
|
+
required: true
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (hasQueue) {
|
|
87
|
+
expectedBindings.push({
|
|
88
|
+
type: "queue",
|
|
89
|
+
name: typeof opts.queue === "object" && opts.queue.binding ? opts.queue.binding : "QUEUE",
|
|
90
|
+
feature: "queue",
|
|
91
|
+
required: true
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (hasHyperdrive) {
|
|
95
|
+
expectedBindings.push({
|
|
96
|
+
type: "hyperdrive",
|
|
97
|
+
name: typeof opts.hyperdrive === "object" && opts.hyperdrive.binding ? opts.hyperdrive.binding : "HYPERDRIVE",
|
|
98
|
+
feature: "hyperdrive",
|
|
99
|
+
required: true
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (hasBrowser) {
|
|
103
|
+
expectedBindings.push({
|
|
104
|
+
type: "browser",
|
|
105
|
+
name: "BROWSER",
|
|
106
|
+
feature: "browser",
|
|
107
|
+
required: false
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (hasAnalytics) {
|
|
111
|
+
expectedBindings.push({
|
|
112
|
+
type: "analytics_engine",
|
|
113
|
+
name: "ANALYTICS",
|
|
114
|
+
feature: "analytics",
|
|
115
|
+
required: false
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const expectedSecrets = [];
|
|
119
|
+
if (hasAuth || hasBlob || hasStore) {
|
|
120
|
+
expectedSecrets.push({
|
|
121
|
+
key: "NUXT_APP_SECRET",
|
|
122
|
+
feature: hasAuth ? "auth" : hasBlob ? "blob" : "store",
|
|
123
|
+
required: true,
|
|
124
|
+
description: "Signing secret for auth sessions, preview tokens, and signed R2 URLs.",
|
|
125
|
+
generatable: "secret"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (hasNotifications) {
|
|
129
|
+
expectedSecrets.push(
|
|
130
|
+
{
|
|
131
|
+
key: "VAPID_PUBLIC_KEY",
|
|
132
|
+
feature: "notifications",
|
|
133
|
+
required: false,
|
|
134
|
+
description: "Web Push VAPID public key.",
|
|
135
|
+
generatable: "vapid"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
key: "VAPID_PRIVATE_KEY",
|
|
139
|
+
feature: "notifications",
|
|
140
|
+
required: false,
|
|
141
|
+
description: "Web Push VAPID private key.",
|
|
142
|
+
generatable: "vapid"
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
if (hasPayments) {
|
|
147
|
+
expectedSecrets.push(
|
|
148
|
+
{
|
|
149
|
+
key: "STRIPE_SECRET_KEY",
|
|
150
|
+
feature: "payments",
|
|
151
|
+
required: true,
|
|
152
|
+
description: "Stripe API secret key for checkout & portal."
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: "STRIPE_WEBHOOK_SECRET",
|
|
156
|
+
feature: "payments",
|
|
157
|
+
required: true,
|
|
158
|
+
description: "Stripe webhook signing secret."
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (hasEmail) {
|
|
163
|
+
expectedSecrets.push({
|
|
164
|
+
key: "RESEND_API_KEY",
|
|
165
|
+
feature: "email",
|
|
166
|
+
required: false,
|
|
167
|
+
description: "Transactional email provider API key (when not using CF Email Routing)."
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const endpoints = {};
|
|
171
|
+
if (hasSite) {
|
|
172
|
+
endpoints.robots = "/robots.txt";
|
|
173
|
+
endpoints.sitemap = "/sitemap.xml";
|
|
174
|
+
endpoints.og = "/__qarpeo/og";
|
|
175
|
+
}
|
|
176
|
+
if (hasPwa) {
|
|
177
|
+
endpoints.manifest = "/manifest.webmanifest";
|
|
178
|
+
endpoints.sw = "/sw.js";
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
qarpeoVersion,
|
|
182
|
+
workerName: typeof opts.workerName === "string" ? opts.workerName : null,
|
|
183
|
+
features,
|
|
184
|
+
expectedBindings,
|
|
185
|
+
expectedSecrets,
|
|
186
|
+
endpoints
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export default defineEventHandler((event) => {
|
|
190
|
+
const config = useRuntimeConfig();
|
|
191
|
+
const baseManifest = config.qarpeo?.manifest;
|
|
192
|
+
const cfEnv = event.context?.cloudflare?.env;
|
|
193
|
+
const manifest = baseManifest || {
|
|
194
|
+
qarpeoVersion: config.public?.qarpeoVersion || "0.0.0",
|
|
195
|
+
workerName: null,
|
|
196
|
+
features: {},
|
|
197
|
+
expectedBindings: [],
|
|
198
|
+
expectedSecrets: [],
|
|
199
|
+
endpoints: {}
|
|
200
|
+
};
|
|
201
|
+
const bindingPresence = {};
|
|
202
|
+
for (const b of manifest.expectedBindings) {
|
|
203
|
+
bindingPresence[b.name] = Boolean(cfEnv && b.name in cfEnv && cfEnv[b.name] !== void 0);
|
|
204
|
+
}
|
|
205
|
+
const secretPresence = {};
|
|
206
|
+
for (const s of manifest.expectedSecrets) {
|
|
207
|
+
secretPresence[s.key] = Boolean(
|
|
208
|
+
cfEnv && typeof cfEnv[s.key] === "string" && cfEnv[s.key].length > 0 || typeof process !== "undefined" && typeof process.env?.[s.key] === "string" && process.env[s.key].length > 0
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
return new Response(
|
|
212
|
+
JSON.stringify({
|
|
213
|
+
...manifest,
|
|
214
|
+
liveEnvPresence: {
|
|
215
|
+
bindings: bindingPresence,
|
|
216
|
+
secrets: secretPresence
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
{
|
|
220
|
+
headers: {
|
|
221
|
+
"Content-Type": "application/json; charset=UTF-8",
|
|
222
|
+
"Cache-Control": "no-store"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface BuildOgSvgOptions {
|
|
2
|
+
title: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
siteName?: string;
|
|
5
|
+
theme?: "dark" | "light" | "gradient";
|
|
6
|
+
themeColor?: string;
|
|
7
|
+
author?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Generates a zero-dependency 1200x630 SVG OpenGraph social card.
|
|
11
|
+
* Used as the edge fallback when Cloudflare Browser Rendering (`browser: true`) is not bound.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildOgSvg(opts: BuildOgSvgOptions): string;
|
|
14
|
+
declare const _default: import("nuxt/server").EventHandler<Promise<Response>>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { renderOgSocialCard } from "../../utils/browser-utils.mjs";
|
|
3
|
+
function escapeXml(str) {
|
|
4
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5
|
+
}
|
|
6
|
+
function wrapText(text, maxChars, maxLines) {
|
|
7
|
+
const words = text.trim().split(/\s+/).filter(Boolean);
|
|
8
|
+
const lines = [];
|
|
9
|
+
let current = "";
|
|
10
|
+
for (const word of words) {
|
|
11
|
+
const candidate = current ? `${current} ${word}` : word;
|
|
12
|
+
if (candidate.length <= maxChars) {
|
|
13
|
+
current = candidate;
|
|
14
|
+
} else {
|
|
15
|
+
if (current) lines.push(current);
|
|
16
|
+
current = word;
|
|
17
|
+
if (lines.length >= maxLines) break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (current && lines.length < maxLines) {
|
|
21
|
+
lines.push(current);
|
|
22
|
+
}
|
|
23
|
+
if (lines.length === maxLines && words.join(" ").length > lines.join(" ").length) {
|
|
24
|
+
lines[maxLines - 1] = `${lines[maxLines - 1].slice(0, Math.max(0, maxChars - 1))}\u2026`;
|
|
25
|
+
}
|
|
26
|
+
return lines;
|
|
27
|
+
}
|
|
28
|
+
export function buildOgSvg(opts) {
|
|
29
|
+
const theme = opts.theme || "dark";
|
|
30
|
+
const accent = opts.themeColor || "#3b82f6";
|
|
31
|
+
const bg = theme === "light" ? "#ffffff" : "#090d16";
|
|
32
|
+
const fg = theme === "light" ? "#0f172a" : "#f8fafc";
|
|
33
|
+
const muted = theme === "light" ? "#64748b" : "#94a3b8";
|
|
34
|
+
const border = theme === "light" ? "#e2e8f0" : "rgba(255,255,255,0.12)";
|
|
35
|
+
const titleLines = wrapText(opts.title || "Qarpeo", 32, 3);
|
|
36
|
+
const descLines = opts.description ? wrapText(opts.description, 62, 2) : [];
|
|
37
|
+
const gradientDef = theme === "gradient" ? `<linearGradient id="bg-grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
38
|
+
<stop offset="0%" stop-color="#090d16"/>
|
|
39
|
+
<stop offset="50%" stop-color="#1e1b4b"/>
|
|
40
|
+
<stop offset="100%" stop-color="#0f172a"/>
|
|
41
|
+
</linearGradient>` : "";
|
|
42
|
+
const titleSvg = titleLines.map(
|
|
43
|
+
(line, i) => `<text x="72" y="${230 + i * 68}" fill="${fg}" font-size="54" font-weight="800" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif">${escapeXml(line)}</text>`
|
|
44
|
+
).join("\n ");
|
|
45
|
+
const descY = 230 + titleLines.length * 68 + 20;
|
|
46
|
+
const descSvg = descLines.map(
|
|
47
|
+
(line, i) => `<text x="72" y="${descY + i * 36}" fill="${muted}" font-size="26" font-weight="400" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif">${escapeXml(line)}</text>`
|
|
48
|
+
).join("\n ");
|
|
49
|
+
const siteBadge = opts.siteName ? `<rect x="72" y="64" width="${Math.max(120, opts.siteName.length * 14 + 36)}" height="42" rx="21" fill="${accent}" fill-opacity="0.16" stroke="${accent}" stroke-opacity="0.4"/>
|
|
50
|
+
<text x="92" y="92" fill="${accent}" font-size="20" font-weight="700" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif">${escapeXml(opts.siteName)}</text>` : "";
|
|
51
|
+
const authorSvg = opts.author ? `<text x="72" y="562" fill="${muted}" font-size="22" font-weight="500" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif">${escapeXml(opts.author)}</text>` : "";
|
|
52
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630">
|
|
53
|
+
<defs>${gradientDef}</defs>
|
|
54
|
+
<rect width="1200" height="630" fill="${theme === "gradient" ? "url(#bg-grad)" : bg}"/>
|
|
55
|
+
<rect x="24" y="24" width="1152" height="582" rx="20" fill="none" stroke="${border}" stroke-width="2"/>
|
|
56
|
+
<circle cx="1100" cy="90" r="180" fill="${accent}" fill-opacity="0.12"/>
|
|
57
|
+
${siteBadge}
|
|
58
|
+
${titleSvg}
|
|
59
|
+
${descSvg}
|
|
60
|
+
${authorSvg}
|
|
61
|
+
</svg>`;
|
|
62
|
+
}
|
|
63
|
+
export default defineEventHandler(async (event) => {
|
|
64
|
+
const rc = useRuntimeConfig(event) || globalThis.__NUXT_RUNTIME_CONFIG__ || {};
|
|
65
|
+
const site = rc.public?.qarpeo?.site || {};
|
|
66
|
+
const ogCfg = typeof site.ogImage === "object" ? site.ogImage : {};
|
|
67
|
+
const q = getQuery(event);
|
|
68
|
+
const title = q.title || site.name || "Qarpeo";
|
|
69
|
+
const description = q.description ?? site.description ?? "";
|
|
70
|
+
const siteName = q.siteName ?? site.name ?? "";
|
|
71
|
+
const theme = q.theme || ogCfg.theme || "dark";
|
|
72
|
+
const themeColor = q.themeColor || ogCfg.themeColor || "#3b82f6";
|
|
73
|
+
const logoUrl = q.logo || ogCfg.logo;
|
|
74
|
+
const author = q.author;
|
|
75
|
+
const maxAge = ogCfg.cacheMaxAge ?? 86400;
|
|
76
|
+
const cacheHeader = `public, max-age=${maxAge}, s-maxage=604800`;
|
|
77
|
+
try {
|
|
78
|
+
const result = await renderOgSocialCard({
|
|
79
|
+
title,
|
|
80
|
+
description,
|
|
81
|
+
siteName,
|
|
82
|
+
theme,
|
|
83
|
+
themeColor,
|
|
84
|
+
logoUrl,
|
|
85
|
+
author: author ? { name: author } : void 0
|
|
86
|
+
});
|
|
87
|
+
return new Response(result.data, {
|
|
88
|
+
headers: {
|
|
89
|
+
"Content-Type": result.contentType || "image/png",
|
|
90
|
+
"Cache-Control": cacheHeader
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
} catch {
|
|
94
|
+
const svg = buildOgSvg({
|
|
95
|
+
title,
|
|
96
|
+
description,
|
|
97
|
+
siteName,
|
|
98
|
+
theme,
|
|
99
|
+
themeColor,
|
|
100
|
+
author
|
|
101
|
+
});
|
|
102
|
+
return new Response(svg, {
|
|
103
|
+
headers: {
|
|
104
|
+
"Content-Type": "image/svg+xml; charset=UTF-8",
|
|
105
|
+
"Cache-Control": cacheHeader
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|