@warp-drive/legacy 5.6.0-alpha.14 → 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 +59 -0
- 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 -271
- 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 +243 -0
- package/dist/compat.js +3 -4
- package/dist/{errors-D74uk36r.js → errors-BX5wowuz.js} +12 -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 +15 -4
- package/dist/model.js +3 -3
- package/dist/{schema-provider-CXFLTMjg.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/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/utils.js.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/errors-D74uk36r.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-CXFLTMjg.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
package/dist/adapter.js
CHANGED
|
@@ -735,7 +735,6 @@ const service = s.service ?? s.inject;
|
|
|
735
735
|
For an example of the implementation, see `RESTAdapter`, the
|
|
736
736
|
included REST adapter.
|
|
737
737
|
|
|
738
|
-
@class Adapter
|
|
739
738
|
@public
|
|
740
739
|
*/
|
|
741
740
|
class Adapter extends EmberObject {
|
|
@@ -766,12 +765,7 @@ class Adapter extends EmberObject {
|
|
|
766
765
|
}
|
|
767
766
|
}
|
|
768
767
|
```
|
|
769
|
-
@
|
|
770
|
-
@param {Model} type
|
|
771
|
-
@param {String} id
|
|
772
|
-
@param {Snapshot} snapshot
|
|
773
|
-
@return {Promise} promise
|
|
774
|
-
@public
|
|
768
|
+
@public
|
|
775
769
|
*/
|
|
776
770
|
// @ts-expect-error
|
|
777
771
|
findRecord(store, type, id, snapshot) {
|
|
@@ -799,11 +793,7 @@ class Adapter extends EmberObject {
|
|
|
799
793
|
}
|
|
800
794
|
}
|
|
801
795
|
```
|
|
802
|
-
@param
|
|
803
|
-
@param {Model} type
|
|
804
|
-
@param {null} neverSet a value is never provided to this argument
|
|
805
|
-
@param {SnapshotRecordArray} snapshotRecordArray
|
|
806
|
-
@return {Promise} promise
|
|
796
|
+
@param neverSet a value is never provided to this argument
|
|
807
797
|
@public
|
|
808
798
|
*/
|
|
809
799
|
findAll(store, type, neverSet, snapshotRecordArray) {
|
|
@@ -831,13 +821,7 @@ class Adapter extends EmberObject {
|
|
|
831
821
|
}
|
|
832
822
|
}
|
|
833
823
|
```
|
|
834
|
-
@
|
|
835
|
-
@param {Model} type
|
|
836
|
-
@param {Object} query
|
|
837
|
-
@param {Collection} recordArray
|
|
838
|
-
@param {Object} adapterOptions
|
|
839
|
-
@return {Promise} promise
|
|
840
|
-
@public
|
|
824
|
+
@public
|
|
841
825
|
*/
|
|
842
826
|
// @ts-expect-error
|
|
843
827
|
query(store, type, query) {
|
|
@@ -863,14 +847,8 @@ class Adapter extends EmberObject {
|
|
|
863
847
|
}
|
|
864
848
|
}
|
|
865
849
|
```
|
|
866
|
-
@
|
|
867
|
-
@param {subclass of Model} type
|
|
868
|
-
@param {Object} query
|
|
869
|
-
@param {Object} adapterOptions
|
|
870
|
-
@return {Promise} promise
|
|
871
|
-
@public
|
|
850
|
+
@public
|
|
872
851
|
*/
|
|
873
|
-
// @ts-expect-error
|
|
874
852
|
queryRecord(store, type, query, adapterOptions) {
|
|
875
853
|
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
876
854
|
throw new Error('You subclassed the Adapter class but missing a queryRecord override');
|
|
@@ -918,10 +896,7 @@ class Adapter extends EmberObject {
|
|
|
918
896
|
}
|
|
919
897
|
}
|
|
920
898
|
```
|
|
921
|
-
@
|
|
922
|
-
@param {Object} options
|
|
923
|
-
@return {Object} serialized snapshot
|
|
924
|
-
@public
|
|
899
|
+
@public
|
|
925
900
|
*/
|
|
926
901
|
serialize(snapshot, options) {
|
|
927
902
|
const serialized = snapshot.serialize(options);
|
|
@@ -961,11 +936,7 @@ class Adapter extends EmberObject {
|
|
|
961
936
|
}
|
|
962
937
|
}
|
|
963
938
|
```
|
|
964
|
-
@
|
|
965
|
-
@param {Model} type the Model class of the record
|
|
966
|
-
@param {Snapshot} snapshot
|
|
967
|
-
@return {Promise} promise
|
|
968
|
-
@public
|
|
939
|
+
@public
|
|
969
940
|
*/
|
|
970
941
|
// @ts-expect-error
|
|
971
942
|
createRecord(store, type, snapshot) {
|
package/dist/compat/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-
|
|
1
|
+
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-CKrP0ogQ.js";
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { get, set } from '@ember/object';
|
|
2
|
+
import { compare } from '@ember/utils';
|
|
3
|
+
import Ember from 'ember';
|
|
4
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
5
|
+
const EmberObjectFeatures = {};
|
|
6
|
+
const EmberObjectMethods = ['addObserver', 'cacheFor', 'decrementProperty', 'get', 'getProperties', 'incrementProperty', 'notifyPropertyChange', 'removeObserver', 'set', 'setProperties', 'toggleProperty'];
|
|
7
|
+
EmberObjectMethods.forEach(method => {
|
|
8
|
+
EmberObjectFeatures[method] = function delegatedMethod(...args) {
|
|
9
|
+
return Ember[method](this, ...args);
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
const EmberObjectArrayExtension = {
|
|
13
|
+
kind: 'array',
|
|
14
|
+
name: 'ember-object',
|
|
15
|
+
features: EmberObjectFeatures
|
|
16
|
+
};
|
|
17
|
+
const EmberObjectExtension = {
|
|
18
|
+
kind: 'object',
|
|
19
|
+
name: 'ember-object',
|
|
20
|
+
features: EmberObjectFeatures
|
|
21
|
+
};
|
|
22
|
+
const EmberArrayLikeFeatures = {
|
|
23
|
+
addObject(obj) {
|
|
24
|
+
const index = this.indexOf(obj);
|
|
25
|
+
if (index === -1) {
|
|
26
|
+
this.push(obj);
|
|
27
|
+
}
|
|
28
|
+
return this;
|
|
29
|
+
},
|
|
30
|
+
addObjects(objs) {
|
|
31
|
+
objs.forEach(obj => {
|
|
32
|
+
const index = this.indexOf(obj);
|
|
33
|
+
if (index === -1) {
|
|
34
|
+
this.push(obj);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return this;
|
|
38
|
+
},
|
|
39
|
+
popObject() {
|
|
40
|
+
return this.pop();
|
|
41
|
+
},
|
|
42
|
+
pushObject(obj) {
|
|
43
|
+
this.push(obj);
|
|
44
|
+
return obj;
|
|
45
|
+
},
|
|
46
|
+
pushObjects(objs) {
|
|
47
|
+
this.push(...objs);
|
|
48
|
+
return this;
|
|
49
|
+
},
|
|
50
|
+
shiftObject() {
|
|
51
|
+
return this.shift();
|
|
52
|
+
},
|
|
53
|
+
unshiftObject(obj) {
|
|
54
|
+
this.unshift(obj);
|
|
55
|
+
return obj;
|
|
56
|
+
},
|
|
57
|
+
unshiftObjects(objs) {
|
|
58
|
+
this.unshift(...objs);
|
|
59
|
+
return this;
|
|
60
|
+
},
|
|
61
|
+
objectAt(index) {
|
|
62
|
+
//For negative index values go back from the end of the array
|
|
63
|
+
const arrIndex = Math.sign(index) === -1 ? this.length + index : index;
|
|
64
|
+
return this[arrIndex];
|
|
65
|
+
},
|
|
66
|
+
objectsAt(indices) {
|
|
67
|
+
// @ts-expect-error adding MutableArray method
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
69
|
+
return indices.map(index => this.objectAt(index));
|
|
70
|
+
},
|
|
71
|
+
removeAt(index) {
|
|
72
|
+
this.splice(index, 1);
|
|
73
|
+
return this;
|
|
74
|
+
},
|
|
75
|
+
insertAt(index, obj) {
|
|
76
|
+
this.splice(index, 0, obj);
|
|
77
|
+
return this;
|
|
78
|
+
},
|
|
79
|
+
removeObject(obj) {
|
|
80
|
+
const index = this.indexOf(obj);
|
|
81
|
+
if (index !== -1) {
|
|
82
|
+
this.splice(index, 1);
|
|
83
|
+
}
|
|
84
|
+
return this;
|
|
85
|
+
},
|
|
86
|
+
removeObjects(objs) {
|
|
87
|
+
objs.forEach(obj => {
|
|
88
|
+
const index = this.indexOf(obj);
|
|
89
|
+
if (index !== -1) {
|
|
90
|
+
this.splice(index, 1);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return this;
|
|
94
|
+
},
|
|
95
|
+
toArray() {
|
|
96
|
+
return this.slice();
|
|
97
|
+
},
|
|
98
|
+
replace(idx, amt, objects) {
|
|
99
|
+
if (objects) {
|
|
100
|
+
this.splice(idx, amt, ...objects);
|
|
101
|
+
} else {
|
|
102
|
+
this.splice(idx, amt);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
clear() {
|
|
106
|
+
this.splice(0, this.length);
|
|
107
|
+
return this;
|
|
108
|
+
},
|
|
109
|
+
setObjects(objects) {
|
|
110
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
111
|
+
if (!test) {
|
|
112
|
+
throw new Error(`setObjects expects to receive an array as its argument`);
|
|
113
|
+
}
|
|
114
|
+
})(Array.isArray(objects)) : {};
|
|
115
|
+
this.splice(0, this.length);
|
|
116
|
+
this.push(...objects);
|
|
117
|
+
return this;
|
|
118
|
+
},
|
|
119
|
+
reverseObjects() {
|
|
120
|
+
this.reverse();
|
|
121
|
+
return this;
|
|
122
|
+
},
|
|
123
|
+
compact() {
|
|
124
|
+
return this.filter(v => v !== null && v !== undefined);
|
|
125
|
+
},
|
|
126
|
+
any(callback, target) {
|
|
127
|
+
return this.some(callback, target);
|
|
128
|
+
},
|
|
129
|
+
isAny(prop, value) {
|
|
130
|
+
const hasValue = arguments.length === 2;
|
|
131
|
+
return this.some(v => hasValue ? v[prop] === value : v[prop] === true);
|
|
132
|
+
},
|
|
133
|
+
isEvery(prop, value) {
|
|
134
|
+
const hasValue = arguments.length === 2;
|
|
135
|
+
return this.every(v => hasValue ? v[prop] === value : v[prop] === true);
|
|
136
|
+
},
|
|
137
|
+
getEach(key) {
|
|
138
|
+
return this.map(value => get(value, key));
|
|
139
|
+
},
|
|
140
|
+
mapBy(key) {
|
|
141
|
+
return this.map(value => get(value, key));
|
|
142
|
+
},
|
|
143
|
+
findBy(key, value) {
|
|
144
|
+
if (arguments.length === 2) {
|
|
145
|
+
return this.find(val => {
|
|
146
|
+
return get(val, key) === value;
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
return this.find(val => Boolean(get(val, key)));
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
filterBy(key, value) {
|
|
153
|
+
if (arguments.length === 2) {
|
|
154
|
+
return this.filter(record => {
|
|
155
|
+
return get(record, key) === value;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return this.filter(record => {
|
|
159
|
+
return Boolean(get(record, key));
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
sortBy(...sortKeys) {
|
|
163
|
+
return this.slice().sort((a, b) => {
|
|
164
|
+
for (let i = 0; i < sortKeys.length; i++) {
|
|
165
|
+
const key = sortKeys[i];
|
|
166
|
+
const propA = get(a, key);
|
|
167
|
+
const propB = get(b, key);
|
|
168
|
+
// return 1 or -1 else continue to the next sortKey
|
|
169
|
+
const compareValue = compare(propA, propB);
|
|
170
|
+
if (compareValue) {
|
|
171
|
+
return compareValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return 0;
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
invoke(key, ...args) {
|
|
178
|
+
return this.map(value => value[key](...args));
|
|
179
|
+
},
|
|
180
|
+
addArrayObserver() {},
|
|
181
|
+
removeArrayObserver() {},
|
|
182
|
+
arrayContentWillChange() {},
|
|
183
|
+
arrayContentDidChange() {},
|
|
184
|
+
reject(callback, target) {
|
|
185
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
186
|
+
if (!test) {
|
|
187
|
+
throw new Error('`reject` expects a function as first argument.');
|
|
188
|
+
}
|
|
189
|
+
})(typeof callback === 'function') : {};
|
|
190
|
+
return this.filter((...args) => {
|
|
191
|
+
return !callback.apply(target, args);
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
rejectBy(key, value) {
|
|
195
|
+
if (arguments.length === 2) {
|
|
196
|
+
return this.filter(record => {
|
|
197
|
+
return get(record, key) !== value;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return this.filter(record => {
|
|
201
|
+
return !get(record, key);
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
setEach(key, value) {
|
|
205
|
+
this.forEach(item => set(item, key, value));
|
|
206
|
+
},
|
|
207
|
+
uniq() {
|
|
208
|
+
return Array.from(new Set(this));
|
|
209
|
+
},
|
|
210
|
+
uniqBy(key) {
|
|
211
|
+
const seen = new Set();
|
|
212
|
+
const result = [];
|
|
213
|
+
this.forEach(item => {
|
|
214
|
+
const value = get(item, key);
|
|
215
|
+
if (seen.has(value)) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
seen.add(value);
|
|
219
|
+
result.push(item);
|
|
220
|
+
});
|
|
221
|
+
return result;
|
|
222
|
+
},
|
|
223
|
+
without(value) {
|
|
224
|
+
const newArr = this.slice();
|
|
225
|
+
const index = this.indexOf(value);
|
|
226
|
+
if (index !== -1) {
|
|
227
|
+
newArr.splice(index, 1);
|
|
228
|
+
}
|
|
229
|
+
return newArr;
|
|
230
|
+
},
|
|
231
|
+
get firstObject() {
|
|
232
|
+
return this.at(0);
|
|
233
|
+
},
|
|
234
|
+
get lastObject() {
|
|
235
|
+
return this.at(-1);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const EmberArrayLikeExtension = {
|
|
239
|
+
kind: 'array',
|
|
240
|
+
name: 'ember-array-like',
|
|
241
|
+
features: EmberArrayLikeFeatures
|
|
242
|
+
};
|
|
243
|
+
export { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension };
|
package/dist/compat.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getOwner } from '@ember/application';
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
3
|
import { waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
|
|
4
|
-
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-
|
|
4
|
+
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-CKrP0ogQ.js";
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
6
|
function _findHasMany(adapter, store, identifier, link, relationship, options) {
|
|
7
7
|
const promise = Promise.resolve().then(() => {
|
|
@@ -868,9 +868,8 @@ function serializerFor(modelName) {
|
|
|
868
868
|
```
|
|
869
869
|
|
|
870
870
|
@public
|
|
871
|
-
@param
|
|
872
|
-
@
|
|
873
|
-
@return {Object} The normalized payload
|
|
871
|
+
@param modelName The name of the model type for this payload
|
|
872
|
+
@return The normalized payload
|
|
874
873
|
*/
|
|
875
874
|
// TODO @runspired @deprecate users should call normalize on the associated serializer directly
|
|
876
875
|
function normalize(modelName, payload) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { memoized, defineSignal, defineNonEnumerableSignal, isStableIdentifier, recordIdentifierFor, storeFor, peekCache, SOURCE, fastPush, RelatedCollection, notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
|
|
2
2
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
3
3
|
import { EnableHydration } from '@warp-drive/core/types/request';
|
|
4
|
-
import { u as upgradeStore } from "./-private-
|
|
4
|
+
import { u as upgradeStore } from "./-private-CKrP0ogQ.js";
|
|
5
5
|
import { computed, get } from '@ember/object';
|
|
6
6
|
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
7
7
|
import ObjectProxy from '@ember/object/proxy';
|
|
@@ -17,6 +17,8 @@ const LegacyPromiseProxy = Symbol.for('LegacyPromiseProxy');
|
|
|
17
17
|
|
|
18
18
|
const Extended = PromiseObject;
|
|
19
19
|
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
A PromiseBelongsTo is a PromiseObject that also proxies certain method calls
|
|
22
24
|
to the underlying belongsTo model.
|
|
@@ -68,8 +70,8 @@ class PromiseBelongsTo extends Extended {
|
|
|
68
70
|
await legacySupport.reloadBelongsTo(key, options);
|
|
69
71
|
return this;
|
|
70
72
|
}
|
|
71
|
-
[LegacyPromiseProxy] = true;
|
|
72
73
|
}
|
|
74
|
+
PromiseBelongsTo.prototype[LegacyPromiseProxy] = true;
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
77
|
This class is returned as the result of accessing an async hasMany relationship
|
|
@@ -91,6 +93,7 @@ class PromiseManyArray {
|
|
|
91
93
|
constructor(promise, content) {
|
|
92
94
|
this._update(promise, content);
|
|
93
95
|
this.isDestroyed = false;
|
|
96
|
+
this[LegacyPromiseProxy] = true;
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
/**
|
|
@@ -195,12 +198,9 @@ class PromiseManyArray {
|
|
|
195
198
|
* chain this promise
|
|
196
199
|
*
|
|
197
200
|
* @public
|
|
198
|
-
* @param success
|
|
199
|
-
* @param fail
|
|
200
|
-
* @return {Promise}
|
|
201
201
|
*/
|
|
202
|
-
then(
|
|
203
|
-
return this.promise.then(
|
|
202
|
+
then(success, rejected) {
|
|
203
|
+
return this.promise.then(success, rejected);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
/**
|
|
@@ -256,6 +256,8 @@ class PromiseManyArray {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
//---- Our own stuff
|
|
259
|
+
|
|
260
|
+
/** @internal */
|
|
259
261
|
static {
|
|
260
262
|
decorateMethodV2(this.prototype, "meta", [memoized]);
|
|
261
263
|
}
|
|
@@ -271,7 +273,6 @@ class PromiseManyArray {
|
|
|
271
273
|
}) {
|
|
272
274
|
return new this(promise, content);
|
|
273
275
|
}
|
|
274
|
-
[LegacyPromiseProxy] = true;
|
|
275
276
|
}
|
|
276
277
|
defineSignal(PromiseManyArray.prototype, 'content', null);
|
|
277
278
|
defineSignal(PromiseManyArray.prototype, 'isPending', false);
|
|
@@ -760,9 +761,9 @@ class HasManyReference {
|
|
|
760
761
|
return false;
|
|
761
762
|
}
|
|
762
763
|
const relationship = this.graph.getData(this.hasManyRelationship.identifier, this.key);
|
|
763
|
-
return relationship.data
|
|
764
|
+
return relationship.data ? relationship.data.every(identifier => {
|
|
764
765
|
return this.store._instanceCache.recordIsLoaded(identifier, true) === true;
|
|
765
|
-
});
|
|
766
|
+
}) : false;
|
|
766
767
|
}
|
|
767
768
|
|
|
768
769
|
/**
|
|
@@ -1668,6 +1669,7 @@ class LegacySupport {
|
|
|
1668
1669
|
type: definition.type,
|
|
1669
1670
|
identifier: this.identifier,
|
|
1670
1671
|
cache: this.cache,
|
|
1672
|
+
field: this.store.schema.fields(this.identifier).get(key),
|
|
1671
1673
|
identifiers,
|
|
1672
1674
|
key,
|
|
1673
1675
|
meta: doc.meta || null,
|