@ember-data/model 4.1.0 → 4.2.0-alpha.10
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.
- package/addon/-private/attr.js +7 -10
- package/addon/-private/errors.js +1 -21
- package/addon/-private/model.js +31 -311
- package/addon/-private/system/many-array.js +3 -3
- package/addon/-private/system/promise-many-array.ts +0 -11
- package/blueprints/model-test/mocha-rfc-232-files/__root__/__path__/__test__.js +1 -1
- package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +1 -1
- package/package.json +15 -15
package/addon/-private/attr.js
CHANGED
|
@@ -2,7 +2,6 @@ import { assert } from '@ember/debug';
|
|
|
2
2
|
import { computed } from '@ember/object';
|
|
3
3
|
import { DEBUG } from '@glimmer/env';
|
|
4
4
|
|
|
5
|
-
import { RECORD_DATA_ERRORS } from '@ember-data/canary-features';
|
|
6
5
|
import { recordDataFor } from '@ember-data/store/-private';
|
|
7
6
|
|
|
8
7
|
import { computedMacroWithOptionalParams } from './util';
|
|
@@ -151,15 +150,13 @@ function attr(type, options) {
|
|
|
151
150
|
);
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.___recordState.cleanErrorRequests();
|
|
162
|
-
}
|
|
153
|
+
if (!this.isValid) {
|
|
154
|
+
let oldValue = this._internalModel._recordData.getAttr(key);
|
|
155
|
+
if (oldValue !== value) {
|
|
156
|
+
const { errors } = this;
|
|
157
|
+
if (errors.get(key)) {
|
|
158
|
+
errors.remove(key);
|
|
159
|
+
this.___recordState.cleanErrorRequests();
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
}
|
package/addon/-private/errors.js
CHANGED
|
@@ -2,10 +2,6 @@ import { A, makeArray } from '@ember/array';
|
|
|
2
2
|
import ArrayProxy from '@ember/array/proxy';
|
|
3
3
|
import { computed, get } from '@ember/object';
|
|
4
4
|
import { mapBy, not } from '@ember/object/computed';
|
|
5
|
-
import { DEBUG } from '@glimmer/env';
|
|
6
|
-
|
|
7
|
-
import { DEPRECATE_EVENTED_API_USAGE } from '@ember-data/private-build-infra/deprecations';
|
|
8
|
-
import { DeprecatedEvented } from '@ember-data/store/-private';
|
|
9
5
|
|
|
10
6
|
/**
|
|
11
7
|
@module @ember-data/store
|
|
@@ -85,9 +81,8 @@ import { DeprecatedEvented } from '@ember-data/store/-private';
|
|
|
85
81
|
@class Errors
|
|
86
82
|
@public
|
|
87
83
|
@extends Ember.ArrayProxy
|
|
88
|
-
@uses Ember.Evented
|
|
89
84
|
*/
|
|
90
|
-
export default ArrayProxy.extend(
|
|
85
|
+
export default ArrayProxy.extend({
|
|
91
86
|
/**
|
|
92
87
|
Register with target handler
|
|
93
88
|
|
|
@@ -250,11 +245,6 @@ export default ArrayProxy.extend(DeprecatedEvented, {
|
|
|
250
245
|
|
|
251
246
|
if (wasEmpty && !get(this, 'isEmpty')) {
|
|
252
247
|
this._registeredHandlers && this._registeredHandlers.becameInvalid();
|
|
253
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
254
|
-
if (this[DEBUG ? '_has' : 'has']('becameInvalid')) {
|
|
255
|
-
this.trigger('becameInvalid');
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
248
|
}
|
|
259
249
|
},
|
|
260
250
|
|
|
@@ -334,11 +324,6 @@ export default ArrayProxy.extend(DeprecatedEvented, {
|
|
|
334
324
|
|
|
335
325
|
if (get(this, 'isEmpty')) {
|
|
336
326
|
this._registeredHandlers && this._registeredHandlers.becameValid();
|
|
337
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
338
|
-
if (this[DEBUG ? '_has' : 'has']('becameValid')) {
|
|
339
|
-
this.trigger('becameValid');
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
327
|
}
|
|
343
328
|
},
|
|
344
329
|
|
|
@@ -417,11 +402,6 @@ export default ArrayProxy.extend(DeprecatedEvented, {
|
|
|
417
402
|
|
|
418
403
|
this._clear();
|
|
419
404
|
this._registeredHandlers && this._registeredHandlers.becameValid();
|
|
420
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
421
|
-
if (this[DEBUG ? '_has' : 'has']('becameValid')) {
|
|
422
|
-
this.trigger('becameValid');
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
405
|
},
|
|
426
406
|
|
|
427
407
|
/**
|
package/addon/-private/model.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@module @ember-data/model
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { assert,
|
|
5
|
+
import { assert, warn } from '@ember/debug';
|
|
6
6
|
import EmberError from '@ember/error';
|
|
7
7
|
import EmberObject, { get } from '@ember/object';
|
|
8
8
|
import { dependentKeyCompat } from '@ember/object/compat';
|
|
@@ -12,21 +12,8 @@ import { DEBUG } from '@glimmer/env';
|
|
|
12
12
|
import { tracked } from '@glimmer/tracking';
|
|
13
13
|
import Ember from 'ember';
|
|
14
14
|
|
|
15
|
-
import { CUSTOM_MODEL_CLASS, RECORD_DATA_ERRORS, REQUEST_SERVICE } from '@ember-data/canary-features';
|
|
16
15
|
import { HAS_DEBUG_PACKAGE } from '@ember-data/private-build-infra';
|
|
17
|
-
import {
|
|
18
|
-
DEPRECATE_EVENTED_API_USAGE,
|
|
19
|
-
DEPRECATE_MODEL_TOJSON,
|
|
20
|
-
DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS,
|
|
21
|
-
} from '@ember-data/private-build-infra/deprecations';
|
|
22
|
-
import {
|
|
23
|
-
coerceId,
|
|
24
|
-
DeprecatedEvented,
|
|
25
|
-
errorsArrayToHash,
|
|
26
|
-
InternalModel,
|
|
27
|
-
PromiseObject,
|
|
28
|
-
recordDataFor,
|
|
29
|
-
} from '@ember-data/store/-private';
|
|
16
|
+
import { coerceId, errorsArrayToHash, InternalModel, PromiseObject, recordDataFor } from '@ember-data/store/-private';
|
|
30
17
|
|
|
31
18
|
import Errors from './errors';
|
|
32
19
|
import RecordState, { peekTag, tagged } from './record-state';
|
|
@@ -34,15 +21,6 @@ import { relationshipFromMeta } from './system/relationships/relationship-meta';
|
|
|
34
21
|
|
|
35
22
|
const { changeProperties } = Ember;
|
|
36
23
|
|
|
37
|
-
/*
|
|
38
|
-
In the non-CUSTOM_MODEL_CLASS world things decorated with flagToggledDecorator
|
|
39
|
-
have logic that requires a cache and caching key (which tagged provides), but
|
|
40
|
-
in the CUSTOM_MODEL_CLASS branch it only requires dependentKeyCompat which
|
|
41
|
-
ensures computeds/observers on the field will fire when anything it accesses
|
|
42
|
-
that is tracked changes
|
|
43
|
-
*/
|
|
44
|
-
const flagToggledDecorator = CUSTOM_MODEL_CLASS ? dependentKeyCompat : tagged;
|
|
45
|
-
|
|
46
24
|
function findPossibleInverses(type, inverseType, name, relationshipsSoFar) {
|
|
47
25
|
let possibleRelationships = relationshipsSoFar || [];
|
|
48
26
|
|
|
@@ -78,7 +56,7 @@ function findPossibleInverses(type, inverseType, name, relationshipsSoFar) {
|
|
|
78
56
|
|
|
79
57
|
/*
|
|
80
58
|
* This decorator allows us to lazily compute
|
|
81
|
-
* an expensive getter on first-access and
|
|
59
|
+
* an expensive getter on first-access and thereafter
|
|
82
60
|
* never recompute it.
|
|
83
61
|
*/
|
|
84
62
|
function computeOnce(target, key, desc) {
|
|
@@ -116,7 +94,6 @@ function computeOnce(target, key, desc) {
|
|
|
116
94
|
@class Model
|
|
117
95
|
@public
|
|
118
96
|
@extends Ember.EmberObject
|
|
119
|
-
@uses DeprecatedEvented
|
|
120
97
|
*/
|
|
121
98
|
class Model extends EmberObject {
|
|
122
99
|
init(options = {}) {
|
|
@@ -132,9 +109,7 @@ class Model extends EmberObject {
|
|
|
132
109
|
}
|
|
133
110
|
}
|
|
134
111
|
|
|
135
|
-
|
|
136
|
-
this.___recordState = new RecordState(this);
|
|
137
|
-
}
|
|
112
|
+
this.___recordState = new RecordState(this);
|
|
138
113
|
this.setProperties(createProps);
|
|
139
114
|
}
|
|
140
115
|
|
|
@@ -390,21 +365,13 @@ class Model extends EmberObject {
|
|
|
390
365
|
@type {Boolean}
|
|
391
366
|
@readOnly
|
|
392
367
|
*/
|
|
393
|
-
@
|
|
368
|
+
@dependentKeyCompat
|
|
394
369
|
get isError() {
|
|
395
|
-
|
|
396
|
-
return this.currentState.isError;
|
|
397
|
-
}
|
|
398
|
-
let tag = peekTag(this, 'isError');
|
|
399
|
-
tag.value = tag.value || false;
|
|
400
|
-
return tag.value;
|
|
370
|
+
return this.currentState.isError;
|
|
401
371
|
}
|
|
402
372
|
set isError(v) {
|
|
403
|
-
if (
|
|
404
|
-
throw new Error(`isError is not directly settable
|
|
405
|
-
} else {
|
|
406
|
-
let tag = peekTag(this, 'isError');
|
|
407
|
-
tag.value = v;
|
|
373
|
+
if (DEBUG) {
|
|
374
|
+
throw new Error(`isError is not directly settable`);
|
|
408
375
|
}
|
|
409
376
|
}
|
|
410
377
|
|
|
@@ -473,19 +440,10 @@ class Model extends EmberObject {
|
|
|
473
440
|
*/
|
|
474
441
|
@tagged
|
|
475
442
|
get currentState() {
|
|
476
|
-
|
|
477
|
-
return this.___recordState;
|
|
478
|
-
}
|
|
479
|
-
if (this.isDestroyed || this.isDestroying) {
|
|
480
|
-
return this._internalModel._previousState;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
return this._internalModel && this._internalModel.currentState;
|
|
443
|
+
return this.___recordState;
|
|
484
444
|
}
|
|
485
|
-
set currentState(
|
|
486
|
-
|
|
487
|
-
this.notifyPropertyChange('currentState');
|
|
488
|
-
}
|
|
445
|
+
set currentState(_v) {
|
|
446
|
+
throw new Error('cannot set currentState');
|
|
489
447
|
}
|
|
490
448
|
|
|
491
449
|
/**
|
|
@@ -565,21 +523,19 @@ class Model extends EmberObject {
|
|
|
565
523
|
this._internalModel.send('becameValid');
|
|
566
524
|
}
|
|
567
525
|
);
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
errors._add(errorKeys[i], errorsHash[errorKeys[i]]);
|
|
582
|
-
}
|
|
526
|
+
// TODO we should unify how errors gets populated
|
|
527
|
+
// with the code managing the update. Probably a
|
|
528
|
+
// lazy flush similar to retrieveLatest in ManyArray
|
|
529
|
+
let recordData = recordDataFor(this);
|
|
530
|
+
let jsonApiErrors;
|
|
531
|
+
if (recordData.getErrors) {
|
|
532
|
+
jsonApiErrors = recordData.getErrors();
|
|
533
|
+
if (jsonApiErrors) {
|
|
534
|
+
let errorsHash = errorsArrayToHash(jsonApiErrors);
|
|
535
|
+
let errorKeys = Object.keys(errorsHash);
|
|
536
|
+
|
|
537
|
+
for (let i = 0; i < errorKeys.length; i++) {
|
|
538
|
+
errors._add(errorKeys[i], errorsHash[errorKeys[i]]);
|
|
583
539
|
}
|
|
584
540
|
}
|
|
585
541
|
}
|
|
@@ -594,22 +550,12 @@ class Model extends EmberObject {
|
|
|
594
550
|
@public
|
|
595
551
|
@type {AdapterError}
|
|
596
552
|
*/
|
|
597
|
-
@
|
|
553
|
+
@dependentKeyCompat
|
|
598
554
|
get adapterError() {
|
|
599
|
-
|
|
600
|
-
return this.currentState.adapterError;
|
|
601
|
-
}
|
|
602
|
-
let tag = peekTag(this, 'adapterError');
|
|
603
|
-
tag.value = tag.value || null;
|
|
604
|
-
return tag.value;
|
|
555
|
+
return this.currentState.adapterError;
|
|
605
556
|
}
|
|
606
557
|
set adapterError(v) {
|
|
607
|
-
|
|
608
|
-
throw new Error(`adapterError is not directly settable when REQUEST_SERVICE is enabled`);
|
|
609
|
-
} else {
|
|
610
|
-
let tag = peekTag(this, 'adapterError');
|
|
611
|
-
tag.value = v;
|
|
612
|
-
}
|
|
558
|
+
throw new Error(`adapterError is not directly settable`);
|
|
613
559
|
}
|
|
614
560
|
|
|
615
561
|
/**
|
|
@@ -631,92 +577,6 @@ class Model extends EmberObject {
|
|
|
631
577
|
return this._internalModel.createSnapshot().serialize(options);
|
|
632
578
|
}
|
|
633
579
|
|
|
634
|
-
/**
|
|
635
|
-
Fired when the record is ready to be interacted with,
|
|
636
|
-
that is either loaded from the server or created locally.
|
|
637
|
-
|
|
638
|
-
@deprecated
|
|
639
|
-
@public
|
|
640
|
-
@event ready
|
|
641
|
-
*/
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
Fired when the record is loaded from the server.
|
|
645
|
-
|
|
646
|
-
@deprecated
|
|
647
|
-
@public
|
|
648
|
-
@event didLoad
|
|
649
|
-
*/
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
Fired when the record is updated.
|
|
653
|
-
|
|
654
|
-
@deprecated
|
|
655
|
-
@public
|
|
656
|
-
@event didUpdate
|
|
657
|
-
*/
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
Fired when a new record is commited to the server.
|
|
661
|
-
|
|
662
|
-
@deprecated
|
|
663
|
-
@public
|
|
664
|
-
@event didCreate
|
|
665
|
-
*/
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
Fired when the record is deleted.
|
|
669
|
-
|
|
670
|
-
@deprecated
|
|
671
|
-
@public
|
|
672
|
-
@event didDelete
|
|
673
|
-
*/
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
Fired when the record becomes invalid.
|
|
677
|
-
|
|
678
|
-
@deprecated
|
|
679
|
-
@public
|
|
680
|
-
@event becameInvalid
|
|
681
|
-
*/
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
Fired when the record enters the error state.
|
|
685
|
-
|
|
686
|
-
@deprecated
|
|
687
|
-
@public
|
|
688
|
-
@event becameError
|
|
689
|
-
*/
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
Fired when the record is rolled back.
|
|
693
|
-
|
|
694
|
-
@deprecated
|
|
695
|
-
@public
|
|
696
|
-
@event rolledBack
|
|
697
|
-
*/
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
@deprecated
|
|
701
|
-
@method send
|
|
702
|
-
@private
|
|
703
|
-
@param {String} name
|
|
704
|
-
@param {Object} context
|
|
705
|
-
*/
|
|
706
|
-
send(name, context) {
|
|
707
|
-
return this._internalModel.send(name, context);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
@deprecated
|
|
712
|
-
@method transitionTo
|
|
713
|
-
@private
|
|
714
|
-
@param {String} name
|
|
715
|
-
*/
|
|
716
|
-
transitionTo(name) {
|
|
717
|
-
return this._internalModel.transitionTo(name);
|
|
718
|
-
}
|
|
719
|
-
|
|
720
580
|
/*
|
|
721
581
|
We hook the default implementation to ensure
|
|
722
582
|
our tagged properties are properly notified
|
|
@@ -767,11 +627,7 @@ class Model extends EmberObject {
|
|
|
767
627
|
@public
|
|
768
628
|
*/
|
|
769
629
|
deleteRecord() {
|
|
770
|
-
|
|
771
|
-
this.store.deleteRecord(this);
|
|
772
|
-
} else {
|
|
773
|
-
this._internalModel.deleteRecord();
|
|
774
|
-
}
|
|
630
|
+
this.store.deleteRecord(this);
|
|
775
631
|
}
|
|
776
632
|
|
|
777
633
|
/**
|
|
@@ -840,11 +696,7 @@ class Model extends EmberObject {
|
|
|
840
696
|
if (this.isDestroyed) {
|
|
841
697
|
return;
|
|
842
698
|
}
|
|
843
|
-
|
|
844
|
-
this.store.unloadRecord(this);
|
|
845
|
-
} else {
|
|
846
|
-
this._internalModel.unloadRecord();
|
|
847
|
-
}
|
|
699
|
+
this.store.unloadRecord(this);
|
|
848
700
|
}
|
|
849
701
|
|
|
850
702
|
/**
|
|
@@ -934,9 +786,7 @@ class Model extends EmberObject {
|
|
|
934
786
|
*/
|
|
935
787
|
rollbackAttributes() {
|
|
936
788
|
this._internalModel.rollbackAttributes();
|
|
937
|
-
|
|
938
|
-
this.currentState.cleanErrorRequests();
|
|
939
|
-
}
|
|
789
|
+
this.currentState.cleanErrorRequests();
|
|
940
790
|
}
|
|
941
791
|
|
|
942
792
|
/**
|
|
@@ -1870,7 +1720,7 @@ class Model extends EmberObject {
|
|
|
1870
1720
|
|
|
1871
1721
|
```javascript
|
|
1872
1722
|
import { get } from '@ember/object';
|
|
1873
|
-
import
|
|
1723
|
+
import Person from 'app/models/person'
|
|
1874
1724
|
|
|
1875
1725
|
let attributes = Person.attributes
|
|
1876
1726
|
|
|
@@ -2145,79 +1995,6 @@ if (HAS_DEBUG_PACKAGE) {
|
|
|
2145
1995
|
};
|
|
2146
1996
|
}
|
|
2147
1997
|
|
|
2148
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
2149
|
-
/**
|
|
2150
|
-
Override the default event firing from Ember.Evented to
|
|
2151
|
-
also call methods with the given name.
|
|
2152
|
-
|
|
2153
|
-
@method trigger
|
|
2154
|
-
@private
|
|
2155
|
-
@param {String} name
|
|
2156
|
-
*/
|
|
2157
|
-
Model.reopen(DeprecatedEvented, {
|
|
2158
|
-
trigger(name) {
|
|
2159
|
-
if (DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS) {
|
|
2160
|
-
let fn = this[name];
|
|
2161
|
-
if (typeof fn === 'function') {
|
|
2162
|
-
let length = arguments.length;
|
|
2163
|
-
let args = new Array(length - 1);
|
|
2164
|
-
|
|
2165
|
-
for (let i = 1; i < length; i++) {
|
|
2166
|
-
args[i - 1] = arguments[i];
|
|
2167
|
-
}
|
|
2168
|
-
fn.apply(this, args);
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
|
-
const _hasEvent = DEBUG ? this._has(name) : this.has(name);
|
|
2173
|
-
if (_hasEvent) {
|
|
2174
|
-
this._super(...arguments);
|
|
2175
|
-
}
|
|
2176
|
-
},
|
|
2177
|
-
});
|
|
2178
|
-
}
|
|
2179
|
-
|
|
2180
|
-
if (DEPRECATE_MODEL_TOJSON) {
|
|
2181
|
-
/**
|
|
2182
|
-
Use [JSONSerializer](JSONSerializer.html) to
|
|
2183
|
-
get the JSON representation of a record.
|
|
2184
|
-
|
|
2185
|
-
`toJSON` takes an optional hash as a parameter, currently
|
|
2186
|
-
supported options are:
|
|
2187
|
-
|
|
2188
|
-
- `includeId`: `true` if the record's ID should be included in the
|
|
2189
|
-
JSON representation.
|
|
2190
|
-
|
|
2191
|
-
@method toJSON
|
|
2192
|
-
@public
|
|
2193
|
-
@param {Object} options
|
|
2194
|
-
@return {Object} A JSON representation of the object.
|
|
2195
|
-
*/
|
|
2196
|
-
Model.reopen({
|
|
2197
|
-
toJSON(options) {
|
|
2198
|
-
// container is for lazy transform lookups
|
|
2199
|
-
deprecate(
|
|
2200
|
-
`Called the built-in \`toJSON\` on the record "${this.constructor.modelName}:${this.id}". The built-in \`toJSON\` method on instances of classes extending \`Model\` is deprecated. For more information see the link below.`,
|
|
2201
|
-
false,
|
|
2202
|
-
{
|
|
2203
|
-
id: 'ember-data:model.toJSON',
|
|
2204
|
-
until: '4.0',
|
|
2205
|
-
url: 'https://deprecations.emberjs.com/ember-data/v3.x#toc_record-toJSON',
|
|
2206
|
-
for: '@ember-data/model',
|
|
2207
|
-
since: {
|
|
2208
|
-
available: '3.15',
|
|
2209
|
-
enabled: '3.15',
|
|
2210
|
-
},
|
|
2211
|
-
}
|
|
2212
|
-
);
|
|
2213
|
-
let serializer = this._internalModel.store.serializerFor('-default');
|
|
2214
|
-
let snapshot = this._internalModel.createSnapshot();
|
|
2215
|
-
|
|
2216
|
-
return serializer.serialize(snapshot, options);
|
|
2217
|
-
},
|
|
2218
|
-
});
|
|
2219
|
-
}
|
|
2220
|
-
|
|
2221
1998
|
if (DEBUG) {
|
|
2222
1999
|
let lookupDescriptor = function lookupDescriptor(obj, keyName) {
|
|
2223
2000
|
let current = obj;
|
|
@@ -2241,42 +2018,10 @@ if (DEBUG) {
|
|
|
2241
2018
|
return isBasicDesc(instanceDesc) && lookupDescriptor(obj.constructor, keyName) === null;
|
|
2242
2019
|
};
|
|
2243
2020
|
|
|
2244
|
-
let lookupDeprecations;
|
|
2245
|
-
let _deprecatedLifecycleMethods;
|
|
2246
|
-
|
|
2247
|
-
if (DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS) {
|
|
2248
|
-
const INSTANCE_DEPRECATIONS = new WeakMap();
|
|
2249
|
-
_deprecatedLifecycleMethods = [
|
|
2250
|
-
'becameError',
|
|
2251
|
-
'becameInvalid',
|
|
2252
|
-
'didCreate',
|
|
2253
|
-
'didDelete',
|
|
2254
|
-
'didLoad',
|
|
2255
|
-
'didUpdate',
|
|
2256
|
-
'ready',
|
|
2257
|
-
'rolledBack',
|
|
2258
|
-
];
|
|
2259
|
-
|
|
2260
|
-
lookupDeprecations = function lookupInstanceDeprecations(instance) {
|
|
2261
|
-
let deprecations = INSTANCE_DEPRECATIONS.get(instance);
|
|
2262
|
-
|
|
2263
|
-
if (!deprecations) {
|
|
2264
|
-
deprecations = new Set();
|
|
2265
|
-
INSTANCE_DEPRECATIONS.set(instance, deprecations);
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
return deprecations;
|
|
2269
|
-
};
|
|
2270
|
-
}
|
|
2271
|
-
|
|
2272
2021
|
Model.reopen({
|
|
2273
2022
|
init() {
|
|
2274
2023
|
this._super(...arguments);
|
|
2275
2024
|
|
|
2276
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
2277
|
-
this._getDeprecatedEventedInfo = () => `${this._internalModel.modelName}#${this.id}`;
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
2025
|
if (!isDefaultEmptyDescriptor(this, '_internalModel') || !(this._internalModel instanceof InternalModel)) {
|
|
2281
2026
|
throw new Error(
|
|
2282
2027
|
`'_internalModel' is a reserved property name on instances of classes extending Model. Please choose a different property name for ${this.constructor.toString()}`
|
|
@@ -2300,31 +2045,6 @@ if (DEBUG) {
|
|
|
2300
2045
|
`You may not set 'id' as an attribute on your model. Please remove any lines that look like: \`id: attr('<type>')\` from ${this.constructor.toString()}`
|
|
2301
2046
|
);
|
|
2302
2047
|
}
|
|
2303
|
-
|
|
2304
|
-
if (DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS) {
|
|
2305
|
-
let lifecycleDeprecations = lookupDeprecations(this.constructor);
|
|
2306
|
-
|
|
2307
|
-
_deprecatedLifecycleMethods.forEach((methodName) => {
|
|
2308
|
-
if (typeof this[methodName] === 'function' && !lifecycleDeprecations.has(methodName)) {
|
|
2309
|
-
deprecate(
|
|
2310
|
-
`You defined a \`${methodName}\` method for ${this.constructor.toString()} but lifecycle events for models have been deprecated.`,
|
|
2311
|
-
false,
|
|
2312
|
-
{
|
|
2313
|
-
id: 'ember-data:record-lifecycle-event-methods',
|
|
2314
|
-
until: '4.0',
|
|
2315
|
-
url: 'https://deprecations.emberjs.com/ember-data/v3.x#toc_record-lifecycle-event-methods',
|
|
2316
|
-
for: '@ember-data/model',
|
|
2317
|
-
since: {
|
|
2318
|
-
available: '3.12',
|
|
2319
|
-
enabled: '3.12',
|
|
2320
|
-
},
|
|
2321
|
-
}
|
|
2322
|
-
);
|
|
2323
|
-
|
|
2324
|
-
lifecycleDeprecations.add(methodName);
|
|
2325
|
-
}
|
|
2326
|
-
});
|
|
2327
|
-
}
|
|
2328
2048
|
},
|
|
2329
2049
|
});
|
|
2330
2050
|
}
|
|
@@ -8,7 +8,7 @@ import EmberObject, { get } from '@ember/object';
|
|
|
8
8
|
|
|
9
9
|
import { all } from 'rsvp';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { PromiseArray, recordDataFor } from '@ember-data/store/-private';
|
|
12
12
|
|
|
13
13
|
import diffArray from './diff-array';
|
|
14
14
|
|
|
@@ -55,9 +55,9 @@ import diffArray from './diff-array';
|
|
|
55
55
|
@class ManyArray
|
|
56
56
|
@public
|
|
57
57
|
@extends Ember.EmberObject
|
|
58
|
-
@uses Ember.MutableArray
|
|
58
|
+
@uses Ember.MutableArray
|
|
59
59
|
*/
|
|
60
|
-
export default EmberObject.extend(MutableArray,
|
|
60
|
+
export default EmberObject.extend(MutableArray, {
|
|
61
61
|
isAsync: false,
|
|
62
62
|
isLoaded: false,
|
|
63
63
|
|
|
@@ -6,8 +6,6 @@ import Ember from 'ember';
|
|
|
6
6
|
|
|
7
7
|
import { resolve } from 'rsvp';
|
|
8
8
|
|
|
9
|
-
import { DEPRECATE_EVENTED_API_USAGE } from '@ember-data/private-build-infra/deprecations';
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
@module @ember-data/model
|
|
13
11
|
*/
|
|
@@ -330,12 +328,3 @@ InheritedProxyMethods.forEach((method) => {
|
|
|
330
328
|
return this.content[method](...args);
|
|
331
329
|
};
|
|
332
330
|
});
|
|
333
|
-
|
|
334
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
335
|
-
['on', 'has', 'trigger', 'off', 'one'].forEach((method) => {
|
|
336
|
-
PromiseManyArray.prototype[method] = function proxiedMethod(...args) {
|
|
337
|
-
assert(`Cannot call ${method} before content is assigned.`, this.content);
|
|
338
|
-
return this.content[method](...args);
|
|
339
|
-
};
|
|
340
|
-
});
|
|
341
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/model",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-alpha.10",
|
|
4
4
|
"description": "The default blueprint for ember-cli addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -18,44 +18,44 @@
|
|
|
18
18
|
"test:node": "mocha"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ember-data/canary-features": "4.
|
|
22
|
-
"@ember-data/private-build-infra": "4.
|
|
23
|
-
"@ember-data/store": "4.
|
|
21
|
+
"@ember-data/canary-features": "4.2.0-alpha.10",
|
|
22
|
+
"@ember-data/private-build-infra": "4.2.0-alpha.10",
|
|
23
|
+
"@ember-data/store": "4.2.0-alpha.10",
|
|
24
24
|
"@ember/edition-utils": "^1.2.0",
|
|
25
25
|
"@ember/string": "^3.0.0",
|
|
26
26
|
"ember-auto-import": "^2.2.4",
|
|
27
27
|
"ember-cached-decorator-polyfill": "^0.1.4",
|
|
28
|
-
"ember-cli-babel": "^7.26.
|
|
28
|
+
"ember-cli-babel": "^7.26.11",
|
|
29
29
|
"ember-cli-string-utils": "^1.1.0",
|
|
30
30
|
"ember-cli-test-info": "^1.0.0",
|
|
31
|
-
"ember-cli-typescript": "^
|
|
31
|
+
"ember-cli-typescript": "^5.0.0",
|
|
32
32
|
"ember-compatibility-helpers": "^1.2.0",
|
|
33
33
|
"inflection": "~1.13.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@ember-data/unpublished-test-infra": "4.
|
|
36
|
+
"@ember-data/unpublished-test-infra": "4.2.0-alpha.10",
|
|
37
37
|
"@ember/optional-features": "^2.0.0",
|
|
38
38
|
"@ember/test-helpers": "^2.6.0",
|
|
39
39
|
"broccoli-asset-rev": "^3.0.0",
|
|
40
|
-
"ember-cli": "~
|
|
40
|
+
"ember-cli": "~4.1.1",
|
|
41
41
|
"ember-cli-blueprint-test-helpers": "^0.19.1",
|
|
42
42
|
"ember-cli-dependency-checker": "^3.2.0",
|
|
43
|
-
"ember-cli-htmlbars": "^
|
|
43
|
+
"ember-cli-htmlbars": "^6.0.1",
|
|
44
44
|
"ember-cli-inject-live-reload": "^2.0.2",
|
|
45
45
|
"ember-cli-sri": "^2.1.1",
|
|
46
46
|
"ember-cli-terser": "~4.0.1",
|
|
47
47
|
"ember-disable-prototype-extensions": "^1.1.3",
|
|
48
48
|
"ember-export-application-global": "^2.0.1",
|
|
49
49
|
"ember-load-initializers": "^2.1.1",
|
|
50
|
-
"ember-maybe-import-regenerator": "^0.
|
|
50
|
+
"ember-maybe-import-regenerator": "^1.0.0",
|
|
51
51
|
"ember-qunit": "^5.1.5",
|
|
52
|
-
"ember-resolver": "^8.0.
|
|
53
|
-
"ember-source": "~4.
|
|
52
|
+
"ember-resolver": "^8.0.3",
|
|
53
|
+
"ember-source": "~4.2.0",
|
|
54
54
|
"ember-source-channel-url": "^3.0.0",
|
|
55
|
-
"ember-try": "^
|
|
55
|
+
"ember-try": "^2.0.0",
|
|
56
56
|
"loader.js": "^4.7.0",
|
|
57
|
-
"qunit": "^2.
|
|
58
|
-
"qunit-dom": "^
|
|
57
|
+
"qunit": "^2.17.0",
|
|
58
|
+
"qunit-dom": "^2.0.0",
|
|
59
59
|
"silent-error": "^1.1.1",
|
|
60
60
|
"webpack": "^5.37.1"
|
|
61
61
|
},
|