@tramvai/module-page-render-mode 2.85.1 → 2.89.2

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.
@@ -29,8 +29,8 @@ export declare class StaticPagesService {
29
29
  private backgroundFetchService;
30
30
  private options;
31
31
  private cache5xxResponse;
32
- shouldUseCache: ShouldUseCache;
33
- shouldSetToCache: ShouldSetToCache;
32
+ shouldUseCache: () => boolean;
33
+ shouldSetToCache: () => boolean;
34
34
  constructor({ getCacheKey, requestManager, response, responseManager, environmentManager, userAgent, modern, logger, cache, modifyCache, shouldUseCache, shouldSetToCache, backgroundFetchService, options, cache5xxResponse, }: {
35
35
  getCacheKey: ExtractDependencyType<typeof STATIC_PAGES_GET_CACHE_KEY_TOKEN>;
36
36
  requestManager: ExtractDependencyType<typeof REQUEST_MANAGER_TOKEN>;
@@ -10,14 +10,18 @@ class StaticPagesService {
10
10
  this.response = response;
11
11
  this.cache = cache;
12
12
  this.modifyCache = modifyCache;
13
- this.shouldUseCache = shouldUseCache;
14
- this.shouldSetToCache = shouldSetToCache;
13
+ this.shouldUseCache = () => shouldUseCache.every((fn) => fn());
14
+ this.shouldSetToCache = () => shouldSetToCache.every((fn) => fn());
15
15
  this.backgroundFetchService = backgroundFetchService;
16
16
  this.options = options;
17
17
  this.cache5xxResponse = cache5xxResponse;
18
18
  }
19
19
  respond(onSuccess) {
20
20
  if (!this.hasCache()) {
21
+ this.log.debug({
22
+ event: 'no-cache',
23
+ key: this.key,
24
+ });
21
25
  return;
22
26
  }
23
27
  const { ttl } = this.options;
@@ -14,14 +14,18 @@ class StaticPagesService {
14
14
  this.response = response;
15
15
  this.cache = cache;
16
16
  this.modifyCache = modifyCache;
17
- this.shouldUseCache = shouldUseCache;
18
- this.shouldSetToCache = shouldSetToCache;
17
+ this.shouldUseCache = () => shouldUseCache.every((fn) => fn());
18
+ this.shouldSetToCache = () => shouldSetToCache.every((fn) => fn());
19
19
  this.backgroundFetchService = backgroundFetchService;
20
20
  this.options = options;
21
21
  this.cache5xxResponse = cache5xxResponse;
22
22
  }
23
23
  respond(onSuccess) {
24
24
  if (!this.hasCache()) {
25
+ this.log.debug({
26
+ event: 'no-cache',
27
+ key: this.key,
28
+ });
25
29
  return;
26
30
  }
27
31
  const { ttl } = this.options;
@@ -137,10 +137,10 @@ export declare const staticPagesProviders: (import("@tinkoff/dippy/lib/Provider"
137
137
  optional: boolean;
138
138
  };
139
139
  shouldUseCache: (() => boolean) & {
140
- __type?: "base token";
140
+ __type?: "multi token";
141
141
  };
142
142
  shouldSetToCache: (() => boolean) & {
143
- __type?: "base token";
143
+ __type?: "multi token";
144
144
  };
145
145
  backgroundFetchService: BackgroundFetchService & {
146
146
  __type?: "base token";
@@ -191,10 +191,10 @@ export declare const staticPagesProviders: (import("@tinkoff/dippy/lib/Provider"
191
191
  optional: boolean;
192
192
  };
193
193
  shouldUseCache: (() => boolean) & {
194
- __type?: "base token";
194
+ __type?: "multi token";
195
195
  };
196
196
  shouldSetToCache: (() => boolean) & {
197
- __type?: "base token";
197
+ __type?: "multi token";
198
198
  };
199
199
  backgroundFetchService: BackgroundFetchService & {
200
200
  __type?: "base token";
@@ -50,8 +50,9 @@ const staticPagesProviders = [
50
50
  provide({
51
51
  provide: STATIC_PAGES_OPTIONS_TOKEN,
52
52
  useValue: {
53
- // @TODO: свой ttl для отдельных страниц
53
+ // @TODO: unique ttl per pages
54
54
  ttl: 60 * 1000,
55
+ // @TODO: too much, better save to file-system
55
56
  maxSize: 1000,
56
57
  },
57
58
  }),
@@ -58,8 +58,9 @@ const staticPagesProviders = [
58
58
  core.provide({
59
59
  provide: tokens.STATIC_PAGES_OPTIONS_TOKEN,
60
60
  useValue: {
61
- // @TODO: свой ttl для отдельных страниц
61
+ // @TODO: unique ttl per pages
62
62
  ttl: 60 * 1000,
63
+ // @TODO: too much, better save to file-system
63
64
  maxSize: 1000,
64
65
  },
65
66
  }),
@@ -8,8 +8,8 @@ const PAGE_RENDER_DEFAULT_MODE = createToken('pageRenderDefaultMode');
8
8
  const PAGE_RENDER_WRAPPER_TYPE = createToken('pageRenderWrapperType');
9
9
  const PAGE_RENDER_DEFAULT_FALLBACK_COMPONENT = createToken('pageRenderDefaultFallbackComponent');
10
10
  const STATIC_PAGES_CACHE_TOKEN = createToken('static pages cache');
11
- const STATIC_PAGES_SHOULD_USE_CACHE = createToken('static pages should use cache');
12
- const STATIC_PAGES_SHOULD_SET_TO_CACHE = createToken('static pages should set to cache');
11
+ const STATIC_PAGES_SHOULD_USE_CACHE = createToken('static pages should use cache', { multi: true });
12
+ const STATIC_PAGES_SHOULD_SET_TO_CACHE = createToken('static pages should set to cache', { multi: true });
13
13
  const STATIC_PAGES_BACKGROUND_FETCH_ENABLED = createToken('static pages can fetch page');
14
14
  const STATIC_PAGES_OPTIONS_TOKEN = createToken('static pages options');
15
15
  const STATIC_PAGES_COMMAND_LINE = createToken('static pages command line');
package/lib/tokens.d.ts CHANGED
@@ -46,10 +46,10 @@ export declare const STATIC_PAGES_CACHE_TOKEN: Cache<Map<string, StaticPagesCach
46
46
  __type?: "base token";
47
47
  };
48
48
  export declare const STATIC_PAGES_SHOULD_USE_CACHE: (() => boolean) & {
49
- __type?: "base token";
49
+ __type?: "multi token";
50
50
  };
51
51
  export declare const STATIC_PAGES_SHOULD_SET_TO_CACHE: (() => boolean) & {
52
- __type?: "base token";
52
+ __type?: "multi token";
53
53
  };
54
54
  export declare const STATIC_PAGES_BACKGROUND_FETCH_ENABLED: (() => boolean) & {
55
55
  __type?: "base token";
package/lib/tokens.es.js CHANGED
@@ -8,8 +8,8 @@ const PAGE_RENDER_DEFAULT_MODE = createToken('pageRenderDefaultMode');
8
8
  const PAGE_RENDER_WRAPPER_TYPE = createToken('pageRenderWrapperType');
9
9
  const PAGE_RENDER_DEFAULT_FALLBACK_COMPONENT = createToken('pageRenderDefaultFallbackComponent');
10
10
  const STATIC_PAGES_CACHE_TOKEN = createToken('static pages cache');
11
- const STATIC_PAGES_SHOULD_USE_CACHE = createToken('static pages should use cache');
12
- const STATIC_PAGES_SHOULD_SET_TO_CACHE = createToken('static pages should set to cache');
11
+ const STATIC_PAGES_SHOULD_USE_CACHE = createToken('static pages should use cache', { multi: true });
12
+ const STATIC_PAGES_SHOULD_SET_TO_CACHE = createToken('static pages should set to cache', { multi: true });
13
13
  const STATIC_PAGES_BACKGROUND_FETCH_ENABLED = createToken('static pages can fetch page');
14
14
  const STATIC_PAGES_OPTIONS_TOKEN = createToken('static pages options');
15
15
  const STATIC_PAGES_COMMAND_LINE = createToken('static pages command line');
package/lib/tokens.js CHANGED
@@ -12,8 +12,8 @@ const PAGE_RENDER_DEFAULT_MODE = dippy.createToken('pageRenderDefaultMode');
12
12
  const PAGE_RENDER_WRAPPER_TYPE = dippy.createToken('pageRenderWrapperType');
13
13
  const PAGE_RENDER_DEFAULT_FALLBACK_COMPONENT = dippy.createToken('pageRenderDefaultFallbackComponent');
14
14
  const STATIC_PAGES_CACHE_TOKEN = dippy.createToken('static pages cache');
15
- const STATIC_PAGES_SHOULD_USE_CACHE = dippy.createToken('static pages should use cache');
16
- const STATIC_PAGES_SHOULD_SET_TO_CACHE = dippy.createToken('static pages should set to cache');
15
+ const STATIC_PAGES_SHOULD_USE_CACHE = dippy.createToken('static pages should use cache', { multi: true });
16
+ const STATIC_PAGES_SHOULD_SET_TO_CACHE = dippy.createToken('static pages should set to cache', { multi: true });
17
17
  const STATIC_PAGES_BACKGROUND_FETCH_ENABLED = dippy.createToken('static pages can fetch page');
18
18
  const STATIC_PAGES_OPTIONS_TOKEN = dippy.createToken('static pages options');
19
19
  const STATIC_PAGES_COMMAND_LINE = dippy.createToken('static pages command line');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-page-render-mode",
3
- "version": "2.85.1",
3
+ "version": "2.89.2",
4
4
  "description": "Enable different rendering modes for pages",
5
5
  "main": "./lib/server.js",
6
6
  "module": "./lib/server.es.js",
@@ -30,18 +30,18 @@
30
30
  "peerDependencies": {
31
31
  "@tinkoff/utils": "^2.1.2",
32
32
  "@tinkoff/dippy": "0.8.15",
33
- "@tramvai/core": "2.85.1",
34
- "@tramvai/react": "2.85.1",
35
- "@tramvai/papi": "2.85.1",
36
- "@tramvai/module-router": "2.85.1",
37
- "@tramvai/module-client-hints": "2.85.1",
38
- "@tramvai/tokens-common": "2.85.1",
39
- "@tramvai/tokens-core": "2.85.1",
40
- "@tramvai/tokens-render": "2.85.1",
41
- "@tramvai/tokens-router": "2.85.1",
42
- "@tramvai/tokens-server": "2.85.1",
43
- "@tramvai/tokens-server-private": "2.85.1",
44
- "@tramvai/tokens-metrics": "2.85.1",
33
+ "@tramvai/core": "2.89.2",
34
+ "@tramvai/react": "2.89.2",
35
+ "@tramvai/papi": "2.89.2",
36
+ "@tramvai/module-router": "2.89.2",
37
+ "@tramvai/module-client-hints": "2.89.2",
38
+ "@tramvai/tokens-common": "2.89.2",
39
+ "@tramvai/tokens-core": "2.89.2",
40
+ "@tramvai/tokens-render": "2.89.2",
41
+ "@tramvai/tokens-router": "2.89.2",
42
+ "@tramvai/tokens-server": "2.89.2",
43
+ "@tramvai/tokens-server-private": "2.89.2",
44
+ "@tramvai/tokens-metrics": "2.89.2",
45
45
  "prom-client": "^12.0.0",
46
46
  "react": ">=16.14.0",
47
47
  "tslib": "^2.4.0"