@explorins/pers-sdk 1.3.16 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +351 -81
  2. package/dist/chunks/base-token-service-D0KANDgM.js +139 -0
  3. package/dist/chunks/base-token-service-D0KANDgM.js.map +1 -0
  4. package/dist/chunks/base-token-service-zNfPjHRx.cjs +141 -0
  5. package/dist/chunks/base-token-service-zNfPjHRx.cjs.map +1 -0
  6. package/dist/chunks/{pers-sdk-DiwCwBiC.cjs → pers-sdk-CI2YXKb_.cjs} +1335 -50
  7. package/dist/chunks/pers-sdk-CI2YXKb_.cjs.map +1 -0
  8. package/dist/chunks/{pers-sdk-Rc8YKyNc.js → pers-sdk-CVSAFBLh.js} +1325 -51
  9. package/dist/chunks/pers-sdk-CVSAFBLh.js.map +1 -0
  10. package/dist/chunks/{base-token-service-BA81_Ouq.js → token-sdk-BW4kkJb3.js} +2 -137
  11. package/dist/chunks/token-sdk-BW4kkJb3.js.map +1 -0
  12. package/dist/chunks/{base-token-service-BQ6uFoki.cjs → token-sdk-CiAbOb6c.cjs} +1 -137
  13. package/dist/chunks/token-sdk-CiAbOb6c.cjs.map +1 -0
  14. package/dist/core/index.d.ts +1 -0
  15. package/dist/core/index.d.ts.map +1 -1
  16. package/dist/core.cjs +22 -1
  17. package/dist/core.cjs.map +1 -1
  18. package/dist/core.js +11 -1
  19. package/dist/core.js.map +1 -1
  20. package/dist/index.cjs +21 -5
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +4 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/legacy-pers-sdk.d.ts +79 -0
  27. package/dist/legacy-pers-sdk.d.ts.map +1 -0
  28. package/dist/managers/analytics-manager.d.ts +28 -0
  29. package/dist/managers/analytics-manager.d.ts.map +1 -0
  30. package/dist/managers/auth-manager.d.ts +80 -0
  31. package/dist/managers/auth-manager.d.ts.map +1 -0
  32. package/dist/managers/business-manager.d.ts +83 -0
  33. package/dist/managers/business-manager.d.ts.map +1 -0
  34. package/dist/managers/campaign-manager.d.ts +158 -0
  35. package/dist/managers/campaign-manager.d.ts.map +1 -0
  36. package/dist/managers/donation-manager.d.ts +27 -0
  37. package/dist/managers/donation-manager.d.ts.map +1 -0
  38. package/dist/managers/index.d.ts +18 -0
  39. package/dist/managers/index.d.ts.map +1 -0
  40. package/dist/managers/payment-manager.d.ts +44 -0
  41. package/dist/managers/payment-manager.d.ts.map +1 -0
  42. package/dist/managers/redemption-manager.d.ts +91 -0
  43. package/dist/managers/redemption-manager.d.ts.map +1 -0
  44. package/dist/managers/tenant-manager.d.ts +60 -0
  45. package/dist/managers/tenant-manager.d.ts.map +1 -0
  46. package/dist/managers/token-manager.d.ts +81 -0
  47. package/dist/managers/token-manager.d.ts.map +1 -0
  48. package/dist/managers/transaction-manager.d.ts +62 -0
  49. package/dist/managers/transaction-manager.d.ts.map +1 -0
  50. package/dist/managers/user-manager.d.ts +72 -0
  51. package/dist/managers/user-manager.d.ts.map +1 -0
  52. package/dist/package.json +6 -1
  53. package/dist/pers-sdk.d.ts +302 -13
  54. package/dist/pers-sdk.d.ts.map +1 -1
  55. package/dist/platform-adapters/angular-http-client.d.ts +35 -0
  56. package/dist/platform-adapters/angular-http-client.d.ts.map +1 -0
  57. package/dist/platform-adapters/browser-fetch-client.d.ts +30 -0
  58. package/dist/platform-adapters/browser-fetch-client.d.ts.map +1 -0
  59. package/dist/platform-adapters/index.d.ts +11 -0
  60. package/dist/platform-adapters/index.d.ts.map +1 -0
  61. package/dist/platform-adapters/node-http-client.d.ts +30 -0
  62. package/dist/platform-adapters/node-http-client.d.ts.map +1 -0
  63. package/dist/platform-adapters.cjs +201 -0
  64. package/dist/platform-adapters.cjs.map +1 -0
  65. package/dist/platform-adapters.js +197 -0
  66. package/dist/platform-adapters.js.map +1 -0
  67. package/dist/token.cjs +6 -5
  68. package/dist/token.cjs.map +1 -1
  69. package/dist/token.js +2 -1
  70. package/dist/token.js.map +1 -1
  71. package/package.json +6 -1
  72. package/dist/chunks/base-token-service-BA81_Ouq.js.map +0 -1
  73. package/dist/chunks/base-token-service-BQ6uFoki.cjs.map +0 -1
  74. package/dist/chunks/pers-sdk-DiwCwBiC.cjs.map +0 -1
  75. package/dist/chunks/pers-sdk-Rc8YKyNc.js.map +0 -1
@@ -1,4 +1,14 @@
1
1
  import { AccountOwnerType } from '@explorins/pers-shared';
2
+ import { createUserSDK } from '../user.js';
3
+ import { T as TokenSDK } from './token-sdk-BW4kkJb3.js';
4
+ import { createBusinessSDK } from '../business.js';
5
+ import { createCampaignSDK } from '../campaign.js';
6
+ import { createRedemptionSDK } from '../redemption.js';
7
+ import { createTransactionSDK } from '../transaction.js';
8
+ import { createPaymentSDK } from '../payment.js';
9
+ import { createTenantSDK } from '../tenant.js';
10
+ import { createAnalyticsSDK } from '../analytics.js';
11
+ import { createDonationSDK } from '../donation.js';
2
12
 
3
13
  /**
4
14
  * PERS SDK Configuration interfaces and utilities
@@ -298,7 +308,7 @@ let LocalStorageTokenStorage$1 = class LocalStorageTokenStorage {
298
308
  /**
299
309
  * Token Manager - High-level token management
300
310
  */
301
- class TokenManager {
311
+ let TokenManager$1 = class TokenManager {
302
312
  constructor(storage = new LocalStorageTokenStorage$1()) {
303
313
  this.storage = storage;
304
314
  }
@@ -379,7 +389,7 @@ class TokenManager {
379
389
  async clearProviderToken() {
380
390
  await this.storage.removeToken(AUTH_STORAGE_KEYS.PROVIDER_TOKEN);
381
391
  }
382
- }
392
+ };
383
393
 
384
394
  /**
385
395
  * PERS SDK Error Handling - Optimized for Performance
@@ -742,7 +752,7 @@ class DefaultAuthProvider {
742
752
  this.authType = 'admin';
743
753
  this.projectKey = projectKey || null;
744
754
  this.authApi = authApi || null;
745
- this.tokenManager = new TokenManager();
755
+ this.tokenManager = new TokenManager$1();
746
756
  const refreshStrategy = new DefaultAuthRefreshStrategy(this.tokenManager, () => Promise.resolve(this.getProviderToken()), this.authApi);
747
757
  this.tokenRefreshManager = new TokenRefreshManager(this.tokenManager, refreshStrategy);
748
758
  }
@@ -1613,79 +1623,1343 @@ function createAuthProvider(config) {
1613
1623
  } */
1614
1624
 
1615
1625
  /**
1616
- * PERS SDK - Platform-agnostic TypeScript SDK for PERS API
1626
+ * Authentication Manager - Clean, high-level interface for authentication operations
1617
1627
  *
1618
- * Provides a simple wrapper around the core API client with
1619
- * intelligent authentication and token management.
1628
+ * Provides a simplified API for common authentication tasks while maintaining
1629
+ * access to the underlying API client for advanced use cases.
1620
1630
  */
1631
+ class AuthManager {
1632
+ constructor(apiClient) {
1633
+ this.apiClient = apiClient;
1634
+ }
1635
+ /**
1636
+ * Login with JWT token
1637
+ *
1638
+ * @param jwtToken - JWT token to authenticate with
1639
+ * @param userType - Type of user ('user' | 'admin')
1640
+ * @returns Promise resolving to authentication response
1641
+ */
1642
+ async loginWithToken(jwtToken, userType = 'user') {
1643
+ return userType === 'admin'
1644
+ ? this.apiClient.loginAdmin(jwtToken)
1645
+ : this.apiClient.loginUser(jwtToken);
1646
+ }
1647
+ /**
1648
+ * Login with raw user data
1649
+ *
1650
+ * @param rawUserData - Raw user data for authentication
1651
+ * @returns Promise resolving to authentication response
1652
+ */
1653
+ async loginWithRawData(rawUserData) {
1654
+ return this.apiClient.loginUserWithRawData(rawUserData);
1655
+ }
1656
+ /**
1657
+ * Get current authenticated user
1658
+ *
1659
+ * @returns Promise resolving to current user data
1660
+ */
1661
+ async getCurrentUser() {
1662
+ return this.apiClient.get('/users/me');
1663
+ }
1664
+ /**
1665
+ * Refresh current user data
1666
+ *
1667
+ * @returns Promise resolving to updated user data
1668
+ */
1669
+ async refreshUserData() {
1670
+ return this.getCurrentUser();
1671
+ }
1672
+ /**
1673
+ * Check if user is authenticated
1674
+ *
1675
+ * @returns Promise resolving to boolean indicating authentication status
1676
+ */
1677
+ async isAuthenticated() {
1678
+ try {
1679
+ await this.getCurrentUser();
1680
+ return true;
1681
+ }
1682
+ catch {
1683
+ return false;
1684
+ }
1685
+ }
1686
+ /**
1687
+ * Refresh access token using stored refresh token
1688
+ *
1689
+ * @param refreshToken - Optional refresh token, uses stored token if not provided
1690
+ * @returns Promise resolving to new auth tokens
1691
+ */
1692
+ async refreshTokens(refreshToken) {
1693
+ return this.apiClient.refreshTokens(refreshToken);
1694
+ }
1695
+ /**
1696
+ * Clear stored authentication tokens
1697
+ *
1698
+ * @returns Promise that resolves when tokens are cleared
1699
+ */
1700
+ async clearAuth() {
1701
+ // Use auth provider to clear tokens if available
1702
+ const authProvider = this.apiClient.getConfig().authProvider;
1703
+ if (authProvider?.clearTokens) {
1704
+ await authProvider.clearTokens();
1705
+ }
1706
+ }
1707
+ /**
1708
+ * Check if SDK has valid authentication
1709
+ *
1710
+ * @returns Boolean indicating if valid authentication exists
1711
+ */
1712
+ hasValidAuth() {
1713
+ return this.apiClient.hasValidAuth();
1714
+ }
1715
+ /**
1716
+ * Admin login with JWT token
1717
+ *
1718
+ * @param jwt - JWT token for admin authentication
1719
+ * @returns Promise resolving to authentication context
1720
+ */
1721
+ async loginAdmin(jwt) {
1722
+ return this.apiClient.loginAdmin(jwt);
1723
+ }
1724
+ /**
1725
+ * User login with JWT token
1726
+ *
1727
+ * @param jwt - JWT token for user authentication
1728
+ * @returns Promise resolving to authentication context
1729
+ */
1730
+ async loginUser(jwt) {
1731
+ return this.apiClient.loginUser(jwt);
1732
+ }
1733
+ }
1734
+
1621
1735
  /**
1622
- * Main PERS SDK class
1623
- *
1624
- * Minimal wrapper around PersApiClient providing a clean interface
1625
- * for platform-specific implementations.
1626
- *
1627
- * @example
1628
- * ```typescript
1629
- * import { createPersSDK, createAuthProvider } from '@explorins/pers-sdk/core';
1630
- * import { BrowserHttpClient } from '@explorins/pers-sdk/browser';
1736
+ * User Manager - Clean, high-level interface for user operations
1631
1737
  *
1632
- * const authProvider = createAuthProvider({
1633
- * tokenProvider: () => getFirebaseToken()
1634
- * });
1738
+ * Provides a simplified API for common user management tasks while maintaining
1739
+ * access to the full user SDK for advanced use cases.
1740
+ */
1741
+ class UserManager {
1742
+ constructor(apiClient) {
1743
+ this.apiClient = apiClient;
1744
+ this.userSDK = createUserSDK(apiClient);
1745
+ }
1746
+ /**
1747
+ * Get current user profile
1748
+ *
1749
+ * @returns Promise resolving to current user data
1750
+ */
1751
+ async getCurrentUser() {
1752
+ return this.userSDK.getRemoteUser();
1753
+ }
1754
+ /**
1755
+ * Update current user profile
1756
+ *
1757
+ * @param userData - User data to update
1758
+ * @returns Promise resolving to updated user data
1759
+ */
1760
+ async updateCurrentUser(userData) {
1761
+ return this.userSDK.updateRemoteUser(userData);
1762
+ }
1763
+ /**
1764
+ * Get user by unique identifier
1765
+ *
1766
+ * @param identifier - Unique identifier for the user
1767
+ * @returns Promise resolving to user data
1768
+ */
1769
+ async getUserById(identifier) {
1770
+ return this.userSDK.getUserByUniqueIdentifier(identifier);
1771
+ }
1772
+ /**
1773
+ * Get all users public profiles with optional filtering
1774
+ *
1775
+ * @param filter - Optional filter criteria
1776
+ * @returns Promise resolving to array of user public profiles
1777
+ */
1778
+ async getAllUsersPublic(filter) {
1779
+ return this.userSDK.getAllUsersPublicProfiles(filter || null);
1780
+ }
1781
+ /**
1782
+ * Admin: Get all users
1783
+ *
1784
+ * @returns Promise resolving to array of all users
1785
+ */
1786
+ async getAllUsers() {
1787
+ return this.userSDK.getAllRemoteUsers();
1788
+ }
1789
+ /**
1790
+ * Admin: Update user data
1791
+ *
1792
+ * @param userId - ID of user to update
1793
+ * @param userData - User data to update
1794
+ * @returns Promise resolving to updated user data
1795
+ */
1796
+ async updateUser(userId, userData) {
1797
+ return this.userSDK.updateUserAsAdmin(userId, userData);
1798
+ }
1799
+ /**
1800
+ * Admin: Toggle user active status
1801
+ *
1802
+ * @param user - User to toggle status for
1803
+ * @returns Promise resolving to updated user data
1804
+ */
1805
+ async toggleUserStatus(user) {
1806
+ return this.userSDK.toggleUserActiveStatusByUser(user);
1807
+ }
1808
+ /**
1809
+ * Get the full user SDK for advanced operations
1810
+ *
1811
+ * @returns UserSDK instance
1812
+ */
1813
+ getUserSDK() {
1814
+ return this.userSDK;
1815
+ }
1816
+ }
1817
+
1818
+ /**
1819
+ * Token Manager - Clean, high-level interface for token operations
1635
1820
  *
1636
- * const sdk = new PersSDK(new BrowserHttpClient(), {
1637
- * environment: 'production',
1638
- * apiProjectKey: 'your-project-key',
1639
- * authProvider
1640
- * });
1821
+ * Provides a simplified API for common token management tasks while maintaining
1822
+ * access to the full token SDK for advanced use cases.
1823
+ */
1824
+ class TokenManager {
1825
+ constructor(apiClient) {
1826
+ this.apiClient = apiClient;
1827
+ this.tokenSDK = new TokenSDK(apiClient);
1828
+ }
1829
+ /**
1830
+ * Get all available tokens
1831
+ *
1832
+ * @returns Promise resolving to array of tokens
1833
+ */
1834
+ async getTokens() {
1835
+ return this.tokenSDK.getTokens();
1836
+ }
1837
+ /**
1838
+ * Get all token types
1839
+ *
1840
+ * @returns Promise resolving to token types
1841
+ */
1842
+ async getTokenTypes() {
1843
+ return this.tokenSDK.getTokenTypes();
1844
+ }
1845
+ /**
1846
+ * Get active credit token
1847
+ *
1848
+ * @returns Promise resolving to active credit token
1849
+ */
1850
+ async getActiveCreditToken() {
1851
+ return this.tokenSDK.getActiveCreditToken();
1852
+ }
1853
+ /**
1854
+ * Get reward tokens
1855
+ *
1856
+ * @returns Promise resolving to reward tokens
1857
+ */
1858
+ async getRewardTokens() {
1859
+ return this.tokenSDK.getRewardTokens();
1860
+ }
1861
+ /**
1862
+ * Get status tokens
1863
+ *
1864
+ * @returns Promise resolving to status tokens
1865
+ */
1866
+ async getStatusTokens() {
1867
+ return this.tokenSDK.getStatusTokens();
1868
+ }
1869
+ /**
1870
+ * Get token by contract address
1871
+ *
1872
+ * @param contractAddress - Contract address to search for
1873
+ * @param contractTokenId - Optional contract token ID
1874
+ * @returns Promise resolving to token
1875
+ */
1876
+ async getTokenByContract(contractAddress, contractTokenId) {
1877
+ return this.tokenSDK.getTokenByContract(contractAddress, contractTokenId);
1878
+ }
1879
+ /**
1880
+ * Admin: Create new token
1881
+ *
1882
+ * @param tokenData - Token creation data
1883
+ * @returns Promise resolving to created token
1884
+ */
1885
+ async createToken(tokenData) {
1886
+ return this.tokenSDK.createToken(tokenData);
1887
+ }
1888
+ /**
1889
+ * Admin: Update token
1890
+ *
1891
+ * @param tokenId - Token ID to update
1892
+ * @param tokenData - Token update data
1893
+ * @returns Promise resolving to updated token
1894
+ */
1895
+ async updateToken(tokenId, tokenData) {
1896
+ return this.tokenSDK.updateToken(tokenId, tokenData);
1897
+ }
1898
+ /**
1899
+ * Admin: Toggle token active status
1900
+ *
1901
+ * @param tokenId - Token ID to toggle
1902
+ * @returns Promise resolving to updated token
1903
+ */
1904
+ async toggleTokenActive(tokenId) {
1905
+ return this.tokenSDK.toggleTokenActive(tokenId);
1906
+ }
1907
+ /**
1908
+ * Get the full token SDK for advanced operations
1909
+ *
1910
+ * @returns TokenSDK instance
1911
+ */
1912
+ getTokenSDK() {
1913
+ return this.tokenSDK;
1914
+ }
1915
+ }
1916
+
1917
+ /**
1918
+ * Business Manager - Clean, high-level interface for business operations
1641
1919
  *
1642
- * const apiClient = sdk.api();
1643
- * const user = await apiClient.get('/users/me');
1644
- * ```
1920
+ * Provides a simplified API for common business management tasks while maintaining
1921
+ * access to the full business SDK for advanced use cases.
1645
1922
  */
1646
- class PersSDK {
1923
+ class BusinessManager {
1924
+ constructor(apiClient) {
1925
+ this.apiClient = apiClient;
1926
+ this.businessSDK = createBusinessSDK(apiClient);
1927
+ }
1647
1928
  /**
1648
- * Creates a new PERS SDK instance
1929
+ * Get all active businesses
1649
1930
  *
1650
- * @param httpClient Platform-specific HTTP client implementation
1651
- * @param config SDK configuration options
1931
+ * @returns Promise resolving to array of active businesses
1652
1932
  */
1653
- constructor(httpClient, config) {
1654
- this.apiClient = new PersApiClient(httpClient, config);
1933
+ async getActiveBusinesses() {
1934
+ return this.businessSDK.getActiveBusinesses();
1655
1935
  }
1656
1936
  /**
1657
- * Gets the API client for making PERS API requests
1937
+ * Get business by ID
1658
1938
  *
1659
- * This is the main interface for interacting with the PERS backend.
1660
- * The returned client handles authentication, token refresh, and error handling automatically.
1939
+ * @param businessId - Business ID to fetch
1940
+ * @returns Promise resolving to business data
1941
+ */
1942
+ async getBusinessById(businessId) {
1943
+ return this.businessSDK.getBusinessById(businessId);
1944
+ }
1945
+ /**
1946
+ * Get business by account address
1661
1947
  *
1662
- * @returns Configured PersApiClient instance
1948
+ * @param accountAddress - Account address to search for
1949
+ * @returns Promise resolving to business data
1950
+ */
1951
+ async getBusinessByAccount(accountAddress) {
1952
+ return this.businessSDK.getBusinessByAccount(accountAddress);
1953
+ }
1954
+ /**
1955
+ * Get all business types
1663
1956
  *
1664
- * @example
1665
- * ```typescript
1666
- * const apiClient = sdk.api();
1667
- * const user = await apiClient.get<User>('/users/me');
1668
- * await apiClient.post('/users', userData);
1669
- * ```
1957
+ * @returns Promise resolving to array of business types
1670
1958
  */
1671
- api() {
1672
- return this.apiClient;
1959
+ async getBusinessTypes() {
1960
+ return this.businessSDK.getAllBusinessTypes();
1673
1961
  }
1674
1962
  /**
1675
- * Checks if SDK is configured for production environment
1963
+ * Get businesses by type
1676
1964
  *
1677
- * @returns True if environment is 'production', false otherwise
1965
+ * @param typeId - Business type ID to filter by
1966
+ * @returns Promise resolving to array of businesses
1678
1967
  */
1679
- isProduction() {
1680
- return this.apiClient.getConfig().environment === 'production';
1968
+ async getBusinessesByType(typeId) {
1969
+ return this.businessSDK.getBusinessesByType(typeId);
1970
+ }
1971
+ /**
1972
+ * Admin: Get all businesses (including inactive)
1973
+ *
1974
+ * @returns Promise resolving to array of all businesses
1975
+ */
1976
+ async getAllBusinesses() {
1977
+ return this.businessSDK.getAllBusinesses();
1978
+ }
1979
+ /**
1980
+ * Admin: Create new business
1981
+ *
1982
+ * @param displayName - Display name for the business
1983
+ * @returns Promise resolving to created business data
1984
+ */
1985
+ async createBusiness(displayName) {
1986
+ return this.businessSDK.createBusinessByDisplayName(displayName);
1987
+ }
1988
+ /**
1989
+ * Admin: Update business
1990
+ *
1991
+ * @param businessId - ID of business to update
1992
+ * @param businessData - Business data to update
1993
+ * @returns Promise resolving to updated business data
1994
+ */
1995
+ async updateBusiness(businessId, businessData) {
1996
+ return this.businessSDK.updateBusiness(businessId, businessData);
1997
+ }
1998
+ /**
1999
+ * Admin: Toggle business active status
2000
+ *
2001
+ * @param businessId - ID of business to toggle
2002
+ * @param toggleData - Toggle request data
2003
+ * @returns Promise resolving to updated business data
2004
+ */
2005
+ async toggleBusinessStatus(businessId, toggleData) {
2006
+ return this.businessSDK.toggleBusinessActive(businessId, toggleData);
2007
+ }
2008
+ /**
2009
+ * Get the full business SDK for advanced operations
2010
+ *
2011
+ * @returns BusinessSDK instance
2012
+ */
2013
+ getBusinessSDK() {
2014
+ return this.businessSDK;
1681
2015
  }
1682
2016
  }
2017
+
1683
2018
  /**
1684
- * Simple factory function
2019
+ * Campaign Manager - Clean, high-level interface for campaign operations
2020
+ *
2021
+ * Provides a simplified API for common campaign management tasks while maintaining
2022
+ * access to the full campaign SDK for advanced use cases.
2023
+ */
2024
+ class CampaignManager {
2025
+ constructor(apiClient) {
2026
+ this.apiClient = apiClient;
2027
+ this.campaignSDK = createCampaignSDK(apiClient);
2028
+ }
2029
+ /**
2030
+ * Get all active campaigns
2031
+ *
2032
+ * @returns Promise resolving to array of active campaigns
2033
+ */
2034
+ async getActiveCampaigns() {
2035
+ return this.campaignSDK.getActiveCampaigns();
2036
+ }
2037
+ /**
2038
+ * Get campaign by ID
2039
+ *
2040
+ * @param campaignId - ID of the campaign
2041
+ * @returns Promise resolving to campaign data
2042
+ */
2043
+ async getCampaignById(campaignId) {
2044
+ return this.campaignSDK.getCampaignById(campaignId);
2045
+ }
2046
+ /**
2047
+ * Claim a campaign reward
2048
+ *
2049
+ * @param claimRequest - Campaign claim data
2050
+ * @returns Promise resolving to claim result
2051
+ */
2052
+ async claimCampaign(claimRequest) {
2053
+ return this.campaignSDK.claimCampaign(claimRequest);
2054
+ }
2055
+ /**
2056
+ * Get user's campaign claims
2057
+ *
2058
+ * @returns Promise resolving to array of user's claims
2059
+ */
2060
+ async getUserClaims() {
2061
+ return this.campaignSDK.getClaimsForLoggedUser();
2062
+ }
2063
+ /**
2064
+ * Admin: Get all campaigns
2065
+ *
2066
+ * @param active - Filter by active status
2067
+ * @returns Promise resolving to array of campaigns
2068
+ */
2069
+ async getAllCampaigns(active) {
2070
+ return this.campaignSDK.getCampaigns(active);
2071
+ }
2072
+ /**
2073
+ * Admin: Create new campaign
2074
+ *
2075
+ * @param campaignData - Campaign data
2076
+ * @returns Promise resolving to created campaign
2077
+ */
2078
+ async createCampaign(campaignData) {
2079
+ return this.campaignSDK.createCampaign(campaignData);
2080
+ }
2081
+ /**
2082
+ * Admin: Update campaign
2083
+ *
2084
+ * @param campaignId - ID of campaign to update
2085
+ * @param campaignData - Updated campaign data
2086
+ * @returns Promise resolving to updated campaign
2087
+ */
2088
+ async updateCampaign(campaignId, campaignData) {
2089
+ return this.campaignSDK.updateCampaign(campaignId, campaignData);
2090
+ }
2091
+ /**
2092
+ * Admin: Toggle campaign active status
2093
+ *
2094
+ * @param campaignId - ID of campaign to toggle
2095
+ * @returns Promise resolving to updated campaign
2096
+ */
2097
+ async toggleCampaignStatus(campaignId) {
2098
+ return this.campaignSDK.toggleCampaignActive(campaignId);
2099
+ }
2100
+ /**
2101
+ * Admin: Toggle campaign testnet environment
2102
+ *
2103
+ * @param campaignId - ID of campaign to toggle
2104
+ * @returns Promise resolving to updated campaign
2105
+ */
2106
+ async toggleCampaignTestnet(campaignId) {
2107
+ return this.campaignSDK.toggleCampaignTestnet(campaignId);
2108
+ }
2109
+ /**
2110
+ * Admin: Get campaign triggers
2111
+ *
2112
+ * @returns Promise resolving to array of campaign triggers
2113
+ */
2114
+ async getCampaignTriggers() {
2115
+ return this.campaignSDK.getCampaignTriggers();
2116
+ }
2117
+ /**
2118
+ * Admin: Set campaign trigger
2119
+ *
2120
+ * @param campaignId - ID of campaign
2121
+ * @param triggerId - ID of trigger to set
2122
+ * @returns Promise resolving to updated campaign
2123
+ */
2124
+ async setCampaignTrigger(campaignId, triggerId) {
2125
+ return this.campaignSDK.setCampaignTrigger(campaignId, triggerId);
2126
+ }
2127
+ /**
2128
+ * Admin: Create campaign token unit
2129
+ *
2130
+ * @param campaignId - ID of campaign
2131
+ * @param tokenUnit - Token unit data
2132
+ * @returns Promise resolving to updated campaign
2133
+ */
2134
+ async createCampaignTokenUnit(campaignId, tokenUnit) {
2135
+ return this.campaignSDK.createCampaignTokenUnit(campaignId, tokenUnit);
2136
+ }
2137
+ /**
2138
+ * Admin: Delete campaign token unit
2139
+ *
2140
+ * @param campaignId - ID of campaign
2141
+ * @param tokenUnitId - ID of token unit to delete
2142
+ * @returns Promise resolving to updated campaign
2143
+ */
2144
+ async deleteCampaignTokenUnit(campaignId, tokenUnitId) {
2145
+ return this.campaignSDK.deleteCampaignTokenUnit(campaignId, tokenUnitId);
2146
+ }
2147
+ /**
2148
+ * Admin: Add business engagement to campaign
2149
+ *
2150
+ * @param campaignId - ID of campaign
2151
+ * @param engagement - Business engagement data
2152
+ * @returns Promise resolving to updated campaign
2153
+ */
2154
+ async addBusinessEngagementToCampaign(campaignId, engagement) {
2155
+ return this.campaignSDK.addBusinessEngagementToCampaign(campaignId, engagement);
2156
+ }
2157
+ /**
2158
+ * Admin: Update campaign business engagement
2159
+ *
2160
+ * @param campaignId - ID of campaign
2161
+ * @param engagementId - ID of engagement to update
2162
+ * @param engagement - Updated engagement data
2163
+ * @returns Promise resolving to updated campaign
2164
+ */
2165
+ async updateCampaignBusinessEngagement(campaignId, engagementId, engagement) {
2166
+ return this.campaignSDK.updateCampaignBusinessEngagement(campaignId, engagementId, engagement);
2167
+ }
2168
+ /**
2169
+ * Admin: Delete campaign business engagement
2170
+ *
2171
+ * @param campaignId - ID of campaign
2172
+ * @param engagementId - ID of engagement to delete
2173
+ * @returns Promise resolving to updated campaign
2174
+ */
2175
+ async deleteCampaignBusinessEngagement(campaignId, engagementId) {
2176
+ return this.campaignSDK.deleteCampaignBusinessEngagement(campaignId, engagementId);
2177
+ }
2178
+ /**
2179
+ * Admin: Get all campaign claims
2180
+ *
2181
+ * @returns Promise resolving to array of campaign claims
2182
+ */
2183
+ async getCampaignClaims() {
2184
+ return this.campaignSDK.getCampaignClaims();
2185
+ }
2186
+ /**
2187
+ * Admin: Get campaign claims by user ID
2188
+ *
2189
+ * @param userId - ID of user
2190
+ * @returns Promise resolving to array of user's campaign claims
2191
+ */
2192
+ async getCampaignClaimsByUserId(userId) {
2193
+ return this.campaignSDK.getCampaignClaimsByUserId(userId);
2194
+ }
2195
+ /**
2196
+ * Admin: Get campaign claims by business ID
2197
+ *
2198
+ * @param businessId - ID of business
2199
+ * @returns Promise resolving to array of business's campaign claims
2200
+ */
2201
+ async getCampaignClaimsByBusinessId(businessId) {
2202
+ return this.campaignSDK.getCampaignClaimsByBusinessId(businessId);
2203
+ }
2204
+ /**
2205
+ * Get the full campaign SDK for advanced operations
2206
+ *
2207
+ * @returns CampaignSDK instance
2208
+ */
2209
+ getCampaignSDK() {
2210
+ return this.campaignSDK;
2211
+ }
2212
+ }
2213
+
2214
+ /**
2215
+ * Redemption Manager - Clean, high-level interface for redemption operations
2216
+ *
2217
+ * Provides a simplified API for common redemption management tasks while maintaining
2218
+ * access to the full redemption SDK for advanced use cases.
2219
+ */
2220
+ class RedemptionManager {
2221
+ constructor(apiClient) {
2222
+ this.apiClient = apiClient;
2223
+ this.redemptionSDK = createRedemptionSDK(apiClient);
2224
+ }
2225
+ /**
2226
+ * Get all active redemption offers
2227
+ *
2228
+ * @returns Promise resolving to array of active redemptions
2229
+ */
2230
+ async getActiveRedemptions() {
2231
+ return this.redemptionSDK.getActiveRedemptions();
2232
+ }
2233
+ /**
2234
+ * Get available redemption types
2235
+ *
2236
+ * @returns Promise resolving to array of redemption types
2237
+ */
2238
+ async getRedemptionTypes() {
2239
+ return this.redemptionSDK.getRedemptionTypes();
2240
+ }
2241
+ /**
2242
+ * Redeem a redemption offer
2243
+ *
2244
+ * @param redemptionId - ID of the redemption to redeem
2245
+ * @returns Promise resolving to redemption result
2246
+ */
2247
+ async redeemOffer(redemptionId) {
2248
+ return this.redemptionSDK.redeemRedemption(redemptionId);
2249
+ }
2250
+ /**
2251
+ * Get user's redemption history
2252
+ *
2253
+ * @returns Promise resolving to array of user's redemptions
2254
+ */
2255
+ async getUserRedemptions() {
2256
+ return this.redemptionSDK.getUserRedeems();
2257
+ }
2258
+ /**
2259
+ * Admin: Get all redemptions
2260
+ *
2261
+ * @param active - Filter by active status
2262
+ * @returns Promise resolving to array of redemptions
2263
+ */
2264
+ async getAllRedemptions(active) {
2265
+ return this.redemptionSDK.getRedemptionsAsAdmin(active);
2266
+ }
2267
+ /**
2268
+ * Admin: Create new redemption offer
2269
+ *
2270
+ * @param redemptionData - Redemption data
2271
+ * @returns Promise resolving to created redemption
2272
+ */
2273
+ async createRedemption(redemptionData) {
2274
+ return this.redemptionSDK.createRedemption(redemptionData);
2275
+ }
2276
+ /**
2277
+ * Admin: Update redemption
2278
+ *
2279
+ * @param redemptionId - ID of redemption to update
2280
+ * @param redemptionData - Updated redemption data
2281
+ * @returns Promise resolving to updated redemption
2282
+ */
2283
+ async updateRedemption(redemptionId, redemptionData) {
2284
+ return this.redemptionSDK.updateRedemption(redemptionId, redemptionData);
2285
+ }
2286
+ /**
2287
+ * Admin: Toggle redemption active status
2288
+ *
2289
+ * @param redemptionId - ID of redemption to toggle
2290
+ * @returns Promise resolving to updated redemption
2291
+ */
2292
+ async toggleRedemptionStatus(redemptionId) {
2293
+ return this.redemptionSDK.toggleRedemptionActive(redemptionId);
2294
+ }
2295
+ /**
2296
+ * Admin: Create redemption token unit
2297
+ *
2298
+ * @param redemptionId - ID of redemption
2299
+ * @param tokenUnit - Token unit data
2300
+ * @returns Promise resolving to updated redemption
2301
+ */
2302
+ async createRedemptionTokenUnit(redemptionId, tokenUnit) {
2303
+ return this.redemptionSDK.createRedemptionTokenUnit(redemptionId, tokenUnit);
2304
+ }
2305
+ /**
2306
+ * Admin: Delete redemption token unit
2307
+ *
2308
+ * @param redemptionId - ID of redemption
2309
+ * @param tokenUnitId - ID of token unit to delete
2310
+ * @returns Promise resolving to updated redemption
2311
+ */
2312
+ async deleteRedemptionTokenUnit(redemptionId, tokenUnitId) {
2313
+ return this.redemptionSDK.deleteRedemptionTokenUnit(redemptionId, tokenUnitId);
2314
+ }
2315
+ /**
2316
+ * Get the full redemption SDK for advanced operations
2317
+ *
2318
+ * @returns RedemptionSDK instance
2319
+ */
2320
+ getRedemptionSDK() {
2321
+ return this.redemptionSDK;
2322
+ }
2323
+ }
2324
+
2325
+ /**
2326
+ * Transaction Manager - Clean, high-level interface for transaction operations
2327
+ *
2328
+ * Provides a simplified API for common transaction management tasks while maintaining
2329
+ * access to the full transaction SDK for advanced use cases.
2330
+ */
2331
+ class TransactionManager {
2332
+ constructor(apiClient) {
2333
+ this.apiClient = apiClient;
2334
+ this.transactionSDK = createTransactionSDK(apiClient);
2335
+ }
2336
+ /**
2337
+ * Get transaction by ID
2338
+ *
2339
+ * @param transactionId - ID of the transaction
2340
+ * @returns Promise resolving to transaction data
2341
+ */
2342
+ async getTransactionById(transactionId) {
2343
+ return this.transactionSDK.getTransactionById(transactionId);
2344
+ }
2345
+ /**
2346
+ * Create a new transaction
2347
+ *
2348
+ * @param transactionData - Transaction data
2349
+ * @returns Promise resolving to transaction response
2350
+ */
2351
+ async createTransaction(transactionData) {
2352
+ return this.transactionSDK.createTransaction(transactionData);
2353
+ }
2354
+ /**
2355
+ * Get user's transaction history
2356
+ *
2357
+ * @param type - Transaction type filter
2358
+ * @returns Promise resolving to array of user's transactions
2359
+ */
2360
+ async getUserTransactionHistory(type) {
2361
+ return this.transactionSDK.getUserTransactionHistory(type);
2362
+ }
2363
+ /**
2364
+ * Admin: Get all tenant transactions
2365
+ *
2366
+ * @returns Promise resolving to array of tenant transactions
2367
+ */
2368
+ async getTenantTransactions() {
2369
+ return this.transactionSDK.getTenantTransactions();
2370
+ }
2371
+ /**
2372
+ * Admin: Get paginated transactions
2373
+ *
2374
+ * @param params - Pagination parameters
2375
+ * @returns Promise resolving to paginated transaction results
2376
+ */
2377
+ async getPaginatedTransactions(params) {
2378
+ return this.transactionSDK.getPaginatedTransactions(params);
2379
+ }
2380
+ /**
2381
+ * Admin: Export transactions as CSV
2382
+ *
2383
+ * @returns Promise resolving to CSV blob
2384
+ */
2385
+ async exportTransactionsCSV() {
2386
+ return this.transactionSDK.exportTransactionsCSV();
2387
+ }
2388
+ /**
2389
+ * Get the full transaction SDK for advanced operations
2390
+ *
2391
+ * @returns TransactionSDK instance
2392
+ */
2393
+ getTransactionSDK() {
2394
+ return this.transactionSDK;
2395
+ }
2396
+ }
2397
+
2398
+ /**
2399
+ * Payment Manager - Clean, high-level interface for payment operations
2400
+ *
2401
+ * Provides a simplified API for common payment management tasks while maintaining
2402
+ * access to the full payment SDK for advanced use cases.
2403
+ */
2404
+ class PaymentManager {
2405
+ constructor(apiClient) {
2406
+ this.apiClient = apiClient;
2407
+ this.paymentSDK = createPaymentSDK(apiClient);
2408
+ }
2409
+ /**
2410
+ * Create a payment intent
2411
+ *
2412
+ * @param amount - Payment amount
2413
+ * @param currency - Payment currency
2414
+ * @param receiptEmail - Receipt email
2415
+ * @param description - Payment description
2416
+ * @returns Promise resolving to created payment intent
2417
+ */
2418
+ async createPaymentIntent(amount, currency, receiptEmail, description) {
2419
+ return this.paymentSDK.createPaymentIntent(amount, currency, receiptEmail, description);
2420
+ }
2421
+ /**
2422
+ * Get active purchase tokens
2423
+ *
2424
+ * @param active - Filter by active status
2425
+ * @returns Promise resolving to purchase tokens
2426
+ */
2427
+ async getActivePurchaseTokens(active) {
2428
+ return this.paymentSDK.getActivePurchaseTokens(active);
2429
+ }
2430
+ /**
2431
+ * Get all user purchases
2432
+ *
2433
+ * @returns Promise resolving to array of user's purchases
2434
+ */
2435
+ async getAllUserPurchases() {
2436
+ return this.paymentSDK.getAllUserPurchases();
2437
+ }
2438
+ /**
2439
+ * Get the full payment SDK for advanced operations
2440
+ *
2441
+ * @returns PaymentSDK instance
2442
+ */
2443
+ getPaymentSDK() {
2444
+ return this.paymentSDK;
2445
+ }
2446
+ }
2447
+
2448
+ /**
2449
+ * Tenant Manager - Clean, high-level interface for tenant operations
2450
+ *
2451
+ * Provides a simplified API for common tenant management tasks while maintaining
2452
+ * access to the full tenant SDK for advanced use cases.
2453
+ */
2454
+ class TenantManager {
2455
+ constructor(apiClient) {
2456
+ this.apiClient = apiClient;
2457
+ this.tenantSDK = createTenantSDK(apiClient);
2458
+ }
2459
+ /**
2460
+ * Get current tenant information
2461
+ *
2462
+ * @returns Promise resolving to tenant data
2463
+ */
2464
+ async getTenantInfo() {
2465
+ return this.tenantSDK.getRemoteTenant();
2466
+ }
2467
+ /**
2468
+ * Get tenant login token
2469
+ *
2470
+ * @returns Promise resolving to login token
2471
+ */
2472
+ async getLoginToken() {
2473
+ return this.tenantSDK.getRemoteLoginToken();
2474
+ }
2475
+ /**
2476
+ * Get tenant client configuration
2477
+ *
2478
+ * @returns Promise resolving to client config
2479
+ */
2480
+ async getClientConfig() {
2481
+ return this.tenantSDK.getRemoteClientConfig();
2482
+ }
2483
+ /**
2484
+ * Admin: Update tenant data
2485
+ *
2486
+ * @param tenantData - Updated tenant data
2487
+ * @returns Promise resolving to updated tenant
2488
+ */
2489
+ async updateTenant(tenantData) {
2490
+ return this.tenantSDK.updateRemoteTenant(tenantData);
2491
+ }
2492
+ /**
2493
+ * Admin: Get all admins
2494
+ *
2495
+ * @returns Promise resolving to array of admins
2496
+ */
2497
+ async getAdmins() {
2498
+ return this.tenantSDK.getAdmins();
2499
+ }
2500
+ /**
2501
+ * Admin: Create new admin
2502
+ *
2503
+ * @param adminData - Admin data
2504
+ * @returns Promise resolving to created admin
2505
+ */
2506
+ async createAdmin(adminData) {
2507
+ return this.tenantSDK.postAdmin(adminData);
2508
+ }
2509
+ /**
2510
+ * Get the full tenant SDK for advanced operations
2511
+ *
2512
+ * @returns TenantSDK instance
2513
+ */
2514
+ getTenantSDK() {
2515
+ return this.tenantSDK;
2516
+ }
2517
+ }
2518
+
2519
+ /**
2520
+ * Analytics Manager - Clean, high-level interface for analytics operations
2521
+ *
2522
+ * Provides a simplified API for common analytics tasks while maintaining
2523
+ * access to the full analytics SDK for advanced use cases.
2524
+ */
2525
+ class AnalyticsManager {
2526
+ constructor(apiClient) {
2527
+ this.apiClient = apiClient;
2528
+ this.analyticsSDK = createAnalyticsSDK(apiClient);
2529
+ }
2530
+ /**
2531
+ * Get transaction analytics
2532
+ *
2533
+ * @param request - Analytics request parameters
2534
+ * @returns Promise resolving to transaction analytics data
2535
+ */
2536
+ async getTransactionAnalytics(request) {
2537
+ return this.analyticsSDK.getTransactionAnalytics(request);
2538
+ }
2539
+ /**
2540
+ * Get the full analytics SDK for advanced operations
2541
+ *
2542
+ * @returns AnalyticsSDK instance
2543
+ */
2544
+ getAnalyticsSDK() {
2545
+ return this.analyticsSDK;
2546
+ }
2547
+ }
2548
+
2549
+ /**
2550
+ * Donation Manager - Clean, high-level interface for donation operations
2551
+ *
2552
+ * Provides a simplified API for common donation tasks while maintaining
2553
+ * access to the full donation SDK for advanced use cases.
2554
+ */
2555
+ class DonationManager {
2556
+ constructor(apiClient) {
2557
+ this.apiClient = apiClient;
2558
+ this.donationSDK = createDonationSDK(apiClient);
2559
+ }
2560
+ /**
2561
+ * Get available donation types
2562
+ *
2563
+ * @returns Promise resolving to array of donation types
2564
+ */
2565
+ async getDonationTypes() {
2566
+ return this.donationSDK.getAllDonationTypes();
2567
+ }
2568
+ /**
2569
+ * Get the full donation SDK for advanced operations
2570
+ *
2571
+ * @returns DonationSDK instance
2572
+ */
2573
+ getDonationSDK() {
2574
+ return this.donationSDK;
2575
+ }
2576
+ }
2577
+
2578
+ /**
2579
+ * PERS SDK - Platform-agnostic TypeScript SDK with High-Level Managers
2580
+ *
2581
+ * ## Overview
2582
+ *
2583
+ * The PERS SDK provides a comprehensive interface for integrating with the PERS
2584
+ * (Phygital Experience Rewards System) platform. It features a clean manager-based
2585
+ * architecture that abstracts complex domain operations into intuitive high-level APIs.
2586
+ *
2587
+ * ## Architecture
2588
+ *
2589
+ * ```
2590
+ * PersSDK
2591
+ * ├── Domain Managers (Recommended) // High-level, intuitive APIs
2592
+ * │ ├── auth: AuthManager // Authentication & user sessions
2593
+ * │ ├── users: UserManager // User profile management
2594
+ * │ ├── tokens: TokenManager // Token balances & transfers
2595
+ * │ ├── businesses: BusinessManager // Business operations
2596
+ * │ ├── campaigns: CampaignManager // Marketing campaigns
2597
+ * │ ├── redemptions: RedemptionManager // Reward redemptions
2598
+ * │ ├── transactions: TransactionManager // Transaction history
2599
+ * │ ├── payments: PaymentManager // Payment processing
2600
+ * │ └── analytics: AnalyticsManager // Reporting & analytics
2601
+ * ├── Domain SDKs (Advanced) // Full-featured domain access
2602
+ * │ ├── createBusinessSDK()
2603
+ * │ ├── createCampaignSDK()
2604
+ * │ └── TokenSDK, etc.
2605
+ * └── Core API Client (Expert) // Direct REST API access
2606
+ * └── api(): PersApiClient
2607
+ * ```
2608
+ *
2609
+ * ## Usage Patterns
2610
+ *
2611
+ * ### 1. High-Level Manager Pattern (Recommended)
2612
+ *
2613
+ * ```typescript
2614
+ * import { PersSDK } from '@explorins/pers-sdk';
2615
+ * import { BrowserFetchClientAdapter } from '@explorins/pers-sdk/platform-adapters';
2616
+ *
2617
+ * const sdk = new PersSDK(new BrowserFetchClientAdapter(), {
2618
+ * environment: 'production',
2619
+ * apiProjectKey: 'your-project-key'
2620
+ * });
2621
+ *
2622
+ * // Clean, intuitive manager interface
2623
+ * const user = await sdk.auth.getCurrentUser();
2624
+ * const campaigns = await sdk.campaigns.getActiveCampaigns();
2625
+ * const balances = await sdk.tokens.getTokens();
2626
+ * ```
2627
+ *
2628
+ * ### 2. Advanced Domain SDK Access
2629
+ *
2630
+ * ```typescript
2631
+ * // Access full SDK capabilities when needed
2632
+ * const campaignSDK = sdk.campaigns.getCampaignSDK();
2633
+ * const advancedCampaignOps = await campaignSDK.api.createComplexCampaign(data);
2634
+ * ```
2635
+ *
2636
+ * ### 3. Direct API Client Access
2637
+ *
2638
+ * ```typescript
2639
+ * // For custom endpoints or advanced operations
2640
+ * const apiClient = sdk.api();
2641
+ * const customData = await apiClient.get('/custom-endpoint');
2642
+ * ```
2643
+ *
2644
+ * ## Platform Integration
2645
+ *
2646
+ * The SDK provides pre-built adapters for common platforms:
2647
+ *
2648
+ * - **Angular**: `AngularHttpClientAdapter`
2649
+ * - **Browser/React/Vue**: `BrowserFetchClientAdapter`
2650
+ * - **Node.js**: `NodeHttpClientAdapter`
2651
+ * - **Custom**: Implement `HttpClient` interface
2652
+ *
2653
+ * ## Features
2654
+ *
2655
+ * - ✅ **Type-safe**: Full TypeScript support with comprehensive type definitions
2656
+ * - ✅ **Platform-agnostic**: Works in browsers, Node.js, React Native, and more
2657
+ * - ✅ **Authentication**: Automatic token management and refresh
2658
+ * - ✅ **Error handling**: Comprehensive error handling with typed exceptions
2659
+ * - ✅ **Modular**: Import only the domains you need
2660
+ * - ✅ **Manager pattern**: Clean, high-level APIs for common operations
2661
+ * - ✅ **Backward compatible**: Maintains compatibility with existing integrations
2662
+ * - ✅ **Tree-shakable**: Optimized for minimal bundle size
2663
+ *
2664
+ * @example Basic Setup
2665
+ * ```typescript
2666
+ * import { PersSDK } from '@explorins/pers-sdk';
2667
+ * import { BrowserFetchClientAdapter } from '@explorins/pers-sdk/platform-adapters';
2668
+ *
2669
+ * const sdk = new PersSDK(new BrowserFetchClientAdapter(), {
2670
+ * environment: 'production',
2671
+ * apiProjectKey: 'your-project-key'
2672
+ * });
2673
+ * ```
2674
+ *
2675
+ * @example Authentication Flow
2676
+ * ```typescript
2677
+ * // Login with external JWT (Firebase, Auth0, etc.)
2678
+ * await sdk.auth.loginWithToken(firebaseJWT, 'user');
2679
+ *
2680
+ * // Check authentication status
2681
+ * if (await sdk.auth.isAuthenticated()) {
2682
+ * const user = await sdk.auth.getCurrentUser();
2683
+ * console.log('Welcome,', user.name);
2684
+ * }
2685
+ * ```
2686
+ *
2687
+ * @example Business Operations
2688
+ * ```typescript
2689
+ * // Get active businesses
2690
+ * const businesses = await sdk.businesses.getActiveBusinesses();
2691
+ *
2692
+ * // Get business details
2693
+ * const business = await sdk.businesses.getBusinessById(businessId);
2694
+ *
2695
+ * // Admin: Create new business
2696
+ * const newBusiness = await sdk.businesses.createBusiness({
2697
+ * name: 'New Business',
2698
+ * location: 'City Center',
2699
+ * type: 'restaurant'
2700
+ * });
2701
+ * ```
2702
+ *
2703
+ * @example Campaign Management
2704
+ * ```typescript
2705
+ * // Get active campaigns
2706
+ * const campaigns = await sdk.campaigns.getActiveCampaigns();
2707
+ *
2708
+ * // Claim a campaign
2709
+ * await sdk.campaigns.claimCampaign({
2710
+ * campaignId: 'campaign-123',
2711
+ * metadata: { source: 'mobile-app' }
2712
+ * });
2713
+ *
2714
+ * // Get user's claims
2715
+ * const claims = await sdk.campaigns.getUserClaims();
2716
+ * ```
2717
+ *
2718
+ * @example Token Operations
2719
+ * ```typescript
2720
+ * // Get user's token balances
2721
+ * const tokens = await sdk.tokens.getTokens();
2722
+ *
2723
+ * // Transfer tokens between users
2724
+ * await sdk.tokens.transferTokens({
2725
+ * fromUserId: 'user-1',
2726
+ * toUserId: 'user-2',
2727
+ * tokenType: 'CREDIT',
2728
+ * amount: 100
2729
+ * });
2730
+ * ```
2731
+ *
2732
+ * @since 1.3.0 - Manager pattern architecture
2733
+ */
2734
+ /**
2735
+ * PERS SDK class with domain managers
2736
+ *
2737
+ * Main SDK interface providing clean, high-level managers for common operations
2738
+ * while maintaining full access to the underlying API client and domain SDKs.
2739
+ *
2740
+ * @example
2741
+ * ```typescript
2742
+ * import { PersSDK, createAuthProvider } from '@explorins/pers-sdk/core';
2743
+ * import { BrowserHttpClient } from '@explorins/pers-sdk/browser';
2744
+ *
2745
+ * const authProvider = createAuthProvider({
2746
+ * tokenProvider: () => getFirebaseToken()
2747
+ * });
2748
+ *
2749
+ * const sdk = new PersSDK(new BrowserHttpClient(), {
2750
+ * environment: 'production',
2751
+ * apiProjectKey: 'your-project-key',
2752
+ * authProvider
2753
+ * });
2754
+ *
2755
+ * // High-level manager interface
2756
+ * const user = await sdk.auth.getCurrentUser();
2757
+ * const tokens = await sdk.tokens.getTokens();
2758
+ * const businesses = await sdk.business.getActiveBusinesses();
2759
+ *
2760
+ * // Direct API access for advanced operations
2761
+ * const apiClient = sdk.api();
2762
+ * const customData = await apiClient.get('/custom-endpoint');
2763
+ * ```
2764
+ */
2765
+ class PersSDK {
2766
+ /**
2767
+ * Creates a new PERS SDK instance
2768
+ *
2769
+ * @param httpClient Platform-specific HTTP client implementation
2770
+ * @param config SDK configuration options
2771
+ */
2772
+ constructor(httpClient, config) {
2773
+ this.apiClient = new PersApiClient(httpClient, config);
2774
+ // Initialize domain managers
2775
+ this._auth = new AuthManager(this.apiClient);
2776
+ this._users = new UserManager(this.apiClient);
2777
+ this._tokens = new TokenManager(this.apiClient);
2778
+ this._businesses = new BusinessManager(this.apiClient);
2779
+ this._campaigns = new CampaignManager(this.apiClient);
2780
+ this._redemptions = new RedemptionManager(this.apiClient);
2781
+ this._transactions = new TransactionManager(this.apiClient);
2782
+ this._payments = new PaymentManager(this.apiClient);
2783
+ this._tenants = new TenantManager(this.apiClient);
2784
+ this._analytics = new AnalyticsManager(this.apiClient);
2785
+ this._donations = new DonationManager(this.apiClient);
2786
+ }
2787
+ /**
2788
+ * Authentication manager - High-level auth operations
2789
+ *
2790
+ * @example
2791
+ * ```typescript
2792
+ * await sdk.auth.loginWithToken(jwtToken);
2793
+ * const user = await sdk.auth.getCurrentUser();
2794
+ * const isAuth = await sdk.auth.isAuthenticated();
2795
+ * ```
2796
+ */
2797
+ get auth() {
2798
+ return this._auth;
2799
+ }
2800
+ /**
2801
+ * User manager - High-level user operations
2802
+ *
2803
+ * @example
2804
+ * ```typescript
2805
+ * const user = await sdk.user.getCurrentUser();
2806
+ * await sdk.user.updateCurrentUser(userData);
2807
+ * const users = await sdk.user.getAllUsersPublic();
2808
+ * ```
2809
+ */
2810
+ get users() {
2811
+ return this._users;
2812
+ }
2813
+ /**
2814
+ * Token manager - High-level token operations
2815
+ *
2816
+ * @example
2817
+ * ```typescript
2818
+ * const tokens = await sdk.tokens.getTokens();
2819
+ * const creditToken = await sdk.tokens.getActiveCreditToken();
2820
+ * const rewards = await sdk.tokens.getRewardTokens();
2821
+ * ```
2822
+ */
2823
+ get tokens() {
2824
+ return this._tokens;
2825
+ }
2826
+ /**
2827
+ * Business manager - High-level business operations
2828
+ *
2829
+ * @example
2830
+ * ```typescript
2831
+ * const businesses = await sdk.business.getActiveBusinesses();
2832
+ * const business = await sdk.business.getBusinessById(id);
2833
+ * const types = await sdk.business.getBusinessTypes();
2834
+ * ```
2835
+ */
2836
+ get businesses() {
2837
+ return this._businesses;
2838
+ }
2839
+ /**
2840
+ * Campaign manager - High-level campaign operations
2841
+ *
2842
+ * @example
2843
+ * ```typescript
2844
+ * const campaigns = await sdk.campaigns.getActiveCampaigns();
2845
+ * await sdk.campaigns.claimCampaign(claimData);
2846
+ * const claims = await sdk.campaigns.getUserClaims();
2847
+ * ```
2848
+ */
2849
+ get campaigns() {
2850
+ return this._campaigns;
2851
+ }
2852
+ /**
2853
+ * Redemption manager - High-level redemption operations
2854
+ *
2855
+ * @example
2856
+ * ```typescript
2857
+ * const redemptions = await sdk.redemptions.getActiveRedemptions();
2858
+ * await sdk.redemptions.redeemOffer(redemptionId);
2859
+ * const history = await sdk.redemptions.getUserRedemptions();
2860
+ * ```
2861
+ */
2862
+ get redemptions() {
2863
+ return this._redemptions;
2864
+ }
2865
+ /**
2866
+ * Transaction manager - High-level transaction operations
2867
+ *
2868
+ * @example
2869
+ * ```typescript
2870
+ * const transaction = await sdk.transactions.getTransactionById(id);
2871
+ * await sdk.transactions.createTransaction(txData);
2872
+ * const history = await sdk.transactions.getUserTransactionHistory('all');
2873
+ * ```
2874
+ */
2875
+ get transactions() {
2876
+ return this._transactions;
2877
+ }
2878
+ /**
2879
+ * Payment manager - High-level payment operations
2880
+ *
2881
+ * @example
2882
+ * ```typescript
2883
+ * const intent = await sdk.payments.createPaymentIntent(100, 'usd', 'email@example.com', 'Purchase');
2884
+ * const tokens = await sdk.payments.getActivePurchaseTokens();
2885
+ * const purchases = await sdk.payments.getAllUserPurchases();
2886
+ * ```
2887
+ */
2888
+ get payments() {
2889
+ return this._payments;
2890
+ }
2891
+ /**
2892
+ * Tenant manager - High-level tenant operations
2893
+ *
2894
+ * @example
2895
+ * ```typescript
2896
+ * const tenant = await sdk.tenant.getTenantInfo();
2897
+ * const config = await sdk.tenant.getClientConfig();
2898
+ * const admins = await sdk.tenant.getAdmins();
2899
+ * ```
2900
+ */
2901
+ get tenants() {
2902
+ return this._tenants;
2903
+ }
2904
+ /**
2905
+ * Analytics manager - High-level analytics operations
2906
+ *
2907
+ * @example
2908
+ * ```typescript
2909
+ * const analytics = await sdk.analytics.getTransactionAnalytics(request);
2910
+ * ```
2911
+ */
2912
+ get analytics() {
2913
+ return this._analytics;
2914
+ }
2915
+ /**
2916
+ * Donation manager - High-level donation operations
2917
+ *
2918
+ * @example
2919
+ * ```typescript
2920
+ * const types = await sdk.donations.getDonationTypes();
2921
+ * ```
2922
+ */
2923
+ get donations() {
2924
+ return this._donations;
2925
+ }
2926
+ /**
2927
+ * Gets the API client for direct PERS API requests
2928
+ *
2929
+ * Use this for advanced operations not covered by the managers.
2930
+ * The returned client handles authentication, token refresh, and error handling automatically.
2931
+ *
2932
+ * @returns Configured PersApiClient instance
2933
+ *
2934
+ * @example
2935
+ * ```typescript
2936
+ * const apiClient = sdk.api();
2937
+ * const customData = await apiClient.get<CustomType>('/custom-endpoint');
2938
+ * await apiClient.post('/custom-endpoint', customData);
2939
+ * ```
2940
+ */
2941
+ api() {
2942
+ return this.apiClient;
2943
+ }
2944
+ /**
2945
+ * Checks if SDK is configured for production environment
2946
+ *
2947
+ * @returns True if environment is 'production', false otherwise
2948
+ */
2949
+ isProduction() {
2950
+ return this.apiClient.getConfig().environment === 'production';
2951
+ }
2952
+ }
2953
+ /**
2954
+ * Factory function for creating PERS SDK
2955
+ *
2956
+ * @param httpClient Platform-specific HTTP client implementation
2957
+ * @param config SDK configuration options
2958
+ * @returns PERS SDK instance
1685
2959
  */
1686
2960
  function createPersSDK(httpClient, config) {
1687
2961
  return new PersSDK(httpClient, config);
1688
2962
  }
1689
2963
 
1690
- export { DEFAULT_PERS_CONFIG as D, PersSDK as P, createPersSDK as a, PersApiClient as b, createAuthProvider as c, buildApiRoot as d, mergeWithDefaults as m };
1691
- //# sourceMappingURL=pers-sdk-Rc8YKyNc.js.map
2964
+ export { AuthManager as A, BusinessManager as B, CampaignManager as C, DEFAULT_PERS_CONFIG as D, PersSDK as P, RedemptionManager as R, TokenManager as T, UserManager as U, createAuthProvider as a, PersApiClient as b, createPersSDK as c, buildApiRoot as d, TransactionManager as e, PaymentManager as f, TenantManager as g, AnalyticsManager as h, DonationManager as i, mergeWithDefaults as m };
2965
+ //# sourceMappingURL=pers-sdk-CVSAFBLh.js.map