@warp-drive/legacy 5.6.0-alpha.15 → 5.6.0-alpha.17

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 (193) hide show
  1. package/declarations/adapter/-private/build-url-mixin.d.ts +41 -29
  2. package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
  3. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
  4. package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
  5. package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
  6. package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
  7. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
  8. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
  9. package/declarations/adapter/-private.d.ts +5 -6
  10. package/declarations/adapter/error.d.ts +206 -178
  11. package/declarations/adapter/json-api.d.ts +206 -207
  12. package/declarations/adapter/rest.d.ts +805 -808
  13. package/declarations/adapter.d.ts +742 -766
  14. package/declarations/compat/-private.d.ts +10 -11
  15. package/declarations/compat/builders/find-all.d.ts +26 -24
  16. package/declarations/compat/builders/find-record.d.ts +41 -39
  17. package/declarations/compat/builders/query.d.ts +50 -45
  18. package/declarations/compat/builders/save-record.d.ts +26 -24
  19. package/declarations/compat/builders/utils.d.ts +1 -2
  20. package/declarations/compat/builders.d.ts +10 -11
  21. package/declarations/compat/extensions.d.ts +52 -106
  22. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
  23. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
  24. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
  25. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
  26. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
  27. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
  28. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
  29. package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
  30. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
  31. package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
  32. package/declarations/compat/utils.d.ts +118 -119
  33. package/declarations/compat.d.ts +106 -104
  34. package/declarations/model/-private/attr.d.ts +164 -145
  35. package/declarations/model/-private/belongs-to.d.ts +135 -122
  36. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
  37. package/declarations/model/-private/errors.d.ts +272 -267
  38. package/declarations/model/-private/has-many.d.ts +119 -116
  39. package/declarations/model/-private/hooks.d.ts +5 -6
  40. package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
  41. package/declarations/model/-private/model-for-mixin.d.ts +18 -3
  42. package/declarations/model/-private/model-methods.d.ts +29 -24
  43. package/declarations/model/-private/model.d.ts +1306 -1254
  44. package/declarations/model/-private/notify-changes.d.ts +3 -4
  45. package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
  46. package/declarations/model/-private/promise-many-array.d.ts +125 -116
  47. package/declarations/model/-private/record-state.d.ts +63 -60
  48. package/declarations/model/-private/references/belongs-to.d.ts +491 -487
  49. package/declarations/model/-private/references/has-many.d.ts +495 -492
  50. package/declarations/model/-private/schema-provider.d.ts +53 -56
  51. package/declarations/model/-private/type-utils.d.ts +41 -41
  52. package/declarations/model/-private/util.d.ts +1 -2
  53. package/declarations/model/-private.d.ts +8 -8
  54. package/declarations/model/migration-support.d.ts +281 -279
  55. package/declarations/model.d.ts +48 -49
  56. package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
  57. package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
  58. package/declarations/serializer/-private/transforms/date.d.ts +22 -22
  59. package/declarations/serializer/-private/transforms/number.d.ts +22 -22
  60. package/declarations/serializer/-private/transforms/string.d.ts +22 -22
  61. package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
  62. package/declarations/serializer/-private/utils.d.ts +0 -1
  63. package/declarations/serializer/json-api.d.ts +124 -494
  64. package/declarations/serializer/json.d.ts +62 -1031
  65. package/declarations/serializer/rest.d.ts +52 -552
  66. package/declarations/serializer/transform.d.ts +5 -6
  67. package/declarations/serializer.d.ts +217 -218
  68. package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
  69. package/dist/adapter/-private.js +1 -1
  70. package/dist/adapter/error.js +17 -0
  71. package/dist/adapter/json-api.js +1 -1
  72. package/dist/adapter/rest.js +5 -7
  73. package/dist/adapter.js +6 -35
  74. package/dist/compat/-private.js +1 -1
  75. package/dist/compat/extensions.js +0 -2
  76. package/dist/compat.js +3 -4
  77. package/dist/{errors-_QQ7xpSn.js → errors-BX5wowuz.js} +11 -10
  78. package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
  79. package/dist/model/-private.js +1 -1
  80. package/dist/model/migration-support.js +3 -4
  81. package/dist/model.js +3 -3
  82. package/dist/{schema-provider-D_P8ReX6.js → schema-provider-BdQhkT-Q.js} +20 -13
  83. package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
  84. package/dist/serializer/json-api.js +42 -2
  85. package/dist/serializer/json.js +1 -1
  86. package/dist/serializer/rest.js +46 -41
  87. package/dist/serializer/transform.js +0 -44
  88. package/package.json +7 -7
  89. package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
  90. package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
  91. package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
  92. package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
  93. package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
  94. package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
  95. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
  96. package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
  97. package/declarations/adapter/-private.d.ts.map +0 -1
  98. package/declarations/adapter/error.d.ts.map +0 -1
  99. package/declarations/adapter/json-api.d.ts.map +0 -1
  100. package/declarations/adapter/rest.d.ts.map +0 -1
  101. package/declarations/adapter.d.ts.map +0 -1
  102. package/declarations/compat/-private.d.ts.map +0 -1
  103. package/declarations/compat/builders/find-all.d.ts.map +0 -1
  104. package/declarations/compat/builders/find-record.d.ts.map +0 -1
  105. package/declarations/compat/builders/query.d.ts.map +0 -1
  106. package/declarations/compat/builders/save-record.d.ts.map +0 -1
  107. package/declarations/compat/builders/utils.d.ts.map +0 -1
  108. package/declarations/compat/builders.d.ts.map +0 -1
  109. package/declarations/compat/extensions.d.ts.map +0 -1
  110. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
  111. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
  112. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
  113. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
  114. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
  115. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
  116. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
  117. package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
  118. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
  119. package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
  120. package/declarations/compat/utils.d.ts.map +0 -1
  121. package/declarations/compat.d.ts.map +0 -1
  122. package/declarations/model/-private/attr.d.ts.map +0 -1
  123. package/declarations/model/-private/attr.type-test.d.ts +0 -2
  124. package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
  125. package/declarations/model/-private/belongs-to.d.ts.map +0 -1
  126. package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
  127. package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
  128. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
  129. package/declarations/model/-private/errors.d.ts.map +0 -1
  130. package/declarations/model/-private/has-many.d.ts.map +0 -1
  131. package/declarations/model/-private/has-many.type-test.d.ts +0 -2
  132. package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
  133. package/declarations/model/-private/hooks.d.ts.map +0 -1
  134. package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
  135. package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
  136. package/declarations/model/-private/model-methods.d.ts.map +0 -1
  137. package/declarations/model/-private/model.d.ts.map +0 -1
  138. package/declarations/model/-private/model.type-test.d.ts +0 -2
  139. package/declarations/model/-private/model.type-test.d.ts.map +0 -1
  140. package/declarations/model/-private/notify-changes.d.ts.map +0 -1
  141. package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
  142. package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
  143. package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
  144. package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
  145. package/declarations/model/-private/record-state.d.ts.map +0 -1
  146. package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
  147. package/declarations/model/-private/references/has-many.d.ts.map +0 -1
  148. package/declarations/model/-private/schema-provider.d.ts.map +0 -1
  149. package/declarations/model/-private/type-utils.d.ts.map +0 -1
  150. package/declarations/model/-private/util.d.ts.map +0 -1
  151. package/declarations/model/-private.d.ts.map +0 -1
  152. package/declarations/model/migration-support.d.ts.map +0 -1
  153. package/declarations/model/migration-support.type-test.d.ts +0 -2
  154. package/declarations/model/migration-support.type-test.d.ts.map +0 -1
  155. package/declarations/model.d.ts.map +0 -1
  156. package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
  157. package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
  158. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
  159. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
  160. package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
  161. package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
  162. package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
  163. package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
  164. package/declarations/serializer/-private/utils.d.ts.map +0 -1
  165. package/declarations/serializer/json-api.d.ts.map +0 -1
  166. package/declarations/serializer/json.d.ts.map +0 -1
  167. package/declarations/serializer/rest.d.ts.map +0 -1
  168. package/declarations/serializer/transform.d.ts.map +0 -1
  169. package/declarations/serializer.d.ts.map +0 -1
  170. package/dist/-private-DFfBszo5.js.map +0 -1
  171. package/dist/adapter/-private.js.map +0 -1
  172. package/dist/adapter/error.js.map +0 -1
  173. package/dist/adapter/json-api.js.map +0 -1
  174. package/dist/adapter/rest.js.map +0 -1
  175. package/dist/adapter.js.map +0 -1
  176. package/dist/compat/-private.js.map +0 -1
  177. package/dist/compat/builders.js.map +0 -1
  178. package/dist/compat/extensions.js.map +0 -1
  179. package/dist/compat/utils.js.map +0 -1
  180. package/dist/compat.js.map +0 -1
  181. package/dist/errors-_QQ7xpSn.js.map +0 -1
  182. package/dist/json-DSOlH9A8.js.map +0 -1
  183. package/dist/model/-private.js.map +0 -1
  184. package/dist/model/migration-support.js.map +0 -1
  185. package/dist/model.js.map +0 -1
  186. package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
  187. package/dist/schema-provider-D_P8ReX6.js.map +0 -1
  188. package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
  189. package/dist/serializer/json-api.js.map +0 -1
  190. package/dist/serializer/json.js.map +0 -1
  191. package/dist/serializer/rest.js.map +0 -1
  192. package/dist/serializer/transform.js.map +0 -1
  193. package/dist/serializer.js.map +0 -1
@@ -1,258 +1,257 @@
1
1
  /**
2
- ## Overview
2
+ ## Overview
3
3
 
4
- <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
5
- <p>
6
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
7
- If starting a new app or thinking of implementing a new serializer, consider writing a
8
- <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
9
- </p>
10
- </blockquote>
4
+ <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
5
+ <p>
6
+ ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
7
+ If starting a new app or thinking of implementing a new serializer, consider writing a
8
+ <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
9
+ </p>
10
+ </blockquote>
11
11
 
12
- In order to properly manage and present your data, WarpDrive
13
- needs to understand the structure of data it receives.
12
+ In order to properly manage and present your data, WarpDrive
13
+ needs to understand the structure of data it receives.
14
14
 
15
- `Serializers` convert data between the server's API format and
16
- the format WarpDrive understands.
15
+ `Serializers` convert data between the server's API format and
16
+ the format WarpDrive understands.
17
17
 
18
- Data received from an API response is **normalized** into
19
- [JSON:API](https://jsonapi.org/) (the format used internally
20
- by WarpDrive), while data sent to an API is **serialized**
21
- into the format the API expects.
18
+ Data received from an API response is **normalized** into
19
+ [JSON:API](https://jsonapi.org/) (the format used internally
20
+ by WarpDrive), while data sent to an API is **serialized**
21
+ into the format the API expects.
22
22
 
23
- ### Implementing a Serializer
23
+ ### Implementing a Serializer
24
24
 
25
- There are only two required serializer methods, one for
26
- normalizing data from the server API format into JSON:API, and
27
- another for serializing records via `Snapshots` into the expected
28
- server API format.
25
+ There are only two required serializer methods, one for
26
+ normalizing data from the server API format into JSON:API, and
27
+ another for serializing records via `Snapshots` into the expected
28
+ server API format.
29
29
 
30
- To implement a serializer, export a class that conforms to the structure
31
- described by {@link MinimumSerializerInterface}
32
- from the `app/serializers/` directory. An example is below.
30
+ To implement a serializer, export a class that conforms to the structure
31
+ described by {@link MinimumSerializerInterface}
32
+ from the `app/serializers/` directory. An example is below.
33
33
 
34
- ```ts
35
- import EmberObject from '@ember/object';
34
+ ```ts
35
+ import EmberObject from '@ember/object';
36
36
 
37
- export default class ApplicationSerializer extends EmberObject {
38
- normalizeResponse(store, schema, rawPayload) {
39
- return rawPayload;
40
- }
37
+ export default class ApplicationSerializer extends EmberObject {
38
+ normalizeResponse(store, schema, rawPayload) {
39
+ return rawPayload;
40
+ }
41
41
 
42
- serialize(snapshot, options) {
43
- const serializedResource = {
44
- id: snapshot.id,
45
- type: snapshot.modelName,
46
- attributes: snapshot.attributes()
47
- };
42
+ serialize(snapshot, options) {
43
+ const serializedResource = {
44
+ id: snapshot.id,
45
+ type: snapshot.modelName,
46
+ attributes: snapshot.attributes()
47
+ };
48
48
 
49
- return serializedResource;
50
- }
51
- }
52
- ```
49
+ return serializedResource;
50
+ }
51
+ }
52
+ ```
53
53
 
54
54
 
55
- ### Serializer Resolution
55
+ ### Serializer Resolution
56
56
 
57
- `store.serializerFor(name)` will lookup serializers defined in
58
- `app/serializers/` and return an instance. If no serializer is found, an
59
- error will be thrown.
57
+ `store.serializerFor(name)` will lookup serializers defined in
58
+ `app/serializers/` and return an instance. If no serializer is found, an
59
+ error will be thrown.
60
60
 
61
- `serializerFor` first attempts to find a serializer with an exact match on `name`,
62
- then falls back to checking for the presence of a serializer named `application`.
61
+ `serializerFor` first attempts to find a serializer with an exact match on `name`,
62
+ then falls back to checking for the presence of a serializer named `application`.
63
63
 
64
- ```ts
65
- store.serializerFor('author');
64
+ ```ts
65
+ store.serializerFor('author');
66
66
 
67
- // lookup paths (in order) =>
68
- // app/serializers/author.js
69
- // app/serializers/application.js
70
- ```
67
+ // lookup paths (in order) =>
68
+ // app/serializers/author.js
69
+ // app/serializers/application.js
70
+ ```
71
71
 
72
- Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`)
73
- (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
74
- refer to this as the **primary** resource `type`.
72
+ Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`)
73
+ (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
74
+ refer to this as the **primary** resource `type`.
75
75
 
76
- Typically `serializerFor` will be used to find a serializer with a name matching that of the primary
77
- resource `type` for the request, falling back to the `application` serializer for those types that
78
- do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy
79
- for defining serializers. However, because APIs rarely format payloads per-type but rather
80
- per-API-version, this may not be a desired strategy.
76
+ Typically `serializerFor` will be used to find a serializer with a name matching that of the primary
77
+ resource `type` for the request, falling back to the `application` serializer for those types that
78
+ do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy
79
+ for defining serializers. However, because APIs rarely format payloads per-type but rather
80
+ per-API-version, this may not be a desired strategy.
81
81
 
82
- It is recommended that applications define only a single `application` adapter and serializer
83
- where possible.
82
+ It is recommended that applications define only a single `application` adapter and serializer
83
+ where possible.
84
84
 
85
- If you have multiple API formats and the per-type strategy is not viable, one strategy is to
86
- write an `application` adapter and serializer that make use of `options` to specify the desired
87
- format when making a request.
85
+ If you have multiple API formats and the per-type strategy is not viable, one strategy is to
86
+ write an `application` adapter and serializer that make use of `options` to specify the desired
87
+ format when making a request.
88
88
 
89
- ### Using a Serializer
89
+ ### Using a Serializer
90
90
 
91
- Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.
91
+ Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.
92
92
 
93
- ### Default Serializers
93
+ ### Default Serializers
94
94
 
95
- For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
96
- format the `@ember-data/serializer` package contains implementations these applications can
97
- extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
95
+ For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
96
+ format the `@ember-data/serializer` package contains implementations these applications can
97
+ extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
98
98
 
99
- Many applications will find writing their own serializer to be more performant and less
100
- complex than extending these classes even when their API format is very close to that expected
101
- by these serializers.
99
+ Many applications will find writing their own serializer to be more performant and less
100
+ complex than extending these classes even when their API format is very close to that expected
101
+ by these serializers.
102
102
 
103
- It is recommended that apps write their own serializer to best suit the needs of their API and
104
- application.
103
+ It is recommended that apps write their own serializer to best suit the needs of their API and
104
+ application.
105
105
 
106
- @module
106
+ @module
107
107
  */
108
- import EmberObject from '@ember/object';
109
- import type { Store } from '@warp-drive/core';
110
- import type { ModelSchema } from '@warp-drive/core/types';
111
- import type { EmptyResourceDocument, SingleResourceDocument } from '@warp-drive/core/types/spec/json-api-raw';
108
+ import EmberObject from "@ember/object";
109
+ import type { Store } from "@warp-drive/core";
110
+ import type { ModelSchema } from "@warp-drive/core/types";
111
+ import type { EmptyResourceDocument, SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
112
112
  /**
113
- > ⚠️ CAUTION you likely want the docs for {@link MinimumSerializerInterface}
114
- > as extending this abstract class is unnecessary.
113
+ > ⚠️ CAUTION you likely want the docs for {@link MinimumSerializerInterface}
114
+ > as extending this abstract class is unnecessary.
115
115
 
116
- `Serializer` is an abstract base class that you may override in your
117
- application to customize it for your backend. The minimum set of methods
118
- that you should implement is:
116
+ `Serializer` is an abstract base class that you may override in your
117
+ application to customize it for your backend. The minimum set of methods
118
+ that you should implement is:
119
119
 
120
- * `normalizeResponse()`
121
- * `serialize()`
120
+ * `normalizeResponse()`
121
+ * `serialize()`
122
122
 
123
- And you can optionally override the following methods:
123
+ And you can optionally override the following methods:
124
124
 
125
- * `normalize()`
125
+ * `normalize()`
126
126
 
127
- For an example implementation, see
128
- [JSONSerializer](JSONSerializer), the included JSON serializer.
127
+ For an example implementation, see
128
+ [JSONSerializer](JSONSerializer), the included JSON serializer.
129
129
 
130
- @class Serializer
131
- @public
130
+ @class Serializer
131
+ @public
132
132
  */
133
133
  export declare class Serializer extends EmberObject {
134
- store: Store;
135
- /**
136
- The `store` property is the application's `store` that contains
137
- all records. It can be used to look up serializers for other model
138
- types that may be nested inside the payload response.
139
-
140
- Example:
141
-
142
- ```js
143
- Serializer.extend({
144
- extractRelationship(relationshipModelName, relationshipHash) {
145
- let modelClass = this.store.modelFor(relationshipModelName);
146
- let relationshipSerializer = this.store.serializerFor(relationshipModelName);
147
- return relationshipSerializer.normalize(modelClass, relationshipHash);
148
- }
149
- });
150
- ```
151
-
152
- @property store
153
- @type {Store}
154
- @public
155
- */
156
- /**
157
- The `normalizeResponse` method is used to normalize a payload from the
158
- server to a JSON-API Document.
159
-
160
- http://jsonapi.org/format/#document-structure
161
-
162
- Example:
163
-
164
- ```js
165
- Serializer.extend({
166
- normalizeResponse(store, primaryModelClass, payload, id, requestType) {
167
- if (requestType === 'findRecord') {
168
- return this.normalize(primaryModelClass, payload);
169
- } else {
170
- return payload.reduce(function(documentHash, item) {
171
- let { data, included } = this.normalize(primaryModelClass, item);
172
- documentHash.included.push(...included);
173
- documentHash.data.push(data);
174
- return documentHash;
175
- }, { data: [], included: [] })
176
- }
177
- }
178
- });
179
- ```
180
-
181
- @since 1.13.0
182
- @public
183
- @param {Store} store
184
- @param {Model} primaryModelClass
185
- @param {Object} payload
186
- @param {String|Number} id
187
- @param {String} requestType
188
- @return {Object} JSON-API Document
189
- */
190
- /**
191
- The `serialize` method is used when a record is saved in order to convert
192
- the record into the form that your external data source expects.
193
-
194
- `serialize` takes an optional `options` hash with a single option:
195
-
196
- - `includeId`: If this is `true`, `serialize` should include the ID
197
- in the serialized object it builds.
198
-
199
- Example:
200
-
201
- ```js
202
- Serializer.extend({
203
- serialize(snapshot, options) {
204
- let json = {
205
- id: snapshot.id
206
- };
207
-
208
- snapshot.eachAttribute((key, attribute) => {
209
- json[key] = snapshot.attr(key);
210
- });
211
-
212
- snapshot.eachRelationship((key, relationship) => {
213
- if (relationship.kind === 'belongsTo') {
214
- json[key] = snapshot.belongsTo(key, { id: true });
215
- } else if (relationship.kind === 'hasMany') {
216
- json[key] = snapshot.hasMany(key, { ids: true });
217
- }
218
- });
219
-
220
- return json;
221
- },
222
- });
223
- ```
224
-
225
- @public
226
- @param {Snapshot} snapshot
227
- @param {Object} [options]
228
- @return {Object}
229
- */
230
- /**
231
- The `normalize` method is used to convert a payload received from your
232
- external data source into the normalized form `store.push()` expects. You
233
- should override this method, munge the hash and return the normalized
234
- payload.
235
-
236
- Example:
237
-
238
- ```js
239
- Serializer.extend({
240
- normalize(modelClass, resourceHash) {
241
- let data = {
242
- id: resourceHash.id,
243
- type: modelClass.modelName,
244
- attributes: resourceHash
245
- };
246
- return { data: data };
247
- }
248
- })
249
- ```
250
-
251
- @public
252
- @param {Model} typeClass
253
- @param {Object} hash
254
- @return {Object}
255
- */
256
- normalize(_typeClass: ModelSchema, hash: Record<string, unknown>): SingleResourceDocument | EmptyResourceDocument;
134
+ store: Store;
135
+ /**
136
+ The `store` property is the application's `store` that contains
137
+ all records. It can be used to look up serializers for other model
138
+ types that may be nested inside the payload response.
139
+
140
+ Example:
141
+
142
+ ```js
143
+ Serializer.extend({
144
+ extractRelationship(relationshipModelName, relationshipHash) {
145
+ let modelClass = this.store.modelFor(relationshipModelName);
146
+ let relationshipSerializer = this.store.serializerFor(relationshipModelName);
147
+ return relationshipSerializer.normalize(modelClass, relationshipHash);
148
+ }
149
+ });
150
+ ```
151
+
152
+ @property store
153
+ @type {Store}
154
+ @public
155
+ */
156
+ /**
157
+ The `normalizeResponse` method is used to normalize a payload from the
158
+ server to a JSON-API Document.
159
+
160
+ http://jsonapi.org/format/#document-structure
161
+
162
+ Example:
163
+
164
+ ```js
165
+ Serializer.extend({
166
+ normalizeResponse(store, primaryModelClass, payload, id, requestType) {
167
+ if (requestType === 'findRecord') {
168
+ return this.normalize(primaryModelClass, payload);
169
+ } else {
170
+ return payload.reduce(function(documentHash, item) {
171
+ let { data, included } = this.normalize(primaryModelClass, item);
172
+ documentHash.included.push(...included);
173
+ documentHash.data.push(data);
174
+ return documentHash;
175
+ }, { data: [], included: [] })
176
+ }
177
+ }
178
+ });
179
+ ```
180
+
181
+ @since 1.13.0
182
+ @public
183
+ @param {Store} store
184
+ @param {Model} primaryModelClass
185
+ @param {Object} payload
186
+ @param {String|Number} id
187
+ @param {String} requestType
188
+ @return {Object} JSON-API Document
189
+ */
190
+ /**
191
+ The `serialize` method is used when a record is saved in order to convert
192
+ the record into the form that your external data source expects.
193
+
194
+ `serialize` takes an optional `options` hash with a single option:
195
+
196
+ - `includeId`: If this is `true`, `serialize` should include the ID
197
+ in the serialized object it builds.
198
+
199
+ Example:
200
+
201
+ ```js
202
+ Serializer.extend({
203
+ serialize(snapshot, options) {
204
+ let json = {
205
+ id: snapshot.id
206
+ };
207
+
208
+ snapshot.eachAttribute((key, attribute) => {
209
+ json[key] = snapshot.attr(key);
210
+ });
211
+
212
+ snapshot.eachRelationship((key, relationship) => {
213
+ if (relationship.kind === 'belongsTo') {
214
+ json[key] = snapshot.belongsTo(key, { id: true });
215
+ } else if (relationship.kind === 'hasMany') {
216
+ json[key] = snapshot.hasMany(key, { ids: true });
217
+ }
218
+ });
219
+
220
+ return json;
221
+ },
222
+ });
223
+ ```
224
+
225
+ @public
226
+ @param {Snapshot} snapshot
227
+ @param {Object} [options]
228
+ @return {Object}
229
+ */
230
+ /**
231
+ The `normalize` method is used to convert a payload received from your
232
+ external data source into the normalized form `store.push()` expects. You
233
+ should override this method, munge the hash and return the normalized
234
+ payload.
235
+
236
+ Example:
237
+
238
+ ```js
239
+ Serializer.extend({
240
+ normalize(modelClass, resourceHash) {
241
+ let data = {
242
+ id: resourceHash.id,
243
+ type: modelClass.modelName,
244
+ attributes: resourceHash
245
+ };
246
+ return { data: data };
247
+ }
248
+ })
249
+ ```
250
+
251
+ @public
252
+ @param {Model} typeClass
253
+ @param {Object} hash
254
+ @return {Object}
255
+ */
256
+ normalize(_typeClass: ModelSchema, hash: Record<string, unknown>): SingleResourceDocument | EmptyResourceDocument;
257
257
  }
258
- //# sourceMappingURL=serializer.d.ts.map
@@ -129,7 +129,7 @@ class SnapshotRecordArray {
129
129
  }
130
130
  ```
131
131
  @public
132
- @return {Array} Array of snapshots
132
+ @return Array of snapshots
133
133
  */
134
134
  snapshots() {
135
135
  if (this._snapshots !== null) {
@@ -1 +1 @@
1
- export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-BxfqWC8u.js";
1
+ export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-Bp58npke.js";
@@ -1,15 +1,23 @@
1
1
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
2
2
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
3
+
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
6
+
3
7
  function _AdapterError(errors, message = 'Adapter operation failed') {
4
8
  this.isAdapterError = true;
5
9
  const error = Error.call(this, message);
6
10
  if (error) {
7
11
  this.stack = error.stack;
12
+ // @ts-expect-error untyped
8
13
  this.description = error.description;
14
+ // @ts-expect-error untyped
9
15
  this.fileName = error.fileName;
16
+ // @ts-expect-error untyped
10
17
  this.lineNumber = error.lineNumber;
11
18
  this.message = error.message;
12
19
  this.name = error.name;
20
+ // @ts-expect-error untyped
13
21
  this.number = error.number;
14
22
  }
15
23
  this.errors = errors || [{
@@ -37,6 +45,7 @@ function extend(ParentErrorClass, defaultMessage) {
37
45
  })(Array.isArray(errors || [])) : {};
38
46
  ParentErrorClass.call(this, errors, message || defaultMessage);
39
47
  };
48
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
40
49
  ErrorClass.prototype = Object.create(ParentErrorClass.prototype);
41
50
  ErrorClass.extend = extendFn(ErrorClass);
42
51
  return ErrorClass;
@@ -102,6 +111,7 @@ function extend(ParentErrorClass, defaultMessage) {
102
111
  @public
103
112
  */
104
113
  // TODO @deprecate extractError documentation
114
+
105
115
  const InvalidError = getOrSetGlobal('InvalidError', extend(AdapterError, 'The adapter rejected the commit because it was invalid'));
106
116
  InvalidError.prototype.code = 'InvalidError';
107
117
 
@@ -133,6 +143,7 @@ InvalidError.prototype.code = 'InvalidError';
133
143
  @class TimeoutError
134
144
  @public
135
145
  */
146
+
136
147
  const TimeoutError = getOrSetGlobal('TimeoutError', extend(AdapterError, 'The adapter operation timed out'));
137
148
  TimeoutError.prototype.code = 'TimeoutError';
138
149
 
@@ -145,6 +156,7 @@ TimeoutError.prototype.code = 'TimeoutError';
145
156
  @class AbortError
146
157
  @public
147
158
  */
159
+
148
160
  const AbortError = getOrSetGlobal('AbortError', extend(AdapterError, 'The adapter operation was aborted'));
149
161
  AbortError.prototype.code = 'AbortError';
150
162
 
@@ -177,6 +189,7 @@ AbortError.prototype.code = 'AbortError';
177
189
  @class UnauthorizedError
178
190
  @public
179
191
  */
192
+
180
193
  const UnauthorizedError = getOrSetGlobal('UnauthorizedError', extend(AdapterError, 'The adapter operation is unauthorized'));
181
194
  UnauthorizedError.prototype.code = 'UnauthorizedError';
182
195
 
@@ -190,6 +203,7 @@ UnauthorizedError.prototype.code = 'UnauthorizedError';
190
203
  @class ForbiddenError
191
204
  @public
192
205
  */
206
+
193
207
  const ForbiddenError = getOrSetGlobal('ForbiddenError', extend(AdapterError, 'The adapter operation is forbidden'));
194
208
  ForbiddenError.prototype.code = 'ForbiddenError';
195
209
 
@@ -225,6 +239,7 @@ ForbiddenError.prototype.code = 'ForbiddenError';
225
239
  @class NotFoundError
226
240
  @public
227
241
  */
242
+
228
243
  const NotFoundError = getOrSetGlobal('NotFoundError', extend(AdapterError, 'The adapter could not find the resource'));
229
244
  NotFoundError.prototype.code = 'NotFoundError';
230
245
 
@@ -238,6 +253,7 @@ NotFoundError.prototype.code = 'NotFoundError';
238
253
  @class ConflictError
239
254
  @public
240
255
  */
256
+
241
257
  const ConflictError = getOrSetGlobal('ConflictError', extend(AdapterError, 'The adapter operation failed due to a conflict'));
242
258
  ConflictError.prototype.code = 'ConflictError';
243
259
 
@@ -249,6 +265,7 @@ ConflictError.prototype.code = 'ConflictError';
249
265
  @class ServerError
250
266
  @public
251
267
  */
268
+
252
269
  const ServerError = getOrSetGlobal('ServerError', extend(AdapterError, 'The adapter operation failed due to a server error'));
253
270
  ServerError.prototype.code = 'ServerError';
254
271
  export { AbortError, AdapterError, ConflictError, ForbiddenError, InvalidError, NotFoundError, ServerError, TimeoutError, UnauthorizedError };
@@ -1,7 +1,7 @@
1
1
  import { dasherize, pluralize } from '@warp-drive/utilities/string';
2
2
  import '@ember/debug';
3
3
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
- import { b as serializeIntoHash } from "../serialize-into-hash-BxfqWC8u.js";
4
+ import { b as serializeIntoHash } from "../serialize-into-hash-Bp58npke.js";
5
5
  import { RESTAdapter } from './rest.js';
6
6
  class JSONAPIAdapter extends RESTAdapter {
7
7
  _defaultContentType = 'application/vnd.api+json';
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application';
2
2
  import { warn } from '@ember/debug';
3
3
  import { computed } from '@ember/object';
4
4
  import { Adapter, BuildURLMixin } from '../adapter.js';
5
- import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-BxfqWC8u.js";
5
+ import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-Bp58npke.js";
6
6
  import { InvalidError, ServerError, ConflictError, NotFoundError, ForbiddenError, UnauthorizedError, AdapterError, TimeoutError, AbortError } from './error.js';
7
7
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
8
8
  import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
@@ -11,6 +11,8 @@ import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
11
11
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
12
12
  /* eslint-disable @typescript-eslint/no-unsafe-return */
13
13
 
14
+ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
15
+
14
16
  /**
15
17
  * <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
16
18
  <p>
@@ -238,7 +240,7 @@ import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
238
240
  @constructor
239
241
  @uses BuildURLMixin
240
242
  */
241
- class RESTAdapter extends Adapter.extend(BuildURLMixin) {
243
+ class RESTAdapter extends AdapterWithBuildURLMixin {
242
244
  /**
243
245
  This property allows ajax to still be used instead when `false`.
244
246
  @property useFetch
@@ -600,11 +602,6 @@ class RESTAdapter extends Adapter.extend(BuildURLMixin) {
600
602
  * Links beginning with a single `/` will have the current adapter's `host` value prepended to it.
601
603
  * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`.
602
604
  @public
603
- @param {Store} store
604
- @param {Snapshot} snapshot
605
- @param {String} url
606
- @param {Object} relationship meta object describing the relationship
607
- @return {Promise} promise
608
605
  */
609
606
  findBelongsTo(store, snapshot, url, relationship) {
610
607
  const id = snapshot.id;
@@ -779,6 +776,7 @@ class RESTAdapter extends Adapter.extend(BuildURLMixin) {
779
776
  if (this.isSuccess(status, headers, payload)) {
780
777
  return payload;
781
778
  } else if (this.isInvalid(status, headers, payload)) {
779
+ // @ts-expect-error needs cast to JsonApiError
782
780
  return new InvalidError(typeof payload === 'object' && 'errors' in payload ? payload.errors : undefined);
783
781
  }
784
782
  const errors = this.normalizeErrorResponse(status, headers, payload);