@tailor-platform/erp-kit 0.2.1 → 0.3.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 +18 -0
- package/README.md +154 -80
- package/dist/cli.mjs +1742 -0
- package/package.json +16 -14
- package/schemas/app-compose/story.yml +12 -0
- package/schemas/module/command.yml +9 -0
- package/schemas/module/module.yml +4 -0
- package/schemas/module/query.yml +9 -0
- package/skills/erp-kit-app-1-requirements/SKILL.md +22 -11
- package/skills/erp-kit-app-2-requirements-review/SKILL.md +103 -0
- package/skills/erp-kit-app-2-requirements-review/references/best-practices-check.md +71 -0
- package/skills/erp-kit-app-2-requirements-review/references/boundary-consistency-check.md +74 -0
- package/skills/erp-kit-app-2-requirements-review/references/requirements-report-format.md +25 -0
- package/skills/erp-kit-app-3-plan/SKILL.md +154 -0
- package/skills/erp-kit-app-3-plan/references/resolver-extraction.md +89 -0
- package/skills/erp-kit-app-3-plan/references/screen-extraction.md +74 -0
- package/skills/erp-kit-app-3-plan/references/story-extraction.md +86 -0
- package/skills/erp-kit-app-4-plan-review/SKILL.md +168 -0
- package/skills/erp-kit-app-4-plan-review/references/actor-flow-parity.md +73 -0
- package/skills/erp-kit-app-4-plan-review/references/business-flow-story-parity.md +86 -0
- package/skills/erp-kit-app-4-plan-review/references/orphan-detection.md +69 -0
- package/skills/erp-kit-app-4-plan-review/references/parity-report-format.md +52 -0
- package/skills/erp-kit-app-4-plan-review/references/story-resolver-parity.md +83 -0
- package/skills/erp-kit-app-4-plan-review/references/story-screen-parity.md +73 -0
- package/skills/erp-kit-app-5-impl-backend/SKILL.md +98 -0
- package/skills/erp-kit-app-5-impl-backend/references/app-config.md +38 -0
- package/skills/erp-kit-app-5-impl-backend/references/module-wiring.md +48 -0
- package/skills/erp-kit-app-5-impl-backend/references/resolver-patterns.md +68 -0
- package/skills/erp-kit-app-6-impl-frontend/SKILL.md +74 -0
- package/skills/{erp-kit-app-5-implementation/references/frontend.md → erp-kit-app-6-impl-frontend/references/pages.md} +8 -90
- package/skills/erp-kit-app-7-impl-review/SKILL.md +176 -0
- package/skills/erp-kit-app-7-impl-review/references/impl-parity-report-format.md +52 -0
- package/skills/erp-kit-app-7-impl-review/references/module-wiring-parity.md +84 -0
- package/skills/erp-kit-app-7-impl-review/references/resolver-doc-code-parity.md +86 -0
- package/skills/erp-kit-app-7-impl-review/references/screen-doc-code-parity.md +86 -0
- package/skills/erp-kit-app-shared/SKILL.md +15 -0
- package/skills/erp-kit-app-shared/references/link-format-reference.md +13 -0
- package/skills/erp-kit-app-shared/references/naming-conventions.md +21 -0
- package/skills/erp-kit-app-shared/references/resolver-classification.md +23 -0
- package/skills/erp-kit-app-shared/references/schema-constraints.md +25 -0
- package/skills/erp-kit-module-1-requirements/SKILL.md +126 -0
- package/skills/erp-kit-module-1-requirements/references/boundary-analysis.md +51 -0
- package/skills/erp-kit-module-1-requirements/references/erp-research.md +57 -0
- package/skills/erp-kit-module-1-requirements/references/feature-doc.md +61 -0
- package/skills/erp-kit-module-2-requirements-review/SKILL.md +112 -0
- package/skills/erp-kit-module-2-requirements-review/references/best-practices-check.md +79 -0
- package/skills/erp-kit-module-2-requirements-review/references/boundary-consistency-check.md +70 -0
- package/skills/erp-kit-module-2-requirements-review/references/requirements-report-format.md +25 -0
- package/skills/erp-kit-module-3-plan/SKILL.md +107 -0
- package/skills/erp-kit-module-3-plan/references/command-extraction.md +87 -0
- package/skills/erp-kit-module-3-plan/references/model-extraction.md +72 -0
- package/skills/{erp-kit-module-2-feature-breakdown → erp-kit-module-3-plan}/references/naming.md +15 -1
- package/skills/erp-kit-module-3-plan/references/query-extraction.md +59 -0
- package/skills/erp-kit-module-4-plan-review/SKILL.md +158 -0
- package/skills/erp-kit-module-4-plan-review/references/command-model-consistency.md +46 -0
- package/skills/erp-kit-module-4-plan-review/references/feature-command-parity.md +97 -0
- package/skills/erp-kit-module-4-plan-review/references/feature-model-parity.md +47 -0
- package/skills/erp-kit-module-4-plan-review/references/feature-query-parity.md +70 -0
- package/skills/erp-kit-module-4-plan-review/references/parity-report-format.md +52 -0
- package/skills/erp-kit-module-5-impl/SKILL.md +120 -0
- package/skills/erp-kit-module-5-impl/references/command-impl.md +68 -0
- package/skills/erp-kit-module-5-impl/references/exports.md +10 -0
- package/skills/{erp-kit-module-4-tdd → erp-kit-module-5-impl}/references/generated-code.md +2 -2
- package/skills/erp-kit-module-5-impl/references/model-impl.md +45 -0
- package/skills/erp-kit-module-5-impl/references/query-impl.md +53 -0
- package/skills/erp-kit-module-6-impl-review/SKILL.md +187 -0
- package/skills/erp-kit-module-6-impl-review/references/command-doc-code-parity.md +92 -0
- package/skills/erp-kit-module-6-impl-review/references/command-doc-test-parity.md +93 -0
- package/skills/erp-kit-module-6-impl-review/references/error-implementation-parity.md +95 -0
- package/skills/{erp-kit-module-5-impl-review → erp-kit-module-6-impl-review}/references/errors.md +2 -2
- package/skills/erp-kit-module-6-impl-review/references/impl-parity-report-format.md +52 -0
- package/skills/erp-kit-module-6-impl-review/references/model-doc-code-parity.md +80 -0
- package/skills/erp-kit-module-shared/SKILL.md +1 -1
- package/skills/erp-kit-module-shared/references/commands.md +1 -1
- package/skills/erp-kit-module-shared/references/errors.md +13 -10
- package/skills/erp-kit-module-shared/references/queries.md +110 -37
- package/skills/erp-kit-module-shared/references/structure.md +1 -1
- package/skills/erp-kit-module-shared/references/testing.md +10 -0
- package/skills/erp-kit-update/SKILL.md +4 -4
- package/src/app.ts +1 -1
- package/src/commands/app/index.ts +57 -24
- package/src/commands/check.ts +1 -1
- package/src/commands/generate-doc.test.ts +63 -0
- package/src/commands/generate-doc.ts +98 -0
- package/src/commands/index.ts +16 -5
- package/src/commands/init-module.test.ts +43 -0
- package/src/commands/init-module.ts +74 -0
- package/src/commands/init.test.ts +22 -69
- package/src/commands/init.ts +28 -115
- package/src/commands/lib/distribute.test.ts +126 -0
- package/src/commands/lib/distribute.ts +129 -0
- package/src/commands/module/generate.ts +33 -13
- package/src/commands/module/index.ts +18 -28
- package/src/commands/parse-doc-test-cases.ts +55 -0
- package/src/commands/sync-check.test.ts +173 -0
- package/src/commands/sync-check.ts +103 -2
- package/src/commands/update.test.ts +87 -0
- package/src/commands/update.ts +41 -0
- package/src/generator/generate-code-boilerplate.test.ts +142 -0
- package/src/generator/generate-code.test.ts +47 -12
- package/src/generator/generate-code.ts +123 -20
- package/src/integration.test.ts +3 -3
- package/src/module.ts +14 -97
- package/src/modules/item-management/README.md +8 -0
- package/src/modules/item-management/command/activateItem.generated.ts +1 -1
- package/src/modules/item-management/command/activateItem.test.ts +12 -18
- package/src/modules/item-management/command/activateItem.ts +9 -5
- package/src/modules/item-management/command/assignItemToTaxonomy.generated.ts +1 -1
- package/src/modules/item-management/command/assignItemToTaxonomy.test.ts +10 -24
- package/src/modules/item-management/command/assignItemToTaxonomy.ts +19 -16
- package/src/modules/item-management/command/createItem.generated.ts +1 -1
- package/src/modules/item-management/command/createItem.test.ts +11 -11
- package/src/modules/item-management/command/createItem.ts +16 -7
- package/src/modules/item-management/command/createTaxonomyNode.generated.ts +1 -1
- package/src/modules/item-management/command/createTaxonomyNode.test.ts +9 -9
- package/src/modules/item-management/command/createTaxonomyNode.ts +33 -14
- package/src/modules/item-management/command/deactivateItem.generated.ts +1 -1
- package/src/modules/item-management/command/deactivateItem.test.ts +12 -18
- package/src/modules/item-management/command/deactivateItem.ts +9 -5
- package/src/modules/item-management/command/deleteItem.generated.ts +1 -1
- package/src/modules/item-management/command/deleteItem.test.ts +10 -16
- package/src/modules/item-management/command/deleteItem.ts +9 -5
- package/src/modules/item-management/command/deleteTaxonomyNode.generated.ts +1 -1
- package/src/modules/item-management/command/deleteTaxonomyNode.test.ts +10 -16
- package/src/modules/item-management/command/deleteTaxonomyNode.ts +22 -12
- package/src/modules/item-management/command/moveTaxonomyNode.generated.ts +1 -1
- package/src/modules/item-management/command/moveTaxonomyNode.test.ts +10 -10
- package/src/modules/item-management/command/moveTaxonomyNode.ts +63 -19
- package/src/modules/item-management/command/reactivateItem.generated.ts +1 -1
- package/src/modules/item-management/command/reactivateItem.test.ts +12 -18
- package/src/modules/item-management/command/reactivateItem.ts +9 -5
- package/src/modules/item-management/command/removeItemFromTaxonomy.generated.ts +1 -1
- package/src/modules/item-management/command/removeItemFromTaxonomy.test.ts +9 -16
- package/src/modules/item-management/command/removeItemFromTaxonomy.ts +11 -6
- package/src/modules/item-management/command/updateItem.generated.ts +1 -1
- package/src/modules/item-management/command/updateItem.test.ts +16 -16
- package/src/modules/item-management/command/updateItem.ts +11 -6
- package/src/modules/item-management/command/updateTaxonomyNode.generated.ts +1 -1
- package/src/modules/item-management/command/updateTaxonomyNode.test.ts +14 -20
- package/src/modules/item-management/command/updateTaxonomyNode.ts +9 -6
- package/src/modules/item-management/docs/commands/ActivateItem.md +8 -0
- package/src/modules/item-management/docs/commands/AssignItemToTaxonomy.md +7 -0
- package/src/modules/item-management/docs/commands/CreateItem.md +10 -0
- package/src/modules/item-management/docs/commands/CreateTaxonomyNode.md +9 -0
- package/src/modules/item-management/docs/commands/DeactivateItem.md +8 -0
- package/src/modules/item-management/docs/commands/DeleteItem.md +7 -0
- package/src/modules/item-management/docs/commands/DeleteTaxonomyNode.md +7 -0
- package/src/modules/item-management/docs/commands/MoveTaxonomyNode.md +10 -0
- package/src/modules/item-management/docs/commands/ReactivateItem.md +8 -0
- package/src/modules/item-management/docs/commands/RemoveItemFromTaxonomy.md +5 -0
- package/src/modules/item-management/docs/commands/UpdateItem.md +15 -0
- package/src/modules/item-management/docs/commands/UpdateTaxonomyNode.md +9 -0
- package/src/modules/item-management/docs/queries/CalculateNodeDepth.md +8 -0
- package/src/modules/item-management/docs/queries/CalculateSubtreeDepth.md +7 -0
- package/src/modules/item-management/docs/queries/DetectCircularReference.md +9 -0
- package/src/modules/item-management/docs/queries/GetItem.md +9 -0
- package/src/modules/item-management/docs/queries/GetItemTaxonomyAssignment.md +5 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNode.md +7 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNodeAssignments.md +5 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNodeChildren.md +6 -0
- package/src/modules/item-management/index.ts +0 -51
- package/src/modules/item-management/lib/errors.generated.ts +24 -24
- package/src/modules/item-management/lib/permissions.generated.ts +1 -1
- package/src/modules/item-management/lib/types.ts +1 -1
- package/src/modules/item-management/module.ts +1 -1
- package/src/modules/item-management/query/calculateNodeDepth.generated.ts +1 -1
- package/src/modules/item-management/query/calculateNodeDepth.test.ts +21 -6
- package/src/modules/item-management/query/calculateNodeDepth.ts +2 -2
- package/src/modules/item-management/query/calculateSubtreeDepth.generated.ts +1 -1
- package/src/modules/item-management/query/calculateSubtreeDepth.test.ts +17 -5
- package/src/modules/item-management/query/calculateSubtreeDepth.ts +2 -2
- package/src/modules/item-management/query/detectCircularReference.generated.ts +1 -1
- package/src/modules/item-management/query/detectCircularReference.test.ts +25 -7
- package/src/modules/item-management/query/detectCircularReference.ts +4 -4
- package/src/modules/item-management/query/getItem.generated.ts +1 -1
- package/src/modules/item-management/query/getItem.test.ts +25 -7
- package/src/modules/item-management/query/getItem.ts +2 -2
- package/src/modules/item-management/query/getItemTaxonomyAssignment.generated.ts +1 -1
- package/src/modules/item-management/query/getItemTaxonomyAssignment.test.ts +9 -3
- package/src/modules/item-management/query/getItemTaxonomyAssignment.ts +2 -2
- package/src/modules/item-management/query/getTaxonomyNode.generated.ts +1 -1
- package/src/modules/item-management/query/getTaxonomyNode.test.ts +17 -5
- package/src/modules/item-management/query/getTaxonomyNode.ts +2 -2
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.generated.ts +1 -1
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.test.ts +9 -3
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.ts +2 -2
- package/src/modules/item-management/query/getTaxonomyNodeChildren.generated.ts +1 -1
- package/src/modules/item-management/query/getTaxonomyNodeChildren.test.ts +13 -4
- package/src/modules/item-management/query/getTaxonomyNodeChildren.ts +2 -2
- package/src/modules/item-management/tailor.config.ts +6 -4
- package/src/modules/item-management/tailor.d.ts +13 -0
- package/src/modules/primitives/README.md +8 -0
- package/src/modules/primitives/command/activateCategory.generated.ts +1 -1
- package/src/modules/primitives/command/activateCategory.test.ts +8 -18
- package/src/modules/primitives/command/activateCategory.ts +9 -5
- package/src/modules/primitives/command/activateCurrency.generated.ts +1 -1
- package/src/modules/primitives/command/activateCurrency.test.ts +8 -18
- package/src/modules/primitives/command/activateCurrency.ts +9 -5
- package/src/modules/primitives/command/activateUnit.generated.ts +1 -1
- package/src/modules/primitives/command/activateUnit.test.ts +8 -15
- package/src/modules/primitives/command/activateUnit.ts +9 -5
- package/src/modules/primitives/command/createCategory.generated.ts +1 -1
- package/src/modules/primitives/command/createCategory.test.ts +29 -44
- package/src/modules/primitives/command/createCategory.ts +9 -5
- package/src/modules/primitives/command/createCurrency.generated.ts +1 -1
- package/src/modules/primitives/command/createCurrency.test.ts +53 -78
- package/src/modules/primitives/command/createCurrency.ts +9 -6
- package/src/modules/primitives/command/createExchangeRate.generated.ts +1 -1
- package/src/modules/primitives/command/createExchangeRate.test.ts +59 -97
- package/src/modules/primitives/command/createExchangeRate.ts +13 -7
- package/src/modules/primitives/command/createUnit.generated.ts +1 -1
- package/src/modules/primitives/command/createUnit.test.ts +59 -90
- package/src/modules/primitives/command/createUnit.ts +9 -6
- package/src/modules/primitives/command/deactivateCategory.generated.ts +1 -1
- package/src/modules/primitives/command/deactivateCategory.test.ts +15 -33
- package/src/modules/primitives/command/deactivateCategory.ts +9 -5
- package/src/modules/primitives/command/deactivateCurrency.generated.ts +1 -1
- package/src/modules/primitives/command/deactivateCurrency.test.ts +12 -26
- package/src/modules/primitives/command/deactivateCurrency.ts +9 -5
- package/src/modules/primitives/command/deactivateUnit.generated.ts +1 -1
- package/src/modules/primitives/command/deactivateUnit.test.ts +15 -30
- package/src/modules/primitives/command/deactivateUnit.ts +14 -7
- package/src/modules/primitives/command/setBaseCurrency.generated.ts +1 -1
- package/src/modules/primitives/command/setBaseCurrency.test.ts +18 -40
- package/src/modules/primitives/command/setBaseCurrency.ts +15 -7
- package/src/modules/primitives/command/setReferenceUnit.generated.ts +1 -1
- package/src/modules/primitives/command/setReferenceUnit.test.ts +22 -44
- package/src/modules/primitives/command/setReferenceUnit.ts +21 -9
- package/src/modules/primitives/docs/commands/ActivateCategory.md +6 -0
- package/src/modules/primitives/docs/commands/ActivateCurrency.md +6 -0
- package/src/modules/primitives/docs/commands/ActivateUnit.md +6 -0
- package/src/modules/primitives/docs/commands/CreateCategory.md +6 -0
- package/src/modules/primitives/docs/commands/CreateCurrency.md +10 -0
- package/src/modules/primitives/docs/commands/CreateExchangeRate.md +11 -0
- package/src/modules/primitives/docs/commands/CreateUnit.md +10 -0
- package/src/modules/primitives/docs/commands/DeactivateCategory.md +7 -0
- package/src/modules/primitives/docs/commands/DeactivateCurrency.md +7 -0
- package/src/modules/primitives/docs/commands/DeactivateUnit.md +7 -0
- package/src/modules/primitives/docs/commands/SetBaseCurrency.md +7 -0
- package/src/modules/primitives/docs/commands/SetReferenceUnit.md +7 -0
- package/src/modules/primitives/docs/queries/ConvertAmount.md +14 -0
- package/src/modules/primitives/docs/queries/ConvertQuantity.md +13 -0
- package/src/modules/primitives/docs/queries/GetBaseCurrency.md +5 -0
- package/src/modules/primitives/docs/queries/GetCurrency.md +7 -0
- package/src/modules/primitives/docs/queries/GetUnit.md +7 -0
- package/src/modules/primitives/docs/queries/GetUoMCategory.md +7 -0
- package/src/modules/primitives/docs/queries/ListUnitsByCategory.md +15 -5
- package/src/modules/primitives/index.ts +0 -49
- package/src/modules/primitives/lib/errors.generated.ts +23 -23
- package/src/modules/primitives/lib/permissions.generated.ts +1 -1
- package/src/modules/primitives/lib/types.ts +1 -1
- package/src/modules/primitives/module.ts +1 -1
- package/src/modules/primitives/query/convertAmount.generated.ts +1 -1
- package/src/modules/primitives/query/convertAmount.test.ts +110 -77
- package/src/modules/primitives/query/convertAmount.ts +61 -47
- package/src/modules/primitives/query/convertQuantity.generated.ts +1 -1
- package/src/modules/primitives/query/convertQuantity.test.ts +99 -69
- package/src/modules/primitives/query/convertQuantity.ts +12 -10
- package/src/modules/primitives/query/getBaseCurrency.generated.ts +1 -1
- package/src/modules/primitives/query/getBaseCurrency.test.ts +10 -4
- package/src/modules/primitives/query/getBaseCurrency.ts +2 -2
- package/src/modules/primitives/query/getCurrency.generated.ts +1 -1
- package/src/modules/primitives/query/getCurrency.test.ts +17 -5
- package/src/modules/primitives/query/getCurrency.ts +2 -2
- package/src/modules/primitives/query/getUnit.generated.ts +1 -1
- package/src/modules/primitives/query/getUnit.test.ts +17 -5
- package/src/modules/primitives/query/getUnit.ts +2 -2
- package/src/modules/primitives/query/getUoMCategory.generated.ts +1 -1
- package/src/modules/primitives/query/getUoMCategory.test.ts +17 -5
- package/src/modules/primitives/query/getUoMCategory.ts +2 -2
- package/src/modules/primitives/query/listUnitsByCategory.generated.ts +1 -1
- package/src/modules/primitives/query/listUnitsByCategory.test.ts +80 -0
- package/src/modules/primitives/query/listUnitsByCategory.ts +19 -3
- package/src/modules/primitives/tailor.config.ts +6 -4
- package/src/modules/primitives/tailor.d.ts +13 -0
- package/src/modules/product-management/README.md +52 -0
- package/src/modules/product-management/command/activateProduct.generated.ts +6 -0
- package/src/modules/product-management/command/activateProduct.test.ts +40 -0
- package/src/modules/product-management/command/activateProduct.ts +42 -0
- package/src/modules/product-management/command/assignProductToCategory.generated.ts +6 -0
- package/src/modules/product-management/command/assignProductToCategory.test.ts +90 -0
- package/src/modules/product-management/command/assignProductToCategory.ts +62 -0
- package/src/modules/product-management/command/createProduct.generated.ts +6 -0
- package/src/modules/product-management/command/createProduct.test.ts +149 -0
- package/src/modules/product-management/command/createProduct.ts +73 -0
- package/src/modules/product-management/command/createProductAttribute.generated.ts +6 -0
- package/src/modules/product-management/command/createProductAttribute.test.ts +70 -0
- package/src/modules/product-management/command/createProductAttribute.ts +53 -0
- package/src/modules/product-management/command/createProductAttributeValue.generated.ts +6 -0
- package/src/modules/product-management/command/createProductAttributeValue.test.ts +68 -0
- package/src/modules/product-management/command/createProductAttributeValue.ts +63 -0
- package/src/modules/product-management/command/createProductCategory.generated.ts +6 -0
- package/src/modules/product-management/command/createProductCategory.test.ts +135 -0
- package/src/modules/product-management/command/createProductCategory.ts +82 -0
- package/src/modules/product-management/command/deactivateProduct.generated.ts +6 -0
- package/src/modules/product-management/command/deactivateProduct.test.ts +40 -0
- package/src/modules/product-management/command/deactivateProduct.ts +42 -0
- package/src/modules/product-management/command/deleteProduct.generated.ts +6 -0
- package/src/modules/product-management/command/deleteProduct.test.ts +42 -0
- package/src/modules/product-management/command/deleteProduct.ts +42 -0
- package/src/modules/product-management/command/deleteProductAttribute.generated.ts +6 -0
- package/src/modules/product-management/command/deleteProductAttribute.test.ts +49 -0
- package/src/modules/product-management/command/deleteProductAttribute.ts +45 -0
- package/src/modules/product-management/command/deleteProductAttributeValue.generated.ts +6 -0
- package/src/modules/product-management/command/deleteProductAttributeValue.test.ts +71 -0
- package/src/modules/product-management/command/deleteProductAttributeValue.ts +68 -0
- package/src/modules/product-management/command/deleteProductCategory.generated.ts +6 -0
- package/src/modules/product-management/command/deleteProductCategory.test.ts +74 -0
- package/src/modules/product-management/command/deleteProductCategory.ts +53 -0
- package/src/modules/product-management/command/generateVariants.generated.ts +6 -0
- package/src/modules/product-management/command/generateVariants.test.ts +365 -0
- package/src/modules/product-management/command/generateVariants.ts +168 -0
- package/src/modules/product-management/command/moveProductCategory.generated.ts +6 -0
- package/src/modules/product-management/command/moveProductCategory.test.ts +170 -0
- package/src/modules/product-management/command/moveProductCategory.ts +124 -0
- package/src/modules/product-management/command/reactivateProduct.generated.ts +6 -0
- package/src/modules/product-management/command/reactivateProduct.test.ts +40 -0
- package/src/modules/product-management/command/reactivateProduct.ts +42 -0
- package/src/modules/product-management/command/removeProductFromCategory.generated.ts +6 -0
- package/src/modules/product-management/command/removeProductFromCategory.test.ts +42 -0
- package/src/modules/product-management/command/removeProductFromCategory.ts +32 -0
- package/src/modules/product-management/command/setProductAttributeAssignment.generated.ts +6 -0
- package/src/modules/product-management/command/setProductAttributeAssignment.test.ts +206 -0
- package/src/modules/product-management/command/setProductAttributeAssignment.ts +102 -0
- package/src/modules/product-management/command/updateProduct.generated.ts +6 -0
- package/src/modules/product-management/command/updateProduct.test.ts +168 -0
- package/src/modules/product-management/command/updateProduct.ts +95 -0
- package/src/modules/product-management/command/updateProductAttribute.generated.ts +6 -0
- package/src/modules/product-management/command/updateProductAttribute.test.ts +101 -0
- package/src/modules/product-management/command/updateProductAttribute.ts +68 -0
- package/src/modules/product-management/command/updateProductAttributeValue.generated.ts +6 -0
- package/src/modules/product-management/command/updateProductAttributeValue.test.ts +80 -0
- package/src/modules/product-management/command/updateProductAttributeValue.ts +58 -0
- package/src/modules/product-management/command/updateProductCategory.generated.ts +6 -0
- package/src/modules/product-management/command/updateProductCategory.test.ts +80 -0
- package/src/modules/product-management/command/updateProductCategory.ts +66 -0
- package/src/modules/product-management/db/product.ts +47 -0
- package/src/modules/product-management/db/productAttribute.ts +26 -0
- package/src/modules/product-management/db/productAttributeAssignment.ts +58 -0
- package/src/modules/product-management/db/productAttributeValue.ts +39 -0
- package/src/modules/product-management/db/productCategory.ts +34 -0
- package/src/modules/product-management/db/productCategoryAssignment.ts +49 -0
- package/src/modules/product-management/db/productVariant.ts +52 -0
- package/src/modules/product-management/docs/commands/ActivateProduct.md +39 -0
- package/src/modules/product-management/docs/commands/AssignProductToCategory.md +43 -0
- package/src/modules/product-management/docs/commands/CreateProduct.md +48 -0
- package/src/modules/product-management/docs/commands/CreateProductAttribute.md +39 -0
- package/src/modules/product-management/docs/commands/CreateProductAttributeValue.md +42 -0
- package/src/modules/product-management/docs/commands/CreateProductCategory.md +54 -0
- package/src/modules/product-management/docs/commands/DeactivateProduct.md +39 -0
- package/src/modules/product-management/docs/commands/DeleteProduct.md +42 -0
- package/src/modules/product-management/docs/commands/DeleteProductAttribute.md +39 -0
- package/src/modules/product-management/docs/commands/DeleteProductAttributeValue.md +42 -0
- package/src/modules/product-management/docs/commands/DeleteProductCategory.md +43 -0
- package/src/modules/product-management/docs/commands/GenerateVariants.md +68 -0
- package/src/modules/product-management/docs/commands/MoveProductCategory.md +54 -0
- package/src/modules/product-management/docs/commands/ReactivateProduct.md +38 -0
- package/src/modules/product-management/docs/commands/RemoveProductFromCategory.md +34 -0
- package/src/modules/product-management/docs/commands/SetProductAttributeAssignment.md +62 -0
- package/src/modules/product-management/docs/commands/UpdateProduct.md +61 -0
- package/src/modules/product-management/docs/commands/UpdateProductAttribute.md +46 -0
- package/src/modules/product-management/docs/commands/UpdateProductAttributeValue.md +47 -0
- package/src/modules/product-management/docs/commands/UpdateProductCategory.md +46 -0
- package/src/modules/product-management/docs/features/attribute-management.md +48 -0
- package/src/modules/product-management/docs/features/product-category.md +71 -0
- package/src/modules/product-management/docs/features/product-lifecycle.md +66 -0
- package/src/modules/product-management/docs/features/variant-generation.md +77 -0
- package/src/modules/product-management/docs/models/Product.md +58 -0
- package/src/modules/product-management/docs/models/ProductAttribute.md +37 -0
- package/src/modules/product-management/docs/models/ProductAttributeAssignment.md +41 -0
- package/src/modules/product-management/docs/models/ProductAttributeValue.md +40 -0
- package/src/modules/product-management/docs/models/ProductCategory.md +46 -0
- package/src/modules/product-management/docs/models/ProductCategoryAssignment.md +37 -0
- package/src/modules/product-management/docs/models/ProductVariant.md +41 -0
- package/src/modules/product-management/docs/queries/CalculateCategoryDepth.md +47 -0
- package/src/modules/product-management/docs/queries/DetectCategoryCircularReference.md +51 -0
- package/src/modules/product-management/docs/queries/GetProduct.md +42 -0
- package/src/modules/product-management/docs/queries/GetProductAttribute.md +42 -0
- package/src/modules/product-management/docs/queries/GetProductAttributeAssignment.md +34 -0
- package/src/modules/product-management/docs/queries/GetProductAttributeValue.md +40 -0
- package/src/modules/product-management/docs/queries/GetProductCategory.md +42 -0
- package/src/modules/product-management/docs/queries/GetProductCategoryAssignment.md +34 -0
- package/src/modules/product-management/docs/queries/GetProductVariant.md +41 -0
- package/src/modules/product-management/docs/queries/ListAttributeAssignmentsByAttribute.md +34 -0
- package/src/modules/product-management/docs/queries/ListCategoryAssignmentsByProduct.md +35 -0
- package/src/modules/product-management/docs/queries/ListProductAttributeAssignments.md +34 -0
- package/src/modules/product-management/docs/queries/ListProductAttributeValues.md +36 -0
- package/src/modules/product-management/docs/queries/ListProductCategoryAssignments.md +34 -0
- package/src/modules/product-management/docs/queries/ListProductCategoryChildren.md +34 -0
- package/src/modules/product-management/docs/queries/ListProductVariants.md +34 -0
- package/src/modules/product-management/generated/enums.ts +9 -0
- package/src/modules/product-management/generated/kysely-tailordb.ts +100 -0
- package/src/modules/product-management/index.ts +2 -0
- package/src/modules/product-management/lib/_db_deps.ts +17 -0
- package/src/modules/product-management/lib/errors.generated.ts +152 -0
- package/src/modules/product-management/lib/permissions.generated.ts +25 -0
- package/src/modules/product-management/lib/types.ts +51 -0
- package/src/modules/product-management/module.ts +201 -0
- package/src/modules/product-management/query/calculateCategoryDepth.generated.ts +5 -0
- package/src/modules/product-management/query/calculateCategoryDepth.test.ts +72 -0
- package/src/modules/product-management/query/calculateCategoryDepth.ts +37 -0
- package/src/modules/product-management/query/detectCategoryCircularReference.generated.ts +5 -0
- package/src/modules/product-management/query/detectCategoryCircularReference.test.ts +72 -0
- package/src/modules/product-management/query/detectCategoryCircularReference.ts +44 -0
- package/src/modules/product-management/query/getProduct.generated.ts +5 -0
- package/src/modules/product-management/query/getProduct.test.ts +59 -0
- package/src/modules/product-management/query/getProduct.ts +18 -0
- package/src/modules/product-management/query/getProductAttribute.generated.ts +5 -0
- package/src/modules/product-management/query/getProductAttribute.test.ts +59 -0
- package/src/modules/product-management/query/getProductAttribute.ts +18 -0
- package/src/modules/product-management/query/getProductAttributeAssignment.generated.ts +5 -0
- package/src/modules/product-management/query/getProductAttributeAssignment.test.ts +37 -0
- package/src/modules/product-management/query/getProductAttributeAssignment.ts +18 -0
- package/src/modules/product-management/query/getProductAttributeValue.generated.ts +5 -0
- package/src/modules/product-management/query/getProductAttributeValue.test.ts +31 -0
- package/src/modules/product-management/query/getProductAttributeValue.ts +16 -0
- package/src/modules/product-management/query/getProductCategory.generated.ts +5 -0
- package/src/modules/product-management/query/getProductCategory.test.ts +59 -0
- package/src/modules/product-management/query/getProductCategory.ts +18 -0
- package/src/modules/product-management/query/getProductCategoryAssignment.generated.ts +5 -0
- package/src/modules/product-management/query/getProductCategoryAssignment.test.ts +37 -0
- package/src/modules/product-management/query/getProductCategoryAssignment.ts +18 -0
- package/src/modules/product-management/query/getProductVariant.generated.ts +5 -0
- package/src/modules/product-management/query/getProductVariant.test.ts +43 -0
- package/src/modules/product-management/query/getProductVariant.ts +20 -0
- package/src/modules/product-management/query/listAttributeAssignmentsByAttribute.generated.ts +5 -0
- package/src/modules/product-management/query/listAttributeAssignmentsByAttribute.test.ts +31 -0
- package/src/modules/product-management/query/listAttributeAssignmentsByAttribute.ts +16 -0
- package/src/modules/product-management/query/listCategoryAssignmentsByProduct.generated.ts +5 -0
- package/src/modules/product-management/query/listCategoryAssignmentsByProduct.test.ts +31 -0
- package/src/modules/product-management/query/listCategoryAssignmentsByProduct.ts +16 -0
- package/src/modules/product-management/query/listProductAttributeAssignments.generated.ts +5 -0
- package/src/modules/product-management/query/listProductAttributeAssignments.test.ts +31 -0
- package/src/modules/product-management/query/listProductAttributeAssignments.ts +16 -0
- package/src/modules/product-management/query/listProductAttributeValues.generated.ts +5 -0
- package/src/modules/product-management/query/listProductAttributeValues.test.ts +31 -0
- package/src/modules/product-management/query/listProductAttributeValues.ts +17 -0
- package/src/modules/product-management/query/listProductCategoryAssignments.generated.ts +5 -0
- package/src/modules/product-management/query/listProductCategoryAssignments.test.ts +31 -0
- package/src/modules/product-management/query/listProductCategoryAssignments.ts +16 -0
- package/src/modules/product-management/query/listProductCategoryChildren.generated.ts +5 -0
- package/src/modules/product-management/query/listProductCategoryChildren.test.ts +31 -0
- package/src/modules/product-management/query/listProductCategoryChildren.ts +16 -0
- package/src/modules/product-management/query/listProductVariants.generated.ts +5 -0
- package/src/modules/product-management/query/listProductVariants.test.ts +31 -0
- package/src/modules/product-management/query/listProductVariants.ts +16 -0
- package/src/modules/product-management/tailor.config.ts +13 -0
- package/src/modules/product-management/tailor.d.ts +13 -0
- package/src/modules/product-management/testing/fixtures.ts +151 -0
- package/src/modules/user-management/README.md +9 -3
- package/src/modules/user-management/command/activateUser.generated.ts +1 -1
- package/src/modules/user-management/command/activateUser.test.ts +12 -65
- package/src/modules/user-management/command/activateUser.ts +5 -20
- package/src/modules/user-management/command/assignPermissionToRole.generated.ts +1 -1
- package/src/modules/user-management/command/assignPermissionToRole.test.ts +25 -60
- package/src/modules/user-management/command/assignPermissionToRole.ts +5 -24
- package/src/modules/user-management/command/assignRoleToUser.generated.ts +1 -1
- package/src/modules/user-management/command/assignRoleToUser.test.ts +35 -87
- package/src/modules/user-management/command/assignRoleToUser.ts +5 -24
- package/src/modules/user-management/command/createPermission.generated.ts +1 -1
- package/src/modules/user-management/command/createPermission.test.ts +23 -33
- package/src/modules/user-management/command/createPermission.ts +4 -5
- package/src/modules/user-management/command/createRole.generated.ts +1 -1
- package/src/modules/user-management/command/createRole.test.ts +17 -27
- package/src/modules/user-management/command/createRole.ts +4 -5
- package/src/modules/user-management/command/createUser.generated.ts +1 -1
- package/src/modules/user-management/command/createUser.test.ts +31 -118
- package/src/modules/user-management/command/createUser.ts +7 -25
- package/src/modules/user-management/command/deactivateUser.generated.ts +1 -1
- package/src/modules/user-management/command/deactivateUser.test.ts +12 -65
- package/src/modules/user-management/command/deactivateUser.ts +6 -21
- package/src/modules/user-management/command/reactivateUser.generated.ts +1 -1
- package/src/modules/user-management/command/reactivateUser.test.ts +13 -66
- package/src/modules/user-management/command/reactivateUser.ts +5 -20
- package/src/modules/user-management/command/revokePermissionFromRole.generated.ts +1 -1
- package/src/modules/user-management/command/revokePermissionFromRole.test.ts +24 -62
- package/src/modules/user-management/command/revokePermissionFromRole.ts +5 -24
- package/src/modules/user-management/command/revokeRoleFromUser.generated.ts +1 -1
- package/src/modules/user-management/command/revokeRoleFromUser.test.ts +24 -60
- package/src/modules/user-management/command/revokeRoleFromUser.ts +5 -24
- package/src/modules/user-management/docs/commands/ActivateUser.md +7 -0
- package/src/modules/user-management/docs/commands/AssignPermissionToRole.md +7 -0
- package/src/modules/user-management/docs/commands/AssignRoleToUser.md +9 -0
- package/src/modules/user-management/docs/commands/CreatePermission.md +12 -0
- package/src/modules/user-management/docs/commands/CreateRole.md +9 -0
- package/src/modules/user-management/docs/commands/CreateUser.md +11 -0
- package/src/modules/user-management/docs/commands/DeactivateUser.md +7 -0
- package/src/modules/user-management/docs/commands/ReactivateUser.md +7 -0
- package/src/modules/user-management/docs/commands/RevokePermissionFromRole.md +7 -0
- package/src/modules/user-management/docs/commands/RevokeRoleFromUser.md +7 -0
- package/src/modules/user-management/index.ts +0 -30
- package/src/modules/user-management/lib/errors.generated.ts +14 -14
- package/src/modules/user-management/lib/permissions.generated.ts +1 -2
- package/src/modules/user-management/lib/recomputeUserPermissions.ts +4 -3
- package/src/modules/user-management/lib/types.ts +1 -1
- package/src/modules/user-management/module.ts +2 -7
- package/src/modules/user-management/tailor.config.ts +6 -4
- package/src/modules/user-management/tailor.d.ts +13 -0
- package/src/modules/user-management/testing/fixtures.ts +1 -20
- package/src/schemas.ts +1 -1
- package/src/{modules/shared → shared}/defineCommand.test.ts +23 -7
- package/src/{modules/shared → shared}/defineCommand.ts +19 -10
- package/src/{modules/shared/internal.ts → shared/index.ts} +9 -1
- package/src/shared/pagination.test.ts +43 -0
- package/src/shared/pagination.ts +22 -0
- package/src/{modules/shared → shared}/types.ts +13 -0
- package/src/{modules/testing → testing}/index.ts +14 -7
- package/src/testing.ts +1 -1
- package/src/util.ts +8 -0
- package/templates/config/license.config.json +4 -0
- package/templates/scaffold/app/backend/.env.example +1 -0
- package/templates/scaffold/app/backend/__dot__gitignore +4 -0
- package/templates/scaffold/app/backend/eslint.config.js +32 -0
- package/templates/scaffold/app/backend/package.json +31 -0
- package/templates/scaffold/app/backend/seed/data/AuditEvent.jsonl +0 -0
- package/templates/scaffold/app/backend/seed/data/Permission.jsonl +0 -0
- package/templates/scaffold/app/backend/seed/data/Permission.schema.ts +20 -0
- package/templates/scaffold/app/backend/seed/data/Role.jsonl +0 -0
- package/templates/scaffold/app/backend/seed/data/Role.schema.ts +20 -0
- package/templates/scaffold/app/backend/seed/data/RolePermission.jsonl +0 -0
- package/templates/scaffold/app/backend/seed/data/RolePermission.schema.ts +24 -0
- package/templates/scaffold/app/backend/seed/data/User.jsonl +1 -0
- package/templates/scaffold/app/backend/seed/data/User.schema.ts +20 -0
- package/templates/scaffold/app/backend/seed/data/UserRole.jsonl +0 -0
- package/templates/scaffold/app/backend/seed/data/UserRole.schema.ts +24 -0
- package/templates/scaffold/app/backend/seed/data/_User.jsonl +1 -0
- package/templates/scaffold/app/backend/seed/data/_User.schema.ts +30 -0
- package/templates/scaffold/app/backend/seed/exec.mjs +659 -0
- package/templates/scaffold/app/backend/src/executors/permissionCreated.ts +3 -0
- package/templates/scaffold/app/backend/src/executors/permissionDeleted.ts +3 -0
- package/templates/scaffold/app/backend/src/generated/kysely-tailordb.ts +83 -0
- package/templates/scaffold/app/backend/src/modules.ts +9 -0
- package/templates/scaffold/app/backend/src/resolvers/createUser.ts +46 -0
- package/templates/scaffold/app/backend/tailor.config.ts +68 -0
- package/templates/scaffold/app/backend/tailor.d.ts +15 -0
- package/templates/scaffold/app/backend/tsconfig.json +19 -0
- package/templates/scaffold/app/docs/actors/.gitkeep +0 -0
- package/templates/scaffold/app/docs/business-flow/.gitkeep +0 -0
- package/templates/scaffold/app/docs/resolver/.gitkeep +0 -0
- package/templates/scaffold/app/docs/screen/.gitkeep +0 -0
- package/templates/scaffold/app/frontend/.env.example +2 -0
- package/templates/scaffold/app/frontend/__dot__gitignore +3 -0
- package/templates/scaffold/app/frontend/components.json +23 -0
- package/templates/scaffold/app/frontend/eslint.config.js +48 -0
- package/templates/scaffold/app/frontend/index.html +13 -0
- package/templates/scaffold/app/frontend/package.json +53 -0
- package/templates/scaffold/app/frontend/scripts/generate-graphql.mjs +6 -0
- package/templates/scaffold/app/frontend/src/App.tsx +58 -0
- package/templates/scaffold/app/frontend/src/components/composed/empty-state.tsx +26 -0
- package/templates/scaffold/app/frontend/src/components/composed/error-fallback.tsx +28 -0
- package/templates/scaffold/app/frontend/src/components/composed/loading.tsx +13 -0
- package/templates/scaffold/app/frontend/src/components/ui/badge.tsx +39 -0
- package/templates/scaffold/app/frontend/src/components/ui/button.tsx +60 -0
- package/templates/scaffold/app/frontend/src/components/ui/card.tsx +75 -0
- package/templates/scaffold/app/frontend/src/components/ui/form.tsx +152 -0
- package/templates/scaffold/app/frontend/src/components/ui/input.tsx +21 -0
- package/templates/scaffold/app/frontend/src/components/ui/label.tsx +21 -0
- package/templates/scaffold/app/frontend/src/components/ui/spinner.tsx +16 -0
- package/templates/scaffold/app/frontend/src/components/ui/table.tsx +90 -0
- package/templates/scaffold/app/frontend/src/graphql/generated/graphql-env.d.ts +103 -0
- package/templates/scaffold/app/frontend/src/graphql/generated/schema.graphql +1235 -0
- package/templates/scaffold/app/frontend/src/graphql/index.ts +15 -0
- package/templates/scaffold/app/frontend/src/index.css +5 -0
- package/templates/scaffold/app/frontend/src/lib/auth-client.ts +17 -0
- package/templates/scaffold/app/frontend/src/lib/utils.ts +6 -0
- package/templates/scaffold/app/frontend/src/main.tsx +10 -0
- package/templates/scaffold/app/frontend/src/pages/page.tsx +20 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/page.tsx +19 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/profile/page.tsx +97 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/user/[id]/components/user-detail.tsx +58 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/user/[id]/page.tsx +51 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/user/components/users-table.tsx +101 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/user/create/components/create-user-form.tsx +99 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/user/create/page.tsx +19 -0
- package/templates/scaffold/app/frontend/src/pages/user-management/user/page.tsx +61 -0
- package/templates/scaffold/app/frontend/src/providers/graphql-provider.tsx +21 -0
- package/templates/scaffold/app/frontend/tsconfig.app.json +35 -0
- package/templates/scaffold/app/frontend/tsconfig.json +16 -0
- package/templates/scaffold/app/frontend/tsconfig.node.json +23 -0
- package/templates/scaffold/app/frontend/vite.config.ts +23 -0
- package/templates/scaffold/module/command/.gitkeep +0 -0
- package/templates/scaffold/module/db/.gitkeep +0 -0
- package/templates/scaffold/module/executor/.gitkeep +0 -0
- package/templates/scaffold/module/generated/.gitkeep +0 -0
- package/templates/scaffold/module/index.ts +2 -0
- package/templates/scaffold/module/lib/errors.ts +1 -0
- package/templates/scaffold/module/lib/types.ts +4 -0
- package/templates/scaffold/module/module.ts +7 -0
- package/templates/scaffold/module/permissions.ts +3 -0
- package/templates/scaffold/module/query/.gitkeep +0 -0
- package/templates/scaffold/module/tailor.config.ts +13 -0
- package/templates/scaffold/module/testing/fixtures.ts +1 -0
- package/templates/workflows/erp-kit-check.yml +37 -0
- package/dist/cli.js +0 -1654
- package/skills/erp-kit-app-2-breakdown/SKILL.md +0 -88
- package/skills/erp-kit-app-3-doc-review/SKILL.md +0 -112
- package/skills/erp-kit-app-4-impl-spec/SKILL.md +0 -116
- package/skills/erp-kit-app-5-implementation/SKILL.md +0 -149
- package/skills/erp-kit-app-5-implementation/references/backend.md +0 -232
- package/skills/erp-kit-module-1-docs/SKILL.md +0 -111
- package/skills/erp-kit-module-2-feature-breakdown/SKILL.md +0 -76
- package/skills/erp-kit-module-3-doc-review/SKILL.md +0 -294
- package/skills/erp-kit-module-4-tdd/SKILL.md +0 -94
- package/skills/erp-kit-module-4-tdd/references/exports.md +0 -8
- package/skills/erp-kit-module-5-impl-review/SKILL.md +0 -410
- package/src/commands/scaffold-templates.ts +0 -65
- package/src/commands/scaffold.test.ts +0 -171
- package/src/commands/scaffold.ts +0 -140
- package/src/modules/shared/index.ts +0 -1
- package/src/modules/user-management/command/logAuditEvent.generated.ts +0 -6
- package/src/modules/user-management/command/logAuditEvent.test.ts +0 -187
- package/src/modules/user-management/command/logAuditEvent.ts +0 -56
- package/src/modules/user-management/db/auditEvent.ts +0 -47
- package/src/modules/user-management/docs/commands/LogAuditEvent.md +0 -37
- package/src/modules/user-management/docs/features/audit-trail.md +0 -80
- package/src/modules/user-management/docs/models/AuditEvent.md +0 -36
- /package/skills/{erp-kit-module-4-tdd → erp-kit-module-5-impl}/references/cross-module-dependency.md +0 -0
- /package/skills/{erp-kit-module-4-tdd → erp-kit-module-5-impl}/references/db-relations.md +0 -0
- /package/skills/{erp-kit-module-4-tdd → erp-kit-module-5-impl}/references/models.md +0 -0
- /package/skills/{erp-kit-module-5-impl-review → erp-kit-module-6-impl-review}/references/commands.md +0 -0
- /package/skills/{erp-kit-module-5-impl-review → erp-kit-module-6-impl-review}/references/testing.md +0 -0
- /package/src/modules/{product-management → audit}/.gitkeep +0 -0
- /package/src/{modules/shared → shared}/createContext.test.ts +0 -0
- /package/src/{modules/shared → shared}/createContext.ts +0 -0
- /package/src/{modules/shared → shared}/definePermissions.test.ts +0 -0
- /package/src/{modules/shared → shared}/definePermissions.ts +0 -0
- /package/src/{modules/shared → shared}/defineQuery.test.ts +0 -0
- /package/src/{modules/shared → shared}/defineQuery.ts +0 -0
- /package/src/{modules/shared → shared}/entityTypes.ts +0 -0
- /package/src/{modules/shared → shared}/errors.ts +0 -0
- /package/src/{modules/shared → shared}/requirePermission.test.ts +0 -0
- /package/src/{modules/shared → shared}/requirePermission.ts +0 -0
- /package/src/{modules/shared → shared}/result.ts +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ok, err
|
|
2
|
-
import {
|
|
1
|
+
import { ok, err } from "../../../shared";
|
|
2
|
+
import { Transaction } from "../generated/kysely-tailordb";
|
|
3
3
|
import { CannotDeactivateReferenceUnitError, UnitNotFoundError } from "../lib/errors.generated";
|
|
4
|
-
import { getUnit } from "../query/getUnit.generated";
|
|
5
|
-
import { getUoMCategory } from "../query/getUoMCategory.generated";
|
|
6
4
|
|
|
7
5
|
export interface DeactivateUnitInput {
|
|
8
6
|
unitId: string;
|
|
@@ -15,9 +13,14 @@ export interface DeactivateUnitInput {
|
|
|
15
13
|
* and quantity conversions while preserving all historical data.
|
|
16
14
|
* Reference units cannot be deactivated.
|
|
17
15
|
*/
|
|
18
|
-
export async function run(db:
|
|
16
|
+
export async function run(db: Transaction, input: DeactivateUnitInput) {
|
|
19
17
|
// 1. Find unit by ID
|
|
20
|
-
const
|
|
18
|
+
const unit = await db
|
|
19
|
+
.selectFrom("Unit")
|
|
20
|
+
.selectAll()
|
|
21
|
+
.where("id", "=", input.unitId)
|
|
22
|
+
.forUpdate()
|
|
23
|
+
.executeTakeFirst();
|
|
21
24
|
|
|
22
25
|
// 2. If not found, throw error
|
|
23
26
|
if (!unit) {
|
|
@@ -25,7 +28,11 @@ export async function run(db: DB, input: DeactivateUnitInput, ctx: CommandContex
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
// 3. Check if unit is reference unit for its category
|
|
28
|
-
const
|
|
31
|
+
const uoMCategory = await db
|
|
32
|
+
.selectFrom("UoMCategory")
|
|
33
|
+
.selectAll()
|
|
34
|
+
.where("id", "=", unit.categoryId)
|
|
35
|
+
.executeTakeFirst();
|
|
29
36
|
|
|
30
37
|
if (uoMCategory?.referenceUnitId === unit.id) {
|
|
31
38
|
return err(new CannotDeactivateReferenceUnitError(input.unitId));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DB } from "../generated/kysely-tailordb";
|
|
2
|
+
import { createMockDb } from "../../../testing/index";
|
|
3
|
+
import { Transaction } from "../generated/kysely-tailordb";
|
|
5
4
|
import {
|
|
6
5
|
CannotSetInactiveAsBaseCurrencyError,
|
|
7
6
|
CurrencyNotFoundError,
|
|
@@ -10,23 +9,14 @@ import { baseCurrencyEUR, baseCurrencyUSD, inactiveCurrency } from "../testing/f
|
|
|
10
9
|
import { run } from "./setBaseCurrency";
|
|
11
10
|
|
|
12
11
|
describe("setBaseCurrency", () => {
|
|
13
|
-
const ctx: CommandContext = {
|
|
14
|
-
actorId: "test-actor",
|
|
15
|
-
permissions: ["primitives:setBaseCurrency"],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
12
|
// Error cases
|
|
19
13
|
it("throws when currency doesn't exist", async () => {
|
|
20
|
-
const { db, spies } = createMockDb<
|
|
14
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
21
15
|
spies.select.mockReturnValue(undefined);
|
|
22
16
|
|
|
23
|
-
const result = await run(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
currencyId: "nonexistent-currency",
|
|
27
|
-
},
|
|
28
|
-
ctx,
|
|
29
|
-
);
|
|
17
|
+
const result = await run(db, {
|
|
18
|
+
currencyId: "nonexistent-currency",
|
|
19
|
+
});
|
|
30
20
|
|
|
31
21
|
expect(result.ok).toBe(false);
|
|
32
22
|
if (!result.ok) {
|
|
@@ -35,16 +25,12 @@ describe("setBaseCurrency", () => {
|
|
|
35
25
|
});
|
|
36
26
|
|
|
37
27
|
it("throws when currency is inactive", async () => {
|
|
38
|
-
const { db, spies } = createMockDb<
|
|
28
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
39
29
|
spies.select.mockReturnValue(inactiveCurrency);
|
|
40
30
|
|
|
41
|
-
const result = await run(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
currencyId: inactiveCurrency.id,
|
|
45
|
-
},
|
|
46
|
-
ctx,
|
|
47
|
-
);
|
|
31
|
+
const result = await run(db, {
|
|
32
|
+
currencyId: inactiveCurrency.id,
|
|
33
|
+
});
|
|
48
34
|
|
|
49
35
|
expect(result.ok).toBe(false);
|
|
50
36
|
if (!result.ok) {
|
|
@@ -54,16 +40,12 @@ describe("setBaseCurrency", () => {
|
|
|
54
40
|
|
|
55
41
|
// Idempotent cases
|
|
56
42
|
it("returns currency unchanged when already base", async () => {
|
|
57
|
-
const { db, spies } = createMockDb<
|
|
43
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
58
44
|
spies.select.mockReturnValue(baseCurrencyUSD); // Already base currency
|
|
59
45
|
|
|
60
|
-
const result = await run(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
currencyId: baseCurrencyUSD.id,
|
|
64
|
-
},
|
|
65
|
-
ctx,
|
|
66
|
-
);
|
|
46
|
+
const result = await run(db, {
|
|
47
|
+
currencyId: baseCurrencyUSD.id,
|
|
48
|
+
});
|
|
67
49
|
|
|
68
50
|
expect(result.ok).toBe(true);
|
|
69
51
|
if (result.ok) {
|
|
@@ -74,7 +56,7 @@ describe("setBaseCurrency", () => {
|
|
|
74
56
|
|
|
75
57
|
// Success cases
|
|
76
58
|
it("changes base currency", async () => {
|
|
77
|
-
const { db, spies } = createMockDb<
|
|
59
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
78
60
|
const newBaseCurrency = {
|
|
79
61
|
...baseCurrencyEUR,
|
|
80
62
|
isBaseCurrency: true,
|
|
@@ -88,13 +70,9 @@ describe("setBaseCurrency", () => {
|
|
|
88
70
|
.mockReturnValueOnce({ ...baseCurrencyUSD, isBaseCurrency: false }) // Remove base from old
|
|
89
71
|
.mockReturnValueOnce(newBaseCurrency); // Set base on new
|
|
90
72
|
|
|
91
|
-
const result = await run(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
currencyId: baseCurrencyEUR.id,
|
|
95
|
-
},
|
|
96
|
-
ctx,
|
|
97
|
-
);
|
|
73
|
+
const result = await run(db, {
|
|
74
|
+
currencyId: baseCurrencyEUR.id,
|
|
75
|
+
});
|
|
98
76
|
|
|
99
77
|
expect(result.ok).toBe(true);
|
|
100
78
|
if (result.ok) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ok, err
|
|
2
|
-
import {
|
|
1
|
+
import { ok, err } from "../../../shared";
|
|
2
|
+
import { Transaction } from "../generated/kysely-tailordb";
|
|
3
3
|
import {
|
|
4
4
|
CannotSetInactiveAsBaseCurrencyError,
|
|
5
5
|
CurrencyNotFoundError,
|
|
6
6
|
} from "../lib/errors.generated";
|
|
7
|
-
import { getCurrency } from "../query/getCurrency.generated";
|
|
8
|
-
import { getBaseCurrency } from "../query/getBaseCurrency.generated";
|
|
9
7
|
|
|
10
8
|
export interface SetBaseCurrencyInput {
|
|
11
9
|
currencyId: string;
|
|
@@ -17,9 +15,14 @@ export interface SetBaseCurrencyInput {
|
|
|
17
15
|
* Changes the organization's base currency to a different active currency.
|
|
18
16
|
* The base currency serves as the default for financial reporting.
|
|
19
17
|
*/
|
|
20
|
-
export async function run(db:
|
|
18
|
+
export async function run(db: Transaction, input: SetBaseCurrencyInput) {
|
|
21
19
|
// 1. Find currency by ID
|
|
22
|
-
const
|
|
20
|
+
const currency = await db
|
|
21
|
+
.selectFrom("Currency")
|
|
22
|
+
.selectAll()
|
|
23
|
+
.where("id", "=", input.currencyId)
|
|
24
|
+
.forUpdate()
|
|
25
|
+
.executeTakeFirst();
|
|
23
26
|
|
|
24
27
|
// 2. If not found, throw error
|
|
25
28
|
if (!currency) {
|
|
@@ -37,7 +40,12 @@ export async function run(db: DB, input: SetBaseCurrencyInput, ctx: CommandConte
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
// 5. Find current base currency
|
|
40
|
-
const
|
|
43
|
+
const currentBase = await db
|
|
44
|
+
.selectFrom("Currency")
|
|
45
|
+
.selectAll()
|
|
46
|
+
.where("isBaseCurrency", "=", true)
|
|
47
|
+
.forUpdate()
|
|
48
|
+
.executeTakeFirst();
|
|
41
49
|
|
|
42
50
|
// 6. Remove base flag from current base
|
|
43
51
|
if (currentBase) {
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createMockDb } from "
|
|
3
|
-
import {
|
|
4
|
-
import { DB } from "../generated/kysely-tailordb";
|
|
2
|
+
import { createMockDb } from "../../../testing/index";
|
|
3
|
+
import { Transaction } from "../generated/kysely-tailordb";
|
|
5
4
|
import { UnitNotFoundError, UnitNotInCategoryError } from "../lib/errors.generated";
|
|
6
5
|
import { baseUoMCategory, baseUnitGram, baseUnitKg, baseUnitLiter } from "../testing/fixtures";
|
|
7
6
|
import { run } from "./setReferenceUnit";
|
|
8
7
|
|
|
9
8
|
describe("setReferenceUnit", () => {
|
|
10
|
-
const ctx: CommandContext = {
|
|
11
|
-
actorId: "test-actor",
|
|
12
|
-
permissions: ["primitives:setReferenceUnit"],
|
|
13
|
-
};
|
|
14
|
-
|
|
15
9
|
// Error cases
|
|
16
10
|
it("throws when unit doesn't exist", async () => {
|
|
17
|
-
const { db, spies } = createMockDb<
|
|
11
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
18
12
|
spies.select.mockReturnValue(undefined);
|
|
19
13
|
|
|
20
|
-
const result = await run(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
categoryId: baseUoMCategory.id,
|
|
25
|
-
},
|
|
26
|
-
ctx,
|
|
27
|
-
);
|
|
14
|
+
const result = await run(db, {
|
|
15
|
+
unitId: "nonexistent-unit",
|
|
16
|
+
categoryId: baseUoMCategory.id,
|
|
17
|
+
});
|
|
28
18
|
|
|
29
19
|
expect(result.ok).toBe(false);
|
|
30
20
|
if (!result.ok) {
|
|
@@ -33,17 +23,13 @@ describe("setReferenceUnit", () => {
|
|
|
33
23
|
});
|
|
34
24
|
|
|
35
25
|
it("throws when unit is not in specified category", async () => {
|
|
36
|
-
const { db, spies } = createMockDb<
|
|
26
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
37
27
|
spies.select.mockReturnValue(baseUnitLiter); // Unit is in category-2, not category-1
|
|
38
28
|
|
|
39
|
-
const result = await run(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
categoryId: baseUoMCategory.id, // category-1
|
|
44
|
-
},
|
|
45
|
-
ctx,
|
|
46
|
-
);
|
|
29
|
+
const result = await run(db, {
|
|
30
|
+
unitId: baseUnitLiter.id,
|
|
31
|
+
categoryId: baseUoMCategory.id, // category-1
|
|
32
|
+
});
|
|
47
33
|
|
|
48
34
|
expect(result.ok).toBe(false);
|
|
49
35
|
if (!result.ok) {
|
|
@@ -53,19 +39,15 @@ describe("setReferenceUnit", () => {
|
|
|
53
39
|
|
|
54
40
|
// Idempotent cases
|
|
55
41
|
it("returns category unchanged when unit is already reference", async () => {
|
|
56
|
-
const { db, spies } = createMockDb<
|
|
42
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
57
43
|
spies.select
|
|
58
44
|
.mockReturnValueOnce(baseUnitKg) // Unit lookup
|
|
59
45
|
.mockReturnValueOnce(baseUoMCategory); // Category lookup
|
|
60
46
|
|
|
61
|
-
const result = await run(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
categoryId: baseUoMCategory.id,
|
|
66
|
-
},
|
|
67
|
-
ctx,
|
|
68
|
-
);
|
|
47
|
+
const result = await run(db, {
|
|
48
|
+
unitId: baseUnitKg.id,
|
|
49
|
+
categoryId: baseUoMCategory.id,
|
|
50
|
+
});
|
|
69
51
|
|
|
70
52
|
expect(result.ok).toBe(true);
|
|
71
53
|
if (result.ok) {
|
|
@@ -76,7 +58,7 @@ describe("setReferenceUnit", () => {
|
|
|
76
58
|
|
|
77
59
|
// Success cases
|
|
78
60
|
it("changes reference unit and recalculates conversion factors", async () => {
|
|
79
|
-
const { db, spies } = createMockDb<
|
|
61
|
+
const { db, spies } = createMockDb<Transaction>();
|
|
80
62
|
// gram has conversion factor 0.001 (1g = 0.001kg)
|
|
81
63
|
// When gram becomes reference, kg should become 1000 (1kg = 1000g)
|
|
82
64
|
const updatedCategory = {
|
|
@@ -94,14 +76,10 @@ describe("setReferenceUnit", () => {
|
|
|
94
76
|
.mockReturnValueOnce({ ...baseUnitGram, conversionFactor: 1.0 }) // Update gram factor
|
|
95
77
|
.mockReturnValueOnce(updatedCategory); // Update category
|
|
96
78
|
|
|
97
|
-
const result = await run(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
categoryId: baseUoMCategory.id,
|
|
102
|
-
},
|
|
103
|
-
ctx,
|
|
104
|
-
);
|
|
79
|
+
const result = await run(db, {
|
|
80
|
+
unitId: baseUnitGram.id,
|
|
81
|
+
categoryId: baseUoMCategory.id,
|
|
82
|
+
});
|
|
105
83
|
|
|
106
84
|
expect(result.ok).toBe(true);
|
|
107
85
|
if (result.ok) {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { ok, err
|
|
2
|
-
import {
|
|
1
|
+
import { ok, err } from "../../../shared";
|
|
2
|
+
import { Transaction } from "../generated/kysely-tailordb";
|
|
3
3
|
import { UnitNotFoundError, UnitNotInCategoryError } from "../lib/errors.generated";
|
|
4
|
-
import { getUnit } from "../query/getUnit.generated";
|
|
5
|
-
import { getUoMCategory } from "../query/getUoMCategory.generated";
|
|
6
|
-
import { listUnitsByCategory } from "../query/listUnitsByCategory.generated";
|
|
7
4
|
|
|
8
5
|
export interface SetReferenceUnitInput {
|
|
9
6
|
unitId: string;
|
|
@@ -16,9 +13,14 @@ export interface SetReferenceUnitInput {
|
|
|
16
13
|
* Changes the reference unit for a UoM category. All conversion factors
|
|
17
14
|
* are recalculated relative to the new reference unit.
|
|
18
15
|
*/
|
|
19
|
-
export async function run(db:
|
|
16
|
+
export async function run(db: Transaction, input: SetReferenceUnitInput) {
|
|
20
17
|
// 1. Find unit by ID
|
|
21
|
-
const
|
|
18
|
+
const unit = await db
|
|
19
|
+
.selectFrom("Unit")
|
|
20
|
+
.selectAll()
|
|
21
|
+
.where("id", "=", input.unitId)
|
|
22
|
+
.forUpdate()
|
|
23
|
+
.executeTakeFirst();
|
|
22
24
|
|
|
23
25
|
if (!unit) {
|
|
24
26
|
return err(new UnitNotFoundError(input.unitId));
|
|
@@ -30,7 +32,12 @@ export async function run(db: DB, input: SetReferenceUnitInput, ctx: CommandCont
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
// 3. Get category
|
|
33
|
-
const
|
|
35
|
+
const uoMCategory = await db
|
|
36
|
+
.selectFrom("UoMCategory")
|
|
37
|
+
.selectAll()
|
|
38
|
+
.where("id", "=", input.categoryId)
|
|
39
|
+
.forUpdate()
|
|
40
|
+
.executeTakeFirst();
|
|
34
41
|
|
|
35
42
|
// 4. If already reference unit, return (idempotent)
|
|
36
43
|
if (uoMCategory?.referenceUnitId === input.unitId && uoMCategory) {
|
|
@@ -38,7 +45,12 @@ export async function run(db: DB, input: SetReferenceUnitInput, ctx: CommandCont
|
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
// 5. Get all units in category for recalculation
|
|
41
|
-
const
|
|
48
|
+
const units = await db
|
|
49
|
+
.selectFrom("Unit")
|
|
50
|
+
.selectAll()
|
|
51
|
+
.where("categoryId", "=", input.categoryId)
|
|
52
|
+
.forUpdate()
|
|
53
|
+
.execute();
|
|
42
54
|
|
|
43
55
|
// 6. Recalculate all conversion factors
|
|
44
56
|
// new_factor = old_factor / new_reference_old_factor
|
|
@@ -39,3 +39,9 @@ flowchart TD
|
|
|
39
39
|
## Error Scenarios
|
|
40
40
|
|
|
41
41
|
- **DUPLICATE_CATEGORY_NAME**: Category with same name already exists
|
|
42
|
+
|
|
43
|
+
## Test Cases
|
|
44
|
+
|
|
45
|
+
- throws when category name already exists
|
|
46
|
+
- creates category with reference unit
|
|
47
|
+
- passes custom fields through to insert
|
|
@@ -44,3 +44,13 @@ flowchart TD
|
|
|
44
44
|
- **INVALID_ISO_CODE**: Code is not exactly 3 uppercase letters
|
|
45
45
|
- **DUPLICATE_CURRENCY_CODE**: Currency with same code already exists
|
|
46
46
|
- **INVALID_DECIMAL_PLACES**: Value is negative or exceeds maximum (typically 4)
|
|
47
|
+
|
|
48
|
+
## Test Cases
|
|
49
|
+
|
|
50
|
+
- throws when ISO code is invalid format
|
|
51
|
+
- throws when ISO code already exists
|
|
52
|
+
- throws when decimal places is negative
|
|
53
|
+
- throws when decimal places exceeds maximum
|
|
54
|
+
- creates first currency as base currency
|
|
55
|
+
- creates subsequent currency as non-base
|
|
56
|
+
- passes custom fields through to insert
|
|
@@ -45,3 +45,14 @@ flowchart TD
|
|
|
45
45
|
- **INACTIVE_CURRENCY**: Source or target currency is inactive
|
|
46
46
|
- **SAME_CURRENCY_PAIR**: Source and target currencies are the same
|
|
47
47
|
- **INVALID_EXCHANGE_RATE**: Rate is zero, negative, or not a valid number
|
|
48
|
+
|
|
49
|
+
## Test Cases
|
|
50
|
+
|
|
51
|
+
- throws when source currency doesn
|
|
52
|
+
- throws when source currency is inactive
|
|
53
|
+
- throws when target currency doesn
|
|
54
|
+
- throws when target currency is inactive
|
|
55
|
+
- throws when source and target are the same
|
|
56
|
+
- throws when rate is not positive
|
|
57
|
+
- creates exchange rate successfully
|
|
58
|
+
- passes custom fields through to insert
|
|
@@ -46,3 +46,13 @@ flowchart TD
|
|
|
46
46
|
- **DUPLICATE_UNIT_SYMBOL**: Unit with same symbol already exists in category
|
|
47
47
|
- **INVALID_CONVERSION_FACTOR**: Factor is zero, negative, or not a valid number
|
|
48
48
|
- **INVALID_ROUNDING_PRECISION**: Precision is negative
|
|
49
|
+
|
|
50
|
+
## Test Cases
|
|
51
|
+
|
|
52
|
+
- throws when category doesn
|
|
53
|
+
- throws when category is inactive
|
|
54
|
+
- throws when symbol already exists in category
|
|
55
|
+
- throws when conversion factor is not positive
|
|
56
|
+
- throws when rounding precision is negative
|
|
57
|
+
- creates unit successfully
|
|
58
|
+
- passes custom fields through to insert
|
|
@@ -35,3 +35,10 @@ flowchart TD
|
|
|
35
35
|
|
|
36
36
|
- **UOM_CATEGORY_NOT_FOUND**: Specified category ID does not exist
|
|
37
37
|
- **CATEGORY_HAS_ACTIVE_UNITS**: Category still contains active units that must be deactivated first
|
|
38
|
+
|
|
39
|
+
## Test Cases
|
|
40
|
+
|
|
41
|
+
- throws when category doesn
|
|
42
|
+
- throws when category has active units
|
|
43
|
+
- returns category unchanged when already inactive
|
|
44
|
+
- deactivates active category with no active units
|
|
@@ -35,3 +35,10 @@ flowchart TD
|
|
|
35
35
|
|
|
36
36
|
- **CURRENCY_NOT_FOUND**: Specified currency ID does not exist
|
|
37
37
|
- **CANNOT_DEACTIVATE_BASE_CURRENCY**: Attempting to deactivate the base currency, must change base currency first
|
|
38
|
+
|
|
39
|
+
## Test Cases
|
|
40
|
+
|
|
41
|
+
- throws when currency doesn
|
|
42
|
+
- throws when attempting to deactivate base currency
|
|
43
|
+
- returns currency unchanged when already inactive
|
|
44
|
+
- deactivates active non-base currency
|
|
@@ -35,3 +35,10 @@ flowchart TD
|
|
|
35
35
|
|
|
36
36
|
- **UNIT_NOT_FOUND**: Specified unit ID does not exist
|
|
37
37
|
- **CANNOT_DEACTIVATE_REFERENCE_UNIT**: Attempting to deactivate the category's reference unit, must change reference unit first
|
|
38
|
+
|
|
39
|
+
## Test Cases
|
|
40
|
+
|
|
41
|
+
- throws when unit doesn
|
|
42
|
+
- throws when attempting to deactivate reference unit
|
|
43
|
+
- returns unit unchanged when already inactive
|
|
44
|
+
- deactivates active non-reference unit
|
|
@@ -36,3 +36,10 @@ flowchart TD
|
|
|
36
36
|
|
|
37
37
|
- **CURRENCY_NOT_FOUND**: Specified currency ID does not exist
|
|
38
38
|
- **CANNOT_SET_INACTIVE_AS_BASE_CURRENCY**: Target currency is not in Active status, must be activated first
|
|
39
|
+
|
|
40
|
+
## Test Cases
|
|
41
|
+
|
|
42
|
+
- throws when currency doesn
|
|
43
|
+
- throws when currency is inactive
|
|
44
|
+
- returns currency unchanged when already base
|
|
45
|
+
- changes base currency
|
|
@@ -40,3 +40,10 @@ flowchart TD
|
|
|
40
40
|
|
|
41
41
|
- **UNIT_NOT_FOUND**: Specified unit ID does not exist
|
|
42
42
|
- **UNIT_NOT_IN_CATEGORY**: Unit belongs to a different category than specified
|
|
43
|
+
|
|
44
|
+
## Test Cases
|
|
45
|
+
|
|
46
|
+
- throws when unit doesn
|
|
47
|
+
- throws when unit is not in specified category
|
|
48
|
+
- returns category unchanged when unit is already reference
|
|
49
|
+
- changes reference unit and recalculates conversion factors
|
|
@@ -46,3 +46,17 @@ flowchart TD
|
|
|
46
46
|
- **INACTIVE_CURRENCY**: Either source or target currency is inactive
|
|
47
47
|
- **EXCHANGE_RATE_NOT_FOUND**: No rate found for the currency pair on or before the specified date
|
|
48
48
|
- **CURRENCY_NOT_FOUND**: Specified currency code/ID does not exist
|
|
49
|
+
|
|
50
|
+
## Test Cases
|
|
51
|
+
|
|
52
|
+
- returns error when source currency doesn
|
|
53
|
+
- returns error when target currency doesn
|
|
54
|
+
- returns error when source currency is inactive
|
|
55
|
+
- returns error when target currency is inactive
|
|
56
|
+
- returns error when no exchange rate exists for the currency pair
|
|
57
|
+
- returns same amount when source and target are the same currency
|
|
58
|
+
- converts USD to EUR using direct rate
|
|
59
|
+
- uses inverse rate when no direct rate exists
|
|
60
|
+
- uses most recent rate on or before the conversion date
|
|
61
|
+
- rounds to target currency decimal places (JPY has 0)
|
|
62
|
+
- handles zero amount correctly
|
|
@@ -39,3 +39,16 @@ flowchart TD
|
|
|
39
39
|
- **INCOMPATIBLE_UNITS**: Source and target units belong to different categories
|
|
40
40
|
- **INACTIVE_UNIT**: Either source or target unit is inactive
|
|
41
41
|
- **UNIT_NOT_FOUND**: Specified unit ID does not exist
|
|
42
|
+
|
|
43
|
+
## Test Cases
|
|
44
|
+
|
|
45
|
+
- returns error when source unit doesn
|
|
46
|
+
- returns error when target unit doesn
|
|
47
|
+
- returns error when source unit is inactive
|
|
48
|
+
- returns error when target unit is inactive
|
|
49
|
+
- returns error when units belong to different categories
|
|
50
|
+
- returns same quantity when source and target are the same unit
|
|
51
|
+
- converts kg to grams correctly
|
|
52
|
+
- converts grams to kg correctly
|
|
53
|
+
- converts pounds to kg correctly
|
|
54
|
+
- handles zero quantity correctly
|
|
@@ -34,3 +34,10 @@ flowchart TD
|
|
|
34
34
|
## Error Scenarios
|
|
35
35
|
|
|
36
36
|
- None (returns null when not found instead of throwing)
|
|
37
|
+
|
|
38
|
+
## Test Cases
|
|
39
|
+
|
|
40
|
+
- returns currency when found
|
|
41
|
+
- returns null when currency not found
|
|
42
|
+
- returns currency when found
|
|
43
|
+
- returns null when currency not found
|
|
@@ -34,3 +34,10 @@ flowchart TD
|
|
|
34
34
|
## Error Scenarios
|
|
35
35
|
|
|
36
36
|
- None (returns null when not found instead of throwing)
|
|
37
|
+
|
|
38
|
+
## Test Cases
|
|
39
|
+
|
|
40
|
+
- returns category when found
|
|
41
|
+
- returns null when category not found
|
|
42
|
+
- returns category when found
|
|
43
|
+
- returns null when category not found
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
ListUnitsByCategory retrieves
|
|
5
|
+
ListUnitsByCategory retrieves paginated units belonging to a specific UoM category. Used to find related units within a category and to validate category constraints such as ensuring a category has units before deactivation.
|
|
6
6
|
|
|
7
7
|
## Business Rules
|
|
8
8
|
|
|
9
|
-
- Returns
|
|
10
|
-
- Returns empty
|
|
9
|
+
- Returns paginated units with the matching categoryId
|
|
10
|
+
- Returns empty result if no units match
|
|
11
|
+
- Supports limit, offset, orderBy, and orderDirection parameters
|
|
12
|
+
- Indicates whether more results exist via hasNextPage
|
|
11
13
|
|
|
12
14
|
## Process Flow
|
|
13
15
|
|
|
14
16
|
```mermaid
|
|
15
17
|
flowchart TD
|
|
16
|
-
A[Receive categoryId] --> B[SELECT from Unit where categoryId = input]
|
|
17
|
-
B --> C[
|
|
18
|
+
A[Receive categoryId and pagination params] --> B[SELECT from Unit where categoryId = input with limit+1, offset, order]
|
|
19
|
+
B --> C[Build paginated result with items and hasNextPage]
|
|
18
20
|
```
|
|
19
21
|
|
|
20
22
|
## External Dependencies
|
|
@@ -24,3 +26,11 @@ flowchart TD
|
|
|
24
26
|
## Error Scenarios
|
|
25
27
|
|
|
26
28
|
- None
|
|
29
|
+
|
|
30
|
+
## Test Cases
|
|
31
|
+
|
|
32
|
+
- returns paginated units with default page size
|
|
33
|
+
- returns hasNextPage true when more results exist
|
|
34
|
+
- returns empty result when no units match
|
|
35
|
+
- respects custom limit and offset
|
|
36
|
+
- accepts orderBy and orderDirection
|