@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
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2025 TemboPlus Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @temboplus/afloat
|
|
2
2
|
|
|
3
|
-
A foundational
|
|
3
|
+
**A foundational library for Temboplus-Afloat projects.**
|
|
4
|
+
|
|
5
|
+
This JavaScript/TypeScript package provides a central hub for shared utilities, logic, and data access mechanisms within the Temboplus-Afloat ecosystem.
|
|
4
6
|
|
|
5
7
|
## Key Features
|
|
6
8
|
|
|
@@ -20,7 +22,7 @@ A foundational JavaScript/TypeScript library for TemboPlus-Afloat projects, prov
|
|
|
20
22
|
|
|
21
23
|
* **Cross-Environment Compatibility**
|
|
22
24
|
* Works seamlessly in both client-side and server-side environments
|
|
23
|
-
*
|
|
25
|
+
* Supports both synchronous and asynchronous initialization patterns
|
|
24
26
|
|
|
25
27
|
## Usage
|
|
26
28
|
|
|
@@ -28,7 +30,7 @@ A foundational JavaScript/TypeScript library for TemboPlus-Afloat projects, prov
|
|
|
28
30
|
|
|
29
31
|
#### Client-Side Usage
|
|
30
32
|
|
|
31
|
-
In client-side applications,
|
|
33
|
+
In client-side applications, authentication is initialized synchronously:
|
|
32
34
|
|
|
33
35
|
```typescript
|
|
34
36
|
import { AfloatAuth } from "@temboplus/afloat";
|
|
@@ -37,67 +39,42 @@ import { AfloatAuth } from "@temboplus/afloat";
|
|
|
37
39
|
const auth = AfloatAuth.instance;
|
|
38
40
|
|
|
39
41
|
// Check if user is authenticated
|
|
40
|
-
console.log("User authenticated:", auth.
|
|
42
|
+
console.log("User authenticated:", !!auth.currentUser);
|
|
41
43
|
|
|
42
44
|
// Access current user
|
|
43
45
|
const user = auth.currentUser;
|
|
44
46
|
if (user) {
|
|
45
47
|
console.log(`Logged in as: ${user.email}`);
|
|
46
48
|
}
|
|
47
|
-
|
|
48
|
-
// Login a user
|
|
49
|
-
try {
|
|
50
|
-
const user = await auth.logIn("user@example.com", "password123");
|
|
51
|
-
console.log("Login successful!");
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error("Login failed:", error.message);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Check permissions
|
|
57
|
-
if (auth.checkPermission(Permission.ViewBalance)) {
|
|
58
|
-
console.log("User can view balance");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// React hook for reactive user state
|
|
62
|
-
function UserProfile() {
|
|
63
|
-
const user = auth.useCurrentUser();
|
|
64
|
-
|
|
65
|
-
if (!user) {
|
|
66
|
-
return <LoginForm />;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return <div>Hello, {user.name}!</div>;
|
|
70
|
-
}
|
|
71
49
|
```
|
|
72
50
|
|
|
73
51
|
#### Server-Side Usage
|
|
74
52
|
|
|
75
|
-
In server-side environments,
|
|
53
|
+
In server-side environments, authentication requires asynchronous initialization:
|
|
76
54
|
|
|
77
55
|
```typescript
|
|
78
|
-
import {
|
|
56
|
+
import { AfloatAuth } from "@temboplus/afloat";
|
|
79
57
|
|
|
80
|
-
// In a server route handler or
|
|
58
|
+
// In a server route handler or similar context
|
|
81
59
|
async function handleRequest(req, res) {
|
|
82
60
|
try {
|
|
83
|
-
// Extract token from request
|
|
61
|
+
// Extract token from request
|
|
84
62
|
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
85
63
|
|
|
86
64
|
if (!token) {
|
|
87
65
|
return res.status(401).json({ error: 'Unauthorized' });
|
|
88
66
|
}
|
|
89
67
|
|
|
90
|
-
//
|
|
91
|
-
const
|
|
68
|
+
// Initialize server-side auth
|
|
69
|
+
const auth = await AfloatAuth.initializeServer(token);
|
|
92
70
|
|
|
93
|
-
//
|
|
94
|
-
const
|
|
95
|
-
const wallets = await walletRepo.getWallets();
|
|
71
|
+
// Now you can use auth for permission checks
|
|
72
|
+
const isAdmin = auth.checkPermission(Permissions.Payout.View);
|
|
96
73
|
|
|
97
|
-
|
|
74
|
+
// Continue with your handler logic...
|
|
98
75
|
} catch (error) {
|
|
99
|
-
console.error('
|
|
100
|
-
return res.status(500).json({ error: '
|
|
76
|
+
console.error('Authentication error:', error);
|
|
77
|
+
return res.status(500).json({ error: 'Authentication failed' });
|
|
101
78
|
}
|
|
102
79
|
}
|
|
103
80
|
```
|
|
@@ -109,235 +86,54 @@ Repositories provide a consistent interface for data operations across environme
|
|
|
109
86
|
#### Client-Side Repository Usage
|
|
110
87
|
|
|
111
88
|
```typescript
|
|
112
|
-
import {
|
|
113
|
-
|
|
114
|
-
// Option 1: Let repository use service locator (default behavior)
|
|
115
|
-
const walletRepo = new WalletRepository();
|
|
89
|
+
import { WalletRepo } from "@temboplus/afloat";
|
|
116
90
|
|
|
117
|
-
//
|
|
118
|
-
const
|
|
119
|
-
const walletRepo = new WalletRepository({ token: auth.getUserToken() });
|
|
91
|
+
// Create repository - auth is automatically handled
|
|
92
|
+
const walletRepo = new WalletRepo();
|
|
120
93
|
|
|
121
94
|
// Use repository methods
|
|
122
95
|
async function displayBalance() {
|
|
123
96
|
try {
|
|
124
|
-
const balance = await walletRepo.getBalance(
|
|
125
|
-
console.log(`Current balance: ${balance
|
|
97
|
+
const balance = await walletRepo.getBalance();
|
|
98
|
+
console.log(`Current balance: ${balance}`);
|
|
126
99
|
} catch (error) {
|
|
127
100
|
console.error('Error fetching balance:', error);
|
|
128
101
|
}
|
|
129
102
|
}
|
|
130
|
-
|
|
131
|
-
// Get all wallets
|
|
132
|
-
const wallets = await walletRepo.getWallets();
|
|
133
|
-
|
|
134
|
-
// Get wallet statement
|
|
135
|
-
const entries = await walletRepo.getStatement({
|
|
136
|
-
wallet,
|
|
137
|
-
range: {
|
|
138
|
-
startDate: new Date('2024-01-01'),
|
|
139
|
-
endDate: new Date('2024-01-31')
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
103
|
```
|
|
143
104
|
|
|
144
105
|
#### Server-Side Repository Usage
|
|
145
106
|
|
|
146
107
|
```typescript
|
|
147
|
-
import {
|
|
108
|
+
import { AfloatAuth, WalletRepo } from "@temboplus/afloat";
|
|
148
109
|
|
|
149
|
-
async function processServerRequest(token
|
|
150
|
-
//
|
|
151
|
-
const
|
|
110
|
+
async function processServerRequest(token) {
|
|
111
|
+
// Initialize auth for this request
|
|
112
|
+
const auth = await AfloatAuth.initializeServer(token);
|
|
113
|
+
|
|
114
|
+
// Create repository with explicit auth instance
|
|
115
|
+
const walletRepo = new WalletRepo({ auth });
|
|
152
116
|
|
|
153
|
-
// Use repository methods
|
|
154
|
-
const balance = await walletRepo.getBalance(
|
|
117
|
+
// Use repository methods
|
|
118
|
+
const balance = await walletRepo.getBalance();
|
|
155
119
|
const wallets = await walletRepo.getWallets();
|
|
156
120
|
|
|
157
121
|
return { balance, wallets };
|
|
158
122
|
}
|
|
159
|
-
|
|
160
|
-
// In Express.js middleware
|
|
161
|
-
app.use('/api/wallet', async (req, res, next) => {
|
|
162
|
-
const token = extractTokenFromRequest(req);
|
|
163
|
-
|
|
164
|
-
if (!token) {
|
|
165
|
-
return res.status(401).json({ error: 'No token provided' });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
req.walletRepo = new WalletRepository({ token });
|
|
169
|
-
next();
|
|
170
|
-
});
|
|
171
123
|
```
|
|
172
124
|
|
|
173
|
-
## Architecture Overview
|
|
174
|
-
|
|
175
|
-
### Client-Side Pattern
|
|
176
|
-
- **Authentication Management**: Use `AfloatAuth.instance` singleton
|
|
177
|
-
- **Repository Creation**: Can use service locator or explicit token passing
|
|
178
|
-
- **State Management**: Reactive updates through React hooks
|
|
179
|
-
- **Permission Checking**: Built into the auth manager
|
|
180
|
-
|
|
181
|
-
### Server-Side Pattern
|
|
182
|
-
- **No Auth Manager**: Extract tokens directly from requests
|
|
183
|
-
- **Repository Creation**: Always pass token explicitly
|
|
184
|
-
- **Stateless**: Each request creates fresh repository instances
|
|
185
|
-
- **Permission Checking**: Handle at route/middleware level
|
|
186
|
-
|
|
187
125
|
## Best Practices
|
|
188
126
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
3. **Handle Permissions**: Check permissions before attempting restricted operations
|
|
194
|
-
4. **Error Handling**: Implement proper error handling for authentication failures
|
|
195
|
-
|
|
196
|
-
```typescript
|
|
197
|
-
// Good: Initialize auth early
|
|
198
|
-
const auth = AfloatAuth.instance;
|
|
199
|
-
|
|
200
|
-
// Good: Use reactive hooks in components
|
|
201
|
-
function Dashboard() {
|
|
202
|
-
const user = auth.useCurrentUser();
|
|
203
|
-
|
|
204
|
-
if (!user) return <LoginPrompt />;
|
|
205
|
-
|
|
206
|
-
return <UserDashboard user={user} />;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Good: Check permissions before operations
|
|
210
|
-
if (auth.checkPermission(Permission.ViewBalance)) {
|
|
211
|
-
const repo = new WalletRepository();
|
|
212
|
-
const balance = await repo.getBalance({ wallet });
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Server-Side Applications
|
|
217
|
-
|
|
218
|
-
1. **Token Extraction**: Always extract and validate tokens from requests
|
|
219
|
-
2. **Explicit Dependencies**: Pass tokens explicitly to repositories
|
|
220
|
-
3. **Error Handling**: Implement proper middleware for authentication errors
|
|
221
|
-
4. **Stateless Design**: Create fresh repository instances per request
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
// Good: Extract token from request
|
|
225
|
-
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
226
|
-
|
|
227
|
-
// Good: Explicit token passing
|
|
228
|
-
const repo = new WalletRepository({ token });
|
|
229
|
-
|
|
230
|
-
// Good: Middleware pattern
|
|
231
|
-
const authMiddleware = (req, res, next) => {
|
|
232
|
-
const token = extractToken(req);
|
|
233
|
-
|
|
234
|
-
if (!token) {
|
|
235
|
-
return res.status(401).json({ error: 'Unauthorized' });
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
req.authToken = token;
|
|
239
|
-
next();
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
// Good: Use in route handlers
|
|
243
|
-
app.get('/api/balance', authMiddleware, async (req, res) => {
|
|
244
|
-
const repo = new WalletRepository({ token: req.authToken });
|
|
245
|
-
const balance = await repo.getBalance({ wallet });
|
|
246
|
-
res.json({ balance });
|
|
247
|
-
});
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Testing
|
|
251
|
-
|
|
252
|
-
1. **Client-Side**: Mock the `AfloatAuth` singleton or use dependency injection
|
|
253
|
-
2. **Server-Side**: Mock repositories with test tokens
|
|
254
|
-
3. **Integration**: Test both authentication flows and repository operations
|
|
255
|
-
|
|
256
|
-
```typescript
|
|
257
|
-
// Client-side testing
|
|
258
|
-
const mockAuth = {
|
|
259
|
-
currentUser: testUser,
|
|
260
|
-
getUserToken: () => 'test-token',
|
|
261
|
-
checkPermission: () => true
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// Server-side testing
|
|
265
|
-
const testRepo = new WalletRepository({ token: 'test-token' });
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## Troubleshooting
|
|
269
|
-
|
|
270
|
-
### Common Issues
|
|
271
|
-
|
|
272
|
-
#### `"Cannot find package 'react'" in Node.js`
|
|
273
|
-
|
|
274
|
-
This error occurs when using Zustand v5. Ensure you're using Zustand v4:
|
|
275
|
-
```bash
|
|
276
|
-
npm install zustand@^4.5.7
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
Remove any existing v5 installation:
|
|
280
|
-
```bash
|
|
281
|
-
npm uninstall zustand@5.x.x
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
#### Authentication Errors in Server Environment
|
|
285
|
-
|
|
286
|
-
**Problem**: Trying to use `AfloatAuth.instance` in server-side code
|
|
287
|
-
**Solution**: Extract tokens from requests and pass directly to repositories
|
|
288
|
-
|
|
289
|
-
```typescript
|
|
290
|
-
// ❌ Don't do this in server code
|
|
291
|
-
const auth = AfloatAuth.instance; // This is client-side only!
|
|
292
|
-
|
|
293
|
-
// ✅ Do this instead
|
|
294
|
-
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
295
|
-
const repo = new WalletRepository({ token });
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
#### Repository Token Issues
|
|
299
|
-
|
|
300
|
-
**Problem**: Repository calls failing with authentication errors
|
|
301
|
-
**Solution**: Ensure tokens are properly extracted and passed
|
|
302
|
-
|
|
303
|
-
```typescript
|
|
304
|
-
// ❌ Missing token
|
|
305
|
-
const repo = new WalletRepository(); // May fail in server context
|
|
306
|
-
|
|
307
|
-
// ✅ Explicit token
|
|
308
|
-
const repo = new WalletRepository({ token: extractedToken });
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Debug Information
|
|
312
|
-
|
|
313
|
-
Use the auth manager's debug utilities for troubleshooting:
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
// Client-side debugging
|
|
317
|
-
const debugInfo = AfloatAuth.instance.getDebugInfo();
|
|
318
|
-
console.log('Auth Debug Info:', debugInfo);
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
## API Reference
|
|
322
|
-
|
|
323
|
-
### AfloatAuth (Client-Side Only)
|
|
324
|
-
|
|
325
|
-
- `AfloatAuth.instance` - Singleton instance for client-side usage
|
|
326
|
-
- `currentUser` - Get current authenticated user
|
|
327
|
-
- `isAuthenticated` - Check authentication status
|
|
328
|
-
- `getUserToken()` - Get current auth token
|
|
329
|
-
- `useCurrentUser()` - React hook for reactive user state
|
|
330
|
-
- `checkPermission(perm)` - Check user permissions
|
|
331
|
-
- `logIn(email, password)` - Authenticate user
|
|
332
|
-
- `logOut()` - Clear authentication state
|
|
333
|
-
- `resetPassword(current, new)` - Update user password
|
|
334
|
-
|
|
335
|
-
### Repository Pattern
|
|
127
|
+
1. **Client-Side Applications**
|
|
128
|
+
- Initialize `AfloatAuth.instance` early in your application lifecycle
|
|
129
|
+
- Create repositories without explicit auth parameters
|
|
130
|
+
- Handle permission errors appropriately in your UI
|
|
336
131
|
|
|
337
|
-
|
|
338
|
-
-
|
|
339
|
-
-
|
|
132
|
+
2. **Server-Side Applications**
|
|
133
|
+
- Always use `await AfloatAuth.initializeServer(token)` for each request
|
|
134
|
+
- Pass the auth instance explicitly to repositories
|
|
135
|
+
- Implement proper error handling for authentication failures
|
|
340
136
|
|
|
341
|
-
|
|
342
|
-
- `
|
|
343
|
-
- `
|
|
137
|
+
3. **Testing**
|
|
138
|
+
- Use the `AuthContext` to inject mock auth instances during testing
|
|
139
|
+
- Reset `AuthContext.current` after each test to prevent test pollution
|
package/esm/mod.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./src/features/auth/index.js";
|
|
2
|
+
export * from "./src/features/contact/index.js";
|
|
3
|
+
export * from "./src/features/wallet/index.js";
|
|
4
|
+
export * from "./src/features/payout/index.js";
|
|
5
|
+
export * from "./src/features/admin/index.js";
|
|
6
|
+
export * from "./src/errors/index.js";
|
|
7
|
+
export * from "./src/models/index.js";
|
|
8
|
+
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
package/esm/mod.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./src/features/auth/index.js";
|
|
2
|
+
export * from "./src/features/contact/index.js";
|
|
3
|
+
export * from "./src/features/wallet/index.js";
|
|
4
|
+
export * from "./src/features/payout/index.js";
|
|
5
|
+
export * from "./src/features/admin/index.js";
|
|
6
|
+
export * from "./src/errors/index.js";
|
|
7
|
+
export * from "./src/models/index.js";
|
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_error.d.ts","sourceRoot":"","sources":["../../../src/src/errors/api_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;;OAGG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;OAGG;IACH,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;IAE/B;;;OAGG;IACH,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElD;;;;;;;OAOG;gBACS,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC;IASD;;;;;;;;;;;;;;;;;OAiBG;WACW,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ;WAKrC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ;IAOjD,WAAkB,MAAM,IAAI,CAAC,CAAC,SAAS,CAAC;QACtC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;QACrB,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC;QACxB,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAClC,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;KACxC,CAAC,CAOD;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Custom error class representing API-related errors.
|
|
4
|
+
* Extends the built-in `Error` class to include additional properties such as `statusCode`, `error`, and `details`.
|
|
5
|
+
*/
|
|
6
|
+
export class APIError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new `APIError` instance.
|
|
9
|
+
* @param {Object} args - The arguments to initialize the error.
|
|
10
|
+
* @param {string} args.message - The error message.
|
|
11
|
+
* @param {number} args.statusCode - The HTTP status code associated with the error.
|
|
12
|
+
* @param {string} [args.error] - An optional error identifier or code.
|
|
13
|
+
* @param {Record<string, unknown>} [args.details] - Additional details about the error.
|
|
14
|
+
*/
|
|
15
|
+
constructor(args) {
|
|
16
|
+
super(args.message);
|
|
17
|
+
/**
|
|
18
|
+
* The HTTP status code associated with the error.
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(this, "statusCode", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* An optional error identifier or code.
|
|
29
|
+
* @type {string | undefined}
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(this, "error", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Additional details about the error, often used for debugging purposes.
|
|
39
|
+
* @type {Record<string, unknown> | undefined}
|
|
40
|
+
*/
|
|
41
|
+
Object.defineProperty(this, "details", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: void 0
|
|
46
|
+
});
|
|
47
|
+
this.name = "ApiError";
|
|
48
|
+
this.statusCode = args.statusCode;
|
|
49
|
+
if (this.error)
|
|
50
|
+
this.error = args.error;
|
|
51
|
+
if (args.details)
|
|
52
|
+
this.details = args.details;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Validates whether an unknown value conforms to the APIError schema.
|
|
56
|
+
* This is more thorough than an instanceof check as it verifies all required properties
|
|
57
|
+
* and their types using the defined schema.
|
|
58
|
+
*
|
|
59
|
+
* @param {unknown} error - Any value to be validated
|
|
60
|
+
* @returns {error is APIError} Type predicate indicating if the value is a valid APIError
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* try {
|
|
64
|
+
* throw new Error('Network failed');
|
|
65
|
+
* } catch (err) {
|
|
66
|
+
* if (APIError.is(err)) {
|
|
67
|
+
* // err is typed as APIError here
|
|
68
|
+
* console.log(err.statusCode);
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
*/
|
|
72
|
+
static is(error) {
|
|
73
|
+
const result = APIError.schema.safeParse(error);
|
|
74
|
+
return result.success;
|
|
75
|
+
}
|
|
76
|
+
static unknown(message) {
|
|
77
|
+
return new APIError({
|
|
78
|
+
message: message ?? "An unknown error occurred",
|
|
79
|
+
statusCode: 502,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
static get schema() {
|
|
83
|
+
return z.object({
|
|
84
|
+
message: z.string(),
|
|
85
|
+
statusCode: z.number().int(),
|
|
86
|
+
error: z.string().optional(),
|
|
87
|
+
details: z.object({}).optional(),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Permission } from "
|
|
1
|
+
import { type Permission } from "../models/permission.js";
|
|
2
2
|
/**
|
|
3
3
|
* Custom error class representing an error caused by missing required permissions.
|
|
4
4
|
* Extends the built-in {@link Error} class to include the `requiredPermissions` property.
|
|
@@ -45,3 +45,4 @@ export declare class PermissionError extends Error {
|
|
|
45
45
|
*/
|
|
46
46
|
static is(error: unknown): error is PermissionError;
|
|
47
47
|
}
|
|
48
|
+
//# sourceMappingURL=permission_error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission_error.d.ts","sourceRoot":"","sources":["../../../src/src/errors/permission_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,yBAAyB,CAAC;AAGvE;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC;;;OAGG;IACH,SAAgB,mBAAmB,EAAE,UAAU,EAAE,CAAC;IAElD;;;;;OAKG;gBACS,IAAI,EAAE;QAChB,mBAAmB,EAAE,UAAU,EAAE,CAAC;QAClC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IASD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACW,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe;CAkB3D"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Permissions } from "../models/permission.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Custom error class representing an error caused by missing required permissions.
|
|
5
|
+
* Extends the built-in {@link Error} class to include the `requiredPermissions` property.
|
|
6
|
+
*/
|
|
7
|
+
export class PermissionError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new `PermissionError` instance.
|
|
10
|
+
* @param {Object} args - The constructor arguments.
|
|
11
|
+
* @param {Permission[]} args.requiredPermissions - An array of permissions required for the operation.
|
|
12
|
+
* @param {string} [args.message] - An optional custom error message. Defaults to listing the missing permissions.
|
|
13
|
+
*/
|
|
14
|
+
constructor(args) {
|
|
15
|
+
super(args.message ??
|
|
16
|
+
`Missing required permissions: ${args.requiredPermissions.join(", ")}`);
|
|
17
|
+
/**
|
|
18
|
+
* The permissions that are required but were not present, causing the error.
|
|
19
|
+
* @type {Permission[]}
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(this, "requiredPermissions", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
this.name = "PermissionError";
|
|
28
|
+
this.requiredPermissions = args.requiredPermissions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validates if an unknown value is a valid PermissionError instance.
|
|
32
|
+
* Performs structural validation of the error object and its properties.
|
|
33
|
+
*
|
|
34
|
+
* @param {unknown} error - The value to validate.
|
|
35
|
+
* @returns {error is PermissionError} Type predicate indicating if the value is a valid PermissionError.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* try {
|
|
39
|
+
* throw new Error('Access denied');
|
|
40
|
+
* } catch (error) {
|
|
41
|
+
* if (PermissionError.is(error)) {
|
|
42
|
+
* // error is typed as PermissionError with properly typed requiredPermissions
|
|
43
|
+
* console.log(error.requiredPermissions);
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* Validates the following:
|
|
49
|
+
* - Has all required Error properties
|
|
50
|
+
* - Has correct error name
|
|
51
|
+
* - Contains properly structured requiredPermissions array
|
|
52
|
+
* - Maintains proper prototype chain
|
|
53
|
+
*/
|
|
54
|
+
static is(error) {
|
|
55
|
+
const permissionSchema = z.union([
|
|
56
|
+
z.enum(Object.values(Permissions.Profile)),
|
|
57
|
+
z.enum(Object.values(Permissions.Contact)),
|
|
58
|
+
z.enum(Object.values(Permissions.Payment)),
|
|
59
|
+
z.enum(Object.values(Permissions.Payout)),
|
|
60
|
+
z.enum(Object.values(Permissions.Transfer)),
|
|
61
|
+
z.enum(Object.values(Permissions.Wallet)),
|
|
62
|
+
]);
|
|
63
|
+
const errorSchema = z.object({
|
|
64
|
+
name: z.literal("PermissionError"),
|
|
65
|
+
message: z.string(),
|
|
66
|
+
requiredPermissions: z.array(permissionSchema),
|
|
67
|
+
});
|
|
68
|
+
return errorSchema.safeParse(error).success;
|
|
69
|
+
}
|
|
70
|
+
}
|