@salesforce/lds-adapters-industries-sustainability-reference-data 1.100.2
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-sustainability-reference-data.js +270 -0
- package/dist/types/src/generated/adapters/adapter-utils.d.ts +66 -0
- package/dist/types/src/generated/adapters/uploadReferenceData.d.ts +15 -0
- package/dist/types/src/generated/artifacts/main.d.ts +1 -0
- package/dist/types/src/generated/artifacts/sfdc.d.ts +2 -0
- package/dist/types/src/generated/resources/postConnectSustainabilityReferenceDataUploadByCategory.d.ts +15 -0
- package/dist/types/src/generated/types/SCReferenceDataOutputRepresentation.d.ts +42 -0
- package/dist/types/src/generated/types/type-utils.d.ts +39 -0
- package/dist/umd/es2018/industries-sustainability-reference-data.js +278 -0
- package/dist/umd/es5/industries-sustainability-reference-data.js +279 -0
- package/package.json +66 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +297 -0
- package/src/raml/api.raml +54 -0
- package/src/raml/luvio.raml +18 -0
package/sfdc/index.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
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 { withDefaultLuvio } from 'force/ldsEngine';
|
|
16
|
+
import { serializeStructuredKey, StoreKeyMap } from 'force/luvioEngine';
|
|
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
|
+
}
|
|
53
|
+
const keyPrefix = 'sustainability-reference-data';
|
|
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
|
+
};
|
|
80
|
+
}
|
|
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;
|
|
173
|
+
}
|
|
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
|
+
};
|
|
209
|
+
}
|
|
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
|
+
};
|
|
277
|
+
};
|
|
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));
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
export { uploadReferenceData };
|
|
297
|
+
// version: 1.100.2-ca56bb821
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#%RAML 1.0
|
|
2
|
+
securedBy:
|
|
3
|
+
- OAuth2
|
|
4
|
+
title: Salesforce Connect API
|
|
5
|
+
version: '54.0'
|
|
6
|
+
mediaType: application/json
|
|
7
|
+
protocols:
|
|
8
|
+
- https
|
|
9
|
+
baseUri: /services/data/v58.0
|
|
10
|
+
securitySchemes:
|
|
11
|
+
OAuth2:
|
|
12
|
+
type: OAuth 2.0
|
|
13
|
+
settings:
|
|
14
|
+
authorizationUri: https://example.com/oauth/authorize
|
|
15
|
+
accessTokenUri: ''
|
|
16
|
+
authorizationGrants:
|
|
17
|
+
- implicit
|
|
18
|
+
annotationTypes:
|
|
19
|
+
oas-readOnly:
|
|
20
|
+
type: boolean
|
|
21
|
+
allowedTargets: TypeDeclaration
|
|
22
|
+
oas-collectionFormat:
|
|
23
|
+
type: string
|
|
24
|
+
oas-body-name:
|
|
25
|
+
type: string
|
|
26
|
+
allowedTargets: TypeDeclaration
|
|
27
|
+
types:
|
|
28
|
+
SCReferenceDataOutputRepresentation:
|
|
29
|
+
description: Represents the response and its status
|
|
30
|
+
type: object
|
|
31
|
+
properties:
|
|
32
|
+
code:
|
|
33
|
+
description: Reference Data Output Code
|
|
34
|
+
type: integer
|
|
35
|
+
message:
|
|
36
|
+
description: Reference Data Output Message
|
|
37
|
+
type: string
|
|
38
|
+
/connect/sustainability/reference-data/{category}/upload:
|
|
39
|
+
post:
|
|
40
|
+
description: Used for uploading Reference Data based on the category
|
|
41
|
+
responses:
|
|
42
|
+
'200':
|
|
43
|
+
description: Success
|
|
44
|
+
body:
|
|
45
|
+
application/json:
|
|
46
|
+
type: SCReferenceDataOutputRepresentation
|
|
47
|
+
queryParameters:
|
|
48
|
+
recordTypeId:
|
|
49
|
+
type: string
|
|
50
|
+
required: false
|
|
51
|
+
uriParameters:
|
|
52
|
+
category:
|
|
53
|
+
type: string
|
|
54
|
+
required: true
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#%RAML 1.0 Overlay
|
|
2
|
+
extends: ./api.raml
|
|
3
|
+
|
|
4
|
+
uses:
|
|
5
|
+
luvio: luvio://annotations.raml
|
|
6
|
+
|
|
7
|
+
(luvio.keyPrefix): 'sustainability-reference-data'
|
|
8
|
+
types:
|
|
9
|
+
SCReferenceDataOutputRepresentation:
|
|
10
|
+
(luvio.ttl): 300
|
|
11
|
+
(luvio.opaque): true
|
|
12
|
+
(luvio.key):
|
|
13
|
+
message: message
|
|
14
|
+
|
|
15
|
+
/connect/sustainability/reference-data/{category}/upload:
|
|
16
|
+
post:
|
|
17
|
+
(luvio.adapter):
|
|
18
|
+
name: uploadReferenceData
|