ti2 1.0.68 → 1.0.70
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/cache.js +7 -3
- package/controllers/bookings.js +1 -0
- package/controllers/graphql-schemas/availability.js +2 -2
- package/index.js +3 -3
- package/package.json +1 -1
package/cache.js
CHANGED
|
@@ -42,6 +42,7 @@ const getOrExec = async ({
|
|
|
42
42
|
ttl,
|
|
43
43
|
fn,
|
|
44
44
|
fnParams,
|
|
45
|
+
forceRefresh,
|
|
45
46
|
}) => {
|
|
46
47
|
const key = (() => {
|
|
47
48
|
if (!keyParam) {
|
|
@@ -52,8 +53,11 @@ const getOrExec = async ({
|
|
|
52
53
|
}
|
|
53
54
|
return keyParam;
|
|
54
55
|
})();
|
|
55
|
-
let value
|
|
56
|
-
if (
|
|
56
|
+
let value;
|
|
57
|
+
if (!forceRefresh) {
|
|
58
|
+
value = await get({ pluginName, key });
|
|
59
|
+
if (value !== null) return value;
|
|
60
|
+
}
|
|
57
61
|
value = await fn(...fnParams);
|
|
58
62
|
await save({
|
|
59
63
|
pluginName,
|
|
@@ -70,7 +74,7 @@ const drop = async ({
|
|
|
70
74
|
fn,
|
|
71
75
|
fnParams,
|
|
72
76
|
}) => {
|
|
73
|
-
|
|
77
|
+
let key = `${pluginName}:${(() => {
|
|
74
78
|
if (!keyParam) {
|
|
75
79
|
return hash({ fn, fnParams });
|
|
76
80
|
}
|
package/controllers/bookings.js
CHANGED
|
@@ -179,6 +179,7 @@ const $bookingsAvailabilityCalendar = plugins => async ({
|
|
|
179
179
|
},
|
|
180
180
|
}));
|
|
181
181
|
assert(userAppKeys, 'could not find the app key');
|
|
182
|
+
assert(app.availabilityCalendar, `availabilityCalendar is not available for ${appKey}`);
|
|
182
183
|
const token = await userAppKeys.token;
|
|
183
184
|
return app.availabilityCalendar({
|
|
184
185
|
axios,
|
|
@@ -38,7 +38,7 @@ const typeDefs = `
|
|
|
38
38
|
available: Boolean
|
|
39
39
|
pricing: Pricing
|
|
40
40
|
unitPricing: [Pricing]
|
|
41
|
-
|
|
41
|
+
offers: [Offer]
|
|
42
42
|
pickupAvailable: Boolean
|
|
43
43
|
pickupRequired: Boolean
|
|
44
44
|
pickupPoints: [PickupPoint]
|
|
@@ -74,7 +74,7 @@ const query = `query getAvailability ($productId: ID, $optionId: ID, $currency:
|
|
|
74
74
|
unitPricing {
|
|
75
75
|
...pricingFields
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
offers {
|
|
78
78
|
offerId
|
|
79
79
|
title
|
|
80
80
|
description
|
package/index.js
CHANGED
|
@@ -80,10 +80,10 @@ module.exports = async ({
|
|
|
80
80
|
});
|
|
81
81
|
const pluginInstance = await new Plugin({
|
|
82
82
|
cache: {
|
|
83
|
-
drop: args => cache.
|
|
84
|
-
get: args => cache.
|
|
83
|
+
drop: args => cache.drop({ ...args, pluginName }),
|
|
84
|
+
get: args => cache.get({ ...args, pluginName }),
|
|
85
85
|
getOrExec: args => cache.getOrExec({ ...args, pluginName }),
|
|
86
|
-
save: args => cache.
|
|
86
|
+
save: args => cache.save({ ...args, pluginName }),
|
|
87
87
|
},
|
|
88
88
|
events: ti2Events,
|
|
89
89
|
name: pluginName,
|