@salesforce/lds-adapters-industries-sustainability-reference-data 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/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
|
@@ -6,265 +6,265 @@
|
|
|
6
6
|
|
|
7
7
|
import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
|
|
8
8
|
|
|
9
|
-
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
-
const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = 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$1(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
|
-
}
|
|
9
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
+
const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = 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$1(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
44
|
const keyPrefix = 'sustainability-reference-data';
|
|
45
45
|
|
|
46
|
-
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
47
|
-
const { isArray: ArrayIsArray } = Array;
|
|
48
|
-
const { stringify: JSONStringify } = JSON;
|
|
49
|
-
function deepFreeze$1(value) {
|
|
50
|
-
// No need to freeze primitives
|
|
51
|
-
if (typeof value !== 'object' || value === null) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (ArrayIsArray(value)) {
|
|
55
|
-
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
56
|
-
deepFreeze$1(value[i]);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const keys = ObjectKeys(value);
|
|
61
|
-
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
62
|
-
deepFreeze$1(value[keys[i]]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
ObjectFreeze(value);
|
|
66
|
-
}
|
|
67
|
-
function createLink(ref) {
|
|
68
|
-
return {
|
|
69
|
-
__ref: serializeStructuredKey(ref),
|
|
70
|
-
};
|
|
46
|
+
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
47
|
+
const { isArray: ArrayIsArray } = Array;
|
|
48
|
+
const { stringify: JSONStringify } = JSON;
|
|
49
|
+
function deepFreeze$1(value) {
|
|
50
|
+
// No need to freeze primitives
|
|
51
|
+
if (typeof value !== 'object' || value === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (ArrayIsArray(value)) {
|
|
55
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
56
|
+
deepFreeze$1(value[i]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const keys = ObjectKeys(value);
|
|
61
|
+
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
62
|
+
deepFreeze$1(value[keys[i]]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ObjectFreeze(value);
|
|
66
|
+
}
|
|
67
|
+
function createLink(ref) {
|
|
68
|
+
return {
|
|
69
|
+
__ref: serializeStructuredKey(ref),
|
|
70
|
+
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const TTL = 300;
|
|
74
|
-
const VERSION = "7ae5f7cb4621bb79199bb51fc64f6e83";
|
|
75
|
-
function validate(obj, path = 'SCReferenceDataOutputRepresentation') {
|
|
76
|
-
const v_error = (() => {
|
|
77
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
78
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
79
|
-
}
|
|
80
|
-
const obj_code = obj.code;
|
|
81
|
-
const path_code = path + '.code';
|
|
82
|
-
if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
|
|
83
|
-
return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
|
|
84
|
-
}
|
|
85
|
-
const obj_message = obj.message;
|
|
86
|
-
const path_message = path + '.message';
|
|
87
|
-
if (typeof obj_message !== 'string') {
|
|
88
|
-
return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
|
|
89
|
-
}
|
|
90
|
-
})();
|
|
91
|
-
return v_error === undefined ? null : v_error;
|
|
92
|
-
}
|
|
93
|
-
const RepresentationType = 'SCReferenceDataOutputRepresentation';
|
|
94
|
-
function keyBuilder(luvio, config) {
|
|
95
|
-
return keyPrefix + '::' + RepresentationType + ':' + config.message;
|
|
96
|
-
}
|
|
97
|
-
function keyBuilderFromType(luvio, object) {
|
|
98
|
-
const keyParams = {
|
|
99
|
-
message: object.message
|
|
100
|
-
};
|
|
101
|
-
return keyBuilder(luvio, keyParams);
|
|
102
|
-
}
|
|
103
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
104
|
-
return input;
|
|
105
|
-
}
|
|
106
|
-
const select$1 = function SCReferenceDataOutputRepresentationSelect() {
|
|
107
|
-
return {
|
|
108
|
-
kind: 'Fragment',
|
|
109
|
-
version: VERSION,
|
|
110
|
-
private: [],
|
|
111
|
-
opaque: true
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
function equals(existing, incoming) {
|
|
115
|
-
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
function deepFreeze(input) {
|
|
121
|
-
ObjectFreeze(input);
|
|
122
|
-
}
|
|
123
|
-
const ingest = function SCReferenceDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
124
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
125
|
-
const validateError = validate(input);
|
|
126
|
-
if (validateError !== null) {
|
|
127
|
-
throw validateError;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const key = keyBuilderFromType(luvio, input);
|
|
131
|
-
const existingRecord = store.readEntry(key);
|
|
132
|
-
const ttlToUse = TTL;
|
|
133
|
-
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
134
|
-
fullPath: key,
|
|
135
|
-
parent: path.parent,
|
|
136
|
-
propertyName: path.propertyName,
|
|
137
|
-
ttl: ttlToUse
|
|
138
|
-
});
|
|
139
|
-
deepFreeze(input);
|
|
140
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
141
|
-
luvio.storePublish(key, incomingRecord);
|
|
142
|
-
}
|
|
143
|
-
{
|
|
144
|
-
const storeMetadataParams = {
|
|
145
|
-
ttl: ttlToUse,
|
|
146
|
-
namespace: "sustainability-reference-data",
|
|
147
|
-
version: VERSION,
|
|
148
|
-
representationName: RepresentationType,
|
|
149
|
-
};
|
|
150
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
151
|
-
}
|
|
152
|
-
return createLink(key);
|
|
153
|
-
};
|
|
154
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
155
|
-
const rootKeySet = new StoreKeyMap();
|
|
156
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
157
|
-
const rootKey = keyBuilderFromType(luvio, input);
|
|
158
|
-
rootKeySet.set(rootKey, {
|
|
159
|
-
namespace: keyPrefix,
|
|
160
|
-
representationName: RepresentationType,
|
|
161
|
-
mergeable: false
|
|
162
|
-
});
|
|
163
|
-
return rootKeySet;
|
|
73
|
+
const TTL = 300;
|
|
74
|
+
const VERSION = "7ae5f7cb4621bb79199bb51fc64f6e83";
|
|
75
|
+
function validate(obj, path = 'SCReferenceDataOutputRepresentation') {
|
|
76
|
+
const v_error = (() => {
|
|
77
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
78
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
79
|
+
}
|
|
80
|
+
const obj_code = obj.code;
|
|
81
|
+
const path_code = path + '.code';
|
|
82
|
+
if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
|
|
83
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
|
|
84
|
+
}
|
|
85
|
+
const obj_message = obj.message;
|
|
86
|
+
const path_message = path + '.message';
|
|
87
|
+
if (typeof obj_message !== 'string') {
|
|
88
|
+
return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
return v_error === undefined ? null : v_error;
|
|
92
|
+
}
|
|
93
|
+
const RepresentationType = 'SCReferenceDataOutputRepresentation';
|
|
94
|
+
function keyBuilder(luvio, config) {
|
|
95
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.message;
|
|
96
|
+
}
|
|
97
|
+
function keyBuilderFromType(luvio, object) {
|
|
98
|
+
const keyParams = {
|
|
99
|
+
message: object.message
|
|
100
|
+
};
|
|
101
|
+
return keyBuilder(luvio, keyParams);
|
|
102
|
+
}
|
|
103
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
104
|
+
return input;
|
|
105
|
+
}
|
|
106
|
+
const select$1 = function SCReferenceDataOutputRepresentationSelect() {
|
|
107
|
+
return {
|
|
108
|
+
kind: 'Fragment',
|
|
109
|
+
version: VERSION,
|
|
110
|
+
private: [],
|
|
111
|
+
opaque: true
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
function equals(existing, incoming) {
|
|
115
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
function deepFreeze(input) {
|
|
121
|
+
ObjectFreeze(input);
|
|
122
|
+
}
|
|
123
|
+
const ingest = function SCReferenceDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
124
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
125
|
+
const validateError = validate(input);
|
|
126
|
+
if (validateError !== null) {
|
|
127
|
+
throw validateError;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const key = keyBuilderFromType(luvio, input);
|
|
131
|
+
const existingRecord = store.readEntry(key);
|
|
132
|
+
const ttlToUse = TTL;
|
|
133
|
+
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
134
|
+
fullPath: key,
|
|
135
|
+
parent: path.parent,
|
|
136
|
+
propertyName: path.propertyName,
|
|
137
|
+
ttl: ttlToUse
|
|
138
|
+
});
|
|
139
|
+
deepFreeze(input);
|
|
140
|
+
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
141
|
+
luvio.storePublish(key, incomingRecord);
|
|
142
|
+
}
|
|
143
|
+
{
|
|
144
|
+
const storeMetadataParams = {
|
|
145
|
+
ttl: ttlToUse,
|
|
146
|
+
namespace: "sustainability-reference-data",
|
|
147
|
+
version: VERSION,
|
|
148
|
+
representationName: RepresentationType,
|
|
149
|
+
};
|
|
150
|
+
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
151
|
+
}
|
|
152
|
+
return createLink(key);
|
|
153
|
+
};
|
|
154
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
155
|
+
const rootKeySet = new StoreKeyMap();
|
|
156
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
157
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
158
|
+
rootKeySet.set(rootKey, {
|
|
159
|
+
namespace: keyPrefix,
|
|
160
|
+
representationName: RepresentationType,
|
|
161
|
+
mergeable: false
|
|
162
|
+
});
|
|
163
|
+
return rootKeySet;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
function select(luvio, params) {
|
|
167
|
-
return select$1();
|
|
168
|
-
}
|
|
169
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
170
|
-
return getTypeCacheKeys(luvio, response);
|
|
171
|
-
}
|
|
172
|
-
function ingestSuccess(luvio, resourceParams, response) {
|
|
173
|
-
const { body } = response;
|
|
174
|
-
const key = keyBuilderFromType(luvio, body);
|
|
175
|
-
luvio.storeIngest(key, ingest, body);
|
|
176
|
-
const snapshot = luvio.storeLookup({
|
|
177
|
-
recordId: key,
|
|
178
|
-
node: select(),
|
|
179
|
-
variables: {},
|
|
180
|
-
});
|
|
181
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
182
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
183
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return snapshot;
|
|
187
|
-
}
|
|
188
|
-
function createResourceRequest(config) {
|
|
189
|
-
const headers = {};
|
|
190
|
-
return {
|
|
191
|
-
baseUri: '/services/data/v58.0',
|
|
192
|
-
basePath: '/connect/sustainability/reference-data/' + config.urlParams.category + '/upload',
|
|
193
|
-
method: 'post',
|
|
194
|
-
body: null,
|
|
195
|
-
urlParams: config.urlParams,
|
|
196
|
-
queryParams: config.queryParams,
|
|
197
|
-
headers,
|
|
198
|
-
priority: 'normal',
|
|
199
|
-
};
|
|
166
|
+
function select(luvio, params) {
|
|
167
|
+
return select$1();
|
|
168
|
+
}
|
|
169
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
170
|
+
return getTypeCacheKeys(luvio, response);
|
|
171
|
+
}
|
|
172
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
173
|
+
const { body } = response;
|
|
174
|
+
const key = keyBuilderFromType(luvio, body);
|
|
175
|
+
luvio.storeIngest(key, ingest, body);
|
|
176
|
+
const snapshot = luvio.storeLookup({
|
|
177
|
+
recordId: key,
|
|
178
|
+
node: select(),
|
|
179
|
+
variables: {},
|
|
180
|
+
});
|
|
181
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
182
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
183
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return snapshot;
|
|
187
|
+
}
|
|
188
|
+
function createResourceRequest(config) {
|
|
189
|
+
const headers = {};
|
|
190
|
+
return {
|
|
191
|
+
baseUri: '/services/data/v58.0',
|
|
192
|
+
basePath: '/connect/sustainability/reference-data/' + config.urlParams.category + '/upload',
|
|
193
|
+
method: 'post',
|
|
194
|
+
body: null,
|
|
195
|
+
urlParams: config.urlParams,
|
|
196
|
+
queryParams: config.queryParams,
|
|
197
|
+
headers,
|
|
198
|
+
priority: 'normal',
|
|
199
|
+
};
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
const uploadReferenceData_ConfigPropertyNames = {
|
|
203
|
-
displayName: 'uploadReferenceData',
|
|
204
|
-
parameters: {
|
|
205
|
-
required: ['category'],
|
|
206
|
-
optional: ['recordTypeId']
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
function createResourceParams(config) {
|
|
210
|
-
const resourceParams = {
|
|
211
|
-
urlParams: {
|
|
212
|
-
category: config.category
|
|
213
|
-
},
|
|
214
|
-
queryParams: {
|
|
215
|
-
recordTypeId: config.recordTypeId
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
return resourceParams;
|
|
219
|
-
}
|
|
220
|
-
function typeCheckConfig(untrustedConfig) {
|
|
221
|
-
const config = {};
|
|
222
|
-
const untrustedConfig_category = untrustedConfig.category;
|
|
223
|
-
if (typeof untrustedConfig_category === 'string') {
|
|
224
|
-
config.category = untrustedConfig_category;
|
|
225
|
-
}
|
|
226
|
-
const untrustedConfig_recordTypeId = untrustedConfig.recordTypeId;
|
|
227
|
-
if (typeof untrustedConfig_recordTypeId === 'string') {
|
|
228
|
-
config.recordTypeId = untrustedConfig_recordTypeId;
|
|
229
|
-
}
|
|
230
|
-
return config;
|
|
231
|
-
}
|
|
232
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
233
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
237
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
238
|
-
}
|
|
239
|
-
const config = typeCheckConfig(untrustedConfig);
|
|
240
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
return config;
|
|
244
|
-
}
|
|
245
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
246
|
-
const resourceParams = createResourceParams(config);
|
|
247
|
-
const request = createResourceRequest(resourceParams);
|
|
248
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
249
|
-
.then((response) => {
|
|
250
|
-
return luvio.handleSuccessResponse(() => {
|
|
251
|
-
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
252
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
253
|
-
}, () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
254
|
-
}, (response) => {
|
|
255
|
-
deepFreeze$1(response);
|
|
256
|
-
throw response;
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
const uploadReferenceDataAdapterFactory = (luvio) => {
|
|
260
|
-
return function uploadReferenceData(untrustedConfig) {
|
|
261
|
-
const config = validateAdapterConfig(untrustedConfig, uploadReferenceData_ConfigPropertyNames);
|
|
262
|
-
// Invalid or incomplete config
|
|
263
|
-
if (config === null) {
|
|
264
|
-
throw new Error('Invalid config for "uploadReferenceData"');
|
|
265
|
-
}
|
|
266
|
-
return buildNetworkSnapshot(luvio, config);
|
|
267
|
-
};
|
|
202
|
+
const uploadReferenceData_ConfigPropertyNames = {
|
|
203
|
+
displayName: 'uploadReferenceData',
|
|
204
|
+
parameters: {
|
|
205
|
+
required: ['category'],
|
|
206
|
+
optional: ['recordTypeId']
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
function createResourceParams(config) {
|
|
210
|
+
const resourceParams = {
|
|
211
|
+
urlParams: {
|
|
212
|
+
category: config.category
|
|
213
|
+
},
|
|
214
|
+
queryParams: {
|
|
215
|
+
recordTypeId: config.recordTypeId
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
return resourceParams;
|
|
219
|
+
}
|
|
220
|
+
function typeCheckConfig(untrustedConfig) {
|
|
221
|
+
const config = {};
|
|
222
|
+
const untrustedConfig_category = untrustedConfig.category;
|
|
223
|
+
if (typeof untrustedConfig_category === 'string') {
|
|
224
|
+
config.category = untrustedConfig_category;
|
|
225
|
+
}
|
|
226
|
+
const untrustedConfig_recordTypeId = untrustedConfig.recordTypeId;
|
|
227
|
+
if (typeof untrustedConfig_recordTypeId === 'string') {
|
|
228
|
+
config.recordTypeId = untrustedConfig_recordTypeId;
|
|
229
|
+
}
|
|
230
|
+
return config;
|
|
231
|
+
}
|
|
232
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
233
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
237
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
238
|
+
}
|
|
239
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
240
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
return config;
|
|
244
|
+
}
|
|
245
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
246
|
+
const resourceParams = createResourceParams(config);
|
|
247
|
+
const request = createResourceRequest(resourceParams);
|
|
248
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
249
|
+
.then((response) => {
|
|
250
|
+
return luvio.handleSuccessResponse(() => {
|
|
251
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
252
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
253
|
+
}, () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
254
|
+
}, (response) => {
|
|
255
|
+
deepFreeze$1(response);
|
|
256
|
+
throw response;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
const uploadReferenceDataAdapterFactory = (luvio) => {
|
|
260
|
+
return function uploadReferenceData(untrustedConfig) {
|
|
261
|
+
const config = validateAdapterConfig(untrustedConfig, uploadReferenceData_ConfigPropertyNames);
|
|
262
|
+
// Invalid or incomplete config
|
|
263
|
+
if (config === null) {
|
|
264
|
+
throw new Error('Invalid config for "uploadReferenceData"');
|
|
265
|
+
}
|
|
266
|
+
return buildNetworkSnapshot(luvio, config);
|
|
267
|
+
};
|
|
268
268
|
};
|
|
269
269
|
|
|
270
270
|
export { uploadReferenceDataAdapterFactory };
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot } from '@luvio/engine';
|
|
2
|
-
export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
|
|
3
|
-
declare const ObjectKeys: {
|
|
4
|
-
(o: object): string[];
|
|
5
|
-
(o: {}): string[];
|
|
6
|
-
}, ObjectFreeze: {
|
|
7
|
-
<T extends Function>(f: T): T;
|
|
8
|
-
<T_1 extends {
|
|
9
|
-
[idx: string]: object | U | null | undefined;
|
|
10
|
-
}, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>;
|
|
11
|
-
<T_2>(o: T_2): Readonly<T_2>;
|
|
12
|
-
}, ObjectCreate: {
|
|
13
|
-
(o: object | null): any;
|
|
14
|
-
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
15
|
-
};
|
|
16
|
-
export { ObjectFreeze, ObjectCreate, ObjectKeys };
|
|
17
|
-
export declare const ArrayIsArray: (arg: any) => arg is any[];
|
|
18
|
-
export declare const ArrayPrototypePush: (...items: any[]) => number;
|
|
19
|
-
export interface AdapterValidationConfig {
|
|
20
|
-
displayName: string;
|
|
21
|
-
parameters: {
|
|
22
|
-
required: string[];
|
|
23
|
-
optional: string[];
|
|
24
|
-
unsupported?: string[];
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Validates an adapter config is well-formed.
|
|
29
|
-
* @param config The config to validate.
|
|
30
|
-
* @param adapter The adapter validation configuration.
|
|
31
|
-
* @param oneOf The keys the config must contain at least one of.
|
|
32
|
-
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
33
|
-
*/
|
|
34
|
-
export declare function validateConfig<T>(config: Untrusted<T>, adapter: AdapterValidationConfig, oneOf?: string[]): void;
|
|
35
|
-
export declare function untrustedIsObject<Base>(untrusted: unknown): untrusted is Untrusted<Base>;
|
|
36
|
-
export type UncoercedConfiguration<Base, Options extends {
|
|
37
|
-
[key in keyof Base]?: any;
|
|
38
|
-
}> = {
|
|
39
|
-
[Key in keyof Base]?: Base[Key] | Options[Key];
|
|
40
|
-
};
|
|
41
|
-
export type Untrusted<Base> = Partial<Base>;
|
|
42
|
-
export declare function areRequiredParametersPresent<T>(config: any, configPropertyNames: AdapterValidationConfig): config is T;
|
|
43
|
-
export declare function refreshable<C, D, R>(adapter: $64$luvio_engine_Adapter<C, D>, resolve: (config: unknown) => Promise<$64$luvio_engine_Snapshot<R>>): $64$luvio_engine_Adapter<C, D>;
|
|
44
|
-
export declare const SNAPSHOT_STATE_FULFILLED = "Fulfilled";
|
|
45
|
-
export declare const SNAPSHOT_STATE_UNFULFILLED = "Unfulfilled";
|
|
46
|
-
export declare const snapshotRefreshOptions: {
|
|
47
|
-
overrides: {
|
|
48
|
-
headers: {
|
|
49
|
-
'Cache-Control': string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
|
|
55
|
-
* This is needed because insertion order for JSON.stringify(object) affects output:
|
|
56
|
-
* JSON.stringify({a: 1, b: 2})
|
|
57
|
-
* "{"a":1,"b":2}"
|
|
58
|
-
* JSON.stringify({b: 2, a: 1})
|
|
59
|
-
* "{"b":2,"a":1}"
|
|
60
|
-
* @param data Data to be JSON-stringified.
|
|
61
|
-
* @returns JSON.stringified value with consistent ordering of keys.
|
|
62
|
-
*/
|
|
63
|
-
export declare function stableJSONStringify(node: any): string | undefined;
|
|
64
|
-
export declare function getFetchResponseStatusText(status: number): string;
|
|
65
|
-
export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
|
|
66
|
-
export declare const keyPrefix = "sustainability-reference-data";
|
|
1
|
+
import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot } from '@luvio/engine';
|
|
2
|
+
export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
|
|
3
|
+
declare const ObjectKeys: {
|
|
4
|
+
(o: object): string[];
|
|
5
|
+
(o: {}): string[];
|
|
6
|
+
}, ObjectFreeze: {
|
|
7
|
+
<T extends Function>(f: T): T;
|
|
8
|
+
<T_1 extends {
|
|
9
|
+
[idx: string]: object | U | null | undefined;
|
|
10
|
+
}, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>;
|
|
11
|
+
<T_2>(o: T_2): Readonly<T_2>;
|
|
12
|
+
}, ObjectCreate: {
|
|
13
|
+
(o: object | null): any;
|
|
14
|
+
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
15
|
+
};
|
|
16
|
+
export { ObjectFreeze, ObjectCreate, ObjectKeys };
|
|
17
|
+
export declare const ArrayIsArray: (arg: any) => arg is any[];
|
|
18
|
+
export declare const ArrayPrototypePush: (...items: any[]) => number;
|
|
19
|
+
export interface AdapterValidationConfig {
|
|
20
|
+
displayName: string;
|
|
21
|
+
parameters: {
|
|
22
|
+
required: string[];
|
|
23
|
+
optional: string[];
|
|
24
|
+
unsupported?: string[];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates an adapter config is well-formed.
|
|
29
|
+
* @param config The config to validate.
|
|
30
|
+
* @param adapter The adapter validation configuration.
|
|
31
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
32
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateConfig<T>(config: Untrusted<T>, adapter: AdapterValidationConfig, oneOf?: string[]): void;
|
|
35
|
+
export declare function untrustedIsObject<Base>(untrusted: unknown): untrusted is Untrusted<Base>;
|
|
36
|
+
export type UncoercedConfiguration<Base, Options extends {
|
|
37
|
+
[key in keyof Base]?: any;
|
|
38
|
+
}> = {
|
|
39
|
+
[Key in keyof Base]?: Base[Key] | Options[Key];
|
|
40
|
+
};
|
|
41
|
+
export type Untrusted<Base> = Partial<Base>;
|
|
42
|
+
export declare function areRequiredParametersPresent<T>(config: any, configPropertyNames: AdapterValidationConfig): config is T;
|
|
43
|
+
export declare function refreshable<C, D, R>(adapter: $64$luvio_engine_Adapter<C, D>, resolve: (config: unknown) => Promise<$64$luvio_engine_Snapshot<R>>): $64$luvio_engine_Adapter<C, D>;
|
|
44
|
+
export declare const SNAPSHOT_STATE_FULFILLED = "Fulfilled";
|
|
45
|
+
export declare const SNAPSHOT_STATE_UNFULFILLED = "Unfulfilled";
|
|
46
|
+
export declare const snapshotRefreshOptions: {
|
|
47
|
+
overrides: {
|
|
48
|
+
headers: {
|
|
49
|
+
'Cache-Control': string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
|
|
55
|
+
* This is needed because insertion order for JSON.stringify(object) affects output:
|
|
56
|
+
* JSON.stringify({a: 1, b: 2})
|
|
57
|
+
* "{"a":1,"b":2}"
|
|
58
|
+
* JSON.stringify({b: 2, a: 1})
|
|
59
|
+
* "{"b":2,"a":1}"
|
|
60
|
+
* @param data Data to be JSON-stringified.
|
|
61
|
+
* @returns JSON.stringified value with consistent ordering of keys.
|
|
62
|
+
*/
|
|
63
|
+
export declare function stableJSONStringify(node: any): string | undefined;
|
|
64
|
+
export declare function getFetchResponseStatusText(status: number): string;
|
|
65
|
+
export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
|
|
66
|
+
export declare const keyPrefix = "sustainability-reference-data";
|