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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/context.d.ts +5 -2
  2. package/context.js +61 -8
  3. package/context.js.map +1 -1
  4. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  5. package/crud/contentEntry/markLockedFields.js +17 -4
  6. package/crud/contentEntry/markLockedFields.js.map +1 -1
  7. package/crud/contentEntry/referenceFieldsMapping.js +40 -9
  8. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  9. package/crud/contentEntry/searchableFields.d.ts +9 -0
  10. package/crud/contentEntry/searchableFields.js +72 -0
  11. package/crud/contentEntry/searchableFields.js.map +1 -0
  12. package/crud/contentEntry.crud.d.ts +8 -5
  13. package/crud/contentEntry.crud.js +1081 -841
  14. package/crud/contentEntry.crud.js.map +1 -1
  15. package/crud/contentModel/beforeCreate.d.ts +2 -3
  16. package/crud/contentModel/beforeCreate.js +43 -81
  17. package/crud/contentModel/beforeCreate.js.map +1 -1
  18. package/crud/contentModel/beforeDelete.d.ts +1 -1
  19. package/crud/contentModel/beforeDelete.js +1 -5
  20. package/crud/contentModel/beforeDelete.js.map +1 -1
  21. package/crud/contentModel/beforeUpdate.d.ts +2 -4
  22. package/crud/contentModel/beforeUpdate.js +33 -5
  23. package/crud/contentModel/beforeUpdate.js.map +1 -1
  24. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  25. package/crud/contentModel/compatibility/modelApiName.js +24 -0
  26. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  27. package/crud/contentModel/createFieldStorageId.js +4 -1
  28. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  29. package/crud/contentModel/defaultFields.d.ts +5 -0
  30. package/crud/contentModel/defaultFields.js +58 -0
  31. package/crud/contentModel/defaultFields.js.map +1 -0
  32. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  33. package/crud/contentModel/fields/descriptionField.js +42 -0
  34. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  35. package/crud/contentModel/fields/imageField.d.ts +2 -0
  36. package/crud/contentModel/fields/imageField.js +46 -0
  37. package/crud/contentModel/fields/imageField.js.map +1 -0
  38. package/crud/contentModel/fields/titleField.d.ts +2 -0
  39. package/crud/contentModel/fields/titleField.js +58 -0
  40. package/crud/contentModel/fields/titleField.js.map +1 -0
  41. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  42. package/crud/contentModel/validate/endingAllowed.js +26 -0
  43. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  44. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  45. package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
  46. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  47. package/crud/contentModel/validate/modelId.d.ts +11 -0
  48. package/crud/contentModel/validate/modelId.js +36 -0
  49. package/crud/contentModel/validate/modelId.js.map +1 -0
  50. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  51. package/crud/contentModel/validate/pluralApiName.js +24 -0
  52. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  53. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  54. package/crud/contentModel/validate/singularApiName.js +24 -0
  55. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  56. package/crud/contentModel/validateModel.d.ts +4 -4
  57. package/crud/contentModel/validateModel.js +6 -3
  58. package/crud/contentModel/validateModel.js.map +1 -1
  59. package/crud/contentModel/validateModelFields.d.ts +4 -4
  60. package/crud/contentModel/validateModelFields.js +123 -88
  61. package/crud/contentModel/validateModelFields.js.map +1 -1
  62. package/crud/contentModel/validation.d.ts +551 -0
  63. package/crud/contentModel/validation.js +145 -0
  64. package/crud/contentModel/validation.js.map +1 -0
  65. package/crud/contentModel.crud.js +369 -273
  66. package/crud/contentModel.crud.js.map +1 -1
  67. package/crud/contentModelGroup/validation.d.ts +30 -0
  68. package/crud/contentModelGroup/validation.js +34 -0
  69. package/crud/contentModelGroup/validation.js.map +1 -0
  70. package/crud/contentModelGroup.crud.js +189 -172
  71. package/crud/contentModelGroup.crud.js.map +1 -1
  72. package/crud/settings.crud.d.ts +1 -1
  73. package/crud/settings.crud.js +5 -10
  74. package/crud/settings.crud.js.map +1 -1
  75. package/crud/system.crud.js +0 -60
  76. package/crud/system.crud.js.map +1 -1
  77. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
  78. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
  79. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
  80. package/fieldConverters/index.d.ts +2 -1
  81. package/fieldConverters/index.js +2 -1
  82. package/fieldConverters/index.js.map +1 -1
  83. package/graphql/buildSchemaPlugins.d.ts +8 -3
  84. package/graphql/buildSchemaPlugins.js +3 -7
  85. package/graphql/buildSchemaPlugins.js.map +1 -1
  86. package/graphql/checkEndpointAccess.d.ts +2 -0
  87. package/graphql/checkEndpointAccess.js +18 -0
  88. package/graphql/checkEndpointAccess.js.map +1 -0
  89. package/graphql/createExecutableSchema.d.ts +6 -0
  90. package/graphql/createExecutableSchema.js +29 -0
  91. package/graphql/createExecutableSchema.js.map +1 -0
  92. package/graphql/createRequestBody.d.ts +2 -0
  93. package/graphql/createRequestBody.js +14 -0
  94. package/graphql/createRequestBody.js.map +1 -0
  95. package/graphql/formatErrorPayload.d.ts +1 -0
  96. package/graphql/formatErrorPayload.js +25 -0
  97. package/graphql/formatErrorPayload.js.map +1 -0
  98. package/graphql/generateSchema.d.ts +8 -0
  99. package/graphql/generateSchema.js +31 -0
  100. package/graphql/generateSchema.js.map +1 -0
  101. package/graphql/getSchema.d.ts +17 -0
  102. package/graphql/getSchema.js +102 -0
  103. package/graphql/getSchema.js.map +1 -0
  104. package/graphql/graphQLHandlerFactory.js +6 -104
  105. package/graphql/graphQLHandlerFactory.js.map +1 -1
  106. package/graphql/handleRequest.d.ts +11 -0
  107. package/graphql/handleRequest.js +81 -0
  108. package/graphql/handleRequest.js.map +1 -0
  109. package/graphql/index.d.ts +1 -3
  110. package/graphql/index.js +2 -39
  111. package/graphql/index.js.map +1 -1
  112. package/graphql/schema/baseContentSchema.d.ts +6 -2
  113. package/graphql/schema/baseContentSchema.js +9 -11
  114. package/graphql/schema/baseContentSchema.js.map +1 -1
  115. package/graphql/schema/baseSchema.d.ts +3 -0
  116. package/graphql/schema/baseSchema.js +68 -0
  117. package/graphql/schema/baseSchema.js.map +1 -0
  118. package/graphql/schema/contentEntries.d.ts +6 -2
  119. package/graphql/schema/contentEntries.js +116 -65
  120. package/graphql/schema/contentEntries.js.map +1 -1
  121. package/graphql/schema/contentModelGroups.d.ts +6 -2
  122. package/graphql/schema/contentModelGroups.js +14 -10
  123. package/graphql/schema/contentModelGroups.js.map +1 -1
  124. package/graphql/schema/contentModels.d.ts +6 -2
  125. package/graphql/schema/contentModels.js +60 -8
  126. package/graphql/schema/contentModels.js.map +1 -1
  127. package/graphql/schema/createFieldResolvers.d.ts +2 -2
  128. package/graphql/schema/createFieldResolvers.js +18 -13
  129. package/graphql/schema/createFieldResolvers.js.map +1 -1
  130. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  131. package/graphql/schema/createFieldTypePluginRecords.js +13 -0
  132. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  133. package/graphql/schema/createManageResolvers.d.ts +1 -1
  134. package/graphql/schema/createManageResolvers.js +37 -17
  135. package/graphql/schema/createManageResolvers.js.map +1 -1
  136. package/graphql/schema/createManageSDL.d.ts +3 -0
  137. package/graphql/schema/createManageSDL.js +81 -63
  138. package/graphql/schema/createManageSDL.js.map +1 -1
  139. package/graphql/schema/createPreviewResolvers.js +3 -7
  140. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  141. package/graphql/schema/createReadResolvers.js +8 -7
  142. package/graphql/schema/createReadResolvers.js.map +1 -1
  143. package/graphql/schema/createReadSDL.d.ts +3 -0
  144. package/graphql/schema/createReadSDL.js +47 -36
  145. package/graphql/schema/createReadSDL.js.map +1 -1
  146. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
  147. package/graphql/schema/resolvers/commonFieldResolvers.js +2 -1
  148. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
  149. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  150. package/graphql/schema/resolvers/manage/resolveDelete.js +13 -3
  151. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  152. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  153. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
  154. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  155. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  156. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
  157. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  158. package/graphql/schema/schemaPlugins.d.ts +8 -3
  159. package/graphql/schema/schemaPlugins.js +55 -52
  160. package/graphql/schema/schemaPlugins.js.map +1 -1
  161. package/graphql/system.js +55 -74
  162. package/graphql/system.js.map +1 -1
  163. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
  164. package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
  165. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
  166. package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
  167. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
  168. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
  169. package/graphqlFields/dynamicZone/index.d.ts +2 -0
  170. package/graphqlFields/dynamicZone/index.js +19 -0
  171. package/graphqlFields/dynamicZone/index.js.map +1 -0
  172. package/graphqlFields/index.d.ts +1 -1
  173. package/graphqlFields/index.js +2 -1
  174. package/graphqlFields/index.js.map +1 -1
  175. package/graphqlFields/number.js +4 -0
  176. package/graphqlFields/number.js.map +1 -1
  177. package/graphqlFields/object.js +131 -68
  178. package/graphqlFields/object.js.map +1 -1
  179. package/graphqlFields/ref.js +70 -56
  180. package/graphqlFields/ref.js.map +1 -1
  181. package/index.d.ts +5 -3
  182. package/index.js +27 -8
  183. package/index.js.map +1 -1
  184. package/package.json +40 -41
  185. package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
  186. package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
  187. package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
  188. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
  189. package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
  190. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
  191. package/plugins/CmsModelFieldConverterPlugin.d.ts +2 -2
  192. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  193. package/plugins/CmsModelPlugin.d.ts +21 -3
  194. package/plugins/CmsModelPlugin.js +28 -2
  195. package/plugins/CmsModelPlugin.js.map +1 -1
  196. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  197. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  198. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  199. package/plugins/StorageTransformPlugin.d.ts +11 -11
  200. package/plugins/StorageTransformPlugin.js.map +1 -1
  201. package/plugins/index.d.ts +3 -0
  202. package/plugins/index.js +33 -0
  203. package/plugins/index.js.map +1 -1
  204. package/storage/object.js +4 -2
  205. package/storage/object.js.map +1 -1
  206. package/types.d.ts +436 -149
  207. package/types.js +74 -8
  208. package/types.js.map +1 -1
  209. package/utils/converters/ConverterCollection.js +5 -2
  210. package/utils/converters/ConverterCollection.js.map +1 -1
  211. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  212. package/utils/converters/valueKeyStorageConverter.js +26 -20
  213. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  214. package/utils/createTypeFromFields.d.ts +16 -0
  215. package/utils/createTypeFromFields.js +66 -0
  216. package/utils/createTypeFromFields.js.map +1 -0
  217. package/utils/createTypeName.d.ts +0 -2
  218. package/utils/createTypeName.js +4 -11
  219. package/utils/createTypeName.js.map +1 -1
  220. package/utils/entryStorage.js +14 -11
  221. package/utils/entryStorage.js.map +1 -1
  222. package/utils/getBaseFieldType.d.ts +2 -0
  223. package/utils/getBaseFieldType.js +10 -0
  224. package/utils/getBaseFieldType.js.map +1 -0
  225. package/utils/getEntryDescription.d.ts +2 -0
  226. package/utils/getEntryDescription.js +17 -0
  227. package/utils/getEntryDescription.js.map +1 -0
  228. package/utils/getEntryImage.d.ts +2 -0
  229. package/utils/getEntryImage.js +17 -0
  230. package/utils/getEntryImage.js.map +1 -0
  231. package/utils/getEntryTitle.d.ts +1 -1
  232. package/utils/getEntryTitle.js.map +1 -1
  233. package/utils/getSchemaFromFieldPlugins.d.ts +4 -7
  234. package/utils/getSchemaFromFieldPlugins.js +22 -14
  235. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  236. package/utils/incrementEntryIdVersion.d.ts +5 -0
  237. package/utils/incrementEntryIdVersion.js +29 -0
  238. package/utils/incrementEntryIdVersion.js.map +1 -0
  239. package/utils/ownership.d.ts +3 -3
  240. package/utils/ownership.js.map +1 -1
  241. package/utils/renderFields.d.ts +4 -2
  242. package/utils/renderFields.js +12 -3
  243. package/utils/renderFields.js.map +1 -1
  244. package/utils/renderGetFilterFields.d.ts +2 -2
  245. package/utils/renderGetFilterFields.js +9 -19
  246. package/utils/renderGetFilterFields.js.map +1 -1
  247. package/utils/renderInputFields.d.ts +4 -2
  248. package/utils/renderInputFields.js +19 -6
  249. package/utils/renderInputFields.js.map +1 -1
  250. package/utils/renderListFilterFields.d.ts +2 -1
  251. package/utils/renderListFilterFields.js +12 -21
  252. package/utils/renderListFilterFields.js.map +1 -1
  253. package/utils/renderSortEnum.d.ts +9 -5
  254. package/utils/renderSortEnum.js +23 -5
  255. package/utils/renderSortEnum.js.map +1 -1
  256. package/validators/dynamicZone.d.ts +2 -0
  257. package/validators/dynamicZone.js +20 -0
  258. package/validators/dynamicZone.js.map +1 -0
  259. package/validators/index.js +2 -1
  260. package/validators/index.js.map +1 -1
  261. package/crud/contentModel/createFieldModels.d.ts +0 -2
  262. package/crud/contentModel/createFieldModels.js +0 -20
  263. package/crud/contentModel/createFieldModels.js.map +0 -1
  264. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  265. package/crud/contentModel/fieldIdValidation.js +0 -20
  266. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  267. package/crud/contentModel/idValidation.d.ts +0 -1
  268. package/crud/contentModel/idValidation.js +0 -17
  269. package/crud/contentModel/idValidation.js.map +0 -1
  270. package/crud/contentModel/models.d.ts +0 -4
  271. package/crud/contentModel/models.js +0 -173
  272. package/crud/contentModel/models.js.map +0 -1
  273. package/crud/contentModel/systemFields.d.ts +0 -1
  274. package/crud/contentModel/systemFields.js +0 -8
  275. package/crud/contentModel/systemFields.js.map +0 -1
  276. package/crud/index.d.ts +0 -6
  277. package/crud/index.js +0 -69
  278. package/crud/index.js.map +0 -1
  279. package/graphql/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -7
  280. package/graphql/schema/resolvers/manage/resolveRequestChanges.js +0 -21
  281. package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
  282. package/graphql/schema/resolvers/manage/resolveRequestReview.d.ts +0 -7
  283. package/graphql/schema/resolvers/manage/resolveRequestReview.js +0 -21
  284. package/graphql/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
  285. package/upgrades/5.33.0/index.d.ts +0 -3
  286. package/upgrades/5.33.0/index.js +0 -159
  287. package/upgrades/5.33.0/index.js.map +0 -1
  288. package/upgrades/index.d.ts +0 -1
  289. package/upgrades/index.js +0 -9
  290. package/upgrades/index.js.map +0 -1
  291. package/utils/filterModelFields.d.ts +0 -16
  292. package/utils/filterModelFields.js +0 -71
  293. package/utils/filterModelFields.js.map +0 -1
  294. package/utils/pluralizedTypeName.d.ts +0 -1
  295. package/utils/pluralizedTypeName.js +0 -20
  296. package/utils/pluralizedTypeName.js.map +0 -1
@@ -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 {};
@@ -4,12 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderFields = exports.renderField = void 0;
7
+ var _getBaseFieldType = require("./getBaseFieldType");
7
8
  const renderFields = ({
9
+ models,
8
10
  model,
11
+ fields,
9
12
  type,
10
13
  fieldTypePlugins
11
14
  }) => {
12
- return model.fields.map(field => renderField({
15
+ return fields.map(field => renderField({
16
+ models,
13
17
  model,
14
18
  type,
15
19
  field,
@@ -18,17 +22,22 @@ const renderFields = ({
18
22
  };
19
23
  exports.renderFields = renderFields;
20
24
  const renderField = ({
25
+ models,
21
26
  model,
22
27
  type,
23
28
  field,
24
29
  fieldTypePlugins
25
30
  }) => {
26
- const plugin = fieldTypePlugins[field.type];
31
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
27
32
  if (!plugin) {
28
33
  // Let's not render the field if it does not exist in the field plugins.
29
34
  return null;
30
35
  }
31
- const defs = plugin[type].createTypeField({
36
+ const {
37
+ createTypeField
38
+ } = plugin[type];
39
+ const defs = createTypeField({
40
+ models,
32
41
  model,
33
42
  field,
34
43
  fieldTypePlugins
@@ -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,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,CAACG,KAAK,CAACJ,IAAI,CAAC;EACzE,IAAI,CAACQ,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EACA,MAAMC,IAAI,GAAGD,MAAM,CAACR,IAAI,CAAC,CAACU,eAAe,CAAC;IACtCX,KAAK;IACLK,KAAK;IACLH;EACJ,CAAC,CAAC;EAEF,IAAI,CAACQ,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACjC,OAAO;MACHP,MAAM,EAAEO;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 {
@@ -4,39 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderGetFilterFields = void 0;
7
- const getCreateFilters = (plugins, fieldType) => {
8
- if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
9
- return null;
10
- }
11
- return plugins[fieldType].read.createGetFilters;
12
- };
7
+ var _getBaseFieldType = require("./getBaseFieldType");
13
8
  const renderGetFilterFields = ({
14
- model,
9
+ fields,
15
10
  fieldTypePlugins
16
11
  }) => {
17
- const fieldIdList = model.fields.filter(field => {
12
+ const filters = ["id: ID", "entryId: String"];
13
+ for (const field of fields) {
14
+ var _plugin$read;
18
15
  // Every time a client updates content model's fields, we check the type of each field. If a field plugin
19
16
  // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
20
17
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
21
18
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
22
19
  // could've just removed the plugin from the backend.
23
- if (!fieldTypePlugins[field.type]) {
24
- return false;
25
- }
26
- return fieldTypePlugins[field.type].isSearchable;
27
- }).map(f => f.fieldId);
28
- const filters = ["id: ID", "entryId: String"];
29
- for (const fieldId of fieldIdList) {
30
- const field = model.fields.find(item => item.fieldId === fieldId);
31
- if (!field) {
20
+ const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
21
+ const plugin = fieldTypePlugins[baseType];
22
+ if (!(plugin !== null && plugin !== void 0 && plugin.isSearchable)) {
32
23
  continue;
33
24
  }
34
- const createGetFilters = getCreateFilters(fieldTypePlugins, field.type);
25
+ const createGetFilters = (_plugin$read = plugin.read) === null || _plugin$read === void 0 ? void 0 : _plugin$read.createGetFilters;
35
26
  if (typeof createGetFilters !== "function") {
36
27
  continue;
37
28
  }
38
29
  filters.push(createGetFilters({
39
- model,
40
30
  field
41
31
  }));
42
32
  }
@@ -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,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,IAAI,CAACJ,gBAAgB,CAACI,KAAK,CAACC,IAAI,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IACA,OAAOL,gBAAgB,CAACI,KAAK,CAACC,IAAI,CAAC,CAACC,YAAY;EACpD,CAAC,CAAC,CACDC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC;EAExB,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMD,OAAO,IAAIR,WAAW,EAAE;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAM,CAACS,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACH,OAAO,KAAKA,OAAO,CAAC;IACjE,IAAI,CAACL,KAAK,EAAE;MACR;IACJ;IACA,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAgB,EAAEI,KAAK,CAACC,IAAI,CAAC;IACvE,IAAI,OAAOR,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAa,OAAO,CAACG,IAAI,CAAChB,gBAAgB,CAAC;MAAEE,KAAK;MAAEK;IAAM,CAAC,CAAC,CAAC;EACpD;EAEA,OAAOM,OAAO,CAACP,MAAM,CAACW,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 {};
@@ -4,18 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderInputFields = exports.renderInputField = void 0;
7
+ var _getBaseFieldType = require("./getBaseFieldType");
7
8
  const renderInputFields = ({
9
+ models,
8
10
  model,
11
+ fields,
9
12
  fieldTypePlugins
10
13
  }) => {
11
- return model.fields.map(field => renderInputField({
12
- model,
13
- field,
14
- fieldTypePlugins
15
- })).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
+ }, []);
16
27
  };
17
28
  exports.renderInputFields = renderInputFields;
18
29
  const renderInputField = ({
30
+ models,
19
31
  model,
20
32
  field,
21
33
  fieldTypePlugins
@@ -25,12 +37,13 @@ const renderInputField = ({
25
37
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
26
38
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
27
39
  // could've just removed the plugin from the backend.
28
- const plugin = fieldTypePlugins[field.type];
40
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
29
41
  if (!plugin) {
30
42
  // Let's not render the field if it does not exist in the field plugins.
31
43
  return null;
32
44
  }
33
45
  const def = plugin.manage.createInputField({
46
+ models,
34
47
  model,
35
48
  field,
36
49
  fieldTypePlugins
@@ -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,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,CAACG,KAAK,CAACK,IAAI,CAAC;EAEzE,IAAI,CAACD,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
  }
@@ -4,48 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderListFilterFields = void 0;
7
- /**
8
- * We cast as read type, because input and output of read and manage are same. This way we ease things.
9
- * Internal stuff so it should be ok.
10
- * TODO note that if changing read/manage types, change this as well.
11
- */
12
- const getCreateListFilters = (plugins, fieldType, type) => {
13
- if (!plugins[fieldType]) {
14
- return null;
15
- } else if (!plugins[fieldType][type]) {
16
- return null;
17
- }
18
- return plugins[fieldType][type].createListFilters;
19
- };
7
+ var _getBaseFieldType = require("./getBaseFieldType");
20
8
  const renderListFilterFields = params => {
21
9
  const {
22
10
  model,
11
+ fields,
23
12
  type,
24
13
  fieldTypePlugins
25
14
  } = params;
26
- 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")];
27
16
  /**
28
17
  * We can find different statuses only in the manage API endpoint.
29
18
  */
30
19
  if (type === "manage") {
31
- 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!]");
32
21
  }
33
- for (const field of model.fields) {
22
+ for (const field of fields) {
23
+ var _fieldTypePlugins$bas, _fieldTypePlugins$bas2;
34
24
  // Every time a client updates content model's fields, we check the type of each field. If a field plugin
35
25
  // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
36
26
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
37
27
  // that contains a field, for which we don't have a plugin registered on the backend. For example, user
38
28
  // could've just removed the plugin from the backend.
39
-
40
- const createListFilters = getCreateListFilters(fieldTypePlugins, field.type, 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;
41
31
  if (typeof createListFilters !== "function") {
42
32
  continue;
43
33
  }
44
- fields.push(createListFilters({
34
+ result.push(createListFilters({
45
35
  model,
46
- field
36
+ field,
37
+ plugins: fieldTypePlugins
47
38
  }));
48
39
  }
49
- return fields.filter(Boolean).join("\n");
40
+ return result.filter(Boolean).join("\n");
50
41
  };
51
42
  exports.renderListFilterFields = renderListFilterFields;
@@ -1 +1 @@
1
- {"version":3,"names":["getCreateListFilters","plugins","fieldType","type","createListFilters","renderListFilterFields","params","model","fieldTypePlugins","fields","join","push","field","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 * 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(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,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,CAACQ,gBAAgB,EAAEI,KAAK,CAACT,IAAI,EAAEA,IAAI,CAAC;IAClF,IAAI,OAAOC,iBAAiB,KAAK,UAAU,EAAE;MACzC;IACJ;IACAK,MAAM,CAACE,IAAI,CAACP,iBAAiB,CAAC;MAAEG,KAAK;MAAEK;IAAM,CAAC,CAAC,CAAC;EACpD;EAEA,OAAOH,MAAM,CAACI,MAAM,CAACC,OAAO,CAAC,CAACJ,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,9 +1,13 @@
1
- import { CmsFieldTypePlugins, CmsModel } from "../types";
1
+ import { CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
2
+ import { CmsGraphQLSchemaSorterPlugin } from "../plugins/CmsGraphQLSchemaSorterPlugin";
3
+ interface RenderSortEnumParams {
4
+ model: CmsModel;
5
+ fields: CmsModelField[];
6
+ fieldTypePlugins: CmsFieldTypePlugins;
7
+ sorterPlugins: CmsGraphQLSchemaSorterPlugin[];
8
+ }
2
9
  interface RenderSortEnum {
3
- (params: {
4
- model: CmsModel;
5
- fieldTypePlugins: CmsFieldTypePlugins;
6
- }): string;
10
+ (params: RenderSortEnumParams): string;
7
11
  }
8
12
  export declare const renderSortEnum: RenderSortEnum;
9
13
  export {};
@@ -4,15 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderSortEnum = void 0;
7
+ var _getBaseFieldType = require("./getBaseFieldType");
7
8
  const renderSortEnum = ({
8
9
  model,
9
- fieldTypePlugins
10
+ fields,
11
+ fieldTypePlugins,
12
+ sorterPlugins
10
13
  }) => {
11
- const sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
12
- for (const field of model.fields) {
13
- const plugin = fieldTypePlugins[field.type];
14
+ let sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
15
+ for (const field of fields) {
16
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
14
17
  if (!plugin) {
15
18
  continue;
19
+ } else if (plugin.createSorters) {
20
+ const result = plugin.createSorters({
21
+ model,
22
+ field,
23
+ sorters
24
+ });
25
+ if (result) {
26
+ sorters = result;
27
+ continue;
28
+ }
16
29
  }
17
30
  if (!plugin.isSortable) {
18
31
  continue;
@@ -20,6 +33,11 @@ const renderSortEnum = ({
20
33
  sorters.push(`${field.fieldId}_ASC`);
21
34
  sorters.push(`${field.fieldId}_DESC`);
22
35
  }
23
- return sorters.join("\n");
36
+ return sorterPlugins.reduce((result, plugin) => {
37
+ return plugin.createSorter({
38
+ model,
39
+ sorters: result
40
+ });
41
+ }, sorters).join("\n");
24
42
  };
25
43
  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,KAAK;EAAEC;AAAiB,CAAC,KAAa;EACnF,MAAMC,OAAiB,GAAG,CACrB,QAAO,EACP,SAAQ,EACT,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,CACnB;EAED,KAAK,MAAMC,KAAK,IAAIH,KAAK,CAACI,MAAM,EAAE;IAC9B,MAAMC,MAAM,GAAGJ,gBAAgB,CAACE,KAAK,CAACG,IAAI,CAAC;IAC3C,IAAI,CAACD,MAAM,EAAE;MACT;IACJ;IACA,IAAI,CAACA,MAAM,CAACE,UAAU,EAAE;MACpB;IACJ;IACAL,OAAO,CAACM,IAAI,CAAE,GAAEL,KAAK,CAACM,OAAQ,MAAK,CAAC;IACpCP,OAAO,CAACM,IAAI,CAAE,GAAEL,KAAK,CAACM,OAAQ,OAAM,CAAC;EACzC;EAEA,OAAOP,OAAO,CAACQ,IAAI,CAAC,IAAI,CAAC;AAC7B,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"}
@@ -0,0 +1,2 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../types";
2
+ export declare const createDynamicZoneValidator: () => CmsModelFieldValidatorPlugin;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createDynamicZoneValidator = void 0;
7
+ const createDynamicZoneValidator = () => {
8
+ return {
9
+ type: "cms-model-field-validator",
10
+ name: "cms-model-field-validator-dynamic-zone",
11
+ validator: {
12
+ name: "dynamicZone",
13
+ validate() {
14
+ // TODO: implement validation.
15
+ return Promise.resolve(true);
16
+ }
17
+ }
18
+ };
19
+ };
20
+ 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,2BAA2B;IACjCC,IAAI,EAAE,wCAAwC;IAC9CC,SAAS,EAAE;MACPD,IAAI,EAAE,aAAa;MACnBE,QAAQ,GAAG;QACP;QACA,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;MAChC;IACJ;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -17,5 +17,6 @@ var _dateGte = require("./dateGte");
17
17
  var _timeLte = require("./timeLte");
18
18
  var _timeGte = require("./timeGte");
19
19
  var _unique = require("./unique");
20
- 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)()];
20
+ var _dynamicZone = require("./dynamicZone");
21
+ 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)()];
21
22
  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,uBAAkB,GAAE,EACpB,IAAAC,qBAAiB,GAAE,EACnB,IAAAC,uBAAkB,GAAE,EACpB,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,iCAAuB,GAAE,EACzB,IAAAC,6CAA6B,GAAE,EAC/B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,6BAAqB,GAAE,CAC1B;AAAC"}
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,uBAAkB,GAAE,EACpB,IAAAC,qBAAiB,GAAE,EACnB,IAAAC,uBAAkB,GAAE,EACpB,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,iCAAuB,GAAE,EACzB,IAAAC,6CAA6B,GAAE,EAC/B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,6BAAqB,GAAE,EACvB,IAAAC,uCAA0B,GAAE,CAC/B;AAAC"}
@@ -1,2 +0,0 @@
1
- import { CmsModelField, CmsModelFieldInput } from "../../types";
2
- export declare const createFieldModels: (input?: CmsModelFieldInput[]) => Promise<CmsModelField[]>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFieldModels = void 0;
7
- var _models = require("./models");
8
- const createFieldModels = async input => {
9
- if (!input || input.length === 0) {
10
- return [];
11
- }
12
- const fields = [];
13
- for (const field of input) {
14
- const fieldData = new _models.ContentModelFieldModel().populate(field);
15
- await fieldData.validate();
16
- fields.push(await fieldData.toJSON());
17
- }
18
- return fields;
19
- };
20
- exports.createFieldModels = createFieldModels;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createFieldModels","input","length","fields","field","fieldData","ContentModelFieldModel","populate","validate","push","toJSON"],"sources":["createFieldModels.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldInput } from \"~/types\";\nimport { ContentModelFieldModel } from \"./models\";\n\nexport const createFieldModels = async (input?: CmsModelFieldInput[]): Promise<CmsModelField[]> => {\n if (!input || input.length === 0) {\n return [];\n }\n const fields: CmsModelField[] = [];\n for (const field of input) {\n const fieldData = new ContentModelFieldModel().populate(field);\n await fieldData.validate();\n fields.push(await fieldData.toJSON());\n }\n return fields;\n};\n"],"mappings":";;;;;;AACA;AAEO,MAAMA,iBAAiB,GAAG,MAAOC,KAA4B,IAA+B;EAC/F,IAAI,CAACA,KAAK,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IAC9B,OAAO,EAAE;EACb;EACA,MAAMC,MAAuB,GAAG,EAAE;EAClC,KAAK,MAAMC,KAAK,IAAIH,KAAK,EAAE;IACvB,MAAMI,SAAS,GAAG,IAAIC,8BAAsB,EAAE,CAACC,QAAQ,CAACH,KAAK,CAAC;IAC9D,MAAMC,SAAS,CAACG,QAAQ,EAAE;IAC1BL,MAAM,CAACM,IAAI,CAAC,MAAMJ,SAAS,CAACK,MAAM,EAAE,CAAC;EACzC;EACA,OAAOP,MAAM;AACjB,CAAC;AAAC"}
@@ -1 +0,0 @@
1
- export declare const validateFieldId: (input: string) => Promise<void>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validateFieldId = void 0;
7
- var _validation = require("@webiny/validation");
8
- var _systemFields = require("./systemFields");
9
- const validateFieldId = async input => {
10
- await _validation.validation.validate(input, "required,maxLength:100");
11
- const value = String(input || "").trim();
12
- if (!value.charAt(0).match(/^[a-zA-Z]/)) {
13
- throw new Error(`Provided ${value} is not valid - must not start with a number.`);
14
- } else if (value.match(/^([a-zA-Z0-9]+)$/) === null) {
15
- throw new Error(`Provided ${value} is not valid - must be alphanumeric string.`);
16
- } else if (_systemFields.fieldSystemFields.includes(value)) {
17
- throw new Error(`Provided ${value} is not valid - "${value}" is an auto-generated field.`);
18
- }
19
- };
20
- exports.validateFieldId = validateFieldId;