@warp-drive/legacy 5.6.0-alpha.15 → 5.6.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/adapter/-private/build-url-mixin.d.ts +41 -29
- package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
- package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
- package/declarations/adapter/-private.d.ts +5 -6
- package/declarations/adapter/error.d.ts +206 -178
- package/declarations/adapter/json-api.d.ts +206 -207
- package/declarations/adapter/rest.d.ts +805 -808
- package/declarations/adapter.d.ts +742 -766
- package/declarations/compat/-private.d.ts +10 -11
- package/declarations/compat/builders/find-all.d.ts +26 -24
- package/declarations/compat/builders/find-record.d.ts +41 -39
- package/declarations/compat/builders/query.d.ts +50 -45
- package/declarations/compat/builders/save-record.d.ts +26 -24
- package/declarations/compat/builders/utils.d.ts +1 -2
- package/declarations/compat/builders.d.ts +10 -11
- package/declarations/compat/extensions.d.ts +52 -106
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
- package/declarations/compat/utils.d.ts +118 -119
- package/declarations/compat.d.ts +106 -104
- package/declarations/model/-private/attr.d.ts +164 -145
- package/declarations/model/-private/belongs-to.d.ts +135 -122
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/model/-private/errors.d.ts +272 -267
- package/declarations/model/-private/has-many.d.ts +119 -116
- package/declarations/model/-private/hooks.d.ts +5 -6
- package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
- package/declarations/model/-private/model-for-mixin.d.ts +18 -3
- package/declarations/model/-private/model-methods.d.ts +29 -24
- package/declarations/model/-private/model.d.ts +1306 -1254
- package/declarations/model/-private/notify-changes.d.ts +3 -4
- package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
- package/declarations/model/-private/promise-many-array.d.ts +125 -116
- package/declarations/model/-private/record-state.d.ts +63 -60
- package/declarations/model/-private/references/belongs-to.d.ts +491 -487
- package/declarations/model/-private/references/has-many.d.ts +495 -492
- package/declarations/model/-private/schema-provider.d.ts +53 -56
- package/declarations/model/-private/type-utils.d.ts +41 -41
- package/declarations/model/-private/util.d.ts +1 -2
- package/declarations/model/-private.d.ts +8 -8
- package/declarations/model/migration-support.d.ts +281 -279
- package/declarations/model.d.ts +48 -49
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
- package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
- package/declarations/serializer/-private/transforms/date.d.ts +22 -22
- package/declarations/serializer/-private/transforms/number.d.ts +22 -22
- package/declarations/serializer/-private/transforms/string.d.ts +22 -22
- package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
- package/declarations/serializer/-private/utils.d.ts +0 -1
- package/declarations/serializer/json-api.d.ts +124 -494
- package/declarations/serializer/json.d.ts +62 -1031
- package/declarations/serializer/rest.d.ts +52 -552
- package/declarations/serializer/transform.d.ts +5 -6
- package/declarations/serializer.d.ts +217 -218
- package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +17 -0
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +5 -7
- package/dist/adapter.js +6 -35
- package/dist/compat/-private.js +1 -1
- package/dist/compat/extensions.js +0 -2
- package/dist/compat.js +3 -4
- package/dist/{errors-_QQ7xpSn.js → errors-BX5wowuz.js} +11 -10
- package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +3 -4
- package/dist/model.js +3 -3
- package/dist/{schema-provider-D_P8ReX6.js → schema-provider-BdQhkT-Q.js} +20 -13
- package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
- package/dist/serializer/json-api.js +42 -2
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +46 -41
- package/dist/serializer/transform.js +0 -44
- package/package.json +7 -7
- package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
- package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
- package/declarations/adapter/-private.d.ts.map +0 -1
- package/declarations/adapter/error.d.ts.map +0 -1
- package/declarations/adapter/json-api.d.ts.map +0 -1
- package/declarations/adapter/rest.d.ts.map +0 -1
- package/declarations/adapter.d.ts.map +0 -1
- package/declarations/compat/-private.d.ts.map +0 -1
- package/declarations/compat/builders/find-all.d.ts.map +0 -1
- package/declarations/compat/builders/find-record.d.ts.map +0 -1
- package/declarations/compat/builders/query.d.ts.map +0 -1
- package/declarations/compat/builders/save-record.d.ts.map +0 -1
- package/declarations/compat/builders/utils.d.ts.map +0 -1
- package/declarations/compat/builders.d.ts.map +0 -1
- package/declarations/compat/extensions.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
- package/declarations/compat/utils.d.ts.map +0 -1
- package/declarations/compat.d.ts.map +0 -1
- package/declarations/model/-private/attr.d.ts.map +0 -1
- package/declarations/model/-private/attr.type-test.d.ts +0 -2
- package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
- package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/model/-private/errors.d.ts.map +0 -1
- package/declarations/model/-private/has-many.d.ts.map +0 -1
- package/declarations/model/-private/has-many.type-test.d.ts +0 -2
- package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
- package/declarations/model/-private/hooks.d.ts.map +0 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
- package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
- package/declarations/model/-private/model-methods.d.ts.map +0 -1
- package/declarations/model/-private/model.d.ts.map +0 -1
- package/declarations/model/-private/model.type-test.d.ts +0 -2
- package/declarations/model/-private/model.type-test.d.ts.map +0 -1
- package/declarations/model/-private/notify-changes.d.ts.map +0 -1
- package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
- package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
- package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
- package/declarations/model/-private/record-state.d.ts.map +0 -1
- package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/references/has-many.d.ts.map +0 -1
- package/declarations/model/-private/schema-provider.d.ts.map +0 -1
- package/declarations/model/-private/type-utils.d.ts.map +0 -1
- package/declarations/model/-private/util.d.ts.map +0 -1
- package/declarations/model/-private.d.ts.map +0 -1
- package/declarations/model/migration-support.d.ts.map +0 -1
- package/declarations/model/migration-support.type-test.d.ts +0 -2
- package/declarations/model/migration-support.type-test.d.ts.map +0 -1
- package/declarations/model.d.ts.map +0 -1
- package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
- package/declarations/serializer/-private/utils.d.ts.map +0 -1
- package/declarations/serializer/json-api.d.ts.map +0 -1
- package/declarations/serializer/json.d.ts.map +0 -1
- package/declarations/serializer/rest.d.ts.map +0 -1
- package/declarations/serializer/transform.d.ts.map +0 -1
- package/declarations/serializer.d.ts.map +0 -1
- package/dist/-private-DFfBszo5.js.map +0 -1
- package/dist/adapter/-private.js.map +0 -1
- package/dist/adapter/error.js.map +0 -1
- package/dist/adapter/json-api.js.map +0 -1
- package/dist/adapter/rest.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/compat/-private.js.map +0 -1
- package/dist/compat/builders.js.map +0 -1
- package/dist/compat/extensions.js.map +0 -1
- package/dist/compat/utils.js.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/errors-_QQ7xpSn.js.map +0 -1
- package/dist/json-DSOlH9A8.js.map +0 -1
- package/dist/model/-private.js.map +0 -1
- package/dist/model/migration-support.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
- package/dist/schema-provider-D_P8ReX6.js.map +0 -1
- package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
- package/dist/serializer/json-api.js.map +0 -1
- package/dist/serializer/json.js.map +0 -1
- package/dist/serializer/rest.js.map +0 -1
- package/dist/serializer/transform.js.map +0 -1
- package/dist/serializer.js.map +0 -1
|
@@ -1,138 +1,137 @@
|
|
|
1
|
-
type Reporter = (type:
|
|
1
|
+
type Reporter = (type: "formatted-id" | "formatted-type", actual: unknown, expected: unknown) => void;
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
* Configure a function to be called when an id or type
|
|
4
|
+
* changes during normalization. This is useful for instrumenting
|
|
5
|
+
* to discover places where usage in the app is not consistent.
|
|
6
|
+
*
|
|
7
|
+
* @param method a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
10
|
export declare function configureMismatchReporter(fn: Reporter): void;
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
* Configure a function to be called when an id or type
|
|
13
|
+
* fails validation. This is useful for instrumenting
|
|
14
|
+
* to discover places where usage in the app is not consistent.
|
|
15
|
+
*
|
|
16
|
+
* @param method a function which takes a message and a condition
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
19
|
export declare function configureAssertFn(fn: (message: string, condition: unknown) => void): void;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
* Configure a function to be called to normalize
|
|
22
|
+
* a resource type string. Used by both formattedType
|
|
23
|
+
* and isEquivType to ensure consistent normalization
|
|
24
|
+
* during comparison.
|
|
25
|
+
*
|
|
26
|
+
* If validation fails or the type turns out be unnormalized
|
|
27
|
+
* the configured mismatch reporter and assert functions will
|
|
28
|
+
* be called.
|
|
29
|
+
*
|
|
30
|
+
* @param method a function which takes a string and returns a string
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
33
|
export declare function configureTypeNormalization(fn: (type: string) => string): void;
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
35
|
+
* Converts a potentially unnormalized type into the format expected
|
|
36
|
+
* by our EmberData Cache. Currently this is singular-dasherized.
|
|
37
|
+
*
|
|
38
|
+
* you should not rely on this function to give you an exact format
|
|
39
|
+
* for display purposes. Formatting for display should be handled
|
|
40
|
+
* differently if the exact format matters.
|
|
41
|
+
*
|
|
42
|
+
* Asserts invalid types (undefined, null, '') in dev.
|
|
43
|
+
*
|
|
44
|
+
* **Usage**
|
|
45
|
+
*
|
|
46
|
+
* ```js
|
|
47
|
+
* import formattedType from 'soxhub-client/helpers/formatted-type';
|
|
48
|
+
*
|
|
49
|
+
* formattedType('post'); // => 'post'
|
|
50
|
+
* formattedType('posts'); // => 'post'
|
|
51
|
+
* formattedType('Posts'); // => 'post'
|
|
52
|
+
* formattedType('post-comment'); // => 'post-comment'
|
|
53
|
+
* formattedType('post-comments'); // => 'post-comment'
|
|
54
|
+
* formattedType('post_comment'); // => 'post-comment'
|
|
55
|
+
* formattedType('postComment'); // => 'post-comment'
|
|
56
|
+
* formattedType('PostComment'); // => 'post-comment'
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param {String} type the potentially un-normalized type
|
|
60
|
+
* @return {String} the normalized type
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
63
|
export declare function formattedType<T extends string>(type: T | string): T;
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
* Format an id to the format expected by the EmberData Cache.
|
|
66
|
+
* Currently this means that id should be `string | null`.
|
|
67
|
+
*
|
|
68
|
+
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
69
|
+
*
|
|
70
|
+
* **Usage**
|
|
71
|
+
*
|
|
72
|
+
* ```js
|
|
73
|
+
* import formattedId from 'client/utils/formatted-id';
|
|
74
|
+
*
|
|
75
|
+
* formattedId('1'); // => '1'
|
|
76
|
+
* formattedId(1); // => '1'
|
|
77
|
+
* formattedId(null); // => null
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @param {String | Number | null} id the potentially un-normalized id
|
|
81
|
+
* @return {String | null} the normalized id
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
84
|
export declare function formattedId(id: string | number): string;
|
|
85
85
|
export declare function formattedId(id: null): null;
|
|
86
86
|
export declare function formattedId(id: string | number | null): string | null;
|
|
87
87
|
export declare function expectId(id: string | number): string;
|
|
88
88
|
export declare function expectId(id: null): never;
|
|
89
89
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
* Compares two types for strict equality, converting them to
|
|
91
|
+
* the format expected by the EmberData Cache to ensure
|
|
92
|
+
* differences in format are accounted for in the comparison.
|
|
93
|
+
*
|
|
94
|
+
* Asserts when expected or actual are invalid types in dev.
|
|
95
|
+
* Expected may never be null.
|
|
96
|
+
*
|
|
97
|
+
* ```js
|
|
98
|
+
* isEquivType('posts', 'post'); // true
|
|
99
|
+
* isEquivType('post', 'post'); // true
|
|
100
|
+
* isEquivType('posts', 'posts'); // true
|
|
101
|
+
* isEquivType('post-comment', 'postComment'); // true
|
|
102
|
+
* isEquivType('post-comment', 'PostComment'); // true
|
|
103
|
+
* isEquivType('post-comment', 'post_comment'); // true
|
|
104
|
+
* isEquivType('post-comment', 'post-comment'); // true
|
|
105
|
+
* isEquivType('post-comment', 'post'); // false
|
|
106
|
+
* isEquivType('posts', null); // false
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @param {String} expected a potentially unnormalized type to match against
|
|
110
|
+
* @param {String} actual a potentially unnormalized type to match against
|
|
111
|
+
* @return {Boolean} true if the types are equivalent
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
114
|
export declare function isEquivType(expected: string, actual: string): boolean;
|
|
115
115
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
116
|
+
* Compares two IDs for strict equality, converting them to
|
|
117
|
+
* the format expected by the EmberData Cache to ensure
|
|
118
|
+
* differences in format are accounted for in the comparison.
|
|
119
|
+
*
|
|
120
|
+
* Asserts when expected or actual are invalid IDs in dev.
|
|
121
|
+
* Expected may never be null.
|
|
122
|
+
*
|
|
123
|
+
* ```js
|
|
124
|
+
* isEquivId('1', 1); // true
|
|
125
|
+
* isEquivId('2', '2'); // true
|
|
126
|
+
* isEquivId(3, '3'); // true
|
|
127
|
+
* isEquivId(4, '3'); // false
|
|
128
|
+
* isEquivId(1, null); // false
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param {string | number} expected a potentially un-normalized id to match against
|
|
132
|
+
* @param {string | number} actual a potentially un-normalized id to match against
|
|
133
|
+
* @return {Boolean} true if the ids are equivalent
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
136
|
export declare function isEquivId(expected: string | number, actual: string | number | null): boolean;
|
|
137
137
|
export {};
|
|
138
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/declarations/compat.d.ts
CHANGED
|
@@ -1,134 +1,136 @@
|
|
|
1
|
-
import { type Store } from
|
|
2
|
-
import type { ObjectValue } from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
|
|
1
|
+
import { type Store } from "@warp-drive/core";
|
|
2
|
+
import type { ObjectValue } from "@warp-drive/core/types/json/raw";
|
|
3
|
+
import type { SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
|
|
4
|
+
import { FetchManager } from "./compat/-private.js";
|
|
5
|
+
import type { AdapterPayload, MinimumAdapterInterface } from "./compat/legacy-network-handler/minimum-adapter-interface.js";
|
|
6
|
+
import type { MinimumSerializerInterface, SerializerOptions } from "./compat/legacy-network-handler/minimum-serializer-interface.js";
|
|
7
|
+
export { LegacyNetworkHandler } from "./compat/legacy-network-handler/legacy-network-handler.js";
|
|
7
8
|
export type { MinimumAdapterInterface, MinimumSerializerInterface, SerializerOptions, AdapterPayload };
|
|
8
9
|
export type LegacyStoreCompat = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
_fetchManager: FetchManager;
|
|
11
|
+
adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
12
|
+
adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
13
|
+
serializerFor<K extends string>(modelName: K, _allowMissing?: boolean): MinimumSerializerInterface | null;
|
|
14
|
+
normalize(modelName: string, payload: ObjectValue): ObjectValue;
|
|
15
|
+
pushPayload(modelName: string, payload: ObjectValue): void;
|
|
16
|
+
serializeRecord(record: unknown, options?: SerializerOptions): unknown;
|
|
17
|
+
_adapterCache: Record<string, MinimumAdapterInterface & {
|
|
18
|
+
store: Store;
|
|
19
|
+
}>;
|
|
20
|
+
_serializerCache: Record<string, MinimumSerializerInterface & {
|
|
21
|
+
store: Store;
|
|
22
|
+
}>;
|
|
22
23
|
};
|
|
23
24
|
export type CompatStore = Store & LegacyStoreCompat;
|
|
24
25
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
Returns an instance of the adapter for a given type. For
|
|
27
|
+
example, `adapterFor('person')` will return an instance of
|
|
28
|
+
the adapter located at `app/adapters/person.js`
|
|
29
|
+
|
|
30
|
+
If no `person` adapter is found, this method will look
|
|
31
|
+
for an `application` adapter (the default adapter for
|
|
32
|
+
your entire application).
|
|
33
|
+
|
|
34
|
+
@public
|
|
35
|
+
@param {String} modelName
|
|
36
|
+
@return {Adapter}
|
|
37
|
+
*/
|
|
37
38
|
export declare function adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
38
39
|
export declare function adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
39
40
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
Returns an instance of the serializer for a given type. For
|
|
42
|
+
example, `serializerFor('person')` will return an instance of
|
|
43
|
+
`App.PersonSerializer`.
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
If no `App.PersonSerializer` is found, this method will look
|
|
46
|
+
for an `App.ApplicationSerializer` (the default serializer for
|
|
47
|
+
your entire application).
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
If a serializer cannot be found on the adapter, it will fall back
|
|
50
|
+
to an instance of `JSONSerializer`.
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
@public
|
|
53
|
+
@param {String} modelName the record to serialize
|
|
54
|
+
@return {Serializer}
|
|
55
|
+
*/
|
|
55
56
|
export declare function serializerFor(this: Store, modelName: string): MinimumSerializerInterface | null;
|
|
56
57
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export declare function normalize(this: Store, modelName: string, payload: ObjectValue):
|
|
58
|
+
`normalize` converts a json payload into the normalized form that
|
|
59
|
+
[push](../methods/push?anchor=push) expects.
|
|
60
|
+
|
|
61
|
+
Example
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
socket.on('message', function(message) {
|
|
65
|
+
let modelName = message.model;
|
|
66
|
+
let data = message.data;
|
|
67
|
+
store.push(store.normalize(modelName, data));
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
@public
|
|
72
|
+
@param modelName The name of the model type for this payload
|
|
73
|
+
@return The normalized payload
|
|
74
|
+
*/
|
|
75
|
+
// TODO @runspired @deprecate users should call normalize on the associated serializer directly
|
|
76
|
+
export declare function normalize(this: Store, modelName: string, payload: ObjectValue): SingleResourceDocument;
|
|
76
77
|
/**
|
|
77
|
-
|
|
78
|
+
Push some raw data into the store.
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
This method can be used both to push in brand new
|
|
81
|
+
records, as well as to update existing records. You
|
|
82
|
+
can push in more than one type of object at once.
|
|
83
|
+
All objects should be in the format expected by the
|
|
84
|
+
serializer.
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
```js [app/serializers/application.js]
|
|
87
|
+
import RESTSerializer from '@ember-data/serializer/rest';
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
export default class ApplicationSerializer extends RESTSerializer;
|
|
90
|
+
```
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
```js
|
|
93
|
+
let pushData = {
|
|
94
|
+
posts: [
|
|
95
|
+
{ id: 1, postTitle: "Great post", commentIds: [2] }
|
|
96
|
+
],
|
|
97
|
+
comments: [
|
|
98
|
+
{ id: 2, commentBody: "Insightful comment" }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
store.pushPayload(pushData);
|
|
103
|
+
```
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
By default, the data will be deserialized using a default
|
|
106
|
+
serializer (the application serializer if it exists).
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
Alternatively, `pushPayload` will accept a model type which
|
|
109
|
+
will determine which serializer will process the payload.
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
```js [app/serializers/application.js]
|
|
112
|
+
import RESTSerializer from '@ember-data/serializer/rest';
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
export default class ApplicationSerializer extends RESTSerializer;
|
|
115
|
+
```
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
```js [app/serializers/post.js]
|
|
118
|
+
import JSONSerializer from '@ember-data/serializer/json';
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
export default JSONSerializer;
|
|
121
|
+
```
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
```js
|
|
124
|
+
store.pushPayload(pushData); // Will use the application serializer
|
|
125
|
+
store.pushPayload('post', pushData); // Will use the post serializer
|
|
126
|
+
```
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
@public
|
|
129
|
+
@param {String} modelName Optionally, a model type used to determine which serializer will be used
|
|
130
|
+
@param {Object} inputPayload
|
|
131
|
+
*/
|
|
132
|
+
// TODO @runspired @deprecate pushPayload in favor of looking up the serializer
|
|
131
133
|
export declare function pushPayload(this: Store, modelName: string, inputPayload: ObjectValue): void;
|
|
134
|
+
// TODO @runspired @deprecate records should implement their own serialization if desired
|
|
132
135
|
export declare function serializeRecord(this: Store, record: unknown, options?: SerializerOptions): unknown;
|
|
133
136
|
export declare function cleanup(this: Store): void;
|
|
134
|
-
//# sourceMappingURL=compat.d.ts.map
|