@webiny/api-headless-cms-ddb-es 6.3.0 → 6.4.0-beta.1

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 (217) hide show
  1. package/configurations.js +27 -35
  2. package/configurations.js.map +1 -1
  3. package/definitions/entry.js +7 -9
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.js +7 -9
  6. package/definitions/group.js.map +1 -1
  7. package/definitions/model.js +7 -9
  8. package/definitions/model.js.map +1 -1
  9. package/definitions/types.d.ts +1 -0
  10. package/definitions/types.js +0 -3
  11. package/elasticsearch/createElasticsearchIndex.js +50 -67
  12. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  13. package/elasticsearch/deleteElasticsearchIndex.js +18 -26
  14. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  15. package/exports/api/cms/opensearch.js +2 -4
  16. package/feature.js +144 -153
  17. package/feature.js.map +1 -1
  18. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +2 -1
  19. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -1
  20. package/features/CmsEntryOpenSearchBodyModifier/index.js +0 -2
  21. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +2 -1
  22. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +33 -27
  23. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
  24. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +0 -3
  25. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +2 -1
  26. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -1
  27. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +2 -1
  28. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
  29. package/features/CmsEntryOpenSearchFieldIndex/constants.js +2 -1
  30. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -1
  31. package/features/CmsEntryOpenSearchFieldIndex/feature.js +15 -12
  32. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -1
  33. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +48 -65
  34. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
  35. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +5 -2
  36. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +24 -30
  37. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -1
  38. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +15 -16
  39. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -1
  40. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +15 -18
  41. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -1
  42. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +24 -29
  43. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -1
  44. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +4 -2
  45. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +95 -146
  46. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -1
  47. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +15 -16
  48. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -1
  49. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +14 -0
  50. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +39 -0
  51. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -0
  52. package/features/CmsEntryOpenSearchFieldIndex/index.js +0 -2
  53. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +26 -28
  54. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
  55. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +2 -1
  56. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -1
  57. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +2 -1
  58. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
  59. package/features/CmsEntryOpenSearchFilter/constants.js +2 -1
  60. package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -1
  61. package/features/CmsEntryOpenSearchFilter/feature.js +9 -8
  62. package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -1
  63. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +18 -15
  64. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -1
  65. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +35 -53
  66. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -1
  67. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +27 -40
  68. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -1
  69. package/features/CmsEntryOpenSearchFilter/index.js +0 -2
  70. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +2 -1
  71. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -1
  72. package/features/CmsEntryOpenSearchFullTextSearch/index.js +0 -2
  73. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +10 -9
  74. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -1
  75. package/features/CmsEntryOpenSearchIndex/abstractions.js +2 -1
  76. package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -1
  77. package/features/CmsEntryOpenSearchIndex/feature.js +6 -5
  78. package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -1
  79. package/features/CmsEntryOpenSearchIndex/index.js +0 -2
  80. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +2 -1
  81. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -1
  82. package/features/CmsEntryOpenSearchQueryModifier/index.js +0 -2
  83. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +2 -1
  84. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -1
  85. package/features/CmsEntryOpenSearchSortModifier/index.js +0 -2
  86. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +24 -20
  87. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
  88. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +2 -1
  89. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -1
  90. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +2 -1
  91. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
  92. package/features/CmsEntryOpenSearchValueSearch/feature.js +9 -8
  93. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -1
  94. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +14 -16
  95. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -1
  96. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +31 -42
  97. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
  98. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +15 -17
  99. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -1
  100. package/features/CmsEntryOpenSearchValueSearch/index.js +0 -2
  101. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +2 -1
  102. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -1
  103. package/features/CmsEntryOpenSearchValuesModifier/index.js +0 -2
  104. package/helpers/entryIndexHelpers.d.ts +1 -1
  105. package/helpers/entryIndexHelpers.js +69 -123
  106. package/helpers/entryIndexHelpers.js.map +1 -1
  107. package/helpers/fieldIdentifier.js +18 -30
  108. package/helpers/fieldIdentifier.js.map +1 -1
  109. package/helpers/index.js +0 -2
  110. package/index.js +0 -2
  111. package/operations/entry/dataLoader/DataLoaderCache.js +22 -26
  112. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  113. package/operations/entry/dataLoader/constants.js +2 -1
  114. package/operations/entry/dataLoader/constants.js.map +1 -1
  115. package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
  116. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  117. package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -29
  118. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  119. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +27 -37
  120. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  121. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +27 -37
  122. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  123. package/operations/entry/dataLoader/getRevisionById.js +32 -46
  124. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  125. package/operations/entry/dataLoader/index.js +8 -9
  126. package/operations/entry/dataLoader/index.js.map +1 -1
  127. package/operations/entry/dataLoader/types.js +0 -3
  128. package/operations/entry/dataLoaders.js +81 -99
  129. package/operations/entry/dataLoaders.js.map +1 -1
  130. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +6 -24
  131. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  132. package/operations/entry/elasticsearch/body.js +74 -125
  133. package/operations/entry/elasticsearch/body.js.map +1 -1
  134. package/operations/entry/elasticsearch/fields/createSystemField.js +6 -7
  135. package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -1
  136. package/operations/entry/elasticsearch/fields/live.js +45 -40
  137. package/operations/entry/elasticsearch/fields/live.js.map +1 -1
  138. package/operations/entry/elasticsearch/fields/location.js +45 -40
  139. package/operations/entry/elasticsearch/fields/location.js.map +1 -1
  140. package/operations/entry/elasticsearch/fields/state.js +99 -88
  141. package/operations/entry/elasticsearch/fields/state.js.map +1 -1
  142. package/operations/entry/elasticsearch/fields.js +193 -217
  143. package/operations/entry/elasticsearch/fields.js.map +1 -1
  144. package/operations/entry/elasticsearch/filtering/applyFiltering.js +32 -45
  145. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  146. package/operations/entry/elasticsearch/filtering/exec.js +85 -114
  147. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  148. package/operations/entry/elasticsearch/filtering/index.js +0 -2
  149. package/operations/entry/elasticsearch/filtering/path.js +24 -33
  150. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  151. package/operations/entry/elasticsearch/filtering/populated.js +8 -14
  152. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  153. package/operations/entry/elasticsearch/filtering/values.js +11 -12
  154. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  155. package/operations/entry/elasticsearch/fullTextSearch.js +43 -80
  156. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  157. package/operations/entry/elasticsearch/fullTextSearchFields.js +7 -17
  158. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  159. package/operations/entry/elasticsearch/initialQuery.js +37 -80
  160. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  161. package/operations/entry/elasticsearch/keyword.js +13 -27
  162. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  163. package/operations/entry/elasticsearch/plugins/operator.js +9 -20
  164. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  165. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -4
  166. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
  167. package/operations/entry/elasticsearch/sort.js +69 -92
  168. package/operations/entry/elasticsearch/sort.js.map +1 -1
  169. package/operations/entry/elasticsearch/transformValueForSearch.js +9 -14
  170. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  171. package/operations/entry/elasticsearch/types.js +0 -3
  172. package/operations/entry/index.js +1313 -1709
  173. package/operations/entry/index.js.map +1 -1
  174. package/operations/entry/keys.js +43 -63
  175. package/operations/entry/keys.js.map +1 -1
  176. package/operations/entry/recordType.js +4 -9
  177. package/operations/entry/recordType.js.map +1 -1
  178. package/operations/entry/transformations/convertEntryKeys.js +21 -26
  179. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  180. package/operations/entry/transformations/index.d.ts +0 -2
  181. package/operations/entry/transformations/index.js +84 -114
  182. package/operations/entry/transformations/index.js.map +1 -1
  183. package/operations/entry/transformations/modifyEntryValues.d.ts +1 -1
  184. package/operations/entry/transformations/modifyEntryValues.js +12 -17
  185. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  186. package/operations/entry/transformations/transformEntryKeys.js +13 -16
  187. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  188. package/operations/entry/transformations/transformEntryToIndex.d.ts +0 -2
  189. package/operations/entry/transformations/transformEntryToIndex.js +16 -22
  190. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  191. package/operations/group/index.js +113 -134
  192. package/operations/group/index.js.map +1 -1
  193. package/operations/model/index.js +128 -156
  194. package/operations/model/index.js.map +1 -1
  195. package/package.json +24 -24
  196. package/tasks/createIndexTaskPlugin.js +35 -38
  197. package/tasks/createIndexTaskPlugin.js.map +1 -1
  198. package/types.js +7 -13
  199. package/types.js.map +1 -1
  200. package/values/NoValueContainer.js +8 -10
  201. package/values/NoValueContainer.js.map +1 -1
  202. package/definitions/types.js.map +0 -1
  203. package/exports/api/cms/opensearch.js.map +0 -1
  204. package/features/CmsEntryOpenSearchBodyModifier/index.js.map +0 -1
  205. package/features/CmsEntryOpenSearchFieldIndex/index.js.map +0 -1
  206. package/features/CmsEntryOpenSearchFilter/index.js.map +0 -1
  207. package/features/CmsEntryOpenSearchFullTextSearch/index.js.map +0 -1
  208. package/features/CmsEntryOpenSearchIndex/index.js.map +0 -1
  209. package/features/CmsEntryOpenSearchQueryModifier/index.js.map +0 -1
  210. package/features/CmsEntryOpenSearchSortModifier/index.js.map +0 -1
  211. package/features/CmsEntryOpenSearchValueSearch/index.js.map +0 -1
  212. package/features/CmsEntryOpenSearchValuesModifier/index.js.map +0 -1
  213. package/helpers/index.js.map +0 -1
  214. package/index.js.map +0 -1
  215. package/operations/entry/dataLoader/types.js.map +0 -1
  216. package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
  217. package/operations/entry/elasticsearch/types.js.map +0 -1
@@ -1,23 +1,21 @@
1
1
  import { CmsEntryOpenSearchValueSearch } from "../abstractions/CmsEntryOpenSearchValueSearch.js";
2
2
  class RefSearchImpl {
3
- fieldType = "ref";
4
- transform(params) {
5
- return params.value;
6
- }
7
- createPath(params) {
8
- const {
9
- field,
10
- key
11
- } = params;
12
- if (key && key.match("entryId") === null) {
13
- return `${field.storageId}.id`;
3
+ transform(params) {
4
+ return params.value;
5
+ }
6
+ createPath(params) {
7
+ const { field, key } = params;
8
+ if (key && null === key.match("entryId")) return `${field.storageId}.id`;
9
+ return `${field.storageId}.entryId`;
10
+ }
11
+ constructor(){
12
+ this.fieldType = "ref";
14
13
  }
15
- return `${field.storageId}.entryId`;
16
- }
17
14
  }
18
- export const RefSearch = CmsEntryOpenSearchValueSearch.createImplementation({
19
- implementation: RefSearchImpl,
20
- dependencies: []
15
+ const RefSearch = CmsEntryOpenSearchValueSearch.createImplementation({
16
+ implementation: RefSearchImpl,
17
+ dependencies: []
21
18
  });
19
+ export { RefSearch };
22
20
 
23
21
  //# sourceMappingURL=RefSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CmsEntryOpenSearchValueSearch","RefSearchImpl","fieldType","transform","params","value","createPath","field","key","match","storageId","RefSearch","createImplementation","implementation","dependencies"],"sources":["RefSearch.ts"],"sourcesContent":["import { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\n\nclass RefSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"ref\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n return params.value;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field, key } = params;\n if (key && key.match(\"entryId\") === null) {\n return `${field.storageId}.id`;\n }\n return `${field.storageId}.entryId`;\n }\n}\n\nexport const RefSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: RefSearchImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,6BAA6B;AAEtC,MAAMC,aAAa,CAAoD;EACnDC,SAAS,GAAG,KAAK;EAE1BC,SAASA,CAACC,MAA+C,EAAO;IACnE,OAAOA,MAAM,CAACC,KAAK;EACvB;EAEOC,UAAUA,CAACF,MAAgD,EAAiB;IAC/E,MAAM;MAAEG,KAAK;MAAEC;IAAI,CAAC,GAAGJ,MAAM;IAC7B,IAAII,GAAG,IAAIA,GAAG,CAACC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;MACtC,OAAO,GAAGF,KAAK,CAACG,SAAS,KAAK;IAClC;IACA,OAAO,GAAGH,KAAK,CAACG,SAAS,UAAU;EACvC;AACJ;AAEA,OAAO,MAAMC,SAAS,GAAGX,6BAA6B,CAACY,oBAAoB,CAAC;EACxEC,cAAc,EAAEZ,aAAa;EAC7Ba,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.ts"],"sourcesContent":["import { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\n\nclass RefSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"ref\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n return params.value;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field, key } = params;\n if (key && key.match(\"entryId\") === null) {\n return `${field.storageId}.id`;\n }\n return `${field.storageId}.entryId`;\n }\n}\n\nexport const RefSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: RefSearchImpl,\n dependencies: []\n});\n"],"names":["RefSearchImpl","params","field","key","RefSearch","CmsEntryOpenSearchValueSearch"],"mappings":";AAEA,MAAMA;IAGK,UAAUC,MAA+C,EAAO;QACnE,OAAOA,OAAO,KAAK;IACvB;IAEO,WAAWA,MAAgD,EAAiB;QAC/E,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;QACvB,IAAIE,OAAOA,AAAyB,SAAzBA,IAAI,KAAK,CAAC,YACjB,OAAO,GAAGD,MAAM,SAAS,CAAC,GAAG,CAAC;QAElC,OAAO,GAAGA,MAAM,SAAS,CAAC,QAAQ,CAAC;IACvC;;aAZgB,SAAS,GAAG;;AAahC;AAEO,MAAME,YAAYC,8BAA8B,oBAAoB,CAAC;IACxE,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -1,55 +1,44 @@
1
1
  import { CmsEntryOpenSearchValueSearch } from "../abstractions/CmsEntryOpenSearchValueSearch.js";
2
2
  import { WebinyError } from "@webiny/error";
3
3
  import { NoValueContainer } from "../../../values/NoValueContainer.js";
4
- const getKey = params => {
5
- const {
6
- field,
7
- value
8
- } = params;
9
- const keys = Object.keys(value);
10
- if (keys.length === 0) {
11
- throw new WebinyError(`Searchable JSON field "${field.fieldId}" cannot be empty.`, "EMPTY_SEARCHABLE_JSON_FIELD", {
12
- field,
13
- value
4
+ const getKey = (params)=>{
5
+ const { field, value } = params;
6
+ const keys = Object.keys(value);
7
+ if (0 === keys.length) throw new WebinyError(`Searchable JSON field "${field.fieldId}" cannot be empty.`, "EMPTY_SEARCHABLE_JSON_FIELD", {
8
+ field,
9
+ value
14
10
  });
15
- } else if (keys.length > 1) {
16
- throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
17
- field,
18
- value,
19
- keys
11
+ if (keys.length > 1) throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
12
+ field,
13
+ value,
14
+ keys
20
15
  });
21
- }
22
- return keys[0];
16
+ return keys[0];
23
17
  };
24
18
  class SearchableJsonSearchImpl {
25
- fieldType = "searchable-json";
26
- transform(params) {
27
- const {
28
- value
29
- } = params;
30
- if (NoValueContainer.is(value)) {
31
- return null;
19
+ transform(params) {
20
+ const { value } = params;
21
+ if (NoValueContainer.is(value)) return null;
22
+ const key = getKey(params);
23
+ return value[key] || null;
32
24
  }
33
- const key = getKey(params);
34
- return value[key] || null;
35
- }
36
- createPath(params) {
37
- const {
38
- field
39
- } = params;
40
- if (NoValueContainer.is(params.originalValue)) {
41
- return `${field.storageId}.unknown`;
25
+ createPath(params) {
26
+ const { field } = params;
27
+ if (NoValueContainer.is(params.originalValue)) return `${field.storageId}.unknown`;
28
+ const key = getKey({
29
+ field,
30
+ value: params.originalValue
31
+ });
32
+ return `${field.storageId}.${key}`;
33
+ }
34
+ constructor(){
35
+ this.fieldType = "searchable-json";
42
36
  }
43
- const key = getKey({
44
- field,
45
- value: params.originalValue
46
- });
47
- return `${field.storageId}.${key}`;
48
- }
49
37
  }
50
- export const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({
51
- implementation: SearchableJsonSearchImpl,
52
- dependencies: []
38
+ const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({
39
+ implementation: SearchableJsonSearchImpl,
40
+ dependencies: []
53
41
  });
42
+ export { SearchableJsonSearch };
54
43
 
55
44
  //# sourceMappingURL=SearchableJsonSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CmsEntryOpenSearchValueSearch","WebinyError","NoValueContainer","getKey","params","field","value","keys","Object","length","fieldId","SearchableJsonSearchImpl","fieldType","transform","is","key","createPath","originalValue","storageId","SearchableJsonSearch","createImplementation","implementation","dependencies"],"sources":["SearchableJsonSearch.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nclass SearchableJsonSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"searchable-json\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n}\n\nexport const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: SearchableJsonSearchImpl,\n dependencies: []\n});\n"],"mappings":"AACA,SAASA,6BAA6B;AACtC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,gBAAgB;AASzB,MAAMC,MAAM,GAAIC,MAAqB,IAAa;EAC9C,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAC/B,MAAMG,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,KAAK,CAAC;EAC/B,IAAIC,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;IACnB,MAAM,IAAIR,WAAW,CACjB,0BAA0BI,KAAK,CAACK,OAAO,oBAAoB,EAC3D,6BAA6B,EAC7B;MACIL,KAAK;MACLC;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIC,IAAI,CAACE,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIR,WAAW,CACjB,0BAA0BI,KAAK,CAACK,OAAO,0BAA0B,EACjE,wCAAwC,EACxC;MACIL,KAAK;MACLC,KAAK;MACLC;IACJ,CACJ,CAAC;EACL;EACA,OAAOA,IAAI,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAMI,wBAAwB,CAAoD;EAC9DC,SAAS,GAAG,iBAAiB;EAEtCC,SAASA,CAACT,MAA+C,EAAO;IACnE,MAAM;MAAEE;IAAM,CAAC,GAAGF,MAAM;IAExB,IAAIF,gBAAgB,CAACY,EAAE,CAACR,KAAK,CAAC,EAAE;MAC5B,OAAO,IAAI;IACf;IAEA,MAAMS,GAAG,GAAGZ,MAAM,CAACC,MAAM,CAAC;IAC1B,OAAOE,KAAK,CAACS,GAAG,CAAC,IAAI,IAAI;EAC7B;EAEOC,UAAUA,CAACZ,MAAgD,EAAiB;IAC/E,MAAM;MAAEC;IAAM,CAAC,GAAGD,MAAM;IAExB,IAAIF,gBAAgB,CAACY,EAAE,CAACV,MAAM,CAACa,aAAa,CAAC,EAAE;MAC3C,OAAO,GAAGZ,KAAK,CAACa,SAAS,UAAU;IACvC;IAEA,MAAMH,GAAG,GAAGZ,MAAM,CAAC;MACfE,KAAK;MACLC,KAAK,EAAEF,MAAM,CAACa;IAClB,CAAC,CAAC;IAEF,OAAO,GAAGZ,KAAK,CAACa,SAAS,IAAIH,GAAG,EAAE;EACtC;AACJ;AAEA,OAAO,MAAMI,oBAAoB,GAAGnB,6BAA6B,CAACoB,oBAAoB,CAAC;EACnFC,cAAc,EAAEV,wBAAwB;EACxCW,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nclass SearchableJsonSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"searchable-json\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n}\n\nexport const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: SearchableJsonSearchImpl,\n dependencies: []\n});\n"],"names":["getKey","params","field","value","keys","Object","WebinyError","SearchableJsonSearchImpl","NoValueContainer","key","SearchableJsonSearch","CmsEntryOpenSearchValueSearch"],"mappings":";;;AAYA,MAAMA,SAAS,CAACC;IACZ,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,MAAMG,OAAOC,OAAO,IAAI,CAACF;IACzB,IAAIC,AAAgB,MAAhBA,KAAK,MAAM,EACX,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,kBAAkB,CAAC,EAC3D,+BACA;QACIA;QACAC;IACJ;IAED,IAAIC,KAAK,MAAM,GAAG,GACrB,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,wBAAwB,CAAC,EACjE,0CACA;QACIA;QACAC;QACAC;IACJ;IAGR,OAAOA,IAAI,CAAC,EAAE;AAClB;AAEA,MAAMG;IAGK,UAAUN,MAA+C,EAAO;QACnE,MAAM,EAAEE,KAAK,EAAE,GAAGF;QAElB,IAAIO,iBAAiB,EAAE,CAACL,QACpB,OAAO;QAGX,MAAMM,MAAMT,OAAOC;QACnB,OAAOE,KAAK,CAACM,IAAI,IAAI;IACzB;IAEO,WAAWR,MAAgD,EAAiB;QAC/E,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,IAAIO,iBAAiB,EAAE,CAACP,OAAO,aAAa,GACxC,OAAO,GAAGC,MAAM,SAAS,CAAC,QAAQ,CAAC;QAGvC,MAAMO,MAAMT,OAAO;YACfE;YACA,OAAOD,OAAO,aAAa;QAC/B;QAEA,OAAO,GAAGC,MAAM,SAAS,CAAC,CAAC,EAAEO,KAAK;IACtC;;aA1BgB,SAAS,GAAG;;AA2BhC;AAEO,MAAMC,uBAAuBC,8BAA8B,oBAAoB,CAAC;IACnF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -1,24 +1,22 @@
1
1
  import { CmsEntryOpenSearchValueSearch } from "../abstractions/CmsEntryOpenSearchValueSearch.js";
2
2
  class TimeSearchImpl {
3
- fieldType = "datetime";
4
- transform(params) {
5
- const {
6
- field,
7
- value
8
- } = params;
9
- if (!value || field.settings?.type !== "time") {
10
- return value;
3
+ transform(params) {
4
+ const { field, value } = params;
5
+ if (!value || field.settings?.type !== "time") return value;
6
+ const [hours, minutes, seconds = 0] = value.split(":").map(Number);
7
+ return 60 * hours * 60 + 60 * minutes + seconds;
8
+ }
9
+ createPath() {
10
+ return null;
11
+ }
12
+ constructor(){
13
+ this.fieldType = "datetime";
11
14
  }
12
- const [hours, minutes, seconds = 0] = value.split(":").map(Number);
13
- return hours * 60 * 60 + minutes * 60 + seconds;
14
- }
15
- createPath() {
16
- return null;
17
- }
18
15
  }
19
- export const TimeSearch = CmsEntryOpenSearchValueSearch.createImplementation({
20
- implementation: TimeSearchImpl,
21
- dependencies: []
16
+ const TimeSearch = CmsEntryOpenSearchValueSearch.createImplementation({
17
+ implementation: TimeSearchImpl,
18
+ dependencies: []
22
19
  });
20
+ export { TimeSearch };
23
21
 
24
22
  //# sourceMappingURL=TimeSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CmsEntryOpenSearchValueSearch","TimeSearchImpl","fieldType","transform","params","field","value","settings","type","hours","minutes","seconds","split","map","Number","createPath","TimeSearch","createImplementation","implementation","dependencies"],"sources":["TimeSearch.ts"],"sourcesContent":["import { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\n\nclass TimeSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"datetime\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { field, value } = params;\n if (!value || field.settings?.type !== \"time\") {\n return value;\n }\n const [hours, minutes, seconds = 0] = value.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n }\n\n public createPath(): string | null {\n return null;\n }\n}\n\nexport const TimeSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: TimeSearchImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,6BAA6B;AAEtC,MAAMC,cAAc,CAAoD;EACpDC,SAAS,GAAG,UAAU;EAE/BC,SAASA,CAACC,MAA+C,EAAO;IACnE,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGF,MAAM;IAC/B,IAAI,CAACE,KAAK,IAAID,KAAK,CAACE,QAAQ,EAAEC,IAAI,KAAK,MAAM,EAAE;MAC3C,OAAOF,KAAK;IAChB;IACA,MAAM,CAACG,KAAK,EAAEC,OAAO,EAAEC,OAAO,GAAG,CAAC,CAAC,GAAGL,KAAK,CAACM,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;IAClE,OAAOL,KAAK,GAAG,EAAE,GAAG,EAAE,GAAGC,OAAO,GAAG,EAAE,GAAGC,OAAO;EACnD;EAEOI,UAAUA,CAAA,EAAkB;IAC/B,OAAO,IAAI;EACf;AACJ;AAEA,OAAO,MAAMC,UAAU,GAAGhB,6BAA6B,CAACiB,oBAAoB,CAAC;EACzEC,cAAc,EAAEjB,cAAc;EAC9BkB,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.ts"],"sourcesContent":["import { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\n\nclass TimeSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"datetime\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { field, value } = params;\n if (!value || field.settings?.type !== \"time\") {\n return value;\n }\n const [hours, minutes, seconds = 0] = value.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n }\n\n public createPath(): string | null {\n return null;\n }\n}\n\nexport const TimeSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: TimeSearchImpl,\n dependencies: []\n});\n"],"names":["TimeSearchImpl","params","field","value","hours","minutes","seconds","Number","TimeSearch","CmsEntryOpenSearchValueSearch"],"mappings":";AAEA,MAAMA;IAGK,UAAUC,MAA+C,EAAO;QACnE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,IAAI,CAACE,SAASD,MAAM,QAAQ,EAAE,SAAS,QACnC,OAAOC;QAEX,MAAM,CAACC,OAAOC,SAASC,UAAU,CAAC,CAAC,GAAGH,MAAM,KAAK,CAAC,KAAK,GAAG,CAACI;QAC3D,OAAOH,AAAQ,KAARA,QAAa,KAAKC,AAAU,KAAVA,UAAeC;IAC5C;IAEO,aAA4B;QAC/B,OAAO;IACX;;aAbgB,SAAS,GAAG;;AAchC;AAEO,MAAME,aAAaC,8BAA8B,oBAAoB,CAAC;IACzE,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
@@ -1,5 +1,3 @@
1
1
  export { CmsEntryOpenSearchValueSearch } from "./abstractions/CmsEntryOpenSearchValueSearch.js";
2
2
  export { CmsEntryOpenSearchValueSearchRegistry } from "./abstractions/CmsEntryOpenSearchValueSearchRegistry.js";
3
3
  export { CmsEntryOpenSearchValueSearchFeature } from "./feature.js";
4
-
5
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const CmsEntryOpenSearchValuesModifier = createAbstraction("Cms/Entry/OpenSearch/ValuesModifier");
2
+ const CmsEntryOpenSearchValuesModifier = createAbstraction("Cms/Entry/OpenSearch/ValuesModifier");
3
+ export { CmsEntryOpenSearchValuesModifier };
3
4
 
4
5
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","CmsEntryOpenSearchValuesModifier"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface SetValuesCb<T extends CmsEntryValues = CmsEntryValues> {\n (prev: T): T;\n}\n\nexport interface ModifyValuesParams<T extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n entry: CmsEntry<T>;\n values: T;\n setValues: (cb: SetValuesCb<T>) => void;\n}\n\nexport interface ICmsEntryOpenSearchValuesModifier {\n canModify(modelId: string): boolean;\n modify<T extends CmsEntryValues = CmsEntryValues>(params: {\n model: CmsModel;\n entry: CmsEntry<T>;\n values: T;\n }): T;\n}\n\nexport const CmsEntryOpenSearchValuesModifier =\n createAbstraction<ICmsEntryOpenSearchValuesModifier>(\"Cms/Entry/OpenSearch/ValuesModifier\");\n\nexport namespace CmsEntryOpenSearchValuesModifier {\n export type Interface = ICmsEntryOpenSearchValuesModifier;\n export type Params<T extends CmsEntryValues = CmsEntryValues> = ModifyValuesParams<T>;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAuBvD,OAAO,MAAMC,gCAAgC,GACzCD,iBAAiB,CAAoC,qCAAqC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchValuesModifier/abstractions.js","sources":["../../../src/features/CmsEntryOpenSearchValuesModifier/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface SetValuesCb<T extends CmsEntryValues = CmsEntryValues> {\n (prev: T): T;\n}\n\nexport interface ModifyValuesParams<T extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n entry: CmsEntry<T>;\n values: T;\n setValues: (cb: SetValuesCb<T>) => void;\n}\n\nexport interface ICmsEntryOpenSearchValuesModifier {\n canModify(modelId: string): boolean;\n modify<T extends CmsEntryValues = CmsEntryValues>(params: {\n model: CmsModel;\n entry: CmsEntry<T>;\n values: T;\n }): T;\n}\n\nexport const CmsEntryOpenSearchValuesModifier =\n createAbstraction<ICmsEntryOpenSearchValuesModifier>(\"Cms/Entry/OpenSearch/ValuesModifier\");\n\nexport namespace CmsEntryOpenSearchValuesModifier {\n export type Interface = ICmsEntryOpenSearchValuesModifier;\n export type Params<T extends CmsEntryValues = CmsEntryValues> = ModifyValuesParams<T>;\n}\n"],"names":["CmsEntryOpenSearchValuesModifier","createAbstraction"],"mappings":";AAuBO,MAAMA,mCACTC,kBAAqD"}
@@ -1,3 +1 @@
1
1
  export { CmsEntryOpenSearchValuesModifier } from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -10,7 +10,7 @@ interface ExtractEntriesFromIndexParams<T extends CmsEntryValues = CmsEntryValue
10
10
  model: CmsModel;
11
11
  entries: CmsIndexEntry<T>[];
12
12
  }
13
- interface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues> extends SetupEntriesIndexHelpersParams {
13
+ interface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues> extends Omit<SetupEntriesIndexHelpersParams, "fieldRegistry"> {
14
14
  model: CmsModel;
15
15
  entry: CmsEntry<T>;
16
16
  storageEntry: CmsEntry<T>;
@@ -1,134 +1,80 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  import { getFieldIdentifier, getFieldIdentifiers } from "./fieldIdentifier.js";
3
- export const prepareEntryToIndex = params => {
4
- const {
5
- fieldRegistry,
6
- fieldIndexRegistry,
7
- storageEntry,
8
- entry,
9
- model
10
- } = params;
11
- function getFieldIndex(type) {
12
- const fieldIndexing = fieldIndexRegistry.get(type);
13
- if (fieldIndexing) {
14
- return fieldIndexing;
3
+ const prepareEntryToIndex = (params)=>{
4
+ const { fieldIndexRegistry, storageEntry, entry, model } = params;
5
+ function getFieldIndex(type) {
6
+ const fieldIndexing = fieldIndexRegistry.get(type);
7
+ if (fieldIndexing) return fieldIndexing;
8
+ return fieldIndexRegistry.getDefault();
15
9
  }
16
- return fieldIndexRegistry.getDefault();
17
- }
18
-
19
- // These objects will contain values processed by field index implementations
20
- const values = {};
21
- const rawValues = {};
22
-
23
- // We're only interested in current model fields.
24
- for (const field of model.fields) {
25
- const identifier = getFieldIdentifier(storageEntry.values, field);
26
- if (!identifier) {
27
- continue;
28
- }
29
- const fieldIndex = getFieldIndex(field.type);
30
- const {
31
- value,
32
- rawValue
33
- } = fieldIndex.toIndex({
34
- fieldRegistry,
35
- model,
36
- field,
37
- rawValue: entry.values[identifier],
38
- value: storageEntry.values[identifier],
39
- getFieldIndex
40
- });
41
- if (typeof value !== "undefined") {
42
- values[identifier] = value;
43
- }
44
- if (typeof rawValue !== "undefined") {
45
- rawValues[identifier] = rawValue;
10
+ const values = {};
11
+ const rawValues = {};
12
+ for (const field of model.fields){
13
+ const identifier = getFieldIdentifier(storageEntry.values, field);
14
+ if (!identifier) continue;
15
+ const fieldIndex = getFieldIndex(field.type);
16
+ const { value, rawValue } = fieldIndex.toIndex({
17
+ model,
18
+ field,
19
+ rawValue: entry.values[identifier],
20
+ value: storageEntry.values[identifier],
21
+ getFieldIndex
22
+ });
23
+ if (void 0 !== value) values[identifier] = value;
24
+ if (void 0 !== rawValue) rawValues[identifier] = rawValue;
46
25
  }
47
- }
48
- return {
49
- ...storageEntry,
50
- values,
51
- rawValues
52
- };
26
+ return {
27
+ ...storageEntry,
28
+ values,
29
+ rawValues
30
+ };
53
31
  };
54
- export const extractEntriesFromIndex = ({
55
- fieldRegistry,
56
- fieldIndexRegistry,
57
- entries,
58
- model
59
- }) => {
60
- function getFieldIndex(type) {
61
- const fieldIndex = fieldIndexRegistry.get(type);
62
- if (fieldIndex) {
63
- return fieldIndex;
32
+ const extractEntriesFromIndex = ({ fieldRegistry, fieldIndexRegistry, entries, model })=>{
33
+ function getFieldIndex(type) {
34
+ const fieldIndex = fieldIndexRegistry.get(type);
35
+ if (fieldIndex) return fieldIndex;
36
+ return fieldIndexRegistry.getDefault();
64
37
  }
65
- return fieldIndexRegistry.getDefault();
66
- }
67
- const list = [];
68
- for (const entry of entries) {
69
- // This object will contain values processed by field index plugins
70
- const indexValues = {};
71
-
72
- // We only consider fields that are present in the model
73
- for (const field of model.fields) {
74
- const fieldType = fieldRegistry.get(field.type);
75
- if (!fieldType) {
76
- throw new WebinyError(`Missing field type "${field.type}". Extract entries from index.`);
77
- }
78
- const fieldIndex = getFieldIndex(field.type);
79
- /**
80
- * We can safely cast as the code will not continue in case of no identifiers.
81
- */
82
- const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);
83
- if (!identifiers) {
84
- continue;
85
- }
86
- try {
87
- const key = identifiers.valueIdentifier;
88
- const rawKey = identifiers.rawValueIdentifier;
89
- indexValues[key] = fieldIndex.fromIndex({
90
- fieldRegistry,
91
- model,
92
- field,
93
- getFieldIndex,
94
- value: entry.values[key || rawKey],
95
- /**
96
- * Possibly no rawValues so we must check for the existence of the field.
97
- */
98
- rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null
38
+ const list = [];
39
+ for (const entry of entries){
40
+ const indexValues = {};
41
+ for (const field of model.fields){
42
+ const fieldType = fieldRegistry.get(field.type);
43
+ if (!fieldType) throw new WebinyError(`Missing field type "${field.type}". Extract entries from index.`);
44
+ const fieldIndex = getFieldIndex(field.type);
45
+ const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);
46
+ if (identifiers) try {
47
+ const key = identifiers.valueIdentifier;
48
+ const rawKey = identifiers.rawValueIdentifier;
49
+ indexValues[key] = fieldIndex.fromIndex({
50
+ model,
51
+ field,
52
+ getFieldIndex,
53
+ value: entry.values[key || rawKey],
54
+ rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null
55
+ });
56
+ } catch (ex) {
57
+ throw new WebinyError(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
58
+ field,
59
+ entry
60
+ });
61
+ }
62
+ }
63
+ const newEntry = {
64
+ ...entry,
65
+ values: indexValues
66
+ };
67
+ delete newEntry["rawValues"];
68
+ delete newEntry["TYPE"];
69
+ delete newEntry["__type"];
70
+ delete newEntry["latest"];
71
+ delete newEntry["published"];
72
+ list.push({
73
+ ...newEntry
99
74
  });
100
- } catch (ex) {
101
- throw new WebinyError(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
102
- field,
103
- entry
104
- });
105
- }
106
75
  }
107
- /**
108
- * Let's have a new entry so we do not modify the original one.
109
- */
110
- const newEntry = {
111
- ...entry,
112
- values: indexValues
113
- };
114
- /**
115
- * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.
116
- */
117
- // @ts-expect-error
118
- delete newEntry["rawValues"];
119
- // @ts-expect-error
120
- delete newEntry["TYPE"];
121
- // @ts-expect-error
122
- delete newEntry["__type"];
123
- // @ts-expect-error
124
- delete newEntry["latest"];
125
- // @ts-expect-error
126
- delete newEntry["published"];
127
- list.push({
128
- ...newEntry
129
- });
130
- }
131
- return list;
76
+ return list;
132
77
  };
78
+ export { extractEntriesFromIndex, prepareEntryToIndex };
133
79
 
134
80
  //# sourceMappingURL=entryIndexHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","getFieldIdentifier","getFieldIdentifiers","prepareEntryToIndex","params","fieldRegistry","fieldIndexRegistry","storageEntry","entry","model","getFieldIndex","type","fieldIndexing","get","getDefault","values","rawValues","field","fields","identifier","fieldIndex","value","rawValue","toIndex","extractEntriesFromIndex","entries","list","indexValues","fieldType","identifiers","key","valueIdentifier","rawKey","rawValueIdentifier","fromIndex","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsIndexEntry } from \"~/types.js\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport type {\n CmsEntryOpenSearchFieldIndex,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\n\ninterface SetupEntriesIndexHelpersParams {\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n}\n\ninterface ExtractEntriesFromIndexParams<\n T extends CmsEntryValues = CmsEntryValues\n> extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry<T>[];\n}\n\ninterface PrepareElasticsearchDataParams<\n T extends CmsEntryValues = CmsEntryValues\n> extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\nexport const prepareEntryToIndex = <T extends CmsEntryValues = CmsEntryValues>(\n params: PrepareElasticsearchDataParams<T>\n): CmsIndexEntry<T> => {\n const { fieldRegistry, fieldIndexRegistry, storageEntry, entry, model } = params;\n\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndexing = fieldIndexRegistry.get(type);\n if (fieldIndexing) {\n return fieldIndexing;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n // These objects will contain values processed by field index implementations\n const values: T = {} as T;\n const rawValues: T = {} as T;\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field) as keyof T;\n if (!identifier) {\n continue;\n }\n\n const fieldIndex = getFieldIndex(field.type);\n\n const { value, rawValue } = fieldIndex.toIndex({\n fieldRegistry,\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndex\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n };\n};\n\nexport const extractEntriesFromIndex = <T extends CmsEntryValues = CmsEntryValues>({\n fieldRegistry,\n fieldIndexRegistry,\n entries,\n model\n}: ExtractEntriesFromIndexParams<T>): CmsEntry<T>[] => {\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndex = fieldIndexRegistry.get(type);\n if (fieldIndex) {\n return fieldIndex;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n const list: CmsEntry<T>[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: T = {} as T;\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldType = fieldRegistry.get(field.type);\n if (!fieldType) {\n throw new WebinyError(\n `Missing field type \"${field.type}\". Extract entries from index.`\n );\n }\n\n const fieldIndex = getFieldIndex(field.type);\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n try {\n const key = identifiers.valueIdentifier as keyof T;\n const rawKey = identifiers.rawValueIdentifier as keyof T;\n indexValues[key] = fieldIndex.fromIndex({\n fieldRegistry,\n model,\n field,\n getFieldIndex,\n value: entry.values[key || rawKey],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry<T> = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-expect-error\n delete newEntry[\"rawValues\"];\n // @ts-expect-error\n delete newEntry[\"TYPE\"];\n // @ts-expect-error\n delete newEntry[\"__type\"];\n // @ts-expect-error\n delete newEntry[\"latest\"];\n // @ts-expect-error\n delete newEntry[\"published\"];\n list.push({\n ...newEntry\n });\n }\n\n return list;\n};\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"helpers/entryIndexHelpers.js","sources":["../../src/helpers/entryIndexHelpers.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsIndexEntry } from \"~/types.js\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport type {\n CmsEntryOpenSearchFieldIndex,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\n\ninterface SetupEntriesIndexHelpersParams {\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n}\n\ninterface ExtractEntriesFromIndexParams<\n T extends CmsEntryValues = CmsEntryValues\n> extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry<T>[];\n}\n\ninterface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues> extends Omit<\n SetupEntriesIndexHelpersParams,\n \"fieldRegistry\"\n> {\n model: CmsModel;\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\nexport const prepareEntryToIndex = <T extends CmsEntryValues = CmsEntryValues>(\n params: PrepareElasticsearchDataParams<T>\n): CmsIndexEntry<T> => {\n const { fieldIndexRegistry, storageEntry, entry, model } = params;\n\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndexing = fieldIndexRegistry.get(type);\n if (fieldIndexing) {\n return fieldIndexing;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n // These objects will contain values processed by field index implementations\n const values: T = {} as T;\n const rawValues: T = {} as T;\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field) as keyof T;\n if (!identifier) {\n continue;\n }\n\n const fieldIndex = getFieldIndex(field.type);\n\n const { value, rawValue } = fieldIndex.toIndex({\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndex\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n };\n};\n\nexport const extractEntriesFromIndex = <T extends CmsEntryValues = CmsEntryValues>({\n fieldRegistry,\n fieldIndexRegistry,\n entries,\n model\n}: ExtractEntriesFromIndexParams<T>): CmsEntry<T>[] => {\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndex = fieldIndexRegistry.get(type);\n if (fieldIndex) {\n return fieldIndex;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n const list: CmsEntry<T>[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: T = {} as T;\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldType = fieldRegistry.get(field.type);\n if (!fieldType) {\n throw new WebinyError(\n `Missing field type \"${field.type}\". Extract entries from index.`\n );\n }\n\n const fieldIndex = getFieldIndex(field.type);\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n try {\n const key = identifiers.valueIdentifier as keyof T;\n const rawKey = identifiers.rawValueIdentifier as keyof T;\n indexValues[key] = fieldIndex.fromIndex({\n model,\n field,\n getFieldIndex,\n value: entry.values[key || rawKey],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry<T> = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-expect-error\n delete newEntry[\"rawValues\"];\n // @ts-expect-error\n delete newEntry[\"TYPE\"];\n // @ts-expect-error\n delete newEntry[\"__type\"];\n // @ts-expect-error\n delete newEntry[\"latest\"];\n // @ts-expect-error\n delete newEntry[\"published\"];\n list.push({\n ...newEntry\n });\n }\n\n return list;\n};\n"],"names":["prepareEntryToIndex","params","fieldIndexRegistry","storageEntry","entry","model","getFieldIndex","type","fieldIndexing","values","rawValues","field","identifier","getFieldIdentifier","fieldIndex","value","rawValue","extractEntriesFromIndex","fieldRegistry","entries","list","indexValues","fieldType","WebinyError","identifiers","getFieldIdentifiers","key","rawKey","ex","newEntry"],"mappings":";;AA+BO,MAAMA,sBAAsB,CAC/BC;IAEA,MAAM,EAAEC,kBAAkB,EAAEC,YAAY,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGJ;IAE3D,SAASK,cAAcC,IAAY;QAC/B,MAAMC,gBAAgBN,mBAAmB,GAAG,CAACK;QAC7C,IAAIC,eACA,OAAOA;QAEX,OAAON,mBAAmB,UAAU;IACxC;IAGA,MAAMO,SAAY,CAAC;IACnB,MAAMC,YAAe,CAAC;IAGtB,KAAK,MAAMC,SAASN,MAAM,MAAM,CAAE;QAC9B,MAAMO,aAAaC,mBAAmBV,aAAa,MAAM,EAAEQ;QAC3D,IAAI,CAACC,YACD;QAGJ,MAAME,aAAaR,cAAcK,MAAM,IAAI;QAE3C,MAAM,EAAEI,KAAK,EAAEC,QAAQ,EAAE,GAAGF,WAAW,OAAO,CAAC;YAC3CT;YACAM;YACA,UAAUP,MAAM,MAAM,CAACQ,WAAW;YAClC,OAAOT,aAAa,MAAM,CAACS,WAAW;YACtCN;QACJ;QAEA,IAAI,AAAiB,WAAVS,OACPN,MAAM,CAACG,WAAW,GAAGG;QAGzB,IAAI,AAAoB,WAAbC,UACPN,SAAS,CAACE,WAAW,GAAGI;IAEhC;IACA,OAAO;QACH,GAAGb,YAAY;QACfM;QACAC;IACJ;AACJ;AAEO,MAAMO,0BAA0B,CAA4C,EAC/EC,aAAa,EACbhB,kBAAkB,EAClBiB,OAAO,EACPd,KAAK,EAC0B;IAC/B,SAASC,cAAcC,IAAY;QAC/B,MAAMO,aAAaZ,mBAAmB,GAAG,CAACK;QAC1C,IAAIO,YACA,OAAOA;QAEX,OAAOZ,mBAAmB,UAAU;IACxC;IAEA,MAAMkB,OAAsB,EAAE;IAE9B,KAAK,MAAMhB,SAASe,QAAS;QAEzB,MAAME,cAAiB,CAAC;QAGxB,KAAK,MAAMV,SAASN,MAAM,MAAM,CAAE;YAC9B,MAAMiB,YAAYJ,cAAc,GAAG,CAACP,MAAM,IAAI;YAC9C,IAAI,CAACW,WACD,MAAM,IAAIC,YACN,CAAC,oBAAoB,EAAEZ,MAAM,IAAI,CAAC,8BAA8B,CAAC;YAIzE,MAAMG,aAAaR,cAAcK,MAAM,IAAI;YAI3C,MAAMa,cAAcC,oBAAoBrB,MAAM,MAAM,EAAEA,MAAM,SAAS,EAAEO;YACvE,IAAKa,aAGL,IAAI;gBACA,MAAME,MAAMF,YAAY,eAAe;gBACvC,MAAMG,SAASH,YAAY,kBAAkB;gBAC7CH,WAAW,CAACK,IAAI,GAAGZ,WAAW,SAAS,CAAC;oBACpCT;oBACAM;oBACAL;oBACA,OAAOF,MAAM,MAAM,CAACsB,OAAOC,OAAO;oBAIlC,UAAUvB,MAAM,SAAS,GAAGA,MAAM,SAAS,CAACuB,UAAUD,IAAI,GAAG;gBACjE;YACJ,EAAE,OAAOE,IAAI;gBACT,MAAM,IAAIL,YACNK,GAAG,OAAO,IAAI,+CACdA,GAAG,IAAI,IAAI,0BACX;oBACIjB;oBACAP;gBACJ;YAER;QACJ;QAIA,MAAMyB,WAAwB;YAC1B,GAAGzB,KAAK;YACR,QAAQiB;QACZ;QAKA,OAAOQ,QAAQ,CAAC,YAAY;QAE5B,OAAOA,QAAQ,CAAC,OAAO;QAEvB,OAAOA,QAAQ,CAAC,SAAS;QAEzB,OAAOA,QAAQ,CAAC,SAAS;QAEzB,OAAOA,QAAQ,CAAC,YAAY;QAC5BT,KAAK,IAAI,CAAC;YACN,GAAGS,QAAQ;QACf;IACJ;IAEA,OAAOT;AACX"}
@@ -1,35 +1,23 @@
1
- const hasOwnProperty = (values = {}, property) => {
2
- if (!values) {
3
- return false;
4
- } else if (values.hasOwnProperty) {
5
- return values.hasOwnProperty(property);
6
- }
7
- return values[property] !== undefined;
1
+ const fieldIdentifier_hasOwnProperty = (values = {}, property)=>{
2
+ if (!values) return false;
3
+ if (values.hasOwnProperty) return values.hasOwnProperty(property);
4
+ return void 0 !== values[property];
8
5
  };
9
- export const getFieldIdentifier = (values, field) => {
10
- if (field.storageId && hasOwnProperty(values, field.storageId)) {
11
- return field.storageId;
12
- } else if (hasOwnProperty(values, field.fieldId)) {
13
- return field.fieldId;
14
- }
15
- return undefined;
6
+ const getFieldIdentifier = (values, field)=>{
7
+ if (field.storageId && fieldIdentifier_hasOwnProperty(values, field.storageId)) return field.storageId;
8
+ if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
16
9
  };
17
- export const getFieldIdentifiers = (values, rawValues, field) => {
18
- let valueIdentifier = getFieldIdentifier(values, field);
19
- let rawValueIdentifier = getFieldIdentifier(rawValues, field);
20
- if (!valueIdentifier && !rawValueIdentifier) {
21
- return null;
22
- }
23
- if (!valueIdentifier) {
24
- valueIdentifier = rawValueIdentifier;
25
- }
26
- if (!rawValueIdentifier) {
27
- rawValueIdentifier = valueIdentifier;
28
- }
29
- return {
30
- valueIdentifier,
31
- rawValueIdentifier
32
- };
10
+ const getFieldIdentifiers = (values, rawValues, field)=>{
11
+ let valueIdentifier = getFieldIdentifier(values, field);
12
+ let rawValueIdentifier = getFieldIdentifier(rawValues, field);
13
+ if (!valueIdentifier && !rawValueIdentifier) return null;
14
+ if (!valueIdentifier) valueIdentifier = rawValueIdentifier;
15
+ if (!rawValueIdentifier) rawValueIdentifier = valueIdentifier;
16
+ return {
17
+ valueIdentifier,
18
+ rawValueIdentifier
19
+ };
33
20
  };
21
+ export { getFieldIdentifier, getFieldIdentifiers };
34
22
 
35
23
  //# sourceMappingURL=fieldIdentifier.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","storageId","fieldId","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"sources":["fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"mappings":"AAEA,MAAMA,cAAc,GAAGA,CACnBC,MAAyC,GAAG,CAAC,CAAC,EAC9CC,QAAgB,KACN;EACV,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIA,MAAM,CAACD,cAAc,EAAE;IAC9B,OAAOC,MAAM,CAACD,cAAc,CAACE,QAAQ,CAAC;EAC1C;EACA,OAAOD,MAAM,CAACC,QAAQ,CAAC,KAAKC,SAAS;AACzC,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAGA,CAC9BH,MAAyC,EACzCI,KAAoB,KACC;EACrB,IAAIA,KAAK,CAACC,SAAS,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACC,SAAS,CAAC,EAAE;IAC5D,OAAOD,KAAK,CAACC,SAAS;EAC1B,CAAC,MAAM,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACE,OAAO,CAAC,EAAE;IAC9C,OAAOF,KAAK,CAACE,OAAO;EACxB;EACA,OAAOJ,SAAS;AACpB,CAAC;AAED,OAAO,MAAMK,mBAAmB,GAAGA,CAC/BP,MAAsB,EACtBQ,SAA4C,EAC5CJ,KAAoB,KACnB;EACD,IAAIK,eAAe,GAAGN,kBAAkB,CAACH,MAAM,EAAEI,KAAK,CAAC;EACvD,IAAIM,kBAAkB,GAAGP,kBAAkB,CAACK,SAAS,EAAEJ,KAAK,CAAC;EAC7D,IAAI,CAACK,eAAe,IAAI,CAACC,kBAAkB,EAAE;IACzC,OAAO,IAAI;EACf;EACA,IAAI,CAACD,eAAe,EAAE;IAClBA,eAAe,GAAGC,kBAA4B;EAClD;EACA,IAAI,CAACA,kBAAkB,EAAE;IACrBA,kBAAkB,GAAGD,eAAyB;EAClD;EACA,OAAO;IACHA,eAAe;IACfC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"helpers/fieldIdentifier.js","sources":["../../src/helpers/fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"mappings":"AAEA,MAAMA,iCAAiB,CACnBC,SAA4C,CAAC,CAAC,EAC9CC;IAEA,IAAI,CAACD,QACD,OAAO;IACJ,IAAIA,OAAO,cAAc,EAC5B,OAAOA,OAAO,cAAc,CAACC;IAEjC,OAAOD,AAAqBE,WAArBF,MAAM,CAACC,SAAS;AAC3B;AAEO,MAAME,qBAAqB,CAC9BH,QACAI;IAEA,IAAIA,MAAM,SAAS,IAAIL,+BAAeC,QAAQI,MAAM,SAAS,GACzD,OAAOA,MAAM,SAAS;IACnB,IAAIL,+BAAeC,QAAQI,MAAM,OAAO,GAC3C,OAAOA,MAAM,OAAO;AAG5B;AAEO,MAAMC,sBAAsB,CAC/BL,QACAM,WACAF;IAEA,IAAIG,kBAAkBJ,mBAAmBH,QAAQI;IACjD,IAAII,qBAAqBL,mBAAmBG,WAAWF;IACvD,IAAI,CAACG,mBAAmB,CAACC,oBACrB,OAAO;IAEX,IAAI,CAACD,iBACDA,kBAAkBC;IAEtB,IAAI,CAACA,oBACDA,qBAAqBD;IAEzB,OAAO;QACHA;QACAC;IACJ;AACJ"}
package/helpers/index.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from "./entryIndexHelpers.js";
2
2
  export * from "./fieldIdentifier.js";
3
-
4
- //# sourceMappingURL=index.js.map
package/index.js CHANGED
@@ -1,3 +1 @@
1
1
  export { registerCmsOpenSearchStorageOperations } from "./feature.js";
2
-
3
- //# sourceMappingURL=index.js.map