@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,56 @@
|
|
|
1
|
+
import { type AppRouter } from "@ts-rest/core";
|
|
2
|
+
import type { InitClientArgs } from "@ts-rest/core";
|
|
3
|
+
/**
|
|
4
|
+
* BaseRepository
|
|
5
|
+
*
|
|
6
|
+
* A generic base class to build repositories for interacting with the Afloat API.
|
|
7
|
+
* This class initializes a "ts-rest" client using a specified "ts-rest" contract and provides
|
|
8
|
+
* helper methods to handle API responses consistently.
|
|
9
|
+
*
|
|
10
|
+
* @template TContract - The API contract extending `AppRouter` from `@npm/ts_rest.ts`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BaseRepository<TContract extends AppRouter> {
|
|
13
|
+
/**
|
|
14
|
+
* A "ts-rest" contract
|
|
15
|
+
*
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
protected contract: TContract;
|
|
19
|
+
/**
|
|
20
|
+
* An API endpoint
|
|
21
|
+
*
|
|
22
|
+
* @protected
|
|
23
|
+
*/
|
|
24
|
+
protected endpoint: string;
|
|
25
|
+
/**
|
|
26
|
+
* An API Root URL
|
|
27
|
+
*
|
|
28
|
+
* @protected
|
|
29
|
+
*/
|
|
30
|
+
protected root: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new instance of `BaseRepository`.
|
|
33
|
+
*
|
|
34
|
+
* @param contract - The "ts-rest" contract
|
|
35
|
+
* @param endpoint - API endpoint
|
|
36
|
+
*/
|
|
37
|
+
constructor(endpoint: string, contract: TContract, args?: {
|
|
38
|
+
root?: string;
|
|
39
|
+
});
|
|
40
|
+
get client(): { [TKey in keyof TContract]: TContract[TKey] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey], InitClientArgs>> : TContract[TKey] extends AppRouter ? TContract[TKey] extends infer T extends AppRouter ? { [TKey_1 in keyof T]: TContract[TKey][TKey_1] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1], InitClientArgs>> : TContract[TKey][TKey_1] extends AppRouter ? TContract[TKey][TKey_1] extends infer T_1 extends AppRouter ? { [TKey_2 in keyof T_1]: TContract[TKey][TKey_1][TKey_2] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2] extends AppRouter ? TContract[TKey][TKey_1][TKey_2] extends infer T_2 extends AppRouter ? { [TKey_3 in keyof T_2]: TContract[TKey][TKey_1][TKey_2][TKey_3] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3] extends infer T_3 extends AppRouter ? { [TKey_4 in keyof T_3]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends infer T_4 extends AppRouter ? { [TKey_5 in keyof T_4]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends infer T_5 extends AppRouter ? { [TKey_6 in keyof T_5]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends infer T_6 extends AppRouter ? { [TKey_7 in keyof T_6]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends infer T_7 extends AppRouter ? { [TKey_8 in keyof T_7]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends infer T_8 extends AppRouter ? { [TKey_9 in keyof T_8]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends infer T_9 extends AppRouter ? { [TKey_10 in keyof T_9]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10] extends AppRouter ? any : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; };
|
|
41
|
+
/**
|
|
42
|
+
* Handles the API response by checking the HTTP status code and returning the response body
|
|
43
|
+
* for successful requests or throwing an `APIError` for errors.
|
|
44
|
+
*
|
|
45
|
+
* @template T - The expected type of the successful response body.
|
|
46
|
+
* @param result - The API response object containing the status code and response body.
|
|
47
|
+
* @param successStatusCode - The expected HTTP status code indicating success (e.g., 200, 201).
|
|
48
|
+
* @returns The response body typed as `T` if the status code matches the success criteria.
|
|
49
|
+
* @throws `APIError` - If the status code indicates a failure.
|
|
50
|
+
*/
|
|
51
|
+
handleResponse<T>(result: {
|
|
52
|
+
status: number;
|
|
53
|
+
body: unknown;
|
|
54
|
+
}, successStatusCode: number): T;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=base_repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_repository.d.ts","sourceRoot":"","sources":["../../../src/src/shared/base_repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,eAAe,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD;;;;;;;;GAQG;AACH,qBAAa,cAAc,CAAC,SAAS,SAAS,SAAS;IACrD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC;IAE9B;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;OAKG;gBACS,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAM3E,IAAI,MAAM,k0LAcT;IAED;;;;;;;;;OASG;IACH,cAAc,CAAC,CAAC,EACd,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EACzC,iBAAiB,EAAE,MAAM,GACxB,CAAC;CAgBL"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseRepository = void 0;
|
|
4
|
+
const core_1 = require("@ts-rest/core");
|
|
5
|
+
const api_error_js_1 = require("../errors/api_error.js");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
const index_js_1 = require("../features/auth/index.js");
|
|
8
|
+
/**
|
|
9
|
+
* BaseRepository
|
|
10
|
+
*
|
|
11
|
+
* A generic base class to build repositories for interacting with the Afloat API.
|
|
12
|
+
* This class initializes a "ts-rest" client using a specified "ts-rest" contract and provides
|
|
13
|
+
* helper methods to handle API responses consistently.
|
|
14
|
+
*
|
|
15
|
+
* @template TContract - The API contract extending `AppRouter` from `@npm/ts_rest.ts`.
|
|
16
|
+
*/
|
|
17
|
+
class BaseRepository {
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new instance of `BaseRepository`.
|
|
20
|
+
*
|
|
21
|
+
* @param contract - The "ts-rest" contract
|
|
22
|
+
* @param endpoint - API endpoint
|
|
23
|
+
*/
|
|
24
|
+
constructor(endpoint, contract, args) {
|
|
25
|
+
/**
|
|
26
|
+
* A "ts-rest" contract
|
|
27
|
+
*
|
|
28
|
+
* @protected
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(this, "contract", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* An API endpoint
|
|
38
|
+
*
|
|
39
|
+
* @protected
|
|
40
|
+
*/
|
|
41
|
+
Object.defineProperty(this, "endpoint", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: void 0
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* An API Root URL
|
|
49
|
+
*
|
|
50
|
+
* @protected
|
|
51
|
+
*/
|
|
52
|
+
Object.defineProperty(this, "root", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: void 0
|
|
57
|
+
});
|
|
58
|
+
this.contract = contract;
|
|
59
|
+
this.endpoint = endpoint;
|
|
60
|
+
this.root = args?.root;
|
|
61
|
+
}
|
|
62
|
+
get client() {
|
|
63
|
+
const baseUrl = this.root
|
|
64
|
+
? `${this.root}/${this.endpoint}`
|
|
65
|
+
: `https://api.afloat.money/v1/${this.endpoint}`;
|
|
66
|
+
const args = {
|
|
67
|
+
baseUrl,
|
|
68
|
+
baseHeaders: {
|
|
69
|
+
"token": index_js_1.AfloatAuth.instance.getUserToken() ?? "",
|
|
70
|
+
"x-request-id": (0, uuid_1.v4)(),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
return (0, core_1.initClient)(this.contract, args);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Handles the API response by checking the HTTP status code and returning the response body
|
|
77
|
+
* for successful requests or throwing an `APIError` for errors.
|
|
78
|
+
*
|
|
79
|
+
* @template T - The expected type of the successful response body.
|
|
80
|
+
* @param result - The API response object containing the status code and response body.
|
|
81
|
+
* @param successStatusCode - The expected HTTP status code indicating success (e.g., 200, 201).
|
|
82
|
+
* @returns The response body typed as `T` if the status code matches the success criteria.
|
|
83
|
+
* @throws `APIError` - If the status code indicates a failure.
|
|
84
|
+
*/
|
|
85
|
+
handleResponse(result, successStatusCode) {
|
|
86
|
+
if (successStatusCode === result.status) {
|
|
87
|
+
return result.body;
|
|
88
|
+
}
|
|
89
|
+
if (result.status === 400) {
|
|
90
|
+
throw new api_error_js_1.APIError(result.body);
|
|
91
|
+
}
|
|
92
|
+
throw new api_error_js_1.APIError({
|
|
93
|
+
message: "We encountered an error trying to process your request. Please try again later",
|
|
94
|
+
statusCode: 520,
|
|
95
|
+
error: "UNKNOWN ERROR",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.BaseRepository = BaseRepository;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AppRouteResponse } from "@ts-rest/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
type ApiErrorResponseSchemaType = z.ZodObject<{
|
|
4
|
+
statusCode: z.ZodNumber;
|
|
5
|
+
message: z.ZodString;
|
|
6
|
+
error: z.ZodString;
|
|
7
|
+
details: z.ZodOptional<z.ZodRecord>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const common400ResponseSchema: ApiErrorResponseSchemaType;
|
|
10
|
+
export type Common400APIResponse = z.infer<typeof common400ResponseSchema>;
|
|
11
|
+
export declare const commonAPIResponses: Record<number, AppRouteResponse>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=common_responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common_responses.d.ts","sourceRoot":"","sources":["../../../src/src/shared/common_responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,KAAK,0BAA0B,GAAG,CAAC,CAAC,SAAS,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC;IACxB,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC;IACnB,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CACrC,CAAC,CAAC;AACH,eAAO,MAAM,uBAAuB,EAAE,0BAKpC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAE/D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commonAPIResponses = exports.common400ResponseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.common400ResponseSchema = zod_1.z.object({
|
|
6
|
+
statusCode: zod_1.z.number(),
|
|
7
|
+
message: zod_1.z.string(),
|
|
8
|
+
error: zod_1.z.string(),
|
|
9
|
+
details: zod_1.z.record(zod_1.z.string()).optional(),
|
|
10
|
+
});
|
|
11
|
+
exports.commonAPIResponses = {
|
|
12
|
+
400: exports.common400ResponseSchema,
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common_responses.js"), exports);
|
|
18
|
+
__exportStar(require("./base_repository.js"), exports);
|