@salesforce/lds-adapters-industries-sustainability-reference-data 1.124.1 → 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/industries-sustainability-reference-data.js +251 -251
- package/dist/{types → es/es2018/types}/src/generated/adapters/adapter-utils.d.ts +66 -66
- package/dist/{types → es/es2018/types}/src/generated/adapters/uploadReferenceData.d.ts +15 -15
- 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 +2 -2
- package/dist/{types → es/es2018/types}/src/generated/resources/postConnectSustainabilityReferenceDataUploadByCategory.d.ts +15 -15
- package/dist/{types → es/es2018/types}/src/generated/types/SCReferenceDataOutputRepresentation.d.ts +42 -42
- 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 +267 -267
- package/dist/umd/es2018/industries-sustainability-reference-data.js +0 -278
- package/dist/umd/es5/industries-sustainability-reference-data.js +0 -279
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* For full license text, see the LICENSE.txt file
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
(function (global, factory) {
|
|
8
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["industriesSustainability-reference-data"] = {}, global.engine));
|
|
11
|
-
})(this, (function (exports, engine) { 'use strict';
|
|
12
|
-
|
|
13
|
-
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
14
|
-
const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
|
|
15
|
-
const { isArray: ArrayIsArray$1 } = Array;
|
|
16
|
-
/**
|
|
17
|
-
* Validates an adapter config is well-formed.
|
|
18
|
-
* @param config The config to validate.
|
|
19
|
-
* @param adapter The adapter validation configuration.
|
|
20
|
-
* @param oneOf The keys the config must contain at least one of.
|
|
21
|
-
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
22
|
-
*/
|
|
23
|
-
function validateConfig(config, adapter, oneOf) {
|
|
24
|
-
const { displayName } = adapter;
|
|
25
|
-
const { required, optional, unsupported } = adapter.parameters;
|
|
26
|
-
if (config === undefined ||
|
|
27
|
-
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
28
|
-
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
29
|
-
}
|
|
30
|
-
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
31
|
-
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
32
|
-
}
|
|
33
|
-
if (unsupported !== undefined &&
|
|
34
|
-
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
35
|
-
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
36
|
-
}
|
|
37
|
-
const supported = required.concat(optional);
|
|
38
|
-
if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
|
|
39
|
-
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function untrustedIsObject(untrusted) {
|
|
43
|
-
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
44
|
-
}
|
|
45
|
-
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
46
|
-
return configPropertyNames.parameters.required.every(req => req in config);
|
|
47
|
-
}
|
|
48
|
-
const keyPrefix = 'sustainability-reference-data';
|
|
49
|
-
|
|
50
|
-
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
51
|
-
const { isArray: ArrayIsArray } = Array;
|
|
52
|
-
const { stringify: JSONStringify } = JSON;
|
|
53
|
-
function deepFreeze$1(value) {
|
|
54
|
-
// No need to freeze primitives
|
|
55
|
-
if (typeof value !== 'object' || value === null) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (ArrayIsArray(value)) {
|
|
59
|
-
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
60
|
-
deepFreeze$1(value[i]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
const keys = ObjectKeys(value);
|
|
65
|
-
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
66
|
-
deepFreeze$1(value[keys[i]]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
ObjectFreeze(value);
|
|
70
|
-
}
|
|
71
|
-
function createLink(ref) {
|
|
72
|
-
return {
|
|
73
|
-
__ref: engine.serializeStructuredKey(ref),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const TTL = 300;
|
|
78
|
-
const VERSION = "7ae5f7cb4621bb79199bb51fc64f6e83";
|
|
79
|
-
function validate(obj, path = 'SCReferenceDataOutputRepresentation') {
|
|
80
|
-
const v_error = (() => {
|
|
81
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
82
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
83
|
-
}
|
|
84
|
-
const obj_code = obj.code;
|
|
85
|
-
const path_code = path + '.code';
|
|
86
|
-
if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
|
|
87
|
-
return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
|
|
88
|
-
}
|
|
89
|
-
const obj_message = obj.message;
|
|
90
|
-
const path_message = path + '.message';
|
|
91
|
-
if (typeof obj_message !== 'string') {
|
|
92
|
-
return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
|
|
93
|
-
}
|
|
94
|
-
})();
|
|
95
|
-
return v_error === undefined ? null : v_error;
|
|
96
|
-
}
|
|
97
|
-
const RepresentationType = 'SCReferenceDataOutputRepresentation';
|
|
98
|
-
function keyBuilder(luvio, config) {
|
|
99
|
-
return keyPrefix + '::' + RepresentationType + ':' + config.message;
|
|
100
|
-
}
|
|
101
|
-
function keyBuilderFromType(luvio, object) {
|
|
102
|
-
const keyParams = {
|
|
103
|
-
message: object.message
|
|
104
|
-
};
|
|
105
|
-
return keyBuilder(luvio, keyParams);
|
|
106
|
-
}
|
|
107
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
108
|
-
return input;
|
|
109
|
-
}
|
|
110
|
-
const select$1 = function SCReferenceDataOutputRepresentationSelect() {
|
|
111
|
-
return {
|
|
112
|
-
kind: 'Fragment',
|
|
113
|
-
version: VERSION,
|
|
114
|
-
private: [],
|
|
115
|
-
opaque: true
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
function equals(existing, incoming) {
|
|
119
|
-
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
function deepFreeze(input) {
|
|
125
|
-
ObjectFreeze(input);
|
|
126
|
-
}
|
|
127
|
-
const ingest = function SCReferenceDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
128
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
129
|
-
const validateError = validate(input);
|
|
130
|
-
if (validateError !== null) {
|
|
131
|
-
throw validateError;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const key = keyBuilderFromType(luvio, input);
|
|
135
|
-
const existingRecord = store.readEntry(key);
|
|
136
|
-
const ttlToUse = TTL;
|
|
137
|
-
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
138
|
-
fullPath: key,
|
|
139
|
-
parent: path.parent,
|
|
140
|
-
propertyName: path.propertyName,
|
|
141
|
-
ttl: ttlToUse
|
|
142
|
-
});
|
|
143
|
-
deepFreeze(input);
|
|
144
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
145
|
-
luvio.storePublish(key, incomingRecord);
|
|
146
|
-
}
|
|
147
|
-
{
|
|
148
|
-
const storeMetadataParams = {
|
|
149
|
-
ttl: ttlToUse,
|
|
150
|
-
namespace: "sustainability-reference-data",
|
|
151
|
-
version: VERSION,
|
|
152
|
-
representationName: RepresentationType,
|
|
153
|
-
};
|
|
154
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
155
|
-
}
|
|
156
|
-
return createLink(key);
|
|
157
|
-
};
|
|
158
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
159
|
-
const rootKeySet = new engine.StoreKeyMap();
|
|
160
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
161
|
-
const rootKey = keyBuilderFromType(luvio, input);
|
|
162
|
-
rootKeySet.set(rootKey, {
|
|
163
|
-
namespace: keyPrefix,
|
|
164
|
-
representationName: RepresentationType,
|
|
165
|
-
mergeable: false
|
|
166
|
-
});
|
|
167
|
-
return rootKeySet;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function select(luvio, params) {
|
|
171
|
-
return select$1();
|
|
172
|
-
}
|
|
173
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
174
|
-
return getTypeCacheKeys(luvio, response);
|
|
175
|
-
}
|
|
176
|
-
function ingestSuccess(luvio, resourceParams, response) {
|
|
177
|
-
const { body } = response;
|
|
178
|
-
const key = keyBuilderFromType(luvio, body);
|
|
179
|
-
luvio.storeIngest(key, ingest, body);
|
|
180
|
-
const snapshot = luvio.storeLookup({
|
|
181
|
-
recordId: key,
|
|
182
|
-
node: select(),
|
|
183
|
-
variables: {},
|
|
184
|
-
});
|
|
185
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
186
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
187
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return snapshot;
|
|
191
|
-
}
|
|
192
|
-
function createResourceRequest(config) {
|
|
193
|
-
const headers = {};
|
|
194
|
-
return {
|
|
195
|
-
baseUri: '/services/data/v58.0',
|
|
196
|
-
basePath: '/connect/sustainability/reference-data/' + config.urlParams.category + '/upload',
|
|
197
|
-
method: 'post',
|
|
198
|
-
body: null,
|
|
199
|
-
urlParams: config.urlParams,
|
|
200
|
-
queryParams: config.queryParams,
|
|
201
|
-
headers,
|
|
202
|
-
priority: 'normal',
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const uploadReferenceData_ConfigPropertyNames = {
|
|
207
|
-
displayName: 'uploadReferenceData',
|
|
208
|
-
parameters: {
|
|
209
|
-
required: ['category'],
|
|
210
|
-
optional: ['recordTypeId']
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
function createResourceParams(config) {
|
|
214
|
-
const resourceParams = {
|
|
215
|
-
urlParams: {
|
|
216
|
-
category: config.category
|
|
217
|
-
},
|
|
218
|
-
queryParams: {
|
|
219
|
-
recordTypeId: config.recordTypeId
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
return resourceParams;
|
|
223
|
-
}
|
|
224
|
-
function typeCheckConfig(untrustedConfig) {
|
|
225
|
-
const config = {};
|
|
226
|
-
const untrustedConfig_category = untrustedConfig.category;
|
|
227
|
-
if (typeof untrustedConfig_category === 'string') {
|
|
228
|
-
config.category = untrustedConfig_category;
|
|
229
|
-
}
|
|
230
|
-
const untrustedConfig_recordTypeId = untrustedConfig.recordTypeId;
|
|
231
|
-
if (typeof untrustedConfig_recordTypeId === 'string') {
|
|
232
|
-
config.recordTypeId = untrustedConfig_recordTypeId;
|
|
233
|
-
}
|
|
234
|
-
return config;
|
|
235
|
-
}
|
|
236
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
237
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
241
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
242
|
-
}
|
|
243
|
-
const config = typeCheckConfig(untrustedConfig);
|
|
244
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
return config;
|
|
248
|
-
}
|
|
249
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
250
|
-
const resourceParams = createResourceParams(config);
|
|
251
|
-
const request = createResourceRequest(resourceParams);
|
|
252
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
253
|
-
.then((response) => {
|
|
254
|
-
return luvio.handleSuccessResponse(() => {
|
|
255
|
-
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
256
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
257
|
-
}, () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
258
|
-
}, (response) => {
|
|
259
|
-
deepFreeze$1(response);
|
|
260
|
-
throw response;
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
const uploadReferenceDataAdapterFactory = (luvio) => {
|
|
264
|
-
return function uploadReferenceData(untrustedConfig) {
|
|
265
|
-
const config = validateAdapterConfig(untrustedConfig, uploadReferenceData_ConfigPropertyNames);
|
|
266
|
-
// Invalid or incomplete config
|
|
267
|
-
if (config === null) {
|
|
268
|
-
throw new Error('Invalid config for "uploadReferenceData"');
|
|
269
|
-
}
|
|
270
|
-
return buildNetworkSnapshot(luvio, config);
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
exports.uploadReferenceDataAdapterFactory = uploadReferenceDataAdapterFactory;
|
|
275
|
-
|
|
276
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
277
|
-
|
|
278
|
-
}));
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* For full license text, see the LICENSE.txt file
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
(function (global, factory) {
|
|
8
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["industriesSustainability-reference-data"] = {}, global.engine));
|
|
11
|
-
})(this, (function (exports, engine) { 'use strict';
|
|
12
|
-
|
|
13
|
-
var ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty;
|
|
14
|
-
var ObjectKeys$1 = Object.keys;
|
|
15
|
-
var ArrayIsArray$1 = Array.isArray;
|
|
16
|
-
/**
|
|
17
|
-
* Validates an adapter config is well-formed.
|
|
18
|
-
* @param config The config to validate.
|
|
19
|
-
* @param adapter The adapter validation configuration.
|
|
20
|
-
* @param oneOf The keys the config must contain at least one of.
|
|
21
|
-
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
22
|
-
*/
|
|
23
|
-
function validateConfig(config, adapter, oneOf) {
|
|
24
|
-
var displayName = adapter.displayName;
|
|
25
|
-
var _a = adapter.parameters, required = _a.required, optional = _a.optional, unsupported = _a.unsupported;
|
|
26
|
-
if (config === undefined ||
|
|
27
|
-
required.every(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); }) === false) {
|
|
28
|
-
throw new TypeError("adapter ".concat(displayName, " configuration must specify ").concat(required.sort().join(', ')));
|
|
29
|
-
}
|
|
30
|
-
if (oneOf && oneOf.some(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); }) === false) {
|
|
31
|
-
throw new TypeError("adapter ".concat(displayName, " configuration must specify one of ").concat(oneOf.sort().join(', ')));
|
|
32
|
-
}
|
|
33
|
-
if (unsupported !== undefined &&
|
|
34
|
-
unsupported.some(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); })) {
|
|
35
|
-
throw new TypeError("adapter ".concat(displayName, " does not yet support ").concat(unsupported.sort().join(', ')));
|
|
36
|
-
}
|
|
37
|
-
var supported = required.concat(optional);
|
|
38
|
-
if (ObjectKeys$1(config).some(function (key) { return !supported.includes(key); })) {
|
|
39
|
-
throw new TypeError("adapter ".concat(displayName, " configuration supports only ").concat(supported.sort().join(', ')));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function untrustedIsObject(untrusted) {
|
|
43
|
-
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
44
|
-
}
|
|
45
|
-
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
46
|
-
return configPropertyNames.parameters.required.every(function (req) { return req in config; });
|
|
47
|
-
}
|
|
48
|
-
var keyPrefix = 'sustainability-reference-data';
|
|
49
|
-
|
|
50
|
-
var ObjectFreeze = Object.freeze, ObjectKeys = Object.keys;
|
|
51
|
-
var ArrayIsArray = Array.isArray;
|
|
52
|
-
var JSONStringify = JSON.stringify;
|
|
53
|
-
function deepFreeze$1(value) {
|
|
54
|
-
// No need to freeze primitives
|
|
55
|
-
if (typeof value !== 'object' || value === null) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (ArrayIsArray(value)) {
|
|
59
|
-
for (var i = 0, len = value.length; i < len; i += 1) {
|
|
60
|
-
deepFreeze$1(value[i]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
var keys = ObjectKeys(value);
|
|
65
|
-
for (var i = 0, len = keys.length; i < len; i += 1) {
|
|
66
|
-
deepFreeze$1(value[keys[i]]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
ObjectFreeze(value);
|
|
70
|
-
}
|
|
71
|
-
function createLink(ref) {
|
|
72
|
-
return {
|
|
73
|
-
__ref: engine.serializeStructuredKey(ref),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var TTL = 300;
|
|
78
|
-
var VERSION = "7ae5f7cb4621bb79199bb51fc64f6e83";
|
|
79
|
-
function validate(obj, path) {
|
|
80
|
-
if (path === void 0) { path = 'SCReferenceDataOutputRepresentation'; }
|
|
81
|
-
var v_error = (function () {
|
|
82
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
83
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
84
|
-
}
|
|
85
|
-
var obj_code = obj.code;
|
|
86
|
-
var path_code = path + '.code';
|
|
87
|
-
if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
|
|
88
|
-
return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
|
|
89
|
-
}
|
|
90
|
-
var obj_message = obj.message;
|
|
91
|
-
var path_message = path + '.message';
|
|
92
|
-
if (typeof obj_message !== 'string') {
|
|
93
|
-
return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
|
|
94
|
-
}
|
|
95
|
-
})();
|
|
96
|
-
return v_error === undefined ? null : v_error;
|
|
97
|
-
}
|
|
98
|
-
var RepresentationType = 'SCReferenceDataOutputRepresentation';
|
|
99
|
-
function keyBuilder(luvio, config) {
|
|
100
|
-
return keyPrefix + '::' + RepresentationType + ':' + config.message;
|
|
101
|
-
}
|
|
102
|
-
function keyBuilderFromType(luvio, object) {
|
|
103
|
-
var keyParams = {
|
|
104
|
-
message: object.message
|
|
105
|
-
};
|
|
106
|
-
return keyBuilder(luvio, keyParams);
|
|
107
|
-
}
|
|
108
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
109
|
-
return input;
|
|
110
|
-
}
|
|
111
|
-
var select$1 = function SCReferenceDataOutputRepresentationSelect() {
|
|
112
|
-
return {
|
|
113
|
-
kind: 'Fragment',
|
|
114
|
-
version: VERSION,
|
|
115
|
-
private: [],
|
|
116
|
-
opaque: true
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
function equals(existing, incoming) {
|
|
120
|
-
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
function deepFreeze(input) {
|
|
126
|
-
ObjectFreeze(input);
|
|
127
|
-
}
|
|
128
|
-
var ingest = function SCReferenceDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
129
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
130
|
-
var validateError = validate(input);
|
|
131
|
-
if (validateError !== null) {
|
|
132
|
-
throw validateError;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
var key = keyBuilderFromType(luvio, input);
|
|
136
|
-
var existingRecord = store.readEntry(key);
|
|
137
|
-
var ttlToUse = TTL;
|
|
138
|
-
var incomingRecord = normalize(input, store.readEntry(key), {
|
|
139
|
-
fullPath: key,
|
|
140
|
-
parent: path.parent,
|
|
141
|
-
propertyName: path.propertyName,
|
|
142
|
-
ttl: ttlToUse
|
|
143
|
-
});
|
|
144
|
-
deepFreeze(input);
|
|
145
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
146
|
-
luvio.storePublish(key, incomingRecord);
|
|
147
|
-
}
|
|
148
|
-
{
|
|
149
|
-
var storeMetadataParams = {
|
|
150
|
-
ttl: ttlToUse,
|
|
151
|
-
namespace: "sustainability-reference-data",
|
|
152
|
-
version: VERSION,
|
|
153
|
-
representationName: RepresentationType,
|
|
154
|
-
};
|
|
155
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
156
|
-
}
|
|
157
|
-
return createLink(key);
|
|
158
|
-
};
|
|
159
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
160
|
-
var rootKeySet = new engine.StoreKeyMap();
|
|
161
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
162
|
-
var rootKey = keyBuilderFromType(luvio, input);
|
|
163
|
-
rootKeySet.set(rootKey, {
|
|
164
|
-
namespace: keyPrefix,
|
|
165
|
-
representationName: RepresentationType,
|
|
166
|
-
mergeable: false
|
|
167
|
-
});
|
|
168
|
-
return rootKeySet;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function select(luvio, params) {
|
|
172
|
-
return select$1();
|
|
173
|
-
}
|
|
174
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
175
|
-
return getTypeCacheKeys(luvio, response);
|
|
176
|
-
}
|
|
177
|
-
function ingestSuccess(luvio, resourceParams, response) {
|
|
178
|
-
var body = response.body;
|
|
179
|
-
var key = keyBuilderFromType(luvio, body);
|
|
180
|
-
luvio.storeIngest(key, ingest, body);
|
|
181
|
-
var snapshot = luvio.storeLookup({
|
|
182
|
-
recordId: key,
|
|
183
|
-
node: select(),
|
|
184
|
-
variables: {},
|
|
185
|
-
});
|
|
186
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
187
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
188
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return snapshot;
|
|
192
|
-
}
|
|
193
|
-
function createResourceRequest(config) {
|
|
194
|
-
var headers = {};
|
|
195
|
-
return {
|
|
196
|
-
baseUri: '/services/data/v58.0',
|
|
197
|
-
basePath: '/connect/sustainability/reference-data/' + config.urlParams.category + '/upload',
|
|
198
|
-
method: 'post',
|
|
199
|
-
body: null,
|
|
200
|
-
urlParams: config.urlParams,
|
|
201
|
-
queryParams: config.queryParams,
|
|
202
|
-
headers: headers,
|
|
203
|
-
priority: 'normal',
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
var uploadReferenceData_ConfigPropertyNames = {
|
|
208
|
-
displayName: 'uploadReferenceData',
|
|
209
|
-
parameters: {
|
|
210
|
-
required: ['category'],
|
|
211
|
-
optional: ['recordTypeId']
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
function createResourceParams(config) {
|
|
215
|
-
var resourceParams = {
|
|
216
|
-
urlParams: {
|
|
217
|
-
category: config.category
|
|
218
|
-
},
|
|
219
|
-
queryParams: {
|
|
220
|
-
recordTypeId: config.recordTypeId
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
return resourceParams;
|
|
224
|
-
}
|
|
225
|
-
function typeCheckConfig(untrustedConfig) {
|
|
226
|
-
var config = {};
|
|
227
|
-
var untrustedConfig_category = untrustedConfig.category;
|
|
228
|
-
if (typeof untrustedConfig_category === 'string') {
|
|
229
|
-
config.category = untrustedConfig_category;
|
|
230
|
-
}
|
|
231
|
-
var untrustedConfig_recordTypeId = untrustedConfig.recordTypeId;
|
|
232
|
-
if (typeof untrustedConfig_recordTypeId === 'string') {
|
|
233
|
-
config.recordTypeId = untrustedConfig_recordTypeId;
|
|
234
|
-
}
|
|
235
|
-
return config;
|
|
236
|
-
}
|
|
237
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
238
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
242
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
243
|
-
}
|
|
244
|
-
var config = typeCheckConfig(untrustedConfig);
|
|
245
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
return config;
|
|
249
|
-
}
|
|
250
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
251
|
-
var resourceParams = createResourceParams(config);
|
|
252
|
-
var request = createResourceRequest(resourceParams);
|
|
253
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
254
|
-
.then(function (response) {
|
|
255
|
-
return luvio.handleSuccessResponse(function () {
|
|
256
|
-
var snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
257
|
-
return luvio.storeBroadcast().then(function () { return snapshot; });
|
|
258
|
-
}, function () { return getResponseCacheKeys(luvio, resourceParams, response.body); });
|
|
259
|
-
}, function (response) {
|
|
260
|
-
deepFreeze$1(response);
|
|
261
|
-
throw response;
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
var uploadReferenceDataAdapterFactory = function (luvio) {
|
|
265
|
-
return function uploadReferenceData(untrustedConfig) {
|
|
266
|
-
var config = validateAdapterConfig(untrustedConfig, uploadReferenceData_ConfigPropertyNames);
|
|
267
|
-
// Invalid or incomplete config
|
|
268
|
-
if (config === null) {
|
|
269
|
-
throw new Error('Invalid config for "uploadReferenceData"');
|
|
270
|
-
}
|
|
271
|
-
return buildNetworkSnapshot(luvio, config);
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
exports.uploadReferenceDataAdapterFactory = uploadReferenceDataAdapterFactory;
|
|
276
|
-
|
|
277
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
278
|
-
|
|
279
|
-
}));
|