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