@temboplus/afloat 0.1.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/LICENSE +7 -0
- package/README.md +21 -0
- package/esm/_dnt.test_shims.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
- package/esm/mod.d.ts +7 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +6 -0
- package/esm/package.json +3 -0
- package/esm/src/errors/api_error.d.ts +63 -0
- package/esm/src/errors/api_error.d.ts.map +1 -0
- package/esm/src/errors/api_error.js +90 -0
- package/esm/src/errors/index.d.ts +3 -0
- package/esm/src/errors/index.d.ts.map +1 -0
- package/esm/src/errors/index.js +2 -0
- package/esm/src/errors/permission_error.d.ts +48 -0
- package/esm/src/errors/permission_error.d.ts.map +1 -0
- package/esm/src/errors/permission_error.js +70 -0
- package/esm/src/features/auth/contract.d.ts +123 -0
- package/esm/src/features/auth/contract.d.ts.map +1 -0
- package/esm/src/features/auth/contract.js +50 -0
- package/esm/src/features/auth/index.d.ts +2 -0
- package/esm/src/features/auth/index.d.ts.map +1 -0
- package/esm/src/features/auth/index.js +1 -0
- package/esm/src/features/auth/manager.d.ts +71 -0
- package/esm/src/features/auth/manager.d.ts.map +1 -0
- package/esm/src/features/auth/manager.js +118 -0
- package/esm/src/features/auth/repository.d.ts +30 -0
- package/esm/src/features/auth/repository.d.ts.map +1 -0
- package/esm/src/features/auth/repository.js +94 -0
- package/esm/src/features/contact/contract.d.ts +170 -0
- package/esm/src/features/contact/contract.d.ts.map +1 -0
- package/esm/src/features/contact/contract.js +49 -0
- package/esm/src/features/contact/index.d.ts +2 -0
- package/esm/src/features/contact/index.d.ts.map +1 -0
- package/esm/src/features/contact/index.js +1 -0
- package/esm/src/features/contact/repository.d.ts +47 -0
- package/esm/src/features/contact/repository.d.ts.map +1 -0
- package/esm/src/features/contact/repository.js +94 -0
- package/esm/src/features/files-gen/contract.d.ts +67 -0
- package/esm/src/features/files-gen/contract.d.ts.map +1 -0
- package/esm/src/features/files-gen/contract.js +40 -0
- package/esm/src/features/files-gen/repository.d.ts +47 -0
- package/esm/src/features/files-gen/repository.d.ts.map +1 -0
- package/esm/src/features/files-gen/repository.js +48 -0
- package/esm/src/features/payout/contract.d.ts +623 -0
- package/esm/src/features/payout/contract.d.ts.map +1 -0
- package/esm/src/features/payout/contract.js +75 -0
- package/esm/src/features/payout/index.d.ts +2 -0
- package/esm/src/features/payout/index.d.ts.map +1 -0
- package/esm/src/features/payout/index.js +1 -0
- package/esm/src/features/payout/repository.d.ts +62 -0
- package/esm/src/features/payout/repository.d.ts.map +1 -0
- package/esm/src/features/payout/repository.js +158 -0
- package/esm/src/features/wallet/contract.d.ts +103 -0
- package/esm/src/features/wallet/contract.d.ts.map +1 -0
- package/esm/src/features/wallet/contract.js +35 -0
- package/esm/src/features/wallet/index.d.ts +2 -0
- package/esm/src/features/wallet/index.d.ts.map +1 -0
- package/esm/src/features/wallet/index.js +1 -0
- package/esm/src/features/wallet/repository.d.ts +74 -0
- package/esm/src/features/wallet/repository.d.ts.map +1 -0
- package/esm/src/features/wallet/repository.js +132 -0
- package/esm/src/models/contact/derivatives/contact.d.ts +168 -0
- package/esm/src/models/contact/derivatives/contact.d.ts.map +1 -0
- package/esm/src/models/contact/derivatives/contact.js +260 -0
- package/esm/src/models/contact/derivatives/contact.test.d.ts.map +1 -0
- package/esm/src/models/contact/derivatives/contact_info.d.ts +188 -0
- package/esm/src/models/contact/derivatives/contact_info.d.ts.map +1 -0
- package/esm/src/models/contact/derivatives/contact_info.js +255 -0
- package/esm/src/models/contact/derivatives/contact_info.test.d.ts.map +1 -0
- package/esm/src/models/contact/index.d.ts +5 -0
- package/esm/src/models/contact/index.d.ts.map +1 -0
- package/esm/src/models/contact/index.js +4 -0
- package/esm/src/models/contact/schemas.d.ts +66 -0
- package/esm/src/models/contact/schemas.d.ts.map +1 -0
- package/esm/src/models/contact/schemas.js +64 -0
- package/esm/src/models/contact/validation.d.ts +37 -0
- package/esm/src/models/contact/validation.d.ts.map +1 -0
- package/esm/src/models/contact/validation.js +139 -0
- package/esm/src/models/contact/validation.test.d.ts.map +1 -0
- package/esm/src/models/index.d.ts +6 -0
- package/esm/src/models/index.d.ts.map +1 -0
- package/esm/src/models/index.js +5 -0
- package/esm/src/models/payout/api.d.ts +29 -0
- package/esm/src/models/payout/api.d.ts.map +1 -0
- package/esm/src/models/payout/api.js +1 -0
- package/esm/src/models/payout/channel.d.ts +58 -0
- package/esm/src/models/payout/channel.d.ts.map +1 -0
- package/esm/src/models/payout/channel.js +46 -0
- package/esm/src/models/payout/derivatives/payout.d.ts +156 -0
- package/esm/src/models/payout/derivatives/payout.d.ts.map +1 -0
- package/esm/src/models/payout/derivatives/payout.js +261 -0
- package/esm/src/models/payout/derivatives/payout.test.d.ts.map +1 -0
- package/esm/src/models/payout/index.d.ts +6 -0
- package/esm/src/models/payout/index.d.ts.map +1 -0
- package/esm/src/models/payout/index.js +5 -0
- package/esm/src/models/payout/schemas.d.ts +154 -0
- package/esm/src/models/payout/schemas.d.ts.map +1 -0
- package/esm/src/models/payout/schemas.js +103 -0
- package/esm/src/models/payout/status.d.ts +31 -0
- package/esm/src/models/payout/status.d.ts.map +1 -0
- package/esm/src/models/payout/status.js +32 -0
- package/esm/src/models/permission.d.ts +42 -0
- package/esm/src/models/permission.d.ts.map +1 -0
- package/esm/src/models/permission.js +37 -0
- package/esm/src/models/user/index.d.ts +3 -0
- package/esm/src/models/user/index.d.ts.map +1 -0
- package/esm/src/models/user/index.js +2 -0
- package/esm/src/models/user/profile.d.ts +38 -0
- package/esm/src/models/user/profile.d.ts.map +1 -0
- package/esm/src/models/user/profile.js +25 -0
- package/esm/src/models/user/user.d.ts +80 -0
- package/esm/src/models/user/user.d.ts.map +1 -0
- package/esm/src/models/user/user.js +149 -0
- package/esm/src/models/wallet/guards.d.ts +11 -0
- package/esm/src/models/wallet/guards.d.ts.map +1 -0
- package/esm/src/models/wallet/guards.js +14 -0
- package/esm/src/models/wallet/index.d.ts +4 -0
- package/esm/src/models/wallet/index.d.ts.map +1 -0
- package/esm/src/models/wallet/index.js +3 -0
- package/esm/src/models/wallet/schemas.d.ts +50 -0
- package/esm/src/models/wallet/schemas.d.ts.map +1 -0
- package/esm/src/models/wallet/schemas.js +64 -0
- package/esm/src/models/wallet/statement.d.ts +27 -0
- package/esm/src/models/wallet/statement.d.ts.map +1 -0
- package/esm/src/models/wallet/statement.js +13 -0
- package/esm/src/shared/base_repository.d.ts +56 -0
- package/esm/src/shared/base_repository.d.ts.map +1 -0
- package/esm/src/shared/base_repository.js +95 -0
- package/esm/src/shared/common_responses.d.ts +13 -0
- package/esm/src/shared/common_responses.d.ts.map +1 -0
- package/esm/src/shared/common_responses.js +10 -0
- package/esm/src/shared/index.d.ts +3 -0
- package/esm/src/shared/index.d.ts.map +1 -0
- package/esm/src/shared/index.js +2 -0
- package/package.json +40 -0
- package/script/_dnt.test_shims.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
- package/script/mod.d.ts +7 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +22 -0
- package/script/package.json +3 -0
- package/script/src/errors/api_error.d.ts +63 -0
- package/script/src/errors/api_error.d.ts.map +1 -0
- package/script/src/errors/api_error.js +94 -0
- package/script/src/errors/index.d.ts +3 -0
- package/script/src/errors/index.d.ts.map +1 -0
- package/script/src/errors/index.js +18 -0
- package/script/src/errors/permission_error.d.ts +48 -0
- package/script/src/errors/permission_error.d.ts.map +1 -0
- package/script/src/errors/permission_error.js +74 -0
- package/script/src/features/auth/contract.d.ts +123 -0
- package/script/src/features/auth/contract.d.ts.map +1 -0
- package/script/src/features/auth/contract.js +53 -0
- package/script/src/features/auth/index.d.ts +2 -0
- package/script/src/features/auth/index.d.ts.map +1 -0
- package/script/src/features/auth/index.js +17 -0
- package/script/src/features/auth/manager.d.ts +71 -0
- package/script/src/features/auth/manager.d.ts.map +1 -0
- package/script/src/features/auth/manager.js +122 -0
- package/script/src/features/auth/repository.d.ts +30 -0
- package/script/src/features/auth/repository.d.ts.map +1 -0
- package/script/src/features/auth/repository.js +98 -0
- package/script/src/features/contact/contract.d.ts +170 -0
- package/script/src/features/contact/contract.d.ts.map +1 -0
- package/script/src/features/contact/contract.js +52 -0
- package/script/src/features/contact/index.d.ts +2 -0
- package/script/src/features/contact/index.d.ts.map +1 -0
- package/script/src/features/contact/index.js +17 -0
- package/script/src/features/contact/repository.d.ts +47 -0
- package/script/src/features/contact/repository.d.ts.map +1 -0
- package/script/src/features/contact/repository.js +98 -0
- package/script/src/features/files-gen/contract.d.ts +67 -0
- package/script/src/features/files-gen/contract.d.ts.map +1 -0
- package/script/src/features/files-gen/contract.js +43 -0
- package/script/src/features/files-gen/repository.d.ts +47 -0
- package/script/src/features/files-gen/repository.d.ts.map +1 -0
- package/script/src/features/files-gen/repository.js +52 -0
- package/script/src/features/payout/contract.d.ts +623 -0
- package/script/src/features/payout/contract.d.ts.map +1 -0
- package/script/src/features/payout/contract.js +78 -0
- package/script/src/features/payout/index.d.ts +2 -0
- package/script/src/features/payout/index.d.ts.map +1 -0
- package/script/src/features/payout/index.js +17 -0
- package/script/src/features/payout/repository.d.ts +62 -0
- package/script/src/features/payout/repository.d.ts.map +1 -0
- package/script/src/features/payout/repository.js +162 -0
- package/script/src/features/wallet/contract.d.ts +103 -0
- package/script/src/features/wallet/contract.d.ts.map +1 -0
- package/script/src/features/wallet/contract.js +38 -0
- package/script/src/features/wallet/index.d.ts +2 -0
- package/script/src/features/wallet/index.d.ts.map +1 -0
- package/script/src/features/wallet/index.js +17 -0
- package/script/src/features/wallet/repository.d.ts +74 -0
- package/script/src/features/wallet/repository.d.ts.map +1 -0
- package/script/src/features/wallet/repository.js +136 -0
- package/script/src/models/contact/derivatives/contact.d.ts +168 -0
- package/script/src/models/contact/derivatives/contact.d.ts.map +1 -0
- package/script/src/models/contact/derivatives/contact.js +264 -0
- package/script/src/models/contact/derivatives/contact.test.d.ts.map +1 -0
- package/script/src/models/contact/derivatives/contact_info.d.ts +188 -0
- package/script/src/models/contact/derivatives/contact_info.d.ts.map +1 -0
- package/script/src/models/contact/derivatives/contact_info.js +260 -0
- package/script/src/models/contact/derivatives/contact_info.test.d.ts.map +1 -0
- package/script/src/models/contact/index.d.ts +5 -0
- package/script/src/models/contact/index.d.ts.map +1 -0
- package/script/src/models/contact/index.js +20 -0
- package/script/src/models/contact/schemas.d.ts +66 -0
- package/script/src/models/contact/schemas.d.ts.map +1 -0
- package/script/src/models/contact/schemas.js +67 -0
- package/script/src/models/contact/validation.d.ts +37 -0
- package/script/src/models/contact/validation.d.ts.map +1 -0
- package/script/src/models/contact/validation.js +146 -0
- package/script/src/models/contact/validation.test.d.ts.map +1 -0
- package/script/src/models/index.d.ts +6 -0
- package/script/src/models/index.d.ts.map +1 -0
- package/script/src/models/index.js +21 -0
- package/script/src/models/payout/api.d.ts +29 -0
- package/script/src/models/payout/api.d.ts.map +1 -0
- package/script/src/models/payout/api.js +2 -0
- package/script/src/models/payout/channel.d.ts +58 -0
- package/script/src/models/payout/channel.d.ts.map +1 -0
- package/script/src/models/payout/channel.js +49 -0
- package/script/src/models/payout/derivatives/payout.d.ts +156 -0
- package/script/src/models/payout/derivatives/payout.d.ts.map +1 -0
- package/script/src/models/payout/derivatives/payout.js +265 -0
- package/script/src/models/payout/derivatives/payout.test.d.ts.map +1 -0
- package/script/src/models/payout/index.d.ts +6 -0
- package/script/src/models/payout/index.d.ts.map +1 -0
- package/script/src/models/payout/index.js +21 -0
- package/script/src/models/payout/schemas.d.ts +154 -0
- package/script/src/models/payout/schemas.d.ts.map +1 -0
- package/script/src/models/payout/schemas.js +106 -0
- package/script/src/models/payout/status.d.ts +31 -0
- package/script/src/models/payout/status.d.ts.map +1 -0
- package/script/src/models/payout/status.js +35 -0
- package/script/src/models/permission.d.ts +42 -0
- package/script/src/models/permission.d.ts.map +1 -0
- package/script/src/models/permission.js +40 -0
- package/script/src/models/user/index.d.ts +3 -0
- package/script/src/models/user/index.d.ts.map +1 -0
- package/script/src/models/user/index.js +18 -0
- package/script/src/models/user/profile.d.ts +38 -0
- package/script/src/models/user/profile.d.ts.map +1 -0
- package/script/src/models/user/profile.js +28 -0
- package/script/src/models/user/user.d.ts +80 -0
- package/script/src/models/user/user.d.ts.map +1 -0
- package/script/src/models/user/user.js +153 -0
- package/script/src/models/wallet/guards.d.ts +11 -0
- package/script/src/models/wallet/guards.d.ts.map +1 -0
- package/script/src/models/wallet/guards.js +17 -0
- package/script/src/models/wallet/index.d.ts +4 -0
- package/script/src/models/wallet/index.d.ts.map +1 -0
- package/script/src/models/wallet/index.js +19 -0
- package/script/src/models/wallet/schemas.d.ts +50 -0
- package/script/src/models/wallet/schemas.d.ts.map +1 -0
- package/script/src/models/wallet/schemas.js +67 -0
- package/script/src/models/wallet/statement.d.ts +27 -0
- package/script/src/models/wallet/statement.d.ts.map +1 -0
- package/script/src/models/wallet/statement.js +16 -0
- package/script/src/shared/base_repository.d.ts +56 -0
- package/script/src/shared/base_repository.d.ts.map +1 -0
- package/script/src/shared/base_repository.js +99 -0
- package/script/src/shared/common_responses.d.ts +13 -0
- package/script/src/shared/common_responses.d.ts.map +1 -0
- package/script/src/shared/common_responses.js +13 -0
- package/script/src/shared/index.d.ts +3 -0
- package/script/src/shared/index.d.ts.map +1 -0
- package/script/src/shared/index.js +18 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { initContract } from "@ts-rest/core";
|
|
3
|
+
import { profileSchema } from "../../models/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Auth API contract
|
|
6
|
+
*/
|
|
7
|
+
export const authContract = initContract().router({
|
|
8
|
+
logIn: {
|
|
9
|
+
method: "POST",
|
|
10
|
+
path: "/login",
|
|
11
|
+
body: z.object({
|
|
12
|
+
type: z.string().default("password"),
|
|
13
|
+
identity: z.string().email(),
|
|
14
|
+
password: z.string(),
|
|
15
|
+
}),
|
|
16
|
+
responses: {
|
|
17
|
+
201: z.object({
|
|
18
|
+
profile: profileSchema,
|
|
19
|
+
token: z.string(),
|
|
20
|
+
access: z.array(z.string()),
|
|
21
|
+
resetPassword: z.boolean(),
|
|
22
|
+
}),
|
|
23
|
+
400: z.object({}),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
resetPassword: {
|
|
27
|
+
method: "PUT",
|
|
28
|
+
path: "/password",
|
|
29
|
+
body: z.object({
|
|
30
|
+
currentPassword: z.string(),
|
|
31
|
+
newPassword: z.string(),
|
|
32
|
+
}),
|
|
33
|
+
responses: {},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
export const identityContract = initContract().router({
|
|
37
|
+
getUserCredentials: {
|
|
38
|
+
method: "GET",
|
|
39
|
+
path: "/me",
|
|
40
|
+
headers: z.object({
|
|
41
|
+
token: z.string(),
|
|
42
|
+
}),
|
|
43
|
+
responses: {
|
|
44
|
+
200: z.object({
|
|
45
|
+
name: z.string(),
|
|
46
|
+
identity: z.string(),
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./manager.js";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { User } from "../../models/index.js";
|
|
2
|
+
import type { Permission } from "../../models/permission.js";
|
|
3
|
+
/**
|
|
4
|
+
* Singleton class responsible for user authentication and session management.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AfloatAuth {
|
|
7
|
+
private static _instance;
|
|
8
|
+
/**
|
|
9
|
+
* Private constructor to prevent direct instantiation.
|
|
10
|
+
*/
|
|
11
|
+
private constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Gets the singleton instance of AfloatAuth.
|
|
14
|
+
* @returns {AfloatAuth} The singleton instance.
|
|
15
|
+
*/
|
|
16
|
+
static get instance(): AfloatAuth;
|
|
17
|
+
/**
|
|
18
|
+
* Fetches the authentication repository.
|
|
19
|
+
* @private
|
|
20
|
+
* @returns {AuthRepository} The repository instance for authentication-related API calls.
|
|
21
|
+
*/
|
|
22
|
+
private get repo();
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the current user's authentication token.
|
|
25
|
+
* @returns {string | undefined} The token of the currently authenticated user.
|
|
26
|
+
*/
|
|
27
|
+
getUserToken(): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the currently logged-in user.
|
|
30
|
+
* @returns {User | undefined} The current user object, or `undefined` if no user is logged in.
|
|
31
|
+
*/
|
|
32
|
+
get currentUser(): User | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* React hook that retrieves the currently authenticated user from the global store.
|
|
35
|
+
*
|
|
36
|
+
* @returns {User | undefined} The current user object if authenticated, or `undefined` if no user is logged in.
|
|
37
|
+
*/
|
|
38
|
+
useCurrentUser(): User | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the current user has the specified permission.
|
|
41
|
+
* @param {Permission} perm - The permission to check.
|
|
42
|
+
* @returns {boolean} `true` if the user has the permission, otherwise `false`.
|
|
43
|
+
*/
|
|
44
|
+
checkPermission(perm: Permission): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Logs in a user with the provided email and password.
|
|
47
|
+
* @param {string} email - The user's email address.
|
|
48
|
+
* @param {string} password - The user's password.
|
|
49
|
+
* @returns {Promise<User>} A promise that resolves to the authenticated user.
|
|
50
|
+
* @throws Will throw an error if authentication fails.
|
|
51
|
+
*/
|
|
52
|
+
logIn(email: string, password: string): Promise<User>;
|
|
53
|
+
/**
|
|
54
|
+
* Resets the user's password.
|
|
55
|
+
* @param {string} current - The current password.
|
|
56
|
+
* @param {string} updated - The new password.
|
|
57
|
+
* @returns {Promise<boolean>} A promise that resolves to `true` if the operation is successful.
|
|
58
|
+
* @throws Will throw an error if the reset fails.
|
|
59
|
+
*/
|
|
60
|
+
resetPassword(current: string, updated: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Logs out the current user and clears session data.
|
|
63
|
+
*/
|
|
64
|
+
logOut(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Clears saved authentication data from the store and session storage.
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
private clearSavedData;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAI7D;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAa;IAErC;;OAEG;IACH,OAAO;IAEP;;;OAGG;IACH,WAAkB,QAAQ,IAAI,UAAU,CAEvC;IAED;;;;OAIG;IACH,OAAO,KAAK,IAAI,GAEf;IAED;;;OAGG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;;OAGG;IACH,IAAI,WAAW,IAAI,IAAI,GAAG,SAAS,CAElC;IACD;;;;OAIG;IACH,cAAc,IAAI,IAAI,GAAG,SAAS;IAIlC;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAI1C;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3D;;;;;;OAMG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvE;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,OAAO,CAAC,cAAc;CAIvB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { create, useStore, } from "zustand";
|
|
2
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
3
|
+
import { AuthRepository } from "./repository.js";
|
|
4
|
+
import { User } from "../../models/index.js";
|
|
5
|
+
const AUTH_STORE_SESSION_STORAGE_KEY = "auth-store";
|
|
6
|
+
/**
|
|
7
|
+
* Singleton class responsible for user authentication and session management.
|
|
8
|
+
*/
|
|
9
|
+
export class AfloatAuth {
|
|
10
|
+
/**
|
|
11
|
+
* Private constructor to prevent direct instantiation.
|
|
12
|
+
*/
|
|
13
|
+
constructor() { }
|
|
14
|
+
/**
|
|
15
|
+
* Gets the singleton instance of AfloatAuth.
|
|
16
|
+
* @returns {AfloatAuth} The singleton instance.
|
|
17
|
+
*/
|
|
18
|
+
static get instance() {
|
|
19
|
+
return this._instance || (this._instance = new this());
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetches the authentication repository.
|
|
23
|
+
* @private
|
|
24
|
+
* @returns {AuthRepository} The repository instance for authentication-related API calls.
|
|
25
|
+
*/
|
|
26
|
+
get repo() {
|
|
27
|
+
return new AuthRepository();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the current user's authentication token.
|
|
31
|
+
* @returns {string | undefined} The token of the currently authenticated user.
|
|
32
|
+
*/
|
|
33
|
+
getUserToken() {
|
|
34
|
+
return this.currentUser?.token;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets the currently logged-in user.
|
|
38
|
+
* @returns {User | undefined} The current user object, or `undefined` if no user is logged in.
|
|
39
|
+
*/
|
|
40
|
+
get currentUser() {
|
|
41
|
+
return store.getState().getUser();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* React hook that retrieves the currently authenticated user from the global store.
|
|
45
|
+
*
|
|
46
|
+
* @returns {User | undefined} The current user object if authenticated, or `undefined` if no user is logged in.
|
|
47
|
+
*/
|
|
48
|
+
useCurrentUser() {
|
|
49
|
+
return useStore(store).getUser();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks if the current user has the specified permission.
|
|
53
|
+
* @param {Permission} perm - The permission to check.
|
|
54
|
+
* @returns {boolean} `true` if the user has the permission, otherwise `false`.
|
|
55
|
+
*/
|
|
56
|
+
checkPermission(perm) {
|
|
57
|
+
return this.currentUser?.can(perm) ?? false;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Logs in a user with the provided email and password.
|
|
61
|
+
* @param {string} email - The user's email address.
|
|
62
|
+
* @param {string} password - The user's password.
|
|
63
|
+
* @returns {Promise<User>} A promise that resolves to the authenticated user.
|
|
64
|
+
* @throws Will throw an error if authentication fails.
|
|
65
|
+
*/
|
|
66
|
+
async logIn(email, password) {
|
|
67
|
+
const user = await this.repo.logIn(email, password);
|
|
68
|
+
this.clearSavedData();
|
|
69
|
+
store.getState().setUser(user);
|
|
70
|
+
return user;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resets the user's password.
|
|
74
|
+
* @param {string} current - The current password.
|
|
75
|
+
* @param {string} updated - The new password.
|
|
76
|
+
* @returns {Promise<boolean>} A promise that resolves to `true` if the operation is successful.
|
|
77
|
+
* @throws Will throw an error if the reset fails.
|
|
78
|
+
*/
|
|
79
|
+
async resetPassword(current, updated) {
|
|
80
|
+
await this.repo.updatePassword(current, updated);
|
|
81
|
+
this.clearSavedData();
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Logs out the current user and clears session data.
|
|
86
|
+
*/
|
|
87
|
+
logOut() {
|
|
88
|
+
this.clearSavedData();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clears saved authentication data from the store and session storage.
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
clearSavedData() {
|
|
95
|
+
store.getState().refresh();
|
|
96
|
+
sessionStorage.removeItem(AUTH_STORE_SESSION_STORAGE_KEY);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const initialState = { user: undefined };
|
|
100
|
+
const store = create(persist((set, get) => ({
|
|
101
|
+
...initialState,
|
|
102
|
+
getUser: () => {
|
|
103
|
+
try {
|
|
104
|
+
const jsonUser = get().user;
|
|
105
|
+
if (jsonUser)
|
|
106
|
+
return User.fromJSON(jsonUser);
|
|
107
|
+
}
|
|
108
|
+
catch (_) {
|
|
109
|
+
console.log(_);
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
},
|
|
113
|
+
setUser: (user) => set({ user: user.toJSON() }),
|
|
114
|
+
refresh: () => set(initialState),
|
|
115
|
+
}), {
|
|
116
|
+
name: AUTH_STORE_SESSION_STORAGE_KEY,
|
|
117
|
+
storage: createJSONStorage(() => sessionStorage),
|
|
118
|
+
}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { User } from "../../models/index.js";
|
|
2
|
+
import { BaseRepository } from "../../shared/base_repository.js";
|
|
3
|
+
import { authContract } from "./contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* Class representing the AuthRepository.
|
|
6
|
+
* Provides methods to handle authentication-related operations, such as login and password updates.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AuthRepository extends BaseRepository<typeof authContract> {
|
|
9
|
+
/**
|
|
10
|
+
* Initializes an instance of AuthRepository.
|
|
11
|
+
*/
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Logs in a user with the provided email and password.
|
|
15
|
+
* @param email - The email of the user attempting to log in.
|
|
16
|
+
* @param password - The password of the user.
|
|
17
|
+
* @returns A promise that resolves to a User object on successful login.
|
|
18
|
+
* @throws {APIError} If the email or password is invalid, or if another error occurs during the login process.
|
|
19
|
+
*/
|
|
20
|
+
logIn(email: string, password: string): Promise<User>;
|
|
21
|
+
/**
|
|
22
|
+
* Updates the user's password.
|
|
23
|
+
* @param currentPassword - The user's current password.
|
|
24
|
+
* @param newPassword - The new password the user wants to set.
|
|
25
|
+
* @returns A promise that resolves to true if the password update is successful.
|
|
26
|
+
* @throws {APIError} If the current password is invalid or another error occurs during the update process.
|
|
27
|
+
*/
|
|
28
|
+
updatePassword(currentPassword: string, newPassword: string): Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAoB,MAAM,eAAe,CAAC;AAO/D;;;GAGG;AACH,qBAAa,cAAe,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IACrE;;OAEG;;IAKH;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3D;;;;;;OAMG;IACG,cAAc,CAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;CAiBpB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { User } from "../../models/index.js";
|
|
2
|
+
import { BaseRepository } from "../../shared/base_repository.js";
|
|
3
|
+
import { authContract, identityContract } from "./contract.js";
|
|
4
|
+
import { APIError } from "../../errors/api_error.js";
|
|
5
|
+
/**
|
|
6
|
+
* Class representing the AuthRepository.
|
|
7
|
+
* Provides methods to handle authentication-related operations, such as login and password updates.
|
|
8
|
+
*/
|
|
9
|
+
export class AuthRepository extends BaseRepository {
|
|
10
|
+
/**
|
|
11
|
+
* Initializes an instance of AuthRepository.
|
|
12
|
+
*/
|
|
13
|
+
constructor() {
|
|
14
|
+
super("auth", authContract);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Logs in a user with the provided email and password.
|
|
18
|
+
* @param email - The email of the user attempting to log in.
|
|
19
|
+
* @param password - The password of the user.
|
|
20
|
+
* @returns A promise that resolves to a User object on successful login.
|
|
21
|
+
* @throws {APIError} If the email or password is invalid, or if another error occurs during the login process.
|
|
22
|
+
*/
|
|
23
|
+
async logIn(email, password) {
|
|
24
|
+
const body = { type: "password", identity: email, password };
|
|
25
|
+
const result = await this.client.logIn({ body });
|
|
26
|
+
if (result.status === 400) {
|
|
27
|
+
throw new APIError({
|
|
28
|
+
message: "Invalid email or password",
|
|
29
|
+
statusCode: 400,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (result.status === 201) {
|
|
33
|
+
const repo = new LoginRepository();
|
|
34
|
+
const loginCredentials = await repo.getIdentity(result.body.token);
|
|
35
|
+
const user = new User({ ...result.body, loginCredentials });
|
|
36
|
+
return user;
|
|
37
|
+
}
|
|
38
|
+
throw new APIError({
|
|
39
|
+
message: "An error occurred while trying to log in",
|
|
40
|
+
statusCode: 502,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Updates the user's password.
|
|
45
|
+
* @param currentPassword - The user's current password.
|
|
46
|
+
* @param newPassword - The new password the user wants to set.
|
|
47
|
+
* @returns A promise that resolves to true if the password update is successful.
|
|
48
|
+
* @throws {APIError} If the current password is invalid or another error occurs during the update process.
|
|
49
|
+
*/
|
|
50
|
+
async updatePassword(currentPassword, newPassword) {
|
|
51
|
+
const result = await this.client.resetPassword({
|
|
52
|
+
body: { currentPassword, newPassword },
|
|
53
|
+
});
|
|
54
|
+
if (result.status === 200)
|
|
55
|
+
return true;
|
|
56
|
+
if (result.status === 400) {
|
|
57
|
+
throw new APIError({
|
|
58
|
+
message: "Invalid current password",
|
|
59
|
+
statusCode: 400,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
throw new APIError({
|
|
63
|
+
message: "An error occurred while trying to update password",
|
|
64
|
+
statusCode: 502,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Class representing the LoginRepository.
|
|
70
|
+
* Provides methods to retrieve user identity-related information.
|
|
71
|
+
*/
|
|
72
|
+
class LoginRepository extends BaseRepository {
|
|
73
|
+
/**
|
|
74
|
+
* Initializes an instance of LoginRepository.
|
|
75
|
+
*/
|
|
76
|
+
constructor() {
|
|
77
|
+
super("login", identityContract);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Retrieves the user's login credentials.
|
|
81
|
+
* @returns A promise that resolves to the user's login credentials on success.
|
|
82
|
+
* @throws {APIError} If an error occurs while retrieving the credentials.
|
|
83
|
+
*/
|
|
84
|
+
async getIdentity(token) {
|
|
85
|
+
const headers = { token };
|
|
86
|
+
const result = await this.client.getUserCredentials({ headers });
|
|
87
|
+
if (result.status === 200)
|
|
88
|
+
return result.body;
|
|
89
|
+
throw new APIError({
|
|
90
|
+
message: "An error occurred while trying to get login credentials",
|
|
91
|
+
statusCode: 502,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Contact API contract
|
|
4
|
+
* Defines the REST endpoints for managing contacts
|
|
5
|
+
*
|
|
6
|
+
* @property {Object} postContact - Create a new contact (POST /)
|
|
7
|
+
* @property {Object} editContact - Update an existing contact (PATCH /:id)
|
|
8
|
+
* @property {Object} getContacts - Retrieve contacts list (GET /)
|
|
9
|
+
* @property {Object} deleteContact - Delete a contact (DELETE /:id)
|
|
10
|
+
*/
|
|
11
|
+
export declare const contract: {
|
|
12
|
+
postContact: {
|
|
13
|
+
method: "POST";
|
|
14
|
+
body: z.ZodObject<{
|
|
15
|
+
displayName: z.ZodString;
|
|
16
|
+
accountNo: z.ZodString;
|
|
17
|
+
channel: z.ZodString;
|
|
18
|
+
type: z.ZodEnum<["Bank", "Mobile"]>;
|
|
19
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
20
|
+
displayName: string;
|
|
21
|
+
accountNo: string;
|
|
22
|
+
type: "Bank" | "Mobile";
|
|
23
|
+
channel: string;
|
|
24
|
+
}, {
|
|
25
|
+
displayName: string;
|
|
26
|
+
accountNo: string;
|
|
27
|
+
type: "Bank" | "Mobile";
|
|
28
|
+
channel: string;
|
|
29
|
+
}>;
|
|
30
|
+
path: "/";
|
|
31
|
+
responses: {
|
|
32
|
+
[x: number]: import("@ts-rest/core").AppRouteResponse;
|
|
33
|
+
201: z.ZodObject<{
|
|
34
|
+
displayName: z.ZodString;
|
|
35
|
+
accountNo: z.ZodString;
|
|
36
|
+
channel: z.ZodString;
|
|
37
|
+
type: z.ZodEnum<["Bank", "Mobile"]>;
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
profileId: z.ZodString;
|
|
40
|
+
createdAt: z.ZodDate;
|
|
41
|
+
updatedAt: z.ZodDate;
|
|
42
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
43
|
+
id: string;
|
|
44
|
+
displayName: string;
|
|
45
|
+
accountNo: string;
|
|
46
|
+
type: "Bank" | "Mobile";
|
|
47
|
+
channel: string;
|
|
48
|
+
profileId: string;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
updatedAt: Date;
|
|
51
|
+
}, {
|
|
52
|
+
id: string;
|
|
53
|
+
displayName: string;
|
|
54
|
+
accountNo: string;
|
|
55
|
+
type: "Bank" | "Mobile";
|
|
56
|
+
channel: string;
|
|
57
|
+
profileId: string;
|
|
58
|
+
createdAt: Date;
|
|
59
|
+
updatedAt: Date;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
editContact: {
|
|
64
|
+
method: "PATCH";
|
|
65
|
+
body: z.ZodObject<{
|
|
66
|
+
displayName: z.ZodString;
|
|
67
|
+
accountNo: z.ZodString;
|
|
68
|
+
channel: z.ZodString;
|
|
69
|
+
type: z.ZodEnum<["Bank", "Mobile"]>;
|
|
70
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
71
|
+
displayName: string;
|
|
72
|
+
accountNo: string;
|
|
73
|
+
type: "Bank" | "Mobile";
|
|
74
|
+
channel: string;
|
|
75
|
+
}, {
|
|
76
|
+
displayName: string;
|
|
77
|
+
accountNo: string;
|
|
78
|
+
type: "Bank" | "Mobile";
|
|
79
|
+
channel: string;
|
|
80
|
+
}>;
|
|
81
|
+
path: "/:id";
|
|
82
|
+
responses: {
|
|
83
|
+
[x: number]: import("@ts-rest/core").AppRouteResponse;
|
|
84
|
+
200: z.ZodObject<{
|
|
85
|
+
displayName: z.ZodString;
|
|
86
|
+
accountNo: z.ZodString;
|
|
87
|
+
channel: z.ZodString;
|
|
88
|
+
type: z.ZodEnum<["Bank", "Mobile"]>;
|
|
89
|
+
id: z.ZodString;
|
|
90
|
+
profileId: z.ZodString;
|
|
91
|
+
createdAt: z.ZodDate;
|
|
92
|
+
updatedAt: z.ZodDate;
|
|
93
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
94
|
+
id: string;
|
|
95
|
+
displayName: string;
|
|
96
|
+
accountNo: string;
|
|
97
|
+
type: "Bank" | "Mobile";
|
|
98
|
+
channel: string;
|
|
99
|
+
profileId: string;
|
|
100
|
+
createdAt: Date;
|
|
101
|
+
updatedAt: Date;
|
|
102
|
+
}, {
|
|
103
|
+
id: string;
|
|
104
|
+
displayName: string;
|
|
105
|
+
accountNo: string;
|
|
106
|
+
type: "Bank" | "Mobile";
|
|
107
|
+
channel: string;
|
|
108
|
+
profileId: string;
|
|
109
|
+
createdAt: Date;
|
|
110
|
+
updatedAt: Date;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
getContacts: {
|
|
115
|
+
query: z.ZodObject<{
|
|
116
|
+
orderByDesc: z.ZodString;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
orderByDesc: string;
|
|
119
|
+
}, {
|
|
120
|
+
orderByDesc: string;
|
|
121
|
+
}>;
|
|
122
|
+
method: "GET";
|
|
123
|
+
path: "/";
|
|
124
|
+
responses: {
|
|
125
|
+
[x: number]: import("@ts-rest/core").AppRouteResponse;
|
|
126
|
+
200: z.ZodArray<z.ZodObject<{
|
|
127
|
+
displayName: z.ZodString;
|
|
128
|
+
accountNo: z.ZodString;
|
|
129
|
+
channel: z.ZodString;
|
|
130
|
+
type: z.ZodEnum<["Bank", "Mobile"]>;
|
|
131
|
+
id: z.ZodString;
|
|
132
|
+
profileId: z.ZodString;
|
|
133
|
+
createdAt: z.ZodDate;
|
|
134
|
+
updatedAt: z.ZodDate;
|
|
135
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
136
|
+
id: string;
|
|
137
|
+
displayName: string;
|
|
138
|
+
accountNo: string;
|
|
139
|
+
type: "Bank" | "Mobile";
|
|
140
|
+
channel: string;
|
|
141
|
+
profileId: string;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
}, {
|
|
145
|
+
id: string;
|
|
146
|
+
displayName: string;
|
|
147
|
+
accountNo: string;
|
|
148
|
+
type: "Bank" | "Mobile";
|
|
149
|
+
channel: string;
|
|
150
|
+
profileId: string;
|
|
151
|
+
createdAt: Date;
|
|
152
|
+
updatedAt: Date;
|
|
153
|
+
}>, "many">;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
deleteContact: {
|
|
157
|
+
method: "DELETE";
|
|
158
|
+
body: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
159
|
+
path: "/:id";
|
|
160
|
+
responses: {
|
|
161
|
+
[x: number]: import("@ts-rest/core").AppRouteResponse;
|
|
162
|
+
200: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Export type for use in client implementations
|
|
168
|
+
*/
|
|
169
|
+
export type ContactAPI = typeof contract;
|
|
170
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/src/features/contact/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCnB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,QAAQ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { initContract } from "@ts-rest/core";
|
|
3
|
+
import { commonAPIResponses } from "../../shared/index.js";
|
|
4
|
+
import { ContactSchemas } from "../../models/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Contact API contract
|
|
7
|
+
* Defines the REST endpoints for managing contacts
|
|
8
|
+
*
|
|
9
|
+
* @property {Object} postContact - Create a new contact (POST /)
|
|
10
|
+
* @property {Object} editContact - Update an existing contact (PATCH /:id)
|
|
11
|
+
* @property {Object} getContacts - Retrieve contacts list (GET /)
|
|
12
|
+
* @property {Object} deleteContact - Delete a contact (DELETE /:id)
|
|
13
|
+
*/
|
|
14
|
+
export const contract = initContract().router({
|
|
15
|
+
postContact: {
|
|
16
|
+
method: "POST",
|
|
17
|
+
path: "/",
|
|
18
|
+
body: ContactSchemas.contactInput,
|
|
19
|
+
responses: {
|
|
20
|
+
201: ContactSchemas.contactData,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
editContact: {
|
|
24
|
+
method: "PATCH",
|
|
25
|
+
path: "/:id",
|
|
26
|
+
body: ContactSchemas.contactInput,
|
|
27
|
+
responses: {
|
|
28
|
+
200: ContactSchemas.contactData,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
getContacts: {
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: "/",
|
|
34
|
+
query: z.object({ orderByDesc: z.string() }),
|
|
35
|
+
responses: {
|
|
36
|
+
200: z.array(ContactSchemas.contactData),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
deleteContact: {
|
|
40
|
+
method: "DELETE",
|
|
41
|
+
path: "/:id",
|
|
42
|
+
body: z.object({}),
|
|
43
|
+
responses: {
|
|
44
|
+
200: z.object({}),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}, {
|
|
48
|
+
commonResponses: commonAPIResponses,
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/features/contact/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./repository.js";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseRepository } from "../../shared/base_repository.js";
|
|
2
|
+
import { contract } from "./contract.js";
|
|
3
|
+
import { Contact, type ContactInput } from "../../models/contact/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Repository class for managing `Contact` data through API interactions.
|
|
6
|
+
* Extends the `BaseRepository` to leverage shared functionality.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of `ContactRepository` using the contact contract.
|
|
11
|
+
*/
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new contact record.
|
|
15
|
+
* @param {ContactInput} input - The data required to create a new contact.
|
|
16
|
+
* @returns {Promise<Contact>} A promise that resolves to the newly created contact.
|
|
17
|
+
* @throws {APIError} If the response status code is not 201.
|
|
18
|
+
*/
|
|
19
|
+
create(input: ContactInput): Promise<Contact>;
|
|
20
|
+
/**
|
|
21
|
+
* Updates an existing contact record by ID.
|
|
22
|
+
* @param {string} id - The unique identifier of the contact to edit.
|
|
23
|
+
* @param {ContactInput} input - The data to update the contact with.
|
|
24
|
+
* @returns {Promise<Contact>} A promise that resolves to the updated contact.
|
|
25
|
+
* @throws {APIError} If the response status code is not 200.
|
|
26
|
+
*/
|
|
27
|
+
edit(id: string, input: ContactInput): Promise<Contact>;
|
|
28
|
+
/**
|
|
29
|
+
* Deletes a contact record by ID.
|
|
30
|
+
* @param {string} id - The unique identifier of the contact to remove.
|
|
31
|
+
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
32
|
+
* @throws {APIError} If the response status code is not 200.
|
|
33
|
+
*/
|
|
34
|
+
remove(id: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves all contacts
|
|
37
|
+
* Results are ordered in descending order by default.
|
|
38
|
+
*
|
|
39
|
+
* @returns {Promise<Contact[]>} A promise that resolves to an array of contacts.
|
|
40
|
+
* @throws {APIError} If the response status code is not 200 or the range is invalid.
|
|
41
|
+
* @example
|
|
42
|
+
* const repository = new ContactRepository();
|
|
43
|
+
* repository.getAll().then(contacts => console.log(contacts));
|
|
44
|
+
*/
|
|
45
|
+
getAll(): Promise<Contact[]>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/contact/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,OAAO,EAEP,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;AAKvC;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IACpE;;OAEG;;IAKH;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAanD;;;;;;OAMG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB7D;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvC;;;;;;;;;OASG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAanC"}
|