@salesforce/lds-adapters-community-seo 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,337 +6,337 @@
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 = 'CommunitiesSeo';
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 = 3600000;
63
- const VERSION = "90faea19574b714959a69d7deba72445";
64
- function validate(obj, path = 'RecordSeoPropertiesRepresentation') {
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_fields = obj.fields;
70
- const path_fields = path + '.fields';
71
- if (typeof obj_fields !== 'object' || ArrayIsArray(obj_fields) || obj_fields === null) {
72
- return new TypeError('Expected "object" but received "' + typeof obj_fields + '" (at "' + path_fields + '")');
73
- }
74
- const obj_fields_keys = ObjectKeys(obj_fields);
75
- for (let i = 0; i < obj_fields_keys.length; i++) {
76
- const key = obj_fields_keys[i];
77
- const obj_fields_prop = obj_fields[key];
78
- const path_fields_prop = path_fields + '["' + key + '"]';
79
- if (typeof obj_fields_prop !== 'string') {
80
- return new TypeError('Expected "string" but received "' + typeof obj_fields_prop + '" (at "' + path_fields_prop + '")');
81
- }
82
- }
83
- const obj_objectName = obj.objectName;
84
- const path_objectName = path + '.objectName';
85
- if (typeof obj_objectName !== 'string') {
86
- return new TypeError('Expected "string" but received "' + typeof obj_objectName + '" (at "' + path_objectName + '")');
87
- }
88
- const obj_recordId = obj.recordId;
89
- const path_recordId = path + '.recordId';
90
- if (typeof obj_recordId !== 'string') {
91
- return new TypeError('Expected "string" but received "' + typeof obj_recordId + '" (at "' + path_recordId + '")');
92
- }
93
- const obj_recordName = obj.recordName;
94
- const path_recordName = path + '.recordName';
95
- if (typeof obj_recordName !== 'string') {
96
- return new TypeError('Expected "string" but received "' + typeof obj_recordName + '" (at "' + path_recordName + '")');
97
- }
98
- })();
99
- return v_error === undefined ? null : v_error;
100
- }
101
- const RepresentationType = 'RecordSeoPropertiesRepresentation';
102
- function normalize(input, existing, path, luvio, store, timestamp) {
103
- return input;
104
- }
105
- const select$1 = function RecordSeoPropertiesRepresentationSelect() {
106
- return {
107
- kind: 'Fragment',
108
- version: VERSION,
109
- private: [],
110
- opaque: true
111
- };
112
- };
113
- function equals(existing, incoming) {
114
- if (JSONStringify(incoming) !== JSONStringify(existing)) {
115
- return false;
116
- }
117
- return true;
118
- }
119
- function deepFreeze(input) {
120
- const input_fields = input.fields;
121
- const input_fields_keys = Object.keys(input_fields);
122
- const input_fields_length = input_fields_keys.length;
123
- for (let i = 0; i < input_fields_length; i++) {
124
- input_fields_keys[i];
125
- }
126
- ObjectFreeze(input_fields);
127
- ObjectFreeze(input);
128
- }
129
- const ingest = function RecordSeoPropertiesRepresentationIngest(input, path, luvio, store, timestamp) {
130
- if (process.env.NODE_ENV !== 'production') {
131
- const validateError = validate(input);
132
- if (validateError !== null) {
133
- throw validateError;
134
- }
135
- }
136
- const key = path.fullPath;
137
- const existingRecord = store.readEntry(key);
138
- const ttlToUse = TTL;
139
- let incomingRecord = normalize(input, store.readEntry(key), {
140
- fullPath: key,
141
- parent: path.parent,
142
- propertyName: path.propertyName,
143
- ttl: ttlToUse
144
- });
145
- deepFreeze(input);
146
- if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
147
- luvio.storePublish(key, incomingRecord);
148
- }
149
- {
150
- const storeMetadataParams = {
151
- ttl: ttlToUse,
152
- namespace: "CommunitiesSeo",
153
- version: VERSION,
154
- representationName: RepresentationType,
155
- };
156
- luvio.publishStoreMetadata(key, storeMetadataParams);
157
- }
158
- return createLink(key);
159
- };
160
- function getTypeCacheKeys(luvio, input, fullPathFactory) {
161
- const rootKeySet = new StoreKeyMap();
162
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
163
- const rootKey = fullPathFactory();
164
- rootKeySet.set(rootKey, {
165
- namespace: keyPrefix,
166
- representationName: RepresentationType,
167
- mergeable: false
168
- });
169
- return rootKeySet;
62
+ const TTL = 3600000;
63
+ const VERSION = "90faea19574b714959a69d7deba72445";
64
+ function validate(obj, path = 'RecordSeoPropertiesRepresentation') {
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_fields = obj.fields;
70
+ const path_fields = path + '.fields';
71
+ if (typeof obj_fields !== 'object' || ArrayIsArray(obj_fields) || obj_fields === null) {
72
+ return new TypeError('Expected "object" but received "' + typeof obj_fields + '" (at "' + path_fields + '")');
73
+ }
74
+ const obj_fields_keys = ObjectKeys(obj_fields);
75
+ for (let i = 0; i < obj_fields_keys.length; i++) {
76
+ const key = obj_fields_keys[i];
77
+ const obj_fields_prop = obj_fields[key];
78
+ const path_fields_prop = path_fields + '["' + key + '"]';
79
+ if (typeof obj_fields_prop !== 'string') {
80
+ return new TypeError('Expected "string" but received "' + typeof obj_fields_prop + '" (at "' + path_fields_prop + '")');
81
+ }
82
+ }
83
+ const obj_objectName = obj.objectName;
84
+ const path_objectName = path + '.objectName';
85
+ if (typeof obj_objectName !== 'string') {
86
+ return new TypeError('Expected "string" but received "' + typeof obj_objectName + '" (at "' + path_objectName + '")');
87
+ }
88
+ const obj_recordId = obj.recordId;
89
+ const path_recordId = path + '.recordId';
90
+ if (typeof obj_recordId !== 'string') {
91
+ return new TypeError('Expected "string" but received "' + typeof obj_recordId + '" (at "' + path_recordId + '")');
92
+ }
93
+ const obj_recordName = obj.recordName;
94
+ const path_recordName = path + '.recordName';
95
+ if (typeof obj_recordName !== 'string') {
96
+ return new TypeError('Expected "string" but received "' + typeof obj_recordName + '" (at "' + path_recordName + '")');
97
+ }
98
+ })();
99
+ return v_error === undefined ? null : v_error;
100
+ }
101
+ const RepresentationType = 'RecordSeoPropertiesRepresentation';
102
+ function normalize(input, existing, path, luvio, store, timestamp) {
103
+ return input;
104
+ }
105
+ const select$1 = function RecordSeoPropertiesRepresentationSelect() {
106
+ return {
107
+ kind: 'Fragment',
108
+ version: VERSION,
109
+ private: [],
110
+ opaque: true
111
+ };
112
+ };
113
+ function equals(existing, incoming) {
114
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
115
+ return false;
116
+ }
117
+ return true;
118
+ }
119
+ function deepFreeze(input) {
120
+ const input_fields = input.fields;
121
+ const input_fields_keys = Object.keys(input_fields);
122
+ const input_fields_length = input_fields_keys.length;
123
+ for (let i = 0; i < input_fields_length; i++) {
124
+ input_fields_keys[i];
125
+ }
126
+ ObjectFreeze(input_fields);
127
+ ObjectFreeze(input);
128
+ }
129
+ const ingest = function RecordSeoPropertiesRepresentationIngest(input, path, luvio, store, timestamp) {
130
+ if (process.env.NODE_ENV !== 'production') {
131
+ const validateError = validate(input);
132
+ if (validateError !== null) {
133
+ throw validateError;
134
+ }
135
+ }
136
+ const key = path.fullPath;
137
+ const existingRecord = store.readEntry(key);
138
+ const ttlToUse = TTL;
139
+ let incomingRecord = normalize(input, store.readEntry(key), {
140
+ fullPath: key,
141
+ parent: path.parent,
142
+ propertyName: path.propertyName,
143
+ ttl: ttlToUse
144
+ });
145
+ deepFreeze(input);
146
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
147
+ luvio.storePublish(key, incomingRecord);
148
+ }
149
+ {
150
+ const storeMetadataParams = {
151
+ ttl: ttlToUse,
152
+ namespace: "CommunitiesSeo",
153
+ version: VERSION,
154
+ representationName: RepresentationType,
155
+ };
156
+ luvio.publishStoreMetadata(key, storeMetadataParams);
157
+ }
158
+ return createLink(key);
159
+ };
160
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
161
+ const rootKeySet = new StoreKeyMap();
162
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
163
+ const rootKey = fullPathFactory();
164
+ rootKeySet.set(rootKey, {
165
+ namespace: keyPrefix,
166
+ representationName: RepresentationType,
167
+ mergeable: false
168
+ });
169
+ return rootKeySet;
170
170
  }
171
171
 
172
- function select(luvio, params) {
173
- return select$1();
174
- }
175
- function keyBuilder$1(luvio, params) {
176
- return keyPrefix + '::RecordSeoPropertiesRepresentation:(' + 'fields:' + params.queryParams.fields + ',' + 'communityId:' + params.urlParams.communityId + ',' + 'recordId:' + params.urlParams.recordId + ')';
177
- }
178
- function getResponseCacheKeys(luvio, resourceParams, response) {
179
- return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
180
- }
181
- function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
182
- const { body } = response;
183
- const key = keyBuilder$1(luvio, resourceParams);
184
- luvio.storeIngest(key, ingest, body);
185
- const snapshot = luvio.storeLookup({
186
- recordId: key,
187
- node: select(),
188
- variables: {},
189
- }, snapshotRefresh);
190
- if (process.env.NODE_ENV !== 'production') {
191
- if (snapshot.state !== 'Fulfilled') {
192
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
193
- }
194
- }
195
- return snapshot;
196
- }
197
- function ingestError(luvio, params, error, snapshotRefresh) {
198
- const key = keyBuilder$1(luvio, params);
199
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
200
- const storeMetadataParams = {
201
- ttl: TTL,
202
- namespace: keyPrefix,
203
- version: VERSION,
204
- representationName: RepresentationType
205
- };
206
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
207
- return errorSnapshot;
208
- }
209
- function createResourceRequest(config) {
210
- const headers = {};
211
- return {
212
- baseUri: '/services/data/v58.0',
213
- basePath: '/connect/communities/' + config.urlParams.communityId + '/seo/properties/' + config.urlParams.recordId + '',
214
- method: 'get',
215
- body: null,
216
- urlParams: config.urlParams,
217
- queryParams: config.queryParams,
218
- headers,
219
- priority: 'normal',
220
- };
172
+ function select(luvio, params) {
173
+ return select$1();
174
+ }
175
+ function keyBuilder$1(luvio, params) {
176
+ return keyPrefix + '::RecordSeoPropertiesRepresentation:(' + 'fields:' + params.queryParams.fields + ',' + 'communityId:' + params.urlParams.communityId + ',' + 'recordId:' + params.urlParams.recordId + ')';
177
+ }
178
+ function getResponseCacheKeys(luvio, resourceParams, response) {
179
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
180
+ }
181
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
182
+ const { body } = response;
183
+ const key = keyBuilder$1(luvio, resourceParams);
184
+ luvio.storeIngest(key, ingest, body);
185
+ const snapshot = luvio.storeLookup({
186
+ recordId: key,
187
+ node: select(),
188
+ variables: {},
189
+ }, snapshotRefresh);
190
+ if (process.env.NODE_ENV !== 'production') {
191
+ if (snapshot.state !== 'Fulfilled') {
192
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
193
+ }
194
+ }
195
+ return snapshot;
196
+ }
197
+ function ingestError(luvio, params, error, snapshotRefresh) {
198
+ const key = keyBuilder$1(luvio, params);
199
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
200
+ const storeMetadataParams = {
201
+ ttl: TTL,
202
+ namespace: keyPrefix,
203
+ version: VERSION,
204
+ representationName: RepresentationType
205
+ };
206
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
207
+ return errorSnapshot;
208
+ }
209
+ function createResourceRequest(config) {
210
+ const headers = {};
211
+ return {
212
+ baseUri: '/services/data/v58.0',
213
+ basePath: '/connect/communities/' + config.urlParams.communityId + '/seo/properties/' + config.urlParams.recordId + '',
214
+ method: 'get',
215
+ body: null,
216
+ urlParams: config.urlParams,
217
+ queryParams: config.queryParams,
218
+ headers,
219
+ priority: 'normal',
220
+ };
221
221
  }
222
222
 
223
- const getRecordSeoProperties_ConfigPropertyNames = {
224
- displayName: 'getRecordSeoProperties',
225
- parameters: {
226
- required: ['communityId', 'recordId'],
227
- optional: ['fields']
228
- }
229
- };
230
- function createResourceParams(config) {
231
- const resourceParams = {
232
- urlParams: {
233
- communityId: config.communityId, recordId: config.recordId
234
- },
235
- queryParams: {
236
- fields: config.fields
237
- }
238
- };
239
- return resourceParams;
240
- }
241
- function keyBuilder(luvio, config) {
242
- const resourceParams = createResourceParams(config);
243
- return keyBuilder$1(luvio, resourceParams);
244
- }
245
- function typeCheckConfig(untrustedConfig) {
246
- const config = {};
247
- const untrustedConfig_communityId = untrustedConfig.communityId;
248
- if (typeof untrustedConfig_communityId === 'string') {
249
- config.communityId = untrustedConfig_communityId;
250
- }
251
- const untrustedConfig_recordId = untrustedConfig.recordId;
252
- if (typeof untrustedConfig_recordId === 'string') {
253
- config.recordId = untrustedConfig_recordId;
254
- }
255
- const untrustedConfig_fields = untrustedConfig.fields;
256
- if (typeof untrustedConfig_fields === 'string') {
257
- config.fields = untrustedConfig_fields;
258
- }
259
- return config;
260
- }
261
- function validateAdapterConfig(untrustedConfig, configPropertyNames) {
262
- if (!untrustedIsObject(untrustedConfig)) {
263
- return null;
264
- }
265
- if (process.env.NODE_ENV !== 'production') {
266
- validateConfig(untrustedConfig, configPropertyNames);
267
- }
268
- const config = typeCheckConfig(untrustedConfig);
269
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
270
- return null;
271
- }
272
- return config;
273
- }
274
- function adapterFragment(luvio, config) {
275
- createResourceParams(config);
276
- return select();
277
- }
278
- function onFetchResponseSuccess(luvio, config, resourceParams, response) {
279
- const snapshot = ingestSuccess(luvio, resourceParams, response, {
280
- config,
281
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
282
- });
283
- return luvio.storeBroadcast().then(() => snapshot);
284
- }
285
- function onFetchResponseError(luvio, config, resourceParams, response) {
286
- const snapshot = ingestError(luvio, resourceParams, response, {
287
- config,
288
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
289
- });
290
- return luvio.storeBroadcast().then(() => snapshot);
291
- }
292
- function buildNetworkSnapshot(luvio, config, options) {
293
- const resourceParams = createResourceParams(config);
294
- const request = createResourceRequest(resourceParams);
295
- return luvio.dispatchResourceRequest(request, options)
296
- .then((response) => {
297
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
298
- }, (response) => {
299
- return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
300
- });
301
- }
302
- function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
303
- const { luvio, config } = context;
304
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
305
- const dispatchOptions = {
306
- resourceRequestContext: {
307
- requestCorrelator,
308
- luvioRequestMethod: undefined,
309
- },
310
- eventObservers
311
- };
312
- if (networkPriority !== 'normal') {
313
- dispatchOptions.overrides = {
314
- priority: networkPriority
315
- };
316
- }
317
- return buildNetworkSnapshot(luvio, config, dispatchOptions);
318
- }
319
- function buildCachedSnapshotCachePolicy(context, storeLookup) {
320
- const { luvio, config } = context;
321
- const selector = {
322
- recordId: keyBuilder(luvio, config),
323
- node: adapterFragment(luvio, config),
324
- variables: {},
325
- };
326
- const cacheSnapshot = storeLookup(selector, {
327
- config,
328
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
329
- });
330
- return cacheSnapshot;
331
- }
332
- const getRecordSeoPropertiesAdapterFactory = (luvio) => function CommunitiesSeo__getRecordSeoProperties(untrustedConfig, requestContext) {
333
- const config = validateAdapterConfig(untrustedConfig, getRecordSeoProperties_ConfigPropertyNames);
334
- // Invalid or incomplete config
335
- if (config === null) {
336
- return null;
337
- }
338
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
339
- buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
223
+ const getRecordSeoProperties_ConfigPropertyNames = {
224
+ displayName: 'getRecordSeoProperties',
225
+ parameters: {
226
+ required: ['communityId', 'recordId'],
227
+ optional: ['fields']
228
+ }
229
+ };
230
+ function createResourceParams(config) {
231
+ const resourceParams = {
232
+ urlParams: {
233
+ communityId: config.communityId, recordId: config.recordId
234
+ },
235
+ queryParams: {
236
+ fields: config.fields
237
+ }
238
+ };
239
+ return resourceParams;
240
+ }
241
+ function keyBuilder(luvio, config) {
242
+ const resourceParams = createResourceParams(config);
243
+ return keyBuilder$1(luvio, resourceParams);
244
+ }
245
+ function typeCheckConfig(untrustedConfig) {
246
+ const config = {};
247
+ const untrustedConfig_communityId = untrustedConfig.communityId;
248
+ if (typeof untrustedConfig_communityId === 'string') {
249
+ config.communityId = untrustedConfig_communityId;
250
+ }
251
+ const untrustedConfig_recordId = untrustedConfig.recordId;
252
+ if (typeof untrustedConfig_recordId === 'string') {
253
+ config.recordId = untrustedConfig_recordId;
254
+ }
255
+ const untrustedConfig_fields = untrustedConfig.fields;
256
+ if (typeof untrustedConfig_fields === 'string') {
257
+ config.fields = untrustedConfig_fields;
258
+ }
259
+ return config;
260
+ }
261
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
262
+ if (!untrustedIsObject(untrustedConfig)) {
263
+ return null;
264
+ }
265
+ if (process.env.NODE_ENV !== 'production') {
266
+ validateConfig(untrustedConfig, configPropertyNames);
267
+ }
268
+ const config = typeCheckConfig(untrustedConfig);
269
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
270
+ return null;
271
+ }
272
+ return config;
273
+ }
274
+ function adapterFragment(luvio, config) {
275
+ createResourceParams(config);
276
+ return select();
277
+ }
278
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
279
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
280
+ config,
281
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
282
+ });
283
+ return luvio.storeBroadcast().then(() => snapshot);
284
+ }
285
+ function onFetchResponseError(luvio, config, resourceParams, response) {
286
+ const snapshot = ingestError(luvio, resourceParams, response, {
287
+ config,
288
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
289
+ });
290
+ return luvio.storeBroadcast().then(() => snapshot);
291
+ }
292
+ function buildNetworkSnapshot(luvio, config, options) {
293
+ const resourceParams = createResourceParams(config);
294
+ const request = createResourceRequest(resourceParams);
295
+ return luvio.dispatchResourceRequest(request, options)
296
+ .then((response) => {
297
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
298
+ }, (response) => {
299
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
300
+ });
301
+ }
302
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
303
+ const { luvio, config } = context;
304
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
305
+ const dispatchOptions = {
306
+ resourceRequestContext: {
307
+ requestCorrelator,
308
+ luvioRequestMethod: undefined,
309
+ },
310
+ eventObservers
311
+ };
312
+ if (networkPriority !== 'normal') {
313
+ dispatchOptions.overrides = {
314
+ priority: networkPriority
315
+ };
316
+ }
317
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
318
+ }
319
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
320
+ const { luvio, config } = context;
321
+ const selector = {
322
+ recordId: keyBuilder(luvio, config),
323
+ node: adapterFragment(luvio, config),
324
+ variables: {},
325
+ };
326
+ const cacheSnapshot = storeLookup(selector, {
327
+ config,
328
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
329
+ });
330
+ return cacheSnapshot;
331
+ }
332
+ const getRecordSeoPropertiesAdapterFactory = (luvio) => function CommunitiesSeo__getRecordSeoProperties(untrustedConfig, requestContext) {
333
+ const config = validateAdapterConfig(untrustedConfig, getRecordSeoProperties_ConfigPropertyNames);
334
+ // Invalid or incomplete config
335
+ if (config === null) {
336
+ return null;
337
+ }
338
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
339
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
340
340
  };
341
341
 
342
342
  export { getRecordSeoPropertiesAdapterFactory };