@salesforce/lds-adapters-platform-named-credential 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.
Files changed (33) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/platform-named-credential.js +1029 -0
  3. package/dist/types/src/generated/adapters/adapter-utils.d.ts +66 -0
  4. package/dist/types/src/generated/adapters/deleteCredential.d.ts +15 -0
  5. package/dist/types/src/generated/adapters/getExternalCredentials.d.ts +25 -0
  6. package/dist/types/src/generated/adapters/getOAuthCredentialAuthUrl.d.ts +15 -0
  7. package/dist/types/src/generated/artifacts/main.d.ts +3 -0
  8. package/dist/types/src/generated/artifacts/sfdc.d.ts +5 -0
  9. package/dist/types/src/generated/resources/deleteNamedCredentialsCredential.d.ts +14 -0
  10. package/dist/types/src/generated/resources/getNamedCredentialsCredential.d.ts +17 -0
  11. package/dist/types/src/generated/resources/getNamedCredentialsExternalCredentials.d.ts +12 -0
  12. package/dist/types/src/generated/resources/getNamedCredentialsExternalCredentialsByDeveloperName.d.ts +15 -0
  13. package/dist/types/src/generated/resources/postNamedCredentialsCredential.d.ts +18 -0
  14. package/dist/types/src/generated/resources/postNamedCredentialsCredentialAuthUrlOAuth.d.ts +13 -0
  15. package/dist/types/src/generated/resources/putNamedCredentialsCredential.d.ts +18 -0
  16. package/dist/types/src/generated/types/CredentialInputRepresentation.d.ts +45 -0
  17. package/dist/types/src/generated/types/CredentialMapRepresentation.d.ts +33 -0
  18. package/dist/types/src/generated/types/CredentialRepresentation.d.ts +63 -0
  19. package/dist/types/src/generated/types/ExternalCredentialListRepresentation.d.ts +39 -0
  20. package/dist/types/src/generated/types/ExternalCredentialPrincipalRepresentation.d.ts +35 -0
  21. package/dist/types/src/generated/types/ExternalCredentialRepresentation.d.ts +55 -0
  22. package/dist/types/src/generated/types/NamedCredentialRepresentation.d.ts +32 -0
  23. package/dist/types/src/generated/types/OAuthCredentialAuthUrlInputRepresentation.d.ts +38 -0
  24. package/dist/types/src/generated/types/OAuthCredentialAuthUrlInputRepresentationWrapper.d.ts +30 -0
  25. package/dist/types/src/generated/types/OAuthCredentialAuthUrlRepresentation.d.ts +47 -0
  26. package/dist/types/src/generated/types/type-utils.d.ts +39 -0
  27. package/dist/umd/es2018/platform-named-credential.js +1039 -0
  28. package/dist/umd/es5/platform-named-credential.js +1045 -0
  29. package/package.json +70 -0
  30. package/sfdc/index.d.ts +1 -0
  31. package/sfdc/index.js +1070 -0
  32. package/src/raml/api.raml +330 -0
  33. package/src/raml/luvio.raml +38 -0
@@ -0,0 +1,1029 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
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
+ }
44
+ const snapshotRefreshOptions = {
45
+ overrides: {
46
+ headers: {
47
+ 'Cache-Control': 'no-cache',
48
+ },
49
+ }
50
+ };
51
+ const keyPrefix = 'named-credential';
52
+
53
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
54
+ const { isArray: ArrayIsArray } = Array;
55
+ function equalsArray(a, b, equalsItem) {
56
+ const aLength = a.length;
57
+ const bLength = b.length;
58
+ if (aLength !== bLength) {
59
+ return false;
60
+ }
61
+ for (let i = 0; i < aLength; i++) {
62
+ if (equalsItem(a[i], b[i]) === false) {
63
+ return false;
64
+ }
65
+ }
66
+ return true;
67
+ }
68
+ function deepFreeze(value) {
69
+ // No need to freeze primitives
70
+ if (typeof value !== 'object' || value === null) {
71
+ return;
72
+ }
73
+ if (ArrayIsArray(value)) {
74
+ for (let i = 0, len = value.length; i < len; i += 1) {
75
+ deepFreeze(value[i]);
76
+ }
77
+ }
78
+ else {
79
+ const keys = ObjectKeys(value);
80
+ for (let i = 0, len = keys.length; i < len; i += 1) {
81
+ deepFreeze(value[keys[i]]);
82
+ }
83
+ }
84
+ ObjectFreeze(value);
85
+ }
86
+ function createLink(ref) {
87
+ return {
88
+ __ref: serializeStructuredKey(ref),
89
+ };
90
+ }
91
+
92
+ const RepresentationType$3 = 'CredentialRepresentation';
93
+ function keyBuilder$5(luvio, config) {
94
+ return keyPrefix + '::' + RepresentationType$3 + ':' + config.externalCredential + ':' + config.principalType + ':' + (config.principalName === null ? '' : config.principalName);
95
+ }
96
+
97
+ function keyBuilder$4(luvio, params) {
98
+ return keyBuilder$5(luvio, {
99
+ externalCredential: params.queryParams.externalCredential || '',
100
+ principalType: params.queryParams.principalType || '',
101
+ principalName: params.queryParams.principalName || ''
102
+ });
103
+ }
104
+ function getResponseCacheKeys$2(luvio, resourceParams) {
105
+ const key = keyBuilder$4(luvio, resourceParams);
106
+ const cacheKeyMap = new StoreKeyMap();
107
+ cacheKeyMap.set(key, {
108
+ namespace: keyPrefix,
109
+ representationName: RepresentationType$3,
110
+ mergeable: false
111
+ });
112
+ return cacheKeyMap;
113
+ }
114
+ function evictSuccess(luvio, resourceParams) {
115
+ const key = keyBuilder$4(luvio, resourceParams);
116
+ luvio.storeEvict(key);
117
+ }
118
+ function createResourceRequest$2(config) {
119
+ const headers = {};
120
+ return {
121
+ baseUri: '/services/data/v58.0',
122
+ basePath: '/named-credentials/credential',
123
+ method: 'delete',
124
+ body: null,
125
+ urlParams: {},
126
+ queryParams: config.queryParams,
127
+ headers,
128
+ priority: 'normal',
129
+ };
130
+ }
131
+
132
+ const adapterName = 'deleteCredential';
133
+ const deleteCredential_ConfigPropertyNames = {
134
+ displayName: 'deleteCredential',
135
+ parameters: {
136
+ required: [],
137
+ optional: ['externalCredential', 'principalName', 'principalType']
138
+ }
139
+ };
140
+ function createResourceParams$2(config) {
141
+ const resourceParams = {
142
+ queryParams: {
143
+ externalCredential: config.externalCredential, principalName: config.principalName, principalType: config.principalType
144
+ }
145
+ };
146
+ return resourceParams;
147
+ }
148
+ function typeCheckConfig$2(untrustedConfig) {
149
+ const config = {};
150
+ const untrustedConfig_externalCredential = untrustedConfig.externalCredential;
151
+ if (typeof untrustedConfig_externalCredential === 'string') {
152
+ config.externalCredential = untrustedConfig_externalCredential;
153
+ }
154
+ const untrustedConfig_principalName = untrustedConfig.principalName;
155
+ if (typeof untrustedConfig_principalName === 'string') {
156
+ config.principalName = untrustedConfig_principalName;
157
+ }
158
+ const untrustedConfig_principalType = untrustedConfig.principalType;
159
+ if (typeof untrustedConfig_principalType === 'string') {
160
+ config.principalType = untrustedConfig_principalType;
161
+ }
162
+ return config;
163
+ }
164
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
165
+ if (!untrustedIsObject(untrustedConfig)) {
166
+ return null;
167
+ }
168
+ if (process.env.NODE_ENV !== 'production') {
169
+ validateConfig(untrustedConfig, configPropertyNames);
170
+ }
171
+ const config = typeCheckConfig$2(untrustedConfig);
172
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
173
+ return null;
174
+ }
175
+ return config;
176
+ }
177
+ function buildNetworkSnapshot$2(luvio, config, options) {
178
+ const resourceParams = createResourceParams$2(config);
179
+ const request = createResourceRequest$2(resourceParams);
180
+ return luvio.dispatchResourceRequest(request, options)
181
+ .then(() => {
182
+ return luvio.handleSuccessResponse(() => {
183
+ evictSuccess(luvio, resourceParams);
184
+ return luvio.storeBroadcast();
185
+ }, () => getResponseCacheKeys$2(luvio, resourceParams));
186
+ }, (response) => {
187
+ deepFreeze(response);
188
+ throw response;
189
+ });
190
+ }
191
+ const deleteCredentialAdapterFactory = (luvio) => {
192
+ return function namedCredentialdeleteCredential(untrustedConfig) {
193
+ const config = validateAdapterConfig$2(untrustedConfig, deleteCredential_ConfigPropertyNames);
194
+ // Invalid or incomplete config
195
+ if (config === null) {
196
+ throw new Error(`Invalid config for "${adapterName}"`);
197
+ }
198
+ return buildNetworkSnapshot$2(luvio, config);
199
+ };
200
+ };
201
+
202
+ function validate$5(obj, path = 'OAuthCredentialAuthUrlInputRepresentation') {
203
+ const v_error = (() => {
204
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
205
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
206
+ }
207
+ const obj_externalCredential = obj.externalCredential;
208
+ const path_externalCredential = path + '.externalCredential';
209
+ if (typeof obj_externalCredential !== 'string') {
210
+ return new TypeError('Expected "string" but received "' + typeof obj_externalCredential + '" (at "' + path_externalCredential + '")');
211
+ }
212
+ const obj_principalName = obj.principalName;
213
+ const path_principalName = path + '.principalName';
214
+ if (typeof obj_principalName !== 'string') {
215
+ return new TypeError('Expected "string" but received "' + typeof obj_principalName + '" (at "' + path_principalName + '")');
216
+ }
217
+ const obj_principalType = obj.principalType;
218
+ const path_principalType = path + '.principalType';
219
+ if (typeof obj_principalType !== 'string') {
220
+ return new TypeError('Expected "string" but received "' + typeof obj_principalType + '" (at "' + path_principalType + '")');
221
+ }
222
+ const obj_returnUrl = obj.returnUrl;
223
+ const path_returnUrl = path + '.returnUrl';
224
+ if (typeof obj_returnUrl !== 'string') {
225
+ return new TypeError('Expected "string" but received "' + typeof obj_returnUrl + '" (at "' + path_returnUrl + '")');
226
+ }
227
+ })();
228
+ return v_error === undefined ? null : v_error;
229
+ }
230
+
231
+ const VERSION$4 = "1e72de165572264bf8309eccfc284fd6";
232
+ function validate$4(obj, path = 'OAuthCredentialAuthUrlRepresentation') {
233
+ const v_error = (() => {
234
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
235
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
236
+ }
237
+ const obj_authenticationUrl = obj.authenticationUrl;
238
+ const path_authenticationUrl = path + '.authenticationUrl';
239
+ if (typeof obj_authenticationUrl !== 'string') {
240
+ return new TypeError('Expected "string" but received "' + typeof obj_authenticationUrl + '" (at "' + path_authenticationUrl + '")');
241
+ }
242
+ const obj_externalCredential = obj.externalCredential;
243
+ const path_externalCredential = path + '.externalCredential';
244
+ if (typeof obj_externalCredential !== 'string') {
245
+ return new TypeError('Expected "string" but received "' + typeof obj_externalCredential + '" (at "' + path_externalCredential + '")');
246
+ }
247
+ const obj_principalName = obj.principalName;
248
+ const path_principalName = path + '.principalName';
249
+ if (typeof obj_principalName !== 'string') {
250
+ return new TypeError('Expected "string" but received "' + typeof obj_principalName + '" (at "' + path_principalName + '")');
251
+ }
252
+ const obj_principalType = obj.principalType;
253
+ const path_principalType = path + '.principalType';
254
+ if (typeof obj_principalType !== 'string') {
255
+ return new TypeError('Expected "string" but received "' + typeof obj_principalType + '" (at "' + path_principalType + '")');
256
+ }
257
+ })();
258
+ return v_error === undefined ? null : v_error;
259
+ }
260
+ const RepresentationType$2 = 'OAuthCredentialAuthUrlRepresentation';
261
+ function keyBuilder$3(luvio, config) {
262
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.authenticationUrl;
263
+ }
264
+ function keyBuilderFromType$1(luvio, object) {
265
+ const keyParams = {
266
+ authenticationUrl: object.authenticationUrl
267
+ };
268
+ return keyBuilder$3(luvio, keyParams);
269
+ }
270
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
271
+ return input;
272
+ }
273
+ const select$6 = function OAuthCredentialAuthUrlRepresentationSelect() {
274
+ return {
275
+ kind: 'Fragment',
276
+ version: VERSION$4,
277
+ private: [],
278
+ selections: [
279
+ {
280
+ name: 'authenticationUrl',
281
+ kind: 'Scalar'
282
+ },
283
+ {
284
+ name: 'externalCredential',
285
+ kind: 'Scalar'
286
+ },
287
+ {
288
+ name: 'principalName',
289
+ kind: 'Scalar'
290
+ },
291
+ {
292
+ name: 'principalType',
293
+ kind: 'Scalar'
294
+ }
295
+ ]
296
+ };
297
+ };
298
+ function equals$4(existing, incoming) {
299
+ const existing_authenticationUrl = existing.authenticationUrl;
300
+ const incoming_authenticationUrl = incoming.authenticationUrl;
301
+ if (!(existing_authenticationUrl === incoming_authenticationUrl)) {
302
+ return false;
303
+ }
304
+ const existing_externalCredential = existing.externalCredential;
305
+ const incoming_externalCredential = incoming.externalCredential;
306
+ if (!(existing_externalCredential === incoming_externalCredential)) {
307
+ return false;
308
+ }
309
+ const existing_principalName = existing.principalName;
310
+ const incoming_principalName = incoming.principalName;
311
+ if (!(existing_principalName === incoming_principalName)) {
312
+ return false;
313
+ }
314
+ const existing_principalType = existing.principalType;
315
+ const incoming_principalType = incoming.principalType;
316
+ if (!(existing_principalType === incoming_principalType)) {
317
+ return false;
318
+ }
319
+ return true;
320
+ }
321
+ const ingest$2 = function OAuthCredentialAuthUrlRepresentationIngest(input, path, luvio, store, timestamp) {
322
+ if (process.env.NODE_ENV !== 'production') {
323
+ const validateError = validate$4(input);
324
+ if (validateError !== null) {
325
+ throw validateError;
326
+ }
327
+ }
328
+ const key = keyBuilderFromType$1(luvio, input);
329
+ const existingRecord = store.readEntry(key);
330
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 300000;
331
+ let incomingRecord = normalize$2(input, store.readEntry(key), {
332
+ fullPath: key,
333
+ parent: path.parent,
334
+ propertyName: path.propertyName,
335
+ ttl: ttlToUse
336
+ });
337
+ if (existingRecord === undefined || equals$4(existingRecord, incomingRecord) === false) {
338
+ luvio.storePublish(key, incomingRecord);
339
+ }
340
+ if (ttlToUse !== undefined) {
341
+ const storeMetadataParams = {
342
+ ttl: ttlToUse,
343
+ namespace: "named-credential",
344
+ version: VERSION$4,
345
+ representationName: RepresentationType$2,
346
+ };
347
+ luvio.publishStoreMetadata(key, storeMetadataParams);
348
+ }
349
+ return createLink(key);
350
+ };
351
+ function getTypeCacheKeys$2(luvio, input, fullPathFactory) {
352
+ const rootKeySet = new StoreKeyMap();
353
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
354
+ const rootKey = keyBuilderFromType$1(luvio, input);
355
+ rootKeySet.set(rootKey, {
356
+ namespace: keyPrefix,
357
+ representationName: RepresentationType$2,
358
+ mergeable: false
359
+ });
360
+ return rootKeySet;
361
+ }
362
+
363
+ function select$5(luvio, params) {
364
+ return select$6();
365
+ }
366
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
367
+ return getTypeCacheKeys$2(luvio, response);
368
+ }
369
+ function ingestSuccess$1(luvio, resourceParams, response) {
370
+ const { body } = response;
371
+ const key = keyBuilderFromType$1(luvio, body);
372
+ luvio.storeIngest(key, ingest$2, body);
373
+ const snapshot = luvio.storeLookup({
374
+ recordId: key,
375
+ node: select$5(),
376
+ variables: {},
377
+ });
378
+ if (process.env.NODE_ENV !== 'production') {
379
+ if (snapshot.state !== 'Fulfilled') {
380
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
381
+ }
382
+ }
383
+ return snapshot;
384
+ }
385
+ function createResourceRequest$1(config) {
386
+ const headers = {};
387
+ return {
388
+ baseUri: '/services/data/v58.0',
389
+ basePath: '/named-credentials/credential/auth-url/o-auth',
390
+ method: 'post',
391
+ body: config.body,
392
+ urlParams: {},
393
+ queryParams: {},
394
+ headers,
395
+ priority: 'normal',
396
+ };
397
+ }
398
+
399
+ const getOAuthCredentialAuthUrl_ConfigPropertyNames = {
400
+ displayName: 'getOAuthCredentialAuthUrl',
401
+ parameters: {
402
+ required: ['requestBody'],
403
+ optional: []
404
+ }
405
+ };
406
+ function createResourceParams$1(config) {
407
+ const resourceParams = {
408
+ body: {
409
+ requestBody: config.requestBody
410
+ }
411
+ };
412
+ return resourceParams;
413
+ }
414
+ function typeCheckConfig$1(untrustedConfig) {
415
+ const config = {};
416
+ const untrustedConfig_requestBody = untrustedConfig.requestBody;
417
+ const referenceOAuthCredentialAuthUrlInputRepresentationValidationError = validate$5(untrustedConfig_requestBody);
418
+ if (referenceOAuthCredentialAuthUrlInputRepresentationValidationError === null) {
419
+ config.requestBody = untrustedConfig_requestBody;
420
+ }
421
+ return config;
422
+ }
423
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
424
+ if (!untrustedIsObject(untrustedConfig)) {
425
+ return null;
426
+ }
427
+ if (process.env.NODE_ENV !== 'production') {
428
+ validateConfig(untrustedConfig, configPropertyNames);
429
+ }
430
+ const config = typeCheckConfig$1(untrustedConfig);
431
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
432
+ return null;
433
+ }
434
+ return config;
435
+ }
436
+ function buildNetworkSnapshot$1(luvio, config, options) {
437
+ const resourceParams = createResourceParams$1(config);
438
+ const request = createResourceRequest$1(resourceParams);
439
+ return luvio.dispatchResourceRequest(request, options)
440
+ .then((response) => {
441
+ return luvio.handleSuccessResponse(() => {
442
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
443
+ return luvio.storeBroadcast().then(() => snapshot);
444
+ }, () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
445
+ }, (response) => {
446
+ deepFreeze(response);
447
+ throw response;
448
+ });
449
+ }
450
+ const getOAuthCredentialAuthUrlAdapterFactory = (luvio) => {
451
+ return function getOAuthCredentialAuthUrl(untrustedConfig) {
452
+ const config = validateAdapterConfig$1(untrustedConfig, getOAuthCredentialAuthUrl_ConfigPropertyNames);
453
+ // Invalid or incomplete config
454
+ if (config === null) {
455
+ throw new Error('Invalid config for "getOAuthCredentialAuthUrl"');
456
+ }
457
+ return buildNetworkSnapshot$1(luvio, config);
458
+ };
459
+ };
460
+
461
+ const VERSION$3 = "0874099e8f2a31ddf81f3ce490386603";
462
+ function validate$3(obj, path = 'ExternalCredentialPrincipalRepresentation') {
463
+ const v_error = (() => {
464
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
465
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
466
+ }
467
+ const obj_authenticationStatus = obj.authenticationStatus;
468
+ const path_authenticationStatus = path + '.authenticationStatus';
469
+ if (typeof obj_authenticationStatus !== 'string') {
470
+ return new TypeError('Expected "string" but received "' + typeof obj_authenticationStatus + '" (at "' + path_authenticationStatus + '")');
471
+ }
472
+ const obj_principalName = obj.principalName;
473
+ const path_principalName = path + '.principalName';
474
+ if (typeof obj_principalName !== 'string') {
475
+ return new TypeError('Expected "string" but received "' + typeof obj_principalName + '" (at "' + path_principalName + '")');
476
+ }
477
+ const obj_principalType = obj.principalType;
478
+ const path_principalType = path + '.principalType';
479
+ if (typeof obj_principalType !== 'string') {
480
+ return new TypeError('Expected "string" but received "' + typeof obj_principalType + '" (at "' + path_principalType + '")');
481
+ }
482
+ })();
483
+ return v_error === undefined ? null : v_error;
484
+ }
485
+ const select$4 = function ExternalCredentialPrincipalRepresentationSelect() {
486
+ return {
487
+ kind: 'Fragment',
488
+ version: VERSION$3,
489
+ private: [],
490
+ selections: [
491
+ {
492
+ name: 'authenticationStatus',
493
+ kind: 'Scalar'
494
+ },
495
+ {
496
+ name: 'principalName',
497
+ kind: 'Scalar'
498
+ },
499
+ {
500
+ name: 'principalType',
501
+ kind: 'Scalar'
502
+ }
503
+ ]
504
+ };
505
+ };
506
+ function equals$3(existing, incoming) {
507
+ const existing_authenticationStatus = existing.authenticationStatus;
508
+ const incoming_authenticationStatus = incoming.authenticationStatus;
509
+ if (!(existing_authenticationStatus === incoming_authenticationStatus)) {
510
+ return false;
511
+ }
512
+ const existing_principalName = existing.principalName;
513
+ const incoming_principalName = incoming.principalName;
514
+ if (!(existing_principalName === incoming_principalName)) {
515
+ return false;
516
+ }
517
+ const existing_principalType = existing.principalType;
518
+ const incoming_principalType = incoming.principalType;
519
+ if (!(existing_principalType === incoming_principalType)) {
520
+ return false;
521
+ }
522
+ return true;
523
+ }
524
+
525
+ const VERSION$2 = "95db03e0e8990cc8f51f006ccf355bf9";
526
+ function validate$2(obj, path = 'NamedCredentialRepresentation') {
527
+ const v_error = (() => {
528
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
529
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
530
+ }
531
+ const obj_developerName = obj.developerName;
532
+ const path_developerName = path + '.developerName';
533
+ if (typeof obj_developerName !== 'string') {
534
+ return new TypeError('Expected "string" but received "' + typeof obj_developerName + '" (at "' + path_developerName + '")');
535
+ }
536
+ const obj_masterLabel = obj.masterLabel;
537
+ const path_masterLabel = path + '.masterLabel';
538
+ if (typeof obj_masterLabel !== 'string') {
539
+ return new TypeError('Expected "string" but received "' + typeof obj_masterLabel + '" (at "' + path_masterLabel + '")');
540
+ }
541
+ })();
542
+ return v_error === undefined ? null : v_error;
543
+ }
544
+ const select$3 = function NamedCredentialRepresentationSelect() {
545
+ return {
546
+ kind: 'Fragment',
547
+ version: VERSION$2,
548
+ private: [],
549
+ selections: [
550
+ {
551
+ name: 'developerName',
552
+ kind: 'Scalar'
553
+ },
554
+ {
555
+ name: 'masterLabel',
556
+ kind: 'Scalar'
557
+ }
558
+ ]
559
+ };
560
+ };
561
+ function equals$2(existing, incoming) {
562
+ const existing_developerName = existing.developerName;
563
+ const incoming_developerName = incoming.developerName;
564
+ if (!(existing_developerName === incoming_developerName)) {
565
+ return false;
566
+ }
567
+ const existing_masterLabel = existing.masterLabel;
568
+ const incoming_masterLabel = incoming.masterLabel;
569
+ if (!(existing_masterLabel === incoming_masterLabel)) {
570
+ return false;
571
+ }
572
+ return true;
573
+ }
574
+
575
+ const VERSION$1 = "fd37a032d72e3491fe4d211486a3fea1";
576
+ function validate$1(obj, path = 'ExternalCredentialRepresentation') {
577
+ const v_error = (() => {
578
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
579
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
580
+ }
581
+ const obj_authenticationProtocol = obj.authenticationProtocol;
582
+ const path_authenticationProtocol = path + '.authenticationProtocol';
583
+ if (typeof obj_authenticationProtocol !== 'string') {
584
+ return new TypeError('Expected "string" but received "' + typeof obj_authenticationProtocol + '" (at "' + path_authenticationProtocol + '")');
585
+ }
586
+ const obj_authenticationStatus = obj.authenticationStatus;
587
+ const path_authenticationStatus = path + '.authenticationStatus';
588
+ if (typeof obj_authenticationStatus !== 'string') {
589
+ return new TypeError('Expected "string" but received "' + typeof obj_authenticationStatus + '" (at "' + path_authenticationStatus + '")');
590
+ }
591
+ const obj_developerName = obj.developerName;
592
+ const path_developerName = path + '.developerName';
593
+ if (typeof obj_developerName !== 'string') {
594
+ return new TypeError('Expected "string" but received "' + typeof obj_developerName + '" (at "' + path_developerName + '")');
595
+ }
596
+ const obj_masterLabel = obj.masterLabel;
597
+ const path_masterLabel = path + '.masterLabel';
598
+ if (typeof obj_masterLabel !== 'string') {
599
+ return new TypeError('Expected "string" but received "' + typeof obj_masterLabel + '" (at "' + path_masterLabel + '")');
600
+ }
601
+ const obj_principals = obj.principals;
602
+ const path_principals = path + '.principals';
603
+ if (!ArrayIsArray(obj_principals)) {
604
+ return new TypeError('Expected "array" but received "' + typeof obj_principals + '" (at "' + path_principals + '")');
605
+ }
606
+ for (let i = 0; i < obj_principals.length; i++) {
607
+ const obj_principals_item = obj_principals[i];
608
+ const path_principals_item = path_principals + '[' + i + ']';
609
+ const referencepath_principals_itemValidationError = validate$3(obj_principals_item, path_principals_item);
610
+ if (referencepath_principals_itemValidationError !== null) {
611
+ let message = 'Object doesn\'t match ExternalCredentialPrincipalRepresentation (at "' + path_principals_item + '")\n';
612
+ message += referencepath_principals_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
613
+ return new TypeError(message);
614
+ }
615
+ }
616
+ const obj_relatedNamedCredentials = obj.relatedNamedCredentials;
617
+ const path_relatedNamedCredentials = path + '.relatedNamedCredentials';
618
+ if (!ArrayIsArray(obj_relatedNamedCredentials)) {
619
+ return new TypeError('Expected "array" but received "' + typeof obj_relatedNamedCredentials + '" (at "' + path_relatedNamedCredentials + '")');
620
+ }
621
+ for (let i = 0; i < obj_relatedNamedCredentials.length; i++) {
622
+ const obj_relatedNamedCredentials_item = obj_relatedNamedCredentials[i];
623
+ const path_relatedNamedCredentials_item = path_relatedNamedCredentials + '[' + i + ']';
624
+ const referencepath_relatedNamedCredentials_itemValidationError = validate$2(obj_relatedNamedCredentials_item, path_relatedNamedCredentials_item);
625
+ if (referencepath_relatedNamedCredentials_itemValidationError !== null) {
626
+ let message = 'Object doesn\'t match NamedCredentialRepresentation (at "' + path_relatedNamedCredentials_item + '")\n';
627
+ message += referencepath_relatedNamedCredentials_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
628
+ return new TypeError(message);
629
+ }
630
+ }
631
+ })();
632
+ return v_error === undefined ? null : v_error;
633
+ }
634
+ const RepresentationType$1 = 'ExternalCredentialRepresentation';
635
+ function keyBuilder$2(luvio, config) {
636
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.developerName;
637
+ }
638
+ function keyBuilderFromType(luvio, object) {
639
+ const keyParams = {
640
+ developerName: object.developerName
641
+ };
642
+ return keyBuilder$2(luvio, keyParams);
643
+ }
644
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
645
+ return input;
646
+ }
647
+ const select$2 = function ExternalCredentialRepresentationSelect() {
648
+ const { selections: ExternalCredentialPrincipalRepresentation__selections, opaque: ExternalCredentialPrincipalRepresentation__opaque, } = select$4();
649
+ const { selections: NamedCredentialRepresentation__selections, opaque: NamedCredentialRepresentation__opaque, } = select$3();
650
+ return {
651
+ kind: 'Fragment',
652
+ version: VERSION$1,
653
+ private: [],
654
+ selections: [
655
+ {
656
+ name: 'authenticationProtocol',
657
+ kind: 'Scalar'
658
+ },
659
+ {
660
+ name: 'authenticationStatus',
661
+ kind: 'Scalar'
662
+ },
663
+ {
664
+ name: 'developerName',
665
+ kind: 'Scalar'
666
+ },
667
+ {
668
+ name: 'masterLabel',
669
+ kind: 'Scalar'
670
+ },
671
+ {
672
+ name: 'principals',
673
+ kind: 'Object',
674
+ plural: true,
675
+ selections: ExternalCredentialPrincipalRepresentation__selections
676
+ },
677
+ {
678
+ name: 'relatedNamedCredentials',
679
+ kind: 'Object',
680
+ plural: true,
681
+ selections: NamedCredentialRepresentation__selections
682
+ }
683
+ ]
684
+ };
685
+ };
686
+ function equals$1(existing, incoming) {
687
+ const existing_authenticationProtocol = existing.authenticationProtocol;
688
+ const incoming_authenticationProtocol = incoming.authenticationProtocol;
689
+ if (!(existing_authenticationProtocol === incoming_authenticationProtocol)) {
690
+ return false;
691
+ }
692
+ const existing_authenticationStatus = existing.authenticationStatus;
693
+ const incoming_authenticationStatus = incoming.authenticationStatus;
694
+ if (!(existing_authenticationStatus === incoming_authenticationStatus)) {
695
+ return false;
696
+ }
697
+ const existing_developerName = existing.developerName;
698
+ const incoming_developerName = incoming.developerName;
699
+ if (!(existing_developerName === incoming_developerName)) {
700
+ return false;
701
+ }
702
+ const existing_masterLabel = existing.masterLabel;
703
+ const incoming_masterLabel = incoming.masterLabel;
704
+ if (!(existing_masterLabel === incoming_masterLabel)) {
705
+ return false;
706
+ }
707
+ const existing_principals = existing.principals;
708
+ const incoming_principals = incoming.principals;
709
+ const equals_principals_items = equalsArray(existing_principals, incoming_principals, (existing_principals_item, incoming_principals_item) => {
710
+ if (!(equals$3(existing_principals_item, incoming_principals_item))) {
711
+ return false;
712
+ }
713
+ });
714
+ if (equals_principals_items === false) {
715
+ return false;
716
+ }
717
+ const existing_relatedNamedCredentials = existing.relatedNamedCredentials;
718
+ const incoming_relatedNamedCredentials = incoming.relatedNamedCredentials;
719
+ const equals_relatedNamedCredentials_items = equalsArray(existing_relatedNamedCredentials, incoming_relatedNamedCredentials, (existing_relatedNamedCredentials_item, incoming_relatedNamedCredentials_item) => {
720
+ if (!(equals$2(existing_relatedNamedCredentials_item, incoming_relatedNamedCredentials_item))) {
721
+ return false;
722
+ }
723
+ });
724
+ if (equals_relatedNamedCredentials_items === false) {
725
+ return false;
726
+ }
727
+ return true;
728
+ }
729
+ const ingest$1 = function ExternalCredentialRepresentationIngest(input, path, luvio, store, timestamp) {
730
+ if (process.env.NODE_ENV !== 'production') {
731
+ const validateError = validate$1(input);
732
+ if (validateError !== null) {
733
+ throw validateError;
734
+ }
735
+ }
736
+ const key = keyBuilderFromType(luvio, input);
737
+ const existingRecord = store.readEntry(key);
738
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 300000;
739
+ let incomingRecord = normalize$1(input, store.readEntry(key), {
740
+ fullPath: key,
741
+ parent: path.parent,
742
+ propertyName: path.propertyName,
743
+ ttl: ttlToUse
744
+ });
745
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
746
+ luvio.storePublish(key, incomingRecord);
747
+ }
748
+ if (ttlToUse !== undefined) {
749
+ const storeMetadataParams = {
750
+ ttl: ttlToUse,
751
+ namespace: "named-credential",
752
+ version: VERSION$1,
753
+ representationName: RepresentationType$1,
754
+ };
755
+ luvio.publishStoreMetadata(key, storeMetadataParams);
756
+ }
757
+ return createLink(key);
758
+ };
759
+ function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
760
+ const rootKeySet = new StoreKeyMap();
761
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
762
+ const rootKey = keyBuilderFromType(luvio, input);
763
+ rootKeySet.set(rootKey, {
764
+ namespace: keyPrefix,
765
+ representationName: RepresentationType$1,
766
+ mergeable: false
767
+ });
768
+ return rootKeySet;
769
+ }
770
+
771
+ const VERSION = "81417919a5a3d6b3e4fc26ab05d87aea";
772
+ function validate(obj, path = 'ExternalCredentialListRepresentation') {
773
+ const v_error = (() => {
774
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
775
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
776
+ }
777
+ const obj_externalCredentials = obj.externalCredentials;
778
+ const path_externalCredentials = path + '.externalCredentials';
779
+ if (!ArrayIsArray(obj_externalCredentials)) {
780
+ return new TypeError('Expected "array" but received "' + typeof obj_externalCredentials + '" (at "' + path_externalCredentials + '")');
781
+ }
782
+ for (let i = 0; i < obj_externalCredentials.length; i++) {
783
+ const obj_externalCredentials_item = obj_externalCredentials[i];
784
+ const path_externalCredentials_item = path_externalCredentials + '[' + i + ']';
785
+ if (typeof obj_externalCredentials_item !== 'object') {
786
+ return new TypeError('Expected "object" but received "' + typeof obj_externalCredentials_item + '" (at "' + path_externalCredentials_item + '")');
787
+ }
788
+ }
789
+ })();
790
+ return v_error === undefined ? null : v_error;
791
+ }
792
+ const RepresentationType = 'ExternalCredentialListRepresentation';
793
+ function normalize(input, existing, path, luvio, store, timestamp) {
794
+ const input_externalCredentials = input.externalCredentials;
795
+ const input_externalCredentials_id = path.fullPath + '__externalCredentials';
796
+ for (let i = 0; i < input_externalCredentials.length; i++) {
797
+ const input_externalCredentials_item = input_externalCredentials[i];
798
+ let input_externalCredentials_item_id = input_externalCredentials_id + '__' + i;
799
+ input_externalCredentials[i] = ingest$1(input_externalCredentials_item, {
800
+ fullPath: input_externalCredentials_item_id,
801
+ propertyName: i,
802
+ parent: {
803
+ data: input,
804
+ key: path.fullPath,
805
+ existing: existing,
806
+ },
807
+ ttl: path.ttl
808
+ }, luvio, store);
809
+ }
810
+ return input;
811
+ }
812
+ const select$1 = function ExternalCredentialListRepresentationSelect() {
813
+ return {
814
+ kind: 'Fragment',
815
+ version: VERSION,
816
+ private: [],
817
+ selections: [
818
+ {
819
+ name: 'externalCredentials',
820
+ kind: 'Link',
821
+ plural: true,
822
+ fragment: select$2()
823
+ }
824
+ ]
825
+ };
826
+ };
827
+ function equals(existing, incoming) {
828
+ const existing_externalCredentials = existing.externalCredentials;
829
+ const incoming_externalCredentials = incoming.externalCredentials;
830
+ const equals_externalCredentials_items = equalsArray(existing_externalCredentials, incoming_externalCredentials, (existing_externalCredentials_item, incoming_externalCredentials_item) => {
831
+ if (!(existing_externalCredentials_item.__ref === incoming_externalCredentials_item.__ref)) {
832
+ return false;
833
+ }
834
+ });
835
+ if (equals_externalCredentials_items === false) {
836
+ return false;
837
+ }
838
+ return true;
839
+ }
840
+ const ingest = function ExternalCredentialListRepresentationIngest(input, path, luvio, store, timestamp) {
841
+ if (process.env.NODE_ENV !== 'production') {
842
+ const validateError = validate(input);
843
+ if (validateError !== null) {
844
+ throw validateError;
845
+ }
846
+ }
847
+ const key = path.fullPath;
848
+ const existingRecord = store.readEntry(key);
849
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 300000;
850
+ let incomingRecord = normalize(input, store.readEntry(key), {
851
+ fullPath: key,
852
+ parent: path.parent,
853
+ propertyName: path.propertyName,
854
+ ttl: ttlToUse
855
+ }, luvio, store);
856
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
857
+ luvio.storePublish(key, incomingRecord);
858
+ }
859
+ if (ttlToUse !== undefined) {
860
+ const storeMetadataParams = {
861
+ ttl: ttlToUse,
862
+ namespace: "named-credential",
863
+ version: VERSION,
864
+ representationName: RepresentationType,
865
+ };
866
+ luvio.publishStoreMetadata(key, storeMetadataParams);
867
+ }
868
+ return createLink(key);
869
+ };
870
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
871
+ const rootKeySet = new StoreKeyMap();
872
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
873
+ const rootKey = fullPathFactory();
874
+ rootKeySet.set(rootKey, {
875
+ namespace: keyPrefix,
876
+ representationName: RepresentationType,
877
+ mergeable: false
878
+ });
879
+ const input_externalCredentials_length = input.externalCredentials.length;
880
+ for (let i = 0; i < input_externalCredentials_length; i++) {
881
+ rootKeySet.merge(getTypeCacheKeys$1(luvio, input.externalCredentials[i]));
882
+ }
883
+ return rootKeySet;
884
+ }
885
+
886
+ function select(luvio, params) {
887
+ return select$1();
888
+ }
889
+ function keyBuilder$1(luvio, params) {
890
+ return keyPrefix + '::ExternalCredentialListRepresentation:(' + ')';
891
+ }
892
+ function getResponseCacheKeys(luvio, resourceParams, response) {
893
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1());
894
+ }
895
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
896
+ const { body } = response;
897
+ const key = keyBuilder$1();
898
+ luvio.storeIngest(key, ingest, body);
899
+ const snapshot = luvio.storeLookup({
900
+ recordId: key,
901
+ node: select(),
902
+ variables: {},
903
+ }, snapshotRefresh);
904
+ if (process.env.NODE_ENV !== 'production') {
905
+ if (snapshot.state !== 'Fulfilled') {
906
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
907
+ }
908
+ }
909
+ return snapshot;
910
+ }
911
+ function ingestError(luvio, params, error, snapshotRefresh) {
912
+ const key = keyBuilder$1();
913
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
914
+ luvio.storeIngestError(key, errorSnapshot);
915
+ return errorSnapshot;
916
+ }
917
+ function createResourceRequest(config) {
918
+ const headers = {};
919
+ return {
920
+ baseUri: '/services/data/v58.0',
921
+ basePath: '/named-credentials/external-credentials',
922
+ method: 'get',
923
+ body: null,
924
+ urlParams: {},
925
+ queryParams: {},
926
+ headers,
927
+ priority: 'normal',
928
+ };
929
+ }
930
+
931
+ const getExternalCredentials_ConfigPropertyNames = {
932
+ displayName: 'getExternalCredentials',
933
+ parameters: {
934
+ required: [],
935
+ optional: []
936
+ }
937
+ };
938
+ function createResourceParams(config) {
939
+ const resourceParams = {};
940
+ return resourceParams;
941
+ }
942
+ function keyBuilder(luvio, config) {
943
+ return keyBuilder$1();
944
+ }
945
+ function typeCheckConfig(untrustedConfig) {
946
+ const config = {};
947
+ return config;
948
+ }
949
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
950
+ if (!untrustedIsObject(untrustedConfig)) {
951
+ return null;
952
+ }
953
+ if (process.env.NODE_ENV !== 'production') {
954
+ validateConfig(untrustedConfig, configPropertyNames);
955
+ }
956
+ const config = typeCheckConfig();
957
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
958
+ return null;
959
+ }
960
+ return config;
961
+ }
962
+ function adapterFragment(luvio, config) {
963
+ return select();
964
+ }
965
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
966
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
967
+ config,
968
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
969
+ });
970
+ return luvio.storeBroadcast().then(() => snapshot);
971
+ }
972
+ function onFetchResponseError(luvio, config, resourceParams, response) {
973
+ const snapshot = ingestError(luvio, resourceParams, response, {
974
+ config,
975
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
976
+ });
977
+ return luvio.storeBroadcast().then(() => snapshot);
978
+ }
979
+ function buildNetworkSnapshot(luvio, config, options) {
980
+ const resourceParams = createResourceParams();
981
+ const request = createResourceRequest();
982
+ return luvio.dispatchResourceRequest(request, options)
983
+ .then((response) => {
984
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
985
+ }, (response) => {
986
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
987
+ });
988
+ }
989
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
990
+ const { luvio, config } = context;
991
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
992
+ const dispatchOptions = {
993
+ resourceRequestContext: {
994
+ requestCorrelator,
995
+ luvioRequestMethod: undefined,
996
+ },
997
+ eventObservers
998
+ };
999
+ if (networkPriority !== 'normal') {
1000
+ dispatchOptions.overrides = {
1001
+ priority: networkPriority
1002
+ };
1003
+ }
1004
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
1005
+ }
1006
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
1007
+ const { luvio, config } = context;
1008
+ const selector = {
1009
+ recordId: keyBuilder(),
1010
+ node: adapterFragment(),
1011
+ variables: {},
1012
+ };
1013
+ const cacheSnapshot = storeLookup(selector, {
1014
+ config,
1015
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
1016
+ });
1017
+ return cacheSnapshot;
1018
+ }
1019
+ const getExternalCredentialsAdapterFactory = (luvio) => function namedCredential__getExternalCredentials(untrustedConfig, requestContext) {
1020
+ const config = validateAdapterConfig(untrustedConfig, getExternalCredentials_ConfigPropertyNames);
1021
+ // Invalid or incomplete config
1022
+ if (config === null) {
1023
+ return null;
1024
+ }
1025
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
1026
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
1027
+ };
1028
+
1029
+ export { deleteCredentialAdapterFactory, getExternalCredentialsAdapterFactory, getOAuthCredentialAuthUrlAdapterFactory };