@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,242 @@
1
+ # Frontend Implementation Patterns
2
+
3
+ ## Table of Contents
4
+
5
+ - [Frontend Scaffold](#frontend-scaffold)
6
+ - [Frontend Pages](#frontend-pages)
7
+
8
+ ---
9
+
10
+ ## Frontend Scaffold
11
+
12
+ ```
13
+ frontend/
14
+ ├── src/
15
+ │ ├── main.tsx, App.tsx, index.css
16
+ │ ├── graphql/
17
+ │ │ ├── index.ts # gql.tada setup
18
+ │ │ └── generated/ # Placeholder until backend deploy
19
+ │ ├── lib/
20
+ │ │ ├── auth-client.ts
21
+ │ │ └── utils.ts # cn() utility
22
+ │ ├── providers/
23
+ │ │ └── graphql-provider.tsx # urql client with DPoP auth
24
+ │ ├── components/
25
+ │ │ ├── ui/ # shadcn/Radix primitives
26
+ │ │ └── composed/ # empty-state, error-fallback, loading
27
+ │ └── pages/
28
+ │ └── <domain>/
29
+ │ ├── page.tsx # Module redirect (REQUIRED)
30
+ │ └── <entity>/
31
+ │ ├── page.tsx # ListView
32
+ │ ├── components/<entities>-table.tsx
33
+ │ ├── create/page.tsx + components/create-<entity>-form.tsx
34
+ │ └── [id]/
35
+ │ ├── page.tsx # DetailView
36
+ │ ├── components/<entity>-detail.tsx, <entity>-actions.tsx
37
+ │ └── edit/page.tsx + components/edit-<entity>-form.tsx
38
+ ├── scripts/generate-graphql.mjs
39
+ ├── package.json, vite.config.ts, tsconfig.json, eslint.config.js
40
+ └── components.json
41
+ ```
42
+
43
+ `package.json` key dependencies and scripts:
44
+
45
+ ```json
46
+ {
47
+ "type": "module",
48
+ "scripts": {
49
+ "dev": "vite",
50
+ "build": "tsc -b && vite build",
51
+ "generate": "node --env-file=.env ./scripts/generate-graphql.mjs",
52
+ "lint": "eslint .",
53
+ "typecheck": "tsc --noEmit"
54
+ },
55
+ "dependencies": {
56
+ "@tailor-platform/app-shell": "...",
57
+ "gql.tada": "...",
58
+ "urql": "...",
59
+ "react-hook-form": "...",
60
+ "@hookform/resolvers": "...",
61
+ "zod": "...",
62
+ "tailwindcss": "...",
63
+ "lucide-react": "..."
64
+ },
65
+ "devDependencies": {
66
+ "@tailor-platform/app-shell-vite-plugin": "...",
67
+ "@tailor-platform/sdk": "...",
68
+ "@tailwindcss/vite": "...",
69
+ "vite": "...",
70
+ "typescript": "..."
71
+ }
72
+ }
73
+ ```
74
+
75
+ `scripts/generate-graphql.mjs` — fetches the GraphQL schema from the deployed backend:
76
+
77
+ ```js
78
+ import { execSync } from "node:child_process";
79
+ const url = process.env.VITE_TAILOR_APP_URL;
80
+ execSync(`pnpm gql-tada generate schema "${url}/query"`);
81
+ execSync("pnpm gql-tada generate output");
82
+ ```
83
+
84
+ Before deployment, create empty placeholders for `src/graphql/generated/schema.graphql` and `graphql-env.d.ts` so the project compiles. After backend deployment, configure `.env` with `VITE_TAILOR_APP_URL` and `VITE_TAILOR_CLIENT_ID`, then run `pnpm generate` to regenerate them.
85
+
86
+ ---
87
+
88
+ ## Frontend Pages
89
+
90
+ ### GraphQL Setup
91
+
92
+ All operations use gql.tada for type safety:
93
+
94
+ ```ts
95
+ import { graphql, type FragmentOf, readFragment } from "@/graphql";
96
+ ```
97
+
98
+ Built-in queries (`gqlOperations: "query"`) generate:
99
+
100
+ - `<Entity>(id: ID!)` — get by ID
101
+ - `<entities>` — list with connection pattern (`edges { node { ... } }`)
102
+
103
+ Mutations are defined by custom resolvers.
104
+
105
+ ### ListView
106
+
107
+ Key points:
108
+
109
+ - Query uses connection pattern: `edges { node { ...Fragment } }`
110
+ - Two-level fragments: row fragment for items, table fragment for the connection
111
+ - `EmptyState` when `edges.length === 0`
112
+ - Columns map to screen spec's "Required Columns"
113
+ - `Layout` with title and create action button
114
+
115
+ ### DetailView
116
+
117
+ Key points:
118
+
119
+ - Two-column `Layout`: detail on left, actions on right
120
+ - `useParams()` to get entity ID from route
121
+ - `DescriptionCard` from `@tailor-platform/app-shell` for key-value fields:
122
+
123
+ ```tsx
124
+ <DescriptionCard
125
+ data={resource}
126
+ title="Overview"
127
+ columns={3}
128
+ fields={[
129
+ { key: "name", label: "Name", meta: { copyable: true } },
130
+ {
131
+ key: "status",
132
+ label: "Status",
133
+ type: "badge",
134
+ meta: { badgeVariantMap: { ACTIVE: "success" } },
135
+ },
136
+ { key: "createdAt", label: "Created At", type: "date", meta: { dateFormat: "medium" } },
137
+ ]}
138
+ />
139
+ ```
140
+
141
+ Field types: `"text"` (default), `"badge"`, `"money"`, `"date"`, `"link"`, `"address"`, `"reference"`, `"divider"`
142
+
143
+ ### Form Pattern
144
+
145
+ Create and edit forms share the same structure:
146
+
147
+ - **React Hook Form + Zod** for validation with `zodResolver`
148
+ - **urql `useMutation`** for GraphQL mutations
149
+ - **Navigate `".."`** to go back to list after success
150
+ - Edit form pre-fills `defaultValues` from existing entity via fragment
151
+
152
+ #### Field Type Mapping
153
+
154
+ | Field Type | Component | Zod Schema |
155
+ | ---------- | ------------------------- | ------------------------------- |
156
+ | Text | `<Input />` | `z.string()` |
157
+ | Textarea | `<textarea />` | `z.string()` |
158
+ | Dropdown | `<Select />` | `z.string()` or `z.enum([...])` |
159
+ | Date | `<Input type="date" />` | `z.string()` (ISO format) |
160
+ | Number | `<Input type="number" />` | `z.coerce.number()` |
161
+ | Checkbox | `<Checkbox />` | `z.boolean()` |
162
+
163
+ #### Validation
164
+
165
+ - **Required: Yes** → `.min(1, "Field is required")` (string) / `.positive()` (number)
166
+ - **Required: No** → `.optional()`
167
+
168
+ ### Shared Component Patterns
169
+
170
+ #### Fragment Collocation
171
+
172
+ Each component defines and exports its own GraphQL fragment. The parent page imports it and includes it in the query:
173
+
174
+ ```tsx
175
+ // components/user-card.tsx
176
+ export const UserCardFragment = graphql(`
177
+ fragment UserCard on User {
178
+ id
179
+ name
180
+ email
181
+ }
182
+ `);
183
+
184
+ export const UserCard = ({ user }: { user: FragmentOf<typeof UserCardFragment> }) => {
185
+ const data = readFragment(UserCardFragment, user);
186
+ return <div>{data.name}</div>;
187
+ };
188
+
189
+ // page.tsx
190
+ const UserQuery = graphql(
191
+ `
192
+ query User($id: ID!) {
193
+ user(id: $id) {
194
+ ...UserCard
195
+ }
196
+ }
197
+ `,
198
+ [UserCardFragment],
199
+ );
200
+ ```
201
+
202
+ #### App.tsx
203
+
204
+ - `AuthGuard` is not exported from app-shell — implement it yourself, pass via `guardComponent` prop
205
+ - `GraphQLProvider` needs `authClient` prop to attach DPoP auth headers
206
+ - Required env vars: `VITE_TAILOR_APP_URL`, `VITE_TAILOR_CLIENT_ID`
207
+ - Auth client: create once in `src/lib/auth-client.ts` using `createAuthClient({ appUri, clientId })`
208
+ - Sidebar: use `SidebarGroup` + `SidebarItem` for custom ordering
209
+
210
+ #### Module-level page.tsx (required)
211
+
212
+ Every module directory must have a `page.tsx` that redirects to the first child. Use **absolute paths** to avoid double-path bugs:
213
+
214
+ ```tsx
215
+ useEffect(() => {
216
+ void navigate("/item-management/item", { replace: true });
217
+ }, [navigate]);
218
+ ```
219
+
220
+ #### Page conventions
221
+
222
+ Every page component must:
223
+
224
+ 1. Be the **default export** of `page.tsx`
225
+ 2. Set `appShellPageProps` with at least `meta.title`
226
+
227
+ #### Common imports
228
+
229
+ ```tsx
230
+ import {
231
+ Layout,
232
+ Link,
233
+ useParams,
234
+ useNavigate,
235
+ type AppShellPageProps,
236
+ } from "@tailor-platform/app-shell";
237
+ import { useQuery, useMutation } from "urql";
238
+ import { graphql, type FragmentOf, readFragment } from "@/graphql";
239
+ import { useForm } from "react-hook-form";
240
+ import { zodResolver } from "@hookform/resolvers/zod";
241
+ import { z } from "zod";
242
+ ```
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: mock-scenario
2
+ name: erp-kit-mock-scenario
3
3
  description: Scaffold a new Mockoon mock scenario with CRUD routes, error scenarios, and registry updates
4
4
  ---
5
5
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: 1-module-docs
2
+ name: erp-kit-module-1-docs
3
3
  description: Create ERP module documentation following framework schemas. Use when starting a new module, documenting an existing module, or when user asks to create module docs, feature docs, or design module features. Guides collaborative research, scoping, and iterative feature breakdown.
4
4
  ---
5
5
 
@@ -108,4 +108,4 @@ pnpm run module:doc:check
108
108
 
109
109
  ## References
110
110
 
111
- - [Module structure](references/structure.md)
111
+ - [Module structure](../erp-kit-module-shared/references/structure.md)
@@ -1,16 +1,16 @@
1
1
  ---
2
- name: 2-module-feature-breakdown
3
- description: Use when breaking down a feature spec into model and command documentation. Triggers on feature implementation planning, creating model docs, creating command docs, or when user references model.yml/command.yml schemas.
2
+ name: erp-kit-module-2-feature-breakdown
3
+ description: Use when breaking down a feature spec into model, command, and query documentation. Triggers on feature implementation planning, creating model docs, creating command docs, creating query docs, or when user references model.yml/command.yml schemas.
4
4
  ---
5
5
 
6
- # Feature Breakdown to Model/Command Docs
6
+ # Feature Breakdown to Model/Command/Query Docs
7
7
 
8
- Convert feature specifications into structured model and command documentation following framework schemas.
8
+ Convert feature specifications into structured model, command, and query documentation following framework schemas.
9
9
 
10
10
  ## When to Use
11
11
 
12
12
  - User has a feature spec (e.g., `docs/features/*.md`) and wants implementation docs
13
- - User asks to create model or command documentation
13
+ - User asks to create model, command, or query documentation
14
14
  - User references `model.yml` or `command.yml` schemas
15
15
 
16
16
  ## Workflow
@@ -25,14 +25,16 @@ Read the feature spec and identify:
25
25
 
26
26
  - **Models**: Entities with state, fields, relationships
27
27
  - **Commands**: Operations that change state (look for verbs in state diagrams)
28
+ - **Queries**: Read-only operations for external consumers — lookups, conversions, aggregations. See [CQRS read rule](../erp-kit-module-shared/references/commands.md#command-side-reads-cqrs-separation)
28
29
 
29
30
  ### 2. Scaffold
30
31
 
31
- For each model and command, scaffold the documentation files using `erp-kit` CLI:
32
+ For each model, command, and query, scaffold the documentation files using `erp-kit` CLI:
32
33
 
33
34
  ```bash
34
35
  erp-kit scaffold --modules-root modules model <module-name> <model-name>
35
36
  erp-kit scaffold --modules-root modules command <module-name> <command-name>
37
+ erp-kit scaffold --modules-root modules query <module-name> <query-name>
36
38
  ```
37
39
 
38
40
  ### 3. Populate
@@ -56,6 +58,9 @@ Schemas are bundled in `@tailor-platform/erp-kit` (model.yml, command.yml).
56
58
  | Verb in state diagram | Command doc |
57
59
  | CRUD operation | Command doc |
58
60
  | Validation logic | Command doc Business Rules |
61
+ | Data lookup | Query doc |
62
+ | Unit/currency convert | Query doc |
63
+ | Computed aggregation | Query doc |
59
64
 
60
65
  ## Validation
61
66
 
@@ -67,6 +72,5 @@ pnpm run module:doc:check
67
72
 
68
73
  ## References
69
74
 
70
- - [Module structure](references/structure.md)
71
- - [Model patterns](references/models.md)
72
- - [Command patterns](references/commands.md)
75
+ - [Command naming convention](references/naming.md)
76
+ - [Module structure](../erp-kit-module-shared/references/structure.md)
@@ -0,0 +1,59 @@
1
+ # Command Naming Convention
2
+
3
+ Commands use imperative `{verb}{Entity}` format. Use this canonical verb vocabulary when scaffolding commands.
4
+
5
+ ## Canonical Verbs
6
+
7
+ | Verb | Meaning | Example |
8
+ | ------------------ | --------------------------------------------------- | ------------------------ |
9
+ | `create` | Insert new entity | `createItem` |
10
+ | `update` | Modify existing entity fields | `updateItem` |
11
+ | `delete` | Permanently remove entity (hard delete) | `deleteItem` |
12
+ | `activate` | Enable entity (inactive → active) | `activateUnit` |
13
+ | `deactivate` | Soft-disable entity (active → inactive, reversible) | `deactivateUnit` |
14
+ | `reactivate` | Re-enable after deactivation | `reactivateItem` |
15
+ | `assign...To...` | Create a relationship between entities | `assignRoleToUser` |
16
+ | `remove...From...` | Remove a relationship between entities | `removeItemFromTaxonomy` |
17
+ | `revoke...From...` | Remove permission/right (RBAC/security domain only) | `revokeRoleFromUser` |
18
+ | `set` | Configure a singular value or reference | `setBaseCurrency` |
19
+ | `move` | Change position or parent in a hierarchy | `moveTaxonomyNode` |
20
+ | `log` | Append-only audit/event record | `logAuditEvent` |
21
+
22
+ ## Choosing the Right Verb
23
+
24
+ - **`delete` vs `deactivate`**: Use `delete` only for permanent removal. Use `deactivate` for soft-disable where the record is preserved.
25
+ - **`remove...From...` vs `revoke...From...`**: Use `revoke` only in security/RBAC contexts (permissions, roles). Use `remove` for all other relationship unlinking.
26
+ - **`assign...To...`**: Always use `assign` to create relationships, never `add...To...`.
27
+ - **`activate` vs `reactivate`**: Use `reactivate` when the command specifically re-enables a previously deactivated entity and the distinction matters for business logic. Otherwise use `activate`.
28
+
29
+ ## Banned Verbs
30
+
31
+ Do not use these — use the canonical alternative instead:
32
+
33
+ | Banned | Use instead |
34
+ | ----------------------- | ------------------------- |
35
+ | `archive` / `unarchive` | `deactivate` / `activate` |
36
+ | `disable` / `enable` | `deactivate` / `activate` |
37
+ | `add...To...` | `assign...To...` |
38
+ | `unlink` | `remove...From...` |
39
+
40
+ ## Domain-Specific Verbs
41
+
42
+ If a feature requires a verb not in this table and the domain experts use it naturally (e.g., `approve`, `reject`, `cancel`, `close`, `submit`), it can be used. Document the rationale in the command doc.
43
+
44
+ ## Feature Operation → Command Name
45
+
46
+ | Feature Operation | Expected Command Doc | Notes |
47
+ | -------------------- | -------------------- | ------------------------------ |
48
+ | "Create X" / "Add X" | `createX` | Never `addX` |
49
+ | "Update X" | `updateX` | |
50
+ | "Delete X" | `deleteX` | Hard delete only |
51
+ | "Deactivate X" | `deactivateX` | Soft-disable (reversible) |
52
+ | "Activate X" | `activateX` | Enable entity |
53
+ | "Reactivate X" | `reactivateX` | Re-enable after deactivation |
54
+ | "Set default X" | `setDefaultX` | Singular value/reference |
55
+ | "Assign X to Y" | `assignXToY` | Never `addXToY` |
56
+ | "Remove X from Y" | `removeXFromY` | Generic relationship unlinking |
57
+ | "Revoke X from Y" | `revokeXFromY` | RBAC/security domain only |
58
+ | "Move X" | `moveX` | Hierarchy position change |
59
+ | "Log X" | `logX` | Append-only audit/event |
@@ -1,15 +1,15 @@
1
1
  ---
2
- name: 3-module-review
3
- description: Review feature parity between feature documentation and command/model documentation. Use when validating that all feature scenarios are covered by command docs, and that all required models exist.
2
+ name: erp-kit-module-3-doc-review
3
+ description: Review feature parity between feature documentation and command/model/query documentation. Use when validating that all feature scenarios are covered by command docs, all read operations have query docs, and that all required models exist.
4
4
  ---
5
5
 
6
6
  # Feature Parity Review Workflow
7
7
 
8
- Review **documentation consistency** between feature specs and command/model docs.
8
+ Review **documentation consistency** between feature specs and command/model/query docs.
9
9
 
10
10
  ## Purpose
11
11
 
12
- Verify that feature documentation (high-level business requirements) is properly covered by command documentation (command specifications) and model documentation (data structures).
12
+ Verify that feature documentation (high-level business requirements) is properly covered by command documentation (write operations), query documentation (read operations), and model documentation (data structures).
13
13
 
14
14
  ```
15
15
  Feature Docs (What) → Command Docs (How) → Model Docs (With What)
@@ -17,18 +17,22 @@ Feature Docs (What) → Command Docs (How) → Model Docs (With What)
17
17
  Scenarios Business Rules Data Structures
18
18
  Process Flows Error Scenarios Relationships
19
19
  Test Cases Process Flows Constraints
20
+ Query Docs (Read)
21
+
22
+ Lookups, Conversions
23
+ Aggregations
20
24
  ```
21
25
 
22
26
  ## When to Use
23
27
 
24
- - After writing feature documentation, check for gaps in command/model documentation
25
- - After writing command/model documentation, verify consistency with features
28
+ - After writing feature documentation, check for gaps in command/model/query documentation
29
+ - After writing command/model/query documentation, verify consistency with features
26
30
  - Quality check during documentation review
27
31
 
28
32
  ## Workflow
29
33
 
30
34
  ```
31
- FEATURE DOCS → COMMAND DOCS → MODEL DOCS → COMPARE → REPORT
35
+ FEATURE DOCS → COMMAND DOCS → QUERY DOCS → MODEL DOCS → COMPARE → REPORT
32
36
  ```
33
37
 
34
38
  ## Step-by-Step
@@ -49,7 +53,15 @@ Read ALL command docs:
49
53
  modules/<module-name>/docs/commands/*.md
50
54
  ```
51
55
 
52
- ### 3. Read Model Documentation
56
+ ### 3. Read Query Documentation
57
+
58
+ Read ALL query docs:
59
+
60
+ ```
61
+ modules/<module-name>/docs/queries/*.md
62
+ ```
63
+
64
+ ### 4. Read Model Documentation
53
65
 
54
66
  Read ALL model docs:
55
67
 
@@ -57,7 +69,7 @@ Read ALL model docs:
57
69
  modules/<module-name>/docs/models/*.md
58
70
  ```
59
71
 
60
- ### 4. Feature → Command Parity Check
72
+ ### 5. Feature → Command Parity Check
61
73
 
62
74
  For each feature's scenarios and test cases:
63
75
 
@@ -75,7 +87,23 @@ For each feature's scenarios and test cases:
75
87
  3. Verify corresponding command doc exists
76
88
  4. Map feature test cases to command business rules / error scenarios
77
89
 
78
- ### 5. Feature → Model Parity Check
90
+ ### 6. Feature → Query Parity Check
91
+
92
+ For each read operation implied by the feature:
93
+
94
+ | Check Item | Question |
95
+ | --------------- | --------------------------------------------------------------------- |
96
+ | Query existence | Does a query doc exist for lookups, conversions, or aggregations? |
97
+ | Input coverage | Are all lookup dimensions documented (by id, by unique field, by FK)? |
98
+ | Error handling | Are error scenarios for missing data documented? |
99
+
100
+ #### How to Check
101
+
102
+ 1. Identify read-only operations in the feature: "look up", "get", "list", "convert", "calculate"
103
+ 2. Verify corresponding query doc exists in `docs/queries/`
104
+ 3. Check that query docs have error scenarios where applicable
105
+
106
+ ### 7. Feature → Model Parity Check
79
107
 
80
108
  For each entity mentioned in feature:
81
109
 
@@ -85,7 +113,7 @@ For each entity mentioned in feature:
85
113
  | State management | Do feature state transitions match model state transitions? |
86
114
  | Relationships | Are relationships shown in feature defined in model relationships? |
87
115
 
88
- ### 6. Command → Model Consistency Check
116
+ ### 8. Command → Model Consistency Check
89
117
 
90
118
  For each command doc:
91
119
 
@@ -94,7 +122,7 @@ For each command doc:
94
122
  | Target model | Does a model doc exist for the model that command operates on? |
95
123
  | State transition alignment | Do state changes by command match model state transitions? |
96
124
 
97
- ### 7. Report Findings
125
+ ### 9. Report Findings
98
126
 
99
127
  ```markdown
100
128
  ## Feature Parity Review Report
@@ -142,6 +170,12 @@ For each command doc:
142
170
  | <feature-2> | <cmd-f> | <purpose description> |
143
171
  | <feature-2> | <cmd-g> | <purpose description> |
144
172
 
173
+ #### Missing Query Docs
174
+
175
+ | Feature | Expected Query | Purpose |
176
+ | ----------- | -------------- | --------------------- |
177
+ | <feature-1> | <query-a> | <purpose description> |
178
+
145
179
  #### Missing Model Docs
146
180
 
147
181
  (none found)
@@ -162,6 +196,7 @@ For each command doc:
162
196
  | Aspect | Status | Details |
163
197
  | -------------------------- | ------ | ------------------------------------------- |
164
198
  | Feature → Command Coverage | ⚠️ | X/Y features have complete command coverage |
199
+ | Feature → Query Coverage | ⚠️ | X/Y read operations have query docs |
165
200
  | Feature → Model Coverage | ✅ | All required models documented |
166
201
  | Test Case Coverage | ⚠️ | X/Y test cases mapped to business rules |
167
202
  | Documentation Consistency | ⚠️ | N inconsistencies found |
@@ -186,6 +221,12 @@ For each command doc:
186
221
  - **Implicit commands**: Feature scenario requires helper command not documented
187
222
  - **Default handling**: Feature mentions "default" selection but no setDefault command
188
223
 
224
+ ### Feature → Query
225
+
226
+ - **Missing query docs**: Feature implies read operation but no query doc exists
227
+ - **Missing conversions**: Feature mentions unit/currency conversion but no query doc
228
+ - **Missing lookups**: Feature requires data retrieval not covered by a query doc
229
+
189
230
  ### Feature → Model
190
231
 
191
232
  - **Missing models**: Feature references entity with no model doc
@@ -218,19 +259,36 @@ For each command doc:
218
259
 
219
260
  ### Expected Command Docs for Feature
220
261
 
221
- | Feature Operation | Expected Command Doc |
222
- | ----------------- | -------------------- |
223
- | "Add X" | addX / createX |
224
- | "Update X" | updateX |
225
- | "Delete X" | deleteX |
226
- | "Set default X" | setDefaultX |
227
- | "Activate X" | activateX |
228
- | "Deactivate X" | deactivateX |
229
- | "Assign X to Y" | assignXToY |
230
- | "Remove X from Y" | removeXFromY |
262
+ See [command naming convention](../erp-kit-module-2-feature-breakdown/references/naming.md) for the full rule, disambiguation guide, and banned verbs.
263
+
264
+ | Feature Operation | Expected Command Doc | Notes |
265
+ | -------------------- | -------------------- | ------------------------------ |
266
+ | "Create X" / "Add X" | `createX` | Never `addX` |
267
+ | "Update X" | `updateX` | |
268
+ | "Delete X" | `deleteX` | Hard delete only |
269
+ | "Deactivate X" | `deactivateX` | Soft-disable (reversible) |
270
+ | "Activate X" | `activateX` | Enable entity |
271
+ | "Reactivate X" | `reactivateX` | Re-enable after deactivation |
272
+ | "Set default X" | `setDefaultX` | Singular value/reference |
273
+ | "Assign X to Y" | `assignXToY` | Never `addXToY` |
274
+ | "Remove X from Y" | `removeXFromY` | Generic relationship unlinking |
275
+ | "Revoke X from Y" | `revokeXFromY` | RBAC/security domain only |
276
+ | "Move X" | `moveX` | Hierarchy position change |
277
+ | "Log X" | `logX` | Append-only audit/event |
278
+
279
+ **Banned verbs** — flag as naming violation if found:
280
+ `archive`, `unarchive`, `disable`, `enable`, `add...To...`, `unlink`
281
+
282
+ ### Expected Query Docs for Feature
283
+
284
+ | Feature Operation | Expected Query Doc |
285
+ | ----------------- | ------------------- |
286
+ | "Get X" | GetX |
287
+ | "Look up X by Y" | GetX (with Y input) |
288
+ | "List X by Y" | ListXsByY |
289
+ | "Convert X" | ConvertX |
290
+ | "Calculate X" | CalculateX |
231
291
 
232
292
  ## References
233
293
 
234
- - [Model patterns](references/models.md)
235
- - [Command patterns](references/commands.md)
236
- - [Testing patterns](references/testing.md)
294
+ For implementation patterns (models, commands, testing), see erp-kit-module-4-tdd.
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: erp-kit-module-4-tdd
3
+ description: Use when implementing features in any module under modules/. Triggers on TDD workflow, domain command implementation, adding new database models, creating test fixtures, or implementing business logic commands.
4
+ ---
5
+
6
+ # TDD Implementation for Module Development
7
+
8
+ Guide for implementing features in modules using Test-Driven Development.
9
+
10
+ ## When to Use
11
+
12
+ - Implementing new domain commands in any module
13
+ - Implementing read-only queries in any module
14
+ - Adding database models with `@tailor-platform/sdk`
15
+ - Creating tests with `@tailor-platform/erp-kit` testing utilities
16
+ - Implementing business logic (CRUD, state transitions, relationships)
17
+
18
+ ## Workflow
19
+
20
+ ```
21
+ DOCS → MODELS → GENERATE → FIXTURES → TESTS → IMPLEMENT → EXPORT → VERIFY
22
+ ```
23
+
24
+ ## Step-by-Step
25
+
26
+ ### 1. Write Command/Query Docs
27
+
28
+ Write markdown specs under `docs/commands/*.md` and `docs/queries/*.md`. These are the source of truth for error scenarios, permissions, and generated code. See erp-kit-module-1-docs, erp-kit-module-2-feature-breakdown, and erp-kit-module-3-doc-review for documentation workflow.
29
+
30
+ ### 2. Database Models (`db/`)
31
+
32
+ **Read [models rules](references/models.md) and [db-relations rules](references/db-relations.md) before writing any model.**
33
+
34
+ Key patterns: factory function, `db.fields.timestamps()`, `.description()` on fields, `.relation()` for foreign keys.
35
+
36
+ ### 3. Generate Code
37
+
38
+ **Read [generated code rules](references/generated-code.md) for what gets generated and what you write by hand.**
39
+
40
+ ```bash
41
+ # Generate kysely types from models
42
+ pnpm generate
43
+
44
+ # Generate errors, permissions, and command/query shells from docs
45
+ erp-kit module generate code --root <root> <module>
46
+ ```
47
+
48
+ Generated `.generated.ts` files provide: error classes, permission definitions, and command/query shells. Never edit these files.
49
+
50
+ ### 4. Test Fixtures (`testing/fixtures.ts`)
51
+
52
+ **Read [testing rules](../erp-kit-module-shared/references/testing.md) before writing fixtures or tests.**
53
+
54
+ ### 5. Write Tests First (`command/*.test.ts`)
55
+
56
+ Same reference: [testing rules](../erp-kit-module-shared/references/testing.md).
57
+
58
+ Key patterns: `createMockDb<DB>()`, fixed IDs `"entity-1"`, cover all doc branches.
59
+
60
+ ### 6. Implement Commands (`command/*.ts`)
61
+
62
+ **Read [commands rules](../erp-kit-module-shared/references/commands.md) before implementing.**
63
+
64
+ Key patterns: export `run` function, generated shell wraps with `defineCommand(permissions.xxx, run)`, generic `CF` for custom fields, validate → query → mutate.
65
+
66
+ ### 7. Implement Queries (`query/*.ts`)
67
+
68
+ **Read [queries rules](../erp-kit-module-shared/references/queries.md) before implementing.**
69
+
70
+ Key patterns: `defineQuery`, `ReadonlyDB<DB>`, `QueryContext`. Generated queries handle simple lookups; write custom queries for joins, aggregations, complex filters.
71
+
72
+ ### 8. Export (`index.ts`)
73
+
74
+ **Read [exports rules](references/exports.md) for export order.**
75
+
76
+ ### 9. Verify
77
+
78
+ ```bash
79
+ pnpm generate # Regenerate types if models changed
80
+ pnpm lint # Check code style
81
+ pnpm typecheck # Verify TypeScript types
82
+ pnpm test # Run all tests
83
+ ```
84
+
85
+ ## References
86
+
87
+ - [Module structure](../erp-kit-module-shared/references/structure.md)
88
+ - [Model patterns](references/models.md)
89
+ - [Database relations](references/db-relations.md)
90
+ - [Command patterns](../erp-kit-module-shared/references/commands.md)
91
+ - [Query patterns](../erp-kit-module-shared/references/queries.md)
92
+ - [Generated code](references/generated-code.md)
93
+ - [Testing patterns](../erp-kit-module-shared/references/testing.md)
94
+ - [Export order](references/exports.md)