@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
@@ -1 +1 @@
1
- {"version":3,"names":["createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","plugin","GraphQLSchemaPlugin","typeDefs","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","DateTimeZ","DateTimeZScalar","Date","DateScalar","Time","TimeScalar","Mutation","_empty"],"sources":["baseContentSchema.ts"],"sourcesContent":["import { GraphQLScalarPlugin } from \"@webiny/handler-graphql/types\";\nimport { CmsContext } from \"~/types\";\nimport {\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateTimeScalar,\n DateScalar,\n TimeScalar,\n LongScalar,\n JsonScalar,\n DateTimeZScalar\n} from \"@webiny/handler-graphql/builtInTypes\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { GraphQLScalarType } from \"graphql\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createBaseContentSchema = ({ context }: Params): GraphQLSchemaPlugin => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const plugin = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar DateTimeZ\n scalar Time\n\n type Query\n\n type Mutation {\n _empty: String\n }\n\n type CmsCreatedBy {\n id: String\n displayName: String\n type: String\n }\n\n type CmsOwnedBy {\n id: String\n displayName: String\n type: String\n }\n\n enum CmsEntryStatusType {\n latest\n published\n }\n `,\n resolvers: {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n DateTimeZ: DateTimeZScalar,\n Date: DateScalar,\n Time: TimeScalar,\n Mutation: {\n _empty: () => \"_empty\"\n }\n }\n });\n plugin.name = `headless-cms.graphql.schema.base`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AAWA;;AAMO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA8C;EACjF,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAR,CACXC,MADW,CACiB,gBADjB,EAEXC,GAFW,CAEPC,IAAI,IAAIA,IAAI,CAACC,MAFN,CAAhB;EAIA,MAAMC,MAAM,GAAG,IAAIC,wCAAJ,CAAwB;IACnCC,QAAQ;IAAE;IAAe;AACjC,cAAcR,OAAO,CAACG,GAAR,CAAYE,MAAM,IAAK,UAASA,MAAM,CAACI,IAAK,EAA5C,EAA+CC,IAA/C,CAAoD,GAApD,CAAyD;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAnC2C;IAoCnCC,SAAS,8DACFX,OAAO,CAACY,MAAR,CAAkD,CAACC,GAAD,EAAMC,CAAN,KAAY;MAC7DD,GAAG,CAACC,CAAC,CAACL,IAAH,CAAH,GAAcK,CAAd;MACA,OAAOD,GAAP;IACH,CAHE,EAGA,EAHA,CADE;MAKLE,IAAI,EAAEC,wBALD;MAMLC,IAAI,EAAEC,wBAND;MAOLC,QAAQ,EAAEC,4BAPL;MAQLC,MAAM,EAAEC,0BARH;MASLC,GAAG,EAAEC,uBATA;MAULC,QAAQ,EAAEC,4BAVL;MAWLC,SAAS,EAAEC,6BAXN;MAYLC,IAAI,EAAEC,wBAZD;MAaLC,IAAI,EAAEC,wBAbD;MAcLC,QAAQ,EAAE;QACNC,MAAM,EAAE,MAAM;MADR;IAdL;EApC0B,CAAxB,CAAf;EAuDA5B,MAAM,CAACG,IAAP,GAAe,kCAAf;EAEA,OAAOH,MAAP;AACH,CA/DM"}
1
+ {"version":3,"names":["createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","plugin","CmsGraphQLSchemaPlugin","typeDefs","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","DateTimeZ","DateTimeZScalar","Date","DateScalar","Time","TimeScalar","Mutation","_empty"],"sources":["baseContentSchema.ts"],"sourcesContent":["import { GraphQLScalarPlugin } from \"@webiny/handler-graphql/types\";\nimport { CmsContext } from \"~/types\";\nimport {\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateTimeScalar,\n DateScalar,\n TimeScalar,\n LongScalar,\n JsonScalar,\n DateTimeZScalar\n} from \"@webiny/handler-graphql/builtInTypes\";\nimport { GraphQLScalarType } from \"graphql\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createBaseContentSchema = ({ context }: Params): CmsGraphQLSchemaPlugin => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar DateTimeZ\n scalar Time\n\n type Query\n\n type Mutation {\n _empty: String\n }\n\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\n enum CmsEntryStatusType {\n latest\n published\n }\n `,\n resolvers: {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n DateTimeZ: DateTimeZScalar,\n Date: DateScalar,\n Time: TimeScalar,\n Mutation: {\n _empty: () => \"_empty\"\n }\n }\n });\n plugin.name = `headless-cms.graphql.schema.baseContentSchema`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;AAEA;AAYA;AAKO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC;AAAgB,CAAC,KAA6B;EACpF,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;EAE7B,MAAMC,MAAM,GAAG,IAAIC,+BAAsB,CAAC;IACtCC,QAAQ,EAAE,aAAe;AACjC,cAAcR,OAAO,CAACG,GAAG,CAACE,MAAM,IAAK,UAASA,MAAM,CAACI,IAAK,EAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,8DACFX,OAAO,CAACY,MAAM,CAAoC,CAACC,GAAG,EAAEC,CAAC,KAAK;MAC7DD,GAAG,CAACC,CAAC,CAACL,IAAI,CAAC,GAAGK,CAAC;MACf,OAAOD,GAAG;IACd,CAAC,EAAE,CAAC,CAAC,CAAC;MACNE,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAEC,4BAAc;MACxBC,MAAM,EAAEC,0BAAY;MACpBC,GAAG,EAAEC,uBAAS;MACdC,QAAQ,EAAEC,4BAAc;MACxBC,SAAS,EAAEC,6BAAe;MAC1BC,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAE;QACNC,MAAM,EAAE,MAAM;MAClB;IAAC;EAET,CAAC,CAAC;EACF5B,MAAM,CAACG,IAAI,GAAI,+CAA8C;EAE7D,OAAOH,MAAM;AACjB,CAAC;AAAC"}
@@ -1,3 +1,3 @@
1
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
2
1
  import { CmsContext } from "../../types";
2
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
3
3
  export declare const createBaseSchema: () => GraphQLSchemaPlugin<CmsContext>[];
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createBaseSchema = void 0;
7
-
7
+ var _plugins = require("../../plugins");
8
8
  var _handlerGraphql = require("@webiny/handler-graphql");
9
-
10
9
  const createBaseSchema = () => {
11
- const cmsPlugin = new _handlerGraphql.GraphQLSchemaPlugin({
12
- typeDefs:
13
- /* GraphQL */
14
- `
10
+ const cmsPlugin = new _plugins.CmsGraphQLSchemaPlugin({
11
+ typeDefs: /* GraphQL */`
15
12
  type CmsError {
16
13
  code: String
17
14
  message: String
@@ -42,17 +39,15 @@ const createBaseSchema = () => {
42
39
  `,
43
40
  resolvers: {}
44
41
  });
45
- cmsPlugin.name = "graphql.cms.schema.base";
42
+ cmsPlugin.name = "headless-cms.graphql.schema.base";
46
43
  const corePlugin = new _handlerGraphql.GraphQLSchemaPlugin({
47
44
  typeDefs: cmsPlugin.schema.typeDefs,
48
45
  resolvers: cmsPlugin.schema.resolvers
49
46
  });
50
- corePlugin.name = "graphql.cms.core.schema.base";
47
+ corePlugin.name = "headless-cms.graphql.core.schema.base";
51
48
  /**
52
49
  * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.
53
50
  */
54
-
55
51
  return [cmsPlugin, corePlugin];
56
52
  };
57
-
58
53
  exports.createBaseSchema = createBaseSchema;
@@ -1 +1 @@
1
- {"version":3,"names":["createBaseSchema","cmsPlugin","GraphQLSchemaPlugin","typeDefs","resolvers","name","corePlugin","schema"],"sources":["baseSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\n\nexport const createBaseSchema = (): GraphQLSchemaPlugin<CmsContext>[] => {\n const cmsPlugin = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"graphql.cms.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"graphql.cms.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,gBAAgB,GAAG,MAAyC;EACrE,MAAMC,SAAS,GAAG,IAAIC,mCAAJ,CAAwB;IACtCC,QAAQ;IAAE;IAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SA7B8C;IA8BtCC,SAAS,EAAE;EA9B2B,CAAxB,CAAlB;EAgCAH,SAAS,CAACI,IAAV,GAAiB,yBAAjB;EACA,MAAMC,UAAU,GAAG,IAAIJ,mCAAJ,CAAwB;IACvCC,QAAQ,EAAEF,SAAS,CAACM,MAAV,CAAiBJ,QADY;IAEvCC,SAAS,EAAEH,SAAS,CAACM,MAAV,CAAiBH;EAFW,CAAxB,CAAnB;EAIAE,UAAU,CAACD,IAAX,GAAkB,8BAAlB;EACA;AACJ;AACA;;EACI,OAAO,CAACJ,SAAD,EAAYK,UAAZ,CAAP;AACH,CA3CM"}
1
+ {"version":3,"names":["createBaseSchema","cmsPlugin","CmsGraphQLSchemaPlugin","typeDefs","resolvers","name","corePlugin","GraphQLSchemaPlugin","schema"],"sources":["baseSchema.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nexport const createBaseSchema = (): GraphQLSchemaPlugin<CmsContext>[] => {\n const cmsPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n"],"mappings":";;;;;;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,MAAyC;EACrE,MAAMC,SAAS,GAAG,IAAIC,+BAAsB,CAAC;IACzCC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFH,SAAS,CAACI,IAAI,GAAG,kCAAkC;EACnD,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAa;IACnDJ,QAAQ,EAAEF,SAAS,CAACO,MAAM,CAACL,QAAQ;IACnCC,SAAS,EAAEH,SAAS,CAACO,MAAM,CAACJ;EAChC,CAAC,CAAC;EACFE,UAAU,CAACD,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACJ,SAAS,EAAEK,UAAU,CAAC;AAClC,CAAC;AAAC"}
@@ -1,7 +1,7 @@
1
1
  import { CmsContext } from "../../types";
2
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin";
2
+ import { CmsGraphQLSchemaPlugin } from "../../plugins";
3
3
  interface Params {
4
4
  context: CmsContext;
5
5
  }
6
- export declare const createContentEntriesSchema: ({ context }: Params) => GraphQLSchemaPlugin<CmsContext>;
6
+ export declare const createContentEntriesSchema: ({ context }: Params) => CmsGraphQLSchemaPlugin<CmsContext>;
7
7
  export {};
@@ -1,59 +1,71 @@
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.createContentEntriesSchema = void 0;
9
-
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
9
  var _handlerGraphql = require("@webiny/handler-graphql");
11
-
12
10
  var _apiSecurity = require("@webiny/api-security");
13
-
14
- var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
15
-
16
11
  var _getEntryTitle = require("../../utils/getEntryTitle");
17
-
18
- var _error = _interopRequireDefault(require("@webiny/error"));
19
-
12
+ var _plugins = require("../../plugins");
13
+ var _getEntryDescription = require("../../utils/getEntryDescription");
14
+ var _getEntryImage = require("../../utils/getEntryImage");
15
+ var _entryStorage = require("../../utils/entryStorage");
16
+ const createDate = date => {
17
+ try {
18
+ return new Date(date);
19
+ } catch {}
20
+ return new Date();
21
+ };
22
+ const createCmsEntryRecord = (model, entry) => {
23
+ return {
24
+ id: entry.id,
25
+ entryId: entry.entryId,
26
+ model: {
27
+ modelId: model.modelId,
28
+ name: model.name
29
+ },
30
+ status: entry.status,
31
+ title: (0, _getEntryTitle.getEntryTitle)(model, entry),
32
+ description: (0, _getEntryDescription.getEntryDescription)(model, entry),
33
+ image: (0, _getEntryImage.getEntryImage)(model, entry),
34
+ createdBy: entry.createdBy,
35
+ modifiedBy: entry.modifiedBy,
36
+ createdOn: createDate(entry.createdOn),
37
+ savedOn: createDate(entry.savedOn)
38
+ };
39
+ };
20
40
  const getFetchMethod = (type, context) => {
21
41
  if (!getContentEntriesMethods[type]) {
22
42
  throw new _error.default(`Unknown getContentEntries method "${type}". Could not fetch content entries.`, "UNKNOWN_METHOD_ERROR", {
23
43
  type
24
44
  });
25
45
  }
26
-
27
46
  const methodName = getContentEntriesMethods[type];
28
-
29
47
  if (!context.cms[methodName]) {
30
48
  throw new _error.default(`Unknown context.cms method "${methodName}". Could not fetch content entries.`, "UNKNOWN_METHOD_ERROR", {
31
49
  type,
32
50
  methodName
33
51
  });
34
52
  }
35
-
36
53
  return context.cms[methodName];
37
54
  };
38
55
  /**
39
56
  * Function to get the list of content entries depending on latest, published or exact GraphQL queries.
40
57
  */
41
-
42
-
43
58
  var GetContentEntryMethods;
44
-
45
59
  (function (GetContentEntryMethods) {
46
60
  GetContentEntryMethods["getLatestEntriesByIds"] = "getLatestEntriesByIds";
47
61
  GetContentEntryMethods["getPublishedEntriesByIds"] = "getPublishedEntriesByIds";
48
62
  GetContentEntryMethods["getEntriesByIds"] = "getEntriesByIds";
49
63
  })(GetContentEntryMethods || (GetContentEntryMethods = {}));
50
-
51
64
  const getContentEntriesMethods = {
52
65
  latest: "getLatestEntriesByIds",
53
66
  published: "getPublishedEntriesByIds",
54
67
  exact: "getEntriesByIds"
55
68
  };
56
-
57
69
  const getContentEntries = async params => {
58
70
  const {
59
71
  args,
@@ -73,33 +85,21 @@ const getContentEntries = async params => {
73
85
  } else if (collection[ref.modelId].includes(ref.id)) {
74
86
  return collection;
75
87
  }
76
-
77
88
  collection[ref.modelId].push(ref.id);
78
89
  return collection;
79
90
  }, {});
80
91
  const getters = Object.keys(entriesByModel).map(async modelId => {
81
92
  return method(modelsMap[modelId], entriesByModel[modelId]);
82
93
  });
83
-
84
94
  if (getters.length === 0) {
85
95
  return new _handlerGraphql.Response([]);
86
96
  }
87
-
88
97
  try {
89
98
  const results = await Promise.all(getters);
90
99
  const entries = results.reduce((collection, items) => {
91
100
  return collection.concat(items.map(item => {
92
101
  const model = modelsMap[item.modelId];
93
- return {
94
- id: item.id,
95
- entryId: item.entryId,
96
- model: {
97
- modelId: model.modelId,
98
- name: model.name
99
- },
100
- status: item.status,
101
- title: (0, _getEntryTitle.getEntryTitle)(model, item)
102
- };
102
+ return createCmsEntryRecord(model, item);
103
103
  }));
104
104
  }, []).filter(Boolean);
105
105
  return new _handlerGraphql.Response(entries);
@@ -107,25 +107,23 @@ const getContentEntries = async params => {
107
107
  return new _handlerGraphql.ErrorResponse(ex);
108
108
  }
109
109
  };
110
+
110
111
  /**
111
112
  * Function to fetch a single content entry depending on latest, published or exact GraphQL query.
112
113
  */
113
114
 
114
-
115
115
  const getContentEntry = async params => {
116
116
  const {
117
117
  args,
118
118
  context,
119
119
  type
120
120
  } = params;
121
-
122
121
  if (!getContentEntriesMethods[type]) {
123
122
  throw new _error.default(`Unknown getContentEntry method "${type}". Could not fetch content entry.`, "UNKNOWN_METHOD_ERROR", {
124
123
  args,
125
124
  type
126
125
  });
127
126
  }
128
-
129
127
  const method = getFetchMethod(type, context);
130
128
  const {
131
129
  modelId,
@@ -133,7 +131,6 @@ const getContentEntry = async params => {
133
131
  } = args.entry;
134
132
  const models = await context.cms.listModels();
135
133
  const model = models.find(m => m.modelId === modelId);
136
-
137
134
  if (!model) {
138
135
  return new _apiSecurity.NotAuthorizedResponse({
139
136
  data: {
@@ -141,62 +138,87 @@ const getContentEntry = async params => {
141
138
  }
142
139
  });
143
140
  }
144
-
145
141
  const result = await method(model, [id]);
146
142
  const entry = result.shift();
147
-
148
143
  if (!entry) {
149
144
  return new _handlerGraphql.Response(null);
150
145
  }
151
-
152
- return new _handlerGraphql.Response({
153
- id: entry.id,
154
- entryId: entry.entryId,
155
- model: {
156
- modelId: model.modelId,
157
- name: model.name
158
- },
159
- status: entry.status,
160
- title: (0, _getEntryTitle.getEntryTitle)(model, entry)
161
- });
146
+ return new _handlerGraphql.Response(createCmsEntryRecord(model, entry));
147
+ };
148
+ /**
149
+ * As we support description field, we need to transform the value from storage.
150
+ */
151
+ const createResolveDescription = () => {
152
+ return async (parent, _, context) => {
153
+ const models = await context.cms.listModels();
154
+ const model = models.find(({
155
+ modelId
156
+ }) => {
157
+ return parent.model.modelId === modelId;
158
+ });
159
+ if (!model) {
160
+ return null;
161
+ }
162
+ const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);
163
+ if (!field) {
164
+ return null;
165
+ }
166
+ const value = parent.description || parent[field.fieldId];
167
+ if (!value) {
168
+ return null;
169
+ }
170
+ return (0, _entryStorage.entryFieldFromStorageTransform)({
171
+ context,
172
+ model,
173
+ field,
174
+ value
175
+ });
176
+ };
162
177
  };
163
-
164
178
  const createContentEntriesSchema = ({
165
179
  context
166
180
  }) => {
167
181
  if (!context.cms.MANAGE) {
168
- return new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
182
+ const plugin = new _plugins.CmsGraphQLSchemaPlugin({
169
183
  typeDefs: "",
170
184
  resolvers: {}
171
185
  });
186
+ plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;
187
+ return plugin;
172
188
  }
173
-
174
- const plugin = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
175
- typeDefs:
176
- /* GraphQL */
177
- `
189
+ const plugin = new _plugins.CmsGraphQLSchemaPlugin({
190
+ typeDefs: /* GraphQL */`
178
191
  type CmsModelMeta {
179
- modelId: String
180
- name: String
192
+ modelId: String!
193
+ name: String!
181
194
  }
182
195
 
183
196
  type CmsPublishedContentEntry {
184
197
  id: ID!
185
198
  entryId: String!
186
199
  title: String
200
+ description: String
201
+ image: String
187
202
  }
188
203
 
189
204
  type CmsContentEntry {
190
205
  id: ID!
191
206
  entryId: String!
192
- model: CmsModelMeta
193
- status: String
194
- title: String
207
+ model: CmsModelMeta!
208
+ status: String!
209
+ title: String!
210
+ description: String
211
+ image: String
212
+ createdBy: CmsIdentity!
213
+ ownedBy: CmsIdentity!
214
+ modifiedBy: CmsIdentity
195
215
  published: CmsPublishedContentEntry
216
+ createdOn: DateTime!
217
+ savedOn: DateTime!
196
218
  }
197
219
 
198
220
  type CmsContentEntriesResponse {
199
- data: [CmsContentEntry]
221
+ data: [CmsContentEntry!]
200
222
  error: CmsError
201
223
  }
202
224
 
@@ -217,20 +239,20 @@ const createContentEntriesSchema = ({
217
239
  query: String
218
240
  fields: [String!]
219
241
  limit: Int
220
- ): CmsContentEntriesResponse
242
+ ): CmsContentEntriesResponse!
221
243
 
222
244
  # Get content entry meta data
223
- getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse
245
+ getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!
224
246
 
225
- getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse
226
- getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse
247
+ getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!
248
+ getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!
227
249
 
228
250
  # Get content entries meta data
229
- getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse
230
- getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse
251
+ getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!
252
+ getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!
231
253
  getPublishedContentEntries(
232
254
  entries: [CmsModelEntryInput!]!
233
- ): CmsContentEntriesResponse
255
+ ): CmsContentEntriesResponse!
234
256
  }
235
257
  `,
236
258
  resolvers: {
@@ -243,26 +265,22 @@ const createContentEntriesSchema = ({
243
265
  }) => {
244
266
  return parent.model.modelId === modelId;
245
267
  });
246
-
247
268
  if (!model) {
248
269
  return null;
249
270
  }
250
-
251
271
  const [entry] = await context.cms.getPublishedEntriesByIds(model, [parent.id]);
252
-
253
272
  if (!entry) {
254
273
  return null;
255
274
  }
256
-
257
- return {
258
- id: entry.id,
259
- entryId: entry.entryId,
260
- title: (0, _getEntryTitle.getEntryTitle)(model, entry)
261
- };
275
+ return createCmsEntryRecord(model, entry);
262
276
  } catch (ex) {
263
277
  return null;
264
278
  }
265
- }
279
+ },
280
+ description: createResolveDescription()
281
+ },
282
+ CmsPublishedContentEntry: {
283
+ description: createResolveDescription()
266
284
  },
267
285
  Query: {
268
286
  async searchContentEntries(_, args, context) {
@@ -283,29 +301,16 @@ const createContentEntriesSchema = ({
283
301
  fields: fields || []
284
302
  });
285
303
  return items.map(entry => {
286
- return {
287
- id: entry.id,
288
- entryId: entry.entryId,
289
- model: {
290
- modelId: model.modelId,
291
- name: model.name
292
- },
293
- status: entry.status,
294
- title: (0, _getEntryTitle.getEntryTitle)(model, entry),
295
- // We need `savedOn` to sort entries from latest to oldest
296
- savedOn: entry.savedOn
297
- };
304
+ return createCmsEntryRecord(model, entry);
298
305
  });
299
306
  });
300
-
301
307
  try {
302
308
  const entries = await Promise.all(getters).then(results => results.reduce((result, item) => result.concat(item), []));
303
- return new _handlerGraphql.Response(entries.sort((a, b) => Date.parse(b.savedOn) - Date.parse(a.savedOn)).slice(0, limit));
309
+ return new _handlerGraphql.Response(entries.sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime()).slice(0, limit));
304
310
  } catch (ex) {
305
311
  return new _handlerGraphql.ErrorResponse(ex);
306
312
  }
307
313
  },
308
-
309
314
  async getContentEntry(_, args, context) {
310
315
  return getContentEntry({
311
316
  args,
@@ -313,7 +318,6 @@ const createContentEntriesSchema = ({
313
318
  type: "exact"
314
319
  });
315
320
  },
316
-
317
321
  async getLatestContentEntry(_, args, context) {
318
322
  return getContentEntry({
319
323
  args,
@@ -321,7 +325,6 @@ const createContentEntriesSchema = ({
321
325
  type: "latest"
322
326
  });
323
327
  },
324
-
325
328
  async getPublishedContentEntry(_, args, context) {
326
329
  return getContentEntry({
327
330
  args,
@@ -329,7 +332,6 @@ const createContentEntriesSchema = ({
329
332
  type: "published"
330
333
  });
331
334
  },
332
-
333
335
  async getContentEntries(_, args, context) {
334
336
  return getContentEntries({
335
337
  args,
@@ -337,7 +339,6 @@ const createContentEntriesSchema = ({
337
339
  type: "exact"
338
340
  });
339
341
  },
340
-
341
342
  async getLatestContentEntries(_, args, context) {
342
343
  return getContentEntries({
343
344
  args,
@@ -345,7 +346,6 @@ const createContentEntriesSchema = ({
345
346
  type: "latest"
346
347
  });
347
348
  },
348
-
349
349
  async getPublishedContentEntries(_, args, context) {
350
350
  return getContentEntries({
351
351
  args,
@@ -353,12 +353,10 @@ const createContentEntriesSchema = ({
353
353
  type: "published"
354
354
  });
355
355
  }
356
-
357
356
  }
358
357
  }
359
358
  });
360
- plugin.name = `headless-cms.graphql.schema.${context.cms.type}.contentEntries`;
359
+ plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;
361
360
  return plugin;
362
361
  };
363
-
364
362
  exports.createContentEntriesSchema = createContentEntriesSchema;
@@ -1 +1 @@
1
- {"version":3,"names":["getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","cms","GetContentEntryMethods","latest","published","exact","getContentEntries","params","args","method","models","listModels","modelsMap","reduce","collection","model","modelId","argsEntries","entries","entriesByModel","ref","includes","id","push","getters","Object","keys","map","length","Response","results","Promise","all","items","concat","item","entryId","name","status","title","getEntryTitle","filter","Boolean","ex","ErrorResponse","getContentEntry","entry","find","m","NotAuthorizedResponse","data","result","shift","createContentEntriesSchema","MANAGE","GraphQLSchemaPlugin","typeDefs","resolvers","plugin","CmsContentEntry","parent","_","getPublishedEntriesByIds","Query","searchContentEntries","modelIds","fields","query","limit","modelManager","getModelManager","where","listLatest","search","undefined","savedOn","then","sort","a","b","Date","parse","slice","getLatestContentEntry","getPublishedContentEntry","getLatestContentEntries","getPublishedContentEntries"],"sources":["contentEntries.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { CmsEntry, CmsContext, CmsModel, CmsEntryListWhere } from \"~/types\";\nimport { NotAuthorizedResponse } from \"@webiny/api-security\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle\";\nimport WebinyError from \"@webiny/error\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n}\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels();\n\n const modelsMap = models.reduce((collection, model) => {\n collection[model.modelId] = model;\n return collection;\n }, {} as Record<string, CmsModel>);\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return {\n id: item.id,\n entryId: item.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: item.status,\n title: getEntryTitle(model, item)\n };\n })\n );\n }, [] as CmsEntryRecord[])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels();\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response({\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry)\n });\n};\n\ninterface Params {\n context: CmsContext;\n}\nexport const createContentEntriesSchema = ({\n context\n}: Params): GraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n return new GraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n }\n\n const plugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: /* GraphQL */ `\n type CmsModelMeta {\n modelId: String\n name: String\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta\n status: String\n title: String\n published: CmsPublishedContentEntry\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return {\n id: entry.id,\n entryId: entry.entryId,\n title: getEntryTitle(model, entry)\n };\n } catch (ex) {\n return null;\n }\n }\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels();\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const modelManager = await context.cms.getModelManager(model.modelId);\n const where: CmsEntryListWhere = {};\n\n const [items] = await modelManager.listLatest({\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n\n return items.map((entry: CmsEntry) => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n // We need `savedOn` to sort entries from latest to oldest\n savedOn: entry.savedOn\n };\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => Date.parse(b.savedOn) - Date.parse(a.savedOn))\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.contentEntries`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AAuBA,MAAMA,cAAc,GAAG,CAACC,IAAD,EAA4BC,OAA5B,KAAiE;EACpF,IAAI,CAACC,wBAAwB,CAACF,IAAD,CAA7B,EAAqC;IACjC,MAAM,IAAIG,cAAJ,CACD,qCAAoCH,IAAK,qCADxC,EAEF,sBAFE,EAGF;MACIA;IADJ,CAHE,CAAN;EAOH;;EACD,MAAMI,UAAU,GAAGF,wBAAwB,CAACF,IAAD,CAA3C;;EACA,IAAI,CAACC,OAAO,CAACI,GAAR,CAAYD,UAAZ,CAAL,EAA8B;IAC1B,MAAM,IAAID,cAAJ,CACD,+BAA8BC,UAAW,qCADxC,EAEF,sBAFE,EAGF;MACIJ,IADJ;MAEII;IAFJ,CAHE,CAAN;EAQH;;EAED,OAAOH,OAAO,CAACI,GAAR,CAAYD,UAAZ,CAAP;AACH,CAvBD;AAwBA;AACA;AACA;;;IAQKE,sB;;WAAAA,sB;EAAAA,sB;EAAAA,sB;EAAAA,sB;GAAAA,sB,KAAAA,sB;;AAKL,MAAMJ,wBAAwB,GAAG;EAC7BK,MAAM,EAAE,uBADqB;EAE7BC,SAAS,EAAE,0BAFkB;EAG7BC,KAAK,EAAE;AAHsB,CAAjC;;AAKA,MAAMC,iBAAiB,GAAG,MACtBC,MADsB,IAEc;EACpC,MAAM;IAAEC,IAAF;IAAQX,OAAR;IAAiBD;EAAjB,IAA0BW,MAAhC;EAEA,MAAME,MAAM,GAAGd,cAAc,CAACC,IAAD,EAAOC,OAAP,CAA7B;EAEA,MAAMa,MAAM,GAAG,MAAMb,OAAO,CAACI,GAAR,CAAYU,UAAZ,EAArB;EAEA,MAAMC,SAAS,GAAGF,MAAM,CAACG,MAAP,CAAc,CAACC,UAAD,EAAaC,KAAb,KAAuB;IACnDD,UAAU,CAACC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AAjC,EAAoCrD,IAApC,EAA+CX,OAA/C,EAAwD;UACpD,OAAOS,iBAAiB,CAAC;YACrBE,IADqB;YAErBX,OAFqB;YAGrBD,IAAI,EAAE;UAHe,CAAD,CAAxB;QAKH;;MAzFE;IA3BA;EA5DoC,CAApC,CAAf;EAoLA8D,MAAM,CAACrB,IAAP,GAAe,+BAA8BxC,OAAO,CAACI,GAAR,CAAYL,IAAK,iBAA9D;EAEA,OAAO8D,MAAP;AACH,CAjMM"}
1
+ {"version":3,"names":["createDate","date","Date","createCmsEntryRecord","model","entry","id","entryId","modelId","name","status","title","getEntryTitle","description","getEntryDescription","image","getEntryImage","createdBy","modifiedBy","createdOn","savedOn","getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","cms","GetContentEntryMethods","latest","published","exact","getContentEntries","params","args","method","models","listModels","modelsMap","reduce","collection","argsEntries","entries","entriesByModel","ref","includes","push","getters","Object","keys","map","length","Response","results","Promise","all","items","concat","item","filter","Boolean","ex","ErrorResponse","getContentEntry","find","m","NotAuthorizedResponse","data","result","shift","createResolveDescription","parent","_","field","fields","f","fieldId","descriptionFieldId","value","entryFieldFromStorageTransform","createContentEntriesSchema","MANAGE","plugin","CmsGraphQLSchemaPlugin","typeDefs","resolvers","CmsContentEntry","getPublishedEntriesByIds","CmsPublishedContentEntry","Query","searchContentEntries","modelIds","query","limit","modelManager","getModelManager","where","listLatest","search","undefined","then","sort","a","b","getTime","slice","getLatestContentEntry","getPublishedContentEntry","getLatestContentEntries","getPublishedContentEntries"],"sources":["contentEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { CmsEntry, CmsContext, CmsModel, CmsEntryListWhere, CmsIdentity } from \"~/types\";\nimport { NotAuthorizedResponse } from \"@webiny/api-security\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription\";\nimport { getEntryImage } from \"~/utils/getEntryImage\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage\";\nimport { Resolvers } from \"@webiny/handler-graphql/types\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string): Date => {\n try {\n return new Date(date);\n } catch {}\n return new Date();\n};\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n createdBy: CmsIdentity;\n modifiedBy?: CmsIdentity | null;\n /**\n * We can use the number since it is an internal field.\n * Created via Date.parse() method.\n */\n createdOn: Date;\n savedOn: Date;\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n createdBy: entry.createdBy,\n modifiedBy: entry.modifiedBy,\n createdOn: createDate(entry.createdOn),\n savedOn: createDate(entry.savedOn)\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels();\n\n const modelsMap = models.reduce((collection, model) => {\n collection[model.modelId] = model;\n return collection;\n }, {} as Record<string, CmsModel>);\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels();\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): Resolvers<CmsContext> => {\n return async (parent, _, context) => {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\nexport const createContentEntriesSchema = ({\n context\n}: Params): CmsGraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;\n return plugin;\n }\n\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n title: String!\n description: String\n image: String\n createdBy: CmsIdentity!\n ownedBy: CmsIdentity!\n modifiedBy: CmsIdentity\n published: CmsPublishedContentEntry\n createdOn: DateTime!\n savedOn: DateTime!\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch (ex) {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels();\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const modelManager = await context.cms.getModelManager(model.modelId);\n const where: CmsEntryListWhere = {};\n\n const [items] = await modelManager.listLatest({\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n\n return items.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AASA,MAAMA,UAAU,GAAIC,IAAY,IAAW;EACvC,IAAI;IACA,OAAO,IAAIC,IAAI,CAACD,IAAI,CAAC;EACzB,CAAC,CAAC,MAAM,CAAC;EACT,OAAO,IAAIC,IAAI,EAAE;AACrB,CAAC;AAsBD,MAAMC,oBAAoB,GAAG,CAACC,KAAe,EAAEC,KAAe,KAAqB;EAC/E,OAAO;IACHC,EAAE,EAAED,KAAK,CAACC,EAAE;IACZC,OAAO,EAAEF,KAAK,CAACE,OAAO;IACtBH,KAAK,EAAE;MACHI,OAAO,EAAEJ,KAAK,CAACI,OAAO;MACtBC,IAAI,EAAEL,KAAK,CAACK;IAChB,CAAC;IACDC,MAAM,EAAEL,KAAK,CAACK,MAAM;IACpBC,KAAK,EAAE,IAAAC,4BAAa,EAACR,KAAK,EAAEC,KAAK,CAAC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AAC,CAAC;QACN,CAAC;QACD,MAAMsF,uBAAuB,CAACpC,CAAC,EAAEtC,IAAS,EAAEX,OAAO,EAAE;UACjD,OAAOS,iBAAiB,CAAC;YACrBE,IAAI;YACJX,OAAO;YACPD,IAAI,EAAE;UACV,CAAC,CAAC;QACN,CAAC;QACD,MAAMuF,0BAA0B,CAACrC,CAAC,EAAEtC,IAAS,EAAEX,OAAO,EAAE;UACpD,OAAOS,iBAAiB,CAAC;YACrBE,IAAI;YACJX,OAAO;YACPD,IAAI,EAAE;UACV,CAAC,CAAC;QACN;MACJ;IACJ;EACJ,CAAC,CAAC;EAEF4D,MAAM,CAACzE,IAAI,GAAI,+BAA8Bc,OAAO,CAACI,GAAG,CAACL,IAAK,kBAAiB;EAE/E,OAAO4D,MAAM;AACjB,CAAC;AAAC"}
@@ -1,7 +1,7 @@
1
1
  import { CmsContext } from "../../types";
2
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin";
2
+ import { CmsGraphQLSchemaPlugin } from "../../plugins";
3
3
  interface Params {
4
4
  context: CmsContext;
5
5
  }
6
- export declare const createGroupsSchema: ({ context }: Params) => GraphQLSchemaPlugin<CmsContext>;
6
+ export declare const createGroupsSchema: ({ context }: Params) => CmsGraphQLSchemaPlugin;
7
7
  export {};