payload 0.15.13 → 0.16.2
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/.eslintrc.js +2 -1
- package/CHANGELOG.md +33 -0
- package/dist/admin/components/elements/ReactSelect/types.d.ts +1 -1
- package/dist/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.d.ts +18 -0
- package/dist/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.js +158 -0
- package/dist/admin/components/forms/Form/{buildStateFromSchema.d.ts → buildStateFromSchema/index.d.ts} +4 -3
- package/dist/admin/components/forms/Form/buildStateFromSchema/index.js +25 -0
- package/dist/admin/components/forms/Form/buildStateFromSchema/iterateFields.d.ts +18 -0
- package/dist/admin/components/forms/Form/buildStateFromSchema/iterateFields.js +24 -0
- package/dist/admin/components/forms/Form/index.js +2 -6
- package/dist/admin/components/forms/RenderFields/index.js +1 -1
- package/dist/admin/components/forms/field-types/Array/Array.js +4 -2
- package/dist/admin/components/forms/field-types/Blocks/Blocks.js +4 -2
- package/dist/admin/components/forms/field-types/Relationship/index.js +3 -1
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/EditModal/index.js +4 -2
- package/dist/admin/components/views/Account/index.js +2 -2
- package/dist/admin/components/views/Global/index.js +4 -4
- package/dist/admin/components/views/collections/Edit/index.js +7 -4
- package/dist/auth/operations/login.js +6 -8
- package/dist/collections/config/types.d.ts +1 -0
- package/dist/collections/operations/create.js +21 -20
- package/dist/collections/operations/delete.js +6 -7
- package/dist/collections/operations/find.js +8 -9
- package/dist/collections/operations/findByID.js +7 -9
- package/dist/collections/operations/findVersionByID.js +7 -9
- package/dist/collections/operations/findVersions.js +8 -10
- package/dist/collections/operations/restoreVersion.js +9 -13
- package/dist/collections/operations/update.js +26 -33
- package/dist/collections/tests/defaultValue.spec.d.ts +1 -0
- package/dist/collections/tests/defaultValue.spec.js +95 -0
- package/dist/collections/tests/hooks.spec.js +5 -1
- package/dist/fields/config/sanitize.d.ts +2 -1
- package/dist/fields/config/sanitize.js +5 -5
- package/dist/fields/config/sanitize.spec.js +30 -19
- package/dist/fields/config/schema.js +16 -15
- package/dist/fields/config/types.d.ts +8 -4
- package/dist/fields/config/types.js +6 -2
- package/dist/fields/getDefaultValue.d.ts +9 -0
- package/dist/fields/getDefaultValue.js +14 -0
- package/dist/fields/hooks/afterChange/index.d.ts +12 -0
- package/dist/fields/hooks/afterChange/index.js +26 -0
- package/dist/fields/hooks/afterChange/promise.d.ts +14 -0
- package/dist/fields/hooks/afterChange/promise.js +104 -0
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +14 -0
- package/dist/fields/hooks/afterChange/traverseFields.js +20 -0
- package/dist/fields/hooks/afterRead/index.d.ts +16 -0
- package/dist/fields/hooks/afterRead/index.js +40 -0
- package/dist/fields/hooks/afterRead/promise.d.ts +18 -0
- package/dist/fields/hooks/afterRead/promise.js +225 -0
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts +13 -0
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +84 -0
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +18 -0
- package/dist/fields/hooks/afterRead/traverseFields.js +24 -0
- package/dist/fields/hooks/beforeChange/index.d.ts +16 -0
- package/dist/fields/hooks/beforeChange/index.js +40 -0
- package/dist/fields/hooks/beforeChange/promise.d.ts +25 -0
- package/dist/fields/hooks/beforeChange/promise.js +236 -0
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +25 -0
- package/dist/fields/hooks/beforeChange/traverseFields.js +27 -0
- package/dist/fields/hooks/beforeValidate/index.d.ts +14 -0
- package/dist/fields/hooks/beforeValidate/index.js +28 -0
- package/dist/fields/hooks/beforeValidate/promise.d.ts +16 -0
- package/dist/fields/hooks/beforeValidate/promise.js +229 -0
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +16 -0
- package/dist/fields/hooks/beforeValidate/traverseFields.js +22 -0
- package/dist/fields/richText/populate.d.ts +1 -3
- package/dist/fields/richText/populate.js +3 -3
- package/dist/fields/richText/recurseNestedFields.d.ts +1 -3
- package/dist/fields/richText/recurseNestedFields.js +7 -15
- package/dist/fields/richText/relationshipPromise.d.ts +6 -9
- package/dist/fields/richText/relationshipPromise.js +11 -15
- package/dist/fields/validations.js +3 -4
- package/dist/globals/config/types.d.ts +1 -0
- package/dist/globals/operations/findOne.js +11 -11
- package/dist/globals/operations/findVersionByID.js +5 -8
- package/dist/globals/operations/findVersions.js +7 -9
- package/dist/globals/operations/restoreVersion.js +12 -14
- package/dist/globals/operations/update.js +29 -33
- package/dist/graphql/schema/buildObjectType.js +3 -5
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -3
- package/dist/localization/middleware.js +1 -2
- package/dist/mongoose/buildSchema.js +1 -2
- package/dist/uploads/mimeTypeValidator.js +4 -1
- package/dist/uploads/mimeTypeValidator.spec.js +7 -1
- package/dist/uploads/uploadFile.js +3 -2
- package/dist/versions/drafts/saveCollectionDraft.d.ts +1 -1
- package/dist/versions/drafts/saveCollectionDraft.js +1 -1
- package/dist/versions/ensurePublishedCollectionVersion.js +5 -7
- package/dist/versions/ensurePublishedGlobalVersion.js +5 -6
- package/dist/versions/saveCollectionVersion.js +6 -7
- package/dist/versions/saveGlobalVersion.js +7 -7
- package/dist/versions/tests/globals-graphql.spec.js +2 -2
- package/dist/webpack/getBaseConfig.js +1 -2
- package/docs/fields/array.mdx +1 -1
- package/docs/fields/blocks.mdx +1 -1
- package/docs/fields/checkbox.mdx +1 -1
- package/docs/fields/code.mdx +1 -1
- package/docs/fields/date.mdx +1 -1
- package/docs/fields/email.mdx +1 -1
- package/docs/fields/group.mdx +1 -1
- package/docs/fields/number.mdx +1 -1
- package/docs/fields/overview.mdx +37 -2
- package/docs/fields/point.mdx +1 -1
- package/docs/fields/radio.mdx +1 -1
- package/docs/fields/relationship.mdx +1 -1
- package/docs/fields/rich-text.mdx +1 -1
- package/docs/fields/select.mdx +1 -1
- package/docs/fields/text.mdx +1 -1
- package/docs/fields/textarea.mdx +1 -1
- package/docs/fields/upload.mdx +1 -1
- package/docs/hooks/collections.mdx +1 -0
- package/docs/hooks/fields.mdx +4 -3
- package/docs/hooks/globals.mdx +1 -0
- package/docs/production/preventing-abuse.mdx +16 -5
- package/docs/queries/overview.mdx +1 -1
- package/docs/rest-api/overview.mdx +1 -1
- package/package.json +4 -1
- package/dist/admin/components/forms/Form/buildStateFromSchema.js +0 -140
- package/dist/fields/accessPromise.d.ts +0 -22
- package/dist/fields/accessPromise.js +0 -39
- package/dist/fields/hookPromise.d.ts +0 -16
- package/dist/fields/hookPromise.js +0 -53
- package/dist/fields/performFieldOperations.d.ts +0 -25
- package/dist/fields/performFieldOperations.js +0 -86
- package/dist/fields/relationshipPopulationPromise.d.ts +0 -15
- package/dist/fields/relationshipPopulationPromise.js +0 -86
- package/dist/fields/traverseFields.d.ts +0 -40
- package/dist/fields/traverseFields.js +0 -329
- package/dist/fields/validationPromise.d.ts +0 -22
- package/dist/fields/validationPromise.js +0 -34
|
@@ -51,4 +51,4 @@ const saveCollectionDraft = async ({ payload, config, id, data, autosave, }) =>
|
|
|
51
51
|
return result;
|
|
52
52
|
};
|
|
53
53
|
exports.saveCollectionDraft = saveCollectionDraft;
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2F2ZUNvbGxlY3Rpb25EcmFmdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy92ZXJzaW9ucy9kcmFmdHMvc2F2ZUNvbGxlY3Rpb25EcmFmdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSw4REFBMkQ7QUFZcEQsTUFBTSxtQkFBbUIsR0FBRyxLQUFLLEVBQUUsRUFDeEMsT0FBTyxFQUNQLE1BQU0sRUFDTixFQUFFLEVBQ0YsSUFBSSxFQUNKLFFBQV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8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLDZDQUE2QyxNQUFNLENBQUMsTUFBTSxDQUFDLFFBQVEsWUFBWSxFQUFFLEdBQUcsQ0FBQyxDQUFDO1FBQzNHLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0tBQzNCO0lBRUQsSUFBSSxNQUFNLENBQUMsUUFBUSxDQUFDLFNBQVMsRUFBRTtRQUM3QixJQUFBLHVDQUFrQixFQUFDO1lBQ2pCLEVBQUU7WUFDRixPQUFPLEVBQUUsSUFBSTtZQUNiLEtBQUssRUFBRSxhQUFhO1lBQ3BCLFdBQVcsRUFBRSxNQUFNLENBQUMsTUFBTSxDQUFDLE1BQU07WUFDakMsVUFBVSxFQUFFLFlBQVk7WUFDeEIsR0FBRyxFQUFFLE1BQU0sQ0FBQyxRQUFRLENBQUMsU0FBUztTQUMvQixDQUFDLENBQUM7S0FDSjtJQUVELE1BQU0sR0FBRyxNQUFNLENBQUMsT0FBTyxDQUFDO0lBQ3hCLE1BQU0sR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ2hDLE1BQU0sR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQzVCLE1BQU0sQ0FBQyxFQUFFLEdBQUcsRUFBRSxDQUFDO0lBRWYsT0FBTyxNQUFNLENBQUM7QUFDaEIsQ0FBQyxDQUFDO0FBOURXLFFBQUEsbUJBQW1CLHVCQThEOUIifQ==
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensurePublishedCollectionVersion = void 0;
|
|
4
4
|
const enforceMaxVersions_1 = require("./enforceMaxVersions");
|
|
5
|
+
const afterRead_1 = require("../fields/hooks/afterRead");
|
|
5
6
|
const ensurePublishedCollectionVersion = async ({ payload, config, req, id, docWithLocales, }) => {
|
|
6
7
|
// If there are no newer drafts,
|
|
7
8
|
// And the current doc is published,
|
|
@@ -23,15 +24,12 @@ const ensurePublishedCollectionVersion = async ({ payload, config, req, id, docW
|
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
if ((moreRecentDrafts === null || moreRecentDrafts === void 0 ? void 0 : moreRecentDrafts.length) === 0) {
|
|
26
|
-
const version = await
|
|
27
|
-
id,
|
|
27
|
+
const version = await (0, afterRead_1.afterRead)({
|
|
28
28
|
depth: 0,
|
|
29
|
+
doc: docWithLocales,
|
|
30
|
+
entityConfig: config,
|
|
29
31
|
req,
|
|
30
|
-
data: docWithLocales,
|
|
31
|
-
hook: 'afterRead',
|
|
32
|
-
operation: 'update',
|
|
33
32
|
overrideAccess: true,
|
|
34
|
-
flattenLocales: false,
|
|
35
33
|
showHiddenFields: true,
|
|
36
34
|
});
|
|
37
35
|
try {
|
|
@@ -59,4 +57,4 @@ const ensurePublishedCollectionVersion = async ({ payload, config, req, id, docW
|
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
59
|
exports.ensurePublishedCollectionVersion = ensurePublishedCollectionVersion;
|
|
62
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5zdXJlUHVibGlzaGVkQ29sbGVjdGlvblZlcnNpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyc2lvbnMvZW5zdXJlUHVibGlzaGVkQ29sbGVjdGlvblZlcnNpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsNkRBQTBEO0FBRTFELHlEQUFzRDtBQVUvQyxNQUFNLGdDQUFnQyxHQUFHLEtBQUssRUFBRSxFQUNyRCxPQUFPLEVBQ1AsTUFBTSxFQUNOLEdBQUcsRUFDSCxFQUFFLEVBQ0YsY0FBYyxHQUNULEVBQWlCLEVBQUU7SUF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87b0JBQ1AsUUFBUSxFQUFFLEtBQUs7aUJBQ2hCLENBQUMsQ0FBQzthQUNKO1lBQUMsT0FBTyxHQUFHLEVBQUU7Z0JBQ1osT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMscURBQXFELE1BQU0sQ0FBQyxNQUFNLENBQUMsUUFBUSxZQUFZLEVBQUUsR0FBRyxDQUFDLENBQUM7Z0JBQ25ILE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO2FBQzNCO1lBRUQsSUFBSSxNQUFNLENBQUMsUUFBUSxDQUFDLFNBQVMsRUFBRTtnQkFDN0IsSUFBQSx1Q0FBa0IsRUFBQztvQkFDakIsRUFBRTtvQkFDRixPQUFPLEVBQUUsSUFBSTtvQkFDYixLQUFLLEVBQUUsWUFBWTtvQkFDbkIsV0FBVyxFQUFFLE1BQU0sQ0FBQyxNQUFNLENBQUMsTUFBTTtvQkFDakMsVUFBVSxFQUFFLFlBQVk7b0JBQ3hCLEdBQUcsRUFBRSxNQUFNLENBQUMsUUFBUSxDQUFDLFNBQVM7aUJBQy9CLENBQUMsQ0FBQzthQUNKO1NBQ0Y7S0FDRjtBQUNILENBQUMsQ0FBQztBQWhFVyxRQUFBLGdDQUFnQyxvQ0FnRTNDIn0=
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensurePublishedGlobalVersion = void 0;
|
|
4
4
|
const enforceMaxVersions_1 = require("./enforceMaxVersions");
|
|
5
|
+
const afterRead_1 = require("../fields/hooks/afterRead");
|
|
5
6
|
const ensurePublishedGlobalVersion = async ({ payload, config, req, docWithLocales, }) => {
|
|
6
7
|
// If there are no newer drafts,
|
|
7
8
|
// And the current doc is published,
|
|
@@ -20,14 +21,12 @@ const ensurePublishedGlobalVersion = async ({ payload, config, req, docWithLocal
|
|
|
20
21
|
},
|
|
21
22
|
});
|
|
22
23
|
if ((moreRecentDrafts === null || moreRecentDrafts === void 0 ? void 0 : moreRecentDrafts.length) === 0) {
|
|
23
|
-
const version = await
|
|
24
|
+
const version = await (0, afterRead_1.afterRead)({
|
|
24
25
|
depth: 0,
|
|
26
|
+
doc: docWithLocales,
|
|
27
|
+
entityConfig: config,
|
|
25
28
|
req,
|
|
26
|
-
data: docWithLocales,
|
|
27
|
-
hook: 'afterRead',
|
|
28
|
-
operation: 'update',
|
|
29
29
|
overrideAccess: true,
|
|
30
|
-
flattenLocales: false,
|
|
31
30
|
showHiddenFields: true,
|
|
32
31
|
});
|
|
33
32
|
try {
|
|
@@ -53,4 +52,4 @@ const ensurePublishedGlobalVersion = async ({ payload, config, req, docWithLocal
|
|
|
53
52
|
}
|
|
54
53
|
};
|
|
55
54
|
exports.ensurePublishedGlobalVersion = ensurePublishedGlobalVersion;
|
|
56
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
55
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5zdXJlUHVibGlzaGVkR2xvYmFsVmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJzaW9ucy9lbnN1cmVQdWJsaXNoZWRHbG9iYWxWZXJzaW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLDZEQUEwRDtBQUcxRCx5REFBc0Q7QUFTL0MsTUFBTSw0QkFBNEIsR0FBRyxLQUFLLEVBQUUsRUFDakQsT0FBTyxFQUNQLE1BQU0sRUFDTixHQUFHLEVBQ0gsY0FBYyxHQUNULEVBQWlCLEVBQUU7SUFDeEIsZ0NBQWdDO0lBQ2hDLG9DQUFvQztJQUNwQyxzREFBc0Q7SUFFdEQsSUFBSSxDQUFBLGNBQWMsYUFBZCxjQUFjLHVCQUFkLGNBQWMsQ0FBRSxPQUFPLE1BQUssV0FBVyxFQUFFO1FBQzNDLE1BQU0sWUFB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QsSUFBSSxNQUFNLENBQUMsUUFBUSxDQUFDLEdBQUcsRUFBRTtnQkFDdkIsSUFBQSx1Q0FBa0IsRUFBQztvQkFDakIsT0FBTyxFQUFFLElBQUk7b0JBQ2IsS0FBSyxFQUFFLFlBQVk7b0JBQ25CLFdBQVcsRUFBRSxNQUFNLENBQUMsS0FBSztvQkFDekIsVUFBVSxFQUFFLFFBQVE7b0JBQ3BCLEdBQUcsRUFBRSxNQUFNLENBQUMsUUFBUSxDQUFDLEdBQUc7aUJBQ3pCLENBQUMsQ0FBQzthQUNKO1NBQ0Y7S0FDRjtBQUNILENBQUMsQ0FBQztBQTFEVyxRQUFBLDRCQUE0QixnQ0EwRHZDIn0=
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.saveCollectionVersion = void 0;
|
|
7
7
|
const enforceMaxVersions_1 = require("./enforceMaxVersions");
|
|
8
8
|
const sanitizeInternalFields_1 = __importDefault(require("../utilities/sanitizeInternalFields"));
|
|
9
|
+
const afterRead_1 = require("../fields/hooks/afterRead");
|
|
9
10
|
const saveCollectionVersion = async ({ payload, config, req, id, docWithLocales, }) => {
|
|
10
11
|
var _a, _b;
|
|
11
12
|
const VersionModel = payload.versions[config.slug];
|
|
@@ -37,16 +38,14 @@ const saveCollectionVersion = async ({ payload, config, req, id, docWithLocales,
|
|
|
37
38
|
version = (0, sanitizeInternalFields_1.default)(version);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
version = await
|
|
41
|
-
id,
|
|
41
|
+
version = await (0, afterRead_1.afterRead)({
|
|
42
42
|
depth: 0,
|
|
43
|
+
doc: version,
|
|
44
|
+
entityConfig: config,
|
|
43
45
|
req,
|
|
44
|
-
data: version,
|
|
45
|
-
hook: 'afterRead',
|
|
46
|
-
operation: 'update',
|
|
47
46
|
overrideAccess: true,
|
|
48
|
-
flattenLocales: false,
|
|
49
47
|
showHiddenFields: true,
|
|
48
|
+
flattenLocales: false,
|
|
50
49
|
});
|
|
51
50
|
if (version._id)
|
|
52
51
|
delete version._id;
|
|
@@ -79,4 +78,4 @@ const saveCollectionVersion = async ({ payload, config, req, id, docWithLocales,
|
|
|
79
78
|
return createdVersion;
|
|
80
79
|
};
|
|
81
80
|
exports.saveCollectionVersion = saveCollectionVersion;
|
|
82
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
81
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2F2ZUNvbGxlY3Rpb25WZXJzaW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ZlcnNpb25zL3NhdmVDb2xsZWN0aW9uVmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFFQSw2REFBMEQ7QUFFMUQsaUdBQXlFO0FBQ3pFLHlEQUFzRDtBQVUvQyxNQUFNLHFCQUFxQixHQUFHLEtBQUssRUFBRSxFQUMxQyxPQUFPLEVBQ1AsTUFBTSxFQUNOLEdBQUcsRUFDSCxFQUFFLEVBQ0YsY0FBYyxHQUNULEVBQWlCLEVBQUU7O0lBQ3hCLE1BQU0sWUFBWSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRW5ELElBQUksT0FBTyxHQUFHLGNBQWMsQ0FBQztJQUU3QixJQUFJLE1BQUEsTUFBTSxDQUFDLFFBQVEsMENBQUUsTUFBTSxFQUFFO1FBQzNCLE1BQU0sYUFBYSxHQUFHLE1BQU0sWUFBWSxDQUFDLE9BQU8sQ0FBQztZQUMvQyxNQUFNLEVBQUU7Z0JBQ04sR0FBRyxFQUFFLGNBQWMsQ0FBQyxFQUFFO2FBQ3ZCO1lBQ0QsU0FBUyxFQUFFO2dCQUNULEdBQUcsRUFBRSxjQUFjLENBQUMsU0FBUzthQUM5QjtTQUNGLEVBQ0QsRUFBRSxFQUNGO1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1lBQ1AsUUFBUSxFQUFFLEtBQUs7U0FDaEIsQ0FBQyxDQUFDO0tBQ0o7SUFBQyxPQUFPLEdBQUcsRUFBRTtRQUNaLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLHFEQUFxRCxNQUFNLENBQUMsTUFBTSxDQUFDLFFBQVEsWUFBWSxFQUFFLEdBQUcsQ0FBQyxDQUFDO1FBQ25ILE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0tBQzNCO0lBRUQsSUFBSSxNQUFNLENBQUMsUUFBUSxDQUFDLFNBQVMsRUFBRTtRQUM3QixJQUFBLHVDQUFrQixFQUFDO1lBQ2pCLEVBQUU7WUFDRixPQUFPLEVBQUUsSUFBSTtZQUNiLEtBQUssRUFBRSxZQUFZO1lBQ25CLFdBQVcsRUFBRSxNQUFNLENBQUMsTUFBTSxDQUFDLE1BQU07WUFDakMsVUFBVSxFQUFFLFlBQVk7WUFDeEIsR0FBRyxFQUFFLE1BQU0sQ0FBQyxRQUFRLENBQUMsU0FBUztTQUMvQixDQUFDLENBQUM7S0FDSjtJQUVELElBQUksY0FBYyxFQUFFO1FBQ2xCLGNBQWMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztRQUM1RCxjQUFjLEdBQUcsSUFBQSxnQ0FBc0IsRUFBQyxjQUFjLENBQUMsQ0FBQztLQUN6RDtJQUVELE9BQU8sY0FBYyxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQXJGVyxRQUFBLHFCQUFxQix5QkFxRmhDIn0=
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.saveGlobalVersion = void 0;
|
|
7
7
|
const enforceMaxVersions_1 = require("./enforceMaxVersions");
|
|
8
8
|
const sanitizeInternalFields_1 = __importDefault(require("../utilities/sanitizeInternalFields"));
|
|
9
|
+
const afterRead_1 = require("../fields/hooks/afterRead");
|
|
9
10
|
const saveGlobalVersion = async ({ payload, config, req, docWithLocales, }) => {
|
|
10
11
|
var _a, _b;
|
|
11
12
|
const VersionModel = payload.versions[config.slug];
|
|
@@ -34,14 +35,13 @@ const saveGlobalVersion = async ({ payload, config, req, docWithLocales, }) => {
|
|
|
34
35
|
version = (0, sanitizeInternalFields_1.default)(version);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
version = await
|
|
38
|
+
version = await (0, afterRead_1.afterRead)({
|
|
38
39
|
depth: 0,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
hook: 'afterRead',
|
|
42
|
-
operation: 'update',
|
|
43
|
-
overrideAccess: true,
|
|
40
|
+
doc: version,
|
|
41
|
+
entityConfig: config,
|
|
44
42
|
flattenLocales: false,
|
|
43
|
+
overrideAccess: true,
|
|
44
|
+
req,
|
|
45
45
|
showHiddenFields: true,
|
|
46
46
|
});
|
|
47
47
|
if (version._id)
|
|
@@ -73,4 +73,4 @@ const saveGlobalVersion = async ({ payload, config, req, docWithLocales, }) => {
|
|
|
73
73
|
return createdVersion;
|
|
74
74
|
};
|
|
75
75
|
exports.saveGlobalVersion = saveGlobalVersion;
|
|
76
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
76
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2F2ZUdsb2JhbFZlcnNpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyc2lvbnMvc2F2ZUdsb2JhbFZlcnNpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQ0EsNkRBQTBEO0FBRzFELGlHQUF5RTtBQUN6RSx5REFBc0Q7QUFTL0MsTUFBTSxpQkFBaUIsR0FBRyxLQUFLLEVBQUUsRUFDdEMsT0FBTyxFQUNQLE1BQU0sRUFDTixHQUFH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FDO1FBQzVELGNBQWMsR0FBRyxJQUFBLGdDQUFzQixFQUFDLGNBQWMsQ0FBQyxDQUFDO0tBQ3pEO0lBRUQsT0FBTyxjQUFjLENBQUM7QUFDeEIsQ0FBQyxDQUFDO0FBL0VXLFFBQUEsaUJBQWlCLHFCQStFNUIifQ==
|
|
@@ -33,7 +33,7 @@ describe('Global Versions - GraphQL', () => {
|
|
|
33
33
|
client = new graphql_request_1.GraphQLClient(url, { headers: { Authorization: `JWT ${token}` } });
|
|
34
34
|
// language=graphql
|
|
35
35
|
const query = `mutation {
|
|
36
|
-
updateBlocksGlobal(
|
|
36
|
+
updateBlocksGlobal(data: {
|
|
37
37
|
title: "${title}"
|
|
38
38
|
blocks: [{ quote: "Test quote", color: "red", blockName: "Some block title", blockType: "quote"}]
|
|
39
39
|
}) {
|
|
@@ -56,7 +56,7 @@ describe('Global Versions - GraphQL', () => {
|
|
|
56
56
|
const updatedTitle = 'updated global title';
|
|
57
57
|
// language=graphql
|
|
58
58
|
const query = `mutation {
|
|
59
|
-
updateBlocksGlobal(
|
|
59
|
+
updateBlocksGlobal(data: {
|
|
60
60
|
title: "${updatedTitle}"
|
|
61
61
|
}) {
|
|
62
62
|
_status
|
|
@@ -58,7 +58,6 @@ exports.default = (config) => ({
|
|
|
58
58
|
'payload-user-css': config.admin.css,
|
|
59
59
|
'payload-scss-overrides': config.admin.scss,
|
|
60
60
|
dotenv: mockDotENVPath,
|
|
61
|
-
[path_1.default.resolve(__dirname, '../index')]: mockModulePath,
|
|
62
61
|
},
|
|
63
62
|
extensions: ['.ts', '.tsx', '.js', '.json'],
|
|
64
63
|
},
|
|
@@ -80,4 +79,4 @@ exports.default = (config) => ({
|
|
|
80
79
|
new webpack_1.default.HotModuleReplacementPlugin(),
|
|
81
80
|
],
|
|
82
81
|
});
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
82
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V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EdBQUcsRUFBRSxHQUFHLENBQUMsRUFBRSxFQUFFO1lBQ3JCLElBQUksR0FBRyxDQUFDLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxLQUFLLENBQUMsRUFBRTtnQkFDeEMsT0FBTyxDQUFDO29CQUNOLEdBQUcsTUFBTTtvQkFDVCxDQUFDLGVBQWUsR0FBRyxFQUFFLENBQUMsRUFBRSxJQUFJLEdBQUcsR0FBRztpQkFDbkMsQ0FBQyxDQUFDO2FBQ0o7WUFFRCxPQUFPLE1BQU0sQ0FBQztRQUNoQixDQUFDLEVBQ0QsRUFBRSxDQUNILENBQ0Y7UUFDRCxJQUFJLDZCQUFpQixDQUFDO1lBQ3BCLFFBQVEsRUFBRSxNQUFNLENBQUMsS0FBSyxDQUFDLFNBQVM7WUFDaEMsUUFBUSxFQUFFLGNBQUksQ0FBQyxTQUFTLENBQUMsY0FBYyxDQUFDO1NBQ3pDLENBQUM7UUFDRixJQUFJLGlCQUFPLENBQUMsMEJBQTBCLEVBQUU7S0FDekM7Q0FDRixDQUFDLENBQUMifQ==
|
package/docs/fields/array.mdx
CHANGED
|
@@ -31,7 +31,7 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
|
|
|
31
31
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
32
32
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
33
33
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
34
|
-
| **`defaultValue`** | Provide an array of row data to be used for this field's default value. |
|
|
34
|
+
| **`defaultValue`** | Provide an array of row data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
35
35
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Array will be kept, so there is no need to specify each nested field as `localized`. |
|
|
36
36
|
| **`required`** | Require this field to have a value. |
|
|
37
37
|
| **`labels`** | Customize the row labels appearing in the Admin dashboard. |
|
package/docs/fields/blocks.mdx
CHANGED
|
@@ -32,7 +32,7 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme
|
|
|
32
32
|
| **`hooks`** | Provide field-level hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
33
33
|
| **`access`** | Provide field-level access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
34
34
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API response or the Admin panel. |
|
|
35
|
-
| **`defaultValue`** | Provide an array of block data to be used for this field's default value. |
|
|
35
|
+
| **`defaultValue`** | Provide an array of block data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
36
36
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. || **`required`** | Require this field to have a value. |
|
|
37
37
|
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
|
|
38
38
|
| **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
|
package/docs/fields/checkbox.mdx
CHANGED
|
@@ -22,7 +22,7 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
|
|
|
22
22
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
23
23
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
24
24
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
25
|
-
| **`defaultValue`** | Provide data to be used for this field's default value, will default to false if field is also `required`. |
|
|
25
|
+
| **`defaultValue`** | Provide data to be used for this field's default value, will default to false if field is also `required`. [More](/docs/fields/overview#default-values) |
|
|
26
26
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
27
27
|
| **`required`** | Require this field to have a value. |
|
|
28
28
|
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
|
package/docs/fields/code.mdx
CHANGED
|
@@ -28,7 +28,7 @@ This field uses `prismjs` for syntax highlighting and `react-simple-code-editor`
|
|
|
28
28
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
29
29
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
30
30
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
31
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
31
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
32
32
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
33
33
|
| **`required`** | Require this field to have a value. |
|
|
34
34
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/date.mdx
CHANGED
|
@@ -25,7 +25,7 @@ This field uses [`react-datepicker`](https://www.npmjs.com/package/react-datepic
|
|
|
25
25
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
26
26
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
27
27
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
28
|
-
| **`defaultValue`** | Provide data to be used for this field's default value.
|
|
28
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
29
29
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
30
30
|
| **`required`** | Require this field to have a value. |
|
|
31
31
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/email.mdx
CHANGED
|
@@ -23,7 +23,7 @@ keywords: email, fields, config, configuration, documentation, Content Managemen
|
|
|
23
23
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
24
24
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
25
25
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
26
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
26
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
27
27
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
28
28
|
| **`required`** | Require this field to have a value. |
|
|
29
29
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/group.mdx
CHANGED
|
@@ -22,7 +22,7 @@ keywords: group, fields, config, configuration, documentation, Content Managemen
|
|
|
22
22
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
23
23
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
24
24
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
25
|
-
| **`defaultValue`** | Provide an object of data to be used for this field's default value. |
|
|
25
|
+
| **`defaultValue`** | Provide an object of data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
26
26
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Group will be kept, so there is no need to specify each nested field as `localized`. |
|
|
27
27
|
| **`required`** | Require this field to have a value. |
|
|
28
28
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/number.mdx
CHANGED
|
@@ -25,7 +25,7 @@ keywords: number, fields, config, configuration, documentation, Content Manageme
|
|
|
25
25
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
26
26
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
27
27
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
28
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
28
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
29
29
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
30
30
|
| **`required`** | Require this field to have a value. |
|
|
31
31
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/overview.mdx
CHANGED
|
@@ -7,7 +7,8 @@ keywords: overview, fields, config, configuration, documentation, Content Manage
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
<Banner type="info">
|
|
10
|
-
|
|
10
|
+
Fields are the building blocks of Payload. Collections and Globals both use Fields to define the shape of the data
|
|
11
|
+
that they store. Payload offers a wide variety of field types - both simple and complex.
|
|
11
12
|
</Banner>
|
|
12
13
|
|
|
13
14
|
Fields are defined as an array on Collections and Globals via the `fields` key. They define the shape of the data that will be stored as well as automatically construct the corresponding Admin UI.
|
|
@@ -75,6 +76,7 @@ There are two arguments available to custom validation functions.
|
|
|
75
76
|
| `operation` | Will be "create" or "update" depending on the UI action or API call |
|
|
76
77
|
| `id` | The value of the collection `id`, will be `undefined` on create request |
|
|
77
78
|
| `user` | The currently authenticated user object |
|
|
79
|
+
| `payload` | If the `validate` function is being executed on the server, Payload will be exposed for easily running local operations. |
|
|
78
80
|
|
|
79
81
|
Example:
|
|
80
82
|
```js
|
|
@@ -227,6 +229,38 @@ const customFieldWithCondition = {
|
|
|
227
229
|
|
|
228
230
|
```
|
|
229
231
|
|
|
232
|
+
### Default values
|
|
233
|
+
|
|
234
|
+
Fields can be prefilled with starting values using the `defaultValue` property. This is used in the admin UI and also on the backend as API requests will be populated with missing or undefined field values. You can assign the defaultValue directly in the field configuration or supply a function for dynamic behavior. Values assigned during a create request on the server are added before validation occurs.
|
|
235
|
+
|
|
236
|
+
Functions are called with an optional argument object containing:
|
|
237
|
+
|
|
238
|
+
- `user` - the authenticated user object
|
|
239
|
+
- `locale` - the currently selected locale string
|
|
240
|
+
|
|
241
|
+
Here is an example of a defaultValue function that uses both:
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
const translation: {
|
|
245
|
+
en: 'Written by',
|
|
246
|
+
es: 'escrito por',
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const field = {
|
|
250
|
+
name: 'attribution',
|
|
251
|
+
type: 'text',
|
|
252
|
+
admin: {
|
|
253
|
+
// highlight-start
|
|
254
|
+
defaultValue: ({ user, locale }) => (`${translation[locale]} ${user.name}`)
|
|
255
|
+
// highlight-end
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
<Banner type="success">
|
|
261
|
+
You can use async defaultValue functions to fill fields with data from API requests.
|
|
262
|
+
</Banner>
|
|
263
|
+
|
|
230
264
|
### Description
|
|
231
265
|
|
|
232
266
|
A description can be configured three ways.
|
|
@@ -246,7 +280,8 @@ As shown above, you can simply provide a string that will show by the field, but
|
|
|
246
280
|
type: 'text',
|
|
247
281
|
maxLength: 20,
|
|
248
282
|
admin: {
|
|
249
|
-
description: ({ value }) =>
|
|
283
|
+
description: ({ value }) =>
|
|
284
|
+
(`${typeof value === 'string' ? 20 - value.length : '20'} characters left`)
|
|
250
285
|
}
|
|
251
286
|
}
|
|
252
287
|
]
|
package/docs/fields/point.mdx
CHANGED
|
@@ -26,7 +26,7 @@ The data structure in the database matches the GeoJSON structure to represent po
|
|
|
26
26
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
27
27
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
28
28
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
29
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
29
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
30
30
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
31
31
|
| **`required`** | Require this field to have a value. |
|
|
32
32
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/radio.mdx
CHANGED
|
@@ -23,7 +23,7 @@ keywords: radio, fields, config, configuration, documentation, Content Managemen
|
|
|
23
23
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
24
24
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
25
25
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
26
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
26
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
27
27
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
28
28
|
| **`required`** | Require this field to have a value. |
|
|
29
29
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
@@ -33,7 +33,7 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
|
|
|
33
33
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
34
34
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
35
35
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
36
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
36
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
37
37
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
38
38
|
| **`required`** | Require this field to have a value. |
|
|
39
39
|
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
|
|
@@ -27,7 +27,7 @@ The Admin component is built on the powerful [`slatejs`](https://docs.slatejs.or
|
|
|
27
27
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
28
28
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
29
29
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
30
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
30
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
31
31
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
32
32
|
| **`required`** | Require this field to have a value. |
|
|
33
33
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/select.mdx
CHANGED
|
@@ -25,7 +25,7 @@ keywords: select, multi-select, fields, config, configuration, documentation, Co
|
|
|
25
25
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
26
26
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
27
27
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
28
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
28
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
29
29
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
30
30
|
| **`required`** | Require this field to have a value. |
|
|
31
31
|
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
|
package/docs/fields/text.mdx
CHANGED
|
@@ -25,7 +25,7 @@ keywords: text, fields, config, configuration, documentation, Content Management
|
|
|
25
25
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
26
26
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
27
27
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
28
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
28
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
29
29
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
30
30
|
| **`required`** | Require this field to have a value. |
|
|
31
31
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/textarea.mdx
CHANGED
|
@@ -25,7 +25,7 @@ keywords: textarea, fields, config, configuration, documentation, Content Manage
|
|
|
25
25
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
26
26
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
27
27
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
28
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
28
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) [More](/docs/fields/overview#default-values) |
|
|
29
29
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
30
30
|
| **`required`** | Require this field to have a value. |
|
|
31
31
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
package/docs/fields/upload.mdx
CHANGED
|
@@ -37,7 +37,7 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
|
|
|
37
37
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
38
38
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
39
39
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
40
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. |
|
|
40
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
41
41
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
42
42
|
| **`required`** | Require this field to have a value. |
|
|
43
43
|
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
|
|
@@ -133,6 +133,7 @@ const afterReadHook = async ({
|
|
|
133
133
|
doc, // full document data
|
|
134
134
|
req, // full express request
|
|
135
135
|
query, // JSON formatted query
|
|
136
|
+
findMany, // boolean to denote if this hook is running against finding one, or finding many
|
|
136
137
|
}) => {
|
|
137
138
|
return doc;
|
|
138
139
|
}
|
package/docs/hooks/fields.mdx
CHANGED
|
@@ -56,12 +56,13 @@ Field Hooks receive one `args` argument that contains the following properties:
|
|
|
56
56
|
|
|
57
57
|
| Option | Description |
|
|
58
58
|
| ----------------- | -------------|
|
|
59
|
-
| **`value`** | The value of the field. |
|
|
60
59
|
| **`data`** | The data passed to update the document within `create` and `update` operations, and the full document itself in the `afterRead` hook. |
|
|
61
|
-
| **`
|
|
62
|
-
| **`originalDoc`** | The full original document in `update` operations. |
|
|
60
|
+
| **`findMany`** | Boolean to denote if this hook is running against finding one, or finding many within the `afterRead` hook. |
|
|
63
61
|
| **`operation`** | A string relating to which operation the field type is currently executing within. Useful within `beforeValidate`, `beforeChange`, and `afterChange` hooks to differentiate between `create` and `update` operations. |
|
|
62
|
+
| **`originalDoc`** | The full original document in `update` operations. |
|
|
64
63
|
| **`req`** | The Express `request` object. It is mocked for Local API operations. |
|
|
64
|
+
| **`siblingData`** | The sibling data passed to a field that the hook is running against. |
|
|
65
|
+
| **`value`** | The value of the field. |
|
|
65
66
|
|
|
66
67
|
#### Return value
|
|
67
68
|
|
package/docs/hooks/globals.mdx
CHANGED
|
@@ -96,6 +96,7 @@ Runs as the last step before a global is returned. Flattens locales, hides prote
|
|
|
96
96
|
const afterReadHook = async ({
|
|
97
97
|
doc, // full document data
|
|
98
98
|
req, // full express request
|
|
99
|
+
findMany, // boolean to denote if this hook is running against finding one, or finding many (useful in versions)
|
|
99
100
|
}) => {...}
|
|
100
101
|
```
|
|
101
102
|
|
|
@@ -10,11 +10,11 @@ keywords: abuse, production, config, configuration, documentation, Content Manag
|
|
|
10
10
|
|
|
11
11
|
Payload has built-in security best practices that can be configured to your application-specific needs.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Limit Failed Login Attempts
|
|
14
14
|
|
|
15
15
|
Set the max number of failed login attempts before a user account is locked out for a period of time. Set the `maxLoginAttempts` on the collections that feature Authentication to a reasonable but low number for your users to get in. Use the `lockTime` to set a number in milliseconds from the time a user fails their last allowed attempt that a user must wait to try again.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
### Rate Limiting Requests
|
|
18
18
|
|
|
19
19
|
To prevent DDoS, brute-force, and similar attacks, you can set IP-based rate limits so that once a certain threshold of requests has been hit by a single IP, further requests from the same IP will be ignored. The Payload config `rateLimit` property accepts an object with the following properties:
|
|
20
20
|
|
|
@@ -30,21 +30,32 @@ To prevent DDoS, brute-force, and similar attacks, you can set IP-based rate lim
|
|
|
30
30
|
Very commonly, NodeJS apps are served behind `nginx` reverse proxies and similar. If you use rate-limiting while you're behind a proxy, <strong>all</strong> IP addresses from everyone that uses your API will appear as if they are from a local origin (127.0.0.1), and your users will get rate-limited very quickly without cause. If you plan to host your app behind a proxy, make sure you set <strong>trustProxy</strong> to <strong>true</strong>.
|
|
31
31
|
</Banner>
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
### Max Depth
|
|
34
34
|
|
|
35
35
|
Querying a collection and automatically including related documents via `depth` incurs a performance cost. Also, it's possible that your configs may have circular relationships, meaning scenarios where an infinite amount of relationships might populate back and forth until your server times out and crashes. You can prevent any potential of depth-related issues by setting a `maxDepth` property on your Payload config.. The maximum allowed depth should be as small as possible without interrupting dev experience, and it defaults to `10`.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
### Cross-Site Request Forgery (CSRF)
|
|
38
38
|
|
|
39
39
|
CSRF prevention will verify the authenticity of each request to your API to prevent a malicious action from another site from authorized users. See how to configure CSRF [here](/docs/authentication/overview#csrf-protection).
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
### Cross Origin Resource Sharing (CORS)
|
|
42
42
|
|
|
43
43
|
To securely allow headless operation you will need to configure the allowed origins for requests to be able to use the Payload API. You can see how to set CORS as well as other payload configuration settings [here](/docs/configuration/overview)
|
|
44
44
|
|
|
45
45
|
### Limiting GraphQL Complexity
|
|
46
|
+
|
|
46
47
|
Because GraphQL gives the power of query writing outside a server's control, someone with bad intentions might write a maliciously complex query and bog down your server. To prevent resource-intensive GraphQL requests, Payload provides a way specify complexity limits which are based on a complexity score that is calculated for each request.
|
|
47
48
|
|
|
48
49
|
Any GraphQL request that is calculated to be too expensive is rejected. On the Payload config, in `graphQL` you can set the `maxComplexity` value as an integer. For reference, the default complexity value for each added field is 1, and all `relationship` and `upload` fields are assigned a value of 10.
|
|
49
50
|
|
|
50
51
|
If you do not need GraphQL it is advised that you disable it altogether with the Payload config by setting `graphQL.disable: true`. Should you wish to enable GraphQL again, you can remove this property or set it `false`, any time. By turning it off, Payload will bypass creating schemas from your collections and will not register the express route.
|
|
52
|
+
|
|
53
|
+
### Malicious File Uploads
|
|
54
|
+
|
|
55
|
+
Payload does not execute uploaded files on the server, but depending on your setup it may be used to transmit and store potentially dangerous files. If your configuration allows file uploads there is the potential that a bad actor uploads a malicious file that is then served to other users. Consider the following ways to mitigate the risks.
|
|
56
|
+
|
|
57
|
+
First, enable email [verification](/docs/authentication/config#email-verification) when users are allowed to register new accounts and add other bot prevention services.
|
|
58
|
+
|
|
59
|
+
Review that `create` and `update` access on file upload collections are as restrictive as your application needs allow. Consider limiting `read` access of uploaded user's files and how you might limit user uploaded files from being served outside of Payload.
|
|
60
|
+
|
|
61
|
+
You can also add a [3rd party library](https://github.com/Cisco-Talos/clamav) to scan files in a [hook](/docs/hooks/collections) or have antivirus software in place.
|
|
@@ -64,7 +64,7 @@ The above example demonstrates a simple query but you can get much more complex.
|
|
|
64
64
|
| `in` | The value must be found within the provided comma-delimited list of values. |
|
|
65
65
|
| `not_in` | The value must NOT be within the provided comma-delimited list of values. |
|
|
66
66
|
| `exists` | Only return documents where the value either exists (`true`) or does not exist (`false`). |
|
|
67
|
-
| `near` | For distance related to a [point field](
|
|
67
|
+
| `near` | For distance related to a [point field](/docs/fields/point) comma separated as `<longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>`. |
|
|
68
68
|
|
|
69
69
|
<Banner type="success">
|
|
70
70
|
<strong>Tip</strong>:<br/>
|
|
@@ -65,7 +65,7 @@ Globals cannot be created or deleted, so there are only two REST endpoints opene
|
|
|
65
65
|
|
|
66
66
|
## Preferences
|
|
67
67
|
|
|
68
|
-
In addition to the dynamically generated endpoints above Payload also has REST endpoints to manage the admin user [preferences](/docs/admin#preferences) for data specific to the authenticated user.
|
|
68
|
+
In addition to the dynamically generated endpoints above Payload also has REST endpoints to manage the admin user [preferences](/docs/admin/overview#preferences) for data specific to the authenticated user.
|
|
69
69
|
|
|
70
70
|
| Method | Path | Description |
|
|
71
71
|
| -------- | --------------------------- | ----------------------- |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Node, React and MongoDB Headless CMS and Application Framework",
|
|
5
5
|
"license": "SEE LICENSE IN license.md",
|
|
6
6
|
"author": {
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"test:e2e": "DISABLE_LOGGING=true MONGO_URL=mongodb://localhost/payload-integration start-server-and-test dev http-get://localhost:3000/admin cy:run",
|
|
47
47
|
"clean": "rimraf dist",
|
|
48
48
|
"release": "release-it",
|
|
49
|
+
"release:patch": "release-it patch",
|
|
50
|
+
"release:minor": "release-it minor",
|
|
51
|
+
"release:major": "release-it major",
|
|
49
52
|
"release:beta": "release-it prepatch --config .release-it.beta.json",
|
|
50
53
|
"lint": "eslint \"src/**/*.ts\""
|
|
51
54
|
},
|