@warp-drive/legacy 5.8.0-alpha.4 → 5.8.0-alpha.40
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 +14 -27
- package/declarations/adapter/error.d.ts +5 -5
- package/declarations/adapter/json-api.d.ts +6 -8
- package/declarations/adapter/rest.d.ts +5 -8
- package/declarations/adapter.d.ts +4 -6
- 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 +8 -8
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +5 -5
- package/declarations/model/-private/references/has-many.d.ts +3 -3
- 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 +7 -9
- package/declarations/serializer/json.d.ts +7 -9
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +9 -12
- package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +12 -13
- package/dist/adapter/json-api.js +4 -1
- package/dist/adapter/rest.js +6 -9
- package/dist/adapter.js +4 -6
- 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 +58 -41
- package/dist/{errors-8kD2mSe_.js → errors-CIGPcDvd.js} +87 -65
- package/dist/hooks-QqRnX108.js +74 -0
- package/dist/index.js +195 -0
- package/dist/{json-DziiodPf.js → json-BNrV8EYG.js} +12 -16
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +54 -24
- 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-g5MfTj8n.js} +18 -20
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
- package/dist/serializer/json-api.js +17 -44
- 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 +3 -0
- package/dist/unpkg/dev/-private-DbaSCSym.js +1205 -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 +1255 -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 +1146 -0
- package/dist/unpkg/dev/errors-DD96TBEs.js +2591 -0
- package/dist/unpkg/dev/hooks-CqWjNWeL.js +73 -0
- package/dist/unpkg/dev/index.js +197 -0
- package/dist/unpkg/dev/json-CCU-ZQ4b.js +1269 -0
- package/dist/unpkg/dev/model/-private.js +1 -0
- package/dist/unpkg/dev/model/migration-support.js +551 -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-B8jiJOYC.js +2229 -0
- package/dist/unpkg/dev/serialize-into-hash-CPAZXrQU.js +259 -0
- package/dist/unpkg/dev/serializer/json-api.js +648 -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 +636 -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-DbaSCSym.js +1205 -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 +1255 -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 +1146 -0
- package/dist/unpkg/dev-deprecated/errors-DEnabIZj.js +2594 -0
- package/dist/unpkg/dev-deprecated/hooks-CAll-Ets.js +73 -0
- package/dist/unpkg/dev-deprecated/index.js +196 -0
- package/dist/unpkg/dev-deprecated/json-CCU-ZQ4b.js +1269 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/model/migration-support.js +568 -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-k2qXQTBg.js +2254 -0
- package/dist/unpkg/dev-deprecated/serialize-into-hash-CPAZXrQU.js +259 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +648 -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 +636 -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-Cvf_97EG.js +970 -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 +1218 -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 +726 -0
- package/dist/unpkg/prod/errors-CXnfnBfQ.js +2343 -0
- package/dist/unpkg/prod/hooks-DvyWhLNg.js +41 -0
- package/dist/unpkg/prod/index.js +151 -0
- package/dist/unpkg/prod/json-BYrUP8ao.js +1256 -0
- package/dist/unpkg/prod/model/-private.js +1 -0
- package/dist/unpkg/prod/model/migration-support.js +544 -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-CHujJvA9.js +1904 -0
- package/dist/unpkg/prod/serialize-into-hash-DYU2egXl.js +215 -0
- package/dist/unpkg/prod/serializer/json-api.js +591 -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 +504 -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-Cvf_97EG.js +970 -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 +1218 -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 +726 -0
- package/dist/unpkg/prod-deprecated/errors-CG1SPYVg.js +2346 -0
- package/dist/unpkg/prod-deprecated/hooks-BIUBiNGR.js +41 -0
- package/dist/unpkg/prod-deprecated/index.js +150 -0
- package/dist/unpkg/prod-deprecated/json-BYrUP8ao.js +1256 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/model/migration-support.js +561 -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-BJ4TWnZf.js +1947 -0
- package/dist/unpkg/prod-deprecated/serialize-into-hash-DYU2egXl.js +215 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +591 -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 +504 -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 +14 -6
- 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
package/dist/compat/utils.js
CHANGED
|
@@ -6,7 +6,6 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
|
6
6
|
and more consistent use of IDs and types.
|
|
7
7
|
|
|
8
8
|
@module
|
|
9
|
-
@deprecated
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
let MismatchReporter = function () {};
|
|
@@ -33,7 +32,7 @@ let NormalizedType = str => {
|
|
|
33
32
|
* changes during normalization. This is useful for instrumenting
|
|
34
33
|
* to discover places where usage in the app is not consistent.
|
|
35
34
|
*
|
|
36
|
-
* @param
|
|
35
|
+
* @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
|
|
37
36
|
* @public
|
|
38
37
|
*/
|
|
39
38
|
function configureMismatchReporter(fn) {
|
|
@@ -45,7 +44,7 @@ function configureMismatchReporter(fn) {
|
|
|
45
44
|
* fails validation. This is useful for instrumenting
|
|
46
45
|
* to discover places where usage in the app is not consistent.
|
|
47
46
|
*
|
|
48
|
-
* @param
|
|
47
|
+
* @param fn - a function which takes a message and a condition
|
|
49
48
|
* @public
|
|
50
49
|
*/
|
|
51
50
|
function configureAssertFn(fn) {
|
|
@@ -62,7 +61,7 @@ function configureAssertFn(fn) {
|
|
|
62
61
|
* the configured mismatch reporter and assert functions will
|
|
63
62
|
* be called.
|
|
64
63
|
*
|
|
65
|
-
* @param
|
|
64
|
+
* @param fn - a function which takes a string and returns a string
|
|
66
65
|
* @public
|
|
67
66
|
*/
|
|
68
67
|
function configureTypeNormalization(fn) {
|
|
@@ -72,7 +71,7 @@ const NORMALIZED_TYPES = new Map();
|
|
|
72
71
|
|
|
73
72
|
/**
|
|
74
73
|
* Converts a potentially unnormalized type into the format expected
|
|
75
|
-
* by our
|
|
74
|
+
* by our WarpDrive Cache. Currently this is singular-dasherized.
|
|
76
75
|
*
|
|
77
76
|
* you should not rely on this function to give you an exact format
|
|
78
77
|
* for display purposes. Formatting for display should be handled
|
|
@@ -95,8 +94,8 @@ const NORMALIZED_TYPES = new Map();
|
|
|
95
94
|
* formattedType('PostComment'); // => 'post-comment'
|
|
96
95
|
* ```
|
|
97
96
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @return
|
|
97
|
+
* @param type the potentially un-normalized type
|
|
98
|
+
* @return the normalized type
|
|
100
99
|
* @public
|
|
101
100
|
*/
|
|
102
101
|
function formattedType(type) {
|
|
@@ -116,7 +115,7 @@ function formattedType(type) {
|
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
/**
|
|
119
|
-
* Format an id to the format expected by the
|
|
118
|
+
* Format an id to the format expected by the WarpDrive Cache.
|
|
120
119
|
* Currently this means that id should be `string | null`.
|
|
121
120
|
*
|
|
122
121
|
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
@@ -131,8 +130,8 @@ function formattedType(type) {
|
|
|
131
130
|
* formattedId(null); // => null
|
|
132
131
|
* ```
|
|
133
132
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @return
|
|
133
|
+
* @param id the potentially un-normalized id
|
|
134
|
+
* @return the normalized id
|
|
136
135
|
* @public
|
|
137
136
|
*/
|
|
138
137
|
|
|
@@ -154,7 +153,7 @@ function expectId(id) {
|
|
|
154
153
|
|
|
155
154
|
/**
|
|
156
155
|
* Compares two types for strict equality, converting them to
|
|
157
|
-
* the format expected by the
|
|
156
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
158
157
|
* differences in format are accounted for in the comparison.
|
|
159
158
|
*
|
|
160
159
|
* Asserts when expected or actual are invalid types in dev.
|
|
@@ -172,9 +171,9 @@ function expectId(id) {
|
|
|
172
171
|
* isEquivType('posts', null); // false
|
|
173
172
|
* ```
|
|
174
173
|
*
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
177
|
-
* @return
|
|
174
|
+
* @param expected a potentially unnormalized type to match against
|
|
175
|
+
* @param actual a potentially unnormalized type to match against
|
|
176
|
+
* @return true if the types are equivalent
|
|
178
177
|
* @public
|
|
179
178
|
*/
|
|
180
179
|
function isEquivType(expected, actual) {
|
|
@@ -191,7 +190,7 @@ function isEquivType(expected, actual) {
|
|
|
191
190
|
|
|
192
191
|
/**
|
|
193
192
|
* Compares two IDs for strict equality, converting them to
|
|
194
|
-
* the format expected by the
|
|
193
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
195
194
|
* differences in format are accounted for in the comparison.
|
|
196
195
|
*
|
|
197
196
|
* Asserts when expected or actual are invalid IDs in dev.
|
|
@@ -205,9 +204,9 @@ function isEquivType(expected, actual) {
|
|
|
205
204
|
* isEquivId(1, null); // false
|
|
206
205
|
* ```
|
|
207
206
|
*
|
|
208
|
-
* @param
|
|
209
|
-
* @param
|
|
210
|
-
* @return
|
|
207
|
+
* @param expected a potentially un-normalized id to match against
|
|
208
|
+
* @param actual a potentially un-normalized id to match against
|
|
209
|
+
* @return true if the ids are equivalent
|
|
211
210
|
* @public
|
|
212
211
|
*/
|
|
213
212
|
function isEquivId(expected, actual) {
|
package/dist/compat.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
3
|
import { assertPrivateStore, waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
|
|
4
4
|
import '@warp-drive/core/reactive/-private';
|
|
5
|
-
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-
|
|
5
|
+
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-B1pSSN52.js";
|
|
6
6
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
7
7
|
function _findHasMany(adapter, store, identifier, link, relationship, options) {
|
|
8
8
|
const promise = Promise.resolve().then(() => {
|
|
@@ -737,18 +737,30 @@ function queryRecord(context) {
|
|
|
737
737
|
}
|
|
738
738
|
|
|
739
739
|
/**
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
740
|
+
* Extends the signature of {@link Store} with additional
|
|
741
|
+
* methods available when using the legacy network layer.
|
|
742
|
+
*
|
|
743
|
+
* @public
|
|
744
|
+
* @noInheritDoc
|
|
745
|
+
* @legacy
|
|
746
|
+
*/
|
|
743
747
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
748
|
+
/**
|
|
749
|
+
* @deprecated - use {@link LegacyStoreCompat} instead
|
|
750
|
+
*/
|
|
747
751
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
+
/**
|
|
753
|
+
Returns an instance of the adapter for a given type. For
|
|
754
|
+
example, `adapterFor('person')` will return an instance of
|
|
755
|
+
the adapter located at `app/adapters/person.js`
|
|
756
|
+
|
|
757
|
+
If no `person` adapter is found, this method will look
|
|
758
|
+
for an `application` adapter (the default adapter for
|
|
759
|
+
your entire application).
|
|
760
|
+
|
|
761
|
+
@public
|
|
762
|
+
@param modelName
|
|
763
|
+
*/
|
|
752
764
|
|
|
753
765
|
function adapterFor(modelName, _allowMissing) {
|
|
754
766
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -799,20 +811,19 @@ function adapterFor(modelName, _allowMissing) {
|
|
|
799
811
|
}
|
|
800
812
|
|
|
801
813
|
/**
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
814
|
+
Returns an instance of the serializer for a given type. For
|
|
815
|
+
example, `serializerFor('person')` will return an instance of
|
|
816
|
+
`App.PersonSerializer`.
|
|
805
817
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
818
|
+
If no `App.PersonSerializer` is found, this method will look
|
|
819
|
+
for an `App.ApplicationSerializer` (the default serializer for
|
|
820
|
+
your entire application).
|
|
809
821
|
|
|
810
|
-
|
|
811
|
-
|
|
822
|
+
If a serializer cannot be found on the adapter, it will fall back
|
|
823
|
+
to an instance of `JSONSerializer`.
|
|
812
824
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
@return {Serializer}
|
|
825
|
+
@public
|
|
826
|
+
@param modelName the record to serialize
|
|
816
827
|
*/
|
|
817
828
|
function serializerFor(modelName) {
|
|
818
829
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -859,23 +870,29 @@ function serializerFor(modelName) {
|
|
|
859
870
|
}
|
|
860
871
|
|
|
861
872
|
/**
|
|
862
|
-
|
|
863
|
-
|
|
873
|
+
`normalize` converts a json payload into the normalized form expected by
|
|
874
|
+
{@link Store.push | push} using the serializer specified by `modelName`
|
|
864
875
|
|
|
865
|
-
|
|
876
|
+
:::warning
|
|
877
|
+
Generally it would be better to invoke the serializer yourself directly,
|
|
878
|
+
or write a more specialized normalization utility.
|
|
879
|
+
:::
|
|
866
880
|
|
|
867
|
-
|
|
868
|
-
socket.on('message', function(message) {
|
|
869
|
-
let modelName = message.model;
|
|
870
|
-
let data = message.data;
|
|
871
|
-
store.push(store.normalize(modelName, data));
|
|
872
|
-
});
|
|
873
|
-
```
|
|
881
|
+
Example
|
|
874
882
|
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
883
|
+
```js
|
|
884
|
+
socket.on('message', function(message) {
|
|
885
|
+
let modelName = message.model;
|
|
886
|
+
let data = message.data;
|
|
887
|
+
store.push(store.normalize(modelName, data));
|
|
888
|
+
});
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
@legacy
|
|
892
|
+
@public
|
|
893
|
+
@param modelName The name of the model type for this payload
|
|
894
|
+
@return The normalized payload
|
|
895
|
+
*/
|
|
879
896
|
// TODO @runspired @deprecate users should call normalize on the associated serializer directly
|
|
880
897
|
function normalize(modelName, payload) {
|
|
881
898
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -914,7 +931,7 @@ function normalize(modelName, payload) {
|
|
|
914
931
|
serializer.
|
|
915
932
|
|
|
916
933
|
```js [app/serializers/application.js]
|
|
917
|
-
import RESTSerializer from '@
|
|
934
|
+
import RESTSerializer from '@warp-drive/legacy/serializer/rest';
|
|
918
935
|
|
|
919
936
|
export default class ApplicationSerializer extends RESTSerializer;
|
|
920
937
|
```
|
|
@@ -939,13 +956,13 @@ function normalize(modelName, payload) {
|
|
|
939
956
|
will determine which serializer will process the payload.
|
|
940
957
|
|
|
941
958
|
```js [app/serializers/application.js]
|
|
942
|
-
import RESTSerializer from '@
|
|
959
|
+
import RESTSerializer from '@warp-drive/legacy/serializer/rest';
|
|
943
960
|
|
|
944
961
|
export default class ApplicationSerializer extends RESTSerializer;
|
|
945
962
|
```
|
|
946
963
|
|
|
947
964
|
```js [app/serializers/post.js]
|
|
948
|
-
import JSONSerializer from '@
|
|
965
|
+
import JSONSerializer from '@warp-drive/legacy/serializer/json';
|
|
949
966
|
|
|
950
967
|
export default JSONSerializer;
|
|
951
968
|
```
|
|
@@ -956,8 +973,8 @@ function normalize(modelName, payload) {
|
|
|
956
973
|
```
|
|
957
974
|
|
|
958
975
|
@public
|
|
959
|
-
@param
|
|
960
|
-
@param
|
|
976
|
+
@param modelName Optionally, a model type used to determine which serializer will be used
|
|
977
|
+
@param inputPayload
|
|
961
978
|
*/
|
|
962
979
|
// TODO @runspired @deprecate pushPayload in favor of looking up the serializer
|
|
963
980
|
function pushPayload(modelName, inputPayload) {
|