@salesforce/lds-adapters-community-navigation-menu 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,24 @@
1
+ import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, FetchResponse as $64$luvio_engine_FetchResponse, SnapshotRefresh as $64$luvio_engine_SnapshotRefresh, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ErrorResponse as $64$luvio_engine_ErrorResponse, ErrorSnapshot as $64$luvio_engine_ErrorSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
2
+ import { NavigationMenuItemCollectionRepresentation as types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation } from '../types/NavigationMenuItemCollectionRepresentation';
3
+ export interface ResourceRequestConfig {
4
+ urlParams: {
5
+ communityId: string;
6
+ };
7
+ queryParams: {
8
+ addHomeMenuItem?: boolean;
9
+ effectiveAccountId?: string;
10
+ includeImageUrl?: boolean;
11
+ menuItemTypesToSkip?: Array<string>;
12
+ navigationLinkSetDeveloperName?: string;
13
+ navigationLinkSetId?: string;
14
+ publishStatus?: string;
15
+ };
16
+ }
17
+ export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
18
+ export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): string;
19
+ export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_NormalizedKeyMetadata;
20
+ export declare function getResponseCacheKeys(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation): $64$luvio_engine_DurableStoreKeyMetadataMap;
21
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation>, snapshotRefresh?: $64$luvio_engine_SnapshotRefresh<types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation, any>;
22
+ export declare function ingestError(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig, error: $64$luvio_engine_ErrorResponse, snapshotRefresh?: $64$luvio_engine_SnapshotRefresh<types_NavigationMenuItemCollectionRepresentation_NavigationMenuItemCollectionRepresentation>): $64$luvio_engine_ErrorSnapshot;
23
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
24
+ export default createResourceRequest;
@@ -0,0 +1,30 @@
1
+ import { NavigationMenuItemRepresentation as NavigationMenuItemRepresentation_NavigationMenuItemRepresentation } from './NavigationMenuItemRepresentation';
2
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, BaseFragment as $64$luvio_engine_BaseFragment, ResourceIngest as $64$luvio_engine_ResourceIngest, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
3
+ export declare const VERSION = "2c44fa1cf5686d4e00960baa7b9e6a1f";
4
+ export declare function validate(obj: any, path?: string): TypeError | null;
5
+ export declare const RepresentationType: string;
6
+ export declare function normalize(input: NavigationMenuItemCollectionRepresentation, existing: NavigationMenuItemCollectionRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): NavigationMenuItemCollectionRepresentationNormalized;
7
+ export declare const select: () => $64$luvio_engine_BaseFragment;
8
+ export declare function equals(existing: NavigationMenuItemCollectionRepresentationNormalized, incoming: NavigationMenuItemCollectionRepresentationNormalized): boolean;
9
+ export declare function deepFreeze(input: NavigationMenuItemCollectionRepresentation): void;
10
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
11
+ export declare function getTypeCacheKeys(luvio: $64$luvio_engine_Luvio, input: NavigationMenuItemCollectionRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): $64$luvio_engine_DurableStoreKeyMetadataMap;
12
+ /**
13
+ * Navigation Menu Item Collection
14
+ *
15
+ * Keys:
16
+ * (none)
17
+ */
18
+ export interface NavigationMenuItemCollectionRepresentationNormalized {
19
+ /** Returns list of Navigation menu Items */
20
+ menuItems: Array<NavigationMenuItemRepresentation_NavigationMenuItemRepresentation>;
21
+ }
22
+ /**
23
+ * Navigation Menu Item Collection
24
+ *
25
+ * Keys:
26
+ * (none)
27
+ */
28
+ export interface NavigationMenuItemCollectionRepresentation {
29
+ menuItems: Array<NavigationMenuItemRepresentation_NavigationMenuItemRepresentation>;
30
+ }
@@ -0,0 +1,44 @@
1
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
2
+ export declare const VERSION = "c33a98f8fe0360b99068afa4c494647a";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: NavigationMenuItemRepresentation, existing: NavigationMenuItemRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): NavigationMenuItemRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: NavigationMenuItemRepresentationNormalized, incoming: NavigationMenuItemRepresentationNormalized): boolean;
8
+ export declare function deepFreeze(input: NavigationMenuItemRepresentation): void;
9
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
10
+ export declare function getTypeCacheKeys(luvio: $64$luvio_engine_Luvio, input: NavigationMenuItemRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): $64$luvio_engine_DurableStoreKeyMetadataMap;
11
+ /**
12
+ * Navigation Menu Item Representation
13
+ *
14
+ * Keys:
15
+ * (none)
16
+ */
17
+ export interface NavigationMenuItemRepresentationNormalized {
18
+ /** Returns the url type or Event of Navigation Menu Item */
19
+ actionType: string;
20
+ /** Returns the route url or event fqn for Navigation Menu item */
21
+ actionValue: string | null;
22
+ /** Returns the image url for Navigation Menu item */
23
+ imageUrl: string | null;
24
+ /** Returns the label for Navigation Menu item */
25
+ label: string;
26
+ /** Returns the sub-menu for Navigation Menu Item */
27
+ subMenu: Array<NavigationMenuItemRepresentation>;
28
+ /** Returns the target SameWindow/NewWindow for Navigation Menu item */
29
+ target: string;
30
+ }
31
+ /**
32
+ * Navigation Menu Item Representation
33
+ *
34
+ * Keys:
35
+ * (none)
36
+ */
37
+ export interface NavigationMenuItemRepresentation {
38
+ actionType: string;
39
+ actionValue: string | null;
40
+ imageUrl: string | null;
41
+ label: string;
42
+ subMenu: Array<NavigationMenuItemRepresentation>;
43
+ target: string;
44
+ }
@@ -0,0 +1,39 @@
1
+ import { NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const ObjectFreeze: {
3
+ <T extends Function>(f: T): T;
4
+ <T_1 extends {
5
+ [idx: string]: object | U | null | undefined;
6
+ }, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>;
7
+ <T_2>(o: T_2): Readonly<T_2>;
8
+ }, ObjectKeys: {
9
+ (o: object): string[];
10
+ (o: {}): string[];
11
+ }, ObjectCreate: {
12
+ (o: object | null): any;
13
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
14
+ }, ObjectAssign: {
15
+ <T extends {}, U>(target: T, source: U): T & U;
16
+ <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
17
+ <T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
18
+ (target: object, ...sources: any[]): any;
19
+ };
20
+ export declare const ArrayIsArray: (arg: any) => arg is any[];
21
+ export declare const JSONStringify: {
22
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
23
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
24
+ };
25
+ type AllowedPrimitives = boolean | string | number | Date | null;
26
+ type Value<T> = T extends AllowedPrimitives ? T : RecursivePartial<T>;
27
+ export type RecursivePartial<T> = null | {
28
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<Value<U>> | null : Value<T[P]> | null;
29
+ };
30
+ export declare function equalsArray<U, V extends U[]>(a: V, b: V, equalsItem: (itemA: U, itemB: U) => boolean | void): boolean;
31
+ export declare function equalsObject<U, V extends {
32
+ [key: string]: U;
33
+ }>(a: V, b: V, equalsProp: (propA: U, propB: U) => boolean | void): boolean;
34
+ export declare function deepFreeze(value: any): void;
35
+ export declare function createLink(ref: string | $64$luvio_engine_NormalizedKeyMetadata): {
36
+ __ref: string;
37
+ };
38
+ export declare function assignMetadataLink(entry: any, metadataKey: string | $64$luvio_engine_NormalizedKeyMetadata): void;
39
+ export {};
@@ -0,0 +1,455 @@
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.communityNavigationService = {}, 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 = 'CommunityNavigation';
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
+ function validate$1(obj, path = 'NavigationMenuItemRepresentation') {
67
+ const v_error = (() => {
68
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
69
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
70
+ }
71
+ const obj_actionType = obj.actionType;
72
+ const path_actionType = path + '.actionType';
73
+ if (typeof obj_actionType !== 'string') {
74
+ return new TypeError('Expected "string" but received "' + typeof obj_actionType + '" (at "' + path_actionType + '")');
75
+ }
76
+ const obj_actionValue = obj.actionValue;
77
+ const path_actionValue = path + '.actionValue';
78
+ let obj_actionValue_union0 = null;
79
+ const obj_actionValue_union0_error = (() => {
80
+ if (typeof obj_actionValue !== 'string') {
81
+ return new TypeError('Expected "string" but received "' + typeof obj_actionValue + '" (at "' + path_actionValue + '")');
82
+ }
83
+ })();
84
+ if (obj_actionValue_union0_error != null) {
85
+ obj_actionValue_union0 = obj_actionValue_union0_error.message;
86
+ }
87
+ let obj_actionValue_union1 = null;
88
+ const obj_actionValue_union1_error = (() => {
89
+ if (obj_actionValue !== null) {
90
+ return new TypeError('Expected "null" but received "' + typeof obj_actionValue + '" (at "' + path_actionValue + '")');
91
+ }
92
+ })();
93
+ if (obj_actionValue_union1_error != null) {
94
+ obj_actionValue_union1 = obj_actionValue_union1_error.message;
95
+ }
96
+ if (obj_actionValue_union0 && obj_actionValue_union1) {
97
+ let message = 'Object doesn\'t match union (at "' + path_actionValue + '")';
98
+ message += '\n' + obj_actionValue_union0.split('\n').map((line) => '\t' + line).join('\n');
99
+ message += '\n' + obj_actionValue_union1.split('\n').map((line) => '\t' + line).join('\n');
100
+ return new TypeError(message);
101
+ }
102
+ const obj_imageUrl = obj.imageUrl;
103
+ const path_imageUrl = path + '.imageUrl';
104
+ let obj_imageUrl_union0 = null;
105
+ const obj_imageUrl_union0_error = (() => {
106
+ if (typeof obj_imageUrl !== 'string') {
107
+ return new TypeError('Expected "string" but received "' + typeof obj_imageUrl + '" (at "' + path_imageUrl + '")');
108
+ }
109
+ })();
110
+ if (obj_imageUrl_union0_error != null) {
111
+ obj_imageUrl_union0 = obj_imageUrl_union0_error.message;
112
+ }
113
+ let obj_imageUrl_union1 = null;
114
+ const obj_imageUrl_union1_error = (() => {
115
+ if (obj_imageUrl !== null) {
116
+ return new TypeError('Expected "null" but received "' + typeof obj_imageUrl + '" (at "' + path_imageUrl + '")');
117
+ }
118
+ })();
119
+ if (obj_imageUrl_union1_error != null) {
120
+ obj_imageUrl_union1 = obj_imageUrl_union1_error.message;
121
+ }
122
+ if (obj_imageUrl_union0 && obj_imageUrl_union1) {
123
+ let message = 'Object doesn\'t match union (at "' + path_imageUrl + '")';
124
+ message += '\n' + obj_imageUrl_union0.split('\n').map((line) => '\t' + line).join('\n');
125
+ message += '\n' + obj_imageUrl_union1.split('\n').map((line) => '\t' + line).join('\n');
126
+ return new TypeError(message);
127
+ }
128
+ const obj_label = obj.label;
129
+ const path_label = path + '.label';
130
+ if (typeof obj_label !== 'string') {
131
+ return new TypeError('Expected "string" but received "' + typeof obj_label + '" (at "' + path_label + '")');
132
+ }
133
+ const obj_subMenu = obj.subMenu;
134
+ const path_subMenu = path + '.subMenu';
135
+ if (!ArrayIsArray(obj_subMenu)) {
136
+ return new TypeError('Expected "array" but received "' + typeof obj_subMenu + '" (at "' + path_subMenu + '")');
137
+ }
138
+ for (let i = 0; i < obj_subMenu.length; i++) {
139
+ const obj_subMenu_item = obj_subMenu[i];
140
+ const path_subMenu_item = path_subMenu + '[' + i + ']';
141
+ const referencepath_subMenu_itemValidationError = validate$1(obj_subMenu_item, path_subMenu_item);
142
+ if (referencepath_subMenu_itemValidationError !== null) {
143
+ let message = 'Object doesn\'t match NavigationMenuItemRepresentation (at "' + path_subMenu_item + '")\n';
144
+ message += referencepath_subMenu_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
145
+ return new TypeError(message);
146
+ }
147
+ }
148
+ const obj_target = obj.target;
149
+ const path_target = path + '.target';
150
+ if (typeof obj_target !== 'string') {
151
+ return new TypeError('Expected "string" but received "' + typeof obj_target + '" (at "' + path_target + '")');
152
+ }
153
+ })();
154
+ return v_error === undefined ? null : v_error;
155
+ }
156
+ function deepFreeze$1(input) {
157
+ const input_subMenu = input.subMenu;
158
+ for (let i = 0; i < input_subMenu.length; i++) {
159
+ const input_subMenu_item = input_subMenu[i];
160
+ deepFreeze$1(input_subMenu_item);
161
+ }
162
+ ObjectFreeze(input_subMenu);
163
+ ObjectFreeze(input);
164
+ }
165
+
166
+ const VERSION = "2c44fa1cf5686d4e00960baa7b9e6a1f";
167
+ function validate(obj, path = 'NavigationMenuItemCollectionRepresentation') {
168
+ const v_error = (() => {
169
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
170
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
171
+ }
172
+ const obj_menuItems = obj.menuItems;
173
+ const path_menuItems = path + '.menuItems';
174
+ if (!ArrayIsArray(obj_menuItems)) {
175
+ return new TypeError('Expected "array" but received "' + typeof obj_menuItems + '" (at "' + path_menuItems + '")');
176
+ }
177
+ for (let i = 0; i < obj_menuItems.length; i++) {
178
+ const obj_menuItems_item = obj_menuItems[i];
179
+ const path_menuItems_item = path_menuItems + '[' + i + ']';
180
+ const referencepath_menuItems_itemValidationError = validate$1(obj_menuItems_item, path_menuItems_item);
181
+ if (referencepath_menuItems_itemValidationError !== null) {
182
+ let message = 'Object doesn\'t match NavigationMenuItemRepresentation (at "' + path_menuItems_item + '")\n';
183
+ message += referencepath_menuItems_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
184
+ return new TypeError(message);
185
+ }
186
+ }
187
+ })();
188
+ return v_error === undefined ? null : v_error;
189
+ }
190
+ const RepresentationType = 'NavigationMenuItemCollectionRepresentation';
191
+ function normalize(input, existing, path, luvio, store, timestamp) {
192
+ return input;
193
+ }
194
+ const select$1 = function NavigationMenuItemCollectionRepresentationSelect() {
195
+ return {
196
+ kind: 'Fragment',
197
+ version: VERSION,
198
+ private: [],
199
+ opaque: true
200
+ };
201
+ };
202
+ function equals(existing, incoming) {
203
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
204
+ return false;
205
+ }
206
+ return true;
207
+ }
208
+ function deepFreeze(input) {
209
+ const input_menuItems = input.menuItems;
210
+ for (let i = 0; i < input_menuItems.length; i++) {
211
+ const input_menuItems_item = input_menuItems[i];
212
+ deepFreeze$1(input_menuItems_item);
213
+ }
214
+ ObjectFreeze(input_menuItems);
215
+ ObjectFreeze(input);
216
+ }
217
+ const ingest = function NavigationMenuItemCollectionRepresentationIngest(input, path, luvio, store, timestamp) {
218
+ if (process.env.NODE_ENV !== 'production') {
219
+ const validateError = validate(input);
220
+ if (validateError !== null) {
221
+ throw validateError;
222
+ }
223
+ }
224
+ const key = path.fullPath;
225
+ const existingRecord = store.readEntry(key);
226
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
227
+ let incomingRecord = normalize(input, store.readEntry(key), {
228
+ fullPath: key,
229
+ parent: path.parent,
230
+ propertyName: path.propertyName,
231
+ ttl: ttlToUse
232
+ });
233
+ deepFreeze(input);
234
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
235
+ luvio.storePublish(key, incomingRecord);
236
+ }
237
+ if (ttlToUse !== undefined) {
238
+ const storeMetadataParams = {
239
+ ttl: ttlToUse,
240
+ namespace: "CommunityNavigation",
241
+ version: VERSION,
242
+ representationName: RepresentationType,
243
+ };
244
+ luvio.publishStoreMetadata(key, storeMetadataParams);
245
+ }
246
+ return createLink(key);
247
+ };
248
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
249
+ const rootKeySet = new engine.StoreKeyMap();
250
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
251
+ const rootKey = fullPathFactory();
252
+ rootKeySet.set(rootKey, {
253
+ namespace: keyPrefix,
254
+ representationName: RepresentationType,
255
+ mergeable: false
256
+ });
257
+ return rootKeySet;
258
+ }
259
+
260
+ function select(luvio, params) {
261
+ return select$1();
262
+ }
263
+ function keyBuilder$1(luvio, params) {
264
+ return keyPrefix + '::NavigationMenuItemCollectionRepresentation:(' + 'addHomeMenuItem:' + params.queryParams.addHomeMenuItem + ',' + 'effectiveAccountId:' + params.queryParams.effectiveAccountId + ',' + 'includeImageUrl:' + params.queryParams.includeImageUrl + ',' + 'menuItemTypesToSkip:' + params.queryParams.menuItemTypesToSkip + ',' + 'navigationLinkSetDeveloperName:' + params.queryParams.navigationLinkSetDeveloperName + ',' + 'navigationLinkSetId:' + params.queryParams.navigationLinkSetId + ',' + 'publishStatus:' + params.queryParams.publishStatus + ',' + 'communityId:' + params.urlParams.communityId + ')';
265
+ }
266
+ function getResponseCacheKeys(luvio, resourceParams, response) {
267
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
268
+ }
269
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
270
+ const { body } = response;
271
+ const key = keyBuilder$1(luvio, resourceParams);
272
+ luvio.storeIngest(key, ingest, body);
273
+ const snapshot = luvio.storeLookup({
274
+ recordId: key,
275
+ node: select(),
276
+ variables: {},
277
+ }, snapshotRefresh);
278
+ if (process.env.NODE_ENV !== 'production') {
279
+ if (snapshot.state !== 'Fulfilled') {
280
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
281
+ }
282
+ }
283
+ return snapshot;
284
+ }
285
+ function ingestError(luvio, params, error, snapshotRefresh) {
286
+ const key = keyBuilder$1(luvio, params);
287
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
288
+ luvio.storeIngestError(key, errorSnapshot);
289
+ return errorSnapshot;
290
+ }
291
+ function createResourceRequest(config) {
292
+ const headers = {};
293
+ return {
294
+ baseUri: '/services/data/v58.0',
295
+ basePath: '/connect/communities/' + config.urlParams.communityId + '/navigation-menu/navigation-menu-items',
296
+ method: 'get',
297
+ body: null,
298
+ urlParams: config.urlParams,
299
+ queryParams: config.queryParams,
300
+ headers,
301
+ priority: 'normal',
302
+ };
303
+ }
304
+
305
+ const getCommunityNavigationMenu_ConfigPropertyNames = {
306
+ displayName: 'getCommunityNavigationMenu',
307
+ parameters: {
308
+ required: ['communityId'],
309
+ optional: ['addHomeMenuItem', 'effectiveAccountId', 'includeImageUrl', 'menuItemTypesToSkip', 'navigationLinkSetDeveloperName', 'navigationLinkSetId', 'publishStatus']
310
+ }
311
+ };
312
+ function createResourceParams(config) {
313
+ const resourceParams = {
314
+ urlParams: {
315
+ communityId: config.communityId
316
+ },
317
+ queryParams: {
318
+ addHomeMenuItem: config.addHomeMenuItem, effectiveAccountId: config.effectiveAccountId, includeImageUrl: config.includeImageUrl, menuItemTypesToSkip: config.menuItemTypesToSkip, navigationLinkSetDeveloperName: config.navigationLinkSetDeveloperName, navigationLinkSetId: config.navigationLinkSetId, publishStatus: config.publishStatus
319
+ }
320
+ };
321
+ return resourceParams;
322
+ }
323
+ function keyBuilder(luvio, config) {
324
+ const resourceParams = createResourceParams(config);
325
+ return keyBuilder$1(luvio, resourceParams);
326
+ }
327
+ function typeCheckConfig(untrustedConfig) {
328
+ const config = {};
329
+ const untrustedConfig_communityId = untrustedConfig.communityId;
330
+ if (typeof untrustedConfig_communityId === 'string') {
331
+ config.communityId = untrustedConfig_communityId;
332
+ }
333
+ const untrustedConfig_addHomeMenuItem = untrustedConfig.addHomeMenuItem;
334
+ if (typeof untrustedConfig_addHomeMenuItem === 'boolean') {
335
+ config.addHomeMenuItem = untrustedConfig_addHomeMenuItem;
336
+ }
337
+ const untrustedConfig_effectiveAccountId = untrustedConfig.effectiveAccountId;
338
+ if (typeof untrustedConfig_effectiveAccountId === 'string') {
339
+ config.effectiveAccountId = untrustedConfig_effectiveAccountId;
340
+ }
341
+ const untrustedConfig_includeImageUrl = untrustedConfig.includeImageUrl;
342
+ if (typeof untrustedConfig_includeImageUrl === 'boolean') {
343
+ config.includeImageUrl = untrustedConfig_includeImageUrl;
344
+ }
345
+ const untrustedConfig_menuItemTypesToSkip = untrustedConfig.menuItemTypesToSkip;
346
+ if (ArrayIsArray$1(untrustedConfig_menuItemTypesToSkip)) {
347
+ const untrustedConfig_menuItemTypesToSkip_array = [];
348
+ for (let i = 0, arrayLength = untrustedConfig_menuItemTypesToSkip.length; i < arrayLength; i++) {
349
+ const untrustedConfig_menuItemTypesToSkip_item = untrustedConfig_menuItemTypesToSkip[i];
350
+ if (typeof untrustedConfig_menuItemTypesToSkip_item === 'string') {
351
+ untrustedConfig_menuItemTypesToSkip_array.push(untrustedConfig_menuItemTypesToSkip_item);
352
+ }
353
+ }
354
+ config.menuItemTypesToSkip = untrustedConfig_menuItemTypesToSkip_array;
355
+ }
356
+ const untrustedConfig_navigationLinkSetDeveloperName = untrustedConfig.navigationLinkSetDeveloperName;
357
+ if (typeof untrustedConfig_navigationLinkSetDeveloperName === 'string') {
358
+ config.navigationLinkSetDeveloperName = untrustedConfig_navigationLinkSetDeveloperName;
359
+ }
360
+ const untrustedConfig_navigationLinkSetId = untrustedConfig.navigationLinkSetId;
361
+ if (typeof untrustedConfig_navigationLinkSetId === 'string') {
362
+ config.navigationLinkSetId = untrustedConfig_navigationLinkSetId;
363
+ }
364
+ const untrustedConfig_publishStatus = untrustedConfig.publishStatus;
365
+ if (typeof untrustedConfig_publishStatus === 'string') {
366
+ config.publishStatus = untrustedConfig_publishStatus;
367
+ }
368
+ return config;
369
+ }
370
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
371
+ if (!untrustedIsObject(untrustedConfig)) {
372
+ return null;
373
+ }
374
+ if (process.env.NODE_ENV !== 'production') {
375
+ validateConfig(untrustedConfig, configPropertyNames);
376
+ }
377
+ const config = typeCheckConfig(untrustedConfig);
378
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
379
+ return null;
380
+ }
381
+ return config;
382
+ }
383
+ function adapterFragment(luvio, config) {
384
+ createResourceParams(config);
385
+ return select();
386
+ }
387
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
388
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
389
+ config,
390
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
391
+ });
392
+ return luvio.storeBroadcast().then(() => snapshot);
393
+ }
394
+ function onFetchResponseError(luvio, config, resourceParams, response) {
395
+ const snapshot = ingestError(luvio, resourceParams, response, {
396
+ config,
397
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
398
+ });
399
+ return luvio.storeBroadcast().then(() => snapshot);
400
+ }
401
+ function buildNetworkSnapshot(luvio, config, options) {
402
+ const resourceParams = createResourceParams(config);
403
+ const request = createResourceRequest(resourceParams);
404
+ return luvio.dispatchResourceRequest(request, options)
405
+ .then((response) => {
406
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
407
+ }, (response) => {
408
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
409
+ });
410
+ }
411
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
412
+ const { luvio, config } = context;
413
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
414
+ const dispatchOptions = {
415
+ resourceRequestContext: {
416
+ requestCorrelator,
417
+ luvioRequestMethod: undefined,
418
+ },
419
+ eventObservers
420
+ };
421
+ if (networkPriority !== 'normal') {
422
+ dispatchOptions.overrides = {
423
+ priority: networkPriority
424
+ };
425
+ }
426
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
427
+ }
428
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
429
+ const { luvio, config } = context;
430
+ const selector = {
431
+ recordId: keyBuilder(luvio, config),
432
+ node: adapterFragment(luvio, config),
433
+ variables: {},
434
+ };
435
+ const cacheSnapshot = storeLookup(selector, {
436
+ config,
437
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
438
+ });
439
+ return cacheSnapshot;
440
+ }
441
+ const getCommunityNavigationMenuAdapterFactory = (luvio) => function CommunityNavigation__getCommunityNavigationMenu(untrustedConfig, requestContext) {
442
+ const config = validateAdapterConfig(untrustedConfig, getCommunityNavigationMenu_ConfigPropertyNames);
443
+ // Invalid or incomplete config
444
+ if (config === null) {
445
+ return null;
446
+ }
447
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
448
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
449
+ };
450
+
451
+ exports.getCommunityNavigationMenuAdapterFactory = getCommunityNavigationMenuAdapterFactory;
452
+
453
+ Object.defineProperty(exports, '__esModule', { value: true });
454
+
455
+ }));