payload 1.6.32 → 1.7.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/dist/admin/Root.js +1 -0
- package/dist/admin/Root.js.map +1 -1
- package/dist/admin/components/Routes.js +8 -3
- package/dist/admin/components/Routes.js.map +1 -1
- package/dist/admin/components/elements/Nav/index.js +8 -4
- package/dist/admin/components/elements/Nav/index.js.map +1 -1
- package/dist/admin/components/elements/PreviewButton/index.js +30 -12
- package/dist/admin/components/elements/PreviewButton/index.js.map +1 -1
- package/dist/admin/components/elements/Status/index.js +5 -4
- package/dist/admin/components/elements/Status/index.js.map +1 -1
- package/dist/admin/components/forms/Form/index.js +7 -0
- package/dist/admin/components/forms/Form/index.js.map +1 -1
- package/dist/admin/components/forms/Form/initContextState.js +1 -0
- package/dist/admin/components/forms/Form/initContextState.js.map +1 -1
- package/dist/admin/components/forms/Form/types.d.ts +1 -0
- package/dist/admin/components/forms/field-types/Array/index.js +1 -2
- package/dist/admin/components/forms/field-types/Array/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/Blocks/BlocksDrawer/index.js +11 -1
- package/dist/admin/components/forms/field-types/Blocks/BlocksDrawer/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/Blocks/index.js +1 -2
- package/dist/admin/components/forms/field-types/Blocks/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/Textarea/index.scss +6 -5
- package/dist/admin/components/utilities/DocumentInfo/index.d.ts +1 -1
- package/dist/admin/components/utilities/DocumentInfo/index.js +18 -12
- package/dist/admin/components/utilities/DocumentInfo/index.js.map +1 -1
- package/dist/admin/components/utilities/DocumentInfo/types.d.ts +0 -3
- package/dist/admin/components/views/Dashboard/Default.js +8 -4
- package/dist/admin/components/views/Dashboard/Default.js.map +1 -1
- package/dist/admin/components/views/Dashboard/index.js +2 -1
- package/dist/admin/components/views/Dashboard/index.js.map +1 -1
- package/dist/admin/components/views/Dashboard/types.d.ts +2 -1
- package/dist/admin/components/views/Global/index.scss +15 -5
- package/dist/admin/components/views/Version/Version.js +5 -2
- package/dist/admin/components/views/Version/Version.js.map +1 -1
- package/dist/admin/components/views/collections/Edit/Default.js +5 -2
- package/dist/admin/components/views/collections/Edit/Default.js.map +1 -1
- package/dist/admin/components/views/collections/Edit/Upload/index.js +7 -4
- package/dist/admin/components/views/collections/Edit/Upload/index.js.map +1 -1
- package/dist/admin/components/views/collections/Edit/index.scss +11 -3
- package/dist/admin/components/views/collections/List/RelationshipProvider/index.js +11 -4
- package/dist/admin/components/views/collections/List/RelationshipProvider/index.js.map +1 -1
- package/dist/auth/getExecuteStaticAccess.js +17 -15
- package/dist/auth/getExecuteStaticAccess.js.map +1 -1
- package/dist/auth/strategies/apiKey.js +0 -1
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/collections/buildSchema.js +1 -1
- package/dist/collections/buildSchema.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +1 -0
- package/dist/collections/config/defaults.js +1 -0
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.js +5 -4
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/schema.js +2 -0
- package/dist/collections/config/schema.js.map +1 -1
- package/dist/collections/config/types.d.ts +13 -3
- package/dist/collections/initLocal.js +3 -2
- package/dist/collections/initLocal.js.map +1 -1
- package/dist/collections/operations/delete.js +11 -9
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.js +13 -11
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/find.d.ts +0 -1
- package/dist/collections/operations/find.js +14 -11
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.js +15 -12
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.js +13 -11
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.js +9 -5
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +0 -1
- package/dist/collections/operations/local/find.js +1 -2
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/restoreVersion.js +12 -10
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.js +13 -10
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.js +12 -10
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/config/defaults.js +1 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/schema.js +3 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/types.d.ts +13 -2
- package/dist/email/build.d.ts +1 -1
- package/dist/email/build.js +6 -3
- package/dist/email/build.js.map +1 -1
- package/dist/email/defaults.d.ts +2 -0
- package/dist/email/defaults.js +8 -0
- package/dist/email/defaults.js.map +1 -0
- package/dist/email/mockHandler.js +3 -2
- package/dist/email/mockHandler.js.map +1 -1
- package/dist/email/sendEmail.js +1 -1
- package/dist/email/sendEmail.js.map +1 -1
- package/dist/errors/QueryError.d.ts +8 -0
- package/dist/errors/QueryError.js +15 -0
- package/dist/errors/QueryError.js.map +1 -0
- package/dist/fields/config/schema.js +1 -0
- package/dist/fields/config/schema.js.map +1 -1
- package/dist/fields/config/types.d.ts +4 -0
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/validations.d.ts +1 -1
- package/dist/globals/buildModel.js +1 -1
- package/dist/globals/buildModel.js.map +1 -1
- package/dist/globals/config/sanitize.js +7 -5
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/schema.js +2 -0
- package/dist/globals/config/schema.js.map +1 -1
- package/dist/globals/config/types.d.ts +12 -2
- package/dist/globals/initLocal.js +3 -2
- package/dist/globals/initLocal.js.map +1 -1
- package/dist/globals/operations/findOne.js +15 -11
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.js +14 -11
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.js +10 -5
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/update.js +14 -11
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/graphql/errorHandler.d.ts +1 -8
- package/dist/graphql/errorHandler.js +2 -9
- package/dist/graphql/errorHandler.js.map +1 -1
- package/dist/graphql/graphQLHandler.d.ts +1 -6
- package/dist/graphql/graphQLHandler.js +24 -7
- package/dist/graphql/graphQLHandler.js.map +1 -1
- package/dist/graphql/registerSchema.js +2 -20
- package/dist/graphql/registerSchema.js.map +1 -1
- package/dist/initHTTP.js +1 -1
- package/dist/initHTTP.js.map +1 -1
- package/dist/mongoose/buildQuery.d.ts +76 -2
- package/dist/mongoose/buildQuery.js +274 -149
- package/dist/mongoose/buildQuery.js.map +1 -1
- package/dist/mongoose/sanitizeQueryValue.d.ts +12 -0
- package/dist/mongoose/{sanitizeFormattedValue.js → sanitizeQueryValue.js} +27 -26
- package/dist/mongoose/sanitizeQueryValue.js.map +1 -0
- package/dist/payload.d.ts +8 -6
- package/dist/payload.js +6 -2
- package/dist/payload.js.map +1 -1
- package/dist/translations/cs.json +1 -0
- package/dist/translations/de.json +1 -0
- package/dist/translations/en.json +1 -0
- package/dist/translations/es.json +1 -0
- package/dist/translations/fr.json +1 -0
- package/dist/translations/hr.json +1 -0
- package/dist/translations/hu.json +1 -0
- package/dist/translations/index.d.ts +21 -0
- package/dist/translations/it.json +1 -0
- package/dist/translations/ja.json +1 -0
- package/dist/translations/my.json +1 -0
- package/dist/translations/nb.json +1 -0
- package/dist/translations/nl.json +1 -0
- package/dist/translations/pl.json +1 -0
- package/dist/translations/pt.json +1 -0
- package/dist/translations/ru.json +1 -0
- package/dist/translations/sv.json +1 -0
- package/dist/translations/th.json +1 -0
- package/dist/translations/tr.json +1 -0
- package/dist/translations/ua.json +1 -0
- package/dist/translations/vi.json +1 -0
- package/dist/translations/zh.json +1 -0
- package/dist/uploads/generateFileData.js +4 -2
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/utilities/flattenWhereConstraints.d.ts +2 -2
- package/dist/utilities/flattenWhereConstraints.js +12 -13
- package/dist/utilities/flattenWhereConstraints.js.map +1 -1
- package/dist/utilities/getEntityPolicies.d.ts +6 -10
- package/dist/utilities/getEntityPolicies.js +25 -15
- package/dist/utilities/getEntityPolicies.js.map +1 -1
- package/dist/versions/drafts/queryDrafts.d.ts +4 -3
- package/dist/versions/drafts/queryDrafts.js +11 -9
- package/dist/versions/drafts/queryDrafts.js.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts +4 -2
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js +16 -13
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/docs/access-control/collections.mdx +1 -1
- package/docs/admin/hooks.mdx +0 -1
- package/docs/configuration/collections.mdx +15 -13
- package/docs/configuration/express.mdx +34 -0
- package/docs/configuration/globals.mdx +6 -4
- package/docs/configuration/localization.mdx +9 -0
- package/docs/configuration/overview.mdx +1 -0
- package/docs/fields/array.mdx +2 -1
- package/docs/fields/blocks.mdx +1 -0
- package/docs/fields/checkbox.mdx +1 -0
- package/docs/fields/code.mdx +1 -0
- package/docs/fields/collapsible.mdx +1 -0
- package/docs/fields/date.mdx +33 -32
- package/docs/fields/email.mdx +1 -0
- package/docs/fields/group.mdx +1 -0
- package/docs/fields/json.mdx +1 -0
- package/docs/fields/number.mdx +1 -0
- package/docs/fields/point.mdx +1 -0
- package/docs/fields/radio.mdx +1 -0
- package/docs/fields/relationship.mdx +2 -1
- package/docs/fields/rich-text.mdx +1 -0
- package/docs/fields/row.mdx +1 -0
- package/docs/fields/select.mdx +1 -0
- package/docs/fields/tabs.mdx +1 -0
- package/docs/fields/text.mdx +1 -0
- package/docs/fields/textarea.mdx +2 -1
- package/docs/fields/ui.mdx +1 -0
- package/docs/fields/upload.mdx +1 -0
- package/docs/getting-started/installation.mdx +2 -0
- package/docs/hooks/collections.mdx +7 -1
- package/docs/queries/overview.mdx +1 -1
- package/docs/rest-api/overview.mdx +2 -1
- package/package.json +4 -5
- package/dist/mongoose/sanitizeFormattedValue.d.ts +0 -2
- package/dist/mongoose/sanitizeFormattedValue.js.map +0 -1
- package/dist/versions/defaults.d.ts +0 -3
- package/dist/versions/defaults.js +0 -18
- package/dist/versions/defaults.js.map +0 -1
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// Take a where query and flatten it to all top-level operators
|
|
4
|
+
const flattenWhereConstraints = (query) => Object.entries(query).reduce((flattenedConstraints, [key, val]) => {
|
|
5
|
+
if ((key === 'and' || key === 'or') && Array.isArray(val)) {
|
|
6
|
+
return [
|
|
7
|
+
...flattenedConstraints,
|
|
8
|
+
...val.map((subVal) => flattenWhereConstraints(subVal)),
|
|
9
|
+
];
|
|
6
10
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (nested.length > 0) {
|
|
13
|
-
return nested.flatMap((nest) => flattenWhereConstraints(nest));
|
|
14
|
-
}
|
|
15
|
-
return query;
|
|
16
|
-
};
|
|
11
|
+
return [
|
|
12
|
+
...flattenedConstraints,
|
|
13
|
+
val,
|
|
14
|
+
];
|
|
15
|
+
}, []);
|
|
17
16
|
exports.default = flattenWhereConstraints;
|
|
18
17
|
//# sourceMappingURL=flattenWhereConstraints.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenWhereConstraints.js","sourceRoot":"","sources":["../../src/utilities/flattenWhereConstraints.ts"],"names":[],"mappings":";;AAEA,MAAM,uBAAuB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"flattenWhereConstraints.js","sourceRoot":"","sources":["../../src/utilities/flattenWhereConstraints.ts"],"names":[],"mappings":";;AAEA,+DAA+D;AAC/D,MAAM,uBAAuB,GAAG,CAAC,KAAY,EAAgB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;IAChI,IAAI,CAAC,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACzD,OAAO;YACL,GAAG,oBAAoB;YACvB,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;SACxD,CAAC;KACH;IAED,OAAO;QACL,GAAG,oBAAoB;QACvB,GAAG;KACJ,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,kBAAe,uBAAuB,CAAC"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { AllOperations } from '../types';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { SanitizedCollectionConfig } from '../collections/config/types';
|
|
3
|
+
import type { SanitizedGlobalConfig } from '../globals/config/types';
|
|
4
4
|
import type { PayloadRequest } from '../express/types';
|
|
5
5
|
import type { CollectionPermission, GlobalPermission } from '../auth/types';
|
|
6
|
-
type Args =
|
|
6
|
+
type Args = {
|
|
7
7
|
req: PayloadRequest;
|
|
8
8
|
operations: AllOperations[];
|
|
9
9
|
id?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} | {
|
|
14
|
-
type: 'global';
|
|
15
|
-
entity: GlobalConfig;
|
|
16
|
-
}));
|
|
10
|
+
type: 'collection' | 'global';
|
|
11
|
+
entity: SanitizedCollectionConfig | SanitizedGlobalConfig;
|
|
12
|
+
};
|
|
17
13
|
type ReturnType<T extends Args> = T['type'] extends 'global' ? [GlobalPermission, Promise<void>[]] : [CollectionPermission, Promise<void>[]];
|
|
18
14
|
export declare function getEntityPolicies<T extends Args>(args: T): ReturnType<T>;
|
|
19
15
|
export {};
|
|
@@ -71,9 +71,10 @@ function getEntityPolicies(args) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
const executeFieldPolicies = ({ policiesObj
|
|
75
|
-
const mutablePolicies = policiesObj;
|
|
76
|
-
fields.forEach((field) => {
|
|
74
|
+
const executeFieldPolicies = async ({ policiesObj, fields, operation, entityAccessPromise, }) => {
|
|
75
|
+
const mutablePolicies = policiesObj.fields;
|
|
76
|
+
fields.forEach(async (field) => {
|
|
77
|
+
var _a;
|
|
77
78
|
if (field.name) {
|
|
78
79
|
if (!mutablePolicies[field.name])
|
|
79
80
|
mutablePolicies[field.name] = {};
|
|
@@ -87,25 +88,29 @@ function getEntityPolicies(args) {
|
|
|
87
88
|
}));
|
|
88
89
|
}
|
|
89
90
|
else {
|
|
91
|
+
if (entityAccessPromise)
|
|
92
|
+
await entityAccessPromise;
|
|
90
93
|
mutablePolicies[field.name][operation] = {
|
|
91
|
-
permission:
|
|
94
|
+
permission: (_a = policiesObj[operation]) === null || _a === void 0 ? void 0 : _a.permission,
|
|
92
95
|
};
|
|
93
96
|
}
|
|
94
97
|
if (field.fields) {
|
|
95
98
|
if (!mutablePolicies[field.name].fields)
|
|
96
99
|
mutablePolicies[field.name].fields = {};
|
|
97
100
|
executeFieldPolicies({
|
|
98
|
-
policiesObj: mutablePolicies[field.name]
|
|
101
|
+
policiesObj: mutablePolicies[field.name],
|
|
99
102
|
fields: field.fields,
|
|
100
103
|
operation,
|
|
104
|
+
entityAccessPromise,
|
|
101
105
|
});
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
else if (field.fields) {
|
|
105
109
|
executeFieldPolicies({
|
|
106
|
-
policiesObj
|
|
110
|
+
policiesObj,
|
|
107
111
|
fields: field.fields,
|
|
108
112
|
operation,
|
|
113
|
+
entityAccessPromise,
|
|
109
114
|
});
|
|
110
115
|
}
|
|
111
116
|
else if (field.type === 'tabs') {
|
|
@@ -114,16 +119,18 @@ function getEntityPolicies(args) {
|
|
|
114
119
|
if (!mutablePolicies[tab.name])
|
|
115
120
|
mutablePolicies[tab.name] = { fields: {} };
|
|
116
121
|
executeFieldPolicies({
|
|
117
|
-
policiesObj: mutablePolicies[tab.name]
|
|
122
|
+
policiesObj: mutablePolicies[tab.name],
|
|
118
123
|
fields: tab.fields,
|
|
119
124
|
operation,
|
|
125
|
+
entityAccessPromise,
|
|
120
126
|
});
|
|
121
127
|
}
|
|
122
128
|
else {
|
|
123
129
|
executeFieldPolicies({
|
|
124
|
-
policiesObj
|
|
130
|
+
policiesObj,
|
|
125
131
|
fields: tab.fields,
|
|
126
132
|
operation,
|
|
133
|
+
entityAccessPromise,
|
|
127
134
|
});
|
|
128
135
|
}
|
|
129
136
|
});
|
|
@@ -131,24 +138,27 @@ function getEntityPolicies(args) {
|
|
|
131
138
|
});
|
|
132
139
|
};
|
|
133
140
|
operations.forEach((operation) => {
|
|
134
|
-
|
|
135
|
-
policiesObj: policies.fields,
|
|
136
|
-
fields: entity.fields,
|
|
137
|
-
operation,
|
|
138
|
-
});
|
|
141
|
+
let entityAccessPromise;
|
|
139
142
|
if (typeof entity.access[operation] === 'function') {
|
|
140
|
-
|
|
143
|
+
entityAccessPromise = createAccessPromise({
|
|
141
144
|
policiesObj: policies,
|
|
142
145
|
access: entity.access[operation],
|
|
143
146
|
operation,
|
|
144
147
|
accessLevel: 'entity',
|
|
145
|
-
})
|
|
148
|
+
});
|
|
149
|
+
promises.push(entityAccessPromise);
|
|
146
150
|
}
|
|
147
151
|
else {
|
|
148
152
|
policies[operation] = {
|
|
149
153
|
permission: isLoggedIn,
|
|
150
154
|
};
|
|
151
155
|
}
|
|
156
|
+
executeFieldPolicies({
|
|
157
|
+
policiesObj: policies,
|
|
158
|
+
fields: entity.fields,
|
|
159
|
+
operation,
|
|
160
|
+
entityAccessPromise,
|
|
161
|
+
});
|
|
152
162
|
});
|
|
153
163
|
return [policies, promises];
|
|
154
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntityPolicies.js","sourceRoot":"","sources":["../../src/utilities/getEntityPolicies.ts"],"names":[],"mappings":";;;AAEA,kDAAiE;
|
|
1
|
+
{"version":3,"file":"getEntityPolicies.js","sourceRoot":"","sources":["../../src/utilities/getEntityPolicies.ts"],"names":[],"mappings":";;;AAEA,kDAAiE;AA2BjE,SAAgB,iBAAiB,CAAiB,IAAO;IACvD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACnD,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,+CAA+C;IAC/C,2CAA2C;IAC3C,6CAA6C;IAC7C,+CAA+C;IAC/C,MAAM,QAAQ,GAAG;QACf,MAAM,EAAE,EAAE;KACS,CAAC;IACtB,MAAM,QAAQ,GAAG,EAAsB,CAAC;IACxC,IAAI,gBAAgB,CAAC;IAErB,KAAK,UAAU,YAAY,CAAC,EAAE,KAAK,KAAwB,EAAE;;QAC3D,IAAI,MAAM,CAAC,IAAI,EAAE;YACf,IAAI,IAAI,KAAK,QAAQ,EAAE;gBACrB,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC;oBAC5B,cAAc,EAAE,IAAI;oBACpB,IAAI,EAAE,MAAM,CAAC,IAAI;iBAClB,CAAC,CAAC;aACJ;YAED,IAAI,IAAI,KAAK,YAAY,IAAI,EAAE,EAAE;gBAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;oBAC7B,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;wBAC1C,cAAc,EAAE,IAAI;wBACpB,UAAU,EAAE,MAAM,CAAC,IAAI;wBACvB,KAAK,EAAE;4BACL,GAAG,KAAK;4BACR,GAAG,EAAE;gCACH,GAAG,KAAK,CAAC,GAAG,IAAI,EAAE;gCAClB;oCACE,EAAE,EAAE;wCACF,MAAM,EAAE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T,WAAW,EAAE,QAAQ;aACtB,CAAC,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;SACpC;aAAM;YACL,QAAQ,CAAC,SAAS,CAAC,GAAG;gBACpB,UAAU,EAAE,UAAU;aACvB,CAAC;SACH;QAED,oBAAoB,CAAC;YACnB,WAAW,EAAE,QAAQ;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS;YACT,mBAAmB;SACpB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAkB,CAAC;AAC/C,CAAC;AA7KD,8CA6KC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { PaginateOptions } from 'mongoose';
|
|
2
2
|
import { AccessResult } from '../../config/types';
|
|
3
|
-
import { Where } from '../../types';
|
|
3
|
+
import { PayloadRequest, Where } from '../../types';
|
|
4
4
|
import { Payload } from '../../payload';
|
|
5
5
|
import { PaginatedDocs } from '../../mongoose/types';
|
|
6
6
|
import { Collection, TypeWithID } from '../../collections/config/types';
|
|
7
7
|
type Args = {
|
|
8
8
|
accessResult: AccessResult;
|
|
9
9
|
collection: Collection;
|
|
10
|
-
|
|
10
|
+
req: PayloadRequest;
|
|
11
|
+
overrideAccess: boolean;
|
|
11
12
|
paginationOptions?: PaginateOptions;
|
|
12
13
|
payload: Payload;
|
|
13
14
|
where: Where;
|
|
14
15
|
};
|
|
15
|
-
export declare const queryDrafts: <T extends TypeWithID>({ accessResult, collection,
|
|
16
|
+
export declare const queryDrafts: <T extends TypeWithID>({ accessResult, collection, req, overrideAccess, payload, paginationOptions, where: incomingWhere, }: Args) => Promise<PaginatedDocs<T>>;
|
|
16
17
|
export {};
|
|
@@ -3,23 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queryDrafts = void 0;
|
|
4
4
|
const auth_1 = require("../../auth");
|
|
5
5
|
const appendVersionToQueryKey_1 = require("./appendVersionToQueryKey");
|
|
6
|
-
const queryDrafts = async ({ accessResult, collection,
|
|
6
|
+
const queryDrafts = async ({ accessResult, collection, req, overrideAccess, payload, paginationOptions, where: incomingWhere, }) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const VersionModel = payload.versions[collection.config.slug];
|
|
9
9
|
const where = (0, appendVersionToQueryKey_1.appendVersionToQueryKey)(incomingWhere || {});
|
|
10
10
|
const versionQueryToBuild = {
|
|
11
|
-
where
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
],
|
|
16
|
-
},
|
|
11
|
+
...where,
|
|
12
|
+
and: [
|
|
13
|
+
...(where === null || where === void 0 ? void 0 : where.and) || [],
|
|
14
|
+
],
|
|
17
15
|
};
|
|
18
16
|
if ((0, auth_1.hasWhereAccessResult)(accessResult)) {
|
|
19
17
|
const versionAccessResult = (0, appendVersionToQueryKey_1.appendVersionToQueryKey)(accessResult);
|
|
20
|
-
versionQueryToBuild.
|
|
18
|
+
versionQueryToBuild.and.push(versionAccessResult);
|
|
21
19
|
}
|
|
22
|
-
const versionQuery = await VersionModel.buildQuery(
|
|
20
|
+
const versionQuery = await VersionModel.buildQuery({
|
|
21
|
+
where: versionQueryToBuild,
|
|
22
|
+
req,
|
|
23
|
+
overrideAccess,
|
|
24
|
+
});
|
|
23
25
|
const aggregate = VersionModel.aggregate([
|
|
24
26
|
// Sort so that newest are first
|
|
25
27
|
{ $sort: { updatedAt: -1 } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryDrafts.js","sourceRoot":"","sources":["../../../src/versions/drafts/queryDrafts.ts"],"names":[],"mappings":";;;AAMA,qCAAkD;AAClD,uEAAoE;
|
|
1
|
+
{"version":3,"file":"queryDrafts.js","sourceRoot":"","sources":["../../../src/versions/drafts/queryDrafts.ts"],"names":[],"mappings":";;;AAMA,qCAAkD;AAClD,uEAAoE;AAmB7D,MAAM,WAAW,GAAG,KAAK,EAAwB,EACtD,YAAY,EACZ,UAAU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M,wBAAwB,GAAG;YAC/B,GAAG,iBAAiB;YACpB,QAAQ,EAAE,MAAA,OAAO,CAAC,YAAY,0CAAE,QAAQ;YACxC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC;iBACzC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,EAAE;gBACzC,IAAI,GAAG,GAAG,eAAe,CAAC;gBAE1B,IAAI,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;oBAChE,GAAG,GAAG,WAAW,eAAe,EAAE,CAAC;iBACpC;gBAED,OAAO;oBACL,GAAG,IAAI;oBACP,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAChC,CAAC;YACJ,CAAC,EAAE,EAAE,CAAC;SACT,CAAC;QAEF,MAAM,GAAG,MAAM,YAAY,CAAC,iBAAiB,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;KACpF;SAAM;QACL,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;KAC3B;IAED,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC9B,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,GAAG,GAAG,CAAC,OAAO;YACd,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;SACzB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC;AApFW,QAAA,WAAW,eAoFtB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Payload } from '../../payload';
|
|
2
|
+
import { PayloadRequest } from '../../types';
|
|
2
3
|
import { AccessResult } from '../../config/types';
|
|
3
4
|
import { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types';
|
|
4
5
|
import { SanitizedGlobalConfig } from '../../globals/config/types';
|
|
@@ -7,8 +8,9 @@ type Arguments<T> = {
|
|
|
7
8
|
entity: SanitizedCollectionConfig | SanitizedGlobalConfig;
|
|
8
9
|
entityType: 'collection' | 'global';
|
|
9
10
|
doc: T;
|
|
10
|
-
|
|
11
|
+
req: PayloadRequest;
|
|
12
|
+
overrideAccess: boolean;
|
|
11
13
|
accessResult: AccessResult;
|
|
12
14
|
};
|
|
13
|
-
declare const replaceWithDraftIfAvailable: <T extends TypeWithID>({ payload, entity, entityType, doc,
|
|
15
|
+
declare const replaceWithDraftIfAvailable: <T extends TypeWithID>({ payload, entity, entityType, doc, req, overrideAccess, accessResult, }: Arguments<T>) => Promise<T>;
|
|
14
16
|
export default replaceWithDraftIfAvailable;
|
|
@@ -7,28 +7,26 @@ const types_1 = require("../../types");
|
|
|
7
7
|
const auth_1 = require("../../auth");
|
|
8
8
|
const sanitizeInternalFields_1 = __importDefault(require("../../utilities/sanitizeInternalFields"));
|
|
9
9
|
const appendVersionToQueryKey_1 = require("./appendVersionToQueryKey");
|
|
10
|
-
const replaceWithDraftIfAvailable = async ({ payload, entity, entityType, doc,
|
|
10
|
+
const replaceWithDraftIfAvailable = async ({ payload, entity, entityType, doc, req, overrideAccess, accessResult, }) => {
|
|
11
11
|
const VersionModel = payload.versions[entity.slug];
|
|
12
12
|
const queryToBuild = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
'
|
|
17
|
-
equals: 'draft',
|
|
18
|
-
},
|
|
13
|
+
and: [
|
|
14
|
+
{
|
|
15
|
+
'version._status': {
|
|
16
|
+
equals: 'draft',
|
|
19
17
|
},
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
},
|
|
19
|
+
],
|
|
22
20
|
};
|
|
23
21
|
if (entityType === 'collection') {
|
|
24
|
-
queryToBuild.
|
|
22
|
+
queryToBuild.and.push({
|
|
25
23
|
parent: {
|
|
26
24
|
equals: doc.id,
|
|
27
25
|
},
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
if ((0, types_1.docHasTimestamps)(doc)) {
|
|
31
|
-
queryToBuild.
|
|
29
|
+
queryToBuild.and.push({
|
|
32
30
|
updatedAt: {
|
|
33
31
|
greater_than: doc.updatedAt,
|
|
34
32
|
},
|
|
@@ -36,9 +34,14 @@ const replaceWithDraftIfAvailable = async ({ payload, entity, entityType, doc, l
|
|
|
36
34
|
}
|
|
37
35
|
if ((0, auth_1.hasWhereAccessResult)(accessResult)) {
|
|
38
36
|
const versionAccessResult = (0, appendVersionToQueryKey_1.appendVersionToQueryKey)(accessResult);
|
|
39
|
-
queryToBuild.
|
|
37
|
+
queryToBuild.and.push(versionAccessResult);
|
|
40
38
|
}
|
|
41
|
-
const query = await VersionModel.buildQuery(
|
|
39
|
+
const query = await VersionModel.buildQuery({
|
|
40
|
+
where: queryToBuild,
|
|
41
|
+
req,
|
|
42
|
+
overrideAccess,
|
|
43
|
+
globalSlug: entityType === 'global' ? entity.slug : undefined,
|
|
44
|
+
});
|
|
42
45
|
let draft = await VersionModel.findOne(query, {}, {
|
|
43
46
|
lean: true,
|
|
44
47
|
sort: { updatedAt: 'desc' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replaceWithDraftIfAvailable.js","sourceRoot":"","sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"names":[],"mappings":";;;;;AACA,
|
|
1
|
+
{"version":3,"file":"replaceWithDraftIfAvailable.js","sourceRoot":"","sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"names":[],"mappings":";;;;;AACA,uCAAsE;AACtE,qCAAkD;AAGlD,oGAA4E;AAC5E,uEAAoE;AAapE,MAAM,2BAA2B,GAAG,KAAK,EAAwB,EAC/D,OAAO,EACP,MAAM,EACN,UAAU,EACV,GAAG,EACH,GAAG,EACH,cAAc,EACd,YAAY,GACC,EAAc,EAAE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AC,KAAK,CAAC,CAAC,CAAC;IAC1C,KAAK,GAAG,IAAA,gCAAsB,EAAC,KAAK,CAAC,CAAC;IAEtC,mDAAmD;IACnD,yCAAyC;IACzC,4CAA4C;IAC5C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,GAAG,KAAK,CAAC,OAAO;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,2BAA2B,CAAC"}
|
package/docs/admin/hooks.mdx
CHANGED
|
@@ -166,7 +166,6 @@ The `useDocumentInfo` hook provides lots of information about the document curre
|
|
|
166
166
|
|---------------------------|--------------------------------------------------------------------------------------------------------------------| |
|
|
167
167
|
| **`collection`** | If the doc is a collection, its collection config will be returned |
|
|
168
168
|
| **`global`** | If the doc is a global, its global config will be returned |
|
|
169
|
-
| **`type`** | The type of document being edited (collection or global) |
|
|
170
169
|
| **`id`** | If the doc is a collection, its ID will be returned |
|
|
171
170
|
| **`preferencesKey`** | The `preferences` key to use when interacting with document-level user preferences |
|
|
172
171
|
| **`versions`** | Versions of the current doc |
|
|
@@ -27,8 +27,9 @@ It's often best practice to write your Collections in separate files and then im
|
|
|
27
27
|
| **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api/overview#custom-endpoints) |
|
|
28
28
|
| **`graphQL`** | An object with `singularName` and `pluralName` strings used in schema generation. Auto-generated from slug if not defined. |
|
|
29
29
|
| **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
|
|
30
|
-
| **`defaultSort`** | Pass a top-level field to sort by default in the collection List view. Prefix the name of the field with a minus symbol ("-") to sort in descending order.
|
|
31
|
-
| **`pagination`** | Set pagination-specific options for this collection. [More](#pagination)
|
|
30
|
+
| **`defaultSort`** | Pass a top-level field to sort by default in the collection List view. Prefix the name of the field with a minus symbol ("-") to sort in descending order. |
|
|
31
|
+
| **`pagination`** | Set pagination-specific options for this collection. [More](#pagination) |
|
|
32
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
32
33
|
|
|
33
34
|
*\* An asterisk denotes that a property is required.*
|
|
34
35
|
|
|
@@ -63,18 +64,19 @@ You can find an assortment of [example collection configs](https://github.com/pa
|
|
|
63
64
|
|
|
64
65
|
You can customize the way that the Admin panel behaves on a collection-by-collection basis by defining the `admin` property on a collection's config.
|
|
65
66
|
|
|
66
|
-
| Option
|
|
67
|
-
|
|
68
|
-
| `group`
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
67
|
+
| Option | Description |
|
|
68
|
+
|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
69
|
+
| `group` | Text used as a label for grouping collection links together in the navigation. |
|
|
70
|
+
| `hidden` | Set to true or a function, called with the current user, returning true to exclude this collection from navigation and admin routing. |
|
|
71
|
+
| `hooks` | Admin-specific hooks for this collection. [More](#admin-hooks) |
|
|
72
|
+
| `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin panel. If no field is defined, the ID of the document is used as the title. |
|
|
73
|
+
| `description` | Text or React component to display below the Collection label in the List view to give editors more information. |
|
|
74
|
+
| `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
|
|
75
|
+
| `disableDuplicate ` | Disables the "Duplicate" button while editing documents within this collection. |
|
|
74
76
|
| `enableRichTextRelationship` | The [Rich Text](/docs/fields/rich-text) field features a `Relationship` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. |
|
|
75
|
-
| `preview`
|
|
76
|
-
| `components`
|
|
77
|
-
| `listSearchableFields`
|
|
77
|
+
| `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
|
|
78
|
+
| `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
|
|
79
|
+
| `listSearchableFields` | Specify which fields should be searched in the List search view. [More](#list-searchable-fields) |
|
|
78
80
|
|
|
79
81
|
### Preview
|
|
80
82
|
|
|
@@ -8,6 +8,40 @@ keywords: config, configuration, documentation, Content Management System, cms,
|
|
|
8
8
|
|
|
9
9
|
Payload utilizes a few Express-specific middleware packages within its own routers. You can customize how they work by passing in configuration options to the main Payload config's `express` property.
|
|
10
10
|
|
|
11
|
+
### Custom Middleware
|
|
12
|
+
|
|
13
|
+
Payload allows you to pass in custom Express middleware to be used on all of the routes it opens. This is useful for adding logging or any other custom functionality to your endpoints.
|
|
14
|
+
|
|
15
|
+
There are 2 exposed properties. Each property is an array of middleware functions.
|
|
16
|
+
|
|
17
|
+
- `preMiddleware` - runs before any of the Payload middleware
|
|
18
|
+
- `postMiddleware` - runs after all of the Payload middleware
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
{
|
|
22
|
+
express: {
|
|
23
|
+
preMiddleware: [
|
|
24
|
+
(req, res, next) => {
|
|
25
|
+
// do something
|
|
26
|
+
next()
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
postMiddleware: [
|
|
30
|
+
(req, res, next) => {
|
|
31
|
+
// do something
|
|
32
|
+
next()
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Example logging middleware function
|
|
39
|
+
const requestLoggerMiddleware = (req, res, next) => {
|
|
40
|
+
req.payload.logger.info(`request: ${req.method} ${req.url}`)
|
|
41
|
+
next()
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
11
45
|
### JSON
|
|
12
46
|
|
|
13
47
|
`express.json()` is used to parse JSON body content into JavaScript objects accessible on the Express `req`. Payload allows you to customize all of the `json` method's options. Common examples of customization use-cases are increasing the max allowed JSON body size which defaults to `2MB`.
|
|
@@ -25,6 +25,7 @@ As with Collection configs, it's often best practice to write your Globals in se
|
|
|
25
25
|
| **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api/overview#custom-endpoints) |
|
|
26
26
|
| **`graphQL.name`** | Text used in schema generation. Auto-generated from slug if not defined. |
|
|
27
27
|
| **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
|
|
28
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
28
29
|
|
|
29
30
|
_\* An asterisk denotes that a property is required._
|
|
30
31
|
|
|
@@ -64,10 +65,11 @@ You can find an [example Global config](https://github.com/payloadcms/public-dem
|
|
|
64
65
|
|
|
65
66
|
You can customize the way that the Admin panel behaves on a Global-by-Global basis by defining the `admin` property on a Global's config.
|
|
66
67
|
|
|
67
|
-
| Option | Description
|
|
68
|
-
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
68
|
+
| Option | Description |
|
|
69
|
+
|--------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
|
70
|
+
| `hidden` | Set to true or a function, called with the current user, returning true to exclude this global from navigation and admin routing. |
|
|
71
|
+
| `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) |
|
|
72
|
+
| `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). |
|
|
71
73
|
|
|
72
74
|
### Preview
|
|
73
75
|
|
|
@@ -72,6 +72,15 @@ All field types with a `name` property support the `localized` property—even t
|
|
|
72
72
|
Enabling localization for field types that support nested fields will automatically create localized "sets" of all fields contained within the field. For example, if you have a page layout using a blocks field type, you have the choice of either localizing the full layout, by enabling localization on the top-level blocks field, or only certain fields within the layout.
|
|
73
73
|
</Banner>
|
|
74
74
|
|
|
75
|
+
<Banner type="warning">
|
|
76
|
+
<strong>Important:</strong>
|
|
77
|
+
<br />
|
|
78
|
+
When converting an existing field to or from `localized: true` the data
|
|
79
|
+
structure in the document will change for this field and so existing data for
|
|
80
|
+
this field will be lost. Before changing the localization setting on fields
|
|
81
|
+
with existing data, you may need to consider a field migration strategy.
|
|
82
|
+
</Banner>
|
|
83
|
+
|
|
75
84
|
### Retrieving localized docs
|
|
76
85
|
|
|
77
86
|
When retrieving documents, you can specify which locale you'd like to receive as well as which fallback locale should be used.
|
|
@@ -43,6 +43,7 @@ Payload is a _config-based_, code-first CMS and application framework. The Paylo
|
|
|
43
43
|
| `hooks` | Tap into Payload-wide hooks. [More](/docs/hooks/overview) |
|
|
44
44
|
| `plugins` | An array of Payload plugins. [More](/docs/plugins/overview) |
|
|
45
45
|
| `endpoints` | An array of custom API endpoints added to the Payload router. [More](/docs/rest-api/overview#custom-endpoints) |
|
|
46
|
+
| `custom` | Extension point for adding custom data (e.g. for plugins) |
|
|
46
47
|
|
|
47
48
|
#### Simple example
|
|
48
49
|
|
package/docs/fields/array.mdx
CHANGED
|
@@ -35,7 +35,8 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
|
|
|
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. |
|
|
38
|
-
| **`admin`**
|
|
38
|
+
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
39
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
39
40
|
|
|
40
41
|
*\* An asterisk denotes that a property is required.*
|
|
41
42
|
|
package/docs/fields/blocks.mdx
CHANGED
|
@@ -37,6 +37,7 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme
|
|
|
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. |
|
|
39
39
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
40
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
40
41
|
|
|
41
42
|
*\* An asterisk denotes that a property is required.*
|
|
42
43
|
|
package/docs/fields/checkbox.mdx
CHANGED
|
@@ -26,6 +26,7 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
|
|
|
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. |
|
|
29
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
29
30
|
|
|
30
31
|
*\* An asterisk denotes that a property is required.*
|
|
31
32
|
|
package/docs/fields/code.mdx
CHANGED
|
@@ -32,6 +32,7 @@ This field uses the `monaco-react` editor syntax highlighting.
|
|
|
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). |
|
|
35
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
35
36
|
|
|
36
37
|
_\* An asterisk denotes that a property is required._
|
|
37
38
|
|
|
@@ -17,6 +17,7 @@ keywords: row, fields, config, configuration, documentation, Content Management
|
|
|
17
17
|
| **`label`** * | A label to render within the header of the collapsible component. This can be a string, function or react component. Function/components receive `({ data, path })` as args. |
|
|
18
18
|
| **`fields`** * | Array of field types to nest within this Collapsible. |
|
|
19
19
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
20
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
20
21
|
|
|
21
22
|
*\* An asterisk denotes that a property is required.*
|
|
22
23
|
|