@gooddata/sdk-backend-base 8.13.0-alpha.2 → 8.13.0-alpha.21

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 (159) hide show
  1. package/dist/cachingBackend/index.js +304 -380
  2. package/dist/cachingBackend/index.js.map +1 -1
  3. package/dist/convertors/fromBackend/afm/result.js +3 -3
  4. package/dist/convertors/fromBackend/afm/result.js.map +1 -1
  5. package/dist/customBackend/execution.js +77 -92
  6. package/dist/customBackend/execution.js.map +1 -1
  7. package/dist/customBackend/index.js +78 -114
  8. package/dist/customBackend/index.js.map +1 -1
  9. package/dist/customBackend/workspace.js +39 -40
  10. package/dist/customBackend/workspace.js.map +1 -1
  11. package/dist/decoratedBackend/attributes.js +21 -22
  12. package/dist/decoratedBackend/attributes.js.map +1 -1
  13. package/dist/decoratedBackend/catalog.js +38 -50
  14. package/dist/decoratedBackend/catalog.js.map +1 -1
  15. package/dist/decoratedBackend/dashboards.js +61 -62
  16. package/dist/decoratedBackend/dashboards.js.map +1 -1
  17. package/dist/decoratedBackend/elements.js +47 -70
  18. package/dist/decoratedBackend/elements.js.map +1 -1
  19. package/dist/decoratedBackend/execution.js +62 -79
  20. package/dist/decoratedBackend/execution.js.map +1 -1
  21. package/dist/decoratedBackend/index.js +90 -104
  22. package/dist/decoratedBackend/index.js.map +1 -1
  23. package/dist/decoratedBackend/securitySettings.js +7 -8
  24. package/dist/decoratedBackend/securitySettings.js.map +1 -1
  25. package/dist/decoratedBackend/workspaceSettings.js +12 -26
  26. package/dist/decoratedBackend/workspaceSettings.js.map +1 -1
  27. package/dist/dummyBackend/index.js +347 -391
  28. package/dist/dummyBackend/index.js.map +1 -1
  29. package/dist/eventingBackend/index.js +42 -49
  30. package/dist/eventingBackend/index.js.map +1 -1
  31. package/dist/ldmFactories/builder.js +14 -16
  32. package/dist/ldmFactories/builder.js.map +1 -1
  33. package/dist/ldmFactories/catalog/attributeFactory.js +22 -32
  34. package/dist/ldmFactories/catalog/attributeFactory.js.map +1 -1
  35. package/dist/ldmFactories/catalog/dateDatasetFactory.js +25 -41
  36. package/dist/ldmFactories/catalog/dateDatasetFactory.js.map +1 -1
  37. package/dist/ldmFactories/catalog/factFactory.js +11 -19
  38. package/dist/ldmFactories/catalog/factFactory.js.map +1 -1
  39. package/dist/ldmFactories/catalog/groupFactory.js +14 -27
  40. package/dist/ldmFactories/catalog/groupFactory.js.map +1 -1
  41. package/dist/ldmFactories/catalog/measureFactory.js +15 -25
  42. package/dist/ldmFactories/catalog/measureFactory.js.map +1 -1
  43. package/dist/ldmFactories/dashboard/insightWidgetFactory.js +20 -27
  44. package/dist/ldmFactories/dashboard/insightWidgetFactory.js.map +1 -1
  45. package/dist/ldmFactories/dashboard/kpiWidgetFactory.js +24 -34
  46. package/dist/ldmFactories/dashboard/kpiWidgetFactory.js.map +1 -1
  47. package/dist/ldmFactories/dashboard/widgetFactory.js +20 -39
  48. package/dist/ldmFactories/dashboard/widgetFactory.js.map +1 -1
  49. package/dist/ldmFactories/metadata/attributeFactory.js +13 -21
  50. package/dist/ldmFactories/metadata/attributeFactory.js.map +1 -1
  51. package/dist/ldmFactories/metadata/dashboardFactory.js +7 -15
  52. package/dist/ldmFactories/metadata/dashboardFactory.js.map +1 -1
  53. package/dist/ldmFactories/metadata/dataSetFactory.js +7 -15
  54. package/dist/ldmFactories/metadata/dataSetFactory.js.map +1 -1
  55. package/dist/ldmFactories/metadata/displayFormFactory.js +13 -21
  56. package/dist/ldmFactories/metadata/displayFormFactory.js.map +1 -1
  57. package/dist/ldmFactories/metadata/factFactory.js +7 -15
  58. package/dist/ldmFactories/metadata/factFactory.js.map +1 -1
  59. package/dist/ldmFactories/metadata/factory.js +17 -23
  60. package/dist/ldmFactories/metadata/factory.js.map +1 -1
  61. package/dist/ldmFactories/metadata/measureFactory.js +13 -21
  62. package/dist/ldmFactories/metadata/measureFactory.js.map +1 -1
  63. package/dist/ldmFactories/metadata/variableFactory.js +7 -15
  64. package/dist/ldmFactories/metadata/variableFactory.js.map +1 -1
  65. package/dist/normalizingBackend/index.js +71 -96
  66. package/dist/normalizingBackend/index.js.map +1 -1
  67. package/dist/normalizingBackend/normalizer.d.ts.map +1 -1
  68. package/dist/normalizingBackend/normalizer.js +130 -138
  69. package/dist/normalizingBackend/normalizer.js.map +1 -1
  70. package/dist/toolkit/auth.js +47 -60
  71. package/dist/toolkit/auth.js.map +1 -1
  72. package/dist/toolkit/execution.js +40 -52
  73. package/dist/toolkit/execution.js.map +1 -1
  74. package/dist/toolkit/paging.js +77 -146
  75. package/dist/toolkit/paging.js.map +1 -1
  76. package/dist/toolkit/pluginUrlValidation.js +9 -9
  77. package/dist/toolkit/pluginUrlValidation.js.map +1 -1
  78. package/dist/workspaceSettingsBackend/index.js +23 -46
  79. package/dist/workspaceSettingsBackend/index.js.map +1 -1
  80. package/esm/cachingBackend/index.js +281 -358
  81. package/esm/cachingBackend/index.js.map +1 -1
  82. package/esm/convertors/fromBackend/afm/result.js +3 -3
  83. package/esm/convertors/fromBackend/afm/result.js.map +1 -1
  84. package/esm/customBackend/execution.js +72 -89
  85. package/esm/customBackend/execution.js.map +1 -1
  86. package/esm/customBackend/index.js +75 -112
  87. package/esm/customBackend/index.js.map +1 -1
  88. package/esm/customBackend/workspace.js +37 -39
  89. package/esm/customBackend/workspace.js.map +1 -1
  90. package/esm/decoratedBackend/attributes.js +21 -23
  91. package/esm/decoratedBackend/attributes.js.map +1 -1
  92. package/esm/decoratedBackend/catalog.js +36 -51
  93. package/esm/decoratedBackend/catalog.js.map +1 -1
  94. package/esm/decoratedBackend/dashboards.js +61 -63
  95. package/esm/decoratedBackend/dashboards.js.map +1 -1
  96. package/esm/decoratedBackend/elements.js +47 -73
  97. package/esm/decoratedBackend/elements.js.map +1 -1
  98. package/esm/decoratedBackend/execution.js +60 -81
  99. package/esm/decoratedBackend/execution.js.map +1 -1
  100. package/esm/decoratedBackend/index.js +88 -103
  101. package/esm/decoratedBackend/index.js.map +1 -1
  102. package/esm/decoratedBackend/securitySettings.js +7 -9
  103. package/esm/decoratedBackend/securitySettings.js.map +1 -1
  104. package/esm/decoratedBackend/workspaceSettings.js +12 -27
  105. package/esm/decoratedBackend/workspaceSettings.js.map +1 -1
  106. package/esm/dummyBackend/index.js +342 -387
  107. package/esm/dummyBackend/index.js.map +1 -1
  108. package/esm/eventingBackend/index.js +37 -45
  109. package/esm/eventingBackend/index.js.map +1 -1
  110. package/esm/ldmFactories/builder.js +14 -17
  111. package/esm/ldmFactories/builder.js.map +1 -1
  112. package/esm/ldmFactories/catalog/attributeFactory.js +15 -27
  113. package/esm/ldmFactories/catalog/attributeFactory.js.map +1 -1
  114. package/esm/ldmFactories/catalog/dateDatasetFactory.js +18 -37
  115. package/esm/ldmFactories/catalog/dateDatasetFactory.js.map +1 -1
  116. package/esm/ldmFactories/catalog/factFactory.js +5 -15
  117. package/esm/ldmFactories/catalog/factFactory.js.map +1 -1
  118. package/esm/ldmFactories/catalog/groupFactory.js +11 -27
  119. package/esm/ldmFactories/catalog/groupFactory.js.map +1 -1
  120. package/esm/ldmFactories/catalog/measureFactory.js +9 -21
  121. package/esm/ldmFactories/catalog/measureFactory.js.map +1 -1
  122. package/esm/ldmFactories/dashboard/insightWidgetFactory.js +16 -25
  123. package/esm/ldmFactories/dashboard/insightWidgetFactory.js.map +1 -1
  124. package/esm/ldmFactories/dashboard/kpiWidgetFactory.js +19 -31
  125. package/esm/ldmFactories/dashboard/kpiWidgetFactory.js.map +1 -1
  126. package/esm/ldmFactories/dashboard/widgetFactory.js +19 -39
  127. package/esm/ldmFactories/dashboard/widgetFactory.js.map +1 -1
  128. package/esm/ldmFactories/metadata/attributeFactory.js +9 -19
  129. package/esm/ldmFactories/metadata/attributeFactory.js.map +1 -1
  130. package/esm/ldmFactories/metadata/dashboardFactory.js +3 -13
  131. package/esm/ldmFactories/metadata/dashboardFactory.js.map +1 -1
  132. package/esm/ldmFactories/metadata/dataSetFactory.js +3 -13
  133. package/esm/ldmFactories/metadata/dataSetFactory.js.map +1 -1
  134. package/esm/ldmFactories/metadata/displayFormFactory.js +9 -19
  135. package/esm/ldmFactories/metadata/displayFormFactory.js.map +1 -1
  136. package/esm/ldmFactories/metadata/factFactory.js +3 -13
  137. package/esm/ldmFactories/metadata/factFactory.js.map +1 -1
  138. package/esm/ldmFactories/metadata/factory.js +16 -23
  139. package/esm/ldmFactories/metadata/factory.js.map +1 -1
  140. package/esm/ldmFactories/metadata/measureFactory.js +9 -19
  141. package/esm/ldmFactories/metadata/measureFactory.js.map +1 -1
  142. package/esm/ldmFactories/metadata/variableFactory.js +3 -13
  143. package/esm/ldmFactories/metadata/variableFactory.js.map +1 -1
  144. package/esm/normalizingBackend/index.js +64 -90
  145. package/esm/normalizingBackend/index.js.map +1 -1
  146. package/esm/normalizingBackend/normalizer.d.ts.map +1 -1
  147. package/esm/normalizingBackend/normalizer.js +125 -136
  148. package/esm/normalizingBackend/normalizer.js.map +1 -1
  149. package/esm/toolkit/auth.js +47 -63
  150. package/esm/toolkit/auth.js.map +1 -1
  151. package/esm/toolkit/execution.js +38 -53
  152. package/esm/toolkit/execution.js.map +1 -1
  153. package/esm/toolkit/paging.js +72 -144
  154. package/esm/toolkit/paging.js.map +1 -1
  155. package/esm/toolkit/pluginUrlValidation.js +8 -8
  156. package/esm/toolkit/pluginUrlValidation.js.map +1 -1
  157. package/esm/workspaceSettingsBackend/index.js +19 -43
  158. package/esm/workspaceSettingsBackend/index.js.map +1 -1
  159. package/package.json +7 -6
@@ -1,6 +1,5 @@
1
- import { __awaiter, __extends, __generator, __spreadArrays } from "tslib";
2
1
  import { decoratedBackend, } from "../decoratedBackend";
3
- import { LRUCache } from "@gooddata/util";
2
+ import LRUCache from "lru-cache";
4
3
  import { DecoratedSecuritySettingsService } from "../decoratedBackend/securitySettings";
5
4
  import { DecoratedDataView, DecoratedExecutionFactory, DecoratedExecutionResult, DecoratedPreparedExecution, } from "../decoratedBackend/execution";
6
5
  import { DecoratedWorkspaceCatalogFactory } from "../decoratedBackend/catalog";
@@ -19,60 +18,45 @@ import { DecoratedWorkspaceSettingsService } from "../decoratedBackend/workspace
19
18
  //
20
19
  // Execution caching
21
20
  //
22
- var WithExecutionCaching = /** @class */ (function (_super) {
23
- __extends(WithExecutionCaching, _super);
24
- function WithExecutionCaching(decorated, ctx) {
25
- var _this = _super.call(this, decorated) || this;
26
- _this.ctx = ctx;
27
- _this.execute = function () { return __awaiter(_this, void 0, void 0, function () {
28
- var cacheKey, cache, cacheEntry, result, _a;
29
- var _this = this;
30
- return __generator(this, function (_b) {
31
- switch (_b.label) {
32
- case 0:
33
- cacheKey = this.fingerprint();
34
- cache = this.ctx.caches.execution;
35
- cacheEntry = cache.get(cacheKey);
36
- if (!cacheEntry) {
37
- result = _super.prototype.execute.call(this)
38
- .then(function (res) {
39
- return new WithExecutionResultCaching(res, _this.createNew, _this.ctx);
40
- })
41
- .catch(function (e) {
42
- cache.delete(cacheKey);
43
- throw e;
44
- });
45
- cacheEntry = { result: result };
46
- cache.set(cacheKey, cacheEntry);
47
- }
48
- _a = DefinitionSanitizingExecutionResult.bind;
49
- return [4 /*yield*/, cacheEntry.result];
50
- case 1: return [2 /*return*/, new (_a.apply(DefinitionSanitizingExecutionResult, [void 0, _b.sent(), this.createNew,
51
- this.definition]))()];
52
- }
53
- });
54
- }); };
55
- _this.createNew = function (decorated) {
56
- return new WithExecutionCaching(decorated, _this.ctx);
21
+ class WithExecutionCaching extends DecoratedPreparedExecution {
22
+ constructor(decorated, ctx) {
23
+ super(decorated);
24
+ this.ctx = ctx;
25
+ this.execute = async () => {
26
+ const cacheKey = this.fingerprint();
27
+ const cache = this.ctx.caches.execution;
28
+ let cacheEntry = cache.get(cacheKey);
29
+ if (!cacheEntry) {
30
+ const result = super
31
+ .execute()
32
+ .then((res) => {
33
+ return new WithExecutionResultCaching(res, this.createNew, this.ctx);
34
+ })
35
+ .catch((e) => {
36
+ cache.delete(cacheKey);
37
+ throw e;
38
+ });
39
+ cacheEntry = { result };
40
+ cache.set(cacheKey, cacheEntry);
41
+ }
42
+ return new DefinitionSanitizingExecutionResult(await cacheEntry.result, this.createNew, this.definition);
43
+ };
44
+ this.createNew = (decorated) => {
45
+ return new WithExecutionCaching(decorated, this.ctx);
57
46
  };
58
- return _this;
59
47
  }
60
- return WithExecutionCaching;
61
- }(DecoratedPreparedExecution));
48
+ }
62
49
  /**
63
50
  * This DataView decorator makes sure that definition used in it is the same as the definition in the result.
64
51
  *
65
52
  * See the usage of this class in {@link DefinitionSanitizingExecutionResult} for more.
66
53
  */
67
- var DefinitionSanitizingDataView = /** @class */ (function (_super) {
68
- __extends(DefinitionSanitizingDataView, _super);
69
- function DefinitionSanitizingDataView(decorated, result) {
70
- var _this = _super.call(this, decorated, result) || this;
71
- _this.definition = result.definition;
72
- return _this;
54
+ class DefinitionSanitizingDataView extends DecoratedDataView {
55
+ constructor(decorated, result) {
56
+ super(decorated, result);
57
+ this.definition = result.definition;
73
58
  }
74
- return DefinitionSanitizingDataView;
75
- }(DecoratedDataView));
59
+ }
76
60
  /**
77
61
  * This ExecutionResult decorator makes sure that definitions used throughout the result are set
78
62
  * to the definitionOverride provided. This is useful with caching because different definitions may yield
@@ -82,98 +66,75 @@ var DefinitionSanitizingDataView = /** @class */ (function (_super) {
82
66
  *
83
67
  * See the usage of this class in {@link WithExecutionCaching} for more.
84
68
  */
85
- var DefinitionSanitizingExecutionResult = /** @class */ (function (_super) {
86
- __extends(DefinitionSanitizingExecutionResult, _super);
87
- function DefinitionSanitizingExecutionResult(decorated, wrapper, definitionOverride) {
88
- var _this = _super.call(this, decorated, wrapper) || this;
89
- _this.readAll = function () { return __awaiter(_this, void 0, void 0, function () {
90
- var _a;
91
- return __generator(this, function (_b) {
92
- switch (_b.label) {
93
- case 0:
94
- _a = this.withSanitizedDefinition;
95
- return [4 /*yield*/, _super.prototype.readAll.call(this)];
96
- case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
97
- }
98
- });
99
- }); };
100
- _this.readWindow = function (offset, size) { return __awaiter(_this, void 0, void 0, function () {
101
- var _a;
102
- return __generator(this, function (_b) {
103
- switch (_b.label) {
104
- case 0:
105
- _a = this.withSanitizedDefinition;
106
- return [4 /*yield*/, _super.prototype.readWindow.call(this, offset, size)];
107
- case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
108
- }
109
- });
110
- }); };
111
- _this.withSanitizedDefinition = function (original) {
112
- return new DefinitionSanitizingDataView(original, _this);
69
+ class DefinitionSanitizingExecutionResult extends DecoratedExecutionResult {
70
+ constructor(decorated, wrapper, definitionOverride) {
71
+ super(decorated, wrapper);
72
+ this.readAll = async () => {
73
+ return this.withSanitizedDefinition(await super.readAll());
74
+ };
75
+ this.readWindow = async (offset, size) => {
76
+ return this.withSanitizedDefinition(await super.readWindow(offset, size));
113
77
  };
114
- _this.definition = definitionOverride;
115
- return _this;
78
+ this.withSanitizedDefinition = (original) => {
79
+ return new DefinitionSanitizingDataView(original, this);
80
+ };
81
+ this.definition = definitionOverride;
116
82
  }
117
- return DefinitionSanitizingExecutionResult;
118
- }(DecoratedExecutionResult));
83
+ }
119
84
  function windowKey(offset, size) {
120
- return "o(" + offset.join(",") + ")_s(" + size.join(",") + ")";
85
+ return `o(${offset.join(",")})_s(${size.join(",")})`;
121
86
  }
122
- var WithExecutionResultCaching = /** @class */ (function (_super) {
123
- __extends(WithExecutionResultCaching, _super);
124
- function WithExecutionResultCaching(decorated, wrapper, ctx) {
125
- var _this = _super.call(this, decorated, wrapper) || this;
126
- _this.ctx = ctx;
127
- _this.readAll = function () {
128
- if (!_this.allData) {
129
- _this.allData = _super.prototype.readAll.call(_this).catch(function (e) {
130
- _this.allData = undefined;
87
+ class WithExecutionResultCaching extends DecoratedExecutionResult {
88
+ constructor(decorated, wrapper, ctx) {
89
+ super(decorated, wrapper);
90
+ this.ctx = ctx;
91
+ this.readAll = () => {
92
+ if (!this.allData) {
93
+ this.allData = super.readAll().catch((e) => {
94
+ this.allData = undefined;
131
95
  throw e;
132
96
  });
133
97
  }
134
- return _this.allData;
98
+ return this.allData;
135
99
  };
136
- _this.readWindow = function (offset, size) {
137
- if (!_this.windows) {
138
- return _super.prototype.readWindow.call(_this, offset, size);
100
+ this.readWindow = (offset, size) => {
101
+ if (!this.windows) {
102
+ return super.readWindow(offset, size);
139
103
  }
140
- var cacheKey = windowKey(offset, size);
141
- var window = _this.windows.get(cacheKey);
104
+ const cacheKey = windowKey(offset, size);
105
+ let window = this.windows.get(cacheKey);
142
106
  if (!window) {
143
- window = _super.prototype.readWindow.call(_this, offset, size).catch(function (e) {
144
- if (_this.windows) {
145
- _this.windows.delete(cacheKey);
107
+ window = super.readWindow(offset, size).catch((e) => {
108
+ if (this.windows) {
109
+ this.windows.delete(cacheKey);
146
110
  }
147
111
  throw e;
148
112
  });
149
- _this.windows.set(cacheKey, window);
113
+ this.windows.set(cacheKey, window);
150
114
  }
151
115
  return window;
152
116
  };
153
- if (cachingEnabled(_this.ctx.config.maxResultWindows)) {
154
- _this.windows = new LRUCache({ maxSize: _this.ctx.config.maxResultWindows });
117
+ if (cachingEnabled(this.ctx.config.maxResultWindows)) {
118
+ this.windows = new LRUCache({ max: this.ctx.config.maxResultWindows });
155
119
  }
156
- return _this;
157
120
  }
158
- return WithExecutionResultCaching;
159
- }(DecoratedExecutionResult));
121
+ }
160
122
  //
161
123
  // Catalog caching
162
124
  //
163
125
  function optionsKey(options) {
164
126
  return stringify(options);
165
127
  }
166
- var WithCatalogCaching = /** @class */ (function (_super) {
167
- __extends(WithCatalogCaching, _super);
168
- function WithCatalogCaching(decorated, ctx) {
169
- var _this = _super.call(this, decorated) || this;
170
- _this.ctx = ctx;
171
- _this.load = function () {
172
- var cache = _this.getOrCreateWorkspaceEntry(_this.workspace).catalogForOptions;
173
- var cacheKey = optionsKey(_this.options);
174
- var catalog = cache.get(cacheKey);
128
+ class WithCatalogCaching extends DecoratedWorkspaceCatalogFactory {
129
+ constructor(decorated, ctx) {
130
+ super(decorated);
131
+ this.ctx = ctx;
132
+ this.load = () => {
133
+ const cache = this.getOrCreateWorkspaceEntry(this.workspace).catalogForOptions;
134
+ const cacheKey = optionsKey(this.options);
135
+ let catalog = cache.get(cacheKey);
175
136
  if (!catalog) {
176
- catalog = _super.prototype.load.call(_this).catch(function (e) {
137
+ catalog = super.load().catch((e) => {
177
138
  cache.delete(cacheKey);
178
139
  throw e;
179
140
  });
@@ -181,43 +142,40 @@ var WithCatalogCaching = /** @class */ (function (_super) {
181
142
  }
182
143
  return catalog;
183
144
  };
184
- _this.createNew = function (decorated) {
185
- return new WithCatalogCaching(decorated, _this.ctx);
145
+ this.createNew = (decorated) => {
146
+ return new WithCatalogCaching(decorated, this.ctx);
186
147
  };
187
- _this.getOrCreateWorkspaceEntry = function (workspace) {
188
- var cache = _this.ctx.caches.workspaceCatalogs;
189
- var cacheEntry = cache.get(workspace);
148
+ this.getOrCreateWorkspaceEntry = (workspace) => {
149
+ const cache = this.ctx.caches.workspaceCatalogs;
150
+ let cacheEntry = cache.get(workspace);
190
151
  if (!cacheEntry) {
191
152
  cacheEntry = {
192
153
  catalogForOptions: new LRUCache({
193
- maxSize: _this.ctx.config.maxCatalogOptions,
154
+ max: this.ctx.config.maxCatalogOptions,
194
155
  }),
195
156
  };
196
157
  cache.set(workspace, cacheEntry);
197
158
  }
198
159
  return cacheEntry;
199
160
  };
200
- return _this;
201
161
  }
202
- return WithCatalogCaching;
203
- }(DecoratedWorkspaceCatalogFactory));
162
+ }
204
163
  //
205
164
  // Organization security settings caching
206
165
  //
207
166
  function validUrlInContextKey(url, context) {
208
- return context + "_" + stringify(url);
167
+ return `${context}_${stringify(url)}`;
209
168
  }
210
- var WithSecuritySettingsCaching = /** @class */ (function (_super) {
211
- __extends(WithSecuritySettingsCaching, _super);
212
- function WithSecuritySettingsCaching(decorated, ctx) {
213
- var _this = _super.call(this, decorated) || this;
214
- _this.ctx = ctx;
215
- _this.isUrlValid = function (url, context) {
216
- var cache = _this.getOrCreateSecuritySettingsEntry(_this.scope).valid;
217
- var cacheKey = validUrlInContextKey(url, context);
218
- var result = cache.get(cacheKey);
169
+ class WithSecuritySettingsCaching extends DecoratedSecuritySettingsService {
170
+ constructor(decorated, ctx) {
171
+ super(decorated);
172
+ this.ctx = ctx;
173
+ this.isUrlValid = (url, context) => {
174
+ const cache = this.getOrCreateSecuritySettingsEntry(this.scope).valid;
175
+ const cacheKey = validUrlInContextKey(url, context);
176
+ let result = cache.get(cacheKey);
219
177
  if (!result) {
220
- result = _super.prototype.isUrlValid.call(_this, url, context).catch(function (e) {
178
+ result = super.isUrlValid(url, context).catch((e) => {
221
179
  cache.delete(cacheKey);
222
180
  throw e;
223
181
  });
@@ -225,12 +183,12 @@ var WithSecuritySettingsCaching = /** @class */ (function (_super) {
225
183
  }
226
184
  return result;
227
185
  };
228
- _this.isDashboardPluginUrlValid = function (url, workspace) {
229
- var scope = "plugins_" + workspace;
230
- var cache = _this.getOrCreateSecuritySettingsEntry(scope).valid;
231
- var result = cache.get(url);
186
+ this.isDashboardPluginUrlValid = (url, workspace) => {
187
+ const scope = `plugins_${workspace}`;
188
+ const cache = this.getOrCreateSecuritySettingsEntry(scope).valid;
189
+ let result = cache.get(url);
232
190
  if (!result) {
233
- result = _super.prototype.isDashboardPluginUrlValid.call(_this, url, workspace).catch(function (e) {
191
+ result = super.isDashboardPluginUrlValid(url, workspace).catch((e) => {
234
192
  cache.delete(url);
235
193
  throw e;
236
194
  });
@@ -238,36 +196,33 @@ var WithSecuritySettingsCaching = /** @class */ (function (_super) {
238
196
  }
239
197
  return result;
240
198
  };
241
- _this.getOrCreateSecuritySettingsEntry = function (scope) {
242
- var cache = _this.ctx.caches.securitySettings;
243
- var cacheEntry = cache.get(scope);
199
+ this.getOrCreateSecuritySettingsEntry = (scope) => {
200
+ const cache = this.ctx.caches.securitySettings;
201
+ let cacheEntry = cache.get(scope);
244
202
  if (!cacheEntry) {
245
203
  cacheEntry = {
246
204
  valid: new LRUCache({
247
- maxSize: _this.ctx.config.maxSecuritySettingsOrgUrls,
248
- maxAge: _this.ctx.config.maxSecuritySettingsOrgUrlsAge,
205
+ max: this.ctx.config.maxSecuritySettingsOrgUrls,
206
+ ttl: this.ctx.config.maxSecuritySettingsOrgUrlsAge,
249
207
  }),
250
208
  };
251
209
  cache.set(scope, cacheEntry);
252
210
  }
253
211
  return cacheEntry;
254
212
  };
255
- return _this;
256
213
  }
257
- return WithSecuritySettingsCaching;
258
- }(DecoratedSecuritySettingsService));
259
- var WithWorkspaceSettingsCaching = /** @class */ (function (_super) {
260
- __extends(WithWorkspaceSettingsCaching, _super);
261
- function WithWorkspaceSettingsCaching(decorated, ctx, workspace) {
262
- var _this = _super.call(this, decorated) || this;
263
- _this.ctx = ctx;
264
- _this.workspace = workspace;
265
- _this.getSettings = function () {
266
- var cache = _this.getOrCreateWorkspaceEntry(_this.workspace).workspaceSettings;
267
- var cacheKey = _this.workspace;
268
- var workspaceSettings = cache.get(cacheKey);
214
+ }
215
+ class WithWorkspaceSettingsCaching extends DecoratedWorkspaceSettingsService {
216
+ constructor(decorated, ctx, workspace) {
217
+ super(decorated);
218
+ this.ctx = ctx;
219
+ this.workspace = workspace;
220
+ this.getSettings = () => {
221
+ const cache = this.getOrCreateWorkspaceEntry(this.workspace).workspaceSettings;
222
+ const cacheKey = this.workspace;
223
+ let workspaceSettings = cache.get(cacheKey);
269
224
  if (!workspaceSettings) {
270
- workspaceSettings = _super.prototype.getSettings.call(_this).catch(function (e) {
225
+ workspaceSettings = super.getSettings().catch((e) => {
271
226
  cache.delete(cacheKey);
272
227
  throw e;
273
228
  });
@@ -275,46 +230,40 @@ var WithWorkspaceSettingsCaching = /** @class */ (function (_super) {
275
230
  }
276
231
  return workspaceSettings;
277
232
  };
278
- _this.getOrCreateWorkspaceEntry = function (workspace) {
279
- var cache = _this.ctx.caches.workspaceSettings;
280
- var cacheEntry = cache.get(workspace);
233
+ this.getOrCreateWorkspaceEntry = (workspace) => {
234
+ const cache = this.ctx.caches.workspaceSettings;
235
+ let cacheEntry = cache.get(workspace);
281
236
  if (!cacheEntry) {
282
237
  cacheEntry = {
283
238
  userWorkspaceSettings: new LRUCache({
284
- maxSize: _this.ctx.config.maxWorkspaceSettings,
239
+ max: this.ctx.config.maxWorkspaceSettings,
285
240
  }),
286
241
  workspaceSettings: new LRUCache({
287
- maxSize: _this.ctx.config.maxWorkspaceSettings,
242
+ max: this.ctx.config.maxWorkspaceSettings,
288
243
  }),
289
244
  };
290
245
  cache.set(workspace, cacheEntry);
291
246
  }
292
247
  return cacheEntry;
293
248
  };
294
- return _this;
295
249
  }
296
- WithWorkspaceSettingsCaching.prototype.getSettingsForCurrentUser = function () {
297
- var cache = this.getOrCreateWorkspaceEntry(this.workspace).userWorkspaceSettings;
298
- var cacheKey = this.workspace; // we assume that the current user does not change over the life span of the backend instance
299
- var userWorkspaceSettings = cache.get(cacheKey);
250
+ getSettingsForCurrentUser() {
251
+ const cache = this.getOrCreateWorkspaceEntry(this.workspace).userWorkspaceSettings;
252
+ const cacheKey = this.workspace; // we assume that the current user does not change over the life span of the backend instance
253
+ let userWorkspaceSettings = cache.get(cacheKey);
300
254
  if (!userWorkspaceSettings) {
301
- userWorkspaceSettings = _super.prototype.getSettingsForCurrentUser.call(this).catch(function (e) {
255
+ userWorkspaceSettings = super.getSettingsForCurrentUser().catch((e) => {
302
256
  cache.delete(cacheKey);
303
257
  throw e;
304
258
  });
305
259
  cache.set(cacheKey, userWorkspaceSettings);
306
260
  }
307
261
  return userWorkspaceSettings;
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
- };
316
- return WithWorkspaceSettingsCaching;
317
- }(DecoratedWorkspaceSettingsService));
262
+ }
263
+ async setLocale(locale) {
264
+ return super.setLocale(locale);
265
+ }
266
+ }
318
267
  //
319
268
  // Attributes caching
320
269
  //
@@ -323,24 +272,24 @@ function refMatchesMdObject(ref, mdObject, type) {
323
272
  areObjRefsEqual(ref, idRef(mdObject.id, type)) ||
324
273
  areObjRefsEqual(ref, uriRef(mdObject.uri)));
325
274
  }
326
- var firstDefined = flow(compact, first);
275
+ const firstDefined = flow(compact, first);
327
276
  function elementsCacheKey(ref, settings) {
328
277
  return new SparkMD5().append(objRefToString(ref)).append(stringify(settings)).end();
329
278
  }
330
279
  function getOrCreateAttributeCache(ctx, workspace) {
331
- var cache = ctx.caches.workspaceAttributes;
332
- var cacheEntry = cache.get(workspace);
280
+ const cache = ctx.caches.workspaceAttributes;
281
+ let cacheEntry = cache.get(workspace);
333
282
  if (!cacheEntry) {
334
283
  cacheEntry = {
335
284
  displayForms: new LRUCache({
336
- maxSize: ctx.config.maxAttributeDisplayFormsPerWorkspace,
285
+ max: ctx.config.maxAttributeDisplayFormsPerWorkspace,
337
286
  }),
338
287
  attributesByDisplayForms: new LRUCache({
339
- maxSize: ctx.config.maxAttributesPerWorkspace,
288
+ max: ctx.config.maxAttributesPerWorkspace,
340
289
  }),
341
290
  attributeElementResults: cachingEnabled(ctx.config.maxAttributeElementResultsPerWorkspace)
342
291
  ? new LRUCache({
343
- maxSize: ctx.config.maxAttributeElementResultsPerWorkspace,
292
+ max: ctx.config.maxAttributeElementResultsPerWorkspace,
344
293
  })
345
294
  : undefined,
346
295
  };
@@ -348,70 +297,59 @@ function getOrCreateAttributeCache(ctx, workspace) {
348
297
  }
349
298
  return cacheEntry;
350
299
  }
351
- var CachedElementsQuery = /** @class */ (function (_super) {
352
- __extends(CachedElementsQuery, _super);
353
- function CachedElementsQuery(decorated, ctx, workspace, ref, settings) {
354
- if (settings === void 0) { settings = {}; }
355
- var _this = _super.call(this, decorated, settings) || this;
356
- _this.ctx = ctx;
357
- _this.workspace = workspace;
358
- _this.ref = ref;
359
- _this.query = function () { return __awaiter(_this, void 0, void 0, function () {
360
- var canCache, cache, cacheKey, result;
300
+ class CachedElementsQuery extends DecoratedElementsQuery {
301
+ constructor(decorated, ctx, workspace, ref, settings = {}) {
302
+ super(decorated, settings);
303
+ this.ctx = ctx;
304
+ this.workspace = workspace;
305
+ this.ref = ref;
306
+ this.query = async () => {
361
307
  var _a;
362
- return __generator(this, function (_b) {
363
- canCache = !((_a = this.settings.options) === null || _a === void 0 ? void 0 : _a.filter);
364
- if (!canCache) {
365
- return [2 /*return*/, _super.prototype.query.call(this)];
366
- }
367
- cache = getOrCreateAttributeCache(this.ctx, this.workspace).attributeElementResults;
368
- invariant(cache, "inconsistent attribute element cache config");
369
- cacheKey = elementsCacheKey(this.ref, this.settings);
370
- result = cache.get(cacheKey);
371
- if (!result) {
372
- result = _super.prototype.query.call(this).catch(function (e) {
373
- cache.delete(cacheKey);
374
- throw e;
375
- });
376
- cache.set(cacheKey, result);
377
- }
378
- return [2 /*return*/, result];
379
- });
380
- }); };
381
- return _this;
308
+ const canCache = !((_a = this.settings.options) === null || _a === void 0 ? void 0 : _a.filter);
309
+ if (!canCache) {
310
+ return super.query();
311
+ }
312
+ const cache = getOrCreateAttributeCache(this.ctx, this.workspace).attributeElementResults;
313
+ invariant(cache, "inconsistent attribute element cache config");
314
+ const cacheKey = elementsCacheKey(this.ref, this.settings);
315
+ let result = cache.get(cacheKey);
316
+ if (!result) {
317
+ result = super.query().catch((e) => {
318
+ cache.delete(cacheKey);
319
+ throw e;
320
+ });
321
+ cache.set(cacheKey, result);
322
+ }
323
+ return result;
324
+ };
382
325
  }
383
- CachedElementsQuery.prototype.createNew = function (decorated, settings) {
326
+ createNew(decorated, settings) {
384
327
  return new CachedElementsQuery(decorated, this.ctx, this.workspace, this.ref, settings);
385
- };
386
- return CachedElementsQuery;
387
- }(DecoratedElementsQuery));
388
- var CachedElementsQueryFactory = /** @class */ (function (_super) {
389
- __extends(CachedElementsQueryFactory, _super);
390
- function CachedElementsQueryFactory(decorated, ctx, workspace) {
391
- var _this = _super.call(this, decorated) || this;
392
- _this.ctx = ctx;
393
- _this.workspace = workspace;
394
- return _this;
395
328
  }
396
- CachedElementsQueryFactory.prototype.forDisplayForm = function (ref) {
397
- var decorated = this.decorated.forDisplayForm(ref);
329
+ }
330
+ class CachedElementsQueryFactory extends DecoratedElementsQueryFactory {
331
+ constructor(decorated, ctx, workspace) {
332
+ super(decorated);
333
+ this.ctx = ctx;
334
+ this.workspace = workspace;
335
+ }
336
+ forDisplayForm(ref) {
337
+ const decorated = this.decorated.forDisplayForm(ref);
398
338
  return new CachedElementsQuery(decorated, this.ctx, this.workspace, ref);
399
- };
400
- return CachedElementsQueryFactory;
401
- }(DecoratedElementsQueryFactory));
402
- var WithAttributesCaching = /** @class */ (function (_super) {
403
- __extends(WithAttributesCaching, _super);
404
- function WithAttributesCaching(decorated, ctx, workspace) {
405
- var _this = _super.call(this, decorated) || this;
406
- _this.ctx = ctx;
407
- _this.workspace = workspace;
408
- _this.getAttributeDisplayForm = function (ref) {
409
- var cache = getOrCreateAttributeCache(_this.ctx, _this.workspace).displayForms;
410
- var idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
411
- var uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
412
- var cacheItem = firstDefined([idCacheKey, uriCacheKey].map(function (key) { return key && cache.get(key); }));
339
+ }
340
+ }
341
+ class WithAttributesCaching extends DecoratedWorkspaceAttributesService {
342
+ constructor(decorated, ctx, workspace) {
343
+ super(decorated);
344
+ this.ctx = ctx;
345
+ this.workspace = workspace;
346
+ this.getAttributeDisplayForm = (ref) => {
347
+ const cache = getOrCreateAttributeCache(this.ctx, this.workspace).displayForms;
348
+ const idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
349
+ const uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
350
+ let cacheItem = firstDefined([idCacheKey, uriCacheKey].map((key) => key && cache.get(key)));
413
351
  if (!cacheItem) {
414
- cacheItem = _super.prototype.getAttributeDisplayForm.call(_this, ref).catch(function (e) {
352
+ cacheItem = super.getAttributeDisplayForm(ref).catch((e) => {
415
353
  if (idCacheKey) {
416
354
  cache.delete(idCacheKey);
417
355
  }
@@ -429,136 +367,121 @@ var WithAttributesCaching = /** @class */ (function (_super) {
429
367
  }
430
368
  return cacheItem;
431
369
  };
432
- _this.getAttributeDisplayForms = function (refs) { return __awaiter(_this, void 0, void 0, function () {
433
- var cache, refsWithCacheResults, _a, withCacheHits, withoutCacheHits, refsToLoad, _b, alreadyInCache, loadedFromServer, loadedRefs, outputRefs, candidates;
434
- return __generator(this, function (_c) {
435
- switch (_c.label) {
436
- case 0:
437
- cache = getOrCreateAttributeCache(this.ctx, this.workspace).displayForms;
438
- refsWithCacheResults = refs.map(function (ref) {
439
- var idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
440
- var uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
441
- var cacheHit = firstDefined([idCacheKey, uriCacheKey].map(function (key) { return key && cache.get(key); }));
442
- return { ref: ref, cacheHit: cacheHit };
443
- });
444
- _a = partition(refsWithCacheResults, function (_a) {
445
- var cacheHit = _a.cacheHit;
446
- return !!cacheHit;
447
- }), withCacheHits = _a[0], withoutCacheHits = _a[1];
448
- refsToLoad = withoutCacheHits.map(function (item) { return item.ref; });
449
- return [4 /*yield*/, Promise.all([
450
- // await the stuff from cache, we need the data available (we cannot just return the promises)
451
- Promise.all(withCacheHits.map(function (item) { return item.cacheHit; })),
452
- // load items not in cache using the bulk operation
453
- this.decorated.getAttributeDisplayForms(refsToLoad),
454
- ])];
455
- case 1:
456
- _b = _c.sent(), alreadyInCache = _b[0], loadedFromServer = _b[1];
457
- // save newly loaded to cache for future reference
458
- loadedFromServer.forEach(function (loaded) {
459
- var promisifiedResult = Promise.resolve(loaded);
460
- // save the cache item for both types of refs
461
- cache.set(loaded.id, promisifiedResult);
462
- cache.set(loaded.uri, promisifiedResult);
463
- });
464
- loadedRefs = loadedFromServer.map(function (item) { return item.ref; });
465
- outputRefs = this.ctx.capabilities.allowsInconsistentRelations
466
- ? skipMissingReferences(refs, refsToLoad, loadedRefs)
467
- : refs;
468
- candidates = __spreadArrays(loadedFromServer, alreadyInCache);
469
- return [2 /*return*/, outputRefs.map(function (ref) {
470
- var match = candidates.find(function (item) { return refMatchesMdObject(ref, item, "displayForm"); });
471
- // if this bombs, some data got lost in the process
472
- invariant(match);
473
- return match;
474
- })];
475
- }
370
+ this.getAttributeDisplayForms = async (refs) => {
371
+ const cache = getOrCreateAttributeCache(this.ctx, this.workspace).displayForms;
372
+ // grab a reference to the cache results as soon as possible in case they would get evicted while loading the ones with missing data in cache
373
+ // then would might not be able to call cache.get again and be guaranteed to get the data
374
+ const refsWithCacheResults = refs.map((ref) => {
375
+ const idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
376
+ const uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
377
+ const cacheHit = firstDefined([idCacheKey, uriCacheKey].map((key) => key && cache.get(key)));
378
+ return { ref, cacheHit };
476
379
  });
477
- }); };
478
- _this.getAttributeByDisplayForm = function (ref) { return __awaiter(_this, void 0, void 0, function () {
479
- var cache, idCacheKey, uriCacheKey, cacheItem;
480
- return __generator(this, function (_a) {
481
- cache = getOrCreateAttributeCache(this.ctx, this.workspace).attributesByDisplayForms;
482
- idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
483
- uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
484
- cacheItem = firstDefined([idCacheKey, uriCacheKey].map(function (key) { return key && cache.get(key); }));
485
- if (!cacheItem) {
486
- // eslint-disable-next-line sonarjs/no-identical-functions
487
- cacheItem = _super.prototype.getAttributeByDisplayForm.call(this, ref).catch(function (e) {
488
- if (idCacheKey) {
489
- cache.delete(idCacheKey);
490
- }
491
- if (uriCacheKey) {
492
- cache.delete(uriCacheKey);
493
- }
494
- throw e;
495
- });
380
+ const [withCacheHits, withoutCacheHits] = partition(refsWithCacheResults, ({ cacheHit }) => !!cacheHit);
381
+ const refsToLoad = withoutCacheHits.map((item) => item.ref);
382
+ const [alreadyInCache, loadedFromServer] = await Promise.all([
383
+ // await the stuff from cache, we need the data available (we cannot just return the promises)
384
+ Promise.all(withCacheHits.map((item) => item.cacheHit)),
385
+ // load items not in cache using the bulk operation
386
+ this.decorated.getAttributeDisplayForms(refsToLoad),
387
+ ]);
388
+ // save newly loaded to cache for future reference
389
+ loadedFromServer.forEach((loaded) => {
390
+ const promisifiedResult = Promise.resolve(loaded);
391
+ // save the cache item for both types of refs
392
+ cache.set(loaded.id, promisifiedResult);
393
+ cache.set(loaded.uri, promisifiedResult);
394
+ });
395
+ const loadedRefs = loadedFromServer.map((item) => item.ref);
396
+ const outputRefs = this.ctx.capabilities.allowsInconsistentRelations
397
+ ? skipMissingReferences(refs, refsToLoad, loadedRefs)
398
+ : refs;
399
+ // reconstruct the original ordering
400
+ const candidates = [...loadedFromServer, ...alreadyInCache];
401
+ return outputRefs.map((ref) => {
402
+ const match = candidates.find((item) => refMatchesMdObject(ref, item, "displayForm"));
403
+ // if this bombs, some data got lost in the process
404
+ invariant(match);
405
+ return match;
406
+ });
407
+ };
408
+ this.getAttributeByDisplayForm = async (ref) => {
409
+ const cache = getOrCreateAttributeCache(this.ctx, this.workspace).attributesByDisplayForms;
410
+ const idCacheKey = isIdentifierRef(ref) ? ref.identifier : undefined;
411
+ const uriCacheKey = isUriRef(ref) ? ref.uri : undefined;
412
+ let cacheItem = firstDefined([idCacheKey, uriCacheKey].map((key) => key && cache.get(key)));
413
+ if (!cacheItem) {
414
+ // eslint-disable-next-line sonarjs/no-identical-functions
415
+ cacheItem = super.getAttributeByDisplayForm(ref).catch((e) => {
496
416
  if (idCacheKey) {
497
- cache.set(idCacheKey, cacheItem);
417
+ cache.delete(idCacheKey);
498
418
  }
499
419
  if (uriCacheKey) {
500
- cache.set(uriCacheKey, cacheItem);
420
+ cache.delete(uriCacheKey);
501
421
  }
422
+ throw e;
423
+ });
424
+ if (idCacheKey) {
425
+ cache.set(idCacheKey, cacheItem);
502
426
  }
503
- return [2 /*return*/, cacheItem];
504
- });
505
- }); };
506
- return _this;
427
+ if (uriCacheKey) {
428
+ cache.set(uriCacheKey, cacheItem);
429
+ }
430
+ }
431
+ return cacheItem;
432
+ };
507
433
  }
508
- WithAttributesCaching.prototype.elements = function () {
509
- var decorated = this.decorated.elements();
434
+ elements() {
435
+ const decorated = this.decorated.elements();
510
436
  return cachingEnabled(this.ctx.config.maxAttributeElementResultsPerWorkspace)
511
437
  ? new CachedElementsQueryFactory(decorated, this.ctx, this.workspace)
512
438
  : decorated;
513
- };
514
- return WithAttributesCaching;
515
- }(DecoratedWorkspaceAttributesService));
439
+ }
440
+ }
516
441
  //
517
442
  //
518
443
  //
519
444
  function cachedExecutions(ctx) {
520
- return function (original) {
521
- return new DecoratedExecutionFactory(original, function (execution) { return new WithExecutionCaching(execution, ctx); });
522
- };
445
+ return (original) => new DecoratedExecutionFactory(original, (execution) => new WithExecutionCaching(execution, ctx));
523
446
  }
524
447
  function cachedCatalog(ctx) {
525
- return function (original) { return new WithCatalogCaching(original, ctx); };
448
+ return (original) => new WithCatalogCaching(original, ctx);
526
449
  }
527
450
  function cachedSecuritySettings(ctx) {
528
- return function (original) { return new WithSecuritySettingsCaching(original, ctx); };
451
+ return (original) => new WithSecuritySettingsCaching(original, ctx);
529
452
  }
530
453
  function cachedWorkspaceSettings(ctx) {
531
- return function (original, workspace) { return new WithWorkspaceSettingsCaching(original, ctx, workspace); };
454
+ return (original, workspace) => new WithWorkspaceSettingsCaching(original, ctx, workspace);
532
455
  }
533
456
  function cachedAttributes(ctx) {
534
- return function (original, workspace) { return new WithAttributesCaching(original, ctx, workspace); };
457
+ return (original, workspace) => new WithAttributesCaching(original, ctx, workspace);
535
458
  }
536
459
  function cachingEnabled(desiredSize) {
537
460
  return desiredSize !== undefined && desiredSize > 0;
538
461
  }
539
462
  function cacheControl(ctx) {
540
- var control = {
541
- resetExecutions: function () {
463
+ const control = {
464
+ resetExecutions: () => {
542
465
  var _a;
543
466
  (_a = ctx.caches.execution) === null || _a === void 0 ? void 0 : _a.clear();
544
467
  },
545
- resetCatalogs: function () {
468
+ resetCatalogs: () => {
546
469
  var _a;
547
470
  (_a = ctx.caches.workspaceCatalogs) === null || _a === void 0 ? void 0 : _a.clear();
548
471
  },
549
- resetSecuritySettings: function () {
472
+ resetSecuritySettings: () => {
550
473
  var _a;
551
474
  (_a = ctx.caches.securitySettings) === null || _a === void 0 ? void 0 : _a.clear();
552
475
  },
553
- resetAttributes: function () {
476
+ resetAttributes: () => {
554
477
  var _a;
555
478
  (_a = ctx.caches.workspaceAttributes) === null || _a === void 0 ? void 0 : _a.clear();
556
479
  },
557
- resetWorkspaceSettings: function () {
480
+ resetWorkspaceSettings: () => {
558
481
  var _a;
559
482
  (_a = ctx.caches.workspaceSettings) === null || _a === void 0 ? void 0 : _a.clear();
560
483
  },
561
- resetAll: function () {
484
+ resetAll: () => {
562
485
  control.resetExecutions();
563
486
  control.resetCatalogs();
564
487
  control.resetSecuritySettings();
@@ -569,7 +492,7 @@ function cacheControl(ctx) {
569
492
  return control;
570
493
  }
571
494
  function assertPositiveOrUndefined(value, valueName) {
572
- invariant(value === undefined || value > 0, valueName + " to cache must be positive or undefined, got: " + value);
495
+ invariant(value === undefined || value > 0, `${valueName} to cache must be positive or undefined, got: ${value}`);
573
496
  }
574
497
  /**
575
498
  * These are the recommended settings for the backend caching.
@@ -579,7 +502,7 @@ function assertPositiveOrUndefined(value, valueName) {
579
502
  *
580
503
  * @public
581
504
  */
582
- export var RecommendedCachingConfiguration = {
505
+ export const RecommendedCachingConfiguration = {
583
506
  maxExecutions: 10,
584
507
  maxResultWindows: 5,
585
508
  maxCatalogs: 1,
@@ -606,46 +529,46 @@ export function withCaching(realBackend, config) {
606
529
  assertPositiveOrUndefined(config.maxCatalogOptions, "maxCatalogOptions");
607
530
  assertPositiveOrUndefined(config.maxSecuritySettingsOrgUrls, "maxSecuritySettingsOrgUrls");
608
531
  assertPositiveOrUndefined(config.maxSecuritySettingsOrgUrlsAge, "maxSecuritySettingsOrgUrlsAge");
609
- var execCaching = cachingEnabled(config.maxExecutions);
610
- var catalogCaching = cachingEnabled(config.maxCatalogs);
611
- var securitySettingsCaching = cachingEnabled(config.maxSecuritySettingsOrgs);
612
- var attributeCaching = cachingEnabled(config.maxAttributeWorkspaces);
613
- var workspaceSettingsCaching = cachingEnabled(config.maxWorkspaceSettings);
614
- var ctx = {
532
+ const execCaching = cachingEnabled(config.maxExecutions);
533
+ const catalogCaching = cachingEnabled(config.maxCatalogs);
534
+ const securitySettingsCaching = cachingEnabled(config.maxSecuritySettingsOrgs);
535
+ const attributeCaching = cachingEnabled(config.maxAttributeWorkspaces);
536
+ const workspaceSettingsCaching = cachingEnabled(config.maxWorkspaceSettings);
537
+ const ctx = {
615
538
  caches: {
616
- execution: execCaching ? new LRUCache({ maxSize: config.maxExecutions }) : undefined,
617
- workspaceCatalogs: catalogCaching ? new LRUCache({ maxSize: config.maxCatalogs }) : undefined,
539
+ execution: execCaching ? new LRUCache({ max: config.maxExecutions }) : undefined,
540
+ workspaceCatalogs: catalogCaching ? new LRUCache({ max: config.maxCatalogs }) : undefined,
618
541
  securitySettings: securitySettingsCaching
619
- ? new LRUCache({ maxSize: config.maxSecuritySettingsOrgs })
542
+ ? new LRUCache({ max: config.maxSecuritySettingsOrgs })
620
543
  : undefined,
621
544
  workspaceAttributes: attributeCaching
622
- ? new LRUCache({ maxSize: config.maxAttributeWorkspaces })
545
+ ? new LRUCache({ max: config.maxAttributeWorkspaces })
623
546
  : undefined,
624
547
  workspaceSettings: workspaceSettingsCaching
625
- ? new LRUCache({ maxSize: config.maxWorkspaceSettings })
548
+ ? new LRUCache({ max: config.maxWorkspaceSettings })
626
549
  : undefined,
627
550
  },
628
- config: config,
551
+ config,
629
552
  capabilities: realBackend.capabilities,
630
553
  };
631
- var execution = execCaching ? cachedExecutions(ctx) : identity;
632
- var catalog = catalogCaching ? cachedCatalog(ctx) : identity;
633
- var securitySettings = securitySettingsCaching ? cachedSecuritySettings(ctx) : identity;
634
- var attributes = attributeCaching ? cachedAttributes(ctx) : identity;
635
- var workspaceSettings = workspaceSettingsCaching ? cachedWorkspaceSettings(ctx) : identity;
554
+ const execution = execCaching ? cachedExecutions(ctx) : identity;
555
+ const catalog = catalogCaching ? cachedCatalog(ctx) : identity;
556
+ const securitySettings = securitySettingsCaching ? cachedSecuritySettings(ctx) : identity;
557
+ const attributes = attributeCaching ? cachedAttributes(ctx) : identity;
558
+ const workspaceSettings = workspaceSettingsCaching ? cachedWorkspaceSettings(ctx) : identity;
636
559
  if (config.onCacheReady) {
637
560
  config.onCacheReady(cacheControl(ctx));
638
561
  }
639
562
  return decoratedBackend(realBackend, {
640
- execution: execution,
641
- catalog: catalog,
642
- securitySettings: securitySettings,
643
- attributes: attributes,
644
- workspaceSettings: workspaceSettings,
563
+ execution,
564
+ catalog,
565
+ securitySettings,
566
+ attributes,
567
+ workspaceSettings,
645
568
  });
646
569
  }
647
570
  function skipMissingReferences(requestedRefs, refsToLoad, refsLoadedFromServer) {
648
- var missingRefs = refsToLoad.filter(function (ref) { return !refsLoadedFromServer.some(function (loadedRef) { return areObjRefsEqual(loadedRef, ref); }); });
649
- return requestedRefs.filter(function (inputRef) { return !missingRefs.some(function (missingRef) { return areObjRefsEqual(missingRef, inputRef); }); });
571
+ const missingRefs = refsToLoad.filter((ref) => !refsLoadedFromServer.some((loadedRef) => areObjRefsEqual(loadedRef, ref)));
572
+ return requestedRefs.filter((inputRef) => !missingRefs.some((missingRef) => areObjRefsEqual(missingRef, inputRef)));
650
573
  }
651
574
  //# sourceMappingURL=index.js.map