@salesforce/lds-adapters-crm-infra-notification-service 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.
@@ -0,0 +1,323 @@
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["crm-infraNotificationService"] = {}, global.engine));
11
+ })(this, (function (exports, engine) { 'use strict';
12
+
13
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
14
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
15
+ const { isArray: ArrayIsArray$1 } = Array;
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
+ const { displayName } = adapter;
25
+ const { required, optional, unsupported } = adapter.parameters;
26
+ if (config === undefined ||
27
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
28
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
29
+ }
30
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
31
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
32
+ }
33
+ if (unsupported !== undefined &&
34
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
35
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
36
+ }
37
+ const supported = required.concat(optional);
38
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
39
+ throw new TypeError(`adapter ${displayName} configuration supports only ${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(req => req in config);
47
+ }
48
+ const snapshotRefreshOptions = {
49
+ overrides: {
50
+ headers: {
51
+ 'Cache-Control': 'no-cache',
52
+ },
53
+ }
54
+ };
55
+ const keyPrefix = 'notification-service';
56
+
57
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
58
+ const { isArray: ArrayIsArray } = Array;
59
+ const { stringify: JSONStringify } = JSON;
60
+ function createLink(ref) {
61
+ return {
62
+ __ref: engine.serializeStructuredKey(ref),
63
+ };
64
+ }
65
+
66
+ const TTL = 60000;
67
+ const VERSION = "17a8e22455464717a67e522cfe3694f0";
68
+ function validate(obj, path = 'NotificationServiceConfigRepresentation') {
69
+ const v_error = (() => {
70
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
71
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
72
+ }
73
+ const obj_authToken = obj.authToken;
74
+ const path_authToken = path + '.authToken';
75
+ if (typeof obj_authToken !== 'string') {
76
+ return new TypeError('Expected "string" but received "' + typeof obj_authToken + '" (at "' + path_authToken + '")');
77
+ }
78
+ const obj_isEnabled = obj.isEnabled;
79
+ const path_isEnabled = path + '.isEnabled';
80
+ if (typeof obj_isEnabled !== 'boolean') {
81
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isEnabled + '" (at "' + path_isEnabled + '")');
82
+ }
83
+ const obj_notificationServiceGrpcEndpoint = obj.notificationServiceGrpcEndpoint;
84
+ const path_notificationServiceGrpcEndpoint = path + '.notificationServiceGrpcEndpoint';
85
+ if (typeof obj_notificationServiceGrpcEndpoint !== 'string') {
86
+ return new TypeError('Expected "string" but received "' + typeof obj_notificationServiceGrpcEndpoint + '" (at "' + path_notificationServiceGrpcEndpoint + '")');
87
+ }
88
+ const obj_notificationServicePublicEndpoint = obj.notificationServicePublicEndpoint;
89
+ const path_notificationServicePublicEndpoint = path + '.notificationServicePublicEndpoint';
90
+ if (typeof obj_notificationServicePublicEndpoint !== 'string') {
91
+ return new TypeError('Expected "string" but received "' + typeof obj_notificationServicePublicEndpoint + '" (at "' + path_notificationServicePublicEndpoint + '")');
92
+ }
93
+ const obj_orgId18 = obj.orgId18;
94
+ const path_orgId18 = path + '.orgId18';
95
+ if (typeof obj_orgId18 !== 'string') {
96
+ return new TypeError('Expected "string" but received "' + typeof obj_orgId18 + '" (at "' + path_orgId18 + '")');
97
+ }
98
+ const obj_userId18 = obj.userId18;
99
+ const path_userId18 = path + '.userId18';
100
+ if (typeof obj_userId18 !== 'string') {
101
+ return new TypeError('Expected "string" but received "' + typeof obj_userId18 + '" (at "' + path_userId18 + '")');
102
+ }
103
+ })();
104
+ return v_error === undefined ? null : v_error;
105
+ }
106
+ const RepresentationType = 'NotificationServiceConfigRepresentation';
107
+ function normalize(input, existing, path, luvio, store, timestamp) {
108
+ return input;
109
+ }
110
+ const select$1 = function NotificationServiceConfigRepresentationSelect() {
111
+ return {
112
+ kind: 'Fragment',
113
+ version: VERSION,
114
+ private: [],
115
+ opaque: true
116
+ };
117
+ };
118
+ function equals(existing, incoming) {
119
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
120
+ return false;
121
+ }
122
+ return true;
123
+ }
124
+ function deepFreeze(input) {
125
+ ObjectFreeze(input);
126
+ }
127
+ const ingest = function NotificationServiceConfigRepresentationIngest(input, path, luvio, store, timestamp) {
128
+ if (process.env.NODE_ENV !== 'production') {
129
+ const validateError = validate(input);
130
+ if (validateError !== null) {
131
+ throw validateError;
132
+ }
133
+ }
134
+ const key = path.fullPath;
135
+ const existingRecord = store.readEntry(key);
136
+ const ttlToUse = TTL;
137
+ let incomingRecord = normalize(input, store.readEntry(key), {
138
+ fullPath: key,
139
+ parent: path.parent,
140
+ propertyName: path.propertyName,
141
+ ttl: ttlToUse
142
+ });
143
+ deepFreeze(input);
144
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
145
+ luvio.storePublish(key, incomingRecord);
146
+ }
147
+ {
148
+ const storeMetadataParams = {
149
+ ttl: ttlToUse,
150
+ namespace: "notification-service",
151
+ version: VERSION,
152
+ representationName: RepresentationType,
153
+ };
154
+ luvio.publishStoreMetadata(key, storeMetadataParams);
155
+ }
156
+ return createLink(key);
157
+ };
158
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
159
+ const rootKeySet = new engine.StoreKeyMap();
160
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
161
+ const rootKey = fullPathFactory();
162
+ rootKeySet.set(rootKey, {
163
+ namespace: keyPrefix,
164
+ representationName: RepresentationType,
165
+ mergeable: false
166
+ });
167
+ return rootKeySet;
168
+ }
169
+
170
+ function select(luvio, params) {
171
+ return select$1();
172
+ }
173
+ function keyBuilder$1(luvio, params) {
174
+ return keyPrefix + '::NotificationServiceConfigRepresentation:(' + ')';
175
+ }
176
+ function getResponseCacheKeys(luvio, resourceParams, response) {
177
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1());
178
+ }
179
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
180
+ const { body } = response;
181
+ const key = keyBuilder$1();
182
+ luvio.storeIngest(key, ingest, body);
183
+ const snapshot = luvio.storeLookup({
184
+ recordId: key,
185
+ node: select(),
186
+ variables: {},
187
+ }, snapshotRefresh);
188
+ if (process.env.NODE_ENV !== 'production') {
189
+ if (snapshot.state !== 'Fulfilled') {
190
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
191
+ }
192
+ }
193
+ return snapshot;
194
+ }
195
+ function ingestError(luvio, params, error, snapshotRefresh) {
196
+ const key = keyBuilder$1();
197
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
198
+ const storeMetadataParams = {
199
+ ttl: TTL,
200
+ namespace: keyPrefix,
201
+ version: VERSION,
202
+ representationName: RepresentationType
203
+ };
204
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
205
+ return errorSnapshot;
206
+ }
207
+ function createResourceRequest(config) {
208
+ const headers = {};
209
+ return {
210
+ baseUri: '/services/data/v58.0',
211
+ basePath: '/connect/notification_service/config',
212
+ method: 'get',
213
+ body: null,
214
+ urlParams: {},
215
+ queryParams: {},
216
+ headers,
217
+ priority: 'normal',
218
+ };
219
+ }
220
+
221
+ const getNSConfig_ConfigPropertyNames = {
222
+ displayName: 'getNSConfig',
223
+ parameters: {
224
+ required: [],
225
+ optional: []
226
+ }
227
+ };
228
+ function createResourceParams(config) {
229
+ const resourceParams = {};
230
+ return resourceParams;
231
+ }
232
+ function keyBuilder(luvio, config) {
233
+ return keyBuilder$1();
234
+ }
235
+ function typeCheckConfig(untrustedConfig) {
236
+ const config = {};
237
+ return config;
238
+ }
239
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
240
+ if (!untrustedIsObject(untrustedConfig)) {
241
+ return null;
242
+ }
243
+ if (process.env.NODE_ENV !== 'production') {
244
+ validateConfig(untrustedConfig, configPropertyNames);
245
+ }
246
+ const config = typeCheckConfig();
247
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
248
+ return null;
249
+ }
250
+ return config;
251
+ }
252
+ function adapterFragment(luvio, config) {
253
+ return select();
254
+ }
255
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
256
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
257
+ config,
258
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
259
+ });
260
+ return luvio.storeBroadcast().then(() => snapshot);
261
+ }
262
+ function onFetchResponseError(luvio, config, resourceParams, response) {
263
+ const snapshot = ingestError(luvio, resourceParams, response, {
264
+ config,
265
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
266
+ });
267
+ return luvio.storeBroadcast().then(() => snapshot);
268
+ }
269
+ function buildNetworkSnapshot(luvio, config, options) {
270
+ const resourceParams = createResourceParams();
271
+ const request = createResourceRequest();
272
+ return luvio.dispatchResourceRequest(request, options)
273
+ .then((response) => {
274
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
275
+ }, (response) => {
276
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
277
+ });
278
+ }
279
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
280
+ const { luvio, config } = context;
281
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
282
+ const dispatchOptions = {
283
+ resourceRequestContext: {
284
+ requestCorrelator,
285
+ luvioRequestMethod: undefined,
286
+ },
287
+ eventObservers
288
+ };
289
+ if (networkPriority !== 'normal') {
290
+ dispatchOptions.overrides = {
291
+ priority: networkPriority
292
+ };
293
+ }
294
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
295
+ }
296
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
297
+ const { luvio, config } = context;
298
+ const selector = {
299
+ recordId: keyBuilder(),
300
+ node: adapterFragment(),
301
+ variables: {},
302
+ };
303
+ const cacheSnapshot = storeLookup(selector, {
304
+ config,
305
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
306
+ });
307
+ return cacheSnapshot;
308
+ }
309
+ const getNSConfigAdapterFactory = (luvio) => function notificationService__getNSConfig(untrustedConfig, requestContext) {
310
+ const config = validateAdapterConfig(untrustedConfig, getNSConfig_ConfigPropertyNames);
311
+ // Invalid or incomplete config
312
+ if (config === null) {
313
+ return null;
314
+ }
315
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
316
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
317
+ };
318
+
319
+ exports.getNSConfigAdapterFactory = getNSConfigAdapterFactory;
320
+
321
+ Object.defineProperty(exports, '__esModule', { value: true });
322
+
323
+ }));
@@ -0,0 +1,324 @@
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["crm-infraNotificationService"] = {}, 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 = 'notification-service';
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 = 60000;
67
+ var VERSION = "17a8e22455464717a67e522cfe3694f0";
68
+ function validate(obj, path) {
69
+ if (path === void 0) { path = 'NotificationServiceConfigRepresentation'; }
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_authToken = obj.authToken;
75
+ var path_authToken = path + '.authToken';
76
+ if (typeof obj_authToken !== 'string') {
77
+ return new TypeError('Expected "string" but received "' + typeof obj_authToken + '" (at "' + path_authToken + '")');
78
+ }
79
+ var obj_isEnabled = obj.isEnabled;
80
+ var path_isEnabled = path + '.isEnabled';
81
+ if (typeof obj_isEnabled !== 'boolean') {
82
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isEnabled + '" (at "' + path_isEnabled + '")');
83
+ }
84
+ var obj_notificationServiceGrpcEndpoint = obj.notificationServiceGrpcEndpoint;
85
+ var path_notificationServiceGrpcEndpoint = path + '.notificationServiceGrpcEndpoint';
86
+ if (typeof obj_notificationServiceGrpcEndpoint !== 'string') {
87
+ return new TypeError('Expected "string" but received "' + typeof obj_notificationServiceGrpcEndpoint + '" (at "' + path_notificationServiceGrpcEndpoint + '")');
88
+ }
89
+ var obj_notificationServicePublicEndpoint = obj.notificationServicePublicEndpoint;
90
+ var path_notificationServicePublicEndpoint = path + '.notificationServicePublicEndpoint';
91
+ if (typeof obj_notificationServicePublicEndpoint !== 'string') {
92
+ return new TypeError('Expected "string" but received "' + typeof obj_notificationServicePublicEndpoint + '" (at "' + path_notificationServicePublicEndpoint + '")');
93
+ }
94
+ var obj_orgId18 = obj.orgId18;
95
+ var path_orgId18 = path + '.orgId18';
96
+ if (typeof obj_orgId18 !== 'string') {
97
+ return new TypeError('Expected "string" but received "' + typeof obj_orgId18 + '" (at "' + path_orgId18 + '")');
98
+ }
99
+ var obj_userId18 = obj.userId18;
100
+ var path_userId18 = path + '.userId18';
101
+ if (typeof obj_userId18 !== 'string') {
102
+ return new TypeError('Expected "string" but received "' + typeof obj_userId18 + '" (at "' + path_userId18 + '")');
103
+ }
104
+ })();
105
+ return v_error === undefined ? null : v_error;
106
+ }
107
+ var RepresentationType = 'NotificationServiceConfigRepresentation';
108
+ function normalize(input, existing, path, luvio, store, timestamp) {
109
+ return input;
110
+ }
111
+ var select$1 = function NotificationServiceConfigRepresentationSelect() {
112
+ return {
113
+ kind: 'Fragment',
114
+ version: VERSION,
115
+ private: [],
116
+ opaque: true
117
+ };
118
+ };
119
+ function equals(existing, incoming) {
120
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
121
+ return false;
122
+ }
123
+ return true;
124
+ }
125
+ function deepFreeze(input) {
126
+ ObjectFreeze(input);
127
+ }
128
+ var ingest = function NotificationServiceConfigRepresentationIngest(input, path, luvio, store, timestamp) {
129
+ if (process.env.NODE_ENV !== 'production') {
130
+ var validateError = validate(input);
131
+ if (validateError !== null) {
132
+ throw validateError;
133
+ }
134
+ }
135
+ var key = path.fullPath;
136
+ var existingRecord = store.readEntry(key);
137
+ var ttlToUse = TTL;
138
+ var incomingRecord = normalize(input, store.readEntry(key), {
139
+ fullPath: key,
140
+ parent: path.parent,
141
+ propertyName: path.propertyName,
142
+ ttl: ttlToUse
143
+ });
144
+ deepFreeze(input);
145
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
146
+ luvio.storePublish(key, incomingRecord);
147
+ }
148
+ {
149
+ var storeMetadataParams = {
150
+ ttl: ttlToUse,
151
+ namespace: "notification-service",
152
+ version: VERSION,
153
+ representationName: RepresentationType,
154
+ };
155
+ luvio.publishStoreMetadata(key, storeMetadataParams);
156
+ }
157
+ return createLink(key);
158
+ };
159
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
160
+ var rootKeySet = new engine.StoreKeyMap();
161
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
162
+ var rootKey = fullPathFactory();
163
+ rootKeySet.set(rootKey, {
164
+ namespace: keyPrefix,
165
+ representationName: RepresentationType,
166
+ mergeable: false
167
+ });
168
+ return rootKeySet;
169
+ }
170
+
171
+ function select(luvio, params) {
172
+ return select$1();
173
+ }
174
+ function keyBuilder$1(luvio, params) {
175
+ return keyPrefix + '::NotificationServiceConfigRepresentation:(' + ')';
176
+ }
177
+ function getResponseCacheKeys(luvio, resourceParams, response) {
178
+ return getTypeCacheKeys(luvio, response, function () { return keyBuilder$1(); });
179
+ }
180
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
181
+ var body = response.body;
182
+ var key = keyBuilder$1();
183
+ luvio.storeIngest(key, ingest, body);
184
+ var snapshot = luvio.storeLookup({
185
+ recordId: key,
186
+ node: select(),
187
+ variables: {},
188
+ }, snapshotRefresh);
189
+ if (process.env.NODE_ENV !== 'production') {
190
+ if (snapshot.state !== 'Fulfilled') {
191
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
192
+ }
193
+ }
194
+ return snapshot;
195
+ }
196
+ function ingestError(luvio, params, error, snapshotRefresh) {
197
+ var key = keyBuilder$1();
198
+ var errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
199
+ var storeMetadataParams = {
200
+ ttl: TTL,
201
+ namespace: keyPrefix,
202
+ version: VERSION,
203
+ representationName: RepresentationType
204
+ };
205
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
206
+ return errorSnapshot;
207
+ }
208
+ function createResourceRequest(config) {
209
+ var headers = {};
210
+ return {
211
+ baseUri: '/services/data/v58.0',
212
+ basePath: '/connect/notification_service/config',
213
+ method: 'get',
214
+ body: null,
215
+ urlParams: {},
216
+ queryParams: {},
217
+ headers: headers,
218
+ priority: 'normal',
219
+ };
220
+ }
221
+
222
+ var getNSConfig_ConfigPropertyNames = {
223
+ displayName: 'getNSConfig',
224
+ parameters: {
225
+ required: [],
226
+ optional: []
227
+ }
228
+ };
229
+ function createResourceParams(config) {
230
+ var resourceParams = {};
231
+ return resourceParams;
232
+ }
233
+ function keyBuilder(luvio, config) {
234
+ return keyBuilder$1();
235
+ }
236
+ function typeCheckConfig(untrustedConfig) {
237
+ var config = {};
238
+ return config;
239
+ }
240
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
241
+ if (!untrustedIsObject(untrustedConfig)) {
242
+ return null;
243
+ }
244
+ if (process.env.NODE_ENV !== 'production') {
245
+ validateConfig(untrustedConfig, configPropertyNames);
246
+ }
247
+ var config = typeCheckConfig();
248
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
249
+ return null;
250
+ }
251
+ return config;
252
+ }
253
+ function adapterFragment(luvio, config) {
254
+ return select();
255
+ }
256
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
257
+ var snapshot = ingestSuccess(luvio, resourceParams, response, {
258
+ config: config,
259
+ resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
260
+ });
261
+ return luvio.storeBroadcast().then(function () { return snapshot; });
262
+ }
263
+ function onFetchResponseError(luvio, config, resourceParams, response) {
264
+ var snapshot = ingestError(luvio, resourceParams, response, {
265
+ config: config,
266
+ resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
267
+ });
268
+ return luvio.storeBroadcast().then(function () { return snapshot; });
269
+ }
270
+ function buildNetworkSnapshot(luvio, config, options) {
271
+ var resourceParams = createResourceParams();
272
+ var request = createResourceRequest();
273
+ return luvio.dispatchResourceRequest(request, options)
274
+ .then(function (response) {
275
+ return luvio.handleSuccessResponse(function () { return onFetchResponseSuccess(luvio, config, resourceParams, response); }, function () { return getResponseCacheKeys(luvio, resourceParams, response.body); });
276
+ }, function (response) {
277
+ return luvio.handleErrorResponse(function () { return onFetchResponseError(luvio, config, resourceParams, response); });
278
+ });
279
+ }
280
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
281
+ var luvio = context.luvio, config = context.config;
282
+ var networkPriority = coercedAdapterRequestContext.networkPriority, requestCorrelator = coercedAdapterRequestContext.requestCorrelator, eventObservers = coercedAdapterRequestContext.eventObservers;
283
+ var dispatchOptions = {
284
+ resourceRequestContext: {
285
+ requestCorrelator: requestCorrelator,
286
+ luvioRequestMethod: undefined,
287
+ },
288
+ eventObservers: eventObservers
289
+ };
290
+ if (networkPriority !== 'normal') {
291
+ dispatchOptions.overrides = {
292
+ priority: networkPriority
293
+ };
294
+ }
295
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
296
+ }
297
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
298
+ var luvio = context.luvio, config = context.config;
299
+ var selector = {
300
+ recordId: keyBuilder(),
301
+ node: adapterFragment(),
302
+ variables: {},
303
+ };
304
+ var cacheSnapshot = storeLookup(selector, {
305
+ config: config,
306
+ resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
307
+ });
308
+ return cacheSnapshot;
309
+ }
310
+ var getNSConfigAdapterFactory = function (luvio) { return function notificationService__getNSConfig(untrustedConfig, requestContext) {
311
+ var config = validateAdapterConfig(untrustedConfig, getNSConfig_ConfigPropertyNames);
312
+ // Invalid or incomplete config
313
+ if (config === null) {
314
+ return null;
315
+ }
316
+ return luvio.applyCachePolicy((requestContext || {}), { config: config, luvio: luvio }, // BuildSnapshotContext
317
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
318
+ }; };
319
+
320
+ exports.getNSConfigAdapterFactory = getNSConfigAdapterFactory;
321
+
322
+ Object.defineProperty(exports, '__esModule', { value: true });
323
+
324
+ }));