@webiny/api-headless-cms 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.8feaff8c32

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 (475) hide show
  1. package/constants.d.ts +1 -0
  2. package/constants.js +8 -0
  3. package/constants.js.map +1 -0
  4. package/context.d.ts +5 -2
  5. package/context.js +96 -30
  6. package/context.js.map +1 -1
  7. package/crud/contentEntry/afterDelete.d.ts +2 -2
  8. package/crud/contentEntry/afterDelete.js +2 -7
  9. package/crud/contentEntry/afterDelete.js.map +1 -1
  10. package/crud/contentEntry/beforeCreate.d.ts +2 -2
  11. package/crud/contentEntry/beforeCreate.js +2 -5
  12. package/crud/contentEntry/beforeCreate.js.map +1 -1
  13. package/crud/contentEntry/beforeUpdate.d.ts +2 -2
  14. package/crud/contentEntry/beforeUpdate.js +2 -5
  15. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  16. package/crud/contentEntry/entryDataValidation.js +4 -47
  17. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  18. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  19. package/crud/contentEntry/markLockedFields.js +25 -39
  20. package/crud/contentEntry/markLockedFields.js.map +1 -1
  21. package/crud/contentEntry/referenceFieldsMapping.js +48 -77
  22. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  23. package/crud/contentEntry/searchableFields.d.ts +9 -0
  24. package/crud/contentEntry/searchableFields.js +72 -0
  25. package/crud/contentEntry/searchableFields.js.map +1 -0
  26. package/crud/contentEntry.crud.d.ts +12 -7
  27. package/crud/contentEntry.crud.js +1213 -1033
  28. package/crud/contentEntry.crud.js.map +1 -1
  29. package/crud/contentModel/afterCreate.d.ts +3 -3
  30. package/crud/contentModel/afterCreate.js +5 -7
  31. package/crud/contentModel/afterCreate.js.map +1 -1
  32. package/crud/contentModel/afterCreateFrom.d.ts +3 -3
  33. package/crud/contentModel/afterCreateFrom.js +5 -7
  34. package/crud/contentModel/afterCreateFrom.js.map +1 -1
  35. package/crud/contentModel/afterDelete.d.ts +3 -3
  36. package/crud/contentModel/afterDelete.js +5 -7
  37. package/crud/contentModel/afterDelete.js.map +1 -1
  38. package/crud/contentModel/afterUpdate.d.ts +3 -3
  39. package/crud/contentModel/afterUpdate.js +5 -7
  40. package/crud/contentModel/afterUpdate.js.map +1 -1
  41. package/crud/contentModel/beforeCreate.d.ts +5 -6
  42. package/crud/contentModel/beforeCreate.js +53 -119
  43. package/crud/contentModel/beforeCreate.js.map +1 -1
  44. package/crud/contentModel/beforeDelete.d.ts +3 -3
  45. package/crud/contentModel/beforeDelete.js +7 -21
  46. package/crud/contentModel/beforeDelete.js.map +1 -1
  47. package/crud/contentModel/beforeUpdate.d.ts +4 -6
  48. package/crud/contentModel/beforeUpdate.js +38 -15
  49. package/crud/contentModel/beforeUpdate.js.map +1 -1
  50. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  51. package/crud/contentModel/compatibility/modelApiName.js +24 -0
  52. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  53. package/crud/contentModel/contentModelManagerFactory.js +0 -7
  54. package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
  55. package/crud/contentModel/createFieldStorageId.js +4 -3
  56. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  57. package/crud/contentModel/defaultFields.d.ts +5 -0
  58. package/crud/contentModel/defaultFields.js +58 -0
  59. package/crud/contentModel/defaultFields.js.map +1 -0
  60. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  61. package/crud/contentModel/fields/descriptionField.js +42 -0
  62. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  63. package/crud/contentModel/fields/imageField.d.ts +2 -0
  64. package/crud/contentModel/fields/imageField.js +46 -0
  65. package/crud/contentModel/fields/imageField.js.map +1 -0
  66. package/crud/contentModel/fields/titleField.d.ts +2 -0
  67. package/crud/contentModel/fields/titleField.js +58 -0
  68. package/crud/contentModel/fields/titleField.js.map +1 -0
  69. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  70. package/crud/contentModel/validate/endingAllowed.js +26 -0
  71. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  72. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  73. package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
  74. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  75. package/crud/contentModel/validate/modelId.d.ts +11 -0
  76. package/crud/contentModel/validate/modelId.js +36 -0
  77. package/crud/contentModel/validate/modelId.js.map +1 -0
  78. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  79. package/crud/contentModel/validate/pluralApiName.js +24 -0
  80. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  81. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  82. package/crud/contentModel/validate/singularApiName.js +24 -0
  83. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  84. package/crud/contentModel/validateLayout.js +0 -8
  85. package/crud/contentModel/validateLayout.js.map +1 -1
  86. package/crud/contentModel/validateModel.d.ts +4 -4
  87. package/crud/contentModel/validateModel.js +7 -12
  88. package/crud/contentModel/validateModel.js.map +1 -1
  89. package/crud/contentModel/validateModelFields.d.ts +4 -4
  90. package/crud/contentModel/validateModelFields.js +134 -155
  91. package/crud/contentModel/validateModelFields.js.map +1 -1
  92. package/crud/contentModel/validation.d.ts +591 -0
  93. package/crud/contentModel/validation.js +145 -0
  94. package/crud/contentModel/validation.js.map +1 -0
  95. package/crud/contentModel.crud.d.ts +2 -0
  96. package/crud/contentModel.crud.js +426 -381
  97. package/crud/contentModel.crud.js.map +1 -1
  98. package/crud/contentModelGroup/beforeCreate.d.ts +2 -2
  99. package/crud/contentModelGroup/beforeCreate.js +3 -15
  100. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  101. package/crud/contentModelGroup/beforeDelete.d.ts +2 -2
  102. package/crud/contentModelGroup/beforeDelete.js +3 -11
  103. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  104. package/crud/contentModelGroup/beforeUpdate.d.ts +2 -2
  105. package/crud/contentModelGroup/beforeUpdate.js +2 -7
  106. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  107. package/crud/contentModelGroup/validation.d.ts +30 -0
  108. package/crud/contentModelGroup/validation.js +34 -0
  109. package/crud/contentModelGroup/validation.js.map +1 -0
  110. package/crud/contentModelGroup.crud.d.ts +2 -0
  111. package/crud/contentModelGroup.crud.js +252 -231
  112. package/crud/contentModelGroup.crud.js.map +1 -1
  113. package/crud/settings.crud.d.ts +3 -1
  114. package/crud/settings.crud.js +10 -36
  115. package/crud/settings.crud.js.map +1 -1
  116. package/crud/system.crud.js +55 -138
  117. package/crud/system.crud.js.map +1 -1
  118. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +1 -14
  119. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
  120. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
  121. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
  122. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
  123. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +17 -72
  124. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  125. package/fieldConverters/index.d.ts +2 -1
  126. package/fieldConverters/index.js +2 -5
  127. package/fieldConverters/index.js.map +1 -1
  128. package/graphql/buildSchemaPlugins.d.ts +8 -3
  129. package/graphql/buildSchemaPlugins.js +7 -11
  130. package/graphql/buildSchemaPlugins.js.map +1 -1
  131. package/graphql/checkEndpointAccess.d.ts +2 -0
  132. package/graphql/checkEndpointAccess.js +18 -0
  133. package/graphql/checkEndpointAccess.js.map +1 -0
  134. package/graphql/createExecutableSchema.d.ts +6 -0
  135. package/graphql/createExecutableSchema.js +29 -0
  136. package/graphql/createExecutableSchema.js.map +1 -0
  137. package/graphql/createRequestBody.d.ts +2 -0
  138. package/graphql/createRequestBody.js +14 -0
  139. package/graphql/createRequestBody.js.map +1 -0
  140. package/graphql/formatErrorPayload.d.ts +1 -0
  141. package/graphql/formatErrorPayload.js +25 -0
  142. package/graphql/formatErrorPayload.js.map +1 -0
  143. package/graphql/generateSchema.d.ts +8 -0
  144. package/graphql/generateSchema.js +31 -0
  145. package/graphql/generateSchema.js.map +1 -0
  146. package/graphql/getSchema.d.ts +17 -0
  147. package/graphql/getSchema.js +102 -0
  148. package/graphql/getSchema.js.map +1 -0
  149. package/graphql/graphQLHandlerFactory.js +7 -130
  150. package/graphql/graphQLHandlerFactory.js.map +1 -1
  151. package/graphql/handleRequest.d.ts +11 -0
  152. package/graphql/handleRequest.js +81 -0
  153. package/graphql/handleRequest.js.map +1 -0
  154. package/graphql/index.d.ts +1 -3
  155. package/graphql/index.js +2 -46
  156. package/graphql/index.js.map +1 -1
  157. package/graphql/schema/baseContentSchema.d.ts +6 -2
  158. package/graphql/schema/baseContentSchema.js +15 -29
  159. package/graphql/schema/baseContentSchema.js.map +1 -1
  160. package/graphql/schema/baseSchema.d.ts +3 -0
  161. package/graphql/schema/baseSchema.js +84 -0
  162. package/graphql/schema/baseSchema.js.map +1 -0
  163. package/graphql/schema/contentEntries.d.ts +6 -2
  164. package/graphql/schema/contentEntries.js +127 -111
  165. package/graphql/schema/contentEntries.js.map +1 -1
  166. package/graphql/schema/contentModelGroups.d.ts +6 -2
  167. package/graphql/schema/contentModelGroups.js +16 -29
  168. package/graphql/schema/contentModelGroups.js.map +1 -1
  169. package/graphql/schema/contentModels.d.ts +6 -2
  170. package/graphql/schema/contentModels.js +77 -22
  171. package/graphql/schema/contentModels.js.map +1 -1
  172. package/graphql/schema/createFieldResolvers.d.ts +2 -2
  173. package/graphql/schema/createFieldResolvers.js +25 -44
  174. package/graphql/schema/createFieldResolvers.js.map +1 -1
  175. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  176. package/graphql/schema/createFieldTypePluginRecords.js +13 -0
  177. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  178. package/graphql/schema/createManageResolvers.d.ts +1 -1
  179. package/graphql/schema/createManageResolvers.js +47 -57
  180. package/graphql/schema/createManageResolvers.js.map +1 -1
  181. package/graphql/schema/createManageSDL.d.ts +3 -0
  182. package/graphql/schema/createManageSDL.js +99 -83
  183. package/graphql/schema/createManageSDL.js.map +1 -1
  184. package/graphql/schema/createPreviewResolvers.js +6 -24
  185. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  186. package/graphql/schema/createReadResolvers.js +11 -24
  187. package/graphql/schema/createReadResolvers.js.map +1 -1
  188. package/graphql/schema/createReadSDL.d.ts +3 -0
  189. package/graphql/schema/createReadSDL.js +48 -46
  190. package/graphql/schema/createReadSDL.js.map +1 -1
  191. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
  192. package/graphql/schema/resolvers/commonFieldResolvers.js +2 -3
  193. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
  194. package/graphql/schema/resolvers/manage/resolveCreate.js +0 -3
  195. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  196. package/graphql/schema/resolvers/manage/resolveCreateFrom.js +0 -3
  197. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  198. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  199. package/graphql/schema/resolvers/manage/resolveDelete.js +13 -9
  200. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  201. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  202. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
  203. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  204. package/graphql/schema/resolvers/manage/resolveGet.js +5 -25
  205. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  206. package/graphql/schema/resolvers/manage/resolveGetByIds.js +0 -3
  207. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  208. package/graphql/schema/resolvers/manage/resolveGetRevisions.js +0 -3
  209. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  210. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  211. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
  212. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  213. package/graphql/schema/resolvers/manage/resolveList.js +0 -3
  214. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  215. package/graphql/schema/resolvers/manage/resolveMove.d.ts +8 -0
  216. package/graphql/schema/resolvers/manage/resolveMove.js +30 -0
  217. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -0
  218. package/graphql/schema/resolvers/manage/resolvePublish.js +0 -3
  219. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  220. package/graphql/schema/resolvers/manage/resolveRepublish.js +0 -3
  221. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  222. package/graphql/schema/resolvers/manage/resolveUnpublish.js +0 -3
  223. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  224. package/graphql/schema/resolvers/manage/resolveUpdate.js +0 -3
  225. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  226. package/graphql/schema/resolvers/preview/resolveGet.js +3 -15
  227. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  228. package/graphql/schema/resolvers/preview/resolveList.js +0 -3
  229. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  230. package/graphql/schema/resolvers/read/resolveGet.js +3 -15
  231. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  232. package/graphql/schema/resolvers/read/resolveList.js +0 -3
  233. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  234. package/graphql/schema/schemaPlugins.d.ts +8 -3
  235. package/graphql/schema/schemaPlugins.js +58 -69
  236. package/graphql/schema/schemaPlugins.js.map +1 -1
  237. package/graphql/system.d.ts +2 -5
  238. package/graphql/system.js +56 -98
  239. package/graphql/system.js.map +1 -1
  240. package/graphqlFields/boolean.js +0 -12
  241. package/graphqlFields/boolean.js.map +1 -1
  242. package/graphqlFields/datetime.js +0 -17
  243. package/graphqlFields/datetime.js.map +1 -1
  244. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
  245. package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
  246. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
  247. package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
  248. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
  249. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
  250. package/graphqlFields/dynamicZone/index.d.ts +2 -0
  251. package/graphqlFields/dynamicZone/index.js +19 -0
  252. package/graphqlFields/dynamicZone/index.js.map +1 -0
  253. package/graphqlFields/file.js +0 -8
  254. package/graphqlFields/file.js.map +1 -1
  255. package/graphqlFields/helpers.js +0 -10
  256. package/graphqlFields/helpers.js.map +1 -1
  257. package/graphqlFields/index.d.ts +1 -1
  258. package/graphqlFields/index.js +2 -12
  259. package/graphqlFields/index.js.map +1 -1
  260. package/graphqlFields/longText.js +0 -10
  261. package/graphqlFields/longText.js.map +1 -1
  262. package/graphqlFields/number.js +5 -12
  263. package/graphqlFields/number.js.map +1 -1
  264. package/graphqlFields/object.js +132 -99
  265. package/graphqlFields/object.js.map +1 -1
  266. package/graphqlFields/ref.js +90 -114
  267. package/graphqlFields/ref.js.map +1 -1
  268. package/graphqlFields/richText.js +0 -9
  269. package/graphqlFields/richText.js.map +1 -1
  270. package/graphqlFields/text.js +2 -11
  271. package/graphqlFields/text.js.map +1 -1
  272. package/index.d.ts +5 -3
  273. package/index.js +27 -27
  274. package/index.js.map +1 -1
  275. package/modelManager/DefaultCmsModelManager.d.ts +7 -7
  276. package/modelManager/DefaultCmsModelManager.js +1 -17
  277. package/modelManager/DefaultCmsModelManager.js.map +1 -1
  278. package/modelManager/index.js +0 -4
  279. package/modelManager/index.js.map +1 -1
  280. package/package.json +36 -42
  281. package/parameters/context.js +0 -4
  282. package/parameters/context.js.map +1 -1
  283. package/parameters/header.js +4 -15
  284. package/parameters/header.js.map +1 -1
  285. package/parameters/index.js +0 -8
  286. package/parameters/index.js.map +1 -1
  287. package/parameters/manual.js +7 -15
  288. package/parameters/manual.js.map +1 -1
  289. package/parameters/path.js +1 -12
  290. package/parameters/path.js.map +1 -1
  291. package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
  292. package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
  293. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
  294. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
  295. package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
  296. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
  297. package/plugins/CmsGroupPlugin.js +1 -9
  298. package/plugins/CmsGroupPlugin.js.map +1 -1
  299. package/plugins/CmsModelFieldConverterPlugin.d.ts +2 -2
  300. package/plugins/CmsModelFieldConverterPlugin.js +1 -6
  301. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  302. package/plugins/CmsModelPlugin.d.ts +27 -5
  303. package/plugins/CmsModelPlugin.js +46 -51
  304. package/plugins/CmsModelPlugin.js.map +1 -1
  305. package/plugins/CmsParametersPlugin.js +4 -7
  306. package/plugins/CmsParametersPlugin.js.map +1 -1
  307. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  308. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  309. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  310. package/plugins/StorageTransformPlugin.d.ts +11 -11
  311. package/plugins/StorageTransformPlugin.js +1 -10
  312. package/plugins/StorageTransformPlugin.js.map +1 -1
  313. package/plugins/index.d.ts +3 -0
  314. package/plugins/index.js +33 -10
  315. package/plugins/index.js.map +1 -1
  316. package/storage/default.js +0 -3
  317. package/storage/default.js.map +1 -1
  318. package/storage/object.js +7 -27
  319. package/storage/object.js.map +1 -1
  320. package/types.d.ts +712 -251
  321. package/types.js +78 -76
  322. package/types.js.map +1 -1
  323. package/utils/converters/Converter.js +1 -14
  324. package/utils/converters/Converter.js.map +1 -1
  325. package/utils/converters/ConverterCollection.d.ts +7 -0
  326. package/utils/converters/ConverterCollection.js +36 -32
  327. package/utils/converters/ConverterCollection.js.map +1 -1
  328. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  329. package/utils/converters/valueKeyStorageConverter.js +32 -51
  330. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  331. package/utils/createTypeFromFields.d.ts +16 -0
  332. package/utils/createTypeFromFields.js +66 -0
  333. package/utils/createTypeFromFields.js.map +1 -0
  334. package/utils/createTypeName.d.ts +0 -2
  335. package/utils/createTypeName.js +5 -20
  336. package/utils/createTypeName.js.map +1 -1
  337. package/utils/entryStorage.js +25 -42
  338. package/utils/entryStorage.js.map +1 -1
  339. package/utils/filterAsync.js +0 -5
  340. package/utils/filterAsync.js.map +1 -1
  341. package/utils/getBaseFieldType.d.ts +2 -0
  342. package/utils/getBaseFieldType.js +10 -0
  343. package/utils/getBaseFieldType.js.map +1 -0
  344. package/utils/getEntryDescription.d.ts +2 -0
  345. package/utils/getEntryDescription.js +17 -0
  346. package/utils/getEntryDescription.js.map +1 -0
  347. package/utils/getEntryImage.d.ts +2 -0
  348. package/utils/getEntryImage.js +17 -0
  349. package/utils/getEntryImage.js.map +1 -0
  350. package/utils/getEntryTitle.d.ts +1 -1
  351. package/utils/getEntryTitle.js +0 -9
  352. package/utils/getEntryTitle.js.map +1 -1
  353. package/utils/getSchemaFromFieldPlugins.d.ts +4 -7
  354. package/utils/getSchemaFromFieldPlugins.js +23 -19
  355. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  356. package/utils/incrementEntryIdVersion.d.ts +5 -0
  357. package/utils/incrementEntryIdVersion.js +29 -0
  358. package/utils/incrementEntryIdVersion.js.map +1 -0
  359. package/utils/permissions/EntriesPermissions.d.ts +4 -0
  360. package/utils/permissions/EntriesPermissions.js +9 -0
  361. package/utils/permissions/EntriesPermissions.js.map +1 -0
  362. package/utils/permissions/ModelGroupsPermissions.d.ts +11 -0
  363. package/utils/permissions/ModelGroupsPermissions.js +48 -0
  364. package/utils/permissions/ModelGroupsPermissions.js.map +1 -0
  365. package/utils/permissions/ModelsPermissions.d.ts +20 -0
  366. package/utils/permissions/ModelsPermissions.js +91 -0
  367. package/utils/permissions/ModelsPermissions.js.map +1 -0
  368. package/utils/permissions/SettingsPermissions.d.ts +4 -0
  369. package/utils/permissions/SettingsPermissions.js +9 -0
  370. package/utils/permissions/SettingsPermissions.js.map +1 -0
  371. package/utils/renderFields.d.ts +4 -2
  372. package/utils/renderFields.js +12 -11
  373. package/utils/renderFields.js.map +1 -1
  374. package/utils/renderGetFilterFields.d.ts +2 -2
  375. package/utils/renderGetFilterFields.js +9 -30
  376. package/utils/renderGetFilterFields.js.map +1 -1
  377. package/utils/renderInputFields.d.ts +4 -2
  378. package/utils/renderInputFields.js +19 -14
  379. package/utils/renderInputFields.js.map +1 -1
  380. package/utils/renderListFilterFields.d.ts +3 -1
  381. package/utils/renderListFilterFields.js +24 -28
  382. package/utils/renderListFilterFields.js.map +1 -1
  383. package/utils/renderSortEnum.d.ts +9 -5
  384. package/utils/renderSortEnum.js +26 -12
  385. package/utils/renderSortEnum.js.map +1 -1
  386. package/utils/toSlug.js +1 -5
  387. package/utils/toSlug.js.map +1 -1
  388. package/validators/dateGte.js +0 -7
  389. package/validators/dateGte.js.map +1 -1
  390. package/validators/dateLte.js +0 -7
  391. package/validators/dateLte.js.map +1 -1
  392. package/validators/dynamicZone.d.ts +2 -0
  393. package/validators/dynamicZone.js +20 -0
  394. package/validators/dynamicZone.js.map +1 -0
  395. package/validators/gte.js +0 -8
  396. package/validators/gte.js.map +1 -1
  397. package/validators/in.js +0 -8
  398. package/validators/in.js.map +1 -1
  399. package/validators/index.js +2 -16
  400. package/validators/index.js.map +1 -1
  401. package/validators/lte.js +0 -8
  402. package/validators/lte.js.map +1 -1
  403. package/validators/maxLength.js +0 -8
  404. package/validators/maxLength.js.map +1 -1
  405. package/validators/minLength.js +0 -8
  406. package/validators/minLength.js.map +1 -1
  407. package/validators/pattern.js +0 -9
  408. package/validators/pattern.js.map +1 -1
  409. package/validators/patternPlugins/email.js +0 -2
  410. package/validators/patternPlugins/email.js.map +1 -1
  411. package/validators/patternPlugins/index.js +0 -8
  412. package/validators/patternPlugins/index.js.map +1 -1
  413. package/validators/patternPlugins/lowerCase.js +0 -2
  414. package/validators/patternPlugins/lowerCase.js.map +1 -1
  415. package/validators/patternPlugins/lowerCaseSpace.js +0 -2
  416. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
  417. package/validators/patternPlugins/upperCase.js +0 -2
  418. package/validators/patternPlugins/upperCase.js.map +1 -1
  419. package/validators/patternPlugins/upperCaseSpace.js +0 -2
  420. package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
  421. package/validators/patternPlugins/url.js +0 -2
  422. package/validators/patternPlugins/url.js.map +1 -1
  423. package/validators/required.js +0 -5
  424. package/validators/required.js.map +1 -1
  425. package/validators/timeGte.js +0 -8
  426. package/validators/timeGte.js.map +1 -1
  427. package/validators/timeLte.js +0 -8
  428. package/validators/timeLte.js.map +1 -1
  429. package/validators/unique.js +1 -8
  430. package/validators/unique.js.map +1 -1
  431. package/crud/contentModel/createFieldModels.d.ts +0 -2
  432. package/crud/contentModel/createFieldModels.js +0 -26
  433. package/crud/contentModel/createFieldModels.js.map +0 -1
  434. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  435. package/crud/contentModel/fieldIdValidation.js +0 -25
  436. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  437. package/crud/contentModel/idValidation.d.ts +0 -1
  438. package/crud/contentModel/idValidation.js +0 -22
  439. package/crud/contentModel/idValidation.js.map +0 -1
  440. package/crud/contentModel/models.d.ts +0 -4
  441. package/crud/contentModel/models.js +0 -180
  442. package/crud/contentModel/models.js.map +0 -1
  443. package/crud/contentModel/systemFields.d.ts +0 -1
  444. package/crud/contentModel/systemFields.js +0 -8
  445. package/crud/contentModel/systemFields.js.map +0 -1
  446. package/crud/index.d.ts +0 -6
  447. package/crud/index.js +0 -89
  448. package/crud/index.js.map +0 -1
  449. package/graphql/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -7
  450. package/graphql/schema/resolvers/manage/resolveRequestChanges.js +0 -21
  451. package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
  452. package/graphql/schema/resolvers/manage/resolveRequestReview.d.ts +0 -7
  453. package/graphql/schema/resolvers/manage/resolveRequestReview.js +0 -21
  454. package/graphql/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
  455. package/upgrades/5.33.0/index.d.ts +0 -3
  456. package/upgrades/5.33.0/index.js +0 -186
  457. package/upgrades/5.33.0/index.js.map +0 -1
  458. package/upgrades/index.d.ts +0 -1
  459. package/upgrades/index.js +0 -12
  460. package/upgrades/index.js.map +0 -1
  461. package/utils/access.d.ts +0 -8
  462. package/utils/access.js +0 -90
  463. package/utils/access.js.map +0 -1
  464. package/utils/filterModelFields.d.ts +0 -16
  465. package/utils/filterModelFields.js +0 -81
  466. package/utils/filterModelFields.js.map +0 -1
  467. package/utils/ownership.d.ts +0 -8
  468. package/utils/ownership.js +0 -41
  469. package/utils/ownership.js.map +0 -1
  470. package/utils/permissions.d.ts +0 -7
  471. package/utils/permissions.js +0 -110
  472. package/utils/permissions.js.map +0 -1
  473. package/utils/pluralizedTypeName.d.ts +0 -1
  474. package/utils/pluralizedTypeName.js +0 -26
  475. package/utils/pluralizedTypeName.js.map +0 -1
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.ConverterCollection = void 0;
9
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
10
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
11
  var _Converter = require("./Converter");
15
-
16
12
  var _plugins = require("../../plugins");
17
-
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
-
13
+ var _getBaseFieldType = require("../getBaseFieldType");
22
14
  class ConverterCollection {
23
15
  constructor(params) {
24
16
  (0, _defineProperty2.default)(this, "converters", new Map());
@@ -28,11 +20,9 @@ class ConverterCollection {
28
20
  const fieldGraphQLPlugins = plugins.byType("cms-model-field-to-graphql");
29
21
  const fieldConverterPlugins = plugins.byType(_plugins.CmsModelFieldConverterPlugin.type);
30
22
  const defaultFieldConverterPlugin = fieldConverterPlugins.find(pl => pl.getFieldType() === "*");
31
-
32
23
  if (defaultFieldConverterPlugin === undefined) {
33
24
  throw new _error.default(`Missing default field converter plugin.`, "DEFAULT_FIELD_CONVERTER_ERROR");
34
25
  }
35
-
36
26
  for (const fieldGraphQLPlugin of fieldGraphQLPlugins) {
37
27
  const plugin = fieldConverterPlugins.find(pl => pl.getFieldType() === fieldGraphQLPlugin.fieldType);
38
28
  const converter = new _Converter.Converter({
@@ -42,74 +32,88 @@ class ConverterCollection {
42
32
  this.addConverter(converter);
43
33
  }
44
34
  }
45
-
46
35
  addConverter(converter) {
47
36
  converter.setConverterCollection(this);
48
37
  this.converters.set(converter.getType(), converter);
49
38
  }
50
-
51
39
  getConverter(type) {
52
40
  const converter = this.converters.get(type);
53
-
54
41
  if (converter === undefined) {
55
42
  throw new _error.default(`Missing converter for field type "${type}".`, "CONVERTER_ERROR", {
56
43
  type
57
44
  });
58
45
  }
59
-
60
46
  return converter;
61
47
  }
62
-
63
48
  convertToStorage(params) {
64
49
  const {
65
50
  fields,
66
51
  values: inputValues
67
52
  } = params;
68
-
69
53
  if (inputValues === undefined) {
70
54
  return undefined;
71
55
  }
72
-
56
+ this.attachHasOwnProperty(inputValues);
73
57
  return fields.reduce((output, field) => {
74
- const converter = this.getConverter(field.type);
75
-
58
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
59
+ const converter = this.getConverter(baseType);
76
60
  if (inputValues === null || inputValues.hasOwnProperty(field.fieldId) === false) {
77
61
  return output;
78
62
  }
79
-
80
63
  const values = converter.convertToStorage({
81
64
  field,
82
65
  value: inputValues[field.fieldId]
83
66
  });
84
- return _objectSpread(_objectSpread({}, output), values);
67
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, output), values);
85
68
  }, {});
86
69
  }
87
-
88
70
  convertFromStorage(params) {
89
71
  const {
90
72
  fields,
91
73
  values: inputValues
92
74
  } = params;
93
-
94
75
  if (inputValues === undefined) {
95
76
  return undefined;
96
77
  }
97
-
98
78
  return fields.reduce((output, field) => {
99
- const converter = this.getConverter(field.type);
100
-
79
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
80
+ const converter = this.getConverter(baseType);
101
81
  if (inputValues === null || inputValues.hasOwnProperty(field.storageId) === false) {
102
82
  return output;
103
83
  }
104
-
105
84
  const values = converter.convertFromStorage({
106
85
  field,
107
86
  value: inputValues[field.storageId]
108
87
  });
109
- return _objectSpread(_objectSpread({}, output), values);
88
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, output), values);
110
89
  }, {});
111
90
  }
112
91
 
92
+ /**
93
+ * This method attaches hasOwnProperty when received object was created via Object.create(null) - no inheritance of Object.
94
+ * At that point, hasOwnProperty does not exist, and we need to add it.
95
+ *
96
+ * TODO add more checks if required
97
+ */
98
+ attachHasOwnProperty(values) {
99
+ if (
100
+ // null or undefined?
101
+ values === null || values === undefined ||
102
+ // not an object?
103
+ typeof values !== "object" ||
104
+ // maybe it's an array?
105
+ Array.isArray(values) ||
106
+ // and in the end, check if hasOwnProperty is a function already
107
+ typeof (values === null || values === void 0 ? void 0 : values.hasOwnProperty) === "function") {
108
+ return;
109
+ }
110
+ Object.defineProperty(values, "hasOwnProperty", {
111
+ enumerable: false,
112
+ writable: false,
113
+ value: function (property) {
114
+ return this[property] !== undefined;
115
+ }
116
+ });
117
+ }
113
118
  }
114
-
115
119
  exports.ConverterCollection = ConverterCollection;
@@ -1 +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","reduce","output","field","hasOwnProperty","fieldId","value","convertFromStorage","storageId"],"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\";\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 return fields.reduce<CmsEntryValues>((output, field) => {\n const converter = this.getConverter(field.type);\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 converter = this.getConverter(field.type);\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"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;AAoBO,MAAMA,mBAAN,CAA0B;EAGtBC,WAAW,CAACC,MAAD,EAAoC;IAAA,kDAFA,IAAIC,GAAJ,EAEA;IAClD,MAAM;MAAEC;IAAF,IAAcF,MAApB;IACA,MAAMG,mBAAmB,GAAGD,OAAO,CAACE,MAAR,CACxB,4BADwB,CAA5B;IAGA,MAAMC,qBAAqB,GAAGH,OAAO,CAACE,MAAR,CAC1BE,qCAAA,CAA6BC,IADH,CAA9B;IAGA,MAAMC,2BAA2B,GAAGH,qBAAqB,CAACI,IAAtB,CAChCC,EAAE,IAAIA,EAAE,CAACC,YAAH,OAAsB,GADI,CAApC;;IAGA,IAAIH,2BAA2B,KAAKI,SAApC,EAA+C;MAC3C,MAAM,IAAIC,cAAJ,CACD,yCADC,EAEF,+BAFE,CAAN;IAIH;;IACD,KAAK,MAAMC,kBAAX,IAAiCX,mBAAjC,EAAsD;MAClD,MAAMY,MAAM,GAAGV,qBAAqB,CAACI,IAAtB,CACXC,EAAE,IAAIA,EAAE,CAACC,YAAH,OAAsBG,kBAAkB,CAACE,SADpC,CAAf;MAGA,MAAMC,SAAS,GAAG,IAAIC,oBAAJ,CAAc;QAC5BX,IAAI,EAAEO,kBAAkB,CAACE,SADG;QAE5BD,MAAM,EAAEA,MAAM,IAAIP;MAFU,CAAd,CAAlB;MAKA,KAAKW,YAAL,CAAkBF,SAAlB;IACH;EACJ;;EAEME,YAAY,CAACF,SAAD,EAA6B;IAC5CA,SAAS,CAACG,sBAAV,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AAOe,MAAM,CAACG,MAAP,CAAc,CAACC,MAAD,EAASC,KAAT,KAAmB;MACpC,MAAMf,SAAS,GAAG,KAAKO,YAAL,CAAkBQ,KAAK,CAACzB,IAAxB,CAAlB;;MACA,IAAIsB,WAAW,KAAK,IAAhB,IAAwBA,WAAW,CAACI,cAAZ,CAA2BD,KAAK,CAACK,SAAjC,MAAgD,KAA5E,EAAmF;QAC/E,OAAON,MAAP;MACH;;MACD,MAAMH,MAAM,GAAGX,SAAS,CAACmB,kBAAV,CAA6B;QACxCJ,KADwC;QAExCG,KAAK,EAAEN,WAAW,CAACG,KAAK,CAACK,SAAP;MAFsB,CAA7B,CAAf;MAKA,uCACON,MADP,GAEOH,MAFP;IAIH,CAdM,EAcJ,EAdI,CAAP;EAeH;;AAlG4B"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_Converter","_plugins","_getBaseFieldType","ConverterCollection","constructor","params","_defineProperty2","default","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","_objectSpread2","convertFromStorage","storageId","Array","isArray","Object","defineProperty","enumerable","writable","property","exports"],"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":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAH,OAAA;AAmBO,MAAMI,mBAAmB,CAAC;EAGtBC,WAAWA,CAACC,MAAiC,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,sBAFA,IAAIC,GAAG,CAAC,CAAC;IAG3D,MAAM;MAAEC;IAAQ,CAAC,GAAGJ,MAAM;IAC1B,MAAMK,mBAAmB,GAAGD,OAAO,CAACE,MAAM,CACtC,4BACJ,CAAC;IACD,MAAMC,qBAAqB,GAAGH,OAAO,CAACE,MAAM,CACxCE,qCAA4B,CAACC,IACjC,CAAC;IACD,M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I,KAAK,CAACQ,SAAS;MACtC,CAAC,CAAC;MAEF,WAAAF,cAAA,CAAAvC,OAAA,MAAAuC,cAAA,CAAAvC,OAAA,MACOgC,MAAM,GACNJ,MAAM;IAEjB,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYE,oBAAoBA,CAACF,MAAsB,EAAE;IACjD;IACI;IACAA,MAAM,KAAK,IAAI,IACfA,MAAM,KAAKhB,SAAS;IACpB;IACA,OAAOgB,MAAM,KAAK,QAAQ;IAC1B;IACAc,KAAK,CAACC,OAAO,CAACf,MAAM,CAAC;IACrB;IACA,QAAOA,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEQ,cAAc,MAAK,UAAU,EAC9C;MACE;IACJ;IACAQ,MAAM,CAACC,cAAc,CAACjB,MAAM,EAAE,gBAAgB,EAAE;MAC5CkB,UAAU,EAAE,KAAK;MACjBC,QAAQ,EAAE,KAAK;MACfT,KAAK,EAAE,SAAAA,CAAUU,QAAgB,EAAE;QAC/B,OAAO,IAAI,CAACA,QAAQ,CAAC,KAAKpC,SAAS;MACvC;IACJ,CAAC,CAAC;EACN;AACJ;AAACqC,OAAA,CAAArD,mBAAA,GAAAA,mBAAA"}
@@ -10,9 +10,5 @@ interface Params {
10
10
  }
11
11
  export declare const createValueKeyToStorageConverter: (params: Params) => CmsModelConverterCallable;
12
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;
13
+ export declare const createCmsModelFieldConvertersAttachFactory: (plugins: PluginsContainer) => (model: StorageOperationsCmsModel | CmsModel) => StorageOperationsCmsModel;
18
14
  export {};
@@ -1,53 +1,41 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.attachCmsModelFieldConverters = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
7
+ exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.createCmsModelFieldConvertersAttachFactory = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _ConverterCollection = require("./ConverterCollection");
13
-
14
10
  var _semver = _interopRequireDefault(require("semver"));
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
-
20
11
  const featureVersion = _semver.default.coerce("5.33.0");
21
-
22
12
  const isBetaOrNext = model => {
23
13
  if (!model.webinyVersion) {
24
14
  return false;
15
+ } else if (model.webinyVersion.startsWith("0.0.0")) {
16
+ return true;
25
17
  }
26
-
27
- return model.webinyVersion.match(/next|beta/) !== null;
18
+ return model.webinyVersion.match(/next|beta|unstable/) !== null;
28
19
  };
29
-
30
20
  const isFeatureEnabled = model => {
31
21
  /**
32
22
  * In case of disabled webinyVersion value, we disable this feature.
33
23
  * This is only for testing...
34
24
  */
35
- if (model.webinyVersion === "disable") {
25
+ const disableConversion = !!process.env.WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE;
26
+ if (model.webinyVersion === "disable" || disableConversion) {
36
27
  return false;
37
28
  }
38
29
  /**
39
30
  * If is a test environment, always have this turned on.
40
31
  */
41
-
42
-
43
- if (process.env.NODE_ENV === "test" || isBetaOrNext(model) === true) {
32
+ const nodeEnv = process.env.NODE_ENV;
33
+ if (nodeEnv === "test" || nodeEnv === "disable" || isBetaOrNext(model)) {
44
34
  return true;
45
35
  }
46
36
  /**
47
37
  * Possibility that the version is not defined, this means it is a quite old system where models did not change.
48
38
  */
49
-
50
-
51
39
  if (!model.webinyVersion) {
52
40
  return false;
53
41
  }
@@ -56,26 +44,25 @@ const isFeatureEnabled = model => {
56
44
  *
57
45
  * TODO change if necessary after the update to the system
58
46
  */
59
-
60
-
61
47
  const modelVersion = _semver.default.coerce(model.webinyVersion);
62
-
63
48
  if (!modelVersion) {
64
49
  console.log(`Warning: Model "${model.modelId}" does not have valid Webiny version set.`);
65
50
  return true;
66
51
  } else if (_semver.default.compare(modelVersion, featureVersion) === -1) {
67
52
  return false;
68
53
  }
69
-
70
54
  return true;
71
55
  };
72
56
 
57
+ /**
58
+ * In the first call of the converter we do not need the fields property as it will be taken directly from the model.
59
+ */
60
+
73
61
  const createValueKeyToStorageConverter = params => {
74
62
  const {
75
63
  plugins,
76
64
  model
77
65
  } = params;
78
-
79
66
  if (isFeatureEnabled(model) === false) {
80
67
  return ({
81
68
  values
@@ -83,7 +70,6 @@ const createValueKeyToStorageConverter = params => {
83
70
  return values || {};
84
71
  };
85
72
  }
86
-
87
73
  const converters = new _ConverterCollection.ConverterCollection({
88
74
  plugins
89
75
  });
@@ -98,15 +84,12 @@ const createValueKeyToStorageConverter = params => {
98
84
  return result || {};
99
85
  };
100
86
  };
101
-
102
87
  exports.createValueKeyToStorageConverter = createValueKeyToStorageConverter;
103
-
104
88
  const createValueKeyFromStorageConverter = params => {
105
89
  const {
106
90
  plugins,
107
91
  model
108
92
  } = params;
109
-
110
93
  if (isFeatureEnabled(model) === false) {
111
94
  return ({
112
95
  values
@@ -114,7 +97,6 @@ const createValueKeyFromStorageConverter = params => {
114
97
  return values || {};
115
98
  };
116
99
  }
117
-
118
100
  const converters = new _ConverterCollection.ConverterCollection({
119
101
  plugins
120
102
  });
@@ -129,24 +111,23 @@ const createValueKeyFromStorageConverter = params => {
129
111
  return result || {};
130
112
  };
131
113
  };
132
-
133
114
  exports.createValueKeyFromStorageConverter = createValueKeyFromStorageConverter;
134
-
135
- const attachCmsModelFieldConverters = params => {
136
- const {
137
- model,
138
- plugins
139
- } = params;
140
- return _objectSpread(_objectSpread({}, model), {}, {
141
- convertValueKeyToStorage: createValueKeyToStorageConverter({
142
- model,
143
- plugins
144
- }),
145
- convertValueKeyFromStorage: createValueKeyFromStorageConverter({
146
- model,
147
- plugins
148
- })
149
- });
115
+ const createCmsModelFieldConvertersAttachFactory = plugins => {
116
+ return model => {
117
+ const storageModel = model;
118
+ if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {
119
+ return storageModel;
120
+ }
121
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
122
+ convertValueKeyToStorage: createValueKeyToStorageConverter({
123
+ model,
124
+ plugins
125
+ }),
126
+ convertValueKeyFromStorage: createValueKeyFromStorageConverter({
127
+ model,
128
+ plugins
129
+ })
130
+ });
131
+ };
150
132
  };
151
-
152
- exports.attachCmsModelFieldConverters = attachCmsModelFieldConverters;
133
+ exports.createCmsModelFieldConvertersAttachFactory = createCmsModelFieldConvertersAttachFactory;
@@ -1 +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":";;;;;;;;;;;AACA;;AAMA;;;;;;AAEA,MAAMA,cAAc,GAAGC,eAAA,CAAOC,MAAP,CAAc,QAAd,CAAvB;;AAEA,MAAMC,YAAY,GAAIC,KAAD,IAA8B;EAC/C,IAAI,CAACA,KAAK,CAACC,aAAX,EAA0B;IACtB,OAAO,KAAP;EACH;;EACD,OAAOD,KAAK,CAACC,aAAN,CAAoBC,KAApB,CAA0B,WAA1B,MAA2C,IAAlD;AACH,CALD;;AAOA,MAAMC,gBAAgB,GAAIH,KAAD,IAA8B;EACnD;AACJ;AACA;AACA;EACI,IAAIA,KAAK,CAACC,aAAN,KAAwB,SAA5B,EAAuC;IACnC,OAAO,KAAP;EACH;EACD;AACJ;AACA;;;EACI,IAAIG,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,MAAzB,IAAmCP,YAAY,CAACC,KAAD,CAAZ,KAAwB,IAA/D,EAAqE;IAC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AAO,CAAC;MAAEe;IAAF,CAAD,KAAkD;MACrD,OAAOA,MAAM,IAAI,EAAjB;IACH,CAFD;EAGH;;EAED,MAAMC,UAAU,GAAG,IAAIC,wCAAJ,CAAwB;IACvCH;EADuC,CAAxB,CAAnB;EAIA,OAAO,CAAC;IAAEI,MAAF;IAAUH;EAAV,CAAD,KAA0D;IAC7D,MAAMI,MAAM,GAAGH,UAAU,CAACM,kBAAX,CAA8B;MACzCJ,MAAM,EAAEA,MAAM,IAAIlB,KAAK,CAACkB,MADiB;MAEzCH;IAFyC,CAA9B,CAAf;IAIA,OAAOI,MAAM,IAAI,EAAjB;EACH,CAND;AAOH,CApBM;;;;AA0BA,MAAMI,6BAA6B,GACtCV,MADyC,IAEb;EAC5B,MAAM;IAAEb,KAAF;IAASc;EAAT,IAAqBD,MAA3B;EACA,uCACOb,KADP;IAEIwB,wBAAwB,EAAEZ,gCAAgC,CAAC;MACvDZ,KADuD;MAEvDc;IAFuD,CAAD,CAF9D;IAMIW,0BAA0B,EAAEJ,kCAAkC,CAAC;MAC3DrB,KAD2D;MAE3Dc;IAF2D,CAAD;EANlE;AAWH,CAfM"}
1
+ {"version":3,"names":["_ConverterCollection","require","_semver","_interopRequireDefault","featureVersion","semver","coerce","isBetaOrNext","model","webinyVersion","startsWith","match","isFeatureEnabled","disableConversion","process","env","WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE","nodeEnv","NODE_ENV","modelVersion","console","log","modelId","compare","createValueKeyToStorageConverter","params","plugins","values","converters","ConverterCollection","fields","result","convertToStorage","exports","createValueKeyFromStorageConverter","convertFromStorage","createCmsModelFieldConvertersAttachFactory","storageModel","convertValueKeyToStorage","convertValueKeyFromStorage","_objectSpread2","default"],"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 } else if (model.webinyVersion.startsWith(\"0.0.0\")) {\n return true;\n }\n return model.webinyVersion.match(/next|beta|unstable/) !== 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 const disableConversion = !!process.env.WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE;\n if (model.webinyVersion === \"disable\" || disableConversion) {\n return false;\n }\n /**\n * If is a test environment, always have this turned on.\n */\n const nodeEnv = process.env.NODE_ENV as string;\n if (nodeEnv === \"test\" || nodeEnv === \"disable\" || isBetaOrNext(model)) {\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\nexport const createCmsModelFieldConvertersAttachFactory = (plugins: PluginsContainer) => {\n return (model: StorageOperationsCmsModel | CmsModel): StorageOperationsCmsModel => {\n const storageModel = model as Partial<StorageOperationsCmsModel>;\n if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {\n return storageModel as StorageOperationsCmsModel;\n }\n return {\n ...model,\n convertValueKeyToStorage: createValueKeyToStorageConverter({\n model,\n plugins\n }),\n convertValueKeyFromStorage: createValueKeyFromStorageConverter({\n model,\n plugins\n })\n };\n };\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,oBAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,cAAc,GAAGC,eAAM,CAACC,MAAM,CAAC,QAAQ,CAAW;AAExD,MAAMC,YAAY,GAAIC,KAAe,IAAc;EAC/C,IAAI,CAACA,KAAK,CAACC,aAAa,EAAE;IACtB,OAAO,KAAK;EAChB,CAAC,MAAM,IAAID,KAAK,CAACC,aAAa,CAACC,UAAU,CAAC,OAAO,CAAC,EAAE;IAChD,OAAO,IAAI;EACf;EACA,OAAOF,KAAK,CAACC,aAAa,CAACE,KAAK,CAAC,oBAAoB,CAAC,KAAK,IAAI;AACnE,CAAC;AAED,MAAMC,gBAAgB,GAAIJ,KAAe,IAAc;EACnD;AACJ;AACA;AACA;EACI,MAAMK,iBAAi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AC3D1B,KAAK;QACLkB;MACJ,CAAC;IAAC;EAEV,CAAC;AACL,CAAC;AAACO,OAAA,CAAAG,0CAAA,GAAAA,0CAAA"}
@@ -0,0 +1,16 @@
1
+ import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
2
+ interface TypeFromFieldParams {
3
+ typeOfType: "type" | "input";
4
+ models: CmsModel[];
5
+ model: CmsModel;
6
+ type: ApiEndpoint;
7
+ typeNamePrefix: string;
8
+ fields: CmsModelField[];
9
+ fieldTypePlugins: CmsFieldTypePlugins;
10
+ }
11
+ interface TypeFromFieldResponse {
12
+ fieldType: string;
13
+ typeDefs: string;
14
+ }
15
+ export declare const createTypeFromFields: (params: TypeFromFieldParams) => TypeFromFieldResponse | null;
16
+ export {};
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createTypeFromFields = void 0;
7
+ var _renderFields = require("./renderFields");
8
+ var _renderInputFields = require("./renderInputFields");
9
+ const createTypeFromFields = params => {
10
+ const {
11
+ typeOfType,
12
+ model,
13
+ models,
14
+ type,
15
+ typeNamePrefix,
16
+ fields,
17
+ fieldTypePlugins
18
+ } = params;
19
+ const typeSuffix = typeOfType === "input" ? "Input" : "";
20
+ const mTypeName = model.singularApiName;
21
+ const typeFields = [];
22
+ const nestedTypes = [];
23
+
24
+ // Once the loop below starts, we'll be executing a recursive "object" type generation.
25
+ // The main trick here is that nested objects don't know who the parent is, and will generate
26
+ // type names using the "model", as if they're at the top level:
27
+ // Every time the types are returned, we need to replace the model name in the generated type name
28
+ // with the actual prefix which includes parent field name type.
29
+ const replace = new RegExp(`${mTypeName}_`, "g");
30
+ for (const field of fields) {
31
+ const result = typeOfType === "type" ? (0, _renderFields.renderField)({
32
+ field,
33
+ type,
34
+ models,
35
+ model,
36
+ fieldTypePlugins
37
+ }) : (0, _renderInputFields.renderInputField)({
38
+ field,
39
+ models,
40
+ model,
41
+ fieldTypePlugins
42
+ });
43
+ if (!result) {
44
+ continue;
45
+ }
46
+ const {
47
+ fields,
48
+ typeDefs
49
+ } = result;
50
+ typeFields.push(fields.replace(replace, `${typeNamePrefix}_`));
51
+ if (typeDefs) {
52
+ nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));
53
+ }
54
+ }
55
+ return {
56
+ fieldType: `${typeNamePrefix}${typeSuffix}`,
57
+ typeDefs: /* GraphQL */`
58
+ ${nestedTypes.join("\n")}
59
+
60
+ ${typeOfType} ${typeNamePrefix}${typeSuffix} {
61
+ ${typeFields.join("\n")}
62
+ }\n
63
+ `
64
+ };
65
+ };
66
+ exports.createTypeFromFields = createTypeFromFields;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_renderFields","require","_renderInputFields","createTypeFromFields","params","typeOfType","model","models","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","singularApiName","typeFields","nestedTypes","replace","RegExp","field","result","renderField","renderInputField","typeDefs","push","fieldType","join","exports"],"sources":["createTypeFromFields.ts"],"sourcesContent":["import { renderField } from \"~/utils/renderFields\";\nimport { renderInputField } from \"~/utils/renderInputFields\";\nimport { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\n\ninterface TypeFromFieldParams {\n typeOfType: \"type\" | \"input\";\n models: CmsModel[];\n model: CmsModel;\n type: ApiEndpoint;\n typeNamePrefix: string;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface TypeFromFieldResponse {\n fieldType: string;\n typeDefs: string;\n}\n\nexport const createTypeFromFields = (params: TypeFromFieldParams): TypeFromFieldResponse | null => {\n const { typeOfType, model, models, type, typeNamePrefix, fields, fieldTypePlugins } = params;\n const typeSuffix = typeOfType === \"input\" ? \"Input\" : \"\";\n const mTypeName = model.singularApiName;\n\n const typeFields: string[] = [];\n const nestedTypes: string[] = [];\n\n // Once the loop below starts, we'll be executing a recursive \"object\" type generation.\n // The main trick here is that nested objects don't know who the parent is, and will generate\n // type names using the \"model\", as if they're at the top level:\n // Every time the types are returned, we need to replace the model name in the generated type name\n // with the actual prefix which includes parent field name type.\n const replace = new RegExp(`${mTypeName}_`, \"g\");\n\n for (const field of fields) {\n const result =\n typeOfType === \"type\"\n ? renderField({ field, type, models, model, fieldTypePlugins })\n : renderInputField({ field, models, model, fieldTypePlugins });\n\n if (!result) {\n continue;\n }\n\n const { fields, typeDefs } = result;\n\n typeFields.push(fields.replace(replace, `${typeNamePrefix}_`));\n if (typeDefs) {\n nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));\n }\n }\n\n return {\n fieldType: `${typeNamePrefix}${typeSuffix}`,\n typeDefs: /* GraphQL */ `\n ${nestedTypes.join(\"\\n\")}\n\n ${typeOfType} ${typeNamePrefix}${typeSuffix} {\n ${typeFields.join(\"\\n\")}\n }\\n\n `\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAkBO,MAAME,oBAAoB,GAAIC,MAA2B,IAAmC;EAC/F,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC,MAAM;IAAEC,IAAI;IAAEC,cAAc;IAAEC,MAAM;IAAEC;EAAiB,CAAC,GAAGP,MAAM;EAC5F,MAAMQ,UAAU,GAAGP,UAAU,KAAK,OAAO,GAAG,OAAO,GAAG,EAAE;EACxD,MAAMQ,SAAS,GAAGP,KAAK,CAACQ,eAAe;EAEvC,MAAMC,UAAoB,GAAG,EAAE;EAC/B,MAAMC,WAAqB,GAAG,EAAE;;EAEhC;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAG,IAAIC,MAAM,CAAE,GAAEL,SAAU,GAAE,EAAE,GAAG,CAAC;EAEhD,KAAK,MAAMM,KAAK,IAAIT,MAAM,EAAE;IACxB,MAAMU,MAAM,GACRf,UAAU,KAAK,MAAM,GACf,IAAAgB,yBAAW,EAAC;MAAEF,KAAK;MAAEX,IAAI;MAAED,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC,GAC7D,IAAAW,mCAAgB,EAAC;MAAEH,KAAK;MAAEZ,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC;IAEtE,IAAI,CAACS,MAAM,EAAE;MACT;IACJ;IAEA,MAAM;MAAEV,MAAM;MAAEa;IAAS,CAAC,GAAGH,MAAM;IAEnCL,UAAU,CAACS,IAAI,CAACd,MAAM,CAACO,OAAO,CAACA,OAAO,EAAG,GAAER,cAAe,GAAE,CAAC,CAAC;IAC9D,IAAIc,QAAQ,EAAE;MACVP,WAAW,CAACQ,IAAI,CAACD,QAAQ,CAACN,OAAO,CAACA,OAAO,EAAG,GAAER,cAAe,GAAE,CAAC,CAAC;IACrE;EACJ;EAEA,OAAO;IACHgB,SAAS,EAAG,GAAEhB,cAAe,GAAEG,UAAW,EAAC;IAC3CW,QAAQ,EAAE,aAAe;AACjC,cAAcP,WAAW,CAACU,IAAI,CAAC,IAAI,CAAE;AACrC;AACA,cAAcrB,UAAW,IAAGI,cAAe,GAAEG,UAAW;AACxD,kBAAkBG,UAAU,CAACW,IAAI,CAAC,IAAI,CAAE;AACxC;AACA;EACI,CAAC;AACL,CAAC;AAACC,OAAA,CAAAxB,oBAAA,GAAAA,oBAAA"}
@@ -1,3 +1 @@
1
1
  export declare const createTypeName: (modelId: string) => string;
2
- export declare const createReadTypeName: (baseTypeName: string) => string;
3
- export declare const createManageTypeName: (baseTypeName: string) => string;
@@ -1,28 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.createTypeName = exports.createReadTypeName = exports.createManageTypeName = void 0;
9
-
7
+ exports.createTypeName = void 0;
10
8
  var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
11
-
9
+ var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
12
10
  const createTypeName = modelId => {
13
- return (0, _upperFirst.default)(modelId);
14
- };
15
-
16
- exports.createTypeName = createTypeName;
17
-
18
- const createReadTypeName = baseTypeName => {
19
- return createTypeName(baseTypeName);
11
+ return (0, _upperFirst.default)((0, _camelCase.default)(modelId));
20
12
  };
21
-
22
- exports.createReadTypeName = createReadTypeName;
23
-
24
- const createManageTypeName = baseTypeName => {
25
- return createTypeName(baseTypeName);
26
- };
27
-
28
- exports.createManageTypeName = createManageTypeName;
13
+ exports.createTypeName = createTypeName;
@@ -1 +1 @@
1
- {"version":3,"names":["createTypeName","modelId","upperFirst","createReadTypeName","baseTypeName","createManageTypeName"],"sources":["createTypeName.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst\";\n\nexport const createTypeName = (modelId: string): string => {\n return upperFirst(modelId);\n};\n\nexport const createReadTypeName = (baseTypeName: string): string => {\n return createTypeName(baseTypeName);\n};\n\nexport const createManageTypeName = (baseTypeName: string): string => {\n return createTypeName(baseTypeName);\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEO,MAAMA,cAAc,GAAIC,OAAD,IAA6B;EACvD,OAAO,IAAAC,mBAAA,EAAWD,OAAX,CAAP;AACH,CAFM;;;;AAIA,MAAME,kBAAkB,GAAIC,YAAD,IAAkC;EAChE,OAAOJ,cAAc,CAACI,YAAD,CAArB;AACH,CAFM;;;;AAIA,MAAMC,oBAAoB,GAAID,YAAD,IAAkC;EAClE,OAAOJ,cAAc,CAACI,YAAD,CAArB;AACH,CAFM"}
1
+ {"version":3,"names":["_upperFirst","_interopRequireDefault","require","_camelCase","createTypeName","modelId","upperFirst","camelCase","exports"],"sources":["createTypeName.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst\";\nimport camelCase from \"lodash/camelCase\";\n\nexport const createTypeName = (modelId: string): string => {\n return upperFirst(camelCase(modelId));\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEO,MAAME,cAAc,GAAIC,OAAe,IAAa;EACvD,OAAO,IAAAC,mBAAU,EAAC,IAAAC,kBAAS,EAACF,OAAO,CAAC,CAAC;AACzC,CAAC;AAACG,OAAA,CAAAJ,cAAA,GAAAA,cAAA"}