@explorins/pers-sdk-react-native 1.3.2 → 1.5.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 (94) hide show
  1. package/README.md +276 -123
  2. package/dist/hooks/index.d.ts +10 -0
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +8 -0
  5. package/dist/hooks/useAnalytics.d.ts +96 -0
  6. package/dist/hooks/useAnalytics.d.ts.map +1 -0
  7. package/dist/hooks/useAnalytics.js +73 -0
  8. package/dist/hooks/useAuth.d.ts +52 -7
  9. package/dist/hooks/useAuth.d.ts.map +1 -1
  10. package/dist/hooks/useAuth.js +250 -3
  11. package/dist/hooks/useBusiness.d.ts +45 -3
  12. package/dist/hooks/useBusiness.d.ts.map +1 -1
  13. package/dist/hooks/useBusiness.js +182 -28
  14. package/dist/hooks/useCampaigns.d.ts +11 -4
  15. package/dist/hooks/useCampaigns.d.ts.map +1 -1
  16. package/dist/hooks/useCampaigns.js +101 -39
  17. package/dist/hooks/useDonations.d.ts +33 -0
  18. package/dist/hooks/useDonations.d.ts.map +1 -0
  19. package/dist/hooks/useDonations.js +62 -0
  20. package/dist/hooks/useFiles.d.ts +50 -0
  21. package/dist/hooks/useFiles.d.ts.map +1 -0
  22. package/dist/hooks/useFiles.js +140 -0
  23. package/dist/hooks/usePurchases.d.ts +9 -0
  24. package/dist/hooks/usePurchases.d.ts.map +1 -0
  25. package/dist/hooks/usePurchases.js +56 -0
  26. package/dist/hooks/useRedemptions.d.ts +10 -5
  27. package/dist/hooks/useRedemptions.d.ts.map +1 -1
  28. package/dist/hooks/useRedemptions.js +118 -66
  29. package/dist/hooks/useTenants.d.ts +10 -0
  30. package/dist/hooks/useTenants.d.ts.map +1 -0
  31. package/dist/hooks/useTenants.js +68 -0
  32. package/dist/hooks/useTokens.d.ts +36 -2
  33. package/dist/hooks/useTokens.d.ts.map +1 -1
  34. package/dist/hooks/useTokens.js +180 -19
  35. package/dist/hooks/useTransactionSigner.d.ts +73 -0
  36. package/dist/hooks/useTransactionSigner.d.ts.map +1 -0
  37. package/dist/hooks/useTransactionSigner.js +216 -0
  38. package/dist/hooks/useTransactions.d.ts +45 -3
  39. package/dist/hooks/useTransactions.d.ts.map +1 -1
  40. package/dist/hooks/useTransactions.js +149 -39
  41. package/dist/hooks/useUserStatus.d.ts +9 -0
  42. package/dist/hooks/useUserStatus.d.ts.map +1 -0
  43. package/dist/hooks/useUserStatus.js +57 -0
  44. package/dist/hooks/useUsers.d.ts +17 -0
  45. package/dist/hooks/useUsers.d.ts.map +1 -0
  46. package/dist/hooks/useUsers.js +120 -0
  47. package/dist/hooks/useWeb3.d.ts +69 -6
  48. package/dist/hooks/useWeb3.d.ts.map +1 -1
  49. package/dist/hooks/useWeb3.js +177 -17
  50. package/dist/index.d.ts +6 -4
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +31540 -794
  53. package/dist/index.js.map +1 -1
  54. package/dist/polyfills/index.d.ts +1 -1
  55. package/dist/polyfills/index.d.ts.map +1 -1
  56. package/dist/polyfills/index.js +155 -9
  57. package/dist/polyfills/web3-polyfills.d.ts +7 -0
  58. package/dist/polyfills/web3-polyfills.d.ts.map +1 -0
  59. package/dist/polyfills/web3-polyfills.js +85 -0
  60. package/dist/providers/PersSDKProvider.d.ts +28 -18
  61. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  62. package/dist/providers/PersSDKProvider.js +63 -129
  63. package/dist/providers/react-native-auth-provider.d.ts +19 -64
  64. package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
  65. package/dist/providers/react-native-auth-provider.js +57 -175
  66. package/package.json +177 -157
  67. package/src/hooks/index.ts +13 -1
  68. package/src/hooks/useAnalytics.ts +150 -0
  69. package/src/hooks/useAuth.ts +286 -27
  70. package/src/hooks/useBusiness.ts +193 -30
  71. package/src/hooks/useCampaigns.ts +121 -43
  72. package/src/hooks/useDonations.ts +68 -0
  73. package/src/hooks/useFiles.ts +160 -0
  74. package/src/hooks/usePurchases.ts +69 -0
  75. package/src/hooks/useRedemptions.ts +135 -68
  76. package/src/hooks/useTenants.ts +77 -0
  77. package/src/hooks/useTokens.ts +189 -21
  78. package/src/hooks/useTransactionSigner.ts +287 -0
  79. package/src/hooks/useTransactions.ts +163 -41
  80. package/src/hooks/useUserStatus.ts +65 -0
  81. package/src/hooks/useUsers.ts +133 -0
  82. package/src/hooks/useWeb3.ts +201 -21
  83. package/src/index.ts +22 -17
  84. package/src/polyfills/index.ts +163 -10
  85. package/src/polyfills/web3-polyfills.ts +98 -0
  86. package/src/providers/PersSDKProvider.tsx +114 -178
  87. package/src/providers/react-native-auth-provider.ts +65 -208
  88. package/dist/index.esm.js +0 -1057
  89. package/dist/index.esm.js.map +0 -1
  90. package/dist/polyfills/index.simple.d.ts +0 -2
  91. package/dist/polyfills/index.simple.d.ts.map +0 -1
  92. package/dist/polyfills/index.simple.js +0 -17
  93. package/src/polyfills/index.simple.ts +0 -22
  94. package/src/types/external-modules.d.ts +0 -13
package/package.json CHANGED
@@ -1,157 +1,177 @@
1
- {
2
- "name": "@explorins/pers-sdk-react-native",
3
- "version": "1.3.2",
4
- "description": "React Native SDK for PERS Platform - Tourism Loyalty System",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc && rollup -c --bundleConfigAsCjs",
9
- "dev": "tsc --watch",
10
- "clean": "rimraf dist",
11
- "prepublishOnly": "npm run clean && npm run build"
12
- },
13
- "keywords": [
14
- "pers",
15
- "sdk",
16
- "react-native",
17
- "tourism",
18
- "loyalty",
19
- "blockchain",
20
- "web3"
21
- ],
22
- "author": "eXplorins",
23
- "license": "MIT",
24
- "dependencies": {
25
- "@explorins/pers-sdk": "^1.3.2",
26
- "@explorins/pers-shared": "^2.1.40",
27
- "buffer": "^6.0.3",
28
- "ethers": "^6.15.0",
29
- "web3": "^4.16.0"
30
- },
31
- "browser": {
32
- "crypto": false,
33
- "url": false,
34
- "http": false,
35
- "https": false,
36
- "zlib": false,
37
- "stream": false,
38
- "assert": false,
39
- "path": false,
40
- "fs": false,
41
- "os": false,
42
- "readable-stream": false,
43
- "util": false,
44
- "events": false,
45
- "net": false,
46
- "tls": false,
47
- "child_process": false,
48
- "pngjs": false,
49
- "pngjs/lib/bitmapper": false,
50
- "pngjs/lib/parser-async": false,
51
- "pngjs/lib/parser-sync": false,
52
- "./bitmapper": false,
53
- "hash-base": false,
54
- "@ethereumjs/common": false,
55
- "@ethereumjs/tx": false,
56
- "@ethereumjs/util": false,
57
- "stream-browserify": false,
58
- "crypto-browserify": false,
59
- "inherits": false,
60
- "safe-buffer": false,
61
- "string_decoder": false,
62
- "process-nextick-args": false,
63
- "isarray": false,
64
- "core-util-is": false,
65
- "util-deprecate": false,
66
- "ethereum-cryptography": false,
67
- "keccak": false,
68
- "secp256k1": false,
69
- "scrypt-js": false,
70
- "bech32": false,
71
- "ws": false,
72
- "xhr2-cookies": false,
73
- "aes-js": false,
74
- "@ethersproject/sha2": false,
75
- "@ethersproject/pbkdf2": false,
76
- "@ethersproject/scrypt": false
77
- },
78
- "peerDependencies": {
79
- "react": ">=16.8.0",
80
- "react-native": ">=0.60.0"
81
- },
82
- "peerDependenciesMeta": {
83
- "react-native-keychain": {
84
- "optional": true
85
- },
86
- "@react-native-async-storage/async-storage": {
87
- "optional": false
88
- },
89
- "react-native-get-random-values": {
90
- "optional": true
91
- },
92
- "react-native-url-polyfill": {
93
- "optional": true
94
- },
95
- "react-native-polyfill-globals": {
96
- "optional": true
97
- },
98
- "web-streams-polyfill": {
99
- "optional": true
100
- }
101
- },
102
- "overrides": {
103
- "readable-stream": false,
104
- "@ethereumjs/common": false,
105
- "@ethereumjs/util": false,
106
- "@ethereumjs/rlp": false,
107
- "@ethereumjs/tx": false,
108
- "stream": false,
109
- "util": false,
110
- "events": false,
111
- "crypto": false,
112
- "fs": false,
113
- "path": false,
114
- "os": false,
115
- "net": false,
116
- "tls": false,
117
- "child_process": false,
118
- "hash-base": false,
119
- "inherits": false,
120
- "safe-buffer": false,
121
- "string_decoder": false,
122
- "process-nextick-args": false,
123
- "isarray": false,
124
- "core-util-is": false,
125
- "util-deprecate": false,
126
- "ethereum-cryptography": false,
127
- "keccak": false,
128
- "secp256k1": false,
129
- "scrypt-js": false,
130
- "bech32": false,
131
- "ws": false,
132
- "xhr2-cookies": false,
133
- "aes-js": false,
134
- "@ethersproject/sha2": false,
135
- "@ethersproject/pbkdf2": false,
136
- "@ethersproject/scrypt": false
137
- },
138
- "devDependencies": {
139
- "@react-native-async-storage/async-storage": "^1.19.0",
140
- "@types/react": "^19.1.1",
141
- "@types/react-native": "^0.72.8",
142
- "rimraf": "^5.0.0",
143
- "rollup": "^4.0.0",
144
- "rollup-plugin-typescript2": "^0.36.0",
145
- "typescript": "^5.2.0"
146
- },
147
- "files": [
148
- "dist/**/*",
149
- "src/**/*",
150
- "README.md"
151
- ],
152
- "repository": {
153
- "type": "git",
154
- "url": "git+https://github.com/eXplorins/pers-sdk.git",
155
- "directory": "packages/pers-sdk-react-native"
156
- }
157
- }
1
+ {
2
+ "name": "@explorins/pers-sdk-react-native",
3
+ "version": "1.5.2",
4
+ "description": "React Native SDK for PERS Platform - Tourism Loyalty System with Manager Pattern Architecture",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc && rollup -c --bundleConfigAsCjs",
9
+ "build:watch": "rollup -c --bundleConfigAsCjs --watch",
10
+ "dev": "tsc --watch",
11
+ "clean": "rimraf dist",
12
+ "docs": "typedoc",
13
+ "docs:dev": "typedoc --watch",
14
+ "docs:json": "typedoc --json docs/api.json",
15
+ "docs:serve": "npx http-server docs -p 8080",
16
+ "prepublishOnly": "npm run clean && npm run build",
17
+ "publish-version": "npm run clean && npm run build && npm version patch && npm publish",
18
+ "publish-with-docs": "npm run clean && npm run build && npm run docs && npm version patch && npm publish",
19
+ "yalc:publish": "npm version patch --no-git-tag-version && npm run build && yalc publish",
20
+ "yalc:push": "npm version patch --no-git-tag-version && npm run build && yalc push"
21
+ },
22
+ "keywords": [
23
+ "pers",
24
+ "sdk",
25
+ "react-native",
26
+ "tourism",
27
+ "loyalty",
28
+ "blockchain",
29
+ "web3"
30
+ ],
31
+ "author": "eXplorins",
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@dfns/sdk": "^0.8.1",
35
+ "@dfns/sdk-react-native": "^0.8.1",
36
+ "@explorins/pers-sdk": "^1.6.3",
37
+ "@explorins/pers-shared": "^2.1.40",
38
+ "@explorins/pers-signer": "^1.0.6",
39
+ "@explorins/web3-ts": "^0.3.75",
40
+ "@react-native-async-storage/async-storage": "^2.2.0",
41
+ "buffer": "^6.0.3",
42
+ "ethers": "^6.15.0",
43
+ "react-native-get-random-values": "^2.0.0",
44
+ "react-native-keychain": "^10.0.0",
45
+ "typedoc": "^0.25.13",
46
+ "typedoc-plugin-markdown": "^3.17.1"
47
+ },
48
+ "browser": {
49
+ "crypto": false,
50
+ "url": false,
51
+ "http": false,
52
+ "https": false,
53
+ "zlib": false,
54
+ "stream": false,
55
+ "assert": false,
56
+ "path": false,
57
+ "fs": false,
58
+ "os": false,
59
+ "readable-stream": false,
60
+ "util": false,
61
+ "events": false,
62
+ "net": false,
63
+ "tls": false,
64
+ "child_process": false,
65
+ "pngjs": false,
66
+ "pngjs/lib/bitmapper": false,
67
+ "pngjs/lib/parser-async": false,
68
+ "pngjs/lib/parser-sync": false,
69
+ "./bitmapper": false,
70
+ "hash-base": false,
71
+ "@ethereumjs/common": false,
72
+ "@ethereumjs/tx": false,
73
+ "@ethereumjs/util": false,
74
+ "stream-browserify": false,
75
+ "crypto-browserify": false,
76
+ "inherits": false,
77
+ "safe-buffer": false,
78
+ "string_decoder": false,
79
+ "process-nextick-args": false,
80
+ "isarray": false,
81
+ "core-util-is": false,
82
+ "util-deprecate": false,
83
+ "ethereum-cryptography": false,
84
+ "keccak": false,
85
+ "secp256k1": false,
86
+ "scrypt-js": false,
87
+ "bech32": false,
88
+ "ws": false,
89
+ "xhr2-cookies": false,
90
+ "aes-js": false,
91
+ "@ethersproject/sha2": false,
92
+ "@ethersproject/pbkdf2": false,
93
+ "@ethersproject/scrypt": false
94
+ },
95
+ "peerDependencies": {
96
+ "react": ">=16.8.0",
97
+ "react-native": ">=0.60.0"
98
+ },
99
+ "peerDependenciesMeta": {
100
+ "react-native-keychain": {
101
+ "optional": true
102
+ },
103
+ "@react-native-async-storage/async-storage": {
104
+ "optional": false
105
+ },
106
+ "react-native-get-random-values": {
107
+ "optional": true
108
+ },
109
+ "react-native-url-polyfill": {
110
+ "optional": true
111
+ },
112
+ "react-native-polyfill-globals": {
113
+ "optional": true
114
+ },
115
+ "web-streams-polyfill": {
116
+ "optional": true
117
+ }
118
+ },
119
+ "overrides": {
120
+ "readable-stream": false,
121
+ "@ethereumjs/common": false,
122
+ "@ethereumjs/util": false,
123
+ "@ethereumjs/rlp": false,
124
+ "@ethereumjs/tx": false,
125
+ "stream": false,
126
+ "util": false,
127
+ "events": false,
128
+ "crypto": false,
129
+ "fs": false,
130
+ "path": false,
131
+ "os": false,
132
+ "net": false,
133
+ "tls": false,
134
+ "child_process": false,
135
+ "hash-base": false,
136
+ "inherits": false,
137
+ "safe-buffer": false,
138
+ "string_decoder": false,
139
+ "process-nextick-args": false,
140
+ "isarray": false,
141
+ "core-util-is": false,
142
+ "util-deprecate": false,
143
+ "ethereum-cryptography": false,
144
+ "keccak": false,
145
+ "secp256k1": false,
146
+ "scrypt-js": false,
147
+ "bech32": false,
148
+ "ws": false,
149
+ "xhr2-cookies": false,
150
+ "aes-js": false,
151
+ "@ethersproject/sha2": false,
152
+ "@ethersproject/pbkdf2": false,
153
+ "@ethersproject/scrypt": false
154
+ },
155
+ "devDependencies": {
156
+ "@react-native-async-storage/async-storage": "^1.19.0",
157
+ "@rollup/plugin-commonjs": "^25.0.7",
158
+ "@rollup/plugin-json": "^6.1.0",
159
+ "@rollup/plugin-node-resolve": "^15.2.3",
160
+ "@types/react": "^19.1.1",
161
+ "@types/react-native": "^0.72.8",
162
+ "rimraf": "^5.0.0",
163
+ "rollup": "^4.0.0",
164
+ "rollup-plugin-typescript2": "^0.36.0",
165
+ "typescript": "^5.2.0"
166
+ },
167
+ "files": [
168
+ "dist/**/*",
169
+ "src/**/*",
170
+ "README.md"
171
+ ],
172
+ "repository": {
173
+ "type": "git",
174
+ "url": "git+https://github.com/eXplorins/pers-sdk.git",
175
+ "directory": "packages/pers-sdk-react-native"
176
+ }
177
+ }
@@ -2,7 +2,19 @@
2
2
  export { useAuth } from './useAuth';
3
3
  export { useTokens } from './useTokens';
4
4
  export { useTransactions } from './useTransactions';
5
+ export { useTransactionSigner } from './useTransactionSigner';
5
6
  export { useBusiness } from './useBusiness';
6
7
  export { useCampaigns } from './useCampaigns';
7
8
  export { useRedemptions } from './useRedemptions';
8
- export { useWeb3 } from './useWeb3';
9
+ export { useWeb3 } from './useWeb3';
10
+ export { usePurchases } from './usePurchases';
11
+ export { useTenants } from './useTenants';
12
+ export { useUsers } from './useUsers';
13
+ export { useUserStatus } from './useUserStatus';
14
+ export { useFiles } from './useFiles';
15
+ export { useAnalytics } from './useAnalytics';
16
+ export { useDonations } from './useDonations';
17
+
18
+ // Re-export auth-related types for convenience
19
+ export type { RawUserData } from './useAuth';
20
+ export type { TransactionSignerHook, TransactionSigningResult } from './useTransactionSigner';
@@ -0,0 +1,150 @@
1
+ import { useCallback } from 'react';
2
+ import { usePersSDK } from '../providers/PersSDKProvider';
3
+
4
+ // Import analytics types directly from core SDK
5
+ interface TransactionAnalyticsFilters {
6
+ status?: string;
7
+ tokenType?: string;
8
+ triggerProcessType?: string;
9
+ tenantId?: string;
10
+ chainId?: number;
11
+ type?: string;
12
+ [key: string]: any;
13
+ }
14
+
15
+ type TransactionAnalyticsGroupBy =
16
+ | 'month' | 'week' | 'day' | 'year' | 'quarter'
17
+ | 'tokenType' | 'status' | 'chainId' | 'triggerProcessType' | 'type'
18
+ | 'senderAddress' | 'recipientAddress' | 'senderId' | 'recipientId' | 'senderOwnerType' | 'recipientOwnerType' | 'createdAt';
19
+
20
+ type TransactionAnalyticsMetric =
21
+ | 'count' | 'sum' | 'avg' | 'min' | 'max';
22
+
23
+ interface TransactionAnalyticsGroupByExpression {
24
+ expression: string;
25
+ alias: string;
26
+ }
27
+
28
+ /**
29
+ * Request DTO for transaction analytics
30
+ */
31
+ interface TransactionAnalyticsRequestDTO {
32
+ filters?: TransactionAnalyticsFilters;
33
+ groupBy?: TransactionAnalyticsGroupBy[];
34
+ groupByExpressions?: TransactionAnalyticsGroupByExpression[];
35
+ metrics?: TransactionAnalyticsMetric[];
36
+ orderBy?: string;
37
+ orderDirection?: 'ASC' | 'DESC';
38
+ limit?: number;
39
+ startDate?: string;
40
+ endDate?: string;
41
+ }
42
+
43
+ interface TransactionAnalyticsResultItem {
44
+ [key: string]: string | number | Date | undefined;
45
+ count?: string;
46
+ sum?: number;
47
+ avg?: number;
48
+ min?: number;
49
+ max?: number;
50
+ tokentype?: string;
51
+ tokenType?: string;
52
+ year?: string;
53
+ month?: string;
54
+ type?: string;
55
+ senderaddress?: string;
56
+ senderAddress?: string;
57
+ recipientaddress?: string;
58
+ recipientAddress?: string;
59
+ triggerprocesstype?: string;
60
+ triggerProcessType?: string;
61
+ userid?: string;
62
+ userId?: string;
63
+ }
64
+
65
+ /**
66
+ * Response DTO for transaction analytics
67
+ */
68
+ interface TransactionAnalyticsResponseDTO {
69
+ results: TransactionAnalyticsResultItem[];
70
+ totalGroups: number;
71
+ metadata: {
72
+ executionTime: string;
73
+ };
74
+ }
75
+
76
+ /**
77
+ * React hook for analytics operations in the PERS SDK
78
+ *
79
+ * Provides methods for retrieving transaction analytics and insights.
80
+ * Supports various analytics queries for business intelligence and reporting.
81
+ *
82
+ * @returns Analytics hook with methods for data analysis
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * function AnalyticsComponent() {
87
+ * const { getTransactionAnalytics } = useAnalytics();
88
+ *
89
+ * const loadAnalytics = async () => {
90
+ * try {
91
+ * const analytics = await getTransactionAnalytics({
92
+ * timeRange: 'last_30_days',
93
+ * groupBy: 'day'
94
+ * });
95
+ * console.log('Transaction analytics:', analytics);
96
+ * } catch (error) {
97
+ * console.error('Failed to load analytics:', error);
98
+ * }
99
+ * };
100
+ *
101
+ * return <button onClick={loadAnalytics}>Load Analytics</button>;
102
+ * }
103
+ * ```
104
+ */
105
+ export const useAnalytics = () => {
106
+ const { sdk, isInitialized } = usePersSDK();
107
+
108
+ /**
109
+ * Retrieves transaction analytics data based on request parameters
110
+ *
111
+ * @param request - Analytics request parameters (time range, grouping, filters, etc.)
112
+ * @returns Promise resolving to analytics data with results and metadata
113
+ * @throws Error if SDK is not initialized
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const { getTransactionAnalytics } = useAnalytics();
118
+ * const analytics = await getTransactionAnalytics({
119
+ * groupBy: ['day'],
120
+ * metrics: ['count', 'sum'],
121
+ * startDate: '2024-01-01',
122
+ * endDate: '2024-01-31',
123
+ * filters: { status: 'completed' }
124
+ * });
125
+ * console.log('Daily transaction analytics:', analytics.results);
126
+ * console.log('Execution time:', analytics.metadata.executionTime);
127
+ * ```
128
+ */
129
+ const getTransactionAnalytics = useCallback(async (request: TransactionAnalyticsRequestDTO): Promise<TransactionAnalyticsResponseDTO> => {
130
+ if (!isInitialized || !sdk) {
131
+ throw new Error('SDK not initialized. Call initialize() first.');
132
+ }
133
+
134
+ try {
135
+ const result = await sdk.analytics.getTransactionAnalytics(request);
136
+ console.log('Transaction analytics fetched successfully:', result);
137
+ return result;
138
+ } catch (error) {
139
+ console.error('Failed to fetch transaction analytics:', error);
140
+ throw error;
141
+ }
142
+ }, [sdk, isInitialized]);
143
+
144
+ return {
145
+ getTransactionAnalytics,
146
+ isAvailable: isInitialized && !!sdk?.analytics,
147
+ };
148
+ };
149
+
150
+ export type AnalyticsHook = ReturnType<typeof useAnalytics>;