@warp-drive/legacy 5.8.0-alpha.40 → 5.8.0-alpha.41
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/error.d.ts +2 -2
- package/declarations/adapter/rest.d.ts +21 -104
- package/declarations/adapter.d.ts +2 -2
- package/declarations/model/-private/model.d.ts +10 -51
- package/declarations/model/-private/promise-many-array.d.ts +0 -18
- package/declarations/model/-private/references/belongs-to.d.ts +14 -24
- package/declarations/model/-private/references/has-many.d.ts +11 -13
- package/declarations/serializer/json-api.d.ts +4 -3
- package/declarations/serializer/json.d.ts +2 -2
- package/dist/{-private-B1pSSN52.js → -private-BG3bMiKp.js} +2 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +2 -2
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +33 -117
- package/dist/adapter.js +2 -2
- package/dist/compat/-private.js +1 -1
- package/dist/compat.js +4 -3
- package/dist/{errors-CIGPcDvd.js → errors-Cz5KrzBk.js} +29 -58
- package/dist/{hooks-QqRnX108.js → hooks-D6diaM34.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/{json-BNrV8EYG.js → json-ChdEfB0X.js} +6 -19
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +7 -5
- package/dist/model.js +3 -3
- package/dist/{schema-provider-g5MfTj8n.js → schema-provider-DJCV_6AF.js} +34 -77
- package/dist/{serialize-into-hash-BnYvPex3.js → serialize-into-hash-DPZYoF-i.js} +1 -1
- package/dist/serializer/json-api.js +2 -2
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +1 -1
- package/dist/store.js +2 -1
- package/dist/unpkg/{dev-deprecated/-private-DbaSCSym.js → dev/-private-DtjBbEgy.js} +2 -1
- package/dist/unpkg/dev/adapter/-private.js +1 -1
- package/dist/unpkg/dev/adapter/error.js +2 -2
- package/dist/unpkg/dev/adapter/json-api.js +1 -1
- package/dist/unpkg/dev/adapter/rest.js +33 -117
- package/dist/unpkg/dev/adapter.js +2 -2
- package/dist/unpkg/dev/compat/-private.js +1 -1
- package/dist/unpkg/dev/compat.js +4 -3
- package/dist/unpkg/dev/{errors-DD96TBEs.js → errors-DmGGJr3T.js} +29 -58
- package/dist/unpkg/dev/{hooks-CqWjNWeL.js → hooks-CkYiE6Ud.js} +1 -1
- package/dist/unpkg/dev/index.js +3 -3
- package/dist/unpkg/{dev-deprecated/json-CCU-ZQ4b.js → dev/json-Cu1LNgmQ.js} +6 -19
- package/dist/unpkg/dev/model/-private.js +1 -1
- package/dist/unpkg/dev/model/migration-support.js +7 -5
- package/dist/unpkg/dev/model.js +3 -3
- package/dist/unpkg/dev/{schema-provider-B8jiJOYC.js → schema-provider-DDVYxmUV.js} +34 -77
- package/dist/unpkg/dev/{serialize-into-hash-CPAZXrQU.js → serialize-into-hash-B2xDbuo5.js} +1 -1
- package/dist/unpkg/dev/serializer/json-api.js +6 -5
- package/dist/unpkg/dev/serializer/json.js +1 -1
- package/dist/unpkg/dev/serializer/rest.js +1 -1
- package/dist/unpkg/dev/store.js +2 -1
- package/dist/unpkg/{dev/-private-DbaSCSym.js → dev-deprecated/-private-DtjBbEgy.js} +2 -1
- package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/adapter/error.js +2 -2
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +1 -1
- package/dist/unpkg/dev-deprecated/adapter/rest.js +33 -117
- package/dist/unpkg/dev-deprecated/adapter.js +2 -2
- package/dist/unpkg/dev-deprecated/compat/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/compat.js +4 -3
- package/dist/unpkg/dev-deprecated/{errors-DEnabIZj.js → errors-Spt6ubMd.js} +29 -58
- package/dist/unpkg/dev-deprecated/{hooks-CAll-Ets.js → hooks-DOXegvhL.js} +1 -1
- package/dist/unpkg/dev-deprecated/index.js +3 -3
- package/dist/unpkg/{dev/json-CCU-ZQ4b.js → dev-deprecated/json-Cu1LNgmQ.js} +6 -19
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/model/migration-support.js +7 -5
- package/dist/unpkg/dev-deprecated/model.js +3 -3
- package/dist/unpkg/dev-deprecated/{schema-provider-k2qXQTBg.js → schema-provider-BP6_8N-V.js} +34 -77
- package/dist/unpkg/dev-deprecated/{serialize-into-hash-CPAZXrQU.js → serialize-into-hash-B2xDbuo5.js} +1 -1
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +6 -5
- package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
- package/dist/unpkg/dev-deprecated/serializer/rest.js +1 -1
- package/dist/unpkg/dev-deprecated/store.js +2 -1
- package/dist/unpkg/{prod-deprecated/-private-Cvf_97EG.js → prod/-private-BdyZaGEh.js} +1 -0
- package/dist/unpkg/prod/adapter/-private.js +1 -1
- package/dist/unpkg/prod/adapter/error.js +2 -2
- package/dist/unpkg/prod/adapter/json-api.js +1 -1
- package/dist/unpkg/prod/adapter/rest.js +33 -117
- package/dist/unpkg/prod/adapter.js +2 -2
- package/dist/unpkg/prod/compat/-private.js +1 -1
- package/dist/unpkg/prod/compat.js +2 -1
- package/dist/unpkg/prod/{errors-CXnfnBfQ.js → errors-BGVFCBmi.js} +29 -58
- package/dist/unpkg/prod/{hooks-DvyWhLNg.js → hooks-BztVA_x0.js} +1 -1
- package/dist/unpkg/prod/index.js +3 -3
- package/dist/unpkg/prod/{json-BYrUP8ao.js → json-BWrZ5546.js} +6 -19
- package/dist/unpkg/prod/model/-private.js +1 -1
- package/dist/unpkg/prod/model/migration-support.js +7 -5
- package/dist/unpkg/prod/model.js +3 -3
- package/dist/unpkg/prod/{schema-provider-CHujJvA9.js → schema-provider-DJtD_8jZ.js} +34 -77
- package/dist/unpkg/{prod-deprecated/serialize-into-hash-DYU2egXl.js → prod/serialize-into-hash-DGlzQteF.js} +1 -1
- package/dist/unpkg/prod/serializer/json-api.js +6 -5
- package/dist/unpkg/prod/serializer/json.js +1 -1
- package/dist/unpkg/prod/serializer/rest.js +1 -1
- package/dist/unpkg/prod/store.js +2 -1
- package/dist/unpkg/{prod/-private-Cvf_97EG.js → prod-deprecated/-private-BdyZaGEh.js} +1 -0
- package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/adapter/error.js +2 -2
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +1 -1
- package/dist/unpkg/prod-deprecated/adapter/rest.js +33 -117
- package/dist/unpkg/prod-deprecated/adapter.js +2 -2
- package/dist/unpkg/prod-deprecated/compat/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/compat.js +2 -1
- package/dist/unpkg/prod-deprecated/{errors-CG1SPYVg.js → errors-CdDaK81x.js} +29 -58
- package/dist/unpkg/prod-deprecated/{hooks-BIUBiNGR.js → hooks-yId87yyG.js} +1 -1
- package/dist/unpkg/prod-deprecated/index.js +3 -3
- package/dist/unpkg/prod-deprecated/{json-BYrUP8ao.js → json-BWrZ5546.js} +6 -19
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/model/migration-support.js +7 -5
- package/dist/unpkg/prod-deprecated/model.js +3 -3
- package/dist/unpkg/prod-deprecated/{schema-provider-BJ4TWnZf.js → schema-provider-CjX55uSY.js} +34 -77
- package/dist/unpkg/{prod/serialize-into-hash-DYU2egXl.js → prod-deprecated/serialize-into-hash-DGlzQteF.js} +1 -1
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +6 -5
- package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
- package/dist/unpkg/prod-deprecated/serializer/rest.js +1 -1
- package/dist/unpkg/prod-deprecated/store.js +2 -1
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getOwner } from '@ember/application';
|
|
2
2
|
import { computed } from '@ember/object';
|
|
3
3
|
import { Adapter, BuildURLMixin } from '../adapter.js';
|
|
4
|
-
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-
|
|
4
|
+
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-DGlzQteF.js";
|
|
5
5
|
import { InvalidError, ServerError, ConflictError, NotFoundError, ForbiddenError, UnauthorizedError, AdapterError, TimeoutError, AbortError } from './error.js';
|
|
6
6
|
import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
|
7
7
|
|
|
@@ -87,7 +87,7 @@ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
|
87
87
|
Note that the object root can be pluralized for both a single-object response
|
|
88
88
|
and an array response: the REST adapter is not strict on this. Further, if the
|
|
89
89
|
HTTP server responds to a `GET` request to `/posts/1` (e.g. the response to a
|
|
90
|
-
`findRecord` query) with more than one object in the array,
|
|
90
|
+
`findRecord` query) with more than one object in the array, WarpDrive will
|
|
91
91
|
only display the object with the matching ID.
|
|
92
92
|
|
|
93
93
|
### Conventional Names
|
|
@@ -148,7 +148,7 @@ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
|
148
148
|
|
|
149
149
|
If the records in the relationship are not known when the response
|
|
150
150
|
is serialized it's also possible to represent the relationship as a
|
|
151
|
-
URL using the `links` key in the response.
|
|
151
|
+
URL using the `links` key in the response. WarpDrive will fetch
|
|
152
152
|
this URL to resolve the relationship when it is accessed for the
|
|
153
153
|
first time.
|
|
154
154
|
|
|
@@ -231,17 +231,12 @@ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
|
231
231
|
}
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
@class RESTAdapter
|
|
235
234
|
@public
|
|
236
|
-
@constructor
|
|
237
|
-
@uses BuildURLMixin
|
|
238
235
|
*/
|
|
239
236
|
class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
240
237
|
/**
|
|
241
238
|
This property allows ajax to still be used instead when `false`.
|
|
242
|
-
@
|
|
243
|
-
@type {Boolean}
|
|
244
|
-
@default true
|
|
239
|
+
@default true
|
|
245
240
|
@public
|
|
246
241
|
*/
|
|
247
242
|
useFetch = true;
|
|
@@ -289,9 +284,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
289
284
|
}
|
|
290
285
|
}
|
|
291
286
|
```
|
|
292
|
-
@
|
|
293
|
-
@return {Object}
|
|
294
|
-
@public
|
|
287
|
+
@public
|
|
295
288
|
*/
|
|
296
289
|
sortQueryParams(obj) {
|
|
297
290
|
const keys = Object.keys(obj);
|
|
@@ -340,9 +333,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
340
333
|
will also send a request to: `GET /comments?ids[]=1&ids[]=2`
|
|
341
334
|
Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app
|
|
342
335
|
`groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work.
|
|
343
|
-
@
|
|
344
|
-
@public
|
|
345
|
-
@type {Boolean}
|
|
336
|
+
@public
|
|
346
337
|
*/
|
|
347
338
|
get coalesceFindRequests() {
|
|
348
339
|
const coalesceFindRequests = this._coalesceFindRequests;
|
|
@@ -365,9 +356,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
365
356
|
}
|
|
366
357
|
```
|
|
367
358
|
Requests for the `Post` model would now target `/api/1/post/`.
|
|
368
|
-
@
|
|
369
|
-
@public
|
|
370
|
-
@type {String}
|
|
359
|
+
@public
|
|
371
360
|
*/
|
|
372
361
|
|
|
373
362
|
/**
|
|
@@ -379,15 +368,13 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
379
368
|
}
|
|
380
369
|
```
|
|
381
370
|
Requests for the `Post` model would now target `https://api.example.com/post/`.
|
|
382
|
-
@
|
|
383
|
-
@public
|
|
384
|
-
@type {String}
|
|
371
|
+
@public
|
|
385
372
|
*/
|
|
386
373
|
|
|
387
374
|
/**
|
|
388
375
|
Some APIs require HTTP headers, e.g. to provide an API
|
|
389
376
|
key. Arbitrary headers can be set as key/value pairs on the
|
|
390
|
-
`RESTAdapter`'s `headers` object and
|
|
377
|
+
`RESTAdapter`'s `headers` object and WarpDrive will send them
|
|
391
378
|
along with each ajax request..
|
|
392
379
|
```js [app/adapters/application.js]
|
|
393
380
|
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
@@ -400,9 +387,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
400
387
|
}
|
|
401
388
|
}
|
|
402
389
|
```
|
|
403
|
-
@
|
|
404
|
-
@public
|
|
405
|
-
@type {Object}
|
|
390
|
+
@public
|
|
406
391
|
*/
|
|
407
392
|
|
|
408
393
|
/**
|
|
@@ -413,11 +398,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
413
398
|
This method performs an HTTP `GET` request with the id provided as part of the query string.
|
|
414
399
|
@since 1.13.0
|
|
415
400
|
@public
|
|
416
|
-
@param {Store} store
|
|
417
|
-
@param {Model} type
|
|
418
|
-
@param {String} id
|
|
419
|
-
@param {Snapshot} snapshot
|
|
420
|
-
@return {Promise} promise
|
|
421
401
|
*/
|
|
422
402
|
findRecord(store, type, id, snapshot) {
|
|
423
403
|
const url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
|
|
@@ -433,18 +413,10 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
433
413
|
The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a
|
|
434
414
|
promise for the resulting payload.
|
|
435
415
|
@public
|
|
436
|
-
@param {Store} store
|
|
437
|
-
@param {Model} type
|
|
438
|
-
@param {undefined} neverSet a value is never provided to this argument
|
|
439
|
-
@param {SnapshotRecordArray} snapshotRecordArray
|
|
440
|
-
@return {Promise} promise
|
|
441
416
|
*/
|
|
442
|
-
findAll(store, type,
|
|
417
|
+
findAll(store, type, neverUsed, snapshotRecordArray) {
|
|
443
418
|
const query = this.buildQuery(snapshotRecordArray);
|
|
444
419
|
const url = this.buildURL(type.modelName, null, snapshotRecordArray, 'findAll');
|
|
445
|
-
if (sinceToken) {
|
|
446
|
-
query.since = sinceToken;
|
|
447
|
-
}
|
|
448
420
|
return this.ajax(url, 'GET', {
|
|
449
421
|
data: query
|
|
450
422
|
});
|
|
@@ -459,12 +431,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
459
431
|
The `query` argument is a simple JavaScript object that will be passed directly
|
|
460
432
|
to the server as parameters.
|
|
461
433
|
@public
|
|
462
|
-
@param {Store} store
|
|
463
|
-
@param {Model} type
|
|
464
|
-
@param {Object} query
|
|
465
|
-
@param {Collection} recordArray
|
|
466
|
-
@param {Object} adapterOptions
|
|
467
|
-
@return {Promise} promise
|
|
468
434
|
*/
|
|
469
435
|
query(store, type, query) {
|
|
470
436
|
const url = this.buildURL(type.modelName, null, null, 'query', query);
|
|
@@ -486,11 +452,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
486
452
|
to the server as parameters.
|
|
487
453
|
@since 1.13.0
|
|
488
454
|
@public
|
|
489
|
-
@param {Store} store
|
|
490
|
-
@param {Model} type
|
|
491
|
-
@param {Object} query
|
|
492
|
-
@param {Object} adapterOptions
|
|
493
|
-
@return {Promise} promise
|
|
494
455
|
*/
|
|
495
456
|
queryRecord(store, type, query, adapterOptions) {
|
|
496
457
|
const url = this.buildURL(type.modelName, null, null, 'queryRecord', query);
|
|
@@ -522,11 +483,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
522
483
|
The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a
|
|
523
484
|
promise for the resulting payload.
|
|
524
485
|
@public
|
|
525
|
-
@param {Store} store
|
|
526
|
-
@param {Model} type
|
|
527
|
-
@param {Array} ids
|
|
528
|
-
@param {Array} snapshots
|
|
529
|
-
@return {Promise} promise
|
|
530
486
|
*/
|
|
531
487
|
findMany(store, type, ids, snapshots) {
|
|
532
488
|
const url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
|
@@ -558,11 +514,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
558
514
|
* Links beginning with a single `/` will have the current adapter's `host` value prepended to it.
|
|
559
515
|
* Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`.
|
|
560
516
|
@public
|
|
561
|
-
@param {Store} store
|
|
562
|
-
@param {Snapshot} snapshot
|
|
563
|
-
@param {String} url
|
|
564
|
-
@param {Object} relationship meta object describing the relationship
|
|
565
|
-
@return {Promise} promise
|
|
566
517
|
*/
|
|
567
518
|
findHasMany(store, snapshot, url, relationship) {
|
|
568
519
|
const id = snapshot.id;
|
|
@@ -608,10 +559,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
608
559
|
See `serialize` for information on how to customize the serialized form
|
|
609
560
|
of a record.
|
|
610
561
|
@public
|
|
611
|
-
@param {Store} store
|
|
612
|
-
@param {Model} type
|
|
613
|
-
@param {Snapshot} snapshot
|
|
614
|
-
@return {Promise} promise
|
|
615
562
|
*/
|
|
616
563
|
createRecord(store, type, snapshot) {
|
|
617
564
|
const url = this.buildURL(type.modelName, null, snapshot, 'createRecord');
|
|
@@ -629,10 +576,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
629
576
|
See `serialize` for information on how to customize the serialized form
|
|
630
577
|
of a record.
|
|
631
578
|
@public
|
|
632
|
-
@param {Store} store
|
|
633
|
-
@param {Model} schema
|
|
634
|
-
@param {Snapshot} snapshot
|
|
635
|
-
@return {Promise} promise
|
|
636
579
|
*/
|
|
637
580
|
updateRecord(store, schema, snapshot) {
|
|
638
581
|
const data = serializeIntoHash(store, schema, snapshot, {});
|
|
@@ -648,16 +591,16 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
648
591
|
Called by the store when a record is deleted.
|
|
649
592
|
The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`.
|
|
650
593
|
@public
|
|
651
|
-
@param {Store} store
|
|
652
|
-
@param {Model} type
|
|
653
|
-
@param {Snapshot} snapshot
|
|
654
|
-
@return {Promise} promise
|
|
655
594
|
*/
|
|
656
595
|
deleteRecord(store, schema, snapshot) {
|
|
657
596
|
const type = snapshot.modelName;
|
|
658
597
|
const id = snapshot.id;
|
|
659
598
|
return this.ajax(this.buildURL(type, id, snapshot, 'deleteRecord'), 'DELETE');
|
|
660
599
|
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
@private
|
|
603
|
+
*/
|
|
661
604
|
_stripIDFromURL(store, snapshot) {
|
|
662
605
|
const type = snapshot.modelName;
|
|
663
606
|
const id = snapshot.id;
|
|
@@ -694,10 +637,8 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
694
637
|
It does not group records that have differing base urls, such as for example: `/posts/1/comments/2`
|
|
695
638
|
and `/posts/2/comments/3`
|
|
696
639
|
@public
|
|
697
|
-
@
|
|
698
|
-
|
|
699
|
-
@return {Array} an array of arrays of records, each of which is to be
|
|
700
|
-
loaded separately by `findMany`.
|
|
640
|
+
@return an array of arrays of records, each of which is to be
|
|
641
|
+
loaded separately by `findMany`.
|
|
701
642
|
*/
|
|
702
643
|
groupRecordsForFindMany(store, snapshots) {
|
|
703
644
|
const groups = new Map();
|
|
@@ -736,11 +677,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
736
677
|
method.
|
|
737
678
|
@since 1.13.0
|
|
738
679
|
@public
|
|
739
|
-
@param {Number} status
|
|
740
|
-
@param {Object} headers
|
|
741
|
-
@param {Object} payload
|
|
742
|
-
@param {Object} requestData - the original request information
|
|
743
|
-
@return {Object | AdapterError} response
|
|
744
680
|
*/
|
|
745
681
|
handleResponse(status, headers, payload, requestData) {
|
|
746
682
|
if (this.isSuccess(status, headers, payload)) {
|
|
@@ -773,10 +709,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
773
709
|
response is a success.
|
|
774
710
|
@since 1.13.0
|
|
775
711
|
@public
|
|
776
|
-
@param {Number} status
|
|
777
|
-
@param {Object} headers
|
|
778
|
-
@param {Object} payload
|
|
779
|
-
@return {Boolean}
|
|
780
712
|
*/
|
|
781
713
|
isSuccess(status, _headers, _payload) {
|
|
782
714
|
return status >= 200 && status < 300 || status === 304;
|
|
@@ -787,10 +719,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
787
719
|
response is an invalid error.
|
|
788
720
|
@since 1.13.0
|
|
789
721
|
@public
|
|
790
|
-
@param {Number} status
|
|
791
|
-
@param {Object} headers
|
|
792
|
-
@param {Object} payload
|
|
793
|
-
@return {Boolean}
|
|
794
722
|
*/
|
|
795
723
|
isInvalid(status, _headers, _payload) {
|
|
796
724
|
return status === 422;
|
|
@@ -799,7 +727,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
799
727
|
/**
|
|
800
728
|
Takes a URL, an HTTP method and a hash of data, and makes an
|
|
801
729
|
HTTP request.
|
|
802
|
-
When the server responds with a payload,
|
|
730
|
+
When the server responds with a payload, WarpDrive will call into `extractSingle`
|
|
803
731
|
or `extractArray` (depending on whether the original query was for one record or
|
|
804
732
|
many records).
|
|
805
733
|
By default, `ajax` method has the following behavior:
|
|
@@ -810,10 +738,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
810
738
|
data is the serialized record in the case of a save.
|
|
811
739
|
* Registers success and failure handlers.
|
|
812
740
|
@private
|
|
813
|
-
@param {String} url
|
|
814
|
-
@param {String} type The request type GET, POST, PUT, DELETE etc.
|
|
815
|
-
@param {Object} options
|
|
816
|
-
@return {Promise} promise
|
|
817
741
|
*/
|
|
818
742
|
async ajax(url, type, options = {}) {
|
|
819
743
|
const requestData = {
|
|
@@ -838,15 +762,21 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
838
762
|
|
|
839
763
|
/**
|
|
840
764
|
@private
|
|
841
|
-
@param
|
|
765
|
+
@param options jQuery ajax options to be used for the ajax request
|
|
842
766
|
*/
|
|
843
767
|
_ajaxRequest(options) {
|
|
844
768
|
void jQuery.ajax(options);
|
|
845
769
|
}
|
|
770
|
+
/**
|
|
771
|
+
@private
|
|
772
|
+
*/
|
|
846
773
|
_fetchRequest(options) {
|
|
847
774
|
const fetchFunction = getFetchFunction();
|
|
848
775
|
return fetchFunction(options.url, options);
|
|
849
776
|
}
|
|
777
|
+
/**
|
|
778
|
+
@private
|
|
779
|
+
*/
|
|
850
780
|
_ajax(options) {
|
|
851
781
|
if (this.useFetch) {
|
|
852
782
|
void this._fetchRequest(options);
|
|
@@ -857,10 +787,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
857
787
|
|
|
858
788
|
/**
|
|
859
789
|
@private
|
|
860
|
-
@param {String} url
|
|
861
|
-
@param {String} type The request type GET, POST, PUT, DELETE etc.
|
|
862
|
-
@param {Object} options
|
|
863
|
-
@return {Object}
|
|
864
790
|
*/
|
|
865
791
|
ajaxOptions(url, method, options) {
|
|
866
792
|
let reqOptions = Object.assign({
|
|
@@ -905,6 +831,10 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
905
831
|
reqOptions.url = this._ajaxURL(reqOptions.url);
|
|
906
832
|
return reqOptions;
|
|
907
833
|
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* @private
|
|
837
|
+
*/
|
|
908
838
|
_ajaxURL(url) {
|
|
909
839
|
if (this.fastboot?.isFastBoot) {
|
|
910
840
|
const httpRegex = /^https?:\/\//;
|
|
@@ -917,7 +847,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
917
847
|
try {
|
|
918
848
|
return `${protocol}//${host}${url}`;
|
|
919
849
|
} catch (fbError) {
|
|
920
|
-
throw new Error('You are using
|
|
850
|
+
throw new Error('You are using WarpDrive with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostWhitelist property for in your environment.js. FastBoot Error: ' + fbError.message);
|
|
921
851
|
}
|
|
922
852
|
}
|
|
923
853
|
}
|
|
@@ -926,8 +856,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
926
856
|
|
|
927
857
|
/**
|
|
928
858
|
@private
|
|
929
|
-
@param {String} responseText
|
|
930
|
-
@return {Object}
|
|
931
859
|
*/
|
|
932
860
|
parseErrorResponse(responseText) {
|
|
933
861
|
let json = responseText;
|
|
@@ -941,10 +869,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
941
869
|
|
|
942
870
|
/**
|
|
943
871
|
@private
|
|
944
|
-
@
|
|
945
|
-
@param {Object} headers
|
|
946
|
-
@param {Object} payload
|
|
947
|
-
@return {Array} errors payload
|
|
872
|
+
@return errors payload
|
|
948
873
|
*/
|
|
949
874
|
normalizeErrorResponse(status, _headers, payload) {
|
|
950
875
|
if (payload && typeof payload === 'object' && 'errors' in payload && Array.isArray(payload.errors)) {
|
|
@@ -967,11 +892,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
967
892
|
Generates a detailed ("friendly") error message, with plenty
|
|
968
893
|
of information for debugging (good luck!)
|
|
969
894
|
@private
|
|
970
|
-
@
|
|
971
|
-
@param {Object} headers
|
|
972
|
-
@param {Object} payload
|
|
973
|
-
@param {Object} requestData
|
|
974
|
-
@return {String} detailed error message
|
|
895
|
+
@return detailed error message
|
|
975
896
|
*/
|
|
976
897
|
generatedDetailedMessage(status, headers, payload, requestData) {
|
|
977
898
|
let shortenedPayload;
|
|
@@ -993,8 +914,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
993
914
|
supplied to the ajax method.
|
|
994
915
|
@since 2.5.0
|
|
995
916
|
@public
|
|
996
|
-
@param {Snapshot} snapshot
|
|
997
|
-
@return {Object}
|
|
998
917
|
*/
|
|
999
918
|
buildQuery(snapshot) {
|
|
1000
919
|
const query = {};
|
|
@@ -1128,17 +1047,14 @@ function headersToObject(headers) {
|
|
|
1128
1047
|
/**
|
|
1129
1048
|
* Helper function that translates the options passed to `jQuery.ajax` into a format that `fetch` expects.
|
|
1130
1049
|
*
|
|
1131
|
-
* @param {Object} _options
|
|
1132
|
-
* @param {Adapter} adapter
|
|
1133
1050
|
* @private
|
|
1134
|
-
* @return {Object}
|
|
1135
1051
|
*/
|
|
1136
1052
|
function fetchOptions(options, adapter) {
|
|
1137
1053
|
options.credentials = options.credentials || 'same-origin';
|
|
1138
1054
|
if (options.data) {
|
|
1139
1055
|
// GET and HEAD requests can't have a `body`
|
|
1140
1056
|
if (options.method === 'GET' || options.method === 'HEAD') {
|
|
1141
|
-
// If no options are passed,
|
|
1057
|
+
// If no options are passed, WarpDrive sets `data` to an empty object, which we test for.
|
|
1142
1058
|
if (Object.keys(options.data).length && options.url) {
|
|
1143
1059
|
// Test if there are already query params in the url (mimics jQuey.ajax).
|
|
1144
1060
|
const queryParamDelimiter = options.url.includes('?') ? '&' : '?';
|
|
@@ -923,10 +923,10 @@ class Adapter extends EmberObject {
|
|
|
923
923
|
Serializes the record update and sends it to the server.
|
|
924
924
|
The updateRecord method is expected to return a promise that will
|
|
925
925
|
resolve with the serialized record. This allows the backend to
|
|
926
|
-
inform the
|
|
926
|
+
inform the WarpDrive store the current state of this record after
|
|
927
927
|
the update. If it is not possible to return a serialized record
|
|
928
928
|
the updateRecord promise can also resolve with `undefined` and the
|
|
929
|
-
|
|
929
|
+
WarpDrive store will assume all of the updates were successfully
|
|
930
930
|
applied on the backend.
|
|
931
931
|
Example
|
|
932
932
|
```js [app/adapters/application.js]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as FetchManager, S as SaveOp, b as Snapshot, a as SnapshotRecordArray, u as upgradeStore } from "../-private-
|
|
1
|
+
export { F as FetchManager, S as SaveOp, b as Snapshot, a as SnapshotRecordArray, u as upgradeStore } from "../-private-BdyZaGEh.js";
|
|
@@ -2,7 +2,8 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
3
|
import { assertPrivateStore, _deprecatingNormalize } from '@warp-drive/core/store/-private';
|
|
4
4
|
import '@warp-drive/core/reactive/-private';
|
|
5
|
-
import { n as normalizeResponseHelper, F as FetchManager, S as SaveOp, a as SnapshotRecordArray } from "./-private-
|
|
5
|
+
import { n as normalizeResponseHelper, F as FetchManager, S as SaveOp, a as SnapshotRecordArray } from "./-private-BdyZaGEh.js";
|
|
6
|
+
import '@warp-drive/core/signals/-leaked';
|
|
6
7
|
function iterateData(data, fn) {
|
|
7
8
|
if (Array.isArray(data)) {
|
|
8
9
|
return data.map(fn);
|