@webiny/api-headless-cms-ddb-es 6.3.0-beta.4 → 6.4.0-beta.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 (207) 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.js +28 -27
  22. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
  23. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +2 -1
  24. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -1
  25. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +2 -1
  26. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
  27. package/features/CmsEntryOpenSearchFieldIndex/constants.js +2 -1
  28. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -1
  29. package/features/CmsEntryOpenSearchFieldIndex/feature.js +13 -12
  30. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -1
  31. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +48 -65
  32. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
  33. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +20 -30
  34. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -1
  35. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +15 -16
  36. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -1
  37. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +15 -18
  38. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -1
  39. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +24 -29
  40. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -1
  41. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +99 -144
  42. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -1
  43. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +15 -16
  44. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -1
  45. package/features/CmsEntryOpenSearchFieldIndex/index.js +0 -2
  46. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +26 -28
  47. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
  48. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +2 -1
  49. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -1
  50. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +2 -1
  51. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
  52. package/features/CmsEntryOpenSearchFilter/constants.js +2 -1
  53. package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -1
  54. package/features/CmsEntryOpenSearchFilter/feature.js +9 -8
  55. package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -1
  56. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +18 -15
  57. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -1
  58. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +35 -53
  59. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -1
  60. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +27 -40
  61. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -1
  62. package/features/CmsEntryOpenSearchFilter/index.js +0 -2
  63. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +2 -1
  64. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -1
  65. package/features/CmsEntryOpenSearchFullTextSearch/index.js +0 -2
  66. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +10 -9
  67. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -1
  68. package/features/CmsEntryOpenSearchIndex/abstractions.js +2 -1
  69. package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -1
  70. package/features/CmsEntryOpenSearchIndex/feature.js +6 -5
  71. package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -1
  72. package/features/CmsEntryOpenSearchIndex/index.js +0 -2
  73. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +2 -1
  74. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -1
  75. package/features/CmsEntryOpenSearchQueryModifier/index.js +0 -2
  76. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +2 -1
  77. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -1
  78. package/features/CmsEntryOpenSearchSortModifier/index.js +0 -2
  79. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +24 -20
  80. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
  81. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +2 -1
  82. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -1
  83. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +2 -1
  84. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
  85. package/features/CmsEntryOpenSearchValueSearch/feature.js +9 -8
  86. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -1
  87. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +14 -16
  88. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -1
  89. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +31 -42
  90. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
  91. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +15 -17
  92. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -1
  93. package/features/CmsEntryOpenSearchValueSearch/index.js +0 -2
  94. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +2 -1
  95. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -1
  96. package/features/CmsEntryOpenSearchValuesModifier/index.js +0 -2
  97. package/helpers/entryIndexHelpers.js +71 -123
  98. package/helpers/entryIndexHelpers.js.map +1 -1
  99. package/helpers/fieldIdentifier.js +18 -30
  100. package/helpers/fieldIdentifier.js.map +1 -1
  101. package/helpers/index.js +0 -2
  102. package/index.js +0 -2
  103. package/operations/entry/dataLoader/DataLoaderCache.js +22 -26
  104. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  105. package/operations/entry/dataLoader/constants.js +2 -1
  106. package/operations/entry/dataLoader/constants.js.map +1 -1
  107. package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
  108. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  109. package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -29
  110. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  111. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +27 -37
  112. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  113. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +27 -37
  114. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  115. package/operations/entry/dataLoader/getRevisionById.js +32 -46
  116. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  117. package/operations/entry/dataLoader/index.js +8 -9
  118. package/operations/entry/dataLoader/index.js.map +1 -1
  119. package/operations/entry/dataLoader/types.js +0 -3
  120. package/operations/entry/dataLoaders.js +81 -99
  121. package/operations/entry/dataLoaders.js.map +1 -1
  122. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +6 -24
  123. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  124. package/operations/entry/elasticsearch/body.js +74 -125
  125. package/operations/entry/elasticsearch/body.js.map +1 -1
  126. package/operations/entry/elasticsearch/fields/createSystemField.js +6 -7
  127. package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -1
  128. package/operations/entry/elasticsearch/fields/live.js +45 -40
  129. package/operations/entry/elasticsearch/fields/live.js.map +1 -1
  130. package/operations/entry/elasticsearch/fields/location.js +45 -40
  131. package/operations/entry/elasticsearch/fields/location.js.map +1 -1
  132. package/operations/entry/elasticsearch/fields/state.js +99 -88
  133. package/operations/entry/elasticsearch/fields/state.js.map +1 -1
  134. package/operations/entry/elasticsearch/fields.js +193 -217
  135. package/operations/entry/elasticsearch/fields.js.map +1 -1
  136. package/operations/entry/elasticsearch/filtering/applyFiltering.js +32 -45
  137. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  138. package/operations/entry/elasticsearch/filtering/exec.js +85 -114
  139. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  140. package/operations/entry/elasticsearch/filtering/index.js +0 -2
  141. package/operations/entry/elasticsearch/filtering/path.js +24 -33
  142. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  143. package/operations/entry/elasticsearch/filtering/populated.js +8 -14
  144. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  145. package/operations/entry/elasticsearch/filtering/values.js +11 -12
  146. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  147. package/operations/entry/elasticsearch/fullTextSearch.js +43 -80
  148. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  149. package/operations/entry/elasticsearch/fullTextSearchFields.js +7 -17
  150. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  151. package/operations/entry/elasticsearch/initialQuery.js +37 -80
  152. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  153. package/operations/entry/elasticsearch/keyword.js +13 -27
  154. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  155. package/operations/entry/elasticsearch/plugins/operator.js +9 -20
  156. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  157. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -4
  158. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
  159. package/operations/entry/elasticsearch/sort.js +69 -92
  160. package/operations/entry/elasticsearch/sort.js.map +1 -1
  161. package/operations/entry/elasticsearch/transformValueForSearch.js +9 -14
  162. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  163. package/operations/entry/elasticsearch/types.js +0 -3
  164. package/operations/entry/index.js +1322 -1709
  165. package/operations/entry/index.js.map +1 -1
  166. package/operations/entry/keys.js +43 -63
  167. package/operations/entry/keys.js.map +1 -1
  168. package/operations/entry/recordType.js +4 -9
  169. package/operations/entry/recordType.js.map +1 -1
  170. package/operations/entry/transformations/convertEntryKeys.js +21 -26
  171. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  172. package/operations/entry/transformations/index.js +85 -114
  173. package/operations/entry/transformations/index.js.map +1 -1
  174. package/operations/entry/transformations/modifyEntryValues.d.ts +1 -1
  175. package/operations/entry/transformations/modifyEntryValues.js +12 -17
  176. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  177. package/operations/entry/transformations/transformEntryKeys.js +13 -16
  178. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  179. package/operations/entry/transformations/transformEntryToIndex.js +17 -22
  180. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  181. package/operations/group/index.js +113 -134
  182. package/operations/group/index.js.map +1 -1
  183. package/operations/model/index.js +128 -156
  184. package/operations/model/index.js.map +1 -1
  185. package/package.json +23 -23
  186. package/tasks/createIndexTaskPlugin.js +35 -38
  187. package/tasks/createIndexTaskPlugin.js.map +1 -1
  188. package/types.js +7 -13
  189. package/types.js.map +1 -1
  190. package/values/NoValueContainer.js +8 -10
  191. package/values/NoValueContainer.js.map +1 -1
  192. package/definitions/types.js.map +0 -1
  193. package/exports/api/cms/opensearch.js.map +0 -1
  194. package/features/CmsEntryOpenSearchBodyModifier/index.js.map +0 -1
  195. package/features/CmsEntryOpenSearchFieldIndex/index.js.map +0 -1
  196. package/features/CmsEntryOpenSearchFilter/index.js.map +0 -1
  197. package/features/CmsEntryOpenSearchFullTextSearch/index.js.map +0 -1
  198. package/features/CmsEntryOpenSearchIndex/index.js.map +0 -1
  199. package/features/CmsEntryOpenSearchQueryModifier/index.js.map +0 -1
  200. package/features/CmsEntryOpenSearchSortModifier/index.js.map +0 -1
  201. package/features/CmsEntryOpenSearchValueSearch/index.js.map +0 -1
  202. package/features/CmsEntryOpenSearchValuesModifier/index.js.map +0 -1
  203. package/helpers/index.js.map +0 -1
  204. package/index.js.map +0 -1
  205. package/operations/entry/dataLoader/types.js.map +0 -1
  206. package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
  207. package/operations/entry/elasticsearch/types.js.map +0 -1
package/configurations.js CHANGED
@@ -1,39 +1,31 @@
1
- import WebinyError from "@webiny/error";
2
- import { getOpenSearchIndexPrefix, isSharedOpenSearchIndex as isSharedElasticsearchIndex } from "@webiny/api-opensearch";
3
- export const configurations = {
4
- es({
5
- model
6
- }) {
7
- const {
8
- tenant
9
- } = model;
10
- if (!tenant) {
11
- throw new WebinyError(`Missing "tenant" parameter when trying to create Elasticsearch index name.`, "TENANT_ERROR");
1
+ import error from "@webiny/error";
2
+ import { getOpenSearchIndexPrefix, isSharedOpenSearchIndex } from "@webiny/api-opensearch";
3
+ const configurations = {
4
+ es ({ model }) {
5
+ const { tenant } = model;
6
+ if (!tenant) throw new error('Missing "tenant" parameter when trying to create Elasticsearch index name.', "TENANT_ERROR");
7
+ const sharedIndex = isSharedOpenSearchIndex();
8
+ const index = [
9
+ sharedIndex ? "root" : tenant,
10
+ "headless-cms",
11
+ model.modelId
12
+ ].join("-").toLowerCase();
13
+ const prefix = getOpenSearchIndexPrefix();
14
+ if (!prefix) return {
15
+ index
16
+ };
17
+ return {
18
+ index: prefix + index
19
+ };
20
+ },
21
+ indexSettings: ({ indexConfigs, model })=>{
22
+ const usable = indexConfigs.filter((c)=>c.canUse({
23
+ model
24
+ }));
25
+ if (0 === usable.length) return {};
26
+ return usable[usable.length - 1].body;
12
27
  }
13
- const sharedIndex = isSharedElasticsearchIndex();
14
- const index = [sharedIndex ? "root" : tenant, "headless-cms", model.modelId].join("-").toLowerCase();
15
- const prefix = getOpenSearchIndexPrefix();
16
- if (!prefix) {
17
- return {
18
- index
19
- };
20
- }
21
- return {
22
- index: prefix + index
23
- };
24
- },
25
- indexSettings: ({
26
- indexConfigs,
27
- model
28
- }) => {
29
- const usable = indexConfigs.filter(c => c.canUse({
30
- model
31
- }));
32
- if (usable.length === 0) {
33
- return {};
34
- }
35
- return usable[usable.length - 1].body;
36
- }
37
28
  };
29
+ export { configurations };
38
30
 
39
31
  //# sourceMappingURL=configurations.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","getOpenSearchIndexPrefix","isSharedOpenSearchIndex","isSharedElasticsearchIndex","configurations","es","model","tenant","sharedIndex","index","modelId","join","toLowerCase","prefix","indexSettings","indexConfigs","usable","filter","c","canUse","length","body"],"sources":["configurations.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport {\n getOpenSearchIndexPrefix,\n isSharedOpenSearchIndex as isSharedElasticsearchIndex\n} from \"@webiny/api-opensearch\";\nimport type { OpenSearchIndexRequestBody } from \"@webiny/api-opensearch/types.js\";\nimport type { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\ninterface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface CmsElasticsearchParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n indexConfigs: CmsEntryOpenSearchIndex.Interface[];\n model: Pick<CmsModel, \"tenant\" | \"modelId\" | \"group\">;\n}\n\nexport interface Configurations {\n es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<OpenSearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n }\n\n const sharedIndex = isSharedElasticsearchIndex();\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = getOpenSearchIndexPrefix();\n\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n },\n indexSettings: ({ indexConfigs, model }) => {\n const usable = indexConfigs.filter(c => c.canUse({ model }));\n if (usable.length === 0) {\n return {};\n }\n return usable[usable.length - 1].body;\n }\n};\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,SACIC,wBAAwB,EACxBC,uBAAuB,IAAIC,0BAA0B,QAClD,wBAAwB;AAwB/B,OAAO,MAAMC,cAA8B,GAAG;EAC1CC,EAAEA,CAAC;IAAEC;EAAM,CAAC,EAAE;IACV,MAAM;MAAEC;IAAO,CAAC,GAAGD,KAAK;IAExB,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIP,WAAW,CACjB,4EAA4E,EAC5E,cACJ,CAAC;IACL;IAEA,MAAMQ,WAAW,GAAGL,0BAA0B,CAAC,CAAC;IAChD,MAAMM,KAAK,GAAG,CAACD,WAAW,GAAG,MAAM,GAAGD,MAAM,EAAE,cAAc,EAAED,KAAK,CAACI,OAAO,CAAC,CACvEC,IAAI,CAAC,GAAG,CAAC,CACTC,WAAW,CAAC,CAAC;IAElB,MAAMC,MAAM,GAAGZ,wBAAwB,CAAC,CAAC;IAEzC,IAAI,CAACY,MAAM,EAAE;MACT,OAAO;QACHJ;MACJ,CAAC;IACL;IACA,OAAO;MACHA,KAAK,EAAEI,MAAM,GAAGJ;IACpB,CAAC;EACL,CAAC;EACDK,aAAa,EAAEA,CAAC;IAAEC,YAAY;IAAET;EAAM,CAAC,KAAK;IACxC,MAAMU,MAAM,GAAGD,YAAY,CAACE,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACC,MAAM,CAAC;MAAEb;IAAM,CAAC,CAAC,CAAC;IAC5D,IAAIU,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;MACrB,OAAO,CAAC,CAAC;IACb;IACA,OAAOJ,MAAM,CAACA,MAAM,CAACI,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI;EACzC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"configurations.js","sources":["../src/configurations.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport {\n getOpenSearchIndexPrefix,\n isSharedOpenSearchIndex as isSharedElasticsearchIndex\n} from \"@webiny/api-opensearch\";\nimport type { OpenSearchIndexRequestBody } from \"@webiny/api-opensearch/types.js\";\nimport type { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\ninterface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface CmsElasticsearchParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n indexConfigs: CmsEntryOpenSearchIndex.Interface[];\n model: Pick<CmsModel, \"tenant\" | \"modelId\" | \"group\">;\n}\n\nexport interface Configurations {\n es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<OpenSearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n }\n\n const sharedIndex = isSharedElasticsearchIndex();\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = getOpenSearchIndexPrefix();\n\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n },\n indexSettings: ({ indexConfigs, model }) => {\n const usable = indexConfigs.filter(c => c.canUse({ model }));\n if (usable.length === 0) {\n return {};\n }\n return usable[usable.length - 1].body;\n }\n};\n"],"names":["configurations","model","tenant","WebinyError","sharedIndex","isSharedElasticsearchIndex","index","prefix","getOpenSearchIndexPrefix","indexConfigs","usable","c"],"mappings":";;AA6BO,MAAMA,iBAAiC;IAC1C,IAAG,EAAEC,KAAK,EAAE;QACR,MAAM,EAAEC,MAAM,EAAE,GAAGD;QAEnB,IAAI,CAACC,QACD,MAAM,IAAIC,MACN,8EACA;QAIR,MAAMC,cAAcC;QACpB,MAAMC,QAAQ;YAACF,cAAc,SAASF;YAAQ;YAAgBD,MAAM,OAAO;SAAC,CACvE,IAAI,CAAC,KACL,WAAW;QAEhB,MAAMM,SAASC;QAEf,IAAI,CAACD,QACD,OAAO;YACHD;QACJ;QAEJ,OAAO;YACH,OAAOC,SAASD;QACpB;IACJ;IACA,eAAe,CAAC,EAAEG,YAAY,EAAER,KAAK,EAAE;QACnC,MAAMS,SAASD,aAAa,MAAM,CAACE,CAAAA,IAAKA,EAAE,MAAM,CAAC;gBAAEV;YAAM;QACzD,IAAIS,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,CAAC;QAEZ,OAAOA,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,CAAC,IAAI;IACzC;AACJ"}
@@ -1,13 +1,11 @@
1
1
  import { createStandardEntity } from "@webiny/db-dynamodb";
2
- export const createEntryEntity = params => {
3
- const {
4
- table,
5
- entityName
6
- } = params;
7
- return createStandardEntity({
8
- name: entityName,
9
- table: table.table
10
- });
2
+ const createEntryEntity = (params)=>{
3
+ const { table, entityName } = params;
4
+ return createStandardEntity({
5
+ name: entityName,
6
+ table: table.table
7
+ });
11
8
  };
9
+ export { createEntryEntity };
12
10
 
13
11
  //# sourceMappingURL=entry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createStandardEntity","createEntryEntity","params","table","entityName","name"],"sources":["entry.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IEntryEntity, IEntryEntityAttributesData } from \"~/definitions/types.js\";\n\nexport interface CreateEntryEntityParams {\n table: ITable;\n entityName: string;\n}\nexport const createEntryEntity = (params: CreateEntryEntityParams): IEntryEntity => {\n const { table, entityName } = params;\n return createStandardEntity<IEntryEntityAttributesData>({\n name: entityName,\n table: table.table\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAqB,qBAAqB;AAOvE,OAAO,MAAMC,iBAAiB,GAAIC,MAA+B,IAAmB;EAChF,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOF,oBAAoB,CAA6B;IACpDK,IAAI,EAAED,UAAU;IAChBD,KAAK,EAAEA,KAAK,CAACA;EACjB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"definitions/entry.js","sources":["../../src/definitions/entry.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IEntryEntity, IEntryEntityAttributesData } from \"~/definitions/types.js\";\n\nexport interface CreateEntryEntityParams {\n table: ITable;\n entityName: string;\n}\nexport const createEntryEntity = (params: CreateEntryEntityParams): IEntryEntity => {\n const { table, entityName } = params;\n return createStandardEntity<IEntryEntityAttributesData>({\n name: entityName,\n table: table.table\n });\n};\n"],"names":["createEntryEntity","params","table","entityName","createStandardEntity"],"mappings":";AAOO,MAAMA,oBAAoB,CAACC;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;IAC9B,OAAOG,qBAAiD;QACpD,MAAMD;QACN,OAAOD,MAAM,KAAK;IACtB;AACJ"}
@@ -1,13 +1,11 @@
1
1
  import { createStandardEntity } from "@webiny/db-dynamodb";
2
- export const createGroupEntity = params => {
3
- const {
4
- table,
5
- entityName
6
- } = params;
7
- return createStandardEntity({
8
- table: table.table,
9
- name: entityName
10
- });
2
+ const createGroupEntity = (params)=>{
3
+ const { table, entityName } = params;
4
+ return createStandardEntity({
5
+ table: table.table,
6
+ name: entityName
7
+ });
11
8
  };
9
+ export { createGroupEntity };
12
10
 
13
11
  //# sourceMappingURL=group.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createStandardEntity","createGroupEntity","params","table","entityName","name"],"sources":["group.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IGroupEntity } from \"~/definitions/types.js\";\nimport type { CmsGroup } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\nexport const createGroupEntity = (params: Params): IGroupEntity => {\n const { table, entityName } = params;\n return createStandardEntity<CmsGroup>({\n table: table.table,\n name: entityName\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAqB,qBAAqB;AAQvE,OAAO,MAAMC,iBAAiB,GAAIC,MAAc,IAAmB;EAC/D,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOF,oBAAoB,CAAW;IAClCG,KAAK,EAAEA,KAAK,CAACA,KAAK;IAClBE,IAAI,EAAED;EACV,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"definitions/group.js","sources":["../../src/definitions/group.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IGroupEntity } from \"~/definitions/types.js\";\nimport type { CmsGroup } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\nexport const createGroupEntity = (params: Params): IGroupEntity => {\n const { table, entityName } = params;\n return createStandardEntity<CmsGroup>({\n table: table.table,\n name: entityName\n });\n};\n"],"names":["createGroupEntity","params","table","entityName","createStandardEntity"],"mappings":";AAQO,MAAMA,oBAAoB,CAACC;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;IAC9B,OAAOG,qBAA+B;QAClC,OAAOF,MAAM,KAAK;QAClB,MAAMC;IACV;AACJ"}
@@ -1,13 +1,11 @@
1
1
  import { createStandardEntity } from "@webiny/db-dynamodb";
2
- export const createModelEntity = params => {
3
- const {
4
- table,
5
- entityName
6
- } = params;
7
- return createStandardEntity({
8
- table: table.table,
9
- name: entityName
10
- });
2
+ const createModelEntity = (params)=>{
3
+ const { table, entityName } = params;
4
+ return createStandardEntity({
5
+ table: table.table,
6
+ name: entityName
7
+ });
11
8
  };
9
+ export { createModelEntity };
12
10
 
13
11
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createStandardEntity","createModelEntity","params","table","entityName","name"],"sources":["model.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\nimport type { StorageCmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\n\nexport const createModelEntity = (params: Params): IModelEntity => {\n const { table, entityName } = params;\n return createStandardEntity<StorageCmsModel>({\n table: table.table,\n name: entityName\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAqB,qBAAqB;AASvE,OAAO,MAAMC,iBAAiB,GAAIC,MAAc,IAAmB;EAC/D,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOF,oBAAoB,CAAkB;IACzCG,KAAK,EAAEA,KAAK,CAACA,KAAK;IAClBE,IAAI,EAAED;EACV,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"definitions/model.js","sources":["../../src/definitions/model.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\nimport type { StorageCmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\n\nexport const createModelEntity = (params: Params): IModelEntity => {\n const { table, entityName } = params;\n return createStandardEntity<StorageCmsModel>({\n table: table.table,\n name: entityName\n });\n};\n"],"names":["createModelEntity","params","table","entityName","createStandardEntity"],"mappings":";AASO,MAAMA,oBAAoB,CAACC;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;IAC9B,OAAOG,qBAAsC;QACzC,OAAOF,MAAM,KAAK;QAClB,MAAMC;IACV;AACJ"}
@@ -53,6 +53,7 @@ export interface IEntryEntityAttributesData {
53
53
  meta?: GenericRecord;
54
54
  system?: ICmsEntrySystem;
55
55
  live: ICmsEntryLive | null;
56
+ revisionDescription: string | undefined;
56
57
  }
57
58
  export type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttributesData>;
58
59
  export type IModelEntity = IEntity<IStandardEntityAttributes<StorageCmsModel>>;
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1,74 +1,57 @@
1
- import WebinyError from "@webiny/error";
1
+ import error from "@webiny/error";
2
2
  import { configurations } from "../configurations.js";
3
- const getLastUsable = params => {
4
- const {
5
- configs
6
- } = params;
7
- const usable = configs.filter(c => c.canUse(params));
8
- if (usable.length === 0) {
9
- throw new WebinyError("Could not find a single usable CmsEntryOpenSearchIndex.", "OPENSEARCH_INDEX_TEMPLATE_ERROR");
10
- }
11
- return usable[usable.length - 1];
3
+ const getLastUsable = (params)=>{
4
+ const { configs } = params;
5
+ const usable = configs.filter((c)=>c.canUse(params));
6
+ if (0 === usable.length) throw new error("Could not find a single usable CmsEntryOpenSearchIndex.", "OPENSEARCH_INDEX_TEMPLATE_ERROR");
7
+ return usable[usable.length - 1];
12
8
  };
13
- export const createElasticsearchIndex = async params => {
14
- const {
15
- client,
16
- indexConfigs,
17
- model
18
- } = params;
19
- const {
20
- index
21
- } = configurations.es({
22
- model
23
- });
24
- const config = getLastUsable({
25
- configs: indexConfigs,
26
- model
27
- });
28
- if (!config) {
29
- /**
30
- * This can happen only while development as we have a base index setting that is always usable.
31
- */
32
- throw new Error(`Could not find a usable CmsEntryOpenSearchIndex for the CMS model "${model.name}".`);
33
- }
34
- try {
35
- const response = await client.indices.exists({
36
- index,
37
- ignore_unavailable: false,
38
- allow_no_indices: true,
39
- include_defaults: true,
40
- flat_settings: false,
41
- local: false
9
+ const createElasticsearchIndex = async (params)=>{
10
+ const { client, indexConfigs, model } = params;
11
+ const { index } = configurations.es({
12
+ model
42
13
  });
43
- if (response.body) {
44
- console.log(`Elasticsearch index "${index}" for the CMS model "${model.name}" already exists.`);
45
- return;
46
- }
47
- } catch {
48
- console.error(`Could not determine if the index "${index}" exists.`);
49
- }
50
- try {
51
- await client.indices.create({
52
- index,
53
- body: {
54
- ...config.body
55
- }
56
- });
57
- } catch (ex) {
58
- console.error(`Could not create Elasticsearch index "${index}" for the CMS model "${model.name}".`);
59
- console.error(ex);
60
- throw new WebinyError(ex.message || "Could not create OpenSearch index for the CMS entry.", ex.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
61
- error: {
62
- ...ex,
63
- message: ex.message,
64
- code: ex.code,
65
- data: ex.data
66
- },
67
- tenant: model.tenant,
68
- index,
69
- body: config.body
14
+ const config = getLastUsable({
15
+ configs: indexConfigs,
16
+ model
70
17
  });
71
- }
18
+ if (!config) throw new Error(`Could not find a usable CmsEntryOpenSearchIndex for the CMS model "${model.name}".`);
19
+ try {
20
+ const response = await client.indices.exists({
21
+ index,
22
+ ignore_unavailable: false,
23
+ allow_no_indices: true,
24
+ include_defaults: true,
25
+ flat_settings: false,
26
+ local: false
27
+ });
28
+ if (response.body) return void console.log(`Elasticsearch index "${index}" for the CMS model "${model.name}" already exists.`);
29
+ } catch {
30
+ console.error(`Could not determine if the index "${index}" exists.`);
31
+ }
32
+ try {
33
+ await client.indices.create({
34
+ index,
35
+ body: {
36
+ ...config.body
37
+ }
38
+ });
39
+ } catch (ex) {
40
+ console.error(`Could not create Elasticsearch index "${index}" for the CMS model "${model.name}".`);
41
+ console.error(ex);
42
+ throw new error(ex.message || "Could not create OpenSearch index for the CMS entry.", ex.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
43
+ error: {
44
+ ...ex,
45
+ message: ex.message,
46
+ code: ex.code,
47
+ data: ex.data
48
+ },
49
+ tenant: model.tenant,
50
+ index,
51
+ body: config.body
52
+ });
53
+ }
72
54
  };
55
+ export { createElasticsearchIndex };
73
56
 
74
57
  //# sourceMappingURL=createElasticsearchIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","configurations","getLastUsable","params","configs","usable","filter","c","canUse","length","createElasticsearchIndex","client","indexConfigs","model","index","es","config","Error","name","response","indices","exists","ignore_unavailable","allow_no_indices","include_defaults","flat_settings","local","body","console","log","error","create","ex","message","code","data","tenant"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-opensearch\";\nimport WebinyError from \"@webiny/error\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n indexConfigs: CmsEntryOpenSearchIndex.Interface[];\n model: CmsModel;\n}\n\ninterface IGetLastUsableParams {\n configs: CmsEntryOpenSearchIndex.Interface[];\n model: CmsModel;\n}\n\nconst getLastUsable = (params: IGetLastUsableParams): CmsEntryOpenSearchIndex.Interface => {\n const { configs } = params;\n const usable = configs.filter(c => c.canUse(params));\n if (usable.length === 0) {\n throw new WebinyError(\n \"Could not find a single usable CmsEntryOpenSearchIndex.\",\n \"OPENSEARCH_INDEX_TEMPLATE_ERROR\"\n );\n }\n return usable[usable.length - 1];\n};\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, indexConfigs, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const config = getLastUsable({\n configs: indexConfigs,\n model\n });\n if (!config) {\n /**\n * This can happen only while development as we have a base index setting that is always usable.\n */\n throw new Error(\n `Could not find a usable CmsEntryOpenSearchIndex for the CMS model \"${model.name}\".`\n );\n }\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (response.body) {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n return;\n }\n } catch {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n\n try {\n await client.indices.create({\n index,\n body: {\n ...config.body\n }\n });\n } catch (ex) {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n throw new WebinyError(\n ex.message || \"Could not create OpenSearch index for the CMS entry.\",\n ex.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n },\n tenant: model.tenant,\n index,\n body: config.body\n }\n );\n }\n};\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,cAAc;AAevB,MAAMC,aAAa,GAAIC,MAA4B,IAAwC;EACvF,MAAM;IAAEC;EAAQ,CAAC,GAAGD,MAAM;EAC1B,MAAME,MAAM,GAAGD,OAAO,CAACE,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACC,MAAM,CAACL,MAAM,CAAC,CAAC;EACpD,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IACrB,MAAM,IAAIT,WAAW,CACjB,yDAAyD,EACzD,iCACJ,CAAC;EACL;EACA,OAAOK,MAAM,CAACA,MAAM,CAACI,MAAM,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAAG,MAAOP,MAAsC,IAAK;EACtF,MAAM;IAAEQ,MAAM;IAAEC,YAAY;IAAEC;EAAM,CAAC,GAAGV,MAAM;EAE9C,MAAM;IAAEW;EAAM,CAAC,GAAGb,cAAc,CAACc,EAAE,CAAC;IAChCF;EACJ,CAAC,CAAC;EAEF,MAAMG,MAAM,GAAGd,aAAa,CAAC;IACzBE,OAAO,EAAEQ,YAAY;IACrBC;EACJ,CAAC,CAAC;EACF,IAAI,CAACG,MAAM,EAAE;IACT;AACR;AACA;IACQ,MAAM,IAAIC,KAAK,CACX,sEAAsEJ,KAAK,CAACK,IAAI,IACpF,CAAC;EACL;EAEA,IAAI;IACA,MAAMC,QAAQ,GAAG,MAAMR,MAAM,CAACS,OAAO,CAACC,MAAM,CAAC;MACzCP,KAAK;MACLQ,kBAAkB,EAAE,KAAK;MACzBC,gBAAgB,EAAE,IAAI;MACtBC,gBAAgB,EAAE,IAAI;MACtBC,aAAa,EAAE,KAAK;MACpBC,KAAK,EAAE;IACX,CAAC,CAAC;IACF,IAAIP,QAAQ,CAACQ,IAAI,EAAE;MACfC,OAAO,CAACC,GAAG,CACP,wBAAwBf,KAAK,wBAAwBD,KAAK,CAACK,IAAI,mBACnE,CAAC;MACD;IACJ;EACJ,CAAC,CAAC,MAAM;IACJU,OAAO,CAACE,KAAK,CAAC,qCAAqChB,KAAK,WAAW,CAAC;EACxE;EAEA,IAAI;IACA,MAAMH,MAAM,CAACS,OAAO,CAACW,MAAM,CAAC;MACxBjB,KAAK;MACLa,IAAI,EAAE;QACF,GAAGX,MAAM,CAACW;MACd;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOK,EAAE,EAAE;IACTJ,OAAO,CAACE,KAAK,CACT,yCAAyChB,KAAK,wBAAwBD,KAAK,CAACK,IAAI,IACpF,CAAC;IACDU,OAAO,CAACE,KAAK,CAACE,EAAE,CAAC;IACjB,MAAM,IAAIhC,WAAW,CACjBgC,EAAE,CAACC,OAAO,IAAI,sDAAsD,EACpED,EAAE,CAACE,IAAI,IAAI,+BAA+B,EAC1C;MACIJ,KAAK,EAAE;QACH,GAAGE,EAAE;QACLC,OAAO,EAAED,EAAE,CAACC,OAAO;QACnBC,IAAI,EAAEF,EAAE,CAACE,IAAI;QACbC,IAAI,EAAEH,EAAE,CAACG;MACb,CAAC;MACDC,MAAM,EAAEvB,KAAK,CAACuB,MAAM;MACpBtB,KAAK;MACLa,IAAI,EAAEX,MAAM,CAACW;IACjB,CACJ,CAAC;EACL;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"elasticsearch/createElasticsearchIndex.js","sources":["../../src/elasticsearch/createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-opensearch\";\nimport WebinyError from \"@webiny/error\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n indexConfigs: CmsEntryOpenSearchIndex.Interface[];\n model: CmsModel;\n}\n\ninterface IGetLastUsableParams {\n configs: CmsEntryOpenSearchIndex.Interface[];\n model: CmsModel;\n}\n\nconst getLastUsable = (params: IGetLastUsableParams): CmsEntryOpenSearchIndex.Interface => {\n const { configs } = params;\n const usable = configs.filter(c => c.canUse(params));\n if (usable.length === 0) {\n throw new WebinyError(\n \"Could not find a single usable CmsEntryOpenSearchIndex.\",\n \"OPENSEARCH_INDEX_TEMPLATE_ERROR\"\n );\n }\n return usable[usable.length - 1];\n};\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, indexConfigs, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const config = getLastUsable({\n configs: indexConfigs,\n model\n });\n if (!config) {\n /**\n * This can happen only while development as we have a base index setting that is always usable.\n */\n throw new Error(\n `Could not find a usable CmsEntryOpenSearchIndex for the CMS model \"${model.name}\".`\n );\n }\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (response.body) {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n return;\n }\n } catch {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n\n try {\n await client.indices.create({\n index,\n body: {\n ...config.body\n }\n });\n } catch (ex) {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n throw new WebinyError(\n ex.message || \"Could not create OpenSearch index for the CMS entry.\",\n ex.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n },\n tenant: model.tenant,\n index,\n body: config.body\n }\n );\n }\n};\n"],"names":["getLastUsable","params","configs","usable","c","WebinyError","createElasticsearchIndex","client","indexConfigs","model","index","configurations","config","Error","response","console","ex"],"mappings":";;AAiBA,MAAMA,gBAAgB,CAACC;IACnB,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,MAAME,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,MAAM,CAACH;IAC5C,IAAIE,AAAkB,MAAlBA,OAAO,MAAM,EACb,MAAM,IAAIE,MACN,2DACA;IAGR,OAAOF,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE;AACpC;AAEO,MAAMG,2BAA2B,OAAOL;IAC3C,MAAM,EAAEM,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGR;IAExC,MAAM,EAAES,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;QAChCF;IACJ;IAEA,MAAMG,SAASZ,cAAc;QACzB,SAASQ;QACTC;IACJ;IACA,IAAI,CAACG,QAID,MAAM,IAAIC,MACN,CAAC,mEAAmE,EAAEJ,MAAM,IAAI,CAAC,EAAE,CAAC;IAI5F,IAAI;QACA,MAAMK,WAAW,MAAMP,OAAO,OAAO,CAAC,MAAM,CAAC;YACzCG;YACA,oBAAoB;YACpB,kBAAkB;YAClB,kBAAkB;YAClB,eAAe;YACf,OAAO;QACX;QACA,IAAII,SAAS,IAAI,EAAE,YACfC,QAAQ,GAAG,CACP,CAAC,qBAAqB,EAAEL,MAAM,qBAAqB,EAAED,MAAM,IAAI,CAAC,iBAAiB,CAAC;IAI9F,EAAE,OAAM;QACJM,QAAQ,KAAK,CAAC,CAAC,kCAAkC,EAAEL,MAAM,SAAS,CAAC;IACvE;IAEA,IAAI;QACA,MAAMH,OAAO,OAAO,CAAC,MAAM,CAAC;YACxBG;YACA,MAAM;gBACF,GAAGE,OAAO,IAAI;YAClB;QACJ;IACJ,EAAE,OAAOI,IAAI;QACTD,QAAQ,KAAK,CACT,CAAC,sCAAsC,EAAEL,MAAM,qBAAqB,EAAED,MAAM,IAAI,CAAC,EAAE,CAAC;QAExFM,QAAQ,KAAK,CAACC;QACd,MAAM,IAAIX,MACNW,GAAG,OAAO,IAAI,wDACdA,GAAG,IAAI,IAAI,iCACX;YACI,OAAO;gBACH,GAAGA,EAAE;gBACL,SAASA,GAAG,OAAO;gBACnB,MAAMA,GAAG,IAAI;gBACb,MAAMA,GAAG,IAAI;YACjB;YACA,QAAQP,MAAM,MAAM;YACpBC;YACA,MAAME,OAAO,IAAI;QACrB;IAER;AACJ"}
@@ -1,31 +1,23 @@
1
1
  import { configurations } from "../configurations.js";
2
- export const deleteElasticsearchIndex = async params => {
3
- const {
4
- client,
5
- model
6
- } = params;
7
- const {
8
- index
9
- } = configurations.es({
10
- model
11
- });
12
- const {
13
- body: exists
14
- } = await client.indices.exists({
15
- index
16
- });
17
- if (!exists) {
18
- return;
19
- }
20
- try {
21
- await client.indices.delete({
22
- index,
23
- ignore_unavailable: true
2
+ const deleteElasticsearchIndex = async (params)=>{
3
+ const { client, model } = params;
4
+ const { index } = configurations.es({
5
+ model
24
6
  });
25
- } catch (ex) {
26
- console.log(`Could not delete Elasticsearch index "${index}". Please do it manually.`);
27
- console.log(ex.message);
28
- }
7
+ const { body: exists } = await client.indices.exists({
8
+ index
9
+ });
10
+ if (!exists) return;
11
+ try {
12
+ await client.indices.delete({
13
+ index,
14
+ ignore_unavailable: true
15
+ });
16
+ } catch (ex) {
17
+ console.log(`Could not delete Elasticsearch index "${index}". Please do it manually.`);
18
+ console.log(ex.message);
19
+ }
29
20
  };
21
+ export { deleteElasticsearchIndex };
30
22
 
31
23
  //# sourceMappingURL=deleteElasticsearchIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["configurations","deleteElasticsearchIndex","params","client","model","index","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\n\ninterface DeleteElasticsearchIndexParams {\n client: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await client.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"mappings":"AAEA,SAASA,cAAc;AAOvB,OAAO,MAAMC,wBAAwB,GAAG,MACpCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGL,cAAc,CAACM,EAAE,CAAC;IAChCF;EACJ,CAAC,CAAC;EACF,MAAM;IAAEG,IAAI,EAAEC;EAAO,CAAC,GAAG,MAAML,MAAM,CAACM,OAAO,CAACD,MAAM,CAAC;IACjDH;EACJ,CAAC,CAAC;EACF,IAAI,CAACG,MAAM,EAAE;IACT;EACJ;EAEA,IAAI;IACA,MAAML,MAAM,CAACM,OAAO,CAACC,MAAM,CAAC;MACxBL,KAAK;MACLM,kBAAkB,EAAE;IACxB,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,yCAAyCT,KAAK,2BAA2B,CAAC;IACtFQ,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;EAC3B;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"elasticsearch/deleteElasticsearchIndex.js","sources":["../../src/elasticsearch/deleteElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\n\ninterface DeleteElasticsearchIndexParams {\n client: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await client.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"names":["deleteElasticsearchIndex","params","client","model","index","configurations","exists","ex","console"],"mappings":";AASO,MAAMA,2BAA2B,OACpCC;IAEA,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGF;IAE1B,MAAM,EAAEG,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;QAChCF;IACJ;IACA,MAAM,EAAE,MAAMG,MAAM,EAAE,GAAG,MAAMJ,OAAO,OAAO,CAAC,MAAM,CAAC;QACjDE;IACJ;IACA,IAAI,CAACE,QACD;IAGJ,IAAI;QACA,MAAMJ,OAAO,OAAO,CAAC,MAAM,CAAC;YACxBE;YACA,oBAAoB;QACxB;IACJ,EAAE,OAAOG,IAAI;QACTC,QAAQ,GAAG,CAAC,CAAC,sCAAsC,EAAEJ,MAAM,yBAAyB,CAAC;QACrFI,QAAQ,GAAG,CAACD,GAAG,OAAO;IAC1B;AACJ"}
@@ -1,5 +1,5 @@
1
- export { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchFieldIndex } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
2
- export { CmsEntryOpenSearchFilterRegistry, CmsEntryOpenSearchFilter } from "../../../features/CmsEntryOpenSearchFilter/index.js";
1
+ export { CmsEntryOpenSearchFieldIndex, CmsEntryOpenSearchFieldIndexRegistry } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
2
+ export { CmsEntryOpenSearchFilter, CmsEntryOpenSearchFilterRegistry } from "../../../features/CmsEntryOpenSearchFilter/index.js";
3
3
  export { CmsEntryOpenSearchBodyModifier } from "../../../features/CmsEntryOpenSearchBodyModifier/index.js";
4
4
  export { CmsEntryOpenSearchSortModifier } from "../../../features/CmsEntryOpenSearchSortModifier/index.js";
5
5
  export { CmsEntryOpenSearchQueryModifier } from "../../../features/CmsEntryOpenSearchQueryModifier/index.js";
@@ -7,5 +7,3 @@ export { CmsEntryOpenSearchValueSearch, CmsEntryOpenSearchValueSearchRegistry }
7
7
  export { CmsEntryOpenSearchFullTextSearch } from "../../../features/CmsEntryOpenSearchFullTextSearch/index.js";
8
8
  export { CmsEntryOpenSearchIndex } from "../../../features/CmsEntryOpenSearchIndex/index.js";
9
9
  export { CmsEntryOpenSearchValuesModifier } from "../../../features/CmsEntryOpenSearchValuesModifier/index.js";
10
-
11
- //# sourceMappingURL=opensearch.js.map