feat: Access the internal scope of Parse Server using the new maintenanceKey; the internal scope contains unofficial and undocumented fields (prefixed with underscore _) which are used internally by Parse Server; you may want to manipulate these fields for out-of-band changes such as data migration or correction tasks; changes within the internal scope of Parse Server may happen at any time without notice or changelog entry, it is therefore recommended to look at the source code of Parse Server to understand the effects of manipulating internal fields before using the key; it is discouraged to use the maintenanceKey for routine operations in a production environment; see [access scopes](https://github.com/parse-community/parse-server#access-scopes) (#8212)
BREAKING CHANGE: Fields in the internal scope of Parse Server (prefixed with underscore `_`) are only returned using the new `maintenanceKey`; previously the `masterKey` allowed reading of internal fields; see [access scopes](https://github.com/parse-community/parse-server#access-scopes) for a comparison of the keys' access permissions (#8212)
This commit is contained in:
@@ -1071,14 +1071,19 @@ export default class SchemaController {
|
||||
className: string,
|
||||
fieldName: string,
|
||||
type: string | SchemaField,
|
||||
isValidation?: boolean
|
||||
isValidation?: boolean,
|
||||
maintenance?: boolean
|
||||
) {
|
||||
if (fieldName.indexOf('.') > 0) {
|
||||
// subdocument key (x.y) => ok if x is of type 'object'
|
||||
fieldName = fieldName.split('.')[0];
|
||||
type = 'Object';
|
||||
}
|
||||
if (!fieldNameIsValid(fieldName, className)) {
|
||||
let fieldNameToValidate = `${fieldName}`;
|
||||
if (maintenance && fieldNameToValidate.charAt(0) === '_') {
|
||||
fieldNameToValidate = fieldNameToValidate.substring(1);
|
||||
}
|
||||
if (!fieldNameIsValid(fieldNameToValidate, className)) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, `Invalid field name: ${fieldName}.`);
|
||||
}
|
||||
|
||||
@@ -1228,7 +1233,7 @@ export default class SchemaController {
|
||||
// Validates an object provided in REST format.
|
||||
// Returns a promise that resolves to the new schema if this object is
|
||||
// valid.
|
||||
async validateObject(className: string, object: any, query: any) {
|
||||
async validateObject(className: string, object: any, query: any, maintenance: boolean) {
|
||||
let geocount = 0;
|
||||
const schema = await this.enforceClassExists(className);
|
||||
const promises = [];
|
||||
@@ -1258,7 +1263,7 @@ export default class SchemaController {
|
||||
// Every object has ACL implicitly.
|
||||
continue;
|
||||
}
|
||||
promises.push(schema.enforceFieldExists(className, fieldName, expected, true));
|
||||
promises.push(schema.enforceFieldExists(className, fieldName, expected, true, maintenance));
|
||||
}
|
||||
const results = await Promise.all(promises);
|
||||
const enforceFields = results.filter(result => !!result);
|
||||
|
||||
Reference in New Issue
Block a user