qarpeo 0.2.0 → 0.3.0

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 (260) hide show
  1. package/dist/chunks/tools.mjs +993 -31
  2. package/dist/cli/index.mjs +1102 -31
  3. package/dist/fate/index.d.ts +9 -1
  4. package/dist/fate/index.mjs +20 -3
  5. package/dist/module.mjs +296 -753
  6. package/dist/runtime/browser.mjs +2 -2
  7. package/dist/runtime/comments-server.d.ts +3 -0
  8. package/dist/runtime/comments-server.mjs +2 -0
  9. package/dist/runtime/comments.d.ts +0 -2
  10. package/dist/runtime/comments.mjs +0 -2
  11. package/dist/runtime/db.d.ts +10 -9
  12. package/dist/runtime/db.mjs +79 -8
  13. package/dist/runtime/drizzle.mjs +21 -6
  14. package/dist/runtime/index.d.ts +4 -0
  15. package/dist/runtime/realtime-server.d.ts +4 -0
  16. package/dist/runtime/realtime-server.mjs +13 -0
  17. package/dist/runtime/realtime.d.ts +1 -4
  18. package/dist/runtime/realtime.mjs +0 -13
  19. package/dist/runtime/replica.d.ts +27 -0
  20. package/dist/runtime/replica.mjs +229 -0
  21. package/dist/runtime/server/durable-objects/agent.mjs +14 -2
  22. package/dist/runtime/server/durable-objects/room.d.ts +10 -0
  23. package/dist/runtime/server/durable-objects/room.mjs +119 -28
  24. package/dist/runtime/server/middleware/devtools.mjs +1 -1
  25. package/dist/runtime/server/middleware/tenancy.mjs +7 -4
  26. package/dist/runtime/server/plugins/store.mjs +1 -1
  27. package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +57 -17
  28. package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +19 -12
  29. package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +8 -9
  30. package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +8 -9
  31. package/dist/runtime/server/routes/analytics/events.get.mjs +12 -2
  32. package/dist/runtime/server/routes/analytics/pageviews.get.mjs +10 -1
  33. package/dist/runtime/server/routes/analytics/summary.get.mjs +10 -1
  34. package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +11 -2
  35. package/dist/runtime/server/routes/auth/2fa/setup.post.mjs +7 -0
  36. package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +11 -2
  37. package/dist/runtime/server/routes/auth/account.delete.mjs +7 -0
  38. package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +5 -3
  39. package/dist/runtime/server/routes/auth/organization/sso/index.post.mjs +10 -0
  40. package/dist/runtime/server/routes/auth/otp/verify.post.mjs +5 -3
  41. package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +18 -0
  42. package/dist/runtime/server/routes/auth/webauthn/login/options.post.d.ts +1 -1
  43. package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +11 -2
  44. package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +10 -1
  45. package/dist/runtime/server/routes/auth/webauthn/register/options.post.d.ts +1 -1
  46. package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +10 -1
  47. package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +10 -1
  48. package/dist/runtime/server/routes/browser/crawl.post.mjs +13 -0
  49. package/dist/runtime/server/routes/browser/invoice.post.mjs +15 -1
  50. package/dist/runtime/server/routes/browser/og-image.post.mjs +13 -0
  51. package/dist/runtime/server/routes/browser/pdf.post.mjs +15 -1
  52. package/dist/runtime/server/routes/browser/screenshot.post.mjs +13 -0
  53. package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.mjs +23 -8
  54. package/dist/runtime/server/routes/cms/[collection]/[id]/publish.post.mjs +2 -1
  55. package/dist/runtime/server/routes/cms/[collection]/[id]/review.post.mjs +2 -1
  56. package/dist/runtime/server/routes/cms/[collection]/[id]/revisions/[revId]/restore.post.mjs +2 -1
  57. package/dist/runtime/server/routes/cms/[collection]/[id].delete.mjs +2 -1
  58. package/dist/runtime/server/routes/cms/[collection]/[id].put.mjs +2 -1
  59. package/dist/runtime/server/routes/cms/[collection]/index.post.mjs +2 -1
  60. package/dist/runtime/server/routes/cms/categories/[id].delete.mjs +2 -1
  61. package/dist/runtime/server/routes/cms/categories/[id].put.mjs +2 -1
  62. package/dist/runtime/server/routes/cms/categories.post.mjs +2 -1
  63. package/dist/runtime/server/routes/cms/collections/[id].delete.mjs +2 -1
  64. package/dist/runtime/server/routes/cms/collections/[id].put.mjs +2 -1
  65. package/dist/runtime/server/routes/cms/collections/index.post.mjs +2 -1
  66. package/dist/runtime/server/routes/cms/export.post.mjs +1 -1
  67. package/dist/runtime/server/routes/cms/subscribers/[id].delete.mjs +2 -1
  68. package/dist/runtime/server/routes/cms/subscribers/[id].patch.mjs +2 -1
  69. package/dist/runtime/server/routes/cms/tags/[id].delete.mjs +2 -1
  70. package/dist/runtime/server/routes/cms/tags.post.mjs +2 -1
  71. package/dist/runtime/server/routes/comments/[id]/react.post.mjs +7 -3
  72. package/dist/runtime/server/routes/comments/[id]/report.post.mjs +3 -0
  73. package/dist/runtime/server/routes/comments/[id].delete.mjs +1 -1
  74. package/dist/runtime/server/routes/comments/[id].get.mjs +13 -0
  75. package/dist/runtime/server/routes/comments/[id].patch.mjs +1 -1
  76. package/dist/runtime/server/routes/fate.d.ts +6 -0
  77. package/dist/runtime/server/routes/fate.mjs +32 -3
  78. package/dist/runtime/server/routes/mail/bounce.post.mjs +14 -2
  79. package/dist/runtime/server/routes/mail/unsubscribe.mjs +2 -1
  80. package/dist/runtime/server/routes/mail/webhooks.post.mjs +18 -4
  81. package/dist/runtime/server/routes/notifications/[id].get.mjs +3 -4
  82. package/dist/runtime/server/routes/notifications/index.get.mjs +4 -2
  83. package/dist/runtime/server/routes/notifications/push/subscribe.post.mjs +3 -1
  84. package/dist/runtime/server/routes/notifications/push/unsubscribe.post.mjs +5 -3
  85. package/dist/runtime/server/routes/notifications/read-all.post.mjs +6 -2
  86. package/dist/runtime/server/routes/notifications/send.post.mjs +13 -2
  87. package/dist/runtime/server/routes/payments/cancel.post.mjs +1 -1
  88. package/dist/runtime/server/routes/payments/change-plan.post.mjs +1 -1
  89. package/dist/runtime/server/routes/payments/checkout.post.mjs +1 -1
  90. package/dist/runtime/server/routes/payments/pause.post.mjs +1 -1
  91. package/dist/runtime/server/routes/payments/portal.post.mjs +1 -1
  92. package/dist/runtime/server/routes/payments/subscription.get.mjs +1 -1
  93. package/dist/runtime/server/routes/payments/usage.get.mjs +1 -1
  94. package/dist/runtime/server/routes/payments/usage.post.mjs +1 -1
  95. package/dist/runtime/server/routes/payments/webhook.post.mjs +8 -1
  96. package/dist/runtime/server/routes/realtime/broadcast.post.mjs +3 -2
  97. package/dist/runtime/server/routes/realtime/history.delete.mjs +2 -2
  98. package/dist/runtime/server/routes/realtime/history.get.mjs +2 -2
  99. package/dist/runtime/server/routes/realtime/presence.get.mjs +3 -3
  100. package/dist/runtime/server/routes/realtime/state.get.mjs +3 -3
  101. package/dist/runtime/server/routes/realtime/state.post.mjs +13 -4
  102. package/dist/runtime/server/routes/realtime/ws.get.mjs +2 -2
  103. package/dist/runtime/server/routes/storage/file/[...key].delete.mjs +1 -1
  104. package/dist/runtime/server/routes/storage/file/[...key].get.mjs +7 -0
  105. package/dist/runtime/server/routes/storage/files.get.d.ts +1 -1
  106. package/dist/runtime/server/routes/storage/files.get.mjs +24 -4
  107. package/dist/runtime/server/routes/storage/multipart/abort.post.mjs +16 -1
  108. package/dist/runtime/server/routes/storage/multipart/complete.post.d.ts +1 -1
  109. package/dist/runtime/server/routes/storage/multipart/complete.post.mjs +15 -1
  110. package/dist/runtime/server/routes/storage/multipart/create.post.mjs +7 -0
  111. package/dist/runtime/server/routes/storage/multipart/part.put.mjs +15 -1
  112. package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +8 -1
  113. package/dist/runtime/server/routes/storage/presigned.post.d.ts +1 -1
  114. package/dist/runtime/server/routes/storage/presigned.post.mjs +8 -1
  115. package/dist/runtime/server/routes/storage/sign.post.mjs +7 -0
  116. package/dist/runtime/server/routes/storage/upload.post.d.ts +2 -2
  117. package/dist/runtime/server/routes/store/cart/index.delete.mjs +3 -4
  118. package/dist/runtime/server/routes/store/cart/index.get.mjs +3 -10
  119. package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +6 -4
  120. package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +12 -4
  121. package/dist/runtime/server/routes/store/cart/items.post.mjs +9 -10
  122. package/dist/runtime/server/routes/store/categories/index.get.mjs +4 -2
  123. package/dist/runtime/server/routes/store/checkout.post.mjs +13 -3
  124. package/dist/runtime/server/routes/store/coupons/apply.post.mjs +6 -5
  125. package/dist/runtime/server/routes/store/orders/[id].get.mjs +2 -2
  126. package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +6 -3
  127. package/dist/runtime/server/routes/store/orders/index.get.mjs +1 -1
  128. package/dist/runtime/server/routes/store/products/[slug].get.mjs +2 -2
  129. package/dist/runtime/server/routes/store/products/index.get.mjs +1 -1
  130. package/dist/runtime/server/routes/store/tax/calculate.post.mjs +10 -0
  131. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +26 -25
  132. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +26 -25
  133. package/dist/runtime/server/utils/ai.d.ts +6 -0
  134. package/dist/runtime/server/utils/ai.mjs +12 -2
  135. package/dist/runtime/server/utils/analytics-query.mjs +8 -4
  136. package/dist/runtime/server/utils/browser-utils.d.ts +9 -0
  137. package/dist/runtime/server/utils/browser-utils.mjs +135 -0
  138. package/dist/runtime/server/utils/cms/cache.d.ts +13 -0
  139. package/dist/runtime/server/utils/cms/cache.mjs +95 -0
  140. package/dist/runtime/server/utils/cms/common.mjs +1 -1
  141. package/dist/runtime/server/utils/cms/markdown.mjs +38 -8
  142. package/dist/runtime/server/utils/cms/mutations.d.ts +26 -0
  143. package/dist/runtime/server/utils/cms/mutations.mjs +569 -0
  144. package/dist/runtime/server/utils/cms/path.d.ts +8 -0
  145. package/dist/runtime/server/utils/cms/path.mjs +23 -0
  146. package/dist/runtime/server/utils/cms/queries.d.ts +27 -0
  147. package/dist/runtime/server/utils/cms/queries.mjs +366 -0
  148. package/dist/runtime/server/utils/cms/references.d.ts +48 -0
  149. package/dist/runtime/server/utils/cms/references.mjs +309 -0
  150. package/dist/runtime/server/utils/cms/revisions.d.ts +7 -0
  151. package/dist/runtime/server/utils/cms/revisions.mjs +60 -0
  152. package/dist/runtime/server/utils/cms/sync.mjs +3 -3
  153. package/dist/runtime/server/utils/cms.d.ts +5 -82
  154. package/dist/runtime/server/utils/cms.mjs +28 -1367
  155. package/dist/runtime/server/utils/comments.d.ts +11 -0
  156. package/dist/runtime/server/utils/comments.mjs +65 -17
  157. package/dist/runtime/server/utils/crypto.mjs +1 -1
  158. package/dist/runtime/server/utils/domains.mjs +9 -0
  159. package/dist/runtime/server/utils/drizzle.d.ts +26 -1
  160. package/dist/runtime/server/utils/drizzle.mjs +78 -19
  161. package/dist/runtime/server/utils/email-inbound.mjs +9 -1
  162. package/dist/runtime/server/utils/impersonation.mjs +58 -1
  163. package/dist/runtime/server/utils/lock.d.ts +11 -0
  164. package/dist/runtime/server/utils/lock.mjs +4 -0
  165. package/dist/runtime/server/utils/mail-suppression.mjs +48 -13
  166. package/dist/runtime/server/utils/mail.d.ts +2 -1
  167. package/dist/runtime/server/utils/mail.mjs +17 -11
  168. package/dist/runtime/server/utils/notifications.d.ts +13 -4
  169. package/dist/runtime/server/utils/notifications.mjs +20 -4
  170. package/dist/runtime/server/utils/organization.mjs +36 -1
  171. package/dist/runtime/server/utils/passwordless.mjs +8 -0
  172. package/dist/runtime/server/utils/payments/checkout.d.ts +34 -0
  173. package/dist/runtime/server/utils/payments/checkout.mjs +158 -0
  174. package/dist/runtime/server/utils/payments/common.d.ts +45 -0
  175. package/dist/runtime/server/utils/payments/common.mjs +234 -0
  176. package/dist/runtime/server/utils/payments/index.d.ts +9 -0
  177. package/dist/runtime/server/utils/payments/index.mjs +21 -0
  178. package/dist/runtime/server/utils/payments/lemonsqueezy.d.ts +7 -0
  179. package/dist/runtime/server/utils/payments/lemonsqueezy.mjs +55 -0
  180. package/dist/runtime/server/utils/payments/paddle.d.ts +7 -0
  181. package/dist/runtime/server/utils/payments/paddle.mjs +92 -0
  182. package/dist/runtime/server/utils/payments/polar.d.ts +11 -0
  183. package/dist/runtime/server/utils/payments/polar.mjs +66 -0
  184. package/dist/runtime/server/utils/payments/stripe.d.ts +7 -0
  185. package/dist/runtime/server/utils/payments/stripe.mjs +159 -0
  186. package/dist/runtime/server/utils/payments/subscriptions.d.ts +89 -0
  187. package/dist/runtime/server/utils/payments/subscriptions.mjs +236 -0
  188. package/dist/runtime/server/utils/payments/usage.d.ts +12 -0
  189. package/dist/runtime/server/utils/payments/usage.mjs +143 -0
  190. package/dist/runtime/server/utils/payments/webhooks.d.ts +10 -0
  191. package/dist/runtime/server/utils/payments/webhooks.mjs +200 -0
  192. package/dist/runtime/server/utils/payments.d.ts +1 -158
  193. package/dist/runtime/server/utils/payments.mjs +1 -1289
  194. package/dist/runtime/server/utils/queue.d.ts +2 -0
  195. package/dist/runtime/server/utils/queue.mjs +34 -21
  196. package/dist/runtime/server/utils/rag.mjs +30 -17
  197. package/dist/runtime/server/utils/realtime.d.ts +5 -1
  198. package/dist/runtime/server/utils/realtime.mjs +43 -7
  199. package/dist/runtime/server/utils/session.mjs +16 -3
  200. package/dist/runtime/server/utils/sso.d.ts +3 -0
  201. package/dist/runtime/server/utils/sso.mjs +43 -0
  202. package/dist/runtime/server/utils/storage.mjs +12 -1
  203. package/dist/runtime/server/utils/store/cart.d.ts +63 -0
  204. package/dist/runtime/server/utils/store/cart.mjs +542 -0
  205. package/dist/runtime/server/utils/store/checkout.d.ts +14 -0
  206. package/dist/runtime/server/utils/store/checkout.mjs +118 -0
  207. package/dist/runtime/server/utils/store/common.d.ts +29 -0
  208. package/dist/runtime/server/utils/store/common.mjs +479 -0
  209. package/dist/runtime/server/utils/store/index.d.ts +7 -0
  210. package/dist/runtime/server/utils/store/index.mjs +30 -0
  211. package/dist/runtime/server/utils/store/inventory.d.ts +25 -0
  212. package/dist/runtime/server/utils/store/inventory.mjs +190 -0
  213. package/dist/runtime/server/utils/store/orders.d.ts +60 -0
  214. package/dist/runtime/server/utils/store/orders.mjs +590 -0
  215. package/dist/runtime/server/utils/store/products.d.ts +35 -0
  216. package/dist/runtime/server/utils/store/products.mjs +461 -0
  217. package/dist/runtime/server/utils/store/vendor.d.ts +18 -0
  218. package/dist/runtime/server/utils/store/vendor.mjs +68 -0
  219. package/dist/runtime/server/utils/store.d.ts +1 -207
  220. package/dist/runtime/server/utils/store.mjs +1 -2227
  221. package/dist/runtime/server/utils/string.d.ts +1 -1
  222. package/dist/runtime/server/utils/string.mjs +12 -4
  223. package/dist/runtime/server/utils/tenant.mjs +19 -5
  224. package/dist/runtime/server/utils/tracker.mjs +2 -0
  225. package/dist/runtime/server.d.ts +3 -3
  226. package/dist/runtime/server.mjs +4 -4
  227. package/dist/runtime/storage-server.d.ts +2 -0
  228. package/dist/runtime/storage-server.mjs +1 -0
  229. package/dist/runtime/storage.d.ts +1 -1
  230. package/dist/runtime/storage.mjs +0 -1
  231. package/dist/runtime/store.d.ts +0 -1
  232. package/dist/runtime/store.mjs +0 -1
  233. package/dist/runtime/test-utils.d.ts +4 -0
  234. package/dist/runtime/test-utils.mjs +54 -0
  235. package/dist/runtime/types/d1.d.ts +43 -0
  236. package/dist/runtime/types/drizzle.d.ts +6 -0
  237. package/dist/runtime/types/store.d.ts +1 -1
  238. package/dist/types/analytics.d.ts +80 -0
  239. package/dist/types/auth.d.ts +282 -0
  240. package/dist/types/cache.d.ts +55 -0
  241. package/dist/types/comments.d.ts +130 -0
  242. package/dist/types/db.d.ts +29 -0
  243. package/dist/types/email.d.ts +182 -0
  244. package/dist/types/index.d.ts +22 -0
  245. package/dist/types/jobs.d.ts +58 -0
  246. package/dist/types/notifications.d.ts +77 -0
  247. package/dist/types/options.d.ts +363 -0
  248. package/dist/types/payments.d.ts +145 -0
  249. package/dist/types/ratelimit.d.ts +71 -0
  250. package/dist/types/realtime.d.ts +136 -0
  251. package/dist/types/site.d.ts +121 -0
  252. package/dist/types/storage.d.ts +164 -0
  253. package/dist/types/store-options.d.ts +199 -0
  254. package/dist/types/tenant.d.ts +100 -0
  255. package/dist/types.d.ts +1 -2174
  256. package/dist/utils/migration-lock.d.ts +139 -0
  257. package/dist/utils/pkg.d.ts +14 -1
  258. package/dist/utils/schema-diff.d.ts +39 -0
  259. package/package.json +55 -17
  260. package/dist/chunks/auth-schema.mjs +0 -364
package/dist/module.mjs CHANGED
@@ -2,16 +2,10 @@ import { existsSync, rmSync, readdirSync, readFileSync, appendFileSync } from 'n
2
2
  import { dirname, resolve, normalize, relative, join } from 'pathe';
3
3
  import { addTemplate, hasNuxtModule, addNitroPlugin, addServerImports, addImports, addTypeTemplate, updateTemplates, addServerImportsDir, addServerHandler, extendPages, addPlugin, addComponent, addImportsDir, addRouteMiddleware, installModule, defineNuxtModule, useLogger, createResolver } from '@nuxt/kit';
4
4
  import { defu } from 'defu';
5
- import { q as buildDevWranglerConfig, f as checkDrizzleVersion, t as scanSchemaExports, d as discoverDatabases, u as findScheduledTasks, w as resolveBindingName, x as createWranglerConfig, y as generateDevWranglerConfig, z as applyD1Migrations, v as version, A as findQueueFiles, n as findJobFiles, p as findEmailHandlerFiles, B as findDurableObjectFiles, o as findWorkflowFiles, e as ensurePackage, j as findAgentFiles, k as findToolFiles, l as findBotFiles, m as findMcpFiles, h as findSchemaFiles } from './chunks/tools.mjs';
6
- export { C as hasDatabaseSchema, r as resolveDatabaseTarget, c as resolveProjectName } from './chunks/tools.mjs';
7
- import { r as resolveTableName, a as resolveIndexName, g as generateAuthSchema } from './chunks/auth-schema.mjs';
8
- export { b as getActiveAuthTableNames } from './chunks/auth-schema.mjs';
9
- import { snakeCase, integer, text, index, uniqueIndex } from 'drizzle-orm/sqlite-core';
5
+ import { x as resolveTableName, y as resolveIndexName, z as buildDevWranglerConfig, l as checkDrizzleVersion, B as generateAuthSchema, C as generateCommentsSchema, D as generateStoreSchema, s as scanSchemaExports, f as discoverDatabases, E as findScheduledTasks, F as formatDlxCommand, G as resolveBindingName, H as createWranglerConfig, I as generateDevWranglerConfig, J as applyD1Migrations, w as version, K as findQueueFiles, t as findJobFiles, v as findEmailHandlerFiles, L as findDurableObjectFiles, u as findWorkflowFiles, e as ensurePackage, n as findAgentFiles, o as findToolFiles, p as findBotFiles, q as findMcpFiles, m as findSchemaFiles } from './chunks/tools.mjs';
6
+ export { A as ALL_CMS_TABLE_NAMES, d as ALL_COMMENTS_TABLE_NAMES, c as ALL_STORE_TABLE_NAMES, M as cmsBookmarks, N as cmsCategories, O as cmsCollections, P as cmsEntries, Q as cmsRevisions, R as cmsSubscribers, S as cmsTags, b as getActiveAuthTableNames, T as getActiveCmsTableNames, U as getActiveCommentsTableNames, V as getActiveStoreTableNames, W as hasDatabaseSchema, r as resolveDatabaseTarget, k as resolveProjectName } from './chunks/tools.mjs';
10
7
  import { createHash } from 'node:crypto';
11
8
  import { readdir, readFile } from 'node:fs/promises';
12
- import { parseMarkdown } from 'comark';
13
- import { render } from 'comark/render';
14
- import { parse } from 'yaml';
15
9
  import { downloadTemplate } from 'giget';
16
10
  import { createRequire } from 'node:module';
17
11
  import { fileURLToPath } from 'node:url';
@@ -19,185 +13,9 @@ import 'node:child_process';
19
13
  import 'drizzle-orm/node-sqlite';
20
14
  import 'node:process';
21
15
  import 'node:readline/promises';
16
+ import 'drizzle-orm/sqlite-core';
22
17
  import 'nuxt/server';
23
18
 
24
- const ALL_CMS_TABLE_NAMES = [
25
- "cms_collection",
26
- "cms_entry",
27
- "cms_revision",
28
- "cms_category",
29
- "cms_tag",
30
- "cms_bookmark",
31
- "cms_subscriber"
32
- ];
33
- function getActiveCmsTableNames(cms, prefixOrOptions) {
34
- if (!cms) return [];
35
- return [
36
- resolveTableName("cms_collection", prefixOrOptions),
37
- resolveTableName("cms_entry", prefixOrOptions),
38
- resolveTableName("cms_revision", prefixOrOptions),
39
- resolveTableName("cms_category", prefixOrOptions),
40
- resolveTableName("cms_tag", prefixOrOptions),
41
- resolveTableName("cms_bookmark", prefixOrOptions),
42
- resolveTableName("cms_subscriber", prefixOrOptions)
43
- ];
44
- }
45
- const collectionTbl = resolveTableName("cms_collection");
46
- const entryTbl = resolveTableName("cms_entry");
47
- const revisionTbl = resolveTableName("cms_revision");
48
- const categoryTbl = resolveTableName("cms_category");
49
- const tagTbl = resolveTableName("cms_tag");
50
- const bookmarkTbl = resolveTableName("cms_bookmark");
51
- const subscriberTbl = resolveTableName("cms_subscriber");
52
- const cmsCollection = snakeCase.table(collectionTbl, {
53
- id: text().primaryKey(),
54
- tenantId: text(),
55
- name: text().notNull(),
56
- description: text(),
57
- schemaJson: text().notNull().default("{}"),
58
- source: text().notNull().default("db"),
59
- order: integer().notNull().default(0),
60
- createdAt: integer().notNull(),
61
- updatedAt: integer().notNull()
62
- });
63
- const cmsCollections = cmsCollection;
64
- const cmsEntry = snakeCase.table(
65
- entryTbl,
66
- {
67
- id: text().primaryKey(),
68
- tenantId: text(),
69
- collectionId: text().notNull(),
70
- slug: text().notNull(),
71
- title: text().notNull(),
72
- description: text(),
73
- coverImage: text(),
74
- tags: text(),
75
- order: integer().notNull().default(0),
76
- contentMd: text().notNull().default(""),
77
- contentHtml: text().notNull().default(""),
78
- metadataJson: text().default("{}"),
79
- status: text().notNull().default("draft"),
80
- source: text().notNull().default("db"),
81
- path: text(),
82
- filePath: text(),
83
- contentHash: text(),
84
- authorId: text(),
85
- categoryId: text(),
86
- subCategoryId: text(),
87
- featured: integer({ mode: "boolean" }).notNull().default(false),
88
- viewCount: integer().notNull().default(0),
89
- readingTime: integer(),
90
- locale: text().notNull().default("en"),
91
- version: text().notNull().default("latest"),
92
- publishedAt: integer(),
93
- createdAt: integer().notNull(),
94
- updatedAt: integer().notNull()
95
- },
96
- (t) => [
97
- index(resolveIndexName(entryTbl, "collection")).on(t.collectionId),
98
- index(resolveIndexName(entryTbl, "tenant")).on(t.tenantId, t.collectionId),
99
- uniqueIndex(resolveIndexName(entryTbl, "slug")).on(t.collectionId, t.slug),
100
- index(resolveIndexName(entryTbl, "status")).on(t.status),
101
- index(resolveIndexName(entryTbl, "order")).on(t.collectionId, t.order),
102
- index(resolveIndexName(entryTbl, "path")).on(t.collectionId, t.path),
103
- index(resolveIndexName(entryTbl, "locale")).on(t.collectionId, t.locale),
104
- index(resolveIndexName(entryTbl, "path_locale")).on(t.path, t.locale),
105
- index(resolveIndexName(entryTbl, "category")).on(t.collectionId, t.categoryId),
106
- index(resolveIndexName(entryTbl, "featured")).on(t.collectionId, t.featured),
107
- index(resolveIndexName(entryTbl, "published_at")).on(t.publishedAt),
108
- index(resolveIndexName(entryTbl, "list")).on(t.collectionId, t.status, t.publishedAt)
109
- ]
110
- );
111
- const cmsEntries = cmsEntry;
112
- const cmsRevision = snakeCase.table(
113
- revisionTbl,
114
- {
115
- id: text().primaryKey(),
116
- entryId: text().notNull(),
117
- title: text().notNull(),
118
- contentMd: text().notNull(),
119
- metadataJson: text().default("{}"),
120
- authorId: text(),
121
- createdAt: integer().notNull()
122
- },
123
- (t) => [index(resolveIndexName(revisionTbl, "entry")).on(t.entryId, t.createdAt)]
124
- );
125
- const cmsRevisions = cmsRevision;
126
- const cmsCategory = snakeCase.table(
127
- categoryTbl,
128
- {
129
- id: text().primaryKey(),
130
- tenantId: text(),
131
- name: text().notNull(),
132
- slug: text().notNull(),
133
- description: text(),
134
- icon: text(),
135
- parentId: text(),
136
- order: integer().notNull().default(0),
137
- metadataJson: text().default("{}"),
138
- createdAt: integer().notNull(),
139
- updatedAt: integer().notNull()
140
- },
141
- (t) => [
142
- uniqueIndex(resolveIndexName(categoryTbl, "slug")).on(t.tenantId, t.slug),
143
- index(resolveIndexName(categoryTbl, "parent")).on(t.parentId),
144
- index(resolveIndexName(categoryTbl, "tenant")).on(t.tenantId)
145
- ]
146
- );
147
- const cmsCategories = cmsCategory;
148
- const cmsTag = snakeCase.table(
149
- tagTbl,
150
- {
151
- id: text().primaryKey(),
152
- tenantId: text(),
153
- name: text().notNull(),
154
- slug: text().notNull(),
155
- description: text(),
156
- count: integer().notNull().default(0),
157
- metadataJson: text().default("{}"),
158
- createdAt: integer().notNull(),
159
- updatedAt: integer().notNull()
160
- },
161
- (t) => [
162
- uniqueIndex(resolveIndexName(tagTbl, "slug")).on(t.tenantId, t.slug),
163
- index(resolveIndexName(tagTbl, "tenant")).on(t.tenantId)
164
- ]
165
- );
166
- const cmsTags = cmsTag;
167
- const cmsBookmark = snakeCase.table(
168
- bookmarkTbl,
169
- {
170
- id: text().primaryKey(),
171
- tenantId: text(),
172
- userId: text().notNull(),
173
- entryId: text().notNull(),
174
- createdAt: integer().notNull()
175
- },
176
- (t) => [
177
- index(resolveIndexName(bookmarkTbl, "user")).on(t.userId),
178
- index(resolveIndexName(bookmarkTbl, "entry")).on(t.entryId),
179
- uniqueIndex(resolveIndexName(bookmarkTbl, "unique")).on(t.tenantId, t.userId, t.entryId)
180
- ]
181
- );
182
- const cmsBookmarks = cmsBookmark;
183
- const cmsSubscriber = snakeCase.table(
184
- subscriberTbl,
185
- {
186
- id: text().primaryKey(),
187
- tenantId: text(),
188
- email: text().notNull(),
189
- status: text().notNull().default("active"),
190
- source: text().default("website"),
191
- createdAt: integer().notNull()
192
- },
193
- (t) => [
194
- uniqueIndex(resolveIndexName(subscriberTbl, "unique_email")).on(t.tenantId, t.email),
195
- index(resolveIndexName(subscriberTbl, "status")).on(t.status),
196
- index(resolveIndexName(subscriberTbl, "tenant")).on(t.tenantId)
197
- ]
198
- );
199
- const cmsSubscribers = cmsSubscriber;
200
-
201
19
  function getActivePaymentsTableNames(payments, prefixOrOptions) {
202
20
  if (!payments) return [];
203
21
  return [
@@ -383,375 +201,6 @@ function generateNotificationsSchema(notifications, prefixOrOptions) {
383
201
  return lines.join("\n") + "\n";
384
202
  }
385
203
 
386
- const ALL_COMMENTS_TABLE_NAMES = [
387
- "comment",
388
- "comment_report",
389
- "comment_reaction"
390
- ];
391
- function getActiveCommentsTableNames(comments, prefixOrOptions) {
392
- if (!comments) return [];
393
- const resolvedPrefix = prefixOrOptions !== void 0 ? prefixOrOptions : typeof comments === "object" && comments.tablePrefix !== void 0 ? comments.tablePrefix : void 0;
394
- return [
395
- resolveTableName("comment", resolvedPrefix),
396
- resolveTableName("comment_report", resolvedPrefix),
397
- resolveTableName("comment_reaction", resolvedPrefix)
398
- ];
399
- }
400
- function generateCommentsSchema(comments, prefixOrOptions) {
401
- if (!comments) {
402
- return "// Qarpeo Comments is disabled\nexport default {};\n";
403
- }
404
- const resolvedPrefix = prefixOrOptions !== void 0 ? prefixOrOptions : typeof comments === "object" && comments.tablePrefix !== void 0 ? comments.tablePrefix : void 0;
405
- const commentTbl = resolveTableName("comment", resolvedPrefix);
406
- const reportTbl = resolveTableName("comment_report", resolvedPrefix);
407
- const reactionTbl = resolveTableName("comment_reaction", resolvedPrefix);
408
- const lines = [
409
- `// Auto-generated by qarpeo \u2014 Threaded Comments System`,
410
- `// snakeCase.table maps camelCase property names \u2192 snake_case column names automatically`,
411
- `import { integer, text, index, uniqueIndex, snakeCase } from "drizzle-orm/sqlite-core";`,
412
- ``,
413
- `// \u2500\u2500\u2500 1. Comments \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
414
- `export const comment = snakeCase.table("${commentTbl}", {`,
415
- ` id: text().primaryKey(),`,
416
- ` /** Universal Resource Name of the target entity, e.g. "urn:cms:blog:abc123" */`,
417
- ` targetUrn: text().notNull(),`,
418
- ` tenantId: text(),`,
419
- ` /** Parent comment ID; null for root-level comments */`,
420
- ` parentId: text(),`,
421
- ` /** Materialized path for fast subtree queries, e.g. "/0001/0002/" */`,
422
- ` path: text().notNull().default("/"),`,
423
- ` depth: integer().notNull().default(0),`,
424
- ` /** Authenticated author user ID; null for anonymous guest comments */`,
425
- ` authorId: text(),`,
426
- ` authorName: text().notNull(),`,
427
- ` authorEmail: text(),`,
428
- ` /** Deterministic inline SVG data-URI avatar \u2014 no external CDN calls */`,
429
- ` authorAvatar: text(),`,
430
- ` /** Anonymous author IP; never exposed in public API responses */`,
431
- ` authorIp: text(),`,
432
- ` content: text().notNull(),`,
433
- ` /** pending | approved | spam | deleted */`,
434
- ` status: text().notNull().default("pending"),`,
435
- ` /** Unix ms timestamp; non-null means the comment is tombstoned */`,
436
- ` deletedAt: integer(),`,
437
- ` reportCount: integer().notNull().default(0),`,
438
- ` /** JSON map of reaction type \u2192 count, e.g. {"like":3,"heart":1} */`,
439
- ` reactionCounts: text().notNull().default("{}"),`,
440
- ` metadataJson: text().notNull().default("{}"),`,
441
- ` createdAt: integer().notNull(),`,
442
- ` updatedAt: integer().notNull(),`,
443
- `}, (t) => [`,
444
- ` index("${resolveIndexName(commentTbl, "target")}").on(t.targetUrn, t.status, t.createdAt),`,
445
- ` index("${resolveIndexName(commentTbl, "parent")}").on(t.parentId),`,
446
- ` index("${resolveIndexName(commentTbl, "path")}").on(t.path),`,
447
- ` index("${resolveIndexName(commentTbl, "tenant")}").on(t.tenantId),`,
448
- ` index("${resolveIndexName(commentTbl, "author")}").on(t.authorId),`,
449
- `]);`,
450
- ``,
451
- `// Backward-compatibility alias`,
452
- `export const qarpeoComments = comment;`,
453
- ``,
454
- `// \u2500\u2500\u2500 2. Community Reports \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
455
- `export const commentReport = snakeCase.table("${reportTbl}", {`,
456
- ` id: text().primaryKey(),`,
457
- ` commentId: text().notNull(),`,
458
- ` reporterIp: text(),`,
459
- ` reporterUserId: text(),`,
460
- ` /** spam | harassment | off-topic | misinformation | other */`,
461
- ` reason: text().notNull(),`,
462
- ` note: text(),`,
463
- ` createdAt: integer().notNull(),`,
464
- `}, (t) => [`,
465
- ` index("${resolveIndexName(reportTbl, "comment")}").on(t.commentId),`,
466
- `]);`,
467
- ``,
468
- `// Backward-compatibility alias`,
469
- `export const qarpeoCommentReports = commentReport;`,
470
- ``,
471
- `// \u2500\u2500\u2500 3. Comment Reactions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
472
- `export const commentReaction = snakeCase.table("${reactionTbl}", {`,
473
- ` id: text().primaryKey(),`,
474
- ` commentId: text().notNull(),`,
475
- ` /** Authenticated user ID; null for anonymous reactions (keyed by IP) */`,
476
- ` userId: text(),`,
477
- ` ip: text(),`,
478
- ` /** like | heart | fire | unicorn \u2014 or any string from CommentsOptions.reactions */`,
479
- ` reaction: text().notNull(),`,
480
- ` createdAt: integer().notNull(),`,
481
- `}, (t) => [`,
482
- ` index("${resolveIndexName(reactionTbl, "comment")}").on(t.commentId),`,
483
- ` uniqueIndex("${resolveIndexName(reactionTbl, "unique_user")}").on(t.commentId, t.userId, t.reaction),`,
484
- `]);`,
485
- ``,
486
- `// Backward-compatibility alias`,
487
- `export const qarpeoCommentReactions = commentReaction;`
488
- ];
489
- return lines.join("\n") + "\n";
490
- }
491
-
492
- const ALL_STORE_TABLE_NAMES = [
493
- "store_product",
494
- "store_product_variant",
495
- "store_inventory",
496
- "store_category",
497
- "store_cart",
498
- "store_cart_item",
499
- "store_order",
500
- "store_order_item",
501
- "store_discount",
502
- "store_customer_address"
503
- ];
504
- function getActiveStoreTableNames(store, prefixOrOptions) {
505
- if (!store) return [];
506
- const resolvedPrefix = prefixOrOptions !== void 0 ? prefixOrOptions : typeof store === "object" && store.tablePrefix !== void 0 ? store.tablePrefix : void 0;
507
- return ALL_STORE_TABLE_NAMES.map((name) => resolveTableName(name, resolvedPrefix));
508
- }
509
- function generateStoreSchema(store, prefixOrOptions) {
510
- if (!store) {
511
- return "// Qarpeo Store App is disabled\nexport default {};\n";
512
- }
513
- const resolvedPrefix = prefixOrOptions !== void 0 ? prefixOrOptions : typeof store === "object" && store.tablePrefix !== void 0 ? store.tablePrefix : void 0;
514
- const productTbl = resolveTableName("store_product", resolvedPrefix);
515
- const variantTbl = resolveTableName("store_product_variant", resolvedPrefix);
516
- const inventoryTbl = resolveTableName("store_inventory", resolvedPrefix);
517
- const categoryTbl = resolveTableName("store_category", resolvedPrefix);
518
- const cartTbl = resolveTableName("store_cart", resolvedPrefix);
519
- const cartItemTbl = resolveTableName("store_cart_item", resolvedPrefix);
520
- const orderTbl = resolveTableName("store_order", resolvedPrefix);
521
- const orderItemTbl = resolveTableName("store_order_item", resolvedPrefix);
522
- const discountTbl = resolveTableName("store_discount", resolvedPrefix);
523
- const addressTbl = resolveTableName("store_customer_address", resolvedPrefix);
524
- const lines = [
525
- `// Auto-generated by qarpeo \u2014 Edge-Native Store App Engine`,
526
- `// snakeCase.table maps camelCase property names -> snake_case column names automatically`,
527
- `import { integer, real, text, index, uniqueIndex, snakeCase } from "drizzle-orm/sqlite-core";`,
528
- ``,
529
- `// \u2500\u2500\u2500 1. Products \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
530
- `export const storeProduct = snakeCase.table("${productTbl}", {`,
531
- ` id: text().primaryKey(),`,
532
- ` tenantId: text(),`,
533
- ` vendorId: text(),`,
534
- ` slug: text().notNull(),`,
535
- ` title: text().notNull(),`,
536
- ` description: text(),`,
537
- ` status: text().notNull().default("draft"),`,
538
- ` type: text().notNull().default("physical"),`,
539
- ` basePrice: integer().notNull(),`,
540
- ` currency: text().notNull().default("USD"),`,
541
- ` categoryId: text(),`,
542
- ` imagesJson: text().notNull().default("[]"),`,
543
- ` metadataJson: text().notNull().default("{}"),`,
544
- ` createdAt: integer().notNull(),`,
545
- ` updatedAt: integer().notNull(),`,
546
- `}, (t) => [`,
547
- ` uniqueIndex("${resolveIndexName(productTbl, "unique_slug")}").on(t.tenantId, t.slug),`,
548
- ` index("${resolveIndexName(productTbl, "status")}").on(t.status),`,
549
- ` index("${resolveIndexName(productTbl, "category")}").on(t.categoryId),`,
550
- ` index("${resolveIndexName(productTbl, "tenant")}").on(t.tenantId),`,
551
- ` index("${resolveIndexName(productTbl, "vendor")}").on(t.vendorId),`,
552
- `]);`,
553
- ``,
554
- `// \u2500\u2500\u2500 2. Product Variants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
555
- `export const storeProductVariant = snakeCase.table("${variantTbl}", {`,
556
- ` id: text().primaryKey(),`,
557
- ` productId: text().notNull(),`,
558
- ` sku: text().notNull(),`,
559
- ` title: text().notNull(),`,
560
- ` optionsJson: text().notNull().default("{}"),`,
561
- ` priceOverride: integer(),`,
562
- ` weight: real(),`,
563
- ` barcode: text(),`,
564
- ` image: text(),`,
565
- ` createdAt: integer().notNull(),`,
566
- ` updatedAt: integer().notNull(),`,
567
- `}, (t) => [`,
568
- ` index("${resolveIndexName(variantTbl, "product")}").on(t.productId),`,
569
- ` index("${resolveIndexName(variantTbl, "sku")}").on(t.sku),`,
570
- `]);`,
571
- ``,
572
- `// \u2500\u2500\u2500 3. Inventory \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
573
- `export const storeInventory = snakeCase.table("${inventoryTbl}", {`,
574
- ` id: text().primaryKey(),`,
575
- ` variantId: text().notNull(),`,
576
- ` productId: text().notNull(),`,
577
- ` stockQuantity: integer().notNull().default(0),`,
578
- ` reservedQuantity: integer().notNull().default(0),`,
579
- ` allowBackorder: integer().notNull().default(0),`,
580
- ` lowStockThreshold: integer().notNull().default(5),`,
581
- ` createdAt: integer().notNull(),`,
582
- ` updatedAt: integer().notNull(),`,
583
- `}, (t) => [`,
584
- ` uniqueIndex("${resolveIndexName(inventoryTbl, "variant")}").on(t.variantId),`,
585
- ` index("${resolveIndexName(inventoryTbl, "product")}").on(t.productId),`,
586
- `]);`,
587
- ``,
588
- `// \u2500\u2500\u2500 4. Categories \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
589
- `export const storeCategory = snakeCase.table("${categoryTbl}", {`,
590
- ` id: text().primaryKey(),`,
591
- ` tenantId: text(),`,
592
- ` slug: text().notNull(),`,
593
- ` name: text().notNull(),`,
594
- ` description: text(),`,
595
- ` image: text(),`,
596
- ` parentId: text(),`,
597
- ` order: integer().notNull().default(0),`,
598
- ` metadataJson: text().notNull().default("{}"),`,
599
- ` createdAt: integer().notNull(),`,
600
- ` updatedAt: integer().notNull(),`,
601
- `}, (t) => [`,
602
- ` uniqueIndex("${resolveIndexName(categoryTbl, "unique_slug")}").on(t.tenantId, t.slug),`,
603
- ` index("${resolveIndexName(categoryTbl, "parent")}").on(t.parentId),`,
604
- ` index("${resolveIndexName(categoryTbl, "tenant")}").on(t.tenantId),`,
605
- `]);`,
606
- ``,
607
- `// \u2500\u2500\u2500 5. Carts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
608
- `export const storeCart = snakeCase.table("${cartTbl}", {`,
609
- ` id: text().primaryKey(),`,
610
- ` tenantId: text(),`,
611
- ` userId: text(),`,
612
- ` sessionToken: text().notNull(),`,
613
- ` currency: text().notNull().default("USD"),`,
614
- ` couponCode: text(),`,
615
- ` metadataJson: text().notNull().default("{}"),`,
616
- ` expiresAt: integer().notNull(),`,
617
- ` createdAt: integer().notNull(),`,
618
- ` updatedAt: integer().notNull(),`,
619
- `}, (t) => [`,
620
- ` uniqueIndex("${resolveIndexName(cartTbl, "session")}").on(t.sessionToken),`,
621
- ` index("${resolveIndexName(cartTbl, "user")}").on(t.userId),`,
622
- ` index("${resolveIndexName(cartTbl, "expires")}").on(t.expiresAt),`,
623
- `]);`,
624
- ``,
625
- `// \u2500\u2500\u2500 6. Cart Items \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
626
- `export const storeCartItem = snakeCase.table("${cartItemTbl}", {`,
627
- ` id: text().primaryKey(),`,
628
- ` cartId: text().notNull(),`,
629
- ` productId: text().notNull(),`,
630
- ` variantId: text().notNull(),`,
631
- ` quantity: integer().notNull().default(1),`,
632
- ` customAttributesJson: text().notNull().default("{}"),`,
633
- ` createdAt: integer().notNull(),`,
634
- ` updatedAt: integer().notNull(),`,
635
- `}, (t) => [`,
636
- ` index("${resolveIndexName(cartItemTbl, "cart")}").on(t.cartId),`,
637
- ` index("${resolveIndexName(cartItemTbl, "variant")}").on(t.variantId),`,
638
- `]);`,
639
- ``,
640
- `// \u2500\u2500\u2500 7. Orders \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
641
- `export const storeOrder = snakeCase.table("${orderTbl}", {`,
642
- ` id: text().primaryKey(),`,
643
- ` tenantId: text(),`,
644
- ` orderNumber: text().notNull(),`,
645
- ` userId: text(),`,
646
- ` customerEmail: text().notNull(),`,
647
- ` customerName: text(),`,
648
- ` status: text().notNull().default("pending"),`,
649
- ` currency: text().notNull().default("USD"),`,
650
- ` subtotal: integer().notNull(),`,
651
- ` taxTotal: integer().notNull().default(0),`,
652
- ` shippingTotal: integer().notNull().default(0),`,
653
- ` discountTotal: integer().notNull().default(0),`,
654
- ` total: integer().notNull(),`,
655
- ` paymentProvider: text(),`,
656
- ` paymentIntentId: text(),`,
657
- ` shippingAddressJson: text().notNull().default("{}"),`,
658
- ` billingAddressJson: text().notNull().default("{}"),`,
659
- ` metadataJson: text().notNull().default("{}"),`,
660
- ` paidAt: integer(),`,
661
- ` shippedAt: integer(),`,
662
- ` deliveredAt: integer(),`,
663
- ` cancelledAt: integer(),`,
664
- ` refundedAt: integer(),`,
665
- ` createdAt: integer().notNull(),`,
666
- ` updatedAt: integer().notNull(),`,
667
- `}, (t) => [`,
668
- ` uniqueIndex("${resolveIndexName(orderTbl, "unique_number")}").on(t.tenantId, t.orderNumber),`,
669
- ` index("${resolveIndexName(orderTbl, "user")}").on(t.userId),`,
670
- ` index("${resolveIndexName(orderTbl, "email")}").on(t.customerEmail),`,
671
- ` index("${resolveIndexName(orderTbl, "status")}").on(t.status),`,
672
- ` index("${resolveIndexName(orderTbl, "created")}").on(t.createdAt),`,
673
- `]);`,
674
- ``,
675
- `// \u2500\u2500\u2500 8. Order Items \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
676
- `export const storeOrderItem = snakeCase.table("${orderItemTbl}", {`,
677
- ` id: text().primaryKey(),`,
678
- ` orderId: text().notNull(),`,
679
- ` productId: text().notNull(),`,
680
- ` variantId: text().notNull(),`,
681
- ` vendorId: text(),`,
682
- ` sku: text().notNull(),`,
683
- ` title: text().notNull(),`,
684
- ` unitPrice: integer().notNull(),`,
685
- ` quantity: integer().notNull().default(1),`,
686
- ` totalPrice: integer().notNull(),`,
687
- ` isDigital: integer().notNull().default(0),`,
688
- ` downloadKey: text(),`,
689
- ` metadataJson: text().notNull().default("{}"),`,
690
- ` createdAt: integer().notNull(),`,
691
- `}, (t) => [`,
692
- ` index("${resolveIndexName(orderItemTbl, "order")}").on(t.orderId),`,
693
- ` index("${resolveIndexName(orderItemTbl, "variant")}").on(t.variantId),`,
694
- ` index("${resolveIndexName(orderItemTbl, "vendor")}").on(t.vendorId),`,
695
- `]);`,
696
- ``,
697
- `// \u2500\u2500\u2500 9. Discounts / Coupons \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
698
- `export const storeDiscount = snakeCase.table("${discountTbl}", {`,
699
- ` id: text().primaryKey(),`,
700
- ` tenantId: text(),`,
701
- ` code: text().notNull(),`,
702
- ` type: text().notNull().default("percentage"),`,
703
- ` value: integer().notNull(),`,
704
- ` minOrderAmount: integer().notNull().default(0),`,
705
- ` maxUses: integer(),`,
706
- ` usedCount: integer().notNull().default(0),`,
707
- ` startsAt: integer(),`,
708
- ` expiresAt: integer(),`,
709
- ` isActive: integer().notNull().default(1),`,
710
- ` metadataJson: text().notNull().default("{}"),`,
711
- ` createdAt: integer().notNull(),`,
712
- ` updatedAt: integer().notNull(),`,
713
- `}, (t) => [`,
714
- ` uniqueIndex("${resolveIndexName(discountTbl, "unique_code")}").on(t.tenantId, t.code),`,
715
- ` index("${resolveIndexName(discountTbl, "active")}").on(t.isActive),`,
716
- `]);`,
717
- ``,
718
- `// \u2500\u2500\u2500 10. Customer Addresses \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
719
- `export const storeCustomerAddress = snakeCase.table("${addressTbl}", {`,
720
- ` id: text().primaryKey(),`,
721
- ` userId: text().notNull(),`,
722
- ` type: text().notNull().default("shipping"),`,
723
- ` name: text().notNull(),`,
724
- ` company: text(),`,
725
- ` line1: text().notNull(),`,
726
- ` line2: text(),`,
727
- ` city: text().notNull(),`,
728
- ` state: text(),`,
729
- ` postalCode: text().notNull(),`,
730
- ` country: text().notNull(),`,
731
- ` phone: text(),`,
732
- ` isDefault: integer().notNull().default(0),`,
733
- ` createdAt: integer().notNull(),`,
734
- ` updatedAt: integer().notNull(),`,
735
- `}, (t) => [`,
736
- ` index("${resolveIndexName(addressTbl, "user")}").on(t.userId),`,
737
- ` index("${resolveIndexName(addressTbl, "type")}").on(t.type),`,
738
- `]);`,
739
- ``,
740
- `// Backward-compatibility / plural aliases`,
741
- `export const storeProducts = storeProduct;`,
742
- `export const storeProductVariants = storeProductVariant;`,
743
- `export const storeInventories = storeInventory;`,
744
- `export const storeCategories = storeCategory;`,
745
- `export const storeCarts = storeCart;`,
746
- `export const storeCartItems = storeCartItem;`,
747
- `export const storeOrders = storeOrder;`,
748
- `export const storeOrderItems = storeOrderItem;`,
749
- `export const storeDiscounts = storeDiscount;`,
750
- `export const storeCustomerAddresses = storeCustomerAddress;`
751
- ];
752
- return lines.join("\n");
753
- }
754
-
755
204
  function matchesSourceFilters(relPath, include, exclude) {
756
205
  const p = relPath.replace(/\\/g, "/");
757
206
  if (exclude) {
@@ -1013,6 +462,31 @@ async function resolveAllCmsSources(options) {
1013
462
  return resolvedList;
1014
463
  }
1015
464
 
465
+ function _requireYamlSync() {
466
+ try {
467
+ const m = require("yaml");
468
+ return { parse: m.parse };
469
+ } catch {
470
+ throw new Error(
471
+ `[qarpeo] CMS content scanning requires the \`yaml\` package.
472
+ Install it with: pnpm add yaml`
473
+ );
474
+ }
475
+ }
476
+ async function _requireComark() {
477
+ try {
478
+ const [comarkMod, renderMod] = await Promise.all([
479
+ import('comark'),
480
+ import('comark/render')
481
+ ]);
482
+ return { parseMarkdown: comarkMod.parseMarkdown, render: renderMod.render };
483
+ } catch {
484
+ throw new Error(
485
+ `[qarpeo] CMS content scanning requires the \`comark\` package.
486
+ Install it with: pnpm add comark`
487
+ );
488
+ }
489
+ }
1016
490
  function slugifyHeading(text) {
1017
491
  return text.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
1018
492
  }
@@ -1043,7 +517,8 @@ function parseFrontmatter(raw) {
1043
517
  const fmMatch = clean.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)/);
1044
518
  if (!fmMatch) return { data: {}, content: clean };
1045
519
  try {
1046
- const parsed = parse(fmMatch[1] || "");
520
+ const { parse: parseYaml } = _requireYamlSync();
521
+ const parsed = parseYaml(fmMatch[1] || "");
1047
522
  return {
1048
523
  data: parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {},
1049
524
  content: fmMatch[2] || ""
@@ -1069,7 +544,7 @@ async function readNavJson(dir) {
1069
544
  if (existsSync(navYmlPath)) {
1070
545
  try {
1071
546
  const raw = await readFile(navYmlPath, "utf8");
1072
- return parse(raw) || {};
547
+ return _requireYamlSync().parse(raw) || {};
1073
548
  } catch {
1074
549
  }
1075
550
  }
@@ -1178,6 +653,7 @@ async function scanContentEntries(options) {
1178
653
  let ast = { nodes: [], frontmatter: {}, meta: {} };
1179
654
  let contentHtml = "";
1180
655
  try {
656
+ const { parseMarkdown, render } = await _requireComark();
1181
657
  const plugins = shikiPluginInstance ? [shikiPluginInstance] : [];
1182
658
  ast = await parseMarkdown(body, { plugins });
1183
659
  contentHtml = (await render(ast, { format: "text/html" })).trim();
@@ -1265,7 +741,7 @@ async function scanContentEntries(options) {
1265
741
  }
1266
742
  } else {
1267
743
  try {
1268
- parsed = parse(rawContent) || {};
744
+ parsed = _requireYamlSync().parse(rawContent) || {};
1269
745
  } catch {
1270
746
  }
1271
747
  }
@@ -1496,10 +972,14 @@ async function setupAliases(options, nuxt, resolver) {
1496
972
  nuxt.options.alias["#qarpeo/cms"] = resolver.resolve("./runtime/cms");
1497
973
  nuxt.options.alias["qarpeo/realtime"] = resolver.resolve("./runtime/realtime");
1498
974
  nuxt.options.alias["#qarpeo/realtime"] = resolver.resolve("./runtime/realtime");
975
+ nuxt.options.alias["qarpeo/realtime/server"] = resolver.resolve("./runtime/realtime-server");
976
+ nuxt.options.alias["#qarpeo/realtime/server"] = resolver.resolve("./runtime/realtime-server");
1499
977
  nuxt.options.alias["qarpeo/payments"] = resolver.resolve("./runtime/payments");
1500
978
  nuxt.options.alias["#qarpeo/payments"] = resolver.resolve("./runtime/payments");
1501
979
  nuxt.options.alias["qarpeo/storage"] = resolver.resolve("./runtime/storage");
1502
980
  nuxt.options.alias["#qarpeo/storage"] = resolver.resolve("./runtime/storage");
981
+ nuxt.options.alias["qarpeo/storage/server"] = resolver.resolve("./runtime/storage-server");
982
+ nuxt.options.alias["#qarpeo/storage/server"] = resolver.resolve("./runtime/storage-server");
1503
983
  nuxt.options.alias["qarpeo/notifications"] = resolver.resolve(
1504
984
  "./runtime/server/utils/notifications"
1505
985
  );
@@ -1508,8 +988,10 @@ async function setupAliases(options, nuxt, resolver) {
1508
988
  );
1509
989
  nuxt.options.alias["qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
1510
990
  nuxt.options.alias["#qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
1511
- nuxt.options.alias["qarpeo/comments"] = resolver.resolve("./runtime/server/utils/comments");
1512
- nuxt.options.alias["#qarpeo/comments"] = resolver.resolve("./runtime/server/utils/comments");
991
+ nuxt.options.alias["qarpeo/comments"] = resolver.resolve("./runtime/comments");
992
+ nuxt.options.alias["#qarpeo/comments"] = resolver.resolve("./runtime/comments");
993
+ nuxt.options.alias["qarpeo/comments/server"] = resolver.resolve("./runtime/comments-server");
994
+ nuxt.options.alias["#qarpeo/comments/server"] = resolver.resolve("./runtime/comments-server");
1513
995
  nuxt.options.alias["qarpeo/store"] = resolver.resolve("./runtime/store");
1514
996
  nuxt.options.alias["#qarpeo/store"] = resolver.resolve("./runtime/store");
1515
997
  nuxt.options.alias["qarpeo/store/server"] = resolver.resolve("./runtime/server/utils/store");
@@ -1914,8 +1396,8 @@ async function setupSchema(options, nuxt, resolver, logger) {
1914
1396
  write: true,
1915
1397
  getContents: () => {
1916
1398
  const dbs = getDatabases();
1917
- const primaryDb = dbs.find((d) => d.isPrimary);
1918
- const primaryFiles = primaryDb?.schemaFiles || [];
1399
+ const primaryDb2 = dbs.find((d) => d.isPrimary);
1400
+ const primaryFiles = primaryDb2?.schemaFiles || [];
1919
1401
  const lines = ["// Auto-generated by qarpeo across all Nuxt layers"];
1920
1402
  for (const file of primaryFiles) {
1921
1403
  const importPath = file.replace(/\\/g, "/").replace(/\.ts$/, "");
@@ -1979,9 +1461,10 @@ async function setupSchema(options, nuxt, resolver, logger) {
1979
1461
  primaryImportNames.push("_d1_store");
1980
1462
  }
1981
1463
  const primaryObj = primaryImportNames.length > 0 ? `{ ${primaryImportNames.map((n) => `...${n}`).join(", ")} }` : "{}";
1982
- lines.push(`export const d1Schema = ${primaryObj};`);
1983
- lines.push(`export const schema = d1Schema;`);
1984
- lines.push(`export default d1Schema;`);
1464
+ if (primaryDb2) {
1465
+ lines.push(`export const schema = ${primaryObj};`);
1466
+ lines.push(`export default schema;`);
1467
+ }
1985
1468
  const secondaryDbs = dbs.filter((d) => !d.isPrimary);
1986
1469
  for (const sec of secondaryDbs) {
1987
1470
  const secImports = [];
@@ -2010,26 +1493,32 @@ async function setupSchema(options, nuxt, resolver, logger) {
2010
1493
  write: true,
2011
1494
  getContents: () => {
2012
1495
  const dbs = getDatabases();
1496
+ const primaryDb2 = dbs.find((d) => d.isPrimary);
2013
1497
  const secondaryDbs = dbs.filter((d) => !d.isPrimary);
2014
1498
  const lines = [
2015
- "// Auto-generated by qarpeo \u2014 multi-database clients",
2016
- 'import { db, d1Db, createDbProxy } from "#qarpeo/runtime/server/utils/drizzle";',
2017
- "export { db, d1Db };"
1499
+ "// Auto-generated by qarpeo \u2014 multi-database clients"
2018
1500
  ];
2019
- for (const sec of secondaryDbs) {
2020
- lines.push(`export const ${sec.identifiers.db} = createDbProxy("${sec.name}");`);
1501
+ if (primaryDb2) {
1502
+ lines.push('import { db } from "#qarpeo/runtime/server/utils/drizzle";');
1503
+ lines.push("export { db };");
1504
+ }
1505
+ if (secondaryDbs.length > 0) {
1506
+ lines.push('import { createDbProxy } from "#qarpeo/runtime/server/utils/drizzle";');
1507
+ for (const sec of secondaryDbs) {
1508
+ lines.push(`export const ${sec.identifiers.db} = createDbProxy("${sec.binding}");`);
1509
+ }
2021
1510
  }
2022
1511
  return lines.join("\n") + "\n";
2023
1512
  }
2024
1513
  });
2025
1514
  nuxt.options.alias["#qarpeo/db/client"] = clientTemplate.dst;
2026
1515
  const initialDbs = getDatabases();
2027
- const serverSchemaImports = [
2028
- { name: "d1Schema", from: "#qarpeo/schema" },
2029
- { name: "schema", from: "#qarpeo/schema" },
2030
- { name: "d1Db", from: "#qarpeo/db/client" },
2031
- { name: "db", from: "#qarpeo/db/client" }
2032
- ];
1516
+ const primaryDb = initialDbs.find((d) => d.isPrimary);
1517
+ const serverSchemaImports = [];
1518
+ if (primaryDb && !(options.db || options.d1)) {
1519
+ serverSchemaImports.push({ name: "schema", from: "#qarpeo/schema" });
1520
+ serverSchemaImports.push({ name: "db", from: "#qarpeo/db/client" });
1521
+ }
2033
1522
  for (const sec of initialDbs.filter((d) => !d.isPrimary)) {
2034
1523
  serverSchemaImports.push({ name: sec.identifiers.schema, from: "#qarpeo/schema" });
2035
1524
  serverSchemaImports.push({ name: sec.identifiers.db, from: "#qarpeo/db/client" });
@@ -2040,8 +1529,8 @@ async function setupSchema(options, nuxt, resolver, logger) {
2040
1529
  write: true,
2041
1530
  getContents: () => {
2042
1531
  const dbs = getDatabases();
2043
- const primaryDb = dbs.find((d) => d.isPrimary);
2044
- const primaryFiles = primaryDb?.schemaFiles || [];
1532
+ const primaryDb2 = dbs.find((d) => d.isPrimary);
1533
+ const primaryFiles = primaryDb2?.schemaFiles || [];
2045
1534
  const { types, tables } = scanSchemaExports(primaryFiles);
2046
1535
  const lines = [
2047
1536
  "// Auto-generated by qarpeo \u2014 database schema types",
@@ -2057,30 +1546,16 @@ async function setupSchema(options, nuxt, resolver, logger) {
2057
1546
  for (const [importPath, names] of byFile) {
2058
1547
  lines.push(`export type { ${names.join(", ")} } from "${importPath}";`);
2059
1548
  }
2060
- lines.push("export namespace D1Types {");
2061
- const explicitTypes = new Set(types.map((t) => t.name));
2062
- for (const table of tables) {
2063
- const { modelName, name } = table;
2064
- lines.push(` export type ${modelName} = typeof _DBSchema.${name}.$inferSelect;`);
2065
- lines.push(` export type New${modelName} = typeof _DBSchema.${name}.$inferInsert;`);
2066
- lines.push(` export type Insert${modelName} = New${modelName};`);
2067
- lines.push(` export type Update${modelName} = Partial<New${modelName}>;`);
2068
- }
2069
- lines.push("}");
2070
- for (const table of tables) {
2071
- const { modelName } = table;
2072
- if (!explicitTypes.has(modelName)) {
2073
- lines.push(`export type ${modelName} = D1Types.${modelName};`);
2074
- }
2075
- if (!explicitTypes.has(`New${modelName}`)) {
2076
- lines.push(`export type New${modelName} = D1Types.New${modelName};`);
2077
- }
2078
- if (!explicitTypes.has(`Insert${modelName}`)) {
2079
- lines.push(`export type Insert${modelName} = D1Types.Insert${modelName};`);
2080
- }
2081
- if (!explicitTypes.has(`Update${modelName}`)) {
2082
- lines.push(`export type Update${modelName} = D1Types.Update${modelName};`);
1549
+ if (primaryDb2) {
1550
+ lines.push("export namespace DbTypes {");
1551
+ for (const table of tables) {
1552
+ const { modelName, name } = table;
1553
+ lines.push(` export type ${modelName} = typeof _DBSchema.${name}.$inferSelect;`);
1554
+ lines.push(` export type New${modelName} = typeof _DBSchema.${name}.$inferInsert;`);
1555
+ lines.push(` export type Insert${modelName} = New${modelName};`);
1556
+ lines.push(` export type Update${modelName} = Partial<New${modelName}>;`);
2083
1557
  }
1558
+ lines.push("}");
2084
1559
  }
2085
1560
  for (const sec of dbs.filter((d) => !d.isPrimary)) {
2086
1561
  const secScanned = scanSchemaExports(sec.schemaFiles);
@@ -2108,8 +1583,8 @@ async function setupSchema(options, nuxt, resolver, logger) {
2108
1583
  write: true,
2109
1584
  getContents: () => {
2110
1585
  const dbs = getDatabases();
2111
- const primaryDb = dbs.find((d) => d.isPrimary);
2112
- const primaryFiles = primaryDb?.schemaFiles || [];
1586
+ const primaryDb2 = dbs.find((d) => d.isPrimary);
1587
+ const primaryFiles = primaryDb2?.schemaFiles || [];
2113
1588
  const { zod, tables } = scanSchemaExports(primaryFiles);
2114
1589
  const lines = [
2115
1590
  "// Auto-generated by qarpeo \u2014 Zod schema validation & re-exports",
@@ -2148,21 +1623,23 @@ async function setupSchema(options, nuxt, resolver, logger) {
2148
1623
  lines
2149
1624
  );
2150
1625
  }
2151
- lines.push("export const d1Zod = {");
2152
- for (const table of tables) {
2153
- const { modelName, camelName } = table;
2154
- lines.push(` ${table.name}: {`);
2155
- lines.push(` insert: insert${modelName}Schema,`);
2156
- lines.push(` update: update${modelName}Schema,`);
2157
- lines.push(` select: select${modelName}Schema,`);
2158
- lines.push(` },`);
2159
- lines.push(` insert${modelName}: insert${modelName}Schema,`);
2160
- lines.push(` update${modelName}: update${modelName}Schema,`);
2161
- lines.push(` select${modelName}: select${modelName}Schema,`);
2162
- lines.push(` ${camelName}Insert: insert${modelName}Schema,`);
2163
- lines.push(` ${camelName}Select: select${modelName}Schema,`);
1626
+ if (primaryDb2) {
1627
+ lines.push("export const dbZod = {");
1628
+ for (const table of tables) {
1629
+ const { modelName, camelName } = table;
1630
+ lines.push(` ${table.name}: {`);
1631
+ lines.push(` insert: insert${modelName}Schema,`);
1632
+ lines.push(` update: update${modelName}Schema,`);
1633
+ lines.push(` select: select${modelName}Schema,`);
1634
+ lines.push(` },`);
1635
+ lines.push(` insert${modelName}: insert${modelName}Schema,`);
1636
+ lines.push(` update${modelName}: update${modelName}Schema,`);
1637
+ lines.push(` select${modelName}: select${modelName}Schema,`);
1638
+ lines.push(` ${camelName}Insert: insert${modelName}Schema,`);
1639
+ lines.push(` ${camelName}Select: select${modelName}Schema,`);
1640
+ }
1641
+ lines.push("};");
2164
1642
  }
2165
- lines.push("};");
2166
1643
  for (const sec of dbs.filter((d) => !d.isPrimary)) {
2167
1644
  const secScanned = scanSchemaExports(sec.schemaFiles);
2168
1645
  const secTableObjLines = [];
@@ -2197,9 +1674,10 @@ async function setupSchema(options, nuxt, resolver, logger) {
2197
1674
  }
2198
1675
  });
2199
1676
  nuxt.options.alias["#qarpeo/db/zod"] = zodTemplate.dst;
2200
- const allZodImports = [
2201
- { name: "d1Zod", from: "#qarpeo/db/zod" }
2202
- ];
1677
+ const allZodImports = [];
1678
+ if (primaryDb) {
1679
+ allZodImports.push({ name: "dbZod", from: "#qarpeo/db/zod" });
1680
+ }
2203
1681
  for (const sec of initialDbs.filter((d) => !d.isPrimary)) {
2204
1682
  allZodImports.push({ name: sec.identifiers.zod, from: "#qarpeo/db/zod" });
2205
1683
  }
@@ -2229,21 +1707,23 @@ async function setupSchema(options, nuxt, resolver, logger) {
2229
1707
  write: true,
2230
1708
  getContents: () => {
2231
1709
  const dbs = getDatabases();
2232
- const primaryDb = dbs.find((d) => d.isPrimary);
2233
- const { types, tables } = scanSchemaExports(primaryDb?.schemaFiles || []);
1710
+ const primaryDb2 = dbs.find((d) => d.isPrimary);
1711
+ const { tables } = scanSchemaExports(primaryDb2?.schemaFiles || []);
2234
1712
  const lines = [
2235
1713
  "// Auto-generated by qarpeo \u2014 ambient global database schema types",
2236
1714
  'import type * as _DBTypes from "#qarpeo/db/types"',
2237
1715
  "declare global {"
2238
1716
  ];
2239
- lines.push(" namespace D1Types {");
2240
- for (const table of tables) {
2241
- lines.push(` type ${table.modelName} = _DBTypes.D1Types.${table.modelName}`);
2242
- lines.push(` type New${table.modelName} = _DBTypes.D1Types.New${table.modelName}`);
2243
- lines.push(` type Insert${table.modelName} = _DBTypes.D1Types.Insert${table.modelName}`);
2244
- lines.push(` type Update${table.modelName} = _DBTypes.D1Types.Update${table.modelName}`);
1717
+ if (primaryDb2) {
1718
+ lines.push(" namespace DbTypes {");
1719
+ for (const table of tables) {
1720
+ lines.push(` type ${table.modelName} = _DBTypes.DbTypes.${table.modelName}`);
1721
+ lines.push(` type New${table.modelName} = _DBTypes.DbTypes.New${table.modelName}`);
1722
+ lines.push(` type Insert${table.modelName} = _DBTypes.DbTypes.Insert${table.modelName}`);
1723
+ lines.push(` type Update${table.modelName} = _DBTypes.DbTypes.Update${table.modelName}`);
1724
+ }
1725
+ lines.push(" }");
2245
1726
  }
2246
- lines.push(" }");
2247
1727
  for (const sec of dbs.filter((d) => !d.isPrimary)) {
2248
1728
  const secScanned = scanSchemaExports(sec.schemaFiles);
2249
1729
  lines.push(` namespace ${sec.identifiers.types} {`);
@@ -2263,16 +1743,6 @@ async function setupSchema(options, nuxt, resolver, logger) {
2263
1743
  }
2264
1744
  lines.push(" }");
2265
1745
  }
2266
- const allTypeNames = new Set(types.map((t) => t.name));
2267
- for (const table of tables) {
2268
- allTypeNames.add(table.modelName);
2269
- allTypeNames.add(`New${table.modelName}`);
2270
- allTypeNames.add(`Insert${table.modelName}`);
2271
- allTypeNames.add(`Update${table.modelName}`);
2272
- }
2273
- for (const name of allTypeNames) {
2274
- lines.push(` type ${name} = _DBTypes.${name}`);
2275
- }
2276
1746
  lines.push("}");
2277
1747
  lines.push("export {}");
2278
1748
  return lines.join("\n") + "\n";
@@ -2322,20 +1792,6 @@ async function setupNitro(options, nuxt, resolver, logger) {
2322
1792
  addNitroPlugin(resolver.resolve("./runtime/server/plugins/env"));
2323
1793
  nuxt.hook("nitro:config", async (nitroConfig) => {
2324
1794
  try {
2325
- let resolveNitroShikiDep = function(name) {
2326
- try {
2327
- const req = createRequire(resolve(shikiDir, "package.json"));
2328
- const entry = req.resolve(name);
2329
- let cur = dirname(entry);
2330
- while (cur && cur !== dirname(cur)) {
2331
- if (existsSync(resolve(cur, "package.json"))) return cur;
2332
- cur = dirname(cur);
2333
- }
2334
- return "";
2335
- } catch {
2336
- return "";
2337
- }
2338
- };
2339
1795
  nitroConfig.alias = nitroConfig.alias || {};
2340
1796
  const drizzleDir = resolvePkgDir("drizzle-orm");
2341
1797
  nitroConfig.alias["drizzle-orm"] = drizzleDir;
@@ -2358,41 +1814,37 @@ async function setupNitro(options, nuxt, resolver, logger) {
2358
1814
  betterAuthAdapterDir,
2359
1815
  "dist/index.mjs"
2360
1816
  );
2361
- const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
2362
- nitroConfig.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
2363
- nitroConfig.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
2364
- nitroConfig.alias["@comark/nuxt/parse"] = resolve(comarkNuxtDir, "dist/parse.js");
2365
- nitroConfig.alias["@comark/nuxt"] = resolve(comarkNuxtDir, "dist/module.js");
2366
- const comarkVueDir = resolvePkgDir("@comark/vue");
2367
- nitroConfig.alias["@comark/vue/vite"] = resolve(comarkVueDir, "dist/vite.js");
2368
- nitroConfig.alias["@comark/vue/utils"] = resolve(comarkVueDir, "dist/utils/index.js");
2369
- nitroConfig.alias["@comark/vue/render"] = resolve(comarkVueDir, "dist/render.js");
2370
- nitroConfig.alias["@comark/vue/parse"] = resolve(comarkVueDir, "dist/parse.js");
2371
- nitroConfig.alias["@comark/vue"] = resolve(comarkVueDir, "dist/index.js");
2372
- const comarkDir = resolvePkgDir("comark");
2373
- nitroConfig.alias["comark/utils"] = resolve(comarkDir, "dist/utils/index.js");
2374
- nitroConfig.alias["comark/render"] = resolve(comarkDir, "dist/render.js");
2375
- nitroConfig.alias["comark/parse"] = resolve(comarkDir, "dist/parse.js");
2376
- nitroConfig.alias["comark/plugins/shiki"] = resolve(comarkDir, "dist/plugins/shiki.js");
2377
- nitroConfig.alias["comark/plugins/shiki.js"] = resolve(comarkDir, "dist/plugins/shiki.js");
2378
- nitroConfig.alias["comark/internal"] = resolve(comarkDir, "dist/internal");
2379
- nitroConfig.alias["comark/internal/"] = `${resolve(comarkDir, "dist/internal")}/`;
2380
- nitroConfig.alias["comark"] = resolve(comarkDir, "dist/index.js");
2381
- const shikiDir = resolvePkgDir("shiki");
2382
- nitroConfig.alias["shiki/engine/javascript"] = resolve(
2383
- shikiDir,
2384
- "dist/engine-javascript.mjs"
2385
- );
2386
- nitroConfig.alias["shiki/engine/oniguruma"] = resolve(shikiDir, "dist/engine-oniguruma.mjs");
2387
- nitroConfig.alias["shiki/core"] = resolve(shikiDir, "dist/core.mjs");
2388
- nitroConfig.alias["shiki/bundle/full"] = resolve(shikiDir, "dist/bundle-full.mjs");
2389
- nitroConfig.alias["shiki/bundle/web"] = resolve(shikiDir, "dist/bundle-web.mjs");
2390
- nitroConfig.alias["shiki/langs"] = resolve(shikiDir, "dist/langs.mjs");
2391
- nitroConfig.alias["shiki/themes"] = resolve(shikiDir, "dist/themes.mjs");
2392
- nitroConfig.alias["shiki/wasm"] = resolve(shikiDir, "dist/wasm.mjs");
2393
- nitroConfig.alias["shiki/dist"] = resolve(shikiDir, "dist");
2394
- nitroConfig.alias["shiki/dist/"] = `${resolve(shikiDir, "dist")}/`;
2395
- nitroConfig.alias["shiki"] = resolve(shikiDir, "dist/index.mjs");
1817
+ if (options.cms) {
1818
+ try {
1819
+ const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
1820
+ nitroConfig.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
1821
+ nitroConfig.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
1822
+ nitroConfig.alias["@comark/nuxt/parse"] = resolve(comarkNuxtDir, "dist/parse.js");
1823
+ nitroConfig.alias["@comark/nuxt"] = resolve(comarkNuxtDir, "dist/module.js");
1824
+ } catch {
1825
+ }
1826
+ try {
1827
+ const comarkVueDir = resolvePkgDir("@comark/vue");
1828
+ nitroConfig.alias["@comark/vue/vite"] = resolve(comarkVueDir, "dist/vite.js");
1829
+ nitroConfig.alias["@comark/vue/utils"] = resolve(comarkVueDir, "dist/utils/index.js");
1830
+ nitroConfig.alias["@comark/vue/render"] = resolve(comarkVueDir, "dist/render.js");
1831
+ nitroConfig.alias["@comark/vue/parse"] = resolve(comarkVueDir, "dist/parse.js");
1832
+ nitroConfig.alias["@comark/vue"] = resolve(comarkVueDir, "dist/index.js");
1833
+ } catch {
1834
+ }
1835
+ try {
1836
+ const comarkDir = resolvePkgDir("comark");
1837
+ nitroConfig.alias["comark/utils"] = resolve(comarkDir, "dist/utils/index.js");
1838
+ nitroConfig.alias["comark/render"] = resolve(comarkDir, "dist/render.js");
1839
+ nitroConfig.alias["comark/parse"] = resolve(comarkDir, "dist/parse.js");
1840
+ nitroConfig.alias["comark/plugins/shiki"] = resolve(comarkDir, "dist/plugins/shiki.js");
1841
+ nitroConfig.alias["comark/plugins/shiki.js"] = resolve(comarkDir, "dist/plugins/shiki.js");
1842
+ nitroConfig.alias["comark/internal"] = resolve(comarkDir, "dist/internal");
1843
+ nitroConfig.alias["comark/internal/"] = `${resolve(comarkDir, "dist/internal")}/`;
1844
+ nitroConfig.alias["comark"] = resolve(comarkDir, "dist/index.js");
1845
+ } catch {
1846
+ }
1847
+ }
2396
1848
  if (options.fate) {
2397
1849
  try {
2398
1850
  const fateDir = resolvePkgDir("@nkzw/fate");
@@ -2408,53 +1860,92 @@ async function setupNitro(options, nuxt, resolver, logger) {
2408
1860
  } catch {
2409
1861
  }
2410
1862
  }
2411
- const langsDir = resolveNitroShikiDep("@shikijs/langs");
2412
- const themesDir = resolveNitroShikiDep("@shikijs/themes");
2413
- const coreDir = resolveNitroShikiDep("@shikijs/core");
2414
- const primitiveDir = resolveNitroShikiDep("@shikijs/primitive");
2415
- const engineJsDir = resolveNitroShikiDep("@shikijs/engine-javascript");
2416
- const typesDir = resolveNitroShikiDep("@shikijs/types");
2417
- const textmateDir = resolveNitroShikiDep("@shikijs/vscode-textmate");
2418
- if (coreDir) {
2419
- nitroConfig.alias["@shikijs/core"] = resolve(coreDir, "dist/index.mjs");
2420
- nitroConfig.alias["@shikijs/core/"] = `${resolve(coreDir, "dist")}/`;
2421
- }
2422
- if (primitiveDir) {
2423
- nitroConfig.alias["@shikijs/primitive"] = resolve(primitiveDir, "dist/index.mjs");
2424
- nitroConfig.alias["@shikijs/primitive/"] = `${resolve(primitiveDir, "dist")}/`;
2425
- }
2426
- if (engineJsDir) {
2427
- nitroConfig.alias["@shikijs/engine-javascript"] = resolve(engineJsDir, "dist/index.mjs");
2428
- }
2429
- if (typesDir) {
2430
- nitroConfig.alias["@shikijs/types"] = resolve(typesDir, "dist/index.mjs");
2431
- nitroConfig.alias["@shikijs/types/"] = `${resolve(typesDir, "dist")}/`;
2432
- }
2433
- if (textmateDir) {
2434
- nitroConfig.alias["@shikijs/vscode-textmate"] = resolve(textmateDir, "dist/index.js");
2435
- }
2436
- if (langsDir) {
2437
- nitroConfig.alias["@shikijs/langs"] = resolve(langsDir, "dist/index.mjs");
2438
- nitroConfig.alias["@shikijs/langs/"] = `${resolve(langsDir, "dist")}/`;
2439
- try {
2440
- const files = readdirSync(resolve(langsDir, "dist")).filter((f) => f.endsWith(".mjs"));
2441
- for (const f of files) {
2442
- const name = f.replace(/\.mjs$/, "");
2443
- nitroConfig.alias[`@shikijs/langs/${name}`] = resolve(langsDir, "dist", f);
1863
+ if (options.cms) {
1864
+ let resolveNitroShikiDep = function(name) {
1865
+ if (!shikiDir) return "";
1866
+ try {
1867
+ const req = createRequire(resolve(shikiDir, "package.json"));
1868
+ const entry = req.resolve(name);
1869
+ let cur = dirname(entry);
1870
+ while (cur && cur !== dirname(cur)) {
1871
+ if (existsSync(resolve(cur, "package.json"))) return cur;
1872
+ cur = dirname(cur);
1873
+ }
1874
+ return "";
1875
+ } catch {
1876
+ return "";
2444
1877
  }
1878
+ };
1879
+ let shikiDir = "";
1880
+ try {
1881
+ shikiDir = resolvePkgDir("shiki");
1882
+ nitroConfig.alias["shiki/engine/javascript"] = resolve(
1883
+ shikiDir,
1884
+ "dist/engine-javascript.mjs"
1885
+ );
1886
+ nitroConfig.alias["shiki/engine/oniguruma"] = resolve(
1887
+ shikiDir,
1888
+ "dist/engine-oniguruma.mjs"
1889
+ );
1890
+ nitroConfig.alias["shiki/core"] = resolve(shikiDir, "dist/core.mjs");
1891
+ nitroConfig.alias["shiki/bundle/full"] = resolve(shikiDir, "dist/bundle-full.mjs");
1892
+ nitroConfig.alias["shiki/bundle/web"] = resolve(shikiDir, "dist/bundle-web.mjs");
1893
+ nitroConfig.alias["shiki/langs"] = resolve(shikiDir, "dist/langs.mjs");
1894
+ nitroConfig.alias["shiki/themes"] = resolve(shikiDir, "dist/themes.mjs");
1895
+ nitroConfig.alias["shiki/wasm"] = resolve(shikiDir, "dist/wasm.mjs");
1896
+ nitroConfig.alias["shiki/dist"] = resolve(shikiDir, "dist");
1897
+ nitroConfig.alias["shiki/dist/"] = `${resolve(shikiDir, "dist")}/`;
1898
+ nitroConfig.alias["shiki"] = resolve(shikiDir, "dist/index.mjs");
2445
1899
  } catch {
2446
1900
  }
2447
- }
2448
- if (themesDir) {
2449
- nitroConfig.alias["@shikijs/themes"] = resolve(themesDir, "dist/index.mjs");
2450
- nitroConfig.alias["@shikijs/themes/"] = `${resolve(themesDir, "dist")}/`;
2451
- try {
2452
- const files = readdirSync(resolve(themesDir, "dist")).filter((f) => f.endsWith(".mjs"));
2453
- for (const f of files) {
2454
- const name = f.replace(/\.mjs$/, "");
2455
- nitroConfig.alias[`@shikijs/themes/${name}`] = resolve(themesDir, "dist", f);
1901
+ const langsDir = resolveNitroShikiDep("@shikijs/langs");
1902
+ const themesDir = resolveNitroShikiDep("@shikijs/themes");
1903
+ const coreDir = resolveNitroShikiDep("@shikijs/core");
1904
+ const primitiveDir = resolveNitroShikiDep("@shikijs/primitive");
1905
+ const engineJsDir = resolveNitroShikiDep("@shikijs/engine-javascript");
1906
+ const typesDir = resolveNitroShikiDep("@shikijs/types");
1907
+ const textmateDir = resolveNitroShikiDep("@shikijs/vscode-textmate");
1908
+ if (coreDir) {
1909
+ nitroConfig.alias["@shikijs/core"] = resolve(coreDir, "dist/index.mjs");
1910
+ nitroConfig.alias["@shikijs/core/"] = `${resolve(coreDir, "dist")}/`;
1911
+ }
1912
+ if (primitiveDir) {
1913
+ nitroConfig.alias["@shikijs/primitive"] = resolve(primitiveDir, "dist/index.mjs");
1914
+ nitroConfig.alias["@shikijs/primitive/"] = `${resolve(primitiveDir, "dist")}/`;
1915
+ }
1916
+ if (engineJsDir) {
1917
+ nitroConfig.alias["@shikijs/engine-javascript"] = resolve(engineJsDir, "dist/index.mjs");
1918
+ }
1919
+ if (typesDir) {
1920
+ nitroConfig.alias["@shikijs/types"] = resolve(typesDir, "dist/index.mjs");
1921
+ nitroConfig.alias["@shikijs/types/"] = `${resolve(typesDir, "dist")}/`;
1922
+ }
1923
+ if (textmateDir) {
1924
+ nitroConfig.alias["@shikijs/vscode-textmate"] = resolve(textmateDir, "dist/index.js");
1925
+ }
1926
+ if (langsDir) {
1927
+ nitroConfig.alias["@shikijs/langs"] = resolve(langsDir, "dist/index.mjs");
1928
+ nitroConfig.alias["@shikijs/langs/"] = `${resolve(langsDir, "dist")}/`;
1929
+ try {
1930
+ const files = readdirSync(resolve(langsDir, "dist")).filter((f) => f.endsWith(".mjs"));
1931
+ for (const f of files) {
1932
+ const name = f.replace(/\.mjs$/, "");
1933
+ nitroConfig.alias[`@shikijs/langs/${name}`] = resolve(langsDir, "dist", f);
1934
+ }
1935
+ } catch {
1936
+ }
1937
+ }
1938
+ if (themesDir) {
1939
+ nitroConfig.alias["@shikijs/themes"] = resolve(themesDir, "dist/index.mjs");
1940
+ nitroConfig.alias["@shikijs/themes/"] = `${resolve(themesDir, "dist")}/`;
1941
+ try {
1942
+ const files = readdirSync(resolve(themesDir, "dist")).filter((f) => f.endsWith(".mjs"));
1943
+ for (const f of files) {
1944
+ const name = f.replace(/\.mjs$/, "");
1945
+ nitroConfig.alias[`@shikijs/themes/${name}`] = resolve(themesDir, "dist", f);
1946
+ }
1947
+ } catch {
2456
1948
  }
2457
- } catch {
2458
1949
  }
2459
1950
  }
2460
1951
  } catch {
@@ -2532,8 +2023,12 @@ async function setupNitro(options, nuxt, resolver, logger) {
2532
2023
  }
2533
2024
  }
2534
2025
  nitroConfig.framework = nitroConfig.framework || {};
2535
- nitroConfig.framework.previewCommand = "vpx nuxt preview";
2536
- nitroConfig.framework.deployCommand = "vpx qp deploy";
2026
+ nitroConfig.framework.previewCommand = await formatDlxCommand("nuxt", ["preview"], {
2027
+ cwd: nuxt.options.rootDir
2028
+ });
2029
+ nitroConfig.framework.deployCommand = await formatDlxCommand("qp", ["deploy"], {
2030
+ cwd: nuxt.options.rootDir
2031
+ });
2537
2032
  nitroConfig.externals = nitroConfig.externals || {};
2538
2033
  nitroConfig.externals.external = nitroConfig.externals.external || [];
2539
2034
  if (!nitroConfig.externals.external.includes("wrangler")) {
@@ -2554,6 +2049,41 @@ async function setupNitro(options, nuxt, resolver, logger) {
2554
2049
  nitroConfig.alias = nitroConfig.alias || {};
2555
2050
  nitroConfig.alias["qarpeo/server"] = nuxt.options.alias["qarpeo/server"] || resolver.resolve("./runtime/server");
2556
2051
  nitroConfig.alias["qarpeo/runtime"] = nuxt.options.alias["qarpeo/runtime"] || resolver.resolve("./runtime");
2052
+ const runtimeAliases = [
2053
+ "#qarpeo/server",
2054
+ "#qarpeo",
2055
+ "qarpeo/auth",
2056
+ "#qarpeo/auth",
2057
+ "qarpeo/cms",
2058
+ "#qarpeo/cms",
2059
+ "qarpeo/realtime",
2060
+ "#qarpeo/realtime",
2061
+ "qarpeo/realtime/server",
2062
+ "#qarpeo/realtime/server",
2063
+ "qarpeo/payments",
2064
+ "#qarpeo/payments",
2065
+ "qarpeo/storage",
2066
+ "#qarpeo/storage",
2067
+ "qarpeo/storage/server",
2068
+ "#qarpeo/storage/server",
2069
+ "qarpeo/notifications",
2070
+ "#qarpeo/notifications",
2071
+ "qarpeo/vapid",
2072
+ "#qarpeo/vapid",
2073
+ "qarpeo/comments",
2074
+ "#qarpeo/comments",
2075
+ "qarpeo/comments/server",
2076
+ "#qarpeo/comments/server",
2077
+ "qarpeo/store",
2078
+ "#qarpeo/store",
2079
+ "qarpeo/store/server",
2080
+ "#qarpeo/store/server"
2081
+ ];
2082
+ for (const k of runtimeAliases) {
2083
+ if (nuxt.options.alias[k]) {
2084
+ nitroConfig.alias[k] = nuxt.options.alias[k];
2085
+ }
2086
+ }
2557
2087
  const schemaAliases = [
2558
2088
  "#qarpeo/auth/schema",
2559
2089
  "#qarpeo/cms/schema",
@@ -2569,7 +2099,6 @@ async function setupNitro(options, nuxt, resolver, logger) {
2569
2099
  "#db",
2570
2100
  "#db/",
2571
2101
  "#qarpeo/db/types",
2572
- "qarpeo/db/types",
2573
2102
  "#qarpeo/db/zod",
2574
2103
  "@nuxthub/blob",
2575
2104
  "@nuxthub/core/blob"
@@ -2632,11 +2161,10 @@ async function setupNitro(options, nuxt, resolver, logger) {
2632
2161
  }
2633
2162
  }
2634
2163
  const wranglerConfig = await createWranglerConfig(nuxt, options);
2635
- nitroConfig.cloudflare = defu(nitroConfig.cloudflare || {}, {
2636
- deployConfig: true,
2637
- nodeCompat: true,
2638
- wrangler: wranglerConfig
2639
- });
2164
+ nitroConfig.cloudflare = nitroConfig.cloudflare || {};
2165
+ nitroConfig.cloudflare.deployConfig = true;
2166
+ nitroConfig.cloudflare.nodeCompat = true;
2167
+ nitroConfig.cloudflare.wrangler = wranglerConfig;
2640
2168
  const configPath = await generateDevWranglerConfig(nuxt, options);
2641
2169
  nitroConfig.cloudflare.dev = nitroConfig.cloudflare.dev || {};
2642
2170
  nitroConfig.cloudflare.dev.configPath = configPath;
@@ -3158,17 +2686,17 @@ async function setupDevTools(options, nuxt, resolver, logger) {
3158
2686
  groupId: "nuxt"
3159
2687
  }
3160
2688
  ];
3161
- nuxt.hook("devtools:customTabs", (customTabs) => {
2689
+ const { NUXT_DEVTOOLS_GROUP_ID, onDevtoolsReady } = await import('@nuxt/devtools-kit');
2690
+ onDevtoolsReady((ctx) => {
3162
2691
  for (const tab of devtoolsTabs) {
3163
- if (!customTabs.some((t) => t.name === tab.name || t.title === tab.title)) {
3164
- customTabs.push({
3165
- name: tab.name,
3166
- title: tab.title,
3167
- icon: tab.icon,
3168
- view: tab.view,
3169
- category: tab.category
3170
- });
3171
- }
2692
+ ctx.docks.register({
2693
+ id: tab.id,
2694
+ type: "iframe",
2695
+ title: tab.title,
2696
+ icon: tab.icon,
2697
+ url: tab.url,
2698
+ groupId: NUXT_DEVTOOLS_GROUP_ID
2699
+ });
3172
2700
  }
3173
2701
  });
3174
2702
  }
@@ -4341,17 +3869,28 @@ ${registrations}
4341
3869
  }
4342
3870
 
4343
3871
  async function setupFate(options, nuxt, resolver, logger) {
3872
+ const fateViewsDir = (typeof options.fate === "object" ? options.fate.viewsDir : void 0) ?? "server/fate";
3873
+ const hasFateViews = existsSync(resolve(nuxt.options.rootDir, fateViewsDir, "views.ts")) || existsSync(resolve(nuxt.options.rootDir, fateViewsDir, "views.js"));
3874
+ if (!options.fate) {
3875
+ if (hasFateViews) {
3876
+ logger.info(
3877
+ `[qarpeo] Detected ${fateViewsDir}/views.ts \u2014 set \`fate: true\` in nuxt.config.ts to enable Fate.`
3878
+ );
3879
+ }
3880
+ return;
3881
+ }
4344
3882
  if (options.fate) {
4345
3883
  const fateOptions = typeof options.fate === "object" ? options.fate : {};
4346
3884
  const fateEndpoint = fateOptions.endpoint ?? "/fate";
4347
- const fateViewsDir = fateOptions.viewsDir ?? "server/fate";
3885
+ const requireAuth = fateOptions.auth !== false;
3886
+ nuxt.options.runtimeConfig.qarpeoFateAuth = requireAuth;
4348
3887
  await ensurePackage("@nkzw/fate", {
4349
3888
  cwd: nuxt.options.rootDir,
4350
- purpose: "Fate Relay-style data fetching (fate: true)"
3889
+ purpose: "Fate Relay-style data fetching"
4351
3890
  });
4352
3891
  await ensurePackage("vue-fate", {
4353
3892
  cwd: nuxt.options.rootDir,
4354
- purpose: "Fate Relay-style data fetching (fate: true)"
3893
+ purpose: "Fate Relay-style data fetching"
4355
3894
  });
4356
3895
  try {
4357
3896
  const fateDir = resolvePkgDir("@nkzw/fate");
@@ -6571,6 +6110,10 @@ async function setupStore(options, nuxt, resolver, logger) {
6571
6110
  name: "getOrCreateStoreCart",
6572
6111
  from: resolver.resolve("./runtime/server/utils/store")
6573
6112
  },
6113
+ {
6114
+ name: "resolveStoreCart",
6115
+ from: resolver.resolve("./runtime/server/utils/store")
6116
+ },
6574
6117
  {
6575
6118
  name: "getStoreCart",
6576
6119
  from: resolver.resolve("./runtime/server/utils/store")
@@ -7087,7 +6630,7 @@ ${extraSources}
7087
6630
  filePath: resolver.resolve("./runtime/app/components/QarpeoWelcome.vue")
7088
6631
  });
7089
6632
  const hasAnyService = Boolean(
7090
- options.auth || options.blob || options.db || options.cache || options.cms || options.cron || options.realtime || options.payments || options.jobs || options.ratelimit || options.agents || options.bots || options.mcp || options.mail || options.analytics || options.multitenant || options.kv || options.email || options.ai || options.vectorize || options.queue || options.workflows || options.hyperdrive || options.browser || options.do || options.d1 || options.r2
6633
+ options.auth || options.blob || options.db || options.cache || options.cms || options.cron || options.realtime || options.payments || options.jobs || options.ratelimit || options.agents || options.bots || options.mcp || options.mail || options.analytics || options.multitenant || options.kv || options.email || options.ai || options.vectorize || options.queue || options.workflows || options.hyperdrive || options.browser || options.do || options.d1 || options.r2 || options.notifications || options.notify || options.comments || options.store || options.site || options.seo
7091
6634
  );
7092
6635
  if (!hasAnyService) {
7093
6636
  return;
@@ -7128,4 +6671,4 @@ ${extraSources}
7128
6671
  }
7129
6672
  });
7130
6673
 
7131
- export { ALL_CMS_TABLE_NAMES, ALL_COMMENTS_TABLE_NAMES, ALL_STORE_TABLE_NAMES, checkDrizzleVersion, cmsBookmarks, cmsCategories, cmsCollections, cmsEntries, cmsRevisions, cmsSubscribers, cmsTags, createWranglerConfig, module$1 as default, discoverDatabases, discoverSources, extractGroupTitle, extractOrderPrefix, findAgentFiles, findBotFiles, findDurableObjectFiles, findEmailHandlerFiles, findJobFiles, findMcpFiles, findQueueFiles, findScheduledTasks, findSchemaFiles, findToolFiles, findWorkflowFiles, generateAuthSchema, generateCommentsSchema, generateDevWranglerConfig, generateNotificationsSchema, generatePaymentsSchema, generateStoreSchema, generateTenantsSchema, getActiveCmsTableNames, getActiveCommentsTableNames, getActiveNotificationsTableNames, getActivePaymentsTableNames, getActiveStoreTableNames, getActiveTenantsTableNames, isGroupSegment, isRemoteSource, matchPathPatterns, matchesGlobFilter, matchesSourceFilters, resolveAllCmsSources, resolveCollectionForPath, resolveSourcePrefix, scanContentEntries, scanSchemaExports, stripOrderPrefix };
6674
+ export { checkDrizzleVersion, createWranglerConfig, module$1 as default, discoverDatabases, discoverSources, extractGroupTitle, extractOrderPrefix, findAgentFiles, findBotFiles, findDurableObjectFiles, findEmailHandlerFiles, findJobFiles, findMcpFiles, findQueueFiles, findScheduledTasks, findSchemaFiles, findToolFiles, findWorkflowFiles, generateAuthSchema, generateCommentsSchema, generateDevWranglerConfig, generateNotificationsSchema, generatePaymentsSchema, generateStoreSchema, generateTenantsSchema, getActiveNotificationsTableNames, getActivePaymentsTableNames, getActiveTenantsTableNames, isGroupSegment, isRemoteSource, matchPathPatterns, matchesGlobFilter, matchesSourceFilters, resolveAllCmsSources, resolveCollectionForPath, resolveSourcePrefix, scanContentEntries, scanSchemaExports, stripOrderPrefix };