@porulle/core 0.64.0 → 0.65.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (463) hide show
  1. package/dist/adapters/email-render.d.ts +18 -0
  2. package/dist/adapters/email-render.d.ts.map +1 -0
  3. package/dist/adapters/email-render.js +37 -0
  4. package/dist/auth/actor.d.ts.map +1 -1
  5. package/dist/auth/actor.js +11 -0
  6. package/dist/auth/auth-failure.d.ts +0 -2
  7. package/dist/auth/auth-failure.d.ts.map +1 -1
  8. package/dist/auth/auth-failure.js +0 -4
  9. package/dist/auth/middleware.d.ts +0 -1
  10. package/dist/auth/middleware.d.ts.map +1 -1
  11. package/dist/auth/middleware.js +7 -6
  12. package/dist/auth/permissions.d.ts +2 -0
  13. package/dist/auth/permissions.d.ts.map +1 -1
  14. package/dist/auth/permissions.js +8 -6
  15. package/dist/auth/role-authority.d.ts +0 -1
  16. package/dist/auth/role-authority.d.ts.map +1 -1
  17. package/dist/auth/role-authority.js +1 -8
  18. package/dist/auth/setup.d.ts.map +1 -1
  19. package/dist/auth/setup.js +5 -0
  20. package/dist/auth/strict-org-resolution.d.ts +8 -1
  21. package/dist/auth/strict-org-resolution.d.ts.map +1 -1
  22. package/dist/auth/strict-org-resolution.js +9 -19
  23. package/dist/auth/system-actor.d.ts +3 -2
  24. package/dist/auth/system-actor.d.ts.map +1 -1
  25. package/dist/auth/system-actor.js +3 -3
  26. package/dist/config/defaults.d.ts.map +1 -1
  27. package/dist/config/defaults.js +3 -20
  28. package/dist/config/define-config.d.ts +2 -2
  29. package/dist/config/define-config.d.ts.map +1 -1
  30. package/dist/config/define-config.js +3 -2
  31. package/dist/config/types.d.ts +2 -3
  32. package/dist/config/types.d.ts.map +1 -1
  33. package/dist/hooks/checkout.d.ts +2 -15
  34. package/dist/hooks/checkout.d.ts.map +1 -1
  35. package/dist/hooks/checkout.js +2 -51
  36. package/dist/index.d.ts +11 -19
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +11 -12
  39. package/dist/interfaces/rest/router.js +3 -3
  40. package/dist/interfaces/rest/routes/admin/compensation-failures.d.ts.map +1 -1
  41. package/dist/interfaces/rest/routes/admin/compensation-failures.js +5 -5
  42. package/dist/interfaces/rest/routes/admin/entity-field-definitions.js +5 -5
  43. package/dist/interfaces/rest/routes/admin/staff.d.ts.map +1 -1
  44. package/dist/interfaces/rest/routes/admin/staff.js +2 -3
  45. package/dist/interfaces/rest/routes/analytics.d.ts.map +1 -1
  46. package/dist/interfaces/rest/routes/analytics.js +2 -2
  47. package/dist/interfaces/rest/routes/carts.d.ts.map +1 -1
  48. package/dist/interfaces/rest/routes/carts.js +12 -12
  49. package/dist/interfaces/rest/routes/catalog.js +37 -37
  50. package/dist/interfaces/rest/routes/checkout.d.ts.map +1 -1
  51. package/dist/interfaces/rest/routes/checkout.js +9 -10
  52. package/dist/interfaces/rest/routes/customers.d.ts.map +1 -1
  53. package/dist/interfaces/rest/routes/customers.js +12 -12
  54. package/dist/interfaces/rest/routes/documents.d.ts.map +1 -1
  55. package/dist/interfaces/rest/routes/documents.js +9 -9
  56. package/dist/interfaces/rest/routes/inventory.d.ts.map +1 -1
  57. package/dist/interfaces/rest/routes/inventory.js +8 -8
  58. package/dist/interfaces/rest/routes/media.d.ts.map +1 -1
  59. package/dist/interfaces/rest/routes/media.js +5 -5
  60. package/dist/interfaces/rest/routes/orders.d.ts.map +1 -1
  61. package/dist/interfaces/rest/routes/orders.js +32 -32
  62. package/dist/interfaces/rest/routes/payments.d.ts.map +1 -1
  63. package/dist/interfaces/rest/routes/payments.js +2 -2
  64. package/dist/interfaces/rest/routes/pricing.d.ts.map +1 -1
  65. package/dist/interfaces/rest/routes/pricing.js +8 -8
  66. package/dist/interfaces/rest/routes/promotions.d.ts.map +1 -1
  67. package/dist/interfaces/rest/routes/promotions.js +7 -7
  68. package/dist/interfaces/rest/routes/search.d.ts.map +1 -1
  69. package/dist/interfaces/rest/routes/search.js +3 -3
  70. package/dist/interfaces/rest/routes/settings.d.ts.map +1 -1
  71. package/dist/interfaces/rest/routes/settings.js +4 -4
  72. package/dist/interfaces/rest/routes/shipping.d.ts.map +1 -1
  73. package/dist/interfaces/rest/routes/shipping.js +9 -9
  74. package/dist/interfaces/rest/routes/tax.d.ts.map +1 -1
  75. package/dist/interfaces/rest/routes/tax.js +9 -9
  76. package/dist/interfaces/rest/routes/webhooks.d.ts.map +1 -1
  77. package/dist/interfaces/rest/routes/webhooks.js +4 -4
  78. package/dist/interfaces/rest/utils.d.ts +1 -1
  79. package/dist/interfaces/rest/utils.d.ts.map +1 -1
  80. package/dist/interfaces/rest/utils.js +4 -13
  81. package/dist/jobs.d.ts +1 -0
  82. package/dist/jobs.d.ts.map +1 -1
  83. package/dist/jobs.js +1 -0
  84. package/dist/kernel/database/adapter.d.ts +9 -0
  85. package/dist/kernel/database/adapter.d.ts.map +1 -1
  86. package/dist/kernel/database/adapter.js +1 -1
  87. package/dist/kernel/database/migrate.d.ts +0 -4
  88. package/dist/kernel/database/migrate.d.ts.map +1 -1
  89. package/dist/kernel/database/migrate.js +2 -14
  90. package/dist/kernel/database/pglite-transaction.d.ts +28 -0
  91. package/dist/kernel/database/pglite-transaction.d.ts.map +1 -0
  92. package/dist/kernel/database/pglite-transaction.js +52 -0
  93. package/dist/kernel/database/tx-context.d.ts +0 -1
  94. package/dist/kernel/database/tx-context.d.ts.map +1 -1
  95. package/dist/kernel/database/tx-context.js +2 -14
  96. package/dist/kernel/database/unique-violation.d.ts +3 -0
  97. package/dist/kernel/database/unique-violation.d.ts.map +1 -0
  98. package/dist/kernel/database/unique-violation.js +9 -0
  99. package/dist/kernel/error-mapper.d.ts.map +1 -1
  100. package/dist/kernel/error-mapper.js +1 -0
  101. package/dist/kernel/errors.d.ts +12 -0
  102. package/dist/kernel/errors.d.ts.map +1 -1
  103. package/dist/kernel/errors.js +16 -0
  104. package/dist/kernel/hooks/create-context.d.ts +18 -9
  105. package/dist/kernel/hooks/create-context.d.ts.map +1 -1
  106. package/dist/kernel/hooks/create-context.js +24 -3
  107. package/dist/kernel/hooks/registry.d.ts +0 -19
  108. package/dist/kernel/hooks/registry.d.ts.map +1 -1
  109. package/dist/kernel/hooks/registry.js +0 -32
  110. package/dist/kernel/jobs/drizzle-adapter.d.ts.map +1 -1
  111. package/dist/kernel/jobs/drizzle-adapter.js +3 -10
  112. package/dist/kernel/jobs/prepare-enqueue.d.ts +20 -0
  113. package/dist/kernel/jobs/prepare-enqueue.d.ts.map +1 -0
  114. package/dist/kernel/jobs/prepare-enqueue.js +24 -0
  115. package/dist/kernel/jobs/types.d.ts +0 -4
  116. package/dist/kernel/jobs/types.d.ts.map +1 -1
  117. package/dist/kernel/jobs/types.js +0 -4
  118. package/dist/kernel/local-api.d.ts +0 -33
  119. package/dist/kernel/local-api.d.ts.map +1 -1
  120. package/dist/kernel/local-api.js +0 -36
  121. package/dist/kernel/plugin/manifest.d.ts +3 -5
  122. package/dist/kernel/plugin/manifest.d.ts.map +1 -1
  123. package/dist/modules/analytics/service.d.ts +0 -6
  124. package/dist/modules/analytics/service.d.ts.map +1 -1
  125. package/dist/modules/analytics/service.js +0 -32
  126. package/dist/modules/cart/service.d.ts.map +1 -1
  127. package/dist/modules/cart/service.js +5 -17
  128. package/dist/modules/catalog/entity-service.d.ts.map +1 -1
  129. package/dist/modules/catalog/entity-service.js +9 -17
  130. package/dist/modules/catalog/import-service.d.ts.map +1 -1
  131. package/dist/modules/catalog/import-service.js +4 -13
  132. package/dist/modules/catalog/service.d.ts +1 -81
  133. package/dist/modules/catalog/service.d.ts.map +1 -1
  134. package/dist/modules/catalog/service.js +1 -8
  135. package/dist/modules/customers/service.d.ts.map +1 -1
  136. package/dist/modules/customers/service.js +5 -17
  137. package/dist/modules/documents/render.d.ts +0 -3
  138. package/dist/modules/documents/render.d.ts.map +1 -1
  139. package/dist/modules/documents/render.js +2 -17
  140. package/dist/modules/fulfillment/service.d.ts.map +1 -1
  141. package/dist/modules/fulfillment/service.js +8 -26
  142. package/dist/modules/inventory/service.d.ts.map +1 -1
  143. package/dist/modules/inventory/service.js +3 -20
  144. package/dist/modules/media/service.d.ts.map +1 -1
  145. package/dist/modules/media/service.js +2 -10
  146. package/dist/modules/orders/quote.d.ts.map +1 -1
  147. package/dist/modules/orders/quote.js +1 -2
  148. package/dist/modules/orders/service.d.ts.map +1 -1
  149. package/dist/modules/orders/service.js +4 -17
  150. package/dist/modules/pricing/service.d.ts.map +1 -1
  151. package/dist/modules/pricing/service.js +7 -18
  152. package/dist/modules/promotions/service.d.ts.map +1 -1
  153. package/dist/modules/promotions/service.js +4 -16
  154. package/dist/modules/tax/service.d.ts +1 -3
  155. package/dist/modules/tax/service.d.ts.map +1 -1
  156. package/dist/modules/tax/service.js +16 -52
  157. package/dist/modules/webhooks/hook.d.ts.map +1 -1
  158. package/dist/modules/webhooks/hook.js +3 -2
  159. package/dist/modules/webhooks/service.d.ts.map +1 -1
  160. package/dist/modules/webhooks/service.js +1 -50
  161. package/dist/runtime/commerce.d.ts.map +1 -1
  162. package/dist/runtime/commerce.js +4 -11
  163. package/dist/runtime/kernel-modules.d.ts +38 -1799
  164. package/dist/runtime/kernel-modules.d.ts.map +1 -1
  165. package/dist/runtime/kernel-modules.js +160 -66
  166. package/dist/runtime/kernel-types.d.ts +3 -15
  167. package/dist/runtime/kernel-types.d.ts.map +1 -1
  168. package/dist/runtime/kernel-types.js +0 -10
  169. package/dist/runtime/kernel.d.ts +2 -3
  170. package/dist/runtime/kernel.d.ts.map +1 -1
  171. package/dist/runtime/kernel.js +10 -51
  172. package/dist/runtime/server.d.ts +1 -1
  173. package/dist/runtime/server.d.ts.map +1 -1
  174. package/dist/test-utils/create-pglite-adapter.d.ts.map +1 -1
  175. package/dist/test-utils/create-pglite-adapter.js +5 -62
  176. package/dist/test-utils/create-plugin-test-app.d.ts.map +1 -1
  177. package/dist/test-utils/create-plugin-test-app.js +13 -32
  178. package/dist/test-utils/rest-api-test-utils.d.ts +0 -12
  179. package/dist/test-utils/rest-api-test-utils.d.ts.map +1 -1
  180. package/dist/test-utils/rest-api-test-utils.js +3 -70
  181. package/dist/test-utils/test-actors.d.ts +9 -0
  182. package/dist/test-utils/test-actors.d.ts.map +1 -1
  183. package/dist/test-utils/test-actors.js +62 -0
  184. package/dist/testing.d.ts +1 -4
  185. package/dist/testing.d.ts.map +1 -1
  186. package/dist/testing.js +1 -4
  187. package/dist/utils/escape-html.d.ts +3 -0
  188. package/dist/utils/escape-html.d.ts.map +1 -0
  189. package/dist/utils/escape-html.js +9 -0
  190. package/dist/utils/id.d.ts +0 -1
  191. package/dist/utils/id.d.ts.map +1 -1
  192. package/dist/utils/id.js +0 -3
  193. package/dist/utils/logger.d.ts +1 -1
  194. package/dist/utils/logger.d.ts.map +1 -1
  195. package/dist/utils/logger.js +1 -1
  196. package/dist/utils/money.d.ts +13 -0
  197. package/dist/utils/money.d.ts.map +1 -0
  198. package/dist/utils/money.js +58 -0
  199. package/package.json +26 -29
  200. package/src/adapters/email-render.ts +63 -0
  201. package/src/auth/actor.ts +14 -0
  202. package/src/auth/auth-failure.ts +0 -5
  203. package/src/auth/middleware.ts +7 -6
  204. package/src/auth/permissions.ts +12 -6
  205. package/src/auth/role-authority.ts +1 -10
  206. package/src/auth/setup.ts +8 -0
  207. package/src/auth/strict-org-resolution.ts +9 -16
  208. package/src/auth/system-actor.ts +3 -3
  209. package/src/config/defaults.ts +3 -20
  210. package/src/config/define-config.ts +5 -4
  211. package/src/config/types.ts +2 -2
  212. package/src/hooks/checkout.ts +2 -86
  213. package/src/index.ts +9 -36
  214. package/src/interfaces/rest/router.ts +3 -3
  215. package/src/interfaces/rest/routes/admin/compensation-failures.ts +5 -5
  216. package/src/interfaces/rest/routes/admin/entity-field-definitions.ts +5 -5
  217. package/src/interfaces/rest/routes/admin/staff.ts +2 -3
  218. package/src/interfaces/rest/routes/analytics.ts +2 -2
  219. package/src/interfaces/rest/routes/carts.ts +12 -12
  220. package/src/interfaces/rest/routes/catalog.ts +37 -37
  221. package/src/interfaces/rest/routes/checkout.ts +8 -10
  222. package/src/interfaces/rest/routes/customers.ts +12 -12
  223. package/src/interfaces/rest/routes/documents.ts +9 -9
  224. package/src/interfaces/rest/routes/inventory.ts +8 -8
  225. package/src/interfaces/rest/routes/media.ts +5 -5
  226. package/src/interfaces/rest/routes/orders.ts +32 -32
  227. package/src/interfaces/rest/routes/payments.ts +2 -2
  228. package/src/interfaces/rest/routes/pricing.ts +8 -8
  229. package/src/interfaces/rest/routes/promotions.ts +7 -7
  230. package/src/interfaces/rest/routes/search.ts +3 -3
  231. package/src/interfaces/rest/routes/settings.ts +4 -4
  232. package/src/interfaces/rest/routes/shipping.ts +9 -9
  233. package/src/interfaces/rest/routes/tax.ts +9 -9
  234. package/src/interfaces/rest/routes/webhooks.ts +4 -4
  235. package/src/interfaces/rest/utils.ts +4 -14
  236. package/src/jobs.ts +2 -1
  237. package/src/kernel/database/adapter.ts +1 -1
  238. package/src/kernel/database/migrate.ts +2 -17
  239. package/src/kernel/database/pglite-transaction.ts +61 -0
  240. package/src/kernel/database/tx-context.ts +2 -20
  241. package/src/kernel/database/unique-violation.ts +7 -0
  242. package/src/kernel/error-mapper.ts +1 -0
  243. package/src/kernel/errors.ts +18 -0
  244. package/src/kernel/hooks/create-context.ts +38 -8
  245. package/src/kernel/hooks/registry.ts +0 -37
  246. package/src/kernel/jobs/drizzle-adapter.ts +4 -15
  247. package/src/kernel/jobs/prepare-enqueue.ts +42 -0
  248. package/src/kernel/jobs/types.ts +0 -5
  249. package/src/kernel/local-api.ts +0 -44
  250. package/src/kernel/plugin/manifest.ts +3 -5
  251. package/src/modules/analytics/service.ts +0 -36
  252. package/src/modules/cart/service.ts +6 -29
  253. package/src/modules/catalog/entity-service.ts +9 -19
  254. package/src/modules/catalog/import-service.ts +4 -11
  255. package/src/modules/catalog/service.ts +2 -286
  256. package/src/modules/customers/service.ts +6 -27
  257. package/src/modules/documents/render.ts +2 -19
  258. package/src/modules/fulfillment/service.ts +8 -27
  259. package/src/modules/inventory/service.ts +3 -21
  260. package/src/modules/media/service.ts +2 -8
  261. package/src/modules/orders/quote.ts +1 -2
  262. package/src/modules/orders/service.ts +5 -30
  263. package/src/modules/pricing/service.ts +12 -30
  264. package/src/modules/promotions/service.ts +5 -28
  265. package/src/modules/tax/service.ts +20 -48
  266. package/src/modules/webhooks/hook.ts +3 -2
  267. package/src/modules/webhooks/service.ts +1 -42
  268. package/src/runtime/commerce.ts +4 -11
  269. package/src/runtime/kernel-modules.ts +191 -67
  270. package/src/runtime/kernel-types.ts +3 -26
  271. package/src/runtime/kernel.ts +11 -66
  272. package/src/runtime/server.ts +1 -3
  273. package/src/test-utils/create-pglite-adapter.ts +5 -67
  274. package/src/test-utils/create-plugin-test-app.ts +13 -52
  275. package/src/test-utils/rest-api-test-utils.ts +3 -70
  276. package/src/test-utils/test-actors.ts +66 -0
  277. package/src/testing.ts +1 -3
  278. package/src/utils/escape-html.ts +9 -0
  279. package/src/utils/id.ts +0 -4
  280. package/src/utils/logger.ts +1 -1
  281. package/src/utils/money.ts +62 -0
  282. package/dist/auth/access.d.ts +0 -101
  283. package/dist/auth/access.d.ts.map +0 -1
  284. package/dist/auth/access.js +0 -128
  285. package/dist/generated/plugin-manifest.d.ts +0 -51
  286. package/dist/generated/plugin-manifest.d.ts.map +0 -1
  287. package/dist/generated/plugin-manifest.js +0 -21
  288. package/dist/kernel/factory/repository-factory.d.ts +0 -71
  289. package/dist/kernel/factory/repository-factory.d.ts.map +0 -1
  290. package/dist/kernel/factory/repository-factory.js +0 -138
  291. package/dist/kernel/http-error.d.ts +0 -30
  292. package/dist/kernel/http-error.d.ts.map +0 -1
  293. package/dist/kernel/http-error.js +0 -35
  294. package/dist/kernel/jobs/builtin-job-tasks.d.ts +0 -3
  295. package/dist/kernel/jobs/builtin-job-tasks.d.ts.map +0 -1
  296. package/dist/kernel/jobs/builtin-job-tasks.js +0 -6
  297. package/dist/kernel/module/define.d.ts +0 -21
  298. package/dist/kernel/module/define.d.ts.map +0 -1
  299. package/dist/kernel/module/define.js +0 -3
  300. package/dist/kernel/module/index.d.ts +0 -4
  301. package/dist/kernel/module/index.d.ts.map +0 -1
  302. package/dist/kernel/module/index.js +0 -2
  303. package/dist/kernel/module/topo-sort.d.ts +0 -7
  304. package/dist/kernel/module/topo-sort.d.ts.map +0 -1
  305. package/dist/kernel/module/topo-sort.js +0 -89
  306. package/dist/kernel/query/executor.d.ts +0 -21
  307. package/dist/kernel/query/executor.d.ts.map +0 -1
  308. package/dist/kernel/query/executor.js +0 -128
  309. package/dist/kernel/query/registry.d.ts +0 -33
  310. package/dist/kernel/query/registry.d.ts.map +0 -1
  311. package/dist/kernel/query/registry.js +0 -20
  312. package/dist/kernel/service-registry.d.ts +0 -109
  313. package/dist/kernel/service-registry.d.ts.map +0 -1
  314. package/dist/kernel/service-registry.js +0 -26
  315. package/dist/modules/analytics/hooks.d.ts +0 -13
  316. package/dist/modules/analytics/hooks.d.ts.map +0 -1
  317. package/dist/modules/analytics/hooks.js +0 -12
  318. package/dist/modules/analytics/module.d.ts +0 -3
  319. package/dist/modules/analytics/module.d.ts.map +0 -1
  320. package/dist/modules/analytics/module.js +0 -24
  321. package/dist/modules/analytics/repository/index.d.ts +0 -5
  322. package/dist/modules/analytics/repository/index.d.ts.map +0 -1
  323. package/dist/modules/analytics/repository/index.js +0 -1
  324. package/dist/modules/audit/index.d.ts +0 -2
  325. package/dist/modules/audit/index.d.ts.map +0 -1
  326. package/dist/modules/audit/index.js +0 -1
  327. package/dist/modules/audit/module.d.ts +0 -180
  328. package/dist/modules/audit/module.d.ts.map +0 -1
  329. package/dist/modules/audit/module.js +0 -8
  330. package/dist/modules/cart/access.d.ts +0 -11
  331. package/dist/modules/cart/access.d.ts.map +0 -1
  332. package/dist/modules/cart/access.js +0 -18
  333. package/dist/modules/cart/module.d.ts +0 -14
  334. package/dist/modules/cart/module.d.ts.map +0 -1
  335. package/dist/modules/cart/module.js +0 -17
  336. package/dist/modules/catalog/module.d.ts +0 -26
  337. package/dist/modules/catalog/module.d.ts.map +0 -1
  338. package/dist/modules/catalog/module.js +0 -33
  339. package/dist/modules/customers/index.d.ts +0 -2
  340. package/dist/modules/customers/index.d.ts.map +0 -1
  341. package/dist/modules/customers/index.js +0 -1
  342. package/dist/modules/customers/module.d.ts +0 -563
  343. package/dist/modules/customers/module.d.ts.map +0 -1
  344. package/dist/modules/customers/module.js +0 -20
  345. package/dist/modules/documents/module.d.ts +0 -7
  346. package/dist/modules/documents/module.d.ts.map +0 -1
  347. package/dist/modules/documents/module.js +0 -13
  348. package/dist/modules/fulfillment/module.d.ts +0 -13
  349. package/dist/modules/fulfillment/module.d.ts.map +0 -1
  350. package/dist/modules/fulfillment/module.js +0 -23
  351. package/dist/modules/inventory/module.d.ts +0 -13
  352. package/dist/modules/inventory/module.d.ts.map +0 -1
  353. package/dist/modules/inventory/module.js +0 -20
  354. package/dist/modules/media/index.d.ts +0 -2
  355. package/dist/modules/media/index.d.ts.map +0 -1
  356. package/dist/modules/media/index.js +0 -1
  357. package/dist/modules/media/module.d.ts +0 -360
  358. package/dist/modules/media/module.d.ts.map +0 -1
  359. package/dist/modules/media/module.js +0 -24
  360. package/dist/modules/orders/module.d.ts +0 -25
  361. package/dist/modules/orders/module.d.ts.map +0 -1
  362. package/dist/modules/orders/module.js +0 -33
  363. package/dist/modules/organization/index.d.ts +0 -2
  364. package/dist/modules/organization/index.d.ts.map +0 -1
  365. package/dist/modules/organization/index.js +0 -1
  366. package/dist/modules/organization/module.d.ts +0 -205
  367. package/dist/modules/organization/module.d.ts.map +0 -1
  368. package/dist/modules/organization/module.js +0 -8
  369. package/dist/modules/payments/module.d.ts +0 -3
  370. package/dist/modules/payments/module.d.ts.map +0 -1
  371. package/dist/modules/payments/module.js +0 -7
  372. package/dist/modules/payments/repository/index.d.ts +0 -5
  373. package/dist/modules/payments/repository/index.d.ts.map +0 -1
  374. package/dist/modules/payments/repository/index.js +0 -1
  375. package/dist/modules/pricing/index.d.ts +0 -2
  376. package/dist/modules/pricing/index.d.ts.map +0 -1
  377. package/dist/modules/pricing/index.js +0 -1
  378. package/dist/modules/pricing/module.d.ts +0 -14
  379. package/dist/modules/pricing/module.d.ts.map +0 -1
  380. package/dist/modules/pricing/module.js +0 -17
  381. package/dist/modules/promotions/module.d.ts +0 -14
  382. package/dist/modules/promotions/module.d.ts.map +0 -1
  383. package/dist/modules/promotions/module.js +0 -19
  384. package/dist/modules/search/module.d.ts +0 -8
  385. package/dist/modules/search/module.d.ts.map +0 -1
  386. package/dist/modules/search/module.js +0 -22
  387. package/dist/modules/search/repository/index.d.ts +0 -5
  388. package/dist/modules/search/repository/index.d.ts.map +0 -1
  389. package/dist/modules/search/repository/index.js +0 -1
  390. package/dist/modules/settings/module.d.ts +0 -6
  391. package/dist/modules/settings/module.d.ts.map +0 -1
  392. package/dist/modules/settings/module.js +0 -12
  393. package/dist/modules/shipping/module.d.ts +0 -12
  394. package/dist/modules/shipping/module.d.ts.map +0 -1
  395. package/dist/modules/shipping/module.js +0 -14
  396. package/dist/modules/tax/module.d.ts +0 -7
  397. package/dist/modules/tax/module.d.ts.map +0 -1
  398. package/dist/modules/tax/module.js +0 -13
  399. package/dist/modules/webhooks/index.d.ts +0 -2
  400. package/dist/modules/webhooks/index.d.ts.map +0 -1
  401. package/dist/modules/webhooks/index.js +0 -1
  402. package/dist/modules/webhooks/module.d.ts +0 -403
  403. package/dist/modules/webhooks/module.d.ts.map +0 -1
  404. package/dist/modules/webhooks/module.js +0 -16
  405. package/dist/test-utils/create-repository-test-harness.d.ts +0 -8
  406. package/dist/test-utils/create-repository-test-harness.d.ts.map +0 -1
  407. package/dist/test-utils/create-repository-test-harness.js +0 -7
  408. package/dist/test-utils/create-test-plugin-context.d.ts +0 -38
  409. package/dist/test-utils/create-test-plugin-context.d.ts.map +0 -1
  410. package/dist/test-utils/create-test-plugin-context.js +0 -39
  411. package/dist/test-utils/typed-hooks.d.ts +0 -44
  412. package/dist/test-utils/typed-hooks.d.ts.map +0 -1
  413. package/dist/test-utils/typed-hooks.js +0 -36
  414. package/dist/types/commerce-types.d.ts +0 -34
  415. package/dist/types/commerce-types.d.ts.map +0 -1
  416. package/dist/types/commerce-types.js +0 -1
  417. package/src/auth/access.ts +0 -187
  418. package/src/generated/plugin-capabilities.d.ts +0 -21
  419. package/src/generated/plugin-manifest.ts +0 -24
  420. package/src/generated/plugin-repositories.d.ts +0 -21
  421. package/src/kernel/factory/repository-factory.ts +0 -244
  422. package/src/kernel/http-error.ts +0 -44
  423. package/src/kernel/jobs/builtin-job-tasks.ts +0 -17
  424. package/src/kernel/module/define.ts +0 -36
  425. package/src/kernel/module/index.ts +0 -3
  426. package/src/kernel/module/topo-sort.ts +0 -99
  427. package/src/kernel/query/executor.ts +0 -184
  428. package/src/kernel/query/registry.ts +0 -46
  429. package/src/kernel/service-registry.ts +0 -76
  430. package/src/modules/analytics/hooks.ts +0 -11
  431. package/src/modules/analytics/module.ts +0 -35
  432. package/src/modules/analytics/repository/index.ts +0 -5
  433. package/src/modules/audit/index.ts +0 -1
  434. package/src/modules/audit/module.ts +0 -11
  435. package/src/modules/cart/access.ts +0 -27
  436. package/src/modules/cart/module.ts +0 -32
  437. package/src/modules/catalog/module.ts +0 -80
  438. package/src/modules/customers/index.ts +0 -1
  439. package/src/modules/customers/module.ts +0 -29
  440. package/src/modules/documents/module.ts +0 -21
  441. package/src/modules/fulfillment/module.ts +0 -44
  442. package/src/modules/inventory/module.ts +0 -37
  443. package/src/modules/media/index.ts +0 -1
  444. package/src/modules/media/module.ts +0 -27
  445. package/src/modules/orders/module.ts +0 -67
  446. package/src/modules/organization/index.ts +0 -1
  447. package/src/modules/organization/module.ts +0 -11
  448. package/src/modules/payments/module.ts +0 -14
  449. package/src/modules/payments/repository/index.ts +0 -5
  450. package/src/modules/pricing/index.ts +0 -1
  451. package/src/modules/pricing/module.ts +0 -32
  452. package/src/modules/promotions/module.ts +0 -34
  453. package/src/modules/search/module.ts +0 -32
  454. package/src/modules/search/repository/index.ts +0 -5
  455. package/src/modules/settings/module.ts +0 -20
  456. package/src/modules/shipping/module.ts +0 -27
  457. package/src/modules/tax/module.ts +0 -21
  458. package/src/modules/webhooks/index.ts +0 -1
  459. package/src/modules/webhooks/module.ts +0 -24
  460. package/src/test-utils/create-repository-test-harness.ts +0 -16
  461. package/src/test-utils/create-test-plugin-context.ts +0 -66
  462. package/src/test-utils/typed-hooks.ts +0 -55
  463. package/src/types/commerce-types.ts +0 -34
@@ -1,99 +0,0 @@
1
- import type { AppModule } from "./define.js";
2
-
3
- export class ModuleCycleError extends Error {
4
- readonly cycle: string[];
5
-
6
- constructor(cycle: string[]) {
7
- const label = cycle.join(" → ");
8
- super(`Module dependency cycle: ${label}`);
9
- this.name = "ModuleCycleError";
10
- this.cycle = cycle;
11
- }
12
- }
13
-
14
- export function topoSortModules(modules: Record<string, AppModule>): string[] {
15
- const keys = Object.keys(modules);
16
- const keySet = new Set(keys);
17
-
18
- for (const [id, mod] of Object.entries(modules)) {
19
- for (const dep of mod.dependencies ?? []) {
20
- const depKey = dep as string;
21
- if (!keySet.has(depKey)) {
22
- throw new Error(`Module "${id}" declares unknown dependency "${depKey}"`);
23
- }
24
- }
25
- }
26
-
27
- const remaining = new Map<string, Set<string>>();
28
- for (const k of keys) {
29
- const mod = modules[k]!;
30
- remaining.set(k, new Set((mod.dependencies ?? []) as string[]));
31
- }
32
-
33
- const waitingOn = new Map<string, string[]>();
34
- for (const m of keys) {
35
- const mod = modules[m]!;
36
- for (const d of (mod.dependencies ?? []) as string[]) {
37
- const list = waitingOn.get(d);
38
- if (list) list.push(m);
39
- else waitingOn.set(d, [m]);
40
- }
41
- }
42
-
43
- const order: string[] = [];
44
- const queue = keys.filter((k) => remaining.get(k)!.size === 0);
45
-
46
- while (queue.length > 0) {
47
- const n = queue.shift()!;
48
- order.push(n);
49
- for (const m of waitingOn.get(n) ?? []) {
50
- const set = remaining.get(m)!;
51
- if (set.delete(n) && set.size === 0) {
52
- queue.push(m);
53
- }
54
- }
55
- }
56
-
57
- if (order.length !== keys.length) {
58
- const cycle = findCycleKeys(modules, keys);
59
- throw new ModuleCycleError(cycle);
60
- }
61
-
62
- return order;
63
- }
64
-
65
- function findCycleKeys(modules: Record<string, AppModule>, keys: string[]): string[] {
66
- const WHITE = 0;
67
- const GRAY = 1;
68
- const BLACK = 2;
69
- const mark = new Map<string, number>();
70
- const stack: string[] = [];
71
-
72
- function dfs(u: string): string[] | null {
73
- mark.set(u, GRAY);
74
- stack.push(u);
75
- const mod = modules[u]!;
76
- for (const v of (mod.dependencies ?? []) as string[]) {
77
- const mv = mark.get(v) ?? WHITE;
78
- if (mv === WHITE) {
79
- const found = dfs(v);
80
- if (found) return found;
81
- } else if (mv === GRAY) {
82
- const idx = stack.indexOf(v);
83
- return [...stack.slice(idx), v];
84
- }
85
- }
86
- stack.pop();
87
- mark.set(u, BLACK);
88
- return null;
89
- }
90
-
91
- for (const k of keys) {
92
- if ((mark.get(k) ?? WHITE) === WHITE) {
93
- const found = dfs(k);
94
- if (found) return found;
95
- }
96
- }
97
-
98
- throw new Error("topoSortModules: expected a cycle but DFS did not find one");
99
- }
@@ -1,184 +0,0 @@
1
- import { CommerceNotFoundError } from "../errors.js";
2
- import type {
3
- QueryRegistry,
4
- EntityDefinition,
5
- RelationDefinition,
6
- } from "./registry.js";
7
-
8
- export interface QueryInput {
9
- entity: string;
10
- id?: string;
11
- filters?: Record<string, unknown>;
12
- include?: string[];
13
- pagination?: { limit?: number; offset?: number };
14
- }
15
-
16
- export interface QueryResult<T = Record<string, unknown>> {
17
- data: T[];
18
- total?: number | undefined;
19
- }
20
-
21
- /**
22
- * Executes a query against the registry, resolving includes via
23
- * batched dataloader-style fetches (one WHERE IN per relation).
24
- */
25
- export async function executeQuery<T = Record<string, unknown>>(
26
- registry: QueryRegistry,
27
- services: Record<string, unknown>,
28
- input: QueryInput,
29
- ): Promise<QueryResult<T>> {
30
- const definition = registry.get(input.entity);
31
- if (!definition) {
32
- throw new CommerceNotFoundError(
33
- `No entity registered with name "${input.entity}".`,
34
- );
35
- }
36
-
37
- const service = services[definition.service] as Record<
38
- string,
39
- (...args: unknown[]) => Promise<unknown>
40
- >;
41
-
42
- // 1. Fetch primary records
43
- let rows: Record<string, unknown>[];
44
- let total: number | undefined;
45
-
46
- if (input.id) {
47
- const result = (await service[definition.getByIdMethod]!(
48
- input.id,
49
- )) as { ok?: boolean; value?: unknown };
50
- const value = result?.value ?? result;
51
- rows = value != null ? [value as Record<string, unknown>] : [];
52
- } else {
53
- const result = (await service[definition.listMethod]!(
54
- input.filters ?? {},
55
- input.pagination,
56
- )) as {
57
- ok?: boolean;
58
- value?: { items?: unknown[]; total?: number };
59
- };
60
- const resolved = result?.value ?? result;
61
- if (resolved && typeof resolved === "object" && "items" in resolved) {
62
- rows = (resolved.items ?? []) as Record<string, unknown>[];
63
- total = resolved.total;
64
- } else if (Array.isArray(resolved)) {
65
- rows = resolved as Record<string, unknown>[];
66
- } else {
67
- rows = [];
68
- }
69
- }
70
-
71
- // 2. Resolve includes
72
- if (input.include?.length) {
73
- await resolveIncludes(rows, input.include, definition, services, registry);
74
- }
75
-
76
- return { data: rows as T[], total };
77
- }
78
-
79
- async function resolveIncludes(
80
- rows: Record<string, unknown>[],
81
- includes: string[],
82
- definition: EntityDefinition,
83
- services: Record<string, unknown>,
84
- registry: QueryRegistry,
85
- ): Promise<void> {
86
- // Group includes by top-level segment
87
- const topLevel = new Map<string, string[]>();
88
- for (const path of includes) {
89
- const dot = path.indexOf(".");
90
- if (dot === -1) {
91
- if (!topLevel.has(path)) topLevel.set(path, []);
92
- } else {
93
- const parent = path.substring(0, dot);
94
- const child = path.substring(dot + 1);
95
- const existing = topLevel.get(parent) ?? [];
96
- existing.push(child);
97
- topLevel.set(parent, existing);
98
- }
99
- }
100
-
101
- for (const [relationName, nestedIncludes] of topLevel) {
102
- const relation = definition.relations[relationName];
103
- if (!relation) continue;
104
-
105
- const targetService = services[relation.targetService] as
106
- | Record<string, (...args: unknown[]) => Promise<unknown>>
107
- | undefined;
108
- if (!targetService) continue;
109
-
110
- // Collect foreign key values (deduplicated)
111
- const ids = [
112
- ...new Set(
113
- rows
114
- .map((r) => r[relation.foreignKey])
115
- .filter((v): v is string => v != null && typeof v === "string"),
116
- ),
117
- ];
118
- if (ids.length === 0) continue;
119
-
120
- // One batched query
121
- const batchFn = targetService[relation.batchMethod];
122
- if (!batchFn) continue;
123
-
124
- const relatedResult = await batchFn(ids);
125
- const relatedRows = extractRows(relatedResult);
126
-
127
- // Build lookup
128
- const map = new Map<string, unknown>();
129
- for (const related of relatedRows) {
130
- const rec = related as Record<string, unknown>;
131
- if (relation.isList) {
132
- const key = rec[relation.foreignKey] as string;
133
- if (!map.has(key)) map.set(key, []);
134
- (map.get(key) as unknown[]).push(rec);
135
- } else {
136
- map.set(rec["id"] as string, rec);
137
- }
138
- }
139
-
140
- // Attach to parent rows
141
- for (const row of rows) {
142
- const fkValue = row[relation.foreignKey] as string | undefined;
143
- if (!fkValue) continue;
144
- row[relation.attachAs] =
145
- map.get(fkValue) ?? (relation.isList ? [] : null);
146
- }
147
-
148
- // Resolve nested includes
149
- if (nestedIncludes.length > 0) {
150
- const targetDef = registry.get(relation.targetService);
151
- if (targetDef) {
152
- const nestedRows = relation.isList
153
- ? rows.flatMap(
154
- (r) =>
155
- (r[relation.attachAs] as Record<string, unknown>[]) ?? [],
156
- )
157
- : rows
158
- .map((r) => r[relation.attachAs] as Record<string, unknown>)
159
- .filter(Boolean);
160
- await resolveIncludes(
161
- nestedRows,
162
- nestedIncludes,
163
- targetDef,
164
- services,
165
- registry,
166
- );
167
- }
168
- }
169
- }
170
- }
171
-
172
- function extractRows(result: unknown): unknown[] {
173
- if (Array.isArray(result)) return result;
174
- if (result && typeof result === "object") {
175
- const r = result as { ok?: boolean; value?: unknown };
176
- if (r.value != null) {
177
- if (Array.isArray(r.value)) return r.value;
178
- if (typeof r.value === "object" && "items" in r.value) {
179
- return (r.value as { items: unknown[] }).items;
180
- }
181
- }
182
- }
183
- return [];
184
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * Defines a relation from a parent entity to a related entity.
3
- * Used by the query executor to batch-load related records.
4
- */
5
- export interface RelationDefinition {
6
- foreignKey: string;
7
- targetService: string;
8
- batchMethod: string;
9
- attachAs: string;
10
- isList?: boolean;
11
- }
12
-
13
- /**
14
- * Defines an entity that can be queried via kernel.query().
15
- */
16
- export interface EntityDefinition {
17
- service: string;
18
- getByIdMethod: string;
19
- listMethod: string;
20
- relations: Record<string, RelationDefinition>;
21
- }
22
-
23
- /**
24
- * Registry of queryable entities and their relations.
25
- * Modules register their entities at kernel boot.
26
- * Plugins can register additional entities.
27
- */
28
- export class QueryRegistry {
29
- private entities = new Map<string, EntityDefinition>();
30
-
31
- register(name: string, definition: EntityDefinition): void {
32
- this.entities.set(name, definition);
33
- }
34
-
35
- get(name: string): EntityDefinition | undefined {
36
- return this.entities.get(name);
37
- }
38
-
39
- has(name: string): boolean {
40
- return this.entities.has(name);
41
- }
42
-
43
- listEntities(): string[] {
44
- return [...this.entities.keys()];
45
- }
46
- }
@@ -1,76 +0,0 @@
1
- /**
2
- * ServiceRegistry -- typed surface of the kernel service container
3
- * for plugin-to-plugin communication.
4
- *
5
- * Plugin services accept this as an optional constructor parameter
6
- * to call core services without resorting to raw SQL.
7
- *
8
- * Core services are loosely typed here (method signatures use `unknown`)
9
- * to avoid plugin packages depending on core's internal service types.
10
- * Plugin authors cast the return values at the call site.
11
- *
12
- * Usage in a plugin service:
13
- *
14
- * import type { ServiceRegistry } from "@porulle/core";
15
- *
16
- * class MyService {
17
- * constructor(private db: PluginDb, private services?: ServiceRegistry) {}
18
- *
19
- * async doWork() {
20
- * const result = await this.services?.inventory.adjust({
21
- * entityId: "...", adjustment: -5, reason: "recipe deduction"
22
- * }, actor);
23
- * }
24
- * }
25
- */
26
-
27
- export interface ServiceRegistry {
28
- inventory: {
29
- adjust(
30
- input: {
31
- entityId: string;
32
- variantId?: string;
33
- warehouseId?: string;
34
- adjustment: number;
35
- reason?: string;
36
- },
37
- actor?: unknown,
38
- ): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
39
- createWarehouse(
40
- input: { name: string; code: string },
41
- actor?: unknown,
42
- ): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
43
- reserve(input: unknown, actor?: unknown): Promise<unknown>;
44
- release(input: unknown, actor?: unknown): Promise<unknown>;
45
- getAvailable(input: unknown, actor?: unknown): Promise<unknown>;
46
- [method: string]: unknown;
47
- };
48
- catalog: {
49
- create(input: unknown, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
50
- getById(id: string, options?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
51
- publish(id: string, actor?: unknown): Promise<unknown>;
52
- list(input?: unknown): Promise<unknown>;
53
- [method: string]: unknown;
54
- };
55
- customers: {
56
- getByUserId(userId: string, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
57
- getById(id: string, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
58
- [method: string]: unknown;
59
- };
60
- orders: {
61
- create(input: unknown, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
62
- changeStatus(input: unknown, actor?: unknown): Promise<unknown>;
63
- [method: string]: unknown;
64
- };
65
- cart: {
66
- create(input: unknown, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
67
- [method: string]: unknown;
68
- };
69
- organization: {
70
- create(input: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
71
- getById(id: string): Promise<unknown>;
72
- [method: string]: unknown;
73
- };
74
- /** Access plugin-registered services by plugin ID or service name */
75
- [key: string]: unknown;
76
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Analytics hooks — legacy compatibility surface.
3
- *
4
- * The in-memory event recording hooks (recordOrderAnalyticsEvent,
5
- * recordInventoryAnalyticsEvent) have been removed. The source tables
6
- * (orders, inventory_levels, customers) ARE the source of truth; the
7
- * DrizzleAnalyticsAdapter queries them directly via SQL.
8
- *
9
- * The empty exports below preserve backwards compatibility for code
10
- * still importing from this module.
11
- */
@@ -1,35 +0,0 @@
1
- import type { CommerceConfig } from "../../config/types.js";
2
- import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
3
- import { defineModule } from "../../kernel/module/index.js";
4
- import type { SettingsService } from "../settings/service.js";
5
- import { DrizzleAnalyticsAdapter } from "./drizzle-adapter.js";
6
- import { BUILTIN_ANALYTICS_MODELS } from "./models.js";
7
- import { RetailReportsEngine } from "./reports.js";
8
- import { AnalyticsService } from "./service.js";
9
-
10
- export const analyticsModule = defineModule<
11
- Record<string, never>,
12
- AnalyticsService,
13
- Record<string, never>
14
- >({
15
- id: "analytics",
16
- schema: () => ({}),
17
- service: (deps) => {
18
- const adapter = new DrizzleAnalyticsAdapter(deps.db.db as DrizzleDatabase);
19
- for (const model of BUILTIN_ANALYTICS_MODELS) {
20
- adapter.registerModel(model);
21
- }
22
- // Settings is resolved lazily from the shared service container — the
23
- // settings module may instantiate after analytics.
24
- const services = deps.services as Record<string, unknown>;
25
- const reports = new RetailReportsEngine(
26
- deps.db.db as DrizzleDatabase,
27
- (orgId, group) => (services.settings as SettingsService).read(orgId, group),
28
- );
29
- return new AnalyticsService({
30
- adapter,
31
- config: deps.config as CommerceConfig,
32
- reports,
33
- });
34
- },
35
- });
@@ -1,5 +0,0 @@
1
- import type { TxContext } from "../../../kernel/database/tx-context.js";
2
-
3
- export interface AnalyticsRepository {
4
- ping(ctx: TxContext): Promise<void>;
5
- }
@@ -1 +0,0 @@
1
- export { auditModule } from "./module.js";
@@ -1,11 +0,0 @@
1
- import { defineModule } from "../../kernel/module/index.js";
2
- import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
3
- import { auditLog } from "./schema.js";
4
- import { createAuditService } from "./service.js";
5
-
6
- export const auditModule = defineModule({
7
- id: "audit",
8
- schema: () => ({ auditLog }),
9
- service: (deps) =>
10
- createAuditService(deps.db.db as DrizzleDatabase),
11
- });
@@ -1,27 +0,0 @@
1
- import type { Actor } from "../../auth/types.js";
2
- import type { Cart } from "./repository/index.js";
3
-
4
- /**
5
- * Determines whether an actor can access a cart.
6
- *
7
- * Access is granted if:
8
- * 1. The actor is authenticated and owns the cart (customerId match)
9
- * 2. The provided secret matches the cart's secret (guest access)
10
- */
11
- export function canAccessCart(
12
- actor: Actor | null,
13
- cart: Cart,
14
- providedSecret?: string,
15
- ): boolean {
16
- // Authenticated owner
17
- if (actor && cart.customerId && actor.userId === cart.customerId) {
18
- return true;
19
- }
20
-
21
- // Valid secret (guest access)
22
- if (providedSecret && cart.secret && providedSecret === cart.secret) {
23
- return true;
24
- }
25
-
26
- return false;
27
- }
@@ -1,32 +0,0 @@
1
- import type { CommerceConfig } from "../../config/types.js";
2
- import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
3
- import { defineModule } from "../../kernel/module/index.js";
4
- import type { CatalogServiceImpl } from "../catalog/service.js";
5
- import type { InventoryService } from "../inventory/service.js";
6
- import { CartRepository } from "./repository/index.js";
7
- import { cartLineItems, carts } from "./schema.js";
8
- import { CartService } from "./service.js";
9
-
10
- type CartModuleDeps = {
11
- catalog: CatalogServiceImpl;
12
- inventory: InventoryService;
13
- };
14
-
15
- export const cartModule = defineModule<
16
- { carts: typeof carts; cartLineItems: typeof cartLineItems },
17
- CartService,
18
- CartModuleDeps
19
- >({
20
- id: "cart",
21
- dependencies: ["catalog", "inventory"],
22
- schema: () => ({ carts, cartLineItems }),
23
- service: (deps) =>
24
- new CartService({
25
- repository: new CartRepository(deps.db.db as DrizzleDatabase),
26
- catalogRepository: deps.services.catalog.repository,
27
- hooks: deps.hooks,
28
- config: deps.config as CommerceConfig,
29
- services: deps.services,
30
- database: deps.db,
31
- }),
32
- });
@@ -1,80 +0,0 @@
1
- import type { CommerceConfig } from "../../config/types.js";
2
- import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
3
- import { defineModule } from "../../kernel/module/index.js";
4
- import type { PricingService } from "../pricing/service.js";
5
- import { CatalogRepository } from "./repository/index.js";
6
- import {
7
- brands,
8
- categories,
9
- tags,
10
- entityTags,
11
- entityBrands,
12
- entityCategories,
13
- optionTypes,
14
- optionValues,
15
- sellableAttributes,
16
- sellableCustomFields,
17
- entityFieldDefinitions,
18
- sellableEntityRevisions,
19
- sellableEntities,
20
- variantOptionValues,
21
- variants,
22
- catalogFieldOwnership,
23
- } from "./schema.js";
24
- import { CatalogServiceImpl } from "./service.js";
25
-
26
- type CatalogModuleDeps = {
27
- pricing: PricingService;
28
- };
29
-
30
- export const catalogModule = defineModule<
31
- {
32
- sellableEntities: typeof sellableEntities;
33
- sellableAttributes: typeof sellableAttributes;
34
- sellableCustomFields: typeof sellableCustomFields;
35
- entityFieldDefinitions: typeof entityFieldDefinitions;
36
- sellableEntityRevisions: typeof sellableEntityRevisions;
37
- categories: typeof categories;
38
- entityCategories: typeof entityCategories;
39
- brands: typeof brands;
40
- entityBrands: typeof entityBrands;
41
- tags: typeof tags;
42
- entityTags: typeof entityTags;
43
- optionTypes: typeof optionTypes;
44
- optionValues: typeof optionValues;
45
- variants: typeof variants;
46
- variantOptionValues: typeof variantOptionValues;
47
- catalogFieldOwnership: typeof catalogFieldOwnership;
48
- },
49
- CatalogServiceImpl,
50
- CatalogModuleDeps
51
- >({
52
- id: "catalog",
53
- dependencies: ["pricing"],
54
- schema: () => ({
55
- sellableEntities,
56
- sellableAttributes,
57
- sellableCustomFields,
58
- entityFieldDefinitions,
59
- sellableEntityRevisions,
60
- categories,
61
- entityCategories,
62
- brands,
63
- entityBrands,
64
- tags,
65
- entityTags,
66
- optionTypes,
67
- optionValues,
68
- variants,
69
- variantOptionValues,
70
- catalogFieldOwnership,
71
- }),
72
- service: (deps) =>
73
- new CatalogServiceImpl({
74
- repository: new CatalogRepository(deps.db.db as DrizzleDatabase),
75
- hooks: deps.hooks,
76
- config: deps.config as CommerceConfig,
77
- services: deps.services,
78
- database: deps.db,
79
- }),
80
- });
@@ -1 +0,0 @@
1
- export { customersModule } from "./module.js";
@@ -1,29 +0,0 @@
1
- import type { CommerceConfig } from "../../config/types.js";
2
- import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
3
- import { defineModule } from "../../kernel/module/index.js";
4
- import { CustomersRepository } from "./repository/index.js";
5
- import { CustomerService } from "./service.js";
6
- import {
7
- customerAddresses,
8
- customerGroupMembers,
9
- customerGroups,
10
- customers,
11
- } from "./schema.js";
12
-
13
- export const customersModule = defineModule({
14
- id: "customers",
15
- schema: () => ({
16
- customers,
17
- customerAddresses,
18
- customerGroups,
19
- customerGroupMembers,
20
- }),
21
- service: (deps) =>
22
- new CustomerService({
23
- repository: new CustomersRepository(deps.db.db as DrizzleDatabase),
24
- hooks: deps.hooks,
25
- config: deps.config as CommerceConfig,
26
- services: deps.services,
27
- database: deps.db,
28
- }),
29
- });
@@ -1,21 +0,0 @@
1
- import type { CommerceConfig } from "../../config/types.js";
2
- import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
3
- import { defineModule } from "../../kernel/module/index.js";
4
- import { DocumentsRepository } from "./repository/index.js";
5
- import { invoiceSequences, orderDocuments } from "./schema.js";
6
- import { DocumentsService } from "./service.js";
7
-
8
- export const documentsModule = defineModule<
9
- { invoiceSequences: typeof invoiceSequences; orderDocuments: typeof orderDocuments },
10
- DocumentsService,
11
- Record<string, never>
12
- >({
13
- id: "documents",
14
- schema: () => ({ invoiceSequences, orderDocuments }),
15
- service: (deps) =>
16
- new DocumentsService({
17
- repository: new DocumentsRepository(deps.db.db as DrizzleDatabase),
18
- services: deps.services as Record<string, unknown>,
19
- config: deps.config as CommerceConfig,
20
- }),
21
- });