@ember-data/model 5.5.0-alpha.10 → 5.5.0-alpha.11

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.
@@ -2,18 +2,16 @@ import { deprecate, assert, warn } from '@ember/debug';
2
2
  import { dasherize } from '@ember/string';
3
3
  import { macroCondition, getOwnConfig, importSync } from '@embroider/macros';
4
4
  import EmberObject, { computed, get } from '@ember/object';
5
- import { dependentKeyCompat } from '@ember/object/compat';
6
- import { cached, tracked } from '@glimmer/tracking';
7
- import Ember from 'ember';
8
5
  import { recordIdentifierFor as recordIdentifierFor$1, storeFor as storeFor$1 } from '@ember-data/store';
9
- import { RecordArray, MUTATE, SOURCE, recordIdentifierFor, IDENTIFIER_ARRAY_TAG, notifyArray, isStableIdentifier, storeFor, peekCache, fastPush, coerceId } from '@ember-data/store/-private';
6
+ import { RecordArray, MUTATE, SOURCE, recordIdentifierFor, ARRAY_SIGNAL, notifyArray, isStableIdentifier, storeFor, peekCache, fastPush, coerceId } from '@ember-data/store/-private';
7
+ import { cached, compat } from '@ember-data/tracking';
8
+ import { defineSignal, getSignal, subscribe, peekSignal, addToTransaction } from '@ember-data/tracking/-private';
10
9
  import { A } from '@ember/array';
11
10
  import ArrayProxy from '@ember/array/proxy';
12
11
  import { mapBy, not } from '@ember/object/computed';
13
12
  import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
14
13
  import ObjectProxy from '@ember/object/proxy';
15
14
  import { cacheFor } from '@ember/object/internals';
16
- import { addToTransaction, subscribe } from '@ember-data/tracking/-private';
17
15
  function isElementDescriptor(args) {
18
16
  let [maybeTarget, maybeKey, maybeDesc] = args;
19
17
  return (
@@ -48,15 +46,6 @@ function normalizeModelName(type) {
48
46
  }
49
47
  return type;
50
48
  }
51
- function _initializerDefineProperty(target, property, descriptor, context) {
52
- if (!descriptor) return;
53
- Object.defineProperty(target, property, {
54
- enumerable: descriptor.enumerable,
55
- configurable: descriptor.configurable,
56
- writable: descriptor.writable,
57
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
58
- });
59
- }
60
49
  function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
61
50
  var desc = {};
62
51
  Object.keys(descriptor).forEach(function (key) {
@@ -80,7 +69,16 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con
80
69
  }
81
70
  return desc;
82
71
  }
83
- var _dec$1, _dec2, _dec3, _dec4, _class$6, _descriptor$5, _descriptor2$2;
72
+ function _initializerDefineProperty(target, property, descriptor, context) {
73
+ if (!descriptor) return;
74
+ Object.defineProperty(target, property, {
75
+ enumerable: descriptor.enumerable,
76
+ configurable: descriptor.configurable,
77
+ writable: descriptor.writable,
78
+ value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
79
+ });
80
+ }
81
+ var _dec$1, _dec2, _dec3, _dec4, _class$6, _descriptor, _descriptor2;
84
82
 
85
83
  /**
86
84
  @module @ember-data/model
@@ -183,7 +181,7 @@ let Errors = (_dec$1 = computed(), _dec2 = mapBy('content', 'message'), _dec3 =
183
181
  @public
184
182
  @type {Array}
185
183
  */
186
- _initializerDefineProperty(this, "messages", _descriptor$5, this);
184
+ _initializerDefineProperty(this, "messages", _descriptor, this);
187
185
  /**
188
186
  Total number of errors.
189
187
  @property length
@@ -198,7 +196,7 @@ let Errors = (_dec$1 = computed(), _dec2 = mapBy('content', 'message'), _dec3 =
198
196
  @public
199
197
  @readOnly
200
198
  */
201
- _initializerDefineProperty(this, "isEmpty", _descriptor2$2, this);
199
+ _initializerDefineProperty(this, "isEmpty", _descriptor2, this);
202
200
  }
203
201
  /**
204
202
  @property errorsByAttributeName
@@ -439,12 +437,12 @@ let Errors = (_dec$1 = computed(), _dec2 = mapBy('content', 'message'), _dec3 =
439
437
  has(attribute) {
440
438
  return this.errorsFor(attribute).length > 0;
441
439
  }
442
- }, (_applyDecoratedDescriptor(_class$6.prototype, "errorsByAttributeName", [_dec$1], Object.getOwnPropertyDescriptor(_class$6.prototype, "errorsByAttributeName"), _class$6.prototype), _descriptor$5 = _applyDecoratedDescriptor(_class$6.prototype, "messages", [_dec2], {
440
+ }, (_applyDecoratedDescriptor(_class$6.prototype, "errorsByAttributeName", [_dec$1], Object.getOwnPropertyDescriptor(_class$6.prototype, "errorsByAttributeName"), _class$6.prototype), _descriptor = _applyDecoratedDescriptor(_class$6.prototype, "messages", [_dec2], {
443
441
  configurable: true,
444
442
  enumerable: true,
445
443
  writable: true,
446
444
  initializer: null
447
- }), _applyDecoratedDescriptor(_class$6.prototype, "content", [_dec3], Object.getOwnPropertyDescriptor(_class$6.prototype, "content"), _class$6.prototype), _descriptor2$2 = _applyDecoratedDescriptor(_class$6.prototype, "isEmpty", [_dec4], {
445
+ }), _applyDecoratedDescriptor(_class$6.prototype, "content", [_dec3], Object.getOwnPropertyDescriptor(_class$6.prototype, "content"), _class$6.prototype), _descriptor2 = _applyDecoratedDescriptor(_class$6.prototype, "isEmpty", [_dec4], {
448
446
  configurable: true,
449
447
  enumerable: true,
450
448
  writable: true,
@@ -666,8 +664,8 @@ class RelatedCollection extends RecordArray {
666
664
  }
667
665
  }
668
666
  notify() {
669
- const tag = this[IDENTIFIER_ARRAY_TAG];
670
- tag.shouldReset = true;
667
+ const signal = this[ARRAY_SIGNAL];
668
+ signal.shouldReset = true;
671
669
  // @ts-expect-error
672
670
  notifyArray(this);
673
671
  }
@@ -804,7 +802,7 @@ let PromiseBelongsTo = (_dec = computed(), (_class$5 = class PromiseBelongsTo ex
804
802
  return this;
805
803
  }
806
804
  }, (_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));
807
- var _class$4, _descriptor$4, _descriptor2$1, _descriptor3, _descriptor4, _descriptor5;
805
+ var _class$4;
808
806
  /**
809
807
  @module @ember-data/model
810
808
  */
@@ -826,46 +824,12 @@ var _class$4, _descriptor$4, _descriptor2$1, _descriptor3, _descriptor4, _descri
826
824
  */
827
825
  let PromiseManyArray = (_class$4 = class PromiseManyArray {
828
826
  constructor(promise, content) {
829
- //---- Methods/Properties on ArrayProxy that we will keep as our API
830
- _initializerDefineProperty(this, "content", _descriptor$4, this);
831
- //---- Properties/Methods from the PromiseProxyMixin that we will keep as our API
832
- /**
833
- * Whether the loading promise is still pending
834
- *
835
- * @property {boolean} isPending
836
- * @public
837
- */
838
- _initializerDefineProperty(this, "isPending", _descriptor2$1, this);
839
- /**
840
- * Whether the loading promise rejected
841
- *
842
- * @property {boolean} isRejected
843
- * @public
844
- */
845
- _initializerDefineProperty(this, "isRejected", _descriptor3, this);
846
- /**
847
- * Whether the loading promise succeeded
848
- *
849
- * @property {boolean} isFulfilled
850
- * @public
851
- */
852
- _initializerDefineProperty(this, "isFulfilled", _descriptor4, this);
853
- /**
854
- * Whether the loading promise completed (resolved or rejected)
855
- *
856
- * @property {boolean} isSettled
857
- * @public
858
- */
859
- _initializerDefineProperty(this, "isSettled", _descriptor5, this);
860
827
  this._update(promise, content);
861
828
  this.isDestroyed = false;
862
- if (macroCondition(getOwnConfig().env.DEBUG)) {
863
- const meta = Ember.meta(this);
864
- meta.addMixin = mixin => {
865
- assert(`Do not use A() on an EmberData PromiseManyArray`);
866
- };
867
- }
868
829
  }
830
+
831
+ //---- Methods/Properties on ArrayProxy that we will keep as our API
832
+
869
833
  /**
870
834
  * Retrieve the length of the content
871
835
  * @property length
@@ -880,16 +844,6 @@ let PromiseManyArray = (_class$4 = class PromiseManyArray {
880
844
  return this.content ? this.content.length : 0;
881
845
  }
882
846
 
883
- // ember-source < 3.23 (e.g. 3.20 lts)
884
- // requires that the tag `'[]'` be notified
885
- // on the ArrayProxy in order for `{{#each}}`
886
- // to recompute. We entangle the '[]' tag from
887
- get '[]'() {
888
- if (macroCondition(getOwnConfig().deprecations.DEPRECATE_COMPUTED_CHAINS)) {
889
- return this.content?.length && this.content;
890
- }
891
- }
892
-
893
847
  /**
894
848
  * Iterate the proxied content. Called by the glimmer iterator in #each
895
849
  * We do not guarantee that forEach will always be available. This
@@ -918,6 +872,33 @@ let PromiseManyArray = (_class$4 = class PromiseManyArray {
918
872
  this.content.reload(options);
919
873
  return this;
920
874
  }
875
+
876
+ //---- Properties/Methods from the PromiseProxyMixin that we will keep as our API
877
+
878
+ /**
879
+ * Whether the loading promise is still pending
880
+ *
881
+ * @property {boolean} isPending
882
+ * @public
883
+ */
884
+ /**
885
+ * Whether the loading promise rejected
886
+ *
887
+ * @property {boolean} isRejected
888
+ * @public
889
+ */
890
+ /**
891
+ * Whether the loading promise succeeded
892
+ *
893
+ * @property {boolean} isFulfilled
894
+ * @public
895
+ */
896
+ /**
897
+ * Whether the loading promise completed (resolved or rejected)
898
+ *
899
+ * @property {boolean} isSettled
900
+ * @public
901
+ */
921
902
  /**
922
903
  * chain this promise
923
904
  *
@@ -996,42 +977,33 @@ let PromiseManyArray = (_class$4 = class PromiseManyArray {
996
977
  }) {
997
978
  return new this(promise, content);
998
979
  }
999
- }, (_descriptor$4 = _applyDecoratedDescriptor(_class$4.prototype, "content", [tracked], {
1000
- configurable: true,
1001
- enumerable: true,
1002
- writable: true,
1003
- initializer: function () {
1004
- return null;
1005
- }
1006
- }), _applyDecoratedDescriptor(_class$4.prototype, "length", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class$4.prototype, "length"), _class$4.prototype), _applyDecoratedDescriptor(_class$4.prototype, '[]', [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class$4.prototype, '[]'), _class$4.prototype), _descriptor2$1 = _applyDecoratedDescriptor(_class$4.prototype, "isPending", [tracked], {
1007
- configurable: true,
1008
- enumerable: true,
1009
- writable: true,
1010
- initializer: function () {
1011
- return false;
1012
- }
1013
- }), _descriptor3 = _applyDecoratedDescriptor(_class$4.prototype, "isRejected", [tracked], {
1014
- configurable: true,
1015
- enumerable: true,
1016
- writable: true,
1017
- initializer: function () {
1018
- return false;
1019
- }
1020
- }), _descriptor4 = _applyDecoratedDescriptor(_class$4.prototype, "isFulfilled", [tracked], {
1021
- configurable: true,
1022
- enumerable: true,
1023
- writable: true,
1024
- initializer: function () {
1025
- return false;
1026
- }
1027
- }), _descriptor5 = _applyDecoratedDescriptor(_class$4.prototype, "isSettled", [tracked], {
1028
- configurable: true,
1029
- enumerable: true,
1030
- writable: true,
1031
- initializer: function () {
1032
- return false;
1033
- }
1034
- }), _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);
980
+ }, (_applyDecoratedDescriptor(_class$4.prototype, "length", [compat], Object.getOwnPropertyDescriptor(_class$4.prototype, "length"), _class$4.prototype), _applyDecoratedDescriptor(_class$4.prototype, "links", [compat], Object.getOwnPropertyDescriptor(_class$4.prototype, "links"), _class$4.prototype), _applyDecoratedDescriptor(_class$4.prototype, "meta", [compat], Object.getOwnPropertyDescriptor(_class$4.prototype, "meta"), _class$4.prototype)), _class$4);
981
+ defineSignal(PromiseManyArray.prototype, 'content', null);
982
+ defineSignal(PromiseManyArray.prototype, 'isPending', false);
983
+ defineSignal(PromiseManyArray.prototype, 'isRejected', false);
984
+ defineSignal(PromiseManyArray.prototype, 'isFulfilled', false);
985
+ defineSignal(PromiseManyArray.prototype, 'isSettled', false);
986
+
987
+ // this will error if someone tries to call
988
+ // A(identifierArray) since it is not configurable
989
+ // which is preferrable to the `meta` override we used
990
+ // before which required importing all of Ember
991
+ if (macroCondition(getOwnConfig().deprecations.DEPRECATE_COMPUTED_CHAINS)) {
992
+ const desc = {
993
+ enumerable: true,
994
+ configurable: false,
995
+ get: function () {
996
+ return this.content?.length && this.content;
997
+ }
998
+ };
999
+ compat(desc);
1000
+
1001
+ // ember-source < 3.23 (e.g. 3.20 lts)
1002
+ // requires that the tag `'[]'` be notified
1003
+ // on the ArrayProxy in order for `{{#each}}`
1004
+ // to recompute. We entangle the '[]' tag from content
1005
+ Object.defineProperty(PromiseManyArray.prototype, '[]', desc);
1006
+ }
1035
1007
  function tapPromise(proxy, promise) {
1036
1008
  proxy.isPending = true;
1037
1009
  proxy.isSettled = false;
@@ -1063,7 +1035,7 @@ if (macroCondition(getOwnConfig().env.DEBUG)) {
1063
1035
  }
1064
1036
  };
1065
1037
  }
1066
- var _class$3, _descriptor$3;
1038
+ var _class$3;
1067
1039
  function isResourceIdentiferWithRelatedLinks$1(value) {
1068
1040
  return Boolean(value && value.links && value.links.related);
1069
1041
  }
@@ -1077,9 +1049,9 @@ function isResourceIdentiferWithRelatedLinks$1(value) {
1077
1049
  @public
1078
1050
  */
1079
1051
  let BelongsToReference = (_class$3 = class BelongsToReference {
1052
+ // unsubscribe tokens given to us by the notification manager
1053
+
1080
1054
  constructor(store, graph, parentIdentifier, belongsToRelationship, key) {
1081
- // unsubscribe tokens given to us by the notification manager
1082
- _initializerDefineProperty(this, "_ref", _descriptor$3, this);
1083
1055
  this.graph = graph;
1084
1056
  this.key = key;
1085
1057
  this.belongsToRelationship = belongsToRelationship;
@@ -1528,15 +1500,9 @@ let BelongsToReference = (_class$3 = class BelongsToReference {
1528
1500
  const support = LEGACY_SUPPORT.get(this.___identifier);
1529
1501
  return support.reloadBelongsTo(this.key, options).then(() => this.value());
1530
1502
  }
1531
- }, (_descriptor$3 = _applyDecoratedDescriptor(_class$3.prototype, "_ref", [tracked], {
1532
- configurable: true,
1533
- enumerable: true,
1534
- writable: true,
1535
- initializer: function () {
1536
- return 0;
1537
- }
1538
- }), _applyDecoratedDescriptor(_class$3.prototype, "identifier", [cached, dependentKeyCompat], Object.getOwnPropertyDescriptor(_class$3.prototype, "identifier"), _class$3.prototype)), _class$3);
1539
- var _class$2, _descriptor$2;
1503
+ }, _applyDecoratedDescriptor(_class$3.prototype, "identifier", [cached, compat], Object.getOwnPropertyDescriptor(_class$3.prototype, "identifier"), _class$3.prototype), _class$3);
1504
+ defineSignal(BelongsToReference.prototype, '_ref', 0);
1505
+ var _class$2;
1540
1506
  function isResourceIdentiferWithRelatedLinks(value) {
1541
1507
  return Boolean(value && value.links && value.links.related);
1542
1508
  }
@@ -1554,7 +1520,6 @@ let HasManyReference = (_class$2 = class HasManyReference {
1554
1520
  this.___token = void 0;
1555
1521
  this.___identifier = void 0;
1556
1522
  this.___relatedTokenMap = void 0;
1557
- _initializerDefineProperty(this, "_ref", _descriptor$2, this);
1558
1523
  this.graph = graph;
1559
1524
  this.key = key;
1560
1525
  this.hasManyRelationship = hasManyRelationship;
@@ -2031,14 +1996,8 @@ let HasManyReference = (_class$2 = class HasManyReference {
2031
1996
  const support = LEGACY_SUPPORT.get(this.___identifier);
2032
1997
  return support.reloadHasMany(this.key, options);
2033
1998
  }
2034
- }, (_descriptor$2 = _applyDecoratedDescriptor(_class$2.prototype, "_ref", [tracked], {
2035
- configurable: true,
2036
- enumerable: true,
2037
- writable: true,
2038
- initializer: function () {
2039
- return 0;
2040
- }
2041
- }), _applyDecoratedDescriptor(_class$2.prototype, "identifiers", [cached, dependentKeyCompat], Object.getOwnPropertyDescriptor(_class$2.prototype, "identifiers"), _class$2.prototype)), _class$2);
1999
+ }, _applyDecoratedDescriptor(_class$2.prototype, "identifiers", [cached, compat], Object.getOwnPropertyDescriptor(_class$2.prototype, "identifiers"), _class$2.prototype), _class$2);
2000
+ defineSignal(HasManyReference.prototype, '_ref', 0);
2042
2001
  class LegacySupport {
2043
2002
  constructor(record) {
2044
2003
  this.record = record;
@@ -2523,6 +2482,7 @@ function handleCompletedRelationshipRequest(recordExt, key, relationship, value,
2523
2482
  // for the async reload case there will be no proxy if the ui
2524
2483
  // has never been accessed
2525
2484
  if (proxy && !isHasMany) {
2485
+ // @ts-expect-error unsure why this is not resolving the boolean but async belongsTo is weird
2526
2486
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2527
2487
  if (proxy.content && proxy.content.isDestroying) {
2528
2488
  proxy.set('content', null);
@@ -2629,7 +2589,7 @@ function notifyAttribute(store, identifier, key, record) {
2629
2589
  record.notifyPropertyChange(key);
2630
2590
  }
2631
2591
  }
2632
- var _class$1, _descriptor$1, _class3, _descriptor2;
2592
+ var _class$1;
2633
2593
  const SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;
2634
2594
  const SOURCE_POINTER_PRIMARY_REGEXP = /^\/?data/;
2635
2595
  const PRIMARY_ATTRIBUTE_KEY = 'base';
@@ -2638,69 +2598,10 @@ function isInvalidError(error) {
2638
2598
  }
2639
2599
 
2640
2600
  /**
2641
- * Tag provides a cache for a getter
2642
- * that recomputes only when a specific
2643
- * tracked property that it manages is dirtied.
2644
- *
2645
- * This allows us to bust the cache for a value
2646
- * that otherwise doesn't access anything tracked
2647
- * as well as control the timing of that notification.
2648
- *
2649
- * @internal
2650
- */
2651
- let Tag = (_class$1 = class Tag {
2652
- constructor() {
2653
- _initializerDefineProperty(this, "ref", _descriptor$1, this);
2654
- if (macroCondition(getOwnConfig().env.DEBUG)) {
2655
- const [base, prop] = arguments;
2656
- this._debug_base = base;
2657
- this._debug_prop = prop;
2658
- }
2659
- this.rev = 1;
2660
- this.isDirty = true;
2661
- this.value = undefined;
2662
- /*
2663
- * whether this was part of a transaction when mutated
2664
- */
2665
- this.t = false;
2666
- }
2667
- notify() {
2668
- this.isDirty = true;
2669
- addToTransaction(this);
2670
- this.rev++;
2671
- }
2672
- consume(v) {
2673
- this.isDirty = false;
2674
- this.value = v; // set cached value
2675
- }
2676
- }, _descriptor$1 = _applyDecoratedDescriptor(_class$1.prototype, "ref", [tracked], {
2677
- configurable: true,
2678
- enumerable: true,
2679
- writable: true,
2680
- initializer: function () {
2681
- return null;
2682
- }
2683
- }), _class$1);
2684
- const Tags = new WeakMap();
2685
- function getTag(record, key) {
2686
- let tags = Tags.get(record);
2687
- if (!tags) {
2688
- tags = Object.create(null);
2689
- Tags.set(record, tags);
2690
- }
2691
- // @ts-expect-error
2692
- return tags[key] = tags[key] || (macroCondition(getOwnConfig().env.DEBUG) ? new Tag(record.constructor.modelName, key) : new Tag());
2693
- }
2694
- function peekTag(record, key) {
2695
- let tags = Tags.get(record);
2696
- return tags && tags[key];
2697
- }
2698
-
2699
- /**
2700
- * A decorattor that caches a getter while
2601
+ * A decorator that caches a getter while
2701
2602
  * providing the ability to bust that cache
2702
2603
  * when we so choose in a way that notifies
2703
- * glimmer's tracking system.
2604
+ * tracking systems.
2704
2605
  *
2705
2606
  * @internal
2706
2607
  */
@@ -2708,21 +2609,29 @@ function tagged(_target, key, desc) {
2708
2609
  const getter = desc.get;
2709
2610
  const setter = desc.set;
2710
2611
  desc.get = function () {
2711
- let tag = getTag(this, key);
2712
- subscribe(tag);
2713
- if (tag.isDirty) {
2714
- tag.consume(getter.call(this));
2612
+ const signal = getSignal(this, key, true);
2613
+ subscribe(signal);
2614
+ if (signal.shouldReset) {
2615
+ signal.shouldReset = false;
2616
+ signal.lastValue = getter.call(this);
2715
2617
  }
2716
- return tag.value;
2618
+ return signal.lastValue;
2717
2619
  };
2718
2620
  desc.set = function (v) {
2719
- getTag(this, key); // ensure tag is setup in case we want to use it.
2621
+ getSignal(this, key, true); // ensure signal is setup in case we want to use it.
2720
2622
  // probably notify here but not yet.
2721
2623
  setter.call(this, v);
2722
2624
  };
2723
- dependentKeyCompat(desc);
2625
+ compat(desc);
2724
2626
  return desc;
2725
2627
  }
2628
+ function notifySignal(obj, key) {
2629
+ const signal = peekSignal(obj, key);
2630
+ if (signal) {
2631
+ signal.shouldReset = true;
2632
+ addToTransaction(signal);
2633
+ }
2634
+ }
2726
2635
 
2727
2636
  /**
2728
2637
  Historically EmberData managed a state machine
@@ -2763,9 +2672,8 @@ root
2763
2672
 
2764
2673
  @internal
2765
2674
  */
2766
- let RecordState = (_class3 = class RecordState {
2675
+ let RecordState = (_class$1 = class RecordState {
2767
2676
  constructor(record) {
2768
- _initializerDefineProperty(this, "isSaving", _descriptor2, this);
2769
2677
  const store = storeFor$1(record);
2770
2678
  const identity = recordIdentifierFor(record);
2771
2679
  this.identifier = identity;
@@ -2858,7 +2766,7 @@ let RecordState = (_class3 = class RecordState {
2858
2766
  storeFor$1(this.record).notifications.unsubscribe(this.handler);
2859
2767
  }
2860
2768
  notify(key) {
2861
- getTag(this, key).notify();
2769
+ notifySignal(this, key);
2862
2770
  }
2863
2771
  updateInvalidErrors(errors) {
2864
2772
  assert(`Expected the Cache instance for ${this.identifier.lid} to implement getErrors(identifier)`, typeof this.cache.getErrors === 'function');
@@ -3019,23 +2927,14 @@ let RecordState = (_class3 = class RecordState {
3019
2927
  return '';
3020
2928
  }
3021
2929
  }
3022
- }, (_descriptor2 = _applyDecoratedDescriptor(_class3.prototype, "isSaving", [tracked], {
3023
- configurable: true,
3024
- enumerable: true,
3025
- writable: true,
3026
- initializer: function () {
3027
- return false;
3028
- }
3029
- }), _applyDecoratedDescriptor(_class3.prototype, "isLoading", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isLoading"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isLoaded", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isLoaded"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isSaved", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isSaved"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isEmpty", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isEmpty"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isNew", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isNew"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isDeleted", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isDeleted"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isValid", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isValid"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isDirty", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isDirty"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isError", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "isError"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "adapterError", [tagged], Object.getOwnPropertyDescriptor(_class3.prototype, "adapterError"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "isPreloaded", [cached], Object.getOwnPropertyDescriptor(_class3.prototype, "isPreloaded"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "stateName", [cached], Object.getOwnPropertyDescriptor(_class3.prototype, "stateName"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "dirtyType", [cached], Object.getOwnPropertyDescriptor(_class3.prototype, "dirtyType"), _class3.prototype)), _class3);
2930
+ }, (_applyDecoratedDescriptor(_class$1.prototype, "isLoading", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isLoading"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isLoaded", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isLoaded"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isSaved", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isSaved"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isEmpty", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isEmpty"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isNew", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isNew"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isDeleted", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isDeleted"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isValid", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isValid"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isDirty", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isDirty"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isError", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "isError"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "adapterError", [tagged], Object.getOwnPropertyDescriptor(_class$1.prototype, "adapterError"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "isPreloaded", [cached], Object.getOwnPropertyDescriptor(_class$1.prototype, "isPreloaded"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "stateName", [cached], Object.getOwnPropertyDescriptor(_class$1.prototype, "stateName"), _class$1.prototype), _applyDecoratedDescriptor(_class$1.prototype, "dirtyType", [cached], Object.getOwnPropertyDescriptor(_class$1.prototype, "dirtyType"), _class$1.prototype)), _class$1);
2931
+ defineSignal(RecordState.prototype, 'isSaving', false);
3030
2932
  function notifyErrorsStateChanged(state) {
3031
2933
  state.notify('isValid');
3032
2934
  state.notify('isError');
3033
2935
  state.notify('adapterError');
3034
2936
  }
3035
- var _class, _descriptor, _class2;
3036
- const {
3037
- changeProperties
3038
- } = Ember;
2937
+ var _class, _class2;
3039
2938
  const LEGACY_SUPPORT = new Map();
3040
2939
  function lookupLegacySupport(record) {
3041
2940
  const identifier = recordIdentifierFor$1(record);
@@ -3118,20 +3017,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
3118
3017
  constructor(...args) {
3119
3018
  super(...args);
3120
3019
  this.___private_notifications = void 0;
3121
- /**
3122
- If `true` the store is attempting to reload the record from the adapter.
3123
- Example
3124
- ```javascript
3125
- record.isReloading; // false
3126
- record.reload();
3127
- record.isReloading; // true
3128
- ```
3129
- @property isReloading
3130
- @public
3131
- @type {Boolean}
3132
- @readOnly
3133
- */
3134
- _initializerDefineProperty(this, "isReloading", _descriptor, this);
3135
3020
  }
3136
3021
  init(options = {}) {
3137
3022
  if (macroCondition(getOwnConfig().env.DEBUG)) {
@@ -3396,6 +3281,21 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
3396
3281
  throw new Error(`isError is not directly settable`);
3397
3282
  }
3398
3283
  }
3284
+
3285
+ /**
3286
+ If `true` the store is attempting to reload the record from the adapter.
3287
+ Example
3288
+ ```javascript
3289
+ record.isReloading; // false
3290
+ record.reload();
3291
+ record.isReloading; // true
3292
+ ```
3293
+ @property isReloading
3294
+ @public
3295
+ @type {Boolean}
3296
+ @readOnly
3297
+ */
3298
+
3399
3299
  /**
3400
3300
  All ember models have an id property. This is an identifier
3401
3301
  managed by an external source. These are always coerced to be
@@ -3560,10 +3460,7 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
3560
3460
  super in 4.0+ where sync observers are removed.
3561
3461
  */
3562
3462
  notifyPropertyChange(prop) {
3563
- let tag = peekTag(this, prop);
3564
- if (tag) {
3565
- tag.notify();
3566
- }
3463
+ notifySignal(this, prop);
3567
3464
  super.notifyPropertyChange(prop);
3568
3465
  }
3569
3466
 
@@ -3573,21 +3470,17 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
3573
3470
  method if you want to allow the user to still `rollbackAttributes()`
3574
3471
  after a delete was made.
3575
3472
  Example
3576
- ```app/controllers/model/delete.js
3577
- import Controller from '@ember/controller';
3578
- import { action } from '@ember/object';
3579
- export default class ModelDeleteController extends Controller {
3580
- @action
3581
- softDelete() {
3582
- this.model.deleteRecord();
3473
+ ```js
3474
+ import Component from '@glimmer/component';
3475
+ export default class extends Component {
3476
+ softDelete = () => {
3477
+ this.args.model.deleteRecord();
3583
3478
  }
3584
- @action
3585
- confirm() {
3586
- this.model.save();
3479
+ confirm = () => {
3480
+ this.args.model.save();
3587
3481
  }
3588
- @action
3589
- undo() {
3590
- this.model.rollbackAttributes();
3482
+ undo = () => {
3483
+ this.args.model.rollbackAttributes();
3591
3484
  }
3592
3485
  }
3593
3486
  ```
@@ -3604,13 +3497,11 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
3604
3497
  /**
3605
3498
  Same as `deleteRecord`, but saves the record immediately.
3606
3499
  Example
3607
- ```app/controllers/model/delete.js
3608
- import Controller from '@ember/controller';
3609
- import { action } from '@ember/object';
3610
- export default class ModelDeleteController extends Controller {
3611
- @action
3612
- delete() {
3613
- this.model.destroyRecord().then(function() {
3500
+ ```js
3501
+ import Component from '@glimmer/component';
3502
+ export default class extends Component {
3503
+ delete = () => {
3504
+ this.args.model.destroyRecord().then(function() {
3614
3505
  this.transitionToRoute('model.index');
3615
3506
  });
3616
3507
  }
@@ -3665,23 +3556,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
3665
3556
  storeFor$1(this).unloadRecord(this);
3666
3557
  }
3667
3558
 
3668
- /**
3669
- @method _notifyProperties
3670
- @private
3671
- */
3672
- _notifyProperties(keys) {
3673
- // changeProperties defers notifications until after the delegate
3674
- // and protects with a try...finally block
3675
- // previously used begin...endPropertyChanges but this is private API
3676
- changeProperties(() => {
3677
- let prop;
3678
- for (let i = 0, length = keys.length; i < length; i++) {
3679
- prop = keys[i];
3680
- this.notifyPropertyChange(prop);
3681
- }
3682
- });
3683
- }
3684
-
3685
3559
  /**
3686
3560
  Returns an object, whose keys are changed properties, and value is
3687
3561
  an [oldProp, newProp] array.
@@ -3816,15 +3690,12 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
3816
3690
  Reload the record from the adapter.
3817
3691
  This will only work if the record has already finished loading.
3818
3692
  Example
3819
- ```app/controllers/model/view.js
3820
- import Controller from '@ember/controller';
3821
- import { action } from '@ember/object';
3822
- export default class ViewController extends Controller {
3823
- @action
3824
- reload() {
3825
- this.model.reload().then(function(model) {
3693
+ ```js
3694
+ import Component from '@glimmer/component';
3695
+ export default class extends Component {
3696
+ async reload = () => {
3697
+ await this.args.model.reload();
3826
3698
  // do something with the reloaded model
3827
- });
3828
3699
  }
3829
3700
  }
3830
3701
  ```
@@ -4196,7 +4067,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4196
4067
  This computed property would return a map describing these
4197
4068
  relationships, like this:
4198
4069
  ```javascript
4199
- import { get } from '@ember/object';
4200
4070
  import Blog from 'app/models/blog';
4201
4071
  import User from 'app/models/user';
4202
4072
  import Post from 'app/models/post';
@@ -4246,7 +4116,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4246
4116
  ```
4247
4117
  This property would contain the following:
4248
4118
  ```javascript
4249
- import { get } from '@ember/object';
4250
4119
  import Blog from 'app/models/blog';
4251
4120
  let relationshipNames = Blog.relationshipNames;
4252
4121
  relationshipNames.hasMany;
@@ -4289,15 +4158,14 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4289
4158
  ```
4290
4159
  This property would contain the following:
4291
4160
  ```javascript
4292
- import { get } from '@ember/object';
4293
4161
  import Blog from 'app/models/blog';
4294
4162
  let relatedTypes = Blog.relatedTypes');
4295
4163
  //=> ['user', 'post']
4296
4164
  ```
4297
4165
  @property relatedTypes
4298
- @public
4166
+ @public
4299
4167
  @static
4300
- @type Ember.Array
4168
+ @type Array
4301
4169
  @readOnly
4302
4170
  */
4303
4171
  static get relatedTypes() {
@@ -4334,7 +4202,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4334
4202
  ```
4335
4203
  This property would contain the following:
4336
4204
  ```javascript
4337
- import { get } from '@ember/object';
4338
4205
  import Blog from 'app/models/blog';
4339
4206
  let relationshipsByName = Blog.relationshipsByName;
4340
4207
  relationshipsByName.users;
@@ -4392,7 +4259,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4392
4259
  }
4393
4260
  ```
4394
4261
  ```js
4395
- import { get } from '@ember/object';
4396
4262
  import Blog from 'app/models/blog'
4397
4263
  let fields = Blog.fields;
4398
4264
  fields.forEach(function(kind, field) {
@@ -4493,7 +4359,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4493
4359
  }
4494
4360
  ```
4495
4361
  ```javascript
4496
- import { get } from '@ember/object';
4497
4362
  import Person from 'app/models/person'
4498
4363
  let attributes = Person.attributes
4499
4364
  attributes.forEach(function(meta, name) {
@@ -4541,7 +4406,6 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4541
4406
  }
4542
4407
  ```
4543
4408
  ```javascript
4544
- import { get } from '@ember/object';
4545
4409
  import Person from 'app/models/person';
4546
4410
  let transformedAttributes = Person.transformedAttributes
4547
4411
  transformedAttributes.forEach(function(field, type) {
@@ -4661,14 +4525,10 @@ let Model = (_class = (_class2 = class Model extends EmberObject {
4661
4525
  assert(`Accessing schema information on Models without looking up the model via the store is disallowed.`, this.modelName);
4662
4526
  return `model:${this.modelName}`;
4663
4527
  }
4664
- }, _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], {
4665
- configurable: true,
4666
- enumerable: true,
4667
- writable: true,
4668
- initializer: function () {
4669
- return false;
4670
- }
4671
- }), _applyDecoratedDescriptor(_class.prototype, "id", [tagged], Object.getOwnPropertyDescriptor(_class.prototype, "id"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "currentState", [tagged], Object.getOwnPropertyDescriptor(_class.prototype, "currentState"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "errors", [computeOnce], Object.getOwnPropertyDescriptor(_class.prototype, "errors"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "adapterError", [dependentKeyCompat], Object.getOwnPropertyDescriptor(_class.prototype, "adapterError"), _class.prototype), _applyDecoratedDescriptor(_class, "inverseMap", [computeOnce], Object.getOwnPropertyDescriptor(_class, "inverseMap"), _class), _applyDecoratedDescriptor(_class, "relationships", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationships"), _class), _applyDecoratedDescriptor(_class, "relationshipNames", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationshipNames"), _class), _applyDecoratedDescriptor(_class, "relatedTypes", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relatedTypes"), _class), _applyDecoratedDescriptor(_class, "relationshipsByName", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationshipsByName"), _class), _applyDecoratedDescriptor(_class, "relationshipsObject", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationshipsObject"), _class), _applyDecoratedDescriptor(_class, "fields", [computeOnce], Object.getOwnPropertyDescriptor(_class, "fields"), _class), _applyDecoratedDescriptor(_class, "attributes", [computeOnce], Object.getOwnPropertyDescriptor(_class, "attributes"), _class), _applyDecoratedDescriptor(_class, "transformedAttributes", [computeOnce], Object.getOwnPropertyDescriptor(_class, "transformedAttributes"), _class)), _class); // this is required to prevent `init` from passing
4528
+ }, _class2.isModel = true, _class2.modelName = null, _class2), (_applyDecoratedDescriptor(_class.prototype, "isEmpty", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isEmpty"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isLoading", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isLoading"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isLoaded", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isLoaded"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "hasDirtyAttributes", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "hasDirtyAttributes"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isSaving", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isSaving"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isDeleted", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isDeleted"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isNew", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isNew"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isValid", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isValid"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "dirtyType", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "dirtyType"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "isError", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "isError"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "id", [tagged], Object.getOwnPropertyDescriptor(_class.prototype, "id"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "currentState", [tagged], Object.getOwnPropertyDescriptor(_class.prototype, "currentState"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "errors", [computeOnce], Object.getOwnPropertyDescriptor(_class.prototype, "errors"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "adapterError", [compat], Object.getOwnPropertyDescriptor(_class.prototype, "adapterError"), _class.prototype), _applyDecoratedDescriptor(_class, "inverseMap", [computeOnce], Object.getOwnPropertyDescriptor(_class, "inverseMap"), _class), _applyDecoratedDescriptor(_class, "relationships", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationships"), _class), _applyDecoratedDescriptor(_class, "relationshipNames", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationshipNames"), _class), _applyDecoratedDescriptor(_class, "relatedTypes", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relatedTypes"), _class), _applyDecoratedDescriptor(_class, "relationshipsByName", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationshipsByName"), _class), _applyDecoratedDescriptor(_class, "relationshipsObject", [computeOnce], Object.getOwnPropertyDescriptor(_class, "relationshipsObject"), _class), _applyDecoratedDescriptor(_class, "fields", [computeOnce], Object.getOwnPropertyDescriptor(_class, "fields"), _class), _applyDecoratedDescriptor(_class, "attributes", [computeOnce], Object.getOwnPropertyDescriptor(_class, "attributes"), _class), _applyDecoratedDescriptor(_class, "transformedAttributes", [computeOnce], Object.getOwnPropertyDescriptor(_class, "transformedAttributes"), _class)), _class);
4529
+ defineSignal(Model.prototype, 'isReloading', false);
4530
+
4531
+ // this is required to prevent `init` from passing
4672
4532
  // the values initialized during create to `setUnknownProperty`
4673
4533
  Model.prototype._createProps = null;
4674
4534
  Model.prototype._secretInit = null;