ti2 1.0.78 → 1.0.80

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 CHANGED
@@ -9,6 +9,7 @@ const save = async ({
9
9
  pluginName,
10
10
  key: keyParam,
11
11
  value,
12
+ skipTTL,
12
13
  ttl = defaultTTL,
13
14
  }) => {
14
15
  const key = `${pluginName}:${(() => {
@@ -18,7 +19,9 @@ const save = async ({
18
19
  return keyParam;
19
20
  })()}`;
20
21
  await cache.set(key, JSON.stringify(value));
21
- await cache.expire(key, ttl);
22
+ if (!skipTTL) {
23
+ await cache.expire(key, ttl);
24
+ }
22
25
  };
23
26
 
24
27
  const get = async ({
@@ -37,6 +37,7 @@ const bookingsSearch = plugins => async (req, res, next) => {
37
37
  });
38
38
  assert(userAppKeys, 'could not find the app key');
39
39
  const token = await userAppKeys.token;
40
+ assert(app.searchHotelBooking || app.searchBooking, `searchHotelBooking or searchBooking is not available for ${appKey}`);
40
41
  const search = (app.searchHotelBooking || app.searchBooking).bind(app);
41
42
  const results = await search({
42
43
  axios,
@@ -6,9 +6,12 @@ const { UserAppKey } = require('../models');
6
6
  const userAppList = async (req, res, next) => {
7
7
  const { params: { userId } } = req;
8
8
  try {
9
- const userAppKeys = (await UserAppKey.findAll({ where: { userId } }))
10
- .map(userAppKey => userAppKey.dataValues);
11
- return res.json({ userAppKeys: userAppKeys.map(userAppKey => omit(['appKey', 'id'], userAppKey)) });
9
+ const userAppKeys = await UserAppKey.findAll({
10
+ where: { userId },
11
+ raw: true,
12
+ attributes: ['integrationId', 'userId', 'hint', 'createdAt', 'updatedAt'],
13
+ })
14
+ return res.json({ userAppKeys });
12
15
  } catch (err) {
13
16
  return next(err);
14
17
  }
package/index.js CHANGED
@@ -23,8 +23,6 @@ const cacheSettings = {
23
23
  'bookingsProductSearch',
24
24
  'getCreateBookingFields',
25
25
  ],
26
- ventrata: [],
27
- fareharbor: [],
28
26
  };
29
27
  const ti2Events = new EventEmitter({ captureRejections: true, wildcard: true });
30
28
  ti2Events.on('event error', console.error);
@@ -265,9 +263,10 @@ module.exports = async ({
265
263
  const currentPlugin = req.pathParams
266
264
  ? plugins.find(p => p.name === req.pathParams.appKey)
267
265
  : null;
266
+ const pluginCacheSettings = R.pathOr({}, ['cacheSettings'], currentPlugin);
268
267
  const cachingOperations = [
269
268
  ...cacheSettings['*'],
270
- ...(currentPlugin ? R.pathOr([], [currentPlugin.name], cacheSettings) : []),
269
+ ...(currentPlugin ? R.keys(pluginCacheSettings) : []),
271
270
  ];
272
271
  const body = req.customBody;
273
272
  if (cachingOperations.indexOf(body.operationId) > -1) {
@@ -288,6 +287,7 @@ module.exports = async ({
288
287
  pluginName: req.pathParams.appKey,
289
288
  key: cacheKey,
290
289
  value: newData,
290
+ skipTTL: R.path([body.operationId, 'skipTTL'], pluginCacheSettings),
291
291
  ttl: 60 * 60 * 24, // one day
292
292
  });
293
293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.78",
3
+ "version": "1.0.80",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {