Revert "Removes runtime dependency babel-polyfill" (#2729)
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
],
|
],
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"babel-polyfill": "6.13.0",
|
||||||
"bcryptjs": "2.3.0",
|
"bcryptjs": "2.3.0",
|
||||||
"body-parser": "1.15.2",
|
"body-parser": "1.15.2",
|
||||||
"commander": "2.9.0",
|
"commander": "2.9.0",
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ const transformKeyValueForUpdate = (className, restKey, restValue, parseFormatSc
|
|||||||
}
|
}
|
||||||
|
|
||||||
const transformInteriorValue = restValue => {
|
const transformInteriorValue = restValue => {
|
||||||
if (restValue !== null && typeof restValue === 'object' && Object.keys(restValue).some(key => key.indexOf('$') >= 0 || key.indexOf('.') >= 0)) {
|
if (restValue !== null && typeof restValue === 'object' && Object.keys(restValue).some(key => key.includes('$') || key.includes('.'))) {
|
||||||
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
|
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
|
||||||
}
|
}
|
||||||
// Handle atomic values
|
// Handle atomic values
|
||||||
@@ -293,7 +293,7 @@ const parseObjectKeyValueToMongoObjectKeyValue = (restKey, restValue, schema) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle normal objects by recursing
|
// Handle normal objects by recursing
|
||||||
if (Object.keys(restValue).some(key => key.indexOf('$') >= 0 || key.indexOf('.') >= 0)) {
|
if (Object.keys(restValue).some(key => key.includes('$') || key.includes('.'))) {
|
||||||
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
|
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
|
||||||
}
|
}
|
||||||
value = _.mapValues(restValue, transformInteriorValue);
|
value = _.mapValues(restValue, transformInteriorValue);
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ export class PostgresStorageAdapter {
|
|||||||
return toParseSchema(schema)
|
return toParseSchema(schema)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err.code === PostgresUniqueIndexViolationError && err.detail.indexOf(className) >= 0) {
|
if (err.code === PostgresUniqueIndexViolationError && err.detail.includes(className)) {
|
||||||
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME, `Class ${className} already exists.`)
|
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME, `Class ${className} already exists.`)
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
@@ -445,7 +445,7 @@ export class PostgresStorageAdapter {
|
|||||||
relations.push(fieldName)
|
relations.push(fieldName)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (['_rperm', '_wperm'].indexOf(fieldName) >=0 ) {
|
if (['_rperm', '_wperm'].includes(fieldName)) {
|
||||||
parseType.contents = { type: 'String' };
|
parseType.contents = { type: 'String' };
|
||||||
}
|
}
|
||||||
valuesArray.push(fieldName);
|
valuesArray.push(fieldName);
|
||||||
@@ -678,7 +678,7 @@ export class PostgresStorageAdapter {
|
|||||||
valuesArray.push(object[fieldName].objectId);
|
valuesArray.push(object[fieldName].objectId);
|
||||||
break;
|
break;
|
||||||
case 'Array':
|
case 'Array':
|
||||||
if (['_rperm', '_wperm'].indexOf(fieldName) >= 0) {
|
if (['_rperm', '_wperm'].includes(fieldName)) {
|
||||||
valuesArray.push(object[fieldName]);
|
valuesArray.push(object[fieldName]);
|
||||||
} else {
|
} else {
|
||||||
valuesArray.push(JSON.stringify(object[fieldName]));
|
valuesArray.push(JSON.stringify(object[fieldName]));
|
||||||
@@ -707,7 +707,7 @@ export class PostgresStorageAdapter {
|
|||||||
let initialValues = valuesArray.map((val, index) => {
|
let initialValues = valuesArray.map((val, index) => {
|
||||||
let termination = '';
|
let termination = '';
|
||||||
let fieldName = columnsArray[index];
|
let fieldName = columnsArray[index];
|
||||||
if (['_rperm','_wperm'].indexOf(fieldName) >= 0) {
|
if (['_rperm','_wperm'].includes(fieldName)) {
|
||||||
termination = '::text[]';
|
termination = '::text[]';
|
||||||
} else if (schema.fields[fieldName] && schema.fields[fieldName].type === 'Array') {
|
} else if (schema.fields[fieldName] && schema.fields[fieldName].type === 'Array') {
|
||||||
termination = '::jsonb';
|
termination = '::jsonb';
|
||||||
@@ -1031,9 +1031,9 @@ export class PostgresStorageAdapter {
|
|||||||
const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${constraintPatterns.join(',')})`;
|
const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${constraintPatterns.join(',')})`;
|
||||||
return this._client.none(qs,[className, constraintName, ...fieldNames])
|
return this._client.none(qs,[className, constraintName, ...fieldNames])
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.code === PostgresDuplicateRelationError && error.message.indexOf(constraintName) >= 0) {
|
if (error.code === PostgresDuplicateRelationError && error.message.includes(constraintName)) {
|
||||||
// Index already exists. Ignore error.
|
// Index already exists. Ignore error.
|
||||||
} else if (error.code === PostgresUniqueIndexViolationError && error.message.indexOf(constraintName) >= 0) {
|
} else if (error.code === PostgresUniqueIndexViolationError && error.message.includes(constraintName)) {
|
||||||
// Cast the error into the proper parse error
|
// Cast the error into the proper parse error
|
||||||
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'A duplicate value for a field with unique values was provided');
|
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'A duplicate value for a field with unique values was provided');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ var batch = require('./batch'),
|
|||||||
path = require('path'),
|
path = require('path'),
|
||||||
authDataManager = require('./authDataManager');
|
authDataManager = require('./authDataManager');
|
||||||
|
|
||||||
|
if (!global._babelPolyfill) {
|
||||||
|
require('babel-polyfill');
|
||||||
|
}
|
||||||
|
|
||||||
import defaults from './defaults';
|
import defaults from './defaults';
|
||||||
import * as logging from './logger';
|
import * as logging from './logger';
|
||||||
import AppCache from './cache';
|
import AppCache from './cache';
|
||||||
|
|||||||
Reference in New Issue
Block a user