@ember-data/legacy-compat 5.6.0-beta.0 → 5.6.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/addon-main.cjs +1 -1
- package/dist/-private.js +1 -1
- package/dist/builders.js +1 -323
- package/dist/index.js +1 -1011
- package/dist/utils.js +1 -246
- package/package.json +7 -34
- package/unstable-preview-types/-private.d.ts +7 -14
- package/unstable-preview-types/builders.d.ts +9 -13
- package/unstable-preview-types/index.d.ts +4 -159
- package/unstable-preview-types/utils.d.ts +9 -159
- package/dist/-private-Bnt-3W7M.js +0 -1207
- package/dist/-private-Bnt-3W7M.js.map +0 -1
- package/dist/-private.js.map +0 -1
- package/dist/builders.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/unstable-preview-types/-private.d.ts.map +0 -1
- package/unstable-preview-types/builders/find-all.d.ts +0 -41
- package/unstable-preview-types/builders/find-all.d.ts.map +0 -1
- package/unstable-preview-types/builders/find-record.d.ts +0 -62
- package/unstable-preview-types/builders/find-record.d.ts.map +0 -1
- package/unstable-preview-types/builders/query.d.ts +0 -72
- package/unstable-preview-types/builders/query.d.ts.map +0 -1
- package/unstable-preview-types/builders/save-record.d.ts +0 -40
- package/unstable-preview-types/builders/save-record.d.ts.map +0 -1
- package/unstable-preview-types/builders/utils.d.ts +0 -6
- package/unstable-preview-types/builders/utils.d.ts.map +0 -1
- package/unstable-preview-types/builders.d.ts.map +0 -1
- package/unstable-preview-types/index.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts +0 -49
- package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts +0 -5
- package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts +0 -14
- package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts +0 -8
- package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts +0 -5
- package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts +0 -549
- package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts +0 -235
- package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts +0 -9
- package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts +0 -96
- package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
- package/unstable-preview-types/legacy-network-handler/snapshot.d.ts +0 -248
- package/unstable-preview-types/legacy-network-handler/snapshot.d.ts.map +0 -1
- package/unstable-preview-types/utils.d.ts.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -1,246 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
Utilities for helping to migrate to stricter
|
|
6
|
-
and more consistent use of IDs and types.
|
|
7
|
-
|
|
8
|
-
@module @ember-data/legacy-compat/utils
|
|
9
|
-
@main @ember-data/legacy-compat/utils
|
|
10
|
-
@deprecated
|
|
11
|
-
*/
|
|
12
|
-
let MismatchReporter = function () {};
|
|
13
|
-
|
|
14
|
-
// TODO: @runspired This pattern prevents AssertFn from being removed in production builds
|
|
15
|
-
// but we should enable that if we can.
|
|
16
|
-
let _AssertFn = function () {};
|
|
17
|
-
const AssertFn = (message, condition) => {
|
|
18
|
-
if (!condition) {
|
|
19
|
-
_AssertFn(message, condition);
|
|
20
|
-
}
|
|
21
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
22
|
-
if (!test) {
|
|
23
|
-
throw new Error(message);
|
|
24
|
-
}
|
|
25
|
-
})(condition) : {};
|
|
26
|
-
};
|
|
27
|
-
let NormalizedType = str => {
|
|
28
|
-
return singularize(dasherize(str));
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Configure a function to be called when an id or type
|
|
33
|
-
* changes during normalization. This is useful for instrumenting
|
|
34
|
-
* to discover places where usage in the app is not consistent.
|
|
35
|
-
*
|
|
36
|
-
* @method configureMismatchReporter
|
|
37
|
-
* @for @ember-data/legacy-compat/utils
|
|
38
|
-
* @param method a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
|
|
39
|
-
* @public
|
|
40
|
-
* @static
|
|
41
|
-
*/
|
|
42
|
-
function configureMismatchReporter(fn) {
|
|
43
|
-
MismatchReporter = fn;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Configure a function to be called when an id or type
|
|
48
|
-
* fails validation. This is useful for instrumenting
|
|
49
|
-
* to discover places where usage in the app is not consistent.
|
|
50
|
-
*
|
|
51
|
-
* @method configureAssertFn
|
|
52
|
-
* @for @ember-data/legacy-compat/utils
|
|
53
|
-
* @param method a function which takes a message and a condition
|
|
54
|
-
* @public
|
|
55
|
-
* @static
|
|
56
|
-
*/
|
|
57
|
-
function configureAssertFn(fn) {
|
|
58
|
-
_AssertFn = fn;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Configure a function to be called to normalize
|
|
63
|
-
* a resource type string. Used by both formattedType
|
|
64
|
-
* and isEquivType to ensure consistent normalization
|
|
65
|
-
* during comparison.
|
|
66
|
-
*
|
|
67
|
-
* If validation fails or the type turns out be unnormalized
|
|
68
|
-
* the configured mismatch reporter and assert functions will
|
|
69
|
-
* be called.
|
|
70
|
-
*
|
|
71
|
-
* @method configureTypeNormalization
|
|
72
|
-
* @for @ember-data/legacy-compat/utils
|
|
73
|
-
* @param method a function which takes a string and returns a string
|
|
74
|
-
* @public
|
|
75
|
-
* @static
|
|
76
|
-
*/
|
|
77
|
-
function configureTypeNormalization(fn) {
|
|
78
|
-
NormalizedType = fn;
|
|
79
|
-
}
|
|
80
|
-
const NORMALIZED_TYPES = new Map();
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Converts a potentially unnormalized type into the format expected
|
|
84
|
-
* by our EmberData Cache. Currently this is singular-dasherized.
|
|
85
|
-
*
|
|
86
|
-
* you should not rely on this function to give you an exact format
|
|
87
|
-
* for display purposes. Formatting for display should be handled
|
|
88
|
-
* differently if the exact format matters.
|
|
89
|
-
*
|
|
90
|
-
* Asserts invalid types (undefined, null, '') in dev.
|
|
91
|
-
*
|
|
92
|
-
* **Usage**
|
|
93
|
-
*
|
|
94
|
-
* ```js
|
|
95
|
-
* import formattedType from 'soxhub-client/helpers/formatted-type';
|
|
96
|
-
*
|
|
97
|
-
* formattedType('post'); // => 'post'
|
|
98
|
-
* formattedType('posts'); // => 'post'
|
|
99
|
-
* formattedType('Posts'); // => 'post'
|
|
100
|
-
* formattedType('post-comment'); // => 'post-comment'
|
|
101
|
-
* formattedType('post-comments'); // => 'post-comment'
|
|
102
|
-
* formattedType('post_comment'); // => 'post-comment'
|
|
103
|
-
* formattedType('postComment'); // => 'post-comment'
|
|
104
|
-
* formattedType('PostComment'); // => 'post-comment'
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* @method formattedType
|
|
108
|
-
* @for @ember-data/legacy-compat/utils
|
|
109
|
-
* @param {String} type the potentially un-normalized type
|
|
110
|
-
* @return {String} the normalized type
|
|
111
|
-
* @public
|
|
112
|
-
* @static
|
|
113
|
-
*/
|
|
114
|
-
function formattedType(type) {
|
|
115
|
-
AssertFn('formattedType: type must not be null', type !== null);
|
|
116
|
-
AssertFn('formattedType: type must not be undefined', type !== undefined);
|
|
117
|
-
AssertFn('formattedType: type must be a string', typeof type === 'string');
|
|
118
|
-
AssertFn('formattedType: type must not be empty', type.length > 0);
|
|
119
|
-
let normalized = NORMALIZED_TYPES.get(type);
|
|
120
|
-
if (normalized === undefined) {
|
|
121
|
-
normalized = NormalizedType(type);
|
|
122
|
-
NORMALIZED_TYPES.set(type, normalized);
|
|
123
|
-
}
|
|
124
|
-
if (normalized !== type) {
|
|
125
|
-
MismatchReporter('formatted-type', type, normalized);
|
|
126
|
-
}
|
|
127
|
-
return normalized;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Format an id to the format expected by the EmberData Cache.
|
|
132
|
-
* Currently this means that id should be `string | null`.
|
|
133
|
-
*
|
|
134
|
-
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
135
|
-
*
|
|
136
|
-
* **Usage**
|
|
137
|
-
*
|
|
138
|
-
* ```js
|
|
139
|
-
* import formattedId from 'client/utils/formatted-id';
|
|
140
|
-
*
|
|
141
|
-
* formattedId('1'); // => '1'
|
|
142
|
-
* formattedId(1); // => '1'
|
|
143
|
-
* formattedId(null); // => null
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* @method formattedId
|
|
147
|
-
* @for @ember-data/legacy-compat/utils
|
|
148
|
-
* @param {String | Number | null} id the potentially un-normalized id
|
|
149
|
-
* @return {String | null} the normalized id
|
|
150
|
-
* @public
|
|
151
|
-
* @static
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
function formattedId(id) {
|
|
155
|
-
AssertFn('formattedId: id must not be undefined', id !== undefined);
|
|
156
|
-
AssertFn('formattedId: id must be a number, string or null', typeof id === 'number' || typeof id === 'string' || id === null);
|
|
157
|
-
AssertFn('formattedId: id must not be empty', typeof id === 'number' || id === null || typeof id === 'string' && id.length > 0);
|
|
158
|
-
AssertFn('formattedId: id must not be 0', id !== '0' && id !== 0);
|
|
159
|
-
const formatted = id === null ? null : String(id);
|
|
160
|
-
if (formatted !== id) {
|
|
161
|
-
MismatchReporter('formatted-id', id, formatted);
|
|
162
|
-
}
|
|
163
|
-
return id === null ? null : String(id);
|
|
164
|
-
}
|
|
165
|
-
function expectId(id) {
|
|
166
|
-
AssertFn('expectId: id must not be null', id !== null);
|
|
167
|
-
return formattedId(id);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Compares two types for strict equality, converting them to
|
|
172
|
-
* the format expected by the EmberData Cache to ensure
|
|
173
|
-
* differences in format are accounted for in the comparison.
|
|
174
|
-
*
|
|
175
|
-
* Asserts when expected or actual are invalid types in dev.
|
|
176
|
-
* Expected may never be null.
|
|
177
|
-
*
|
|
178
|
-
* ```js
|
|
179
|
-
* isEquivType('posts', 'post'); // true
|
|
180
|
-
* isEquivType('post', 'post'); // true
|
|
181
|
-
* isEquivType('posts', 'posts'); // true
|
|
182
|
-
* isEquivType('post-comment', 'postComment'); // true
|
|
183
|
-
* isEquivType('post-comment', 'PostComment'); // true
|
|
184
|
-
* isEquivType('post-comment', 'post_comment'); // true
|
|
185
|
-
* isEquivType('post-comment', 'post-comment'); // true
|
|
186
|
-
* isEquivType('post-comment', 'post'); // false
|
|
187
|
-
* isEquivType('posts', null); // false
|
|
188
|
-
* ```
|
|
189
|
-
*
|
|
190
|
-
* @method isEquivType
|
|
191
|
-
* @for @ember-data/legacy-compat/utils
|
|
192
|
-
* @param {String} expected a potentially unnormalized type to match against
|
|
193
|
-
* @param {String} actual a potentially unnormalized type to match against
|
|
194
|
-
* @return {Boolean} true if the types are equivalent
|
|
195
|
-
* @public
|
|
196
|
-
* @static
|
|
197
|
-
*/
|
|
198
|
-
function isEquivType(expected, actual) {
|
|
199
|
-
AssertFn('isEquivType: Expected type must not be null', expected !== null);
|
|
200
|
-
AssertFn('isEquivType: Expected type must not be undefined', expected !== undefined);
|
|
201
|
-
AssertFn('isEquivType: Expected type must be a string', typeof expected === 'string');
|
|
202
|
-
AssertFn('isEquivType: Expected type must not be empty', expected.length > 0);
|
|
203
|
-
AssertFn('isEquivType: Actual type must not be null', actual !== null);
|
|
204
|
-
AssertFn('isEquivType: Actual type must not be undefined', actual !== undefined);
|
|
205
|
-
AssertFn('isEquivType: Actual type must be a string', typeof actual === 'string');
|
|
206
|
-
AssertFn('isEquivType: Actual type must not be empty', actual.length > 0);
|
|
207
|
-
return expected === actual || formattedType(expected) === formattedType(actual);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Compares two IDs for strict equality, converting them to
|
|
212
|
-
* the format expected by the EmberData Cache to ensure
|
|
213
|
-
* differences in format are accounted for in the comparison.
|
|
214
|
-
*
|
|
215
|
-
* Asserts when expected or actual are invalid IDs in dev.
|
|
216
|
-
* Expected may never be null.
|
|
217
|
-
*
|
|
218
|
-
* ```js
|
|
219
|
-
* isEquivId('1', 1); // true
|
|
220
|
-
* isEquivId('2', '2'); // true
|
|
221
|
-
* isEquivId(3, '3'); // true
|
|
222
|
-
* isEquivId(4, '3'); // false
|
|
223
|
-
* isEquivId(1, null); // false
|
|
224
|
-
* ```
|
|
225
|
-
*
|
|
226
|
-
* @method isEquivId
|
|
227
|
-
* @for @ember-data/legacy-compat/utils
|
|
228
|
-
* @param {string | number} expected a potentially un-normalized id to match against
|
|
229
|
-
* @param {string | number} actual a potentially un-normalized id to match against
|
|
230
|
-
* @return {Boolean} true if the ids are equivalent
|
|
231
|
-
* @public
|
|
232
|
-
* @static
|
|
233
|
-
*/
|
|
234
|
-
function isEquivId(expected, actual) {
|
|
235
|
-
AssertFn('isEquivId: Expected id must not be null', expected !== null);
|
|
236
|
-
AssertFn('isEquivId: Expected id must not be undefined', expected !== undefined);
|
|
237
|
-
AssertFn('isEquivId: Expected id must be a number or string', typeof expected === 'number' || typeof expected === 'string');
|
|
238
|
-
AssertFn('isEquivId: Expected id must not be empty', typeof expected === 'number' || typeof expected === 'string' && expected.length > 0);
|
|
239
|
-
AssertFn('isEquivId: Expected id must not be 0', expected !== '0' && expected !== 0);
|
|
240
|
-
AssertFn('isEquivId: Actual id must not be undefined', actual !== undefined);
|
|
241
|
-
AssertFn('isEquivId: Actual id must be a number, string or null', typeof actual === 'number' || typeof actual === 'string' || actual === null);
|
|
242
|
-
AssertFn('isEquivId: Actual id must not be empty', actual === null || typeof actual === 'number' || typeof actual === 'string' && actual.length > 0);
|
|
243
|
-
AssertFn('isEquivId: Actual id must not be 0', actual !== '0' && actual !== 0);
|
|
244
|
-
return expected === actual || formattedId(expected) === formattedId(actual);
|
|
245
|
-
}
|
|
246
|
-
export { configureAssertFn, configureMismatchReporter, configureTypeNormalization, expectId, formattedId, formattedType, isEquivId, isEquivType };
|
|
1
|
+
export * from '@warp-drive/legacy/compat/utils';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/legacy-compat",
|
|
3
3
|
"description": "Compatibility Shims for Older EmberData",
|
|
4
|
-
"version": "5.6.0-beta.
|
|
4
|
+
"version": "5.6.0-beta.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
7
7
|
"repository": {
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://github.com/emberjs/data",
|
|
13
13
|
"bugs": "https://github.com/emberjs/data/issues",
|
|
14
|
-
"engines": {
|
|
15
|
-
"node": ">= 18.20.8"
|
|
16
|
-
},
|
|
17
14
|
"keywords": [
|
|
18
15
|
"ember-addon"
|
|
19
16
|
],
|
|
@@ -44,45 +41,21 @@
|
|
|
44
41
|
"type": "addon",
|
|
45
42
|
"version": 2
|
|
46
43
|
},
|
|
47
|
-
"peerDependenciesMeta": {
|
|
48
|
-
"@ember-data/graph": {
|
|
49
|
-
"optional": true
|
|
50
|
-
},
|
|
51
|
-
"@ember-data/json-api": {
|
|
52
|
-
"optional": true
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
44
|
"dependencies": {
|
|
56
45
|
"@embroider/macros": "^1.16.12",
|
|
57
|
-
"@warp-drive/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"ember-source": "3.28.12 || ^4.0.4 || ^5.0.0 || ^6.0.0",
|
|
61
|
-
"@ember-data/graph": "5.6.0-beta.0",
|
|
62
|
-
"@ember-data/json-api": "5.6.0-beta.0",
|
|
63
|
-
"@ember-data/request": "5.6.0-beta.0",
|
|
64
|
-
"@ember-data/request-utils": "5.6.0-beta.0",
|
|
65
|
-
"@ember-data/store": "5.6.0-beta.0",
|
|
66
|
-
"@ember/test-waiters": "^3.1.0 || >= 4.0.0",
|
|
67
|
-
"@warp-drive/core-types": "5.6.0-beta.0"
|
|
46
|
+
"@warp-drive/core": "5.6.0-beta.0",
|
|
47
|
+
"@warp-drive/legacy": "5.6.0-beta.0",
|
|
48
|
+
"@warp-drive/utilities": "5.6.0-beta.0"
|
|
68
49
|
},
|
|
50
|
+
"peerDependencies": {},
|
|
69
51
|
"devDependencies": {
|
|
70
52
|
"@babel/core": "^7.26.10",
|
|
71
53
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
72
54
|
"@babel/preset-env": "^7.26.9",
|
|
73
55
|
"@babel/preset-typescript": "^7.27.0",
|
|
74
|
-
"@
|
|
75
|
-
"@ember-data/json-api": "5.6.0-beta.0",
|
|
76
|
-
"@ember-data/request": "5.6.0-beta.0",
|
|
77
|
-
"@ember-data/request-utils": "5.6.0-beta.0",
|
|
78
|
-
"@ember-data/store": "5.6.0-beta.0",
|
|
79
|
-
"@ember/test-waiters": "^4.1.0",
|
|
80
|
-
"@glimmer/component": "^2.0.0",
|
|
81
|
-
"@warp-drive/core-types": "5.6.0-beta.0",
|
|
82
|
-
"@warp-drive/internal-config": "5.6.0-beta.0",
|
|
83
|
-
"ember-source": "~6.3.0",
|
|
56
|
+
"@warp-drive/internal-config": "5.6.0-beta.1",
|
|
84
57
|
"typescript": "^5.8.3",
|
|
85
|
-
"vite": "^
|
|
58
|
+
"vite": "^7.0.0"
|
|
86
59
|
},
|
|
87
60
|
"ember": {
|
|
88
61
|
"edition": "octane"
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
declare module '@ember-data/legacy-compat/-private' {
|
|
2
|
-
import type Store from '@ember-data/store';
|
|
3
|
-
import type { CompatStore } from '@ember-data/legacy-compat';
|
|
4
2
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@main @ember-data/legacy-compat
|
|
3
|
+
* Utilities - often temporary - for maintaining backwards compatibility with
|
|
4
|
+
* older parts of EmberData.
|
|
5
|
+
*
|
|
6
|
+
@module
|
|
10
7
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export { Snapshot } from '@ember-data/legacy-compat/legacy-network-handler/snapshot';
|
|
15
|
-
export function upgradeStore(store: Store): asserts store is CompatStore;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=-private.d.ts.map
|
|
8
|
+
export * from "@warp-drive/legacy/compat/-private";
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
declare module '@ember-data/legacy-compat/builders' {
|
|
2
2
|
/**
|
|
3
|
-
|
|
3
|
+
Builders for migrating from `store` methods to `store.request`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
These builders enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
|
|
6
|
+
This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
|
|
7
|
+
To that end, these builders are deprecated and will be removed in a future version of Ember Data.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@deprecated
|
|
9
|
+
@module
|
|
10
|
+
@deprecated
|
|
12
11
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export { saveRecordBuilder as saveRecord } from '@ember-data/legacy-compat/builders/save-record';
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=builders.d.ts.map
|
|
12
|
+
export * from "@warp-drive/legacy/compat/builders";
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -1,162 +1,7 @@
|
|
|
1
|
-
/// <reference path="./utils.d.ts" />
|
|
2
|
-
/// <reference path="./-private.d.ts" />
|
|
3
1
|
/// <reference path="./builders.d.ts" />
|
|
4
|
-
/// <reference path="
|
|
5
|
-
/// <reference path="./
|
|
6
|
-
/// <reference path="./builders/save-record.d.ts" />
|
|
7
|
-
/// <reference path="./builders/find-all.d.ts" />
|
|
8
|
-
/// <reference path="./builders/find-record.d.ts" />
|
|
9
|
-
/// <reference path="./legacy-network-handler/snapshot.d.ts" />
|
|
10
|
-
/// <reference path="./legacy-network-handler/identifier-has-id.d.ts" />
|
|
11
|
-
/// <reference path="./legacy-network-handler/serializer-response.d.ts" />
|
|
12
|
-
/// <reference path="./legacy-network-handler/minimum-serializer-interface.d.ts" />
|
|
13
|
-
/// <reference path="./legacy-network-handler/legacy-network-handler.d.ts" />
|
|
14
|
-
/// <reference path="./legacy-network-handler/minimum-adapter-interface.d.ts" />
|
|
15
|
-
/// <reference path="./legacy-network-handler/fetch-manager.d.ts" />
|
|
16
|
-
/// <reference path="./legacy-network-handler/legacy-data-fetch.d.ts" />
|
|
17
|
-
/// <reference path="./legacy-network-handler/legacy-data-utils.d.ts" />
|
|
18
|
-
/// <reference path="./legacy-network-handler/snapshot-record-array.d.ts" />
|
|
2
|
+
/// <reference path="./-private.d.ts" />
|
|
3
|
+
/// <reference path="./utils.d.ts" />
|
|
19
4
|
declare module '@ember-data/legacy-compat' {
|
|
20
|
-
|
|
21
|
-
import type { ObjectValue } from '@warp-drive/core-types/json/raw';
|
|
22
|
-
import { FetchManager } from '@ember-data/legacy-compat/-private';
|
|
23
|
-
import type { AdapterPayload, MinimumAdapterInterface } from '@ember-data/legacy-compat/legacy-network-handler/minimum-adapter-interface';
|
|
24
|
-
import type { MinimumSerializerInterface, SerializerOptions } from '@ember-data/legacy-compat/legacy-network-handler/minimum-serializer-interface';
|
|
25
|
-
export { LegacyNetworkHandler } from '@ember-data/legacy-compat/legacy-network-handler/legacy-network-handler';
|
|
26
|
-
export type { MinimumAdapterInterface, MinimumSerializerInterface, SerializerOptions, AdapterPayload };
|
|
27
|
-
/**
|
|
28
|
-
* @module @ember-data/store
|
|
29
|
-
* @class Store
|
|
30
|
-
*/
|
|
31
|
-
export type LegacyStoreCompat = {
|
|
32
|
-
_fetchManager: FetchManager;
|
|
33
|
-
adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
34
|
-
adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
35
|
-
serializerFor<K extends string>(modelName: K, _allowMissing?: boolean): MinimumSerializerInterface | null;
|
|
36
|
-
normalize(modelName: string, payload: ObjectValue): ObjectValue;
|
|
37
|
-
pushPayload(modelName: string, payload: ObjectValue): void;
|
|
38
|
-
serializeRecord(record: unknown, options?: SerializerOptions): unknown;
|
|
39
|
-
_adapterCache: Record<string, MinimumAdapterInterface & {
|
|
40
|
-
store: Store;
|
|
41
|
-
}>;
|
|
42
|
-
_serializerCache: Record<string, MinimumSerializerInterface & {
|
|
43
|
-
store: Store;
|
|
44
|
-
}>;
|
|
45
|
-
};
|
|
46
|
-
export type CompatStore = Store & LegacyStoreCompat;
|
|
47
|
-
/**
|
|
48
|
-
Returns an instance of the adapter for a given type. For
|
|
49
|
-
example, `adapterFor('person')` will return an instance of
|
|
50
|
-
the adapter located at `app/adapters/person.js`
|
|
51
|
-
|
|
52
|
-
If no `person` adapter is found, this method will look
|
|
53
|
-
for an `application` adapter (the default adapter for
|
|
54
|
-
your entire application).
|
|
55
|
-
|
|
56
|
-
@method adapterFor
|
|
57
|
-
@public
|
|
58
|
-
@param {String} modelName
|
|
59
|
-
@return Adapter
|
|
60
|
-
*/
|
|
61
|
-
export function adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
62
|
-
export function adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
63
|
-
/**
|
|
64
|
-
Returns an instance of the serializer for a given type. For
|
|
65
|
-
example, `serializerFor('person')` will return an instance of
|
|
66
|
-
`App.PersonSerializer`.
|
|
67
|
-
|
|
68
|
-
If no `App.PersonSerializer` is found, this method will look
|
|
69
|
-
for an `App.ApplicationSerializer` (the default serializer for
|
|
70
|
-
your entire application).
|
|
71
|
-
|
|
72
|
-
If a serializer cannot be found on the adapter, it will fall back
|
|
73
|
-
to an instance of `JSONSerializer`.
|
|
74
|
-
|
|
75
|
-
@method serializerFor
|
|
76
|
-
@public
|
|
77
|
-
@param {String} modelName the record to serialize
|
|
78
|
-
@return {Serializer}
|
|
79
|
-
*/
|
|
80
|
-
export function serializerFor(this: Store, modelName: string): MinimumSerializerInterface | null;
|
|
81
|
-
/**
|
|
82
|
-
`normalize` converts a json payload into the normalized form that
|
|
83
|
-
[push](../methods/push?anchor=push) expects.
|
|
84
|
-
|
|
85
|
-
Example
|
|
86
|
-
|
|
87
|
-
```js
|
|
88
|
-
socket.on('message', function(message) {
|
|
89
|
-
let modelName = message.model;
|
|
90
|
-
let data = message.data;
|
|
91
|
-
store.push(store.normalize(modelName, data));
|
|
92
|
-
});
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
@method normalize
|
|
96
|
-
@public
|
|
97
|
-
@param {String} modelName The name of the model type for this payload
|
|
98
|
-
@param {Object} payload
|
|
99
|
-
@return {Object} The normalized payload
|
|
100
|
-
*/
|
|
101
|
-
export function normalize(this: Store, modelName: string, payload: ObjectValue): import("@warp-drive/core-types/spec/json-api-raw").SingleResourceDocument;
|
|
102
|
-
/**
|
|
103
|
-
Push some raw data into the store.
|
|
104
|
-
|
|
105
|
-
This method can be used both to push in brand new
|
|
106
|
-
records, as well as to update existing records. You
|
|
107
|
-
can push in more than one type of object at once.
|
|
108
|
-
All objects should be in the format expected by the
|
|
109
|
-
serializer.
|
|
110
|
-
|
|
111
|
-
```app/serializers/application.js
|
|
112
|
-
import RESTSerializer from '@ember-data/serializer/rest';
|
|
113
|
-
|
|
114
|
-
export default class ApplicationSerializer extends RESTSerializer;
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
let pushData = {
|
|
119
|
-
posts: [
|
|
120
|
-
{ id: 1, postTitle: "Great post", commentIds: [2] }
|
|
121
|
-
],
|
|
122
|
-
comments: [
|
|
123
|
-
{ id: 2, commentBody: "Insightful comment" }
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
store.pushPayload(pushData);
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
By default, the data will be deserialized using a default
|
|
131
|
-
serializer (the application serializer if it exists).
|
|
132
|
-
|
|
133
|
-
Alternatively, `pushPayload` will accept a model type which
|
|
134
|
-
will determine which serializer will process the payload.
|
|
135
|
-
|
|
136
|
-
```app/serializers/application.js
|
|
137
|
-
import RESTSerializer from '@ember-data/serializer/rest';
|
|
138
|
-
|
|
139
|
-
export default class ApplicationSerializer extends RESTSerializer;
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
```app/serializers/post.js
|
|
143
|
-
import JSONSerializer from '@ember-data/serializer/json';
|
|
144
|
-
|
|
145
|
-
export default JSONSerializer;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
```js
|
|
149
|
-
store.pushPayload(pushData); // Will use the application serializer
|
|
150
|
-
store.pushPayload('post', pushData); // Will use the post serializer
|
|
151
|
-
```
|
|
5
|
+
export * from "@warp-drive/legacy/compat";
|
|
152
6
|
|
|
153
|
-
|
|
154
|
-
@public
|
|
155
|
-
@param {String} modelName Optionally, a model type used to determine which serializer will be used
|
|
156
|
-
@param {Object} inputPayload
|
|
157
|
-
*/
|
|
158
|
-
export function pushPayload(this: Store, modelName: string, inputPayload: ObjectValue): void;
|
|
159
|
-
export function serializeRecord(this: Store, record: unknown, options?: SerializerOptions): unknown;
|
|
160
|
-
export function cleanup(this: Store): void;
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=index.d.ts.map
|
|
7
|
+
}
|