@explorins/pers-sdk 1.1.0-beta.0 → 1.1.3

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 (239) hide show
  1. package/dist/analytics/api/analytics-api.d.ts +17 -0
  2. package/dist/analytics/api/analytics-api.d.ts.map +1 -0
  3. package/dist/analytics/index.d.ts +28 -0
  4. package/dist/analytics/index.d.ts.map +1 -0
  5. package/dist/analytics/models/index.d.ts +61 -0
  6. package/dist/analytics/models/index.d.ts.map +1 -0
  7. package/dist/analytics/services/analytics-service.d.ts +19 -0
  8. package/dist/analytics/services/analytics-service.d.ts.map +1 -0
  9. package/dist/analytics.cjs +76 -0
  10. package/dist/analytics.cjs.map +1 -0
  11. package/dist/analytics.d.ts +28 -0
  12. package/dist/analytics.js +72 -0
  13. package/dist/analytics.js.map +1 -0
  14. package/dist/auth-admin/api/auth-admin-api.d.ts +27 -0
  15. package/dist/auth-admin/api/auth-admin-api.d.ts.map +1 -0
  16. package/dist/auth-admin/index.d.ts +26 -0
  17. package/dist/auth-admin/index.d.ts.map +1 -0
  18. package/dist/auth-admin/services/auth-admin-service.d.ts +23 -0
  19. package/dist/auth-admin/services/auth-admin-service.d.ts.map +1 -0
  20. package/dist/auth-admin.cjs +96 -0
  21. package/dist/auth-admin.cjs.map +1 -0
  22. package/dist/auth-admin.d.ts +26 -0
  23. package/dist/auth-admin.js +92 -0
  24. package/dist/auth-admin.js.map +1 -0
  25. package/dist/business/api/business-api.d.ts +133 -0
  26. package/dist/business/api/business-api.d.ts.map +1 -0
  27. package/dist/business/index.d.ts +34 -0
  28. package/dist/business/index.d.ts.map +1 -0
  29. package/{src/business/models/index.ts → dist/business/models/index.d.ts} +8 -13
  30. package/dist/business/models/index.d.ts.map +1 -0
  31. package/dist/business/services/business-service.d.ts +51 -0
  32. package/dist/business/services/business-service.d.ts.map +1 -0
  33. package/dist/business.cjs +303 -0
  34. package/dist/business.cjs.map +1 -0
  35. package/dist/business.d.ts +34 -0
  36. package/dist/business.js +299 -0
  37. package/dist/business.js.map +1 -0
  38. package/dist/campaign/api/campaign-api.d.ts +213 -0
  39. package/dist/campaign/api/campaign-api.d.ts.map +1 -0
  40. package/dist/campaign/index.d.ts +44 -0
  41. package/dist/campaign/index.d.ts.map +1 -0
  42. package/dist/campaign/services/campaign-service.d.ts +88 -0
  43. package/dist/campaign/services/campaign-service.d.ts.map +1 -0
  44. package/dist/campaign.cjs +506 -0
  45. package/dist/campaign.cjs.map +1 -0
  46. package/dist/campaign.d.ts +44 -0
  47. package/dist/campaign.js +502 -0
  48. package/dist/campaign.js.map +1 -0
  49. package/dist/core/abstractions/http-client.d.ts +22 -0
  50. package/dist/core/abstractions/http-client.d.ts.map +1 -0
  51. package/dist/core/auth/auth-provider.interface.d.ts +12 -0
  52. package/dist/core/auth/auth-provider.interface.d.ts.map +1 -0
  53. package/dist/core/auth/create-auth-provider.d.ts +27 -0
  54. package/dist/core/auth/create-auth-provider.d.ts.map +1 -0
  55. package/dist/core/auth/simple-auth-config.interface.d.ts +15 -0
  56. package/dist/core/auth/simple-auth-config.interface.d.ts.map +1 -0
  57. package/dist/core/index.d.ts +13 -0
  58. package/dist/core/index.d.ts.map +1 -0
  59. package/dist/core/pers-api-client.d.ts +54 -0
  60. package/dist/core/pers-api-client.d.ts.map +1 -0
  61. package/dist/core/pers-config.d.ts +38 -0
  62. package/dist/core/pers-config.d.ts.map +1 -0
  63. package/dist/core/utils/jwt.function.d.ts +2 -0
  64. package/dist/core/utils/jwt.function.d.ts.map +1 -0
  65. package/dist/core.cjs +506 -0
  66. package/dist/core.cjs.map +1 -0
  67. package/dist/core.d.ts +13 -0
  68. package/dist/core.js +497 -0
  69. package/dist/core.js.map +1 -0
  70. package/dist/donation/api/donation-api.d.ts +18 -0
  71. package/dist/donation/api/donation-api.d.ts.map +1 -0
  72. package/dist/donation/index.d.ts +25 -0
  73. package/dist/donation/index.d.ts.map +1 -0
  74. package/dist/donation/models/index.d.ts +8 -0
  75. package/dist/donation/models/index.d.ts.map +1 -0
  76. package/dist/donation/services/donation-service.d.ts +19 -0
  77. package/dist/donation/services/donation-service.d.ts.map +1 -0
  78. package/dist/donation.cjs +78 -0
  79. package/dist/donation.cjs.map +1 -0
  80. package/dist/donation.d.ts +25 -0
  81. package/dist/donation.js +74 -0
  82. package/dist/donation.js.map +1 -0
  83. package/dist/index.cjs +4217 -0
  84. package/dist/index.cjs.map +1 -0
  85. package/dist/index.d.ts +21 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +4164 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/package.json +148 -0
  90. package/dist/payment/api/payment-api.d.ts +105 -0
  91. package/dist/payment/api/payment-api.d.ts.map +1 -0
  92. package/dist/payment/index.d.ts +36 -0
  93. package/dist/payment/index.d.ts.map +1 -0
  94. package/dist/payment/models/index.d.ts +12 -0
  95. package/dist/payment/models/index.d.ts.map +1 -0
  96. package/dist/payment/services/payment-service.d.ts +40 -0
  97. package/dist/payment/services/payment-service.d.ts.map +1 -0
  98. package/dist/payment.cjs +258 -0
  99. package/dist/payment.cjs.map +1 -0
  100. package/dist/payment.d.ts +36 -0
  101. package/dist/payment.js +254 -0
  102. package/dist/payment.js.map +1 -0
  103. package/dist/pers-sdk.d.ts +29 -0
  104. package/dist/pers-sdk.d.ts.map +1 -0
  105. package/dist/redemption/api/redemption-api.d.ts +147 -0
  106. package/dist/redemption/api/redemption-api.d.ts.map +1 -0
  107. package/dist/redemption/index.d.ts +35 -0
  108. package/dist/redemption/index.d.ts.map +1 -0
  109. package/dist/redemption/models/index.d.ts +8 -0
  110. package/dist/redemption/models/index.d.ts.map +1 -0
  111. package/dist/redemption/services/redemption-service.d.ts +56 -0
  112. package/dist/redemption/services/redemption-service.d.ts.map +1 -0
  113. package/dist/redemption.cjs +333 -0
  114. package/dist/redemption.cjs.map +1 -0
  115. package/dist/redemption.d.ts +35 -0
  116. package/dist/redemption.js +329 -0
  117. package/dist/redemption.js.map +1 -0
  118. package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts +18 -0
  119. package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts.map +1 -0
  120. package/dist/tenant/api/tenant-api.d.ts +56 -0
  121. package/dist/tenant/api/tenant-api.d.ts.map +1 -0
  122. package/dist/tenant/index.d.ts +34 -0
  123. package/dist/tenant/index.d.ts.map +1 -0
  124. package/dist/tenant/models/index.d.ts +11 -0
  125. package/dist/tenant/models/index.d.ts.map +1 -0
  126. package/dist/tenant/services/tenant-service.d.ts +46 -0
  127. package/dist/tenant/services/tenant-service.d.ts.map +1 -0
  128. package/dist/tenant.cjs +177 -0
  129. package/dist/tenant.cjs.map +1 -0
  130. package/dist/tenant.d.ts +34 -0
  131. package/dist/tenant.js +173 -0
  132. package/dist/tenant.js.map +1 -0
  133. package/dist/token/api/token-api.d.ts +64 -0
  134. package/dist/token/api/token-api.d.ts.map +1 -0
  135. package/dist/token/base/base-token-service.d.ts +87 -0
  136. package/dist/token/base/base-token-service.d.ts.map +1 -0
  137. package/dist/token/index.d.ts +13 -0
  138. package/dist/token/index.d.ts.map +1 -0
  139. package/dist/token/models/index.d.ts +18 -0
  140. package/dist/token/models/index.d.ts.map +1 -0
  141. package/dist/token/services/token-service.d.ts +68 -0
  142. package/dist/token/services/token-service.d.ts.map +1 -0
  143. package/dist/token/token-sdk.d.ts +140 -0
  144. package/dist/token/token-sdk.d.ts.map +1 -0
  145. package/dist/token.cjs +537 -0
  146. package/dist/token.cjs.map +1 -0
  147. package/dist/token.d.ts +13 -0
  148. package/dist/token.js +532 -0
  149. package/dist/token.js.map +1 -0
  150. package/dist/transaction/api/transaction-api.d.ts +133 -0
  151. package/dist/transaction/api/transaction-api.d.ts.map +1 -0
  152. package/dist/transaction/index.d.ts +38 -0
  153. package/dist/transaction/index.d.ts.map +1 -0
  154. package/dist/transaction/models/index.d.ts +42 -0
  155. package/dist/transaction/models/index.d.ts.map +1 -0
  156. package/dist/transaction/services/transaction-service.d.ts +56 -0
  157. package/dist/transaction/services/transaction-service.d.ts.map +1 -0
  158. package/dist/transaction.cjs +394 -0
  159. package/dist/transaction.cjs.map +1 -0
  160. package/dist/transaction.d.ts +38 -0
  161. package/dist/transaction.js +390 -0
  162. package/dist/transaction.js.map +1 -0
  163. package/dist/user/api/user-api.d.ts +56 -0
  164. package/dist/user/api/user-api.d.ts.map +1 -0
  165. package/dist/user/index.d.ts +36 -0
  166. package/dist/user/index.d.ts.map +1 -0
  167. package/dist/user/models/index.d.ts +12 -0
  168. package/dist/user/models/index.d.ts.map +1 -0
  169. package/dist/user/services/user-service.d.ts +46 -0
  170. package/dist/user/services/user-service.d.ts.map +1 -0
  171. package/dist/user-status/api/user-status-api.d.ts +37 -0
  172. package/dist/user-status/api/user-status-api.d.ts.map +1 -0
  173. package/dist/user-status/index.d.ts +28 -0
  174. package/dist/user-status/index.d.ts.map +1 -0
  175. package/dist/user-status/models/index.d.ts +8 -0
  176. package/dist/user-status/models/index.d.ts.map +1 -0
  177. package/dist/user-status/services/user-status-service.d.ts +26 -0
  178. package/dist/user-status/services/user-status-service.d.ts.map +1 -0
  179. package/dist/user-status.cjs +147 -0
  180. package/dist/user-status.cjs.map +1 -0
  181. package/dist/user-status.d.ts +28 -0
  182. package/dist/user-status.js +143 -0
  183. package/dist/user-status.js.map +1 -0
  184. package/dist/user.cjs +188 -0
  185. package/dist/user.cjs.map +1 -0
  186. package/dist/user.d.ts +36 -0
  187. package/dist/user.js +184 -0
  188. package/dist/user.js.map +1 -0
  189. package/dist/web3/api/web3-api.d.ts +27 -0
  190. package/dist/web3/api/web3-api.d.ts.map +1 -0
  191. package/dist/web3/index.d.ts +16 -0
  192. package/dist/web3/index.d.ts.map +1 -0
  193. package/dist/web3/models/index.d.ts +92 -0
  194. package/dist/web3/models/index.d.ts.map +1 -0
  195. package/dist/web3/services/web3-service.d.ts +21 -0
  196. package/dist/web3/services/web3-service.d.ts.map +1 -0
  197. package/dist/web3-chain/api/web3-chain-api.d.ts +19 -0
  198. package/dist/web3-chain/api/web3-chain-api.d.ts.map +1 -0
  199. package/dist/web3-chain/index.d.ts +17 -0
  200. package/dist/web3-chain/index.d.ts.map +1 -0
  201. package/dist/web3-chain/models/index.d.ts +38 -0
  202. package/dist/web3-chain/models/index.d.ts.map +1 -0
  203. package/dist/web3-chain/services/getWeb3FCD.service.d.ts +8 -0
  204. package/dist/web3-chain/services/getWeb3FCD.service.d.ts.map +1 -0
  205. package/dist/web3-chain/services/provider.service.d.ts +15 -0
  206. package/dist/web3-chain/services/provider.service.d.ts.map +1 -0
  207. package/dist/web3-chain/services/public-http-provider.service.d.ts +8 -0
  208. package/dist/web3-chain/services/public-http-provider.service.d.ts.map +1 -0
  209. package/dist/web3-chain/services/web3-chain-service.d.ts +17 -0
  210. package/dist/web3-chain/services/web3-chain-service.d.ts.map +1 -0
  211. package/dist/web3-chain.cjs +316 -0
  212. package/dist/web3-chain.cjs.map +1 -0
  213. package/dist/web3-chain.d.ts +17 -0
  214. package/dist/web3-chain.js +310 -0
  215. package/dist/web3-chain.js.map +1 -0
  216. package/dist/web3.cjs +516 -0
  217. package/dist/web3.cjs.map +1 -0
  218. package/dist/web3.d.ts +16 -0
  219. package/dist/web3.js +513 -0
  220. package/dist/web3.js.map +1 -0
  221. package/package.json +105 -17
  222. package/explorins-pers-sdk-1.0.0-alpha.1.tgz +0 -0
  223. package/rollup.config.js +0 -84
  224. package/src/business/api/business-api.ts +0 -72
  225. package/src/business/business/tsconfig.json +0 -18
  226. package/src/business/index.ts +0 -52
  227. package/src/business/services/business-service.ts +0 -88
  228. package/src/core/abstractions/core-interfaces.ts +0 -56
  229. package/src/core/abstractions/http-client.ts +0 -23
  230. package/src/core/auth/auth-provider.interface.ts +0 -16
  231. package/src/core/auth/create-auth-provider.ts +0 -136
  232. package/src/core/auth/simple-auth-config.interface.ts +0 -15
  233. package/src/core/core.ts +0 -30
  234. package/src/core/pers-api-client.ts +0 -151
  235. package/src/core/pers-config.ts +0 -38
  236. package/src/core.ts +0 -30
  237. package/src/index.ts +0 -16
  238. package/src/pers-sdk.ts +0 -45
  239. package/tsconfig.json +0 -28
@@ -1,136 +0,0 @@
1
- import { AuthProvider } from './auth-provider.interface';
2
- import { SimpleAuthConfig } from './simple-auth-config.interface';
3
-
4
- /**
5
- * Creates a platform-agnostic AuthProvider from simple configuration
6
- *
7
- * This factory function is completely platform-agnostic and can be used
8
- * across Angular, React, Vue, Node.js, or any other JavaScript environment.
9
- *
10
- * Features:
11
- * - Token caching with refresh support
12
- * - Automatic token refresh on expiration
13
- * - Configurable token providers
14
- * - Platform-independent (no localStorage assumptions)
15
- *
16
- * @param config - Simple auth configuration
17
- * @returns AuthProvider implementation
18
- */
19
- export function createAuthProvider(config: SimpleAuthConfig): AuthProvider {
20
- // Store current token for refresh scenarios and caching
21
- let currentToken: string | null = config.token || null;
22
- let isRefreshing = false; // Prevent concurrent refresh attempts
23
- let refreshPromise: Promise<void> | null = null;
24
-
25
- return {
26
- authType: config.authType || 'user',
27
-
28
- async getToken(): Promise<string | null> {
29
- // If currently refreshing, wait for it to complete
30
- if (isRefreshing && refreshPromise) {
31
- await refreshPromise;
32
- return currentToken;
33
- }
34
-
35
- // Use cached current token (updated after refresh)
36
- if (currentToken) {
37
- return currentToken;
38
- }
39
-
40
- // Custom token provider function (always fresh)
41
- if (config.tokenProvider) {
42
- const token = await config.tokenProvider();
43
- currentToken = token; // Cache for future calls
44
- return token;
45
- }
46
-
47
- // No token available
48
- return null;
49
- },
50
-
51
- async getProjectKey(): Promise<string | null> {
52
- return config.projectKey || null;
53
- },
54
-
55
- async onTokenExpired(): Promise<void> {
56
- // Prevent concurrent refresh attempts
57
- if (isRefreshing) {
58
- if (refreshPromise) {
59
- await refreshPromise;
60
- }
61
- return;
62
- }
63
-
64
- // No refresh logic provided
65
- if (!config.onTokenExpired) {
66
- console.warn('Token expired but no refresh logic provided');
67
- currentToken = null; // Clear expired token
68
- return;
69
- }
70
-
71
- // Start refresh process
72
- isRefreshing = true;
73
- refreshPromise = (async () => {
74
- try {
75
- // Execute refresh logic (should update token source)
76
- await config.onTokenExpired!();
77
-
78
- // After refresh, get the new token
79
- if (config.tokenProvider) {
80
- const newToken = await config.tokenProvider();
81
- if (newToken && newToken !== currentToken) {
82
- currentToken = newToken;
83
-
84
- // Notify about successful token refresh
85
- if (config.onTokenRefreshed) {
86
- config.onTokenRefreshed(newToken);
87
- }
88
- } else {
89
- console.warn('Token refresh completed but no new token received');
90
- currentToken = null;
91
- }
92
- } else {
93
- // For static token configs, clear the token since we can't refresh
94
- console.warn('Token expired for static token config - clearing token');
95
- currentToken = null;
96
- }
97
- } catch (error) {
98
- console.error('Token refresh failed:', error);
99
- currentToken = null; // Clear token on refresh failure
100
- throw error; // Re-throw to let SDK handle the error
101
- } finally {
102
- isRefreshing = false;
103
- refreshPromise = null;
104
- }
105
- })();
106
-
107
- await refreshPromise;
108
- }
109
- };
110
- }
111
-
112
- /**
113
- * Platform-specific localStorage token provider for browsers
114
- * This is a convenience function for browser environments
115
- */
116
- export function createBrowserTokenProvider(tokenKey: string = 'userJwt'): () => Promise<string | null> {
117
- return async () => {
118
- if (typeof localStorage !== 'undefined') {
119
- return localStorage.getItem(tokenKey);
120
- }
121
- return null;
122
- };
123
- }
124
-
125
- /**
126
- * Platform-specific environment variable token provider for Node.js
127
- * This is a convenience function for Node.js environments
128
- */
129
- export function createNodeTokenProvider(envVar: string = 'JWT_TOKEN'): () => Promise<string | null> {
130
- return async () => {
131
- if (typeof process !== 'undefined' && process.env) {
132
- return process.env[envVar] || null;
133
- }
134
- return null;
135
- };
136
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Simple Auth Configuration Interface - Dev-Friendly Alternative
3
- *
4
- * Instead of implementing AuthProvider, developers can use this simple config
5
- * which will be automatically converted to a full AuthProvider implementation.
6
- */
7
- export interface SimpleAuthConfig {
8
- authType?: 'admin' | 'user' | 'firebase';
9
- token?: string;
10
- tokenProvider?: () => Promise<string | null>;
11
- projectKey?: string;
12
- onTokenExpired?: () => Promise<void>;
13
- // Advanced: for reactive token updates after refresh
14
- onTokenRefreshed?: (newToken: string) => void;
15
- }
package/src/core/core.ts DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * @explorins/pers-sdk/core - Core SDK Entry Point
3
- *
4
- * Platform-agnostic PERS API client and core functionality
5
- */
6
-
7
- // Core PERS API client
8
- export * from './pers-api-client';
9
-
10
- // Configuration interfaces
11
- export * from './pers-config';
12
-
13
- // Authentication interfaces
14
- export {
15
- AuthProvider,
16
- SimpleAuthConfig,
17
- createAuthProvider,
18
- createBrowserTokenProvider,
19
- createNodeTokenProvider
20
- } from './auth/auth-provider.interface';
21
- export type { RequestOptions as AuthRequestOptions } from './auth/auth-provider.interface';
22
-
23
- // Platform abstractions
24
- export * from './abstractions/http-client';
25
-
26
- // Main SDK class
27
- export * from '../pers-sdk';
28
-
29
- // Version
30
- export const PERS_SDK_VERSION = '1.0.0-alpha.1';
@@ -1,151 +0,0 @@
1
- /**
2
- * PERS API Client - Core platform-agnostic client for PERS backend
3
- */
4
-
5
- import { HttpClient, RequestOptions } from './abstractions/http-client';
6
- import { PersConfig, buildApiRoot } from './pers-config';
7
-
8
- export class PersApiClient {
9
- private readonly apiRoot: string;
10
-
11
- constructor(
12
- private httpClient: HttpClient,
13
- private config: PersConfig
14
- ) {
15
- // Build API root from environment and version
16
- this.apiRoot = buildApiRoot(config.environment, config.apiVersion);
17
- }
18
-
19
- /**
20
- * Get request headers including auth token and project key
21
- */
22
- private async getHeaders(): Promise<Record<string, string>> {
23
- const headers: Record<string, string> = {
24
- 'Content-Type': 'application/json',
25
- };
26
-
27
- // Add authentication token
28
- if (this.config.authProvider) {
29
- const token = await this.config.authProvider.getToken();
30
- if (token) {
31
- headers['Authorization'] = `Bearer ${token}`;
32
- }
33
- }
34
-
35
- // Add project key
36
- if (this.config.authProvider) {
37
- const projectKey = await this.config.authProvider.getProjectKey();
38
- if (projectKey) {
39
- headers['x-project-key'] = projectKey;
40
- }
41
- } else {
42
- // Fallback to config project key if no auth provider
43
- headers['x-project-key'] = this.config.apiProjectKey;
44
- }
45
-
46
- return headers;
47
- }
48
-
49
- /**
50
- * Make a request with proper headers, auth, and error handling
51
- */
52
- private async request<T>(
53
- method: 'GET' | 'POST' | 'PUT' | 'DELETE',
54
- endpoint: string,
55
- body?: any,
56
- options?: { retryCount?: number }
57
- ): Promise<T> {
58
- const { retryCount = 0 } = options || {};
59
- const url = `${this.apiRoot}${endpoint}`;
60
-
61
- const requestOptions: RequestOptions = {
62
- headers: await this.getHeaders(),
63
- timeout: this.config.timeout || 30000,
64
- };
65
-
66
- try {
67
- switch (method) {
68
- case 'GET':
69
- return await this.httpClient.get<T>(url, requestOptions);
70
- case 'POST':
71
- return await this.httpClient.post<T>(url, body, requestOptions);
72
- case 'PUT':
73
- return await this.httpClient.put<T>(url, body, requestOptions);
74
- case 'DELETE':
75
- return await this.httpClient.delete<T>(url, requestOptions);
76
- default:
77
- throw new Error(`Unsupported HTTP method: ${method}`);
78
- }
79
- } catch (error: any) {
80
- // Handle 401 errors with automatic token refresh
81
- if (error.status === 401 && retryCount === 0 && this.config.authProvider?.onTokenExpired) {
82
- try {
83
- await this.config.authProvider.onTokenExpired();
84
- // Retry once with refreshed token
85
- return this.request<T>(method, endpoint, body, { ...options, retryCount: 1 });
86
- } catch (refreshError) {
87
- throw new PersApiError(
88
- `Authentication refresh failed: ${refreshError}`,
89
- endpoint,
90
- method,
91
- 401
92
- );
93
- }
94
- }
95
-
96
- throw new PersApiError(
97
- `PERS API request failed: ${error.message || error}`,
98
- endpoint,
99
- method,
100
- error.status
101
- );
102
- }
103
- }
104
-
105
- /**
106
- * Generic GET request
107
- */
108
- async get<T>(endpoint: string): Promise<T> {
109
- return this.request<T>('GET', endpoint);
110
- }
111
-
112
- /**
113
- * Generic POST request
114
- */
115
- async post<T>(endpoint: string, body?: any): Promise<T> {
116
- return this.request<T>('POST', endpoint, body);
117
- }
118
-
119
- /**
120
- * Generic PUT request
121
- */
122
- async put<T>(endpoint: string, body?: any): Promise<T> {
123
- return this.request<T>('PUT', endpoint, body);
124
- }
125
-
126
- /**
127
- * Generic DELETE request
128
- */
129
- async delete<T>(endpoint: string): Promise<T> {
130
- return this.request<T>('DELETE', endpoint);
131
- }
132
-
133
- /**
134
- * Get current configuration
135
- */
136
- getConfig(): PersConfig {
137
- return this.config;
138
- }
139
- }
140
-
141
- export class PersApiError extends Error {
142
- constructor(
143
- message: string,
144
- public endpoint: string,
145
- public method: string,
146
- public statusCode?: number
147
- ) {
148
- super(message);
149
- this.name = 'PersApiError';
150
- }
151
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * PERS SDK Configuration interfaces
3
- */
4
-
5
- import { AuthProvider } from './auth/auth-provider.interface';
6
-
7
- export type PersEnvironment = 'development' | 'staging' | 'production';
8
- export type PersApiVersion = 'v1' | 'v1.8' | 'v1.9' | 'v2';
9
-
10
- export interface PersConfig {
11
- environment: PersEnvironment;
12
- apiProjectKey: string;
13
- apiVersion?: PersApiVersion;
14
- timeout?: number;
15
- retries?: number;
16
- authProvider?: AuthProvider;
17
- // Internal - constructed automatically
18
- readonly apiRoot?: string;
19
- }
20
-
21
- export interface PersAuthConfig {
22
- type: 'firebase' | 'jwt' | 'none';
23
- tokenProvider?: () => Promise<string | null>;
24
- }
25
-
26
- /**
27
- * Internal function to construct API root from environment
28
- */
29
-
30
- export function buildApiRoot(environment: PersEnvironment, version: PersApiVersion = 'v2'): string {
31
- const baseUrls = {
32
- development: 'https://explorins-loyalty.ngrok.io',
33
- staging: `https://dev.api.pers.ninja/${version}`,
34
- production: `https://dev.api.pers.ninja/${version}`
35
- };
36
-
37
- return `${baseUrls[environment]}`;
38
- }
package/src/core.ts DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * @explorins/pers-sdk/core - Core SDK Entry Point
3
- *
4
- * Platform-agnostic PERS API client and core functionality
5
- */
6
-
7
- // Core PERS API client
8
- export * from './core/pers-api-client';
9
-
10
- // Configuration interfaces
11
- export * from './core/pers-config';
12
-
13
- // Authentication interfaces
14
- export {
15
- AuthProvider,
16
- SimpleAuthConfig,
17
- createAuthProvider,
18
- createBrowserTokenProvider,
19
- createNodeTokenProvider
20
- } from './core/auth/auth-provider.interface';
21
- export type { RequestOptions as AuthRequestOptions } from './core/auth/auth-provider.interface';
22
-
23
- // Platform abstractions
24
- export * from './core/abstractions/http-client';
25
-
26
- // Main SDK class
27
- export * from './pers-sdk';
28
-
29
- // Version
30
- export const PERS_SDK_VERSION = '1.0.0-alpha.1';
package/src/index.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * @explorins/pers-sdk - Main Entry Point
3
- *
4
- * Platform-agnostic PERS SDK - Core and Business domains only
5
- */
6
-
7
- // Re-export everything from core
8
- export * from './core/core';
9
-
10
- // Re-export everything from business domain
11
- export * from './business';
12
-
13
- // NOTE: Angular integration available in separate package '@explorins/pers-sdk-angular'
14
- // Future domains will be added here
15
- // export * from './campaign';
16
- // export * from './challenge';
package/src/pers-sdk.ts DELETED
@@ -1,45 +0,0 @@
1
- /**
2
- * PERS SDK - Minimal platform-agnostic client with built-in authentication
3
- * Authentication is now handled at the SDK core level for better scalability
4
- */
5
-
6
- import { HttpClient } from './core/abstractions/http-client';
7
- import { PersConfig } from './core/pers-config';
8
- import { PersApiClient } from './core/pers-api-client';
9
-
10
- /**
11
- * Minimal PERS SDK - API client with authentication built-in
12
- * Platform adapters provide auth providers and HTTP clients
13
- */
14
- export class PersSDK {
15
- private apiClient: PersApiClient;
16
-
17
- constructor(httpClient: HttpClient, config: PersConfig) {
18
- this.apiClient = new PersApiClient(httpClient, config);
19
- }
20
-
21
- /**
22
- * Get the API client for direct PERS API calls
23
- * This is the main interface - keep it simple!
24
- */
25
- api(): PersApiClient {
26
- return this.apiClient;
27
- }
28
-
29
- /**
30
- * Quick config check
31
- */
32
- isProduction(): boolean {
33
- return this.apiClient.getConfig().environment === 'production';
34
- }
35
- }
36
-
37
- /**
38
- * Simple factory function
39
- */
40
- export function createPersSDK(
41
- httpClient: HttpClient,
42
- config: PersConfig
43
- ): PersSDK {
44
- return new PersSDK(httpClient, config);
45
- }
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "node",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "forceConsistentCasingInFileNames": true,
10
- "declaration": true,
11
- "declarationMap": true,
12
- "sourceMap": true,
13
- "outDir": "./dist",
14
- "baseUrl": ".",
15
- "paths": {
16
- "@explorins/pers-shared": ["../../framework/entities"]
17
- }
18
- },
19
- "include": [
20
- "src/**/*"
21
- ],
22
- "exclude": [
23
- "node_modules",
24
- "dist",
25
- "**/*.test.ts",
26
- "**/*.spec.ts"
27
- ]
28
- }