@ember-data-types/serializer 5.6.0-alpha.15 → 5.6.0-alpha.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-data-types/serializer",
3
- "version": "5.6.0-alpha.15",
3
+ "version": "5.6.0-alpha.17",
4
4
  "files": [
5
5
  "unstable-preview-types",
6
6
  "README.md",
@@ -4,112 +4,112 @@
4
4
  /// <reference path="./rest.d.ts" />
5
5
  declare module '@ember-data/serializer' {
6
6
  /**
7
- ## Overview
7
+ ## Overview
8
8
 
9
- <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
10
- <p>
11
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
12
- If starting a new app or thinking of implementing a new serializer, consider writing a
13
- <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
14
- </p>
15
- </blockquote>
9
+ <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
10
+ <p>
11
+ ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
12
+ If starting a new app or thinking of implementing a new serializer, consider writing a
13
+ <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
14
+ </p>
15
+ </blockquote>
16
16
 
17
- In order to properly manage and present your data, EmberData
18
- needs to understand the structure of data it receives.
17
+ In order to properly manage and present your data, EmberData
18
+ needs to understand the structure of data it receives.
19
19
 
20
- `Serializers` convert data between the server's API format and
21
- the format EmberData understands.
20
+ `Serializers` convert data between the server's API format and
21
+ the format EmberData understands.
22
22
 
23
- Data received from an API response is **normalized** into
24
- [JSON:API](https://jsonapi.org/) (the format used internally
25
- by EmberData), while data sent to an API is **serialized**
26
- into the format the API expects.
23
+ Data received from an API response is **normalized** into
24
+ [JSON:API](https://jsonapi.org/) (the format used internally
25
+ by EmberData), while data sent to an API is **serialized**
26
+ into the format the API expects.
27
27
 
28
- ### Implementing a Serializer
28
+ ### Implementing a Serializer
29
29
 
30
- There are only two required serializer methods, one for
31
- normalizing data from the server API format into JSON:API, and
32
- another for serializing records via `Snapshots` into the expected
33
- server API format.
30
+ There are only two required serializer methods, one for
31
+ normalizing data from the server API format into JSON:API, and
32
+ another for serializing records via `Snapshots` into the expected
33
+ server API format.
34
34
 
35
- To implement a serializer, export a class that conforms to the structure
36
- described by {@link MinimumSerializerInterface}
37
- from the `app/serializers/` directory. An example is below.
35
+ To implement a serializer, export a class that conforms to the structure
36
+ described by {@link MinimumSerializerInterface}
37
+ from the `app/serializers/` directory. An example is below.
38
38
 
39
- ```ts
40
- import EmberObject from '@ember/object';
39
+ ```ts
40
+ import EmberObject from '@ember/object';
41
41
 
42
- export default class ApplicationSerializer extends EmberObject {
43
- normalizeResponse(store, schema, rawPayload) {
44
- return rawPayload;
45
- }
42
+ export default class ApplicationSerializer extends EmberObject {
43
+ normalizeResponse(store, schema, rawPayload) {
44
+ return rawPayload;
45
+ }
46
46
 
47
- serialize(snapshot, options) {
48
- const serializedResource = {
49
- id: snapshot.id,
50
- type: snapshot.modelName,
51
- attributes: snapshot.attributes()
52
- };
47
+ serialize(snapshot, options) {
48
+ const serializedResource = {
49
+ id: snapshot.id,
50
+ type: snapshot.modelName,
51
+ attributes: snapshot.attributes()
52
+ };
53
53
 
54
- return serializedResource;
55
- }
56
- }
57
- ```
54
+ return serializedResource;
55
+ }
56
+ }
57
+ ```
58
58
 
59
59
 
60
- ### Serializer Resolution
60
+ ### Serializer Resolution
61
61
 
62
- `store.serializerFor(name)` will lookup serializers defined in
63
- `app/serializers/` and return an instance. If no serializer is found, an
64
- error will be thrown.
62
+ `store.serializerFor(name)` will lookup serializers defined in
63
+ `app/serializers/` and return an instance. If no serializer is found, an
64
+ error will be thrown.
65
65
 
66
- `serializerFor` first attempts to find a serializer with an exact match on `name`,
67
- then falls back to checking for the presence of a serializer named `application`.
66
+ `serializerFor` first attempts to find a serializer with an exact match on `name`,
67
+ then falls back to checking for the presence of a serializer named `application`.
68
68
 
69
- ```ts
70
- store.serializerFor('author');
69
+ ```ts
70
+ store.serializerFor('author');
71
71
 
72
- // lookup paths (in order) =>
73
- // app/serializers/author.js
74
- // app/serializers/application.js
75
- ```
72
+ // lookup paths (in order) =>
73
+ // app/serializers/author.js
74
+ // app/serializers/application.js
75
+ ```
76
76
 
77
- Most requests in EmberData are made with respect to a particular `type` (or `modelName`)
78
- (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
79
- refer to this as the **primary** resource `type`.
77
+ Most requests in EmberData are made with respect to a particular `type` (or `modelName`)
78
+ (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
79
+ refer to this as the **primary** resource `type`.
80
80
 
81
- Typically `serializerFor` will be used to find a serializer with a name matching that of the primary
82
- resource `type` for the request, falling back to the `application` serializer for those types that
83
- do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy
84
- for defining serializers. However, because APIs rarely format payloads per-type but rather
85
- per-API-version, this may not be a desired strategy.
81
+ Typically `serializerFor` will be used to find a serializer with a name matching that of the primary
82
+ resource `type` for the request, falling back to the `application` serializer for those types that
83
+ do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy
84
+ for defining serializers. However, because APIs rarely format payloads per-type but rather
85
+ per-API-version, this may not be a desired strategy.
86
86
 
87
- It is recommended that applications define only a single `application` adapter and serializer
88
- where possible.
87
+ It is recommended that applications define only a single `application` adapter and serializer
88
+ where possible.
89
89
 
90
- If you have multiple API formats and the per-type strategy is not viable, one strategy is to
91
- write an `application` adapter and serializer that make use of `options` to specify the desired
92
- format when making a request.
90
+ If you have multiple API formats and the per-type strategy is not viable, one strategy is to
91
+ write an `application` adapter and serializer that make use of `options` to specify the desired
92
+ format when making a request.
93
93
 
94
- ### Using a Serializer
94
+ ### Using a Serializer
95
95
 
96
- Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.
96
+ Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.
97
97
 
98
- ### Default Serializers
98
+ ### Default Serializers
99
99
 
100
- For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
101
- format the `@ember-data/serializer` package contains implementations these applications can
102
- extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
100
+ For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
101
+ format the `@ember-data/serializer` package contains implementations these applications can
102
+ extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
103
103
 
104
- Many applications will find writing their own serializer to be more performant and less
105
- complex than extending these classes even when their API format is very close to that expected
106
- by these serializers.
104
+ Many applications will find writing their own serializer to be more performant and less
105
+ complex than extending these classes even when their API format is very close to that expected
106
+ by these serializers.
107
107
 
108
- It is recommended that apps write their own serializer to best suit the needs of their API and
109
- application.
108
+ It is recommended that apps write their own serializer to best suit the needs of their API and
109
+ application.
110
110
 
111
- @module
111
+ @module
112
112
  */
113
- export { Serializer as default } from '@warp-drive/legacy/serializer';
114
- }
115
- //# sourceMappingURL=index.d.ts.map
113
+ export { Serializer as default } from "@warp-drive/legacy/serializer";
114
+
115
+ }
@@ -1,4 +1,4 @@
1
1
  declare module '@ember-data/serializer/json-api' {
2
- export { JSONAPISerializer as default } from '@warp-drive/legacy/serializer/json-api';
3
- }
4
- //# sourceMappingURL=json-api.d.ts.map
2
+ export { JSONAPISerializer as default } from "@warp-drive/legacy/serializer/json-api";
3
+
4
+ }
@@ -1,4 +1,4 @@
1
1
  declare module '@ember-data/serializer/json' {
2
- export { JSONSerializer as default } from '@warp-drive/legacy/serializer/json';
3
- }
4
- //# sourceMappingURL=json.d.ts.map
2
+ export { JSONSerializer as default } from "@warp-drive/legacy/serializer/json";
3
+
4
+ }
@@ -1,4 +1,4 @@
1
1
  declare module '@ember-data/serializer/rest' {
2
- export { RESTSerializer as default, EmbeddedRecordsMixin } from '@warp-drive/legacy/serializer/rest';
3
- }
4
- //# sourceMappingURL=rest.d.ts.map
2
+ export { RESTSerializer as default, EmbeddedRecordsMixin } from "@warp-drive/legacy/serializer/rest";
3
+
4
+ }
@@ -1,4 +1,4 @@
1
1
  declare module '@ember-data/serializer/transform' {
2
- export { Transform as default, BooleanTransform, StringTransform, NumberTransform, DateTransform, } from '@warp-drive/legacy/serializer/transform';
3
- }
4
- //# sourceMappingURL=transform.d.ts.map
2
+ export { Transform as default, BooleanTransform, StringTransform, NumberTransform, DateTransform } from "@warp-drive/legacy/serializer/transform";
3
+
4
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0GE;AACF,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-api.d.ts","sourceRoot":"","sources":["../src/json-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,MAAM,wCAAwC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,oCAAoC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,IAAI,OAAO,EACpB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,yCAAyC,CAAC"}