@warp-drive/legacy 5.7.0 → 5.8.0-alpha.10
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 +6 -3
- package/declarations/adapter/json-api.d.ts +4 -6
- 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/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 +32 -8
- package/declarations/index.d.ts +53 -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/model.d.ts +8 -8
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +1 -1
- package/declarations/model/-private/references/has-many.d.ts +1 -1
- package/declarations/model/migration-support.d.ts +4 -2
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -5
- 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 +4 -6
- package/declarations/serializer/json.d.ts +6 -8
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +8 -11
- package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +5 -6
- 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/utils.js +17 -17
- package/dist/compat.js +55 -38
- package/dist/{errors-8kD2mSe_.js → errors-COviC59J.js} +3 -3
- package/dist/hooks-Bp8SIQBU.js +74 -0
- package/dist/index.js +178 -0
- package/dist/{json-Et4mt_LM.js → json-BHxlccxF.js} +8 -12
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +6 -4
- package/dist/model.js +18 -90
- package/dist/{schema-provider-DQu4Rjco.js → schema-provider-JlCneqZH.js} +8 -10
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
- package/dist/serializer/json-api.js +11 -38
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +5 -12
- package/dist/serializer/transform.js +15 -6
- package/dist/serializer.js +8 -12
- package/dist/store.js +3 -0
- package/package.json +7 -7
|
@@ -28,9 +28,6 @@ export type FactoryCache = Record<string, ModelFactory>;
|
|
|
28
28
|
export type ModelStore = Store & {
|
|
29
29
|
_modelFactoryCache: FactoryCache;
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* @noInheritDoc
|
|
33
|
-
*/
|
|
34
31
|
interface Model {
|
|
35
32
|
/**
|
|
36
33
|
* The store service instance which created this record instance
|
|
@@ -89,8 +86,8 @@ interface Model {
|
|
|
89
86
|
```
|
|
90
87
|
|
|
91
88
|
@public
|
|
92
|
-
@param
|
|
93
|
-
@return
|
|
89
|
+
@param options
|
|
90
|
+
@return a promise that will be resolved when the adapter returns
|
|
94
91
|
successfully or rejected if the adapter returns with an error.
|
|
95
92
|
*/
|
|
96
93
|
destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
|
|
@@ -204,9 +201,9 @@ interface Model {
|
|
|
204
201
|
}
|
|
205
202
|
```
|
|
206
203
|
|
|
204
|
+
@deprecated use {@link Store.request} instead
|
|
207
205
|
@public
|
|
208
|
-
@
|
|
209
|
-
@return {Promise} a promise that will be resolved when the adapter returns
|
|
206
|
+
@return a promise that will be resolved when the adapter returns
|
|
210
207
|
successfully or rejected if the adapter returns with an error.
|
|
211
208
|
*/
|
|
212
209
|
save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
|
|
@@ -414,7 +411,10 @@ interface Model {
|
|
|
414
411
|
* the class to use as the reactive object for data of resource
|
|
415
412
|
* of that type.
|
|
416
413
|
*
|
|
414
|
+
* @public
|
|
417
415
|
* @noInheritDoc
|
|
416
|
+
* @hideconstructor
|
|
417
|
+
* @legacy
|
|
418
418
|
*/
|
|
419
419
|
declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
420
420
|
/** @private */
|
|
@@ -797,7 +797,7 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
797
797
|
Represents the model's class name as a string. This can be used to look up the model's class name through
|
|
798
798
|
`Store`'s modelFor method.
|
|
799
799
|
|
|
800
|
-
`modelName` is generated for you by
|
|
800
|
+
`modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.
|
|
801
801
|
For example:
|
|
802
802
|
|
|
803
803
|
```javascript
|
|
@@ -241,7 +241,7 @@ export default class BelongsToReference<
|
|
|
241
241
|
*/
|
|
242
242
|
remoteType(): "link" | "id";
|
|
243
243
|
/**
|
|
244
|
-
`push` can be used to update the data in the relationship and
|
|
244
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
245
245
|
will treat the new data as the canonical value of this relationship on
|
|
246
246
|
the backend. A value of `null` (e.g. `{ data: null }`) can be passed to
|
|
247
247
|
clear the relationship.
|
|
@@ -243,7 +243,7 @@ export default class HasManyReference<
|
|
|
243
243
|
*/
|
|
244
244
|
meta(): Meta | null;
|
|
245
245
|
/**
|
|
246
|
-
`push` can be used to update the data in the relationship and
|
|
246
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
247
247
|
will treat the new data as the canonical value of this relationship on
|
|
248
248
|
the backend. An empty array will signify the canonical value should be
|
|
249
249
|
empty.
|
|
@@ -207,8 +207,6 @@ export interface DelegatingSchemaService {
|
|
|
207
207
|
doesTypeExist?(type: string): boolean;
|
|
208
208
|
}
|
|
209
209
|
export declare class DelegatingSchemaService implements SchemaService {
|
|
210
|
-
_preferred: SchemaService;
|
|
211
|
-
_secondary: SchemaService;
|
|
212
210
|
constructor(store: Store, schema: SchemaService);
|
|
213
211
|
isDelegated(resource: ResourceKey | {
|
|
214
212
|
type: string;
|
|
@@ -252,4 +250,8 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
252
250
|
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
253
251
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
254
252
|
}
|
|
253
|
+
export interface PrivateDelegatingSchemaService extends DelegatingSchemaService {
|
|
254
|
+
_preferred: SchemaService;
|
|
255
|
+
_secondary: SchemaService;
|
|
256
|
+
}
|
|
255
257
|
export {};
|
|
@@ -85,11 +85,6 @@ instances must have an `id` property to be used with Ember Data.
|
|
|
85
85
|
are. Please read the docs for the methods this mixin provides, in case you need
|
|
86
86
|
to modify it to fit your specific needs.**
|
|
87
87
|
|
|
88
|
-
For example, review the docs for each method of this mixin:
|
|
89
|
-
* [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)
|
|
90
|
-
* [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)
|
|
91
|
-
* [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)
|
|
92
|
-
|
|
93
88
|
@class EmbeddedRecordsMixin
|
|
94
89
|
@public
|
|
95
90
|
*/
|
|
@@ -5,8 +5,8 @@ export interface BooleanTransform {
|
|
|
5
5
|
/**
|
|
6
6
|
The `BooleanTransform` class is used to serialize and deserialize
|
|
7
7
|
boolean attributes on Ember Data record objects. This transform is
|
|
8
|
-
used when `boolean` is passed as the type parameter to the
|
|
9
|
-
|
|
8
|
+
used when `'boolean'` is passed as the type parameter to the
|
|
9
|
+
{@link attr}function.
|
|
10
10
|
|
|
11
11
|
Usage
|
|
12
12
|
|
|
@@ -5,8 +5,8 @@ export interface DateTransform {
|
|
|
5
5
|
/**
|
|
6
6
|
The `DateTransform` class is used to serialize and deserialize
|
|
7
7
|
date attributes on Ember Data record objects. This transform is used
|
|
8
|
-
when `date` is passed as the type parameter to the
|
|
9
|
-
|
|
8
|
+
when `'date'` is passed as the type parameter to the
|
|
9
|
+
{@link attr} function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
|
|
10
10
|
standard.
|
|
11
11
|
|
|
12
12
|
```js [app/models/score.js]
|
|
@@ -6,7 +6,7 @@ export interface NumberTransform {
|
|
|
6
6
|
The `NumberTransform` class is used to serialize and deserialize
|
|
7
7
|
numeric attributes on Ember Data record objects. This transform is
|
|
8
8
|
used when `number` is passed as the type parameter to the
|
|
9
|
-
|
|
9
|
+
{@link attr} function.
|
|
10
10
|
|
|
11
11
|
Usage
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@ export interface StringTransform {
|
|
|
6
6
|
The `StringTransform` class is used to serialize and deserialize
|
|
7
7
|
string attributes on Ember Data record objects. This transform is
|
|
8
8
|
used when `string` is passed as the type parameter to the
|
|
9
|
-
|
|
9
|
+
{@link attr} function.
|
|
10
10
|
|
|
11
11
|
Usage
|
|
12
12
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
<p>
|
|
2
|
+
* :::danger
|
|
4
3
|
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
5
4
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</blockquote>
|
|
5
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
|
+
:::
|
|
9
7
|
|
|
10
|
-
In
|
|
8
|
+
In WarpDrive a Serializer is used to serialize and deserialize
|
|
11
9
|
records when they are transferred in and out of an external source.
|
|
12
10
|
This process involves normalizing property names, transforming
|
|
13
11
|
attribute values and serializing relationships.
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
2
|
+
* :::danger
|
|
3
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
5
4
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</blockquote>
|
|
5
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
|
+
:::
|
|
9
7
|
|
|
10
|
-
In
|
|
8
|
+
In WarpDrive a Serializer is used to serialize and deserialize
|
|
11
9
|
records when they are transferred in and out of an external source.
|
|
12
10
|
This process involves normalizing property names, transforming
|
|
13
11
|
attribute values and serializing relationships.
|
|
14
12
|
|
|
15
|
-
By default,
|
|
13
|
+
By default, WarpDrive uses and recommends the `JSONAPISerializer`.
|
|
16
14
|
|
|
17
15
|
`JSONSerializer` is useful for simpler or legacy backends that may
|
|
18
16
|
not support the http://jsonapi.org/ spec.
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
2
|
+
* :::danger
|
|
3
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
5
4
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</blockquote>
|
|
5
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
|
+
:::
|
|
9
7
|
|
|
10
8
|
Normally, applications will use the `RESTSerializer` by implementing
|
|
11
9
|
the `normalize` method.
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
## Overview
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
4
|
+
:::danger
|
|
5
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
7
6
|
If starting a new app or thinking of implementing a new serializer, consider writing a
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</blockquote>
|
|
7
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
8
|
+
:::
|
|
11
9
|
|
|
12
10
|
In order to properly manage and present your data, WarpDrive
|
|
13
11
|
needs to understand the structure of data it receives.
|
|
@@ -16,14 +14,14 @@ needs to understand the structure of data it receives.
|
|
|
16
14
|
the format WarpDrive understands.
|
|
17
15
|
|
|
18
16
|
Data received from an API response is **normalized** into
|
|
19
|
-
[
|
|
17
|
+
[{json:api}](https://jsonapi.org/) (the format used internally
|
|
20
18
|
by WarpDrive), while data sent to an API is **serialized**
|
|
21
19
|
into the format the API expects.
|
|
22
20
|
|
|
23
21
|
### Implementing a Serializer
|
|
24
22
|
|
|
25
23
|
There are only two required serializer methods, one for
|
|
26
|
-
normalizing data from the server API format into
|
|
24
|
+
normalizing data from the server API format into {json:api}, and
|
|
27
25
|
another for serializing records via `Snapshots` into the expected
|
|
28
26
|
server API format.
|
|
29
27
|
|
|
@@ -69,7 +67,7 @@ store.serializerFor('author');
|
|
|
69
67
|
// app/serializers/application.js
|
|
70
68
|
```
|
|
71
69
|
|
|
72
|
-
Most requests in
|
|
70
|
+
Most requests in `@warp-drive/legacy` are made with respect to a particular `type` (or `modelName`)
|
|
73
71
|
(e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
|
|
74
72
|
refer to this as the **primary** resource `type`.
|
|
75
73
|
|
|
@@ -124,8 +122,7 @@ And you can optionally override the following methods:
|
|
|
124
122
|
|
|
125
123
|
* `normalize()`
|
|
126
124
|
|
|
127
|
-
For an example implementation, see
|
|
128
|
-
[JSONSerializer](JSONSerializer), the included JSON serializer.
|
|
125
|
+
For an example implementation, see the included {@link JSONSerializer}.
|
|
129
126
|
|
|
130
127
|
@class Serializer
|
|
131
128
|
@public
|
package/dist/adapter/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-
|
|
1
|
+
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-BnYvPex3.js";
|
package/dist/adapter/error.js
CHANGED
|
@@ -3,17 +3,16 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
|
3
3
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
## Overview
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
11
|
+
:::danger
|
|
12
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
13
13
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</blockquote>
|
|
14
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
15
|
+
:::
|
|
17
16
|
|
|
18
17
|
An `AdapterError` is used by an adapter to signal that an error occurred
|
|
19
18
|
during a request to an external API. It indicates a generic error, and
|
package/dist/adapter/json-api.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { dasherize, pluralize } from '@warp-drive/utilities/string';
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
-
import { b as serializeIntoHash } from "../serialize-into-hash-
|
|
4
|
+
import { b as serializeIntoHash } from "../serialize-into-hash-BnYvPex3.js";
|
|
5
5
|
import { RESTAdapter } from './rest.js';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
|
|
6
9
|
class JSONAPIAdapter extends RESTAdapter {
|
|
7
10
|
_defaultContentType = 'application/vnd.api+json';
|
|
8
11
|
|
package/dist/adapter/rest.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import { computed } from '@ember/object';
|
|
4
4
|
import { Adapter, BuildURLMixin } from '../adapter.js';
|
|
5
|
-
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-
|
|
5
|
+
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-BnYvPex3.js";
|
|
6
6
|
import { InvalidError, ServerError, ConflictError, NotFoundError, ForbiddenError, UnauthorizedError, AdapterError, TimeoutError, AbortError } from './error.js';
|
|
7
7
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
8
8
|
import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
|
@@ -14,13 +14,11 @@ import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
|
|
14
14
|
const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
17
|
+
* :::danger
|
|
18
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
20
19
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
</blockquote>
|
|
20
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
21
|
+
:::
|
|
24
22
|
|
|
25
23
|
The REST adapter allows your store to communicate with an HTTP server by
|
|
26
24
|
transmitting JSON via XHR.
|
|
@@ -392,8 +390,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
392
390
|
Some APIs require HTTP headers, e.g. to provide an API
|
|
393
391
|
key. Arbitrary headers can be set as key/value pairs on the
|
|
394
392
|
`RESTAdapter`'s `headers` object and Ember Data will send them
|
|
395
|
-
along with each ajax request
|
|
396
|
-
customization](/ember-data/release/classes/RESTAdapter).
|
|
393
|
+
along with each ajax request..
|
|
397
394
|
```js [app/adapters/application.js]
|
|
398
395
|
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
399
396
|
export default class ApplicationAdapter extends RESTAdapter {
|
package/dist/adapter.js
CHANGED
|
@@ -496,13 +496,11 @@ const BuildURLMixin = Mixin.create(mixinProps);
|
|
|
496
496
|
/**
|
|
497
497
|
* ## Overview
|
|
498
498
|
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
* ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
499
|
+
* :::danger
|
|
500
|
+
* ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
502
501
|
* If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* </blockquote>
|
|
502
|
+
* {@link Handler} instead to be used with the {@link RequestManager}
|
|
503
|
+
* ::::
|
|
506
504
|
*
|
|
507
505
|
* In order to properly fetch and update data, @warp-drive/legacy
|
|
508
506
|
* needs to understand how to connect to your API.
|
package/dist/compat/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-
|
|
1
|
+
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-B1pSSN52.js";
|
package/dist/compat/utils.js
CHANGED
|
@@ -33,7 +33,7 @@ let NormalizedType = str => {
|
|
|
33
33
|
* changes during normalization. This is useful for instrumenting
|
|
34
34
|
* to discover places where usage in the app is not consistent.
|
|
35
35
|
*
|
|
36
|
-
* @param
|
|
36
|
+
* @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
|
|
37
37
|
* @public
|
|
38
38
|
*/
|
|
39
39
|
function configureMismatchReporter(fn) {
|
|
@@ -45,7 +45,7 @@ function configureMismatchReporter(fn) {
|
|
|
45
45
|
* fails validation. This is useful for instrumenting
|
|
46
46
|
* to discover places where usage in the app is not consistent.
|
|
47
47
|
*
|
|
48
|
-
* @param
|
|
48
|
+
* @param fn - a function which takes a message and a condition
|
|
49
49
|
* @public
|
|
50
50
|
*/
|
|
51
51
|
function configureAssertFn(fn) {
|
|
@@ -62,7 +62,7 @@ function configureAssertFn(fn) {
|
|
|
62
62
|
* the configured mismatch reporter and assert functions will
|
|
63
63
|
* be called.
|
|
64
64
|
*
|
|
65
|
-
* @param
|
|
65
|
+
* @param fn - a function which takes a string and returns a string
|
|
66
66
|
* @public
|
|
67
67
|
*/
|
|
68
68
|
function configureTypeNormalization(fn) {
|
|
@@ -72,7 +72,7 @@ const NORMALIZED_TYPES = new Map();
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Converts a potentially unnormalized type into the format expected
|
|
75
|
-
* by our
|
|
75
|
+
* by our WarpDrive Cache. Currently this is singular-dasherized.
|
|
76
76
|
*
|
|
77
77
|
* you should not rely on this function to give you an exact format
|
|
78
78
|
* for display purposes. Formatting for display should be handled
|
|
@@ -95,8 +95,8 @@ const NORMALIZED_TYPES = new Map();
|
|
|
95
95
|
* formattedType('PostComment'); // => 'post-comment'
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @return
|
|
98
|
+
* @param type the potentially un-normalized type
|
|
99
|
+
* @return the normalized type
|
|
100
100
|
* @public
|
|
101
101
|
*/
|
|
102
102
|
function formattedType(type) {
|
|
@@ -116,7 +116,7 @@ function formattedType(type) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Format an id to the format expected by the
|
|
119
|
+
* Format an id to the format expected by the WarpDrive Cache.
|
|
120
120
|
* Currently this means that id should be `string | null`.
|
|
121
121
|
*
|
|
122
122
|
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
@@ -131,8 +131,8 @@ function formattedType(type) {
|
|
|
131
131
|
* formattedId(null); // => null
|
|
132
132
|
* ```
|
|
133
133
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @return
|
|
134
|
+
* @param id the potentially un-normalized id
|
|
135
|
+
* @return the normalized id
|
|
136
136
|
* @public
|
|
137
137
|
*/
|
|
138
138
|
|
|
@@ -154,7 +154,7 @@ function expectId(id) {
|
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* Compares two types for strict equality, converting them to
|
|
157
|
-
* the format expected by the
|
|
157
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
158
158
|
* differences in format are accounted for in the comparison.
|
|
159
159
|
*
|
|
160
160
|
* Asserts when expected or actual are invalid types in dev.
|
|
@@ -172,9 +172,9 @@ function expectId(id) {
|
|
|
172
172
|
* isEquivType('posts', null); // false
|
|
173
173
|
* ```
|
|
174
174
|
*
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
177
|
-
* @return
|
|
175
|
+
* @param expected a potentially unnormalized type to match against
|
|
176
|
+
* @param actual a potentially unnormalized type to match against
|
|
177
|
+
* @return true if the types are equivalent
|
|
178
178
|
* @public
|
|
179
179
|
*/
|
|
180
180
|
function isEquivType(expected, actual) {
|
|
@@ -191,7 +191,7 @@ function isEquivType(expected, actual) {
|
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* Compares two IDs for strict equality, converting them to
|
|
194
|
-
* the format expected by the
|
|
194
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
195
195
|
* differences in format are accounted for in the comparison.
|
|
196
196
|
*
|
|
197
197
|
* Asserts when expected or actual are invalid IDs in dev.
|
|
@@ -205,9 +205,9 @@ function isEquivType(expected, actual) {
|
|
|
205
205
|
* isEquivId(1, null); // false
|
|
206
206
|
* ```
|
|
207
207
|
*
|
|
208
|
-
* @param
|
|
209
|
-
* @param
|
|
210
|
-
* @return
|
|
208
|
+
* @param expected a potentially un-normalized id to match against
|
|
209
|
+
* @param actual a potentially un-normalized id to match against
|
|
210
|
+
* @return true if the ids are equivalent
|
|
211
211
|
* @public
|
|
212
212
|
*/
|
|
213
213
|
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 => {
|
|
@@ -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) {
|