@temboplus/afloat 0.1.77-beta.9 → 0.1.79
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 +42 -246
- package/esm/mod.d.ts +8 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +7 -0
- package/esm/package.json +3 -0
- package/{dist/lib/error/error.api.d.ts → esm/src/errors/api_error.d.ts} +1 -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/{dist/lib/error/error.permission.d.ts → esm/src/errors/permission_error.d.ts} +2 -1
- package/esm/src/errors/permission_error.d.ts.map +1 -0
- package/esm/src/errors/permission_error.js +70 -0
- package/{dist/modules/team-member/team-member.contract.d.ts → esm/src/features/admin/contract.d.ts} +158 -233
- package/esm/src/features/admin/contract.d.ts.map +1 -0
- package/esm/src/features/admin/contract.js +210 -0
- package/esm/src/features/admin/index.d.ts +4 -0
- package/esm/src/features/admin/index.d.ts.map +1 -0
- package/esm/src/features/admin/index.js +3 -0
- package/esm/src/features/admin/repository.d.ts +114 -0
- package/esm/src/features/admin/repository.d.ts.map +1 -0
- package/esm/src/features/admin/repository.js +248 -0
- package/esm/src/features/admin/schemas.d.ts +146 -0
- package/esm/src/features/admin/schemas.d.ts.map +1 -0
- package/esm/src/features/admin/schemas.js +206 -0
- package/esm/src/features/auth/access/contract.d.ts +14 -0
- package/esm/src/features/auth/access/contract.d.ts.map +1 -0
- package/esm/src/features/auth/access/contract.js +14 -0
- package/esm/src/features/auth/access/repository.d.ts +11 -0
- package/esm/src/features/auth/access/repository.d.ts.map +1 -0
- package/esm/src/features/auth/access/repository.js +25 -0
- package/{dist/modules/auth/auth.contract.d.ts → esm/src/features/auth/contract.d.ts} +19 -16
- package/esm/src/features/auth/contract.d.ts.map +1 -0
- package/esm/src/features/auth/contract.js +43 -0
- package/esm/src/features/auth/identity/contract.d.ts +23 -0
- package/esm/src/features/auth/identity/contract.d.ts.map +1 -0
- package/esm/src/features/auth/identity/contract.js +17 -0
- package/esm/src/features/auth/identity/repository.d.ts +22 -0
- package/esm/src/features/auth/identity/repository.d.ts.map +1 -0
- package/esm/src/features/auth/identity/repository.js +30 -0
- package/esm/src/features/auth/index.d.ts +6 -0
- package/esm/src/features/auth/index.d.ts.map +1 -0
- package/esm/src/features/auth/index.js +5 -0
- package/esm/src/features/auth/manager.d.ts +105 -0
- package/esm/src/features/auth/manager.d.ts.map +1 -0
- package/esm/src/features/auth/manager.js +181 -0
- package/{dist/modules/profile/profile.api-contract.d.ts → esm/src/features/auth/profile/contract.d.ts} +6 -8
- package/esm/src/features/auth/profile/contract.d.ts.map +1 -0
- package/esm/src/features/auth/profile/contract.js +14 -0
- package/esm/src/features/auth/profile/repository.d.ts +11 -0
- package/esm/src/features/auth/profile/repository.d.ts.map +1 -0
- package/esm/src/features/auth/profile/repository.js +25 -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 +69 -0
- package/{dist/modules/auth/storage/client-store.d.ts → esm/src/features/auth/storage/client_store.d.ts} +2 -1
- package/esm/src/features/auth/storage/client_store.d.ts.map +1 -0
- package/esm/src/features/auth/storage/client_store.js +46 -0
- package/{dist/modules/auth/storage/client-token-handler.d.ts → esm/src/features/auth/storage/client_token_handler.d.ts} +1 -0
- package/esm/src/features/auth/storage/client_token_handler.d.ts.map +1 -0
- package/esm/src/features/auth/storage/client_token_handler.js +36 -0
- package/esm/src/features/auth/storage/server_store.d.ts +24 -0
- package/esm/src/features/auth/storage/server_store.d.ts.map +1 -0
- package/esm/src/features/auth/storage/server_store.js +34 -0
- package/esm/src/features/auth/storage/server_token_handler.d.ts +36 -0
- package/esm/src/features/auth/storage/server_token_handler.d.ts.map +1 -0
- package/esm/src/features/auth/storage/server_token_handler.js +115 -0
- package/{dist/modules → esm/src/features}/auth/storage/types.d.ts +2 -1
- package/esm/src/features/auth/storage/types.d.ts.map +1 -0
- package/esm/src/features/auth/storage/types.js +1 -0
- package/{dist/modules/contact/contact.api-contract.d.ts → esm/src/features/contact/contract.d.ts} +55 -88
- 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 +58 -0
- package/esm/src/features/contact/repository.d.ts.map +1 -0
- package/esm/src/features/contact/repository.js +108 -0
- package/{dist/modules/payout/payout.api-contract.d.ts → esm/src/features/payout/contract.d.ts} +197 -340
- 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 +67 -0
- package/esm/src/features/payout/repository.d.ts.map +1 -0
- package/esm/src/features/payout/repository.js +163 -0
- package/{dist/modules/wallet/wallet.contract.d.ts → esm/src/features/wallet/contract.d.ts} +11 -13
- package/esm/src/features/wallet/contract.d.ts.map +1 -0
- package/esm/src/features/wallet/contract.js +38 -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 +57 -0
- package/esm/src/features/wallet/repository.d.ts.map +1 -0
- package/esm/src/features/wallet/repository.js +93 -0
- package/esm/src/models/contact/derivatives/contact.d.ts +172 -0
- package/esm/src/models/contact/derivatives/contact.d.ts.map +1 -0
- package/esm/src/models/contact/derivatives/contact.js +266 -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/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 +146 -0
- package/esm/src/models/index.d.ts +7 -0
- package/esm/src/models/index.d.ts.map +1 -0
- package/esm/src/models/index.js +6 -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 +53 -0
- package/esm/src/models/payout/derivatives/payout.d.ts +158 -0
- package/esm/src/models/payout/derivatives/payout.d.ts.map +1 -0
- package/esm/src/models/payout/derivatives/payout.js +271 -0
- package/esm/src/models/payout/index.d.ts +7 -0
- package/esm/src/models/payout/index.d.ts.map +1 -0
- package/esm/src/models/payout/index.js +6 -0
- package/esm/src/models/payout/narration.d.ts +164 -0
- package/esm/src/models/payout/narration.d.ts.map +1 -0
- package/esm/src/models/payout/narration.js +308 -0
- package/esm/src/models/payout/schemas.d.ts +156 -0
- package/esm/src/models/payout/schemas.d.ts.map +1 -0
- package/esm/src/models/payout/schemas.js +105 -0
- package/esm/src/models/payout/status.d.ts +33 -0
- package/esm/src/models/payout/status.d.ts.map +1 -0
- package/esm/src/models/payout/status.js +34 -0
- package/{dist/modules/login/permission.type.d.ts → esm/src/models/permission.d.ts} +9 -8
- package/esm/src/models/permission.d.ts.map +1 -0
- package/esm/src/models/permission.js +50 -0
- package/esm/src/models/role.d.ts +21 -0
- package/esm/src/models/role.d.ts.map +1 -0
- package/esm/src/models/role.js +73 -0
- package/esm/src/models/user/authenticated-user.d.ts +77 -0
- package/esm/src/models/user/authenticated-user.d.ts.map +1 -0
- package/esm/src/models/user/authenticated-user.js +226 -0
- package/esm/src/models/user/index.d.ts +4 -0
- package/esm/src/models/user/index.d.ts.map +1 -0
- package/esm/src/models/user/index.js +3 -0
- package/esm/src/models/user/managed-user.d.ts +108 -0
- package/esm/src/models/user/managed-user.d.ts.map +1 -0
- package/esm/src/models/user/managed-user.js +255 -0
- package/{dist/modules/profile/profile.model.d.ts → esm/src/models/user/profile.d.ts} +52 -81
- package/esm/src/models/user/profile.d.ts.map +1 -0
- package/esm/src/models/user/profile.js +334 -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 +95 -0
- package/esm/src/models/wallet/schemas.d.ts.map +1 -0
- package/esm/src/models/wallet/schemas.js +35 -0
- package/esm/src/models/wallet/statement_entry.d.ts +160 -0
- package/esm/src/models/wallet/statement_entry.d.ts.map +1 -0
- package/esm/src/models/wallet/statement_entry.js +255 -0
- package/{dist/modules/wallet/wallet.model.d.ts → esm/src/models/wallet/wallet.d.ts} +37 -31
- package/esm/src/models/wallet/wallet.d.ts.map +1 -0
- package/esm/src/models/wallet/wallet.js +279 -0
- package/esm/src/shared/base_repository.d.ts +80 -0
- package/esm/src/shared/base_repository.d.ts.map +1 -0
- package/esm/src/shared/base_repository.js +153 -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/esm/src/shared/token_required_repository.d.ts +78 -0
- package/esm/src/shared/token_required_repository.d.ts.map +1 -0
- package/esm/src/shared/token_required_repository.js +128 -0
- package/package.json +23 -49
- package/script/mod.d.ts +8 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +23 -0
- package/script/npm/src/mod.d.ts +8 -0
- package/script/npm/src/mod.d.ts.map +1 -0
- package/script/npm/src/mod.js +23 -0
- package/script/npm/src/src/errors/api_error.d.ts +63 -0
- package/script/npm/src/src/errors/api_error.d.ts.map +1 -0
- package/script/npm/src/src/errors/api_error.js +94 -0
- package/script/npm/src/src/errors/index.d.ts +3 -0
- package/script/npm/src/src/errors/index.d.ts.map +1 -0
- package/script/npm/src/src/errors/index.js +18 -0
- package/script/npm/src/src/errors/permission_error.d.ts +48 -0
- package/script/npm/src/src/errors/permission_error.d.ts.map +1 -0
- package/script/npm/src/src/errors/permission_error.js +74 -0
- package/script/npm/src/src/features/admin/contract.d.ts +842 -0
- package/script/npm/src/src/features/admin/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/admin/contract.js +213 -0
- package/script/npm/src/src/features/admin/index.d.ts +4 -0
- package/script/npm/src/src/features/admin/index.d.ts.map +1 -0
- package/script/npm/src/src/features/admin/index.js +19 -0
- package/script/npm/src/src/features/admin/repository.d.ts +114 -0
- package/script/npm/src/src/features/admin/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/admin/repository.js +252 -0
- package/script/npm/src/src/features/admin/schemas.d.ts +146 -0
- package/script/npm/src/src/features/admin/schemas.d.ts.map +1 -0
- package/script/npm/src/src/features/admin/schemas.js +209 -0
- package/script/npm/src/src/features/auth/access/contract.d.ts +14 -0
- package/script/npm/src/src/features/auth/access/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/access/contract.js +17 -0
- package/script/npm/src/src/features/auth/access/repository.d.ts +11 -0
- package/script/npm/src/src/features/auth/access/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/access/repository.js +29 -0
- package/script/npm/src/src/features/auth/contract.d.ts +112 -0
- package/script/npm/src/src/features/auth/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/contract.js +46 -0
- package/script/npm/src/src/features/auth/identity/contract.d.ts +23 -0
- package/script/npm/src/src/features/auth/identity/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/identity/contract.js +20 -0
- package/script/npm/src/src/features/auth/identity/repository.d.ts +22 -0
- package/script/npm/src/src/features/auth/identity/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/identity/repository.js +34 -0
- package/script/npm/src/src/features/auth/index.d.ts +6 -0
- package/script/npm/src/src/features/auth/index.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/index.js +21 -0
- package/script/npm/src/src/features/auth/manager.d.ts +105 -0
- package/script/npm/src/src/features/auth/manager.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/manager.js +185 -0
- package/script/npm/src/src/features/auth/profile/contract.d.ts +37 -0
- package/script/npm/src/src/features/auth/profile/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/profile/contract.js +17 -0
- package/script/npm/src/src/features/auth/profile/repository.d.ts +11 -0
- package/script/npm/src/src/features/auth/profile/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/profile/repository.js +29 -0
- package/script/npm/src/src/features/auth/repository.d.ts +30 -0
- package/script/npm/src/src/features/auth/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/repository.js +73 -0
- package/script/npm/src/src/features/auth/storage/client_store.d.ts +30 -0
- package/script/npm/src/src/features/auth/storage/client_store.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/storage/client_store.js +51 -0
- package/script/npm/src/src/features/auth/storage/client_token_handler.d.ts +32 -0
- package/script/npm/src/src/features/auth/storage/client_token_handler.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/storage/client_token_handler.js +40 -0
- package/script/npm/src/src/features/auth/storage/server_store.d.ts +24 -0
- package/script/npm/src/src/features/auth/storage/server_store.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/storage/server_store.js +38 -0
- package/script/npm/src/src/features/auth/storage/server_token_handler.d.ts +36 -0
- package/script/npm/src/src/features/auth/storage/server_token_handler.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/storage/server_token_handler.js +119 -0
- package/script/npm/src/src/features/auth/storage/types.d.ts +42 -0
- package/script/npm/src/src/features/auth/storage/types.d.ts.map +1 -0
- package/script/npm/src/src/features/auth/storage/types.js +2 -0
- package/script/npm/src/src/features/contact/contract.d.ts +170 -0
- package/script/npm/src/src/features/contact/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/contact/contract.js +52 -0
- package/script/npm/src/src/features/contact/index.d.ts +2 -0
- package/script/npm/src/src/features/contact/index.d.ts.map +1 -0
- package/script/npm/src/src/features/contact/index.js +17 -0
- package/script/npm/src/src/features/contact/repository.d.ts +58 -0
- package/script/npm/src/src/features/contact/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/contact/repository.js +112 -0
- package/script/npm/src/src/features/payout/contract.d.ts +623 -0
- package/script/npm/src/src/features/payout/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/payout/contract.js +78 -0
- package/script/npm/src/src/features/payout/index.d.ts +2 -0
- package/script/npm/src/src/features/payout/index.d.ts.map +1 -0
- package/script/npm/src/src/features/payout/index.js +17 -0
- package/script/npm/src/src/features/payout/repository.d.ts +67 -0
- package/script/npm/src/src/features/payout/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/payout/repository.js +167 -0
- package/script/npm/src/src/features/wallet/contract.d.ts +137 -0
- package/script/npm/src/src/features/wallet/contract.d.ts.map +1 -0
- package/script/npm/src/src/features/wallet/contract.js +41 -0
- package/script/npm/src/src/features/wallet/index.d.ts +2 -0
- package/script/npm/src/src/features/wallet/index.d.ts.map +1 -0
- package/script/npm/src/src/features/wallet/index.js +17 -0
- package/script/npm/src/src/features/wallet/repository.d.ts +57 -0
- package/script/npm/src/src/features/wallet/repository.d.ts.map +1 -0
- package/script/npm/src/src/features/wallet/repository.js +97 -0
- package/script/npm/src/src/models/contact/derivatives/contact.d.ts +172 -0
- package/script/npm/src/src/models/contact/derivatives/contact.d.ts.map +1 -0
- package/script/npm/src/src/models/contact/derivatives/contact.js +270 -0
- package/script/npm/src/src/models/contact/derivatives/contact_info.d.ts +188 -0
- package/script/npm/src/src/models/contact/derivatives/contact_info.d.ts.map +1 -0
- package/script/npm/src/src/models/contact/derivatives/contact_info.js +260 -0
- package/script/npm/src/src/models/contact/index.d.ts +5 -0
- package/script/npm/src/src/models/contact/index.d.ts.map +1 -0
- package/script/npm/src/src/models/contact/index.js +20 -0
- package/script/npm/src/src/models/contact/schemas.d.ts +66 -0
- package/script/npm/src/src/models/contact/schemas.d.ts.map +1 -0
- package/script/npm/src/src/models/contact/schemas.js +67 -0
- package/script/npm/src/src/models/contact/validation.d.ts +37 -0
- package/script/npm/src/src/models/contact/validation.d.ts.map +1 -0
- package/script/npm/src/src/models/contact/validation.js +153 -0
- package/script/npm/src/src/models/index.d.ts +7 -0
- package/script/npm/src/src/models/index.d.ts.map +1 -0
- package/script/npm/src/src/models/index.js +22 -0
- package/script/npm/src/src/models/payout/api.d.ts +29 -0
- package/script/npm/src/src/models/payout/api.d.ts.map +1 -0
- package/script/npm/src/src/models/payout/api.js +2 -0
- package/script/npm/src/src/models/payout/channel.d.ts +58 -0
- package/script/npm/src/src/models/payout/channel.d.ts.map +1 -0
- package/script/npm/src/src/models/payout/channel.js +56 -0
- package/script/npm/src/src/models/payout/derivatives/payout.d.ts +158 -0
- package/script/npm/src/src/models/payout/derivatives/payout.d.ts.map +1 -0
- package/script/npm/src/src/models/payout/derivatives/payout.js +275 -0
- package/script/npm/src/src/models/payout/index.d.ts +7 -0
- package/script/npm/src/src/models/payout/index.d.ts.map +1 -0
- package/script/npm/src/src/models/payout/index.js +22 -0
- package/script/npm/src/src/models/payout/narration.d.ts +164 -0
- package/script/npm/src/src/models/payout/narration.d.ts.map +1 -0
- package/script/npm/src/src/models/payout/narration.js +312 -0
- package/script/npm/src/src/models/payout/schemas.d.ts +156 -0
- package/script/npm/src/src/models/payout/schemas.d.ts.map +1 -0
- package/script/npm/src/src/models/payout/schemas.js +108 -0
- package/script/npm/src/src/models/payout/status.d.ts +33 -0
- package/script/npm/src/src/models/payout/status.d.ts.map +1 -0
- package/script/npm/src/src/models/payout/status.js +37 -0
- package/script/npm/src/src/models/permission.d.ts +55 -0
- package/script/npm/src/src/models/permission.d.ts.map +1 -0
- package/script/npm/src/src/models/permission.js +53 -0
- package/script/npm/src/src/models/role.d.ts +21 -0
- package/script/npm/src/src/models/role.d.ts.map +1 -0
- package/script/npm/src/src/models/role.js +77 -0
- package/script/npm/src/src/models/user/authenticated-user.d.ts +77 -0
- package/script/npm/src/src/models/user/authenticated-user.d.ts.map +1 -0
- package/script/npm/src/src/models/user/authenticated-user.js +230 -0
- package/script/npm/src/src/models/user/index.d.ts +4 -0
- package/script/npm/src/src/models/user/index.d.ts.map +1 -0
- package/script/npm/src/src/models/user/index.js +19 -0
- package/script/npm/src/src/models/user/managed-user.d.ts +108 -0
- package/script/npm/src/src/models/user/managed-user.d.ts.map +1 -0
- package/script/npm/src/src/models/user/managed-user.js +260 -0
- package/script/npm/src/src/models/user/profile.d.ts +161 -0
- package/script/npm/src/src/models/user/profile.d.ts.map +1 -0
- package/script/npm/src/src/models/user/profile.js +338 -0
- package/script/npm/src/src/models/wallet/index.d.ts +4 -0
- package/script/npm/src/src/models/wallet/index.d.ts.map +1 -0
- package/script/npm/src/src/models/wallet/index.js +19 -0
- package/script/npm/src/src/models/wallet/schemas.d.ts +95 -0
- package/script/npm/src/src/models/wallet/schemas.d.ts.map +1 -0
- package/script/npm/src/src/models/wallet/schemas.js +38 -0
- package/script/npm/src/src/models/wallet/statement_entry.d.ts +160 -0
- package/script/npm/src/src/models/wallet/statement_entry.d.ts.map +1 -0
- package/script/npm/src/src/models/wallet/statement_entry.js +259 -0
- package/script/npm/src/src/models/wallet/wallet.d.ts +147 -0
- package/script/npm/src/src/models/wallet/wallet.d.ts.map +1 -0
- package/script/npm/src/src/models/wallet/wallet.js +283 -0
- package/script/npm/src/src/shared/base_repository.d.ts +80 -0
- package/script/npm/src/src/shared/base_repository.d.ts.map +1 -0
- package/script/npm/src/src/shared/base_repository.js +157 -0
- package/script/npm/src/src/shared/common_responses.d.ts +13 -0
- package/script/npm/src/src/shared/common_responses.d.ts.map +1 -0
- package/script/npm/src/src/shared/common_responses.js +13 -0
- package/script/npm/src/src/shared/index.d.ts +3 -0
- package/script/npm/src/src/shared/index.d.ts.map +1 -0
- package/script/npm/src/src/shared/index.js +18 -0
- package/script/npm/src/src/shared/token_required_repository.d.ts +78 -0
- package/script/npm/src/src/shared/token_required_repository.d.ts.map +1 -0
- package/script/npm/src/src/shared/token_required_repository.js +132 -0
- package/script/package.json +3 -0
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/lib/api/base-repository.d.ts +0 -175
- package/dist/lib/api/index.d.ts +0 -1
- package/dist/lib/error/error.utils.d.ts +0 -22
- package/dist/lib/error/index.d.ts +0 -3
- package/dist/lib/query/index.d.ts +0 -4
- package/dist/lib/query/pagination/pagination.d.ts +0 -73
- package/dist/lib/query/pagination/pagination.schemas.d.ts +0 -83
- package/dist/lib/query/query.builder.d.ts +0 -71
- package/dist/lib/query/query.types.d.ts +0 -36
- package/dist/modules/auth/auth.manager.d.ts +0 -249
- package/dist/modules/auth/auth.repository.d.ts +0 -83
- package/dist/modules/auth/auth.store.d.ts +0 -139
- package/dist/modules/auth/company-membership.model.d.ts +0 -171
- package/dist/modules/auth/index.d.ts +0 -4
- package/dist/modules/auth/user.model.d.ts +0 -363
- package/dist/modules/contact/contact-info.model.d.ts +0 -485
- package/dist/modules/contact/contact-input-handler.d.ts +0 -16
- package/dist/modules/contact/contact.dtos.d.ts +0 -84
- package/dist/modules/contact/contact.model.d.ts +0 -441
- package/dist/modules/contact/contact.repository.d.ts +0 -116
- package/dist/modules/contact/index.d.ts +0 -4
- package/dist/modules/login/index.d.ts +0 -4
- package/dist/modules/login/login.api-contract.d.ts +0 -51
- package/dist/modules/login/login.dtos.d.ts +0 -85
- package/dist/modules/login/login.model.d.ts +0 -168
- package/dist/modules/login/login.repository.d.ts +0 -58
- package/dist/modules/payout/index.d.ts +0 -5
- package/dist/modules/payout/payout-channel-handler.d.ts +0 -82
- package/dist/modules/payout/payout.dtos.d.ts +0 -605
- package/dist/modules/payout/payout.model.d.ts +0 -379
- package/dist/modules/payout/payout.query.d.ts +0 -133
- package/dist/modules/payout/payout.repository.d.ts +0 -181
- package/dist/modules/profile/index.d.ts +0 -3
- package/dist/modules/profile/profile.dtos.d.ts +0 -80
- package/dist/modules/profile/profile.repository.d.ts +0 -56
- package/dist/modules/team-member/index.d.ts +0 -4
- package/dist/modules/team-member/role.model.d.ts +0 -61
- package/dist/modules/team-member/team-member.dtos.d.ts +0 -261
- package/dist/modules/team-member/team-member.model.d.ts +0 -237
- package/dist/modules/team-member/team-member.repository.d.ts +0 -179
- package/dist/modules/wallet/index.d.ts +0 -7
- package/dist/modules/wallet/narration.model.d.ts +0 -225
- package/dist/modules/wallet/statement-entry.model.d.ts +0 -299
- package/dist/modules/wallet/wallet-manager.session.d.ts +0 -143
- package/dist/modules/wallet/wallet.dtos.d.ts +0 -204
- package/dist/modules/wallet/wallet.query.d.ts +0 -95
- package/dist/modules/wallet/wallet.repository.d.ts +0 -205
- package/dist/modules/wallet/wallet.utils.d.ts +0 -17
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WalletRepo = void 0;
|
|
4
|
+
const base_repository_js_1 = require("../../shared/base_repository.js");
|
|
5
|
+
const contract_js_1 = require("./contract.js");
|
|
6
|
+
const index_js_1 = require("../../models/wallet/index.js");
|
|
7
|
+
const permission_js_1 = require("../../models/permission.js");
|
|
8
|
+
const index_js_2 = require("../../errors/index.js");
|
|
9
|
+
/**
|
|
10
|
+
* Repository class for managing wallet operations including balance checking,
|
|
11
|
+
* statement generation, and wallet information retrieval.
|
|
12
|
+
* @extends {BaseRepository<typeof contract>}
|
|
13
|
+
*/
|
|
14
|
+
class WalletRepo extends base_repository_js_1.BaseRepository {
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of WalletRepo initialized with the wallet contract.
|
|
17
|
+
* @param {Object} [options] - Optional configuration
|
|
18
|
+
* @param {string} [options.root] - Custom API root URL
|
|
19
|
+
* @param {AfloatAuth} [options.auth] - Auth instance to use
|
|
20
|
+
*/
|
|
21
|
+
constructor(props) {
|
|
22
|
+
super("wallet", contract_js_1.contract, {
|
|
23
|
+
root: props?.root,
|
|
24
|
+
auth: props?.auth,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the current available balance for the wallet.
|
|
29
|
+
* @throws {PermissionError} If user lacks the ViewBalance permission
|
|
30
|
+
* @throws {Error} If the balance fetch operation fails
|
|
31
|
+
* @returns {Promise<number>} The available balance amount
|
|
32
|
+
*/
|
|
33
|
+
async getBalance(props) {
|
|
34
|
+
const auth = this.getAuthForPermissionCheck();
|
|
35
|
+
const requirePerm = permission_js_1.Permissions.Wallet.ViewBalance;
|
|
36
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
37
|
+
throw new index_js_2.PermissionError({
|
|
38
|
+
message: "You are not authorized to view the account balance.",
|
|
39
|
+
requiredPermissions: [requirePerm],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const result = await this.client.getBalance({
|
|
43
|
+
body: { accountNo: props.accountNo },
|
|
44
|
+
});
|
|
45
|
+
if (result.status === 201) {
|
|
46
|
+
return result.body.availableBalance;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("An error occured while fetching balance");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves all wallets associated with the current context.
|
|
52
|
+
* @throws {Error} If the wallet fetch operation fails
|
|
53
|
+
* @returns {Promise<Wallet[]>} Array of wallet objects
|
|
54
|
+
*/
|
|
55
|
+
async getWallets(args) {
|
|
56
|
+
const result = await this.client.getWallets({ query: args });
|
|
57
|
+
if (result.status === 200) {
|
|
58
|
+
return result.body.map((w) => index_js_1.Wallet.from(w));
|
|
59
|
+
}
|
|
60
|
+
throw new Error("An error occured while fetching wallets");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves wallet statement items for a specified date range and account.
|
|
64
|
+
* If no range is provided, defaults to the current month (1st to 30th).
|
|
65
|
+
* @param {Object} props - The statement request properties
|
|
66
|
+
* @param {Object} [props.range] - Optional date range for the statement
|
|
67
|
+
* @param {Date} props.range.startDate - Start date for the statement period
|
|
68
|
+
* @param {Date} props.range.endDate - End date for the statement period
|
|
69
|
+
* @param {string} [props.accountNo] - Optional account number to fetch statement for
|
|
70
|
+
* @throws {PermissionError} If user lacks the ViewStatement permission
|
|
71
|
+
* @throws {Error} If the statement fetch operation fails
|
|
72
|
+
* @returns {Promise<WalletStatementEntry[]>} Array of statement items for the specified period
|
|
73
|
+
*/
|
|
74
|
+
async getStatement(props) {
|
|
75
|
+
const auth = this.getAuthForPermissionCheck();
|
|
76
|
+
const requirePerm = permission_js_1.Permissions.Wallet.ViewStatement;
|
|
77
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
78
|
+
throw new index_js_2.PermissionError({
|
|
79
|
+
message: "You are not authorized to view the statement.",
|
|
80
|
+
requiredPermissions: [requirePerm],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const now = new Date();
|
|
84
|
+
const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
85
|
+
const monthEnd = new Date(now.getFullYear(), now.getMonth(), 30);
|
|
86
|
+
const range = props.range !== undefined
|
|
87
|
+
? { startDate: props.range.startDate, endDate: props.range.endDate }
|
|
88
|
+
: { startDate: monthStart, endDate: monthEnd };
|
|
89
|
+
const body = { ...range, accountNo: props.accountNo };
|
|
90
|
+
const result = await this.client.getStatement({ body });
|
|
91
|
+
if (result.status === 201) {
|
|
92
|
+
return result.body.map((e) => index_js_1.WalletStatementEntry.from(e));
|
|
93
|
+
}
|
|
94
|
+
throw new Error("An error occured while fetching statement");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.WalletRepo = WalletRepo;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type ContactData, type ContactType } from "../schemas.js";
|
|
2
|
+
import { type ContactInfo } from "./contact_info.js";
|
|
3
|
+
/**
|
|
4
|
+
* Contact class that wraps the Zod schema and provides additional functionality
|
|
5
|
+
*/
|
|
6
|
+
export declare class Contact {
|
|
7
|
+
private readonly data;
|
|
8
|
+
/**
|
|
9
|
+
* Private constructor - use static methods to create instances
|
|
10
|
+
*/
|
|
11
|
+
private constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier for the contact
|
|
14
|
+
*/
|
|
15
|
+
get id(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Profile identifier associated with this contact
|
|
18
|
+
*/
|
|
19
|
+
get profileId(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Display name of the contact
|
|
22
|
+
*/
|
|
23
|
+
get displayName(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Type of contact (Bank or Mobile)
|
|
26
|
+
*/
|
|
27
|
+
get type(): ContactType;
|
|
28
|
+
/**
|
|
29
|
+
* Creation timestamp of the contact
|
|
30
|
+
*/
|
|
31
|
+
get createdAt(): Date;
|
|
32
|
+
/**
|
|
33
|
+
* Update timestamp of the contact
|
|
34
|
+
*/
|
|
35
|
+
get updatedAt(): Date;
|
|
36
|
+
/**
|
|
37
|
+
* Detailed contact information based on contact type
|
|
38
|
+
*
|
|
39
|
+
* @returns {ContactInfo | undefined} Contact information object:
|
|
40
|
+
* - MobileContactInfo for mobile money contacts
|
|
41
|
+
* - BankContactInfo for bank contacts
|
|
42
|
+
* - undefined if contact information cannot be constructed
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* For mobile contacts, constructs from phone number
|
|
46
|
+
* For bank contacts, constructs from SWIFT code and account number
|
|
47
|
+
*/
|
|
48
|
+
get info(): ContactInfo | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Payment channel for the contact
|
|
51
|
+
*
|
|
52
|
+
* @returns {string} Channel information:
|
|
53
|
+
* - For valid contacts, returns formatted channel from ContactInfo
|
|
54
|
+
* - For invalid contacts, falls back to account number
|
|
55
|
+
*/
|
|
56
|
+
get channel(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Account number for the contact
|
|
59
|
+
*
|
|
60
|
+
* @returns {string} Account number:
|
|
61
|
+
* - For valid contacts, returns formatted account number from ContactInfo
|
|
62
|
+
* - For invalid contacts, falls back to raw account number
|
|
63
|
+
*/
|
|
64
|
+
get accNo(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Account name for the contact
|
|
67
|
+
* Always returns the display name
|
|
68
|
+
*/
|
|
69
|
+
get accName(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Label for the account number field based on contact type
|
|
72
|
+
*
|
|
73
|
+
* @returns {string} Appropriate label:
|
|
74
|
+
* - "Phone Number" for mobile contacts
|
|
75
|
+
* - "Bank Account Number" for bank contacts
|
|
76
|
+
* - "Account Number" as fallback
|
|
77
|
+
*/
|
|
78
|
+
get accNoLabel(): string;
|
|
79
|
+
/**
|
|
80
|
+
* Label for the channel field based on contact type
|
|
81
|
+
*
|
|
82
|
+
* @returns {string} Appropriate label:
|
|
83
|
+
* - "Channel" for mobile contacts
|
|
84
|
+
* - "Bank" for bank contacts
|
|
85
|
+
* - "Channel" as fallback
|
|
86
|
+
*/
|
|
87
|
+
get channelLabel(): string;
|
|
88
|
+
/**
|
|
89
|
+
* Label for the account name field based on contact type
|
|
90
|
+
*
|
|
91
|
+
* @returns {string} Appropriate label:
|
|
92
|
+
* - "Full Name" for mobile contacts
|
|
93
|
+
* - "Bank Account Name" for bank contacts
|
|
94
|
+
* - "Display Name" as fallback
|
|
95
|
+
*/
|
|
96
|
+
get accNameLabel(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Creates a Contact instance from raw data
|
|
99
|
+
* @throws {ZodError} if validation fails
|
|
100
|
+
*/
|
|
101
|
+
static create(data: ContactData): Contact;
|
|
102
|
+
/**
|
|
103
|
+
* Creates multiple Contact instances from an array of raw data
|
|
104
|
+
* @throws {ZodError} if validation fails for any item
|
|
105
|
+
*/
|
|
106
|
+
static createMany(dataArray: ContactData[]): Contact[];
|
|
107
|
+
/**
|
|
108
|
+
* Creates a Contact instance from raw data without throwing
|
|
109
|
+
* @returns {Contact | null} Contact instance or null if validation fails
|
|
110
|
+
*/
|
|
111
|
+
static createSafe(data: ContactData): Contact | null;
|
|
112
|
+
/**
|
|
113
|
+
* Checks if an unknown value contains valid data to construct a Contact instance.
|
|
114
|
+
* This is useful when validating raw data structures before instantiation.
|
|
115
|
+
*
|
|
116
|
+
* @param {unknown} obj - The value containing potential contact data
|
|
117
|
+
* @returns {obj is Contact} Type predicate indicating if a Contact can be constructed
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const rawData = await fetchFromAPI();
|
|
122
|
+
* if (Contact.canConstruct(rawData)) {
|
|
123
|
+
* const contact = Contact.create(rawData);
|
|
124
|
+
* // TypeScript knows contact is valid here
|
|
125
|
+
* console.log(contact.displayName);
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @throws {never} This method never throws errors
|
|
130
|
+
*
|
|
131
|
+
* @remarks
|
|
132
|
+
* This method performs strict validation against the {@link ContactData} schema.
|
|
133
|
+
*/
|
|
134
|
+
static canConstruct(obj: unknown): obj is Contact;
|
|
135
|
+
/**
|
|
136
|
+
* Validates if an unknown value is a Contact instance.
|
|
137
|
+
* This is a runtime type guard that ensures proper object structure and data validity.
|
|
138
|
+
*
|
|
139
|
+
* @param {unknown} obj - The value to validate
|
|
140
|
+
* @returns {obj is Contact} Type predicate indicating if the value is a valid Contact
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const maybeContact = getContactFromCache();
|
|
145
|
+
* if (Contact.is(maybeContact)) {
|
|
146
|
+
* // TypeScript knows maybeContact is a Contact here
|
|
147
|
+
* console.log(maybeContact.displayName);
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @throws {never} This method never throws errors
|
|
152
|
+
*
|
|
153
|
+
* @remarks
|
|
154
|
+
* This method performs a complete structural validation:
|
|
155
|
+
* 1. Checks if the value is an object
|
|
156
|
+
* 2. Verifies presence of internal data property
|
|
157
|
+
* 3. Validates the data against ContactData schema
|
|
158
|
+
* 4. Ensures the object is a proper Contact instance
|
|
159
|
+
*
|
|
160
|
+
* Use this method when:
|
|
161
|
+
* - Validating cached Contact instances
|
|
162
|
+
* - Checking serialized Contact objects
|
|
163
|
+
* - Verifying API responses
|
|
164
|
+
* - Type narrowing in conditional blocks
|
|
165
|
+
*/
|
|
166
|
+
static is(obj: unknown): obj is Contact;
|
|
167
|
+
/**
|
|
168
|
+
* Converts Payout instance to a plain object
|
|
169
|
+
*/
|
|
170
|
+
toJSON(): ContactData;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=contact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../../../../../../src/src/models/contact/derivatives/contact.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IAEnC;;OAEG;IACH,OAAO;IAIP;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAEf;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,IAAI,CAEpB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,IAAI,CAEpB;IAED;;;;;;;;;;;OAWG;IACH,IAAI,IAAI,IAAI,WAAW,GAAG,SAAS,CAoBlC;IAED;;;;;;OAMG;IACH,IAAI,OAAO,IAAI,MAAM,CAIpB;IAED;;;;;;OAMG;IACH,IAAI,KAAK,IAAI,MAAM,CAIlB;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;;;;;OAOG;IACH,IAAI,UAAU,IAAI,MAAM,CAKvB;IAED;;;;;;;OAOG;IACH,IAAI,YAAY,IAAI,MAAM,CAKzB;IAED;;;;;;;OAOG;IACH,IAAI,YAAY,IAAI,MAAM,CAKzB;IAED;;;OAGG;WACW,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;IAIhD;;;OAGG;WACW,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE;IAI7D;;;OAGG;WACW,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,IAAI;IAQ3D;;;;;;;;;;;;;;;;;;;;;OAqBG;WACW,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO;IAUxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACW,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO;IAO9C;;OAEG;IACH,MAAM,IAAI,WAAW;CAGtB"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Contact = void 0;
|
|
4
|
+
const schemas_js_1 = require("../schemas.js");
|
|
5
|
+
const index_js_1 = require("../index.js");
|
|
6
|
+
const frontend_core_1 = require("@temboplus/frontend-core");
|
|
7
|
+
const contact_info_js_1 = require("./contact_info.js");
|
|
8
|
+
/**
|
|
9
|
+
* Contact class that wraps the Zod schema and provides additional functionality
|
|
10
|
+
*/
|
|
11
|
+
class Contact {
|
|
12
|
+
/**
|
|
13
|
+
* Private constructor - use static methods to create instances
|
|
14
|
+
*/
|
|
15
|
+
constructor(data) {
|
|
16
|
+
Object.defineProperty(this, "data", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
this.data = schemas_js_1.ContactSchemas.contactData.parse(data);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Unique identifier for the contact
|
|
26
|
+
*/
|
|
27
|
+
get id() {
|
|
28
|
+
return this.data.id;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Profile identifier associated with this contact
|
|
32
|
+
*/
|
|
33
|
+
get profileId() {
|
|
34
|
+
return this.data.profileId;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Display name of the contact
|
|
38
|
+
*/
|
|
39
|
+
get displayName() {
|
|
40
|
+
return this.data.displayName;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Type of contact (Bank or Mobile)
|
|
44
|
+
*/
|
|
45
|
+
get type() {
|
|
46
|
+
return this.data.type;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creation timestamp of the contact
|
|
50
|
+
*/
|
|
51
|
+
get createdAt() {
|
|
52
|
+
return this.data.createdAt;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Update timestamp of the contact
|
|
56
|
+
*/
|
|
57
|
+
get updatedAt() {
|
|
58
|
+
return this.data.updatedAt;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Detailed contact information based on contact type
|
|
62
|
+
*
|
|
63
|
+
* @returns {ContactInfo | undefined} Contact information object:
|
|
64
|
+
* - MobileContactInfo for mobile money contacts
|
|
65
|
+
* - BankContactInfo for bank contacts
|
|
66
|
+
* - undefined if contact information cannot be constructed
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* For mobile contacts, constructs from phone number
|
|
70
|
+
* For bank contacts, constructs from SWIFT code and account number
|
|
71
|
+
*/
|
|
72
|
+
get info() {
|
|
73
|
+
if (this.data.type === "Mobile") {
|
|
74
|
+
const phone = frontend_core_1.TZPhoneNumber.from(this.data.accountNo);
|
|
75
|
+
if (phone) {
|
|
76
|
+
return new index_js_1.MobileContactInfo(this.data.displayName, phone);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (this.data.type === "Bank") {
|
|
80
|
+
const bank = frontend_core_1.Bank.fromSWIFTCode(this.data.channel);
|
|
81
|
+
if (bank) {
|
|
82
|
+
return new contact_info_js_1.BankContactInfo(this.data.displayName, bank, this.data.accountNo);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Payment channel for the contact
|
|
89
|
+
*
|
|
90
|
+
* @returns {string} Channel information:
|
|
91
|
+
* - For valid contacts, returns formatted channel from ContactInfo
|
|
92
|
+
* - For invalid contacts, falls back to account number
|
|
93
|
+
*/
|
|
94
|
+
get channel() {
|
|
95
|
+
const info = this.info;
|
|
96
|
+
if (info)
|
|
97
|
+
return info.channel;
|
|
98
|
+
return this.data.accountNo;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Account number for the contact
|
|
102
|
+
*
|
|
103
|
+
* @returns {string} Account number:
|
|
104
|
+
* - For valid contacts, returns formatted account number from ContactInfo
|
|
105
|
+
* - For invalid contacts, falls back to raw account number
|
|
106
|
+
*/
|
|
107
|
+
get accNo() {
|
|
108
|
+
const info = this.info;
|
|
109
|
+
if (info)
|
|
110
|
+
return info.accNumber;
|
|
111
|
+
return this.data.accountNo;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Account name for the contact
|
|
115
|
+
* Always returns the display name
|
|
116
|
+
*/
|
|
117
|
+
get accName() {
|
|
118
|
+
return this.data.displayName;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Label for the account number field based on contact type
|
|
122
|
+
*
|
|
123
|
+
* @returns {string} Appropriate label:
|
|
124
|
+
* - "Phone Number" for mobile contacts
|
|
125
|
+
* - "Bank Account Number" for bank contacts
|
|
126
|
+
* - "Account Number" as fallback
|
|
127
|
+
*/
|
|
128
|
+
get accNoLabel() {
|
|
129
|
+
const info = this.info;
|
|
130
|
+
if (info instanceof index_js_1.MobileContactInfo)
|
|
131
|
+
return "Phone Number";
|
|
132
|
+
if (info instanceof contact_info_js_1.BankContactInfo)
|
|
133
|
+
return "Bank Account Number";
|
|
134
|
+
return "Account Number";
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Label for the channel field based on contact type
|
|
138
|
+
*
|
|
139
|
+
* @returns {string} Appropriate label:
|
|
140
|
+
* - "Channel" for mobile contacts
|
|
141
|
+
* - "Bank" for bank contacts
|
|
142
|
+
* - "Channel" as fallback
|
|
143
|
+
*/
|
|
144
|
+
get channelLabel() {
|
|
145
|
+
const info = this.info;
|
|
146
|
+
if (info instanceof index_js_1.MobileContactInfo)
|
|
147
|
+
return "Channel";
|
|
148
|
+
if (info instanceof contact_info_js_1.BankContactInfo)
|
|
149
|
+
return "Bank";
|
|
150
|
+
return "Channel";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Label for the account name field based on contact type
|
|
154
|
+
*
|
|
155
|
+
* @returns {string} Appropriate label:
|
|
156
|
+
* - "Full Name" for mobile contacts
|
|
157
|
+
* - "Bank Account Name" for bank contacts
|
|
158
|
+
* - "Display Name" as fallback
|
|
159
|
+
*/
|
|
160
|
+
get accNameLabel() {
|
|
161
|
+
const info = this.info;
|
|
162
|
+
if (info instanceof index_js_1.MobileContactInfo)
|
|
163
|
+
return "Full Name";
|
|
164
|
+
if (info instanceof contact_info_js_1.BankContactInfo)
|
|
165
|
+
return "Bank Account Name";
|
|
166
|
+
return "Display Name";
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Creates a Contact instance from raw data
|
|
170
|
+
* @throws {ZodError} if validation fails
|
|
171
|
+
*/
|
|
172
|
+
static create(data) {
|
|
173
|
+
return new Contact(data);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Creates multiple Contact instances from an array of raw data
|
|
177
|
+
* @throws {ZodError} if validation fails for any item
|
|
178
|
+
*/
|
|
179
|
+
static createMany(dataArray) {
|
|
180
|
+
return dataArray.map((data) => new Contact(data));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Creates a Contact instance from raw data without throwing
|
|
184
|
+
* @returns {Contact | null} Contact instance or null if validation fails
|
|
185
|
+
*/
|
|
186
|
+
static createSafe(data) {
|
|
187
|
+
try {
|
|
188
|
+
return new Contact(data);
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Checks if an unknown value contains valid data to construct a Contact instance.
|
|
196
|
+
* This is useful when validating raw data structures before instantiation.
|
|
197
|
+
*
|
|
198
|
+
* @param {unknown} obj - The value containing potential contact data
|
|
199
|
+
* @returns {obj is Contact} Type predicate indicating if a Contact can be constructed
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const rawData = await fetchFromAPI();
|
|
204
|
+
* if (Contact.canConstruct(rawData)) {
|
|
205
|
+
* const contact = Contact.create(rawData);
|
|
206
|
+
* // TypeScript knows contact is valid here
|
|
207
|
+
* console.log(contact.displayName);
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @throws {never} This method never throws errors
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
214
|
+
* This method performs strict validation against the {@link ContactData} schema.
|
|
215
|
+
*/
|
|
216
|
+
static canConstruct(obj) {
|
|
217
|
+
if (!obj || typeof obj !== "object")
|
|
218
|
+
return false;
|
|
219
|
+
const result = schemas_js_1.ContactSchemas.contactData.safeParse(obj);
|
|
220
|
+
if (!result.success)
|
|
221
|
+
return false;
|
|
222
|
+
const contact = Contact.createSafe(result.data);
|
|
223
|
+
return contact !== null;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Validates if an unknown value is a Contact instance.
|
|
227
|
+
* This is a runtime type guard that ensures proper object structure and data validity.
|
|
228
|
+
*
|
|
229
|
+
* @param {unknown} obj - The value to validate
|
|
230
|
+
* @returns {obj is Contact} Type predicate indicating if the value is a valid Contact
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const maybeContact = getContactFromCache();
|
|
235
|
+
* if (Contact.is(maybeContact)) {
|
|
236
|
+
* // TypeScript knows maybeContact is a Contact here
|
|
237
|
+
* console.log(maybeContact.displayName);
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* @throws {never} This method never throws errors
|
|
242
|
+
*
|
|
243
|
+
* @remarks
|
|
244
|
+
* This method performs a complete structural validation:
|
|
245
|
+
* 1. Checks if the value is an object
|
|
246
|
+
* 2. Verifies presence of internal data property
|
|
247
|
+
* 3. Validates the data against ContactData schema
|
|
248
|
+
* 4. Ensures the object is a proper Contact instance
|
|
249
|
+
*
|
|
250
|
+
* Use this method when:
|
|
251
|
+
* - Validating cached Contact instances
|
|
252
|
+
* - Checking serialized Contact objects
|
|
253
|
+
* - Verifying API responses
|
|
254
|
+
* - Type narrowing in conditional blocks
|
|
255
|
+
*/
|
|
256
|
+
static is(obj) {
|
|
257
|
+
if (!obj || typeof obj !== "object")
|
|
258
|
+
return false;
|
|
259
|
+
if (!("data" in obj))
|
|
260
|
+
return false;
|
|
261
|
+
return Contact.canConstruct(obj.data);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Converts Payout instance to a plain object
|
|
265
|
+
*/
|
|
266
|
+
toJSON() {
|
|
267
|
+
return { ...this.data };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
exports.Contact = Contact;
|