@webiny/api-headless-cms-ddb 0.0.0-unstable.496cf268ac → 0.0.0-unstable.5387e5f7c8

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 (294) hide show
  1. package/README.md +6 -20
  2. package/abstractions/CmsDdbDataLoaders.d.ts +5 -0
  3. package/abstractions/CmsDdbDataLoaders.js +5 -0
  4. package/abstractions/CmsDdbDataLoaders.js.map +1 -0
  5. package/abstractions/CmsDdbEntryEntity.d.ts +5 -0
  6. package/abstractions/CmsDdbEntryEntity.js +5 -0
  7. package/abstractions/CmsDdbEntryEntity.js.map +1 -0
  8. package/abstractions/CmsDdbGroupEntity.d.ts +5 -0
  9. package/abstractions/CmsDdbGroupEntity.js +5 -0
  10. package/abstractions/CmsDdbGroupEntity.js.map +1 -0
  11. package/abstractions/CmsDdbModelEntity.d.ts +5 -0
  12. package/abstractions/CmsDdbModelEntity.js +5 -0
  13. package/abstractions/CmsDdbModelEntity.js.map +1 -0
  14. package/abstractions/CmsDdbTable.d.ts +5 -0
  15. package/abstractions/CmsDdbTable.js +5 -0
  16. package/abstractions/CmsDdbTable.js.map +1 -0
  17. package/definitions/entry.d.ts +4 -5
  18. package/definitions/entry.js +10 -93
  19. package/definitions/entry.js.map +1 -1
  20. package/definitions/group.d.ts +4 -5
  21. package/definitions/group.js +10 -64
  22. package/definitions/group.js.map +1 -1
  23. package/definitions/model.d.ts +4 -5
  24. package/definitions/model.js +10 -108
  25. package/definitions/model.js.map +1 -1
  26. package/definitions/table.d.ts +4 -6
  27. package/definitions/table.js +7 -26
  28. package/definitions/table.js.map +1 -1
  29. package/definitions/types.d.ts +65 -0
  30. package/definitions/types.js +0 -0
  31. package/index.d.ts +10 -3
  32. package/index.js +45 -129
  33. package/index.js.map +1 -1
  34. package/operations/entry/DdbCreateEntry.d.ts +16 -0
  35. package/operations/entry/DdbCreateEntry.js +77 -0
  36. package/operations/entry/DdbCreateEntry.js.map +1 -0
  37. package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +16 -0
  38. package/operations/entry/DdbCreateEntryRevisionFrom.js +85 -0
  39. package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -0
  40. package/operations/entry/DdbDeleteEntry.d.ts +16 -0
  41. package/operations/entry/DdbDeleteEntry.js +65 -0
  42. package/operations/entry/DdbDeleteEntry.js.map +1 -0
  43. package/operations/entry/DdbDeleteEntryRevision.d.ts +17 -0
  44. package/operations/entry/DdbDeleteEntryRevision.js +91 -0
  45. package/operations/entry/DdbDeleteEntryRevision.js.map +1 -0
  46. package/operations/entry/DdbDeleteMultipleEntries.d.ts +16 -0
  47. package/operations/entry/DdbDeleteMultipleEntries.js +59 -0
  48. package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -0
  49. package/operations/entry/DdbGetEntriesByIds.d.ts +14 -0
  50. package/operations/entry/DdbGetEntriesByIds.js +31 -0
  51. package/operations/entry/DdbGetEntriesByIds.js.map +1 -0
  52. package/operations/entry/DdbGetEntry.d.ts +14 -0
  53. package/operations/entry/DdbGetEntry.js +27 -0
  54. package/operations/entry/DdbGetEntry.js.map +1 -0
  55. package/operations/entry/DdbGetLatestEntriesByIds.d.ts +14 -0
  56. package/operations/entry/DdbGetLatestEntriesByIds.js +31 -0
  57. package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -0
  58. package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +14 -0
  59. package/operations/entry/DdbGetLatestRevisionByEntryId.js +35 -0
  60. package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -0
  61. package/operations/entry/DdbGetPreviousRevision.d.ts +14 -0
  62. package/operations/entry/DdbGetPreviousRevision.js +53 -0
  63. package/operations/entry/DdbGetPreviousRevision.js.map +1 -0
  64. package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +14 -0
  65. package/operations/entry/DdbGetPublishedEntriesByIds.js +31 -0
  66. package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -0
  67. package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +14 -0
  68. package/operations/entry/DdbGetPublishedRevisionByEntryId.js +35 -0
  69. package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -0
  70. package/operations/entry/DdbGetRevisionById.d.ts +14 -0
  71. package/operations/entry/DdbGetRevisionById.js +34 -0
  72. package/operations/entry/DdbGetRevisionById.js.map +1 -0
  73. package/operations/entry/DdbGetRevisions.d.ts +14 -0
  74. package/operations/entry/DdbGetRevisions.js +33 -0
  75. package/operations/entry/DdbGetRevisions.js.map +1 -0
  76. package/operations/entry/DdbGetUniqueFieldValues.d.ts +12 -0
  77. package/operations/entry/DdbGetUniqueFieldValues.js +31 -0
  78. package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -0
  79. package/operations/entry/DdbListEntries.d.ts +28 -0
  80. package/operations/entry/DdbListEntries.js +124 -0
  81. package/operations/entry/DdbListEntries.js.map +1 -0
  82. package/operations/entry/DdbMoveEntry.d.ts +14 -0
  83. package/operations/entry/DdbMoveEntry.js +57 -0
  84. package/operations/entry/DdbMoveEntry.js.map +1 -0
  85. package/operations/entry/DdbMoveToBin.d.ts +16 -0
  86. package/operations/entry/DdbMoveToBin.js +77 -0
  87. package/operations/entry/DdbMoveToBin.js.map +1 -0
  88. package/operations/entry/DdbPublishEntry.d.ts +18 -0
  89. package/operations/entry/DdbPublishEntry.js +162 -0
  90. package/operations/entry/DdbPublishEntry.js.map +1 -0
  91. package/operations/entry/DdbRestoreFromBin.d.ts +16 -0
  92. package/operations/entry/DdbRestoreFromBin.js +78 -0
  93. package/operations/entry/DdbRestoreFromBin.js.map +1 -0
  94. package/operations/entry/DdbUnpublishEntry.d.ts +17 -0
  95. package/operations/entry/DdbUnpublishEntry.js +112 -0
  96. package/operations/entry/DdbUnpublishEntry.js.map +1 -0
  97. package/operations/entry/DdbUpdateEntry.d.ts +17 -0
  98. package/operations/entry/DdbUpdateEntry.js +105 -0
  99. package/operations/entry/DdbUpdateEntry.js.map +1 -0
  100. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  101. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  102. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  103. package/operations/entry/dataLoader/constants.d.ts +1 -0
  104. package/operations/entry/dataLoader/constants.js +5 -0
  105. package/operations/entry/dataLoader/constants.js.map +1 -0
  106. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  107. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  108. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  109. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  110. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  111. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  112. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  113. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
  114. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  115. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  116. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
  117. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  118. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  119. package/operations/entry/dataLoader/getRevisionById.js +42 -0
  120. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  121. package/operations/entry/dataLoader/index.d.ts +8 -0
  122. package/operations/entry/dataLoader/index.js +18 -0
  123. package/operations/entry/dataLoader/index.js.map +1 -0
  124. package/operations/entry/dataLoader/types.d.ts +6 -0
  125. package/operations/entry/dataLoader/types.js +0 -0
  126. package/operations/entry/dataLoaders.d.ts +16 -31
  127. package/operations/entry/dataLoaders.js +92 -272
  128. package/operations/entry/dataLoaders.js.map +1 -1
  129. package/operations/entry/feature.d.ts +4 -0
  130. package/operations/entry/feature.js +55 -0
  131. package/operations/entry/feature.js.map +1 -0
  132. package/operations/entry/keys.d.ts +46 -2
  133. package/operations/entry/keys.js +54 -49
  134. package/operations/entry/keys.js.map +1 -1
  135. package/operations/entry/storageEntryUtils.d.ts +8 -0
  136. package/operations/entry/storageEntryUtils.js +25 -0
  137. package/operations/entry/storageEntryUtils.js.map +1 -0
  138. package/operations/group/DdbCreateGroup.d.ts +12 -0
  139. package/operations/group/DdbCreateGroup.js +35 -0
  140. package/operations/group/DdbCreateGroup.js.map +1 -0
  141. package/operations/group/DdbDeleteGroup.d.ts +12 -0
  142. package/operations/group/DdbDeleteGroup.js +31 -0
  143. package/operations/group/DdbDeleteGroup.js.map +1 -0
  144. package/operations/group/DdbGetGroup.d.ts +12 -0
  145. package/operations/group/DdbGetGroup.js +31 -0
  146. package/operations/group/DdbGetGroup.js.map +1 -0
  147. package/operations/group/DdbListGroups.d.ts +14 -0
  148. package/operations/group/DdbListGroups.js +52 -0
  149. package/operations/group/DdbListGroups.js.map +1 -0
  150. package/operations/group/DdbUpdateGroup.d.ts +12 -0
  151. package/operations/group/DdbUpdateGroup.js +35 -0
  152. package/operations/group/DdbUpdateGroup.js.map +1 -0
  153. package/operations/group/feature.d.ts +4 -0
  154. package/operations/group/feature.js +19 -0
  155. package/operations/group/feature.js.map +1 -0
  156. package/operations/group/keys.d.ts +15 -0
  157. package/operations/group/keys.js +17 -0
  158. package/operations/group/keys.js.map +1 -0
  159. package/operations/model/DdbCreateModel.d.ts +12 -0
  160. package/operations/model/DdbCreateModel.js +37 -0
  161. package/operations/model/DdbCreateModel.js.map +1 -0
  162. package/operations/model/DdbDeleteModel.d.ts +12 -0
  163. package/operations/model/DdbDeleteModel.js +31 -0
  164. package/operations/model/DdbDeleteModel.js.map +1 -0
  165. package/operations/model/DdbGetModel.d.ts +12 -0
  166. package/operations/model/DdbGetModel.js +30 -0
  167. package/operations/model/DdbGetModel.js.map +1 -0
  168. package/operations/model/DdbListModels.d.ts +12 -0
  169. package/operations/model/DdbListModels.js +36 -0
  170. package/operations/model/DdbListModels.js.map +1 -0
  171. package/operations/model/DdbUpdateModel.d.ts +12 -0
  172. package/operations/model/DdbUpdateModel.js +36 -0
  173. package/operations/model/DdbUpdateModel.js.map +1 -0
  174. package/operations/model/feature.d.ts +4 -0
  175. package/operations/model/feature.js +19 -0
  176. package/operations/model/feature.js.map +1 -0
  177. package/operations/model/keys.d.ts +15 -0
  178. package/operations/model/keys.js +16 -0
  179. package/operations/model/keys.js.map +1 -0
  180. package/package.json +30 -33
  181. package/types.d.ts +12 -45
  182. package/types.js +8 -14
  183. package/types.js.map +1 -1
  184. package/definitions/settings.d.ts +0 -9
  185. package/definitions/settings.js +0 -53
  186. package/definitions/settings.js.map +0 -1
  187. package/definitions/system.d.ts +0 -9
  188. package/definitions/system.js +0 -41
  189. package/definitions/system.js.map +0 -1
  190. package/dynamoDb/index.d.ts +0 -2
  191. package/dynamoDb/index.js +0 -13
  192. package/dynamoDb/index.js.map +0 -1
  193. package/dynamoDb/path/plainObject.d.ts +0 -2
  194. package/dynamoDb/path/plainObject.js +0 -33
  195. package/dynamoDb/path/plainObject.js.map +0 -1
  196. package/dynamoDb/storage/date.d.ts +0 -3
  197. package/dynamoDb/storage/date.js +0 -91
  198. package/dynamoDb/storage/date.js.map +0 -1
  199. package/dynamoDb/storage/longText.d.ts +0 -10
  200. package/dynamoDb/storage/longText.js +0 -91
  201. package/dynamoDb/storage/longText.js.map +0 -1
  202. package/dynamoDb/storage/richText.d.ts +0 -2
  203. package/dynamoDb/storage/richText.js +0 -95
  204. package/dynamoDb/storage/richText.js.map +0 -1
  205. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  206. package/dynamoDb/transformValue/datetime.js +0 -45
  207. package/dynamoDb/transformValue/datetime.js.map +0 -1
  208. package/operations/entry/filtering/createExpressions.d.ts +0 -26
  209. package/operations/entry/filtering/createExpressions.js +0 -176
  210. package/operations/entry/filtering/createExpressions.js.map +0 -1
  211. package/operations/entry/filtering/createFields.d.ts +0 -14
  212. package/operations/entry/filtering/createFields.js +0 -105
  213. package/operations/entry/filtering/createFields.js.map +0 -1
  214. package/operations/entry/filtering/extractSort.d.ts +0 -17
  215. package/operations/entry/filtering/extractSort.js +0 -67
  216. package/operations/entry/filtering/extractSort.js.map +0 -1
  217. package/operations/entry/filtering/filter.d.ts +0 -15
  218. package/operations/entry/filtering/filter.js +0 -143
  219. package/operations/entry/filtering/filter.js.map +0 -1
  220. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  221. package/operations/entry/filtering/fullTextSearch.js +0 -48
  222. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  223. package/operations/entry/filtering/getValue.d.ts +0 -5
  224. package/operations/entry/filtering/getValue.js +0 -63
  225. package/operations/entry/filtering/getValue.js.map +0 -1
  226. package/operations/entry/filtering/index.d.ts +0 -2
  227. package/operations/entry/filtering/index.js +0 -19
  228. package/operations/entry/filtering/index.js.map +0 -1
  229. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  230. package/operations/entry/filtering/mapPlugins.js +0 -31
  231. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  232. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  233. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -41
  234. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  235. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  236. package/operations/entry/filtering/plugins/index.js +0 -13
  237. package/operations/entry/filtering/plugins/index.js.map +0 -1
  238. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  239. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -86
  240. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  241. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
  242. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
  243. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  244. package/operations/entry/filtering/sort.d.ts +0 -12
  245. package/operations/entry/filtering/sort.js +0 -69
  246. package/operations/entry/filtering/sort.js.map +0 -1
  247. package/operations/entry/filtering/systemFields.d.ts +0 -4
  248. package/operations/entry/filtering/systemFields.js +0 -70
  249. package/operations/entry/filtering/systemFields.js.map +0 -1
  250. package/operations/entry/filtering/transform.d.ts +0 -6
  251. package/operations/entry/filtering/transform.js +0 -16
  252. package/operations/entry/filtering/transform.js.map +0 -1
  253. package/operations/entry/filtering/types.d.ts +0 -40
  254. package/operations/entry/filtering/types.js +0 -5
  255. package/operations/entry/filtering/types.js.map +0 -1
  256. package/operations/entry/filtering/values.d.ts +0 -2
  257. package/operations/entry/filtering/values.js +0 -22
  258. package/operations/entry/filtering/values.js.map +0 -1
  259. package/operations/entry/filtering/where.d.ts +0 -5
  260. package/operations/entry/filtering/where.js +0 -32
  261. package/operations/entry/filtering/where.js.map +0 -1
  262. package/operations/entry/index.d.ts +0 -8
  263. package/operations/entry/index.js +0 -787
  264. package/operations/entry/index.js.map +0 -1
  265. package/operations/entry/systemFields.d.ts +0 -2
  266. package/operations/entry/systemFields.js +0 -72
  267. package/operations/entry/systemFields.js.map +0 -1
  268. package/operations/group/index.d.ts +0 -9
  269. package/operations/group/index.js +0 -162
  270. package/operations/group/index.js.map +0 -1
  271. package/operations/model/index.d.ts +0 -7
  272. package/operations/model/index.js +0 -137
  273. package/operations/model/index.js.map +0 -1
  274. package/operations/settings/index.d.ts +0 -7
  275. package/operations/settings/index.js +0 -111
  276. package/operations/settings/index.js.map +0 -1
  277. package/operations/system/index.d.ts +0 -7
  278. package/operations/system/index.js +0 -82
  279. package/operations/system/index.js.map +0 -1
  280. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
  281. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
  282. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  283. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  284. package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
  285. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  286. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  287. package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
  288. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  289. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  290. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
  291. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  292. package/plugins/index.d.ts +0 -4
  293. package/plugins/index.js +0 -49
  294. package/plugins/index.js.map +0 -1
@@ -1,111 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createSettingsStorageOperations = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _get = require("@webiny/db-dynamodb/utils/get");
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
12
- const convertToDbData = settings => {
13
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
14
- contentModelLastChange: settings.contentModelLastChange.toISOString()
15
- });
16
- };
17
- const convertFromDbData = settings => {
18
- if (!settings) {
19
- return null;
20
- }
21
- let contentModelLastChange;
22
- try {
23
- contentModelLastChange = new Date(settings.contentModelLastChange);
24
- } catch {
25
- contentModelLastChange = new Date();
26
- }
27
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
28
- contentModelLastChange
29
- });
30
- };
31
- const createPartitionKey = ({
32
- tenant,
33
- locale
34
- }) => {
35
- return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
36
- };
37
- const createSortKey = () => {
38
- return "settings";
39
- };
40
- const createKeys = params => {
41
- return {
42
- PK: createPartitionKey(params),
43
- SK: createSortKey()
44
- };
45
- };
46
- const createSettingsStorageOperations = params => {
47
- const {
48
- entity
49
- } = params;
50
- const create = async params => {
51
- const {
52
- settings
53
- } = params;
54
- const keys = createKeys(settings);
55
- const dbSettings = convertToDbData(settings);
56
- try {
57
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
58
- return settings;
59
- } catch (ex) {
60
- throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
61
- error: ex,
62
- settings,
63
- dbSettings,
64
- keys
65
- });
66
- }
67
- };
68
- const update = async params => {
69
- const {
70
- settings
71
- } = params;
72
- const keys = createKeys(settings);
73
- const dbSettings = convertToDbData(settings);
74
- try {
75
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
76
- return settings;
77
- } catch (ex) {
78
- throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
79
- error: ex,
80
- settings,
81
- dbSettings,
82
- keys
83
- });
84
- }
85
- };
86
- const get = async params => {
87
- const keys = createKeys(params);
88
- try {
89
- const record = await (0, _get.get)({
90
- entity,
91
- keys
92
- });
93
- if (!record) {
94
- return null;
95
- }
96
- const settings = (0, _cleanup.cleanupItem)(entity, record);
97
- return convertFromDbData(settings);
98
- } catch (ex) {
99
- throw new _error.default(ex.message || "Could not get settings.", ex.code || "GET_SETTINGS_ERROR", {
100
- error: ex,
101
- keys
102
- });
103
- }
104
- };
105
- return {
106
- create,
107
- get,
108
- update
109
- };
110
- };
111
- exports.createSettingsStorageOperations = createSettingsStorageOperations;
@@ -1 +0,0 @@
1
- {"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,eAAe,GAAIC,QAAqB,IAAoB;EAC9D,mEACOA,QAAQ;IACXC,sBAAsB,EAAED,QAAQ,CAACC,sBAAsB,CAACC,WAAW;EAAE;AAE7E,CAAC;AAED,MAAMC,iBAAiB,GAAIH,QAAwB,IAAyB;EACxE,IAAI,CAACA,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,IAAIC,sBAAsB;EAC1B,IAAI;IACAA,sBAAsB,GAAG,IAAIG,IAAI,CAACJ,QAAQ,CAACC,sBAAsB,CAAC;EACtE,CAAC,CAAC,MAAM;IACJA,sBAAsB,GAAG,IAAIG,IAAI,EAAE;EACvC;EACA,mEACOJ,QAAQ;IACXC;EAAsB;AAE9B,CAAC;AAOD,MAAMI,kBAAkB,GAAG,CAAC;EAAEC,MAAM;EAAEC;AAA2B,CAAC,KAAa;EAC3E,OAAQ,KAAID,MAAO,MAAKC,MAAO,eAAc;AACjD,CAAC;AAED,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,UAAU;AACrB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9BE,EAAE,EAAEJ,aAAa;EACrB,CAAC;AACL,CAAC;AAMM,MAAMK,+BAA+B,GACxCH,MAA6C,IACd;EAC/B,MAAM;IAAEI;EAAO,CAAC,GAAGJ,MAAM;EAEzB,MAAMK,MAAM,GAAG,MAAOL,MAAgD,IAAK;IACvE,MAAM;MAAEV;IAAS,CAAC,GAAGU,MAAM;IAC3B,MAAMM,IAAI,GAAGP,UAAU,CAACT,QAAQ,CAAC;IAEjC,MAAMiB,UAAyB,GAAGlB,eAAe,CAACC,QAAQ,CAAC;IAE3D,IAAI;MACA,MAAMc,MAAM,CAACI,GAAG,6DACTD,UAAU,GACVD,IAAI,EACT;MACF,OAAOhB,QAAQ;IACnB,CAAC,CAAC,OAAOmB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,4BAA4B,EAC1CF,EAAE,CAACG,IAAI,IAAI,uBAAuB,EAClC;QACIC,KAAK,EAAEJ,EAAE;QACTnB,QAAQ;QACRiB,UAAU;QACVD;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMQ,MAAM,GAAG,MAAOd,MAAgD,IAAK;IACvE,MAAM;MAAEV;IAAS,CAAC,GAAGU,MAAM;IAE3B,MAAMM,IAAI,GAAGP,UAAU,CAACT,QAAQ,CAAC;IAEjC,MAAMiB,UAAyB,GAAGlB,eAAe,CAACC,QAAQ,CAAC;IAE3D,IAAI;MACA,MAAMc,MAAM,CAACI,GAAG,6DACTD,UAAU,GACVD,IAAI,EACT;MACF,OAAOhB,QAAQ;IACnB,CAAC,CAAC,OAAOmB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,4BAA4B,EAC1CF,EAAE,CAACG,IAAI,IAAI,uBAAuB,EAClC;QACIC,KAAK,EAAEJ,EAAE;QACTnB,QAAQ;QACRiB,UAAU;QACVD;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMS,GAAG,GAAG,MAAOf,MAA6C,IAAK;IACjE,MAAMM,IAAI,GAAGP,UAAU,CAACC,MAAM,CAAC;IAC/B,IAAI;MACA,MAAMgB,MAAM,GAAG,MAAM,IAAAC,QAAS,EAAgB;QAC1Cb,MAAM;QACNE;MACJ,CAAC,CAAC;MACF,IAAI,CAACU,MAAM,EAAE;QACT,OAAO,IAAI;MACf;MACA,MAAM1B,QAAQ,GAAG,IAAA4B,oBAAW,EAACd,MAAM,EAAEY,MAAM,CAAkB;MAC7D,OAAOvB,iBAAiB,CAACH,QAAQ,CAAC;IACtC,CAAC,CAAC,OAAOmB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,yBAAyB,EACvCF,EAAE,CAACG,IAAI,IAAI,oBAAoB,EAC/B;QACIC,KAAK,EAAEJ,EAAE;QACTH;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACHD,MAAM;IACNU,GAAG;IACHD;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -1,7 +0,0 @@
1
- import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- interface CreateSystemStorageOperationsParams {
4
- entity: Entity<any>;
5
- }
6
- export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => CmsSystemStorageOperations;
7
- export {};
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createSystemStorageOperations = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _error = _interopRequireDefault(require("@webiny/error"));
10
- var _get = require("@webiny/db-dynamodb/utils/get");
11
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
12
- const createPartitionKey = ({
13
- tenant
14
- }) => {
15
- return `T#${tenant.toLowerCase()}#SYSTEM`;
16
- };
17
- const createSortKey = () => {
18
- return "CMS";
19
- };
20
- const createKeys = params => {
21
- return {
22
- PK: createPartitionKey(params),
23
- SK: createSortKey()
24
- };
25
- };
26
- const createSystemStorageOperations = params => {
27
- const {
28
- entity
29
- } = params;
30
- const create = async ({
31
- system
32
- }) => {
33
- const keys = createKeys(system);
34
- try {
35
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
36
- return system;
37
- } catch (ex) {
38
- throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
39
- error: ex,
40
- system,
41
- keys
42
- });
43
- }
44
- };
45
- const update = async params => {
46
- const {
47
- system
48
- } = params;
49
- const keys = createKeys(system);
50
- try {
51
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
52
- return system;
53
- } catch (ex) {
54
- throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
55
- error: ex,
56
- system,
57
- keys
58
- });
59
- }
60
- };
61
- const get = async params => {
62
- const keys = createKeys(params);
63
- try {
64
- const system = await (0, _get.get)({
65
- entity,
66
- keys
67
- });
68
- return (0, _cleanup.cleanupItem)(entity, system);
69
- } catch (ex) {
70
- throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
71
- error: ex,
72
- keys
73
- });
74
- }
75
- };
76
- return {
77
- create,
78
- update,
79
- get
80
- };
81
- };
82
- exports.createSystemStorageOperations = createSystemStorageOperations;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AASA,MAAMA,kBAAkB,GAAG,CAAC;EAAEC;AAA2B,CAAC,KAAa;EACnE,OAAQ,KAAIA,MAAM,CAACC,WAAW,EAAG,SAAQ;AAC7C,CAAC;AACD,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,KAAK;AAChB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9BE,EAAE,EAAEJ,aAAa;EACrB,CAAC;AACL,CAAC;AAEM,MAAMK,6BAA6B,GACtCH,MAA2C,IACd;EAC7B,MAAM;IAAEI;EAAO,CAAC,GAAGJ,MAAM;EAEzB,MAAMK,MAAM,GAAG,OAAO;IAAEC;EAA+C,CAAC,KAAK;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAM,CAAC;IAC/B,IAAI;MACA,MAAMF,MAAM,CAACI,GAAG,6DACTF,MAAM,GACNC,IAAI,EACT;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,0BAA0B,EACxCF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTH,MAAM;QACNC;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMO,MAAM,GAAG,MAAOd,MAA8C,IAAK;IACrE,MAAM;MAAEM;IAAO,CAAC,GAAGN,MAAM;IAEzB,MAAMO,IAAI,GAAGR,UAAU,CAACO,MAAM,CAAC;IAE/B,IAAI;MACA,MAAMF,MAAM,CAACI,GAAG,6DACTF,MAAM,GACNC,IAAI,EACT;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,0BAA0B,EACxCF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTH,MAAM;QACNC;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMQ,GAAG,GAAG,MAAOf,MAA2C,IAAK;IAC/D,MAAMO,IAAI,GAAGR,UAAU,CAACC,MAAM,CAAC;IAE/B,IAAI;MACA,MAAMM,MAAM,GAAG,MAAM,IAAAU,QAAS,EAAY;QACtCZ,MAAM;QACNG;MACJ,CAAC,CAAC;MACF,OAAO,IAAAU,oBAAW,EAACb,MAAM,EAAEE,MAAM,CAAC;IACtC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,uBAAuB,EACrCF,EAAE,CAACG,IAAI,IAAI,kBAAkB,EAC7B;QACIC,KAAK,EAAEJ,EAAE;QACTF;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACHF,MAAM;IACNS,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -1,22 +0,0 @@
1
- import { Plugin } from "@webiny/plugins/Plugin";
2
- import { CmsModelField } from "@webiny/api-headless-cms/types";
3
- export interface CreatePathCallableParams {
4
- field: Partial<CmsModelField> & Pick<CmsModelField, "fieldId" | "storageId" | "id">;
5
- index?: number;
6
- }
7
- export interface CreatePathCallable {
8
- (params: CreatePathCallableParams): string;
9
- }
10
- export interface CmsEntryFieldFilterPathPluginParams {
11
- fieldType: string;
12
- fieldId?: string[];
13
- path: string | CreatePathCallable;
14
- }
15
- export declare class CmsEntryFieldFilterPathPlugin extends Plugin {
16
- static readonly type: string;
17
- private readonly config;
18
- get fieldType(): string;
19
- constructor(config: CmsEntryFieldFilterPathPluginParams);
20
- canUse(field: Pick<CmsModelField, "fieldId" | "type">): boolean;
21
- createPath(params: CreatePathCallableParams): string;
22
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.CmsEntryFieldFilterPathPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _error = _interopRequireDefault(require("@webiny/error"));
10
- var _Plugin = require("@webiny/plugins/Plugin");
11
- class CmsEntryFieldFilterPathPlugin extends _Plugin.Plugin {
12
- get fieldType() {
13
- return this.config.fieldType;
14
- }
15
- constructor(config) {
16
- super();
17
- (0, _defineProperty2.default)(this, "config", void 0);
18
- this.config = config;
19
- this.name = `${this.constructor.type}-${this.config.fieldType}`;
20
- }
21
- canUse(field) {
22
- if (field.type !== this.config.fieldType) {
23
- return false;
24
- }
25
- const fieldId = this.config.fieldId;
26
- if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
27
- return true;
28
- }
29
- return fieldId.includes(field.fieldId);
30
- }
31
- createPath(params) {
32
- if (typeof this.config.path === "function") {
33
- return this.config.path(params);
34
- } else if (typeof this.config.path === "string") {
35
- return this.config.path;
36
- }
37
- throw new _error.default(`Missing path in "${this.name}" plugin.`);
38
- }
39
- }
40
- exports.CmsEntryFieldFilterPathPlugin = CmsEntryFieldFilterPathPlugin;
41
- (0, _defineProperty2.default)(CmsEntryFieldFilterPathPlugin, "type", "cms-field-filter-path");
@@ -1 +0,0 @@
1
- {"version":3,"names":["CmsEntryFieldFilterPathPlugin","Plugin","fieldType","config","constructor","name","type","canUse","field","fieldId","Array","isArray","length","includes","createPath","params","path","WebinyError"],"sources":["CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams {\n field: Partial<CmsModelField> & Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\">;\n index?: number;\n}\nexport interface CreatePathCallable {\n (params: CreatePathCallableParams): string;\n}\nexport interface CmsEntryFieldFilterPathPluginParams {\n fieldType: string;\n fieldId?: string[];\n path: string | CreatePathCallable;\n}\nexport class CmsEntryFieldFilterPathPlugin extends Plugin {\n public static override readonly type: string = \"cms-field-filter-path\";\n\n private readonly config: CmsEntryFieldFilterPathPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(config: CmsEntryFieldFilterPathPluginParams) {\n super();\n\n this.config = config;\n\n this.name = `${(this.constructor as any).type}-${this.config.fieldType}`;\n }\n\n public canUse(field: Pick<CmsModelField, \"fieldId\" | \"type\">): boolean {\n if (field.type !== this.config.fieldType) {\n return false;\n }\n const fieldId = this.config.fieldId;\n if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {\n return true;\n }\n return fieldId.includes(field.fieldId);\n }\n\n public createPath(params: CreatePathCallableParams): string {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n throw new WebinyError(`Missing path in \"${this.name}\" plugin.`);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAeO,MAAMA,6BAA6B,SAASC,cAAM,CAAC;EAKtD,IAAWC,SAAS,GAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAEOE,WAAW,CAACD,MAA2C,EAAE;IAC5D,KAAK,EAAE;IAAC;IAER,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACE,IAAI,GAAI,GAAG,IAAI,CAACD,WAAW,CAASE,IAAK,IAAG,IAAI,CAACH,MAAM,CAACD,SAAU,EAAC;EAC5E;EAEOK,MAAM,CAACC,KAA8C,EAAW;IACnE,IAAIA,KAAK,CAACF,IAAI,KAAK,IAAI,CAACH,MAAM,CAACD,SAAS,EAAE;MACtC,OAAO,KAAK;IAChB;IACA,MAAMO,OAAO,GAAG,IAAI,CAACN,MAAM,CAACM,OAAO;IACnC,IAAI,CAACA,OAAO,IAAIC,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,KAAK,KAAK,IAAIA,OAAO,CAACG,MAAM,KAAK,CAAC,EAAE;MACtE,OAAO,IAAI;IACf;IACA,OAAOH,OAAO,CAACI,QAAQ,CAACL,KAAK,CAACC,OAAO,CAAC;EAC1C;EAEOK,UAAU,CAACC,MAAgC,EAAU;IACxD,IAAI,OAAO,IAAI,CAACZ,MAAM,CAACa,IAAI,KAAK,UAAU,EAAE;MACxC,OAAO,IAAI,CAACb,MAAM,CAACa,IAAI,CAACD,MAAM,CAAC;IACnC,CAAC,MAAM,IAAI,OAAO,IAAI,CAACZ,MAAM,CAACa,IAAI,KAAK,QAAQ,EAAE;MAC7C,OAAO,IAAI,CAACb,MAAM,CAACa,IAAI;IAC3B;IACA,MAAM,IAAIC,cAAW,CAAE,oBAAmB,IAAI,CAACZ,IAAK,WAAU,CAAC;EACnE;AACJ;AAAC;AAAA,8BApCYL,6BAA6B,UACS,uBAAuB"}
@@ -1,43 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
3
- import { Field } from "../operations/entry/filtering/types";
4
- import { CmsFieldFilterValueTransformPlugin } from "../types";
5
- /**
6
- * This plugin is used to create the filter.
7
- * Internally we have default one + the one for the reference field - because it is actually an object when filtering.
8
- */
9
- interface CmsEntryFieldFilterPluginParams {
10
- fieldType: string;
11
- create: (params: CmsEntryFieldFilterPluginCreateParams) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];
12
- }
13
- interface CmsEntryFieldFilterPluginCreateParams {
14
- key: string;
15
- value: any;
16
- field: Field;
17
- fields: Record<string, Field>;
18
- operation: string;
19
- valueFilterPlugins: Record<string, ValueFilterPlugin>;
20
- transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;
21
- getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;
22
- negate: boolean;
23
- compareValue: any;
24
- transformValue: <I = any, O = any>(value: I) => O;
25
- }
26
- export interface CmsEntryFieldFilterPluginCreateResponse {
27
- field: Field;
28
- path: string;
29
- fieldPathId: string;
30
- plugin: ValueFilterPlugin;
31
- negate: boolean;
32
- compareValue: any;
33
- transformValue: <I = any, O = any>(value: I) => O;
34
- }
35
- export declare class CmsEntryFieldFilterPlugin extends Plugin {
36
- static readonly type: string;
37
- static readonly ALL: string;
38
- private readonly config;
39
- readonly fieldType: string;
40
- constructor(config: CmsEntryFieldFilterPluginParams);
41
- create(params: CmsEntryFieldFilterPluginCreateParams): CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[] | null;
42
- }
43
- export {};
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.CmsEntryFieldFilterPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _plugins = require("@webiny/plugins");
10
- class CmsEntryFieldFilterPlugin extends _plugins.Plugin {
11
- constructor(config) {
12
- super();
13
- (0, _defineProperty2.default)(this, "config", void 0);
14
- (0, _defineProperty2.default)(this, "fieldType", void 0);
15
- this.config = config;
16
- this.fieldType = this.config.fieldType;
17
- }
18
- create(params) {
19
- return this.config.create(params);
20
- }
21
- }
22
- exports.CmsEntryFieldFilterPlugin = CmsEntryFieldFilterPlugin;
23
- (0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "type", "cms.dynamodb.entry.field.filter");
24
- (0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "ALL", "*");
@@ -1 +0,0 @@
1
- {"version":3,"names":["CmsEntryFieldFilterPlugin","Plugin","constructor","config","fieldType","create","params"],"sources":["CmsEntryFieldFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { Field } from \"~/operations/entry/filtering/types\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\n\n/**\n * This plugin is used to create the filter.\n * Internally we have default one + the one for the reference field - because it is actually an object when filtering.\n */\n\ninterface CmsEntryFieldFilterPluginParams {\n fieldType: string;\n create: (\n params: CmsEntryFieldFilterPluginCreateParams\n ) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];\n}\n\ninterface CmsEntryFieldFilterPluginCreateParams {\n key: string;\n value: any;\n field: Field;\n fields: Record<string, Field>;\n operation: string;\n valueFilterPlugins: Record<string, ValueFilterPlugin>;\n transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;\n getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport interface CmsEntryFieldFilterPluginCreateResponse {\n field: Field;\n path: string;\n fieldPathId: string;\n plugin: ValueFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport class CmsEntryFieldFilterPlugin extends Plugin {\n public static override readonly type: string = \"cms.dynamodb.entry.field.filter\";\n public static readonly ALL: string = \"*\";\n\n private readonly config: CmsEntryFieldFilterPluginParams;\n\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFieldFilterPluginParams) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public create(params: CmsEntryFieldFilterPluginCreateParams) {\n return this.config.create(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAyCO,MAAMA,yBAAyB,SAASC,eAAM,CAAC;EAQ3CC,WAAW,CAACC,MAAuC,EAAE;IACxD,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,SAAS,GAAG,IAAI,CAACD,MAAM,CAACC,SAAS;EAC1C;EAEOC,MAAM,CAACC,MAA6C,EAAE;IACzD,OAAO,IAAI,CAACH,MAAM,CAACE,MAAM,CAACC,MAAM,CAAC;EACrC;AACJ;AAAC;AAAA,8BAjBYN,yBAAyB,UACa,iCAAiC;AAAA,8BADvEA,yBAAyB,SAEG,GAAG"}
@@ -1,42 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- import { Field } from "../operations/entry/filtering/types";
3
- import { CmsModel } from "@webiny/api-headless-cms/types";
4
- interface CmsEntryFieldSortingPluginCanUseParams {
5
- model: CmsModel;
6
- field?: Field;
7
- fieldId: string;
8
- order: "ASC" | "DESC";
9
- /**
10
- * Combination of fieldId and sortBy
11
- *
12
- * example: id_ASC or createdBy_DESC
13
- */
14
- sortBy: string;
15
- }
16
- interface CmsEntryFieldSortingPluginCreateSortParams {
17
- model: CmsModel;
18
- fieldId: string;
19
- order: "ASC" | "DESC";
20
- sortBy: string;
21
- fields: Record<string, Field>;
22
- field?: Field;
23
- }
24
- interface CmsEntryFieldSortingPluginCreateSortResult {
25
- valuePath: string;
26
- reverse: boolean;
27
- fieldId: string;
28
- field: Field;
29
- }
30
- interface CmsEntryFieldSortingPluginConfig {
31
- createSort: (params: CmsEntryFieldSortingPluginCreateSortParams) => CmsEntryFieldSortingPluginCreateSortResult;
32
- canUse: (params: CmsEntryFieldSortingPluginCanUseParams) => boolean;
33
- }
34
- export declare class CmsEntryFieldSortingPlugin extends Plugin {
35
- static readonly type: string;
36
- private readonly config;
37
- constructor(config: CmsEntryFieldSortingPluginConfig);
38
- canUse(params: CmsEntryFieldSortingPluginCanUseParams): boolean;
39
- createSort(params: CmsEntryFieldSortingPluginCreateSortParams): CmsEntryFieldSortingPluginCreateSortResult;
40
- }
41
- export declare const createCmsEntryFieldSortingPlugin: (config: CmsEntryFieldSortingPluginConfig) => CmsEntryFieldSortingPlugin;
42
- export {};
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createCmsEntryFieldSortingPlugin = exports.CmsEntryFieldSortingPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _plugins = require("@webiny/plugins");
10
- class CmsEntryFieldSortingPlugin extends _plugins.Plugin {
11
- constructor(config) {
12
- super();
13
- (0, _defineProperty2.default)(this, "config", void 0);
14
- this.config = config;
15
- }
16
- canUse(params) {
17
- return this.config.canUse(params);
18
- }
19
- createSort(params) {
20
- return this.config.createSort(params);
21
- }
22
- }
23
- exports.CmsEntryFieldSortingPlugin = CmsEntryFieldSortingPlugin;
24
- (0, _defineProperty2.default)(CmsEntryFieldSortingPlugin, "type", "cms.entry.field.sorting");
25
- const createCmsEntryFieldSortingPlugin = config => {
26
- return new CmsEntryFieldSortingPlugin(config);
27
- };
28
- exports.createCmsEntryFieldSortingPlugin = createCmsEntryFieldSortingPlugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["CmsEntryFieldSortingPlugin","Plugin","constructor","config","canUse","params","createSort","createCmsEntryFieldSortingPlugin"],"sources":["CmsEntryFieldSortingPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Field } from \"~/operations/entry/filtering/types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface CmsEntryFieldSortingPluginCanUseParams {\n model: CmsModel;\n field?: Field;\n fieldId: string;\n order: \"ASC\" | \"DESC\";\n /**\n * Combination of fieldId and sortBy\n *\n * example: id_ASC or createdBy_DESC\n */\n sortBy: string;\n}\n\ninterface CmsEntryFieldSortingPluginCreateSortParams {\n model: CmsModel;\n fieldId: string;\n order: \"ASC\" | \"DESC\";\n sortBy: string;\n fields: Record<string, Field>;\n field?: Field;\n}\n\ninterface CmsEntryFieldSortingPluginCreateSortResult {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: Field;\n}\n\ninterface CmsEntryFieldSortingPluginConfig {\n createSort: (\n params: CmsEntryFieldSortingPluginCreateSortParams\n ) => CmsEntryFieldSortingPluginCreateSortResult;\n canUse: (params: CmsEntryFieldSortingPluginCanUseParams) => boolean;\n}\n\nexport class CmsEntryFieldSortingPlugin extends Plugin {\n public static override readonly type: string = \"cms.entry.field.sorting\";\n private readonly config: CmsEntryFieldSortingPluginConfig;\n\n public constructor(config: CmsEntryFieldSortingPluginConfig) {\n super();\n this.config = config;\n }\n\n public canUse(params: CmsEntryFieldSortingPluginCanUseParams): boolean {\n return this.config.canUse(params);\n }\n\n public createSort(\n params: CmsEntryFieldSortingPluginCreateSortParams\n ): CmsEntryFieldSortingPluginCreateSortResult {\n return this.config.createSort(params);\n }\n}\n\nexport const createCmsEntryFieldSortingPlugin = (config: CmsEntryFieldSortingPluginConfig) => {\n return new CmsEntryFieldSortingPlugin(config);\n};\n"],"mappings":";;;;;;;;AAAA;AAwCO,MAAMA,0BAA0B,SAASC,eAAM,CAAC;EAI5CC,WAAW,CAACC,MAAwC,EAAE;IACzD,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOC,MAAM,CAACC,MAA8C,EAAW;IACnE,OAAO,IAAI,CAACF,MAAM,CAACC,MAAM,CAACC,MAAM,CAAC;EACrC;EAEOC,UAAU,CACbD,MAAkD,EACR;IAC1C,OAAO,IAAI,CAACF,MAAM,CAACG,UAAU,CAACD,MAAM,CAAC;EACzC;AACJ;AAAC;AAAA,8BAlBYL,0BAA0B,UACY,yBAAyB;AAmBrE,MAAMO,gCAAgC,GAAIJ,MAAwC,IAAK;EAC1F,OAAO,IAAIH,0BAA0B,CAACG,MAAM,CAAC;AACjD,CAAC;AAAC"}
@@ -1,11 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- import { CmsFieldFilterValueTransformPlugin as CmsFieldFilterValueTransformPluginInterface } from "../types";
3
- declare type CmsFieldFilterValueTransformPluginParams = Omit<CmsFieldFilterValueTransformPluginInterface, "type">;
4
- export declare class CmsFieldFilterValueTransformPlugin extends Plugin implements Omit<CmsFieldFilterValueTransformPluginInterface, "type"> {
5
- static type: string;
6
- private config;
7
- get fieldType(): string;
8
- get transform(): CmsFieldFilterValueTransformPluginParams["transform"];
9
- constructor(config: CmsFieldFilterValueTransformPluginParams);
10
- }
11
- export {};
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.CmsFieldFilterValueTransformPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _plugins = require("@webiny/plugins");
10
- class CmsFieldFilterValueTransformPlugin extends _plugins.Plugin {
11
- get fieldType() {
12
- return this.config.fieldType;
13
- }
14
- get transform() {
15
- return this.config.transform;
16
- }
17
- constructor(config) {
18
- super();
19
- (0, _defineProperty2.default)(this, "config", void 0);
20
- this.config = config;
21
- }
22
- }
23
- exports.CmsFieldFilterValueTransformPlugin = CmsFieldFilterValueTransformPlugin;
24
- (0, _defineProperty2.default)(CmsFieldFilterValueTransformPlugin, "type", "cms-field-filter-value-transform");
@@ -1 +0,0 @@
1
- {"version":3,"names":["CmsFieldFilterValueTransformPlugin","Plugin","fieldType","config","transform","constructor"],"sources":["CmsFieldFilterValueTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsFieldFilterValueTransformPlugin as CmsFieldFilterValueTransformPluginInterface } from \"~/types\";\n\ntype CmsFieldFilterValueTransformPluginParams = Omit<\n CmsFieldFilterValueTransformPluginInterface,\n \"type\"\n>;\nexport class CmsFieldFilterValueTransformPlugin\n extends Plugin\n implements Omit<CmsFieldFilterValueTransformPluginInterface, \"type\">\n{\n public static override type = \"cms-field-filter-value-transform\";\n\n private config: CmsFieldFilterValueTransformPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public get transform(): CmsFieldFilterValueTransformPluginParams[\"transform\"] {\n return this.config.transform;\n }\n\n public constructor(config: CmsFieldFilterValueTransformPluginParams) {\n super();\n this.config = config;\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAOO,MAAMA,kCAAkC,SACnCC,eAAM,CAElB;EAKI,IAAWC,SAAS,GAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAEA,IAAWE,SAAS,GAA0D;IAC1E,OAAO,IAAI,CAACD,MAAM,CAACC,SAAS;EAChC;EAEOC,WAAW,CAACF,MAAgD,EAAE;IACjE,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;AACJ;AAAC;AAAA,8BApBYH,kCAAkC,UAIb,kCAAkC"}
@@ -1,4 +0,0 @@
1
- export * from "./CmsEntryFieldFilterPathPlugin";
2
- export * from "./CmsEntryFieldSortingPlugin";
3
- export * from "./CmsEntryFieldFilterPlugin";
4
- export * from "./CmsFieldFilterValueTransformPlugin";
package/plugins/index.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _CmsEntryFieldFilterPathPlugin = require("./CmsEntryFieldFilterPathPlugin");
7
- Object.keys(_CmsEntryFieldFilterPathPlugin).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _CmsEntryFieldFilterPathPlugin[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _CmsEntryFieldFilterPathPlugin[key];
14
- }
15
- });
16
- });
17
- var _CmsEntryFieldSortingPlugin = require("./CmsEntryFieldSortingPlugin");
18
- Object.keys(_CmsEntryFieldSortingPlugin).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _CmsEntryFieldSortingPlugin[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _CmsEntryFieldSortingPlugin[key];
25
- }
26
- });
27
- });
28
- var _CmsEntryFieldFilterPlugin = require("./CmsEntryFieldFilterPlugin");
29
- Object.keys(_CmsEntryFieldFilterPlugin).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _CmsEntryFieldFilterPlugin[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _CmsEntryFieldFilterPlugin[key];
36
- }
37
- });
38
- });
39
- var _CmsFieldFilterValueTransformPlugin = require("./CmsFieldFilterValueTransformPlugin");
40
- Object.keys(_CmsFieldFilterValueTransformPlugin).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _CmsFieldFilterValueTransformPlugin[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _CmsFieldFilterValueTransformPlugin[key];
47
- }
48
- });
49
- });
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsEntryFieldFilterPathPlugin\";\nexport * from \"./CmsEntryFieldSortingPlugin\";\nexport * from \"./CmsEntryFieldFilterPlugin\";\nexport * from \"./CmsFieldFilterValueTransformPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}