@salesforce/lds-adapters-platform-scale-center 1.124.2 → 1.124.3
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/es/es2018/platform-scale-center.js +282 -282
- package/dist/{types → es/es2018/types}/src/generated/adapters/adapter-utils.d.ts +66 -66
- package/dist/{types → es/es2018/types}/src/generated/adapters/queryMetrics.d.ts +26 -26
- package/dist/{types → es/es2018/types}/src/generated/artifacts/main.d.ts +1 -1
- package/dist/{types → es/es2018/types}/src/generated/artifacts/sfdc.d.ts +3 -3
- package/dist/{types → es/es2018/types}/src/generated/resources/getScalecenterMetricsQuery.d.ts +15 -15
- package/dist/{types → es/es2018/types}/src/generated/types/ScaleCenterMetricDataRepresentation.d.ts +30 -30
- package/dist/{types → es/es2018/types}/src/generated/types/type-utils.d.ts +39 -39
- package/package.json +5 -5
- package/sfdc/index.d.ts +1 -1
- package/sfdc/index.js +302 -302
- package/dist/umd/es2018/platform-scale-center.js +0 -309
- package/dist/umd/es5/platform-scale-center.js +0 -310
|
@@ -6,296 +6,296 @@
|
|
|
6
6
|
|
|
7
7
|
import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
|
|
8
8
|
|
|
9
|
-
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
-
const { keys: ObjectKeys, freeze: ObjectFreeze, create: ObjectCreate } = Object;
|
|
11
|
-
const { isArray: ArrayIsArray$1 } = Array;
|
|
12
|
-
/**
|
|
13
|
-
* Validates an adapter config is well-formed.
|
|
14
|
-
* @param config The config to validate.
|
|
15
|
-
* @param adapter The adapter validation configuration.
|
|
16
|
-
* @param oneOf The keys the config must contain at least one of.
|
|
17
|
-
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
18
|
-
*/
|
|
19
|
-
function validateConfig(config, adapter, oneOf) {
|
|
20
|
-
const { displayName } = adapter;
|
|
21
|
-
const { required, optional, unsupported } = adapter.parameters;
|
|
22
|
-
if (config === undefined ||
|
|
23
|
-
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
24
|
-
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
25
|
-
}
|
|
26
|
-
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
27
|
-
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
28
|
-
}
|
|
29
|
-
if (unsupported !== undefined &&
|
|
30
|
-
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
31
|
-
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
32
|
-
}
|
|
33
|
-
const supported = required.concat(optional);
|
|
34
|
-
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
35
|
-
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function untrustedIsObject(untrusted) {
|
|
39
|
-
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
40
|
-
}
|
|
41
|
-
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
42
|
-
return configPropertyNames.parameters.required.every(req => req in config);
|
|
43
|
-
}
|
|
44
|
-
const snapshotRefreshOptions = {
|
|
45
|
-
overrides: {
|
|
46
|
-
headers: {
|
|
47
|
-
'Cache-Control': 'no-cache',
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
};
|
|
9
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
+
const { keys: ObjectKeys, freeze: ObjectFreeze, create: ObjectCreate } = Object;
|
|
11
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
12
|
+
/**
|
|
13
|
+
* Validates an adapter config is well-formed.
|
|
14
|
+
* @param config The config to validate.
|
|
15
|
+
* @param adapter The adapter validation configuration.
|
|
16
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
17
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
18
|
+
*/
|
|
19
|
+
function validateConfig(config, adapter, oneOf) {
|
|
20
|
+
const { displayName } = adapter;
|
|
21
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
22
|
+
if (config === undefined ||
|
|
23
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
24
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
25
|
+
}
|
|
26
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
27
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
if (unsupported !== undefined &&
|
|
30
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
31
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
const supported = required.concat(optional);
|
|
34
|
+
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
35
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function untrustedIsObject(untrusted) {
|
|
39
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
40
|
+
}
|
|
41
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
42
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
43
|
+
}
|
|
44
|
+
const snapshotRefreshOptions = {
|
|
45
|
+
overrides: {
|
|
46
|
+
headers: {
|
|
47
|
+
'Cache-Control': 'no-cache',
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
51
|
const keyPrefix = 'ScaleCenter';
|
|
52
52
|
|
|
53
|
-
const { isArray: ArrayIsArray } = Array;
|
|
54
|
-
function createLink(ref) {
|
|
55
|
-
return {
|
|
56
|
-
__ref: serializeStructuredKey(ref),
|
|
57
|
-
};
|
|
53
|
+
const { isArray: ArrayIsArray } = Array;
|
|
54
|
+
function createLink(ref) {
|
|
55
|
+
return {
|
|
56
|
+
__ref: serializeStructuredKey(ref),
|
|
57
|
+
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const TTL = 30000;
|
|
61
|
-
const VERSION = "b8f014d0e9442d4f93f4eec945f0b6e4";
|
|
62
|
-
function validate(obj, path = 'ScaleCenterMetricDataRepresentation') {
|
|
63
|
-
const v_error = (() => {
|
|
64
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
65
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
66
|
-
}
|
|
67
|
-
const obj_response = obj.response;
|
|
68
|
-
const path_response = path + '.response';
|
|
69
|
-
if (typeof obj_response !== 'string') {
|
|
70
|
-
return new TypeError('Expected "string" but received "' + typeof obj_response + '" (at "' + path_response + '")');
|
|
71
|
-
}
|
|
72
|
-
})();
|
|
73
|
-
return v_error === undefined ? null : v_error;
|
|
74
|
-
}
|
|
75
|
-
const RepresentationType = 'ScaleCenterMetricDataRepresentation';
|
|
76
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
77
|
-
return input;
|
|
78
|
-
}
|
|
79
|
-
const select$1 = function ScaleCenterMetricDataRepresentationSelect() {
|
|
80
|
-
return {
|
|
81
|
-
kind: 'Fragment',
|
|
82
|
-
version: VERSION,
|
|
83
|
-
private: [],
|
|
84
|
-
selections: [
|
|
85
|
-
{
|
|
86
|
-
name: 'response',
|
|
87
|
-
kind: 'Scalar'
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
function equals(existing, incoming) {
|
|
93
|
-
const existing_response = existing.response;
|
|
94
|
-
const incoming_response = incoming.response;
|
|
95
|
-
if (!(existing_response === incoming_response)) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
const ingest = function ScaleCenterMetricDataRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
101
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
102
|
-
const validateError = validate(input);
|
|
103
|
-
if (validateError !== null) {
|
|
104
|
-
throw validateError;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const key = path.fullPath;
|
|
108
|
-
const existingRecord = store.readEntry(key);
|
|
109
|
-
const ttlToUse = TTL;
|
|
110
|
-
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
111
|
-
fullPath: key,
|
|
112
|
-
parent: path.parent,
|
|
113
|
-
propertyName: path.propertyName,
|
|
114
|
-
ttl: ttlToUse
|
|
115
|
-
});
|
|
116
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
117
|
-
luvio.storePublish(key, incomingRecord);
|
|
118
|
-
}
|
|
119
|
-
{
|
|
120
|
-
const storeMetadataParams = {
|
|
121
|
-
ttl: ttlToUse,
|
|
122
|
-
namespace: "ScaleCenter",
|
|
123
|
-
version: VERSION,
|
|
124
|
-
representationName: RepresentationType,
|
|
125
|
-
};
|
|
126
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
127
|
-
}
|
|
128
|
-
return createLink(key);
|
|
129
|
-
};
|
|
130
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
131
|
-
const rootKeySet = new StoreKeyMap();
|
|
132
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
133
|
-
const rootKey = fullPathFactory();
|
|
134
|
-
rootKeySet.set(rootKey, {
|
|
135
|
-
namespace: keyPrefix,
|
|
136
|
-
representationName: RepresentationType,
|
|
137
|
-
mergeable: false
|
|
138
|
-
});
|
|
139
|
-
return rootKeySet;
|
|
60
|
+
const TTL = 30000;
|
|
61
|
+
const VERSION = "b8f014d0e9442d4f93f4eec945f0b6e4";
|
|
62
|
+
function validate(obj, path = 'ScaleCenterMetricDataRepresentation') {
|
|
63
|
+
const v_error = (() => {
|
|
64
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
65
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
66
|
+
}
|
|
67
|
+
const obj_response = obj.response;
|
|
68
|
+
const path_response = path + '.response';
|
|
69
|
+
if (typeof obj_response !== 'string') {
|
|
70
|
+
return new TypeError('Expected "string" but received "' + typeof obj_response + '" (at "' + path_response + '")');
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
return v_error === undefined ? null : v_error;
|
|
74
|
+
}
|
|
75
|
+
const RepresentationType = 'ScaleCenterMetricDataRepresentation';
|
|
76
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
77
|
+
return input;
|
|
78
|
+
}
|
|
79
|
+
const select$1 = function ScaleCenterMetricDataRepresentationSelect() {
|
|
80
|
+
return {
|
|
81
|
+
kind: 'Fragment',
|
|
82
|
+
version: VERSION,
|
|
83
|
+
private: [],
|
|
84
|
+
selections: [
|
|
85
|
+
{
|
|
86
|
+
name: 'response',
|
|
87
|
+
kind: 'Scalar'
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
function equals(existing, incoming) {
|
|
93
|
+
const existing_response = existing.response;
|
|
94
|
+
const incoming_response = incoming.response;
|
|
95
|
+
if (!(existing_response === incoming_response)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
const ingest = function ScaleCenterMetricDataRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
101
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
102
|
+
const validateError = validate(input);
|
|
103
|
+
if (validateError !== null) {
|
|
104
|
+
throw validateError;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const key = path.fullPath;
|
|
108
|
+
const existingRecord = store.readEntry(key);
|
|
109
|
+
const ttlToUse = TTL;
|
|
110
|
+
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
111
|
+
fullPath: key,
|
|
112
|
+
parent: path.parent,
|
|
113
|
+
propertyName: path.propertyName,
|
|
114
|
+
ttl: ttlToUse
|
|
115
|
+
});
|
|
116
|
+
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
117
|
+
luvio.storePublish(key, incomingRecord);
|
|
118
|
+
}
|
|
119
|
+
{
|
|
120
|
+
const storeMetadataParams = {
|
|
121
|
+
ttl: ttlToUse,
|
|
122
|
+
namespace: "ScaleCenter",
|
|
123
|
+
version: VERSION,
|
|
124
|
+
representationName: RepresentationType,
|
|
125
|
+
};
|
|
126
|
+
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
127
|
+
}
|
|
128
|
+
return createLink(key);
|
|
129
|
+
};
|
|
130
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
131
|
+
const rootKeySet = new StoreKeyMap();
|
|
132
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
133
|
+
const rootKey = fullPathFactory();
|
|
134
|
+
rootKeySet.set(rootKey, {
|
|
135
|
+
namespace: keyPrefix,
|
|
136
|
+
representationName: RepresentationType,
|
|
137
|
+
mergeable: false
|
|
138
|
+
});
|
|
139
|
+
return rootKeySet;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
function select(luvio, params) {
|
|
143
|
-
return select$1();
|
|
144
|
-
}
|
|
145
|
-
function keyBuilder$1(luvio, params) {
|
|
146
|
-
return keyPrefix + '::ScaleCenterMetricDataRepresentation:(' + 'request:' + params.queryParams.request + ')';
|
|
147
|
-
}
|
|
148
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
149
|
-
return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
|
|
150
|
-
}
|
|
151
|
-
function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
|
|
152
|
-
const { body } = response;
|
|
153
|
-
const key = keyBuilder$1(luvio, resourceParams);
|
|
154
|
-
luvio.storeIngest(key, ingest, body);
|
|
155
|
-
const snapshot = luvio.storeLookup({
|
|
156
|
-
recordId: key,
|
|
157
|
-
node: select(),
|
|
158
|
-
variables: {},
|
|
159
|
-
}, snapshotRefresh);
|
|
160
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
161
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
162
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return snapshot;
|
|
166
|
-
}
|
|
167
|
-
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
168
|
-
const key = keyBuilder$1(luvio, params);
|
|
169
|
-
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
170
|
-
const storeMetadataParams = {
|
|
171
|
-
ttl: TTL,
|
|
172
|
-
namespace: keyPrefix,
|
|
173
|
-
version: VERSION,
|
|
174
|
-
representationName: RepresentationType
|
|
175
|
-
};
|
|
176
|
-
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
177
|
-
return errorSnapshot;
|
|
178
|
-
}
|
|
179
|
-
function createResourceRequest(config) {
|
|
180
|
-
const headers = {};
|
|
181
|
-
return {
|
|
182
|
-
baseUri: '/services/data/v58.0',
|
|
183
|
-
basePath: '/scalecenter/metrics/query',
|
|
184
|
-
method: 'get',
|
|
185
|
-
body: null,
|
|
186
|
-
urlParams: {},
|
|
187
|
-
queryParams: config.queryParams,
|
|
188
|
-
headers,
|
|
189
|
-
priority: 'normal',
|
|
190
|
-
};
|
|
142
|
+
function select(luvio, params) {
|
|
143
|
+
return select$1();
|
|
144
|
+
}
|
|
145
|
+
function keyBuilder$1(luvio, params) {
|
|
146
|
+
return keyPrefix + '::ScaleCenterMetricDataRepresentation:(' + 'request:' + params.queryParams.request + ')';
|
|
147
|
+
}
|
|
148
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
149
|
+
return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
|
|
150
|
+
}
|
|
151
|
+
function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
|
|
152
|
+
const { body } = response;
|
|
153
|
+
const key = keyBuilder$1(luvio, resourceParams);
|
|
154
|
+
luvio.storeIngest(key, ingest, body);
|
|
155
|
+
const snapshot = luvio.storeLookup({
|
|
156
|
+
recordId: key,
|
|
157
|
+
node: select(),
|
|
158
|
+
variables: {},
|
|
159
|
+
}, snapshotRefresh);
|
|
160
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
161
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
162
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return snapshot;
|
|
166
|
+
}
|
|
167
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
168
|
+
const key = keyBuilder$1(luvio, params);
|
|
169
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
170
|
+
const storeMetadataParams = {
|
|
171
|
+
ttl: TTL,
|
|
172
|
+
namespace: keyPrefix,
|
|
173
|
+
version: VERSION,
|
|
174
|
+
representationName: RepresentationType
|
|
175
|
+
};
|
|
176
|
+
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
177
|
+
return errorSnapshot;
|
|
178
|
+
}
|
|
179
|
+
function createResourceRequest(config) {
|
|
180
|
+
const headers = {};
|
|
181
|
+
return {
|
|
182
|
+
baseUri: '/services/data/v58.0',
|
|
183
|
+
basePath: '/scalecenter/metrics/query',
|
|
184
|
+
method: 'get',
|
|
185
|
+
body: null,
|
|
186
|
+
urlParams: {},
|
|
187
|
+
queryParams: config.queryParams,
|
|
188
|
+
headers,
|
|
189
|
+
priority: 'normal',
|
|
190
|
+
};
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
const queryMetrics_ConfigPropertyNames = {
|
|
194
|
-
displayName: 'queryMetrics',
|
|
195
|
-
parameters: {
|
|
196
|
-
required: [],
|
|
197
|
-
optional: ['request']
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
function createResourceParams(config) {
|
|
201
|
-
const resourceParams = {
|
|
202
|
-
queryParams: {
|
|
203
|
-
request: config.request
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
return resourceParams;
|
|
207
|
-
}
|
|
208
|
-
function keyBuilder(luvio, config) {
|
|
209
|
-
const resourceParams = createResourceParams(config);
|
|
210
|
-
return keyBuilder$1(luvio, resourceParams);
|
|
211
|
-
}
|
|
212
|
-
function typeCheckConfig(untrustedConfig) {
|
|
213
|
-
const config = {};
|
|
214
|
-
const untrustedConfig_request = untrustedConfig.request;
|
|
215
|
-
if (typeof untrustedConfig_request === 'string') {
|
|
216
|
-
config.request = untrustedConfig_request;
|
|
217
|
-
}
|
|
218
|
-
return config;
|
|
219
|
-
}
|
|
220
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
221
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
225
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
226
|
-
}
|
|
227
|
-
const config = typeCheckConfig(untrustedConfig);
|
|
228
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
return config;
|
|
232
|
-
}
|
|
233
|
-
function adapterFragment(luvio, config) {
|
|
234
|
-
createResourceParams(config);
|
|
235
|
-
return select();
|
|
236
|
-
}
|
|
237
|
-
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
238
|
-
const snapshot = ingestSuccess(luvio, resourceParams, response, {
|
|
239
|
-
config,
|
|
240
|
-
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
241
|
-
});
|
|
242
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
243
|
-
}
|
|
244
|
-
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
245
|
-
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
246
|
-
config,
|
|
247
|
-
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
248
|
-
});
|
|
249
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
250
|
-
}
|
|
251
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
252
|
-
const resourceParams = createResourceParams(config);
|
|
253
|
-
const request = createResourceRequest(resourceParams);
|
|
254
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
255
|
-
.then((response) => {
|
|
256
|
-
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
257
|
-
}, (response) => {
|
|
258
|
-
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
262
|
-
const { luvio, config } = context;
|
|
263
|
-
const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
|
|
264
|
-
const dispatchOptions = {
|
|
265
|
-
resourceRequestContext: {
|
|
266
|
-
requestCorrelator,
|
|
267
|
-
luvioRequestMethod: undefined,
|
|
268
|
-
},
|
|
269
|
-
eventObservers
|
|
270
|
-
};
|
|
271
|
-
if (networkPriority !== 'normal') {
|
|
272
|
-
dispatchOptions.overrides = {
|
|
273
|
-
priority: networkPriority
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
return buildNetworkSnapshot(luvio, config, dispatchOptions);
|
|
277
|
-
}
|
|
278
|
-
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
279
|
-
const { luvio, config } = context;
|
|
280
|
-
const selector = {
|
|
281
|
-
recordId: keyBuilder(luvio, config),
|
|
282
|
-
node: adapterFragment(luvio, config),
|
|
283
|
-
variables: {},
|
|
284
|
-
};
|
|
285
|
-
const cacheSnapshot = storeLookup(selector, {
|
|
286
|
-
config,
|
|
287
|
-
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
288
|
-
});
|
|
289
|
-
return cacheSnapshot;
|
|
290
|
-
}
|
|
291
|
-
const queryMetricsAdapterFactory = (luvio) => function ScaleCenter__queryMetrics(untrustedConfig, requestContext) {
|
|
292
|
-
const config = validateAdapterConfig(untrustedConfig, queryMetrics_ConfigPropertyNames);
|
|
293
|
-
// Invalid or incomplete config
|
|
294
|
-
if (config === null) {
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
298
|
-
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
193
|
+
const queryMetrics_ConfigPropertyNames = {
|
|
194
|
+
displayName: 'queryMetrics',
|
|
195
|
+
parameters: {
|
|
196
|
+
required: [],
|
|
197
|
+
optional: ['request']
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
function createResourceParams(config) {
|
|
201
|
+
const resourceParams = {
|
|
202
|
+
queryParams: {
|
|
203
|
+
request: config.request
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
return resourceParams;
|
|
207
|
+
}
|
|
208
|
+
function keyBuilder(luvio, config) {
|
|
209
|
+
const resourceParams = createResourceParams(config);
|
|
210
|
+
return keyBuilder$1(luvio, resourceParams);
|
|
211
|
+
}
|
|
212
|
+
function typeCheckConfig(untrustedConfig) {
|
|
213
|
+
const config = {};
|
|
214
|
+
const untrustedConfig_request = untrustedConfig.request;
|
|
215
|
+
if (typeof untrustedConfig_request === 'string') {
|
|
216
|
+
config.request = untrustedConfig_request;
|
|
217
|
+
}
|
|
218
|
+
return config;
|
|
219
|
+
}
|
|
220
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
221
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
225
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
226
|
+
}
|
|
227
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
228
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return config;
|
|
232
|
+
}
|
|
233
|
+
function adapterFragment(luvio, config) {
|
|
234
|
+
createResourceParams(config);
|
|
235
|
+
return select();
|
|
236
|
+
}
|
|
237
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
238
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response, {
|
|
239
|
+
config,
|
|
240
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
241
|
+
});
|
|
242
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
243
|
+
}
|
|
244
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
245
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
246
|
+
config,
|
|
247
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
248
|
+
});
|
|
249
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
250
|
+
}
|
|
251
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
252
|
+
const resourceParams = createResourceParams(config);
|
|
253
|
+
const request = createResourceRequest(resourceParams);
|
|
254
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
255
|
+
.then((response) => {
|
|
256
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
257
|
+
}, (response) => {
|
|
258
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
262
|
+
const { luvio, config } = context;
|
|
263
|
+
const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
|
|
264
|
+
const dispatchOptions = {
|
|
265
|
+
resourceRequestContext: {
|
|
266
|
+
requestCorrelator,
|
|
267
|
+
luvioRequestMethod: undefined,
|
|
268
|
+
},
|
|
269
|
+
eventObservers
|
|
270
|
+
};
|
|
271
|
+
if (networkPriority !== 'normal') {
|
|
272
|
+
dispatchOptions.overrides = {
|
|
273
|
+
priority: networkPriority
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return buildNetworkSnapshot(luvio, config, dispatchOptions);
|
|
277
|
+
}
|
|
278
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
279
|
+
const { luvio, config } = context;
|
|
280
|
+
const selector = {
|
|
281
|
+
recordId: keyBuilder(luvio, config),
|
|
282
|
+
node: adapterFragment(luvio, config),
|
|
283
|
+
variables: {},
|
|
284
|
+
};
|
|
285
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
286
|
+
config,
|
|
287
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
288
|
+
});
|
|
289
|
+
return cacheSnapshot;
|
|
290
|
+
}
|
|
291
|
+
const queryMetricsAdapterFactory = (luvio) => function ScaleCenter__queryMetrics(untrustedConfig, requestContext) {
|
|
292
|
+
const config = validateAdapterConfig(untrustedConfig, queryMetrics_ConfigPropertyNames);
|
|
293
|
+
// Invalid or incomplete config
|
|
294
|
+
if (config === null) {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
298
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
299
299
|
};
|
|
300
300
|
|
|
301
301
|
export { queryMetricsAdapterFactory };
|