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.
Files changed (106) hide show
  1. package/dist/chunks/{tools.mjs → manifest.get.mjs} +229 -3
  2. package/dist/cli/index.mjs +74 -5
  3. package/dist/features/console.d.ts +4 -0
  4. package/dist/module.mjs +299 -57
  5. package/dist/runtime/app/components/{BlobImage.vue → QImg.vue} +5 -4
  6. package/dist/runtime/app/composables/console.d.ts +60 -0
  7. package/dist/runtime/app/composables/console.mjs +169 -0
  8. package/dist/runtime/app/composables/pwa.d.ts +34 -0
  9. package/dist/runtime/app/composables/pwa.mjs +86 -0
  10. package/dist/runtime/app/composables/rbac.d.ts +33 -0
  11. package/dist/runtime/app/composables/rbac.mjs +60 -0
  12. package/dist/runtime/app/composables/site.d.ts +73 -0
  13. package/dist/runtime/app/composables/site.mjs +174 -1
  14. package/dist/runtime/app/middleware/console.global.d.ts +2 -0
  15. package/dist/runtime/app/middleware/console.global.mjs +37 -0
  16. package/dist/runtime/app/plugins/pwa.client.d.ts +2 -0
  17. package/dist/runtime/app/plugins/pwa.client.mjs +28 -0
  18. package/dist/runtime/app/plugins/pwa.d.ts +2 -0
  19. package/dist/runtime/app/plugins/pwa.mjs +42 -0
  20. package/dist/runtime/app/plugins/seo.mjs +39 -10
  21. package/dist/runtime/schema.d.ts +32 -12
  22. package/dist/runtime/schema.mjs +47 -125
  23. package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.d.ts +13 -0
  24. package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.mjs +46 -0
  25. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.d.ts +22 -0
  26. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.mjs +40 -0
  27. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.d.ts +20 -0
  28. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.mjs +52 -0
  29. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.d.ts +26 -0
  30. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.mjs +80 -0
  31. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.d.ts +16 -0
  32. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.mjs +30 -0
  33. package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.d.ts +21 -0
  34. package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.mjs +49 -0
  35. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.d.ts +22 -0
  36. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.mjs +65 -0
  37. package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.d.ts +12 -0
  38. package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.mjs +17 -0
  39. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.d.ts +22 -0
  40. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.mjs +87 -0
  41. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.d.ts +25 -0
  42. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.mjs +119 -0
  43. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/users.post.d.ts +19 -0
  44. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/users.post.mjs +86 -0
  45. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.d.ts +21 -0
  46. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.mjs +91 -0
  47. package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.d.ts +13 -0
  48. package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.mjs +49 -0
  49. package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.d.ts +43 -0
  50. package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.mjs +111 -0
  51. package/dist/runtime/server/routes/__qarpeo/cloud/overview.get.d.ts +22 -0
  52. package/dist/runtime/server/routes/__qarpeo/cloud/overview.get.mjs +44 -0
  53. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.d.ts +9 -0
  54. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.mjs +27 -0
  55. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.d.ts +23 -0
  56. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.mjs +56 -0
  57. package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.d.ts +21 -0
  58. package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.mjs +50 -0
  59. package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.d.ts +12 -0
  60. package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.mjs +24 -0
  61. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.d.ts +26 -0
  62. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.mjs +40 -0
  63. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.d.ts +39 -0
  64. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.mjs +69 -0
  65. package/dist/runtime/server/routes/__qarpeo/manifest.get.d.ts +39 -0
  66. package/dist/runtime/server/routes/__qarpeo/manifest.get.mjs +226 -0
  67. package/dist/runtime/server/routes/__qarpeo/og.get.d.ts +15 -0
  68. package/dist/runtime/server/routes/__qarpeo/og.get.mjs +109 -0
  69. package/dist/runtime/server/routes/__qarpeo/rbac/me.get.d.ts +26 -0
  70. package/dist/runtime/server/routes/__qarpeo/rbac/me.get.mjs +23 -0
  71. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.d.ts +12 -0
  72. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.mjs +12 -0
  73. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.d.ts +16 -0
  74. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.mjs +15 -0
  75. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.d.ts +11 -0
  76. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.mjs +16 -0
  77. package/dist/runtime/server/routes/__qarpeo/rbac/users.post.d.ts +14 -0
  78. package/dist/runtime/server/routes/__qarpeo/rbac/users.post.mjs +19 -0
  79. package/dist/runtime/server/routes/manifest.webmanifest.get.d.ts +2 -0
  80. package/dist/runtime/server/routes/manifest.webmanifest.get.mjs +31 -0
  81. package/dist/runtime/server/routes/robots.txt.get.mjs +20 -4
  82. package/dist/runtime/server/routes/sitemap.xml.get.mjs +47 -6
  83. package/dist/runtime/server/routes/sw.js.get.d.ts +8 -0
  84. package/dist/runtime/server/routes/sw.js.get.mjs +141 -0
  85. package/dist/runtime/server/utils/auth.d.ts +2 -14
  86. package/dist/runtime/server/utils/auth.mjs +32 -36
  87. package/dist/runtime/server/utils/cloud-auth.d.ts +8 -0
  88. package/dist/runtime/server/utils/cloud-auth.mjs +23 -0
  89. package/dist/runtime/server/utils/console.d.ts +19 -0
  90. package/dist/runtime/server/utils/console.mjs +34 -0
  91. package/dist/runtime/server/utils/legacy-hash.d.ts +76 -0
  92. package/dist/runtime/server/utils/legacy-hash.mjs +96 -0
  93. package/dist/runtime/server/utils/rbac.d.ts +89 -0
  94. package/dist/runtime/server/utils/rbac.mjs +427 -0
  95. package/dist/runtime/server/utils/role-env.d.ts +19 -0
  96. package/dist/runtime/server/utils/role-env.mjs +34 -0
  97. package/dist/runtime/server.d.ts +2 -0
  98. package/dist/runtime/server.mjs +2 -0
  99. package/dist/types/console.d.ts +67 -0
  100. package/dist/types/index.d.ts +1 -0
  101. package/dist/types/options.d.ts +9 -0
  102. package/dist/types/site.d.ts +102 -0
  103. package/dist/types/storage.d.ts +5 -11
  104. package/package.json +1 -1
  105. package/dist/runtime/providers/qarpeo.d.ts +0 -23
  106. package/dist/runtime/providers/qarpeo.mjs +0 -46
@@ -0,0 +1,169 @@
1
+ import { useRuntimeConfig } from "nuxt/app";
2
+ import { computed } from "vue";
3
+ import { usePermissions } from "./rbac.mjs";
4
+ export function normalizeConsolePrefix(prefix) {
5
+ const raw = (prefix || "/console").trim();
6
+ if (!raw || raw === "/") return "/console";
7
+ const withLeading = raw.startsWith("/") ? raw : `/${raw}`;
8
+ return withLeading.replace(/\/+$/, "");
9
+ }
10
+ export function buildDefaultConsoleNav(prefix = "/console", features = {}) {
11
+ const base = normalizeConsolePrefix(prefix);
12
+ const items = [
13
+ {
14
+ id: "overview",
15
+ label: "Overview",
16
+ to: base,
17
+ icon: "lucide:layout-dashboard",
18
+ permission: "console:access",
19
+ module: "console",
20
+ order: 10
21
+ }
22
+ ];
23
+ if (features.cms) {
24
+ items.push({
25
+ id: "cms",
26
+ label: "CMS",
27
+ to: `${base}/cms`,
28
+ icon: "lucide:file-text",
29
+ permission: "cms:read",
30
+ module: "cms",
31
+ order: 20
32
+ });
33
+ }
34
+ if (features.store) {
35
+ items.push({
36
+ id: "store",
37
+ label: "Store",
38
+ to: `${base}/store`,
39
+ icon: "lucide:shopping-bag",
40
+ permission: "store:read",
41
+ module: "store",
42
+ order: 30
43
+ });
44
+ }
45
+ if (features.comments) {
46
+ items.push({
47
+ id: "comments",
48
+ label: "Comments",
49
+ to: `${base}/comments`,
50
+ icon: "lucide:message-square",
51
+ permission: "comments:read",
52
+ module: "comments",
53
+ order: 40
54
+ });
55
+ }
56
+ if (features.blob) {
57
+ items.push({
58
+ id: "media",
59
+ label: "Media",
60
+ to: `${base}/media`,
61
+ icon: "lucide:image",
62
+ permission: "media:upload",
63
+ module: "media",
64
+ order: 50
65
+ });
66
+ }
67
+ if (features.auth) {
68
+ items.push(
69
+ {
70
+ id: "users",
71
+ label: "Users",
72
+ to: `${base}/users`,
73
+ icon: "lucide:users",
74
+ permission: "users:read",
75
+ module: "users",
76
+ order: 60
77
+ },
78
+ {
79
+ id: "roles",
80
+ label: "Roles & Permissions",
81
+ to: `${base}/roles`,
82
+ icon: "lucide:shield",
83
+ permission: "roles:manage",
84
+ module: "roles",
85
+ order: 70
86
+ }
87
+ );
88
+ }
89
+ return items;
90
+ }
91
+ export function resolveConsoleNav(defaults, custom = [], can) {
92
+ const byId = /* @__PURE__ */ new Map();
93
+ for (const item of defaults) {
94
+ byId.set(item.id, item);
95
+ }
96
+ for (const item of custom) {
97
+ const existing = byId.get(item.id);
98
+ byId.set(item.id, existing ? { ...existing, ...item } : item);
99
+ }
100
+ return Array.from(byId.values()).filter((item) => {
101
+ if (!item.permission) return can("console:access");
102
+ const list = Array.isArray(item.permission) ? item.permission : [item.permission];
103
+ if (list.length === 0) return can("console:access");
104
+ return item.match === "any" ? list.some((p) => can(p)) : list.every((p) => can(p));
105
+ }).sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
106
+ }
107
+ function getConsoleConfig() {
108
+ const config = useRuntimeConfig();
109
+ const raw = config.public?.qarpeo?.console;
110
+ return {
111
+ enabled: Boolean(raw?.enabled),
112
+ prefix: normalizeConsolePrefix(raw?.prefix),
113
+ title: raw?.title || "Console",
114
+ loginPath: raw?.loginPath || "/login",
115
+ unauthorizedPath: raw?.unauthorizedPath || "/unauthorized",
116
+ nav: raw?.nav || [],
117
+ features: raw?.features || {}
118
+ };
119
+ }
120
+ export function useConsoleNav() {
121
+ const cfg = getConsoleConfig();
122
+ const { can } = usePermissions();
123
+ return computed(() => {
124
+ if (!cfg.enabled) return [];
125
+ const defaults = buildDefaultConsoleNav(cfg.prefix, cfg.features);
126
+ return resolveConsoleNav(defaults, cfg.nav, can);
127
+ });
128
+ }
129
+ export function useConsole() {
130
+ const cfg = getConsoleConfig();
131
+ const permissions = usePermissions();
132
+ const nav = useConsoleNav();
133
+ const hasAccess = computed(() => cfg.enabled && permissions.can("console:access"));
134
+ return {
135
+ enabled: cfg.enabled,
136
+ prefix: cfg.prefix,
137
+ title: cfg.title,
138
+ loginPath: cfg.loginPath,
139
+ unauthorizedPath: cfg.unauthorizedPath,
140
+ hasAccess,
141
+ nav,
142
+ ready: permissions.ready,
143
+ roles: permissions.roles,
144
+ isSuper: permissions.isSuper,
145
+ can: permissions.can,
146
+ refresh: permissions.refresh,
147
+ permissions
148
+ };
149
+ }
150
+ export function defineConsolePage(meta = {}) {
151
+ const normalized = {
152
+ layout: meta.layout === void 0 ? "console" : meta.layout,
153
+ match: meta.match ?? "all",
154
+ permission: meta.permission,
155
+ title: meta.title
156
+ };
157
+ const definePageMetaFn = globalThis.definePageMeta;
158
+ if (typeof definePageMetaFn === "function") {
159
+ definePageMetaFn({
160
+ layout: normalized.layout,
161
+ title: normalized.title,
162
+ console: {
163
+ permission: normalized.permission,
164
+ match: normalized.match
165
+ }
166
+ });
167
+ }
168
+ return normalized;
169
+ }
@@ -0,0 +1,34 @@
1
+ import { type ComputedRef, type Ref } from "vue";
2
+ declare const swRegistration: import("vue").ShallowRef<ServiceWorkerRegistration | null, ServiceWorkerRegistration | null>;
3
+ export interface UsePwaReturn {
4
+ /** Whether Service Workers are supported in the current browser */
5
+ isSupported: ComputedRef<boolean>;
6
+ /** Reactive network online status */
7
+ isOnline: Ref<boolean>;
8
+ /** Whether the app is currently running in standalone/installed mode */
9
+ isInstalled: Ref<boolean>;
10
+ /** Whether the browser install prompt is ready to be triggered */
11
+ canInstall: ComputedRef<boolean>;
12
+ /** Whether a new Service Worker version is waiting to activate */
13
+ needRefresh: Ref<boolean>;
14
+ /** Active ServiceWorkerRegistration if registered */
15
+ registration: typeof swRegistration;
16
+ /** Trigger the native browser install prompt */
17
+ promptInstall: () => Promise<"accepted" | "dismissed" | "unavailable">;
18
+ /** Activate the waiting Service Worker and reload the page */
19
+ updateServiceWorker: (reload?: boolean) => Promise<void>;
20
+ /** @internal */
21
+ _bindClientEvents: () => void;
22
+ /** @internal */
23
+ _setRegistration: (reg: ServiceWorkerRegistration) => void;
24
+ /** @internal */
25
+ _setNeedRefresh: (val: boolean) => void;
26
+ }
27
+ /**
28
+ * Reactive PWA composable for install prompts, offline status, and Service Worker updates.
29
+ *
30
+ * @example
31
+ * const { canInstall, promptInstall, needRefresh, updateServiceWorker, isOnline } = usePwa()
32
+ */
33
+ export declare function usePwa(): UsePwaReturn;
34
+ export {};
@@ -0,0 +1,86 @@
1
+ import { useState } from "nuxt/app";
2
+ import { computed, shallowRef } from "vue";
3
+ const deferredPrompt = shallowRef(null);
4
+ const swRegistration = shallowRef(null);
5
+ let clientEventsBound = false;
6
+ export function usePwa() {
7
+ const isOnline = useState(
8
+ "qarpeo-pwa-online",
9
+ () => typeof navigator !== "undefined" ? navigator.onLine : true
10
+ );
11
+ const isInstalled = useState("qarpeo-pwa-installed", () => false);
12
+ const needRefresh = useState("qarpeo-pwa-need-refresh", () => false);
13
+ const hasPrompt = useState("qarpeo-pwa-has-prompt", () => false);
14
+ const isSupported = computed(
15
+ () => typeof navigator !== "undefined" && "serviceWorker" in navigator
16
+ );
17
+ const canInstall = computed(() => hasPrompt.value && !isInstalled.value);
18
+ function _bindClientEvents() {
19
+ if (clientEventsBound || typeof window === "undefined") return;
20
+ clientEventsBound = true;
21
+ isOnline.value = navigator.onLine;
22
+ isInstalled.value = window.matchMedia?.("(display-mode: standalone)")?.matches || navigator.standalone === true;
23
+ window.addEventListener("online", () => {
24
+ isOnline.value = true;
25
+ });
26
+ window.addEventListener("offline", () => {
27
+ isOnline.value = false;
28
+ });
29
+ window.addEventListener("beforeinstallprompt", (e) => {
30
+ e.preventDefault();
31
+ deferredPrompt.value = e;
32
+ hasPrompt.value = true;
33
+ });
34
+ window.addEventListener("appinstalled", () => {
35
+ deferredPrompt.value = null;
36
+ hasPrompt.value = false;
37
+ isInstalled.value = true;
38
+ });
39
+ }
40
+ function _setRegistration(reg) {
41
+ swRegistration.value = reg;
42
+ }
43
+ function _setNeedRefresh(val) {
44
+ needRefresh.value = val;
45
+ }
46
+ async function promptInstall() {
47
+ if (!deferredPrompt.value) return "unavailable";
48
+ await deferredPrompt.value.prompt();
49
+ const { outcome } = await deferredPrompt.value.userChoice;
50
+ deferredPrompt.value = null;
51
+ hasPrompt.value = false;
52
+ if (outcome === "accepted") {
53
+ isInstalled.value = true;
54
+ }
55
+ return outcome;
56
+ }
57
+ async function updateServiceWorker(reload = true) {
58
+ const reg = swRegistration.value;
59
+ if (reg?.waiting) {
60
+ reg.waiting.postMessage({ type: "SKIP_WAITING" });
61
+ needRefresh.value = false;
62
+ if (reload && typeof window !== "undefined") {
63
+ navigator.serviceWorker.addEventListener(
64
+ "controllerchange",
65
+ () => {
66
+ window.location.reload();
67
+ },
68
+ { once: true }
69
+ );
70
+ }
71
+ }
72
+ }
73
+ return {
74
+ isSupported,
75
+ isOnline,
76
+ isInstalled,
77
+ canInstall,
78
+ needRefresh,
79
+ registration: swRegistration,
80
+ promptInstall,
81
+ updateServiceWorker,
82
+ _bindClientEvents,
83
+ _setRegistration,
84
+ _setNeedRefresh
85
+ };
86
+ }
@@ -0,0 +1,33 @@
1
+ import { type ComputedRef, type MaybeRef } from "vue";
2
+ export interface RbacMeState {
3
+ authenticated: boolean;
4
+ userId: string | null;
5
+ primaryRole: string | null;
6
+ roles: string[];
7
+ isSuper: boolean;
8
+ rolePermissions: string[];
9
+ allow: string[];
10
+ deny: string[];
11
+ ready: boolean;
12
+ }
13
+ /**
14
+ * Reactive RBAC permissions composable for the current authenticated user.
15
+ * Backed by `GET /__qarpeo/rbac/me` with deny-first evaluation matching the server.
16
+ */
17
+ export declare function usePermissions(): {
18
+ state: import("vue").Ref<RbacMeState, RbacMeState>;
19
+ ready: ComputedRef<boolean>;
20
+ roles: ComputedRef<string[]>;
21
+ isSuper: ComputedRef<boolean>;
22
+ can: (permission: string) => boolean;
23
+ refresh: () => Promise<RbacMeState>;
24
+ };
25
+ /**
26
+ * Reactive boolean helper for checking a single permission in templates.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const canPublish = useCan("cms:publish")
31
+ * ```
32
+ */
33
+ export declare function useCan(permission: MaybeRef<string>): ComputedRef<boolean>;
@@ -0,0 +1,60 @@
1
+ import { useRequestFetch, useState } from "nuxt/app";
2
+ import { computed, unref } from "vue";
3
+ function matchClientPermission(granted, required) {
4
+ if (!required) return false;
5
+ for (const g of granted) {
6
+ if (g === "*") return true;
7
+ if (g === required) return true;
8
+ if (g.endsWith(":*") && required.startsWith(g.slice(0, -1))) return true;
9
+ }
10
+ return false;
11
+ }
12
+ export function usePermissions() {
13
+ const state = useState("qarpeo-rbac-me", () => ({
14
+ authenticated: false,
15
+ userId: null,
16
+ primaryRole: null,
17
+ roles: [],
18
+ isSuper: false,
19
+ rolePermissions: [],
20
+ allow: [],
21
+ deny: [],
22
+ ready: false
23
+ }));
24
+ async function refresh() {
25
+ try {
26
+ const fetcher = import.meta.server ? useRequestFetch() : $fetch;
27
+ const data = await fetcher("/__qarpeo/rbac/me");
28
+ state.value = {
29
+ ...data,
30
+ ready: true
31
+ };
32
+ } catch {
33
+ state.value = { ...state.value, ready: true };
34
+ }
35
+ return state.value;
36
+ }
37
+ if (!state.value.ready && import.meta.client) {
38
+ void refresh();
39
+ }
40
+ function can(permission) {
41
+ const s = state.value;
42
+ if (!s.authenticated) return false;
43
+ if (s.isSuper) return true;
44
+ if (matchClientPermission(s.deny, permission)) return false;
45
+ if (matchClientPermission(s.allow, permission)) return true;
46
+ return matchClientPermission(s.rolePermissions, permission);
47
+ }
48
+ return {
49
+ state,
50
+ ready: computed(() => state.value.ready),
51
+ roles: computed(() => state.value.roles),
52
+ isSuper: computed(() => state.value.isSuper),
53
+ can,
54
+ refresh
55
+ };
56
+ }
57
+ export function useCan(permission) {
58
+ const { can } = usePermissions();
59
+ return computed(() => can(unref(permission)));
60
+ }
@@ -33,3 +33,76 @@ export interface BreadcrumbItem {
33
33
  * ])
34
34
  */
35
35
  export declare function defineBreadcrumbs(items: BreadcrumbItem[]): void;
36
+ export interface DefineSeoOptions {
37
+ title: string;
38
+ description?: string;
39
+ image?: string;
40
+ type?: "website" | "article" | "product" | "profile";
41
+ canonical?: string;
42
+ noindex?: boolean;
43
+ publishedAt?: string;
44
+ modifiedAt?: string;
45
+ author?: string;
46
+ tags?: string[];
47
+ }
48
+ /**
49
+ * One-call per-page SEO helper that sets title, description, OpenGraph, Twitter Card,
50
+ * optional canonical override, robots noindex, and Article JSON-LD when `type === "article"`.
51
+ */
52
+ export declare function defineSeo(opts: DefineSeoOptions): void;
53
+ export interface ArticleSchemaInput {
54
+ headline: string;
55
+ description?: string;
56
+ image?: string;
57
+ datePublished?: string;
58
+ dateModified?: string;
59
+ authorName?: string;
60
+ authorUrl?: string;
61
+ url?: string;
62
+ type?: "Article" | "BlogPosting" | "NewsArticle" | "TechArticle";
63
+ }
64
+ /** Injects Schema.org `Article` / `BlogPosting` JSON-LD structured data. */
65
+ export declare function defineArticleSchema(input: ArticleSchemaInput): void;
66
+ export interface OrganizationSchemaInput {
67
+ name?: string;
68
+ url?: string;
69
+ logo?: string;
70
+ sameAs?: string[];
71
+ type?: "Organization" | "Person";
72
+ }
73
+ /** Injects Schema.org `Organization` or `Person` JSON-LD structured data. */
74
+ export declare function defineOrganizationSchema(input?: OrganizationSchemaInput): void;
75
+ export interface ProductSchemaInput {
76
+ name: string;
77
+ description?: string;
78
+ image?: string;
79
+ sku?: string;
80
+ brand?: string;
81
+ price: number | string;
82
+ currency?: string;
83
+ availability?: "InStock" | "OutOfStock" | "PreOrder";
84
+ url?: string;
85
+ }
86
+ /** Injects Schema.org `Product` + `Offer` JSON-LD structured data (pairs with Qarpeo Store). */
87
+ export declare function defineProductSchema(input: ProductSchemaInput): void;
88
+ export interface FaqItemInput {
89
+ question: string;
90
+ answer: string;
91
+ }
92
+ /** Injects Schema.org `FAQPage` JSON-LD structured data. */
93
+ export declare function defineFaqSchema(items: FaqItemInput[]): void;
94
+ export interface OgImageOptions {
95
+ title?: string;
96
+ description?: string;
97
+ siteName?: string;
98
+ theme?: "dark" | "light" | "gradient";
99
+ themeColor?: string;
100
+ logo?: string;
101
+ author?: string;
102
+ alt?: string;
103
+ }
104
+ /**
105
+ * Sets a dynamic 1200x630 OpenGraph image pointing to Qarpeo's `/__qarpeo/og` edge endpoint
106
+ * (renders PNG via Cloudflare Browser Rendering when available, or zero-dependency SVG otherwise).
107
+ */
108
+ export declare function defineOgImage(options?: OgImageOptions): void;
@@ -1,4 +1,4 @@
1
- import { useRuntimeConfig, useRoute, useHead } from "nuxt/app";
1
+ import { useRuntimeConfig, useRoute, useHead, useSeoMeta } from "nuxt/app";
2
2
  import { computed } from "vue";
3
3
  export function useSite() {
4
4
  const runtimeConfig = useRuntimeConfig();
@@ -35,3 +35,176 @@ export function defineBreadcrumbs(items) {
35
35
  ]
36
36
  });
37
37
  }
38
+ function resolveAbsoluteUrl(site, pathOrUrl) {
39
+ if (!pathOrUrl) return void 0;
40
+ if (pathOrUrl.startsWith("http")) return pathOrUrl;
41
+ const base = (site.url || "").replace(/\/$/, "");
42
+ if (!base) return pathOrUrl;
43
+ return `${base}${pathOrUrl.startsWith("/") ? "" : "/"}${pathOrUrl}`;
44
+ }
45
+ function injectJsonLd(schema) {
46
+ useHead({
47
+ script: [
48
+ {
49
+ type: "application/ld+json",
50
+ innerHTML: JSON.stringify(schema).replace(/</g, "\\u003c")
51
+ }
52
+ ]
53
+ });
54
+ }
55
+ export function defineSeo(opts) {
56
+ const site = useSite();
57
+ const imageUrl = resolveAbsoluteUrl(site, opts.image || site.image);
58
+ const meta = {
59
+ title: opts.title,
60
+ ogTitle: opts.title,
61
+ ogType: opts.type || "website"
62
+ };
63
+ if (opts.description) {
64
+ meta.description = opts.description;
65
+ meta.ogDescription = opts.description;
66
+ }
67
+ if (imageUrl) {
68
+ meta.ogImage = imageUrl;
69
+ meta.ogImageWidth = 1200;
70
+ meta.ogImageHeight = 630;
71
+ } else if (site.ogImage && (site.ogImage === true || site.ogImage.enabled !== false)) {
72
+ defineOgImage({
73
+ title: opts.title,
74
+ description: opts.description,
75
+ author: opts.author
76
+ });
77
+ }
78
+ if (opts.noindex) {
79
+ meta.robots = "noindex, nofollow";
80
+ }
81
+ if (opts.publishedAt) {
82
+ meta.articlePublishedTime = opts.publishedAt;
83
+ }
84
+ if (opts.modifiedAt) {
85
+ meta.articleModifiedTime = opts.modifiedAt;
86
+ }
87
+ if (opts.author) {
88
+ meta.articleAuthor = [opts.author];
89
+ }
90
+ if (opts.tags?.length) {
91
+ meta.articleTag = opts.tags;
92
+ }
93
+ useSeoMeta(meta);
94
+ if (opts.canonical) {
95
+ const canonicalHref = resolveAbsoluteUrl(site, opts.canonical);
96
+ if (canonicalHref) {
97
+ useHead({
98
+ link: [{ rel: "canonical", href: canonicalHref }]
99
+ });
100
+ useSeoMeta({ ogUrl: canonicalHref });
101
+ }
102
+ }
103
+ if (opts.type === "article") {
104
+ defineArticleSchema({
105
+ headline: opts.title,
106
+ description: opts.description,
107
+ image: imageUrl,
108
+ datePublished: opts.publishedAt,
109
+ dateModified: opts.modifiedAt,
110
+ authorName: opts.author
111
+ });
112
+ }
113
+ }
114
+ export function defineArticleSchema(input) {
115
+ const site = useSite();
116
+ const canonical = useCanonicalUrl();
117
+ injectJsonLd({
118
+ "@context": "https://schema.org",
119
+ "@type": input.type || "Article",
120
+ headline: input.headline,
121
+ description: input.description,
122
+ image: resolveAbsoluteUrl(site, input.image || site.image),
123
+ datePublished: input.datePublished,
124
+ dateModified: input.dateModified || input.datePublished,
125
+ mainEntityOfPage: resolveAbsoluteUrl(site, input.url) || canonical.value || void 0,
126
+ author: input.authorName ? {
127
+ "@type": "Person",
128
+ name: input.authorName,
129
+ url: input.authorUrl
130
+ } : void 0,
131
+ publisher: site.name ? {
132
+ "@type": "Organization",
133
+ name: site.name,
134
+ url: site.url
135
+ } : void 0
136
+ });
137
+ }
138
+ export function defineOrganizationSchema(input = {}) {
139
+ const site = useSite();
140
+ injectJsonLd({
141
+ "@context": "https://schema.org",
142
+ "@type": input.type || "Organization",
143
+ name: input.name || site.name,
144
+ url: input.url || site.url,
145
+ logo: resolveAbsoluteUrl(site, input.logo || site.image),
146
+ sameAs: input.sameAs?.length ? input.sameAs : void 0
147
+ });
148
+ }
149
+ export function defineProductSchema(input) {
150
+ const site = useSite();
151
+ const canonical = useCanonicalUrl();
152
+ injectJsonLd({
153
+ "@context": "https://schema.org",
154
+ "@type": "Product",
155
+ name: input.name,
156
+ description: input.description,
157
+ image: resolveAbsoluteUrl(site, input.image),
158
+ sku: input.sku,
159
+ brand: input.brand ? { "@type": "Brand", name: input.brand } : void 0,
160
+ offers: {
161
+ "@type": "Offer",
162
+ price: String(input.price),
163
+ priceCurrency: input.currency || "USD",
164
+ availability: `https://schema.org/${input.availability || "InStock"}`,
165
+ url: resolveAbsoluteUrl(site, input.url) || canonical.value || void 0
166
+ }
167
+ });
168
+ }
169
+ export function defineFaqSchema(items) {
170
+ injectJsonLd({
171
+ "@context": "https://schema.org",
172
+ "@type": "FAQPage",
173
+ mainEntity: items.map((item) => ({
174
+ "@type": "Question",
175
+ name: item.question,
176
+ acceptedAnswer: {
177
+ "@type": "Answer",
178
+ text: item.answer
179
+ }
180
+ }))
181
+ });
182
+ }
183
+ export function defineOgImage(options = {}) {
184
+ const site = useSite();
185
+ const ogCfg = typeof site.ogImage === "object" ? site.ogImage : {};
186
+ const params = new URLSearchParams();
187
+ const title = options.title || site.name;
188
+ const description = options.description ?? site.description;
189
+ const siteName = options.siteName ?? site.name;
190
+ const theme = options.theme || ogCfg.theme;
191
+ const themeColor = options.themeColor || ogCfg.themeColor;
192
+ const logo = options.logo || ogCfg.logo;
193
+ if (title) params.set("title", title);
194
+ if (description) params.set("description", description);
195
+ if (siteName) params.set("siteName", siteName);
196
+ if (theme) params.set("theme", theme);
197
+ if (themeColor) params.set("themeColor", themeColor);
198
+ if (logo) params.set("logo", logo);
199
+ if (options.author) params.set("author", options.author);
200
+ const query = params.toString();
201
+ const path = query ? `/__qarpeo/og?${query}` : "/__qarpeo/og";
202
+ const base = (site.url || "").replace(/\/$/, "");
203
+ const imageUrl = base ? `${base}${path}` : path;
204
+ useSeoMeta({
205
+ ogImage: imageUrl,
206
+ ogImageWidth: 1200,
207
+ ogImageHeight: 630,
208
+ ogImageAlt: options.alt || title || site.name || "OpenGraph image"
209
+ });
210
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").RouteMiddleware;
2
+ export default _default;
@@ -0,0 +1,37 @@
1
+ import { defineNuxtRouteMiddleware, navigateTo, useRuntimeConfig } from "nuxt/app";
2
+ import { useAuth } from "../composables/auth.mjs";
3
+ import { normalizeConsolePrefix } from "../composables/console.mjs";
4
+ import { usePermissions } from "../composables/rbac.mjs";
5
+ function isConsolePath(path, prefix) {
6
+ return path === prefix || path.startsWith(`${prefix}/`);
7
+ }
8
+ export default defineNuxtRouteMiddleware(async (to) => {
9
+ const runtimeConfig = useRuntimeConfig();
10
+ const consoleConfig = runtimeConfig.public?.qarpeo?.console;
11
+ if (!consoleConfig?.enabled) return;
12
+ const prefix = normalizeConsolePrefix(consoleConfig.prefix);
13
+ if (!isConsolePath(to.path, prefix)) return;
14
+ const { loggedIn } = useAuth();
15
+ if (!loggedIn.value) {
16
+ const loginPath = consoleConfig.loginPath || "/login";
17
+ return navigateTo(`${loginPath}?redirect=${encodeURIComponent(to.fullPath)}`);
18
+ }
19
+ const { ready, can, refresh } = usePermissions();
20
+ if (!ready.value) {
21
+ await refresh();
22
+ }
23
+ const unauthorizedPath = consoleConfig.unauthorizedPath || "/unauthorized";
24
+ if (!can("console:access")) {
25
+ return navigateTo(unauthorizedPath);
26
+ }
27
+ const pageMeta = to.meta?.console;
28
+ if (pageMeta?.permission) {
29
+ const required = Array.isArray(pageMeta.permission) ? pageMeta.permission : [pageMeta.permission];
30
+ if (required.length > 0) {
31
+ const allowed = pageMeta.match === "any" ? required.some((p) => can(p)) : required.every((p) => can(p));
32
+ if (!allowed) {
33
+ return navigateTo(unauthorizedPath);
34
+ }
35
+ }
36
+ }
37
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;