@tailor-platform/erp-kit 0.1.2 → 0.2.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 (330) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +80 -12
  3. package/dist/cli.js +1070 -450
  4. package/package.json +11 -8
  5. package/schemas/app-compose/business-flow.yml +3 -0
  6. package/schemas/app-compose/story.yml +1 -1
  7. package/schemas/module/model.yml +5 -0
  8. package/skills/{app-compose-1-requirement-analysis → erp-kit-app-1-requirements}/SKILL.md +8 -14
  9. package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/SKILL.md +6 -13
  10. package/skills/{app-compose-3-doc-review → erp-kit-app-3-doc-review}/SKILL.md +2 -6
  11. package/skills/{app-compose-6-implementation-spec → erp-kit-app-4-impl-spec}/SKILL.md +11 -22
  12. package/skills/erp-kit-app-5-implementation/SKILL.md +149 -0
  13. package/skills/erp-kit-app-5-implementation/references/backend.md +232 -0
  14. package/skills/erp-kit-app-5-implementation/references/frontend.md +242 -0
  15. package/skills/{mock-scenario → erp-kit-mock-scenario}/SKILL.md +1 -1
  16. package/skills/{1-module-docs → erp-kit-module-1-docs}/SKILL.md +2 -2
  17. package/skills/{2-module-feature-breakdown → erp-kit-module-2-feature-breakdown}/SKILL.md +13 -9
  18. package/skills/erp-kit-module-2-feature-breakdown/references/naming.md +59 -0
  19. package/skills/{3-module-doc-review → erp-kit-module-3-doc-review}/SKILL.md +83 -25
  20. package/skills/erp-kit-module-4-tdd/SKILL.md +94 -0
  21. package/skills/erp-kit-module-4-tdd/references/cross-module-dependency.md +133 -0
  22. package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/db-relations.md +5 -1
  23. package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/exports.md +1 -1
  24. package/skills/erp-kit-module-4-tdd/references/generated-code.md +32 -0
  25. package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/SKILL.md +46 -44
  26. package/skills/erp-kit-module-5-impl-review/references/commands.md +62 -0
  27. package/skills/erp-kit-module-5-impl-review/references/errors.md +10 -0
  28. package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/references/testing.md +1 -1
  29. package/skills/erp-kit-module-shared/SKILL.md +16 -0
  30. package/skills/erp-kit-module-shared/references/commands.md +203 -0
  31. package/skills/erp-kit-module-shared/references/errors.md +35 -0
  32. package/skills/erp-kit-module-shared/references/queries.md +168 -0
  33. package/skills/erp-kit-module-shared/references/structure.md +36 -0
  34. package/skills/{3-module-doc-review → erp-kit-module-shared}/references/testing.md +4 -3
  35. package/skills/erp-kit-update/SKILL.md +64 -0
  36. package/src/cli.doc.test.ts +65 -0
  37. package/src/cli.ts +3 -35
  38. package/src/commands/app/index.ts +3 -3
  39. package/src/commands/check.test.ts +1 -1
  40. package/src/commands/check.ts +2 -2
  41. package/src/commands/index.ts +73 -0
  42. package/src/commands/init.test.ts +22 -5
  43. package/src/commands/init.ts +25 -16
  44. package/src/commands/license.ts +193 -0
  45. package/src/commands/mock/index.ts +2 -2
  46. package/src/commands/mock/start.ts +1 -1
  47. package/src/commands/mock/validate.test.ts +1 -1
  48. package/src/commands/module/generate.ts +35 -0
  49. package/src/commands/module/index.ts +6 -4
  50. package/src/commands/module/list.test.ts +7 -12
  51. package/src/commands/module/list.ts +1 -1
  52. package/src/commands/scaffold-templates.ts +65 -0
  53. package/src/commands/scaffold.test.ts +92 -2
  54. package/src/commands/scaffold.ts +22 -2
  55. package/src/commands/sync-check.test.ts +60 -1
  56. package/src/commands/sync-check.ts +35 -2
  57. package/src/generator/generate-code.test.ts +200 -0
  58. package/src/generator/generate-code.ts +260 -0
  59. package/src/generator/parse-command-doc.test.ts +159 -0
  60. package/src/generator/parse-command-doc.ts +116 -0
  61. package/src/integration.test.ts +2 -2
  62. package/src/module.ts +44 -6
  63. package/src/modules/item-management/README.md +38 -0
  64. package/src/modules/item-management/command/activateItem.generated.ts +6 -0
  65. package/src/modules/item-management/command/activateItem.test.ts +76 -0
  66. package/src/modules/item-management/command/activateItem.ts +42 -0
  67. package/src/modules/item-management/command/assignItemToTaxonomy.generated.ts +6 -0
  68. package/src/modules/item-management/command/assignItemToTaxonomy.test.ts +88 -0
  69. package/src/modules/item-management/command/assignItemToTaxonomy.ts +63 -0
  70. package/src/modules/item-management/command/createItem.generated.ts +6 -0
  71. package/src/modules/item-management/command/createItem.test.ts +152 -0
  72. package/src/modules/item-management/command/createItem.ts +72 -0
  73. package/src/modules/item-management/command/createTaxonomyNode.generated.ts +6 -0
  74. package/src/modules/item-management/command/createTaxonomyNode.test.ts +126 -0
  75. package/src/modules/item-management/command/createTaxonomyNode.ts +70 -0
  76. package/src/modules/item-management/command/deactivateItem.generated.ts +6 -0
  77. package/src/modules/item-management/command/deactivateItem.test.ts +76 -0
  78. package/src/modules/item-management/command/deactivateItem.ts +42 -0
  79. package/src/modules/item-management/command/deleteItem.generated.ts +6 -0
  80. package/src/modules/item-management/command/deleteItem.test.ts +61 -0
  81. package/src/modules/item-management/command/deleteItem.ts +38 -0
  82. package/src/modules/item-management/command/deleteTaxonomyNode.generated.ts +6 -0
  83. package/src/modules/item-management/command/deleteTaxonomyNode.test.ts +73 -0
  84. package/src/modules/item-management/command/deleteTaxonomyNode.ts +50 -0
  85. package/src/modules/item-management/command/moveTaxonomyNode.generated.ts +6 -0
  86. package/src/modules/item-management/command/moveTaxonomyNode.test.ts +136 -0
  87. package/src/modules/item-management/command/moveTaxonomyNode.ts +85 -0
  88. package/src/modules/item-management/command/reactivateItem.generated.ts +6 -0
  89. package/src/modules/item-management/command/reactivateItem.test.ts +76 -0
  90. package/src/modules/item-management/command/reactivateItem.ts +42 -0
  91. package/src/modules/item-management/command/removeItemFromTaxonomy.generated.ts +6 -0
  92. package/src/modules/item-management/command/removeItemFromTaxonomy.test.ts +43 -0
  93. package/src/modules/item-management/command/removeItemFromTaxonomy.ts +30 -0
  94. package/src/modules/item-management/command/updateItem.generated.ts +6 -0
  95. package/src/modules/item-management/command/updateItem.test.ts +178 -0
  96. package/src/modules/item-management/command/updateItem.ts +103 -0
  97. package/src/modules/item-management/command/updateTaxonomyNode.generated.ts +6 -0
  98. package/src/modules/item-management/command/updateTaxonomyNode.test.ts +88 -0
  99. package/src/modules/item-management/command/updateTaxonomyNode.ts +62 -0
  100. package/src/modules/item-management/db/item.ts +47 -0
  101. package/src/modules/item-management/db/itemTaxonomyAssignment.ts +49 -0
  102. package/src/modules/item-management/db/taxonomyNode.ts +34 -0
  103. package/src/modules/item-management/docs/commands/ActivateItem.md +32 -0
  104. package/src/modules/item-management/docs/commands/AssignItemToTaxonomy.md +38 -0
  105. package/src/modules/item-management/docs/commands/CreateItem.md +44 -0
  106. package/src/modules/item-management/docs/commands/CreateTaxonomyNode.md +44 -0
  107. package/src/modules/item-management/docs/commands/DeactivateItem.md +34 -0
  108. package/src/modules/item-management/docs/commands/DeleteItem.md +35 -0
  109. package/src/modules/item-management/docs/commands/DeleteTaxonomyNode.md +39 -0
  110. package/src/modules/item-management/docs/commands/MoveTaxonomyNode.md +45 -0
  111. package/src/modules/item-management/docs/commands/ReactivateItem.md +34 -0
  112. package/src/modules/item-management/docs/commands/RemoveItemFromTaxonomy.md +30 -0
  113. package/src/modules/item-management/docs/commands/UpdateItem.md +55 -0
  114. package/src/modules/item-management/docs/commands/UpdateTaxonomyNode.md +36 -0
  115. package/src/modules/item-management/docs/features/item-lifecycle.md +60 -0
  116. package/src/modules/item-management/docs/features/item-taxonomy.md +65 -0
  117. package/src/modules/item-management/docs/models/ItemTaxonomyAssignment.md +36 -0
  118. package/src/modules/item-management/docs/models/TaxonomyNode.md +47 -0
  119. package/src/modules/item-management/docs/models/item.md +59 -0
  120. package/src/modules/item-management/docs/queries/CalculateNodeDepth.md +36 -0
  121. package/src/modules/item-management/docs/queries/CalculateSubtreeDepth.md +40 -0
  122. package/src/modules/item-management/docs/queries/DetectCircularReference.md +41 -0
  123. package/src/modules/item-management/docs/queries/GetItem.md +38 -0
  124. package/src/modules/item-management/docs/queries/GetItemTaxonomyAssignment.md +29 -0
  125. package/src/modules/item-management/docs/queries/GetTaxonomyNode.md +35 -0
  126. package/src/modules/item-management/docs/queries/GetTaxonomyNodeAssignments.md +29 -0
  127. package/src/modules/item-management/docs/queries/GetTaxonomyNodeChildren.md +29 -0
  128. package/src/modules/item-management/generated/enums.ts +9 -0
  129. package/src/modules/item-management/generated/kysely-tailordb.ts +62 -0
  130. package/src/modules/item-management/index.ts +53 -0
  131. package/src/modules/item-management/lib/_db_deps.ts +13 -0
  132. package/src/modules/item-management/lib/errors.generated.ts +117 -0
  133. package/src/modules/item-management/lib/permissions.generated.ts +17 -0
  134. package/src/modules/item-management/lib/types.ts +19 -0
  135. package/src/modules/item-management/module.ts +97 -0
  136. package/src/modules/item-management/query/calculateNodeDepth.generated.ts +5 -0
  137. package/src/modules/item-management/query/calculateNodeDepth.test.ts +56 -0
  138. package/src/modules/item-management/query/calculateNodeDepth.ts +28 -0
  139. package/src/modules/item-management/query/calculateSubtreeDepth.generated.ts +5 -0
  140. package/src/modules/item-management/query/calculateSubtreeDepth.test.ts +75 -0
  141. package/src/modules/item-management/query/calculateSubtreeDepth.ts +29 -0
  142. package/src/modules/item-management/query/detectCircularReference.generated.ts +5 -0
  143. package/src/modules/item-management/query/detectCircularReference.test.ts +61 -0
  144. package/src/modules/item-management/query/detectCircularReference.ts +32 -0
  145. package/src/modules/item-management/query/getItem.generated.ts +5 -0
  146. package/src/modules/item-management/query/getItem.test.ts +67 -0
  147. package/src/modules/item-management/query/getItem.ts +20 -0
  148. package/src/modules/item-management/query/getItemTaxonomyAssignment.generated.ts +5 -0
  149. package/src/modules/item-management/query/getItemTaxonomyAssignment.test.ts +25 -0
  150. package/src/modules/item-management/query/getItemTaxonomyAssignment.ts +18 -0
  151. package/src/modules/item-management/query/getTaxonomyNode.generated.ts +5 -0
  152. package/src/modules/item-management/query/getTaxonomyNode.test.ts +47 -0
  153. package/src/modules/item-management/query/getTaxonomyNode.ts +18 -0
  154. package/src/modules/item-management/query/getTaxonomyNodeAssignments.generated.ts +5 -0
  155. package/src/modules/item-management/query/getTaxonomyNodeAssignments.test.ts +25 -0
  156. package/src/modules/item-management/query/getTaxonomyNodeAssignments.ts +16 -0
  157. package/src/modules/item-management/query/getTaxonomyNodeChildren.generated.ts +5 -0
  158. package/src/modules/item-management/query/getTaxonomyNodeChildren.test.ts +34 -0
  159. package/src/modules/item-management/query/getTaxonomyNodeChildren.ts +16 -0
  160. package/src/modules/item-management/tailor.config.ts +11 -0
  161. package/src/modules/item-management/testing/fixtures.ts +81 -0
  162. package/src/modules/primitives/command/activateCategory.generated.ts +6 -0
  163. package/src/modules/primitives/command/activateCategory.test.ts +11 -29
  164. package/src/modules/primitives/command/activateCategory.ts +27 -34
  165. package/src/modules/primitives/command/activateCurrency.generated.ts +6 -0
  166. package/src/modules/primitives/command/activateCurrency.test.ts +11 -29
  167. package/src/modules/primitives/command/activateCurrency.ts +27 -34
  168. package/src/modules/primitives/command/activateUnit.generated.ts +6 -0
  169. package/src/modules/primitives/command/activateUnit.test.ts +11 -15
  170. package/src/modules/primitives/command/activateUnit.ts +27 -34
  171. package/src/modules/primitives/command/createCategory.generated.ts +6 -0
  172. package/src/modules/primitives/command/createCategory.test.ts +27 -39
  173. package/src/modules/primitives/command/createCategory.ts +53 -62
  174. package/src/modules/primitives/command/createCurrency.generated.ts +6 -0
  175. package/src/modules/primitives/command/createCurrency.test.ts +78 -71
  176. package/src/modules/primitives/command/createCurrency.ts +43 -48
  177. package/src/modules/primitives/command/createExchangeRate.generated.ts +6 -0
  178. package/src/modules/primitives/command/createExchangeRate.test.ts +101 -100
  179. package/src/modules/primitives/command/createExchangeRate.ts +50 -59
  180. package/src/modules/primitives/command/createUnit.generated.ts +6 -0
  181. package/src/modules/primitives/command/createUnit.test.ts +92 -95
  182. package/src/modules/primitives/command/createUnit.ts +54 -57
  183. package/src/modules/primitives/command/deactivateCategory.generated.ts +6 -0
  184. package/src/modules/primitives/command/deactivateCategory.test.ts +27 -28
  185. package/src/modules/primitives/command/deactivateCategory.ts +43 -50
  186. package/src/modules/primitives/command/deactivateCurrency.generated.ts +6 -0
  187. package/src/modules/primitives/command/deactivateCurrency.test.ts +23 -38
  188. package/src/modules/primitives/command/deactivateCurrency.ts +31 -38
  189. package/src/modules/primitives/command/deactivateUnit.generated.ts +6 -0
  190. package/src/modules/primitives/command/deactivateUnit.test.ts +27 -23
  191. package/src/modules/primitives/command/deactivateUnit.ts +39 -49
  192. package/src/modules/primitives/command/setBaseCurrency.generated.ts +6 -0
  193. package/src/modules/primitives/command/setBaseCurrency.test.ts +40 -33
  194. package/src/modules/primitives/command/setBaseCurrency.ts +43 -50
  195. package/src/modules/primitives/command/setReferenceUnit.generated.ts +6 -0
  196. package/src/modules/primitives/command/setReferenceUnit.test.ts +39 -35
  197. package/src/modules/primitives/command/setReferenceUnit.ts +46 -59
  198. package/src/modules/primitives/db/unit.ts +13 -3
  199. package/src/modules/primitives/docs/commands/ActivateCategory.md +1 -2
  200. package/src/modules/primitives/docs/commands/ActivateCurrency.md +1 -2
  201. package/src/modules/primitives/docs/commands/ActivateUnit.md +1 -2
  202. package/src/modules/primitives/docs/commands/CreateCategory.md +1 -4
  203. package/src/modules/primitives/docs/commands/CreateCurrency.md +3 -4
  204. package/src/modules/primitives/docs/commands/CreateExchangeRate.md +4 -5
  205. package/src/modules/primitives/docs/commands/CreateUnit.md +5 -5
  206. package/src/modules/primitives/docs/commands/DeactivateCategory.md +2 -3
  207. package/src/modules/primitives/docs/commands/DeactivateCurrency.md +2 -3
  208. package/src/modules/primitives/docs/commands/DeactivateUnit.md +2 -3
  209. package/src/modules/primitives/docs/commands/SetBaseCurrency.md +2 -3
  210. package/src/modules/primitives/docs/commands/SetReferenceUnit.md +2 -3
  211. package/src/modules/primitives/docs/queries/ConvertAmount.md +3 -5
  212. package/src/modules/primitives/docs/queries/ConvertQuantity.md +3 -5
  213. package/src/modules/primitives/docs/queries/GetBaseCurrency.md +32 -0
  214. package/src/modules/primitives/docs/queries/GetCurrency.md +36 -0
  215. package/src/modules/primitives/docs/queries/GetUnit.md +36 -0
  216. package/src/modules/primitives/docs/queries/GetUoMCategory.md +36 -0
  217. package/src/modules/primitives/docs/queries/ListUnitsByCategory.md +26 -0
  218. package/src/modules/primitives/generated/kysely-tailordb.ts +24 -45
  219. package/src/modules/primitives/index.ts +15 -4
  220. package/src/modules/primitives/lib/errors.generated.ts +112 -0
  221. package/src/modules/primitives/{permissions.ts → lib/permissions.generated.ts} +9 -8
  222. package/src/modules/primitives/module.ts +37 -27
  223. package/src/modules/primitives/query/convertAmount.generated.ts +5 -0
  224. package/src/modules/primitives/query/convertAmount.test.ts +2 -2
  225. package/src/modules/primitives/query/convertAmount.ts +27 -28
  226. package/src/modules/primitives/query/convertQuantity.generated.ts +5 -0
  227. package/src/modules/primitives/query/convertQuantity.test.ts +6 -2
  228. package/src/modules/primitives/query/convertQuantity.ts +49 -57
  229. package/src/modules/primitives/query/getBaseCurrency.generated.ts +5 -0
  230. package/src/modules/primitives/query/getBaseCurrency.test.ts +28 -0
  231. package/src/modules/primitives/query/getBaseCurrency.ts +16 -0
  232. package/src/modules/primitives/query/getCurrency.generated.ts +5 -0
  233. package/src/modules/primitives/query/getCurrency.test.ts +47 -0
  234. package/src/modules/primitives/query/getCurrency.ts +18 -0
  235. package/src/modules/primitives/query/getUnit.generated.ts +5 -0
  236. package/src/modules/primitives/query/getUnit.test.ts +47 -0
  237. package/src/modules/primitives/query/getUnit.ts +18 -0
  238. package/src/modules/primitives/query/getUoMCategory.generated.ts +5 -0
  239. package/src/modules/primitives/query/getUoMCategory.test.ts +47 -0
  240. package/src/modules/primitives/query/getUoMCategory.ts +18 -0
  241. package/src/modules/primitives/query/listUnitsByCategory.generated.ts +5 -0
  242. package/src/modules/primitives/query/listUnitsByCategory.ts +16 -0
  243. package/src/modules/primitives/tailor.config.ts +3 -3
  244. package/src/modules/shared/defineCommand.test.ts +23 -10
  245. package/src/modules/shared/defineCommand.ts +23 -10
  246. package/src/modules/shared/internal.ts +1 -0
  247. package/src/modules/shared/requirePermission.test.ts +22 -21
  248. package/src/modules/shared/requirePermission.ts +8 -2
  249. package/src/modules/shared/result.ts +12 -0
  250. package/src/modules/testing/index.ts +36 -11
  251. package/src/modules/user-management/command/activateUser.generated.ts +6 -0
  252. package/src/modules/user-management/command/activateUser.test.ts +27 -27
  253. package/src/modules/user-management/command/activateUser.ts +40 -48
  254. package/src/modules/user-management/command/assignPermissionToRole.generated.ts +6 -0
  255. package/src/modules/user-management/command/assignPermissionToRole.test.ts +42 -43
  256. package/src/modules/user-management/command/assignPermissionToRole.ts +59 -62
  257. package/src/modules/user-management/command/assignRoleToUser.generated.ts +6 -0
  258. package/src/modules/user-management/command/assignRoleToUser.test.ts +70 -63
  259. package/src/modules/user-management/command/assignRoleToUser.ts +63 -66
  260. package/src/modules/user-management/command/createPermission.generated.ts +6 -0
  261. package/src/modules/user-management/command/createPermission.test.ts +45 -38
  262. package/src/modules/user-management/command/createPermission.ts +42 -46
  263. package/src/modules/user-management/command/createRole.generated.ts +6 -0
  264. package/src/modules/user-management/command/createRole.test.ts +30 -29
  265. package/src/modules/user-management/command/createRole.ts +33 -33
  266. package/src/modules/user-management/command/createUser.generated.ts +6 -0
  267. package/src/modules/user-management/command/createUser.test.ts +64 -42
  268. package/src/modules/user-management/command/createUser.ts +54 -56
  269. package/src/modules/user-management/command/deactivateUser.generated.ts +6 -0
  270. package/src/modules/user-management/command/deactivateUser.test.ts +27 -27
  271. package/src/modules/user-management/command/deactivateUser.ts +40 -48
  272. package/src/modules/user-management/command/logAuditEvent.generated.ts +6 -0
  273. package/src/modules/user-management/command/logAuditEvent.test.ts +50 -42
  274. package/src/modules/user-management/command/logAuditEvent.ts +25 -28
  275. package/src/modules/user-management/command/reactivateUser.generated.ts +6 -0
  276. package/src/modules/user-management/command/reactivateUser.test.ts +31 -27
  277. package/src/modules/user-management/command/reactivateUser.ts +40 -48
  278. package/src/modules/user-management/command/revokePermissionFromRole.generated.ts +6 -0
  279. package/src/modules/user-management/command/revokePermissionFromRole.test.ts +52 -51
  280. package/src/modules/user-management/command/revokePermissionFromRole.ts +60 -57
  281. package/src/modules/user-management/command/revokeRoleFromUser.generated.ts +6 -0
  282. package/src/modules/user-management/command/revokeRoleFromUser.test.ts +53 -48
  283. package/src/modules/user-management/command/revokeRoleFromUser.ts +58 -57
  284. package/src/modules/user-management/docs/commands/CreatePermission.md +2 -2
  285. package/src/modules/user-management/docs/commands/CreateRole.md +1 -1
  286. package/src/modules/user-management/generated/enums.ts +11 -11
  287. package/src/modules/user-management/generated/kysely-tailordb.ts +27 -56
  288. package/src/modules/user-management/index.ts +2 -2
  289. package/src/modules/user-management/lib/errors.generated.ts +67 -0
  290. package/src/modules/user-management/{permissions.ts → lib/permissions.generated.ts} +8 -7
  291. package/src/modules/user-management/module.ts +22 -22
  292. package/src/modules/user-management/tailor.config.ts +3 -3
  293. package/src/schemas.ts +1 -1
  294. package/skills/1-module-docs/references/structure.md +0 -22
  295. package/skills/2-module-feature-breakdown/references/commands.md +0 -48
  296. package/skills/2-module-feature-breakdown/references/structure.md +0 -22
  297. package/skills/3-module-doc-review/references/commands.md +0 -54
  298. package/skills/3-module-doc-review/references/models.md +0 -29
  299. package/skills/4-module-tdd-implementation/SKILL.md +0 -74
  300. package/skills/4-module-tdd-implementation/references/commands.md +0 -45
  301. package/skills/4-module-tdd-implementation/references/errors.md +0 -7
  302. package/skills/4-module-tdd-implementation/references/models.md +0 -30
  303. package/skills/4-module-tdd-implementation/references/structure.md +0 -22
  304. package/skills/4-module-tdd-implementation/references/testing.md +0 -37
  305. package/skills/5-module-implementation-review/references/commands.md +0 -45
  306. package/skills/5-module-implementation-review/references/errors.md +0 -7
  307. package/skills/5-module-implementation-review/references/exports.md +0 -8
  308. package/skills/5-module-implementation-review/references/models.md +0 -30
  309. package/skills/app-compose-1-requirement-analysis/references/structure.md +0 -27
  310. package/skills/app-compose-2-requirements-breakdown/references/screen-detailview.md +0 -106
  311. package/skills/app-compose-2-requirements-breakdown/references/screen-form.md +0 -139
  312. package/skills/app-compose-2-requirements-breakdown/references/screen-listview.md +0 -153
  313. package/skills/app-compose-2-requirements-breakdown/references/structure.md +0 -27
  314. package/skills/app-compose-3-doc-review/references/structure.md +0 -27
  315. package/skills/app-compose-4-design-mock/SKILL.md +0 -256
  316. package/skills/app-compose-4-design-mock/references/component.md +0 -50
  317. package/skills/app-compose-4-design-mock/references/screen-detailview.md +0 -106
  318. package/skills/app-compose-4-design-mock/references/screen-form.md +0 -139
  319. package/skills/app-compose-4-design-mock/references/screen-listview.md +0 -153
  320. package/skills/app-compose-4-design-mock/references/structure.md +0 -27
  321. package/skills/app-compose-5-design-mock-review/SKILL.md +0 -290
  322. package/skills/app-compose-5-design-mock-review/references/component.md +0 -50
  323. package/skills/app-compose-5-design-mock-review/references/screen-detailview.md +0 -106
  324. package/skills/app-compose-5-design-mock-review/references/screen-form.md +0 -139
  325. package/skills/app-compose-5-design-mock-review/references/screen-listview.md +0 -153
  326. package/skills/app-compose-6-implementation-spec/references/auth.md +0 -72
  327. package/skills/app-compose-6-implementation-spec/references/structure.md +0 -27
  328. package/src/modules/primitives/lib/errors.ts +0 -138
  329. package/src/modules/user-management/lib/errors.ts +0 -81
  330. /package/skills/{2-module-feature-breakdown → erp-kit-module-4-tdd}/references/models.md +0 -0
@@ -0,0 +1,65 @@
1
+ # Item Taxonomy
2
+
3
+ ## Overview
4
+
5
+ Item Taxonomy organizes items using a structured, hierarchical classification system. Taxonomy nodes form a tree where each node can have a parent, creating multi-level classification (e.g., "Electronics > Computers > Laptops"). Items are linked to taxonomy nodes through a many-to-many relationship, allowing a single item to belong to multiple classification branches simultaneously (e.g., both "Electronics > Smartphones" and "Gift Ideas > Tech Gifts").
6
+
7
+ ## Business Purpose
8
+
9
+ As item catalogs grow, a single flat category structure is insufficient. Item Taxonomy addresses this by:
10
+
11
+ - Enabling multi-dimensional item classification — an item can belong to multiple taxonomy branches
12
+ - Supporting hierarchical browsing and filtering of large item catalogs
13
+ - Enabling consistent item grouping for operations and reporting
14
+ - Organizing items for different audiences (internal operations, eCommerce, procurement)
15
+ - Providing a flexible foundation for future classification needs without restructuring existing data
16
+ - Stable node identification via globally unique code for API references and integrations
17
+
18
+ ## Process Flow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Create Root Taxonomy Node] --> B[Create Child Node]
23
+ B --> C{More Levels?}
24
+ C -->|Yes| B
25
+ C -->|No| D[Assign Items to Taxonomy Nodes]
26
+ D --> E{Move Node?}
27
+ E -->|Yes| F[Validate No Circular Reference]
28
+ F --> G[Update Parent]
29
+ G --> H[Children Move With Parent]
30
+ E -->|No| I{Delete Node?}
31
+ I -->|Yes| J{Has Children or Item Assignments?}
32
+ J -->|Yes| K[Block Deletion]
33
+ J -->|No| L[Delete Node]
34
+ I -->|No| M[Node Active]
35
+ ```
36
+
37
+ ## Scenario Patterns
38
+
39
+ - **Initial Taxonomy Setup**: Administrator creates root nodes with unique codes (e.g., "electronics", "clothing") and populates child nodes for each classification branch
40
+ - **Deep Hierarchy**: "Clothing > Men > Outerwear > Jackets > Winter Jackets" — five levels deep for detailed classification
41
+ - **Multi-Classification**: A "Bluetooth Headset" item is assigned to both "Electronics > Audio" and "Accessories > Travel" taxonomy nodes simultaneously
42
+ - **Node Reparenting**: "Accessories" node moved from under "Clothing" to a root-level node, all child nodes and item assignments preserved
43
+ - **Taxonomy Standards**: "Electronics" node groups items such as laptops, monitors, and accessories under a common branch for operational consistency
44
+ - **Node Rename**: Administrator renames "Accessories" to "Travel Accessories" to better reflect the node's contents — child nodes and item assignments are unaffected
45
+ - **Node Merge**: Two similar nodes consolidated by moving item assignments from one to the other, then deleting the empty node
46
+ - **Reporting by Taxonomy**: Sales report grouped by top-level taxonomy node shows revenue breakdown across item groups (cross-module dependency: reporting/analytics module consumes taxonomy hierarchy)
47
+
48
+ ## Test Cases
49
+
50
+ - Node code must be globally unique across all taxonomy nodes
51
+ - Node code is immutable after creation; only the display name can be updated
52
+ - Moving a node under its own descendant should fail (circular reference prevention)
53
+ - Deleting a node with child nodes should be blocked
54
+ - Deleting a node with assigned items should be blocked
55
+ - Root nodes have no parent (null parent reference)
56
+ - An item can be assigned to multiple taxonomy nodes
57
+ - Removing an item-taxonomy assignment does not affect the item or other assignments
58
+ - Duplicate item-taxonomy assignments (same item + same node) should be rejected
59
+ - Node tree depth should have a configurable maximum to prevent excessively deep hierarchies
60
+
61
+ ## Reference Links
62
+
63
+ - [Akeneo Product Classification](https://docs.akeneo.com/serenity-2025-02/articles/manage-your-categories.html)
64
+ - [Salsify Taxonomy Management](https://www.salsify.com/resources/content/product-taxonomy-management)
65
+ - [Odoo Product Categories](https://www.odoo.com/documentation/19.0/applications/inventory_and_mrp/inventory/product_management.html)
@@ -0,0 +1,36 @@
1
+ # ItemTaxonomyAssignment
2
+
3
+ ## Description
4
+
5
+ ItemTaxonomyAssignment is a join entity that links an Item to a TaxonomyNode, enabling many-to-many classification. A single item can belong to multiple taxonomy branches simultaneously (e.g., both "Electronics > Smartphones" and "Gift Ideas > Tech Gifts"), and a single taxonomy node can have multiple items assigned.
6
+
7
+ ## Domain Model Definitions
8
+
9
+ ### Model type
10
+
11
+ Standard
12
+
13
+ ### Command Definitions
14
+
15
+ - [assignItemToTaxonomy](../commands/AssignItemToTaxonomy.md) - Link an item to a taxonomy node
16
+ - [removeItemFromTaxonomy](../commands/RemoveItemFromTaxonomy.md) - Remove a link between an item and a taxonomy node
17
+
18
+ ### Query Definitions
19
+
20
+ - [GetItemTaxonomyAssignment](../queries/GetItemTaxonomyAssignment.md) - Retrieve an assignment by itemId and taxonomyNodeId
21
+ - [GetTaxonomyNodeAssignments](../queries/GetTaxonomyNodeAssignments.md) - Retrieve item assignments for a given taxonomy node
22
+
23
+ ### Models
24
+
25
+ - ItemTaxonomyAssignment
26
+
27
+ ### Invariants
28
+
29
+ - The combination of item and taxonomy node must be unique (no duplicate assignments)
30
+ - The referenced item must exist
31
+ - The referenced taxonomy node must exist
32
+
33
+ ### Relationships
34
+
35
+ - **References Item**: Each assignment references exactly one Item
36
+ - **References TaxonomyNode**: Each assignment references exactly one TaxonomyNode
@@ -0,0 +1,47 @@
1
+ # TaxonomyNode
2
+
3
+ ## Description
4
+
5
+ TaxonomyNode represents a single node in a hierarchical classification tree used to organize items. Each node has a globally unique code, a display name, and an optional parent reference that defines its position in the tree. Root nodes have no parent. Nodes can be reparented to restructure the tree, and children move with their parent.
6
+
7
+ Examples: "electronics", "electronics > computers", "electronics > computers > laptops".
8
+
9
+ ## Domain Model Definitions
10
+
11
+ ### Model type
12
+
13
+ Standard
14
+
15
+ ### Command Definitions
16
+
17
+ - [createTaxonomyNode](../commands/CreateTaxonomyNode.md) - Create a new root or child taxonomy node
18
+ - [updateTaxonomyNode](../commands/UpdateTaxonomyNode.md) - Update the display name of an existing node
19
+ - [moveTaxonomyNode](../commands/MoveTaxonomyNode.md) - Reparent a node within the tree
20
+ - [deleteTaxonomyNode](../commands/DeleteTaxonomyNode.md) - Delete a leaf node with no item assignments
21
+
22
+ ### Query Definitions
23
+
24
+ - [GetTaxonomyNode](../queries/GetTaxonomyNode.md) - Retrieve a taxonomy node by id or code
25
+ - [GetTaxonomyNodeChildren](../queries/GetTaxonomyNodeChildren.md) - Retrieve direct child nodes of a given node
26
+ - [CalculateNodeDepth](../queries/CalculateNodeDepth.md) - Calculate the depth of a node from root by walking the ancestor chain
27
+ - [CalculateSubtreeDepth](../queries/CalculateSubtreeDepth.md) - Recursively calculate the maximum depth of a node's subtree
28
+ - [DetectCircularReference](../queries/DetectCircularReference.md) - Validate that reparenting would not create a cycle
29
+
30
+ ### Models
31
+
32
+ - TaxonomyNode
33
+
34
+ ### Invariants
35
+
36
+ - Node code must be globally unique across all taxonomy nodes
37
+ - Node code is immutable after creation — it cannot be changed once assigned
38
+ - Root nodes have a null parent reference
39
+ - A node cannot be moved under its own descendant (circular reference prevention)
40
+ - Node tree depth has a configurable maximum (default 10) to prevent excessively deep hierarchies
41
+ - A node with child nodes cannot be deleted
42
+ - A node with assigned items cannot be deleted
43
+
44
+ ### Relationships
45
+
46
+ - **Self-Referential Parent-Child**: Each node optionally references another TaxonomyNode as its parent, forming a tree
47
+ - **Referenced By Item Assignments**: TaxonomyNodes are linked to Items via ItemTaxonomyAssignment (many-to-many)
@@ -0,0 +1,59 @@
1
+ # item
2
+
3
+ ## Description
4
+
5
+ Item is the fundamental SKU-level entity in the ERP system — the sellable, purchasable, and trackable unit referenced by all downstream modules (Sales, Purchasing, Inventory, Manufacturing). Each item has a lifecycle state machine (DRAFT → ACTIVE ↔ INACTIVE), a globally unique SKU identifier, an optional barcode, and an assigned unit of measure.
6
+
7
+ Items can be created in either DRAFT or ACTIVE status. DRAFT items require explicit activation before participating in transactions.
8
+
9
+ ## Domain Model Definitions
10
+
11
+ ### Model type
12
+
13
+ Stateful
14
+
15
+ #### State Transitions
16
+
17
+ ```mermaid
18
+ stateDiagram-v2
19
+ [*] --> Draft: createItem (draft)
20
+ [*] --> Active: createItem (active)
21
+ Draft --> Active: activateItem
22
+ Active --> Inactive: deactivateItem
23
+ Inactive --> Active: reactivateItem
24
+ Draft --> [*]: deleteItem
25
+ ```
26
+
27
+ ### Command Definitions
28
+
29
+ - [createItem](../commands/CreateItem.md) - Create a new item in DRAFT or ACTIVE status
30
+ - [updateItem](../commands/UpdateItem.md) - Update mutable fields (name, barcode, UoM) of an existing item
31
+ - [activateItem](../commands/ActivateItem.md) - Transition item from DRAFT to ACTIVE
32
+ - [deactivateItem](../commands/DeactivateItem.md) - Transition item from ACTIVE to INACTIVE
33
+ - [reactivateItem](../commands/ReactivateItem.md) - Transition item from INACTIVE to ACTIVE
34
+ - [deleteItem](../commands/DeleteItem.md) - Permanently delete a DRAFT item
35
+
36
+ ### Query Definitions
37
+
38
+ - [GetItem](../queries/GetItem.md) - Retrieve an item by id, sku, or barcode
39
+
40
+ ### Models
41
+
42
+ - Item
43
+
44
+ ### Invariants
45
+
46
+ - SKU is required and must be globally unique across all items regardless of status
47
+ - SKU is immutable after assignment (cannot be changed once set)
48
+ - Barcode must be unique across all items when provided
49
+ - Barcode can be updated after creation
50
+ - Only DRAFT items can be deleted; ACTIVE and INACTIVE items are preserved for audit trails
51
+ - Only ACTIVE items can be referenced in new transactions (sales orders, purchase orders)
52
+ - Name is required at creation time
53
+ - UoM can be updated only in DRAFT status — once activated, UoM is locked to preserve transaction consistency
54
+
55
+ ### Relationships
56
+
57
+ - **References Unit**: Each item references a Unit from the primitives module as its unit of measure
58
+ - **Referenced By Taxonomy Assignments**: Items are linked to TaxonomyNodes via ItemTaxonomyAssignment (many-to-many)
59
+ - **Referenced By Downstream Modules**: Items are referenced by Sales, Purchasing, Inventory, and Manufacturing modules
@@ -0,0 +1,36 @@
1
+ # CalculateNodeDepth
2
+
3
+ ## Overview
4
+
5
+ CalculateNodeDepth determines the depth of a taxonomy node in the tree hierarchy by walking up the ancestor chain from a given node to the root. Depth is defined as the number of nodes in the path from root to the target node (root = depth 1). This is essential for enforcing maximum depth constraints when creating or moving taxonomy nodes.
6
+
7
+ ## Business Rules
8
+
9
+ - Depth is calculated by traversing parentId references from the target node up to the root
10
+ - Root nodes (parentId = null) have depth 1
11
+ - Each additional ancestor increments the depth by 1
12
+ - The traversal stops when a node with parentId = null is reached or a parent is not found
13
+ - Used together with maxDepth parameter (default: 10) to enforce tree depth limits
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive nodeId] --> B[Initialize depth = 1, currentId = nodeId]
20
+ B --> C[SELECT node where id = currentId]
21
+ C --> D{Node found?}
22
+ D -->|No| E[Return current depth]
23
+ D -->|Yes| F{parentId is null?}
24
+ F -->|Yes| E
25
+ F -->|No| G[Increment depth]
26
+ G --> H[Set currentId = parentId]
27
+ H --> C
28
+ ```
29
+
30
+ ## External Dependencies
31
+
32
+ - None
33
+
34
+ ## Error Scenarios
35
+
36
+ - **NODE_NOT_FOUND**: The starting node or an ancestor in the chain is not found — traversal stops and returns partial depth
@@ -0,0 +1,40 @@
1
+ # CalculateSubtreeDepth
2
+
3
+ ## Overview
4
+
5
+ CalculateSubtreeDepth recursively calculates the maximum depth of a node's subtree, including the node itself. This is used in conjunction with CalculateNodeDepth to determine the total tree depth after a move operation, ensuring the combined depth does not exceed the maximum allowed depth.
6
+
7
+ ## Business Rules
8
+
9
+ - A leaf node (no children) has subtree depth of 1
10
+ - For nodes with children, subtree depth = 1 + max(child subtree depths)
11
+ - All children are fetched by querying parentId = nodeId
12
+ - Recursion continues until leaf nodes are reached
13
+ - The calculation is exhaustive — it traverses the entire subtree
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive nodeId] --> B[SELECT all children where parentId = nodeId]
20
+ B --> C{Has children?}
21
+ C -->|No| D[Return 1]
22
+ C -->|Yes| E[Initialize maxChildDepth = 0]
23
+ E --> F[For each child]
24
+ F --> G[Recursively calculate child subtree depth]
25
+ G --> H{childDepth > maxChildDepth?}
26
+ H -->|Yes| I[Update maxChildDepth = childDepth]
27
+ H -->|No| J[Continue to next child]
28
+ I --> J
29
+ J --> K{More children?}
30
+ K -->|Yes| F
31
+ K -->|No| L[Return 1 + maxChildDepth]
32
+ ```
33
+
34
+ ## External Dependencies
35
+
36
+ - None
37
+
38
+ ## Error Scenarios
39
+
40
+ - **MAX_DEPTH_EXCEEDED**: Combined new parent depth + subtree depth exceeds maxDepth — enforced by the calling command, not this query directly
@@ -0,0 +1,41 @@
1
+ # DetectCircularReference
2
+
3
+ ## Overview
4
+
5
+ DetectCircularReference validates that reparenting a taxonomy node would not create a circular reference in the tree hierarchy. It walks up the ancestor chain from the proposed new parent, checking whether the node being moved appears as an ancestor. If the moved node is found in the ancestor chain, the move would create a cycle.
6
+
7
+ ## Business Rules
8
+
9
+ - A node cannot be moved to become a descendant of itself
10
+ - Self-referencing is explicitly rejected: newParentId === nodeId
11
+ - Ancestor chain is traversed from the new parent upward to the root
12
+ - If the moved node's ID is found in the ancestor chain, the move is circular
13
+ - Traversal stops at root (parentId = null) or broken chain (parent not found)
14
+ - Only relevant when newParentId is non-null (promoting to root cannot create a cycle)
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive nodeId + newParentId] --> B{newParentId === nodeId?}
21
+ B -->|Yes| C[Return isCircular: true]
22
+ B -->|No| D[Set ancestorId = newParentId]
23
+ D --> E[SELECT ancestor where id = ancestorId]
24
+ E --> F{Ancestor found?}
25
+ F -->|No| G[Return isCircular: false]
26
+ F -->|Yes| H[Set ancestorId = ancestor.parentId]
27
+ H --> I{ancestorId === nodeId?}
28
+ I -->|Yes| C
29
+ I -->|No| J{ancestorId is null?}
30
+ J -->|Yes| G
31
+ J -->|No| E
32
+ ```
33
+
34
+ ## External Dependencies
35
+
36
+ - None
37
+
38
+ ## Error Scenarios
39
+
40
+ - **CIRCULAR_REFERENCE**: The moved node appears in the ancestor chain of the new parent — returns isCircular: true
41
+ - **SELF_REFERENCE**: Node is moved to itself as parent — returns isCircular: true
@@ -0,0 +1,38 @@
1
+ # GetItem
2
+
3
+ ## Overview
4
+
5
+ GetItem retrieves a single item record by id, sku, or barcode. The input is a union type — callers specify exactly one lookup field. This serves as the core item lookup for existence checks, uniqueness validation, and all item lifecycle commands.
6
+
7
+ ## Business Rules
8
+
9
+ - Accepts one of three lookup variants:
10
+ - `{ id }` — retrieves by unique identifier (most common, used for existence/state checks)
11
+ - `{ sku }` — retrieves by SKU code (used for uniqueness validation during creation; SKU is immutable after creation)
12
+ - `{ barcode }` — retrieves by barcode (used for uniqueness validation)
13
+ - Returns the full item record including all fields (id, sku, name, barcode, unitId, status, timestamps)
14
+ - Returns null if no matching item is found
15
+ - All comparisons are exact (case-sensitive)
16
+
17
+ ## Process Flow
18
+
19
+ ```mermaid
20
+ flowchart TD
21
+ A[Receive input] --> B{Which field?}
22
+ B -->|id| C[SELECT from Item where id = input.id]
23
+ B -->|sku| D[SELECT from Item where sku = input.sku]
24
+ B -->|barcode| E[SELECT from Item where barcode = input.barcode]
25
+ C --> H{Item found?}
26
+ D --> H
27
+ E --> H
28
+ H -->|Yes| I[Return item record]
29
+ H -->|No| J[Return null]
30
+ ```
31
+
32
+ ## External Dependencies
33
+
34
+ - None
35
+
36
+ ## Error Scenarios
37
+
38
+ - **ITEM_NOT_FOUND**: No item matches the given criteria — caller receives null
@@ -0,0 +1,29 @@
1
+ # GetItemTaxonomyAssignment
2
+
3
+ ## Overview
4
+
5
+ GetItemTaxonomyAssignment retrieves a specific item-to-taxonomy-node assignment by the composite key of itemId and taxonomyNodeId. Used for duplicate detection during assignment creation and existence verification before removal.
6
+
7
+ ## Business Rules
8
+
9
+ - Searches ItemTaxonomyAssignment table using both itemId AND taxonomyNodeId as a composite filter
10
+ - Returns the full assignment record if found (id, itemId, taxonomyNodeId, timestamps)
11
+ - Returns null if no assignment exists for the given pair
12
+
13
+ ## Process Flow
14
+
15
+ ```mermaid
16
+ flowchart TD
17
+ A[Receive itemId + taxonomyNodeId] --> B[SELECT from ItemTaxonomyAssignment where itemId = input AND taxonomyNodeId = input]
18
+ B --> C{Assignment found?}
19
+ C -->|Yes| D[Return assignment record]
20
+ C -->|No| E[Return null]
21
+ ```
22
+
23
+ ## External Dependencies
24
+
25
+ - None
26
+
27
+ ## Error Scenarios
28
+
29
+ - **ASSIGNMENT_NOT_FOUND**: No assignment exists for the item-node pair — caller receives null
@@ -0,0 +1,35 @@
1
+ # GetTaxonomyNode
2
+
3
+ ## Overview
4
+
5
+ GetTaxonomyNode retrieves a single taxonomy node by id or code. The input is a union type — callers specify exactly one lookup field. This serves as the core taxonomy node lookup for existence checks, uniqueness validation, and as the starting point for tree traversal operations.
6
+
7
+ ## Business Rules
8
+
9
+ - Accepts one of two lookup variants:
10
+ - `{ id }` — retrieves by unique identifier (used for existence checks and tree operations)
11
+ - `{ code }` — retrieves by code (used for uniqueness validation during creation; code is immutable after creation)
12
+ - Returns the full taxonomy node record (id, code, name, parentId, timestamps)
13
+ - Returns null if no matching node is found
14
+ - All comparisons are exact (case-sensitive)
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive input] --> B{Which field?}
21
+ B -->|id| C[SELECT from TaxonomyNode where id = input.id]
22
+ B -->|code| D[SELECT from TaxonomyNode where code = input.code]
23
+ C --> E{Node found?}
24
+ D --> E
25
+ E -->|Yes| F[Return node record]
26
+ E -->|No| G[Return null]
27
+ ```
28
+
29
+ ## External Dependencies
30
+
31
+ - None
32
+
33
+ ## Error Scenarios
34
+
35
+ - **NODE_NOT_FOUND**: No taxonomy node matches the given criteria — caller receives null
@@ -0,0 +1,29 @@
1
+ # GetTaxonomyNodeAssignments
2
+
3
+ ## Overview
4
+
5
+ GetTaxonomyNodeAssignments retrieves item assignments for a given taxonomy node. Used as a guard check before node deletion to ensure no items are classified under the node being removed.
6
+
7
+ ## Business Rules
8
+
9
+ - Searches ItemTaxonomyAssignment table for records with taxonomyNodeId matching the given node ID
10
+ - Returns all matching assignment records as an array
11
+ - Returns an empty array if the node has no item assignments
12
+
13
+ ## Process Flow
14
+
15
+ ```mermaid
16
+ flowchart TD
17
+ A[Receive taxonomyNodeId] --> B[SELECT from ItemTaxonomyAssignment where taxonomyNodeId = input]
18
+ B --> C{Assignments found?}
19
+ C -->|Yes| D[Return assignment records]
20
+ C -->|No| E[Return empty array]
21
+ ```
22
+
23
+ ## External Dependencies
24
+
25
+ - None
26
+
27
+ ## Error Scenarios
28
+
29
+ - **NO_ASSIGNMENTS**: No item assignments exist for the given node — caller receives empty array
@@ -0,0 +1,29 @@
1
+ # GetTaxonomyNodeChildren
2
+
3
+ ## Overview
4
+
5
+ GetTaxonomyNodeChildren retrieves the direct child nodes of a given taxonomy node. Used as a guard check before node deletion to enforce the constraint that only leaf nodes can be deleted.
6
+
7
+ ## Business Rules
8
+
9
+ - Searches TaxonomyNode table for records with parentId matching the given node ID
10
+ - Returns all matching child node records as an array
11
+ - Returns an empty array if the node has no children (is a leaf node)
12
+
13
+ ## Process Flow
14
+
15
+ ```mermaid
16
+ flowchart TD
17
+ A[Receive parentId] --> B[SELECT from TaxonomyNode where parentId = input]
18
+ B --> C{Children found?}
19
+ C -->|Yes| D[Return child records]
20
+ C -->|No| E[Return empty array]
21
+ ```
22
+
23
+ ## External Dependencies
24
+
25
+ - None
26
+
27
+ ## Error Scenarios
28
+
29
+ - **NO_CHILDREN**: No child nodes exist for the given parent — caller receives empty array
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Lifecycle status: DRAFT, ACTIVE, INACTIVE
3
+ */
4
+ export const ItemStatus = {
5
+ "DRAFT": "DRAFT",
6
+ "ACTIVE": "ACTIVE",
7
+ "INACTIVE": "INACTIVE"
8
+ } as const;
9
+ export type ItemStatus = (typeof ItemStatus)[keyof typeof ItemStatus];
@@ -0,0 +1,62 @@
1
+ import {
2
+ createGetDB,
3
+ type Generated,
4
+ type Timestamp,
5
+ type NamespaceDB,
6
+ type NamespaceInsertable,
7
+ type NamespaceSelectable,
8
+ type NamespaceTable,
9
+ type NamespaceTableName,
10
+ type NamespaceTransaction,
11
+ type NamespaceUpdateable,
12
+ } from "@tailor-platform/sdk/kysely";
13
+
14
+ export interface Namespace {
15
+ "main-db": {
16
+ Item: {
17
+ id: Generated<string>;
18
+ sku: string;
19
+ name: string;
20
+ barcode: string | null;
21
+ unitId: string;
22
+ status: "DRAFT" | "ACTIVE" | "INACTIVE";
23
+ createdAt: Generated<Timestamp>;
24
+ updatedAt: Timestamp | null;
25
+ }
26
+
27
+ ItemTaxonomyAssignment: {
28
+ id: Generated<string>;
29
+ itemId: string;
30
+ taxonomyNodeId: string;
31
+ createdAt: Generated<Timestamp>;
32
+ updatedAt: Timestamp | null;
33
+ }
34
+
35
+ TaxonomyNode: {
36
+ id: Generated<string>;
37
+ code: string;
38
+ name: string;
39
+ parentId: string | null;
40
+ createdAt: Generated<Timestamp>;
41
+ updatedAt: Timestamp | null;
42
+ }
43
+
44
+ Unit: {
45
+ id: Generated<string>;
46
+ }
47
+ }
48
+ }
49
+
50
+ export const getDB = createGetDB<Namespace>();
51
+
52
+ export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
53
+
54
+ export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
55
+ NamespaceTransaction<Namespace, K>;
56
+
57
+ type TableName = NamespaceTableName<Namespace>;
58
+ export type Table<T extends TableName> = NamespaceTable<Namespace, T>;
59
+
60
+ export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;
61
+ export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;
62
+ export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;
@@ -0,0 +1,53 @@
1
+ export { defineModule } from "./module";
2
+ export { permissions, own, all } from "./lib/permissions.generated";
3
+
4
+ // generated types
5
+ export { ItemStatus } from "./generated/enums";
6
+
7
+ // errors
8
+ export {
9
+ ItemNotFoundError,
10
+ DuplicateSkuError,
11
+ DuplicateBarcodeError,
12
+ UnitNotFoundError,
13
+ SkuImmutableError,
14
+ UomLockedError,
15
+ NoFieldsToUpdateError,
16
+ InvalidStateTransitionError,
17
+ DeleteNonDraftError,
18
+ NodeNotFoundError,
19
+ DuplicateNodeCodeError,
20
+ ParentNodeNotFoundError,
21
+ MaxDepthExceededError,
22
+ CodeImmutableError,
23
+ MissingRequiredFieldsError,
24
+ CircularReferenceError,
25
+ NodeHasChildrenError,
26
+ NodeHasAssignmentsError,
27
+ DuplicateAssignmentError,
28
+ AssignmentNotFoundError,
29
+ } from "./lib/errors.generated";
30
+
31
+ // query input types
32
+ export { type GetItemInput } from "./query/getItem";
33
+ export { type GetTaxonomyNodeInput } from "./query/getTaxonomyNode";
34
+ export { type GetTaxonomyNodeChildrenInput } from "./query/getTaxonomyNodeChildren";
35
+ export { type GetItemTaxonomyAssignmentInput } from "./query/getItemTaxonomyAssignment";
36
+ export { type GetTaxonomyNodeAssignmentsInput } from "./query/getTaxonomyNodeAssignments";
37
+ export { type CalculateNodeDepthInput } from "./query/calculateNodeDepth";
38
+ export { type CalculateSubtreeDepthInput } from "./query/calculateSubtreeDepth";
39
+ export { type DetectCircularReferenceInput } from "./query/detectCircularReference";
40
+
41
+ // command input types
42
+ export { type CreateItemInput } from "./command/createItem";
43
+ export { type UpdateItemInput } from "./command/updateItem";
44
+ export { type ActivateItemInput } from "./command/activateItem";
45
+ export { type DeactivateItemInput } from "./command/deactivateItem";
46
+ export { type ReactivateItemInput } from "./command/reactivateItem";
47
+ export { type DeleteItemInput } from "./command/deleteItem";
48
+ export { type CreateTaxonomyNodeInput } from "./command/createTaxonomyNode";
49
+ export { type UpdateTaxonomyNodeInput } from "./command/updateTaxonomyNode";
50
+ export { type MoveTaxonomyNodeInput } from "./command/moveTaxonomyNode";
51
+ export { type DeleteTaxonomyNodeInput } from "./command/deleteTaxonomyNode";
52
+ export { type AssignItemToTaxonomyInput } from "./command/assignItemToTaxonomy";
53
+ export { type RemoveItemFromTaxonomyInput } from "./command/removeItemFromTaxonomy";
@@ -0,0 +1,13 @@
1
+ // Stub types for cross-module dependencies — used only for codegen.
2
+ // At runtime, actual types are injected via defineModule() params.
3
+ // TODO: Replace with SDK-level externalTypes support when available.
4
+ import {
5
+ db,
6
+ unsafeAllowAllGqlPermission,
7
+ unsafeAllowAllTypePermission,
8
+ } from "@tailor-platform/sdk";
9
+
10
+ export const unit = db
11
+ .type("Unit", {})
12
+ .permission(unsafeAllowAllTypePermission)
13
+ .gqlPermission(unsafeAllowAllGqlPermission);