@salesforce/lds-adapters-industries-tearsheet 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/sfdc/index.js ADDED
@@ -0,0 +1,385 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /* *******************************************************************************************
8
+ * ATTENTION!
9
+ * THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
10
+ * If you would like to contribute to LDS, please follow the steps outlined in the git repo.
11
+ * Any changes made to this file in p4 will be automatically overwritten.
12
+ * *******************************************************************************************
13
+ */
14
+ /* proxy-compat-disable */
15
+ import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
16
+ import { withDefaultLuvio } from 'force/ldsEngine';
17
+ import { serializeStructuredKey, StoreKeyMap } from 'force/luvioEngine';
18
+
19
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
21
+ const { isArray: ArrayIsArray$1 } = Array;
22
+ /**
23
+ * Validates an adapter config is well-formed.
24
+ * @param config The config to validate.
25
+ * @param adapter The adapter validation configuration.
26
+ * @param oneOf The keys the config must contain at least one of.
27
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
28
+ */
29
+ function validateConfig(config, adapter, oneOf) {
30
+ const { displayName } = adapter;
31
+ const { required, optional, unsupported } = adapter.parameters;
32
+ if (config === undefined ||
33
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
34
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
35
+ }
36
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
37
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
38
+ }
39
+ if (unsupported !== undefined &&
40
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
41
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
42
+ }
43
+ const supported = required.concat(optional);
44
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
45
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
46
+ }
47
+ }
48
+ function untrustedIsObject(untrusted) {
49
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
50
+ }
51
+ function areRequiredParametersPresent(config, configPropertyNames) {
52
+ return configPropertyNames.parameters.required.every(req => req in config);
53
+ }
54
+ const snapshotRefreshOptions = {
55
+ overrides: {
56
+ headers: {
57
+ 'Cache-Control': 'no-cache',
58
+ },
59
+ }
60
+ };
61
+ const keyPrefix = 'tearsheet';
62
+
63
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
64
+ const { isArray: ArrayIsArray } = Array;
65
+ const { stringify: JSONStringify } = JSON;
66
+ function createLink(ref) {
67
+ return {
68
+ __ref: serializeStructuredKey(ref),
69
+ };
70
+ }
71
+
72
+ function validate$1(obj, path = 'TearsheetRepresentation') {
73
+ const v_error = (() => {
74
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
75
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
76
+ }
77
+ const obj_id = obj.id;
78
+ const path_id = path + '.id';
79
+ if (typeof obj_id !== 'string') {
80
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
81
+ }
82
+ const obj_title = obj.title;
83
+ const path_title = path + '.title';
84
+ if (typeof obj_title !== 'string') {
85
+ return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
86
+ }
87
+ })();
88
+ return v_error === undefined ? null : v_error;
89
+ }
90
+ function deepFreeze$1(input) {
91
+ ObjectFreeze(input);
92
+ }
93
+
94
+ const TTL = 1000;
95
+ const VERSION = "33cf28595aef16a27da68accf962bce3";
96
+ function validate(obj, path = 'TearsheetListRepresentation') {
97
+ const v_error = (() => {
98
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
99
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
100
+ }
101
+ const obj_data = obj.data;
102
+ const path_data = path + '.data';
103
+ if (!ArrayIsArray(obj_data)) {
104
+ return new TypeError('Expected "array" but received "' + typeof obj_data + '" (at "' + path_data + '")');
105
+ }
106
+ for (let i = 0; i < obj_data.length; i++) {
107
+ const obj_data_item = obj_data[i];
108
+ const path_data_item = path_data + '[' + i + ']';
109
+ const referencepath_data_itemValidationError = validate$1(obj_data_item, path_data_item);
110
+ if (referencepath_data_itemValidationError !== null) {
111
+ let message = 'Object doesn\'t match TearsheetRepresentation (at "' + path_data_item + '")\n';
112
+ message += referencepath_data_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
113
+ return new TypeError(message);
114
+ }
115
+ }
116
+ })();
117
+ return v_error === undefined ? null : v_error;
118
+ }
119
+ const RepresentationType = 'TearsheetListRepresentation';
120
+ function normalize(input, existing, path, luvio, store, timestamp) {
121
+ return input;
122
+ }
123
+ const select$1 = function TearsheetListRepresentationSelect() {
124
+ return {
125
+ kind: 'Fragment',
126
+ version: VERSION,
127
+ private: [],
128
+ opaque: true
129
+ };
130
+ };
131
+ function equals(existing, incoming) {
132
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
133
+ return false;
134
+ }
135
+ return true;
136
+ }
137
+ function deepFreeze(input) {
138
+ const input_data = input.data;
139
+ for (let i = 0; i < input_data.length; i++) {
140
+ const input_data_item = input_data[i];
141
+ deepFreeze$1(input_data_item);
142
+ }
143
+ ObjectFreeze(input_data);
144
+ ObjectFreeze(input);
145
+ }
146
+ const ingest = function TearsheetListRepresentationIngest(input, path, luvio, store, timestamp) {
147
+ if (process.env.NODE_ENV !== 'production') {
148
+ const validateError = validate(input);
149
+ if (validateError !== null) {
150
+ throw validateError;
151
+ }
152
+ }
153
+ const key = path.fullPath;
154
+ const existingRecord = store.readEntry(key);
155
+ const ttlToUse = TTL;
156
+ let incomingRecord = normalize(input, store.readEntry(key), {
157
+ fullPath: key,
158
+ parent: path.parent,
159
+ propertyName: path.propertyName,
160
+ ttl: ttlToUse
161
+ });
162
+ deepFreeze(input);
163
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
164
+ luvio.storePublish(key, incomingRecord);
165
+ }
166
+ {
167
+ const storeMetadataParams = {
168
+ ttl: ttlToUse,
169
+ namespace: "tearsheet",
170
+ version: VERSION,
171
+ representationName: RepresentationType,
172
+ };
173
+ luvio.publishStoreMetadata(key, storeMetadataParams);
174
+ }
175
+ return createLink(key);
176
+ };
177
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
178
+ const rootKeySet = new StoreKeyMap();
179
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
180
+ const rootKey = fullPathFactory();
181
+ rootKeySet.set(rootKey, {
182
+ namespace: keyPrefix,
183
+ representationName: RepresentationType,
184
+ mergeable: false
185
+ });
186
+ return rootKeySet;
187
+ }
188
+
189
+ function select(luvio, params) {
190
+ return select$1();
191
+ }
192
+ function keyBuilder$1(luvio, params) {
193
+ return keyPrefix + '::TearsheetListRepresentation:(' + 'limit:' + params.queryParams.limit + ',' + 'offset:' + params.queryParams.offset + ',' + 'templateType:' + params.queryParams.templateType + ',' + 'accountId:' + params.urlParams.accountId + ')';
194
+ }
195
+ function getResponseCacheKeys(luvio, resourceParams, response) {
196
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
197
+ }
198
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
199
+ const { body } = response;
200
+ const key = keyBuilder$1(luvio, resourceParams);
201
+ luvio.storeIngest(key, ingest, body);
202
+ const snapshot = luvio.storeLookup({
203
+ recordId: key,
204
+ node: select(),
205
+ variables: {},
206
+ }, snapshotRefresh);
207
+ if (process.env.NODE_ENV !== 'production') {
208
+ if (snapshot.state !== 'Fulfilled') {
209
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
210
+ }
211
+ }
212
+ return snapshot;
213
+ }
214
+ function ingestError(luvio, params, error, snapshotRefresh) {
215
+ const key = keyBuilder$1(luvio, params);
216
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
217
+ const storeMetadataParams = {
218
+ ttl: TTL,
219
+ namespace: keyPrefix,
220
+ version: VERSION,
221
+ representationName: RepresentationType
222
+ };
223
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
224
+ return errorSnapshot;
225
+ }
226
+ function createResourceRequest(config) {
227
+ const headers = {};
228
+ return {
229
+ baseUri: '/services/data/v58.0',
230
+ basePath: '/connect/financialservices/tearsheets/' + config.urlParams.accountId + '',
231
+ method: 'get',
232
+ body: null,
233
+ urlParams: config.urlParams,
234
+ queryParams: config.queryParams,
235
+ headers,
236
+ priority: 'normal',
237
+ };
238
+ }
239
+
240
+ const getTearsheets_ConfigPropertyNames = {
241
+ displayName: 'getTearsheets',
242
+ parameters: {
243
+ required: ['accountId'],
244
+ optional: ['limit', 'offset', 'templateType']
245
+ }
246
+ };
247
+ function createResourceParams(config) {
248
+ const resourceParams = {
249
+ urlParams: {
250
+ accountId: config.accountId
251
+ },
252
+ queryParams: {
253
+ limit: config.limit, offset: config.offset, templateType: config.templateType
254
+ }
255
+ };
256
+ return resourceParams;
257
+ }
258
+ function keyBuilder(luvio, config) {
259
+ const resourceParams = createResourceParams(config);
260
+ return keyBuilder$1(luvio, resourceParams);
261
+ }
262
+ function typeCheckConfig(untrustedConfig) {
263
+ const config = {};
264
+ const untrustedConfig_accountId = untrustedConfig.accountId;
265
+ if (typeof untrustedConfig_accountId === 'string') {
266
+ config.accountId = untrustedConfig_accountId;
267
+ }
268
+ const untrustedConfig_limit = untrustedConfig.limit;
269
+ if (typeof untrustedConfig_limit === 'number' && Math.floor(untrustedConfig_limit) === untrustedConfig_limit) {
270
+ config.limit = untrustedConfig_limit;
271
+ }
272
+ const untrustedConfig_offset = untrustedConfig.offset;
273
+ if (typeof untrustedConfig_offset === 'number' && Math.floor(untrustedConfig_offset) === untrustedConfig_offset) {
274
+ config.offset = untrustedConfig_offset;
275
+ }
276
+ const untrustedConfig_templateType = untrustedConfig.templateType;
277
+ if (typeof untrustedConfig_templateType === 'string') {
278
+ config.templateType = untrustedConfig_templateType;
279
+ }
280
+ return config;
281
+ }
282
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
283
+ if (!untrustedIsObject(untrustedConfig)) {
284
+ return null;
285
+ }
286
+ if (process.env.NODE_ENV !== 'production') {
287
+ validateConfig(untrustedConfig, configPropertyNames);
288
+ }
289
+ const config = typeCheckConfig(untrustedConfig);
290
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
291
+ return null;
292
+ }
293
+ return config;
294
+ }
295
+ function adapterFragment(luvio, config) {
296
+ createResourceParams(config);
297
+ return select();
298
+ }
299
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
300
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
301
+ config,
302
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
303
+ });
304
+ return luvio.storeBroadcast().then(() => snapshot);
305
+ }
306
+ function onFetchResponseError(luvio, config, resourceParams, response) {
307
+ const snapshot = ingestError(luvio, resourceParams, response, {
308
+ config,
309
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
310
+ });
311
+ return luvio.storeBroadcast().then(() => snapshot);
312
+ }
313
+ function buildNetworkSnapshot(luvio, config, options) {
314
+ const resourceParams = createResourceParams(config);
315
+ const request = createResourceRequest(resourceParams);
316
+ return luvio.dispatchResourceRequest(request, options)
317
+ .then((response) => {
318
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
319
+ }, (response) => {
320
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
321
+ });
322
+ }
323
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
324
+ const { luvio, config } = context;
325
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
326
+ const dispatchOptions = {
327
+ resourceRequestContext: {
328
+ requestCorrelator,
329
+ luvioRequestMethod: undefined,
330
+ },
331
+ eventObservers
332
+ };
333
+ if (networkPriority !== 'normal') {
334
+ dispatchOptions.overrides = {
335
+ priority: networkPriority
336
+ };
337
+ }
338
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
339
+ }
340
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
341
+ const { luvio, config } = context;
342
+ const selector = {
343
+ recordId: keyBuilder(luvio, config),
344
+ node: adapterFragment(luvio, config),
345
+ variables: {},
346
+ };
347
+ const cacheSnapshot = storeLookup(selector, {
348
+ config,
349
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
350
+ });
351
+ return cacheSnapshot;
352
+ }
353
+ const getTearsheetsAdapterFactory = (luvio) => function tearsheet__getTearsheets(untrustedConfig, requestContext) {
354
+ const config = validateAdapterConfig(untrustedConfig, getTearsheets_ConfigPropertyNames);
355
+ // Invalid or incomplete config
356
+ if (config === null) {
357
+ return null;
358
+ }
359
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
360
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
361
+ };
362
+
363
+ let getTearsheets;
364
+ // Imperative GET Adapters
365
+ let getTearsheets_imperative;
366
+ // Adapter Metadata
367
+ const getTearsheetsMetadata = { apiFamily: 'tearsheet', name: 'getTearsheets', ttl: 1000 };
368
+ function bindExportsTo(luvio) {
369
+ // LDS Adapters
370
+ const getTearsheets_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getTearsheets', getTearsheetsAdapterFactory), getTearsheetsMetadata);
371
+ return {
372
+ getTearsheets: createWireAdapterConstructor(luvio, getTearsheets_ldsAdapter, getTearsheetsMetadata),
373
+ // Imperative GET Adapters
374
+ getTearsheets_imperative: createImperativeAdapter(luvio, getTearsheets_ldsAdapter, getTearsheetsMetadata)
375
+ };
376
+ }
377
+ withDefaultLuvio((luvio) => {
378
+ ({
379
+ getTearsheets,
380
+ getTearsheets_imperative
381
+ } = bindExportsTo(luvio));
382
+ });
383
+
384
+ export { getTearsheets, getTearsheets_imperative };
385
+ // version: 1.100.2-ca56bb821
@@ -0,0 +1,69 @@
1
+ #%RAML 1.0
2
+ securedBy:
3
+ - OAuth2
4
+ title: Salesforce Connect API
5
+ version: '56.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
+ TearsheetListRepresentation:
29
+ description: List of Tearsheets
30
+ type: object
31
+ properties:
32
+ data:
33
+ description: The list of tearsheetS
34
+ type: array
35
+ items:
36
+ type: TearsheetRepresentation
37
+ TearsheetRepresentation:
38
+ description: Tearsheet record
39
+ type: object
40
+ properties:
41
+ id:
42
+ description: The record Id of the tearsheet
43
+ type: string
44
+ title:
45
+ description: The title of the tearsheet
46
+ type: string
47
+ /connect/financialservices/tearsheets/{accountId}:
48
+ get:
49
+ description: Get tearsheet details based on id
50
+ responses:
51
+ '200':
52
+ description: Success
53
+ body:
54
+ application/json:
55
+ type: TearsheetListRepresentation
56
+ queryParameters:
57
+ limit:
58
+ type: integer
59
+ required: false
60
+ offset:
61
+ type: integer
62
+ required: false
63
+ templateType:
64
+ type: string
65
+ required: false
66
+ uriParameters:
67
+ accountId:
68
+ type: string
69
+ 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): 'tearsheet'
8
+ (luvio.ttl): 1000
9
+
10
+ types:
11
+ TearsheetListRepresentation:
12
+ (luvio.ttl): 1000
13
+ (luvio.opaque): true
14
+
15
+ /connect/financialservices/tearsheets/{accountId}:
16
+ get:
17
+ (luvio.adapter):
18
+ name: getTearsheets