@salesforce/lds-adapters-industries-constraints 1.308.0-dev1
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/LICENSE.txt +82 -0
- package/dist/es/es2018/industries-constraints.js +570 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/getViewConstraint.d.ts +27 -0
- package/dist/es/es2018/types/src/generated/adapters/patchUpdateConstraint.d.ts +18 -0
- package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +2 -0
- package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +4 -0
- package/dist/es/es2018/types/src/generated/resources/getConstraintActionsViewByExpressionSetDefinitionVersionId.d.ts +15 -0
- package/dist/es/es2018/types/src/generated/resources/patchConstraintActionsUpdateByExpressionSetDefinitionVersionId.d.ts +17 -0
- package/dist/es/es2018/types/src/generated/types/ConstraintErrorResponseRepresentation.d.ts +32 -0
- package/dist/es/es2018/types/src/generated/types/ConstraintInputRepresentation.d.ts +34 -0
- package/dist/es/es2018/types/src/generated/types/ConstraintOutputRepresentation.d.ts +51 -0
- package/dist/es/es2018/types/src/generated/types/ViewConstraintOutputRepresentation.d.ts +35 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
- package/package.json +66 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +612 -0
- package/src/raml/api.raml +110 -0
- package/src/raml/luvio.raml +33 -0
package/sfdc/index.js
ADDED
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* ATTENTION!
|
|
9
|
+
* THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
|
|
10
|
+
* If you would like to contribute to LDS, please follow the steps outlined in the git repo.
|
|
11
|
+
* Any changes made to this file in p4 will be automatically overwritten.
|
|
12
|
+
* *******************************************************************************************
|
|
13
|
+
*/
|
|
14
|
+
/* proxy-compat-disable */
|
|
15
|
+
import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
|
|
16
|
+
import { withDefaultLuvio } from 'force/ldsEngine';
|
|
17
|
+
import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from 'force/luvioEngine';
|
|
18
|
+
|
|
19
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
20
|
+
const { keys: ObjectKeys, create: ObjectCreate } = Object;
|
|
21
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
22
|
+
/**
|
|
23
|
+
* Validates an adapter config is well-formed.
|
|
24
|
+
* @param config The config to validate.
|
|
25
|
+
* @param adapter The adapter validation configuration.
|
|
26
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
27
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
28
|
+
*/
|
|
29
|
+
function validateConfig(config, adapter, oneOf) {
|
|
30
|
+
const { displayName } = adapter;
|
|
31
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
32
|
+
if (config === undefined ||
|
|
33
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
34
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
37
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
38
|
+
}
|
|
39
|
+
if (unsupported !== undefined &&
|
|
40
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
41
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
42
|
+
}
|
|
43
|
+
const supported = required.concat(optional);
|
|
44
|
+
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
45
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function untrustedIsObject(untrusted) {
|
|
49
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
50
|
+
}
|
|
51
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
52
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
53
|
+
}
|
|
54
|
+
const snapshotRefreshOptions = {
|
|
55
|
+
overrides: {
|
|
56
|
+
headers: {
|
|
57
|
+
'Cache-Control': 'no-cache',
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
|
|
62
|
+
return {
|
|
63
|
+
name,
|
|
64
|
+
required,
|
|
65
|
+
resourceType,
|
|
66
|
+
typeCheckShape,
|
|
67
|
+
isArrayShape,
|
|
68
|
+
coerceFn,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
72
|
+
const required = paramsMeta.filter(p => p.required).map(p => p.name);
|
|
73
|
+
const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
|
|
74
|
+
return {
|
|
75
|
+
displayName,
|
|
76
|
+
parameters: {
|
|
77
|
+
required,
|
|
78
|
+
optional,
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const keyPrefix = 'constraints';
|
|
83
|
+
|
|
84
|
+
const { isArray: ArrayIsArray } = Array;
|
|
85
|
+
const { stringify: JSONStringify } = JSON;
|
|
86
|
+
function equalsArray(a, b, equalsItem) {
|
|
87
|
+
const aLength = a.length;
|
|
88
|
+
const bLength = b.length;
|
|
89
|
+
if (aLength !== bLength) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
for (let i = 0; i < aLength; i++) {
|
|
93
|
+
if (equalsItem(a[i], b[i]) === false) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
function createLink(ref) {
|
|
100
|
+
return {
|
|
101
|
+
__ref: serializeStructuredKey(ref),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const TTL$2 = 1000;
|
|
106
|
+
const VERSION$2 = "76516fe771fad46e2555a4f24b577b13";
|
|
107
|
+
function validate$2(obj, path = 'ViewConstraintOutputRepresentation') {
|
|
108
|
+
const v_error = (() => {
|
|
109
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
110
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
111
|
+
}
|
|
112
|
+
const obj_constraintModel = obj.constraintModel;
|
|
113
|
+
const path_constraintModel = path + '.constraintModel';
|
|
114
|
+
if (typeof obj_constraintModel !== 'string') {
|
|
115
|
+
return new TypeError('Expected "string" but received "' + typeof obj_constraintModel + '" (at "' + path_constraintModel + '")');
|
|
116
|
+
}
|
|
117
|
+
const obj_description = obj.description;
|
|
118
|
+
const path_description = path + '.description';
|
|
119
|
+
if (typeof obj_description !== 'string') {
|
|
120
|
+
return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
|
|
121
|
+
}
|
|
122
|
+
const obj_status = obj.status;
|
|
123
|
+
const path_status = path + '.status';
|
|
124
|
+
if (typeof obj_status !== 'string') {
|
|
125
|
+
return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
|
|
126
|
+
}
|
|
127
|
+
})();
|
|
128
|
+
return v_error === undefined ? null : v_error;
|
|
129
|
+
}
|
|
130
|
+
const RepresentationType$2 = 'ViewConstraintOutputRepresentation';
|
|
131
|
+
function normalize$2(input, existing, path, luvio, store, timestamp) {
|
|
132
|
+
return input;
|
|
133
|
+
}
|
|
134
|
+
const select$4 = function ViewConstraintOutputRepresentationSelect() {
|
|
135
|
+
return {
|
|
136
|
+
kind: 'Fragment',
|
|
137
|
+
version: VERSION$2,
|
|
138
|
+
private: [],
|
|
139
|
+
opaque: true
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
function equals$2(existing, incoming) {
|
|
143
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
const ingest$2 = function ViewConstraintOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
149
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
150
|
+
const validateError = validate$2(input);
|
|
151
|
+
if (validateError !== null) {
|
|
152
|
+
throw validateError;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const key = path.fullPath;
|
|
156
|
+
const ttlToUse = TTL$2;
|
|
157
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "constraints", VERSION$2, RepresentationType$2, equals$2);
|
|
158
|
+
return createLink(key);
|
|
159
|
+
};
|
|
160
|
+
function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
|
|
161
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
162
|
+
const rootKey = fullPathFactory();
|
|
163
|
+
rootKeySet.set(rootKey, {
|
|
164
|
+
namespace: keyPrefix,
|
|
165
|
+
representationName: RepresentationType$2,
|
|
166
|
+
mergeable: false
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function select$3(luvio, params) {
|
|
171
|
+
return select$4();
|
|
172
|
+
}
|
|
173
|
+
function keyBuilder$2(luvio, params) {
|
|
174
|
+
return keyPrefix + '::ViewConstraintOutputRepresentation:(' + 'expressionSetDefinitionVersionId:' + params.urlParams.expressionSetDefinitionVersionId + ')';
|
|
175
|
+
}
|
|
176
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
177
|
+
getTypeCacheKeys$2(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
|
|
178
|
+
}
|
|
179
|
+
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
180
|
+
const { body } = response;
|
|
181
|
+
const key = keyBuilder$2(luvio, resourceParams);
|
|
182
|
+
luvio.storeIngest(key, ingest$2, body);
|
|
183
|
+
const snapshot = luvio.storeLookup({
|
|
184
|
+
recordId: key,
|
|
185
|
+
node: select$3(),
|
|
186
|
+
variables: {},
|
|
187
|
+
}, snapshotRefresh);
|
|
188
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
189
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
190
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
deepFreeze(snapshot.data);
|
|
194
|
+
return snapshot;
|
|
195
|
+
}
|
|
196
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
197
|
+
const key = keyBuilder$2(luvio, params);
|
|
198
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
199
|
+
const storeMetadataParams = {
|
|
200
|
+
ttl: TTL$2,
|
|
201
|
+
namespace: keyPrefix,
|
|
202
|
+
version: VERSION$2,
|
|
203
|
+
representationName: RepresentationType$2
|
|
204
|
+
};
|
|
205
|
+
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
206
|
+
return errorSnapshot;
|
|
207
|
+
}
|
|
208
|
+
function createResourceRequest$1(config) {
|
|
209
|
+
const headers = {};
|
|
210
|
+
return {
|
|
211
|
+
baseUri: '/services/data/v62.0',
|
|
212
|
+
basePath: '/constraint/actions/' + config.urlParams.expressionSetDefinitionVersionId + '/view',
|
|
213
|
+
method: 'get',
|
|
214
|
+
body: null,
|
|
215
|
+
urlParams: config.urlParams,
|
|
216
|
+
queryParams: {},
|
|
217
|
+
headers,
|
|
218
|
+
priority: 'normal',
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const adapterName$1 = 'getViewConstraint';
|
|
223
|
+
const getViewConstraint_ConfigPropertyMetadata = [
|
|
224
|
+
generateParamConfigMetadata('expressionSetDefinitionVersionId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
225
|
+
];
|
|
226
|
+
const getViewConstraint_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getViewConstraint_ConfigPropertyMetadata);
|
|
227
|
+
const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getViewConstraint_ConfigPropertyMetadata);
|
|
228
|
+
function keyBuilder$1(luvio, config) {
|
|
229
|
+
const resourceParams = createResourceParams$1(config);
|
|
230
|
+
return keyBuilder$2(luvio, resourceParams);
|
|
231
|
+
}
|
|
232
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
233
|
+
const config = {};
|
|
234
|
+
typeCheckConfig$2(untrustedConfig, config, getViewConstraint_ConfigPropertyMetadata);
|
|
235
|
+
return config;
|
|
236
|
+
}
|
|
237
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
238
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
242
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
243
|
+
}
|
|
244
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
245
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
return config;
|
|
249
|
+
}
|
|
250
|
+
function adapterFragment(luvio, config) {
|
|
251
|
+
createResourceParams$1(config);
|
|
252
|
+
return select$3();
|
|
253
|
+
}
|
|
254
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
255
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
256
|
+
config,
|
|
257
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
258
|
+
});
|
|
259
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
260
|
+
}
|
|
261
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
262
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
263
|
+
config,
|
|
264
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
265
|
+
});
|
|
266
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
267
|
+
}
|
|
268
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
269
|
+
const resourceParams = createResourceParams$1(config);
|
|
270
|
+
const request = createResourceRequest$1(resourceParams);
|
|
271
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
272
|
+
.then((response) => {
|
|
273
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
|
|
274
|
+
const cache = new StoreKeyMap();
|
|
275
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
276
|
+
return cache;
|
|
277
|
+
});
|
|
278
|
+
}, (response) => {
|
|
279
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
283
|
+
return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
|
|
284
|
+
}
|
|
285
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
286
|
+
const { luvio, config } = context;
|
|
287
|
+
const selector = {
|
|
288
|
+
recordId: keyBuilder$1(luvio, config),
|
|
289
|
+
node: adapterFragment(luvio, config),
|
|
290
|
+
variables: {},
|
|
291
|
+
};
|
|
292
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
293
|
+
config,
|
|
294
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
295
|
+
});
|
|
296
|
+
return cacheSnapshot;
|
|
297
|
+
}
|
|
298
|
+
const getViewConstraintAdapterFactory = (luvio) => function constraints__getViewConstraint(untrustedConfig, requestContext) {
|
|
299
|
+
const config = validateAdapterConfig$1(untrustedConfig, getViewConstraint_ConfigPropertyNames);
|
|
300
|
+
// Invalid or incomplete config
|
|
301
|
+
if (config === null) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
305
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
const TTL$1 = 1000;
|
|
309
|
+
const VERSION$1 = "ced261010494087086be7d8b043d2fda";
|
|
310
|
+
function validate$1(obj, path = 'ConstraintErrorResponseRepresentation') {
|
|
311
|
+
const v_error = (() => {
|
|
312
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
313
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
314
|
+
}
|
|
315
|
+
const obj_errorCode = obj.errorCode;
|
|
316
|
+
const path_errorCode = path + '.errorCode';
|
|
317
|
+
if (typeof obj_errorCode !== 'string') {
|
|
318
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
|
|
319
|
+
}
|
|
320
|
+
const obj_message = obj.message;
|
|
321
|
+
const path_message = path + '.message';
|
|
322
|
+
if (typeof obj_message !== 'string') {
|
|
323
|
+
return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
|
|
324
|
+
}
|
|
325
|
+
})();
|
|
326
|
+
return v_error === undefined ? null : v_error;
|
|
327
|
+
}
|
|
328
|
+
const RepresentationType$1 = 'ConstraintErrorResponseRepresentation';
|
|
329
|
+
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
330
|
+
return input;
|
|
331
|
+
}
|
|
332
|
+
const select$2 = function ConstraintErrorResponseRepresentationSelect() {
|
|
333
|
+
return {
|
|
334
|
+
kind: 'Fragment',
|
|
335
|
+
version: VERSION$1,
|
|
336
|
+
private: [],
|
|
337
|
+
opaque: true
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
function equals$1(existing, incoming) {
|
|
341
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
const ingest$1 = function ConstraintErrorResponseRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
347
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
348
|
+
const validateError = validate$1(input);
|
|
349
|
+
if (validateError !== null) {
|
|
350
|
+
throw validateError;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
const key = path.fullPath;
|
|
354
|
+
const ttlToUse = TTL$1;
|
|
355
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "constraints", VERSION$1, RepresentationType$1, equals$1);
|
|
356
|
+
return createLink(key);
|
|
357
|
+
};
|
|
358
|
+
function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
|
|
359
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
360
|
+
const rootKey = fullPathFactory();
|
|
361
|
+
rootKeySet.set(rootKey, {
|
|
362
|
+
namespace: keyPrefix,
|
|
363
|
+
representationName: RepresentationType$1,
|
|
364
|
+
mergeable: false
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const TTL = 1000;
|
|
369
|
+
const VERSION = "5646f5b52bdab0ca9d29c0a28b60ac39";
|
|
370
|
+
function validate(obj, path = 'ConstraintOutputRepresentation') {
|
|
371
|
+
const v_error = (() => {
|
|
372
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
373
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
374
|
+
}
|
|
375
|
+
const obj_errors = obj.errors;
|
|
376
|
+
const path_errors = path + '.errors';
|
|
377
|
+
if (!ArrayIsArray(obj_errors)) {
|
|
378
|
+
return new TypeError('Expected "array" but received "' + typeof obj_errors + '" (at "' + path_errors + '")');
|
|
379
|
+
}
|
|
380
|
+
for (let i = 0; i < obj_errors.length; i++) {
|
|
381
|
+
const obj_errors_item = obj_errors[i];
|
|
382
|
+
const path_errors_item = path_errors + '[' + i + ']';
|
|
383
|
+
if (typeof obj_errors_item !== 'object') {
|
|
384
|
+
return new TypeError('Expected "object" but received "' + typeof obj_errors_item + '" (at "' + path_errors_item + '")');
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const obj_success = obj.success;
|
|
388
|
+
const path_success = path + '.success';
|
|
389
|
+
if (typeof obj_success !== 'boolean') {
|
|
390
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_success + '" (at "' + path_success + '")');
|
|
391
|
+
}
|
|
392
|
+
})();
|
|
393
|
+
return v_error === undefined ? null : v_error;
|
|
394
|
+
}
|
|
395
|
+
const RepresentationType = 'ConstraintOutputRepresentation';
|
|
396
|
+
function keyBuilder(luvio, config) {
|
|
397
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.success;
|
|
398
|
+
}
|
|
399
|
+
function keyBuilderFromType(luvio, object) {
|
|
400
|
+
const keyParams = {
|
|
401
|
+
success: object.success
|
|
402
|
+
};
|
|
403
|
+
return keyBuilder(luvio, keyParams);
|
|
404
|
+
}
|
|
405
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
406
|
+
const input_errors = input.errors;
|
|
407
|
+
const input_errors_id = path.fullPath + '__errors';
|
|
408
|
+
for (let i = 0; i < input_errors.length; i++) {
|
|
409
|
+
const input_errors_item = input_errors[i];
|
|
410
|
+
let input_errors_item_id = input_errors_id + '__' + i;
|
|
411
|
+
input_errors[i] = ingest$1(input_errors_item, {
|
|
412
|
+
fullPath: input_errors_item_id,
|
|
413
|
+
propertyName: i,
|
|
414
|
+
parent: {
|
|
415
|
+
data: input,
|
|
416
|
+
key: path.fullPath,
|
|
417
|
+
existing: existing,
|
|
418
|
+
},
|
|
419
|
+
ttl: path.ttl
|
|
420
|
+
}, luvio, store, timestamp);
|
|
421
|
+
}
|
|
422
|
+
return input;
|
|
423
|
+
}
|
|
424
|
+
const select$1 = function ConstraintOutputRepresentationSelect() {
|
|
425
|
+
return {
|
|
426
|
+
kind: 'Fragment',
|
|
427
|
+
version: VERSION,
|
|
428
|
+
private: [],
|
|
429
|
+
selections: [
|
|
430
|
+
{
|
|
431
|
+
name: 'errors',
|
|
432
|
+
kind: 'Link',
|
|
433
|
+
plural: true,
|
|
434
|
+
fragment: select$2()
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: 'success',
|
|
438
|
+
kind: 'Scalar'
|
|
439
|
+
}
|
|
440
|
+
]
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
function equals(existing, incoming) {
|
|
444
|
+
const existing_success = existing.success;
|
|
445
|
+
const incoming_success = incoming.success;
|
|
446
|
+
if (!(existing_success === incoming_success)) {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
const existing_errors = existing.errors;
|
|
450
|
+
const incoming_errors = incoming.errors;
|
|
451
|
+
const equals_errors_items = equalsArray(existing_errors, incoming_errors, (existing_errors_item, incoming_errors_item) => {
|
|
452
|
+
if (!(existing_errors_item.__ref === incoming_errors_item.__ref)) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
if (equals_errors_items === false) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
const ingest = function ConstraintOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
462
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
463
|
+
const validateError = validate(input);
|
|
464
|
+
if (validateError !== null) {
|
|
465
|
+
throw validateError;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
const key = keyBuilderFromType(luvio, input);
|
|
469
|
+
const ttlToUse = TTL;
|
|
470
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "constraints", VERSION, RepresentationType, equals);
|
|
471
|
+
return createLink(key);
|
|
472
|
+
};
|
|
473
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
474
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
475
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
476
|
+
rootKeySet.set(rootKey, {
|
|
477
|
+
namespace: keyPrefix,
|
|
478
|
+
representationName: RepresentationType,
|
|
479
|
+
mergeable: false
|
|
480
|
+
});
|
|
481
|
+
const input_errors_length = input.errors.length;
|
|
482
|
+
for (let i = 0; i < input_errors_length; i++) {
|
|
483
|
+
getTypeCacheKeys$1(rootKeySet, luvio, input.errors[i], () => '');
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function select(luvio, params) {
|
|
488
|
+
return select$1();
|
|
489
|
+
}
|
|
490
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
491
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
492
|
+
}
|
|
493
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
494
|
+
const { body } = response;
|
|
495
|
+
const key = keyBuilderFromType(luvio, body);
|
|
496
|
+
luvio.storeIngest(key, ingest, body);
|
|
497
|
+
const snapshot = luvio.storeLookup({
|
|
498
|
+
recordId: key,
|
|
499
|
+
node: select(),
|
|
500
|
+
variables: {},
|
|
501
|
+
});
|
|
502
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
503
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
504
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
deepFreeze(snapshot.data);
|
|
508
|
+
return snapshot;
|
|
509
|
+
}
|
|
510
|
+
function createResourceRequest(config) {
|
|
511
|
+
const headers = {};
|
|
512
|
+
return {
|
|
513
|
+
baseUri: '/services/data/v62.0',
|
|
514
|
+
basePath: '/constraint/actions/' + config.urlParams.expressionSetDefinitionVersionId + '/update',
|
|
515
|
+
method: 'patch',
|
|
516
|
+
body: config.body,
|
|
517
|
+
urlParams: config.urlParams,
|
|
518
|
+
queryParams: {},
|
|
519
|
+
headers,
|
|
520
|
+
priority: 'normal',
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const adapterName = 'patchUpdateConstraint';
|
|
525
|
+
const patchUpdateConstraint_ConfigPropertyMetadata = [
|
|
526
|
+
generateParamConfigMetadata('expressionSetDefinitionVersionId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
527
|
+
generateParamConfigMetadata('constraintModel', true, 2 /* Body */, 0 /* String */),
|
|
528
|
+
generateParamConfigMetadata('description', true, 2 /* Body */, 0 /* String */),
|
|
529
|
+
generateParamConfigMetadata('status', true, 2 /* Body */, 0 /* String */),
|
|
530
|
+
];
|
|
531
|
+
const patchUpdateConstraint_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, patchUpdateConstraint_ConfigPropertyMetadata);
|
|
532
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$2(patchUpdateConstraint_ConfigPropertyMetadata);
|
|
533
|
+
function typeCheckConfig(untrustedConfig) {
|
|
534
|
+
const config = {};
|
|
535
|
+
typeCheckConfig$2(untrustedConfig, config, patchUpdateConstraint_ConfigPropertyMetadata);
|
|
536
|
+
return config;
|
|
537
|
+
}
|
|
538
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
539
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
543
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
544
|
+
}
|
|
545
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
546
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
return config;
|
|
550
|
+
}
|
|
551
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
552
|
+
const resourceParams = createResourceParams(config);
|
|
553
|
+
const request = createResourceRequest(resourceParams);
|
|
554
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
555
|
+
.then((response) => {
|
|
556
|
+
return luvio.handleSuccessResponse(() => {
|
|
557
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
558
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
559
|
+
}, () => {
|
|
560
|
+
const cache = new StoreKeyMap();
|
|
561
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
562
|
+
return cache;
|
|
563
|
+
});
|
|
564
|
+
}, (response) => {
|
|
565
|
+
deepFreeze(response);
|
|
566
|
+
throw response;
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
const patchUpdateConstraintAdapterFactory = (luvio) => {
|
|
570
|
+
return function patchUpdateConstraint(untrustedConfig) {
|
|
571
|
+
const config = validateAdapterConfig(untrustedConfig, patchUpdateConstraint_ConfigPropertyNames);
|
|
572
|
+
// Invalid or incomplete config
|
|
573
|
+
if (config === null) {
|
|
574
|
+
throw new Error('Invalid config for "patchUpdateConstraint"');
|
|
575
|
+
}
|
|
576
|
+
return buildNetworkSnapshot(luvio, config);
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
let getViewConstraint;
|
|
581
|
+
let patchUpdateConstraint;
|
|
582
|
+
// Imperative GET Adapters
|
|
583
|
+
let getViewConstraint_imperative;
|
|
584
|
+
// Adapter Metadata
|
|
585
|
+
const getViewConstraintMetadata = {
|
|
586
|
+
apiFamily: 'constraints',
|
|
587
|
+
name: 'getViewConstraint',
|
|
588
|
+
ttl: 1000,
|
|
589
|
+
};
|
|
590
|
+
// Notify Update Available
|
|
591
|
+
function bindExportsTo(luvio) {
|
|
592
|
+
// LDS Adapters
|
|
593
|
+
const getViewConstraint_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getViewConstraint', getViewConstraintAdapterFactory), getViewConstraintMetadata);
|
|
594
|
+
function unwrapSnapshotData(factory) {
|
|
595
|
+
const adapter = factory(luvio);
|
|
596
|
+
return (config) => adapter(config).then((snapshot) => snapshot.data);
|
|
597
|
+
}
|
|
598
|
+
return {
|
|
599
|
+
getViewConstraint: createWireAdapterConstructor(luvio, getViewConstraint_ldsAdapter, getViewConstraintMetadata),
|
|
600
|
+
patchUpdateConstraint: unwrapSnapshotData(patchUpdateConstraintAdapterFactory),
|
|
601
|
+
// Imperative GET Adapters
|
|
602
|
+
getViewConstraint_imperative: createImperativeAdapter(luvio, getViewConstraint_ldsAdapter, getViewConstraintMetadata),
|
|
603
|
+
// Notify Update Availables
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
withDefaultLuvio((luvio) => {
|
|
607
|
+
({ getViewConstraint, patchUpdateConstraint, getViewConstraint_imperative } =
|
|
608
|
+
bindExportsTo(luvio));
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
export { getViewConstraint, getViewConstraint_imperative, patchUpdateConstraint };
|
|
612
|
+
// version: 1.308.0-dev1-36d38ba652
|