@webiny/api-headless-cms 0.0.0-unstable.99666aeb00 → 0.0.0-unstable.a9593f74dd

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 (495) hide show
  1. package/constants.d.ts +31 -0
  2. package/constants.js +51 -2
  3. package/constants.js.map +1 -1
  4. package/context.js +50 -45
  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.js +17 -10
  43. package/crud/contentEntry/markLockedFields.js.map +1 -1
  44. package/crud/contentEntry/referenceFieldsMapping.d.ts +6 -0
  45. package/crud/contentEntry/referenceFieldsMapping.js +134 -111
  46. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  47. package/crud/contentEntry/searchableFields.js +5 -4
  48. package/crud/contentEntry/searchableFields.js.map +1 -1
  49. package/crud/contentEntry.crud.d.ts +1 -4
  50. package/crud/contentEntry.crud.js +295 -466
  51. package/crud/contentEntry.crud.js.map +1 -1
  52. package/crud/contentModel/beforeCreate.d.ts +1 -1
  53. package/crud/contentModel/beforeCreate.js +11 -9
  54. package/crud/contentModel/beforeCreate.js.map +1 -1
  55. package/crud/contentModel/beforeDelete.js +3 -1
  56. package/crud/contentModel/beforeDelete.js.map +1 -1
  57. package/crud/contentModel/beforeUpdate.d.ts +1 -1
  58. package/crud/contentModel/beforeUpdate.js +3 -6
  59. package/crud/contentModel/beforeUpdate.js.map +1 -1
  60. package/crud/contentModel/compatibility/modelApiName.js +3 -1
  61. package/crud/contentModel/compatibility/modelApiName.js.map +1 -1
  62. package/crud/contentModel/contentModelManagerFactory.js +3 -1
  63. package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
  64. package/crud/contentModel/createFieldStorageId.js +3 -1
  65. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  66. package/crud/contentModel/defaultFields.js +3 -1
  67. package/crud/contentModel/defaultFields.js.map +1 -1
  68. package/crud/contentModel/ensureTypeTag.d.ts +5 -0
  69. package/crud/contentModel/ensureTypeTag.js +21 -0
  70. package/crud/contentModel/ensureTypeTag.js.map +1 -0
  71. package/crud/contentModel/fields/descriptionField.js +4 -2
  72. package/crud/contentModel/fields/descriptionField.js.map +1 -1
  73. package/crud/contentModel/fields/imageField.js +6 -8
  74. package/crud/contentModel/fields/imageField.js.map +1 -1
  75. package/crud/contentModel/fields/titleField.js +4 -2
  76. package/crud/contentModel/fields/titleField.js.map +1 -1
  77. package/crud/contentModel/listModelsFromDatabase.d.ts +10 -0
  78. package/crud/contentModel/listModelsFromDatabase.js +38 -0
  79. package/crud/contentModel/listModelsFromDatabase.js.map +1 -0
  80. package/crud/contentModel/validate/endingAllowed.js +3 -1
  81. package/crud/contentModel/validate/endingAllowed.js.map +1 -1
  82. package/crud/contentModel/validate/isModelEndingAllowed.js +4 -2
  83. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -1
  84. package/crud/contentModel/validate/modelId.js +3 -1
  85. package/crud/contentModel/validate/modelId.js.map +1 -1
  86. package/crud/contentModel/validate/pluralApiName.js +3 -1
  87. package/crud/contentModel/validate/pluralApiName.js.map +1 -1
  88. package/crud/contentModel/validate/singularApiName.js +3 -1
  89. package/crud/contentModel/validate/singularApiName.js.map +1 -1
  90. package/crud/contentModel/validateModel.js +3 -1
  91. package/crud/contentModel/validateModel.js.map +1 -1
  92. package/crud/contentModel/validateModelFields.js +7 -6
  93. package/crud/contentModel/validateModelFields.js.map +1 -1
  94. package/crud/contentModel/validation.d.ts +531 -210
  95. package/crud/contentModel/validation.js +71 -11
  96. package/crud/contentModel/validation.js.map +1 -1
  97. package/crud/contentModel.crud.js +137 -182
  98. package/crud/contentModel.crud.js.map +1 -1
  99. package/crud/contentModelGroup/beforeCreate.d.ts +1 -1
  100. package/crud/contentModelGroup/beforeCreate.js +15 -1
  101. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  102. package/crud/contentModelGroup/beforeDelete.js +3 -1
  103. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  104. package/crud/contentModelGroup/beforeUpdate.js +3 -1
  105. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  106. package/crud/contentModelGroup/listGroupsFromDatabase.d.ts +8 -0
  107. package/crud/contentModelGroup/listGroupsFromDatabase.js +22 -0
  108. package/crud/contentModelGroup/listGroupsFromDatabase.js.map +1 -0
  109. package/crud/contentModelGroup/validation.d.ts +9 -6
  110. package/crud/contentModelGroup/validation.js +5 -2
  111. package/crud/contentModelGroup/validation.js.map +1 -1
  112. package/crud/contentModelGroup.crud.d.ts +1 -1
  113. package/crud/contentModelGroup.crud.js +113 -112
  114. package/crud/contentModelGroup.crud.js.map +1 -1
  115. package/crud/system.crud.js +8 -11
  116. package/crud/system.crud.js.map +1 -1
  117. package/export/crud/exporting.d.ts +3 -0
  118. package/export/crud/exporting.js +49 -0
  119. package/export/crud/exporting.js.map +1 -0
  120. package/export/crud/importing.d.ts +3 -0
  121. package/export/crud/importing.js +79 -0
  122. package/export/crud/importing.js.map +1 -0
  123. package/export/crud/imports/importData.d.ts +14 -0
  124. package/export/crud/imports/importData.js +52 -0
  125. package/export/crud/imports/importData.js.map +1 -0
  126. package/export/crud/imports/importGroups.d.ts +8 -0
  127. package/export/crud/imports/importGroups.js +104 -0
  128. package/export/crud/imports/importGroups.js.map +1 -0
  129. package/export/crud/imports/importModels.d.ts +8 -0
  130. package/export/crud/imports/importModels.js +136 -0
  131. package/export/crud/imports/importModels.js.map +1 -0
  132. package/export/crud/imports/validateGroups.d.ts +8 -0
  133. package/export/crud/imports/validateGroups.js +112 -0
  134. package/export/crud/imports/validateGroups.js.map +1 -0
  135. package/export/crud/imports/validateInput.d.ts +19 -0
  136. package/export/crud/imports/validateInput.js +55 -0
  137. package/export/crud/imports/validateInput.js.map +1 -0
  138. package/export/crud/imports/validateModels.d.ts +12 -0
  139. package/export/crud/imports/validateModels.js +203 -0
  140. package/export/crud/imports/validateModels.js.map +1 -0
  141. package/export/crud/index.d.ts +4 -0
  142. package/export/crud/index.js +15 -0
  143. package/export/crud/index.js.map +1 -0
  144. package/export/crud/sanitize.d.ts +4 -0
  145. package/export/crud/sanitize.js +35 -0
  146. package/export/crud/sanitize.js.map +1 -0
  147. package/export/graphql/index.d.ts +3 -0
  148. package/export/graphql/index.js +188 -0
  149. package/export/graphql/index.js.map +1 -0
  150. package/export/index.d.ts +2 -0
  151. package/export/index.js +29 -0
  152. package/export/index.js.map +1 -0
  153. package/export/types.d.ts +113 -0
  154. package/export/types.js +22 -0
  155. package/export/types.js.map +1 -0
  156. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +4 -7
  157. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
  158. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +5 -8
  159. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  160. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +47 -38
  161. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  162. package/fieldConverters/index.js +3 -1
  163. package/fieldConverters/index.js.map +1 -1
  164. package/graphql/buildSchemaPlugins.js +7 -1
  165. package/graphql/buildSchemaPlugins.js.map +1 -1
  166. package/graphql/checkEndpointAccess.js +3 -1
  167. package/graphql/checkEndpointAccess.js.map +1 -1
  168. package/graphql/createExecutableSchema.js +3 -1
  169. package/graphql/createExecutableSchema.js.map +1 -1
  170. package/graphql/createRequestBody.js +3 -1
  171. package/graphql/createRequestBody.js.map +1 -1
  172. package/graphql/formatErrorPayload.js +3 -1
  173. package/graphql/formatErrorPayload.js.map +1 -1
  174. package/graphql/generateSchema.js +3 -1
  175. package/graphql/generateSchema.js.map +1 -1
  176. package/graphql/getSchema.d.ts +0 -1
  177. package/graphql/getSchema.js +34 -18
  178. package/graphql/getSchema.js.map +1 -1
  179. package/graphql/graphQLHandlerFactory.js +3 -1
  180. package/graphql/graphQLHandlerFactory.js.map +1 -1
  181. package/graphql/handleRequest.js +3 -5
  182. package/graphql/handleRequest.js.map +1 -1
  183. package/graphql/index.d.ts +1 -1
  184. package/graphql/index.js +4 -2
  185. package/graphql/index.js.map +1 -1
  186. package/graphql/schema/baseContentSchema.js +9 -8
  187. package/graphql/schema/baseContentSchema.js.map +1 -1
  188. package/graphql/schema/baseSchema.d.ts +2 -3
  189. package/graphql/schema/baseSchema.js +64 -2
  190. package/graphql/schema/baseSchema.js.map +1 -1
  191. package/graphql/schema/contentEntries.js +51 -18
  192. package/graphql/schema/contentEntries.js.map +1 -1
  193. package/graphql/schema/contentModelGroups.js +5 -2
  194. package/graphql/schema/contentModelGroups.js.map +1 -1
  195. package/graphql/schema/contentModels.js +10 -10
  196. package/graphql/schema/contentModels.js.map +1 -1
  197. package/graphql/schema/createFieldResolvers.js +14 -12
  198. package/graphql/schema/createFieldResolvers.js.map +1 -1
  199. package/graphql/schema/createFieldTypePluginRecords.js +3 -1
  200. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -1
  201. package/graphql/schema/createManageResolvers.js +13 -10
  202. package/graphql/schema/createManageResolvers.js.map +1 -1
  203. package/graphql/schema/createManageSDL.js +37 -19
  204. package/graphql/schema/createManageSDL.js.map +1 -1
  205. package/graphql/schema/createPreviewResolvers.js +7 -6
  206. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  207. package/graphql/schema/createReadResolvers.js +7 -6
  208. package/graphql/schema/createReadResolvers.js.map +1 -1
  209. package/graphql/schema/createReadSDL.js +12 -5
  210. package/graphql/schema/createReadSDL.js.map +1 -1
  211. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +2 -1
  212. package/graphql/schema/resolvers/manage/resolveCreate.js +4 -2
  213. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  214. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +2 -1
  215. package/graphql/schema/resolvers/manage/resolveCreateFrom.js +4 -2
  216. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  217. package/graphql/schema/resolvers/manage/resolveDelete.js +4 -2
  218. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  219. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +4 -2
  220. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -1
  221. package/graphql/schema/resolvers/manage/resolveGet.js +12 -5
  222. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  223. package/graphql/schema/resolvers/manage/resolveGetByIds.js +3 -1
  224. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  225. package/graphql/schema/resolvers/manage/resolveGetRevisions.js +3 -1
  226. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  227. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +3 -1
  228. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -1
  229. package/graphql/schema/resolvers/manage/resolveList.js +3 -1
  230. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  231. package/graphql/schema/resolvers/manage/resolveMove.js +7 -10
  232. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
  233. package/graphql/schema/resolvers/manage/resolvePublish.js +3 -1
  234. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  235. package/graphql/schema/resolvers/manage/resolveRepublish.js +3 -1
  236. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  237. package/graphql/schema/resolvers/manage/resolveUnpublish.js +3 -1
  238. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  239. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +2 -1
  240. package/graphql/schema/resolvers/manage/resolveUpdate.js +4 -2
  241. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  242. package/graphql/schema/resolvers/manage/resolveValidate.d.ts +8 -0
  243. package/graphql/schema/resolvers/manage/resolveValidate.js +20 -0
  244. package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -0
  245. package/graphql/schema/resolvers/preview/resolveGet.js +6 -5
  246. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  247. package/graphql/schema/resolvers/preview/resolveList.js +3 -1
  248. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  249. package/graphql/schema/resolvers/read/resolveGet.js +6 -5
  250. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  251. package/graphql/schema/resolvers/read/resolveList.js +3 -1
  252. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  253. package/graphql/schema/schemaPlugins.js +3 -1
  254. package/graphql/schema/schemaPlugins.js.map +1 -1
  255. package/graphql/system.js +3 -1
  256. package/graphql/system.js.map +1 -1
  257. package/graphqlFields/boolean.js +3 -1
  258. package/graphqlFields/boolean.js.map +1 -1
  259. package/graphqlFields/datetime.js +5 -5
  260. package/graphqlFields/datetime.js.map +1 -1
  261. package/graphqlFields/dynamicZone/dynamicZoneField.js +42 -19
  262. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  263. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +60 -12
  264. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -1
  265. package/graphqlFields/dynamicZone/index.js +3 -1
  266. package/graphqlFields/dynamicZone/index.js.map +1 -1
  267. package/graphqlFields/file.js +3 -1
  268. package/graphqlFields/file.js.map +1 -1
  269. package/graphqlFields/helpers.d.ts +0 -1
  270. package/graphqlFields/helpers.js +6 -18
  271. package/graphqlFields/helpers.js.map +1 -1
  272. package/graphqlFields/index.js +5 -2
  273. package/graphqlFields/index.js.map +1 -1
  274. package/graphqlFields/json.d.ts +2 -0
  275. package/graphqlFields/json.js +49 -0
  276. package/graphqlFields/json.js.map +1 -0
  277. package/graphqlFields/longText.js +14 -3
  278. package/graphqlFields/longText.js.map +1 -1
  279. package/graphqlFields/number.js +3 -1
  280. package/graphqlFields/number.js.map +1 -1
  281. package/graphqlFields/object.js +24 -44
  282. package/graphqlFields/object.js.map +1 -1
  283. package/graphqlFields/ref.js +28 -16
  284. package/graphqlFields/ref.js.map +1 -1
  285. package/graphqlFields/richText/RichTextPluginsProcessor.d.ts +6 -0
  286. package/graphqlFields/richText/RichTextPluginsProcessor.js +34 -0
  287. package/graphqlFields/richText/RichTextPluginsProcessor.js.map +1 -0
  288. package/graphqlFields/richText/richTextResolver.d.ts +7 -0
  289. package/graphqlFields/richText/richTextResolver.js +39 -0
  290. package/graphqlFields/richText/richTextResolver.js.map +1 -0
  291. package/graphqlFields/richText.js +11 -3
  292. package/graphqlFields/richText.js.map +1 -1
  293. package/graphqlFields/text.js +3 -1
  294. package/graphqlFields/text.js.map +1 -1
  295. package/htmlRenderer/LexicalRenderer.d.ts +5 -0
  296. package/htmlRenderer/LexicalRenderer.js +28 -0
  297. package/htmlRenderer/LexicalRenderer.js.map +1 -0
  298. package/htmlRenderer/createLexicalHTMLRenderer.d.ts +2 -0
  299. package/htmlRenderer/createLexicalHTMLRenderer.js +31 -0
  300. package/htmlRenderer/createLexicalHTMLRenderer.js.map +1 -0
  301. package/index.d.ts +2 -1
  302. package/index.js +20 -5
  303. package/index.js.map +1 -1
  304. package/modelManager/DefaultCmsModelManager.js +3 -5
  305. package/modelManager/DefaultCmsModelManager.js.map +1 -1
  306. package/modelManager/index.js +3 -1
  307. package/modelManager/index.js.map +1 -1
  308. package/package.json +27 -26
  309. package/parameters/context.js +4 -2
  310. package/parameters/context.js.map +1 -1
  311. package/parameters/header.js +7 -6
  312. package/parameters/header.js.map +1 -1
  313. package/parameters/index.js +3 -1
  314. package/parameters/index.js.map +1 -1
  315. package/parameters/manual.js +9 -4
  316. package/parameters/manual.js.map +1 -1
  317. package/parameters/path.js +4 -3
  318. package/parameters/path.js.map +1 -1
  319. package/plugins/CmsGraphQLSchemaPlugin.js +5 -4
  320. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -1
  321. package/plugins/CmsGraphQLSchemaSorterPlugin.js +4 -5
  322. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
  323. package/plugins/CmsGroupPlugin.d.ts +6 -3
  324. package/plugins/CmsGroupPlugin.js +8 -6
  325. package/plugins/CmsGroupPlugin.js.map +1 -1
  326. package/plugins/CmsModelFieldConverterPlugin.js +5 -4
  327. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  328. package/plugins/CmsModelPlugin.d.ts +6 -4
  329. package/plugins/CmsModelPlugin.js +56 -27
  330. package/plugins/CmsModelPlugin.js.map +1 -1
  331. package/plugins/CmsParametersPlugin.js +7 -4
  332. package/plugins/CmsParametersPlugin.js.map +1 -1
  333. package/plugins/CmsRichTextRendererPlugin.d.ts +24 -0
  334. package/plugins/CmsRichTextRendererPlugin.js +28 -0
  335. package/plugins/CmsRichTextRendererPlugin.js.map +1 -0
  336. package/plugins/StorageOperationsCmsModelPlugin.js +5 -6
  337. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -1
  338. package/plugins/StorageTransformPlugin.d.ts +2 -2
  339. package/plugins/StorageTransformPlugin.js +3 -4
  340. package/plugins/StorageTransformPlugin.js.map +1 -1
  341. package/plugins/index.d.ts +1 -0
  342. package/plugins/index.js +14 -1
  343. package/plugins/index.js.map +1 -1
  344. package/storage/default.js +3 -1
  345. package/storage/default.js.map +1 -1
  346. package/storage/index.d.ts +1 -0
  347. package/storage/index.js +15 -0
  348. package/storage/index.js.map +1 -0
  349. package/storage/json.d.ts +2 -0
  350. package/storage/json.js +27 -0
  351. package/storage/json.js.map +1 -0
  352. package/storage/object.js +8 -8
  353. package/storage/object.js.map +1 -1
  354. package/types.d.ts +300 -260
  355. package/types.js +9 -20
  356. package/types.js.map +1 -1
  357. package/utils/access.d.ts +9 -0
  358. package/utils/access.js +26 -0
  359. package/utils/access.js.map +1 -0
  360. package/utils/caching/Cache.d.ts +2 -0
  361. package/utils/caching/Cache.js +51 -0
  362. package/utils/caching/Cache.js.map +1 -0
  363. package/utils/caching/CacheKey.d.ts +2 -0
  364. package/utils/caching/CacheKey.js +40 -0
  365. package/utils/caching/CacheKey.js.map +1 -0
  366. package/utils/caching/index.d.ts +2 -0
  367. package/utils/caching/index.js +29 -0
  368. package/utils/caching/index.js.map +1 -0
  369. package/utils/caching/types.d.ts +11 -0
  370. package/utils/caching/types.js +7 -0
  371. package/utils/caching/types.js.map +1 -0
  372. package/utils/converters/Converter.js +4 -5
  373. package/utils/converters/Converter.js.map +1 -1
  374. package/utils/converters/ConverterCollection.js +13 -7
  375. package/utils/converters/ConverterCollection.js.map +1 -1
  376. package/utils/converters/valueKeyStorageConverter.js +11 -4
  377. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  378. package/utils/createTypeFromFields.js +6 -1
  379. package/utils/createTypeFromFields.js.map +1 -1
  380. package/utils/createTypeName.js +3 -1
  381. package/utils/createTypeName.js.map +1 -1
  382. package/utils/date.d.ts +10 -0
  383. package/utils/date.js +36 -0
  384. package/utils/date.js.map +1 -0
  385. package/utils/entryStorage.d.ts +4 -4
  386. package/utils/entryStorage.js +6 -4
  387. package/utils/entryStorage.js.map +1 -1
  388. package/utils/filterAsync.js +9 -8
  389. package/utils/filterAsync.js.map +1 -1
  390. package/utils/getBaseFieldType.js +3 -1
  391. package/utils/getBaseFieldType.js.map +1 -1
  392. package/utils/getEntryDescription.js +3 -1
  393. package/utils/getEntryDescription.js.map +1 -1
  394. package/utils/getEntryImage.js +3 -1
  395. package/utils/getEntryImage.js.map +1 -1
  396. package/utils/getEntryTitle.js +3 -1
  397. package/utils/getEntryTitle.js.map +1 -1
  398. package/utils/getSchemaFromFieldPlugins.d.ts +13 -2
  399. package/utils/getSchemaFromFieldPlugins.js +22 -4
  400. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  401. package/utils/identity.d.ts +2 -0
  402. package/utils/identity.js +20 -0
  403. package/utils/identity.js.map +1 -0
  404. package/utils/incrementEntryIdVersion.js +3 -1
  405. package/utils/incrementEntryIdVersion.js.map +1 -1
  406. package/utils/index.d.ts +1 -0
  407. package/utils/index.js +18 -0
  408. package/utils/index.js.map +1 -0
  409. package/utils/permissions/EntriesPermissions.js +3 -1
  410. package/utils/permissions/EntriesPermissions.js.map +1 -1
  411. package/utils/permissions/ModelGroupsPermissions.d.ts +3 -5
  412. package/utils/permissions/ModelGroupsPermissions.js +8 -6
  413. package/utils/permissions/ModelGroupsPermissions.js.map +1 -1
  414. package/utils/permissions/ModelsPermissions.d.ts +9 -7
  415. package/utils/permissions/ModelsPermissions.js +5 -6
  416. package/utils/permissions/ModelsPermissions.js.map +1 -1
  417. package/utils/renderFields.js +3 -1
  418. package/utils/renderFields.js.map +1 -1
  419. package/utils/renderGetFilterFields.js +5 -4
  420. package/utils/renderGetFilterFields.js.map +1 -1
  421. package/utils/renderInputFields.js +3 -1
  422. package/utils/renderInputFields.js.map +1 -1
  423. package/utils/renderListFilterFields.js +12 -4
  424. package/utils/renderListFilterFields.js.map +1 -1
  425. package/utils/renderSortEnum.js +5 -2
  426. package/utils/renderSortEnum.js.map +1 -1
  427. package/utils/toSlug.js +3 -1
  428. package/utils/toSlug.js.map +1 -1
  429. package/validators/dateGte.js +3 -1
  430. package/validators/dateGte.js.map +1 -1
  431. package/validators/dateLte.js +3 -1
  432. package/validators/dateLte.js.map +1 -1
  433. package/validators/gte.js +4 -3
  434. package/validators/gte.js.map +1 -1
  435. package/validators/in.js +4 -3
  436. package/validators/in.js.map +1 -1
  437. package/validators/index.js +4 -3
  438. package/validators/index.js.map +1 -1
  439. package/validators/lte.js +4 -3
  440. package/validators/lte.js.map +1 -1
  441. package/validators/maxLength.js +4 -3
  442. package/validators/maxLength.js.map +1 -1
  443. package/validators/minLength.js +4 -3
  444. package/validators/minLength.js.map +1 -1
  445. package/validators/pattern.js +5 -3
  446. package/validators/pattern.js.map +1 -1
  447. package/validators/patternPlugins/email.js +3 -1
  448. package/validators/patternPlugins/email.js.map +1 -1
  449. package/validators/patternPlugins/index.js +3 -1
  450. package/validators/patternPlugins/index.js.map +1 -1
  451. package/validators/patternPlugins/lowerCase.js +3 -1
  452. package/validators/patternPlugins/lowerCase.js.map +1 -1
  453. package/validators/patternPlugins/lowerCaseSpace.js +3 -1
  454. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
  455. package/validators/patternPlugins/upperCase.js +3 -1
  456. package/validators/patternPlugins/upperCase.js.map +1 -1
  457. package/validators/patternPlugins/upperCaseSpace.js +3 -1
  458. package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
  459. package/validators/patternPlugins/url.js +3 -1
  460. package/validators/patternPlugins/url.js.map +1 -1
  461. package/validators/required.js +3 -1
  462. package/validators/required.js.map +1 -1
  463. package/validators/timeGte.js +4 -3
  464. package/validators/timeGte.js.map +1 -1
  465. package/validators/timeLte.js +4 -3
  466. package/validators/timeLte.js.map +1 -1
  467. package/validators/unique.js +4 -2
  468. package/validators/unique.js.map +1 -1
  469. package/crud/contentModel/afterCreate.d.ts +0 -8
  470. package/crud/contentModel/afterCreate.js +0 -16
  471. package/crud/contentModel/afterCreate.js.map +0 -1
  472. package/crud/contentModel/afterCreateFrom.d.ts +0 -8
  473. package/crud/contentModel/afterCreateFrom.js +0 -16
  474. package/crud/contentModel/afterCreateFrom.js.map +0 -1
  475. package/crud/contentModel/afterDelete.d.ts +0 -8
  476. package/crud/contentModel/afterDelete.js +0 -16
  477. package/crud/contentModel/afterDelete.js.map +0 -1
  478. package/crud/contentModel/afterUpdate.d.ts +0 -8
  479. package/crud/contentModel/afterUpdate.js +0 -16
  480. package/crud/contentModel/afterUpdate.js.map +0 -1
  481. package/crud/contentModel/validateLayout.d.ts +0 -2
  482. package/crud/contentModel/validateLayout.js +0 -28
  483. package/crud/contentModel/validateLayout.js.map +0 -1
  484. package/crud/settings.crud.d.ts +0 -12
  485. package/crud/settings.crud.js +0 -62
  486. package/crud/settings.crud.js.map +0 -1
  487. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +0 -7
  488. package/graphql/schema/resolvers/commonFieldResolvers.js +0 -13
  489. package/graphql/schema/resolvers/commonFieldResolvers.js.map +0 -1
  490. package/utils/permissions/SettingsPermissions.d.ts +0 -4
  491. package/utils/permissions/SettingsPermissions.js +0 -9
  492. package/utils/permissions/SettingsPermissions.js.map +0 -1
  493. package/validators/dynamicZone.d.ts +0 -2
  494. package/validators/dynamicZone.js +0 -20
  495. package/validators/dynamicZone.js.map +0 -1
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.assignModelBeforeUpdate = void 0;
7
7
  var _validateModel = require("./validateModel");
8
- var _validateLayout = require("./validateLayout");
9
8
  var _singularApiName = require("./validate/singularApiName");
10
9
  var _pluralApiName = require("./validate/pluralApiName");
11
10
  var _endingAllowed = require("./validate/endingAllowed");
@@ -18,10 +17,6 @@ const assignModelBeforeUpdate = params => {
18
17
  model: newModel,
19
18
  original
20
19
  }) => {
21
- /**
22
- * First we go through the layout...
23
- */
24
- (0, _validateLayout.validateLayout)(newModel.layout, newModel.fields);
25
20
  const models = await context.security.withoutAuthorization(async () => {
26
21
  return (await context.cms.listModels()).filter(model => {
27
22
  return model.modelId !== newModel.modelId;
@@ -57,4 +52,6 @@ const assignModelBeforeUpdate = params => {
57
52
  });
58
53
  });
59
54
  };
60
- 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","newModel","original","validateLayout","layout","fields","models","security","withoutAuthorization","cms","listModels","filter","modelId","validateEndingAllowed","validateSingularApiName","existingModel","validatePluralApiName","validateModel"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnModelBeforeUpdateTopicParams, CmsContext } from \"~/types\";\nimport { validateModel } from \"./validateModel\";\nimport { validateLayout } from \"./validateLayout\";\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 /**\n * First we go through the layout...\n */\n validateLayout(newModel.layout, newModel.fields);\n\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;AACA;AACA;AACA;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,EAAEC,QAAQ;IAAEC;EAAS,CAAC,KAAK;IACnE;AACR;AACA;IACQ,IAAAC,8BAAc,EAACF,QAAQ,CAACG,MAAM,EAAEH,QAAQ,CAACI,MAAM,CAAC;IAEhD,MAAMC,MAAM,GAAG,MAAMR,OAAO,CAACS,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACnE,OAAO,CAAC,MAAMV,OAAO,CAACW,GAAG,CAACC,UAAU,EAAE,EAAEC,MAAM,CAACX,KAAK,IAAI;QACpD,OAAOA,KAAK,CAACY,OAAO,KAAKX,QAAQ,CAACW,OAAO;MAC7C,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,IAAAC,oCAAqB,EAAC;MAClBb,KAAK,EAAEC;IACX,CAAC,CAAC;IACF;AACR;AACA;AACA;AACA;AACA;IACQ,KAAK,MAAMD,KAAK,IAAIM,MAAM,EAAE;MACxB,IAAAQ,wCAAuB,EAAC;QACpBC,aAAa,EAAEf,KAAK;QACpBA,KAAK,EAAEC;MACX,CAAC,CAAC;MACF,IAAAe,oCAAqB,EAAC;QAClBD,aAAa,EAAEf,KAAK;QACpBA,KAAK,EAAEC;MACX,CAAC,CAAC;IACN;IACA;AACR;AACA;IACQ,MAAM,IAAAgB,4BAAa,EAAC;MAChBX,MAAM;MACNN,KAAK,EAAEC,QAAQ;MACfC,QAAQ;MACRJ;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"}
@@ -21,4 +21,6 @@ const ensurePluralApiName = model => {
21
21
  }
22
22
  return model.pluralApiName;
23
23
  };
24
- exports.ensurePluralApiName = ensurePluralApiName;
24
+ exports.ensurePluralApiName = ensurePluralApiName;
25
+
26
+ //# sourceMappingURL=modelApiName.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ensureSingularApiName","model","singularApiName","upperFirst","camelCase","modelId","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;AACA;AACA;AAGO,MAAMA,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;AAAC;AAEK,MAAMI,mBAAmB,GAAIL,KAAe,IAAa;EAC5D,IAAI,CAACA,KAAK,CAACM,aAAa,EAAE;IACtB,OAAO,IAAAC,kBAAS,EAACR,qBAAqB,CAACC,KAAK,CAAC,CAAC;EAClD;EACA,OAAOA,KAAK,CAACM,aAAa;AAC9B,CAAC;AAAC"}
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"}
@@ -55,4 +55,6 @@ const assignModelDefaultFields = model => {
55
55
  model.fields = createDefaultFields();
56
56
  model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];
57
57
  };
58
- exports.assignModelDefaultFields = assignModelDefaultFields;
58
+ exports.assignModelDefaultFields = assignModelDefaultFields;
59
+
60
+ //# sourceMappingURL=defaultFields.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createDefaultFields","id","generateAlphaNumericLowerCaseId","fieldId","type","label","validation","name","message","listValidation","renderer","settings","imagesOnly","assignModelDefaultFields","model","fields","length","layout"],"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;AAEA,MAAMA,mBAAmB,GAAG,MAA4B;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,EAAE;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;AAAC"}
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"}
@@ -21,7 +21,7 @@ const getContentModelDescriptionFieldId = (fields, descriptionFieldId) => {
21
21
  const descriptionField = fields.find(field => {
22
22
  return (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text" && !field.multipleValues;
23
23
  });
24
- return (descriptionField === null || descriptionField === void 0 ? void 0 : descriptionField.fieldId) || null;
24
+ return descriptionField?.fieldId || null;
25
25
  }
26
26
  const target = fields.find(field => field.fieldId === descriptionFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text");
27
27
  if (!target) {
@@ -39,4 +39,6 @@ const getContentModelDescriptionFieldId = (fields, descriptionFieldId) => {
39
39
  }
40
40
  return target.fieldId;
41
41
  };
42
- exports.getContentModelDescriptionFieldId = getContentModelDescriptionFieldId;
42
+ exports.getContentModelDescriptionFieldId = getContentModelDescriptionFieldId;
43
+
44
+ //# sourceMappingURL=descriptionField.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getContentModelDescriptionFieldId","fields","descriptionFieldId","length","descriptionField","find","field","getBaseFieldType","multipleValues","fieldId","target","WebinyError","storageId","type"],"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;AACA;AAEO,MAAMA,iCAAiC,GAAG,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,OAAO,CAAAJ,gBAAgB,aAAhBA,gBAAgB,uBAAhBA,gBAAgB,CAAEK,OAAO,KAAI,IAAI;EAC5C;EACA,MAAMC,MAAM,GAAGT,MAAM,CAACI,IAAI,CACtBC,KAAK,IAAIA,KAAK,CAACG,OAAO,KAAKP,kBAAkB,IAAI,IAAAK,kCAAgB,EAACD,KAAK,CAAC,KAAK,WAAW,CAC3F;EACD,IAAI,CAACI,MAAM,EAAE;IACT,MAAM,IAAIC,cAAW,CAChB,uEAAsE,EACvE,kBAAkB,EAClB;MACIF,OAAO,EAAEP,kBAAkB;MAC3BD;IACJ,CAAC,CACJ;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,CAAC,CACJ;EACL;EAEA,OAAOH,MAAM,CAACD,OAAO;AACzB,CAAC;AAAC"}
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"}
@@ -19,15 +19,11 @@ const getContentModelImageFieldId = (fields, imageFieldId) => {
19
19
  */
20
20
  if (!imageFieldId) {
21
21
  const imageField = fields.find(field => {
22
- var _field$settings;
23
- return (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && !field.multipleValues && ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.imagesOnly);
22
+ return (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && !field.multipleValues && field.settings?.imagesOnly;
24
23
  });
25
- return (imageField === null || imageField === void 0 ? void 0 : imageField.fieldId) || null;
24
+ return imageField?.fieldId || null;
26
25
  }
27
- const target = fields.find(field => {
28
- var _field$settings2;
29
- return field.fieldId === imageFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && ((_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.imagesOnly);
30
- });
26
+ const target = fields.find(field => field.fieldId === imageFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && field.settings?.imagesOnly);
31
27
  if (!target) {
32
28
  throw new _error.default(`Field selected for the image field does not exist in the model.`, "VALIDATION_ERROR", {
33
29
  fieldId: imageFieldId,
@@ -43,4 +39,6 @@ const getContentModelImageFieldId = (fields, imageFieldId) => {
43
39
  }
44
40
  return target.fieldId;
45
41
  };
46
- exports.getContentModelImageFieldId = getContentModelImageFieldId;
42
+ exports.getContentModelImageFieldId = getContentModelImageFieldId;
43
+
44
+ //# sourceMappingURL=imageField.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getContentModelImageFieldId","fields","imageFieldId","length","imageField","find","field","getBaseFieldType","multipleValues","settings","imagesOnly","fieldId","target","WebinyError","storageId","type"],"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;AACA;AAEO,MAAMA,2BAA2B,GAAG,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;MAAA;MACpC,OACI,IAAAC,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,IAClC,CAACA,KAAK,CAACE,cAAc,wBACrBF,KAAK,CAACG,QAAQ,oDAAd,gBAAgBC,UAAU;IAElC,CAAC,CAAC;IACF,OAAO,CAAAN,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,OAAO,KAAI,IAAI;EACtC;EACA,MAAMC,MAAM,GAAGX,MAAM,CAACI,IAAI,CACtBC,KAAK;IAAA;IAAA,OACDA,KAAK,CAACK,OAAO,KAAKT,YAAY,IAC9B,IAAAK,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,yBAClCA,KAAK,CAACG,QAAQ,qDAAd,iBAAgBC,UAAU;EAAA,EACjC;EACD,IAAI,CAACE,MAAM,EAAE;IACT,MAAM,IAAIC,cAAW,CAChB,iEAAgE,EACjE,kBAAkB,EAClB;MACIF,OAAO,EAAET,YAAY;MACrBD;IACJ,CAAC,CACJ;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,CAAC,CACJ;EACL;EAEA,OAAOH,MAAM,CAACD,OAAO;AACzB,CAAC;AAAC"}
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"}
@@ -25,7 +25,7 @@ const getContentModelTitleFieldId = (fields, titleFieldId) => {
25
25
  const titleField = fields.find(field => {
26
26
  return (0, _getBaseFieldType.getBaseFieldType)(field) === "text" && !field.multipleValues;
27
27
  });
28
- return (titleField === null || titleField === void 0 ? void 0 : titleField.fieldId) || defaultTitleFieldId;
28
+ return titleField?.fieldId || defaultTitleFieldId;
29
29
  }
30
30
  /**
31
31
  * check existing titleFieldId for existence in the model
@@ -55,4 +55,6 @@ const getContentModelTitleFieldId = (fields, titleFieldId) => {
55
55
  }
56
56
  return target.fieldId;
57
57
  };
58
- exports.getContentModelTitleFieldId = getContentModelTitleFieldId;
58
+ exports.getContentModelTitleFieldId = getContentModelTitleFieldId;
59
+
60
+ //# sourceMappingURL=titleField.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defaultTitleFieldId","allowedTitleFieldTypes","getContentModelTitleFieldId","fields","titleFieldId","length","titleField","find","field","getBaseFieldType","multipleValues","fieldId","target","f","WebinyError","includes","type","join","storageId"],"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;AACA;AAEA,MAAMA,mBAAmB,GAAG,IAAI;AAEhC,MAAMC,sBAAsB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;AAE1C,MAAMC,2BAA2B,GAAG,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,OAAO,CAAAJ,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEK,OAAO,KAAIX,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,CAAC,CACJ;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,IAAI,CACN,+CAA8C,EAChD,wBAAwB,EACxB;MACIC,SAAS,EAAEN,MAAM,CAACM,SAAS;MAC3BP,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBK,IAAI,EAAEJ,MAAM,CAACI;IACjB,CAAC,CACJ;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,CAAC,CACJ;EACL;EAEA,OAAOJ,MAAM,CAACD,OAAO;AACzB,CAAC;AAAC"}
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 {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.listModelsFromDatabase = void 0;
7
+ var _modelApiName = require("./compatibility/modelApiName");
8
+ var _ensureTypeTag = require("./ensureTypeTag");
9
+ const listModelsFromDatabase = async params => {
10
+ const {
11
+ storageOperations,
12
+ getTenant,
13
+ getLocale
14
+ } = params;
15
+ const models = await storageOperations.models.list({
16
+ where: {
17
+ tenant: getTenant().id,
18
+ locale: getLocale().code
19
+ }
20
+ });
21
+ return models.map(model => {
22
+ return {
23
+ ...model,
24
+ tags: (0, _ensureTypeTag.ensureTypeTag)(model),
25
+ tenant: model.tenant || getTenant().id,
26
+ locale: model.locale || getLocale().code,
27
+ /**
28
+ * TODO: remove in v5.36.0
29
+ * This is for backward compatibility while migrations are not yet executed.
30
+ */
31
+ singularApiName: (0, _modelApiName.ensureSingularApiName)(model),
32
+ pluralApiName: (0, _modelApiName.ensurePluralApiName)(model)
33
+ };
34
+ });
35
+ };
36
+ exports.listModelsFromDatabase = listModelsFromDatabase;
37
+
38
+ //# sourceMappingURL=listModelsFromDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_modelApiName","require","_ensureTypeTag","listModelsFromDatabase","params","storageOperations","getTenant","getLocale","models","list","where","tenant","id","locale","code","map","model","tags","ensureTypeTag","singularApiName","ensureSingularApiName","pluralApiName","ensurePluralApiName","exports"],"sources":["listModelsFromDatabase.ts"],"sourcesContent":["import { CmsModel, HeadlessCmsStorageOperations } from \"~/types\";\nimport {\n ensurePluralApiName,\n ensureSingularApiName\n} from \"~/crud/contentModel/compatibility/modelApiName\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { ensureTypeTag } from \"./ensureTypeTag\";\n\ninterface Params {\n storageOperations: HeadlessCmsStorageOperations;\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n}\n\nexport const listModelsFromDatabase = async (params: Params): Promise<CmsModel[]> => {\n const { storageOperations, getTenant, getLocale } = params;\n const models = await storageOperations.models.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n return models.map(model => {\n return {\n ...model,\n tags: ensureTypeTag(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code,\n /**\n * TODO: remove in v5.36.0\n * This is for backward compatibility while migrations are not yet executed.\n */\n singularApiName: ensureSingularApiName(model),\n pluralApiName: ensurePluralApiName(model)\n };\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAMA,IAAAC,cAAA,GAAAD,OAAA;AAQO,MAAME,sBAAsB,GAAG,MAAOC,MAAc,IAA0B;EACjF,MAAM;IAAEC,iBAAiB;IAAEC,SAAS;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAC1D,MAAMI,MAAM,GAAG,MAAMH,iBAAiB,CAACG,MAAM,CAACC,IAAI,CAAC;IAC/CC,KAAK,EAAE;MACHC,MAAM,EAAEL,SAAS,CAAC,CAAC,CAACM,EAAE;MACtBC,MAAM,EAAEN,SAAS,CAAC,CAAC,CAACO;IACxB;EACJ,CAAC,CAAC;EACF,OAAON,MAAM,CAACO,GAAG,CAACC,KAAK,IAAI;IACvB,OAAO;MACH,GAAGA,KAAK;MACRC,IAAI,EAAE,IAAAC,4BAAa,EAACF,KAAK,CAAC;MAC1BL,MAAM,EAAEK,KAAK,CAACL,MAAM,IAAIL,SAAS,CAAC,CAAC,CAACM,EAAE;MACtCC,MAAM,EAAEG,KAAK,CAACH,MAAM,IAAIN,SAAS,CAAC,CAAC,CAACO,IAAI;MACxC;AACZ;AACA;AACA;MACYK,eAAe,EAAE,IAAAC,mCAAqB,EAACJ,KAAK,CAAC;MAC7CK,aAAa,EAAE,IAAAC,iCAAmB,EAACN,KAAK;IAC5C,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAApB,sBAAA,GAAAA,sBAAA"}
@@ -23,4 +23,6 @@ const validateEndingAllowed = params => {
23
23
  });
24
24
  }
25
25
  };
26
- exports.validateEndingAllowed = validateEndingAllowed;
26
+ exports.validateEndingAllowed = validateEndingAllowed;
27
+
28
+ //# sourceMappingURL=endingAllowed.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["validateEndingAllowed","params","model","isModelEndingAllowed","singularApiName","WebinyError","input","disallowedEnding","pluralApiName"],"sources":["endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAOO,MAAMA,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAI,IAAAE,0CAAoB,EAACD,KAAK,CAACE,eAAe,CAAC,KAAK,KAAK,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,eAAgB,mDAAkD,EAC/G,4CAA4C,EAC5C;MACIE,KAAK,EAAEJ,KAAK,CAACE,eAAe;MAC5BG,gBAAgB,EAAhBA;IACJ,CAAC,CACJ;EACL,CAAC,MAAM,IAAI,IAAAJ,0CAAoB,EAACD,KAAK,CAACM,aAAa,CAAC,KAAK,KAAK,EAAE;IAC5D,MAAM,IAAIH,cAAW,CAChB,qCAAoCH,KAAK,CAACM,aAAc,mDAAkD,EAC3G,0CAA0C,EAC1C;MACIF,KAAK,EAAEJ,KAAK,CAACM,aAAa;MAC1BD,gBAAgB,EAAEA;IACtB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_isModelEndingAllowed","validateEndingAllowed","params","model","isModelEndingAllowed","singularApiName","WebinyError","input","disallowedEnding","pluralApiName","exports"],"sources":["endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAOO,MAAME,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAI,IAAAE,0CAAoB,EAACD,KAAK,CAACE,eAAe,CAAC,KAAK,KAAK,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,eAAgB,mDAAkD,EAC/G,4CAA4C,EAC5C;MACIE,KAAK,EAAEJ,KAAK,CAACE,eAAe;MAC5BG,gBAAgB,EAAhBA;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAI,IAAAJ,0CAAoB,EAACD,KAAK,CAACM,aAAa,CAAC,KAAK,KAAK,EAAE;IAC5D,MAAM,IAAIH,cAAW,CAChB,qCAAoCH,KAAK,CAACM,aAAc,mDAAkD,EAC3G,0CAA0C,EAC1C;MACIF,KAAK,EAAEJ,KAAK,CAACM,aAAa;MAC1BD,gBAAgB,EAAEA;IACtB,CACJ,CAAC;EACL;AACJ,CAAC;AAACE,OAAA,CAAAT,qBAAA,GAAAA,qBAAA"}
@@ -12,7 +12,7 @@ const disallowedEnding = ["Response", "List", "Meta", "Input", "Sorter", "RefTyp
12
12
  exports.disallowedEnding = disallowedEnding;
13
13
  const isModelEndingAllowed = apiName => {
14
14
  for (const ending of disallowedEnding) {
15
- const re = new RegExp(`${ending}$`, "i");
15
+ const re = new RegExp(`${ending}$`);
16
16
  const matched = apiName.match(re);
17
17
  if (matched === null) {
18
18
  continue;
@@ -21,4 +21,6 @@ const isModelEndingAllowed = apiName => {
21
21
  }
22
22
  return true;
23
23
  };
24
- exports.isModelEndingAllowed = isModelEndingAllowed;
24
+ exports.isModelEndingAllowed = isModelEndingAllowed;
25
+
26
+ //# sourceMappingURL=isModelEndingAllowed.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["disallowedEnding","isModelEndingAllowed","apiName","ending","re","RegExp","matched","match"],"sources":["isModelEndingAllowed.ts"],"sourcesContent":["/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nexport const disallowedEnding: string[] = [\n \"Response\",\n \"List\",\n \"Meta\",\n \"Input\",\n \"Sorter\",\n \"RefType\"\n];\n\nexport const isModelEndingAllowed = (apiName: string): boolean => {\n for (const ending of disallowedEnding) {\n const re = new RegExp(`${ending}$`, \"i\");\n const matched = apiName.match(re);\n if (matched === null) {\n continue;\n }\n return false;\n }\n return true;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,gBAA0B,GAAG,CACtC,UAAU,EACV,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,CACZ;AAAC;AAEK,MAAMC,oBAAoB,GAAIC,OAAe,IAAc;EAC9D,KAAK,MAAMC,MAAM,IAAIH,gBAAgB,EAAE;IACnC,MAAMI,EAAE,GAAG,IAAIC,MAAM,CAAE,GAAEF,MAAO,GAAE,EAAE,GAAG,CAAC;IACxC,MAAMG,OAAO,GAAGJ,OAAO,CAACK,KAAK,CAACH,EAAE,CAAC;IACjC,IAAIE,OAAO,KAAK,IAAI,EAAE;MAClB;IACJ;IACA,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAAC"}
1
+ {"version":3,"names":["disallowedEnding","exports","isModelEndingAllowed","apiName","ending","re","RegExp","matched","match"],"sources":["isModelEndingAllowed.ts"],"sourcesContent":["/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nexport const disallowedEnding: string[] = [\n \"Response\",\n \"List\",\n \"Meta\",\n \"Input\",\n \"Sorter\",\n \"RefType\"\n];\n\nexport const isModelEndingAllowed = (apiName: string): boolean => {\n for (const ending of disallowedEnding) {\n const re = new RegExp(`${ending}$`);\n const matched = apiName.match(re);\n if (matched === null) {\n continue;\n }\n return false;\n }\n return true;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,gBAA0B,GAAG,CACtC,UAAU,EACV,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,CACZ;AAACC,OAAA,CAAAD,gBAAA,GAAAA,gBAAA;AAEK,MAAME,oBAAoB,GAAIC,OAAe,IAAc;EAC9D,KAAK,MAAMC,MAAM,IAAIJ,gBAAgB,EAAE;IACnC,MAAMK,EAAE,GAAG,IAAIC,MAAM,CAAE,GAAEF,MAAO,GAAE,CAAC;IACnC,MAAMG,OAAO,GAAGJ,OAAO,CAACK,KAAK,CAACH,EAAE,CAAC;IACjC,IAAIE,OAAO,KAAK,IAAI,EAAE;MAClB;IACJ;IACA,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAACN,OAAA,CAAAC,oBAAA,GAAAA,oBAAA"}
@@ -33,4 +33,6 @@ const validateExistingModelId = params => {
33
33
  });
34
34
  }
35
35
  };
36
- exports.validateExistingModelId = validateExistingModelId;
36
+ exports.validateExistingModelId = validateExistingModelId;
37
+
38
+ //# sourceMappingURL=modelId.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["disallowedModelIdList","isModelIdAllowed","modelId","includes","validateModelIdAllowed","params","model","WebinyError","input","validateExistingModelId","existingModel"],"sources":["modelId.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\nconst disallowedModelIdList: string[] = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\nconst isModelIdAllowed = (modelId: string): boolean => {\n return disallowedModelIdList.includes(modelId) === false;\n};\n\ninterface ModelIdAllowedParams {\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateModelIdAllowed = (params: ModelIdAllowedParams) => {\n const { model } = params;\n if (isModelIdAllowed(model.modelId)) {\n return;\n }\n throw new WebinyError(\n `Provided model ID \"${model.modelId}\" is not allowed.`,\n \"MODEL_ID_NOT_ALLOWED\",\n {\n input: model.modelId\n }\n );\n};\n\ninterface Params {\n existingModel: Pick<CmsModel, \"modelId\">;\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateExistingModelId = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.modelId === model.modelId) {\n throw new WebinyError(\n `Content model with modelId \"${model.modelId}\" already exists.`,\n \"MODEL_ID_EXISTS\",\n {\n input: existingModel.modelId\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAGA,MAAMA,qBAA+B,GAAG,CACpC,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,oBAAoB,CACvB;AACD,MAAMC,gBAAgB,GAAIC,OAAe,IAAc;EACnD,OAAOF,qBAAqB,CAACG,QAAQ,CAACD,OAAO,CAAC,KAAK,KAAK;AAC5D,CAAC;AAMM,MAAME,sBAAsB,GAAIC,MAA4B,IAAK;EACpE,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAIJ,gBAAgB,CAACK,KAAK,CAACJ,OAAO,CAAC,EAAE;IACjC;EACJ;EACA,MAAM,IAAIK,cAAW,CAChB,sBAAqBD,KAAK,CAACJ,OAAQ,mBAAkB,EACtD,sBAAsB,EACtB;IACIM,KAAK,EAAEF,KAAK,CAACJ;EACjB,CAAC,CACJ;AACL,CAAC;AAAC;AAOK,MAAMO,uBAAuB,GAAIJ,MAAc,IAAW;EAC7D,MAAM;IAAEK,aAAa;IAAEJ;EAAM,CAAC,GAAGD,MAAM;EAEvC,IAAIK,aAAa,CAACR,OAAO,KAAKI,KAAK,CAACJ,OAAO,EAAE;IACzC,MAAM,IAAIK,cAAW,CAChB,+BAA8BD,KAAK,CAACJ,OAAQ,mBAAkB,EAC/D,iBAAiB,EACjB;MACIM,KAAK,EAAEE,aAAa,CAACR;IACzB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","disallowedModelIdList","isModelIdAllowed","modelId","includes","validateModelIdAllowed","params","model","WebinyError","input","exports","validateExistingModelId","existingModel"],"sources":["modelId.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\nconst disallowedModelIdList: string[] = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\nconst isModelIdAllowed = (modelId: string): boolean => {\n return disallowedModelIdList.includes(modelId) === false;\n};\n\ninterface ModelIdAllowedParams {\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateModelIdAllowed = (params: ModelIdAllowedParams) => {\n const { model } = params;\n if (isModelIdAllowed(model.modelId)) {\n return;\n }\n throw new WebinyError(\n `Provided model ID \"${model.modelId}\" is not allowed.`,\n \"MODEL_ID_NOT_ALLOWED\",\n {\n input: model.modelId\n }\n );\n};\n\ninterface Params {\n existingModel: Pick<CmsModel, \"modelId\">;\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateExistingModelId = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.modelId === model.modelId) {\n throw new WebinyError(\n `Content model with modelId \"${model.modelId}\" already exists.`,\n \"MODEL_ID_EXISTS\",\n {\n input: existingModel.modelId\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,MAAMC,qBAA+B,GAAG,CACpC,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,oBAAoB,CACvB;AACD,MAAMC,gBAAgB,GAAIC,OAAe,IAAc;EACnD,OAAOF,qBAAqB,CAACG,QAAQ,CAACD,OAAO,CAAC,KAAK,KAAK;AAC5D,CAAC;AAMM,MAAME,sBAAsB,GAAIC,MAA4B,IAAK;EACpE,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAIJ,gBAAgB,CAACK,KAAK,CAACJ,OAAO,CAAC,EAAE;IACjC;EACJ;EACA,MAAM,IAAIK,cAAW,CAChB,sBAAqBD,KAAK,CAACJ,OAAQ,mBAAkB,EACtD,sBAAsB,EACtB;IACIM,KAAK,EAAEF,KAAK,CAACJ;EACjB,CACJ,CAAC;AACL,CAAC;AAACO,OAAA,CAAAL,sBAAA,GAAAA,sBAAA;AAOK,MAAMM,uBAAuB,GAAIL,MAAc,IAAW;EAC7D,MAAM;IAAEM,aAAa;IAAEL;EAAM,CAAC,GAAGD,MAAM;EAEvC,IAAIM,aAAa,CAACT,OAAO,KAAKI,KAAK,CAACJ,OAAO,EAAE;IACzC,MAAM,IAAIK,cAAW,CAChB,+BAA8BD,KAAK,CAACJ,OAAQ,mBAAkB,EAC/D,iBAAiB,EACjB;MACIM,KAAK,EAAEG,aAAa,CAACT;IACzB,CACJ,CAAC;EACL;AACJ,CAAC;AAACO,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
@@ -21,4 +21,6 @@ const validatePluralApiName = params => {
21
21
  });
22
22
  }
23
23
  };
24
- exports.validatePluralApiName = validatePluralApiName;
24
+ exports.validatePluralApiName = validatePluralApiName;
25
+
26
+ //# sourceMappingURL=pluralApiName.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["validatePluralApiName","params","existingModel","model","singularApiName","pluralApiName","WebinyError","input"],"sources":["pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAQO,MAAMA,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACE,aAAa,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,aAAc,mBAAkB,EAC7E,gCAAgC,EAChC;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CAAC,CACJ;EACL,CAAC,MAAM,IAAIH,aAAa,CAACG,aAAa,KAAKF,KAAK,CAACE,aAAa,EAAE;IAC5D,MAAM,IAAIC,cAAW,CAChB,qCAAoCH,KAAK,CAACE,aAAc,mBAAkB,EAC3E,8BAA8B,EAC9B;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","validatePluralApiName","params","existingModel","model","singularApiName","pluralApiName","WebinyError","input","exports"],"sources":["pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAQO,MAAMC,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACE,aAAa,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,aAAc,mBAAkB,EAC7E,gCAAgC,EAChC;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CACJ,CAAC;EACL,CAAC,MAAM,IAAIH,aAAa,CAACG,aAAa,KAAKF,KAAK,CAACE,aAAa,EAAE;IAC5D,MAAM,IAAIC,cAAW,CAChB,qCAAoCH,KAAK,CAACE,aAAc,mBAAkB,EAC3E,8BAA8B,EAC9B;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAACG,OAAA,CAAAR,qBAAA,GAAAA,qBAAA"}
@@ -21,4 +21,6 @@ const validateSingularApiName = params => {
21
21
  });
22
22
  }
23
23
  };
24
- exports.validateSingularApiName = validateSingularApiName;
24
+ exports.validateSingularApiName = validateSingularApiName;
25
+
26
+ //# sourceMappingURL=singularApiName.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["validateSingularApiName","params","existingModel","model","singularApiName","WebinyError","input","pluralApiName"],"sources":["singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateSingularApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n } else if (existingModel.pluralApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAQO,MAAMA,uBAAuB,GAAIC,MAAc,IAAW;EAC7D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACC,eAAe,EAAE;IACzD,MAAM,IAAIC,cAAW,CAChB,uCAAsCF,KAAK,CAACC,eAAgB,mBAAkB,EAC/E,gCAAgC,EAChC;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CAAC,CACJ;EACL,CAAC,MAAM,IAAIF,aAAa,CAACK,aAAa,KAAKJ,KAAK,CAACC,eAAe,EAAE;IAC9D,MAAM,IAAIC,cAAW,CAChB,qCAAoCF,KAAK,CAACC,eAAgB,mBAAkB,EAC7E,8BAA8B,EAC9B;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","validateSingularApiName","params","existingModel","model","singularApiName","WebinyError","input","pluralApiName","exports"],"sources":["singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateSingularApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n } else if (existingModel.pluralApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAQO,MAAMC,uBAAuB,GAAIC,MAAc,IAAW;EAC7D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACC,eAAe,EAAE;IACzD,MAAM,IAAIC,cAAW,CAChB,uCAAsCF,KAAK,CAACC,eAAgB,mBAAkB,EAC/E,gCAAgC,EAChC;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CACJ,CAAC;EACL,CAAC,MAAM,IAAIF,aAAa,CAACK,aAAa,KAAKJ,KAAK,CAACC,eAAe,EAAE;IAC9D,MAAM,IAAIC,cAAW,CAChB,qCAAoCF,KAAK,CAACC,eAAgB,mBAAkB,EAC7E,8BAA8B,EAC9B;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAACI,OAAA,CAAAR,uBAAA,GAAAA,uBAAA"}
@@ -24,4 +24,6 @@ const validateModel = async params => {
24
24
  }
25
25
  await (0, _validateModelFields.validateModelFields)(params);
26
26
  };
27
- exports.validateModel = validateModel;
27
+ exports.validateModel = validateModel;
28
+
29
+ //# sourceMappingURL=validateModel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["validateModel","params","model","context","plugins","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","validateModelFields"],"sources":["validateModel.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { CmsContext, CmsModel } from \"~/types\";\nimport { validateModelFields } from \"~/crud/contentModel/validateModelFields\";\n\ninterface ValidateModelParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModel = async (params: ValidateModelParams): Promise<void> => {\n const { model, context } = params;\n\n const { plugins } = context;\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 updated.\",\n \"CONTENT_MODEL_UPDATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n await validateModelFields(params);\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AASO,MAAMA,aAAa,GAAG,MAAOC,MAA2B,IAAoB;EAC/E,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEjC,MAAM;IAAEG;EAAQ,CAAC,GAAGD,OAAO;EAE3B,MAAME,WAAW,GAAGD,OAAO,CACtBE,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,YAAY,CAACC,OAAO,KAAKV,KAAK,CAACU,OAAO,CAAC;EAE9D,IAAIP,WAAW,EAAE;IACb,MAAM,IAAIQ,cAAW,CACjB,uDAAuD,EACvD,4BAA4B,EAC5B;MACID,OAAO,EAAEV,KAAK,CAACU;IACnB,CAAC,CACJ;EACL;EAEA,MAAM,IAAAE,wCAAmB,EAACb,MAAM,CAAC;AACrC,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_CmsModelPlugin","_validateModelFields","validateModel","params","model","context","plugins","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","validateModelFields","exports"],"sources":["validateModel.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { CmsContext, CmsModel } from \"~/types\";\nimport { validateModelFields } from \"./validateModelFields\";\n\ninterface ValidateModelParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModel = async (params: ValidateModelParams): Promise<void> => {\n const { model, context } = params;\n\n const { plugins } = context;\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 updated.\",\n \"CONTENT_MODEL_UPDATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n await validateModelFields(params);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,oBAAA,GAAAF,OAAA;AASO,MAAMG,aAAa,GAAG,MAAOC,MAA2B,IAAoB;EAC/E,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEjC,MAAM;IAAEG;EAAQ,CAAC,GAAGD,OAAO;EAE3B,MAAME,WAAW,GAAGD,OAAO,CACtBE,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,YAAY,CAACC,OAAO,KAAKV,KAAK,CAACU,OAAO,CAAC;EAE9D,IAAIP,WAAW,EAAE;IACb,MAAM,IAAIQ,cAAW,CACjB,uDAAuD,EACvD,4BAA4B,EAC5B;MACID,OAAO,EAAEV,KAAK,CAACU;IACnB,CACJ,CAAC;EACL;EAEA,MAAM,IAAAE,wCAAmB,EAACb,MAAM,CAAC;AACrC,CAAC;AAACc,OAAA,CAAAf,aAAA,GAAAA,aAAA"}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.validateModelFields = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
8
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
10
9
  var _error = _interopRequireDefault(require("@webiny/error"));
11
10
  var _createManageSDL = require("../../graphql/schema/createManageSDL");
@@ -19,8 +18,7 @@ var _buildSchemaPlugins = require("../../graphql/buildSchemaPlugins");
19
18
  var _createExecutableSchema = require("../../graphql/createExecutableSchema");
20
19
  var _utils = require("@webiny/utils");
21
20
  const extractInvalidField = (model, err) => {
22
- var _err$source;
23
- const sdl = ((_err$source = err.source) === null || _err$source === void 0 ? void 0 : _err$source.body) || "";
21
+ const sdl = err.source?.body || "";
24
22
 
25
23
  /**
26
24
  * Find the invalid type
@@ -249,7 +247,7 @@ const validateModelFields = async params => {
249
247
  const fieldTypePlugins = plugins.byType("cms-model-field-to-graphql");
250
248
  validateFields({
251
249
  fields,
252
- originalFields: (original === null || original === void 0 ? void 0 : original.fields) || [],
250
+ originalFields: original?.fields || [],
253
251
  lockedFields,
254
252
  plugins: fieldTypePlugins
255
253
  });
@@ -261,7 +259,8 @@ const validateModelFields = async params => {
261
259
  const schema = (0, _createManageSDL.createManageSDL)({
262
260
  models,
263
261
  model,
264
- fieldTypePlugins: fieldTypePlugins.reduce((acc, pl) => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, acc), {}, {
262
+ fieldTypePlugins: fieldTypePlugins.reduce((acc, pl) => ({
263
+ ...acc,
265
264
  [pl.fieldType]: pl
266
265
  }), {}),
267
266
  sorterPlugins
@@ -339,4 +338,6 @@ const validateModelFields = async params => {
339
338
  }
340
339
  }
341
340
  };
342
- exports.validateModelFields = validateModelFields;
341
+ exports.validateModelFields = validateModelFields;
342
+
343
+ //# sourceMappingURL=validateModelFields.js.map