@gooddata/sdk-backend-base 8.11.0-alpha.10 → 8.11.0-alpha.100

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.
Files changed (73) hide show
  1. package/README.md +6 -5
  2. package/dist/cachingBackend/index.d.ts +50 -17
  3. package/dist/cachingBackend/index.d.ts.map +1 -1
  4. package/dist/cachingBackend/index.js +127 -21
  5. package/dist/cachingBackend/index.js.map +1 -1
  6. package/dist/customBackend/execution.d.ts.map +1 -1
  7. package/dist/customBackend/execution.js +4 -1
  8. package/dist/customBackend/execution.js.map +1 -1
  9. package/dist/decoratedBackend/catalog.d.ts +1 -0
  10. package/dist/decoratedBackend/catalog.d.ts.map +1 -1
  11. package/dist/decoratedBackend/catalog.js +3 -0
  12. package/dist/decoratedBackend/catalog.js.map +1 -1
  13. package/dist/decoratedBackend/elements.d.ts +65 -0
  14. package/dist/decoratedBackend/elements.d.ts.map +1 -0
  15. package/dist/decoratedBackend/elements.js +101 -0
  16. package/dist/decoratedBackend/elements.js.map +1 -0
  17. package/dist/decoratedBackend/execution.d.ts +2 -2
  18. package/dist/decoratedBackend/execution.d.ts.map +1 -1
  19. package/dist/decoratedBackend/execution.js.map +1 -1
  20. package/dist/decoratedBackend/index.d.ts.map +1 -1
  21. package/dist/decoratedBackend/index.js +6 -0
  22. package/dist/decoratedBackend/index.js.map +1 -1
  23. package/dist/decoratedBackend/workspaceSettings.d.ts +1 -0
  24. package/dist/decoratedBackend/workspaceSettings.d.ts.map +1 -1
  25. package/dist/decoratedBackend/workspaceSettings.js +7 -0
  26. package/dist/decoratedBackend/workspaceSettings.js.map +1 -1
  27. package/dist/dummyBackend/index.d.ts.map +1 -1
  28. package/dist/dummyBackend/index.js +295 -5
  29. package/dist/dummyBackend/index.js.map +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +2 -2
  33. package/dist/index.js.map +1 -1
  34. package/dist/normalizingBackend/normalizer.d.ts.map +1 -1
  35. package/dist/normalizingBackend/normalizer.js +1 -1
  36. package/dist/normalizingBackend/normalizer.js.map +1 -1
  37. package/dist/sdk-backend-base.d.ts +58 -21
  38. package/esm/cachingBackend/index.d.ts +50 -17
  39. package/esm/cachingBackend/index.d.ts.map +1 -1
  40. package/esm/cachingBackend/index.js +127 -21
  41. package/esm/cachingBackend/index.js.map +1 -1
  42. package/esm/customBackend/execution.d.ts.map +1 -1
  43. package/esm/customBackend/execution.js +4 -1
  44. package/esm/customBackend/execution.js.map +1 -1
  45. package/esm/decoratedBackend/catalog.d.ts +1 -0
  46. package/esm/decoratedBackend/catalog.d.ts.map +1 -1
  47. package/esm/decoratedBackend/catalog.js +3 -0
  48. package/esm/decoratedBackend/catalog.js.map +1 -1
  49. package/esm/decoratedBackend/elements.d.ts +65 -0
  50. package/esm/decoratedBackend/elements.d.ts.map +1 -0
  51. package/esm/decoratedBackend/elements.js +98 -0
  52. package/esm/decoratedBackend/elements.js.map +1 -0
  53. package/esm/decoratedBackend/execution.d.ts +2 -2
  54. package/esm/decoratedBackend/execution.d.ts.map +1 -1
  55. package/esm/decoratedBackend/execution.js.map +1 -1
  56. package/esm/decoratedBackend/index.d.ts.map +1 -1
  57. package/esm/decoratedBackend/index.js +6 -0
  58. package/esm/decoratedBackend/index.js.map +1 -1
  59. package/esm/decoratedBackend/workspaceSettings.d.ts +1 -0
  60. package/esm/decoratedBackend/workspaceSettings.d.ts.map +1 -1
  61. package/esm/decoratedBackend/workspaceSettings.js +7 -0
  62. package/esm/decoratedBackend/workspaceSettings.js.map +1 -1
  63. package/esm/dummyBackend/index.d.ts.map +1 -1
  64. package/esm/dummyBackend/index.js +295 -5
  65. package/esm/dummyBackend/index.js.map +1 -1
  66. package/esm/index.d.ts +1 -1
  67. package/esm/index.d.ts.map +1 -1
  68. package/esm/index.js +1 -1
  69. package/esm/index.js.map +1 -1
  70. package/esm/normalizingBackend/normalizer.d.ts.map +1 -1
  71. package/esm/normalizingBackend/normalizer.js +2 -2
  72. package/esm/normalizingBackend/normalizer.js.map +1 -1
  73. package/package.json +6 -6
@@ -16,6 +16,7 @@ import { DateAttributeGranularity } from '@gooddata/sdk-model';
16
16
  import { DimensionGenerator } from '@gooddata/sdk-model';
17
17
  import { ErrorConverter } from '@gooddata/sdk-backend-spi';
18
18
  import { ExplainConfig } from '@gooddata/sdk-backend-spi';
19
+ import { ExplainType } from '@gooddata/sdk-backend-spi';
19
20
  import { FilterContextItem } from '@gooddata/sdk-model';
20
21
  import { IAnalyticalBackend } from '@gooddata/sdk-backend-spi';
21
22
  import { IAnalyticalBackendConfig } from '@gooddata/sdk-backend-spi';
@@ -49,6 +50,7 @@ import { IExecutionConfig } from '@gooddata/sdk-model';
49
50
  import { IExecutionDefinition } from '@gooddata/sdk-model';
50
51
  import { IExecutionFactory } from '@gooddata/sdk-backend-spi';
51
52
  import { IExecutionResult } from '@gooddata/sdk-backend-spi';
53
+ import { IExplainProvider } from '@gooddata/sdk-backend-spi';
52
54
  import { IExportConfig } from '@gooddata/sdk-backend-spi';
53
55
  import { IExportResult } from '@gooddata/sdk-backend-spi';
54
56
  import { IFactMetadataObject } from '@gooddata/sdk-model';
@@ -322,7 +324,7 @@ export declare type BuilderModifications<TBuilder extends IBuilder<TItem>, TItem
322
324
  * Cache control can be used to interact with the caching layer - at the moment to reset the contents of the
323
325
  * different top-level caches.
324
326
  *
325
- * @beta
327
+ * @public
326
328
  */
327
329
  export declare type CacheControl = {
328
330
  /**
@@ -357,7 +359,7 @@ export declare type CacheControl = {
357
359
  /**
358
360
  * Specifies where should the caching decorator apply and to what size should caches grow.
359
361
  *
360
- * @beta
362
+ * @public
361
363
  */
362
364
  export declare type CachingConfiguration = {
363
365
  /**
@@ -373,7 +375,7 @@ export declare type CachingConfiguration = {
373
375
  *
374
376
  * When non-positive number is specified, then no caching will be done.
375
377
  */
376
- maxExecutions: number | undefined;
378
+ maxExecutions?: number;
377
379
  /**
378
380
  * Maximum number of execution result's pages to cache PER result. The window offset and limit are used as cache key.
379
381
  *
@@ -386,7 +388,7 @@ export declare type CachingConfiguration = {
386
388
  *
387
389
  * Note: this option has no effect if execution caching is disabled.
388
390
  */
389
- maxResultWindows: number | undefined;
391
+ maxResultWindows?: number;
390
392
  /**
391
393
  * Maximum number of workspaces for which to cache catalogs. The workspace identifier is used as cache key. For
392
394
  * each workspace, there will be a cache entry holding `maxCatalogOptions` entries.
@@ -399,7 +401,7 @@ export declare type CachingConfiguration = {
399
401
  *
400
402
  * When non-positive number is specified, then no caching of result windows will be done.
401
403
  */
402
- maxCatalogs: number | undefined;
404
+ maxCatalogs?: number;
403
405
  /**
404
406
  * Catalog can be viewed in many different ways - determined by the options specified during load. This option
405
407
  * indicates how many unique options to cache results for.
@@ -413,7 +415,7 @@ export declare type CachingConfiguration = {
413
415
  *
414
416
  * Setting non-positive number here is invalid. If you want to turn off catalog caching, tweak the `maxCatalogs`.
415
417
  */
416
- maxCatalogOptions: number | undefined;
418
+ maxCatalogOptions?: number;
417
419
  /**
418
420
  * Specify function to call once the caching is set up. If present, the function will be called
419
421
  * with an instance of {@link CacheControl} which you can use to interact with the caches.
@@ -433,7 +435,7 @@ export declare type CachingConfiguration = {
433
435
  *
434
436
  * When non-positive number is specified, then no caching will be done.
435
437
  */
436
- maxSecuritySettingsOrgs: number | undefined;
438
+ maxSecuritySettingsOrgs?: number;
437
439
  /**
438
440
  * Maximum number of URLs per organization that will have its validation result cached. The URL
439
441
  * and validation context is used to form a cache key.
@@ -447,7 +449,7 @@ export declare type CachingConfiguration = {
447
449
  * Setting non-positive number here is invalid. If you want to turn off organization security settings caching,
448
450
  * tweak the `maxSecuritySettingsOrgs`.
449
451
  */
450
- maxSecuritySettingsOrgUrls: number | undefined;
452
+ maxSecuritySettingsOrgUrls?: number;
451
453
  /**
452
454
  * Maximum age of cached organization's URL validation results. The value is in milliseconds.
453
455
  *
@@ -459,7 +461,7 @@ export declare type CachingConfiguration = {
459
461
  * Setting non-positive number here is invalid. If you want to turn off organization security settings
460
462
  * caching, tweak the `maxSecuritySettingsOrgs`.
461
463
  */
462
- maxSecuritySettingsOrgUrlsAge: number | undefined;
464
+ maxSecuritySettingsOrgUrlsAge?: number;
463
465
  /**
464
466
  * Maximum number of workspaces for which to cache selected {@link @gooddata/sdk-backend-spi#IWorkspaceAttributesService} calls.
465
467
  * The workspace identifier is used as cache key.
@@ -473,7 +475,7 @@ export declare type CachingConfiguration = {
473
475
  *
474
476
  * When non-positive number is specified, then no caching will be done.
475
477
  */
476
- maxAttributeWorkspaces: number | undefined;
478
+ maxAttributeWorkspaces?: number;
477
479
  /**
478
480
  * Maximum number of attribute display forms to cache per workspace.
479
481
  *
@@ -486,7 +488,35 @@ export declare type CachingConfiguration = {
486
488
  * Setting non-positive number here is invalid. If you want to turn off attribute display form
487
489
  * caching, tweak the `maxAttributeWorkspaces` value.
488
490
  */
489
- maxAttributeDisplayFormsPerWorkspace: number | undefined;
491
+ maxAttributeDisplayFormsPerWorkspace?: number;
492
+ /**
493
+ * Maximum number of attributes to cache per workspace.
494
+ *
495
+ * When limit is reached, cache entries will be evicted using LRU policy.
496
+ *
497
+ * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded
498
+ * attribute cache may be OK in applications where number of attributes is small and/or they are requested
499
+ * infrequently - the cache will be limited naturally and will not grow uncontrollably.
500
+ *
501
+ * Setting non-positive number here is invalid. If you want to turn off attribute caching,
502
+ * tweak the `maxAttributeWorkspaces` value.
503
+ */
504
+ maxAttributesPerWorkspace?: number;
505
+ /**
506
+ * Maximum number of attributes element results to cache per workspace.
507
+ *
508
+ * Note that not all the queries are cached (e.g. queries with `filter` value).
509
+ *
510
+ * When limit is reached, cache entries will be evicted using LRU policy.
511
+ *
512
+ * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded
513
+ * attribute elements cache may be OK in applications where number of attributes and/or their elements is small
514
+ * and/or they are requested infrequently - the cache will be limited naturally and will not grow uncontrollably.
515
+ *
516
+ * Setting non-positive number here is invalid. If you want to turn off attribute caching,
517
+ * tweak the `maxAttributeWorkspaces` value.
518
+ */
519
+ maxAttributeElementResultsPerWorkspace?: number;
490
520
  /**
491
521
  * Maximum number of settings for a workspace and for a user to cache per workspace.
492
522
  *
@@ -498,7 +528,7 @@ export declare type CachingConfiguration = {
498
528
  *
499
529
  * When non-positive number is specified, then no caching of result windows will be done.
500
530
  */
501
- maxWorkspaceSettings: number | undefined;
531
+ maxWorkspaceSettings?: number;
502
532
  };
503
533
 
504
534
  /**
@@ -828,7 +858,7 @@ export declare abstract class DecoratedPreparedExecution implements IPreparedExe
828
858
  protected constructor(decorated: IPreparedExecution);
829
859
  equals(other: IPreparedExecution): boolean;
830
860
  execute(): Promise<IExecutionResult>;
831
- explain(config: ExplainConfig): Promise<void>;
861
+ explain<T extends ExplainType | undefined>(config: ExplainConfig<T>): IExplainProvider<typeof config["explainType"]>;
832
862
  fingerprint(): string;
833
863
  withDimensions(...dim: Array<IDimension | DimensionGenerator>): IPreparedExecution;
834
864
  withSorting(...items: ISortItem[]): IPreparedExecution;
@@ -884,6 +914,7 @@ export declare abstract class DecoratedWorkspaceCatalogFactory implements IWorks
884
914
  excludeTags(tags: ObjRef[]): IWorkspaceCatalogFactory;
885
915
  includeTags(tags: ObjRef[]): IWorkspaceCatalogFactory;
886
916
  withOptions(options: IWorkspaceCatalogFactoryOptions): IWorkspaceCatalogFactory;
917
+ withGroups(loadGroups: boolean): IWorkspaceCatalogFactory;
887
918
  load(): Promise<IWorkspaceCatalog>;
888
919
  /**
889
920
  * Methods that create new instances of catalog loader (e.g. all except load) will
@@ -938,6 +969,7 @@ export declare abstract class DecoratedWorkspaceSettingsService implements IWork
938
969
  protected constructor(decorated: IWorkspaceSettingsService);
939
970
  getSettings(): Promise<IWorkspaceSettings>;
940
971
  getSettingsForCurrentUser(): Promise<IUserWorkspaceSettings>;
972
+ setLocale(locale: string): Promise<void>;
941
973
  }
942
974
 
943
975
  /**
@@ -956,11 +988,6 @@ export declare type DecoratorFactories = {
956
988
  dashboards?: DashboardsDecoratorFactory;
957
989
  };
958
990
 
959
- /**
960
- * @beta
961
- */
962
- export declare const DefaultCachingConfiguration: CachingConfiguration;
963
-
964
991
  /**
965
992
  * @internal
966
993
  */
@@ -1634,6 +1661,16 @@ export declare class Normalizer {
1634
1661
  */
1635
1662
  export declare type PreparedExecutionWrapper = (execution: IPreparedExecution) => IPreparedExecution;
1636
1663
 
1664
+ /**
1665
+ * These are the recommended settings for the backend caching.
1666
+ *
1667
+ * @remarks
1668
+ * For more information on what the options mean see {@link CachingConfiguration}.
1669
+ *
1670
+ * @public
1671
+ */
1672
+ export declare const RecommendedCachingConfiguration: CachingConfiguration;
1673
+
1637
1674
  /**
1638
1675
  * Calls an update callback when it's a function, otherwise returns the value itself.
1639
1676
  * This is just an utility function to DRY the builder implementation a bit.
@@ -1776,10 +1813,10 @@ export declare class WidgetBaseBuilder<T extends IWidget> extends Builder<T> imp
1776
1813
  *
1777
1814
  * @remarks see {@link CachingConfiguration} properties for more information.
1778
1815
  * @param realBackend - real backend to decorate with caching
1779
- * @param config - caching configuration
1780
- * @beta
1816
+ * @param config - caching configuration. {@link RecommendedCachingConfiguration} can be used
1817
+ * @public
1781
1818
  */
1782
- export declare function withCaching(realBackend: IAnalyticalBackend, config?: CachingConfiguration): IAnalyticalBackend;
1819
+ export declare function withCaching(realBackend: IAnalyticalBackend, config: CachingConfiguration): IAnalyticalBackend;
1783
1820
 
1784
1821
  /**
1785
1822
  * Adjusts workspace configs and current user configs from the real backend.
@@ -3,7 +3,7 @@ import { IAnalyticalBackend } from "@gooddata/sdk-backend-spi";
3
3
  * Cache control can be used to interact with the caching layer - at the moment to reset the contents of the
4
4
  * different top-level caches.
5
5
  *
6
- * @beta
6
+ * @public
7
7
  */
8
8
  export declare type CacheControl = {
9
9
  /**
@@ -37,7 +37,7 @@ export declare type CacheControl = {
37
37
  /**
38
38
  * Specifies where should the caching decorator apply and to what size should caches grow.
39
39
  *
40
- * @beta
40
+ * @public
41
41
  */
42
42
  export declare type CachingConfiguration = {
43
43
  /**
@@ -53,7 +53,7 @@ export declare type CachingConfiguration = {
53
53
  *
54
54
  * When non-positive number is specified, then no caching will be done.
55
55
  */
56
- maxExecutions: number | undefined;
56
+ maxExecutions?: number;
57
57
  /**
58
58
  * Maximum number of execution result's pages to cache PER result. The window offset and limit are used as cache key.
59
59
  *
@@ -66,7 +66,7 @@ export declare type CachingConfiguration = {
66
66
  *
67
67
  * Note: this option has no effect if execution caching is disabled.
68
68
  */
69
- maxResultWindows: number | undefined;
69
+ maxResultWindows?: number;
70
70
  /**
71
71
  * Maximum number of workspaces for which to cache catalogs. The workspace identifier is used as cache key. For
72
72
  * each workspace, there will be a cache entry holding `maxCatalogOptions` entries.
@@ -79,7 +79,7 @@ export declare type CachingConfiguration = {
79
79
  *
80
80
  * When non-positive number is specified, then no caching of result windows will be done.
81
81
  */
82
- maxCatalogs: number | undefined;
82
+ maxCatalogs?: number;
83
83
  /**
84
84
  * Catalog can be viewed in many different ways - determined by the options specified during load. This option
85
85
  * indicates how many unique options to cache results for.
@@ -93,7 +93,7 @@ export declare type CachingConfiguration = {
93
93
  *
94
94
  * Setting non-positive number here is invalid. If you want to turn off catalog caching, tweak the `maxCatalogs`.
95
95
  */
96
- maxCatalogOptions: number | undefined;
96
+ maxCatalogOptions?: number;
97
97
  /**
98
98
  * Specify function to call once the caching is set up. If present, the function will be called
99
99
  * with an instance of {@link CacheControl} which you can use to interact with the caches.
@@ -113,7 +113,7 @@ export declare type CachingConfiguration = {
113
113
  *
114
114
  * When non-positive number is specified, then no caching will be done.
115
115
  */
116
- maxSecuritySettingsOrgs: number | undefined;
116
+ maxSecuritySettingsOrgs?: number;
117
117
  /**
118
118
  * Maximum number of URLs per organization that will have its validation result cached. The URL
119
119
  * and validation context is used to form a cache key.
@@ -127,7 +127,7 @@ export declare type CachingConfiguration = {
127
127
  * Setting non-positive number here is invalid. If you want to turn off organization security settings caching,
128
128
  * tweak the `maxSecuritySettingsOrgs`.
129
129
  */
130
- maxSecuritySettingsOrgUrls: number | undefined;
130
+ maxSecuritySettingsOrgUrls?: number;
131
131
  /**
132
132
  * Maximum age of cached organization's URL validation results. The value is in milliseconds.
133
133
  *
@@ -139,7 +139,7 @@ export declare type CachingConfiguration = {
139
139
  * Setting non-positive number here is invalid. If you want to turn off organization security settings
140
140
  * caching, tweak the `maxSecuritySettingsOrgs`.
141
141
  */
142
- maxSecuritySettingsOrgUrlsAge: number | undefined;
142
+ maxSecuritySettingsOrgUrlsAge?: number;
143
143
  /**
144
144
  * Maximum number of workspaces for which to cache selected {@link @gooddata/sdk-backend-spi#IWorkspaceAttributesService} calls.
145
145
  * The workspace identifier is used as cache key.
@@ -153,7 +153,7 @@ export declare type CachingConfiguration = {
153
153
  *
154
154
  * When non-positive number is specified, then no caching will be done.
155
155
  */
156
- maxAttributeWorkspaces: number | undefined;
156
+ maxAttributeWorkspaces?: number;
157
157
  /**
158
158
  * Maximum number of attribute display forms to cache per workspace.
159
159
  *
@@ -166,7 +166,35 @@ export declare type CachingConfiguration = {
166
166
  * Setting non-positive number here is invalid. If you want to turn off attribute display form
167
167
  * caching, tweak the `maxAttributeWorkspaces` value.
168
168
  */
169
- maxAttributeDisplayFormsPerWorkspace: number | undefined;
169
+ maxAttributeDisplayFormsPerWorkspace?: number;
170
+ /**
171
+ * Maximum number of attributes to cache per workspace.
172
+ *
173
+ * When limit is reached, cache entries will be evicted using LRU policy.
174
+ *
175
+ * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded
176
+ * attribute cache may be OK in applications where number of attributes is small and/or they are requested
177
+ * infrequently - the cache will be limited naturally and will not grow uncontrollably.
178
+ *
179
+ * Setting non-positive number here is invalid. If you want to turn off attribute caching,
180
+ * tweak the `maxAttributeWorkspaces` value.
181
+ */
182
+ maxAttributesPerWorkspace?: number;
183
+ /**
184
+ * Maximum number of attributes element results to cache per workspace.
185
+ *
186
+ * Note that not all the queries are cached (e.g. queries with `filter` value).
187
+ *
188
+ * When limit is reached, cache entries will be evicted using LRU policy.
189
+ *
190
+ * When no maximum number is specified, the cache will be unbounded and no evictions will happen. Unbounded
191
+ * attribute elements cache may be OK in applications where number of attributes and/or their elements is small
192
+ * and/or they are requested infrequently - the cache will be limited naturally and will not grow uncontrollably.
193
+ *
194
+ * Setting non-positive number here is invalid. If you want to turn off attribute caching,
195
+ * tweak the `maxAttributeWorkspaces` value.
196
+ */
197
+ maxAttributeElementResultsPerWorkspace?: number;
170
198
  /**
171
199
  * Maximum number of settings for a workspace and for a user to cache per workspace.
172
200
  *
@@ -178,20 +206,25 @@ export declare type CachingConfiguration = {
178
206
  *
179
207
  * When non-positive number is specified, then no caching of result windows will be done.
180
208
  */
181
- maxWorkspaceSettings: number | undefined;
209
+ maxWorkspaceSettings?: number;
182
210
  };
183
211
  /**
184
- * @beta
212
+ * These are the recommended settings for the backend caching.
213
+ *
214
+ * @remarks
215
+ * For more information on what the options mean see {@link CachingConfiguration}.
216
+ *
217
+ * @public
185
218
  */
186
- export declare const DefaultCachingConfiguration: CachingConfiguration;
219
+ export declare const RecommendedCachingConfiguration: CachingConfiguration;
187
220
  /**
188
221
  * Adds caching layer on top of an existing analytical backend instance. It is currently possible to cache
189
222
  * results of executions and the workspace LDM catalog.
190
223
  *
191
224
  * @remarks see {@link CachingConfiguration} properties for more information.
192
225
  * @param realBackend - real backend to decorate with caching
193
- * @param config - caching configuration
194
- * @beta
226
+ * @param config - caching configuration. {@link RecommendedCachingConfiguration} can be used
227
+ * @public
195
228
  */
196
- export declare function withCaching(realBackend: IAnalyticalBackend, config?: CachingConfiguration): IAnalyticalBackend;
229
+ export declare function withCaching(realBackend: IAnalyticalBackend, config: CachingConfiguration): IAnalyticalBackend;
197
230
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cachingBackend/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,kBAAkB,EAerB,MAAM,2BAA2B,CAA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AC;IAEhC;;;;;;;;;;;OAWG;IACH,oCAAoC,CAAC,EAAE,MAAM,CAAC;IAE9C;;;;;;;;;;;OAWG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;;;;;;;;;;OAaG;IACH,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAEhD;;;;;;;;;;OAUG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AASF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,oBAa7C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACvB,WAAW,EAAE,kBAAkB,EAC/B,MAAM,EAAE,oBAAoB,GAC7B,kBAAkB,CA8CpB"}
@@ -4,6 +4,7 @@ import { LRUCache } from "@gooddata/util";
4
4
  import { DecoratedSecuritySettingsService } from "../decoratedBackend/securitySettings";
5
5
  import { DecoratedDataView, DecoratedExecutionFactory, DecoratedExecutionResult, DecoratedPreparedExecution, } from "../decoratedBackend/execution";
6
6
  import { DecoratedWorkspaceCatalogFactory } from "../decoratedBackend/catalog";
7
+ import { DecoratedElementsQuery, DecoratedElementsQueryFactory } from "../decoratedBackend/elements";
7
8
  import stringify from "json-stable-stringify";
8
9
  import compact from "lodash/compact";
9
10
  import first from "lodash/first";
@@ -11,7 +12,8 @@ import flow from "lodash/flow";
11
12
  import identity from "lodash/identity";
12
13
  import invariant from "ts-invariant";
13
14
  import partition from "lodash/partition";
14
- import { areObjRefsEqual, idRef, isIdentifierRef, isUriRef, uriRef, } from "@gooddata/sdk-model";
15
+ import SparkMD5 from "spark-md5";
16
+ import { areObjRefsEqual, idRef, isIdentifierRef, isUriRef, uriRef, objRefToString, } from "@gooddata/sdk-model";
15
17
  import { DecoratedWorkspaceAttributesService } from "../decoratedBackend/attributes";
16
18
  import { DecoratedWorkspaceSettingsService } from "../decoratedBackend/workspaceSettings";
17
19
  //
@@ -304,6 +306,13 @@ var WithWorkspaceSettingsCaching = /** @class */ (function (_super) {
304
306
  }
305
307
  return userWorkspaceSettings;
306
308
  };
309
+ WithWorkspaceSettingsCaching.prototype.setLocale = function (locale) {
310
+ return __awaiter(this, void 0, void 0, function () {
311
+ return __generator(this, function (_a) {
312
+ return [2 /*return*/, _super.prototype.setLocale.call(this, locale)];
313
+ });
314
+ });
315
+ };
307
316
  return WithWorkspaceSettingsCaching;
308
317
  }(DecoratedWorkspaceSettingsService));
309
318
  //
@@ -315,6 +324,78 @@ function refMatchesMdObject(ref, mdObject, type) {
315
324
  areObjRefsEqual(ref, uriRef(mdObject.uri)));
316
325
  }
317
326
  var firstDefined = flow(compact, first);
327
+ function elementsCacheKey(ref, settings) {
328
+ return new SparkMD5().append(objRefToString(ref)).append(stringify(settings)).end();
329
+ }
330
+ function getOrCreateAttributeCache(ctx, workspace) {
331
+ var cache = ctx.caches.workspaceAttributes;
332
+ var cacheEntry = cache.get(workspace);
333
+ if (!cacheEntry) {
334
+ cacheEntry = {
335
+ displayForms: new LRUCache({
336
+ maxSize: ctx.config.maxAttributeDisplayFormsPerWorkspace,
337
+ }),
338
+ attributesByDisplayForms: new LRUCache({
339
+ maxSize: ctx.config.maxAttributesPerWorkspace,
340
+ }),
341
+ attributeElementResults: new LRUCache({
342
+ maxSize: ctx.config.maxAttributeElementResultsPerWorkspace,
343
+ }),
344
+ };
345
+ cache.set(workspace, cacheEntry);
346
+ }
347
+ return cacheEntry;
348
+ }
349
+ var CachedElementsQuery = /** @class */ (function (_super) {
350
+ __extends(CachedElementsQuery, _super);
351
+ function CachedElementsQuery(decorated, ctx, workspace, ref, settings) {
352
+ if (settings === void 0) { settings = {}; }
353
+ var _this = _super.call(this, decorated, settings) || this;
354
+ _this.ctx = ctx;
355
+ _this.workspace = workspace;
356
+ _this.ref = ref;
357
+ _this.query = function () { return __awaiter(_this, void 0, void 0, function () {
358
+ var canCache, cache, cacheKey, result;
359
+ var _a;
360
+ return __generator(this, function (_b) {
361
+ canCache = !((_a = this.settings.options) === null || _a === void 0 ? void 0 : _a.filter);
362
+ if (!canCache) {
363
+ return [2 /*return*/, _super.prototype.query.call(this)];
364
+ }
365
+ cache = getOrCreateAttributeCache(this.ctx, this.workspace).attributeElementResults;
366
+ cacheKey = elementsCacheKey(this.ref, this.settings);
367
+ result = cache.get(cacheKey);
368
+ if (!result) {
369
+ result = _super.prototype.query.call(this).catch(function (e) {
370
+ cache.delete(cacheKey);
371
+ throw e;
372
+ });
373
+ cache.set(cacheKey, result);
374
+ }
375
+ return [2 /*return*/, result];
376
+ });
377
+ }); };
378
+ return _this;
379
+ }
380
+ CachedElementsQuery.prototype.createNew = function (decorated, settings) {
381
+ return new CachedElementsQuery(decorated, this.ctx, this.workspace, this.ref, settings);
382
+ };
383
+ return CachedElementsQuery;
384
+ }(DecoratedElementsQuery));
385
+ var CachedElementsQueryFactory = /** @class */ (function (_super) {
386
+ __extends(CachedElementsQueryFactory, _super);
387
+ function CachedElementsQueryFactory(decorated, ctx, workspace) {
388
+ var _this = _super.call(this, decorated) || this;
389
+ _this.ctx = ctx;
390
+ _this.workspace = workspace;
391
+ return _this;
392
+ }
393
+ CachedElementsQueryFactory.prototype.forDisplayForm = function (ref) {
394
+ var decorated = this.decorated.forDisplayForm(ref);
395
+ return new CachedElementsQuery(decorated, this.ctx, this.workspace, ref);
396
+ };
397
+ return CachedElementsQueryFactory;
398
+ }(DecoratedElementsQueryFactory));
318
399
  var WithAttributesCaching = /** @class */ (function (_super) {
319
400
  __extends(WithAttributesCaching, _super);
320
401
  function WithAttributesCaching(decorated, ctx, workspace) {
@@ -322,7 +403,7 @@ var WithAttributesCaching = /** @class */ (function (_super) {
322
403
  _this.ctx = ctx;
323
404
  _this.workspace = workspace;
324
405
  _this.getAttributeDisplayForm = function (ref) {
325
- var cache = _this.getOrCreateWorkspaceEntry(_this.workspace).displayForms;
406
+ var cache = getOrCreateAttributeCache(_this.ctx, _this.workspace).displayForms;
326
407
  var idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
327
408
  var uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
328
409
  var cacheItem = firstDefined([idCacheKey, uriCacheKey].map(function (key) { return key && cache.get(key); }));
@@ -350,7 +431,7 @@ var WithAttributesCaching = /** @class */ (function (_super) {
350
431
  return __generator(this, function (_c) {
351
432
  switch (_c.label) {
352
433
  case 0:
353
- cache = this.getOrCreateWorkspaceEntry(this.workspace).displayForms;
434
+ cache = getOrCreateAttributeCache(this.ctx, this.workspace).displayForms;
354
435
  refsWithCacheResults = refs.map(function (ref) {
355
436
  var idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
356
437
  var uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
@@ -391,21 +472,40 @@ var WithAttributesCaching = /** @class */ (function (_super) {
391
472
  }
392
473
  });
393
474
  }); };
394
- _this.getOrCreateWorkspaceEntry = function (workspace) {
395
- var cache = _this.ctx.caches.workspaceAttributes;
396
- var cacheEntry = cache.get(workspace);
397
- if (!cacheEntry) {
398
- cacheEntry = {
399
- displayForms: new LRUCache({
400
- maxSize: _this.ctx.config.maxAttributeDisplayFormsPerWorkspace,
401
- }),
402
- };
403
- cache.set(workspace, cacheEntry);
404
- }
405
- return cacheEntry;
406
- };
475
+ _this.getAttributeByDisplayForm = function (ref) { return __awaiter(_this, void 0, void 0, function () {
476
+ var cache, idCacheKey, uriCacheKey, cacheItem;
477
+ return __generator(this, function (_a) {
478
+ cache = getOrCreateAttributeCache(this.ctx, this.workspace).attributesByDisplayForms;
479
+ idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
480
+ uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
481
+ cacheItem = firstDefined([idCacheKey, uriCacheKey].map(function (key) { return key && cache.get(key); }));
482
+ if (!cacheItem) {
483
+ // eslint-disable-next-line sonarjs/no-identical-functions
484
+ cacheItem = _super.prototype.getAttributeByDisplayForm.call(this, ref).catch(function (e) {
485
+ if (idCacheKey) {
486
+ cache.delete(idCacheKey);
487
+ }
488
+ if (uriCacheKey) {
489
+ cache.delete(uriCacheKey);
490
+ }
491
+ throw e;
492
+ });
493
+ if (idCacheKey) {
494
+ cache.set(idCacheKey, cacheItem);
495
+ }
496
+ if (uriCacheKey) {
497
+ cache.set(uriCacheKey, cacheItem);
498
+ }
499
+ }
500
+ return [2 /*return*/, cacheItem];
501
+ });
502
+ }); };
407
503
  return _this;
408
504
  }
505
+ WithAttributesCaching.prototype.elements = function () {
506
+ var decorated = this.decorated.elements();
507
+ return new CachedElementsQueryFactory(decorated, this.ctx, this.workspace);
508
+ };
409
509
  return WithAttributesCaching;
410
510
  }(DecoratedWorkspaceAttributesService));
411
511
  //
@@ -467,9 +567,14 @@ function assertPositiveOrUndefined(value, valueName) {
467
567
  invariant(value === undefined || value > 0, valueName + " to cache must be positive or undefined, got: " + value);
468
568
  }
469
569
  /**
470
- * @beta
570
+ * These are the recommended settings for the backend caching.
571
+ *
572
+ * @remarks
573
+ * For more information on what the options mean see {@link CachingConfiguration}.
574
+ *
575
+ * @public
471
576
  */
472
- export var DefaultCachingConfiguration = {
577
+ export var RecommendedCachingConfiguration = {
473
578
  maxExecutions: 10,
474
579
  maxResultWindows: 5,
475
580
  maxCatalogs: 1,
@@ -479,6 +584,8 @@ export var DefaultCachingConfiguration = {
479
584
  maxSecuritySettingsOrgUrlsAge: 300000,
480
585
  maxAttributeWorkspaces: 1,
481
586
  maxAttributeDisplayFormsPerWorkspace: 100,
587
+ maxAttributesPerWorkspace: 100,
588
+ maxAttributeElementResultsPerWorkspace: 100,
482
589
  maxWorkspaceSettings: 1,
483
590
  };
484
591
  /**
@@ -487,11 +594,10 @@ export var DefaultCachingConfiguration = {
487
594
  *
488
595
  * @remarks see {@link CachingConfiguration} properties for more information.
489
596
  * @param realBackend - real backend to decorate with caching
490
- * @param config - caching configuration
491
- * @beta
597
+ * @param config - caching configuration. {@link RecommendedCachingConfiguration} can be used
598
+ * @public
492
599
  */
493
600
  export function withCaching(realBackend, config) {
494
- if (config === void 0) { config = DefaultCachingConfiguration; }
495
601
  assertPositiveOrUndefined(config.maxCatalogOptions, "maxCatalogOptions");
496
602
  assertPositiveOrUndefined(config.maxSecuritySettingsOrgUrls, "maxSecuritySettingsOrgUrls");
497
603
  assertPositiveOrUndefined(config.maxSecuritySettingsOrgUrlsAge, "maxSecuritySettingsOrgUrlsAge");