@salesforce/lds-adapters-crm-infra-notification-service 1.124.2 → 1.124.3

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