@tailor-platform/erp-kit 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +81 -12
  3. package/dist/cli.js +1070 -450
  4. package/package.json +11 -8
  5. package/schemas/module/model.yml +5 -0
  6. package/skills/{app-compose-1-requirement-analysis → erp-kit-app-1-requirements}/SKILL.md +2 -2
  7. package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/SKILL.md +3 -3
  8. package/skills/{app-compose-3-doc-review → erp-kit-app-3-doc-review}/SKILL.md +2 -2
  9. package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/SKILL.md +3 -3
  10. package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/SKILL.md +4 -4
  11. package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/SKILL.md +3 -3
  12. package/skills/{mock-scenario → erp-kit-mock-scenario}/SKILL.md +1 -1
  13. package/skills/{1-module-docs → erp-kit-module-1-docs}/SKILL.md +2 -2
  14. package/skills/{2-module-feature-breakdown → erp-kit-module-2-feature-breakdown}/SKILL.md +13 -9
  15. package/skills/erp-kit-module-2-feature-breakdown/references/naming.md +59 -0
  16. package/skills/{3-module-doc-review → erp-kit-module-3-doc-review}/SKILL.md +83 -25
  17. package/skills/erp-kit-module-4-tdd/SKILL.md +94 -0
  18. package/skills/erp-kit-module-4-tdd/references/cross-module-dependency.md +133 -0
  19. package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/db-relations.md +5 -1
  20. package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/exports.md +1 -1
  21. package/skills/erp-kit-module-4-tdd/references/generated-code.md +32 -0
  22. package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/SKILL.md +46 -44
  23. package/skills/erp-kit-module-5-impl-review/references/commands.md +62 -0
  24. package/skills/erp-kit-module-5-impl-review/references/errors.md +10 -0
  25. package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/references/testing.md +1 -1
  26. package/skills/erp-kit-module-shared/SKILL.md +16 -0
  27. package/skills/erp-kit-module-shared/references/commands.md +203 -0
  28. package/skills/erp-kit-module-shared/references/errors.md +35 -0
  29. package/skills/erp-kit-module-shared/references/queries.md +168 -0
  30. package/skills/erp-kit-module-shared/references/structure.md +36 -0
  31. package/skills/{3-module-doc-review → erp-kit-module-shared}/references/testing.md +4 -3
  32. package/skills/erp-kit-update/SKILL.md +64 -0
  33. package/src/cli.doc.test.ts +65 -0
  34. package/src/cli.ts +3 -35
  35. package/src/commands/app/index.ts +3 -3
  36. package/src/commands/check.test.ts +1 -1
  37. package/src/commands/check.ts +2 -2
  38. package/src/commands/index.ts +73 -0
  39. package/src/commands/init.test.ts +22 -5
  40. package/src/commands/init.ts +25 -16
  41. package/src/commands/license.ts +193 -0
  42. package/src/commands/mock/index.ts +2 -2
  43. package/src/commands/mock/start.ts +1 -1
  44. package/src/commands/mock/validate.test.ts +1 -1
  45. package/src/commands/module/generate.ts +35 -0
  46. package/src/commands/module/index.ts +6 -4
  47. package/src/commands/module/list.test.ts +7 -12
  48. package/src/commands/module/list.ts +1 -1
  49. package/src/commands/scaffold-templates.ts +65 -0
  50. package/src/commands/scaffold.test.ts +92 -2
  51. package/src/commands/scaffold.ts +22 -2
  52. package/src/commands/sync-check.test.ts +60 -1
  53. package/src/commands/sync-check.ts +35 -2
  54. package/src/generator/generate-code.test.ts +200 -0
  55. package/src/generator/generate-code.ts +260 -0
  56. package/src/generator/parse-command-doc.test.ts +159 -0
  57. package/src/generator/parse-command-doc.ts +116 -0
  58. package/src/integration.test.ts +2 -2
  59. package/src/module.ts +6 -6
  60. package/src/modules/item-management/README.md +38 -0
  61. package/src/modules/item-management/command/activateItem.generated.ts +6 -0
  62. package/src/modules/item-management/command/activateItem.test.ts +76 -0
  63. package/src/modules/item-management/command/activateItem.ts +42 -0
  64. package/src/modules/item-management/command/assignItemToTaxonomy.generated.ts +6 -0
  65. package/src/modules/item-management/command/assignItemToTaxonomy.test.ts +88 -0
  66. package/src/modules/item-management/command/assignItemToTaxonomy.ts +63 -0
  67. package/src/modules/item-management/command/createItem.generated.ts +6 -0
  68. package/src/modules/item-management/command/createItem.test.ts +152 -0
  69. package/src/modules/item-management/command/createItem.ts +72 -0
  70. package/src/modules/item-management/command/createTaxonomyNode.generated.ts +6 -0
  71. package/src/modules/item-management/command/createTaxonomyNode.test.ts +126 -0
  72. package/src/modules/item-management/command/createTaxonomyNode.ts +70 -0
  73. package/src/modules/item-management/command/deactivateItem.generated.ts +6 -0
  74. package/src/modules/item-management/command/deactivateItem.test.ts +76 -0
  75. package/src/modules/item-management/command/deactivateItem.ts +42 -0
  76. package/src/modules/item-management/command/deleteItem.generated.ts +6 -0
  77. package/src/modules/item-management/command/deleteItem.test.ts +61 -0
  78. package/src/modules/item-management/command/deleteItem.ts +38 -0
  79. package/src/modules/item-management/command/deleteTaxonomyNode.generated.ts +6 -0
  80. package/src/modules/item-management/command/deleteTaxonomyNode.test.ts +73 -0
  81. package/src/modules/item-management/command/deleteTaxonomyNode.ts +50 -0
  82. package/src/modules/item-management/command/moveTaxonomyNode.generated.ts +6 -0
  83. package/src/modules/item-management/command/moveTaxonomyNode.test.ts +136 -0
  84. package/src/modules/item-management/command/moveTaxonomyNode.ts +85 -0
  85. package/src/modules/item-management/command/reactivateItem.generated.ts +6 -0
  86. package/src/modules/item-management/command/reactivateItem.test.ts +76 -0
  87. package/src/modules/item-management/command/reactivateItem.ts +42 -0
  88. package/src/modules/item-management/command/removeItemFromTaxonomy.generated.ts +6 -0
  89. package/src/modules/item-management/command/removeItemFromTaxonomy.test.ts +43 -0
  90. package/src/modules/item-management/command/removeItemFromTaxonomy.ts +30 -0
  91. package/src/modules/item-management/command/updateItem.generated.ts +6 -0
  92. package/src/modules/item-management/command/updateItem.test.ts +178 -0
  93. package/src/modules/item-management/command/updateItem.ts +103 -0
  94. package/src/modules/item-management/command/updateTaxonomyNode.generated.ts +6 -0
  95. package/src/modules/item-management/command/updateTaxonomyNode.test.ts +88 -0
  96. package/src/modules/item-management/command/updateTaxonomyNode.ts +62 -0
  97. package/src/modules/item-management/db/item.ts +47 -0
  98. package/src/modules/item-management/db/itemTaxonomyAssignment.ts +49 -0
  99. package/src/modules/item-management/db/taxonomyNode.ts +34 -0
  100. package/src/modules/item-management/docs/commands/ActivateItem.md +32 -0
  101. package/src/modules/item-management/docs/commands/AssignItemToTaxonomy.md +38 -0
  102. package/src/modules/item-management/docs/commands/CreateItem.md +44 -0
  103. package/src/modules/item-management/docs/commands/CreateTaxonomyNode.md +44 -0
  104. package/src/modules/item-management/docs/commands/DeactivateItem.md +34 -0
  105. package/src/modules/item-management/docs/commands/DeleteItem.md +35 -0
  106. package/src/modules/item-management/docs/commands/DeleteTaxonomyNode.md +39 -0
  107. package/src/modules/item-management/docs/commands/MoveTaxonomyNode.md +45 -0
  108. package/src/modules/item-management/docs/commands/ReactivateItem.md +34 -0
  109. package/src/modules/item-management/docs/commands/RemoveItemFromTaxonomy.md +30 -0
  110. package/src/modules/item-management/docs/commands/UpdateItem.md +55 -0
  111. package/src/modules/item-management/docs/commands/UpdateTaxonomyNode.md +36 -0
  112. package/src/modules/item-management/docs/features/item-lifecycle.md +60 -0
  113. package/src/modules/item-management/docs/features/item-taxonomy.md +65 -0
  114. package/src/modules/item-management/docs/models/ItemTaxonomyAssignment.md +36 -0
  115. package/src/modules/item-management/docs/models/TaxonomyNode.md +47 -0
  116. package/src/modules/item-management/docs/models/item.md +59 -0
  117. package/src/modules/item-management/docs/queries/CalculateNodeDepth.md +36 -0
  118. package/src/modules/item-management/docs/queries/CalculateSubtreeDepth.md +40 -0
  119. package/src/modules/item-management/docs/queries/DetectCircularReference.md +41 -0
  120. package/src/modules/item-management/docs/queries/GetItem.md +38 -0
  121. package/src/modules/item-management/docs/queries/GetItemTaxonomyAssignment.md +29 -0
  122. package/src/modules/item-management/docs/queries/GetTaxonomyNode.md +35 -0
  123. package/src/modules/item-management/docs/queries/GetTaxonomyNodeAssignments.md +29 -0
  124. package/src/modules/item-management/docs/queries/GetTaxonomyNodeChildren.md +29 -0
  125. package/src/modules/item-management/generated/enums.ts +9 -0
  126. package/src/modules/item-management/generated/kysely-tailordb.ts +62 -0
  127. package/src/modules/item-management/index.ts +53 -0
  128. package/src/modules/item-management/lib/_db_deps.ts +13 -0
  129. package/src/modules/item-management/lib/errors.generated.ts +117 -0
  130. package/src/modules/item-management/lib/permissions.generated.ts +17 -0
  131. package/src/modules/item-management/lib/types.ts +19 -0
  132. package/src/modules/item-management/module.ts +97 -0
  133. package/src/modules/item-management/query/calculateNodeDepth.generated.ts +5 -0
  134. package/src/modules/item-management/query/calculateNodeDepth.test.ts +56 -0
  135. package/src/modules/item-management/query/calculateNodeDepth.ts +28 -0
  136. package/src/modules/item-management/query/calculateSubtreeDepth.generated.ts +5 -0
  137. package/src/modules/item-management/query/calculateSubtreeDepth.test.ts +75 -0
  138. package/src/modules/item-management/query/calculateSubtreeDepth.ts +29 -0
  139. package/src/modules/item-management/query/detectCircularReference.generated.ts +5 -0
  140. package/src/modules/item-management/query/detectCircularReference.test.ts +61 -0
  141. package/src/modules/item-management/query/detectCircularReference.ts +32 -0
  142. package/src/modules/item-management/query/getItem.generated.ts +5 -0
  143. package/src/modules/item-management/query/getItem.test.ts +67 -0
  144. package/src/modules/item-management/query/getItem.ts +20 -0
  145. package/src/modules/item-management/query/getItemTaxonomyAssignment.generated.ts +5 -0
  146. package/src/modules/item-management/query/getItemTaxonomyAssignment.test.ts +25 -0
  147. package/src/modules/item-management/query/getItemTaxonomyAssignment.ts +18 -0
  148. package/src/modules/item-management/query/getTaxonomyNode.generated.ts +5 -0
  149. package/src/modules/item-management/query/getTaxonomyNode.test.ts +47 -0
  150. package/src/modules/item-management/query/getTaxonomyNode.ts +18 -0
  151. package/src/modules/item-management/query/getTaxonomyNodeAssignments.generated.ts +5 -0
  152. package/src/modules/item-management/query/getTaxonomyNodeAssignments.test.ts +25 -0
  153. package/src/modules/item-management/query/getTaxonomyNodeAssignments.ts +16 -0
  154. package/src/modules/item-management/query/getTaxonomyNodeChildren.generated.ts +5 -0
  155. package/src/modules/item-management/query/getTaxonomyNodeChildren.test.ts +34 -0
  156. package/src/modules/item-management/query/getTaxonomyNodeChildren.ts +16 -0
  157. package/src/modules/item-management/tailor.config.ts +11 -0
  158. package/src/modules/item-management/testing/fixtures.ts +81 -0
  159. package/src/modules/primitives/command/activateCategory.generated.ts +6 -0
  160. package/src/modules/primitives/command/activateCategory.test.ts +11 -29
  161. package/src/modules/primitives/command/activateCategory.ts +27 -34
  162. package/src/modules/primitives/command/activateCurrency.generated.ts +6 -0
  163. package/src/modules/primitives/command/activateCurrency.test.ts +11 -29
  164. package/src/modules/primitives/command/activateCurrency.ts +27 -34
  165. package/src/modules/primitives/command/activateUnit.generated.ts +6 -0
  166. package/src/modules/primitives/command/activateUnit.test.ts +11 -15
  167. package/src/modules/primitives/command/activateUnit.ts +27 -34
  168. package/src/modules/primitives/command/createCategory.generated.ts +6 -0
  169. package/src/modules/primitives/command/createCategory.test.ts +27 -39
  170. package/src/modules/primitives/command/createCategory.ts +53 -62
  171. package/src/modules/primitives/command/createCurrency.generated.ts +6 -0
  172. package/src/modules/primitives/command/createCurrency.test.ts +78 -71
  173. package/src/modules/primitives/command/createCurrency.ts +43 -48
  174. package/src/modules/primitives/command/createExchangeRate.generated.ts +6 -0
  175. package/src/modules/primitives/command/createExchangeRate.test.ts +101 -100
  176. package/src/modules/primitives/command/createExchangeRate.ts +50 -59
  177. package/src/modules/primitives/command/createUnit.generated.ts +6 -0
  178. package/src/modules/primitives/command/createUnit.test.ts +92 -95
  179. package/src/modules/primitives/command/createUnit.ts +54 -57
  180. package/src/modules/primitives/command/deactivateCategory.generated.ts +6 -0
  181. package/src/modules/primitives/command/deactivateCategory.test.ts +27 -28
  182. package/src/modules/primitives/command/deactivateCategory.ts +43 -50
  183. package/src/modules/primitives/command/deactivateCurrency.generated.ts +6 -0
  184. package/src/modules/primitives/command/deactivateCurrency.test.ts +23 -38
  185. package/src/modules/primitives/command/deactivateCurrency.ts +31 -38
  186. package/src/modules/primitives/command/deactivateUnit.generated.ts +6 -0
  187. package/src/modules/primitives/command/deactivateUnit.test.ts +27 -23
  188. package/src/modules/primitives/command/deactivateUnit.ts +39 -49
  189. package/src/modules/primitives/command/setBaseCurrency.generated.ts +6 -0
  190. package/src/modules/primitives/command/setBaseCurrency.test.ts +40 -33
  191. package/src/modules/primitives/command/setBaseCurrency.ts +43 -50
  192. package/src/modules/primitives/command/setReferenceUnit.generated.ts +6 -0
  193. package/src/modules/primitives/command/setReferenceUnit.test.ts +39 -35
  194. package/src/modules/primitives/command/setReferenceUnit.ts +46 -59
  195. package/src/modules/primitives/db/unit.ts +13 -3
  196. package/src/modules/primitives/docs/commands/ActivateCategory.md +1 -2
  197. package/src/modules/primitives/docs/commands/ActivateCurrency.md +1 -2
  198. package/src/modules/primitives/docs/commands/ActivateUnit.md +1 -2
  199. package/src/modules/primitives/docs/commands/CreateCategory.md +1 -4
  200. package/src/modules/primitives/docs/commands/CreateCurrency.md +3 -4
  201. package/src/modules/primitives/docs/commands/CreateExchangeRate.md +4 -5
  202. package/src/modules/primitives/docs/commands/CreateUnit.md +5 -5
  203. package/src/modules/primitives/docs/commands/DeactivateCategory.md +2 -3
  204. package/src/modules/primitives/docs/commands/DeactivateCurrency.md +2 -3
  205. package/src/modules/primitives/docs/commands/DeactivateUnit.md +2 -3
  206. package/src/modules/primitives/docs/commands/SetBaseCurrency.md +2 -3
  207. package/src/modules/primitives/docs/commands/SetReferenceUnit.md +2 -3
  208. package/src/modules/primitives/docs/queries/ConvertAmount.md +3 -5
  209. package/src/modules/primitives/docs/queries/ConvertQuantity.md +3 -5
  210. package/src/modules/primitives/docs/queries/GetBaseCurrency.md +32 -0
  211. package/src/modules/primitives/docs/queries/GetCurrency.md +36 -0
  212. package/src/modules/primitives/docs/queries/GetUnit.md +36 -0
  213. package/src/modules/primitives/docs/queries/GetUoMCategory.md +36 -0
  214. package/src/modules/primitives/docs/queries/ListUnitsByCategory.md +26 -0
  215. package/src/modules/primitives/generated/kysely-tailordb.ts +24 -45
  216. package/src/modules/primitives/index.ts +15 -4
  217. package/src/modules/primitives/lib/errors.generated.ts +112 -0
  218. package/src/modules/primitives/{permissions.ts → lib/permissions.generated.ts} +9 -8
  219. package/src/modules/primitives/module.ts +37 -27
  220. package/src/modules/primitives/query/convertAmount.generated.ts +5 -0
  221. package/src/modules/primitives/query/convertAmount.test.ts +2 -2
  222. package/src/modules/primitives/query/convertAmount.ts +27 -28
  223. package/src/modules/primitives/query/convertQuantity.generated.ts +5 -0
  224. package/src/modules/primitives/query/convertQuantity.test.ts +6 -2
  225. package/src/modules/primitives/query/convertQuantity.ts +49 -57
  226. package/src/modules/primitives/query/getBaseCurrency.generated.ts +5 -0
  227. package/src/modules/primitives/query/getBaseCurrency.test.ts +28 -0
  228. package/src/modules/primitives/query/getBaseCurrency.ts +16 -0
  229. package/src/modules/primitives/query/getCurrency.generated.ts +5 -0
  230. package/src/modules/primitives/query/getCurrency.test.ts +47 -0
  231. package/src/modules/primitives/query/getCurrency.ts +18 -0
  232. package/src/modules/primitives/query/getUnit.generated.ts +5 -0
  233. package/src/modules/primitives/query/getUnit.test.ts +47 -0
  234. package/src/modules/primitives/query/getUnit.ts +18 -0
  235. package/src/modules/primitives/query/getUoMCategory.generated.ts +5 -0
  236. package/src/modules/primitives/query/getUoMCategory.test.ts +47 -0
  237. package/src/modules/primitives/query/getUoMCategory.ts +18 -0
  238. package/src/modules/primitives/query/listUnitsByCategory.generated.ts +5 -0
  239. package/src/modules/primitives/query/listUnitsByCategory.ts +16 -0
  240. package/src/modules/primitives/tailor.config.ts +3 -3
  241. package/src/modules/shared/defineCommand.test.ts +23 -10
  242. package/src/modules/shared/defineCommand.ts +23 -10
  243. package/src/modules/shared/internal.ts +1 -0
  244. package/src/modules/shared/requirePermission.test.ts +22 -21
  245. package/src/modules/shared/requirePermission.ts +8 -2
  246. package/src/modules/shared/result.ts +12 -0
  247. package/src/modules/testing/index.ts +36 -11
  248. package/src/modules/user-management/command/activateUser.generated.ts +6 -0
  249. package/src/modules/user-management/command/activateUser.test.ts +27 -27
  250. package/src/modules/user-management/command/activateUser.ts +40 -48
  251. package/src/modules/user-management/command/assignPermissionToRole.generated.ts +6 -0
  252. package/src/modules/user-management/command/assignPermissionToRole.test.ts +42 -43
  253. package/src/modules/user-management/command/assignPermissionToRole.ts +59 -62
  254. package/src/modules/user-management/command/assignRoleToUser.generated.ts +6 -0
  255. package/src/modules/user-management/command/assignRoleToUser.test.ts +70 -63
  256. package/src/modules/user-management/command/assignRoleToUser.ts +63 -66
  257. package/src/modules/user-management/command/createPermission.generated.ts +6 -0
  258. package/src/modules/user-management/command/createPermission.test.ts +45 -38
  259. package/src/modules/user-management/command/createPermission.ts +42 -46
  260. package/src/modules/user-management/command/createRole.generated.ts +6 -0
  261. package/src/modules/user-management/command/createRole.test.ts +30 -29
  262. package/src/modules/user-management/command/createRole.ts +33 -33
  263. package/src/modules/user-management/command/createUser.generated.ts +6 -0
  264. package/src/modules/user-management/command/createUser.test.ts +64 -42
  265. package/src/modules/user-management/command/createUser.ts +54 -56
  266. package/src/modules/user-management/command/deactivateUser.generated.ts +6 -0
  267. package/src/modules/user-management/command/deactivateUser.test.ts +27 -27
  268. package/src/modules/user-management/command/deactivateUser.ts +40 -48
  269. package/src/modules/user-management/command/logAuditEvent.generated.ts +6 -0
  270. package/src/modules/user-management/command/logAuditEvent.test.ts +50 -42
  271. package/src/modules/user-management/command/logAuditEvent.ts +25 -28
  272. package/src/modules/user-management/command/reactivateUser.generated.ts +6 -0
  273. package/src/modules/user-management/command/reactivateUser.test.ts +31 -27
  274. package/src/modules/user-management/command/reactivateUser.ts +40 -48
  275. package/src/modules/user-management/command/revokePermissionFromRole.generated.ts +6 -0
  276. package/src/modules/user-management/command/revokePermissionFromRole.test.ts +52 -51
  277. package/src/modules/user-management/command/revokePermissionFromRole.ts +60 -57
  278. package/src/modules/user-management/command/revokeRoleFromUser.generated.ts +6 -0
  279. package/src/modules/user-management/command/revokeRoleFromUser.test.ts +53 -48
  280. package/src/modules/user-management/command/revokeRoleFromUser.ts +58 -57
  281. package/src/modules/user-management/docs/commands/CreatePermission.md +2 -2
  282. package/src/modules/user-management/docs/commands/CreateRole.md +1 -1
  283. package/src/modules/user-management/generated/enums.ts +11 -11
  284. package/src/modules/user-management/generated/kysely-tailordb.ts +27 -56
  285. package/src/modules/user-management/index.ts +2 -2
  286. package/src/modules/user-management/lib/errors.generated.ts +67 -0
  287. package/src/modules/user-management/{permissions.ts → lib/permissions.generated.ts} +8 -7
  288. package/src/modules/user-management/module.ts +22 -22
  289. package/src/modules/user-management/tailor.config.ts +3 -3
  290. package/src/schemas.ts +1 -1
  291. package/skills/1-module-docs/references/structure.md +0 -22
  292. package/skills/2-module-feature-breakdown/references/commands.md +0 -48
  293. package/skills/2-module-feature-breakdown/references/structure.md +0 -22
  294. package/skills/3-module-doc-review/references/commands.md +0 -54
  295. package/skills/3-module-doc-review/references/models.md +0 -29
  296. package/skills/4-module-tdd-implementation/SKILL.md +0 -74
  297. package/skills/4-module-tdd-implementation/references/commands.md +0 -45
  298. package/skills/4-module-tdd-implementation/references/errors.md +0 -7
  299. package/skills/4-module-tdd-implementation/references/models.md +0 -30
  300. package/skills/4-module-tdd-implementation/references/structure.md +0 -22
  301. package/skills/4-module-tdd-implementation/references/testing.md +0 -37
  302. package/skills/5-module-implementation-review/references/commands.md +0 -45
  303. package/skills/5-module-implementation-review/references/errors.md +0 -7
  304. package/skills/5-module-implementation-review/references/exports.md +0 -8
  305. package/skills/5-module-implementation-review/references/models.md +0 -30
  306. package/src/modules/primitives/lib/errors.ts +0 -138
  307. package/src/modules/user-management/lib/errors.ts +0 -81
  308. /package/skills/{app-compose-1-requirement-analysis → erp-kit-app-1-requirements}/references/structure.md +0 -0
  309. /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-detailview.md +0 -0
  310. /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-form.md +0 -0
  311. /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-listview.md +0 -0
  312. /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/structure.md +0 -0
  313. /package/skills/{app-compose-3-doc-review → erp-kit-app-3-doc-review}/references/structure.md +0 -0
  314. /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/component.md +0 -0
  315. /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-detailview.md +0 -0
  316. /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-form.md +0 -0
  317. /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-listview.md +0 -0
  318. /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/structure.md +0 -0
  319. /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/component.md +0 -0
  320. /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-detailview.md +0 -0
  321. /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-form.md +0 -0
  322. /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-listview.md +0 -0
  323. /package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/references/auth.md +0 -0
  324. /package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/references/structure.md +0 -0
  325. /package/skills/{2-module-feature-breakdown → erp-kit-module-4-tdd}/references/models.md +0 -0
@@ -0,0 +1,47 @@
1
+ import {
2
+ db,
3
+ type TailorAnyDBField,
4
+ type TailorAnyDBType,
5
+ unsafeAllowAllGqlPermission,
6
+ unsafeAllowAllTypePermission,
7
+ } from "@tailor-platform/sdk";
8
+ import { unit as unitStub } from "../lib/_db_deps";
9
+
10
+ export const BASE_ITEM_STATUSES = ["DRAFT", "ACTIVE", "INACTIVE"] as const;
11
+
12
+ export interface CreateItemTypeParams<F extends Record<string, TailorAnyDBField>> {
13
+ fields?: F;
14
+ additionalStatuses?: string[];
15
+ unitType: TailorAnyDBType;
16
+ }
17
+
18
+ export function createItemType<const F extends Record<string, TailorAnyDBField>>(
19
+ params: CreateItemTypeParams<F>,
20
+ ) {
21
+ const statuses = [...BASE_ITEM_STATUSES, ...(params.additionalStatuses ?? [])] as [
22
+ string,
23
+ ...string[],
24
+ ];
25
+
26
+ return db
27
+ .type("Item", {
28
+ sku: db.string().unique().description("Globally unique, immutable SKU identifier"),
29
+ name: db.string().description("Item display name"),
30
+ barcode: db.string({ optional: true }).unique().description("Optional unique barcode"),
31
+ unitId: db
32
+ .uuid()
33
+ .relation({
34
+ type: "n-1",
35
+ toward: { type: params.unitType },
36
+ backward: "items",
37
+ })
38
+ .description("Foreign key to Unit"),
39
+ status: db.enum(statuses).description("Lifecycle status: DRAFT, ACTIVE, INACTIVE"),
40
+ ...((params.fields ?? {}) as F),
41
+ ...db.fields.timestamps(),
42
+ })
43
+ .permission(unsafeAllowAllTypePermission)
44
+ .gqlPermission(unsafeAllowAllGqlPermission);
45
+ }
46
+
47
+ export const item = createItemType({ unitType: unitStub });
@@ -0,0 +1,49 @@
1
+ import {
2
+ db,
3
+ type TailorAnyDBField,
4
+ unsafeAllowAllGqlPermission,
5
+ unsafeAllowAllTypePermission,
6
+ } from "@tailor-platform/sdk";
7
+ import { item } from "./item";
8
+ import { taxonomyNode } from "./taxonomyNode";
9
+
10
+ export interface CreateItemTaxonomyAssignmentTypeParams<
11
+ F extends Record<string, TailorAnyDBField>,
12
+ > {
13
+ fields?: F;
14
+ }
15
+
16
+ export function createItemTaxonomyAssignmentType<const F extends Record<string, TailorAnyDBField>>(
17
+ params: CreateItemTaxonomyAssignmentTypeParams<F>,
18
+ ) {
19
+ return db
20
+ .type("ItemTaxonomyAssignment", {
21
+ itemId: db
22
+ .uuid()
23
+ .relation({
24
+ type: "n-1",
25
+ toward: { type: item },
26
+ backward: "itemTaxonomyAssignments",
27
+ })
28
+ .description("Foreign key to Item"),
29
+ taxonomyNodeId: db
30
+ .uuid()
31
+ .relation({
32
+ type: "n-1",
33
+ toward: { type: taxonomyNode },
34
+ backward: "itemTaxonomyAssignments",
35
+ })
36
+ .description("Foreign key to TaxonomyNode"),
37
+ ...((params.fields ?? {}) as F),
38
+ ...db.fields.timestamps(),
39
+ })
40
+ .indexes({
41
+ fields: ["itemId", "taxonomyNodeId"],
42
+ unique: true,
43
+ name: "item_taxonomy_assignment_unique_idx",
44
+ })
45
+ .permission(unsafeAllowAllTypePermission)
46
+ .gqlPermission(unsafeAllowAllGqlPermission);
47
+ }
48
+
49
+ export const itemTaxonomyAssignment = createItemTaxonomyAssignmentType({});
@@ -0,0 +1,34 @@
1
+ import {
2
+ db,
3
+ type TailorAnyDBField,
4
+ unsafeAllowAllGqlPermission,
5
+ unsafeAllowAllTypePermission,
6
+ } from "@tailor-platform/sdk";
7
+
8
+ export interface CreateTaxonomyNodeTypeParams<F extends Record<string, TailorAnyDBField>> {
9
+ fields?: F;
10
+ }
11
+
12
+ export function createTaxonomyNodeType<const F extends Record<string, TailorAnyDBField>>(
13
+ params: CreateTaxonomyNodeTypeParams<F>,
14
+ ) {
15
+ return db
16
+ .type("TaxonomyNode", {
17
+ code: db.string().unique().description("Globally unique, immutable node code"),
18
+ name: db.string().description("Display name for the taxonomy node"),
19
+ parentId: db
20
+ .uuid({ optional: true })
21
+ .relation({
22
+ type: "n-1",
23
+ toward: { type: "self" },
24
+ backward: "children",
25
+ })
26
+ .description("Parent node ID (null for root nodes)"),
27
+ ...((params.fields ?? {}) as F),
28
+ ...db.fields.timestamps(),
29
+ })
30
+ .permission(unsafeAllowAllTypePermission)
31
+ .gqlPermission(unsafeAllowAllGqlPermission);
32
+ }
33
+
34
+ export const taxonomyNode = createTaxonomyNodeType({});
@@ -0,0 +1,32 @@
1
+ # ActivateItem
2
+
3
+ ## Overview
4
+
5
+ activateItem transitions an item from DRAFT to ACTIVE status, making it available for use in transactions across downstream modules (Sales, Purchasing, Inventory). Since name, SKU, and UoM are required at creation time, no completeness validation is needed at activation.
6
+
7
+ ## Business Rules
8
+
9
+ - Target item must exist in the system
10
+ - Target item must be in DRAFT status
11
+ - After activation, the item can participate in new transactions
12
+
13
+ ## Process Flow
14
+
15
+ ```mermaid
16
+ flowchart TD
17
+ A[Receive activate request] --> B{Item exists?}
18
+ B -->|No| C[Return error: not found]
19
+ B -->|Yes| D{Status is DRAFT?}
20
+ D -->|No| E[Return error: invalid state transition]
21
+ D -->|Yes| F[Update status to ACTIVE]
22
+ F --> G[Return activated item]
23
+ ```
24
+
25
+ ## External Dependencies
26
+
27
+ - None
28
+
29
+ ## Error Scenarios
30
+
31
+ - **ITEM_NOT_FOUND**: Specified item ID does not exist
32
+ - **INVALID_STATE_TRANSITION**: Item is not in DRAFT status
@@ -0,0 +1,38 @@
1
+ # AssignItemToTaxonomy
2
+
3
+ ## Overview
4
+
5
+ assignItemToTaxonomy creates a link between an item and a taxonomy node, enabling many-to-many classification. A single item can be assigned to multiple taxonomy nodes simultaneously (e.g., both "Electronics > Smartphones" and "Gift Ideas > Tech Gifts"), allowing flexible multi-dimensional classification.
6
+
7
+ ## Business Rules
8
+
9
+ - The referenced item must exist in the system
10
+ - The referenced taxonomy node must exist in the system
11
+ - The combination of item and taxonomy node must be unique — duplicate assignments are rejected
12
+ - An item can be assigned to any number of taxonomy nodes
13
+ - A taxonomy node can have any number of items assigned
14
+ - Assignment does not change the item's status or the node's position in the tree
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive assign request] --> B{Item exists?}
21
+ B -->|No| C[Return error: item not found]
22
+ B -->|Yes| D{Node exists?}
23
+ D -->|No| E[Return error: node not found]
24
+ D -->|Yes| F{Assignment already exists?}
25
+ F -->|Yes| G[Return error: duplicate assignment]
26
+ F -->|No| H[Create assignment record]
27
+ H --> I[Return created assignment]
28
+ ```
29
+
30
+ ## External Dependencies
31
+
32
+ - None
33
+
34
+ ## Error Scenarios
35
+
36
+ - **ITEM_NOT_FOUND**: Specified item ID does not exist
37
+ - **NODE_NOT_FOUND**: Specified taxonomy node ID does not exist
38
+ - **DUPLICATE_ASSIGNMENT**: Item is already assigned to this taxonomy node
@@ -0,0 +1,44 @@
1
+ # CreateItem
2
+
3
+ ## Overview
4
+
5
+ createItem establishes a new item in the system with a unique SKU, name, unit of measure, and optional barcode. Items can be created in either DRAFT or ACTIVE status. DRAFT items allow review and correction before activation, while ACTIVE items are immediately available for transactions.
6
+
7
+ This command supports both careful item onboarding workflows (create as DRAFT, review, then activate) and rapid setup scenarios (create directly as ACTIVE).
8
+
9
+ ## Business Rules
10
+
11
+ - SKU is required, must be globally unique across all items (active, inactive, and draft)
12
+ - SKU is immutable after creation — it cannot be changed once assigned
13
+ - Name is required
14
+ - Barcode must be unique across all items when provided
15
+ - UoM (unit of measure) is required and must reference an existing active Unit from the primitives module
16
+ - Default status is DRAFT if not specified
17
+
18
+ ## Process Flow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Receive create request] --> B{Validate SKU format}
23
+ B -->|Invalid| C[Return error: invalid SKU]
24
+ B -->|Valid| D{SKU unique?}
25
+ D -->|No| E[Return error: duplicate SKU]
26
+ D -->|Yes| F{Barcode provided?}
27
+ F -->|Yes| G{Barcode unique?}
28
+ G -->|No| H[Return error: duplicate barcode]
29
+ G -->|Yes| I{Validate UoM}
30
+ F -->|No| I
31
+ I -->|Invalid| J[Return error: invalid UoM]
32
+ I -->|Valid| K[Create item record]
33
+ K --> L[Return created item]
34
+ ```
35
+
36
+ ## External Dependencies
37
+
38
+ - [primitives::Unit](../../../primitives/docs/models/Unit.md) - Validates that the referenced UoM exists and is active
39
+
40
+ ## Error Scenarios
41
+
42
+ - **DUPLICATE_SKU**: An item with the same SKU already exists
43
+ - **DUPLICATE_BARCODE**: An item with the same barcode already exists
44
+ - **UNIT_NOT_FOUND**: Referenced unit does not exist or is inactive
@@ -0,0 +1,44 @@
1
+ # CreateTaxonomyNode
2
+
3
+ ## Overview
4
+
5
+ createTaxonomyNode establishes a new node in the taxonomy hierarchy. A node can be a root node (no parent) or a child node positioned under an existing parent. Each node has a globally unique code for stable API references and integrations, and a display name.
6
+
7
+ This command supports both initial taxonomy setup and incremental expansion of the classification tree.
8
+
9
+ ## Business Rules
10
+
11
+ - Node code is required and must be globally unique across all taxonomy nodes
12
+ - Node name is required
13
+ - Parent node ID is optional — omitting it creates a root node
14
+ - When parent is specified, the parent node must exist
15
+ - Creating a child node must not cause the tree to exceed the configurable maximum depth (default 10)
16
+ - Root nodes have a null parent reference
17
+
18
+ ## Process Flow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Receive create request] --> B{Validate code format}
23
+ B -->|Invalid| C[Return error: invalid code]
24
+ B -->|Valid| D{Code unique?}
25
+ D -->|No| E[Return error: duplicate code]
26
+ D -->|Yes| F{Parent specified?}
27
+ F -->|Yes| G{Parent exists?}
28
+ G -->|No| H[Return error: parent not found]
29
+ G -->|Yes| I{Depth limit exceeded?}
30
+ I -->|Yes| J[Return error: max depth exceeded]
31
+ I -->|No| K[Create node with parent]
32
+ F -->|No| K[Create root node]
33
+ K --> L[Return created node]
34
+ ```
35
+
36
+ ## External Dependencies
37
+
38
+ - None
39
+
40
+ ## Error Scenarios
41
+
42
+ - **DUPLICATE_NODE_CODE**: A node with the same code already exists
43
+ - **PARENT_NODE_NOT_FOUND**: Specified parent node ID does not exist
44
+ - **MAX_DEPTH_EXCEEDED**: Adding this child would exceed the configurable tree depth limit
@@ -0,0 +1,34 @@
1
+ # DeactivateItem
2
+
3
+ ## Overview
4
+
5
+ deactivateItem transitions an item from ACTIVE to INACTIVE status, removing it from availability for new transactions while preserving it for historical reference and audit trails. This supports scenarios such as discontinuing a product line or seasonal item removal.
6
+
7
+ ## Business Rules
8
+
9
+ - Target item must exist in the system
10
+ - Target item must be in ACTIVE status
11
+ - Deactivated items remain in the system for reporting and audit purposes
12
+ - Deactivation prevents the item from being used in new transactions
13
+ - Existing transactions referencing this item are not affected
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive deactivate request] --> B{Item exists?}
20
+ B -->|No| C[Return error: not found]
21
+ B -->|Yes| D{Status is ACTIVE?}
22
+ D -->|No| E[Return error: invalid state transition]
23
+ D -->|Yes| F[Update status to INACTIVE]
24
+ F --> G[Return deactivated item]
25
+ ```
26
+
27
+ ## External Dependencies
28
+
29
+ - None
30
+
31
+ ## Error Scenarios
32
+
33
+ - **ITEM_NOT_FOUND**: Specified item ID does not exist
34
+ - **INVALID_STATE_TRANSITION**: Item is not in ACTIVE status
@@ -0,0 +1,35 @@
1
+ # DeleteItem
2
+
3
+ ## Overview
4
+
5
+ deleteItem permanently removes a DRAFT item from the system. Only items in DRAFT status can be deleted — ACTIVE and INACTIVE items are preserved for audit trails and historical reference. This supports draft cleanup workflows where unwanted items are removed before activation.
6
+
7
+ ## Business Rules
8
+
9
+ - Target item must exist in the system
10
+ - Target item must be in DRAFT status
11
+ - ACTIVE and INACTIVE items cannot be deleted — they must be preserved for audit trails
12
+ - Deletion is permanent and cannot be undone
13
+ - Any taxonomy assignments for the item should be removed before or as part of deletion
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive delete request] --> B{Item exists?}
20
+ B -->|No| C[Return error: not found]
21
+ B -->|Yes| D{Status is DRAFT?}
22
+ D -->|No| E[Return error: cannot delete non-draft item]
23
+ D -->|Yes| F[Remove taxonomy assignments]
24
+ F --> G[Delete item record]
25
+ G --> H[Return success]
26
+ ```
27
+
28
+ ## External Dependencies
29
+
30
+ - None
31
+
32
+ ## Error Scenarios
33
+
34
+ - **ITEM_NOT_FOUND**: Specified item ID does not exist
35
+ - **DELETE_NON_DRAFT**: Item is in ACTIVE or INACTIVE status — only DRAFT items can be deleted
@@ -0,0 +1,39 @@
1
+ # DeleteTaxonomyNode
2
+
3
+ ## Overview
4
+
5
+ deleteTaxonomyNode permanently removes a taxonomy node from the hierarchy. Deletion is only allowed for leaf nodes (no children) with no item assignments. This ensures the classification tree remains consistent and no item classifications are silently lost.
6
+
7
+ For node consolidation scenarios, item assignments should first be moved to another node using assignItemToTaxonomy and removeItemFromTaxonomy before deleting the empty node.
8
+
9
+ ## Business Rules
10
+
11
+ - Target node must exist in the system
12
+ - Node must have no child nodes — a node with children cannot be deleted
13
+ - Node must have no item assignments — a node with assigned items cannot be deleted
14
+ - Deletion is permanent and cannot be undone
15
+ - The node's code becomes available for reuse after deletion
16
+
17
+ ## Process Flow
18
+
19
+ ```mermaid
20
+ flowchart TD
21
+ A[Receive delete request] --> B{Node exists?}
22
+ B -->|No| C[Return error: not found]
23
+ B -->|Yes| D{Has child nodes?}
24
+ D -->|Yes| E[Return error: has children]
25
+ D -->|No| F{Has item assignments?}
26
+ F -->|Yes| G[Return error: has assignments]
27
+ F -->|No| H[Delete node record]
28
+ H --> I[Return success]
29
+ ```
30
+
31
+ ## External Dependencies
32
+
33
+ - None
34
+
35
+ ## Error Scenarios
36
+
37
+ - **NODE_NOT_FOUND**: Specified node ID does not exist
38
+ - **NODE_HAS_CHILDREN**: Node has one or more child nodes — children must be moved or deleted first
39
+ - **NODE_HAS_ASSIGNMENTS**: Node has one or more item assignments — assignments must be removed first
@@ -0,0 +1,45 @@
1
+ # MoveTaxonomyNode
2
+
3
+ ## Overview
4
+
5
+ moveTaxonomyNode reparents a taxonomy node by changing its parent reference. The node and all its descendants move together, preserving the subtree structure and all item assignments. This supports taxonomy restructuring scenarios such as promoting a branch to root level or reorganizing classification hierarchies.
6
+
7
+ Moving to a null parent promotes the node to a root node.
8
+
9
+ ## Business Rules
10
+
11
+ - Target node must exist in the system
12
+ - New parent node must exist when specified (null for root promotion)
13
+ - A node cannot be moved under itself or any of its descendants (circular reference prevention)
14
+ - All child nodes and their item assignments are preserved during the move
15
+ - The move must not cause the tree to exceed the configurable maximum depth
16
+ - Node code and item assignments are unchanged by the move
17
+
18
+ ## Process Flow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Receive move request] --> B{Node exists?}
23
+ B -->|No| C[Return error: not found]
24
+ B -->|Yes| D{New parent specified?}
25
+ D -->|Yes| E{New parent exists?}
26
+ E -->|No| F[Return error: parent not found]
27
+ E -->|Yes| G{New parent is descendant of node?}
28
+ G -->|Yes| H[Return error: circular reference]
29
+ G -->|No| I{Depth limit exceeded?}
30
+ I -->|Yes| J[Return error: max depth exceeded]
31
+ I -->|No| K[Update parent reference]
32
+ D -->|No/null| K[Promote to root]
33
+ K --> L[Return moved node]
34
+ ```
35
+
36
+ ## External Dependencies
37
+
38
+ - None
39
+
40
+ ## Error Scenarios
41
+
42
+ - **NODE_NOT_FOUND**: Specified node ID does not exist
43
+ - **PARENT_NODE_NOT_FOUND**: Specified new parent node ID does not exist
44
+ - **CIRCULAR_REFERENCE**: New parent is the node itself or one of its descendants
45
+ - **MAX_DEPTH_EXCEEDED**: Moving this subtree would exceed the configurable tree depth limit
@@ -0,0 +1,34 @@
1
+ # ReactivateItem
2
+
3
+ ## Overview
4
+
5
+ reactivateItem transitions an item from INACTIVE back to ACTIVE status, making a previously discontinued SKU available for transactions again. This supports scenarios such as bringing back seasonal products or restoring items after a temporary suspension.
6
+
7
+ ## Business Rules
8
+
9
+ - Target item must exist in the system
10
+ - Target item must be in INACTIVE status
11
+ - After reactivation, the item can participate in new transactions
12
+ - All item data (SKU, barcode, UoM, name) is preserved from before deactivation
13
+ - Bulk reactivation is not supported — reactivation is expected to be a targeted, individual operation since bringing back discontinued items requires deliberate per-item review
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive reactivate request] --> B{Item exists?}
20
+ B -->|No| C[Return error: not found]
21
+ B -->|Yes| D{Status is INACTIVE?}
22
+ D -->|No| E[Return error: invalid state transition]
23
+ D -->|Yes| F[Update status to ACTIVE]
24
+ F --> G[Return reactivated item]
25
+ ```
26
+
27
+ ## External Dependencies
28
+
29
+ - None
30
+
31
+ ## Error Scenarios
32
+
33
+ - **ITEM_NOT_FOUND**: Specified item ID does not exist
34
+ - **INVALID_STATE_TRANSITION**: Item is not in INACTIVE status
@@ -0,0 +1,30 @@
1
+ # RemoveItemFromTaxonomy
2
+
3
+ ## Overview
4
+
5
+ removeItemFromTaxonomy deletes the link between an item and a taxonomy node. Removing an assignment does not affect the item itself, the taxonomy node, or any other assignments the item may have. This supports scenarios such as reclassification, node consolidation, and cleanup of incorrect assignments.
6
+
7
+ ## Business Rules
8
+
9
+ - The assignment (item + taxonomy node link) must exist in the system
10
+ - Removing an assignment does not affect the item or its other taxonomy assignments
11
+ - Removing an assignment does not affect the taxonomy node or its other item assignments
12
+ - Removal is permanent and cannot be undone
13
+
14
+ ## Process Flow
15
+
16
+ ```mermaid
17
+ flowchart TD
18
+ A[Receive remove request] --> B{Assignment exists?}
19
+ B -->|No| C[Return error: assignment not found]
20
+ B -->|Yes| D[Delete assignment record]
21
+ D --> E[Return success]
22
+ ```
23
+
24
+ ## External Dependencies
25
+
26
+ - None
27
+
28
+ ## Error Scenarios
29
+
30
+ - **ASSIGNMENT_NOT_FOUND**: No assignment exists for the specified item and taxonomy node combination
@@ -0,0 +1,55 @@
1
+ # UpdateItem
2
+
3
+ ## Overview
4
+
5
+ updateItem modifies mutable fields of an existing item — name, barcode, and unit of measure (UoM). SKU is immutable and cannot be changed after creation. The set of updatable fields depends on the item's current lifecycle status.
6
+
7
+ This command supports the DRAFT review workflow (correcting barcodes, setting names before activation) as well as post-activation updates to non-transactional fields.
8
+
9
+ ## Business Rules
10
+
11
+ - Target item must exist in the system
12
+ - SKU is immutable — any attempt to change SKU returns an error
13
+ - Name can be updated in any status (DRAFT, ACTIVE, INACTIVE)
14
+ - Barcode can be updated in any status; must remain unique across all items when provided
15
+ - Barcode can be cleared (set to null) to remove it from the item
16
+ - UoM can be updated only when the item is in DRAFT status — once activated, UoM is locked to preserve transaction consistency
17
+ - UoM must reference an existing active Unit from the primitives module
18
+ - At least one field must be provided for update (no-op updates are rejected)
19
+
20
+ ## Process Flow
21
+
22
+ ```mermaid
23
+ flowchart TD
24
+ A[Receive update request] --> B{Item exists?}
25
+ B -->|No| C[Return error: not found]
26
+ B -->|Yes| D{SKU change attempted?}
27
+ D -->|Yes| E[Return error: SKU immutable]
28
+ D -->|No| F{Any field provided?}
29
+ F -->|No| G[Return error: no fields to update]
30
+ F -->|Yes| H{Barcode provided?}
31
+ H -->|Yes| I{Barcode unique?}
32
+ I -->|No| J[Return error: duplicate barcode]
33
+ I -->|Yes| K{UoM change requested?}
34
+ H -->|No| K
35
+ K -->|Yes| L{Status is DRAFT?}
36
+ L -->|No| M[Return error: UoM locked after activation]
37
+ L -->|Yes| N{UoM valid and active?}
38
+ N -->|No| O[Return error: invalid UoM]
39
+ N -->|Yes| P[Apply updates]
40
+ K -->|No| P
41
+ P --> Q[Return updated item]
42
+ ```
43
+
44
+ ## External Dependencies
45
+
46
+ - [primitives::Unit](../../../primitives/docs/models/Unit.md) - Validates that the referenced UoM exists and is active (when UoM is being updated)
47
+
48
+ ## Error Scenarios
49
+
50
+ - **ITEM_NOT_FOUND**: Specified item ID does not exist
51
+ - **SKU_IMMUTABLE**: Attempt to change the SKU field
52
+ - **DUPLICATE_BARCODE**: An item with the same barcode already exists
53
+ - **UNIT_NOT_FOUND**: Referenced unit does not exist or is inactive
54
+ - **UOM_LOCKED**: UoM cannot be changed after item has been activated (status is ACTIVE or INACTIVE)
55
+ - **NO_FIELDS_TO_UPDATE**: No updatable fields were provided in the request
@@ -0,0 +1,36 @@
1
+ # UpdateTaxonomyNode
2
+
3
+ ## Overview
4
+
5
+ updateTaxonomyNode modifies the display name of an existing taxonomy node. The node code is immutable and cannot be changed after creation — only the name (display label) can be updated. This supports scenarios such as renaming a classification branch to better reflect its contents or aligning terminology across the organization.
6
+
7
+ ## Business Rules
8
+
9
+ - Target node must exist in the system
10
+ - Node code is immutable — any attempt to change the code returns an error
11
+ - Name is required and must not be empty
12
+ - Name update does not affect the node's position in the tree, child nodes, or item assignments
13
+
14
+ ## Process Flow
15
+
16
+ ```mermaid
17
+ flowchart TD
18
+ A[Receive update request] --> B{Node exists?}
19
+ B -->|No| C[Return error: not found]
20
+ B -->|Yes| D{Code change attempted?}
21
+ D -->|Yes| E[Return error: code immutable]
22
+ D -->|No| F{Name provided and non-empty?}
23
+ F -->|No| G[Return error: name required]
24
+ F -->|Yes| H[Update node name]
25
+ H --> I[Return updated node]
26
+ ```
27
+
28
+ ## External Dependencies
29
+
30
+ - None
31
+
32
+ ## Error Scenarios
33
+
34
+ - **NODE_NOT_FOUND**: Specified node ID does not exist
35
+ - **CODE_IMMUTABLE**: Attempt to change the node code
36
+ - **MISSING_REQUIRED_FIELDS**: Name not provided or empty
@@ -0,0 +1,60 @@
1
+ # Item Lifecycle
2
+
3
+ ## Overview
4
+
5
+ Items are the fundamental SKU-level entity in the ERP system — the sellable, purchasable, and trackable unit. Each item has its own lifecycle state machine, unique SKU identifier, and optional barcode. Items manage their unit of measure independently.
6
+
7
+ Items can be created in DRAFT or ACTIVE status. DRAFT items require explicit activation before they can participate in transactions.
8
+
9
+ ## Business Purpose
10
+
11
+ Items serve as the universal SKU entity across the ERP system. Downstream domains reference items as the fundamental tradeable/trackable unit:
12
+
13
+ - Sales module creates order lines linked to Items
14
+ - Inventory module tracks stock quantities per Item
15
+ - Purchasing module creates purchase order lines linked to Items
16
+ - Manufacturing module references Items in Bill of Materials
17
+
18
+ The lifecycle state machine ensures:
19
+
20
+ - Items are reviewed before becoming transactionally available (DRAFT → ACTIVE)
21
+ - Discontinued items are preserved for historical reference (ACTIVE → INACTIVE)
22
+ - Previously discontinued items can return to active use (INACTIVE → ACTIVE)
23
+ - Only DRAFT items can be permanently deleted; ACTIVE/INACTIVE items are preserved for audit trails
24
+
25
+ ## Process Flow
26
+
27
+ ```mermaid
28
+ stateDiagram-v2
29
+ [*] --> Draft: createItem (draft)
30
+ [*] --> Active: createItem (active)
31
+ Draft --> Active: activateItem
32
+ Active --> Inactive: deactivateItem
33
+ Inactive --> Active: reactivateItem
34
+ Draft --> [*]: deleteItem
35
+ ```
36
+
37
+ ## Scenario Patterns
38
+
39
+ - **New Item**: An item is created with a unique SKU, name, UoM, and optional barcode
40
+ - **Draft Item Review**: Items created in DRAFT status are reviewed, barcodes corrected, and activated
41
+ - **Item Deactivation**: A specific SKU is discontinued while other items remain active
42
+ - **Item Reactivation**: A previously discontinued SKU is brought back into active use (INACTIVE → ACTIVE)
43
+ - **Draft Item Cleanup**: Unwanted items in DRAFT status are deleted before activation
44
+ - **SKU Assignment**: Each item receives a globally unique SKU that is immutable once assigned
45
+
46
+ ## Test Cases
47
+
48
+ - Item lifecycle follows DRAFT → ACTIVE ↔ INACTIVE state machine
49
+ - Items can be created in either DRAFT or ACTIVE status
50
+ - SKU is required, globally unique, and immutable after assignment
51
+ - Barcode must be unique when provided, can be updated
52
+ - Only DRAFT items can be deleted; ACTIVE and INACTIVE items cannot
53
+ - Only ACTIVE items can be referenced in new transactions (sales orders, purchase orders)
54
+ - Items can be activated, deactivated, and reactivated individually
55
+ - Item UoM can be updated in DRAFT status; once activated, UoM is locked to preserve transaction consistency
56
+
57
+ ## Reference Links
58
+
59
+ - [Oracle Item Master](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25a/fammi/define-items-and-item-structures.html)
60
+ - [NetSuite Item Master Data](https://www.netsuite.com/portal/resource/articles/inventory-management/item-master-data.shtml)