ti2 1.0.122 → 1.0.124
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/README.md +29 -1
- package/__tests__/plugin-capabilities.js +42 -0
- package/api.yml +76 -13
- package/controllers/README.md +24 -34
- package/controllers/__tests__/bookings-searchProducts.js +408 -232
- package/controllers/__tests__/product-search-ttr.js +39 -0
- package/controllers/__tests__/user.js +5 -1
- package/controllers/app.js +1 -1
- package/controllers/bookings.js +294 -152
- package/controllers/user.js +1 -0
- package/index.js +11 -1
- package/package.json +1 -1
- package/worker/__tests__/job-api.js +55 -3
- package/worker/__tests__/job-plugin.js +3 -3
- package/worker/index.js +16 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const bookings = require('../bookings');
|
|
2
|
+
|
|
3
|
+
describe('resolveProductSearchTtrSeconds', () => {
|
|
4
|
+
const oneDay = bookings.oneDayProductSearchTtrSeconds;
|
|
5
|
+
const weekly = bookings.defaultProductSearchTtrSeconds;
|
|
6
|
+
|
|
7
|
+
it('uses a seven-day default when no TTR is configured', () => {
|
|
8
|
+
expect(bookings.resolveProductSearchTtrSeconds({}, {})).toBe(weekly);
|
|
9
|
+
expect(weekly).toBe(oneDay * 7);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('keeps an explicit one-day token TTR', () => {
|
|
13
|
+
expect(bookings.resolveProductSearchTtrSeconds({
|
|
14
|
+
ttlForProducts: oneDay,
|
|
15
|
+
}, {})).toBe(oneDay);
|
|
16
|
+
expect(bookings.resolveProductSearchTtrSeconds({
|
|
17
|
+
ttlForProducts: String(oneDay),
|
|
18
|
+
}, {})).toBe(String(oneDay));
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('keeps an explicit non-legacy TTR, including short test values', () => {
|
|
22
|
+
expect(bookings.resolveProductSearchTtrSeconds({
|
|
23
|
+
ttlForProducts: 2,
|
|
24
|
+
}, {})).toBe(2);
|
|
25
|
+
expect(bookings.resolveProductSearchTtrSeconds({
|
|
26
|
+
ttlForProducts: oneDay * 2,
|
|
27
|
+
}, {})).toBe(oneDay * 2);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('keeps an explicit one-day plugin cacheSettings TTR', () => {
|
|
31
|
+
expect(bookings.resolveProductSearchTtrSeconds({}, {
|
|
32
|
+
cacheSettings: {
|
|
33
|
+
bookingsProductSearch: {
|
|
34
|
+
ttr: oneDay,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
})).toBe(oneDay);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -40,6 +40,9 @@ describe('user', () => {
|
|
|
40
40
|
plugins,
|
|
41
41
|
} = await testUtils({
|
|
42
42
|
plugins: [appName],
|
|
43
|
+
pluginCapabilities: {
|
|
44
|
+
[appName]: { weeklyProductCatalogSync: true },
|
|
45
|
+
},
|
|
43
46
|
}));
|
|
44
47
|
await db.models.UserAppKey.destroy({ where: { userId } });
|
|
45
48
|
// create an App
|
|
@@ -353,10 +356,11 @@ describe('user', () => {
|
|
|
353
356
|
expect(returnValue.success).toBe(true);
|
|
354
357
|
});
|
|
355
358
|
it('should be able to get all the methods for an app', async () => {
|
|
356
|
-
const { methods } = await doApiGet({
|
|
359
|
+
const { capabilities, methods } = await doApiGet({
|
|
357
360
|
url: `/app/${appName}/methods`,
|
|
358
361
|
token: userKey,
|
|
359
362
|
});
|
|
363
|
+
expect(capabilities).toEqual({ weeklyProductCatalogSync: true });
|
|
360
364
|
expect(methods).toEqual(
|
|
361
365
|
expect.arrayContaining([
|
|
362
366
|
'validateToken', 'getProduct',
|
package/controllers/app.js
CHANGED
|
@@ -70,7 +70,7 @@ const tokenTemplate = async (req, res, next) => {
|
|
|
70
70
|
ttlForProducts: {
|
|
71
71
|
type: 'number',
|
|
72
72
|
regExp: /.+/,
|
|
73
|
-
default: 60 * 60 * 24, //
|
|
73
|
+
default: 60 * 60 * 24 * 7, // 7 days; weekly full product catalog refresh
|
|
74
74
|
},
|
|
75
75
|
doNotCallPluginForProducts: {
|
|
76
76
|
type: 'boolean',
|