@warp-drive/legacy 5.9.0-alpha.2 → 5.9.0-alpha.21

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.
Files changed (162) hide show
  1. package/README.md +6 -0
  2. package/declarations/adapter/-private/build-url-mixin.d.ts +156 -0
  3. package/declarations/adapter/error.d.ts +385 -169
  4. package/declarations/adapter/json-api.d.ts +12 -1
  5. package/declarations/adapter/rest.d.ts +74 -0
  6. package/declarations/adapter.d.ts +6 -0
  7. package/declarations/compat/builders/find-all.d.ts +0 -1
  8. package/declarations/compat/extensions.d.ts +40 -0
  9. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +7 -0
  10. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +4 -0
  11. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +7 -0
  12. package/declarations/compat/utils.d.ts +11 -0
  13. package/declarations/compat.d.ts +32 -0
  14. package/declarations/index.d.ts +142 -0
  15. package/declarations/model/-private/attr.d.ts +21 -0
  16. package/declarations/model/-private/belongs-to.d.ts +21 -0
  17. package/declarations/model/-private/hooks.d.ts +26 -0
  18. package/declarations/model/-private/model.d.ts +55 -4
  19. package/declarations/model/-private/promise-many-array.d.ts +25 -1
  20. package/declarations/model/-private/schema-provider.d.ts +11 -1
  21. package/declarations/model/migration-support.d.ts +31 -5
  22. package/declarations/model-fragments/extensions/fragment-array.d.ts +38 -0
  23. package/declarations/model-fragments/extensions/fragment.d.ts +35 -0
  24. package/declarations/model-fragments/hooks/model-for.d.ts +7 -0
  25. package/declarations/model-fragments/index.d.ts +8 -0
  26. package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +6 -0
  27. package/declarations/model-fragments/utilities/with-array-defaults.d.ts +30 -0
  28. package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +18 -0
  29. package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +15 -0
  30. package/declarations/model-fragments/utilities/with-legacy.d.ts +8 -0
  31. package/declarations/serializer/-private/transforms/boolean.d.ts +13 -0
  32. package/declarations/serializer/-private/transforms/date.d.ts +15 -1
  33. package/declarations/serializer/-private/transforms/number.d.ts +14 -1
  34. package/declarations/serializer/-private/transforms/string.d.ts +14 -1
  35. package/declarations/serializer/-private/utils.d.ts +24 -0
  36. package/declarations/serializer/json-api.d.ts +1 -1
  37. package/declarations/serializer.d.ts +4 -6
  38. package/declarations/store/-private.d.ts +2 -2
  39. package/declarations/store.d.ts +7 -0
  40. package/dist/adapter/error.js +386 -241
  41. package/dist/adapter/json-api.js +12 -0
  42. package/dist/adapter/rest.js +39 -3
  43. package/dist/adapter.js +23 -26
  44. package/dist/compat/builders.js +0 -1
  45. package/dist/compat/extensions.js +80 -3
  46. package/dist/compat/utils.js +14 -0
  47. package/dist/compat.js +17 -0
  48. package/dist/{errors-Cz5KrzBk.js → errors-DZKA206g.js} +24 -1
  49. package/dist/{hooks-D6diaM34.js → hooks-BvOqJBei.js} +33 -2
  50. package/dist/index.js +168 -13
  51. package/dist/{json-ChdEfB0X.js → json-DU8m1pGf.js} +83 -6
  52. package/dist/model/-private.js +1 -1
  53. package/dist/model/migration-support.js +15 -2
  54. package/dist/{unpkg/dev-deprecated/model-for-CqXsIKws.js → model-for-CXkJw59V.js} +77 -1
  55. package/dist/model-fragments.js +18 -2
  56. package/dist/model.js +12 -8
  57. package/dist/{schema-provider-DJCV_6AF.js → schema-provider-DtPOp0d7.js} +93 -6
  58. package/dist/serializer/json-api.js +8 -3
  59. package/dist/serializer/json.js +1 -1
  60. package/dist/serializer/rest.js +3 -4
  61. package/dist/serializer/transform.js +51 -3
  62. package/dist/serializer.js +4 -7
  63. package/dist/store.js +13 -7
  64. package/dist/unpkg/dev/adapter/error.js +386 -241
  65. package/dist/unpkg/dev/adapter/json-api.js +13 -1
  66. package/dist/unpkg/dev/adapter/rest.js +39 -3
  67. package/dist/unpkg/dev/adapter.js +23 -26
  68. package/dist/unpkg/dev/compat/builders.js +0 -1
  69. package/dist/unpkg/dev/compat/extensions.js +80 -3
  70. package/dist/unpkg/dev/compat/utils.js +14 -0
  71. package/dist/unpkg/dev/compat.js +34 -1
  72. package/dist/unpkg/dev/{errors-DmGGJr3T.js → errors-DngRU-If.js} +24 -1
  73. package/dist/unpkg/dev/{hooks-CkYiE6Ud.js → hooks-UuiLxWxS.js} +33 -2
  74. package/dist/unpkg/dev/index.js +171 -13
  75. package/dist/unpkg/dev/json-K2Y9z6MN.js +1333 -0
  76. package/dist/unpkg/dev/model/-private.js +1 -1
  77. package/dist/unpkg/dev/model/migration-support.js +16 -2
  78. package/dist/unpkg/{prod-deprecated/model-for-CqXsIKws.js → dev/model-for-CXkJw59V.js} +77 -1
  79. package/dist/unpkg/dev/model-fragments.js +18 -2
  80. package/dist/unpkg/dev/model.js +12 -8
  81. package/dist/unpkg/dev/{schema-provider-DDVYxmUV.js → schema-provider-0D7f-QOn.js} +92 -6
  82. package/dist/unpkg/dev/serializer/json-api.js +9 -4
  83. package/dist/unpkg/dev/serializer/json.js +1 -1
  84. package/dist/unpkg/dev/serializer/rest.js +3 -4
  85. package/dist/unpkg/dev/serializer/transform.js +51 -3
  86. package/dist/unpkg/dev/serializer.js +4 -7
  87. package/dist/unpkg/dev/store.js +21 -7
  88. package/dist/unpkg/dev-deprecated/adapter/error.js +386 -241
  89. package/dist/unpkg/dev-deprecated/adapter/json-api.js +13 -1
  90. package/dist/unpkg/dev-deprecated/adapter/rest.js +39 -3
  91. package/dist/unpkg/dev-deprecated/adapter.js +23 -26
  92. package/dist/unpkg/dev-deprecated/compat/builders.js +0 -1
  93. package/dist/unpkg/dev-deprecated/compat/extensions.js +80 -3
  94. package/dist/unpkg/dev-deprecated/compat/utils.js +14 -0
  95. package/dist/unpkg/dev-deprecated/compat.js +34 -1
  96. package/dist/unpkg/dev-deprecated/{errors-Spt6ubMd.js → errors-Bzidntpi.js} +24 -1
  97. package/dist/unpkg/dev-deprecated/{hooks-DOXegvhL.js → hooks-DVXhMW14.js} +33 -2
  98. package/dist/unpkg/dev-deprecated/index.js +171 -13
  99. package/dist/unpkg/{prod-deprecated/json-BWrZ5546.js → dev-deprecated/json-K2Y9z6MN.js} +96 -6
  100. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  101. package/dist/unpkg/dev-deprecated/model/migration-support.js +16 -2
  102. package/dist/unpkg/{dev/model-for-CqXsIKws.js → dev-deprecated/model-for-CXkJw59V.js} +77 -1
  103. package/dist/unpkg/dev-deprecated/model-fragments.js +18 -2
  104. package/dist/unpkg/dev-deprecated/model.js +12 -8
  105. package/dist/unpkg/dev-deprecated/{schema-provider-BP6_8N-V.js → schema-provider-ZwO5_fZw.js} +84 -3
  106. package/dist/unpkg/dev-deprecated/serializer/json-api.js +9 -4
  107. package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
  108. package/dist/unpkg/dev-deprecated/serializer/rest.js +3 -4
  109. package/dist/unpkg/dev-deprecated/serializer/transform.js +51 -3
  110. package/dist/unpkg/dev-deprecated/serializer.js +4 -7
  111. package/dist/unpkg/dev-deprecated/store.js +21 -7
  112. package/dist/unpkg/prod/adapter/error.js +386 -241
  113. package/dist/unpkg/prod/adapter/json-api.js +13 -1
  114. package/dist/unpkg/prod/adapter/rest.js +39 -3
  115. package/dist/unpkg/prod/adapter.js +23 -26
  116. package/dist/unpkg/prod/compat/builders.js +0 -1
  117. package/dist/unpkg/prod/compat/extensions.js +70 -3
  118. package/dist/unpkg/prod/compat/utils.js +14 -0
  119. package/dist/unpkg/prod/compat.js +17 -0
  120. package/dist/unpkg/prod/{errors-BGVFCBmi.js → errors-B-PWeYlW.js} +24 -1
  121. package/dist/unpkg/prod/{hooks-BztVA_x0.js → hooks-Bx-zBziU.js} +32 -1
  122. package/dist/unpkg/prod/index.js +171 -5
  123. package/dist/unpkg/{dev/json-Cu1LNgmQ.js → prod/json-Qewu-UN9.js} +63 -19
  124. package/dist/unpkg/prod/model/-private.js +1 -1
  125. package/dist/unpkg/prod/model/migration-support.js +16 -2
  126. package/dist/unpkg/prod/model-for-CXkJw59V.js +297 -0
  127. package/dist/unpkg/prod/model-fragments.js +18 -2
  128. package/dist/unpkg/prod/model.js +12 -8
  129. package/dist/unpkg/prod/{schema-provider-DJtD_8jZ.js → schema-provider-BgRqk8i9.js} +96 -6
  130. package/dist/unpkg/prod/serializer/json-api.js +9 -4
  131. package/dist/unpkg/prod/serializer/json.js +1 -1
  132. package/dist/unpkg/prod/serializer/rest.js +3 -4
  133. package/dist/unpkg/prod/serializer/transform.js +51 -3
  134. package/dist/unpkg/prod/serializer.js +4 -7
  135. package/dist/unpkg/prod/store.js +21 -7
  136. package/dist/unpkg/prod-deprecated/adapter/error.js +386 -241
  137. package/dist/unpkg/prod-deprecated/adapter/json-api.js +13 -1
  138. package/dist/unpkg/prod-deprecated/adapter/rest.js +39 -3
  139. package/dist/unpkg/prod-deprecated/adapter.js +23 -26
  140. package/dist/unpkg/prod-deprecated/compat/builders.js +0 -1
  141. package/dist/unpkg/prod-deprecated/compat/extensions.js +70 -3
  142. package/dist/unpkg/prod-deprecated/compat/utils.js +14 -0
  143. package/dist/unpkg/prod-deprecated/compat.js +17 -0
  144. package/dist/unpkg/prod-deprecated/{errors-CdDaK81x.js → errors-Dl2J9d1D.js} +24 -1
  145. package/dist/unpkg/prod-deprecated/{hooks-yId87yyG.js → hooks-Cm60wWTf.js} +32 -1
  146. package/dist/unpkg/prod-deprecated/index.js +171 -5
  147. package/dist/unpkg/{dev-deprecated/json-Cu1LNgmQ.js → prod-deprecated/json-Qewu-UN9.js} +63 -19
  148. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  149. package/dist/unpkg/prod-deprecated/model/migration-support.js +16 -2
  150. package/dist/{model-for-CqXsIKws.js → unpkg/prod-deprecated/model-for-CXkJw59V.js} +77 -1
  151. package/dist/unpkg/prod-deprecated/model-fragments.js +18 -2
  152. package/dist/unpkg/prod-deprecated/model.js +12 -8
  153. package/dist/unpkg/prod-deprecated/{schema-provider-CjX55uSY.js → schema-provider-Dh6tRqVI.js} +79 -3
  154. package/dist/unpkg/prod-deprecated/serializer/json-api.js +9 -4
  155. package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
  156. package/dist/unpkg/prod-deprecated/serializer/rest.js +3 -4
  157. package/dist/unpkg/prod-deprecated/serializer/transform.js +51 -3
  158. package/dist/unpkg/prod-deprecated/serializer.js +4 -7
  159. package/dist/unpkg/prod-deprecated/store.js +21 -7
  160. package/package.json +8 -8
  161. package/dist/unpkg/prod/json-BWrZ5546.js +0 -1243
  162. package/dist/unpkg/prod/model-for-CqXsIKws.js +0 -221
@@ -4,7 +4,7 @@ import { recordIdentifierFor, storeFor } from '@warp-drive/core';
4
4
  import { notifyInternalSignal, peekInternalSignal, withSignalStore, gate, memoized, defineSignal, entangleSignal, defineGate } from '@warp-drive/core/signals/-leaked';
5
5
  import { assertPrivateStore, recordIdentifierFor as recordIdentifierFor$1, coerceId } from '@warp-drive/core/store/-private';
6
6
  import { RecordStore } from '@warp-drive/core/types/symbols';
7
- import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-BGVFCBmi.js";
7
+ import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-B-PWeYlW.js";
8
8
  import { u as upgradeStore, F as FetchManager } from "./-private-BdyZaGEh.js";
9
9
  import { cacheFor } from '@ember/object/internals';
10
10
  import { Context } from '@warp-drive/core/reactive/-private';
@@ -40,7 +40,12 @@ function belongsTo(prop) {
40
40
  function hasMany(prop) {
41
41
  return lookupLegacySupport(this).referenceFor('hasMany', prop);
42
42
  }
43
- function reload(options = {}) {}
43
+ function reload(options = {}) {
44
+ {
45
+ const message = `You cannot use reload() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;
46
+ return Promise.reject(new Error(message));
47
+ }
48
+ }
44
49
  function _reload(options = {}) {
45
50
  options.isReloading = true;
46
51
  options.reload = true;
@@ -73,7 +78,12 @@ function deleteRecord() {
73
78
  this[RecordStore].deleteRecord(this);
74
79
  }
75
80
  }
76
- function save(options) {}
81
+ function save(options) {
82
+ {
83
+ const message = `You cannot use save() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;
84
+ return Promise.reject(new Error(message));
85
+ }
86
+ }
77
87
  function _save(options) {
78
88
  let promise;
79
89
  if (this.currentState.isNew && this.currentState.isDeleted) {
@@ -84,7 +94,12 @@ function _save(options) {
84
94
  }
85
95
  return promise;
86
96
  }
87
- function destroyRecord(options) {}
97
+ function destroyRecord(options) {
98
+ {
99
+ const message = `You cannot use destroyRecord() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`;
100
+ return Promise.reject(new Error(message));
101
+ }
102
+ }
88
103
  function _destroyRecord(options) {
89
104
  const {
90
105
  isNew
@@ -854,6 +869,9 @@ class Model extends EmberObject {
854
869
  get isError() {
855
870
  return this.currentState.isError;
856
871
  }
872
+ /**
873
+ * `isError` is read-only and cannot be set directly.
874
+ */
857
875
  static {
858
876
  decorateMethodV2(this.prototype, "isError", [memoized]);
859
877
  }
@@ -891,6 +909,10 @@ class Model extends EmberObject {
891
909
 
892
910
  return recordIdentifierFor(this).id;
893
911
  }
912
+ /**
913
+ * Assigns the resource's primary key. Typically only used internally
914
+ * when a client-created record is assigned an id upon being saved.
915
+ */
894
916
  static {
895
917
  decorateMethodV2(this.prototype, "id", [gate]);
896
918
  }
@@ -925,6 +947,9 @@ class Model extends EmberObject {
925
947
  }
926
948
  return this.___recordState;
927
949
  }
950
+ /**
951
+ * `currentState` is read-only and cannot be set directly.
952
+ */
928
953
  static {
929
954
  decorateMethodV2(this.prototype, "currentState", [gate]);
930
955
  }
@@ -998,6 +1023,9 @@ class Model extends EmberObject {
998
1023
  get adapterError() {
999
1024
  return this.currentState.adapterError;
1000
1025
  }
1026
+ /**
1027
+ * `adapterError` is read-only and cannot be set directly.
1028
+ */
1001
1029
  static {
1002
1030
  decorateMethodV2(this.prototype, "adapterError", [memoized]);
1003
1031
  }
@@ -1065,12 +1093,29 @@ class Model extends EmberObject {
1065
1093
  eachRelationship(callback, binding) {
1066
1094
  this.constructor.eachRelationship(callback, binding);
1067
1095
  }
1096
+
1097
+ /**
1098
+ * Returns the relationship schema for the given relationship name, if any.
1099
+ */
1068
1100
  relationshipFor(name) {
1069
1101
  return this.constructor.relationshipsByName.get(name);
1070
1102
  }
1103
+
1104
+ /**
1105
+ * Returns the inverse relationship schema for the given relationship
1106
+ * name, if one exists. See {@link Model.inverseFor | the static inverseFor}.
1107
+ */
1071
1108
  inverseFor(name) {
1072
1109
  return this.constructor.inverseFor(name, storeFor(this, false));
1073
1110
  }
1111
+
1112
+ /**
1113
+ * Iterates over the attributes defined on this record's class, calling
1114
+ * `callback` for each one. See {@link Model.eachAttribute | the static eachAttribute}.
1115
+ *
1116
+ * @param callback the callback to invoke
1117
+ * @param binding the value to which the callback's `this` should be bound
1118
+ */
1074
1119
  eachAttribute(callback, binding) {
1075
1120
  this.constructor.eachAttribute(callback, binding);
1076
1121
  }
@@ -1137,6 +1182,11 @@ class Model extends EmberObject {
1137
1182
  const relationship = this.relationshipsByName.get(name);
1138
1183
  return relationship && store.modelFor(relationship.type);
1139
1184
  }
1185
+
1186
+ /**
1187
+ * A cache of resolved inverse relationships by name, populated lazily by
1188
+ * {@link Model.inverseFor | inverseFor}.
1189
+ */
1140
1190
  static get inverseMap() {
1141
1191
  return Object.create(null);
1142
1192
  }
@@ -1179,6 +1229,9 @@ class Model extends EmberObject {
1179
1229
  }
1180
1230
  }
1181
1231
 
1232
+ /**
1233
+ * @private
1234
+ */
1182
1235
  //Calculate the inverse, ignoring the cache
1183
1236
  static _findInverseFor(name, store) {
1184
1237
  const relationship = this.relationshipsByName.get(name);
@@ -1364,6 +1417,12 @@ class Model extends EmberObject {
1364
1417
  }
1365
1418
  return map;
1366
1419
  }
1420
+
1421
+ /**
1422
+ * A hash of the model's relationship schemas keyed by relationship name.
1423
+ * See also {@link Model.relationshipsByName | relationshipsByName}, which
1424
+ * provides the same information as a `Map`.
1425
+ */
1367
1426
  static {
1368
1427
  decorateMethodV2(this, "relationshipsByName", [computeOnce]);
1369
1428
  }
@@ -1674,6 +1733,13 @@ defineGate(Model.prototype, 'isReloading', {
1674
1733
  // @ts-expect-error specially handled prop
1675
1734
  isLocal: true
1676
1735
  });
1736
+
1737
+ /**
1738
+ * Restores the pre-`RequestManager` implementations of `save`,
1739
+ * `destroyRecord`, and `reload` onto the given `Model` subclass, for
1740
+ * apps that have not yet migrated off of the deprecated
1741
+ * `ENABLE_LEGACY_REQUEST_METHODS` behaviors.
1742
+ */
1677
1743
  function restoreDeprecatedModelRequestBehaviors(ModelKlass) {
1678
1744
  // @ts-expect-error TS doesn't know how to do `this` function overloads
1679
1745
  ModelKlass.prototype.save = _save;
@@ -1771,7 +1837,11 @@ class ModelSchemaProvider {
1771
1837
  registerHashFn(hashFn) {}
1772
1838
  /** @internal */
1773
1839
  _loadModelSchema(type) {
1774
- const modelClass = this.store.modelFor(type);
1840
+ const factory = getModelFactory(this.store, type);
1841
+ if (!factory) {
1842
+ throw new Error(`No model was found for '${type}'`);
1843
+ }
1844
+ const modelClass = factory.class;
1775
1845
  const attributeMap = modelClass.attributes;
1776
1846
  const attributes = Object.create(null);
1777
1847
  attributeMap.forEach((meta, name) => attributes[name] = meta);
@@ -1792,11 +1862,17 @@ class ModelSchemaProvider {
1792
1862
  type,
1793
1863
  fields: Array.from(fields.values())
1794
1864
  };
1865
+ const cacheFields = new Map();
1866
+ for (const field of fields.values()) {
1867
+ const cacheKey = field.sourceKey ?? field.name;
1868
+ cacheFields.set(cacheKey, field);
1869
+ }
1795
1870
  const internalSchema = {
1796
1871
  schema,
1797
1872
  attributes,
1798
1873
  relationships,
1799
- fields
1874
+ fields,
1875
+ cacheFields
1800
1876
  };
1801
1877
  this._schemas.set(type, internalSchema);
1802
1878
  return internalSchema;
@@ -1808,6 +1884,13 @@ class ModelSchemaProvider {
1808
1884
  }
1809
1885
  return this._schemas.get(type).fields;
1810
1886
  }
1887
+ cacheFields(resource) {
1888
+ const type = normalizeModelName(resource.type);
1889
+ if (!this._schemas.has(type)) {
1890
+ this._loadModelSchema(type);
1891
+ }
1892
+ return this._schemas.get(type).cacheFields;
1893
+ }
1811
1894
  hasResource(resource) {
1812
1895
  const type = normalizeModelName(resource.type);
1813
1896
  if (this._schemas.has(type)) {
@@ -1825,6 +1908,13 @@ class ModelSchemaProvider {
1825
1908
  return true;
1826
1909
  }
1827
1910
  }
1911
+ /**
1912
+ * The `createSchemaService` implementation for use with `Model`. Pass
1913
+ * the result of this to your store's `createSchemaService` method when
1914
+ * configuring the store to use `Model` for schema information.
1915
+ *
1916
+ * @public
1917
+ */
1828
1918
  function buildSchema(store) {
1829
1919
  return new ModelSchemaProvider(store);
1830
1920
  }
@@ -1,5 +1,5 @@
1
1
  import { dasherize, pluralize, singularize } from '@warp-drive/utilities/string';
2
- import { J as JSONSerializer } from "../json-BWrZ5546.js";
2
+ import { J as JSONSerializer } from "../json-Qewu-UN9.js";
3
3
 
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-return */
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
@@ -102,7 +102,7 @@ import { J as JSONSerializer } from "../json-BWrZ5546.js";
102
102
  `extractRelationship`.
103
103
 
104
104
  ```js [app/serializers/application.js]
105
- import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
105
+ import { JSONAPISerializer } from '@warp-drive/legacy/serializer/json-api';
106
106
 
107
107
  export default class ApplicationSerializer extends JSONAPISerializer {
108
108
  normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {
@@ -136,10 +136,15 @@ const JSONAPISerializer = JSONSerializer.extend({
136
136
  */
137
137
  _normalizeDocumentHelper(documentHash) {
138
138
  if (Array.isArray(documentHash.data)) {
139
- const ret = new Array(documentHash.data.length);
139
+ const ret = [];
140
140
  for (let i = 0; i < documentHash.data.length; i++) {
141
141
  const data = documentHash.data[i];
142
- ret[i] = this._normalizeResourceHelper(data);
142
+ const normalized = this._normalizeResourceHelper(data);
143
+ if (normalized !== null) {
144
+ // @ts-expect-error untyped
145
+ // can be null when unknown type is encountered
146
+ ret.push(normalized);
147
+ }
143
148
  }
144
149
  documentHash.data = ret;
145
150
  } else if (documentHash.data && typeof documentHash.data === 'object') {
@@ -1,4 +1,4 @@
1
1
  import '@ember/application';
2
2
  import '@warp-drive/utilities/string';
3
3
  import '../serializer.js';
4
- export { J as JSONSerializer } from "../json-BWrZ5546.js";
4
+ export { J as JSONSerializer } from "../json-Qewu-UN9.js";
@@ -1,5 +1,5 @@
1
1
  import { camelize, dasherize, singularize } from '@warp-drive/utilities/string';
2
- import { J as JSONSerializer, c as coerceId } from "../json-BWrZ5546.js";
2
+ import { i as inverseForRelationship, J as JSONSerializer, c as coerceId } from "../json-Qewu-UN9.js";
3
3
  import Mixin from '@ember/object/mixin';
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
@@ -417,8 +417,7 @@ const EmbeddedRecordsMixin = Mixin.create({
417
417
  */
418
418
  removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json) {
419
419
  if (relationship.kind === 'belongsTo') {
420
- const schema = this.store.modelFor(snapshot.modelName);
421
- const parentRecord = schema.inverseFor(relationship.name, this.store);
420
+ const parentRecord = inverseForRelationship(this.store, snapshot.modelName, relationship.name);
422
421
  if (parentRecord) {
423
422
  const name = parentRecord.name;
424
423
  const embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);
@@ -999,7 +998,7 @@ const RESTSerializer = JSONSerializer.extend({
999
998
  `serialize` takes an options hash with a single option:
1000
999
  `includeId`. If this option is `true`, `serialize` will,
1001
1000
  by default include the ID in the JSON object it builds.
1002
- The adapter passes in `includeId: true` when serializing
1001
+ The RESTAdapter passes in `includeId: true` when serializing
1003
1002
  a record for `createRecord`, but not for `updateRecord`.
1004
1003
  ## Customization
1005
1004
  Your server may expect a different JSON format than the
@@ -116,6 +116,10 @@ const Transform = EmberObject;
116
116
  @public
117
117
  */
118
118
  class BooleanTransform {
119
+ /**
120
+ * Converts a serialized (raw payload) value into a `boolean` (or `null`
121
+ * when `allowNull` is set and the value is nullish).
122
+ */
119
123
  deserialize(serialized, options) {
120
124
  if ((serialized === null || serialized === undefined) && options?.allowNull === true) {
121
125
  return null;
@@ -130,12 +134,20 @@ class BooleanTransform {
130
134
  return false;
131
135
  }
132
136
  }
137
+
138
+ /**
139
+ * Converts a `boolean` attribute value into its serialized (raw payload) form.
140
+ */
133
141
  serialize(deserialized, options) {
134
142
  if ((deserialized === null || deserialized === undefined) && options?.allowNull === true) {
135
143
  return null;
136
144
  }
137
145
  return Boolean(deserialized);
138
146
  }
147
+
148
+ /**
149
+ * Creates a new instance of this transform.
150
+ */
139
151
  static create() {
140
152
  return new this();
141
153
  }
@@ -151,7 +163,7 @@ class BooleanTransform {
151
163
  standard.
152
164
 
153
165
  ```js [app/models/score.js]
154
- import Model, { attr, belongsTo } from '@ember-data/model';
166
+ import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
155
167
 
156
168
  export default class ScoreModel extends Model {
157
169
  @attr('number') value;
@@ -164,6 +176,10 @@ class BooleanTransform {
164
176
  */
165
177
 
166
178
  class DateTransform {
179
+ /**
180
+ * Converts a serialized (raw payload) `ISO 8601` string, epoch number,
181
+ * or nullish value into a `Date` (or `null`/`undefined`).
182
+ */
167
183
  deserialize(serialized, _options) {
168
184
  if (typeof serialized === 'string') {
169
185
  let offset = serialized.indexOf('+');
@@ -182,6 +198,11 @@ class DateTransform {
182
198
  return null;
183
199
  }
184
200
  }
201
+
202
+ /**
203
+ * Converts a `Date` attribute value into an `ISO 8601` string, or `null`
204
+ * if the value is not a valid `Date`.
205
+ */
185
206
  serialize(date, _options) {
186
207
  // @ts-expect-error isNaN accepts date as it is coercible
187
208
  if (date instanceof Date && !isNaN(date)) {
@@ -190,6 +211,10 @@ class DateTransform {
190
211
  return null;
191
212
  }
192
213
  }
214
+
215
+ /**
216
+ * Creates a new instance of this transform.
217
+ */
193
218
  static create() {
194
219
  return new this();
195
220
  }
@@ -209,7 +234,7 @@ function isNumber(value) {
209
234
  Usage
210
235
 
211
236
  ```js [app/models/score.js]
212
- import Model, { attr, belongsTo } from '@ember-data/model';
237
+ import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
213
238
 
214
239
  export default class ScoreModel extends Model {
215
240
  @attr('number') value;
@@ -221,6 +246,10 @@ function isNumber(value) {
221
246
  @public
222
247
  */
223
248
  class NumberTransform {
249
+ /**
250
+ * Converts a serialized (raw payload) value into a `number`, or `null`
251
+ * if the value is empty, nullish, or not a valid number.
252
+ */
224
253
  deserialize(serialized, _options) {
225
254
  if (serialized === '' || serialized === null || serialized === undefined) {
226
255
  return null;
@@ -229,6 +258,10 @@ class NumberTransform {
229
258
  return isNumber(transformed) ? transformed : null;
230
259
  }
231
260
  }
261
+
262
+ /**
263
+ * Converts a `number` attribute value into its serialized (raw payload) form.
264
+ */
232
265
  serialize(deserialized, _options) {
233
266
  if (deserialized === '' || deserialized === null || deserialized === undefined) {
234
267
  return null;
@@ -237,6 +270,10 @@ class NumberTransform {
237
270
  return isNumber(transformed) ? transformed : null;
238
271
  }
239
272
  }
273
+
274
+ /**
275
+ * Creates a new instance of this transform.
276
+ */
240
277
  static create() {
241
278
  return new this();
242
279
  }
@@ -253,7 +290,7 @@ class NumberTransform {
253
290
  Usage
254
291
 
255
292
  ```js [app/models/user.js]
256
- import Model, { attr, belongsTo } from '@ember-data/model';
293
+ import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
257
294
 
258
295
  export default class UserModel extends Model {
259
296
  @attr('boolean') isAdmin;
@@ -265,12 +302,23 @@ class NumberTransform {
265
302
  @public
266
303
  */
267
304
  class StringTransform {
305
+ /**
306
+ * Converts a serialized (raw payload) value into a `string`, or `null`
307
+ * if the value is falsy (and not an empty string).
308
+ */
268
309
  deserialize(serialized, _options) {
269
310
  return !serialized && serialized !== '' ? null : String(serialized);
270
311
  }
312
+ /**
313
+ * Converts a `string` attribute value into its serialized (raw payload) form.
314
+ */
271
315
  serialize(deserialized, _options) {
272
316
  return !deserialized && deserialized !== '' ? null : String(deserialized);
273
317
  }
318
+
319
+ /**
320
+ * Creates a new instance of this transform.
321
+ */
274
322
  static create() {
275
323
  return new this();
276
324
  }
@@ -149,11 +149,8 @@ class Serializer extends EmberObject {
149
149
  }
150
150
  });
151
151
  ```
152
- @property store
153
- @type {Store}
154
- @public
152
+ @public
155
153
  */
156
-
157
154
  /**
158
155
  The `normalizeResponse` method is used to normalize a payload from the
159
156
  server to a JSON-API Document.
@@ -237,9 +234,9 @@ class Serializer extends EmberObject {
237
234
  })
238
235
  ```
239
236
  @public
240
- @param {Model} typeClass
241
- @param {Object} hash
242
- @return {Object}
237
+ @param _typeClass - the model class the hash is being normalized for
238
+ @param hash - the raw payload hash to normalize
239
+ @return the normalized resource document
243
240
  */
244
241
  normalize(_typeClass, hash) {
245
242
  return hash;
@@ -98,12 +98,11 @@ function resourceIsFullyDeleted(instanceCache, identifier) {
98
98
  class RecordReference {
99
99
  /** @internal */
100
100
 
101
- /** @internal */
102
101
  // unsubscribe token given to us by the notification manager
102
+ /** @internal */
103
103
  ___token;
104
104
  /** @internal */
105
105
  ___identifier;
106
-
107
106
  /** @internal */
108
107
 
109
108
  constructor(store, identifier) {
@@ -134,7 +133,7 @@ class RecordReference {
134
133
  userRef.id(); // '1'
135
134
  ```
136
135
  @public
137
- @return The id of the record.
136
+ @return The id of the record.
138
137
  */
139
138
  id() {
140
139
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -152,7 +151,7 @@ class RecordReference {
152
151
  userRef.identifier(); // '1'
153
152
  ```
154
153
  @public
155
- @return The identifier of the record.
154
+ @return The identifier of the record.
156
155
  */
157
156
  identifier() {
158
157
  return this.___identifier;
@@ -178,7 +177,7 @@ class RecordReference {
178
177
  simplest usage of this API is similar to `store.push`: you provide a
179
178
  normalized hash of data and the object represented by the reference
180
179
  will update.
181
- If you pass a promise to `push`, Ember Data will not ask the adapter
180
+ If you pass a promise to `push`, WarpDrive will not ask the adapter
182
181
  for the data if another attempt to fetch it is made in the
183
182
  interim. When the promise resolves, the underlying object is updated
184
183
  with the new data, and the promise returned by *this function* is resolved
@@ -222,7 +221,7 @@ class RecordReference {
222
221
  userRef.value(); // user
223
222
  ```
224
223
  @public
225
- @return {Model} the record for this RecordReference
224
+ @return the record for this RecordReference
226
225
  */
227
226
  value() {
228
227
  return this.store.peekRecord(this.___identifier);
@@ -357,6 +356,14 @@ class ShimModelClass {
357
356
  });
358
357
  }
359
358
  }
359
+
360
+ /**
361
+ * Restores the deprecated `findRecord`/`findAll`/`query`/`queryRecord`/
362
+ * `findBelongsTo`/`findHasMany`/`createRecord`/`deleteRecord`/`saveRecord`
363
+ * legacy-network-layer implementations of these methods onto the given
364
+ * `Store` subclass, for apps that have not yet migrated to the
365
+ * `RequestManager`-based equivalents.
366
+ */
360
367
  function restoreDeprecatedStoreBehaviors(StoreKlass) {
361
368
  StoreKlass.prototype.findRecord = function (resource, id, options) {
362
369
  if (isMaybeIdentifier(resource)) {
@@ -437,7 +444,14 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
437
444
  };
438
445
 
439
446
  // do not put a ts-expect-error here, because typedoc will fail to
440
- // build due to this error only occurring when references are in use in the editor
447
+ // build due to this error only occurring when references are in use in the editor.
448
+ // The return statement below casts to `PrivateStore['getReference']`'s return
449
+ // type rather than annotating this function `: RecordReference` directly,
450
+ // since this package's `RecordReference` and core's `deprecated/-private.ts`
451
+ // copy are structurally identical but nominally distinct classes (TS treats
452
+ // their private fields as separate brands); casting only the return value
453
+ // (instead of the whole function) keeps `this` contextually typed from the
454
+ // assignment target below.
441
455
  StoreKlass.prototype.getReference = function (resource, id) {
442
456
  let resourceIdentifier;
443
457
  if (arguments.length === 1 && isMaybeIdentifier(resource)) {