@salesforce/lds-adapters-cms-delivery 0.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/cms-delivery.js +2501 -0
  3. package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +66 -0
  4. package/dist/es/es2018/types/src/generated/adapters/getCollectionItemsForChannel.d.ts +28 -0
  5. package/dist/es/es2018/types/src/generated/adapters/getCollectionItemsForSite.d.ts +28 -0
  6. package/dist/es/es2018/types/src/generated/adapters/getCollectionMetadataForChannel.d.ts +29 -0
  7. package/dist/es/es2018/types/src/generated/adapters/getCollectionMetadataForSite.d.ts +29 -0
  8. package/dist/es/es2018/types/src/generated/adapters/listContent.d.ts +34 -0
  9. package/dist/es/es2018/types/src/generated/adapters/listContentInternal.d.ts +36 -0
  10. package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +6 -0
  11. package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +13 -0
  12. package/dist/es/es2018/types/src/generated/resources/deleteConnectCmsContentJobsByJobId.d.ts +11 -0
  13. package/dist/es/es2018/types/src/generated/resources/deleteConnectManagedContentContentSpacesContentsByContentSpaceIdAndManagedContentId.d.ts +10 -0
  14. package/dist/es/es2018/types/src/generated/resources/deleteConnectManagedContentContentSpacesMembersByContentSpaceIdAndMemberIdOrMe.d.ts +10 -0
  15. package/dist/es/es2018/types/src/generated/resources/getConnectCmsChannelsSearchableContentTypesByChannelId.d.ts +19 -0
  16. package/dist/es/es2018/types/src/generated/resources/getConnectCmsContent.d.ts +16 -0
  17. package/dist/es/es2018/types/src/generated/resources/getConnectCmsContentJobsByJobId.d.ts +15 -0
  18. package/dist/es/es2018/types/src/generated/resources/getConnectCmsContentVersionByManagedContentVersionId.d.ts +19 -0
  19. package/dist/es/es2018/types/src/generated/resources/getConnectCmsDeliveryChannelsCollectionsByChannelIdAndCollectionKeyOrId.d.ts +19 -0
  20. package/dist/es/es2018/types/src/generated/resources/getConnectCmsDeliveryChannelsCollectionsMetadataByChannelIdAndCollectionKeyOrId.d.ts +20 -0
  21. package/dist/es/es2018/types/src/generated/resources/getConnectCmsDeliveryChannelsContentsQueryByChannelId.d.ts +27 -0
  22. package/dist/es/es2018/types/src/generated/resources/getConnectCmsDeliveryChannelsContentsSearchByChannelId.d.ts +21 -0
  23. package/dist/es/es2018/types/src/generated/resources/getConnectCmsDeliveryChannelsMediaContentByChannelIdAndMediaGuid.d.ts +16 -0
  24. package/dist/es/es2018/types/src/generated/resources/getConnectCmsDeliveryRecordsContentsByRecordId.d.ts +22 -0
  25. package/dist/es/es2018/types/src/generated/resources/getConnectCmsFoldersByFolderId.d.ts +15 -0
  26. package/dist/es/es2018/types/src/generated/resources/getConnectCmsFoldersItemsByFolderId.d.ts +25 -0
  27. package/dist/es/es2018/types/src/generated/resources/getConnectCmsSpacesByContentSpaceId.d.ts +15 -0
  28. package/dist/es/es2018/types/src/generated/resources/getConnectCommunitiesManagedContentDeliveryByCommunityId.d.ts +25 -0
  29. package/dist/es/es2018/types/src/generated/resources/getConnectCommunitiesManagedContentDeliveryContentsByCommunityId.d.ts +27 -0
  30. package/dist/es/es2018/types/src/generated/resources/getConnectCommunitiesManagedContentDeliveryContentsByCommunityIdAndManagedContentId.d.ts +16 -0
  31. package/dist/es/es2018/types/src/generated/resources/getConnectCommunitiesManagedContentDeliveryContentsSearchByCommunityId.d.ts +21 -0
  32. package/dist/es/es2018/types/src/generated/resources/getConnectManagedContentContentSpacesContentVersionsByContentSpaceIdAndManagedContentVersionId.d.ts +19 -0
  33. package/dist/es/es2018/types/src/generated/resources/getConnectManagedContentContentSpacesMembersByContentSpaceId.d.ts +15 -0
  34. package/dist/es/es2018/types/src/generated/resources/getConnectManagedContentContentSpacesMembersPermissionsByContentSpaceIdAndMemberIdOrMe.d.ts +16 -0
  35. package/dist/es/es2018/types/src/generated/resources/getConnectManagedContentDeliveryContentsByManagedContentId.d.ts +15 -0
  36. package/dist/es/es2018/types/src/generated/resources/getConnectManagedContentRoles.d.ts +15 -0
  37. package/dist/es/es2018/types/src/generated/resources/getConnectSitesCmsDeliveryCollectionsByCollectionKeyOrIdAndSiteId.d.ts +19 -0
  38. package/dist/es/es2018/types/src/generated/resources/getConnectSitesCmsDeliveryCollectionsMetadataByCollectionKeyOrIdAndSiteId.d.ts +20 -0
  39. package/dist/es/es2018/types/src/generated/resources/patchConnectCmsChannelsSearchableContentTypesByChannelId.d.ts +13 -0
  40. package/dist/es/es2018/types/src/generated/resources/patchConnectCmsContentVersionByManagedContentVersionId.d.ts +21 -0
  41. package/dist/es/es2018/types/src/generated/resources/patchConnectCmsFoldersItemsByFolderId.d.ts +13 -0
  42. package/dist/es/es2018/types/src/generated/resources/patchConnectManagedContentContentSpacesContentVersionsByContentSpaceIdAndManagedContentVersionId.d.ts +21 -0
  43. package/dist/es/es2018/types/src/generated/resources/patchConnectManagedContentContentSpacesContentsByContentSpaceIdAndManagedContentId.d.ts +13 -0
  44. package/dist/es/es2018/types/src/generated/resources/patchConnectManagedContentContentSpacesMembersByContentSpaceIdAndMemberIdOrMe.d.ts +14 -0
  45. package/dist/es/es2018/types/src/generated/resources/postConnectCmsContentJobsImport.d.ts +14 -0
  46. package/dist/es/es2018/types/src/generated/resources/postConnectCmsContentVariant.d.ts +18 -0
  47. package/dist/es/es2018/types/src/generated/resources/postConnectCmsContentVersion.d.ts +21 -0
  48. package/dist/es/es2018/types/src/generated/resources/postConnectCmsContentVersions.d.ts +12 -0
  49. package/dist/es/es2018/types/src/generated/resources/postConnectManagedContentContentSpacesContentVersionsByContentSpaceId.d.ts +23 -0
  50. package/dist/es/es2018/types/src/generated/resources/postConnectManagedContentContentSpacesMembersByContentSpaceId.d.ts +16 -0
  51. package/dist/es/es2018/types/src/generated/resources/postConnectManagedContentTranslation.d.ts +15 -0
  52. package/dist/es/es2018/types/src/generated/resources/putConnectCmsContentVersionByManagedContentVersionId.d.ts +21 -0
  53. package/dist/es/es2018/types/src/generated/types/AbstractMCSFolderRepresentation.d.ts +41 -0
  54. package/dist/es/es2018/types/src/generated/types/ManagedContentAssociationsInputRep.d.ts +33 -0
  55. package/dist/es/es2018/types/src/generated/types/ManagedContentAssociationsRepresentation.d.ts +30 -0
  56. package/dist/es/es2018/types/src/generated/types/ManagedContentBodyInputRep.d.ts +33 -0
  57. package/dist/es/es2018/types/src/generated/types/ManagedContentChannelSummaryRepresentation.d.ts +38 -0
  58. package/dist/es/es2018/types/src/generated/types/ManagedContentChannelTargetSummaryRepresentation.d.ts +29 -0
  59. package/dist/es/es2018/types/src/generated/types/ManagedContentCollectionItemRepresentation.d.ts +42 -0
  60. package/dist/es/es2018/types/src/generated/types/ManagedContentCollectionItemTypeSummaryRepresentation.d.ts +32 -0
  61. package/dist/es/es2018/types/src/generated/types/ManagedContentCollectionItemsRepresentation.d.ts +59 -0
  62. package/dist/es/es2018/types/src/generated/types/ManagedContentCollectionMetadataRepresentation.d.ts +66 -0
  63. package/dist/es/es2018/types/src/generated/types/ManagedContentCollectionRepresentation.d.ts +30 -0
  64. package/dist/es/es2018/types/src/generated/types/ManagedContentDateAndTimeNodeValueRepresentation.d.ts +34 -0
  65. package/dist/es/es2018/types/src/generated/types/ManagedContentDateNodeValueRepresentation.d.ts +31 -0
  66. package/dist/es/es2018/types/src/generated/types/ManagedContentDetailCollectionRepresentation.d.ts +33 -0
  67. package/dist/es/es2018/types/src/generated/types/ManagedContentDetailRepresentation.d.ts +38 -0
  68. package/dist/es/es2018/types/src/generated/types/ManagedContentInputRep.d.ts +29 -0
  69. package/dist/es/es2018/types/src/generated/types/ManagedContentJobRepresentation.d.ts +65 -0
  70. package/dist/es/es2018/types/src/generated/types/ManagedContentJobRequestInputRepresentation.d.ts +35 -0
  71. package/dist/es/es2018/types/src/generated/types/ManagedContentMediaNodeValueRepresentation.d.ts +57 -0
  72. package/dist/es/es2018/types/src/generated/types/ManagedContentMediaSourceNodeValueRepresentation.d.ts +51 -0
  73. package/dist/es/es2018/types/src/generated/types/ManagedContentNodeTypeRepresentation.d.ts +35 -0
  74. package/dist/es/es2018/types/src/generated/types/ManagedContentNodeValueRepresentation.d.ts +35 -0
  75. package/dist/es/es2018/types/src/generated/types/ManagedContentRepresentation.d.ts +35 -0
  76. package/dist/es/es2018/types/src/generated/types/ManagedContentSearchResultCollectionRepresentation.d.ts +39 -0
  77. package/dist/es/es2018/types/src/generated/types/ManagedContentSearchResultContentTypeRepresentation.d.ts +32 -0
  78. package/dist/es/es2018/types/src/generated/types/ManagedContentSearchResultRepresentation.d.ts +45 -0
  79. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceFolderDetailRepresentation.d.ts +44 -0
  80. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceFolderItemCollectionInputRep.d.ts +32 -0
  81. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceFolderItemCollectionRepresentation.d.ts +36 -0
  82. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceFolderItemRepresentation.d.ts +62 -0
  83. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceFolderRepresentation.d.ts +27 -0
  84. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceMemberCollectionRepresentation.d.ts +30 -0
  85. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceMemberInputRepresentation.d.ts +32 -0
  86. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceMemberPermissionsRepresentation.d.ts +38 -0
  87. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceMemberRepresentation.d.ts +35 -0
  88. package/dist/es/es2018/types/src/generated/types/ManagedContentSpacePermissionRepresentation.d.ts +47 -0
  89. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceRepresentation.d.ts +56 -0
  90. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceRoleCollectionRepresentation.d.ts +30 -0
  91. package/dist/es/es2018/types/src/generated/types/ManagedContentSpaceRoleRepresentation.d.ts +35 -0
  92. package/dist/es/es2018/types/src/generated/types/ManagedContentTextNodeValueRepresentation.d.ts +31 -0
  93. package/dist/es/es2018/types/src/generated/types/ManagedContentTranslationRepresentation.d.ts +65 -0
  94. package/dist/es/es2018/types/src/generated/types/ManagedContentTranslationRequestInputRep.d.ts +38 -0
  95. package/dist/es/es2018/types/src/generated/types/ManagedContentTypeRepresentation.d.ts +40 -0
  96. package/dist/es/es2018/types/src/generated/types/ManagedContentTypeSearchableCollectionRepresentation.d.ts +39 -0
  97. package/dist/es/es2018/types/src/generated/types/ManagedContentTypeSearchableInputRepresentation.d.ts +32 -0
  98. package/dist/es/es2018/types/src/generated/types/ManagedContentTypeSearchableRepresentation.d.ts +38 -0
  99. package/dist/es/es2018/types/src/generated/types/ManagedContentTypeSummaryRepresentation.d.ts +32 -0
  100. package/dist/es/es2018/types/src/generated/types/ManagedContentVariantInputRep.d.ts +47 -0
  101. package/dist/es/es2018/types/src/generated/types/ManagedContentVariantRepresentation.d.ts +50 -0
  102. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionCollectionRepresentation.d.ts +51 -0
  103. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionInputRep.d.ts +51 -0
  104. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionInternalCollectionRepresentation.d.ts +42 -0
  105. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionInternalRepresentation.d.ts +82 -0
  106. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionRepresentation.d.ts +67 -0
  107. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionV2CollectionInputRepresentation.d.ts +29 -0
  108. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionV2CollectionRepresentation.d.ts +33 -0
  109. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionV2InputRepresentation.d.ts +54 -0
  110. package/dist/es/es2018/types/src/generated/types/ManagedContentVersionV2Representation.d.ts +72 -0
  111. package/dist/es/es2018/types/src/generated/types/ReferenceRepresentation.d.ts +32 -0
  112. package/dist/es/es2018/types/src/generated/types/StreamedRepresentation.d.ts +26 -0
  113. package/dist/es/es2018/types/src/generated/types/TopicSummaryRepresentation.d.ts +32 -0
  114. package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +39 -0
  115. package/dist/es/es2018/types/src/raml-artifacts/adapters/getCollectionItemsForChannel/onFetchResponseSuccess.d.ts +5 -0
  116. package/dist/es/es2018/types/src/raml-artifacts/adapters/getCollectionItemsForSite/onFetchResponseSuccess.d.ts +5 -0
  117. package/dist/es/es2018/types/src/raml-artifacts/adapters/getCollectionMetadataForChannel/onFetchResponseSuccess.d.ts +5 -0
  118. package/dist/es/es2018/types/src/raml-artifacts/adapters/getCollectionMetadataForSite/onFetchResponseSuccess.d.ts +5 -0
  119. package/package.json +54 -0
  120. package/sfdc/index.d.ts +1 -0
  121. package/sfdc/index.js +2573 -0
  122. package/src/raml/api.raml +2091 -0
  123. package/src/raml/luvio.raml +47 -0
@@ -0,0 +1,2501 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
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
+ };
51
+ const keyPrefix = 'CMS';
52
+
53
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
54
+ const { isArray: ArrayIsArray } = Array;
55
+ const { stringify: JSONStringify } = JSON;
56
+ function equalsArray(a, b, equalsItem) {
57
+ const aLength = a.length;
58
+ const bLength = b.length;
59
+ if (aLength !== bLength) {
60
+ return false;
61
+ }
62
+ for (let i = 0; i < aLength; i++) {
63
+ if (equalsItem(a[i], b[i]) === false) {
64
+ return false;
65
+ }
66
+ }
67
+ return true;
68
+ }
69
+ function deepFreeze$g(value) {
70
+ // No need to freeze primitives
71
+ if (typeof value !== 'object' || value === null) {
72
+ return;
73
+ }
74
+ if (ArrayIsArray(value)) {
75
+ for (let i = 0, len = value.length; i < len; i += 1) {
76
+ deepFreeze$g(value[i]);
77
+ }
78
+ }
79
+ else {
80
+ const keys = ObjectKeys(value);
81
+ for (let i = 0, len = keys.length; i < len; i += 1) {
82
+ deepFreeze$g(value[keys[i]]);
83
+ }
84
+ }
85
+ ObjectFreeze(value);
86
+ }
87
+ function createLink(ref) {
88
+ return {
89
+ __ref: serializeStructuredKey(ref),
90
+ };
91
+ }
92
+
93
+ function validate$g(obj, path = 'ManagedContentChannelTargetSummaryRepresentation') {
94
+ const v_error = (() => {
95
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
96
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
97
+ }
98
+ const obj_id = obj.id;
99
+ const path_id = path + '.id';
100
+ if (typeof obj_id !== 'string') {
101
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
102
+ }
103
+ })();
104
+ return v_error === undefined ? null : v_error;
105
+ }
106
+ function deepFreeze$f(input) {
107
+ ObjectFreeze(input);
108
+ }
109
+
110
+ function validate$f(obj, path = 'ManagedContentChannelSummaryRepresentation') {
111
+ const v_error = (() => {
112
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
113
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
114
+ }
115
+ if (obj.domainUrl !== undefined) {
116
+ const obj_domainUrl = obj.domainUrl;
117
+ const path_domainUrl = path + '.domainUrl';
118
+ if (typeof obj_domainUrl !== 'string') {
119
+ return new TypeError('Expected "string" but received "' + typeof obj_domainUrl + '" (at "' + path_domainUrl + '")');
120
+ }
121
+ }
122
+ const obj_name = obj.name;
123
+ const path_name = path + '.name';
124
+ if (typeof obj_name !== 'string') {
125
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
126
+ }
127
+ const obj_resourceUrl = obj.resourceUrl;
128
+ const path_resourceUrl = path + '.resourceUrl';
129
+ if (typeof obj_resourceUrl !== 'string') {
130
+ return new TypeError('Expected "string" but received "' + typeof obj_resourceUrl + '" (at "' + path_resourceUrl + '")');
131
+ }
132
+ if (obj.targetSummary !== undefined) {
133
+ const obj_targetSummary = obj.targetSummary;
134
+ const path_targetSummary = path + '.targetSummary';
135
+ const referencepath_targetSummaryValidationError = validate$g(obj_targetSummary, path_targetSummary);
136
+ if (referencepath_targetSummaryValidationError !== null) {
137
+ let message = 'Object doesn\'t match ManagedContentChannelTargetSummaryRepresentation (at "' + path_targetSummary + '")\n';
138
+ message += referencepath_targetSummaryValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
139
+ return new TypeError(message);
140
+ }
141
+ }
142
+ })();
143
+ return v_error === undefined ? null : v_error;
144
+ }
145
+ function deepFreeze$e(input) {
146
+ const input_targetSummary = input.targetSummary;
147
+ if (input_targetSummary !== undefined) {
148
+ deepFreeze$f(input_targetSummary);
149
+ }
150
+ ObjectFreeze(input);
151
+ }
152
+
153
+ function validate$e(obj, path = 'ManagedContentTypeSummaryRepresentation') {
154
+ const v_error = (() => {
155
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
156
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
157
+ }
158
+ const obj_fullyQualifiedName = obj.fullyQualifiedName;
159
+ const path_fullyQualifiedName = path + '.fullyQualifiedName';
160
+ if (typeof obj_fullyQualifiedName !== 'string') {
161
+ return new TypeError('Expected "string" but received "' + typeof obj_fullyQualifiedName + '" (at "' + path_fullyQualifiedName + '")');
162
+ }
163
+ if (obj.name !== undefined) {
164
+ const obj_name = obj.name;
165
+ const path_name = path + '.name';
166
+ if (typeof obj_name !== 'string') {
167
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
168
+ }
169
+ }
170
+ })();
171
+ return v_error === undefined ? null : v_error;
172
+ }
173
+ function deepFreeze$d(input) {
174
+ ObjectFreeze(input);
175
+ }
176
+
177
+ function validate$d(obj, path = 'ManagedContentCollectionItemTypeSummaryRepresentation') {
178
+ const v_error = (() => {
179
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
180
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
181
+ }
182
+ const obj_fullyQualifiedName = obj.fullyQualifiedName;
183
+ const path_fullyQualifiedName = path + '.fullyQualifiedName';
184
+ if (typeof obj_fullyQualifiedName !== 'string') {
185
+ return new TypeError('Expected "string" but received "' + typeof obj_fullyQualifiedName + '" (at "' + path_fullyQualifiedName + '")');
186
+ }
187
+ const obj_name = obj.name;
188
+ const path_name = path + '.name';
189
+ if (typeof obj_name !== 'string') {
190
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
191
+ }
192
+ })();
193
+ return v_error === undefined ? null : v_error;
194
+ }
195
+ function deepFreeze$c(input) {
196
+ ObjectFreeze(input);
197
+ }
198
+
199
+ function validate$c(obj, path = 'ManagedContentCollectionItemRepresentation') {
200
+ const v_error = (() => {
201
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
202
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
203
+ }
204
+ const obj_body = obj.body;
205
+ const path_body = path + '.body';
206
+ if (typeof obj_body !== 'object' || ArrayIsArray(obj_body) || obj_body === null) {
207
+ return new TypeError('Expected "object" but received "' + typeof obj_body + '" (at "' + path_body + '")');
208
+ }
209
+ const obj_body_keys = ObjectKeys(obj_body);
210
+ for (let i = 0; i < obj_body_keys.length; i++) {
211
+ const key = obj_body_keys[i];
212
+ const obj_body_prop = obj_body[key];
213
+ const path_body_prop = path_body + '["' + key + '"]';
214
+ if (obj_body_prop === undefined) {
215
+ return new TypeError('Expected "defined" but received "' + typeof obj_body_prop + '" (at "' + path_body_prop + '")');
216
+ }
217
+ }
218
+ const obj_contentType = obj.contentType;
219
+ const path_contentType = path + '.contentType';
220
+ const referencepath_contentTypeValidationError = validate$d(obj_contentType, path_contentType);
221
+ if (referencepath_contentTypeValidationError !== null) {
222
+ let message = 'Object doesn\'t match ManagedContentCollectionItemTypeSummaryRepresentation (at "' + path_contentType + '")\n';
223
+ message += referencepath_contentTypeValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
224
+ return new TypeError(message);
225
+ }
226
+ const obj_id = obj.id;
227
+ const path_id = path + '.id';
228
+ if (typeof obj_id !== 'string') {
229
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
230
+ }
231
+ const obj_name = obj.name;
232
+ const path_name = path + '.name';
233
+ if (typeof obj_name !== 'string') {
234
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
235
+ }
236
+ })();
237
+ return v_error === undefined ? null : v_error;
238
+ }
239
+ function deepFreeze$b(input) {
240
+ const input_body = input.body;
241
+ const input_body_keys = Object.keys(input_body);
242
+ const input_body_length = input_body_keys.length;
243
+ for (let i = 0; i < input_body_length; i++) {
244
+ const key = input_body_keys[i];
245
+ const input_body_prop = input_body[key];
246
+ deepFreeze$g(input_body_prop);
247
+ }
248
+ ObjectFreeze(input_body);
249
+ const input_contentType = input.contentType;
250
+ deepFreeze$c(input_contentType);
251
+ ObjectFreeze(input);
252
+ }
253
+
254
+ const TTL$3 = 3600000;
255
+ const VERSION$4 = "f8aeed959e28f0d935539e65aa3e5211";
256
+ function validate$b(obj, path = 'ManagedContentCollectionItemsRepresentation') {
257
+ const v_error = (() => {
258
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
259
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
260
+ }
261
+ const obj_channelInfo = obj.channelInfo;
262
+ const path_channelInfo = path + '.channelInfo';
263
+ const referencepath_channelInfoValidationError = validate$f(obj_channelInfo, path_channelInfo);
264
+ if (referencepath_channelInfoValidationError !== null) {
265
+ let message = 'Object doesn\'t match ManagedContentChannelSummaryRepresentation (at "' + path_channelInfo + '")\n';
266
+ message += referencepath_channelInfoValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
267
+ return new TypeError(message);
268
+ }
269
+ const obj_collectionKey = obj.collectionKey;
270
+ const path_collectionKey = path + '.collectionKey';
271
+ if (typeof obj_collectionKey !== 'string') {
272
+ return new TypeError('Expected "string" but received "' + typeof obj_collectionKey + '" (at "' + path_collectionKey + '")');
273
+ }
274
+ const obj_collectionType = obj.collectionType;
275
+ const path_collectionType = path + '.collectionType';
276
+ const referencepath_collectionTypeValidationError = validate$e(obj_collectionType, path_collectionType);
277
+ if (referencepath_collectionTypeValidationError !== null) {
278
+ let message = 'Object doesn\'t match ManagedContentTypeSummaryRepresentation (at "' + path_collectionType + '")\n';
279
+ message += referencepath_collectionTypeValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
280
+ return new TypeError(message);
281
+ }
282
+ const obj_id = obj.id;
283
+ const path_id = path + '.id';
284
+ if (typeof obj_id !== 'string') {
285
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
286
+ }
287
+ const obj_items = obj.items;
288
+ const path_items = path + '.items';
289
+ if (!ArrayIsArray(obj_items)) {
290
+ return new TypeError('Expected "array" but received "' + typeof obj_items + '" (at "' + path_items + '")');
291
+ }
292
+ for (let i = 0; i < obj_items.length; i++) {
293
+ const obj_items_item = obj_items[i];
294
+ const path_items_item = path_items + '[' + i + ']';
295
+ const referencepath_items_itemValidationError = validate$c(obj_items_item, path_items_item);
296
+ if (referencepath_items_itemValidationError !== null) {
297
+ let message = 'Object doesn\'t match ManagedContentCollectionItemRepresentation (at "' + path_items_item + '")\n';
298
+ message += referencepath_items_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
299
+ return new TypeError(message);
300
+ }
301
+ }
302
+ const obj_language = obj.language;
303
+ const path_language = path + '.language';
304
+ if (typeof obj_language !== 'string') {
305
+ return new TypeError('Expected "string" but received "' + typeof obj_language + '" (at "' + path_language + '")');
306
+ }
307
+ const obj_publishedDate = obj.publishedDate;
308
+ const path_publishedDate = path + '.publishedDate';
309
+ if (typeof obj_publishedDate !== 'string') {
310
+ return new TypeError('Expected "string" but received "' + typeof obj_publishedDate + '" (at "' + path_publishedDate + '")');
311
+ }
312
+ const obj_title = obj.title;
313
+ const path_title = path + '.title';
314
+ if (typeof obj_title !== 'string') {
315
+ return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
316
+ }
317
+ const obj_total = obj.total;
318
+ const path_total = path + '.total';
319
+ if (typeof obj_total !== 'number' || (typeof obj_total === 'number' && Math.floor(obj_total) !== obj_total)) {
320
+ return new TypeError('Expected "integer" but received "' + typeof obj_total + '" (at "' + path_total + '")');
321
+ }
322
+ const obj_urlName = obj.urlName;
323
+ const path_urlName = path + '.urlName';
324
+ if (typeof obj_urlName !== 'string') {
325
+ return new TypeError('Expected "string" but received "' + typeof obj_urlName + '" (at "' + path_urlName + '")');
326
+ }
327
+ })();
328
+ return v_error === undefined ? null : v_error;
329
+ }
330
+ const RepresentationType$4 = 'ManagedContentCollectionItemsRepresentation';
331
+ function normalize$4(input, existing, path, luvio, store, timestamp) {
332
+ return input;
333
+ }
334
+ const select$a = function ManagedContentCollectionItemsRepresentationSelect() {
335
+ return {
336
+ kind: 'Fragment',
337
+ version: VERSION$4,
338
+ private: [],
339
+ opaque: true
340
+ };
341
+ };
342
+ function equals$4(existing, incoming) {
343
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
344
+ return false;
345
+ }
346
+ return true;
347
+ }
348
+ function deepFreeze$a(input) {
349
+ const input_channelInfo = input.channelInfo;
350
+ deepFreeze$e(input_channelInfo);
351
+ const input_collectionType = input.collectionType;
352
+ deepFreeze$d(input_collectionType);
353
+ const input_items = input.items;
354
+ for (let i = 0; i < input_items.length; i++) {
355
+ const input_items_item = input_items[i];
356
+ deepFreeze$b(input_items_item);
357
+ }
358
+ ObjectFreeze(input_items);
359
+ ObjectFreeze(input);
360
+ }
361
+ const ingest$4 = function ManagedContentCollectionItemsRepresentationIngest(input, path, luvio, store, timestamp) {
362
+ if (process.env.NODE_ENV !== 'production') {
363
+ const validateError = validate$b(input);
364
+ if (validateError !== null) {
365
+ throw validateError;
366
+ }
367
+ }
368
+ const key = path.fullPath;
369
+ const existingRecord = store.readEntry(key);
370
+ const ttlToUse = TTL$3;
371
+ let incomingRecord = normalize$4(input, store.readEntry(key), {
372
+ fullPath: key,
373
+ parent: path.parent,
374
+ propertyName: path.propertyName,
375
+ ttl: ttlToUse
376
+ });
377
+ deepFreeze$a(input);
378
+ if (existingRecord === undefined || equals$4(existingRecord, incomingRecord) === false) {
379
+ luvio.storePublish(key, incomingRecord);
380
+ }
381
+ {
382
+ const storeMetadataParams = {
383
+ ttl: ttlToUse,
384
+ namespace: "CMS",
385
+ version: VERSION$4,
386
+ representationName: RepresentationType$4,
387
+ };
388
+ luvio.publishStoreMetadata(key, storeMetadataParams);
389
+ }
390
+ return createLink(key);
391
+ };
392
+ function getTypeCacheKeys$4(luvio, input, fullPathFactory) {
393
+ const rootKeySet = new StoreKeyMap();
394
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
395
+ const rootKey = fullPathFactory();
396
+ rootKeySet.set(rootKey, {
397
+ namespace: keyPrefix,
398
+ representationName: RepresentationType$4,
399
+ mergeable: false
400
+ });
401
+ return rootKeySet;
402
+ }
403
+
404
+ function select$9(luvio, params) {
405
+ return select$a();
406
+ }
407
+ function keyBuilder$b(luvio, params) {
408
+ return keyPrefix + '::ManagedContentCollectionItemsRepresentation:(' + 'language:' + params.queryParams.language + ',' + 'channelId:' + params.urlParams.channelId + ',' + 'collectionKeyOrId:' + params.urlParams.collectionKeyOrId + ')';
409
+ }
410
+ function getResponseCacheKeys$5(luvio, resourceParams, response) {
411
+ return getTypeCacheKeys$4(luvio, response, () => keyBuilder$b(luvio, resourceParams));
412
+ }
413
+ function ingestSuccess$5(luvio, resourceParams, response, snapshotRefresh) {
414
+ const { body } = response;
415
+ const key = keyBuilder$b(luvio, resourceParams);
416
+ luvio.storeIngest(key, ingest$4, body);
417
+ const snapshot = luvio.storeLookup({
418
+ recordId: key,
419
+ node: select$9(),
420
+ variables: {},
421
+ }, snapshotRefresh);
422
+ if (process.env.NODE_ENV !== 'production') {
423
+ if (snapshot.state !== 'Fulfilled') {
424
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
425
+ }
426
+ }
427
+ return snapshot;
428
+ }
429
+ function ingestError$5(luvio, params, error, snapshotRefresh) {
430
+ const key = keyBuilder$b(luvio, params);
431
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
432
+ const storeMetadataParams = {
433
+ ttl: TTL$3,
434
+ namespace: keyPrefix,
435
+ version: VERSION$4,
436
+ representationName: RepresentationType$4
437
+ };
438
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
439
+ return errorSnapshot;
440
+ }
441
+ function createResourceRequest$5(config) {
442
+ const headers = {};
443
+ return {
444
+ baseUri: '/services/data/v58.0',
445
+ basePath: '/connect/cms/delivery/channels/' + config.urlParams.channelId + '/collections/' + config.urlParams.collectionKeyOrId + '',
446
+ method: 'get',
447
+ body: null,
448
+ urlParams: config.urlParams,
449
+ queryParams: config.queryParams,
450
+ headers,
451
+ priority: 'normal',
452
+ };
453
+ }
454
+
455
+ function onFetchResponseSuccess$9(luvio, config, resourceParams, response) {
456
+ let updatedResourceParams = resourceParams;
457
+ // If language is not provided in request resource params, use language from the response
458
+ // and update the response params. As this resource params will be used to build a cache key.
459
+ if (updatedResourceParams.queryParams.language === undefined) {
460
+ updatedResourceParams.queryParams.language = response.body.language;
461
+ }
462
+ return onFetchResponseSuccess$8(luvio, config, updatedResourceParams, response);
463
+ }
464
+
465
+ const getCollectionItemsForChannel_ConfigPropertyNames = {
466
+ displayName: 'getCollectionItemsForChannel',
467
+ parameters: {
468
+ required: ['channelId', 'collectionKeyOrId'],
469
+ optional: ['language']
470
+ }
471
+ };
472
+ function createResourceParams$5(config) {
473
+ const resourceParams = {
474
+ urlParams: {
475
+ channelId: config.channelId, collectionKeyOrId: config.collectionKeyOrId
476
+ },
477
+ queryParams: {
478
+ language: config.language
479
+ }
480
+ };
481
+ return resourceParams;
482
+ }
483
+ function keyBuilder$a(luvio, config) {
484
+ const resourceParams = createResourceParams$5(config);
485
+ return keyBuilder$b(luvio, resourceParams);
486
+ }
487
+ function typeCheckConfig$5(untrustedConfig) {
488
+ const config = {};
489
+ const untrustedConfig_channelId = untrustedConfig.channelId;
490
+ if (typeof untrustedConfig_channelId === 'string') {
491
+ config.channelId = untrustedConfig_channelId;
492
+ }
493
+ const untrustedConfig_collectionKeyOrId = untrustedConfig.collectionKeyOrId;
494
+ if (typeof untrustedConfig_collectionKeyOrId === 'string') {
495
+ config.collectionKeyOrId = untrustedConfig_collectionKeyOrId;
496
+ }
497
+ const untrustedConfig_language = untrustedConfig.language;
498
+ if (typeof untrustedConfig_language === 'string') {
499
+ config.language = untrustedConfig_language;
500
+ }
501
+ return config;
502
+ }
503
+ function validateAdapterConfig$5(untrustedConfig, configPropertyNames) {
504
+ if (!untrustedIsObject(untrustedConfig)) {
505
+ return null;
506
+ }
507
+ if (process.env.NODE_ENV !== 'production') {
508
+ validateConfig(untrustedConfig, configPropertyNames);
509
+ }
510
+ const config = typeCheckConfig$5(untrustedConfig);
511
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
512
+ return null;
513
+ }
514
+ return config;
515
+ }
516
+ function adapterFragment$5(luvio, config) {
517
+ createResourceParams$5(config);
518
+ return select$9();
519
+ }
520
+ function onFetchResponseSuccess$8(luvio, config, resourceParams, response) {
521
+ const snapshot = ingestSuccess$5(luvio, resourceParams, response, {
522
+ config,
523
+ resolve: () => buildNetworkSnapshot$5(luvio, config, snapshotRefreshOptions)
524
+ });
525
+ return luvio.storeBroadcast().then(() => snapshot);
526
+ }
527
+ function onFetchResponseError$5(luvio, config, resourceParams, response) {
528
+ const snapshot = ingestError$5(luvio, resourceParams, response, {
529
+ config,
530
+ resolve: () => buildNetworkSnapshot$5(luvio, config, snapshotRefreshOptions)
531
+ });
532
+ return luvio.storeBroadcast().then(() => snapshot);
533
+ }
534
+ function buildNetworkSnapshot$5(luvio, config, options) {
535
+ const resourceParams = createResourceParams$5(config);
536
+ const request = createResourceRequest$5(resourceParams);
537
+ return luvio.dispatchResourceRequest(request, options)
538
+ .then((response) => {
539
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$9(luvio, config, resourceParams, response), () => getResponseCacheKeys$5(luvio, resourceParams, response.body));
540
+ }, (response) => {
541
+ return luvio.handleErrorResponse(() => onFetchResponseError$5(luvio, config, resourceParams, response));
542
+ });
543
+ }
544
+ function buildNetworkSnapshotCachePolicy$5(context, coercedAdapterRequestContext) {
545
+ const { luvio, config } = context;
546
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
547
+ const dispatchOptions = {
548
+ resourceRequestContext: {
549
+ requestCorrelator,
550
+ luvioRequestMethod: undefined,
551
+ },
552
+ eventObservers
553
+ };
554
+ if (networkPriority !== 'normal') {
555
+ dispatchOptions.overrides = {
556
+ priority: networkPriority
557
+ };
558
+ }
559
+ return buildNetworkSnapshot$5(luvio, config, dispatchOptions);
560
+ }
561
+ function buildCachedSnapshotCachePolicy$5(context, storeLookup) {
562
+ const { luvio, config } = context;
563
+ const selector = {
564
+ recordId: keyBuilder$a(luvio, config),
565
+ node: adapterFragment$5(luvio, config),
566
+ variables: {},
567
+ };
568
+ const cacheSnapshot = storeLookup(selector, {
569
+ config,
570
+ resolve: () => buildNetworkSnapshot$5(luvio, config, snapshotRefreshOptions)
571
+ });
572
+ return cacheSnapshot;
573
+ }
574
+ const getCollectionItemsForChannelAdapterFactory = (luvio) => function CMS__getCollectionItemsForChannel(untrustedConfig, requestContext) {
575
+ const config = validateAdapterConfig$5(untrustedConfig, getCollectionItemsForChannel_ConfigPropertyNames);
576
+ // Invalid or incomplete config
577
+ if (config === null) {
578
+ return null;
579
+ }
580
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
581
+ buildCachedSnapshotCachePolicy$5, buildNetworkSnapshotCachePolicy$5);
582
+ };
583
+
584
+ const TTL$2 = 3600000;
585
+ const VERSION$3 = "181754fe91f1eab67546c9f961cedb5f";
586
+ function validate$a(obj, path = 'ManagedContentCollectionMetadataRepresentation') {
587
+ const v_error = (() => {
588
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
589
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
590
+ }
591
+ const obj_channelInfo = obj.channelInfo;
592
+ const path_channelInfo = path + '.channelInfo';
593
+ const referencepath_channelInfoValidationError = validate$f(obj_channelInfo, path_channelInfo);
594
+ if (referencepath_channelInfoValidationError !== null) {
595
+ let message = 'Object doesn\'t match ManagedContentChannelSummaryRepresentation (at "' + path_channelInfo + '")\n';
596
+ message += referencepath_channelInfoValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
597
+ return new TypeError(message);
598
+ }
599
+ const obj_collectionKey = obj.collectionKey;
600
+ const path_collectionKey = path + '.collectionKey';
601
+ if (typeof obj_collectionKey !== 'string') {
602
+ return new TypeError('Expected "string" but received "' + typeof obj_collectionKey + '" (at "' + path_collectionKey + '")');
603
+ }
604
+ const obj_collectionMetadata = obj.collectionMetadata;
605
+ const path_collectionMetadata = path + '.collectionMetadata';
606
+ if (typeof obj_collectionMetadata !== 'object' || ArrayIsArray(obj_collectionMetadata) || obj_collectionMetadata === null) {
607
+ return new TypeError('Expected "object" but received "' + typeof obj_collectionMetadata + '" (at "' + path_collectionMetadata + '")');
608
+ }
609
+ const obj_collectionMetadata_keys = ObjectKeys(obj_collectionMetadata);
610
+ for (let i = 0; i < obj_collectionMetadata_keys.length; i++) {
611
+ const key = obj_collectionMetadata_keys[i];
612
+ const obj_collectionMetadata_prop = obj_collectionMetadata[key];
613
+ const path_collectionMetadata_prop = path_collectionMetadata + '["' + key + '"]';
614
+ if (obj_collectionMetadata_prop === undefined) {
615
+ return new TypeError('Expected "defined" but received "' + typeof obj_collectionMetadata_prop + '" (at "' + path_collectionMetadata_prop + '")');
616
+ }
617
+ }
618
+ const obj_collectionType = obj.collectionType;
619
+ const path_collectionType = path + '.collectionType';
620
+ const referencepath_collectionTypeValidationError = validate$e(obj_collectionType, path_collectionType);
621
+ if (referencepath_collectionTypeValidationError !== null) {
622
+ let message = 'Object doesn\'t match ManagedContentTypeSummaryRepresentation (at "' + path_collectionType + '")\n';
623
+ message += referencepath_collectionTypeValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
624
+ return new TypeError(message);
625
+ }
626
+ const obj_id = obj.id;
627
+ const path_id = path + '.id';
628
+ if (typeof obj_id !== 'string') {
629
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
630
+ }
631
+ const obj_language = obj.language;
632
+ const path_language = path + '.language';
633
+ if (typeof obj_language !== 'string') {
634
+ return new TypeError('Expected "string" but received "' + typeof obj_language + '" (at "' + path_language + '")');
635
+ }
636
+ const obj_publishedDate = obj.publishedDate;
637
+ const path_publishedDate = path + '.publishedDate';
638
+ if (typeof obj_publishedDate !== 'string') {
639
+ return new TypeError('Expected "string" but received "' + typeof obj_publishedDate + '" (at "' + path_publishedDate + '")');
640
+ }
641
+ const obj_schema = obj.schema;
642
+ const path_schema = path + '.schema';
643
+ if (typeof obj_schema !== 'object' || ArrayIsArray(obj_schema) || obj_schema === null) {
644
+ return new TypeError('Expected "object" but received "' + typeof obj_schema + '" (at "' + path_schema + '")');
645
+ }
646
+ const obj_schema_keys = ObjectKeys(obj_schema);
647
+ for (let i = 0; i < obj_schema_keys.length; i++) {
648
+ const key = obj_schema_keys[i];
649
+ const obj_schema_prop = obj_schema[key];
650
+ const path_schema_prop = path_schema + '["' + key + '"]';
651
+ if (obj_schema_prop === undefined) {
652
+ return new TypeError('Expected "defined" but received "' + typeof obj_schema_prop + '" (at "' + path_schema_prop + '")');
653
+ }
654
+ }
655
+ const obj_title = obj.title;
656
+ const path_title = path + '.title';
657
+ if (typeof obj_title !== 'string') {
658
+ return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
659
+ }
660
+ const obj_urlName = obj.urlName;
661
+ const path_urlName = path + '.urlName';
662
+ if (typeof obj_urlName !== 'string') {
663
+ return new TypeError('Expected "string" but received "' + typeof obj_urlName + '" (at "' + path_urlName + '")');
664
+ }
665
+ })();
666
+ return v_error === undefined ? null : v_error;
667
+ }
668
+ const RepresentationType$3 = 'ManagedContentCollectionMetadataRepresentation';
669
+ function normalize$3(input, existing, path, luvio, store, timestamp) {
670
+ return input;
671
+ }
672
+ const select$8 = function ManagedContentCollectionMetadataRepresentationSelect() {
673
+ return {
674
+ kind: 'Fragment',
675
+ version: VERSION$3,
676
+ private: [],
677
+ opaque: true
678
+ };
679
+ };
680
+ function equals$3(existing, incoming) {
681
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
682
+ return false;
683
+ }
684
+ return true;
685
+ }
686
+ function deepFreeze$9(input) {
687
+ const input_channelInfo = input.channelInfo;
688
+ deepFreeze$e(input_channelInfo);
689
+ const input_collectionMetadata = input.collectionMetadata;
690
+ const input_collectionMetadata_keys = Object.keys(input_collectionMetadata);
691
+ const input_collectionMetadata_length = input_collectionMetadata_keys.length;
692
+ for (let i = 0; i < input_collectionMetadata_length; i++) {
693
+ const key = input_collectionMetadata_keys[i];
694
+ const input_collectionMetadata_prop = input_collectionMetadata[key];
695
+ deepFreeze$g(input_collectionMetadata_prop);
696
+ }
697
+ ObjectFreeze(input_collectionMetadata);
698
+ const input_collectionType = input.collectionType;
699
+ deepFreeze$d(input_collectionType);
700
+ const input_schema = input.schema;
701
+ const input_schema_keys = Object.keys(input_schema);
702
+ const input_schema_length = input_schema_keys.length;
703
+ for (let i = 0; i < input_schema_length; i++) {
704
+ const key = input_schema_keys[i];
705
+ const input_schema_prop = input_schema[key];
706
+ deepFreeze$g(input_schema_prop);
707
+ }
708
+ ObjectFreeze(input_schema);
709
+ ObjectFreeze(input);
710
+ }
711
+ const ingest$3 = function ManagedContentCollectionMetadataRepresentationIngest(input, path, luvio, store, timestamp) {
712
+ if (process.env.NODE_ENV !== 'production') {
713
+ const validateError = validate$a(input);
714
+ if (validateError !== null) {
715
+ throw validateError;
716
+ }
717
+ }
718
+ const key = path.fullPath;
719
+ const existingRecord = store.readEntry(key);
720
+ const ttlToUse = TTL$2;
721
+ let incomingRecord = normalize$3(input, store.readEntry(key), {
722
+ fullPath: key,
723
+ parent: path.parent,
724
+ propertyName: path.propertyName,
725
+ ttl: ttlToUse
726
+ });
727
+ deepFreeze$9(input);
728
+ if (existingRecord === undefined || equals$3(existingRecord, incomingRecord) === false) {
729
+ luvio.storePublish(key, incomingRecord);
730
+ }
731
+ {
732
+ const storeMetadataParams = {
733
+ ttl: ttlToUse,
734
+ namespace: "CMS",
735
+ version: VERSION$3,
736
+ representationName: RepresentationType$3,
737
+ };
738
+ luvio.publishStoreMetadata(key, storeMetadataParams);
739
+ }
740
+ return createLink(key);
741
+ };
742
+ function getTypeCacheKeys$3(luvio, input, fullPathFactory) {
743
+ const rootKeySet = new StoreKeyMap();
744
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
745
+ const rootKey = fullPathFactory();
746
+ rootKeySet.set(rootKey, {
747
+ namespace: keyPrefix,
748
+ representationName: RepresentationType$3,
749
+ mergeable: false
750
+ });
751
+ return rootKeySet;
752
+ }
753
+
754
+ function select$7(luvio, params) {
755
+ return select$8();
756
+ }
757
+ function keyBuilder$9(luvio, params) {
758
+ return keyPrefix + '::ManagedContentCollectionMetadataRepresentation:(' + 'expandMetadata:' + params.queryParams.expandMetadata + ',' + 'language:' + params.queryParams.language + ',' + 'channelId:' + params.urlParams.channelId + ',' + 'collectionKeyOrId:' + params.urlParams.collectionKeyOrId + ')';
759
+ }
760
+ function getResponseCacheKeys$4(luvio, resourceParams, response) {
761
+ return getTypeCacheKeys$3(luvio, response, () => keyBuilder$9(luvio, resourceParams));
762
+ }
763
+ function ingestSuccess$4(luvio, resourceParams, response, snapshotRefresh) {
764
+ const { body } = response;
765
+ const key = keyBuilder$9(luvio, resourceParams);
766
+ luvio.storeIngest(key, ingest$3, body);
767
+ const snapshot = luvio.storeLookup({
768
+ recordId: key,
769
+ node: select$7(),
770
+ variables: {},
771
+ }, snapshotRefresh);
772
+ if (process.env.NODE_ENV !== 'production') {
773
+ if (snapshot.state !== 'Fulfilled') {
774
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
775
+ }
776
+ }
777
+ return snapshot;
778
+ }
779
+ function ingestError$4(luvio, params, error, snapshotRefresh) {
780
+ const key = keyBuilder$9(luvio, params);
781
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
782
+ const storeMetadataParams = {
783
+ ttl: TTL$2,
784
+ namespace: keyPrefix,
785
+ version: VERSION$3,
786
+ representationName: RepresentationType$3
787
+ };
788
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
789
+ return errorSnapshot;
790
+ }
791
+ function createResourceRequest$4(config) {
792
+ const headers = {};
793
+ return {
794
+ baseUri: '/services/data/v58.0',
795
+ basePath: '/connect/cms/delivery/channels/' + config.urlParams.channelId + '/collections/' + config.urlParams.collectionKeyOrId + '/metadata',
796
+ method: 'get',
797
+ body: null,
798
+ urlParams: config.urlParams,
799
+ queryParams: config.queryParams,
800
+ headers,
801
+ priority: 'normal',
802
+ };
803
+ }
804
+
805
+ function onFetchResponseSuccess$7(luvio, config, resourceParams, response) {
806
+ let updatedResourceParams = resourceParams;
807
+ // If language is not provided in request resource params, use language from the response
808
+ // and update the response params. As this resource params will be used to build a cache key.
809
+ if (updatedResourceParams.queryParams.language === undefined) {
810
+ updatedResourceParams.queryParams.language = response.body.language;
811
+ }
812
+ return onFetchResponseSuccess$6(luvio, config, updatedResourceParams, response);
813
+ }
814
+
815
+ const getCollectionMetadataForChannel_ConfigPropertyNames = {
816
+ displayName: 'getCollectionMetadataForChannel',
817
+ parameters: {
818
+ required: ['channelId', 'collectionKeyOrId'],
819
+ optional: ['expandMetadata', 'language']
820
+ }
821
+ };
822
+ function createResourceParams$4(config) {
823
+ const resourceParams = {
824
+ urlParams: {
825
+ channelId: config.channelId, collectionKeyOrId: config.collectionKeyOrId
826
+ },
827
+ queryParams: {
828
+ expandMetadata: config.expandMetadata, language: config.language
829
+ }
830
+ };
831
+ return resourceParams;
832
+ }
833
+ function keyBuilder$8(luvio, config) {
834
+ const resourceParams = createResourceParams$4(config);
835
+ return keyBuilder$9(luvio, resourceParams);
836
+ }
837
+ function typeCheckConfig$4(untrustedConfig) {
838
+ const config = {};
839
+ const untrustedConfig_channelId = untrustedConfig.channelId;
840
+ if (typeof untrustedConfig_channelId === 'string') {
841
+ config.channelId = untrustedConfig_channelId;
842
+ }
843
+ const untrustedConfig_collectionKeyOrId = untrustedConfig.collectionKeyOrId;
844
+ if (typeof untrustedConfig_collectionKeyOrId === 'string') {
845
+ config.collectionKeyOrId = untrustedConfig_collectionKeyOrId;
846
+ }
847
+ const untrustedConfig_expandMetadata = untrustedConfig.expandMetadata;
848
+ if (typeof untrustedConfig_expandMetadata === 'boolean') {
849
+ config.expandMetadata = untrustedConfig_expandMetadata;
850
+ }
851
+ const untrustedConfig_language = untrustedConfig.language;
852
+ if (typeof untrustedConfig_language === 'string') {
853
+ config.language = untrustedConfig_language;
854
+ }
855
+ return config;
856
+ }
857
+ function validateAdapterConfig$4(untrustedConfig, configPropertyNames) {
858
+ if (!untrustedIsObject(untrustedConfig)) {
859
+ return null;
860
+ }
861
+ if (process.env.NODE_ENV !== 'production') {
862
+ validateConfig(untrustedConfig, configPropertyNames);
863
+ }
864
+ const config = typeCheckConfig$4(untrustedConfig);
865
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
866
+ return null;
867
+ }
868
+ return config;
869
+ }
870
+ function adapterFragment$4(luvio, config) {
871
+ createResourceParams$4(config);
872
+ return select$7();
873
+ }
874
+ function onFetchResponseSuccess$6(luvio, config, resourceParams, response) {
875
+ const snapshot = ingestSuccess$4(luvio, resourceParams, response, {
876
+ config,
877
+ resolve: () => buildNetworkSnapshot$4(luvio, config, snapshotRefreshOptions)
878
+ });
879
+ return luvio.storeBroadcast().then(() => snapshot);
880
+ }
881
+ function onFetchResponseError$4(luvio, config, resourceParams, response) {
882
+ const snapshot = ingestError$4(luvio, resourceParams, response, {
883
+ config,
884
+ resolve: () => buildNetworkSnapshot$4(luvio, config, snapshotRefreshOptions)
885
+ });
886
+ return luvio.storeBroadcast().then(() => snapshot);
887
+ }
888
+ function buildNetworkSnapshot$4(luvio, config, options) {
889
+ const resourceParams = createResourceParams$4(config);
890
+ const request = createResourceRequest$4(resourceParams);
891
+ return luvio.dispatchResourceRequest(request, options)
892
+ .then((response) => {
893
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$7(luvio, config, resourceParams, response), () => getResponseCacheKeys$4(luvio, resourceParams, response.body));
894
+ }, (response) => {
895
+ return luvio.handleErrorResponse(() => onFetchResponseError$4(luvio, config, resourceParams, response));
896
+ });
897
+ }
898
+ function buildNetworkSnapshotCachePolicy$4(context, coercedAdapterRequestContext) {
899
+ const { luvio, config } = context;
900
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
901
+ const dispatchOptions = {
902
+ resourceRequestContext: {
903
+ requestCorrelator,
904
+ luvioRequestMethod: undefined,
905
+ },
906
+ eventObservers
907
+ };
908
+ if (networkPriority !== 'normal') {
909
+ dispatchOptions.overrides = {
910
+ priority: networkPriority
911
+ };
912
+ }
913
+ return buildNetworkSnapshot$4(luvio, config, dispatchOptions);
914
+ }
915
+ function buildCachedSnapshotCachePolicy$4(context, storeLookup) {
916
+ const { luvio, config } = context;
917
+ const selector = {
918
+ recordId: keyBuilder$8(luvio, config),
919
+ node: adapterFragment$4(luvio, config),
920
+ variables: {},
921
+ };
922
+ const cacheSnapshot = storeLookup(selector, {
923
+ config,
924
+ resolve: () => buildNetworkSnapshot$4(luvio, config, snapshotRefreshOptions)
925
+ });
926
+ return cacheSnapshot;
927
+ }
928
+ const getCollectionMetadataForChannelAdapterFactory = (luvio) => function CMS__getCollectionMetadataForChannel(untrustedConfig, requestContext) {
929
+ const config = validateAdapterConfig$4(untrustedConfig, getCollectionMetadataForChannel_ConfigPropertyNames);
930
+ // Invalid or incomplete config
931
+ if (config === null) {
932
+ return null;
933
+ }
934
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
935
+ buildCachedSnapshotCachePolicy$4, buildNetworkSnapshotCachePolicy$4);
936
+ };
937
+
938
+ function validate$9(obj, path = 'TopicSummaryRepresentation') {
939
+ const v_error = (() => {
940
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
941
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
942
+ }
943
+ const obj_id = obj.id;
944
+ const path_id = path + '.id';
945
+ if (typeof obj_id !== 'string') {
946
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
947
+ }
948
+ const obj_name = obj.name;
949
+ const path_name = path + '.name';
950
+ if (typeof obj_name !== 'string') {
951
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
952
+ }
953
+ })();
954
+ return v_error === undefined ? null : v_error;
955
+ }
956
+ function deepFreeze$8(input) {
957
+ ObjectFreeze(input);
958
+ }
959
+
960
+ function validate$8(obj, path = 'ManagedContentAssociationsRepresentation') {
961
+ const v_error = (() => {
962
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
963
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
964
+ }
965
+ const obj_topics = obj.topics;
966
+ const path_topics = path + '.topics';
967
+ if (!ArrayIsArray(obj_topics)) {
968
+ return new TypeError('Expected "array" but received "' + typeof obj_topics + '" (at "' + path_topics + '")');
969
+ }
970
+ for (let i = 0; i < obj_topics.length; i++) {
971
+ const obj_topics_item = obj_topics[i];
972
+ const path_topics_item = path_topics + '[' + i + ']';
973
+ const referencepath_topics_itemValidationError = validate$9(obj_topics_item, path_topics_item);
974
+ if (referencepath_topics_itemValidationError !== null) {
975
+ let message = 'Object doesn\'t match TopicSummaryRepresentation (at "' + path_topics_item + '")\n';
976
+ message += referencepath_topics_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
977
+ return new TypeError(message);
978
+ }
979
+ }
980
+ })();
981
+ return v_error === undefined ? null : v_error;
982
+ }
983
+ function deepFreeze$7(input) {
984
+ const input_topics = input.topics;
985
+ for (let i = 0; i < input_topics.length; i++) {
986
+ const input_topics_item = input_topics[i];
987
+ deepFreeze$8(input_topics_item);
988
+ }
989
+ ObjectFreeze(input_topics);
990
+ ObjectFreeze(input);
991
+ }
992
+
993
+ var DiscriminatorValues;
994
+ (function (DiscriminatorValues) {
995
+ DiscriminatorValues["Date"] = "Date";
996
+ DiscriminatorValues["Text"] = "Text";
997
+ })(DiscriminatorValues || (DiscriminatorValues = {}));
998
+ function validate$7(obj, path = 'ManagedContentNodeValueRepresentation') {
999
+ const v_error = (() => {
1000
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1001
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1002
+ }
1003
+ const obj_nodeType = obj.nodeType;
1004
+ const path_nodeType = path + '.nodeType';
1005
+ if (typeof obj_nodeType !== 'string') {
1006
+ return new TypeError('Expected "string" but received "' + typeof obj_nodeType + '" (at "' + path_nodeType + '")');
1007
+ }
1008
+ })();
1009
+ return v_error === undefined ? null : v_error;
1010
+ }
1011
+ function deepFreeze$6(input) {
1012
+ ObjectFreeze(input);
1013
+ }
1014
+
1015
+ function validate$6(obj, path = 'ManagedContentVersionRepresentation') {
1016
+ const v_error = (() => {
1017
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1018
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1019
+ }
1020
+ if (obj.associations !== undefined) {
1021
+ const obj_associations = obj.associations;
1022
+ const path_associations = path + '.associations';
1023
+ const referencepath_associationsValidationError = validate$8(obj_associations, path_associations);
1024
+ if (referencepath_associationsValidationError !== null) {
1025
+ let message = 'Object doesn\'t match ManagedContentAssociationsRepresentation (at "' + path_associations + '")\n';
1026
+ message += referencepath_associationsValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1027
+ return new TypeError(message);
1028
+ }
1029
+ }
1030
+ const obj_contentKey = obj.contentKey;
1031
+ const path_contentKey = path + '.contentKey';
1032
+ if (typeof obj_contentKey !== 'string') {
1033
+ return new TypeError('Expected "string" but received "' + typeof obj_contentKey + '" (at "' + path_contentKey + '")');
1034
+ }
1035
+ const obj_contentNodes = obj.contentNodes;
1036
+ const path_contentNodes = path + '.contentNodes';
1037
+ if (typeof obj_contentNodes !== 'object' || ArrayIsArray(obj_contentNodes) || obj_contentNodes === null) {
1038
+ return new TypeError('Expected "object" but received "' + typeof obj_contentNodes + '" (at "' + path_contentNodes + '")');
1039
+ }
1040
+ const obj_contentNodes_keys = ObjectKeys(obj_contentNodes);
1041
+ for (let i = 0; i < obj_contentNodes_keys.length; i++) {
1042
+ const key = obj_contentNodes_keys[i];
1043
+ const obj_contentNodes_prop = obj_contentNodes[key];
1044
+ const path_contentNodes_prop = path_contentNodes + '["' + key + '"]';
1045
+ const referencepath_contentNodes_propValidationError = validate$7(obj_contentNodes_prop, path_contentNodes_prop);
1046
+ if (referencepath_contentNodes_propValidationError !== null) {
1047
+ let message = 'Object doesn\'t match ManagedContentNodeValueRepresentation (at "' + path_contentNodes_prop + '")\n';
1048
+ message += referencepath_contentNodes_propValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1049
+ return new TypeError(message);
1050
+ }
1051
+ }
1052
+ const obj_contentUrlName = obj.contentUrlName;
1053
+ const path_contentUrlName = path + '.contentUrlName';
1054
+ if (typeof obj_contentUrlName !== 'string') {
1055
+ return new TypeError('Expected "string" but received "' + typeof obj_contentUrlName + '" (at "' + path_contentUrlName + '")');
1056
+ }
1057
+ const obj_language = obj.language;
1058
+ const path_language = path + '.language';
1059
+ if (typeof obj_language !== 'string') {
1060
+ return new TypeError('Expected "string" but received "' + typeof obj_language + '" (at "' + path_language + '")');
1061
+ }
1062
+ const obj_managedContentId = obj.managedContentId;
1063
+ const path_managedContentId = path + '.managedContentId';
1064
+ if (typeof obj_managedContentId !== 'string') {
1065
+ return new TypeError('Expected "string" but received "' + typeof obj_managedContentId + '" (at "' + path_managedContentId + '")');
1066
+ }
1067
+ const obj_publishedDate = obj.publishedDate;
1068
+ const path_publishedDate = path + '.publishedDate';
1069
+ if (typeof obj_publishedDate !== 'string') {
1070
+ return new TypeError('Expected "string" but received "' + typeof obj_publishedDate + '" (at "' + path_publishedDate + '")');
1071
+ }
1072
+ const obj_title = obj.title;
1073
+ const path_title = path + '.title';
1074
+ if (typeof obj_title !== 'string') {
1075
+ return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
1076
+ }
1077
+ const obj_type = obj.type;
1078
+ const path_type = path + '.type';
1079
+ if (typeof obj_type !== 'string') {
1080
+ return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
1081
+ }
1082
+ const obj_typeLabel = obj.typeLabel;
1083
+ const path_typeLabel = path + '.typeLabel';
1084
+ if (typeof obj_typeLabel !== 'string') {
1085
+ return new TypeError('Expected "string" but received "' + typeof obj_typeLabel + '" (at "' + path_typeLabel + '")');
1086
+ }
1087
+ const obj_unauthenticatedUrl = obj.unauthenticatedUrl;
1088
+ const path_unauthenticatedUrl = path + '.unauthenticatedUrl';
1089
+ let obj_unauthenticatedUrl_union0 = null;
1090
+ const obj_unauthenticatedUrl_union0_error = (() => {
1091
+ if (typeof obj_unauthenticatedUrl !== 'string') {
1092
+ return new TypeError('Expected "string" but received "' + typeof obj_unauthenticatedUrl + '" (at "' + path_unauthenticatedUrl + '")');
1093
+ }
1094
+ })();
1095
+ if (obj_unauthenticatedUrl_union0_error != null) {
1096
+ obj_unauthenticatedUrl_union0 = obj_unauthenticatedUrl_union0_error.message;
1097
+ }
1098
+ let obj_unauthenticatedUrl_union1 = null;
1099
+ const obj_unauthenticatedUrl_union1_error = (() => {
1100
+ if (obj_unauthenticatedUrl !== null) {
1101
+ return new TypeError('Expected "null" but received "' + typeof obj_unauthenticatedUrl + '" (at "' + path_unauthenticatedUrl + '")');
1102
+ }
1103
+ })();
1104
+ if (obj_unauthenticatedUrl_union1_error != null) {
1105
+ obj_unauthenticatedUrl_union1 = obj_unauthenticatedUrl_union1_error.message;
1106
+ }
1107
+ if (obj_unauthenticatedUrl_union0 && obj_unauthenticatedUrl_union1) {
1108
+ let message = 'Object doesn\'t match union (at "' + path_unauthenticatedUrl + '")';
1109
+ message += '\n' + obj_unauthenticatedUrl_union0.split('\n').map((line) => '\t' + line).join('\n');
1110
+ message += '\n' + obj_unauthenticatedUrl_union1.split('\n').map((line) => '\t' + line).join('\n');
1111
+ return new TypeError(message);
1112
+ }
1113
+ })();
1114
+ return v_error === undefined ? null : v_error;
1115
+ }
1116
+ function deepFreeze$5(input) {
1117
+ const input_associations = input.associations;
1118
+ if (input_associations !== undefined) {
1119
+ deepFreeze$7(input_associations);
1120
+ }
1121
+ const input_contentNodes = input.contentNodes;
1122
+ const input_contentNodes_keys = Object.keys(input_contentNodes);
1123
+ const input_contentNodes_length = input_contentNodes_keys.length;
1124
+ for (let i = 0; i < input_contentNodes_length; i++) {
1125
+ const key = input_contentNodes_keys[i];
1126
+ const input_contentNodes_prop = input_contentNodes[key];
1127
+ deepFreeze$6(input_contentNodes_prop);
1128
+ }
1129
+ ObjectFreeze(input_contentNodes);
1130
+ ObjectFreeze(input);
1131
+ }
1132
+
1133
+ function validate$5(obj, path = 'ManagedContentNodeTypeRepresentation') {
1134
+ const v_error = (() => {
1135
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1136
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1137
+ }
1138
+ const obj_label = obj.label;
1139
+ const path_label = path + '.label';
1140
+ if (typeof obj_label !== 'string') {
1141
+ return new TypeError('Expected "string" but received "' + typeof obj_label + '" (at "' + path_label + '")');
1142
+ }
1143
+ const obj_name = obj.name;
1144
+ const path_name = path + '.name';
1145
+ if (typeof obj_name !== 'string') {
1146
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
1147
+ }
1148
+ const obj_nodeType = obj.nodeType;
1149
+ const path_nodeType = path + '.nodeType';
1150
+ if (typeof obj_nodeType !== 'string') {
1151
+ return new TypeError('Expected "string" but received "' + typeof obj_nodeType + '" (at "' + path_nodeType + '")');
1152
+ }
1153
+ })();
1154
+ return v_error === undefined ? null : v_error;
1155
+ }
1156
+ function deepFreeze$4(input) {
1157
+ ObjectFreeze(input);
1158
+ }
1159
+
1160
+ function validate$4(obj, path = 'ManagedContentTypeRepresentation') {
1161
+ const v_error = (() => {
1162
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1163
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1164
+ }
1165
+ const obj_label = obj.label;
1166
+ const path_label = path + '.label';
1167
+ if (typeof obj_label !== 'string') {
1168
+ return new TypeError('Expected "string" but received "' + typeof obj_label + '" (at "' + path_label + '")');
1169
+ }
1170
+ const obj_name = obj.name;
1171
+ const path_name = path + '.name';
1172
+ if (typeof obj_name !== 'string') {
1173
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
1174
+ }
1175
+ const obj_nodeTypes = obj.nodeTypes;
1176
+ const path_nodeTypes = path + '.nodeTypes';
1177
+ if (typeof obj_nodeTypes !== 'object' || ArrayIsArray(obj_nodeTypes) || obj_nodeTypes === null) {
1178
+ return new TypeError('Expected "object" but received "' + typeof obj_nodeTypes + '" (at "' + path_nodeTypes + '")');
1179
+ }
1180
+ const obj_nodeTypes_keys = ObjectKeys(obj_nodeTypes);
1181
+ for (let i = 0; i < obj_nodeTypes_keys.length; i++) {
1182
+ const key = obj_nodeTypes_keys[i];
1183
+ const obj_nodeTypes_prop = obj_nodeTypes[key];
1184
+ const path_nodeTypes_prop = path_nodeTypes + '["' + key + '"]';
1185
+ const referencepath_nodeTypes_propValidationError = validate$5(obj_nodeTypes_prop, path_nodeTypes_prop);
1186
+ if (referencepath_nodeTypes_propValidationError !== null) {
1187
+ let message = 'Object doesn\'t match ManagedContentNodeTypeRepresentation (at "' + path_nodeTypes_prop + '")\n';
1188
+ message += referencepath_nodeTypes_propValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1189
+ return new TypeError(message);
1190
+ }
1191
+ }
1192
+ })();
1193
+ return v_error === undefined ? null : v_error;
1194
+ }
1195
+ function deepFreeze$3(input) {
1196
+ const input_nodeTypes = input.nodeTypes;
1197
+ const input_nodeTypes_keys = Object.keys(input_nodeTypes);
1198
+ const input_nodeTypes_length = input_nodeTypes_keys.length;
1199
+ for (let i = 0; i < input_nodeTypes_length; i++) {
1200
+ const key = input_nodeTypes_keys[i];
1201
+ const input_nodeTypes_prop = input_nodeTypes[key];
1202
+ deepFreeze$4(input_nodeTypes_prop);
1203
+ }
1204
+ ObjectFreeze(input_nodeTypes);
1205
+ ObjectFreeze(input);
1206
+ }
1207
+
1208
+ const TTL$1 = 3600000;
1209
+ const VERSION$2 = "5ee006120d0880559392ef3c5fdc2a52";
1210
+ function validate$3(obj, path = 'ManagedContentVersionCollectionRepresentation') {
1211
+ const v_error = (() => {
1212
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1213
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1214
+ }
1215
+ const obj_currentPageUrl = obj.currentPageUrl;
1216
+ const path_currentPageUrl = path + '.currentPageUrl';
1217
+ if (typeof obj_currentPageUrl !== 'string') {
1218
+ return new TypeError('Expected "string" but received "' + typeof obj_currentPageUrl + '" (at "' + path_currentPageUrl + '")');
1219
+ }
1220
+ const obj_items = obj.items;
1221
+ const path_items = path + '.items';
1222
+ if (!ArrayIsArray(obj_items)) {
1223
+ return new TypeError('Expected "array" but received "' + typeof obj_items + '" (at "' + path_items + '")');
1224
+ }
1225
+ for (let i = 0; i < obj_items.length; i++) {
1226
+ const obj_items_item = obj_items[i];
1227
+ const path_items_item = path_items + '[' + i + ']';
1228
+ const referencepath_items_itemValidationError = validate$6(obj_items_item, path_items_item);
1229
+ if (referencepath_items_itemValidationError !== null) {
1230
+ let message = 'Object doesn\'t match ManagedContentVersionRepresentation (at "' + path_items_item + '")\n';
1231
+ message += referencepath_items_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1232
+ return new TypeError(message);
1233
+ }
1234
+ }
1235
+ if (obj.managedContentTypes !== undefined) {
1236
+ const obj_managedContentTypes = obj.managedContentTypes;
1237
+ const path_managedContentTypes = path + '.managedContentTypes';
1238
+ if (typeof obj_managedContentTypes !== 'object' || ArrayIsArray(obj_managedContentTypes) || obj_managedContentTypes === null) {
1239
+ return new TypeError('Expected "object" but received "' + typeof obj_managedContentTypes + '" (at "' + path_managedContentTypes + '")');
1240
+ }
1241
+ const obj_managedContentTypes_keys = ObjectKeys(obj_managedContentTypes);
1242
+ for (let i = 0; i < obj_managedContentTypes_keys.length; i++) {
1243
+ const key = obj_managedContentTypes_keys[i];
1244
+ const obj_managedContentTypes_prop = obj_managedContentTypes[key];
1245
+ const path_managedContentTypes_prop = path_managedContentTypes + '["' + key + '"]';
1246
+ const referencepath_managedContentTypes_propValidationError = validate$4(obj_managedContentTypes_prop, path_managedContentTypes_prop);
1247
+ if (referencepath_managedContentTypes_propValidationError !== null) {
1248
+ let message = 'Object doesn\'t match ManagedContentTypeRepresentation (at "' + path_managedContentTypes_prop + '")\n';
1249
+ message += referencepath_managedContentTypes_propValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1250
+ return new TypeError(message);
1251
+ }
1252
+ }
1253
+ }
1254
+ if (obj.nextPageUrl !== undefined) {
1255
+ const obj_nextPageUrl = obj.nextPageUrl;
1256
+ const path_nextPageUrl = path + '.nextPageUrl';
1257
+ if (typeof obj_nextPageUrl !== 'string') {
1258
+ return new TypeError('Expected "string" but received "' + typeof obj_nextPageUrl + '" (at "' + path_nextPageUrl + '")');
1259
+ }
1260
+ }
1261
+ const obj_total = obj.total;
1262
+ const path_total = path + '.total';
1263
+ if (typeof obj_total !== 'number' || (typeof obj_total === 'number' && Math.floor(obj_total) !== obj_total)) {
1264
+ return new TypeError('Expected "integer" but received "' + typeof obj_total + '" (at "' + path_total + '")');
1265
+ }
1266
+ const obj_totalTypes = obj.totalTypes;
1267
+ const path_totalTypes = path + '.totalTypes';
1268
+ if (typeof obj_totalTypes !== 'number' || (typeof obj_totalTypes === 'number' && Math.floor(obj_totalTypes) !== obj_totalTypes)) {
1269
+ return new TypeError('Expected "integer" but received "' + typeof obj_totalTypes + '" (at "' + path_totalTypes + '")');
1270
+ }
1271
+ })();
1272
+ return v_error === undefined ? null : v_error;
1273
+ }
1274
+ const RepresentationType$2 = 'ManagedContentVersionCollectionRepresentation';
1275
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
1276
+ return input;
1277
+ }
1278
+ const select$6 = function ManagedContentVersionCollectionRepresentationSelect() {
1279
+ return {
1280
+ kind: 'Fragment',
1281
+ version: VERSION$2,
1282
+ private: [],
1283
+ opaque: true
1284
+ };
1285
+ };
1286
+ function equals$2(existing, incoming) {
1287
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
1288
+ return false;
1289
+ }
1290
+ return true;
1291
+ }
1292
+ function deepFreeze$2(input) {
1293
+ const input_items = input.items;
1294
+ for (let i = 0; i < input_items.length; i++) {
1295
+ const input_items_item = input_items[i];
1296
+ deepFreeze$5(input_items_item);
1297
+ }
1298
+ ObjectFreeze(input_items);
1299
+ const input_managedContentTypes = input.managedContentTypes;
1300
+ if (input_managedContentTypes !== undefined) {
1301
+ const input_managedContentTypes_keys = Object.keys(input_managedContentTypes);
1302
+ const input_managedContentTypes_length = input_managedContentTypes_keys.length;
1303
+ for (let i = 0; i < input_managedContentTypes_length; i++) {
1304
+ const key = input_managedContentTypes_keys[i];
1305
+ const input_managedContentTypes_prop = input_managedContentTypes[key];
1306
+ deepFreeze$3(input_managedContentTypes_prop);
1307
+ }
1308
+ ObjectFreeze(input_managedContentTypes);
1309
+ }
1310
+ ObjectFreeze(input);
1311
+ }
1312
+ const ingest$2 = function ManagedContentVersionCollectionRepresentationIngest(input, path, luvio, store, timestamp) {
1313
+ if (process.env.NODE_ENV !== 'production') {
1314
+ const validateError = validate$3(input);
1315
+ if (validateError !== null) {
1316
+ throw validateError;
1317
+ }
1318
+ }
1319
+ const key = path.fullPath;
1320
+ const existingRecord = store.readEntry(key);
1321
+ const ttlToUse = TTL$1;
1322
+ let incomingRecord = normalize$2(input, store.readEntry(key), {
1323
+ fullPath: key,
1324
+ parent: path.parent,
1325
+ propertyName: path.propertyName,
1326
+ ttl: ttlToUse
1327
+ });
1328
+ deepFreeze$2(input);
1329
+ if (existingRecord === undefined || equals$2(existingRecord, incomingRecord) === false) {
1330
+ luvio.storePublish(key, incomingRecord);
1331
+ }
1332
+ {
1333
+ const storeMetadataParams = {
1334
+ ttl: ttlToUse,
1335
+ namespace: "CMS",
1336
+ version: VERSION$2,
1337
+ representationName: RepresentationType$2,
1338
+ };
1339
+ luvio.publishStoreMetadata(key, storeMetadataParams);
1340
+ }
1341
+ return createLink(key);
1342
+ };
1343
+ function getTypeCacheKeys$2(luvio, input, fullPathFactory) {
1344
+ const rootKeySet = new StoreKeyMap();
1345
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1346
+ const rootKey = fullPathFactory();
1347
+ rootKeySet.set(rootKey, {
1348
+ namespace: keyPrefix,
1349
+ representationName: RepresentationType$2,
1350
+ mergeable: false
1351
+ });
1352
+ return rootKeySet;
1353
+ }
1354
+
1355
+ function select$5(luvio, params) {
1356
+ return select$6();
1357
+ }
1358
+ function keyBuilder$7(luvio, params) {
1359
+ return keyPrefix + '::ManagedContentVersionCollectionRepresentation:(' + 'contentKeys:' + params.queryParams.contentKeys + ',' + 'language:' + params.queryParams.language + ',' + 'managedContentIds:' + params.queryParams.managedContentIds + ',' + 'managedContentType:' + params.queryParams.managedContentType + ',' + 'page:' + params.queryParams.page + ',' + 'pageSize:' + params.queryParams.pageSize + ',' + 'showAbsoluteUrl:' + params.queryParams.showAbsoluteUrl + ',' + 'topics:' + params.queryParams.topics + ',' + 'communityId:' + params.urlParams.communityId + ')';
1360
+ }
1361
+ function getResponseCacheKeys$3(luvio, resourceParams, response) {
1362
+ return getTypeCacheKeys$2(luvio, response, () => keyBuilder$7(luvio, resourceParams));
1363
+ }
1364
+ function ingestSuccess$3(luvio, resourceParams, response, snapshotRefresh) {
1365
+ const { body } = response;
1366
+ const key = keyBuilder$7(luvio, resourceParams);
1367
+ luvio.storeIngest(key, ingest$2, body);
1368
+ const snapshot = luvio.storeLookup({
1369
+ recordId: key,
1370
+ node: select$5(),
1371
+ variables: {},
1372
+ }, snapshotRefresh);
1373
+ if (process.env.NODE_ENV !== 'production') {
1374
+ if (snapshot.state !== 'Fulfilled') {
1375
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1376
+ }
1377
+ }
1378
+ return snapshot;
1379
+ }
1380
+ function ingestError$3(luvio, params, error, snapshotRefresh) {
1381
+ const key = keyBuilder$7(luvio, params);
1382
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
1383
+ const storeMetadataParams = {
1384
+ ttl: TTL$1,
1385
+ namespace: keyPrefix,
1386
+ version: VERSION$2,
1387
+ representationName: RepresentationType$2
1388
+ };
1389
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
1390
+ return errorSnapshot;
1391
+ }
1392
+ function createResourceRequest$3(config) {
1393
+ const headers = {};
1394
+ return {
1395
+ baseUri: '/services/data/v58.0',
1396
+ basePath: '/connect/communities/' + config.urlParams.communityId + '/managed-content/delivery',
1397
+ method: 'get',
1398
+ body: null,
1399
+ urlParams: config.urlParams,
1400
+ queryParams: config.queryParams,
1401
+ headers,
1402
+ priority: 'normal',
1403
+ };
1404
+ }
1405
+
1406
+ const listContent_ConfigPropertyNames = {
1407
+ displayName: 'listContent',
1408
+ parameters: {
1409
+ required: ['communityId'],
1410
+ optional: ['contentKeys', 'language', 'managedContentIds', 'managedContentType', 'page', 'pageSize', 'showAbsoluteUrl', 'topics']
1411
+ }
1412
+ };
1413
+ function createResourceParams$3(config) {
1414
+ const resourceParams = {
1415
+ urlParams: {
1416
+ communityId: config.communityId
1417
+ },
1418
+ queryParams: {
1419
+ contentKeys: config.contentKeys, language: config.language, managedContentIds: config.managedContentIds, managedContentType: config.managedContentType, page: config.page, pageSize: config.pageSize, showAbsoluteUrl: config.showAbsoluteUrl, topics: config.topics
1420
+ }
1421
+ };
1422
+ return resourceParams;
1423
+ }
1424
+ function keyBuilder$6(luvio, config) {
1425
+ const resourceParams = createResourceParams$3(config);
1426
+ return keyBuilder$7(luvio, resourceParams);
1427
+ }
1428
+ function typeCheckConfig$3(untrustedConfig) {
1429
+ const config = {};
1430
+ const untrustedConfig_communityId = untrustedConfig.communityId;
1431
+ if (typeof untrustedConfig_communityId === 'string') {
1432
+ config.communityId = untrustedConfig_communityId;
1433
+ }
1434
+ const untrustedConfig_contentKeys = untrustedConfig.contentKeys;
1435
+ if (ArrayIsArray$1(untrustedConfig_contentKeys)) {
1436
+ const untrustedConfig_contentKeys_array = [];
1437
+ for (let i = 0, arrayLength = untrustedConfig_contentKeys.length; i < arrayLength; i++) {
1438
+ const untrustedConfig_contentKeys_item = untrustedConfig_contentKeys[i];
1439
+ if (typeof untrustedConfig_contentKeys_item === 'string') {
1440
+ untrustedConfig_contentKeys_array.push(untrustedConfig_contentKeys_item);
1441
+ }
1442
+ }
1443
+ config.contentKeys = untrustedConfig_contentKeys_array;
1444
+ }
1445
+ const untrustedConfig_language = untrustedConfig.language;
1446
+ if (typeof untrustedConfig_language === 'string') {
1447
+ config.language = untrustedConfig_language;
1448
+ }
1449
+ const untrustedConfig_managedContentIds = untrustedConfig.managedContentIds;
1450
+ if (ArrayIsArray$1(untrustedConfig_managedContentIds)) {
1451
+ const untrustedConfig_managedContentIds_array = [];
1452
+ for (let i = 0, arrayLength = untrustedConfig_managedContentIds.length; i < arrayLength; i++) {
1453
+ const untrustedConfig_managedContentIds_item = untrustedConfig_managedContentIds[i];
1454
+ if (typeof untrustedConfig_managedContentIds_item === 'string') {
1455
+ untrustedConfig_managedContentIds_array.push(untrustedConfig_managedContentIds_item);
1456
+ }
1457
+ }
1458
+ config.managedContentIds = untrustedConfig_managedContentIds_array;
1459
+ }
1460
+ const untrustedConfig_managedContentType = untrustedConfig.managedContentType;
1461
+ if (typeof untrustedConfig_managedContentType === 'string') {
1462
+ config.managedContentType = untrustedConfig_managedContentType;
1463
+ }
1464
+ const untrustedConfig_page = untrustedConfig.page;
1465
+ if (typeof untrustedConfig_page === 'number' && Math.floor(untrustedConfig_page) === untrustedConfig_page) {
1466
+ config.page = untrustedConfig_page;
1467
+ }
1468
+ const untrustedConfig_pageSize = untrustedConfig.pageSize;
1469
+ if (typeof untrustedConfig_pageSize === 'number' && Math.floor(untrustedConfig_pageSize) === untrustedConfig_pageSize) {
1470
+ config.pageSize = untrustedConfig_pageSize;
1471
+ }
1472
+ const untrustedConfig_showAbsoluteUrl = untrustedConfig.showAbsoluteUrl;
1473
+ if (typeof untrustedConfig_showAbsoluteUrl === 'boolean') {
1474
+ config.showAbsoluteUrl = untrustedConfig_showAbsoluteUrl;
1475
+ }
1476
+ const untrustedConfig_topics = untrustedConfig.topics;
1477
+ if (ArrayIsArray$1(untrustedConfig_topics)) {
1478
+ const untrustedConfig_topics_array = [];
1479
+ for (let i = 0, arrayLength = untrustedConfig_topics.length; i < arrayLength; i++) {
1480
+ const untrustedConfig_topics_item = untrustedConfig_topics[i];
1481
+ if (typeof untrustedConfig_topics_item === 'string') {
1482
+ untrustedConfig_topics_array.push(untrustedConfig_topics_item);
1483
+ }
1484
+ }
1485
+ config.topics = untrustedConfig_topics_array;
1486
+ }
1487
+ return config;
1488
+ }
1489
+ function validateAdapterConfig$3(untrustedConfig, configPropertyNames) {
1490
+ if (!untrustedIsObject(untrustedConfig)) {
1491
+ return null;
1492
+ }
1493
+ if (process.env.NODE_ENV !== 'production') {
1494
+ validateConfig(untrustedConfig, configPropertyNames);
1495
+ }
1496
+ const config = typeCheckConfig$3(untrustedConfig);
1497
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
1498
+ return null;
1499
+ }
1500
+ return config;
1501
+ }
1502
+ function adapterFragment$3(luvio, config) {
1503
+ createResourceParams$3(config);
1504
+ return select$5();
1505
+ }
1506
+ function onFetchResponseSuccess$5(luvio, config, resourceParams, response) {
1507
+ const snapshot = ingestSuccess$3(luvio, resourceParams, response, {
1508
+ config,
1509
+ resolve: () => buildNetworkSnapshot$3(luvio, config, snapshotRefreshOptions)
1510
+ });
1511
+ return luvio.storeBroadcast().then(() => snapshot);
1512
+ }
1513
+ function onFetchResponseError$3(luvio, config, resourceParams, response) {
1514
+ const snapshot = ingestError$3(luvio, resourceParams, response, {
1515
+ config,
1516
+ resolve: () => buildNetworkSnapshot$3(luvio, config, snapshotRefreshOptions)
1517
+ });
1518
+ return luvio.storeBroadcast().then(() => snapshot);
1519
+ }
1520
+ function buildNetworkSnapshot$3(luvio, config, options) {
1521
+ const resourceParams = createResourceParams$3(config);
1522
+ const request = createResourceRequest$3(resourceParams);
1523
+ return luvio.dispatchResourceRequest(request, options)
1524
+ .then((response) => {
1525
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$5(luvio, config, resourceParams, response), () => getResponseCacheKeys$3(luvio, resourceParams, response.body));
1526
+ }, (response) => {
1527
+ return luvio.handleErrorResponse(() => onFetchResponseError$3(luvio, config, resourceParams, response));
1528
+ });
1529
+ }
1530
+ function buildNetworkSnapshotCachePolicy$3(context, coercedAdapterRequestContext) {
1531
+ const { luvio, config } = context;
1532
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
1533
+ const dispatchOptions = {
1534
+ resourceRequestContext: {
1535
+ requestCorrelator,
1536
+ luvioRequestMethod: undefined,
1537
+ },
1538
+ eventObservers
1539
+ };
1540
+ if (networkPriority !== 'normal') {
1541
+ dispatchOptions.overrides = {
1542
+ priority: networkPriority
1543
+ };
1544
+ }
1545
+ return buildNetworkSnapshot$3(luvio, config, dispatchOptions);
1546
+ }
1547
+ function buildCachedSnapshotCachePolicy$3(context, storeLookup) {
1548
+ const { luvio, config } = context;
1549
+ const selector = {
1550
+ recordId: keyBuilder$6(luvio, config),
1551
+ node: adapterFragment$3(luvio, config),
1552
+ variables: {},
1553
+ };
1554
+ const cacheSnapshot = storeLookup(selector, {
1555
+ config,
1556
+ resolve: () => buildNetworkSnapshot$3(luvio, config, snapshotRefreshOptions)
1557
+ });
1558
+ return cacheSnapshot;
1559
+ }
1560
+ const listContentAdapterFactory = (luvio) => function CMS__listContent(untrustedConfig, requestContext) {
1561
+ const config = validateAdapterConfig$3(untrustedConfig, listContent_ConfigPropertyNames);
1562
+ // Invalid or incomplete config
1563
+ if (config === null) {
1564
+ return null;
1565
+ }
1566
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
1567
+ buildCachedSnapshotCachePolicy$3, buildNetworkSnapshotCachePolicy$3);
1568
+ };
1569
+
1570
+ function validate$2(obj, path = 'ReferenceRepresentation') {
1571
+ const v_error = (() => {
1572
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1573
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1574
+ }
1575
+ const obj_id = obj.id;
1576
+ const path_id = path + '.id';
1577
+ if (typeof obj_id !== 'string') {
1578
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
1579
+ }
1580
+ const obj_url = obj.url;
1581
+ const path_url = path + '.url';
1582
+ if (typeof obj_url !== 'string') {
1583
+ return new TypeError('Expected "string" but received "' + typeof obj_url + '" (at "' + path_url + '")');
1584
+ }
1585
+ })();
1586
+ return v_error === undefined ? null : v_error;
1587
+ }
1588
+ function deepFreeze$1(input) {
1589
+ ObjectFreeze(input);
1590
+ }
1591
+
1592
+ const TTL = 3600000;
1593
+ const VERSION$1 = "ce50e14585c86e6b3e7d029adbe702cc";
1594
+ function validate$1(obj, path = 'ManagedContentVersionInternalRepresentation') {
1595
+ const v_error = (() => {
1596
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1597
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1598
+ }
1599
+ const obj_associations = obj.associations;
1600
+ const path_associations = path + '.associations';
1601
+ const referencepath_associationsValidationError = validate$8(obj_associations, path_associations);
1602
+ if (referencepath_associationsValidationError !== null) {
1603
+ let message = 'Object doesn\'t match ManagedContentAssociationsRepresentation (at "' + path_associations + '")\n';
1604
+ message += referencepath_associationsValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1605
+ return new TypeError(message);
1606
+ }
1607
+ const obj_authoredManagedContentId = obj.authoredManagedContentId;
1608
+ const path_authoredManagedContentId = path + '.authoredManagedContentId';
1609
+ if (typeof obj_authoredManagedContentId !== 'string') {
1610
+ return new TypeError('Expected "string" but received "' + typeof obj_authoredManagedContentId + '" (at "' + path_authoredManagedContentId + '")');
1611
+ }
1612
+ const obj_body = obj.body;
1613
+ const path_body = path + '.body';
1614
+ if (typeof obj_body !== 'object' || ArrayIsArray(obj_body) || obj_body === null) {
1615
+ return new TypeError('Expected "object" but received "' + typeof obj_body + '" (at "' + path_body + '")');
1616
+ }
1617
+ const obj_body_keys = ObjectKeys(obj_body);
1618
+ for (let i = 0; i < obj_body_keys.length; i++) {
1619
+ const key = obj_body_keys[i];
1620
+ const obj_body_prop = obj_body[key];
1621
+ const path_body_prop = path_body + '["' + key + '"]';
1622
+ if (obj_body_prop === undefined) {
1623
+ return new TypeError('Expected "defined" but received "' + typeof obj_body_prop + '" (at "' + path_body_prop + '")');
1624
+ }
1625
+ }
1626
+ const obj_contentKey = obj.contentKey;
1627
+ const path_contentKey = path + '.contentKey';
1628
+ if (typeof obj_contentKey !== 'string') {
1629
+ return new TypeError('Expected "string" but received "' + typeof obj_contentKey + '" (at "' + path_contentKey + '")');
1630
+ }
1631
+ const obj_createdByReference = obj.createdByReference;
1632
+ const path_createdByReference = path + '.createdByReference';
1633
+ const referencepath_createdByReferenceValidationError = validate$2(obj_createdByReference, path_createdByReference);
1634
+ if (referencepath_createdByReferenceValidationError !== null) {
1635
+ let message = 'Object doesn\'t match ReferenceRepresentation (at "' + path_createdByReference + '")\n';
1636
+ message += referencepath_createdByReferenceValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1637
+ return new TypeError(message);
1638
+ }
1639
+ const obj_createdDate = obj.createdDate;
1640
+ const path_createdDate = path + '.createdDate';
1641
+ if (typeof obj_createdDate !== 'string') {
1642
+ return new TypeError('Expected "string" but received "' + typeof obj_createdDate + '" (at "' + path_createdDate + '")');
1643
+ }
1644
+ const obj_id = obj.id;
1645
+ const path_id = path + '.id';
1646
+ if (typeof obj_id !== 'string') {
1647
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
1648
+ }
1649
+ const obj_lastUpdatedByReference = obj.lastUpdatedByReference;
1650
+ const path_lastUpdatedByReference = path + '.lastUpdatedByReference';
1651
+ const referencepath_lastUpdatedByReferenceValidationError = validate$2(obj_lastUpdatedByReference, path_lastUpdatedByReference);
1652
+ if (referencepath_lastUpdatedByReferenceValidationError !== null) {
1653
+ let message = 'Object doesn\'t match ReferenceRepresentation (at "' + path_lastUpdatedByReference + '")\n';
1654
+ message += referencepath_lastUpdatedByReferenceValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1655
+ return new TypeError(message);
1656
+ }
1657
+ const obj_managedContentId = obj.managedContentId;
1658
+ const path_managedContentId = path + '.managedContentId';
1659
+ if (typeof obj_managedContentId !== 'string') {
1660
+ return new TypeError('Expected "string" but received "' + typeof obj_managedContentId + '" (at "' + path_managedContentId + '")');
1661
+ }
1662
+ const obj_masterLanguage = obj.masterLanguage;
1663
+ const path_masterLanguage = path + '.masterLanguage';
1664
+ if (typeof obj_masterLanguage !== 'string') {
1665
+ return new TypeError('Expected "string" but received "' + typeof obj_masterLanguage + '" (at "' + path_masterLanguage + '")');
1666
+ }
1667
+ const obj_publishDate = obj.publishDate;
1668
+ const path_publishDate = path + '.publishDate';
1669
+ if (typeof obj_publishDate !== 'string') {
1670
+ return new TypeError('Expected "string" but received "' + typeof obj_publishDate + '" (at "' + path_publishDate + '")');
1671
+ }
1672
+ const obj_status = obj.status;
1673
+ const path_status = path + '.status';
1674
+ if (typeof obj_status !== 'string') {
1675
+ return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
1676
+ }
1677
+ const obj_title = obj.title;
1678
+ const path_title = path + '.title';
1679
+ if (typeof obj_title !== 'string') {
1680
+ return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
1681
+ }
1682
+ const obj_type = obj.type;
1683
+ const path_type = path + '.type';
1684
+ if (typeof obj_type !== 'string') {
1685
+ return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
1686
+ }
1687
+ const obj_typeLabel = obj.typeLabel;
1688
+ const path_typeLabel = path + '.typeLabel';
1689
+ if (typeof obj_typeLabel !== 'string') {
1690
+ return new TypeError('Expected "string" but received "' + typeof obj_typeLabel + '" (at "' + path_typeLabel + '")');
1691
+ }
1692
+ const obj_updatedDate = obj.updatedDate;
1693
+ const path_updatedDate = path + '.updatedDate';
1694
+ if (typeof obj_updatedDate !== 'string') {
1695
+ return new TypeError('Expected "string" but received "' + typeof obj_updatedDate + '" (at "' + path_updatedDate + '")');
1696
+ }
1697
+ const obj_urlName = obj.urlName;
1698
+ const path_urlName = path + '.urlName';
1699
+ if (typeof obj_urlName !== 'string') {
1700
+ return new TypeError('Expected "string" but received "' + typeof obj_urlName + '" (at "' + path_urlName + '")');
1701
+ }
1702
+ })();
1703
+ return v_error === undefined ? null : v_error;
1704
+ }
1705
+ const RepresentationType$1 = 'ManagedContentVersionInternalRepresentation';
1706
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
1707
+ return input;
1708
+ }
1709
+ const select$4 = function ManagedContentVersionInternalRepresentationSelect() {
1710
+ return {
1711
+ kind: 'Fragment',
1712
+ version: VERSION$1,
1713
+ private: [],
1714
+ opaque: true
1715
+ };
1716
+ };
1717
+ function equals$1(existing, incoming) {
1718
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
1719
+ return false;
1720
+ }
1721
+ return true;
1722
+ }
1723
+ function deepFreeze(input) {
1724
+ const input_associations = input.associations;
1725
+ deepFreeze$7(input_associations);
1726
+ const input_body = input.body;
1727
+ const input_body_keys = Object.keys(input_body);
1728
+ const input_body_length = input_body_keys.length;
1729
+ for (let i = 0; i < input_body_length; i++) {
1730
+ const key = input_body_keys[i];
1731
+ const input_body_prop = input_body[key];
1732
+ deepFreeze$g(input_body_prop);
1733
+ }
1734
+ ObjectFreeze(input_body);
1735
+ const input_createdByReference = input.createdByReference;
1736
+ deepFreeze$1(input_createdByReference);
1737
+ const input_lastUpdatedByReference = input.lastUpdatedByReference;
1738
+ deepFreeze$1(input_lastUpdatedByReference);
1739
+ ObjectFreeze(input);
1740
+ }
1741
+ const ingest$1 = function ManagedContentVersionInternalRepresentationIngest(input, path, luvio, store, timestamp) {
1742
+ if (process.env.NODE_ENV !== 'production') {
1743
+ const validateError = validate$1(input);
1744
+ if (validateError !== null) {
1745
+ throw validateError;
1746
+ }
1747
+ }
1748
+ const key = path.fullPath;
1749
+ const existingRecord = store.readEntry(key);
1750
+ const ttlToUse = TTL;
1751
+ let incomingRecord = normalize$1(input, store.readEntry(key), {
1752
+ fullPath: key,
1753
+ parent: path.parent,
1754
+ propertyName: path.propertyName,
1755
+ ttl: ttlToUse
1756
+ });
1757
+ deepFreeze(input);
1758
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
1759
+ luvio.storePublish(key, incomingRecord);
1760
+ }
1761
+ {
1762
+ const storeMetadataParams = {
1763
+ ttl: ttlToUse,
1764
+ namespace: "CMS",
1765
+ version: VERSION$1,
1766
+ representationName: RepresentationType$1,
1767
+ };
1768
+ luvio.publishStoreMetadata(key, storeMetadataParams);
1769
+ }
1770
+ return createLink(key);
1771
+ };
1772
+ function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
1773
+ const rootKeySet = new StoreKeyMap();
1774
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1775
+ const rootKey = fullPathFactory();
1776
+ rootKeySet.set(rootKey, {
1777
+ namespace: keyPrefix,
1778
+ representationName: RepresentationType$1,
1779
+ mergeable: false
1780
+ });
1781
+ return rootKeySet;
1782
+ }
1783
+
1784
+ const VERSION = "a524ce828168211d9e25771a19aa2d0c";
1785
+ function validate(obj, path = 'ManagedContentVersionInternalCollectionRepresentation') {
1786
+ const v_error = (() => {
1787
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1788
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1789
+ }
1790
+ const obj_items = obj.items;
1791
+ const path_items = path + '.items';
1792
+ if (!ArrayIsArray(obj_items)) {
1793
+ return new TypeError('Expected "array" but received "' + typeof obj_items + '" (at "' + path_items + '")');
1794
+ }
1795
+ for (let i = 0; i < obj_items.length; i++) {
1796
+ const obj_items_item = obj_items[i];
1797
+ const path_items_item = path_items + '[' + i + ']';
1798
+ if (typeof obj_items_item !== 'object') {
1799
+ return new TypeError('Expected "object" but received "' + typeof obj_items_item + '" (at "' + path_items_item + '")');
1800
+ }
1801
+ }
1802
+ const obj_total = obj.total;
1803
+ const path_total = path + '.total';
1804
+ if (typeof obj_total !== 'number' || (typeof obj_total === 'number' && Math.floor(obj_total) !== obj_total)) {
1805
+ return new TypeError('Expected "integer" but received "' + typeof obj_total + '" (at "' + path_total + '")');
1806
+ }
1807
+ })();
1808
+ return v_error === undefined ? null : v_error;
1809
+ }
1810
+ const RepresentationType = 'ManagedContentVersionInternalCollectionRepresentation';
1811
+ function normalize(input, existing, path, luvio, store, timestamp) {
1812
+ const input_items = input.items;
1813
+ const input_items_id = path.fullPath + '__items';
1814
+ for (let i = 0; i < input_items.length; i++) {
1815
+ const input_items_item = input_items[i];
1816
+ let input_items_item_id = input_items_id + '__' + i;
1817
+ input_items[i] = ingest$1(input_items_item, {
1818
+ fullPath: input_items_item_id,
1819
+ propertyName: i,
1820
+ parent: {
1821
+ data: input,
1822
+ key: path.fullPath,
1823
+ existing: existing,
1824
+ },
1825
+ ttl: path.ttl
1826
+ }, luvio, store);
1827
+ }
1828
+ return input;
1829
+ }
1830
+ const select$3 = function ManagedContentVersionInternalCollectionRepresentationSelect() {
1831
+ return {
1832
+ kind: 'Fragment',
1833
+ version: VERSION,
1834
+ private: [],
1835
+ selections: [
1836
+ {
1837
+ name: 'items',
1838
+ kind: 'Link',
1839
+ plural: true,
1840
+ fragment: select$4()
1841
+ },
1842
+ {
1843
+ name: 'total',
1844
+ kind: 'Scalar'
1845
+ }
1846
+ ]
1847
+ };
1848
+ };
1849
+ function equals(existing, incoming) {
1850
+ const existing_total = existing.total;
1851
+ const incoming_total = incoming.total;
1852
+ if (!(existing_total === incoming_total)) {
1853
+ return false;
1854
+ }
1855
+ const existing_items = existing.items;
1856
+ const incoming_items = incoming.items;
1857
+ const equals_items_items = equalsArray(existing_items, incoming_items, (existing_items_item, incoming_items_item) => {
1858
+ if (!(existing_items_item.__ref === incoming_items_item.__ref)) {
1859
+ return false;
1860
+ }
1861
+ });
1862
+ if (equals_items_items === false) {
1863
+ return false;
1864
+ }
1865
+ return true;
1866
+ }
1867
+ const ingest = function ManagedContentVersionInternalCollectionRepresentationIngest(input, path, luvio, store, timestamp) {
1868
+ if (process.env.NODE_ENV !== 'production') {
1869
+ const validateError = validate(input);
1870
+ if (validateError !== null) {
1871
+ throw validateError;
1872
+ }
1873
+ }
1874
+ const key = path.fullPath;
1875
+ const existingRecord = store.readEntry(key);
1876
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
1877
+ let incomingRecord = normalize(input, store.readEntry(key), {
1878
+ fullPath: key,
1879
+ parent: path.parent,
1880
+ propertyName: path.propertyName,
1881
+ ttl: ttlToUse
1882
+ }, luvio, store);
1883
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
1884
+ luvio.storePublish(key, incomingRecord);
1885
+ }
1886
+ if (ttlToUse !== undefined) {
1887
+ const storeMetadataParams = {
1888
+ ttl: ttlToUse,
1889
+ namespace: "CMS",
1890
+ version: VERSION,
1891
+ representationName: RepresentationType,
1892
+ };
1893
+ luvio.publishStoreMetadata(key, storeMetadataParams);
1894
+ }
1895
+ return createLink(key);
1896
+ };
1897
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
1898
+ const rootKeySet = new StoreKeyMap();
1899
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1900
+ const rootKey = fullPathFactory();
1901
+ rootKeySet.set(rootKey, {
1902
+ namespace: keyPrefix,
1903
+ representationName: RepresentationType,
1904
+ mergeable: false
1905
+ });
1906
+ const input_items_length = input.items.length;
1907
+ for (let i = 0; i < input_items_length; i++) {
1908
+ rootKeySet.merge(getTypeCacheKeys$1(luvio, input.items[i], () => ''));
1909
+ }
1910
+ return rootKeySet;
1911
+ }
1912
+
1913
+ function select$2(luvio, params) {
1914
+ return select$3();
1915
+ }
1916
+ function keyBuilder$5(luvio, params) {
1917
+ return keyPrefix + '::ManagedContentVersionInternalCollectionRepresentation:(' + 'collectionName:' + params.queryParams.collectionName + ',' + 'contentKeys:' + params.queryParams.contentKeys + ',' + 'language:' + params.queryParams.language + ',' + 'managedContentIds:' + params.queryParams.managedContentIds + ',' + 'managedContentType:' + params.queryParams.managedContentType + ',' + 'page:' + params.queryParams.page + ',' + 'pageSize:' + params.queryParams.pageSize + ',' + 'queryTerm:' + params.queryParams.queryTerm + ',' + 'topics:' + params.queryParams.topics + ',' + 'urlNameInList:' + params.queryParams.urlNameInList + ',' + 'communityId:' + params.urlParams.communityId + ')';
1918
+ }
1919
+ function getResponseCacheKeys$2(luvio, resourceParams, response) {
1920
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$5(luvio, resourceParams));
1921
+ }
1922
+ function ingestSuccess$2(luvio, resourceParams, response, snapshotRefresh) {
1923
+ const { body } = response;
1924
+ const key = keyBuilder$5(luvio, resourceParams);
1925
+ luvio.storeIngest(key, ingest, body);
1926
+ const snapshot = luvio.storeLookup({
1927
+ recordId: key,
1928
+ node: select$2(),
1929
+ variables: {},
1930
+ }, snapshotRefresh);
1931
+ if (process.env.NODE_ENV !== 'production') {
1932
+ if (snapshot.state !== 'Fulfilled') {
1933
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1934
+ }
1935
+ }
1936
+ return snapshot;
1937
+ }
1938
+ function ingestError$2(luvio, params, error, snapshotRefresh) {
1939
+ const key = keyBuilder$5(luvio, params);
1940
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
1941
+ luvio.storeIngestError(key, errorSnapshot);
1942
+ return errorSnapshot;
1943
+ }
1944
+ function createResourceRequest$2(config) {
1945
+ const headers = {};
1946
+ return {
1947
+ baseUri: '/services/data/v58.0',
1948
+ basePath: '/connect/communities/' + config.urlParams.communityId + '/managed-content/delivery/contents',
1949
+ method: 'get',
1950
+ body: null,
1951
+ urlParams: config.urlParams,
1952
+ queryParams: config.queryParams,
1953
+ headers,
1954
+ priority: 'normal',
1955
+ };
1956
+ }
1957
+
1958
+ const listContentInternal_ConfigPropertyNames = {
1959
+ displayName: 'listContentInternal',
1960
+ parameters: {
1961
+ required: ['communityId'],
1962
+ optional: ['collectionName', 'contentKeys', 'language', 'managedContentIds', 'managedContentType', 'page', 'pageSize', 'queryTerm', 'topics', 'urlNameInList']
1963
+ }
1964
+ };
1965
+ function createResourceParams$2(config) {
1966
+ const resourceParams = {
1967
+ urlParams: {
1968
+ communityId: config.communityId
1969
+ },
1970
+ queryParams: {
1971
+ collectionName: config.collectionName, contentKeys: config.contentKeys, language: config.language, managedContentIds: config.managedContentIds, managedContentType: config.managedContentType, page: config.page, pageSize: config.pageSize, queryTerm: config.queryTerm, topics: config.topics, urlNameInList: config.urlNameInList
1972
+ }
1973
+ };
1974
+ return resourceParams;
1975
+ }
1976
+ function keyBuilder$4(luvio, config) {
1977
+ const resourceParams = createResourceParams$2(config);
1978
+ return keyBuilder$5(luvio, resourceParams);
1979
+ }
1980
+ function typeCheckConfig$2(untrustedConfig) {
1981
+ const config = {};
1982
+ const untrustedConfig_communityId = untrustedConfig.communityId;
1983
+ if (typeof untrustedConfig_communityId === 'string') {
1984
+ config.communityId = untrustedConfig_communityId;
1985
+ }
1986
+ const untrustedConfig_collectionName = untrustedConfig.collectionName;
1987
+ if (typeof untrustedConfig_collectionName === 'string') {
1988
+ config.collectionName = untrustedConfig_collectionName;
1989
+ }
1990
+ const untrustedConfig_contentKeys = untrustedConfig.contentKeys;
1991
+ if (ArrayIsArray$1(untrustedConfig_contentKeys)) {
1992
+ const untrustedConfig_contentKeys_array = [];
1993
+ for (let i = 0, arrayLength = untrustedConfig_contentKeys.length; i < arrayLength; i++) {
1994
+ const untrustedConfig_contentKeys_item = untrustedConfig_contentKeys[i];
1995
+ if (typeof untrustedConfig_contentKeys_item === 'string') {
1996
+ untrustedConfig_contentKeys_array.push(untrustedConfig_contentKeys_item);
1997
+ }
1998
+ }
1999
+ config.contentKeys = untrustedConfig_contentKeys_array;
2000
+ }
2001
+ const untrustedConfig_language = untrustedConfig.language;
2002
+ if (typeof untrustedConfig_language === 'string') {
2003
+ config.language = untrustedConfig_language;
2004
+ }
2005
+ const untrustedConfig_managedContentIds = untrustedConfig.managedContentIds;
2006
+ if (ArrayIsArray$1(untrustedConfig_managedContentIds)) {
2007
+ const untrustedConfig_managedContentIds_array = [];
2008
+ for (let i = 0, arrayLength = untrustedConfig_managedContentIds.length; i < arrayLength; i++) {
2009
+ const untrustedConfig_managedContentIds_item = untrustedConfig_managedContentIds[i];
2010
+ if (typeof untrustedConfig_managedContentIds_item === 'string') {
2011
+ untrustedConfig_managedContentIds_array.push(untrustedConfig_managedContentIds_item);
2012
+ }
2013
+ }
2014
+ config.managedContentIds = untrustedConfig_managedContentIds_array;
2015
+ }
2016
+ const untrustedConfig_managedContentType = untrustedConfig.managedContentType;
2017
+ if (typeof untrustedConfig_managedContentType === 'string') {
2018
+ config.managedContentType = untrustedConfig_managedContentType;
2019
+ }
2020
+ const untrustedConfig_page = untrustedConfig.page;
2021
+ if (typeof untrustedConfig_page === 'number' && Math.floor(untrustedConfig_page) === untrustedConfig_page) {
2022
+ config.page = untrustedConfig_page;
2023
+ }
2024
+ const untrustedConfig_pageSize = untrustedConfig.pageSize;
2025
+ if (typeof untrustedConfig_pageSize === 'number' && Math.floor(untrustedConfig_pageSize) === untrustedConfig_pageSize) {
2026
+ config.pageSize = untrustedConfig_pageSize;
2027
+ }
2028
+ const untrustedConfig_queryTerm = untrustedConfig.queryTerm;
2029
+ if (typeof untrustedConfig_queryTerm === 'string') {
2030
+ config.queryTerm = untrustedConfig_queryTerm;
2031
+ }
2032
+ const untrustedConfig_topics = untrustedConfig.topics;
2033
+ if (ArrayIsArray$1(untrustedConfig_topics)) {
2034
+ const untrustedConfig_topics_array = [];
2035
+ for (let i = 0, arrayLength = untrustedConfig_topics.length; i < arrayLength; i++) {
2036
+ const untrustedConfig_topics_item = untrustedConfig_topics[i];
2037
+ if (typeof untrustedConfig_topics_item === 'string') {
2038
+ untrustedConfig_topics_array.push(untrustedConfig_topics_item);
2039
+ }
2040
+ }
2041
+ config.topics = untrustedConfig_topics_array;
2042
+ }
2043
+ const untrustedConfig_urlNameInList = untrustedConfig.urlNameInList;
2044
+ if (ArrayIsArray$1(untrustedConfig_urlNameInList)) {
2045
+ const untrustedConfig_urlNameInList_array = [];
2046
+ for (let i = 0, arrayLength = untrustedConfig_urlNameInList.length; i < arrayLength; i++) {
2047
+ const untrustedConfig_urlNameInList_item = untrustedConfig_urlNameInList[i];
2048
+ if (typeof untrustedConfig_urlNameInList_item === 'string') {
2049
+ untrustedConfig_urlNameInList_array.push(untrustedConfig_urlNameInList_item);
2050
+ }
2051
+ }
2052
+ config.urlNameInList = untrustedConfig_urlNameInList_array;
2053
+ }
2054
+ return config;
2055
+ }
2056
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
2057
+ if (!untrustedIsObject(untrustedConfig)) {
2058
+ return null;
2059
+ }
2060
+ if (process.env.NODE_ENV !== 'production') {
2061
+ validateConfig(untrustedConfig, configPropertyNames);
2062
+ }
2063
+ const config = typeCheckConfig$2(untrustedConfig);
2064
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
2065
+ return null;
2066
+ }
2067
+ return config;
2068
+ }
2069
+ function adapterFragment$2(luvio, config) {
2070
+ createResourceParams$2(config);
2071
+ return select$2();
2072
+ }
2073
+ function onFetchResponseSuccess$4(luvio, config, resourceParams, response) {
2074
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response, {
2075
+ config,
2076
+ resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
2077
+ });
2078
+ return luvio.storeBroadcast().then(() => snapshot);
2079
+ }
2080
+ function onFetchResponseError$2(luvio, config, resourceParams, response) {
2081
+ const snapshot = ingestError$2(luvio, resourceParams, response, {
2082
+ config,
2083
+ resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
2084
+ });
2085
+ return luvio.storeBroadcast().then(() => snapshot);
2086
+ }
2087
+ function buildNetworkSnapshot$2(luvio, config, options) {
2088
+ const resourceParams = createResourceParams$2(config);
2089
+ const request = createResourceRequest$2(resourceParams);
2090
+ return luvio.dispatchResourceRequest(request, options)
2091
+ .then((response) => {
2092
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$4(luvio, config, resourceParams, response), () => getResponseCacheKeys$2(luvio, resourceParams, response.body));
2093
+ }, (response) => {
2094
+ return luvio.handleErrorResponse(() => onFetchResponseError$2(luvio, config, resourceParams, response));
2095
+ });
2096
+ }
2097
+ function buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext) {
2098
+ const { luvio, config } = context;
2099
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
2100
+ const dispatchOptions = {
2101
+ resourceRequestContext: {
2102
+ requestCorrelator,
2103
+ luvioRequestMethod: undefined,
2104
+ },
2105
+ eventObservers
2106
+ };
2107
+ if (networkPriority !== 'normal') {
2108
+ dispatchOptions.overrides = {
2109
+ priority: networkPriority
2110
+ };
2111
+ }
2112
+ return buildNetworkSnapshot$2(luvio, config, dispatchOptions);
2113
+ }
2114
+ function buildCachedSnapshotCachePolicy$2(context, storeLookup) {
2115
+ const { luvio, config } = context;
2116
+ const selector = {
2117
+ recordId: keyBuilder$4(luvio, config),
2118
+ node: adapterFragment$2(luvio, config),
2119
+ variables: {},
2120
+ };
2121
+ const cacheSnapshot = storeLookup(selector, {
2122
+ config,
2123
+ resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
2124
+ });
2125
+ return cacheSnapshot;
2126
+ }
2127
+ const listContentInternalAdapterFactory = (luvio) => function CMS__listContentInternal(untrustedConfig, requestContext) {
2128
+ const config = validateAdapterConfig$2(untrustedConfig, listContentInternal_ConfigPropertyNames);
2129
+ // Invalid or incomplete config
2130
+ if (config === null) {
2131
+ return null;
2132
+ }
2133
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
2134
+ buildCachedSnapshotCachePolicy$2, buildNetworkSnapshotCachePolicy$2);
2135
+ };
2136
+
2137
+ function select$1(luvio, params) {
2138
+ return select$a();
2139
+ }
2140
+ function keyBuilder$3(luvio, params) {
2141
+ return keyPrefix + '::ManagedContentCollectionItemsRepresentation:(' + 'language:' + params.queryParams.language + ',' + 'collectionKeyOrId:' + params.urlParams.collectionKeyOrId + ',' + 'siteId:' + params.urlParams.siteId + ')';
2142
+ }
2143
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
2144
+ return getTypeCacheKeys$4(luvio, response, () => keyBuilder$3(luvio, resourceParams));
2145
+ }
2146
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
2147
+ const { body } = response;
2148
+ const key = keyBuilder$3(luvio, resourceParams);
2149
+ luvio.storeIngest(key, ingest$4, body);
2150
+ const snapshot = luvio.storeLookup({
2151
+ recordId: key,
2152
+ node: select$1(),
2153
+ variables: {},
2154
+ }, snapshotRefresh);
2155
+ if (process.env.NODE_ENV !== 'production') {
2156
+ if (snapshot.state !== 'Fulfilled') {
2157
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
2158
+ }
2159
+ }
2160
+ return snapshot;
2161
+ }
2162
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
2163
+ const key = keyBuilder$3(luvio, params);
2164
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
2165
+ const storeMetadataParams = {
2166
+ ttl: TTL$3,
2167
+ namespace: keyPrefix,
2168
+ version: VERSION$4,
2169
+ representationName: RepresentationType$4
2170
+ };
2171
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
2172
+ return errorSnapshot;
2173
+ }
2174
+ function createResourceRequest$1(config) {
2175
+ const headers = {};
2176
+ return {
2177
+ baseUri: '/services/data/v58.0',
2178
+ basePath: '/connect/sites/' + config.urlParams.siteId + '/cms/delivery/collections/' + config.urlParams.collectionKeyOrId + '',
2179
+ method: 'get',
2180
+ body: null,
2181
+ urlParams: config.urlParams,
2182
+ queryParams: config.queryParams,
2183
+ headers,
2184
+ priority: 'normal',
2185
+ };
2186
+ }
2187
+
2188
+ function onFetchResponseSuccess$3(luvio, config, resourceParams, response) {
2189
+ let updatedResourceParams = resourceParams;
2190
+ // If language is not provided in request resource params, use language from the response
2191
+ // and update the response params. As this resource params will be used to build a cache key.
2192
+ if (updatedResourceParams.queryParams.language === undefined) {
2193
+ updatedResourceParams.queryParams.language = response.body.language;
2194
+ }
2195
+ return onFetchResponseSuccess$2(luvio, config, updatedResourceParams, response);
2196
+ }
2197
+
2198
+ const getCollectionItemsForSite_ConfigPropertyNames = {
2199
+ displayName: 'getCollectionItemsForSite',
2200
+ parameters: {
2201
+ required: ['collectionKeyOrId', 'siteId'],
2202
+ optional: ['language']
2203
+ }
2204
+ };
2205
+ function createResourceParams$1(config) {
2206
+ const resourceParams = {
2207
+ urlParams: {
2208
+ collectionKeyOrId: config.collectionKeyOrId, siteId: config.siteId
2209
+ },
2210
+ queryParams: {
2211
+ language: config.language
2212
+ }
2213
+ };
2214
+ return resourceParams;
2215
+ }
2216
+ function keyBuilder$2(luvio, config) {
2217
+ const resourceParams = createResourceParams$1(config);
2218
+ return keyBuilder$3(luvio, resourceParams);
2219
+ }
2220
+ function typeCheckConfig$1(untrustedConfig) {
2221
+ const config = {};
2222
+ const untrustedConfig_collectionKeyOrId = untrustedConfig.collectionKeyOrId;
2223
+ if (typeof untrustedConfig_collectionKeyOrId === 'string') {
2224
+ config.collectionKeyOrId = untrustedConfig_collectionKeyOrId;
2225
+ }
2226
+ const untrustedConfig_siteId = untrustedConfig.siteId;
2227
+ if (typeof untrustedConfig_siteId === 'string') {
2228
+ config.siteId = untrustedConfig_siteId;
2229
+ }
2230
+ const untrustedConfig_language = untrustedConfig.language;
2231
+ if (typeof untrustedConfig_language === 'string') {
2232
+ config.language = untrustedConfig_language;
2233
+ }
2234
+ return config;
2235
+ }
2236
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
2237
+ if (!untrustedIsObject(untrustedConfig)) {
2238
+ return null;
2239
+ }
2240
+ if (process.env.NODE_ENV !== 'production') {
2241
+ validateConfig(untrustedConfig, configPropertyNames);
2242
+ }
2243
+ const config = typeCheckConfig$1(untrustedConfig);
2244
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
2245
+ return null;
2246
+ }
2247
+ return config;
2248
+ }
2249
+ function adapterFragment$1(luvio, config) {
2250
+ createResourceParams$1(config);
2251
+ return select$1();
2252
+ }
2253
+ function onFetchResponseSuccess$2(luvio, config, resourceParams, response) {
2254
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
2255
+ config,
2256
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
2257
+ });
2258
+ return luvio.storeBroadcast().then(() => snapshot);
2259
+ }
2260
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
2261
+ const snapshot = ingestError$1(luvio, resourceParams, response, {
2262
+ config,
2263
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
2264
+ });
2265
+ return luvio.storeBroadcast().then(() => snapshot);
2266
+ }
2267
+ function buildNetworkSnapshot$1(luvio, config, options) {
2268
+ const resourceParams = createResourceParams$1(config);
2269
+ const request = createResourceRequest$1(resourceParams);
2270
+ return luvio.dispatchResourceRequest(request, options)
2271
+ .then((response) => {
2272
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$3(luvio, config, resourceParams, response), () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
2273
+ }, (response) => {
2274
+ return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
2275
+ });
2276
+ }
2277
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
2278
+ const { luvio, config } = context;
2279
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
2280
+ const dispatchOptions = {
2281
+ resourceRequestContext: {
2282
+ requestCorrelator,
2283
+ luvioRequestMethod: undefined,
2284
+ },
2285
+ eventObservers
2286
+ };
2287
+ if (networkPriority !== 'normal') {
2288
+ dispatchOptions.overrides = {
2289
+ priority: networkPriority
2290
+ };
2291
+ }
2292
+ return buildNetworkSnapshot$1(luvio, config, dispatchOptions);
2293
+ }
2294
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
2295
+ const { luvio, config } = context;
2296
+ const selector = {
2297
+ recordId: keyBuilder$2(luvio, config),
2298
+ node: adapterFragment$1(luvio, config),
2299
+ variables: {},
2300
+ };
2301
+ const cacheSnapshot = storeLookup(selector, {
2302
+ config,
2303
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
2304
+ });
2305
+ return cacheSnapshot;
2306
+ }
2307
+ const getCollectionItemsForSiteAdapterFactory = (luvio) => function CMS__getCollectionItemsForSite(untrustedConfig, requestContext) {
2308
+ const config = validateAdapterConfig$1(untrustedConfig, getCollectionItemsForSite_ConfigPropertyNames);
2309
+ // Invalid or incomplete config
2310
+ if (config === null) {
2311
+ return null;
2312
+ }
2313
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
2314
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
2315
+ };
2316
+
2317
+ function select(luvio, params) {
2318
+ return select$8();
2319
+ }
2320
+ function keyBuilder$1(luvio, params) {
2321
+ return keyPrefix + '::ManagedContentCollectionMetadataRepresentation:(' + 'expandMetadata:' + params.queryParams.expandMetadata + ',' + 'language:' + params.queryParams.language + ',' + 'collectionKeyOrId:' + params.urlParams.collectionKeyOrId + ',' + 'siteId:' + params.urlParams.siteId + ')';
2322
+ }
2323
+ function getResponseCacheKeys(luvio, resourceParams, response) {
2324
+ return getTypeCacheKeys$3(luvio, response, () => keyBuilder$1(luvio, resourceParams));
2325
+ }
2326
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
2327
+ const { body } = response;
2328
+ const key = keyBuilder$1(luvio, resourceParams);
2329
+ luvio.storeIngest(key, ingest$3, body);
2330
+ const snapshot = luvio.storeLookup({
2331
+ recordId: key,
2332
+ node: select(),
2333
+ variables: {},
2334
+ }, snapshotRefresh);
2335
+ if (process.env.NODE_ENV !== 'production') {
2336
+ if (snapshot.state !== 'Fulfilled') {
2337
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
2338
+ }
2339
+ }
2340
+ return snapshot;
2341
+ }
2342
+ function ingestError(luvio, params, error, snapshotRefresh) {
2343
+ const key = keyBuilder$1(luvio, params);
2344
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
2345
+ const storeMetadataParams = {
2346
+ ttl: TTL$2,
2347
+ namespace: keyPrefix,
2348
+ version: VERSION$3,
2349
+ representationName: RepresentationType$3
2350
+ };
2351
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
2352
+ return errorSnapshot;
2353
+ }
2354
+ function createResourceRequest(config) {
2355
+ const headers = {};
2356
+ return {
2357
+ baseUri: '/services/data/v58.0',
2358
+ basePath: '/connect/sites/' + config.urlParams.siteId + '/cms/delivery/collections/' + config.urlParams.collectionKeyOrId + '/metadata',
2359
+ method: 'get',
2360
+ body: null,
2361
+ urlParams: config.urlParams,
2362
+ queryParams: config.queryParams,
2363
+ headers,
2364
+ priority: 'normal',
2365
+ };
2366
+ }
2367
+
2368
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
2369
+ let updatedResourceParams = resourceParams;
2370
+ // If language is not provided in request resource params, use language from the response
2371
+ // and update the response params. As this resource params will be used to build a cache key.
2372
+ if (updatedResourceParams.queryParams.language === undefined) {
2373
+ updatedResourceParams.queryParams.language = response.body.language;
2374
+ }
2375
+ return onFetchResponseSuccess(luvio, config, updatedResourceParams, response);
2376
+ }
2377
+
2378
+ const getCollectionMetadataForSite_ConfigPropertyNames = {
2379
+ displayName: 'getCollectionMetadataForSite',
2380
+ parameters: {
2381
+ required: ['collectionKeyOrId', 'siteId'],
2382
+ optional: ['expandMetadata', 'language']
2383
+ }
2384
+ };
2385
+ function createResourceParams(config) {
2386
+ const resourceParams = {
2387
+ urlParams: {
2388
+ collectionKeyOrId: config.collectionKeyOrId, siteId: config.siteId
2389
+ },
2390
+ queryParams: {
2391
+ expandMetadata: config.expandMetadata, language: config.language
2392
+ }
2393
+ };
2394
+ return resourceParams;
2395
+ }
2396
+ function keyBuilder(luvio, config) {
2397
+ const resourceParams = createResourceParams(config);
2398
+ return keyBuilder$1(luvio, resourceParams);
2399
+ }
2400
+ function typeCheckConfig(untrustedConfig) {
2401
+ const config = {};
2402
+ const untrustedConfig_collectionKeyOrId = untrustedConfig.collectionKeyOrId;
2403
+ if (typeof untrustedConfig_collectionKeyOrId === 'string') {
2404
+ config.collectionKeyOrId = untrustedConfig_collectionKeyOrId;
2405
+ }
2406
+ const untrustedConfig_siteId = untrustedConfig.siteId;
2407
+ if (typeof untrustedConfig_siteId === 'string') {
2408
+ config.siteId = untrustedConfig_siteId;
2409
+ }
2410
+ const untrustedConfig_expandMetadata = untrustedConfig.expandMetadata;
2411
+ if (typeof untrustedConfig_expandMetadata === 'boolean') {
2412
+ config.expandMetadata = untrustedConfig_expandMetadata;
2413
+ }
2414
+ const untrustedConfig_language = untrustedConfig.language;
2415
+ if (typeof untrustedConfig_language === 'string') {
2416
+ config.language = untrustedConfig_language;
2417
+ }
2418
+ return config;
2419
+ }
2420
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
2421
+ if (!untrustedIsObject(untrustedConfig)) {
2422
+ return null;
2423
+ }
2424
+ if (process.env.NODE_ENV !== 'production') {
2425
+ validateConfig(untrustedConfig, configPropertyNames);
2426
+ }
2427
+ const config = typeCheckConfig(untrustedConfig);
2428
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
2429
+ return null;
2430
+ }
2431
+ return config;
2432
+ }
2433
+ function adapterFragment(luvio, config) {
2434
+ createResourceParams(config);
2435
+ return select();
2436
+ }
2437
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
2438
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
2439
+ config,
2440
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
2441
+ });
2442
+ return luvio.storeBroadcast().then(() => snapshot);
2443
+ }
2444
+ function onFetchResponseError(luvio, config, resourceParams, response) {
2445
+ const snapshot = ingestError(luvio, resourceParams, response, {
2446
+ config,
2447
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
2448
+ });
2449
+ return luvio.storeBroadcast().then(() => snapshot);
2450
+ }
2451
+ function buildNetworkSnapshot(luvio, config, options) {
2452
+ const resourceParams = createResourceParams(config);
2453
+ const request = createResourceRequest(resourceParams);
2454
+ return luvio.dispatchResourceRequest(request, options)
2455
+ .then((response) => {
2456
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
2457
+ }, (response) => {
2458
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
2459
+ });
2460
+ }
2461
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
2462
+ const { luvio, config } = context;
2463
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
2464
+ const dispatchOptions = {
2465
+ resourceRequestContext: {
2466
+ requestCorrelator,
2467
+ luvioRequestMethod: undefined,
2468
+ },
2469
+ eventObservers
2470
+ };
2471
+ if (networkPriority !== 'normal') {
2472
+ dispatchOptions.overrides = {
2473
+ priority: networkPriority
2474
+ };
2475
+ }
2476
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
2477
+ }
2478
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
2479
+ const { luvio, config } = context;
2480
+ const selector = {
2481
+ recordId: keyBuilder(luvio, config),
2482
+ node: adapterFragment(luvio, config),
2483
+ variables: {},
2484
+ };
2485
+ const cacheSnapshot = storeLookup(selector, {
2486
+ config,
2487
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
2488
+ });
2489
+ return cacheSnapshot;
2490
+ }
2491
+ const getCollectionMetadataForSiteAdapterFactory = (luvio) => function CMS__getCollectionMetadataForSite(untrustedConfig, requestContext) {
2492
+ const config = validateAdapterConfig(untrustedConfig, getCollectionMetadataForSite_ConfigPropertyNames);
2493
+ // Invalid or incomplete config
2494
+ if (config === null) {
2495
+ return null;
2496
+ }
2497
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
2498
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
2499
+ };
2500
+
2501
+ export { getCollectionItemsForChannelAdapterFactory, getCollectionItemsForSiteAdapterFactory, getCollectionMetadataForChannelAdapterFactory, getCollectionMetadataForSiteAdapterFactory, listContentAdapterFactory, listContentInternalAdapterFactory };