@ember-data-mirror/serializer 5.6.0-alpha.1 → 5.6.0-alpha.11

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.
Files changed (40) hide show
  1. package/addon-main.cjs +1 -1
  2. package/dist/index.js +1 -306
  3. package/dist/index.js.map +1 -1
  4. package/dist/json-api.js +1 -531
  5. package/dist/json-api.js.map +1 -1
  6. package/dist/json.js +1 -6
  7. package/dist/json.js.map +1 -1
  8. package/dist/rest.js +1 -1274
  9. package/dist/rest.js.map +1 -1
  10. package/dist/transform.js +1 -336
  11. package/dist/transform.js.map +1 -1
  12. package/package.json +6 -23
  13. package/unstable-preview-types/index.d.ts +5 -167
  14. package/unstable-preview-types/index.d.ts.map +1 -1
  15. package/unstable-preview-types/json-api.d.ts +1 -511
  16. package/unstable-preview-types/json-api.d.ts.map +1 -1
  17. package/unstable-preview-types/json.d.ts +1 -1090
  18. package/unstable-preview-types/json.d.ts.map +1 -1
  19. package/unstable-preview-types/rest.d.ts +1 -567
  20. package/unstable-preview-types/rest.d.ts.map +1 -1
  21. package/unstable-preview-types/transform.d.ts +1 -8
  22. package/unstable-preview-types/transform.d.ts.map +1 -1
  23. package/dist/json-CVTR4xWv.js +0 -1396
  24. package/dist/json-CVTR4xWv.js.map +0 -1
  25. package/unstable-preview-types/-private/embedded-records-mixin.d.ts +0 -102
  26. package/unstable-preview-types/-private/embedded-records-mixin.d.ts.map +0 -1
  27. package/unstable-preview-types/-private/transforms/boolean.d.ts +0 -52
  28. package/unstable-preview-types/-private/transforms/boolean.d.ts.map +0 -1
  29. package/unstable-preview-types/-private/transforms/boolean.type-test.d.ts +0 -4
  30. package/unstable-preview-types/-private/transforms/boolean.type-test.d.ts.map +0 -1
  31. package/unstable-preview-types/-private/transforms/date.d.ts +0 -33
  32. package/unstable-preview-types/-private/transforms/date.d.ts.map +0 -1
  33. package/unstable-preview-types/-private/transforms/number.d.ts +0 -34
  34. package/unstable-preview-types/-private/transforms/number.d.ts.map +0 -1
  35. package/unstable-preview-types/-private/transforms/string.d.ts +0 -34
  36. package/unstable-preview-types/-private/transforms/string.d.ts.map +0 -1
  37. package/unstable-preview-types/-private/transforms/transform.d.ts +0 -126
  38. package/unstable-preview-types/-private/transforms/transform.d.ts.map +0 -1
  39. package/unstable-preview-types/-private/utils.d.ts +0 -6
  40. package/unstable-preview-types/-private/utils.d.ts.map +0 -1
package/addon-main.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const { addonShim } = require('@warp-drive-mirror/build-config/addon-shim.cjs');
3
+ const { addonShim } = require('@warp-drive-mirror/core/addon-shim.cjs');
4
4
 
5
5
  module.exports = addonShim(__dirname);
package/dist/index.js CHANGED
@@ -1,306 +1 @@
1
- import EmberObject from '@ember/object';
2
- import * as s from '@ember/service';
3
- const deferred = /* @__PURE__ */new WeakMap();
4
- function deferDecorator(proto, prop, desc) {
5
- let map = deferred.get(proto);
6
- if (!map) {
7
- map = /* @__PURE__ */new Map();
8
- deferred.set(proto, map);
9
- }
10
- map.set(prop, desc);
11
- }
12
- function findDeferredDecorator(target, prop) {
13
- var _a;
14
- let cursor = target.prototype;
15
- while (cursor) {
16
- let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);
17
- if (desc) {
18
- return desc;
19
- }
20
- cursor = cursor.prototype;
21
- }
22
- }
23
- function decorateFieldV2(prototype, prop, decorators, initializer) {
24
- let desc = {
25
- configurable: true,
26
- enumerable: true,
27
- writable: true,
28
- initializer: null
29
- };
30
- if (initializer) {
31
- desc.initializer = initializer;
32
- }
33
- for (let decorator of decorators) {
34
- desc = decorator(prototype, prop, desc) || desc;
35
- }
36
- if (desc.initializer === void 0) {
37
- Object.defineProperty(prototype, prop, desc);
38
- } else {
39
- deferDecorator(prototype, prop, desc);
40
- }
41
- }
42
- function initializeDeferredDecorator(target, prop) {
43
- let desc = findDeferredDecorator(target.constructor, prop);
44
- if (desc) {
45
- Object.defineProperty(target, prop, {
46
- enumerable: desc.enumerable,
47
- configurable: desc.configurable,
48
- writable: desc.writable,
49
- value: desc.initializer ? desc.initializer.call(target) : void 0
50
- });
51
- }
52
- }
53
-
54
- /**
55
- ## Overview
56
-
57
- <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
58
- <p>
59
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
60
- If starting a new app or thinking of implementing a new serializer, consider writing a
61
- <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>
62
- </p>
63
- </blockquote>
64
-
65
- In order to properly manage and present your data, EmberData
66
- needs to understand the structure of data it receives.
67
-
68
- `Serializers` convert data between the server's API format and
69
- the format EmberData understands.
70
-
71
- Data received from an API response is **normalized** into
72
- [JSON:API](https://jsonapi.org/) (the format used internally
73
- by EmberData), while data sent to an API is **serialized**
74
- into the format the API expects.
75
-
76
- ### Implementing a Serializer
77
-
78
- There are only two required serializer methods, one for
79
- normalizing data from the server API format into JSON:API, and
80
- another for serializing records via `Snapshots` into the expected
81
- server API format.
82
-
83
- To implement a serializer, export a class that conforms to the structure
84
- described by [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)
85
- from the `app/serializers/` directory. An example is below.
86
-
87
- ```ts
88
- import EmberObject from '@ember/object';
89
-
90
- export default class ApplicationSerializer extends EmberObject {
91
- normalizeResponse(store, schema, rawPayload) {
92
- return rawPayload;
93
- }
94
-
95
- serialize(snapshot, options) {
96
- const serializedResource = {
97
- id: snapshot.id,
98
- type: snapshot.modelName,
99
- attributes: snapshot.attributes()
100
- };
101
-
102
- return serializedResource;
103
- }
104
- }
105
- ```
106
-
107
-
108
- ### Serializer Resolution
109
-
110
- `store.serializerFor(name)` will lookup serializers defined in
111
- `app/serializers/` and return an instance. If no serializer is found, an
112
- error will be thrown.
113
-
114
- `serializerFor` first attempts to find a serializer with an exact match on `name`,
115
- then falls back to checking for the presence of a serializer named `application`.
116
-
117
- ```ts
118
- store.serializerFor('author');
119
-
120
- // lookup paths (in order) =>
121
- // app/serializers/author.js
122
- // app/serializers/application.js
123
- ```
124
-
125
- Most requests in EmberData are made with respect to a particular `type` (or `modelName`)
126
- (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
127
- refer to this as the **primary** resource `type`.
128
-
129
- Typically `serializerFor` will be used to find a serializer with a name matching that of the primary
130
- resource `type` for the request, falling back to the `application` serializer for those types that
131
- do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy
132
- for defining serializers. However, because APIs rarely format payloads per-type but rather
133
- per-API-version, this may not be a desired strategy.
134
-
135
- It is recommended that applications define only a single `application` adapter and serializer
136
- where possible.
137
-
138
- If you have multiple API formats and the per-type strategy is not viable, one strategy is to
139
- write an `application` adapter and serializer that make use of `options` to specify the desired
140
- format when making a request.
141
-
142
- ### Using a Serializer
143
-
144
- Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.
145
-
146
- ### Default Serializers
147
-
148
- For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
149
- format the `@ember-data-mirror/serializer` package contains implementations these applications can
150
- extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
151
-
152
- Many applications will find writing their own serializer to be more performant and less
153
- complex than extending these classes even when their API format is very close to that expected
154
- by these serializers.
155
-
156
- It is recommended that apps write their own serializer to best suit the needs of their API and
157
- application.
158
-
159
- @module @ember-data-mirror/serializer
160
- @main @ember-data-mirror/serializer
161
- */
162
-
163
- const service = s.service ?? s.inject;
164
-
165
- /**
166
- > ⚠️ CAUTION you likely want the docs for [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)
167
- > as extending this abstract class is unnecessary.
168
-
169
- `Serializer` is an abstract base class that you may override in your
170
- application to customize it for your backend. The minimum set of methods
171
- that you should implement is:
172
-
173
- * `normalizeResponse()`
174
- * `serialize()`
175
-
176
- And you can optionally override the following methods:
177
-
178
- * `normalize()`
179
-
180
- For an example implementation, see
181
- [JSONSerializer](JSONSerializer), the included JSON serializer.
182
-
183
- @class Serializer
184
- @public
185
- @extends Ember.EmberObject
186
- */
187
-
188
- class Serializer extends EmberObject {
189
- static {
190
- decorateFieldV2(this.prototype, "store", [service]);
191
- }
192
- #store = (initializeDeferredDecorator(this, "store"), void 0);
193
- /**
194
- The `store` property is the application's `store` that contains
195
- all records. It can be used to look up serializers for other model
196
- types that may be nested inside the payload response.
197
- Example:
198
- ```js
199
- Serializer.extend({
200
- extractRelationship(relationshipModelName, relationshipHash) {
201
- let modelClass = this.store.modelFor(relationshipModelName);
202
- let relationshipSerializer = this.store.serializerFor(relationshipModelName);
203
- return relationshipSerializer.normalize(modelClass, relationshipHash);
204
- }
205
- });
206
- ```
207
- @property store
208
- @type {Store}
209
- @public
210
- */
211
-
212
- /**
213
- The `normalizeResponse` method is used to normalize a payload from the
214
- server to a JSON-API Document.
215
- http://jsonapi.org/format/#document-structure
216
- Example:
217
- ```js
218
- Serializer.extend({
219
- normalizeResponse(store, primaryModelClass, payload, id, requestType) {
220
- if (requestType === 'findRecord') {
221
- return this.normalize(primaryModelClass, payload);
222
- } else {
223
- return payload.reduce(function(documentHash, item) {
224
- let { data, included } = this.normalize(primaryModelClass, item);
225
- documentHash.included.push(...included);
226
- documentHash.data.push(data);
227
- return documentHash;
228
- }, { data: [], included: [] })
229
- }
230
- }
231
- });
232
- ```
233
- @since 1.13.0
234
- @method normalizeResponse
235
- @public
236
- @param {Store} store
237
- @param {Model} primaryModelClass
238
- @param {Object} payload
239
- @param {String|Number} id
240
- @param {String} requestType
241
- @return {Object} JSON-API Document
242
- */
243
-
244
- /**
245
- The `serialize` method is used when a record is saved in order to convert
246
- the record into the form that your external data source expects.
247
- `serialize` takes an optional `options` hash with a single option:
248
- - `includeId`: If this is `true`, `serialize` should include the ID
249
- in the serialized object it builds.
250
- Example:
251
- ```js
252
- Serializer.extend({
253
- serialize(snapshot, options) {
254
- let json = {
255
- id: snapshot.id
256
- };
257
- snapshot.eachAttribute((key, attribute) => {
258
- json[key] = snapshot.attr(key);
259
- });
260
- snapshot.eachRelationship((key, relationship) => {
261
- if (relationship.kind === 'belongsTo') {
262
- json[key] = snapshot.belongsTo(key, { id: true });
263
- } else if (relationship.kind === 'hasMany') {
264
- json[key] = snapshot.hasMany(key, { ids: true });
265
- }
266
- });
267
- return json;
268
- },
269
- });
270
- ```
271
- @method serialize
272
- @public
273
- @param {Snapshot} snapshot
274
- @param {Object} [options]
275
- @return {Object}
276
- */
277
-
278
- /**
279
- The `normalize` method is used to convert a payload received from your
280
- external data source into the normalized form `store.push()` expects. You
281
- should override this method, munge the hash and return the normalized
282
- payload.
283
- Example:
284
- ```js
285
- Serializer.extend({
286
- normalize(modelClass, resourceHash) {
287
- let data = {
288
- id: resourceHash.id,
289
- type: modelClass.modelName,
290
- attributes: resourceHash
291
- };
292
- return { data: data };
293
- }
294
- })
295
- ```
296
- @method normalize
297
- @public
298
- @param {Model} typeClass
299
- @param {Object} hash
300
- @return {Object}
301
- */
302
- normalize(_typeClass, hash) {
303
- return hash;
304
- }
305
- }
306
- export { Serializer as default };
1
+ export { Serializer as default } from '@warp-drive-mirror/legacy/serializer';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/decorat_bfe8edbefc8aced6f61ce140cd72ecf2/node_modules/decorator-transforms/dist/runtime-BPCpkOf1.js","../src/index.ts"],"sourcesContent":["const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = cursor.prototype;\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV2 as a,\n decorateMethodV1 as b,\n decorateMethodV2 as c,\n decorateFieldV1 as d,\n decorateClass as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime-BPCpkOf1.js.map\n","/**\n ## Overview\n\n <blockquote style=\"margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;\">\n <p>\n ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new serializer, consider writing a\n <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>\n </p>\n </blockquote>\n\n In order to properly manage and present your data, EmberData\n needs to understand the structure of data it receives.\n\n `Serializers` convert data between the server's API format and\n the format EmberData understands.\n\n Data received from an API response is **normalized** into\n [JSON:API](https://jsonapi.org/) (the format used internally\n by EmberData), while data sent to an API is **serialized**\n into the format the API expects.\n\n ### Implementing a Serializer\n\n There are only two required serializer methods, one for\n normalizing data from the server API format into JSON:API, and\n another for serializing records via `Snapshots` into the expected\n server API format.\n\n To implement a serializer, export a class that conforms to the structure\n described by [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n from the `app/serializers/` directory. An example is below.\n\n ```ts\n import EmberObject from '@ember/object';\n\n export default class ApplicationSerializer extends EmberObject {\n normalizeResponse(store, schema, rawPayload) {\n return rawPayload;\n }\n\n serialize(snapshot, options) {\n const serializedResource = {\n id: snapshot.id,\n type: snapshot.modelName,\n attributes: snapshot.attributes()\n };\n\n return serializedResource;\n }\n }\n ```\n\n\n ### Serializer Resolution\n\n `store.serializerFor(name)` will lookup serializers defined in\n `app/serializers/` and return an instance. If no serializer is found, an\n error will be thrown.\n\n `serializerFor` first attempts to find a serializer with an exact match on `name`,\n then falls back to checking for the presence of a serializer named `application`.\n\n ```ts\n store.serializerFor('author');\n\n // lookup paths (in order) =>\n // app/serializers/author.js\n // app/serializers/application.js\n ```\n\n Most requests in EmberData are made with respect to a particular `type` (or `modelName`)\n (e.g., \"get me the full collection of **books**\" or \"get me the **employee** whose id is 37\"). We\n refer to this as the **primary** resource `type`.\n\n Typically `serializerFor` will be used to find a serializer with a name matching that of the primary\n resource `type` for the request, falling back to the `application` serializer for those types that\n do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy\n for defining serializers. However, because APIs rarely format payloads per-type but rather\n per-API-version, this may not be a desired strategy.\n\n It is recommended that applications define only a single `application` adapter and serializer\n where possible.\n\n If you have multiple API formats and the per-type strategy is not viable, one strategy is to\n write an `application` adapter and serializer that make use of `options` to specify the desired\n format when making a request.\n\n ### Using a Serializer\n\n Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.\n\n ### Default Serializers\n\n For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**\n format the `@ember-data-mirror/serializer` package contains implementations these applications can\n extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.\n\n Many applications will find writing their own serializer to be more performant and less\n complex than extending these classes even when their API format is very close to that expected\n by these serializers.\n\n It is recommended that apps write their own serializer to best suit the needs of their API and\n application.\n\n @module @ember-data-mirror/serializer\n @main @ember-data-mirror/serializer\n*/\n\nimport EmberObject from '@ember/object';\nimport * as s from '@ember/service';\n\nimport type Store from '@ember-data-mirror/store';\nimport type { ModelSchema } from '@ember-data-mirror/store/types';\nimport type { EmptyResourceDocument, SingleResourceDocument } from '@warp-drive-mirror/core-types/spec/json-api-raw';\n\nconst service = s.service ?? s.inject;\n\n/**\n > ⚠️ CAUTION you likely want the docs for [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n > as extending this abstract class is unnecessary.\n\n `Serializer` is an abstract base class that you may override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `normalizeResponse()`\n * `serialize()`\n\n And you can optionally override the following methods:\n\n * `normalize()`\n\n For an example implementation, see\n [JSONSerializer](JSONSerializer), the included JSON serializer.\n\n @class Serializer\n @public\n @extends Ember.EmberObject\n*/\n\nexport default class extends EmberObject {\n @service declare store: Store;\n /**\n The `store` property is the application's `store` that contains\n all records. It can be used to look up serializers for other model\n types that may be nested inside the payload response.\n\n Example:\n\n ```js\n Serializer.extend({\n extractRelationship(relationshipModelName, relationshipHash) {\n let modelClass = this.store.modelFor(relationshipModelName);\n let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n return relationshipSerializer.normalize(modelClass, relationshipHash);\n }\n });\n ```\n\n @property store\n @type {Store}\n @public\n */\n\n /**\n The `normalizeResponse` method is used to normalize a payload from the\n server to a JSON-API Document.\n\n http://jsonapi.org/format/#document-structure\n\n Example:\n\n ```js\n Serializer.extend({\n normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n if (requestType === 'findRecord') {\n return this.normalize(primaryModelClass, payload);\n } else {\n return payload.reduce(function(documentHash, item) {\n let { data, included } = this.normalize(primaryModelClass, item);\n documentHash.included.push(...included);\n documentHash.data.push(data);\n return documentHash;\n }, { data: [], included: [] })\n }\n }\n });\n ```\n\n @since 1.13.0\n @method normalizeResponse\n @public\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @return {Object} JSON-API Document\n */\n\n /**\n The `serialize` method is used when a record is saved in order to convert\n the record into the form that your external data source expects.\n\n `serialize` takes an optional `options` hash with a single option:\n\n - `includeId`: If this is `true`, `serialize` should include the ID\n in the serialized object it builds.\n\n Example:\n\n ```js\n Serializer.extend({\n serialize(snapshot, options) {\n let json = {\n id: snapshot.id\n };\n\n snapshot.eachAttribute((key, attribute) => {\n json[key] = snapshot.attr(key);\n });\n\n snapshot.eachRelationship((key, relationship) => {\n if (relationship.kind === 'belongsTo') {\n json[key] = snapshot.belongsTo(key, { id: true });\n } else if (relationship.kind === 'hasMany') {\n json[key] = snapshot.hasMany(key, { ids: true });\n }\n });\n\n return json;\n },\n });\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} [options]\n @return {Object}\n */\n\n /**\n The `normalize` method is used to convert a payload received from your\n external data source into the normalized form `store.push()` expects. You\n should override this method, munge the hash and return the normalized\n payload.\n\n Example:\n\n ```js\n Serializer.extend({\n normalize(modelClass, resourceHash) {\n let data = {\n id: resourceHash.id,\n type: modelClass.modelName,\n attributes: resourceHash\n };\n return { data: data };\n }\n })\n ```\n\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash\n @return {Object}\n */\n normalize(_typeClass: ModelSchema, hash: Record<string, unknown>): SingleResourceDocument | EmptyResourceDocument {\n return hash as unknown as SingleResourceDocument;\n }\n}\n"],"names":["deferred","WeakMap","deferDecorator","proto","prop","desc","map","get","Map","set","findDeferredDecorator","target","_a","cursor","prototype","decorateFieldV2","decorators","initializer","configurable","enumerable","writable","decorator","Object","defineProperty","initializeDeferredDecorator","constructor","value","call","service","s","inject","EmberObject","g","i","void 0","normalize","_typeClass","hash"],"mappings":";;;AAuBA,MAAMA,QAAA,sBAGEC,OAAA,EAAA;AAER,SAASC,eACPC,KAAA,EACAC,IAAA,EACAC,IAAA,EACM;AACF,EAAA,IAAAC,GAAA,GAAMN,QAAA,CAASO,GAAA,CAAIJ,KAAK,CAAA;EAC5B,IAAI,CAACG,GAAA,EAAK;AACRA,IAAAA,GAAA,sBAAUE,GAAA,EAAA;AACDR,IAAAA,QAAA,CAAAS,GAAA,CAAIN,KAAA,EAAOG,GAAG,CAAA;AACzB;AACIA,EAAAA,GAAA,CAAAG,GAA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AAA;AACR;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAME;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIEC,EAAAA,SAASA,CAACC,UAAuB,EAAEC,IAA6B,EAAkD;AAChH,IAAA,OAAOA,IAAI;AACb;AACF;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}