@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.
- package/dist/cachingBackend/index.js +304 -380
- package/dist/cachingBackend/index.js.map +1 -1
- package/dist/convertors/fromBackend/afm/result.js +3 -3
- package/dist/convertors/fromBackend/afm/result.js.map +1 -1
- package/dist/customBackend/execution.js +77 -92
- package/dist/customBackend/execution.js.map +1 -1
- package/dist/customBackend/index.js +78 -114
- package/dist/customBackend/index.js.map +1 -1
- package/dist/customBackend/workspace.js +39 -40
- package/dist/customBackend/workspace.js.map +1 -1
- package/dist/decoratedBackend/attributes.js +21 -22
- package/dist/decoratedBackend/attributes.js.map +1 -1
- package/dist/decoratedBackend/catalog.js +38 -50
- package/dist/decoratedBackend/catalog.js.map +1 -1
- package/dist/decoratedBackend/dashboards.js +61 -62
- package/dist/decoratedBackend/dashboards.js.map +1 -1
- package/dist/decoratedBackend/elements.js +47 -70
- package/dist/decoratedBackend/elements.js.map +1 -1
- package/dist/decoratedBackend/execution.js +62 -79
- package/dist/decoratedBackend/execution.js.map +1 -1
- package/dist/decoratedBackend/index.js +90 -104
- package/dist/decoratedBackend/index.js.map +1 -1
- package/dist/decoratedBackend/securitySettings.js +7 -8
- package/dist/decoratedBackend/securitySettings.js.map +1 -1
- package/dist/decoratedBackend/workspaceSettings.js +12 -26
- package/dist/decoratedBackend/workspaceSettings.js.map +1 -1
- package/dist/dummyBackend/index.js +347 -391
- package/dist/dummyBackend/index.js.map +1 -1
- package/dist/eventingBackend/index.js +42 -49
- package/dist/eventingBackend/index.js.map +1 -1
- package/dist/ldmFactories/builder.js +14 -16
- package/dist/ldmFactories/builder.js.map +1 -1
- package/dist/ldmFactories/catalog/attributeFactory.js +22 -32
- package/dist/ldmFactories/catalog/attributeFactory.js.map +1 -1
- package/dist/ldmFactories/catalog/dateDatasetFactory.js +25 -41
- package/dist/ldmFactories/catalog/dateDatasetFactory.js.map +1 -1
- package/dist/ldmFactories/catalog/factFactory.js +11 -19
- package/dist/ldmFactories/catalog/factFactory.js.map +1 -1
- package/dist/ldmFactories/catalog/groupFactory.js +14 -27
- package/dist/ldmFactories/catalog/groupFactory.js.map +1 -1
- package/dist/ldmFactories/catalog/measureFactory.js +15 -25
- package/dist/ldmFactories/catalog/measureFactory.js.map +1 -1
- package/dist/ldmFactories/dashboard/insightWidgetFactory.js +20 -27
- package/dist/ldmFactories/dashboard/insightWidgetFactory.js.map +1 -1
- package/dist/ldmFactories/dashboard/kpiWidgetFactory.js +24 -34
- package/dist/ldmFactories/dashboard/kpiWidgetFactory.js.map +1 -1
- package/dist/ldmFactories/dashboard/widgetFactory.js +20 -39
- package/dist/ldmFactories/dashboard/widgetFactory.js.map +1 -1
- package/dist/ldmFactories/metadata/attributeFactory.js +13 -21
- package/dist/ldmFactories/metadata/attributeFactory.js.map +1 -1
- package/dist/ldmFactories/metadata/dashboardFactory.js +7 -15
- package/dist/ldmFactories/metadata/dashboardFactory.js.map +1 -1
- package/dist/ldmFactories/metadata/dataSetFactory.js +7 -15
- package/dist/ldmFactories/metadata/dataSetFactory.js.map +1 -1
- package/dist/ldmFactories/metadata/displayFormFactory.js +13 -21
- package/dist/ldmFactories/metadata/displayFormFactory.js.map +1 -1
- package/dist/ldmFactories/metadata/factFactory.js +7 -15
- package/dist/ldmFactories/metadata/factFactory.js.map +1 -1
- package/dist/ldmFactories/metadata/factory.js +17 -23
- package/dist/ldmFactories/metadata/factory.js.map +1 -1
- package/dist/ldmFactories/metadata/measureFactory.js +13 -21
- package/dist/ldmFactories/metadata/measureFactory.js.map +1 -1
- package/dist/ldmFactories/metadata/variableFactory.js +7 -15
- package/dist/ldmFactories/metadata/variableFactory.js.map +1 -1
- package/dist/normalizingBackend/index.js +71 -96
- package/dist/normalizingBackend/index.js.map +1 -1
- package/dist/normalizingBackend/normalizer.d.ts.map +1 -1
- package/dist/normalizingBackend/normalizer.js +130 -138
- package/dist/normalizingBackend/normalizer.js.map +1 -1
- package/dist/toolkit/auth.js +47 -60
- package/dist/toolkit/auth.js.map +1 -1
- package/dist/toolkit/execution.js +40 -52
- package/dist/toolkit/execution.js.map +1 -1
- package/dist/toolkit/paging.js +77 -146
- package/dist/toolkit/paging.js.map +1 -1
- package/dist/toolkit/pluginUrlValidation.js +9 -9
- package/dist/toolkit/pluginUrlValidation.js.map +1 -1
- package/dist/workspaceSettingsBackend/index.js +23 -46
- package/dist/workspaceSettingsBackend/index.js.map +1 -1
- package/esm/cachingBackend/index.js +281 -358
- package/esm/cachingBackend/index.js.map +1 -1
- package/esm/convertors/fromBackend/afm/result.js +3 -3
- package/esm/convertors/fromBackend/afm/result.js.map +1 -1
- package/esm/customBackend/execution.js +72 -89
- package/esm/customBackend/execution.js.map +1 -1
- package/esm/customBackend/index.js +75 -112
- package/esm/customBackend/index.js.map +1 -1
- package/esm/customBackend/workspace.js +37 -39
- package/esm/customBackend/workspace.js.map +1 -1
- package/esm/decoratedBackend/attributes.js +21 -23
- package/esm/decoratedBackend/attributes.js.map +1 -1
- package/esm/decoratedBackend/catalog.js +36 -51
- package/esm/decoratedBackend/catalog.js.map +1 -1
- package/esm/decoratedBackend/dashboards.js +61 -63
- package/esm/decoratedBackend/dashboards.js.map +1 -1
- package/esm/decoratedBackend/elements.js +47 -73
- package/esm/decoratedBackend/elements.js.map +1 -1
- package/esm/decoratedBackend/execution.js +60 -81
- package/esm/decoratedBackend/execution.js.map +1 -1
- package/esm/decoratedBackend/index.js +88 -103
- package/esm/decoratedBackend/index.js.map +1 -1
- package/esm/decoratedBackend/securitySettings.js +7 -9
- package/esm/decoratedBackend/securitySettings.js.map +1 -1
- package/esm/decoratedBackend/workspaceSettings.js +12 -27
- package/esm/decoratedBackend/workspaceSettings.js.map +1 -1
- package/esm/dummyBackend/index.js +342 -387
- package/esm/dummyBackend/index.js.map +1 -1
- package/esm/eventingBackend/index.js +37 -45
- package/esm/eventingBackend/index.js.map +1 -1
- package/esm/ldmFactories/builder.js +14 -17
- package/esm/ldmFactories/builder.js.map +1 -1
- package/esm/ldmFactories/catalog/attributeFactory.js +15 -27
- package/esm/ldmFactories/catalog/attributeFactory.js.map +1 -1
- package/esm/ldmFactories/catalog/dateDatasetFactory.js +18 -37
- package/esm/ldmFactories/catalog/dateDatasetFactory.js.map +1 -1
- package/esm/ldmFactories/catalog/factFactory.js +5 -15
- package/esm/ldmFactories/catalog/factFactory.js.map +1 -1
- package/esm/ldmFactories/catalog/groupFactory.js +11 -27
- package/esm/ldmFactories/catalog/groupFactory.js.map +1 -1
- package/esm/ldmFactories/catalog/measureFactory.js +9 -21
- package/esm/ldmFactories/catalog/measureFactory.js.map +1 -1
- package/esm/ldmFactories/dashboard/insightWidgetFactory.js +16 -25
- package/esm/ldmFactories/dashboard/insightWidgetFactory.js.map +1 -1
- package/esm/ldmFactories/dashboard/kpiWidgetFactory.js +19 -31
- package/esm/ldmFactories/dashboard/kpiWidgetFactory.js.map +1 -1
- package/esm/ldmFactories/dashboard/widgetFactory.js +19 -39
- package/esm/ldmFactories/dashboard/widgetFactory.js.map +1 -1
- package/esm/ldmFactories/metadata/attributeFactory.js +9 -19
- package/esm/ldmFactories/metadata/attributeFactory.js.map +1 -1
- package/esm/ldmFactories/metadata/dashboardFactory.js +3 -13
- package/esm/ldmFactories/metadata/dashboardFactory.js.map +1 -1
- package/esm/ldmFactories/metadata/dataSetFactory.js +3 -13
- package/esm/ldmFactories/metadata/dataSetFactory.js.map +1 -1
- package/esm/ldmFactories/metadata/displayFormFactory.js +9 -19
- package/esm/ldmFactories/metadata/displayFormFactory.js.map +1 -1
- package/esm/ldmFactories/metadata/factFactory.js +3 -13
- package/esm/ldmFactories/metadata/factFactory.js.map +1 -1
- package/esm/ldmFactories/metadata/factory.js +16 -23
- package/esm/ldmFactories/metadata/factory.js.map +1 -1
- package/esm/ldmFactories/metadata/measureFactory.js +9 -19
- package/esm/ldmFactories/metadata/measureFactory.js.map +1 -1
- package/esm/ldmFactories/metadata/variableFactory.js +3 -13
- package/esm/ldmFactories/metadata/variableFactory.js.map +1 -1
- package/esm/normalizingBackend/index.js +64 -90
- package/esm/normalizingBackend/index.js.map +1 -1
- package/esm/normalizingBackend/normalizer.d.ts.map +1 -1
- package/esm/normalizingBackend/normalizer.js +125 -136
- package/esm/normalizingBackend/normalizer.js.map +1 -1
- package/esm/toolkit/auth.js +47 -63
- package/esm/toolkit/auth.js.map +1 -1
- package/esm/toolkit/execution.js +38 -53
- package/esm/toolkit/execution.js.map +1 -1
- package/esm/toolkit/paging.js +72 -144
- package/esm/toolkit/paging.js.map +1 -1
- package/esm/toolkit/pluginUrlValidation.js +8 -8
- package/esm/toolkit/pluginUrlValidation.js.map +1 -1
- package/esm/workspaceSettingsBackend/index.js +19 -43
- package/esm/workspaceSettingsBackend/index.js.map +1 -1
- 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
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
115
|
-
|
|
78
|
+
this.withSanitizedDefinition = (original) => {
|
|
79
|
+
return new DefinitionSanitizingDataView(original, this);
|
|
80
|
+
};
|
|
81
|
+
this.definition = definitionOverride;
|
|
116
82
|
}
|
|
117
|
-
|
|
118
|
-
}(DecoratedExecutionResult));
|
|
83
|
+
}
|
|
119
84
|
function windowKey(offset, size) {
|
|
120
|
-
return
|
|
85
|
+
return `o(${offset.join(",")})_s(${size.join(",")})`;
|
|
121
86
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
98
|
+
return this.allData;
|
|
135
99
|
};
|
|
136
|
-
|
|
137
|
-
if (!
|
|
138
|
-
return
|
|
100
|
+
this.readWindow = (offset, size) => {
|
|
101
|
+
if (!this.windows) {
|
|
102
|
+
return super.readWindow(offset, size);
|
|
139
103
|
}
|
|
140
|
-
|
|
141
|
-
|
|
104
|
+
const cacheKey = windowKey(offset, size);
|
|
105
|
+
let window = this.windows.get(cacheKey);
|
|
142
106
|
if (!window) {
|
|
143
|
-
window =
|
|
144
|
-
if (
|
|
145
|
-
|
|
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
|
-
|
|
113
|
+
this.windows.set(cacheKey, window);
|
|
150
114
|
}
|
|
151
115
|
return window;
|
|
152
116
|
};
|
|
153
|
-
if (cachingEnabled(
|
|
154
|
-
|
|
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
|
-
|
|
159
|
-
}(DecoratedExecutionResult));
|
|
121
|
+
}
|
|
160
122
|
//
|
|
161
123
|
// Catalog caching
|
|
162
124
|
//
|
|
163
125
|
function optionsKey(options) {
|
|
164
126
|
return stringify(options);
|
|
165
127
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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 =
|
|
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
|
-
|
|
185
|
-
return new WithCatalogCaching(decorated,
|
|
145
|
+
this.createNew = (decorated) => {
|
|
146
|
+
return new WithCatalogCaching(decorated, this.ctx);
|
|
186
147
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
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
|
-
|
|
203
|
-
}(DecoratedWorkspaceCatalogFactory));
|
|
162
|
+
}
|
|
204
163
|
//
|
|
205
164
|
// Organization security settings caching
|
|
206
165
|
//
|
|
207
166
|
function validUrlInContextKey(url, context) {
|
|
208
|
-
return context
|
|
167
|
+
return `${context}_${stringify(url)}`;
|
|
209
168
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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 =
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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 =
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
248
|
-
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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 =
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
239
|
+
max: this.ctx.config.maxWorkspaceSettings,
|
|
285
240
|
}),
|
|
286
241
|
workspaceSettings: new LRUCache({
|
|
287
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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 =
|
|
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
|
-
|
|
310
|
-
return
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
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
|
-
|
|
332
|
-
|
|
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
|
-
|
|
285
|
+
max: ctx.config.maxAttributeDisplayFormsPerWorkspace,
|
|
337
286
|
}),
|
|
338
287
|
attributesByDisplayForms: new LRUCache({
|
|
339
|
-
|
|
288
|
+
max: ctx.config.maxAttributesPerWorkspace,
|
|
340
289
|
}),
|
|
341
290
|
attributeElementResults: cachingEnabled(ctx.config.maxAttributeElementResultsPerWorkspace)
|
|
342
291
|
? new LRUCache({
|
|
343
|
-
|
|
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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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
|
-
|
|
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
|
-
|
|
397
|
-
|
|
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
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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 =
|
|
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
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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.
|
|
417
|
+
cache.delete(idCacheKey);
|
|
498
418
|
}
|
|
499
419
|
if (uriCacheKey) {
|
|
500
|
-
cache.
|
|
420
|
+
cache.delete(uriCacheKey);
|
|
501
421
|
}
|
|
422
|
+
throw e;
|
|
423
|
+
});
|
|
424
|
+
if (idCacheKey) {
|
|
425
|
+
cache.set(idCacheKey, cacheItem);
|
|
502
426
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
427
|
+
if (uriCacheKey) {
|
|
428
|
+
cache.set(uriCacheKey, cacheItem);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return cacheItem;
|
|
432
|
+
};
|
|
507
433
|
}
|
|
508
|
-
|
|
509
|
-
|
|
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
|
-
|
|
515
|
-
}(DecoratedWorkspaceAttributesService));
|
|
439
|
+
}
|
|
440
|
+
}
|
|
516
441
|
//
|
|
517
442
|
//
|
|
518
443
|
//
|
|
519
444
|
function cachedExecutions(ctx) {
|
|
520
|
-
return
|
|
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
|
|
448
|
+
return (original) => new WithCatalogCaching(original, ctx);
|
|
526
449
|
}
|
|
527
450
|
function cachedSecuritySettings(ctx) {
|
|
528
|
-
return
|
|
451
|
+
return (original) => new WithSecuritySettingsCaching(original, ctx);
|
|
529
452
|
}
|
|
530
453
|
function cachedWorkspaceSettings(ctx) {
|
|
531
|
-
return
|
|
454
|
+
return (original, workspace) => new WithWorkspaceSettingsCaching(original, ctx, workspace);
|
|
532
455
|
}
|
|
533
456
|
function cachedAttributes(ctx) {
|
|
534
|
-
return
|
|
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
|
-
|
|
541
|
-
resetExecutions:
|
|
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:
|
|
468
|
+
resetCatalogs: () => {
|
|
546
469
|
var _a;
|
|
547
470
|
(_a = ctx.caches.workspaceCatalogs) === null || _a === void 0 ? void 0 : _a.clear();
|
|
548
471
|
},
|
|
549
|
-
resetSecuritySettings:
|
|
472
|
+
resetSecuritySettings: () => {
|
|
550
473
|
var _a;
|
|
551
474
|
(_a = ctx.caches.securitySettings) === null || _a === void 0 ? void 0 : _a.clear();
|
|
552
475
|
},
|
|
553
|
-
resetAttributes:
|
|
476
|
+
resetAttributes: () => {
|
|
554
477
|
var _a;
|
|
555
478
|
(_a = ctx.caches.workspaceAttributes) === null || _a === void 0 ? void 0 : _a.clear();
|
|
556
479
|
},
|
|
557
|
-
resetWorkspaceSettings:
|
|
480
|
+
resetWorkspaceSettings: () => {
|
|
558
481
|
var _a;
|
|
559
482
|
(_a = ctx.caches.workspaceSettings) === null || _a === void 0 ? void 0 : _a.clear();
|
|
560
483
|
},
|
|
561
|
-
resetAll:
|
|
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
|
|
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
|
|
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
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
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({
|
|
617
|
-
workspaceCatalogs: catalogCaching ? new LRUCache({
|
|
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({
|
|
542
|
+
? new LRUCache({ max: config.maxSecuritySettingsOrgs })
|
|
620
543
|
: undefined,
|
|
621
544
|
workspaceAttributes: attributeCaching
|
|
622
|
-
? new LRUCache({
|
|
545
|
+
? new LRUCache({ max: config.maxAttributeWorkspaces })
|
|
623
546
|
: undefined,
|
|
624
547
|
workspaceSettings: workspaceSettingsCaching
|
|
625
|
-
? new LRUCache({
|
|
548
|
+
? new LRUCache({ max: config.maxWorkspaceSettings })
|
|
626
549
|
: undefined,
|
|
627
550
|
},
|
|
628
|
-
config
|
|
551
|
+
config,
|
|
629
552
|
capabilities: realBackend.capabilities,
|
|
630
553
|
};
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
|
641
|
-
catalog
|
|
642
|
-
securitySettings
|
|
643
|
-
attributes
|
|
644
|
-
workspaceSettings
|
|
563
|
+
execution,
|
|
564
|
+
catalog,
|
|
565
|
+
securitySettings,
|
|
566
|
+
attributes,
|
|
567
|
+
workspaceSettings,
|
|
645
568
|
});
|
|
646
569
|
}
|
|
647
570
|
function skipMissingReferences(requestedRefs, refsToLoad, refsLoadedFromServer) {
|
|
648
|
-
|
|
649
|
-
return requestedRefs.filter(
|
|
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
|