@@ -67,7 +67,20 @@ var defaultColumns = {
67
67
"icon" : { type :'File' } ,
68
68
"order" : { type :'Number' } ,
69
69
"title" : { type :'String' } ,
70
- "subtitle" : { type :'String' } ,
70
+ "subtitle" : { type :'String' } ,
71
+ } ,
72
+ _PushStatus : {
73
+ "pushTime" : { type :'String' } ,
74
+ "source" : { type :'String' } , // rest or web
75
+ "query" : { type :'String' } , // the stringified JSON query
76
+ "payload" : { type :'Object' } , // the JSON payload,
77
+ "title" : { type :'String' } ,
78
+ "expiry" : { type :'Number' } ,
79
+ "status" : { type :'String' } ,
80
+ "numSent" : { type :'Number' } ,
81
+ "pushHash" : { type :'String' } ,
82
+ "errorMessage" : { type :'Object' } ,
83
+ "sentPerType" : { type :'Object' }
71
84
}
72
85
} ;
73
86
@@ -76,6 +89,8 @@ var requiredColumns = {
76
89
_Role : [ "name" , "ACL" ]
77
90
}
78
91
92
+ const systemClasses = [ '_User' , '_Installation' , '_Role' , '_Session' , '_Product' , '_PushStatus' ] ;
93
+
79
94
// 10 alpha numberic chars + uppercase
80
95
const userIdRegex = / ^ [ a - z A - Z 0 - 9 ] { 10 } $ / ;
81
96
// Anything that start with role
@@ -127,13 +142,8 @@ function validateCLP(perms) {
127
142
var joinClassRegex = / ^ _ J o i n : [ A - Z a - z 0 - 9 _ ] + : [ A - Z a - z 0 - 9 _ ] + / ;
128
143
var classAndFieldRegex = / ^ [ A - Z a - z ] [ A - Z a - z 0 - 9 _ ] * $ / ;
129
144
function classNameIsValid ( className ) {
130
- return (
131
- className === '_User' ||
132
- className === '_Installation' ||
133
- className === '_Session' ||
145
+ return ( systemClasses . indexOf ( className ) > - 1 ||
134
146
className === '_SCHEMA' || //TODO: remove this, as _SCHEMA is not a valid class name for storing Parse Objects.
135
- className === '_Role' ||
136
- className === '_Product' ||
137
147
joinClassRegex . test ( className ) ||
138
148
//Class names have the same constraints as field names, but also allow the previous additional names.
139
149
fieldNameIsValid ( className )
@@ -284,7 +294,7 @@ class Schema {
284
294
return Promise . reject ( error ) ;
285
295
} ) ;
286
296
}
287
-
297
+
288
298
updateClass ( className , submittedFields , classLevelPermissions , database ) {
289
299
if ( ! this . data [ className ] ) {
290
300
throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME , `Class ${ className } does not exist.` ) ;
@@ -299,7 +309,7 @@ class Schema {
299
309
throw new Parse . Error ( 255 , `Field ${ name } does not exist, cannot delete.` ) ;
300
310
}
301
311
} ) ;
302
-
312
+
303
313
let newSchema = buildMergedSchemaObject ( existingFields , submittedFields ) ;
304
314
let mongoObject = mongoSchemaFromFieldsAndClassNameAndCLP ( newSchema , className , classLevelPermissions ) ;
305
315
if ( ! mongoObject . result ) {
@@ -327,7 +337,7 @@ class Schema {
327
337
} ) ;
328
338
return Promise . all ( promises ) ;
329
339
} )
330
- . then ( ( ) => {
340
+ . then ( ( ) => {
331
341
return this . setPermissions ( className , classLevelPermissions )
332
342
} )
333
343
. then ( ( ) => { return mongoSchemaToSchemaAPIResponse ( mongoObject . result ) } ) ;
@@ -697,7 +707,7 @@ function mongoSchemaFromFieldsAndClassNameAndCLP(fields, className, classLevelPe
697
707
error : 'currently, only one GeoPoint field may exist in an object. Adding ' + geoPoints [ 1 ] + ' when ' + geoPoints [ 0 ] + ' already exists.' ,
698
708
} ;
699
709
}
700
-
710
+
701
711
validateCLP ( classLevelPermissions ) ;
702
712
if ( typeof classLevelPermissions !== 'undefined' ) {
703
713
mongoObject . _metadata = mongoObject . _metadata || { } ;
@@ -886,11 +896,11 @@ function mongoSchemaToSchemaAPIResponse(schema) {
886
896
className : schema . _id ,
887
897
fields : mongoSchemaAPIResponseFields ( schema ) ,
888
898
} ;
889
-
899
+
890
900
let classLevelPermissions = DefaultClassLevelPermissions ;
891
901
if ( schema . _metadata && schema . _metadata . class_permissions ) {
892
902
classLevelPermissions = Object . assign ( classLevelPermissions , schema . _metadata . class_permissions ) ;
893
- }
903
+ }
894
904
result . classLevelPermissions = classLevelPermissions ;
895
905
return result ;
896
906
}
@@ -903,4 +913,5 @@ module.exports = {
903
913
buildMergedSchemaObject : buildMergedSchemaObject ,
904
914
mongoFieldTypeToSchemaAPIType : mongoFieldTypeToSchemaAPIType ,
905
915
mongoSchemaToSchemaAPIResponse,
916
+ systemClasses,
906
917
} ;
0 commit comments