@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
@@ -117,7 +117,7 @@ import { RESTAdapter } from './rest.js';
117
117
  namespace property on the adapter:
118
118
 
119
119
  ```js [app/adapters/application.js]
120
- import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';
120
+ import { JSONAPIAdapter } from '@warp-drive/legacy/adapter/json-api';
121
121
 
122
122
  export default class ApplicationAdapter extends JSONAPIAdapter {
123
123
  namespace = 'api/1';
@@ -146,6 +146,10 @@ import { RESTAdapter } from './rest.js';
146
146
  @constructor
147
147
  */
148
148
  class JSONAPIAdapter extends RESTAdapter {
149
+ /**
150
+ * The `Content-Type` header used when serializing request bodies
151
+ * that don't otherwise specify one.
152
+ */
149
153
  _defaultContentType = 'application/vnd.api+json';
150
154
 
151
155
  /**
@@ -227,6 +231,14 @@ class JSONAPIAdapter extends RESTAdapter {
227
231
  }
228
232
  });
229
233
  }
234
+
235
+ /**
236
+ * Determines the pathname for a given type.
237
+ *
238
+ * Unlike the base `BuildURLMixin` implementation, dasherizes (rather
239
+ * than camelizes) the type name before pluralizing it, per the
240
+ * {json:api} convention for member names.
241
+ */
230
242
  pathForType(modelName) {
231
243
  const dasherized = dasherize(modelName);
232
244
  return pluralize(dasherized);
@@ -234,13 +234,39 @@ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
234
234
  @public
235
235
  */
236
236
  class RESTAdapter extends AdapterWithBuildURLMixin {
237
+ /**
238
+ * @private
239
+ */
240
+
241
+ /**
242
+ * @private
243
+ */
244
+
245
+ /**
246
+ * See "Host customization" above.
247
+ */
248
+
249
+ /**
250
+ * See "Namespace customization" above.
251
+ */
252
+
237
253
  /**
238
254
  This property allows ajax to still be used instead when `false`.
239
255
  @default true
240
256
  @public
241
257
  */
242
258
  useFetch = true;
259
+
260
+ /**
261
+ * The `Content-Type` header used when serializing request bodies
262
+ * that don't otherwise specify one.
263
+ */
243
264
  _defaultContentType = 'application/json; charset=utf-8';
265
+
266
+ /**
267
+ * The FastBoot service instance, if running in a FastBoot environment.
268
+ * Lazily looked up on first access.
269
+ */
244
270
  get fastboot() {
245
271
  // Avoid computed property override deprecation in fastboot as suggested by:
246
272
  // https://deprecations.emberjs.com/v3.x/#toc_computed-property-override
@@ -250,6 +276,10 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
250
276
  }
251
277
  return this._fastboot = getOwner(this).lookup('service:fastboot');
252
278
  }
279
+
280
+ /**
281
+ * Sets the FastBoot service instance to use.
282
+ */
253
283
  static {
254
284
  decorateMethodV2(this.prototype, "fastboot", [computed()]);
255
285
  }
@@ -646,7 +676,13 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
646
676
  return expandedURL.join('/');
647
677
  }
648
678
 
649
- // http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
679
+ /**
680
+ * The maximum URL length to allow when coalescing `findRecord` requests
681
+ * into a single `findMany` request via {@link RESTAdapter.groupRecordsForFindMany | groupRecordsForFindMany}.
682
+ * Requests that would exceed this length are split into multiple groups.
683
+ *
684
+ * See http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
685
+ */
650
686
  maxURLLength = 2048;
651
687
 
652
688
  /**
@@ -707,8 +743,8 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
707
743
  if (this.isSuccess(status, headers, payload)) {
708
744
  return payload;
709
745
  } else if (this.isInvalid(status, headers, payload)) {
710
- // @ts-expect-error needs cast to ApiError
711
- return new InvalidError(typeof payload === 'object' && 'errors' in payload ? payload.errors : undefined);
746
+ const errorPayload = payload ?? {};
747
+ return new InvalidError(typeof errorPayload === 'object' && 'errors' in errorPayload ? errorPayload.errors : undefined);
712
748
  }
713
749
  const errors = this.normalizeErrorResponse(status, headers, payload);
714
750
  const detailedMessage = this.generatedDetailedMessage(status, headers, payload, requestData);
@@ -4,6 +4,8 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
4
4
  import Mixin from '@ember/object/mixin';
5
5
  import { camelize, pluralize } from '@warp-drive/utilities/string';
6
6
 
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+
7
9
  /*
8
10
  The structure of this file is such because typing Mixins is hard. Here we've structured it in
9
11
  such a way as to maximize the type information that a consumer can utilize. There are simpler
@@ -14,37 +16,18 @@ import { camelize, pluralize } from '@warp-drive/utilities/string';
14
16
  // `interface BuildURLMixin { buildURL: typeof buildURL }`
15
17
  // then an extending class overwriting one of the methods will break because typescript
16
18
  // thinks it is a switch from an instance prop (that is a method) to an instance method.
19
+ /**
20
+ * The methods provided by the `BuildURLMixin` mixin (see the exported
21
+ * `BuildURLMixin` {@link Mixin} below).
22
+ *
23
+ * See also {@link MixtBuildURLMixin}, the interface used to type `this`
24
+ * within these methods.
25
+ */
17
26
 
18
27
  // prevents the final constructed object from needing to add
19
28
  // host and namespace which are provided by the final consuming
20
29
  // class to the prototype which can result in overwrite errors
21
30
 
22
- /**
23
- ## Using BuildURLMixin
24
-
25
- To use URL building, include the mixin when extending an adapter, and call `buildURL` where needed.
26
- The default behaviour is designed for RESTAdapter.
27
-
28
- ### Example
29
-
30
- ```javascript
31
- import Adapter, { BuildURLMixin } from '@ember-data/adapter';
32
-
33
- export default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {
34
- findRecord(store, type, id, snapshot) {
35
- var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
36
- return this.ajax(url, 'GET');
37
- }
38
- }
39
- ```
40
-
41
- ### Attributes
42
-
43
- The `host` and `namespace` attributes will be used if defined, and are optional.
44
-
45
- @class BuildURLMixin
46
- @public
47
- */
48
31
  /**
49
32
  Builds a URL for a given type and optional ID.
50
33
 
@@ -490,6 +473,13 @@ const mixinProps = {
490
473
  urlPrefix,
491
474
  pathForType
492
475
  };
476
+
477
+ /**
478
+ * The `Mixin` implementation of {@link BuildURLMixin}, ready to be applied
479
+ * to an `EmberObject` subclass such as an `Adapter`.
480
+ *
481
+ * @public
482
+ */
493
483
  const BuildURLMixin = Mixin.create(mixinProps);
494
484
 
495
485
  /**
@@ -739,6 +729,13 @@ class Adapter extends EmberObject {
739
729
  decorateFieldV2(this.prototype, "store", [service]);
740
730
  }
741
731
  #store = (initializeDeferredDecorator(this, "store"), void 0);
732
+ /**
733
+ * The Store service instance that owns this Adapter.
734
+ */
735
+ /**
736
+ * @private
737
+ */
738
+
742
739
  /**
743
740
  The `findRecord()` method is invoked when the store is asked for a record that
744
741
  has not previously been loaded. In response to `findRecord()` being called, you
@@ -15,7 +15,6 @@ import { storeFor, recordIdentifierFor } from '@warp-drive/core';
15
15
  @deprecated
16
16
  @public
17
17
  @param type the name of the resource
18
- @param query a query to be used by the adapter
19
18
  @param options optional, may include `adapterOptions` hash which will be passed to adapter.findAll
20
19
  @return request config
21
20
  */
@@ -1,18 +1,74 @@
1
- import { get, set } from '@ember/object';
1
+ import { get, set, setProperties, notifyPropertyChange, getProperties } from '@ember/object';
2
+ import { removeObserver, addObserver } from '@ember/object/observers';
2
3
  import { compare } from '@ember/utils';
3
- import Ember from 'ember';
4
4
  const EmberObjectFeatures = {};
5
5
  const EmberObjectMethods = ['addObserver', 'cacheFor', 'decrementProperty', 'get', 'getProperties', 'incrementProperty', 'notifyPropertyChange', 'removeObserver', 'set', 'setProperties', 'toggleProperty'];
6
6
  EmberObjectMethods.forEach(method => {
7
7
  EmberObjectFeatures[method] = function delegatedMethod(...args) {
8
- return Ember[method](this, ...args);
8
+ switch (method) {
9
+ case 'addObserver':
10
+ return addObserver(this, ...args);
11
+ case 'cacheFor':
12
+ throw new Error('cacheFor has been removed and will not be replaced');
13
+ case 'decrementProperty':
14
+ {
15
+ const keyName = args[0];
16
+ const decrement = args[1] ?? 1;
17
+ (test => {
18
+ if (!test) {
19
+ throw new Error('Must pass a numeric value to decrementProperty');
20
+ }
21
+ })((typeof decrement === 'number' || !isNaN(parseFloat(decrement))) && isFinite(decrement));
22
+ return set(this, keyName, (get(this, keyName) || 0) - decrement);
23
+ }
24
+ case 'get':
25
+ return get(this, ...args);
26
+ case 'getProperties':
27
+ return getProperties(this, ...args);
28
+ case 'incrementProperty':
29
+ {
30
+ const keyName = args[0];
31
+ const increment = args[1] ?? 1;
32
+ (test => {
33
+ if (!test) {
34
+ throw new Error('Must pass a numeric value to incrementProperty');
35
+ }
36
+ })(!isNaN(parseFloat(String(increment))) && isFinite(increment));
37
+ return set(this, keyName, (parseFloat(get(this, keyName)) || 0) + increment);
38
+ }
39
+ case 'notifyPropertyChange':
40
+ return notifyPropertyChange(this, ...args);
41
+ case 'removeObserver':
42
+ return removeObserver(this, ...args);
43
+ case 'set':
44
+ return set(this, ...args);
45
+ case 'setProperties':
46
+ return setProperties(this, ...args);
47
+ case 'toggleProperty':
48
+ {
49
+ const key = args[0];
50
+ return set(this, key, !get(this, key));
51
+ }
52
+ }
9
53
  };
10
54
  });
55
+ /**
56
+ * A schema extension that adds the classic `EmberObject` API (`get`, `set`,
57
+ * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,
58
+ * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)
59
+ * to reactive array resources.
60
+ */
11
61
  const EmberObjectArrayExtension = {
12
62
  kind: 'array',
13
63
  name: 'ember-object',
14
64
  features: EmberObjectFeatures
15
65
  };
66
+ /**
67
+ * A schema extension that adds the classic `EmberObject` API (`get`, `set`,
68
+ * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,
69
+ * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)
70
+ * to reactive object resources.
71
+ */
16
72
  const EmberObjectExtension = {
17
73
  kind: 'object',
18
74
  name: 'ember-object',
@@ -234,9 +290,30 @@ const EmberArrayLikeFeatures = {
234
290
  return this.at(-1);
235
291
  }
236
292
  };
293
+
294
+ /**
295
+ * A schema extension that adds Ember's classic `MutableArray`/`Enumerable`
296
+ * style methods (`pushObject`, `removeObject`, `mapBy`, `filterBy`,
297
+ * `sortBy`, `firstObject`, `lastObject`, etc.) to reactive array resources.
298
+ */
237
299
  const EmberArrayLikeExtension = {
238
300
  kind: 'array',
239
301
  name: 'ember-array-like',
240
302
  features: EmberArrayLikeFeatures
241
303
  };
304
+
305
+ /**
306
+ * Extracts the element type of an array type, or `never` if `T` is not an array.
307
+ */
308
+
309
+ /**
310
+ * Adds the classic `EmberObject` API (as registered by {@link EmberObjectExtension}/
311
+ * {@link EmberObjectArrayExtension}) to the type of a reactive resource.
312
+ */
313
+
314
+ /**
315
+ * Adds Ember's classic array-like API (as registered by {@link EmberArrayLikeExtension})
316
+ * to the type of a reactive array resource.
317
+ */
318
+
242
319
  export { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension };
@@ -145,6 +145,20 @@ function formattedId(id) {
145
145
  }
146
146
  return id === null ? null : String(id);
147
147
  }
148
+
149
+ /**
150
+ * Like {@link formattedId}, but asserts that `id` is not `null` rather
151
+ * than allowing and passing through `null`.
152
+ *
153
+ * @public
154
+ */
155
+
156
+ /**
157
+ * Throws, since `id` is `null`.
158
+ *
159
+ * @public
160
+ */
161
+
148
162
  function expectId(id) {
149
163
  AssertFn('expectId: id must not be null', id !== null);
150
164
  return formattedId(id);
@@ -303,7 +303,23 @@ function config(packageRoot) {
303
303
  function getGlobalConfig() {
304
304
  return runtimeConfig.global;
305
305
  }
306
- const runtimeConfig = initializeRuntimeMacrosConfig();
306
+
307
+ // Welcome intrepid developer!
308
+ //
309
+ // While this data is "global", this is a private variable.
310
+ //
311
+ // do not build features based off of its contents,
312
+ // or assume it will have the same name in future releases.
313
+ const runtimeConfig = globalThis.__embroider_macros__runtime_config__ ||= {};
314
+ runtimeConfig.packages ||= {};
315
+ runtimeConfig.global ||= {};
316
+
317
+ // In the off chance there are duplicate copies of @embroider/macros in the dep graph
318
+ // (due to the package manager messing up)
319
+ // Let's try to merge them together via the above global well known variable
320
+ const localConfig = initializeRuntimeMacrosConfig();
321
+ Object.assign(runtimeConfig.packages, localConfig.packages);
322
+ Object.assign(runtimeConfig.global, localConfig.global);
307
323
 
308
324
  // this exists to be targeted by our babel plugin
309
325
  function initializeRuntimeMacrosConfig() {
@@ -417,6 +433,14 @@ if (updaters) {
417
433
  }
418
434
  }
419
435
  const PotentialLegacyOperations = new Set(['findRecord', 'findAll', 'query', 'queryRecord', 'findBelongsTo', 'findHasMany', 'updateRecord', 'createRecord', 'deleteRecord']);
436
+
437
+ /**
438
+ * A {@link Handler} that fulfills legacy `findRecord`/`findAll`/`query`/
439
+ * `queryRecord`/`findBelongsTo`/`findHasMany`/`createRecord`/`updateRecord`/
440
+ * `deleteRecord` requests using the store's configured {@link MinimumAdapterInterface | adapter}
441
+ * and {@link MinimumSerializerInterface | serializer}, passing any other
442
+ * request through to the next handler unchanged.
443
+ */
420
444
  const LegacyNetworkHandler = {
421
445
  request(context, next) {
422
446
  // if we are not a legacy request, move on
@@ -1121,6 +1145,10 @@ function pushPayload(modelName, inputPayload) {
1121
1145
  serializer.pushPayload(this, payload);
1122
1146
  }
1123
1147
 
1148
+ /**
1149
+ * Serializes a record using the store's legacy network layer, as with
1150
+ * {@link LegacyStoreCompat.serializeRecord | store.serializeRecord}.
1151
+ */
1124
1152
  // TODO @runspired @deprecate records should implement their own serialization if desired
1125
1153
  function serializeRecord(record, options) {
1126
1154
  // TODO we used to check if the record was destroyed here
@@ -1129,6 +1157,11 @@ function serializeRecord(record, options) {
1129
1157
  }
1130
1158
  return this._fetchManager.createSnapshot(recordIdentifierFor(record)).serialize(options);
1131
1159
  }
1160
+
1161
+ /**
1162
+ * Destroys any adapters/serializers the legacy network layer has created
1163
+ * for this store, invoked when the store itself is destroyed.
1164
+ */
1132
1165
  function cleanup() {
1133
1166
  // enqueue destruction of any adapters/serializers we have created
1134
1167
  for (const adapterName in this._adapterCache) {
@@ -76,7 +76,7 @@ PromiseBelongsTo.prototype[LegacyPromiseProxy] = true;
76
76
 
77
77
  /**
78
78
  This class is returned as the result of accessing an async hasMany relationship
79
- on an instance of a Model extending from `@ember-data/model`.
79
+ on an instance of a Model extending from `@warp-drive/legacy/model`.
80
80
 
81
81
  A PromiseManyArray is an iterable proxy that allows templates to consume related
82
82
  ManyArrays and update once their contents are no longer pending.
@@ -90,6 +90,20 @@ PromiseBelongsTo.prototype[LegacyPromiseProxy] = true;
90
90
  @public
91
91
  */
92
92
  class PromiseManyArray {
93
+ /**
94
+ * The promise for the relationship's content, or `null` once
95
+ * {@link PromiseManyArray.destroy | destroy} has been called.
96
+ */
97
+
98
+ /**
99
+ * Whether {@link PromiseManyArray.destroy | destroy} has been called.
100
+ */
101
+
102
+ /**
103
+ * The resolved `ManyArray` for the relationship, if the promise has
104
+ * resolved, else `null`.
105
+ */
106
+
93
107
  constructor(promise, content) {
94
108
  this._update(promise, content);
95
109
  this.isDestroyed = false;
@@ -110,6 +124,9 @@ class PromiseManyArray {
110
124
  return this.content ? this.content.length : 0;
111
125
  }
112
126
 
127
+ /**
128
+ * @private
129
+ */
113
130
  // this will error if someone tries to call
114
131
  // A(identifierArray) since it is not configurable
115
132
  // which is preferrable to the `meta` override we used
@@ -211,6 +228,12 @@ class PromiseManyArray {
211
228
 
212
229
  //---- Methods on EmberObject that we should keep
213
230
 
231
+ /**
232
+ * Tears down this proxy, releasing its {@link PromiseManyArray.content | content} and
233
+ * {@link PromiseManyArray.promise | promise} and marking it as {@link PromiseManyArray.isDestroyed | destroyed}.
234
+ *
235
+ * @public
236
+ */
214
237
  destroy() {
215
238
  this.isDestroyed = true;
216
239
  this.content = null;
@@ -1,7 +1,15 @@
1
1
  import { setOwner, getOwner } from '@ember/application';
2
2
  import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
3
- import { g as getModelFactory } from "./schema-provider-BP6_8N-V.js";
3
+ import { g as getModelFactory } from "./schema-provider-ZwO5_fZw.js";
4
4
  import { n as normalizeModelName } from "./util-CWr5WQOT.js";
5
+
6
+ /**
7
+ * The `instantiateRecord` hook implementation for use with `Model`. Pass
8
+ * this to your store's `instantiateRecord` method when configuring the
9
+ * store to use `Model` for schema/record instantiation.
10
+ *
11
+ * @public
12
+ */
5
13
  function instantiateRecord(identifier, createRecordArgs) {
6
14
  const type = identifier.type;
7
15
 
@@ -26,14 +34,37 @@ function instantiateRecord(identifier, createRecordArgs) {
26
34
  })(factory);
27
35
  return factory.class.create(createOptions);
28
36
  }
37
+
38
+ /**
39
+ * The `teardownRecord` hook implementation for use with `Model`. Pass this
40
+ * to your store's `teardownRecord` method when configuring the store to
41
+ * use `Model` for schema/record instantiation.
42
+ *
43
+ * @public
44
+ */
29
45
  function teardownRecord(record) {
30
46
  (test => {
31
47
  if (!test) {
32
- throw new Error(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`);
48
+ throw new Error(`expected to receive an instance of Model from @warp-drive/legacy/model. If using a custom model make sure you implement teardownRecord`);
33
49
  }
34
50
  })('destroy' in record);
35
51
  record.destroy();
36
52
  }
53
+
54
+ /**
55
+ * The `modelFor` implementation for use with `Model`, exposed on the store
56
+ * as `store.modelFor(type)` when the store is configured to use `Model`.
57
+ * Returns the `Model` subclass registered for the given type, if any.
58
+ *
59
+ * @public
60
+ */
61
+
62
+ /**
63
+ * Overload accepting a raw type string instead of a typed record instance.
64
+ *
65
+ * @public
66
+ */
67
+
37
68
  function modelFor(modelName) {
38
69
  assertPrivateStore(this);
39
70
  (test => {