@salesforce/lds-adapters-analytics-tableau-embedding 1.114.0

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.
@@ -0,0 +1,704 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ (function (global, factory) {
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
9
+ typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.analyticsTableauEmbedding = {}, global.engine));
11
+ })(this, (function (exports, engine) { 'use strict';
12
+
13
+ var ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty;
14
+ var ObjectKeys = Object.keys;
15
+ var ArrayIsArray$1 = Array.isArray;
16
+ /**
17
+ * Validates an adapter config is well-formed.
18
+ * @param config The config to validate.
19
+ * @param adapter The adapter validation configuration.
20
+ * @param oneOf The keys the config must contain at least one of.
21
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
22
+ */
23
+ function validateConfig(config, adapter, oneOf) {
24
+ var displayName = adapter.displayName;
25
+ var _a = adapter.parameters, required = _a.required, optional = _a.optional, unsupported = _a.unsupported;
26
+ if (config === undefined ||
27
+ required.every(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); }) === false) {
28
+ throw new TypeError("adapter ".concat(displayName, " configuration must specify ").concat(required.sort().join(', ')));
29
+ }
30
+ if (oneOf && oneOf.some(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); }) === false) {
31
+ throw new TypeError("adapter ".concat(displayName, " configuration must specify one of ").concat(oneOf.sort().join(', ')));
32
+ }
33
+ if (unsupported !== undefined &&
34
+ unsupported.some(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); })) {
35
+ throw new TypeError("adapter ".concat(displayName, " does not yet support ").concat(unsupported.sort().join(', ')));
36
+ }
37
+ var supported = required.concat(optional);
38
+ if (ObjectKeys(config).some(function (key) { return !supported.includes(key); })) {
39
+ throw new TypeError("adapter ".concat(displayName, " configuration supports only ").concat(supported.sort().join(', ')));
40
+ }
41
+ }
42
+ function untrustedIsObject(untrusted) {
43
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
44
+ }
45
+ function areRequiredParametersPresent(config, configPropertyNames) {
46
+ return configPropertyNames.parameters.required.every(function (req) { return req in config; });
47
+ }
48
+ var snapshotRefreshOptions = {
49
+ overrides: {
50
+ headers: {
51
+ 'Cache-Control': 'no-cache',
52
+ },
53
+ }
54
+ };
55
+ var keyPrefix = 'TableauEmbedding';
56
+
57
+ var ObjectFreeze = Object.freeze;
58
+ var ArrayIsArray = Array.isArray;
59
+ var JSONStringify = JSON.stringify;
60
+ function createLink(ref) {
61
+ return {
62
+ __ref: engine.serializeStructuredKey(ref),
63
+ };
64
+ }
65
+
66
+ var TTL$1 = 180000;
67
+ var VERSION$1 = "97a38409c54dceea0317e696f6166bc4";
68
+ function validate$1(obj, path) {
69
+ if (path === void 0) { path = 'TableauEASRepresentation'; }
70
+ var v_error = (function () {
71
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
72
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
73
+ }
74
+ var obj_issuer = obj.issuer;
75
+ var path_issuer = path + '.issuer';
76
+ if (typeof obj_issuer !== 'string') {
77
+ return new TypeError('Expected "string" but received "' + typeof obj_issuer + '" (at "' + path_issuer + '")');
78
+ }
79
+ var obj_jwks = obj.jwks;
80
+ var path_jwks = path + '.jwks';
81
+ if (typeof obj_jwks !== 'string') {
82
+ return new TypeError('Expected "string" but received "' + typeof obj_jwks + '" (at "' + path_jwks + '")');
83
+ }
84
+ })();
85
+ return v_error === undefined ? null : v_error;
86
+ }
87
+ var RepresentationType$1 = 'TableauEASRepresentation';
88
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
89
+ return input;
90
+ }
91
+ var select$4 = function TableauEASRepresentationSelect() {
92
+ return {
93
+ kind: 'Fragment',
94
+ version: VERSION$1,
95
+ private: [],
96
+ opaque: true
97
+ };
98
+ };
99
+ function equals$1(existing, incoming) {
100
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
101
+ return false;
102
+ }
103
+ return true;
104
+ }
105
+ function deepFreeze$1(input) {
106
+ ObjectFreeze(input);
107
+ }
108
+ var ingest$1 = function TableauEASRepresentationIngest(input, path, luvio, store, timestamp) {
109
+ if (process.env.NODE_ENV !== 'production') {
110
+ var validateError = validate$1(input);
111
+ if (validateError !== null) {
112
+ throw validateError;
113
+ }
114
+ }
115
+ var key = path.fullPath;
116
+ var existingRecord = store.readEntry(key);
117
+ var ttlToUse = TTL$1;
118
+ var incomingRecord = normalize$1(input, store.readEntry(key), {
119
+ fullPath: key,
120
+ parent: path.parent,
121
+ propertyName: path.propertyName,
122
+ ttl: ttlToUse
123
+ });
124
+ deepFreeze$1(input);
125
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
126
+ luvio.storePublish(key, incomingRecord);
127
+ }
128
+ {
129
+ var storeMetadataParams = {
130
+ ttl: ttlToUse,
131
+ namespace: "TableauEmbedding",
132
+ version: VERSION$1,
133
+ representationName: RepresentationType$1,
134
+ };
135
+ luvio.publishStoreMetadata(key, storeMetadataParams);
136
+ }
137
+ return createLink(key);
138
+ };
139
+ function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
140
+ var rootKeySet = new engine.StoreKeyMap();
141
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
142
+ var rootKey = fullPathFactory();
143
+ rootKeySet.set(rootKey, {
144
+ namespace: keyPrefix,
145
+ representationName: RepresentationType$1,
146
+ mergeable: false
147
+ });
148
+ return rootKeySet;
149
+ }
150
+
151
+ function select$3(luvio, params) {
152
+ return select$4();
153
+ }
154
+ function keyBuilder$5(luvio, params) {
155
+ return keyPrefix + '::TableauEASRepresentation:(' + ')';
156
+ }
157
+ function getResponseCacheKeys$2(luvio, resourceParams, response) {
158
+ return getTypeCacheKeys$1(luvio, response, function () { return keyBuilder$5(); });
159
+ }
160
+ function ingestSuccess$2(luvio, resourceParams, response, snapshotRefresh) {
161
+ var body = response.body;
162
+ var key = keyBuilder$5();
163
+ luvio.storeIngest(key, ingest$1, body);
164
+ var snapshot = luvio.storeLookup({
165
+ recordId: key,
166
+ node: select$3(),
167
+ variables: {},
168
+ }, snapshotRefresh);
169
+ if (process.env.NODE_ENV !== 'production') {
170
+ if (snapshot.state !== 'Fulfilled') {
171
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
172
+ }
173
+ }
174
+ return snapshot;
175
+ }
176
+ function ingestError$2(luvio, params, error, snapshotRefresh) {
177
+ var key = keyBuilder$5();
178
+ var errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
179
+ var storeMetadataParams = {
180
+ ttl: TTL$1,
181
+ namespace: keyPrefix,
182
+ version: VERSION$1,
183
+ representationName: RepresentationType$1
184
+ };
185
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
186
+ return errorSnapshot;
187
+ }
188
+ function createResourceRequest$2(config) {
189
+ var headers = {};
190
+ return {
191
+ baseUri: '/services/data/v58.0',
192
+ basePath: '/tableau/eas',
193
+ method: 'get',
194
+ body: null,
195
+ urlParams: {},
196
+ queryParams: {},
197
+ headers: headers,
198
+ priority: 'normal',
199
+ };
200
+ }
201
+
202
+ var getEAS_ConfigPropertyNames = {
203
+ displayName: 'getEAS',
204
+ parameters: {
205
+ required: [],
206
+ optional: []
207
+ }
208
+ };
209
+ function createResourceParams$2(config) {
210
+ var resourceParams = {};
211
+ return resourceParams;
212
+ }
213
+ function keyBuilder$4(luvio, config) {
214
+ return keyBuilder$5();
215
+ }
216
+ function typeCheckConfig$2(untrustedConfig) {
217
+ var config = {};
218
+ return config;
219
+ }
220
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
221
+ if (!untrustedIsObject(untrustedConfig)) {
222
+ return null;
223
+ }
224
+ if (process.env.NODE_ENV !== 'production') {
225
+ validateConfig(untrustedConfig, configPropertyNames);
226
+ }
227
+ var config = typeCheckConfig$2();
228
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
229
+ return null;
230
+ }
231
+ return config;
232
+ }
233
+ function adapterFragment$2(luvio, config) {
234
+ return select$3();
235
+ }
236
+ function onFetchResponseSuccess$2(luvio, config, resourceParams, response) {
237
+ var snapshot = ingestSuccess$2(luvio, resourceParams, response, {
238
+ config: config,
239
+ resolve: function () { return buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions); }
240
+ });
241
+ return luvio.storeBroadcast().then(function () { return snapshot; });
242
+ }
243
+ function onFetchResponseError$2(luvio, config, resourceParams, response) {
244
+ var snapshot = ingestError$2(luvio, resourceParams, response, {
245
+ config: config,
246
+ resolve: function () { return buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions); }
247
+ });
248
+ return luvio.storeBroadcast().then(function () { return snapshot; });
249
+ }
250
+ function buildNetworkSnapshot$2(luvio, config, options) {
251
+ var resourceParams = createResourceParams$2();
252
+ var request = createResourceRequest$2();
253
+ return luvio.dispatchResourceRequest(request, options)
254
+ .then(function (response) {
255
+ return luvio.handleSuccessResponse(function () { return onFetchResponseSuccess$2(luvio, config, resourceParams, response); }, function () { return getResponseCacheKeys$2(luvio, resourceParams, response.body); });
256
+ }, function (response) {
257
+ return luvio.handleErrorResponse(function () { return onFetchResponseError$2(luvio, config, resourceParams, response); });
258
+ });
259
+ }
260
+ function buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext) {
261
+ var luvio = context.luvio, config = context.config;
262
+ var networkPriority = coercedAdapterRequestContext.networkPriority, requestCorrelator = coercedAdapterRequestContext.requestCorrelator, eventObservers = coercedAdapterRequestContext.eventObservers;
263
+ var dispatchOptions = {
264
+ resourceRequestContext: {
265
+ requestCorrelator: requestCorrelator,
266
+ luvioRequestMethod: undefined,
267
+ },
268
+ eventObservers: eventObservers
269
+ };
270
+ if (networkPriority !== 'normal') {
271
+ dispatchOptions.overrides = {
272
+ priority: networkPriority
273
+ };
274
+ }
275
+ return buildNetworkSnapshot$2(luvio, config, dispatchOptions);
276
+ }
277
+ function buildCachedSnapshotCachePolicy$2(context, storeLookup) {
278
+ var luvio = context.luvio, config = context.config;
279
+ var selector = {
280
+ recordId: keyBuilder$4(),
281
+ node: adapterFragment$2(),
282
+ variables: {},
283
+ };
284
+ var cacheSnapshot = storeLookup(selector, {
285
+ config: config,
286
+ resolve: function () { return buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions); }
287
+ });
288
+ return cacheSnapshot;
289
+ }
290
+ var getEASAdapterFactory = function (luvio) { return function TableauEmbedding__getEAS(untrustedConfig, requestContext) {
291
+ var config = validateAdapterConfig$2(untrustedConfig, getEAS_ConfigPropertyNames);
292
+ // Invalid or incomplete config
293
+ if (config === null) {
294
+ return null;
295
+ }
296
+ return luvio.applyCachePolicy((requestContext || {}), { config: config, luvio: luvio }, // BuildSnapshotContext
297
+ buildCachedSnapshotCachePolicy$2, buildNetworkSnapshotCachePolicy$2);
298
+ }; };
299
+
300
+ var TTL = 0;
301
+ var VERSION = "53f57df1863a858a8575f7088b4d78cb";
302
+ function validate(obj, path) {
303
+ if (path === void 0) { path = 'TableauJWTRepresentation'; }
304
+ var v_error = (function () {
305
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
306
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
307
+ }
308
+ var obj_token = obj.token;
309
+ var path_token = path + '.token';
310
+ if (typeof obj_token !== 'string') {
311
+ return new TypeError('Expected "string" but received "' + typeof obj_token + '" (at "' + path_token + '")');
312
+ }
313
+ })();
314
+ return v_error === undefined ? null : v_error;
315
+ }
316
+ var RepresentationType = 'TableauJWTRepresentation';
317
+ function normalize(input, existing, path, luvio, store, timestamp) {
318
+ return input;
319
+ }
320
+ var select$2 = function TableauJWTRepresentationSelect() {
321
+ return {
322
+ kind: 'Fragment',
323
+ version: VERSION,
324
+ private: [],
325
+ opaque: true
326
+ };
327
+ };
328
+ function equals(existing, incoming) {
329
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
330
+ return false;
331
+ }
332
+ return true;
333
+ }
334
+ function deepFreeze(input) {
335
+ ObjectFreeze(input);
336
+ }
337
+ var ingest = function TableauJWTRepresentationIngest(input, path, luvio, store, timestamp) {
338
+ if (process.env.NODE_ENV !== 'production') {
339
+ var validateError = validate(input);
340
+ if (validateError !== null) {
341
+ throw validateError;
342
+ }
343
+ }
344
+ var key = path.fullPath;
345
+ var existingRecord = store.readEntry(key);
346
+ var ttlToUse = TTL;
347
+ var incomingRecord = normalize(input, store.readEntry(key), {
348
+ fullPath: key,
349
+ parent: path.parent,
350
+ propertyName: path.propertyName,
351
+ ttl: ttlToUse
352
+ });
353
+ deepFreeze(input);
354
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
355
+ luvio.storePublish(key, incomingRecord);
356
+ }
357
+ {
358
+ var storeMetadataParams = {
359
+ ttl: ttlToUse,
360
+ namespace: "TableauEmbedding",
361
+ version: VERSION,
362
+ representationName: RepresentationType,
363
+ };
364
+ luvio.publishStoreMetadata(key, storeMetadataParams);
365
+ }
366
+ return createLink(key);
367
+ };
368
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
369
+ var rootKeySet = new engine.StoreKeyMap();
370
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
371
+ var rootKey = fullPathFactory();
372
+ rootKeySet.set(rootKey, {
373
+ namespace: keyPrefix,
374
+ representationName: RepresentationType,
375
+ mergeable: false
376
+ });
377
+ return rootKeySet;
378
+ }
379
+
380
+ function select$1(luvio, params) {
381
+ return select$2();
382
+ }
383
+ function keyBuilder$3(luvio, params) {
384
+ return keyPrefix + '::TableauJWTRepresentation:(' + 'siteId:' + params.queryParams.siteId + ',' + 'tabUrl:' + params.queryParams.tabUrl + ')';
385
+ }
386
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
387
+ return getTypeCacheKeys(luvio, response, function () { return keyBuilder$3(luvio, resourceParams); });
388
+ }
389
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
390
+ var body = response.body;
391
+ var key = keyBuilder$3(luvio, resourceParams);
392
+ luvio.storeIngest(key, ingest, body);
393
+ var snapshot = luvio.storeLookup({
394
+ recordId: key,
395
+ node: select$1(),
396
+ variables: {},
397
+ }, snapshotRefresh);
398
+ if (process.env.NODE_ENV !== 'production') {
399
+ if (snapshot.state !== 'Fulfilled') {
400
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
401
+ }
402
+ }
403
+ return snapshot;
404
+ }
405
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
406
+ var key = keyBuilder$3(luvio, params);
407
+ var errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
408
+ luvio.storeIngestError(key, errorSnapshot);
409
+ return errorSnapshot;
410
+ }
411
+ function createResourceRequest$1(config) {
412
+ var headers = {};
413
+ return {
414
+ baseUri: '/services/data/v58.0',
415
+ basePath: '/tableau/jwt',
416
+ method: 'get',
417
+ body: null,
418
+ urlParams: {},
419
+ queryParams: config.queryParams,
420
+ headers: headers,
421
+ priority: 'normal',
422
+ };
423
+ }
424
+
425
+ var getJWT_ConfigPropertyNames = {
426
+ displayName: 'getJWT',
427
+ parameters: {
428
+ required: [],
429
+ optional: ['siteId', 'tabUrl']
430
+ }
431
+ };
432
+ function createResourceParams$1(config) {
433
+ var resourceParams = {
434
+ queryParams: {
435
+ siteId: config.siteId, tabUrl: config.tabUrl
436
+ }
437
+ };
438
+ return resourceParams;
439
+ }
440
+ function keyBuilder$2(luvio, config) {
441
+ var resourceParams = createResourceParams$1(config);
442
+ return keyBuilder$3(luvio, resourceParams);
443
+ }
444
+ function typeCheckConfig$1(untrustedConfig) {
445
+ var config = {};
446
+ var untrustedConfig_siteId = untrustedConfig.siteId;
447
+ if (typeof untrustedConfig_siteId === 'string') {
448
+ config.siteId = untrustedConfig_siteId;
449
+ }
450
+ var untrustedConfig_tabUrl = untrustedConfig.tabUrl;
451
+ if (typeof untrustedConfig_tabUrl === 'string') {
452
+ config.tabUrl = untrustedConfig_tabUrl;
453
+ }
454
+ return config;
455
+ }
456
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
457
+ if (!untrustedIsObject(untrustedConfig)) {
458
+ return null;
459
+ }
460
+ if (process.env.NODE_ENV !== 'production') {
461
+ validateConfig(untrustedConfig, configPropertyNames);
462
+ }
463
+ var config = typeCheckConfig$1(untrustedConfig);
464
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
465
+ return null;
466
+ }
467
+ return config;
468
+ }
469
+ function adapterFragment$1(luvio, config) {
470
+ createResourceParams$1(config);
471
+ return select$1();
472
+ }
473
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
474
+ var snapshot = ingestSuccess$1(luvio, resourceParams, response, {
475
+ config: config,
476
+ resolve: function () { return buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions); }
477
+ });
478
+ return luvio.storeBroadcast().then(function () { return snapshot; });
479
+ }
480
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
481
+ var snapshot = ingestError$1(luvio, resourceParams, response, {
482
+ config: config,
483
+ resolve: function () { return buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions); }
484
+ });
485
+ return luvio.storeBroadcast().then(function () { return snapshot; });
486
+ }
487
+ function buildNetworkSnapshot$1(luvio, config, options) {
488
+ var resourceParams = createResourceParams$1(config);
489
+ var request = createResourceRequest$1(resourceParams);
490
+ return luvio.dispatchResourceRequest(request, options)
491
+ .then(function (response) {
492
+ return luvio.handleSuccessResponse(function () { return onFetchResponseSuccess$1(luvio, config, resourceParams, response); }, function () { return getResponseCacheKeys$1(luvio, resourceParams, response.body); });
493
+ }, function (response) {
494
+ return luvio.handleErrorResponse(function () { return onFetchResponseError$1(luvio, config, resourceParams, response); });
495
+ });
496
+ }
497
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
498
+ var luvio = context.luvio, config = context.config;
499
+ var networkPriority = coercedAdapterRequestContext.networkPriority, requestCorrelator = coercedAdapterRequestContext.requestCorrelator, eventObservers = coercedAdapterRequestContext.eventObservers;
500
+ var dispatchOptions = {
501
+ resourceRequestContext: {
502
+ requestCorrelator: requestCorrelator,
503
+ luvioRequestMethod: undefined,
504
+ },
505
+ eventObservers: eventObservers
506
+ };
507
+ if (networkPriority !== 'normal') {
508
+ dispatchOptions.overrides = {
509
+ priority: networkPriority
510
+ };
511
+ }
512
+ return buildNetworkSnapshot$1(luvio, config, dispatchOptions);
513
+ }
514
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
515
+ var luvio = context.luvio, config = context.config;
516
+ var selector = {
517
+ recordId: keyBuilder$2(luvio, config),
518
+ node: adapterFragment$1(luvio, config),
519
+ variables: {},
520
+ };
521
+ var cacheSnapshot = storeLookup(selector, {
522
+ config: config,
523
+ resolve: function () { return buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions); }
524
+ });
525
+ return cacheSnapshot;
526
+ }
527
+ var getJWTAdapterFactory = function (luvio) { return function TableauEmbedding__getJWT(untrustedConfig, requestContext) {
528
+ var config = validateAdapterConfig$1(untrustedConfig, getJWT_ConfigPropertyNames);
529
+ // Invalid or incomplete config
530
+ if (config === null) {
531
+ return null;
532
+ }
533
+ return luvio.applyCachePolicy((requestContext || {}), { config: config, luvio: luvio }, // BuildSnapshotContext
534
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
535
+ }; };
536
+
537
+ function select(luvio, params) {
538
+ return select$2();
539
+ }
540
+ function keyBuilder$1(luvio, params) {
541
+ return keyPrefix + '::TableauJWTRepresentation:(' + (params.body.siteId === undefined ? 'siteId' : 'siteId:' + params.body.siteId) + '::' + (params.body.tabUrl === undefined ? 'tabUrl' : 'tabUrl:' + params.body.tabUrl) + ')';
542
+ }
543
+ function getResponseCacheKeys(luvio, resourceParams, response) {
544
+ return getTypeCacheKeys(luvio, response, function () { return keyBuilder$1(luvio, resourceParams); });
545
+ }
546
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
547
+ var body = response.body;
548
+ var key = keyBuilder$1(luvio, resourceParams);
549
+ luvio.storeIngest(key, ingest, body);
550
+ var snapshot = luvio.storeLookup({
551
+ recordId: key,
552
+ node: select(),
553
+ variables: {},
554
+ }, snapshotRefresh);
555
+ if (process.env.NODE_ENV !== 'production') {
556
+ if (snapshot.state !== 'Fulfilled') {
557
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
558
+ }
559
+ }
560
+ return snapshot;
561
+ }
562
+ function ingestError(luvio, params, error, snapshotRefresh) {
563
+ var key = keyBuilder$1(luvio, params);
564
+ var errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
565
+ luvio.storeIngestError(key, errorSnapshot);
566
+ return errorSnapshot;
567
+ }
568
+ function createResourceRequest(config) {
569
+ var headers = {};
570
+ return {
571
+ baseUri: '/services/data/v58.0',
572
+ basePath: '/tableau/jwt',
573
+ method: 'post',
574
+ body: config.body,
575
+ urlParams: {},
576
+ queryParams: {},
577
+ headers: headers,
578
+ priority: 'normal',
579
+ };
580
+ }
581
+
582
+ var postJWT_ConfigPropertyNames = {
583
+ displayName: 'postJWT',
584
+ parameters: {
585
+ required: [],
586
+ optional: ['siteId', 'tabUrl']
587
+ }
588
+ };
589
+ function createResourceParams(config) {
590
+ var resourceParams = {
591
+ body: {}
592
+ };
593
+ if (config['siteId'] !== undefined) {
594
+ resourceParams.body['siteId'] = config['siteId'];
595
+ }
596
+ if (config['tabUrl'] !== undefined) {
597
+ resourceParams.body['tabUrl'] = config['tabUrl'];
598
+ }
599
+ return resourceParams;
600
+ }
601
+ function keyBuilder(luvio, config) {
602
+ var resourceParams = createResourceParams(config);
603
+ return keyBuilder$1(luvio, resourceParams);
604
+ }
605
+ function typeCheckConfig(untrustedConfig) {
606
+ var config = {};
607
+ var untrustedConfig_siteId = untrustedConfig.siteId;
608
+ if (typeof untrustedConfig_siteId === 'string') {
609
+ config.siteId = untrustedConfig_siteId;
610
+ }
611
+ var untrustedConfig_tabUrl = untrustedConfig.tabUrl;
612
+ if (typeof untrustedConfig_tabUrl === 'string') {
613
+ config.tabUrl = untrustedConfig_tabUrl;
614
+ }
615
+ return config;
616
+ }
617
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
618
+ if (!untrustedIsObject(untrustedConfig)) {
619
+ return null;
620
+ }
621
+ if (process.env.NODE_ENV !== 'production') {
622
+ validateConfig(untrustedConfig, configPropertyNames);
623
+ }
624
+ var config = typeCheckConfig(untrustedConfig);
625
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
626
+ return null;
627
+ }
628
+ return config;
629
+ }
630
+ function adapterFragment(luvio, config) {
631
+ createResourceParams(config);
632
+ return select();
633
+ }
634
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
635
+ var snapshot = ingestSuccess(luvio, resourceParams, response, {
636
+ config: config,
637
+ resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
638
+ });
639
+ return luvio.storeBroadcast().then(function () { return snapshot; });
640
+ }
641
+ function onFetchResponseError(luvio, config, resourceParams, response) {
642
+ var snapshot = ingestError(luvio, resourceParams, response, {
643
+ config: config,
644
+ resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
645
+ });
646
+ return luvio.storeBroadcast().then(function () { return snapshot; });
647
+ }
648
+ function buildNetworkSnapshot(luvio, config, options) {
649
+ var resourceParams = createResourceParams(config);
650
+ var request = createResourceRequest(resourceParams);
651
+ return luvio.dispatchResourceRequest(request, options)
652
+ .then(function (response) {
653
+ return luvio.handleSuccessResponse(function () { return onFetchResponseSuccess(luvio, config, resourceParams, response); }, function () { return getResponseCacheKeys(luvio, resourceParams, response.body); });
654
+ }, function (response) {
655
+ return luvio.handleErrorResponse(function () { return onFetchResponseError(luvio, config, resourceParams, response); });
656
+ });
657
+ }
658
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
659
+ var luvio = context.luvio, config = context.config;
660
+ var networkPriority = coercedAdapterRequestContext.networkPriority, requestCorrelator = coercedAdapterRequestContext.requestCorrelator, eventObservers = coercedAdapterRequestContext.eventObservers;
661
+ var dispatchOptions = {
662
+ resourceRequestContext: {
663
+ requestCorrelator: requestCorrelator,
664
+ luvioRequestMethod: 'get',
665
+ },
666
+ eventObservers: eventObservers
667
+ };
668
+ if (networkPriority !== 'normal') {
669
+ dispatchOptions.overrides = {
670
+ priority: networkPriority
671
+ };
672
+ }
673
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
674
+ }
675
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
676
+ var luvio = context.luvio, config = context.config;
677
+ var selector = {
678
+ recordId: keyBuilder(luvio, config),
679
+ node: adapterFragment(luvio, config),
680
+ variables: {},
681
+ };
682
+ var cacheSnapshot = storeLookup(selector, {
683
+ config: config,
684
+ resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
685
+ });
686
+ return cacheSnapshot;
687
+ }
688
+ var postJWTAdapterFactory = function (luvio) { return function TableauEmbedding__postJWT(untrustedConfig, requestContext) {
689
+ var config = validateAdapterConfig(untrustedConfig, postJWT_ConfigPropertyNames);
690
+ // Invalid or incomplete config
691
+ if (config === null) {
692
+ return null;
693
+ }
694
+ return luvio.applyCachePolicy((requestContext || {}), { config: config, luvio: luvio }, // BuildSnapshotContext
695
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
696
+ }; };
697
+
698
+ exports.getEASAdapterFactory = getEASAdapterFactory;
699
+ exports.getJWTAdapterFactory = getJWTAdapterFactory;
700
+ exports.postJWTAdapterFactory = postJWTAdapterFactory;
701
+
702
+ Object.defineProperty(exports, '__esModule', { value: true });
703
+
704
+ }));