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,28 @@
1
+ import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
2
+ import { usePwa } from "../composables/pwa.mjs";
3
+ export default defineNuxtPlugin(() => {
4
+ if (typeof window === "undefined") return;
5
+ const runtimeConfig = useRuntimeConfig();
6
+ const pwaConfig = runtimeConfig.public?.qarpeo?.pwa || {};
7
+ if (pwaConfig.enabled === false) return;
8
+ const { _bindClientEvents, _setRegistration, _setNeedRefresh } = usePwa();
9
+ _bindClientEvents();
10
+ if (pwaConfig.register !== false && "serviceWorker" in navigator) {
11
+ navigator.serviceWorker.register("/sw.js", { scope: pwaConfig.scope || "/" }).then((reg) => {
12
+ _setRegistration(reg);
13
+ if (reg.waiting) {
14
+ _setNeedRefresh(true);
15
+ }
16
+ reg.addEventListener("updatefound", () => {
17
+ const installing = reg.installing;
18
+ if (!installing) return;
19
+ installing.addEventListener("statechange", () => {
20
+ if (installing.state === "installed" && navigator.serviceWorker.controller) {
21
+ _setNeedRefresh(true);
22
+ }
23
+ });
24
+ });
25
+ }).catch(() => {
26
+ });
27
+ }
28
+ });
@@ -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;
@@ -0,0 +1,42 @@
1
+ import { defineNuxtPlugin, useHead, useRuntimeConfig } from "nuxt/app";
2
+ export default defineNuxtPlugin(() => {
3
+ const runtimeConfig = useRuntimeConfig();
4
+ const qarpeo = runtimeConfig.public?.qarpeo || {};
5
+ const pwa = qarpeo.pwa || {};
6
+ const site = qarpeo.site || {};
7
+ if (pwa.enabled === false) return;
8
+ const links = [
9
+ { rel: "manifest", href: "/manifest.webmanifest" }
10
+ ];
11
+ const appleTouchIcon = pwa.appleTouchIcon || pwa.icons?.find((i) => i.sizes.includes("180") || i.sizes.includes("192"))?.src || pwa.icons?.[0]?.src;
12
+ if (appleTouchIcon) {
13
+ links.push({ rel: "apple-touch-icon", href: appleTouchIcon });
14
+ }
15
+ const meta = [
16
+ { name: "apple-mobile-web-app-capable", content: "yes" },
17
+ { name: "apple-mobile-web-app-status-bar-style", content: "default" },
18
+ {
19
+ name: "apple-mobile-web-app-title",
20
+ content: pwa.shortName || pwa.name || site.name || "App"
21
+ }
22
+ ];
23
+ const themeColor = pwa.themeColor || "#0f172a";
24
+ if (pwa.themeColorDark) {
25
+ meta.push({
26
+ name: "theme-color",
27
+ content: themeColor,
28
+ media: "(prefers-color-scheme: light)"
29
+ });
30
+ meta.push({
31
+ name: "theme-color",
32
+ content: pwa.themeColorDark,
33
+ media: "(prefers-color-scheme: dark)"
34
+ });
35
+ } else {
36
+ meta.push({ name: "theme-color", content: themeColor });
37
+ }
38
+ useHead({
39
+ link: links,
40
+ meta
41
+ });
42
+ });
@@ -20,7 +20,8 @@ export default defineNuxtPlugin(() => {
20
20
  });
21
21
  const baseSeo = {
22
22
  ogSiteName: siteName,
23
- ogLocale: site.defaultLocale || "en"
23
+ ogLocale: site.defaultLocale || "en",
24
+ ogType: "website"
24
25
  };
25
26
  if (site.name) {
26
27
  baseSeo.title = site.name;
@@ -33,6 +34,17 @@ export default defineNuxtPlugin(() => {
33
34
  if (site.image) {
34
35
  const imageUrl = site.image.startsWith("http") ? site.image : site.url ? `${site.url.replace(/\/$/, "")}/${site.image.replace(/^\//, "")}` : site.image;
35
36
  baseSeo.ogImage = imageUrl;
37
+ } else if (site.ogImage && (site.ogImage === true || site.ogImage.enabled !== false)) {
38
+ const ogCfg = typeof site.ogImage === "object" ? site.ogImage : {};
39
+ const params = new URLSearchParams();
40
+ if (site.name) params.set("title", site.name);
41
+ if (site.description) params.set("description", site.description);
42
+ if (ogCfg.theme) params.set("theme", ogCfg.theme);
43
+ if (ogCfg.themeColor) params.set("themeColor", ogCfg.themeColor);
44
+ const path = `/__qarpeo/og?${params.toString()}`;
45
+ baseSeo.ogImage = site.url ? `${site.url.replace(/\/$/, "")}${path}` : path;
46
+ baseSeo.ogImageWidth = 1200;
47
+ baseSeo.ogImageHeight = 630;
36
48
  }
37
49
  if (site.twitter) {
38
50
  baseSeo.twitterSite = site.twitter;
@@ -48,8 +60,13 @@ export default defineNuxtPlugin(() => {
48
60
  const route = useRoute();
49
61
  const baseUrl = site.url.replace(/\/$/, "");
50
62
  const canonicalHref = computed(() => {
51
- const cleanPath = route.path === "/" ? "" : route.path;
52
- return `${baseUrl}${cleanPath}`;
63
+ let cleanPath = route.path === "/" ? "" : route.path;
64
+ if (site.trailingSlash && cleanPath && !cleanPath.endsWith("/")) {
65
+ cleanPath = `${cleanPath}/`;
66
+ } else if (!site.trailingSlash && cleanPath.endsWith("/")) {
67
+ cleanPath = cleanPath.slice(0, -1);
68
+ }
69
+ return `${baseUrl}${cleanPath || (site.trailingSlash ? "/" : "")}`;
53
70
  });
54
71
  useHead({
55
72
  link: computed(() => {
@@ -83,16 +100,28 @@ export default defineNuxtPlugin(() => {
83
100
  useHead({
84
101
  script: computed(() => {
85
102
  if (route.path !== "/") return [];
103
+ const websiteSchema = {
104
+ "@context": "https://schema.org",
105
+ "@type": "WebSite",
106
+ name: siteName,
107
+ url: baseUrl,
108
+ description: site.description || void 0
109
+ };
110
+ if (site.searchUrl) {
111
+ const target = site.searchUrl.startsWith("http") ? site.searchUrl : `${baseUrl}${site.searchUrl.startsWith("/") ? "" : "/"}${site.searchUrl}`;
112
+ websiteSchema.potentialAction = {
113
+ "@type": "SearchAction",
114
+ target: {
115
+ "@type": "EntryPoint",
116
+ urlTemplate: target
117
+ },
118
+ "query-input": "required name=search_term_string"
119
+ };
120
+ }
86
121
  return [
87
122
  {
88
123
  type: "application/ld+json",
89
- innerHTML: JSON.stringify({
90
- "@context": "https://schema.org",
91
- "@type": "WebSite",
92
- name: siteName,
93
- url: baseUrl,
94
- description: site.description || void 0
95
- })
124
+ innerHTML: JSON.stringify(websiteSchema).replace(/</g, "\\u003c")
96
125
  }
97
126
  ];
98
127
  })
@@ -1,12 +1,15 @@
1
1
  /**
2
- * `qarpeo/schema` — Reusable Drizzle ORM column helpers for Cloudflare D1 (SQLite) and PostgreSQL.
2
+ * `qarpeo/schema` — Qarpeo column spreads, table factories, ID generators, and type helpers
3
+ * for Cloudflare D1 (SQLite), PostgreSQL, and MySQL.
3
4
  *
4
- * Provides zero-config primary key strategies, timestamp columns, and common field helpers
5
- * that can be spread directly into any Drizzle table definition.
5
+ * Import standard Drizzle column builders (`text`, `integer`, `varchar`, etc.) and query
6
+ * operators (`eq`, `isNull`, `sql`, etc.) directly from `"drizzle-orm/sqlite-core"`,
7
+ * `"drizzle-orm/pg-core"`, `"drizzle-orm/mysql-core"`, or `"drizzle-orm"`.
6
8
  *
7
9
  * @example
8
10
  * ```ts [db/d1/schema/posts.ts]
9
- * import { sqlTable, sqlid, sqltimestamps, text } from "qarpeo/schema"
11
+ * import { text } from "drizzle-orm/sqlite-core"
12
+ * import { sqlTable, sqlid, sqltimestamps, type SelectFrom, type InsertInto } from "qarpeo/schema"
10
13
  *
11
14
  * export const posts = sqlTable("posts", {
12
15
  * ...sqlid,
@@ -14,14 +17,14 @@
14
17
  * body: text(),
15
18
  * ...sqltimestamps,
16
19
  * })
20
+ *
21
+ * export type Post = SelectFrom<typeof posts>
22
+ * export type NewPost = InsertInto<typeof posts>
17
23
  * ```
18
24
  */
19
- export { sqliteTable, text, integer, real, blob, numeric, uniqueIndex, index, primaryKey, foreignKey, check, customType as sqliteCustomType, } from "drizzle-orm/sqlite-core";
20
- export { pgTable, varchar, char, serial, bigint, bigserial, smallint, doublePrecision, boolean, jsonb, json, timestamp, date, time, uuid, customType as pgCustomType, } from "drizzle-orm/pg-core";
21
- export { mysqlTable, mysqlView, varchar as mysqlVarchar, char as mysqlChar, serial as mysqlSerial, int as mysqlInt, tinyint as mysqlTinyint, smallint as mysqlSmallint, mediumint as mysqlMediumint, bigint as mysqlBigint, decimal as mysqlDecimal, float as mysqlFloat, double as mysqlDouble, boolean as mysqlBoolean, json as mysqlJson, timestamp as mysqlTimestamp, datetime as mysqlDatetime, date as mysqlDate, time as mysqlTime, year as mysqlYear, text as mysqlText, binary as mysqlBinary, varbinary as mysqlVarbinary, customType as mysqlCustomType, } from "drizzle-orm/mysql-core";
25
+ export { pgTable } from "drizzle-orm/pg-core";
22
26
  /** Alias for `mysqlTable` for consistency with `msSchema`, `msDb`, `msid`. */
23
27
  export { mysqlTable as msTable } from "drizzle-orm/mysql-core";
24
- export { sql, defineRelations, eq, ne, gt, gte, lt, lte, and, or, not, desc, asc, like, notLike, ilike, notIlike, inArray, notInArray, isNull, isNotNull, between, notBetween, count, countDistinct, avg, max, min, sum, } from "drizzle-orm";
25
28
  /**
26
29
  * Drizzle table factory with automatic `camelCase` → `snake_case` column name mapping.
27
30
  * Equivalent to `sqliteTable` but all JS column keys are automatically stored with underscore names.
@@ -45,7 +48,7 @@ export declare function generateUUID(): string;
45
48
  *
46
49
  * The first 48 bits encode the current Unix timestamp in milliseconds so records sort
47
50
  * chronologically by ID alone. Sub-millisecond generation uses a monotonic counter
48
- * per RFC 9562 §6.2 Method 1 to guarantee strictly increasing order even in high-throughput loops.
51
+ * per RFC 9562 §6.2 Method 1 to avoid same-millisecond collisions.
49
52
  *
50
53
  * **Why prefer UUID v7 over v4 for database primary keys:**
51
54
  * - New rows are always appended to the end of the B-tree index → no page splits → faster inserts
@@ -53,6 +56,10 @@ export declare function generateUUID(): string;
53
56
  * - Works in distributed edge Workers without a central counter
54
57
  * - You can decode the creation timestamp from the ID: `new Date(parseInt(id.slice(0, 8), 16))`
55
58
  *
59
+ * Note: The monotonic counter guarantees ordering within a single isolate. Across concurrent
60
+ * requests in the same Cloudflare Worker isolate, ordering is best-effort — UUID v7 collisions
61
+ * remain astronomically unlikely even under concurrency.
62
+ *
56
63
  * Zero external dependencies — uses only `Date.now()` and `crypto.getRandomValues()`.
57
64
  *
58
65
  * @example `"01936c0a-5e0c-7b3a-8f9d-2e1c4a6b8d0f"`
@@ -170,7 +177,7 @@ export declare const pgid: {
170
177
  * ID generation happens inside PostgreSQL (`gen_random_uuid()`), not in the Worker.
171
178
  * Note: you won't know the ID before insert without a RETURNING clause.
172
179
  */
173
- export declare const pgUuidId: {
180
+ export declare const pguuid: {
174
181
  readonly id: import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetIsPrimaryKey<import("drizzle-orm/pg-core").PgUUIDBuilder>>;
175
182
  };
176
183
  /**
@@ -192,6 +199,18 @@ export declare const pgtimestamps: {
192
199
  readonly createdAt: import("drizzle-orm/pg-core").SetHasRuntimeDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTimestampBuilder>>;
193
200
  readonly updatedAt: import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetHasRuntimeDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTimestampBuilder>>>;
194
201
  };
202
+ /**
203
+ * Just `createdAt` for PostgreSQL — set once at insert, never updated.
204
+ */
205
+ export declare const pgCreatedAt: {
206
+ readonly createdAt: import("drizzle-orm/pg-core").SetHasRuntimeDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTimestampBuilder>>;
207
+ };
208
+ /**
209
+ * Just `updatedAt` for PostgreSQL — set at insert and refreshed on every update.
210
+ */
211
+ export declare const pgUpdatedAt: {
212
+ readonly updatedAt: import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetHasRuntimeDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTimestampBuilder>>>;
213
+ };
195
214
  /**
196
215
  * PostgreSQL soft-delete column — `deletedAt` nullable timestamptz.
197
216
  */
@@ -207,10 +226,11 @@ export declare const pgtenantid: {
207
226
  /**
208
227
  * **Recommended MySQL primary key** — VARCHAR(36) UUID v7, auto-generated at insert.
209
228
  *
229
+ * The `ms` prefix stands for **MySQL** throughout this module (`sql` = SQLite/D1, `pg` = PostgreSQL, `ms` = MySQL).
210
230
  * Time-ordered so rows always sort chronologically by id.
211
231
  *
212
232
  * ```ts
213
- * export const posts = mysqlTable("posts", { ...msid, title: varchar("title", { length: 255 }).notNull() })
233
+ * export const posts = mysqlTable("posts", { ...msid, title: mysqlVarchar({ length: 255 }).notNull() })
214
234
  * // → id VARCHAR(36) PRIMARY KEY (auto UUID v7)
215
235
  * ```
216
236
  */
@@ -231,7 +251,7 @@ export declare const msuuid: {
231
251
  * Best for simple, single-region tables where sequential IDs are acceptable.
232
252
  *
233
253
  * ```ts
234
- * export const hits = mysqlTable("hits", { ...msint, path: text("path").notNull() })
254
+ * export const hits = mysqlTable("hits", { ...msint, path: mysqlText().notNull() })
235
255
  * // → id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY
236
256
  * ```
237
257
  */
@@ -1,94 +1,6 @@
1
- export {
2
- sqliteTable,
3
- text,
4
- integer,
5
- real,
6
- blob,
7
- numeric,
8
- uniqueIndex,
9
- index,
10
- primaryKey,
11
- foreignKey,
12
- check,
13
- customType as sqliteCustomType
14
- } from "drizzle-orm/sqlite-core";
15
- export {
16
- pgTable,
17
- varchar,
18
- char,
19
- serial,
20
- bigint,
21
- bigserial,
22
- smallint,
23
- doublePrecision,
24
- boolean,
25
- jsonb,
26
- json,
27
- timestamp,
28
- date,
29
- time,
30
- uuid,
31
- customType as pgCustomType
32
- } from "drizzle-orm/pg-core";
33
- export {
34
- mysqlTable,
35
- mysqlView,
36
- varchar as mysqlVarchar,
37
- char as mysqlChar,
38
- serial as mysqlSerial,
39
- int as mysqlInt,
40
- tinyint as mysqlTinyint,
41
- smallint as mysqlSmallint,
42
- mediumint as mysqlMediumint,
43
- bigint as mysqlBigint,
44
- decimal as mysqlDecimal,
45
- float as mysqlFloat,
46
- double as mysqlDouble,
47
- boolean as mysqlBoolean,
48
- json as mysqlJson,
49
- timestamp as mysqlTimestamp,
50
- datetime as mysqlDatetime,
51
- date as mysqlDate,
52
- time as mysqlTime,
53
- year as mysqlYear,
54
- text as mysqlText,
55
- binary as mysqlBinary,
56
- varbinary as mysqlVarbinary,
57
- customType as mysqlCustomType
58
- } from "drizzle-orm/mysql-core";
59
- export { mysqlTable as msTable } from "drizzle-orm/mysql-core";
60
- export {
61
- sql,
62
- defineRelations,
63
- eq,
64
- ne,
65
- gt,
66
- gte,
67
- lt,
68
- lte,
69
- and,
70
- or,
71
- not,
72
- desc,
73
- asc,
74
- like,
75
- notLike,
76
- ilike,
77
- notIlike,
78
- inArray,
79
- notInArray,
80
- isNull,
81
- isNotNull,
82
- between,
83
- notBetween,
84
- count,
85
- countDistinct,
86
- avg,
87
- max,
88
- min,
89
- sum
90
- } from "drizzle-orm";
91
1
  import { snakeCase } from "drizzle-orm/sqlite-core";
2
+ export { pgTable } from "drizzle-orm/pg-core";
3
+ export { mysqlTable as msTable } from "drizzle-orm/mysql-core";
92
4
  export const sqlTable = snakeCase.table;
93
5
  export function generateUUID() {
94
6
  return crypto.randomUUID();
@@ -98,23 +10,23 @@ let seq = 0;
98
10
  export function generateUUIDv7() {
99
11
  const bytes = new Uint8Array(16);
100
12
  crypto.getRandomValues(bytes);
101
- let timestamp3 = Date.now();
102
- if (timestamp3 > lastTimestamp) {
103
- lastTimestamp = timestamp3;
13
+ let timestamp = Date.now();
14
+ if (timestamp > lastTimestamp) {
15
+ lastTimestamp = timestamp;
104
16
  seq = (bytes[6] & 15) << 8 | bytes[7];
105
17
  } else {
106
18
  seq = seq + 1 & 4095;
107
19
  if (seq === 0) {
108
20
  lastTimestamp++;
109
21
  }
110
- timestamp3 = lastTimestamp;
111
- }
112
- bytes[0] = timestamp3 / 1099511627776 & 255;
113
- bytes[1] = timestamp3 / 4294967296 & 255;
114
- bytes[2] = timestamp3 / 16777216 & 255;
115
- bytes[3] = timestamp3 / 65536 & 255;
116
- bytes[4] = timestamp3 / 256 & 255;
117
- bytes[5] = timestamp3 & 255;
22
+ timestamp = lastTimestamp;
23
+ }
24
+ bytes[0] = timestamp / 1099511627776 & 255;
25
+ bytes[1] = timestamp / 4294967296 & 255;
26
+ bytes[2] = timestamp / 16777216 & 255;
27
+ bytes[3] = timestamp / 65536 & 255;
28
+ bytes[4] = timestamp / 256 & 255;
29
+ bytes[5] = timestamp & 255;
118
30
  bytes[6] = 112 | seq >> 8 & 15;
119
31
  bytes[7] = seq & 255;
120
32
  bytes[8] = bytes[8] & 63 | 128;
@@ -171,89 +83,99 @@ export const sqltenantid = {
171
83
  }
172
84
  };
173
85
  import {
174
- text as pgText,
175
- uuid as pgUuid,
176
- timestamp as pgTimestamp,
177
- serial as pgSerial
86
+ text as _pgText,
87
+ uuid as _pgUuid,
88
+ timestamp as _pgTimestamp,
89
+ serial as _pgSerial
178
90
  } from "drizzle-orm/pg-core";
179
91
  export const pgid = {
180
92
  get id() {
181
- return pgText("id").primaryKey().$defaultFn(() => generateUUIDv7());
93
+ return _pgText("id").primaryKey().$defaultFn(() => generateUUIDv7());
182
94
  }
183
95
  };
184
- export const pgUuidId = {
96
+ export const pguuid = {
185
97
  get id() {
186
- return pgUuid("id").primaryKey().defaultRandom();
98
+ return _pgUuid("id").primaryKey().defaultRandom();
187
99
  }
188
100
  };
189
101
  export const pgint = {
190
102
  get id() {
191
- return pgSerial("id").primaryKey();
103
+ return _pgSerial("id").primaryKey();
192
104
  }
193
105
  };
194
106
  export const pgtimestamps = {
195
107
  get createdAt() {
196
- return pgTimestamp("created_at", { withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date());
108
+ return _pgTimestamp("created_at", { withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date());
197
109
  },
198
110
  get updatedAt() {
199
- return pgTimestamp("updated_at", { withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdate(() => /* @__PURE__ */ new Date());
111
+ return _pgTimestamp("updated_at", { withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdate(() => /* @__PURE__ */ new Date());
112
+ }
113
+ };
114
+ export const pgCreatedAt = {
115
+ get createdAt() {
116
+ return _pgTimestamp("created_at", { withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date());
117
+ }
118
+ };
119
+ export const pgUpdatedAt = {
120
+ get updatedAt() {
121
+ return _pgTimestamp("updated_at", { withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdate(() => /* @__PURE__ */ new Date());
200
122
  }
201
123
  };
202
124
  export const pgsoftdelete = {
203
125
  get deletedAt() {
204
- return pgTimestamp("deleted_at", { withTimezone: true });
126
+ return _pgTimestamp("deleted_at", { withTimezone: true });
205
127
  }
206
128
  };
207
129
  export const pgtenantid = {
208
130
  get tenantId() {
209
- return pgText("tenant_id");
131
+ return _pgText("tenant_id");
210
132
  }
211
133
  };
212
134
  import {
213
- varchar as mysqlVarcharCol,
214
- serial as mysqlSerialCol,
215
- timestamp as mysqlTimestampCol
135
+ varchar as _mysqlVarchar,
136
+ serial as _mysqlSerial,
137
+ timestamp as _mysqlTimestamp
216
138
  } from "drizzle-orm/mysql-core";
217
139
  export const msid = {
218
140
  get id() {
219
- return mysqlVarcharCol("id", { length: 36 }).primaryKey().$defaultFn(() => generateUUIDv7());
141
+ return _mysqlVarchar("id", { length: 36 }).primaryKey().$defaultFn(() => generateUUIDv7());
220
142
  }
221
143
  };
222
144
  export const msuuid = {
223
145
  get id() {
224
- return mysqlVarcharCol("id", { length: 36 }).primaryKey().$defaultFn(() => crypto.randomUUID());
146
+ return _mysqlVarchar("id", { length: 36 }).primaryKey().$defaultFn(() => crypto.randomUUID());
225
147
  }
226
148
  };
227
149
  export const msint = {
228
150
  get id() {
229
- return mysqlSerialCol("id").primaryKey();
151
+ return _mysqlSerial("id").primaryKey();
230
152
  }
231
153
  };
232
154
  export const mstimestamps = {
233
155
  get createdAt() {
234
- return mysqlTimestampCol("created_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date());
156
+ return _mysqlTimestamp("created_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date());
235
157
  },
236
158
  get updatedAt() {
237
- return mysqlTimestampCol("updated_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdate(() => /* @__PURE__ */ new Date());
159
+ return _mysqlTimestamp("updated_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdate(() => /* @__PURE__ */ new Date());
238
160
  }
239
161
  };
240
162
  export const msCreatedAt = {
241
163
  get createdAt() {
242
- return mysqlTimestampCol("created_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date());
164
+ return _mysqlTimestamp("created_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date());
243
165
  }
244
166
  };
245
167
  export const msUpdatedAt = {
246
168
  get updatedAt() {
247
- return mysqlTimestampCol("updated_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdate(() => /* @__PURE__ */ new Date());
169
+ return _mysqlTimestamp("updated_at").notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdate(() => /* @__PURE__ */ new Date());
248
170
  }
249
171
  };
250
172
  export const mssoftdelete = {
251
173
  get deletedAt() {
252
- return mysqlTimestampCol("deleted_at");
174
+ return _mysqlTimestamp("deleted_at");
253
175
  }
254
176
  };
255
177
  export const mstenantid = {
256
178
  get tenantId() {
257
- return mysqlVarcharCol("tenant_id", { length: 36 });
179
+ return _mysqlVarchar("tenant_id", { length: 36 });
258
180
  }
259
181
  };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * POST /__qarpeo/cloud/agents/run
3
+ *
4
+ * Invokes a registered AI agent with a test prompt from Qarpeo Cloud.
5
+ * Requires `Authorization: Bearer <QARPEO_CLOUD_SECRET>`.
6
+ */
7
+ declare const _default: import("nuxt/server").EventHandler<Promise<{
8
+ ok: boolean;
9
+ agent: string;
10
+ model: string | undefined;
11
+ reply: any;
12
+ }>>;
13
+ export default _default;
@@ -0,0 +1,46 @@
1
+ import { createError, defineEventHandler, readBody } from "nuxt/server";
2
+ import { getAgentDefinition, useAgent } from "../../../../utils/ai.mjs";
3
+ import { verifyCloudSecret } from "../../../../utils/cloud-auth.mjs";
4
+ export default defineEventHandler(async (event) => {
5
+ verifyCloudSecret(event);
6
+ const body = await readBody(event).catch(() => ({}));
7
+ const agentName = typeof body?.agent === "string" ? body.agent.trim() : "";
8
+ const message = typeof body?.message === "string" ? body.message.trim() : "";
9
+ if (!agentName) {
10
+ throw createError({
11
+ statusCode: 400,
12
+ statusMessage: "Bad Request",
13
+ message: "agent name is required."
14
+ });
15
+ }
16
+ if (!message) {
17
+ throw createError({
18
+ statusCode: 400,
19
+ statusMessage: "Bad Request",
20
+ message: "message is required."
21
+ });
22
+ }
23
+ const def = getAgentDefinition(agentName);
24
+ if (!def) {
25
+ throw createError({
26
+ statusCode: 404,
27
+ statusMessage: "Not Found",
28
+ message: `Agent "${agentName}" is not registered on this Worker.`
29
+ });
30
+ }
31
+ const model = typeof body?.model === "string" && body.model.trim() ? body.model.trim() : def.model;
32
+ const client = useAgent(agentName, "cloud-console", event);
33
+ const res = await client.chat(message, {
34
+ stream: false,
35
+ model,
36
+ system: def.system
37
+ });
38
+ const data = await res.json();
39
+ const reply = data.reply || data.message?.content || data.response || "";
40
+ return {
41
+ ok: true,
42
+ agent: agentName,
43
+ model,
44
+ reply
45
+ };
46
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * GET /__qarpeo/cloud/cms/entry?id=<entryId>
3
+ *
4
+ * Fetches a single CMS entry with full `contentMd`, `description`, and `metadataJson`.
5
+ */
6
+ declare const _default: import("nuxt/server").EventHandler<Promise<{
7
+ ok: boolean;
8
+ entry: {
9
+ id: any;
10
+ collection: any;
11
+ slug: any;
12
+ title: any;
13
+ description: any;
14
+ body: any;
15
+ status: any;
16
+ metadataJson: any;
17
+ createdAt: any;
18
+ updatedAt: any;
19
+ publishedAt: any;
20
+ };
21
+ }>>;
22
+ export default _default;
@@ -0,0 +1,40 @@
1
+ import { createError, 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 qs = getQuery(event);
8
+ const id = typeof qs.id === "string" ? qs.id.trim() : "";
9
+ if (!id) {
10
+ throw createError({ statusCode: 400, statusMessage: "Bad Request", message: "id is required" });
11
+ }
12
+ const d1 = getD1Binding(event);
13
+ if (!d1) {
14
+ throw createError({ statusCode: 500, statusMessage: "Internal Server Error", message: "D1 unavailable" });
15
+ }
16
+ const entryTable = resolveTableName("cms_entry").replace(/"/g, "");
17
+ const row = await d1.prepare(
18
+ `SELECT id, collection_id, slug, title, description, content_md, status, metadata_json, created_at, updated_at, published_at
19
+ FROM "${entryTable}" WHERE id = ?1 LIMIT 1`
20
+ ).bind(id).first();
21
+ if (!row) {
22
+ throw createError({ statusCode: 404, statusMessage: "Not Found", message: "CMS entry not found" });
23
+ }
24
+ return {
25
+ ok: true,
26
+ entry: {
27
+ id: row.id,
28
+ collection: row.collection_id,
29
+ slug: row.slug,
30
+ title: row.title,
31
+ description: row.description || "",
32
+ body: row.content_md || "",
33
+ status: row.status,
34
+ metadataJson: row.metadata_json || "{}",
35
+ createdAt: row.created_at,
36
+ updatedAt: row.updated_at,
37
+ publishedAt: row.published_at
38
+ }
39
+ };
40
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * POST /__qarpeo/cloud/cms/entry
3
+ *
4
+ * Create, update, or delete a CMS entry directly from Qarpeo Cloud.
5
+ * Body: `{ action?: "save" | "delete", id?, collection, title, slug?, description?, body?, status? }`
6
+ */
7
+ declare const _default: import("nuxt/server").EventHandler<Promise<{
8
+ ok: boolean;
9
+ deleted: string;
10
+ id?: undefined;
11
+ slug?: undefined;
12
+ status?: undefined;
13
+ } | {
14
+ ok: boolean;
15
+ id: string;
16
+ slug: string;
17
+ status: "published" | "draft" | "archived";
18
+ deleted?: undefined;
19
+ }>>;
20
+ export default _default;