@explorins/pers-sdk 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics/api/analytics-api.d.ts +17 -0
- package/dist/analytics/api/analytics-api.d.ts.map +1 -0
- package/{src/analytics/index.ts → dist/analytics/index.d.ts} +28 -52
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/models/index.d.ts +61 -0
- package/dist/analytics/models/index.d.ts.map +1 -0
- package/dist/analytics/services/analytics-service.d.ts +19 -0
- package/dist/analytics/services/analytics-service.d.ts.map +1 -0
- package/dist/analytics.cjs +76 -0
- package/dist/analytics.cjs.map +1 -0
- package/dist/analytics.js +72 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth-admin/api/auth-admin-api.d.ts +27 -0
- package/dist/auth-admin/api/auth-admin-api.d.ts.map +1 -0
- package/dist/auth-admin/index.d.ts +26 -0
- package/dist/auth-admin/index.d.ts.map +1 -0
- package/dist/auth-admin/services/auth-admin-service.d.ts +23 -0
- package/dist/auth-admin/services/auth-admin-service.d.ts.map +1 -0
- package/dist/auth-admin.cjs +96 -0
- package/dist/auth-admin.cjs.map +1 -0
- package/dist/auth-admin.js +92 -0
- package/dist/auth-admin.js.map +1 -0
- package/dist/business/api/business-api.d.ts +133 -0
- package/dist/business/api/business-api.d.ts.map +1 -0
- package/dist/business/index.d.ts +34 -0
- package/dist/business/index.d.ts.map +1 -0
- package/dist/business/models/index.d.ts +8 -0
- package/dist/business/models/index.d.ts.map +1 -0
- package/dist/business/services/business-service.d.ts +51 -0
- package/dist/business/services/business-service.d.ts.map +1 -0
- package/dist/business.cjs +303 -0
- package/dist/business.cjs.map +1 -0
- package/dist/business.js +299 -0
- package/dist/business.js.map +1 -0
- package/dist/campaign/api/campaign-api.d.ts +213 -0
- package/dist/campaign/api/campaign-api.d.ts.map +1 -0
- package/dist/campaign/index.d.ts +44 -0
- package/dist/campaign/index.d.ts.map +1 -0
- package/dist/campaign/services/campaign-service.d.ts +88 -0
- package/dist/campaign/services/campaign-service.d.ts.map +1 -0
- package/dist/campaign.cjs +506 -0
- package/dist/campaign.cjs.map +1 -0
- package/dist/campaign.js +502 -0
- package/dist/campaign.js.map +1 -0
- package/dist/core/abstractions/http-client.d.ts +22 -0
- package/dist/core/abstractions/http-client.d.ts.map +1 -0
- package/dist/core/auth/auth-provider.interface.d.ts +12 -0
- package/dist/core/auth/auth-provider.interface.d.ts.map +1 -0
- package/dist/core/auth/create-auth-provider.d.ts +27 -0
- package/dist/core/auth/create-auth-provider.d.ts.map +1 -0
- package/dist/core/auth/simple-auth-config.interface.d.ts +15 -0
- package/dist/core/auth/simple-auth-config.interface.d.ts.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/pers-api-client.d.ts +54 -0
- package/dist/core/pers-api-client.d.ts.map +1 -0
- package/dist/core/pers-config.d.ts +38 -0
- package/dist/core/pers-config.d.ts.map +1 -0
- package/dist/core/utils/jwt.function.d.ts +2 -0
- package/dist/core/utils/jwt.function.d.ts.map +1 -0
- package/dist/core.cjs +506 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.js +497 -0
- package/dist/core.js.map +1 -0
- package/dist/donation/api/donation-api.d.ts +18 -0
- package/dist/donation/api/donation-api.d.ts.map +1 -0
- package/dist/donation/index.d.ts +25 -0
- package/dist/donation/index.d.ts.map +1 -0
- package/{src/donation/models/index.ts → dist/donation/models/index.d.ts} +8 -11
- package/dist/donation/models/index.d.ts.map +1 -0
- package/dist/donation/services/donation-service.d.ts +19 -0
- package/dist/donation/services/donation-service.d.ts.map +1 -0
- package/dist/donation.cjs +78 -0
- package/dist/donation.cjs.map +1 -0
- package/dist/donation.js +74 -0
- package/dist/donation.js.map +1 -0
- package/dist/index.cjs +4217 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4164 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +129 -0
- package/dist/payment/api/payment-api.d.ts +105 -0
- package/dist/payment/api/payment-api.d.ts.map +1 -0
- package/dist/payment/index.d.ts +36 -0
- package/dist/payment/index.d.ts.map +1 -0
- package/dist/payment/models/index.d.ts +12 -0
- package/dist/payment/models/index.d.ts.map +1 -0
- package/dist/payment/services/payment-service.d.ts +40 -0
- package/dist/payment/services/payment-service.d.ts.map +1 -0
- package/dist/payment.cjs +258 -0
- package/dist/payment.cjs.map +1 -0
- package/dist/payment.js +254 -0
- package/dist/payment.js.map +1 -0
- package/dist/pers-sdk.d.ts +29 -0
- package/dist/pers-sdk.d.ts.map +1 -0
- package/dist/redemption/api/redemption-api.d.ts +147 -0
- package/dist/redemption/api/redemption-api.d.ts.map +1 -0
- package/dist/redemption/index.d.ts +35 -0
- package/dist/redemption/index.d.ts.map +1 -0
- package/dist/redemption/models/index.d.ts +8 -0
- package/dist/redemption/models/index.d.ts.map +1 -0
- package/dist/redemption/services/redemption-service.d.ts +56 -0
- package/dist/redemption/services/redemption-service.d.ts.map +1 -0
- package/dist/redemption.cjs +333 -0
- package/dist/redemption.cjs.map +1 -0
- package/dist/redemption.js +329 -0
- package/dist/redemption.js.map +1 -0
- package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts +18 -0
- package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts.map +1 -0
- package/dist/tenant/api/tenant-api.d.ts +56 -0
- package/dist/tenant/api/tenant-api.d.ts.map +1 -0
- package/dist/tenant/index.d.ts +34 -0
- package/dist/tenant/index.d.ts.map +1 -0
- package/dist/tenant/models/index.d.ts +11 -0
- package/dist/tenant/models/index.d.ts.map +1 -0
- package/dist/tenant/services/tenant-service.d.ts +46 -0
- package/dist/tenant/services/tenant-service.d.ts.map +1 -0
- package/dist/tenant.cjs +177 -0
- package/dist/tenant.cjs.map +1 -0
- package/dist/tenant.js +173 -0
- package/dist/tenant.js.map +1 -0
- package/dist/token/api/token-api.d.ts +64 -0
- package/dist/token/api/token-api.d.ts.map +1 -0
- package/dist/token/base/base-token-service.d.ts +87 -0
- package/dist/token/base/base-token-service.d.ts.map +1 -0
- package/dist/token/index.d.ts +13 -0
- package/dist/token/index.d.ts.map +1 -0
- package/dist/token/models/index.d.ts +18 -0
- package/dist/token/models/index.d.ts.map +1 -0
- package/dist/token/services/token-service.d.ts +68 -0
- package/dist/token/services/token-service.d.ts.map +1 -0
- package/dist/token/token-sdk.d.ts +140 -0
- package/dist/token/token-sdk.d.ts.map +1 -0
- package/dist/token.cjs +537 -0
- package/dist/token.cjs.map +1 -0
- package/dist/token.js +532 -0
- package/dist/token.js.map +1 -0
- package/dist/transaction/api/transaction-api.d.ts +133 -0
- package/dist/transaction/api/transaction-api.d.ts.map +1 -0
- package/dist/transaction/index.d.ts +38 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/models/index.d.ts +42 -0
- package/dist/transaction/models/index.d.ts.map +1 -0
- package/dist/transaction/services/transaction-service.d.ts +56 -0
- package/dist/transaction/services/transaction-service.d.ts.map +1 -0
- package/dist/transaction.cjs +394 -0
- package/dist/transaction.cjs.map +1 -0
- package/dist/transaction.js +390 -0
- package/dist/transaction.js.map +1 -0
- package/dist/user/api/user-api.d.ts +56 -0
- package/dist/user/api/user-api.d.ts.map +1 -0
- package/dist/user/index.d.ts +36 -0
- package/dist/user/index.d.ts.map +1 -0
- package/{src/user/models/index.ts → dist/user/models/index.d.ts} +12 -10
- package/dist/user/models/index.d.ts.map +1 -0
- package/dist/user/services/user-service.d.ts +46 -0
- package/dist/user/services/user-service.d.ts.map +1 -0
- package/dist/user-status/api/user-status-api.d.ts +37 -0
- package/dist/user-status/api/user-status-api.d.ts.map +1 -0
- package/dist/user-status/index.d.ts +28 -0
- package/dist/user-status/index.d.ts.map +1 -0
- package/{src/user-status/models/index.ts → dist/user-status/models/index.d.ts} +8 -11
- package/dist/user-status/models/index.d.ts.map +1 -0
- package/dist/user-status/services/user-status-service.d.ts +26 -0
- package/dist/user-status/services/user-status-service.d.ts.map +1 -0
- package/dist/user-status.cjs +147 -0
- package/dist/user-status.cjs.map +1 -0
- package/dist/user-status.js +143 -0
- package/dist/user-status.js.map +1 -0
- package/dist/user.cjs +188 -0
- package/dist/user.cjs.map +1 -0
- package/dist/user.js +184 -0
- package/dist/user.js.map +1 -0
- package/dist/web3/api/web3-api.d.ts +27 -0
- package/dist/web3/api/web3-api.d.ts.map +1 -0
- package/dist/web3/index.d.ts +16 -0
- package/dist/web3/index.d.ts.map +1 -0
- package/dist/web3/models/index.d.ts +92 -0
- package/dist/web3/models/index.d.ts.map +1 -0
- package/dist/web3/services/web3-service.d.ts +21 -0
- package/dist/web3/services/web3-service.d.ts.map +1 -0
- package/dist/web3-chain/api/web3-chain-api.d.ts +19 -0
- package/dist/web3-chain/api/web3-chain-api.d.ts.map +1 -0
- package/dist/web3-chain/index.d.ts +17 -0
- package/dist/web3-chain/index.d.ts.map +1 -0
- package/{src/web3-chain/models/index.ts → dist/web3-chain/models/index.d.ts} +38 -45
- package/dist/web3-chain/models/index.d.ts.map +1 -0
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts +8 -0
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts.map +1 -0
- package/dist/web3-chain/services/provider.service.d.ts +15 -0
- package/dist/web3-chain/services/provider.service.d.ts.map +1 -0
- package/dist/web3-chain/services/public-http-provider.service.d.ts +8 -0
- package/dist/web3-chain/services/public-http-provider.service.d.ts.map +1 -0
- package/dist/web3-chain/services/web3-chain-service.d.ts +17 -0
- package/dist/web3-chain/services/web3-chain-service.d.ts.map +1 -0
- package/dist/web3-chain.cjs +316 -0
- package/dist/web3-chain.cjs.map +1 -0
- package/dist/web3-chain.js +310 -0
- package/dist/web3-chain.js.map +1 -0
- package/dist/web3.cjs +516 -0
- package/dist/web3.cjs.map +1 -0
- package/dist/web3.js +513 -0
- package/dist/web3.js.map +1 -0
- package/package.json +56 -72
- package/config/domains.js +0 -22
- package/explorins-pers-sdk-1.0.0-alpha.1.tgz +0 -0
- package/rollup.config.js +0 -74
- package/scripts/copy-declarations.js +0 -147
- package/src/analytics/api/analytics-api.ts +0 -24
- package/src/analytics/models/index.ts +0 -74
- package/src/analytics/services/analytics-service.ts +0 -28
- package/src/auth-admin/api/auth-admin-api.ts +0 -42
- package/src/auth-admin/index.ts +0 -47
- package/src/auth-admin/services/auth-admin-service.ts +0 -36
- package/src/business/api/business-api.ts +0 -234
- package/src/business/index.ts +0 -53
- package/src/business/models/index.ts +0 -13
- package/src/business/services/business-service.ts +0 -88
- package/src/campaign/api/campaign-api.ts +0 -376
- package/src/campaign/index.ts +0 -67
- package/src/campaign/services/campaign-service.ts +0 -164
- package/src/core/abstractions/http-client.ts +0 -24
- package/src/core/auth/auth-provider.interface.ts +0 -16
- package/src/core/auth/create-auth-provider.ts +0 -136
- package/src/core/auth/simple-auth-config.interface.ts +0 -15
- package/src/core/index.ts +0 -33
- package/src/core/pers-api-client.ts +0 -343
- package/src/core/pers-config.ts +0 -65
- package/src/core/utils/jwt.function.ts +0 -24
- package/src/donation/api/donation-api.ts +0 -24
- package/src/donation/index.ts +0 -47
- package/src/donation/services/donation-service.ts +0 -25
- package/src/index.ts +0 -55
- package/src/payment/api/payment-api.ts +0 -185
- package/src/payment/index.ts +0 -64
- package/src/payment/models/index.ts +0 -29
- package/src/payment/services/payment-service.ts +0 -70
- package/src/pers-sdk.ts +0 -45
- package/src/redemption/api/redemption-api.ts +0 -241
- package/src/redemption/index.ts +0 -60
- package/src/redemption/models/index.ts +0 -17
- package/src/redemption/services/redemption-service.ts +0 -103
- package/src/shared/interfaces/pers-shared-lib.interfaces.ts +0 -99
- package/src/tenant/api/tenant-api.ts +0 -92
- package/src/tenant/index.ts +0 -61
- package/src/tenant/models/index.ts +0 -20
- package/src/tenant/services/tenant-service.ts +0 -78
- package/src/token/api/token-api.ts +0 -129
- package/src/token/base/base-token-service.ts +0 -167
- package/src/token/index.ts +0 -38
- package/src/token/models/index.ts +0 -30
- package/src/token/services/token-service.ts +0 -125
- package/src/token/token-sdk.ts +0 -231
- package/src/transaction/api/transaction-api.ts +0 -296
- package/src/transaction/index.ts +0 -65
- package/src/transaction/models/index.ts +0 -60
- package/src/transaction/services/transaction-service.ts +0 -104
- package/src/user/api/user-api.ts +0 -98
- package/src/user/index.ts +0 -62
- package/src/user/services/user-service.ts +0 -75
- package/src/user-status/api/user-status-api.ts +0 -78
- package/src/user-status/index.ts +0 -55
- package/src/user-status/services/user-status-service.ts +0 -51
- package/src/web3/api/web3-api.ts +0 -68
- package/src/web3/index.ts +0 -38
- package/src/web3/models/index.ts +0 -150
- package/src/web3/services/web3-service.ts +0 -338
- package/src/web3-chain/api/web3-chain-api.ts +0 -42
- package/src/web3-chain/index.ts +0 -27
- package/src/web3-chain/services/getWeb3FCD.service.ts +0 -47
- package/src/web3-chain/services/provider.service.ts +0 -123
- package/src/web3-chain/services/public-http-provider.service.ts +0 -26
- package/src/web3-chain/services/web3-chain-service.ts +0 -131
- package/tsconfig.json +0 -28
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { PersApiClient } from '../../core/pers-api-client';
|
|
2
|
-
import {
|
|
3
|
-
BusinessDTO,
|
|
4
|
-
BusinessTypeDTO,
|
|
5
|
-
BusinessUpdateRequestDTO,
|
|
6
|
-
BusinessCreateRequestDTO,
|
|
7
|
-
BusinessToggleActiveRequestDTO,
|
|
8
|
-
BusinessApiKeyDTO,
|
|
9
|
-
BusinessTokenBalancesDTO,
|
|
10
|
-
BusinessTypeCreateRequestDTO
|
|
11
|
-
} from '../../shared/interfaces/pers-shared-lib.interfaces';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Platform-Agnostic Business API Client
|
|
15
|
-
*
|
|
16
|
-
* Updated to match the new RESTful /businesses endpoints.
|
|
17
|
-
* Uses @explorins/pers-shared DTOs for full type safety and consistency with backend.
|
|
18
|
-
*/
|
|
19
|
-
export class BusinessApi {
|
|
20
|
-
constructor(private apiClient: PersApiClient) {}
|
|
21
|
-
|
|
22
|
-
private readonly basePath = '/businesses';
|
|
23
|
-
|
|
24
|
-
// ==========================================
|
|
25
|
-
// 🌐 BUSINESS TYPES MANAGEMENT
|
|
26
|
-
// ==========================================
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get all business types (project key required)
|
|
30
|
-
*
|
|
31
|
-
* Endpoint: GET /businesses/types
|
|
32
|
-
* Auth: @ApiSecurity('projectKey')
|
|
33
|
-
*/
|
|
34
|
-
async getAllBusinessTypes(): Promise<BusinessTypeDTO[]> {
|
|
35
|
-
return this.apiClient.get<BusinessTypeDTO[]>(`${this.basePath}/types`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* ADMIN: Create business type
|
|
40
|
-
*
|
|
41
|
-
* Endpoint: POST /businesses/types
|
|
42
|
-
* Auth: @TenantAdmin()
|
|
43
|
-
*/
|
|
44
|
-
async createBusinessType(dto: BusinessTypeCreateRequestDTO): Promise<BusinessTypeDTO> {
|
|
45
|
-
return this.apiClient.post<BusinessTypeDTO>(`${this.basePath}/types`, dto);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* ADMIN: Update business type
|
|
50
|
-
*
|
|
51
|
-
* Endpoint: PUT /businesses/types
|
|
52
|
-
* Auth: @TenantAdmin()
|
|
53
|
-
*/
|
|
54
|
-
async updateBusinessType(dto: BusinessTypeDTO): Promise<BusinessTypeDTO> {
|
|
55
|
-
return this.apiClient.put<BusinessTypeDTO>(`${this.basePath}/types`, dto);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* ADMIN: Delete business type
|
|
60
|
-
*
|
|
61
|
-
* Endpoint: DELETE /businesses/types/{id}
|
|
62
|
-
* Auth: @TenantAdmin()
|
|
63
|
-
*/
|
|
64
|
-
async deleteBusinessType(id: number): Promise<boolean> {
|
|
65
|
-
return this.apiClient.delete<boolean>(`${this.basePath}/types/${id}`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ==========================================
|
|
69
|
-
// 🏢 BUSINESS MANAGEMENT
|
|
70
|
-
// ==========================================
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get current business info (business authentication required)
|
|
74
|
-
*
|
|
75
|
-
* Endpoint: GET /businesses/me
|
|
76
|
-
* Auth: @Business()
|
|
77
|
-
*/
|
|
78
|
-
async getCurrentBusiness(): Promise<BusinessTokenBalancesDTO> {
|
|
79
|
-
return this.apiClient.get<BusinessTokenBalancesDTO>(`${this.basePath}/me`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get all active businesses (project key required)
|
|
84
|
-
*
|
|
85
|
-
* Endpoint: GET /businesses
|
|
86
|
-
* Auth: @ApiSecurity('projectKey')
|
|
87
|
-
* Note: Regular users automatically get active businesses only
|
|
88
|
-
*/
|
|
89
|
-
async getActiveBusinesses(): Promise<BusinessDTO[]> {
|
|
90
|
-
return this.apiClient.get<BusinessDTO[]>(`${this.basePath}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Get all businesses with filtering (admin users can access inactive)
|
|
95
|
-
*
|
|
96
|
-
* Endpoint: GET /businesses?active={boolean}&sanitize={mode}
|
|
97
|
-
* Auth: @ApiSecurity('projectKey') (enhanced with role-based filtering)
|
|
98
|
-
*/
|
|
99
|
-
async getAllBusinesses(options?: {
|
|
100
|
-
active?: boolean;
|
|
101
|
-
sanitize?: 'soft' | 'hard';
|
|
102
|
-
}): Promise<BusinessDTO[]> {
|
|
103
|
-
const params = new URLSearchParams();
|
|
104
|
-
|
|
105
|
-
if (options?.active !== undefined) {
|
|
106
|
-
params.append('active', String(options.active));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (options?.sanitize) {
|
|
110
|
-
params.append('sanitize', options.sanitize);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const queryString = params.toString();
|
|
114
|
-
const url = queryString ? `${this.basePath}?${queryString}` : this.basePath;
|
|
115
|
-
|
|
116
|
-
return this.apiClient.get<BusinessDTO[]>(url);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* ADMIN: Get all businesses (admin endpoint with full access)
|
|
121
|
-
*
|
|
122
|
-
* Endpoint: GET /businesses/admin
|
|
123
|
-
* Auth: @TenantAdmin()
|
|
124
|
-
*/
|
|
125
|
-
async getAllBusinessesAdmin(options?: {
|
|
126
|
-
active?: boolean;
|
|
127
|
-
sanitize?: 'soft' | 'hard';
|
|
128
|
-
}): Promise<BusinessDTO[]> {
|
|
129
|
-
const params = new URLSearchParams();
|
|
130
|
-
|
|
131
|
-
if (options?.active !== undefined) {
|
|
132
|
-
params.append('active', String(options.active));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (options?.sanitize) {
|
|
136
|
-
params.append('sanitize', options.sanitize);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const queryString = params.toString();
|
|
140
|
-
const url = queryString ? `${this.basePath}?${queryString}` : this.basePath;
|
|
141
|
-
|
|
142
|
-
return this.apiClient.get<BusinessDTO[]>(url);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Get business by ID
|
|
147
|
-
*
|
|
148
|
-
* Endpoint: GET /businesses/{id}
|
|
149
|
-
* Auth: @ApiSecurity('projectKey')
|
|
150
|
-
*/
|
|
151
|
-
async getBusinessById(businessId: string): Promise<BusinessDTO> {
|
|
152
|
-
return this.apiClient.get<BusinessDTO>(`${this.basePath}/${businessId}`);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Get business by account address
|
|
157
|
-
*
|
|
158
|
-
* Endpoint: GET /businesses/account/{accountAddress}
|
|
159
|
-
* Auth: @ApiSecurity('projectKey')
|
|
160
|
-
*/
|
|
161
|
-
async getBusinessByAccount(accountAddress: string): Promise<BusinessDTO> {
|
|
162
|
-
return this.apiClient.get<BusinessDTO>(`${this.basePath}/account/${accountAddress}`);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ==========================================
|
|
166
|
-
// 🔧 ADMIN OPERATIONS
|
|
167
|
-
// ==========================================
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* ADMIN: Create business
|
|
171
|
-
*
|
|
172
|
-
* Endpoint: POST /businesses
|
|
173
|
-
* Auth: @TenantAdmin()
|
|
174
|
-
* Returns: BusinessApiKeyDTO | BusinessTokenBalancesDTO
|
|
175
|
-
*/
|
|
176
|
-
async createBusiness(dto: BusinessCreateRequestDTO): Promise<BusinessApiKeyDTO | BusinessTokenBalancesDTO> {
|
|
177
|
-
return this.apiClient.post<BusinessApiKeyDTO | BusinessTokenBalancesDTO>(`${this.basePath}`, dto);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* ADMIN: Create business by display name (convenience method)
|
|
182
|
-
*
|
|
183
|
-
* This is a convenience wrapper that creates the proper DTO structure
|
|
184
|
-
*/
|
|
185
|
-
async createBusinessByDisplayName(displayName: string): Promise<BusinessApiKeyDTO | BusinessTokenBalancesDTO> {
|
|
186
|
-
const dto: BusinessCreateRequestDTO = {
|
|
187
|
-
displayName,
|
|
188
|
-
// Add other required fields based on BusinessCreateRequestDTO structure
|
|
189
|
-
// You may need to check the DTO definition for required fields
|
|
190
|
-
};
|
|
191
|
-
return this.createBusiness(dto);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* ADMIN: Create businesses from URL
|
|
196
|
-
*
|
|
197
|
-
* Endpoint: POST /businesses/bulk/url
|
|
198
|
-
* Auth: @TenantAdmin()
|
|
199
|
-
*/
|
|
200
|
-
async createBusinessesFromUrl(url: string): Promise<BusinessDTO[]> {
|
|
201
|
-
return this.apiClient.post<BusinessDTO[]>(`${this.basePath}/bulk/url`, { url });
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* ADMIN: Update business
|
|
206
|
-
*
|
|
207
|
-
* Endpoint: PUT /businesses/{id}
|
|
208
|
-
* Auth: @TenantAdmin()
|
|
209
|
-
*/
|
|
210
|
-
async updateBusiness(id: string, businessData: BusinessUpdateRequestDTO): Promise<BusinessDTO> {
|
|
211
|
-
return this.apiClient.put<BusinessDTO>(`${this.basePath}/${id}`, businessData);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* ADMIN: Toggle business active status
|
|
216
|
-
*
|
|
217
|
-
* Endpoint: PUT /businesses/{id}/activate
|
|
218
|
-
* Auth: @TenantAdmin()
|
|
219
|
-
*/
|
|
220
|
-
async toggleBusinessActive(id: string, isActive: boolean): Promise<BusinessDTO> {
|
|
221
|
-
const dto: BusinessToggleActiveRequestDTO = { isActive };
|
|
222
|
-
return this.apiClient.put<BusinessDTO>(`${this.basePath}/${id}/status`, dto);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* ADMIN: Generate new business API key
|
|
227
|
-
*
|
|
228
|
-
* Endpoint: PUT /businesses/{id}/api-key
|
|
229
|
-
* Auth: @TenantAdmin()
|
|
230
|
-
*/
|
|
231
|
-
async generateNewBusinessApiKey(id: string): Promise<string> {
|
|
232
|
-
return this.apiClient.put<string>(`${this.basePath}/${id}/api-key`, {});
|
|
233
|
-
}
|
|
234
|
-
}
|
package/src/business/index.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @explorins/pers-sdk-business
|
|
3
|
-
*
|
|
4
|
-
* Platform-agnostic Business Domain SDK for PERS ecosystem
|
|
5
|
-
* Focuses on non-admin business operations
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// API Layer
|
|
9
|
-
export { BusinessApi } from './api/business-api';
|
|
10
|
-
|
|
11
|
-
// Service Layer
|
|
12
|
-
export { BusinessService } from './services/business-service';
|
|
13
|
-
|
|
14
|
-
// Models & Types - re-export all centralized interfaces
|
|
15
|
-
export * from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
16
|
-
|
|
17
|
-
import { BusinessUpdateRequestDTO } from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
18
|
-
// Factory function for creating business SDK instance
|
|
19
|
-
import { PersApiClient } from '../core/pers-api-client';
|
|
20
|
-
import { BusinessApi } from './api/business-api';
|
|
21
|
-
import { BusinessService } from './services/business-service';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Create a complete Business SDK instance
|
|
25
|
-
*
|
|
26
|
-
* @param apiClient - Configured PERS API client
|
|
27
|
-
* @returns Business SDK with flattened structure for better DX
|
|
28
|
-
*/
|
|
29
|
-
export function createBusinessSDK(apiClient: PersApiClient) {
|
|
30
|
-
const businessApi = new BusinessApi(apiClient);
|
|
31
|
-
const businessService = new BusinessService(businessApi);
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
// Direct access to service methods (primary interface)
|
|
35
|
-
getActiveBusinesses: () => businessService.getActiveBusinesses(),
|
|
36
|
-
getAllBusinessTypes: () => businessService.getAllBusinessTypes(),
|
|
37
|
-
getBusinessById: (businessId: string) => businessService.getBusinessById(businessId),
|
|
38
|
-
getBusinessByAccount: (accountAddress: string) => businessService.getBusinessByAccount(accountAddress),
|
|
39
|
-
getBusinessesByType: (typeId: string) => businessService.getBusinessesByType(typeId),
|
|
40
|
-
|
|
41
|
-
// Admin methods
|
|
42
|
-
getAllBusinesses: () => businessService.getAllBusinesses(),
|
|
43
|
-
createBusinessByDisplayName: (displayName: string) => businessService.createBusinessByDisplayName(displayName),
|
|
44
|
-
updateBusiness: (id: string, businessData: BusinessUpdateRequestDTO) => businessService.updateBusiness(id, businessData),
|
|
45
|
-
toggleBusinessActive: (id: string, isActive: boolean) => businessService.toggleBusinessActive(id, isActive),
|
|
46
|
-
|
|
47
|
-
// Advanced access for edge cases
|
|
48
|
-
api: businessApi,
|
|
49
|
-
service: businessService
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type BusinessSDK = ReturnType<typeof createBusinessSDK>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Business Domain Models
|
|
3
|
-
*
|
|
4
|
-
* Re-exports from @explorins/pers-shared for consistency with backend
|
|
5
|
-
* and to provide a single import source for business-related types.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Core business entities from centralized pers-shared interfaces
|
|
9
|
-
export type {
|
|
10
|
-
BusinessDTO,
|
|
11
|
-
BusinessTypeDTO,
|
|
12
|
-
BusinessUpdateRequestDTO
|
|
13
|
-
} from '../../shared/interfaces/pers-shared-lib.interfaces';
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { BusinessApi } from '../api/business-api';
|
|
2
|
-
import {
|
|
3
|
-
BusinessDTO,
|
|
4
|
-
BusinessTypeDTO,
|
|
5
|
-
BusinessUpdateRequestDTO
|
|
6
|
-
} from '../../shared/interfaces/pers-shared-lib.interfaces';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Platform-Agnostic Business Service
|
|
10
|
-
*
|
|
11
|
-
* Contains business logic and operations that work across platforms.
|
|
12
|
-
* No framework dependencies - pure TypeScript business logic.
|
|
13
|
-
*
|
|
14
|
-
* Focuses only on actual backend capabilities.
|
|
15
|
-
*/
|
|
16
|
-
export class BusinessService {
|
|
17
|
-
constructor(private businessApi: BusinessApi) {}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get all active businesses
|
|
21
|
-
*/
|
|
22
|
-
async getActiveBusinesses(): Promise<BusinessDTO[]> {
|
|
23
|
-
return this.businessApi.getActiveBusinesses();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get all business types
|
|
28
|
-
*/
|
|
29
|
-
async getAllBusinessTypes(): Promise<BusinessTypeDTO[]> {
|
|
30
|
-
return this.businessApi.getAllBusinessTypes();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Get business by ID
|
|
35
|
-
*/
|
|
36
|
-
async getBusinessById(businessId: string): Promise<BusinessDTO> {
|
|
37
|
-
return this.businessApi.getBusinessById(businessId);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get business by account address
|
|
42
|
-
*/
|
|
43
|
-
async getBusinessByAccount(accountAddress: string): Promise<BusinessDTO> {
|
|
44
|
-
return this.businessApi.getBusinessByAccount(accountAddress);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get businesses by type (client-side filtering)
|
|
49
|
-
*/
|
|
50
|
-
async getBusinessesByType(typeId: string): Promise<BusinessDTO[]> {
|
|
51
|
-
const businesses = await this.getActiveBusinesses();
|
|
52
|
-
return businesses.filter(business =>
|
|
53
|
-
business.businessType && business.businessType.id === parseInt(typeId)
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ==========================================
|
|
58
|
-
// ADMIN OPERATIONS
|
|
59
|
-
// ==========================================
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* ADMIN: Get all businesses (active and inactive)
|
|
63
|
-
*/
|
|
64
|
-
async getAllBusinesses(): Promise<BusinessDTO[]> {
|
|
65
|
-
return this.businessApi.getAllBusinesses();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* ADMIN: Create business by display name
|
|
70
|
-
*/
|
|
71
|
-
async createBusinessByDisplayName(displayName: string): Promise<BusinessDTO> {
|
|
72
|
-
return this.businessApi.createBusinessByDisplayName(displayName);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* ADMIN: Update business
|
|
77
|
-
*/
|
|
78
|
-
async updateBusiness(id: string, businessData: BusinessUpdateRequestDTO): Promise<BusinessDTO> {
|
|
79
|
-
return this.businessApi.updateBusiness(id, businessData);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* ADMIN: Toggle business active status
|
|
84
|
-
*/
|
|
85
|
-
async toggleBusinessActive(id: string, isActive: boolean): Promise<BusinessDTO> {
|
|
86
|
-
return this.businessApi.toggleBusinessActive(id, isActive);
|
|
87
|
-
}
|
|
88
|
-
}
|