@explorins/pers-sdk 1.1.0-beta.0 → 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.
- package/config/domains.js +22 -0
- package/package.json +100 -15
- package/rollup.config.js +44 -54
- package/scripts/copy-declarations.js +147 -0
- package/src/analytics/api/analytics-api.ts +24 -0
- package/src/analytics/index.ts +52 -0
- package/src/analytics/models/index.ts +74 -0
- package/src/analytics/services/analytics-service.ts +28 -0
- package/src/auth-admin/api/auth-admin-api.ts +42 -0
- package/src/auth-admin/index.ts +47 -0
- package/src/auth-admin/services/auth-admin-service.ts +36 -0
- package/src/business/api/business-api.ts +181 -19
- package/src/business/index.ts +4 -3
- package/src/business/models/index.ts +4 -4
- package/src/business/services/business-service.ts +1 -1
- package/src/campaign/api/campaign-api.ts +376 -0
- package/src/campaign/index.ts +67 -0
- package/src/campaign/services/campaign-service.ts +164 -0
- package/src/core/abstractions/http-client.ts +1 -0
- package/src/core/auth/auth-provider.interface.ts +2 -2
- package/src/core/auth/create-auth-provider.ts +6 -6
- package/src/core/index.ts +33 -0
- package/src/core/pers-api-client.ts +211 -19
- package/src/core/pers-config.ts +34 -7
- package/src/core/utils/jwt.function.ts +24 -0
- package/src/donation/api/donation-api.ts +24 -0
- package/src/donation/index.ts +47 -0
- package/src/donation/models/index.ts +11 -0
- package/src/donation/services/donation-service.ts +25 -0
- package/src/index.ts +40 -1
- package/src/payment/api/payment-api.ts +185 -0
- package/src/payment/index.ts +64 -0
- package/src/payment/models/index.ts +29 -0
- package/src/payment/services/payment-service.ts +70 -0
- package/src/redemption/api/redemption-api.ts +241 -0
- package/src/redemption/index.ts +60 -0
- package/src/redemption/models/index.ts +17 -0
- package/src/redemption/services/redemption-service.ts +103 -0
- package/src/shared/interfaces/pers-shared-lib.interfaces.ts +99 -0
- package/src/tenant/api/tenant-api.ts +92 -0
- package/src/tenant/index.ts +61 -0
- package/src/tenant/models/index.ts +20 -0
- package/src/tenant/services/tenant-service.ts +78 -0
- package/src/token/api/token-api.ts +129 -0
- package/src/token/base/base-token-service.ts +167 -0
- package/src/token/index.ts +38 -0
- package/src/token/models/index.ts +30 -0
- package/src/token/services/token-service.ts +125 -0
- package/src/token/token-sdk.ts +231 -0
- package/src/transaction/api/transaction-api.ts +296 -0
- package/src/transaction/index.ts +65 -0
- package/src/transaction/models/index.ts +60 -0
- package/src/transaction/services/transaction-service.ts +104 -0
- package/src/user/api/user-api.ts +98 -0
- package/src/user/index.ts +62 -0
- package/src/user/models/index.ts +10 -0
- package/src/user/services/user-service.ts +75 -0
- package/src/user-status/api/user-status-api.ts +78 -0
- package/src/user-status/index.ts +55 -0
- package/src/user-status/models/index.ts +11 -0
- package/src/user-status/services/user-status-service.ts +51 -0
- package/src/web3/api/web3-api.ts +68 -0
- package/src/web3/index.ts +38 -0
- package/src/web3/models/index.ts +150 -0
- package/src/web3/services/web3-service.ts +338 -0
- package/src/web3-chain/api/web3-chain-api.ts +42 -0
- package/src/web3-chain/index.ts +27 -0
- package/src/web3-chain/models/index.ts +45 -0
- package/src/web3-chain/services/getWeb3FCD.service.ts +47 -0
- package/src/web3-chain/services/provider.service.ts +123 -0
- package/src/web3-chain/services/public-http-provider.service.ts +26 -0
- package/src/web3-chain/services/web3-chain-service.ts +131 -0
- package/src/business/business/tsconfig.json +0 -18
- package/src/core/abstractions/core-interfaces.ts +0 -56
- package/src/core/core.ts +0 -30
- package/src/core.ts +0 -30
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Domain configurations for the PERS SDK
|
|
2
|
+
// This is the single source of truth for all domain configurations
|
|
3
|
+
export const domains = [
|
|
4
|
+
{ name: 'core', externals: ['jwt-decode'] },
|
|
5
|
+
{ name: 'business', externals: ['@explorins/pers-shared'] },
|
|
6
|
+
{ name: 'transaction', externals: ['@explorins/pers-shared'] },
|
|
7
|
+
{ name: 'analytics', externals: ['@explorins/pers-shared'] },
|
|
8
|
+
{ name: 'auth-admin', externals: ['@explorins/pers-shared'] },
|
|
9
|
+
{ name: 'campaign', externals: ['@explorins/pers-shared'] },
|
|
10
|
+
{ name: 'donation', externals: ['@explorins/pers-shared'] },
|
|
11
|
+
{ name: 'payment', externals: ['@explorins/pers-shared'] },
|
|
12
|
+
{ name: 'redemption', externals: ['@explorins/pers-shared'] },
|
|
13
|
+
{ name: 'tenant', externals: ['@explorins/pers-shared'] },
|
|
14
|
+
{ name: 'token', externals: ['@explorins/pers-shared'] },
|
|
15
|
+
{ name: 'user', externals: ['@explorins/pers-shared'] },
|
|
16
|
+
{ name: 'user-status', externals: ['@explorins/pers-shared'] },
|
|
17
|
+
{ name: 'web3-chain', externals: ['@explorins/pers-shared', 'web3', '@explorins/web3-ts', 'ethers'] },
|
|
18
|
+
{ name: 'web3', externals: ['@explorins/pers-shared', 'web3', '@explorins/web3-ts', 'ethers'] }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
// Extract just the domain names for scripts that only need the names
|
|
22
|
+
export const domainNames = domains.map(domain => domain.name);
|
package/package.json
CHANGED
|
@@ -1,27 +1,114 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@explorins/pers-sdk",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "Platform-agnostic SDK for PERS (Phygital Experience Rewards System)",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Platform-agnostic SDK for PERS (Phygital Experience Rewards System) - Production Defaults",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./index.cjs",
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
6
9
|
"exports": {
|
|
7
10
|
".": {
|
|
8
11
|
"types": "./index.d.ts",
|
|
9
|
-
"import": "./index.
|
|
10
|
-
"require": "./index.
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"require": "./index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./analytics": {
|
|
16
|
+
"types": "./analytics.d.ts",
|
|
17
|
+
"import": "./analytics.js",
|
|
18
|
+
"require": "./analytics.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./auth-admin": {
|
|
21
|
+
"types": "./auth-admin.d.ts",
|
|
22
|
+
"import": "./auth-admin.js",
|
|
23
|
+
"require": "./auth-admin.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./business": {
|
|
26
|
+
"types": "./business.d.ts",
|
|
27
|
+
"import": "./business.js",
|
|
28
|
+
"require": "./business.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./campaign": {
|
|
31
|
+
"types": "./campaign.d.ts",
|
|
32
|
+
"import": "./campaign.js",
|
|
33
|
+
"require": "./campaign.cjs"
|
|
11
34
|
},
|
|
12
35
|
"./core": {
|
|
13
36
|
"types": "./core.d.ts",
|
|
14
|
-
"import": "./core.
|
|
15
|
-
"require": "./core.
|
|
37
|
+
"import": "./core.js",
|
|
38
|
+
"require": "./core.cjs"
|
|
16
39
|
},
|
|
17
|
-
"./
|
|
18
|
-
"types": "./
|
|
19
|
-
"import": "./
|
|
20
|
-
"require": "./
|
|
40
|
+
"./donation": {
|
|
41
|
+
"types": "./donation.d.ts",
|
|
42
|
+
"import": "./donation.js",
|
|
43
|
+
"require": "./donation.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./payment": {
|
|
46
|
+
"types": "./payment.d.ts",
|
|
47
|
+
"import": "./payment.js",
|
|
48
|
+
"require": "./payment.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./redemption": {
|
|
51
|
+
"types": "./redemption.d.ts",
|
|
52
|
+
"import": "./redemption.js",
|
|
53
|
+
"require": "./redemption.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./tenant": {
|
|
56
|
+
"types": "./tenant.d.ts",
|
|
57
|
+
"import": "./tenant.js",
|
|
58
|
+
"require": "./tenant.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./token": {
|
|
61
|
+
"types": "./token.d.ts",
|
|
62
|
+
"import": "./token.js",
|
|
63
|
+
"require": "./token.cjs"
|
|
64
|
+
},
|
|
65
|
+
"./transaction": {
|
|
66
|
+
"types": "./transaction.d.ts",
|
|
67
|
+
"import": "./transaction.js",
|
|
68
|
+
"require": "./transaction.cjs"
|
|
69
|
+
},
|
|
70
|
+
"./user": {
|
|
71
|
+
"types": "./user.d.ts",
|
|
72
|
+
"import": "./user.js",
|
|
73
|
+
"require": "./user.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./user-status": {
|
|
76
|
+
"types": "./user-status.d.ts",
|
|
77
|
+
"import": "./user-status.js",
|
|
78
|
+
"require": "./user-status.cjs"
|
|
79
|
+
},
|
|
80
|
+
"./web3-chain": {
|
|
81
|
+
"types": "./web3-chain.d.ts",
|
|
82
|
+
"import": "./web3-chain.js",
|
|
83
|
+
"require": "./web3-chain.cjs"
|
|
84
|
+
},
|
|
85
|
+
"./web3": {
|
|
86
|
+
"types": "./web3.d.ts",
|
|
87
|
+
"import": "./web3.js",
|
|
88
|
+
"require": "./web3.cjs"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"typesVersions": {
|
|
92
|
+
"*": {
|
|
93
|
+
"analytics": ["./analytics.d.ts"],
|
|
94
|
+
"auth-admin": ["./auth-admin.d.ts"],
|
|
95
|
+
"business": ["./business.d.ts"],
|
|
96
|
+
"campaign": ["./campaign.d.ts"],
|
|
97
|
+
"core": ["./core.d.ts"],
|
|
98
|
+
"donation": ["./donation.d.ts"],
|
|
99
|
+
"payment": ["./payment.d.ts"],
|
|
100
|
+
"redemption": ["./redemption.d.ts"],
|
|
101
|
+
"tenant": ["./tenant.d.ts"],
|
|
102
|
+
"token": ["./token.d.ts"],
|
|
103
|
+
"transaction": ["./transaction.d.ts"],
|
|
104
|
+
"user": ["./user.d.ts"],
|
|
105
|
+
"user-status": ["./user-status.d.ts"],
|
|
106
|
+
"web3-chain": ["./web3-chain.d.ts"],
|
|
107
|
+
"web3": ["./web3.d.ts"]
|
|
21
108
|
}
|
|
22
109
|
},
|
|
23
110
|
"scripts": {
|
|
24
|
-
"build": "rollup -c",
|
|
111
|
+
"build": "rollup -c && node scripts/copy-declarations.js",
|
|
25
112
|
"build:watch": "rollup -c --watch",
|
|
26
113
|
"clean": "rimraf dist",
|
|
27
114
|
"test": "jest",
|
|
@@ -30,9 +117,6 @@
|
|
|
30
117
|
"prepublishOnly": "npm run clean && npm run build",
|
|
31
118
|
"publish": "npm publish"
|
|
32
119
|
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@explorins/pers-shared": "*"
|
|
35
|
-
},
|
|
36
120
|
"devDependencies": {
|
|
37
121
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
38
122
|
"@types/jest": "^29.5.12",
|
|
@@ -43,7 +127,8 @@
|
|
|
43
127
|
"typescript": "^5.4.5"
|
|
44
128
|
},
|
|
45
129
|
"peerDependencies": {
|
|
46
|
-
"@explorins/pers-shared": "*"
|
|
130
|
+
"@explorins/pers-shared": "*",
|
|
131
|
+
"jwt-decode": "^3.0.0 || ^4.0.0"
|
|
47
132
|
},
|
|
48
133
|
"publishConfig": {
|
|
49
134
|
"access": "public",
|
package/rollup.config.js
CHANGED
|
@@ -1,68 +1,56 @@
|
|
|
1
1
|
import typescript from '@rollup/plugin-typescript';
|
|
2
2
|
import copy from 'rollup-plugin-copy';
|
|
3
|
+
import { domains } from './config/domains.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
input: 'src/business/index.ts',
|
|
33
|
-
output: [
|
|
34
|
-
{
|
|
35
|
-
file: 'dist/business.js',
|
|
36
|
-
format: 'cjs',
|
|
37
|
-
sourcemap: true
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
file: 'dist/business.esm.js',
|
|
41
|
-
format: 'esm',
|
|
42
|
-
sourcemap: true
|
|
5
|
+
// Generate domain configurations
|
|
6
|
+
const domainConfigs = domains.map(domain => ({
|
|
7
|
+
input: `src/${domain.name}/index.ts`,
|
|
8
|
+
output: [
|
|
9
|
+
{
|
|
10
|
+
file: `dist/${domain.name}.cjs`,
|
|
11
|
+
format: 'cjs',
|
|
12
|
+
sourcemap: true,
|
|
13
|
+
exports: 'named'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
file: `dist/${domain.name}.js`,
|
|
17
|
+
format: 'esm',
|
|
18
|
+
sourcemap: true
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
plugins: [
|
|
22
|
+
typescript({
|
|
23
|
+
tsconfig: './tsconfig.json',
|
|
24
|
+
declaration: true,
|
|
25
|
+
declarationMap: true,
|
|
26
|
+
outDir: './dist/temp',
|
|
27
|
+
declarationDir: './dist/temp',
|
|
28
|
+
compilerOptions: {
|
|
29
|
+
rootDir: './src',
|
|
30
|
+
outDir: './dist/temp',
|
|
31
|
+
declarationDir: './dist/temp'
|
|
43
32
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
external: ['@explorins/pers-shared', 'rxjs', 'rxjs/operators']
|
|
53
|
-
},
|
|
33
|
+
})
|
|
34
|
+
],
|
|
35
|
+
external: domain.externals
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
export default [
|
|
39
|
+
// All domain configurations
|
|
40
|
+
...domainConfigs,
|
|
54
41
|
|
|
55
42
|
// Main entry point (everything)
|
|
56
43
|
{
|
|
57
44
|
input: 'src/index.ts',
|
|
58
45
|
output: [
|
|
59
46
|
{
|
|
60
|
-
file: 'dist/index.
|
|
47
|
+
file: 'dist/index.cjs',
|
|
61
48
|
format: 'cjs',
|
|
62
|
-
sourcemap: true
|
|
49
|
+
sourcemap: true,
|
|
50
|
+
exports: 'named'
|
|
63
51
|
},
|
|
64
52
|
{
|
|
65
|
-
file: 'dist/index.
|
|
53
|
+
file: 'dist/index.js',
|
|
66
54
|
format: 'esm',
|
|
67
55
|
sourcemap: true
|
|
68
56
|
}
|
|
@@ -71,7 +59,9 @@ export default [
|
|
|
71
59
|
typescript({
|
|
72
60
|
tsconfig: './tsconfig.json',
|
|
73
61
|
declaration: true,
|
|
74
|
-
|
|
62
|
+
declarationMap: true,
|
|
63
|
+
declarationDir: './dist',
|
|
64
|
+
outDir: './dist'
|
|
75
65
|
}),
|
|
76
66
|
copy({
|
|
77
67
|
targets: [
|
|
@@ -79,6 +69,6 @@ export default [
|
|
|
79
69
|
]
|
|
80
70
|
})
|
|
81
71
|
],
|
|
82
|
-
external: ['@explorins/pers-shared', '
|
|
72
|
+
external: ['@explorins/pers-shared', 'web3', 'jwt-decode', '@explorins/web3-ts', 'ethers'] // All dependencies
|
|
83
73
|
}
|
|
84
74
|
];
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
// Import domain names from shared configuration
|
|
8
|
+
import { domainNames } from '../config/domains.js';
|
|
9
|
+
|
|
10
|
+
// Get __dirname equivalent for ES modules
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
|
|
14
|
+
const distPath = path.join(__dirname, '..', 'dist');
|
|
15
|
+
const tempPath = path.join(distPath, 'temp');
|
|
16
|
+
|
|
17
|
+
console.log('Copying domain declaration files...');
|
|
18
|
+
|
|
19
|
+
// Ensure dist directory exists
|
|
20
|
+
if (!fs.existsSync(distPath)) {
|
|
21
|
+
fs.mkdirSync(distPath, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let copiedCount = 0;
|
|
25
|
+
let errors = [];
|
|
26
|
+
|
|
27
|
+
for (const domain of domainNames) {
|
|
28
|
+
const sourcePath = path.join(tempPath, domain, 'index.d.ts');
|
|
29
|
+
const targetPath = path.join(distPath, `${domain}.d.ts`);
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
if (fs.existsSync(sourcePath)) {
|
|
33
|
+
let content = fs.readFileSync(sourcePath, 'utf8');
|
|
34
|
+
|
|
35
|
+
// Fix relative imports for the root-level declaration files
|
|
36
|
+
// Convert './api/something' to './domain/api/something'
|
|
37
|
+
// Convert './models' to './domain/models'
|
|
38
|
+
// Convert './services/something' to './domain/services/something'
|
|
39
|
+
content = content.replace(
|
|
40
|
+
/from ['"]\.\/(api|models|services)([^'"]*)['"]/g,
|
|
41
|
+
`from './${domain}/$1$2'`
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Also fix export statements
|
|
45
|
+
content = content.replace(
|
|
46
|
+
/export \{ ([^}]+) \} from ['"]\.\/(api|models|services)([^'"]*)['"]/g,
|
|
47
|
+
`export { $1 } from './${domain}/$2$3'`
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Fix export * statements
|
|
51
|
+
content = content.replace(
|
|
52
|
+
/export \* from ['"]\.\/(api|models|services)([^'"]*)['"]/g,
|
|
53
|
+
`export * from './${domain}/$1$2'`
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Fix problematic import paths that reference @explorins/pers-shared directly
|
|
57
|
+
// Replace specific import patterns with the re-exported types
|
|
58
|
+
content = content.replace(
|
|
59
|
+
/import\("@explorins\/pers-shared\/[^"]+"\)\.(\w+)/g,
|
|
60
|
+
'$1'
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// Fix centralized interface imports - convert relative paths to correct dist structure
|
|
64
|
+
content = content.replace(
|
|
65
|
+
/from ['"]\.\.\/(shared\/interfaces\/pers-shared-lib\.interfaces)['"]/g,
|
|
66
|
+
`from './$1'`
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// Fix centralized interface exports
|
|
70
|
+
content = content.replace(
|
|
71
|
+
/export \* from ['"]\.\.\/(shared\/interfaces\/pers-shared-lib\.interfaces)['"]/g,
|
|
72
|
+
`export * from './$1'`
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Fix core imports - convert ../core/ to ./core/
|
|
76
|
+
content = content.replace(
|
|
77
|
+
/from ['"]\.\.\/(core\/[^'"]*)['"]/g,
|
|
78
|
+
`from './$1'`
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// Fix pers-sdk imports - convert ../pers-sdk to ./pers-sdk
|
|
82
|
+
content = content.replace(
|
|
83
|
+
/from ['"]\.\.\/(pers-sdk)['"]/g,
|
|
84
|
+
`from './$1'`
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Fix cross-domain imports - convert ../domain-name/ to ./domain-name/
|
|
88
|
+
content = content.replace(
|
|
89
|
+
/from ['"]\.\.\/(web3-chain|core|business|payment|user|transaction|campaign|analytics|auth-admin|donation|redemption|tenant|token|user-status|web3)\/([^'"]*)['"]/g,
|
|
90
|
+
`from './$1/$2'`
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Fix relative imports within domain files - they need to reference the domain subfolder
|
|
94
|
+
// But skip paths that already reference shared, core, or business subdirectories correctly
|
|
95
|
+
if (!content.includes('./shared/interfaces/') && !content.includes('./core/')) {
|
|
96
|
+
content = content.replace(
|
|
97
|
+
/from ['"]\.\/([^'"]+)['"]/g,
|
|
98
|
+
(match, path) => {
|
|
99
|
+
// Don't transform if it's already correctly prefixed
|
|
100
|
+
if (path.startsWith(`${domain}/`) || path.startsWith('shared/') || path.startsWith('core/')) {
|
|
101
|
+
return match;
|
|
102
|
+
}
|
|
103
|
+
return `from './${domain}/${path}'`;
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
content = content.replace(
|
|
108
|
+
/export \* from ['"]\.\/([^'"]+)['"]/g,
|
|
109
|
+
(match, path) => {
|
|
110
|
+
if (path.startsWith(`${domain}/`) || path.startsWith('shared/') || path.startsWith('core/')) {
|
|
111
|
+
return match;
|
|
112
|
+
}
|
|
113
|
+
return `export * from './${domain}/${path}'`;
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fs.writeFileSync(targetPath, content);
|
|
119
|
+
console.log(`✓ Copied ${domain}.d.ts`);
|
|
120
|
+
copiedCount++;
|
|
121
|
+
} else {
|
|
122
|
+
errors.push(`Source file not found: ${sourcePath}`);
|
|
123
|
+
}
|
|
124
|
+
} catch (error) {
|
|
125
|
+
errors.push(`Error copying ${domain}.d.ts: ${error.message}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Clean up temp directory
|
|
130
|
+
try {
|
|
131
|
+
if (fs.existsSync(tempPath)) {
|
|
132
|
+
fs.rmSync(tempPath, { recursive: true, force: true });
|
|
133
|
+
console.log('✓ Cleaned up temp directory');
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.warn(`Warning: Could not clean up temp directory: ${error.message}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
console.log(`\nSummary: ${copiedCount}/${domainNames.length} declaration files copied successfully`);
|
|
140
|
+
|
|
141
|
+
if (errors.length > 0) {
|
|
142
|
+
console.error('\nErrors encountered:');
|
|
143
|
+
errors.forEach(error => console.error(` - ${error}`));
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
console.log('✓ All declaration files copied successfully!');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PersApiClient } from '../../core/pers-api-client';
|
|
2
|
+
import { TransactionAnalyticsRequestDTO, TransactionAnalyticsResponseDTO } from '../models';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Platform-Agnostic Analytics API Client
|
|
7
|
+
*
|
|
8
|
+
* Handles analytics operations using the PERS backend.
|
|
9
|
+
* Uses @explorins/pers-shared DTOs for consistency with backend.
|
|
10
|
+
*/
|
|
11
|
+
export class AnalyticsApi {
|
|
12
|
+
constructor(private apiClient: PersApiClient) {}
|
|
13
|
+
|
|
14
|
+
// ==========================================
|
|
15
|
+
// ADMIN OPERATIONS
|
|
16
|
+
// ==========================================
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* ADMIN: Get transaction analytics with filtering and aggregation
|
|
20
|
+
*/
|
|
21
|
+
async getTransactionAnalytics(request: TransactionAnalyticsRequestDTO): Promise<TransactionAnalyticsResponseDTO> {
|
|
22
|
+
return this.apiClient.post<TransactionAnalyticsResponseDTO>('/transactions/analytics', request);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @explorins/pers-sdk-analytics
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic Analytics Domain SDK for PERS ecosystem
|
|
5
|
+
* Handles analytics operations and data aggregation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// API Layer
|
|
9
|
+
export { AnalyticsApi } from './api/analytics-api';
|
|
10
|
+
|
|
11
|
+
// Service Layer
|
|
12
|
+
export { AnalyticsService } from './services/analytics-service';
|
|
13
|
+
|
|
14
|
+
// Models & Types
|
|
15
|
+
export * from './models';
|
|
16
|
+
export * from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
17
|
+
|
|
18
|
+
// Base Service (for inheritance pattern)
|
|
19
|
+
// Note: BaseAnalyticsService not yet implemented - using factory pattern for now
|
|
20
|
+
|
|
21
|
+
// Models & Types
|
|
22
|
+
export * from './models';
|
|
23
|
+
|
|
24
|
+
// Factory function for creating analytics SDK instance
|
|
25
|
+
import { PersApiClient } from '../core/pers-api-client';
|
|
26
|
+
import { AnalyticsApi } from './api/analytics-api';
|
|
27
|
+
import { TransactionAnalyticsRequestDTO } from './models';
|
|
28
|
+
import { AnalyticsService } from './services/analytics-service';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create a complete Analytics SDK instance
|
|
32
|
+
*
|
|
33
|
+
* @param apiClient - Configured PERS API client
|
|
34
|
+
* @returns Analytics SDK with flattened structure for better DX
|
|
35
|
+
*/
|
|
36
|
+
export function createAnalyticsSDK(apiClient: PersApiClient) {
|
|
37
|
+
const analyticsApi = new AnalyticsApi(apiClient);
|
|
38
|
+
const analyticsService = new AnalyticsService(analyticsApi);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
// Direct access to service methods (primary interface)
|
|
42
|
+
|
|
43
|
+
// Admin methods
|
|
44
|
+
getTransactionAnalytics: (request: TransactionAnalyticsRequestDTO) => analyticsService.getTransactionAnalytics(request),
|
|
45
|
+
|
|
46
|
+
// Advanced access for edge cases
|
|
47
|
+
api: analyticsApi,
|
|
48
|
+
service: analyticsService
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type AnalyticsSDK = ReturnType<typeof createAnalyticsSDK>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytics Domain Models
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from @explorins/pers-shared for consistency with backend
|
|
5
|
+
* and to provide a single import source for analytics-related types.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Core analytics entities
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface TransactionAnalyticsGroupByExpression {
|
|
12
|
+
expression: string;
|
|
13
|
+
alias: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TransactionAnalyticsRequestDTO {
|
|
17
|
+
filters?: TransactionAnalyticsFilters;
|
|
18
|
+
groupBy?: TransactionAnalyticsGroupBy[];
|
|
19
|
+
groupByExpressions?: TransactionAnalyticsGroupByExpression[];
|
|
20
|
+
metrics?: TransactionAnalyticsMetric[];
|
|
21
|
+
orderBy?: string;
|
|
22
|
+
orderDirection?: 'ASC' | 'DESC';
|
|
23
|
+
limit?: number;
|
|
24
|
+
startDate?: string;
|
|
25
|
+
endDate?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type TransactionAnalyticsFilters = {
|
|
29
|
+
status?: string;
|
|
30
|
+
tokenType?: string;
|
|
31
|
+
triggerProcessType?: string;
|
|
32
|
+
tenantId?: string;
|
|
33
|
+
chainId?: number;
|
|
34
|
+
type?: string;
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type TransactionAnalyticsGroupBy =
|
|
39
|
+
| 'month' | 'week' | 'day' | 'year' | 'quarter'
|
|
40
|
+
| 'tokenType' | 'status' | 'chainId' | 'triggerProcessType' | 'type'
|
|
41
|
+
| 'senderAddress' | 'recipientAddress' | 'senderId' | 'recipientId' | 'senderOwnerType' | 'recipientOwnerType' | 'createdAt';
|
|
42
|
+
|
|
43
|
+
export type TransactionAnalyticsMetric =
|
|
44
|
+
| 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
45
|
+
|
|
46
|
+
export interface TransactionAnalyticsResultItem {
|
|
47
|
+
[key: string]: string | number | Date | undefined;
|
|
48
|
+
count?: string;
|
|
49
|
+
sum?: number;
|
|
50
|
+
avg?: number;
|
|
51
|
+
min?: number;
|
|
52
|
+
max?: number;
|
|
53
|
+
tokentype?: string;
|
|
54
|
+
tokenType?: string;
|
|
55
|
+
year?: string;
|
|
56
|
+
month?: string;
|
|
57
|
+
type?: string;
|
|
58
|
+
senderaddress?: string;
|
|
59
|
+
senderAddress?: string;
|
|
60
|
+
recipientaddress?: string;
|
|
61
|
+
recipientAddress?: string;
|
|
62
|
+
triggerprocesstype?: string;
|
|
63
|
+
triggerProcessType?: string;
|
|
64
|
+
userid?: string;
|
|
65
|
+
userId?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface TransactionAnalyticsResponseDTO {
|
|
69
|
+
results: TransactionAnalyticsResultItem[];
|
|
70
|
+
totalGroups: number;
|
|
71
|
+
metadata: {
|
|
72
|
+
executionTime: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AnalyticsApi } from '../api/analytics-api';
|
|
2
|
+
import {
|
|
3
|
+
TransactionAnalyticsRequestDTO,
|
|
4
|
+
TransactionAnalyticsResponseDTO
|
|
5
|
+
} from '../models';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Platform-Agnostic Analytics Service
|
|
9
|
+
*
|
|
10
|
+
* Contains analytics business logic and operations that work across platforms.
|
|
11
|
+
* No framework dependencies - pure TypeScript business logic.
|
|
12
|
+
*
|
|
13
|
+
* Focuses only on actual backend capabilities.
|
|
14
|
+
*/
|
|
15
|
+
export class AnalyticsService {
|
|
16
|
+
constructor(private analyticsApi: AnalyticsApi) {}
|
|
17
|
+
|
|
18
|
+
// ==========================================
|
|
19
|
+
// ADMIN OPERATIONS
|
|
20
|
+
// ==========================================
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* ADMIN: Get transaction analytics with filtering and aggregation
|
|
24
|
+
*/
|
|
25
|
+
async getTransactionAnalytics(request: TransactionAnalyticsRequestDTO): Promise<TransactionAnalyticsResponseDTO> {
|
|
26
|
+
return this.analyticsApi.getTransactionAnalytics(request);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PersApiClient } from '../../core/pers-api-client';
|
|
2
|
+
import {
|
|
3
|
+
AdminDTO,
|
|
4
|
+
SessionAuthResponseDTO as TokenRefreshResponse,
|
|
5
|
+
SessionAuthResponseDTO as AdminLoginResponseDTO
|
|
6
|
+
} from '../../shared/interfaces/pers-shared-lib.interfaces';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Platform-Agnostic Auth Admin API Client
|
|
10
|
+
*
|
|
11
|
+
* Handles authentication and authorization admin operations using the PERS backend.
|
|
12
|
+
* Uses @explorins/pers-shared DTOs for consistency with backend.
|
|
13
|
+
*
|
|
14
|
+
* Note: Special header handling (bypass-auth-interceptor) may need to be implemented
|
|
15
|
+
* at the PersApiClient level or through a specialized auth client.
|
|
16
|
+
*/
|
|
17
|
+
export class AuthAdminApi {
|
|
18
|
+
constructor(private apiClient: PersApiClient) {}
|
|
19
|
+
|
|
20
|
+
private readonly basePath = '/auth';
|
|
21
|
+
|
|
22
|
+
// ==========================================
|
|
23
|
+
// ADMIN AUTHENTICATION OPERATIONS
|
|
24
|
+
// ==========================================
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* ADMIN: Login tenant admin with JWT
|
|
28
|
+
* Note: JWT handling and auth bypass headers may need special implementation
|
|
29
|
+
*/
|
|
30
|
+
async loginTenantAdmin(jwt: string): Promise<AdminLoginResponseDTO> {
|
|
31
|
+
// TODO: Implement proper JWT and bypass header handling when PersApiClient supports it
|
|
32
|
+
return this.apiClient.post<AdminLoginResponseDTO>(`${this.basePath}/token`, {});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* ADMIN: Refresh access token
|
|
37
|
+
* Note: Bypass header handling may need special implementation
|
|
38
|
+
*/
|
|
39
|
+
async refreshAccessToken(refreshToken: string): Promise<TokenRefreshResponse> {
|
|
40
|
+
return this.apiClient.post<TokenRefreshResponse>(`${this.basePath}/refresh`, { refreshToken });
|
|
41
|
+
}
|
|
42
|
+
}
|