@explorins/pers-sdk 1.6.4 → 1.6.6
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/README.md +63 -37
- package/dist/analytics/index.d.ts +0 -16
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics.cjs +5 -73
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +1 -72
- package/dist/analytics.js.map +1 -1
- package/dist/business/index.d.ts +0 -24
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business.cjs +5 -273
- package/dist/business.cjs.map +1 -1
- package/dist/business.js +1 -272
- package/dist/business.js.map +1 -1
- package/dist/campaign/api/campaign-api.d.ts +3 -3
- package/dist/campaign/api/campaign-api.d.ts.map +1 -1
- package/dist/campaign/index.d.ts +0 -34
- package/dist/campaign/index.d.ts.map +1 -1
- package/dist/campaign.cjs +5 -447
- package/dist/campaign.cjs.map +1 -1
- package/dist/campaign.js +1 -446
- package/dist/campaign.js.map +1 -1
- package/dist/chunks/analytics-service-CitlimKJ.cjs +49 -0
- package/dist/chunks/analytics-service-CitlimKJ.cjs.map +1 -0
- package/dist/chunks/analytics-service-CxyrOwel.js +46 -0
- package/dist/chunks/analytics-service-CxyrOwel.js.map +1 -0
- package/dist/chunks/{token-sdk-BW4kkJb3.js → base-token-service-BSXDwrcq.js} +138 -204
- package/dist/chunks/base-token-service-BSXDwrcq.js.map +1 -0
- package/dist/chunks/{token-sdk-CiAbOb6c.cjs → base-token-service-CYuqPPs0.cjs} +140 -207
- package/dist/chunks/base-token-service-CYuqPPs0.cjs.map +1 -0
- package/dist/chunks/business-service-Cq3-oksM.cjs +241 -0
- package/dist/chunks/business-service-Cq3-oksM.cjs.map +1 -0
- package/dist/chunks/business-service-DrC-TNGa.js +238 -0
- package/dist/chunks/business-service-DrC-TNGa.js.map +1 -0
- package/dist/chunks/campaign-service-CWK9I388.cjs +403 -0
- package/dist/chunks/campaign-service-CWK9I388.cjs.map +1 -0
- package/dist/chunks/campaign-service-Dd7gMjC9.js +400 -0
- package/dist/chunks/campaign-service-Dd7gMjC9.js.map +1 -0
- package/dist/chunks/donation-service-CyJS4DIZ.js +47 -0
- package/dist/chunks/donation-service-CyJS4DIZ.js.map +1 -0
- package/dist/chunks/donation-service-D-xFrONi.cjs +50 -0
- package/dist/chunks/donation-service-D-xFrONi.cjs.map +1 -0
- package/dist/chunks/{index-CJ9Jfa4A.js → explorer.utils-Ckll15ja.js} +108 -172
- package/dist/chunks/explorer.utils-Ckll15ja.js.map +1 -0
- package/dist/chunks/{index-CzEluQmf.cjs → explorer.utils-GpskbLl1.cjs} +106 -174
- package/dist/chunks/explorer.utils-GpskbLl1.cjs.map +1 -0
- package/dist/chunks/index-BtDNXaFq.js +13 -0
- package/dist/chunks/index-BtDNXaFq.js.map +1 -0
- package/dist/chunks/index-CMk3Aqkk.cjs +15 -0
- package/dist/chunks/index-CMk3Aqkk.cjs.map +1 -0
- package/dist/chunks/payment-service-B4qx0qiE.cjs +220 -0
- package/dist/chunks/payment-service-B4qx0qiE.cjs.map +1 -0
- package/dist/chunks/payment-service-DfCBFosx.js +217 -0
- package/dist/chunks/payment-service-DfCBFosx.js.map +1 -0
- package/dist/chunks/pers-sdk-CajYwGkL.cjs +5850 -0
- package/dist/chunks/pers-sdk-CajYwGkL.cjs.map +1 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js +5817 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js.map +1 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs +330 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs.map +1 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js +327 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js.map +1 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs +171 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs.map +1 -0
- package/dist/chunks/tenant-service-DELk412y.js +168 -0
- package/dist/chunks/tenant-service-DELk412y.js.map +1 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs +208 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs.map +1 -0
- package/dist/chunks/token-service-CpVwC5Eb.js +205 -0
- package/dist/chunks/token-service-CpVwC5Eb.js.map +1 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs +153 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs.map +1 -0
- package/dist/chunks/user-service-D6mTa_WZ.js +150 -0
- package/dist/chunks/user-service-D6mTa_WZ.js.map +1 -0
- package/dist/chunks/{index-BfOoX87y.cjs → web3-chain-service-BYkj61DN.cjs} +1 -33
- package/dist/chunks/web3-chain-service-BYkj61DN.cjs.map +1 -0
- package/dist/chunks/{index-CM21r58m.js → web3-chain-service-DN6tJmvK.js} +2 -31
- package/dist/chunks/web3-chain-service-DN6tJmvK.js.map +1 -0
- package/dist/core/auth/auth-provider.interface.d.ts +32 -69
- package/dist/core/auth/auth-provider.interface.d.ts.map +1 -1
- package/dist/core/auth/default-auth-provider.d.ts +15 -58
- package/dist/core/auth/default-auth-provider.d.ts.map +1 -1
- package/dist/core/auth/index.d.ts +10 -12
- package/dist/core/auth/index.d.ts.map +1 -1
- package/dist/core/auth/refresh-manager.d.ts +18 -0
- package/dist/core/auth/refresh-manager.d.ts.map +1 -0
- package/dist/core/auth/services/auth-service.d.ts +11 -6
- package/dist/core/auth/services/auth-service.d.ts.map +1 -1
- package/dist/core/auth/token-storage.d.ts +27 -47
- package/dist/core/auth/token-storage.d.ts.map +1 -1
- package/dist/core/errors/index.d.ts +1 -5
- package/dist/core/errors/index.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts +10 -126
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core/pers-config.d.ts +8 -3
- package/dist/core/pers-config.d.ts.map +1 -1
- package/dist/core/utils/jwt.function.d.ts.map +1 -1
- package/dist/core.cjs +22 -17
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +13 -13
- package/dist/donation/index.d.ts +0 -15
- package/dist/donation/index.d.ts.map +1 -1
- package/dist/donation.cjs +5 -75
- package/dist/donation.cjs.map +1 -1
- package/dist/donation.js +1 -74
- package/dist/donation.js.map +1 -1
- package/dist/index.cjs +51 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/managers/analytics-manager.d.ts +290 -10
- package/dist/managers/analytics-manager.d.ts.map +1 -1
- package/dist/managers/auth-manager.d.ts +123 -23
- package/dist/managers/auth-manager.d.ts.map +1 -1
- package/dist/managers/business-manager.d.ts +273 -18
- package/dist/managers/business-manager.d.ts.map +1 -1
- package/dist/managers/campaign-manager.d.ts +585 -46
- package/dist/managers/campaign-manager.d.ts.map +1 -1
- package/dist/managers/donation-manager.d.ts +5 -5
- package/dist/managers/donation-manager.d.ts.map +1 -1
- package/dist/managers/file-manager.d.ts +430 -13
- package/dist/managers/file-manager.d.ts.map +1 -1
- package/dist/managers/purchase-manager.d.ts +340 -15
- package/dist/managers/purchase-manager.d.ts.map +1 -1
- package/dist/managers/redemption-manager.d.ts +450 -27
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/tenant-manager.d.ts +5 -5
- package/dist/managers/tenant-manager.d.ts.map +1 -1
- package/dist/managers/token-manager.d.ts +245 -21
- package/dist/managers/token-manager.d.ts.map +1 -1
- package/dist/managers/transaction-manager.d.ts +447 -18
- package/dist/managers/transaction-manager.d.ts.map +1 -1
- package/dist/managers/user-manager.d.ts +216 -14
- package/dist/managers/user-manager.d.ts.map +1 -1
- package/dist/managers/web3-manager.d.ts +4 -4
- package/dist/managers/web3-manager.d.ts.map +1 -1
- package/dist/package.json +9 -2
- package/dist/payment/index.d.ts +0 -21
- package/dist/payment/index.d.ts.map +1 -1
- package/dist/payment.cjs +5 -255
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +1 -254
- package/dist/payment.js.map +1 -1
- package/dist/pers-sdk.d.ts +141 -34
- package/dist/pers-sdk.d.ts.map +1 -1
- package/dist/redemption/index.d.ts +0 -25
- package/dist/redemption/index.d.ts.map +1 -1
- package/dist/redemption.cjs +5 -365
- package/dist/redemption.cjs.map +1 -1
- package/dist/redemption.js +1 -364
- package/dist/redemption.js.map +1 -1
- package/dist/tenant/index.d.ts +0 -22
- package/dist/tenant/index.d.ts.map +1 -1
- package/dist/tenant.cjs +5 -203
- package/dist/tenant.cjs.map +1 -1
- package/dist/tenant.js +1 -202
- package/dist/tenant.js.map +1 -1
- package/dist/token.cjs +6 -6
- package/dist/token.js +2 -2
- package/dist/transaction/index.d.ts +0 -22
- package/dist/transaction/index.d.ts.map +1 -1
- package/dist/transaction.cjs +0 -40
- package/dist/transaction.cjs.map +1 -1
- package/dist/transaction.js +1 -40
- package/dist/transaction.js.map +1 -1
- package/dist/user/index.d.ts +0 -25
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user.cjs +5 -185
- package/dist/user.cjs.map +1 -1
- package/dist/user.js +1 -184
- package/dist/user.js.map +1 -1
- package/dist/web3/index.d.ts +0 -11
- package/dist/web3/index.d.ts.map +1 -1
- package/dist/web3-chain/index.d.ts +0 -9
- package/dist/web3-chain/index.d.ts.map +1 -1
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts.map +1 -1
- package/dist/web3-chain.cjs +5 -5
- package/dist/web3-chain.js +2 -1
- package/dist/web3-chain.js.map +1 -1
- package/dist/web3.cjs +6 -10
- package/dist/web3.cjs.map +1 -1
- package/dist/web3.js +1 -4
- package/dist/web3.js.map +1 -1
- package/package.json +9 -2
- package/dist/chunks/base-token-service-D0KANDgM.js +0 -139
- package/dist/chunks/base-token-service-D0KANDgM.js.map +0 -1
- package/dist/chunks/base-token-service-zNfPjHRx.cjs +0 -141
- package/dist/chunks/base-token-service-zNfPjHRx.cjs.map +0 -1
- package/dist/chunks/index-BfOoX87y.cjs.map +0 -1
- package/dist/chunks/index-CJ9Jfa4A.js.map +0 -1
- package/dist/chunks/index-CM21r58m.js.map +0 -1
- package/dist/chunks/index-CzEluQmf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs +0 -3378
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-Z6MKeFBX.js +0 -3353
- package/dist/chunks/pers-sdk-Z6MKeFBX.js.map +0 -1
- package/dist/chunks/token-sdk-BW4kkJb3.js.map +0 -1
- package/dist/chunks/token-sdk-CiAbOb6c.cjs.map +0 -1
- package/dist/core/auth/auth-constants.d.ts +0 -33
- package/dist/core/auth/auth-constants.d.ts.map +0 -1
- package/dist/core/auth/auth-errors.d.ts +0 -8
- package/dist/core/auth/auth-errors.d.ts.map +0 -1
- package/dist/core/auth/create-auth-provider.d.ts +0 -27
- package/dist/core/auth/create-auth-provider.d.ts.map +0 -1
- package/dist/core/auth/token-refresh.d.ts +0 -91
- package/dist/core/auth/token-refresh.d.ts.map +0 -1
|
@@ -1,62 +1,491 @@
|
|
|
1
1
|
import { PersApiClient } from '../core/pers-api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { TransactionService } from '../transaction';
|
|
3
3
|
import type { TransactionDTO, TransactionRequestDTO } from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
4
4
|
import type { TransactionPaginationParams } from '../transaction/models';
|
|
5
5
|
/**
|
|
6
6
|
* Transaction Manager - Clean, high-level interface for transaction operations
|
|
7
7
|
*
|
|
8
|
-
* Provides a
|
|
9
|
-
*
|
|
8
|
+
* Provides a comprehensive API for loyalty transaction management including transaction
|
|
9
|
+
* creation, history tracking, reporting, and administrative oversight. Transactions
|
|
10
|
+
* are the core financial operations that track token movements, purchases, rewards,
|
|
11
|
+
* and all value exchanges within the loyalty ecosystem.
|
|
12
|
+
*
|
|
13
|
+
* @group Managers
|
|
14
|
+
* @category Transaction Management
|
|
15
|
+
*
|
|
16
|
+
* @example Basic Transaction Operations
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Create a purchase transaction
|
|
19
|
+
* const transaction = await sdk.transactions.createTransaction({
|
|
20
|
+
* type: 'PURCHASE',
|
|
21
|
+
* amount: 100.00,
|
|
22
|
+
* currency: 'USD',
|
|
23
|
+
* businessId: 'partner-store-123',
|
|
24
|
+
* description: 'Coffee shop purchase'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Get transaction details
|
|
28
|
+
* const details = await sdk.transactions.getTransactionById(transaction.id);
|
|
29
|
+
* console.log('Transaction:', details.description, details.status);
|
|
30
|
+
*
|
|
31
|
+
* // View transaction history
|
|
32
|
+
* const history = await sdk.transactions.getUserTransactionHistory('ALL');
|
|
33
|
+
* console.log(`Found ${history.length} transactions`);
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Transaction History Analysis
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Get different types of transactions
|
|
39
|
+
* const purchases = await sdk.transactions.getUserTransactionHistory('PURCHASE');
|
|
40
|
+
* const rewards = await sdk.transactions.getUserTransactionHistory('REWARD');
|
|
41
|
+
* const redemptions = await sdk.transactions.getUserTransactionHistory('REDEMPTION');
|
|
42
|
+
*
|
|
43
|
+
* console.log('Transaction Summary:');
|
|
44
|
+
* console.log(`Purchases: ${purchases.length}`);
|
|
45
|
+
* console.log(`Rewards: ${rewards.length}`);
|
|
46
|
+
* console.log(`Redemptions: ${redemptions.length}`);
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Administrative Reporting
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // Admin: Get all tenant transactions for analysis
|
|
52
|
+
* const allTransactions = await sdk.transactions.getTenantTransactions();
|
|
53
|
+
*
|
|
54
|
+
* // Export transaction data
|
|
55
|
+
* const csvBlob = await sdk.transactions.exportTransactionsCSV();
|
|
56
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
57
|
+
* console.log('Download transaction report:', downloadUrl);
|
|
58
|
+
* ```
|
|
10
59
|
*/
|
|
11
60
|
export declare class TransactionManager {
|
|
12
61
|
private apiClient;
|
|
13
|
-
private
|
|
62
|
+
private transactionService;
|
|
14
63
|
constructor(apiClient: PersApiClient);
|
|
15
64
|
/**
|
|
16
65
|
* Get transaction by ID
|
|
17
66
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
67
|
+
* Retrieves detailed information for a specific transaction including status,
|
|
68
|
+
* amounts, participants, token transfers, and blockchain confirmations.
|
|
69
|
+
* Provides complete transaction audit trail and verification data.
|
|
70
|
+
*
|
|
71
|
+
* @param transactionId - Unique transaction identifier
|
|
72
|
+
* @returns Promise resolving to complete transaction data
|
|
73
|
+
* @throws {PersApiError} When transaction with specified ID is not found or access denied
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* try {
|
|
78
|
+
* const transaction = await sdk.transactions.getTransactionById('txn-abc123');
|
|
79
|
+
*
|
|
80
|
+
* console.log('📋 Transaction Details:');
|
|
81
|
+
* console.log('ID:', transaction.id);
|
|
82
|
+
* console.log('Type:', transaction.type);
|
|
83
|
+
* console.log('Status:', transaction.status);
|
|
84
|
+
* console.log('Amount:', transaction.amount, transaction.currency);
|
|
85
|
+
* console.log('Date:', new Date(transaction.createdAt).toLocaleString());
|
|
86
|
+
*
|
|
87
|
+
* if (transaction.description) {
|
|
88
|
+
* console.log('Description:', transaction.description);
|
|
89
|
+
* }
|
|
90
|
+
*
|
|
91
|
+
* if (transaction.business) {
|
|
92
|
+
* console.log('Business:', transaction.business.displayName);
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* // Show token movements
|
|
96
|
+
* if (transaction.tokenTransfers?.length) {
|
|
97
|
+
* console.log('\n💰 Token Transfers:');
|
|
98
|
+
* transaction.tokenTransfers.forEach(transfer => {
|
|
99
|
+
* console.log(`${transfer.amount} ${transfer.token.symbol} ${transfer.direction}`);
|
|
100
|
+
* });
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* // Show blockchain confirmation
|
|
104
|
+
* if (transaction.blockchainHash) {
|
|
105
|
+
* console.log('🔗 Blockchain:', transaction.blockchainHash);
|
|
106
|
+
* }
|
|
107
|
+
*
|
|
108
|
+
* } catch (error) {
|
|
109
|
+
* console.log('Transaction not found or access denied:', error.message);
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
20
112
|
*/
|
|
21
113
|
getTransactionById(transactionId: string): Promise<TransactionDTO>;
|
|
22
114
|
/**
|
|
23
115
|
* Create a new transaction
|
|
24
116
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
117
|
+
* Creates a new transaction in the loyalty system, processing token transfers,
|
|
118
|
+
* applying rewards, and updating user balances. Supports various transaction
|
|
119
|
+
* types including purchases, rewards, redemptions, and transfers.
|
|
120
|
+
*
|
|
121
|
+
* @param transactionData - Transaction configuration including type, amounts, and context
|
|
122
|
+
* @returns Promise resolving to transaction creation response
|
|
123
|
+
* @throws {PersApiError} When validation fails or insufficient balance
|
|
124
|
+
*
|
|
125
|
+
* @example Purchase Transaction
|
|
126
|
+
* ```typescript
|
|
127
|
+
* try {
|
|
128
|
+
* const purchase = await sdk.transactions.createTransaction({
|
|
129
|
+
* type: 'PURCHASE',
|
|
130
|
+
* amount: 25.50,
|
|
131
|
+
* currency: 'USD',
|
|
132
|
+
* businessId: 'coffee-shop-123',
|
|
133
|
+
* description: 'Morning coffee and pastry',
|
|
134
|
+
* metadata: {
|
|
135
|
+
* items: ['Latte', 'Croissant'],
|
|
136
|
+
* location: 'Downtown Store'
|
|
137
|
+
* }
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* console.log('✅ Purchase completed!');
|
|
141
|
+
* console.log('Transaction ID:', purchase.id);
|
|
142
|
+
* console.log('Status:', purchase.status);
|
|
143
|
+
*
|
|
144
|
+
* if (purchase.tokensEarned?.length) {
|
|
145
|
+
* console.log('\n🎁 Loyalty rewards earned:');
|
|
146
|
+
* purchase.tokensEarned.forEach(reward => {
|
|
147
|
+
* console.log(`${reward.amount} ${reward.token.symbol}`);
|
|
148
|
+
* });
|
|
149
|
+
* }
|
|
150
|
+
*
|
|
151
|
+
* } catch (error) {
|
|
152
|
+
* console.log('Transaction failed:', error.message);
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example Reward Transaction
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Create reward transaction (typically triggered by campaigns)
|
|
159
|
+
* const reward = await sdk.transactions.createTransaction({
|
|
160
|
+
* type: 'REWARD',
|
|
161
|
+
* businessId: 'partner-hotel-456',
|
|
162
|
+
* description: 'Welcome bonus for new customer',
|
|
163
|
+
* tokenRewards: [
|
|
164
|
+
* {
|
|
165
|
+
* tokenId: 'loyalty-points',
|
|
166
|
+
* amount: 500
|
|
167
|
+
* }
|
|
168
|
+
* ]
|
|
169
|
+
* });
|
|
170
|
+
*
|
|
171
|
+
* console.log('Reward transaction created:', reward.id);
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @example Transfer Transaction
|
|
175
|
+
* ```typescript
|
|
176
|
+
* // Create token transfer between users
|
|
177
|
+
* const transfer = await sdk.transactions.createTransaction({
|
|
178
|
+
* type: 'TRANSFER',
|
|
179
|
+
* recipientUserId: 'user-789',
|
|
180
|
+
* description: 'Gift to friend',
|
|
181
|
+
* tokenTransfers: [
|
|
182
|
+
* {
|
|
183
|
+
* tokenId: 'loyalty-points',
|
|
184
|
+
* amount: 100,
|
|
185
|
+
* direction: 'OUTBOUND'
|
|
186
|
+
* }
|
|
187
|
+
* ]
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* console.log('Transfer initiated:', transfer.id);
|
|
191
|
+
* ```
|
|
27
192
|
*/
|
|
28
|
-
createTransaction(transactionData: TransactionRequestDTO): Promise<import("
|
|
193
|
+
createTransaction(transactionData: TransactionRequestDTO): Promise<import("node_modules/@explorins/pers-shared/dist/cjs/shared-lib/dto/transaction/transaction.request.dto").TransactionRequestResponseDTO>;
|
|
29
194
|
/**
|
|
30
195
|
* Get user's transaction history
|
|
31
196
|
*
|
|
32
|
-
*
|
|
197
|
+
* Retrieves transaction history for the authenticated user, filtered by
|
|
198
|
+
* transaction type. Provides chronological view of all user's loyalty
|
|
199
|
+
* activities including purchases, rewards, redemptions, and transfers.
|
|
200
|
+
*
|
|
201
|
+
* @param type - Transaction type filter ('ALL', 'PURCHASE', 'REWARD', 'REDEMPTION', 'TRANSFER', etc.)
|
|
33
202
|
* @returns Promise resolving to array of user's transactions
|
|
203
|
+
*
|
|
204
|
+
* @example All Transactions
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const allTransactions = await sdk.transactions.getUserTransactionHistory('ALL');
|
|
207
|
+
*
|
|
208
|
+
* console.log(`📜 Transaction History (${allTransactions.length} transactions):`);
|
|
209
|
+
*
|
|
210
|
+
* allTransactions.forEach((transaction, index) => {
|
|
211
|
+
* const date = new Date(transaction.createdAt).toLocaleDateString();
|
|
212
|
+
* console.log(`\n${index + 1}. ${transaction.type} - ${date}`);
|
|
213
|
+
* console.log(` ${transaction.description || 'No description'}`);
|
|
214
|
+
* console.log(` Status: ${transaction.status}`);
|
|
215
|
+
*
|
|
216
|
+
* if (transaction.amount && transaction.currency) {
|
|
217
|
+
* console.log(` Amount: ${transaction.amount} ${transaction.currency}`);
|
|
218
|
+
* }
|
|
219
|
+
*
|
|
220
|
+
* if (transaction.business) {
|
|
221
|
+
* console.log(` Business: ${transaction.business.displayName}`);
|
|
222
|
+
* }
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @example Filtered by Type
|
|
227
|
+
* ```typescript
|
|
228
|
+
* // Get only purchase transactions
|
|
229
|
+
* const purchases = await sdk.transactions.getUserTransactionHistory('PURCHASE');
|
|
230
|
+
*
|
|
231
|
+
* let totalSpent = 0;
|
|
232
|
+
* let totalRewards = 0;
|
|
233
|
+
*
|
|
234
|
+
* purchases.forEach(purchase => {
|
|
235
|
+
* if (purchase.amount) {
|
|
236
|
+
* totalSpent += purchase.amount;
|
|
237
|
+
* }
|
|
238
|
+
*
|
|
239
|
+
* if (purchase.tokensEarned?.length) {
|
|
240
|
+
* purchase.tokensEarned.forEach(reward => {
|
|
241
|
+
* totalRewards += reward.amount;
|
|
242
|
+
* });
|
|
243
|
+
* }
|
|
244
|
+
* });
|
|
245
|
+
*
|
|
246
|
+
* console.log('💳 Purchase Summary:');
|
|
247
|
+
* console.log(`Total purchases: ${purchases.length}`);
|
|
248
|
+
* console.log(`Total spent: $${totalSpent.toFixed(2)}`);
|
|
249
|
+
* console.log(`Total rewards earned: ${totalRewards} points`);
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* @example Recent Activity
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const recentTransactions = await sdk.transactions.getUserTransactionHistory('ALL');
|
|
255
|
+
*
|
|
256
|
+
* // Filter to last 30 days
|
|
257
|
+
* const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
|
|
258
|
+
* const recentActivity = recentTransactions.filter(t =>
|
|
259
|
+
* new Date(t.createdAt) > thirtyDaysAgo
|
|
260
|
+
* );
|
|
261
|
+
*
|
|
262
|
+
* console.log(`📅 Recent Activity (${recentActivity.length} transactions in last 30 days):`);
|
|
263
|
+
*
|
|
264
|
+
* // Group by type
|
|
265
|
+
* const activityByType = recentActivity.reduce((acc, t) => {
|
|
266
|
+
* acc[t.type] = (acc[t.type] || 0) + 1;
|
|
267
|
+
* return acc;
|
|
268
|
+
* }, {});
|
|
269
|
+
*
|
|
270
|
+
* Object.entries(activityByType).forEach(([type, count]) => {
|
|
271
|
+
* console.log(`${type}: ${count} transactions`);
|
|
272
|
+
* });
|
|
273
|
+
* ```
|
|
34
274
|
*/
|
|
35
275
|
getUserTransactionHistory(type: string): Promise<TransactionDTO[]>;
|
|
36
276
|
/**
|
|
37
277
|
* Admin: Get all tenant transactions
|
|
38
278
|
*
|
|
39
|
-
*
|
|
279
|
+
* Retrieves all transactions across the entire tenant/organization for
|
|
280
|
+
* comprehensive reporting and analysis. This operation requires administrator
|
|
281
|
+
* privileges and provides system-wide transaction visibility.
|
|
282
|
+
*
|
|
283
|
+
* @returns Promise resolving to array of all tenant transactions
|
|
284
|
+
* @throws {PersApiError} When not authenticated as administrator
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* // Admin operation - comprehensive transaction analysis
|
|
289
|
+
* const allTransactions = await sdk.transactions.getTenantTransactions();
|
|
290
|
+
*
|
|
291
|
+
* console.log(`📊 Tenant Transaction Overview:`);
|
|
292
|
+
* console.log(`Total transactions: ${allTransactions.length}`);
|
|
293
|
+
*
|
|
294
|
+
* // Analyze by status
|
|
295
|
+
* const statusCounts = allTransactions.reduce((acc, t) => {
|
|
296
|
+
* acc[t.status] = (acc[t.status] || 0) + 1;
|
|
297
|
+
* return acc;
|
|
298
|
+
* }, {});
|
|
299
|
+
*
|
|
300
|
+
* console.log('\n📈 By status:');
|
|
301
|
+
* Object.entries(statusCounts).forEach(([status, count]) => {
|
|
302
|
+
* console.log(`${status}: ${count} transactions`);
|
|
303
|
+
* });
|
|
304
|
+
*
|
|
305
|
+
* // Analyze by type
|
|
306
|
+
* const typeCounts = allTransactions.reduce((acc, t) => {
|
|
307
|
+
* acc[t.type] = (acc[t.type] || 0) + 1;
|
|
308
|
+
* return acc;
|
|
309
|
+
* }, {});
|
|
310
|
+
*
|
|
311
|
+
* console.log('\n🏷️ By type:');
|
|
312
|
+
* Object.entries(typeCounts).forEach(([type, count]) => {
|
|
313
|
+
* console.log(`${type}: ${count} transactions`);
|
|
314
|
+
* });
|
|
315
|
+
*
|
|
316
|
+
* // Calculate volume metrics
|
|
317
|
+
* const totalVolume = allTransactions.reduce((sum, t) =>
|
|
318
|
+
* sum + (t.amount || 0), 0
|
|
319
|
+
* );
|
|
320
|
+
*
|
|
321
|
+
* const avgTransactionSize = totalVolume / allTransactions.length;
|
|
322
|
+
*
|
|
323
|
+
* console.log('\n💰 Volume metrics:');
|
|
324
|
+
* console.log(`Total volume: $${totalVolume.toFixed(2)}`);
|
|
325
|
+
* console.log(`Average transaction: $${avgTransactionSize.toFixed(2)}`);
|
|
326
|
+
*
|
|
327
|
+
* // Recent activity analysis
|
|
328
|
+
* const last24Hours = allTransactions.filter(t =>
|
|
329
|
+
* new Date(t.createdAt) > new Date(Date.now() - 24 * 60 * 60 * 1000)
|
|
330
|
+
* );
|
|
331
|
+
*
|
|
332
|
+
* console.log(`\n⏰ Last 24 hours: ${last24Hours.length} transactions`);
|
|
333
|
+
* ```
|
|
40
334
|
*/
|
|
41
335
|
getTenantTransactions(): Promise<TransactionDTO[]>;
|
|
42
336
|
/**
|
|
43
337
|
* Admin: Get paginated transactions
|
|
44
338
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
339
|
+
* Retrieves transactions with pagination support for efficient large dataset
|
|
340
|
+
* handling. This operation requires administrator privileges and is used for
|
|
341
|
+
* detailed transaction analysis and reporting interfaces.
|
|
342
|
+
*
|
|
343
|
+
* @param params - Pagination and filtering parameters
|
|
344
|
+
* @returns Promise resolving to paginated transaction results with metadata
|
|
345
|
+
* @throws {PersApiError} When not authenticated as administrator
|
|
346
|
+
*
|
|
347
|
+
* @example Basic Pagination
|
|
348
|
+
* ```typescript
|
|
349
|
+
* // Admin operation - paginated transaction retrieval
|
|
350
|
+
* const result = await sdk.transactions.getPaginatedTransactions({
|
|
351
|
+
* page: 1,
|
|
352
|
+
* limit: 50,
|
|
353
|
+
* sortBy: 'createdAt',
|
|
354
|
+
* sortOrder: 'DESC'
|
|
355
|
+
* });
|
|
356
|
+
*
|
|
357
|
+
* console.log(`📄 Page ${result.page} of ${result.totalPages}`);
|
|
358
|
+
* console.log(`Showing ${result.data.length} of ${result.total} transactions`);
|
|
359
|
+
*
|
|
360
|
+
* result.data.forEach((transaction, index) => {
|
|
361
|
+
* console.log(`${index + 1}. ${transaction.type} - ${transaction.status}`);
|
|
362
|
+
* console.log(` ${new Date(transaction.createdAt).toLocaleDateString()}`);
|
|
363
|
+
* });
|
|
364
|
+
*
|
|
365
|
+
* // Continue pagination if needed
|
|
366
|
+
* if (result.hasNextPage) {
|
|
367
|
+
* const nextPage = await sdk.transactions.getPaginatedTransactions({
|
|
368
|
+
* page: result.page + 1,
|
|
369
|
+
* limit: 50
|
|
370
|
+
* });
|
|
371
|
+
* }
|
|
372
|
+
* ```
|
|
373
|
+
*
|
|
374
|
+
* @example Filtered Pagination
|
|
375
|
+
* ```typescript
|
|
376
|
+
* // Admin operation - filter transactions by criteria
|
|
377
|
+
* const filteredResult = await sdk.transactions.getPaginatedTransactions({
|
|
378
|
+
* page: 1,
|
|
379
|
+
* limit: 25,
|
|
380
|
+
* filters: {
|
|
381
|
+
* type: 'PURCHASE',
|
|
382
|
+
* status: 'COMPLETED',
|
|
383
|
+
* businessId: 'partner-store-123',
|
|
384
|
+
* dateFrom: '2024-01-01',
|
|
385
|
+
* dateTo: '2024-12-31'
|
|
386
|
+
* },
|
|
387
|
+
* sortBy: 'amount',
|
|
388
|
+
* sortOrder: 'DESC'
|
|
389
|
+
* });
|
|
390
|
+
*
|
|
391
|
+
* console.log('🔍 Filtered Results:');
|
|
392
|
+
* console.log(`Found ${filteredResult.total} matching transactions`);
|
|
393
|
+
*
|
|
394
|
+
* filteredResult.data.forEach(transaction => {
|
|
395
|
+
* console.log(`$${transaction.amount} - ${transaction.business?.displayName}`);
|
|
396
|
+
* });
|
|
397
|
+
* ```
|
|
47
398
|
*/
|
|
48
|
-
getPaginatedTransactions(params: TransactionPaginationParams): Promise<import("
|
|
399
|
+
getPaginatedTransactions(params: TransactionPaginationParams): Promise<import("../transaction").TransactionPaginationResponse>;
|
|
49
400
|
/**
|
|
50
401
|
* Admin: Export transactions as CSV
|
|
51
402
|
*
|
|
52
|
-
*
|
|
403
|
+
* Generates a comprehensive CSV export of all tenant transactions for
|
|
404
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
405
|
+
* requires administrator privileges and creates a downloadable file.
|
|
406
|
+
*
|
|
407
|
+
* @returns Promise resolving to CSV blob for download
|
|
408
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* // Admin operation - export transaction data
|
|
413
|
+
* try {
|
|
414
|
+
* const csvBlob = await sdk.transactions.exportTransactionsCSV();
|
|
415
|
+
*
|
|
416
|
+
* // Create download link
|
|
417
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
418
|
+
* const link = document.createElement('a');
|
|
419
|
+
* link.href = downloadUrl;
|
|
420
|
+
* link.download = `transactions-${new Date().toISOString().split('T')[0]}.csv`;
|
|
421
|
+
*
|
|
422
|
+
* // Trigger download
|
|
423
|
+
* document.body.appendChild(link);
|
|
424
|
+
* link.click();
|
|
425
|
+
* document.body.removeChild(link);
|
|
426
|
+
*
|
|
427
|
+
* // Clean up object URL
|
|
428
|
+
* URL.revokeObjectURL(downloadUrl);
|
|
429
|
+
*
|
|
430
|
+
* console.log('✅ Transaction export downloaded successfully');
|
|
431
|
+
*
|
|
432
|
+
* } catch (error) {
|
|
433
|
+
* console.log('❌ Export failed:', error.message);
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*
|
|
437
|
+
* @example Server-side Export (Node.js)
|
|
438
|
+
* ```typescript
|
|
439
|
+
* // Admin operation - server-side CSV export
|
|
440
|
+
* const csvBlob = await sdk.transactions.exportTransactionsCSV();
|
|
441
|
+
*
|
|
442
|
+
* // Convert blob to buffer for Node.js
|
|
443
|
+
* const buffer = Buffer.from(await csvBlob.arrayBuffer());
|
|
444
|
+
*
|
|
445
|
+
* // Save to file system
|
|
446
|
+
* const fs = require('fs');
|
|
447
|
+
* const filename = `transactions-export-${Date.now()}.csv`;
|
|
448
|
+
* fs.writeFileSync(filename, buffer);
|
|
449
|
+
*
|
|
450
|
+
* console.log(`Transaction data exported to ${filename}`);
|
|
451
|
+
* ```
|
|
53
452
|
*/
|
|
54
453
|
exportTransactionsCSV(): Promise<Blob>;
|
|
55
454
|
/**
|
|
56
|
-
* Get the full transaction
|
|
455
|
+
* Get the full transaction service for advanced operations
|
|
456
|
+
*
|
|
457
|
+
* Provides access to the complete TransactionService instance for advanced
|
|
458
|
+
* transaction operations, custom analytics, blockchain interactions, and
|
|
459
|
+
* operations not covered by the high-level manager methods.
|
|
460
|
+
*
|
|
461
|
+
* @returns TransactionService instance with full API access
|
|
462
|
+
*
|
|
463
|
+
* @example Advanced Operations
|
|
464
|
+
* ```typescript
|
|
465
|
+
* const transactionService = sdk.transactions.getTransactionService();
|
|
466
|
+
*
|
|
467
|
+
* // Access advanced transaction analytics
|
|
468
|
+
* const analytics = await transactionService.getTransactionAnalytics({
|
|
469
|
+
* timeframe: 'last-30-days',
|
|
470
|
+
* groupBy: 'business'
|
|
471
|
+
* });
|
|
472
|
+
*
|
|
473
|
+
* // Access blockchain transaction monitoring
|
|
474
|
+
* const blockchainStatus = await transactionService.getBlockchainTransactionStatus('txn-123');
|
|
475
|
+
*
|
|
476
|
+
* // Access transaction API directly
|
|
477
|
+
* const transactionApi = transactionService.api;
|
|
478
|
+
*
|
|
479
|
+
* // Use advanced validation and verification
|
|
480
|
+
* const verification = await transactionService.verifyTransactionIntegrity('txn-456');
|
|
57
481
|
*
|
|
58
|
-
*
|
|
482
|
+
* // Access real-time transaction streaming
|
|
483
|
+
* const stream = transactionService.subscribeToTransactionUpdates();
|
|
484
|
+
* stream.on('transaction', (transaction) => {
|
|
485
|
+
* console.log('New transaction:', transaction.id);
|
|
486
|
+
* });
|
|
487
|
+
* ```
|
|
59
488
|
*/
|
|
60
|
-
|
|
489
|
+
getTransactionService(): TransactionService;
|
|
61
490
|
}
|
|
62
491
|
//# sourceMappingURL=transaction-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-manager.d.ts","sourceRoot":"","sources":["../../src/managers/transaction-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"transaction-manager.d.ts","sourceRoot":"","sources":["../../src/managers/transaction-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAkB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACtB,MAAM,iDAAiD,CAAC;AACzD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,kBAAkB;IAGjB,OAAO,CAAC,SAAS;IAF7B,OAAO,CAAC,kBAAkB,CAAqB;gBAE3B,SAAS,EAAE,aAAa;IAK5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACG,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8EG;IACG,iBAAiB,CAAC,eAAe,EAAE,qBAAqB;IAI9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgFG;IACG,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0DG;IACG,qBAAqB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DG;IACG,wBAAwB,CAAC,MAAM,EAAE,2BAA2B;IAIlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,qBAAqB,IAAI,kBAAkB;CAG5C"}
|