@explorins/pers-sdk 1.0.0-alpha.1 → 1.1.2

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.
Files changed (77) hide show
  1. package/config/domains.js +22 -0
  2. package/explorins-pers-sdk-1.0.0-alpha.1.tgz +0 -0
  3. package/package.json +116 -23
  4. package/rollup.config.js +50 -54
  5. package/scripts/copy-declarations.js +147 -0
  6. package/src/analytics/api/analytics-api.ts +24 -0
  7. package/src/analytics/index.ts +52 -0
  8. package/src/analytics/models/index.ts +74 -0
  9. package/src/analytics/services/analytics-service.ts +28 -0
  10. package/src/auth-admin/api/auth-admin-api.ts +42 -0
  11. package/src/auth-admin/index.ts +47 -0
  12. package/src/auth-admin/services/auth-admin-service.ts +36 -0
  13. package/src/business/api/business-api.ts +181 -19
  14. package/src/business/index.ts +4 -3
  15. package/src/business/models/index.ts +4 -4
  16. package/src/business/services/business-service.ts +1 -1
  17. package/src/campaign/api/campaign-api.ts +376 -0
  18. package/src/campaign/index.ts +67 -0
  19. package/src/campaign/services/campaign-service.ts +164 -0
  20. package/src/core/abstractions/http-client.ts +1 -0
  21. package/src/core/auth/auth-provider.interface.ts +2 -2
  22. package/src/core/auth/create-auth-provider.ts +6 -6
  23. package/src/core/index.ts +33 -0
  24. package/src/core/pers-api-client.ts +211 -19
  25. package/src/core/pers-config.ts +34 -7
  26. package/src/core/utils/jwt.function.ts +24 -0
  27. package/src/donation/api/donation-api.ts +24 -0
  28. package/src/donation/index.ts +47 -0
  29. package/src/donation/models/index.ts +11 -0
  30. package/src/donation/services/donation-service.ts +25 -0
  31. package/src/index.ts +40 -1
  32. package/src/payment/api/payment-api.ts +185 -0
  33. package/src/payment/index.ts +64 -0
  34. package/src/payment/models/index.ts +29 -0
  35. package/src/payment/services/payment-service.ts +70 -0
  36. package/src/redemption/api/redemption-api.ts +241 -0
  37. package/src/redemption/index.ts +60 -0
  38. package/src/redemption/models/index.ts +17 -0
  39. package/src/redemption/services/redemption-service.ts +103 -0
  40. package/src/shared/interfaces/pers-shared-lib.interfaces.ts +99 -0
  41. package/src/tenant/api/tenant-api.ts +92 -0
  42. package/src/tenant/index.ts +61 -0
  43. package/src/tenant/models/index.ts +20 -0
  44. package/src/tenant/services/tenant-service.ts +78 -0
  45. package/src/token/api/token-api.ts +129 -0
  46. package/src/token/base/base-token-service.ts +167 -0
  47. package/src/token/index.ts +38 -0
  48. package/src/token/models/index.ts +30 -0
  49. package/src/token/services/token-service.ts +125 -0
  50. package/src/token/token-sdk.ts +231 -0
  51. package/src/transaction/api/transaction-api.ts +296 -0
  52. package/src/transaction/index.ts +65 -0
  53. package/src/transaction/models/index.ts +60 -0
  54. package/src/transaction/services/transaction-service.ts +104 -0
  55. package/src/user/api/user-api.ts +98 -0
  56. package/src/user/index.ts +62 -0
  57. package/src/user/models/index.ts +10 -0
  58. package/src/user/services/user-service.ts +75 -0
  59. package/src/user-status/api/user-status-api.ts +78 -0
  60. package/src/user-status/index.ts +55 -0
  61. package/src/user-status/models/index.ts +11 -0
  62. package/src/user-status/services/user-status-service.ts +51 -0
  63. package/src/web3/api/web3-api.ts +68 -0
  64. package/src/web3/index.ts +38 -0
  65. package/src/web3/models/index.ts +150 -0
  66. package/src/web3/services/web3-service.ts +338 -0
  67. package/src/web3-chain/api/web3-chain-api.ts +42 -0
  68. package/src/web3-chain/index.ts +27 -0
  69. package/src/web3-chain/models/index.ts +45 -0
  70. package/src/web3-chain/services/getWeb3FCD.service.ts +47 -0
  71. package/src/web3-chain/services/provider.service.ts +123 -0
  72. package/src/web3-chain/services/public-http-provider.service.ts +26 -0
  73. package/src/web3-chain/services/web3-chain-service.ts +131 -0
  74. package/src/business/business/tsconfig.json +0 -18
  75. package/src/core/abstractions/core-interfaces.ts +0 -56
  76. package/src/core/core.ts +0 -30
  77. package/src/core.ts +0 -30
@@ -0,0 +1,103 @@
1
+ import { RedemptionApi } from '../api/redemption-api';
2
+ import {
3
+ RedemptionCreateRequestDTO,
4
+ RedemptionDTO,
5
+ RedemptionTypeDTO,
6
+ RedemptionUserRedeemDetailedDTO,
7
+ RedemptionUserRedeemDTO
8
+ } from '@explorins/pers-shared';
9
+ import { TokenUnitCreateRequestDTO } from '../../campaign'; // ✅ CORRECTED: Proper cross-domain import
10
+
11
+ /**
12
+ * Platform-Agnostic Redemption Service
13
+ *
14
+ * Contains redemption business logic and operations that work across platforms.
15
+ * No framework dependencies - pure TypeScript business logic.
16
+ *
17
+ * Focuses only on actual backend capabilities.
18
+ */
19
+ export class RedemptionService {
20
+ constructor(private redemptionApi: RedemptionApi) {}
21
+
22
+ // ==========================================
23
+ // PUBLIC OPERATIONS
24
+ // ==========================================
25
+
26
+ /**
27
+ * PUBLIC: Get active redemptions
28
+ */
29
+ async getActiveRedemptions(): Promise<RedemptionDTO[]> {
30
+ return this.redemptionApi.getActiveRedemptions();
31
+ }
32
+
33
+ /**
34
+ * PUBLIC: Get redemption types
35
+ */
36
+ async getRedemptionTypes(): Promise<RedemptionTypeDTO[]> {
37
+ return this.redemptionApi.getRedemptionTypes();
38
+ }
39
+
40
+ // ==========================================
41
+ // AUTHENTICATED OPERATIONS
42
+ // ==========================================
43
+
44
+ /**
45
+ * AUTH: Redeem a redemption
46
+ */
47
+ async redeemRedemption(redemptionId: string): Promise<RedemptionUserRedeemDetailedDTO> {
48
+ return this.redemptionApi.redeemRedemption(redemptionId);
49
+ }
50
+
51
+ /**
52
+ * AUTH: Get user redemptions
53
+ */
54
+ async getUserRedeems(): Promise<RedemptionUserRedeemDTO[]> {
55
+ return this.redemptionApi.getUserRedeems();
56
+ }
57
+
58
+ // ==========================================
59
+ // ADMIN OPERATIONS
60
+ // ==========================================
61
+
62
+ /**
63
+ * ADMIN: Get redemptions with optional active filter
64
+ */
65
+ async getRedemptionsAsAdmin(active?: boolean): Promise<RedemptionDTO[]> {
66
+ return this.redemptionApi.getRedemptionsAsAdmin(active);
67
+ }
68
+
69
+ /**
70
+ * ADMIN: Create redemption
71
+ */
72
+ async createRedemption(redemption: RedemptionCreateRequestDTO): Promise<RedemptionDTO> {
73
+ return this.redemptionApi.createRedemption(redemption);
74
+ }
75
+
76
+ /**
77
+ * ADMIN: Update redemption
78
+ */
79
+ async updateRedemption(id: string, redemptionCreateRequest: RedemptionCreateRequestDTO): Promise<RedemptionDTO> {
80
+ return this.redemptionApi.updateRedemption(id, redemptionCreateRequest); // ✅ CORRECTED: Fixed parameter
81
+ }
82
+
83
+ /**
84
+ * ADMIN: Toggle redemption active status
85
+ */
86
+ async toggleRedemptionActive(redemptionId: string): Promise<RedemptionDTO> {
87
+ return this.redemptionApi.toggleRedemptionActive(redemptionId);
88
+ }
89
+
90
+ /**
91
+ * ADMIN: Create redemption token unit
92
+ */
93
+ async createRedemptionTokenUnit(redemptionId: string, redemptionTokenUnit: TokenUnitCreateRequestDTO): Promise<RedemptionDTO> {
94
+ return this.redemptionApi.createRedemptionTokenUnit(redemptionId, redemptionTokenUnit);
95
+ }
96
+
97
+ /**
98
+ * ADMIN: Delete redemption token unit
99
+ */
100
+ async deleteRedemptionTokenUnit(redemptionId: string, redemptionTokenUnitId: string): Promise<RedemptionDTO> {
101
+ return this.redemptionApi.deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId);
102
+ }
103
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Centralized PERS Shared Library Interfaces
3
+ *
4
+ * Single source of truth for all @explorins/pers-shared type exports
5
+ * used throughout the PERS SDK. This ensures consistent type usage
6
+ * and makes it easier to manage dependencies.
7
+ */
8
+
9
+ // Auth Admin Domain
10
+ export {
11
+ type AdminDTO,
12
+ type SessionAuthResponseDTO
13
+ } from '@explorins/pers-shared';
14
+
15
+ // Business Domain
16
+ export {
17
+ type BusinessDTO,
18
+ type BusinessTypeDTO,
19
+ type BusinessUpdateRequestDTO,
20
+ type BusinessCreateRequestDTO,
21
+ type BusinessToggleActiveRequestDTO,
22
+ type BusinessApiKeyDTO,
23
+ type BusinessTokenBalancesDTO,
24
+ type BusinessTypeCreateRequestDTO
25
+ } from '@explorins/pers-shared';
26
+
27
+ // Campaign Domain
28
+ export {
29
+ type CampaignDTO,
30
+ type CampaignCreateRequestDTO,
31
+ type CampaignUserClaimDTO,
32
+ type CampaignClaimRequestDTO,
33
+ type CampaignTriggerDTO,
34
+ type CampaignBusinessEngagementCreateRequestDTO,
35
+ type TokenUnitCreateRequestDTO,
36
+ type CampaignTriggerType
37
+ } from '@explorins/pers-shared';
38
+
39
+ // Donation Domain
40
+ export {
41
+ type DonationTypeDTO
42
+ } from '@explorins/pers-shared';
43
+
44
+ // Payment Domain
45
+ export {
46
+ type UserDTO,
47
+ type PurchaseDTO,
48
+ type PurchaseTokenDTO,
49
+ type PurchaseTypeDTO,
50
+ type PaymentIntentDTO,
51
+ type PurchaseCreateRequestDTO,
52
+ type PurchaseCreateResponseDTO,
53
+ type PaymentIntentCreateDTO,
54
+ type PurchaseCurrency
55
+ } from '@explorins/pers-shared';
56
+
57
+ // Redemption Domain
58
+ export {
59
+ type RedemptionDTO,
60
+ type RedemptionCreateRequestDTO,
61
+ type RedemptionRedeemRequestDTO,
62
+ type RedemptionTypeDTO,
63
+ type RedemptionTypeCreateRequestDTO,
64
+ type RedemptionUserRedeemDTO,
65
+ type RedemptionUserRedeemDetailedDTO
66
+ } from '@explorins/pers-shared';
67
+
68
+ // Tenant Domain
69
+ export {
70
+ type TenantClientConfigDTO,
71
+ type TenantDTO,
72
+ type TenantPublicDTO
73
+ } from '@explorins/pers-shared';
74
+
75
+ // Token Domain
76
+ export {
77
+ type TokenMetadataDTO,
78
+ type TokenDTO,
79
+ type TokenCreateRequestDTO,
80
+ type TokenUpdateRequestDTO,
81
+ type TokenStorageData,
82
+ type TokenTypeDTO
83
+ } from '@explorins/pers-shared';
84
+
85
+ // Transaction Domain
86
+ export {
87
+ type TransactionDTO,
88
+ type TransactionRequestDTO,
89
+ type ClientTransactionRequestDTO,
90
+ type ClientTransactionRequestResponseDto,
91
+ type UserToBusinessTokenTransactionCreateRequestDTO,
92
+ type AccountSelectorDTO
93
+ } from '@explorins/pers-shared';
94
+
95
+ // User Domain
96
+ export {
97
+ type UserCreateRequestDTO,
98
+ type UserStatusTypeDTO
99
+ } from '@explorins/pers-shared';
@@ -0,0 +1,92 @@
1
+ import {
2
+ AdminDTO,
3
+ TenantPublicDTO,
4
+ TenantClientConfigDTO
5
+ } from '../../shared/interfaces/pers-shared-lib.interfaces';
6
+ import { PersApiClient } from '../../core/pers-api-client';
7
+
8
+ // Local interfaces
9
+ interface AdminCreateRequestDTO {
10
+ [key: string]: any;
11
+ }
12
+
13
+ /**
14
+ * Platform-Agnostic Tenant API Client
15
+ *
16
+ * Handles tenant and admin operations using the PERS backend.
17
+ * Matches framework TenantApiService methods exactly.
18
+ *
19
+ * Note: Special header handling (bypass-auth-interceptor) should be handled by PersApiClient internally
20
+ * or through endpoint-specific configuration.
21
+ */
22
+ export class TenantApi {
23
+ constructor(private apiClient: PersApiClient) {}
24
+
25
+ private basePath = '/tenants';
26
+ private adminPath = '/admins';
27
+
28
+ // ==========================================
29
+ // PUBLIC OPERATIONS
30
+ // ==========================================
31
+
32
+ /**
33
+ * PUBLIC: Get tenant public information
34
+ * ✅ FIXED: Matches framework cache busting pattern exactly
35
+ */
36
+ async getRemoteTenant(): Promise<TenantPublicDTO> {
37
+ const timestamp = Date.now().toString();
38
+ const url = `${this.basePath}/public?date=${timestamp}`;
39
+ return this.apiClient.get<TenantPublicDTO>(url);
40
+ }
41
+
42
+ /**
43
+ * PUBLIC: Get remote login token
44
+ */
45
+ async getRemoteLoginToken(): Promise<string> {
46
+ return this.apiClient.get<string>(`${this.basePath}/login-token`);
47
+ }
48
+
49
+ /**
50
+ * PUBLIC: Get remote client configuration
51
+ * ✅ FIXED: Removed second parameter - PersApiClient handles bypass auth internally
52
+ * Note: The /tenants/client-config endpoint should be configured to bypass auth at the API client level
53
+ */
54
+ async getRemoteClientConfig(): Promise<TenantClientConfigDTO> {
55
+ return this.apiClient.get<TenantClientConfigDTO>(`${this.basePath}/client-config`);
56
+ }
57
+
58
+ // ==========================================
59
+ // ADMIN OPERATIONS
60
+ // ==========================================
61
+
62
+ /**
63
+ * ADMIN: Update tenant information
64
+ * ✅ FIXED: Uses TenantPublicDTO directly like framework
65
+ */
66
+ async updateRemoteTenant(tenantData: TenantPublicDTO): Promise<TenantPublicDTO> {
67
+ return this.apiClient.put<TenantPublicDTO>(`${this.basePath}`, tenantData);
68
+ }
69
+
70
+ /**
71
+ * ADMIN: Get all tenant admins
72
+ */
73
+ async getAdmins(): Promise<AdminDTO[]> {
74
+ return this.apiClient.get<AdminDTO[]>(`${this.adminPath}`);
75
+ }
76
+
77
+ /**
78
+ * ADMIN: Create new admin
79
+ * ✅ FIXED: Renamed to match framework postAdmin method
80
+ */
81
+ async postAdmin(adminData: AdminCreateRequestDTO): Promise<AdminDTO> {
82
+ return this.apiClient.post<AdminDTO>(`${this.adminPath}`, adminData);
83
+ }
84
+
85
+ /**
86
+ * ADMIN: Update admin (toggle tenant association)
87
+ * ✅ FIXED: Renamed to match framework putAdmin method
88
+ */
89
+ async putAdmin(adminId: string, adminData: AdminCreateRequestDTO): Promise<AdminDTO> {
90
+ return this.apiClient.put<AdminDTO>(`${this.adminPath}/${adminId}/tenant`, adminData);
91
+ }
92
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @explorins/pers-sdk-tenant
3
+ *
4
+ * Platform-agnostic Tenant Domain SDK for PERS ecosystem
5
+ * Handles tenant management and admin operations for multi-tenant architecture
6
+ */
7
+
8
+ // API Layer
9
+ export { TenantApi } from './api/tenant-api';
10
+
11
+ // Service Layer
12
+ export { TenantService } from './services/tenant-service';
13
+
14
+ // Models & Types
15
+ export * from './models';
16
+ export * from '../shared/interfaces/pers-shared-lib.interfaces';
17
+
18
+ // Models & Types
19
+ export * from './models';
20
+
21
+ // Factory function for creating tenant SDK instance
22
+ import { PersApiClient } from '../core/pers-api-client';
23
+ import { TenantApi } from './api/tenant-api';
24
+ import { TenantService } from './services/tenant-service';
25
+ import { TenantPublicDTO, AdminCreateRequestDTO } from './models';
26
+
27
+ /**
28
+ * Create a complete Tenant SDK instance
29
+ *
30
+ * @param apiClient - Configured PERS API client
31
+ * @returns Tenant SDK with flattened structure for better DX
32
+ */
33
+ export function createTenantSDK(apiClient: PersApiClient) {
34
+ const tenantApi = new TenantApi(apiClient);
35
+ const tenantService = new TenantService(tenantApi);
36
+
37
+ return {
38
+ // Direct access to service methods (primary interface)
39
+ // ✅ FRAMEWORK ALIGNED: Only methods actually used by framework
40
+
41
+ // Public methods
42
+ getRemoteTenant: () => tenantService.getRemoteTenant(),
43
+ getRemoteLoginToken: () => tenantService.getRemoteLoginToken(),
44
+ getRemoteClientConfig: () => tenantService.getRemoteClientConfig(),
45
+
46
+ // Admin methods - ✅ FIXED: Matches framework method names exactly
47
+ updateRemoteTenant: (tenantData: TenantPublicDTO) =>
48
+ tenantService.updateRemoteTenant(tenantData),
49
+ getAdmins: () => tenantService.getAdmins(),
50
+ postAdmin: (adminData: AdminCreateRequestDTO) =>
51
+ tenantService.postAdmin(adminData),
52
+ putAdmin: (adminId: string, adminData: AdminCreateRequestDTO) =>
53
+ tenantService.putAdmin(adminId, adminData),
54
+
55
+ // Advanced access for edge cases
56
+ api: tenantApi,
57
+ service: tenantService
58
+ };
59
+ }
60
+
61
+ export type TenantSDK = ReturnType<typeof createTenantSDK>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Tenant Domain Models
3
+ *
4
+ * Re-exports from centralized pers-shared interfaces for consistency with backend
5
+ * and to provide a single import source for tenant-related types.
6
+ */
7
+
8
+ // Core tenant entities from centralized pers-shared interfaces
9
+ export type {
10
+ TenantClientConfigDTO,
11
+ TenantDTO,
12
+ TenantPublicDTO,
13
+ AdminDTO
14
+ } from '../../shared/interfaces/pers-shared-lib.interfaces';
15
+
16
+ // Local tenant interfaces
17
+ export interface AdminCreateRequestDTO {
18
+ // Add properties as needed
19
+ [key: string]: any;
20
+ }
@@ -0,0 +1,78 @@
1
+ import { AdminDTO } from '../../shared/interfaces/pers-shared-lib.interfaces';
2
+ import { TenantApi } from '../api/tenant-api';
3
+ import {
4
+ TenantPublicDTO,
5
+ TenantClientConfigDTO,
6
+ AdminCreateRequestDTO
7
+ } from '../models';
8
+
9
+ /**
10
+ * Platform-Agnostic Tenant Service
11
+ *
12
+ * Contains tenant business logic and operations that work across platforms.
13
+ * No framework dependencies - pure TypeScript business logic.
14
+ * Matches framework TenantApiService capabilities exactly.
15
+ */
16
+ export class TenantService {
17
+ constructor(private tenantApi: TenantApi) {}
18
+
19
+ // ==========================================
20
+ // PUBLIC OPERATIONS
21
+ // ==========================================
22
+
23
+ /**
24
+ * PUBLIC: Get tenant public information
25
+ */
26
+ async getRemoteTenant(): Promise<TenantPublicDTO> {
27
+ return this.tenantApi.getRemoteTenant();
28
+ }
29
+
30
+ /**
31
+ * PUBLIC: Get remote login token
32
+ */
33
+ async getRemoteLoginToken(): Promise<string> {
34
+ return this.tenantApi.getRemoteLoginToken();
35
+ }
36
+
37
+ /**
38
+ * PUBLIC: Get remote client configuration
39
+ */
40
+ async getRemoteClientConfig(): Promise<TenantClientConfigDTO> {
41
+ return this.tenantApi.getRemoteClientConfig();
42
+ }
43
+
44
+ // ==========================================
45
+ // ADMIN OPERATIONS
46
+ // ==========================================
47
+
48
+ /**
49
+ * ADMIN: Update tenant information
50
+ * ✅ FIXED: Uses TenantPublicDTO directly like framework
51
+ */
52
+ async updateRemoteTenant(tenantData: TenantPublicDTO): Promise<TenantPublicDTO> {
53
+ return this.tenantApi.updateRemoteTenant(tenantData);
54
+ }
55
+
56
+ /**
57
+ * ADMIN: Get all tenant admins
58
+ */
59
+ async getAdmins(): Promise<AdminDTO[]> {
60
+ return this.tenantApi.getAdmins();
61
+ }
62
+
63
+ /**
64
+ * ADMIN: Create new admin
65
+ * ✅ FIXED: Renamed to match framework postAdmin method
66
+ */
67
+ async postAdmin(adminData: AdminCreateRequestDTO): Promise<AdminDTO> {
68
+ return this.tenantApi.postAdmin(adminData);
69
+ }
70
+
71
+ /**
72
+ * ADMIN: Update admin (toggle tenant association)
73
+ * ✅ FIXED: Renamed to match framework putAdmin method
74
+ */
75
+ async putAdmin(adminId: string, adminData: AdminCreateRequestDTO): Promise<AdminDTO> {
76
+ return this.tenantApi.putAdmin(adminId, adminData);
77
+ }
78
+ }
@@ -0,0 +1,129 @@
1
+ import { PersApiClient } from '../../core/pers-api-client';
2
+ import {
3
+ TokenDTO,
4
+ TokenTypeDTO,
5
+ TokenCreateRequestDTO,
6
+ TokenStorageData,
7
+ TokenUpdateRequestDTO,
8
+ TokenMetadataDTO
9
+ } from '../models';
10
+
11
+
12
+ export class TokenApi {
13
+ constructor(private apiClient: PersApiClient) {}
14
+
15
+ private basePath = '/tokens';
16
+
17
+ // ==========================================
18
+ // PUBLIC OPERATIONS
19
+ // ==========================================
20
+
21
+ /**
22
+ * PUBLIC: Get all remote tokens
23
+ * ENHANCED: Added admin filtering capability
24
+ */
25
+ async getRemoteTokens(includeInactive: boolean = false): Promise<TokenDTO[]> {
26
+ const url = includeInactive ? `${this.basePath}?active=false` : `${this.basePath}`;
27
+ return this.apiClient.get<TokenDTO[]>(url);
28
+ }
29
+
30
+ /**
31
+ * PUBLIC: Get all remote token types
32
+ */
33
+ async getRemoteTokenTypes(): Promise<TokenTypeDTO[]> {
34
+ return this.apiClient.get<TokenTypeDTO[]>(`${this.basePath}/types`);
35
+ }
36
+
37
+ /**
38
+ * PUBLIC: Get active point token (was credit token)
39
+ */
40
+ async getRemoteActiveCreditToken(): Promise<TokenDTO> {
41
+ return this.apiClient.get<TokenDTO>(`${this.basePath}/points`);
42
+ }
43
+
44
+ /**
45
+ * PUBLIC: Get reward tokens
46
+ * ENHANCED: Added admin filtering capability
47
+ */
48
+ async getRemoteRewardTokens(includeInactive: boolean = false): Promise<TokenDTO[]> {
49
+ const url = includeInactive ? `${this.basePath}/rewards?active=false` : `${this.basePath}/rewards`;
50
+ return this.apiClient.get<TokenDTO[]>(url);
51
+ }
52
+
53
+ /**
54
+ * PUBLIC: Get stamp tokens (was status tokens)
55
+ * ENHANCED: Added admin filtering capability
56
+ */
57
+ async getRemoteStatusTokens(includeInactive: boolean = false): Promise<TokenDTO[]> {
58
+ const url = includeInactive ? `${this.basePath}/stamps?active=false` : `${this.basePath}/stamps`;
59
+ return this.apiClient.get<TokenDTO[]>(url);
60
+ }
61
+
62
+ /**
63
+ * PUBLIC: Get token by contract address
64
+ */
65
+ async getTokenByContractAddress(contractAddress: string, contractTokenId: string | null): Promise<TokenDTO> {
66
+ let url = `${this.basePath}/address/${contractAddress}`;
67
+ if (contractTokenId) {
68
+ url += `?contractTokenId=${contractTokenId}`;
69
+ }
70
+ return this.apiClient.get<TokenDTO>(url);
71
+ }
72
+
73
+ // ==========================================
74
+ // ADMIN OPERATIONS
75
+ // ==========================================
76
+
77
+ /**
78
+ * ADMIN: Create new token
79
+ */
80
+ async createToken(tokenData: TokenCreateRequestDTO): Promise<TokenDTO> {
81
+ return this.apiClient.post<TokenDTO>(`${this.basePath}`, tokenData);
82
+ }
83
+
84
+ /**
85
+ * ADMIN: Update token
86
+ */
87
+ async updateToken(tokenId: string, tokenData: TokenUpdateRequestDTO): Promise<TokenDTO> {
88
+ return this.apiClient.put<TokenDTO>(`${this.basePath}/${tokenId}`, tokenData);
89
+ }
90
+
91
+ /**
92
+ * ADMIN: Toggle token active status
93
+ * FIXED: Now calls correct endpoint
94
+ */
95
+ async toggleTokenActive(tokenId: string): Promise<TokenDTO> {
96
+ return this.apiClient.put<TokenDTO>(`${this.basePath}/${tokenId}/status`, {});
97
+ }
98
+
99
+ /**
100
+ * ADMIN: Set mainnet contract address
101
+ */
102
+ async setMainnetContract(tokenId: string, contractAddress: string, chainId: number): Promise<TokenDTO> {
103
+ return this.apiClient.put<TokenDTO>(`${this.basePath}/${tokenId}/mainnet`, {
104
+ contractAddress,
105
+ chainId
106
+ });
107
+ }
108
+
109
+ /**
110
+ * ADMIN: Create token metadata
111
+ */
112
+ async createTokenMetadata(tokenId: string, tokenData: TokenStorageData): Promise<TokenDTO> {
113
+ return this.apiClient.post<TokenDTO>(`${this.basePath}/${tokenId}/metadata`, tokenData);
114
+ }
115
+
116
+ /**
117
+ * ADMIN: Toggle token metadata status (separate from token status)
118
+ */
119
+ async toggleTokenMetadataStatus(metadataId: string): Promise<TokenMetadataDTO> {
120
+ return this.apiClient.put<TokenMetadataDTO>(`${this.basePath}/metadata/${metadataId}/status`, {});
121
+ }
122
+
123
+ /**
124
+ * ADMIN: Create token type
125
+ */
126
+ async createTokenType(tokenType: TokenTypeDTO): Promise<TokenTypeDTO> {
127
+ return this.apiClient.post<TokenTypeDTO>(`${this.basePath}/types`, tokenType);
128
+ }
129
+ }