qarpeo 0.1.34 → 0.2.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 (364) hide show
  1. package/README.md +114 -26
  2. package/dist/apps/cms.d.ts +4 -0
  3. package/dist/apps/comments.d.ts +4 -0
  4. package/dist/apps/payments.d.ts +4 -0
  5. package/dist/apps/store.d.ts +4 -0
  6. package/dist/chunks/auth-schema.mjs +169 -30
  7. package/dist/chunks/tools.mjs +1680 -0
  8. package/dist/cli/index.mjs +1256 -221
  9. package/dist/core/aliases.d.ts +5 -0
  10. package/dist/core/context.d.ts +10 -0
  11. package/dist/core/cross-drive.d.ts +2 -0
  12. package/dist/core/d1-migrate.d.ts +4 -0
  13. package/dist/core/devtools.d.ts +4 -0
  14. package/dist/core/nitro.d.ts +4 -0
  15. package/dist/core/schema.d.ts +4 -0
  16. package/dist/core/server-utils.d.ts +4 -0
  17. package/dist/core/wrangler.d.ts +4 -0
  18. package/dist/dev/wrangler.d.ts +1 -0
  19. package/dist/fate/index.d.ts +8 -8
  20. package/dist/features/agents.d.ts +4 -0
  21. package/dist/features/auth.d.ts +4 -0
  22. package/dist/features/bots.d.ts +4 -0
  23. package/dist/features/fate.d.ts +4 -0
  24. package/dist/features/mail.d.ts +4 -0
  25. package/dist/features/mcp.d.ts +4 -0
  26. package/dist/features/multitenant.d.ts +4 -0
  27. package/dist/features/notifications.d.ts +4 -0
  28. package/dist/features/realtime.d.ts +4 -0
  29. package/dist/module.d.ts +10 -2
  30. package/dist/module.mjs +6313 -5114
  31. package/dist/primitives/ai.d.ts +4 -0
  32. package/dist/primitives/analytics.d.ts +4 -0
  33. package/dist/primitives/blob.d.ts +4 -0
  34. package/dist/primitives/browser.d.ts +4 -0
  35. package/dist/primitives/cache.d.ts +4 -0
  36. package/dist/primitives/d1.d.ts +4 -0
  37. package/dist/primitives/do.d.ts +4 -0
  38. package/dist/primitives/email.d.ts +4 -0
  39. package/dist/primitives/hyperdrive.d.ts +4 -0
  40. package/dist/primitives/kv.d.ts +4 -0
  41. package/dist/primitives/queue.d.ts +4 -0
  42. package/dist/primitives/ratelimit.d.ts +4 -0
  43. package/dist/primitives/vectorize.d.ts +4 -0
  44. package/dist/primitives/workflows.d.ts +4 -0
  45. package/dist/runtime/ai.d.ts +3 -3
  46. package/dist/runtime/ai.mjs +8 -1
  47. package/dist/runtime/app/components/RealtimeCursors.vue +2 -2
  48. package/dist/runtime/app/composables/ai.d.ts +56 -29
  49. package/dist/runtime/app/composables/analytics.d.ts +26 -106
  50. package/dist/runtime/app/composables/api-tokens.d.ts +31 -34
  51. package/dist/runtime/app/composables/auth.d.ts +147 -51
  52. package/dist/runtime/app/composables/auth.mjs +0 -7
  53. package/dist/runtime/app/composables/chat.d.ts +38 -35
  54. package/dist/runtime/app/composables/cms-preview.d.ts +30 -25
  55. package/dist/runtime/app/composables/cms.d.ts +57 -282
  56. package/dist/runtime/app/composables/cms.mjs +0 -35
  57. package/dist/runtime/app/composables/comments.d.ts +32 -5
  58. package/dist/runtime/app/composables/comments.mjs +29 -1
  59. package/dist/runtime/app/composables/docs-version.d.ts +25 -28
  60. package/dist/runtime/app/composables/impersonation.d.ts +22 -5
  61. package/dist/runtime/app/composables/organization.d.ts +38 -91
  62. package/dist/runtime/app/composables/passkey.d.ts +22 -6
  63. package/dist/runtime/app/composables/passwordless.d.ts +24 -7
  64. package/dist/runtime/app/composables/payments.d.ts +50 -34
  65. package/dist/runtime/app/composables/payments.mjs +1 -0
  66. package/dist/runtime/app/composables/sse.d.ts +76 -0
  67. package/dist/runtime/app/composables/sse.mjs +152 -0
  68. package/dist/runtime/app/composables/storage.d.ts +53 -65
  69. package/dist/runtime/app/composables/storage.mjs +17 -0
  70. package/dist/runtime/app/composables/store.d.ts +198 -0
  71. package/dist/runtime/app/composables/store.mjs +414 -0
  72. package/dist/runtime/app/composables/tenant.d.ts +31 -72
  73. package/dist/runtime/app/composables/turnstile.d.ts +16 -3
  74. package/dist/runtime/app/composables/two-factor.d.ts +23 -6
  75. package/dist/runtime/app/pages/devtools/notifications.vue +30 -27
  76. package/dist/runtime/app/pages/devtools/realtime.vue +19 -31
  77. package/dist/runtime/app/pages/devtools.vue +0 -7
  78. package/dist/runtime/auth.d.ts +9 -9
  79. package/dist/runtime/blob.d.ts +10 -1
  80. package/dist/runtime/blob.mjs +83 -0
  81. package/dist/runtime/cache.d.ts +48 -0
  82. package/dist/runtime/cache.mjs +92 -0
  83. package/dist/runtime/comments.d.ts +4 -0
  84. package/dist/runtime/comments.mjs +2 -0
  85. package/dist/runtime/db.d.ts +21 -1
  86. package/dist/runtime/db.mjs +54 -0
  87. package/dist/runtime/drizzle.d.ts +4 -2
  88. package/dist/runtime/drizzle.mjs +68 -1
  89. package/dist/runtime/durable-object.d.ts +2 -0
  90. package/dist/runtime/durable-object.mjs +2 -0
  91. package/dist/runtime/email.d.ts +1 -1
  92. package/dist/runtime/email.mjs +1 -1
  93. package/dist/runtime/kv.mjs +50 -1
  94. package/dist/runtime/mcp.d.ts +2 -0
  95. package/dist/runtime/mcp.mjs +2 -0
  96. package/dist/runtime/queue.d.ts +12 -2
  97. package/dist/runtime/queue.mjs +19 -1
  98. package/dist/runtime/ratelimit.d.ts +1 -0
  99. package/dist/runtime/ratelimit.mjs +7 -0
  100. package/dist/runtime/schema.d.ts +313 -0
  101. package/dist/runtime/schema.mjs +259 -0
  102. package/dist/runtime/server/db/cms-schema.d.ts +1225 -171
  103. package/dist/runtime/server/db/cms-schema.mjs +69 -70
  104. package/dist/runtime/server/db/store-schema.d.ts +4344 -0
  105. package/dist/runtime/server/db/store-schema.mjs +266 -0
  106. package/dist/runtime/server/durable-objects/agent.mjs +35 -0
  107. package/dist/runtime/server/durable-objects/room.mjs +0 -1
  108. package/dist/runtime/server/middleware/ratelimit.mjs +10 -8
  109. package/dist/runtime/server/plugins/comments.d.ts +7 -0
  110. package/dist/runtime/server/plugins/comments.mjs +7 -0
  111. package/dist/runtime/server/plugins/email-inbound.d.ts +5 -0
  112. package/dist/runtime/server/plugins/email-inbound.mjs +17 -0
  113. package/dist/runtime/server/plugins/store.d.ts +7 -0
  114. package/dist/runtime/server/plugins/store.mjs +7 -0
  115. package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +2 -2
  116. package/dist/runtime/server/routes/atom.xml.get.mjs +3 -1
  117. package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +13 -2
  118. package/dist/runtime/server/routes/auth/2fa/setup.post.mjs +9 -3
  119. package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +11 -3
  120. package/dist/runtime/server/routes/auth/account.delete.mjs +2 -1
  121. package/dist/runtime/server/routes/auth/audit-logs.get.mjs +1 -1
  122. package/dist/runtime/server/routes/auth/magic-link/send.post.d.ts +1 -9
  123. package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +8 -0
  124. package/dist/runtime/server/routes/auth/organization/sso/[id].delete.mjs +1 -1
  125. package/dist/runtime/server/routes/auth/organization/sso/index.get.mjs +1 -1
  126. package/dist/runtime/server/routes/auth/organization/sso/index.post.mjs +1 -1
  127. package/dist/runtime/server/routes/auth/otp/send.post.d.ts +1 -9
  128. package/dist/runtime/server/routes/auth/otp/send.post.mjs +8 -0
  129. package/dist/runtime/server/routes/auth/sso/login.get.mjs +3 -3
  130. package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +1 -1
  131. package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +2 -2
  132. package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
  133. package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +1 -1
  134. package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +2 -2
  135. package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +1 -1
  136. package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.mjs +1 -1
  137. package/dist/runtime/server/routes/cms/[collection]/atom.xml.get.mjs +3 -1
  138. package/dist/runtime/server/routes/cms/[collection]/feed.xml.get.mjs +3 -1
  139. package/dist/runtime/server/routes/cms/bookmarks/[id].delete.mjs +1 -1
  140. package/dist/runtime/server/routes/cms/bookmarks/check.post.mjs +1 -1
  141. package/dist/runtime/server/routes/cms/bookmarks/index.get.mjs +1 -1
  142. package/dist/runtime/server/routes/cms/bookmarks/index.post.mjs +1 -1
  143. package/dist/runtime/server/routes/cms/deploy.post.mjs +1 -1
  144. package/dist/runtime/server/routes/cms/export.post.mjs +4 -3
  145. package/dist/runtime/server/routes/cms/search.get.mjs +7 -5
  146. package/dist/runtime/server/routes/cms/sync.post.mjs +2 -1
  147. package/dist/runtime/server/routes/comments/[id]/react.post.mjs +1 -2
  148. package/dist/runtime/server/routes/comments/[id]/report.post.d.ts +1 -1
  149. package/dist/runtime/server/routes/comments/[id]/report.post.mjs +0 -2
  150. package/dist/runtime/server/routes/comments/[id].delete.mjs +8 -4
  151. package/dist/runtime/server/routes/comments/[id].get.d.ts +1 -1
  152. package/dist/runtime/server/routes/comments/[id].get.mjs +1 -2
  153. package/dist/runtime/server/routes/comments/[id].patch.d.ts +1 -1
  154. package/dist/runtime/server/routes/comments/[id].patch.mjs +6 -3
  155. package/dist/runtime/server/routes/comments/batch.post.d.ts +2 -0
  156. package/dist/runtime/server/routes/comments/batch.post.mjs +33 -0
  157. package/dist/runtime/server/routes/comments/index.get.d.ts +1 -1
  158. package/dist/runtime/server/routes/comments/index.get.mjs +6 -4
  159. package/dist/runtime/server/routes/comments/index.post.d.ts +1 -1
  160. package/dist/runtime/server/routes/comments/index.post.mjs +6 -2
  161. package/dist/runtime/server/routes/feed.xml.get.mjs +3 -1
  162. package/dist/runtime/server/routes/sitemap.xml.get.mjs +3 -1
  163. package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +17 -0
  164. package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +29 -0
  165. package/dist/runtime/server/routes/store/cart/index.delete.d.ts +6 -0
  166. package/dist/runtime/server/routes/store/cart/index.delete.mjs +11 -0
  167. package/dist/runtime/server/routes/store/cart/index.get.d.ts +5 -0
  168. package/dist/runtime/server/routes/store/cart/index.get.mjs +14 -0
  169. package/dist/runtime/server/routes/store/cart/items/[id].delete.d.ts +6 -0
  170. package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +25 -0
  171. package/dist/runtime/server/routes/store/cart/items/[id].patch.d.ts +6 -0
  172. package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +29 -0
  173. package/dist/runtime/server/routes/store/cart/items.post.d.ts +6 -0
  174. package/dist/runtime/server/routes/store/cart/items.post.mjs +36 -0
  175. package/dist/runtime/server/routes/store/categories/index.get.d.ts +2 -0
  176. package/dist/runtime/server/routes/store/categories/index.get.mjs +8 -0
  177. package/dist/runtime/server/routes/store/checkout.post.d.ts +6 -0
  178. package/dist/runtime/server/routes/store/checkout.post.mjs +21 -0
  179. package/dist/runtime/server/routes/store/coupons/apply.post.d.ts +7 -0
  180. package/dist/runtime/server/routes/store/coupons/apply.post.mjs +18 -0
  181. package/dist/runtime/server/routes/store/currencies.get.d.ts +15 -0
  182. package/dist/runtime/server/routes/store/currencies.get.mjs +13 -0
  183. package/dist/runtime/server/routes/store/orders/[id].get.d.ts +2 -0
  184. package/dist/runtime/server/routes/store/orders/[id].get.mjs +26 -0
  185. package/dist/runtime/server/routes/store/orders/download/[token].get.d.ts +7 -0
  186. package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +57 -0
  187. package/dist/runtime/server/routes/store/orders/index.get.d.ts +5 -0
  188. package/dist/runtime/server/routes/store/orders/index.get.mjs +30 -0
  189. package/dist/runtime/server/routes/store/products/[slug].get.d.ts +2 -0
  190. package/dist/runtime/server/routes/store/products/[slug].get.mjs +18 -0
  191. package/dist/runtime/server/routes/store/products/index.get.d.ts +5 -0
  192. package/dist/runtime/server/routes/store/products/index.get.mjs +33 -0
  193. package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +9 -0
  194. package/dist/runtime/server/routes/store/tax/calculate.post.mjs +18 -0
  195. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +14 -1
  196. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +14 -1
  197. package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +24 -1
  198. package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +6 -0
  199. package/dist/runtime/server/utils/ai.d.ts +146 -21
  200. package/dist/runtime/server/utils/ai.mjs +406 -11
  201. package/dist/runtime/server/utils/analytics-query.d.ts +13 -58
  202. package/dist/runtime/server/utils/audit.d.ts +5 -4
  203. package/dist/runtime/server/utils/audit.mjs +25 -14
  204. package/dist/runtime/server/utils/auth.d.ts +29 -12
  205. package/dist/runtime/server/utils/auth.mjs +88 -70
  206. package/dist/runtime/server/utils/bots.d.ts +20 -4
  207. package/dist/runtime/server/utils/bots.mjs +7 -3
  208. package/dist/runtime/server/utils/browser-utils.d.ts +23 -23
  209. package/dist/runtime/server/utils/cache.d.ts +31 -10
  210. package/dist/runtime/server/utils/cache.mjs +130 -53
  211. package/dist/runtime/server/utils/cms/collections.d.ts +23 -0
  212. package/dist/runtime/server/utils/cms/collections.mjs +143 -0
  213. package/dist/runtime/server/utils/cms/common.d.ts +9 -0
  214. package/dist/runtime/server/utils/cms/common.mjs +28 -0
  215. package/dist/runtime/server/utils/cms/git.mjs +2 -2
  216. package/dist/runtime/server/utils/cms/navigation.d.ts +46 -0
  217. package/dist/runtime/server/utils/cms/navigation.mjs +683 -0
  218. package/dist/runtime/server/utils/cms/preview.d.ts +11 -0
  219. package/dist/runtime/server/utils/cms/preview.mjs +50 -0
  220. package/dist/runtime/server/utils/cms/search.d.ts +1 -1
  221. package/dist/runtime/server/utils/cms/search.mjs +11 -7
  222. package/dist/runtime/server/utils/cms/sync.d.ts +34 -0
  223. package/dist/runtime/server/utils/cms/sync.mjs +1082 -0
  224. package/dist/runtime/server/utils/cms/taxonomy.d.ts +103 -0
  225. package/dist/runtime/server/utils/cms/taxonomy.mjs +348 -0
  226. package/dist/runtime/server/utils/cms.d.ts +13 -249
  227. package/dist/runtime/server/utils/cms.mjs +108 -2350
  228. package/dist/runtime/server/utils/comments-filter.d.ts +45 -0
  229. package/dist/runtime/server/utils/comments-filter.mjs +541 -0
  230. package/dist/runtime/server/utils/comments.d.ts +71 -0
  231. package/dist/runtime/server/utils/comments.mjs +137 -61
  232. package/dist/runtime/server/utils/config.d.ts +4 -3
  233. package/dist/runtime/server/utils/config.mjs +7 -6
  234. package/dist/runtime/server/utils/context.d.ts +14 -0
  235. package/dist/runtime/server/utils/context.mjs +2 -2
  236. package/dist/runtime/server/utils/crypto.d.ts +44 -5
  237. package/dist/runtime/server/utils/crypto.mjs +18 -0
  238. package/dist/runtime/server/utils/domains.mjs +9 -5
  239. package/dist/runtime/server/utils/drizzle.d.ts +35 -3
  240. package/dist/runtime/server/utils/drizzle.mjs +115 -6
  241. package/dist/runtime/server/utils/durable-object.d.ts +106 -0
  242. package/dist/runtime/server/utils/durable-object.mjs +628 -0
  243. package/dist/runtime/server/utils/email-inbound.d.ts +29 -0
  244. package/dist/runtime/server/utils/email-inbound.mjs +76 -0
  245. package/dist/runtime/server/utils/impersonation.d.ts +32 -2
  246. package/dist/runtime/server/utils/impersonation.mjs +16 -13
  247. package/dist/runtime/server/utils/lock.d.ts +71 -0
  248. package/dist/runtime/server/utils/lock.mjs +139 -0
  249. package/dist/runtime/server/utils/mail-suppression.mjs +7 -7
  250. package/dist/runtime/server/utils/mail.d.ts +30 -19
  251. package/dist/runtime/server/utils/mcp.d.ts +44 -0
  252. package/dist/runtime/server/utils/mcp.mjs +308 -0
  253. package/dist/runtime/server/utils/notifications.d.ts +72 -7
  254. package/dist/runtime/server/utils/notifications.mjs +67 -55
  255. package/dist/runtime/server/utils/oauth.d.ts +27 -4
  256. package/dist/runtime/server/utils/organization.d.ts +63 -7
  257. package/dist/runtime/server/utils/organization.mjs +26 -21
  258. package/dist/runtime/server/utils/passwordless.d.ts +62 -33
  259. package/dist/runtime/server/utils/payments.d.ts +51 -12
  260. package/dist/runtime/server/utils/payments.mjs +472 -282
  261. package/dist/runtime/server/utils/queue.d.ts +106 -13
  262. package/dist/runtime/server/utils/queue.mjs +313 -28
  263. package/dist/runtime/server/utils/rag.d.ts +42 -14
  264. package/dist/runtime/server/utils/rag.mjs +169 -4
  265. package/dist/runtime/server/utils/ratelimit.d.ts +34 -5
  266. package/dist/runtime/server/utils/ratelimit.mjs +95 -14
  267. package/dist/runtime/server/utils/realtime.d.ts +68 -52
  268. package/dist/runtime/server/utils/scheduled-task.d.ts +42 -1
  269. package/dist/runtime/server/utils/scheduled-task.mjs +29 -0
  270. package/dist/runtime/server/utils/schema-fallback.d.ts +1 -1
  271. package/dist/runtime/server/utils/schema-fallback.mjs +1 -1
  272. package/dist/runtime/server/utils/session.d.ts +84 -10
  273. package/dist/runtime/server/utils/session.mjs +12 -10
  274. package/dist/runtime/server/utils/sse.d.ts +75 -0
  275. package/dist/runtime/server/utils/sse.mjs +147 -0
  276. package/dist/runtime/server/utils/sso.d.ts +1 -1
  277. package/dist/runtime/server/utils/storage.d.ts +53 -4
  278. package/dist/runtime/server/utils/storage.mjs +15 -11
  279. package/dist/runtime/server/utils/store-localization.d.ts +51 -0
  280. package/dist/runtime/server/utils/store-localization.mjs +417 -0
  281. package/dist/runtime/server/utils/store.d.ts +207 -0
  282. package/dist/runtime/server/utils/store.mjs +2227 -0
  283. package/dist/runtime/server/utils/table-names.d.ts +51 -0
  284. package/dist/runtime/server/utils/table-names.mjs +69 -0
  285. package/dist/runtime/server/utils/tenant.d.ts +26 -2
  286. package/dist/runtime/server/utils/tenant.mjs +16 -12
  287. package/dist/runtime/server/utils/tools-registry-fallback.d.ts +1 -0
  288. package/dist/runtime/server/utils/tools-registry-fallback.mjs +1 -0
  289. package/dist/runtime/server/utils/totp.d.ts +45 -2
  290. package/dist/runtime/server/utils/tracker.d.ts +10 -11
  291. package/dist/runtime/server/utils/turnstile.d.ts +16 -1
  292. package/dist/runtime/server/utils/workflows.d.ts +92 -0
  293. package/dist/runtime/server/utils/workflows.mjs +299 -0
  294. package/dist/runtime/server.d.ts +8 -1
  295. package/dist/runtime/server.mjs +8 -5
  296. package/dist/runtime/service.d.ts +10 -10
  297. package/dist/runtime/storage.d.ts +1 -0
  298. package/dist/runtime/storage.mjs +1 -0
  299. package/dist/runtime/store.d.ts +4 -0
  300. package/dist/runtime/store.mjs +2 -0
  301. package/dist/runtime/test-utils.d.ts +11 -10
  302. package/dist/runtime/test-utils.mjs +64 -4
  303. package/dist/runtime/types/ai.d.ts +21 -2
  304. package/dist/runtime/types/d1.d.ts +17 -0
  305. package/dist/runtime/types/drizzle.d.ts +2 -2
  306. package/dist/runtime/types/durable-object.d.ts +62 -2
  307. package/dist/runtime/types/email.d.ts +46 -0
  308. package/dist/runtime/types/imports.d.ts +6 -1
  309. package/dist/runtime/types/index.d.ts +58 -0
  310. package/dist/runtime/types/index.mjs +3 -0
  311. package/dist/runtime/types/mcp.d.ts +83 -0
  312. package/dist/runtime/types/mcp.mjs +0 -0
  313. package/dist/runtime/types/queue.d.ts +36 -0
  314. package/dist/runtime/types/r2.d.ts +41 -0
  315. package/dist/runtime/types/store.d.ts +313 -0
  316. package/dist/runtime/types/store.mjs +0 -0
  317. package/dist/runtime/types/workflows.d.ts +98 -0
  318. package/dist/runtime/types/workflows.mjs +0 -0
  319. package/dist/runtime/workflows.d.ts +5 -0
  320. package/dist/runtime/workflows.mjs +2 -0
  321. package/dist/types/ai.d.ts +721 -0
  322. package/dist/types/cms.d.ts +710 -0
  323. package/dist/types.d.ts +430 -1292
  324. package/dist/utils/auth-schema.d.ts +3 -2
  325. package/dist/utils/bots.d.ts +20 -0
  326. package/dist/utils/comments-schema.d.ts +5 -4
  327. package/dist/utils/drizzle.d.ts +83 -3
  328. package/dist/utils/durable-objects.d.ts +10 -0
  329. package/dist/utils/email-inbound.d.ts +10 -0
  330. package/dist/utils/local-db.d.ts +1 -3
  331. package/dist/utils/mcp.d.ts +24 -0
  332. package/dist/utils/notifications-schema.d.ts +5 -4
  333. package/dist/utils/payments-schema.d.ts +4 -3
  334. package/dist/utils/store-schema.d.ts +14 -0
  335. package/dist/utils/table-names.d.ts +1 -0
  336. package/dist/utils/tenants-schema.d.ts +4 -3
  337. package/dist/utils/tools.d.ts +20 -0
  338. package/dist/utils/workflows.d.ts +8 -0
  339. package/package.json +34 -4
  340. package/dist/chunks/wrangler.mjs +0 -897
  341. package/dist/runtime/app/components/AuthRegister.vue +0 -306
  342. package/dist/runtime/app/components/AuthSessionsList.vue +0 -137
  343. package/dist/runtime/app/components/AuthSignIn.vue +0 -298
  344. package/dist/runtime/app/components/CMSBookmarkButton.vue +0 -59
  345. package/dist/runtime/app/components/CMSImage.vue +0 -47
  346. package/dist/runtime/app/components/CMSLocaleSwitcher.vue +0 -110
  347. package/dist/runtime/app/components/CMSNewsletter.vue +0 -81
  348. package/dist/runtime/app/components/CMSPreviewBanner.vue +0 -83
  349. package/dist/runtime/app/components/CMSTableOfContents.vue +0 -84
  350. package/dist/runtime/app/components/CMSVersionBanner.vue +0 -53
  351. package/dist/runtime/app/components/CMSVersionSwitcher.vue +0 -140
  352. package/dist/runtime/app/components/Comments.vue +0 -411
  353. package/dist/runtime/app/components/FileUpload.vue +0 -200
  354. package/dist/runtime/app/components/ImpersonationBanner.vue +0 -61
  355. package/dist/runtime/app/components/NotificationBell.vue +0 -263
  356. package/dist/runtime/app/components/NotificationList.vue +0 -205
  357. package/dist/runtime/app/components/NotificationPrompt.vue +0 -133
  358. package/dist/runtime/app/components/PricingGated.vue +0 -81
  359. package/dist/runtime/app/components/PricingTable.vue +0 -274
  360. package/dist/runtime/app/components/RealtimeChat.vue +0 -164
  361. package/dist/runtime/app/components/RealtimePresence.vue +0 -129
  362. package/dist/runtime/app/components/RealtimeStatus.vue +0 -79
  363. package/dist/runtime/app/components/SubscriptionCard.vue +0 -207
  364. package/dist/runtime/app/components/UserProfile.vue +0 -558
@@ -0,0 +1,683 @@
1
+ import { getCookie } from "nuxt/server";
2
+ import { getAuthContext } from "../context.mjs";
3
+ import { getCMSDb, getCMSConfig, getCMSTenantId, cmsEntryTbl } from "./common.mjs";
4
+ import { parseMarkdownAST } from "./markdown.mjs";
5
+ import { verifyPreviewToken } from "./preview.mjs";
6
+ import {
7
+ projectCMSEntry,
8
+ ensureCMSSynced,
9
+ rowToEntry,
10
+ listCMSCollections,
11
+ queryCMSEntries
12
+ } from "../cms.mjs";
13
+ export async function getCMSEntryByPath(event, collectionId, path, locale, options = {}) {
14
+ await ensureCMSSynced(event);
15
+ const db = getCMSDb(event);
16
+ const cleanPath = path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
17
+ const tenantId = getCMSTenantId(event);
18
+ const tenantClause = tenantId ? " AND (tenant_id = ? OR tenant_id IS NULL)" : "";
19
+ let allowDraft = false;
20
+ const previewCookie = event ? getCookie(event, "qarpeo_preview") : null;
21
+ let cookieObj = null;
22
+ if (previewCookie) {
23
+ try {
24
+ cookieObj = typeof previewCookie === "string" ? JSON.parse(previewCookie) : previewCookie;
25
+ } catch {
26
+ }
27
+ }
28
+ const isPreviewRequested = options.preview || Boolean(cookieObj);
29
+ if (isPreviewRequested) {
30
+ const auth = await getAuthContext(event).catch(() => null);
31
+ const config = getCMSConfig(event);
32
+ if (auth?.user && config.roles.some((r) => r === auth.role || auth.isAdmin)) {
33
+ allowDraft = true;
34
+ }
35
+ if (!allowDraft && db) {
36
+ const token = options.previewToken || cookieObj?.token;
37
+ const expires = options.previewExpires || cookieObj?.expires;
38
+ if (token && expires) {
39
+ try {
40
+ const candidate = await db.prepare(
41
+ `SELECT id, slug, collection_id FROM ${cmsEntryTbl(event)} WHERE (collection_id = ? OR ? = 'content') AND (path = ? OR path = ?) ${tenantClause} LIMIT 1`
42
+ ).bind(collectionId, collectionId, cleanPath, `${cleanPath}/`).first();
43
+ if (candidate) {
44
+ allowDraft = await verifyPreviewToken(
45
+ event,
46
+ candidate.collection_id,
47
+ candidate.id,
48
+ token,
49
+ expires
50
+ ) || await verifyPreviewToken(
51
+ event,
52
+ candidate.collection_id,
53
+ candidate.slug,
54
+ token,
55
+ expires
56
+ );
57
+ }
58
+ } catch {
59
+ }
60
+ }
61
+ }
62
+ }
63
+ const statusFilter = allowDraft ? "status IN ('draft', 'published', 'scheduled')" : "status = 'published'";
64
+ const statusOrder = allowDraft ? "CASE WHEN status = 'draft' THEN 1 WHEN status = 'scheduled' THEN 2 ELSE 3 END," : "";
65
+ let row = null;
66
+ if (db) {
67
+ try {
68
+ if (locale) {
69
+ const bindsLocale = tenantId ? [collectionId, cleanPath, `${cleanPath}/`, locale, tenantId] : [collectionId, cleanPath, `${cleanPath}/`, locale];
70
+ row = await db.prepare(
71
+ `SELECT * FROM ${cmsEntryTbl(event)} WHERE collection_id = ? AND (path = ? OR path = ?) AND locale = ? AND ${statusFilter}${tenantClause} ORDER BY ${statusOrder} created_at DESC LIMIT 1`
72
+ ).bind(...bindsLocale).first();
73
+ }
74
+ const binds1 = tenantId ? [collectionId, cleanPath, `${cleanPath}/`, tenantId] : [collectionId, cleanPath, `${cleanPath}/`];
75
+ if (!row) {
76
+ row = await db.prepare(
77
+ `SELECT * FROM ${cmsEntryTbl(event)} WHERE collection_id = ? AND (path = ? OR path = ?) AND ${statusFilter}${tenantClause} ORDER BY ${statusOrder} CASE WHEN locale = 'en' THEN 1 ELSE 2 END LIMIT 1`
78
+ ).bind(...binds1).first();
79
+ }
80
+ if (!row && cleanPath.startsWith(`/${collectionId}`)) {
81
+ const unPrefixed = cleanPath.slice(`/${collectionId}`.length) || "/";
82
+ const binds2 = tenantId ? [collectionId, unPrefixed, `${unPrefixed}/`, tenantId] : [collectionId, unPrefixed, `${unPrefixed}/`];
83
+ row = await db.prepare(
84
+ `SELECT * FROM ${cmsEntryTbl(event)} WHERE collection_id = ? AND (path = ? OR path = ?) AND ${statusFilter}${tenantClause} ORDER BY ${statusOrder} created_at DESC LIMIT 1`
85
+ ).bind(...binds2).first();
86
+ }
87
+ if (!row) {
88
+ const binds3 = tenantId ? [cleanPath, `${cleanPath}/`, tenantId] : [cleanPath, `${cleanPath}/`];
89
+ row = await db.prepare(
90
+ `SELECT * FROM ${cmsEntryTbl(event)} WHERE (path = ? OR path = ?) AND ${statusFilter}${tenantClause} ORDER BY ${statusOrder} created_at DESC LIMIT 1`
91
+ ).bind(...binds3).first();
92
+ }
93
+ } catch {
94
+ }
95
+ }
96
+ if (!row) {
97
+ try {
98
+ const { manifestEntries } = await import("#qarpeo/cms/manifest");
99
+ const candidate = (manifestEntries || []).find(
100
+ (e) => (e.collection_id === collectionId || collectionId === "content") && (e.path === cleanPath || e.path === `${cleanPath}/`)
101
+ );
102
+ if (candidate) {
103
+ row = candidate;
104
+ }
105
+ } catch {
106
+ }
107
+ }
108
+ if (!row) return null;
109
+ const entry = rowToEntry(row);
110
+ const wantsBody = !options.fields || (Array.isArray(options.fields) ? options.fields.some((f) => f === "body" || f.includes("body")) : String(options.fields).includes("body"));
111
+ if (wantsBody && (!entry.body || !Array.isArray(entry.body.nodes)) && entry.contentMd) {
112
+ const ast = await parseMarkdownAST(entry.contentMd);
113
+ entry.body = {
114
+ ...ast,
115
+ toc: entry.toc || { links: [] }
116
+ };
117
+ } else if (entry.body && Array.isArray(entry.body.nodes)) {
118
+ if ("value" in entry.body) delete entry.body.value;
119
+ if ("content" in entry.body) delete entry.body.content;
120
+ }
121
+ if (options.fields) {
122
+ return projectCMSEntry(entry, options.fields);
123
+ }
124
+ return entry;
125
+ }
126
+ export async function getCMSEntrySurroundings(event, collectionId, path, fields = []) {
127
+ await ensureCMSSynced(event);
128
+ const db = getCMSDb(event);
129
+ const cleanPath = path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
130
+ const pick = (entry) => {
131
+ if (!entry) return null;
132
+ if (!fields.length) return entry;
133
+ const partial = { id: entry.id, slug: entry.slug, path: entry.path, title: entry.title };
134
+ for (const f of fields) {
135
+ if (f in entry) partial[f] = entry[f];
136
+ }
137
+ return partial;
138
+ };
139
+ try {
140
+ const navTree = await getCMSNavigationTree(event, collectionId);
141
+ const orderedPaths = [];
142
+ const seenPaths = /* @__PURE__ */ new Set();
143
+ const collectPaths = (items) => {
144
+ for (const item of items) {
145
+ if (item.path && item.type !== "group") {
146
+ const norm = item.path.length > 1 && item.path.endsWith("/") ? item.path.slice(0, -1) : item.path;
147
+ if (!seenPaths.has(norm)) {
148
+ seenPaths.add(norm);
149
+ orderedPaths.push(norm);
150
+ }
151
+ }
152
+ if (item.children?.length) {
153
+ collectPaths(item.children);
154
+ }
155
+ }
156
+ };
157
+ collectPaths(navTree);
158
+ let idx2 = orderedPaths.indexOf(cleanPath);
159
+ if (idx2 === -1) {
160
+ idx2 = orderedPaths.indexOf(`${cleanPath}/`);
161
+ }
162
+ if (idx2 !== -1) {
163
+ const prevPath = idx2 > 0 ? orderedPaths[idx2 - 1] : null;
164
+ const nextPath = idx2 < orderedPaths.length - 1 ? orderedPaths[idx2 + 1] : null;
165
+ const [prevEntry, nextEntry] = await Promise.all([
166
+ prevPath ? getCMSEntryByPath(event, collectionId, prevPath) : Promise.resolve(null),
167
+ nextPath ? getCMSEntryByPath(event, collectionId, nextPath) : Promise.resolve(null)
168
+ ]);
169
+ return [pick(prevEntry), pick(nextEntry)];
170
+ }
171
+ } catch (err) {
172
+ console.warn("[qarpeo:cms] getCMSEntrySurroundings navTree lookup failed:", err);
173
+ }
174
+ if (!db) return [null, null];
175
+ const tenantId = getCMSTenantId(event);
176
+ const tenantClause = tenantId ? " AND (tenant_id = ? OR tenant_id IS NULL)" : "";
177
+ const binds = tenantId ? [collectionId, tenantId] : [collectionId];
178
+ const all = await db.prepare(
179
+ `SELECT * FROM ${cmsEntryTbl(event)} WHERE collection_id = ? AND status = 'published'${tenantClause} ORDER BY "order" ASC`
180
+ ).bind(...binds).all();
181
+ const rows = (all.results || []).map(rowToEntry);
182
+ const idx = rows.findIndex((e) => e.path === cleanPath || e.path === `${cleanPath}/`);
183
+ if (idx === -1) return [null, null];
184
+ return [pick(rows[idx - 1]), pick(rows[idx + 1])];
185
+ }
186
+ function pruneTreeLevels(items, currentLevel, maxLevel) {
187
+ if (currentLevel >= maxLevel) {
188
+ for (const item of items) {
189
+ delete item.children;
190
+ }
191
+ return items;
192
+ }
193
+ for (const item of items) {
194
+ if (item.children) {
195
+ pruneTreeLevels(item.children, currentLevel + 1, maxLevel);
196
+ }
197
+ }
198
+ return items;
199
+ }
200
+ const CMS_FIRST_CLASS_COLUMNS = /* @__PURE__ */ new Set([
201
+ "id",
202
+ "slug",
203
+ "path",
204
+ "title",
205
+ "description",
206
+ "tags",
207
+ "status",
208
+ "source"
209
+ ]);
210
+ function matchesWhereFilter(row, meta, where) {
211
+ return Object.entries(where).every(([key, expected]) => {
212
+ if (CMS_FIRST_CLASS_COLUMNS.has(key)) {
213
+ const actual2 = row[key] ?? null;
214
+ return actual2 === expected;
215
+ }
216
+ const actual = meta[key] !== void 0 ? meta[key] : null;
217
+ return actual === expected;
218
+ });
219
+ }
220
+ export async function getCMSNavigationTree(event, collectionId, options) {
221
+ await ensureCMSSynced(event);
222
+ const db = getCMSDb(event);
223
+ if (collectionId === "content") {
224
+ const config = getCMSConfig(event);
225
+ const configuredKeys = Object.keys(config.collections || {});
226
+ const collections = await listCMSCollections(event);
227
+ const valid = collections.filter((c) => {
228
+ if (c.id.startsWith("_") || c.id === "content") return false;
229
+ const colConf = config.collections?.[c.id];
230
+ if (colConf && (colConf.navigation === false || colConf.hidden === true)) {
231
+ return false;
232
+ }
233
+ return true;
234
+ });
235
+ if (configuredKeys.length) {
236
+ valid.sort((a, b) => {
237
+ const ia = configuredKeys.indexOf(a.id);
238
+ const ib = configuredKeys.indexOf(b.id);
239
+ if (ia !== -1 && ib !== -1) return ia - ib;
240
+ if (ia !== -1) return -1;
241
+ if (ib !== -1) return 1;
242
+ return (a.order ?? 0) - (b.order ?? 0) || a.name.localeCompare(b.name);
243
+ });
244
+ } else {
245
+ valid.sort((a, b) => (a.order ?? 0) - (b.order ?? 0) || a.name.localeCompare(b.name));
246
+ }
247
+ let items = valid.map((c) => ({
248
+ title: c.name,
249
+ path: `/${c.id}`
250
+ }));
251
+ const targetStatus2 = options?.status || "published";
252
+ const navRootTenantId = getCMSTenantId(event);
253
+ let rootSql = `SELECT id, slug, path, title, "order", metadata_json, status FROM ${cmsEntryTbl(event)} WHERE collection_id = 'content'`;
254
+ const rootBinds = [];
255
+ if (targetStatus2 !== "all") {
256
+ rootSql += " AND status = ?";
257
+ rootBinds.push(targetStatus2);
258
+ }
259
+ if (navRootTenantId) {
260
+ rootSql += " AND (tenant_id = ? OR tenant_id IS NULL)";
261
+ rootBinds.push(navRootTenantId);
262
+ }
263
+ rootSql += ' ORDER BY "order" ASC';
264
+ let rows2 = [];
265
+ if (db) {
266
+ try {
267
+ const rootEntries = await db.prepare(rootSql).bind(...rootBinds).all();
268
+ rows2 = rootEntries.results || [];
269
+ } catch {
270
+ }
271
+ }
272
+ if (!rows2.length) {
273
+ try {
274
+ const { manifestEntries } = await import("#qarpeo/cms/manifest");
275
+ rows2 = (manifestEntries || []).filter((e) => e.collection_id === "content").map((e) => ({
276
+ id: e.id,
277
+ slug: e.slug,
278
+ path: e.path,
279
+ title: e.title,
280
+ order: e.order ?? 0,
281
+ metadata_json: typeof e.metadata_json === "string" ? e.metadata_json : JSON.stringify(e.metadata || {}),
282
+ status: e.status || "published"
283
+ }));
284
+ } catch {
285
+ }
286
+ }
287
+ for (const r of rows2) {
288
+ let meta = {};
289
+ try {
290
+ meta = JSON.parse(r.metadata_json || "{}");
291
+ } catch {
292
+ }
293
+ if (meta.navigation === false || meta.hidden === true || meta.navigation?.hidden === true || meta._nav?.navigation === false || meta._nav?.hidden === true) {
294
+ continue;
295
+ }
296
+ if (options?.where && !matchesWhereFilter(r, meta, options.where)) {
297
+ continue;
298
+ }
299
+ const entryPath = r.path || (r.slug === "index" ? "/" : `/${r.slug}`);
300
+ const title = meta.navigation?.title || meta._itemTitle || r.title;
301
+ const icon = meta.navigation?.icon || meta._nav?.icon;
302
+ items.push({
303
+ title,
304
+ path: entryPath,
305
+ to: entryPath,
306
+ icon
307
+ });
308
+ }
309
+ if (options?.skip != null || options?.limit != null) {
310
+ const skip = options?.skip ?? 0;
311
+ const limit = options?.limit ?? items.length;
312
+ items = items.slice(skip, skip + limit);
313
+ }
314
+ return items;
315
+ }
316
+ const targetStatus = options?.status || "published";
317
+ const navTenantId = getCMSTenantId(event);
318
+ let sql = `SELECT id, slug, path, title, "order", metadata_json, status FROM ${cmsEntryTbl(event)} WHERE collection_id = ?`;
319
+ const binds = [collectionId];
320
+ if (targetStatus !== "all") {
321
+ sql += " AND status = ?";
322
+ binds.push(targetStatus);
323
+ }
324
+ if (navTenantId) {
325
+ sql += " AND (tenant_id = ? OR tenant_id IS NULL)";
326
+ binds.push(navTenantId);
327
+ }
328
+ if (options?.locale) {
329
+ sql += " AND (locale = ? OR locale = 'en' OR locale IS NULL)";
330
+ binds.push(options.locale);
331
+ }
332
+ if (options?.path) {
333
+ const searchPath = ("/" + options.path.replace(/\\/g, "/").replace(/^\/+/, "")).replace(
334
+ /\/+$/,
335
+ ""
336
+ );
337
+ sql += " AND (path = ? OR path LIKE ?)";
338
+ binds.push(searchPath, `${searchPath}/%`);
339
+ }
340
+ sql += ' ORDER BY "order" ASC';
341
+ let rows = [];
342
+ if (db) {
343
+ try {
344
+ const all = await db.prepare(sql).bind(...binds).all();
345
+ rows = all.results || [];
346
+ } catch {
347
+ }
348
+ }
349
+ if (!rows.length) {
350
+ try {
351
+ const { manifestEntries } = await import("#qarpeo/cms/manifest");
352
+ rows = (manifestEntries || []).filter((e) => e.collection_id === collectionId).map((e) => ({
353
+ id: e.id,
354
+ slug: e.slug,
355
+ path: e.path,
356
+ title: e.title,
357
+ order: e.order ?? 0,
358
+ metadata_json: typeof e.metadata_json === "string" ? e.metadata_json : JSON.stringify(e.metadata || {})
359
+ }));
360
+ } catch {
361
+ }
362
+ }
363
+ const sectionsMap = /* @__PURE__ */ new Map();
364
+ for (const r of rows) {
365
+ let meta = {};
366
+ try {
367
+ meta = JSON.parse(r.metadata_json || "{}");
368
+ } catch {
369
+ }
370
+ const sectionMeta = meta._section || {};
371
+ const isHiddenFromNav = meta.navigation === false || meta.hidden === true || meta.navigation?.hidden === true || meta._nav?.navigation === false || meta._nav?.hidden === true || sectionMeta?.navigation === false || sectionMeta?.hidden === true;
372
+ if (isHiddenFromNav) {
373
+ continue;
374
+ }
375
+ if (options?.where && !matchesWhereFilter(r, meta, options.where)) {
376
+ continue;
377
+ }
378
+ const entryPath = r.path || `/${collectionId}/${r.slug}`;
379
+ const segments = entryPath.split("/").filter(Boolean);
380
+ const sectionPath = segments.length >= 2 ? `/${segments[0]}/${segments[1]}` : entryPath;
381
+ const defaultSectionTitle = segments.length >= 2 ? segments[1].charAt(0).toUpperCase() + segments[1].slice(1).replace(/-/g, " ") : r.title;
382
+ if (!sectionsMap.has(sectionPath)) {
383
+ const initialTitle = sectionMeta.title || defaultSectionTitle;
384
+ sectionsMap.set(sectionPath, {
385
+ title: initialTitle,
386
+ path: sectionPath,
387
+ icon: sectionMeta.icon,
388
+ children: [],
389
+ _order: meta._sectionOrder ?? (r.order ? Math.floor(r.order / 1e3) : 500)
390
+ });
391
+ }
392
+ const section = sectionsMap.get(sectionPath);
393
+ const itemTitle = meta.navigation?.title || meta._itemTitle || r.title;
394
+ const rawNavIcon = meta.navigation?.icon ?? meta.icon;
395
+ const itemIcon = rawNavIcon === false || rawNavIcon === null || rawNavIcon === "" ? void 0 : rawNavIcon;
396
+ const itemOrder = meta._isIndex ? 0 : typeof meta.navigation?.order === "number" ? meta.navigation.order : typeof meta.order === "number" ? meta.order : typeof meta._itemOrder === "number" ? meta._itemOrder : typeof meta._fileOrder === "number" ? meta._fileOrder : r.order ? r.order % 50 : 500;
397
+ if (entryPath === sectionPath) {
398
+ if (sectionMeta.title) section.title = sectionMeta.title;
399
+ if (sectionMeta.icon) section.icon = sectionMeta.icon;
400
+ if (sectionMeta.isolated !== void 0) section.isolated = sectionMeta.isolated;
401
+ if (meta._nav?.title) section.title = meta._nav.title;
402
+ if (meta._nav?.icon) section.icon = meta._nav.icon;
403
+ if (meta._nav?.isolated !== void 0) section.isolated = meta._nav.isolated;
404
+ section.children = section.children || [];
405
+ section.children.push({
406
+ title: itemTitle,
407
+ path: entryPath,
408
+ icon: itemIcon,
409
+ _groupOrder: itemOrder
410
+ });
411
+ continue;
412
+ }
413
+ if (meta._group) {
414
+ const groupKey = meta._group.key;
415
+ let groupItem = section.children?.find((c) => c._groupKey === groupKey);
416
+ if (!groupItem) {
417
+ groupItem = {
418
+ title: meta._group.title,
419
+ icon: meta._group.icon,
420
+ type: "group",
421
+ children: [],
422
+ _groupKey: groupKey,
423
+ _groupOrder: meta._group.order ?? 999
424
+ };
425
+ section.children = section.children || [];
426
+ section.children.push(groupItem);
427
+ }
428
+ const gi = groupItem;
429
+ gi.children = gi.children || [];
430
+ gi.children.push({
431
+ title: itemTitle,
432
+ path: entryPath,
433
+ icon: itemIcon,
434
+ _groupOrder: itemOrder
435
+ });
436
+ continue;
437
+ }
438
+ const folderSegments = meta._isIndex ? segments.slice(2) : segments.slice(2, -1);
439
+ let currentParent = section;
440
+ let currentPath = sectionPath;
441
+ for (let i = 0; i < folderSegments.length; i++) {
442
+ const folderSeg = folderSegments[i];
443
+ currentPath += `/${folderSeg}`;
444
+ const isLeafFolder = i === folderSegments.length - 1;
445
+ let subNode = currentParent.children?.find(
446
+ (c) => c._folderKey === folderSeg || c.path === currentPath
447
+ );
448
+ if (!subNode) {
449
+ const folderTitle = isLeafFolder && meta._nav?.title ? meta._nav.title : folderSeg.charAt(0).toUpperCase() + folderSeg.slice(1).replace(/-/g, " ");
450
+ const folderIcon = isLeafFolder ? meta._nav?.icon : void 0;
451
+ const folderOrder = isLeafFolder && typeof meta._nav?.order === "number" ? meta._nav.order : isLeafFolder && typeof meta._fileOrder === "number" ? meta._fileOrder : 500;
452
+ const newNode = {
453
+ title: folderTitle,
454
+ path: currentPath,
455
+ icon: folderIcon,
456
+ isolated: isLeafFolder ? meta._nav?.isolated : void 0,
457
+ children: [],
458
+ _folderKey: folderSeg,
459
+ _groupOrder: folderOrder
460
+ };
461
+ if (folderSegments.length > 1 && i > 0) {
462
+ newNode.type = "group";
463
+ }
464
+ currentParent.children = currentParent.children || [];
465
+ currentParent.children.push(newNode);
466
+ subNode = newNode;
467
+ } else if (isLeafFolder) {
468
+ if (meta._nav?.title) subNode.title = meta._nav.title;
469
+ if (meta._nav?.icon) subNode.icon = meta._nav.icon;
470
+ if (meta._nav?.isolated !== void 0) subNode.isolated = meta._nav.isolated;
471
+ if (typeof meta._nav?.order === "number") subNode._groupOrder = meta._nav.order;
472
+ }
473
+ currentParent = subNode;
474
+ }
475
+ if (meta._isIndex && folderSegments.length > 0) {
476
+ if (!currentParent.isolated) {
477
+ currentParent.children = currentParent.children || [];
478
+ currentParent.children.push({
479
+ title: itemTitle || "Overview",
480
+ path: entryPath,
481
+ icon: itemIcon,
482
+ _groupOrder: 0
483
+ });
484
+ }
485
+ continue;
486
+ }
487
+ currentParent.children = currentParent.children || [];
488
+ currentParent.children.push({
489
+ title: itemTitle,
490
+ path: entryPath,
491
+ icon: itemIcon,
492
+ _groupOrder: itemOrder
493
+ });
494
+ }
495
+ function cleanAndSortNode(item) {
496
+ if (item.path && !item.to) {
497
+ item.to = item.path;
498
+ }
499
+ if (item.children) {
500
+ item.children.sort((a, b) => {
501
+ if (a.path === item.path) return -1;
502
+ if (b.path === item.path) return 1;
503
+ const orderA = a._groupOrder ?? 500;
504
+ const orderB = b._groupOrder ?? 500;
505
+ if (orderA !== orderB) return orderA - orderB;
506
+ return (a.title || "").localeCompare(b.title || "");
507
+ });
508
+ for (const c of item.children) {
509
+ if (c.path && !c.to) {
510
+ c.to = c.path;
511
+ }
512
+ delete c._folderKey;
513
+ delete c._groupKey;
514
+ delete c._groupOrder;
515
+ delete c._subGroupKey;
516
+ delete c._subFeatureKey;
517
+ delete c._appKey;
518
+ cleanAndSortNode(c);
519
+ }
520
+ }
521
+ }
522
+ for (const s of sectionsMap.values()) {
523
+ cleanAndSortNode(s);
524
+ }
525
+ const sectionsList = Array.from(sectionsMap.values());
526
+ sectionsList.sort((a, b) => {
527
+ const orderA = a._order ?? 500;
528
+ const orderB = b._order ?? 500;
529
+ if (orderA !== orderB) return orderA - orderB;
530
+ return a.title.localeCompare(b.title);
531
+ });
532
+ for (const s of sectionsList) {
533
+ if (s.path && !s.to) {
534
+ s.to = s.path;
535
+ }
536
+ delete s._order;
537
+ }
538
+ let result = sectionsList;
539
+ if (options?.unwrap) {
540
+ if (result.length === 1 && result[0].children?.length) {
541
+ result = result[0].children;
542
+ } else {
543
+ const collectionRoot = result.find((item) => item.path === `/${collectionId}`);
544
+ if (collectionRoot?.children?.length) {
545
+ result = collectionRoot.children;
546
+ }
547
+ }
548
+ }
549
+ if (options?.path) {
550
+ const searchPath = ("/" + options.path.replace(/\\/g, "/").replace(/^\/+/, "")).replace(
551
+ /\/+$/,
552
+ ""
553
+ );
554
+ const matchedSection = sectionsList.find((s) => s.path === searchPath);
555
+ if (matchedSection && matchedSection.children?.length) {
556
+ result = matchedSection.children;
557
+ } else {
558
+ const findNode = (items) => {
559
+ for (const item of items) {
560
+ if (item.path === searchPath) return item;
561
+ if (item.children) {
562
+ const found = findNode(item.children);
563
+ if (found) return found;
564
+ }
565
+ }
566
+ };
567
+ const deepNode = findNode(sectionsList);
568
+ if (deepNode) {
569
+ result = deepNode.children?.length ? deepNode.children : [deepNode];
570
+ }
571
+ }
572
+ }
573
+ if (options?.levels != null && options.levels > 0) {
574
+ pruneTreeLevels(result, 1, options.levels);
575
+ }
576
+ if (options?.skip != null || options?.limit != null) {
577
+ const skip = options?.skip ?? 0;
578
+ const limit = options?.limit ?? result.length;
579
+ result = result.slice(skip, skip + limit);
580
+ }
581
+ return result;
582
+ }
583
+ export function queryCollection(event, collection) {
584
+ let _path = null;
585
+ let _locale = null;
586
+ let _limit = null;
587
+ let _page = 1;
588
+ let _sort = null;
589
+ let _tag = null;
590
+ let _status = "published";
591
+ let _preview = false;
592
+ let _fields = [];
593
+ const _wheres = {};
594
+ const builder = {
595
+ select(...fields) {
596
+ _fields = fields.flatMap((f) => typeof f === "string" ? f.split(",") : []).map((s) => s.trim()).filter(Boolean);
597
+ return builder;
598
+ },
599
+ locale(loc) {
600
+ _locale = loc;
601
+ return builder;
602
+ },
603
+ path(p) {
604
+ _path = p;
605
+ return builder;
606
+ },
607
+ limit(n) {
608
+ _limit = n;
609
+ return builder;
610
+ },
611
+ page(n) {
612
+ _page = n;
613
+ return builder;
614
+ },
615
+ order(field, direction = "ASC") {
616
+ const sanitizedField = String(field || "").replace(/[^a-zA-Z0-9_]/g, "");
617
+ const dir = String(direction).trim().toUpperCase() === "DESC" ? "desc" : "asc";
618
+ _sort = `${sanitizedField || "published_at"}:${dir}`;
619
+ return builder;
620
+ },
621
+ where(field, value) {
622
+ _wheres[field] = value;
623
+ return builder;
624
+ },
625
+ status(s) {
626
+ _status = s;
627
+ return builder;
628
+ },
629
+ tag(t) {
630
+ _tag = t;
631
+ return builder;
632
+ },
633
+ preview(enabled = true) {
634
+ _preview = enabled;
635
+ if (enabled) _status = "all";
636
+ return builder;
637
+ },
638
+ async first() {
639
+ if (_path) {
640
+ return await getCMSEntryByPath(event, collection, _path, _locale || void 0, {
641
+ preview: _preview,
642
+ fields: _fields.length ? _fields : void 0
643
+ });
644
+ }
645
+ const res = await queryCMSEntries(event, collection, {
646
+ limit: 1,
647
+ page: _page,
648
+ sort: _sort || void 0,
649
+ status: _status,
650
+ tag: _tag || void 0,
651
+ preview: _preview,
652
+ where: Object.keys(_wheres).length ? _wheres : void 0,
653
+ fields: _fields.length ? _fields : void 0
654
+ });
655
+ return res.entries[0] || null;
656
+ },
657
+ async all() {
658
+ const res = await queryCMSEntries(event, collection, {
659
+ limit: _limit || 100,
660
+ page: _page,
661
+ sort: _sort || void 0,
662
+ status: _status,
663
+ tag: _tag || void 0,
664
+ preview: _preview,
665
+ where: Object.keys(_wheres).length ? _wheres : void 0,
666
+ fields: _fields.length ? _fields : void 0
667
+ });
668
+ return res.entries;
669
+ },
670
+ async count() {
671
+ const res = await queryCMSEntries(event, collection, {
672
+ limit: 1,
673
+ page: 1,
674
+ status: _status,
675
+ tag: _tag || void 0,
676
+ preview: _preview,
677
+ where: Object.keys(_wheres).length ? _wheres : void 0
678
+ });
679
+ return res.total;
680
+ }
681
+ };
682
+ return builder;
683
+ }
@@ -0,0 +1,11 @@
1
+ import type { RequestEvent } from "nuxt/server";
2
+ /** Generates a 24-hour (or custom TTL) HMAC-SHA256 preview token for a draft entry. */
3
+ export declare function generatePreviewToken(event: RequestEvent, collection: string, slugOrId: string, ttlMs?: number): Promise<{
4
+ token: string;
5
+ expires: number;
6
+ }>;
7
+ /**
8
+ * Verifies an HMAC-SHA256 preview token. Tests against both `slugOrId` and alternate identifier (id
9
+ * vs slug) if available in D1.
10
+ */
11
+ export declare function verifyPreviewToken(event: RequestEvent, collection: string, slugOrId: string, token: string, expiresStr: string | number): Promise<boolean>;