@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.
- package/LICENSE +21 -0
- package/README.md +73 -0
- package/content/contextSetup.d.ts +4 -0
- package/content/contextSetup.js +65 -0
- package/content/graphQLHandlerFactory.d.ts +5 -0
- package/content/graphQLHandlerFactory.js +173 -0
- package/content/plugins/CmsGroupPlugin.d.ts +11 -0
- package/content/plugins/CmsGroupPlugin.js +24 -0
- package/content/plugins/CmsModelPlugin.d.ts +11 -0
- package/content/plugins/CmsModelPlugin.js +24 -0
- package/content/plugins/buildSchemaPlugins.d.ts +7 -0
- package/content/plugins/buildSchemaPlugins.js +29 -0
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +7 -0
- package/content/plugins/crud/contentEntry/afterDelete.js +41 -0
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeCreate.js +28 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +4 -0
- package/content/plugins/crud/contentEntry/entryDataValidation.js +188 -0
- package/content/plugins/crud/contentEntry/markLockedFields.d.ts +12 -0
- package/content/plugins/crud/contentEntry/markLockedFields.js +117 -0
- package/content/plugins/crud/contentEntry.crud.d.ts +17 -0
- package/content/plugins/crud/contentEntry.crud.js +931 -0
- package/content/plugins/crud/contentModel/afterCreate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterCreate.js +18 -0
- package/content/plugins/crud/contentModel/afterDelete.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterDelete.js +18 -0
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterUpdate.js +18 -0
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeCreate.js +146 -0
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeDelete.js +56 -0
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeUpdate.js +128 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.js +29 -0
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +2 -0
- package/content/plugins/crud/contentModel/createFieldModels.js +22 -0
- package/content/plugins/crud/contentModel/idValidation.d.ts +2 -0
- package/content/plugins/crud/contentModel/idValidation.js +22 -0
- package/content/plugins/crud/contentModel/models.d.ts +3 -0
- package/content/plugins/crud/contentModel/models.js +141 -0
- package/content/plugins/crud/contentModel/validateLayout.d.ts +2 -0
- package/content/plugins/crud/contentModel/validateLayout.js +38 -0
- package/content/plugins/crud/contentModel.crud.d.ts +12 -0
- package/content/plugins/crud/contentModel.crud.js +425 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.js +66 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.js +48 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +8 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentModelGroup.crud.d.ts +12 -0
- package/content/plugins/crud/contentModelGroup.crud.js +351 -0
- package/content/plugins/crud/index.d.ts +6 -0
- package/content/plugins/crud/index.js +100 -0
- package/content/plugins/graphqlFields/boolean.d.ts +3 -0
- package/content/plugins/graphqlFields/boolean.js +69 -0
- package/content/plugins/graphqlFields/datetime.d.ts +3 -0
- package/content/plugins/graphqlFields/datetime.js +83 -0
- package/content/plugins/graphqlFields/file.d.ts +3 -0
- package/content/plugins/graphqlFields/file.js +49 -0
- package/content/plugins/graphqlFields/index.d.ts +2 -0
- package/content/plugins/graphqlFields/index.js +30 -0
- package/content/plugins/graphqlFields/longText.d.ts +3 -0
- package/content/plugins/graphqlFields/longText.js +62 -0
- package/content/plugins/graphqlFields/number.d.ts +3 -0
- package/content/plugins/graphqlFields/number.js +75 -0
- package/content/plugins/graphqlFields/object.d.ts +3 -0
- package/content/plugins/graphqlFields/object.js +180 -0
- package/content/plugins/graphqlFields/ref.d.ts +3 -0
- package/content/plugins/graphqlFields/ref.js +205 -0
- package/content/plugins/graphqlFields/richText.d.ts +3 -0
- package/content/plugins/graphqlFields/richText.js +55 -0
- package/content/plugins/graphqlFields/text.d.ts +3 -0
- package/content/plugins/graphqlFields/text.js +72 -0
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +8 -0
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +54 -0
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +7 -0
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +35 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +15 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.js +62 -0
- package/content/plugins/modelManager/index.d.ts +3 -0
- package/content/plugins/modelManager/index.js +20 -0
- package/content/plugins/schema/baseSchema.d.ts +4 -0
- package/content/plugins/schema/baseSchema.js +98 -0
- package/content/plugins/schema/contentEntries.d.ts +4 -0
- package/content/plugins/schema/contentEntries.js +166 -0
- package/content/plugins/schema/contentModelGroups.d.ts +4 -0
- package/content/plugins/schema/contentModelGroups.js +153 -0
- package/content/plugins/schema/contentModels.d.ts +4 -0
- package/content/plugins/schema/contentModels.js +225 -0
- package/content/plugins/schema/createFieldResolvers.d.ts +19 -0
- package/content/plugins/schema/createFieldResolvers.js +92 -0
- package/content/plugins/schema/createManageResolvers.d.ts +11 -0
- package/content/plugins/schema/createManageResolvers.js +135 -0
- package/content/plugins/schema/createManageSDL.d.ts +9 -0
- package/content/plugins/schema/createManageSDL.js +153 -0
- package/content/plugins/schema/createPreviewResolvers.d.ts +10 -0
- package/content/plugins/schema/createPreviewResolvers.js +55 -0
- package/content/plugins/schema/createReadResolvers.d.ts +10 -0
- package/content/plugins/schema/createReadResolvers.js +55 -0
- package/content/plugins/schema/createReadSDL.d.ts +9 -0
- package/content/plugins/schema/createReadSDL.js +96 -0
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/content/plugins/schema/resolvers/commonFieldResolvers.js +14 -0
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveCreate.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +7 -0
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveDelete.js +30 -0
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGet.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveList.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolvePublish.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +7 -0
- package/content/plugins/schema/resolvers/manage/resolveUpdate.js +23 -0
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/preview/resolveGet.js +38 -0
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/preview/resolveList.js +23 -0
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/read/resolveGet.js +38 -0
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/read/resolveList.js +23 -0
- package/content/plugins/schema/schemaPlugins.d.ts +3 -0
- package/content/plugins/schema/schemaPlugins.js +92 -0
- package/content/plugins/storage/StorageTransformPlugin.d.ts +30 -0
- package/content/plugins/storage/StorageTransformPlugin.js +36 -0
- package/content/plugins/storage/default.d.ts +3 -0
- package/content/plugins/storage/default.js +28 -0
- package/content/plugins/storage/object.d.ts +3 -0
- package/content/plugins/storage/object.js +119 -0
- package/content/plugins/utils/createTypeName.d.ts +3 -0
- package/content/plugins/utils/createTypeName.js +28 -0
- package/content/plugins/utils/entryStorage.d.ts +17 -0
- package/content/plugins/utils/entryStorage.js +125 -0
- package/content/plugins/utils/getEntryTitle.d.ts +2 -0
- package/content/plugins/utils/getEntryTitle.js +42 -0
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +11 -0
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +30 -0
- package/content/plugins/utils/pluralizedTypeName.d.ts +1 -0
- package/content/plugins/utils/pluralizedTypeName.js +26 -0
- package/content/plugins/utils/renderFields.d.ts +16 -0
- package/content/plugins/utils/renderFields.js +51 -0
- package/content/plugins/utils/renderGetFilterFields.d.ts +9 -0
- package/content/plugins/utils/renderGetFilterFields.js +41 -0
- package/content/plugins/utils/renderInputFields.d.ts +14 -0
- package/content/plugins/utils/renderInputFields.js +53 -0
- package/content/plugins/utils/renderListFilterFields.d.ts +10 -0
- package/content/plugins/utils/renderListFilterFields.js +39 -0
- package/content/plugins/utils/renderSortEnum.d.ts +9 -0
- package/content/plugins/utils/renderSortEnum.js +32 -0
- package/content/plugins/validators/dateGte.d.ts +3 -0
- package/content/plugins/validators/dateGte.js +37 -0
- package/content/plugins/validators/dateLte.d.ts +3 -0
- package/content/plugins/validators/dateLte.js +37 -0
- package/content/plugins/validators/gte.d.ts +3 -0
- package/content/plugins/validators/gte.js +32 -0
- package/content/plugins/validators/in.d.ts +3 -0
- package/content/plugins/validators/in.js +32 -0
- package/content/plugins/validators/index.d.ts +2 -0
- package/content/plugins/validators/index.js +36 -0
- package/content/plugins/validators/lte.d.ts +3 -0
- package/content/plugins/validators/lte.js +32 -0
- package/content/plugins/validators/maxLength.d.ts +3 -0
- package/content/plugins/validators/maxLength.js +32 -0
- package/content/plugins/validators/minLength.d.ts +3 -0
- package/content/plugins/validators/minLength.js +32 -0
- package/content/plugins/validators/pattern.d.ts +3 -0
- package/content/plugins/validators/pattern.js +47 -0
- package/content/plugins/validators/patternPlugins/email.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/email.js +17 -0
- package/content/plugins/validators/patternPlugins/index.d.ts +2 -0
- package/content/plugins/validators/patternPlugins/index.js +19 -0
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/lowerCase.js +17 -0
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/upperCase.js +17 -0
- package/content/plugins/validators/patternPlugins/url.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/url.js +17 -0
- package/content/plugins/validators/required.d.ts +3 -0
- package/content/plugins/validators/required.js +25 -0
- package/content/plugins/validators/timeGte.d.ts +3 -0
- package/content/plugins/validators/timeGte.js +32 -0
- package/content/plugins/validators/timeLte.d.ts +3 -0
- package/content/plugins/validators/timeLte.js +32 -0
- package/index.d.ts +12 -0
- package/index.js +66 -0
- package/migrateCMSPermissions.d.ts +17 -0
- package/migrateCMSPermissions.js +193 -0
- package/package.json +80 -0
- package/plugins/context.d.ts +4 -0
- package/plugins/context.js +34 -0
- package/plugins/crud/index.d.ts +6 -0
- package/plugins/crud/index.js +100 -0
- package/plugins/crud/settings.crud.d.ts +10 -0
- package/plugins/crud/settings.crud.js +93 -0
- package/plugins/crud/system.crud.d.ts +10 -0
- package/plugins/crud/system.crud.js +182 -0
- package/plugins/graphql/system.d.ts +17 -0
- package/plugins/graphql/system.js +72 -0
- package/plugins/graphql.d.ts +2 -0
- package/plugins/graphql.js +79 -0
- package/plugins/upgrades/index.d.ts +2 -0
- package/plugins/upgrades/index.js +14 -0
- package/plugins/upgrades/v5.5.0/helpers.d.ts +6 -0
- package/plugins/upgrades/v5.5.0/helpers.js +10 -0
- package/plugins/upgrades/v5.5.0/index.d.ts +4 -0
- package/plugins/upgrades/v5.5.0/index.js +129 -0
- package/transformers.d.ts +2 -0
- package/transformers.js +25 -0
- package/types.d.ts +2149 -0
- package/types.js +366 -0
- package/utils.d.ts +25 -0
- 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,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,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,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,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,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,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,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,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,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;
|