@webiny/api-headless-cms 5.34.8 → 5.35.0-beta.0

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 (374) hide show
  1. package/context.js +47 -68
  2. package/context.js.map +1 -1
  3. package/crud/contentEntry/afterDelete.js +0 -5
  4. package/crud/contentEntry/afterDelete.js.map +1 -1
  5. package/crud/contentEntry/beforeCreate.js +0 -3
  6. package/crud/contentEntry/beforeCreate.js.map +1 -1
  7. package/crud/contentEntry/beforeUpdate.js +0 -3
  8. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  9. package/crud/contentEntry/entryDataValidation.js +1 -40
  10. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  11. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  12. package/crud/contentEntry/markLockedFields.js +5 -26
  13. package/crud/contentEntry/markLockedFields.js.map +1 -1
  14. package/crud/contentEntry/referenceFieldsMapping.js +39 -66
  15. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  16. package/crud/contentEntry/searchableFields.js +1 -12
  17. package/crud/contentEntry/searchableFields.js.map +1 -1
  18. package/crud/contentEntry.crud.d.ts +5 -2
  19. package/crud/contentEntry.crud.js +859 -941
  20. package/crud/contentEntry.crud.js.map +1 -1
  21. package/crud/contentModel/afterCreate.js +0 -2
  22. package/crud/contentModel/afterCreate.js.map +1 -1
  23. package/crud/contentModel/afterCreateFrom.js +0 -2
  24. package/crud/contentModel/afterCreateFrom.js.map +1 -1
  25. package/crud/contentModel/afterDelete.js +0 -2
  26. package/crud/contentModel/afterDelete.js.map +1 -1
  27. package/crud/contentModel/afterUpdate.js +0 -2
  28. package/crud/contentModel/afterUpdate.js.map +1 -1
  29. package/crud/contentModel/beforeCreate.js +39 -105
  30. package/crud/contentModel/beforeCreate.js.map +1 -1
  31. package/crud/contentModel/beforeDelete.d.ts +1 -1
  32. package/crud/contentModel/beforeDelete.js +1 -15
  33. package/crud/contentModel/beforeDelete.js.map +1 -1
  34. package/crud/contentModel/beforeUpdate.js +31 -8
  35. package/crud/contentModel/beforeUpdate.js.map +1 -1
  36. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  37. package/crud/contentModel/compatibility/modelApiName.js +24 -0
  38. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  39. package/crud/contentModel/contentModelManagerFactory.js +0 -7
  40. package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
  41. package/crud/contentModel/createFieldStorageId.js +0 -3
  42. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  43. package/crud/contentModel/defaultFields.d.ts +5 -0
  44. package/crud/contentModel/defaultFields.js +58 -0
  45. package/crud/contentModel/defaultFields.js.map +1 -0
  46. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  47. package/crud/contentModel/fields/descriptionField.js +42 -0
  48. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  49. package/crud/contentModel/fields/imageField.d.ts +2 -0
  50. package/crud/contentModel/fields/imageField.js +46 -0
  51. package/crud/contentModel/fields/imageField.js.map +1 -0
  52. package/crud/contentModel/fields/titleField.d.ts +2 -0
  53. package/crud/contentModel/fields/titleField.js +58 -0
  54. package/crud/contentModel/fields/titleField.js.map +1 -0
  55. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  56. package/crud/contentModel/validate/endingAllowed.js +26 -0
  57. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  58. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  59. package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
  60. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  61. package/crud/contentModel/validate/modelId.d.ts +11 -0
  62. package/crud/contentModel/validate/modelId.js +36 -0
  63. package/crud/contentModel/validate/modelId.js.map +1 -0
  64. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  65. package/crud/contentModel/validate/pluralApiName.js +24 -0
  66. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  67. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  68. package/crud/contentModel/validate/singularApiName.js +24 -0
  69. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  70. package/crud/contentModel/validateLayout.js +0 -8
  71. package/crud/contentModel/validateLayout.js.map +1 -1
  72. package/crud/contentModel/validateModel.d.ts +1 -0
  73. package/crud/contentModel/validateModel.js +0 -8
  74. package/crud/contentModel/validateModel.js.map +1 -1
  75. package/crud/contentModel/validateModelFields.d.ts +2 -1
  76. package/crud/contentModel/validateModelFields.js +25 -133
  77. package/crud/contentModel/validateModelFields.js.map +1 -1
  78. package/crud/contentModel/validation.d.ts +551 -0
  79. package/crud/contentModel/validation.js +145 -0
  80. package/crud/contentModel/validation.js.map +1 -0
  81. package/crud/contentModel.crud.js +354 -373
  82. package/crud/contentModel.crud.js.map +1 -1
  83. package/crud/contentModelGroup/beforeCreate.js +0 -12
  84. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  85. package/crud/contentModelGroup/beforeDelete.js +0 -8
  86. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  87. package/crud/contentModelGroup/beforeUpdate.js +0 -5
  88. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  89. package/crud/contentModelGroup/validation.d.ts +30 -0
  90. package/crud/contentModelGroup/validation.js +34 -0
  91. package/crud/contentModelGroup/validation.js.map +1 -0
  92. package/crud/contentModelGroup.crud.js +177 -221
  93. package/crud/contentModelGroup.crud.js.map +1 -1
  94. package/crud/settings.crud.d.ts +1 -1
  95. package/crud/settings.crud.js +5 -22
  96. package/crud/settings.crud.js.map +1 -1
  97. package/crud/system.crud.js +1 -96
  98. package/crud/system.crud.js.map +1 -1
  99. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +0 -13
  100. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
  101. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +0 -36
  102. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  103. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +0 -53
  104. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  105. package/fieldConverters/index.js +0 -5
  106. package/fieldConverters/index.js.map +1 -1
  107. package/graphql/buildSchemaPlugins.d.ts +2 -2
  108. package/graphql/buildSchemaPlugins.js +4 -9
  109. package/graphql/buildSchemaPlugins.js.map +1 -1
  110. package/graphql/checkEndpointAccess.d.ts +2 -0
  111. package/graphql/checkEndpointAccess.js +18 -0
  112. package/graphql/checkEndpointAccess.js.map +1 -0
  113. package/graphql/createExecutableSchema.d.ts +2 -3
  114. package/graphql/createExecutableSchema.js +2 -6
  115. package/graphql/createExecutableSchema.js.map +1 -1
  116. package/graphql/createRequestBody.d.ts +2 -0
  117. package/graphql/createRequestBody.js +14 -0
  118. package/graphql/createRequestBody.js.map +1 -0
  119. package/graphql/formatErrorPayload.d.ts +1 -0
  120. package/graphql/formatErrorPayload.js +25 -0
  121. package/graphql/formatErrorPayload.js.map +1 -0
  122. package/graphql/generateSchema.js +2 -9
  123. package/graphql/generateSchema.js.map +1 -1
  124. package/graphql/getSchema.d.ts +17 -0
  125. package/graphql/getSchema.js +102 -0
  126. package/graphql/getSchema.js.map +1 -0
  127. package/graphql/graphQLHandlerFactory.js +6 -173
  128. package/graphql/graphQLHandlerFactory.js.map +1 -1
  129. package/graphql/handleRequest.d.ts +11 -0
  130. package/graphql/handleRequest.js +81 -0
  131. package/graphql/handleRequest.js.map +1 -0
  132. package/graphql/index.d.ts +1 -1
  133. package/graphql/index.js +0 -5
  134. package/graphql/index.js.map +1 -1
  135. package/graphql/schema/baseContentSchema.d.ts +2 -2
  136. package/graphql/schema/baseContentSchema.js +5 -19
  137. package/graphql/schema/baseContentSchema.js.map +1 -1
  138. package/graphql/schema/baseSchema.d.ts +1 -1
  139. package/graphql/schema/baseSchema.js +5 -10
  140. package/graphql/schema/baseSchema.js.map +1 -1
  141. package/graphql/schema/contentEntries.d.ts +2 -2
  142. package/graphql/schema/contentEntries.js +98 -100
  143. package/graphql/schema/contentEntries.js.map +1 -1
  144. package/graphql/schema/contentModelGroups.d.ts +2 -2
  145. package/graphql/schema/contentModelGroups.js +12 -29
  146. package/graphql/schema/contentModelGroups.js.map +1 -1
  147. package/graphql/schema/contentModels.d.ts +2 -2
  148. package/graphql/schema/contentModels.js +28 -31
  149. package/graphql/schema/contentModels.js.map +1 -1
  150. package/graphql/schema/createFieldResolvers.js +7 -29
  151. package/graphql/schema/createFieldResolvers.js.map +1 -1
  152. package/graphql/schema/createManageResolvers.d.ts +1 -1
  153. package/graphql/schema/createManageResolvers.js +33 -43
  154. package/graphql/schema/createManageResolvers.js.map +1 -1
  155. package/graphql/schema/createManageSDL.d.ts +1 -0
  156. package/graphql/schema/createManageSDL.js +56 -63
  157. package/graphql/schema/createManageSDL.js.map +1 -1
  158. package/graphql/schema/createPreviewResolvers.js +3 -17
  159. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  160. package/graphql/schema/createReadResolvers.js +4 -18
  161. package/graphql/schema/createReadResolvers.js.map +1 -1
  162. package/graphql/schema/createReadSDL.d.ts +1 -0
  163. package/graphql/schema/createReadSDL.js +24 -32
  164. package/graphql/schema/createReadSDL.js.map +1 -1
  165. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
  166. package/graphql/schema/resolvers/commonFieldResolvers.js +2 -3
  167. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
  168. package/graphql/schema/resolvers/manage/resolveCreate.js +0 -3
  169. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  170. package/graphql/schema/resolvers/manage/resolveCreateFrom.js +0 -3
  171. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  172. package/graphql/schema/resolvers/manage/resolveDelete.js +0 -6
  173. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  174. package/graphql/schema/resolvers/manage/resolveGet.js +0 -16
  175. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  176. package/graphql/schema/resolvers/manage/resolveGetByIds.js +0 -3
  177. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  178. package/graphql/schema/resolvers/manage/resolveGetRevisions.js +0 -3
  179. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  180. package/graphql/schema/resolvers/manage/resolveList.js +0 -3
  181. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  182. package/graphql/schema/resolvers/manage/resolvePublish.js +0 -3
  183. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  184. package/graphql/schema/resolvers/manage/resolveRepublish.js +0 -3
  185. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  186. package/graphql/schema/resolvers/manage/resolveUnpublish.js +0 -3
  187. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  188. package/graphql/schema/resolvers/manage/resolveUpdate.js +0 -3
  189. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  190. package/graphql/schema/resolvers/preview/resolveGet.js +0 -8
  191. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  192. package/graphql/schema/resolvers/preview/resolveList.js +0 -3
  193. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  194. package/graphql/schema/resolvers/read/resolveGet.js +0 -8
  195. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  196. package/graphql/schema/resolvers/read/resolveList.js +0 -3
  197. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  198. package/graphql/schema/schemaPlugins.d.ts +2 -2
  199. package/graphql/schema/schemaPlugins.js +21 -30
  200. package/graphql/schema/schemaPlugins.js.map +1 -1
  201. package/graphql/system.js +55 -87
  202. package/graphql/system.js.map +1 -1
  203. package/graphqlFields/boolean.js +0 -12
  204. package/graphqlFields/boolean.js.map +1 -1
  205. package/graphqlFields/datetime.js +0 -17
  206. package/graphqlFields/datetime.js.map +1 -1
  207. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  208. package/graphqlFields/dynamicZone/dynamicZoneField.js +57 -48
  209. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  210. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +2 -18
  211. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -1
  212. package/graphqlFields/dynamicZone/index.js +0 -2
  213. package/graphqlFields/dynamicZone/index.js.map +1 -1
  214. package/graphqlFields/file.js +0 -8
  215. package/graphqlFields/file.js.map +1 -1
  216. package/graphqlFields/helpers.js +0 -10
  217. package/graphqlFields/helpers.js.map +1 -1
  218. package/graphqlFields/index.js +0 -12
  219. package/graphqlFields/index.js.map +1 -1
  220. package/graphqlFields/longText.js +0 -10
  221. package/graphqlFields/longText.js.map +1 -1
  222. package/graphqlFields/number.js +0 -12
  223. package/graphqlFields/number.js.map +1 -1
  224. package/graphqlFields/object.js +21 -38
  225. package/graphqlFields/object.js.map +1 -1
  226. package/graphqlFields/ref.js +59 -65
  227. package/graphqlFields/ref.js.map +1 -1
  228. package/graphqlFields/richText.js +0 -9
  229. package/graphqlFields/richText.js.map +1 -1
  230. package/graphqlFields/text.js +0 -11
  231. package/graphqlFields/text.js.map +1 -1
  232. package/index.d.ts +4 -2
  233. package/index.js +26 -22
  234. package/index.js.map +1 -1
  235. package/modelManager/DefaultCmsModelManager.js +0 -16
  236. package/modelManager/DefaultCmsModelManager.js.map +1 -1
  237. package/modelManager/index.js +0 -4
  238. package/modelManager/index.js.map +1 -1
  239. package/package.json +26 -28
  240. package/parameters/context.js +0 -4
  241. package/parameters/context.js.map +1 -1
  242. package/parameters/header.js +0 -11
  243. package/parameters/header.js.map +1 -1
  244. package/parameters/index.js +0 -8
  245. package/parameters/index.js.map +1 -1
  246. package/parameters/manual.js +1 -8
  247. package/parameters/manual.js.map +1 -1
  248. package/parameters/path.js +0 -11
  249. package/parameters/path.js.map +1 -1
  250. package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
  251. package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
  252. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
  253. package/plugins/CmsGraphQLSchemaSorterPlugin.js +0 -10
  254. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
  255. package/plugins/CmsGroupPlugin.js +0 -8
  256. package/plugins/CmsGroupPlugin.js.map +1 -1
  257. package/plugins/CmsModelFieldConverterPlugin.js +0 -5
  258. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  259. package/plugins/CmsModelPlugin.d.ts +21 -3
  260. package/plugins/CmsModelPlugin.js +30 -40
  261. package/plugins/CmsModelPlugin.js.map +1 -1
  262. package/plugins/CmsParametersPlugin.js +0 -7
  263. package/plugins/CmsParametersPlugin.js.map +1 -1
  264. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  265. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  266. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  267. package/plugins/StorageTransformPlugin.js +0 -9
  268. package/plugins/StorageTransformPlugin.js.map +1 -1
  269. package/plugins/index.d.ts +2 -0
  270. package/plugins/index.js +22 -12
  271. package/plugins/index.js.map +1 -1
  272. package/storage/default.js +0 -3
  273. package/storage/default.js.map +1 -1
  274. package/storage/object.js +0 -19
  275. package/storage/object.js.map +1 -1
  276. package/types.d.ts +173 -79
  277. package/types.js +23 -73
  278. package/types.js.map +1 -1
  279. package/utils/access.js +11 -25
  280. package/utils/access.js.map +1 -1
  281. package/utils/converters/Converter.js +0 -13
  282. package/utils/converters/Converter.js.map +1 -1
  283. package/utils/converters/ConverterCollection.js +9 -33
  284. package/utils/converters/ConverterCollection.js.map +1 -1
  285. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  286. package/utils/converters/valueKeyStorageConverter.js +21 -44
  287. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  288. package/utils/createTypeFromFields.d.ts +1 -0
  289. package/utils/createTypeFromFields.js +11 -20
  290. package/utils/createTypeFromFields.js.map +1 -1
  291. package/utils/createTypeName.d.ts +0 -2
  292. package/utils/createTypeName.js +2 -19
  293. package/utils/createTypeName.js.map +1 -1
  294. package/utils/entryStorage.js +10 -26
  295. package/utils/entryStorage.js.map +1 -1
  296. package/utils/filterAsync.js +0 -5
  297. package/utils/filterAsync.js.map +1 -1
  298. package/utils/getBaseFieldType.js +0 -2
  299. package/utils/getBaseFieldType.js.map +1 -1
  300. package/utils/getEntryDescription.d.ts +2 -0
  301. package/utils/getEntryDescription.js +17 -0
  302. package/utils/getEntryDescription.js.map +1 -0
  303. package/utils/getEntryImage.d.ts +2 -0
  304. package/utils/getEntryImage.js +17 -0
  305. package/utils/getEntryImage.js.map +1 -0
  306. package/utils/getEntryTitle.js +0 -9
  307. package/utils/getEntryTitle.js.map +1 -1
  308. package/utils/getSchemaFromFieldPlugins.d.ts +4 -7
  309. package/utils/getSchemaFromFieldPlugins.js +23 -19
  310. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  311. package/utils/incrementEntryIdVersion.d.ts +5 -0
  312. package/utils/incrementEntryIdVersion.js +29 -0
  313. package/utils/incrementEntryIdVersion.js.map +1 -0
  314. package/utils/ownership.d.ts +3 -3
  315. package/utils/ownership.js +0 -8
  316. package/utils/ownership.js.map +1 -1
  317. package/utils/permissions.js +8 -23
  318. package/utils/permissions.js.map +1 -1
  319. package/utils/renderFields.d.ts +2 -1
  320. package/utils/renderFields.js +8 -10
  321. package/utils/renderFields.js.map +1 -1
  322. package/utils/renderGetFilterFields.js +0 -13
  323. package/utils/renderGetFilterFields.js.map +1 -1
  324. package/utils/renderInputFields.d.ts +2 -1
  325. package/utils/renderInputFields.js +4 -9
  326. package/utils/renderInputFields.js.map +1 -1
  327. package/utils/renderListFilterFields.js +1 -10
  328. package/utils/renderListFilterFields.js.map +1 -1
  329. package/utils/renderSortEnum.js +0 -9
  330. package/utils/renderSortEnum.js.map +1 -1
  331. package/utils/toSlug.js +0 -4
  332. package/utils/toSlug.js.map +1 -1
  333. package/validators/dateGte.js +0 -7
  334. package/validators/dateGte.js.map +1 -1
  335. package/validators/dateLte.js +0 -7
  336. package/validators/dateLte.js.map +1 -1
  337. package/validators/dynamicZone.js +0 -4
  338. package/validators/dynamicZone.js.map +1 -1
  339. package/validators/gte.js +0 -8
  340. package/validators/gte.js.map +1 -1
  341. package/validators/in.js +0 -8
  342. package/validators/in.js.map +1 -1
  343. package/validators/index.js +0 -16
  344. package/validators/index.js.map +1 -1
  345. package/validators/lte.js +0 -8
  346. package/validators/lte.js.map +1 -1
  347. package/validators/maxLength.js +0 -8
  348. package/validators/maxLength.js.map +1 -1
  349. package/validators/minLength.js +0 -8
  350. package/validators/minLength.js.map +1 -1
  351. package/validators/pattern.js +0 -9
  352. package/validators/pattern.js.map +1 -1
  353. package/validators/patternPlugins/email.js +0 -2
  354. package/validators/patternPlugins/email.js.map +1 -1
  355. package/validators/patternPlugins/index.js +0 -8
  356. package/validators/patternPlugins/index.js.map +1 -1
  357. package/validators/patternPlugins/lowerCase.js +0 -2
  358. package/validators/patternPlugins/lowerCase.js.map +1 -1
  359. package/validators/patternPlugins/lowerCaseSpace.js +0 -2
  360. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
  361. package/validators/patternPlugins/upperCase.js +0 -2
  362. package/validators/patternPlugins/upperCase.js.map +1 -1
  363. package/validators/patternPlugins/upperCaseSpace.js +0 -2
  364. package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
  365. package/validators/patternPlugins/url.js +0 -2
  366. package/validators/patternPlugins/url.js.map +1 -1
  367. package/validators/required.js +0 -5
  368. package/validators/required.js.map +1 -1
  369. package/validators/timeGte.js +0 -8
  370. package/validators/timeGte.js.map +1 -1
  371. package/validators/timeLte.js +0 -8
  372. package/validators/timeLte.js.map +1 -1
  373. package/validators/unique.js +0 -7
  374. package/validators/unique.js.map +1 -1
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getContentModelDescriptionFieldId = void 0;
8
+ var _getBaseFieldType = require("../../../utils/getBaseFieldType");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const getContentModelDescriptionFieldId = (fields, descriptionFieldId) => {
11
+ /**
12
+ * If there are no fields defined, we will just set as null.
13
+ */
14
+ if (fields.length === 0) {
15
+ return null;
16
+ }
17
+ /**
18
+ * If description field is not defined, let us find possible one.
19
+ */
20
+ if (!descriptionFieldId) {
21
+ const descriptionField = fields.find(field => {
22
+ return (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text" && !field.multipleValues;
23
+ });
24
+ return (descriptionField === null || descriptionField === void 0 ? void 0 : descriptionField.fieldId) || null;
25
+ }
26
+ const target = fields.find(field => field.fieldId === descriptionFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text");
27
+ if (!target) {
28
+ throw new _error.default(`Field selected for the description field does not exist in the model.`, "VALIDATION_ERROR", {
29
+ fieldId: descriptionFieldId,
30
+ fields
31
+ });
32
+ }
33
+ if (target.multipleValues) {
34
+ throw new _error.default(`Fields that accept multiple values cannot be used as the entry description.`, "ENTRY_TITLE_FIELD_TYPE", {
35
+ storageId: target.storageId,
36
+ fieldId: target.fieldId,
37
+ type: target.type
38
+ });
39
+ }
40
+ return target.fieldId;
41
+ };
42
+ exports.getContentModelDescriptionFieldId = getContentModelDescriptionFieldId;
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ import { CmsModelField } from "../../../types";
2
+ export declare const getContentModelImageFieldId: (fields: CmsModelField[], imageFieldId?: string | null) => string | null | undefined;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getContentModelImageFieldId = void 0;
8
+ var _getBaseFieldType = require("../../../utils/getBaseFieldType");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const getContentModelImageFieldId = (fields, imageFieldId) => {
11
+ /**
12
+ * If there are no fields defined, we will just set as null.
13
+ */
14
+ if (fields.length === 0) {
15
+ return null;
16
+ }
17
+ /**
18
+ * If image field is not defined, let us find possible one.
19
+ */
20
+ if (!imageFieldId) {
21
+ const imageField = fields.find(field => {
22
+ 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);
24
+ });
25
+ return (imageField === null || imageField === void 0 ? void 0 : imageField.fieldId) || null;
26
+ }
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
+ });
31
+ if (!target) {
32
+ throw new _error.default(`Field selected for the image field does not exist in the model.`, "VALIDATION_ERROR", {
33
+ fieldId: imageFieldId,
34
+ fields
35
+ });
36
+ }
37
+ if (target.multipleValues) {
38
+ throw new _error.default(`Fields that accept multiple values cannot be used as the entry image.`, "ENTRY_TITLE_FIELD_TYPE", {
39
+ storageId: target.storageId,
40
+ fieldId: target.fieldId,
41
+ type: target.type
42
+ });
43
+ }
44
+ return target.fieldId;
45
+ };
46
+ exports.getContentModelImageFieldId = getContentModelImageFieldId;
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ import { CmsModelField } from "../../../types";
2
+ export declare const getContentModelTitleFieldId: (fields: CmsModelField[], titleFieldId?: string) => string;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getContentModelTitleFieldId = void 0;
8
+ var _getBaseFieldType = require("../../../utils/getBaseFieldType");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const defaultTitleFieldId = "id";
11
+ const allowedTitleFieldTypes = ["text", "number"];
12
+ const getContentModelTitleFieldId = (fields, titleFieldId) => {
13
+ /**
14
+ * If there are no fields defined, we will return the default field
15
+ */
16
+ if (fields.length === 0) {
17
+ return defaultTitleFieldId;
18
+ }
19
+ /**
20
+ * if there is no title field defined either in input data or existing content model data
21
+ * we will take first text field that has no multiple values enabled
22
+ * or if initial titleFieldId is the default one also try to find first available text field
23
+ */
24
+ if (!titleFieldId || titleFieldId === defaultTitleFieldId) {
25
+ const titleField = fields.find(field => {
26
+ return (0, _getBaseFieldType.getBaseFieldType)(field) === "text" && !field.multipleValues;
27
+ });
28
+ return (titleField === null || titleField === void 0 ? void 0 : titleField.fieldId) || defaultTitleFieldId;
29
+ }
30
+ /**
31
+ * check existing titleFieldId for existence in the model
32
+ * for correct type
33
+ * and that it is not multiple values field
34
+ */
35
+ const target = fields.find(f => f.fieldId === titleFieldId);
36
+ if (!target) {
37
+ throw new _error.default(`Field selected for the title field does not exist in the model.`, "VALIDATION_ERROR", {
38
+ fieldId: titleFieldId,
39
+ fields
40
+ });
41
+ }
42
+ if (allowedTitleFieldTypes.includes(target.type) === false) {
43
+ throw new _error.default(`Only ${allowedTitleFieldTypes.join(", ")} and id fields can be used as an entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
44
+ storageId: target.storageId,
45
+ fieldId: target.fieldId,
46
+ type: target.type
47
+ });
48
+ }
49
+ if (target.multipleValues) {
50
+ throw new _error.default(`Fields that accept multiple values cannot be used as the entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
51
+ storageId: target.storageId,
52
+ fieldId: target.fieldId,
53
+ type: target.type
54
+ });
55
+ }
56
+ return target.fieldId;
57
+ };
58
+ exports.getContentModelTitleFieldId = getContentModelTitleFieldId;
@@ -0,0 +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"}
@@ -0,0 +1,6 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface Params {
3
+ model: Pick<CmsModel, "singularApiName" | "pluralApiName">;
4
+ }
5
+ export declare const validateEndingAllowed: (params: Params) => void;
6
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateEndingAllowed = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _isModelEndingAllowed = require("./isModelEndingAllowed");
10
+ const validateEndingAllowed = params => {
11
+ const {
12
+ model
13
+ } = params;
14
+ if ((0, _isModelEndingAllowed.isModelEndingAllowed)(model.singularApiName) === false) {
15
+ throw new _error.default(`Content model with singularApiName "${model.singularApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED", {
16
+ input: model.singularApiName,
17
+ disallowedEnding: _isModelEndingAllowed.disallowedEnding
18
+ });
19
+ } else if ((0, _isModelEndingAllowed.isModelEndingAllowed)(model.pluralApiName) === false) {
20
+ throw new _error.default(`Content model with pluralApiName "${model.pluralApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED", {
21
+ input: model.pluralApiName,
22
+ disallowedEnding: _isModelEndingAllowed.disallowedEnding
23
+ });
24
+ }
25
+ };
26
+ exports.validateEndingAllowed = validateEndingAllowed;
@@ -0,0 +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"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This list is to disallow creating models that might interfere with GraphQL schema creation.
3
+ * Add more if required.
4
+ */
5
+ export declare const disallowedEnding: string[];
6
+ export declare const isModelEndingAllowed: (apiName: string) => boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isModelEndingAllowed = exports.disallowedEnding = void 0;
7
+ /**
8
+ * This list is to disallow creating models that might interfere with GraphQL schema creation.
9
+ * Add more if required.
10
+ */
11
+ const disallowedEnding = ["Response", "List", "Meta", "Input", "Sorter", "RefType"];
12
+ exports.disallowedEnding = disallowedEnding;
13
+ const isModelEndingAllowed = apiName => {
14
+ for (const ending of disallowedEnding) {
15
+ const re = new RegExp(`${ending}$`, "i");
16
+ const matched = apiName.match(re);
17
+ if (matched === null) {
18
+ continue;
19
+ }
20
+ return false;
21
+ }
22
+ return true;
23
+ };
24
+ exports.isModelEndingAllowed = isModelEndingAllowed;
@@ -0,0 +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"}
@@ -0,0 +1,11 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface ModelIdAllowedParams {
3
+ model: Pick<CmsModel, "modelId">;
4
+ }
5
+ export declare const validateModelIdAllowed: (params: ModelIdAllowedParams) => void;
6
+ interface Params {
7
+ existingModel: Pick<CmsModel, "modelId">;
8
+ model: Pick<CmsModel, "modelId">;
9
+ }
10
+ export declare const validateExistingModelId: (params: Params) => void;
11
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateModelIdAllowed = exports.validateExistingModelId = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ const disallowedModelIdList = ["contentModel", "contentModels", "contentModelGroup", "contentModelGroups"];
10
+ const isModelIdAllowed = modelId => {
11
+ return disallowedModelIdList.includes(modelId) === false;
12
+ };
13
+ const validateModelIdAllowed = params => {
14
+ const {
15
+ model
16
+ } = params;
17
+ if (isModelIdAllowed(model.modelId)) {
18
+ return;
19
+ }
20
+ throw new _error.default(`Provided model ID "${model.modelId}" is not allowed.`, "MODEL_ID_NOT_ALLOWED", {
21
+ input: model.modelId
22
+ });
23
+ };
24
+ exports.validateModelIdAllowed = validateModelIdAllowed;
25
+ const validateExistingModelId = params => {
26
+ const {
27
+ existingModel,
28
+ model
29
+ } = params;
30
+ if (existingModel.modelId === model.modelId) {
31
+ throw new _error.default(`Content model with modelId "${model.modelId}" already exists.`, "MODEL_ID_EXISTS", {
32
+ input: existingModel.modelId
33
+ });
34
+ }
35
+ };
36
+ exports.validateExistingModelId = validateExistingModelId;
@@ -0,0 +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"}
@@ -0,0 +1,7 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface Params {
3
+ existingModel: Pick<CmsModel, "singularApiName" | "pluralApiName">;
4
+ model: Pick<CmsModel, "singularApiName" | "pluralApiName">;
5
+ }
6
+ export declare const validatePluralApiName: (params: Params) => void;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validatePluralApiName = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ const validatePluralApiName = params => {
10
+ const {
11
+ existingModel,
12
+ model
13
+ } = params;
14
+ if (existingModel.singularApiName === model.pluralApiName) {
15
+ throw new _error.default(`Content model with singularApiName "${model.pluralApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
16
+ input: model.pluralApiName
17
+ });
18
+ } else if (existingModel.pluralApiName === model.pluralApiName) {
19
+ throw new _error.default(`Content model with pluralApiName "${model.pluralApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
20
+ input: model.pluralApiName
21
+ });
22
+ }
23
+ };
24
+ exports.validatePluralApiName = validatePluralApiName;
@@ -0,0 +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"}
@@ -0,0 +1,7 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface Params {
3
+ existingModel: Pick<CmsModel, "singularApiName" | "pluralApiName">;
4
+ model: Pick<CmsModel, "singularApiName" | "pluralApiName">;
5
+ }
6
+ export declare const validateSingularApiName: (params: Params) => void;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateSingularApiName = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ const validateSingularApiName = params => {
10
+ const {
11
+ existingModel,
12
+ model
13
+ } = params;
14
+ if (existingModel.singularApiName === model.singularApiName) {
15
+ throw new _error.default(`Content model with singularApiName "${model.singularApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
16
+ input: model.singularApiName
17
+ });
18
+ } else if (existingModel.pluralApiName === model.singularApiName) {
19
+ throw new _error.default(`Content model with pluralApiName "${model.singularApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
20
+ input: model.singularApiName
21
+ });
22
+ }
23
+ };
24
+ exports.validateSingularApiName = validateSingularApiName;
@@ -0,0 +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"}
@@ -4,33 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.validateLayout = void 0;
7
-
8
7
  const validateLayout = (layout, fields = []) => {
9
8
  const flatLayoutIdList = layout.reduce((acc, id) => {
10
9
  return acc.concat(Array.isArray(id) ? id : [id]);
11
10
  }, []);
12
-
13
11
  if (flatLayoutIdList.length !== fields.length) {
14
12
  throw new Error(`There are ${flatLayoutIdList.length} IDs in the layout and ${fields.length} in fields, which cannot be - numbers must be the same.`);
15
13
  }
16
-
17
14
  for (const field of fields) {
18
15
  if (flatLayoutIdList.includes(field.id)) {
19
16
  continue;
20
17
  }
21
-
22
18
  throw new Error(`Field "${field.id}" is not defined in layout.`);
23
19
  }
24
-
25
20
  for (const id of flatLayoutIdList) {
26
21
  const fieldFound = fields.some(f => f.id === id);
27
-
28
22
  if (fieldFound) {
29
23
  continue;
30
24
  }
31
-
32
25
  throw new Error(`Field id "${id}" is in layout but not in fields.`);
33
26
  }
34
27
  };
35
-
36
28
  exports.validateLayout = validateLayout;
@@ -1 +1 @@
1
- {"version":3,"names":["validateLayout","layout","fields","flatLayoutIdList","reduce","acc","id","concat","Array","isArray","length","Error","field","includes","fieldFound","some","f"],"sources":["validateLayout.ts"],"sourcesContent":["import { CmsModelField, CmsModel } from \"~/types\";\n\nexport const validateLayout = (layout: CmsModel[\"layout\"], fields: CmsModelField[] = []): void => {\n const flatLayoutIdList = layout.reduce((acc, id) => {\n return acc.concat(Array.isArray(id) ? id : [id]);\n }, []);\n if (flatLayoutIdList.length !== fields.length) {\n throw new Error(\n `There are ${flatLayoutIdList.length} IDs in the layout and ${fields.length} in fields, which cannot be - numbers must be the same.`\n );\n }\n for (const field of fields) {\n if (flatLayoutIdList.includes(field.id)) {\n continue;\n }\n throw new Error(`Field \"${field.id}\" is not defined in layout.`);\n }\n for (const id of flatLayoutIdList) {\n const fieldFound = fields.some(f => f.id === id);\n if (fieldFound) {\n continue;\n }\n throw new Error(`Field id \"${id}\" is in layout but not in fields.`);\n }\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,cAAc,GAAG,CAACC,MAAD,EAA6BC,MAAuB,GAAG,EAAvD,KAAoE;EAC9F,MAAMC,gBAAgB,GAAGF,MAAM,CAACG,MAAP,CAAc,CAACC,GAAD,EAAMC,EAAN,KAAa;IAChD,OAAOD,GAAG,CAACE,MAAJ,CAAWC,KAAK,CAACC,OAAN,CAAcH,EAAd,IAAoBA,EAApB,GAAyB,CAACA,EAAD,CAApC,CAAP;EACH,CAFwB,EAEtB,EAFsB,CAAzB;;EAGA,IAAIH,gBAAgB,CAACO,MAAjB,KAA4BR,MAAM,CAACQ,MAAvC,EAA+C;IAC3C,MAAM,IAAIC,KAAJ,CACD,aAAYR,gBAAgB,CAACO,MAAO,0BAAyBR,MAAM,CAACQ,MAAO,yDAD1E,CAAN;EAGH;;EACD,KAAK,MAAME,KAAX,IAAoBV,MAApB,EAA4B;IACxB,IAAIC,gBAAgB,CAACU,QAAjB,CAA0BD,KAAK,CAACN,EAAhC,CAAJ,EAAyC;MACrC;IACH;;IACD,MAAM,IAAIK,KAAJ,CAAW,UAASC,KAAK,CAACN,EAAG,6BAA7B,CAAN;EACH;;EACD,KAAK,MAAMA,EAAX,IAAiBH,gBAAjB,EAAmC;IAC/B,MAAMW,UAAU,GAAGZ,MAAM,CAACa,IAAP,CAAYC,CAAC,IAAIA,CAAC,CAACV,EAAF,KAASA,EAA1B,CAAnB;;IACA,IAAIQ,UAAJ,EAAgB;MACZ;IACH;;IACD,MAAM,IAAIH,KAAJ,CAAW,aAAYL,EAAG,mCAA1B,CAAN;EACH;AACJ,CAtBM"}
1
+ {"version":3,"names":["validateLayout","layout","fields","flatLayoutIdList","reduce","acc","id","concat","Array","isArray","length","Error","field","includes","fieldFound","some","f"],"sources":["validateLayout.ts"],"sourcesContent":["import { CmsModelField, CmsModel } from \"~/types\";\n\nexport const validateLayout = (layout: CmsModel[\"layout\"], fields: CmsModelField[] = []): void => {\n const flatLayoutIdList = layout.reduce((acc, id) => {\n return acc.concat(Array.isArray(id) ? id : [id]);\n }, []);\n if (flatLayoutIdList.length !== fields.length) {\n throw new Error(\n `There are ${flatLayoutIdList.length} IDs in the layout and ${fields.length} in fields, which cannot be - numbers must be the same.`\n );\n }\n for (const field of fields) {\n if (flatLayoutIdList.includes(field.id)) {\n continue;\n }\n throw new Error(`Field \"${field.id}\" is not defined in layout.`);\n }\n for (const id of flatLayoutIdList) {\n const fieldFound = fields.some(f => f.id === id);\n if (fieldFound) {\n continue;\n }\n throw new Error(`Field id \"${id}\" is in layout but not in fields.`);\n }\n};\n"],"mappings":";;;;;;AAEO,MAAMA,cAAc,GAAG,CAACC,MAA0B,EAAEC,MAAuB,GAAG,EAAE,KAAW;EAC9F,MAAMC,gBAAgB,GAAGF,MAAM,CAACG,MAAM,CAAC,CAACC,GAAG,EAAEC,EAAE,KAAK;IAChD,OAAOD,GAAG,CAACE,MAAM,CAACC,KAAK,CAACC,OAAO,CAACH,EAAE,CAAC,GAAGA,EAAE,GAAG,CAACA,EAAE,CAAC,CAAC;EACpD,CAAC,EAAE,EAAE,CAAC;EACN,IAAIH,gBAAgB,CAACO,MAAM,KAAKR,MAAM,CAACQ,MAAM,EAAE;IAC3C,MAAM,IAAIC,KAAK,CACV,aAAYR,gBAAgB,CAACO,MAAO,0BAAyBR,MAAM,CAACQ,MAAO,yDAAwD,CACvI;EACL;EACA,KAAK,MAAME,KAAK,IAAIV,MAAM,EAAE;IACxB,IAAIC,gBAAgB,CAACU,QAAQ,CAACD,KAAK,CAACN,EAAE,CAAC,EAAE;MACrC;IACJ;IACA,MAAM,IAAIK,KAAK,CAAE,UAASC,KAAK,CAACN,EAAG,6BAA4B,CAAC;EACpE;EACA,KAAK,MAAMA,EAAE,IAAIH,gBAAgB,EAAE;IAC/B,MAAMW,UAAU,GAAGZ,MAAM,CAACa,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACV,EAAE,KAAKA,EAAE,CAAC;IAChD,IAAIQ,UAAU,EAAE;MACZ;IACJ;IACA,MAAM,IAAIH,KAAK,CAAE,aAAYL,EAAG,mCAAkC,CAAC;EACvE;AACJ,CAAC;AAAC"}
@@ -1,5 +1,6 @@
1
1
  import { CmsContext, CmsModel } from "../../types";
2
2
  interface ValidateModelParams {
3
+ models: CmsModel[];
3
4
  model: CmsModel;
4
5
  original?: CmsModel;
5
6
  context: CmsContext;
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.validateModel = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _CmsModelPlugin = require("../../plugins/CmsModelPlugin");
13
-
14
10
  var _validateModelFields = require("./validateModelFields");
15
-
16
11
  const validateModel = async params => {
17
12
  const {
18
13
  model,
@@ -22,14 +17,11 @@ const validateModel = async params => {
22
17
  plugins
23
18
  } = context;
24
19
  const modelPlugin = plugins.byType(_CmsModelPlugin.CmsModelPlugin.type).find(item => item.contentModel.modelId === model.modelId);
25
-
26
20
  if (modelPlugin) {
27
21
  throw new _error.default("Content models defined via plugins cannot be updated.", "CONTENT_MODEL_UPDATE_ERROR", {
28
22
  modelId: model.modelId
29
23
  });
30
24
  }
31
-
32
25
  await (0, _validateModelFields.validateModelFields)(params);
33
26
  };
34
-
35
27
  exports.validateModel = validateModel;
@@ -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 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;;AAQO,MAAMA,aAAa,GAAG,MAAOC,MAAP,IAAsD;EAC/E,MAAM;IAAEC,KAAF;IAASC;EAAT,IAAqBF,MAA3B;EAEA,MAAM;IAAEG;EAAF,IAAcD,OAApB;EAEA,MAAME,WAAW,GAAGD,OAAO,CACtBE,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,YAAL,CAAkBC,OAAlB,KAA8BV,KAAK,CAACU,OAFlC,CAApB;;EAIA,IAAIP,WAAJ,EAAiB;IACb,MAAM,IAAIQ,cAAJ,CACF,uDADE,EAEF,4BAFE,EAGF;MACID,OAAO,EAAEV,KAAK,CAACU;IADnB,CAHE,CAAN;EAOH;;EAED,MAAM,IAAAE,wCAAA,EAAoBb,MAApB,CAAN;AACH,CApBM"}
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,5 +1,6 @@
1
- import { CmsContext, CmsModel } from "../../types";
1
+ import { CmsModel, CmsContext } from "../../types";
2
2
  interface ValidateModelFieldsParams {
3
+ models: CmsModel[];
3
4
  model: CmsModel;
4
5
  original?: CmsModel;
5
6
  context: CmsContext;