Skip to content

Commit 0ec1e8c

Browse files
authored
Revert "Removes runtime dependency babel-polyfill" (#2729)
1 parent e97579e commit 0ec1e8c

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
],
1919
"license": "BSD-3-Clause",
2020
"dependencies": {
21+
"babel-polyfill": "6.13.0",
2122
"bcryptjs": "2.3.0",
2223
"body-parser": "1.15.2",
2324
"commander": "2.9.0",

src/Adapters/Storage/Mongo/MongoTransform.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const transformKeyValueForUpdate = (className, restKey, restValue, parseFormatSc
9999
}
100100

101101
const transformInteriorValue = restValue => {
102-
if (restValue !== null && typeof restValue === 'object' && Object.keys(restValue).some(key => key.indexOf('$') >= 0 || key.indexOf('.') >= 0)) {
102+
if (restValue !== null && typeof restValue === 'object' && Object.keys(restValue).some(key => key.includes('$') || key.includes('.'))) {
103103
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
104104
}
105105
// Handle atomic values
@@ -293,7 +293,7 @@ const parseObjectKeyValueToMongoObjectKeyValue = (restKey, restValue, schema) =>
293293
}
294294

295295
// Handle normal objects by recursing
296-
if (Object.keys(restValue).some(key => key.indexOf('$') >= 0 || key.indexOf('.') >= 0)) {
296+
if (Object.keys(restValue).some(key => key.includes('$') || key.includes('.'))) {
297297
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
298298
}
299299
value = _.mapValues(restValue, transformInteriorValue);

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export class PostgresStorageAdapter {
415415
return toParseSchema(schema)
416416
})
417417
.catch((err) => {
418-
if (err.code === PostgresUniqueIndexViolationError && err.detail.indexOf(className) >= 0) {
418+
if (err.code === PostgresUniqueIndexViolationError && err.detail.includes(className)) {
419419
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME, `Class ${className} already exists.`)
420420
}
421421
throw err;
@@ -445,7 +445,7 @@ export class PostgresStorageAdapter {
445445
relations.push(fieldName)
446446
return;
447447
}
448-
if (['_rperm', '_wperm'].indexOf(fieldName) >=0 ) {
448+
if (['_rperm', '_wperm'].includes(fieldName)) {
449449
parseType.contents = { type: 'String' };
450450
}
451451
valuesArray.push(fieldName);
@@ -678,7 +678,7 @@ export class PostgresStorageAdapter {
678678
valuesArray.push(object[fieldName].objectId);
679679
break;
680680
case 'Array':
681-
if (['_rperm', '_wperm'].indexOf(fieldName) >= 0) {
681+
if (['_rperm', '_wperm'].includes(fieldName)) {
682682
valuesArray.push(object[fieldName]);
683683
} else {
684684
valuesArray.push(JSON.stringify(object[fieldName]));
@@ -707,7 +707,7 @@ export class PostgresStorageAdapter {
707707
let initialValues = valuesArray.map((val, index) => {
708708
let termination = '';
709709
let fieldName = columnsArray[index];
710-
if (['_rperm','_wperm'].indexOf(fieldName) >= 0) {
710+
if (['_rperm','_wperm'].includes(fieldName)) {
711711
termination = '::text[]';
712712
} else if (schema.fields[fieldName] && schema.fields[fieldName].type === 'Array') {
713713
termination = '::jsonb';
@@ -1031,9 +1031,9 @@ export class PostgresStorageAdapter {
10311031
const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${constraintPatterns.join(',')})`;
10321032
return this._client.none(qs,[className, constraintName, ...fieldNames])
10331033
.catch(error => {
1034-
if (error.code === PostgresDuplicateRelationError && error.message.indexOf(constraintName) >= 0) {
1034+
if (error.code === PostgresDuplicateRelationError && error.message.includes(constraintName)) {
10351035
// Index already exists. Ignore error.
1036-
} else if (error.code === PostgresUniqueIndexViolationError && error.message.indexOf(constraintName) >= 0) {
1036+
} else if (error.code === PostgresUniqueIndexViolationError && error.message.includes(constraintName)) {
10371037
// Cast the error into the proper parse error
10381038
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'A duplicate value for a field with unique values was provided');
10391039
} else {

src/ParseServer.js

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ var batch = require('./batch'),
99
path = require('path'),
1010
authDataManager = require('./authDataManager');
1111

12+
if (!global._babelPolyfill) {
13+
require('babel-polyfill');
14+
}
15+
1216
import defaults from './defaults';
1317
import * as logging from './logger';
1418
import AppCache from './cache';

0 commit comments

Comments
 (0)