@warp-drive/legacy 5.8.0-beta.0 → 5.8.0-beta.1
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/README.md +16 -26
- package/declarations/adapter/error.d.ts +7 -7
- package/declarations/adapter/json-api.d.ts +6 -8
- package/declarations/adapter/rest.d.ts +26 -112
- package/declarations/adapter.d.ts +6 -8
- package/declarations/compat/-private.d.ts +1 -1
- package/declarations/compat/builders/find-all.d.ts +6 -6
- package/declarations/compat/builders/find-record.d.ts +8 -8
- package/declarations/compat/builders/query.d.ts +12 -12
- package/declarations/compat/extensions.d.ts +1 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
- package/declarations/compat/utils.d.ts +17 -17
- package/declarations/compat.d.ts +35 -11
- package/declarations/index.d.ts +70 -0
- package/declarations/model/-private/attr.d.ts +5 -6
- package/declarations/model/-private/belongs-to.d.ts +4 -5
- package/declarations/model/-private/has-many.d.ts +4 -5
- package/declarations/model/-private/hooks.d.ts +1 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts +2 -2
- package/declarations/model/-private/model.d.ts +18 -59
- package/declarations/model/-private/promise-many-array.d.ts +0 -18
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +19 -29
- package/declarations/model/-private/references/has-many.d.ts +14 -16
- package/declarations/model/migration-support.d.ts +46 -21
- package/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/declarations/model-fragments/index.d.ts +5 -0
- package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/declarations/model-fragments.d.ts +9 -0
- package/declarations/model.d.ts +2 -2
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -6
- package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
- package/declarations/serializer/-private/transforms/date.d.ts +2 -2
- package/declarations/serializer/-private/transforms/number.d.ts +1 -1
- package/declarations/serializer/-private/transforms/string.d.ts +1 -1
- package/declarations/serializer/json-api.d.ts +11 -12
- package/declarations/serializer/json.d.ts +9 -11
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +9 -12
- package/dist/{-private-8UmnAf9J.js → -private-BG3bMiKp.js} +3 -2
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +14 -15
- package/dist/adapter/json-api.js +4 -1
- package/dist/adapter/rest.js +38 -125
- package/dist/adapter.js +6 -8
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +26 -26
- package/dist/compat/utils.js +17 -18
- package/dist/compat.js +61 -43
- package/dist/{errors-8kD2mSe_.js → errors-Cz5KrzBk.js} +115 -122
- package/dist/hooks-D6diaM34.js +74 -0
- package/dist/index.js +195 -0
- package/dist/{json-Et4mt_LM.js → json-ChdEfB0X.js} +18 -35
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +59 -27
- package/dist/model-for-CqXsIKws.js +221 -0
- package/dist/model-fragments.js +76 -0
- package/dist/model.js +18 -90
- package/dist/{schema-provider-DQu4Rjco.js → schema-provider-DJCV_6AF.js} +50 -95
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-DPZYoF-i.js} +1 -1
- package/dist/serializer/json-api.js +18 -45
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +14 -21
- package/dist/serializer/transform.js +15 -6
- package/dist/serializer.js +9 -13
- package/dist/store.js +5 -1
- package/dist/unpkg/dev/-private-DtjBbEgy.js +1206 -0
- package/dist/unpkg/dev/adapter/-private.js +1 -0
- package/dist/unpkg/dev/adapter/error.js +335 -0
- package/dist/unpkg/dev/adapter/json-api.js +271 -0
- package/dist/unpkg/dev/adapter/rest.js +1171 -0
- package/dist/unpkg/dev/adapter.js +1252 -0
- package/dist/unpkg/dev/compat/-private.js +1 -0
- package/dist/unpkg/dev/compat/builders.js +275 -0
- package/dist/unpkg/dev/compat/extensions.js +242 -0
- package/dist/unpkg/dev/compat/utils.js +223 -0
- package/dist/unpkg/dev/compat.js +1147 -0
- package/dist/unpkg/dev/errors-DmGGJr3T.js +2562 -0
- package/dist/unpkg/dev/hooks-CkYiE6Ud.js +73 -0
- package/dist/unpkg/dev/index.js +197 -0
- package/dist/unpkg/dev/json-Cu1LNgmQ.js +1256 -0
- package/dist/unpkg/dev/model/-private.js +1 -0
- package/dist/unpkg/dev/model/migration-support.js +553 -0
- package/dist/unpkg/dev/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev/model-fragments.js +76 -0
- package/dist/unpkg/dev/model.js +678 -0
- package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev/schema-provider-DDVYxmUV.js +2186 -0
- package/dist/unpkg/dev/serialize-into-hash-B2xDbuo5.js +259 -0
- package/dist/unpkg/dev/serializer/json-api.js +649 -0
- package/dist/unpkg/dev/serializer/json.js +4 -0
- package/dist/unpkg/dev/serializer/rest.js +1242 -0
- package/dist/unpkg/dev/serializer/transform.js +278 -0
- package/dist/unpkg/dev/serializer.js +248 -0
- package/dist/unpkg/dev/store.js +637 -0
- package/dist/unpkg/dev/util-DvanW33H.js +20 -0
- package/dist/unpkg/dev/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/dev-deprecated/-private-DtjBbEgy.js +1206 -0
- package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/adapter/error.js +335 -0
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +271 -0
- package/dist/unpkg/dev-deprecated/adapter/rest.js +1171 -0
- package/dist/unpkg/dev-deprecated/adapter.js +1252 -0
- package/dist/unpkg/dev-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/compat/builders.js +275 -0
- package/dist/unpkg/dev-deprecated/compat/extensions.js +242 -0
- package/dist/unpkg/dev-deprecated/compat/utils.js +223 -0
- package/dist/unpkg/dev-deprecated/compat.js +1147 -0
- package/dist/unpkg/dev-deprecated/errors-Spt6ubMd.js +2565 -0
- package/dist/unpkg/dev-deprecated/hooks-DOXegvhL.js +73 -0
- package/dist/unpkg/dev-deprecated/index.js +196 -0
- package/dist/unpkg/dev-deprecated/json-Cu1LNgmQ.js +1256 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/model/migration-support.js +570 -0
- package/dist/unpkg/dev-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/dev-deprecated/model.js +682 -0
- package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev-deprecated/schema-provider-BP6_8N-V.js +2211 -0
- package/dist/unpkg/dev-deprecated/serialize-into-hash-B2xDbuo5.js +259 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +649 -0
- package/dist/unpkg/dev-deprecated/serializer/json.js +4 -0
- package/dist/unpkg/dev-deprecated/serializer/rest.js +1242 -0
- package/dist/unpkg/dev-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/dev-deprecated/serializer.js +248 -0
- package/dist/unpkg/dev-deprecated/store.js +637 -0
- package/dist/unpkg/dev-deprecated/util-CWr5WQOT.js +24 -0
- package/dist/unpkg/dev-deprecated/utils-C9PJehtL.js +12 -0
- package/dist/unpkg/prod/-private-BdyZaGEh.js +971 -0
- package/dist/unpkg/prod/adapter/-private.js +1 -0
- package/dist/unpkg/prod/adapter/error.js +330 -0
- package/dist/unpkg/prod/adapter/json-api.js +266 -0
- package/dist/unpkg/prod/adapter/rest.js +1134 -0
- package/dist/unpkg/prod/adapter.js +1219 -0
- package/dist/unpkg/prod/compat/-private.js +1 -0
- package/dist/unpkg/prod/compat/builders.js +210 -0
- package/dist/unpkg/prod/compat/extensions.js +232 -0
- package/dist/unpkg/prod/compat/utils.js +218 -0
- package/dist/unpkg/prod/compat.js +727 -0
- package/dist/unpkg/prod/errors-BGVFCBmi.js +2314 -0
- package/dist/unpkg/prod/hooks-BztVA_x0.js +41 -0
- package/dist/unpkg/prod/index.js +151 -0
- package/dist/unpkg/prod/json-BWrZ5546.js +1243 -0
- package/dist/unpkg/prod/model/-private.js +1 -0
- package/dist/unpkg/prod/model/migration-support.js +546 -0
- package/dist/unpkg/prod/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod/model-fragments.js +76 -0
- package/dist/unpkg/prod/model.js +593 -0
- package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod/schema-provider-DJtD_8jZ.js +1861 -0
- package/dist/unpkg/prod/serialize-into-hash-DGlzQteF.js +215 -0
- package/dist/unpkg/prod/serializer/json-api.js +592 -0
- package/dist/unpkg/prod/serializer/json.js +4 -0
- package/dist/unpkg/prod/serializer/rest.js +1210 -0
- package/dist/unpkg/prod/serializer/transform.js +278 -0
- package/dist/unpkg/prod/serializer.js +248 -0
- package/dist/unpkg/prod/store.js +505 -0
- package/dist/unpkg/prod/util-DvanW33H.js +20 -0
- package/dist/unpkg/prod/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/prod-deprecated/-private-BdyZaGEh.js +971 -0
- package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/adapter/error.js +330 -0
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +266 -0
- package/dist/unpkg/prod-deprecated/adapter/rest.js +1134 -0
- package/dist/unpkg/prod-deprecated/adapter.js +1219 -0
- package/dist/unpkg/prod-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/compat/builders.js +210 -0
- package/dist/unpkg/prod-deprecated/compat/extensions.js +232 -0
- package/dist/unpkg/prod-deprecated/compat/utils.js +218 -0
- package/dist/unpkg/prod-deprecated/compat.js +727 -0
- package/dist/unpkg/prod-deprecated/errors-CdDaK81x.js +2317 -0
- package/dist/unpkg/prod-deprecated/hooks-yId87yyG.js +41 -0
- package/dist/unpkg/prod-deprecated/index.js +150 -0
- package/dist/unpkg/prod-deprecated/json-BWrZ5546.js +1243 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/model/migration-support.js +563 -0
- package/dist/unpkg/prod-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/prod-deprecated/model.js +596 -0
- package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod-deprecated/schema-provider-CjX55uSY.js +1904 -0
- package/dist/unpkg/prod-deprecated/serialize-into-hash-DGlzQteF.js +215 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +592 -0
- package/dist/unpkg/prod-deprecated/serializer/json.js +4 -0
- package/dist/unpkg/prod-deprecated/serializer/rest.js +1210 -0
- package/dist/unpkg/prod-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/prod-deprecated/serializer.js +248 -0
- package/dist/unpkg/prod-deprecated/store.js +505 -0
- package/dist/unpkg/prod-deprecated/util-B6cn-i93.js +23 -0
- package/dist/unpkg/prod-deprecated/utils-BUWwQwCh.js +11 -0
- package/logos/README.md +2 -2
- package/logos/logo-yellow-slab.svg +1 -0
- package/logos/word-mark-black.svg +1 -0
- package/logos/word-mark-white.svg +1 -0
- package/package.json +15 -7
- package/logos/NCC-1701-a-blue.svg +0 -4
- package/logos/NCC-1701-a-gold.svg +0 -4
- package/logos/NCC-1701-a-gold_100.svg +0 -1
- package/logos/NCC-1701-a-gold_base-64.txt +0 -1
- package/logos/NCC-1701-a.svg +0 -4
- package/logos/docs-badge.svg +0 -2
- package/logos/ember-data-logo-dark.svg +0 -12
- package/logos/ember-data-logo-light.svg +0 -12
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +0 -4
- package/logos/warp-drive-logo-gold.svg +0 -4
|
@@ -2,10 +2,11 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { deprecate } from '@ember/debug';
|
|
3
3
|
import EmberObject from '@ember/object';
|
|
4
4
|
import { recordIdentifierFor, storeFor } from '@warp-drive/core';
|
|
5
|
-
import {
|
|
5
|
+
import { notifyInternalSignal, peekInternalSignal, withSignalStore, gate, memoized, defineSignal, entangleSignal, defineGate } from '@warp-drive/core/signals/-leaked';
|
|
6
|
+
import { assertPrivateStore, recordIdentifierFor as recordIdentifierFor$1, coerceId } from '@warp-drive/core/store/-private';
|
|
6
7
|
import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
7
|
-
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-
|
|
8
|
-
import { u as upgradeStore, F as FetchManager } from "./-private-
|
|
8
|
+
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-Cz5KrzBk.js";
|
|
9
|
+
import { u as upgradeStore, F as FetchManager } from "./-private-BG3bMiKp.js";
|
|
9
10
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
10
11
|
import { cacheFor } from '@ember/object/internals';
|
|
11
12
|
import { Context } from '@warp-drive/core/reactive/-private';
|
|
@@ -254,7 +255,7 @@ function isInvalidError(error) {
|
|
|
254
255
|
}
|
|
255
256
|
|
|
256
257
|
/**
|
|
257
|
-
Historically
|
|
258
|
+
Historically WarpDrive managed a state machine
|
|
258
259
|
for each record, the localState for which
|
|
259
260
|
was reflected onto Model.
|
|
260
261
|
|
|
@@ -680,11 +681,6 @@ function computeOnce(target, propertyName, desc) {
|
|
|
680
681
|
};
|
|
681
682
|
return desc;
|
|
682
683
|
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* @noInheritDoc
|
|
686
|
-
*/
|
|
687
|
-
|
|
688
684
|
/**
|
|
689
685
|
* Base class from which Models can be defined.
|
|
690
686
|
*
|
|
@@ -727,7 +723,10 @@ function computeOnce(target, propertyName, desc) {
|
|
|
727
723
|
* the class to use as the reactive object for data of resource
|
|
728
724
|
* of that type.
|
|
729
725
|
*
|
|
726
|
+
* @public
|
|
730
727
|
* @noInheritDoc
|
|
728
|
+
* @hideconstructor
|
|
729
|
+
* @legacy
|
|
731
730
|
*/
|
|
732
731
|
class Model extends EmberObject {
|
|
733
732
|
/** @internal */
|
|
@@ -777,9 +776,7 @@ class Model extends EmberObject {
|
|
|
777
776
|
the server or the `created` state if the record is created on the
|
|
778
777
|
client. A record can also enter the empty state if the adapter is
|
|
779
778
|
unable to locate the record.
|
|
780
|
-
@
|
|
781
|
-
@public
|
|
782
|
-
@readonly
|
|
779
|
+
@public
|
|
783
780
|
*/
|
|
784
781
|
get isEmpty() {
|
|
785
782
|
return this.currentState.isEmpty;
|
|
@@ -790,9 +787,7 @@ class Model extends EmberObject {
|
|
|
790
787
|
record enters this state when the store asks the adapter for its
|
|
791
788
|
data. It remains in this state until the adapter provides the
|
|
792
789
|
requested data.
|
|
793
|
-
@
|
|
794
|
-
@public
|
|
795
|
-
@readonly
|
|
790
|
+
@public
|
|
796
791
|
*/
|
|
797
792
|
static {
|
|
798
793
|
decorateMethodV2(this.prototype, "isEmpty", [memoized]);
|
|
@@ -813,9 +808,7 @@ class Model extends EmberObject {
|
|
|
813
808
|
const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));
|
|
814
809
|
model.isLoaded;
|
|
815
810
|
```
|
|
816
|
-
@
|
|
817
|
-
@public
|
|
818
|
-
@readonly
|
|
811
|
+
@public
|
|
819
812
|
*/
|
|
820
813
|
static {
|
|
821
814
|
decorateMethodV2(this.prototype, "isLoading", [memoized]);
|
|
@@ -839,9 +832,7 @@ class Model extends EmberObject {
|
|
|
839
832
|
model.hasDirtyAttributes; // true
|
|
840
833
|
```
|
|
841
834
|
@since 1.13.0
|
|
842
|
-
@property hasDirtyAttributes
|
|
843
835
|
@public
|
|
844
|
-
@readonly
|
|
845
836
|
*/
|
|
846
837
|
static {
|
|
847
838
|
decorateMethodV2(this.prototype, "isLoaded", [memoized]);
|
|
@@ -865,9 +856,7 @@ class Model extends EmberObject {
|
|
|
865
856
|
record.isSaving; // false
|
|
866
857
|
});
|
|
867
858
|
```
|
|
868
|
-
@
|
|
869
|
-
@public
|
|
870
|
-
@readonly
|
|
859
|
+
@public
|
|
871
860
|
*/
|
|
872
861
|
static {
|
|
873
862
|
decorateMethodV2(this.prototype, "hasDirtyAttributes", [memoized]);
|
|
@@ -903,9 +892,7 @@ class Model extends EmberObject {
|
|
|
903
892
|
record.hasDirtyAttributes; // false
|
|
904
893
|
});
|
|
905
894
|
```
|
|
906
|
-
@
|
|
907
|
-
@public
|
|
908
|
-
@readonly
|
|
895
|
+
@public
|
|
909
896
|
*/
|
|
910
897
|
static {
|
|
911
898
|
decorateMethodV2(this.prototype, "isSaving", [memoized]);
|
|
@@ -927,9 +914,7 @@ class Model extends EmberObject {
|
|
|
927
914
|
model.isNew; // false
|
|
928
915
|
});
|
|
929
916
|
```
|
|
930
|
-
@
|
|
931
|
-
@public
|
|
932
|
-
@readonly
|
|
917
|
+
@public
|
|
933
918
|
*/
|
|
934
919
|
static {
|
|
935
920
|
decorateMethodV2(this.prototype, "isDeleted", [memoized]);
|
|
@@ -942,9 +927,7 @@ class Model extends EmberObject {
|
|
|
942
927
|
If this property is `true` the record is in the `valid` state.
|
|
943
928
|
A record will be in the `valid` state when the adapter did not report any
|
|
944
929
|
server-side validation failures.
|
|
945
|
-
@
|
|
946
|
-
@public
|
|
947
|
-
@readonly
|
|
930
|
+
@public
|
|
948
931
|
*/
|
|
949
932
|
static {
|
|
950
933
|
decorateMethodV2(this.prototype, "isNew", [memoized]);
|
|
@@ -965,9 +948,7 @@ class Model extends EmberObject {
|
|
|
965
948
|
let record = store.createRecord('model');
|
|
966
949
|
record.dirtyType; // 'created'
|
|
967
950
|
```
|
|
968
|
-
@
|
|
969
|
-
@public
|
|
970
|
-
@readonly
|
|
951
|
+
@public
|
|
971
952
|
*/
|
|
972
953
|
static {
|
|
973
954
|
decorateMethodV2(this.prototype, "isValid", [memoized]);
|
|
@@ -988,9 +969,7 @@ class Model extends EmberObject {
|
|
|
988
969
|
record.isError; // true
|
|
989
970
|
});
|
|
990
971
|
```
|
|
991
|
-
@
|
|
992
|
-
@public
|
|
993
|
-
@readonly
|
|
972
|
+
@public
|
|
994
973
|
*/
|
|
995
974
|
static {
|
|
996
975
|
decorateMethodV2(this.prototype, "dirtyType", [memoized]);
|
|
@@ -1015,9 +994,7 @@ class Model extends EmberObject {
|
|
|
1015
994
|
record.reload();
|
|
1016
995
|
record.isReloading; // true
|
|
1017
996
|
```
|
|
1018
|
-
@
|
|
1019
|
-
@public
|
|
1020
|
-
@readonly
|
|
997
|
+
@public
|
|
1021
998
|
*/
|
|
1022
999
|
|
|
1023
1000
|
/**
|
|
@@ -1032,8 +1009,7 @@ class Model extends EmberObject {
|
|
|
1032
1009
|
const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' }));
|
|
1033
1010
|
model.id; // '1'
|
|
1034
1011
|
```
|
|
1035
|
-
@
|
|
1036
|
-
@public
|
|
1012
|
+
@public
|
|
1037
1013
|
*/
|
|
1038
1014
|
get id() {
|
|
1039
1015
|
// this guard exists, because some dev-only deprecation code
|
|
@@ -1071,7 +1047,6 @@ class Model extends EmberObject {
|
|
|
1071
1047
|
}
|
|
1072
1048
|
|
|
1073
1049
|
/**
|
|
1074
|
-
@property currentState
|
|
1075
1050
|
@private
|
|
1076
1051
|
*/
|
|
1077
1052
|
// TODO we can probably make this a computeOnce
|
|
@@ -1097,8 +1072,7 @@ class Model extends EmberObject {
|
|
|
1097
1072
|
|
|
1098
1073
|
/**
|
|
1099
1074
|
The store service instance which created this record instance
|
|
1100
|
-
|
|
1101
|
-
@public
|
|
1075
|
+
@public
|
|
1102
1076
|
*/
|
|
1103
1077
|
|
|
1104
1078
|
/**
|
|
@@ -1141,8 +1115,7 @@ class Model extends EmberObject {
|
|
|
1141
1115
|
</div>
|
|
1142
1116
|
{{/each}}
|
|
1143
1117
|
```
|
|
1144
|
-
@
|
|
1145
|
-
@public
|
|
1118
|
+
@public
|
|
1146
1119
|
*/
|
|
1147
1120
|
get errors() {
|
|
1148
1121
|
const errors = Errors.create({
|
|
@@ -1155,8 +1128,7 @@ class Model extends EmberObject {
|
|
|
1155
1128
|
/**
|
|
1156
1129
|
This property holds the `AdapterError` object with which
|
|
1157
1130
|
last adapter operation was rejected.
|
|
1158
|
-
@
|
|
1159
|
-
@public
|
|
1131
|
+
@public
|
|
1160
1132
|
*/
|
|
1161
1133
|
static {
|
|
1162
1134
|
decorateMethodV2(this.prototype, "errors", [computeOnce]);
|
|
@@ -1255,7 +1227,7 @@ class Model extends EmberObject {
|
|
|
1255
1227
|
/**
|
|
1256
1228
|
Represents the model's class name as a string. This can be used to look up the model's class name through
|
|
1257
1229
|
`Store`'s modelFor method.
|
|
1258
|
-
`modelName` is generated for you by
|
|
1230
|
+
`modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.
|
|
1259
1231
|
For example:
|
|
1260
1232
|
```javascript
|
|
1261
1233
|
store.modelFor('post').modelName; // 'post'
|
|
@@ -1272,9 +1244,7 @@ class Model extends EmberObject {
|
|
|
1272
1244
|
}
|
|
1273
1245
|
});
|
|
1274
1246
|
```
|
|
1275
|
-
|
|
1276
|
-
@public
|
|
1277
|
-
@readonly
|
|
1247
|
+
@public
|
|
1278
1248
|
*/
|
|
1279
1249
|
static modelName = null;
|
|
1280
1250
|
|
|
@@ -1440,11 +1410,8 @@ class Model extends EmberObject {
|
|
|
1440
1410
|
relationships.post;
|
|
1441
1411
|
//=> [ { name: 'posts', kind: 'hasMany' } ]
|
|
1442
1412
|
```
|
|
1443
|
-
|
|
1444
|
-
@public
|
|
1445
|
-
@readonly
|
|
1413
|
+
@public
|
|
1446
1414
|
*/
|
|
1447
|
-
|
|
1448
1415
|
static get relationships() {
|
|
1449
1416
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1450
1417
|
if (!test) {
|
|
@@ -1488,9 +1455,7 @@ class Model extends EmberObject {
|
|
|
1488
1455
|
relationshipNames.belongsTo;
|
|
1489
1456
|
//=> ['owner']
|
|
1490
1457
|
```
|
|
1491
|
-
|
|
1492
|
-
@public
|
|
1493
|
-
@readonly
|
|
1458
|
+
@public
|
|
1494
1459
|
*/
|
|
1495
1460
|
static {
|
|
1496
1461
|
decorateMethodV2(this, "relationships", [computeOnce]);
|
|
@@ -1532,9 +1497,7 @@ class Model extends EmberObject {
|
|
|
1532
1497
|
let relatedTypes = Blog.relatedTypes');
|
|
1533
1498
|
//=> ['user', 'post']
|
|
1534
1499
|
```
|
|
1535
|
-
@
|
|
1536
|
-
@public
|
|
1537
|
-
@readonly
|
|
1500
|
+
@public
|
|
1538
1501
|
*/
|
|
1539
1502
|
static {
|
|
1540
1503
|
decorateMethodV2(this, "relationshipNames", [computeOnce]);
|
|
@@ -1584,9 +1547,7 @@ class Model extends EmberObject {
|
|
|
1584
1547
|
relationshipsByName.owner;
|
|
1585
1548
|
//=> { name: 'owner', kind: 'belongsTo', type: 'user', options: Object }
|
|
1586
1549
|
```
|
|
1587
|
-
|
|
1588
|
-
@public
|
|
1589
|
-
@readonly
|
|
1550
|
+
@public
|
|
1590
1551
|
*/
|
|
1591
1552
|
static {
|
|
1592
1553
|
decorateMethodV2(this, "relatedTypes", [computeOnce]);
|
|
@@ -1666,9 +1627,7 @@ class Model extends EmberObject {
|
|
|
1666
1627
|
// posts, hasMany
|
|
1667
1628
|
// title, attribute
|
|
1668
1629
|
```
|
|
1669
|
-
|
|
1670
|
-
@public
|
|
1671
|
-
@readonly
|
|
1630
|
+
@public
|
|
1672
1631
|
*/
|
|
1673
1632
|
static {
|
|
1674
1633
|
decorateMethodV2(this, "relationshipsObject", [computeOnce]);
|
|
@@ -1695,8 +1654,8 @@ class Model extends EmberObject {
|
|
|
1695
1654
|
invoking the callback with the name of each relationship and its relationship
|
|
1696
1655
|
descriptor.
|
|
1697
1656
|
@public
|
|
1698
|
-
@param
|
|
1699
|
-
@param
|
|
1657
|
+
@param callback the callback to invoke
|
|
1658
|
+
@param binding the value to which the callback's `this` should be bound
|
|
1700
1659
|
*/
|
|
1701
1660
|
static {
|
|
1702
1661
|
decorateMethodV2(this, "fields", [computeOnce]);
|
|
@@ -1718,8 +1677,8 @@ class Model extends EmberObject {
|
|
|
1718
1677
|
returned just once, regardless of how many different relationships it has
|
|
1719
1678
|
with a model.
|
|
1720
1679
|
@public
|
|
1721
|
-
@param
|
|
1722
|
-
@param
|
|
1680
|
+
@param callback the callback to invoke
|
|
1681
|
+
@param binding the value to which the callback's `this` should be bound
|
|
1723
1682
|
*/
|
|
1724
1683
|
static eachRelatedType(callback, binding) {
|
|
1725
1684
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -1787,9 +1746,7 @@ class Model extends EmberObject {
|
|
|
1787
1746
|
// lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"}
|
|
1788
1747
|
// birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"}
|
|
1789
1748
|
```
|
|
1790
|
-
|
|
1791
|
-
@public
|
|
1792
|
-
@readonly
|
|
1749
|
+
@public
|
|
1793
1750
|
*/
|
|
1794
1751
|
static get attributes() {
|
|
1795
1752
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -1839,9 +1796,7 @@ class Model extends EmberObject {
|
|
|
1839
1796
|
// lastName string
|
|
1840
1797
|
// birthday date
|
|
1841
1798
|
```
|
|
1842
|
-
|
|
1843
|
-
@public
|
|
1844
|
-
@readonly
|
|
1799
|
+
@public
|
|
1845
1800
|
*/
|
|
1846
1801
|
static {
|
|
1847
1802
|
decorateMethodV2(this, "attributes", [computeOnce]);
|
|
@@ -1890,8 +1845,8 @@ class Model extends EmberObject {
|
|
|
1890
1845
|
// birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"}
|
|
1891
1846
|
```
|
|
1892
1847
|
@public
|
|
1893
|
-
@param
|
|
1894
|
-
@param
|
|
1848
|
+
@param callback The callback to execute
|
|
1849
|
+
@param binding [optional] the value to which the callback's `this` should be bound
|
|
1895
1850
|
*/
|
|
1896
1851
|
static {
|
|
1897
1852
|
decorateMethodV2(this, "transformedAttributes", [computeOnce]);
|
|
@@ -1937,8 +1892,8 @@ class Model extends EmberObject {
|
|
|
1937
1892
|
// birthday date
|
|
1938
1893
|
```
|
|
1939
1894
|
@public
|
|
1940
|
-
@param
|
|
1941
|
-
@param
|
|
1895
|
+
@param callback The callback to execute
|
|
1896
|
+
@param binding [optional] the value to which the callback's `this` should be bound
|
|
1942
1897
|
*/
|
|
1943
1898
|
static eachTransformedAttribute(callback, binding) {
|
|
1944
1899
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -2114,7 +2069,7 @@ class ModelSchemaProvider {
|
|
|
2114
2069
|
hasTrait(type) {
|
|
2115
2070
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2116
2071
|
{
|
|
2117
|
-
throw new Error(`hasTrait is not available with @
|
|
2072
|
+
throw new Error(`hasTrait is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2118
2073
|
}
|
|
2119
2074
|
})() : {};
|
|
2120
2075
|
return false;
|
|
@@ -2122,7 +2077,7 @@ class ModelSchemaProvider {
|
|
|
2122
2077
|
resourceHasTrait(resource, trait) {
|
|
2123
2078
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2124
2079
|
{
|
|
2125
|
-
throw new Error(`resourceHasTrait is not available with @
|
|
2080
|
+
throw new Error(`resourceHasTrait is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2126
2081
|
}
|
|
2127
2082
|
})() : {};
|
|
2128
2083
|
return false;
|
|
@@ -2130,21 +2085,21 @@ class ModelSchemaProvider {
|
|
|
2130
2085
|
transformation(field) {
|
|
2131
2086
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2132
2087
|
{
|
|
2133
|
-
throw new Error(`transformation is not available with @
|
|
2088
|
+
throw new Error(`transformation is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2134
2089
|
}
|
|
2135
2090
|
})() : {};
|
|
2136
2091
|
}
|
|
2137
2092
|
derivation(field) {
|
|
2138
2093
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2139
2094
|
{
|
|
2140
|
-
throw new Error(`derivation is not available with @
|
|
2095
|
+
throw new Error(`derivation is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2141
2096
|
}
|
|
2142
2097
|
})() : {};
|
|
2143
2098
|
}
|
|
2144
2099
|
hashFn(field) {
|
|
2145
2100
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2146
2101
|
{
|
|
2147
|
-
throw new Error(`hashFn is not available with @
|
|
2102
|
+
throw new Error(`hashFn is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2148
2103
|
}
|
|
2149
2104
|
})() : {};
|
|
2150
2105
|
}
|
|
@@ -2158,35 +2113,35 @@ class ModelSchemaProvider {
|
|
|
2158
2113
|
registerResources(schemas) {
|
|
2159
2114
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2160
2115
|
{
|
|
2161
|
-
throw new Error(`registerResources is not available with @
|
|
2116
|
+
throw new Error(`registerResources is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2162
2117
|
}
|
|
2163
2118
|
})() : {};
|
|
2164
2119
|
}
|
|
2165
2120
|
registerResource(schema) {
|
|
2166
2121
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2167
2122
|
{
|
|
2168
|
-
throw new Error(`registerResource is not available with @
|
|
2123
|
+
throw new Error(`registerResource is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2169
2124
|
}
|
|
2170
2125
|
})() : {};
|
|
2171
2126
|
}
|
|
2172
2127
|
registerTransformation(transform) {
|
|
2173
2128
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2174
2129
|
{
|
|
2175
|
-
throw new Error(`registerTransformation is not available with @
|
|
2130
|
+
throw new Error(`registerTransformation is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2176
2131
|
}
|
|
2177
2132
|
})() : {};
|
|
2178
2133
|
}
|
|
2179
2134
|
registerDerivation(derivation) {
|
|
2180
2135
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2181
2136
|
{
|
|
2182
|
-
throw new Error(`registerDerivation is not available with @
|
|
2137
|
+
throw new Error(`registerDerivation is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2183
2138
|
}
|
|
2184
2139
|
})() : {};
|
|
2185
2140
|
}
|
|
2186
2141
|
registerHashFn(hashFn) {
|
|
2187
2142
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
2188
2143
|
{
|
|
2189
|
-
throw new Error(`registerHashFn is not available with @
|
|
2144
|
+
throw new Error(`registerHashFn is not available with @warp-drive/legacy/model's SchemaService`);
|
|
2190
2145
|
}
|
|
2191
2146
|
})() : {};
|
|
2192
2147
|
}
|
|
@@ -2337,4 +2292,4 @@ function getModelFactory(store, type) {
|
|
|
2337
2292
|
}
|
|
2338
2293
|
return factory;
|
|
2339
2294
|
}
|
|
2340
|
-
export { Model as M, RecordState as R, _save as _, save as a, buildSchema as b, _reload as c, reload as d, _destroyRecord as e, destroyRecord as f,
|
|
2295
|
+
export { Model as M, RecordState as R, _save as _, save as a, buildSchema as b, _reload as c, reload as d, _destroyRecord as e, destroyRecord as f, getModelFactory as g, hasMany as h, deleteRecord as i, changedAttributes as j, belongsTo as k, createSnapshot as l, restoreDeprecatedModelRequestBehaviors as m, rollbackAttributes as r, serialize as s, unloadRecord as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
3
|
import '@warp-drive/core/reactive/-private';
|
|
4
|
-
import "./-private-
|
|
4
|
+
import "./-private-BG3bMiKp.js";
|
|
5
5
|
import '@warp-drive/core/store/-private';
|
|
6
6
|
const newline = /\r?\n/;
|
|
7
7
|
function parseResponseHeaders(headersString) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { dasherize, pluralize, singularize } from '@warp-drive/utilities/string';
|
|
3
|
-
import { J as JSONSerializer } from "../json-
|
|
3
|
+
import { J as JSONSerializer } from "../json-ChdEfB0X.js";
|
|
4
4
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
5
5
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
@@ -10,8 +10,6 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
|
10
10
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
11
11
|
const JSONAPISerializer = JSONSerializer.extend({
|
|
12
12
|
/**
|
|
13
|
-
@param {Object} documentHash
|
|
14
|
-
@return {Object}
|
|
15
13
|
@private
|
|
16
14
|
*/
|
|
17
15
|
_normalizeDocumentHelper(documentHash) {
|
|
@@ -41,8 +39,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
41
39
|
return documentHash;
|
|
42
40
|
},
|
|
43
41
|
/**
|
|
44
|
-
@param {Object} relationshipDataHash
|
|
45
|
-
@return {Object}
|
|
46
42
|
@private
|
|
47
43
|
*/
|
|
48
44
|
_normalizeRelationshipDataHelper(relationshipDataHash) {
|
|
@@ -50,8 +46,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
50
46
|
return relationshipDataHash;
|
|
51
47
|
},
|
|
52
48
|
/**
|
|
53
|
-
@param {Object} resourceHash
|
|
54
|
-
@return {Object}
|
|
55
49
|
@private
|
|
56
50
|
*/
|
|
57
51
|
_normalizeResourceHelper(resourceHash) {
|
|
@@ -88,21 +82,13 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
88
82
|
/**
|
|
89
83
|
Normalize some data and push it into the store.
|
|
90
84
|
@public
|
|
91
|
-
@param {Store} store
|
|
92
|
-
@param {Object} payload
|
|
93
85
|
*/
|
|
94
86
|
pushPayload(store, payload) {
|
|
95
87
|
const normalizedPayload = this._normalizeDocumentHelper(payload);
|
|
96
88
|
store.push(normalizedPayload);
|
|
97
89
|
},
|
|
98
90
|
/**
|
|
99
|
-
@
|
|
100
|
-
@param {Model} primaryModelClass
|
|
101
|
-
@param {Object} payload
|
|
102
|
-
@param {String|Number} id
|
|
103
|
-
@param {String} requestType
|
|
104
|
-
@param {Boolean} isSingle
|
|
105
|
-
@return {Object} JSON-API Document
|
|
91
|
+
@return A {json:api} Document
|
|
106
92
|
@private
|
|
107
93
|
*/
|
|
108
94
|
_normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {
|
|
@@ -144,8 +130,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
144
130
|
Returns a relationship formatted as a JSON-API "relationship object".
|
|
145
131
|
http://jsonapi.org/format/#document-resource-object-relationships
|
|
146
132
|
@public
|
|
147
|
-
@param {Object} relationshipHash
|
|
148
|
-
@return {Object}
|
|
149
133
|
*/
|
|
150
134
|
extractRelationship(relationshipHash) {
|
|
151
135
|
if (Array.isArray(relationshipHash.data)) {
|
|
@@ -164,9 +148,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
164
148
|
Returns the resource's relationships formatted as a JSON-API "relationships object".
|
|
165
149
|
http://jsonapi.org/format/#document-resource-object-relationships
|
|
166
150
|
@public
|
|
167
|
-
@param {Object} modelClass
|
|
168
|
-
@param {Object} resourceHash
|
|
169
|
-
@return {Object}
|
|
170
151
|
*/
|
|
171
152
|
extractRelationships(modelClass, resourceHash) {
|
|
172
153
|
const relationships = {};
|
|
@@ -191,9 +172,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
191
172
|
return relationships;
|
|
192
173
|
},
|
|
193
174
|
/**
|
|
194
|
-
@param {Model} modelClass
|
|
195
|
-
@param {Object} resourceHash
|
|
196
|
-
@return {String}
|
|
197
175
|
@private
|
|
198
176
|
*/
|
|
199
177
|
_extractType(modelClass, resourceHash) {
|
|
@@ -201,12 +179,11 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
201
179
|
},
|
|
202
180
|
/**
|
|
203
181
|
Dasherizes and singularizes the model name in the payload to match
|
|
204
|
-
the
|
|
182
|
+
the common convention for model names.
|
|
205
183
|
For example the key `posts` would be converted to `post` and the
|
|
206
184
|
key `studentAssesments` would be converted to `student-assesment`.
|
|
207
185
|
@public
|
|
208
|
-
@
|
|
209
|
-
@return {String} the model's modelName
|
|
186
|
+
@return the model's modelName
|
|
210
187
|
*/
|
|
211
188
|
modelNameFromPayloadKey(key) {
|
|
212
189
|
return dasherize(singularize(key));
|
|
@@ -216,8 +193,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
216
193
|
For example `post` would be converted to `posts` and
|
|
217
194
|
`student-assesment` would be converted to `student-assesments`.
|
|
218
195
|
@public
|
|
219
|
-
@param {String} modelName
|
|
220
|
-
@return {String}
|
|
221
196
|
*/
|
|
222
197
|
payloadKeyFromModelName(modelName) {
|
|
223
198
|
return pluralize(modelName);
|
|
@@ -258,7 +233,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
258
233
|
This behaviour can be easily customized by extending this method.
|
|
259
234
|
Example
|
|
260
235
|
```js [app/serializers/application.js]
|
|
261
|
-
import JSONAPISerializer from '@
|
|
236
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
262
237
|
import { dasherize } from '<app-name>/utils/string-utils';
|
|
263
238
|
export default class ApplicationSerializer extends JSONAPISerializer {
|
|
264
239
|
keyForAttribute(attr, method) {
|
|
@@ -267,9 +242,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
267
242
|
}
|
|
268
243
|
```
|
|
269
244
|
@public
|
|
270
|
-
@
|
|
271
|
-
@param {String} method
|
|
272
|
-
@return {String} normalized key
|
|
245
|
+
@return normalized key
|
|
273
246
|
*/
|
|
274
247
|
keyForAttribute(key, method) {
|
|
275
248
|
return dasherize(key);
|
|
@@ -283,7 +256,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
283
256
|
This behaviour can be easily customized by extending this method.
|
|
284
257
|
Example
|
|
285
258
|
```js [app/serializers/post.js]
|
|
286
|
-
import JSONAPISerializer from '@
|
|
259
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
287
260
|
import { underscore } from '<app-name>/utils/string-utils';
|
|
288
261
|
export default class ApplicationSerializer extends JSONAPISerializer {
|
|
289
262
|
keyForRelationship(key, relationship, method) {
|
|
@@ -292,10 +265,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
292
265
|
}
|
|
293
266
|
```
|
|
294
267
|
@public
|
|
295
|
-
@
|
|
296
|
-
@param {String} typeClass
|
|
297
|
-
@param {String} method
|
|
298
|
-
@return {String} normalized key
|
|
268
|
+
@return the normalized key
|
|
299
269
|
*/
|
|
300
270
|
keyForRelationship(key, typeClass, method) {
|
|
301
271
|
return dasherize(key);
|
|
@@ -305,7 +275,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
305
275
|
record into JSON.
|
|
306
276
|
For example, consider this model:
|
|
307
277
|
```js [app/models/comment.js]
|
|
308
|
-
import Model, { attr, belongsTo } from '@
|
|
278
|
+
import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
|
|
309
279
|
export default class CommentModel extends Model {
|
|
310
280
|
@attr title;
|
|
311
281
|
@attr body;
|
|
@@ -356,7 +326,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
356
326
|
consider authoring your own adapter and serializer instead of extending
|
|
357
327
|
this class.
|
|
358
328
|
```js [app/serializers/post.js]
|
|
359
|
-
import JSONAPISerializer from '@
|
|
329
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
360
330
|
export default class PostSerializer extends JSONAPISerializer {
|
|
361
331
|
serialize(snapshot, options) {
|
|
362
332
|
let json = {
|
|
@@ -376,7 +346,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
376
346
|
application, you'll probably want to use `eachAttribute`
|
|
377
347
|
and `eachRelationship` on the record.
|
|
378
348
|
```js [app/serializers/application.js]
|
|
379
|
-
import JSONAPISerializer from '@
|
|
349
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
380
350
|
import { underscore, singularize } from '<app-name>/utils/string-utils';
|
|
381
351
|
export default class ApplicationSerializer extends JSONAPISerializer {
|
|
382
352
|
serialize(snapshot, options) {
|
|
@@ -415,7 +385,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
415
385
|
you can call `super.serialize` first and make the tweaks
|
|
416
386
|
on the returned object.
|
|
417
387
|
```js [app/serializers/post.js]
|
|
418
|
-
import JSONAPISerializer from '@
|
|
388
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
419
389
|
export default class PostSerializer extends JSONAPISerializer {
|
|
420
390
|
serialize(snapshot, options) {
|
|
421
391
|
let json = super.serialize(...arguments);
|
|
@@ -426,9 +396,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
426
396
|
}
|
|
427
397
|
```
|
|
428
398
|
@public
|
|
429
|
-
@param {Snapshot} snapshot
|
|
430
|
-
@param {Object} options
|
|
431
|
-
@return {Object} json
|
|
432
399
|
*/
|
|
433
400
|
serialize(snapshot, options) {
|
|
434
401
|
// @ts-expect-error untyped
|
|
@@ -467,6 +434,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
467
434
|
// @ts-expect-error untyped
|
|
468
435
|
if (this._canSerialize(name)) {
|
|
469
436
|
const belongsTo = snapshot.belongsTo(name);
|
|
437
|
+
// @ts-expect-error not narrowed
|
|
470
438
|
const belongsToIsNotNew = belongsTo && !belongsTo.isNew;
|
|
471
439
|
if (belongsTo === null || belongsToIsNotNew) {
|
|
472
440
|
json.relationships = json.relationships || {};
|
|
@@ -480,11 +448,13 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
480
448
|
}
|
|
481
449
|
let data = null;
|
|
482
450
|
if (belongsTo) {
|
|
451
|
+
// @ts-expect-error not narrowed
|
|
483
452
|
const payloadType = this.payloadKeyFromModelName(belongsTo.modelName);
|
|
484
453
|
|
|
485
454
|
// @ts-expect-error untyped
|
|
486
455
|
data = {
|
|
487
456
|
type: payloadType,
|
|
457
|
+
// @ts-expect-error not narrowed
|
|
488
458
|
id: belongsTo.id
|
|
489
459
|
};
|
|
490
460
|
}
|
|
@@ -512,13 +482,16 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
512
482
|
}
|
|
513
483
|
|
|
514
484
|
// only serialize has many relationships that are not new
|
|
485
|
+
// @ts-expect-error not narrowed
|
|
515
486
|
const nonNewHasMany = hasMany.filter(item => !item.isNew);
|
|
516
487
|
const data = new Array(nonNewHasMany.length);
|
|
517
488
|
for (let i = 0; i < nonNewHasMany.length; i++) {
|
|
518
489
|
const item = hasMany[i];
|
|
490
|
+
// @ts-expect-error not narrowed
|
|
519
491
|
const payloadType = this.payloadKeyFromModelName(item.modelName);
|
|
520
492
|
data[i] = {
|
|
521
493
|
type: payloadType,
|
|
494
|
+
// @ts-expect-error not narrowed
|
|
522
495
|
id: item.id
|
|
523
496
|
};
|
|
524
497
|
}
|
package/dist/serializer/json.js
CHANGED
|
@@ -2,5 +2,5 @@ import '@ember/application';
|
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import '@warp-drive/utilities/string';
|
|
4
4
|
import '../serializer.js';
|
|
5
|
-
export { J as JSONSerializer } from "../json-
|
|
5
|
+
export { J as JSONSerializer } from "../json-ChdEfB0X.js";
|
|
6
6
|
import '@embroider/macros';
|