parse 5.1.0-alpha.8 → 5.1.0-alpha.9

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v5.1.0-alpha.8
2
+ * Parse JavaScript SDK v5.1.0-alpha.9
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -378,181 +378,16 @@ _Object$defineProperty(exports, "__esModule", {
378
378
  exports.default = void 0;
379
379
  var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
380
380
  var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
381
- /*
382
- * @flow
383
- */
384
- /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
385
- /*:: import type ParseFile from './ParseFile';*/
386
- /*:: import type { FileSource } from './ParseFile';*/
387
- /*:: import type { Op } from './ParseOp';*/
388
- /*:: import type ParseObject, {SaveOptions} from './ParseObject';*/
389
- /*:: import type { QueryJSON } from './ParseQuery';*/
390
- /*:: import type ParseUser from './ParseUser';*/
391
- /*:: import type { AuthData } from './ParseUser';*/
392
- /*:: import type { PushData } from './Push';*/
393
- /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
394
- /*:: type AnalyticsController = {
395
- track: (name: string, dimensions: { [key: string]: string }) => Promise,
396
- };*/
397
- /*:: type CloudController = {
398
- run: (name: string, data: mixed, options: RequestOptions) => Promise,
399
- getJobsData: (options: RequestOptions) => Promise,
400
- startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
401
- };*/
402
- /*:: type ConfigController = {
403
- current: () => Promise,
404
- get: () => Promise,
405
- save: (attrs: { [key: string]: any }) => Promise,
406
- };*/
407
- /*:: type CryptoController = {
408
- encrypt: (obj: any, secretKey: string) => string,
409
- decrypt: (encryptedText: string, secretKey: any) => string,
410
- };*/
411
- /*:: type FileController = {
412
- saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
413
- saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
414
- download: (uri: string) => Promise,
415
- };*/
416
- /*:: type InstallationController = {
417
- currentInstallationId: () => Promise,
418
- };*/
419
- /*:: type ObjectController = {
420
- fetch: (
421
- object: ParseObject | Array<ParseObject>,
422
- forceFetch: boolean,
423
- options: RequestOptions
424
- ) => Promise,
425
- save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
426
- destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
427
- };*/
428
- /*:: type ObjectStateController = {
429
- getState: (obj: any) => ?State,
430
- initializeState: (obj: any, initial?: State) => State,
431
- removeState: (obj: any) => ?State,
432
- getServerData: (obj: any) => AttributeMap,
433
- setServerData: (obj: any, attributes: AttributeMap) => void,
434
- getPendingOps: (obj: any) => Array<OpsMap>,
435
- setPendingOp: (obj: any, attr: string, op: ?Op) => void,
436
- pushPendingState: (obj: any) => void,
437
- popPendingState: (obj: any) => OpsMap,
438
- mergeFirstPendingState: (obj: any) => void,
439
- getObjectCache: (obj: any) => ObjectCache,
440
- estimateAttribute: (obj: any, attr: string) => mixed,
441
- estimateAttributes: (obj: any) => AttributeMap,
442
- commitServerChanges: (obj: any, changes: AttributeMap) => void,
443
- enqueueTask: (obj: any, task: () => Promise) => Promise,
444
- clearAllState: () => void,
445
- duplicateState: (source: any, dest: any) => void,
446
- };*/
447
- /*:: type PushController = {
448
- send: (data: PushData) => Promise,
449
- };*/
450
- /*:: type QueryController = {
451
- find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
452
- aggregate: (className: string, params: any, options: RequestOptions) => Promise,
453
- };*/
454
- /*:: type EventuallyQueue = {
455
- save: (object: ParseObject, serverOptions: SaveOptions) => Promise,
456
- destroy: (object: ParseObject, serverOptions: RequestOptions) => Promise,
457
- poll: (ms: number) => void
458
- };*/
459
- /*:: type RESTController = {
460
- request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
461
- ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
462
- };*/
463
- /*:: type SchemaController = {
464
- purge: (className: string) => Promise,
465
- get: (className: string, options: RequestOptions) => Promise,
466
- delete: (className: string, options: RequestOptions) => Promise,
467
- create: (className: string, params: any, options: RequestOptions) => Promise,
468
- update: (className: string, params: any, options: RequestOptions) => Promise,
469
- send(className: string, method: string, params: any, options: RequestOptions): Promise,
470
- };*/
471
- /*:: type SessionController = {
472
- getSession: (token: RequestOptions) => Promise,
473
- };*/
474
- /*:: type StorageController =
475
- | {
476
- async: 0,
477
- getItem: (path: string) => ?string,
478
- setItem: (path: string, value: string) => void,
479
- removeItem: (path: string) => void,
480
- getItemAsync?: (path: string) => Promise,
481
- setItemAsync?: (path: string, value: string) => Promise,
482
- removeItemAsync?: (path: string) => Promise,
483
- clear: () => void,
484
- }
485
- | {
486
- async: 1,
487
- getItem?: (path: string) => ?string,
488
- setItem?: (path: string, value: string) => void,
489
- removeItem?: (path: string) => void,
490
- getItemAsync: (path: string) => Promise,
491
- setItemAsync: (path: string, value: string) => Promise,
492
- removeItemAsync: (path: string) => Promise,
493
- clear: () => void,
494
- };*/
495
- /*:: type LocalDatastoreController = {
496
- fromPinWithName: (name: string) => ?any,
497
- pinWithName: (name: string, objects: any) => void,
498
- unPinWithName: (name: string) => void,
499
- getAllContents: () => ?any,
500
- clear: () => void,
501
- };*/
502
- /*:: type UserController = {
503
- setCurrentUser: (user: ParseUser) => Promise,
504
- currentUser: () => ?ParseUser,
505
- currentUserAsync: () => Promise,
506
- signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
507
- logIn: (user: ParseUser, options: RequestOptions) => Promise,
508
- become: (options: RequestOptions) => Promise,
509
- hydrate: (userJSON: AttributeMap) => Promise,
510
- logOut: (options: RequestOptions) => Promise,
511
- me: (options: RequestOptions) => Promise,
512
- requestPasswordReset: (email: string, options: RequestOptions) => Promise,
513
- updateUserOnDisk: (user: ParseUser) => Promise,
514
- upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
515
- linkWith: (user: ParseUser, authData: AuthData) => Promise,
516
- removeUserFromDisk: () => Promise,
517
- verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
518
- requestEmailVerification: (email: string, options: RequestOptions) => Promise,
519
- };*/
520
- /*:: type HooksController = {
521
- get: (type: string, functionName?: string, triggerName?: string) => Promise,
522
- create: (hook: mixed) => Promise,
523
- delete: (hook: mixed) => Promise,
524
- update: (hook: mixed) => Promise,
525
- send: (method: string, path: string, body?: mixed) => Promise,
526
- };*/
527
- /*:: type WebSocketController = {
381
+ /** Based on https://github.com/react-native-async-storage/async-storage/blob/main/packages/default-storage-backend/src/types.ts */
382
+ /*:: export type WebSocketController = {
528
383
  onopen: () => void,
529
384
  onmessage: (message: any) => void,
530
- onclose: () => void,
385
+ onclose: (arg?: any) => void,
531
386
  onerror: (error: any) => void,
532
387
  send: (data: any) => void,
533
388
  close: () => void,
534
389
  };*/
535
- /*:: type Config = {
536
- AnalyticsController?: AnalyticsController,
537
- CloudController?: CloudController,
538
- ConfigController?: ConfigController,
539
- FileController?: FileController,
540
- InstallationController?: InstallationController,
541
- ObjectController?: ObjectController,
542
- ObjectStateController?: ObjectStateController,
543
- PushController?: PushController,
544
- QueryController?: QueryController,
545
- RESTController?: RESTController,
546
- SchemaController?: SchemaController,
547
- SessionController?: SessionController,
548
- StorageController?: StorageController,
549
- LocalDatastoreController?: LocalDatastoreController,
550
- UserController?: UserController,
551
- HooksController?: HooksController,
552
- WebSocketController?: WebSocketController,
553
- };*/
554
- var config /*: Config & { [key: string]: mixed }*/ = {
555
- // Defaults
390
+ var config /*: Config & { [key: string]: any }*/ = {
556
391
  IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
557
392
  REQUEST_ATTEMPT_LIMIT: 5,
558
393
  REQUEST_BATCH_SIZE: 20,
@@ -562,7 +397,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
562
397
  SERVER_AUTH_TOKEN: null,
563
398
  LIVEQUERY_SERVER_URL: null,
564
399
  ENCRYPTED_KEY: null,
565
- VERSION: 'js' + "5.1.0-alpha.8",
400
+ VERSION: 'js' + "5.1.0-alpha.9",
566
401
  APPLICATION_ID: null,
567
402
  JAVASCRIPT_KEY: null,
568
403
  MASTER_KEY: null,
@@ -636,11 +471,18 @@ var CoreManager = {
636
471
  requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
637
472
  config['FileController'] = controller;
638
473
  },
474
+ setEventuallyQueue: function (controller /*: EventuallyQueue*/) {
475
+ requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
476
+ config['EventuallyQueue'] = controller;
477
+ },
478
+ getEventuallyQueue: function () /*: EventuallyQueue*/{
479
+ return config['EventuallyQueue'];
480
+ },
639
481
  getFileController: function () /*: FileController*/{
640
482
  return config['FileController'];
641
483
  },
642
484
  setInstallationController: function (controller /*: InstallationController*/) {
643
- requireMethods('InstallationController', ['currentInstallationId'], controller);
485
+ requireMethods('InstallationController', ['currentInstallationId', 'currentInstallation', 'updateInstallationOnDisk'], controller);
644
486
  config['InstallationController'] = controller;
645
487
  },
646
488
  getInstallationController: function () /*: InstallationController*/{
@@ -687,13 +529,6 @@ var CoreManager = {
687
529
  getRESTController: function () /*: RESTController*/{
688
530
  return config['RESTController'];
689
531
  },
690
- setEventuallyQueue: function (controller /*: EventuallyQueue*/) {
691
- requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
692
- config['EventuallyQueue'] = controller;
693
- },
694
- getEventuallyQueue: function () /*: EventuallyQueue*/{
695
- return config['EventuallyQueue'];
696
- },
697
532
  setSchemaController: function (controller /*: SchemaController*/) {
698
533
  requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
699
534
  config['SchemaController'] = controller;
@@ -732,16 +567,16 @@ var CoreManager = {
732
567
  getStorageController: function () /*: StorageController*/{
733
568
  return config['StorageController'];
734
569
  },
735
- setAsyncStorage: function (storage /*: any*/) {
570
+ setAsyncStorage: function (storage /*: AsyncStorageType*/) {
736
571
  config['AsyncStorage'] = storage;
737
572
  },
738
573
  getAsyncStorage: function () {
739
574
  return config['AsyncStorage'];
740
575
  },
741
- setWebSocketController: function (controller /*: WebSocketController*/) {
576
+ setWebSocketController: function (controller /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/) {
742
577
  config['WebSocketController'] = controller;
743
578
  },
744
- getWebSocketController: function () /*: WebSocketController*/{
579
+ getWebSocketController: function () /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/{
745
580
  return config['WebSocketController'];
746
581
  },
747
582
  setUserController: function (controller /*: UserController*/) {
@@ -751,11 +586,11 @@ var CoreManager = {
751
586
  getUserController: function () /*: UserController*/{
752
587
  return config['UserController'];
753
588
  },
754
- setLiveQueryController: function (controller /*: any*/) {
589
+ setLiveQueryController: function (controller /*: LiveQueryControllerType*/) {
755
590
  requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
756
591
  config['LiveQueryController'] = controller;
757
592
  },
758
- getLiveQueryController: function () /*: any*/{
593
+ getLiveQueryController: function () /*: LiveQueryControllerType*/{
759
594
  return config['LiveQueryController'];
760
595
  },
761
596
  setHooksController: function (controller /*: HooksController*/) {
@@ -1637,42 +1472,153 @@ if (typeof window !== 'undefined' && window.indexedDB) {
1637
1472
  },{"@babel/runtime-corejs3/core-js-stable/instance/keys":72,"idb-keyval":625}],10:[function(_dereq_,module,exports){
1638
1473
  "use strict";
1639
1474
 
1475
+ var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
1640
1476
  var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
1641
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
1477
+ _Object$defineProperty(exports, "__esModule", {
1478
+ value: true
1479
+ });
1480
+ exports.default = void 0;
1481
+ var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
1482
+ var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
1483
+ var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
1484
+ var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
1642
1485
  var _Storage = _interopRequireDefault(_dereq_("./Storage"));
1643
- /**
1644
- * @flow
1645
- */
1646
-
1647
- var uuidv4 = _dereq_('./uuid');
1648
- var iidCache = null;
1486
+ var _ParseInstallation = _interopRequireDefault(_dereq_("./ParseInstallation"));
1487
+ var _uuid = _interopRequireDefault(_dereq_("./uuid"));
1488
+ var CURRENT_INSTALLATION_KEY = 'currentInstallation';
1489
+ var CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
1490
+ var iidCache /*: string | null*/ = null;
1491
+ var currentInstallationCache = null;
1492
+ var currentInstallationCacheMatchesDisk = false;
1649
1493
  var InstallationController = {
1494
+ updateInstallationOnDisk: function (installation /*: ParseInstallation*/) /*: Promise<void>*/{
1495
+ var _this = this;
1496
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
1497
+ var path;
1498
+ return _regenerator.default.wrap(function (_context) {
1499
+ while (1) switch (_context.prev = _context.next) {
1500
+ case 0:
1501
+ path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
1502
+ _context.next = 3;
1503
+ return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
1504
+ case 3:
1505
+ _this._setCurrentInstallationCache(installation);
1506
+ case 4:
1507
+ case "end":
1508
+ return _context.stop();
1509
+ }
1510
+ }, _callee);
1511
+ }))();
1512
+ },
1650
1513
  currentInstallationId: function () /*: Promise<string>*/{
1651
- if (typeof iidCache === 'string') {
1652
- return _promise.default.resolve(iidCache);
1653
- }
1654
- var path = _Storage.default.generatePath('installationId');
1655
- return _Storage.default.getItemAsync(path).then(function (iid) {
1656
- if (!iid) {
1657
- iid = uuidv4();
1658
- return _Storage.default.setItemAsync(path, iid).then(function () {
1659
- iidCache = iid;
1660
- return iid;
1661
- });
1662
- }
1663
- iidCache = iid;
1664
- return iid;
1665
- });
1514
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
1515
+ var path, iid;
1516
+ return _regenerator.default.wrap(function (_context2) {
1517
+ while (1) switch (_context2.prev = _context2.next) {
1518
+ case 0:
1519
+ if (!(typeof iidCache === 'string')) {
1520
+ _context2.next = 2;
1521
+ break;
1522
+ }
1523
+ return _context2.abrupt("return", iidCache);
1524
+ case 2:
1525
+ path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
1526
+ _context2.next = 5;
1527
+ return _Storage.default.getItemAsync(path);
1528
+ case 5:
1529
+ iid = _context2.sent;
1530
+ if (iid) {
1531
+ _context2.next = 9;
1532
+ break;
1533
+ }
1534
+ iid = (0, _uuid.default)();
1535
+ return _context2.abrupt("return", _Storage.default.setItemAsync(path, iid).then(function () {
1536
+ iidCache = iid;
1537
+ return iid;
1538
+ }));
1539
+ case 9:
1540
+ iidCache = iid;
1541
+ return _context2.abrupt("return", iid);
1542
+ case 11:
1543
+ case "end":
1544
+ return _context2.stop();
1545
+ }
1546
+ }, _callee2);
1547
+ }))();
1548
+ },
1549
+ currentInstallation: function () /*: Promise<ParseInstallation | null>*/{
1550
+ var _this2 = this;
1551
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
1552
+ var path, installationData, current, installationId, installation;
1553
+ return _regenerator.default.wrap(function (_context3) {
1554
+ while (1) switch (_context3.prev = _context3.next) {
1555
+ case 0:
1556
+ if (!currentInstallationCache) {
1557
+ _context3.next = 2;
1558
+ break;
1559
+ }
1560
+ return _context3.abrupt("return", currentInstallationCache);
1561
+ case 2:
1562
+ if (!currentInstallationCacheMatchesDisk) {
1563
+ _context3.next = 4;
1564
+ break;
1565
+ }
1566
+ return _context3.abrupt("return", null);
1567
+ case 4:
1568
+ path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
1569
+ _context3.next = 7;
1570
+ return _Storage.default.getItemAsync(path);
1571
+ case 7:
1572
+ installationData = _context3.sent;
1573
+ currentInstallationCacheMatchesDisk = true;
1574
+ if (!installationData) {
1575
+ _context3.next = 15;
1576
+ break;
1577
+ }
1578
+ installationData = JSON.parse(installationData);
1579
+ installationData.className = '_Installation';
1580
+ current = _ParseInstallation.default.fromJSON(installationData);
1581
+ currentInstallationCache = current;
1582
+ return _context3.abrupt("return", current);
1583
+ case 15:
1584
+ _context3.next = 17;
1585
+ return _this2.currentInstallationId();
1586
+ case 17:
1587
+ installationId = _context3.sent;
1588
+ installation = new _ParseInstallation.default();
1589
+ installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
1590
+ installation.set('installationId', installationId);
1591
+ installation.set('parseVersion', _CoreManager.default.get('VERSION'));
1592
+ currentInstallationCache = installation;
1593
+ _context3.next = 25;
1594
+ return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
1595
+ case 25:
1596
+ return _context3.abrupt("return", installation);
1597
+ case 26:
1598
+ case "end":
1599
+ return _context3.stop();
1600
+ }
1601
+ }, _callee3);
1602
+ }))();
1666
1603
  },
1667
1604
  _clearCache: function () {
1668
1605
  iidCache = null;
1606
+ currentInstallationCache = null;
1607
+ currentInstallationCacheMatchesDisk = false;
1669
1608
  },
1670
1609
  _setInstallationIdCache: function (iid /*: string*/) {
1671
1610
  iidCache = iid;
1611
+ },
1612
+ _setCurrentInstallationCache: function (installation /*: ParseInstallation*/) {
1613
+ var matchesDisk /*: boolean*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1614
+ currentInstallationCache = installation;
1615
+ currentInstallationCacheMatchesDisk = matchesDisk;
1672
1616
  }
1673
1617
  };
1674
1618
  module.exports = InstallationController;
1675
- },{"./Storage":41,"./uuid":59,"@babel/runtime-corejs3/core-js-stable/promise":95,"@babel/runtime-corejs3/helpers/interopRequireDefault":115}],11:[function(_dereq_,module,exports){
1619
+ var _default = InstallationController;
1620
+ exports.default = _default;
1621
+ },{"./CoreManager":4,"./ParseInstallation":26,"./Storage":41,"./uuid":59,"@babel/runtime-corejs3/core-js-stable/json/stringify":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":86,"@babel/runtime-corejs3/helpers/asyncToGenerator":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":115,"@babel/runtime-corejs3/regenerator":133}],11:[function(_dereq_,module,exports){
1676
1622
  "use strict";
1677
1623
 
1678
1624
  var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
@@ -4453,10 +4399,11 @@ var Parse /*: ParseType*/ = {
4453
4399
  _CoreManager.default.setIfNeeded('EventEmitter', _EventEmitter.default);
4454
4400
  _CoreManager.default.setIfNeeded('LiveQuery', new _ParseLiveQuery.default());
4455
4401
  _CoreManager.default.setIfNeeded('CryptoController', _CryptoController.default);
4402
+ _CoreManager.default.setIfNeeded('EventuallyQueue', _EventuallyQueue.default);
4403
+ _CoreManager.default.setIfNeeded('InstallationController', _InstallationController.default);
4456
4404
  _CoreManager.default.setIfNeeded('LocalDatastoreController', _LocalDatastoreController.default);
4457
4405
  _CoreManager.default.setIfNeeded('StorageController', _StorageController.default);
4458
4406
  _CoreManager.default.setIfNeeded('WebSocketController', _WebSocketController.default);
4459
- _CoreManager.default.setIfNeeded('EventuallyQueue', _EventuallyQueue.default);
4460
4407
  },
4461
4408
  /**
4462
4409
  * Call this method to set your AsyncStorage engine
@@ -4698,7 +4645,6 @@ var Parse /*: ParseType*/ = {
4698
4645
  return this.encryptedUser;
4699
4646
  }
4700
4647
  };
4701
- _CoreManager.default.setInstallationController(_InstallationController.default);
4702
4648
  _CoreManager.default.setRESTController(_RESTController.default);
4703
4649
  // For legacy requires, of the form `var Parse = require('parse').Parse`
4704
4650
  Parse.Parse = Parse;
@@ -6753,6 +6699,10 @@ XHR = _dereq_('./Xhr.weapp');
6753
6699
  /*:: type Base64 = { base64: string };*/
6754
6700
  /*:: type Uri = { uri: string };*/
6755
6701
  /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
6702
+ /*:: export type FileSaveOptions = FullOptions & {
6703
+ metadata?: { [key: string]: any },
6704
+ tags?: { [key: string]: any },
6705
+ };*/
6756
6706
  /*:: export type FileSource =
6757
6707
  | {
6758
6708
  format: 'file',
@@ -7565,12 +7515,16 @@ _Object$defineProperty(exports, "__esModule", {
7565
7515
  value: true
7566
7516
  });
7567
7517
  exports.default = void 0;
7518
+ var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
7519
+ var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
7568
7520
  var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
7569
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
7570
7521
  var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
7522
+ var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
7523
+ var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
7571
7524
  var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
7572
7525
  var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
7573
7526
  var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
7527
+ var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
7574
7528
  var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
7575
7529
  function _createSuper(Derived) {
7576
7530
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
@@ -7596,29 +7550,286 @@ function _isNativeReflectConstruct() {
7596
7550
  } catch (e) {
7597
7551
  return false;
7598
7552
  }
7599
- } /**
7600
- * @flow
7553
+ }
7554
+ var DEVICE_TYPES /*: DeviceInterface*/ = {
7555
+ IOS: 'ios',
7556
+ MACOS: 'macos',
7557
+ TVOS: 'tvos',
7558
+ FCM: 'fcm',
7559
+ ANDROID: 'android',
7560
+ WEB: 'web'
7561
+ };
7562
+
7563
+ /**
7564
+ * Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
7565
+ * This class is a subclass of a Parse.Object, and retains the same functionality of a Parse.Object, but also extends it with installation-specific features.
7566
+ *
7567
+ * <p>A valid Parse.Installation can only be instantiated via <code>Parse.Installation.currentInstallation()</code>
7568
+ *
7569
+ * Parse.Installation objects which have a valid <code>deviceToken</code> and are saved to the Parse cloud can be used to target push notifications.
7570
+ * </p>
7571
+ *
7572
+ * @alias Parse.Installation
7573
+ */
7574
+ var ParseInstallation = /*#__PURE__*/function (_ParseObject) {
7575
+ (0, _inherits2.default)(ParseInstallation, _ParseObject);
7576
+ var _super = _createSuper(ParseInstallation);
7577
+ /**
7578
+ * @param {object} attributes The initial set of data to store in the object.
7601
7579
  */
7602
- /*:: import type { AttributeMap } from './ObjectStateMutations';*/
7603
- var Installation = /*#__PURE__*/function (_ParseObject) {
7604
- (0, _inherits2.default)(Installation, _ParseObject);
7605
- var _super = _createSuper(Installation);
7606
- function Installation(attributes /*: ?AttributeMap*/) {
7580
+ function ParseInstallation(attributes /*:: ?: AttributeMap*/) {
7607
7581
  var _this;
7608
- (0, _classCallCheck2.default)(this, Installation);
7582
+ (0, _classCallCheck2.default)(this, ParseInstallation);
7609
7583
  _this = _super.call(this, '_Installation');
7610
7584
  if (attributes && (0, _typeof2.default)(attributes) === 'object') {
7611
- if (!_this.set(attributes || {})) {
7585
+ if (!_this.set(attributes)) {
7612
7586
  throw new Error("Can't create an invalid Installation");
7613
7587
  }
7614
7588
  }
7615
7589
  return _this;
7616
7590
  }
7617
- return (0, _createClass2.default)(Installation);
7591
+
7592
+ /**
7593
+ * A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
7594
+ *
7595
+ * @property {string} appIdentifier
7596
+ * @static
7597
+ */
7598
+ (0, _createClass2.default)(ParseInstallation, [{
7599
+ key: "appIdentifier",
7600
+ get: function () {
7601
+ return this.get('appIdentifier');
7602
+ }
7603
+
7604
+ /**
7605
+ * The version string of the client application to which this installation belongs.
7606
+ *
7607
+ * @property {string} appVersion
7608
+ * @static
7609
+ */
7610
+ }, {
7611
+ key: "appVersion",
7612
+ get: function () {
7613
+ return this.get('appVersion');
7614
+ }
7615
+
7616
+ /**
7617
+ * The display name of the client application to which this installation belongs.
7618
+ *
7619
+ * @property {string} appName
7620
+ * @static
7621
+ */
7622
+ }, {
7623
+ key: "appName",
7624
+ get: function () {
7625
+ return this.get('appName');
7626
+ }
7627
+
7628
+ /**
7629
+ * The current value of the icon badge for iOS apps.
7630
+ * Changes to this value on the server will be used
7631
+ * for future badge-increment push notifications.
7632
+ *
7633
+ * @property {number} badge
7634
+ * @static
7635
+ */
7636
+ }, {
7637
+ key: "badge",
7638
+ get: function () {
7639
+ return this.get('badge');
7640
+ }
7641
+
7642
+ /**
7643
+ * An array of the channels to which a device is currently subscribed.
7644
+ *
7645
+ * @property {string[]} channels
7646
+ * @static
7647
+ */
7648
+ }, {
7649
+ key: "channels",
7650
+ get: function () {
7651
+ return this.get('channels');
7652
+ }
7653
+
7654
+ /**
7655
+ * Token used to deliver push notifications to the device.
7656
+ *
7657
+ * @property {string} deviceToken
7658
+ * @static
7659
+ */
7660
+ }, {
7661
+ key: "deviceToken",
7662
+ get: function () {
7663
+ return this.get('deviceToken');
7664
+ }
7665
+
7666
+ /**
7667
+ * The type of device, “ios”, “android”, “web”, etc.
7668
+ *
7669
+ * @property {string} deviceType
7670
+ * @static
7671
+ */
7672
+ }, {
7673
+ key: "deviceType",
7674
+ get: function () {
7675
+ return this.get('deviceType');
7676
+ }
7677
+
7678
+ /**
7679
+ * Gets the GCM sender identifier for this installation
7680
+ *
7681
+ * @property {string} GCMSenderId
7682
+ * @static
7683
+ */
7684
+ }, {
7685
+ key: "GCMSenderId",
7686
+ get: function () {
7687
+ return this.get('GCMSenderId');
7688
+ }
7689
+
7690
+ /**
7691
+ * Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
7692
+ *
7693
+ * @property {string} installationId
7694
+ * @static
7695
+ */
7696
+ }, {
7697
+ key: "installationId",
7698
+ get: function () {
7699
+ return this.get('installationId');
7700
+ }
7701
+
7702
+ /**
7703
+ * Gets the local identifier for this installation
7704
+ *
7705
+ * @property {string} localeIdentifier
7706
+ * @static
7707
+ */
7708
+ }, {
7709
+ key: "localeIdentifier",
7710
+ get: function () {
7711
+ return this.get('localeIdentifier');
7712
+ }
7713
+
7714
+ /**
7715
+ * Gets the parse server version for this installation
7716
+ *
7717
+ * @property {string} parseVersion
7718
+ * @static
7719
+ */
7720
+ }, {
7721
+ key: "parseVersion",
7722
+ get: function () {
7723
+ return this.get('parseVersion');
7724
+ }
7725
+
7726
+ /**
7727
+ * This field is reserved for directing Parse to the push delivery network to be used.
7728
+ *
7729
+ * @property {string} pushType
7730
+ * @static
7731
+ */
7732
+ }, {
7733
+ key: "pushType",
7734
+ get: function () {
7735
+ return this.get('pushType');
7736
+ }
7737
+
7738
+ /**
7739
+ * Gets the time zone for this installation
7740
+ *
7741
+ * @property {string} timeZone
7742
+ * @static
7743
+ */
7744
+ }, {
7745
+ key: "timeZone",
7746
+ get: function () {
7747
+ return this.get('timeZone');
7748
+ }
7749
+
7750
+ /**
7751
+ * Returns the device types for used for Push Notifications.
7752
+ *
7753
+ * <pre>
7754
+ * Parse.Installation.DEVICE_TYPES.IOS
7755
+ * Parse.Installation.DEVICE_TYPES.MACOS
7756
+ * Parse.Installation.DEVICE_TYPES.TVOS
7757
+ * Parse.Installation.DEVICE_TYPES.FCM
7758
+ * Parse.Installation.DEVICE_TYPES.ANDROID
7759
+ * Parse.Installation.DEVICE_TYPES.WEB
7760
+ * </pre
7761
+ *
7762
+ * @property {Object} DEVICE_TYPES
7763
+ * @static
7764
+ */
7765
+ }, {
7766
+ key: "save",
7767
+ value:
7768
+ /**
7769
+ * Wrap the default save behavior with functionality to save to local storage.
7770
+ *
7771
+ * @param {...any} args
7772
+ * @returns {Promise}
7773
+ */
7774
+ function () {
7775
+ var _save = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
7776
+ var _len,
7777
+ args,
7778
+ _key,
7779
+ _args = arguments;
7780
+ return _regenerator.default.wrap(function (_context) {
7781
+ while (1) switch (_context.prev = _context.next) {
7782
+ case 0:
7783
+ for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7784
+ args[_key] = _args[_key];
7785
+ }
7786
+ _context.next = 3;
7787
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseInstallation.prototype), "save", this).apply(this, args);
7788
+ case 3:
7789
+ _context.next = 5;
7790
+ return _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
7791
+ case 5:
7792
+ return _context.abrupt("return", this);
7793
+ case 6:
7794
+ case "end":
7795
+ return _context.stop();
7796
+ }
7797
+ }, _callee, this);
7798
+ }));
7799
+ function save() {
7800
+ return _save.apply(this, arguments);
7801
+ }
7802
+ return save;
7803
+ }()
7804
+ /**
7805
+ * Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
7806
+ *
7807
+ * <pre>
7808
+ * const installation = await Parse.Installation.currentInstallation();
7809
+ * installation.set('deviceToken', '123');
7810
+ * await installation.save();
7811
+ * </pre>
7812
+ *
7813
+ * @returns {Promise} A promise that resolves to the local installation object.
7814
+ */
7815
+ }], [{
7816
+ key: "DEVICE_TYPES",
7817
+ get: function () /*: DeviceInterface*/{
7818
+ return DEVICE_TYPES;
7819
+ }
7820
+ }, {
7821
+ key: "currentInstallation",
7822
+ value: function () /*: Promise<ParseInstallation>*/{
7823
+ return _CoreManager.default.getInstallationController().currentInstallation();
7824
+ }
7825
+ }]);
7826
+ return ParseInstallation;
7618
7827
  }(_ParseObject2.default);
7619
- exports.default = Installation;
7620
- _ParseObject2.default.registerSubclass('_Installation', Installation);
7621
- },{"./ParseObject":28,"@babel/runtime-corejs3/core-js-stable/object/define-property":86,"@babel/runtime-corejs3/core-js-stable/reflect/construct":96,"@babel/runtime-corejs3/helpers/classCallCheck":108,"@babel/runtime-corejs3/helpers/createClass":110,"@babel/runtime-corejs3/helpers/getPrototypeOf":113,"@babel/runtime-corejs3/helpers/inherits":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":115,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":122,"@babel/runtime-corejs3/helpers/typeof":130}],27:[function(_dereq_,module,exports){
7828
+ _ParseObject2.default.registerSubclass('_Installation', ParseInstallation);
7829
+ module.exports = ParseInstallation;
7830
+ var _default = ParseInstallation;
7831
+ exports.default = _default;
7832
+ },{"./CoreManager":4,"./ParseObject":28,"@babel/runtime-corejs3/core-js-stable/object/define-property":86,"@babel/runtime-corejs3/core-js-stable/reflect/construct":96,"@babel/runtime-corejs3/helpers/asyncToGenerator":107,"@babel/runtime-corejs3/helpers/classCallCheck":108,"@babel/runtime-corejs3/helpers/createClass":110,"@babel/runtime-corejs3/helpers/get":112,"@babel/runtime-corejs3/helpers/getPrototypeOf":113,"@babel/runtime-corejs3/helpers/inherits":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":115,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":122,"@babel/runtime-corejs3/helpers/typeof":130,"@babel/runtime-corejs3/regenerator":133}],27:[function(_dereq_,module,exports){
7622
7833
  "use strict";
7623
7834
 
7624
7835
  var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
@@ -15061,7 +15272,7 @@ var ParseSession = /*#__PURE__*/function (_ParseObject) {
15061
15272
  value: function (options /*: FullOptions*/) {
15062
15273
  options = options || {};
15063
15274
  var controller = _CoreManager.default.getSessionController();
15064
- var sessionOptions = {};
15275
+ var sessionOptions /*: FullOptions*/ = {};
15065
15276
  if (options.hasOwnProperty('useMasterKey')) {
15066
15277
  sessionOptions.useMasterKey = options.useMasterKey;
15067
15278
  }