@ember-data/model 5.0.0-alpha.1 → 5.0.0-alpha.2

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,19 +1,19 @@
1
1
  import { macroCondition, getOwnConfig, importSync } from '@embroider/macros';
2
- import { assert, deprecate, warn, inspect } from '@ember/debug';
2
+ import { assert, warn } from '@ember/debug';
3
3
  import EmberObject, { computed, get } from '@ember/object';
4
4
  import { recordIdentifierFor, storeFor as storeFor$1 } from '@ember-data/store';
5
5
  import { peekCache, RecordArray, MUTATE, SOURCE, recordIdentifierFor as recordIdentifierFor$1, IDENTIFIER_ARRAY_TAG, notifyArray, isStableIdentifier, storeFor, fastPush, coerceId } from '@ember-data/store/-private';
6
6
  import { dasherize } from '@ember/string';
7
- import ArrayMixin, { A, NativeArray } from '@ember/array';
7
+ import { A } from '@ember/array';
8
8
  import { singularize } from 'ember-inflector';
9
9
  import { dependentKeyCompat } from '@ember/object/compat';
10
10
  import { run } from '@ember/runloop';
11
11
  import { cached, tracked } from '@glimmer/tracking';
12
12
  import Ember from 'ember';
13
- import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
14
- import ObjectProxy from '@ember/object/proxy';
15
13
  import ArrayProxy from '@ember/array/proxy';
16
14
  import { mapBy, not } from '@ember/object/computed';
15
+ import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
16
+ import ObjectProxy from '@ember/object/proxy';
17
17
  import { cacheFor } from '@ember/object/internals';
18
18
  import { addToTransaction, subscribe } from '@ember-data/tracking/-private';
19
19
  function isElementDescriptor(args) {
@@ -212,62 +212,6 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con
212
212
  }
213
213
  return desc;
214
214
  }
215
- const PromiseObject = ObjectProxy.extend(PromiseProxyMixin);
216
- function promiseObject(promise) {
217
- return PromiseObject.create({
218
- promise
219
- });
220
- }
221
-
222
- // constructor is accessed in some internals but not including it in the copyright for the deprecation
223
- const ALLOWABLE_METHODS = ['constructor', 'then', 'catch', 'finally'];
224
- const ALLOWABLE_PROPS = ['__ec_yieldable__', '__ec_cancel__'];
225
- const PROXIED_OBJECT_PROPS = ['content', 'isPending', 'isSettled', 'isRejected', 'isFulfilled', 'promise', 'reason'];
226
- const ProxySymbolString = String(Symbol.for('PROXY_CONTENT'));
227
- function deprecatedPromiseObject(promise) {
228
- const promiseObjectProxy = promiseObject(promise);
229
- if (macroCondition(!getOwnConfig().env.DEBUG)) {
230
- return promiseObjectProxy;
231
- }
232
- const handler = {
233
- get(target, prop, receiver) {
234
- if (typeof prop === 'symbol') {
235
- if (String(prop) === ProxySymbolString) {
236
- return;
237
- }
238
- return Reflect.get(target, prop, receiver);
239
- }
240
- if (prop === 'constructor') {
241
- return target.constructor;
242
- }
243
- if (ALLOWABLE_PROPS.includes(prop)) {
244
- return target[prop];
245
- }
246
- if (!ALLOWABLE_METHODS.includes(prop)) {
247
- deprecate(`Accessing ${prop} is deprecated. The return type is being changed from PromiseObjectProxy to a Promise. The only available methods to access on this promise are .then, .catch and .finally`, false, {
248
- id: 'ember-data:model-save-promise',
249
- until: '5.0',
250
- for: '@ember-data/store',
251
- since: {
252
- available: '4.4',
253
- enabled: '4.4'
254
- }
255
- });
256
- } else {
257
- return target[prop].bind(target);
258
- }
259
- if (PROXIED_OBJECT_PROPS.includes(prop)) {
260
- return target[prop];
261
- }
262
- const value = get(target, prop);
263
- if (value && typeof value === 'function' && typeof value.bind === 'function') {
264
- return value.bind(receiver);
265
- }
266
- return undefined;
267
- }
268
- };
269
- return new Proxy(promiseObjectProxy, handler);
270
- }
271
215
  var _dec$1, _dec2, _dec3, _dec4, _class$6, _descriptor$5, _descriptor2$2;
272
216
 
273
217
  /**
@@ -639,6 +583,9 @@ let Errors = (_dec$1 = computed(), _dec2 = mapBy('content', 'message'), _dec3 =
639
583
  initializer: null
640
584
  })), _class$6));
641
585
 
586
+ /**
587
+ @module @ember-data/store
588
+ */
642
589
  /**
643
590
  A `ManyArray` is a `MutableArray` that represents the contents of a has-many
644
591
  relationship.
@@ -933,29 +880,10 @@ function extractIdentifiersFromRecords(records) {
933
880
  return records.map(extractIdentifierFromRecord$1);
934
881
  }
935
882
  function extractIdentifierFromRecord$1(recordOrPromiseRecord) {
936
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_PROMISE_PROXIES)) {
937
- if (isPromiseRecord$1(recordOrPromiseRecord)) {
938
- let content = recordOrPromiseRecord.content;
939
- assert('You passed in a promise that did not originate from an EmberData relationship. You can only pass promises that come from a belongsTo relationship.', content !== undefined && content !== null);
940
- deprecate(`You passed in a PromiseProxy to a Relationship API that now expects a resolved value. await the value before setting it.`, false, {
941
- id: 'ember-data:deprecate-promise-proxies',
942
- until: '5.0',
943
- since: {
944
- enabled: '4.7',
945
- available: '4.7'
946
- },
947
- for: 'ember-data'
948
- });
949
- assertRecordPassedToHasMany(content);
950
- return recordIdentifierFor$1(content);
951
- }
952
- }
953
883
  assertRecordPassedToHasMany(recordOrPromiseRecord);
954
884
  return recordIdentifierFor$1(recordOrPromiseRecord);
955
885
  }
956
- function isPromiseRecord$1(record) {
957
- return !!record.then;
958
- }
886
+ const PromiseObject = ObjectProxy.extend(PromiseProxyMixin);
959
887
  var _dec, _class$5;
960
888
 
961
889
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1006,7 +934,6 @@ let PromiseBelongsTo = (_dec = computed(), (_class$5 = class PromiseBelongsTo ex
1006
934
  }
1007
935
  }, (_applyDecoratedDescriptor(_class$5.prototype, "id", [cached], Object.getOwnPropertyDescriptor(_class$5.prototype, "id"), _class$5.prototype), _applyDecoratedDescriptor(_class$5.prototype, "meta", [_dec], Object.getOwnPropertyDescriptor(_class$5.prototype, "meta"), _class$5.prototype)), _class$5));
1008
936
  var _class$4, _descriptor$4, _descriptor2$1, _descriptor3, _descriptor4, _descriptor5;
1009
-
1010
937
  /**
1011
938
  @module @ember-data/model
1012
939
  */
@@ -1027,8 +954,6 @@ var _class$4, _descriptor$4, _descriptor2$1, _descriptor3, _descriptor4, _descri
1027
954
  @public
1028
955
  */
1029
956
  let PromiseManyArray = (_class$4 = class PromiseManyArray {
1030
- // @deprecated (isDestroyed is not deprecated)
1031
-
1032
957
  constructor(promise, content) {
1033
958
  //---- Methods/Properties on ArrayProxy that we will keep as our API
1034
959
  _initializerDefineProperty(this, "content", _descriptor$4, this);
@@ -1063,26 +988,7 @@ let PromiseManyArray = (_class$4 = class PromiseManyArray {
1063
988
  _initializerDefineProperty(this, "isSettled", _descriptor5, this);
1064
989
  this._update(promise, content);
1065
990
  this.isDestroyed = false;
1066
- this.isDestroying = false;
1067
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_A_USAGE)) {
1068
- const meta = Ember.meta(this);
1069
- meta.hasMixin = mixin => {
1070
- deprecate(`Do not use A() on an EmberData PromiseManyArray`, false, {
1071
- id: 'ember-data:no-a-with-array-like',
1072
- until: '5.0',
1073
- since: {
1074
- enabled: '4.7',
1075
- available: '4.7'
1076
- },
1077
- for: 'ember-data'
1078
- });
1079
- // @ts-expect-error ArrayMixin is more than a type
1080
- if (mixin === NativeArray || mixin === ArrayMixin) {
1081
- return true;
1082
- }
1083
- return false;
1084
- };
1085
- } else if (macroCondition(getOwnConfig().env.DEBUG)) {
991
+ if (macroCondition(getOwnConfig().env.DEBUG)) {
1086
992
  const meta = Ember.meta(this);
1087
993
  meta.hasMixin = mixin => {
1088
994
  assert(`Do not use A() on an EmberData PromiseManyArray`);
@@ -1180,7 +1086,6 @@ let PromiseManyArray = (_class$4 = class PromiseManyArray {
1180
1086
  //---- Methods on EmberObject that we should keep
1181
1087
 
1182
1088
  destroy() {
1183
- this.isDestroying = true;
1184
1089
  this.isDestroyed = true;
1185
1090
  this.content = null;
1186
1091
  this.promise = null;
@@ -1256,49 +1161,6 @@ let PromiseManyArray = (_class$4 = class PromiseManyArray {
1256
1161
  return false;
1257
1162
  }
1258
1163
  }), _applyDecoratedDescriptor(_class$4.prototype, "links", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class$4.prototype, "links"), _class$4.prototype), _applyDecoratedDescriptor(_class$4.prototype, "meta", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class$4.prototype, "meta"), _class$4.prototype)), _class$4);
1259
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_PROMISE_MANY_ARRAY_BEHAVIORS)) {
1260
- PromiseManyArray.prototype.createRecord = function createRecord(...args) {
1261
- deprecate(`The createRecord method on ember-data's PromiseManyArray is deprecated. await the promise and work with the ManyArray directly.`, false, {
1262
- id: 'ember-data:deprecate-promise-many-array-behaviors',
1263
- until: '5.0',
1264
- since: {
1265
- enabled: '4.7',
1266
- available: '4.7'
1267
- },
1268
- for: 'ember-data'
1269
- });
1270
- assert('You are trying to createRecord on an async manyArray before it has been created', this.content);
1271
- return this.content.createRecord(...args);
1272
- };
1273
- Object.defineProperty(PromiseManyArray.prototype, 'firstObject', {
1274
- get() {
1275
- deprecate(`The firstObject property on ember-data's PromiseManyArray is deprecated. await the promise and work with the ManyArray directly.`, false, {
1276
- id: 'ember-data:deprecate-promise-many-array-behaviors',
1277
- until: '5.0',
1278
- since: {
1279
- enabled: '4.7',
1280
- available: '4.7'
1281
- },
1282
- for: 'ember-data'
1283
- });
1284
- return this.content ? this.content.firstObject : undefined;
1285
- }
1286
- });
1287
- Object.defineProperty(PromiseManyArray.prototype, 'lastObject', {
1288
- get() {
1289
- deprecate(`The lastObject property on ember-data's PromiseManyArray is deprecated. await the promise and work with the ManyArray directly.`, false, {
1290
- id: 'ember-data:deprecate-promise-many-array-behaviors',
1291
- until: '5.0',
1292
- since: {
1293
- enabled: '4.7',
1294
- available: '4.7'
1295
- },
1296
- for: 'ember-data'
1297
- });
1298
- return this.content ? this.content.lastObject : undefined;
1299
- }
1300
- });
1301
- }
1302
1164
  function tapPromise(proxy, promise) {
1303
1165
  proxy.isPending = true;
1304
1166
  proxy.isSettled = false;
@@ -1318,41 +1180,6 @@ function tapPromise(proxy, promise) {
1318
1180
  throw error;
1319
1181
  });
1320
1182
  }
1321
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_PROMISE_MANY_ARRAY_BEHAVIORS)) {
1322
- const EmberObjectMethods = ['addObserver', 'cacheFor', 'decrementProperty', 'get', 'getProperties', 'incrementProperty', 'notifyPropertyChange', 'removeObserver', 'set', 'setProperties', 'toggleProperty'];
1323
- EmberObjectMethods.forEach(method => {
1324
- PromiseManyArray.prototype[method] = function delegatedMethod(...args) {
1325
- deprecate(`The ${method} method on ember-data's PromiseManyArray is deprecated. await the promise and work with the ManyArray directly.`, false, {
1326
- id: 'ember-data:deprecate-promise-many-array-behaviors',
1327
- until: '5.0',
1328
- since: {
1329
- enabled: '4.7',
1330
- available: '4.7'
1331
- },
1332
- for: 'ember-data'
1333
- });
1334
- return Ember[method](this, ...args);
1335
- };
1336
- });
1337
- const InheritedProxyMethods = ['addArrayObserver', 'addObject', 'addObjects', 'any', 'arrayContentDidChange', 'arrayContentWillChange', 'clear', 'compact', 'every', 'filter', 'filterBy', 'find', 'findBy', 'getEach', 'includes', 'indexOf', 'insertAt', 'invoke', 'isAny', 'isEvery', 'lastIndexOf', 'map', 'mapBy',
1338
- // TODO update RFC to note objectAt was deprecated (forEach was left for iteration)
1339
- 'objectAt', 'objectsAt', 'popObject', 'pushObject', 'pushObjects', 'reduce', 'reject', 'rejectBy', 'removeArrayObserver', 'removeAt', 'removeObject', 'removeObjects', 'replace', 'reverseObjects', 'setEach', 'setObjects', 'shiftObject', 'slice', 'sortBy', 'toArray', 'uniq', 'uniqBy', 'unshiftObject', 'unshiftObjects', 'without'];
1340
- InheritedProxyMethods.forEach(method => {
1341
- PromiseManyArray.prototype[method] = function proxiedMethod(...args) {
1342
- deprecate(`The ${method} method on ember-data's PromiseManyArray is deprecated. await the promise and work with the ManyArray directly.`, false, {
1343
- id: 'ember-data:deprecate-promise-many-array-behaviors',
1344
- until: '5.0',
1345
- since: {
1346
- enabled: '4.7',
1347
- available: '4.7'
1348
- },
1349
- for: 'ember-data'
1350
- });
1351
- assert(`Cannot call ${method} before content is assigned.`, this.content);
1352
- return this.content[method](...args);
1353
- };
1354
- });
1355
- }
1356
1183
 
1357
1184
  /*
1358
1185
  Assert that `addedRecord` has a valid type so it can be added to the
@@ -1368,39 +1195,13 @@ if (macroCondition(getOwnConfig().deprecations.DEPRECATE_PROMISE_MANY_ARRAY_BEHA
1368
1195
  */
1369
1196
  let assertPolymorphicType;
1370
1197
  if (macroCondition(getOwnConfig().env.DEBUG)) {
1371
- let checkPolymorphic = function checkPolymorphic(modelClass, addedModelClass) {
1372
- if (modelClass.__isMixin) {
1373
- return modelClass.__mixin.detect(addedModelClass.PrototypeMixin) ||
1374
- // handle native class extension e.g. `class Post extends Model.extend(Commentable) {}`
1375
- modelClass.__mixin.detect(Object.getPrototypeOf(addedModelClass).PrototypeMixin);
1376
- }
1377
- return addedModelClass.prototype instanceof modelClass || modelClass.detect(addedModelClass);
1378
- };
1379
1198
  assertPolymorphicType = function assertPolymorphicType(parentIdentifier, parentDefinition, addedIdentifier, store) {
1380
- let asserted = false;
1381
1199
  if (parentDefinition.inverseIsImplicit) {
1382
1200
  return;
1383
1201
  }
1384
1202
  if (parentDefinition.isPolymorphic) {
1385
1203
  let meta = store.getSchemaDefinitionService().relationshipsDefinitionFor(addedIdentifier)[parentDefinition.inverseKey];
1386
- if (meta?.options?.as) {
1387
- asserted = true;
1388
- assert(`The schema for the relationship '${parentDefinition.inverseKey}' on '${addedIdentifier.type}' type does not implement '${parentDefinition.type}' and thus cannot be assigned to the '${parentDefinition.key}' relationship in '${parentIdentifier.type}'. The definition should specify 'as: "${parentDefinition.type}"' in options.`, meta.options.as === parentDefinition.type);
1389
- }
1390
- }
1391
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_NON_EXPLICIT_POLYMORPHISM)) {
1392
- if (!asserted) {
1393
- store = store._store ? store._store : store; // allow usage with storeWrapper
1394
- let addedModelName = addedIdentifier.type;
1395
- let parentModelName = parentIdentifier.type;
1396
- let key = parentDefinition.key;
1397
- let relationshipModelName = parentDefinition.type;
1398
- let relationshipClass = store.modelFor(relationshipModelName);
1399
- let addedClass = store.modelFor(addedModelName);
1400
- let assertionMessage = `The '${addedModelName}' type does not implement '${relationshipModelName}' and thus cannot be assigned to the '${key}' relationship in '${parentModelName}'. Make it a descendant of '${relationshipModelName}' or use a mixin of the same name.`;
1401
- let isPolymorphic = checkPolymorphic(relationshipClass, addedClass);
1402
- assert(assertionMessage, isPolymorphic);
1403
- }
1204
+ assert(`The schema for the relationship '${parentDefinition.inverseKey}' on '${addedIdentifier.type}' type does not implement '${parentDefinition.type}' and thus cannot be assigned to the '${parentDefinition.key}' relationship in '${parentIdentifier.type}'. The definition should specify 'as: "${parentDefinition.type}"' in options.`, meta?.options.as === parentDefinition.type);
1404
1205
  }
1405
1206
  };
1406
1207
  }
@@ -1619,7 +1420,7 @@ let BelongsToReference = (_class$3 = class BelongsToReference {
1619
1420
  }
1620
1421
  _resource() {
1621
1422
  this._ref; // subscribe
1622
- const cache = macroCondition(getOwnConfig().deprecations.DEPRECATE_V1_RECORD_DATA) ? this.store._instanceCache.getResourceCache(this.___identifier) : this.store.cache;
1423
+ const cache = this.store.cache;
1623
1424
  return cache.getRelationship(this.___identifier, this.key);
1624
1425
  }
1625
1426
 
@@ -1703,27 +1504,11 @@ let BelongsToReference = (_class$3 = class BelongsToReference {
1703
1504
  ```
1704
1505
  @method push
1705
1506
  @public
1706
- @param {Object|Promise} objectOrPromise a promise that resolves to a JSONAPI document object describing the new value of this relationship.
1507
+ @param {Object} object a JSONAPI document object describing the new value of this relationship.
1707
1508
  @return {Promise<record>} A promise that resolves with the new value in this belongs-to relationship.
1708
1509
  */
1709
- async push(data) {
1510
+ push(data) {
1710
1511
  let jsonApiDoc = data;
1711
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_PROMISE_PROXIES)) {
1712
- if (data.then) {
1713
- jsonApiDoc = await data;
1714
- if (jsonApiDoc !== data) {
1715
- deprecate(`You passed in a Promise to a Reference API that now expects a resolved value. await the value before setting it.`, false, {
1716
- id: 'ember-data:deprecate-promise-proxies',
1717
- until: '5.0',
1718
- since: {
1719
- enabled: '4.7',
1720
- available: '4.7'
1721
- },
1722
- for: 'ember-data'
1723
- });
1724
- }
1725
- }
1726
- }
1727
1512
  let record = this.store.push(jsonApiDoc);
1728
1513
  if (macroCondition(getOwnConfig().env.DEBUG)) {
1729
1514
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
@@ -1740,7 +1525,7 @@ let BelongsToReference = (_class$3 = class BelongsToReference {
1740
1525
  value: recordIdentifierFor$1(record)
1741
1526
  });
1742
1527
  });
1743
- return record;
1528
+ return Promise.resolve(record);
1744
1529
  }
1745
1530
 
1746
1531
  /**
@@ -1985,7 +1770,7 @@ let HasManyReference = (_class$2 = class HasManyReference {
1985
1770
  return [];
1986
1771
  }
1987
1772
  _resource() {
1988
- const cache = macroCondition(getOwnConfig().deprecations.DEPRECATE_V1_RECORD_DATA) ? this.store._instanceCache.getResourceCache(this.___identifier) : this.store.cache;
1773
+ const cache = this.store.cache;
1989
1774
  return cache.getRelationship(this.___identifier, this.key);
1990
1775
  }
1991
1776
 
@@ -2201,22 +1986,6 @@ let HasManyReference = (_class$2 = class HasManyReference {
2201
1986
  */
2202
1987
  async push(objectOrPromise) {
2203
1988
  let payload = objectOrPromise;
2204
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_PROMISE_PROXIES)) {
2205
- if (objectOrPromise.then) {
2206
- payload = await objectOrPromise;
2207
- if (payload !== objectOrPromise) {
2208
- deprecate(`You passed in a Promise to a Reference API that now expects a resolved value. await the value before setting it.`, false, {
2209
- id: 'ember-data:deprecate-promise-proxies',
2210
- until: '5.0',
2211
- since: {
2212
- enabled: '4.7',
2213
- available: '4.7'
2214
- },
2215
- for: 'ember-data'
2216
- });
2217
- }
2218
- }
2219
- }
2220
1989
  let array;
2221
1990
  if (!Array.isArray(payload) && typeof payload === 'object' && Array.isArray(payload.data)) {
2222
1991
  array = payload.data;
@@ -2532,7 +2301,7 @@ class LegacySupport {
2532
2301
  true);
2533
2302
  }
2534
2303
  _getCurrentState(identifier, field) {
2535
- let jsonApi = this.cache.getRelationship(identifier, field, true);
2304
+ let jsonApi = this.cache.getRelationship(identifier, field);
2536
2305
  const cache = this.store._instanceCache;
2537
2306
  let identifiers = [];
2538
2307
  if (jsonApi.data) {
@@ -2924,30 +2693,11 @@ function handleCompletedRelationshipRequest(recordExt, key, relationship, value,
2924
2693
  relationship.state.isStale = false;
2925
2694
  return isHasMany || !value ? value : recordExt.store.peekRecord(value);
2926
2695
  }
2927
- function extractIdentifierFromRecord(recordOrPromiseRecord) {
2928
- if (!recordOrPromiseRecord) {
2696
+ function extractIdentifierFromRecord(record) {
2697
+ if (!record) {
2929
2698
  return null;
2930
2699
  }
2931
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_PROMISE_PROXIES)) {
2932
- if (isPromiseRecord(recordOrPromiseRecord)) {
2933
- let content = recordOrPromiseRecord.content;
2934
- assert('You passed in a promise that did not originate from an EmberData relationship. You can only pass promises that come from a belongsTo or hasMany relationship to the get call.', content !== undefined);
2935
- deprecate(`You passed in a PromiseProxy to a Relationship API that now expects a resolved value. await the value before setting it.`, false, {
2936
- id: 'ember-data:deprecate-promise-proxies',
2937
- until: '5.0',
2938
- since: {
2939
- enabled: '4.7',
2940
- available: '4.7'
2941
- },
2942
- for: 'ember-data'
2943
- });
2944
- return content ? recordIdentifierFor$1(content) : null;
2945
- }
2946
- }
2947
- return recordIdentifierFor$1(recordOrPromiseRecord);
2948
- }
2949
- function isPromiseRecord(record) {
2950
- return !!record.then;
2700
+ return recordIdentifierFor$1(record);
2951
2701
  }
2952
2702
  function anyUnloaded(store, relationship) {
2953
2703
  let state = relationship.localState;
@@ -3024,7 +2774,7 @@ function notifyRelationship(identifier, key, record, meta) {
3024
2774
  }
3025
2775
  function notifyAttribute(store, identifier, key, record) {
3026
2776
  let currentValue = cacheFor(record, key);
3027
- const cache = macroCondition(getOwnConfig().deprecations.DEPRECATE_V1_RECORD_DATA) ? peekCache(record) : store.cache;
2777
+ const cache = store.cache;
3028
2778
  if (currentValue !== cache.getAttr(identifier, key)) {
3029
2779
  record.notifyPropertyChange(key);
3030
2780
  }
@@ -3164,7 +2914,7 @@ let RecordState = (_class3 = class RecordState {
3164
2914
  const identity = recordIdentifierFor$1(record);
3165
2915
  this.identifier = identity;
3166
2916
  this.record = record;
3167
- this.cache = macroCondition(getOwnConfig().deprecations.DEPRECATE_V1_RECORD_DATA) ? peekCache(record) : store.cache;
2917
+ this.cache = store.cache;
3168
2918
  this.pendingCount = 0;
3169
2919
  this.fulfilledCount = 0;
3170
2920
  this.rejectedCount = 0;
@@ -3426,79 +3176,6 @@ function notifyErrorsStateChanged(state) {
3426
3176
  state.notify('isError');
3427
3177
  state.notify('adapterError');
3428
3178
  }
3429
- function typeForRelationshipMeta(meta) {
3430
- let modelName = dasherize(meta.type || meta.key);
3431
- if (meta.kind === 'hasMany') {
3432
- modelName = singularize(modelName);
3433
- }
3434
- return modelName;
3435
- }
3436
- function shouldFindInverse(relationshipMeta) {
3437
- let options = relationshipMeta.options;
3438
- return !(options && options.inverse === null);
3439
- }
3440
- class RelationshipDefinition {
3441
- constructor(meta) {
3442
- this._type = '';
3443
- this.__inverseKey = '';
3444
- this.__hasCalculatedInverse = false;
3445
- this.parentModelName = meta.parentModelName;
3446
- this.meta = meta;
3447
- }
3448
-
3449
- /**
3450
- * @internal
3451
- * @deprecated
3452
- */
3453
- get key() {
3454
- return this.meta.key;
3455
- }
3456
- get kind() {
3457
- return this.meta.kind;
3458
- }
3459
- get type() {
3460
- if (this._type) {
3461
- return this._type;
3462
- }
3463
- this._type = typeForRelationshipMeta(this.meta);
3464
- return this._type;
3465
- }
3466
- get options() {
3467
- return this.meta.options;
3468
- }
3469
- get name() {
3470
- return this.meta.name;
3471
- }
3472
- _inverseKey(store, modelClass) {
3473
- if (this.__hasCalculatedInverse === false) {
3474
- this._calculateInverse(store, modelClass);
3475
- }
3476
- return this.__inverseKey;
3477
- }
3478
- _calculateInverse(store, modelClass) {
3479
- this.__hasCalculatedInverse = true;
3480
- let inverseKey;
3481
- let inverse = null;
3482
- if (shouldFindInverse(this.meta)) {
3483
- inverse = modelClass.inverseFor(this.key, store);
3484
- }
3485
- // TODO make this error again for the non-polymorphic case
3486
- if (macroCondition(getOwnConfig().env.DEBUG)) {
3487
- if (!this.options.polymorphic) {
3488
- modelClass.typeForRelationship(this.key, store);
3489
- }
3490
- }
3491
- if (inverse) {
3492
- inverseKey = inverse.name;
3493
- } else {
3494
- inverseKey = null;
3495
- }
3496
- this.__inverseKey = inverseKey;
3497
- }
3498
- }
3499
- function relationshipFromMeta(meta) {
3500
- return new RelationshipDefinition(meta);
3501
- }
3502
3179
  var _class, _descriptor, _class2;
3503
3180
  const {
3504
3181
  changeProperties
@@ -4277,9 +3954,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4277
3954
  } else {
4278
3955
  promise = storeFor$1(this).saveRecord(this, options);
4279
3956
  }
4280
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_SAVE_PROMISE_ACCESS)) {
4281
- return deprecatedPromiseObject(promise);
4282
- }
4283
3957
  return promise;
4284
3958
  }
4285
3959
 
@@ -4324,9 +3998,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4324
3998
  }).then(() => this).finally(() => {
4325
3999
  this.isReloading = false;
4326
4000
  });
4327
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_SAVE_PROMISE_ACCESS)) {
4328
- return deprecatedPromiseObject(promise);
4329
- }
4330
4001
  return promise;
4331
4002
  }
4332
4003
  attr() {
@@ -4560,36 +4231,12 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4560
4231
  @return {Model} the type of the relationship, or undefined
4561
4232
  */
4562
4233
  static typeForRelationship(name, store) {
4563
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4564
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4565
- id: 'ember-data:deprecate-early-static',
4566
- for: 'ember-data',
4567
- until: '5.0',
4568
- since: {
4569
- available: '4.7',
4570
- enabled: '4.7'
4571
- }
4572
- });
4573
- } else {
4574
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4575
- }
4234
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4576
4235
  let relationship = this.relationshipsByName.get(name);
4577
4236
  return relationship && store.modelFor(relationship.type);
4578
4237
  }
4579
4238
  static get inverseMap() {
4580
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4581
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4582
- id: 'ember-data:deprecate-early-static',
4583
- for: 'ember-data',
4584
- until: '5.0',
4585
- since: {
4586
- available: '4.7',
4587
- enabled: '4.7'
4588
- }
4589
- });
4590
- } else {
4591
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4592
- }
4239
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4593
4240
  return Object.create(null);
4594
4241
  }
4595
4242
 
@@ -4620,19 +4267,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4620
4267
  @return {Object} the inverse relationship, or null
4621
4268
  */
4622
4269
  static inverseFor(name, store) {
4623
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4624
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4625
- id: 'ember-data:deprecate-early-static',
4626
- for: 'ember-data',
4627
- until: '5.0',
4628
- since: {
4629
- available: '4.7',
4630
- enabled: '4.7'
4631
- }
4632
- });
4633
- } else {
4634
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4635
- }
4270
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4636
4271
  let inverseMap = this.inverseMap;
4637
4272
  if (inverseMap[name]) {
4638
4273
  return inverseMap[name];
@@ -4645,19 +4280,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4645
4280
 
4646
4281
  //Calculate the inverse, ignoring the cache
4647
4282
  static _findInverseFor(name, store) {
4648
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4649
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4650
- id: 'ember-data:deprecate-early-static',
4651
- for: 'ember-data',
4652
- until: '5.0',
4653
- since: {
4654
- available: '4.7',
4655
- enabled: '4.7'
4656
- }
4657
- });
4658
- } else {
4659
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4660
- }
4283
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4661
4284
  const relationship = this.relationshipsByName.get(name);
4662
4285
  const {
4663
4286
  options
@@ -4715,44 +4338,16 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4715
4338
  // ensure inverse is properly configured
4716
4339
  if (macroCondition(getOwnConfig().env.DEBUG)) {
4717
4340
  if (isPolymorphic) {
4718
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_NON_EXPLICIT_POLYMORPHISM)) {
4719
- if (!inverseOptions.as) {
4720
- deprecate(`Relationships that satisfy polymorphic relationships MUST define which abstract-type they are satisfying using 'as'. The field '${fieldOnInverse}' on type '${inverseSchema.modelName}' is misconfigured.`, false, {
4721
- id: 'ember-data:non-explicit-relationships',
4722
- since: {
4723
- enabled: '4.7',
4724
- available: '4.7'
4725
- },
4726
- until: '5.0',
4727
- for: 'ember-data'
4728
- });
4729
- }
4730
- } else {
4731
- assert(`Relationships that satisfy polymorphic relationships MUST define which abstract-type they are satisfying using 'as'. The field '${fieldOnInverse}' on type '${inverseSchema.modelName}' is misconfigured.`, inverseOptions.as);
4732
- assert(`options.as should match the expected type of the polymorphic relationship. Expected field '${fieldOnInverse}' on type '${inverseSchema.modelName}' to specify '${relationship.type}' but found '${inverseOptions.as}'`, !!inverseOptions.as && relationship.type === inverseOptions.as);
4733
- }
4341
+ assert(`Relationships that satisfy polymorphic relationships MUST define which abstract-type they are satisfying using 'as'. The field '${fieldOnInverse}' on type '${inverseSchema.modelName}' is misconfigured.`, inverseOptions.as);
4342
+ assert(`options.as should match the expected type of the polymorphic relationship. Expected field '${fieldOnInverse}' on type '${inverseSchema.modelName}' to specify '${relationship.type}' but found '${inverseOptions.as}'`, !!inverseOptions.as && relationship.type === inverseOptions.as);
4734
4343
  }
4735
4344
  }
4736
4345
 
4737
4346
  // ensure we are properly configured
4738
4347
  if (macroCondition(getOwnConfig().env.DEBUG)) {
4739
4348
  if (inverseOptions.polymorphic) {
4740
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_NON_EXPLICIT_POLYMORPHISM)) {
4741
- if (!options.as) {
4742
- deprecate(`Relationships that satisfy polymorphic relationships MUST define which abstract-type they are satisfying using 'as'. The field '${name}' on type '${this.modelName}' is misconfigured.`, false, {
4743
- id: 'ember-data:non-explicit-relationships',
4744
- since: {
4745
- enabled: '4.7',
4746
- available: '4.7'
4747
- },
4748
- until: '5.0',
4749
- for: 'ember-data'
4750
- });
4751
- }
4752
- } else {
4753
- assert(`Relationships that satisfy polymorphic relationships MUST define which abstract-type they are satisfying using 'as'. The field '${name}' on type '${this.modelName}' is misconfigured.`, options.as);
4754
- assert(`options.as should match the expected type of the polymorphic relationship. Expected field '${name}' on type '${this.modelName}' to specify '${inverseRelationship.type}' but found '${options.as}'`, !!options.as && inverseRelationship.type === options.as);
4755
- }
4349
+ assert(`Relationships that satisfy polymorphic relationships MUST define which abstract-type they are satisfying using 'as'. The field '${name}' on type '${this.modelName}' is misconfigured.`, options.as);
4350
+ assert(`options.as should match the expected type of the polymorphic relationship. Expected field '${name}' on type '${this.modelName}' to specify '${inverseRelationship.type}' but found '${options.as}'`, !!options.as && inverseRelationship.type === options.as);
4756
4351
  }
4757
4352
  }
4758
4353
  assert(`The ${inverseSchema.modelName}:${fieldOnInverse} relationship declares 'inverse: null', but it was resolved as the inverse for ${this.modelName}:${name}.`, inverseOptions.inverse !== null);
@@ -4800,19 +4395,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4800
4395
  */
4801
4396
 
4802
4397
  static get relationships() {
4803
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4804
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4805
- id: 'ember-data:deprecate-early-static',
4806
- for: 'ember-data',
4807
- until: '5.0',
4808
- since: {
4809
- available: '4.7',
4810
- enabled: '4.7'
4811
- }
4812
- });
4813
- } else {
4814
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4815
- }
4398
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4816
4399
  let map = new Map();
4817
4400
  let relationshipsByName = this.relationshipsByName;
4818
4401
 
@@ -4858,19 +4441,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4858
4441
  @readOnly
4859
4442
  */
4860
4443
  static get relationshipNames() {
4861
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4862
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4863
- id: 'ember-data:deprecate-early-static',
4864
- for: 'ember-data',
4865
- until: '5.0',
4866
- since: {
4867
- available: '4.7',
4868
- enabled: '4.7'
4869
- }
4870
- });
4871
- } else {
4872
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4873
- }
4444
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4874
4445
  let names = {
4875
4446
  hasMany: [],
4876
4447
  belongsTo: []
@@ -4910,19 +4481,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4910
4481
  @readOnly
4911
4482
  */
4912
4483
  static get relatedTypes() {
4913
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4914
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4915
- id: 'ember-data:deprecate-early-static',
4916
- for: 'ember-data',
4917
- until: '5.0',
4918
- since: {
4919
- available: '4.7',
4920
- enabled: '4.7'
4921
- }
4922
- });
4923
- } else {
4924
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4925
- }
4484
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4926
4485
  let types = [];
4927
4486
  let rels = this.relationshipsObject;
4928
4487
  let relationships = Object.keys(rels);
@@ -4970,19 +4529,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4970
4529
  @readOnly
4971
4530
  */
4972
4531
  static get relationshipsByName() {
4973
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4974
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4975
- id: 'ember-data:deprecate-early-static',
4976
- for: 'ember-data',
4977
- until: '5.0',
4978
- since: {
4979
- available: '4.7',
4980
- enabled: '4.7'
4981
- }
4982
- });
4983
- } else {
4984
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4985
- }
4532
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4986
4533
  let map = new Map();
4987
4534
  let rels = this.relationshipsObject;
4988
4535
  let relationships = Object.keys(rels);
@@ -4994,19 +4541,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4994
4541
  return map;
4995
4542
  }
4996
4543
  static get relationshipsObject() {
4997
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
4998
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
4999
- id: 'ember-data:deprecate-early-static',
5000
- for: 'ember-data',
5001
- until: '5.0',
5002
- since: {
5003
- available: '4.7',
5004
- enabled: '4.7'
5005
- }
5006
- });
5007
- } else {
5008
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5009
- }
4544
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5010
4545
  let relationships = Object.create(null);
5011
4546
  let modelName = this.modelName;
5012
4547
  this.eachComputedProperty((name, meta) => {
@@ -5014,7 +4549,8 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5014
4549
  meta.key = name;
5015
4550
  meta.name = name;
5016
4551
  meta.parentModelName = modelName;
5017
- relationships[name] = macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_INVERSE) ? relationshipFromMeta(meta) : meta;
4552
+ relationships[name] = meta;
4553
+ assert(`You should not specify both options.as and options.inverse as null on ${modelName}.${meta.name}, as if there is no inverse field there is no abstract type to conform to. You may have intended for this relationship to be polymorphic, or you may have mistakenly set inverse to null.`, !(meta.options.inverse === null && meta.options.as?.length > 0));
5018
4554
  }
5019
4555
  });
5020
4556
  return relationships;
@@ -5054,19 +4590,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5054
4590
  @readOnly
5055
4591
  */
5056
4592
  static get fields() {
5057
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5058
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5059
- id: 'ember-data:deprecate-early-static',
5060
- for: 'ember-data',
5061
- until: '5.0',
5062
- since: {
5063
- available: '4.7',
5064
- enabled: '4.7'
5065
- }
5066
- });
5067
- } else {
5068
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5069
- }
4593
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5070
4594
  let map = new Map();
5071
4595
  this.eachComputedProperty((name, meta) => {
5072
4596
  // TODO end reliance on these booleans and stop leaking them in the spec
@@ -5090,19 +4614,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5090
4614
  @param {any} binding the value to which the callback's `this` should be bound
5091
4615
  */
5092
4616
  static eachRelationship(callback, binding) {
5093
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5094
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5095
- id: 'ember-data:deprecate-early-static',
5096
- for: 'ember-data',
5097
- until: '5.0',
5098
- since: {
5099
- available: '4.7',
5100
- enabled: '4.7'
5101
- }
5102
- });
5103
- } else {
5104
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5105
- }
4617
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5106
4618
  this.relationshipsByName.forEach((relationship, name) => {
5107
4619
  callback.call(binding, name, relationship);
5108
4620
  });
@@ -5120,19 +4632,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5120
4632
  @param {any} binding the value to which the callback's `this` should be bound
5121
4633
  */
5122
4634
  static eachRelatedType(callback, binding) {
5123
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5124
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5125
- id: 'ember-data:deprecate-early-static',
5126
- for: 'ember-data',
5127
- until: '5.0',
5128
- since: {
5129
- available: '4.7',
5130
- enabled: '4.7'
5131
- }
5132
- });
5133
- } else {
5134
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5135
- }
4635
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5136
4636
  let relationshipTypes = this.relatedTypes;
5137
4637
  for (let i = 0; i < relationshipTypes.length; i++) {
5138
4638
  let type = relationshipTypes[i];
@@ -5140,19 +4640,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5140
4640
  }
5141
4641
  }
5142
4642
  static determineRelationshipType(knownSide, store) {
5143
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5144
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5145
- id: 'ember-data:deprecate-early-static',
5146
- for: 'ember-data',
5147
- until: '5.0',
5148
- since: {
5149
- available: '4.7',
5150
- enabled: '4.7'
5151
- }
5152
- });
5153
- } else {
5154
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5155
- }
4643
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5156
4644
  let knownKey = knownSide.key;
5157
4645
  let knownKind = knownSide.kind;
5158
4646
  let inverse = this.inverseFor(knownKey, store);
@@ -5203,19 +4691,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5203
4691
  @readOnly
5204
4692
  */
5205
4693
  static get attributes() {
5206
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5207
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5208
- id: 'ember-data:deprecate-early-static',
5209
- for: 'ember-data',
5210
- until: '5.0',
5211
- since: {
5212
- available: '4.7',
5213
- enabled: '4.7'
5214
- }
5215
- });
5216
- } else {
5217
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5218
- }
4694
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5219
4695
  let map = new Map();
5220
4696
  this.eachComputedProperty((name, meta) => {
5221
4697
  if (meta.isAttribute) {
@@ -5259,19 +4735,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5259
4735
  @readOnly
5260
4736
  */
5261
4737
  static get transformedAttributes() {
5262
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5263
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5264
- id: 'ember-data:deprecate-early-static',
5265
- for: 'ember-data',
5266
- until: '5.0',
5267
- since: {
5268
- available: '4.7',
5269
- enabled: '4.7'
5270
- }
5271
- });
5272
- } else {
5273
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5274
- }
4738
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5275
4739
  let map = new Map();
5276
4740
  this.eachAttribute((key, meta) => {
5277
4741
  if (meta.type) {
@@ -5316,19 +4780,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5316
4780
  @static
5317
4781
  */
5318
4782
  static eachAttribute(callback, binding) {
5319
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5320
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5321
- id: 'ember-data:deprecate-early-static',
5322
- for: 'ember-data',
5323
- until: '5.0',
5324
- since: {
5325
- available: '4.7',
5326
- enabled: '4.7'
5327
- }
5328
- });
5329
- } else {
5330
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5331
- }
4783
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5332
4784
  this.attributes.forEach((meta, name) => {
5333
4785
  callback.call(binding, name, meta);
5334
4786
  });
@@ -5370,19 +4822,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5370
4822
  @static
5371
4823
  */
5372
4824
  static eachTransformedAttribute(callback, binding) {
5373
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5374
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5375
- id: 'ember-data:deprecate-early-static',
5376
- for: 'ember-data',
5377
- until: '5.0',
5378
- since: {
5379
- available: '4.7',
5380
- enabled: '4.7'
5381
- }
5382
- });
5383
- } else {
5384
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5385
- }
4825
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5386
4826
  this.transformedAttributes.forEach((type, name) => {
5387
4827
  callback.call(binding, name, type);
5388
4828
  });
@@ -5395,19 +4835,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
5395
4835
  @static
5396
4836
  */
5397
4837
  static toString() {
5398
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_EARLY_STATIC)) {
5399
- deprecate(`Accessing schema information on Models without looking up the model via the store is deprecated. Use store.modelFor (or better Snapshots or the store.getSchemaDefinitionService() apis) instead.`, this.modelName, {
5400
- id: 'ember-data:deprecate-early-static',
5401
- for: 'ember-data',
5402
- until: '5.0',
5403
- since: {
5404
- available: '4.7',
5405
- enabled: '4.7'
5406
- }
5407
- });
5408
- } else {
5409
- assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5410
- }
4838
+ assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
5411
4839
  return `model:${this.modelName}`;
5412
4840
  }
5413
4841
  }, _class2.isModel = true, _class2.modelName = null, _class2), (_applyDecoratedDescriptor(_class.prototype, "isEmpty", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isEmpty"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isLoading", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isLoading"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isLoaded", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isLoaded"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "hasDirtyAttributes", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "hasDirtyAttributes"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isSaving", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isSaving"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isDeleted", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isDeleted"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isNew", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isNew"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isValid", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isValid"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "dirtyType", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "dirtyType"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isError", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "isError"), _class.prototype), _descriptor = _applyDecoratedDescriptor(_class.prototype, "isReloading", [tracked], {
@@ -5506,41 +4934,14 @@ if (macroCondition(getOwnConfig().env.DEBUG)) {
5506
4934
  }
5507
4935
  }
5508
4936
  });
5509
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_MODEL_REOPEN)) {
5510
- const originalReopen = Model.reopen;
5511
- const originalReopenClass = Model.reopenClass;
5512
- Model.reopen = function deprecatedReopen() {
5513
- deprecate(`Model.reopen is deprecated. Use Foo extends Model to extend your class instead.`, false, {
5514
- id: 'ember-data:deprecate-model-reopen',
5515
- for: 'ember-data',
5516
- until: '5.0',
5517
- since: {
5518
- available: '4.7',
5519
- enabled: '4.7'
5520
- }
5521
- });
5522
- return originalReopen.call(this, ...arguments);
5523
- };
5524
- Model.reopenClass = function deprecatedReopenClass() {
5525
- deprecate(`Model.reopenClass is deprecated. Use Foo extends Model to add static methods and properties to your class instead.`, false, {
5526
- id: 'ember-data:deprecate-model-reopenclass',
5527
- for: 'ember-data',
5528
- until: '5.0',
5529
- since: {
5530
- available: '4.7',
5531
- enabled: '4.7'
5532
- }
5533
- });
5534
- return originalReopenClass.call(this, ...arguments);
5535
- };
5536
- }
4937
+ Model.reopen = function deprecatedReopen() {
4938
+ assert(`Model.reopen is deprecated. Use Foo extends Model to extend your class instead.`);
4939
+ };
4940
+ Model.reopenClass = function deprecatedReopenClass() {
4941
+ assert(`Model.reopenClass is deprecated. Use Foo extends Model to add static methods and properties to your class instead.`);
4942
+ };
5537
4943
  }
5538
4944
  function normalizeType$1(type) {
5539
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_TYPE)) {
5540
- if (!type) {
5541
- return;
5542
- }
5543
- }
5544
4945
  return dasherize(type);
5545
4946
  }
5546
4947
  /**
@@ -5640,65 +5041,8 @@ function normalizeType$1(type) {
5640
5041
  function belongsTo(modelName, options) {
5641
5042
  let opts = options;
5642
5043
  let userEnteredModelName = modelName;
5643
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_TYPE)) {
5644
- if (typeof modelName !== 'string' || !modelName.length) {
5645
- deprecate('belongsTo() must specify the string type of the related resource as the first parameter', false, {
5646
- id: 'ember-data:deprecate-non-strict-relationships',
5647
- for: 'ember-data',
5648
- until: '5.0',
5649
- since: {
5650
- enabled: '4.7',
5651
- available: '4.7'
5652
- }
5653
- });
5654
- if (typeof modelName === 'object') {
5655
- opts = modelName;
5656
- userEnteredModelName = undefined;
5657
- } else {
5658
- opts = options;
5659
- userEnteredModelName = modelName;
5660
- }
5661
- assert('The first argument to belongsTo must be a string representing a model type key, not an instance of ' + typeof userEnteredModelName + ". E.g., to define a relation to the Person model, use belongsTo('person')", typeof userEnteredModelName === 'string' || typeof userEnteredModelName === 'undefined');
5662
- }
5663
- }
5664
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_ASYNC)) {
5665
- if (!opts || typeof opts.async !== 'boolean') {
5666
- opts = opts || {};
5667
- if (!('async' in opts)) {
5668
- opts.async = true;
5669
- }
5670
- deprecate('belongsTo(<type>, <options>) must specify options.async as either `true` or `false`.', false, {
5671
- id: 'ember-data:deprecate-non-strict-relationships',
5672
- for: 'ember-data',
5673
- until: '5.0',
5674
- since: {
5675
- enabled: '4.7',
5676
- available: '4.7'
5677
- }
5678
- });
5679
- } else {
5680
- assert(`Expected belongsTo options.async to be a boolean`, opts && typeof opts.async === 'boolean');
5681
- }
5682
- } else {
5683
- assert(`Expected belongsTo options.async to be a boolean`, opts && typeof opts.async === 'boolean');
5684
- }
5685
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_INVERSE)) {
5686
- if (opts.inverse !== null && (typeof opts.inverse !== 'string' || opts.inverse.length === 0)) {
5687
- deprecate('belongsTo(<type>, <options>) must specify options.inverse as either `null` or the name of the field on the related resource type.', false, {
5688
- id: 'ember-data:deprecate-non-strict-relationships',
5689
- for: 'ember-data',
5690
- until: '5.0',
5691
- since: {
5692
- enabled: '4.7',
5693
- available: '4.7'
5694
- }
5695
- });
5696
- } else {
5697
- assert(`Expected belongsTo options.inverse to be either null or the string type of the related resource.`, opts.inverse === null || typeof opts.inverse === 'string' && opts.inverse.length > 0);
5698
- }
5699
- } else {
5700
- assert(`Expected belongsTo options.inverse to be either null or the string type of the related resource.`, opts.inverse === null || typeof opts.inverse === 'string' && opts.inverse.length > 0);
5701
- }
5044
+ assert(`Expected belongsTo options.async to be a boolean`, opts && typeof opts.async === 'boolean');
5045
+ assert(`Expected belongsTo options.inverse to be either null or the string type of the related resource.`, opts.inverse === null || typeof opts.inverse === 'string' && opts.inverse.length > 0);
5702
5046
  let meta = {
5703
5047
  type: normalizeType$1(userEnteredModelName),
5704
5048
  isRelationship: true,
@@ -5749,11 +5093,6 @@ function belongsTo(modelName, options) {
5749
5093
  }
5750
5094
  var belongsTo$1 = computedMacroWithOptionalParams(belongsTo);
5751
5095
  function normalizeType(type) {
5752
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_TYPE)) {
5753
- if (!type) {
5754
- return;
5755
- }
5756
- }
5757
5096
  return singularize(dasherize(type));
5758
5097
  }
5759
5098
 
@@ -5899,58 +5238,7 @@ function normalizeType(type) {
5899
5238
  @return {Ember.computed} relationship
5900
5239
  */
5901
5240
  function hasMany(type, options) {
5902
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_TYPE)) {
5903
- if (typeof type !== 'string' || !type.length) {
5904
- deprecate('hasMany(<type>, <options>) must specify the string type of the related resource as the first parameter', false, {
5905
- id: 'ember-data:deprecate-non-strict-relationships',
5906
- for: 'ember-data',
5907
- until: '5.0',
5908
- since: {
5909
- enabled: '4.7',
5910
- available: '4.7'
5911
- }
5912
- });
5913
- if (typeof type === 'object') {
5914
- options = type;
5915
- type = undefined;
5916
- }
5917
- assert(`The first argument to hasMany must be a string representing a model type key, not an instance of ${inspect(type)}. E.g., to define a relation to the Comment model, use hasMany('comment')`, typeof type === 'string' || typeof type === 'undefined');
5918
- }
5919
- }
5920
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_ASYNC)) {
5921
- if (!options || typeof options.async !== 'boolean') {
5922
- options = options || {};
5923
- if (!('async' in options)) {
5924
- options.async = true;
5925
- }
5926
- deprecate('hasMany(<type>, <options>) must specify options.async as either `true` or `false`.', false, {
5927
- id: 'ember-data:deprecate-non-strict-relationships',
5928
- for: 'ember-data',
5929
- until: '5.0',
5930
- since: {
5931
- enabled: '4.7',
5932
- available: '4.7'
5933
- }
5934
- });
5935
- } else {
5936
- assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');
5937
- }
5938
- } else {
5939
- assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');
5940
- }
5941
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_RELATIONSHIPS_WITHOUT_INVERSE)) {
5942
- if (options.inverse !== null && (typeof options.inverse !== 'string' || options.inverse.length === 0)) {
5943
- deprecate('hasMany(<type>, <options>) must specify options.inverse as either `null` or the name of the field on the related resource type.', false, {
5944
- id: 'ember-data:deprecate-non-strict-relationships',
5945
- for: 'ember-data',
5946
- until: '5.0',
5947
- since: {
5948
- enabled: '4.7',
5949
- available: '4.7'
5950
- }
5951
- });
5952
- }
5953
- }
5241
+ assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');
5954
5242
 
5955
5243
  // Metadata about relationships is stored on the meta of
5956
5244
  // the relationship. This is used for introspection and