{"_id":"@200systems/mf-service-base","_rev":"13-4f44ef3200cfea7b385cd076dc513179","name":"@200systems/mf-service-base","dist-tags":{"latest":"1.1.7"},"versions":{"1.0.1":{"name":"@200systems/mf-service-base","version":"1.0.1","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.0.1","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"5c40d5ba778e1b85a8de9dd6fbfc7918571f74ee","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.0.1.tgz","fileCount":38,"integrity":"sha512-at25loKTPGP1suGxDtyW4P7sJDZO6JUFbFWnzDGE/pNOvmMjspAUkI7VHJEaen81epuLnli1AoicUr9v334gzg==","signatures":[{"sig":"MEUCIQDQlus/L4zGE7VCFWDGXWSgg3O7ttf8MQSpH61CPGN9owIgdbYgIslkvVBew/Rw8z4o053EPIGPCktjomJVwfNoxVU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":62899},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"b23d0aca4444d3727bef596b99d52f845ee6bdd8","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.0.1_1750937030897_0.9471395010672607","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.0.2":{"name":"@200systems/mf-service-base","version":"1.0.2","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.0.2","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"9408c3e0bd61f0b84cd37b855eb99df5ac9133c1","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.0.2.tgz","fileCount":38,"integrity":"sha512-cSJOxjubIhLYK3qgdafX2NyD8/I2dclTEBFoX4FkCncXdpUvA1ZqFkIrs8ykMqSqnYj6BwJzB8Sy9V3Wz6UjIg==","signatures":[{"sig":"MEUCIB0f25Ma1ASvqJ7vci/684Qwj6r23Yfe2v7+k07zmO+ZAiEA6aY9MBQ+jEi4Z2rS8kYeXVdbtqZ7zLZhWkhpiavKijU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63033},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"3b9df0fba14ad311035a103071c895f780597d75","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.0.2_1751014423669_0.6779036669262124","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.0.3":{"name":"@200systems/mf-service-base","version":"1.0.3","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.0.3","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"01024ca3bedb2721b3e0584b7703f0e75a8d8bdf","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.0.3.tgz","fileCount":38,"integrity":"sha512-Xib8xXjva4K+3K964fX+3QYo2fJrmrellGFk/pbUpK5hR6BG10yu3AHZVnhHeo37uX8CRZQc+iGYHTiggxG8Lg==","signatures":[{"sig":"MEQCIHcmTthO/PGYIodnxXZNrJW8cC+OuUp0zCI8BMsm58IuAiA9YJXgDwOjjzIzXfcA2lWBVjbf/rOnUd+Dfveh7xS/gA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63033},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"17e3ce1150d8a91f15ba15d4208a96a40cf211b9","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.0.3_1751056804259_0.13742743007283464","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.0.4":{"name":"@200systems/mf-service-base","version":"1.0.4","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.0.4","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"0865618731f8a2179bd763695331e17c45b4ba97","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.0.4.tgz","fileCount":38,"integrity":"sha512-8/9G2CTz7wpNKjvmkHvAGxJa6A8iHNFeOkM5xGIgv9mdbQL2JYMmt9iuju1ISwmjTc6cD8b9z7nufv94Nj/aTg==","signatures":[{"sig":"MEYCIQCD26vI3EhhchfWJem4HPJXdlwB+FoENPAHYLrGPFcbogIhAIMJ1tGZZemdYRYRZEYcd+Ar9J1jJPWIjtlPnzAnRIaF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63033},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"d7bb90f291b6b532083319fa040cfeb43eae8ad7","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.0.4_1751058917265_0.05810432291639045","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.0.5":{"name":"@200systems/mf-service-base","version":"1.0.5","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.0.5","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"837dd5fd2e9354f95a1b6e30f28d932f3c6576ee","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.0.5.tgz","fileCount":38,"integrity":"sha512-Du19oA73Uf2u4ZdwIz6ke2bpPn6YmEn42jku/l7cVrbvaXBmeu+lJ3e9sOeWItFNJpobDdCWkZOg7wQsfKHCUQ==","signatures":[{"sig":"MEYCIQDzQRtZa27+wPC22YV0ZUnGPmNa0fBJnOQOINwZmGDj1QIhAOlSYT4NkF/ruoc5rAyInQeKm5CTPlCwL7oK/GPJqhh5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63055},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"d7bb90f291b6b532083319fa040cfeb43eae8ad7","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.0.5_1751059755149_0.4832804420677037","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.1.1":{"name":"@200systems/mf-service-base","version":"1.1.1","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.1.1","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"e9ec9b00e3323d37fdd111b2f3bf1fee35a2b499","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.1.1.tgz","fileCount":38,"integrity":"sha512-nCgnV65cCKar5Y3FK7HycikxqlhR45fMU6hcK1RxsmGDUcnZx3gxdLVPKCoQ2k3IaPzJ51QdN7q3JgVHnu0Ciw==","signatures":[{"sig":"MEUCIQC689PXUwdHfTV5omY/bwLcMpQGpa7v5SgmIT7x230d8wIgKSnM1pDTDRhgw88yBl1es0Bu5VSag4ntn/ijk0BiTwg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63333},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"b2e1d0a164c5cfd355a044b56b7ec48c88def397","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.1.1_1751223533602_0.07889366529396313","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.1.2":{"name":"@200systems/mf-service-base","version":"1.1.2","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.1.2","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"e4f7835d1564a00b3ef6b1c59b3c841a01d35801","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.1.2.tgz","fileCount":38,"integrity":"sha512-aS1G8HLrpI7AGmieJVv68DcB6hVb9IOLrlKk7AKOGaxHBpz0K1snTQQq6x7XaYjEUnAv2iKbkP/iHVH2Pz5xAQ==","signatures":[{"sig":"MEQCIHeA0Fd8HkB+EOpUVWuiBYiAh2yczjIqqOzRlWV5gaIhAiAD1j4MVNmjLDh1Wt4NsoZLjbAqrd5iIAwwDqJsDSi2Zw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63333},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"b2e1d0a164c5cfd355a044b56b7ec48c88def397","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.1.2_1751224236496_0.761167401505872","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.1.3":{"name":"@200systems/mf-service-base","version":"1.1.3","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.1.3","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"a2a8075e0724d6c8ebf853ec4c3a10b9fc986e98","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.1.3.tgz","fileCount":38,"integrity":"sha512-iY0ORj9nDHvJkSdzQ5dK//GNLqoJSX+H2+m8vU1ray7+iDKyp+Mc6ygpeg8Ideh40k1kpRfb0VqqSnF00QPapQ==","signatures":[{"sig":"MEUCIFtluykkr6nkA0Himmo2U4QVlEb49eFydCTFzDNHr0VkAiEAig7L6FDYR6RZaZ01pc4kBA4o3Z2BlAr2i1ZvSDR6ykE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63333},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"23dcee4f5721e057c3d9625f10e1823f834a466d","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.1.3_1751472527268_0.37671299173496364","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.1.4":{"name":"@200systems/mf-service-base","version":"1.1.4","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.1.4","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"e247747a491d520a62e934e010804d11b6eb5b53","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.1.4.tgz","fileCount":38,"integrity":"sha512-zKkHmkGNf/dpiYM64eq7UfRVl8r0LIUjC/7Dh6npbiQlnN1AJ1eZNtf1aBX+C0JJNTWNXVmEhe5Ey4qRsLoXmw==","signatures":[{"sig":"MEYCIQCugflEvYBZpXT8zHpusHDcC9CLyXRQopqPu1e/fWtKxwIhAJzbbVjAnK7gkNyc73bj8mrfcI9o08dr08ciGRRLk9lk","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63404},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"23dcee4f5721e057c3d9625f10e1823f834a466d","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.1.4_1751473979098_0.7802434832566423","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.1.5":{"name":"@200systems/mf-service-base","version":"1.1.5","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.1.5","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"1992a52d92985ff1e0f4b835e4be7e872b8cf9f6","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.1.5.tgz","fileCount":38,"integrity":"sha512-BEIsF4FTZpJxuEeLRbhXaVkrrvcoUiVMVruCsb4ditfwHwsEduIgkv1c0adpV/rQSg7eFtQmEh2gFdCvvb2lyw==","signatures":[{"sig":"MEUCIC/4lCIDJStfGAFDBjGNU54E1l7+lqqFw5P3fuR7oUPAAiEArX86hASNwFXvZrivQuyqhmgIHawrKx5u1fEQGZxlWKc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63404},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"23dcee4f5721e057c3d9625f10e1823f834a466d","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.1.5_1751474252288_0.13248303709741016","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.1.6":{"name":"@200systems/mf-service-base","version":"1.1.6","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.1.6","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"d5591b60b33f7712e47ee7eb71f4db6d0b3882f9","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.1.6.tgz","fileCount":38,"integrity":"sha512-3MWXg4J5kq+38r+vIDSohoxoZsf+i8o9VvAXdJg3PNf32auUc7Ia2Q72e6/DUHQv/6CThjRlOKIIk9oFJbhO4A==","signatures":[{"sig":"MEUCIDiXxaef8IuPh054Lzmsls2GyxxNAnC1PI3l7acI/g8SAiEA6mgLKAw1xwWWYtP9ZXFGqKHSWUsyGtf9nWETAhzHKEI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63404},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"23dcee4f5721e057c3d9625f10e1823f834a466d","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.1.6_1751474857125_0.8882570449139653","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."},"1.1.7":{"name":"@200systems/mf-service-base","version":"1.1.7","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","_id":"@200systems/mf-service-base@1.1.7","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"homepage":"https://github.com/200Systems/bitbrick-microframework#readme","bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"dist":{"shasum":"b49d538e03fe3d5e229b1037c42dafc4e161651d","tarball":"https://registry.npmjs.org/@200systems/mf-service-base/-/mf-service-base-1.1.7.tgz","fileCount":38,"integrity":"sha512-O4Zm7jssUl4i4H+FSiosVQJDn1P9TNMblbkhftoqsiJvP6beoCDPeaN6JQByBUDLtUjlmMF09lWgSKZCvaeIOg==","signatures":[{"sig":"MEYCIQCS51HlJstfo9kA5lXU2G3TsLN2woZJGFl+AcwjwYwpKQIhAP450xsrOSUq3F79myNPKOuSeY51tJSzYEl3rfRzt7L2","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63413},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"23dcee4f5721e057c3d9625f10e1823f834a466d","scripts":{"lint":"eslint src/**/*.ts","build":"tsc --build","clean":"rm -rf dist *.tsbuildinfo","lint:fix":"eslint src/**/*.ts --fix"},"_npmUser":{"name":"200systems","actor":{"name":"200systems","type":"user","email":"cleiton.marques@200.systems"},"email":"cleiton.marques@200.systems"},"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"_npmVersion":"10.8.1","description":"Service layer base classes with validation, error handling, and business logic patterns","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@200systems/mf-logger":"^1.0.0","@200systems/mf-db-core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mf-service-base_1.1.7_1751475261409_0.7739110494380526","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Descontinuado: use @groundbrick/service-base."}},"time":{"created":"2025-06-26T11:23:50.814Z","modified":"2026-09-27T14:02:53.257Z","1.0.1":"2025-06-26T11:23:51.277Z","1.0.2":"2025-06-27T08:53:43.865Z","1.0.3":"2025-06-27T20:40:04.486Z","1.0.4":"2025-06-27T21:15:17.451Z","1.0.5":"2025-06-27T21:29:15.314Z","1.1.1":"2025-06-29T18:58:53.781Z","1.1.2":"2025-06-29T19:10:36.711Z","1.1.3":"2025-07-02T16:08:47.466Z","1.1.4":"2025-07-02T16:32:59.351Z","1.1.5":"2025-07-02T16:37:32.545Z","1.1.6":"2025-07-02T16:47:37.353Z","1.1.7":"2025-07-02T16:54:21.586Z"},"bugs":{"url":"https://github.com/200Systems/bitbrick-microframework/issues"},"author":{"name":"Cleiton Marques","email":"cleiton.marques@200.systems"},"license":"MIT","homepage":"https://github.com/200Systems/bitbrick-microframework#readme","keywords":["typescript","service-layer","business-logic","validation","microframework","error-handling","transactions"],"repository":{"url":"git+https://github.com/200Systems/bitbrick-microframework.git","type":"git","directory":"packages/service-base"},"description":"Service layer base classes with validation, error handling, and business logic patterns","maintainers":[{"name":"200systems","email":"cleiton.marques@200.systems"}],"readme":"# @200systems/mf-service-base\n\n🧠 Service layer foundation with validation, logging, error handling, and transaction support.\n\n\nService layer base classes and utilities for business logic implementation in layered architecture applications.\n\n## 🚀 Features\n\n### 🎯 **BaseService Class**\n- Integrated logging with service context\n- Database transaction management\n- Input validation framework\n- Standardized error handling\n- Repository integration patterns\n\n### 🔧 **Business Logic Patterns**\n- Input validation before repository calls\n- Business rule enforcement\n- Cross-entity operations coordination\n- Response transformation and mapping\n\n### ⚡ **Error Handling**\n- Business-specific error types (`BusinessError`)\n- Validation error aggregation\n- Repository error transformation\n- Structured error responses for APIs\n\n### ✅ **Validation System**\n- Simple, extensible validation framework\n- Common validation rules included\n- Custom rule registration\n- Field-level error reporting\n\n## Installation\n\n```bash\nnpm install @200systems/mf-service-base\n```\n\n## Dependencies\n\nThis package requires:\n- `@200systems/mf-logger` - Logging functionality\n- `@200systems/mf-db-core` - Database interfaces\n\n## Quick Start\n\n### 1. Basic Service Implementation\n\n```typescript\nimport { BaseService, BusinessError, ValidationHelper } from '@200systems/mf-service-base';\nimport { UserRepository } from './UserRepository';\n\ninterface User {\n  id: number;\n  name: string;\n  email: string;\n  active: boolean;\n}\n\ninterface CreateUserRequest {\n  name: string;\n  email: string;\n}\n\nexport class UserService extends BaseService {\n  constructor(private userRepository: UserRepository) {\n    super();\n  }\n\n  async createUser(userData: CreateUserRequest): Promise<User> {\n    const endTimer = this.startOperation('createUser');\n\n    try {\n      // 1. Validate input\n      const validationResult = await this.validate(userData, {\n        name: [\n          ValidationHelper.required(),\n          ValidationHelper.minLength(2),\n          ValidationHelper.maxLength(100)\n        ],\n        email: [\n          ValidationHelper.required(),\n          ValidationHelper.email()\n        ]\n      });\n\n      if (!validationResult.isValid) {\n        throw new BusinessError(\n          'Invalid user data',\n          'VALIDATION_FAILED',\n          undefined,\n          { errors: validationResult.errors }\n        );\n      }\n\n      // 2. Business logic\n      const existingUser = await this.userRepository.findByEmail(userData.email);\n      if (existingUser) {\n        throw new BusinessError(\n          'User already exists',\n          'USER_EXISTS',\n          undefined,\n          { email: userData.email }\n        );\n      }\n\n      // 3. Create user\n      const user = await this.userRepository.create({\n        name: userData.name,\n        email: userData.email.toLowerCase(),\n        active: true\n      });\n\n      this.logger.info('User created successfully', { userId: user.id });\n      return user;\n\n    } catch (error) {\n      if (BusinessError.isBusinessError(error)) {\n        throw error;\n      }\n      throw this.handleRepositoryError(error as Error);\n    } finally {\n      endTimer();\n    }\n  }\n}\n```\n\n### 2. Using Transactions\n\n```typescript\nexport class OrderService extends BaseService {\n  constructor(\n    private orderRepository: OrderRepository,\n    private inventoryRepository: InventoryRepository,\n    options?: ServiceOptions\n  ) {\n    super(options);\n  }\n\n  async createOrder(orderData: CreateOrderRequest): Promise<Order> {\n    // Use transaction for multi-repository operations\n    return await this.withTransaction(async (tx) => {\n      // Create order\n      const order = await this.orderRepository.createWithTransaction(tx, {\n        user_id: orderData.user_id,\n        total_amount: orderData.total\n      });\n\n      // Update inventory\n      for (const item of orderData.items) {\n        await this.inventoryRepository.decrementStockWithTransaction(\n          tx,\n          item.product_id,\n          item.quantity\n        );\n      }\n\n      return order;\n    });\n  }\n}\n```\n\n#### 📋 Transaction pattern:\n1. **Create Parent First, Use Generated ID**\n\n```typescript\n// Inside withTransaction callback\nconst newOrder = await this.orderRepository.createWithTransaction(tx, {\n  user_id: orderData.user_id,\n  total_amount: totalAmount,\n  status: 'pending'\n});\n\n// newOrder.id is now available (auto-generated by database)\n\n// Use the order ID for child records\nfor (const item of orderData.items) {\n  await this.orderItemRepository.createWithTransaction(tx, {\n    order_id: newOrder.id,  // 👈 Use the generated ID\n    product_id: item.product_id,\n    quantity: item.quantity,\n    unit_price: item.unit_price\n  });\n}\n```\n\n2. **Alternative: Bulk Creation**\n```typescript\n// Create all order items at once\nconst orderItemsData = orderData.items.map(item => ({\n  order_id: newOrder.id,  // Same ID for all items\n  product_id: item.product_id,\n  quantity: item.quantity,\n  unit_price: item.unit_price\n}));\n\nawait this.orderItemRepository.createManyWithTransaction(tx, orderItemsData);\n```\n\n3. **Complete Example with Proper Flow**\n```typescript\nasync createOrder(orderData: CreateOrderRequest): Promise<Order> {\n  return await this.withTransaction(async (tx) => {\n    // 1. Validate business rules first\n    await this.validateOrderData(orderData);\n    \n    // 2. Calculate total amount\n    let totalAmount = 0;\n    const validatedItems = [];\n    \n    for (const item of orderData.items) {\n      const product = await this.productRepository.findByIdWithTransaction(tx, item.product_id);\n      // ... validation logic\n      totalAmount += product.price * item.quantity;\n      validatedItems.push({\n        product_id: item.product_id,\n        quantity: item.quantity,\n        unit_price: product.price\n      });\n    }\n\n    // 3. Create the order (gets auto-generated ID)\n    const newOrder = await this.orderRepository.createWithTransaction(tx, {\n      user_id: orderData.user_id,\n      total_amount: totalAmount,\n      status: 'pending',\n      created_at: new Date()\n    });\n\n    // 4. Create order items using the order ID\n    for (const item of validatedItems) {\n      await this.orderItemRepository.createWithTransaction(tx, {\n        order_id: newOrder.id,  // 👈 Key: Use generated order ID\n        product_id: item.product_id,\n        quantity: item.quantity,\n        unit_price: item.unit_price\n      });\n    }\n\n    // 5. Update product inventory\n    for (const item of orderData.items) {\n      await this.productRepository.decrementStockWithTransaction(\n        tx, \n        item.product_id, \n        item.quantity\n      );\n    }\n\n    // 6. Return the complete order (with ID)\n    return newOrder;\n  });\n}\n```\n\n#### 🔧 Repository Method Requirements:\nYour repositories need to support transaction-aware methods:\n```typescript\n// In your OrderRepository\nclass OrderRepository extends BaseRepository<Order> {\n  async createWithTransaction(tx: DatabaseTransaction, data: Partial<Order>): Promise<Order> {\n    // Use tx.query() instead of this.db.query()\n    const result = await tx.query(\n      'INSERT INTO orders (user_id, total_amount, status, created_at) VALUES (?, ?, ?, ?) RETURNING *',\n      [data.user_id, data.total_amount, data.status, data.created_at]\n    );\n    return result.rows[0];\n  }\n}\n\n// In your OrderItemRepository  \nclass OrderItemRepository extends BaseRepository<OrderItem> {\n  async createWithTransaction(tx: DatabaseTransaction, data: Partial<OrderItem>): Promise<OrderItem> {\n    const result = await tx.query(\n      'INSERT INTO order_items (order_id, product_id, quantity, unit_price) VALUES (?, ?, ?, ?) RETURNING *',\n      [data.order_id, data.product_id, data.quantity, data.unit_price]\n    );\n    return result.rows[0];\n  }\n\n  async createManyWithTransaction(tx: DatabaseTransaction, items: Partial<OrderItem>[]): Promise<OrderItem[]> {\n    // Bulk insert implementation\n    const values = items.map(item => [item.order_id, item.product_id, item.quantity, item.unit_price]);\n    // ... bulk insert logic\n  }\n}\n```\n#### 💡 Key Points:\n\n- Order matters: Create parent record first to get the ID\n- Use the transaction: All operations must use the same tx parameter\n- ID is immediately available: After createWithTransaction, the returned object has the generated ID\n- All-or-nothing: If any step fails, the entire transaction rolls back\n- Performance: Consider bulk operations for multiple child records\n\n### 3. Custom Validation Rules\n\n```typescript\nexport class ProductService extends BaseService {\n  constructor(private productRepository: ProductRepository) {\n    super();\n    \n    // Register custom validation rules\n    this.validator.registerRule('sku', (value) => {\n      const skuPattern = /^[A-Z]{2}-\\d{4}$/;\n      return skuPattern.test(value) ? null : 'SKU must follow format: XX-0000';\n    });\n  }\n\n  async createProduct(productData: CreateProductRequest): Promise<Product> {\n    const validationResult = await this.validate(productData, {\n      name: [ValidationHelper.required(), ValidationHelper.minLength(2)],\n      sku: [ValidationHelper.required(), this.validator.getRule('sku')!],\n      price: [ValidationHelper.required(), ValidationHelper.numberRange(0.01, 10000)]\n    });\n\n    if (!validationResult.isValid) {\n      throw new BusinessError('Invalid product data', 'VALIDATION_FAILED', undefined, {\n        errors: validationResult.errors\n      });\n    }\n\n    // Create product logic...\n  }\n}\n```\n\n## API Reference\n\n### BaseService\n\nThe abstract base class that your services should extend.\n\n#### Constructor Options\n\n```typescript\ninterface ServiceOptions {\n  database?: DatabaseClient;     // For transaction support\n  validator?: Validator;         // Custom validator instance\n  config?: Record<string, any>;  // Service-specific config\n}\n```\n\n#### Protected Methods\n\n```typescript\n// Validation\nprotected async validate<T>(data: T, rules: ValidationRules): Promise<ValidationResult>\nprotected validateRequired(data: Record<string, any>, fields: string[]): void\n\n// Transactions\nprotected async withTransaction<T>(callback: (tx: DatabaseTransaction) => Promise<T>): Promise<T>\n\n// Error Handling\nprotected handleRepositoryError(error: Error): BusinessError\n\n// Utilities\nprotected startOperation(operation: string, metadata?: Record<string, any>): () => void\nprotected safeSerialize(obj: any): any\n```\n\n### 🛡 BusinessError\n\nCustom error class for business logic errors.\n\n```typescript\nclass BusinessError extends Error {\n  constructor(\n    message: string,\n    code: string,\n    originalError?: Error,\n    context?: Record<string, any>\n  )\n\n  // Properties\n  readonly code: string\n  readonly originalError?: Error\n  readonly context?: Record<string, any>\n  readonly timestamp: Date\n\n  // Methods\n  toJSON(): Record<string, any>\n  toUserResponse(): { error: string; code: string; timestamp: string }\n  hasCode(code: string): boolean\n  static isBusinessError(error: any): error is BusinessError\n}\n```\n\n### ValidationHelper\n\nPre-built validation rules for common scenarios.\n\n```typescript\nclass ValidationHelper {\n  // Basic rules\n  static required(): ValidationRule\n  static minLength(min: number): ValidationRule\n  static maxLength(max: number): ValidationRule\n  static email(): ValidationRule\n  static numberRange(min?: number, max?: number): ValidationRule\n  static pattern(regex: RegExp, message: string): ValidationRule\n  static oneOf(options: any[], message?: string): ValidationRule\n  \n  // Array rules\n  static arrayMinLength(min: number): ValidationRule\n  \n  // Advanced rules\n  static custom(validator: (value: any, data?: any) => string | null): ValidationRule\n  static when(condition: (data: any) => boolean, rule: ValidationRule): ValidationRule\n  \n  // Utility methods\n  static combine(...rules: ValidationRule[]): ValidationRule[]\n  static entityId(): ValidationRule[]\n  \n  // Pre-configured rule sets\n  static userCreation(): ValidationRules\n  static pagination(): ValidationRules\n}\n```\n\n## ✅ Validation System\n\n### Basic Validation\n\n```typescript\nconst result = await this.validate(data, {\n  email: [ValidationHelper.required(), ValidationHelper.email()],\n  age: [ValidationHelper.numberRange(18, 120)]\n});\n\nif (!result.isValid) {\n  // Handle validation errors\n  console.log(result.errors); // { email: ['Must be a valid email'], age: ['Must be at least 18'] }\n}\n```\n\n### 🧠 Custom Validation Rules\n\n```typescript\n// Register a custom rule\nthis.validator.registerRule('phone', (value) => {\n  const phonePattern = /^\\+?[\\d\\s-()]{10,}$/;\n  return phonePattern.test(value) ? null : 'Invalid phone number format';\n});\n\n// Use in validation\nconst rules = {\n  phone: [ValidationHelper.required(), this.validator.getRule('phone')!]\n};\n```\n\n### Conditional Validation\n\n```typescript\nconst rules = {\n  email: [ValidationHelper.required(), ValidationHelper.email()],\n  password: ValidationHelper.when(\n    (data) => data.isNewUser === true,\n    ValidationHelper.combine(\n      ValidationHelper.required(),\n      ValidationHelper.minLength(8)\n    )\n  )\n};\n```\n\n## Error Handling Patterns\n\n### 1. Repository Error Transformation\n\nThe `handleRepositoryError` method automatically transforms common database errors:\n\n```typescript\n// Database constraint violation → BusinessError with DUPLICATE_RESOURCE code\n// Record not found → BusinessError with RESOURCE_NOT_FOUND code  \n// Foreign key violation → BusinessError with CONSTRAINT_VIOLATION code\n// Other errors → BusinessError with OPERATION_FAILED code\n```\n\n### 2. Structured Error Responses\n\n```typescript\ntry {\n  const user = await userService.createUser(userData);\n  return createSuccessResult(user);\n} catch (error) {\n  if (BusinessError.isBusinessError(error)) {\n    // Handle business logic errors\n    return createErrorResult(error);\n  }\n  // Handle unexpected errors\n  throw error;\n}\n```\n\n### 3. API Integration\n\n```typescript\nexport class UserController {\n  async createUser(req: any, res: any) {\n    try {\n      const user = await this.userService.createUser(req.body);\n      res.status(201).json(createSuccessResult(user));\n    } catch (error) {\n      const result = createErrorResult(error as Error);\n      \n      // Map business error codes to HTTP status codes\n      let status = 500;\n      if (BusinessError.isBusinessError(error)) {\n        switch (error.code) {\n          case 'VALIDATION_FAILED': status = 400; break;\n          case 'USER_EXISTS': status = 409; break;\n          case 'USER_NOT_FOUND': status = 404; break;\n        }\n      }\n      \n      res.status(status).json(result);\n    }\n  }\n}\n```\n\n## Transaction Management\n\n### Simple Transaction\n\n```typescript\nasync updateUserProfile(userId: number, profileData: any): Promise<User> {\n  return await this.withTransaction(async (tx) => {\n    // Update user\n    const user = await this.userRepository.updateWithTransaction(tx, userId, {\n      name: profileData.name,\n      email: profileData.email\n    });\n\n    // Update user preferences\n    await this.preferencesRepository.updateWithTransaction(tx, userId, {\n      theme: profileData.theme,\n      language: profileData.language\n    });\n\n    return user;\n  });\n}\n```\n\n### Complex Business Transaction\n\n```typescript\nasync processOrder(orderData: CreateOrderRequest): Promise<Order> {\n  return await this.withTransaction(async (tx) => {\n    // 1. Validate inventory\n    for (const item of orderData.items) {\n      const product = await this.productRepository.findByIdWithTransaction(tx, item.productId);\n      if (product.stock < item.quantity) {\n        throw new BusinessError('Insufficient stock', 'INSUFFICIENT_STOCK');\n      }\n    }\n\n    // 2. Create order\n    const order = await this.orderRepository.createWithTransaction(tx, orderData);\n\n    // 3. Update inventory\n    for (const item of orderData.items) {\n      await this.productRepository.decrementStockWithTransaction(\n        tx, item.productId, item.quantity\n      );\n    }\n\n    // 4. Send notification (example of non-transactional side effect)\n    // Note: This should be handled outside the transaction\n    // Consider using event-driven patterns for side effects\n\n    return order;\n  });\n}\n```\n\n## Best Practices\n\n### 1. Keep Services Focused\n\n```typescript\n// ✅ Good - Single responsibility\nclass UserService extends BaseService {\n  async createUser(userData: CreateUserRequest): Promise<User> { }\n  async updateUser(id: number, updates: UpdateUserRequest): Promise<User> { }\n  async getUserById(id: number): Promise<User> { }\n}\n\n// ❌ Bad - Too many responsibilities\nclass UserService extends BaseService {\n  async createUser(userData: CreateUserRequest): Promise<User> { }\n  async sendWelcomeEmail(user: User): Promise<void> { } // Should be EmailService\n  async generateReport(userId: number): Promise<Report> { } // Should be ReportService\n}\n```\n\n### 2. Validate Input Early\n\n```typescript\n// ✅ Good - Validate first\nasync createUser(userData: CreateUserRequest): Promise<User> {\n  const validationResult = await this.validate(userData, this.getUserValidationRules());\n  if (!validationResult.isValid) {\n    throw new BusinessError('Validation failed', 'VALIDATION_FAILED', undefined, {\n      errors: validationResult.errors\n    });\n  }\n  \n  // Continue with business logic...\n}\n\n// ❌ Bad - Validation mixed with business logic\nasync createUser(userData: CreateUserRequest): Promise<User> {\n  const existingUser = await this.userRepository.findByEmail(userData.email);\n  if (!userData.email) { // Too late for basic validation\n    throw new Error('Email required');\n  }\n  // ...\n}\n```\n\n### 3. Use Transactions for Multi-Repository Operations\n\n```typescript\n// ✅ Good - Transaction for consistency\nasync transferFunds(fromAccount: number, toAccount: number, amount: number): Promise<void> {\n  await this.withTransaction(async (tx) => {\n    await this.accountRepository.decrementBalanceWithTransaction(tx, fromAccount, amount);\n    await this.accountRepository.incrementBalanceWithTransaction(tx, toAccount, amount);\n    await this.transactionRepository.createWithTransaction(tx, {\n      from_account: fromAccount,\n      to_account: toAccount,\n      amount\n    });\n  });\n}\n\n// ❌ Bad - No transaction, inconsistent state possible\nasync transferFunds(fromAccount: number, toAccount: number, amount: number): Promise<void> {\n  await this.accountRepository.decrementBalance(fromAccount, amount);\n  await this.accountRepository.incrementBalance(toAccount, amount); // Could fail, leaving inconsistent state\n  await this.transactionRepository.create({ from_account: fromAccount, to_account: toAccount, amount });\n}\n```\n\n### 4. Handle Errors Appropriately\n\n```typescript\n// ✅ Good - Structured error handling\nasync getUserById(id: number): Promise<User> {\n  try {\n    this.validateRequired({ id }, ['id']);\n    \n    const user = await this.userRepository.findById(id);\n    if (!user) {\n      throw new BusinessError('User not found', 'USER_NOT_FOUND', undefined, { userId: id });\n    }\n    \n    return user;\n  } catch (error) {\n    if (BusinessError.isBusinessError(error)) {\n      throw error; // Re-throw business errors\n    }\n    // Transform repository errors\n    throw this.handleRepositoryError(error as Error);\n  }\n}\n```\n\n## Integration with Other Packages\n\nThis service layer integrates seamlessly with other microframework packages:\n\n```typescript\nimport { createLogger } from '@200systems/mf-logger';\nimport { DatabaseFactory } from '@200systems/mf-db-postgres';\nimport { UserRepository } from '@200systems/mf-repository-base';\nimport { UserService } from './UserService';\n\n// Initialize database\nconst db = DatabaseFactory.getInstance({\n  host: 'localhost',\n  database: 'myapp',\n  user: 'user',\n  password: 'password'\n});\n\n// Initialize repository\nconst userRepository = new UserRepository(db);\n\n// Initialize service with database for transaction support\nconst userService = new UserService(userRepository, { database: db });\n\n// Use in application\nconst user = await userService.createUser({\n  name: 'John Doe',\n  email: 'john@example.com'\n});\n```\n\n## Testing\n\nThe package includes comprehensive test utilities. See the `src/__tests__/` directory for examples of:\n\n- Service unit testing with mocked dependencies\n- Validation rule testing\n- Error handling testing\n- Transaction behavior testing\n\n## 📜 License\n\nMIT","readmeFilename":"README.md"}