@webiny/api-headless-cms 0.0.0-mt-1

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 (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/content/contextSetup.d.ts +4 -0
  4. package/content/contextSetup.js +65 -0
  5. package/content/graphQLHandlerFactory.d.ts +5 -0
  6. package/content/graphQLHandlerFactory.js +173 -0
  7. package/content/plugins/CmsGroupPlugin.d.ts +11 -0
  8. package/content/plugins/CmsGroupPlugin.js +24 -0
  9. package/content/plugins/CmsModelPlugin.d.ts +11 -0
  10. package/content/plugins/CmsModelPlugin.js +24 -0
  11. package/content/plugins/buildSchemaPlugins.d.ts +7 -0
  12. package/content/plugins/buildSchemaPlugins.js +29 -0
  13. package/content/plugins/crud/contentEntry/afterDelete.d.ts +7 -0
  14. package/content/plugins/crud/contentEntry/afterDelete.js +41 -0
  15. package/content/plugins/crud/contentEntry/beforeCreate.d.ts +7 -0
  16. package/content/plugins/crud/contentEntry/beforeCreate.js +28 -0
  17. package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +7 -0
  18. package/content/plugins/crud/contentEntry/beforeUpdate.js +28 -0
  19. package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +4 -0
  20. package/content/plugins/crud/contentEntry/entryDataValidation.js +188 -0
  21. package/content/plugins/crud/contentEntry/markLockedFields.d.ts +12 -0
  22. package/content/plugins/crud/contentEntry/markLockedFields.js +117 -0
  23. package/content/plugins/crud/contentEntry.crud.d.ts +17 -0
  24. package/content/plugins/crud/contentEntry.crud.js +931 -0
  25. package/content/plugins/crud/contentModel/afterCreate.d.ts +7 -0
  26. package/content/plugins/crud/contentModel/afterCreate.js +18 -0
  27. package/content/plugins/crud/contentModel/afterDelete.d.ts +7 -0
  28. package/content/plugins/crud/contentModel/afterDelete.js +18 -0
  29. package/content/plugins/crud/contentModel/afterUpdate.d.ts +7 -0
  30. package/content/plugins/crud/contentModel/afterUpdate.js +18 -0
  31. package/content/plugins/crud/contentModel/beforeCreate.d.ts +9 -0
  32. package/content/plugins/crud/contentModel/beforeCreate.js +146 -0
  33. package/content/plugins/crud/contentModel/beforeDelete.d.ts +9 -0
  34. package/content/plugins/crud/contentModel/beforeDelete.js +56 -0
  35. package/content/plugins/crud/contentModel/beforeUpdate.d.ts +9 -0
  36. package/content/plugins/crud/contentModel/beforeUpdate.js +128 -0
  37. package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
  38. package/content/plugins/crud/contentModel/contentModelManagerFactory.js +29 -0
  39. package/content/plugins/crud/contentModel/createFieldModels.d.ts +2 -0
  40. package/content/plugins/crud/contentModel/createFieldModels.js +22 -0
  41. package/content/plugins/crud/contentModel/idValidation.d.ts +2 -0
  42. package/content/plugins/crud/contentModel/idValidation.js +22 -0
  43. package/content/plugins/crud/contentModel/models.d.ts +3 -0
  44. package/content/plugins/crud/contentModel/models.js +141 -0
  45. package/content/plugins/crud/contentModel/validateLayout.d.ts +2 -0
  46. package/content/plugins/crud/contentModel/validateLayout.js +38 -0
  47. package/content/plugins/crud/contentModel.crud.d.ts +12 -0
  48. package/content/plugins/crud/contentModel.crud.js +425 -0
  49. package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +9 -0
  50. package/content/plugins/crud/contentModelGroup/beforeCreate.js +66 -0
  51. package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +9 -0
  52. package/content/plugins/crud/contentModelGroup/beforeDelete.js +48 -0
  53. package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +8 -0
  54. package/content/plugins/crud/contentModelGroup/beforeUpdate.js +28 -0
  55. package/content/plugins/crud/contentModelGroup.crud.d.ts +12 -0
  56. package/content/plugins/crud/contentModelGroup.crud.js +351 -0
  57. package/content/plugins/crud/index.d.ts +6 -0
  58. package/content/plugins/crud/index.js +100 -0
  59. package/content/plugins/graphqlFields/boolean.d.ts +3 -0
  60. package/content/plugins/graphqlFields/boolean.js +69 -0
  61. package/content/plugins/graphqlFields/datetime.d.ts +3 -0
  62. package/content/plugins/graphqlFields/datetime.js +83 -0
  63. package/content/plugins/graphqlFields/file.d.ts +3 -0
  64. package/content/plugins/graphqlFields/file.js +49 -0
  65. package/content/plugins/graphqlFields/index.d.ts +2 -0
  66. package/content/plugins/graphqlFields/index.js +30 -0
  67. package/content/plugins/graphqlFields/longText.d.ts +3 -0
  68. package/content/plugins/graphqlFields/longText.js +62 -0
  69. package/content/plugins/graphqlFields/number.d.ts +3 -0
  70. package/content/plugins/graphqlFields/number.js +75 -0
  71. package/content/plugins/graphqlFields/object.d.ts +3 -0
  72. package/content/plugins/graphqlFields/object.js +180 -0
  73. package/content/plugins/graphqlFields/ref.d.ts +3 -0
  74. package/content/plugins/graphqlFields/ref.js +205 -0
  75. package/content/plugins/graphqlFields/richText.d.ts +3 -0
  76. package/content/plugins/graphqlFields/richText.js +55 -0
  77. package/content/plugins/graphqlFields/text.d.ts +3 -0
  78. package/content/plugins/graphqlFields/text.js +72 -0
  79. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +8 -0
  80. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +54 -0
  81. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +7 -0
  82. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +35 -0
  83. package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +15 -0
  84. package/content/plugins/modelManager/DefaultCmsModelManager.js +62 -0
  85. package/content/plugins/modelManager/index.d.ts +3 -0
  86. package/content/plugins/modelManager/index.js +20 -0
  87. package/content/plugins/schema/baseSchema.d.ts +4 -0
  88. package/content/plugins/schema/baseSchema.js +98 -0
  89. package/content/plugins/schema/contentEntries.d.ts +4 -0
  90. package/content/plugins/schema/contentEntries.js +166 -0
  91. package/content/plugins/schema/contentModelGroups.d.ts +4 -0
  92. package/content/plugins/schema/contentModelGroups.js +153 -0
  93. package/content/plugins/schema/contentModels.d.ts +4 -0
  94. package/content/plugins/schema/contentModels.js +225 -0
  95. package/content/plugins/schema/createFieldResolvers.d.ts +19 -0
  96. package/content/plugins/schema/createFieldResolvers.js +92 -0
  97. package/content/plugins/schema/createManageResolvers.d.ts +11 -0
  98. package/content/plugins/schema/createManageResolvers.js +135 -0
  99. package/content/plugins/schema/createManageSDL.d.ts +9 -0
  100. package/content/plugins/schema/createManageSDL.js +153 -0
  101. package/content/plugins/schema/createPreviewResolvers.d.ts +10 -0
  102. package/content/plugins/schema/createPreviewResolvers.js +55 -0
  103. package/content/plugins/schema/createReadResolvers.d.ts +10 -0
  104. package/content/plugins/schema/createReadResolvers.js +55 -0
  105. package/content/plugins/schema/createReadSDL.d.ts +9 -0
  106. package/content/plugins/schema/createReadSDL.js +96 -0
  107. package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +6 -0
  108. package/content/plugins/schema/resolvers/commonFieldResolvers.js +14 -0
  109. package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +6 -0
  110. package/content/plugins/schema/resolvers/manage/resolveCreate.js +23 -0
  111. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +7 -0
  112. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +23 -0
  113. package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +2 -0
  114. package/content/plugins/schema/resolvers/manage/resolveDelete.js +30 -0
  115. package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +2 -0
  116. package/content/plugins/schema/resolvers/manage/resolveGet.js +21 -0
  117. package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +2 -0
  118. package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +23 -0
  119. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +2 -0
  120. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +23 -0
  121. package/content/plugins/schema/resolvers/manage/resolveList.d.ts +2 -0
  122. package/content/plugins/schema/resolvers/manage/resolveList.js +23 -0
  123. package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +2 -0
  124. package/content/plugins/schema/resolvers/manage/resolvePublish.js +21 -0
  125. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +6 -0
  126. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +23 -0
  127. package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +6 -0
  128. package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +23 -0
  129. package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +2 -0
  130. package/content/plugins/schema/resolvers/manage/resolveUnpublish.js +21 -0
  131. package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +7 -0
  132. package/content/plugins/schema/resolvers/manage/resolveUpdate.js +23 -0
  133. package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +2 -0
  134. package/content/plugins/schema/resolvers/preview/resolveGet.js +38 -0
  135. package/content/plugins/schema/resolvers/preview/resolveList.d.ts +2 -0
  136. package/content/plugins/schema/resolvers/preview/resolveList.js +23 -0
  137. package/content/plugins/schema/resolvers/read/resolveGet.d.ts +2 -0
  138. package/content/plugins/schema/resolvers/read/resolveGet.js +38 -0
  139. package/content/plugins/schema/resolvers/read/resolveList.d.ts +2 -0
  140. package/content/plugins/schema/resolvers/read/resolveList.js +23 -0
  141. package/content/plugins/schema/schemaPlugins.d.ts +3 -0
  142. package/content/plugins/schema/schemaPlugins.js +92 -0
  143. package/content/plugins/storage/StorageTransformPlugin.d.ts +30 -0
  144. package/content/plugins/storage/StorageTransformPlugin.js +36 -0
  145. package/content/plugins/storage/default.d.ts +3 -0
  146. package/content/plugins/storage/default.js +28 -0
  147. package/content/plugins/storage/object.d.ts +3 -0
  148. package/content/plugins/storage/object.js +119 -0
  149. package/content/plugins/utils/createTypeName.d.ts +3 -0
  150. package/content/plugins/utils/createTypeName.js +28 -0
  151. package/content/plugins/utils/entryStorage.d.ts +17 -0
  152. package/content/plugins/utils/entryStorage.js +125 -0
  153. package/content/plugins/utils/getEntryTitle.d.ts +2 -0
  154. package/content/plugins/utils/getEntryTitle.js +42 -0
  155. package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +11 -0
  156. package/content/plugins/utils/getSchemaFromFieldPlugins.js +30 -0
  157. package/content/plugins/utils/pluralizedTypeName.d.ts +1 -0
  158. package/content/plugins/utils/pluralizedTypeName.js +26 -0
  159. package/content/plugins/utils/renderFields.d.ts +16 -0
  160. package/content/plugins/utils/renderFields.js +51 -0
  161. package/content/plugins/utils/renderGetFilterFields.d.ts +9 -0
  162. package/content/plugins/utils/renderGetFilterFields.js +41 -0
  163. package/content/plugins/utils/renderInputFields.d.ts +14 -0
  164. package/content/plugins/utils/renderInputFields.js +53 -0
  165. package/content/plugins/utils/renderListFilterFields.d.ts +10 -0
  166. package/content/plugins/utils/renderListFilterFields.js +39 -0
  167. package/content/plugins/utils/renderSortEnum.d.ts +9 -0
  168. package/content/plugins/utils/renderSortEnum.js +32 -0
  169. package/content/plugins/validators/dateGte.d.ts +3 -0
  170. package/content/plugins/validators/dateGte.js +37 -0
  171. package/content/plugins/validators/dateLte.d.ts +3 -0
  172. package/content/plugins/validators/dateLte.js +37 -0
  173. package/content/plugins/validators/gte.d.ts +3 -0
  174. package/content/plugins/validators/gte.js +32 -0
  175. package/content/plugins/validators/in.d.ts +3 -0
  176. package/content/plugins/validators/in.js +32 -0
  177. package/content/plugins/validators/index.d.ts +2 -0
  178. package/content/plugins/validators/index.js +36 -0
  179. package/content/plugins/validators/lte.d.ts +3 -0
  180. package/content/plugins/validators/lte.js +32 -0
  181. package/content/plugins/validators/maxLength.d.ts +3 -0
  182. package/content/plugins/validators/maxLength.js +32 -0
  183. package/content/plugins/validators/minLength.d.ts +3 -0
  184. package/content/plugins/validators/minLength.js +32 -0
  185. package/content/plugins/validators/pattern.d.ts +3 -0
  186. package/content/plugins/validators/pattern.js +47 -0
  187. package/content/plugins/validators/patternPlugins/email.d.ts +3 -0
  188. package/content/plugins/validators/patternPlugins/email.js +17 -0
  189. package/content/plugins/validators/patternPlugins/index.d.ts +2 -0
  190. package/content/plugins/validators/patternPlugins/index.js +19 -0
  191. package/content/plugins/validators/patternPlugins/lowerCase.d.ts +3 -0
  192. package/content/plugins/validators/patternPlugins/lowerCase.js +17 -0
  193. package/content/plugins/validators/patternPlugins/upperCase.d.ts +3 -0
  194. package/content/plugins/validators/patternPlugins/upperCase.js +17 -0
  195. package/content/plugins/validators/patternPlugins/url.d.ts +3 -0
  196. package/content/plugins/validators/patternPlugins/url.js +17 -0
  197. package/content/plugins/validators/required.d.ts +3 -0
  198. package/content/plugins/validators/required.js +25 -0
  199. package/content/plugins/validators/timeGte.d.ts +3 -0
  200. package/content/plugins/validators/timeGte.js +32 -0
  201. package/content/plugins/validators/timeLte.d.ts +3 -0
  202. package/content/plugins/validators/timeLte.js +32 -0
  203. package/index.d.ts +12 -0
  204. package/index.js +66 -0
  205. package/migrateCMSPermissions.d.ts +17 -0
  206. package/migrateCMSPermissions.js +193 -0
  207. package/package.json +80 -0
  208. package/plugins/context.d.ts +4 -0
  209. package/plugins/context.js +34 -0
  210. package/plugins/crud/index.d.ts +6 -0
  211. package/plugins/crud/index.js +100 -0
  212. package/plugins/crud/settings.crud.d.ts +10 -0
  213. package/plugins/crud/settings.crud.js +93 -0
  214. package/plugins/crud/system.crud.d.ts +10 -0
  215. package/plugins/crud/system.crud.js +182 -0
  216. package/plugins/graphql/system.d.ts +17 -0
  217. package/plugins/graphql/system.js +72 -0
  218. package/plugins/graphql.d.ts +2 -0
  219. package/plugins/graphql.js +79 -0
  220. package/plugins/upgrades/index.d.ts +2 -0
  221. package/plugins/upgrades/index.js +14 -0
  222. package/plugins/upgrades/v5.5.0/helpers.d.ts +6 -0
  223. package/plugins/upgrades/v5.5.0/helpers.js +10 -0
  224. package/plugins/upgrades/v5.5.0/index.d.ts +4 -0
  225. package/plugins/upgrades/v5.5.0/index.js +129 -0
  226. package/transformers.d.ts +2 -0
  227. package/transformers.js +25 -0
  228. package/types.d.ts +2149 -0
  229. package/types.js +366 -0
  230. package/utils.d.ts +25 -0
  231. package/utils.js +251 -0
@@ -0,0 +1 @@
1
+ export declare const pluralizedTypeName: (typeName: string) => any;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.pluralizedTypeName = void 0;
9
+
10
+ var _pluralize = _interopRequireDefault(require("pluralize"));
11
+
12
+ // This will make it so if the content model name is a single capitalized letter
13
+ // Ex. A, pluralizedTypeName will capitalize the name to As, instead of AS
14
+ const pluralizedTypeName = typeName => {
15
+ let pluralizedTypeName;
16
+
17
+ if (typeName.length === 1) {
18
+ pluralizedTypeName = `${typeName}s`;
19
+ } else {
20
+ pluralizedTypeName = (0, _pluralize.default)(typeName);
21
+ }
22
+
23
+ return pluralizedTypeName;
24
+ };
25
+
26
+ exports.pluralizedTypeName = pluralizedTypeName;
@@ -0,0 +1,16 @@
1
+ import { CmsFieldTypePlugins, CmsModel, CmsModelFieldDefinition } from "../../../types";
2
+ interface RenderFields {
3
+ (params: {
4
+ model: CmsModel;
5
+ type: string;
6
+ fieldTypePlugins: CmsFieldTypePlugins;
7
+ }): CmsModelFieldDefinition[];
8
+ }
9
+ export declare const renderFields: RenderFields;
10
+ export declare const renderField: ({ model, type, field, fieldTypePlugins }: {
11
+ model: any;
12
+ type: any;
13
+ field: any;
14
+ fieldTypePlugins: any;
15
+ }) => any;
16
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderFields = exports.renderField = void 0;
7
+
8
+ const renderFields = ({
9
+ model,
10
+ type,
11
+ fieldTypePlugins
12
+ }) => {
13
+ return model.fields.map(field => renderField({
14
+ model,
15
+ type,
16
+ field,
17
+ fieldTypePlugins
18
+ })).filter(Boolean);
19
+ };
20
+
21
+ exports.renderFields = renderFields;
22
+
23
+ const renderField = ({
24
+ model,
25
+ type,
26
+ field,
27
+ fieldTypePlugins
28
+ }) => {
29
+ const plugin = fieldTypePlugins[field.type];
30
+
31
+ if (!plugin) {
32
+ // Let's not render the field if it does not exist in the field plugins.
33
+ return;
34
+ }
35
+
36
+ const defs = plugin[type].createTypeField({
37
+ model,
38
+ field,
39
+ fieldTypePlugins
40
+ });
41
+
42
+ if (typeof defs === "string") {
43
+ return {
44
+ fields: defs
45
+ };
46
+ }
47
+
48
+ return defs;
49
+ };
50
+
51
+ exports.renderField = renderField;
@@ -0,0 +1,9 @@
1
+ import { CmsFieldTypePlugins, CmsModel } from "../../../types";
2
+ interface RenderGetFilterFields {
3
+ (params: {
4
+ model: CmsModel;
5
+ fieldTypePlugins: CmsFieldTypePlugins;
6
+ }): string;
7
+ }
8
+ export declare const renderGetFilterFields: RenderGetFilterFields;
9
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.renderGetFilterFields = void 0;
9
+
10
+ var _get = _interopRequireDefault(require("lodash/get"));
11
+
12
+ const renderGetFilterFields = ({
13
+ model,
14
+ fieldTypePlugins
15
+ }) => {
16
+ const fieldIds = model.fields.filter(f => {
17
+ // Every time a client updates content model's fields, we check the type of each field. If a field plugin
18
+ // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
19
+ // want to be careful when accessing the field plugin here too. It is still possible to have a content model
20
+ // that contains a field, for which we don't have a plugin registered on the backend. For example, user
21
+ // could've just removed the plugin from the backend.
22
+ return (0, _get.default)(fieldTypePlugins, `${f.type}.isSearchable`);
23
+ }).map(f => f.fieldId);
24
+ const filters = ["id: ID", "entryId: String"];
25
+
26
+ for (let i = 0; i < fieldIds.length; i++) {
27
+ const field = model.fields.find(item => item.fieldId === fieldIds[i]);
28
+ const createGetFilters = (0, _get.default)(fieldTypePlugins, `${field.type}.read.createGetFilters`);
29
+
30
+ if (typeof createGetFilters === "function") {
31
+ filters.push(createGetFilters({
32
+ model,
33
+ field
34
+ }));
35
+ }
36
+ }
37
+
38
+ return filters.filter(Boolean).join("\n");
39
+ };
40
+
41
+ exports.renderGetFilterFields = renderGetFilterFields;
@@ -0,0 +1,14 @@
1
+ import { CmsFieldTypePlugins, CmsModel, CmsModelFieldDefinition } from "../../../types";
2
+ interface RenderInputFields {
3
+ (params: {
4
+ model: CmsModel;
5
+ fieldTypePlugins: CmsFieldTypePlugins;
6
+ }): CmsModelFieldDefinition[];
7
+ }
8
+ export declare const renderInputFields: RenderInputFields;
9
+ export declare const renderInputField: ({ model, field, fieldTypePlugins }: {
10
+ model: any;
11
+ field: any;
12
+ fieldTypePlugins: any;
13
+ }) => CmsModelFieldDefinition;
14
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderInputFields = exports.renderInputField = void 0;
7
+
8
+ const renderInputFields = ({
9
+ model,
10
+ fieldTypePlugins
11
+ }) => {
12
+ return model.fields.map(field => renderInputField({
13
+ model,
14
+ field,
15
+ fieldTypePlugins
16
+ })).filter(Boolean);
17
+ };
18
+
19
+ exports.renderInputFields = renderInputFields;
20
+
21
+ const renderInputField = ({
22
+ model,
23
+ field,
24
+ fieldTypePlugins
25
+ }) => {
26
+ // Every time a client updates content model's fields, we check the type of each field. If a field plugin
27
+ // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
28
+ // want to be careful when accessing the field plugin here too. It is still possible to have a content model
29
+ // that contains a field, for which we don't have a plugin registered on the backend. For example, user
30
+ // could've just removed the plugin from the backend.
31
+ const plugin = fieldTypePlugins[field.type];
32
+
33
+ if (!plugin) {
34
+ // Let's not render the field if it does not exist in the field plugins.
35
+ return;
36
+ }
37
+
38
+ const def = plugin.manage.createInputField({
39
+ model,
40
+ field,
41
+ fieldTypePlugins
42
+ });
43
+
44
+ if (typeof def === "string") {
45
+ return {
46
+ fields: def
47
+ };
48
+ }
49
+
50
+ return def;
51
+ };
52
+
53
+ exports.renderInputField = renderInputField;
@@ -0,0 +1,10 @@
1
+ import { CmsFieldTypePlugins, CmsModel } from "../../../types";
2
+ interface RenderListFilterFields {
3
+ (params: {
4
+ model: CmsModel;
5
+ type: "read" | "manage";
6
+ fieldTypePlugins: CmsFieldTypePlugins;
7
+ }): string;
8
+ }
9
+ export declare const renderListFilterFields: RenderListFilterFields;
10
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.renderListFilterFields = void 0;
9
+
10
+ var _get = _interopRequireDefault(require("lodash/get"));
11
+
12
+ const renderListFilterFields = ({
13
+ model,
14
+ type,
15
+ fieldTypePlugins
16
+ }) => {
17
+ 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")];
18
+
19
+ for (let i = 0; i < model.fields.length; i++) {
20
+ const field = model.fields[i]; // Every time a client updates content model's fields, we check the type of each field. If a field plugin
21
+ // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
22
+ // want to be careful when accessing the field plugin here too. It is still possible to have a content model
23
+ // that contains a field, for which we don't have a plugin registered on the backend. For example, user
24
+ // could've just removed the plugin from the backend.
25
+
26
+ const createListFilters = (0, _get.default)(fieldTypePlugins, `${field.type}.${type}.createListFilters`);
27
+
28
+ if (typeof createListFilters === "function") {
29
+ fields.push(createListFilters({
30
+ model,
31
+ field
32
+ }));
33
+ }
34
+ }
35
+
36
+ return fields.filter(Boolean).join("\n");
37
+ };
38
+
39
+ exports.renderListFilterFields = renderListFilterFields;
@@ -0,0 +1,9 @@
1
+ import { CmsFieldTypePlugins, CmsModel } from "../../../types";
2
+ interface RenderSortEnum {
3
+ (params: {
4
+ model: CmsModel;
5
+ fieldTypePlugins: CmsFieldTypePlugins;
6
+ }): string;
7
+ }
8
+ export declare const renderSortEnum: RenderSortEnum;
9
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.renderSortEnum = void 0;
9
+
10
+ var _get = _interopRequireDefault(require("lodash/get"));
11
+
12
+ const renderSortEnum = ({
13
+ model,
14
+ fieldTypePlugins
15
+ }) => {
16
+ const sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
17
+ const fieldIds = model.fields.filter(f => {
18
+ // Every time a client updates content model's fields, we check the type of each field. If a field plugin
19
+ // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
20
+ // want to be careful when accessing the field plugin here too. It is still possible to have a content model
21
+ // that contains a field, for which we don't have a plugin registered on the backend. For example, user
22
+ // could've just removed the plugin from the backend.
23
+ return (0, _get.default)(fieldTypePlugins, `${f.type}.isSortable`);
24
+ }).map(f => f.fieldId);
25
+ fieldIds.forEach(fieldId => {
26
+ sorters.push(`${fieldId}_ASC`);
27
+ sorters.push(`${fieldId}_DESC`);
28
+ });
29
+ return sorters.join("\n");
30
+ };
31
+
32
+ exports.renderSortEnum = renderSortEnum;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const _default: () => CmsModelFieldValidatorPlugin;
3
+ export default _default;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ var _default = () => ({
11
+ type: "cms-model-field-validator",
12
+ name: "cms-model-field-validator-date-gte",
13
+ validator: {
14
+ name: "dateGte",
15
+
16
+ async validate({
17
+ value,
18
+ validator
19
+ }) {
20
+ const {
21
+ value: gteValue,
22
+ type
23
+ } = validator.settings;
24
+
25
+ if (typeof gteValue === "undefined") {
26
+ return true;
27
+ } else if (type === "time") {
28
+ return _validation.validation.validate(value, `timeGte:${gteValue}`).then(v => v === true).catch(() => false);
29
+ }
30
+
31
+ return _validation.validation.validate(value, `dateGte:${gteValue}`).then(v => v === true).catch(() => false);
32
+ }
33
+
34
+ }
35
+ });
36
+
37
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const _default: () => CmsModelFieldValidatorPlugin;
3
+ export default _default;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ var _default = () => ({
11
+ type: "cms-model-field-validator",
12
+ name: "cms-model-field-validator-date-lte",
13
+ validator: {
14
+ name: "dateLte",
15
+
16
+ async validate({
17
+ value,
18
+ validator
19
+ }) {
20
+ const {
21
+ value: lteValue,
22
+ type
23
+ } = validator.settings;
24
+
25
+ if (typeof lteValue === "undefined") {
26
+ return true;
27
+ } else if (type === "time") {
28
+ return _validation.validation.validate(value, `timeLte:${lteValue}`).then(v => v === true).catch(() => false);
29
+ }
30
+
31
+ return _validation.validation.validate(value, `dateLte:${lteValue}`).then(v => v === true).catch(() => false);
32
+ }
33
+
34
+ }
35
+ });
36
+
37
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const plugin: CmsModelFieldValidatorPlugin;
3
+ export default plugin;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ const plugin = {
11
+ type: "cms-model-field-validator",
12
+ name: "cms-model-field-validator-gte",
13
+ validator: {
14
+ name: "gte",
15
+
16
+ validate({
17
+ value,
18
+ validator
19
+ }) {
20
+ const gteValue = validator.settings.value;
21
+
22
+ if (typeof gteValue !== "undefined") {
23
+ return _validation.validation.validate(value, `gte:${gteValue}`).then(v => v === true).catch(() => false);
24
+ }
25
+
26
+ return Promise.resolve(true);
27
+ }
28
+
29
+ }
30
+ };
31
+ var _default = plugin;
32
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const plugin: CmsModelFieldValidatorPlugin;
3
+ export default plugin;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ const plugin = {
11
+ type: "cms-model-field-validator",
12
+ name: "cms-model-field-validator-in",
13
+ validator: {
14
+ name: "in",
15
+
16
+ validate({
17
+ value,
18
+ validator
19
+ }) {
20
+ const values = validator.settings.values;
21
+
22
+ if (Array.isArray(values)) {
23
+ return _validation.validation.validate(value, `in:${values.join(":")}`).then(v => v === true).catch(() => false);
24
+ }
25
+
26
+ return Promise.resolve(true);
27
+ }
28
+
29
+ }
30
+ };
31
+ var _default = plugin;
32
+ exports.default = _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => (import("../../../types").CmsModelFieldValidatorPlugin | import("../../../types").CmsModelFieldPatternValidatorPlugin[])[];
2
+ export default _default;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _gte = _interopRequireDefault(require("./gte"));
11
+
12
+ var _in = _interopRequireDefault(require("./in"));
13
+
14
+ var _lte = _interopRequireDefault(require("./lte"));
15
+
16
+ var _maxLength = _interopRequireDefault(require("./maxLength"));
17
+
18
+ var _minLength = _interopRequireDefault(require("./minLength"));
19
+
20
+ var _pattern = _interopRequireDefault(require("./pattern"));
21
+
22
+ var _required = _interopRequireDefault(require("./required"));
23
+
24
+ var _patternPlugins = _interopRequireDefault(require("./patternPlugins"));
25
+
26
+ var _dateLte = _interopRequireDefault(require("./dateLte"));
27
+
28
+ var _dateGte = _interopRequireDefault(require("./dateGte"));
29
+
30
+ var _timeLte = _interopRequireDefault(require("./timeLte"));
31
+
32
+ var _timeGte = _interopRequireDefault(require("./timeGte"));
33
+
34
+ var _default = () => [_gte.default, _in.default, _lte.default, _pattern.default, _required.default, _minLength.default, _maxLength.default, _patternPlugins.default, (0, _dateLte.default)(), (0, _dateGte.default)(), (0, _timeLte.default)(), (0, _timeGte.default)()];
35
+
36
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const plugin: CmsModelFieldValidatorPlugin;
3
+ export default plugin;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ const plugin = {
11
+ type: "cms-model-field-validator",
12
+ name: "cms-model-field-validator-lte",
13
+ validator: {
14
+ name: "lte",
15
+
16
+ validate({
17
+ value,
18
+ validator
19
+ }) {
20
+ const lteValue = validator.settings.value;
21
+
22
+ if (typeof lteValue !== "undefined") {
23
+ return _validation.validation.validate(value, `lte:${lteValue}`).then(v => v === true).catch(() => false);
24
+ }
25
+
26
+ return Promise.resolve(true);
27
+ }
28
+
29
+ }
30
+ };
31
+ var _default = plugin;
32
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const plugin: CmsModelFieldValidatorPlugin;
3
+ export default plugin;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ const plugin = {
11
+ type: "cms-model-field-validator",
12
+ name: "cms-model-field-validator-max-length",
13
+ validator: {
14
+ name: "maxLength",
15
+
16
+ validate({
17
+ value,
18
+ validator
19
+ }) {
20
+ const maxLengthValue = validator.settings.value;
21
+
22
+ if (typeof maxLengthValue !== "undefined") {
23
+ return _validation.validation.validate(value, `maxLength:${maxLengthValue}`).then(v => v === true).catch(() => false);
24
+ }
25
+
26
+ return Promise.resolve(true);
27
+ }
28
+
29
+ }
30
+ };
31
+ var _default = plugin;
32
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const plugin: CmsModelFieldValidatorPlugin;
3
+ export default plugin;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ const plugin = {
11
+ type: "cms-model-field-validator",
12
+ name: "cms-model-field-validator-min-length",
13
+ validator: {
14
+ name: "minLength",
15
+
16
+ validate({
17
+ value,
18
+ validator
19
+ }) {
20
+ const minLengthValue = validator.settings.value;
21
+
22
+ if (typeof minLengthValue !== "undefined") {
23
+ return _validation.validation.validate(value, `minLength:${minLengthValue}`).then(v => v === true).catch(() => false);
24
+ }
25
+
26
+ return Promise.resolve(true);
27
+ }
28
+
29
+ }
30
+ };
31
+ var _default = plugin;
32
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldValidatorPlugin } from "../../../types";
2
+ declare const plugin: CmsModelFieldValidatorPlugin;
3
+ export default plugin;