@prezly/theme-kit-core 10.9.3 → 10.10.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.
@@ -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('does not call a mismatched scope or a stored null a cache hit', /*#__PURE__*/_asyncToGenerator(function* () {
61
- var _loop = function* _loop(value) {
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(false);
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
- for (var value of [{
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 (_x) {
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 _loop2 = function* _loop2() {
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* _loop2();
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('does not call a mismatched scope or a stored null a cache hit', /*#__PURE__*/_asyncToGenerator(function* () {
59
- var _loop = function* _loop(value) {
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(false);
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
- for (var value of [{
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 (_x) {
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 _loop2 = function* _loop2() {
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* _loop2();
350
+ yield* _loop();
343
351
  }
344
352
  }));
package/package.json CHANGED
@@ -1,78 +1,74 @@
1
1
  {
2
- "name": "@prezly/theme-kit-core",
3
- "version": "10.9.3",
4
- "description": "Data layer and utility library for developing Prezly themes with JavaScript",
5
- "main": "build/index.mjs",
6
- "type": "module",
7
- "types": "build/index.d.ts",
8
- "files": [
9
- "build",
10
- "README.md"
11
- ],
12
- "exports": {
13
- ".": {
14
- "types": "./build/index.d.ts",
15
- "require": "./build/index.cjs",
16
- "default": "./build/index.mjs"
2
+ "name": "@prezly/theme-kit-core",
3
+ "version": "10.10.0",
4
+ "description": "Data layer and utility library for developing Prezly themes with JavaScript",
5
+ "main": "build/index.mjs",
6
+ "type": "module",
7
+ "types": "build/index.d.ts",
8
+ "files": [
9
+ "build",
10
+ "README.md"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./build/index.d.ts",
15
+ "require": "./build/index.cjs",
16
+ "default": "./build/index.mjs"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "prepack": "pnpm test:build",
21
+ "prebuild": "rimraf --glob build/* *.tsbuildinfo",
22
+ "build": "pnpm build:types && pnpm build:esm && pnpm build:cjs",
23
+ "build:types": "tsc --project .",
24
+ "build:esm": "babel --config-file=../../babel.esm.json src/ --extensions=.ts --out-dir=build/ --out-file-extension=.mjs",
25
+ "build:cjs": "babel --config-file=../../babel.cjs.json src/ --extensions=.ts --out-dir=build/ --out-file-extension=.cjs",
26
+ "dev": "tsc --watch --preserveWatchOutput --project .",
27
+ "typecheck": "tsc --noEmit --emitDeclarationOnly false --incremental --project .",
28
+ "lint": "biome lint src",
29
+ "lint:fix": "biome lint --write src",
30
+ "format": "biome format src",
31
+ "format:fix": "biome format --write src",
32
+ "test": "pnpm test:unit && pnpm test:build",
33
+ "test:unit": "jest",
34
+ "test:build": "pnpm test:build:cjs && pnpm test:build:esm && pnpm test:build:types",
35
+ "test:build:types": "tsc --esModuleInterop --noEmit --target esnext --moduleResolution node build/index.d.ts",
36
+ "test:build:esm": "node tests/test-build.mjs",
37
+ "test:build:cjs": "node tests/test-build.cjs"
38
+ },
39
+ "peerDependencies": {
40
+ "@prezly/sdk": "21.12.0 || ^23.x"
41
+ },
42
+ "dependencies": {
43
+ "@prezly/theme-kit-intl": "workspace:^",
44
+ "@prezly/uploadcare": "2.4.4",
45
+ "@technically/is-not-undefined": "^1.0.0",
46
+ "@technically/omit-undefined": "^1.0.4",
47
+ "parse-data-url": "^6.0.0",
48
+ "url-pattern": "^1.0.3"
49
+ },
50
+ "devDependencies": {
51
+ "@types/parse-data-url": "3.0.2"
52
+ },
53
+ "engines": {
54
+ "node": ">= 16.x",
55
+ "npm": ">= 8.x"
56
+ },
57
+ "keywords": [
58
+ "prezly"
59
+ ],
60
+ "author": "Prezly Team",
61
+ "license": "MIT",
62
+ "bugs": {
63
+ "url": "https://github.com/prezly/theme-kit-js/issues"
64
+ },
65
+ "homepage": "https://github.com/prezly/theme-kit-js/tree/main/packages/core#readme",
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/prezly/theme-kit-js.git",
69
+ "directory": "packages/core"
70
+ },
71
+ "publishConfig": {
72
+ "access": "public"
17
73
  }
18
- },
19
- "peerDependencies": {
20
- "@prezly/sdk": "21.12.0 || ^23.x"
21
- },
22
- "dependencies": {
23
- "@prezly/theme-kit-intl": "^10.9.1",
24
- "@prezly/uploadcare": "2.4.4",
25
- "@technically/is-not-undefined": "^1.0.0",
26
- "@technically/omit-undefined": "^1.0.4",
27
- "parse-data-url": "^6.0.0",
28
- "url-pattern": "^1.0.3"
29
- },
30
- "devDependencies": {
31
- "@types/parse-data-url": "3.0.2"
32
- },
33
- "engines": {
34
- "node": ">= 16.x",
35
- "npm": ">= 8.x"
36
- },
37
- "devEngines": {
38
- "node": ">= 16.x",
39
- "npm": ">= 8.x"
40
- },
41
- "keywords": [
42
- "prezly"
43
- ],
44
- "author": "Prezly Team",
45
- "license": "MIT",
46
- "bugs": {
47
- "url": "https://github.com/prezly/theme-kit-js/issues"
48
- },
49
- "homepage": "https://github.com/prezly/theme-kit-js/tree/main/packages/core#readme",
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/prezly/theme-kit-js.git",
53
- "directory": "packages/core"
54
- },
55
- "publishConfig": {
56
- "access": "public"
57
- },
58
- "gitHead": "31134742a0ff3f3e669283f94843c3222eac8ebd",
59
- "scripts": {
60
- "prebuild": "rimraf --glob build/* *.tsbuildinfo",
61
- "build": "pnpm build:types && pnpm build:esm && pnpm build:cjs",
62
- "build:types": "tsc --project .",
63
- "build:esm": "babel --config-file=../../babel.esm.json src/ --extensions=.ts --out-dir=build/ --out-file-extension=.mjs",
64
- "build:cjs": "babel --config-file=../../babel.cjs.json src/ --extensions=.ts --out-dir=build/ --out-file-extension=.cjs",
65
- "dev": "tsc --watch --preserveWatchOutput --project .",
66
- "typecheck": "tsc --noEmit --emitDeclarationOnly false --incremental --project .",
67
- "lint": "biome lint src",
68
- "lint:fix": "biome lint --write src",
69
- "format": "biome format src",
70
- "format:fix": "biome format --write src",
71
- "test": "pnpm test:unit && pnpm test:build",
72
- "test:unit": "jest",
73
- "test:build": "pnpm test:build:cjs && pnpm test:build:esm && pnpm test:build:types",
74
- "test:build:types": "tsc --esModuleInterop --noEmit --target esnext --moduleResolution node build/index.d.ts",
75
- "test:build:esm": "node tests/test-build.mjs",
76
- "test:build:cjs": "node tests/test-build.cjs"
77
- }
78
- }
74
+ }