@ember-data/serializer 5.8.0-alpha.3 → 5.8.0-alpha.5

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/serializer",
3
- "version": "5.8.0-alpha.3",
3
+ "version": "5.8.0-alpha.5",
4
4
  "description": "Provides Legacy JSON, JSON:API and REST Implementations of the Serializer Interface for use with @ember-data/store",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -48,16 +48,16 @@
48
48
  "ember-cli-string-utils": "^1.1.0",
49
49
  "ember-cli-path-utils": "^1.0.0",
50
50
  "@ember/edition-utils": "1.2.0",
51
- "@warp-drive/core": "5.8.0-alpha.3",
52
- "@warp-drive/utilities": "5.8.0-alpha.3",
53
- "@warp-drive/legacy": "5.8.0-alpha.3"
51
+ "@warp-drive/core": "5.8.0-alpha.5",
52
+ "@warp-drive/utilities": "5.8.0-alpha.5",
53
+ "@warp-drive/legacy": "5.8.0-alpha.5"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/core": "^7.28.3",
57
57
  "@babel/plugin-transform-typescript": "^7.28.0",
58
58
  "@babel/preset-env": "^7.28.3",
59
59
  "@babel/preset-typescript": "^7.27.1",
60
- "@warp-drive/internal-config": "5.8.0-alpha.3",
60
+ "@warp-drive/internal-config": "5.8.0-alpha.5",
61
61
  "typescript": "^5.9.2",
62
62
  "vite": "^7.1.3"
63
63
  },
@@ -3,113 +3,6 @@
3
3
  /// <reference path="./json.d.ts" />
4
4
  /// <reference path="./json-api.d.ts" />
5
5
  declare module '@ember-data/serializer' {
6
- /**
7
- ## Overview
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/warp-drive-data/warp-drive/tree/main/packages/request#readme">RequestManager</a>
14
- </p>
15
- </blockquote>
16
-
17
- In order to properly manage and present your data, EmberData
18
- needs to understand the structure of data it receives.
19
-
20
- `Serializers` convert data between the server's API format and
21
- the format EmberData understands.
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.
27
-
28
- ### Implementing a Serializer
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.
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.
38
-
39
- ```ts
40
- import EmberObject from '@ember/object';
41
-
42
- export default class ApplicationSerializer extends EmberObject {
43
- normalizeResponse(store, schema, rawPayload) {
44
- return rawPayload;
45
- }
46
-
47
- serialize(snapshot, options) {
48
- const serializedResource = {
49
- id: snapshot.id,
50
- type: snapshot.modelName,
51
- attributes: snapshot.attributes()
52
- };
53
-
54
- return serializedResource;
55
- }
56
- }
57
- ```
58
-
59
-
60
- ### Serializer Resolution
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.
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`.
68
-
69
- ```ts
70
- store.serializerFor('author');
71
-
72
- // lookup paths (in order) =>
73
- // app/serializers/author.js
74
- // app/serializers/application.js
75
- ```
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`.
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.
86
-
87
- It is recommended that applications define only a single `application` adapter and serializer
88
- where possible.
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.
93
-
94
- ### Using a Serializer
95
-
96
- Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.
97
-
98
- ### Default Serializers
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.
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.
107
-
108
- It is recommended that apps write their own serializer to best suit the needs of their API and
109
- application.
110
-
111
- @module
112
- */
113
6
  export { Serializer as default } from "@warp-drive/legacy/serializer";
114
7
 
115
8
  }