@webiny/api-headless-cms 0.0.0-unstable.bca7b3e350 → 0.0.0-unstable.c59b9cc5b9

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 (215) hide show
  1. package/context.js +47 -43
  2. package/context.js.map +1 -1
  3. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  4. package/crud/contentEntry/markLockedFields.js +3 -0
  5. package/crud/contentEntry/markLockedFields.js.map +1 -1
  6. package/crud/contentEntry/referenceFieldsMapping.js +34 -5
  7. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  8. package/crud/contentEntry.crud.d.ts +8 -5
  9. package/crud/contentEntry.crud.js +1023 -840
  10. package/crud/contentEntry.crud.js.map +1 -1
  11. package/crud/contentModel/beforeCreate.js +39 -76
  12. package/crud/contentModel/beforeCreate.js.map +1 -1
  13. package/crud/contentModel/beforeDelete.d.ts +1 -1
  14. package/crud/contentModel/beforeDelete.js +1 -5
  15. package/crud/contentModel/beforeDelete.js.map +1 -1
  16. package/crud/contentModel/beforeUpdate.js +31 -3
  17. package/crud/contentModel/beforeUpdate.js.map +1 -1
  18. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  19. package/crud/contentModel/compatibility/modelApiName.js +24 -0
  20. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  21. package/crud/contentModel/defaultFields.d.ts +5 -0
  22. package/crud/contentModel/defaultFields.js +58 -0
  23. package/crud/contentModel/defaultFields.js.map +1 -0
  24. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  25. package/crud/contentModel/fields/descriptionField.js +42 -0
  26. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  27. package/crud/contentModel/fields/imageField.d.ts +2 -0
  28. package/crud/contentModel/fields/imageField.js +46 -0
  29. package/crud/contentModel/fields/imageField.js.map +1 -0
  30. package/crud/contentModel/fields/titleField.d.ts +2 -0
  31. package/crud/contentModel/fields/titleField.js +58 -0
  32. package/crud/contentModel/fields/titleField.js.map +1 -0
  33. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  34. package/crud/contentModel/validate/endingAllowed.js +26 -0
  35. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  36. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  37. package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
  38. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  39. package/crud/contentModel/validate/modelId.d.ts +11 -0
  40. package/crud/contentModel/validate/modelId.js +36 -0
  41. package/crud/contentModel/validate/modelId.js.map +1 -0
  42. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  43. package/crud/contentModel/validate/pluralApiName.js +24 -0
  44. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  45. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  46. package/crud/contentModel/validate/singularApiName.js +24 -0
  47. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  48. package/crud/contentModel/validateModel.d.ts +1 -0
  49. package/crud/contentModel/validateModel.js.map +1 -1
  50. package/crud/contentModel/validateModelFields.d.ts +2 -1
  51. package/crud/contentModel/validateModelFields.js +19 -57
  52. package/crud/contentModel/validateModelFields.js.map +1 -1
  53. package/crud/contentModel/validation.d.ts +136 -62
  54. package/crud/contentModel/validation.js +61 -13
  55. package/crud/contentModel/validation.js.map +1 -1
  56. package/crud/contentModel.crud.js +346 -285
  57. package/crud/contentModel.crud.js.map +1 -1
  58. package/crud/contentModelGroup.crud.js +170 -148
  59. package/crud/contentModelGroup.crud.js.map +1 -1
  60. package/crud/settings.crud.d.ts +1 -1
  61. package/crud/settings.crud.js +5 -10
  62. package/crud/settings.crud.js.map +1 -1
  63. package/crud/system.crud.js +0 -60
  64. package/crud/system.crud.js.map +1 -1
  65. package/graphql/checkEndpointAccess.d.ts +2 -0
  66. package/graphql/checkEndpointAccess.js +18 -0
  67. package/graphql/checkEndpointAccess.js.map +1 -0
  68. package/graphql/createExecutableSchema.d.ts +2 -3
  69. package/graphql/createExecutableSchema.js.map +1 -1
  70. package/graphql/createRequestBody.d.ts +2 -0
  71. package/graphql/createRequestBody.js +14 -0
  72. package/graphql/createRequestBody.js.map +1 -0
  73. package/graphql/formatErrorPayload.d.ts +1 -0
  74. package/graphql/formatErrorPayload.js +25 -0
  75. package/graphql/formatErrorPayload.js.map +1 -0
  76. package/graphql/generateSchema.js.map +1 -1
  77. package/graphql/getSchema.d.ts +17 -0
  78. package/graphql/getSchema.js +102 -0
  79. package/graphql/getSchema.js.map +1 -0
  80. package/graphql/graphQLHandlerFactory.js +6 -145
  81. package/graphql/graphQLHandlerFactory.js.map +1 -1
  82. package/graphql/handleRequest.d.ts +11 -0
  83. package/graphql/handleRequest.js +81 -0
  84. package/graphql/handleRequest.js.map +1 -0
  85. package/graphql/schema/baseContentSchema.js +1 -7
  86. package/graphql/schema/baseContentSchema.js.map +1 -1
  87. package/graphql/schema/baseSchema.js +15 -0
  88. package/graphql/schema/baseSchema.js.map +1 -1
  89. package/graphql/schema/contentEntries.js +90 -53
  90. package/graphql/schema/contentEntries.js.map +1 -1
  91. package/graphql/schema/contentModelGroups.js +7 -7
  92. package/graphql/schema/contentModelGroups.js.map +1 -1
  93. package/graphql/schema/contentModels.js +23 -4
  94. package/graphql/schema/contentModels.js.map +1 -1
  95. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  96. package/graphql/schema/createFieldResolvers.js +6 -12
  97. package/graphql/schema/createFieldResolvers.js.map +1 -1
  98. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  99. package/graphql/schema/createFieldTypePluginRecords.js +13 -0
  100. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  101. package/graphql/schema/createManageResolvers.d.ts +1 -1
  102. package/graphql/schema/createManageResolvers.js +37 -17
  103. package/graphql/schema/createManageResolvers.js.map +1 -1
  104. package/graphql/schema/createManageSDL.d.ts +1 -0
  105. package/graphql/schema/createManageSDL.js +76 -62
  106. package/graphql/schema/createManageSDL.js.map +1 -1
  107. package/graphql/schema/createPreviewResolvers.js +3 -7
  108. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  109. package/graphql/schema/createReadResolvers.js +4 -8
  110. package/graphql/schema/createReadResolvers.js.map +1 -1
  111. package/graphql/schema/createReadSDL.d.ts +1 -0
  112. package/graphql/schema/createReadSDL.js +40 -35
  113. package/graphql/schema/createReadSDL.js.map +1 -1
  114. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
  115. package/graphql/schema/resolvers/commonFieldResolvers.js +2 -1
  116. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
  117. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  118. package/graphql/schema/resolvers/manage/resolveDelete.js +13 -3
  119. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  120. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  121. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
  122. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  123. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  124. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
  125. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  126. package/graphql/schema/schemaPlugins.js +7 -16
  127. package/graphql/schema/schemaPlugins.js.map +1 -1
  128. package/graphql/system.js +0 -16
  129. package/graphql/system.js.map +1 -1
  130. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  131. package/graphqlFields/dynamicZone/dynamicZoneField.js +54 -19
  132. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  133. package/graphqlFields/object.js +21 -2
  134. package/graphqlFields/object.js.map +1 -1
  135. package/graphqlFields/ref.js +42 -14
  136. package/graphqlFields/ref.js.map +1 -1
  137. package/index.d.ts +3 -1
  138. package/index.js +25 -2
  139. package/index.js.map +1 -1
  140. package/package.json +35 -36
  141. package/plugins/CmsModelPlugin.d.ts +21 -3
  142. package/plugins/CmsModelPlugin.js +28 -2
  143. package/plugins/CmsModelPlugin.js.map +1 -1
  144. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  145. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  146. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  147. package/plugins/index.d.ts +1 -0
  148. package/plugins/index.js +11 -0
  149. package/plugins/index.js.map +1 -1
  150. package/types.d.ts +200 -97
  151. package/types.js +12 -1
  152. package/types.js.map +1 -1
  153. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  154. package/utils/converters/valueKeyStorageConverter.js +26 -20
  155. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  156. package/utils/createTypeFromFields.d.ts +1 -0
  157. package/utils/createTypeFromFields.js +7 -5
  158. package/utils/createTypeFromFields.js.map +1 -1
  159. package/utils/createTypeName.d.ts +0 -2
  160. package/utils/createTypeName.js +2 -10
  161. package/utils/createTypeName.js.map +1 -1
  162. package/utils/getBaseFieldType.d.ts +1 -3
  163. package/utils/getBaseFieldType.js.map +1 -1
  164. package/utils/getEntryDescription.d.ts +2 -0
  165. package/utils/getEntryDescription.js +17 -0
  166. package/utils/getEntryDescription.js.map +1 -0
  167. package/utils/getEntryImage.d.ts +2 -0
  168. package/utils/getEntryImage.js +17 -0
  169. package/utils/getEntryImage.js.map +1 -0
  170. package/utils/getEntryTitle.d.ts +1 -1
  171. package/utils/getEntryTitle.js.map +1 -1
  172. package/utils/incrementEntryIdVersion.d.ts +5 -0
  173. package/utils/incrementEntryIdVersion.js +29 -0
  174. package/utils/incrementEntryIdVersion.js.map +1 -0
  175. package/utils/ownership.d.ts +3 -3
  176. package/utils/ownership.js.map +1 -1
  177. package/utils/renderFields.d.ts +4 -2
  178. package/utils/renderFields.js +10 -2
  179. package/utils/renderFields.js.map +1 -1
  180. package/utils/renderGetFilterFields.d.ts +2 -2
  181. package/utils/renderGetFilterFields.js +7 -20
  182. package/utils/renderGetFilterFields.js.map +1 -1
  183. package/utils/renderInputFields.d.ts +4 -2
  184. package/utils/renderInputFields.js +17 -5
  185. package/utils/renderInputFields.js.map +1 -1
  186. package/utils/renderListFilterFields.d.ts +2 -1
  187. package/utils/renderListFilterFields.js +9 -20
  188. package/utils/renderListFilterFields.js.map +1 -1
  189. package/utils/renderSortEnum.d.ts +2 -1
  190. package/utils/renderSortEnum.js +2 -1
  191. package/utils/renderSortEnum.js.map +1 -1
  192. package/crud/contentModel/createFieldModels.d.ts +0 -2
  193. package/crud/contentModel/createFieldModels.js +0 -26
  194. package/crud/contentModel/createFieldModels.js.map +0 -1
  195. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  196. package/crud/contentModel/fieldIdValidation.js +0 -25
  197. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  198. package/crud/contentModel/idValidation.d.ts +0 -1
  199. package/crud/contentModel/idValidation.js +0 -22
  200. package/crud/contentModel/idValidation.js.map +0 -1
  201. package/crud/contentModel/models.d.ts +0 -4
  202. package/crud/contentModel/models.js +0 -192
  203. package/crud/contentModel/models.js.map +0 -1
  204. package/crud/contentModel/systemFields.d.ts +0 -1
  205. package/crud/contentModel/systemFields.js +0 -8
  206. package/crud/contentModel/systemFields.js.map +0 -1
  207. package/upgrades/5.33.0/index.d.ts +0 -3
  208. package/upgrades/5.33.0/index.js +0 -159
  209. package/upgrades/5.33.0/index.js.map +0 -1
  210. package/upgrades/index.d.ts +0 -1
  211. package/upgrades/index.js +0 -9
  212. package/upgrades/index.js.map +0 -1
  213. package/utils/pluralizedTypeName.d.ts +0 -1
  214. package/utils/pluralizedTypeName.js +0 -20
  215. package/utils/pluralizedTypeName.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["createTypeFromFields","params","typeOfType","model","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","createTypeName","modelId","typeFields","nestedTypes","replace","RegExp","f","result","renderField","field","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 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, type, typeNamePrefix, fields, fieldTypePlugins } = params;\n const typeSuffix = typeOfType === \"input\" ? \"Input\" : \"\";\n const mTypeName = createTypeName(model.modelId);\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 f of fields) {\n const result =\n typeOfType === \"type\"\n ? renderField({ field: f, type, model, fieldTypePlugins })\n : renderInputField({ field: f, 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;AAiBO,MAAMA,oBAAoB,GAAIC,MAA2B,IAAmC;EAC/F,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC,IAAI;IAAEC,cAAc;IAAEC,MAAM;IAAEC;EAAiB,CAAC,GAAGN,MAAM;EACpF,MAAMO,UAAU,GAAGN,UAAU,KAAK,OAAO,GAAG,OAAO,GAAG,EAAE;EACxD,MAAMO,SAAS,GAAG,IAAAC,8BAAc,EAACP,KAAK,CAACQ,OAAO,CAAC;EAE/C,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,CAAC,IAAIV,MAAM,EAAE;IACpB,MAAMW,MAAM,GACRf,UAAU,KAAK,MAAM,GACf,IAAAgB,yBAAW,EAAC;MAAEC,KAAK,EAAEH,CAAC;MAAEZ,IAAI;MAAED,KAAK;MAAEI;IAAiB,CAAC,CAAC,GACxD,IAAAa,mCAAgB,EAAC;MAAED,KAAK,EAAEH,CAAC;MAAEb,KAAK;MAAEI;IAAiB,CAAC,CAAC;IAEjE,IAAI,CAACU,MAAM,EAAE;MACT;IACJ;IAEA,MAAM;MAAEX,MAAM;MAAEe;IAAS,CAAC,GAAGJ,MAAM;IAEnCL,UAAU,CAACU,IAAI,CAAChB,MAAM,CAACQ,OAAO,CAACA,OAAO,EAAG,GAAET,cAAe,GAAE,CAAC,CAAC;IAC9D,IAAIgB,QAAQ,EAAE;MACVR,WAAW,CAACS,IAAI,CAACD,QAAQ,CAACP,OAAO,CAACA,OAAO,EAAG,GAAET,cAAe,GAAE,CAAC,CAAC;IACrE;EACJ;EAEA,OAAO;IACHkB,SAAS,EAAG,GAAElB,cAAe,GAAEG,UAAW,EAAC;IAC3Ca,QAAQ,EAAE,aAAe;AACjC,cAAcR,WAAW,CAACW,IAAI,CAAC,IAAI,CAAE;AACrC;AACA,cAActB,UAAW,IAAGG,cAAe,GAAEG,UAAW;AACxD,kBAAkBI,UAAU,CAACY,IAAI,CAAC,IAAI,CAAE;AACxC;AACA;EACI,CAAC;AACL,CAAC;AAAC"}
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,IAAI;IAAEC,cAAc;IAAEC,MAAM;IAAEC;EAAiB,CAAC,GAAGP,MAAM;EAC5F,MAAMQ,UAAU,GAAGP,UAAU,KAAK,OAAO,GAAG,OAAO,GAAG,EAAE;EACxD,MAAMQ,SAAS,GAAGP,KAAK,CAACQ,eAAe;EAEvC,MAAMC,UAAoB,GAAG,EAAE;EAC/B,MAAMC,WAAqB,GAAG,EAAE;;EAEhC;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAG,IAAIC,MAAM,CAAE,GAAEL,SAAU,GAAE,EAAE,GAAG,CAAC;EAEhD,KAAK,MAAMM,KAAK,IAAIT,MAAM,EAAE;IACxB,MAAMU,MAAM,GACRf,UAAU,KAAK,MAAM,GACf,IAAAgB,yBAAW,EAAC;MAAEF,KAAK;MAAEX,IAAI;MAAED,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC,GAC7D,IAAAW,mCAAgB,EAAC;MAAEH,KAAK;MAAEZ,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC;IAEtE,IAAI,CAACS,MAAM,EAAE;MACT;IACJ;IAEA,MAAM;MAAEV,MAAM;MAAEa;IAAS,CAAC,GAAGH,MAAM;IAEnCL,UAAU,CAACS,IAAI,CAACd,MAAM,CAACO,OAAO,CAACA,OAAO,EAAG,GAAER,cAAe,GAAE,CAAC,CAAC;IAC9D,IAAIc,QAAQ,EAAE;MACVP,WAAW,CAACQ,IAAI,CAACD,QAAQ,CAACN,OAAO,CAACA,OAAO,EAAG,GAAER,cAAe,GAAE,CAAC,CAAC;IACrE;EACJ;EAEA,OAAO;IACHgB,SAAS,EAAG,GAAEhB,cAAe,GAAEG,UAAW,EAAC;IAC3CW,QAAQ,EAAE,aAAe;AACjC,cAAcP,WAAW,CAACU,IAAI,CAAC,IAAI,CAAE;AACrC;AACA,cAAcrB,UAAW,IAAGI,cAAe,GAAEG,UAAW;AACxD,kBAAkBG,UAAU,CAACW,IAAI,CAAC,IAAI,CAAE;AACxC;AACA;EACI,CAAC;AACL,CAAC;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,18 +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
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
- 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;
13
+ exports.createTypeName = createTypeName;
@@ -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":["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"}
@@ -1,4 +1,2 @@
1
1
  import { CmsModelField } from "../types";
2
- export declare const getBaseFieldType: (field: {
3
- type: CmsModelField["type"];
4
- }) => string;
2
+ export declare const getBaseFieldType: (field: Pick<CmsModelField, "type">) => string;
@@ -1 +1 @@
1
- {"version":3,"names":["getBaseFieldType","field","type","split"],"sources":["getBaseFieldType.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\n\nexport const getBaseFieldType = (field: { type: CmsModelField[\"type\"] }) => {\n return field.type.split(\":\")[0];\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAIC,KAAsC,IAAK;EACxE,OAAOA,KAAK,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAAC"}
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"}
@@ -0,0 +1,5 @@
1
+ export declare const incrementEntryIdVersion: (id: string) => {
2
+ entryId: string;
3
+ version: number;
4
+ id: string;
5
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.incrementEntryIdVersion = void 0;
8
+ var _utils = require("@webiny/utils");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const incrementEntryIdVersion = id => {
11
+ const {
12
+ id: entryId,
13
+ version
14
+ } = (0, _utils.parseIdentifier)(id);
15
+ if (!version) {
16
+ throw new _error.default("Cannot increase version on the ID without the version part.", "WRONG_ID", {
17
+ id
18
+ });
19
+ }
20
+ return {
21
+ entryId,
22
+ version: version + 1,
23
+ id: (0, _utils.createIdentifier)({
24
+ id: entryId,
25
+ version: version + 1
26
+ })
27
+ };
28
+ };
29
+ exports.incrementEntryIdVersion = incrementEntryIdVersion;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["incrementEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier"],"sources":["incrementEntryIdVersion.ts"],"sourcesContent":["import { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\n\nexport const incrementEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,uBAAuB,GAAIC,EAAU,IAAK;EACnD,MAAM;IAAEA,EAAE,EAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACH,EAAE,CAAC;EACpD,IAAI,CAACE,OAAO,EAAE;IACV,MAAM,IAAIE,cAAW,CACjB,6DAA6D,EAC7D,UAAU,EACV;MACIJ;IACJ,CAAC,CACJ;EACL;EACA,OAAO;IACHC,OAAO;IACPC,OAAO,EAAEA,OAAO,GAAG,CAAC;IACpBF,EAAE,EAAE,IAAAK,uBAAgB,EAAC;MACjBL,EAAE,EAAEC,OAAO;MACXC,OAAO,EAAEA,OAAO,GAAG;IACvB,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
@@ -1,7 +1,7 @@
1
- import { BaseCmsSecurityPermission, CmsContext, CreatedBy } from "../types";
1
+ import { BaseCmsSecurityPermission, CmsContext, CmsIdentity } from "../types";
2
2
  interface OwnableRecord {
3
- createdBy?: CreatedBy;
4
- ownedBy?: CreatedBy;
3
+ createdBy?: CmsIdentity;
4
+ ownedBy?: CmsIdentity;
5
5
  }
6
6
  export declare const checkOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => void;
7
7
  export declare const validateOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => boolean;
@@ -1 +1 @@
1
- {"version":3,"names":["checkOwnership","context","permission","record","own","identity","security","getIdentity","owner","ownedBy","id","creator","createdBy","NotAuthorizedError","data","reason","validateOwnership"],"sources":["ownership.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CreatedBy } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\ninterface OwnableRecord {\n createdBy?: CreatedBy;\n ownedBy?: CreatedBy;\n}\n\nexport const checkOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): void => {\n if (!permission.own) {\n return;\n }\n\n const identity = context.security.getIdentity();\n const owner = identity && record.ownedBy?.id === identity.id;\n const creator = identity && record.createdBy?.id === identity.id;\n\n if (!owner && !creator) {\n throw new NotAuthorizedError({\n data: {\n reason: `You are not the owner of the record.`\n }\n });\n }\n};\n\nexport const validateOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): boolean => {\n try {\n checkOwnership(context, permission, record);\n return true;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;AACA;AAOO,MAAMA,cAAc,GAAG,CAC1BC,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACd;EAAA;EACP,IAAI,CAACD,UAAU,CAACE,GAAG,EAAE;IACjB;EACJ;EAEA,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,QAAQ,CAACC,WAAW,EAAE;EAC/C,MAAMC,KAAK,GAAGH,QAAQ,IAAI,oBAAAF,MAAM,CAACM,OAAO,oDAAd,gBAAgBC,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAC5D,MAAMC,OAAO,GAAGN,QAAQ,IAAI,sBAAAF,MAAM,CAACS,SAAS,sDAAhB,kBAAkBF,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAEhE,IAAI,CAACF,KAAK,IAAI,CAACG,OAAO,EAAE;IACpB,MAAM,IAAIE,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG;MACb;IACJ,CAAC,CAAC;EACN;AACJ,CAAC;AAAC;AAEK,MAAMC,iBAAiB,GAAG,CAC7Bf,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACX;EACV,IAAI;IACAH,cAAc,CAACC,OAAO,EAAEC,UAAU,EAAEC,MAAM,CAAC;IAC3C,OAAO,IAAI;EACf,CAAC,CAAC,MAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["checkOwnership","context","permission","record","own","identity","security","getIdentity","owner","ownedBy","id","creator","createdBy","NotAuthorizedError","data","reason","validateOwnership"],"sources":["ownership.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CmsIdentity } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\ninterface OwnableRecord {\n createdBy?: CmsIdentity;\n ownedBy?: CmsIdentity;\n}\n\nexport const checkOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): void => {\n if (!permission.own) {\n return;\n }\n\n const identity = context.security.getIdentity();\n const owner = identity && record.ownedBy?.id === identity.id;\n const creator = identity && record.createdBy?.id === identity.id;\n\n if (!owner && !creator) {\n throw new NotAuthorizedError({\n data: {\n reason: `You are not the owner of the record.`\n }\n });\n }\n};\n\nexport const validateOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): boolean => {\n try {\n checkOwnership(context, permission, record);\n return true;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;AACA;AAOO,MAAMA,cAAc,GAAG,CAC1BC,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACd;EAAA;EACP,IAAI,CAACD,UAAU,CAACE,GAAG,EAAE;IACjB;EACJ;EAEA,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,QAAQ,CAACC,WAAW,EAAE;EAC/C,MAAMC,KAAK,GAAGH,QAAQ,IAAI,oBAAAF,MAAM,CAACM,OAAO,oDAAd,gBAAgBC,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAC5D,MAAMC,OAAO,GAAGN,QAAQ,IAAI,sBAAAF,MAAM,CAACS,SAAS,sDAAhB,kBAAkBF,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAEhE,IAAI,CAACF,KAAK,IAAI,CAACG,OAAO,EAAE;IACpB,MAAM,IAAIE,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG;MACb;IACJ,CAAC,CAAC;EACN;AACJ,CAAC;AAAC;AAEK,MAAMC,iBAAiB,GAAG,CAC7Bf,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACX;EACV,IAAI;IACAH,cAAc,CAACC,OAAO,EAAEC,UAAU,EAAEC,MAAM,CAAC;IAC3C,OAAO,IAAI;EACf,CAAC,CAAC,MAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC;AAAC"}
@@ -1,6 +1,8 @@
1
1
  import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
2
2
  interface RenderFieldsParams {
3
+ models: CmsModel[];
3
4
  model: CmsModel;
5
+ fields: CmsModelField[];
4
6
  type: ApiEndpoint;
5
7
  fieldTypePlugins: CmsFieldTypePlugins;
6
8
  }
@@ -8,8 +10,8 @@ interface RenderFields {
8
10
  (params: RenderFieldsParams): CmsModelFieldDefinition[];
9
11
  }
10
12
  export declare const renderFields: RenderFields;
11
- interface RenderFieldParams extends RenderFieldsParams {
13
+ interface RenderFieldParams extends Omit<RenderFieldsParams, "fields"> {
12
14
  field: CmsModelField;
13
15
  }
14
- export declare const renderField: ({ model, type, field, fieldTypePlugins }: RenderFieldParams) => CmsModelFieldDefinition | null;
16
+ export declare const renderField: ({ models, model, type, field, fieldTypePlugins }: RenderFieldParams) => CmsModelFieldDefinition | null;
15
17
  export {};
@@ -6,11 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.renderFields = exports.renderField = void 0;
7
7
  var _getBaseFieldType = require("./getBaseFieldType");
8
8
  const renderFields = ({
9
+ models,
9
10
  model,
11
+ fields,
10
12
  type,
11
13
  fieldTypePlugins
12
14
  }) => {
13
- return model.fields.map(field => renderField({
15
+ return fields.map(field => renderField({
16
+ models,
14
17
  model,
15
18
  type,
16
19
  field,
@@ -19,6 +22,7 @@ const renderFields = ({
19
22
  };
20
23
  exports.renderFields = renderFields;
21
24
  const renderField = ({
25
+ models,
22
26
  model,
23
27
  type,
24
28
  field,
@@ -29,7 +33,11 @@ const renderField = ({
29
33
  // Let's not render the field if it does not exist in the field plugins.
30
34
  return null;
31
35
  }
32
- const defs = plugin[type].createTypeField({
36
+ const {
37
+ createTypeField
38
+ } = plugin[type];
39
+ const defs = createTypeField({
40
+ models,
33
41
  model,
34
42
  field,
35
43
  fieldTypePlugins
@@ -1 +1 @@
1
- {"version":3,"names":["renderFields","model","type","fieldTypePlugins","fields","map","field","renderField","filter","Boolean","plugin","getBaseFieldType","defs","createTypeField"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderFieldsParams {\n model: CmsModel;\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderFields {\n (params: RenderFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderFields: RenderFields = ({\n model,\n type,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return model.fields\n .map(field => renderField({ model, type, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\ninterface RenderFieldParams extends RenderFieldsParams {\n field: CmsModelField;\n}\n\nexport const renderField = ({\n model,\n type,\n field,\n fieldTypePlugins\n}: RenderFieldParams): CmsModelFieldDefinition | null => {\n const plugin: CmsModelFieldToGraphQLPlugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n const defs = plugin[type].createTypeField({\n model,\n field,\n fieldTypePlugins\n });\n\n if (!defs) {\n return null;\n } else if (typeof defs === \"string\") {\n return {\n fields: defs\n };\n }\n\n return defs;\n};\n"],"mappings":";;;;;;AAQA;AAWO,MAAMA,YAA0B,GAAG,CAAC;EACvCC,KAAK;EACLC,IAAI;EACJC;AACJ,CAAC,KAAgC;EAC7B,OAAOF,KAAK,CAACG,MAAM,CACdC,GAAG,CAACC,KAAK,IAAIC,WAAW,CAAC;IAAEN,KAAK;IAAEC,IAAI;IAAEI,KAAK;IAAEH;EAAiB,CAAC,CAAC,CAAC,CACnEK,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAAC;AAMK,MAAMF,WAAW,GAAG,CAAC;EACxBN,KAAK;EACLC,IAAI;EACJI,KAAK;EACLH;AACe,CAAC,KAAqC;EACrD,MAAMO,MAAoC,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACL,KAAK,CAAC,CAAC;EACtF,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EACA,MAAME,IAAI,GAAGF,MAAM,CAACR,IAAI,CAAC,CAACW,eAAe,CAAC;IACtCZ,KAAK;IACLK,KAAK;IACLH;EACJ,CAAC,CAAC;EAEF,IAAI,CAACS,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACjC,OAAO;MACHR,MAAM,EAAEQ;IACZ,CAAC;EACL;EAEA,OAAOA,IAAI;AACf,CAAC;AAAC"}
1
+ {"version":3,"names":["renderFields","models","model","fields","type","fieldTypePlugins","map","field","renderField","filter","Boolean","plugin","getBaseFieldType","createTypeField","defs"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fields: CmsModelField[];\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderFields {\n (params: RenderFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderFields: RenderFields = ({\n models,\n model,\n fields,\n type,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return fields\n .map(field => renderField({ models, model, type, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\ninterface RenderFieldParams extends Omit<RenderFieldsParams, \"fields\"> {\n field: CmsModelField;\n}\n\nexport const renderField = ({\n models,\n model,\n type,\n field,\n fieldTypePlugins\n}: RenderFieldParams): CmsModelFieldDefinition | null => {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n const { createTypeField } = plugin[type] as CmsModelFieldToGraphQLPlugin[\"manage\"];\n const defs = createTypeField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n\n if (!defs) {\n return null;\n } else if (typeof defs === \"string\") {\n return {\n fields: defs\n };\n }\n\n return defs;\n};\n"],"mappings":";;;;;;AAQA;AAcO,MAAMA,YAA0B,GAAG,CAAC;EACvCC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,IAAI;EACJC;AACJ,CAAC,KAAgC;EAC7B,OAAOF,MAAM,CACRG,GAAG,CAACC,KAAK,IAAIC,WAAW,CAAC;IAAEP,MAAM;IAAEC,KAAK;IAAEE,IAAI;IAAEG,KAAK;IAAEF;EAAiB,CAAC,CAAC,CAAC,CAC3EI,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAAC;AAMK,MAAMF,WAAW,GAAG,CAAC;EACxBP,MAAM;EACNC,KAAK;EACLE,IAAI;EACJG,KAAK;EACLF;AACe,CAAC,KAAqC;EACrD,MAAMM,MAAM,GAAGN,gBAAgB,CAAC,IAAAO,kCAAgB,EAACL,KAAK,CAAC,CAAC;EACxD,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EACA,MAAM;IAAEE;EAAgB,CAAC,GAAGF,MAAM,CAACP,IAAI,CAA2C;EAClF,MAAMU,IAAI,GAAGD,eAAe,CAAC;IACzBZ,MAAM;IACNC,KAAK;IACLK,KAAK;IACLF;EACJ,CAAC,CAAC;EAEF,IAAI,CAACS,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACjC,OAAO;MACHX,MAAM,EAAEW;IACZ,CAAC;EACL;EAEA,OAAOA,IAAI;AACf,CAAC;AAAC"}
@@ -1,6 +1,6 @@
1
- import { CmsFieldTypePlugins, CmsModel } from "../types";
1
+ import { CmsFieldTypePlugins, CmsModelField } from "../types";
2
2
  interface RenderGetFilterFieldsParams {
3
- model: CmsModel;
3
+ fields: CmsModelField[];
4
4
  fieldTypePlugins: CmsFieldTypePlugins;
5
5
  }
6
6
  interface RenderGetFilterFields {
@@ -5,41 +5,28 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderGetFilterFields = void 0;
7
7
  var _getBaseFieldType = require("./getBaseFieldType");
8
- const getCreateFilters = (plugins, fieldType) => {
9
- if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
10
- return null;
11
- }
12
- return plugins[fieldType].read.createGetFilters;
13
- };
14
8
  const renderGetFilterFields = ({
15
- model,
9
+ fields,
16
10
  fieldTypePlugins
17
11
  }) => {
18
- const fieldIdList = model.fields.filter(field => {
12
+ const filters = ["id: ID", "entryId: String"];
13
+ for (const field of fields) {
14
+ var _plugin$read;
19
15
  // Every time a client updates content model's fields, we check the type of each field. If a field plugin
20
16
  // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
21
17
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
22
18
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
23
19
  // could've just removed the plugin from the backend.
24
20
  const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
25
- if (!fieldTypePlugins[baseType]) {
26
- return false;
27
- }
28
- return fieldTypePlugins[baseType].isSearchable;
29
- }).map(f => f.fieldId);
30
- const filters = ["id: ID", "entryId: String"];
31
- for (const fieldId of fieldIdList) {
32
- const field = model.fields.find(item => item.fieldId === fieldId);
33
- if (!field) {
21
+ const plugin = fieldTypePlugins[baseType];
22
+ if (!(plugin !== null && plugin !== void 0 && plugin.isSearchable)) {
34
23
  continue;
35
24
  }
36
- const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
37
- const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);
25
+ const createGetFilters = (_plugin$read = plugin.read) === null || _plugin$read === void 0 ? void 0 : _plugin$read.createGetFilters;
38
26
  if (typeof createGetFilters !== "function") {
39
27
  continue;
40
28
  }
41
29
  filters.push(createGetFilters({
42
- model,
43
30
  field
44
31
  }));
45
32
  }
@@ -1 +1 @@
1
- {"version":3,"names":["getCreateFilters","plugins","fieldType","read","createGetFilters","renderGetFilterFields","model","fieldTypePlugins","fieldIdList","fields","filter","field","baseType","getBaseFieldType","isSearchable","map","f","fieldId","filters","find","item","push","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderGetFilterFieldsParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nconst getCreateFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string\n): CmsModelFieldToGraphQLPlugin[\"read\"][\"createGetFilters\"] | null => {\n if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {\n return null;\n }\n return plugins[fieldType].read.createGetFilters;\n};\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ model, fieldTypePlugins }) => {\n const fieldIdList = model.fields\n .filter(field => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n if (!fieldTypePlugins[baseType]) {\n return false;\n }\n return fieldTypePlugins[baseType].isSearchable;\n })\n .map(f => f.fieldId);\n\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const fieldId of fieldIdList) {\n const field = model.fields.find(item => item.fieldId === fieldId);\n if (!field) {\n continue;\n }\n const baseType = getBaseFieldType(field);\n const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ model, field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAUA,MAAMA,gBAAgB,GAAG,CACrBC,OAA4B,EAC5BC,SAAiB,KACiD;EAClE,IAAI,CAACD,OAAO,CAACC,SAAS,CAAC,IAAI,CAACD,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAACC,gBAAgB,EAAE;IAClE,OAAO,IAAI;EACf;EACA,OAAOH,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAACC,gBAAgB;AACnD,CAAC;AAEM,MAAMC,qBAA4C,GAAG,CAAC;EAAEC,KAAK;EAAEC;AAAiB,CAAC,KAAK;EACzF,MAAMC,WAAW,GAAGF,KAAK,CAACG,MAAM,CAC3BC,MAAM,CAACC,KAAK,IAAI;IACb;IACA;IACA;IACA;IACA;IACA,MAAMC,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,IAAI,CAACJ,gBAAgB,CAACK,QAAQ,CAAC,EAAE;MAC7B,OAAO,KAAK;IAChB;IACA,OAAOL,gBAAgB,CAACK,QAAQ,CAAC,CAACE,YAAY;EAClD,CAAC,CAAC,CACDC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC;EAExB,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMD,OAAO,IAAIT,WAAW,EAAE;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAM,CAACU,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACH,OAAO,KAAKA,OAAO,CAAC;IACjE,IAAI,CAACN,KAAK,EAAE;MACR;IACJ;IACA,MAAMC,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAgB,EAAEK,QAAQ,CAAC;IACrE,IAAI,OAAOR,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAc,OAAO,CAACG,IAAI,CAACjB,gBAAgB,CAAC;MAAEE,KAAK;MAAEK;IAAM,CAAC,CAAC,CAAC;EACpD;EAEA,OAAOO,OAAO,CAACR,MAAM,CAACY,OAAO,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC7C,CAAC;AAAC"}
1
+ {"version":3,"names":["renderGetFilterFields","fields","fieldTypePlugins","filters","field","baseType","getBaseFieldType","plugin","isSearchable","createGetFilters","read","push","filter","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderGetFilterFieldsParams {\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ fields, fieldTypePlugins }) => {\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const field of fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n const plugin = fieldTypePlugins[baseType];\n if (!plugin?.isSearchable) {\n continue;\n }\n const createGetFilters = plugin.read?.createGetFilters;\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAUO,MAAMA,qBAA4C,GAAG,CAAC;EAAEC,MAAM;EAAEC;AAAiB,CAAC,KAAK;EAC1F,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMC,KAAK,IAAIH,MAAM,EAAE;IAAA;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMI,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,MAAM,GAAGL,gBAAgB,CAACG,QAAQ,CAAC;IACzC,IAAI,EAACE,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEC,YAAY,GAAE;MACvB;IACJ;IACA,MAAMC,gBAAgB,mBAAGF,MAAM,CAACG,IAAI,iDAAX,aAAaD,gBAAgB;IACtD,IAAI,OAAOA,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAN,OAAO,CAACQ,IAAI,CAACF,gBAAgB,CAAC;MAAEL;IAAM,CAAC,CAAC,CAAC;EAC7C;EAEA,OAAOD,OAAO,CAACS,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC7C,CAAC;AAAC"}
@@ -1,14 +1,16 @@
1
1
  import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
2
2
  interface RenderInputFieldsParams {
3
+ models: CmsModel[];
3
4
  model: CmsModel;
5
+ fields: CmsModelField[];
4
6
  fieldTypePlugins: CmsFieldTypePlugins;
5
7
  }
6
- interface RenderInputFieldParams extends RenderInputFieldsParams {
8
+ interface RenderInputFieldParams extends Omit<RenderInputFieldsParams, "fields"> {
7
9
  field: CmsModelField;
8
10
  }
9
11
  interface RenderInputFields {
10
12
  (params: RenderInputFieldsParams): CmsModelFieldDefinition[];
11
13
  }
12
14
  export declare const renderInputFields: RenderInputFields;
13
- export declare const renderInputField: ({ model, field, fieldTypePlugins }: RenderInputFieldParams) => CmsModelFieldDefinition | null;
15
+ export declare const renderInputField: ({ models, model, field, fieldTypePlugins }: RenderInputFieldParams) => CmsModelFieldDefinition | null;
14
16
  export {};
@@ -6,17 +6,28 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.renderInputFields = exports.renderInputField = void 0;
7
7
  var _getBaseFieldType = require("./getBaseFieldType");
8
8
  const renderInputFields = ({
9
+ models,
9
10
  model,
11
+ fields,
10
12
  fieldTypePlugins
11
13
  }) => {
12
- return model.fields.map(field => renderInputField({
13
- model,
14
- field,
15
- fieldTypePlugins
16
- })).filter(Boolean);
14
+ return fields.reduce((result, field) => {
15
+ const input = renderInputField({
16
+ models,
17
+ model,
18
+ field,
19
+ fieldTypePlugins
20
+ });
21
+ if (!input) {
22
+ return result;
23
+ }
24
+ result.push(input);
25
+ return result;
26
+ }, []);
17
27
  };
18
28
  exports.renderInputFields = renderInputFields;
19
29
  const renderInputField = ({
30
+ models,
20
31
  model,
21
32
  field,
22
33
  fieldTypePlugins
@@ -32,6 +43,7 @@ const renderInputField = ({
32
43
  return null;
33
44
  }
34
45
  const def = plugin.manage.createInputField({
46
+ models,
35
47
  model,
36
48
  field,
37
49
  fieldTypePlugins
@@ -1 +1 @@
1
- {"version":3,"names":["renderInputFields","model","fieldTypePlugins","fields","map","field","renderInputField","filter","Boolean","plugin","getBaseFieldType","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import {\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderInputFieldsParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderInputFieldParams extends RenderInputFieldsParams {\n field: CmsModelField;\n}\ninterface RenderInputFields {\n (params: RenderInputFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderInputFields: RenderInputFields = ({\n model,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return model.fields\n .map(field => renderInputField({ model, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\nexport const renderInputField = ({\n model,\n field,\n fieldTypePlugins\n}: RenderInputFieldParams): CmsModelFieldDefinition | null => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const plugin: CmsModelFieldToGraphQLPlugin = fieldTypePlugins[getBaseFieldType(field)];\n\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n\n const def = plugin.manage.createInputField({\n model,\n field,\n fieldTypePlugins\n });\n if (typeof def === \"string\") {\n return {\n fields: def\n };\n }\n\n return def;\n};\n"],"mappings":";;;;;;AAOA;AAaO,MAAMA,iBAAoC,GAAG,CAAC;EACjDC,KAAK;EACLC;AACJ,CAAC,KAAgC;EAC7B,OAAOD,KAAK,CAACE,MAAM,CACdC,GAAG,CAACC,KAAK,IAAIC,gBAAgB,CAAC;IAAEL,KAAK;IAAEI,KAAK;IAAEH;EAAiB,CAAC,CAAC,CAAC,CAClEK,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAAC;AAEK,MAAMF,gBAAgB,GAAG,CAAC;EAC7BL,KAAK;EACLI,KAAK;EACLH;AACoB,CAAC,KAAqC;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAoC,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACL,KAAK,CAAC,CAAC;EAEtF,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EAEA,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAM,CAACC,gBAAgB,CAAC;IACvCZ,KAAK;IACLI,KAAK;IACLH;EACJ,CAAC,CAAC;EACF,IAAI,OAAOS,GAAG,KAAK,QAAQ,EAAE;IACzB,OAAO;MACHR,MAAM,EAAEQ;IACZ,CAAC;EACL;EAEA,OAAOA,GAAG;AACd,CAAC;AAAC"}
1
+ {"version":3,"names":["renderInputFields","models","model","fields","fieldTypePlugins","reduce","result","field","input","renderInputField","push","plugin","getBaseFieldType","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderInputFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderInputFieldParams extends Omit<RenderInputFieldsParams, \"fields\"> {\n field: CmsModelField;\n}\n\ninterface RenderInputFields {\n (params: RenderInputFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderInputFields: RenderInputFields = ({\n models,\n model,\n fields,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return fields.reduce<CmsModelFieldDefinition[]>((result, field) => {\n const input = renderInputField({ models, model, field, fieldTypePlugins });\n if (!input) {\n return result;\n }\n result.push(input);\n return result;\n }, []);\n};\n\nexport const renderInputField = ({\n models,\n model,\n field,\n fieldTypePlugins\n}: RenderInputFieldParams): CmsModelFieldDefinition | null => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n\n const def = plugin.manage.createInputField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n if (typeof def === \"string\") {\n return {\n fields: def\n };\n }\n\n return def;\n};\n"],"mappings":";;;;;;AACA;AAiBO,MAAMA,iBAAoC,GAAG,CAAC;EACjDC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC;AACJ,CAAC,KAAgC;EAC7B,OAAOD,MAAM,CAACE,MAAM,CAA4B,CAACC,MAAM,EAAEC,KAAK,KAAK;IAC/D,MAAMC,KAAK,GAAGC,gBAAgB,CAAC;MAAER,MAAM;MAAEC,KAAK;MAAEK,KAAK;MAAEH;IAAiB,CAAC,CAAC;IAC1E,IAAI,CAACI,KAAK,EAAE;MACR,OAAOF,MAAM;IACjB;IACAA,MAAM,CAACI,IAAI,CAACF,KAAK,CAAC;IAClB,OAAOF,MAAM;EACjB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAAC;AAEK,MAAMG,gBAAgB,GAAG,CAAC;EAC7BR,MAAM;EACNC,KAAK;EACLK,KAAK;EACLH;AACoB,CAAC,KAAqC;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAM,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACL,KAAK,CAAC,CAAC;EAExD,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EAEA,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAM,CAACC,gBAAgB,CAAC;IACvCd,MAAM;IACNC,KAAK;IACLK,KAAK;IACLH;EACJ,CAAC,CAAC;EACF,IAAI,OAAOS,GAAG,KAAK,QAAQ,EAAE;IACzB,OAAO;MACHV,MAAM,EAAEU;IACZ,CAAC;EACL;EAEA,OAAOA,GAAG;AACd,CAAC;AAAC"}
@@ -1,6 +1,7 @@
1
- import { ApiEndpoint, CmsFieldTypePlugins, CmsModel } from "../types";
1
+ import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
2
2
  interface RenderListFilterFieldsParams {
3
3
  model: CmsModel;
4
+ fields: CmsModelField[];
4
5
  type: ApiEndpoint;
5
6
  fieldTypePlugins: CmsFieldTypePlugins;
6
7
  }
@@ -5,49 +5,38 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderListFilterFields = void 0;
7
7
  var _getBaseFieldType = require("./getBaseFieldType");
8
- /**
9
- * We cast as read type, because input and output of read and manage are same. This way we ease things.
10
- * Internal stuff so it should be ok.
11
- * TODO note that if changing read/manage types, change this as well.
12
- */
13
- const getCreateListFilters = (plugins, fieldType, type) => {
14
- if (!plugins[fieldType]) {
15
- return null;
16
- } else if (!plugins[fieldType][type]) {
17
- return null;
18
- }
19
- return plugins[fieldType][type].createListFilters;
20
- };
21
8
  const renderListFilterFields = params => {
22
9
  const {
23
10
  model,
11
+ fields,
24
12
  type,
25
13
  fieldTypePlugins
26
14
  } = params;
27
- const fields = [["id: ID", "id_not: ID", "id_in: [ID!]", "id_not_in: [ID!]", "entryId: String", "entryId_not: String", "entryId_in: [String!]", "entryId_not_in: [String!]", "createdOn: DateTime", "createdOn_gt: DateTime", "createdOn_gte: DateTime", "createdOn_lt: DateTime", "createdOn_lte: DateTime", "createdOn_between: [DateTime!]", "createdOn_not_between: [DateTime!]", "savedOn: DateTime", "savedOn_gt: DateTime", "savedOn_gte: DateTime", "savedOn_lt: DateTime", "savedOn_lte: DateTime", "savedOn_between: [DateTime!]", "savedOn_not_between: [DateTime!]", "createdBy: String", "createdBy_not: String", "createdBy_in: [String!]", "createdBy_not_in: [String!]", "ownedBy: String", "ownedBy_not: String", "ownedBy_in: [String!]", "ownedBy_not_in: [String!]"].join("\n")];
15
+ const result = [["id: ID", "id_not: ID", "id_in: [ID!]", "id_not_in: [ID!]", "entryId: String", "entryId_not: String", "entryId_in: [String!]", "entryId_not_in: [String!]", "createdOn: DateTime", "createdOn_gt: DateTime", "createdOn_gte: DateTime", "createdOn_lt: DateTime", "createdOn_lte: DateTime", "createdOn_between: [DateTime!]", "createdOn_not_between: [DateTime!]", "savedOn: DateTime", "savedOn_gt: DateTime", "savedOn_gte: DateTime", "savedOn_lt: DateTime", "savedOn_lte: DateTime", "savedOn_between: [DateTime!]", "savedOn_not_between: [DateTime!]", "createdBy: String", "createdBy_not: String", "createdBy_in: [String!]", "createdBy_not_in: [String!]", "ownedBy: String", "ownedBy_not: String", "ownedBy_in: [String!]", "ownedBy_not_in: [String!]"].join("\n")];
28
16
  /**
29
17
  * We can find different statuses only in the manage API endpoint.
30
18
  */
31
19
  if (type === "manage") {
32
- fields.push(...["status: String", "status_not: String", "status_in: [String!]", "status_not_in: [String!]"]);
20
+ result.push("status: String", "status_not: String", "status_in: [String!]", "status_not_in: [String!]");
33
21
  }
34
- for (const field of model.fields) {
22
+ for (const field of fields) {
23
+ var _fieldTypePlugins$bas, _fieldTypePlugins$bas2;
35
24
  // Every time a client updates content model's fields, we check the type of each field. If a field plugin
36
25
  // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
37
26
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
38
27
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
39
28
  // could've just removed the plugin from the backend.
40
-
41
- const createListFilters = getCreateListFilters(fieldTypePlugins, (0, _getBaseFieldType.getBaseFieldType)(field), type);
29
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
30
+ const createListFilters = (_fieldTypePlugins$bas = fieldTypePlugins[baseType]) === null || _fieldTypePlugins$bas === void 0 ? void 0 : (_fieldTypePlugins$bas2 = _fieldTypePlugins$bas[type]) === null || _fieldTypePlugins$bas2 === void 0 ? void 0 : _fieldTypePlugins$bas2.createListFilters;
42
31
  if (typeof createListFilters !== "function") {
43
32
  continue;
44
33
  }
45
- fields.push(createListFilters({
34
+ result.push(createListFilters({
46
35
  model,
47
36
  field,
48
37
  plugins: fieldTypePlugins
49
38
  }));
50
39
  }
51
- return fields.filter(Boolean).join("\n");
40
+ return result.filter(Boolean).join("\n");
52
41
  };
53
42
  exports.renderListFilterFields = renderListFilterFields;
@@ -1 +1 @@
1
- {"version":3,"names":["getCreateListFilters","plugins","fieldType","type","createListFilters","renderListFilterFields","params","model","fieldTypePlugins","fields","join","push","field","getBaseFieldType","filter","Boolean"],"sources":["renderListFilterFields.ts"],"sourcesContent":["import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderListFilterFieldsParams {\n model: CmsModel;\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderListFilterFields {\n (params: RenderListFilterFieldsParams): string;\n}\n\ntype CreateListFiltersType =\n | CmsModelFieldToGraphQLPlugin[\"read\"][\"createListFilters\"]\n | CmsModelFieldToGraphQLPlugin[\"manage\"][\"createListFilters\"];\n/**\n * We cast as read type, because input and output of read and manage are same. This way we ease things.\n * Internal stuff so it should be ok.\n * TODO note that if changing read/manage types, change this as well.\n */\nconst getCreateListFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string,\n type: ApiEndpoint\n): CreateListFiltersType | null => {\n if (!plugins[fieldType]) {\n return null;\n } else if (!plugins[fieldType][type]) {\n return null;\n }\n return plugins[fieldType][type].createListFilters;\n};\n\nexport const renderListFilterFields: RenderListFilterFields = (params): string => {\n const { model, type, fieldTypePlugins } = params;\n const fields: string[] = [\n [\n \"id: ID\",\n \"id_not: ID\",\n \"id_in: [ID!]\",\n \"id_not_in: [ID!]\",\n \"entryId: String\",\n \"entryId_not: String\",\n \"entryId_in: [String!]\",\n \"entryId_not_in: [String!]\",\n \"createdOn: DateTime\",\n \"createdOn_gt: DateTime\",\n \"createdOn_gte: DateTime\",\n \"createdOn_lt: DateTime\",\n \"createdOn_lte: DateTime\",\n \"createdOn_between: [DateTime!]\",\n \"createdOn_not_between: [DateTime!]\",\n \"savedOn: DateTime\",\n \"savedOn_gt: DateTime\",\n \"savedOn_gte: DateTime\",\n \"savedOn_lt: DateTime\",\n \"savedOn_lte: DateTime\",\n \"savedOn_between: [DateTime!]\",\n \"savedOn_not_between: [DateTime!]\",\n \"createdBy: String\",\n \"createdBy_not: String\",\n \"createdBy_in: [String!]\",\n \"createdBy_not_in: [String!]\",\n \"ownedBy: String\",\n \"ownedBy_not: String\",\n \"ownedBy_in: [String!]\",\n \"ownedBy_not_in: [String!]\"\n ].join(\"\\n\")\n ];\n /**\n * We can find different statuses only in the manage API endpoint.\n */\n if (type === \"manage\") {\n fields.push(\n ...[\n \"status: String\",\n \"status_not: String\",\n \"status_in: [String!]\",\n \"status_not_in: [String!]\"\n ]\n );\n }\n\n for (const field of model.fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n\n const createListFilters = getCreateListFilters(\n fieldTypePlugins,\n getBaseFieldType(field),\n type\n );\n if (typeof createListFilters !== \"function\") {\n continue;\n }\n fields.push(createListFilters({ model, field, plugins: fieldTypePlugins }));\n }\n\n return fields.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAcA;AACA;AACA;AACA;AACA;AACA,MAAMA,oBAAoB,GAAG,CACzBC,OAA4B,EAC5BC,SAAiB,EACjBC,IAAiB,KACc;EAC/B,IAAI,CAACF,OAAO,CAACC,SAAS,CAAC,EAAE;IACrB,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,CAACD,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,EAAE;IAClC,OAAO,IAAI;EACf;EACA,OAAOF,OAAO,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,CAACC,iBAAiB;AACrD,CAAC;AAEM,MAAMC,sBAA8C,GAAIC,MAAM,IAAa;EAC9E,MAAM;IAAEC,KAAK;IAAEJ,IAAI;IAAEK;EAAiB,CAAC,GAAGF,MAAM;EAChD,MAAMG,MAAgB,GAAG,CACrB,CACI,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,CAC9B,CAACC,IAAI,CAAC,IAAI,CAAC,CACf;EACD;AACJ;AACA;EACI,IAAIP,IAAI,KAAK,QAAQ,EAAE;IACnBM,MAAM,CAACE,IAAI,CACP,GAAG,CACC,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,CAC7B,CACJ;EACL;EAEA,KAAK,MAAMC,KAAK,IAAIL,KAAK,CAACE,MAAM,EAAE;IAC9B;IACA;IACA;IACA;IACA;;IAEA,MAAML,iBAAiB,GAAGJ,oBAAoB,CAC1CQ,gBAAgB,EAChB,IAAAK,kCAAgB,EAACD,KAAK,CAAC,EACvBT,IAAI,CACP;IACD,IAAI,OAAOC,iBAAiB,KAAK,UAAU,EAAE;MACzC;IACJ;IACAK,MAAM,CAACE,IAAI,CAACP,iBAAiB,CAAC;MAAEG,KAAK;MAAEK,KAAK;MAAEX,OAAO,EAAEO;IAAiB,CAAC,CAAC,CAAC;EAC/E;EAEA,OAAOC,MAAM,CAACK,MAAM,CAACC,OAAO,CAAC,CAACL,IAAI,CAAC,IAAI,CAAC;AAC5C,CAAC;AAAC"}
1
+ {"version":3,"names":["renderListFilterFields","params","model","fields","type","fieldTypePlugins","result","join","push","field","baseType","getBaseFieldType","createListFilters","plugins","filter","Boolean"],"sources":["renderListFilterFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderListFilterFieldsParams {\n model: CmsModel;\n fields: CmsModelField[];\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderListFilterFields {\n (params: RenderListFilterFieldsParams): string;\n}\n\ntype CreateListFiltersType =\n | CmsModelFieldToGraphQLPlugin[\"read\"][\"createListFilters\"]\n | CmsModelFieldToGraphQLPlugin[\"manage\"][\"createListFilters\"];\n\nexport const renderListFilterFields: RenderListFilterFields = (params): string => {\n const { model, fields, type, fieldTypePlugins } = params;\n const result: string[] = [\n [\n \"id: ID\",\n \"id_not: ID\",\n \"id_in: [ID!]\",\n \"id_not_in: [ID!]\",\n \"entryId: String\",\n \"entryId_not: String\",\n \"entryId_in: [String!]\",\n \"entryId_not_in: [String!]\",\n \"createdOn: DateTime\",\n \"createdOn_gt: DateTime\",\n \"createdOn_gte: DateTime\",\n \"createdOn_lt: DateTime\",\n \"createdOn_lte: DateTime\",\n \"createdOn_between: [DateTime!]\",\n \"createdOn_not_between: [DateTime!]\",\n \"savedOn: DateTime\",\n \"savedOn_gt: DateTime\",\n \"savedOn_gte: DateTime\",\n \"savedOn_lt: DateTime\",\n \"savedOn_lte: DateTime\",\n \"savedOn_between: [DateTime!]\",\n \"savedOn_not_between: [DateTime!]\",\n \"createdBy: String\",\n \"createdBy_not: String\",\n \"createdBy_in: [String!]\",\n \"createdBy_not_in: [String!]\",\n \"ownedBy: String\",\n \"ownedBy_not: String\",\n \"ownedBy_in: [String!]\",\n \"ownedBy_not_in: [String!]\"\n ].join(\"\\n\")\n ];\n /**\n * We can find different statuses only in the manage API endpoint.\n */\n if (type === \"manage\") {\n result.push(\n \"status: String\",\n \"status_not: String\",\n \"status_in: [String!]\",\n \"status_not_in: [String!]\"\n );\n }\n\n for (const field of fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n const createListFilters: CreateListFiltersType | undefined =\n fieldTypePlugins[baseType]?.[type]?.createListFilters;\n if (typeof createListFilters !== \"function\") {\n continue;\n }\n result.push(createListFilters({ model, field, plugins: fieldTypePlugins }));\n }\n\n return result.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AAOA;AAgBO,MAAMA,sBAA8C,GAAIC,MAAM,IAAa;EAC9E,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAiB,CAAC,GAAGJ,MAAM;EACxD,MAAMK,MAAgB,GAAG,CACrB,CACI,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,CAC9B,CAACC,IAAI,CAAC,IAAI,CAAC,CACf;EACD;AACJ;AACA;EACI,IAAIH,IAAI,KAAK,QAAQ,EAAE;IACnBE,MAAM,CAACE,IAAI,CACP,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,CAC7B;EACL;EAEA,KAAK,MAAMC,KAAK,IAAIN,MAAM,EAAE;IAAA;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMO,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,iBAAoD,4BACtDP,gBAAgB,CAACK,QAAQ,CAAC,oFAA1B,sBAA6BN,IAAI,CAAC,2DAAlC,uBAAoCQ,iBAAiB;IACzD,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;MACzC;IACJ;IACAN,MAAM,CAACE,IAAI,CAACI,iBAAiB,CAAC;MAAEV,KAAK;MAAEO,KAAK;MAAEI,OAAO,EAAER;IAAiB,CAAC,CAAC,CAAC;EAC/E;EAEA,OAAOC,MAAM,CAACQ,MAAM,CAACC,OAAO,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC5C,CAAC;AAAC"}
@@ -1,7 +1,8 @@
1
- import { CmsFieldTypePlugins, CmsModel } from "../types";
1
+ import { CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
2
2
  import { CmsGraphQLSchemaSorterPlugin } from "../plugins/CmsGraphQLSchemaSorterPlugin";
3
3
  interface RenderSortEnumParams {
4
4
  model: CmsModel;
5
+ fields: CmsModelField[];
5
6
  fieldTypePlugins: CmsFieldTypePlugins;
6
7
  sorterPlugins: CmsGraphQLSchemaSorterPlugin[];
7
8
  }
@@ -7,11 +7,12 @@ exports.renderSortEnum = void 0;
7
7
  var _getBaseFieldType = require("./getBaseFieldType");
8
8
  const renderSortEnum = ({
9
9
  model,
10
+ fields,
10
11
  fieldTypePlugins,
11
12
  sorterPlugins
12
13
  }) => {
13
14
  let sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
14
- for (const field of model.fields) {
15
+ for (const field of fields) {
15
16
  const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
16
17
  if (!plugin) {
17
18
  continue;
@@ -1 +1 @@
1
- {"version":3,"names":["renderSortEnum","model","fieldTypePlugins","sorterPlugins","sorters","field","fields","plugin","getBaseFieldType","createSorters","result","isSortable","push","fieldId","reduce","createSorter","join"],"sources":["renderSortEnum.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/CmsGraphQLSchemaSorterPlugin\";\n\ninterface RenderSortEnumParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\ninterface RenderSortEnum {\n (params: RenderSortEnumParams): string;\n}\n\nexport const renderSortEnum: RenderSortEnum = ({\n model,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n let sorters: string[] = [\n `id_ASC`,\n `id_DESC`,\n \"savedOn_ASC\",\n \"savedOn_DESC\",\n \"createdOn_ASC\",\n \"createdOn_DESC\"\n ];\n\n for (const field of model.fields) {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n continue;\n } else if (plugin.createSorters) {\n const result = plugin.createSorters({\n model,\n field,\n sorters\n });\n if (result) {\n sorters = result;\n continue;\n }\n }\n if (!plugin.isSortable) {\n continue;\n }\n sorters.push(`${field.fieldId}_ASC`);\n sorters.push(`${field.fieldId}_DESC`);\n }\n\n return sorterPlugins\n .reduce((result, plugin) => {\n return plugin.createSorter({\n model,\n sorters: result\n });\n }, sorters)\n .join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAYO,MAAMA,cAA8B,GAAG,CAAC;EAC3CC,KAAK;EACLC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,IAAIC,OAAiB,GAAG,CACnB,QAAO,EACP,SAAQ,EACT,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,CACnB;EAED,KAAK,MAAMC,KAAK,IAAIJ,KAAK,CAACK,MAAM,EAAE;IAC9B,MAAMC,MAAM,GAAGL,gBAAgB,CAAC,IAAAM,kCAAgB,EAACH,KAAK,CAAC,CAAC;IACxD,IAAI,CAACE,MAAM,EAAE;MACT;IACJ,CAAC,MAAM,IAAIA,MAAM,CAACE,aAAa,EAAE;MAC7B,MAAMC,MAAM,GAAGH,MAAM,CAACE,aAAa,CAAC;QAChCR,KAAK;QACLI,KAAK;QACLD;MACJ,CAAC,CAAC;MACF,IAAIM,MAAM,EAAE;QACRN,OAAO,GAAGM,MAAM;QAChB;MACJ;IACJ;IACA,IAAI,CAACH,MAAM,CAACI,UAAU,EAAE;MACpB;IACJ;IACAP,OAAO,CAACQ,IAAI,CAAE,GAAEP,KAAK,CAACQ,OAAQ,MAAK,CAAC;IACpCT,OAAO,CAACQ,IAAI,CAAE,GAAEP,KAAK,CAACQ,OAAQ,OAAM,CAAC;EACzC;EAEA,OAAOV,aAAa,CACfW,MAAM,CAAC,CAACJ,MAAM,EAAEH,MAAM,KAAK;IACxB,OAAOA,MAAM,CAACQ,YAAY,CAAC;MACvBd,KAAK;MACLG,OAAO,EAAEM;IACb,CAAC,CAAC;EACN,CAAC,EAAEN,OAAO,CAAC,CACVY,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAAC"}
1
+ {"version":3,"names":["renderSortEnum","model","fields","fieldTypePlugins","sorterPlugins","sorters","field","plugin","getBaseFieldType","createSorters","result","isSortable","push","fieldId","reduce","createSorter","join"],"sources":["renderSortEnum.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/CmsGraphQLSchemaSorterPlugin\";\n\ninterface RenderSortEnumParams {\n model: CmsModel;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\ninterface RenderSortEnum {\n (params: RenderSortEnumParams): string;\n}\n\nexport const renderSortEnum: RenderSortEnum = ({\n model,\n fields,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n let sorters: string[] = [\n `id_ASC`,\n `id_DESC`,\n \"savedOn_ASC\",\n \"savedOn_DESC\",\n \"createdOn_ASC\",\n \"createdOn_DESC\"\n ];\n\n for (const field of fields) {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n continue;\n } else if (plugin.createSorters) {\n const result = plugin.createSorters({\n model,\n field,\n sorters\n });\n if (result) {\n sorters = result;\n continue;\n }\n }\n if (!plugin.isSortable) {\n continue;\n }\n sorters.push(`${field.fieldId}_ASC`);\n sorters.push(`${field.fieldId}_DESC`);\n }\n\n return sorterPlugins\n .reduce((result, plugin) => {\n return plugin.createSorter({\n model,\n sorters: result\n });\n }, sorters)\n .join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAaO,MAAMA,cAA8B,GAAG,CAAC;EAC3CC,KAAK;EACLC,MAAM;EACNC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,IAAIC,OAAiB,GAAG,CACnB,QAAO,EACP,SAAQ,EACT,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,CACnB;EAED,KAAK,MAAMC,KAAK,IAAIJ,MAAM,EAAE;IACxB,MAAMK,MAAM,GAAGJ,gBAAgB,CAAC,IAAAK,kCAAgB,EAACF,KAAK,CAAC,CAAC;IACxD,IAAI,CAACC,MAAM,EAAE;MACT;IACJ,CAAC,MAAM,IAAIA,MAAM,CAACE,aAAa,EAAE;MAC7B,MAAMC,MAAM,GAAGH,MAAM,CAACE,aAAa,CAAC;QAChCR,KAAK;QACLK,KAAK;QACLD;MACJ,CAAC,CAAC;MACF,IAAIK,MAAM,EAAE;QACRL,OAAO,GAAGK,MAAM;QAChB;MACJ;IACJ;IACA,IAAI,CAACH,MAAM,CAACI,UAAU,EAAE;MACpB;IACJ;IACAN,OAAO,CAACO,IAAI,CAAE,GAAEN,KAAK,CAACO,OAAQ,MAAK,CAAC;IACpCR,OAAO,CAACO,IAAI,CAAE,GAAEN,KAAK,CAACO,OAAQ,OAAM,CAAC;EACzC;EAEA,OAAOT,aAAa,CACfU,MAAM,CAAC,CAACJ,MAAM,EAAEH,MAAM,KAAK;IACxB,OAAOA,MAAM,CAACQ,YAAY,CAAC;MACvBd,KAAK;MACLI,OAAO,EAAEK;IACb,CAAC,CAAC;EACN,CAAC,EAAEL,OAAO,CAAC,CACVW,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAAC"}