@vicacha-devs/medusa-plugin-b2b 0.0.0-stage → 0.0.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 (493) hide show
  1. package/.medusa/server/src/admin/index.cjs +8706 -0
  2. package/.medusa/server/src/admin/index.js +8683 -0
  3. package/.medusa/server/src/api/admin/b2b/approvals/[id]/route.js +24 -0
  4. package/.medusa/server/src/api/admin/b2b/approvals/middlewares.js +23 -0
  5. package/.medusa/server/src/api/admin/b2b/approvals/query-config.js +13 -0
  6. package/.medusa/server/src/api/admin/b2b/approvals/route.js +45 -0
  7. package/.medusa/server/src/api/admin/b2b/approvals/validators.js +15 -0
  8. package/.medusa/server/src/api/admin/b2b/companies/[id]/approval-settings/route.js +36 -0
  9. package/.medusa/server/src/api/admin/b2b/companies/[id]/customer-group/[customerGroupId]/route.js +10 -0
  10. package/.medusa/server/src/api/admin/b2b/companies/[id]/customer-group/route.js +35 -0
  11. package/.medusa/server/src/api/admin/b2b/companies/[id]/employees/[employeeId]/route.js +48 -0
  12. package/.medusa/server/src/api/admin/b2b/companies/[id]/employees/route.js +64 -0
  13. package/.medusa/server/src/api/admin/b2b/companies/[id]/route.js +48 -0
  14. package/.medusa/server/src/api/admin/b2b/companies/middlewares.js +77 -0
  15. package/.medusa/server/src/api/admin/b2b/companies/query-config.js +91 -0
  16. package/.medusa/server/src/api/admin/b2b/companies/route.js +68 -0
  17. package/.medusa/server/src/api/admin/b2b/companies/validators.js +113 -0
  18. package/.medusa/server/src/api/admin/b2b/customers/[id]/employee/route.js +20 -0
  19. package/.medusa/server/src/api/admin/b2b/quotes/[id]/messages/route.js +20 -0
  20. package/.medusa/server/src/api/admin/b2b/quotes/[id]/reject/route.js +19 -0
  21. package/.medusa/server/src/api/admin/b2b/quotes/[id]/route.js +30 -0
  22. package/.medusa/server/src/api/admin/b2b/quotes/[id]/send/route.js +19 -0
  23. package/.medusa/server/src/api/admin/b2b/quotes/middlewares.js +44 -0
  24. package/.medusa/server/src/api/admin/b2b/quotes/query-config.js +43 -0
  25. package/.medusa/server/src/api/admin/b2b/quotes/route.js +54 -0
  26. package/.medusa/server/src/api/admin/b2b/quotes/validators.js +37 -0
  27. package/.medusa/server/src/api/admin/companies/route.js +32 -0
  28. package/.medusa/server/src/api/admin/middlewares.js +9 -0
  29. package/.medusa/server/src/api/admin/validators.js +4 -0
  30. package/.medusa/server/src/api/admin/views/b2b-approvals/columns/route.js +119 -0
  31. package/.medusa/server/src/api/admin/views/b2b-companies/columns/route.js +144 -0
  32. package/.medusa/server/src/api/admin/views/b2b-company-employees/columns/route.js +73 -0
  33. package/.medusa/server/src/api/admin/views/b2b-quotes/columns/route.js +108 -0
  34. package/.medusa/server/src/api/middlewares/ensure-role.js +88 -0
  35. package/.medusa/server/src/api/middlewares.js +20 -0
  36. package/.medusa/server/src/api/store/b2b/approvals/[id]/route.js +24 -0
  37. package/.medusa/server/src/api/store/b2b/approvals/middlewares.js +71 -0
  38. package/.medusa/server/src/api/store/b2b/approvals/query-config.js +13 -0
  39. package/.medusa/server/src/api/store/b2b/approvals/route.js +76 -0
  40. package/.medusa/server/src/api/store/b2b/approvals/validators.js +22 -0
  41. package/.medusa/server/src/api/store/b2b/carts/[id]/approvals/route.js +24 -0
  42. package/.medusa/server/src/api/store/b2b/carts/[id]/line-items/bulk/route.js +26 -0
  43. package/.medusa/server/src/api/store/b2b/carts/middlewares.js +19 -0
  44. package/.medusa/server/src/api/store/b2b/carts/query-config.js +13 -0
  45. package/.medusa/server/src/api/store/b2b/carts/validators.js +12 -0
  46. package/.medusa/server/src/api/store/b2b/companies/[id]/approval-settings/route.js +21 -0
  47. package/.medusa/server/src/api/store/b2b/companies/[id]/employees/[employeeId]/route.js +53 -0
  48. package/.medusa/server/src/api/store/b2b/companies/[id]/employees/route.js +44 -0
  49. package/.medusa/server/src/api/store/b2b/companies/[id]/route.js +39 -0
  50. package/.medusa/server/src/api/store/b2b/companies/middlewares.js +94 -0
  51. package/.medusa/server/src/api/store/b2b/companies/query-config.js +62 -0
  52. package/.medusa/server/src/api/store/b2b/companies/route.js +18 -0
  53. package/.medusa/server/src/api/store/b2b/companies/validators.js +66 -0
  54. package/.medusa/server/src/api/store/b2b/free-shipping/middlewares.js +15 -0
  55. package/.medusa/server/src/api/store/b2b/free-shipping/prices/route.js +41 -0
  56. package/.medusa/server/src/api/store/b2b/free-shipping/utils.js +51 -0
  57. package/.medusa/server/src/api/store/b2b/free-shipping/validators.js +11 -0
  58. package/.medusa/server/src/api/store/b2b/quotes/[id]/accept/route.js +20 -0
  59. package/.medusa/server/src/api/store/b2b/quotes/[id]/messages/route.js +20 -0
  60. package/.medusa/server/src/api/store/b2b/quotes/[id]/preview/route.js +19 -0
  61. package/.medusa/server/src/api/store/b2b/quotes/[id]/reject/route.js +19 -0
  62. package/.medusa/server/src/api/store/b2b/quotes/[id]/route.js +15 -0
  63. package/.medusa/server/src/api/store/b2b/quotes/middlewares.js +64 -0
  64. package/.medusa/server/src/api/store/b2b/quotes/query-config.js +58 -0
  65. package/.medusa/server/src/api/store/b2b/quotes/route.js +39 -0
  66. package/.medusa/server/src/api/store/b2b/quotes/validators.js +35 -0
  67. package/.medusa/server/src/api/store/middlewares.js +13 -0
  68. package/.medusa/server/src/api/store/validators.js +6 -0
  69. package/.medusa/server/src/api/validators.js +3 -0
  70. package/.medusa/server/src/jobs/expire-quotes.js +22 -0
  71. package/.medusa/server/src/links/cart-approval-status.js +12 -0
  72. package/.medusa/server/src/links/cart-approvals.js +13 -0
  73. package/.medusa/server/src/links/company-approval-setting.js +5 -0
  74. package/.medusa/server/src/links/company-carts.js +12 -0
  75. package/.medusa/server/src/links/company-customer-group.js +11 -0
  76. package/.medusa/server/src/links/employee-customer.js +9 -0
  77. package/.medusa/server/src/links/order-company.js +9 -0
  78. package/.medusa/server/src/links/quote-links.js +77 -0
  79. package/.medusa/server/src/modules/approval/index.js +7 -0
  80. package/.medusa/server/src/modules/approval/migrations/Migration20260912010000.js +22 -0
  81. package/.medusa/server/src/modules/approval/models/approval-settings.js +21 -0
  82. package/.medusa/server/src/modules/approval/models/approval-status.js +21 -0
  83. package/.medusa/server/src/modules/approval/models/approval.js +36 -0
  84. package/.medusa/server/src/modules/approval/models/index.js +4 -0
  85. package/.medusa/server/src/modules/approval/service.js +18 -0
  86. package/.medusa/server/src/modules/company/index.js +7 -0
  87. package/.medusa/server/src/modules/company/migrations/Migration20260912010000.js +24 -0
  88. package/.medusa/server/src/modules/company/models/company.js +44 -0
  89. package/.medusa/server/src/modules/company/models/employee.js +30 -0
  90. package/.medusa/server/src/modules/company/models/index.js +3 -0
  91. package/.medusa/server/src/modules/company/service.js +9 -0
  92. package/.medusa/server/src/modules/company/types/common.js +2 -0
  93. package/.medusa/server/src/modules/company/types/mutations.js +2 -0
  94. package/.medusa/server/src/modules/quote/index.js +5 -0
  95. package/.medusa/server/src/modules/quote/migrations/Migration20260912010000.js +29 -0
  96. package/.medusa/server/src/modules/quote/models/index.js +3 -0
  97. package/.medusa/server/src/modules/quote/models/message.js +34 -0
  98. package/.medusa/server/src/modules/quote/models/quote.js +57 -0
  99. package/.medusa/server/src/modules/quote/service.js +6 -0
  100. package/.medusa/server/src/rbac.js +122 -0
  101. package/.medusa/server/src/scripts/seed-b2b-data.js +99 -0
  102. package/.medusa/server/src/scripts/seed-b2b-test-data.js +813 -0
  103. package/.medusa/server/src/types/approval/http.js +2 -0
  104. package/.medusa/server/src/types/approval/index.js +5 -0
  105. package/.medusa/server/src/types/approval/module.js +14 -0
  106. package/.medusa/server/src/types/approval/query.js +2 -0
  107. package/.medusa/server/src/types/approval/service.js +2 -0
  108. package/.medusa/server/src/types/company/http.js +2 -0
  109. package/.medusa/server/src/types/company/index.js +5 -0
  110. package/.medusa/server/src/types/company/module.js +3 -0
  111. package/.medusa/server/src/types/company/query.js +2 -0
  112. package/.medusa/server/src/types/company/service.js +2 -0
  113. package/.medusa/server/src/types/constants.js +16 -0
  114. package/.medusa/server/src/types/enums.js +18 -0
  115. package/.medusa/server/src/types/index.js +6 -0
  116. package/.medusa/server/src/types/quote/http.js +2 -0
  117. package/.medusa/server/src/types/quote/index.js +5 -0
  118. package/.medusa/server/src/types/quote/module.js +3 -0
  119. package/.medusa/server/src/types/quote/query.js +2 -0
  120. package/.medusa/server/src/types/quote/service.js +2 -0
  121. package/.medusa/server/src/types/shipping-options/http.js +2 -0
  122. package/.medusa/server/src/types/shipping-options/index.js +2 -0
  123. package/.medusa/server/src/types/types.js +2 -0
  124. package/.medusa/server/src/utils/check-spending-limit.js +51 -0
  125. package/.medusa/server/src/utils/get-cart-approval-status.js +22 -0
  126. package/.medusa/server/src/workflows/approval/steps/create-approval-settings.js +18 -0
  127. package/.medusa/server/src/workflows/approval/steps/create-approval-status.js +37 -0
  128. package/.medusa/server/src/workflows/approval/steps/create-approvals.js +55 -0
  129. package/.medusa/server/src/workflows/approval/steps/delete-approval-settings.js +23 -0
  130. package/.medusa/server/src/workflows/approval/steps/delete-approvals.js +11 -0
  131. package/.medusa/server/src/workflows/approval/steps/index.js +9 -0
  132. package/.medusa/server/src/workflows/approval/steps/update-approval-settings.js +12 -0
  133. package/.medusa/server/src/workflows/approval/steps/update-approval-statuses.js +49 -0
  134. package/.medusa/server/src/workflows/approval/steps/update-approval.js +60 -0
  135. package/.medusa/server/src/workflows/approval/workflows/create-approval-settings.js +20 -0
  136. package/.medusa/server/src/workflows/approval/workflows/create-approvals.js +43 -0
  137. package/.medusa/server/src/workflows/approval/workflows/index.js +5 -0
  138. package/.medusa/server/src/workflows/approval/workflows/update-approval-settings.js +6 -0
  139. package/.medusa/server/src/workflows/approval/workflows/update-approval.js +8 -0
  140. package/.medusa/server/src/workflows/company/steps/add-company-employees-to-customer-group.js +41 -0
  141. package/.medusa/server/src/workflows/company/steps/create-companies.js +14 -0
  142. package/.medusa/server/src/workflows/company/steps/delete-companies.js +11 -0
  143. package/.medusa/server/src/workflows/company/steps/dismiss-company-customer-group-link.js +40 -0
  144. package/.medusa/server/src/workflows/company/steps/index.js +7 -0
  145. package/.medusa/server/src/workflows/company/steps/remove-company-employees-from-customer-group.js +39 -0
  146. package/.medusa/server/src/workflows/company/steps/update-companies.js +14 -0
  147. package/.medusa/server/src/workflows/company/workflows/add-company-to-customer-group.js +25 -0
  148. package/.medusa/server/src/workflows/company/workflows/create-companies.js +21 -0
  149. package/.medusa/server/src/workflows/company/workflows/delete-companies.js +12 -0
  150. package/.medusa/server/src/workflows/company/workflows/index.js +6 -0
  151. package/.medusa/server/src/workflows/company/workflows/remove-company-from-customer-group.js +22 -0
  152. package/.medusa/server/src/workflows/company/workflows/update-companies.js +6 -0
  153. package/.medusa/server/src/workflows/employee/steps/add-employee-to-customer-group.js +41 -0
  154. package/.medusa/server/src/workflows/employee/steps/create-employees.js +20 -0
  155. package/.medusa/server/src/workflows/employee/steps/delete-employees.js +14 -0
  156. package/.medusa/server/src/workflows/employee/steps/index.js +8 -0
  157. package/.medusa/server/src/workflows/employee/steps/link-employee-to-customer.js +29 -0
  158. package/.medusa/server/src/workflows/employee/steps/remove-admin-role.js +37 -0
  159. package/.medusa/server/src/workflows/employee/steps/set-admin-role.js +56 -0
  160. package/.medusa/server/src/workflows/employee/steps/sync-customer-company-name.js +41 -0
  161. package/.medusa/server/src/workflows/employee/steps/update-employees.js +29 -0
  162. package/.medusa/server/src/workflows/employee/workflows/create-employees.js +34 -0
  163. package/.medusa/server/src/workflows/employee/workflows/delete-employees.js +15 -0
  164. package/.medusa/server/src/workflows/employee/workflows/index.js +4 -0
  165. package/.medusa/server/src/workflows/employee/workflows/update-employees.js +14 -0
  166. package/.medusa/server/src/workflows/hooks/cart-created.js +37 -0
  167. package/.medusa/server/src/workflows/hooks/order-created.js +30 -0
  168. package/.medusa/server/src/workflows/hooks/validate-add-to-cart.js +20 -0
  169. package/.medusa/server/src/workflows/hooks/validate-cart-completion.js +38 -0
  170. package/.medusa/server/src/workflows/hooks/validate-update-cart.js +20 -0
  171. package/.medusa/server/src/workflows/index.js +6 -0
  172. package/.medusa/server/src/workflows/order/steps/update-order.js +28 -0
  173. package/.medusa/server/src/workflows/order/workflows/update-order.js +21 -0
  174. package/.medusa/server/src/workflows/quote/steps/create-quote-message.js +18 -0
  175. package/.medusa/server/src/workflows/quote/steps/create-quotes.js +18 -0
  176. package/.medusa/server/src/workflows/quote/steps/update-quotes.js +28 -0
  177. package/.medusa/server/src/workflows/quote/steps/validate-quote-acceptance.js +11 -0
  178. package/.medusa/server/src/workflows/quote/steps/validate-quote-rejection.js +10 -0
  179. package/.medusa/server/src/workflows/quote/workflows/create-quote-message.js +11 -0
  180. package/.medusa/server/src/workflows/quote/workflows/create-quote.js +9 -0
  181. package/.medusa/server/src/workflows/quote/workflows/create-request-for-quote.js +84 -0
  182. package/.medusa/server/src/workflows/quote/workflows/customer-accept-quote.js +39 -0
  183. package/.medusa/server/src/workflows/quote/workflows/customer-reject-quote.js +27 -0
  184. package/.medusa/server/src/workflows/quote/workflows/index.js +9 -0
  185. package/.medusa/server/src/workflows/quote/workflows/merchant-reject-quote.js +28 -0
  186. package/.medusa/server/src/workflows/quote/workflows/merchant-send-quote.js +29 -0
  187. package/.medusa/server/src/workflows/quote/workflows/update-quote.js +9 -0
  188. package/LICENSE +21 -0
  189. package/README.md +587 -2
  190. package/package.json +121 -3
  191. package/src/__tests__/b2b-contract.spec.ts +41 -0
  192. package/src/admin/README.md +73 -0
  193. package/src/admin/constants.ts +1 -0
  194. package/src/admin/hooks/api/approvals.tsx +106 -0
  195. package/src/admin/hooks/api/companies.tsx +288 -0
  196. package/src/admin/hooks/api/customers.tsx +44 -0
  197. package/src/admin/hooks/api/employees.tsx +170 -0
  198. package/src/admin/hooks/api/index.ts +5 -0
  199. package/src/admin/hooks/api/quotes.tsx +329 -0
  200. package/src/admin/i18n/README.md +78 -0
  201. package/src/admin/i18n/index.ts +23 -0
  202. package/src/admin/i18n/json/ar.json +388 -0
  203. package/src/admin/i18n/json/de.json +388 -0
  204. package/src/admin/i18n/json/en.json +388 -0
  205. package/src/admin/i18n/json/es.json +388 -0
  206. package/src/admin/i18n/json/fr.json +388 -0
  207. package/src/admin/i18n/json/it.json +388 -0
  208. package/src/admin/i18n/json/nl.json +388 -0
  209. package/src/admin/i18n/json/pl.json +388 -0
  210. package/src/admin/i18n/json/pt.json +388 -0
  211. package/src/admin/i18n/json/tr.json +388 -0
  212. package/src/admin/routes/b2b/approvals/components/approval-actions.tsx +129 -0
  213. package/src/admin/routes/b2b/approvals/components/approval-status-badge.tsx +24 -0
  214. package/src/admin/routes/b2b/approvals/components/approvals-items-popover.tsx +69 -0
  215. package/src/admin/routes/b2b/approvals/components/approvals-table-adapter.tsx +45 -0
  216. package/src/admin/routes/b2b/approvals/components/approvals-table-renderers.tsx +74 -0
  217. package/src/admin/routes/b2b/approvals/components/approvals-table.tsx +66 -0
  218. package/src/admin/routes/b2b/approvals/components/table/columns.tsx +113 -0
  219. package/src/admin/routes/b2b/approvals/components/table/filters.tsx +30 -0
  220. package/src/admin/routes/b2b/approvals/components/table/query.tsx +25 -0
  221. package/src/admin/routes/b2b/approvals/page.tsx +66 -0
  222. package/src/admin/routes/b2b/companies/@create/page.tsx +70 -0
  223. package/src/admin/routes/b2b/companies/[id]/@approval-settings/page.tsx +106 -0
  224. package/src/admin/routes/b2b/companies/[id]/@customer-group/page.tsx +152 -0
  225. package/src/admin/routes/b2b/companies/[id]/@edit/page.tsx +93 -0
  226. package/src/admin/routes/b2b/companies/[id]/@employee/[employeeId]/page.tsx +82 -0
  227. package/src/admin/routes/b2b/companies/[id]/@employee/components/employees-actions-menu.tsx +61 -0
  228. package/src/admin/routes/b2b/companies/[id]/@employee/components/employees-create-form.tsx +190 -0
  229. package/src/admin/routes/b2b/companies/[id]/@employee/components/employees-update-form.tsx +160 -0
  230. package/src/admin/routes/b2b/companies/[id]/@employee/components/index.ts +3 -0
  231. package/src/admin/routes/b2b/companies/[id]/@employee/components/validators.ts +25 -0
  232. package/src/admin/routes/b2b/companies/[id]/@employee/create/page.tsx +91 -0
  233. package/src/admin/routes/b2b/companies/[id]/components/company-approval-settings-section.tsx +67 -0
  234. package/src/admin/routes/b2b/companies/[id]/components/company-customer-group-section.tsx +55 -0
  235. package/src/admin/routes/b2b/companies/[id]/components/company-employees-section.tsx +70 -0
  236. package/src/admin/routes/b2b/companies/[id]/components/company-employees-table-renderers.tsx +53 -0
  237. package/src/admin/routes/b2b/companies/[id]/components/company-general-section.tsx +59 -0
  238. package/src/admin/routes/b2b/companies/[id]/page.tsx +85 -0
  239. package/src/admin/routes/b2b/companies/components/companies-table-adapter.tsx +46 -0
  240. package/src/admin/routes/b2b/companies/components/companies-table-renderers.tsx +53 -0
  241. package/src/admin/routes/b2b/companies/components/companies-table.tsx +83 -0
  242. package/src/admin/routes/b2b/companies/components/company-actions-menu.tsx +46 -0
  243. package/src/admin/routes/b2b/companies/components/company-create-admin-tab.tsx +185 -0
  244. package/src/admin/routes/b2b/companies/components/company-create-details-tab.tsx +169 -0
  245. package/src/admin/routes/b2b/companies/components/company-create-form.tsx +201 -0
  246. package/src/admin/routes/b2b/companies/components/company-form-admin-tab.tsx +99 -0
  247. package/src/admin/routes/b2b/companies/components/company-form-details-tab.tsx +159 -0
  248. package/src/admin/routes/b2b/companies/components/company-form.tsx +159 -0
  249. package/src/admin/routes/b2b/companies/components/index.ts +9 -0
  250. package/src/admin/routes/b2b/companies/components/table/columns.tsx +81 -0
  251. package/src/admin/routes/b2b/companies/components/table/filters.tsx +23 -0
  252. package/src/admin/routes/b2b/companies/components/table/query.tsx +27 -0
  253. package/src/admin/routes/b2b/companies/components/use-delete-company-list-action.tsx +37 -0
  254. package/src/admin/routes/b2b/companies/components/validators.ts +49 -0
  255. package/src/admin/routes/b2b/companies/page.tsx +66 -0
  256. package/src/admin/routes/b2b/components/index.ts +6 -0
  257. package/src/admin/routes/b2b/components/navigation-card.tsx +51 -0
  258. package/src/admin/routes/b2b/components/stat-card.tsx +48 -0
  259. package/src/admin/routes/b2b/page.tsx +173 -0
  260. package/src/admin/routes/b2b/quotes/[id]/components/index.ts +8 -0
  261. package/src/admin/routes/b2b/quotes/[id]/components/quote-company-section.tsx +54 -0
  262. package/src/admin/routes/b2b/quotes/[id]/components/quote-customer-section.tsx +75 -0
  263. package/src/admin/routes/b2b/quotes/[id]/components/quote-detail-actions.tsx +57 -0
  264. package/src/admin/routes/b2b/quotes/[id]/components/quote-general-section.tsx +66 -0
  265. package/src/admin/routes/b2b/quotes/[id]/components/quote-message-bubble.tsx +132 -0
  266. package/src/admin/routes/b2b/quotes/[id]/components/quote-message-composer.tsx +135 -0
  267. package/src/admin/routes/b2b/quotes/[id]/components/quote-messages-section.tsx +100 -0
  268. package/src/admin/routes/b2b/quotes/[id]/components/quote-order-section.tsx +115 -0
  269. package/src/admin/routes/b2b/quotes/[id]/components/validators.ts +8 -0
  270. package/src/admin/routes/b2b/quotes/[id]/manage/components/index.ts +7 -0
  271. package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-item-info.tsx +63 -0
  272. package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-item-price-form.tsx +60 -0
  273. package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-item.tsx +227 -0
  274. package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-items-section.tsx +145 -0
  275. package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-items-table.tsx +117 -0
  276. package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-quote-form.tsx +187 -0
  277. package/src/admin/routes/b2b/quotes/[id]/manage/components/table/columns.tsx +29 -0
  278. package/src/admin/routes/b2b/quotes/[id]/manage/components/table/filters.tsx +8 -0
  279. package/src/admin/routes/b2b/quotes/[id]/manage/components/table/index.ts +3 -0
  280. package/src/admin/routes/b2b/quotes/[id]/manage/components/table/query.tsx +25 -0
  281. package/src/admin/routes/b2b/quotes/[id]/manage/components/validators.ts +5 -0
  282. package/src/admin/routes/b2b/quotes/[id]/manage/page.tsx +60 -0
  283. package/src/admin/routes/b2b/quotes/[id]/page.tsx +213 -0
  284. package/src/admin/routes/b2b/quotes/components/index.ts +4 -0
  285. package/src/admin/routes/b2b/quotes/components/quote-actions-menu.tsx +119 -0
  286. package/src/admin/routes/b2b/quotes/components/quote-status-badge.tsx +30 -0
  287. package/src/admin/routes/b2b/quotes/components/quotes-table-adapter.tsx +43 -0
  288. package/src/admin/routes/b2b/quotes/components/quotes-table-renderers.tsx +87 -0
  289. package/src/admin/routes/b2b/quotes/components/quotes-table.tsx +70 -0
  290. package/src/admin/routes/b2b/quotes/components/send-quote-drawer.tsx +69 -0
  291. package/src/admin/routes/b2b/quotes/components/table/columns.tsx +75 -0
  292. package/src/admin/routes/b2b/quotes/components/table/filters.tsx +44 -0
  293. package/src/admin/routes/b2b/quotes/components/table/query.tsx +27 -0
  294. package/src/admin/routes/b2b/quotes/page.tsx +65 -0
  295. package/src/admin/tsconfig.json +23 -0
  296. package/src/admin/validators.ts +4 -0
  297. package/src/admin/vite-env.d.ts +1 -0
  298. package/src/admin/widgets/customer-company-widget.tsx +63 -0
  299. package/src/admin/widgets/customer-employee-widget.tsx +48 -0
  300. package/src/admin/widgets/customer-group-companies-widget.tsx +68 -0
  301. package/src/api/README.md +64 -0
  302. package/src/api/admin/b2b/approvals/[id]/route.ts +34 -0
  303. package/src/api/admin/b2b/approvals/middlewares.ts +31 -0
  304. package/src/api/admin/b2b/approvals/query-config.ts +13 -0
  305. package/src/api/admin/b2b/approvals/route.ts +56 -0
  306. package/src/api/admin/b2b/approvals/validators.ts +23 -0
  307. package/src/api/admin/b2b/companies/[id]/approval-settings/route.ts +57 -0
  308. package/src/api/admin/b2b/companies/[id]/customer-group/[customerGroupId]/route.ts +17 -0
  309. package/src/api/admin/b2b/companies/[id]/customer-group/route.ts +56 -0
  310. package/src/api/admin/b2b/companies/[id]/employees/[employeeId]/route.ts +84 -0
  311. package/src/api/admin/b2b/companies/[id]/employees/route.ts +90 -0
  312. package/src/api/admin/b2b/companies/[id]/route.ts +88 -0
  313. package/src/api/admin/b2b/companies/middlewares.ts +123 -0
  314. package/src/api/admin/b2b/companies/query-config.ts +99 -0
  315. package/src/api/admin/b2b/companies/route.ts +101 -0
  316. package/src/api/admin/b2b/companies/validators.ts +165 -0
  317. package/src/api/admin/b2b/customers/[id]/employee/route.ts +31 -0
  318. package/src/api/admin/b2b/quotes/[id]/messages/route.ts +36 -0
  319. package/src/api/admin/b2b/quotes/[id]/reject/route.ts +35 -0
  320. package/src/api/admin/b2b/quotes/[id]/route.ts +48 -0
  321. package/src/api/admin/b2b/quotes/[id]/send/route.ts +35 -0
  322. package/src/api/admin/b2b/quotes/middlewares.ts +71 -0
  323. package/src/api/admin/b2b/quotes/query-config.ts +45 -0
  324. package/src/api/admin/b2b/quotes/route.ts +72 -0
  325. package/src/api/admin/b2b/quotes/validators.ts +49 -0
  326. package/src/api/admin/companies/route.ts +43 -0
  327. package/src/api/admin/middlewares.ts +10 -0
  328. package/src/api/admin/validators.ts +3 -0
  329. package/src/api/admin/views/b2b-approvals/columns/route.ts +121 -0
  330. package/src/api/admin/views/b2b-companies/columns/route.ts +146 -0
  331. package/src/api/admin/views/b2b-company-employees/columns/route.ts +74 -0
  332. package/src/api/admin/views/b2b-quotes/columns/route.ts +110 -0
  333. package/src/api/middlewares/ensure-role.ts +138 -0
  334. package/src/api/middlewares.ts +26 -0
  335. package/src/api/store/b2b/approvals/[id]/route.ts +34 -0
  336. package/src/api/store/b2b/approvals/middlewares.ts +103 -0
  337. package/src/api/store/b2b/approvals/query-config.ts +13 -0
  338. package/src/api/store/b2b/approvals/route.ts +105 -0
  339. package/src/api/store/b2b/approvals/validators.ts +30 -0
  340. package/src/api/store/b2b/carts/[id]/approvals/route.ts +33 -0
  341. package/src/api/store/b2b/carts/[id]/line-items/bulk/route.ts +46 -0
  342. package/src/api/store/b2b/carts/middlewares.ts +27 -0
  343. package/src/api/store/b2b/carts/query-config.ts +13 -0
  344. package/src/api/store/b2b/carts/validators.ts +19 -0
  345. package/src/api/store/b2b/companies/[id]/approval-settings/route.ts +33 -0
  346. package/src/api/store/b2b/companies/[id]/employees/[employeeId]/route.ts +86 -0
  347. package/src/api/store/b2b/companies/[id]/employees/route.ts +72 -0
  348. package/src/api/store/b2b/companies/[id]/route.ts +70 -0
  349. package/src/api/store/b2b/companies/middlewares.ts +137 -0
  350. package/src/api/store/b2b/companies/query-config.ts +76 -0
  351. package/src/api/store/b2b/companies/route.ts +34 -0
  352. package/src/api/store/b2b/companies/validators.ts +88 -0
  353. package/src/api/store/b2b/free-shipping/middlewares.ts +16 -0
  354. package/src/api/store/b2b/free-shipping/prices/route.ts +71 -0
  355. package/src/api/store/b2b/free-shipping/utils.ts +60 -0
  356. package/src/api/store/b2b/free-shipping/validators.ts +16 -0
  357. package/src/api/store/b2b/quotes/[id]/accept/route.ts +36 -0
  358. package/src/api/store/b2b/quotes/[id]/messages/route.ts +36 -0
  359. package/src/api/store/b2b/quotes/[id]/preview/route.ts +45 -0
  360. package/src/api/store/b2b/quotes/[id]/reject/route.ts +35 -0
  361. package/src/api/store/b2b/quotes/[id]/route.ts +30 -0
  362. package/src/api/store/b2b/quotes/middlewares.ts +96 -0
  363. package/src/api/store/b2b/quotes/query-config.ts +59 -0
  364. package/src/api/store/b2b/quotes/route.ts +65 -0
  365. package/src/api/store/b2b/quotes/validators.ts +51 -0
  366. package/src/api/store/middlewares.ts +14 -0
  367. package/src/api/store/validators.ts +5 -0
  368. package/src/api/validators.ts +2 -0
  369. package/src/jobs/expire-quotes.ts +31 -0
  370. package/src/links/README.md +62 -0
  371. package/src/links/cart-approval-status.ts +14 -0
  372. package/src/links/cart-approvals.ts +15 -0
  373. package/src/links/company-approval-setting.ts +8 -0
  374. package/src/links/company-carts.ts +14 -0
  375. package/src/links/company-customer-group.ts +16 -0
  376. package/src/links/employee-customer.ts +14 -0
  377. package/src/links/order-company.ts +14 -0
  378. package/src/links/quote-links.ts +77 -0
  379. package/src/modules/README.md +75 -0
  380. package/src/modules/approval/index.ts +8 -0
  381. package/src/modules/approval/migrations/Migration20260912010000.ts +47 -0
  382. package/src/modules/approval/models/approval-settings.ts +21 -0
  383. package/src/modules/approval/models/approval-status.ts +21 -0
  384. package/src/modules/approval/models/approval.ts +36 -0
  385. package/src/modules/approval/models/index.ts +3 -0
  386. package/src/modules/approval/service.ts +20 -0
  387. package/src/modules/company/index.ts +8 -0
  388. package/src/modules/company/migrations/Migration20260912010000.ts +50 -0
  389. package/src/modules/company/models/company.ts +44 -0
  390. package/src/modules/company/models/employee.ts +30 -0
  391. package/src/modules/company/models/index.ts +2 -0
  392. package/src/modules/company/service.ts +9 -0
  393. package/src/modules/company/types/common.ts +30 -0
  394. package/src/modules/company/types/mutations.ts +30 -0
  395. package/src/modules/quote/index.ts +6 -0
  396. package/src/modules/quote/migrations/Migration20260912010000.ts +65 -0
  397. package/src/modules/quote/models/index.ts +2 -0
  398. package/src/modules/quote/models/message.ts +35 -0
  399. package/src/modules/quote/models/quote.ts +58 -0
  400. package/src/modules/quote/service.ts +6 -0
  401. package/src/rbac.ts +136 -0
  402. package/src/scripts/README.md +40 -0
  403. package/src/scripts/seed-b2b-data.ts +177 -0
  404. package/src/scripts/seed-b2b-test-data.ts +986 -0
  405. package/src/types/README.md +52 -0
  406. package/src/types/approval/http.ts +56 -0
  407. package/src/types/approval/index.ts +4 -0
  408. package/src/types/approval/module.ts +77 -0
  409. package/src/types/approval/query.ts +11 -0
  410. package/src/types/approval/service.ts +126 -0
  411. package/src/types/company/http.ts +126 -0
  412. package/src/types/company/index.ts +4 -0
  413. package/src/types/company/module.ts +78 -0
  414. package/src/types/company/query.ts +15 -0
  415. package/src/types/company/service.ts +109 -0
  416. package/src/types/constants.ts +16 -0
  417. package/src/types/enums.ts +16 -0
  418. package/src/types/index.ts +5 -0
  419. package/src/types/quote/http.ts +50 -0
  420. package/src/types/quote/index.ts +4 -0
  421. package/src/types/quote/module.ts +45 -0
  422. package/src/types/quote/query.ts +22 -0
  423. package/src/types/quote/service.ts +65 -0
  424. package/src/types/shipping-options/http.ts +7 -0
  425. package/src/types/shipping-options/index.ts +1 -0
  426. package/src/types/types.ts +5 -0
  427. package/src/utils/README.md +37 -0
  428. package/src/utils/check-spending-limit.ts +81 -0
  429. package/src/utils/get-cart-approval-status.ts +35 -0
  430. package/src/workflows/README.md +85 -0
  431. package/src/workflows/approval/steps/create-approval-settings.ts +34 -0
  432. package/src/workflows/approval/steps/create-approval-status.ts +56 -0
  433. package/src/workflows/approval/steps/create-approvals.ts +114 -0
  434. package/src/workflows/approval/steps/delete-approval-settings.ts +52 -0
  435. package/src/workflows/approval/steps/delete-approvals.ts +21 -0
  436. package/src/workflows/approval/steps/index.ts +8 -0
  437. package/src/workflows/approval/steps/update-approval-settings.ts +27 -0
  438. package/src/workflows/approval/steps/update-approval-statuses.ts +77 -0
  439. package/src/workflows/approval/steps/update-approval.ts +87 -0
  440. package/src/workflows/approval/workflows/create-approval-settings.ts +32 -0
  441. package/src/workflows/approval/workflows/create-approvals.ts +60 -0
  442. package/src/workflows/approval/workflows/index.ts +4 -0
  443. package/src/workflows/approval/workflows/update-approval-settings.ts +13 -0
  444. package/src/workflows/approval/workflows/update-approval.ts +17 -0
  445. package/src/workflows/company/steps/add-company-employees-to-customer-group.ts +74 -0
  446. package/src/workflows/company/steps/create-companies.ts +28 -0
  447. package/src/workflows/company/steps/delete-companies.ts +21 -0
  448. package/src/workflows/company/steps/dismiss-company-customer-group-link.ts +53 -0
  449. package/src/workflows/company/steps/index.ts +6 -0
  450. package/src/workflows/company/steps/remove-company-employees-from-customer-group.ts +76 -0
  451. package/src/workflows/company/steps/update-companies.ts +25 -0
  452. package/src/workflows/company/workflows/add-company-to-customer-group.ts +34 -0
  453. package/src/workflows/company/workflows/create-companies.ts +35 -0
  454. package/src/workflows/company/workflows/delete-companies.ts +18 -0
  455. package/src/workflows/company/workflows/index.ts +5 -0
  456. package/src/workflows/company/workflows/remove-company-from-customer-group.ts +30 -0
  457. package/src/workflows/company/workflows/update-companies.ts +13 -0
  458. package/src/workflows/employee/steps/add-employee-to-customer-group.ts +81 -0
  459. package/src/workflows/employee/steps/create-employees.ts +46 -0
  460. package/src/workflows/employee/steps/delete-employees.ts +25 -0
  461. package/src/workflows/employee/steps/index.ts +7 -0
  462. package/src/workflows/employee/steps/link-employee-to-customer.ts +49 -0
  463. package/src/workflows/employee/steps/remove-admin-role.ts +59 -0
  464. package/src/workflows/employee/steps/set-admin-role.ts +89 -0
  465. package/src/workflows/employee/steps/sync-customer-company-name.ts +83 -0
  466. package/src/workflows/employee/steps/update-employees.ts +61 -0
  467. package/src/workflows/employee/workflows/create-employees.ts +61 -0
  468. package/src/workflows/employee/workflows/delete-employees.ts +26 -0
  469. package/src/workflows/employee/workflows/index.ts +3 -0
  470. package/src/workflows/employee/workflows/update-employees.ts +31 -0
  471. package/src/workflows/hooks/cart-created.ts +56 -0
  472. package/src/workflows/hooks/order-created.ts +38 -0
  473. package/src/workflows/hooks/validate-add-to-cart.ts +32 -0
  474. package/src/workflows/hooks/validate-cart-completion.ts +61 -0
  475. package/src/workflows/hooks/validate-update-cart.ts +32 -0
  476. package/src/workflows/index.ts +5 -0
  477. package/src/workflows/order/steps/update-order.ts +53 -0
  478. package/src/workflows/order/workflows/update-order.ts +28 -0
  479. package/src/workflows/quote/steps/create-quote-message.ts +33 -0
  480. package/src/workflows/quote/steps/create-quotes.ts +32 -0
  481. package/src/workflows/quote/steps/update-quotes.ts +48 -0
  482. package/src/workflows/quote/steps/validate-quote-acceptance.ts +22 -0
  483. package/src/workflows/quote/steps/validate-quote-rejection.ts +17 -0
  484. package/src/workflows/quote/workflows/create-quote-message.ts +20 -0
  485. package/src/workflows/quote/workflows/create-quote.ts +16 -0
  486. package/src/workflows/quote/workflows/create-request-for-quote.ts +102 -0
  487. package/src/workflows/quote/workflows/customer-accept-quote.ts +49 -0
  488. package/src/workflows/quote/workflows/customer-reject-quote.ts +31 -0
  489. package/src/workflows/quote/workflows/index.ts +8 -0
  490. package/src/workflows/quote/workflows/merchant-reject-quote.ts +34 -0
  491. package/src/workflows/quote/workflows/merchant-send-quote.ts +33 -0
  492. package/src/workflows/quote/workflows/update-quote.ts +16 -0
  493. package/tsconfig.json +40 -0
@@ -0,0 +1,52 @@
1
+ # Types
2
+
3
+ Shared TypeScript types for the plugin's public surface — HTTP request/response shapes, module-level data types, query result types, and service interfaces.
4
+
5
+ ```
6
+ types/
7
+ ├── index.ts re-exports everything from all domain folders
8
+ ├── company/
9
+ │ ├── http.ts Admin* and Store* request/response types
10
+ │ ├── module.ts ModuleCompany, ModuleEmployee, enums, ICompanyModuleService
11
+ │ ├── query.ts QueryCompany, QueryEmployee (remoteQuery result shapes)
12
+ │ └── service.ts service-level create/update/delete input types
13
+ ├── quote/
14
+ │ ├── http.ts AdminQuoteResponse, StoreQuoteResponse, …
15
+ │ ├── module.ts ModuleQuote, ModuleQuoteMessage, IQuoteModuleService
16
+ │ ├── query.ts QueryQuote
17
+ │ └── service.ts CreateQuoteType, QuoteFilterParams
18
+ ├── approval/
19
+ │ ├── http.ts AdminUpdateApproval, StoreGetApprovalsType, …
20
+ │ ├── module.ts ModuleApproval, ApprovalType, ApprovalStatusType, IApprovalModuleService
21
+ │ └── query.ts QueryApproval
22
+ └── shipping-options/
23
+ └── index.ts StoreFreeShippingPrice
24
+ ```
25
+
26
+ ---
27
+
28
+ ## File conventions
29
+
30
+ | File | Contains |
31
+ | ------------ | ---------------------------------------------------------------------------------------------------- |
32
+ | `http.ts` | Types consumed by API route handlers and the admin hooks — prefixed `Admin*` or `Store*` |
33
+ | `module.ts` | Data-model types mirroring entity fields, enums, and service interfaces — prefixed `Module*` or `I*` |
34
+ | `query.ts` | Expanded types returned by `remoteQuery` — prefixed `Query*` |
35
+ | `service.ts` | Input types for workflow steps when they differ from the HTTP types |
36
+
37
+ ## Usage
38
+
39
+ Import from the barrel export in `src/types` (or via the `@/types` alias):
40
+
41
+ ```ts
42
+ import type { ICompanyModuleService, ModuleCompany } from "@/types"
43
+ import type { AdminCreateCompany } from "@/types"
44
+ ```
45
+
46
+ Do not import from individual sub-files outside of `src/types/` — the barrel is the stable surface.
47
+
48
+ ## Adding types for a new domain
49
+
50
+ 1. Create a folder under `src/types/<domain>/`.
51
+ 2. Add `http.ts`, `module.ts`, `query.ts`, and `service.ts` as needed.
52
+ 3. Re-export from `src/types/index.ts`.
@@ -0,0 +1,56 @@
1
+ import { QueryCompany } from "../company/query"
2
+ import { ApprovalStatusType, ApprovalType } from "./module"
3
+ import {
4
+ QueryApproval,
5
+ QueryApprovalSettings,
6
+ QueryApprovalStatus,
7
+ } from "./query"
8
+ import { HttpTypes } from "@medusajs/framework/types"
9
+
10
+ /* Admin */
11
+ export type AdminApprovalSettings = QueryApprovalSettings
12
+
13
+ export type AdminUpdateApprovalSettings = {
14
+ requires_admin_approval: boolean
15
+ requires_sales_manager_approval: boolean
16
+ }
17
+
18
+ export type AdminApproval = QueryApproval
19
+
20
+ export type AdminApprovalsResponse = {
21
+ carts_with_approvals: AdminCartWithApprovals[]
22
+ count: number
23
+ }
24
+
25
+ export type AdminCartWithApprovals = HttpTypes.StoreCart & {
26
+ company: QueryCompany
27
+ approval_status: QueryApprovalStatus
28
+ approvals: QueryApproval[]
29
+ }
30
+
31
+ export type AdminUpdateApproval = {
32
+ status: ApprovalStatusType
33
+ reason?: string | null
34
+ }
35
+
36
+ export type AdminApprovalStatus = QueryApprovalStatus
37
+ /* Store */
38
+ export type StoreApprovalSettings = QueryApprovalSettings
39
+
40
+ export type StoreUpdateApprovalSettings = {
41
+ requires_admin_approval: boolean
42
+ requires_sales_manager_approval: boolean
43
+ }
44
+
45
+ export type StoreApproval = QueryApproval
46
+
47
+ export type StoreCreateApproval = {
48
+ cart_id: string
49
+ type: ApprovalType
50
+ created_by: string
51
+ }
52
+
53
+ export type StoreUpdateApproval = {
54
+ status: ApprovalStatusType
55
+ reason?: string | null
56
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./http"
2
+ export * from "./module"
3
+ export * from "./query"
4
+ export * from "./service"
@@ -0,0 +1,77 @@
1
+ /* Entity: Approval Settings */
2
+
3
+ export type ModuleApprovalSettings = {
4
+ id: string
5
+ company_id: string
6
+ requires_admin_approval: boolean
7
+ requires_sales_manager_approval: boolean
8
+ created_at: string
9
+ updated_at: string
10
+ deleted_at: string | null
11
+ }
12
+
13
+ export type ModuleCreateApprovalSettings = {
14
+ company_id: string
15
+ requires_admin_approval: boolean
16
+ requires_sales_manager_approval: boolean
17
+ }
18
+
19
+ export type ModuleUpdateApprovalSettings = {
20
+ id: string
21
+ requires_admin_approval?: boolean
22
+ requires_sales_manager_approval?: boolean
23
+ }
24
+
25
+ /* Entity: Approval */
26
+ export enum ApprovalType {
27
+ ADMIN = "admin",
28
+ SALES_MANAGER = "sales_manager",
29
+ }
30
+
31
+ export enum ApprovalStatusType {
32
+ PENDING = "pending",
33
+ APPROVED = "approved",
34
+ REJECTED = "rejected",
35
+ }
36
+
37
+ export type ModuleApproval = {
38
+ id: string
39
+ cart_id: string
40
+ type: ApprovalType
41
+ status: ApprovalStatusType
42
+ created_by: string
43
+ handled_by: string | null
44
+ handled_at: string | null
45
+ reason: string | null
46
+ }
47
+
48
+ export type ModuleCreateApproval = {
49
+ cart_id: string
50
+ type: ApprovalType
51
+ created_by: string
52
+ }
53
+
54
+ export type ModuleUpdateApproval = {
55
+ id: string
56
+ status: ApprovalStatusType
57
+ handled_by: string
58
+ handled_at?: string
59
+ reason?: string | null
60
+ }
61
+
62
+ /* Entity: Approval Status */
63
+ export type ModuleApprovalStatus = {
64
+ id: string
65
+ cart_id: string
66
+ status: ApprovalStatusType
67
+ }
68
+
69
+ export type ModuleCreateApprovalStatus = {
70
+ cart_id: string
71
+ status: ApprovalStatusType
72
+ }
73
+
74
+ export type ModuleUpdateApprovalStatus = {
75
+ id: string
76
+ status: ApprovalStatusType
77
+ }
@@ -0,0 +1,11 @@
1
+ import {
2
+ ModuleApprovalSettings,
3
+ ModuleApproval,
4
+ ModuleApprovalStatus,
5
+ } from "./module"
6
+
7
+ export type QueryApprovalSettings = ModuleApprovalSettings
8
+
9
+ export type QueryApproval = ModuleApproval
10
+
11
+ export type QueryApprovalStatus = ModuleApprovalStatus
@@ -0,0 +1,126 @@
1
+ import {
2
+ BaseFilterable,
3
+ Context,
4
+ FindConfig,
5
+ IModuleService,
6
+ } from "@medusajs/framework/types"
7
+ import {
8
+ ModuleCreateApprovalSettings,
9
+ ModuleApprovalSettings,
10
+ ModuleUpdateApprovalSettings,
11
+ ModuleApproval,
12
+ ModuleCreateApproval,
13
+ ModuleUpdateApproval,
14
+ ModuleCreateApprovalStatus,
15
+ ModuleApprovalStatus,
16
+ ModuleUpdateApprovalStatus,
17
+ } from "./module"
18
+
19
+ export interface ModuleApprovalSettingsFilters extends BaseFilterable<ModuleApprovalSettingsFilters> {
20
+ id?: string | string[]
21
+ company_id?: string | string[]
22
+ }
23
+
24
+ export interface ModuleApprovalFilters extends BaseFilterable<ModuleApprovalFilters> {
25
+ id?: string | string[]
26
+ cart_id?: string | string[]
27
+ }
28
+
29
+ /**
30
+ * The main service interface for the Approval Module.
31
+ */
32
+ export interface IApprovalModuleService extends IModuleService {
33
+ /* Entity: Approval */
34
+ createApproval(
35
+ data: ModuleCreateApproval,
36
+ sharedContext?: Context
37
+ ): Promise<ModuleApproval>
38
+
39
+ createApprovals(
40
+ data: ModuleCreateApproval[],
41
+ sharedContext?: Context
42
+ ): Promise<ModuleApproval[]>
43
+
44
+ updateApproval(
45
+ data: ModuleUpdateApproval,
46
+ sharedContext?: Context
47
+ ): Promise<ModuleApproval>
48
+
49
+ updateApprovals(
50
+ data: ModuleUpdateApproval[],
51
+ sharedContext?: Context
52
+ ): Promise<ModuleApproval[]>
53
+
54
+ listApprovals(
55
+ filters?: ModuleApprovalFilters,
56
+ config?: FindConfig<ModuleApproval>,
57
+ sharedContext?: Context
58
+ ): Promise<ModuleApproval[]>
59
+
60
+ retrieveApproval(id: string, sharedContext?: Context): Promise<ModuleApproval>
61
+
62
+ softDeleteApprovals(ids: string[], sharedContext?: Context): Promise<void>
63
+
64
+ deleteApprovals(ids: string[], sharedContext?: Context): Promise<void>
65
+
66
+ restoreApprovals(ids: string[], sharedContext?: Context): Promise<void>
67
+
68
+ hasPendingApprovals(cartId: string): Promise<boolean>
69
+
70
+ /* Entity: Approval Settings */
71
+ retrieveApprovalSettings(
72
+ id: string,
73
+ sharedContext?: Context
74
+ ): Promise<ModuleApprovalSettings>
75
+
76
+ createApprovalSettings(
77
+ data: ModuleCreateApprovalSettings,
78
+ sharedContext?: Context
79
+ ): Promise<ModuleApprovalSettings>
80
+
81
+ createApprovalSettings(
82
+ data: ModuleCreateApprovalSettings[],
83
+ sharedContext?: Context
84
+ ): Promise<ModuleApprovalSettings[]>
85
+
86
+ updateApprovalSettings(
87
+ data: ModuleUpdateApprovalSettings,
88
+ sharedContext?: Context
89
+ ): Promise<ModuleApprovalSettings>
90
+
91
+ updateApprovalSettings(
92
+ data: ModuleUpdateApprovalSettings[],
93
+ sharedContext?: Context
94
+ ): Promise<ModuleApprovalSettings[]>
95
+
96
+ listApprovalSettings(
97
+ filters?: ModuleApprovalSettingsFilters,
98
+ config?: FindConfig<ModuleApprovalSettings>,
99
+ sharedContext?: Context
100
+ ): Promise<ModuleApprovalSettings[]>
101
+
102
+ deleteApprovalSettings(ids: string[], sharedContext?: Context): Promise<void>
103
+
104
+ /* Entity: Approval Status */
105
+ createApprovalStatus(
106
+ data: ModuleCreateApprovalStatus,
107
+ sharedContext?: Context
108
+ ): Promise<ModuleApprovalStatus>
109
+
110
+ createApprovalStatuses(
111
+ data: ModuleCreateApprovalStatus[],
112
+ sharedContext?: Context
113
+ ): Promise<ModuleApprovalStatus[]>
114
+
115
+ updateApprovalStatus(
116
+ data: ModuleUpdateApprovalStatus,
117
+ sharedContext?: Context
118
+ ): Promise<ModuleApprovalStatus>
119
+
120
+ updateApprovalStatuses(
121
+ data: ModuleUpdateApprovalStatus[],
122
+ sharedContext?: Context
123
+ ): Promise<ModuleApprovalStatus[]>
124
+
125
+ deleteApprovalStatuses(ids: string[], sharedContext?: Context): Promise<void>
126
+ }
@@ -0,0 +1,126 @@
1
+ import { FindParams, PaginatedResponse } from "@medusajs/framework/types"
2
+ import { QueryCompany, QueryEmployee } from "./query"
3
+ import { ModuleCompanyFilters, ModuleEmployeeFilters } from "./service"
4
+ import { ESpendingLimitResetFrequency } from "../enums"
5
+
6
+ /* Filters */
7
+
8
+ export interface CompanyFilterParams extends FindParams, ModuleCompanyFilters {}
9
+
10
+ export interface EmployeeFilterParams
11
+ extends FindParams, ModuleEmployeeFilters {}
12
+
13
+ /* Admin */
14
+
15
+ /* Company */
16
+ export type AdminCompanyResponse = {
17
+ company: QueryCompany
18
+ }
19
+
20
+ export type AdminCompaniesResponse = PaginatedResponse<{
21
+ companies: QueryCompany[]
22
+ }>
23
+
24
+ export type AdminCreateCompany = {
25
+ name: string
26
+ phone: string
27
+ email: string
28
+ address: string | null
29
+ city: string | null
30
+ state: string | null
31
+ zip: string | null
32
+ country: string | null
33
+ logo_url: string | null
34
+ currency_code: string | null
35
+ spending_limit_reset_frequency: ESpendingLimitResetFrequency
36
+ spending_limit_reset_at: string | null
37
+ }
38
+
39
+ export type AdminUpdateCompany = Partial<AdminCreateCompany>
40
+
41
+ /* Employee */
42
+
43
+ export type AdminEmployeeResponse = {
44
+ employee: QueryEmployee
45
+ }
46
+
47
+ export type AdminEmployeesResponse = PaginatedResponse<{
48
+ employees: QueryEmployee[]
49
+ }>
50
+
51
+ export type AdminCreateEmployee = {
52
+ spending_limit: number
53
+ is_admin: boolean
54
+ company_id: string
55
+ customer_id: string
56
+ }
57
+
58
+ export type AdminUpdateEmployee = Partial<AdminCreateEmployee>
59
+
60
+ /* Store */
61
+
62
+ /* Company */
63
+
64
+ export type StoreCompanyResponse = {
65
+ company: QueryCompany
66
+ }
67
+
68
+ export type StoreCompaniesResponse = PaginatedResponse<{
69
+ companies: QueryCompany[]
70
+ }>
71
+
72
+ export type StoreCompanyPreviewResponse = {
73
+ company: QueryCompany
74
+ }
75
+
76
+ export type StoreCreateCompany = {
77
+ name: string
78
+ phone?: string | null
79
+ email: string
80
+ address?: string | null
81
+ city?: string | null
82
+ state?: string | null
83
+ zip?: string | null
84
+ country?: string | null
85
+ logo_url?: string | null
86
+ currency_code: string
87
+ }
88
+
89
+ export type StoreUpdateCompany = {
90
+ id: string
91
+ name: string
92
+ phone: string
93
+ email: string
94
+ address: string | null
95
+ city: string | null
96
+ state: string | null
97
+ zip: string | null
98
+ country: string | null
99
+ logo_url: string | null
100
+ currency_code: string
101
+ spending_limit_reset_frequency?: ESpendingLimitResetFrequency
102
+ }
103
+
104
+ /* Employee */
105
+
106
+ export type StoreEmployeeResponse = {
107
+ employee: QueryEmployee
108
+ }
109
+
110
+ export type StoreEmployeesResponse = PaginatedResponse<{
111
+ employees: QueryEmployee[]
112
+ }>
113
+
114
+ export type StoreCreateEmployee = {
115
+ customer_id: string
116
+ spending_limit: number
117
+ is_admin: boolean
118
+ company_id: string
119
+ }
120
+
121
+ export type StoreUpdateEmployee = {
122
+ id: string
123
+ spending_limit: number
124
+ is_admin: boolean
125
+ company_id: string
126
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./http"
2
+ export * from "./module"
3
+ export * from "./query"
4
+ export * from "./service"
@@ -0,0 +1,78 @@
1
+ /* Entity: Company */
2
+
3
+ import { CustomerGroupDTO } from "@medusajs/framework/types"
4
+ import { CustomerDTO } from "@medusajs/framework/types"
5
+ import { ModuleApprovalSettings } from "../approval/module"
6
+ import { ESpendingLimitResetFrequency } from "../enums"
7
+
8
+ export type ModuleCompany = {
9
+ id: string
10
+ name: string
11
+ phone: string
12
+ email: string
13
+ address: string | null
14
+ city: string | null
15
+ state: string | null
16
+ zip: string | null
17
+ country: string | null
18
+ logo_url: string | null
19
+ currency_code: string | null
20
+ spending_limit_reset_frequency: ESpendingLimitResetFrequency
21
+ spending_limit_reset_at: Date | null
22
+ created_at: Date
23
+ updated_at: Date
24
+ customer_group: CustomerGroupDTO
25
+ approval_settings: ModuleApprovalSettings
26
+ }
27
+
28
+ export type ModuleCreateCompany = {
29
+ name: string
30
+ phone: string
31
+ email: string
32
+ address: string | null
33
+ city: string | null
34
+ state: string | null
35
+ zip: string | null
36
+ country: string | null
37
+ logo_url: string | null
38
+ currency_code: string
39
+ spending_limit_reset_frequency: ESpendingLimitResetFrequency
40
+ }
41
+
42
+ export interface ModuleUpdateCompany extends Partial<ModuleCompany> {
43
+ id: string
44
+ }
45
+
46
+ export type ModuleDeleteCompany = {
47
+ id: string
48
+ }
49
+
50
+ /* Entity: Employee */
51
+
52
+ export interface ModuleEmployee {
53
+ id: string
54
+ spending_limit: number
55
+ is_admin: boolean
56
+ is_active: boolean
57
+ company_id: string
58
+ created_at: Date
59
+ updated_at: Date
60
+ customer: CustomerDTO
61
+ company: ModuleCompany
62
+ }
63
+
64
+ export type ModuleCreateEmployee = {
65
+ customer_id: string
66
+ spending_limit: number
67
+ is_admin: boolean
68
+ is_active?: boolean
69
+ company_id: string
70
+ }
71
+
72
+ export interface ModuleUpdateEmployee extends Partial<ModuleEmployee> {
73
+ id: string
74
+ }
75
+
76
+ export type ModuleDeleteEmployee = {
77
+ id: string
78
+ }
@@ -0,0 +1,15 @@
1
+ import { CustomerDTO } from "@medusajs/framework/types"
2
+ import { ModuleCompany, ModuleEmployee } from "./module"
3
+ import { QueryApprovalSettings } from "../approval/query"
4
+ import { HttpTypes } from "@medusajs/framework/types"
5
+
6
+ export type QueryCompany = ModuleCompany & {
7
+ employees: QueryEmployee[]
8
+ approval_settings: QueryApprovalSettings
9
+ carts: HttpTypes.StoreCart[]
10
+ }
11
+
12
+ export type QueryEmployee = ModuleEmployee & {
13
+ company: QueryCompany
14
+ customer: CustomerDTO
15
+ }
@@ -0,0 +1,109 @@
1
+ import {
2
+ BaseFilterable,
3
+ Context,
4
+ FindConfig,
5
+ IModuleService,
6
+ RestoreReturn,
7
+ } from "@medusajs/framework/types"
8
+ import {
9
+ ModuleCompany,
10
+ ModuleCreateCompany,
11
+ ModuleCreateEmployee,
12
+ ModuleEmployee,
13
+ ModuleUpdateCompany,
14
+ ModuleUpdateEmployee,
15
+ } from "./module"
16
+
17
+ export interface ModuleCompanyFilters extends BaseFilterable<ModuleCompanyFilters> {
18
+ q?: string
19
+ id?: string | string[]
20
+ }
21
+
22
+ export interface ModuleEmployeeFilters extends BaseFilterable<ModuleEmployeeFilters> {
23
+ q?: string
24
+ id?: string | string[]
25
+ company_id?: string | string[]
26
+ customer_id?: string | string[]
27
+ }
28
+
29
+ /**
30
+ * The main service interface for the Company Module.
31
+ */
32
+ export interface ICompanyModuleService extends IModuleService {
33
+ /* Entity: Companies */
34
+ createCompanies(
35
+ data: ModuleCreateCompany,
36
+ sharedContext?: Context
37
+ ): Promise<ModuleCompany>
38
+
39
+ createCompanies(
40
+ data: ModuleCreateCompany[],
41
+ sharedContext?: Context
42
+ ): Promise<ModuleCompany[]>
43
+
44
+ retrieveCompany(
45
+ id: string,
46
+ config?: FindConfig<ModuleCompany>,
47
+ sharedContext?: Context
48
+ ): Promise<ModuleCompany>
49
+
50
+ updateCompanies(
51
+ data: ModuleUpdateCompany,
52
+ sharedContext?: Context
53
+ ): Promise<ModuleCompany>
54
+
55
+ updateCompanies(
56
+ data: ModuleUpdateCompany[],
57
+ sharedContext?: Context
58
+ ): Promise<ModuleCompany[]>
59
+
60
+ listCompanies(
61
+ filters?: ModuleCompanyFilters,
62
+ config?: FindConfig<ModuleCompany>,
63
+ sharedContext?: Context
64
+ ): Promise<ModuleCompany[]>
65
+
66
+ deleteCompanies(ids: string[], sharedContext?: Context): Promise<void>
67
+
68
+ softDeleteCompanies(ids: string[], sharedContext?: Context): Promise<void>
69
+
70
+ restoreCompanies<TReturnableLinkableKeys extends string = string>(
71
+ ids: string[],
72
+ config?: RestoreReturn<TReturnableLinkableKeys>,
73
+ sharedContext?: Context
74
+ ): Promise<Record<TReturnableLinkableKeys, string[]> | void>
75
+
76
+ /* Entity: Employees */
77
+
78
+ listEmployees(
79
+ filters?: ModuleEmployeeFilters,
80
+ config?: FindConfig<ModuleEmployee>,
81
+ sharedContext?: Context
82
+ ): Promise<ModuleEmployee[]>
83
+
84
+ retrieveEmployee(
85
+ id: string,
86
+ config?: FindConfig<ModuleEmployee>,
87
+ sharedContext?: Context
88
+ ): Promise<ModuleEmployee>
89
+
90
+ createEmployees(
91
+ data: ModuleCreateEmployee,
92
+ sharedContext?: Context
93
+ ): Promise<ModuleEmployee>
94
+
95
+ updateEmployees(
96
+ data: ModuleUpdateEmployee,
97
+ sharedContext?: Context
98
+ ): Promise<ModuleEmployee>
99
+
100
+ deleteEmployees(ids: string[], sharedContext?: Context): Promise<void>
101
+
102
+ softDeleteEmployees(ids: string[], sharedContext?: Context): Promise<void>
103
+
104
+ restoreEmployees<TReturnableLinkableKeys extends string = string>(
105
+ ids: string[],
106
+ config?: RestoreReturn<TReturnableLinkableKeys>,
107
+ sharedContext?: Context
108
+ ): Promise<Record<TReturnableLinkableKeys, string[]> | void>
109
+ }
@@ -0,0 +1,16 @@
1
+ export const QUOTE_STATUS = [
2
+ "pending_merchant",
3
+ "pending_customer",
4
+ "accepted",
5
+ "customer_rejected",
6
+ "merchant_rejected",
7
+ "expired",
8
+ ] as const
9
+
10
+ export const SPENDING_LIMIT_RESET_FREQUENCY = [
11
+ "never",
12
+ "daily",
13
+ "weekly",
14
+ "monthly",
15
+ "yearly",
16
+ ] as const
@@ -0,0 +1,16 @@
1
+ export enum EQuoteStatus {
2
+ PendingMerchant = "pending_merchant",
3
+ PendingCustomer = "pending_customer",
4
+ Accepted = "accepted",
5
+ CustomerRejected = "customer_rejected",
6
+ MerchantRejected = "merchant_rejected",
7
+ Expired = "expired",
8
+ }
9
+
10
+ export enum ESpendingLimitResetFrequency {
11
+ NEVER = "never",
12
+ DAILY = "daily",
13
+ WEEKLY = "weekly",
14
+ MONTHLY = "monthly",
15
+ YEARLY = "yearly",
16
+ }