@webiny/api-headless-cms 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.de38392959

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 (568) hide show
  1. package/constants.d.ts +32 -0
  2. package/constants.js +57 -0
  3. package/constants.js.map +1 -0
  4. package/context.js +88 -47
  5. package/context.js.map +1 -1
  6. package/crud/contentEntry/afterDelete.js +3 -1
  7. package/crud/contentEntry/afterDelete.js.map +1 -1
  8. package/crud/contentEntry/beforeCreate.js +3 -1
  9. package/crud/contentEntry/beforeCreate.js.map +1 -1
  10. package/crud/contentEntry/beforeUpdate.js +3 -1
  11. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  12. package/crud/contentEntry/entryDataFactories/createEntryData.d.ts +20 -0
  13. package/crud/contentEntry/entryDataFactories/createEntryData.js +228 -0
  14. package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -0
  15. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.d.ts +21 -0
  16. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js +114 -0
  17. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js.map +1 -0
  18. package/crud/contentEntry/entryDataFactories/createPublishEntryData.d.ts +13 -0
  19. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js +61 -0
  20. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js.map +1 -0
  21. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.d.ts +12 -0
  22. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js +57 -0
  23. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js.map +1 -0
  24. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.d.ts +12 -0
  25. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js +38 -0
  26. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js.map +1 -0
  27. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.d.ts +20 -0
  28. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js +122 -0
  29. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js.map +1 -0
  30. package/crud/contentEntry/entryDataFactories/index.d.ts +8 -0
  31. package/crud/contentEntry/entryDataFactories/index.js +95 -0
  32. package/crud/contentEntry/entryDataFactories/index.js.map +1 -0
  33. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.d.ts +5 -0
  34. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js +36 -0
  35. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js.map +1 -0
  36. package/crud/contentEntry/entryDataFactories/statuses.d.ts +4 -0
  37. package/crud/contentEntry/entryDataFactories/statuses.js +15 -0
  38. package/crud/contentEntry/entryDataFactories/statuses.js.map +1 -0
  39. package/crud/contentEntry/entryDataValidation.d.ts +4 -2
  40. package/crud/contentEntry/entryDataValidation.js +223 -45
  41. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  42. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  43. package/crud/contentEntry/markLockedFields.js +20 -10
  44. package/crud/contentEntry/markLockedFields.js.map +1 -1
  45. package/crud/contentEntry/referenceFieldsMapping.d.ts +6 -0
  46. package/crud/contentEntry/referenceFieldsMapping.js +142 -90
  47. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  48. package/crud/contentEntry/searchableFields.js +5 -4
  49. package/crud/contentEntry/searchableFields.js.map +1 -1
  50. package/crud/contentEntry.crud.d.ts +9 -5
  51. package/crud/contentEntry.crud.js +1093 -981
  52. package/crud/contentEntry.crud.js.map +1 -1
  53. package/crud/contentModel/beforeCreate.d.ts +1 -1
  54. package/crud/contentModel/beforeCreate.js +50 -85
  55. package/crud/contentModel/beforeCreate.js.map +1 -1
  56. package/crud/contentModel/beforeDelete.d.ts +1 -1
  57. package/crud/contentModel/beforeDelete.js +4 -6
  58. package/crud/contentModel/beforeDelete.js.map +1 -1
  59. package/crud/contentModel/beforeUpdate.d.ts +1 -1
  60. package/crud/contentModel/beforeUpdate.js +31 -6
  61. package/crud/contentModel/beforeUpdate.js.map +1 -1
  62. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  63. package/crud/contentModel/compatibility/modelApiName.js +26 -0
  64. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  65. package/crud/contentModel/contentModelManagerFactory.js +3 -1
  66. package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
  67. package/crud/contentModel/createFieldStorageId.js +3 -1
  68. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  69. package/crud/contentModel/defaultFields.d.ts +5 -0
  70. package/crud/contentModel/defaultFields.js +60 -0
  71. package/crud/contentModel/defaultFields.js.map +1 -0
  72. package/crud/contentModel/ensureTypeTag.d.ts +5 -0
  73. package/crud/contentModel/ensureTypeTag.js +21 -0
  74. package/crud/contentModel/ensureTypeTag.js.map +1 -0
  75. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  76. package/crud/contentModel/fields/descriptionField.js +44 -0
  77. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  78. package/crud/contentModel/fields/imageField.d.ts +2 -0
  79. package/crud/contentModel/fields/imageField.js +44 -0
  80. package/crud/contentModel/fields/imageField.js.map +1 -0
  81. package/crud/contentModel/fields/titleField.d.ts +2 -0
  82. package/crud/contentModel/fields/titleField.js +60 -0
  83. package/crud/contentModel/fields/titleField.js.map +1 -0
  84. package/crud/contentModel/listModelsFromDatabase.d.ts +10 -0
  85. package/crud/contentModel/listModelsFromDatabase.js +38 -0
  86. package/crud/contentModel/listModelsFromDatabase.js.map +1 -0
  87. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  88. package/crud/contentModel/validate/endingAllowed.js +28 -0
  89. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  90. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  91. package/crud/contentModel/validate/isModelEndingAllowed.js +26 -0
  92. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  93. package/crud/contentModel/validate/modelId.d.ts +11 -0
  94. package/crud/contentModel/validate/modelId.js +38 -0
  95. package/crud/contentModel/validate/modelId.js.map +1 -0
  96. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  97. package/crud/contentModel/validate/pluralApiName.js +26 -0
  98. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  99. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  100. package/crud/contentModel/validate/singularApiName.js +26 -0
  101. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  102. package/crud/contentModel/validateModel.d.ts +1 -0
  103. package/crud/contentModel/validateModel.js +3 -1
  104. package/crud/contentModel/validateModel.js.map +1 -1
  105. package/crud/contentModel/validateModelFields.d.ts +2 -1
  106. package/crud/contentModel/validateModelFields.js +27 -64
  107. package/crud/contentModel/validateModelFields.js.map +1 -1
  108. package/crud/contentModel/validation.d.ts +595 -200
  109. package/crud/contentModel/validation.js +125 -17
  110. package/crud/contentModel/validation.js.map +1 -1
  111. package/crud/contentModel.crud.d.ts +2 -0
  112. package/crud/contentModel.crud.js +437 -411
  113. package/crud/contentModel.crud.js.map +1 -1
  114. package/crud/contentModelGroup/beforeCreate.d.ts +1 -1
  115. package/crud/contentModelGroup/beforeCreate.js +15 -1
  116. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  117. package/crud/contentModelGroup/beforeDelete.js +3 -1
  118. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  119. package/crud/contentModelGroup/beforeUpdate.js +3 -1
  120. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  121. package/crud/contentModelGroup/listGroupsFromDatabase.d.ts +8 -0
  122. package/crud/contentModelGroup/listGroupsFromDatabase.js +22 -0
  123. package/crud/contentModelGroup/listGroupsFromDatabase.js.map +1 -0
  124. package/crud/contentModelGroup/validation.d.ts +10 -7
  125. package/crud/contentModelGroup/validation.js +5 -2
  126. package/crud/contentModelGroup/validation.js.map +1 -1
  127. package/crud/contentModelGroup.crud.d.ts +3 -1
  128. package/crud/contentModelGroup.crud.js +272 -228
  129. package/crud/contentModelGroup.crud.js.map +1 -1
  130. package/crud/system.crud.js +8 -71
  131. package/crud/system.crud.js.map +1 -1
  132. package/export/crud/exporting.d.ts +3 -0
  133. package/export/crud/exporting.js +49 -0
  134. package/export/crud/exporting.js.map +1 -0
  135. package/export/crud/importing.d.ts +3 -0
  136. package/export/crud/importing.js +79 -0
  137. package/export/crud/importing.js.map +1 -0
  138. package/export/crud/imports/importData.d.ts +14 -0
  139. package/export/crud/imports/importData.js +52 -0
  140. package/export/crud/imports/importData.js.map +1 -0
  141. package/export/crud/imports/importGroups.d.ts +8 -0
  142. package/export/crud/imports/importGroups.js +104 -0
  143. package/export/crud/imports/importGroups.js.map +1 -0
  144. package/export/crud/imports/importModels.d.ts +8 -0
  145. package/export/crud/imports/importModels.js +136 -0
  146. package/export/crud/imports/importModels.js.map +1 -0
  147. package/export/crud/imports/validateGroups.d.ts +8 -0
  148. package/export/crud/imports/validateGroups.js +112 -0
  149. package/export/crud/imports/validateGroups.js.map +1 -0
  150. package/export/crud/imports/validateInput.d.ts +19 -0
  151. package/export/crud/imports/validateInput.js +55 -0
  152. package/export/crud/imports/validateInput.js.map +1 -0
  153. package/export/crud/imports/validateModels.d.ts +12 -0
  154. package/export/crud/imports/validateModels.js +203 -0
  155. package/export/crud/imports/validateModels.js.map +1 -0
  156. package/export/crud/index.d.ts +4 -0
  157. package/export/crud/index.js +15 -0
  158. package/export/crud/index.js.map +1 -0
  159. package/export/crud/sanitize.d.ts +4 -0
  160. package/export/crud/sanitize.js +35 -0
  161. package/export/crud/sanitize.js.map +1 -0
  162. package/export/graphql/index.d.ts +3 -0
  163. package/export/graphql/index.js +188 -0
  164. package/export/graphql/index.js.map +1 -0
  165. package/export/index.d.ts +2 -0
  166. package/export/index.js +29 -0
  167. package/export/index.js.map +1 -0
  168. package/export/types.d.ts +113 -0
  169. package/export/types.js +22 -0
  170. package/export/types.js.map +1 -0
  171. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +4 -7
  172. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
  173. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +5 -8
  174. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  175. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +47 -38
  176. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  177. package/fieldConverters/index.js +3 -1
  178. package/fieldConverters/index.js.map +1 -1
  179. package/graphql/buildSchemaPlugins.js +7 -1
  180. package/graphql/buildSchemaPlugins.js.map +1 -1
  181. package/graphql/checkEndpointAccess.d.ts +2 -0
  182. package/graphql/checkEndpointAccess.js +20 -0
  183. package/graphql/checkEndpointAccess.js.map +1 -0
  184. package/graphql/createExecutableSchema.d.ts +2 -3
  185. package/graphql/createExecutableSchema.js +3 -1
  186. package/graphql/createExecutableSchema.js.map +1 -1
  187. package/graphql/createRequestBody.d.ts +2 -0
  188. package/graphql/createRequestBody.js +16 -0
  189. package/graphql/createRequestBody.js.map +1 -0
  190. package/graphql/formatErrorPayload.d.ts +1 -0
  191. package/graphql/formatErrorPayload.js +27 -0
  192. package/graphql/formatErrorPayload.js.map +1 -0
  193. package/graphql/generateSchema.js +3 -1
  194. package/graphql/generateSchema.js.map +1 -1
  195. package/graphql/getSchema.d.ts +16 -0
  196. package/graphql/getSchema.js +118 -0
  197. package/graphql/getSchema.js.map +1 -0
  198. package/graphql/graphQLHandlerFactory.js +9 -146
  199. package/graphql/graphQLHandlerFactory.js.map +1 -1
  200. package/graphql/handleRequest.d.ts +11 -0
  201. package/graphql/handleRequest.js +79 -0
  202. package/graphql/handleRequest.js.map +1 -0
  203. package/graphql/index.d.ts +1 -1
  204. package/graphql/index.js +4 -2
  205. package/graphql/index.js.map +1 -1
  206. package/graphql/schema/baseContentSchema.js +10 -15
  207. package/graphql/schema/baseContentSchema.js.map +1 -1
  208. package/graphql/schema/baseSchema.d.ts +2 -3
  209. package/graphql/schema/baseSchema.js +95 -2
  210. package/graphql/schema/baseSchema.js.map +1 -1
  211. package/graphql/schema/contentEntries.js +134 -59
  212. package/graphql/schema/contentEntries.js.map +1 -1
  213. package/graphql/schema/contentModelGroups.js +12 -9
  214. package/graphql/schema/contentModelGroups.js.map +1 -1
  215. package/graphql/schema/contentModels.js +33 -14
  216. package/graphql/schema/contentModels.js.map +1 -1
  217. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  218. package/graphql/schema/createFieldResolvers.js +18 -22
  219. package/graphql/schema/createFieldResolvers.js.map +1 -1
  220. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  221. package/graphql/schema/createFieldTypePluginRecords.js +15 -0
  222. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  223. package/graphql/schema/createManageResolvers.d.ts +1 -1
  224. package/graphql/schema/createManageResolvers.js +60 -27
  225. package/graphql/schema/createManageResolvers.js.map +1 -1
  226. package/graphql/schema/createManageSDL.d.ts +1 -0
  227. package/graphql/schema/createManageSDL.js +116 -69
  228. package/graphql/schema/createManageSDL.js.map +1 -1
  229. package/graphql/schema/createPreviewResolvers.js +10 -13
  230. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  231. package/graphql/schema/createReadResolvers.js +11 -14
  232. package/graphql/schema/createReadResolvers.js.map +1 -1
  233. package/graphql/schema/createReadSDL.d.ts +1 -0
  234. package/graphql/schema/createReadSDL.js +51 -38
  235. package/graphql/schema/createReadSDL.js.map +1 -1
  236. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +2 -1
  237. package/graphql/schema/resolvers/manage/resolveCreate.js +4 -2
  238. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  239. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +2 -1
  240. package/graphql/schema/resolvers/manage/resolveCreateFrom.js +4 -2
  241. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  242. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  243. package/graphql/schema/resolvers/manage/resolveDelete.js +16 -4
  244. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  245. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  246. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +22 -0
  247. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  248. package/graphql/schema/resolvers/manage/resolveGet.js +12 -5
  249. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  250. package/graphql/schema/resolvers/manage/resolveGetByIds.js +3 -1
  251. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  252. package/graphql/schema/resolvers/manage/resolveGetRevisions.js +3 -1
  253. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  254. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  255. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +20 -0
  256. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  257. package/graphql/schema/resolvers/manage/resolveList.js +3 -1
  258. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  259. package/graphql/schema/resolvers/manage/resolveMove.d.ts +8 -0
  260. package/graphql/schema/resolvers/manage/resolveMove.js +27 -0
  261. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -0
  262. package/graphql/schema/resolvers/manage/resolvePublish.js +3 -1
  263. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  264. package/graphql/schema/resolvers/manage/resolveRepublish.js +3 -1
  265. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  266. package/graphql/schema/resolvers/manage/resolveUnpublish.js +3 -1
  267. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  268. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +2 -1
  269. package/graphql/schema/resolvers/manage/resolveUpdate.js +4 -2
  270. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  271. package/graphql/schema/resolvers/manage/resolveValidate.d.ts +8 -0
  272. package/graphql/schema/resolvers/manage/resolveValidate.js +20 -0
  273. package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -0
  274. package/graphql/schema/resolvers/preview/resolveGet.js +6 -5
  275. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  276. package/graphql/schema/resolvers/preview/resolveList.js +3 -1
  277. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  278. package/graphql/schema/resolvers/read/resolveGet.js +6 -5
  279. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  280. package/graphql/schema/resolvers/read/resolveList.js +3 -1
  281. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  282. package/graphql/schema/schemaPlugins.js +10 -17
  283. package/graphql/schema/schemaPlugins.js.map +1 -1
  284. package/graphql/system.d.ts +2 -5
  285. package/graphql/system.js +4 -28
  286. package/graphql/system.js.map +1 -1
  287. package/graphqlFields/boolean.js +3 -1
  288. package/graphqlFields/boolean.js.map +1 -1
  289. package/graphqlFields/datetime.js +5 -5
  290. package/graphqlFields/datetime.js.map +1 -1
  291. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  292. package/graphqlFields/dynamicZone/dynamicZoneField.js +86 -28
  293. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  294. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +60 -12
  295. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -1
  296. package/graphqlFields/dynamicZone/index.js +3 -1
  297. package/graphqlFields/dynamicZone/index.js.map +1 -1
  298. package/graphqlFields/file.js +3 -1
  299. package/graphqlFields/file.js.map +1 -1
  300. package/graphqlFields/helpers.d.ts +0 -1
  301. package/graphqlFields/helpers.js +6 -18
  302. package/graphqlFields/helpers.js.map +1 -1
  303. package/graphqlFields/index.js +5 -2
  304. package/graphqlFields/index.js.map +1 -1
  305. package/graphqlFields/json.d.ts +2 -0
  306. package/graphqlFields/json.js +49 -0
  307. package/graphqlFields/json.js.map +1 -0
  308. package/graphqlFields/longText.js +14 -3
  309. package/graphqlFields/longText.js.map +1 -1
  310. package/graphqlFields/number.js +4 -1
  311. package/graphqlFields/number.js.map +1 -1
  312. package/graphqlFields/object.js +33 -34
  313. package/graphqlFields/object.js.map +1 -1
  314. package/graphqlFields/ref.js +68 -28
  315. package/graphqlFields/ref.js.map +1 -1
  316. package/graphqlFields/richText/RichTextPluginsProcessor.d.ts +6 -0
  317. package/graphqlFields/richText/RichTextPluginsProcessor.js +34 -0
  318. package/graphqlFields/richText/RichTextPluginsProcessor.js.map +1 -0
  319. package/graphqlFields/richText/richTextResolver.d.ts +7 -0
  320. package/graphqlFields/richText/richTextResolver.js +39 -0
  321. package/graphqlFields/richText/richTextResolver.js.map +1 -0
  322. package/graphqlFields/richText.js +11 -3
  323. package/graphqlFields/richText.js.map +1 -1
  324. package/graphqlFields/text.js +5 -1
  325. package/graphqlFields/text.js.map +1 -1
  326. package/htmlRenderer/LexicalRenderer.d.ts +5 -0
  327. package/htmlRenderer/LexicalRenderer.js +28 -0
  328. package/htmlRenderer/LexicalRenderer.js.map +1 -0
  329. package/htmlRenderer/createLexicalHTMLRenderer.d.ts +2 -0
  330. package/htmlRenderer/createLexicalHTMLRenderer.js +31 -0
  331. package/htmlRenderer/createLexicalHTMLRenderer.js.map +1 -0
  332. package/index.d.ts +5 -2
  333. package/index.js +44 -6
  334. package/index.js.map +1 -1
  335. package/modelManager/DefaultCmsModelManager.js +3 -5
  336. package/modelManager/DefaultCmsModelManager.js.map +1 -1
  337. package/modelManager/index.js +3 -1
  338. package/modelManager/index.js.map +1 -1
  339. package/package.json +36 -40
  340. package/parameters/context.js +4 -2
  341. package/parameters/context.js.map +1 -1
  342. package/parameters/header.js +7 -6
  343. package/parameters/header.js.map +1 -1
  344. package/parameters/index.js +3 -1
  345. package/parameters/index.js.map +1 -1
  346. package/parameters/manual.js +9 -4
  347. package/parameters/manual.js.map +1 -1
  348. package/parameters/path.js +4 -3
  349. package/parameters/path.js.map +1 -1
  350. package/plugins/CmsGraphQLSchemaPlugin.js +5 -4
  351. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -1
  352. package/plugins/CmsGraphQLSchemaSorterPlugin.js +4 -5
  353. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
  354. package/plugins/CmsGroupPlugin.d.ts +6 -3
  355. package/plugins/CmsGroupPlugin.js +8 -6
  356. package/plugins/CmsGroupPlugin.js.map +1 -1
  357. package/plugins/CmsModelFieldConverterPlugin.js +5 -4
  358. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  359. package/plugins/CmsModelPlugin.d.ts +25 -5
  360. package/plugins/CmsModelPlugin.js +75 -20
  361. package/plugins/CmsModelPlugin.js.map +1 -1
  362. package/plugins/CmsParametersPlugin.js +7 -4
  363. package/plugins/CmsParametersPlugin.js.map +1 -1
  364. package/plugins/CmsRichTextRendererPlugin.d.ts +24 -0
  365. package/plugins/CmsRichTextRendererPlugin.js +28 -0
  366. package/plugins/CmsRichTextRendererPlugin.js.map +1 -0
  367. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  368. package/plugins/StorageOperationsCmsModelPlugin.js +41 -0
  369. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  370. package/plugins/StorageTransformPlugin.d.ts +2 -2
  371. package/plugins/StorageTransformPlugin.js +3 -4
  372. package/plugins/StorageTransformPlugin.js.map +1 -1
  373. package/plugins/index.d.ts +2 -0
  374. package/plugins/index.js +25 -1
  375. package/plugins/index.js.map +1 -1
  376. package/storage/default.js +3 -1
  377. package/storage/default.js.map +1 -1
  378. package/storage/index.d.ts +1 -0
  379. package/storage/index.js +15 -0
  380. package/storage/index.js.map +1 -0
  381. package/storage/json.d.ts +2 -0
  382. package/storage/json.js +27 -0
  383. package/storage/json.js.map +1 -0
  384. package/storage/object.js +8 -8
  385. package/storage/object.js.map +1 -1
  386. package/types.d.ts +510 -334
  387. package/types.js +21 -21
  388. package/types.js.map +1 -1
  389. package/utils/access.d.ts +9 -8
  390. package/utils/access.js +12 -62
  391. package/utils/access.js.map +1 -1
  392. package/utils/caching/Cache.d.ts +2 -0
  393. package/utils/caching/Cache.js +51 -0
  394. package/utils/caching/Cache.js.map +1 -0
  395. package/utils/caching/CacheKey.d.ts +2 -0
  396. package/utils/caching/CacheKey.js +40 -0
  397. package/utils/caching/CacheKey.js.map +1 -0
  398. package/utils/caching/index.d.ts +2 -0
  399. package/utils/caching/index.js +29 -0
  400. package/utils/caching/index.js.map +1 -0
  401. package/utils/caching/types.d.ts +11 -0
  402. package/utils/caching/types.js +7 -0
  403. package/utils/caching/types.js.map +1 -0
  404. package/utils/converters/Converter.js +4 -5
  405. package/utils/converters/Converter.js.map +1 -1
  406. package/utils/converters/ConverterCollection.js +13 -7
  407. package/utils/converters/ConverterCollection.js.map +1 -1
  408. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  409. package/utils/converters/valueKeyStorageConverter.js +34 -21
  410. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  411. package/utils/createTypeFromFields.d.ts +1 -0
  412. package/utils/createTypeFromFields.js +14 -7
  413. package/utils/createTypeFromFields.js.map +1 -1
  414. package/utils/createTypeName.d.ts +0 -2
  415. package/utils/createTypeName.js +3 -9
  416. package/utils/createTypeName.js.map +1 -1
  417. package/utils/date.d.ts +10 -0
  418. package/utils/date.js +36 -0
  419. package/utils/date.js.map +1 -0
  420. package/utils/entryStorage.d.ts +4 -4
  421. package/utils/entryStorage.js +6 -4
  422. package/utils/entryStorage.js.map +1 -1
  423. package/utils/filterAsync.js +9 -8
  424. package/utils/filterAsync.js.map +1 -1
  425. package/utils/getBaseFieldType.d.ts +1 -3
  426. package/utils/getBaseFieldType.js +3 -1
  427. package/utils/getBaseFieldType.js.map +1 -1
  428. package/utils/getEntryDescription.d.ts +2 -0
  429. package/utils/getEntryDescription.js +19 -0
  430. package/utils/getEntryDescription.js.map +1 -0
  431. package/utils/getEntryImage.d.ts +2 -0
  432. package/utils/getEntryImage.js +19 -0
  433. package/utils/getEntryImage.js.map +1 -0
  434. package/utils/getEntryTitle.d.ts +1 -1
  435. package/utils/getEntryTitle.js +3 -1
  436. package/utils/getEntryTitle.js.map +1 -1
  437. package/utils/getSchemaFromFieldPlugins.d.ts +13 -2
  438. package/utils/getSchemaFromFieldPlugins.js +22 -4
  439. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  440. package/utils/identity.d.ts +2 -0
  441. package/utils/identity.js +20 -0
  442. package/utils/identity.js.map +1 -0
  443. package/utils/incrementEntryIdVersion.d.ts +5 -0
  444. package/utils/incrementEntryIdVersion.js +31 -0
  445. package/utils/incrementEntryIdVersion.js.map +1 -0
  446. package/utils/index.d.ts +1 -0
  447. package/utils/index.js +18 -0
  448. package/utils/index.js.map +1 -0
  449. package/utils/permissions/EntriesPermissions.d.ts +4 -0
  450. package/utils/permissions/EntriesPermissions.js +11 -0
  451. package/utils/permissions/EntriesPermissions.js.map +1 -0
  452. package/utils/permissions/ModelGroupsPermissions.d.ts +9 -0
  453. package/utils/permissions/ModelGroupsPermissions.js +50 -0
  454. package/utils/permissions/ModelGroupsPermissions.js.map +1 -0
  455. package/utils/permissions/ModelsPermissions.d.ts +22 -0
  456. package/utils/permissions/ModelsPermissions.js +90 -0
  457. package/utils/permissions/ModelsPermissions.js.map +1 -0
  458. package/utils/renderFields.d.ts +4 -2
  459. package/utils/renderFields.js +13 -3
  460. package/utils/renderFields.js.map +1 -1
  461. package/utils/renderGetFilterFields.d.ts +2 -2
  462. package/utils/renderGetFilterFields.js +9 -21
  463. package/utils/renderGetFilterFields.js.map +1 -1
  464. package/utils/renderInputFields.d.ts +4 -2
  465. package/utils/renderInputFields.js +20 -6
  466. package/utils/renderInputFields.js.map +1 -1
  467. package/utils/renderListFilterFields.d.ts +3 -1
  468. package/utils/renderListFilterFields.js +25 -22
  469. package/utils/renderListFilterFields.js.map +1 -1
  470. package/utils/renderSortEnum.d.ts +3 -2
  471. package/utils/renderSortEnum.js +10 -3
  472. package/utils/renderSortEnum.js.map +1 -1
  473. package/utils/toSlug.js +3 -1
  474. package/utils/toSlug.js.map +1 -1
  475. package/validators/dateGte.js +3 -1
  476. package/validators/dateGte.js.map +1 -1
  477. package/validators/dateLte.js +3 -1
  478. package/validators/dateLte.js.map +1 -1
  479. package/validators/gte.js +4 -3
  480. package/validators/gte.js.map +1 -1
  481. package/validators/in.js +4 -3
  482. package/validators/in.js.map +1 -1
  483. package/validators/index.js +4 -3
  484. package/validators/index.js.map +1 -1
  485. package/validators/lte.js +4 -3
  486. package/validators/lte.js.map +1 -1
  487. package/validators/maxLength.js +4 -3
  488. package/validators/maxLength.js.map +1 -1
  489. package/validators/minLength.js +4 -3
  490. package/validators/minLength.js.map +1 -1
  491. package/validators/pattern.js +5 -3
  492. package/validators/pattern.js.map +1 -1
  493. package/validators/patternPlugins/email.js +3 -1
  494. package/validators/patternPlugins/email.js.map +1 -1
  495. package/validators/patternPlugins/index.js +3 -1
  496. package/validators/patternPlugins/index.js.map +1 -1
  497. package/validators/patternPlugins/lowerCase.js +3 -1
  498. package/validators/patternPlugins/lowerCase.js.map +1 -1
  499. package/validators/patternPlugins/lowerCaseSpace.js +3 -1
  500. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
  501. package/validators/patternPlugins/upperCase.js +3 -1
  502. package/validators/patternPlugins/upperCase.js.map +1 -1
  503. package/validators/patternPlugins/upperCaseSpace.js +3 -1
  504. package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
  505. package/validators/patternPlugins/url.js +3 -1
  506. package/validators/patternPlugins/url.js.map +1 -1
  507. package/validators/required.js +3 -1
  508. package/validators/required.js.map +1 -1
  509. package/validators/timeGte.js +4 -3
  510. package/validators/timeGte.js.map +1 -1
  511. package/validators/timeLte.js +4 -3
  512. package/validators/timeLte.js.map +1 -1
  513. package/validators/unique.js +4 -2
  514. package/validators/unique.js.map +1 -1
  515. package/crud/contentModel/afterCreate.d.ts +0 -8
  516. package/crud/contentModel/afterCreate.js +0 -16
  517. package/crud/contentModel/afterCreate.js.map +0 -1
  518. package/crud/contentModel/afterCreateFrom.d.ts +0 -8
  519. package/crud/contentModel/afterCreateFrom.js +0 -16
  520. package/crud/contentModel/afterCreateFrom.js.map +0 -1
  521. package/crud/contentModel/afterDelete.d.ts +0 -8
  522. package/crud/contentModel/afterDelete.js +0 -16
  523. package/crud/contentModel/afterDelete.js.map +0 -1
  524. package/crud/contentModel/afterUpdate.d.ts +0 -8
  525. package/crud/contentModel/afterUpdate.js +0 -16
  526. package/crud/contentModel/afterUpdate.js.map +0 -1
  527. package/crud/contentModel/createFieldModels.d.ts +0 -2
  528. package/crud/contentModel/createFieldModels.js +0 -26
  529. package/crud/contentModel/createFieldModels.js.map +0 -1
  530. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  531. package/crud/contentModel/fieldIdValidation.js +0 -25
  532. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  533. package/crud/contentModel/idValidation.d.ts +0 -1
  534. package/crud/contentModel/idValidation.js +0 -22
  535. package/crud/contentModel/idValidation.js.map +0 -1
  536. package/crud/contentModel/models.d.ts +0 -4
  537. package/crud/contentModel/models.js +0 -192
  538. package/crud/contentModel/models.js.map +0 -1
  539. package/crud/contentModel/systemFields.d.ts +0 -1
  540. package/crud/contentModel/systemFields.js +0 -8
  541. package/crud/contentModel/systemFields.js.map +0 -1
  542. package/crud/contentModel/validateLayout.d.ts +0 -2
  543. package/crud/contentModel/validateLayout.js +0 -28
  544. package/crud/contentModel/validateLayout.js.map +0 -1
  545. package/crud/settings.crud.d.ts +0 -10
  546. package/crud/settings.crud.js +0 -71
  547. package/crud/settings.crud.js.map +0 -1
  548. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +0 -6
  549. package/graphql/schema/resolvers/commonFieldResolvers.js +0 -12
  550. package/graphql/schema/resolvers/commonFieldResolvers.js.map +0 -1
  551. package/upgrades/5.33.0/index.d.ts +0 -3
  552. package/upgrades/5.33.0/index.js +0 -159
  553. package/upgrades/5.33.0/index.js.map +0 -1
  554. package/upgrades/index.d.ts +0 -1
  555. package/upgrades/index.js +0 -9
  556. package/upgrades/index.js.map +0 -1
  557. package/utils/ownership.d.ts +0 -8
  558. package/utils/ownership.js +0 -33
  559. package/utils/ownership.js.map +0 -1
  560. package/utils/permissions.d.ts +0 -7
  561. package/utils/permissions.js +0 -91
  562. package/utils/permissions.js.map +0 -1
  563. package/utils/pluralizedTypeName.d.ts +0 -1
  564. package/utils/pluralizedTypeName.js +0 -20
  565. package/utils/pluralizedTypeName.js.map +0 -1
  566. package/validators/dynamicZone.d.ts +0 -2
  567. package/validators/dynamicZone.js +0 -20
  568. package/validators/dynamicZone.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["disallowedModelIdList","disallowedModelIdEndingList","checkModelIdUniqueness","modelIdList","modelId","includes","WebinyError","pluralizedModelIdCamelCase","pluralize","plural","singularizedModelIdCamelCase","singular","checkModelIdAllowed","checkModelIdEndingAllowed","ending","re","RegExp","matched","match","getModelId","model","name","camelCase","trim","createOnModelBeforeCb","plugins","storageOperations","params","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","models","list","where","tenant","locale","map","m","assignModelBeforeCreate","onModelBeforeCreate","onModelBeforeCreateFrom","context","subscribe","input","validateLayout","layout","fields","cb","validateModel"],"sources":["beforeCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport camelCase from \"lodash/camelCase\";\nimport pluralize from \"pluralize\";\nimport {\n OnModelBeforeCreateFromTopicParams,\n OnModelBeforeCreateTopicParams,\n CmsModel,\n HeadlessCmsStorageOperations,\n CmsContext\n} from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { validateModel } from \"./validateModel\";\nimport { validateLayout } from \"./validateLayout\";\n\nconst disallowedModelIdList: string[] = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\n/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nconst disallowedModelIdEndingList: string[] = [\n \"Response\",\n \"List\",\n \"Meta\",\n \"Input\",\n \"Sorter\",\n \"RefType\"\n];\n\n/**\n * Checks for the uniqueness of provided modelId, against the provided list of models.\n * It also takes plural / singular forms of the provided modelId into account.\n */\nconst checkModelIdUniqueness = (modelIdList: string[], modelId: string) => {\n if (modelIdList.includes(modelId) === true) {\n throw new WebinyError(\n `Content model with modelId \"${modelId}\" already exists.`,\n \"MODEL_ID_EXISTS\",\n {\n modelId\n }\n );\n }\n /**\n * Additionally, check if the plural form of the received modelId exists too. This prevents users\n * from creating, for example, \"event\" and \"events\" models, which would break the GraphQL schema.\n * 1. First check if user wants to create the \"event\" model, but the \"events\" model already exists.\n */\n const pluralizedModelIdCamelCase = pluralize(modelId);\n if (modelIdList.includes(pluralizedModelIdCamelCase) === true) {\n throw new WebinyError(\n `Content model with modelId \"${modelId}\" does not exist, but a model with modelId \"${pluralizedModelIdCamelCase}\" does.`,\n \"MODEL_ID_PLURAL_ERROR\",\n {\n modelId,\n plural: pluralizedModelIdCamelCase\n }\n );\n }\n\n /**\n * 2. Then check if user wants to create the \"events\" model, but the \"event\" model already exists.\n */\n const singularizedModelIdCamelCase = pluralize.singular(modelId);\n if (modelIdList.includes(singularizedModelIdCamelCase) === true) {\n throw new WebinyError(\n `Content model with modelId \"${modelId}\" does not exist, but a model with modelId \"${singularizedModelIdCamelCase}\" does.`,\n \"MODEL_ID_SINGULAR_ERROR\",\n {\n modelId,\n singular: singularizedModelIdCamelCase\n }\n );\n }\n};\n\nconst checkModelIdAllowed = (modelId: string): void => {\n if (disallowedModelIdList.includes(modelId) === false) {\n return;\n }\n throw new WebinyError(`Provided model ID \"${modelId}\" is not allowed.`);\n};\n\nconst checkModelIdEndingAllowed = (modelId: string): void => {\n for (const ending of disallowedModelIdEndingList) {\n const re = new RegExp(`${ending}$`, \"i\");\n const matched = modelId.match(re);\n if (matched === null) {\n continue;\n }\n throw new WebinyError(\n `ModelId that ends with \"${ending}\" is not allowed.`,\n \"MODEL_ID_NOT_ALLOWED\",\n {\n modelId\n }\n );\n }\n};\n\nconst getModelId = (model: CmsModel): string => {\n const { modelId, name } = model;\n if (!!modelId) {\n return camelCase(modelId.trim());\n } else if (name) {\n return camelCase(name.trim());\n }\n throw new WebinyError(\n `There is no \"modelId\" or \"name\" passed into the create model method.`,\n \"MISSING_MODEL_DATA\",\n {\n model\n }\n );\n};\n\ninterface CreateOnModelBeforeCreateCbParams {\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nconst createOnModelBeforeCb = ({\n plugins,\n storageOperations\n}: CreateOnModelBeforeCreateCbParams) => {\n return async (params: OnModelBeforeCreateTopicParams | OnModelBeforeCreateFromTopicParams) => {\n const { model } = params;\n\n const modelId = getModelId(model);\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find((item: CmsModelPlugin) => item.contentModel.modelId === modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n `Cannot create \"${model.modelId}\" content model because one is already registered via a plugin.`,\n \"CONTENT_MODEL_CREATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: model.tenant,\n locale: model.locale\n }\n });\n const modelIdList = models.map(m => m.modelId);\n\n /**\n * We need to check for:\n * - is that exact modelId allowed\n * - is modelId unique\n * - is model ending allowed\n */\n checkModelIdAllowed(modelId);\n checkModelIdEndingAllowed(modelId);\n checkModelIdUniqueness(modelIdList, modelId);\n model.modelId = modelId;\n };\n};\n\ninterface AssignBeforeModelCreateParams {\n onModelBeforeCreate: Topic<OnModelBeforeCreateTopicParams>;\n onModelBeforeCreateFrom: Topic<OnModelBeforeCreateFromTopicParams>;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n}\n\n/**\n * We attach both on before create and createFrom events here.\n * Callables are identical.\n */\nexport const assignModelBeforeCreate = (params: AssignBeforeModelCreateParams) => {\n const { onModelBeforeCreate, onModelBeforeCreateFrom, storageOperations, context } = params;\n\n onModelBeforeCreate.subscribe(async ({ model, input }) => {\n /**\n * First the layout...\n */\n validateLayout(model.layout, model.fields);\n /**\n * then we run the shared create/createFrom methods.\n */\n const cb = createOnModelBeforeCb({\n storageOperations,\n plugins: context.plugins\n });\n await cb({\n model,\n input\n });\n /**\n * and then we move onto model and fields...\n */\n await validateModel({\n model,\n context\n });\n });\n\n onModelBeforeCreateFrom.subscribe(\n createOnModelBeforeCb({\n storageOperations,\n plugins: context.plugins\n })\n );\n};\n"],"mappings":"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"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_camelCase","_CmsModelPlugin","_validateModel","_modelId","_singularApiName","_pluralApiName","_endingAllowed","getModelId","model","modelId","name","value","trim","isModelIdValid","camelCase","toLowerCase","WebinyError","createOnModelBeforeCb","plugins","storageOperations","params","newModel","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","models","list","where","tenant","locale","validateModelIdAllowed","validateEndingAllowed","validateExistingModelId","existingModel","validateSingularApiName","validatePluralApiName","assignModelBeforeCreate","onModelBeforeCreate","onModelBeforeCreateFrom","context","subscribe","input","cb","security","withoutAuthorization","cms","listModels","validateModel","exports"],"sources":["beforeCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport camelCase from \"lodash/camelCase\";\nimport {\n CmsContext,\n CmsModel,\n HeadlessCmsStorageOperations,\n OnModelBeforeCreateFromTopicParams,\n OnModelBeforeCreateTopicParams\n} from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { validateModel } from \"./validateModel\";\nimport { validateExistingModelId, validateModelIdAllowed } from \"./validate/modelId\";\nimport { validateSingularApiName } from \"./validate/singularApiName\";\nimport { validatePluralApiName } from \"./validate/pluralApiName\";\nimport { validateEndingAllowed } from \"~/crud/contentModel/validate/endingAllowed\";\n\nconst getModelId = (model: CmsModel): string => {\n const { modelId, name } = model;\n const value = modelId ? modelId.trim() : null;\n if (value) {\n const isModelIdValid = camelCase(value).toLowerCase() === value.toLowerCase();\n if (isModelIdValid) {\n return value;\n }\n return camelCase(value);\n } else if (name) {\n return camelCase(name.trim());\n }\n throw new WebinyError(\n `There is no \"modelId\" or \"name\" passed into the create model method.`,\n \"MISSING_MODEL_DATA\",\n {\n model\n }\n );\n};\n\ninterface CreateOnModelBeforeCreateCbParams {\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\n\nconst createOnModelBeforeCb = ({\n plugins,\n storageOperations\n}: CreateOnModelBeforeCreateCbParams) => {\n return async (params: OnModelBeforeCreateTopicParams | OnModelBeforeCreateFromTopicParams) => {\n const { model: newModel } = params;\n\n const modelId = getModelId(newModel);\n\n newModel.modelId = modelId;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find((item: CmsModelPlugin) => item.contentModel.modelId === modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n `Cannot create \"${newModel.modelId}\" content model because one is already registered via a plugin.`,\n \"CONTENT_MODEL_CREATE_ERROR\",\n {\n modelId: newModel.modelId\n }\n );\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: newModel.tenant,\n locale: newModel.locale\n }\n });\n\n validateModelIdAllowed({\n model: newModel\n });\n validateEndingAllowed({\n model: newModel\n });\n /**\n * We need to check for the existence of:\n * - modelId\n * - singularApiName\n * - pluralApiName\n */\n for (const model of models) {\n validateExistingModelId({\n existingModel: model,\n model: newModel\n });\n validateSingularApiName({\n existingModel: model,\n model: newModel\n });\n validatePluralApiName({\n existingModel: model,\n model: newModel\n });\n }\n };\n};\n\ninterface AssignBeforeModelCreateParams {\n onModelBeforeCreate: Topic<OnModelBeforeCreateTopicParams>;\n onModelBeforeCreateFrom: Topic<OnModelBeforeCreateFromTopicParams>;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n}\n\n/**\n * We attach both on before create and createFrom events here.\n * Callables are identical.\n */\nexport const assignModelBeforeCreate = (params: AssignBeforeModelCreateParams) => {\n const { onModelBeforeCreate, onModelBeforeCreateFrom, storageOperations, context } = params;\n\n onModelBeforeCreate.subscribe(async ({ model, input }) => {\n /**\n * Run the shared create/createFrom methods.\n */\n const cb = createOnModelBeforeCb({\n storageOperations,\n plugins: context.plugins\n });\n await cb({\n model,\n input\n });\n const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\n /**\n * and then we move onto model and fields...\n */\n await validateModel({\n models,\n model,\n context\n });\n });\n\n onModelBeforeCreateFrom.subscribe(\n createOnModelBeforeCb({\n storageOperations,\n plugins: context.plugins\n })\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAUA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AAEA,MAAMQ,UAAU,GAAIC,KAAe,IAAa;EAC5C,MAAM;IAAEC,OAAO;IAAEC;EAAK,CAAC,GAAGF,KAAK;EAC/B,MAAMG,KAAK,GAAGF,OAAO,GAAGA,OAAO,CAACG,IAAI,CAAC,CAAC,GAAG,IAAI;EAC7C,IAAID,KAAK,EAAE;IACP,MAAME,cAAc,GAAG,IAAAC,kBAAS,EAACH,KAAK,CAAC,CAACI,WAAW,CAAC,CAAC,KAAKJ,KAAK,CAACI,WAAW,CAAC,CAAC;IAC7E,IAAIF,cAAc,EAAE;MAChB,OAAOF,KAAK;IAChB;IACA,OAAO,IAAAG,kBAAS,EAACH,KAAK,CAAC;EAC3B,CAAC,MAAM,IAAID,IAAI,EAAE;IACb,OAAO,IAAAI,kBAAS,EAACJ,IAAI,CAACE,IAAI,CAAC,CAAC,CAAC;EACjC;EACA,MAAM,IAAII,cAAW,CAChB,sEAAqE,EACtE,oBAAoB,EACpB;IACIR;EACJ,CACJ,CAAC;AACL,CAAC;AAOD,MAAMS,qBAAqB,GAAGA,CAAC;EAC3BC,OAAO;EACPC;AAC+B,CAAC,KAAK;EACrC,OAAO,MAAOC,MAA2E,IAAK;IAC1F,MAAM;MAAEZ,KAAK,EAAEa;IAAS,CAAC,GAAGD,MAAM;IAElC,MAAMX,OAAO,GAAGF,UAAU,CAACc,QAAQ,CAAC;IAEpCA,QAAQ,CAACZ,OAAO,GAAGA,OAAO;IAE1B,MAAMa,WAAW,GAAGJ,OAAO,CACtBK,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAAEC,IAAoB,IAAKA,IAAI,CAACC,YAAY,CAACnB,OAAO,KAAKA,OAAO,CAAC;IAE1E,IAAIa,WAAW,EAAE;MACb,MAAM,IAAIN,cAAW,CAChB,kBAAiBK,QAAQ,CAACZ,OAAQ,iEAAgE,EACnG,4BAA4B,EAC5B;QACIA,OAAO,EAAEY,QAAQ,CAACZ;MACtB,CACJ,CAAC;IACL;IAEA,MAAMoB,MAAM,GAAG,MAAMV,iBAAiB,CAACU,MAAM,CAACC,IAAI,CAAC;MAC/CC,KAAK,EAAE;QACHC,MAAM,EAAEX,QAAQ,CAACW,MAAM;QACvBC,MAAM,EAAEZ,QAAQ,CAACY;MACrB;IACJ,CAAC,CAAC;IAEF,IAAAC,+BAAsB,EAAC;MACnB1B,KAAK,EAAEa;IACX,CAAC,CAAC;IACF,IAAAc,oCAAqB,EAAC;MAClB3B,KAAK,EAAEa;IACX,CAAC,CAAC;IACF;AACR;AACA;AACA;AACA;AACA;IACQ,KAAK,MAAMb,KAAK,IAAIqB,MAAM,EAAE;MACxB,IAAAO,gCAAuB,EAAC;QACpBC,aAAa,EAAE7B,KAAK;QACpBA,KAAK,EAAEa;MACX,CAAC,CAAC;MACF,IAAAiB,wCAAuB,EAAC;QACpBD,aAAa,EAAE7B,KAAK;QACpBA,KAAK,EAAEa;MACX,CAAC,CAAC;MACF,IAAAkB,oCAAqB,EAAC;QAClBF,aAAa,EAAE7B,KAAK;QACpBA,KAAK,EAAEa;MACX,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AASD;AACA;AACA;AACA;AACO,MAAMmB,uBAAuB,GAAIpB,MAAqC,IAAK;EAC9E,MAAM;IAAEqB,mBAAmB;IAAEC,uBAAuB;IAAEvB,iBAAiB;IAAEwB;EAAQ,CAAC,GAAGvB,MAAM;EAE3FqB,mBAAmB,CAACG,SAAS,CAAC,OAAO;IAAEpC,KAAK;IAAEqC;EAAM,CAAC,KAAK;IACtD;AACR;AACA;IACQ,MAAMC,EAAE,GAAG7B,qBAAqB,CAAC;MAC7BE,iBAAiB;MACjBD,OAAO,EAAEyB,OAAO,CAACzB;IACrB,CAAC,CAAC;IACF,MAAM4B,EAAE,CAAC;MACLtC,KAAK;MACLqC;IACJ,CAAC,CAAC;IACF,MAAMhB,MAAM,GAAG,MAAMc,OAAO,CAACI,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACnE,OAAOL,OAAO,CAACM,GAAG,CAACC,UAAU,CAAC,CAAC;IACnC,CAAC,CAAC;IACF;AACR;AACA;IACQ,MAAM,IAAAC,4BAAa,EAAC;MAChBtB,MAAM;MACNrB,KAAK;MACLmC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFD,uBAAuB,CAACE,SAAS,CAC7B3B,qBAAqB,CAAC;IAClBE,iBAAiB;IACjBD,OAAO,EAAEyB,OAAO,CAACzB;EACrB,CAAC,CACL,CAAC;AACL,CAAC;AAACkC,OAAA,CAAAZ,uBAAA,GAAAA,uBAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Topic } from "@webiny/pubsub/types";
2
- import { OnModelBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from "../../types";
2
+ import { HeadlessCmsStorageOperations, OnModelBeforeDeleteTopicParams } from "../../types";
3
3
  import { PluginsContainer } from "@webiny/plugins";
4
4
  interface AssignBeforeModelDeleteParams {
5
5
  onModelBeforeDelete: Topic<OnModelBeforeDeleteTopicParams>;
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.assignModelBeforeDelete = void 0;
8
8
  var _error = _interopRequireDefault(require("@webiny/error"));
9
9
  var _CmsModelPlugin = require("../../plugins/CmsModelPlugin");
10
- var _valueKeyStorageConverter = require("../../utils/converters/valueKeyStorageConverter");
11
10
  const assignModelBeforeDelete = params => {
12
11
  const {
13
12
  onModelBeforeDelete,
@@ -26,10 +25,7 @@ const assignModelBeforeDelete = params => {
26
25
  }
27
26
  let entries = [];
28
27
  try {
29
- const result = await storageOperations.entries.list((0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
30
- model,
31
- plugins
32
- }), {
28
+ const result = await storageOperations.entries.list(model, {
33
29
  where: {
34
30
  latest: true
35
31
  },
@@ -47,4 +43,6 @@ const assignModelBeforeDelete = params => {
47
43
  }
48
44
  });
49
45
  };
50
- exports.assignModelBeforeDelete = assignModelBeforeDelete;
46
+ exports.assignModelBeforeDelete = assignModelBeforeDelete;
47
+
48
+ //# sourceMappingURL=beforeDelete.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["assignModelBeforeDelete","params","onModelBeforeDelete","storageOperations","plugins","subscribe","model","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","entries","result","list","attachCmsModelFieldConverters","where","latest","limit","items","ex","error","length"],"sources":["beforeDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnModelBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { attachCmsModelFieldConverters } from \"~/utils/converters/valueKeyStorageConverter\";\n\ninterface AssignBeforeModelDeleteParams {\n onModelBeforeDelete: Topic<OnModelBeforeDeleteTopicParams>;\n storageOperations: HeadlessCmsStorageOperations;\n plugins: PluginsContainer;\n}\nexport const assignModelBeforeDelete = (params: AssignBeforeModelDeleteParams) => {\n const { onModelBeforeDelete, storageOperations, plugins } = params;\n\n onModelBeforeDelete.subscribe(async params => {\n const { model } = params;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find(item => item.contentModel.modelId === model.modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n \"Content models defined via plugins cannot be deleted.\",\n \"CONTENT_MODEL_DELETE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n let entries = [];\n try {\n const result = await storageOperations.entries.list(\n attachCmsModelFieldConverters({\n model,\n plugins\n }),\n {\n where: {\n latest: true\n },\n limit: 1\n }\n );\n entries = result.items;\n } catch (ex) {\n throw new WebinyError(\n \"Could not retrieve a list of content entries from the model.\",\n \"ENTRIES_ERROR\",\n {\n error: ex,\n model\n }\n );\n }\n if (entries.length > 0) {\n throw new WebinyError(\n `Cannot delete content model \"${model.modelId}\" because there are existing entries.`,\n \"CONTENT_MODEL_BEFORE_DELETE_HOOK_FAILED\"\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAGA;AACA;AACA;AAOO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC,iBAAiB;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAElEC,mBAAmB,CAACG,SAAS,CAAC,MAAMJ,MAAM,IAAI;IAC1C,MAAM;MAAEK;IAAM,CAAC,GAAGL,MAAM;IAExB,MAAMM,WAAW,GAAGH,OAAO,CACtBI,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,YAAY,CAACC,OAAO,KAAKR,KAAK,CAACQ,OAAO,CAAC;IAE9D,IAAIP,WAAW,EAAE;MACb,MAAM,IAAIQ,cAAW,CACjB,uDAAuD,EACvD,4BAA4B,EAC5B;QACID,OAAO,EAAER,KAAK,CAACQ;MACnB,CAAC,CACJ;IACL;IAEA,IAAIE,OAAO,GAAG,EAAE;IAChB,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMd,iBAAiB,CAACa,OAAO,CAACE,IAAI,CAC/C,IAAAC,uDAA6B,EAAC;QAC1Bb,KAAK;QACLF;MACJ,CAAC,CAAC,EACF;QACIgB,KAAK,EAAE;UACHC,MAAM,EAAE;QACZ,CAAC;QACDC,KAAK,EAAE;MACX,CAAC,CACJ;MACDN,OAAO,GAAGC,MAAM,CAACM,KAAK;IAC1B,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,MAAM,IAAIT,cAAW,CACjB,8DAA8D,EAC9D,eAAe,EACf;QACIU,KAAK,EAAED,EAAE;QACTlB;MACJ,CAAC,CACJ;IACL;IACA,IAAIU,OAAO,CAACU,MAAM,GAAG,CAAC,EAAE;MACpB,MAAM,IAAIX,cAAW,CAChB,gCAA+BT,KAAK,CAACQ,OAAQ,uCAAsC,EACpF,yCAAyC,CAC5C;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_CmsModelPlugin","assignModelBeforeDelete","params","onModelBeforeDelete","storageOperations","plugins","subscribe","model","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","entries","result","list","where","latest","limit","items","ex","error","length","exports"],"sources":["beforeDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { HeadlessCmsStorageOperations, OnModelBeforeDeleteTopicParams } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\n\ninterface AssignBeforeModelDeleteParams {\n onModelBeforeDelete: Topic<OnModelBeforeDeleteTopicParams>;\n storageOperations: HeadlessCmsStorageOperations;\n plugins: PluginsContainer;\n}\nexport const assignModelBeforeDelete = (params: AssignBeforeModelDeleteParams) => {\n const { onModelBeforeDelete, storageOperations, plugins } = params;\n\n onModelBeforeDelete.subscribe(async params => {\n const { model } = params;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find(item => item.contentModel.modelId === model.modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n \"Content models defined via plugins cannot be deleted.\",\n \"CONTENT_MODEL_DELETE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n let entries = [];\n try {\n const result = await storageOperations.entries.list(model, {\n where: {\n latest: true\n },\n limit: 1\n });\n entries = result.items;\n } catch (ex) {\n throw new WebinyError(\n \"Could not retrieve a list of content entries from the model.\",\n \"ENTRIES_ERROR\",\n {\n error: ex,\n model\n }\n );\n }\n if (entries.length > 0) {\n throw new WebinyError(\n `Cannot delete content model \"${model.modelId}\" because there are existing entries.`,\n \"CONTENT_MODEL_BEFORE_DELETE_HOOK_FAILED\"\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAOO,MAAME,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC,iBAAiB;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAElEC,mBAAmB,CAACG,SAAS,CAAC,MAAMJ,MAAM,IAAI;IAC1C,MAAM;MAAEK;IAAM,CAAC,GAAGL,MAAM;IAExB,MAAMM,WAAW,GAAGH,OAAO,CACtBI,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,YAAY,CAACC,OAAO,KAAKR,KAAK,CAACQ,OAAO,CAAC;IAE9D,IAAIP,WAAW,EAAE;MACb,MAAM,IAAIQ,cAAW,CACjB,uDAAuD,EACvD,4BAA4B,EAC5B;QACID,OAAO,EAAER,KAAK,CAACQ;MACnB,CACJ,CAAC;IACL;IAEA,IAAIE,OAAO,GAAG,EAAE;IAChB,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMd,iBAAiB,CAACa,OAAO,CAACE,IAAI,CAACZ,KAAK,EAAE;QACvDa,KAAK,EAAE;UACHC,MAAM,EAAE;QACZ,CAAC;QACDC,KAAK,EAAE;MACX,CAAC,CAAC;MACFL,OAAO,GAAGC,MAAM,CAACK,KAAK;IAC1B,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,MAAM,IAAIR,cAAW,CACjB,8DAA8D,EAC9D,eAAe,EACf;QACIS,KAAK,EAAED,EAAE;QACTjB;MACJ,CACJ,CAAC;IACL;IACA,IAAIU,OAAO,CAACS,MAAM,GAAG,CAAC,EAAE;MACpB,MAAM,IAAIV,cAAW,CAChB,gCAA+BT,KAAK,CAACQ,OAAQ,uCAAsC,EACpF,yCACJ,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAACY,OAAA,CAAA1B,uBAAA,GAAAA,uBAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Topic } from "@webiny/pubsub/types";
2
- import { OnModelBeforeUpdateTopicParams, CmsContext } from "../../types";
2
+ import { CmsContext, OnModelBeforeUpdateTopicParams } from "../../types";
3
3
  interface AssignBeforeModelUpdateParams {
4
4
  onModelBeforeUpdate: Topic<OnModelBeforeUpdateTopicParams>;
5
5
  context: CmsContext;
@@ -5,28 +5,53 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.assignModelBeforeUpdate = void 0;
7
7
  var _validateModel = require("./validateModel");
8
- var _validateLayout = require("./validateLayout");
8
+ var _singularApiName = require("./validate/singularApiName");
9
+ var _pluralApiName = require("./validate/pluralApiName");
10
+ var _endingAllowed = require("./validate/endingAllowed");
9
11
  const assignModelBeforeUpdate = params => {
10
12
  const {
11
13
  onModelBeforeUpdate,
12
14
  context
13
15
  } = params;
14
16
  onModelBeforeUpdate.subscribe(async ({
15
- model,
17
+ model: newModel,
16
18
  original
17
19
  }) => {
20
+ const models = await context.security.withoutAuthorization(async () => {
21
+ return (await context.cms.listModels()).filter(model => {
22
+ return model.modelId !== newModel.modelId;
23
+ });
24
+ });
25
+ (0, _endingAllowed.validateEndingAllowed)({
26
+ model: newModel
27
+ });
18
28
  /**
19
- * First we go through the layout...
29
+ * We need to check for the existence of:
30
+ * - modelId
31
+ * - singularApiName
32
+ * - pluralApiName
20
33
  */
21
- (0, _validateLayout.validateLayout)(model.layout, model.fields);
34
+ for (const model of models) {
35
+ (0, _singularApiName.validateSingularApiName)({
36
+ existingModel: model,
37
+ model: newModel
38
+ });
39
+ (0, _pluralApiName.validatePluralApiName)({
40
+ existingModel: model,
41
+ model: newModel
42
+ });
43
+ }
22
44
  /**
23
45
  * then the model and fields...
24
46
  */
25
47
  await (0, _validateModel.validateModel)({
26
- model,
48
+ models,
49
+ model: newModel,
27
50
  original,
28
51
  context
29
52
  });
30
53
  });
31
54
  };
32
- exports.assignModelBeforeUpdate = assignModelBeforeUpdate;
55
+ exports.assignModelBeforeUpdate = assignModelBeforeUpdate;
56
+
57
+ //# sourceMappingURL=beforeUpdate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["assignModelBeforeUpdate","params","onModelBeforeUpdate","context","subscribe","model","original","validateLayout","layout","fields","validateModel"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnModelBeforeUpdateTopicParams, CmsContext } from \"~/types\";\nimport { validateModel } from \"./validateModel\";\nimport { validateLayout } from \"./validateLayout\";\n\ninterface AssignBeforeModelUpdateParams {\n onModelBeforeUpdate: Topic<OnModelBeforeUpdateTopicParams>;\n context: CmsContext;\n}\n\nexport const assignModelBeforeUpdate = (params: AssignBeforeModelUpdateParams) => {\n const { onModelBeforeUpdate, context } = params;\n\n onModelBeforeUpdate.subscribe(async ({ model, original }) => {\n /**\n * First we go through the layout...\n */\n validateLayout(model.layout, model.fields);\n /**\n * then the model and fields...\n */\n await validateModel({\n model,\n original,\n context\n });\n });\n};\n"],"mappings":";;;;;;AAEA;AACA;AAOO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAE/CC,mBAAmB,CAACE,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEC;EAAS,CAAC,KAAK;IACzD;AACR;AACA;IACQ,IAAAC,8BAAc,EAACF,KAAK,CAACG,MAAM,EAAEH,KAAK,CAACI,MAAM,CAAC;IAC1C;AACR;AACA;IACQ,MAAM,IAAAC,4BAAa,EAAC;MAChBL,KAAK;MACLC,QAAQ;MACRH;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["_validateModel","require","_singularApiName","_pluralApiName","_endingAllowed","assignModelBeforeUpdate","params","onModelBeforeUpdate","context","subscribe","model","newModel","original","models","security","withoutAuthorization","cms","listModels","filter","modelId","validateEndingAllowed","validateSingularApiName","existingModel","validatePluralApiName","validateModel","exports"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext, OnModelBeforeUpdateTopicParams } from \"~/types\";\nimport { validateModel } from \"./validateModel\";\nimport { validateSingularApiName } from \"./validate/singularApiName\";\nimport { validatePluralApiName } from \"./validate/pluralApiName\";\nimport { validateEndingAllowed } from \"~/crud/contentModel/validate/endingAllowed\";\n\ninterface AssignBeforeModelUpdateParams {\n onModelBeforeUpdate: Topic<OnModelBeforeUpdateTopicParams>;\n context: CmsContext;\n}\n\nexport const assignModelBeforeUpdate = (params: AssignBeforeModelUpdateParams) => {\n const { onModelBeforeUpdate, context } = params;\n\n onModelBeforeUpdate.subscribe(async ({ model: newModel, original }) => {\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n return model.modelId !== newModel.modelId;\n });\n });\n\n validateEndingAllowed({\n model: newModel\n });\n /**\n * We need to check for the existence of:\n * - modelId\n * - singularApiName\n * - pluralApiName\n */\n for (const model of models) {\n validateSingularApiName({\n existingModel: model,\n model: newModel\n });\n validatePluralApiName({\n existingModel: model,\n model: newModel\n });\n }\n /**\n * then the model and fields...\n */\n await validateModel({\n models,\n model: newModel,\n original,\n context\n });\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAOO,MAAMI,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAE/CC,mBAAmB,CAACE,SAAS,CAAC,OAAO;IAAEC,KAAK,EAAEC,QAAQ;IAAEC;EAAS,CAAC,KAAK;IACnE,MAAMC,MAAM,GAAG,MAAML,OAAO,CAACM,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACnE,OAAO,CAAC,MAAMP,OAAO,CAACQ,GAAG,CAACC,UAAU,CAAC,CAAC,EAAEC,MAAM,CAACR,KAAK,IAAI;QACpD,OAAOA,KAAK,CAACS,OAAO,KAAKR,QAAQ,CAACQ,OAAO;MAC7C,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,IAAAC,oCAAqB,EAAC;MAClBV,KAAK,EAAEC;IACX,CAAC,CAAC;IACF;AACR;AACA;AACA;AACA;AACA;IACQ,KAAK,MAAMD,KAAK,IAAIG,MAAM,EAAE;MACxB,IAAAQ,wCAAuB,EAAC;QACpBC,aAAa,EAAEZ,KAAK;QACpBA,KAAK,EAAEC;MACX,CAAC,CAAC;MACF,IAAAY,oCAAqB,EAAC;QAClBD,aAAa,EAAEZ,KAAK;QACpBA,KAAK,EAAEC;MACX,CAAC,CAAC;IACN;IACA;AACR;AACA;IACQ,MAAM,IAAAa,4BAAa,EAAC;MAChBX,MAAM;MACNH,KAAK,EAAEC,QAAQ;MACfC,QAAQ;MACRJ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACiB,OAAA,CAAApB,uBAAA,GAAAA,uBAAA"}
@@ -0,0 +1,3 @@
1
+ import { CmsModel } from "../../../types";
2
+ export declare const ensureSingularApiName: (model: CmsModel) => string;
3
+ export declare const ensurePluralApiName: (model: CmsModel) => string;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ensureSingularApiName = exports.ensurePluralApiName = void 0;
8
+ var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
9
+ var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
10
+ var _pluralize = _interopRequireDefault(require("pluralize"));
11
+ const ensureSingularApiName = model => {
12
+ if (!model.singularApiName) {
13
+ return (0, _upperFirst.default)((0, _camelCase.default)(model.modelId));
14
+ }
15
+ return model.singularApiName;
16
+ };
17
+ exports.ensureSingularApiName = ensureSingularApiName;
18
+ const ensurePluralApiName = model => {
19
+ if (!model.pluralApiName) {
20
+ return (0, _pluralize.default)(ensureSingularApiName(model));
21
+ }
22
+ return model.pluralApiName;
23
+ };
24
+ exports.ensurePluralApiName = ensurePluralApiName;
25
+
26
+ //# sourceMappingURL=modelApiName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_camelCase","_interopRequireDefault","require","_upperFirst","_pluralize","ensureSingularApiName","model","singularApiName","upperFirst","camelCase","modelId","exports","ensurePluralApiName","pluralApiName","pluralize"],"sources":["modelApiName.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase\";\nimport upperFirst from \"lodash/upperFirst\";\nimport pluralize from \"pluralize\";\nimport { CmsModel } from \"~/types\";\n\nexport const ensureSingularApiName = (model: CmsModel): string => {\n if (!model.singularApiName) {\n return upperFirst(camelCase(model.modelId));\n }\n return model.singularApiName;\n};\n\nexport const ensurePluralApiName = (model: CmsModel): string => {\n if (!model.pluralApiName) {\n return pluralize(ensureSingularApiName(model));\n }\n return model.pluralApiName;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,KAAe,IAAa;EAC9D,IAAI,CAACA,KAAK,CAACC,eAAe,EAAE;IACxB,OAAO,IAAAC,mBAAU,EAAC,IAAAC,kBAAS,EAACH,KAAK,CAACI,OAAO,CAAC,CAAC;EAC/C;EACA,OAAOJ,KAAK,CAACC,eAAe;AAChC,CAAC;AAACI,OAAA,CAAAN,qBAAA,GAAAA,qBAAA;AAEK,MAAMO,mBAAmB,GAAIN,KAAe,IAAa;EAC5D,IAAI,CAACA,KAAK,CAACO,aAAa,EAAE;IACtB,OAAO,IAAAC,kBAAS,EAACT,qBAAqB,CAACC,KAAK,CAAC,CAAC;EAClD;EACA,OAAOA,KAAK,CAACO,aAAa;AAC9B,CAAC;AAACF,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
@@ -19,4 +19,6 @@ const contentModelManagerFactory = async (context, model) => {
19
19
  }
20
20
  return await plugin.create(context, model);
21
21
  };
22
- exports.contentModelManagerFactory = contentModelManagerFactory;
22
+ exports.contentModelManagerFactory = contentModelManagerFactory;
23
+
24
+ //# sourceMappingURL=contentModelManagerFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defaultName","contentModelManagerFactory","context","model","pluginsByType","plugins","byType","reverse","plugin","target","Array","isArray","modelId","includes","name","create","find","Error"],"sources":["contentModelManagerFactory.ts"],"sourcesContent":["import { CmsModel, CmsContext, ModelManagerPlugin, CmsModelManager } from \"~/types\";\n\nconst defaultName = \"content-model-manager-default\";\n\nexport const contentModelManagerFactory = async (\n context: CmsContext,\n model: CmsModel\n): Promise<CmsModelManager> => {\n const pluginsByType = context.plugins\n .byType<ModelManagerPlugin>(\"cms-content-model-manager\")\n .reverse();\n for (const plugin of pluginsByType) {\n const target = Array.isArray(plugin.modelId) ? plugin.modelId : [plugin.modelId];\n if (target.includes(model.modelId) === true && plugin.name !== defaultName) {\n return await plugin.create(context, model);\n }\n }\n const plugin = pluginsByType.find(plugin => plugin.name === defaultName);\n if (!plugin) {\n throw new Error(\"There is no default plugin to create CmsModelManager\");\n }\n return await plugin.create(context, model);\n};\n"],"mappings":";;;;;;AAEA,MAAMA,WAAW,GAAG,+BAA+B;AAE5C,MAAMC,0BAA0B,GAAG,OACtCC,OAAmB,EACnBC,KAAe,KACY;EAC3B,MAAMC,aAAa,GAAGF,OAAO,CAACG,OAAO,CAChCC,MAAM,CAAqB,2BAA2B,CAAC,CACvDC,OAAO,EAAE;EACd,KAAK,MAAMC,MAAM,IAAIJ,aAAa,EAAE;IAChC,MAAMK,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACI,OAAO,CAAC,GAAGJ,MAAM,CAACI,OAAO,GAAG,CAACJ,MAAM,CAACI,OAAO,CAAC;IAChF,IAAIH,MAAM,CAACI,QAAQ,CAACV,KAAK,CAACS,OAAO,CAAC,KAAK,IAAI,IAAIJ,MAAM,CAACM,IAAI,KAAKd,WAAW,EAAE;MACxE,OAAO,MAAMQ,MAAM,CAACO,MAAM,CAACb,OAAO,EAAEC,KAAK,CAAC;IAC9C;EACJ;EACA,MAAMK,MAAM,GAAGJ,aAAa,CAACY,IAAI,CAACR,MAAM,IAAIA,MAAM,CAACM,IAAI,KAAKd,WAAW,CAAC;EACxE,IAAI,CAACQ,MAAM,EAAE;IACT,MAAM,IAAIS,KAAK,CAAC,sDAAsD,CAAC;EAC3E;EACA,OAAO,MAAMT,MAAM,CAACO,MAAM,CAACb,OAAO,EAAEC,KAAK,CAAC;AAC9C,CAAC;AAAC"}
1
+ {"version":3,"names":["defaultName","contentModelManagerFactory","context","model","pluginsByType","plugins","byType","reverse","plugin","target","Array","isArray","modelId","includes","name","create","find","Error","exports"],"sources":["contentModelManagerFactory.ts"],"sourcesContent":["import { CmsModel, CmsContext, ModelManagerPlugin, CmsModelManager } from \"~/types\";\n\nconst defaultName = \"content-model-manager-default\";\n\nexport const contentModelManagerFactory = async (\n context: CmsContext,\n model: CmsModel\n): Promise<CmsModelManager> => {\n const pluginsByType = context.plugins\n .byType<ModelManagerPlugin>(\"cms-content-model-manager\")\n .reverse();\n for (const plugin of pluginsByType) {\n const target = Array.isArray(plugin.modelId) ? plugin.modelId : [plugin.modelId];\n if (target.includes(model.modelId) === true && plugin.name !== defaultName) {\n return await plugin.create(context, model);\n }\n }\n const plugin = pluginsByType.find(plugin => plugin.name === defaultName);\n if (!plugin) {\n throw new Error(\"There is no default plugin to create CmsModelManager\");\n }\n return await plugin.create(context, model);\n};\n"],"mappings":";;;;;;AAEA,MAAMA,WAAW,GAAG,+BAA+B;AAE5C,MAAMC,0BAA0B,GAAG,MAAAA,CACtCC,OAAmB,EACnBC,KAAe,KACY;EAC3B,MAAMC,aAAa,GAAGF,OAAO,CAACG,OAAO,CAChCC,MAAM,CAAqB,2BAA2B,CAAC,CACvDC,OAAO,CAAC,CAAC;EACd,KAAK,MAAMC,MAAM,IAAIJ,aAAa,EAAE;IAChC,MAAMK,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACI,OAAO,CAAC,GAAGJ,MAAM,CAACI,OAAO,GAAG,CAACJ,MAAM,CAACI,OAAO,CAAC;IAChF,IAAIH,MAAM,CAACI,QAAQ,CAACV,KAAK,CAACS,OAAO,CAAC,KAAK,IAAI,IAAIJ,MAAM,CAACM,IAAI,KAAKd,WAAW,EAAE;MACxE,OAAO,MAAMQ,MAAM,CAACO,MAAM,CAACb,OAAO,EAAEC,KAAK,CAAC;IAC9C;EACJ;EACA,MAAMK,MAAM,GAAGJ,aAAa,CAACY,IAAI,CAACR,MAAM,IAAIA,MAAM,CAACM,IAAI,KAAKd,WAAW,CAAC;EACxE,IAAI,CAACQ,MAAM,EAAE;IACT,MAAM,IAAIS,KAAK,CAAC,sDAAsD,CAAC;EAC3E;EACA,OAAO,MAAMT,MAAM,CAACO,MAAM,CAACb,OAAO,EAAEC,KAAK,CAAC;AAC9C,CAAC;AAACe,OAAA,CAAAjB,0BAAA,GAAAA,0BAAA"}
@@ -14,4 +14,6 @@ const createFieldStorageId = params => {
14
14
  type
15
15
  })}@${id}`;
16
16
  };
17
- exports.createFieldStorageId = createFieldStorageId;
17
+ exports.createFieldStorageId = createFieldStorageId;
18
+
19
+ //# sourceMappingURL=createFieldStorageId.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFieldStorageId","params","type","id","getBaseFieldType"],"sources":["createFieldStorageId.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport const createFieldStorageId = (params: Pick<CmsModelField, \"id\" | \"type\">): string => {\n const { type, id } = params;\n return `${getBaseFieldType({ type })}@${id}`;\n};\n"],"mappings":";;;;;;AACA;AAEO,MAAMA,oBAAoB,GAAIC,MAA0C,IAAa;EACxF,MAAM;IAAEC,IAAI;IAAEC;EAAG,CAAC,GAAGF,MAAM;EAC3B,OAAQ,GAAE,IAAAG,kCAAgB,EAAC;IAAEF;EAAK,CAAC,CAAE,IAAGC,EAAG,EAAC;AAChD,CAAC;AAAC"}
1
+ {"version":3,"names":["_getBaseFieldType","require","createFieldStorageId","params","type","id","getBaseFieldType","exports"],"sources":["createFieldStorageId.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport const createFieldStorageId = (params: Pick<CmsModelField, \"id\" | \"type\">): string => {\n const { type, id } = params;\n return `${getBaseFieldType({ type })}@${id}`;\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAEO,MAAMC,oBAAoB,GAAIC,MAA0C,IAAa;EACxF,MAAM;IAAEC,IAAI;IAAEC;EAAG,CAAC,GAAGF,MAAM;EAC3B,OAAQ,GAAE,IAAAG,kCAAgB,EAAC;IAAEF;EAAK,CAAC,CAAE,IAAGC,EAAG,EAAC;AAChD,CAAC;AAACE,OAAA,CAAAL,oBAAA,GAAAA,oBAAA"}
@@ -0,0 +1,5 @@
1
+ import { CmsModelCreateInput } from "../../types";
2
+ /**
3
+ * We only assign default fields if there are no fields in the model already.
4
+ */
5
+ export declare const assignModelDefaultFields: (model: CmsModelCreateInput) => void;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.assignModelDefaultFields = void 0;
7
+ var _utils = require("@webiny/utils");
8
+ const createDefaultFields = () => {
9
+ return [{
10
+ id: (0, _utils.generateAlphaNumericLowerCaseId)(8),
11
+ fieldId: "title",
12
+ type: "text",
13
+ label: "Title",
14
+ validation: [{
15
+ name: "required",
16
+ message: "Title is a required field."
17
+ }],
18
+ listValidation: [],
19
+ renderer: {
20
+ name: "text-input"
21
+ }
22
+ }, {
23
+ id: (0, _utils.generateAlphaNumericLowerCaseId)(8),
24
+ fieldId: "description",
25
+ type: "long-text",
26
+ label: "Description",
27
+ validation: [],
28
+ listValidation: [],
29
+ renderer: {
30
+ name: "long-text-text-area"
31
+ }
32
+ }, {
33
+ id: (0, _utils.generateAlphaNumericLowerCaseId)(8),
34
+ fieldId: "image",
35
+ type: "file",
36
+ label: "Image",
37
+ validation: [],
38
+ listValidation: [],
39
+ renderer: {
40
+ name: "file-input"
41
+ },
42
+ settings: {
43
+ imagesOnly: true
44
+ }
45
+ }];
46
+ };
47
+
48
+ /**
49
+ * We only assign default fields if there are no fields in the model already.
50
+ */
51
+ const assignModelDefaultFields = model => {
52
+ if (model.fields && model.fields.length !== 0) {
53
+ return;
54
+ }
55
+ model.fields = createDefaultFields();
56
+ model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];
57
+ };
58
+ exports.assignModelDefaultFields = assignModelDefaultFields;
59
+
60
+ //# sourceMappingURL=defaultFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","createDefaultFields","id","generateAlphaNumericLowerCaseId","fieldId","type","label","validation","name","message","listValidation","renderer","settings","imagesOnly","assignModelDefaultFields","model","fields","length","layout","exports"],"sources":["defaultFields.ts"],"sourcesContent":["import { CmsModelCreateInput, CmsModelFieldInput } from \"~/types\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils\";\n\nconst createDefaultFields = (): CmsModelFieldInput[] => {\n return [\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"title\",\n type: \"text\",\n label: \"Title\",\n validation: [\n {\n name: \"required\",\n message: \"Title is a required field.\"\n }\n ],\n listValidation: [],\n renderer: {\n name: \"text-input\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"description\",\n type: \"long-text\",\n label: \"Description\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"long-text-text-area\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"image\",\n type: \"file\",\n label: \"Image\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"file-input\"\n },\n settings: {\n imagesOnly: true\n }\n }\n ];\n};\n\n/**\n * We only assign default fields if there are no fields in the model already.\n */\nexport const assignModelDefaultFields = (model: CmsModelCreateInput): void => {\n if (model.fields && model.fields.length !== 0) {\n return;\n }\n\n model.fields = createDefaultFields();\n model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,mBAAmB,GAAGA,CAAA,KAA4B;EACpD,OAAO,CACH;IACIC,EAAE,EAAE,IAAAC,sCAA+B,EAAC,CAAC,CAAC;IACtCC,OAAO,EAAE,OAAO;IAChBC,IAAI,EAAE,MAAM;IACZC,KAAK,EAAE,OAAO;IACdC,UAAU,EAAE,CACR;MACIC,IAAI,EAAE,UAAU;MAChBC,OAAO,EAAE;IACb,CAAC,CACJ;IACDC,cAAc,EAAE,EAAE;IAClBC,QAAQ,EAAE;MACNH,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,IAAAC,sCAA+B,EAAC,CAAC,CAAC;IACtCC,OAAO,EAAE,aAAa;IACtBC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAE,aAAa;IACpBC,UAAU,EAAE,EAAE;IACdG,cAAc,EAAE,EAAE;IAClBC,QAAQ,EAAE;MACNH,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,IAAAC,sCAA+B,EAAC,CAAC,CAAC;IACtCC,OAAO,EAAE,OAAO;IAChBC,IAAI,EAAE,MAAM;IACZC,KAAK,EAAE,OAAO;IACdC,UAAU,EAAE,EAAE;IACdG,cAAc,EAAE,EAAE;IAClBC,QAAQ,EAAE;MACNH,IAAI,EAAE;IACV,CAAC;IACDI,QAAQ,EAAE;MACNC,UAAU,EAAE;IAChB;EACJ,CAAC,CACJ;AACL,CAAC;;AAED;AACA;AACA;AACO,MAAMC,wBAAwB,GAAIC,KAA0B,IAAW;EAC1E,IAAIA,KAAK,CAACC,MAAM,IAAID,KAAK,CAACC,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;IAC3C;EACJ;EAEAF,KAAK,CAACC,MAAM,GAAGf,mBAAmB,CAAC,CAAC;EACpCc,KAAK,CAACG,MAAM,GAAG,CAAC,CAACH,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACd,EAAE,CAAC,EAAE,CAACa,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACd,EAAE,EAAEa,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACd,EAAE,CAAC,CAAC;AACnF,CAAC;AAACiB,OAAA,CAAAL,wBAAA,GAAAA,wBAAA"}
@@ -0,0 +1,5 @@
1
+ import { CmsModel } from "../../types";
2
+ /**
3
+ * Given a model, return an array of tags ensuring the `type` tag is set.
4
+ */
5
+ export declare const ensureTypeTag: (model: Pick<CmsModel, "tags">) => string[];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ensureTypeTag = void 0;
7
+ /**
8
+ * Given a model, return an array of tags ensuring the `type` tag is set.
9
+ */
10
+ const ensureTypeTag = model => {
11
+ // Let's make sure we have a `type` tag assigned.
12
+ // If `type` tag is not set, set it to a default one (`model`).
13
+ const tags = model.tags || [];
14
+ if (!tags.some(tag => tag.startsWith("type:"))) {
15
+ tags.push("type:model");
16
+ }
17
+ return tags;
18
+ };
19
+ exports.ensureTypeTag = ensureTypeTag;
20
+
21
+ //# sourceMappingURL=ensureTypeTag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ensureTypeTag","model","tags","some","tag","startsWith","push","exports"],"sources":["ensureTypeTag.ts"],"sourcesContent":["import { CmsModel } from \"~/types\";\n\n/**\n * Given a model, return an array of tags ensuring the `type` tag is set.\n */\nexport const ensureTypeTag = (model: Pick<CmsModel, \"tags\">) => {\n // Let's make sure we have a `type` tag assigned.\n // If `type` tag is not set, set it to a default one (`model`).\n const tags = model.tags || [];\n if (!tags.some(tag => tag.startsWith(\"type:\"))) {\n tags.push(\"type:model\");\n }\n\n return tags;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,MAAMA,aAAa,GAAIC,KAA6B,IAAK;EAC5D;EACA;EACA,MAAMC,IAAI,GAAGD,KAAK,CAACC,IAAI,IAAI,EAAE;EAC7B,IAAI,CAACA,IAAI,CAACC,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE;IAC5CH,IAAI,CAACI,IAAI,CAAC,YAAY,CAAC;EAC3B;EAEA,OAAOJ,IAAI;AACf,CAAC;AAACK,OAAA,CAAAP,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,2 @@
1
+ import { CmsModelField } from "../../../types";
2
+ export declare const getContentModelDescriptionFieldId: (fields: CmsModelField[], descriptionFieldId?: string | null) => string | null | undefined;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getContentModelDescriptionFieldId = void 0;
8
+ var _getBaseFieldType = require("../../../utils/getBaseFieldType");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const getContentModelDescriptionFieldId = (fields, descriptionFieldId) => {
11
+ /**
12
+ * If there are no fields defined, we will just set as null.
13
+ */
14
+ if (fields.length === 0) {
15
+ return null;
16
+ }
17
+ /**
18
+ * If description field is not defined, let us find possible one.
19
+ */
20
+ if (!descriptionFieldId) {
21
+ const descriptionField = fields.find(field => {
22
+ return (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text" && !field.multipleValues;
23
+ });
24
+ return descriptionField?.fieldId || null;
25
+ }
26
+ const target = fields.find(field => field.fieldId === descriptionFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text");
27
+ if (!target) {
28
+ throw new _error.default(`Field selected for the description field does not exist in the model.`, "VALIDATION_ERROR", {
29
+ fieldId: descriptionFieldId,
30
+ fields
31
+ });
32
+ }
33
+ if (target.multipleValues) {
34
+ throw new _error.default(`Fields that accept multiple values cannot be used as the entry description.`, "ENTRY_TITLE_FIELD_TYPE", {
35
+ storageId: target.storageId,
36
+ fieldId: target.fieldId,
37
+ type: target.type
38
+ });
39
+ }
40
+ return target.fieldId;
41
+ };
42
+ exports.getContentModelDescriptionFieldId = getContentModelDescriptionFieldId;
43
+
44
+ //# sourceMappingURL=descriptionField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getBaseFieldType","require","_error","_interopRequireDefault","getContentModelDescriptionFieldId","fields","descriptionFieldId","length","descriptionField","find","field","getBaseFieldType","multipleValues","fieldId","target","WebinyError","storageId","type","exports"],"sources":["descriptionField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getContentModelDescriptionFieldId = (\n fields: CmsModelField[],\n descriptionFieldId?: string | null\n): string | null | undefined => {\n /**\n * If there are no fields defined, we will just set as null.\n */\n if (fields.length === 0) {\n return null;\n }\n /**\n * If description field is not defined, let us find possible one.\n */\n if (!descriptionFieldId) {\n const descriptionField = fields.find(field => {\n return getBaseFieldType(field) === \"long-text\" && !field.multipleValues;\n });\n return descriptionField?.fieldId || null;\n }\n const target = fields.find(\n field => field.fieldId === descriptionFieldId && getBaseFieldType(field) === \"long-text\"\n );\n if (!target) {\n throw new WebinyError(\n `Field selected for the description field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: descriptionFieldId,\n fields\n }\n );\n }\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry description.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,MAAMG,iCAAiC,GAAGA,CAC7CC,MAAuB,EACvBC,kBAAkC,KACN;EAC5B;AACJ;AACA;EACI,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACD,kBAAkB,EAAE;IACrB,MAAME,gBAAgB,GAAGH,MAAM,CAACI,IAAI,CAACC,KAAK,IAAI;MAC1C,OAAO,IAAAC,kCAAgB,EAACD,KAAK,CAAC,KAAK,WAAW,IAAI,CAACA,KAAK,CAACE,cAAc;IAC3E,CAAC,CAAC;IACF,OAAOJ,gBAAgB,EAAEK,OAAO,IAAI,IAAI;EAC5C;EACA,MAAMC,MAAM,GAAGT,MAAM,CAACI,IAAI,CACtBC,KAAK,IAAIA,KAAK,CAACG,OAAO,KAAKP,kBAAkB,IAAI,IAAAK,kCAAgB,EAACD,KAAK,CAAC,KAAK,WACjF,CAAC;EACD,IAAI,CAACI,MAAM,EAAE;IACT,MAAM,IAAIC,cAAW,CAChB,uEAAsE,EACvE,kBAAkB,EAClB;MACIF,OAAO,EAAEP,kBAAkB;MAC3BD;IACJ,CACJ,CAAC;EACL;EACA,IAAIS,MAAM,CAACF,cAAc,EAAE;IACvB,MAAM,IAAIG,cAAW,CAChB,6EAA4E,EAC7E,wBAAwB,EACxB;MACIC,SAAS,EAAEF,MAAM,CAACE,SAAS;MAC3BH,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBI,IAAI,EAAEH,MAAM,CAACG;IACjB,CACJ,CAAC;EACL;EAEA,OAAOH,MAAM,CAACD,OAAO;AACzB,CAAC;AAACK,OAAA,CAAAd,iCAAA,GAAAA,iCAAA"}
@@ -0,0 +1,2 @@
1
+ import { CmsModelField } from "../../../types";
2
+ export declare const getContentModelImageFieldId: (fields: CmsModelField[], imageFieldId?: string | null) => string | null | undefined;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getContentModelImageFieldId = void 0;
8
+ var _getBaseFieldType = require("../../../utils/getBaseFieldType");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const getContentModelImageFieldId = (fields, imageFieldId) => {
11
+ /**
12
+ * If there are no fields defined, we will just set as null.
13
+ */
14
+ if (fields.length === 0) {
15
+ return null;
16
+ }
17
+ /**
18
+ * If image field is not defined, let us find possible one.
19
+ */
20
+ if (!imageFieldId) {
21
+ const imageField = fields.find(field => {
22
+ return (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && !field.multipleValues && field.settings?.imagesOnly;
23
+ });
24
+ return imageField?.fieldId || null;
25
+ }
26
+ const target = fields.find(field => field.fieldId === imageFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && field.settings?.imagesOnly);
27
+ if (!target) {
28
+ throw new _error.default(`Field selected for the image field does not exist in the model.`, "VALIDATION_ERROR", {
29
+ fieldId: imageFieldId,
30
+ fields
31
+ });
32
+ }
33
+ if (target.multipleValues) {
34
+ throw new _error.default(`Fields that accept multiple values cannot be used as the entry image.`, "ENTRY_TITLE_FIELD_TYPE", {
35
+ storageId: target.storageId,
36
+ fieldId: target.fieldId,
37
+ type: target.type
38
+ });
39
+ }
40
+ return target.fieldId;
41
+ };
42
+ exports.getContentModelImageFieldId = getContentModelImageFieldId;
43
+
44
+ //# sourceMappingURL=imageField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getBaseFieldType","require","_error","_interopRequireDefault","getContentModelImageFieldId","fields","imageFieldId","length","imageField","find","field","getBaseFieldType","multipleValues","settings","imagesOnly","fieldId","target","WebinyError","storageId","type","exports"],"sources":["imageField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getContentModelImageFieldId = (\n fields: CmsModelField[],\n imageFieldId?: string | null\n): string | null | undefined => {\n /**\n * If there are no fields defined, we will just set as null.\n */\n if (fields.length === 0) {\n return null;\n }\n /**\n * If image field is not defined, let us find possible one.\n */\n if (!imageFieldId) {\n const imageField = fields.find(field => {\n return (\n getBaseFieldType(field) === \"file\" &&\n !field.multipleValues &&\n field.settings?.imagesOnly\n );\n });\n return imageField?.fieldId || null;\n }\n const target = fields.find(\n field =>\n field.fieldId === imageFieldId &&\n getBaseFieldType(field) === \"file\" &&\n field.settings?.imagesOnly\n );\n if (!target) {\n throw new WebinyError(\n `Field selected for the image field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: imageFieldId,\n fields\n }\n );\n }\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry image.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,MAAMG,2BAA2B,GAAGA,CACvCC,MAAuB,EACvBC,YAA4B,KACA;EAC5B;AACJ;AACA;EACI,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACD,YAAY,EAAE;IACf,MAAME,UAAU,GAAGH,MAAM,CAACI,IAAI,CAACC,KAAK,IAAI;MACpC,OACI,IAAAC,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,IAClC,CAACA,KAAK,CAACE,cAAc,IACrBF,KAAK,CAACG,QAAQ,EAAEC,UAAU;IAElC,CAAC,CAAC;IACF,OAAON,UAAU,EAAEO,OAAO,IAAI,IAAI;EACtC;EACA,MAAMC,MAAM,GAAGX,MAAM,CAACI,IAAI,CACtBC,KAAK,IACDA,KAAK,CAACK,OAAO,KAAKT,YAAY,IAC9B,IAAAK,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,IAClCA,KAAK,CAACG,QAAQ,EAAEC,UACxB,CAAC;EACD,IAAI,CAACE,MAAM,EAAE;IACT,MAAM,IAAIC,cAAW,CAChB,iEAAgE,EACjE,kBAAkB,EAClB;MACIF,OAAO,EAAET,YAAY;MACrBD;IACJ,CACJ,CAAC;EACL;EACA,IAAIW,MAAM,CAACJ,cAAc,EAAE;IACvB,MAAM,IAAIK,cAAW,CAChB,uEAAsE,EACvE,wBAAwB,EACxB;MACIC,SAAS,EAAEF,MAAM,CAACE,SAAS;MAC3BH,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBI,IAAI,EAAEH,MAAM,CAACG;IACjB,CACJ,CAAC;EACL;EAEA,OAAOH,MAAM,CAACD,OAAO;AACzB,CAAC;AAACK,OAAA,CAAAhB,2BAAA,GAAAA,2BAAA"}
@@ -0,0 +1,2 @@
1
+ import { CmsModelField } from "../../../types";
2
+ export declare const getContentModelTitleFieldId: (fields: CmsModelField[], titleFieldId?: string) => string;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getContentModelTitleFieldId = void 0;
8
+ var _getBaseFieldType = require("../../../utils/getBaseFieldType");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const defaultTitleFieldId = "id";
11
+ const allowedTitleFieldTypes = ["text", "number"];
12
+ const getContentModelTitleFieldId = (fields, titleFieldId) => {
13
+ /**
14
+ * If there are no fields defined, we will return the default field
15
+ */
16
+ if (fields.length === 0) {
17
+ return defaultTitleFieldId;
18
+ }
19
+ /**
20
+ * if there is no title field defined either in input data or existing content model data
21
+ * we will take first text field that has no multiple values enabled
22
+ * or if initial titleFieldId is the default one also try to find first available text field
23
+ */
24
+ if (!titleFieldId || titleFieldId === defaultTitleFieldId) {
25
+ const titleField = fields.find(field => {
26
+ return (0, _getBaseFieldType.getBaseFieldType)(field) === "text" && !field.multipleValues;
27
+ });
28
+ return titleField?.fieldId || defaultTitleFieldId;
29
+ }
30
+ /**
31
+ * check existing titleFieldId for existence in the model
32
+ * for correct type
33
+ * and that it is not multiple values field
34
+ */
35
+ const target = fields.find(f => f.fieldId === titleFieldId);
36
+ if (!target) {
37
+ throw new _error.default(`Field selected for the title field does not exist in the model.`, "VALIDATION_ERROR", {
38
+ fieldId: titleFieldId,
39
+ fields
40
+ });
41
+ }
42
+ if (allowedTitleFieldTypes.includes(target.type) === false) {
43
+ throw new _error.default(`Only ${allowedTitleFieldTypes.join(", ")} and id fields can be used as an entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
44
+ storageId: target.storageId,
45
+ fieldId: target.fieldId,
46
+ type: target.type
47
+ });
48
+ }
49
+ if (target.multipleValues) {
50
+ throw new _error.default(`Fields that accept multiple values cannot be used as the entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
51
+ storageId: target.storageId,
52
+ fieldId: target.fieldId,
53
+ type: target.type
54
+ });
55
+ }
56
+ return target.fieldId;
57
+ };
58
+ exports.getContentModelTitleFieldId = getContentModelTitleFieldId;
59
+
60
+ //# sourceMappingURL=titleField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getBaseFieldType","require","_error","_interopRequireDefault","defaultTitleFieldId","allowedTitleFieldTypes","getContentModelTitleFieldId","fields","titleFieldId","length","titleField","find","field","getBaseFieldType","multipleValues","fieldId","target","f","WebinyError","includes","type","join","storageId","exports"],"sources":["titleField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nconst defaultTitleFieldId = \"id\";\n\nconst allowedTitleFieldTypes = [\"text\", \"number\"];\n\nexport const getContentModelTitleFieldId = (\n fields: CmsModelField[],\n titleFieldId?: string\n): string => {\n /**\n * If there are no fields defined, we will return the default field\n */\n if (fields.length === 0) {\n return defaultTitleFieldId;\n }\n /**\n * if there is no title field defined either in input data or existing content model data\n * we will take first text field that has no multiple values enabled\n * or if initial titleFieldId is the default one also try to find first available text field\n */\n if (!titleFieldId || titleFieldId === defaultTitleFieldId) {\n const titleField = fields.find(field => {\n return getBaseFieldType(field) === \"text\" && !field.multipleValues;\n });\n return titleField?.fieldId || defaultTitleFieldId;\n }\n /**\n * check existing titleFieldId for existence in the model\n * for correct type\n * and that it is not multiple values field\n */\n const target = fields.find(f => f.fieldId === titleFieldId);\n if (!target) {\n throw new WebinyError(\n `Field selected for the title field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: titleFieldId,\n fields\n }\n );\n }\n\n if (allowedTitleFieldTypes.includes(target.type) === false) {\n throw new WebinyError(\n `Only ${allowedTitleFieldTypes.join(\n \", \"\n )} and id fields can be used as an entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,mBAAmB,GAAG,IAAI;AAEhC,MAAMC,sBAAsB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;AAE1C,MAAMC,2BAA2B,GAAGA,CACvCC,MAAuB,EACvBC,YAAqB,KACZ;EACT;AACJ;AACA;EACI,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,OAAOL,mBAAmB;EAC9B;EACA;AACJ;AACA;AACA;AACA;EACI,IAAI,CAACI,YAAY,IAAIA,YAAY,KAAKJ,mBAAmB,EAAE;IACvD,MAAMM,UAAU,GAAGH,MAAM,CAACI,IAAI,CAACC,KAAK,IAAI;MACpC,OAAO,IAAAC,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,IAAI,CAACA,KAAK,CAACE,cAAc;IACtE,CAAC,CAAC;IACF,OAAOJ,UAAU,EAAEK,OAAO,IAAIX,mBAAmB;EACrD;EACA;AACJ;AACA;AACA;AACA;EACI,MAAMY,MAAM,GAAGT,MAAM,CAACI,IAAI,CAACM,CAAC,IAAIA,CAAC,CAACF,OAAO,KAAKP,YAAY,CAAC;EAC3D,IAAI,CAACQ,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CAChB,iEAAgE,EACjE,kBAAkB,EAClB;MACIH,OAAO,EAAEP,YAAY;MACrBD;IACJ,CACJ,CAAC;EACL;EAEA,IAAIF,sBAAsB,CAACc,QAAQ,CAACH,MAAM,CAACI,IAAI,CAAC,KAAK,KAAK,EAAE;IACxD,MAAM,IAAIF,cAAW,CAChB,QAAOb,sBAAsB,CAACgB,IAAI,CAC/B,IACJ,CAAE,+CAA8C,EAChD,wBAAwB,EACxB;MACIC,SAAS,EAAEN,MAAM,CAACM,SAAS;MAC3BP,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBK,IAAI,EAAEJ,MAAM,CAACI;IACjB,CACJ,CAAC;EACL;EAEA,IAAIJ,MAAM,CAACF,cAAc,EAAE;IACvB,MAAM,IAAII,cAAW,CAChB,uEAAsE,EACvE,wBAAwB,EACxB;MACII,SAAS,EAAEN,MAAM,CAACM,SAAS;MAC3BP,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBK,IAAI,EAAEJ,MAAM,CAACI;IACjB,CACJ,CAAC;EACL;EAEA,OAAOJ,MAAM,CAACD,OAAO;AACzB,CAAC;AAACQ,OAAA,CAAAjB,2BAAA,GAAAA,2BAAA"}
@@ -0,0 +1,10 @@
1
+ import { CmsModel, HeadlessCmsStorageOperations } from "../../types";
2
+ import { Tenant } from "@webiny/api-tenancy/types";
3
+ import { I18NLocale } from "@webiny/api-i18n/types";
4
+ interface Params {
5
+ storageOperations: HeadlessCmsStorageOperations;
6
+ getTenant: () => Tenant;
7
+ getLocale: () => I18NLocale;
8
+ }
9
+ export declare const listModelsFromDatabase: (params: Params) => Promise<CmsModel[]>;
10
+ export {};