qarpeo 0.4.13 → 0.4.15

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 (304) hide show
  1. package/README.md +197 -191
  2. package/dist/apps/cms.d.ts +1 -1
  3. package/dist/apps/comments.d.ts +1 -1
  4. package/dist/apps/payments.d.ts +1 -1
  5. package/dist/apps/store.d.ts +1 -1
  6. package/dist/chunks/{manifest.get.mjs → tools.mjs} +445 -430
  7. package/dist/cli/index.mjs +756 -746
  8. package/dist/core/aliases.d.ts +1 -1
  9. package/dist/core/context.d.ts +1 -1
  10. package/dist/core/d1-migrate.d.ts +1 -1
  11. package/dist/core/devtools.d.ts +1 -1
  12. package/dist/core/nitro.d.ts +1 -1
  13. package/dist/core/schema.d.ts +1 -1
  14. package/dist/core/server-utils.d.ts +1 -1
  15. package/dist/core/wrangler.d.ts +1 -1
  16. package/dist/fate/index.d.ts +8 -8
  17. package/dist/fate/index.mjs +3 -1
  18. package/dist/features/agents.d.ts +1 -1
  19. package/dist/features/auth.d.ts +1 -1
  20. package/dist/features/bots.d.ts +1 -1
  21. package/dist/features/console.d.ts +1 -1
  22. package/dist/features/fate.d.ts +1 -1
  23. package/dist/features/mail.d.ts +1 -1
  24. package/dist/features/mcp.d.ts +1 -1
  25. package/dist/features/multitenant.d.ts +1 -1
  26. package/dist/features/notifications.d.ts +1 -1
  27. package/dist/features/realtime.d.ts +1 -1
  28. package/dist/features/studio.d.ts +4 -0
  29. package/dist/module.d.ts +1 -1
  30. package/dist/module.mjs +5451 -5249
  31. package/dist/primitives/ai.d.ts +1 -1
  32. package/dist/primitives/analytics.d.ts +1 -1
  33. package/dist/primitives/blob.d.ts +1 -1
  34. package/dist/primitives/browser.d.ts +1 -1
  35. package/dist/primitives/cache.d.ts +1 -1
  36. package/dist/primitives/d1.d.ts +1 -1
  37. package/dist/primitives/do.d.ts +1 -1
  38. package/dist/primitives/email.d.ts +1 -1
  39. package/dist/primitives/hyperdrive.d.ts +1 -1
  40. package/dist/primitives/kv.d.ts +1 -1
  41. package/dist/primitives/queue.d.ts +1 -1
  42. package/dist/primitives/ratelimit.d.ts +1 -1
  43. package/dist/primitives/vectorize.d.ts +1 -1
  44. package/dist/primitives/workflows.d.ts +1 -1
  45. package/dist/runtime/ai.mjs +4 -1
  46. package/dist/runtime/app/components/CMSEditor.vue +439 -0
  47. package/dist/runtime/app/components/CMSEditorImageNode.vue +90 -0
  48. package/dist/runtime/app/components/CMSEditorLinkPopover.vue +120 -0
  49. package/dist/runtime/app/components/QDropZone.vue +327 -0
  50. package/dist/runtime/app/components/QImageCropper.vue +658 -0
  51. package/dist/runtime/app/components/QImageStudio.vue +300 -0
  52. package/dist/runtime/app/components/QImg.vue +7 -4
  53. package/dist/runtime/app/composables/analytics.d.ts +8 -8
  54. package/dist/runtime/app/composables/api-tokens.d.ts +5 -5
  55. package/dist/runtime/app/composables/auth.d.ts +23 -19
  56. package/dist/runtime/app/composables/chat.d.ts +7 -6
  57. package/dist/runtime/app/composables/cms-preview.d.ts +7 -8
  58. package/dist/runtime/app/composables/cms.d.ts +6 -6
  59. package/dist/runtime/app/composables/comments.d.ts +5 -5
  60. package/dist/runtime/app/composables/comments.mjs +7 -4
  61. package/dist/runtime/app/composables/console.d.ts +6 -14
  62. package/dist/runtime/app/composables/docs-version.d.ts +8 -8
  63. package/dist/runtime/app/composables/impersonation.d.ts +5 -5
  64. package/dist/runtime/app/composables/organization.d.ts +5 -5
  65. package/dist/runtime/app/composables/passkey.d.ts +5 -5
  66. package/dist/runtime/app/composables/passwordless.d.ts +5 -5
  67. package/dist/runtime/app/composables/payments.d.ts +5 -5
  68. package/dist/runtime/app/composables/rbac.d.ts +5 -5
  69. package/dist/runtime/app/composables/site.d.ts +2 -2
  70. package/dist/runtime/app/composables/sse.d.ts +20 -33
  71. package/dist/runtime/app/composables/sse.mjs +6 -3
  72. package/dist/runtime/app/composables/storage.d.ts +6 -8
  73. package/dist/runtime/app/composables/store.d.ts +52 -36
  74. package/dist/runtime/app/composables/store.mjs +70 -11
  75. package/dist/runtime/app/composables/studio.d.ts +59 -0
  76. package/dist/runtime/app/composables/studio.mjs +129 -0
  77. package/dist/runtime/app/composables/tenant.d.ts +7 -7
  78. package/dist/runtime/app/composables/turnstile.d.ts +5 -5
  79. package/dist/runtime/app/composables/two-factor.d.ts +5 -5
  80. package/dist/runtime/app/pages/devtools/notifications.vue +1 -6
  81. package/dist/runtime/app/plugins/pwa.mjs +1 -3
  82. package/dist/runtime/app/utils/cms-editor.d.ts +25 -0
  83. package/dist/runtime/app/utils/cms-editor.mjs +43 -0
  84. package/dist/runtime/auth.d.ts +9 -9
  85. package/dist/runtime/blob.d.ts +1 -3
  86. package/dist/runtime/blob.mjs +3 -1
  87. package/dist/runtime/cache.d.ts +8 -6
  88. package/dist/runtime/cache.mjs +8 -11
  89. package/dist/runtime/db.d.ts +4 -3
  90. package/dist/runtime/drizzle.d.ts +2 -1
  91. package/dist/runtime/drizzle.mjs +2 -2
  92. package/dist/runtime/queue.d.ts +1 -0
  93. package/dist/runtime/replica.d.ts +6 -10
  94. package/dist/runtime/replica.mjs +3 -1
  95. package/dist/runtime/schema-mysql.d.ts +16 -32
  96. package/dist/runtime/schema-pg.d.ts +15 -31
  97. package/dist/runtime/schema-shared.d.ts +20 -17
  98. package/dist/runtime/schema.d.ts +21 -33
  99. package/dist/runtime/server/durable-objects/agent.mjs +4 -1
  100. package/dist/runtime/server/durable-objects/room.d.ts +4 -6
  101. package/dist/runtime/server/durable-objects/room.mjs +18 -8
  102. package/dist/runtime/server/plugins/comments.d.ts +2 -3
  103. package/dist/runtime/server/plugins/email-inbound.d.ts +1 -3
  104. package/dist/runtime/server/plugins/store.d.ts +2 -3
  105. package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.d.ts +2 -2
  106. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.mjs +10 -2
  107. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.d.ts +2 -2
  108. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.mjs +10 -2
  109. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.d.ts +2 -2
  110. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.mjs +7 -1
  111. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.d.ts +2 -2
  112. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.mjs +5 -1
  113. package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.d.ts +1 -3
  114. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.d.ts +2 -2
  115. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.mjs +15 -4
  116. package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.d.ts +2 -2
  117. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.mjs +13 -4
  118. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.mjs +1 -1
  119. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.d.ts +3 -3
  120. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.mjs +22 -6
  121. package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.d.ts +2 -2
  122. package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.d.ts +6 -5
  123. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.d.ts +1 -3
  124. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.mjs +14 -2
  125. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.d.ts +1 -3
  126. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.mjs +7 -1
  127. package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.d.ts +1 -3
  128. package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.d.ts +2 -2
  129. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.d.ts +2 -2
  130. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.mjs +5 -1
  131. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.d.ts +6 -5
  132. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.mjs +1 -3
  133. package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +2 -2
  134. package/dist/runtime/server/routes/__qarpeo/manifest.get.d.ts +2 -2
  135. package/dist/runtime/server/routes/__qarpeo/og.get.d.ts +2 -2
  136. package/dist/runtime/server/routes/__qarpeo/rbac/me.get.d.ts +2 -2
  137. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.d.ts +2 -2
  138. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.mjs +5 -1
  139. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.d.ts +2 -2
  140. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.mjs +1 -5
  141. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.d.ts +2 -2
  142. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.mjs +5 -1
  143. package/dist/runtime/server/routes/__qarpeo/rbac/users.post.d.ts +2 -2
  144. package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +1 -6
  145. package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +1 -6
  146. package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +1 -6
  147. package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +5 -1
  148. package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +7 -1
  149. package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +1 -1
  150. package/dist/runtime/server/routes/auth/otp/send.post.mjs +1 -1
  151. package/dist/runtime/server/routes/cms/search.get.mjs +2 -6
  152. package/dist/runtime/server/routes/comments/[id]/report.post.mjs +1 -4
  153. package/dist/runtime/server/routes/comments/[id].patch.mjs +1 -4
  154. package/dist/runtime/server/routes/comments/batch.post.mjs +1 -3
  155. package/dist/runtime/server/routes/comments/index.post.mjs +1 -5
  156. package/dist/runtime/server/routes/fate.mjs +1 -1
  157. package/dist/runtime/server/routes/mail/webhooks.post.mjs +1 -1
  158. package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
  159. package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +5 -6
  160. package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +1 -1
  161. package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +1 -1
  162. package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +1 -1
  163. package/dist/runtime/server/routes/store/currencies.get.mjs +1 -4
  164. package/dist/runtime/server/routes/store/orders/[id].get.mjs +1 -1
  165. package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +13 -4
  166. package/dist/runtime/server/routes/store/orders/index.get.mjs +1 -1
  167. package/dist/runtime/server/routes/store/products/index.get.mjs +2 -0
  168. package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +2 -1
  169. package/dist/runtime/server/routes/store/tax/calculate.post.mjs +12 -3
  170. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +4 -1
  171. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +4 -1
  172. package/dist/runtime/server/utils/ai.d.ts +38 -35
  173. package/dist/runtime/server/utils/ai.mjs +7 -11
  174. package/dist/runtime/server/utils/analytics-query.d.ts +4 -4
  175. package/dist/runtime/server/utils/auth.d.ts +25 -25
  176. package/dist/runtime/server/utils/auth.mjs +22 -8
  177. package/dist/runtime/server/utils/bots.d.ts +7 -7
  178. package/dist/runtime/server/utils/browser-utils.d.ts +26 -27
  179. package/dist/runtime/server/utils/cache.d.ts +20 -20
  180. package/dist/runtime/server/utils/cms/collections.mjs +1 -6
  181. package/dist/runtime/server/utils/cms/common.mjs +1 -0
  182. package/dist/runtime/server/utils/cms/markdown.d.ts +2 -2
  183. package/dist/runtime/server/utils/cms/markdown.mjs +5 -5
  184. package/dist/runtime/server/utils/cms/mutations.mjs +8 -23
  185. package/dist/runtime/server/utils/cms/navigation.mjs +4 -4
  186. package/dist/runtime/server/utils/cms/path.d.ts +1 -0
  187. package/dist/runtime/server/utils/cms/path.mjs +8 -2
  188. package/dist/runtime/server/utils/cms/references.mjs +1 -7
  189. package/dist/runtime/server/utils/cms/search.d.ts +2 -2
  190. package/dist/runtime/server/utils/cms/sync.mjs +4 -2
  191. package/dist/runtime/server/utils/cms/taxonomy.d.ts +2 -2
  192. package/dist/runtime/server/utils/cms.d.ts +1 -1
  193. package/dist/runtime/server/utils/cms.mjs +1 -5
  194. package/dist/runtime/server/utils/comments-filter.d.ts +9 -7
  195. package/dist/runtime/server/utils/comments.d.ts +68 -55
  196. package/dist/runtime/server/utils/comments.mjs +21 -9
  197. package/dist/runtime/server/utils/config.d.ts +2 -2
  198. package/dist/runtime/server/utils/console.d.ts +3 -5
  199. package/dist/runtime/server/utils/context.d.ts +10 -10
  200. package/dist/runtime/server/utils/crypto.d.ts +20 -20
  201. package/dist/runtime/server/utils/domains.mjs +3 -1
  202. package/dist/runtime/server/utils/drizzle.d.ts +24 -25
  203. package/dist/runtime/server/utils/drizzle.mjs +17 -17
  204. package/dist/runtime/server/utils/durable-object.d.ts +27 -25
  205. package/dist/runtime/server/utils/durable-object.mjs +3 -10
  206. package/dist/runtime/server/utils/email-inbound.d.ts +10 -10
  207. package/dist/runtime/server/utils/impersonation.d.ts +18 -18
  208. package/dist/runtime/server/utils/legacy-hash.d.ts +23 -27
  209. package/dist/runtime/server/utils/lock.d.ts +20 -23
  210. package/dist/runtime/server/utils/mail.d.ts +19 -19
  211. package/dist/runtime/server/utils/mail.mjs +4 -2
  212. package/dist/runtime/server/utils/mcp.d.ts +20 -20
  213. package/dist/runtime/server/utils/mcp.mjs +22 -38
  214. package/dist/runtime/server/utils/notifications.d.ts +49 -38
  215. package/dist/runtime/server/utils/oauth.d.ts +3 -9
  216. package/dist/runtime/server/utils/organization.d.ts +28 -28
  217. package/dist/runtime/server/utils/organization.mjs +15 -5
  218. package/dist/runtime/server/utils/passwordless.d.ts +24 -24
  219. package/dist/runtime/server/utils/payments/checkout.d.ts +12 -12
  220. package/dist/runtime/server/utils/payments/checkout.mjs +1 -3
  221. package/dist/runtime/server/utils/payments/common.d.ts +3 -3
  222. package/dist/runtime/server/utils/payments/paddle.d.ts +4 -1
  223. package/dist/runtime/server/utils/payments/polar.d.ts +4 -1
  224. package/dist/runtime/server/utils/payments/stripe.mjs +5 -7
  225. package/dist/runtime/server/utils/payments/subscriptions.d.ts +14 -14
  226. package/dist/runtime/server/utils/payments/subscriptions.mjs +2 -6
  227. package/dist/runtime/server/utils/payments/usage.mjs +1 -3
  228. package/dist/runtime/server/utils/payments/webhooks.mjs +2 -2
  229. package/dist/runtime/server/utils/queue.d.ts +54 -58
  230. package/dist/runtime/server/utils/queue.mjs +2 -6
  231. package/dist/runtime/server/utils/rag.d.ts +23 -23
  232. package/dist/runtime/server/utils/rag.mjs +10 -5
  233. package/dist/runtime/server/utils/ratelimit.d.ts +21 -18
  234. package/dist/runtime/server/utils/rbac.d.ts +13 -15
  235. package/dist/runtime/server/utils/rbac.mjs +44 -10
  236. package/dist/runtime/server/utils/realtime.d.ts +53 -52
  237. package/dist/runtime/server/utils/role-env.d.ts +5 -4
  238. package/dist/runtime/server/utils/scheduled-task.d.ts +14 -15
  239. package/dist/runtime/server/utils/session.d.ts +40 -40
  240. package/dist/runtime/server/utils/sse.d.ts +23 -33
  241. package/dist/runtime/server/utils/sse.mjs +5 -14
  242. package/dist/runtime/server/utils/sso.mjs +3 -1
  243. package/dist/runtime/server/utils/storage.d.ts +20 -22
  244. package/dist/runtime/server/utils/storage.mjs +2 -2
  245. package/dist/runtime/server/utils/store/cart.d.ts +5 -3
  246. package/dist/runtime/server/utils/store/cart.mjs +14 -10
  247. package/dist/runtime/server/utils/store/checkout.mjs +4 -1
  248. package/dist/runtime/server/utils/store/common.d.ts +1 -1
  249. package/dist/runtime/server/utils/store/common.mjs +36 -12
  250. package/dist/runtime/server/utils/store/inventory.mjs +3 -1
  251. package/dist/runtime/server/utils/store/orders.mjs +32 -24
  252. package/dist/runtime/server/utils/store/vendor.d.ts +11 -1
  253. package/dist/runtime/server/utils/store/vendor.mjs +47 -0
  254. package/dist/runtime/server/utils/store-localization.d.ts +9 -27
  255. package/dist/runtime/server/utils/store-localization.mjs +3 -3
  256. package/dist/runtime/server/utils/table-names.d.ts +15 -15
  257. package/dist/runtime/server/utils/table-names.mjs +1 -1
  258. package/dist/runtime/server/utils/tenant.d.ts +12 -12
  259. package/dist/runtime/server/utils/tenant.mjs +7 -4
  260. package/dist/runtime/server/utils/totp.d.ts +18 -18
  261. package/dist/runtime/server/utils/tracker.d.ts +5 -5
  262. package/dist/runtime/server/utils/turnstile.d.ts +9 -9
  263. package/dist/runtime/server/utils/urn.d.ts +5 -8
  264. package/dist/runtime/server/utils/workflows.d.ts +30 -31
  265. package/dist/runtime/server/utils/workflows.mjs +2 -4
  266. package/dist/runtime/server.d.ts +2 -2
  267. package/dist/runtime/service.d.ts +10 -10
  268. package/dist/runtime/test-utils.d.ts +10 -10
  269. package/dist/runtime/test-utils.mjs +9 -2
  270. package/dist/runtime/types/ai.d.ts +14 -14
  271. package/dist/runtime/types/d1.d.ts +6 -11
  272. package/dist/runtime/types/durable-object.d.ts +4 -8
  273. package/dist/runtime/types/email.d.ts +3 -9
  274. package/dist/runtime/types/index.d.ts +15 -21
  275. package/dist/runtime/types/r2.d.ts +5 -5
  276. package/dist/runtime/types/store.d.ts +7 -0
  277. package/dist/runtime/types/workflows.d.ts +5 -6
  278. package/dist/runtime/workflows.d.ts +1 -3
  279. package/dist/types/ai.d.ts +10 -17
  280. package/dist/types/auth.d.ts +5 -3
  281. package/dist/types/cache.d.ts +7 -7
  282. package/dist/types/cms.d.ts +30 -5
  283. package/dist/types/comments.d.ts +23 -21
  284. package/dist/types/console.d.ts +1 -3
  285. package/dist/types/db.d.ts +7 -7
  286. package/dist/types/index.d.ts +1 -0
  287. package/dist/types/options.d.ts +36 -24
  288. package/dist/types/site.d.ts +8 -2
  289. package/dist/types/storage.d.ts +2 -1
  290. package/dist/types/store-options.d.ts +31 -26
  291. package/dist/types/studio.d.ts +79 -0
  292. package/dist/utils/bots.d.ts +7 -3
  293. package/dist/utils/cms-table-names.d.ts +1 -1
  294. package/dist/utils/drizzle.d.ts +13 -14
  295. package/dist/utils/email-inbound.d.ts +4 -4
  296. package/dist/utils/features.d.ts +19 -5
  297. package/dist/utils/mcp.d.ts +1 -0
  298. package/dist/utils/migration-lock.d.ts +15 -29
  299. package/dist/utils/overridable-routes.d.ts +12 -0
  300. package/dist/utils/pkg.d.ts +6 -7
  301. package/dist/utils/schema-diff.d.ts +7 -11
  302. package/dist/utils/store-schema.d.ts +4 -6
  303. package/dist/utils/tools.d.ts +3 -3
  304. package/package.json +55 -5
@@ -6,14 +6,16 @@ export declare function getStoreCart(cartIdOrToken: string, event?: RequestEvent
6
6
  * Resolves the active cart for the current request event and verifies ownership.
7
7
  *
8
8
  * Enforces ownership:
9
+ *
9
10
  * 1. Resolves caller's token from:
11
+ *
10
12
  * - `options.sessionToken` (if explicitly passed in body)
11
13
  * - `x-cart-session` request header
12
14
  * - `qarpeo_cart_session` cookie
13
15
  * - Authenticated user ID via `getAuthContext(event)`
14
- * 2. If caller already has an established cart or session, and an `explicitCartId`
15
- * is provided, verifies that `explicitCartId === cart.id` or that the cart belongs
16
- * to the same authenticated user or session token.
16
+ * 2. If caller already has an established cart or session, and an `explicitCartId` is provided,
17
+ * verifies that `explicitCartId === cart.id` or that the cart belongs to the same authenticated
18
+ * user or session token.
17
19
  * 3. Throws 403 Forbidden if a caller attempts to access, mutate, or checkout a foreign cart.
18
20
  * 4. Persists the cookie on `event` so the browser maintains the verified session.
19
21
  */
@@ -1,9 +1,4 @@
1
- import {
2
- createError,
3
- getCookie,
4
- setCookie,
5
- getRequestHeader
6
- } from "nuxt/server";
1
+ import { createError, getCookie, setCookie, getRequestHeader } from "nuxt/server";
7
2
  import { getAuthContext } from "../context.mjs";
8
3
  import { nanoid } from "../crypto.mjs";
9
4
  import { detectStoreCountry, calculateStoreTax } from "../store-localization.mjs";
@@ -41,9 +36,13 @@ export async function getOrCreateStoreCart(sessionToken, event) {
41
36
  let cartRow = await db.prepare(`SELECT * FROM ${cart} WHERE session_token = ?`).bind(token).first();
42
37
  if (!cartRow && userId) {
43
38
  if (tenantId) {
44
- cartRow = await db.prepare(`SELECT * FROM ${cart} WHERE user_id = ? AND tenant_id = ? AND expires_at > ? ORDER BY updated_at DESC LIMIT 1`).bind(userId, tenantId, now).first();
39
+ cartRow = await db.prepare(
40
+ `SELECT * FROM ${cart} WHERE user_id = ? AND tenant_id = ? AND expires_at > ? ORDER BY updated_at DESC LIMIT 1`
41
+ ).bind(userId, tenantId, now).first();
45
42
  } else {
46
- cartRow = await db.prepare(`SELECT * FROM ${cart} WHERE user_id = ? AND tenant_id IS NULL AND expires_at > ? ORDER BY updated_at DESC LIMIT 1`).bind(userId, now).first();
43
+ cartRow = await db.prepare(
44
+ `SELECT * FROM ${cart} WHERE user_id = ? AND tenant_id IS NULL AND expires_at > ? ORDER BY updated_at DESC LIMIT 1`
45
+ ).bind(userId, now).first();
47
46
  }
48
47
  }
49
48
  if (!cartRow) {
@@ -170,7 +169,10 @@ export async function addToStoreCart(cartId, item, event) {
170
169
  }
171
170
  const existing = await db.prepare(`SELECT * FROM ${cartItem} WHERE cart_id = ? AND variant_id = ?`).bind(cartId, item.variantId).first();
172
171
  if (existing) {
173
- const newQty = Math.min(999, Math.max(1, Math.trunc(Number(existing.quantity) || 0) + safeQuantity));
172
+ const newQty = Math.min(
173
+ 999,
174
+ Math.max(1, Math.trunc(Number(existing.quantity) || 0) + safeQuantity)
175
+ );
174
176
  await db.prepare(`UPDATE ${cartItem} SET quantity = ?, updated_at = ? WHERE id = ?`).bind(newQty, now, existing.id).run();
175
177
  await db.prepare(`UPDATE ${cart} SET updated_at = ? WHERE id = ?`).bind(now, cartId).run();
176
178
  const updated = await db.prepare(`SELECT * FROM ${cartItem} WHERE id = ?`).bind(existing.id).first();
@@ -318,7 +320,9 @@ export async function mergeGuestCartOnLogin(guestSessionToken, userId, event) {
318
320
  if (!guestCart) {
319
321
  return getOrCreateStoreCart(void 0, event);
320
322
  }
321
- const userCart = await db.prepare(`SELECT * FROM ${cart} WHERE user_id = ? AND expires_at > ? ORDER BY updated_at DESC LIMIT 1`).bind(userId, now).first();
323
+ const userCart = await db.prepare(
324
+ `SELECT * FROM ${cart} WHERE user_id = ? AND expires_at > ? ORDER BY updated_at DESC LIMIT 1`
325
+ ).bind(userId, now).first();
322
326
  if (!userCart) {
323
327
  await db.prepare(`UPDATE ${cart} SET user_id = ?, updated_at = ? WHERE id = ?`).bind(userId, now, guestCart.id).run();
324
328
  return await getStoreCart(guestCart.id, event);
@@ -44,7 +44,10 @@ export async function createStoreCheckoutSession(cartId, opts = {}, event) {
44
44
  order.items.forEach((item, index) => {
45
45
  params.set(`line_items[${index}][price_data][currency]`, order.currency.toLowerCase());
46
46
  params.set(`line_items[${index}][price_data][unit_amount]`, String(item.unitPrice));
47
- params.set(`line_items[${index}][price_data][product_data][name]`, item.title || "Store Item");
47
+ params.set(
48
+ `line_items[${index}][price_data][product_data][name]`,
49
+ item.title || "Store Item"
50
+ );
48
51
  params.set(`line_items[${index}][quantity]`, String(item.quantity));
49
52
  });
50
53
  if (order.shippingTotal && order.shippingTotal > 0) {
@@ -1,6 +1,6 @@
1
1
  import type { RequestEvent } from "nuxt/server";
2
- import type { D1Database } from "../../../types/d1";
3
2
  import type { StoreOptions } from "../../../../types";
3
+ import type { D1Database } from "../../../types/d1";
4
4
  import type { StoreProduct, StoreProductVariant, StoreInventory, StoreCategory, StoreCart, StoreCartItem, StoreCustomerAddress, StoreOrder, StoreOrderItem, StoreDiscount } from "../../../types/store";
5
5
  export declare function storeProductTbl(event?: RequestEvent): string;
6
6
  export declare function storeVariantTbl(event?: RequestEvent): string;
@@ -280,7 +280,9 @@ export async function ensureStoreTables(event) {
280
280
  `CREATE UNIQUE INDEX IF NOT EXISTS ${resolveIndexName(p, "unique_slug")} ON ${p}(COALESCE(tenant_id, ''), slug)`
281
281
  ),
282
282
  db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(p, "status")} ON ${p}(status)`),
283
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(p, "category")} ON ${p}(category_id)`),
283
+ db.prepare(
284
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(p, "category")} ON ${p}(category_id)`
285
+ ),
284
286
  db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(p, "tenant")} ON ${p}(tenant_id)`),
285
287
  db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(p, "vendor")} ON ${p}(vendor_id)`),
286
288
  // 2. Product Variants
@@ -297,7 +299,9 @@ export async function ensureStoreTables(event) {
297
299
  created_at INTEGER NOT NULL,
298
300
  updated_at INTEGER NOT NULL
299
301
  )`),
300
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(v, "product")} ON ${v}(product_id)`),
302
+ db.prepare(
303
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(v, "product")} ON ${v}(product_id)`
304
+ ),
301
305
  db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(v, "sku")} ON ${v}(sku)`),
302
306
  // 3. Inventory
303
307
  db.prepare(`CREATE TABLE IF NOT EXISTS ${inv} (
@@ -314,7 +318,9 @@ export async function ensureStoreTables(event) {
314
318
  db.prepare(
315
319
  `CREATE UNIQUE INDEX IF NOT EXISTS ${resolveIndexName(inv, "variant")} ON ${inv}(variant_id)`
316
320
  ),
317
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(inv, "product")} ON ${inv}(product_id)`),
321
+ db.prepare(
322
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(inv, "product")} ON ${inv}(product_id)`
323
+ ),
318
324
  // 4. Categories
319
325
  db.prepare(`CREATE TABLE IF NOT EXISTS ${c} (
320
326
  id TEXT PRIMARY KEY,
@@ -350,8 +356,12 @@ export async function ensureStoreTables(event) {
350
356
  db.prepare(
351
357
  `CREATE UNIQUE INDEX IF NOT EXISTS ${resolveIndexName(cart, "session")} ON ${cart}(session_token)`
352
358
  ),
353
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(cart, "user")} ON ${cart}(user_id)`),
354
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(cart, "expires")} ON ${cart}(expires_at)`),
359
+ db.prepare(
360
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(cart, "user")} ON ${cart}(user_id)`
361
+ ),
362
+ db.prepare(
363
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(cart, "expires")} ON ${cart}(expires_at)`
364
+ ),
355
365
  // 6. Cart Items
356
366
  db.prepare(`CREATE TABLE IF NOT EXISTS ${cartItem} (
357
367
  id TEXT PRIMARY KEY,
@@ -363,7 +373,9 @@ export async function ensureStoreTables(event) {
363
373
  created_at INTEGER NOT NULL,
364
374
  updated_at INTEGER NOT NULL
365
375
  )`),
366
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(cartItem, "cart")} ON ${cartItem}(cart_id)`),
376
+ db.prepare(
377
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(cartItem, "cart")} ON ${cartItem}(cart_id)`
378
+ ),
367
379
  db.prepare(
368
380
  `CREATE INDEX IF NOT EXISTS ${resolveIndexName(cartItem, "variant")} ON ${cartItem}(variant_id)`
369
381
  ),
@@ -399,9 +411,13 @@ export async function ensureStoreTables(event) {
399
411
  `CREATE UNIQUE INDEX IF NOT EXISTS ${resolveIndexName(ord, "unique_number")} ON ${ord}(COALESCE(tenant_id, ''), order_number)`
400
412
  ),
401
413
  db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(ord, "user")} ON ${ord}(user_id)`),
402
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(ord, "email")} ON ${ord}(customer_email)`),
414
+ db.prepare(
415
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(ord, "email")} ON ${ord}(customer_email)`
416
+ ),
403
417
  db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(ord, "status")} ON ${ord}(status)`),
404
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(ord, "created")} ON ${ord}(created_at)`),
418
+ db.prepare(
419
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(ord, "created")} ON ${ord}(created_at)`
420
+ ),
405
421
  // 8. Order Items
406
422
  db.prepare(`CREATE TABLE IF NOT EXISTS ${ordItem} (
407
423
  id TEXT PRIMARY KEY,
@@ -419,11 +435,15 @@ export async function ensureStoreTables(event) {
419
435
  metadata_json TEXT NOT NULL DEFAULT '{}',
420
436
  created_at INTEGER NOT NULL
421
437
  )`),
422
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(ordItem, "order")} ON ${ordItem}(order_id)`),
438
+ db.prepare(
439
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(ordItem, "order")} ON ${ordItem}(order_id)`
440
+ ),
423
441
  db.prepare(
424
442
  `CREATE INDEX IF NOT EXISTS ${resolveIndexName(ordItem, "variant")} ON ${ordItem}(variant_id)`
425
443
  ),
426
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(ordItem, "vendor")} ON ${ordItem}(vendor_id)`),
444
+ db.prepare(
445
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(ordItem, "vendor")} ON ${ordItem}(vendor_id)`
446
+ ),
427
447
  // 9. Discounts
428
448
  db.prepare(`CREATE TABLE IF NOT EXISTS ${disc} (
429
449
  id TEXT PRIMARY KEY,
@@ -444,7 +464,9 @@ export async function ensureStoreTables(event) {
444
464
  db.prepare(
445
465
  `CREATE UNIQUE INDEX IF NOT EXISTS ${resolveIndexName(disc, "unique_code")} ON ${disc}(COALESCE(tenant_id, ''), code)`
446
466
  ),
447
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(disc, "active")} ON ${disc}(is_active)`),
467
+ db.prepare(
468
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(disc, "active")} ON ${disc}(is_active)`
469
+ ),
448
470
  // 10. Customer Addresses
449
471
  db.prepare(`CREATE TABLE IF NOT EXISTS ${addr} (
450
472
  id TEXT PRIMARY KEY,
@@ -463,7 +485,9 @@ export async function ensureStoreTables(event) {
463
485
  created_at INTEGER NOT NULL,
464
486
  updated_at INTEGER NOT NULL
465
487
  )`),
466
- db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(addr, "user")} ON ${addr}(user_id)`),
488
+ db.prepare(
489
+ `CREATE INDEX IF NOT EXISTS ${resolveIndexName(addr, "user")} ON ${addr}(user_id)`
490
+ ),
467
491
  db.prepare(`CREATE INDEX IF NOT EXISTS ${resolveIndexName(addr, "type")} ON ${addr}(type)`)
468
492
  ]).then(async () => {
469
493
  await db.batch([
@@ -175,7 +175,9 @@ export async function releaseStoreOrderStock(orderId, event) {
175
175
  const ordItem = storeOrderItemTbl(event);
176
176
  const inv = storeInventoryTbl(event);
177
177
  const now = Date.now();
178
- const items = await db.prepare(`SELECT variant_id, quantity FROM ${ordItem} WHERE order_id = ? AND variant_id IS NOT NULL`).bind(orderId).all();
178
+ const items = await db.prepare(
179
+ `SELECT variant_id, quantity FROM ${ordItem} WHERE order_id = ? AND variant_id IS NOT NULL`
180
+ ).bind(orderId).all();
179
181
  const updates = (items.results ?? []).filter((item) => item.variant_id).map(
180
182
  (item) => db.prepare(
181
183
  `UPDATE ${inv}
@@ -2,7 +2,10 @@ import { createError } from "nuxt/server";
2
2
  import { getAuthContext } from "../context.mjs";
3
3
  import { nanoid, signHmacSha256 } from "../crypto.mjs";
4
4
  import { getPaymentsConfig } from "../payments/index.mjs";
5
- import { registerPaymentWebhookListener } from "../payments/common.mjs";
5
+ import {
6
+ registerPaymentWebhookListener
7
+ } from "../payments/common.mjs";
8
+ import { getStoreCart, clearStoreCart, calculateStoreCartTotals } from "./cart.mjs";
6
9
  import {
7
10
  getD1,
8
11
  getStoreConfig,
@@ -16,7 +19,6 @@ import {
16
19
  rowToOrder,
17
20
  rowToAddress
18
21
  } from "./common.mjs";
19
- import { getStoreCart, clearStoreCart, calculateStoreCartTotals } from "./cart.mjs";
20
22
  import { commitStoreStock, releaseStoreOrderStock, reserveStoreStock } from "./inventory.mjs";
21
23
  function generateOrderNumber() {
22
24
  const datePart = (/* @__PURE__ */ new Date()).toISOString().slice(2, 10).replace(/-/g, "");
@@ -530,24 +532,30 @@ export async function reconcileStoreOrderFromWebhook({
530
532
  const orderId = obj.metadata.orderId;
531
533
  if (orderId) {
532
534
  const paymentIntentId = obj.payment_intent || obj.id;
533
- await updateStoreOrderStatus(
534
- orderId,
535
- "paid",
536
- { paymentProvider: "stripe", paymentIntentId, event }
537
- ).catch((err) => {
538
- console.warn("[qarpeo:store] Webhook failed to update order to paid:", err?.message || err);
535
+ await updateStoreOrderStatus(orderId, "paid", {
536
+ paymentProvider: "stripe",
537
+ paymentIntentId,
538
+ event
539
+ }).catch((err) => {
540
+ console.warn(
541
+ "[qarpeo:store] Webhook failed to update order to paid:",
542
+ err?.message || err
543
+ );
539
544
  });
540
545
  }
541
546
  }
542
547
  } else if (type === "payment_intent.succeeded") {
543
548
  const orderId = obj.metadata?.orderId;
544
549
  if (orderId && (obj.metadata?.type === "store_order" || obj.metadata?.type === "store")) {
545
- await updateStoreOrderStatus(
546
- orderId,
547
- "paid",
548
- { paymentProvider: "stripe", paymentIntentId: obj.id, event }
549
- ).catch((err) => {
550
- console.warn("[qarpeo:store] payment_intent.succeeded failed to update order:", err?.message || err);
550
+ await updateStoreOrderStatus(orderId, "paid", {
551
+ paymentProvider: "stripe",
552
+ paymentIntentId: obj.id,
553
+ event
554
+ }).catch((err) => {
555
+ console.warn(
556
+ "[qarpeo:store] payment_intent.succeeded failed to update order:",
557
+ err?.message || err
558
+ );
551
559
  });
552
560
  }
553
561
  } else if (type === "payment_intent.payment_failed") {
@@ -567,22 +575,22 @@ export async function reconcileStoreOrderFromWebhook({
567
575
  const customData = payload?.meta?.custom_data || {};
568
576
  const orderId = customData.orderId || customData.order_id;
569
577
  if (orderId && (customData.type === "store_order" || customData.type === "store")) {
570
- await updateStoreOrderStatus(
571
- orderId,
572
- "paid",
573
- { paymentProvider: "lemonsqueezy", paymentIntentId: String(data?.id), event }
574
- ).catch(() => {
578
+ await updateStoreOrderStatus(orderId, "paid", {
579
+ paymentProvider: "lemonsqueezy",
580
+ paymentIntentId: String(data?.id),
581
+ event
582
+ }).catch(() => {
575
583
  });
576
584
  }
577
585
  } else if (provider === "polar" && (type === "order.created" || type === "payment.succeeded")) {
578
586
  const meta = data?.metadata || {};
579
587
  const orderId = meta.orderId || meta.order_id;
580
588
  if (orderId && (meta.type === "store_order" || meta.type === "store")) {
581
- await updateStoreOrderStatus(
582
- orderId,
583
- "paid",
584
- { paymentProvider: "polar", paymentIntentId: String(data?.id), event }
585
- ).catch(() => {
589
+ await updateStoreOrderStatus(orderId, "paid", {
590
+ paymentProvider: "polar",
591
+ paymentIntentId: String(data?.id),
592
+ event
593
+ }).catch(() => {
586
594
  });
587
595
  }
588
596
  }
@@ -1,5 +1,5 @@
1
1
  import type { RequestEvent } from "nuxt/server";
2
- import type { StoreProduct, StoreOrderItem, StoreQueryProductsOptions, StoreVendorMetrics } from "../../../types/store";
2
+ import type { StoreProduct, StoreOrderItem, StoreQueryProductsOptions, StoreVendorMetrics, StoreVendorSummary } from "../../../types/store";
3
3
  export declare function isMultiVendorStore(event?: RequestEvent): boolean;
4
4
  export declare function getStoreVendorMetrics(vendorId: string, opts?: {
5
5
  tenantId?: string;
@@ -16,3 +16,13 @@ export declare function queryVendorOrderItems(vendorId: string, opts?: {
16
16
  items: StoreOrderItem[];
17
17
  total: number;
18
18
  }>;
19
+ /** List active vendors aggregated from published products. */
20
+ export declare function queryStoreVendors(opts?: {
21
+ tenantId?: string;
22
+ limit?: number;
23
+ offset?: number;
24
+ }, event?: RequestEvent): Promise<StoreVendorSummary[]>;
25
+ /** Fetch a single vendor summary by vendor ID. Returns null if no active products exist. */
26
+ export declare function getStoreVendor(vendorId: string, opts?: {
27
+ tenantId?: string;
28
+ }, event?: RequestEvent): Promise<StoreVendorSummary | null>;
@@ -66,3 +66,50 @@ export async function queryVendorOrderItems(vendorId, opts = {}, event) {
66
66
  ).bind(...params, limit, offset).all();
67
67
  return { items: (rows.results ?? []).map(rowToOrderItem), total };
68
68
  }
69
+ export async function queryStoreVendors(opts = {}, event) {
70
+ const db = getD1(event);
71
+ const p = storeProductTbl(event);
72
+ const whereClauses = ["status = 'active'", "vendor_id IS NOT NULL"];
73
+ const params = [];
74
+ if (opts.tenantId !== void 0) {
75
+ whereClauses.push("tenant_id = ?");
76
+ params.push(opts.tenantId);
77
+ }
78
+ const limit = Math.min(opts.limit ?? 50, 100);
79
+ const offset = opts.offset ?? 0;
80
+ const result = await db.prepare(
81
+ `SELECT vendor_id as id, COUNT(*) as product_count
82
+ FROM ${p}
83
+ WHERE ${whereClauses.join(" AND ")}
84
+ GROUP BY vendor_id
85
+ ORDER BY product_count DESC
86
+ LIMIT ? OFFSET ?`
87
+ ).bind(...params, limit, offset).all();
88
+ return (result.results ?? []).map((row) => ({
89
+ id: row.id,
90
+ name: row.id,
91
+ productCount: Number(row.product_count),
92
+ logoUrl: null,
93
+ description: null
94
+ }));
95
+ }
96
+ export async function getStoreVendor(vendorId, opts = {}, event) {
97
+ const db = getD1(event);
98
+ const p = storeProductTbl(event);
99
+ const whereClauses = ["status = 'active'", "vendor_id = ?"];
100
+ const params = [vendorId];
101
+ if (opts.tenantId !== void 0) {
102
+ whereClauses.push("tenant_id = ?");
103
+ params.push(opts.tenantId);
104
+ }
105
+ const row = await db.prepare(`SELECT COUNT(*) as product_count FROM ${p} WHERE ${whereClauses.join(" AND ")}`).bind(...params).first();
106
+ const count = Number(row?.product_count ?? 0);
107
+ if (count === 0) return null;
108
+ return {
109
+ id: vendorId,
110
+ name: vendorId,
111
+ productCount: count,
112
+ logoUrl: null,
113
+ description: null
114
+ };
115
+ }
@@ -3,49 +3,31 @@ import type { StoreCurrency, StoreTaxCalculationInput, StoreTaxResult, StoreTaxO
3
3
  export declare const DEFAULT_STORE_RATES: Record<string, number>;
4
4
  export declare const SUPPORTED_STORE_CURRENCIES: Record<string, Omit<StoreCurrency, "rate">>;
5
5
  export declare const COUNTRY_TO_CURRENCY_MAP: Record<string, string>;
6
- /**
7
- * Detects visitor ISO 3166-1 alpha-2 country code using Cloudflare headers.
8
- */
6
+ /** Detects visitor ISO 3166-1 alpha-2 country code using Cloudflare headers. */
9
7
  export declare function detectStoreCountry(event?: RequestEvent): string;
10
- /**
11
- * Detects visitor preferred currency based on cookie or Cloudflare geo-location.
12
- */
8
+ /** Detects visitor preferred currency based on cookie or Cloudflare geo-location. */
13
9
  export declare function detectStoreCurrency(event?: RequestEvent, options?: StoreLocalizationOptions): string;
14
- /**
15
- * Converts a price in cents from one currency to another using exchange rates.
16
- */
10
+ /** Converts a price in cents from one currency to another using exchange rates. */
17
11
  export declare function convertStoreCurrency(amountInCents: number, fromCurrency: string, toCurrency: string, rates?: Record<string, number>, rounding?: "none" | "round" | "charm-99" | "charm-95"): number;
18
- /**
19
- * Formats a cent amount into a localized currency string.
20
- */
12
+ /** Formats a cent amount into a localized currency string. */
21
13
  export declare function formatStorePrice(amountInCents: number, currency?: string, locale?: string): string;
22
- /**
23
- * Standard EU VAT Rates (as of 2026/2027 standard rules).
24
- */
14
+ /** Standard EU VAT Rates (as of 2026/2027 standard rules). */
25
15
  export declare const EU_STANDARD_VAT_RATES: Record<string, {
26
16
  rate: number;
27
17
  name: string;
28
18
  }>;
29
- /**
30
- * US State Sales Tax Default Base Rates.
31
- */
19
+ /** US State Sales Tax Default Base Rates. */
32
20
  export declare const US_STATE_TAX_RATES: Record<string, number>;
33
- /**
34
- * Canadian Province Combined Sales Tax (GST/PST/HST).
35
- */
21
+ /** Canadian Province Combined Sales Tax (GST/PST/HST). */
36
22
  export declare const CANADA_PROVINCE_TAX_RATES: Record<string, {
37
23
  rate: number;
38
24
  name: string;
39
25
  }>;
40
- /**
41
- * Validates an EU VAT identification number format against official member state syntax rules.
42
- */
26
+ /** Validates an EU VAT identification number format against official member state syntax rules. */
43
27
  export declare function validateEuVatNumber(vatNumber: string): {
44
28
  valid: boolean;
45
29
  countryCode?: string;
46
30
  cleanNumber?: string;
47
31
  };
48
- /**
49
- * Edge Tax Engine: Calculates exact tax, VAT, and B2B reverse charge exemptions.
50
- */
32
+ /** Edge Tax Engine: Calculates exact tax, VAT, and B2B reverse charge exemptions. */
51
33
  export declare function calculateStoreTax(input: StoreTaxCalculationInput, options?: StoreTaxOptions): StoreTaxResult;
@@ -136,9 +136,9 @@ export function convertStoreCurrency(amountInCents, fromCurrency, toCurrency, ra
136
136
  const toRate = rates[to] ?? DEFAULT_STORE_RATES[to] ?? 1;
137
137
  const fromDecimals = SUPPORTED_STORE_CURRENCIES[from]?.decimals ?? 2;
138
138
  const toDecimals = SUPPORTED_STORE_CURRENCIES[to]?.decimals ?? 2;
139
- const baseUnits = amountInCents / Math.pow(10, fromDecimals) / fromRate;
139
+ const baseUnits = amountInCents / 10 ** fromDecimals / fromRate;
140
140
  const targetUnits = baseUnits * toRate;
141
- let targetCents = Math.round(targetUnits * Math.pow(10, toDecimals));
141
+ let targetCents = Math.round(targetUnits * 10 ** toDecimals);
142
142
  if (toDecimals === 2) {
143
143
  if (rounding === "charm-99") {
144
144
  const dollars = Math.floor(targetCents / 100);
@@ -153,7 +153,7 @@ export function convertStoreCurrency(amountInCents, fromCurrency, toCurrency, ra
153
153
  export function formatStorePrice(amountInCents, currency = "USD", locale = "en-US") {
154
154
  const curr = currency.toUpperCase();
155
155
  const decimals = SUPPORTED_STORE_CURRENCIES[curr]?.decimals ?? 2;
156
- const value = amountInCents / Math.pow(10, decimals);
156
+ const value = amountInCents / 10 ** decimals;
157
157
  try {
158
158
  return new Intl.NumberFormat(locale, {
159
159
  style: "currency",
@@ -5,47 +5,47 @@ export interface TableResolveOptions {
5
5
  tables?: Record<string, string | undefined>;
6
6
  }
7
7
  /**
8
- * Resolves the database table prefix.
9
- * Priority:
8
+ * Resolves the database table prefix. Priority:
9
+ *
10
10
  * 1. Explicit `explicitPrefix` argument (if provided as boolean or string)
11
11
  * 2. `tablePrefix` or `prefix` from Qarpeo runtimeConfig (via `event` or global)
12
12
  * 3. `process.env.QARPEO_TABLE_PREFIX`
13
13
  *
14
14
  * Rules:
15
+ *
15
16
  * - `false`, `""`, or `undefined` -> `""` (no prefix, clean singular table name)
16
17
  * - `true` -> `"qarpeo_"`
17
18
  * - `"custom"` -> `"custom_"` (appends underscore if not present)
18
19
  * - `"custom_"` -> `"custom_"`
19
20
  */
20
21
  export declare function getTablePrefix(event?: RequestEvent, explicitPrefix?: boolean | string): string;
21
- /**
22
- * Returns configured granular table name overrides from runtime config or options.
23
- */
22
+ /** Returns configured granular table name overrides from runtime config or options. */
24
23
  export declare function getTableOverrides(event?: RequestEvent): Record<string, string>;
25
24
  /**
26
25
  * Resolves a database table name given a base singular name and optional prefix/event/options.
27
26
  *
28
27
  * Resolution Order:
28
+ *
29
29
  * 1. Granular table override (e.g. `tables.user` -> "profiles")
30
30
  * 2. Prefix + baseName (e.g. `tablePrefix: "q_"` + "session" -> "q_session")
31
31
  * 3. Clean singular baseName (default: "user", "comment", "customer")
32
32
  *
33
33
  * @example
34
- * ```ts
35
- * resolveTableName("user") // "user"
36
- * resolveTableName("user", "q_") // "q_user"
37
- * resolveTableName("user", { tables: { user: "profiles" } }) // "profiles"
38
- * resolveTableName("user", { tablePrefix: "q_", tables: { user: "profiles" } }) // "profiles"
39
- * ```
34
+ * ```ts
35
+ * resolveTableName("user") // "user"
36
+ * resolveTableName("user", "q_") // "q_user"
37
+ * resolveTableName("user", { tables: { user: "profiles" } }) // "profiles"
38
+ * resolveTableName("user", { tablePrefix: "q_", tables: { user: "profiles" } }) // "profiles"
39
+ * ```
40
40
  */
41
41
  export declare function resolveTableName(baseName: string, prefixOrEventOrOptions?: boolean | string | RequestEvent | TableResolveOptions, event?: RequestEvent): string;
42
42
  /**
43
43
  * Resolves an index name given the resolved table name and index suffix.
44
44
  *
45
45
  * @example
46
- * ```ts
47
- * resolveIndexName("comment", "target") // "idx_comment_target"
48
- * resolveIndexName("qarpeo_comment", "target") // "idx_qarpeo_comment_target"
49
- * ```
46
+ * ```ts
47
+ * resolveIndexName("comment", "target") // "idx_comment_target"
48
+ * resolveIndexName("qarpeo_comment", "target") // "idx_qarpeo_comment_target"
49
+ * ```
50
50
  */
51
51
  export declare function resolveIndexName(tableName: string, suffix: string): string;
@@ -55,7 +55,7 @@ export function resolveTableName(baseName, prefixOrEventOrOptions, event) {
55
55
  effectiveEvent = prefixOrEventOrOptions;
56
56
  }
57
57
  const runtimeOverrides = getTableOverrides(effectiveEvent);
58
- const mergedTables = { ...runtimeOverrides, ...tablesMap || {} };
58
+ const mergedTables = { ...runtimeOverrides, ...tablesMap };
59
59
  const camelKey = toCamelCase(baseName);
60
60
  const override = mergedTables[baseName] || mergedTables[camelKey];
61
61
  if (override) {
@@ -18,9 +18,9 @@ export declare function extractSubdomain(host: string, rootDomains: string[]): s
18
18
  * Retrieve a tenant record by slug.
19
19
  *
20
20
  * @example
21
- * ```ts
22
- * const tenant = await getTenantBySlug("acme", event)
23
- * ```
21
+ * ```ts
22
+ * const tenant = await getTenantBySlug("acme", event)
23
+ * ```
24
24
  */
25
25
  export declare function getTenantBySlug(slug: string, event?: RequestEvent): Promise<TenantRecord | null>;
26
26
  /** Retrieve a tenant record by ID. */
@@ -40,9 +40,9 @@ export declare function listTenants(event?: RequestEvent): Promise<TenantRecord[
40
40
  * 4. Direct database lookup (fallback)
41
41
  *
42
42
  * @example
43
- * ```ts
44
- * const tenant = await resolveTenant(event)
45
- * ```
43
+ * ```ts
44
+ * const tenant = await resolveTenant(event)
45
+ * ```
46
46
  */
47
47
  export declare function resolveTenant(event: RequestEvent): Promise<TenantRecord | null>;
48
48
  /** Assign tenant to request context. */
@@ -52,17 +52,17 @@ export declare function setTenant(event: RequestEvent, tenant: TenantRecord): vo
52
52
  * matched.
53
53
  *
54
54
  * @example
55
- * ```ts
56
- * const tenant = getTenant(event)
57
- * ```
55
+ * ```ts
56
+ * const tenant = getTenant(event)
57
+ * ```
58
58
  */
59
59
  export declare function getTenant(event: RequestEvent): TenantRecord | null;
60
60
  /**
61
61
  * Retrieve the active tenant or throw a 404 HTTP error.
62
62
  *
63
63
  * @example
64
- * ```ts
65
- * const tenant = useTenant(event)
66
- * ```
64
+ * ```ts
65
+ * const tenant = useTenant(event)
66
+ * ```
67
67
  */
68
68
  export declare function useTenant(event: RequestEvent): TenantRecord;
@@ -73,7 +73,9 @@ export async function getTenantBySlug(slug, event) {
73
73
  const db = event?.context?.db;
74
74
  if (db) {
75
75
  await ensureTenantsTableMigrated(db, event);
76
- const rows = await db.all(`SELECT * FROM ${tenantTbl(event)} WHERE slug = ? LIMIT 1`, [cleanSlug]);
76
+ const rows = await db.all(`SELECT * FROM ${tenantTbl(event)} WHERE slug = ? LIMIT 1`, [
77
+ cleanSlug
78
+ ]);
77
79
  if (rows?.[0]) {
78
80
  const row = rows[0];
79
81
  const rec = {
@@ -136,9 +138,10 @@ export async function getTenantByOrganization(orgId, event) {
136
138
  const db = event?.context?.db;
137
139
  if (db) {
138
140
  await ensureTenantsTableMigrated(db, event);
139
- const rows = await db.all(`SELECT * FROM ${tenantTbl(event)} WHERE organization_id = ? LIMIT 1`, [
140
- orgId
141
- ]);
141
+ const rows = await db.all(
142
+ `SELECT * FROM ${tenantTbl(event)} WHERE organization_id = ? LIMIT 1`,
143
+ [orgId]
144
+ );
142
145
  if (rows?.[0]) {
143
146
  const row = rows[0];
144
147
  const rec = {