@ember-data/model 4.2.0-alpha.5 → 4.2.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.
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';
|
|
@@ -13,18 +13,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
13
13
|
import Ember from 'ember';
|
|
14
14
|
|
|
15
15
|
import { HAS_DEBUG_PACKAGE } from '@ember-data/private-build-infra';
|
|
16
|
-
import {
|
|
17
|
-
DEPRECATE_EVENTED_API_USAGE,
|
|
18
|
-
DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS,
|
|
19
|
-
} from '@ember-data/private-build-infra/deprecations';
|
|
20
|
-
import {
|
|
21
|
-
coerceId,
|
|
22
|
-
DeprecatedEvented,
|
|
23
|
-
errorsArrayToHash,
|
|
24
|
-
InternalModel,
|
|
25
|
-
PromiseObject,
|
|
26
|
-
recordDataFor,
|
|
27
|
-
} from '@ember-data/store/-private';
|
|
16
|
+
import { coerceId, errorsArrayToHash, InternalModel, PromiseObject, recordDataFor } from '@ember-data/store/-private';
|
|
28
17
|
|
|
29
18
|
import Errors from './errors';
|
|
30
19
|
import RecordState, { peekTag, tagged } from './record-state';
|
|
@@ -105,7 +94,6 @@ function computeOnce(target, key, desc) {
|
|
|
105
94
|
@class Model
|
|
106
95
|
@public
|
|
107
96
|
@extends Ember.EmberObject
|
|
108
|
-
@uses DeprecatedEvented
|
|
109
97
|
*/
|
|
110
98
|
class Model extends EmberObject {
|
|
111
99
|
init(options = {}) {
|
|
@@ -589,92 +577,6 @@ class Model extends EmberObject {
|
|
|
589
577
|
return this._internalModel.createSnapshot().serialize(options);
|
|
590
578
|
}
|
|
591
579
|
|
|
592
|
-
/**
|
|
593
|
-
Fired when the record is ready to be interacted with,
|
|
594
|
-
that is either loaded from the server or created locally.
|
|
595
|
-
|
|
596
|
-
@deprecated
|
|
597
|
-
@public
|
|
598
|
-
@event ready
|
|
599
|
-
*/
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
Fired when the record is loaded from the server.
|
|
603
|
-
|
|
604
|
-
@deprecated
|
|
605
|
-
@public
|
|
606
|
-
@event didLoad
|
|
607
|
-
*/
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
Fired when the record is updated.
|
|
611
|
-
|
|
612
|
-
@deprecated
|
|
613
|
-
@public
|
|
614
|
-
@event didUpdate
|
|
615
|
-
*/
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
Fired when a new record is commited to the server.
|
|
619
|
-
|
|
620
|
-
@deprecated
|
|
621
|
-
@public
|
|
622
|
-
@event didCreate
|
|
623
|
-
*/
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
Fired when the record is deleted.
|
|
627
|
-
|
|
628
|
-
@deprecated
|
|
629
|
-
@public
|
|
630
|
-
@event didDelete
|
|
631
|
-
*/
|
|
632
|
-
|
|
633
|
-
/**
|
|
634
|
-
Fired when the record becomes invalid.
|
|
635
|
-
|
|
636
|
-
@deprecated
|
|
637
|
-
@public
|
|
638
|
-
@event becameInvalid
|
|
639
|
-
*/
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
Fired when the record enters the error state.
|
|
643
|
-
|
|
644
|
-
@deprecated
|
|
645
|
-
@public
|
|
646
|
-
@event becameError
|
|
647
|
-
*/
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
Fired when the record is rolled back.
|
|
651
|
-
|
|
652
|
-
@deprecated
|
|
653
|
-
@public
|
|
654
|
-
@event rolledBack
|
|
655
|
-
*/
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
@deprecated
|
|
659
|
-
@method send
|
|
660
|
-
@private
|
|
661
|
-
@param {String} name
|
|
662
|
-
@param {Object} context
|
|
663
|
-
*/
|
|
664
|
-
send(name, context) {
|
|
665
|
-
return this._internalModel.send(name, context);
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
@deprecated
|
|
670
|
-
@method transitionTo
|
|
671
|
-
@private
|
|
672
|
-
@param {String} name
|
|
673
|
-
*/
|
|
674
|
-
transitionTo(name) {
|
|
675
|
-
return this._internalModel.transitionTo(name);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
580
|
/*
|
|
679
581
|
We hook the default implementation to ensure
|
|
680
582
|
our tagged properties are properly notified
|
|
@@ -2093,38 +1995,6 @@ if (HAS_DEBUG_PACKAGE) {
|
|
|
2093
1995
|
};
|
|
2094
1996
|
}
|
|
2095
1997
|
|
|
2096
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
2097
|
-
/**
|
|
2098
|
-
Override the default event firing from Ember.Evented to
|
|
2099
|
-
also call methods with the given name.
|
|
2100
|
-
|
|
2101
|
-
@method trigger
|
|
2102
|
-
@private
|
|
2103
|
-
@param {String} name
|
|
2104
|
-
*/
|
|
2105
|
-
Model.reopen(DeprecatedEvented, {
|
|
2106
|
-
trigger(name) {
|
|
2107
|
-
if (DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS) {
|
|
2108
|
-
let fn = this[name];
|
|
2109
|
-
if (typeof fn === 'function') {
|
|
2110
|
-
let length = arguments.length;
|
|
2111
|
-
let args = new Array(length - 1);
|
|
2112
|
-
|
|
2113
|
-
for (let i = 1; i < length; i++) {
|
|
2114
|
-
args[i - 1] = arguments[i];
|
|
2115
|
-
}
|
|
2116
|
-
fn.apply(this, args);
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
|
|
2120
|
-
const _hasEvent = DEBUG ? this._has(name) : this.has(name);
|
|
2121
|
-
if (_hasEvent) {
|
|
2122
|
-
this._super(...arguments);
|
|
2123
|
-
}
|
|
2124
|
-
},
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
1998
|
if (DEBUG) {
|
|
2129
1999
|
let lookupDescriptor = function lookupDescriptor(obj, keyName) {
|
|
2130
2000
|
let current = obj;
|
|
@@ -2148,42 +2018,10 @@ if (DEBUG) {
|
|
|
2148
2018
|
return isBasicDesc(instanceDesc) && lookupDescriptor(obj.constructor, keyName) === null;
|
|
2149
2019
|
};
|
|
2150
2020
|
|
|
2151
|
-
let lookupDeprecations;
|
|
2152
|
-
let _deprecatedLifecycleMethods;
|
|
2153
|
-
|
|
2154
|
-
if (DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS) {
|
|
2155
|
-
const INSTANCE_DEPRECATIONS = new WeakMap();
|
|
2156
|
-
_deprecatedLifecycleMethods = [
|
|
2157
|
-
'becameError',
|
|
2158
|
-
'becameInvalid',
|
|
2159
|
-
'didCreate',
|
|
2160
|
-
'didDelete',
|
|
2161
|
-
'didLoad',
|
|
2162
|
-
'didUpdate',
|
|
2163
|
-
'ready',
|
|
2164
|
-
'rolledBack',
|
|
2165
|
-
];
|
|
2166
|
-
|
|
2167
|
-
lookupDeprecations = function lookupInstanceDeprecations(instance) {
|
|
2168
|
-
let deprecations = INSTANCE_DEPRECATIONS.get(instance);
|
|
2169
|
-
|
|
2170
|
-
if (!deprecations) {
|
|
2171
|
-
deprecations = new Set();
|
|
2172
|
-
INSTANCE_DEPRECATIONS.set(instance, deprecations);
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
return deprecations;
|
|
2176
|
-
};
|
|
2177
|
-
}
|
|
2178
|
-
|
|
2179
2021
|
Model.reopen({
|
|
2180
2022
|
init() {
|
|
2181
2023
|
this._super(...arguments);
|
|
2182
2024
|
|
|
2183
|
-
if (DEPRECATE_EVENTED_API_USAGE) {
|
|
2184
|
-
this._getDeprecatedEventedInfo = () => `${this._internalModel.modelName}#${this.id}`;
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
2025
|
if (!isDefaultEmptyDescriptor(this, '_internalModel') || !(this._internalModel instanceof InternalModel)) {
|
|
2188
2026
|
throw new Error(
|
|
2189
2027
|
`'_internalModel' is a reserved property name on instances of classes extending Model. Please choose a different property name for ${this.constructor.toString()}`
|
|
@@ -2207,31 +2045,6 @@ if (DEBUG) {
|
|
|
2207
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()}`
|
|
2208
2046
|
);
|
|
2209
2047
|
}
|
|
2210
|
-
|
|
2211
|
-
if (DEPRECATE_RECORD_LIFECYCLE_EVENT_METHODS) {
|
|
2212
|
-
let lifecycleDeprecations = lookupDeprecations(this.constructor);
|
|
2213
|
-
|
|
2214
|
-
_deprecatedLifecycleMethods.forEach((methodName) => {
|
|
2215
|
-
if (typeof this[methodName] === 'function' && !lifecycleDeprecations.has(methodName)) {
|
|
2216
|
-
deprecate(
|
|
2217
|
-
`You defined a \`${methodName}\` method for ${this.constructor.toString()} but lifecycle events for models have been deprecated.`,
|
|
2218
|
-
false,
|
|
2219
|
-
{
|
|
2220
|
-
id: 'ember-data:record-lifecycle-event-methods',
|
|
2221
|
-
until: '4.0',
|
|
2222
|
-
url: 'https://deprecations.emberjs.com/ember-data/v3.x#toc_record-lifecycle-event-methods',
|
|
2223
|
-
for: '@ember-data/model',
|
|
2224
|
-
since: {
|
|
2225
|
-
available: '3.12',
|
|
2226
|
-
enabled: '3.12',
|
|
2227
|
-
},
|
|
2228
|
-
}
|
|
2229
|
-
);
|
|
2230
|
-
|
|
2231
|
-
lifecycleDeprecations.add(methodName);
|
|
2232
|
-
}
|
|
2233
|
-
});
|
|
2234
|
-
}
|
|
2235
2048
|
},
|
|
2236
2049
|
});
|
|
2237
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.2.0-alpha.
|
|
3
|
+
"version": "4.2.0-alpha.9",
|
|
4
4
|
"description": "The default blueprint for ember-cli addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -18,26 +18,26 @@
|
|
|
18
18
|
"test:node": "mocha"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ember-data/canary-features": "4.2.0-alpha.
|
|
22
|
-
"@ember-data/private-build-infra": "4.2.0-alpha.
|
|
23
|
-
"@ember-data/store": "4.2.0-alpha.
|
|
21
|
+
"@ember-data/canary-features": "4.2.0-alpha.9",
|
|
22
|
+
"@ember-data/private-build-infra": "4.2.0-alpha.9",
|
|
23
|
+
"@ember-data/store": "4.2.0-alpha.9",
|
|
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.2.0-alpha.
|
|
36
|
+
"@ember-data/unpublished-test-infra": "4.2.0-alpha.9",
|
|
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": "~4.
|
|
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
43
|
"ember-cli-htmlbars": "^6.0.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"ember-source-channel-url": "^3.0.0",
|
|
55
55
|
"ember-try": "^1.4.0",
|
|
56
56
|
"loader.js": "^4.7.0",
|
|
57
|
-
"qunit": "^2.
|
|
57
|
+
"qunit": "^2.17.0",
|
|
58
58
|
"qunit-dom": "^2.0.0",
|
|
59
59
|
"silent-error": "^1.1.1",
|
|
60
60
|
"webpack": "^5.37.1"
|