@webiny/api-headless-cms 0.0.0-unstable.5e7233243f → 0.0.0-unstable.60e968001a

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 (232) hide show
  1. package/context.d.ts +5 -2
  2. package/context.js +63 -8
  3. package/context.js.map +1 -1
  4. package/crud/contentEntry/afterDelete.d.ts +2 -2
  5. package/crud/contentEntry/afterDelete.js +2 -2
  6. package/crud/contentEntry/afterDelete.js.map +1 -1
  7. package/crud/contentEntry/beforeCreate.d.ts +2 -2
  8. package/crud/contentEntry/beforeCreate.js +2 -2
  9. package/crud/contentEntry/beforeCreate.js.map +1 -1
  10. package/crud/contentEntry/beforeUpdate.d.ts +2 -2
  11. package/crud/contentEntry/beforeUpdate.js +2 -2
  12. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  13. package/crud/contentEntry/entryDataValidation.js +3 -7
  14. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  15. package/crud/contentEntry/markLockedFields.js +10 -11
  16. package/crud/contentEntry/markLockedFields.js.map +1 -1
  17. package/crud/contentEntry/referenceFieldsMapping.js +11 -13
  18. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  19. package/crud/contentEntry/searchableFields.d.ts +9 -0
  20. package/crud/contentEntry/searchableFields.js +83 -0
  21. package/crud/contentEntry/searchableFields.js.map +1 -0
  22. package/crud/contentEntry.crud.d.ts +0 -2
  23. package/crud/contentEntry.crud.js +253 -270
  24. package/crud/contentEntry.crud.js.map +1 -1
  25. package/crud/contentModel/afterCreate.d.ts +3 -3
  26. package/crud/contentModel/afterCreate.js +5 -5
  27. package/crud/contentModel/afterCreate.js.map +1 -1
  28. package/crud/contentModel/afterCreateFrom.d.ts +3 -3
  29. package/crud/contentModel/afterCreateFrom.js +5 -5
  30. package/crud/contentModel/afterCreateFrom.js.map +1 -1
  31. package/crud/contentModel/afterDelete.d.ts +3 -3
  32. package/crud/contentModel/afterDelete.js +5 -5
  33. package/crud/contentModel/afterDelete.js.map +1 -1
  34. package/crud/contentModel/afterUpdate.d.ts +3 -3
  35. package/crud/contentModel/afterUpdate.js +5 -5
  36. package/crud/contentModel/afterUpdate.js.map +1 -1
  37. package/crud/contentModel/beforeCreate.d.ts +4 -4
  38. package/crud/contentModel/beforeCreate.js +10 -10
  39. package/crud/contentModel/beforeCreate.js.map +1 -1
  40. package/crud/contentModel/beforeDelete.d.ts +3 -3
  41. package/crud/contentModel/beforeDelete.js +6 -6
  42. package/crud/contentModel/beforeDelete.js.map +1 -1
  43. package/crud/contentModel/beforeUpdate.d.ts +3 -3
  44. package/crud/contentModel/beforeUpdate.js +5 -5
  45. package/crud/contentModel/beforeUpdate.js.map +1 -1
  46. package/crud/contentModel/createFieldStorageId.js +5 -1
  47. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  48. package/crud/contentModel/models.js +12 -0
  49. package/crud/contentModel/models.js.map +1 -1
  50. package/crud/contentModel/validateModel.js +1 -1
  51. package/crud/contentModel/validateModelFields.js +47 -42
  52. package/crud/contentModel/validateModelFields.js.map +1 -1
  53. package/crud/contentModel/validation.d.ts +477 -0
  54. package/crud/contentModel/validation.js +109 -0
  55. package/crud/contentModel/validation.js.map +1 -0
  56. package/crud/contentModel.crud.js +287 -211
  57. package/crud/contentModel.crud.js.map +1 -1
  58. package/crud/contentModelGroup/beforeCreate.d.ts +2 -2
  59. package/crud/contentModelGroup/beforeCreate.js +3 -3
  60. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  61. package/crud/contentModelGroup/beforeDelete.d.ts +2 -2
  62. package/crud/contentModelGroup/beforeDelete.js +3 -3
  63. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  64. package/crud/contentModelGroup/beforeUpdate.d.ts +2 -2
  65. package/crud/contentModelGroup/beforeUpdate.js +2 -2
  66. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  67. package/crud/contentModelGroup/validation.d.ts +30 -0
  68. package/crud/contentModelGroup/validation.js +43 -0
  69. package/crud/contentModelGroup/validation.js.map +1 -0
  70. package/crud/contentModelGroup.crud.js +102 -82
  71. package/crud/contentModelGroup.crud.js.map +1 -1
  72. package/crud/settings.crud.js +3 -8
  73. package/crud/settings.crud.js.map +1 -1
  74. package/crud/system.crud.js +63 -51
  75. package/crud/system.crud.js.map +1 -1
  76. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +1 -1
  77. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
  78. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +239 -0
  79. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
  80. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +17 -19
  81. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  82. package/fieldConverters/index.d.ts +2 -1
  83. package/fieldConverters/index.js +3 -1
  84. package/fieldConverters/index.js.map +1 -1
  85. package/graphql/buildSchemaPlugins.d.ts +2 -2
  86. package/graphql/buildSchemaPlugins.js.map +1 -1
  87. package/graphql/graphQLHandlerFactory.js +59 -29
  88. package/graphql/graphQLHandlerFactory.js.map +1 -1
  89. package/graphql/index.d.ts +2 -2
  90. package/graphql/index.js +49 -38
  91. package/graphql/index.js.map +1 -1
  92. package/graphql/schema/baseContentSchema.d.ts +2 -2
  93. package/graphql/schema/baseContentSchema.js +8 -12
  94. package/graphql/schema/baseContentSchema.js.map +1 -1
  95. package/graphql/schema/contentEntries.d.ts +2 -2
  96. package/graphql/schema/contentEntries.js +6 -6
  97. package/graphql/schema/contentEntries.js.map +1 -1
  98. package/graphql/schema/contentModelGroups.d.ts +2 -2
  99. package/graphql/schema/contentModelGroups.js +3 -3
  100. package/graphql/schema/contentModelGroups.js.map +1 -1
  101. package/graphql/schema/contentModels.d.ts +2 -2
  102. package/graphql/schema/contentModels.js +42 -4
  103. package/graphql/schema/contentModels.js.map +1 -1
  104. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  105. package/graphql/schema/createFieldResolvers.js +26 -16
  106. package/graphql/schema/createFieldResolvers.js.map +1 -1
  107. package/graphql/schema/createManageResolvers.js +4 -18
  108. package/graphql/schema/createManageResolvers.js.map +1 -1
  109. package/graphql/schema/createManageSDL.d.ts +2 -0
  110. package/graphql/schema/createManageSDL.js +11 -12
  111. package/graphql/schema/createManageSDL.js.map +1 -1
  112. package/graphql/schema/createPreviewResolvers.js +3 -7
  113. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  114. package/graphql/schema/createReadResolvers.js +8 -7
  115. package/graphql/schema/createReadResolvers.js.map +1 -1
  116. package/graphql/schema/createReadSDL.d.ts +2 -0
  117. package/graphql/schema/createReadSDL.js +11 -5
  118. package/graphql/schema/createReadSDL.js.map +1 -1
  119. package/graphql/schema/resolvers/manage/resolveGet.js +5 -9
  120. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  121. package/graphql/schema/resolvers/preview/resolveGet.js +3 -7
  122. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  123. package/graphql/schema/resolvers/read/resolveGet.js +3 -7
  124. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  125. package/graphql/schema/schemaPlugins.d.ts +2 -2
  126. package/graphql/schema/schemaPlugins.js +11 -8
  127. package/graphql/schema/schemaPlugins.js.map +1 -1
  128. package/graphql/system.js +79 -82
  129. package/graphql/system.js.map +1 -1
  130. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
  131. package/graphqlFields/dynamicZone/dynamicZoneField.js +234 -0
  132. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
  133. package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
  134. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +79 -0
  135. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
  136. package/graphqlFields/dynamicZone/index.d.ts +2 -0
  137. package/graphqlFields/dynamicZone/index.js +21 -0
  138. package/graphqlFields/dynamicZone/index.js.map +1 -0
  139. package/graphqlFields/index.d.ts +1 -1
  140. package/graphqlFields/index.js +3 -1
  141. package/graphqlFields/index.js.map +1 -1
  142. package/graphqlFields/number.js +4 -0
  143. package/graphqlFields/number.js.map +1 -1
  144. package/graphqlFields/object.js +123 -73
  145. package/graphqlFields/object.js.map +1 -1
  146. package/graphqlFields/ref.js +38 -56
  147. package/graphqlFields/ref.js.map +1 -1
  148. package/index.d.ts +3 -3
  149. package/index.js +4 -8
  150. package/index.js.map +1 -1
  151. package/modelManager/DefaultCmsModelManager.d.ts +7 -7
  152. package/modelManager/DefaultCmsModelManager.js +1 -1
  153. package/package.json +30 -31
  154. package/parameters/header.js +1 -1
  155. package/parameters/manual.js +7 -8
  156. package/parameters/manual.js.map +1 -1
  157. package/parameters/path.js +1 -1
  158. package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
  159. package/plugins/CmsGraphQLSchemaPlugin.js +17 -0
  160. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
  161. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
  162. package/plugins/CmsGraphQLSchemaSorterPlugin.js +38 -0
  163. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
  164. package/plugins/CmsGroupPlugin.js +1 -1
  165. package/plugins/CmsModelFieldConverterPlugin.d.ts +2 -2
  166. package/plugins/CmsModelFieldConverterPlugin.js +1 -1
  167. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  168. package/plugins/CmsModelPlugin.d.ts +6 -2
  169. package/plugins/CmsModelPlugin.js +18 -13
  170. package/plugins/CmsModelPlugin.js.map +1 -1
  171. package/plugins/CmsParametersPlugin.js +1 -1
  172. package/plugins/StorageTransformPlugin.d.ts +11 -11
  173. package/plugins/StorageTransformPlugin.js +1 -1
  174. package/plugins/StorageTransformPlugin.js.map +1 -1
  175. package/plugins/index.d.ts +2 -0
  176. package/plugins/index.js +26 -0
  177. package/plugins/index.js.map +1 -1
  178. package/storage/object.js +7 -8
  179. package/storage/object.js.map +1 -1
  180. package/types.d.ts +469 -180
  181. package/types.js +55 -9
  182. package/types.js.map +1 -1
  183. package/upgrades/5.33.0/index.js +5 -9
  184. package/upgrades/5.33.0/index.js.map +1 -1
  185. package/utils/converters/Converter.js +1 -1
  186. package/utils/converters/ConverterCollection.d.ts +7 -0
  187. package/utils/converters/ConverterCollection.js +36 -8
  188. package/utils/converters/ConverterCollection.js.map +1 -1
  189. package/utils/converters/valueKeyStorageConverter.js +3 -7
  190. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  191. package/utils/createTypeFromFields.d.ts +15 -0
  192. package/utils/createTypeFromFields.js +75 -0
  193. package/utils/createTypeFromFields.js.map +1 -0
  194. package/utils/createTypeName.js +4 -2
  195. package/utils/createTypeName.js.map +1 -1
  196. package/utils/entryStorage.js +17 -18
  197. package/utils/entryStorage.js.map +1 -1
  198. package/utils/filterModelFields.js +5 -9
  199. package/utils/filterModelFields.js.map +1 -1
  200. package/utils/getBaseFieldType.d.ts +4 -0
  201. package/utils/getBaseFieldType.js +12 -0
  202. package/utils/getBaseFieldType.js.map +1 -0
  203. package/utils/permissions.js +1 -5
  204. package/utils/permissions.js.map +1 -1
  205. package/utils/pluralizedTypeName.js +1 -1
  206. package/utils/renderFields.js +3 -1
  207. package/utils/renderFields.js.map +1 -1
  208. package/utils/renderGetFilterFields.js +8 -3
  209. package/utils/renderGetFilterFields.js.map +1 -1
  210. package/utils/renderInputFields.js +3 -1
  211. package/utils/renderInputFields.js.map +1 -1
  212. package/utils/renderListFilterFields.js +12 -2
  213. package/utils/renderListFilterFields.js.map +1 -1
  214. package/utils/renderSortEnum.d.ts +7 -4
  215. package/utils/renderSortEnum.js +23 -4
  216. package/utils/renderSortEnum.js.map +1 -1
  217. package/utils/toSlug.js +1 -1
  218. package/validators/dynamicZone.d.ts +2 -0
  219. package/validators/dynamicZone.js +24 -0
  220. package/validators/dynamicZone.js.map +1 -0
  221. package/validators/index.js +3 -1
  222. package/validators/index.js.map +1 -1
  223. package/validators/unique.js +1 -1
  224. package/crud/index.d.ts +0 -6
  225. package/crud/index.js +0 -89
  226. package/crud/index.js.map +0 -1
  227. package/graphql/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -7
  228. package/graphql/schema/resolvers/manage/resolveRequestChanges.js +0 -21
  229. package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
  230. package/graphql/schema/resolvers/manage/resolveRequestReview.d.ts +0 -7
  231. package/graphql/schema/resolvers/manage/resolveRequestReview.js +0 -21
  232. package/graphql/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderFields = exports.renderField = void 0;
7
7
 
8
+ var _getBaseFieldType = require("./getBaseFieldType");
9
+
8
10
  const renderFields = ({
9
11
  model,
10
12
  type,
@@ -26,7 +28,7 @@ const renderField = ({
26
28
  field,
27
29
  fieldTypePlugins
28
30
  }) => {
29
- const plugin = fieldTypePlugins[field.type];
31
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
30
32
 
31
33
  if (!plugin) {
32
34
  // Let's not render the field if it does not exist in the field plugins.
@@ -1 +1 @@
1
- {"version":3,"names":["renderFields","model","type","fieldTypePlugins","fields","map","field","renderField","filter","Boolean","plugin","defs","createTypeField"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\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[field.type];\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":";;;;;;;AAkBO,MAAMA,YAA0B,GAAG,CAAC;EACvCC,KADuC;EAEvCC,IAFuC;EAGvCC;AAHuC,CAAD,KAIT;EAC7B,OAAOF,KAAK,CAACG,MAAN,CACFC,GADE,CACEC,KAAK,IAAIC,WAAW,CAAC;IAAEN,KAAF;IAASC,IAAT;IAAeI,KAAf;IAAsBH;EAAtB,CAAD,CADtB,EAEFK,MAFE,CAEKC,OAFL,CAAP;AAGH,CARM;;;;AAcA,MAAMF,WAAW,GAAG,CAAC;EACxBN,KADwB;EAExBC,IAFwB;EAGxBI,KAHwB;EAIxBH;AAJwB,CAAD,KAK8B;EACrD,MAAMO,MAAoC,GAAGP,gBAAgB,CAACG,KAAK,CAACJ,IAAP,CAA7D;;EACA,IAAI,CAACQ,MAAL,EAAa;IACT;IACA,OAAO,IAAP;EACH;;EACD,MAAMC,IAAI,GAAGD,MAAM,CAACR,IAAD,CAAN,CAAaU,eAAb,CAA6B;IACtCX,KADsC;IAEtCK,KAFsC;IAGtCH;EAHsC,CAA7B,CAAb;;EAMA,IAAI,CAACQ,IAAL,EAAW;IACP,OAAO,IAAP;EACH,CAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;IACjC,OAAO;MACHP,MAAM,EAAEO;IADL,CAAP;EAGH;;EAED,OAAOA,IAAP;AACH,CA1BM"}
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,KADuC;EAEvCC,IAFuC;EAGvCC;AAHuC,CAAD,KAIT;EAC7B,OAAOF,KAAK,CAACG,MAAN,CACFC,GADE,CACEC,KAAK,IAAIC,WAAW,CAAC;IAAEN,KAAF;IAASC,IAAT;IAAeI,KAAf;IAAsBH;EAAtB,CAAD,CADtB,EAEFK,MAFE,CAEKC,OAFL,CAAP;AAGH,CARM;;;;AAcA,MAAMF,WAAW,GAAG,CAAC;EACxBN,KADwB;EAExBC,IAFwB;EAGxBI,KAHwB;EAIxBH;AAJwB,CAAD,KAK8B;EACrD,MAAMO,MAAoC,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAA,EAAiBL,KAAjB,CAAD,CAA7D;;EACA,IAAI,CAACI,MAAL,EAAa;IACT;IACA,OAAO,IAAP;EACH;;EACD,MAAME,IAAI,GAAGF,MAAM,CAACR,IAAD,CAAN,CAAaW,eAAb,CAA6B;IACtCZ,KADsC;IAEtCK,KAFsC;IAGtCH;EAHsC,CAA7B,CAAb;;EAMA,IAAI,CAACS,IAAL,EAAW;IACP,OAAO,IAAP;EACH,CAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;IACjC,OAAO;MACHR,MAAM,EAAEQ;IADL,CAAP;EAGH;;EAED,OAAOA,IAAP;AACH,CA1BM"}
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderGetFilterFields = void 0;
7
7
 
8
+ var _getBaseFieldType = require("./getBaseFieldType");
9
+
8
10
  const getCreateFilters = (plugins, fieldType) => {
9
11
  if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
10
12
  return null;
@@ -23,11 +25,13 @@ const renderGetFilterFields = ({
23
25
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
24
26
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
25
27
  // could've just removed the plugin from the backend.
26
- if (!fieldTypePlugins[field.type]) {
28
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
29
+
30
+ if (!fieldTypePlugins[baseType]) {
27
31
  return false;
28
32
  }
29
33
 
30
- return fieldTypePlugins[field.type].isSearchable;
34
+ return fieldTypePlugins[baseType].isSearchable;
31
35
  }).map(f => f.fieldId);
32
36
  const filters = ["id: ID", "entryId: String"];
33
37
 
@@ -38,7 +42,8 @@ const renderGetFilterFields = ({
38
42
  continue;
39
43
  }
40
44
 
41
- const createGetFilters = getCreateFilters(fieldTypePlugins, field.type);
45
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
46
+ const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);
42
47
 
43
48
  if (typeof createGetFilters !== "function") {
44
49
  continue;
@@ -1 +1 @@
1
- {"version":3,"names":["getCreateFilters","plugins","fieldType","read","createGetFilters","renderGetFilterFields","model","fieldTypePlugins","fieldIdList","fields","filter","field","type","isSearchable","map","f","fieldId","filters","find","item","push","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\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 if (!fieldTypePlugins[field.type]) {\n return false;\n }\n return fieldTypePlugins[field.type].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 createGetFilters = getCreateFilters(fieldTypePlugins, field.type);\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":";;;;;;;AAUA,MAAMA,gBAAgB,GAAG,CACrBC,OADqB,EAErBC,SAFqB,KAG6C;EAClE,IAAI,CAACD,OAAO,CAACC,SAAD,CAAR,IAAuB,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAApD,EAAsE;IAClE,OAAO,IAAP;EACH;;EACD,OAAOH,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAA/B;AACH,CARD;;AAUO,MAAMC,qBAA4C,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAiC;EACzF,MAAMC,WAAW,GAAGF,KAAK,CAACG,MAAN,CACfC,MADe,CACRC,KAAK,IAAI;IACb;IACA;IACA;IACA;IACA;IACA,IAAI,CAACJ,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAArB,EAAmC;MAC/B,OAAO,KAAP;IACH;;IACD,OAAOL,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAAhB,CAA6BC,YAApC;EACH,CAXe,EAYfC,GAZe,CAYXC,CAAC,IAAIA,CAAC,CAACC,OAZI,CAApB;EAcA,MAAMC,OAAiB,GAAG,CAAC,QAAD,EAAW,iBAAX,CAA1B;;EAEA,KAAK,MAAMD,OAAX,IAAsBR,WAAtB,EAAmC;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAN,CAAaS,IAAb,CAAkBC,IAAI,IAAIA,IAAI,CAACH,OAAL,KAAiBA,OAA3C,CAAd;;IACA,IAAI,CAACL,KAAL,EAAY;MACR;IACH;;IACD,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAD,EAAmBI,KAAK,CAACC,IAAzB,CAAzC;;IACA,IAAI,OAAOR,gBAAP,KAA4B,UAAhC,EAA4C;MACxC;IACH;;IACDa,OAAO,CAACG,IAAR,CAAahB,gBAAgB,CAAC;MAAEE,KAAF;MAASK;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOM,OAAO,CAACP,MAAR,CAAeW,OAAf,EAAwBC,IAAxB,CAA6B,IAA7B,CAAP;AACH,CA9BM"}
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,OADqB,EAErBC,SAFqB,KAG6C;EAClE,IAAI,CAACD,OAAO,CAACC,SAAD,CAAR,IAAuB,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAApD,EAAsE;IAClE,OAAO,IAAP;EACH;;EACD,OAAOH,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAA/B;AACH,CARD;;AAUO,MAAMC,qBAA4C,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAiC;EACzF,MAAMC,WAAW,GAAGF,KAAK,CAACG,MAAN,CACfC,MADe,CACRC,KAAK,IAAI;IACb;IACA;IACA;IACA;IACA;IACA,MAAMC,QAAQ,GAAG,IAAAC,kCAAA,EAAiBF,KAAjB,CAAjB;;IACA,IAAI,CAACJ,gBAAgB,CAACK,QAAD,CAArB,EAAiC;MAC7B,OAAO,KAAP;IACH;;IACD,OAAOL,gBAAgB,CAACK,QAAD,CAAhB,CAA2BE,YAAlC;EACH,CAZe,EAafC,GAbe,CAaXC,CAAC,IAAIA,CAAC,CAACC,OAbI,CAApB;EAeA,MAAMC,OAAiB,GAAG,CAAC,QAAD,EAAW,iBAAX,CAA1B;;EAEA,KAAK,MAAMD,OAAX,IAAsBT,WAAtB,EAAmC;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAN,CAAaU,IAAb,CAAkBC,IAAI,IAAIA,IAAI,CAACH,OAAL,KAAiBA,OAA3C,CAAd;;IACA,IAAI,CAACN,KAAL,EAAY;MACR;IACH;;IACD,MAAMC,QAAQ,GAAG,IAAAC,kCAAA,EAAiBF,KAAjB,CAAjB;IACA,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAD,EAAmBK,QAAnB,CAAzC;;IACA,IAAI,OAAOR,gBAAP,KAA4B,UAAhC,EAA4C;MACxC;IACH;;IACDc,OAAO,CAACG,IAAR,CAAajB,gBAAgB,CAAC;MAAEE,KAAF;MAASK;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOO,OAAO,CAACR,MAAR,CAAeY,OAAf,EAAwBC,IAAxB,CAA6B,IAA7B,CAAP;AACH,CAhCM"}
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderInputFields = exports.renderInputField = void 0;
7
7
 
8
+ var _getBaseFieldType = require("./getBaseFieldType");
9
+
8
10
  const renderInputFields = ({
9
11
  model,
10
12
  fieldTypePlugins
@@ -28,7 +30,7 @@ const renderInputField = ({
28
30
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
29
31
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
30
32
  // could've just removed the plugin from the backend.
31
- const plugin = fieldTypePlugins[field.type];
33
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
32
34
 
33
35
  if (!plugin) {
34
36
  // Let's not render the field if it does not exist in the field plugins.
@@ -1 +1 @@
1
- {"version":3,"names":["renderInputFields","model","fieldTypePlugins","fields","map","field","renderInputField","filter","Boolean","plugin","type","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import {\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\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[field.type];\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":";;;;;;;AAmBO,MAAMA,iBAAoC,GAAG,CAAC;EACjDC,KADiD;EAEjDC;AAFiD,CAAD,KAGnB;EAC7B,OAAOD,KAAK,CAACE,MAAN,CACFC,GADE,CACEC,KAAK,IAAIC,gBAAgB,CAAC;IAAEL,KAAF;IAASI,KAAT;IAAgBH;EAAhB,CAAD,CAD3B,EAEFK,MAFE,CAEKC,OAFL,CAAP;AAGH,CAPM;;;;AASA,MAAMF,gBAAgB,GAAG,CAAC;EAC7BL,KAD6B;EAE7BI,KAF6B;EAG7BH;AAH6B,CAAD,KAI8B;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAoC,GAAGP,gBAAgB,CAACG,KAAK,CAACK,IAAP,CAA7D;;EAEA,IAAI,CAACD,MAAL,EAAa;IACT;IACA,OAAO,IAAP;EACH;;EAED,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAP,CAAcC,gBAAd,CAA+B;IACvCZ,KADuC;IAEvCI,KAFuC;IAGvCH;EAHuC,CAA/B,CAAZ;;EAKA,IAAI,OAAOS,GAAP,KAAe,QAAnB,EAA6B;IACzB,OAAO;MACHR,MAAM,EAAEQ;IADL,CAAP;EAGH;;EAED,OAAOA,GAAP;AACH,CA7BM"}
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,KADiD;EAEjDC;AAFiD,CAAD,KAGnB;EAC7B,OAAOD,KAAK,CAACE,MAAN,CACFC,GADE,CACEC,KAAK,IAAIC,gBAAgB,CAAC;IAAEL,KAAF;IAASI,KAAT;IAAgBH;EAAhB,CAAD,CAD3B,EAEFK,MAFE,CAEKC,OAFL,CAAP;AAGH,CAPM;;;;AASA,MAAMF,gBAAgB,GAAG,CAAC;EAC7BL,KAD6B;EAE7BI,KAF6B;EAG7BH;AAH6B,CAAD,KAI8B;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAoC,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAA,EAAiBL,KAAjB,CAAD,CAA7D;;EAEA,IAAI,CAACI,MAAL,EAAa;IACT;IACA,OAAO,IAAP;EACH;;EAED,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAP,CAAcC,gBAAd,CAA+B;IACvCZ,KADuC;IAEvCI,KAFuC;IAGvCH;EAHuC,CAA/B,CAAZ;;EAKA,IAAI,OAAOS,GAAP,KAAe,QAAnB,EAA6B;IACzB,OAAO;MACHR,MAAM,EAAEQ;IADL,CAAP;EAGH;;EAED,OAAOA,GAAP;AACH,CA7BM"}
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderListFilterFields = void 0;
7
7
 
8
+ var _getBaseFieldType = require("./getBaseFieldType");
9
+
8
10
  /**
9
11
  * We cast as read type, because input and output of read and manage are same. This way we ease things.
10
12
  * Internal stuff so it should be ok.
@@ -27,6 +29,13 @@ const renderListFilterFields = params => {
27
29
  fieldTypePlugins
28
30
  } = params;
29
31
  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")];
32
+ /**
33
+ * We can find different statuses only in the manage API endpoint.
34
+ */
35
+
36
+ if (type === "manage") {
37
+ fields.push(...["status: String", "status_not: String", "status_in: [String!]", "status_not_in: [String!]"]);
38
+ }
30
39
 
31
40
  for (const field of model.fields) {
32
41
  // Every time a client updates content model's fields, we check the type of each field. If a field plugin
@@ -34,7 +43,7 @@ const renderListFilterFields = params => {
34
43
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
35
44
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
36
45
  // could've just removed the plugin from the backend.
37
- const createListFilters = getCreateListFilters(fieldTypePlugins, field.type, type);
46
+ const createListFilters = getCreateListFilters(fieldTypePlugins, (0, _getBaseFieldType.getBaseFieldType)(field), type);
38
47
 
39
48
  if (typeof createListFilters !== "function") {
40
49
  continue;
@@ -42,7 +51,8 @@ const renderListFilterFields = params => {
42
51
 
43
52
  fields.push(createListFilters({
44
53
  model,
45
- field
54
+ field,
55
+ plugins: fieldTypePlugins
46
56
  }));
47
57
  }
48
58
 
@@ -1 +1 @@
1
- {"version":3,"names":["getCreateListFilters","plugins","fieldType","type","createListFilters","renderListFilterFields","params","model","fieldTypePlugins","fields","join","field","push","filter","Boolean"],"sources":["renderListFilterFields.ts"],"sourcesContent":["import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\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 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(fieldTypePlugins, field.type, type);\n if (typeof createListFilters !== \"function\") {\n continue;\n }\n fields.push(createListFilters({ model, field }));\n }\n\n return fields.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;;AAcA;AACA;AACA;AACA;AACA;AACA,MAAMA,oBAAoB,GAAG,CACzBC,OADyB,EAEzBC,SAFyB,EAGzBC,IAHyB,KAIM;EAC/B,IAAI,CAACF,OAAO,CAACC,SAAD,CAAZ,EAAyB;IACrB,OAAO,IAAP;EACH,CAFD,MAEO,IAAI,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAL,EAA+B;IAClC,OAAO,IAAP;EACH;;EACD,OAAOF,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,EAAyBC,iBAAhC;AACH,CAXD;;AAaO,MAAMC,sBAA8C,GAAIC,MAAD,IAAoB;EAC9E,MAAM;IAAEC,KAAF;IAASJ,IAAT;IAAeK;EAAf,IAAoCF,MAA1C;EACA,MAAMG,MAAgB,GAAG,CACrB,CACI,QADJ,EAEI,YAFJ,EAGI,cAHJ,EAII,kBAJJ,EAKI,iBALJ,EAMI,qBANJ,EAOI,uBAPJ,EAQI,2BARJ,EASI,qBATJ,EAUI,wBAVJ,EAWI,yBAXJ,EAYI,wBAZJ,EAaI,yBAbJ,EAcI,gCAdJ,EAeI,oCAfJ,EAgBI,mBAhBJ,EAiBI,sBAjBJ,EAkBI,uBAlBJ,EAmBI,sBAnBJ,EAoBI,uBApBJ,EAqBI,8BArBJ,EAsBI,kCAtBJ,EAuBI,mBAvBJ,EAwBI,uBAxBJ,EAyBI,yBAzBJ,EA0BI,6BA1BJ,EA2BI,iBA3BJ,EA4BI,qBA5BJ,EA6BI,uBA7BJ,EA8BI,2BA9BJ,EA+BEC,IA/BF,CA+BO,IA/BP,CADqB,CAAzB;;EAmCA,KAAK,MAAMC,KAAX,IAAoBJ,KAAK,CAACE,MAA1B,EAAkC;IAC9B;IACA;IACA;IACA;IACA;IAEA,MAAML,iBAAiB,GAAGJ,oBAAoB,CAACQ,gBAAD,EAAmBG,KAAK,CAACR,IAAzB,EAA+BA,IAA/B,CAA9C;;IACA,IAAI,OAAOC,iBAAP,KAA6B,UAAjC,EAA6C;MACzC;IACH;;IACDK,MAAM,CAACG,IAAP,CAAYR,iBAAiB,CAAC;MAAEG,KAAF;MAASI;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOF,MAAM,CAACI,MAAP,CAAcC,OAAd,EAAuBJ,IAAvB,CAA4B,IAA5B,CAAP;AACH,CApDM"}
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,OADyB,EAEzBC,SAFyB,EAGzBC,IAHyB,KAIM;EAC/B,IAAI,CAACF,OAAO,CAACC,SAAD,CAAZ,EAAyB;IACrB,OAAO,IAAP;EACH,CAFD,MAEO,IAAI,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAL,EAA+B;IAClC,OAAO,IAAP;EACH;;EACD,OAAOF,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,EAAyBC,iBAAhC;AACH,CAXD;;AAaO,MAAMC,sBAA8C,GAAIC,MAAD,IAAoB;EAC9E,MAAM;IAAEC,KAAF;IAASJ,IAAT;IAAeK;EAAf,IAAoCF,MAA1C;EACA,MAAMG,MAAgB,GAAG,CACrB,CACI,QADJ,EAEI,YAFJ,EAGI,cAHJ,EAII,kBAJJ,EAKI,iBALJ,EAMI,qBANJ,EAOI,uBAPJ,EAQI,2BARJ,EASI,qBATJ,EAUI,wBAVJ,EAWI,yBAXJ,EAYI,wBAZJ,EAaI,yBAbJ,EAcI,gCAdJ,EAeI,oCAfJ,EAgBI,mBAhBJ,EAiBI,sBAjBJ,EAkBI,uBAlBJ,EAmBI,sBAnBJ,EAoBI,uBApBJ,EAqBI,8BArBJ,EAsBI,kCAtBJ,EAuBI,mBAvBJ,EAwBI,uBAxBJ,EAyBI,yBAzBJ,EA0BI,6BA1BJ,EA2BI,iBA3BJ,EA4BI,qBA5BJ,EA6BI,uBA7BJ,EA8BI,2BA9BJ,EA+BEC,IA/BF,CA+BO,IA/BP,CADqB,CAAzB;EAkCA;AACJ;AACA;;EACI,IAAIP,IAAI,KAAK,QAAb,EAAuB;IACnBM,MAAM,CAACE,IAAP,CACI,GAAG,CACC,gBADD,EAEC,oBAFD,EAGC,sBAHD,EAIC,0BAJD,CADP;EAQH;;EAED,KAAK,MAAMC,KAAX,IAAoBL,KAAK,CAACE,MAA1B,EAAkC;IAC9B;IACA;IACA;IACA;IACA;IAEA,MAAML,iBAAiB,GAAGJ,oBAAoB,CAC1CQ,gBAD0C,EAE1C,IAAAK,kCAAA,EAAiBD,KAAjB,CAF0C,EAG1CT,IAH0C,CAA9C;;IAKA,IAAI,OAAOC,iBAAP,KAA6B,UAAjC,EAA6C;MACzC;IACH;;IACDK,MAAM,CAACE,IAAP,CAAYP,iBAAiB,CAAC;MAAEG,KAAF;MAASK,KAAT;MAAgBX,OAAO,EAAEO;IAAzB,CAAD,CAA7B;EACH;;EAED,OAAOC,MAAM,CAACK,MAAP,CAAcC,OAAd,EAAuBL,IAAvB,CAA4B,IAA5B,CAAP;AACH,CArEM"}
@@ -1,9 +1,12 @@
1
1
  import { CmsFieldTypePlugins, CmsModel } from "../types";
2
+ import { CmsGraphQLSchemaSorterPlugin } from "../plugins/CmsGraphQLSchemaSorterPlugin";
3
+ interface RenderSortEnumParams {
4
+ model: CmsModel;
5
+ fieldTypePlugins: CmsFieldTypePlugins;
6
+ sorterPlugins: CmsGraphQLSchemaSorterPlugin[];
7
+ }
2
8
  interface RenderSortEnum {
3
- (params: {
4
- model: CmsModel;
5
- fieldTypePlugins: CmsFieldTypePlugins;
6
- }): string;
9
+ (params: RenderSortEnumParams): string;
7
10
  }
8
11
  export declare const renderSortEnum: RenderSortEnum;
9
12
  export {};
@@ -5,17 +5,31 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderSortEnum = void 0;
7
7
 
8
+ var _getBaseFieldType = require("./getBaseFieldType");
9
+
8
10
  const renderSortEnum = ({
9
11
  model,
10
- fieldTypePlugins
12
+ fieldTypePlugins,
13
+ sorterPlugins
11
14
  }) => {
12
- const sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
15
+ let sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
13
16
 
14
17
  for (const field of model.fields) {
15
- const plugin = fieldTypePlugins[field.type];
18
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
16
19
 
17
20
  if (!plugin) {
18
21
  continue;
22
+ } else if (plugin.createSorters) {
23
+ const result = plugin.createSorters({
24
+ model,
25
+ field,
26
+ sorters
27
+ });
28
+
29
+ if (result) {
30
+ sorters = result;
31
+ continue;
32
+ }
19
33
  }
20
34
 
21
35
  if (!plugin.isSortable) {
@@ -26,7 +40,12 @@ const renderSortEnum = ({
26
40
  sorters.push(`${field.fieldId}_DESC`);
27
41
  }
28
42
 
29
- return sorters.join("\n");
43
+ return sorterPlugins.reduce((result, plugin) => {
44
+ return plugin.createSorter({
45
+ model,
46
+ sorters: result
47
+ });
48
+ }, sorters).join("\n");
30
49
  };
31
50
 
32
51
  exports.renderSortEnum = renderSortEnum;
@@ -1 +1 @@
1
- {"version":3,"names":["renderSortEnum","model","fieldTypePlugins","sorters","field","fields","plugin","type","isSortable","push","fieldId","join"],"sources":["renderSortEnum.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel } from \"~/types\";\n\ninterface RenderSortEnum {\n (params: { model: CmsModel; fieldTypePlugins: CmsFieldTypePlugins }): string;\n}\n\nexport const renderSortEnum: RenderSortEnum = ({ model, fieldTypePlugins }): string => {\n const 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[field.type];\n if (!plugin) {\n continue;\n }\n if (!plugin.isSortable) {\n continue;\n }\n sorters.push(`${field.fieldId}_ASC`);\n sorters.push(`${field.fieldId}_DESC`);\n }\n\n return sorters.join(\"\\n\");\n};\n"],"mappings":";;;;;;;AAMO,MAAMA,cAA8B,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAyC;EACnF,MAAMC,OAAiB,GAAG,CACrB,QADqB,EAErB,SAFqB,EAGtB,aAHsB,EAItB,cAJsB,EAKtB,eALsB,EAMtB,gBANsB,CAA1B;;EASA,KAAK,MAAMC,KAAX,IAAoBH,KAAK,CAACI,MAA1B,EAAkC;IAC9B,MAAMC,MAAM,GAAGJ,gBAAgB,CAACE,KAAK,CAACG,IAAP,CAA/B;;IACA,IAAI,CAACD,MAAL,EAAa;MACT;IACH;;IACD,IAAI,CAACA,MAAM,CAACE,UAAZ,EAAwB;MACpB;IACH;;IACDL,OAAO,CAACM,IAAR,CAAc,GAAEL,KAAK,CAACM,OAAQ,MAA9B;IACAP,OAAO,CAACM,IAAR,CAAc,GAAEL,KAAK,CAACM,OAAQ,OAA9B;EACH;;EAED,OAAOP,OAAO,CAACQ,IAAR,CAAa,IAAb,CAAP;AACH,CAvBM"}
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,KAD2C;EAE3CC,gBAF2C;EAG3CC;AAH2C,CAAD,KAIhC;EACV,IAAIC,OAAiB,GAAG,CACnB,QADmB,EAEnB,SAFmB,EAGpB,aAHoB,EAIpB,cAJoB,EAKpB,eALoB,EAMpB,gBANoB,CAAxB;;EASA,KAAK,MAAMC,KAAX,IAAoBJ,KAAK,CAACK,MAA1B,EAAkC;IAC9B,MAAMC,MAAM,GAAGL,gBAAgB,CAAC,IAAAM,kCAAA,EAAiBH,KAAjB,CAAD,CAA/B;;IACA,IAAI,CAACE,MAAL,EAAa;MACT;IACH,CAFD,MAEO,IAAIA,MAAM,CAACE,aAAX,EAA0B;MAC7B,MAAMC,MAAM,GAAGH,MAAM,CAACE,aAAP,CAAqB;QAChCR,KADgC;QAEhCI,KAFgC;QAGhCD;MAHgC,CAArB,CAAf;;MAKA,IAAIM,MAAJ,EAAY;QACRN,OAAO,GAAGM,MAAV;QACA;MACH;IACJ;;IACD,IAAI,CAACH,MAAM,CAACI,UAAZ,EAAwB;MACpB;IACH;;IACDP,OAAO,CAACQ,IAAR,CAAc,GAAEP,KAAK,CAACQ,OAAQ,MAA9B;IACAT,OAAO,CAACQ,IAAR,CAAc,GAAEP,KAAK,CAACQ,OAAQ,OAA9B;EACH;;EAED,OAAOV,aAAa,CACfW,MADE,CACK,CAACJ,MAAD,EAASH,MAAT,KAAoB;IACxB,OAAOA,MAAM,CAACQ,YAAP,CAAoB;MACvBd,KADuB;MAEvBG,OAAO,EAAEM;IAFc,CAApB,CAAP;EAIH,CANE,EAMAN,OANA,EAOFY,IAPE,CAOG,IAPH,CAAP;AAQH,CA5CM"}
package/utils/toSlug.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1,2 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../types";
2
+ export declare const createDynamicZoneValidator: () => CmsModelFieldValidatorPlugin;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createDynamicZoneValidator = void 0;
7
+
8
+ const createDynamicZoneValidator = () => {
9
+ return {
10
+ type: "cms-model-field-validator",
11
+ name: "cms-model-field-validator-dynamic-zone",
12
+ validator: {
13
+ name: "dynamicZone",
14
+
15
+ validate() {
16
+ // TODO: implement validation.
17
+ return Promise.resolve(true);
18
+ }
19
+
20
+ }
21
+ };
22
+ };
23
+
24
+ exports.createDynamicZoneValidator = createDynamicZoneValidator;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createDynamicZoneValidator","type","name","validator","validate","Promise","resolve"],"sources":["dynamicZone.ts"],"sourcesContent":["import { CmsModelFieldValidatorPlugin } from \"~/types\";\n\nexport const createDynamicZoneValidator = (): CmsModelFieldValidatorPlugin => {\n return {\n type: \"cms-model-field-validator\",\n name: \"cms-model-field-validator-dynamic-zone\",\n validator: {\n name: \"dynamicZone\",\n validate() {\n // TODO: implement validation.\n return Promise.resolve(true);\n }\n }\n };\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,0BAA0B,GAAG,MAAoC;EAC1E,OAAO;IACHC,IAAI,EAAE,2BADH;IAEHC,IAAI,EAAE,wCAFH;IAGHC,SAAS,EAAE;MACPD,IAAI,EAAE,aADC;;MAEPE,QAAQ,GAAG;QACP;QACA,OAAOC,OAAO,CAACC,OAAR,CAAgB,IAAhB,CAAP;MACH;;IALM;EAHR,CAAP;AAWH,CAZM"}
@@ -31,6 +31,8 @@ var _timeGte = require("./timeGte");
31
31
 
32
32
  var _unique = require("./unique");
33
33
 
34
- const createValidators = () => [(0, _gte.createGteValidator)(), (0, _in.createInValidator)(), (0, _lte.createLteValidator)(), (0, _maxLength.createMaxLengthValidator)(), (0, _minLength.createMinLengthValidator)(), (0, _pattern.createPatternValidator)(), (0, _required.createRequiredValidator)(), (0, _patternPlugins.createPatternValidatorPlugins)(), (0, _dateLte.createDateLteValidator)(), (0, _dateGte.createDateGteValidator)(), (0, _timeLte.createTimeLteValidator)(), (0, _timeGte.createTimeGteValidator)(), (0, _unique.createUniqueValidator)()];
34
+ var _dynamicZone = require("./dynamicZone");
35
+
36
+ const createValidators = () => [(0, _gte.createGteValidator)(), (0, _in.createInValidator)(), (0, _lte.createLteValidator)(), (0, _maxLength.createMaxLengthValidator)(), (0, _minLength.createMinLengthValidator)(), (0, _pattern.createPatternValidator)(), (0, _required.createRequiredValidator)(), (0, _patternPlugins.createPatternValidatorPlugins)(), (0, _dateLte.createDateLteValidator)(), (0, _dateGte.createDateGteValidator)(), (0, _timeLte.createTimeLteValidator)(), (0, _timeGte.createTimeGteValidator)(), (0, _unique.createUniqueValidator)(), (0, _dynamicZone.createDynamicZoneValidator)()];
35
37
 
36
38
  exports.createValidators = createValidators;
@@ -1 +1 @@
1
- {"version":3,"names":["createValidators","createGteValidator","createInValidator","createLteValidator","createMaxLengthValidator","createMinLengthValidator","createPatternValidator","createRequiredValidator","createPatternValidatorPlugins","createDateLteValidator","createDateGteValidator","createTimeLteValidator","createTimeGteValidator","createUniqueValidator"],"sources":["index.ts"],"sourcesContent":["import { createGteValidator } from \"./gte\";\nimport { createInValidator } from \"./in\";\nimport { createLteValidator } from \"./lte\";\nimport { createMaxLengthValidator } from \"./maxLength\";\nimport { createMinLengthValidator } from \"./minLength\";\nimport { createPatternValidator } from \"./pattern\";\nimport { createRequiredValidator } from \"./required\";\nimport { createPatternValidatorPlugins } from \"./patternPlugins\";\nimport { createDateLteValidator } from \"./dateLte\";\nimport { createDateGteValidator } from \"./dateGte\";\nimport { createTimeLteValidator } from \"./timeLte\";\nimport { createTimeGteValidator } from \"./timeGte\";\nimport { createUniqueValidator } from \"./unique\";\n\nexport const createValidators = () => [\n createGteValidator(),\n createInValidator(),\n createLteValidator(),\n createMaxLengthValidator(),\n createMinLengthValidator(),\n createPatternValidator(),\n createRequiredValidator(),\n createPatternValidatorPlugins(),\n createDateLteValidator(),\n createDateGteValidator(),\n createTimeLteValidator(),\n createTimeGteValidator(),\n createUniqueValidator()\n];\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,gBAAgB,GAAG,MAAM,CAClC,IAAAC,uBAAA,GADkC,EAElC,IAAAC,qBAAA,GAFkC,EAGlC,IAAAC,uBAAA,GAHkC,EAIlC,IAAAC,mCAAA,GAJkC,EAKlC,IAAAC,mCAAA,GALkC,EAMlC,IAAAC,+BAAA,GANkC,EAOlC,IAAAC,iCAAA,GAPkC,EAQlC,IAAAC,6CAAA,GARkC,EASlC,IAAAC,+BAAA,GATkC,EAUlC,IAAAC,+BAAA,GAVkC,EAWlC,IAAAC,+BAAA,GAXkC,EAYlC,IAAAC,+BAAA,GAZkC,EAalC,IAAAC,6BAAA,GAbkC,CAA/B"}
1
+ {"version":3,"names":["createValidators","createGteValidator","createInValidator","createLteValidator","createMaxLengthValidator","createMinLengthValidator","createPatternValidator","createRequiredValidator","createPatternValidatorPlugins","createDateLteValidator","createDateGteValidator","createTimeLteValidator","createTimeGteValidator","createUniqueValidator","createDynamicZoneValidator"],"sources":["index.ts"],"sourcesContent":["import { createGteValidator } from \"./gte\";\nimport { createInValidator } from \"./in\";\nimport { createLteValidator } from \"./lte\";\nimport { createMaxLengthValidator } from \"./maxLength\";\nimport { createMinLengthValidator } from \"./minLength\";\nimport { createPatternValidator } from \"./pattern\";\nimport { createRequiredValidator } from \"./required\";\nimport { createPatternValidatorPlugins } from \"./patternPlugins\";\nimport { createDateLteValidator } from \"./dateLte\";\nimport { createDateGteValidator } from \"./dateGte\";\nimport { createTimeLteValidator } from \"./timeLte\";\nimport { createTimeGteValidator } from \"./timeGte\";\nimport { createUniqueValidator } from \"./unique\";\nimport { createDynamicZoneValidator } from \"./dynamicZone\";\n\nexport const createValidators = () => [\n createGteValidator(),\n createInValidator(),\n createLteValidator(),\n createMaxLengthValidator(),\n createMinLengthValidator(),\n createPatternValidator(),\n createRequiredValidator(),\n createPatternValidatorPlugins(),\n createDateLteValidator(),\n createDateGteValidator(),\n createTimeLteValidator(),\n createTimeGteValidator(),\n createUniqueValidator(),\n createDynamicZoneValidator()\n];\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,gBAAgB,GAAG,MAAM,CAClC,IAAAC,uBAAA,GADkC,EAElC,IAAAC,qBAAA,GAFkC,EAGlC,IAAAC,uBAAA,GAHkC,EAIlC,IAAAC,mCAAA,GAJkC,EAKlC,IAAAC,mCAAA,GALkC,EAMlC,IAAAC,+BAAA,GANkC,EAOlC,IAAAC,iCAAA,GAPkC,EAQlC,IAAAC,6CAAA,GARkC,EASlC,IAAAC,+BAAA,GATkC,EAUlC,IAAAC,+BAAA,GAVkC,EAWlC,IAAAC,+BAAA,GAXkC,EAYlC,IAAAC,+BAAA,GAZkC,EAalC,IAAAC,6BAAA,GAbkC,EAclC,IAAAC,uCAAA,GAdkC,CAA/B"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
package/crud/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { CmsContext, HeadlessCmsStorageOperations } from "../types";
3
- export interface CrudParams {
4
- storageOperations: HeadlessCmsStorageOperations;
5
- }
6
- export declare const createCrud: (params: CrudParams) => ContextPlugin<CmsContext>;
package/crud/index.js DELETED
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createCrud = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _api = require("@webiny/api");
13
-
14
- var _contentModelGroup = require("./contentModelGroup.crud");
15
-
16
- var _contentModel = require("./contentModel.crud");
17
-
18
- var _contentEntry = require("./contentEntry.crud");
19
-
20
- var _system = require("./system.crud");
21
-
22
- var _settings = require("./settings.crud");
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
28
- const createCrud = params => {
29
- const {
30
- storageOperations
31
- } = params;
32
- return new _api.ContextPlugin(async context => {
33
- const getLocale = () => {
34
- return context.cms.getLocale();
35
- };
36
-
37
- const getIdentity = () => {
38
- return context.security.getIdentity();
39
- };
40
-
41
- const getTenant = () => {
42
- return context.tenancy.getCurrentTenant();
43
- };
44
-
45
- if (storageOperations.beforeInit) {
46
- await storageOperations.beforeInit(context);
47
- }
48
-
49
- context.cms = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context.cms), {}, {
50
- storageOperations
51
- }, (0, _system.createSystemCrud)({
52
- context,
53
- getTenant,
54
- getLocale,
55
- getIdentity,
56
- storageOperations
57
- })), (0, _settings.createSettingsCrud)({
58
- context,
59
- getTenant,
60
- getLocale,
61
- storageOperations
62
- })), (0, _contentModelGroup.createModelGroupsCrud)({
63
- context,
64
- getTenant,
65
- getLocale,
66
- getIdentity,
67
- storageOperations
68
- })), (0, _contentModel.createModelsCrud)({
69
- context,
70
- getLocale,
71
- getTenant,
72
- getIdentity,
73
- storageOperations
74
- })), (0, _contentEntry.createContentEntryCrud)({
75
- context,
76
- getIdentity,
77
- getTenant,
78
- storageOperations
79
- }));
80
-
81
- if (!storageOperations.init) {
82
- return;
83
- }
84
-
85
- await storageOperations.init(context);
86
- });
87
- };
88
-
89
- exports.createCrud = createCrud;
package/crud/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["createCrud","params","storageOperations","ContextPlugin","context","getLocale","cms","getIdentity","security","getTenant","tenancy","getCurrentTenant","beforeInit","createSystemCrud","createSettingsCrud","createModelGroupsCrud","createModelsCrud","createContentEntryCrud","init"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { CmsContext, HeadlessCmsStorageOperations } from \"~/types\";\nimport { createModelGroupsCrud } from \"./contentModelGroup.crud\";\nimport { createModelsCrud } from \"./contentModel.crud\";\nimport { createContentEntryCrud } from \"./contentEntry.crud\";\nimport { createSystemCrud } from \"./system.crud\";\nimport { createSettingsCrud } from \"./settings.crud\";\n\nexport interface CrudParams {\n storageOperations: HeadlessCmsStorageOperations;\n}\n\nexport const createCrud = (params: CrudParams) => {\n const { storageOperations } = params;\n return new ContextPlugin<CmsContext>(async context => {\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const getIdentity = () => {\n return context.security.getIdentity();\n };\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n if (storageOperations.beforeInit) {\n await storageOperations.beforeInit(context);\n }\n\n context.cms = {\n ...context.cms,\n storageOperations,\n ...createSystemCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createSettingsCrud({\n context,\n getTenant,\n getLocale,\n storageOperations\n }),\n ...createModelGroupsCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createModelsCrud({\n context,\n getLocale,\n getTenant,\n getIdentity,\n storageOperations\n }),\n ...createContentEntryCrud({\n context,\n getIdentity,\n getTenant,\n storageOperations\n })\n };\n\n if (!storageOperations.init) {\n return;\n }\n await storageOperations.init(context);\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMO,MAAMA,UAAU,GAAIC,MAAD,IAAwB;EAC9C,MAAM;IAAEC;EAAF,IAAwBD,MAA9B;EACA,OAAO,IAAIE,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;IAClD,MAAMC,SAAS,GAAG,MAAM;MACpB,OAAOD,OAAO,CAACE,GAAR,CAAYD,SAAZ,EAAP;IACH,CAFD;;IAIA,MAAME,WAAW,GAAG,MAAM;MACtB,OAAOH,OAAO,CAACI,QAAR,CAAiBD,WAAjB,EAAP;IACH,CAFD;;IAIA,MAAME,SAAS,GAAG,MAAM;MACpB,OAAOL,OAAO,CAACM,OAAR,CAAgBC,gBAAhB,EAAP;IACH,CAFD;;IAIA,IAAIT,iBAAiB,CAACU,UAAtB,EAAkC;MAC9B,MAAMV,iBAAiB,CAACU,UAAlB,CAA6BR,OAA7B,CAAN;IACH;;IAEDA,OAAO,CAACE,GAAR,2FACOF,OAAO,CAACE,GADf;MAEIJ;IAFJ,GAGO,IAAAW,wBAAA,EAAiB;MAChBT,OADgB;MAEhBK,SAFgB;MAGhBJ,SAHgB;MAIhBE,WAJgB;MAKhBL;IALgB,CAAjB,CAHP,GAUO,IAAAY,4BAAA,EAAmB;MAClBV,OADkB;MAElBK,SAFkB;MAGlBJ,SAHkB;MAIlBH;IAJkB,CAAnB,CAVP,GAgBO,IAAAa,wCAAA,EAAsB;MACrBX,OADqB;MAErBK,SAFqB;MAGrBJ,SAHqB;MAIrBE,WAJqB;MAKrBL;IALqB,CAAtB,CAhBP,GAuBO,IAAAc,8BAAA,EAAiB;MAChBZ,OADgB;MAEhBC,SAFgB;MAGhBI,SAHgB;MAIhBF,WAJgB;MAKhBL;IALgB,CAAjB,CAvBP,GA8BO,IAAAe,oCAAA,EAAuB;MACtBb,OADsB;MAEtBG,WAFsB;MAGtBE,SAHsB;MAItBP;IAJsB,CAAvB,CA9BP;;IAsCA,IAAI,CAACA,iBAAiB,CAACgB,IAAvB,EAA6B;MACzB;IACH;;IACD,MAAMhB,iBAAiB,CAACgB,IAAlB,CAAuBd,OAAvB,CAAN;EACH,CA3DM,CAAP;AA4DH,CA9DM"}
@@ -1,7 +0,0 @@
1
- import { CmsEntryResolverFactory as ResolverFactory } from "../../../../types";
2
- interface ResolveRequestChangesArgs {
3
- revision: string;
4
- }
5
- declare type ResolveRequestChanges = ResolverFactory<any, ResolveRequestChangesArgs>;
6
- export declare const resolveRequestChanges: ResolveRequestChanges;
7
- export {};
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveRequestChanges = void 0;
7
-
8
- var _responses = require("@webiny/handler-graphql/responses");
9
-
10
- const resolveRequestChanges = ({
11
- model
12
- }) => async (_, args, context) => {
13
- try {
14
- const entry = await context.cms.requestEntryChanges(model, args.revision);
15
- return new _responses.Response(entry);
16
- } catch (e) {
17
- return new _responses.ErrorResponse(e);
18
- }
19
- };
20
-
21
- exports.resolveRequestChanges = resolveRequestChanges;
@@ -1 +0,0 @@
1
- {"version":3,"names":["resolveRequestChanges","model","_","args","context","entry","cms","requestEntryChanges","revision","Response","e","ErrorResponse"],"sources":["resolveRequestChanges.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql/responses\";\nimport { CmsEntryResolverFactory as ResolverFactory } from \"~/types\";\n\ninterface ResolveRequestChangesArgs {\n revision: string;\n}\ntype ResolveRequestChanges = ResolverFactory<any, ResolveRequestChangesArgs>;\n\nexport const resolveRequestChanges: ResolveRequestChanges =\n ({ model }) =>\n async (_, args: any, context) => {\n try {\n const entry = await context.cms.requestEntryChanges(model, args.revision);\n\n return new Response(entry);\n } catch (e) {\n return new ErrorResponse(e);\n }\n };\n"],"mappings":";;;;;;;AAAA;;AAQO,MAAMA,qBAA4C,GACrD,CAAC;EAAEC;AAAF,CAAD,KACA,OAAOC,CAAP,EAAUC,IAAV,EAAqBC,OAArB,KAAiC;EAC7B,IAAI;IACA,MAAMC,KAAK,GAAG,MAAMD,OAAO,CAACE,GAAR,CAAYC,mBAAZ,CAAgCN,KAAhC,EAAuCE,IAAI,CAACK,QAA5C,CAApB;IAEA,OAAO,IAAIC,mBAAJ,CAAaJ,KAAb,CAAP;EACH,CAJD,CAIE,OAAOK,CAAP,EAAU;IACR,OAAO,IAAIC,wBAAJ,CAAkBD,CAAlB,CAAP;EACH;AACJ,CAVE"}
@@ -1,7 +0,0 @@
1
- import { CmsEntryResolverFactory as ResolverFactory } from "../../../../types";
2
- interface ResolveRequestReviewArgs {
3
- revision: string;
4
- }
5
- declare type ResolveRequestReview = ResolverFactory<any, ResolveRequestReviewArgs>;
6
- export declare const resolveRequestReview: ResolveRequestReview;
7
- export {};
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveRequestReview = void 0;
7
-
8
- var _responses = require("@webiny/handler-graphql/responses");
9
-
10
- const resolveRequestReview = ({
11
- model
12
- }) => async (_, args, context) => {
13
- try {
14
- const entry = await context.cms.requestEntryReview(model, args.revision);
15
- return new _responses.Response(entry);
16
- } catch (e) {
17
- return new _responses.ErrorResponse(e);
18
- }
19
- };
20
-
21
- exports.resolveRequestReview = resolveRequestReview;
@@ -1 +0,0 @@
1
- {"version":3,"names":["resolveRequestReview","model","_","args","context","entry","cms","requestEntryReview","revision","Response","e","ErrorResponse"],"sources":["resolveRequestReview.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql/responses\";\nimport { CmsEntryResolverFactory as ResolverFactory } from \"~/types\";\n\ninterface ResolveRequestReviewArgs {\n revision: string;\n}\ntype ResolveRequestReview = ResolverFactory<any, ResolveRequestReviewArgs>;\n\nexport const resolveRequestReview: ResolveRequestReview =\n ({ model }) =>\n async (_, args: any, context) => {\n try {\n const entry = await context.cms.requestEntryReview(model, args.revision);\n\n return new Response(entry);\n } catch (e) {\n return new ErrorResponse(e);\n }\n };\n"],"mappings":";;;;;;;AAAA;;AAQO,MAAMA,oBAA0C,GACnD,CAAC;EAAEC;AAAF,CAAD,KACA,OAAOC,CAAP,EAAUC,IAAV,EAAqBC,OAArB,KAAiC;EAC7B,IAAI;IACA,MAAMC,KAAK,GAAG,MAAMD,OAAO,CAACE,GAAR,CAAYC,kBAAZ,CAA+BN,KAA/B,EAAsCE,IAAI,CAACK,QAA3C,CAApB;IAEA,OAAO,IAAIC,mBAAJ,CAAaJ,KAAb,CAAP;EACH,CAJD,CAIE,OAAOK,CAAP,EAAU;IACR,OAAO,IAAIC,wBAAJ,CAAkBD,CAAlB,CAAP;EACH;AACJ,CAVE"}