@prezly/theme-kit-core 10.9.3 → 10.10.1
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/build/content-delivery/ContentDelivery.cjs +43 -8
- package/build/content-delivery/ContentDelivery.d.ts +12 -0
- package/build/content-delivery/ContentDelivery.mjs +42 -7
- package/build/content-delivery/ContentDelivery.test.cjs +369 -5
- package/build/content-delivery/ContentDelivery.test.mjs +371 -7
- package/build/content-delivery/cache/memory.cjs +8 -4
- package/build/content-delivery/cache/memory.mjs +8 -4
- package/build/content-delivery/cache/memory.test.cjs +30 -0
- package/build/content-delivery/cache/memory.test.mjs +30 -0
- package/build/content-delivery/cache/stacked.cjs +2 -2
- package/build/content-delivery/cache/stacked.mjs +2 -2
- package/build/content-delivery/cache/type.d.ts +13 -1
- package/build/content-delivery/telemetry.test.cjs +27 -19
- package/build/content-delivery/telemetry.test.mjs +27 -19
- package/package.json +3 -8
|
@@ -57,8 +57,24 @@ it('counts concurrent callers once each, one origin, and a later valid memory hi
|
|
|
57
57
|
})]);
|
|
58
58
|
expect(JSON.stringify(events)).not.toMatch(/private-|payload|token|cacheKey/);
|
|
59
59
|
}));
|
|
60
|
-
it('
|
|
61
|
-
|
|
60
|
+
it.each([['a mismatched scope', {
|
|
61
|
+
scope: 'another-secret',
|
|
62
|
+
value: {
|
|
63
|
+
name: 'room'
|
|
64
|
+
}
|
|
65
|
+
}, false], ['a legacy null without a deadline', {
|
|
66
|
+
scope: 'scope',
|
|
67
|
+
value: null
|
|
68
|
+
}, false], ['an expired null', {
|
|
69
|
+
scope: 'scope',
|
|
70
|
+
value: null,
|
|
71
|
+
expires: 1
|
|
72
|
+
}, false], ['a fresh null', {
|
|
73
|
+
scope: 'scope',
|
|
74
|
+
value: null,
|
|
75
|
+
expires: Date.now() / 1000 + 60
|
|
76
|
+
}, true]])('reports %s as a cache hit: %p', /*#__PURE__*/function () {
|
|
77
|
+
var _ref3 = _asyncToGenerator(function* (_label, value, hit) {
|
|
62
78
|
var events = [];
|
|
63
79
|
var storage = {
|
|
64
80
|
get: (_key, _version, source) => {
|
|
@@ -83,21 +99,13 @@ it('does not call a mismatched scope or a stored null a cache hit', /*#__PURE__*
|
|
|
83
99
|
}
|
|
84
100
|
}).newsroom();
|
|
85
101
|
yield tick();
|
|
86
|
-
expect(events.some(e => e.type === 'cache_hit')).toBe(
|
|
87
|
-
expect(events.filter(e => e.type === 'cache_miss')).toHaveLength(1);
|
|
102
|
+
expect(events.some(e => e.type === 'cache_hit')).toBe(hit);
|
|
103
|
+
expect(events.filter(e => e.type === 'cache_miss')).toHaveLength(hit ? 0 : 1);
|
|
104
|
+
});
|
|
105
|
+
return function (_x, _x2, _x3) {
|
|
106
|
+
return _ref3.apply(this, arguments);
|
|
88
107
|
};
|
|
89
|
-
|
|
90
|
-
scope: 'another-secret',
|
|
91
|
-
value: {
|
|
92
|
-
name: 'room'
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
scope: 'scope',
|
|
96
|
-
value: null
|
|
97
|
-
}]) {
|
|
98
|
-
yield* _loop(value);
|
|
99
|
-
}
|
|
100
|
-
}));
|
|
108
|
+
}());
|
|
101
109
|
it('attributes a valid lower-layer hit after version and scope validation', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
102
110
|
var events = [];
|
|
103
111
|
var empty = {
|
|
@@ -196,7 +204,7 @@ it.each(['sync', 'async'])('a failing %s observer cannot change results or poiso
|
|
|
196
204
|
});
|
|
197
205
|
yield tick();
|
|
198
206
|
});
|
|
199
|
-
return function (
|
|
207
|
+
return function (_x4) {
|
|
200
208
|
return _ref6.apply(this, arguments);
|
|
201
209
|
};
|
|
202
210
|
}());
|
|
@@ -317,7 +325,7 @@ it('attributes a legacy fallback to custom when an earlier layer returns undefin
|
|
|
317
325
|
return this;
|
|
318
326
|
}
|
|
319
327
|
};
|
|
320
|
-
var
|
|
328
|
+
var _loop = function* _loop() {
|
|
321
329
|
var events = [];
|
|
322
330
|
var origin = sdk();
|
|
323
331
|
var client = (0, _ContentDelivery.createClient)(origin, "fallback-".concat(sequence++), undefined, {
|
|
@@ -341,6 +349,6 @@ it('attributes a legacy fallback to custom when an earlier layer returns undefin
|
|
|
341
349
|
})]);
|
|
342
350
|
};
|
|
343
351
|
for (var first of [emptyMemory, announcingMiss]) {
|
|
344
|
-
yield*
|
|
352
|
+
yield* _loop();
|
|
345
353
|
}
|
|
346
354
|
}));
|
|
@@ -55,8 +55,24 @@ it('counts concurrent callers once each, one origin, and a later valid memory hi
|
|
|
55
55
|
})]);
|
|
56
56
|
expect(JSON.stringify(events)).not.toMatch(/private-|payload|token|cacheKey/);
|
|
57
57
|
}));
|
|
58
|
-
it('
|
|
59
|
-
|
|
58
|
+
it.each([['a mismatched scope', {
|
|
59
|
+
scope: 'another-secret',
|
|
60
|
+
value: {
|
|
61
|
+
name: 'room'
|
|
62
|
+
}
|
|
63
|
+
}, false], ['a legacy null without a deadline', {
|
|
64
|
+
scope: 'scope',
|
|
65
|
+
value: null
|
|
66
|
+
}, false], ['an expired null', {
|
|
67
|
+
scope: 'scope',
|
|
68
|
+
value: null,
|
|
69
|
+
expires: 1
|
|
70
|
+
}, false], ['a fresh null', {
|
|
71
|
+
scope: 'scope',
|
|
72
|
+
value: null,
|
|
73
|
+
expires: Date.now() / 1000 + 60
|
|
74
|
+
}, true]])('reports %s as a cache hit: %p', /*#__PURE__*/function () {
|
|
75
|
+
var _ref3 = _asyncToGenerator(function* (_label, value, hit) {
|
|
60
76
|
var events = [];
|
|
61
77
|
var storage = {
|
|
62
78
|
get: (_key, _version, source) => {
|
|
@@ -81,21 +97,13 @@ it('does not call a mismatched scope or a stored null a cache hit', /*#__PURE__*
|
|
|
81
97
|
}
|
|
82
98
|
}).newsroom();
|
|
83
99
|
yield tick();
|
|
84
|
-
expect(events.some(e => e.type === 'cache_hit')).toBe(
|
|
85
|
-
expect(events.filter(e => e.type === 'cache_miss')).toHaveLength(1);
|
|
100
|
+
expect(events.some(e => e.type === 'cache_hit')).toBe(hit);
|
|
101
|
+
expect(events.filter(e => e.type === 'cache_miss')).toHaveLength(hit ? 0 : 1);
|
|
102
|
+
});
|
|
103
|
+
return function (_x, _x2, _x3) {
|
|
104
|
+
return _ref3.apply(this, arguments);
|
|
86
105
|
};
|
|
87
|
-
|
|
88
|
-
scope: 'another-secret',
|
|
89
|
-
value: {
|
|
90
|
-
name: 'room'
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
scope: 'scope',
|
|
94
|
-
value: null
|
|
95
|
-
}]) {
|
|
96
|
-
yield* _loop(value);
|
|
97
|
-
}
|
|
98
|
-
}));
|
|
106
|
+
}());
|
|
99
107
|
it('attributes a valid lower-layer hit after version and scope validation', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
100
108
|
var events = [];
|
|
101
109
|
var empty = {
|
|
@@ -194,7 +202,7 @@ it.each(['sync', 'async'])('a failing %s observer cannot change results or poiso
|
|
|
194
202
|
});
|
|
195
203
|
yield tick();
|
|
196
204
|
});
|
|
197
|
-
return function (
|
|
205
|
+
return function (_x4) {
|
|
198
206
|
return _ref6.apply(this, arguments);
|
|
199
207
|
};
|
|
200
208
|
}());
|
|
@@ -315,7 +323,7 @@ it('attributes a legacy fallback to custom when an earlier layer returns undefin
|
|
|
315
323
|
return this;
|
|
316
324
|
}
|
|
317
325
|
};
|
|
318
|
-
var
|
|
326
|
+
var _loop = function* _loop() {
|
|
319
327
|
var events = [];
|
|
320
328
|
var origin = sdk();
|
|
321
329
|
var client = createClient(origin, "fallback-".concat(sequence++), undefined, {
|
|
@@ -339,6 +347,6 @@ it('attributes a legacy fallback to custom when an earlier layer returns undefin
|
|
|
339
347
|
})]);
|
|
340
348
|
};
|
|
341
349
|
for (var first of [emptyMemory, announcingMiss]) {
|
|
342
|
-
yield*
|
|
350
|
+
yield* _loop();
|
|
343
351
|
}
|
|
344
352
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-core",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.10.1",
|
|
4
4
|
"description": "Data layer and utility library for developing Prezly themes with JavaScript",
|
|
5
5
|
"main": "build/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"@prezly/sdk": "21.12.0 || ^23.x"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@prezly/theme-kit-intl": "^10.9.1",
|
|
24
23
|
"@prezly/uploadcare": "2.4.4",
|
|
25
24
|
"@technically/is-not-undefined": "^1.0.0",
|
|
26
25
|
"@technically/omit-undefined": "^1.0.4",
|
|
27
26
|
"parse-data-url": "^6.0.0",
|
|
28
|
-
"url-pattern": "^1.0.3"
|
|
27
|
+
"url-pattern": "^1.0.3",
|
|
28
|
+
"@prezly/theme-kit-intl": "^10.9.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/parse-data-url": "3.0.2"
|
|
@@ -34,10 +34,6 @@
|
|
|
34
34
|
"node": ">= 16.x",
|
|
35
35
|
"npm": ">= 8.x"
|
|
36
36
|
},
|
|
37
|
-
"devEngines": {
|
|
38
|
-
"node": ">= 16.x",
|
|
39
|
-
"npm": ">= 8.x"
|
|
40
|
-
},
|
|
41
37
|
"keywords": [
|
|
42
38
|
"prezly"
|
|
43
39
|
],
|
|
@@ -55,7 +51,6 @@
|
|
|
55
51
|
"publishConfig": {
|
|
56
52
|
"access": "public"
|
|
57
53
|
},
|
|
58
|
-
"gitHead": "31134742a0ff3f3e669283f94843c3222eac8ebd",
|
|
59
54
|
"scripts": {
|
|
60
55
|
"prebuild": "rimraf --glob build/* *.tsbuildinfo",
|
|
61
56
|
"build": "pnpm build:types && pnpm build:esm && pnpm build:cjs",
|