@tailor-platform/erp-kit 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +81 -12
- package/dist/cli.js +1070 -450
- package/package.json +11 -8
- package/schemas/module/model.yml +5 -0
- package/skills/{app-compose-1-requirement-analysis → erp-kit-app-1-requirements}/SKILL.md +2 -2
- package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/SKILL.md +3 -3
- package/skills/{app-compose-3-doc-review → erp-kit-app-3-doc-review}/SKILL.md +2 -2
- package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/SKILL.md +3 -3
- package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/SKILL.md +4 -4
- package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/SKILL.md +3 -3
- package/skills/{mock-scenario → erp-kit-mock-scenario}/SKILL.md +1 -1
- package/skills/{1-module-docs → erp-kit-module-1-docs}/SKILL.md +2 -2
- package/skills/{2-module-feature-breakdown → erp-kit-module-2-feature-breakdown}/SKILL.md +13 -9
- package/skills/erp-kit-module-2-feature-breakdown/references/naming.md +59 -0
- package/skills/{3-module-doc-review → erp-kit-module-3-doc-review}/SKILL.md +83 -25
- package/skills/erp-kit-module-4-tdd/SKILL.md +94 -0
- package/skills/erp-kit-module-4-tdd/references/cross-module-dependency.md +133 -0
- package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/db-relations.md +5 -1
- package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/exports.md +1 -1
- package/skills/erp-kit-module-4-tdd/references/generated-code.md +32 -0
- package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/SKILL.md +46 -44
- package/skills/erp-kit-module-5-impl-review/references/commands.md +62 -0
- package/skills/erp-kit-module-5-impl-review/references/errors.md +10 -0
- package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/references/testing.md +1 -1
- package/skills/erp-kit-module-shared/SKILL.md +16 -0
- package/skills/erp-kit-module-shared/references/commands.md +203 -0
- package/skills/erp-kit-module-shared/references/errors.md +35 -0
- package/skills/erp-kit-module-shared/references/queries.md +168 -0
- package/skills/erp-kit-module-shared/references/structure.md +36 -0
- package/skills/{3-module-doc-review → erp-kit-module-shared}/references/testing.md +4 -3
- package/skills/erp-kit-update/SKILL.md +64 -0
- package/src/cli.doc.test.ts +65 -0
- package/src/cli.ts +3 -35
- package/src/commands/app/index.ts +3 -3
- package/src/commands/check.test.ts +1 -1
- package/src/commands/check.ts +2 -2
- package/src/commands/index.ts +73 -0
- package/src/commands/init.test.ts +22 -5
- package/src/commands/init.ts +25 -16
- package/src/commands/license.ts +193 -0
- package/src/commands/mock/index.ts +2 -2
- package/src/commands/mock/start.ts +1 -1
- package/src/commands/mock/validate.test.ts +1 -1
- package/src/commands/module/generate.ts +35 -0
- package/src/commands/module/index.ts +6 -4
- package/src/commands/module/list.test.ts +7 -12
- package/src/commands/module/list.ts +1 -1
- package/src/commands/scaffold-templates.ts +65 -0
- package/src/commands/scaffold.test.ts +92 -2
- package/src/commands/scaffold.ts +22 -2
- package/src/commands/sync-check.test.ts +60 -1
- package/src/commands/sync-check.ts +35 -2
- package/src/generator/generate-code.test.ts +200 -0
- package/src/generator/generate-code.ts +260 -0
- package/src/generator/parse-command-doc.test.ts +159 -0
- package/src/generator/parse-command-doc.ts +116 -0
- package/src/integration.test.ts +2 -2
- package/src/module.ts +6 -6
- package/src/modules/item-management/README.md +38 -0
- package/src/modules/item-management/command/activateItem.generated.ts +6 -0
- package/src/modules/item-management/command/activateItem.test.ts +76 -0
- package/src/modules/item-management/command/activateItem.ts +42 -0
- package/src/modules/item-management/command/assignItemToTaxonomy.generated.ts +6 -0
- package/src/modules/item-management/command/assignItemToTaxonomy.test.ts +88 -0
- package/src/modules/item-management/command/assignItemToTaxonomy.ts +63 -0
- package/src/modules/item-management/command/createItem.generated.ts +6 -0
- package/src/modules/item-management/command/createItem.test.ts +152 -0
- package/src/modules/item-management/command/createItem.ts +72 -0
- package/src/modules/item-management/command/createTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/createTaxonomyNode.test.ts +126 -0
- package/src/modules/item-management/command/createTaxonomyNode.ts +70 -0
- package/src/modules/item-management/command/deactivateItem.generated.ts +6 -0
- package/src/modules/item-management/command/deactivateItem.test.ts +76 -0
- package/src/modules/item-management/command/deactivateItem.ts +42 -0
- package/src/modules/item-management/command/deleteItem.generated.ts +6 -0
- package/src/modules/item-management/command/deleteItem.test.ts +61 -0
- package/src/modules/item-management/command/deleteItem.ts +38 -0
- package/src/modules/item-management/command/deleteTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/deleteTaxonomyNode.test.ts +73 -0
- package/src/modules/item-management/command/deleteTaxonomyNode.ts +50 -0
- package/src/modules/item-management/command/moveTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/moveTaxonomyNode.test.ts +136 -0
- package/src/modules/item-management/command/moveTaxonomyNode.ts +85 -0
- package/src/modules/item-management/command/reactivateItem.generated.ts +6 -0
- package/src/modules/item-management/command/reactivateItem.test.ts +76 -0
- package/src/modules/item-management/command/reactivateItem.ts +42 -0
- package/src/modules/item-management/command/removeItemFromTaxonomy.generated.ts +6 -0
- package/src/modules/item-management/command/removeItemFromTaxonomy.test.ts +43 -0
- package/src/modules/item-management/command/removeItemFromTaxonomy.ts +30 -0
- package/src/modules/item-management/command/updateItem.generated.ts +6 -0
- package/src/modules/item-management/command/updateItem.test.ts +178 -0
- package/src/modules/item-management/command/updateItem.ts +103 -0
- package/src/modules/item-management/command/updateTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/updateTaxonomyNode.test.ts +88 -0
- package/src/modules/item-management/command/updateTaxonomyNode.ts +62 -0
- package/src/modules/item-management/db/item.ts +47 -0
- package/src/modules/item-management/db/itemTaxonomyAssignment.ts +49 -0
- package/src/modules/item-management/db/taxonomyNode.ts +34 -0
- package/src/modules/item-management/docs/commands/ActivateItem.md +32 -0
- package/src/modules/item-management/docs/commands/AssignItemToTaxonomy.md +38 -0
- package/src/modules/item-management/docs/commands/CreateItem.md +44 -0
- package/src/modules/item-management/docs/commands/CreateTaxonomyNode.md +44 -0
- package/src/modules/item-management/docs/commands/DeactivateItem.md +34 -0
- package/src/modules/item-management/docs/commands/DeleteItem.md +35 -0
- package/src/modules/item-management/docs/commands/DeleteTaxonomyNode.md +39 -0
- package/src/modules/item-management/docs/commands/MoveTaxonomyNode.md +45 -0
- package/src/modules/item-management/docs/commands/ReactivateItem.md +34 -0
- package/src/modules/item-management/docs/commands/RemoveItemFromTaxonomy.md +30 -0
- package/src/modules/item-management/docs/commands/UpdateItem.md +55 -0
- package/src/modules/item-management/docs/commands/UpdateTaxonomyNode.md +36 -0
- package/src/modules/item-management/docs/features/item-lifecycle.md +60 -0
- package/src/modules/item-management/docs/features/item-taxonomy.md +65 -0
- package/src/modules/item-management/docs/models/ItemTaxonomyAssignment.md +36 -0
- package/src/modules/item-management/docs/models/TaxonomyNode.md +47 -0
- package/src/modules/item-management/docs/models/item.md +59 -0
- package/src/modules/item-management/docs/queries/CalculateNodeDepth.md +36 -0
- package/src/modules/item-management/docs/queries/CalculateSubtreeDepth.md +40 -0
- package/src/modules/item-management/docs/queries/DetectCircularReference.md +41 -0
- package/src/modules/item-management/docs/queries/GetItem.md +38 -0
- package/src/modules/item-management/docs/queries/GetItemTaxonomyAssignment.md +29 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNode.md +35 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNodeAssignments.md +29 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNodeChildren.md +29 -0
- package/src/modules/item-management/generated/enums.ts +9 -0
- package/src/modules/item-management/generated/kysely-tailordb.ts +62 -0
- package/src/modules/item-management/index.ts +53 -0
- package/src/modules/item-management/lib/_db_deps.ts +13 -0
- package/src/modules/item-management/lib/errors.generated.ts +117 -0
- package/src/modules/item-management/lib/permissions.generated.ts +17 -0
- package/src/modules/item-management/lib/types.ts +19 -0
- package/src/modules/item-management/module.ts +97 -0
- package/src/modules/item-management/query/calculateNodeDepth.generated.ts +5 -0
- package/src/modules/item-management/query/calculateNodeDepth.test.ts +56 -0
- package/src/modules/item-management/query/calculateNodeDepth.ts +28 -0
- package/src/modules/item-management/query/calculateSubtreeDepth.generated.ts +5 -0
- package/src/modules/item-management/query/calculateSubtreeDepth.test.ts +75 -0
- package/src/modules/item-management/query/calculateSubtreeDepth.ts +29 -0
- package/src/modules/item-management/query/detectCircularReference.generated.ts +5 -0
- package/src/modules/item-management/query/detectCircularReference.test.ts +61 -0
- package/src/modules/item-management/query/detectCircularReference.ts +32 -0
- package/src/modules/item-management/query/getItem.generated.ts +5 -0
- package/src/modules/item-management/query/getItem.test.ts +67 -0
- package/src/modules/item-management/query/getItem.ts +20 -0
- package/src/modules/item-management/query/getItemTaxonomyAssignment.generated.ts +5 -0
- package/src/modules/item-management/query/getItemTaxonomyAssignment.test.ts +25 -0
- package/src/modules/item-management/query/getItemTaxonomyAssignment.ts +18 -0
- package/src/modules/item-management/query/getTaxonomyNode.generated.ts +5 -0
- package/src/modules/item-management/query/getTaxonomyNode.test.ts +47 -0
- package/src/modules/item-management/query/getTaxonomyNode.ts +18 -0
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.generated.ts +5 -0
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.test.ts +25 -0
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.ts +16 -0
- package/src/modules/item-management/query/getTaxonomyNodeChildren.generated.ts +5 -0
- package/src/modules/item-management/query/getTaxonomyNodeChildren.test.ts +34 -0
- package/src/modules/item-management/query/getTaxonomyNodeChildren.ts +16 -0
- package/src/modules/item-management/tailor.config.ts +11 -0
- package/src/modules/item-management/testing/fixtures.ts +81 -0
- package/src/modules/primitives/command/activateCategory.generated.ts +6 -0
- package/src/modules/primitives/command/activateCategory.test.ts +11 -29
- package/src/modules/primitives/command/activateCategory.ts +27 -34
- package/src/modules/primitives/command/activateCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/activateCurrency.test.ts +11 -29
- package/src/modules/primitives/command/activateCurrency.ts +27 -34
- package/src/modules/primitives/command/activateUnit.generated.ts +6 -0
- package/src/modules/primitives/command/activateUnit.test.ts +11 -15
- package/src/modules/primitives/command/activateUnit.ts +27 -34
- package/src/modules/primitives/command/createCategory.generated.ts +6 -0
- package/src/modules/primitives/command/createCategory.test.ts +27 -39
- package/src/modules/primitives/command/createCategory.ts +53 -62
- package/src/modules/primitives/command/createCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/createCurrency.test.ts +78 -71
- package/src/modules/primitives/command/createCurrency.ts +43 -48
- package/src/modules/primitives/command/createExchangeRate.generated.ts +6 -0
- package/src/modules/primitives/command/createExchangeRate.test.ts +101 -100
- package/src/modules/primitives/command/createExchangeRate.ts +50 -59
- package/src/modules/primitives/command/createUnit.generated.ts +6 -0
- package/src/modules/primitives/command/createUnit.test.ts +92 -95
- package/src/modules/primitives/command/createUnit.ts +54 -57
- package/src/modules/primitives/command/deactivateCategory.generated.ts +6 -0
- package/src/modules/primitives/command/deactivateCategory.test.ts +27 -28
- package/src/modules/primitives/command/deactivateCategory.ts +43 -50
- package/src/modules/primitives/command/deactivateCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/deactivateCurrency.test.ts +23 -38
- package/src/modules/primitives/command/deactivateCurrency.ts +31 -38
- package/src/modules/primitives/command/deactivateUnit.generated.ts +6 -0
- package/src/modules/primitives/command/deactivateUnit.test.ts +27 -23
- package/src/modules/primitives/command/deactivateUnit.ts +39 -49
- package/src/modules/primitives/command/setBaseCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/setBaseCurrency.test.ts +40 -33
- package/src/modules/primitives/command/setBaseCurrency.ts +43 -50
- package/src/modules/primitives/command/setReferenceUnit.generated.ts +6 -0
- package/src/modules/primitives/command/setReferenceUnit.test.ts +39 -35
- package/src/modules/primitives/command/setReferenceUnit.ts +46 -59
- package/src/modules/primitives/db/unit.ts +13 -3
- package/src/modules/primitives/docs/commands/ActivateCategory.md +1 -2
- package/src/modules/primitives/docs/commands/ActivateCurrency.md +1 -2
- package/src/modules/primitives/docs/commands/ActivateUnit.md +1 -2
- package/src/modules/primitives/docs/commands/CreateCategory.md +1 -4
- package/src/modules/primitives/docs/commands/CreateCurrency.md +3 -4
- package/src/modules/primitives/docs/commands/CreateExchangeRate.md +4 -5
- package/src/modules/primitives/docs/commands/CreateUnit.md +5 -5
- package/src/modules/primitives/docs/commands/DeactivateCategory.md +2 -3
- package/src/modules/primitives/docs/commands/DeactivateCurrency.md +2 -3
- package/src/modules/primitives/docs/commands/DeactivateUnit.md +2 -3
- package/src/modules/primitives/docs/commands/SetBaseCurrency.md +2 -3
- package/src/modules/primitives/docs/commands/SetReferenceUnit.md +2 -3
- package/src/modules/primitives/docs/queries/ConvertAmount.md +3 -5
- package/src/modules/primitives/docs/queries/ConvertQuantity.md +3 -5
- package/src/modules/primitives/docs/queries/GetBaseCurrency.md +32 -0
- package/src/modules/primitives/docs/queries/GetCurrency.md +36 -0
- package/src/modules/primitives/docs/queries/GetUnit.md +36 -0
- package/src/modules/primitives/docs/queries/GetUoMCategory.md +36 -0
- package/src/modules/primitives/docs/queries/ListUnitsByCategory.md +26 -0
- package/src/modules/primitives/generated/kysely-tailordb.ts +24 -45
- package/src/modules/primitives/index.ts +15 -4
- package/src/modules/primitives/lib/errors.generated.ts +112 -0
- package/src/modules/primitives/{permissions.ts → lib/permissions.generated.ts} +9 -8
- package/src/modules/primitives/module.ts +37 -27
- package/src/modules/primitives/query/convertAmount.generated.ts +5 -0
- package/src/modules/primitives/query/convertAmount.test.ts +2 -2
- package/src/modules/primitives/query/convertAmount.ts +27 -28
- package/src/modules/primitives/query/convertQuantity.generated.ts +5 -0
- package/src/modules/primitives/query/convertQuantity.test.ts +6 -2
- package/src/modules/primitives/query/convertQuantity.ts +49 -57
- package/src/modules/primitives/query/getBaseCurrency.generated.ts +5 -0
- package/src/modules/primitives/query/getBaseCurrency.test.ts +28 -0
- package/src/modules/primitives/query/getBaseCurrency.ts +16 -0
- package/src/modules/primitives/query/getCurrency.generated.ts +5 -0
- package/src/modules/primitives/query/getCurrency.test.ts +47 -0
- package/src/modules/primitives/query/getCurrency.ts +18 -0
- package/src/modules/primitives/query/getUnit.generated.ts +5 -0
- package/src/modules/primitives/query/getUnit.test.ts +47 -0
- package/src/modules/primitives/query/getUnit.ts +18 -0
- package/src/modules/primitives/query/getUoMCategory.generated.ts +5 -0
- package/src/modules/primitives/query/getUoMCategory.test.ts +47 -0
- package/src/modules/primitives/query/getUoMCategory.ts +18 -0
- package/src/modules/primitives/query/listUnitsByCategory.generated.ts +5 -0
- package/src/modules/primitives/query/listUnitsByCategory.ts +16 -0
- package/src/modules/primitives/tailor.config.ts +3 -3
- package/src/modules/shared/defineCommand.test.ts +23 -10
- package/src/modules/shared/defineCommand.ts +23 -10
- package/src/modules/shared/internal.ts +1 -0
- package/src/modules/shared/requirePermission.test.ts +22 -21
- package/src/modules/shared/requirePermission.ts +8 -2
- package/src/modules/shared/result.ts +12 -0
- package/src/modules/testing/index.ts +36 -11
- package/src/modules/user-management/command/activateUser.generated.ts +6 -0
- package/src/modules/user-management/command/activateUser.test.ts +27 -27
- package/src/modules/user-management/command/activateUser.ts +40 -48
- package/src/modules/user-management/command/assignPermissionToRole.generated.ts +6 -0
- package/src/modules/user-management/command/assignPermissionToRole.test.ts +42 -43
- package/src/modules/user-management/command/assignPermissionToRole.ts +59 -62
- package/src/modules/user-management/command/assignRoleToUser.generated.ts +6 -0
- package/src/modules/user-management/command/assignRoleToUser.test.ts +70 -63
- package/src/modules/user-management/command/assignRoleToUser.ts +63 -66
- package/src/modules/user-management/command/createPermission.generated.ts +6 -0
- package/src/modules/user-management/command/createPermission.test.ts +45 -38
- package/src/modules/user-management/command/createPermission.ts +42 -46
- package/src/modules/user-management/command/createRole.generated.ts +6 -0
- package/src/modules/user-management/command/createRole.test.ts +30 -29
- package/src/modules/user-management/command/createRole.ts +33 -33
- package/src/modules/user-management/command/createUser.generated.ts +6 -0
- package/src/modules/user-management/command/createUser.test.ts +64 -42
- package/src/modules/user-management/command/createUser.ts +54 -56
- package/src/modules/user-management/command/deactivateUser.generated.ts +6 -0
- package/src/modules/user-management/command/deactivateUser.test.ts +27 -27
- package/src/modules/user-management/command/deactivateUser.ts +40 -48
- package/src/modules/user-management/command/logAuditEvent.generated.ts +6 -0
- package/src/modules/user-management/command/logAuditEvent.test.ts +50 -42
- package/src/modules/user-management/command/logAuditEvent.ts +25 -28
- package/src/modules/user-management/command/reactivateUser.generated.ts +6 -0
- package/src/modules/user-management/command/reactivateUser.test.ts +31 -27
- package/src/modules/user-management/command/reactivateUser.ts +40 -48
- package/src/modules/user-management/command/revokePermissionFromRole.generated.ts +6 -0
- package/src/modules/user-management/command/revokePermissionFromRole.test.ts +52 -51
- package/src/modules/user-management/command/revokePermissionFromRole.ts +60 -57
- package/src/modules/user-management/command/revokeRoleFromUser.generated.ts +6 -0
- package/src/modules/user-management/command/revokeRoleFromUser.test.ts +53 -48
- package/src/modules/user-management/command/revokeRoleFromUser.ts +58 -57
- package/src/modules/user-management/docs/commands/CreatePermission.md +2 -2
- package/src/modules/user-management/docs/commands/CreateRole.md +1 -1
- package/src/modules/user-management/generated/enums.ts +11 -11
- package/src/modules/user-management/generated/kysely-tailordb.ts +27 -56
- package/src/modules/user-management/index.ts +2 -2
- package/src/modules/user-management/lib/errors.generated.ts +67 -0
- package/src/modules/user-management/{permissions.ts → lib/permissions.generated.ts} +8 -7
- package/src/modules/user-management/module.ts +22 -22
- package/src/modules/user-management/tailor.config.ts +3 -3
- package/src/schemas.ts +1 -1
- package/skills/1-module-docs/references/structure.md +0 -22
- package/skills/2-module-feature-breakdown/references/commands.md +0 -48
- package/skills/2-module-feature-breakdown/references/structure.md +0 -22
- package/skills/3-module-doc-review/references/commands.md +0 -54
- package/skills/3-module-doc-review/references/models.md +0 -29
- package/skills/4-module-tdd-implementation/SKILL.md +0 -74
- package/skills/4-module-tdd-implementation/references/commands.md +0 -45
- package/skills/4-module-tdd-implementation/references/errors.md +0 -7
- package/skills/4-module-tdd-implementation/references/models.md +0 -30
- package/skills/4-module-tdd-implementation/references/structure.md +0 -22
- package/skills/4-module-tdd-implementation/references/testing.md +0 -37
- package/skills/5-module-implementation-review/references/commands.md +0 -45
- package/skills/5-module-implementation-review/references/errors.md +0 -7
- package/skills/5-module-implementation-review/references/exports.md +0 -8
- package/skills/5-module-implementation-review/references/models.md +0 -30
- package/src/modules/primitives/lib/errors.ts +0 -138
- package/src/modules/user-management/lib/errors.ts +0 -81
- /package/skills/{app-compose-1-requirement-analysis → erp-kit-app-1-requirements}/references/structure.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-detailview.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-form.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-listview.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/structure.md +0 -0
- /package/skills/{app-compose-3-doc-review → erp-kit-app-3-doc-review}/references/structure.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/component.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-detailview.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-form.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-listview.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/structure.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/component.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-detailview.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-form.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-listview.md +0 -0
- /package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/references/auth.md +0 -0
- /package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/references/structure.md +0 -0
- /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,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);
|