@webiny/api-headless-cms 0.0.0-mt-3 → 0.0.0-unstable.3386f66516

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 (614) hide show
  1. package/context.d.ts +6 -0
  2. package/context.js +119 -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 -2
  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 -2
  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 -2
  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 +23 -11
  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 +14 -15
  18. package/crud/contentEntry/markLockedFields.js.map +1 -0
  19. package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
  20. package/crud/contentEntry/referenceFieldsMapping.js +292 -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 +83 -0
  24. package/crud/contentEntry/searchableFields.js.map +1 -0
  25. package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +5 -9
  26. package/crud/contentEntry.crud.js +1309 -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 +18 -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 +18 -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 +18 -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 +18 -0
  39. package/crud/contentModel/afterUpdate.js.map +1 -0
  40. package/crud/contentModel/beforeCreate.d.ts +14 -0
  41. package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +61 -13
  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 +14 -10
  45. package/crud/contentModel/beforeDelete.js.map +1 -0
  46. package/crud/contentModel/beforeUpdate.d.ts +8 -0
  47. package/crud/contentModel/beforeUpdate.js +37 -0
  48. package/crud/contentModel/beforeUpdate.js.map +1 -0
  49. package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
  50. package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -0
  51. package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
  52. package/crud/contentModel/createFieldModels.d.ts +2 -0
  53. package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +6 -2
  54. package/crud/contentModel/createFieldModels.js.map +1 -0
  55. package/crud/contentModel/createFieldStorageId.d.ts +2 -0
  56. package/crud/contentModel/createFieldStorageId.js +20 -0
  57. package/crud/contentModel/createFieldStorageId.js.map +1 -0
  58. package/crud/contentModel/fieldIdValidation.d.ts +1 -0
  59. package/crud/contentModel/fieldIdValidation.js +25 -0
  60. package/crud/contentModel/fieldIdValidation.js.map +1 -0
  61. package/crud/contentModel/idValidation.d.ts +1 -0
  62. package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
  63. package/crud/contentModel/idValidation.js.map +1 -0
  64. package/{content/plugins/crud → crud}/contentModel/models.d.ts +2 -1
  65. package/{content/plugins/crud → crud}/contentModel/models.js +76 -25
  66. package/crud/contentModel/models.js.map +1 -0
  67. package/crud/contentModel/systemFields.d.ts +1 -0
  68. package/crud/contentModel/systemFields.js +8 -0
  69. package/crud/contentModel/systemFields.js.map +1 -0
  70. package/crud/contentModel/validateLayout.d.ts +2 -0
  71. package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -3
  72. package/crud/contentModel/validateLayout.js.map +1 -0
  73. package/crud/contentModel/validateModel.d.ts +8 -0
  74. package/crud/contentModel/validateModel.js +35 -0
  75. package/crud/contentModel/validateModel.js.map +1 -0
  76. package/crud/contentModel/validateModelFields.d.ts +8 -0
  77. package/crud/contentModel/validateModelFields.js +436 -0
  78. package/crud/contentModel/validateModelFields.js.map +1 -0
  79. package/crud/contentModel/validation.d.ts +477 -0
  80. package/crud/contentModel/validation.js +109 -0
  81. package/crud/contentModel/validation.js.map +1 -0
  82. package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
  83. package/crud/contentModel.crud.js +642 -0
  84. package/crud/contentModel.crud.js.map +1 -0
  85. package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
  86. package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +9 -9
  87. package/crud/contentModelGroup/beforeCreate.js.map +1 -0
  88. package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
  89. package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +4 -4
  90. package/crud/contentModelGroup/beforeDelete.js.map +1 -0
  91. package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
  92. package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +3 -3
  93. package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
  94. package/crud/contentModelGroup/validation.d.ts +30 -0
  95. package/crud/contentModelGroup/validation.js +43 -0
  96. package/crud/contentModelGroup/validation.js.map +1 -0
  97. package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
  98. package/crud/contentModelGroup.crud.js +366 -0
  99. package/crud/contentModelGroup.crud.js.map +1 -0
  100. package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
  101. package/crud/settings.crud.js +83 -0
  102. package/crud/settings.crud.js.map +1 -0
  103. package/{plugins/crud → crud}/system.crud.d.ts +6 -3
  104. package/crud/system.crud.js +221 -0
  105. package/crud/system.crud.js.map +1 -0
  106. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
  107. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +66 -0
  108. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
  109. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
  110. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +239 -0
  111. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
  112. package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
  113. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +304 -0
  114. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
  115. package/fieldConverters/index.d.ts +4 -0
  116. package/fieldConverters/index.js +18 -0
  117. package/fieldConverters/index.js.map +1 -0
  118. package/graphql/buildSchemaPlugins.d.ts +11 -0
  119. package/graphql/buildSchemaPlugins.js +24 -0
  120. package/graphql/buildSchemaPlugins.js.map +1 -0
  121. package/graphql/createExecutableSchema.d.ts +7 -0
  122. package/graphql/createExecutableSchema.js +33 -0
  123. package/graphql/createExecutableSchema.js.map +1 -0
  124. package/graphql/generateSchema.d.ts +8 -0
  125. package/graphql/generateSchema.js +38 -0
  126. package/graphql/generateSchema.js.map +1 -0
  127. package/graphql/graphQLHandlerFactory.d.ts +5 -0
  128. package/graphql/graphQLHandlerFactory.js +202 -0
  129. package/graphql/graphQLHandlerFactory.js.map +1 -0
  130. package/graphql/index.d.ts +3 -0
  131. package/graphql/index.js +18 -0
  132. package/graphql/index.js.map +1 -0
  133. package/graphql/schema/baseContentSchema.d.ts +7 -0
  134. package/graphql/schema/baseContentSchema.js +78 -0
  135. package/graphql/schema/baseContentSchema.js.map +1 -0
  136. package/graphql/schema/baseSchema.d.ts +3 -0
  137. package/graphql/schema/baseSchema.js +60 -0
  138. package/graphql/schema/baseSchema.js.map +1 -0
  139. package/graphql/schema/contentEntries.d.ts +7 -0
  140. package/graphql/schema/contentEntries.js +357 -0
  141. package/graphql/schema/contentEntries.js.map +1 -0
  142. package/graphql/schema/contentModelGroups.d.ts +7 -0
  143. package/{content/plugins → graphql}/schema/contentModelGroups.js +40 -17
  144. package/graphql/schema/contentModelGroups.js.map +1 -0
  145. package/graphql/schema/contentModels.d.ts +7 -0
  146. package/{content/plugins → graphql}/schema/contentModels.js +108 -13
  147. package/graphql/schema/contentModels.js.map +1 -0
  148. package/graphql/schema/createFieldResolvers.d.ts +20 -0
  149. package/graphql/schema/createFieldResolvers.js +133 -0
  150. package/graphql/schema/createFieldResolvers.js.map +1 -0
  151. package/graphql/schema/createManageResolvers.d.ts +12 -0
  152. package/{content/plugins → graphql}/schema/createManageResolvers.js +36 -34
  153. package/graphql/schema/createManageResolvers.js.map +1 -0
  154. package/graphql/schema/createManageSDL.d.ts +12 -0
  155. package/{content/plugins → graphql}/schema/createManageSDL.js +31 -21
  156. package/graphql/schema/createManageSDL.js.map +1 -0
  157. package/graphql/schema/createPreviewResolvers.d.ts +12 -0
  158. package/graphql/schema/createPreviewResolvers.js +58 -0
  159. package/graphql/schema/createPreviewResolvers.js.map +1 -0
  160. package/graphql/schema/createReadResolvers.d.ts +12 -0
  161. package/graphql/schema/createReadResolvers.js +63 -0
  162. package/graphql/schema/createReadResolvers.js.map +1 -0
  163. package/graphql/schema/createReadSDL.d.ts +12 -0
  164. package/{content/plugins → graphql}/schema/createReadSDL.js +25 -13
  165. package/graphql/schema/createReadSDL.js.map +1 -0
  166. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
  167. package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +0 -0
  168. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
  169. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
  170. package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +2 -4
  171. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
  172. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
  173. package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +2 -4
  174. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
  175. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
  176. package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +10 -8
  177. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
  178. package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
  179. package/graphql/schema/resolvers/manage/resolveGet.js +79 -0
  180. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
  181. package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
  182. package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -4
  183. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
  184. package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
  185. package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +2 -4
  186. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
  187. package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
  188. package/{content/plugins/schema/resolvers/read → graphql/schema/resolvers/manage}/resolveList.js +2 -4
  189. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
  190. package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
  191. package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -0
  192. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
  193. package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
  194. package/{content/plugins/schema/resolvers/manage/resolveGet.js → graphql/schema/resolvers/manage/resolveRepublish.js} +4 -4
  195. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
  196. package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
  197. package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -0
  198. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
  199. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
  200. package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +2 -4
  201. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
  202. package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
  203. package/graphql/schema/resolvers/preview/resolveGet.js +34 -0
  204. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
  205. package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
  206. package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js +2 -4
  207. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
  208. package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
  209. package/graphql/schema/resolvers/read/resolveGet.js +34 -0
  210. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
  211. package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
  212. package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/read}/resolveList.js +2 -4
  213. package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
  214. package/graphql/schema/schemaPlugins.d.ts +8 -0
  215. package/graphql/schema/schemaPlugins.js +119 -0
  216. package/graphql/schema/schemaPlugins.js.map +1 -0
  217. package/graphql/system.d.ts +6 -0
  218. package/{plugins/graphql → graphql}/system.js +50 -6
  219. package/graphql/system.js.map +1 -0
  220. package/graphqlFields/boolean.d.ts +2 -0
  221. package/graphqlFields/boolean.js +69 -0
  222. package/graphqlFields/boolean.js.map +1 -0
  223. package/graphqlFields/datetime.d.ts +2 -0
  224. package/graphqlFields/datetime.js +95 -0
  225. package/graphqlFields/datetime.js.map +1 -0
  226. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
  227. package/graphqlFields/dynamicZone/dynamicZoneField.js +234 -0
  228. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
  229. package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
  230. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +79 -0
  231. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
  232. package/graphqlFields/dynamicZone/index.d.ts +2 -0
  233. package/graphqlFields/dynamicZone/index.js +21 -0
  234. package/graphqlFields/dynamicZone/index.js.map +1 -0
  235. package/graphqlFields/file.d.ts +2 -0
  236. package/graphqlFields/file.js +50 -0
  237. package/graphqlFields/file.js.map +1 -0
  238. package/graphqlFields/helpers.d.ts +6 -0
  239. package/graphqlFields/helpers.js +49 -0
  240. package/graphqlFields/helpers.js.map +1 -0
  241. package/graphqlFields/index.d.ts +2 -0
  242. package/graphqlFields/index.js +30 -0
  243. package/graphqlFields/index.js.map +1 -0
  244. package/graphqlFields/longText.d.ts +2 -0
  245. package/graphqlFields/longText.js +63 -0
  246. package/graphqlFields/longText.js.map +1 -0
  247. package/graphqlFields/number.d.ts +2 -0
  248. package/graphqlFields/number.js +79 -0
  249. package/graphqlFields/number.js.map +1 -0
  250. package/graphqlFields/object.d.ts +2 -0
  251. package/graphqlFields/object.js +275 -0
  252. package/graphqlFields/object.js.map +1 -0
  253. package/graphqlFields/ref.d.ts +2 -0
  254. package/graphqlFields/ref.js +261 -0
  255. package/graphqlFields/ref.js.map +1 -0
  256. package/graphqlFields/richText.d.ts +2 -0
  257. package/graphqlFields/richText.js +56 -0
  258. package/graphqlFields/richText.js.map +1 -0
  259. package/graphqlFields/text.d.ts +2 -0
  260. package/graphqlFields/text.js +73 -0
  261. package/graphqlFields/text.js.map +1 -0
  262. package/index.d.ts +10 -12
  263. package/index.js +75 -36
  264. package/index.js.map +1 -0
  265. package/modelManager/DefaultCmsModelManager.d.ts +14 -0
  266. package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +12 -10
  267. package/modelManager/DefaultCmsModelManager.js.map +1 -0
  268. package/modelManager/index.d.ts +2 -0
  269. package/{content/plugins/modelManager → modelManager}/index.js +3 -3
  270. package/modelManager/index.js.map +1 -0
  271. package/package.json +38 -38
  272. package/parameters/context.d.ts +2 -0
  273. package/parameters/context.js +22 -0
  274. package/parameters/context.js.map +1 -0
  275. package/parameters/header.d.ts +2 -0
  276. package/parameters/header.js +55 -0
  277. package/parameters/header.js.map +1 -0
  278. package/parameters/index.d.ts +4 -0
  279. package/parameters/index.js +57 -0
  280. package/parameters/index.js.map +1 -0
  281. package/parameters/manual.d.ts +6 -0
  282. package/parameters/manual.js +44 -0
  283. package/parameters/manual.js.map +1 -0
  284. package/parameters/path.d.ts +2 -0
  285. package/parameters/path.js +51 -0
  286. package/parameters/path.js.map +1 -0
  287. package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
  288. package/plugins/CmsGraphQLSchemaPlugin.js +17 -0
  289. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
  290. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
  291. package/plugins/CmsGraphQLSchemaSorterPlugin.js +38 -0
  292. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
  293. package/plugins/CmsGroupPlugin.d.ts +13 -0
  294. package/{content/plugins → plugins}/CmsGroupPlugin.js +9 -3
  295. package/plugins/CmsGroupPlugin.js.map +1 -0
  296. package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
  297. package/plugins/CmsModelFieldConverterPlugin.js +17 -0
  298. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
  299. package/plugins/CmsModelPlugin.d.ts +45 -0
  300. package/plugins/CmsModelPlugin.js +194 -0
  301. package/plugins/CmsModelPlugin.js.map +1 -0
  302. package/plugins/CmsParametersPlugin.d.ts +20 -0
  303. package/plugins/CmsParametersPlugin.js +28 -0
  304. package/plugins/CmsParametersPlugin.js.map +1 -0
  305. package/plugins/StorageTransformPlugin.d.ts +31 -0
  306. package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -1
  307. package/plugins/StorageTransformPlugin.js.map +1 -0
  308. package/plugins/index.d.ts +7 -0
  309. package/plugins/index.js +96 -0
  310. package/plugins/index.js.map +1 -0
  311. package/storage/default.d.ts +2 -0
  312. package/storage/default.js +27 -0
  313. package/storage/default.js.map +1 -0
  314. package/storage/object.d.ts +2 -0
  315. package/storage/object.js +127 -0
  316. package/storage/object.js.map +1 -0
  317. package/types.d.ts +878 -387
  318. package/types.js +130 -8
  319. package/types.js.map +1 -0
  320. package/upgrades/5.33.0/index.d.ts +3 -0
  321. package/upgrades/5.33.0/index.js +182 -0
  322. package/upgrades/5.33.0/index.js.map +1 -0
  323. package/upgrades/index.d.ts +1 -0
  324. package/upgrades/index.js +12 -0
  325. package/upgrades/index.js.map +1 -0
  326. package/utils/access.d.ts +8 -0
  327. package/utils/access.js +90 -0
  328. package/utils/access.js.map +1 -0
  329. package/utils/converters/Converter.d.ts +27 -0
  330. package/utils/converters/Converter.js +71 -0
  331. package/utils/converters/Converter.js.map +1 -0
  332. package/utils/converters/ConverterCollection.d.ts +31 -0
  333. package/utils/converters/ConverterCollection.js +143 -0
  334. package/utils/converters/ConverterCollection.js.map +1 -0
  335. package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
  336. package/utils/converters/valueKeyStorageConverter.js +148 -0
  337. package/utils/converters/valueKeyStorageConverter.js.map +1 -0
  338. package/utils/createTypeFromFields.d.ts +15 -0
  339. package/utils/createTypeFromFields.js +75 -0
  340. package/utils/createTypeFromFields.js.map +1 -0
  341. package/{content/plugins/utils → utils}/createTypeName.d.ts +3 -3
  342. package/{content/plugins/utils → utils}/createTypeName.js +4 -2
  343. package/utils/createTypeName.js.map +1 -0
  344. package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
  345. package/{content/plugins/utils → utils}/entryStorage.js +18 -23
  346. package/utils/entryStorage.js.map +1 -0
  347. package/utils/filterAsync.d.ts +1 -0
  348. package/utils/filterAsync.js +23 -0
  349. package/utils/filterAsync.js.map +1 -0
  350. package/utils/getBaseFieldType.d.ts +4 -0
  351. package/utils/getBaseFieldType.js +12 -0
  352. package/utils/getBaseFieldType.js.map +1 -0
  353. package/utils/getEntryTitle.d.ts +2 -0
  354. package/{content/plugins/utils → utils}/getEntryTitle.js +7 -6
  355. package/utils/getEntryTitle.js.map +1 -0
  356. package/utils/getSchemaFromFieldPlugins.d.ts +9 -0
  357. package/utils/getSchemaFromFieldPlugins.js +48 -0
  358. package/utils/getSchemaFromFieldPlugins.js.map +1 -0
  359. package/utils/ownership.d.ts +8 -0
  360. package/utils/ownership.js +41 -0
  361. package/utils/ownership.js.map +1 -0
  362. package/utils/permissions.d.ts +7 -0
  363. package/utils/permissions.js +106 -0
  364. package/utils/permissions.js.map +1 -0
  365. package/utils/pluralizedTypeName.d.ts +1 -0
  366. package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -1
  367. package/utils/pluralizedTypeName.js.map +1 -0
  368. package/utils/renderFields.d.ts +15 -0
  369. package/{content/plugins/utils → utils}/renderFields.js +7 -3
  370. package/utils/renderFields.js.map +1 -0
  371. package/utils/renderGetFilterFields.d.ts +10 -0
  372. package/utils/renderGetFilterFields.js +61 -0
  373. package/utils/renderGetFilterFields.js.map +1 -0
  374. package/utils/renderInputFields.d.ts +14 -0
  375. package/{content/plugins/utils → utils}/renderInputFields.js +4 -2
  376. package/utils/renderInputFields.js.map +1 -0
  377. package/utils/renderListFilterFields.d.ts +11 -0
  378. package/{content/plugins/utils → utils}/renderListFilterFields.js +40 -17
  379. package/utils/renderListFilterFields.js.map +1 -0
  380. package/utils/renderSortEnum.d.ts +12 -0
  381. package/utils/renderSortEnum.js +51 -0
  382. package/utils/renderSortEnum.js.map +1 -0
  383. package/utils/toSlug.d.ts +1 -0
  384. package/utils/toSlug.js +20 -0
  385. package/utils/toSlug.js.map +1 -0
  386. package/validators/dateGte.d.ts +2 -0
  387. package/{content/plugins/validators → validators}/dateGte.js +4 -4
  388. package/validators/dateGte.js.map +1 -0
  389. package/validators/dateLte.d.ts +2 -0
  390. package/{content/plugins/validators → validators}/dateLte.js +4 -4
  391. package/validators/dateLte.js.map +1 -0
  392. package/validators/dynamicZone.d.ts +2 -0
  393. package/validators/dynamicZone.js +24 -0
  394. package/validators/dynamicZone.js.map +1 -0
  395. package/validators/gte.d.ts +2 -0
  396. package/validators/gte.js +36 -0
  397. package/validators/gte.js.map +1 -0
  398. package/validators/in.d.ts +2 -0
  399. package/validators/in.js +36 -0
  400. package/validators/in.js.map +1 -0
  401. package/validators/index.d.ts +1 -0
  402. package/validators/index.js +38 -0
  403. package/validators/index.js.map +1 -0
  404. package/validators/lte.d.ts +2 -0
  405. package/validators/lte.js +36 -0
  406. package/validators/lte.js.map +1 -0
  407. package/validators/maxLength.d.ts +2 -0
  408. package/validators/maxLength.js +36 -0
  409. package/validators/maxLength.js.map +1 -0
  410. package/validators/minLength.d.ts +2 -0
  411. package/validators/minLength.js +36 -0
  412. package/validators/minLength.js.map +1 -0
  413. package/validators/pattern.d.ts +2 -0
  414. package/validators/pattern.js +50 -0
  415. package/validators/pattern.js.map +1 -0
  416. package/validators/patternPlugins/email.d.ts +2 -0
  417. package/validators/patternPlugins/email.js +20 -0
  418. package/validators/patternPlugins/email.js.map +1 -0
  419. package/validators/patternPlugins/index.d.ts +2 -0
  420. package/validators/patternPlugins/index.js +24 -0
  421. package/validators/patternPlugins/index.js.map +1 -0
  422. package/validators/patternPlugins/lowerCase.d.ts +2 -0
  423. package/validators/patternPlugins/lowerCase.js +20 -0
  424. package/validators/patternPlugins/lowerCase.js.map +1 -0
  425. package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
  426. package/validators/patternPlugins/lowerCaseSpace.js +20 -0
  427. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
  428. package/validators/patternPlugins/upperCase.d.ts +2 -0
  429. package/validators/patternPlugins/upperCase.js +20 -0
  430. package/validators/patternPlugins/upperCase.js.map +1 -0
  431. package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
  432. package/validators/patternPlugins/upperCaseSpace.js +20 -0
  433. package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
  434. package/validators/patternPlugins/url.d.ts +2 -0
  435. package/validators/patternPlugins/url.js +20 -0
  436. package/validators/patternPlugins/url.js.map +1 -0
  437. package/validators/required.d.ts +2 -0
  438. package/validators/required.js +27 -0
  439. package/validators/required.js.map +1 -0
  440. package/validators/timeGte.d.ts +2 -0
  441. package/{content/plugins/validators → validators}/timeGte.js +6 -4
  442. package/validators/timeGte.js.map +1 -0
  443. package/validators/timeLte.d.ts +2 -0
  444. package/{content/plugins/validators → validators}/timeLte.js +6 -4
  445. package/validators/timeLte.js.map +1 -0
  446. package/validators/unique.d.ts +6 -0
  447. package/validators/unique.js +63 -0
  448. package/validators/unique.js.map +1 -0
  449. package/content/contextSetup.d.ts +0 -4
  450. package/content/contextSetup.js +0 -65
  451. package/content/graphQLHandlerFactory.d.ts +0 -5
  452. package/content/graphQLHandlerFactory.js +0 -173
  453. package/content/plugins/CmsGroupPlugin.d.ts +0 -11
  454. package/content/plugins/CmsModelPlugin.d.ts +0 -11
  455. package/content/plugins/CmsModelPlugin.js +0 -24
  456. package/content/plugins/buildSchemaPlugins.d.ts +0 -7
  457. package/content/plugins/buildSchemaPlugins.js +0 -29
  458. package/content/plugins/crud/contentEntry/afterDelete.d.ts +0 -7
  459. package/content/plugins/crud/contentEntry/beforeCreate.d.ts +0 -7
  460. package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +0 -7
  461. package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +0 -4
  462. package/content/plugins/crud/contentEntry.crud.js +0 -931
  463. package/content/plugins/crud/contentModel/afterCreate.d.ts +0 -7
  464. package/content/plugins/crud/contentModel/afterCreate.js +0 -18
  465. package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
  466. package/content/plugins/crud/contentModel/afterDelete.js +0 -18
  467. package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
  468. package/content/plugins/crud/contentModel/afterUpdate.js +0 -18
  469. package/content/plugins/crud/contentModel/beforeCreate.d.ts +0 -9
  470. package/content/plugins/crud/contentModel/beforeDelete.d.ts +0 -9
  471. package/content/plugins/crud/contentModel/beforeUpdate.d.ts +0 -9
  472. package/content/plugins/crud/contentModel/beforeUpdate.js +0 -128
  473. package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +0 -2
  474. package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
  475. package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
  476. package/content/plugins/crud/contentModel/validateLayout.d.ts +0 -2
  477. package/content/plugins/crud/contentModel.crud.js +0 -425
  478. package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +0 -9
  479. package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +0 -9
  480. package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +0 -8
  481. package/content/plugins/crud/contentModelGroup.crud.js +0 -351
  482. package/content/plugins/crud/index.d.ts +0 -6
  483. package/content/plugins/crud/index.js +0 -100
  484. package/content/plugins/graphqlFields/boolean.d.ts +0 -3
  485. package/content/plugins/graphqlFields/boolean.js +0 -69
  486. package/content/plugins/graphqlFields/datetime.d.ts +0 -3
  487. package/content/plugins/graphqlFields/datetime.js +0 -83
  488. package/content/plugins/graphqlFields/file.d.ts +0 -3
  489. package/content/plugins/graphqlFields/file.js +0 -49
  490. package/content/plugins/graphqlFields/index.d.ts +0 -2
  491. package/content/plugins/graphqlFields/index.js +0 -30
  492. package/content/plugins/graphqlFields/longText.d.ts +0 -3
  493. package/content/plugins/graphqlFields/longText.js +0 -62
  494. package/content/plugins/graphqlFields/number.d.ts +0 -3
  495. package/content/plugins/graphqlFields/number.js +0 -75
  496. package/content/plugins/graphqlFields/object.d.ts +0 -3
  497. package/content/plugins/graphqlFields/object.js +0 -180
  498. package/content/plugins/graphqlFields/ref.d.ts +0 -3
  499. package/content/plugins/graphqlFields/ref.js +0 -205
  500. package/content/plugins/graphqlFields/richText.d.ts +0 -3
  501. package/content/plugins/graphqlFields/richText.js +0 -55
  502. package/content/plugins/graphqlFields/text.d.ts +0 -3
  503. package/content/plugins/graphqlFields/text.js +0 -72
  504. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
  505. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -54
  506. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
  507. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -35
  508. package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -15
  509. package/content/plugins/modelManager/index.d.ts +0 -3
  510. package/content/plugins/schema/baseSchema.d.ts +0 -4
  511. package/content/plugins/schema/baseSchema.js +0 -98
  512. package/content/plugins/schema/contentEntries.d.ts +0 -4
  513. package/content/plugins/schema/contentEntries.js +0 -166
  514. package/content/plugins/schema/contentModelGroups.d.ts +0 -4
  515. package/content/plugins/schema/contentModels.d.ts +0 -4
  516. package/content/plugins/schema/createFieldResolvers.d.ts +0 -19
  517. package/content/plugins/schema/createFieldResolvers.js +0 -92
  518. package/content/plugins/schema/createManageResolvers.d.ts +0 -11
  519. package/content/plugins/schema/createManageSDL.d.ts +0 -9
  520. package/content/plugins/schema/createPreviewResolvers.d.ts +0 -10
  521. package/content/plugins/schema/createPreviewResolvers.js +0 -55
  522. package/content/plugins/schema/createReadResolvers.d.ts +0 -10
  523. package/content/plugins/schema/createReadResolvers.js +0 -55
  524. package/content/plugins/schema/createReadSDL.d.ts +0 -9
  525. package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
  526. package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +0 -6
  527. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +0 -7
  528. package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +0 -2
  529. package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +0 -2
  530. package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +0 -2
  531. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +0 -2
  532. package/content/plugins/schema/resolvers/manage/resolveList.d.ts +0 -2
  533. package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +0 -2
  534. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -6
  535. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +0 -23
  536. package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +0 -6
  537. package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +0 -23
  538. package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +0 -2
  539. package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +0 -7
  540. package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +0 -2
  541. package/content/plugins/schema/resolvers/preview/resolveGet.js +0 -38
  542. package/content/plugins/schema/resolvers/preview/resolveList.d.ts +0 -2
  543. package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
  544. package/content/plugins/schema/resolvers/read/resolveGet.js +0 -38
  545. package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
  546. package/content/plugins/schema/schemaPlugins.d.ts +0 -3
  547. package/content/plugins/schema/schemaPlugins.js +0 -92
  548. package/content/plugins/storage/StorageTransformPlugin.d.ts +0 -30
  549. package/content/plugins/storage/default.d.ts +0 -3
  550. package/content/plugins/storage/default.js +0 -28
  551. package/content/plugins/storage/object.d.ts +0 -3
  552. package/content/plugins/storage/object.js +0 -119
  553. package/content/plugins/utils/getEntryTitle.d.ts +0 -2
  554. package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +0 -11
  555. package/content/plugins/utils/getSchemaFromFieldPlugins.js +0 -30
  556. package/content/plugins/utils/pluralizedTypeName.d.ts +0 -1
  557. package/content/plugins/utils/renderFields.d.ts +0 -16
  558. package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
  559. package/content/plugins/utils/renderGetFilterFields.js +0 -41
  560. package/content/plugins/utils/renderInputFields.d.ts +0 -14
  561. package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
  562. package/content/plugins/utils/renderSortEnum.d.ts +0 -9
  563. package/content/plugins/utils/renderSortEnum.js +0 -32
  564. package/content/plugins/validators/dateGte.d.ts +0 -3
  565. package/content/plugins/validators/dateLte.d.ts +0 -3
  566. package/content/plugins/validators/gte.d.ts +0 -3
  567. package/content/plugins/validators/gte.js +0 -32
  568. package/content/plugins/validators/in.d.ts +0 -3
  569. package/content/plugins/validators/in.js +0 -32
  570. package/content/plugins/validators/index.d.ts +0 -2
  571. package/content/plugins/validators/index.js +0 -36
  572. package/content/plugins/validators/lte.d.ts +0 -3
  573. package/content/plugins/validators/lte.js +0 -32
  574. package/content/plugins/validators/maxLength.d.ts +0 -3
  575. package/content/plugins/validators/maxLength.js +0 -32
  576. package/content/plugins/validators/minLength.d.ts +0 -3
  577. package/content/plugins/validators/minLength.js +0 -32
  578. package/content/plugins/validators/pattern.d.ts +0 -3
  579. package/content/plugins/validators/pattern.js +0 -47
  580. package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
  581. package/content/plugins/validators/patternPlugins/email.js +0 -17
  582. package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
  583. package/content/plugins/validators/patternPlugins/index.js +0 -19
  584. package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
  585. package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
  586. package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
  587. package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
  588. package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
  589. package/content/plugins/validators/patternPlugins/url.js +0 -17
  590. package/content/plugins/validators/required.d.ts +0 -3
  591. package/content/plugins/validators/required.js +0 -25
  592. package/content/plugins/validators/timeGte.d.ts +0 -3
  593. package/content/plugins/validators/timeLte.d.ts +0 -3
  594. package/migrateCMSPermissions.d.ts +0 -17
  595. package/migrateCMSPermissions.js +0 -193
  596. package/plugins/context.d.ts +0 -4
  597. package/plugins/context.js +0 -34
  598. package/plugins/crud/index.d.ts +0 -6
  599. package/plugins/crud/index.js +0 -100
  600. package/plugins/crud/settings.crud.js +0 -93
  601. package/plugins/crud/system.crud.js +0 -182
  602. package/plugins/graphql/system.d.ts +0 -17
  603. package/plugins/graphql.d.ts +0 -2
  604. package/plugins/graphql.js +0 -79
  605. package/plugins/upgrades/index.d.ts +0 -2
  606. package/plugins/upgrades/index.js +0 -14
  607. package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
  608. package/plugins/upgrades/v5.5.0/helpers.js +0 -10
  609. package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
  610. package/plugins/upgrades/v5.5.0/index.js +0 -129
  611. package/transformers.d.ts +0 -2
  612. package/transformers.js +0 -25
  613. package/utils.d.ts +0 -25
  614. package/utils.js +0 -251
@@ -0,0 +1,8 @@
1
+ import { CmsContext, CmsGroup, CmsGroupPermission, CmsModel } from "../types";
2
+ export declare const validateGroupAccess: (context: CmsContext, permission: CmsGroupPermission, group: CmsGroup) => boolean;
3
+ export declare const validateModelAccess: (context: CmsContext, model: CmsModel) => Promise<boolean>;
4
+ /**
5
+ * model access is checking for both specific model or group access
6
+ * if permission has specific models set as access pattern then groups will not matter (although both can be set)
7
+ */
8
+ export declare const checkModelAccess: (context: CmsContext, model: CmsModel) => Promise<void>;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateModelAccess = exports.validateGroupAccess = exports.checkModelAccess = void 0;
7
+
8
+ var _apiSecurity = require("@webiny/api-security");
9
+
10
+ var _permissions = require("./permissions");
11
+
12
+ const validateGroupAccess = (context, permission, group) => {
13
+ const {
14
+ groups
15
+ } = permission; // when no groups defined on permission
16
+ // it means user has access to everything
17
+
18
+ if (!groups) {
19
+ return true;
20
+ }
21
+
22
+ const locale = context.cms.getLocale().code; // when there is no locale in groups, it means that no access was given
23
+ // this happens when access control was set but no models or groups were added
24
+
25
+ if (Array.isArray(groups[locale]) === false || groups[locale].includes(group.id) === false) {
26
+ return false;
27
+ }
28
+
29
+ return true;
30
+ };
31
+
32
+ exports.validateGroupAccess = validateGroupAccess;
33
+
34
+ const validateModelAccess = async (context, model) => {
35
+ const modelGroupPermission = await (0, _permissions.checkPermissions)(context, "cms.contentModelGroup", {
36
+ rwd: "r"
37
+ });
38
+ const {
39
+ groups
40
+ } = modelGroupPermission;
41
+ const modelPermission = await (0, _permissions.checkPermissions)(context, "cms.contentModel", {
42
+ rwd: "r"
43
+ });
44
+ const {
45
+ models
46
+ } = modelPermission; // when no models or groups defined on permission
47
+ // it means user has access to everything
48
+
49
+ if (!models && !groups) {
50
+ return true;
51
+ }
52
+
53
+ const locale = context.cms.getLocale().code; // Check whether the model is question belongs to "content model groups" for which user has permission.
54
+
55
+ if (groups) {
56
+ if (Array.isArray(groups[locale]) === false || groups[locale].includes(model.group.id) === false) {
57
+ return false;
58
+ }
59
+ } // Check whether the model is question belongs to "content models" for which user has permission.
60
+
61
+
62
+ if (models) {
63
+ if (Array.isArray(models[locale]) === false || models[locale].includes(model.modelId) === false) {
64
+ return false;
65
+ }
66
+ }
67
+
68
+ return true;
69
+ };
70
+ /**
71
+ * model access is checking for both specific model or group access
72
+ * if permission has specific models set as access pattern then groups will not matter (although both can be set)
73
+ */
74
+
75
+
76
+ exports.validateModelAccess = validateModelAccess;
77
+
78
+ const checkModelAccess = async (context, model) => {
79
+ if (await validateModelAccess(context, model)) {
80
+ return;
81
+ }
82
+
83
+ throw new _apiSecurity.NotAuthorizedError({
84
+ data: {
85
+ reason: `Not allowed to access model "${model.modelId}".`
86
+ }
87
+ });
88
+ };
89
+
90
+ exports.checkModelAccess = checkModelAccess;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateGroupAccess","context","permission","group","groups","locale","cms","getLocale","code","Array","isArray","includes","id","validateModelAccess","model","modelGroupPermission","checkPermissions","rwd","modelPermission","models","modelId","checkModelAccess","NotAuthorizedError","data","reason"],"sources":["access.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport { CmsContext, CmsGroup, CmsGroupPermission, CmsModel, CmsModelPermission } from \"~/types\";\nimport { checkPermissions } from \"./permissions\";\n\nexport const validateGroupAccess = (\n context: CmsContext,\n permission: CmsGroupPermission,\n group: CmsGroup\n): boolean => {\n const { groups } = permission;\n // when no groups defined on permission\n // it means user has access to everything\n if (!groups) {\n return true;\n }\n const locale = context.cms.getLocale().code;\n // when there is no locale in groups, it means that no access was given\n // this happens when access control was set but no models or groups were added\n if (Array.isArray(groups[locale]) === false || groups[locale].includes(group.id) === false) {\n return false;\n }\n return true;\n};\n\nexport const validateModelAccess = async (\n context: CmsContext,\n model: CmsModel\n): Promise<boolean> => {\n const modelGroupPermission: CmsGroupPermission = await checkPermissions(\n context,\n \"cms.contentModelGroup\",\n { rwd: \"r\" }\n );\n const { groups } = modelGroupPermission;\n\n const modelPermission: CmsModelPermission = await checkPermissions(\n context,\n \"cms.contentModel\",\n {\n rwd: \"r\"\n }\n );\n const { models } = modelPermission;\n // when no models or groups defined on permission\n // it means user has access to everything\n if (!models && !groups) {\n return true;\n }\n const locale = context.cms.getLocale().code;\n // Check whether the model is question belongs to \"content model groups\" for which user has permission.\n if (groups) {\n if (\n Array.isArray(groups[locale]) === false ||\n groups[locale].includes(model.group.id) === false\n ) {\n return false;\n }\n }\n // Check whether the model is question belongs to \"content models\" for which user has permission.\n if (models) {\n if (\n Array.isArray(models[locale]) === false ||\n models[locale].includes(model.modelId) === false\n ) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * model access is checking for both specific model or group access\n * if permission has specific models set as access pattern then groups will not matter (although both can be set)\n */\nexport const checkModelAccess = async (context: CmsContext, model: CmsModel): Promise<void> => {\n if (await validateModelAccess(context, model)) {\n return;\n }\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access model \"${model.modelId}\".`\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEO,MAAMA,mBAAmB,GAAG,CAC/BC,OAD+B,EAE/BC,UAF+B,EAG/BC,KAH+B,KAIrB;EACV,MAAM;IAAEC;EAAF,IAAaF,UAAnB,CADU,CAEV;EACA;;EACA,IAAI,CAACE,MAAL,EAAa;IACT,OAAO,IAAP;EACH;;EACD,MAAMC,MAAM,GAAGJ,OAAO,CAACK,GAAR,CAAYC,SAAZ,GAAwBC,IAAvC,CAPU,CAQV;EACA;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcN,MAAM,CAACC,MAAD,CAApB,MAAkC,KAAlC,IAA2CD,MAAM,CAACC,MAAD,CAAN,CAAeM,QAAf,CAAwBR,KAAK,CAACS,EAA9B,MAAsC,KAArF,EAA4F;IACxF,OAAO,KAAP;EACH;;EACD,OAAO,IAAP;AACH,CAlBM;;;;AAoBA,MAAMC,mBAAmB,GAAG,OAC/BZ,OAD+B,EAE/Ba,KAF+B,KAGZ;EACnB,MAAMC,oBAAwC,GAAG,MAAM,IAAAC,6BAAA,EACnDf,OADmD,EAEnD,uBAFmD,EAGnD;IAAEgB,GAAG,EAAE;EAAP,CAHmD,CAAvD;EAKA,MAAM;IAAEb;EAAF,IAAaW,oBAAnB;EAEA,MAAMG,eAAmC,GAAG,MAAM,IAAAF,6BAAA,EAC9Cf,OAD8C,EAE9C,kBAF8C,EAG9C;IACIgB,GAAG,EAAE;EADT,CAH8C,CAAlD;EAOA,MAAM;IAAEE;EAAF,IAAaD,eAAnB,CAfmB,CAgBnB;EACA;;EACA,IAAI,CAACC,MAAD,IAAW,CAACf,MAAhB,EAAwB;IACpB,OAAO,IAAP;EACH;;EACD,MAAMC,MAAM,GAAGJ,OAAO,CAACK,GAAR,CAAYC,SAAZ,GAAwBC,IAAvC,CArBmB,CAsBnB;;EACA,IAAIJ,MAAJ,EAAY;IACR,IACIK,KAAK,CAACC,OAAN,CAAcN,MAAM,CAACC,MAAD,CAApB,MAAkC,KAAlC,IACAD,MAAM,CAACC,MAAD,CAAN,CAAeM,QAAf,CAAwBG,KAAK,CAACX,KAAN,CAAYS,EAApC,MAA4C,KAFhD,EAGE;MACE,OAAO,KAAP;IACH;EACJ,CA9BkB,CA+BnB;;;EACA,IAAIO,MAAJ,EAAY;IACR,IACIV,KAAK,CAACC,OAAN,CAAcS,MAAM,CAACd,MAAD,CAApB,MAAkC,KAAlC,IACAc,MAAM,CAACd,MAAD,CAAN,CAAeM,QAAf,CAAwBG,KAAK,CAACM,OAA9B,MAA2C,KAF/C,EAGE;MACE,OAAO,KAAP;IACH;EACJ;;EAED,OAAO,IAAP;AACH,CA7CM;AA+CP;AACA;AACA;AACA;;;;;AACO,MAAMC,gBAAgB,GAAG,OAAOpB,OAAP,EAA4Ba,KAA5B,KAA+D;EAC3F,IAAI,MAAMD,mBAAmB,CAACZ,OAAD,EAAUa,KAAV,CAA7B,EAA+C;IAC3C;EACH;;EACD,MAAM,IAAIQ,+BAAJ,CAAuB;IACzBC,IAAI,EAAE;MACFC,MAAM,EAAG,gCAA+BV,KAAK,CAACM,OAAQ;IADpD;EADmB,CAAvB,CAAN;AAKH,CATM"}
@@ -0,0 +1,27 @@
1
+ import { CmsEntryValues, CmsModelField } from "../../types";
2
+ import { CmsModelFieldConverterPlugin } from "../../plugins";
3
+ import { ConverterCollection } from "./ConverterCollection";
4
+ export interface CmsModelFieldWithParent extends CmsModelField {
5
+ parent?: CmsModelFieldWithParent | null;
6
+ }
7
+ interface ConverterConvertParams {
8
+ field: CmsModelFieldWithParent;
9
+ value: any;
10
+ parent?: CmsModelFieldWithParent | null;
11
+ }
12
+ export interface ConverterConfig {
13
+ type: string;
14
+ plugin: CmsModelFieldConverterPlugin;
15
+ }
16
+ export declare class Converter {
17
+ private readonly type;
18
+ private readonly plugin;
19
+ private converters;
20
+ constructor(config: ConverterConfig);
21
+ setConverterCollection(converters: ConverterCollection): void;
22
+ getConverterCollection(): ConverterCollection;
23
+ getType(): string;
24
+ convertToStorage(params: ConverterConvertParams): CmsEntryValues;
25
+ convertFromStorage(params: ConverterConvertParams): CmsEntryValues;
26
+ }
27
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Converter = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ class Converter {
15
+ constructor(config) {
16
+ (0, _defineProperty2.default)(this, "type", void 0);
17
+ (0, _defineProperty2.default)(this, "plugin", void 0);
18
+ (0, _defineProperty2.default)(this, "converters", undefined);
19
+ this.type = config.type;
20
+ this.plugin = config.plugin;
21
+ }
22
+
23
+ setConverterCollection(converters) {
24
+ if (this.converters) {
25
+ throw new _error.default(`Cannot attach converters collection more than once to Converter with type "${this.type}".`, "CONVERTER_COLLECTION_ERROR", {
26
+ type: this.type
27
+ });
28
+ }
29
+
30
+ this.converters = converters;
31
+ }
32
+
33
+ getConverterCollection() {
34
+ if (!this.converters) {
35
+ throw new _error.default(`There is no ConverterCollection defined in the converter with type "${this.type}".`);
36
+ }
37
+
38
+ return this.converters;
39
+ }
40
+
41
+ getType() {
42
+ return this.type;
43
+ }
44
+
45
+ convertToStorage(params) {
46
+ const {
47
+ field,
48
+ value
49
+ } = params;
50
+ return this.plugin.convertToStorage({
51
+ field,
52
+ value,
53
+ converterCollection: this.getConverterCollection()
54
+ });
55
+ }
56
+
57
+ convertFromStorage(params) {
58
+ const {
59
+ field,
60
+ value
61
+ } = params;
62
+ return this.plugin.convertFromStorage({
63
+ field,
64
+ value,
65
+ converterCollection: this.getConverterCollection()
66
+ });
67
+ }
68
+
69
+ }
70
+
71
+ exports.Converter = Converter;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Converter","constructor","config","undefined","type","plugin","setConverterCollection","converters","WebinyError","getConverterCollection","getType","convertToStorage","params","field","value","converterCollection","convertFromStorage"],"sources":["Converter.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryValues, CmsModelField } from \"~/types\";\nimport { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport { ConverterCollection } from \"./ConverterCollection\";\n\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\ninterface ConverterConvertParams {\n field: CmsModelFieldWithParent;\n value: any;\n parent?: CmsModelFieldWithParent | null;\n}\nexport interface ConverterConfig {\n type: string;\n plugin: CmsModelFieldConverterPlugin;\n}\nexport class Converter {\n private readonly type: string;\n private readonly plugin: CmsModelFieldConverterPlugin;\n\n private converters: ConverterCollection | undefined = undefined;\n\n public constructor(config: ConverterConfig) {\n this.type = config.type;\n this.plugin = config.plugin;\n }\n\n public setConverterCollection(converters: ConverterCollection): void {\n if (this.converters) {\n throw new WebinyError(\n `Cannot attach converters collection more than once to Converter with type \"${this.type}\".`,\n \"CONVERTER_COLLECTION_ERROR\",\n {\n type: this.type\n }\n );\n }\n this.converters = converters;\n }\n\n public getConverterCollection(): ConverterCollection {\n if (!this.converters) {\n throw new WebinyError(\n `There is no ConverterCollection defined in the converter with type \"${this.type}\".`\n );\n }\n return this.converters;\n }\n\n public getType(): string {\n return this.type;\n }\n\n public convertToStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertToStorage({\n field,\n value,\n converterCollection: this.getConverterCollection()\n });\n }\n\n public convertFromStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertFromStorage({\n field,\n value,\n converterCollection: this.getConverterCollection()\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAkBO,MAAMA,SAAN,CAAgB;EAMZC,WAAW,CAACC,MAAD,EAA0B;IAAA;IAAA;IAAA,kDAFUC,SAEV;IACxC,KAAKC,IAAL,GAAYF,MAAM,CAACE,IAAnB;IACA,KAAKC,MAAL,GAAcH,MAAM,CAACG,MAArB;EACH;;EAEMC,sBAAsB,CAACC,UAAD,EAAwC;IACjE,IAAI,KAAKA,UAAT,EAAqB;MACjB,MAAM,IAAIC,cAAJ,CACD,8EAA6E,KAAKJ,IAAK,IADtF,EAEF,4BAFE,EAGF;QACIA,IAAI,EAAE,KAAKA;MADf,CAHE,CAAN;IAOH;;IACD,KAAKG,UAAL,GAAkBA,UAAlB;EACH;;EAEME,sBAAsB,GAAwB;IACjD,IAAI,CAAC,KAAKF,UAAV,EAAsB;MAClB,MAAM,IAAIC,cAAJ,CACD,uEAAsE,KAAKJ,IAAK,IAD/E,CAAN;IAGH;;IACD,OAAO,KAAKG,UAAZ;EACH;;EAEMG,OAAO,GAAW;IACrB,OAAO,KAAKN,IAAZ;EACH;;EAEMO,gBAAgB,CAACC,MAAD,EAAiD;IACpE,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAmBF,MAAzB;IAEA,OAAO,KAAKP,MAAL,CAAYM,gBAAZ,CAA6B;MAChCE,KADgC;MAEhCC,KAFgC;MAGhCC,mBAAmB,EAAE,KAAKN,sBAAL;IAHW,CAA7B,CAAP;EAKH;;EAEMO,kBAAkB,CAACJ,MAAD,EAAiD;IACtE,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAmBF,MAAzB;IAEA,OAAO,KAAKP,MAAL,CAAYW,kBAAZ,CAA+B;MAClCH,KADkC;MAElCC,KAFkC;MAGlCC,mBAAmB,EAAE,KAAKN,sBAAL;IAHa,CAA/B,CAAP;EAKH;;AAvDkB"}
@@ -0,0 +1,31 @@
1
+ import { Converter } from "./Converter";
2
+ import { CmsEntryValues, CmsModelField } from "../../types";
3
+ import { PluginsContainer } from "@webiny/plugins";
4
+ export interface CmsModelFieldsWithParent extends CmsModelField {
5
+ parent?: CmsModelField | null;
6
+ }
7
+ export interface CmsModelConverterCallable {
8
+ (params: ConverterCollectionConvertParams): CmsEntryValues;
9
+ }
10
+ export interface ConverterCollectionConvertParams {
11
+ fields: CmsModelFieldsWithParent[];
12
+ values?: CmsEntryValues;
13
+ }
14
+ export interface ConverterCollectionParams {
15
+ plugins: PluginsContainer;
16
+ }
17
+ export declare class ConverterCollection {
18
+ private readonly converters;
19
+ constructor(params: ConverterCollectionParams);
20
+ addConverter(converter: Converter): void;
21
+ getConverter(type: string): Converter;
22
+ convertToStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined;
23
+ convertFromStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined;
24
+ /**
25
+ * This method attaches hasOwnProperty when received object was created via Object.create(null) - no inheritance of Object.
26
+ * At that point, hasOwnProperty does not exist, and we need to add it.
27
+ *
28
+ * TODO add more checks if required
29
+ */
30
+ private attachHasOwnProperty;
31
+ }
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ConverterCollection = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _error = _interopRequireDefault(require("@webiny/error"));
15
+
16
+ var _Converter = require("./Converter");
17
+
18
+ var _plugins = require("../../plugins");
19
+
20
+ var _getBaseFieldType = require("../getBaseFieldType");
21
+
22
+ class ConverterCollection {
23
+ constructor(params) {
24
+ (0, _defineProperty2.default)(this, "converters", new Map());
25
+ const {
26
+ plugins
27
+ } = params;
28
+ const fieldGraphQLPlugins = plugins.byType("cms-model-field-to-graphql");
29
+ const fieldConverterPlugins = plugins.byType(_plugins.CmsModelFieldConverterPlugin.type);
30
+ const defaultFieldConverterPlugin = fieldConverterPlugins.find(pl => pl.getFieldType() === "*");
31
+
32
+ if (defaultFieldConverterPlugin === undefined) {
33
+ throw new _error.default(`Missing default field converter plugin.`, "DEFAULT_FIELD_CONVERTER_ERROR");
34
+ }
35
+
36
+ for (const fieldGraphQLPlugin of fieldGraphQLPlugins) {
37
+ const plugin = fieldConverterPlugins.find(pl => pl.getFieldType() === fieldGraphQLPlugin.fieldType);
38
+ const converter = new _Converter.Converter({
39
+ type: fieldGraphQLPlugin.fieldType,
40
+ plugin: plugin || defaultFieldConverterPlugin
41
+ });
42
+ this.addConverter(converter);
43
+ }
44
+ }
45
+
46
+ addConverter(converter) {
47
+ converter.setConverterCollection(this);
48
+ this.converters.set(converter.getType(), converter);
49
+ }
50
+
51
+ getConverter(type) {
52
+ const converter = this.converters.get(type);
53
+
54
+ if (converter === undefined) {
55
+ throw new _error.default(`Missing converter for field type "${type}".`, "CONVERTER_ERROR", {
56
+ type
57
+ });
58
+ }
59
+
60
+ return converter;
61
+ }
62
+
63
+ convertToStorage(params) {
64
+ const {
65
+ fields,
66
+ values: inputValues
67
+ } = params;
68
+
69
+ if (inputValues === undefined) {
70
+ return undefined;
71
+ }
72
+
73
+ this.attachHasOwnProperty(inputValues);
74
+ return fields.reduce((output, field) => {
75
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
76
+ const converter = this.getConverter(baseType);
77
+
78
+ if (inputValues === null || inputValues.hasOwnProperty(field.fieldId) === false) {
79
+ return output;
80
+ }
81
+
82
+ const values = converter.convertToStorage({
83
+ field,
84
+ value: inputValues[field.fieldId]
85
+ });
86
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, output), values);
87
+ }, {});
88
+ }
89
+
90
+ convertFromStorage(params) {
91
+ const {
92
+ fields,
93
+ values: inputValues
94
+ } = params;
95
+
96
+ if (inputValues === undefined) {
97
+ return undefined;
98
+ }
99
+
100
+ return fields.reduce((output, field) => {
101
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
102
+ const converter = this.getConverter(baseType);
103
+
104
+ if (inputValues === null || inputValues.hasOwnProperty(field.storageId) === false) {
105
+ return output;
106
+ }
107
+
108
+ const values = converter.convertFromStorage({
109
+ field,
110
+ value: inputValues[field.storageId]
111
+ });
112
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, output), values);
113
+ }, {});
114
+ }
115
+ /**
116
+ * This method attaches hasOwnProperty when received object was created via Object.create(null) - no inheritance of Object.
117
+ * At that point, hasOwnProperty does not exist, and we need to add it.
118
+ *
119
+ * TODO add more checks if required
120
+ */
121
+
122
+
123
+ attachHasOwnProperty(values) {
124
+ if ( // null or undefined?
125
+ values === null || values === undefined || // not an object?
126
+ typeof values !== "object" || // maybe it's an array?
127
+ Array.isArray(values) || // and in the end, check if hasOwnProperty is a function already
128
+ typeof (values === null || values === void 0 ? void 0 : values.hasOwnProperty) === "function") {
129
+ return;
130
+ }
131
+
132
+ Object.defineProperty(values, "hasOwnProperty", {
133
+ enumerable: false,
134
+ writable: false,
135
+ value: function (property) {
136
+ return this[property] !== undefined;
137
+ }
138
+ });
139
+ }
140
+
141
+ }
142
+
143
+ exports.ConverterCollection = ConverterCollection;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ConverterCollection","constructor","params","Map","plugins","fieldGraphQLPlugins","byType","fieldConverterPlugins","CmsModelFieldConverterPlugin","type","defaultFieldConverterPlugin","find","pl","getFieldType","undefined","WebinyError","fieldGraphQLPlugin","plugin","fieldType","converter","Converter","addConverter","setConverterCollection","converters","set","getType","getConverter","get","convertToStorage","fields","values","inputValues","attachHasOwnProperty","reduce","output","field","baseType","getBaseFieldType","hasOwnProperty","fieldId","value","convertFromStorage","storageId","Array","isArray","Object","defineProperty","enumerable","writable","property"],"sources":["ConverterCollection.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"./Converter\";\nimport { CmsEntryValues, CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport interface CmsModelFieldsWithParent extends CmsModelField {\n parent?: CmsModelField | null;\n}\n\nexport interface CmsModelConverterCallable {\n (params: ConverterCollectionConvertParams): CmsEntryValues;\n}\n\nexport interface ConverterCollectionConvertParams {\n fields: CmsModelFieldsWithParent[];\n values?: CmsEntryValues;\n}\n\nexport interface ConverterCollectionParams {\n plugins: PluginsContainer;\n}\n\nexport class ConverterCollection {\n private readonly converters: Map<string, Converter> = new Map();\n\n public constructor(params: ConverterCollectionParams) {\n const { plugins } = params;\n const fieldGraphQLPlugins = plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n const fieldConverterPlugins = plugins.byType<CmsModelFieldConverterPlugin>(\n CmsModelFieldConverterPlugin.type\n );\n const defaultFieldConverterPlugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === \"*\"\n );\n if (defaultFieldConverterPlugin === undefined) {\n throw new WebinyError(\n `Missing default field converter plugin.`,\n \"DEFAULT_FIELD_CONVERTER_ERROR\"\n );\n }\n for (const fieldGraphQLPlugin of fieldGraphQLPlugins) {\n const plugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === fieldGraphQLPlugin.fieldType\n );\n const converter = new Converter({\n type: fieldGraphQLPlugin.fieldType,\n plugin: plugin || defaultFieldConverterPlugin\n });\n\n this.addConverter(converter);\n }\n }\n\n public addConverter(converter: Converter): void {\n converter.setConverterCollection(this);\n this.converters.set(converter.getType(), converter);\n }\n\n public getConverter(type: string): Converter {\n const converter = this.converters.get(type);\n if (converter === undefined) {\n throw new WebinyError(\n `Missing converter for field type \"${type}\".`,\n \"CONVERTER_ERROR\",\n {\n type\n }\n );\n }\n return converter;\n }\n\n public convertToStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n this.attachHasOwnProperty(inputValues);\n\n return fields.reduce<CmsEntryValues>((output, field) => {\n const baseType = getBaseFieldType(field);\n const converter = this.getConverter(baseType);\n if (inputValues === null || inputValues.hasOwnProperty(field.fieldId) === false) {\n return output;\n }\n const values = converter.convertToStorage({\n field,\n value: inputValues[field.fieldId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n\n public convertFromStorage(\n params: ConverterCollectionConvertParams\n ): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n return fields.reduce((output, field) => {\n const baseType = getBaseFieldType(field);\n const converter = this.getConverter(baseType);\n if (inputValues === null || inputValues.hasOwnProperty(field.storageId) === false) {\n return output;\n }\n const values = converter.convertFromStorage({\n field,\n value: inputValues[field.storageId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n\n /**\n * This method attaches hasOwnProperty when received object was created via Object.create(null) - no inheritance of Object.\n * At that point, hasOwnProperty does not exist, and we need to add it.\n *\n * TODO add more checks if required\n */\n private attachHasOwnProperty(values: CmsEntryValues) {\n if (\n // null or undefined?\n values === null ||\n values === undefined ||\n // not an object?\n typeof values !== \"object\" ||\n // maybe it's an array?\n Array.isArray(values) ||\n // and in the end, check if hasOwnProperty is a function already\n typeof values?.hasOwnProperty === \"function\"\n ) {\n return;\n }\n Object.defineProperty(values, \"hasOwnProperty\", {\n enumerable: false,\n writable: false,\n value: function (property: string) {\n return this[property] !== undefined;\n }\n });\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,18 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { CmsModelConverterCallable } from "./ConverterCollection";
3
+ import { CmsModel, StorageOperationsCmsModel } from "../../types";
4
+ interface Params {
5
+ /**
6
+ * We need a model to determine if the conversion feature is enabled.
7
+ */
8
+ model: CmsModel;
9
+ plugins: PluginsContainer;
10
+ }
11
+ export declare const createValueKeyToStorageConverter: (params: Params) => CmsModelConverterCallable;
12
+ export declare const createValueKeyFromStorageConverter: (params: Params) => CmsModelConverterCallable;
13
+ interface AttachConvertersParams {
14
+ plugins: PluginsContainer;
15
+ model: CmsModel;
16
+ }
17
+ export declare const attachCmsModelFieldConverters: (params: AttachConvertersParams) => StorageOperationsCmsModel;
18
+ export {};
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.attachCmsModelFieldConverters = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _ConverterCollection = require("./ConverterCollection");
13
+
14
+ var _semver = _interopRequireDefault(require("semver"));
15
+
16
+ const featureVersion = _semver.default.coerce("5.33.0");
17
+
18
+ const isBetaOrNext = model => {
19
+ if (!model.webinyVersion) {
20
+ return false;
21
+ }
22
+
23
+ return model.webinyVersion.match(/next|beta/) !== null;
24
+ };
25
+
26
+ const isFeatureEnabled = model => {
27
+ /**
28
+ * In case of disabled webinyVersion value, we disable this feature.
29
+ * This is only for testing...
30
+ */
31
+ if (model.webinyVersion === "disable") {
32
+ return false;
33
+ }
34
+ /**
35
+ * If is a test environment, always have this turned on.
36
+ */
37
+
38
+
39
+ if (process.env.NODE_ENV === "test" || isBetaOrNext(model) === true) {
40
+ return true;
41
+ }
42
+ /**
43
+ * Possibility that the version is not defined, this means it is a quite old system where models did not change.
44
+ */
45
+
46
+
47
+ if (!model.webinyVersion) {
48
+ return false;
49
+ }
50
+ /**
51
+ * In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.
52
+ *
53
+ * TODO change if necessary after the update to the system
54
+ */
55
+
56
+
57
+ const modelVersion = _semver.default.coerce(model.webinyVersion);
58
+
59
+ if (!modelVersion) {
60
+ console.log(`Warning: Model "${model.modelId}" does not have valid Webiny version set.`);
61
+ return true;
62
+ } else if (_semver.default.compare(modelVersion, featureVersion) === -1) {
63
+ return false;
64
+ }
65
+
66
+ return true;
67
+ };
68
+
69
+ const createValueKeyToStorageConverter = params => {
70
+ const {
71
+ plugins,
72
+ model
73
+ } = params;
74
+
75
+ if (isFeatureEnabled(model) === false) {
76
+ return ({
77
+ values
78
+ }) => {
79
+ return values || {};
80
+ };
81
+ }
82
+
83
+ const converters = new _ConverterCollection.ConverterCollection({
84
+ plugins
85
+ });
86
+ return ({
87
+ fields,
88
+ values
89
+ }) => {
90
+ const result = converters.convertToStorage({
91
+ fields: fields || model.fields,
92
+ values
93
+ });
94
+ return result || {};
95
+ };
96
+ };
97
+
98
+ exports.createValueKeyToStorageConverter = createValueKeyToStorageConverter;
99
+
100
+ const createValueKeyFromStorageConverter = params => {
101
+ const {
102
+ plugins,
103
+ model
104
+ } = params;
105
+
106
+ if (isFeatureEnabled(model) === false) {
107
+ return ({
108
+ values
109
+ }) => {
110
+ return values || {};
111
+ };
112
+ }
113
+
114
+ const converters = new _ConverterCollection.ConverterCollection({
115
+ plugins
116
+ });
117
+ return ({
118
+ fields,
119
+ values
120
+ }) => {
121
+ const result = converters.convertFromStorage({
122
+ fields: fields || model.fields,
123
+ values
124
+ });
125
+ return result || {};
126
+ };
127
+ };
128
+
129
+ exports.createValueKeyFromStorageConverter = createValueKeyFromStorageConverter;
130
+
131
+ const attachCmsModelFieldConverters = params => {
132
+ const {
133
+ model,
134
+ plugins
135
+ } = params;
136
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
137
+ convertValueKeyToStorage: createValueKeyToStorageConverter({
138
+ model,
139
+ plugins
140
+ }),
141
+ convertValueKeyFromStorage: createValueKeyFromStorageConverter({
142
+ model,
143
+ plugins
144
+ })
145
+ });
146
+ };
147
+
148
+ exports.attachCmsModelFieldConverters = attachCmsModelFieldConverters;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["featureVersion","semver","coerce","isBetaOrNext","model","webinyVersion","match","isFeatureEnabled","process","env","NODE_ENV","modelVersion","console","log","modelId","compare","createValueKeyToStorageConverter","params","plugins","values","converters","ConverterCollection","fields","result","convertToStorage","createValueKeyFromStorageConverter","convertFromStorage","attachCmsModelFieldConverters","convertValueKeyToStorage","convertValueKeyFromStorage"],"sources":["valueKeyStorageConverter.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsModelConverterCallable,\n ConverterCollection,\n ConverterCollectionConvertParams as BaseConverterCollectionConvertParams\n} from \"~/utils/converters/ConverterCollection\";\nimport { CmsModel, StorageOperationsCmsModel } from \"~/types\";\nimport semver, { SemVer } from \"semver\";\n\nconst featureVersion = semver.coerce(\"5.33.0\") as SemVer;\n\nconst isBetaOrNext = (model: CmsModel): boolean => {\n if (!model.webinyVersion) {\n return false;\n }\n return model.webinyVersion.match(/next|beta/) !== null;\n};\n\nconst isFeatureEnabled = (model: CmsModel): boolean => {\n /**\n * In case of disabled webinyVersion value, we disable this feature.\n * This is only for testing...\n */\n if (model.webinyVersion === \"disable\") {\n return false;\n }\n /**\n * If is a test environment, always have this turned on.\n */\n if (process.env.NODE_ENV === \"test\" || isBetaOrNext(model) === true) {\n return true;\n }\n /**\n * Possibility that the version is not defined, this means it is a quite old system where models did not change.\n */\n if (!model.webinyVersion) {\n return false;\n }\n /**\n * In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.\n *\n * TODO change if necessary after the update to the system\n */\n const modelVersion = semver.coerce(model.webinyVersion);\n if (!modelVersion) {\n console.log(`Warning: Model \"${model.modelId}\" does not have valid Webiny version set.`);\n return true;\n } else if (semver.compare(modelVersion, featureVersion) === -1) {\n return false;\n }\n return true;\n};\n\ninterface Params {\n /**\n * We need a model to determine if the conversion feature is enabled.\n */\n model: CmsModel;\n plugins: PluginsContainer;\n}\n\n/**\n * In the first call of the converter we do not need the fields property as it will be taken directly from the model.\n */\ninterface ConverterCollectionConvertParams\n extends Omit<BaseConverterCollectionConvertParams, \"fields\"> {\n fields?: BaseConverterCollectionConvertParams[\"fields\"];\n}\n\nexport const createValueKeyToStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertToStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createValueKeyFromStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertFromStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\ninterface AttachConvertersParams {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const attachCmsModelFieldConverters = (\n params: AttachConvertersParams\n): StorageOperationsCmsModel => {\n const { model, plugins } = params;\n return {\n ...model,\n convertValueKeyToStorage: createValueKeyToStorageConverter({\n model,\n plugins\n }),\n convertValueKeyFromStorage: createValueKeyFromStorageConverter({\n model,\n plugins\n })\n };\n};\n"],"mappings":"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"}
@@ -0,0 +1,15 @@
1
+ import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
2
+ interface TypeFromFieldParams {
3
+ typeOfType: "type" | "input";
4
+ model: CmsModel;
5
+ type: ApiEndpoint;
6
+ typeNamePrefix: string;
7
+ fields: CmsModelField[];
8
+ fieldTypePlugins: CmsFieldTypePlugins;
9
+ }
10
+ interface TypeFromFieldResponse {
11
+ fieldType: string;
12
+ typeDefs: string;
13
+ }
14
+ export declare const createTypeFromFields: (params: TypeFromFieldParams) => TypeFromFieldResponse | null;
15
+ export {};