@explorins/pers-sdk-react-native 2.1.10 → 2.1.12
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.
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { OnStatusUpdateFn } from './useTransactionSigner';
|
|
2
2
|
import type { RedemptionCreateRequestDTO, RedemptionDTO, RedemptionRedeemDTO, RedemptionRedeemRequestResponseDTO, RedemptionTypeDTO, PaginatedResponseDTO, RedemptionRedeemIncludeRelation } from '@explorins/pers-shared';
|
|
3
3
|
import type { RedemptionRedeemFilters } from '@explorins/pers-sdk/redemption';
|
|
4
|
+
import type { PaginationOptions } from '@explorins/pers-sdk';
|
|
4
5
|
export type { RedemptionRedeemFilters } from '@explorins/pers-sdk/redemption';
|
|
5
6
|
export declare const useRedemptions: () => {
|
|
6
7
|
getRedemptions: (options?: {
|
|
7
8
|
active?: boolean;
|
|
8
9
|
}) => Promise<PaginatedResponseDTO<RedemptionDTO>>;
|
|
9
|
-
getUserRedemptions: (include?: RedemptionRedeemIncludeRelation[]) => Promise<PaginatedResponseDTO<RedemptionRedeemDTO>>;
|
|
10
|
+
getUserRedemptions: (options?: PaginationOptions, include?: RedemptionRedeemIncludeRelation[]) => Promise<PaginatedResponseDTO<RedemptionRedeemDTO>>;
|
|
10
11
|
redeem: (redemptionId: string, onStatusUpdate?: OnStatusUpdateFn) => Promise<RedemptionRedeemRequestResponseDTO>;
|
|
11
12
|
getRedemptionTypes: () => Promise<PaginatedResponseDTO<RedemptionTypeDTO>>;
|
|
12
13
|
getRedemptionRedeems: (filters?: RedemptionRedeemFilters, include?: RedemptionRedeemIncludeRelation[]) => Promise<PaginatedResponseDTO<RedemptionRedeemDTO>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedemptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useRedemptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,gBAAgB,EAAE,MAAM,wBAAwB,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GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -26,22 +26,27 @@ export const useRedemptions = () => {
|
|
|
26
26
|
}
|
|
27
27
|
}, [sdk, isInitialized]);
|
|
28
28
|
/**
|
|
29
|
-
* Get user's redemption history with optional include relations
|
|
29
|
+
* Get user's redemption history with optional pagination and include relations
|
|
30
30
|
*
|
|
31
|
+
* @param options - Pagination options (page, limit, sortBy, sortOrder)
|
|
31
32
|
* @param include - Relations to include: 'redemption', 'user', 'business'
|
|
32
33
|
* @returns Promise resolving to paginated redemption history
|
|
33
34
|
*
|
|
34
35
|
* @example
|
|
35
36
|
* ```typescript
|
|
37
|
+
* // Get first page of user redemptions
|
|
38
|
+
* const { data: redeems, pagination } = await getUserRedemptions({ page: 1, limit: 10 });
|
|
39
|
+
* console.log(`Page ${pagination.page} of ${pagination.pages}`);
|
|
40
|
+
*
|
|
36
41
|
* // Get user redemptions with full redemption details
|
|
37
|
-
* const { data: redeems } = await getUserRedemptions(['redemption', 'business']);
|
|
42
|
+
* const { data: redeems } = await getUserRedemptions({}, ['redemption', 'business']);
|
|
38
43
|
* redeems.forEach(redeem => {
|
|
39
44
|
* console.log('Redemption:', redeem.included?.redemption?.title);
|
|
40
45
|
* console.log('Business:', redeem.included?.business?.displayName);
|
|
41
46
|
* });
|
|
42
47
|
* ```
|
|
43
48
|
*/
|
|
44
|
-
const getUserRedemptions = useCallback(async (include) => {
|
|
49
|
+
const getUserRedemptions = useCallback(async (options, include) => {
|
|
45
50
|
if (!isInitialized || !sdk) {
|
|
46
51
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
47
52
|
}
|
|
@@ -50,7 +55,7 @@ export const useRedemptions = () => {
|
|
|
50
55
|
return { data: [], pagination: { page: 1, limit: 0, total: 0, pages: 0, hasNext: false, hasPrev: false } };
|
|
51
56
|
}
|
|
52
57
|
try {
|
|
53
|
-
const result = await sdk.redemptions.getUserRedemptions(
|
|
58
|
+
const result = await sdk.redemptions.getUserRedemptions(options, include);
|
|
54
59
|
return result;
|
|
55
60
|
}
|
|
56
61
|
catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -2933,15 +2933,42 @@ exports.PurchaseCurrency = void 0;
|
|
|
2933
2933
|
})(exports.PurchaseCurrency || (exports.PurchaseCurrency = {}));
|
|
2934
2934
|
|
|
2935
2935
|
/**
|
|
2936
|
-
* Trigger Source Types
|
|
2937
|
-
*
|
|
2936
|
+
* Trigger Source Types - HOW a claim is triggered (the touchpoint mechanism)
|
|
2937
|
+
*
|
|
2938
|
+
* This defines the physical/digital interaction method for triggering claims.
|
|
2939
|
+
* NOT to be confused with CampaignTriggerType which defines WHO can claim.
|
|
2940
|
+
*
|
|
2941
|
+
* Relationship:
|
|
2942
|
+
* - campaign.trigger.triggerType → WHO can claim (CLAIM_BY_USER, CLAIM_BY_BUSINESS, CLAIM_BY_SYSTEM)
|
|
2943
|
+
* - campaign.triggerSources[].type → HOW to claim (QR_CODE, NFC_TAG, GPS_GEOFENCE, etc.)
|
|
2944
|
+
*
|
|
2945
|
+
* Access via: campaign.included?.triggerSources?.map(ts => ts.type)
|
|
2946
|
+
*
|
|
2947
|
+
* App Integration Guide:
|
|
2948
|
+
* - QR_CODE: Open camera/scanner, decode QR, extract triggerSourceId
|
|
2949
|
+
* - NFC_TAG: Activate NFC reader, read tag data, extract triggerSourceId
|
|
2950
|
+
* - GPS_GEOFENCE: Get user location, send latitude/longitude with claim
|
|
2951
|
+
* - API_WEBHOOK: Server-to-server, external system triggers claim
|
|
2952
|
+
* - TRANSACTION: Triggered by purchase events (Stripe, POS, etc.)
|
|
2953
|
+
*
|
|
2954
|
+
* NOTE: A campaign can have MULTIPLE trigger sources of different types.
|
|
2955
|
+
* Example: Same campaign claimable via QR_CODE OR NFC_TAG at different locations.
|
|
2956
|
+
*
|
|
2938
2957
|
* Using const object pattern for better extensibility without requiring deploys
|
|
2958
|
+
*
|
|
2959
|
+
* @see CampaignTriggerType for WHO can initiate claims
|
|
2960
|
+
* @see CampaignClaimRequestDTO for the claim payload structure
|
|
2939
2961
|
*/
|
|
2940
2962
|
const TRIGGER_SOURCE_TYPES = {
|
|
2963
|
+
/** Physical QR code scan. App opens camera, decodes QR, extracts triggerSourceId */
|
|
2941
2964
|
QR_CODE: 'QR_CODE',
|
|
2965
|
+
/** NFC tag tap. App activates NFC reader, reads tag data, extracts triggerSourceId */
|
|
2942
2966
|
NFC_TAG: 'NFC_TAG',
|
|
2967
|
+
/** Server-to-server webhook. External system triggers claim via API */
|
|
2943
2968
|
API_WEBHOOK: 'API_WEBHOOK',
|
|
2969
|
+
/** GPS-based geofence entry. App sends user coordinates for proximity validation */
|
|
2944
2970
|
GPS_GEOFENCE: 'GPS_GEOFENCE',
|
|
2971
|
+
/** Purchase/transaction triggered. Claim activated by payment events */
|
|
2945
2972
|
TRANSACTION: 'TRANSACTION',
|
|
2946
2973
|
};
|
|
2947
2974
|
// Export values array for validation
|
|
@@ -2967,10 +2994,46 @@ exports.CampaignConditionType = void 0;
|
|
|
2967
2994
|
CampaignConditionType["IS_PART_OF"] = "IS_PART_OF";
|
|
2968
2995
|
})(exports.CampaignConditionType || (exports.CampaignConditionType = {}));
|
|
2969
2996
|
|
|
2997
|
+
/**
|
|
2998
|
+
* Campaign Trigger Type - WHO can initiate a claim
|
|
2999
|
+
*
|
|
3000
|
+
* This defines the authentication/authorization context for claiming rewards.
|
|
3001
|
+
* NOT to be confused with TriggerSourceType which defines HOW to claim (QR, NFC, etc.)
|
|
3002
|
+
*
|
|
3003
|
+
* Relationship:
|
|
3004
|
+
* - campaign.trigger.triggerType → WHO can claim (CLAIM_BY_USER, CLAIM_BY_BUSINESS, CLAIM_BY_SYSTEM)
|
|
3005
|
+
* - campaign.triggerSources[].type → HOW to claim (QR_CODE, NFC_TAG, GPS_GEOFENCE, etc.)
|
|
3006
|
+
*
|
|
3007
|
+
* Example Flow:
|
|
3008
|
+
* 1. Campaign has triggerType=CLAIM_BY_USER (users initiate claims)
|
|
3009
|
+
* 2. Campaign has triggerSources with type=QR_CODE (via QR scan)
|
|
3010
|
+
* 3. User scans QR code → App calls claimCampaign with triggerSourceId
|
|
3011
|
+
*
|
|
3012
|
+
* @see TriggerSourceType for HOW claims are triggered
|
|
3013
|
+
* @see CampaignClaimRequestDTO for the claim payload structure
|
|
3014
|
+
*/
|
|
2970
3015
|
exports.CampaignTriggerType = void 0;
|
|
2971
3016
|
(function (CampaignTriggerType) {
|
|
3017
|
+
/**
|
|
3018
|
+
* User-initiated claims. The end user triggers the claim action.
|
|
3019
|
+
* App determines HOW via campaign.triggerSources[].type:
|
|
3020
|
+
* - QR_CODE: Open camera/scanner
|
|
3021
|
+
* - NFC_TAG: Activate NFC reader
|
|
3022
|
+
* - GPS_GEOFENCE: Send user location
|
|
3023
|
+
* - TRANSACTION: Triggered by purchase
|
|
3024
|
+
*/
|
|
2972
3025
|
CampaignTriggerType["CLAIM_BY_USER"] = "CLAIM_BY_USER";
|
|
3026
|
+
/**
|
|
3027
|
+
* System/server-initiated claims. Automated processes trigger claims.
|
|
3028
|
+
* Use cases: webhooks, scheduled jobs, backend integrations.
|
|
3029
|
+
* Requires tenant API key authentication.
|
|
3030
|
+
*/
|
|
2973
3031
|
CampaignTriggerType["CLAIM_BY_SYSTEM"] = "CLAIM_BY_SYSTEM";
|
|
3032
|
+
/**
|
|
3033
|
+
* Business-initiated claims. A business claims on behalf of users.
|
|
3034
|
+
* Use cases: POS systems, staff-assisted redemptions, kiosks.
|
|
3035
|
+
* Requires business authentication + user identifier.
|
|
3036
|
+
*/
|
|
2974
3037
|
CampaignTriggerType["CLAIM_BY_BUSINESS"] = "CLAIM_BY_BUSINESS";
|
|
2975
3038
|
})(exports.CampaignTriggerType || (exports.CampaignTriggerType = {}));
|
|
2976
3039
|
|
|
@@ -7703,15 +7766,26 @@ class TenantApi {
|
|
|
7703
7766
|
// ==========================================
|
|
7704
7767
|
// PUBLIC OPERATIONS
|
|
7705
7768
|
// ==========================================
|
|
7769
|
+
/**
|
|
7770
|
+
* API KEY + ADMIN JWT: Get full tenant information including sensitive config
|
|
7771
|
+
* Uses /tenants/me endpoint with Admin JWT authentication
|
|
7772
|
+
*
|
|
7773
|
+
* Requires: X-API-Key header + Authorization Bearer token (Admin JWT)
|
|
7774
|
+
* Returns: Full tenant information including allowedTokenIssuers and sensitive config
|
|
7775
|
+
*/
|
|
7776
|
+
async getRemoteTenant() {
|
|
7777
|
+
const timestamp = Date.now().toString();
|
|
7778
|
+
const url = `${this.basePath}/me?date=${timestamp}`;
|
|
7779
|
+
return this.apiClient.get(url);
|
|
7780
|
+
}
|
|
7706
7781
|
/**
|
|
7707
7782
|
* API KEY: Get current tenant public information
|
|
7708
|
-
*
|
|
7783
|
+
* Uses /tenants/me endpoint with API key authentication
|
|
7709
7784
|
*
|
|
7710
7785
|
* Requires: X-API-Key header (handled by PersApiClient)
|
|
7711
|
-
* Returns:
|
|
7786
|
+
* Returns: Public tenant information (no sensitive config)
|
|
7712
7787
|
*/
|
|
7713
|
-
async
|
|
7714
|
-
// Remove cache busting - not needed for authenticated endpoint
|
|
7788
|
+
async getRemoteTenantPublic() {
|
|
7715
7789
|
const timestamp = Date.now().toString();
|
|
7716
7790
|
const url = `${this.basePath}/me?date=${timestamp}`;
|
|
7717
7791
|
return this.apiClient.get(url);
|
|
@@ -7748,7 +7822,8 @@ class TenantApi {
|
|
|
7748
7822
|
// ==========================================
|
|
7749
7823
|
/**
|
|
7750
7824
|
* ADMIN: Update tenant information
|
|
7751
|
-
*
|
|
7825
|
+
* UPDATED: Uses PUT /tenants (admin endpoint)
|
|
7826
|
+
* Returns full TenantDTO including sensitive config
|
|
7752
7827
|
*/
|
|
7753
7828
|
async updateRemoteTenant(tenantData) {
|
|
7754
7829
|
return this.apiClient.put(`${this.basePath}`, tenantData);
|
|
@@ -7793,11 +7868,17 @@ class TenantService {
|
|
|
7793
7868
|
// PUBLIC OPERATIONS
|
|
7794
7869
|
// ==========================================
|
|
7795
7870
|
/**
|
|
7796
|
-
*
|
|
7871
|
+
* Get full tenant information (Admin JWT required)
|
|
7797
7872
|
*/
|
|
7798
7873
|
async getRemoteTenant() {
|
|
7799
7874
|
return this.tenantApi.getRemoteTenant();
|
|
7800
7875
|
}
|
|
7876
|
+
/**
|
|
7877
|
+
* PUBLIC: Get tenant public information (API key only)
|
|
7878
|
+
*/
|
|
7879
|
+
async getRemoteTenantPublic() {
|
|
7880
|
+
return this.tenantApi.getRemoteTenantPublic();
|
|
7881
|
+
}
|
|
7801
7882
|
/**
|
|
7802
7883
|
* PUBLIC: Get remote login token
|
|
7803
7884
|
*/
|
|
@@ -7815,7 +7896,7 @@ class TenantService {
|
|
|
7815
7896
|
// ==========================================
|
|
7816
7897
|
/**
|
|
7817
7898
|
* ADMIN: Update tenant information
|
|
7818
|
-
*
|
|
7899
|
+
* Returns full TenantDTO including sensitive config
|
|
7819
7900
|
*/
|
|
7820
7901
|
async updateRemoteTenant(tenantData) {
|
|
7821
7902
|
return this.tenantApi.updateRemoteTenant(tenantData);
|
|
@@ -7859,9 +7940,20 @@ class TenantManager {
|
|
|
7859
7940
|
this.tenantService = new TenantService(tenantApi);
|
|
7860
7941
|
}
|
|
7861
7942
|
/**
|
|
7862
|
-
* Get current tenant information
|
|
7943
|
+
* Get current tenant public information (API key only)
|
|
7863
7944
|
*
|
|
7864
|
-
* @returns Promise resolving to tenant data
|
|
7945
|
+
* @returns Promise resolving to public tenant data
|
|
7946
|
+
*/
|
|
7947
|
+
async getTenantPublicInfo() {
|
|
7948
|
+
return this.tenantService.getRemoteTenantPublic();
|
|
7949
|
+
}
|
|
7950
|
+
/**
|
|
7951
|
+
* Get full tenant information including sensitive config (Admin JWT required)
|
|
7952
|
+
*
|
|
7953
|
+
* Returns additional fields like allowedTokenIssuers that are only
|
|
7954
|
+
* available to authenticated tenant admins.
|
|
7955
|
+
*
|
|
7956
|
+
* @returns Promise resolving to full tenant data
|
|
7865
7957
|
*/
|
|
7866
7958
|
async getTenantInfo() {
|
|
7867
7959
|
return this.tenantService.getRemoteTenant();
|
|
@@ -7944,7 +8036,7 @@ class TenantManager {
|
|
|
7944
8036
|
* Admin: Update tenant data
|
|
7945
8037
|
*
|
|
7946
8038
|
* @param tenantData - Updated tenant data
|
|
7947
|
-
* @returns Promise resolving to updated tenant
|
|
8039
|
+
* @returns Promise resolving to full updated tenant (includes sensitive config)
|
|
7948
8040
|
*/
|
|
7949
8041
|
async updateTenant(tenantData) {
|
|
7950
8042
|
return this.tenantService.updateRemoteTenant(tenantData);
|
|
@@ -41600,22 +41692,27 @@ const useRedemptions = () => {
|
|
|
41600
41692
|
}
|
|
41601
41693
|
}, [sdk, isInitialized]);
|
|
41602
41694
|
/**
|
|
41603
|
-
* Get user's redemption history with optional include relations
|
|
41695
|
+
* Get user's redemption history with optional pagination and include relations
|
|
41604
41696
|
*
|
|
41697
|
+
* @param options - Pagination options (page, limit, sortBy, sortOrder)
|
|
41605
41698
|
* @param include - Relations to include: 'redemption', 'user', 'business'
|
|
41606
41699
|
* @returns Promise resolving to paginated redemption history
|
|
41607
41700
|
*
|
|
41608
41701
|
* @example
|
|
41609
41702
|
* ```typescript
|
|
41703
|
+
* // Get first page of user redemptions
|
|
41704
|
+
* const { data: redeems, pagination } = await getUserRedemptions({ page: 1, limit: 10 });
|
|
41705
|
+
* console.log(`Page ${pagination.page} of ${pagination.pages}`);
|
|
41706
|
+
*
|
|
41610
41707
|
* // Get user redemptions with full redemption details
|
|
41611
|
-
* const { data: redeems } = await getUserRedemptions(['redemption', 'business']);
|
|
41708
|
+
* const { data: redeems } = await getUserRedemptions({}, ['redemption', 'business']);
|
|
41612
41709
|
* redeems.forEach(redeem => {
|
|
41613
41710
|
* console.log('Redemption:', redeem.included?.redemption?.title);
|
|
41614
41711
|
* console.log('Business:', redeem.included?.business?.displayName);
|
|
41615
41712
|
* });
|
|
41616
41713
|
* ```
|
|
41617
41714
|
*/
|
|
41618
|
-
const getUserRedemptions = react.useCallback(async (include) => {
|
|
41715
|
+
const getUserRedemptions = react.useCallback(async (options, include) => {
|
|
41619
41716
|
if (!isInitialized || !sdk) {
|
|
41620
41717
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
41621
41718
|
}
|
|
@@ -41624,7 +41721,7 @@ const useRedemptions = () => {
|
|
|
41624
41721
|
return { data: [], pagination: { page: 1, limit: 0, total: 0, pages: 0, hasNext: false, hasPrev: false } };
|
|
41625
41722
|
}
|
|
41626
41723
|
try {
|
|
41627
|
-
const result = await sdk.redemptions.getUserRedemptions(
|
|
41724
|
+
const result = await sdk.redemptions.getUserRedemptions(options, include);
|
|
41628
41725
|
return result;
|
|
41629
41726
|
}
|
|
41630
41727
|
catch (error) {
|