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

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,34 +1,46 @@
1
- import Mixin from '@ember/object/mixin';
2
- import type { Snapshot, SnapshotRecordArray } from '../../compat/-private.ts';
1
+ import Mixin from "@ember/object/mixin";
2
+ import type { Snapshot, SnapshotRecordArray } from "../../compat/-private.js";
3
+ /*
4
+ The structure of this file is such because typing Mixins is hard. Here we've structured it in
5
+ such a way as to maximize the type information that a consumer can utilize. There are simpler
6
+ ways to type a mixin but we would not be able to provide the nice overload signature for buildURL
7
+ */
8
+ // the interface must fully declare the function signatures that the individual functions
9
+ // will also declare. If instead we try to keep them in sync by doing something like
10
+ // `interface BuildURLMixin { buildURL: typeof buildURL }`
11
+ // then an extending class overwriting one of the methods will break because typescript
12
+ // thinks it is a switch from an instance prop (that is a method) to an instance method.
3
13
  export interface BuildURLMixin {
4
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: 'findRecord'): string;
5
- buildURL(this: MixtBuildURLMixin, modelName: string, id: null, snapshot: SnapshotRecordArray, requestType: 'findAll'): string;
6
- buildURL(this: MixtBuildURLMixin, modelName: string, id: null, snapshot: null, requestType: 'query', query: Record<string, unknown>): string;
7
- buildURL(this: MixtBuildURLMixin, modelName: string, id: null, snapshot: null, requestType: 'queryRecord', query: Record<string, unknown>): string;
8
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string[], snapshot: Snapshot[], requestType: 'findMany'): string;
9
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: 'findHasMany'): string;
10
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: 'findBelongsTo'): string;
11
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string | null, snapshot: Snapshot, requestType: 'createRecord'): string;
12
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: 'updateRecord'): string;
13
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: 'deleteRecord'): string;
14
- buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot): string;
15
- _buildURL(this: MixtBuildURLMixin, modelName: string | null | undefined, id?: string | null): string;
16
- urlForFindRecord(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
17
- urlForFindAll(this: MixtBuildURLMixin, modelName: string, snapshots: SnapshotRecordArray): string;
18
- urlForQueryRecord(this: MixtBuildURLMixin, query: Record<string, unknown>, modelName: string): string;
19
- urlForQuery(this: MixtBuildURLMixin, query: Record<string, unknown>, modelName: string): string;
20
- urlForFindMany(this: MixtBuildURLMixin, ids: string[], modelName: string, snapshots: Snapshot[]): string;
21
- urlForFindHasMany(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
22
- urlForFindBelongsTo(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
23
- urlForCreateRecord(this: MixtBuildURLMixin, modelName: string, snapshot: Snapshot): string;
24
- urlForUpdateRecord(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
25
- urlForDeleteRecord(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
26
- urlPrefix(this: MixtBuildURLMixin, path?: string | null, parentURL?: string): string;
27
- pathForType(this: MixtBuildURLMixin, modelName: string): string;
14
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: "findRecord"): string;
15
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: null, snapshot: SnapshotRecordArray, requestType: "findAll"): string;
16
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: null, snapshot: null, requestType: "query", query: Record<string, unknown>): string;
17
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: null, snapshot: null, requestType: "queryRecord", query: Record<string, unknown>): string;
18
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string[], snapshot: Snapshot[], requestType: "findMany"): string;
19
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: "findHasMany"): string;
20
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: "findBelongsTo"): string;
21
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string | null, snapshot: Snapshot, requestType: "createRecord"): string;
22
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: "updateRecord"): string;
23
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot, requestType: "deleteRecord"): string;
24
+ buildURL(this: MixtBuildURLMixin, modelName: string, id: string, snapshot: Snapshot): string;
25
+ _buildURL(this: MixtBuildURLMixin, modelName: string | null | undefined, id?: string | null): string;
26
+ urlForFindRecord(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
27
+ urlForFindAll(this: MixtBuildURLMixin, modelName: string, snapshots: SnapshotRecordArray): string;
28
+ urlForQueryRecord(this: MixtBuildURLMixin, query: Record<string, unknown>, modelName: string): string;
29
+ urlForQuery(this: MixtBuildURLMixin, query: Record<string, unknown>, modelName: string): string;
30
+ urlForFindMany(this: MixtBuildURLMixin, ids: string[], modelName: string, snapshots: Snapshot[]): string;
31
+ urlForFindHasMany(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
32
+ urlForFindBelongsTo(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
33
+ urlForCreateRecord(this: MixtBuildURLMixin, modelName: string, snapshot: Snapshot): string;
34
+ urlForUpdateRecord(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
35
+ urlForDeleteRecord(this: MixtBuildURLMixin, id: string, modelName: string, snapshot: Snapshot): string;
36
+ urlPrefix(this: MixtBuildURLMixin, path?: string | null, parentURL?: string): string;
37
+ pathForType(this: MixtBuildURLMixin, modelName: string): string;
28
38
  }
39
+ // prevents the final constructed object from needing to add
40
+ // host and namespace which are provided by the final consuming
41
+ // class to the prototype which can result in overwrite errors
29
42
  export interface MixtBuildURLMixin extends BuildURLMixin {
30
- host: string | null;
31
- namespace: string | null;
43
+ host: string | null;
44
+ namespace: string | null;
32
45
  }
33
46
  export declare const BuildURLMixin: Mixin;
34
- //# sourceMappingURL=build-url-mixin.d.ts.map
@@ -1,9 +1,8 @@
1
1
  export interface Request {
2
- protocol: string;
3
- host: string;
2
+ protocol: string;
3
+ host: string;
4
4
  }
5
5
  export interface FastBoot {
6
- isFastBoot: boolean;
7
- request: Request;
6
+ isFastBoot: boolean;
7
+ request: Request;
8
8
  }
9
- //# sourceMappingURL=fastboot-interface.d.ts.map
@@ -1,8 +1,7 @@
1
1
  /**
2
- * A utility function that returns a promise that resolves
3
- * even when the source promise rejects.
4
- *
5
- * @internal
6
- */
2
+ * A utility function that returns a promise that resolves
3
+ * even when the source promise rejects.
4
+ *
5
+ * @internal
6
+ */
7
7
  export declare function continueOnReject<T>(promise: Promise<T>): Promise<T>;
8
- //# sourceMappingURL=continue-on-reject.d.ts.map
@@ -1,5 +1,4 @@
1
- import type { RequestData } from '../../rest.ts';
1
+ import type { RequestData } from "../../rest.js";
2
2
  type Payload = Error | Record<string, unknown> | unknown[] | string | undefined;
3
3
  export declare function determineBodyPromise(response: Response, requestData: RequestData): Promise<Payload>;
4
4
  export {};
5
- //# sourceMappingURL=determine-body-promise.d.ts.map
@@ -1,9 +1,8 @@
1
1
  type FetchFunction = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
2
2
  type MockRequest = {
3
- protocol?: string;
4
- get(key: string): string | undefined;
3
+ protocol?: string;
4
+ get(key: string): string | undefined;
5
5
  };
6
6
  export declare function getFetchFunction(): FetchFunction;
7
7
  export declare function setupFastboot(fastBootRequest: MockRequest): void;
8
8
  export {};
9
- //# sourceMappingURL=fetch.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare function parseResponseHeaders(headersString: string): Record<string, string>;
2
- //# sourceMappingURL=parse-response-headers.d.ts.map
@@ -1,7 +1,6 @@
1
- import type { Store } from '@warp-drive/core';
2
- import type { ModelSchema } from '@warp-drive/core/types';
3
- import { type Snapshot } from '../../../compat/-private.ts';
1
+ import type { Store } from "@warp-drive/core";
2
+ import type { ModelSchema } from "@warp-drive/core/types";
3
+ import { type Snapshot } from "../../../compat/-private.js";
4
4
  export declare function serializeIntoHash(store: Store, modelClass: ModelSchema, snapshot: Snapshot, options?: {
5
- includeId?: boolean;
6
- }): {};
7
- //# sourceMappingURL=serialize-into-hash.d.ts.map
5
+ includeId?: boolean;
6
+ }): object;
@@ -1,6 +1,9 @@
1
1
  interface PlainObject {
2
- [key: string]: string | PlainObject | PlainObject[] | string[];
2
+ [key: string]: string | PlainObject | PlainObject[] | string[];
3
3
  }
4
+ /*
5
+ * Helper function that turns the data/body of a request into a query param string.
6
+ * This is directly copied from jQuery.param.
7
+ */
4
8
  export declare function serializeQueryParams(queryParamsObject: PlainObject | string): string;
5
9
  export {};
6
- //# sourceMappingURL=serialize-query-params.d.ts.map
@@ -1,6 +1,5 @@
1
- export { parseResponseHeaders } from './-private/utils/parse-response-headers.ts';
2
- export { determineBodyPromise } from './-private/utils/determine-body-promise.ts';
3
- export { serializeQueryParams } from './-private/utils/serialize-query-params.ts';
4
- export { getFetchFunction as fetch, setupFastboot } from './-private/utils/fetch.ts';
5
- export { serializeIntoHash } from './-private/utils/serialize-into-hash.ts';
6
- //# sourceMappingURL=-private.d.ts.map
1
+ export { parseResponseHeaders } from "./-private/utils/parse-response-headers.js";
2
+ export { determineBodyPromise } from "./-private/utils/determine-body-promise.js";
3
+ export { serializeQueryParams } from "./-private/utils/serialize-query-params.js";
4
+ export { getFetchFunction as fetch, setupFastboot } from "./-private/utils/fetch.js";
5
+ export { serializeIntoHash } from "./-private/utils/serialize-into-hash.js";
@@ -1,188 +1,216 @@
1
- export const AdapterError: typeof _AdapterError;
2
- export class InvalidError {
3
- private constructor();
4
- code: string;
1
+ import type { JsonApiError } from "@warp-drive/core/store/-types/q/record-data-json-api";
2
+ export interface AdapterRequestError<T extends string = string> extends Error {
3
+ isAdapterError: true;
4
+ code: T;
5
+ errors: JsonApiError[];
5
6
  }
6
- export class TimeoutError {
7
- private constructor();
8
- code: string;
7
+ export interface AdapterRequestErrorConstructor<Instance extends AdapterRequestError = AdapterRequestError> {
8
+ new (errors?: unknown[], message?: string): Instance;
9
+ extend(options: {
10
+ message: string;
11
+ }): AdapterRequestErrorConstructor;
9
12
  }
10
- export class AbortError {
11
- private constructor();
12
- code: string;
13
+ export type AdapterError = AdapterRequestError<"AdapterError">;
14
+ export declare const AdapterError: AdapterRequestErrorConstructor<AdapterError>;
15
+ /**
16
+ A `InvalidError` is used by an adapter to signal the external API
17
+ was unable to process a request because the content was not
18
+ semantically correct or meaningful per the API. Usually, this means a
19
+ record failed some form of server-side validation. When a promise
20
+ from an adapter is rejected with a `InvalidError` the record will
21
+ transition to the `invalid` state and the errors will be set to the
22
+ `errors` property on the record.
23
+
24
+ For Ember Data to correctly map errors to their corresponding
25
+ properties on the model, Ember Data expects each error to be
26
+ a valid JSON-API error object with a `source/pointer` that matches
27
+ the property name. For example, if you had a Post model that
28
+ looked like this.
29
+
30
+ ```js [app/models/post.js]
31
+ import { Model, attr } from '@warp-drive/legacy/model';
32
+
33
+ export default class PostModel extends Model {
34
+ @attr('string') title;
35
+ @attr('string') content;
36
+ }
37
+ ```
38
+
39
+ To show an error from the server related to the `title` and
40
+ `content` properties your adapter could return a promise that
41
+ rejects with a `InvalidError` object that looks like this:
42
+
43
+ ```js [app/adapters/post.js]
44
+ import RSVP from 'RSVP';
45
+ import RESTAdapter from '@ember-data/adapter/rest';
46
+ import { InvalidError } from '@ember-data/adapter/error';
47
+
48
+ export default class ApplicationAdapter extends RESTAdapter {
49
+ updateRecord() {
50
+ // Fictional adapter that always rejects
51
+ return RSVP.reject(new InvalidError([
52
+ {
53
+ detail: 'Must be unique',
54
+ source: { pointer: '/data/attributes/title' }
55
+ },
56
+ {
57
+ detail: 'Must not be blank',
58
+ source: { pointer: '/data/attributes/content'}
59
+ }
60
+ ]));
61
+ }
62
+ }
63
+ ```
64
+
65
+ Your backend may use different property names for your records the
66
+ store will attempt to extract and normalize the errors using the
67
+ serializer's `extractErrors` method before the errors get added to
68
+ the model. As a result, it is safe for the `InvalidError` to
69
+ wrap the error payload unaltered.
70
+
71
+ @class InvalidError
72
+ @public
73
+ */
74
+ // TODO @deprecate extractError documentation
75
+ export type InvalidError = AdapterRequestError<"InvalidError">;
76
+ export declare const InvalidError: AdapterRequestErrorConstructor<InvalidError>;
77
+ /**
78
+ A `TimeoutError` is used by an adapter to signal that a request
79
+ to the external API has timed out. I.e. no response was received from
80
+ the external API within an allowed time period.
81
+
82
+ An example use case would be to warn the user to check their internet
83
+ connection if an adapter operation has timed out:
84
+
85
+ ```js [app/routes/application.js]
86
+ import { TimeoutError } from '@ember-data/adapter/error';
87
+
88
+ export default class ApplicationRoute extends Route {
89
+ @action
90
+ error(error, transition) {
91
+ if (error instanceof TimeoutError) {
92
+ // alert the user
93
+ alert('Are you still connected to the Internet?');
94
+ return;
95
+ }
96
+
97
+ // ...other error handling logic
98
+ }
99
+ }
100
+ ```
101
+
102
+ @class TimeoutError
103
+ @public
104
+ */
105
+ export type TimeoutError = AdapterRequestError<"TimeoutError">;
106
+ export declare const TimeoutError: AdapterRequestErrorConstructor<TimeoutError>;
107
+ /**
108
+ A `AbortError` is used by an adapter to signal that a request to
109
+ the external API was aborted. For example, this can occur if the user
110
+ navigates away from the current page after a request to the external API
111
+ has been initiated but before a response has been received.
112
+
113
+ @class AbortError
114
+ @public
115
+ */
116
+ export type AbortError = AdapterRequestError<"AbortError">;
117
+ export declare const AbortError: AdapterRequestErrorConstructor<AbortError>;
118
+ /**
119
+ A `UnauthorizedError` equates to a HTTP `401 Unauthorized` response
120
+ status. It is used by an adapter to signal that a request to the external
121
+ API was rejected because authorization is required and has failed or has not
122
+ yet been provided.
123
+
124
+ An example use case would be to redirect the user to a login route if a
125
+ request is unauthorized:
126
+
127
+ ```js [app/routes/application.js]
128
+ import { UnauthorizedError } from '@ember-data/adapter/error';
129
+
130
+ export default class ApplicationRoute extends Route {
131
+ @action
132
+ error(error, transition) {
133
+ if (error instanceof UnauthorizedError) {
134
+ // go to the login route
135
+ this.transitionTo('login');
136
+ return;
137
+ }
138
+
139
+ // ...other error handling logic
13
140
  }
14
- export class UnauthorizedError {
15
- private constructor();
16
- code: string;
17
141
  }
18
- export class ForbiddenError {
19
- private constructor();
20
- code: string;
142
+ ```
143
+
144
+ @class UnauthorizedError
145
+ @public
146
+ */
147
+ export type UnauthorizedError = AdapterRequestError<"UnauthorizedError">;
148
+ export declare const UnauthorizedError: AdapterRequestErrorConstructor<UnauthorizedError>;
149
+ /**
150
+ A `ForbiddenError` equates to a HTTP `403 Forbidden` response status.
151
+ It is used by an adapter to signal that a request to the external API was
152
+ valid but the server is refusing to respond to it. If authorization was
153
+ provided and is valid, then the authenticated user does not have the
154
+ necessary permissions for the request.
155
+
156
+ @class ForbiddenError
157
+ @public
158
+ */
159
+ export type ForbiddenError = AdapterRequestError<"ForbiddenError">;
160
+ export declare const ForbiddenError: AdapterRequestErrorConstructor<ForbiddenError>;
161
+ /**
162
+ A `NotFoundError` equates to a HTTP `404 Not Found` response status.
163
+ It is used by an adapter to signal that a request to the external API
164
+ was rejected because the resource could not be found on the API.
165
+
166
+ An example use case would be to detect if the user has entered a route
167
+ for a specific model that does not exist. For example:
168
+
169
+ ```js [app/routes/post.js]
170
+ import { NotFoundError } from '@ember-data/adapter/error';
171
+
172
+ export default class PostRoute extends Route {
173
+ @service store;
174
+ model(params) {
175
+ return this.store.findRecord('post', params.post_id);
21
176
  }
22
- export class NotFoundError {
23
- private constructor();
24
- code: string;
177
+ @action
178
+ error(error, transition) {
179
+ if (error instanceof NotFoundError) {
180
+ // redirect to a list of all posts instead
181
+ this.transitionTo('posts');
182
+ } else {
183
+ // otherwise let the error bubble
184
+ return true;
25
185
  }
26
- export class ConflictError {
27
- private constructor();
28
- code: string;
29
186
  }
30
- export class ServerError {
31
- private constructor();
32
- code: string;
33
187
  }
188
+ ```
189
+
190
+ @class NotFoundError
191
+ @public
192
+ */
193
+ export type NotFoundError = AdapterRequestError<"NotFoundError">;
194
+ export declare const NotFoundError: AdapterRequestErrorConstructor<NotFoundError>;
195
+ /**
196
+ A `ConflictError` equates to a HTTP `409 Conflict` response status.
197
+ It is used by an adapter to indicate that the request could not be processed
198
+ because of a conflict in the request. An example scenario would be when
199
+ creating a record with a client-generated ID but that ID is already known
200
+ to the external API.
201
+
202
+ @class ConflictError
203
+ @public
204
+ */
205
+ export type ConflictError = AdapterRequestError<"ConflictError">;
206
+ export declare const ConflictError: AdapterRequestErrorConstructor<ConflictError>;
34
207
  /**
35
- ## Overview
36
-
37
- <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
38
- <p>
39
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
40
- If starting a new app or thinking of implementing a new adapter, consider writing a
41
- <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>
42
- </p>
43
- </blockquote>
44
-
45
- An `AdapterError` is used by an adapter to signal that an error occurred
46
- during a request to an external API. It indicates a generic error, and
47
- subclasses are used to indicate specific error states.
48
-
49
- To create a custom error to signal a specific error state in communicating
50
- with an external API, extend the `AdapterError`. For example, if the
51
- external API exclusively used HTTP `503 Service Unavailable` to indicate
52
- it was closed for maintenance:
53
-
54
- ```js [app/adapters/maintenance-error.js]
55
- import AdapterError from '@ember-data/adapter/error';
56
-
57
- export default AdapterError.extend({ message: "Down for maintenance." });
58
- ```
59
-
60
- This error would then be returned by an adapter's `handleResponse` method:
61
-
62
- ```js [app/adapters/application.js]
63
- import JSONAPIAdapter from '@ember-data/adapter/json-api';
64
- import MaintenanceError from './maintenance-error';
65
-
66
- export default class ApplicationAdapter extends JSONAPIAdapter {
67
- handleResponse(status) {
68
- if (503 === status) {
69
- return new MaintenanceError();
70
- }
71
-
72
- return super.handleResponse(...arguments);
73
- }
74
- }
75
- ```
76
-
77
- And can then be detected in an application and used to send the user to an
78
- `under-maintenance` route:
79
-
80
- ```js [app/routes/application.js]
81
- import MaintenanceError from '../adapters/maintenance-error';
82
-
83
- export default class ApplicationRoute extends Route {
84
- actions: {
85
- error(error, transition) {
86
- if (error instanceof MaintenanceError) {
87
- this.transitionTo('under-maintenance');
88
- return;
89
- }
90
-
91
- // ...other error handling logic
92
- }
93
- }
94
- }
95
- ```
96
-
97
- @class AdapterError
98
- @public
208
+ A `ServerError` equates to a HTTP `500 Internal Server Error` response
209
+ status. It is used by the adapter to indicate that a request has failed
210
+ because of an error in the external API.
211
+
212
+ @class ServerError
213
+ @public
99
214
  */
100
- declare function _AdapterError(errors: any, message?: string): void;
101
- declare class _AdapterError {
102
- /**
103
- ## Overview
104
-
105
- <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
106
- <p>
107
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
108
- If starting a new app or thinking of implementing a new adapter, consider writing a
109
- <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>
110
- </p>
111
- </blockquote>
112
-
113
- An `AdapterError` is used by an adapter to signal that an error occurred
114
- during a request to an external API. It indicates a generic error, and
115
- subclasses are used to indicate specific error states.
116
-
117
- To create a custom error to signal a specific error state in communicating
118
- with an external API, extend the `AdapterError`. For example, if the
119
- external API exclusively used HTTP `503 Service Unavailable` to indicate
120
- it was closed for maintenance:
121
-
122
- ```js [app/adapters/maintenance-error.js]
123
- import AdapterError from '@ember-data/adapter/error';
124
-
125
- export default AdapterError.extend({ message: "Down for maintenance." });
126
- ```
127
-
128
- This error would then be returned by an adapter's `handleResponse` method:
129
-
130
- ```js [app/adapters/application.js]
131
- import JSONAPIAdapter from '@ember-data/adapter/json-api';
132
- import MaintenanceError from './maintenance-error';
133
-
134
- export default class ApplicationAdapter extends JSONAPIAdapter {
135
- handleResponse(status) {
136
- if (503 === status) {
137
- return new MaintenanceError();
138
- }
139
-
140
- return super.handleResponse(...arguments);
141
- }
142
- }
143
- ```
144
-
145
- And can then be detected in an application and used to send the user to an
146
- `under-maintenance` route:
147
-
148
- ```js [app/routes/application.js]
149
- import MaintenanceError from '../adapters/maintenance-error';
150
-
151
- export default class ApplicationRoute extends Route {
152
- actions: {
153
- error(error, transition) {
154
- if (error instanceof MaintenanceError) {
155
- this.transitionTo('under-maintenance');
156
- return;
157
- }
158
-
159
- // ...other error handling logic
160
- }
161
- }
162
- }
163
- ```
164
-
165
- @class AdapterError
166
- @public
167
- */
168
- constructor(errors: any, message?: string);
169
- isAdapterError: boolean;
170
- stack: string | undefined;
171
- description: any;
172
- fileName: any;
173
- lineNumber: any;
174
- message: string | undefined;
175
- name: string | undefined;
176
- number: any;
177
- errors: any;
178
- code: string;
179
- }
180
- declare namespace _AdapterError {
181
- function extend({ message: defaultMessage }?: {}): {
182
- (errors: any, message: any): void;
183
- prototype: any;
184
- extend: ({ message: defaultMessage }?: {}) => /*elided*/ any;
185
- };
186
- }
187
- export {};
188
- //# sourceMappingURL=error.d.ts.map
215
+ export type ServerError = AdapterRequestError<"ServerError">;
216
+ export declare const ServerError: AdapterRequestErrorConstructor<ServerError>;