@webiny/api-headless-cms 0.0.0-unstable.990c3ab1b6 → 0.0.0-unstable.aa00eecd97

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 (296) hide show
  1. package/context.d.ts +5 -2
  2. package/context.js +61 -8
  3. package/context.js.map +1 -1
  4. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  5. package/crud/contentEntry/markLockedFields.js +17 -4
  6. package/crud/contentEntry/markLockedFields.js.map +1 -1
  7. package/crud/contentEntry/referenceFieldsMapping.js +40 -9
  8. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  9. package/crud/contentEntry/searchableFields.d.ts +9 -0
  10. package/crud/contentEntry/searchableFields.js +72 -0
  11. package/crud/contentEntry/searchableFields.js.map +1 -0
  12. package/crud/contentEntry.crud.d.ts +8 -5
  13. package/crud/contentEntry.crud.js +1081 -841
  14. package/crud/contentEntry.crud.js.map +1 -1
  15. package/crud/contentModel/beforeCreate.d.ts +2 -3
  16. package/crud/contentModel/beforeCreate.js +43 -81
  17. package/crud/contentModel/beforeCreate.js.map +1 -1
  18. package/crud/contentModel/beforeDelete.d.ts +1 -1
  19. package/crud/contentModel/beforeDelete.js +1 -5
  20. package/crud/contentModel/beforeDelete.js.map +1 -1
  21. package/crud/contentModel/beforeUpdate.d.ts +2 -4
  22. package/crud/contentModel/beforeUpdate.js +33 -5
  23. package/crud/contentModel/beforeUpdate.js.map +1 -1
  24. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  25. package/crud/contentModel/compatibility/modelApiName.js +24 -0
  26. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  27. package/crud/contentModel/createFieldStorageId.js +4 -1
  28. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  29. package/crud/contentModel/defaultFields.d.ts +5 -0
  30. package/crud/contentModel/defaultFields.js +58 -0
  31. package/crud/contentModel/defaultFields.js.map +1 -0
  32. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  33. package/crud/contentModel/fields/descriptionField.js +42 -0
  34. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  35. package/crud/contentModel/fields/imageField.d.ts +2 -0
  36. package/crud/contentModel/fields/imageField.js +46 -0
  37. package/crud/contentModel/fields/imageField.js.map +1 -0
  38. package/crud/contentModel/fields/titleField.d.ts +2 -0
  39. package/crud/contentModel/fields/titleField.js +58 -0
  40. package/crud/contentModel/fields/titleField.js.map +1 -0
  41. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  42. package/crud/contentModel/validate/endingAllowed.js +26 -0
  43. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  44. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  45. package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
  46. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  47. package/crud/contentModel/validate/modelId.d.ts +11 -0
  48. package/crud/contentModel/validate/modelId.js +36 -0
  49. package/crud/contentModel/validate/modelId.js.map +1 -0
  50. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  51. package/crud/contentModel/validate/pluralApiName.js +24 -0
  52. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  53. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  54. package/crud/contentModel/validate/singularApiName.js +24 -0
  55. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  56. package/crud/contentModel/validateModel.d.ts +4 -4
  57. package/crud/contentModel/validateModel.js +6 -3
  58. package/crud/contentModel/validateModel.js.map +1 -1
  59. package/crud/contentModel/validateModelFields.d.ts +4 -4
  60. package/crud/contentModel/validateModelFields.js +123 -88
  61. package/crud/contentModel/validateModelFields.js.map +1 -1
  62. package/crud/contentModel/validation.d.ts +551 -0
  63. package/crud/contentModel/validation.js +145 -0
  64. package/crud/contentModel/validation.js.map +1 -0
  65. package/crud/contentModel.crud.js +369 -273
  66. package/crud/contentModel.crud.js.map +1 -1
  67. package/crud/contentModelGroup/validation.d.ts +30 -0
  68. package/crud/contentModelGroup/validation.js +34 -0
  69. package/crud/contentModelGroup/validation.js.map +1 -0
  70. package/crud/contentModelGroup.crud.js +189 -172
  71. package/crud/contentModelGroup.crud.js.map +1 -1
  72. package/crud/settings.crud.d.ts +1 -1
  73. package/crud/settings.crud.js +5 -10
  74. package/crud/settings.crud.js.map +1 -1
  75. package/crud/system.crud.js +0 -60
  76. package/crud/system.crud.js.map +1 -1
  77. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
  78. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
  79. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
  80. package/fieldConverters/index.d.ts +2 -1
  81. package/fieldConverters/index.js +2 -1
  82. package/fieldConverters/index.js.map +1 -1
  83. package/graphql/buildSchemaPlugins.d.ts +8 -3
  84. package/graphql/buildSchemaPlugins.js +3 -7
  85. package/graphql/buildSchemaPlugins.js.map +1 -1
  86. package/graphql/checkEndpointAccess.d.ts +2 -0
  87. package/graphql/checkEndpointAccess.js +18 -0
  88. package/graphql/checkEndpointAccess.js.map +1 -0
  89. package/graphql/createExecutableSchema.d.ts +6 -0
  90. package/graphql/createExecutableSchema.js +29 -0
  91. package/graphql/createExecutableSchema.js.map +1 -0
  92. package/graphql/createRequestBody.d.ts +2 -0
  93. package/graphql/createRequestBody.js +14 -0
  94. package/graphql/createRequestBody.js.map +1 -0
  95. package/graphql/formatErrorPayload.d.ts +1 -0
  96. package/graphql/formatErrorPayload.js +25 -0
  97. package/graphql/formatErrorPayload.js.map +1 -0
  98. package/graphql/generateSchema.d.ts +8 -0
  99. package/graphql/generateSchema.js +31 -0
  100. package/graphql/generateSchema.js.map +1 -0
  101. package/graphql/getSchema.d.ts +17 -0
  102. package/graphql/getSchema.js +102 -0
  103. package/graphql/getSchema.js.map +1 -0
  104. package/graphql/graphQLHandlerFactory.js +6 -104
  105. package/graphql/graphQLHandlerFactory.js.map +1 -1
  106. package/graphql/handleRequest.d.ts +11 -0
  107. package/graphql/handleRequest.js +81 -0
  108. package/graphql/handleRequest.js.map +1 -0
  109. package/graphql/index.d.ts +1 -3
  110. package/graphql/index.js +2 -39
  111. package/graphql/index.js.map +1 -1
  112. package/graphql/schema/baseContentSchema.d.ts +6 -2
  113. package/graphql/schema/baseContentSchema.js +9 -11
  114. package/graphql/schema/baseContentSchema.js.map +1 -1
  115. package/graphql/schema/baseSchema.d.ts +3 -0
  116. package/graphql/schema/baseSchema.js +68 -0
  117. package/graphql/schema/baseSchema.js.map +1 -0
  118. package/graphql/schema/contentEntries.d.ts +6 -2
  119. package/graphql/schema/contentEntries.js +116 -65
  120. package/graphql/schema/contentEntries.js.map +1 -1
  121. package/graphql/schema/contentModelGroups.d.ts +6 -2
  122. package/graphql/schema/contentModelGroups.js +14 -10
  123. package/graphql/schema/contentModelGroups.js.map +1 -1
  124. package/graphql/schema/contentModels.d.ts +6 -2
  125. package/graphql/schema/contentModels.js +60 -8
  126. package/graphql/schema/contentModels.js.map +1 -1
  127. package/graphql/schema/createFieldResolvers.d.ts +2 -2
  128. package/graphql/schema/createFieldResolvers.js +18 -13
  129. package/graphql/schema/createFieldResolvers.js.map +1 -1
  130. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  131. package/graphql/schema/createFieldTypePluginRecords.js +13 -0
  132. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  133. package/graphql/schema/createManageResolvers.d.ts +1 -1
  134. package/graphql/schema/createManageResolvers.js +37 -17
  135. package/graphql/schema/createManageResolvers.js.map +1 -1
  136. package/graphql/schema/createManageSDL.d.ts +3 -0
  137. package/graphql/schema/createManageSDL.js +81 -63
  138. package/graphql/schema/createManageSDL.js.map +1 -1
  139. package/graphql/schema/createPreviewResolvers.js +3 -7
  140. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  141. package/graphql/schema/createReadResolvers.js +8 -7
  142. package/graphql/schema/createReadResolvers.js.map +1 -1
  143. package/graphql/schema/createReadSDL.d.ts +3 -0
  144. package/graphql/schema/createReadSDL.js +47 -36
  145. package/graphql/schema/createReadSDL.js.map +1 -1
  146. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
  147. package/graphql/schema/resolvers/commonFieldResolvers.js +2 -1
  148. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
  149. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  150. package/graphql/schema/resolvers/manage/resolveDelete.js +13 -3
  151. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  152. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  153. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
  154. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  155. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  156. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
  157. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  158. package/graphql/schema/schemaPlugins.d.ts +8 -3
  159. package/graphql/schema/schemaPlugins.js +55 -52
  160. package/graphql/schema/schemaPlugins.js.map +1 -1
  161. package/graphql/system.js +55 -74
  162. package/graphql/system.js.map +1 -1
  163. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
  164. package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
  165. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
  166. package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
  167. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
  168. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
  169. package/graphqlFields/dynamicZone/index.d.ts +2 -0
  170. package/graphqlFields/dynamicZone/index.js +19 -0
  171. package/graphqlFields/dynamicZone/index.js.map +1 -0
  172. package/graphqlFields/index.d.ts +1 -1
  173. package/graphqlFields/index.js +2 -1
  174. package/graphqlFields/index.js.map +1 -1
  175. package/graphqlFields/number.js +4 -0
  176. package/graphqlFields/number.js.map +1 -1
  177. package/graphqlFields/object.js +131 -68
  178. package/graphqlFields/object.js.map +1 -1
  179. package/graphqlFields/ref.js +70 -56
  180. package/graphqlFields/ref.js.map +1 -1
  181. package/index.d.ts +5 -3
  182. package/index.js +27 -8
  183. package/index.js.map +1 -1
  184. package/package.json +40 -41
  185. package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
  186. package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
  187. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
  188. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
  189. package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
  190. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
  191. package/plugins/CmsModelFieldConverterPlugin.d.ts +2 -2
  192. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  193. package/plugins/CmsModelPlugin.d.ts +21 -3
  194. package/plugins/CmsModelPlugin.js +28 -2
  195. package/plugins/CmsModelPlugin.js.map +1 -1
  196. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  197. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  198. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  199. package/plugins/StorageTransformPlugin.d.ts +11 -11
  200. package/plugins/StorageTransformPlugin.js.map +1 -1
  201. package/plugins/index.d.ts +3 -0
  202. package/plugins/index.js +33 -0
  203. package/plugins/index.js.map +1 -1
  204. package/storage/object.js +4 -2
  205. package/storage/object.js.map +1 -1
  206. package/types.d.ts +436 -149
  207. package/types.js +74 -8
  208. package/types.js.map +1 -1
  209. package/utils/converters/ConverterCollection.js +5 -2
  210. package/utils/converters/ConverterCollection.js.map +1 -1
  211. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  212. package/utils/converters/valueKeyStorageConverter.js +26 -20
  213. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  214. package/utils/createTypeFromFields.d.ts +16 -0
  215. package/utils/createTypeFromFields.js +66 -0
  216. package/utils/createTypeFromFields.js.map +1 -0
  217. package/utils/createTypeName.d.ts +0 -2
  218. package/utils/createTypeName.js +4 -11
  219. package/utils/createTypeName.js.map +1 -1
  220. package/utils/entryStorage.js +14 -11
  221. package/utils/entryStorage.js.map +1 -1
  222. package/utils/getBaseFieldType.d.ts +2 -0
  223. package/utils/getBaseFieldType.js +10 -0
  224. package/utils/getBaseFieldType.js.map +1 -0
  225. package/utils/getEntryDescription.d.ts +2 -0
  226. package/utils/getEntryDescription.js +17 -0
  227. package/utils/getEntryDescription.js.map +1 -0
  228. package/utils/getEntryImage.d.ts +2 -0
  229. package/utils/getEntryImage.js +17 -0
  230. package/utils/getEntryImage.js.map +1 -0
  231. package/utils/getEntryTitle.d.ts +1 -1
  232. package/utils/getEntryTitle.js.map +1 -1
  233. package/utils/getSchemaFromFieldPlugins.d.ts +4 -7
  234. package/utils/getSchemaFromFieldPlugins.js +22 -14
  235. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  236. package/utils/incrementEntryIdVersion.d.ts +5 -0
  237. package/utils/incrementEntryIdVersion.js +29 -0
  238. package/utils/incrementEntryIdVersion.js.map +1 -0
  239. package/utils/ownership.d.ts +3 -3
  240. package/utils/ownership.js.map +1 -1
  241. package/utils/renderFields.d.ts +4 -2
  242. package/utils/renderFields.js +12 -3
  243. package/utils/renderFields.js.map +1 -1
  244. package/utils/renderGetFilterFields.d.ts +2 -2
  245. package/utils/renderGetFilterFields.js +9 -19
  246. package/utils/renderGetFilterFields.js.map +1 -1
  247. package/utils/renderInputFields.d.ts +4 -2
  248. package/utils/renderInputFields.js +19 -6
  249. package/utils/renderInputFields.js.map +1 -1
  250. package/utils/renderListFilterFields.d.ts +2 -1
  251. package/utils/renderListFilterFields.js +12 -21
  252. package/utils/renderListFilterFields.js.map +1 -1
  253. package/utils/renderSortEnum.d.ts +9 -5
  254. package/utils/renderSortEnum.js +23 -5
  255. package/utils/renderSortEnum.js.map +1 -1
  256. package/validators/dynamicZone.d.ts +2 -0
  257. package/validators/dynamicZone.js +20 -0
  258. package/validators/dynamicZone.js.map +1 -0
  259. package/validators/index.js +2 -1
  260. package/validators/index.js.map +1 -1
  261. package/crud/contentModel/createFieldModels.d.ts +0 -2
  262. package/crud/contentModel/createFieldModels.js +0 -20
  263. package/crud/contentModel/createFieldModels.js.map +0 -1
  264. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  265. package/crud/contentModel/fieldIdValidation.js +0 -20
  266. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  267. package/crud/contentModel/idValidation.d.ts +0 -1
  268. package/crud/contentModel/idValidation.js +0 -17
  269. package/crud/contentModel/idValidation.js.map +0 -1
  270. package/crud/contentModel/models.d.ts +0 -4
  271. package/crud/contentModel/models.js +0 -173
  272. package/crud/contentModel/models.js.map +0 -1
  273. package/crud/contentModel/systemFields.d.ts +0 -1
  274. package/crud/contentModel/systemFields.js +0 -8
  275. package/crud/contentModel/systemFields.js.map +0 -1
  276. package/crud/index.d.ts +0 -6
  277. package/crud/index.js +0 -69
  278. package/crud/index.js.map +0 -1
  279. package/graphql/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -7
  280. package/graphql/schema/resolvers/manage/resolveRequestChanges.js +0 -21
  281. package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
  282. package/graphql/schema/resolvers/manage/resolveRequestReview.d.ts +0 -7
  283. package/graphql/schema/resolvers/manage/resolveRequestReview.js +0 -21
  284. package/graphql/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
  285. package/upgrades/5.33.0/index.d.ts +0 -3
  286. package/upgrades/5.33.0/index.js +0 -159
  287. package/upgrades/5.33.0/index.js.map +0 -1
  288. package/upgrades/index.d.ts +0 -1
  289. package/upgrades/index.js +0 -9
  290. package/upgrades/index.js.map +0 -1
  291. package/utils/filterModelFields.d.ts +0 -16
  292. package/utils/filterModelFields.js +0 -71
  293. package/utils/filterModelFields.js.map +0 -1
  294. package/utils/pluralizedTypeName.d.ts +0 -1
  295. package/utils/pluralizedTypeName.js +0 -20
  296. package/utils/pluralizedTypeName.js.map +0 -1
@@ -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","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\";\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 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 /**\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;AAoBO,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,kBAAkB,IAAIX,mBAAmB,EAAE;MAClD,MAAMY,MAAM,GAAGV,qBAAqB,CAACI,IAAI,CACrCC,EAAE,IAAIA,EAAE,CAACC,YAAY,EAAE,KAAKG,kBAAkB,CAACE,SAAS,CAC3D;MACD,MAAMC,SAAS,GAAG,IAAIC,oBAAS,CAAC;QAC5BX,IAAI,EAAEO,kBAAkB,CAACE,SAAS;QAClCD,MAAM,EAAEA,MAAM,IAAIP;MACtB,CAAC,CAAC;MAEF,IAAI,CAACW,YAAY,CAACF,SAAS,CAAC;IAChC;EACJ;EAEOE,YAAY,CAACF,SAAoB,EAAQ;IAC5CA,SAAS,CAACG,sBAAsB,CAAC,IAAI,CAAC;IACt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MAC3B,OAAOA,SAAS;IACpB;IAEA,OAAOe,MAAM,CAACI,MAAM,CAAC,CAACC,MAAM,EAAEC,KAAK,KAAK;MACpC,MAAMhB,SAAS,GAAG,IAAI,CAACO,YAAY,CAACS,KAAK,CAAC1B,IAAI,CAAC;MAC/C,IAAIsB,WAAW,KAAK,IAAI,IAAIA,WAAW,CAACK,cAAc,CAACD,KAAK,CAACK,SAAS,CAAC,KAAK,KAAK,EAAE;QAC/E,OAAON,MAAM;MACjB;MACA,MAAMJ,MAAM,GAAGX,SAAS,CAACoB,kBAAkB,CAAC;QACxCJ,KAAK;QACLG,KAAK,EAAEP,WAAW,CAACI,KAAK,CAACK,SAAS;MACtC,CAAC,CAAC;MAEF,mEACON,MAAM,GACNJ,MAAM;IAEjB,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYE,oBAAoB,CAACF,MAAsB,EAAE;IACjD;IACI;IACAA,MAAM,KAAK,IAAI,IACfA,MAAM,KAAKhB,SAAS;IACpB;IACA,OAAOgB,MAAM,KAAK,QAAQ;IAC1B;IACAW,KAAK,CAACC,OAAO,CAACZ,MAAM,CAAC;IACrB;IACA,QAAOA,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEM,cAAc,MAAK,UAAU,EAC9C;MACE;IACJ;IACAO,MAAM,CAACC,cAAc,CAACd,MAAM,EAAE,gBAAgB,EAAE;MAC5Ce,UAAU,EAAE,KAAK;MACjBC,QAAQ,EAAE,KAAK;MACfR,KAAK,EAAE,UAAUS,QAAgB,EAAE;QAC/B,OAAO,IAAI,CAACA,QAAQ,CAAC,KAAKjC,SAAS;MACvC;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
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;\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SAAS,GAAG,IAAI,CAACO,YAAY,CAACU,QAAQ,CAAC;MAC7C,IAAIL,WAAW,KAAK,IAAI,IAAIA,WAAW,CAACO,cAAc,CAACH,KAAK,CAACO,SAAS,CAAC,KAAK,KAAK,EAAE;QAC/E,OAAOR,MAAM;MACjB;MACA,MAAMJ,MAAM,GAAGX,SAAS,CAACsB,kBAAkB,CAAC;QACxCN,KAAK;QACLK,KAAK,EAAET,WAAW,CAACI,KAAK,CAACO,SAAS;MACtC,CAAC,CAAC;MAEF,mEACOR,MAAM,GACNJ,MAAM;IAEjB,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYE,oBAAoB,CAACF,MAAsB,EAAE;IACjD;IACI;IACAA,MAAM,KAAK,IAAI,IACfA,MAAM,KAAKhB,SAAS;IACpB;IACA,OAAOgB,MAAM,KAAK,QAAQ;IAC1B;IACAa,KAAK,CAACC,OAAO,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"}
@@ -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 {};
@@ -4,7 +4,7 @@ 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;
7
+ exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.createCmsModelFieldConvertersAttachFactory = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
9
  var _ConverterCollection = require("./ConverterCollection");
10
10
  var _semver = _interopRequireDefault(require("semver"));
@@ -12,21 +12,25 @@ const featureVersion = _semver.default.coerce("5.33.0");
12
12
  const isBetaOrNext = model => {
13
13
  if (!model.webinyVersion) {
14
14
  return false;
15
+ } else if (model.webinyVersion.startsWith("0.0.0")) {
16
+ return true;
15
17
  }
16
- return model.webinyVersion.match(/next|beta/) !== null;
18
+ return model.webinyVersion.match(/next|beta|unstable/) !== null;
17
19
  };
18
20
  const isFeatureEnabled = model => {
19
21
  /**
20
22
  * In case of disabled webinyVersion value, we disable this feature.
21
23
  * This is only for testing...
22
24
  */
23
- if (model.webinyVersion === "disable") {
25
+ const disableConversion = !!process.env.WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE;
26
+ if (model.webinyVersion === "disable" || disableConversion) {
24
27
  return false;
25
28
  }
26
29
  /**
27
30
  * If is a test environment, always have this turned on.
28
31
  */
29
- if (process.env.NODE_ENV === "test" || isBetaOrNext(model) === true) {
32
+ const nodeEnv = process.env.NODE_ENV;
33
+ if (nodeEnv === "test" || nodeEnv === "disable" || isBetaOrNext(model)) {
30
34
  return true;
31
35
  }
32
36
  /**
@@ -103,20 +107,22 @@ const createValueKeyFromStorageConverter = params => {
103
107
  };
104
108
  };
105
109
  exports.createValueKeyFromStorageConverter = createValueKeyFromStorageConverter;
106
- const attachCmsModelFieldConverters = params => {
107
- const {
108
- model,
109
- plugins
110
- } = params;
111
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
112
- convertValueKeyToStorage: createValueKeyToStorageConverter({
113
- model,
114
- plugins
115
- }),
116
- convertValueKeyFromStorage: createValueKeyFromStorageConverter({
117
- model,
118
- plugins
119
- })
120
- });
110
+ const createCmsModelFieldConvertersAttachFactory = plugins => {
111
+ return model => {
112
+ const storageModel = model;
113
+ if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {
114
+ return storageModel;
115
+ }
116
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
117
+ convertValueKeyToStorage: createValueKeyToStorageConverter({
118
+ model,
119
+ plugins
120
+ }),
121
+ convertValueKeyFromStorage: createValueKeyFromStorageConverter({
122
+ model,
123
+ plugins
124
+ })
125
+ });
126
+ };
121
127
  };
122
- exports.attachCmsModelFieldConverters = attachCmsModelFieldConverters;
128
+ 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,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,IAAIG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,IAAIP,YAAY,CAACC,KAAK,CAAC,KAAK,IAAI,EAAE;IACjE,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACA,KAAK,CAACC,aAAa,EAAE;IACtB,OAAO,KAAK;EAChB;EACA;AACJ;AACA;AACA;AACA;EACI,MAAMM,YAAY,GAAGV,eAAM,CAACC,MAAM,CAACE,KAAK,CAACC,aAAa,CAAC;EACvD,IAAI,CAACM,YAAY,EAAE;IACfC,OAAO,CAACC,GAAG,CAAE,mBAAkBT,KAAK,CAACU,OAAQ,2CAA0C,CAAC;IACxF,OAAO,IAAI;EACf,CAAC,MAAM,IAAIb,eAAM,CAACc,OAAO,CAACJ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AAM,IAAI,CAAC,CAAC;EACvB,CAAC;AACL,CAAC;AAAC;AAMK,MAAMI,6BAA6B,GACtCV,MAA8B,IACF;EAC5B,MAAM;IAAEb,KAAK;IAAEc;EAAQ,CAAC,GAAGD,MAAM;EACjC,mEACOb,KAAK;IACRwB,wBAAwB,EAAEZ,gCAAgC,CAAC;MACvDZ,KAAK;MACLc;IACJ,CAAC,CAAC;IACFW,0BAA0B,EAAEJ,kCAAkC,CAAC;MAC3DrB,KAAK;MACLc;IACJ,CAAC;EAAC;AAEV,CAAC;AAAC"}
1
+ {"version":3,"names":["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","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;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,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,KAAK;EAChB;EACA;AACJ;AACA;AACA;AACA;EACI,MAAMU,YAAY,GAAGd,eAAM,CAACC,MAAM,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EAEF,OAAO,CAAC;IAAEI,MAAM;IAAEH;EAAyC,CAAC,KAAK;IAC7D,MAAMI,MAAM,GAAGH,UAAU,CAACM,kBAAkB,CAAC;MACzCJ,MAAM,EAAEA,MAAM,IAAItB,KAAK,CAACsB,MAAM;MAC9BH;IACJ,CAAC,CAAC;IACF,OAAOI,MAAM,IAAI,CAAC,CAAC;EACvB,CAAC;AACL,CAAC;AAAC;AAEK,MAAMI,0CAA0C,GAAIT,OAAyB,IAAK;EACrF,OAAQlB,KAA2C,IAAgC;IAC/E,MAAM4B,YAAY,GAAG5B,KAA2C;IAChE,IAAI,CAAC,CAAC4B,YAAY,CAACC,wBAAwB,IAAI,CAAC,CAACD,YAAY,CAACE,0BAA0B,EAAE;MACtF,OAAOF,YAAY;IACvB;IACA,mEACO5B,KAAK;MACR6B,wBAAwB,EAAEb,gCAAgC,CAAC;QACvDhB,KAAK;QACLkB;MACJ,CAAC,CAAC;MACFY,0BAA0B,EAAEL,kCAAkC,CAAC;QAC3DzB,KAAK;QACLkB;MACJ,CAAC;IAAC;EAEV,CAAC;AACL,CAAC;AAAC"}
@@ -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
+ }
63
+ `
64
+ };
65
+ };
66
+ exports.createTypeFromFields = createTypeFromFields;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createTypeFromFields","params","typeOfType","model","models","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","singularApiName","typeFields","nestedTypes","replace","RegExp","field","result","renderField","renderInputField","typeDefs","push","fieldType","join"],"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"],"mappings":";;;;;;AAAA;AACA;AAkBO,MAAMA,oBAAoB,GAAIC,MAA2B,IAAmC;EAC/F,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC,MAAM;IAAEC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ACxC;AACA;EACI,CAAC;AACL,CAAC;AAAC"}
@@ -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,17 +4,10 @@ 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
+ var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
9
10
  const createTypeName = modelId => {
10
- return (0, _upperFirst.default)(modelId);
11
+ return (0, _upperFirst.default)((0, _camelCase.default)(modelId));
11
12
  };
12
- exports.createTypeName = createTypeName;
13
- const createReadTypeName = baseTypeName => {
14
- return createTypeName(baseTypeName);
15
- };
16
- exports.createReadTypeName = createReadTypeName;
17
- const createManageTypeName = baseTypeName => {
18
- return createTypeName(baseTypeName);
19
- };
20
- 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,OAAe,IAAa;EACvD,OAAO,IAAAC,mBAAU,EAACD,OAAO,CAAC;AAC9B,CAAC;AAAC;AAEK,MAAME,kBAAkB,GAAIC,YAAoB,IAAa;EAChE,OAAOJ,cAAc,CAACI,YAAY,CAAC;AACvC,CAAC;AAAC;AAEK,MAAMC,oBAAoB,GAAID,YAAoB,IAAa;EAClE,OAAOJ,cAAc,CAACI,YAAY,CAAC;AACvC,CAAC;AAAC"}
1
+ {"version":3,"names":["createTypeName","modelId","upperFirst","camelCase"],"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;AACA;AAEO,MAAMA,cAAc,GAAIC,OAAe,IAAa;EACvD,OAAO,IAAAC,mBAAU,EAAC,IAAAC,kBAAS,EAACF,OAAO,CAAC,CAAC;AACzC,CAAC;AAAC"}
@@ -8,24 +8,25 @@ exports.entryToStorageTransform = exports.entryFromStorageTransform = exports.en
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
9
  var _error = _interopRequireDefault(require("@webiny/error"));
10
10
  var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
11
+ var _getBaseFieldType = require("./getBaseFieldType");
11
12
  const getStoragePluginFactory = context => {
12
13
  let defaultStoragePlugin;
13
14
  const plugins = context.plugins.byType(_StorageTransformPlugin.StorageTransformPlugin.type)
14
15
  // we reverse plugins because we want to get latest added only
15
16
  .reverse().reduce((collection, plugin) => {
16
- // check if it's a default plugin
17
- if (plugin.fieldType === "*" && !defaultStoragePlugin) {
17
+ /**
18
+ * Check if it's a default plugin and set it - always override the previous one.
19
+ */
20
+ if (plugin.fieldType === "*") {
18
21
  defaultStoragePlugin = plugin;
19
22
  return collection;
20
23
  }
21
24
 
22
25
  /**
23
- * either existing plugin added or plugin fieldType does not exist in current model
24
- * this is to iterate a bit less later
26
+ * We will just set the plugin for given type.
27
+ * The last one will override existing one - so users can override our default ones.
25
28
  */
26
- if (!collection[plugin.fieldType]) {
27
- collection[plugin.fieldType] = plugin;
28
- }
29
+ collection[plugin.fieldType] = plugin;
29
30
  return collection;
30
31
  }, {});
31
32
  return fieldType => {
@@ -40,10 +41,11 @@ const entryStorageTransform = async (context, model, operation, entry) => {
40
41
  const getStoragePlugin = getStoragePluginFactory(context);
41
42
  const transformedValues = {};
42
43
  for (const field of model.fields) {
43
- const plugin = getStoragePlugin(field.type);
44
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
45
+ const plugin = getStoragePlugin(baseType);
44
46
  // TODO: remove this once plugins are converted into classes
45
47
  if (typeof plugin[operation] !== "function") {
46
- throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${field.type}"`);
48
+ throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
47
49
  }
48
50
  transformedValues[field.fieldId] = await plugin[operation]({
49
51
  plugins: context.plugins,
@@ -84,11 +86,12 @@ const entryFieldFromStorageTransform = async params => {
84
86
  value
85
87
  } = params;
86
88
  const getStoragePlugin = getStoragePluginFactory(context);
87
- const plugin = getStoragePlugin(field.type);
89
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
90
+ const plugin = getStoragePlugin(baseType);
88
91
 
89
92
  // TODO: remove this once plugins are converted into classes
90
93
  if (typeof plugin.fromStorage !== "function") {
91
- throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${field.type}"`);
94
+ throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
92
95
  }
93
96
  return plugin.fromStorage({
94
97
  plugins: context.plugins,
@@ -1 +1 @@
1
- {"version":3,"names":["getStoragePluginFactory","context","defaultStoragePlugin","plugins","byType","StorageTransformPlugin","type","reverse","reduce","collection","plugin","fieldType","entryStorageTransform","model","operation","entry","getStoragePlugin","transformedValues","field","fields","WebinyError","name","fieldId","value","values","entryToStorageTransform","entryFromStorageTransform","entryFieldFromStorageTransform","params","fromStorage"],"sources":["entryStorage.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\nimport { CmsEntry, CmsModel, CmsModelField, CmsContext } from \"~/types\";\n\ninterface GetStoragePluginFactory {\n (context: CmsContext): (fieldType: string) => StorageTransformPlugin<any>;\n}\n\nconst getStoragePluginFactory: GetStoragePluginFactory = context => {\n let defaultStoragePlugin: StorageTransformPlugin;\n\n const plugins = context.plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n // we reverse plugins because we want to get latest added only\n .reverse()\n .reduce((collection, plugin) => {\n // check if it's a default plugin\n if (plugin.fieldType === \"*\" && !defaultStoragePlugin) {\n defaultStoragePlugin = plugin;\n return collection;\n }\n\n /**\n * either existing plugin added or plugin fieldType does not exist in current model\n * this is to iterate a bit less later\n */\n if (!collection[plugin.fieldType]) {\n collection[plugin.fieldType] = plugin;\n }\n\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n return (fieldType: string) => {\n return plugins[fieldType] || defaultStoragePlugin;\n };\n};\n\n/**\n * This should be used when transforming the whole entry.\n */\nconst entryStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n operation: \"toStorage\" | \"fromStorage\",\n entry: CmsEntry\n): Promise<CmsEntry> => {\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const transformedValues: Record<string, any> = {};\n for (const field of model.fields) {\n const plugin = getStoragePlugin(field.type);\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin[operation] !== \"function\") {\n throw new WebinyError(\n `Missing \"${operation}\" function in storage plugin \"${plugin.name}\" for field type \"${field.type}\"`\n );\n }\n\n transformedValues[field.fieldId] = await plugin[operation]({\n plugins: context.plugins,\n model,\n field,\n value: entry.values[field.fieldId],\n getStoragePlugin\n });\n }\n\n return { ...entry, values: transformedValues };\n};\n\n/**\n * A function that is used in crud to transform entry into the storage type.\n */\nexport const entryToStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"toStorage\", entry);\n};\n\n/**\n * A function that is used to transform the whole entry from storage into its native form.\n */\nexport const entryFromStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"fromStorage\", entry);\n};\n\ninterface EntryFieldFromStorageTransformParams {\n context: CmsContext;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n}\n/*\n * A function that is used to transform a single field from storage\n */\nexport const entryFieldFromStorageTransform = async <T = any>(\n params: EntryFieldFromStorageTransformParams\n): Promise<T> => {\n const { context, model, field, value } = params;\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const plugin = getStoragePlugin(field.type);\n\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin.fromStorage !== \"function\") {\n throw new WebinyError(\n `Missing \"fromStorage\" function in storage plugin \"${plugin.name}\" for field type \"${field.type}\"`\n );\n }\n\n return plugin.fromStorage({\n plugins: context.plugins,\n model,\n field,\n value,\n getStoragePlugin\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AAOA,MAAMA,uBAAgD,GAAGC,OAAO,IAAI;EAChE,IAAIC,oBAA4C;EAEhD,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAyBC,8CAAsB,CAACC,IAAI;EAC3D;EAAA,CACCC,OAAO,EAAE,CACTC,MAAM,CAAC,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC5B;IACA,IAAIA,MAAM,CAACC,SAAS,KAAK,GAAG,IAAI,CAACT,oBAAoB,EAAE;MACnDA,oBAAoB,GAAGQ,MAAM;MAC7B,OAAOD,UAAU;IACrB;;IAEA;AACZ;AACA;AACA;IACY,IAAI,CAACA,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,EAAE;MAC/BF,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IACzC;IAEA,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAA2C;EAEpD,OAAQE,SAAiB,IAAK;IAC1B,OAAOR,OAAO,CAACQ,SAAS,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AC;AAQF;AACA;AACA;AACO,MAAMY,8BAA8B,GAAG,MAC1CC,MAA4C,IAC/B;EACb,MAAM;IAAE3B,OAAO;IAAEY,KAAK;IAAEK,KAAK;IAAEK;EAAM,CAAC,GAAGK,MAAM;EAC/C,MAAMZ,gBAAgB,GAAGhB,uBAAuB,CAACC,OAAO,CAAC;EAEzD,MAAMS,MAAM,GAAGM,gBAAgB,CAACE,KAAK,CAACZ,IAAI,CAAC;;EAE3C;EACA,IAAI,OAAOI,MAAM,CAACmB,WAAW,KAAK,UAAU,EAAE;IAC1C,MAAM,IAAIT,cAAW,CAChB,qDAAoDV,MAAM,CAACW,IAAK,qBAAoBH,KAAK,CAACZ,IAAK,GAAE,CACrG;EACL;EAEA,OAAOI,MAAM,CAACmB,WAAW,CAAC;IACtB1B,OAAO,EAAEF,OAAO,CAACE,OAAO;IACxBU,KAAK;IACLK,KAAK;IACLK,KAAK;IACLP;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["getStoragePluginFactory","context","defaultStoragePlugin","plugins","byType","StorageTransformPlugin","type","reverse","reduce","collection","plugin","fieldType","entryStorageTransform","model","operation","entry","getStoragePlugin","transformedValues","field","fields","baseType","getBaseFieldType","WebinyError","name","fieldId","value","values","entryToStorageTransform","entryFromStorageTransform","entryFieldFromStorageTransform","params","fromStorage"],"sources":["entryStorage.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\nimport { CmsEntry, CmsModel, CmsModelField, CmsContext } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface GetStoragePluginFactory {\n (context: CmsContext): (fieldType: string) => StorageTransformPlugin<any>;\n}\n\nconst getStoragePluginFactory: GetStoragePluginFactory = context => {\n let defaultStoragePlugin: StorageTransformPlugin;\n\n const plugins = context.plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n // we reverse plugins because we want to get latest added only\n .reverse()\n .reduce((collection, plugin) => {\n /**\n * Check if it's a default plugin and set it - always override the previous one.\n */\n if (plugin.fieldType === \"*\") {\n defaultStoragePlugin = plugin;\n return collection;\n }\n\n /**\n * We will just set the plugin for given type.\n * The last one will override existing one - so users can override our default ones.\n */\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n return (fieldType: string) => {\n return plugins[fieldType] || defaultStoragePlugin;\n };\n};\n\n/**\n * This should be used when transforming the whole entry.\n */\nconst entryStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n operation: \"toStorage\" | \"fromStorage\",\n entry: CmsEntry\n): Promise<CmsEntry> => {\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const transformedValues: Record<string, any> = {};\n for (const field of model.fields) {\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin[operation] !== \"function\") {\n throw new WebinyError(\n `Missing \"${operation}\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n transformedValues[field.fieldId] = await plugin[operation]({\n plugins: context.plugins,\n model,\n field,\n value: entry.values[field.fieldId],\n getStoragePlugin\n });\n }\n\n return { ...entry, values: transformedValues };\n};\n\n/**\n * A function that is used in crud to transform entry into the storage type.\n */\nexport const entryToStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"toStorage\", entry);\n};\n\n/**\n * A function that is used to transform the whole entry from storage into its native form.\n */\nexport const entryFromStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"fromStorage\", entry);\n};\n\ninterface EntryFieldFromStorageTransformParams {\n context: CmsContext;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n}\n/*\n * A function that is used to transform a single field from storage\n */\nexport const entryFieldFromStorageTransform = async <T = any>(\n params: EntryFieldFromStorageTransformParams\n): Promise<T> => {\n const { context, model, field, value } = params;\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin.fromStorage !== \"function\") {\n throw new WebinyError(\n `Missing \"fromStorage\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n return plugin.fromStorage({\n plugins: context.plugins,\n model,\n field,\n value,\n getStoragePlugin\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AAEA;AAMA,MAAMA,uBAAgD,GAAGC,OAAO,IAAI;EAChE,IAAIC,oBAA4C;EAEhD,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAyBC,8CAAsB,CAACC,IAAI;EAC3D;EAAA,CACCC,OAAO,EAAE,CACTC,MAAM,CAAC,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC5B;AACZ;AACA;IACY,IAAIA,MAAM,CAACC,SAAS,KAAK,GAAG,EAAE;MAC1BT,oBAAoB,GAAGQ,MAAM;MAC7B,OAAOD,UAAU;IACrB;;IAEA;AACZ;AACA;AACA;IACYA,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAErC,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAA2C;EAEpD,OAAQE,SAAiB,IAAK;IAC1B,OAAOR,OAAO,CAACQ,SAAS,CAAC,IAAIT,oBAAoB;EACrD,CAAC;AACL,CAAC;;AAED;AACA;AACA;AACA,MAAMU,qBAAqB,GAAG,OAC1BX,OAAmB,EACnBY,KAAe,EACfC,SAAsC,EACtCC,KAAe,KACK;EACpB,MAAMC,gBAAgB,GAAGhB,uBAAuB,CAACC,OAAO,CAAC;EAEzD,MAAMgB,iBAAsC,GAAG,CAAC,CAAC;EACjD,KAAK,MAAMC,KAAK,IAAIL,KAAK,CAACM,MAAM,EAAE;IAC9B,MAAMC,QAA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MAAM,GAAGM,gBAAgB,CAACI,QAAQ,CAAC;;EAEzC;EACA,IAAI,OAAOV,MAAM,CAACqB,WAAW,KAAK,UAAU,EAAE;IAC1C,MAAM,IAAIT,cAAW,CAChB,qDAAoDZ,MAAM,CAACa,IAAK,qBAAoBH,QAAS,GAAE,CACnG;EACL;EAEA,OAAOV,MAAM,CAACqB,WAAW,CAAC;IACtB5B,OAAO,EAAEF,OAAO,CAACE,OAAO;IACxBU,KAAK;IACLK,KAAK;IACLO,KAAK;IACLT;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { CmsModelField } from "../types";
2
+ export declare const getBaseFieldType: (field: Pick<CmsModelField, "type">) => string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBaseFieldType = void 0;
7
+ const getBaseFieldType = field => {
8
+ return field.type.split(":")[0];
9
+ };
10
+ exports.getBaseFieldType = getBaseFieldType;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getBaseFieldType","field","type","split"],"sources":["getBaseFieldType.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\n\nexport const getBaseFieldType = (field: Pick<CmsModelField, \"type\">) => {\n return field.type.split(\":\")[0];\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAIC,KAAkC,IAAK;EACpE,OAAOA,KAAK,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntry, CmsModel } from "../types";
2
+ export declare function getEntryDescription(model: Pick<CmsModel, "descriptionFieldId" | "fields">, entry: CmsEntry): string;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getEntryDescription = getEntryDescription;
7
+ function getEntryDescription(model, entry) {
8
+ if (!model.descriptionFieldId) {
9
+ return "";
10
+ }
11
+ const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);
12
+ if (!field) {
13
+ return "";
14
+ }
15
+ const descriptionFieldId = field.fieldId;
16
+ return entry.values[descriptionFieldId] || "";
17
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getEntryDescription","model","entry","descriptionFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryDescription.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryDescription(\n model: Pick<CmsModel, \"descriptionFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.descriptionFieldId) {\n return \"\";\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return \"\";\n }\n const descriptionFieldId = field.fieldId;\n return entry.values[descriptionFieldId] || \"\";\n}\n"],"mappings":";;;;;;AAEO,SAASA,mBAAmB,CAC/BC,KAAsD,EACtDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,kBAAkB,EAAE;IAC3B,OAAO,EAAE;EACb;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,kBAAkB,CAAC;EAC5E,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EACA,MAAMD,kBAAkB,GAAGC,KAAK,CAACI,OAAO;EACxC,OAAON,KAAK,CAACO,MAAM,CAACN,kBAAkB,CAAC,IAAI,EAAE;AACjD"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntry, CmsModel } from "../types";
2
+ export declare function getEntryImage(model: Pick<CmsModel, "imageFieldId" | "fields">, entry: CmsEntry): string | null;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getEntryImage = getEntryImage;
7
+ function getEntryImage(model, entry) {
8
+ if (!model.imageFieldId) {
9
+ return null;
10
+ }
11
+ const field = model.fields.find(f => f.fieldId === model.imageFieldId);
12
+ if (!field) {
13
+ return null;
14
+ }
15
+ const imageFieldId = field.fieldId;
16
+ return entry.values[imageFieldId] || null;
17
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getEntryImage","model","entry","imageFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryImage.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryImage(\n model: Pick<CmsModel, \"imageFieldId\" | \"fields\">,\n entry: CmsEntry\n): string | null {\n if (!model.imageFieldId) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.imageFieldId);\n if (!field) {\n return null;\n }\n const imageFieldId = field.fieldId;\n return entry.values[imageFieldId] || null;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAa,CACzBC,KAAgD,EAChDC,KAAe,EACF;EACb,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAO,IAAI;EACf;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,MAAMD,YAAY,GAAGC,KAAK,CAACI,OAAO;EAClC,OAAON,KAAK,CAACO,MAAM,CAACN,YAAY,CAAC,IAAI,IAAI;AAC7C"}
@@ -1,2 +1,2 @@
1
1
  import { CmsEntry, CmsModel } from "../types";
2
- export declare function getEntryTitle(model: CmsModel, entry: CmsEntry): string;
2
+ export declare function getEntryTitle(model: Pick<CmsModel, "titleFieldId" | "fields">, entry: CmsEntry): string;
@@ -1 +1 @@
1
- {"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","field","fields","find","f","fieldId","titleValue","values","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(model: CmsModel, entry: CmsEntry): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return entry.id;\n }\n const titleFieldId = field.fieldId;\n const titleValue = entry.values[titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAa,CAACC,KAAe,EAAEC,KAAe,EAAU;EACpE,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAOD,KAAK,CAACE,EAAE;EACnB;EACA,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKR,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACE,KAAK,EAAE;IACR,OAAOH,KAAK,CAACE,EAAE;EACnB;EACA,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAAO;EAClC,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAACR,YAAY,CAAC;EAC7C,IAAI,CAACO,UAAU,EAAE;IACb,OAAOR,KAAK,CAACE,EAAE;EACnB;EAEA,MAAM;IAAEQ,OAAO,GAAG,KAAK;IAAED;EAAO,CAAC,GAAGN,KAAK,CAACQ,gBAAgB,IAAI,CAAC,CAAC;EAChE,IAAI,CAACD,OAAO,IAAI,CAACD,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,KAAK,KAAK,EAAE;IACxD,OAAOD,UAAU;EACrB;EACA,KAAK,MAAMM,KAAK,IAAIL,MAAM,EAAE;IACxB;IACA,IAAIK,KAAK,CAACA,KAAK,IAAIN,UAAU,EAAE;MAC3B,OAAOM,KAAK,CAACC,KAAK;IACtB;EACJ;EACA,OAAOP,UAAU;AACrB"}
1
+ {"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","field","fields","find","f","fieldId","titleValue","values","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(\n model: Pick<CmsModel, \"titleFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return entry.id;\n }\n const titleFieldId = field.fieldId;\n const titleValue = entry.values[titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAa,CACzBC,KAAgD,EAChDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAOD,KAAK,CAACE,EAAE;EACnB;EACA,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKR,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACE,KAAK,EAAE;IACR,OAAOH,KAAK,CAACE,EAAE;EACnB;EACA,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAAO;EAClC,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAACR,YAAY,CAAC;EAC7C,IAAI,CAACO,UAAU,EAAE;IACb,OAAOR,KAAK,CAACE,EAAE;EACnB;EAEA,MAAM;IAAEQ,OAAO,GAAG,KAAK;IAAED;EAAO,CAAC,GAAGN,KAAK,CAACQ,gBAAgB,IAAI,CAAC,CAAC;EAChE,IAAI,CAACD,OAAO,IAAI,CAACD,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,KAAK,KAAK,EAAE;IACxD,OAAOD,UAAU;EACrB;EACA,KAAK,MAAMM,KAAK,IAAIL,MAAM,EAAE;IACxB;IACA,IAAIK,KAAK,CAACA,KAAK,IAAIN,UAAU,EAAE;MAC3B,OAAOM,KAAK,CAACC,KAAK;IACtB;EACJ;EACA,OAAOP,UAAU;AACrB"}
@@ -1,12 +1,9 @@
1
- import { CmsModel, CmsContext, CmsFieldTypePlugins, ApiEndpoint } from "../types";
2
- import { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types";
3
- interface RenderTypesFromFieldPluginsParams {
1
+ import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from "../types";
2
+ import { CmsGraphQLSchemaPlugin } from "../plugins";
3
+ interface Params {
4
4
  models: CmsModel[];
5
5
  fieldTypePlugins: CmsFieldTypePlugins;
6
6
  type: ApiEndpoint;
7
7
  }
8
- interface RenderTypesFromFieldPlugins {
9
- (params: RenderTypesFromFieldPluginsParams): GraphQLSchemaDefinition<CmsContext>[];
10
- }
11
- export declare const getSchemaFromFieldPlugins: RenderTypesFromFieldPlugins;
8
+ export declare const createGraphQLSchemaPluginFromFieldPlugins: (params: Params) => CmsGraphQLSchemaPlugin<import("../types").CmsContext>[];
12
9
  export {};
@@ -3,29 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getSchemaFromFieldPlugins = void 0;
6
+ exports.createGraphQLSchemaPluginFromFieldPlugins = void 0;
7
+ var _plugins = require("../plugins");
7
8
  const TYPE_MAP = {
8
9
  preview: "read",
9
10
  read: "read",
10
11
  manage: "manage"
11
12
  };
12
- const getSchemaFromFieldPlugins = ({
13
- models,
14
- fieldTypePlugins,
15
- type
16
- }) => {
17
- return Object.values(fieldTypePlugins).map(plugin => {
18
- if (!TYPE_MAP[type] || !plugin[TYPE_MAP[type]]) {
19
- return null;
13
+ const createGraphQLSchemaPluginFromFieldPlugins = params => {
14
+ const {
15
+ models,
16
+ fieldTypePlugins,
17
+ type
18
+ } = params;
19
+ const plugins = [];
20
+ for (const key in fieldTypePlugins) {
21
+ const fieldTypePlugin = fieldTypePlugins[key];
22
+ if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {
23
+ continue;
20
24
  }
21
- const createSchema = plugin[TYPE_MAP[type]].createSchema;
25
+ const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema;
22
26
  // Render gql types generated by field type plugins
23
27
  if (!createSchema) {
24
- return null;
28
+ continue;
25
29
  }
26
- return createSchema({
30
+ const schema = createSchema({
27
31
  models
28
32
  });
29
- }).filter(Boolean);
33
+ const plugin = new _plugins.CmsGraphQLSchemaPlugin(schema);
34
+ plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;
35
+ plugins.push(plugin);
36
+ }
37
+ return plugins;
30
38
  };
31
- exports.getSchemaFromFieldPlugins = getSchemaFromFieldPlugins;
39
+ exports.createGraphQLSchemaPluginFromFieldPlugins = createGraphQLSchemaPluginFromFieldPlugins;
@@ -1 +1 @@
1
- {"version":3,"names":["TYPE_MAP","preview","read","manage","getSchemaFromFieldPlugins","models","fieldTypePlugins","type","Object","values","map","plugin","createSchema","filter","Boolean"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import { CmsModel, CmsContext, CmsFieldTypePlugins, ApiEndpoint } from \"~/types\";\nimport { GraphQLSchemaDefinition } from \"@webiny/handler-graphql/types\";\n\ninterface RenderTypesFromFieldPluginsParams {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n}\ninterface RenderTypesFromFieldPlugins {\n (params: RenderTypesFromFieldPluginsParams): GraphQLSchemaDefinition<CmsContext>[];\n}\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\nexport const getSchemaFromFieldPlugins: RenderTypesFromFieldPlugins = ({\n models,\n fieldTypePlugins,\n type\n}) => {\n return Object.values(fieldTypePlugins)\n .map(plugin => {\n if (!TYPE_MAP[type] || !plugin[TYPE_MAP[type]]) {\n return null;\n }\n const createSchema = plugin[TYPE_MAP[type]].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n return null;\n }\n return createSchema({ models });\n })\n .filter(Boolean) as GraphQLSchemaDefinition<CmsContext>[];\n};\n"],"mappings":";;;;;;AAYA,MAAMA,QAA2C,GAAG;EAChDC,OAAO,EAAE,MAAM;EACfC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC;AAEM,MAAMC,yBAAsD,GAAG,CAAC;EACnEC,MAAM;EACNC,gBAAgB;EAChBC;AACJ,CAAC,KAAK;EACF,OAAOC,MAAM,CAACC,MAAM,CAACH,gBAAgB,CAAC,CACjCI,GAAG,CAACC,MAAM,IAAI;IACX,IAAI,CAACX,QAAQ,CAACO,IAAI,CAAC,IAAI,CAACI,MAAM,CAACX,QAAQ,CAACO,IAAI,CAAC,CAAC,EAAE;MAC5C,OAAO,IAAI;IACf;IACA,MAAMK,YAAY,GAAGD,MAAM,CAACX,QAAQ,CAACO,IAAI,CAAC,CAAC,CAACK,YAAY;IACxD;IACA,IAAI,CAACA,YAAY,EAAE;MACf,OAAO,IAAI;IACf;IACA,OAAOA,YAAY,CAAC;MAAEP;IAAO,CAAC,CAAC;EACnC,CAAC,CAAC,CACDQ,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAAC"}
1
+ {"version":3,"names":["TYPE_MAP","preview","read","manage","createGraphQLSchemaPluginFromFieldPlugins","params","models","fieldTypePlugins","type","plugins","key","fieldTypePlugin","createSchema","schema","plugin","CmsGraphQLSchemaPlugin","name","fieldType","push"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\ninterface Params {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n}\nexport const createGraphQLSchemaPluginFromFieldPlugins = (params: Params) => {\n const { models, fieldTypePlugins, type } = params;\n\n const plugins: CmsGraphQLSchemaPlugin[] = [];\n for (const key in fieldTypePlugins) {\n const fieldTypePlugin = fieldTypePlugins[key];\n if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {\n continue;\n }\n const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n continue;\n }\n const schema = createSchema({ models });\n\n const plugin = new CmsGraphQLSchemaPlugin(schema);\n plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;\n plugins.push(plugin);\n }\n return plugins;\n};\n"],"mappings":";;;;;;AACA;AAEA,MAAMA,QAA2C,GAAG;EAChDC,OAAO,EAAE,MAAM;EACfC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC;AAOM,MAAMC,yCAAyC,GAAIC,MAAc,IAAK;EACzE,MAAM;IAAEC,MAAM;IAAEC,gBAAgB;IAAEC;EAAK,CAAC,GAAGH,MAAM;EAEjD,MAAMI,OAAiC,GAAG,EAAE;EAC5C,KAAK,MAAMC,GAAG,IAAIH,gBAAgB,EAAE;IAChC,MAAMI,eAAe,GAAGJ,gBAAgB,CAACG,GAAG,CAAC;IAC7C,IAAI,CAACV,QAAQ,CAACQ,IAAI,CAAC,IAAI,CAACG,eAAe,CAACX,QAAQ,CAACQ,IAAI,CAAC,CAAC,EAAE;MACrD;IACJ;IACA,MAAMI,YAAY,GAAGD,eAAe,CAACX,QAAQ,CAACQ,IAAI,CAAC,CAAC,CAACI,YAAY;IACjE;IACA,IAAI,CAACA,YAAY,EAAE;MACf;IACJ;IACA,MAAMC,MAAM,GAAGD,YAAY,CAAC;MAAEN;IAAO,CAAC,CAAC;IAEvC,MAAMQ,MAAM,GAAG,IAAIC,+BAAsB,CAACF,MAAM,CAAC;IACjDC,MAAM,CAACE,IAAI,GAAI,+BAA8BR,IAAK,UAASG,eAAe,CAACM,SAAU,EAAC;IACtFR,OAAO,CAACS,IAAI,CAACJ,MAAM,CAAC;EACxB;EACA,OAAOL,OAAO;AAClB,CAAC;AAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const incrementEntryIdVersion: (id: string) => {
2
+ entryId: string;
3
+ version: number;
4
+ id: string;
5
+ };