@explorins/pers-sdk 1.1.2 → 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 (291) 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/{src/analytics/index.ts → dist/analytics/index.d.ts} +28 -52
  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/dist/business/models/index.d.ts +8 -0
  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/{src/donation/models/index.ts → dist/donation/models/index.d.ts} +8 -11
  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/{src/user/models/index.ts → dist/user/models/index.d.ts} +12 -10
  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/{src/user-status/models/index.ts → dist/user-status/models/index.d.ts} +8 -11
  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/{src/web3-chain/models/index.ts → dist/web3-chain/models/index.d.ts} +38 -45
  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 +70 -67
  222. package/config/domains.js +0 -22
  223. package/explorins-pers-sdk-1.0.0-alpha.1.tgz +0 -0
  224. package/rollup.config.js +0 -74
  225. package/scripts/copy-declarations.js +0 -147
  226. package/src/analytics/api/analytics-api.ts +0 -24
  227. package/src/analytics/models/index.ts +0 -74
  228. package/src/analytics/services/analytics-service.ts +0 -28
  229. package/src/auth-admin/api/auth-admin-api.ts +0 -42
  230. package/src/auth-admin/index.ts +0 -47
  231. package/src/auth-admin/services/auth-admin-service.ts +0 -36
  232. package/src/business/api/business-api.ts +0 -234
  233. package/src/business/index.ts +0 -53
  234. package/src/business/models/index.ts +0 -13
  235. package/src/business/services/business-service.ts +0 -88
  236. package/src/campaign/api/campaign-api.ts +0 -376
  237. package/src/campaign/index.ts +0 -67
  238. package/src/campaign/services/campaign-service.ts +0 -164
  239. package/src/core/abstractions/http-client.ts +0 -24
  240. package/src/core/auth/auth-provider.interface.ts +0 -16
  241. package/src/core/auth/create-auth-provider.ts +0 -136
  242. package/src/core/auth/simple-auth-config.interface.ts +0 -15
  243. package/src/core/index.ts +0 -33
  244. package/src/core/pers-api-client.ts +0 -343
  245. package/src/core/pers-config.ts +0 -65
  246. package/src/core/utils/jwt.function.ts +0 -24
  247. package/src/donation/api/donation-api.ts +0 -24
  248. package/src/donation/index.ts +0 -47
  249. package/src/donation/services/donation-service.ts +0 -25
  250. package/src/index.ts +0 -55
  251. package/src/payment/api/payment-api.ts +0 -185
  252. package/src/payment/index.ts +0 -64
  253. package/src/payment/models/index.ts +0 -29
  254. package/src/payment/services/payment-service.ts +0 -70
  255. package/src/pers-sdk.ts +0 -45
  256. package/src/redemption/api/redemption-api.ts +0 -241
  257. package/src/redemption/index.ts +0 -60
  258. package/src/redemption/models/index.ts +0 -17
  259. package/src/redemption/services/redemption-service.ts +0 -103
  260. package/src/shared/interfaces/pers-shared-lib.interfaces.ts +0 -99
  261. package/src/tenant/api/tenant-api.ts +0 -92
  262. package/src/tenant/index.ts +0 -61
  263. package/src/tenant/models/index.ts +0 -20
  264. package/src/tenant/services/tenant-service.ts +0 -78
  265. package/src/token/api/token-api.ts +0 -129
  266. package/src/token/base/base-token-service.ts +0 -167
  267. package/src/token/index.ts +0 -38
  268. package/src/token/models/index.ts +0 -30
  269. package/src/token/services/token-service.ts +0 -125
  270. package/src/token/token-sdk.ts +0 -231
  271. package/src/transaction/api/transaction-api.ts +0 -296
  272. package/src/transaction/index.ts +0 -65
  273. package/src/transaction/models/index.ts +0 -60
  274. package/src/transaction/services/transaction-service.ts +0 -104
  275. package/src/user/api/user-api.ts +0 -98
  276. package/src/user/index.ts +0 -62
  277. package/src/user/services/user-service.ts +0 -75
  278. package/src/user-status/api/user-status-api.ts +0 -78
  279. package/src/user-status/index.ts +0 -55
  280. package/src/user-status/services/user-status-service.ts +0 -51
  281. package/src/web3/api/web3-api.ts +0 -68
  282. package/src/web3/index.ts +0 -38
  283. package/src/web3/models/index.ts +0 -150
  284. package/src/web3/services/web3-service.ts +0 -338
  285. package/src/web3-chain/api/web3-chain-api.ts +0 -42
  286. package/src/web3-chain/index.ts +0 -27
  287. package/src/web3-chain/services/getWeb3FCD.service.ts +0 -47
  288. package/src/web3-chain/services/provider.service.ts +0 -123
  289. package/src/web3-chain/services/public-http-provider.service.ts +0 -26
  290. package/src/web3-chain/services/web3-chain-service.ts +0 -131
  291. package/tsconfig.json +0 -28
@@ -1,25 +0,0 @@
1
- import { DonationApi } from '../api/donation-api';
2
- import { DonationTypeDTO } from '../../shared/interfaces/pers-shared-lib.interfaces';
3
-
4
- /**
5
- * Platform-Agnostic Donation Service
6
- *
7
- * Contains donation business logic and operations that work across platforms.
8
- * No framework dependencies - pure TypeScript business logic.
9
- * Matches framework DonationApiService capabilities exactly.
10
- */
11
- export class DonationService {
12
- constructor(private donationApi: DonationApi) {}
13
-
14
- // ==========================================
15
- // PUBLIC OPERATIONS
16
- // ==========================================
17
-
18
- /**
19
- * PUBLIC: Get all donation types
20
- * ✅ ONLY method actually used by framework
21
- */
22
- async getAllDonationTypes(): Promise<DonationTypeDTO[]> {
23
- return this.donationApi.getAllDonationTypes();
24
- }
25
- }
package/src/index.ts DELETED
@@ -1,55 +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'
9
-
10
- // Re-export everything from business domain
11
- export * from './business';
12
-
13
- // Re-export everything from transaction domain
14
- export * from './transaction';
15
-
16
- // Re-export everything from analytics domain
17
- export * from './analytics';
18
-
19
- // Re-export everything from auth-admin domain
20
- export * from './auth-admin';
21
-
22
- // Re-export everything from campaign domain
23
- export * from './campaign';
24
-
25
- // Re-export everything from donation domain
26
- export * from './donation';
27
-
28
- // Re-export everything from analytics domain
29
- export * from './payment';
30
-
31
- // Re-export everything from analytics domain
32
- export * from './redemption';
33
-
34
- // Re-export everything from analytics domain
35
- export * from './tenant';
36
-
37
- // Re-export everything from analytics domain
38
- export * from './token';
39
-
40
- // Re-export everything from user domain
41
- export * from './user';
42
-
43
- // Re-export everything from user-status domain
44
- export * from './user-status';
45
-
46
- // Re-export everything from web3-chain domain
47
- export * from './web3-chain';
48
-
49
- // Re-export everything from web3 domain
50
- export * from './web3';
51
-
52
- // NOTE: Angular integration available in separate package '@explorins/pers-sdk-angular'
53
- // Future domains will be added here
54
- // export * from './campaign';
55
- // export * from './challenge';
@@ -1,185 +0,0 @@
1
- import { PersApiClient } from '../../core/pers-api-client';
2
- import {
3
- PurchaseTokenDTO,
4
- PurchaseDTO,
5
- PurchaseCurrency,
6
- PurchaseCreateRequestDTO,
7
- PaymentIntentDTO,
8
- PaymentIntentCreateDTO,
9
- PurchaseCreateResponseDTO,
10
- DonationTypeDTO
11
- } from '../models';
12
-
13
- /**
14
- * Platform-Agnostic Purchase API Client (RESTful Architecture)
15
- *
16
- * Handles purchase and payment operations using the PERS backend's new RESTful endpoints.
17
- * Uses @explorins/pers-shared DTOs for consistency with backend.
18
- *
19
- * Migration Status: Updated to match /purchases controller (replaces /purchase endpoints)
20
- *
21
- * Available Access Levels:
22
- * - PUBLIC: Project key authentication for catalog browsing and payment operations
23
- * - USER: Requires user authentication JWT (purchase creation, history access)
24
- * - ADMIN: Requires tenant admin privileges (not implemented in this client)
25
- *
26
- * Note: This SDK focuses on backend purchase operations only.
27
- * Payment provider integrations (Stripe, etc.) should remain in infrastructure layer.
28
- */
29
- export class PurchaseApi {
30
- constructor(private apiClient: PersApiClient) {}
31
-
32
- private readonly basePath = '/purchases';
33
-
34
- // ==========================================
35
- // PUBLIC OPERATIONS (Project Key)
36
- // ==========================================
37
-
38
- /**
39
- * PUBLIC: Get purchase tokens (Intelligent Access)
40
- *
41
- * RESTful endpoint: GET /purchases/tokens
42
- * Replaces: GET /purchase/token
43
- *
44
- * INTELLIGENT ACCESS:
45
- * - PUBLIC (Project Key): Returns active tokens only (active parameter ignored)
46
- * - ADMIN (Tenant Admin JWT): Returns filtered results based on active parameter
47
- */
48
- async getPurchaseTokens(active?: boolean): Promise<PurchaseTokenDTO[]> {
49
- let url = `${this.basePath}/tokens`;
50
- if (active !== undefined) {
51
- url += `?active=${active}`;
52
- }
53
- return this.apiClient.get<PurchaseTokenDTO[]>(url);
54
- }
55
-
56
- /**
57
- * PUBLIC: Get donation types
58
- *
59
- * RESTful endpoint: GET /purchases/donation-types
60
- * Replaces: GET /purchase/donation/type
61
- */
62
- async getDonationTypes(): Promise<DonationTypeDTO[]> {
63
- return this.apiClient.get<DonationTypeDTO[]>(`${this.basePath}/donation-types`);
64
- }
65
-
66
- // ==========================================
67
- // PAYMENT OPERATIONS (FINANCIAL - CRITICAL)
68
- // ==========================================
69
-
70
- /**
71
- * PUBLIC: Create payment intent (FINANCIAL OPERATION)
72
- *
73
- * RESTful endpoint: POST /purchases/payment-intents
74
- * Replaces: POST /purchase/payment-intent
75
- *
76
- * CRITICAL: Handles real money operations - tenant context required
77
- */
78
- async createPaymentIntent(amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string): Promise<PaymentIntentDTO> {
79
- const body: PaymentIntentCreateDTO = {
80
- amount,
81
- currency,
82
- receiptEmail,
83
- description
84
- };
85
- return this.apiClient.post<PaymentIntentDTO>(`${this.basePath}/payment-intents`, body);
86
- }
87
-
88
- /**
89
- * PUBLIC: Update payment intent (FINANCIAL OPERATION)
90
- *
91
- * RESTful endpoint: PUT /purchases/payment-intents/{paymentIntentId}
92
- * Replaces: PUT /purchase/payment-intent/{paymentIntentId}
93
- *
94
- * CRITICAL: Handles real money operations - tenant context required
95
- */
96
- async updatePaymentIntent(paymentIntentId: string, amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string): Promise<PaymentIntentDTO> {
97
- const body: PaymentIntentCreateDTO = {
98
- amount,
99
- currency,
100
- receiptEmail,
101
- description
102
- };
103
- return this.apiClient.put<PaymentIntentDTO>(`${this.basePath}/payment-intents/${paymentIntentId}`, body);
104
- }
105
-
106
- /**
107
- * PUBLIC: Cancel payment intent (FINANCIAL OPERATION)
108
- *
109
- * RESTful endpoint: DELETE /purchases/payment-intents/{paymentIntentId}
110
- * Replaces: DELETE /purchase/payment-intent/{paymentIntentId}
111
- *
112
- * CRITICAL: Handles real money operations - tenant context required
113
- */
114
- async cancelPaymentIntent(paymentIntentId: string): Promise<PaymentIntentDTO> {
115
- return this.apiClient.delete<PaymentIntentDTO>(`${this.basePath}/payment-intents/${paymentIntentId}`);
116
- }
117
-
118
- // ==========================================
119
- // USER OPERATIONS (JWT + Project Key)
120
- // ==========================================
121
-
122
- /**
123
- * USER: Create purchase (BUSINESS CRITICAL - FINANCIAL TRANSACTION)
124
- *
125
- * RESTful endpoint: POST /purchases
126
- * Replaces: POST /purchase/auth
127
- *
128
- * USER-ONLY: Requires user authentication JWT for purchase creation
129
- * CRITICAL: Real financial transaction with Stripe integration
130
- */
131
- async createUserPurchase(paymentIntentId: string, amount: number, purchaseTokenId?: string, donationTypeId?: number, donationAccountAddress?: string): Promise<PurchaseCreateResponseDTO> {
132
- const body: PurchaseCreateRequestDTO = {
133
- quantity: amount,
134
- purchaseTokenId: purchaseTokenId || '',
135
- donationTypeId,
136
- donationAccountAddress,
137
- paymentIntentId
138
- };
139
- return this.apiClient.post<PurchaseCreateResponseDTO>(`${this.basePath}`, body);
140
- }
141
-
142
- /**
143
- * USER: Get user purchase history
144
- *
145
- * RESTful endpoint: GET /purchases/me/history
146
- * Replaces: GET /purchase/auth
147
- *
148
- * USER-ONLY: Get authenticated user's purchase history
149
- * FINANCIAL RECORDS: User attribution critical for compliance
150
- */
151
- async getUserPurchaseHistory(): Promise<PurchaseDTO[]> {
152
- return this.apiClient.get<PurchaseDTO[]>(`${this.basePath}/me/history`);
153
- }
154
-
155
- // ==========================================
156
- // CONVENIENCE METHODS (Backward Compatibility)
157
- // ==========================================
158
-
159
- /**
160
- * @deprecated Use getPurchaseTokens() instead
161
- * Backward compatibility alias for getActivePurchaseTokens
162
- */
163
- async getActivePurchaseTokens(active: boolean = true): Promise<PurchaseTokenDTO[]> {
164
- return this.getPurchaseTokens(active);
165
- }
166
-
167
- /**
168
- * @deprecated Use createUserPurchase() instead
169
- * Backward compatibility alias for createPurchase
170
- */
171
- async createPurchase(paymentIntentId: string, amount: number, purchaseTokenId?: string, donationTypeId?: number, donationAccountAddress?: string): Promise<PurchaseCreateResponseDTO> {
172
- return this.createUserPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress);
173
- }
174
-
175
- /**
176
- * @deprecated Use getUserPurchaseHistory() instead
177
- * Backward compatibility alias for getAllUserPurchases
178
- */
179
- async getAllUserPurchases(): Promise<PurchaseDTO[]> {
180
- return this.getUserPurchaseHistory();
181
- }
182
- }
183
-
184
- // Backward compatibility - export as PaymentApi as well
185
- export { PurchaseApi as PaymentApi };
@@ -1,64 +0,0 @@
1
- /**
2
- * @explorins/pers-sdk-payment
3
- *
4
- * Platform-agnostic Payment Domain SDK for PERS ecosystem
5
- * Handles payment intents, purchases, and purchase tokens
6
- *
7
- * Note: Payment provider integrations (Stripe, etc.) are kept separate
8
- * in the infrastructure layer to maintain platform-agnostic principles.
9
- */
10
-
11
- // API Layer
12
- export { PaymentApi } from './api/payment-api';
13
-
14
- // Service Layer
15
- export { PaymentService } from './services/payment-service';
16
-
17
- // Models & Types
18
- export * from './models';
19
- export * from '../shared/interfaces/pers-shared-lib.interfaces';
20
-
21
- // Models & Types
22
- export * from './models';
23
-
24
- // Factory function for creating payment SDK instance
25
- import { PersApiClient } from '../core/pers-api-client';
26
- import { PaymentApi } from './api/payment-api';
27
- import { PurchaseCurrency } from './models';
28
- import { PaymentService } from './services/payment-service';
29
-
30
- /**
31
- * Create a complete Payment SDK instance
32
- *
33
- * @param apiClient - Configured PERS API client
34
- * @returns Payment SDK with flattened structure for better DX
35
- */
36
- export function createPaymentSDK(apiClient: PersApiClient) {
37
- const paymentApi = new PaymentApi(apiClient);
38
- const paymentService = new PaymentService(paymentApi);
39
-
40
- return {
41
- // Direct access to service methods (primary interface)
42
-
43
- // Public methods
44
- getActivePurchaseTokens: (active?: boolean) => paymentService.getActivePurchaseTokens(active),
45
- // ✅ FIXED: Proper type instead of any
46
- createPaymentIntent: (amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string) =>
47
- paymentService.createPaymentIntent(amount, currency, receiptEmail, description),
48
- // ✅ FIXED: Proper type instead of any
49
- updatePaymentIntent: (paymentIntentId: string, amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string) =>
50
- paymentService.updatePaymentIntent(paymentIntentId, amount, currency, receiptEmail, description),
51
- cancelPaymentIntent: (paymentIntentId: string) => paymentService.cancelPaymentIntent(paymentIntentId),
52
-
53
- // Auth methods
54
- createPurchase: (paymentIntentId: string, amount: number, purchaseTokenId?: string, donationTypeId?: number, donationAccountAddress?: string) =>
55
- paymentService.createPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress),
56
- getAllUserPurchases: () => paymentService.getAllUserPurchases(),
57
-
58
- // Advanced access for edge cases
59
- api: paymentApi,
60
- service: paymentService
61
- };
62
- }
63
-
64
- export type PaymentSDK = ReturnType<typeof createPaymentSDK>;
@@ -1,29 +0,0 @@
1
- /**
2
- * Payment Domain Models
3
- *
4
- * Re-exports from centralized pers-shared interfaces for consistency with backend
5
- * and to provide a single import source for payment-related types.
6
- */
7
-
8
- // Core payment entities from centralized pers-shared interfaces
9
- export type {
10
- UserDTO,
11
- PurchaseDTO,
12
- PurchaseTokenDTO,
13
- PurchaseTypeDTO,
14
- PaymentIntentDTO,
15
- PurchaseCreateRequestDTO,
16
- PurchaseCreateResponseDTO,
17
- PaymentIntentCreateDTO,
18
- PurchaseCurrency,
19
- DonationTypeDTO
20
- } from '../../shared/interfaces/pers-shared-lib.interfaces';
21
-
22
- // Import for local interface usage
23
- import { PaymentIntentCreateDTO } from '../../shared/interfaces/pers-shared-lib.interfaces';
24
-
25
- // Local payment interfaces
26
- export interface PaymentIntentUpdateDTO extends PaymentIntentCreateDTO {
27
- paymentIntentId: string;
28
- }
29
-
@@ -1,70 +0,0 @@
1
- import { PaymentApi } from '../api/payment-api';
2
- import {
3
- PurchaseTokenDTO,
4
- PurchaseDTO,
5
- PurchaseCurrency,
6
- PaymentIntentDTO,
7
- } from '../models';
8
-
9
- /**
10
- * Platform-Agnostic Payment Service
11
- *
12
- * Contains payment business logic and operations that work across platforms.
13
- * No framework dependencies - pure TypeScript business logic.
14
- *
15
- * Focuses only on actual backend capabilities.
16
- * Payment provider logic (Stripe, etc.) should remain in infrastructure layer.
17
- */
18
- export class PaymentService {
19
- constructor(private paymentApi: PaymentApi) {}
20
-
21
- // ==========================================
22
- // PUBLIC OPERATIONS
23
- // ==========================================
24
-
25
- /**
26
- * PUBLIC: Get active purchase tokens
27
- */
28
- async getActivePurchaseTokens(active: boolean = true): Promise<PurchaseTokenDTO[]> {
29
- return this.paymentApi.getActivePurchaseTokens(active);
30
- }
31
-
32
- /**
33
- * PUBLIC: Create payment intent
34
- */
35
- async createPaymentIntent(amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string): Promise<PaymentIntentDTO> {
36
- return this.paymentApi.createPaymentIntent(amount, currency, receiptEmail, description);
37
- }
38
-
39
- /**
40
- * PUBLIC: Update payment intent
41
- */
42
- async updatePaymentIntent(paymentIntentId: string, amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string): Promise<PaymentIntentDTO> {
43
- return this.paymentApi.updatePaymentIntent(paymentIntentId, amount, currency, receiptEmail, description);
44
- }
45
-
46
- /**
47
- * PUBLIC: Cancel payment intent
48
- */
49
- async cancelPaymentIntent(paymentIntentId: string): Promise<PaymentIntentDTO> {
50
- return this.paymentApi.cancelPaymentIntent(paymentIntentId);
51
- }
52
-
53
- // ==========================================
54
- // AUTHENTICATED OPERATIONS
55
- // ==========================================
56
-
57
- /**
58
- * AUTH: Create purchase
59
- */
60
- async createPurchase(paymentIntentId: string, amount: number, purchaseTokenId?: string, donationTypeId?: number, donationAccountAddress?: string): Promise<PurchaseDTO> {
61
- return this.paymentApi.createPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress);
62
- }
63
-
64
- /**
65
- * AUTH: Get all user purchases
66
- */
67
- async getAllUserPurchases(): Promise<PurchaseDTO[]> {
68
- return this.paymentApi.getAllUserPurchases();
69
- }
70
- }
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
- }