@webiny/api-headless-cms 0.0.0-mt-2 → 0.0.0-unstable.1145e7667f

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 (677) hide show
  1. package/context.d.ts +6 -0
  2. package/context.js +98 -0
  3. package/context.js.map +1 -0
  4. package/crud/contentEntry/afterDelete.d.ts +8 -0
  5. package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +2 -7
  6. package/crud/contentEntry/afterDelete.js.map +1 -0
  7. package/crud/contentEntry/beforeCreate.d.ts +8 -0
  8. package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +2 -5
  9. package/crud/contentEntry/beforeCreate.js.map +1 -0
  10. package/crud/contentEntry/beforeUpdate.d.ts +8 -0
  11. package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +2 -5
  12. package/crud/contentEntry/beforeUpdate.js.map +1 -0
  13. package/crud/contentEntry/entryDataValidation.d.ts +10 -0
  14. package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +22 -49
  15. package/crud/contentEntry/entryDataValidation.js.map +1 -0
  16. package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +3 -2
  17. package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +29 -43
  18. package/crud/contentEntry/markLockedFields.js.map +1 -0
  19. package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
  20. package/crud/contentEntry/referenceFieldsMapping.js +265 -0
  21. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
  22. package/crud/contentEntry/searchableFields.d.ts +9 -0
  23. package/crud/contentEntry/searchableFields.js +72 -0
  24. package/crud/contentEntry/searchableFields.js.map +1 -0
  25. package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +7 -8
  26. package/crud/contentEntry.crud.js +1212 -0
  27. package/crud/contentEntry.crud.js.map +1 -0
  28. package/crud/contentModel/afterCreate.d.ts +8 -0
  29. package/crud/contentModel/afterCreate.js +16 -0
  30. package/crud/contentModel/afterCreate.js.map +1 -0
  31. package/crud/contentModel/afterCreateFrom.d.ts +8 -0
  32. package/crud/contentModel/afterCreateFrom.js +16 -0
  33. package/crud/contentModel/afterCreateFrom.js.map +1 -0
  34. package/crud/contentModel/afterDelete.d.ts +8 -0
  35. package/crud/contentModel/afterDelete.js +16 -0
  36. package/crud/contentModel/afterDelete.js.map +1 -0
  37. package/crud/contentModel/afterUpdate.d.ts +8 -0
  38. package/crud/contentModel/afterUpdate.js +16 -0
  39. package/crud/contentModel/afterUpdate.js.map +1 -0
  40. package/crud/contentModel/beforeCreate.d.ts +14 -0
  41. package/crud/contentModel/beforeCreate.js +128 -0
  42. package/crud/contentModel/beforeCreate.js.map +1 -0
  43. package/crud/contentModel/beforeDelete.d.ts +10 -0
  44. package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +8 -18
  45. package/crud/contentModel/beforeDelete.js.map +1 -0
  46. package/crud/contentModel/beforeUpdate.d.ts +8 -0
  47. package/crud/contentModel/beforeUpdate.js +60 -0
  48. package/crud/contentModel/beforeUpdate.js.map +1 -0
  49. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  50. package/crud/contentModel/compatibility/modelApiName.js +24 -0
  51. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  52. package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
  53. package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -7
  54. package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
  55. package/crud/contentModel/createFieldModels.d.ts +2 -0
  56. package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +6 -2
  57. package/crud/contentModel/createFieldModels.js.map +1 -0
  58. package/crud/contentModel/createFieldStorageId.d.ts +2 -0
  59. package/crud/contentModel/createFieldStorageId.js +17 -0
  60. package/crud/contentModel/createFieldStorageId.js.map +1 -0
  61. package/crud/contentModel/defaultFields.d.ts +5 -0
  62. package/crud/contentModel/defaultFields.js +58 -0
  63. package/crud/contentModel/defaultFields.js.map +1 -0
  64. package/crud/contentModel/fieldIdValidation.d.ts +1 -0
  65. package/crud/contentModel/fieldIdValidation.js +25 -0
  66. package/crud/contentModel/fieldIdValidation.js.map +1 -0
  67. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  68. package/crud/contentModel/fields/descriptionField.js +42 -0
  69. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  70. package/crud/contentModel/fields/imageField.d.ts +2 -0
  71. package/crud/contentModel/fields/imageField.js +46 -0
  72. package/crud/contentModel/fields/imageField.js.map +1 -0
  73. package/crud/contentModel/fields/titleField.d.ts +2 -0
  74. package/crud/contentModel/fields/titleField.js +58 -0
  75. package/crud/contentModel/fields/titleField.js.map +1 -0
  76. package/crud/contentModel/idValidation.d.ts +1 -0
  77. package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
  78. package/crud/contentModel/idValidation.js.map +1 -0
  79. package/{content/plugins/crud → crud}/contentModel/models.d.ts +2 -1
  80. package/{content/plugins/crud → crud}/contentModel/models.js +76 -25
  81. package/crud/contentModel/models.js.map +1 -0
  82. package/crud/contentModel/systemFields.d.ts +1 -0
  83. package/crud/contentModel/systemFields.js +8 -0
  84. package/crud/contentModel/systemFields.js.map +1 -0
  85. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  86. package/crud/contentModel/validate/endingAllowed.js +26 -0
  87. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  88. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  89. package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
  90. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  91. package/crud/contentModel/validate/modelId.d.ts +11 -0
  92. package/crud/contentModel/validate/modelId.js +36 -0
  93. package/crud/contentModel/validate/modelId.js.map +1 -0
  94. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  95. package/crud/contentModel/validate/pluralApiName.js +24 -0
  96. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  97. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  98. package/crud/contentModel/validate/singularApiName.js +24 -0
  99. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  100. package/crud/contentModel/validateLayout.d.ts +2 -0
  101. package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -11
  102. package/crud/contentModel/validateLayout.js.map +1 -0
  103. package/crud/contentModel/validateModel.d.ts +9 -0
  104. package/crud/contentModel/validateModel.js +27 -0
  105. package/crud/contentModel/validateModel.js.map +1 -0
  106. package/crud/contentModel/validateModelFields.d.ts +9 -0
  107. package/crud/contentModel/validateModelFields.js +342 -0
  108. package/crud/contentModel/validateModelFields.js.map +1 -0
  109. package/crud/contentModel/validation.d.ts +551 -0
  110. package/crud/contentModel/validation.js +145 -0
  111. package/crud/contentModel/validation.js.map +1 -0
  112. package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
  113. package/crud/contentModel.crud.js +616 -0
  114. package/crud/contentModel.crud.js.map +1 -0
  115. package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
  116. package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +8 -20
  117. package/crud/contentModelGroup/beforeCreate.js.map +1 -0
  118. package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
  119. package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +4 -12
  120. package/crud/contentModelGroup/beforeDelete.js.map +1 -0
  121. package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
  122. package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +3 -8
  123. package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
  124. package/crud/contentModelGroup/validation.d.ts +30 -0
  125. package/crud/contentModelGroup/validation.js +34 -0
  126. package/crud/contentModelGroup/validation.js.map +1 -0
  127. package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
  128. package/crud/contentModelGroup.crud.js +352 -0
  129. package/crud/contentModelGroup.crud.js.map +1 -0
  130. package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
  131. package/crud/settings.crud.js +66 -0
  132. package/crud/settings.crud.js.map +1 -0
  133. package/{plugins/crud → crud}/system.crud.d.ts +6 -3
  134. package/crud/system.crud.js +126 -0
  135. package/crud/system.crud.js.map +1 -0
  136. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
  137. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +53 -0
  138. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
  139. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
  140. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
  141. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
  142. package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
  143. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +251 -0
  144. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
  145. package/fieldConverters/index.d.ts +4 -0
  146. package/fieldConverters/index.js +13 -0
  147. package/fieldConverters/index.js.map +1 -0
  148. package/graphql/buildSchemaPlugins.d.ts +11 -0
  149. package/graphql/buildSchemaPlugins.js +19 -0
  150. package/graphql/buildSchemaPlugins.js.map +1 -0
  151. package/graphql/checkEndpointAccess.d.ts +2 -0
  152. package/graphql/checkEndpointAccess.js +18 -0
  153. package/graphql/checkEndpointAccess.js.map +1 -0
  154. package/graphql/createExecutableSchema.d.ts +6 -0
  155. package/graphql/createExecutableSchema.js +29 -0
  156. package/graphql/createExecutableSchema.js.map +1 -0
  157. package/graphql/createRequestBody.d.ts +2 -0
  158. package/graphql/createRequestBody.js +14 -0
  159. package/graphql/createRequestBody.js.map +1 -0
  160. package/graphql/formatErrorPayload.d.ts +1 -0
  161. package/graphql/formatErrorPayload.js +25 -0
  162. package/graphql/formatErrorPayload.js.map +1 -0
  163. package/graphql/generateSchema.d.ts +8 -0
  164. package/graphql/generateSchema.js +31 -0
  165. package/graphql/generateSchema.js.map +1 -0
  166. package/graphql/getSchema.d.ts +17 -0
  167. package/graphql/getSchema.js +102 -0
  168. package/graphql/getSchema.js.map +1 -0
  169. package/graphql/graphQLHandlerFactory.d.ts +5 -0
  170. package/graphql/graphQLHandlerFactory.js +35 -0
  171. package/graphql/graphQLHandlerFactory.js.map +1 -0
  172. package/graphql/handleRequest.d.ts +11 -0
  173. package/graphql/handleRequest.js +81 -0
  174. package/graphql/handleRequest.js.map +1 -0
  175. package/graphql/index.d.ts +3 -0
  176. package/graphql/index.js +13 -0
  177. package/graphql/index.js.map +1 -0
  178. package/graphql/schema/baseContentSchema.d.ts +7 -0
  179. package/graphql/schema/baseContentSchema.js +66 -0
  180. package/graphql/schema/baseContentSchema.js.map +1 -0
  181. package/graphql/schema/baseSchema.d.ts +3 -0
  182. package/graphql/schema/baseSchema.js +53 -0
  183. package/graphql/schema/baseSchema.js.map +1 -0
  184. package/graphql/schema/contentEntries.d.ts +7 -0
  185. package/graphql/schema/contentEntries.js +362 -0
  186. package/graphql/schema/contentEntries.js.map +1 -0
  187. package/graphql/schema/contentModelGroups.d.ts +7 -0
  188. package/{content/plugins → graphql}/schema/contentModelGroups.js +39 -33
  189. package/graphql/schema/contentModelGroups.js.map +1 -0
  190. package/graphql/schema/contentModels.d.ts +7 -0
  191. package/{content/plugins → graphql}/schema/contentModels.js +121 -29
  192. package/graphql/schema/contentModels.js.map +1 -0
  193. package/graphql/schema/createFieldResolvers.d.ts +20 -0
  194. package/graphql/schema/createFieldResolvers.js +111 -0
  195. package/graphql/schema/createFieldResolvers.js.map +1 -0
  196. package/graphql/schema/createManageResolvers.d.ts +12 -0
  197. package/graphql/schema/createManageResolvers.js +127 -0
  198. package/graphql/schema/createManageResolvers.js.map +1 -0
  199. package/graphql/schema/createManageSDL.d.ts +13 -0
  200. package/graphql/schema/createManageSDL.js +157 -0
  201. package/graphql/schema/createManageSDL.js.map +1 -0
  202. package/graphql/schema/createPreviewResolvers.d.ts +12 -0
  203. package/graphql/schema/createPreviewResolvers.js +44 -0
  204. package/graphql/schema/createPreviewResolvers.js.map +1 -0
  205. package/graphql/schema/createReadResolvers.d.ts +12 -0
  206. package/graphql/schema/createReadResolvers.js +49 -0
  207. package/graphql/schema/createReadResolvers.js.map +1 -0
  208. package/graphql/schema/createReadSDL.d.ts +13 -0
  209. package/graphql/schema/createReadSDL.js +100 -0
  210. package/graphql/schema/createReadSDL.js.map +1 -0
  211. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +7 -0
  212. package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +2 -3
  213. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
  214. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
  215. package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +2 -7
  216. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
  217. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
  218. package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +2 -7
  219. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
  220. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
  221. package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +8 -12
  222. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
  223. package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
  224. package/graphql/schema/resolvers/manage/resolveGet.js +63 -0
  225. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
  226. package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
  227. package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -7
  228. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
  229. package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
  230. package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +2 -7
  231. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
  232. package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
  233. package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/manage}/resolveList.js +2 -7
  234. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
  235. package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
  236. package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -3
  237. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
  238. package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
  239. package/{content/plugins/schema/resolvers/manage/resolveGet.js → graphql/schema/resolvers/manage/resolveRepublish.js} +4 -7
  240. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
  241. package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
  242. package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -3
  243. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
  244. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
  245. package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +2 -7
  246. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
  247. package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
  248. package/graphql/schema/resolvers/preview/resolveGet.js +26 -0
  249. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
  250. package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
  251. package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/preview}/resolveList.js +2 -7
  252. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
  253. package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
  254. package/graphql/schema/resolvers/read/resolveGet.js +26 -0
  255. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
  256. package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
  257. package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +2 -7
  258. package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
  259. package/graphql/schema/schemaPlugins.d.ts +8 -0
  260. package/graphql/schema/schemaPlugins.js +109 -0
  261. package/graphql/schema/schemaPlugins.js.map +1 -0
  262. package/graphql/system.d.ts +6 -0
  263. package/{plugins/graphql → graphql}/system.js +39 -24
  264. package/graphql/system.js.map +1 -0
  265. package/graphqlFields/boolean.d.ts +2 -0
  266. package/graphqlFields/boolean.js +57 -0
  267. package/graphqlFields/boolean.js.map +1 -0
  268. package/graphqlFields/datetime.d.ts +2 -0
  269. package/graphqlFields/datetime.js +78 -0
  270. package/graphqlFields/datetime.js.map +1 -0
  271. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
  272. package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
  273. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
  274. package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
  275. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
  276. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
  277. package/graphqlFields/dynamicZone/index.d.ts +2 -0
  278. package/graphqlFields/dynamicZone/index.js +19 -0
  279. package/graphqlFields/dynamicZone/index.js.map +1 -0
  280. package/graphqlFields/file.d.ts +2 -0
  281. package/graphqlFields/file.js +42 -0
  282. package/graphqlFields/file.js.map +1 -0
  283. package/graphqlFields/helpers.d.ts +6 -0
  284. package/graphqlFields/helpers.js +39 -0
  285. package/graphqlFields/helpers.js.map +1 -0
  286. package/graphqlFields/index.d.ts +2 -0
  287. package/graphqlFields/index.js +18 -0
  288. package/graphqlFields/index.js.map +1 -0
  289. package/graphqlFields/longText.d.ts +2 -0
  290. package/graphqlFields/longText.js +53 -0
  291. package/graphqlFields/longText.js.map +1 -0
  292. package/graphqlFields/number.d.ts +2 -0
  293. package/graphqlFields/number.js +67 -0
  294. package/graphqlFields/number.js.map +1 -0
  295. package/graphqlFields/object.d.ts +2 -0
  296. package/graphqlFields/object.js +258 -0
  297. package/graphqlFields/object.js.map +1 -0
  298. package/graphqlFields/ref.d.ts +2 -0
  299. package/graphqlFields/ref.js +255 -0
  300. package/graphqlFields/ref.js.map +1 -0
  301. package/graphqlFields/richText.d.ts +2 -0
  302. package/graphqlFields/richText.js +47 -0
  303. package/graphqlFields/richText.js.map +1 -0
  304. package/graphqlFields/text.d.ts +2 -0
  305. package/graphqlFields/text.js +62 -0
  306. package/graphqlFields/text.js.map +1 -0
  307. package/index.d.ts +12 -12
  308. package/index.js +98 -55
  309. package/index.js.map +1 -0
  310. package/modelManager/DefaultCmsModelManager.d.ts +14 -0
  311. package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +10 -24
  312. package/modelManager/DefaultCmsModelManager.js.map +1 -0
  313. package/modelManager/index.d.ts +2 -0
  314. package/{content/plugins/modelManager → modelManager}/index.js +3 -7
  315. package/modelManager/index.js.map +1 -0
  316. package/package.json +37 -38
  317. package/parameters/context.d.ts +2 -0
  318. package/parameters/context.js +18 -0
  319. package/parameters/context.js.map +1 -0
  320. package/parameters/header.d.ts +2 -0
  321. package/parameters/header.js +44 -0
  322. package/parameters/header.js.map +1 -0
  323. package/parameters/index.d.ts +4 -0
  324. package/parameters/index.js +49 -0
  325. package/parameters/index.js.map +1 -0
  326. package/parameters/manual.d.ts +6 -0
  327. package/parameters/manual.js +37 -0
  328. package/parameters/manual.js.map +1 -0
  329. package/parameters/path.d.ts +2 -0
  330. package/parameters/path.js +40 -0
  331. package/parameters/path.js.map +1 -0
  332. package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
  333. package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
  334. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
  335. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
  336. package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
  337. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
  338. package/plugins/CmsGroupPlugin.d.ts +13 -0
  339. package/{content/plugins → plugins}/CmsGroupPlugin.js +7 -9
  340. package/plugins/CmsGroupPlugin.js.map +1 -0
  341. package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
  342. package/plugins/CmsModelFieldConverterPlugin.js +12 -0
  343. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
  344. package/plugins/CmsModelPlugin.d.ts +61 -0
  345. package/plugins/CmsModelPlugin.js +184 -0
  346. package/plugins/CmsModelPlugin.js.map +1 -0
  347. package/plugins/CmsParametersPlugin.d.ts +20 -0
  348. package/plugins/CmsParametersPlugin.js +21 -0
  349. package/plugins/CmsParametersPlugin.js.map +1 -0
  350. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  351. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  352. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  353. package/plugins/StorageTransformPlugin.d.ts +31 -0
  354. package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -10
  355. package/plugins/StorageTransformPlugin.js.map +1 -0
  356. package/plugins/index.d.ts +8 -0
  357. package/plugins/index.js +93 -0
  358. package/plugins/index.js.map +1 -0
  359. package/storage/default.d.ts +2 -0
  360. package/storage/default.js +24 -0
  361. package/storage/default.js.map +1 -0
  362. package/storage/object.d.ts +2 -0
  363. package/storage/object.js +108 -0
  364. package/storage/object.js.map +1 -0
  365. package/types.d.ts +920 -374
  366. package/types.js +105 -62
  367. package/types.js.map +1 -0
  368. package/upgrades/5.33.0/index.d.ts +3 -0
  369. package/upgrades/5.33.0/index.js +182 -0
  370. package/upgrades/5.33.0/index.js.map +1 -0
  371. package/upgrades/index.d.ts +1 -0
  372. package/upgrades/index.js +12 -0
  373. package/upgrades/index.js.map +1 -0
  374. package/utils/access.d.ts +8 -0
  375. package/utils/access.js +76 -0
  376. package/utils/access.js.map +1 -0
  377. package/utils/converters/Converter.d.ts +27 -0
  378. package/utils/converters/Converter.js +58 -0
  379. package/utils/converters/Converter.js.map +1 -0
  380. package/utils/converters/ConverterCollection.d.ts +31 -0
  381. package/utils/converters/ConverterCollection.js +119 -0
  382. package/utils/converters/ConverterCollection.js.map +1 -0
  383. package/utils/converters/valueKeyStorageConverter.d.ts +14 -0
  384. package/utils/converters/valueKeyStorageConverter.js +125 -0
  385. package/utils/converters/valueKeyStorageConverter.js.map +1 -0
  386. package/utils/createTypeFromFields.d.ts +16 -0
  387. package/utils/createTypeFromFields.js +66 -0
  388. package/utils/createTypeFromFields.js.map +1 -0
  389. package/utils/createTypeName.d.ts +1 -0
  390. package/utils/createTypeName.js +13 -0
  391. package/utils/createTypeName.js.map +1 -0
  392. package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
  393. package/{content/plugins/utils → utils}/entryStorage.js +26 -47
  394. package/utils/entryStorage.js.map +1 -0
  395. package/utils/filterAsync.d.ts +1 -0
  396. package/utils/filterAsync.js +18 -0
  397. package/utils/filterAsync.js.map +1 -0
  398. package/utils/getBaseFieldType.d.ts +4 -0
  399. package/utils/getBaseFieldType.js +10 -0
  400. package/utils/getBaseFieldType.js.map +1 -0
  401. package/utils/getEntryDescription.d.ts +2 -0
  402. package/utils/getEntryDescription.js +17 -0
  403. package/utils/getEntryDescription.js.map +1 -0
  404. package/utils/getEntryImage.d.ts +2 -0
  405. package/utils/getEntryImage.js +17 -0
  406. package/utils/getEntryImage.js.map +1 -0
  407. package/utils/getEntryTitle.d.ts +2 -0
  408. package/{content/plugins/utils → utils}/getEntryTitle.js +7 -15
  409. package/utils/getEntryTitle.js.map +1 -0
  410. package/utils/getSchemaFromFieldPlugins.d.ts +9 -0
  411. package/utils/getSchemaFromFieldPlugins.js +39 -0
  412. package/utils/getSchemaFromFieldPlugins.js.map +1 -0
  413. package/utils/incrementEntryIdVersion.d.ts +5 -0
  414. package/utils/incrementEntryIdVersion.js +29 -0
  415. package/utils/incrementEntryIdVersion.js.map +1 -0
  416. package/utils/ownership.d.ts +8 -0
  417. package/utils/ownership.js +33 -0
  418. package/utils/ownership.js.map +1 -0
  419. package/utils/permissions.d.ts +7 -0
  420. package/utils/permissions.js +91 -0
  421. package/utils/permissions.js.map +1 -0
  422. package/utils/pluralizedTypeName.d.ts +1 -0
  423. package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -1
  424. package/utils/pluralizedTypeName.js.map +1 -0
  425. package/utils/renderFields.d.ts +16 -0
  426. package/{content/plugins/utils → utils}/renderFields.js +14 -12
  427. package/utils/renderFields.js.map +1 -0
  428. package/utils/renderGetFilterFields.d.ts +10 -0
  429. package/utils/renderGetFilterFields.js +48 -0
  430. package/utils/renderGetFilterFields.js.map +1 -0
  431. package/utils/renderInputFields.d.ts +15 -0
  432. package/{content/plugins/utils → utils}/renderInputFields.js +7 -10
  433. package/utils/renderInputFields.js.map +1 -0
  434. package/utils/renderListFilterFields.d.ts +11 -0
  435. package/{content/plugins/utils → utils}/renderListFilterFields.js +36 -22
  436. package/utils/renderListFilterFields.js.map +1 -0
  437. package/utils/renderSortEnum.d.ts +12 -0
  438. package/utils/renderSortEnum.js +42 -0
  439. package/utils/renderSortEnum.js.map +1 -0
  440. package/utils/toSlug.d.ts +1 -0
  441. package/utils/toSlug.js +16 -0
  442. package/utils/toSlug.js.map +1 -0
  443. package/validators/dateGte.d.ts +2 -0
  444. package/{content/plugins/validators → validators}/dateGte.js +4 -11
  445. package/validators/dateGte.js.map +1 -0
  446. package/validators/dateLte.d.ts +2 -0
  447. package/{content/plugins/validators → validators}/dateLte.js +4 -11
  448. package/validators/dateLte.js.map +1 -0
  449. package/validators/dynamicZone.d.ts +2 -0
  450. package/validators/dynamicZone.js +20 -0
  451. package/validators/dynamicZone.js.map +1 -0
  452. package/validators/gte.d.ts +2 -0
  453. package/validators/gte.js +28 -0
  454. package/validators/gte.js.map +1 -0
  455. package/validators/in.d.ts +2 -0
  456. package/validators/in.js +28 -0
  457. package/validators/in.js.map +1 -0
  458. package/validators/index.d.ts +1 -0
  459. package/validators/index.js +22 -0
  460. package/validators/index.js.map +1 -0
  461. package/validators/lte.d.ts +2 -0
  462. package/validators/lte.js +28 -0
  463. package/validators/lte.js.map +1 -0
  464. package/validators/maxLength.d.ts +2 -0
  465. package/validators/maxLength.js +28 -0
  466. package/validators/maxLength.js.map +1 -0
  467. package/validators/minLength.d.ts +2 -0
  468. package/validators/minLength.js +28 -0
  469. package/validators/minLength.js.map +1 -0
  470. package/validators/pattern.d.ts +2 -0
  471. package/validators/pattern.js +41 -0
  472. package/validators/pattern.js.map +1 -0
  473. package/validators/patternPlugins/email.d.ts +2 -0
  474. package/validators/patternPlugins/email.js +18 -0
  475. package/validators/patternPlugins/email.js.map +1 -0
  476. package/validators/patternPlugins/index.d.ts +2 -0
  477. package/validators/patternPlugins/index.js +16 -0
  478. package/validators/patternPlugins/index.js.map +1 -0
  479. package/validators/patternPlugins/lowerCase.d.ts +2 -0
  480. package/validators/patternPlugins/lowerCase.js +18 -0
  481. package/validators/patternPlugins/lowerCase.js.map +1 -0
  482. package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
  483. package/validators/patternPlugins/lowerCaseSpace.js +18 -0
  484. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
  485. package/validators/patternPlugins/upperCase.d.ts +2 -0
  486. package/validators/patternPlugins/upperCase.js +18 -0
  487. package/validators/patternPlugins/upperCase.js.map +1 -0
  488. package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
  489. package/validators/patternPlugins/upperCaseSpace.js +18 -0
  490. package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
  491. package/validators/patternPlugins/url.d.ts +2 -0
  492. package/validators/patternPlugins/url.js +18 -0
  493. package/validators/patternPlugins/url.js.map +1 -0
  494. package/validators/required.d.ts +2 -0
  495. package/validators/required.js +22 -0
  496. package/validators/required.js.map +1 -0
  497. package/validators/timeGte.d.ts +2 -0
  498. package/{content/plugins/validators → validators}/timeGte.js +5 -11
  499. package/validators/timeGte.js.map +1 -0
  500. package/validators/timeLte.d.ts +2 -0
  501. package/{content/plugins/validators → validators}/timeLte.js +5 -11
  502. package/validators/timeLte.js.map +1 -0
  503. package/validators/unique.d.ts +6 -0
  504. package/validators/unique.js +56 -0
  505. package/validators/unique.js.map +1 -0
  506. package/content/contextSetup.d.ts +0 -4
  507. package/content/contextSetup.js +0 -65
  508. package/content/graphQLHandlerFactory.d.ts +0 -5
  509. package/content/graphQLHandlerFactory.js +0 -173
  510. package/content/plugins/CmsGroupPlugin.d.ts +0 -11
  511. package/content/plugins/CmsModelPlugin.d.ts +0 -11
  512. package/content/plugins/CmsModelPlugin.js +0 -24
  513. package/content/plugins/buildSchemaPlugins.d.ts +0 -7
  514. package/content/plugins/buildSchemaPlugins.js +0 -29
  515. package/content/plugins/crud/contentEntry/afterDelete.d.ts +0 -7
  516. package/content/plugins/crud/contentEntry/beforeCreate.d.ts +0 -7
  517. package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +0 -7
  518. package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +0 -4
  519. package/content/plugins/crud/contentEntry.crud.js +0 -931
  520. package/content/plugins/crud/contentModel/afterCreate.d.ts +0 -7
  521. package/content/plugins/crud/contentModel/afterCreate.js +0 -18
  522. package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
  523. package/content/plugins/crud/contentModel/afterDelete.js +0 -18
  524. package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
  525. package/content/plugins/crud/contentModel/afterUpdate.js +0 -18
  526. package/content/plugins/crud/contentModel/beforeCreate.d.ts +0 -9
  527. package/content/plugins/crud/contentModel/beforeCreate.js +0 -146
  528. package/content/plugins/crud/contentModel/beforeDelete.d.ts +0 -9
  529. package/content/plugins/crud/contentModel/beforeUpdate.d.ts +0 -9
  530. package/content/plugins/crud/contentModel/beforeUpdate.js +0 -128
  531. package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +0 -2
  532. package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
  533. package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
  534. package/content/plugins/crud/contentModel/validateLayout.d.ts +0 -2
  535. package/content/plugins/crud/contentModel.crud.js +0 -425
  536. package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +0 -9
  537. package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +0 -9
  538. package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +0 -8
  539. package/content/plugins/crud/contentModelGroup.crud.js +0 -351
  540. package/content/plugins/crud/index.d.ts +0 -6
  541. package/content/plugins/crud/index.js +0 -100
  542. package/content/plugins/graphqlFields/boolean.d.ts +0 -3
  543. package/content/plugins/graphqlFields/boolean.js +0 -69
  544. package/content/plugins/graphqlFields/datetime.d.ts +0 -3
  545. package/content/plugins/graphqlFields/datetime.js +0 -83
  546. package/content/plugins/graphqlFields/file.d.ts +0 -3
  547. package/content/plugins/graphqlFields/file.js +0 -49
  548. package/content/plugins/graphqlFields/index.d.ts +0 -2
  549. package/content/plugins/graphqlFields/index.js +0 -30
  550. package/content/plugins/graphqlFields/longText.d.ts +0 -3
  551. package/content/plugins/graphqlFields/longText.js +0 -62
  552. package/content/plugins/graphqlFields/number.d.ts +0 -3
  553. package/content/plugins/graphqlFields/number.js +0 -75
  554. package/content/plugins/graphqlFields/object.d.ts +0 -3
  555. package/content/plugins/graphqlFields/object.js +0 -180
  556. package/content/plugins/graphqlFields/ref.d.ts +0 -3
  557. package/content/plugins/graphqlFields/ref.js +0 -205
  558. package/content/plugins/graphqlFields/richText.d.ts +0 -3
  559. package/content/plugins/graphqlFields/richText.js +0 -55
  560. package/content/plugins/graphqlFields/text.d.ts +0 -3
  561. package/content/plugins/graphqlFields/text.js +0 -72
  562. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
  563. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -54
  564. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
  565. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -35
  566. package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -15
  567. package/content/plugins/modelManager/index.d.ts +0 -3
  568. package/content/plugins/schema/baseSchema.d.ts +0 -4
  569. package/content/plugins/schema/baseSchema.js +0 -98
  570. package/content/plugins/schema/contentEntries.d.ts +0 -4
  571. package/content/plugins/schema/contentEntries.js +0 -166
  572. package/content/plugins/schema/contentModelGroups.d.ts +0 -4
  573. package/content/plugins/schema/contentModels.d.ts +0 -4
  574. package/content/plugins/schema/createFieldResolvers.d.ts +0 -19
  575. package/content/plugins/schema/createFieldResolvers.js +0 -92
  576. package/content/plugins/schema/createManageResolvers.d.ts +0 -11
  577. package/content/plugins/schema/createManageResolvers.js +0 -135
  578. package/content/plugins/schema/createManageSDL.d.ts +0 -9
  579. package/content/plugins/schema/createManageSDL.js +0 -153
  580. package/content/plugins/schema/createPreviewResolvers.d.ts +0 -10
  581. package/content/plugins/schema/createPreviewResolvers.js +0 -55
  582. package/content/plugins/schema/createReadResolvers.d.ts +0 -10
  583. package/content/plugins/schema/createReadResolvers.js +0 -55
  584. package/content/plugins/schema/createReadSDL.d.ts +0 -9
  585. package/content/plugins/schema/createReadSDL.js +0 -96
  586. package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
  587. package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +0 -6
  588. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +0 -7
  589. package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +0 -2
  590. package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +0 -2
  591. package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +0 -2
  592. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +0 -2
  593. package/content/plugins/schema/resolvers/manage/resolveList.d.ts +0 -2
  594. package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +0 -2
  595. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -6
  596. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +0 -23
  597. package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +0 -6
  598. package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +0 -23
  599. package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +0 -2
  600. package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +0 -7
  601. package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +0 -2
  602. package/content/plugins/schema/resolvers/preview/resolveGet.js +0 -38
  603. package/content/plugins/schema/resolvers/preview/resolveList.d.ts +0 -2
  604. package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
  605. package/content/plugins/schema/resolvers/read/resolveGet.js +0 -38
  606. package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
  607. package/content/plugins/schema/schemaPlugins.d.ts +0 -3
  608. package/content/plugins/schema/schemaPlugins.js +0 -92
  609. package/content/plugins/storage/StorageTransformPlugin.d.ts +0 -30
  610. package/content/plugins/storage/default.d.ts +0 -3
  611. package/content/plugins/storage/default.js +0 -28
  612. package/content/plugins/storage/object.d.ts +0 -3
  613. package/content/plugins/storage/object.js +0 -119
  614. package/content/plugins/utils/createTypeName.d.ts +0 -3
  615. package/content/plugins/utils/createTypeName.js +0 -28
  616. package/content/plugins/utils/getEntryTitle.d.ts +0 -2
  617. package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +0 -11
  618. package/content/plugins/utils/getSchemaFromFieldPlugins.js +0 -30
  619. package/content/plugins/utils/pluralizedTypeName.d.ts +0 -1
  620. package/content/plugins/utils/renderFields.d.ts +0 -16
  621. package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
  622. package/content/plugins/utils/renderGetFilterFields.js +0 -41
  623. package/content/plugins/utils/renderInputFields.d.ts +0 -14
  624. package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
  625. package/content/plugins/utils/renderSortEnum.d.ts +0 -9
  626. package/content/plugins/utils/renderSortEnum.js +0 -32
  627. package/content/plugins/validators/dateGte.d.ts +0 -3
  628. package/content/plugins/validators/dateLte.d.ts +0 -3
  629. package/content/plugins/validators/gte.d.ts +0 -3
  630. package/content/plugins/validators/gte.js +0 -32
  631. package/content/plugins/validators/in.d.ts +0 -3
  632. package/content/plugins/validators/in.js +0 -32
  633. package/content/plugins/validators/index.d.ts +0 -2
  634. package/content/plugins/validators/index.js +0 -36
  635. package/content/plugins/validators/lte.d.ts +0 -3
  636. package/content/plugins/validators/lte.js +0 -32
  637. package/content/plugins/validators/maxLength.d.ts +0 -3
  638. package/content/plugins/validators/maxLength.js +0 -32
  639. package/content/plugins/validators/minLength.d.ts +0 -3
  640. package/content/plugins/validators/minLength.js +0 -32
  641. package/content/plugins/validators/pattern.d.ts +0 -3
  642. package/content/plugins/validators/pattern.js +0 -47
  643. package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
  644. package/content/plugins/validators/patternPlugins/email.js +0 -17
  645. package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
  646. package/content/plugins/validators/patternPlugins/index.js +0 -19
  647. package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
  648. package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
  649. package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
  650. package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
  651. package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
  652. package/content/plugins/validators/patternPlugins/url.js +0 -17
  653. package/content/plugins/validators/required.d.ts +0 -3
  654. package/content/plugins/validators/required.js +0 -25
  655. package/content/plugins/validators/timeGte.d.ts +0 -3
  656. package/content/plugins/validators/timeLte.d.ts +0 -3
  657. package/migrateCMSPermissions.d.ts +0 -17
  658. package/migrateCMSPermissions.js +0 -193
  659. package/plugins/context.d.ts +0 -4
  660. package/plugins/context.js +0 -34
  661. package/plugins/crud/index.d.ts +0 -6
  662. package/plugins/crud/index.js +0 -100
  663. package/plugins/crud/settings.crud.js +0 -93
  664. package/plugins/crud/system.crud.js +0 -182
  665. package/plugins/graphql/system.d.ts +0 -17
  666. package/plugins/graphql.d.ts +0 -2
  667. package/plugins/graphql.js +0 -79
  668. package/plugins/upgrades/index.d.ts +0 -2
  669. package/plugins/upgrades/index.js +0 -14
  670. package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
  671. package/plugins/upgrades/v5.5.0/helpers.js +0 -10
  672. package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
  673. package/plugins/upgrades/v5.5.0/index.js +0 -129
  674. package/transformers.d.ts +0 -2
  675. package/transformers.js +0 -25
  676. package/utils.d.ts +0 -25
  677. package/utils.js +0 -251
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createGraphQLSchemaPluginFromFieldPlugins = void 0;
7
+ var _plugins = require("../plugins");
8
+ const TYPE_MAP = {
9
+ preview: "read",
10
+ read: "read",
11
+ manage: "manage"
12
+ };
13
+ const createGraphQLSchemaPluginFromFieldPlugins = params => {
14
+ const {
15
+ models,
16
+ fieldTypePlugins,
17
+ type
18
+ } = params;
19
+ const plugins = [];
20
+ for (const key in fieldTypePlugins) {
21
+ const fieldTypePlugin = fieldTypePlugins[key];
22
+ if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {
23
+ continue;
24
+ }
25
+ const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema;
26
+ // Render gql types generated by field type plugins
27
+ if (!createSchema) {
28
+ continue;
29
+ }
30
+ const schema = createSchema({
31
+ models
32
+ });
33
+ const plugin = new _plugins.CmsGraphQLSchemaPlugin(schema);
34
+ plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;
35
+ plugins.push(plugin);
36
+ }
37
+ return plugins;
38
+ };
39
+ exports.createGraphQLSchemaPluginFromFieldPlugins = createGraphQLSchemaPluginFromFieldPlugins;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TYPE_MAP","preview","read","manage","createGraphQLSchemaPluginFromFieldPlugins","params","models","fieldTypePlugins","type","plugins","key","fieldTypePlugin","createSchema","schema","plugin","CmsGraphQLSchemaPlugin","name","fieldType","push"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\ninterface Params {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n}\nexport const createGraphQLSchemaPluginFromFieldPlugins = (params: Params) => {\n const { models, fieldTypePlugins, type } = params;\n\n const plugins: CmsGraphQLSchemaPlugin[] = [];\n for (const key in fieldTypePlugins) {\n const fieldTypePlugin = fieldTypePlugins[key];\n if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {\n continue;\n }\n const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n continue;\n }\n const schema = createSchema({ models });\n\n const plugin = new CmsGraphQLSchemaPlugin(schema);\n plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;\n plugins.push(plugin);\n }\n return plugins;\n};\n"],"mappings":";;;;;;AACA;AAEA,MAAMA,QAA2C,GAAG;EAChDC,OAAO,EAAE,MAAM;EACfC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC;AAOM,MAAMC,yCAAyC,GAAIC,MAAc,IAAK;EACzE,MAAM;IAAEC,MAAM;IAAEC,gBAAgB;IAAEC;EAAK,CAAC,GAAGH,MAAM;EAEjD,MAAMI,OAAiC,GAAG,EAAE;EAC5C,KAAK,MAAMC,GAAG,IAAIH,gBAAgB,EAAE;IAChC,MAAMI,eAAe,GAAGJ,gBAAgB,CAACG,GAAG,CAAC;IAC7C,IAAI,CAACV,QAAQ,CAACQ,IAAI,CAAC,IAAI,CAACG,eAAe,CAACX,QAAQ,CAACQ,IAAI,CAAC,CAAC,EAAE;MACrD;IACJ;IACA,MAAMI,YAAY,GAAGD,eAAe,CAACX,QAAQ,CAACQ,IAAI,CAAC,CAAC,CAACI,YAAY;IACjE;IACA,IAAI,CAACA,YAAY,EAAE;MACf;IACJ;IACA,MAAMC,MAAM,GAAGD,YAAY,CAAC;MAAEN;IAAO,CAAC,CAAC;IAEvC,MAAMQ,MAAM,GAAG,IAAIC,+BAAsB,CAACF,MAAM,CAAC;IACjDC,MAAM,CAACE,IAAI,GAAI,+BAA8BR,IAAK,UAASG,eAAe,CAACM,SAAU,EAAC;IACtFR,OAAO,CAACS,IAAI,CAACJ,MAAM,CAAC;EACxB;EACA,OAAOL,OAAO;AAClB,CAAC;AAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const incrementEntryIdVersion: (id: string) => {
2
+ entryId: string;
3
+ version: number;
4
+ id: string;
5
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.incrementEntryIdVersion = void 0;
8
+ var _utils = require("@webiny/utils");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const incrementEntryIdVersion = id => {
11
+ const {
12
+ id: entryId,
13
+ version
14
+ } = (0, _utils.parseIdentifier)(id);
15
+ if (!version) {
16
+ throw new _error.default("Cannot increase version on the ID without the version part.", "WRONG_ID", {
17
+ id
18
+ });
19
+ }
20
+ return {
21
+ entryId,
22
+ version: version + 1,
23
+ id: (0, _utils.createIdentifier)({
24
+ id: entryId,
25
+ version: version + 1
26
+ })
27
+ };
28
+ };
29
+ exports.incrementEntryIdVersion = incrementEntryIdVersion;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["incrementEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier"],"sources":["incrementEntryIdVersion.ts"],"sourcesContent":["import { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\n\nexport const incrementEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,uBAAuB,GAAIC,EAAU,IAAK;EACnD,MAAM;IAAEA,EAAE,EAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACH,EAAE,CAAC;EACpD,IAAI,CAACE,OAAO,EAAE;IACV,MAAM,IAAIE,cAAW,CACjB,6DAA6D,EAC7D,UAAU,EACV;MACIJ;IACJ,CAAC,CACJ;EACL;EACA,OAAO;IACHC,OAAO;IACPC,OAAO,EAAEA,OAAO,GAAG,CAAC;IACpBF,EAAE,EAAE,IAAAK,uBAAgB,EAAC;MACjBL,EAAE,EAAEC,OAAO;MACXC,OAAO,EAAEA,OAAO,GAAG;IACvB,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
@@ -0,0 +1,8 @@
1
+ import { BaseCmsSecurityPermission, CmsContext, CmsIdentity } from "../types";
2
+ interface OwnableRecord {
3
+ createdBy?: CmsIdentity;
4
+ ownedBy?: CmsIdentity;
5
+ }
6
+ export declare const checkOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => void;
7
+ export declare const validateOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => boolean;
8
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateOwnership = exports.checkOwnership = void 0;
7
+ var _apiSecurity = require("@webiny/api-security");
8
+ const checkOwnership = (context, permission, record) => {
9
+ var _record$ownedBy, _record$createdBy;
10
+ if (!permission.own) {
11
+ return;
12
+ }
13
+ const identity = context.security.getIdentity();
14
+ const owner = identity && ((_record$ownedBy = record.ownedBy) === null || _record$ownedBy === void 0 ? void 0 : _record$ownedBy.id) === identity.id;
15
+ const creator = identity && ((_record$createdBy = record.createdBy) === null || _record$createdBy === void 0 ? void 0 : _record$createdBy.id) === identity.id;
16
+ if (!owner && !creator) {
17
+ throw new _apiSecurity.NotAuthorizedError({
18
+ data: {
19
+ reason: `You are not the owner of the record.`
20
+ }
21
+ });
22
+ }
23
+ };
24
+ exports.checkOwnership = checkOwnership;
25
+ const validateOwnership = (context, permission, record) => {
26
+ try {
27
+ checkOwnership(context, permission, record);
28
+ return true;
29
+ } catch {
30
+ return false;
31
+ }
32
+ };
33
+ exports.validateOwnership = validateOwnership;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["checkOwnership","context","permission","record","own","identity","security","getIdentity","owner","ownedBy","id","creator","createdBy","NotAuthorizedError","data","reason","validateOwnership"],"sources":["ownership.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CmsIdentity } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\ninterface OwnableRecord {\n createdBy?: CmsIdentity;\n ownedBy?: CmsIdentity;\n}\n\nexport const checkOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): void => {\n if (!permission.own) {\n return;\n }\n\n const identity = context.security.getIdentity();\n const owner = identity && record.ownedBy?.id === identity.id;\n const creator = identity && record.createdBy?.id === identity.id;\n\n if (!owner && !creator) {\n throw new NotAuthorizedError({\n data: {\n reason: `You are not the owner of the record.`\n }\n });\n }\n};\n\nexport const validateOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): boolean => {\n try {\n checkOwnership(context, permission, record);\n return true;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;AACA;AAOO,MAAMA,cAAc,GAAG,CAC1BC,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACd;EAAA;EACP,IAAI,CAACD,UAAU,CAACE,GAAG,EAAE;IACjB;EACJ;EAEA,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,QAAQ,CAACC,WAAW,EAAE;EAC/C,MAAMC,KAAK,GAAGH,QAAQ,IAAI,oBAAAF,MAAM,CAACM,OAAO,oDAAd,gBAAgBC,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAC5D,MAAMC,OAAO,GAAGN,QAAQ,IAAI,sBAAAF,MAAM,CAACS,SAAS,sDAAhB,kBAAkBF,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAEhE,IAAI,CAACF,KAAK,IAAI,CAACG,OAAO,EAAE;IACpB,MAAM,IAAIE,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG;MACb;IACJ,CAAC,CAAC;EACN;AACJ,CAAC;AAAC;AAEK,MAAMC,iBAAiB,GAAG,CAC7Bf,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACX;EACV,IAAI;IACAH,cAAc,CAACC,OAAO,EAAEC,UAAU,EAAEC,MAAM,CAAC;IAC3C,OAAO,IAAI;EACf,CAAC,CAAC,MAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC;AAAC"}
@@ -0,0 +1,7 @@
1
+ import { BaseCmsSecurityPermission, CmsContext, CmsEntryPermission } from "../types";
2
+ export declare const hasRwd: (permission: BaseCmsSecurityPermission, rwd: string) => boolean;
3
+ export declare const hasPw: (permission: CmsEntryPermission, pw: string) => boolean;
4
+ export declare const checkPermissions: <TPermission extends BaseCmsSecurityPermission = BaseCmsSecurityPermission>(context: CmsContext, name: string, check?: {
5
+ rwd?: string;
6
+ pw?: string;
7
+ }) => Promise<TPermission>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasRwd = exports.hasPw = exports.checkPermissions = void 0;
7
+ var _apiSecurity = require("@webiny/api-security");
8
+ const hasRwd = (permission, rwd) => {
9
+ if (typeof permission.rwd !== "string") {
10
+ return true;
11
+ }
12
+ return permission.rwd.includes(rwd);
13
+ };
14
+ exports.hasRwd = hasRwd;
15
+ const hasPw = (permission, pw) => {
16
+ const isCustom = Object.keys(permission).length > 1; // "name" key is always present
17
+
18
+ if (!isCustom) {
19
+ // Means it's a "full-access" permission.
20
+ return true;
21
+ }
22
+ if (typeof permission.pw !== "string") {
23
+ return false;
24
+ }
25
+ return permission.pw.includes(pw);
26
+ };
27
+ exports.hasPw = hasPw;
28
+ const PW = {
29
+ p: "publish",
30
+ u: "unpublish"
31
+ };
32
+ const RWD = {
33
+ r: "read",
34
+ w: "write",
35
+ d: "delete"
36
+ };
37
+ const checkPermissions = async (context, name, check) => {
38
+ // Check if user is allowed to edit content in current language
39
+ const contentPermission = await context.security.getPermission("content.i18n");
40
+ if (!contentPermission) {
41
+ throw new _apiSecurity.NotAuthorizedError({
42
+ data: {
43
+ reason: "Missing access to content in any locale."
44
+ }
45
+ });
46
+ }
47
+
48
+ // We need to check this manually as CMS locale comes from the URL and not the default i18n app.
49
+ const code = context.cms.getLocale().code;
50
+ const locales = contentPermission.locales;
51
+
52
+ // IMPORTANT: If we have a `contentPermission`, and `locales` key is NOT SET - it means the user has access to all locales.
53
+ // However, if the the `locales` IS SET - check that it contains the required locale.
54
+ if (Array.isArray(locales) && !locales.includes(code)) {
55
+ throw new _apiSecurity.NotAuthorizedError({
56
+ data: {
57
+ reason: `Not allowed to access content in "${code}."`
58
+ }
59
+ });
60
+ }
61
+ const permission = await context.security.getPermission(name);
62
+ if (!permission) {
63
+ throw new _apiSecurity.NotAuthorizedError({
64
+ data: {
65
+ reason: `Missing permission "${name}".`
66
+ }
67
+ });
68
+ }
69
+ if (!check) {
70
+ return permission;
71
+ }
72
+ if (check.rwd && !hasRwd(permission, check.rwd)) {
73
+ throw new _apiSecurity.NotAuthorizedError({
74
+ data: {
75
+ reason: `Not allowed to perform "${RWD[check.rwd]}" on "${name}".`
76
+ }
77
+ });
78
+ }
79
+
80
+ // p = publish
81
+ // u = unpublish
82
+ if (check.pw && !hasPw(permission, check.pw)) {
83
+ throw new _apiSecurity.NotAuthorizedError({
84
+ data: {
85
+ reason: `Not allowed to perform "${PW[check.pw]}" on "${name}".`
86
+ }
87
+ });
88
+ }
89
+ return permission;
90
+ };
91
+ exports.checkPermissions = checkPermissions;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hasRwd","permission","rwd","includes","hasPw","pw","isCustom","Object","keys","length","PW","p","u","RWD","r","w","d","checkPermissions","context","name","check","contentPermission","security","getPermission","NotAuthorizedError","data","reason","code","cms","getLocale","locales","Array","isArray"],"sources":["permissions.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CmsEntryPermission } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport const hasRwd = (permission: BaseCmsSecurityPermission, rwd: string): boolean => {\n if (typeof permission.rwd !== \"string\") {\n return true;\n }\n\n return permission.rwd.includes(rwd);\n};\n\nexport const hasPw = (permission: CmsEntryPermission, pw: string): boolean => {\n const isCustom = Object.keys(permission).length > 1; // \"name\" key is always present\n\n if (!isCustom) {\n // Means it's a \"full-access\" permission.\n return true;\n }\n\n if (typeof permission.pw !== \"string\") {\n return false;\n }\n\n return permission.pw.includes(pw);\n};\n\nconst PW: Record<string, string> = {\n p: \"publish\",\n u: \"unpublish\"\n};\n\nconst RWD: Record<string, string> = {\n r: \"read\",\n w: \"write\",\n d: \"delete\"\n};\n\nexport const checkPermissions = async <\n TPermission extends BaseCmsSecurityPermission = BaseCmsSecurityPermission\n>(\n context: CmsContext,\n name: string,\n check?: { rwd?: string; pw?: string }\n): Promise<TPermission> => {\n // Check if user is allowed to edit content in current language\n const contentPermission = await context.security.getPermission(\"content.i18n\");\n\n if (!contentPermission) {\n throw new NotAuthorizedError({\n data: {\n reason: \"Missing access to content in any locale.\"\n }\n });\n }\n\n // We need to check this manually as CMS locale comes from the URL and not the default i18n app.\n const code = context.cms.getLocale().code;\n\n const locales: string[] = contentPermission.locales;\n\n // IMPORTANT: If we have a `contentPermission`, and `locales` key is NOT SET - it means the user has access to all locales.\n // However, if the the `locales` IS SET - check that it contains the required locale.\n if (Array.isArray(locales) && !locales.includes(code)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access content in \"${code}.\"`\n }\n });\n }\n\n const permission = await context.security.getPermission<TPermission>(name);\n\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Missing permission \"${name}\".`\n }\n });\n }\n\n if (!check) {\n return permission;\n }\n\n if (check.rwd && !hasRwd(permission, check.rwd)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to perform \"${RWD[check.rwd]}\" on \"${name}\".`\n }\n });\n }\n\n // p = publish\n // u = unpublish\n if (check.pw && !hasPw(permission, check.pw)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to perform \"${PW[check.pw]}\" on \"${name}\".`\n }\n });\n }\n\n return permission;\n};\n"],"mappings":";;;;;;AACA;AAEO,MAAMA,MAAM,GAAG,CAACC,UAAqC,EAAEC,GAAW,KAAc;EACnF,IAAI,OAAOD,UAAU,CAACC,GAAG,KAAK,QAAQ,EAAE;IACpC,OAAO,IAAI;EACf;EAEA,OAAOD,UAAU,CAACC,GAAG,CAACC,QAAQ,CAACD,GAAG,CAAC;AACvC,CAAC;AAAC;AAEK,MAAME,KAAK,GAAG,CAACH,UAA8B,EAAEI,EAAU,KAAc;EAC1E,MAAMC,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAACP,UAAU,CAAC,CAACQ,MAAM,GAAG,CAAC,CAAC,CAAC;;EAErD,IAAI,CAACH,QAAQ,EAAE;IACX;IACA,OAAO,IAAI;EACf;EAEA,IAAI,OAAOL,UAAU,CAACI,EAAE,KAAK,QAAQ,EAAE;IACnC,OAAO,KAAK;EAChB;EAEA,OAAOJ,UAAU,CAACI,EAAE,CAACF,QAAQ,CAACE,EAAE,CAAC;AACrC,CAAC;AAAC;AAEF,MAAMK,EAA0B,GAAG;EAC/BC,CAAC,EAAE,SAAS;EACZC,CAAC,EAAE;AACP,CAAC;AAED,MAAMC,GAA2B,GAAG;EAChCC,CAAC,EAAE,MAAM;EACTC,CAAC,EAAE,OAAO;EACVC,CAAC,EAAE;AACP,CAAC;AAEM,MAAMC,gBAAgB,GAAG,OAG5BC,OAAmB,EACnBC,IAAY,EACZC,KAAqC,KACd;EACvB;EACA,MAAMC,iBAAiB,GAAG,MAAMH,OAAO,CAACI,QAAQ,CAACC,aAAa,CAAC,cAAc,CAAC;EAE9E,IAAI,CAACF,iBAAiB,EAAE;IACpB,MAAM,IAAIG,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAE;MACZ;IACJ,CAAC,CAAC;EACN;;EAEA;EACA,MAAMC,IAAI,GAAGT,OAAO,CAACU,GAAG,CAACC,SAAS,EAAE,CAACF,IAAI;EAEzC,MAAMG,OAAiB,GAAGT,iBAAiB,CAACS,OAAO;;EAEnD;EACA;EACA,IAAIC,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,IAAI,CAACA,OAAO,CAAC3B,QAAQ,CAACwB,IAAI,CAAC,EAAE;IACnD,MAAM,IAAIH,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,qCAAoCC,IAAK;MACtD;IACJ,CAAC,CAAC;EACN;EAEA,MAAM1B,UAAU,GAAG,MAAMiB,OAAO,CAACI,QAAQ,CAACC,aAAa,CAAcJ,IAAI,CAAC;EAE1E,IAAI,CAAClB,UAAU,EAAE;IACb,MAAM,IAAIuB,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,uBAAsBP,IAAK;MACxC;IACJ,CAAC,CAAC;EACN;EAEA,IAAI,CAACC,KAAK,EAAE;IACR,OAAOnB,UAAU;EACrB;EAEA,IAAImB,KAAK,CAAClB,GAAG,IAAI,CAACF,MAAM,CAACC,UAAU,EAAEmB,KAAK,CAAClB,GAAG,CAAC,EAAE;IAC7C,MAAM,IAAIsB,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,2BAA0Bb,GAAG,CAACO,KAAK,CAAClB,GAAG,CAAE,SAAQiB,IAAK;MACnE;IACJ,CAAC,CAAC;EACN;;EAEA;EACA;EACA,IAAIC,KAAK,CAACf,EAAE,IAAI,CAACD,KAAK,CAACH,UAAU,EAAEmB,KAAK,CAACf,EAAE,CAAC,EAAE;IAC1C,MAAM,IAAImB,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,2BAA0BhB,EAAE,CAACU,KAAK,CAACf,EAAE,CAAE,SAAQc,IAAK;MACjE;IACJ,CAAC,CAAC;EACN;EAEA,OAAOlB,UAAU;AACrB,CAAC;AAAC"}
@@ -0,0 +1 @@
1
+ export declare const pluralizedTypeName: (typeName: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["pluralizedTypeName","typeName","length","pluralize"],"sources":["pluralizedTypeName.ts"],"sourcesContent":["import pluralize from \"pluralize\";\n\n// This will make it so if the content model name is a single capitalized letter\n// Ex. A, pluralizedTypeName will capitalize the name to As, instead of AS\nexport const pluralizedTypeName = (typeName: string): string => {\n let pluralizedTypeName;\n if (typeName.length === 1) {\n pluralizedTypeName = `${typeName}s`;\n } else {\n pluralizedTypeName = pluralize(typeName);\n }\n return pluralizedTypeName;\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;AACA;AACO,MAAMA,kBAAkB,GAAIC,QAAD,IAA8B;EAC5D,IAAID,kBAAJ;;EACA,IAAIC,QAAQ,CAACC,MAAT,KAAoB,CAAxB,EAA2B;IACvBF,kBAAkB,GAAI,GAAEC,QAAS,GAAjC;EACH,CAFD,MAEO;IACHD,kBAAkB,GAAG,IAAAG,kBAAA,EAAUF,QAAV,CAArB;EACH;;EACD,OAAOD,kBAAP;AACH,CARM"}
@@ -0,0 +1,16 @@
1
+ import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
2
+ interface RenderFieldsParams {
3
+ models: CmsModel[];
4
+ model: CmsModel;
5
+ type: ApiEndpoint;
6
+ fieldTypePlugins: CmsFieldTypePlugins;
7
+ }
8
+ interface RenderFields {
9
+ (params: RenderFieldsParams): CmsModelFieldDefinition[];
10
+ }
11
+ export declare const renderFields: RenderFields;
12
+ interface RenderFieldParams extends RenderFieldsParams {
13
+ field: CmsModelField;
14
+ }
15
+ export declare const renderField: ({ models, model, type, field, fieldTypePlugins }: RenderFieldParams) => CmsModelFieldDefinition | null;
16
+ export {};
@@ -4,48 +4,50 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderFields = exports.renderField = void 0;
7
-
7
+ var _getBaseFieldType = require("./getBaseFieldType");
8
8
  const renderFields = ({
9
+ models,
9
10
  model,
10
11
  type,
11
12
  fieldTypePlugins
12
13
  }) => {
13
14
  return model.fields.map(field => renderField({
15
+ models,
14
16
  model,
15
17
  type,
16
18
  field,
17
19
  fieldTypePlugins
18
20
  })).filter(Boolean);
19
21
  };
20
-
21
22
  exports.renderFields = renderFields;
22
-
23
23
  const renderField = ({
24
+ models,
24
25
  model,
25
26
  type,
26
27
  field,
27
28
  fieldTypePlugins
28
29
  }) => {
29
- const plugin = fieldTypePlugins[field.type];
30
-
30
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
31
31
  if (!plugin) {
32
32
  // Let's not render the field if it does not exist in the field plugins.
33
- return;
33
+ return null;
34
34
  }
35
-
36
- const defs = plugin[type].createTypeField({
35
+ const {
36
+ createTypeField
37
+ } = plugin[type];
38
+ const defs = createTypeField({
39
+ models,
37
40
  model,
38
41
  field,
39
42
  fieldTypePlugins
40
43
  });
41
-
42
- if (typeof defs === "string") {
44
+ if (!defs) {
45
+ return null;
46
+ } else if (typeof defs === "string") {
43
47
  return {
44
48
  fields: defs
45
49
  };
46
50
  }
47
-
48
51
  return defs;
49
52
  };
50
-
51
53
  exports.renderField = renderField;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["renderFields","models","model","type","fieldTypePlugins","fields","map","field","renderField","filter","Boolean","plugin","getBaseFieldType","createTypeField","defs"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderFields {\n (params: RenderFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderFields: RenderFields = ({\n models,\n model,\n type,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return model.fields\n .map(field => renderField({ models, model, type, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\ninterface RenderFieldParams extends RenderFieldsParams {\n field: CmsModelField;\n}\n\nexport const renderField = ({\n models,\n model,\n type,\n field,\n fieldTypePlugins\n}: RenderFieldParams): CmsModelFieldDefinition | null => {\n const plugin: CmsModelFieldToGraphQLPlugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n const { createTypeField } = plugin[type] as CmsModelFieldToGraphQLPlugin[\"manage\"];\n const defs = createTypeField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n\n if (!defs) {\n return null;\n } else if (typeof defs === \"string\") {\n return {\n fields: defs\n };\n }\n\n return defs;\n};\n"],"mappings":";;;;;;AAQA;AAaO,MAAMA,YAA0B,GAAG,CAAC;EACvCC,MAAM;EACNC,KAAK;EACLC,IAAI;EACJC;AACJ,CAAC,KAAgC;EAC7B,OAAOF,KAAK,CAACG,MAAM,CACdC,GAAG,CAACC,KAAK,IAAIC,WAAW,CAAC;IAAEP,MAAM;IAAEC,KAAK;IAAEC,IAAI;IAAEI,KAAK;IAAEH;EAAiB,CAAC,CAAC,CAAC,CAC3EK,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAAC;AAMK,MAAMF,WAAW,GAAG,CAAC;EACxBP,MAAM;EACNC,KAAK;EACLC,IAAI;EACJI,KAAK;EACLH;AACe,CAAC,KAAqC;EACrD,MAAMO,MAAoC,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACL,KAAK,CAAC,CAAC;EACtF,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EACA,MAAM;IAAEE;EAAgB,CAAC,GAAGF,MAAM,CAACR,IAAI,CAA2C;EAClF,MAAMW,IAAI,GAAGD,eAAe,CAAC;IACzBZ,MAAM;IACNC,KAAK;IACLK,KAAK;IACLH;EACJ,CAAC,CAAC;EAEF,IAAI,CAACU,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACjC,OAAO;MACHT,MAAM,EAAES;IACZ,CAAC;EACL;EAEA,OAAOA,IAAI;AACf,CAAC;AAAC"}
@@ -0,0 +1,10 @@
1
+ import { CmsFieldTypePlugins, CmsModel } from "../types";
2
+ interface RenderGetFilterFieldsParams {
3
+ model: CmsModel;
4
+ fieldTypePlugins: CmsFieldTypePlugins;
5
+ }
6
+ interface RenderGetFilterFields {
7
+ (params: RenderGetFilterFieldsParams): string;
8
+ }
9
+ export declare const renderGetFilterFields: RenderGetFilterFields;
10
+ export {};
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderGetFilterFields = void 0;
7
+ var _getBaseFieldType = require("./getBaseFieldType");
8
+ const getCreateFilters = (plugins, fieldType) => {
9
+ if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
10
+ return null;
11
+ }
12
+ return plugins[fieldType].read.createGetFilters;
13
+ };
14
+ const renderGetFilterFields = ({
15
+ model,
16
+ fieldTypePlugins
17
+ }) => {
18
+ const fieldIdList = model.fields.filter(field => {
19
+ // Every time a client updates content model's fields, we check the type of each field. If a field plugin
20
+ // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
21
+ // want to be careful when accessing the field plugin here too. It is still possible to have a content model
22
+ // that contains a field, for which we don't have a plugin registered on the backend. For example, user
23
+ // could've just removed the plugin from the backend.
24
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
25
+ if (!fieldTypePlugins[baseType]) {
26
+ return false;
27
+ }
28
+ return fieldTypePlugins[baseType].isSearchable;
29
+ }).map(f => f.fieldId);
30
+ const filters = ["id: ID", "entryId: String"];
31
+ for (const fieldId of fieldIdList) {
32
+ const field = model.fields.find(item => item.fieldId === fieldId);
33
+ if (!field) {
34
+ continue;
35
+ }
36
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
37
+ const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);
38
+ if (typeof createGetFilters !== "function") {
39
+ continue;
40
+ }
41
+ filters.push(createGetFilters({
42
+ model,
43
+ field
44
+ }));
45
+ }
46
+ return filters.filter(Boolean).join("\n");
47
+ };
48
+ exports.renderGetFilterFields = renderGetFilterFields;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getCreateFilters","plugins","fieldType","read","createGetFilters","renderGetFilterFields","model","fieldTypePlugins","fieldIdList","fields","filter","field","baseType","getBaseFieldType","isSearchable","map","f","fieldId","filters","find","item","push","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderGetFilterFieldsParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nconst getCreateFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string\n): CmsModelFieldToGraphQLPlugin[\"read\"][\"createGetFilters\"] | null => {\n if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {\n return null;\n }\n return plugins[fieldType].read.createGetFilters;\n};\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ model, fieldTypePlugins }) => {\n const fieldIdList = model.fields\n .filter(field => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n if (!fieldTypePlugins[baseType]) {\n return false;\n }\n return fieldTypePlugins[baseType].isSearchable;\n })\n .map(f => f.fieldId);\n\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const fieldId of fieldIdList) {\n const field = model.fields.find(item => item.fieldId === fieldId);\n if (!field) {\n continue;\n }\n const baseType = getBaseFieldType(field);\n const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ model, field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAUA,MAAMA,gBAAgB,GAAG,CACrBC,OAA4B,EAC5BC,SAAiB,KACiD;EAClE,IAAI,CAACD,OAAO,CAACC,SAAS,CAAC,IAAI,CAACD,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAACC,gBAAgB,EAAE;IAClE,OAAO,IAAI;EACf;EACA,OAAOH,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAACC,gBAAgB;AACnD,CAAC;AAEM,MAAMC,qBAA4C,GAAG,CAAC;EAAEC,KAAK;EAAEC;AAAiB,CAAC,KAAK;EACzF,MAAMC,WAAW,GAAGF,KAAK,CAACG,MAAM,CAC3BC,MAAM,CAACC,KAAK,IAAI;IACb;IACA;IACA;IACA;IACA;IACA,MAAMC,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,IAAI,CAACJ,gBAAgB,CAACK,QAAQ,CAAC,EAAE;MAC7B,OAAO,KAAK;IAChB;IACA,OAAOL,gBAAgB,CAACK,QAAQ,CAAC,CAACE,YAAY;EAClD,CAAC,CAAC,CACDC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC;EAExB,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMD,OAAO,IAAIT,WAAW,EAAE;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAM,CAACU,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACH,OAAO,KAAKA,OAAO,CAAC;IACjE,IAAI,CAACN,KAAK,EAAE;MACR;IACJ;IACA,MAAMC,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAgB,EAAEK,QAAQ,CAAC;IACrE,IAAI,OAAOR,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAc,OAAO,CAACG,IAAI,CAACjB,gBAAgB,CAAC;MAAEE,KAAK;MAAEK;IAAM,CAAC,CAAC,CAAC;EACpD;EAEA,OAAOO,OAAO,CAACR,MAAM,CAACY,OAAO,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC7C,CAAC;AAAC"}
@@ -0,0 +1,15 @@
1
+ import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
2
+ interface RenderInputFieldsParams {
3
+ models: CmsModel[];
4
+ model: CmsModel;
5
+ fieldTypePlugins: CmsFieldTypePlugins;
6
+ }
7
+ interface RenderInputFieldParams extends RenderInputFieldsParams {
8
+ field: CmsModelField;
9
+ }
10
+ interface RenderInputFields {
11
+ (params: RenderInputFieldsParams): CmsModelFieldDefinition[];
12
+ }
13
+ export declare const renderInputFields: RenderInputFields;
14
+ export declare const renderInputField: ({ models, model, field, fieldTypePlugins }: RenderInputFieldParams) => CmsModelFieldDefinition | null;
15
+ export {};
@@ -4,21 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderInputFields = exports.renderInputField = void 0;
7
-
7
+ var _getBaseFieldType = require("./getBaseFieldType");
8
8
  const renderInputFields = ({
9
+ models,
9
10
  model,
10
11
  fieldTypePlugins
11
12
  }) => {
12
13
  return model.fields.map(field => renderInputField({
14
+ models,
13
15
  model,
14
16
  field,
15
17
  fieldTypePlugins
16
18
  })).filter(Boolean);
17
19
  };
18
-
19
20
  exports.renderInputFields = renderInputFields;
20
-
21
21
  const renderInputField = ({
22
+ models,
22
23
  model,
23
24
  field,
24
25
  fieldTypePlugins
@@ -28,26 +29,22 @@ const renderInputField = ({
28
29
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
29
30
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
30
31
  // could've just removed the plugin from the backend.
31
- const plugin = fieldTypePlugins[field.type];
32
-
32
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
33
33
  if (!plugin) {
34
34
  // Let's not render the field if it does not exist in the field plugins.
35
- return;
35
+ return null;
36
36
  }
37
-
38
37
  const def = plugin.manage.createInputField({
38
+ models,
39
39
  model,
40
40
  field,
41
41
  fieldTypePlugins
42
42
  });
43
-
44
43
  if (typeof def === "string") {
45
44
  return {
46
45
  fields: def
47
46
  };
48
47
  }
49
-
50
48
  return def;
51
49
  };
52
-
53
50
  exports.renderInputField = renderInputField;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["renderInputFields","models","model","fieldTypePlugins","fields","map","field","renderInputField","filter","Boolean","plugin","getBaseFieldType","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import {\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderInputFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderInputFieldParams extends RenderInputFieldsParams {\n field: CmsModelField;\n}\ninterface RenderInputFields {\n (params: RenderInputFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderInputFields: RenderInputFields = ({\n models,\n model,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return model.fields\n .map(field => renderInputField({ models, model, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\nexport const renderInputField = ({\n models,\n model,\n field,\n fieldTypePlugins\n}: RenderInputFieldParams): CmsModelFieldDefinition | null => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const plugin: CmsModelFieldToGraphQLPlugin = fieldTypePlugins[getBaseFieldType(field)];\n\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n\n const def = plugin.manage.createInputField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n if (typeof def === \"string\") {\n return {\n fields: def\n };\n }\n\n return def;\n};\n"],"mappings":";;;;;;AAOA;AAcO,MAAMA,iBAAoC,GAAG,CAAC;EACjDC,MAAM;EACNC,KAAK;EACLC;AACJ,CAAC,KAAgC;EAC7B,OAAOD,KAAK,CAACE,MAAM,CACdC,GAAG,CAACC,KAAK,IAAIC,gBAAgB,CAAC;IAAEN,MAAM;IAAEC,KAAK;IAAEI,KAAK;IAAEH;EAAiB,CAAC,CAAC,CAAC,CAC1EK,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAAC;AAEK,MAAMF,gBAAgB,GAAG,CAAC;EAC7BN,MAAM;EACNC,KAAK;EACLI,KAAK;EACLH;AACoB,CAAC,KAAqC;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAoC,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACL,KAAK,CAAC,CAAC;EAEtF,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EAEA,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAM,CAACC,gBAAgB,CAAC;IACvCb,MAAM;IACNC,KAAK;IACLI,KAAK;IACLH;EACJ,CAAC,CAAC;EACF,IAAI,OAAOS,GAAG,KAAK,QAAQ,EAAE;IACzB,OAAO;MACHR,MAAM,EAAEQ;IACZ,CAAC;EACL;EAEA,OAAOA,GAAG;AACd,CAAC;AAAC"}
@@ -0,0 +1,11 @@
1
+ import { ApiEndpoint, CmsFieldTypePlugins, CmsModel } from "../types";
2
+ interface RenderListFilterFieldsParams {
3
+ model: CmsModel;
4
+ type: ApiEndpoint;
5
+ fieldTypePlugins: CmsFieldTypePlugins;
6
+ }
7
+ interface RenderListFilterFields {
8
+ (params: RenderListFilterFieldsParams): string;
9
+ }
10
+ export declare const renderListFilterFields: RenderListFilterFields;
11
+ export {};
@@ -1,39 +1,53 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.renderListFilterFields = void 0;
9
-
10
- var _get = _interopRequireDefault(require("lodash/get"));
11
-
12
- const renderListFilterFields = ({
13
- model,
14
- type,
15
- fieldTypePlugins
16
- }) => {
7
+ var _getBaseFieldType = require("./getBaseFieldType");
8
+ /**
9
+ * We cast as read type, because input and output of read and manage are same. This way we ease things.
10
+ * Internal stuff so it should be ok.
11
+ * TODO note that if changing read/manage types, change this as well.
12
+ */
13
+ const getCreateListFilters = (plugins, fieldType, type) => {
14
+ if (!plugins[fieldType]) {
15
+ return null;
16
+ } else if (!plugins[fieldType][type]) {
17
+ return null;
18
+ }
19
+ return plugins[fieldType][type].createListFilters;
20
+ };
21
+ const renderListFilterFields = params => {
22
+ const {
23
+ model,
24
+ type,
25
+ fieldTypePlugins
26
+ } = params;
17
27
  const fields = [["id: ID", "id_not: ID", "id_in: [ID!]", "id_not_in: [ID!]", "entryId: String", "entryId_not: String", "entryId_in: [String!]", "entryId_not_in: [String!]", "createdOn: DateTime", "createdOn_gt: DateTime", "createdOn_gte: DateTime", "createdOn_lt: DateTime", "createdOn_lte: DateTime", "createdOn_between: [DateTime!]", "createdOn_not_between: [DateTime!]", "savedOn: DateTime", "savedOn_gt: DateTime", "savedOn_gte: DateTime", "savedOn_lt: DateTime", "savedOn_lte: DateTime", "savedOn_between: [DateTime!]", "savedOn_not_between: [DateTime!]", "createdBy: String", "createdBy_not: String", "createdBy_in: [String!]", "createdBy_not_in: [String!]", "ownedBy: String", "ownedBy_not: String", "ownedBy_in: [String!]", "ownedBy_not_in: [String!]"].join("\n")];
18
-
19
- for (let i = 0; i < model.fields.length; i++) {
20
- const field = model.fields[i]; // Every time a client updates content model's fields, we check the type of each field. If a field plugin
28
+ /**
29
+ * We can find different statuses only in the manage API endpoint.
30
+ */
31
+ if (type === "manage") {
32
+ fields.push(...["status: String", "status_not: String", "status_in: [String!]", "status_not_in: [String!]"]);
33
+ }
34
+ for (const field of model.fields) {
35
+ // Every time a client updates content model's fields, we check the type of each field. If a field plugin
21
36
  // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
22
37
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
23
38
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
24
39
  // could've just removed the plugin from the backend.
25
40
 
26
- const createListFilters = (0, _get.default)(fieldTypePlugins, `${field.type}.${type}.createListFilters`);
27
-
28
- if (typeof createListFilters === "function") {
29
- fields.push(createListFilters({
30
- model,
31
- field
32
- }));
41
+ const createListFilters = getCreateListFilters(fieldTypePlugins, (0, _getBaseFieldType.getBaseFieldType)(field), type);
42
+ if (typeof createListFilters !== "function") {
43
+ continue;
33
44
  }
45
+ fields.push(createListFilters({
46
+ model,
47
+ field,
48
+ plugins: fieldTypePlugins
49
+ }));
34
50
  }
35
-
36
51
  return fields.filter(Boolean).join("\n");
37
52
  };
38
-
39
53
  exports.renderListFilterFields = renderListFilterFields;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getCreateListFilters","plugins","fieldType","type","createListFilters","renderListFilterFields","params","model","fieldTypePlugins","fields","join","push","field","getBaseFieldType","filter","Boolean"],"sources":["renderListFilterFields.ts"],"sourcesContent":["import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderListFilterFieldsParams {\n model: CmsModel;\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderListFilterFields {\n (params: RenderListFilterFieldsParams): string;\n}\n\ntype CreateListFiltersType =\n | CmsModelFieldToGraphQLPlugin[\"read\"][\"createListFilters\"]\n | CmsModelFieldToGraphQLPlugin[\"manage\"][\"createListFilters\"];\n/**\n * We cast as read type, because input and output of read and manage are same. This way we ease things.\n * Internal stuff so it should be ok.\n * TODO note that if changing read/manage types, change this as well.\n */\nconst getCreateListFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string,\n type: ApiEndpoint\n): CreateListFiltersType | null => {\n if (!plugins[fieldType]) {\n return null;\n } else if (!plugins[fieldType][type]) {\n return null;\n }\n return plugins[fieldType][type].createListFilters;\n};\n\nexport const renderListFilterFields: RenderListFilterFields = (params): string => {\n const { model, type, fieldTypePlugins } = params;\n const fields: string[] = [\n [\n \"id: ID\",\n \"id_not: ID\",\n \"id_in: [ID!]\",\n \"id_not_in: [ID!]\",\n \"entryId: String\",\n \"entryId_not: String\",\n \"entryId_in: [String!]\",\n \"entryId_not_in: [String!]\",\n \"createdOn: DateTime\",\n \"createdOn_gt: DateTime\",\n \"createdOn_gte: DateTime\",\n \"createdOn_lt: DateTime\",\n \"createdOn_lte: DateTime\",\n \"createdOn_between: [DateTime!]\",\n \"createdOn_not_between: [DateTime!]\",\n \"savedOn: DateTime\",\n \"savedOn_gt: DateTime\",\n \"savedOn_gte: DateTime\",\n \"savedOn_lt: DateTime\",\n \"savedOn_lte: DateTime\",\n \"savedOn_between: [DateTime!]\",\n \"savedOn_not_between: [DateTime!]\",\n \"createdBy: String\",\n \"createdBy_not: String\",\n \"createdBy_in: [String!]\",\n \"createdBy_not_in: [String!]\",\n \"ownedBy: String\",\n \"ownedBy_not: String\",\n \"ownedBy_in: [String!]\",\n \"ownedBy_not_in: [String!]\"\n ].join(\"\\n\")\n ];\n /**\n * We can find different statuses only in the manage API endpoint.\n */\n if (type === \"manage\") {\n fields.push(\n ...[\n \"status: String\",\n \"status_not: String\",\n \"status_in: [String!]\",\n \"status_not_in: [String!]\"\n ]\n );\n }\n\n for (const field of model.fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n\n const createListFilters = getCreateListFilters(\n fieldTypePlugins,\n getBaseFieldType(field),\n type\n );\n if (typeof createListFilters !== \"function\") {\n continue;\n }\n fields.push(createListFilters({ model, field, plugins: fieldTypePlugins }));\n }\n\n return fields.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAcA;AACA;AACA;AACA;AACA;AACA,MAAMA,oBAAoB,GAAG,CACzBC,OAA4B,EAC5BC,SAAiB,EACjBC,IAAiB,KACc;EAC/B,IAAI,CAACF,OAAO,CAACC,SAAS,CAAC,EAAE;IACrB,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,CAACD,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,EAAE;IAClC,OAAO,IAAI;EACf;EACA,OAAOF,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,CAACC,iBAAiB;AACrD,CAAC;AAEM,MAAMC,sBAA8C,GAAIC,MAAM,IAAa;EAC9E,MAAM;IAAEC,KAAK;IAAEJ,IAAI;IAAEK;EAAiB,CAAC,GAAGF,MAAM;EAChD,MAAMG,MAAgB,GAAG,CACrB,CACI,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,CAC9B,CAACC,IAAI,CAAC,IAAI,CAAC,CACf;EACD;AACJ;AACA;EACI,IAAIP,IAAI,KAAK,QAAQ,EAAE;IACnBM,MAAM,CAACE,IAAI,CACP,GAAG,CACC,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,CAC7B,CACJ;EACL;EAEA,KAAK,MAAMC,KAAK,IAAIL,KAAK,CAACE,MAAM,EAAE;IAC9B;IACA;IACA;IACA;IACA;;IAEA,MAAML,iBAAiB,GAAGJ,oBAAoB,CAC1CQ,gBAAgB,EAChB,IAAAK,kCAAgB,EAACD,KAAK,CAAC,EACvBT,IAAI,CACP;IACD,IAAI,OAAOC,iBAAiB,KAAK,UAAU,EAAE;MACzC;IACJ;IACAK,MAAM,CAACE,IAAI,CAACP,iBAAiB,CAAC;MAAEG,KAAK;MAAEK,KAAK;MAAEX,OAAO,EAAEO;IAAiB,CAAC,CAAC,CAAC;EAC/E;EAEA,OAAOC,MAAM,CAACK,MAAM,CAACC,OAAO,CAAC,CAACL,IAAI,CAAC,IAAI,CAAC;AAC5C,CAAC;AAAC"}
@@ -0,0 +1,12 @@
1
+ import { CmsFieldTypePlugins, CmsModel } from "../types";
2
+ import { CmsGraphQLSchemaSorterPlugin } from "../plugins/CmsGraphQLSchemaSorterPlugin";
3
+ interface RenderSortEnumParams {
4
+ model: CmsModel;
5
+ fieldTypePlugins: CmsFieldTypePlugins;
6
+ sorterPlugins: CmsGraphQLSchemaSorterPlugin[];
7
+ }
8
+ interface RenderSortEnum {
9
+ (params: RenderSortEnumParams): string;
10
+ }
11
+ export declare const renderSortEnum: RenderSortEnum;
12
+ export {};