ember-data-source 2.9.0 → 2.10.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fd00a284388c3fb0a7bd52bc95427647ed4c234
4
- data.tar.gz: 8a55fc98c0e92feb58c579ee0fa10480e25b8c23
3
+ metadata.gz: 56f6df9d5f50684f7201674fdb06d7027996eb0b
4
+ data.tar.gz: f2cdbbf3e0d6370c871fec50d32dc6a011d7c5a5
5
5
  SHA512:
6
- metadata.gz: 4d3e1b375efa5d30041b709eb3bdb1b4f50a6a4b988fd7b2cb306b9f8aff2544678a0e657882abe8b54032e81130efb7064b2777a3393e513a77a717d7f8b539
7
- data.tar.gz: bcc25577b3827a03227aacbdda85324500aa9d645038b09fb43e217ad8fe99e75c1999826ff21ed0e5779f3261fd5799449fcbd8fbcfe5689f5443aac0e0520d
6
+ metadata.gz: 89d4f16bce1ad0a5b612eec9be176eb85e8b755dcf792544c652cb961a0d3faf48c05fec3fc55fdd70247ded877e46a4b70243e57d75a5040af3aae70cb09253
7
+ data.tar.gz: 9fd7f66e9b0ff44d7a81c45d8d0842064a0346d9abafc04b20f344a8c87479ca54792b583d94098068fd6fabab242ea53780e9b57c88d43e072aae5632a9b5a5
@@ -6,7 +6,7 @@
6
6
  * @copyright Copyright 2011-2016 Tilde Inc. and contributors.
7
7
  * Portions Copyright 2011 LivingSocial Inc.
8
8
  * @license Licensed under MIT license (see license.js)
9
- * @version 2.9.0
9
+ * @version 2.10.0-beta.1
10
10
  */
11
11
 
12
12
  var loader, define, requireModule, require, requirejs;
@@ -431,102 +431,218 @@ define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember'], fun
431
431
  },
432
432
 
433
433
  /**
434
- * @method urlForFindRecord
435
- * @param {String} id
436
- * @param {String} modelName
437
- * @param {DS.Snapshot} snapshot
438
- * @return {String} url
439
- */
434
+ Builds a URL for a `store.findRecord(type, id)` call.
435
+ Example:
436
+ ```app/adapters/user.js
437
+ import DS from 'ember-data';
438
+ export default DS.JSONAPIAdapter.extend({
439
+ urlForFindRecord(id, modelName, snapshot) {
440
+ let baseUrl = this.buildURL();
441
+ return `${baseUrl}/users/${snapshot.adapterOptions.user_id}/playlists/${id}`;
442
+ }
443
+ });
444
+ ```
445
+ @method urlForFindRecord
446
+ @param {String} id
447
+ @param {String} modelName
448
+ @param {DS.Snapshot} snapshot
449
+ @return {String} url
450
+ */
440
451
  urlForFindRecord: function (id, modelName, snapshot) {
441
452
  return this._buildURL(modelName, id);
442
453
  },
443
454
 
444
455
  /**
445
- * @method urlForFindAll
446
- * @param {String} modelName
447
- * @param {DS.SnapshotRecordArray} snapshot
448
- * @return {String} url
456
+ Builds a URL for a `store.findAll(type)` call.
457
+ Example:
458
+ ```app/adapters/comment.js
459
+ import DS from 'ember-data';
460
+ export default DS.JSONAPIAdapter.extend({
461
+ urlForFindAll(id, modelName, snapshot) {
462
+ return 'data/comments.json';
463
+ }
464
+ });
465
+ ```
466
+ @method urlForFindAll
467
+ @param {String} modelName
468
+ @param {DS.SnapshotRecordArray} snapshot
469
+ @return {String} url
449
470
  */
450
471
  urlForFindAll: function (modelName, snapshot) {
451
472
  return this._buildURL(modelName);
452
473
  },
453
474
 
454
475
  /**
455
- * @method urlForQuery
456
- * @param {Object} query
457
- * @param {String} modelName
458
- * @return {String} url
476
+ Builds a URL for a `store.query(type, query)` call.
477
+ Example:
478
+ ```app/adapters/application.js
479
+ import DS from 'ember-data';
480
+ export default DS.RESTAdapter.extend({
481
+ host: 'https://api.github.com',
482
+ urlForQuery (query, modelName) {
483
+ switch(modelName) {
484
+ case 'repo':
485
+ return `https://api.github.com/orgs/${query.orgId}/repos`;
486
+ default:
487
+ return this._super(...arguments);
488
+ }
489
+ }
490
+ });
491
+ ```
492
+ @method urlForQuery
493
+ @param {Object} query
494
+ @param {String} modelName
495
+ @return {String} url
459
496
  */
460
497
  urlForQuery: function (query, modelName) {
461
498
  return this._buildURL(modelName);
462
499
  },
463
500
 
464
501
  /**
465
- * @method urlForQueryRecord
466
- * @param {Object} query
467
- * @param {String} modelName
468
- * @return {String} url
502
+ Builds a URL for a `store.queryRecord(type, query)` call.
503
+ Example:
504
+ ```app/adapters/application.js
505
+ import DS from 'ember-data';
506
+ export default DS.RESTAdapter.extend({
507
+ urlForQueryRecord({ slug }, modelName) {
508
+ let baseUrl = this.buildURL();
509
+ return `${baseUrl}/${encodeURIComponent(slug)}`;
510
+ }
511
+ });
512
+ ```
513
+ @method urlForQueryRecord
514
+ @param {Object} query
515
+ @param {String} modelName
516
+ @return {String} url
469
517
  */
470
518
  urlForQueryRecord: function (query, modelName) {
471
519
  return this._buildURL(modelName);
472
520
  },
473
521
 
474
522
  /**
475
- * @method urlForFindMany
476
- * @param {Array} ids
477
- * @param {String} modelName
478
- * @param {Array} snapshots
479
- * @return {String} url
523
+ Builds a URL for coalesceing multiple `store.findRecord(type, id)
524
+ records into 1 request when the adapter's `coalesceFindRequests`
525
+ property is true.
526
+ Example:
527
+ ```app/adapters/application.js
528
+ import DS from 'ember-data';
529
+ export default DS.RESTAdapter.extend({
530
+ urlForFindMany(ids, modelName) {
531
+ let baseUrl = this.buildURL();
532
+ return `${baseUrl}/coalesce`;
533
+ }
534
+ });
535
+ ```
536
+ @method urlForFindMany
537
+ @param {Array} ids
538
+ @param {String} modelName
539
+ @param {Array} snapshots
540
+ @return {String} url
480
541
  */
481
542
  urlForFindMany: function (ids, modelName, snapshots) {
482
543
  return this._buildURL(modelName);
483
544
  },
484
545
 
485
546
  /**
486
- * @method urlForFindHasMany
487
- * @param {String} id
488
- * @param {String} modelName
489
- * @param {DS.Snapshot} snapshot
490
- * @return {String} url
547
+ Builds a URL for fetching a async hasMany relationship when a url
548
+ is not provided by the server.
549
+ Example:
550
+ ```app/adapters/application.js
551
+ import DS from 'ember-data';
552
+ export default DS.JSONAPIAdapter.extend({
553
+ urlForFindHasMany(id, modelName, snapshot) {
554
+ let baseUrl = this.buildURL(id, modelName);
555
+ return `${baseUrl}/relationships`;
556
+ }
557
+ });
558
+ ```
559
+ @method urlForFindHasMany
560
+ @param {String} id
561
+ @param {String} modelName
562
+ @param {DS.Snapshot} snapshot
563
+ @return {String} url
491
564
  */
492
565
  urlForFindHasMany: function (id, modelName, snapshot) {
493
566
  return this._buildURL(modelName, id);
494
567
  },
495
568
 
496
569
  /**
497
- * @method urlForFindBelongsTo
498
- * @param {String} id
499
- * @param {String} modelName
500
- * @param {DS.Snapshot} snapshot
501
- * @return {String} url
570
+ Builds a URL for fetching a async belongsTo relationship when a url
571
+ is not provided by the server.
572
+ Example:
573
+ ```app/adapters/application.js
574
+ import DS from 'ember-data';
575
+ export default DS.JSONAPIAdapter.extend({
576
+ urlForFindBelongsTo(id, modelName, snapshot) {
577
+ let baseUrl = this.buildURL(id, modelName);
578
+ return `${baseUrl}/relationships`;
579
+ }
580
+ });
581
+ ```
582
+ @method urlForFindBelongsTo
583
+ @param {String} id
584
+ @param {String} modelName
585
+ @param {DS.Snapshot} snapshot
586
+ @return {String} url
502
587
  */
503
588
  urlForFindBelongsTo: function (id, modelName, snapshot) {
504
589
  return this._buildURL(modelName, id);
505
590
  },
506
591
 
507
592
  /**
508
- * @method urlForCreateRecord
509
- * @param {String} modelName
510
- * @param {DS.Snapshot} snapshot
511
- * @return {String} url
593
+ Builds a URL for a `record.save()` call when the record was created
594
+ locally using `store.createRecord()`.
595
+ Example:
596
+ ```app/adapters/application.js
597
+ import DS from 'ember-data';
598
+ export default DS.RESTAdapter.extend({
599
+ urlForCreateRecord(modelName, snapshot) {
600
+ return this._super(...arguments) + '/new';
601
+ }
602
+ });
603
+ ```
604
+ @method urlForCreateRecord
605
+ @param {String} modelName
606
+ @param {DS.Snapshot} snapshot
607
+ @return {String} url
512
608
  */
513
609
  urlForCreateRecord: function (modelName, snapshot) {
514
610
  return this._buildURL(modelName);
515
611
  },
516
612
 
517
613
  /**
518
- * @method urlForUpdateRecord
519
- * @param {String} id
520
- * @param {String} modelName
521
- * @param {DS.Snapshot} snapshot
522
- * @return {String} url
614
+ Builds a URL for a `record.save()` call when the record has been update locally.
615
+ Example:
616
+ ```app/adapters/application.js
617
+ import DS from 'ember-data';
618
+ export default DS.RESTAdapter.extend({
619
+ urlForUpdateRecord(id, modelName, snapshot) {
620
+ return `/${id}/feed?access_token=${snapshot.adapterOptions.token}`;
621
+ }
622
+ });
623
+ ```
624
+ @method urlForUpdateRecord
625
+ @param {String} id
626
+ @param {String} modelName
627
+ @param {DS.Snapshot} snapshot
628
+ @return {String} url
523
629
  */
524
630
  urlForUpdateRecord: function (id, modelName, snapshot) {
525
631
  return this._buildURL(modelName, id);
526
632
  },
527
633
 
528
634
  /**
529
- * @method urlForDeleteRecord
635
+ Builds a URL for a `record.save()` call when the record has been deleted locally.
636
+ Example:
637
+ ```app/adapters/application.js
638
+ import DS from 'ember-data';
639
+ export default DS.RESTAdapter.extend({
640
+ urlForDeleteRecord(id, modelName, snapshot) {
641
+ return this._super(...arguments) + '/destroy';
642
+ }
643
+ });
644
+ ```
645
+ * @method urlForDeleteRecord
530
646
  * @param {String} id
531
647
  * @param {String} modelName
532
648
  * @param {DS.Snapshot} snapshot
@@ -638,6 +754,7 @@ define('ember-data/-private/debug', ['exports', 'ember'], function (exports, _em
638
754
  exports.deprecate = deprecate;
639
755
  exports.info = info;
640
756
  exports.runInDebug = runInDebug;
757
+ exports.instrument = instrument;
641
758
  exports.warn = warn;
642
759
  exports.debugSeal = debugSeal;
643
760
  exports.assertPolymorphicType = assertPolymorphicType;
@@ -662,6 +779,10 @@ define('ember-data/-private/debug', ['exports', 'ember'], function (exports, _em
662
779
  return _ember.default.runInDebug.apply(_ember.default, arguments);
663
780
  }
664
781
 
782
+ function instrument(method) {
783
+ return method();
784
+ }
785
+
665
786
  function warn() {
666
787
  return _ember.default.warn.apply(_ember.default, arguments);
667
788
  }
@@ -2126,6 +2247,9 @@ define("ember-data/-private/system/model/internal-model", ["exports", "ember", "
2126
2247
  };
2127
2248
  }
2128
2249
 
2250
+ // this (and all heimdall instrumentation) will be stripped by a babel transform
2251
+ // https://github.com/heimdalljs/babel5-plugin-strip-heimdall
2252
+
2129
2253
  /*
2130
2254
  `InternalModel` is the Model class that we use internally inside Ember Data to represent models.
2131
2255
  Internal ED methods should only deal with `InternalModel` objects. It is a fast, plain Javascript class.
@@ -2304,14 +2428,14 @@ define("ember-data/-private/system/model/internal-model", ["exports", "ember", "
2304
2428
  if (this.record) {
2305
2429
  this.record._notifyProperties(changedKeys);
2306
2430
  }
2307
- this.didInitalizeData();
2431
+ this.didInitializeData();
2308
2432
  },
2309
2433
 
2310
2434
  becameReady: function () {
2311
2435
  _ember.default.run.schedule('actions', this.store.recordArrayManager, this.store.recordArrayManager.recordWasLoaded, this);
2312
2436
  },
2313
2437
 
2314
- didInitalizeData: function () {
2438
+ didInitializeData: function () {
2315
2439
  if (!this.dataHasInitialized) {
2316
2440
  this.becameReady();
2317
2441
  this.dataHasInitialized = true;
@@ -2347,7 +2471,7 @@ define("ember-data/-private/system/model/internal-model", ["exports", "ember", "
2347
2471
  */
2348
2472
  loadedData: function () {
2349
2473
  this.send('loadedData');
2350
- this.didInitalizeData();
2474
+ this.didInitializeData();
2351
2475
  },
2352
2476
 
2353
2477
  /*
@@ -5411,6 +5535,11 @@ define("ember-data/-private/system/record-arrays/record-array", ["exports", "emb
5411
5535
  */
5412
5536
  store: null,
5413
5537
 
5538
+ replace: function () {
5539
+ var type = get(this, 'type').toString();
5540
+ throw new Error("The result of a server query (for all " + type + " types) is immutable. To modify contents, use toArray()");
5541
+ },
5542
+
5414
5543
  /**
5415
5544
  Retrieves an object from the content by index.
5416
5545
  @method objectAtContent
@@ -7496,6 +7625,7 @@ define("ember-data/-private/system/relationships/state/relationship", ["exports"
7496
7625
  }
7497
7626
  };
7498
7627
  });
7628
+ /* global heimdall */
7499
7629
  define('ember-data/-private/system/snapshot-record-array', ['exports'], function (exports) {
7500
7630
  exports.default = SnapshotRecordArray;
7501
7631
  /**
@@ -7914,15 +8044,16 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
7914
8044
  return (0, _emberDataPrivateSystemPromiseProxies.promiseObject)(toReturn, label);
7915
8045
  }
7916
8046
 
7917
- var get = _ember.default.get;
7918
- var set = _ember.default.set;
7919
8047
  var once = _ember.default.run.once;
7920
- var isNone = _ember.default.isNone;
7921
- var isPresent = _ember.default.isPresent;
7922
8048
  var Promise = _ember.default.RSVP.Promise;
7923
- var copy = _ember.default.copy;
7924
8049
  var Store;
7925
8050
 
8051
+ var copy = _ember.default.copy;
8052
+ var get = _ember.default.get;
8053
+ var GUID_KEY = _ember.default.GUID_KEY;
8054
+ var isNone = _ember.default.isNone;
8055
+ var isPresent = _ember.default.isPresent;
8056
+ var set = _ember.default.set;
7926
8057
  var Service = _ember.default.Service;
7927
8058
 
7928
8059
  // Implementors Note:
@@ -8845,7 +8976,9 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
8845
8976
  (0, _emberDataPrivateDebug.assert)("You tried to load a query but you have no adapter (for " + typeClass + ")", adapter);
8846
8977
  (0, _emberDataPrivateDebug.assert)("You tried to load a query but your adapter does not implement `query`", typeof adapter.query === 'function');
8847
8978
 
8848
- return (0, _emberDataPrivateSystemPromiseProxies.promiseArray)((0, _emberDataPrivateSystemStoreFinders._query)(adapter, this, typeClass, query, array));
8979
+ var pA = (0, _emberDataPrivateSystemPromiseProxies.promiseArray)((0, _emberDataPrivateSystemStoreFinders._query)(adapter, this, typeClass, query, array));
8980
+
8981
+ return pA;
8849
8982
  },
8850
8983
 
8851
8984
  /**
@@ -9061,9 +9194,12 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9061
9194
  findAll: function (modelName, options) {
9062
9195
  (0, _emberDataPrivateDebug.assert)("You need to pass a model name to the store's findAll method", isPresent(modelName));
9063
9196
  (0, _emberDataPrivateDebug.assert)('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + _ember.default.inspect(modelName), typeof modelName === 'string');
9197
+
9064
9198
  var typeClass = this.modelFor(modelName);
9065
9199
 
9066
- return this._fetchAll(typeClass, this.peekAll(modelName), options);
9200
+ var fetch = this._fetchAll(typeClass, this.peekAll(modelName), options);
9201
+
9202
+ return fetch;
9067
9203
  },
9068
9204
 
9069
9205
  /**
@@ -9380,6 +9516,8 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9380
9516
  // normalize relationship IDs into records
9381
9517
  this._backburner.schedule('normalizeRelationships', this, '_setupRelationships', internalModel, data);
9382
9518
  this.updateId(internalModel, data);
9519
+ } else {
9520
+ (0, _emberDataPrivateDebug.assert)('Your ' + internalModel.type.modelName + ' record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response.', internalModel.id);
9383
9521
  }
9384
9522
 
9385
9523
  //We first make sure the primary data has been updated
@@ -9426,7 +9564,18 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9426
9564
  var oldId = internalModel.id;
9427
9565
  var id = (0, _emberDataPrivateSystemCoerceId.default)(data.id);
9428
9566
 
9429
- (0, _emberDataPrivateDebug.assert)("An adapter cannot assign a new id to a record that already has an id. " + internalModel + " had id: " + oldId + " and you tried to update it with " + id + ". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.", oldId === null || id === oldId);
9567
+ // ID absolutely can't be missing if the oldID is empty (missing Id in response for a new record)
9568
+ (0, _emberDataPrivateDebug.assert)('\'' + internalModel.type.modelName + ':' + internalModel[GUID_KEY] + '\' was saved to the server, but the response does not have an id and your record does not either.', !(id === null && oldId === null));
9569
+
9570
+ // ID absolutely can't be different than oldID if oldID is not null
9571
+ (0, _emberDataPrivateDebug.assert)('\'' + internalModel.type.modelName + ':' + oldId + '\' was saved to the server, but the response returned the new id \'' + id + '\'. The store cannot assign a new id to a record that already has an id.', !(oldId !== null && id !== oldId));
9572
+
9573
+ // ID can be null if oldID is not null (altered ID in response for a record)
9574
+ // however, this is more than likely a developer error.
9575
+ if (oldId !== null && id === null) {
9576
+ (0, _emberDataPrivateDebug.warn)('Your ' + internalModel.type.modelName + ' record was saved to the server, but the response does not have an id.', !(oldId !== null && id === null));
9577
+ return;
9578
+ }
9430
9579
 
9431
9580
  this.typeMapFor(internalModel.type).idToRecord[id] = internalModel;
9432
9581
 
@@ -9700,6 +9849,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9700
9849
  for (i = 0; i < length; i++) {
9701
9850
  internalModels[i] = this._pushInternalModel(data.data[i]).getRecord();
9702
9851
  }
9852
+
9703
9853
  return internalModels;
9704
9854
  }
9705
9855
 
@@ -9711,7 +9861,9 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9711
9861
 
9712
9862
  var internalModel = this._pushInternalModel(data.data);
9713
9863
 
9714
- return internalModel.getRecord();
9864
+ var record = internalModel.getRecord();
9865
+
9866
+ return record;
9715
9867
  },
9716
9868
 
9717
9869
  _hasModelFor: function (type) {
@@ -10278,6 +10430,7 @@ define('ember-data/-private/system/store/container-instance-cache', ['exports',
10278
10430
  }
10279
10431
  });
10280
10432
  });
10433
+ /* global heimdall */
10281
10434
  define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-data/-private/debug", "ember-data/-private/system/store/common", "ember-data/-private/system/store/serializer-response", "ember-data/-private/system/store/serializers"], function (exports, _ember, _emberDataPrivateDebug, _emberDataPrivateSystemStoreCommon, _emberDataPrivateSystemStoreSerializerResponse, _emberDataPrivateSystemStoreSerializers) {
10282
10435
  exports._find = _find;
10283
10436
  exports._findMany = _findMany;
@@ -10451,6 +10604,7 @@ define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-d
10451
10604
 
10452
10605
  (0, _emberDataPrivateDebug.assert)('The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or use `store.queryRecord` to query for a single record.', Array.isArray(records));
10453
10606
  recordArray.loadRecords(records, payload);
10607
+
10454
10608
  return recordArray;
10455
10609
  }, null, "DS: Extract payload of query " + typeClass);
10456
10610
  }
@@ -11902,6 +12056,7 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
11902
12056
 
11903
12057
  exports.default = JSONAPIAdapter;
11904
12058
  });
12059
+ /* global heimdall */
11905
12060
  /**
11906
12061
  @module ember-data
11907
12062
  */
@@ -13259,6 +13414,7 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
13259
13414
 
13260
13415
  exports.default = RESTAdapter;
13261
13416
  });
13417
+ /* global heimdall */
13262
13418
  /**
13263
13419
  @module ember-data
13264
13420
  */
@@ -17479,7 +17635,7 @@ define('ember-data/transform', ['exports', 'ember'], function (exports, _ember)
17479
17635
  });
17480
17636
  });
17481
17637
  define("ember-data/version", ["exports"], function (exports) {
17482
- exports.default = "2.9.0";
17638
+ exports.default = "2.10.0-beta.1";
17483
17639
  });
17484
17640
  define("ember-inflector", ["exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (exports, _ember, _emberInflectorLibSystem, _emberInflectorLibExtString) {
17485
17641