@ember-data/legacy-compat 5.6.0-alpha.1 → 5.6.0-alpha.12
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 +2 -1
- package/dist/builders.js +2 -323
- package/dist/builders.js.map +1 -1
- package/dist/index.js +2 -1011
- package/dist/index.js.map +1 -1
- package/dist/utils.js +2 -246
- package/dist/utils.js.map +1 -1
- package/package.json +6 -33
- package/unstable-preview-types/-private.d.ts +2 -9
- package/unstable-preview-types/-private.d.ts.map +1 -1
- package/unstable-preview-types/builders.d.ts +2 -6
- package/unstable-preview-types/builders.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +3 -158
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/unstable-preview-types/utils.d.ts +7 -157
- package/unstable-preview-types/utils.d.ts.map +1 -1
- package/dist/-private-Bnt-3W7M.js +0 -1207
- package/dist/-private-Bnt-3W7M.js.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/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
|
@@ -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
|
-
```
|
|
152
|
-
|
|
153
|
-
@method pushPayload
|
|
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;
|
|
5
|
+
export * from '@warp-drive/legacy/compat';
|
|
161
6
|
}
|
|
162
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
@@ -1,161 +1,11 @@
|
|
|
1
1
|
declare module '@ember-data/legacy-compat/utils' {
|
|
2
|
-
type Reporter = (type: 'formatted-id' | 'formatted-type', actual: unknown, expected: unknown) => void;
|
|
3
2
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @public
|
|
12
|
-
* @static
|
|
13
|
-
*/
|
|
14
|
-
export function configureMismatchReporter(fn: Reporter): void;
|
|
15
|
-
/**
|
|
16
|
-
* Configure a function to be called when an id or type
|
|
17
|
-
* fails validation. This is useful for instrumenting
|
|
18
|
-
* to discover places where usage in the app is not consistent.
|
|
19
|
-
*
|
|
20
|
-
* @method configureAssertFn
|
|
21
|
-
* @for @ember-data/legacy-compat/utils
|
|
22
|
-
* @param method a function which takes a message and a condition
|
|
23
|
-
* @public
|
|
24
|
-
* @static
|
|
25
|
-
*/
|
|
26
|
-
export function configureAssertFn(fn: (message: string, condition: unknown) => void): void;
|
|
27
|
-
/**
|
|
28
|
-
* Configure a function to be called to normalize
|
|
29
|
-
* a resource type string. Used by both formattedType
|
|
30
|
-
* and isEquivType to ensure consistent normalization
|
|
31
|
-
* during comparison.
|
|
32
|
-
*
|
|
33
|
-
* If validation fails or the type turns out be unnormalized
|
|
34
|
-
* the configured mismatch reporter and assert functions will
|
|
35
|
-
* be called.
|
|
36
|
-
*
|
|
37
|
-
* @method configureTypeNormalization
|
|
38
|
-
* @for @ember-data/legacy-compat/utils
|
|
39
|
-
* @param method a function which takes a string and returns a string
|
|
40
|
-
* @public
|
|
41
|
-
* @static
|
|
42
|
-
*/
|
|
43
|
-
export function configureTypeNormalization(fn: (type: string) => string): void;
|
|
44
|
-
/**
|
|
45
|
-
* Converts a potentially unnormalized type into the format expected
|
|
46
|
-
* by our EmberData Cache. Currently this is singular-dasherized.
|
|
47
|
-
*
|
|
48
|
-
* you should not rely on this function to give you an exact format
|
|
49
|
-
* for display purposes. Formatting for display should be handled
|
|
50
|
-
* differently if the exact format matters.
|
|
51
|
-
*
|
|
52
|
-
* Asserts invalid types (undefined, null, '') in dev.
|
|
53
|
-
*
|
|
54
|
-
* **Usage**
|
|
55
|
-
*
|
|
56
|
-
* ```js
|
|
57
|
-
* import formattedType from 'soxhub-client/helpers/formatted-type';
|
|
58
|
-
*
|
|
59
|
-
* formattedType('post'); // => 'post'
|
|
60
|
-
* formattedType('posts'); // => 'post'
|
|
61
|
-
* formattedType('Posts'); // => 'post'
|
|
62
|
-
* formattedType('post-comment'); // => 'post-comment'
|
|
63
|
-
* formattedType('post-comments'); // => 'post-comment'
|
|
64
|
-
* formattedType('post_comment'); // => 'post-comment'
|
|
65
|
-
* formattedType('postComment'); // => 'post-comment'
|
|
66
|
-
* formattedType('PostComment'); // => 'post-comment'
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* @method formattedType
|
|
70
|
-
* @for @ember-data/legacy-compat/utils
|
|
71
|
-
* @param {String} type the potentially un-normalized type
|
|
72
|
-
* @return {String} the normalized type
|
|
73
|
-
* @public
|
|
74
|
-
* @static
|
|
75
|
-
*/
|
|
76
|
-
export function formattedType<T extends string>(type: T | string): T;
|
|
77
|
-
/**
|
|
78
|
-
* Format an id to the format expected by the EmberData Cache.
|
|
79
|
-
* Currently this means that id should be `string | null`.
|
|
80
|
-
*
|
|
81
|
-
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
82
|
-
*
|
|
83
|
-
* **Usage**
|
|
84
|
-
*
|
|
85
|
-
* ```js
|
|
86
|
-
* import formattedId from 'client/utils/formatted-id';
|
|
87
|
-
*
|
|
88
|
-
* formattedId('1'); // => '1'
|
|
89
|
-
* formattedId(1); // => '1'
|
|
90
|
-
* formattedId(null); // => null
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @method formattedId
|
|
94
|
-
* @for @ember-data/legacy-compat/utils
|
|
95
|
-
* @param {String | Number | null} id the potentially un-normalized id
|
|
96
|
-
* @return {String | null} the normalized id
|
|
97
|
-
* @public
|
|
98
|
-
* @static
|
|
99
|
-
*/
|
|
100
|
-
export function formattedId(id: string | number): string;
|
|
101
|
-
export function formattedId(id: null): null;
|
|
102
|
-
export function formattedId(id: string | number | null): string | null;
|
|
103
|
-
export function expectId(id: string | number): string;
|
|
104
|
-
export function expectId(id: null): never;
|
|
105
|
-
/**
|
|
106
|
-
* Compares two types for strict equality, converting them to
|
|
107
|
-
* the format expected by the EmberData Cache to ensure
|
|
108
|
-
* differences in format are accounted for in the comparison.
|
|
109
|
-
*
|
|
110
|
-
* Asserts when expected or actual are invalid types in dev.
|
|
111
|
-
* Expected may never be null.
|
|
112
|
-
*
|
|
113
|
-
* ```js
|
|
114
|
-
* isEquivType('posts', 'post'); // true
|
|
115
|
-
* isEquivType('post', 'post'); // true
|
|
116
|
-
* isEquivType('posts', 'posts'); // true
|
|
117
|
-
* isEquivType('post-comment', 'postComment'); // true
|
|
118
|
-
* isEquivType('post-comment', 'PostComment'); // true
|
|
119
|
-
* isEquivType('post-comment', 'post_comment'); // true
|
|
120
|
-
* isEquivType('post-comment', 'post-comment'); // true
|
|
121
|
-
* isEquivType('post-comment', 'post'); // false
|
|
122
|
-
* isEquivType('posts', null); // false
|
|
123
|
-
* ```
|
|
124
|
-
*
|
|
125
|
-
* @method isEquivType
|
|
126
|
-
* @for @ember-data/legacy-compat/utils
|
|
127
|
-
* @param {String} expected a potentially unnormalized type to match against
|
|
128
|
-
* @param {String} actual a potentially unnormalized type to match against
|
|
129
|
-
* @return {Boolean} true if the types are equivalent
|
|
130
|
-
* @public
|
|
131
|
-
* @static
|
|
132
|
-
*/
|
|
133
|
-
export function isEquivType(expected: string, actual: string): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Compares two IDs for strict equality, converting them to
|
|
136
|
-
* the format expected by the EmberData Cache to ensure
|
|
137
|
-
* differences in format are accounted for in the comparison.
|
|
138
|
-
*
|
|
139
|
-
* Asserts when expected or actual are invalid IDs in dev.
|
|
140
|
-
* Expected may never be null.
|
|
141
|
-
*
|
|
142
|
-
* ```js
|
|
143
|
-
* isEquivId('1', 1); // true
|
|
144
|
-
* isEquivId('2', '2'); // true
|
|
145
|
-
* isEquivId(3, '3'); // true
|
|
146
|
-
* isEquivId(4, '3'); // false
|
|
147
|
-
* isEquivId(1, null); // false
|
|
148
|
-
* ```
|
|
149
|
-
*
|
|
150
|
-
* @method isEquivId
|
|
151
|
-
* @for @ember-data/legacy-compat/utils
|
|
152
|
-
* @param {string | number} expected a potentially un-normalized id to match against
|
|
153
|
-
* @param {string | number} actual a potentially un-normalized id to match against
|
|
154
|
-
* @return {Boolean} true if the ids are equivalent
|
|
155
|
-
* @public
|
|
156
|
-
* @static
|
|
157
|
-
*/
|
|
158
|
-
export function isEquivId(expected: string | number, actual: string | number | null): boolean;
|
|
159
|
-
export {};
|
|
3
|
+
Utilities for helping to migrate to stricter
|
|
4
|
+
and more consistent use of IDs and types.
|
|
5
|
+
|
|
6
|
+
@module
|
|
7
|
+
@deprecated
|
|
8
|
+
*/
|
|
9
|
+
export * from '@warp-drive/legacy/compat/utils';
|
|
160
10
|
}
|
|
161
11
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,cAAc,iCAAiC,CAAC"}
|