@unifiedcommerce/core 0.0.1 → 0.0.2

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 (554) hide show
  1. package/dist/auth/access.d.ts +1 -1
  2. package/dist/auth/access.d.ts.map +1 -1
  3. package/dist/auth/auth-schema.js +3 -3
  4. package/dist/auth/middleware.d.ts +2 -2
  5. package/dist/auth/middleware.d.ts.map +1 -1
  6. package/dist/auth/middleware.js +37 -10
  7. package/dist/auth/org.js +1 -1
  8. package/dist/auth/permissions.d.ts +1 -1
  9. package/dist/auth/permissions.d.ts.map +1 -1
  10. package/dist/auth/permissions.js +1 -1
  11. package/dist/auth/setup.d.ts +19 -10
  12. package/dist/auth/setup.d.ts.map +1 -1
  13. package/dist/auth/setup.js +3 -4
  14. package/dist/auth/system-actor.d.ts +1 -1
  15. package/dist/auth/system-actor.d.ts.map +1 -1
  16. package/dist/auth/system-actor.js +1 -1
  17. package/dist/config/defaults.d.ts +1 -1
  18. package/dist/config/defaults.d.ts.map +1 -1
  19. package/dist/config/define-config.d.ts +1 -1
  20. package/dist/config/define-config.d.ts.map +1 -1
  21. package/dist/config/define-config.js +2 -2
  22. package/dist/config/types.d.ts +11 -11
  23. package/dist/config/types.d.ts.map +1 -1
  24. package/dist/hooks/checkout-completion.d.ts +2 -2
  25. package/dist/hooks/checkout-completion.d.ts.map +1 -1
  26. package/dist/hooks/checkout-completion.js +2 -2
  27. package/dist/hooks/checkout.d.ts +3 -3
  28. package/dist/hooks/checkout.d.ts.map +1 -1
  29. package/dist/hooks/checkout.js +3 -3
  30. package/dist/hooks/order-emails.d.ts +1 -1
  31. package/dist/hooks/order-emails.d.ts.map +1 -1
  32. package/dist/index.d.ts +81 -81
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +50 -13381
  35. package/dist/interfaces/mcp/context-enrichment.d.ts +2 -2
  36. package/dist/interfaces/mcp/context-enrichment.d.ts.map +1 -1
  37. package/dist/interfaces/mcp/context-enrichment.js +1 -1
  38. package/dist/interfaces/mcp/server.d.ts +2 -2
  39. package/dist/interfaces/mcp/server.d.ts.map +1 -1
  40. package/dist/interfaces/mcp/server.js +3 -3
  41. package/dist/interfaces/mcp/transport.d.ts +2 -2
  42. package/dist/interfaces/mcp/transport.d.ts.map +1 -1
  43. package/dist/interfaces/mcp/transport.js +1 -1
  44. package/dist/interfaces/rest/customer-portal.d.ts +2 -2
  45. package/dist/interfaces/rest/customer-portal.d.ts.map +1 -1
  46. package/dist/interfaces/rest/customer-portal.js +3 -3
  47. package/dist/interfaces/rest/index.d.ts +2 -2
  48. package/dist/interfaces/rest/index.d.ts.map +1 -1
  49. package/dist/interfaces/rest/index.js +13 -13
  50. package/dist/interfaces/rest/router.d.ts +1 -1
  51. package/dist/interfaces/rest/router.d.ts.map +1 -1
  52. package/dist/interfaces/rest/router.js +4 -4
  53. package/dist/interfaces/rest/routes/admin-jobs.d.ts +2 -2
  54. package/dist/interfaces/rest/routes/admin-jobs.d.ts.map +1 -1
  55. package/dist/interfaces/rest/routes/admin-jobs.js +4 -4
  56. package/dist/interfaces/rest/routes/audit.d.ts +2 -2
  57. package/dist/interfaces/rest/routes/audit.d.ts.map +1 -1
  58. package/dist/interfaces/rest/routes/audit.js +3 -3
  59. package/dist/interfaces/rest/routes/carts.d.ts +2 -2
  60. package/dist/interfaces/rest/routes/carts.d.ts.map +1 -1
  61. package/dist/interfaces/rest/routes/carts.js +2 -2
  62. package/dist/interfaces/rest/routes/catalog.d.ts +2 -2
  63. package/dist/interfaces/rest/routes/catalog.d.ts.map +1 -1
  64. package/dist/interfaces/rest/routes/catalog.js +2 -2
  65. package/dist/interfaces/rest/routes/checkout.d.ts +2 -2
  66. package/dist/interfaces/rest/routes/checkout.d.ts.map +1 -1
  67. package/dist/interfaces/rest/routes/checkout.js +7 -7
  68. package/dist/interfaces/rest/routes/inventory.d.ts +2 -2
  69. package/dist/interfaces/rest/routes/inventory.d.ts.map +1 -1
  70. package/dist/interfaces/rest/routes/inventory.js +2 -2
  71. package/dist/interfaces/rest/routes/media.d.ts +2 -2
  72. package/dist/interfaces/rest/routes/media.d.ts.map +1 -1
  73. package/dist/interfaces/rest/routes/media.js +2 -2
  74. package/dist/interfaces/rest/routes/orders.d.ts +2 -2
  75. package/dist/interfaces/rest/routes/orders.d.ts.map +1 -1
  76. package/dist/interfaces/rest/routes/orders.js +2 -2
  77. package/dist/interfaces/rest/routes/payments.d.ts +2 -2
  78. package/dist/interfaces/rest/routes/payments.d.ts.map +1 -1
  79. package/dist/interfaces/rest/routes/payments.js +2 -2
  80. package/dist/interfaces/rest/routes/pricing.d.ts +2 -2
  81. package/dist/interfaces/rest/routes/pricing.d.ts.map +1 -1
  82. package/dist/interfaces/rest/routes/pricing.js +2 -2
  83. package/dist/interfaces/rest/routes/promotions.d.ts +2 -2
  84. package/dist/interfaces/rest/routes/promotions.d.ts.map +1 -1
  85. package/dist/interfaces/rest/routes/promotions.js +3 -3
  86. package/dist/interfaces/rest/routes/search.d.ts +2 -2
  87. package/dist/interfaces/rest/routes/search.d.ts.map +1 -1
  88. package/dist/interfaces/rest/routes/search.js +2 -2
  89. package/dist/interfaces/rest/routes/webhooks.d.ts +2 -2
  90. package/dist/interfaces/rest/routes/webhooks.d.ts.map +1 -1
  91. package/dist/interfaces/rest/routes/webhooks.js +2 -2
  92. package/dist/interfaces/rest/schemas/admin-jobs.js +1 -1
  93. package/dist/interfaces/rest/schemas/carts.d.ts +1 -1
  94. package/dist/interfaces/rest/schemas/carts.d.ts.map +1 -1
  95. package/dist/interfaces/rest/schemas/carts.js +3 -3
  96. package/dist/interfaces/rest/schemas/catalog.js +3 -3
  97. package/dist/interfaces/rest/schemas/checkout.js +1 -1
  98. package/dist/interfaces/rest/schemas/customer-portal.js +2 -2
  99. package/dist/interfaces/rest/schemas/inventory.d.ts +1 -1
  100. package/dist/interfaces/rest/schemas/inventory.d.ts.map +1 -1
  101. package/dist/interfaces/rest/schemas/inventory.js +2 -2
  102. package/dist/interfaces/rest/schemas/media.js +1 -1
  103. package/dist/interfaces/rest/schemas/orders.js +2 -2
  104. package/dist/interfaces/rest/schemas/pricing.d.ts +1 -1
  105. package/dist/interfaces/rest/schemas/pricing.d.ts.map +1 -1
  106. package/dist/interfaces/rest/schemas/pricing.js +2 -2
  107. package/dist/interfaces/rest/schemas/promotions.d.ts +1 -1
  108. package/dist/interfaces/rest/schemas/promotions.d.ts.map +1 -1
  109. package/dist/interfaces/rest/schemas/promotions.js +2 -2
  110. package/dist/interfaces/rest/schemas/responses.js +5 -5
  111. package/dist/interfaces/rest/schemas/search.js +1 -1
  112. package/dist/interfaces/rest/schemas/webhooks.js +1 -1
  113. package/dist/interfaces/rest/utils.d.ts +2 -2
  114. package/dist/interfaces/rest/utils.d.ts.map +1 -1
  115. package/dist/interfaces/rest/utils.js +2 -2
  116. package/dist/interfaces/rest/webhook-router.d.ts +1 -1
  117. package/dist/interfaces/rest/webhook-router.d.ts.map +1 -1
  118. package/dist/kernel/compensation/executor.d.ts +2 -2
  119. package/dist/kernel/compensation/executor.d.ts.map +1 -1
  120. package/dist/kernel/compensation/types.d.ts +3 -3
  121. package/dist/kernel/compensation/types.d.ts.map +1 -1
  122. package/dist/kernel/database/drizzle-db.d.ts +1 -1
  123. package/dist/kernel/database/drizzle-db.d.ts.map +1 -1
  124. package/dist/kernel/database/drizzle-db.js +1 -1
  125. package/dist/kernel/database/migrate.d.ts +2 -2
  126. package/dist/kernel/database/migrate.d.ts.map +1 -1
  127. package/dist/kernel/database/migrate.js +1 -1
  128. package/dist/kernel/database/schema.d.ts +13 -13
  129. package/dist/kernel/database/schema.d.ts.map +1 -1
  130. package/dist/kernel/database/schema.js +13 -13
  131. package/dist/kernel/database/tx-context.d.ts +2 -2
  132. package/dist/kernel/database/tx-context.d.ts.map +1 -1
  133. package/dist/kernel/error-mapper.js +1 -1
  134. package/dist/kernel/factory/repository-factory.d.ts +2 -2
  135. package/dist/kernel/factory/repository-factory.d.ts.map +1 -1
  136. package/dist/kernel/factory/repository-factory.js +1 -1
  137. package/dist/kernel/hooks/create-context.d.ts +4 -4
  138. package/dist/kernel/hooks/create-context.d.ts.map +1 -1
  139. package/dist/kernel/hooks/create-context.js +1 -1
  140. package/dist/kernel/hooks/executor.d.ts +1 -1
  141. package/dist/kernel/hooks/executor.d.ts.map +1 -1
  142. package/dist/kernel/hooks/types.d.ts +3 -3
  143. package/dist/kernel/hooks/types.d.ts.map +1 -1
  144. package/dist/kernel/http-error.d.ts +1 -1
  145. package/dist/kernel/http-error.d.ts.map +1 -1
  146. package/dist/kernel/jobs/drizzle-adapter.d.ts +3 -3
  147. package/dist/kernel/jobs/drizzle-adapter.d.ts.map +1 -1
  148. package/dist/kernel/jobs/drizzle-adapter.js +2 -2
  149. package/dist/kernel/jobs/runner.d.ts +3 -3
  150. package/dist/kernel/jobs/runner.d.ts.map +1 -1
  151. package/dist/kernel/jobs/runner.js +1 -1
  152. package/dist/kernel/jobs/schema.js +1 -1
  153. package/dist/kernel/jobs/types.d.ts +2 -2
  154. package/dist/kernel/jobs/types.d.ts.map +1 -1
  155. package/dist/kernel/local-api.d.ts +21 -21
  156. package/dist/kernel/local-api.d.ts.map +1 -1
  157. package/dist/kernel/plugin/manifest.d.ts +1 -1
  158. package/dist/kernel/plugin/manifest.d.ts.map +1 -1
  159. package/dist/kernel/query/executor.d.ts +1 -1
  160. package/dist/kernel/query/executor.d.ts.map +1 -1
  161. package/dist/kernel/query/executor.js +1 -1
  162. package/dist/kernel/result.d.ts +1 -1
  163. package/dist/kernel/result.d.ts.map +1 -1
  164. package/dist/kernel/state-machine/machine.js +1 -1
  165. package/dist/modules/analytics/drizzle-adapter.d.ts +3 -3
  166. package/dist/modules/analytics/drizzle-adapter.d.ts.map +1 -1
  167. package/dist/modules/analytics/drizzle-adapter.js +2 -2
  168. package/dist/modules/analytics/models.d.ts +1 -1
  169. package/dist/modules/analytics/models.d.ts.map +1 -1
  170. package/dist/modules/analytics/repository/index.d.ts +1 -1
  171. package/dist/modules/analytics/repository/index.d.ts.map +1 -1
  172. package/dist/modules/analytics/service.d.ts +4 -4
  173. package/dist/modules/analytics/service.d.ts.map +1 -1
  174. package/dist/modules/analytics/service.js +2 -2
  175. package/dist/modules/analytics/types.d.ts +1 -1
  176. package/dist/modules/analytics/types.d.ts.map +1 -1
  177. package/dist/modules/audit/hooks.d.ts +1 -1
  178. package/dist/modules/audit/hooks.d.ts.map +1 -1
  179. package/dist/modules/audit/schema.js +1 -1
  180. package/dist/modules/audit/service.d.ts +4 -4
  181. package/dist/modules/audit/service.d.ts.map +1 -1
  182. package/dist/modules/audit/service.js +2 -2
  183. package/dist/modules/cart/access.d.ts +2 -2
  184. package/dist/modules/cart/access.d.ts.map +1 -1
  185. package/dist/modules/cart/matcher.d.ts +1 -1
  186. package/dist/modules/cart/matcher.d.ts.map +1 -1
  187. package/dist/modules/cart/repository/index.d.ts +3 -3
  188. package/dist/modules/cart/repository/index.d.ts.map +1 -1
  189. package/dist/modules/cart/repository/index.js +1 -1
  190. package/dist/modules/cart/schema.js +2 -2
  191. package/dist/modules/cart/service.d.ts +10 -10
  192. package/dist/modules/cart/service.d.ts.map +1 -1
  193. package/dist/modules/cart/service.js +8 -8
  194. package/dist/modules/catalog/repository/index.d.ts +3 -3
  195. package/dist/modules/catalog/repository/index.d.ts.map +1 -1
  196. package/dist/modules/catalog/repository/index.js +1 -1
  197. package/dist/modules/catalog/schema.js +1 -1
  198. package/dist/modules/catalog/service.d.ts +9 -9
  199. package/dist/modules/catalog/service.d.ts.map +1 -1
  200. package/dist/modules/catalog/service.js +8 -8
  201. package/dist/modules/customers/repository/index.d.ts +3 -3
  202. package/dist/modules/customers/repository/index.d.ts.map +1 -1
  203. package/dist/modules/customers/repository/index.js +1 -1
  204. package/dist/modules/customers/schema.js +1 -1
  205. package/dist/modules/customers/service.d.ts +4 -4
  206. package/dist/modules/customers/service.d.ts.map +1 -1
  207. package/dist/modules/customers/service.js +3 -3
  208. package/dist/modules/fulfillment/repository/index.d.ts +3 -3
  209. package/dist/modules/fulfillment/repository/index.d.ts.map +1 -1
  210. package/dist/modules/fulfillment/repository/index.js +1 -1
  211. package/dist/modules/fulfillment/schema.js +2 -2
  212. package/dist/modules/fulfillment/service.d.ts +6 -6
  213. package/dist/modules/fulfillment/service.d.ts.map +1 -1
  214. package/dist/modules/fulfillment/service.js +4 -4
  215. package/dist/modules/fulfillment/types.d.ts +2 -2
  216. package/dist/modules/fulfillment/types.d.ts.map +1 -1
  217. package/dist/modules/inventory/repository/index.d.ts +3 -3
  218. package/dist/modules/inventory/repository/index.d.ts.map +1 -1
  219. package/dist/modules/inventory/repository/index.js +1 -1
  220. package/dist/modules/inventory/schema.js +2 -2
  221. package/dist/modules/inventory/service.d.ts +9 -9
  222. package/dist/modules/inventory/service.d.ts.map +1 -1
  223. package/dist/modules/inventory/service.js +8 -8
  224. package/dist/modules/media/adapter.d.ts +1 -1
  225. package/dist/modules/media/adapter.d.ts.map +1 -1
  226. package/dist/modules/media/repository/index.d.ts +3 -3
  227. package/dist/modules/media/repository/index.d.ts.map +1 -1
  228. package/dist/modules/media/repository/index.js +1 -1
  229. package/dist/modules/media/schema.js +2 -2
  230. package/dist/modules/media/service.d.ts +6 -6
  231. package/dist/modules/media/service.d.ts.map +1 -1
  232. package/dist/modules/media/service.js +4 -4
  233. package/dist/modules/orders/repository/index.d.ts +3 -3
  234. package/dist/modules/orders/repository/index.d.ts.map +1 -1
  235. package/dist/modules/orders/repository/index.js +1 -1
  236. package/dist/modules/orders/schema.js +2 -2
  237. package/dist/modules/orders/service.d.ts +8 -8
  238. package/dist/modules/orders/service.d.ts.map +1 -1
  239. package/dist/modules/orders/service.js +9 -9
  240. package/dist/modules/orders/stale-order-cleanup.d.ts +1 -1
  241. package/dist/modules/orders/stale-order-cleanup.d.ts.map +1 -1
  242. package/dist/modules/orders/stale-order-cleanup.js +1 -1
  243. package/dist/modules/organization/service.d.ts +1 -1
  244. package/dist/modules/organization/service.d.ts.map +1 -1
  245. package/dist/modules/organization/service.js +1 -1
  246. package/dist/modules/payments/adapter.d.ts +1 -1
  247. package/dist/modules/payments/adapter.d.ts.map +1 -1
  248. package/dist/modules/payments/repository/index.d.ts +1 -1
  249. package/dist/modules/payments/repository/index.d.ts.map +1 -1
  250. package/dist/modules/payments/service.d.ts +3 -3
  251. package/dist/modules/payments/service.d.ts.map +1 -1
  252. package/dist/modules/payments/service.js +2 -2
  253. package/dist/modules/pricing/repository/index.d.ts +3 -3
  254. package/dist/modules/pricing/repository/index.d.ts.map +1 -1
  255. package/dist/modules/pricing/repository/index.js +1 -1
  256. package/dist/modules/pricing/schema.js +2 -2
  257. package/dist/modules/pricing/service.d.ts +7 -7
  258. package/dist/modules/pricing/service.d.ts.map +1 -1
  259. package/dist/modules/pricing/service.js +3 -3
  260. package/dist/modules/promotions/repository/index.d.ts +3 -3
  261. package/dist/modules/promotions/repository/index.d.ts.map +1 -1
  262. package/dist/modules/promotions/repository/index.js +1 -1
  263. package/dist/modules/promotions/schema.js +1 -1
  264. package/dist/modules/promotions/service.d.ts +8 -8
  265. package/dist/modules/promotions/service.d.ts.map +1 -1
  266. package/dist/modules/promotions/service.js +3 -3
  267. package/dist/modules/search/adapter.d.ts +1 -1
  268. package/dist/modules/search/adapter.d.ts.map +1 -1
  269. package/dist/modules/search/hooks.d.ts +1 -1
  270. package/dist/modules/search/hooks.d.ts.map +1 -1
  271. package/dist/modules/search/repository/index.d.ts +1 -1
  272. package/dist/modules/search/repository/index.d.ts.map +1 -1
  273. package/dist/modules/search/service.d.ts +4 -4
  274. package/dist/modules/search/service.d.ts.map +1 -1
  275. package/dist/modules/search/service.js +2 -2
  276. package/dist/modules/shipping/calculator.d.ts +3 -3
  277. package/dist/modules/shipping/calculator.d.ts.map +1 -1
  278. package/dist/modules/shipping/repository/index.d.ts +1 -1
  279. package/dist/modules/shipping/repository/index.d.ts.map +1 -1
  280. package/dist/modules/shipping/service.d.ts +5 -5
  281. package/dist/modules/shipping/service.d.ts.map +1 -1
  282. package/dist/modules/shipping/service.js +2 -2
  283. package/dist/modules/tax/adapter.d.ts +1 -1
  284. package/dist/modules/tax/adapter.d.ts.map +1 -1
  285. package/dist/modules/tax/repository/index.d.ts +1 -1
  286. package/dist/modules/tax/repository/index.d.ts.map +1 -1
  287. package/dist/modules/tax/service.d.ts +2 -2
  288. package/dist/modules/tax/service.d.ts.map +1 -1
  289. package/dist/modules/tax/service.js +2 -2
  290. package/dist/modules/webhooks/hook.d.ts +1 -1
  291. package/dist/modules/webhooks/hook.d.ts.map +1 -1
  292. package/dist/modules/webhooks/repository/index.d.ts +3 -3
  293. package/dist/modules/webhooks/repository/index.d.ts.map +1 -1
  294. package/dist/modules/webhooks/repository/index.js +1 -1
  295. package/dist/modules/webhooks/schema.js +1 -1
  296. package/dist/modules/webhooks/service.d.ts +4 -4
  297. package/dist/modules/webhooks/service.d.ts.map +1 -1
  298. package/dist/modules/webhooks/service.js +3 -3
  299. package/dist/modules/webhooks/tasks.d.ts +1 -1
  300. package/dist/modules/webhooks/tasks.d.ts.map +1 -1
  301. package/dist/modules/webhooks/tasks.js +1 -1
  302. package/dist/modules/webhooks/worker.d.ts +1 -1
  303. package/dist/modules/webhooks/worker.d.ts.map +1 -1
  304. package/dist/modules/webhooks/worker.js +2 -2
  305. package/dist/runtime/commerce.d.ts +9 -9
  306. package/dist/runtime/commerce.d.ts.map +1 -1
  307. package/dist/runtime/commerce.js +5 -5
  308. package/dist/runtime/kernel.d.ts +21 -21
  309. package/dist/runtime/kernel.d.ts.map +1 -1
  310. package/dist/runtime/kernel.js +41 -41
  311. package/dist/runtime/logger.d.ts +1 -1
  312. package/dist/runtime/logger.d.ts.map +1 -1
  313. package/dist/runtime/server.d.ts +6 -6
  314. package/dist/runtime/server.d.ts.map +1 -1
  315. package/dist/runtime/server.js +8 -6
  316. package/dist/runtime/shutdown.d.ts +1 -1
  317. package/dist/runtime/shutdown.d.ts.map +1 -1
  318. package/dist/test-utils/create-pglite-adapter.d.ts +2 -2
  319. package/dist/test-utils/create-pglite-adapter.d.ts.map +1 -1
  320. package/dist/test-utils/create-pglite-adapter.js +3 -3
  321. package/dist/test-utils/create-plugin-test-app.d.ts +3 -3
  322. package/dist/test-utils/create-plugin-test-app.d.ts.map +1 -1
  323. package/dist/test-utils/create-plugin-test-app.js +4 -4
  324. package/dist/test-utils/create-repository-test-harness.d.ts +2 -2
  325. package/dist/test-utils/create-repository-test-harness.d.ts.map +1 -1
  326. package/dist/test-utils/create-repository-test-harness.js +2 -2
  327. package/dist/test-utils/create-test-config.d.ts +1 -1
  328. package/dist/test-utils/create-test-config.d.ts.map +1 -1
  329. package/dist/test-utils/create-test-config.js +4 -4
  330. package/dist/test-utils/create-test-kernel.d.ts +2 -2
  331. package/dist/test-utils/create-test-kernel.d.ts.map +1 -1
  332. package/dist/test-utils/create-test-kernel.js +2 -2
  333. package/dist/test-utils/create-test-plugin-context.d.ts +2 -2
  334. package/dist/test-utils/create-test-plugin-context.d.ts.map +1 -1
  335. package/dist/test-utils/create-test-plugin-context.js +3 -3
  336. package/dist/test-utils/rest-api-test-utils.d.ts +4 -4
  337. package/dist/test-utils/rest-api-test-utils.d.ts.map +1 -1
  338. package/dist/test-utils/rest-api-test-utils.js +8 -8
  339. package/dist/test-utils/test-actors.d.ts +1 -1
  340. package/dist/test-utils/test-actors.d.ts.map +1 -1
  341. package/dist/test-utils/typed-hooks.d.ts +2 -2
  342. package/dist/test-utils/typed-hooks.d.ts.map +1 -1
  343. package/dist/types/commerce-types.d.ts +5 -5
  344. package/dist/types/commerce-types.d.ts.map +1 -1
  345. package/dist/utils/logger.d.ts +1 -1
  346. package/dist/utils/logger.d.ts.map +1 -1
  347. package/package.json +17 -9
  348. package/src/auth/access.ts +1 -1
  349. package/src/auth/auth-schema.ts +3 -3
  350. package/src/auth/middleware.ts +43 -14
  351. package/src/auth/org.ts +1 -1
  352. package/src/auth/permissions.ts +2 -2
  353. package/src/auth/setup.ts +18 -14
  354. package/src/auth/system-actor.ts +2 -2
  355. package/src/config/defaults.ts +1 -1
  356. package/src/config/define-config.ts +3 -3
  357. package/src/config/types.ts +11 -11
  358. package/src/hooks/checkout-completion.ts +4 -4
  359. package/src/hooks/checkout.ts +8 -8
  360. package/src/hooks/order-emails.ts +1 -1
  361. package/src/index.ts +83 -83
  362. package/src/interfaces/mcp/context-enrichment.ts +3 -3
  363. package/src/interfaces/mcp/server.ts +6 -6
  364. package/src/interfaces/mcp/transport.ts +3 -3
  365. package/src/interfaces/rest/customer-portal.ts +6 -6
  366. package/src/interfaces/rest/index.ts +15 -15
  367. package/src/interfaces/rest/router.ts +5 -5
  368. package/src/interfaces/rest/routes/admin-jobs.ts +5 -5
  369. package/src/interfaces/rest/routes/audit.ts +4 -4
  370. package/src/interfaces/rest/routes/carts.ts +4 -4
  371. package/src/interfaces/rest/routes/catalog.ts +5 -5
  372. package/src/interfaces/rest/routes/checkout.ts +11 -11
  373. package/src/interfaces/rest/routes/inventory.ts +3 -3
  374. package/src/interfaces/rest/routes/media.ts +4 -4
  375. package/src/interfaces/rest/routes/orders.ts +3 -3
  376. package/src/interfaces/rest/routes/payments.ts +3 -3
  377. package/src/interfaces/rest/routes/pricing.ts +3 -3
  378. package/src/interfaces/rest/routes/promotions.ts +4 -4
  379. package/src/interfaces/rest/routes/search.ts +3 -3
  380. package/src/interfaces/rest/routes/webhooks.ts +3 -3
  381. package/src/interfaces/rest/schemas/admin-jobs.ts +1 -1
  382. package/src/interfaces/rest/schemas/carts.ts +3 -3
  383. package/src/interfaces/rest/schemas/catalog.ts +3 -3
  384. package/src/interfaces/rest/schemas/checkout.ts +1 -1
  385. package/src/interfaces/rest/schemas/customer-portal.ts +2 -2
  386. package/src/interfaces/rest/schemas/inventory.ts +2 -2
  387. package/src/interfaces/rest/schemas/media.ts +1 -1
  388. package/src/interfaces/rest/schemas/orders.ts +2 -2
  389. package/src/interfaces/rest/schemas/pricing.ts +2 -2
  390. package/src/interfaces/rest/schemas/promotions.ts +2 -2
  391. package/src/interfaces/rest/schemas/responses.ts +5 -5
  392. package/src/interfaces/rest/schemas/search.ts +1 -1
  393. package/src/interfaces/rest/schemas/webhooks.ts +1 -1
  394. package/src/interfaces/rest/utils.ts +4 -4
  395. package/src/interfaces/rest/webhook-router.ts +1 -1
  396. package/src/kernel/compensation/executor.ts +2 -2
  397. package/src/kernel/compensation/types.ts +3 -3
  398. package/src/kernel/database/drizzle-db.ts +1 -1
  399. package/src/kernel/database/migrate.ts +2 -2
  400. package/src/kernel/database/schema.ts +13 -13
  401. package/src/kernel/database/tx-context.ts +2 -2
  402. package/src/kernel/error-mapper.ts +1 -1
  403. package/src/kernel/factory/repository-factory.ts +3 -3
  404. package/src/kernel/hooks/create-context.ts +5 -5
  405. package/src/kernel/hooks/executor.ts +1 -1
  406. package/src/kernel/hooks/types.ts +3 -3
  407. package/src/kernel/http-error.ts +1 -1
  408. package/src/kernel/jobs/drizzle-adapter.ts +5 -5
  409. package/src/kernel/jobs/runner.ts +4 -4
  410. package/src/kernel/jobs/schema.ts +1 -1
  411. package/src/kernel/jobs/types.ts +2 -2
  412. package/src/kernel/local-api.ts +4 -4
  413. package/src/kernel/plugin/manifest.ts +1 -1
  414. package/src/kernel/query/executor.ts +2 -2
  415. package/src/kernel/result.ts +1 -1
  416. package/src/kernel/state-machine/machine.ts +1 -1
  417. package/src/modules/analytics/drizzle-adapter.ts +4 -4
  418. package/src/modules/analytics/models.ts +1 -1
  419. package/src/modules/analytics/repository/index.ts +1 -1
  420. package/src/modules/analytics/service.ts +5 -5
  421. package/src/modules/analytics/types.ts +1 -1
  422. package/src/modules/audit/hooks.ts +3 -3
  423. package/src/modules/audit/schema.ts +1 -1
  424. package/src/modules/audit/service.ts +5 -5
  425. package/src/modules/cart/access.ts +2 -2
  426. package/src/modules/cart/matcher.ts +1 -1
  427. package/src/modules/cart/repository/index.ts +3 -3
  428. package/src/modules/cart/schema.ts +2 -2
  429. package/src/modules/cart/service.ts +17 -17
  430. package/src/modules/catalog/repository/index.ts +3 -3
  431. package/src/modules/catalog/schema.ts +1 -1
  432. package/src/modules/catalog/service.ts +16 -16
  433. package/src/modules/customers/repository/index.ts +3 -3
  434. package/src/modules/customers/schema.ts +1 -1
  435. package/src/modules/customers/service.ts +6 -6
  436. package/src/modules/fulfillment/repository/index.ts +3 -3
  437. package/src/modules/fulfillment/schema.ts +2 -2
  438. package/src/modules/fulfillment/service.ts +9 -9
  439. package/src/modules/fulfillment/types.ts +2 -2
  440. package/src/modules/inventory/repository/index.ts +3 -3
  441. package/src/modules/inventory/schema.ts +2 -2
  442. package/src/modules/inventory/service.ts +16 -16
  443. package/src/modules/media/adapter.ts +1 -1
  444. package/src/modules/media/repository/index.ts +3 -3
  445. package/src/modules/media/schema.ts +2 -2
  446. package/src/modules/media/service.ts +9 -9
  447. package/src/modules/orders/repository/index.ts +3 -3
  448. package/src/modules/orders/schema.ts +2 -2
  449. package/src/modules/orders/service.ts +15 -15
  450. package/src/modules/orders/stale-order-cleanup.ts +2 -2
  451. package/src/modules/organization/service.ts +2 -2
  452. package/src/modules/payments/adapter.ts +1 -1
  453. package/src/modules/payments/repository/index.ts +1 -1
  454. package/src/modules/payments/service.ts +3 -3
  455. package/src/modules/pricing/repository/index.ts +3 -3
  456. package/src/modules/pricing/schema.ts +2 -2
  457. package/src/modules/pricing/service.ts +9 -9
  458. package/src/modules/promotions/repository/index.ts +3 -3
  459. package/src/modules/promotions/schema.ts +1 -1
  460. package/src/modules/promotions/service.ts +10 -10
  461. package/src/modules/search/adapter.ts +1 -1
  462. package/src/modules/search/hooks.ts +2 -2
  463. package/src/modules/search/repository/index.ts +1 -1
  464. package/src/modules/search/service.ts +5 -5
  465. package/src/modules/shipping/calculator.ts +3 -3
  466. package/src/modules/shipping/repository/index.ts +1 -1
  467. package/src/modules/shipping/service.ts +5 -5
  468. package/src/modules/tax/adapter.ts +1 -1
  469. package/src/modules/tax/repository/index.ts +1 -1
  470. package/src/modules/tax/service.ts +3 -3
  471. package/src/modules/webhooks/hook.ts +1 -1
  472. package/src/modules/webhooks/repository/index.ts +3 -3
  473. package/src/modules/webhooks/schema.ts +1 -1
  474. package/src/modules/webhooks/service.ts +6 -6
  475. package/src/modules/webhooks/tasks.ts +3 -3
  476. package/src/modules/webhooks/worker.ts +3 -3
  477. package/src/runtime/commerce.ts +11 -11
  478. package/src/runtime/kernel.ts +45 -45
  479. package/src/runtime/logger.ts +1 -1
  480. package/src/runtime/server.ts +17 -13
  481. package/src/runtime/shutdown.ts +1 -1
  482. package/src/test-utils/create-pglite-adapter.ts +5 -5
  483. package/src/test-utils/create-plugin-test-app.ts +7 -7
  484. package/src/test-utils/create-repository-test-harness.ts +3 -3
  485. package/src/test-utils/create-test-config.ts +6 -6
  486. package/src/test-utils/create-test-kernel.ts +3 -3
  487. package/src/test-utils/create-test-plugin-context.ts +4 -4
  488. package/src/test-utils/rest-api-test-utils.ts +11 -11
  489. package/src/test-utils/test-actors.ts +1 -1
  490. package/src/test-utils/typed-hooks.ts +2 -2
  491. package/src/types/commerce-types.ts +5 -5
  492. package/src/utils/logger.ts +1 -1
  493. package/dist/auth/pos.d.ts +0 -3
  494. package/dist/auth/pos.d.ts.map +0 -1
  495. package/dist/auth/pos.js +0 -62
  496. package/dist/index.js.map +0 -156
  497. package/dist/interfaces/graphql/index.d.ts +0 -4
  498. package/dist/interfaces/graphql/index.d.ts.map +0 -1
  499. package/dist/interfaces/graphql/index.js +0 -415
  500. package/dist/kernel/factory/in-memory-repository-factory.d.ts +0 -20
  501. package/dist/kernel/factory/in-memory-repository-factory.d.ts.map +0 -1
  502. package/dist/kernel/factory/in-memory-repository-factory.js +0 -83
  503. package/dist/kernel/plugin/capability-registry.d.ts +0 -9
  504. package/dist/kernel/plugin/capability-registry.d.ts.map +0 -1
  505. package/dist/kernel/plugin/capability-registry.js +0 -28
  506. package/dist/kernel/plugin/dependency-graph.d.ts +0 -6
  507. package/dist/kernel/plugin/dependency-graph.d.ts.map +0 -1
  508. package/dist/kernel/plugin/dependency-graph.js +0 -55
  509. package/dist/modules/analytics/cubes.d.ts +0 -19
  510. package/dist/modules/analytics/cubes.d.ts.map +0 -1
  511. package/dist/modules/analytics/cubes.js +0 -187
  512. package/dist/modules/cart/repository/in-memory.d.ts +0 -30
  513. package/dist/modules/cart/repository/in-memory.d.ts.map +0 -1
  514. package/dist/modules/cart/repository/in-memory.js +0 -159
  515. package/dist/modules/catalog/repository/in-memory.d.ts +0 -82
  516. package/dist/modules/catalog/repository/in-memory.d.ts.map +0 -1
  517. package/dist/modules/catalog/repository/in-memory.js +0 -444
  518. package/dist/modules/customers/repository/in-memory.d.ts +0 -37
  519. package/dist/modules/customers/repository/in-memory.d.ts.map +0 -1
  520. package/dist/modules/customers/repository/in-memory.js +0 -278
  521. package/dist/modules/fulfillment/repository/in-memory.d.ts +0 -53
  522. package/dist/modules/fulfillment/repository/in-memory.d.ts.map +0 -1
  523. package/dist/modules/fulfillment/repository/in-memory.js +0 -327
  524. package/dist/modules/inventory/repository/in-memory.d.ts +0 -51
  525. package/dist/modules/inventory/repository/in-memory.d.ts.map +0 -1
  526. package/dist/modules/inventory/repository/in-memory.js +0 -281
  527. package/dist/modules/media/repository/in-memory.d.ts +0 -26
  528. package/dist/modules/media/repository/in-memory.d.ts.map +0 -1
  529. package/dist/modules/media/repository/in-memory.js +0 -145
  530. package/dist/modules/orders/repository/in-memory.d.ts +0 -40
  531. package/dist/modules/orders/repository/in-memory.d.ts.map +0 -1
  532. package/dist/modules/orders/repository/in-memory.js +0 -245
  533. package/dist/modules/pricing/repository/in-memory.d.ts +0 -25
  534. package/dist/modules/pricing/repository/in-memory.d.ts.map +0 -1
  535. package/dist/modules/pricing/repository/in-memory.js +0 -288
  536. package/dist/modules/promotions/repository/in-memory.d.ts +0 -32
  537. package/dist/modules/promotions/repository/in-memory.d.ts.map +0 -1
  538. package/dist/modules/promotions/repository/in-memory.js +0 -227
  539. package/dist/modules/webhooks/repository/in-memory.d.ts +0 -31
  540. package/dist/modules/webhooks/repository/in-memory.d.ts.map +0 -1
  541. package/dist/modules/webhooks/repository/in-memory.js +0 -187
  542. package/dist/runtime/state-manager.d.ts +0 -14
  543. package/dist/runtime/state-manager.d.ts.map +0 -1
  544. package/dist/runtime/state-manager.js +0 -84
  545. package/dist/runtime/state-repository.d.ts +0 -13
  546. package/dist/runtime/state-repository.d.ts.map +0 -1
  547. package/dist/runtime/state-repository.js +0 -160
  548. package/dist/runtime/state.d.ts +0 -382
  549. package/dist/runtime/state.d.ts.map +0 -1
  550. package/dist/runtime/state.js +0 -37
  551. package/dist/runtime/store.d.ts +0 -382
  552. package/dist/runtime/store.d.ts.map +0 -1
  553. package/dist/runtime/store.js +0 -37
  554. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,444 +0,0 @@
1
- function makeId() {
2
- return crypto.randomUUID();
3
- }
4
- /**
5
- * In-memory implementation of CatalogRepository for testing.
6
- * Provides the same interface as the Drizzle-based repository but stores data in memory.
7
- */
8
- export class InMemoryCatalogRepository {
9
- entities = new Map();
10
- attributes = new Map();
11
- customFields = new Map();
12
- categories = new Map();
13
- entityCategories = [];
14
- brands = new Map();
15
- entityBrands = [];
16
- optionTypes = new Map();
17
- optionValues = new Map();
18
- variants = new Map();
19
- variantOptionValues = [];
20
- // Entities
21
- async findEntityById(id, _ctx) {
22
- return this.entities.get(id);
23
- }
24
- async findEntityBySlug(slug, _ctx) {
25
- return [...this.entities.values()].find((e) => e.slug === slug);
26
- }
27
- async findEntities(filter, _ctx) {
28
- let result = [...this.entities.values()];
29
- if (filter?.type)
30
- result = result.filter((e) => e.type === filter.type);
31
- if (filter?.status)
32
- result = result.filter((e) => e.status === filter.status);
33
- if (filter?.ids) {
34
- const idSet = new Set(filter.ids);
35
- result = result.filter((e) => idSet.has(e.id));
36
- }
37
- return result;
38
- }
39
- async createEntity(data, _ctx) {
40
- const duplicate = [...this.entities.values()].find((e) => e.slug === data.slug);
41
- if (duplicate) {
42
- throw new Error(`Entity with slug "${data.slug}" already exists.`);
43
- }
44
- const now = new Date();
45
- const entity = {
46
- id: data.id ?? makeId(),
47
- type: data.type,
48
- slug: data.slug,
49
- status: data.status ?? "draft",
50
- isVisible: data.isVisible ?? false,
51
- metadata: data.metadata ?? null,
52
- createdAt: data.createdAt ?? now,
53
- updatedAt: data.updatedAt ?? now,
54
- publishedAt: data.publishedAt ?? null,
55
- };
56
- this.entities.set(entity.id, entity);
57
- return entity;
58
- }
59
- async updateEntity(id, data, _ctx) {
60
- const existing = this.entities.get(id);
61
- if (!existing)
62
- return undefined;
63
- const updated = {
64
- id: existing.id,
65
- type: data.type ?? existing.type,
66
- slug: data.slug ?? existing.slug,
67
- status: data.status ?? existing.status,
68
- isVisible: data.isVisible ?? existing.isVisible,
69
- metadata: data.metadata !== undefined
70
- ? (data.metadata ?? null)
71
- : existing.metadata,
72
- createdAt: existing.createdAt,
73
- updatedAt: new Date(),
74
- publishedAt: data.publishedAt !== undefined
75
- ? (data.publishedAt ?? null)
76
- : existing.publishedAt,
77
- };
78
- this.entities.set(id, updated);
79
- return updated;
80
- }
81
- async deleteEntity(id, _ctx) {
82
- return this.entities.delete(id);
83
- }
84
- // Attributes
85
- async findAttributesByEntityId(entityId, _ctx) {
86
- return this.attributes.get(entityId) ?? [];
87
- }
88
- async findAttributeByLocale(entityId, locale, _ctx) {
89
- return (this.attributes.get(entityId) ?? []).find((a) => a.locale === locale);
90
- }
91
- async createAttribute(data, _ctx) {
92
- const attr = {
93
- id: data.id ?? makeId(),
94
- entityId: data.entityId,
95
- locale: data.locale ?? "en",
96
- title: data.title,
97
- subtitle: data.subtitle ?? null,
98
- description: data.description ?? null,
99
- richDescription: data.richDescription ?? null,
100
- seoTitle: data.seoTitle ?? null,
101
- seoDescription: data.seoDescription ?? null,
102
- };
103
- const list = this.attributes.get(data.entityId) ?? [];
104
- list.push(attr);
105
- this.attributes.set(data.entityId, list);
106
- return attr;
107
- }
108
- async updateAttribute(id, data, _ctx) {
109
- for (const [entityId, attrs] of this.attributes.entries()) {
110
- const idx = attrs.findIndex((a) => a.id === id);
111
- if (idx !== -1) {
112
- const existing = attrs[idx];
113
- const updated = {
114
- id: existing.id,
115
- entityId: existing.entityId,
116
- locale: data.locale ?? existing.locale,
117
- title: data.title ?? existing.title,
118
- subtitle: data.subtitle !== undefined
119
- ? (data.subtitle ?? null)
120
- : existing.subtitle,
121
- description: data.description !== undefined
122
- ? (data.description ?? null)
123
- : existing.description,
124
- richDescription: data.richDescription !== undefined
125
- ? (data.richDescription ?? null)
126
- : existing.richDescription,
127
- seoTitle: data.seoTitle !== undefined
128
- ? (data.seoTitle ?? null)
129
- : existing.seoTitle,
130
- seoDescription: data.seoDescription !== undefined
131
- ? (data.seoDescription ?? null)
132
- : existing.seoDescription,
133
- };
134
- attrs[idx] = updated;
135
- return updated;
136
- }
137
- }
138
- return undefined;
139
- }
140
- async upsertAttribute(entityId, locale, data, ctx) {
141
- const existing = await this.findAttributeByLocale(entityId, locale, ctx);
142
- if (existing) {
143
- return (await this.updateAttribute(existing.id, data, ctx));
144
- }
145
- return this.createAttribute({ ...data, entityId, locale }, ctx);
146
- }
147
- async deleteAttributesByEntityId(entityId, _ctx) {
148
- this.attributes.delete(entityId);
149
- }
150
- // Custom Fields
151
- async findCustomFieldsByEntityId(entityId, _ctx) {
152
- return this.customFields.get(entityId) ?? [];
153
- }
154
- async createCustomField(data, _ctx) {
155
- const field = {
156
- id: data.id ?? makeId(),
157
- entityId: data.entityId,
158
- fieldName: data.fieldName,
159
- fieldType: data.fieldType,
160
- textValue: data.textValue ?? null,
161
- numberValue: data.numberValue ?? null,
162
- booleanValue: data.booleanValue ?? null,
163
- dateValue: data.dateValue ?? null,
164
- jsonValue: data.jsonValue ?? null,
165
- };
166
- const list = this.customFields.get(data.entityId) ?? [];
167
- list.push(field);
168
- this.customFields.set(data.entityId, list);
169
- return field;
170
- }
171
- async deleteCustomFieldsByEntityId(entityId, _ctx) {
172
- this.customFields.delete(entityId);
173
- }
174
- // Categories
175
- async findCategoryById(id, _ctx) {
176
- return this.categories.get(id);
177
- }
178
- async findCategoryBySlug(slug, _ctx) {
179
- return [...this.categories.values()].find((c) => c.slug === slug);
180
- }
181
- async findAllCategories(_ctx) {
182
- return [...this.categories.values()];
183
- }
184
- async createCategory(data, _ctx) {
185
- const duplicate = [...this.categories.values()].find((c) => c.slug === data.slug);
186
- if (duplicate) {
187
- throw new Error(`Category with slug "${data.slug}" already exists.`);
188
- }
189
- const category = {
190
- id: data.id ?? makeId(),
191
- parentId: data.parentId ?? null,
192
- slug: data.slug,
193
- sortOrder: data.sortOrder ?? 0,
194
- metadata: data.metadata ?? null,
195
- };
196
- this.categories.set(category.id, category);
197
- return category;
198
- }
199
- async updateCategory(id, data, _ctx) {
200
- const existing = this.categories.get(id);
201
- if (!existing)
202
- return undefined;
203
- const updated = {
204
- id: existing.id,
205
- parentId: data.parentId !== undefined
206
- ? (data.parentId ?? null)
207
- : existing.parentId,
208
- slug: data.slug ?? existing.slug,
209
- sortOrder: data.sortOrder ?? existing.sortOrder,
210
- metadata: data.metadata !== undefined
211
- ? (data.metadata ?? null)
212
- : existing.metadata,
213
- };
214
- this.categories.set(id, updated);
215
- return updated;
216
- }
217
- async deleteCategory(id, _ctx) {
218
- return this.categories.delete(id);
219
- }
220
- // Entity Categories
221
- async findEntityCategories(entityId, _ctx) {
222
- return this.entityCategories.filter((ec) => ec.entityId === entityId);
223
- }
224
- async findEntitiesByCategory(categoryId, _ctx) {
225
- return this.entityCategories
226
- .filter((ec) => ec.categoryId === categoryId)
227
- .map((ec) => ec.entityId);
228
- }
229
- async addEntityToCategory(entityId, categoryId, sortOrder = 0, _ctx) {
230
- const exists = this.entityCategories.some((ec) => ec.entityId === entityId && ec.categoryId === categoryId);
231
- if (!exists) {
232
- this.entityCategories.push({ entityId, categoryId, sortOrder });
233
- }
234
- }
235
- async removeEntityFromCategory(entityId, categoryId, _ctx) {
236
- const before = this.entityCategories.length;
237
- this.entityCategories = this.entityCategories.filter((ec) => !(ec.entityId === entityId && ec.categoryId === categoryId));
238
- return this.entityCategories.length < before;
239
- }
240
- async deleteEntityCategoriesByEntityId(entityId, _ctx) {
241
- this.entityCategories = this.entityCategories.filter((ec) => ec.entityId !== entityId);
242
- }
243
- async deleteEntityCategoriesByCategoryId(categoryId, _ctx) {
244
- this.entityCategories = this.entityCategories.filter((ec) => ec.categoryId !== categoryId);
245
- }
246
- // Brands
247
- async findBrandById(id, _ctx) {
248
- return this.brands.get(id);
249
- }
250
- async findBrandBySlug(slug, _ctx) {
251
- return [...this.brands.values()].find((b) => b.slug === slug);
252
- }
253
- async findAllBrands(_ctx) {
254
- return [...this.brands.values()];
255
- }
256
- async createBrand(data, _ctx) {
257
- const duplicate = [...this.brands.values()].find((b) => b.slug === data.slug);
258
- if (duplicate) {
259
- throw new Error(`Brand with slug "${data.slug}" already exists.`);
260
- }
261
- const brand = {
262
- id: data.id ?? makeId(),
263
- slug: data.slug,
264
- displayName: data.displayName,
265
- metadata: data.metadata ?? null,
266
- };
267
- this.brands.set(brand.id, brand);
268
- return brand;
269
- }
270
- async updateBrand(id, data, _ctx) {
271
- const existing = this.brands.get(id);
272
- if (!existing)
273
- return undefined;
274
- const updated = {
275
- id: existing.id,
276
- slug: data.slug ?? existing.slug,
277
- displayName: data.displayName ?? existing.displayName,
278
- metadata: data.metadata !== undefined
279
- ? (data.metadata ?? null)
280
- : existing.metadata,
281
- };
282
- this.brands.set(id, updated);
283
- return updated;
284
- }
285
- async deleteBrand(id, _ctx) {
286
- return this.brands.delete(id);
287
- }
288
- // Entity Brands
289
- async findEntityBrands(entityId, _ctx) {
290
- return this.entityBrands.filter((eb) => eb.entityId === entityId);
291
- }
292
- async addEntityToBrand(entityId, brandId, sortOrder = 0, _ctx) {
293
- const exists = this.entityBrands.some((eb) => eb.entityId === entityId && eb.brandId === brandId);
294
- if (!exists) {
295
- this.entityBrands.push({ entityId, brandId, sortOrder });
296
- }
297
- }
298
- async removeEntityFromBrand(entityId, brandId, _ctx) {
299
- const before = this.entityBrands.length;
300
- this.entityBrands = this.entityBrands.filter((eb) => !(eb.entityId === entityId && eb.brandId === brandId));
301
- return this.entityBrands.length < before;
302
- }
303
- async deleteEntityBrandsByEntityId(entityId, _ctx) {
304
- this.entityBrands = this.entityBrands.filter((eb) => eb.entityId !== entityId);
305
- }
306
- async deleteEntityBrandsByBrandId(brandId, _ctx) {
307
- this.entityBrands = this.entityBrands.filter((eb) => eb.brandId !== brandId);
308
- }
309
- // Option Types
310
- async findOptionTypesByEntityId(entityId, _ctx) {
311
- return [...this.optionTypes.values()].filter((ot) => ot.entityId === entityId);
312
- }
313
- async findOptionTypeById(id, _ctx) {
314
- return this.optionTypes.get(id);
315
- }
316
- async createOptionType(data, _ctx) {
317
- const optionType = {
318
- id: data.id ?? makeId(),
319
- entityId: data.entityId,
320
- name: data.name,
321
- displayName: data.displayName,
322
- sortOrder: data.sortOrder ?? 0,
323
- };
324
- this.optionTypes.set(optionType.id, optionType);
325
- return optionType;
326
- }
327
- async deleteOptionTypesByEntityId(entityId, _ctx) {
328
- for (const [id, ot] of this.optionTypes) {
329
- if (ot.entityId === entityId)
330
- this.optionTypes.delete(id);
331
- }
332
- }
333
- // Option Values
334
- async findOptionValuesByTypeId(optionTypeId, _ctx) {
335
- return [...this.optionValues.values()].filter((ov) => ov.optionTypeId === optionTypeId);
336
- }
337
- async findOptionValueById(id, _ctx) {
338
- return this.optionValues.get(id);
339
- }
340
- async findOptionValuesByIds(ids, _ctx) {
341
- return ids
342
- .map((id) => this.optionValues.get(id))
343
- .filter((v) => v !== undefined);
344
- }
345
- async createOptionValue(data, _ctx) {
346
- const optionValue = {
347
- id: data.id ?? makeId(),
348
- optionTypeId: data.optionTypeId,
349
- value: data.value,
350
- displayValue: data.displayValue,
351
- sortOrder: data.sortOrder ?? 0,
352
- metadata: data.metadata ?? null,
353
- };
354
- this.optionValues.set(optionValue.id, optionValue);
355
- return optionValue;
356
- }
357
- async deleteOptionValuesByTypeId(optionTypeId, _ctx) {
358
- for (const [id, ov] of this.optionValues) {
359
- if (ov.optionTypeId === optionTypeId)
360
- this.optionValues.delete(id);
361
- }
362
- }
363
- // Variants
364
- async findVariantsByEntityId(entityId, _ctx) {
365
- return [...this.variants.values()].filter((v) => v.entityId === entityId);
366
- }
367
- async findVariantById(id, _ctx) {
368
- return this.variants.get(id);
369
- }
370
- async findVariantBySku(sku, _ctx) {
371
- return [...this.variants.values()].find((v) => v.sku === sku);
372
- }
373
- async findVariantByBarcode(barcode, _ctx) {
374
- return [...this.variants.values()].find((v) => v.barcode === barcode);
375
- }
376
- async createVariant(data, _ctx) {
377
- if (data.sku != null) {
378
- const duplicate = [...this.variants.values()].find((v) => v.sku === data.sku);
379
- if (duplicate) {
380
- throw new Error(`Variant with SKU "${data.sku}" already exists.`);
381
- }
382
- }
383
- const variant = {
384
- id: data.id ?? makeId(),
385
- entityId: data.entityId,
386
- sku: data.sku ?? null,
387
- barcode: data.barcode ?? null,
388
- status: data.status ?? "active",
389
- sortOrder: data.sortOrder ?? 0,
390
- metadata: data.metadata ?? null,
391
- };
392
- this.variants.set(variant.id, variant);
393
- return variant;
394
- }
395
- async updateVariant(id, data, _ctx) {
396
- const existing = this.variants.get(id);
397
- if (!existing)
398
- return undefined;
399
- const updated = {
400
- id: existing.id,
401
- entityId: existing.entityId,
402
- sku: data.sku !== undefined ? (data.sku ?? null) : existing.sku,
403
- barcode: data.barcode !== undefined ? (data.barcode ?? null) : existing.barcode,
404
- status: data.status ?? existing.status,
405
- sortOrder: data.sortOrder ?? existing.sortOrder,
406
- metadata: data.metadata !== undefined
407
- ? (data.metadata ?? null)
408
- : existing.metadata,
409
- };
410
- this.variants.set(id, updated);
411
- return updated;
412
- }
413
- async deleteVariantsByEntityId(entityId, _ctx) {
414
- for (const [id, v] of this.variants) {
415
- if (v.entityId === entityId)
416
- this.variants.delete(id);
417
- }
418
- }
419
- // Variant Option Values
420
- async findVariantOptionValues(variantId, _ctx) {
421
- return this.variantOptionValues.filter((vov) => vov.variantId === variantId);
422
- }
423
- async createVariantOptionValues(data, _ctx) {
424
- for (const item of data) {
425
- const exists = this.variantOptionValues.some((vov) => vov.variantId === item.variantId &&
426
- vov.optionValueId === item.optionValueId);
427
- if (!exists) {
428
- this.variantOptionValues.push({
429
- variantId: item.variantId,
430
- optionValueId: item.optionValueId,
431
- });
432
- }
433
- }
434
- }
435
- async deleteVariantOptionValuesByVariantId(variantId, _ctx) {
436
- this.variantOptionValues = this.variantOptionValues.filter((vov) => vov.variantId !== variantId);
437
- }
438
- async deleteVariantOptionValuesByEntityId(entityId, _ctx) {
439
- const entityVariantIds = new Set([...this.variants.values()]
440
- .filter((v) => v.entityId === entityId)
441
- .map((v) => v.id));
442
- this.variantOptionValues = this.variantOptionValues.filter((vov) => !entityVariantIds.has(vov.variantId));
443
- }
444
- }
@@ -1,37 +0,0 @@
1
- import type { TxContext } from "../../../kernel/database/tx-context";
2
- import type { Customer, CustomerInsert, CustomerAddress, CustomerAddressInsert, CustomerGroup, CustomerGroupInsert } from "./index";
3
- /**
4
- * In-memory implementation of CustomersRepository for testing.
5
- */
6
- export declare class InMemoryCustomersRepository {
7
- private customers;
8
- private customerByUserId;
9
- private addresses;
10
- private groups;
11
- private groupMembers;
12
- findById(id: string, _ctx?: TxContext): Promise<Customer | undefined>;
13
- findByUserId(userId: string, _ctx?: TxContext): Promise<Customer | undefined>;
14
- findByEmail(email: string, _ctx?: TxContext): Promise<Customer | undefined>;
15
- findByPosPin(hashedPin: string, _ctx?: TxContext): Promise<Customer | undefined>;
16
- findAll(_ctx?: TxContext): Promise<Customer[]>;
17
- create(data: CustomerInsert, _ctx?: TxContext): Promise<Customer>;
18
- update(id: string, data: Partial<Omit<CustomerInsert, "id">>, _ctx?: TxContext): Promise<Customer | undefined>;
19
- delete(id: string, _ctx?: TxContext): Promise<boolean>;
20
- findAddressById(id: string, _ctx?: TxContext): Promise<CustomerAddress | undefined>;
21
- findAddressesByCustomerId(customerId: string, _ctx?: TxContext): Promise<CustomerAddress[]>;
22
- findDefaultAddress(customerId: string, type: "shipping" | "billing", _ctx?: TxContext): Promise<CustomerAddress | undefined>;
23
- createAddress(data: CustomerAddressInsert, _ctx?: TxContext): Promise<CustomerAddress>;
24
- updateAddress(id: string, data: Partial<Omit<CustomerAddressInsert, "id">>, _ctx?: TxContext): Promise<CustomerAddress | undefined>;
25
- deleteAddress(id: string, _ctx?: TxContext): Promise<boolean>;
26
- deleteAddressesByCustomerId(customerId: string, _ctx?: TxContext): Promise<void>;
27
- findGroupById(id: string, _ctx?: TxContext): Promise<CustomerGroup | undefined>;
28
- findGroupByName(name: string, _ctx?: TxContext): Promise<CustomerGroup | undefined>;
29
- findAllGroups(_ctx?: TxContext): Promise<CustomerGroup[]>;
30
- createGroup(data: CustomerGroupInsert, _ctx?: TxContext): Promise<CustomerGroup>;
31
- updateGroup(id: string, data: Partial<Omit<CustomerGroupInsert, "id">>, _ctx?: TxContext): Promise<CustomerGroup | undefined>;
32
- deleteGroup(id: string, _ctx?: TxContext): Promise<boolean>;
33
- findGroupsByCustomerId(customerId: string, _ctx?: TxContext): Promise<string[]>;
34
- addToGroup(customerId: string, groupId: string, _ctx?: TxContext): Promise<void>;
35
- removeFromGroup(customerId: string, groupId: string, _ctx?: TxContext): Promise<boolean>;
36
- }
37
- //# sourceMappingURL=in-memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../../../src/modules/customers/repository/in-memory.ts"],"names":[],"mappings":"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"}