@webiny/api-headless-cms 0.0.0-unstable.9e825fd5fb → 0.0.0-unstable.a9593f74dd

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 (550) hide show
  1. package/constants.d.ts +32 -0
  2. package/constants.js +57 -0
  3. package/constants.js.map +1 -0
  4. package/context.js +77 -39
  5. package/context.js.map +1 -1
  6. package/crud/contentEntry/afterDelete.js +3 -1
  7. package/crud/contentEntry/afterDelete.js.map +1 -1
  8. package/crud/contentEntry/beforeCreate.js +3 -1
  9. package/crud/contentEntry/beforeCreate.js.map +1 -1
  10. package/crud/contentEntry/beforeUpdate.js +3 -1
  11. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  12. package/crud/contentEntry/entryDataFactories/createEntryData.d.ts +20 -0
  13. package/crud/contentEntry/entryDataFactories/createEntryData.js +228 -0
  14. package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -0
  15. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.d.ts +21 -0
  16. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js +114 -0
  17. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js.map +1 -0
  18. package/crud/contentEntry/entryDataFactories/createPublishEntryData.d.ts +13 -0
  19. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js +61 -0
  20. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js.map +1 -0
  21. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.d.ts +12 -0
  22. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js +57 -0
  23. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js.map +1 -0
  24. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.d.ts +12 -0
  25. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js +38 -0
  26. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js.map +1 -0
  27. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.d.ts +20 -0
  28. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js +122 -0
  29. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js.map +1 -0
  30. package/crud/contentEntry/entryDataFactories/index.d.ts +8 -0
  31. package/crud/contentEntry/entryDataFactories/index.js +95 -0
  32. package/crud/contentEntry/entryDataFactories/index.js.map +1 -0
  33. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.d.ts +5 -0
  34. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js +36 -0
  35. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js.map +1 -0
  36. package/crud/contentEntry/entryDataFactories/statuses.d.ts +4 -0
  37. package/crud/contentEntry/entryDataFactories/statuses.js +15 -0
  38. package/crud/contentEntry/entryDataFactories/statuses.js.map +1 -0
  39. package/crud/contentEntry/entryDataValidation.d.ts +4 -2
  40. package/crud/contentEntry/entryDataValidation.js +223 -45
  41. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  42. package/crud/contentEntry/markLockedFields.js +17 -10
  43. package/crud/contentEntry/markLockedFields.js.map +1 -1
  44. package/crud/contentEntry/referenceFieldsMapping.d.ts +6 -0
  45. package/crud/contentEntry/referenceFieldsMapping.js +142 -90
  46. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  47. package/crud/contentEntry/searchableFields.js +5 -4
  48. package/crud/contentEntry/searchableFields.js.map +1 -1
  49. package/crud/contentEntry.crud.d.ts +5 -4
  50. package/crud/contentEntry.crud.js +558 -528
  51. package/crud/contentEntry.crud.js.map +1 -1
  52. package/crud/contentModel/beforeCreate.d.ts +1 -1
  53. package/crud/contentModel/beforeCreate.js +11 -9
  54. package/crud/contentModel/beforeCreate.js.map +1 -1
  55. package/crud/contentModel/beforeDelete.d.ts +1 -1
  56. package/crud/contentModel/beforeDelete.js +4 -6
  57. package/crud/contentModel/beforeDelete.js.map +1 -1
  58. package/crud/contentModel/beforeUpdate.d.ts +1 -1
  59. package/crud/contentModel/beforeUpdate.js +3 -6
  60. package/crud/contentModel/beforeUpdate.js.map +1 -1
  61. package/crud/contentModel/compatibility/modelApiName.js +3 -1
  62. package/crud/contentModel/compatibility/modelApiName.js.map +1 -1
  63. package/crud/contentModel/contentModelManagerFactory.js +3 -1
  64. package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
  65. package/crud/contentModel/createFieldStorageId.js +3 -1
  66. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  67. package/crud/contentModel/defaultFields.js +3 -1
  68. package/crud/contentModel/defaultFields.js.map +1 -1
  69. package/crud/contentModel/ensureTypeTag.d.ts +5 -0
  70. package/crud/contentModel/ensureTypeTag.js +21 -0
  71. package/crud/contentModel/ensureTypeTag.js.map +1 -0
  72. package/crud/contentModel/fields/descriptionField.js +4 -2
  73. package/crud/contentModel/fields/descriptionField.js.map +1 -1
  74. package/crud/contentModel/fields/imageField.js +6 -8
  75. package/crud/contentModel/fields/imageField.js.map +1 -1
  76. package/crud/contentModel/fields/titleField.js +4 -2
  77. package/crud/contentModel/fields/titleField.js.map +1 -1
  78. package/crud/contentModel/listModelsFromDatabase.d.ts +10 -0
  79. package/crud/contentModel/listModelsFromDatabase.js +38 -0
  80. package/crud/contentModel/listModelsFromDatabase.js.map +1 -0
  81. package/crud/contentModel/validate/endingAllowed.js +3 -1
  82. package/crud/contentModel/validate/endingAllowed.js.map +1 -1
  83. package/crud/contentModel/validate/isModelEndingAllowed.js +4 -2
  84. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -1
  85. package/crud/contentModel/validate/modelId.js +3 -1
  86. package/crud/contentModel/validate/modelId.js.map +1 -1
  87. package/crud/contentModel/validate/pluralApiName.js +3 -1
  88. package/crud/contentModel/validate/pluralApiName.js.map +1 -1
  89. package/crud/contentModel/validate/singularApiName.js +3 -1
  90. package/crud/contentModel/validate/singularApiName.js.map +1 -1
  91. package/crud/contentModel/validateModel.js +3 -1
  92. package/crud/contentModel/validateModel.js.map +1 -1
  93. package/crud/contentModel/validateModelFields.js +8 -7
  94. package/crud/contentModel/validateModelFields.js.map +1 -1
  95. package/crud/contentModel/validation.d.ts +586 -233
  96. package/crud/contentModel/validation.js +73 -13
  97. package/crud/contentModel/validation.js.map +1 -1
  98. package/crud/contentModel.crud.d.ts +2 -0
  99. package/crud/contentModel.crud.js +146 -181
  100. package/crud/contentModel.crud.js.map +1 -1
  101. package/crud/contentModelGroup/beforeCreate.d.ts +1 -1
  102. package/crud/contentModelGroup/beforeCreate.js +15 -1
  103. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  104. package/crud/contentModelGroup/beforeDelete.js +3 -1
  105. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  106. package/crud/contentModelGroup/beforeUpdate.js +3 -1
  107. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  108. package/crud/contentModelGroup/listGroupsFromDatabase.d.ts +8 -0
  109. package/crud/contentModelGroup/listGroupsFromDatabase.js +22 -0
  110. package/crud/contentModelGroup/listGroupsFromDatabase.js.map +1 -0
  111. package/crud/contentModelGroup/validation.d.ts +10 -7
  112. package/crud/contentModelGroup/validation.js +5 -2
  113. package/crud/contentModelGroup/validation.js.map +1 -1
  114. package/crud/contentModelGroup.crud.d.ts +3 -1
  115. package/crud/contentModelGroup.crud.js +139 -123
  116. package/crud/contentModelGroup.crud.js.map +1 -1
  117. package/crud/system.crud.js +8 -11
  118. package/crud/system.crud.js.map +1 -1
  119. package/export/crud/exporting.d.ts +3 -0
  120. package/export/crud/exporting.js +49 -0
  121. package/export/crud/exporting.js.map +1 -0
  122. package/export/crud/importing.d.ts +3 -0
  123. package/export/crud/importing.js +79 -0
  124. package/export/crud/importing.js.map +1 -0
  125. package/export/crud/imports/importData.d.ts +14 -0
  126. package/export/crud/imports/importData.js +52 -0
  127. package/export/crud/imports/importData.js.map +1 -0
  128. package/export/crud/imports/importGroups.d.ts +8 -0
  129. package/export/crud/imports/importGroups.js +104 -0
  130. package/export/crud/imports/importGroups.js.map +1 -0
  131. package/export/crud/imports/importModels.d.ts +8 -0
  132. package/export/crud/imports/importModels.js +136 -0
  133. package/export/crud/imports/importModels.js.map +1 -0
  134. package/export/crud/imports/validateGroups.d.ts +8 -0
  135. package/export/crud/imports/validateGroups.js +112 -0
  136. package/export/crud/imports/validateGroups.js.map +1 -0
  137. package/export/crud/imports/validateInput.d.ts +19 -0
  138. package/export/crud/imports/validateInput.js +55 -0
  139. package/export/crud/imports/validateInput.js.map +1 -0
  140. package/export/crud/imports/validateModels.d.ts +12 -0
  141. package/export/crud/imports/validateModels.js +203 -0
  142. package/export/crud/imports/validateModels.js.map +1 -0
  143. package/export/crud/index.d.ts +4 -0
  144. package/export/crud/index.js +15 -0
  145. package/export/crud/index.js.map +1 -0
  146. package/export/crud/sanitize.d.ts +4 -0
  147. package/export/crud/sanitize.js +35 -0
  148. package/export/crud/sanitize.js.map +1 -0
  149. package/export/graphql/index.d.ts +3 -0
  150. package/export/graphql/index.js +188 -0
  151. package/export/graphql/index.js.map +1 -0
  152. package/export/index.d.ts +2 -0
  153. package/export/index.js +29 -0
  154. package/export/index.js.map +1 -0
  155. package/export/types.d.ts +113 -0
  156. package/export/types.js +22 -0
  157. package/export/types.js.map +1 -0
  158. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +4 -7
  159. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
  160. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +5 -8
  161. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  162. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +47 -38
  163. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  164. package/fieldConverters/index.js +3 -1
  165. package/fieldConverters/index.js.map +1 -1
  166. package/graphql/buildSchemaPlugins.js +7 -1
  167. package/graphql/buildSchemaPlugins.js.map +1 -1
  168. package/graphql/checkEndpointAccess.d.ts +2 -0
  169. package/graphql/checkEndpointAccess.js +20 -0
  170. package/graphql/checkEndpointAccess.js.map +1 -0
  171. package/graphql/createExecutableSchema.js +3 -1
  172. package/graphql/createExecutableSchema.js.map +1 -1
  173. package/graphql/createRequestBody.d.ts +2 -0
  174. package/graphql/createRequestBody.js +16 -0
  175. package/graphql/createRequestBody.js.map +1 -0
  176. package/graphql/formatErrorPayload.d.ts +1 -0
  177. package/graphql/formatErrorPayload.js +27 -0
  178. package/graphql/formatErrorPayload.js.map +1 -0
  179. package/graphql/generateSchema.js +3 -1
  180. package/graphql/generateSchema.js.map +1 -1
  181. package/graphql/getSchema.d.ts +16 -0
  182. package/graphql/getSchema.js +118 -0
  183. package/graphql/getSchema.js.map +1 -0
  184. package/graphql/graphQLHandlerFactory.js +8 -191
  185. package/graphql/graphQLHandlerFactory.js.map +1 -1
  186. package/graphql/handleRequest.d.ts +11 -0
  187. package/graphql/handleRequest.js +79 -0
  188. package/graphql/handleRequest.js.map +1 -0
  189. package/graphql/index.d.ts +1 -1
  190. package/graphql/index.js +4 -2
  191. package/graphql/index.js.map +1 -1
  192. package/graphql/schema/baseContentSchema.js +9 -8
  193. package/graphql/schema/baseContentSchema.js.map +1 -1
  194. package/graphql/schema/baseSchema.d.ts +2 -3
  195. package/graphql/schema/baseSchema.js +95 -2
  196. package/graphql/schema/baseSchema.js.map +1 -1
  197. package/graphql/schema/contentEntries.js +54 -16
  198. package/graphql/schema/contentEntries.js.map +1 -1
  199. package/graphql/schema/contentModelGroups.js +5 -2
  200. package/graphql/schema/contentModelGroups.js.map +1 -1
  201. package/graphql/schema/contentModels.js +10 -10
  202. package/graphql/schema/contentModels.js.map +1 -1
  203. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  204. package/graphql/schema/createFieldResolvers.js +18 -22
  205. package/graphql/schema/createFieldResolvers.js.map +1 -1
  206. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  207. package/graphql/schema/createFieldTypePluginRecords.js +15 -0
  208. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  209. package/graphql/schema/createManageResolvers.d.ts +1 -1
  210. package/graphql/schema/createManageResolvers.js +27 -10
  211. package/graphql/schema/createManageResolvers.js.map +1 -1
  212. package/graphql/schema/createManageSDL.js +83 -42
  213. package/graphql/schema/createManageSDL.js.map +1 -1
  214. package/graphql/schema/createPreviewResolvers.js +7 -6
  215. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  216. package/graphql/schema/createReadResolvers.js +7 -6
  217. package/graphql/schema/createReadResolvers.js.map +1 -1
  218. package/graphql/schema/createReadSDL.js +35 -24
  219. package/graphql/schema/createReadSDL.js.map +1 -1
  220. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +2 -1
  221. package/graphql/schema/resolvers/manage/resolveCreate.js +4 -2
  222. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  223. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +2 -1
  224. package/graphql/schema/resolvers/manage/resolveCreateFrom.js +4 -2
  225. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  226. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  227. package/graphql/schema/resolvers/manage/resolveDelete.js +16 -4
  228. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  229. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  230. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +22 -0
  231. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  232. package/graphql/schema/resolvers/manage/resolveGet.js +12 -5
  233. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  234. package/graphql/schema/resolvers/manage/resolveGetByIds.js +3 -1
  235. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  236. package/graphql/schema/resolvers/manage/resolveGetRevisions.js +3 -1
  237. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  238. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  239. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +20 -0
  240. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  241. package/graphql/schema/resolvers/manage/resolveList.js +3 -1
  242. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  243. package/graphql/schema/resolvers/manage/resolveMove.d.ts +8 -0
  244. package/graphql/schema/resolvers/manage/resolveMove.js +27 -0
  245. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -0
  246. package/graphql/schema/resolvers/manage/resolvePublish.js +3 -1
  247. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  248. package/graphql/schema/resolvers/manage/resolveRepublish.js +3 -1
  249. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  250. package/graphql/schema/resolvers/manage/resolveUnpublish.js +3 -1
  251. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  252. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +2 -1
  253. package/graphql/schema/resolvers/manage/resolveUpdate.js +4 -2
  254. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  255. package/graphql/schema/resolvers/manage/resolveValidate.d.ts +8 -0
  256. package/graphql/schema/resolvers/manage/resolveValidate.js +20 -0
  257. package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -0
  258. package/graphql/schema/resolvers/preview/resolveGet.js +6 -5
  259. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  260. package/graphql/schema/resolvers/preview/resolveList.js +3 -1
  261. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  262. package/graphql/schema/resolvers/read/resolveGet.js +6 -5
  263. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  264. package/graphql/schema/resolvers/read/resolveList.js +3 -1
  265. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  266. package/graphql/schema/schemaPlugins.js +5 -12
  267. package/graphql/schema/schemaPlugins.js.map +1 -1
  268. package/graphql/system.d.ts +2 -5
  269. package/graphql/system.js +4 -12
  270. package/graphql/system.js.map +1 -1
  271. package/graphqlFields/boolean.js +3 -1
  272. package/graphqlFields/boolean.js.map +1 -1
  273. package/graphqlFields/datetime.js +5 -5
  274. package/graphqlFields/datetime.js.map +1 -1
  275. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  276. package/graphqlFields/dynamicZone/dynamicZoneField.js +76 -26
  277. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  278. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +60 -12
  279. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -1
  280. package/graphqlFields/dynamicZone/index.js +3 -1
  281. package/graphqlFields/dynamicZone/index.js.map +1 -1
  282. package/graphqlFields/file.js +3 -1
  283. package/graphqlFields/file.js.map +1 -1
  284. package/graphqlFields/helpers.d.ts +0 -1
  285. package/graphqlFields/helpers.js +6 -18
  286. package/graphqlFields/helpers.js.map +1 -1
  287. package/graphqlFields/index.js +5 -2
  288. package/graphqlFields/index.js.map +1 -1
  289. package/graphqlFields/json.d.ts +2 -0
  290. package/graphqlFields/json.js +49 -0
  291. package/graphqlFields/json.js.map +1 -0
  292. package/graphqlFields/longText.js +14 -3
  293. package/graphqlFields/longText.js.map +1 -1
  294. package/graphqlFields/number.js +4 -1
  295. package/graphqlFields/number.js.map +1 -1
  296. package/graphqlFields/object.js +26 -46
  297. package/graphqlFields/object.js.map +1 -1
  298. package/graphqlFields/ref.js +35 -23
  299. package/graphqlFields/ref.js.map +1 -1
  300. package/graphqlFields/richText/RichTextPluginsProcessor.d.ts +6 -0
  301. package/graphqlFields/richText/RichTextPluginsProcessor.js +34 -0
  302. package/graphqlFields/richText/RichTextPluginsProcessor.js.map +1 -0
  303. package/graphqlFields/richText/richTextResolver.d.ts +7 -0
  304. package/graphqlFields/richText/richTextResolver.js +39 -0
  305. package/graphqlFields/richText/richTextResolver.js.map +1 -0
  306. package/graphqlFields/richText.js +11 -3
  307. package/graphqlFields/richText.js.map +1 -1
  308. package/graphqlFields/text.js +5 -1
  309. package/graphqlFields/text.js.map +1 -1
  310. package/htmlRenderer/LexicalRenderer.d.ts +5 -0
  311. package/htmlRenderer/LexicalRenderer.js +28 -0
  312. package/htmlRenderer/LexicalRenderer.js.map +1 -0
  313. package/htmlRenderer/createLexicalHTMLRenderer.d.ts +2 -0
  314. package/htmlRenderer/createLexicalHTMLRenderer.js +31 -0
  315. package/htmlRenderer/createLexicalHTMLRenderer.js.map +1 -0
  316. package/index.d.ts +3 -2
  317. package/index.js +33 -14
  318. package/index.js.map +1 -1
  319. package/modelManager/DefaultCmsModelManager.js +3 -5
  320. package/modelManager/DefaultCmsModelManager.js.map +1 -1
  321. package/modelManager/index.js +3 -1
  322. package/modelManager/index.js.map +1 -1
  323. package/package.json +36 -39
  324. package/parameters/context.js +4 -2
  325. package/parameters/context.js.map +1 -1
  326. package/parameters/header.js +7 -6
  327. package/parameters/header.js.map +1 -1
  328. package/parameters/index.js +3 -1
  329. package/parameters/index.js.map +1 -1
  330. package/parameters/manual.js +9 -4
  331. package/parameters/manual.js.map +1 -1
  332. package/parameters/path.js +4 -3
  333. package/parameters/path.js.map +1 -1
  334. package/plugins/CmsGraphQLSchemaPlugin.js +5 -4
  335. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -1
  336. package/plugins/CmsGraphQLSchemaSorterPlugin.js +4 -5
  337. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
  338. package/plugins/CmsGroupPlugin.d.ts +6 -3
  339. package/plugins/CmsGroupPlugin.js +8 -6
  340. package/plugins/CmsGroupPlugin.js.map +1 -1
  341. package/plugins/CmsModelFieldConverterPlugin.js +5 -4
  342. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  343. package/plugins/CmsModelPlugin.d.ts +8 -4
  344. package/plugins/CmsModelPlugin.js +61 -32
  345. package/plugins/CmsModelPlugin.js.map +1 -1
  346. package/plugins/CmsParametersPlugin.js +7 -4
  347. package/plugins/CmsParametersPlugin.js.map +1 -1
  348. package/plugins/CmsRichTextRendererPlugin.d.ts +24 -0
  349. package/plugins/CmsRichTextRendererPlugin.js +28 -0
  350. package/plugins/CmsRichTextRendererPlugin.js.map +1 -0
  351. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  352. package/plugins/StorageOperationsCmsModelPlugin.js +41 -0
  353. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  354. package/plugins/StorageTransformPlugin.d.ts +2 -2
  355. package/plugins/StorageTransformPlugin.js +3 -4
  356. package/plugins/StorageTransformPlugin.js.map +1 -1
  357. package/plugins/index.d.ts +2 -0
  358. package/plugins/index.js +25 -1
  359. package/plugins/index.js.map +1 -1
  360. package/storage/default.js +3 -1
  361. package/storage/default.js.map +1 -1
  362. package/storage/index.d.ts +1 -0
  363. package/storage/index.js +15 -0
  364. package/storage/index.js.map +1 -0
  365. package/storage/json.d.ts +2 -0
  366. package/storage/json.js +27 -0
  367. package/storage/json.js.map +1 -0
  368. package/storage/object.js +8 -8
  369. package/storage/object.js.map +1 -1
  370. package/types.d.ts +437 -313
  371. package/types.js +20 -20
  372. package/types.js.map +1 -1
  373. package/utils/access.d.ts +9 -8
  374. package/utils/access.js +12 -62
  375. package/utils/access.js.map +1 -1
  376. package/utils/caching/Cache.d.ts +2 -0
  377. package/utils/caching/Cache.js +51 -0
  378. package/utils/caching/Cache.js.map +1 -0
  379. package/utils/caching/CacheKey.d.ts +2 -0
  380. package/utils/caching/CacheKey.js +40 -0
  381. package/utils/caching/CacheKey.js.map +1 -0
  382. package/utils/caching/index.d.ts +2 -0
  383. package/utils/caching/index.js +29 -0
  384. package/utils/caching/index.js.map +1 -0
  385. package/utils/caching/types.d.ts +11 -0
  386. package/utils/caching/types.js +7 -0
  387. package/utils/caching/types.js.map +1 -0
  388. package/utils/converters/Converter.js +4 -5
  389. package/utils/converters/Converter.js.map +1 -1
  390. package/utils/converters/ConverterCollection.js +13 -7
  391. package/utils/converters/ConverterCollection.js.map +1 -1
  392. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  393. package/utils/converters/valueKeyStorageConverter.js +32 -26
  394. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  395. package/utils/createTypeFromFields.js +8 -4
  396. package/utils/createTypeFromFields.js.map +1 -1
  397. package/utils/createTypeName.d.ts +0 -2
  398. package/utils/createTypeName.js +3 -9
  399. package/utils/createTypeName.js.map +1 -1
  400. package/utils/date.d.ts +10 -0
  401. package/utils/date.js +36 -0
  402. package/utils/date.js.map +1 -0
  403. package/utils/entryStorage.d.ts +4 -4
  404. package/utils/entryStorage.js +6 -4
  405. package/utils/entryStorage.js.map +1 -1
  406. package/utils/filterAsync.js +9 -8
  407. package/utils/filterAsync.js.map +1 -1
  408. package/utils/getBaseFieldType.d.ts +1 -3
  409. package/utils/getBaseFieldType.js +3 -1
  410. package/utils/getBaseFieldType.js.map +1 -1
  411. package/utils/getEntryDescription.d.ts +1 -1
  412. package/utils/getEntryDescription.js +3 -1
  413. package/utils/getEntryDescription.js.map +1 -1
  414. package/utils/getEntryImage.d.ts +1 -1
  415. package/utils/getEntryImage.js +3 -1
  416. package/utils/getEntryImage.js.map +1 -1
  417. package/utils/getEntryTitle.d.ts +1 -1
  418. package/utils/getEntryTitle.js +3 -1
  419. package/utils/getEntryTitle.js.map +1 -1
  420. package/utils/getSchemaFromFieldPlugins.d.ts +13 -2
  421. package/utils/getSchemaFromFieldPlugins.js +22 -4
  422. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  423. package/utils/identity.d.ts +2 -0
  424. package/utils/identity.js +20 -0
  425. package/utils/identity.js.map +1 -0
  426. package/utils/incrementEntryIdVersion.js +3 -1
  427. package/utils/incrementEntryIdVersion.js.map +1 -1
  428. package/utils/index.d.ts +1 -0
  429. package/utils/index.js +18 -0
  430. package/utils/index.js.map +1 -0
  431. package/utils/permissions/EntriesPermissions.d.ts +4 -0
  432. package/utils/permissions/EntriesPermissions.js +11 -0
  433. package/utils/permissions/EntriesPermissions.js.map +1 -0
  434. package/utils/permissions/ModelGroupsPermissions.d.ts +9 -0
  435. package/utils/permissions/ModelGroupsPermissions.js +50 -0
  436. package/utils/permissions/ModelGroupsPermissions.js.map +1 -0
  437. package/utils/permissions/ModelsPermissions.d.ts +22 -0
  438. package/utils/permissions/ModelsPermissions.js +90 -0
  439. package/utils/permissions/ModelsPermissions.js.map +1 -0
  440. package/utils/renderFields.d.ts +2 -1
  441. package/utils/renderFields.js +5 -2
  442. package/utils/renderFields.js.map +1 -1
  443. package/utils/renderGetFilterFields.d.ts +2 -2
  444. package/utils/renderGetFilterFields.js +9 -21
  445. package/utils/renderGetFilterFields.js.map +1 -1
  446. package/utils/renderInputFields.d.ts +2 -1
  447. package/utils/renderInputFields.js +17 -7
  448. package/utils/renderInputFields.js.map +1 -1
  449. package/utils/renderListFilterFields.d.ts +3 -1
  450. package/utils/renderListFilterFields.js +25 -22
  451. package/utils/renderListFilterFields.js.map +1 -1
  452. package/utils/renderSortEnum.d.ts +3 -2
  453. package/utils/renderSortEnum.js +10 -3
  454. package/utils/renderSortEnum.js.map +1 -1
  455. package/utils/toSlug.js +3 -1
  456. package/utils/toSlug.js.map +1 -1
  457. package/validators/dateGte.js +3 -1
  458. package/validators/dateGte.js.map +1 -1
  459. package/validators/dateLte.js +3 -1
  460. package/validators/dateLte.js.map +1 -1
  461. package/validators/gte.js +4 -3
  462. package/validators/gte.js.map +1 -1
  463. package/validators/in.js +4 -3
  464. package/validators/in.js.map +1 -1
  465. package/validators/index.js +4 -3
  466. package/validators/index.js.map +1 -1
  467. package/validators/lte.js +4 -3
  468. package/validators/lte.js.map +1 -1
  469. package/validators/maxLength.js +4 -3
  470. package/validators/maxLength.js.map +1 -1
  471. package/validators/minLength.js +4 -3
  472. package/validators/minLength.js.map +1 -1
  473. package/validators/pattern.js +5 -3
  474. package/validators/pattern.js.map +1 -1
  475. package/validators/patternPlugins/email.js +3 -1
  476. package/validators/patternPlugins/email.js.map +1 -1
  477. package/validators/patternPlugins/index.js +3 -1
  478. package/validators/patternPlugins/index.js.map +1 -1
  479. package/validators/patternPlugins/lowerCase.js +3 -1
  480. package/validators/patternPlugins/lowerCase.js.map +1 -1
  481. package/validators/patternPlugins/lowerCaseSpace.js +3 -1
  482. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
  483. package/validators/patternPlugins/upperCase.js +3 -1
  484. package/validators/patternPlugins/upperCase.js.map +1 -1
  485. package/validators/patternPlugins/upperCaseSpace.js +3 -1
  486. package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
  487. package/validators/patternPlugins/url.js +3 -1
  488. package/validators/patternPlugins/url.js.map +1 -1
  489. package/validators/required.js +3 -1
  490. package/validators/required.js.map +1 -1
  491. package/validators/timeGte.js +4 -3
  492. package/validators/timeGte.js.map +1 -1
  493. package/validators/timeLte.js +4 -3
  494. package/validators/timeLte.js.map +1 -1
  495. package/validators/unique.js +4 -2
  496. package/validators/unique.js.map +1 -1
  497. package/crud/contentModel/afterCreate.d.ts +0 -8
  498. package/crud/contentModel/afterCreate.js +0 -16
  499. package/crud/contentModel/afterCreate.js.map +0 -1
  500. package/crud/contentModel/afterCreateFrom.d.ts +0 -8
  501. package/crud/contentModel/afterCreateFrom.js +0 -16
  502. package/crud/contentModel/afterCreateFrom.js.map +0 -1
  503. package/crud/contentModel/afterDelete.d.ts +0 -8
  504. package/crud/contentModel/afterDelete.js +0 -16
  505. package/crud/contentModel/afterDelete.js.map +0 -1
  506. package/crud/contentModel/afterUpdate.d.ts +0 -8
  507. package/crud/contentModel/afterUpdate.js +0 -16
  508. package/crud/contentModel/afterUpdate.js.map +0 -1
  509. package/crud/contentModel/createFieldModels.d.ts +0 -2
  510. package/crud/contentModel/createFieldModels.js +0 -26
  511. package/crud/contentModel/createFieldModels.js.map +0 -1
  512. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  513. package/crud/contentModel/fieldIdValidation.js +0 -25
  514. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  515. package/crud/contentModel/idValidation.d.ts +0 -1
  516. package/crud/contentModel/idValidation.js +0 -22
  517. package/crud/contentModel/idValidation.js.map +0 -1
  518. package/crud/contentModel/models.d.ts +0 -4
  519. package/crud/contentModel/models.js +0 -192
  520. package/crud/contentModel/models.js.map +0 -1
  521. package/crud/contentModel/systemFields.d.ts +0 -1
  522. package/crud/contentModel/systemFields.js +0 -8
  523. package/crud/contentModel/systemFields.js.map +0 -1
  524. package/crud/contentModel/validateLayout.d.ts +0 -2
  525. package/crud/contentModel/validateLayout.js +0 -28
  526. package/crud/contentModel/validateLayout.js.map +0 -1
  527. package/crud/settings.crud.d.ts +0 -10
  528. package/crud/settings.crud.js +0 -66
  529. package/crud/settings.crud.js.map +0 -1
  530. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +0 -7
  531. package/graphql/schema/resolvers/commonFieldResolvers.js +0 -13
  532. package/graphql/schema/resolvers/commonFieldResolvers.js.map +0 -1
  533. package/upgrades/5.33.0/index.d.ts +0 -3
  534. package/upgrades/5.33.0/index.js +0 -182
  535. package/upgrades/5.33.0/index.js.map +0 -1
  536. package/upgrades/index.d.ts +0 -1
  537. package/upgrades/index.js +0 -12
  538. package/upgrades/index.js.map +0 -1
  539. package/utils/ownership.d.ts +0 -8
  540. package/utils/ownership.js +0 -33
  541. package/utils/ownership.js.map +0 -1
  542. package/utils/permissions.d.ts +0 -7
  543. package/utils/permissions.js +0 -91
  544. package/utils/permissions.js.map +0 -1
  545. package/utils/pluralizedTypeName.d.ts +0 -1
  546. package/utils/pluralizedTypeName.js +0 -26
  547. package/utils/pluralizedTypeName.js.map +0 -1
  548. package/validators/dynamicZone.d.ts +0 -2
  549. package/validators/dynamicZone.js +0 -20
  550. package/validators/dynamicZone.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import { ICache } from "./types";
2
+ export declare const createMemoryCache: <T>() => ICache<T>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createMemoryCache = void 0;
7
+ class Cache {
8
+ _cache = new Map();
9
+ constructor() {
10
+ // Prevent direct instantiation.
11
+ }
12
+ static create() {
13
+ return new this();
14
+ }
15
+ get(cacheKey) {
16
+ const key = cacheKey.get();
17
+ const value = this._cache.get(key);
18
+ return value || null;
19
+ }
20
+ set(cacheKey, value) {
21
+ const key = cacheKey.get();
22
+ this._cache.set(key, value);
23
+ return value;
24
+ }
25
+ getOrSet(cacheKey, cb) {
26
+ const existing = this.get(cacheKey);
27
+ if (existing) {
28
+ return existing;
29
+ }
30
+ const value = cb();
31
+ return this.set(cacheKey, value);
32
+ }
33
+ clear(cacheKey) {
34
+ if (!cacheKey) {
35
+ this._cache.clear();
36
+ return;
37
+ } else if (Array.isArray(cacheKey)) {
38
+ for (const key of cacheKey) {
39
+ this._cache.delete(key.get());
40
+ }
41
+ return;
42
+ }
43
+ this._cache.delete(cacheKey.get());
44
+ }
45
+ }
46
+ const createMemoryCache = () => {
47
+ return Cache.create();
48
+ };
49
+ exports.createMemoryCache = createMemoryCache;
50
+
51
+ //# sourceMappingURL=Cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Cache","_cache","Map","constructor","create","get","cacheKey","key","value","set","getOrSet","cb","existing","clear","Array","isArray","delete","createMemoryCache","exports"],"sources":["Cache.ts"],"sourcesContent":["import { ICache, ICacheKey } from \"./types\";\n\nclass Cache<T> implements ICache {\n private _cache: Map<string, T> = new Map();\n\n protected constructor() {\n // Prevent direct instantiation.\n }\n\n public static create<R>() {\n return new this<R>();\n }\n\n public get(cacheKey: ICacheKey): T | null {\n const key = cacheKey.get();\n const value = this._cache.get(key);\n return value || null;\n }\n\n public set(cacheKey: ICacheKey, value: T): T {\n const key = cacheKey.get();\n this._cache.set(key, value);\n return value;\n }\n\n public getOrSet(cacheKey: ICacheKey, cb: () => T): T {\n const existing = this.get(cacheKey);\n if (existing) {\n return existing;\n }\n const value = cb();\n return this.set(cacheKey, value);\n }\n\n public clear(cacheKey?: ICacheKey | ICacheKey[]) {\n if (!cacheKey) {\n this._cache.clear();\n return;\n } else if (Array.isArray(cacheKey)) {\n for (const key of cacheKey) {\n this._cache.delete(key.get());\n }\n return;\n }\n\n this._cache.delete(cacheKey.get());\n }\n}\n\nexport const createMemoryCache = <T>(): ICache<T> => {\n return Cache.create<T>();\n};\n"],"mappings":";;;;;;AAEA,MAAMA,KAAK,CAAsB;EACrBC,MAAM,GAAmB,IAAIC,GAAG,CAAC,CAAC;EAEhCC,WAAWA,CAAA,EAAG;IACpB;EAAA;EAGJ,OAAcC,MAAMA,CAAA,EAAM;IACtB,OAAO,IAAI,IAAI,CAAI,CAAC;EACxB;EAEOC,GAAGA,CAACC,QAAmB,EAAY;IACtC,MAAMC,GAAG,GAAGD,QAAQ,CAACD,GAAG,CAAC,CAAC;IAC1B,MAAMG,KAAK,GAAG,IAAI,CAACP,MAAM,CAACI,GAAG,CAACE,GAAG,CAAC;IAClC,OAAOC,KAAK,IAAI,IAAI;EACxB;EAEOC,GAAGA,CAACH,QAAmB,EAAEE,KAAQ,EAAK;IACzC,MAAMD,GAAG,GAAGD,QAAQ,CAACD,GAAG,CAAC,CAAC;IAC1B,IAAI,CAACJ,MAAM,CAACQ,GAAG,CAACF,GAAG,EAAEC,KAAK,CAAC;IAC3B,OAAOA,KAAK;EAChB;EAEOE,QAAQA,CAACJ,QAAmB,EAAEK,EAAW,EAAK;IACjD,MAAMC,QAAQ,GAAG,IAAI,CAACP,GAAG,CAACC,QAAQ,CAAC;IACnC,IAAIM,QAAQ,EAAE;MACV,OAAOA,QAAQ;IACnB;IACA,MAAMJ,KAAK,GAAGG,EAAE,CAAC,CAAC;IAClB,OAAO,IAAI,CAACF,GAAG,CAACH,QAAQ,EAAEE,KAAK,CAAC;EACpC;EAEOK,KAAKA,CAACP,QAAkC,EAAE;IAC7C,IAAI,CAACA,QAAQ,EAAE;MACX,IAAI,CAACL,MAAM,CAACY,KAAK,CAAC,CAAC;MACnB;IACJ,CAAC,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACT,QAAQ,CAAC,EAAE;MAChC,KAAK,MAAMC,GAAG,IAAID,QAAQ,EAAE;QACxB,IAAI,CAACL,MAAM,CAACe,MAAM,CAACT,GAAG,CAACF,GAAG,CAAC,CAAC,CAAC;MACjC;MACA;IACJ;IAEA,IAAI,CAACJ,MAAM,CAACe,MAAM,CAACV,QAAQ,CAACD,GAAG,CAAC,CAAC,CAAC;EACtC;AACJ;AAEO,MAAMY,iBAAiB,GAAGA,CAAA,KAAoB;EACjD,OAAOjB,KAAK,CAACI,MAAM,CAAI,CAAC;AAC5B,CAAC;AAACc,OAAA,CAAAD,iBAAA,GAAAA,iBAAA"}
@@ -0,0 +1,2 @@
1
+ import { ICacheKey, ICacheKeyKeys } from "./types";
2
+ export declare const createCacheKey: (key: ICacheKeyKeys) => ICacheKey;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createCacheKey = void 0;
8
+ var _crypto = _interopRequireDefault(require("crypto"));
9
+ const getCacheKey = input => {
10
+ if (typeof input === "string") {
11
+ return input;
12
+ } else if (typeof input === "number") {
13
+ return `${input}`;
14
+ }
15
+ return JSON.stringify(input);
16
+ };
17
+ const createHash = input => {
18
+ const key = getCacheKey(input);
19
+ const hash = _crypto.default.createHash("sha1");
20
+ hash.update(key);
21
+ return hash.digest("hex");
22
+ };
23
+ class CacheKey {
24
+ constructor(keys) {
25
+ this.keys = keys;
26
+ this.key = createHash(keys);
27
+ }
28
+ static create(key) {
29
+ return new CacheKey(key);
30
+ }
31
+ get() {
32
+ return this.key;
33
+ }
34
+ }
35
+ const createCacheKey = key => {
36
+ return CacheKey.create(key);
37
+ };
38
+ exports.createCacheKey = createCacheKey;
39
+
40
+ //# sourceMappingURL=CacheKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_crypto","_interopRequireDefault","require","getCacheKey","input","JSON","stringify","createHash","key","hash","crypto","update","digest","CacheKey","constructor","keys","create","get","createCacheKey","exports"],"sources":["CacheKey.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport { ICacheKey, ICacheKeyKeys } from \"./types\";\n\nconst getCacheKey = (input: ICacheKeyKeys): string => {\n if (typeof input === \"string\") {\n return input;\n } else if (typeof input === \"number\") {\n return `${input}`;\n }\n return JSON.stringify(input);\n};\n\nconst createHash = (input: ICacheKeyKeys): string => {\n const key = getCacheKey(input);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nclass CacheKey implements ICacheKey {\n private readonly key: string;\n public readonly keys: ICacheKeyKeys;\n\n private constructor(keys: ICacheKeyKeys) {\n this.keys = keys;\n this.key = createHash(keys);\n }\n\n public static create(key: ICacheKeyKeys): ICacheKey {\n return new CacheKey(key);\n }\n\n public get(): string {\n return this.key;\n }\n}\n\nexport const createCacheKey = (key: ICacheKeyKeys) => {\n return CacheKey.create(key);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,MAAMC,WAAW,GAAIC,KAAoB,IAAa;EAClD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAQ,GAAEA,KAAM,EAAC;EACrB;EACA,OAAOC,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC;AAChC,CAAC;AAED,MAAMG,UAAU,GAAIH,KAAoB,IAAa;EACjD,MAAMI,GAAG,GAAGL,WAAW,CAACC,KAAK,CAAC;EAC9B,MAAMK,IAAI,GAAGC,eAAM,CAACH,UAAU,CAAC,MAAM,CAAC;EACtCE,IAAI,CAACE,MAAM,CAACH,GAAG,CAAC;EAChB,OAAOC,IAAI,CAACG,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAED,MAAMC,QAAQ,CAAsB;EAIxBC,WAAWA,CAACC,IAAmB,EAAE;IACrC,IAAI,CAACA,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACP,GAAG,GAAGD,UAAU,CAACQ,IAAI,CAAC;EAC/B;EAEA,OAAcC,MAAMA,CAACR,GAAkB,EAAa;IAChD,OAAO,IAAIK,QAAQ,CAACL,GAAG,CAAC;EAC5B;EAEOS,GAAGA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACT,GAAG;EACnB;AACJ;AAEO,MAAMU,cAAc,GAAIV,GAAkB,IAAK;EAClD,OAAOK,QAAQ,CAACG,MAAM,CAACR,GAAG,CAAC;AAC/B,CAAC;AAACW,OAAA,CAAAD,cAAA,GAAAA,cAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "./Cache";
2
+ export * from "./CacheKey";
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Cache = require("./Cache");
7
+ Object.keys(_Cache).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Cache[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Cache[key];
14
+ }
15
+ });
16
+ });
17
+ var _CacheKey = require("./CacheKey");
18
+ Object.keys(_CacheKey).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _CacheKey[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _CacheKey[key];
25
+ }
26
+ });
27
+ });
28
+
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Cache","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_CacheKey"],"sources":["index.ts"],"sourcesContent":["export * from \"./Cache\";\nexport * from \"./CacheKey\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,SAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,SAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,SAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,SAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,11 @@
1
+ export declare type ICacheKeyKeys = Record<string, string | undefined> | string | number;
2
+ export interface ICacheKey {
3
+ get(): string;
4
+ keys: ICacheKeyKeys;
5
+ }
6
+ export interface ICache<T = any> {
7
+ get(cacheKey: ICacheKey): T | null;
8
+ set(cacheKey: ICacheKey, value: T): T;
9
+ getOrSet(cacheKey: ICacheKey, cb: () => T): T;
10
+ clear(cacheKey?: ICacheKey | ICacheKey[]): void;
11
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type ICacheKeyKeys = Record<string, string | undefined> | string | number;\n\nexport interface ICacheKey {\n get(): string;\n keys: ICacheKeyKeys;\n}\n\nexport interface ICache<T = any> {\n get(cacheKey: ICacheKey): T | null;\n set(cacheKey: ICacheKey, value: T): T;\n getOrSet(cacheKey: ICacheKey, cb: () => T): T;\n clear(cacheKey?: ICacheKey | ICacheKey[]): void;\n}\n"],"mappings":""}
@@ -5,13 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.Converter = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
8
  var _error = _interopRequireDefault(require("@webiny/error"));
10
9
  class Converter {
10
+ converters = undefined;
11
11
  constructor(config) {
12
- (0, _defineProperty2.default)(this, "type", void 0);
13
- (0, _defineProperty2.default)(this, "plugin", void 0);
14
- (0, _defineProperty2.default)(this, "converters", undefined);
15
12
  this.type = config.type;
16
13
  this.plugin = config.plugin;
17
14
  }
@@ -55,4 +52,6 @@ class Converter {
55
52
  });
56
53
  }
57
54
  }
58
- exports.Converter = Converter;
55
+ exports.Converter = Converter;
56
+
57
+ //# sourceMappingURL=Converter.js.map
@@ -1 +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,SAAS,CAAC;EAMZC,WAAW,CAACC,MAAuB,EAAE;IAAA;IAAA;IAAA,kDAFUC,SAAS;IAG3D,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,MAAM,GAAGH,MAAM,CAACG,MAAM;EAC/B;EAEOC,sBAAsB,CAACC,UAA+B,EAAQ;IACjE,IAAI,IAAI,CAACA,UAAU,EAAE;MACjB,MAAM,IAAIC,cAAW,CAChB,8EAA6E,IAAI,CAACJ,IAAK,IAAG,EAC3F,4BAA4B,EAC5B;QACIA,IAAI,EAAE,IAAI,CAACA;MACf,CAAC,CACJ;IACL;IACA,IAAI,CAACG,UAAU,GAAGA,UAAU;EAChC;EAEOE,sBAAsB,GAAwB;IACjD,IAAI,CAAC,IAAI,CAACF,UAAU,EAAE;MAClB,MAAM,IAAIC,cAAW,CAChB,uEAAsE,IAAI,CAACJ,IAAK,IAAG,CACvF;IACL;IACA,OAAO,IAAI,CAACG,UAAU;EAC1B;EAEOG,OAAO,GAAW;IACrB,OAAO,IAAI,CAACN,IAAI;EACpB;EAEOO,gBAAgB,CAACC,MAA8B,EAAkB;IACpE,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGF,MAAM;IAE/B,OAAO,IAAI,CAACP,MAAM,CAACM,gBAAgB,CAAC;MAChCE,KAAK;MACLC,KAAK;MACLC,mBAAmB,EAAE,IAAI,CAACN,sBAAsB;IACpD,CAAC,CAAC;EACN;EAEOO,kBAAkB,CAACJ,MAA8B,EAAkB;IACtE,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGF,MAAM;IAE/B,OAAO,IAAI,CAACP,MAAM,CAACW,kBAAkB,CAAC;MAClCH,KAAK;MACLC,KAAK;MACLC,mBAAmB,EAAE,IAAI,CAACN,sBAAsB;IACpD,CAAC,CAAC;EACN;AACJ;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","Converter","converters","undefined","constructor","config","type","plugin","setConverterCollection","WebinyError","getConverterCollection","getType","convertToStorage","params","field","value","converterCollection","convertFromStorage","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAkBO,MAAMC,SAAS,CAAC;EAIXC,UAAU,GAAoCC,SAAS;EAExDC,WAAWA,CAACC,MAAuB,EAAE;IACxC,IAAI,CAACC,IAAI,GAAGD,MAAM,CAACC,IAAI;IACvB,IAAI,CAACC,MAAM,GAAGF,MAAM,CAACE,MAAM;EAC/B;EAEOC,sBAAsBA,CAACN,UAA+B,EAAQ;IACjE,IAAI,IAAI,CAACA,UAAU,EAAE;MACjB,MAAM,IAAIO,cAAW,CAChB,8EAA6E,IAAI,CAACH,IAAK,IAAG,EAC3F,4BAA4B,EAC5B;QACIA,IAAI,EAAE,IAAI,CAACA;MACf,CACJ,CAAC;IACL;IACA,IAAI,CAACJ,UAAU,GAAGA,UAAU;EAChC;EAEOQ,sBAAsBA,CAAA,EAAwB;IACjD,IAAI,CAAC,IAAI,CAACR,UAAU,EAAE;MAClB,MAAM,IAAIO,cAAW,CAChB,uEAAsE,IAAI,CAACH,IAAK,IACrF,CAAC;IACL;IACA,OAAO,IAAI,CAACJ,UAAU;EAC1B;EAEOS,OAAOA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACL,IAAI;EACpB;EAEOM,gBAAgBA,CAACC,MAA8B,EAAkB;IACpE,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGF,MAAM;IAE/B,OAAO,IAAI,CAACN,MAAM,CAACK,gBAAgB,CAAC;MAChCE,KAAK;MACLC,KAAK;MACLC,mBAAmB,EAAE,IAAI,CAACN,sBAAsB,CAAC;IACrD,CAAC,CAAC;EACN;EAEOO,kBAAkBA,CAACJ,MAA8B,EAAkB;IACtE,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGF,MAAM;IAE/B,OAAO,IAAI,CAACN,MAAM,CAACU,kBAAkB,CAAC;MAClCH,KAAK;MACLC,KAAK;MACLC,mBAAmB,EAAE,IAAI,CAACN,sBAAsB,CAAC;IACrD,CAAC,CAAC;EACN;AACJ;AAACQ,OAAA,CAAAjB,SAAA,GAAAA,SAAA"}
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ConverterCollection = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
9
  var _Converter = require("./Converter");
12
10
  var _plugins = require("../../plugins");
13
11
  var _getBaseFieldType = require("../getBaseFieldType");
14
12
  class ConverterCollection {
13
+ converters = new Map();
15
14
  constructor(params) {
16
- (0, _defineProperty2.default)(this, "converters", new Map());
17
15
  const {
18
16
  plugins
19
17
  } = params;
@@ -64,7 +62,10 @@ class ConverterCollection {
64
62
  field,
65
63
  value: inputValues[field.fieldId]
66
64
  });
67
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, output), values);
65
+ return {
66
+ ...output,
67
+ ...values
68
+ };
68
69
  }, {});
69
70
  }
70
71
  convertFromStorage(params) {
@@ -85,7 +86,10 @@ class ConverterCollection {
85
86
  field,
86
87
  value: inputValues[field.storageId]
87
88
  });
88
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, output), values);
89
+ return {
90
+ ...output,
91
+ ...values
92
+ };
89
93
  }, {});
90
94
  }
91
95
 
@@ -104,7 +108,7 @@ class ConverterCollection {
104
108
  // maybe it's an array?
105
109
  Array.isArray(values) ||
106
110
  // and in the end, check if hasOwnProperty is a function already
107
- typeof (values === null || values === void 0 ? void 0 : values.hasOwnProperty) === "function") {
111
+ typeof values?.hasOwnProperty === "function") {
108
112
  return;
109
113
  }
110
114
  Object.defineProperty(values, "hasOwnProperty", {
@@ -116,4 +120,6 @@ class ConverterCollection {
116
120
  });
117
121
  }
118
122
  }
119
- exports.ConverterCollection = ConverterCollection;
123
+ exports.ConverterCollection = ConverterCollection;
124
+
125
+ //# sourceMappingURL=ConverterCollection.js.map
@@ -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","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":";;;;;;;;;AAAA;AACA;AAEA;AAEA;AAmBO,MAAMA,mBAAmB,CAAC;EAGtBC,WAAW,CAACC,MAAiC,EAAE;IAAA,kDAFA,IAAIC,GAAG,EAAE;IAG3D,MAAM;MAAEC;IAAQ,CAAC,GAAGF,MAAM;IAC1B,MAAMG,mBAAmB,GAAGD,OAAO,CAACE,MAAM,CACtC,4BAA4B,CAC/B;IACD,MAAMC,qBAAqB,GAAGH,OAAO,CAACE,MAAM,CACxCE,qCAA4B,CAACC,IAAI,CACpC;IACD,MAAMC,2BAA2B,GAAGH,qBAAqB,CAACI,IAAI,CAC1DC,EAAE,IAAIA,EAAE,CAACC,YAAY,EAAE,KAAK,GAAG,CAClC;IACD,IAAIH,2BAA2B,KAAKI,SAAS,EAAE;MAC3C,MAAM,IAAIC,cAAW,CAChB,yCAAwC,EACzC,+BAA+B,CAClC;IACL;IACA,KAAK,MAAMC,kB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CAACd,MAAM,CAAC;IACrB;IACA,QAAOA,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEQ,cAAc,MAAK,UAAU,EAC9C;MACE;IACJ;IACAO,MAAM,CAACC,cAAc,CAAChB,MAAM,EAAE,gBAAgB,EAAE;MAC5CiB,UAAU,EAAE,KAAK;MACjBC,QAAQ,EAAE,KAAK;MACfR,KAAK,EAAE,UAAUS,QAAgB,EAAE;QAC/B,OAAO,IAAI,CAACA,QAAQ,CAAC,KAAKnC,SAAS;MACvC;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_Converter","_plugins","_getBaseFieldType","ConverterCollection","converters","Map","constructor","params","plugins","fieldGraphQLPlugins","byType","fieldConverterPlugins","CmsModelFieldConverterPlugin","type","defaultFieldConverterPlugin","find","pl","getFieldType","undefined","WebinyError","fieldGraphQLPlugin","plugin","fieldType","converter","Converter","addConverter","setConverterCollection","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","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;EACZC,UAAU,GAA2B,IAAIC,GAAG,CAAC,CAAC;EAExDC,WAAWA,CAACC,MAAiC,EAAE;IAClD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM;IAC1B,MAAME,mBAAmB,GAAGD,OAAO,CAACE,MAAM,CACtC,4BACJ,CAAC;IACD,MAAMC,qBAAqB,GAAGH,OAAO,CAACE,MAAM,CACxCE,qCAA4B,CAACC,IACjC,CAAC;IACD,MAAMC,2BAA2B,GAAGH,qBAAqB,CAACI,IAAI,CAC1DC,EAAE,IAAIA,EAAE,CAACC,YAAY,CAAC,CAAC,KAAK,GAChC,CAAC;IACD,IAAIH,2BAA2B,KAAKI,SAAS,EAAE;MAC3C,MAAM,IAAIC,cAAW,CAChB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,MAAM,KAAK,IAAI,IACfA,MAAM,KAAKf,SAAS;IACpB;IACA,OAAOe,MAAM,KAAK,QAAQ;IAC1B;IACAa,KAAK,CAACC,OAAO,CAACd,MAAM,CAAC;IACrB;IACA,OAAOA,MAAM,EAAEQ,cAAc,KAAK,UAAU,EAC9C;MACE;IACJ;IACAO,MAAM,CAACC,cAAc,CAAChB,MAAM,EAAE,gBAAgB,EAAE;MAC5CiB,UAAU,EAAE,KAAK;MACjBC,QAAQ,EAAE,KAAK;MACfR,KAAK,EAAE,SAAAA,CAAUS,QAAgB,EAAE;QAC/B,OAAO,IAAI,CAACA,QAAQ,CAAC,KAAKlC,SAAS;MACvC;IACJ,CAAC,CAAC;EACN;AACJ;AAACmC,OAAA,CAAAlD,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
- export interface AttachConvertersParams {
14
- plugins: PluginsContainer;
15
- model: CmsModel | StorageOperationsCmsModel;
16
- }
17
- export declare const attachCmsModelFieldConverters: (params: AttachConvertersParams) => StorageOperationsCmsModel;
13
+ export declare const createCmsModelFieldConvertersAttachFactory: (plugins: PluginsContainer) => (model: StorageOperationsCmsModel | CmsModel) => StorageOperationsCmsModel;
18
14
  export {};
@@ -4,23 +4,25 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.attachCmsModelFieldConverters = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
7
+ exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.createCmsModelFieldConvertersAttachFactory = void 0;
9
8
  var _ConverterCollection = require("./ConverterCollection");
10
9
  var _semver = _interopRequireDefault(require("semver"));
11
10
  const featureVersion = _semver.default.coerce("5.33.0");
12
11
  const isBetaOrNext = model => {
13
12
  if (!model.webinyVersion) {
14
13
  return false;
14
+ } else if (model.webinyVersion.startsWith("0.0.0")) {
15
+ return true;
15
16
  }
16
- return model.webinyVersion.match(/next|beta/) !== null;
17
+ return model.webinyVersion.match(/next|beta|unstable/) !== null;
17
18
  };
18
19
  const isFeatureEnabled = model => {
19
20
  /**
20
21
  * In case of disabled webinyVersion value, we disable this feature.
21
22
  * This is only for testing...
22
23
  */
23
- if (model.webinyVersion === "disable") {
24
+ const disableConversion = !!process.env.WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE;
25
+ if (model.webinyVersion === "disable" || disableConversion) {
24
26
  return false;
25
27
  }
26
28
  /**
@@ -50,6 +52,11 @@ const isFeatureEnabled = model => {
50
52
  }
51
53
  return true;
52
54
  };
55
+
56
+ /**
57
+ * In the first call of the converter we do not need the fields property as it will be taken directly from the model.
58
+ */
59
+
53
60
  const createValueKeyToStorageConverter = params => {
54
61
  const {
55
62
  plugins,
@@ -104,26 +111,25 @@ const createValueKeyFromStorageConverter = params => {
104
111
  };
105
112
  };
106
113
  exports.createValueKeyFromStorageConverter = createValueKeyFromStorageConverter;
107
- const attachCmsModelFieldConverters = params => {
108
- const {
109
- model,
110
- plugins
111
- } = params;
112
- /**
113
- * We can safely return the model as it already has the converters attached.
114
- */
115
- if (model.convertValueKeyToStorage && model.convertValueKeyFromStorage) {
116
- return model;
117
- }
118
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
119
- convertValueKeyToStorage: createValueKeyToStorageConverter({
120
- model,
121
- plugins
122
- }),
123
- convertValueKeyFromStorage: createValueKeyFromStorageConverter({
124
- model,
125
- plugins
126
- })
127
- });
114
+ const createCmsModelFieldConvertersAttachFactory = plugins => {
115
+ return model => {
116
+ const storageModel = model;
117
+ if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {
118
+ return storageModel;
119
+ }
120
+ return {
121
+ ...model,
122
+ convertValueKeyToStorage: createValueKeyToStorageConverter({
123
+ model,
124
+ plugins
125
+ }),
126
+ convertValueKeyFromStorage: createValueKeyFromStorageConverter({
127
+ model,
128
+ plugins
129
+ })
130
+ };
131
+ };
128
132
  };
129
- exports.attachCmsModelFieldConverters = attachCmsModelFieldConverters;
133
+ exports.createCmsModelFieldConvertersAttachFactory = createCmsModelFieldConvertersAttachFactory;
134
+
135
+ //# sourceMappingURL=valueKeyStorageConverter.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["featureVersion","semver","coerce","isBetaOrNext","model","webinyVersion","match","isFeatureEnabled","nodeEnv","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 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 interface AttachConvertersParams {\n plugins: PluginsContainer;\n model: CmsModel | StorageOperationsCmsModel;\n}\n\nexport const attachCmsModelFieldConverters = (\n params: AttachConvertersParams\n): StorageOperationsCmsModel => {\n const { model, plugins } = params;\n /**\n * We can safely return the model as it already has the converters attached.\n */\n if ((model as any).convertValueKeyToStorage && (model as any).convertValueKeyFromStorage) {\n return model 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"],"mappings":";;;;;;;;AACA;AAMA;AAEA,MAAMA,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;EACA,OAAOD,KAAK,CAACC,aAAa,CAACC,KAAK,CAAC,WAAW,CAAC,KAAK,IAAI;AAC1D,CAAC;AAED,MAAMC,gBAAgB,GAAIH,KAAe,IAAc;EACnD;AACJ;AACA;AACA;EACI,IAAIA,KAAK,CAACC,aAAa,KAAK,SAAS,EAAE;IACnC,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI,MAAMG,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAkB;EAC9C,IAAIH,OAAO,KAAK,MAAM,IAAIA,OAAO,KAAK,SAAS,IAAIL,YAAY,CAACC,KAAK,CAAC,EAAE;IACpE,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACA,KAAK,CAACC,aAAa,EAAE;IACtB,OAAO,KAAK;EAChB;EACA;AACJ;AACA;AACA;AACA;EACI,MAAMO,YAAY,GAAGX,eAAM,CAACC,MAAM,CAACE,KAAK,CAACC,aAAa,CAAC;EACvD,IAAI,CAACO,YAAY,EAAE;IACfC,OAAO,CAACC,GAAG,CAAE,mBAAkBV,KAAK,CAACW,OAAQ,2CAA0C,CAAC;IACxF,OAAO,IAAI;EACf,CAAC,MAAM,IAAId,eAAM,CAACe,OAAO,CAACJ,YAAY,EAAEZ,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;IAC5D,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAkBM,MAAMiB,gCAAgC,GAAI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CAAC,GAAGD,MAAM;EACjC;AACJ;AACA;EACI,IAAKd,KAAK,CAASyB,wBAAwB,IAAKzB,KAAK,CAAS0B,0BAA0B,EAAE;IACtF,OAAO1B,KAAK;EAChB;EACA,mEACOA,KAAK;IACRyB,wBAAwB,EAAEZ,gCAAgC,CAAC;MACvDb,KAAK;MACLe;IACJ,CAAC,CAAC;IACFW,0BAA0B,EAAEJ,kCAAkC,CAAC;MAC3DtB,KAAK;MACLe;IACJ,CAAC;EAAC;AAEV,CAAC;AAAC"}
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"],"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,iBAAiB,GAAG,CAAC,CAACC,OAAO,CAACC,GAAG,CAACC,6CAA6C;EACrF,IAAIR,KAAK,CAACC,aAAa,KAAK,SAAS,IAAII,iBAAiB,EAAE;IACxD,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI,MAAMI,OAAO,GAAGH,OAAO,CAACC,GAAG,CAACG,QAAkB;EAC9C,IAAID,OAAO,KAAK,MAAM,IAAIA,OAAO,KAAK,SAAS,IAAIV,YAAY,CAACC,KAAK,CAAC,EAAE;IACpE,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACA,KAAK,CAACC,aAAa,EAAE;IACtB,OAAO,K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KAAK;MACrD,OAAOA,MAAM,IAAI,CAAC,CAAC;IACvB,CAAC;EACL;EAEA,MAAMC,UAAU,GAAG,IAAIC,wCAAmB,CAAC;IACvCH;EACJ,CAAC,CAAC;EAEF,OAAO,CAAC;IAAEI,MAAM;IAAEH;EAAyC,CAAC,KAAK;IAC7D,MAAMI,MAAM,GAAGH,UAAU,CAACO,kBAAkB,CAAC;MACzCL,MAAM,EAAEA,MAAM,IAAItB,KAAK,CAACsB,MAAM;MAC9BH;IACJ,CAAC,CAAC;IACF,OAAOI,MAAM,IAAI,CAAC,CAAC;EACvB,CAAC;AACL,CAAC;AAACE,OAAA,CAAAC,kCAAA,GAAAA,kCAAA;AAEK,MAAME,0CAA0C,GAAIV,OAAyB,IAAK;EACrF,OAAQlB,KAA2C,IAAgC;IAC/E,MAAM6B,YAAY,GAAG7B,KAA2C;IAChE,IAAI,CAAC,CAAC6B,YAAY,CAACC,wBAAwB,IAAI,CAAC,CAACD,YAAY,CAACE,0BAA0B,EAAE;MACtF,OAAOF,YAAY;IACvB;IACA,OAAO;MACH,GAAG7B,KAAK;MACR8B,wBAAwB,EAAEd,gCAAgC,CAAC;QACvDhB,KAAK;QACLkB;MACJ,CAAC,CAAC;MACFa,0BAA0B,EAAEL,kCAAkC,CAAC;QAC3D1B,KAAK;QACLkB;MACJ,CAAC;IACL,CAAC;EACL,CAAC;AACL,CAAC;AAACO,OAAA,CAAAG,0CAAA,GAAAA,0CAAA"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createTypeFromFields = void 0;
7
- var _createTypeName = require("./createTypeName");
8
7
  var _renderFields = require("./renderFields");
9
8
  var _renderInputFields = require("./renderInputFields");
10
9
  const createTypeFromFields = params => {
@@ -18,7 +17,7 @@ const createTypeFromFields = params => {
18
17
  fieldTypePlugins
19
18
  } = params;
20
19
  const typeSuffix = typeOfType === "input" ? "Input" : "";
21
- const mTypeName = (0, _createTypeName.createTypeName)(model.singularApiName);
20
+ const mTypeName = model.singularApiName;
22
21
  const typeFields = [];
23
22
  const nestedTypes = [];
24
23
 
@@ -53,6 +52,9 @@ const createTypeFromFields = params => {
53
52
  nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));
54
53
  }
55
54
  }
55
+ if (!typeFields.length) {
56
+ typeFields.push("_empty: String");
57
+ }
56
58
  return {
57
59
  fieldType: `${typeNamePrefix}${typeSuffix}`,
58
60
  typeDefs: /* GraphQL */`
@@ -60,8 +62,10 @@ const createTypeFromFields = params => {
60
62
 
61
63
  ${typeOfType} ${typeNamePrefix}${typeSuffix} {
62
64
  ${typeFields.join("\n")}
63
- }
65
+ }\n
64
66
  `
65
67
  };
66
68
  };
67
- exports.createTypeFromFields = createTypeFromFields;
69
+ exports.createTypeFromFields = createTypeFromFields;
70
+
71
+ //# sourceMappingURL=createTypeFromFields.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createTypeFromFields","params","typeOfType","model","models","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","createTypeName","singularApiName","typeFields","nestedTypes","replace","RegExp","field","result","renderField","renderInputField","typeDefs","push","fieldType","join"],"sources":["createTypeFromFields.ts"],"sourcesContent":["import { createTypeName } from \"~/utils/createTypeName\";\nimport { 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 = createTypeName(model.singularApiName);\n\n const typeFields = [];\n const nestedTypes = [];\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"],"mappings":";;;;;;AAAA;AACA;AACA;AAkBO,MAAMA,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,GAAG,IAAAC,8BAAc,EAACR,KAAK,CAACS,eAAe,CAAC;EAEvD,MAAMC,UAAU,GAAG,EAAE;EACrB,MAAMC,WAAW,GAAG,EAAE;;EAEtB;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAG,IAAIC,MAAM,CAAE,GAAEN,SAAU,GAAE,EAAE,GAAG,CAAC;EAEhD,KAAK,MAAMO,KAAK,IAAIV,MAAM,EAAE;IACxB,MAAMW,MAAM,GACRhB,UAAU,KAAK,MAAM,GACf,IAAAiB,yBAAW,EAAC;MAAEF,KAAK;MAAEZ,IAAI;MAAED,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC,GAC7D,IAAAY,mCAAgB,EAAC;MAAEH,KAAK;MAAEb,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC;IAEtE,IAAI,CAACU,MAAM,EAAE;MACT;IACJ;IAEA,MAAM;MAAEX,MAAM;MAAEc;IAAS,CAAC,GAAGH,MAAM;IAEnCL,UAAU,CAACS,IAAI,CAACf,MAAM,CAACQ,OAAO,CAACA,OAAO,EAAG,GAAET,cAAe,GAAE,CAAC,CAAC;IAC9D,IAAIe,QAAQ,EAAE;MACVP,WAAW,CAACQ,IAAI,CAACD,QAAQ,CAACN,OAAO,CAACA,OAAO,EAAG,GAAET,cAAe,GAAE,CAAC,CAAC;IACrE;EACJ;EAEA,OAAO;IACHiB,SAAS,EAAG,GAAEjB,cAAe,GAAEG,UAAW,EAAC;IAC3CY,QAAQ,EAAE,aAAe;AACjC,cAAcP,WAAW,CAACU,IAAI,CAAC,IAAI,CAAE;AACrC;AACA,cAActB,UAAW,IAAGI,cAAe,GAAEG,UAAW;AACxD,kBAAkBI,UAAU,CAACW,IAAI,CAAC,IAAI,CAAE;AACxC;AACA;EACI,CAAC;AACL,CAAC;AAAC"}
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","length","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 if (!typeFields.length) {\n typeFields.push(\"_empty: String\");\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;IAA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AACxD,kBAAkBG,UAAU,CAACY,IAAI,CAAC,IAAI,CAAE;AACxC;AACA;EACI,CAAC;AACL,CAAC;AAACC,OAAA,CAAAzB,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;
@@ -4,18 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.createTypeName = exports.createReadTypeName = exports.createManageTypeName = void 0;
7
+ exports.createTypeName = void 0;
8
8
  var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
9
9
  var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
10
10
  const createTypeName = modelId => {
11
11
  return (0, _upperFirst.default)((0, _camelCase.default)(modelId));
12
12
  };
13
13
  exports.createTypeName = createTypeName;
14
- const createReadTypeName = baseTypeName => {
15
- return createTypeName(baseTypeName);
16
- };
17
- exports.createReadTypeName = createReadTypeName;
18
- const createManageTypeName = baseTypeName => {
19
- return createTypeName(baseTypeName);
20
- };
21
- exports.createManageTypeName = createManageTypeName;
14
+
15
+ //# sourceMappingURL=createTypeName.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createTypeName","modelId","upperFirst","camelCase","createReadTypeName","baseTypeName","createManageTypeName"],"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\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;AACA;AAEO,MAAMA,cAAc,GAAIC,OAAe,IAAa;EACvD,OAAO,IAAAC,mBAAU,EAAC,IAAAC,kBAAS,EAACF,OAAO,CAAC,CAAC;AACzC,CAAC;AAAC;AAEK,MAAMG,kBAAkB,GAAIC,YAAoB,IAAa;EAChE,OAAOL,cAAc,CAACK,YAAY,CAAC;AACvC,CAAC;AAAC;AAEK,MAAMC,oBAAoB,GAAID,YAAoB,IAAa;EAClE,OAAOL,cAAc,CAACK,YAAY,CAAC;AACvC,CAAC;AAAC"}
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"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Should not be used by users as method is prone to breaking changes.
3
+ * @internal
4
+ */
5
+ export declare const formatDate: (date?: Date | string | null) => string | null;
6
+ /**
7
+ * Should not be used by users as method is prone to breaking changes.
8
+ * @internal
9
+ */
10
+ export declare const getDate: <T extends string | null = string | null>(input?: Date | string | null, defaultValue?: Date | string | null) => T;