sahab-utils 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ts/loyalty.d.ts +11 -0
- package/dist/ts/loyalty.js +17 -0
- package/package.json +1 -1
package/dist/ts/loyalty.d.ts
CHANGED
|
@@ -7,6 +7,17 @@ import { Discount, Gift, LoyaltyProgress, Order } from '../constants/types';
|
|
|
7
7
|
* offer that spends other providers' money.
|
|
8
8
|
*/
|
|
9
9
|
export declare function loyaltyProviderScope(offer?: Discount): string[] | null;
|
|
10
|
+
/**
|
|
11
|
+
* Whether an offer is a provider's own programme.
|
|
12
|
+
*
|
|
13
|
+
* `createdByProvider` is the discriminator, not the shape of the scope: a Sahab offer restricted
|
|
14
|
+
* to a handful of carwashes still belongs to Sahab, and a provider's offer is always pinned to
|
|
15
|
+
* itself. Reading `loyalty.providerUids` to tell them apart is what made every provider
|
|
16
|
+
* programme label itself "at any carwash".
|
|
17
|
+
*/
|
|
18
|
+
export declare function isProviderLoyaltyOffer(offer?: Discount): boolean;
|
|
19
|
+
/** Whether an offer is one Sahab runs and funds. */
|
|
20
|
+
export declare function isSahabLoyaltyOffer(offer?: Discount): boolean;
|
|
10
21
|
/** Whether an offer's provider scope admits a given provider. */
|
|
11
22
|
export declare function loyaltyCoversProvider(offer: Discount | undefined, providerUid?: string): boolean;
|
|
12
23
|
/**
|
package/dist/ts/loyalty.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loyaltyProviderScope = loyaltyProviderScope;
|
|
4
|
+
exports.isProviderLoyaltyOffer = isProviderLoyaltyOffer;
|
|
5
|
+
exports.isSahabLoyaltyOffer = isSahabLoyaltyOffer;
|
|
4
6
|
exports.loyaltyCoversProvider = loyaltyCoversProvider;
|
|
5
7
|
exports.orderEarnsLoyaltyStamp = orderEarnsLoyaltyStamp;
|
|
6
8
|
exports.giftEarnsLoyaltyStamp = giftEarnsLoyaltyStamp;
|
|
@@ -43,6 +45,21 @@ function loyaltyProviderScope(offer) {
|
|
|
43
45
|
const scope = offer.loyalty.providerUids;
|
|
44
46
|
return scope && scope.length ? scope : null;
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether an offer is a provider's own programme.
|
|
50
|
+
*
|
|
51
|
+
* `createdByProvider` is the discriminator, not the shape of the scope: a Sahab offer restricted
|
|
52
|
+
* to a handful of carwashes still belongs to Sahab, and a provider's offer is always pinned to
|
|
53
|
+
* itself. Reading `loyalty.providerUids` to tell them apart is what made every provider
|
|
54
|
+
* programme label itself "at any carwash".
|
|
55
|
+
*/
|
|
56
|
+
function isProviderLoyaltyOffer(offer) {
|
|
57
|
+
return !!(offer === null || offer === void 0 ? void 0 : offer.loyalty) && offer.createdByProvider === true;
|
|
58
|
+
}
|
|
59
|
+
/** Whether an offer is one Sahab runs and funds. */
|
|
60
|
+
function isSahabLoyaltyOffer(offer) {
|
|
61
|
+
return !!(offer === null || offer === void 0 ? void 0 : offer.loyalty) && offer.createdByProvider !== true;
|
|
62
|
+
}
|
|
46
63
|
/** Whether an offer's provider scope admits a given provider. */
|
|
47
64
|
function loyaltyCoversProvider(offer, providerUid) {
|
|
48
65
|
const scope = loyaltyProviderScope(offer);
|