@salesforce/lds-adapters-industries-sustainability-reference-data 1.124.2 → 1.124.4

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