@webiny/api-headless-cms-ddb-es 6.0.0-beta.0 → 6.0.0-rc.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 (285) hide show
  1. package/README.md +6 -30
  2. package/configurations.d.ts +4 -5
  3. package/configurations.js +12 -24
  4. package/configurations.js.map +1 -1
  5. package/definitions/entry.d.ts +4 -5
  6. package/definitions/entry.js +5 -174
  7. package/definitions/entry.js.map +1 -1
  8. package/definitions/group.d.ts +6 -6
  9. package/definitions/group.js +5 -58
  10. package/definitions/group.js.map +1 -1
  11. package/definitions/model.d.ts +6 -6
  12. package/definitions/model.js +5 -102
  13. package/definitions/model.js.map +1 -1
  14. package/definitions/types.d.ts +59 -0
  15. package/definitions/types.js +3 -0
  16. package/definitions/types.js.map +1 -0
  17. package/dynamoDb/index.d.ts +2 -2
  18. package/dynamoDb/index.js +5 -14
  19. package/dynamoDb/index.js.map +1 -1
  20. package/dynamoDb/storage/longText.js +11 -18
  21. package/dynamoDb/storage/longText.js.map +1 -1
  22. package/dynamoDb/storage/richText.d.ts +0 -5
  23. package/dynamoDb/storage/richText.js +25 -80
  24. package/dynamoDb/storage/richText.js.map +1 -1
  25. package/elasticsearch/createElasticsearchIndex.d.ts +3 -3
  26. package/elasticsearch/createElasticsearchIndex.js +7 -15
  27. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  28. package/elasticsearch/deleteElasticsearchIndex.d.ts +2 -2
  29. package/elasticsearch/deleteElasticsearchIndex.js +3 -10
  30. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  31. package/elasticsearch/index.d.ts +1 -1
  32. package/elasticsearch/index.js +3 -11
  33. package/elasticsearch/index.js.map +1 -1
  34. package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
  35. package/elasticsearch/indexing/dateTimeIndexing.js +1 -8
  36. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  37. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
  38. package/elasticsearch/indexing/defaultFieldIndexing.js +1 -8
  39. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
  40. package/elasticsearch/indexing/index.d.ts +1 -1
  41. package/elasticsearch/indexing/index.js +8 -16
  42. package/elasticsearch/indexing/index.js.map +1 -1
  43. package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
  44. package/elasticsearch/indexing/jsonIndexing.js +1 -8
  45. package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
  46. package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
  47. package/elasticsearch/indexing/longTextIndexing.js +1 -8
  48. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  49. package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
  50. package/elasticsearch/indexing/numberIndexing.js +1 -8
  51. package/elasticsearch/indexing/numberIndexing.js.map +1 -1
  52. package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
  53. package/elasticsearch/indexing/objectIndexing.js +6 -13
  54. package/elasticsearch/indexing/objectIndexing.js.map +1 -1
  55. package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
  56. package/elasticsearch/indexing/richTextIndexing.js +1 -8
  57. package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
  58. package/elasticsearch/indices/base.d.ts +1 -1
  59. package/elasticsearch/indices/base.js +4 -10
  60. package/elasticsearch/indices/base.js.map +1 -1
  61. package/elasticsearch/indices/index.d.ts +1 -1
  62. package/elasticsearch/indices/index.js +3 -11
  63. package/elasticsearch/indices/index.js.map +1 -1
  64. package/elasticsearch/search/index.d.ts +1 -1
  65. package/elasticsearch/search/index.js +4 -10
  66. package/elasticsearch/search/index.js.map +1 -1
  67. package/elasticsearch/search/refSearch.d.ts +1 -1
  68. package/elasticsearch/search/refSearch.js +3 -10
  69. package/elasticsearch/search/refSearch.js.map +1 -1
  70. package/elasticsearch/search/searchableJson.d.ts +2 -0
  71. package/elasticsearch/search/searchableJson.js +53 -0
  72. package/elasticsearch/search/searchableJson.js.map +1 -0
  73. package/elasticsearch/search/timeSearch.d.ts +1 -1
  74. package/elasticsearch/search/timeSearch.js +3 -10
  75. package/elasticsearch/search/timeSearch.js.map +1 -1
  76. package/helpers/entryIndexHelpers.d.ts +10 -10
  77. package/helpers/entryIndexHelpers.js +32 -26
  78. package/helpers/entryIndexHelpers.js.map +1 -1
  79. package/helpers/fieldIdentifier.d.ts +1 -1
  80. package/helpers/fieldIdentifier.js +2 -10
  81. package/helpers/fieldIdentifier.js.map +1 -1
  82. package/helpers/index.d.ts +2 -2
  83. package/helpers/index.js +2 -27
  84. package/helpers/index.js.map +1 -1
  85. package/index.d.ts +2 -2
  86. package/index.js +108 -134
  87. package/index.js.map +1 -1
  88. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
  89. package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
  90. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  91. package/operations/entry/dataLoader/constants.js +1 -7
  92. package/operations/entry/dataLoader/constants.js.map +1 -1
  93. package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
  94. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  95. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  96. package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
  97. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  98. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  99. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +18 -30
  100. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  101. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  102. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +18 -30
  103. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  104. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  105. package/operations/entry/dataLoader/getRevisionById.js +23 -35
  106. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  107. package/operations/entry/dataLoader/index.d.ts +5 -5
  108. package/operations/entry/dataLoader/index.js +10 -31
  109. package/operations/entry/dataLoader/index.js.map +1 -1
  110. package/operations/entry/dataLoader/types.d.ts +3 -4
  111. package/operations/entry/dataLoader/types.js +1 -5
  112. package/operations/entry/dataLoader/types.js.map +1 -1
  113. package/operations/entry/dataLoaders.d.ts +13 -13
  114. package/operations/entry/dataLoaders.js +15 -25
  115. package/operations/entry/dataLoaders.js.map +1 -1
  116. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  117. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
  118. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  119. package/operations/entry/elasticsearch/body.d.ts +3 -3
  120. package/operations/entry/elasticsearch/body.js +21 -28
  121. package/operations/entry/elasticsearch/body.js.map +1 -1
  122. package/operations/entry/elasticsearch/fields.d.ts +3 -3
  123. package/operations/entry/elasticsearch/fields.js +110 -24
  124. package/operations/entry/elasticsearch/fields.js.map +1 -1
  125. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
  126. package/operations/entry/elasticsearch/filtering/applyFiltering.js +10 -17
  127. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  128. package/operations/entry/elasticsearch/filtering/exec.d.ts +7 -6
  129. package/operations/entry/elasticsearch/filtering/exec.js +48 -45
  130. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  131. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
  132. package/operations/entry/elasticsearch/filtering/index.js +1 -16
  133. package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
  134. package/operations/entry/elasticsearch/filtering/path.d.ts +2 -1
  135. package/operations/entry/elasticsearch/filtering/path.js +9 -17
  136. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  137. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +1 -1
  138. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +6 -14
  139. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
  140. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -1
  141. package/operations/entry/elasticsearch/filtering/plugins/index.js +5 -12
  142. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
  143. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +1 -1
  144. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +7 -15
  145. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
  146. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +1 -1
  147. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +15 -16
  148. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
  149. package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
  150. package/operations/entry/elasticsearch/filtering/populated.js +1 -8
  151. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  152. package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
  153. package/operations/entry/elasticsearch/filtering/values.js +4 -12
  154. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  155. package/operations/entry/elasticsearch/fullTextSearch.d.ts +3 -3
  156. package/operations/entry/elasticsearch/fullTextSearch.js +6 -12
  157. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  158. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
  159. package/operations/entry/elasticsearch/fullTextSearchFields.js +1 -8
  160. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  161. package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
  162. package/operations/entry/elasticsearch/initialQuery.js +9 -26
  163. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  164. package/operations/entry/elasticsearch/keyword.d.ts +1 -1
  165. package/operations/entry/elasticsearch/keyword.js +4 -9
  166. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  167. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +4 -4
  168. package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -10
  169. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
  170. package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -3
  171. package/operations/entry/elasticsearch/plugins/operator.js +4 -19
  172. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  173. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +4 -4
  174. package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -10
  175. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
  176. package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
  177. package/operations/entry/elasticsearch/plugins/search.js +5 -13
  178. package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
  179. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +4 -4
  180. package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -10
  181. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
  182. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  183. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -0
  184. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  185. package/operations/entry/elasticsearch/sort.d.ts +4 -4
  186. package/operations/entry/elasticsearch/sort.js +57 -33
  187. package/operations/entry/elasticsearch/sort.js.map +1 -1
  188. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
  189. package/operations/entry/elasticsearch/transformValueForSearch.js +4 -9
  190. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  191. package/operations/entry/elasticsearch/types.d.ts +5 -5
  192. package/operations/entry/elasticsearch/types.js +1 -5
  193. package/operations/entry/elasticsearch/types.js.map +1 -1
  194. package/operations/entry/index.d.ts +7 -6
  195. package/operations/entry/index.js +634 -735
  196. package/operations/entry/index.js.map +1 -1
  197. package/operations/entry/keys.d.ts +31 -1
  198. package/operations/entry/keys.js +56 -19
  199. package/operations/entry/keys.js.map +1 -1
  200. package/operations/entry/recordType.js +3 -12
  201. package/operations/entry/recordType.js.map +1 -1
  202. package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
  203. package/operations/entry/transformations/convertEntryKeys.js +2 -10
  204. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  205. package/operations/entry/transformations/index.d.ts +17 -17
  206. package/operations/entry/transformations/index.js +22 -30
  207. package/operations/entry/transformations/index.js.map +1 -1
  208. package/operations/entry/transformations/modifyEntryValues.d.ts +27 -34
  209. package/operations/entry/transformations/modifyEntryValues.js +1 -8
  210. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  211. package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
  212. package/operations/entry/transformations/transformEntryKeys.js +4 -11
  213. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  214. package/operations/entry/transformations/transformEntryToIndex.d.ts +7 -7
  215. package/operations/entry/transformations/transformEntryToIndex.js +3 -10
  216. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  217. package/operations/group/index.d.ts +6 -5
  218. package/operations/group/index.js +39 -73
  219. package/operations/group/index.js.map +1 -1
  220. package/operations/model/index.d.ts +4 -4
  221. package/operations/model/index.js +38 -57
  222. package/operations/model/index.js.map +1 -1
  223. package/package.json +29 -41
  224. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
  225. package/plugins/CmsElasticsearchModelFieldPlugin.js +2 -8
  226. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
  227. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -2
  228. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -11
  229. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  230. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
  231. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +3 -11
  232. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
  233. package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -9
  234. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  235. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +3 -2
  236. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +3 -11
  237. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
  238. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -2
  239. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -11
  240. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  241. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -2
  242. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -11
  243. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  244. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +12 -12
  245. package/plugins/CmsEntryElasticsearchValuesModifier.js +4 -12
  246. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
  247. package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
  248. package/plugins/CmsEntryFilterPlugin.js +2 -9
  249. package/plugins/CmsEntryFilterPlugin.js.map +1 -1
  250. package/plugins/index.d.ts +8 -8
  251. package/plugins/index.js +8 -93
  252. package/plugins/index.js.map +1 -1
  253. package/tasks/createIndexTaskPlugin.d.ts +2 -2
  254. package/tasks/createIndexTaskPlugin.js +36 -62
  255. package/tasks/createIndexTaskPlugin.js.map +1 -1
  256. package/types.d.ts +28 -33
  257. package/types.js +5 -8
  258. package/types.js.map +1 -1
  259. package/values/NoValueContainer.d.ts +5 -0
  260. package/values/NoValueContainer.js +13 -0
  261. package/values/NoValueContainer.js.map +1 -0
  262. package/definitions/entryElasticsearch.d.ts +0 -8
  263. package/definitions/entryElasticsearch.js +0 -38
  264. package/definitions/entryElasticsearch.js.map +0 -1
  265. package/definitions/system.d.ts +0 -8
  266. package/definitions/system.js +0 -42
  267. package/definitions/system.js.map +0 -1
  268. package/definitions/table.d.ts +0 -8
  269. package/definitions/table.js +0 -25
  270. package/definitions/table.js.map +0 -1
  271. package/definitions/tableElasticsearch.d.ts +0 -8
  272. package/definitions/tableElasticsearch.js +0 -25
  273. package/definitions/tableElasticsearch.js.map +0 -1
  274. package/dynamoDb/storage/date.d.ts +0 -3
  275. package/dynamoDb/storage/date.js +0 -84
  276. package/dynamoDb/storage/date.js.map +0 -1
  277. package/elasticsearch/indices/japanese.d.ts +0 -2
  278. package/elasticsearch/indices/japanese.js +0 -14
  279. package/elasticsearch/indices/japanese.js.map +0 -1
  280. package/operations/system/index.d.ts +0 -6
  281. package/operations/system/index.js +0 -94
  282. package/operations/system/index.js.map +0 -1
  283. package/operations/system/indexes.d.ts +0 -10
  284. package/operations/system/indexes.js +0 -41
  285. package/operations/system/indexes.js.map +0 -1
@@ -0,0 +1,59 @@
1
+ import type { IEntity, IStandardEntityAttributes } from "@webiny/db-dynamodb";
2
+ import type { GenericRecord } from "@webiny/api/types.js";
3
+ import type { CmsEntryStatus, CmsGroup, CmsIdentity, CmsModel, ICmsEntryLocation, IEntryState } from "@webiny/api-headless-cms/types/index.js";
4
+ export interface IEntryEntityAttributesData {
5
+ tenant: string;
6
+ entryId: string;
7
+ id: string;
8
+ modelId: string;
9
+ /**
10
+ * Revision-level meta fields. 👇
11
+ */
12
+ revisionCreatedOn: string;
13
+ revisionModifiedOn: string | null;
14
+ revisionSavedOn: string;
15
+ revisionDeletedOn: string | null;
16
+ revisionRestoredOn: string | null;
17
+ revisionFirstPublishedOn: string | null;
18
+ revisionLastPublishedOn: string | null;
19
+ revisionCreatedBy: CmsIdentity;
20
+ revisionModifiedBy: CmsIdentity | null;
21
+ revisionSavedBy: CmsIdentity;
22
+ revisionDeletedBy: CmsIdentity | null;
23
+ revisionRestoredBy: CmsIdentity | null;
24
+ revisionFirstPublishedBy: CmsIdentity | null;
25
+ revisionLastPublishedBy: CmsIdentity | null;
26
+ /**
27
+ * Entry-level meta fields. 👇
28
+ */
29
+ createdOn: string;
30
+ modifiedOn: string | null;
31
+ savedOn: string;
32
+ deletedOn: string | null;
33
+ restoredOn: string | null;
34
+ firstPublishedOn: string | null;
35
+ lastPublishedOn: string | null;
36
+ createdBy: CmsIdentity;
37
+ modifiedBy: CmsIdentity | null;
38
+ savedBy: CmsIdentity;
39
+ deletedBy: CmsIdentity | null;
40
+ restoredBy: CmsIdentity | null;
41
+ firstPublishedBy: CmsIdentity | null;
42
+ lastPublishedBy: CmsIdentity | null;
43
+ /**
44
+ * The rest. 👇
45
+ */
46
+ version: number;
47
+ locked: boolean;
48
+ status: CmsEntryStatus;
49
+ location?: ICmsEntryLocation;
50
+ wbyDeleted?: boolean | null;
51
+ binOriginalFolderId?: string;
52
+ values: GenericRecord;
53
+ meta?: GenericRecord;
54
+ state?: IEntryState;
55
+ }
56
+ export type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttributesData>;
57
+ export type IModelEntity = IEntity<IStandardEntityAttributes<CmsModel>>;
58
+ export type IGroupEntity = IEntity<IStandardEntityAttributes<CmsGroup>>;
59
+ export type IEntryEntity = IEntity<IEntryEntityAttributes>;
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntity, IStandardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type {\n CmsEntryStatus,\n CmsGroup,\n CmsIdentity,\n CmsModel,\n ICmsEntryLocation,\n IEntryState\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IEntryEntityAttributesData {\n tenant: string;\n entryId: string;\n id: string;\n modelId: string;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: string;\n revisionModifiedOn: string | null;\n revisionSavedOn: string;\n revisionDeletedOn: string | null;\n revisionRestoredOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionDeletedBy: CmsIdentity | null;\n revisionRestoredBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n deletedOn: string | null;\n restoredOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n deletedBy: CmsIdentity | null;\n restoredBy: CmsIdentity | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * The rest. 👇\n */\n version: number;\n locked: boolean;\n status: CmsEntryStatus;\n location?: ICmsEntryLocation;\n wbyDeleted?: boolean | null;\n binOriginalFolderId?: string;\n values: GenericRecord;\n meta?: GenericRecord;\n state?: IEntryState;\n}\n\nexport type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttributesData>;\n\nexport type IModelEntity = IEntity<IStandardEntityAttributes<CmsModel>>;\nexport type IGroupEntity = IEntity<IStandardEntityAttributes<CmsGroup>>;\nexport type IEntryEntity = IEntity<IEntryEntityAttributes>;\n"],"mappings":"","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- declare const _default: () => import("@webiny/api-headless-cms").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>[];
1
+ declare const _default: () => import("@webiny/api-headless-cms/index.js").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types/modelField.js").CmsModelField>[];
2
2
  export default _default;
3
- export declare const createDynamoDbPlugins: () => import("@webiny/api-headless-cms").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>[];
3
+ export declare const createDynamoDbPlugins: () => import("@webiny/api-headless-cms/index.js").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types/modelField.js").CmsModelField>[];
package/dynamoDb/index.js CHANGED
@@ -1,17 +1,8 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.createDynamoDbPlugins = void 0;
7
- var _richText = require("./storage/richText");
8
- var _longText = require("./storage/longText");
9
- var _date = require("./storage/date");
10
- var _default = () => createDynamoDbPlugins();
11
- exports.default = _default;
12
- const createDynamoDbPlugins = () => {
13
- return [(0, _richText.createRichTextStorageTransformPlugin)(), (0, _longText.createLongTextStorageTransformPlugin)(), (0, _date.createDateStorageTransformPlugin)()];
1
+ import { createRichTextStorageTransformPlugin } from "./storage/richText.js";
2
+ import { createLongTextStorageTransformPlugin } from "./storage/longText.js";
3
+ export default () => createDynamoDbPlugins();
4
+ export const createDynamoDbPlugins = () => {
5
+ return [createRichTextStorageTransformPlugin(), createLongTextStorageTransformPlugin()];
14
6
  };
15
- exports.createDynamoDbPlugins = createDynamoDbPlugins;
16
7
 
17
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_richText","require","_longText","_date","_default","createDynamoDbPlugins","exports","default","createRichTextStorageTransformPlugin","createLongTextStorageTransformPlugin","createDateStorageTransformPlugin"],"sources":["index.ts"],"sourcesContent":["import { createRichTextStorageTransformPlugin } from \"./storage/richText\";\nimport { createLongTextStorageTransformPlugin } from \"./storage/longText\";\nimport { createDateStorageTransformPlugin } from \"./storage/date\";\n\nexport default () => createDynamoDbPlugins();\n\nexport const createDynamoDbPlugins = () => {\n return [\n createRichTextStorageTransformPlugin(),\n createLongTextStorageTransformPlugin(),\n createDateStorageTransformPlugin()\n ];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAkE,IAAAG,QAAA,GAEnDA,CAAA,KAAMC,qBAAqB,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAH,QAAA;AAErC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,CACH,IAAAG,8CAAoC,EAAC,CAAC,EACtC,IAAAC,8CAAoC,EAAC,CAAC,EACtC,IAAAC,sCAAgC,EAAC,CAAC,CACrC;AACL,CAAC;AAACJ,OAAA,CAAAD,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createRichTextStorageTransformPlugin","createLongTextStorageTransformPlugin","createDynamoDbPlugins"],"sources":["index.ts"],"sourcesContent":["import { createRichTextStorageTransformPlugin } from \"./storage/richText.js\";\nimport { createLongTextStorageTransformPlugin } from \"./storage/longText.js\";\n\nexport default () => createDynamoDbPlugins();\n\nexport const createDynamoDbPlugins = () => {\n return [createRichTextStorageTransformPlugin(), createLongTextStorageTransformPlugin()];\n};\n"],"mappings":"AAAA,SAASA,oCAAoC;AAC7C,SAASC,oCAAoC;AAE7C,eAAe,MAAMC,qBAAqB,CAAC,CAAC;AAE5C,OAAO,MAAMA,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,CAACF,oCAAoC,CAAC,CAAC,EAAEC,oCAAoC,CAAC,CAAC,CAAC;AAC3F,CAAC","ignoreList":[]}
@@ -1,17 +1,10 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createLongTextStorageTransformPlugin = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _gzip = require("@webiny/utils/compression/gzip");
10
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
11
1
  /**
12
2
  * File is @internal
13
3
  */
14
4
 
5
+ import WebinyError from "@webiny/error";
6
+ import { compress as gzip, decompress as ungzip } from "@webiny/utils/compression/gzip.js";
7
+ import { StorageTransformPlugin } from "@webiny/api-headless-cms";
15
8
  const GZIP = "gzip";
16
9
  const TO_STORAGE_ENCODING = "base64";
17
10
  const FROM_STORAGE_ENCODING = "utf8";
@@ -21,8 +14,9 @@ const convertToBuffer = value => {
21
14
  }
22
15
  return value;
23
16
  };
24
- const createLongTextStorageTransformPlugin = () => {
25
- const plugin = new _apiHeadlessCms.StorageTransformPlugin({
17
+ export const createLongTextStorageTransformPlugin = () => {
18
+ const plugin = new StorageTransformPlugin({
19
+ name: "headless-cms.storage-transform.long-text.default",
26
20
  fieldType: "long-text",
27
21
  fromStorage: async ({
28
22
  field,
@@ -32,7 +26,7 @@ const createLongTextStorageTransformPlugin = () => {
32
26
  if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
33
27
  return storageValue;
34
28
  } else if (typeOf !== "object") {
35
- throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
29
+ throw new WebinyError(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
36
30
  }
37
31
  const {
38
32
  compression,
@@ -43,16 +37,16 @@ const createLongTextStorageTransformPlugin = () => {
43
37
  * Check if possibly undefined, null, empty...
44
38
  */
45
39
  if (!compression) {
46
- throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
40
+ throw new WebinyError(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
47
41
  value: storageValue
48
42
  });
49
43
  } else if (compression !== GZIP) {
50
- throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
44
+ throw new WebinyError(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
51
45
  compression
52
46
  });
53
47
  }
54
48
  try {
55
- const buf = await (0, _gzip.decompress)(convertToBuffer(value));
49
+ const buf = await ungzip(convertToBuffer(value));
56
50
  const result = buf.toString(FROM_STORAGE_ENCODING);
57
51
  if (!isArray) {
58
52
  return result;
@@ -75,7 +69,7 @@ const createLongTextStorageTransformPlugin = () => {
75
69
  }
76
70
  const isArray = Array.isArray(initialValue);
77
71
  const value = isArray ? JSON.stringify(initialValue) : initialValue;
78
- const compressedValue = await (0, _gzip.compress)(value);
72
+ const compressedValue = await gzip(value);
79
73
  const result = {
80
74
  compression: GZIP,
81
75
  value: compressedValue.toString(TO_STORAGE_ENCODING)
@@ -90,6 +84,5 @@ const createLongTextStorageTransformPlugin = () => {
90
84
  plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;
91
85
  return plugin;
92
86
  };
93
- exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;
94
87
 
95
88
  //# sourceMappingURL=longText.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_gzip","_apiHeadlessCms","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue","gzip","name","exports"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin<string | string[], StorageValue>({\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as unknown as StorageValue;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;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ACAA,MAAM,CAACT,OAAO,GAAGA,OAAO;MACxB,OAAOS,MAAM;IACjB;EACJ,CAAC,CAAC;EACFjB,MAAM,CAAC6B,IAAI,GAAG7B,MAAM,CAAC6B,IAAI,GAAI,kDAAiD;EAE9E,OAAO7B,MAAM;AACjB,CAAC;AAAC8B,OAAA,CAAA/B,oCAAA,GAAAA,oCAAA","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","compress","gzip","decompress","ungzip","StorageTransformPlugin","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","plugin","name","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","storageId","fieldId","compression","JSON","stringify","buf","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip.js\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin<string | string[], StorageValue>({\n name: \"headless-cms.storage-transform.long-text.default\",\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as unknown as StorageValue;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;\n\n return plugin;\n};\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,QAAQ,IAAIC,IAAI,EAAEC,UAAU,IAAIC,MAAM,QAAQ,mCAAmC;AAC1F,SAASC,sBAAsB,QAAQ,0BAA0B;AAEjE,MAAMC,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAa;EACxD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;I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AAGD,GAAG,CAACE,QAAQ,CAACtB,qBAAqB,CAAC;QAClD,IAAI,CAACc,OAAO,EAAE;UACV,OAAOO,MAAM;QACjB;QACA,OAAOH,IAAI,CAACK,KAAK,CAACF,MAAM,CAAC;MAC7B,CAAC,CAAC,OAAOG,EAAE,EAAE;QACTC,OAAO,CAACC,GAAG,CAAC,qCAAqC,CAAC;QAClDD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;QACvB,OAAO,EAAE;MACb;IACJ,CAAC;IACDC,SAAS,EAAE,MAAAA,CAAO;MAAE1B,KAAK,EAAE2B;IAAa,CAAC,KAAK;MAC1C;AACZ;AACA;MACY,IAAIA,YAAY,IAAIA,YAAY,CAACC,cAAc,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;QACrE,OAAOD,YAAY;MACvB;MACA,MAAMf,OAAO,GAAGD,KAAK,CAACC,OAAO,CAACe,YAAY,CAAC;MAC3C,MAAM3B,KAAK,GAAGY,OAAO,GAAGI,IAAI,CAACC,SAAS,CAACU,YAAY,CAAC,GAAGA,YAAY;MACnE,MAAME,eAAe,GAAG,MAAMrC,IAAI,CAACQ,KAAK,CAAC;MAEzC,MAAMmB,MAAoB,GAAG;QACzBJ,WAAW,EAAEnB,IAAI;QACjBI,KAAK,EAAE6B,eAAe,CAACT,QAAQ,CAACvB,mBAAmB;MACvD,CAAC;MACD,IAAI,CAACe,OAAO,EAAE;QACV,OAAOO,MAAM;MACjB;MACAA,MAAM,CAACP,OAAO,GAAGA,OAAO;MACxB,OAAOO,MAAM;IACjB;EACJ,CAAC,CAAC;EACFf,MAAM,CAACC,IAAI,GAAGD,MAAM,CAACC,IAAI,GAAG,kDAAkD;EAE9E,OAAOD,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,7 +1,2 @@
1
1
  import { StorageTransformPlugin } from "@webiny/api-headless-cms";
2
- export declare type OriginalValue = Record<string, any> | any[];
3
- export interface StorageValue {
4
- compression: string;
5
- value: any;
6
- }
7
2
  export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>;
@@ -1,106 +1,51 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createRichTextStorageTransformPlugin = void 0;
8
- var _jsonpack = _interopRequireDefault(require("jsonpack"));
9
- var _error = _interopRequireDefault(require("@webiny/error"));
10
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
11
- /**
12
- * Remove when jsonpack gets PR with a fix merged
13
- * https://github.com/rgcl/jsonpack/pull/25/files
14
- * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.
15
- */
16
- // TODO @ts-refactor figure better type
17
- const transformArray = value => {
18
- if (!value) {
19
- return value;
20
- }
21
- let isArray = Array.isArray(value);
22
- const shouldBeArray = value instanceof Array === false && isArray;
23
- if (shouldBeArray) {
24
- value = Array.from(value);
25
- isArray = true;
26
- }
27
- if (typeof value === "object" || isArray) {
28
- for (const k in value) {
29
- value[k] = transformArray(value[k]);
30
- }
31
- }
32
- return value;
33
- };
34
- const createRichTextStorageTransformPlugin = () => {
35
- const plugin = new _apiHeadlessCms.StorageTransformPlugin({
1
+ import WebinyError from "@webiny/error";
2
+ import { StorageTransformPlugin } from "@webiny/api-headless-cms";
3
+ import { CompressorPlugin } from "@webiny/api";
4
+ export const createRichTextStorageTransformPlugin = () => {
5
+ const plugin = new StorageTransformPlugin({
6
+ name: "headless-cms.storage-transform.rich-text.default",
36
7
  fieldType: "rich-text",
37
8
  fromStorage: async ({
38
9
  field,
39
- value: storageValue
10
+ value: storageValue,
11
+ plugins
40
12
  }) => {
41
13
  if (!storageValue) {
42
14
  return storageValue;
43
15
  } else if (typeof storageValue !== "object") {
44
- throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}".`);
16
+ throw new WebinyError(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
45
17
  }
46
- /**
47
- * This is to circumvent a bug introduced with 5.8.0 storage operations.
48
- * Do not remove.
49
- */
50
- if (!storageValue["compression"]) {
18
+ let compressor;
19
+ try {
20
+ compressor = plugins.oneByType(CompressorPlugin.type);
21
+ } catch {
51
22
  return storageValue;
52
23
  }
53
- const {
54
- compression,
55
- value
56
- } = storageValue;
57
- if (compression !== "jsonpack") {
58
- throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
59
- compression
60
- });
61
- }
62
- /**
63
- * No point in going further if no value.
64
- */
65
- if (!value) {
66
- return null;
67
- }
68
24
  try {
69
- return _jsonpack.default.unpack(value);
70
- } catch (ex) {
71
- return null;
25
+ return await compressor.getCompressor().decompress(storageValue);
26
+ } catch {
27
+ return storageValue;
72
28
  }
73
29
  },
74
30
  toStorage: async ({
75
- value
31
+ value,
32
+ plugins
76
33
  }) => {
77
- /**
78
- * There is a possibility that we are trying to compress already compressed value.
79
- * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.
80
- */
81
- if (!!value?.compression) {
34
+ let compressor;
35
+ try {
36
+ compressor = plugins.oneByType(CompressorPlugin.type);
37
+ } catch {
82
38
  return value;
83
39
  }
84
- value = transformArray(value);
85
- let jsonValue = null;
86
40
  try {
87
- jsonValue = _jsonpack.default.pack(value);
88
- } catch (ex) {
89
- if (process.env.DEBUG !== "true") {
90
- return null;
91
- }
92
- console.log("Error while compressing rich-text.");
93
- console.log(ex.message);
41
+ return await compressor.getCompressor().compress(value);
42
+ } catch {
43
+ return value;
94
44
  }
95
- return {
96
- compression: "jsonpack",
97
- value: jsonValue
98
- };
99
45
  }
100
46
  });
101
47
  plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;
102
48
  return plugin;
103
49
  };
104
- exports.createRichTextStorageTransformPlugin = createRichTextStorageTransformPlugin;
105
50
 
106
51
  //# sourceMappingURL=richText.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_jsonpack","_interopRequireDefault","require","_error","_apiHeadlessCms","transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","WebinyError","storageId","compression","jsonpack","unpack","ex","toStorage","jsonValue","pack","process","env","DEBUG","console","log","message","name","exports"],"sources":["richText.ts"],"sourcesContent":["import jsonpack from \"jsonpack\";\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nexport type OriginalValue = Record<string, any> | any[];\n\nexport interface StorageValue {\n compression: string;\n value: any;\n}\n\n/**\n * Remove when jsonpack gets PR with a fix merged\n * https://github.com/rgcl/jsonpack/pull/25/files\n * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.\n */\n// TODO @ts-refactor figure better type\nconst transformArray = (value: any) => {\n if (!value) {\n return value;\n }\n let isArray = Array.isArray(value);\n const shouldBeArray = value instanceof Array === false && isArray;\n if (shouldBeArray) {\n value = Array.from(value);\n isArray = true;\n }\n if (typeof value === \"object\" || isArray) {\n for (const k in value) {\n value[k] = transformArray(value[k]);\n }\n }\n return value;\n};\n\nexport const createRichTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\".`\n );\n }\n /**\n * This is to circumvent a bug introduced with 5.8.0 storage operations.\n * Do not remove.\n */\n if (!storageValue[\"compression\"]) {\n return storageValue;\n }\n const { compression, value } = storageValue;\n if (compression !== \"jsonpack\") {\n throw new WebinyError(\n `This plugin cannot transform something not packed with \"jsonpack\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n /**\n * No point in going further if no value.\n */\n if (!value) {\n return null;\n }\n try {\n return jsonpack.unpack(value);\n } catch (ex) {\n return null;\n }\n },\n toStorage: async ({ value }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.\n */\n if (!!value?.compression) {\n return value;\n }\n value = transformArray(value);\n\n let jsonValue: string | null = null;\n try {\n jsonValue = jsonpack.pack(value);\n } catch (ex) {\n if (process.env.DEBUG !== \"true\") {\n return null;\n }\n console.log(\"Error while compressing rich-text.\");\n console.log(ex.message);\n }\n return {\n compression: \"jsonpack\",\n value: jsonValue\n };\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,cAAc,GAAIC,KAAU,IAAK;EACnC,IAAI,CAACA,KAAK,EAAE;IACR,OAAOA,KAAK;EAChB;EACA,IAAIC,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACD,KAAK,CAAC;EAClC,MAAMG,aAAa,GAAGH,KAAK,YAAYE,KAAK,KAAK,KAAK,IAAID,OAAO;EACjE,IAAIE,aAAa,EAAE;IACfH,KAAK,GAAGE,KAAK,CAACE,IAAI,CAACJ,KAAK,CAAC;IACzBC,OAAO,GAAG,IAAI;EAClB;EACA,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAIC,OAAO,EAAE;IACtC,KAAK,MAAMI,CAAC,IAAIL,KAAK,EAAE;MACnBA,KAAK,CAACK,CAAC,CAAC,GAAGN,cAAc,CAACC,KAAK,CAACK,CAAC,CAAC,CAAC;IACvC;EACJ;EACA,OAAOL,KAAK;AAChB,CAAC;AAEM,MAAMM,oCAAoC,GAAGA,CAAA,KAAM;EACtD,MAAMC,MAAM,GAAG,IAAIC,sCAAsB,CAAC;IACtCC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CA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AAO,CAAC;MAC3B;MACA,OAAO;QACHZ,WAAW,EAAE,UAAU;QACvBf,KAAK,EAAEoB;MACX,CAAC;IACL;EACJ,CAAC,CAAC;EACFb,MAAM,CAACqB,IAAI,GAAI,kDAAiD;EAEhE,OAAOrB,MAAM;AACjB,CAAC;AAACsB,OAAA,CAAAvB,oCAAA,GAAAA,oCAAA","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","StorageTransformPlugin","CompressorPlugin","createRichTextStorageTransformPlugin","plugin","name","fieldType","fromStorage","field","value","storageValue","plugins","storageId","fieldId","compressor","oneByType","type","getCompressor","decompress","toStorage","compress"],"sources":["richText.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport const createRichTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.rich-text.default\",\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue, plugins }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return storageValue;\n }\n\n try {\n return await compressor.getCompressor().decompress(storageValue);\n } catch {\n return storageValue;\n }\n },\n toStorage: async ({ value, plugins }) => {\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return value;\n }\n try {\n return await compressor.getCompressor().compress(value);\n } catch {\n return value;\n }\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gBAA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ACjB,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Client } from "@elastic/elasticsearch";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- import { CmsModel } from "@webiny/api-headless-cms/types";
1
+ import type { Client } from "@elastic/elasticsearch";
2
+ import type { PluginsContainer } from "@webiny/plugins";
3
+ import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
4
  export interface CreateElasticsearchIndexParams {
5
5
  client: Client;
6
6
  plugins: PluginsContainer;
@@ -1,13 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createElasticsearchIndex = void 0;
7
- var _CmsEntryElasticsearchIndexPlugin = require("../plugins/CmsEntryElasticsearchIndexPlugin");
8
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
9
- var _configurations = require("../configurations");
10
- const createElasticsearchIndex = async params => {
1
+ import { CmsEntryElasticsearchIndexPlugin } from "../plugins/CmsEntryElasticsearchIndexPlugin.js";
2
+ import { createIndex } from "@webiny/api-elasticsearch";
3
+ import { configurations } from "../configurations.js";
4
+ export const createElasticsearchIndex = async params => {
11
5
  const {
12
6
  client,
13
7
  plugins,
@@ -15,15 +9,14 @@ const createElasticsearchIndex = async params => {
15
9
  } = params;
16
10
  const {
17
11
  index
18
- } = _configurations.configurations.es({
12
+ } = configurations.es({
19
13
  model
20
14
  });
21
- await (0, _apiElasticsearch.createIndex)({
15
+ await createIndex({
22
16
  client,
23
17
  index,
24
- type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
18
+ type: CmsEntryElasticsearchIndexPlugin.type,
25
19
  tenant: model.tenant,
26
- locale: model.locale,
27
20
  plugins,
28
21
  onExists: () => {
29
22
  console.log(`Elasticsearch index "${index}" for the CMS model "${model.name}" already exists.`);
@@ -35,6 +28,5 @@ const createElasticsearchIndex = async params => {
35
28
  }
36
29
  });
37
30
  };
38
- exports.createElasticsearchIndex = createElasticsearchIndex;
39
31
 
40
32
  //# sourceMappingURL=createElasticsearchIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_CmsEntryElasticsearchIndexPlugin","require","_apiElasticsearch","_configurations","createElasticsearchIndex","params","client","plugins","model","index","configurations","es","createIndex","type","CmsEntryElasticsearchIndexPlugin","tenant","locale","onExists","console","log","name","onError","ex","error","exports"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { createIndex } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, plugins, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n await createIndex({\n client,\n index,\n type: CmsEntryElasticsearchIndexPlugin.type,\n tenant: model.tenant,\n locale: model.locale,\n plugins,\n onExists: () => {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n },\n onError: ex => {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n return ex;\n }\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,iCAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASO,MAAMG,wBAAwB,GAAG,MAAOC,MAAsC,IAAK;EACtF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EAEF,MAAM,IAAAI,6BAAW,EAAC;IACdN,MAAM;IACNG,KAAK;IACLI,IAAI,EAAEC,kEAAgC,CAACD,IAAI;IAC3CE,MAAM,EAAEP,KAAK,CAACO,MAAM;IACpBC,MAAM,EAAER,KAAK,CAACQ,MAAM;IACpBT,OAAO;IACPU,QAAQ,EAAEA,CAAA,KAAM;MACZC,OAAO,CAACC,GAAG,CACN,wBAAuBV,KAAM,wBAAuBD,KAAK,CAACY,IAAK,mBACpE,CAAC;IACL,CAAC;IACDC,OAAO,EAAEC,EAAE,IAAI;MACXJ,OAAO,CAACK,KAAK,CACR,yCAAwCd,KAAM,wBAAuBD,KAAK,CAACY,IAAK,IACrF,CAAC;MACDF,OAAO,CAACK,KAAK,CAACD,EAAE,CAAC;MACjB,OAAOA,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAApB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["CmsEntryElasticsearchIndexPlugin","createIndex","configurations","createElasticsearchIndex","params","client","plugins","model","index","es","type","tenant","onExists","console","log","name","onError","ex","error"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin.js\";\nimport { createIndex } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, plugins, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n await createIndex({\n client,\n index,\n type: CmsEntryElasticsearchIndexPlugin.type,\n tenant: model.tenant,\n plugins,\n onExists: () => {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n },\n onError: ex => {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n return ex;\n }\n });\n};\n"],"mappings":"AAEA,SAASA,gCAAgC;AACzC,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,cAAc;AASvB,OAAO,MAAMC,wBAAwB,GAAG,MAAOC,MAAsC,IAAK;EACtF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGN,cAAc,CAACO,EAAE,CAAC;IAChCF;EACJ,CAAC,CAAC;EAEF,MAAMN,WAAW,CAAC;IACdI,MAAM;IACNG,KAAK;IACLE,IAAI,EAAEV,gCAAgC,CAACU,IAAI;IAC3CC,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBL,OAAO;IACPM,QAAQ,EAAEA,CAAA,KAAM;MACZC,OAAO,CAACC,GAAG,CACP,wBAAwBN,KAAK,wBAAwBD,KAAK,CAACQ,IAAI,mBACnE,CAAC;IACL,CAAC;IACDC,OAAO,EAAEC,EAAE,IAAI;MACXJ,OAAO,CAACK,KAAK,CACT,yCAAyCV,KAAK,wBAAwBD,KAAK,CAACQ,IAAI,IACpF,CAAC;MACDF,OAAO,CAACK,KAAK,CAACD,EAAE,CAAC;MACjB,OAAOA,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { Client } from "@elastic/elasticsearch";
2
- import { CmsModel } from "@webiny/api-headless-cms/types";
1
+ import type { Client } from "@elastic/elasticsearch";
2
+ import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
3
3
  interface DeleteElasticsearchIndexParams {
4
4
  client: Client;
5
5
  model: CmsModel;
@@ -1,18 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.deleteElasticsearchIndex = void 0;
7
- var _configurations = require("../configurations");
8
- const deleteElasticsearchIndex = async params => {
1
+ import { configurations } from "../configurations.js";
2
+ export const deleteElasticsearchIndex = async params => {
9
3
  const {
10
4
  client,
11
5
  model
12
6
  } = params;
13
7
  const {
14
8
  index
15
- } = _configurations.configurations.es({
9
+ } = configurations.es({
16
10
  model
17
11
  });
18
12
  const {
@@ -33,6 +27,5 @@ const deleteElasticsearchIndex = async params => {
33
27
  console.log(ex.message);
34
28
  }
35
29
  };
36
- exports.deleteElasticsearchIndex = deleteElasticsearchIndex;
37
30
 
38
31
  //# sourceMappingURL=deleteElasticsearchIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_configurations","require","deleteElasticsearchIndex","params","client","model","index","configurations","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message","exports"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"~/configurations\";\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,IAAAA,eAAA,GAAAC,OAAA;AAOO,MAAMC,wBAAwB,GAAG,MACpCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EACF,MAAM;IAAEI,IAAI,EAAEC;EAAO,CAAC,GAAG,MAAMN,MAAM,CAACO,OAAO,CAACD,MAAM,CAAC;IACjDJ;EACJ,CAAC,CAAC;EACF,IAAI,CAACI,MAAM,EAAE;IACT;EACJ;EAEA,IAAI;IACA,MAAMN,MAAM,CAACO,OAAO,CAACC,MAAM,CAAC;MACxBN,KAAK;MACLO,kBAAkB,EAAE;IACxB,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAE,yCAAwCV,KAAM,2BAA0B,CAAC;IACtFS,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;EAC3B;AACJ,CAAC;AAACC,OAAA,CAAAhB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
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 \"@elastic/elasticsearch\";\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,2 +1,2 @@
1
- declare const _default: () => (import("../types").CmsModelFieldToElasticsearchPlugin[] | import("..").CmsEntryElasticsearchQueryBuilderValueSearchPlugin[])[];
1
+ declare const _default: () => (import("../types.js").CmsModelFieldToElasticsearchPlugin[] | import("../index.js").CmsEntryElasticsearchQueryBuilderValueSearchPlugin[])[];
2
2
  export default _default;
@@ -1,13 +1,5 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _indexing = _interopRequireDefault(require("./indexing"));
9
- var _search = _interopRequireDefault(require("./search"));
10
- var _default = () => [(0, _indexing.default)(), (0, _search.default)()];
11
- exports.default = _default;
1
+ import elasticsearchIndexingPlugins from "./indexing/index.js";
2
+ import elasticsearchSearchPlugins from "./search/index.js";
3
+ export default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];
12
4
 
13
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_indexing","_interopRequireDefault","require","_search","_default","elasticsearchIndexingPlugins","elasticsearchSearchPlugins","exports","default"],"sources":["index.ts"],"sourcesContent":["import elasticsearchIndexingPlugins from \"./indexing\";\nimport elasticsearchSearchPlugins from \"./search\";\n\nexport default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAkD,IAAAE,QAAA,GAEnCA,CAAA,KAAM,CAAC,IAAAC,iBAA4B,EAAC,CAAC,EAAE,IAAAC,eAA0B,EAAC,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["elasticsearchIndexingPlugins","elasticsearchSearchPlugins"],"sources":["index.ts"],"sourcesContent":["import elasticsearchIndexingPlugins from \"./indexing/index.js\";\nimport elasticsearchSearchPlugins from \"./search/index.js\";\n\nexport default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];\n"],"mappings":"AAAA,OAAOA,4BAA4B;AACnC,OAAOC,0BAA0B;AAEjC,eAAe,MAAM,CAACD,4BAA4B,CAAC,CAAC,EAAEC,0BAA0B,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import { CmsModelFieldToElasticsearchPlugin } from "../../types";
1
+ import type { CmsModelFieldToElasticsearchPlugin } from "../../types.js";
2
2
  declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
3
  export default _default;
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
1
  const convertTimeToNumber = time => {
8
2
  if (!time) {
9
3
  return null;
@@ -48,7 +42,7 @@ const convertValueToIndex = (value, field) => {
48
42
  }
49
43
  return value;
50
44
  };
51
- var _default = () => ({
45
+ export default () => ({
52
46
  type: "cms-model-field-to-elastic-search",
53
47
  name: "cms-model-field-to-elastic-search-datetime",
54
48
  fieldType: "datetime",
@@ -83,6 +77,5 @@ var _default = () => ({
83
77
  return convertValueFromIndex(value, field);
84
78
  }
85
79
  });
86
- exports.default = _default;
87
80
 
88
81
  //# sourceMappingURL=dateTimeIndexing.js.map