@webiny/api-headless-cms 0.0.0-mt-2 → 0.0.0-unstable.1e66d121db

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 (570) hide show
  1. package/context.d.ts +3 -0
  2. package/context.js +60 -0
  3. package/context.js.map +1 -0
  4. package/crud/contentEntry/afterDelete.d.ts +8 -0
  5. package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +2 -2
  6. package/crud/contentEntry/afterDelete.js.map +1 -0
  7. package/crud/contentEntry/beforeCreate.d.ts +8 -0
  8. package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +2 -2
  9. package/crud/contentEntry/beforeCreate.js.map +1 -0
  10. package/crud/contentEntry/beforeUpdate.d.ts +8 -0
  11. package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +2 -2
  12. package/crud/contentEntry/beforeUpdate.js.map +1 -0
  13. package/crud/contentEntry/entryDataValidation.d.ts +10 -0
  14. package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +23 -11
  15. package/crud/contentEntry/entryDataValidation.js.map +1 -0
  16. package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +3 -2
  17. package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +10 -14
  18. package/crud/contentEntry/markLockedFields.js.map +1 -0
  19. package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
  20. package/crud/contentEntry/referenceFieldsMapping.js +288 -0
  21. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
  22. package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +5 -9
  23. package/crud/contentEntry.crud.js +1255 -0
  24. package/crud/contentEntry.crud.js.map +1 -0
  25. package/crud/contentModel/afterCreate.d.ts +8 -0
  26. package/crud/contentModel/afterCreate.js +18 -0
  27. package/crud/contentModel/afterCreate.js.map +1 -0
  28. package/crud/contentModel/afterCreateFrom.d.ts +8 -0
  29. package/crud/contentModel/afterCreateFrom.js +18 -0
  30. package/crud/contentModel/afterCreateFrom.js.map +1 -0
  31. package/crud/contentModel/afterDelete.d.ts +8 -0
  32. package/crud/contentModel/afterDelete.js +18 -0
  33. package/crud/contentModel/afterDelete.js.map +1 -0
  34. package/crud/contentModel/afterUpdate.d.ts +8 -0
  35. package/crud/contentModel/afterUpdate.js +18 -0
  36. package/crud/contentModel/afterUpdate.js.map +1 -0
  37. package/crud/contentModel/beforeCreate.d.ts +15 -0
  38. package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +61 -13
  39. package/crud/contentModel/beforeCreate.js.map +1 -0
  40. package/crud/contentModel/beforeDelete.d.ts +10 -0
  41. package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +14 -10
  42. package/crud/contentModel/beforeDelete.js.map +1 -0
  43. package/crud/contentModel/beforeUpdate.d.ts +10 -0
  44. package/crud/contentModel/beforeUpdate.js +37 -0
  45. package/crud/contentModel/beforeUpdate.js.map +1 -0
  46. package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
  47. package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -0
  48. package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
  49. package/crud/contentModel/createFieldModels.d.ts +2 -0
  50. package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +6 -2
  51. package/crud/contentModel/createFieldModels.js.map +1 -0
  52. package/crud/contentModel/createFieldStorageId.d.ts +2 -0
  53. package/crud/contentModel/createFieldStorageId.js +16 -0
  54. package/crud/contentModel/createFieldStorageId.js.map +1 -0
  55. package/crud/contentModel/fieldIdValidation.d.ts +1 -0
  56. package/crud/contentModel/fieldIdValidation.js +25 -0
  57. package/crud/contentModel/fieldIdValidation.js.map +1 -0
  58. package/crud/contentModel/idValidation.d.ts +1 -0
  59. package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
  60. package/crud/contentModel/idValidation.js.map +1 -0
  61. package/{content/plugins/crud → crud}/contentModel/models.d.ts +2 -1
  62. package/{content/plugins/crud → crud}/contentModel/models.js +64 -25
  63. package/crud/contentModel/models.js.map +1 -0
  64. package/crud/contentModel/systemFields.d.ts +1 -0
  65. package/crud/contentModel/systemFields.js +8 -0
  66. package/crud/contentModel/systemFields.js.map +1 -0
  67. package/crud/contentModel/validateLayout.d.ts +2 -0
  68. package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -3
  69. package/crud/contentModel/validateLayout.js.map +1 -0
  70. package/crud/contentModel/validateModel.d.ts +9 -0
  71. package/crud/contentModel/validateModel.js +32 -0
  72. package/crud/contentModel/validateModel.js.map +1 -0
  73. package/crud/contentModel/validateModelFields.d.ts +9 -0
  74. package/crud/contentModel/validateModelFields.js +359 -0
  75. package/crud/contentModel/validateModelFields.js.map +1 -0
  76. package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
  77. package/crud/contentModel.crud.js +590 -0
  78. package/crud/contentModel.crud.js.map +1 -0
  79. package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
  80. package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +9 -9
  81. package/crud/contentModelGroup/beforeCreate.js.map +1 -0
  82. package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
  83. package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +4 -4
  84. package/crud/contentModelGroup/beforeDelete.js.map +1 -0
  85. package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
  86. package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +3 -3
  87. package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
  88. package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
  89. package/{content/plugins/crud → crud}/contentModelGroup.crud.js +108 -93
  90. package/crud/contentModelGroup.crud.js.map +1 -0
  91. package/crud/index.d.ts +6 -0
  92. package/crud/index.js +85 -0
  93. package/crud/index.js.map +1 -0
  94. package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
  95. package/crud/settings.crud.js +83 -0
  96. package/crud/settings.crud.js.map +1 -0
  97. package/{plugins/crud → crud}/system.crud.d.ts +6 -3
  98. package/crud/system.crud.js +221 -0
  99. package/crud/system.crud.js.map +1 -0
  100. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
  101. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +66 -0
  102. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
  103. package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
  104. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +304 -0
  105. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
  106. package/fieldConverters/index.d.ts +3 -0
  107. package/fieldConverters/index.js +16 -0
  108. package/fieldConverters/index.js.map +1 -0
  109. package/{content/plugins → graphql}/buildSchemaPlugins.d.ts +2 -3
  110. package/graphql/buildSchemaPlugins.js +27 -0
  111. package/graphql/buildSchemaPlugins.js.map +1 -0
  112. package/graphql/graphQLHandlerFactory.d.ts +5 -0
  113. package/graphql/graphQLHandlerFactory.js +158 -0
  114. package/graphql/graphQLHandlerFactory.js.map +1 -0
  115. package/graphql/index.d.ts +5 -0
  116. package/graphql/index.js +57 -0
  117. package/graphql/index.js.map +1 -0
  118. package/graphql/schema/baseContentSchema.d.ts +3 -0
  119. package/graphql/schema/baseContentSchema.js +76 -0
  120. package/graphql/schema/baseContentSchema.js.map +1 -0
  121. package/graphql/schema/contentEntries.d.ts +3 -0
  122. package/graphql/schema/contentEntries.js +351 -0
  123. package/graphql/schema/contentEntries.js.map +1 -0
  124. package/graphql/schema/contentModelGroups.d.ts +3 -0
  125. package/{content/plugins → graphql}/schema/contentModelGroups.js +34 -15
  126. package/graphql/schema/contentModelGroups.js.map +1 -0
  127. package/graphql/schema/contentModels.d.ts +3 -0
  128. package/{content/plugins → graphql}/schema/contentModels.js +47 -10
  129. package/graphql/schema/contentModels.js.map +1 -0
  130. package/graphql/schema/createFieldResolvers.d.ts +20 -0
  131. package/{content/plugins → graphql}/schema/createFieldResolvers.js +48 -23
  132. package/graphql/schema/createFieldResolvers.js.map +1 -0
  133. package/graphql/schema/createManageResolvers.d.ts +12 -0
  134. package/{content/plugins → graphql}/schema/createManageResolvers.js +36 -34
  135. package/graphql/schema/createManageResolvers.js.map +1 -0
  136. package/graphql/schema/createManageSDL.d.ts +10 -0
  137. package/{content/plugins → graphql}/schema/createManageSDL.js +23 -16
  138. package/graphql/schema/createManageSDL.js.map +1 -0
  139. package/graphql/schema/createPreviewResolvers.d.ts +12 -0
  140. package/graphql/schema/createPreviewResolvers.js +58 -0
  141. package/graphql/schema/createPreviewResolvers.js.map +1 -0
  142. package/graphql/schema/createReadResolvers.d.ts +12 -0
  143. package/graphql/schema/createReadResolvers.js +58 -0
  144. package/graphql/schema/createReadResolvers.js.map +1 -0
  145. package/graphql/schema/createReadSDL.d.ts +10 -0
  146. package/{content/plugins → graphql}/schema/createReadSDL.js +14 -8
  147. package/graphql/schema/createReadSDL.js.map +1 -0
  148. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
  149. package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +0 -0
  150. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
  151. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
  152. package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +2 -4
  153. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
  154. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
  155. package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +2 -4
  156. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
  157. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
  158. package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +10 -8
  159. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
  160. package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
  161. package/graphql/schema/resolvers/manage/resolveGet.js +79 -0
  162. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
  163. package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
  164. package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -4
  165. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
  166. package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
  167. package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +2 -4
  168. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
  169. package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
  170. package/{content/plugins/schema/resolvers/read → graphql/schema/resolvers/manage}/resolveList.js +2 -4
  171. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
  172. package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
  173. package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -0
  174. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
  175. package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
  176. package/{content/plugins/schema/resolvers/manage/resolveGet.js → graphql/schema/resolvers/manage/resolveRepublish.js} +4 -4
  177. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
  178. package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.d.ts +4 -3
  179. package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js +2 -4
  180. package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +1 -0
  181. package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.d.ts +4 -3
  182. package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js +2 -4
  183. package/graphql/schema/resolvers/manage/resolveRequestReview.js.map +1 -0
  184. package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
  185. package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -0
  186. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
  187. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
  188. package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +2 -4
  189. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
  190. package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
  191. package/graphql/schema/resolvers/preview/resolveGet.js +34 -0
  192. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
  193. package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
  194. package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js +2 -4
  195. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
  196. package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
  197. package/graphql/schema/resolvers/read/resolveGet.js +34 -0
  198. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
  199. package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
  200. package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/read}/resolveList.js +2 -4
  201. package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
  202. package/{content/plugins → graphql}/schema/schemaPlugins.d.ts +1 -1
  203. package/{content/plugins → graphql}/schema/schemaPlugins.js +25 -6
  204. package/graphql/schema/schemaPlugins.js.map +1 -0
  205. package/graphql/system.d.ts +6 -0
  206. package/graphql/system.js +119 -0
  207. package/graphql/system.js.map +1 -0
  208. package/graphqlFields/boolean.d.ts +2 -0
  209. package/graphqlFields/boolean.js +69 -0
  210. package/graphqlFields/boolean.js.map +1 -0
  211. package/graphqlFields/datetime.d.ts +2 -0
  212. package/graphqlFields/datetime.js +95 -0
  213. package/graphqlFields/datetime.js.map +1 -0
  214. package/graphqlFields/file.d.ts +2 -0
  215. package/graphqlFields/file.js +50 -0
  216. package/graphqlFields/file.js.map +1 -0
  217. package/graphqlFields/helpers.d.ts +6 -0
  218. package/graphqlFields/helpers.js +49 -0
  219. package/graphqlFields/helpers.js.map +1 -0
  220. package/graphqlFields/index.d.ts +2 -0
  221. package/graphqlFields/index.js +28 -0
  222. package/graphqlFields/index.js.map +1 -0
  223. package/graphqlFields/longText.d.ts +2 -0
  224. package/graphqlFields/longText.js +63 -0
  225. package/graphqlFields/longText.js.map +1 -0
  226. package/graphqlFields/number.d.ts +2 -0
  227. package/graphqlFields/number.js +75 -0
  228. package/graphqlFields/number.js.map +1 -0
  229. package/graphqlFields/object.d.ts +2 -0
  230. package/graphqlFields/object.js +225 -0
  231. package/graphqlFields/object.js.map +1 -0
  232. package/graphqlFields/ref.d.ts +2 -0
  233. package/graphqlFields/ref.js +275 -0
  234. package/graphqlFields/ref.js.map +1 -0
  235. package/graphqlFields/richText.d.ts +2 -0
  236. package/graphqlFields/richText.js +56 -0
  237. package/graphqlFields/richText.js.map +1 -0
  238. package/graphqlFields/text.d.ts +2 -0
  239. package/graphqlFields/text.js +73 -0
  240. package/graphqlFields/text.js.map +1 -0
  241. package/index.d.ts +10 -12
  242. package/index.js +80 -37
  243. package/index.js.map +1 -0
  244. package/modelManager/DefaultCmsModelManager.d.ts +14 -0
  245. package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +12 -10
  246. package/modelManager/DefaultCmsModelManager.js.map +1 -0
  247. package/modelManager/index.d.ts +2 -0
  248. package/{content/plugins/modelManager → modelManager}/index.js +3 -3
  249. package/modelManager/index.js.map +1 -0
  250. package/package.json +37 -36
  251. package/parameters/context.d.ts +2 -0
  252. package/parameters/context.js +22 -0
  253. package/parameters/context.js.map +1 -0
  254. package/parameters/header.d.ts +2 -0
  255. package/parameters/header.js +55 -0
  256. package/parameters/header.js.map +1 -0
  257. package/parameters/index.d.ts +4 -0
  258. package/parameters/index.js +57 -0
  259. package/parameters/index.js.map +1 -0
  260. package/parameters/manual.d.ts +6 -0
  261. package/parameters/manual.js +44 -0
  262. package/parameters/manual.js.map +1 -0
  263. package/parameters/path.d.ts +2 -0
  264. package/parameters/path.js +51 -0
  265. package/parameters/path.js.map +1 -0
  266. package/plugins/CmsGroupPlugin.d.ts +13 -0
  267. package/{content/plugins → plugins}/CmsGroupPlugin.js +9 -3
  268. package/plugins/CmsGroupPlugin.js.map +1 -0
  269. package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
  270. package/plugins/CmsModelFieldConverterPlugin.js +17 -0
  271. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
  272. package/plugins/CmsModelPlugin.d.ts +45 -0
  273. package/plugins/CmsModelPlugin.js +194 -0
  274. package/plugins/CmsModelPlugin.js.map +1 -0
  275. package/plugins/CmsParametersPlugin.d.ts +20 -0
  276. package/plugins/CmsParametersPlugin.js +28 -0
  277. package/plugins/CmsParametersPlugin.js.map +1 -0
  278. package/{content/plugins/storage → plugins}/StorageTransformPlugin.d.ts +4 -3
  279. package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -1
  280. package/plugins/StorageTransformPlugin.js.map +1 -0
  281. package/plugins/index.d.ts +5 -0
  282. package/plugins/index.js +70 -0
  283. package/plugins/index.js.map +1 -0
  284. package/storage/default.d.ts +2 -0
  285. package/storage/default.js +27 -0
  286. package/storage/default.js.map +1 -0
  287. package/storage/object.d.ts +2 -0
  288. package/storage/object.js +124 -0
  289. package/storage/object.js.map +1 -0
  290. package/types.d.ts +645 -348
  291. package/types.js +52 -2
  292. package/types.js.map +1 -0
  293. package/upgrades/5.33.0/index.d.ts +3 -0
  294. package/upgrades/5.33.0/index.js +182 -0
  295. package/upgrades/5.33.0/index.js.map +1 -0
  296. package/upgrades/index.d.ts +1 -0
  297. package/upgrades/index.js +12 -0
  298. package/upgrades/index.js.map +1 -0
  299. package/utils/access.d.ts +8 -0
  300. package/utils/access.js +90 -0
  301. package/utils/access.js.map +1 -0
  302. package/utils/converters/Converter.d.ts +27 -0
  303. package/utils/converters/Converter.js +71 -0
  304. package/utils/converters/Converter.js.map +1 -0
  305. package/utils/converters/ConverterCollection.d.ts +24 -0
  306. package/utils/converters/ConverterCollection.js +113 -0
  307. package/utils/converters/ConverterCollection.js.map +1 -0
  308. package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
  309. package/utils/converters/valueKeyStorageConverter.js +148 -0
  310. package/utils/converters/valueKeyStorageConverter.js.map +1 -0
  311. package/{content/plugins/utils → utils}/createTypeName.d.ts +3 -3
  312. package/{content/plugins/utils → utils}/createTypeName.js +1 -1
  313. package/utils/createTypeName.js.map +1 -0
  314. package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
  315. package/{content/plugins/utils → utils}/entryStorage.js +4 -12
  316. package/utils/entryStorage.js.map +1 -0
  317. package/utils/filterAsync.d.ts +1 -0
  318. package/utils/filterAsync.js +23 -0
  319. package/utils/filterAsync.js.map +1 -0
  320. package/utils/filterModelFields.d.ts +16 -0
  321. package/utils/filterModelFields.js +77 -0
  322. package/utils/filterModelFields.js.map +1 -0
  323. package/utils/getEntryTitle.d.ts +2 -0
  324. package/{content/plugins/utils → utils}/getEntryTitle.js +7 -6
  325. package/utils/getEntryTitle.js.map +1 -0
  326. package/utils/getSchemaFromFieldPlugins.d.ts +12 -0
  327. package/utils/getSchemaFromFieldPlugins.js +35 -0
  328. package/utils/getSchemaFromFieldPlugins.js.map +1 -0
  329. package/utils/ownership.d.ts +8 -0
  330. package/utils/ownership.js +41 -0
  331. package/utils/ownership.js.map +1 -0
  332. package/utils/permissions.d.ts +7 -0
  333. package/utils/permissions.js +106 -0
  334. package/utils/permissions.js.map +1 -0
  335. package/utils/pluralizedTypeName.d.ts +1 -0
  336. package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -1
  337. package/utils/pluralizedTypeName.js.map +1 -0
  338. package/utils/renderFields.d.ts +15 -0
  339. package/{content/plugins/utils → utils}/renderFields.js +4 -2
  340. package/utils/renderFields.js.map +1 -0
  341. package/utils/renderGetFilterFields.d.ts +10 -0
  342. package/{content/plugins/utils → utils}/renderGetFilterFields.js +28 -13
  343. package/utils/renderGetFilterFields.js.map +1 -0
  344. package/utils/renderInputFields.d.ts +14 -0
  345. package/{content/plugins/utils → utils}/renderInputFields.js +1 -1
  346. package/utils/renderInputFields.js.map +1 -0
  347. package/utils/renderListFilterFields.d.ts +11 -0
  348. package/{content/plugins/utils → utils}/renderListFilterFields.js +37 -17
  349. package/utils/renderListFilterFields.js.map +1 -0
  350. package/{content/plugins/utils → utils}/renderSortEnum.d.ts +1 -1
  351. package/utils/renderSortEnum.js +32 -0
  352. package/utils/renderSortEnum.js.map +1 -0
  353. package/utils/toSlug.d.ts +1 -0
  354. package/utils/toSlug.js +20 -0
  355. package/utils/toSlug.js.map +1 -0
  356. package/validators/dateGte.d.ts +2 -0
  357. package/{content/plugins/validators → validators}/dateGte.js +4 -4
  358. package/validators/dateGte.js.map +1 -0
  359. package/validators/dateLte.d.ts +2 -0
  360. package/{content/plugins/validators → validators}/dateLte.js +4 -4
  361. package/validators/dateLte.js.map +1 -0
  362. package/validators/gte.d.ts +2 -0
  363. package/validators/gte.js +36 -0
  364. package/validators/gte.js.map +1 -0
  365. package/validators/in.d.ts +2 -0
  366. package/validators/in.js +36 -0
  367. package/validators/in.js.map +1 -0
  368. package/validators/index.d.ts +1 -0
  369. package/validators/index.js +36 -0
  370. package/validators/index.js.map +1 -0
  371. package/validators/lte.d.ts +2 -0
  372. package/validators/lte.js +36 -0
  373. package/validators/lte.js.map +1 -0
  374. package/validators/maxLength.d.ts +2 -0
  375. package/validators/maxLength.js +36 -0
  376. package/validators/maxLength.js.map +1 -0
  377. package/validators/minLength.d.ts +2 -0
  378. package/validators/minLength.js +36 -0
  379. package/validators/minLength.js.map +1 -0
  380. package/validators/pattern.d.ts +2 -0
  381. package/validators/pattern.js +50 -0
  382. package/validators/pattern.js.map +1 -0
  383. package/validators/patternPlugins/email.d.ts +2 -0
  384. package/validators/patternPlugins/email.js +20 -0
  385. package/validators/patternPlugins/email.js.map +1 -0
  386. package/validators/patternPlugins/index.d.ts +2 -0
  387. package/validators/patternPlugins/index.js +24 -0
  388. package/validators/patternPlugins/index.js.map +1 -0
  389. package/validators/patternPlugins/lowerCase.d.ts +2 -0
  390. package/validators/patternPlugins/lowerCase.js +20 -0
  391. package/validators/patternPlugins/lowerCase.js.map +1 -0
  392. package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
  393. package/validators/patternPlugins/lowerCaseSpace.js +20 -0
  394. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
  395. package/validators/patternPlugins/upperCase.d.ts +2 -0
  396. package/validators/patternPlugins/upperCase.js +20 -0
  397. package/validators/patternPlugins/upperCase.js.map +1 -0
  398. package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
  399. package/validators/patternPlugins/upperCaseSpace.js +20 -0
  400. package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
  401. package/validators/patternPlugins/url.d.ts +2 -0
  402. package/validators/patternPlugins/url.js +20 -0
  403. package/validators/patternPlugins/url.js.map +1 -0
  404. package/validators/required.d.ts +2 -0
  405. package/validators/required.js +27 -0
  406. package/validators/required.js.map +1 -0
  407. package/validators/timeGte.d.ts +2 -0
  408. package/{content/plugins/validators → validators}/timeGte.js +6 -4
  409. package/validators/timeGte.js.map +1 -0
  410. package/validators/timeLte.d.ts +2 -0
  411. package/{content/plugins/validators → validators}/timeLte.js +6 -4
  412. package/validators/timeLte.js.map +1 -0
  413. package/validators/unique.d.ts +6 -0
  414. package/validators/unique.js +63 -0
  415. package/validators/unique.js.map +1 -0
  416. package/content/contextSetup.d.ts +0 -4
  417. package/content/contextSetup.js +0 -65
  418. package/content/graphQLHandlerFactory.d.ts +0 -5
  419. package/content/graphQLHandlerFactory.js +0 -173
  420. package/content/plugins/CmsGroupPlugin.d.ts +0 -11
  421. package/content/plugins/CmsModelPlugin.d.ts +0 -11
  422. package/content/plugins/CmsModelPlugin.js +0 -24
  423. package/content/plugins/buildSchemaPlugins.js +0 -29
  424. package/content/plugins/crud/contentEntry/afterDelete.d.ts +0 -7
  425. package/content/plugins/crud/contentEntry/beforeCreate.d.ts +0 -7
  426. package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +0 -7
  427. package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +0 -4
  428. package/content/plugins/crud/contentEntry.crud.js +0 -931
  429. package/content/plugins/crud/contentModel/afterCreate.d.ts +0 -7
  430. package/content/plugins/crud/contentModel/afterCreate.js +0 -18
  431. package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
  432. package/content/plugins/crud/contentModel/afterDelete.js +0 -18
  433. package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
  434. package/content/plugins/crud/contentModel/afterUpdate.js +0 -18
  435. package/content/plugins/crud/contentModel/beforeCreate.d.ts +0 -9
  436. package/content/plugins/crud/contentModel/beforeDelete.d.ts +0 -9
  437. package/content/plugins/crud/contentModel/beforeUpdate.d.ts +0 -9
  438. package/content/plugins/crud/contentModel/beforeUpdate.js +0 -128
  439. package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +0 -2
  440. package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
  441. package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
  442. package/content/plugins/crud/contentModel/validateLayout.d.ts +0 -2
  443. package/content/plugins/crud/contentModel.crud.js +0 -425
  444. package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +0 -9
  445. package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +0 -9
  446. package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +0 -8
  447. package/content/plugins/crud/index.d.ts +0 -6
  448. package/content/plugins/crud/index.js +0 -100
  449. package/content/plugins/graphqlFields/boolean.d.ts +0 -3
  450. package/content/plugins/graphqlFields/boolean.js +0 -69
  451. package/content/plugins/graphqlFields/datetime.d.ts +0 -3
  452. package/content/plugins/graphqlFields/datetime.js +0 -83
  453. package/content/plugins/graphqlFields/file.d.ts +0 -3
  454. package/content/plugins/graphqlFields/file.js +0 -49
  455. package/content/plugins/graphqlFields/index.d.ts +0 -2
  456. package/content/plugins/graphqlFields/index.js +0 -30
  457. package/content/plugins/graphqlFields/longText.d.ts +0 -3
  458. package/content/plugins/graphqlFields/longText.js +0 -62
  459. package/content/plugins/graphqlFields/number.d.ts +0 -3
  460. package/content/plugins/graphqlFields/number.js +0 -75
  461. package/content/plugins/graphqlFields/object.d.ts +0 -3
  462. package/content/plugins/graphqlFields/object.js +0 -180
  463. package/content/plugins/graphqlFields/ref.d.ts +0 -3
  464. package/content/plugins/graphqlFields/ref.js +0 -205
  465. package/content/plugins/graphqlFields/richText.d.ts +0 -3
  466. package/content/plugins/graphqlFields/richText.js +0 -55
  467. package/content/plugins/graphqlFields/text.d.ts +0 -3
  468. package/content/plugins/graphqlFields/text.js +0 -72
  469. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
  470. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -54
  471. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
  472. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -35
  473. package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -15
  474. package/content/plugins/modelManager/index.d.ts +0 -3
  475. package/content/plugins/schema/baseSchema.d.ts +0 -4
  476. package/content/plugins/schema/baseSchema.js +0 -98
  477. package/content/plugins/schema/contentEntries.d.ts +0 -4
  478. package/content/plugins/schema/contentEntries.js +0 -166
  479. package/content/plugins/schema/contentModelGroups.d.ts +0 -4
  480. package/content/plugins/schema/contentModels.d.ts +0 -4
  481. package/content/plugins/schema/createFieldResolvers.d.ts +0 -19
  482. package/content/plugins/schema/createManageResolvers.d.ts +0 -11
  483. package/content/plugins/schema/createManageSDL.d.ts +0 -9
  484. package/content/plugins/schema/createPreviewResolvers.d.ts +0 -10
  485. package/content/plugins/schema/createPreviewResolvers.js +0 -55
  486. package/content/plugins/schema/createReadResolvers.d.ts +0 -10
  487. package/content/plugins/schema/createReadResolvers.js +0 -55
  488. package/content/plugins/schema/createReadSDL.d.ts +0 -9
  489. package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
  490. package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +0 -6
  491. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +0 -7
  492. package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +0 -2
  493. package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +0 -2
  494. package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +0 -2
  495. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +0 -2
  496. package/content/plugins/schema/resolvers/manage/resolveList.d.ts +0 -2
  497. package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +0 -2
  498. package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +0 -2
  499. package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +0 -7
  500. package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +0 -2
  501. package/content/plugins/schema/resolvers/preview/resolveGet.js +0 -38
  502. package/content/plugins/schema/resolvers/preview/resolveList.d.ts +0 -2
  503. package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
  504. package/content/plugins/schema/resolvers/read/resolveGet.js +0 -38
  505. package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
  506. package/content/plugins/storage/default.d.ts +0 -3
  507. package/content/plugins/storage/default.js +0 -28
  508. package/content/plugins/storage/object.d.ts +0 -3
  509. package/content/plugins/storage/object.js +0 -119
  510. package/content/plugins/utils/getEntryTitle.d.ts +0 -2
  511. package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +0 -11
  512. package/content/plugins/utils/getSchemaFromFieldPlugins.js +0 -30
  513. package/content/plugins/utils/pluralizedTypeName.d.ts +0 -1
  514. package/content/plugins/utils/renderFields.d.ts +0 -16
  515. package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
  516. package/content/plugins/utils/renderInputFields.d.ts +0 -14
  517. package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
  518. package/content/plugins/utils/renderSortEnum.js +0 -32
  519. package/content/plugins/validators/dateGte.d.ts +0 -3
  520. package/content/plugins/validators/dateLte.d.ts +0 -3
  521. package/content/plugins/validators/gte.d.ts +0 -3
  522. package/content/plugins/validators/gte.js +0 -32
  523. package/content/plugins/validators/in.d.ts +0 -3
  524. package/content/plugins/validators/in.js +0 -32
  525. package/content/plugins/validators/index.d.ts +0 -2
  526. package/content/plugins/validators/index.js +0 -36
  527. package/content/plugins/validators/lte.d.ts +0 -3
  528. package/content/plugins/validators/lte.js +0 -32
  529. package/content/plugins/validators/maxLength.d.ts +0 -3
  530. package/content/plugins/validators/maxLength.js +0 -32
  531. package/content/plugins/validators/minLength.d.ts +0 -3
  532. package/content/plugins/validators/minLength.js +0 -32
  533. package/content/plugins/validators/pattern.d.ts +0 -3
  534. package/content/plugins/validators/pattern.js +0 -47
  535. package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
  536. package/content/plugins/validators/patternPlugins/email.js +0 -17
  537. package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
  538. package/content/plugins/validators/patternPlugins/index.js +0 -19
  539. package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
  540. package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
  541. package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
  542. package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
  543. package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
  544. package/content/plugins/validators/patternPlugins/url.js +0 -17
  545. package/content/plugins/validators/required.d.ts +0 -3
  546. package/content/plugins/validators/required.js +0 -25
  547. package/content/plugins/validators/timeGte.d.ts +0 -3
  548. package/content/plugins/validators/timeLte.d.ts +0 -3
  549. package/migrateCMSPermissions.d.ts +0 -17
  550. package/migrateCMSPermissions.js +0 -193
  551. package/plugins/context.d.ts +0 -4
  552. package/plugins/context.js +0 -34
  553. package/plugins/crud/index.d.ts +0 -6
  554. package/plugins/crud/index.js +0 -100
  555. package/plugins/crud/settings.crud.js +0 -93
  556. package/plugins/crud/system.crud.js +0 -182
  557. package/plugins/graphql/system.d.ts +0 -17
  558. package/plugins/graphql/system.js +0 -72
  559. package/plugins/graphql.d.ts +0 -2
  560. package/plugins/graphql.js +0 -79
  561. package/plugins/upgrades/index.d.ts +0 -2
  562. package/plugins/upgrades/index.js +0 -14
  563. package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
  564. package/plugins/upgrades/v5.5.0/helpers.js +0 -10
  565. package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
  566. package/plugins/upgrades/v5.5.0/index.js +0 -129
  567. package/transformers.d.ts +0 -2
  568. package/transformers.js +0 -25
  569. package/utils.d.ts +0 -25
  570. package/utils.js +0 -251
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createCmsModel = exports.CmsModelPlugin = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _plugins = require("@webiny/plugins");
15
+
16
+ var _error = _interopRequireDefault(require("@webiny/error"));
17
+
18
+ var _createFieldStorageId = require("../crud/contentModel/createFieldStorageId");
19
+
20
+ var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
21
+
22
+ class CmsModelPlugin extends _plugins.Plugin {
23
+ constructor(contentModel, options) {
24
+ super();
25
+ (0, _defineProperty2.default)(this, "contentModel", void 0);
26
+ (0, _defineProperty2.default)(this, "options", void 0);
27
+ this.options = options || {};
28
+ this.contentModel = this.buildModel(contentModel);
29
+ }
30
+
31
+ buildModel(input) {
32
+ const model = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
33
+ fields: this.buildFields(input, input.fields)
34
+ });
35
+ this.validateLayout(model);
36
+ return model;
37
+ }
38
+
39
+ buildFields(model, inputFields) {
40
+ if (inputFields.length === 0) {
41
+ throw new _error.default(`Missing fields for the defined model "${model.modelId}".`, "MISSING_FIELDS", {
42
+ model
43
+ });
44
+ }
45
+
46
+ const fields = [];
47
+ const storageIdList = [];
48
+ const fieldIdList = [];
49
+
50
+ for (const input of inputFields) {
51
+ var _settings;
52
+
53
+ /**
54
+ * Field must contain an fieldId. It is required in the graphql, but lets check it just in case
55
+ */
56
+ if (!(input.fieldId || "").trim()) {
57
+ throw new _error.default(`Field's "storageId" is not defined for the content model "${model.modelId}".`, "FIELD_ID_ERROR", {
58
+ model,
59
+ field: input
60
+ });
61
+ }
62
+
63
+ const fieldId = (0, _camelCase.default)(input.fieldId);
64
+ /**
65
+ * FieldID must be in correct pattern.
66
+ */
67
+
68
+ if (fieldId.match(/^[0-9]/) !== null) {
69
+ throw new _error.default(`Field's "fieldId" does not match correct pattern in the content model "${model.modelId}" - cannot start with a number.`, "FIELD_FIELD_ID_ERROR", {
70
+ model,
71
+ field: input
72
+ });
73
+ }
74
+ /**
75
+ * FieldID also must be camelCased.
76
+ */
77
+
78
+
79
+ if (fieldId !== input.fieldId) {
80
+ throw new _error.default(`Field's "fieldId" must be a camel cased string in the content model "${model.modelId}".`, "FIELD_FIELD_ID_ERROR", {
81
+ model,
82
+ field: input
83
+ });
84
+ }
85
+ /**
86
+ * ... and fieldId must be unique.
87
+ */
88
+
89
+
90
+ if (fieldIdList.includes(fieldId) === true) {
91
+ throw new _error.default(`Field's "fieldId" is not unique in the content model "${model.modelId}".`, "FIELD_ID_NOT_UNIQUE_ERROR", {
92
+ model,
93
+ field: input
94
+ });
95
+ }
96
+
97
+ let storageId = input.storageId ? (0, _camelCase.default)(input.storageId) : null;
98
+ /**
99
+ * If defined, storageId MUST be camel cased string - for backward compatibility.
100
+ */
101
+
102
+ if (storageId && (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)) {
103
+ throw new _error.default(`Field's "storageId" of the field with "fieldId" ${input.fieldId} is not camel cased string in the content model "${model.modelId}".`, "STORAGE_ID_NOT_CAMEL_CASED_ERROR", {
104
+ model,
105
+ storageId,
106
+ field: input
107
+ });
108
+ } else if (!storageId) {
109
+ storageId = (0, _createFieldStorageId.createFieldStorageId)(input);
110
+ }
111
+ /**
112
+ * Fields storageId must be unique.
113
+ */
114
+
115
+
116
+ if (storageIdList.includes(storageId) === true) {
117
+ throw new _error.default(`Field's "storageId" is not unique in the content model "${model.modelId}".`, "STORAGE_ID_ERROR", {
118
+ model,
119
+ field: input
120
+ });
121
+ }
122
+ /**
123
+ * We can safely ignore error because we are going through the fields and making sure each has storageId.
124
+ */
125
+ // @ts-ignore
126
+
127
+
128
+ let settings = input.settings;
129
+ const childFields = ((_settings = settings) === null || _settings === void 0 ? void 0 : _settings.fields) || [];
130
+
131
+ if (input.type === "object" && childFields.length > 0) {
132
+ settings = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings || {}), {}, {
133
+ fields: this.buildFields(model, childFields)
134
+ });
135
+ }
136
+
137
+ const field = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
138
+ settings,
139
+ storageId
140
+ });
141
+ /**
142
+ * Add all relevant data to arrays.
143
+ */
144
+
145
+ fields.push(field);
146
+ storageIdList.push(field.storageId);
147
+ fieldIdList.push(field.fieldId);
148
+ }
149
+
150
+ return fields;
151
+ }
152
+
153
+ validateLayout(model) {
154
+ /**
155
+ * Only skip validation if option.validateLayout was set as false, explicitly.
156
+ */
157
+ if (this.options.validateLayout === false) {
158
+ return;
159
+ }
160
+
161
+ for (const field of model.fields) {
162
+ let total = 0;
163
+
164
+ for (const row of model.layout) {
165
+ const count = row.filter(cell => cell === field.id).length;
166
+ total = total + count;
167
+ }
168
+
169
+ if (total === 1) {
170
+ continue;
171
+ } else if (total > 1) {
172
+ throw new _error.default(`Field "${field.id}" is in more than one layout cell.`, "DUPLICATE_FIELD_IN_LAYOUT", {
173
+ model,
174
+ field
175
+ });
176
+ }
177
+
178
+ throw new _error.default(`Missing field "${field.id}" in layout.`, "MISSING_FIELD_IN_LAYOUT", {
179
+ model,
180
+ field
181
+ });
182
+ }
183
+ }
184
+
185
+ }
186
+
187
+ exports.CmsModelPlugin = CmsModelPlugin;
188
+ (0, _defineProperty2.default)(CmsModelPlugin, "type", "cms-content-model");
189
+
190
+ const createCmsModel = (model, options) => {
191
+ return new CmsModelPlugin(model, options);
192
+ };
193
+
194
+ exports.createCmsModel = createCmsModel;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsModelPlugin","Plugin","constructor","contentModel","options","buildModel","input","model","fields","buildFields","validateLayout","inputFields","length","WebinyError","modelId","storageIdList","fieldIdList","fieldId","trim","field","lodashCamelCase","match","includes","storageId","createFieldStorageId","settings","childFields","type","push","total","row","layout","count","filter","cell","id","createCmsModel"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId\";\nimport lodashCamelCase from \"lodash/camelCase\";\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * News ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\ninterface CmsModelInput\n extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\" | \"fields\"> {\n fields: CmsModelFieldInput[];\n locale?: string;\n tenant?: string;\n}\ninterface CmsModel extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n locale?: string;\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModel {\n const model: CmsModel = {\n ...input,\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId) === true) {\n throw new WebinyError(\n `Field's \"fieldId\" is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId ? lodashCamelCase(input.storageId) : null;\n /**\n * If defined, storageId MUST be camel cased string - for backward compatibility.\n */\n if (\n storageId &&\n (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)\n ) {\n throw new WebinyError(\n `Field's \"storageId\" of the field with \"fieldId\" ${input.fieldId} is not camel cased string in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_NOT_CAMEL_CASED_ERROR\",\n {\n model,\n storageId,\n field: input\n }\n );\n } else if (!storageId) {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId) === true) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-ignore\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n for (const field of model.fields) {\n let total = 0;\n for (const row of model.layout) {\n const count = row.filter(cell => cell === field.id).length;\n total = total + count;\n }\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\nexport const createCmsModel = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n"],"mappings":"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"}
@@ -0,0 +1,20 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ApiEndpoint, CmsContext } from "../types";
3
+ /**
4
+ * Type can be null because it might be that Headless CMS context is loaded on a different Lambda where there is no GraphQL Schema generated.
5
+ */
6
+ export declare type CmsParametersPluginResponseType = ApiEndpoint | null;
7
+ export declare type CmsParametersPluginResponseLocale = string;
8
+ export interface CmsParametersPluginResponse {
9
+ type: CmsParametersPluginResponseType;
10
+ locale: CmsParametersPluginResponseLocale;
11
+ }
12
+ export interface CmsParametersPluginCallable {
13
+ (context: CmsContext): Promise<CmsParametersPluginResponse | null>;
14
+ }
15
+ export declare class CmsParametersPlugin extends Plugin {
16
+ static readonly type: string;
17
+ private readonly callable;
18
+ constructor(callable: CmsParametersPluginCallable);
19
+ getParameters(context: CmsContext): Promise<CmsParametersPluginResponse | null>;
20
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CmsParametersPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class CmsParametersPlugin extends _plugins.Plugin {
15
+ constructor(callable) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "callable", void 0);
18
+ this.callable = callable;
19
+ }
20
+
21
+ async getParameters(context) {
22
+ return this.callable(context);
23
+ }
24
+
25
+ }
26
+
27
+ exports.CmsParametersPlugin = CmsParametersPlugin;
28
+ (0, _defineProperty2.default)(CmsParametersPlugin, "type", "cms-parameters-plugin");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsParametersPlugin","Plugin","constructor","callable","getParameters","context"],"sources":["CmsParametersPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\n\n/**\n * Type can be null because it might be that Headless CMS context is loaded on a different Lambda where there is no GraphQL Schema generated.\n */\nexport type CmsParametersPluginResponseType = ApiEndpoint | null;\nexport type CmsParametersPluginResponseLocale = string;\n\nexport interface CmsParametersPluginResponse {\n type: CmsParametersPluginResponseType;\n locale: CmsParametersPluginResponseLocale;\n}\n\nexport interface CmsParametersPluginCallable {\n (context: CmsContext): Promise<CmsParametersPluginResponse | null>;\n}\n\nexport class CmsParametersPlugin extends Plugin {\n public static override readonly type: string = \"cms-parameters-plugin\";\n\n private readonly callable: CmsParametersPluginCallable;\n\n public constructor(callable: CmsParametersPluginCallable) {\n super();\n\n this.callable = callable;\n }\n\n public async getParameters(context: CmsContext): Promise<CmsParametersPluginResponse | null> {\n return this.callable(context);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAkBO,MAAMA,mBAAN,SAAkCC,eAAlC,CAAyC;EAKrCC,WAAW,CAACC,QAAD,EAAwC;IACtD;IADsD;IAGtD,KAAKA,QAAL,GAAgBA,QAAhB;EACH;;EAEyB,MAAbC,aAAa,CAACC,OAAD,EAAmE;IACzF,OAAO,KAAKF,QAAL,CAAcE,OAAd,CAAP;EACH;;AAb2C;;;8BAAnCL,mB,UACsC,uB"}
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin";
2
- import { CmsModel, CmsModelField } from "../../../types";
2
+ import { CmsModel, CmsModelField } from "../types";
3
3
  import { PluginsContainer } from "@webiny/plugins";
4
4
  export interface ToStorageParams<T> {
5
5
  model: CmsModel;
@@ -15,7 +15,8 @@ export interface FromStorageParams<T> {
15
15
  getStoragePlugin(fieldType: string): StorageTransformPlugin<T>;
16
16
  plugins: PluginsContainer;
17
17
  }
18
- export interface Params<T, R> {
18
+ export interface StorageTransformPluginParams<T, R> {
19
+ name?: string;
19
20
  fieldType: string;
20
21
  toStorage: (params: ToStorageParams<T>) => Promise<R>;
21
22
  fromStorage: (params: FromStorageParams<R>) => Promise<T>;
@@ -24,7 +25,7 @@ export declare class StorageTransformPlugin<T = any, R = any> extends Plugin {
24
25
  static readonly type: string;
25
26
  get fieldType(): string;
26
27
  private readonly config;
27
- constructor(config: Params<T, R>);
28
+ constructor(config: StorageTransformPluginParams<T, R>);
28
29
  toStorage(params: ToStorageParams<T>): Promise<R>;
29
30
  fromStorage(params: FromStorageParams<R>): Promise<T>;
30
31
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -19,6 +19,7 @@ class StorageTransformPlugin extends _Plugin.Plugin {
19
19
  constructor(config) {
20
20
  super();
21
21
  (0, _defineProperty2.default)(this, "config", void 0);
22
+ this.name = config.name;
22
23
  this.config = config;
23
24
  }
24
25
 
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StorageTransformPlugin","Plugin","fieldType","config","constructor","name","toStorage","params","fromStorage"],"sources":["StorageTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModel, CmsModelField } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface ToStorageParams<T> {\n model: CmsModel;\n field: CmsModelField;\n value: T;\n getStoragePlugin(fieldType: string): StorageTransformPlugin<T>;\n plugins: PluginsContainer;\n}\n\nexport interface FromStorageParams<T> {\n model: CmsModel;\n field: CmsModelField;\n value: T;\n getStoragePlugin(fieldType: string): StorageTransformPlugin<T>;\n plugins: PluginsContainer;\n}\n\nexport interface StorageTransformPluginParams<T, R> {\n name?: string;\n fieldType: string;\n toStorage: (params: ToStorageParams<T>) => Promise<R>;\n fromStorage: (params: FromStorageParams<R>) => Promise<T>;\n}\nexport class StorageTransformPlugin<T = any, R = any> extends Plugin {\n public static override readonly type: string = \"cms.storage.transform.plugin\";\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n private readonly config: StorageTransformPluginParams<T, R>;\n\n public constructor(config: StorageTransformPluginParams<T, R>) {\n super();\n this.name = config.name;\n this.config = config;\n }\n\n public toStorage(params: ToStorageParams<T>): Promise<R> {\n return this.config.toStorage(params);\n }\n\n public fromStorage(params: FromStorageParams<R>): Promise<T> {\n return this.config.fromStorage(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AA0BO,MAAMA,sBAAN,SAAuDC,cAAvD,CAA8D;EAE7C,IAATC,SAAS,GAAW;IAC3B,OAAO,KAAKC,MAAL,CAAYD,SAAnB;EACH;;EAIME,WAAW,CAACD,MAAD,EAA6C;IAC3D;IAD2D;IAE3D,KAAKE,IAAL,GAAYF,MAAM,CAACE,IAAnB;IACA,KAAKF,MAAL,GAAcA,MAAd;EACH;;EAEMG,SAAS,CAACC,MAAD,EAAyC;IACrD,OAAO,KAAKJ,MAAL,CAAYG,SAAZ,CAAsBC,MAAtB,CAAP;EACH;;EAEMC,WAAW,CAACD,MAAD,EAA2C;IACzD,OAAO,KAAKJ,MAAL,CAAYK,WAAZ,CAAwBD,MAAxB,CAAP;EACH;;AApBgE;;;8BAAxDP,sB,UACsC,8B"}
@@ -0,0 +1,5 @@
1
+ export * from "./CmsGroupPlugin";
2
+ export * from "./CmsModelPlugin";
3
+ export * from "./StorageTransformPlugin";
4
+ export * from "./CmsParametersPlugin";
5
+ export * from "./CmsModelFieldConverterPlugin";
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _CmsGroupPlugin = require("./CmsGroupPlugin");
8
+
9
+ Object.keys(_CmsGroupPlugin).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _CmsGroupPlugin[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _CmsGroupPlugin[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _CmsModelPlugin = require("./CmsModelPlugin");
21
+
22
+ Object.keys(_CmsModelPlugin).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _CmsModelPlugin[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _CmsModelPlugin[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _StorageTransformPlugin = require("./StorageTransformPlugin");
34
+
35
+ Object.keys(_StorageTransformPlugin).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _StorageTransformPlugin[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _StorageTransformPlugin[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _CmsParametersPlugin = require("./CmsParametersPlugin");
47
+
48
+ Object.keys(_CmsParametersPlugin).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _CmsParametersPlugin[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _CmsParametersPlugin[key];
55
+ }
56
+ });
57
+ });
58
+
59
+ var _CmsModelFieldConverterPlugin = require("./CmsModelFieldConverterPlugin");
60
+
61
+ Object.keys(_CmsModelFieldConverterPlugin).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (key in exports && exports[key] === _CmsModelFieldConverterPlugin[key]) return;
64
+ Object.defineProperty(exports, key, {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _CmsModelFieldConverterPlugin[key];
68
+ }
69
+ });
70
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsGroupPlugin\";\nexport * from \"./CmsModelPlugin\";\nexport * from \"./StorageTransformPlugin\";\nexport * from \"./CmsParametersPlugin\";\nexport * from \"./CmsModelFieldConverterPlugin\";\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;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import { StorageTransformPlugin } from "../plugins/StorageTransformPlugin";
2
+ export declare const createDefaultStorageTransform: () => StorageTransformPlugin;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createDefaultStorageTransform = void 0;
7
+
8
+ var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
9
+
10
+ const createDefaultStorageTransform = () => {
11
+ return new _StorageTransformPlugin.StorageTransformPlugin({
12
+ name: "headless-cms.storage-transform.all.default",
13
+ fieldType: "*",
14
+ fromStorage: async ({
15
+ value
16
+ }) => {
17
+ return value;
18
+ },
19
+ toStorage: async ({
20
+ value
21
+ }) => {
22
+ return value;
23
+ }
24
+ });
25
+ };
26
+
27
+ exports.createDefaultStorageTransform = createDefaultStorageTransform;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createDefaultStorageTransform","StorageTransformPlugin","name","fieldType","fromStorage","value","toStorage"],"sources":["default.ts"],"sourcesContent":["import { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\n\nexport const createDefaultStorageTransform = (): StorageTransformPlugin => {\n return new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.all.default\",\n fieldType: \"*\",\n fromStorage: async ({ value }) => {\n return value;\n },\n toStorage: async ({ value }) => {\n return value;\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,6BAA6B,GAAG,MAA8B;EACvE,OAAO,IAAIC,8CAAJ,CAA2B;IAC9BC,IAAI,EAAE,4CADwB;IAE9BC,SAAS,EAAE,GAFmB;IAG9BC,WAAW,EAAE,OAAO;MAAEC;IAAF,CAAP,KAAqB;MAC9B,OAAOA,KAAP;IACH,CAL6B;IAM9BC,SAAS,EAAE,OAAO;MAAED;IAAF,CAAP,KAAqB;MAC5B,OAAOA,KAAP;IACH;EAR6B,CAA3B,CAAP;AAUH,CAXM"}
@@ -0,0 +1,2 @@
1
+ import { StorageTransformPlugin } from "../plugins/StorageTransformPlugin";
2
+ export declare const createObjectStorageTransform: () => StorageTransformPlugin;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createObjectStorageTransform = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _pReduce = _interopRequireDefault(require("p-reduce"));
13
+
14
+ var _pMap = _interopRequireDefault(require("p-map"));
15
+
16
+ var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
17
+
18
+ const processValue = async params => {
19
+ const {
20
+ fields,
21
+ sourceValue,
22
+ getStoragePlugin,
23
+ plugins,
24
+ model,
25
+ operation
26
+ } = params;
27
+ return await (0, _pReduce.default)(fields, async (values, field) => {
28
+ const plugin = getStoragePlugin(field.type);
29
+
30
+ if (!plugin) {
31
+ throw new Error(`Missing storage plugin for field type "${field.type}".`);
32
+ }
33
+
34
+ const value = await plugin[operation]({
35
+ plugins,
36
+ model,
37
+ field,
38
+ value: sourceValue[field.fieldId],
39
+ getStoragePlugin
40
+ });
41
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, values), {}, {
42
+ [field.fieldId]: value
43
+ });
44
+ }, {});
45
+ };
46
+
47
+ const createObjectStorageTransform = () => {
48
+ return new _StorageTransformPlugin.StorageTransformPlugin({
49
+ name: "headless-cms.storage-transform.object.default",
50
+ fieldType: "object",
51
+ toStorage: async ({
52
+ field,
53
+ value,
54
+ getStoragePlugin,
55
+ model,
56
+ plugins
57
+ }) => {
58
+ var _field$settings;
59
+
60
+ if (!value) {
61
+ return null;
62
+ }
63
+
64
+ const fields = ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.fields) || [];
65
+
66
+ if (field.multipleValues) {
67
+ return await (0, _pMap.default)(value, value => processValue({
68
+ sourceValue: value,
69
+ getStoragePlugin,
70
+ model,
71
+ plugins,
72
+ operation: "toStorage",
73
+ fields
74
+ }));
75
+ }
76
+
77
+ return await processValue({
78
+ sourceValue: value,
79
+ getStoragePlugin,
80
+ model,
81
+ plugins,
82
+ operation: "toStorage",
83
+ fields
84
+ });
85
+ },
86
+ fromStorage: async ({
87
+ field,
88
+ value,
89
+ getStoragePlugin,
90
+ plugins,
91
+ model
92
+ }) => {
93
+ var _field$settings2;
94
+
95
+ if (!value) {
96
+ return null;
97
+ }
98
+
99
+ const fields = ((_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.fields) || [];
100
+
101
+ if (field.multipleValues) {
102
+ return (0, _pMap.default)(value, value => processValue({
103
+ sourceValue: value,
104
+ getStoragePlugin,
105
+ model,
106
+ plugins,
107
+ operation: "fromStorage",
108
+ fields
109
+ }));
110
+ }
111
+
112
+ return processValue({
113
+ sourceValue: value,
114
+ getStoragePlugin,
115
+ model,
116
+ plugins,
117
+ operation: "fromStorage",
118
+ fields
119
+ });
120
+ }
121
+ });
122
+ };
123
+
124
+ exports.createObjectStorageTransform = createObjectStorageTransform;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["processValue","params","fields","sourceValue","getStoragePlugin","plugins","model","operation","pReduce","values","field","plugin","type","Error","value","fieldId","createObjectStorageTransform","StorageTransformPlugin","name","fieldType","toStorage","settings","multipleValues","pMap","fromStorage"],"sources":["object.ts"],"sourcesContent":["import pReduce from \"p-reduce\";\nimport pMap from \"p-map\";\nimport { CmsModel, CmsModelField } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\n\ninterface ProcessValueParams {\n fields: CmsModelField[];\n sourceValue: Record<string, any>;\n getStoragePlugin: (fieldType: string) => StorageTransformPlugin;\n plugins: PluginsContainer;\n model: CmsModel;\n operation: \"toStorage\" | \"fromStorage\";\n}\ninterface ProcessValue {\n (params: ProcessValueParams): Promise<Record<string, any>>;\n}\n\nconst processValue: ProcessValue = async params => {\n const { fields, sourceValue, getStoragePlugin, plugins, model, operation } = params;\n return await pReduce(\n fields,\n async (values, field) => {\n const plugin = getStoragePlugin(field.type);\n if (!plugin) {\n throw new Error(`Missing storage plugin for field type \"${field.type}\".`);\n }\n const value = await plugin[operation]({\n plugins,\n model,\n field,\n value: sourceValue[field.fieldId],\n getStoragePlugin\n });\n return { ...values, [field.fieldId]: value };\n },\n {}\n );\n};\n\nexport const createObjectStorageTransform = (): StorageTransformPlugin => {\n return new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.object.default\",\n fieldType: \"object\",\n toStorage: async ({ field, value, getStoragePlugin, model, plugins }) => {\n if (!value) {\n return null;\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.multipleValues) {\n return await pMap(value as Record<string, any>[], value =>\n processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"toStorage\",\n fields\n })\n );\n }\n\n return await processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"toStorage\",\n fields\n });\n },\n fromStorage: async ({ field, value, getStoragePlugin, plugins, model }) => {\n if (!value) {\n return null;\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.multipleValues) {\n return pMap(value as Record<string, any>[], value =>\n processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"fromStorage\",\n fields\n })\n );\n }\n\n return processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"fromStorage\",\n fields\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAGA;;AAcA,MAAMA,YAA0B,GAAG,MAAMC,MAAN,IAAgB;EAC/C,MAAM;IAAEC,MAAF;IAAUC,WAAV;IAAuBC,gBAAvB;IAAyCC,OAAzC;IAAkDC,KAAlD;IAAyDC;EAAzD,IAAuEN,MAA7E;EACA,OAAO,MAAM,IAAAO,gBAAA,EACTN,MADS,EAET,OAAOO,MAAP,EAAeC,KAAf,KAAyB;IACrB,MAAMC,MAAM,GAAGP,gBAAgB,CAACM,KAAK,CAACE,IAAP,CAA/B;;IACA,IAAI,CAACD,MAAL,EAAa;MACT,MAAM,IAAIE,KAAJ,CAAW,0CAAyCH,KAAK,CAACE,IAAK,IAA/D,CAAN;IACH;;IACD,MAAME,KAAK,GAAG,MAAMH,MAAM,CAACJ,SAAD,CAAN,CAAkB;MAClCF,OADkC;MAElCC,KAFkC;MAGlCI,KAHkC;MAIlCI,KAAK,EAAEX,WAAW,CAACO,KAAK,CAACK,OAAP,CAJgB;MAKlCX;IALkC,CAAlB,CAApB;IAOA,mEAAYK,MAAZ;MAAoB,CAACC,KAAK,CAACK,OAAP,GAAiBD;IAArC;EACH,CAfQ,EAgBT,EAhBS,CAAb;AAkBH,CApBD;;AAsBO,MAAME,4BAA4B,GAAG,MAA8B;EACtE,OAAO,IAAIC,8CAAJ,CAA2B;IAC9BC,IAAI,EAAE,+CADwB;IAE9BC,SAAS,EAAE,QAFmB;IAG9BC,SAAS,EAAE,OAAO;MAAEV,KAAF;MAASI,KAAT;MAAgBV,gBAAhB;MAAkCE,KAAlC;MAAyCD;IAAzC,CAAP,KAA8D;MAAA;;MACrE,IAAI,CAACS,KAAL,EAAY;QACR,OAAO,IAAP;MACH;;MAED,MAAMZ,MAAM,GAAI,oBAAAQ,KAAK,CAACW,QAAN,oEAAgBnB,MAAhB,KAA0B,EAA1C;;MAEA,IAAIQ,KAAK,CAACY,cAAV,EAA0B;QACtB,OAAO,MAAM,IAAAC,aAAA,EAAKT,KAAL,EAAqCA,KAAK,IACnDd,YAAY,CAAC;UACTG,WAAW,EAAEW,KADJ;UAETV,gBAFS;UAGTE,KAHS;UAITD,OAJS;UAKTE,SAAS,EAAE,WALF;UAMTL;QANS,CAAD,CADH,CAAb;MAUH;;MAED,OAAO,MAAMF,YAAY,CAAC;QACtBG,WAAW,EAAEW,KADS;QAEtBV,gBAFsB;QAGtBE,KAHsB;QAItBD,OAJsB;QAKtBE,SAAS,EAAE,WALW;QAMtBL;MANsB,CAAD,CAAzB;IAQH,CA/B6B;IAgC9BsB,WAAW,EAAE,OAAO;MAAEd,KAAF;MAASI,KAAT;MAAgBV,gBAAhB;MAAkCC,OAAlC;MAA2CC;IAA3C,CAAP,KAA8D;MAAA;;MACvE,IAAI,CAACQ,KAAL,EAAY;QACR,OAAO,IAAP;MACH;;MAED,MAAMZ,MAAM,GAAI,qBAAAQ,KAAK,CAACW,QAAN,sEAAgBnB,MAAhB,KAA0B,EAA1C;;MAEA,IAAIQ,KAAK,CAACY,cAAV,EAA0B;QACtB,OAAO,IAAAC,aAAA,EAAKT,KAAL,EAAqCA,KAAK,IAC7Cd,YAAY,CAAC;UACTG,WAAW,EAAEW,KADJ;UAETV,gBAFS;UAGTE,KAHS;UAITD,OAJS;UAKTE,SAAS,EAAE,aALF;UAMTL;QANS,CAAD,CADT,CAAP;MAUH;;MAED,OAAOF,YAAY,CAAC;QAChBG,WAAW,EAAEW,KADG;QAEhBV,gBAFgB;QAGhBE,KAHgB;QAIhBD,OAJgB;QAKhBE,SAAS,EAAE,aALK;QAMhBL;MANgB,CAAD,CAAnB;IAQH;EA5D6B,CAA3B,CAAP;AA8DH,CA/DM"}