@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.
- package/declarations/adapter/-private/build-url-mixin.d.ts +41 -29
- package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
- package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
- package/declarations/adapter/-private.d.ts +5 -6
- package/declarations/adapter/error.d.ts +206 -178
- package/declarations/adapter/json-api.d.ts +206 -207
- package/declarations/adapter/rest.d.ts +805 -808
- package/declarations/adapter.d.ts +742 -766
- package/declarations/compat/-private.d.ts +10 -11
- package/declarations/compat/builders/find-all.d.ts +26 -24
- package/declarations/compat/builders/find-record.d.ts +41 -39
- package/declarations/compat/builders/query.d.ts +50 -45
- package/declarations/compat/builders/save-record.d.ts +26 -24
- package/declarations/compat/builders/utils.d.ts +1 -2
- package/declarations/compat/builders.d.ts +10 -11
- package/declarations/compat/extensions.d.ts +52 -106
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
- package/declarations/compat/utils.d.ts +118 -119
- package/declarations/compat.d.ts +106 -104
- package/declarations/model/-private/attr.d.ts +164 -145
- package/declarations/model/-private/belongs-to.d.ts +135 -122
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/model/-private/errors.d.ts +272 -267
- package/declarations/model/-private/has-many.d.ts +119 -116
- package/declarations/model/-private/hooks.d.ts +5 -6
- package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
- package/declarations/model/-private/model-for-mixin.d.ts +18 -3
- package/declarations/model/-private/model-methods.d.ts +29 -24
- package/declarations/model/-private/model.d.ts +1306 -1254
- package/declarations/model/-private/notify-changes.d.ts +3 -4
- package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
- package/declarations/model/-private/promise-many-array.d.ts +125 -116
- package/declarations/model/-private/record-state.d.ts +63 -60
- package/declarations/model/-private/references/belongs-to.d.ts +491 -487
- package/declarations/model/-private/references/has-many.d.ts +495 -492
- package/declarations/model/-private/schema-provider.d.ts +53 -56
- package/declarations/model/-private/type-utils.d.ts +41 -41
- package/declarations/model/-private/util.d.ts +1 -2
- package/declarations/model/-private.d.ts +8 -8
- package/declarations/model/migration-support.d.ts +281 -279
- package/declarations/model.d.ts +48 -49
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
- package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
- package/declarations/serializer/-private/transforms/date.d.ts +22 -22
- package/declarations/serializer/-private/transforms/number.d.ts +22 -22
- package/declarations/serializer/-private/transforms/string.d.ts +22 -22
- package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
- package/declarations/serializer/-private/utils.d.ts +0 -1
- package/declarations/serializer/json-api.d.ts +124 -494
- package/declarations/serializer/json.d.ts +62 -1031
- package/declarations/serializer/rest.d.ts +52 -552
- package/declarations/serializer/transform.d.ts +5 -6
- package/declarations/serializer.d.ts +217 -218
- package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +17 -0
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +5 -7
- package/dist/adapter.js +6 -35
- package/dist/compat/-private.js +1 -1
- package/dist/compat/extensions.js +0 -2
- package/dist/compat.js +3 -4
- package/dist/{errors-_QQ7xpSn.js → errors-BX5wowuz.js} +11 -10
- package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +3 -4
- package/dist/model.js +3 -3
- package/dist/{schema-provider-D_P8ReX6.js → schema-provider-BdQhkT-Q.js} +20 -13
- package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
- package/dist/serializer/json-api.js +42 -2
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +46 -41
- package/dist/serializer/transform.js +0 -44
- package/package.json +7 -7
- package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
- package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
- package/declarations/adapter/-private.d.ts.map +0 -1
- package/declarations/adapter/error.d.ts.map +0 -1
- package/declarations/adapter/json-api.d.ts.map +0 -1
- package/declarations/adapter/rest.d.ts.map +0 -1
- package/declarations/adapter.d.ts.map +0 -1
- package/declarations/compat/-private.d.ts.map +0 -1
- package/declarations/compat/builders/find-all.d.ts.map +0 -1
- package/declarations/compat/builders/find-record.d.ts.map +0 -1
- package/declarations/compat/builders/query.d.ts.map +0 -1
- package/declarations/compat/builders/save-record.d.ts.map +0 -1
- package/declarations/compat/builders/utils.d.ts.map +0 -1
- package/declarations/compat/builders.d.ts.map +0 -1
- package/declarations/compat/extensions.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
- package/declarations/compat/utils.d.ts.map +0 -1
- package/declarations/compat.d.ts.map +0 -1
- package/declarations/model/-private/attr.d.ts.map +0 -1
- package/declarations/model/-private/attr.type-test.d.ts +0 -2
- package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
- package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/model/-private/errors.d.ts.map +0 -1
- package/declarations/model/-private/has-many.d.ts.map +0 -1
- package/declarations/model/-private/has-many.type-test.d.ts +0 -2
- package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
- package/declarations/model/-private/hooks.d.ts.map +0 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
- package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
- package/declarations/model/-private/model-methods.d.ts.map +0 -1
- package/declarations/model/-private/model.d.ts.map +0 -1
- package/declarations/model/-private/model.type-test.d.ts +0 -2
- package/declarations/model/-private/model.type-test.d.ts.map +0 -1
- package/declarations/model/-private/notify-changes.d.ts.map +0 -1
- package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
- package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
- package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
- package/declarations/model/-private/record-state.d.ts.map +0 -1
- package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/references/has-many.d.ts.map +0 -1
- package/declarations/model/-private/schema-provider.d.ts.map +0 -1
- package/declarations/model/-private/type-utils.d.ts.map +0 -1
- package/declarations/model/-private/util.d.ts.map +0 -1
- package/declarations/model/-private.d.ts.map +0 -1
- package/declarations/model/migration-support.d.ts.map +0 -1
- package/declarations/model/migration-support.type-test.d.ts +0 -2
- package/declarations/model/migration-support.type-test.d.ts.map +0 -1
- package/declarations/model.d.ts.map +0 -1
- package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
- package/declarations/serializer/-private/utils.d.ts.map +0 -1
- package/declarations/serializer/json-api.d.ts.map +0 -1
- package/declarations/serializer/json.d.ts.map +0 -1
- package/declarations/serializer/rest.d.ts.map +0 -1
- package/declarations/serializer/transform.d.ts.map +0 -1
- package/declarations/serializer.d.ts.map +0 -1
- package/dist/-private-DFfBszo5.js.map +0 -1
- package/dist/adapter/-private.js.map +0 -1
- package/dist/adapter/error.js.map +0 -1
- package/dist/adapter/json-api.js.map +0 -1
- package/dist/adapter/rest.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/compat/-private.js.map +0 -1
- package/dist/compat/builders.js.map +0 -1
- package/dist/compat/extensions.js.map +0 -1
- package/dist/compat/utils.js.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/errors-_QQ7xpSn.js.map +0 -1
- package/dist/json-DSOlH9A8.js.map +0 -1
- package/dist/model/-private.js.map +0 -1
- package/dist/model/migration-support.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
- package/dist/schema-provider-D_P8ReX6.js.map +0 -1
- package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
- package/dist/serializer/json-api.js.map +0 -1
- package/dist/serializer/json.js.map +0 -1
- package/dist/serializer/rest.js.map +0 -1
- package/dist/serializer/transform.js.map +0 -1
- package/dist/serializer.js.map +0 -1
|
@@ -1,234 +1,233 @@
|
|
|
1
|
-
import type { Store } from
|
|
2
|
-
import type { ModelSchema } from
|
|
3
|
-
import type { HTTPMethod } from
|
|
4
|
-
import type { AdapterPayload } from
|
|
5
|
-
import type { Snapshot, SnapshotRecordArray } from
|
|
6
|
-
import type { FetchRequestInit, JQueryRequestInit, QueryState } from
|
|
7
|
-
import { RESTAdapter } from
|
|
1
|
+
import type { Store } from "@warp-drive/core";
|
|
2
|
+
import type { ModelSchema } from "@warp-drive/core/types";
|
|
3
|
+
import type { HTTPMethod } from "@warp-drive/core/types/request";
|
|
4
|
+
import type { AdapterPayload } from "../compat.js";
|
|
5
|
+
import type { Snapshot, SnapshotRecordArray } from "../compat/-private.js";
|
|
6
|
+
import type { FetchRequestInit, JQueryRequestInit, QueryState } from "./rest.js";
|
|
7
|
+
import { RESTAdapter } from "./rest.js";
|
|
8
8
|
/**
|
|
9
|
-
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
<blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
|
|
12
|
+
<p>
|
|
13
|
+
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
14
|
+
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
15
|
+
<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>
|
|
16
|
+
</p>
|
|
17
|
+
</blockquote>
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
The `JSONAPIAdapter` is an adapter whichtransforms the store's
|
|
20
|
+
requests into HTTP requests that follow the [JSON API format](http://jsonapi.org/format/).
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## JSON API Conventions
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
The JSONAPIAdapter uses JSON API conventions for building the URL
|
|
25
|
+
for a record and selecting the HTTP verb to use with a request. The
|
|
26
|
+
actions you can take on a record map onto the following URLs in the
|
|
27
|
+
JSON API adapter:
|
|
28
28
|
|
|
29
29
|
<table>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
30
|
+
<tr>
|
|
31
|
+
<th>
|
|
32
|
+
Action
|
|
33
|
+
</th>
|
|
34
|
+
<th>
|
|
35
|
+
HTTP Verb
|
|
36
|
+
</th>
|
|
37
|
+
<th>
|
|
38
|
+
URL
|
|
39
|
+
</th>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<th>
|
|
43
|
+
`store.findRecord('post', 123)`
|
|
44
|
+
</th>
|
|
45
|
+
<td>
|
|
46
|
+
GET
|
|
47
|
+
</td>
|
|
48
|
+
<td>
|
|
49
|
+
/posts/123
|
|
50
|
+
</td>
|
|
51
|
+
</tr>
|
|
52
|
+
<tr>
|
|
53
|
+
<th>
|
|
54
|
+
`store.findAll('post')`
|
|
55
|
+
</th>
|
|
56
|
+
<td>
|
|
57
|
+
GET
|
|
58
|
+
</td>
|
|
59
|
+
<td>
|
|
60
|
+
/posts
|
|
61
|
+
</td>
|
|
62
|
+
</tr>
|
|
63
|
+
<tr>
|
|
64
|
+
<th>
|
|
65
|
+
Update `postRecord.save()`
|
|
66
|
+
</th>
|
|
67
|
+
<td>
|
|
68
|
+
PATCH
|
|
69
|
+
</td>
|
|
70
|
+
<td>
|
|
71
|
+
/posts/123
|
|
72
|
+
</td>
|
|
73
|
+
</tr>
|
|
74
|
+
<tr>
|
|
75
|
+
<th>
|
|
76
|
+
Create `store.createRecord('post').save()`
|
|
77
|
+
</th>
|
|
78
|
+
<td>
|
|
79
|
+
POST
|
|
80
|
+
</td>
|
|
81
|
+
<td>
|
|
82
|
+
/posts
|
|
83
|
+
</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<th>
|
|
87
|
+
Delete `postRecord.destroyRecord()`
|
|
88
|
+
</th>
|
|
89
|
+
<td>
|
|
90
|
+
DELETE
|
|
91
|
+
</td>
|
|
92
|
+
<td>
|
|
93
|
+
/posts/123
|
|
94
|
+
</td>
|
|
95
|
+
</tr>
|
|
96
96
|
</table>
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
## Success and failure
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
The JSONAPIAdapter will consider a success any response with a
|
|
101
|
+
status code of the 2xx family ("Success"), as well as 304 ("Not
|
|
102
|
+
Modified"). Any other status code will be considered a failure.
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
On success, the request promise will be resolved with the full
|
|
105
|
+
response payload.
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
Failed responses with status code 422 ("Unprocessable Entity") will
|
|
108
|
+
be considered "invalid". The response will be discarded, except for
|
|
109
|
+
the `errors` key. The request promise will be rejected with a
|
|
110
|
+
`InvalidError`. This error object will encapsulate the saved
|
|
111
|
+
`errors` value.
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
Any other status codes will be treated as an adapter error. The
|
|
114
|
+
request promise will be rejected, similarly to the invalid case,
|
|
115
|
+
but with an instance of `AdapterError` instead.
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
### Endpoint path customization
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
Endpoint paths can be prefixed with a `namespace` by setting the
|
|
120
|
+
namespace property on the adapter:
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
```js [app/adapters/application.js]
|
|
123
|
+
import JSONAPIAdapter from '@ember-data/adapter/json-api';
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
export default class ApplicationAdapter extends JSONAPIAdapter {
|
|
126
|
+
namespace = 'api/1';
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
Requests for the `person` model would now target `/api/1/people/1`.
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
### Host customization
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
An adapter can target other hosts by setting the `host` property.
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
```js [app/adapters/application.js]
|
|
136
|
+
import JSONAPIAdapter from '@ember-data/adapter/json-api';
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
export default class ApplicationAdapter extends JSONAPIAdapter {
|
|
139
|
+
host = 'https://api.example.com';
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
Requests for the `person` model would now target
|
|
144
|
+
`https://api.example.com/people/1`.
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
@since 1.13.0
|
|
147
|
+
@class JSONAPIAdapter
|
|
148
|
+
@public
|
|
149
|
+
@constructor
|
|
150
150
|
*/
|
|
151
151
|
declare class JSONAPIAdapter extends RESTAdapter {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
152
|
+
_defaultContentType: string;
|
|
153
|
+
/**
|
|
154
|
+
@private
|
|
155
|
+
@param {String} url
|
|
156
|
+
@param {String} type The request type GET, POST, PUT, DELETE etc.
|
|
157
|
+
@param {Object} options
|
|
158
|
+
@return {Object}
|
|
159
|
+
*/
|
|
160
|
+
ajaxOptions(url: string, type: HTTPMethod, options?: JQueryAjaxSettings | RequestInit): JQueryRequestInit | FetchRequestInit;
|
|
161
|
+
/**
|
|
162
|
+
By default the JSONAPIAdapter will send each find request coming from a `store.find`
|
|
163
|
+
or from accessing a relationship separately to the server. If your server supports passing
|
|
164
|
+
ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests
|
|
165
|
+
within a single runloop.
|
|
166
|
+
|
|
167
|
+
For example, if you have an initial payload of:
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
{
|
|
171
|
+
data: {
|
|
172
|
+
id: 1,
|
|
173
|
+
type: 'post',
|
|
174
|
+
relationship: {
|
|
175
|
+
comments: {
|
|
176
|
+
data: [
|
|
177
|
+
{ id: 1, type: 'comment' },
|
|
178
|
+
{ id: 2, type: 'comment' }
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
By default calling `post.comments` will trigger the following requests(assuming the
|
|
187
|
+
comments haven't been loaded before):
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
GET /comments/1
|
|
191
|
+
GET /comments/2
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
If you set coalesceFindRequests to `true` it will instead trigger the following request:
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
GET /comments?filter[id]=1,2
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo`
|
|
201
|
+
relationships accessed within the same runloop. If you set `coalesceFindRequests: true`
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
store.findRecord('comment', 1);
|
|
205
|
+
store.findRecord('comment', 2);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
will also send a request to: `GET /comments?filter[id]=1,2`
|
|
209
|
+
|
|
210
|
+
Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app
|
|
211
|
+
`groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work.
|
|
212
|
+
|
|
213
|
+
@property coalesceFindRequests
|
|
214
|
+
@public
|
|
215
|
+
@type {Boolean}
|
|
216
|
+
*/
|
|
217
|
+
get coalesceFindRequests(): boolean;
|
|
218
|
+
set coalesceFindRequests(value: boolean);
|
|
219
|
+
findMany(store: Store, type: ModelSchema, ids: string[], snapshots: Snapshot[]): Promise<AdapterPayload>;
|
|
220
|
+
pathForType(modelName: string): string;
|
|
221
|
+
updateRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
222
|
+
/**
|
|
223
|
+
Used by `findAll` and `findRecord` to build the query's `data` hash
|
|
224
|
+
supplied to the ajax method.
|
|
225
|
+
|
|
226
|
+
@since 2.5.0
|
|
227
|
+
@public
|
|
228
|
+
@param {Snapshot} snapshot
|
|
229
|
+
@return {Object}
|
|
230
|
+
*/
|
|
231
|
+
buildQuery(snapshot: Snapshot | SnapshotRecordArray): QueryState;
|
|
232
232
|
}
|
|
233
233
|
export { JSONAPIAdapter };
|
|
234
|
-
//# sourceMappingURL=json-api.d.ts.map
|