@explorins/pers-sdk-react-native 1.3.2 → 1.5.1

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 (90) hide show
  1. package/README.md +276 -123
  2. package/dist/hooks/index.d.ts +8 -0
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +7 -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 +94 -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/useTransactions.d.ts +45 -3
  36. package/dist/hooks/useTransactions.d.ts.map +1 -1
  37. package/dist/hooks/useTransactions.js +152 -31
  38. package/dist/hooks/useUserStatus.d.ts +9 -0
  39. package/dist/hooks/useUserStatus.d.ts.map +1 -0
  40. package/dist/hooks/useUserStatus.js +57 -0
  41. package/dist/hooks/useUsers.d.ts +17 -0
  42. package/dist/hooks/useUsers.d.ts.map +1 -0
  43. package/dist/hooks/useUsers.js +120 -0
  44. package/dist/hooks/useWeb3.d.ts +69 -6
  45. package/dist/hooks/useWeb3.d.ts.map +1 -1
  46. package/dist/hooks/useWeb3.js +177 -17
  47. package/dist/index.d.ts +6 -4
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +12199 -796
  50. package/dist/index.js.map +1 -1
  51. package/dist/polyfills/index.d.ts +1 -1
  52. package/dist/polyfills/index.d.ts.map +1 -1
  53. package/dist/polyfills/index.js +155 -9
  54. package/dist/polyfills/web3-polyfills.d.ts +7 -0
  55. package/dist/polyfills/web3-polyfills.d.ts.map +1 -0
  56. package/dist/polyfills/web3-polyfills.js +85 -0
  57. package/dist/providers/PersSDKProvider.d.ts +28 -18
  58. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  59. package/dist/providers/PersSDKProvider.js +63 -129
  60. package/dist/providers/react-native-auth-provider.d.ts +19 -64
  61. package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
  62. package/dist/providers/react-native-auth-provider.js +57 -175
  63. package/package.json +171 -157
  64. package/src/hooks/index.ts +11 -1
  65. package/src/hooks/useAnalytics.ts +150 -0
  66. package/src/hooks/useAuth.ts +286 -27
  67. package/src/hooks/useBusiness.ts +193 -30
  68. package/src/hooks/useCampaigns.ts +121 -43
  69. package/src/hooks/useDonations.ts +68 -0
  70. package/src/hooks/useFiles.ts +160 -0
  71. package/src/hooks/usePurchases.ts +69 -0
  72. package/src/hooks/useRedemptions.ts +109 -68
  73. package/src/hooks/useTenants.ts +77 -0
  74. package/src/hooks/useTokens.ts +189 -21
  75. package/src/hooks/useTransactions.ts +170 -34
  76. package/src/hooks/useUserStatus.ts +65 -0
  77. package/src/hooks/useUsers.ts +133 -0
  78. package/src/hooks/useWeb3.ts +201 -21
  79. package/src/index.ts +21 -17
  80. package/src/polyfills/index.ts +163 -10
  81. package/src/polyfills/web3-polyfills.ts +98 -0
  82. package/src/providers/PersSDKProvider.tsx +114 -178
  83. package/src/providers/react-native-auth-provider.ts +65 -208
  84. package/dist/index.esm.js +0 -1057
  85. package/dist/index.esm.js.map +0 -1
  86. package/dist/polyfills/index.simple.d.ts +0 -2
  87. package/dist/polyfills/index.simple.d.ts.map +0 -1
  88. package/dist/polyfills/index.simple.js +0 -17
  89. package/src/polyfills/index.simple.ts +0 -22
  90. package/src/types/external-modules.d.ts +0 -13
package/package.json CHANGED
@@ -1,157 +1,171 @@
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.1",
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
+ },
20
+ "keywords": [
21
+ "pers",
22
+ "sdk",
23
+ "react-native",
24
+ "tourism",
25
+ "loyalty",
26
+ "blockchain",
27
+ "web3"
28
+ ],
29
+ "author": "eXplorins",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@explorins/pers-sdk": "^1.6.3",
33
+ "@explorins/pers-shared": "^2.1.40",
34
+ "@explorins/web3-ts": "^0.3.75",
35
+ "@react-native-async-storage/async-storage": "^2.2.0",
36
+ "buffer": "^6.0.3",
37
+ "ethers": "^6.15.0",
38
+ "react-native-get-random-values": "^2.0.0",
39
+ "react-native-keychain": "^10.0.0",
40
+ "typedoc": "^0.25.13",
41
+ "typedoc-plugin-markdown": "^3.17.1"
42
+ },
43
+ "browser": {
44
+ "crypto": false,
45
+ "url": false,
46
+ "http": false,
47
+ "https": false,
48
+ "zlib": false,
49
+ "stream": false,
50
+ "assert": false,
51
+ "path": false,
52
+ "fs": false,
53
+ "os": false,
54
+ "readable-stream": false,
55
+ "util": false,
56
+ "events": false,
57
+ "net": false,
58
+ "tls": false,
59
+ "child_process": false,
60
+ "pngjs": false,
61
+ "pngjs/lib/bitmapper": false,
62
+ "pngjs/lib/parser-async": false,
63
+ "pngjs/lib/parser-sync": false,
64
+ "./bitmapper": false,
65
+ "hash-base": false,
66
+ "@ethereumjs/common": false,
67
+ "@ethereumjs/tx": false,
68
+ "@ethereumjs/util": false,
69
+ "stream-browserify": false,
70
+ "crypto-browserify": false,
71
+ "inherits": false,
72
+ "safe-buffer": false,
73
+ "string_decoder": false,
74
+ "process-nextick-args": false,
75
+ "isarray": false,
76
+ "core-util-is": false,
77
+ "util-deprecate": false,
78
+ "ethereum-cryptography": false,
79
+ "keccak": false,
80
+ "secp256k1": false,
81
+ "scrypt-js": false,
82
+ "bech32": false,
83
+ "ws": false,
84
+ "xhr2-cookies": false,
85
+ "aes-js": false,
86
+ "@ethersproject/sha2": false,
87
+ "@ethersproject/pbkdf2": false,
88
+ "@ethersproject/scrypt": false
89
+ },
90
+ "peerDependencies": {
91
+ "react": ">=16.8.0",
92
+ "react-native": ">=0.60.0"
93
+ },
94
+ "peerDependenciesMeta": {
95
+ "react-native-keychain": {
96
+ "optional": true
97
+ },
98
+ "@react-native-async-storage/async-storage": {
99
+ "optional": false
100
+ },
101
+ "react-native-get-random-values": {
102
+ "optional": true
103
+ },
104
+ "react-native-url-polyfill": {
105
+ "optional": true
106
+ },
107
+ "react-native-polyfill-globals": {
108
+ "optional": true
109
+ },
110
+ "web-streams-polyfill": {
111
+ "optional": true
112
+ }
113
+ },
114
+ "overrides": {
115
+ "readable-stream": false,
116
+ "@ethereumjs/common": false,
117
+ "@ethereumjs/util": false,
118
+ "@ethereumjs/rlp": false,
119
+ "@ethereumjs/tx": false,
120
+ "stream": false,
121
+ "util": false,
122
+ "events": false,
123
+ "crypto": false,
124
+ "fs": false,
125
+ "path": false,
126
+ "os": false,
127
+ "net": false,
128
+ "tls": false,
129
+ "child_process": false,
130
+ "hash-base": false,
131
+ "inherits": false,
132
+ "safe-buffer": false,
133
+ "string_decoder": false,
134
+ "process-nextick-args": false,
135
+ "isarray": false,
136
+ "core-util-is": false,
137
+ "util-deprecate": false,
138
+ "ethereum-cryptography": false,
139
+ "keccak": false,
140
+ "secp256k1": false,
141
+ "scrypt-js": false,
142
+ "bech32": false,
143
+ "ws": false,
144
+ "xhr2-cookies": false,
145
+ "aes-js": false,
146
+ "@ethersproject/sha2": false,
147
+ "@ethersproject/pbkdf2": false,
148
+ "@ethersproject/scrypt": false
149
+ },
150
+ "devDependencies": {
151
+ "@react-native-async-storage/async-storage": "^1.19.0",
152
+ "@rollup/plugin-commonjs": "^25.0.7",
153
+ "@rollup/plugin-node-resolve": "^15.2.3",
154
+ "@types/react": "^19.1.1",
155
+ "@types/react-native": "^0.72.8",
156
+ "rimraf": "^5.0.0",
157
+ "rollup": "^4.0.0",
158
+ "rollup-plugin-typescript2": "^0.36.0",
159
+ "typescript": "^5.2.0"
160
+ },
161
+ "files": [
162
+ "dist/**/*",
163
+ "src/**/*",
164
+ "README.md"
165
+ ],
166
+ "repository": {
167
+ "type": "git",
168
+ "url": "git+https://github.com/eXplorins/pers-sdk.git",
169
+ "directory": "packages/pers-sdk-react-native"
170
+ }
171
+ }
@@ -5,4 +5,14 @@ export { useTransactions } from './useTransactions';
5
5
  export { useBusiness } from './useBusiness';
6
6
  export { useCampaigns } from './useCampaigns';
7
7
  export { useRedemptions } from './useRedemptions';
8
- export { useWeb3 } from './useWeb3';
8
+ export { useWeb3 } from './useWeb3';
9
+ export { usePurchases } from './usePurchases';
10
+ export { useTenants } from './useTenants';
11
+ export { useUsers } from './useUsers';
12
+ export { useUserStatus } from './useUserStatus';
13
+ export { useFiles } from './useFiles';
14
+ export { useAnalytics } from './useAnalytics';
15
+ export { useDonations } from './useDonations';
16
+
17
+ // Re-export auth-related types for convenience
18
+ export type { RawUserData } from './useAuth';
@@ -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>;