@ember-data-mirror/serializer 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.
Files changed (40) hide show
  1. package/addon-main.cjs +1 -1
  2. package/dist/index.js +2 -306
  3. package/dist/index.js.map +1 -1
  4. package/dist/json-api.js +2 -531
  5. package/dist/json-api.js.map +1 -1
  6. package/dist/json.js +2 -6
  7. package/dist/json.js.map +1 -1
  8. package/dist/rest.js +2 -1274
  9. package/dist/rest.js.map +1 -1
  10. package/dist/transform.js +2 -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
@@ -1,15 +1,7 @@
1
+ /// <reference path="./json.d.ts" />
2
+ /// <reference path="./transform.d.ts" />
1
3
  /// <reference path="./json-api.d.ts" />
2
4
  /// <reference path="./rest.d.ts" />
3
- /// <reference path="./transform.d.ts" />
4
- /// <reference path="./json.d.ts" />
5
- /// <reference path="./-private/utils.d.ts" />
6
- /// <reference path="./-private/embedded-records-mixin.d.ts" />
7
- /// <reference path="./-private/transforms/number.d.ts" />
8
- /// <reference path="./-private/transforms/boolean.d.ts" />
9
- /// <reference path="./-private/transforms/boolean.type-test.d.ts" />
10
- /// <reference path="./-private/transforms/date.d.ts" />
11
- /// <reference path="./-private/transforms/string.d.ts" />
12
- /// <reference path="./-private/transforms/transform.d.ts" />
13
5
  declare module '@ember-data-mirror/serializer' {
14
6
  /**
15
7
  ## Overview
@@ -41,7 +33,7 @@ declare module '@ember-data-mirror/serializer' {
41
33
  server API format.
42
34
 
43
35
  To implement a serializer, export a class that conforms to the structure
44
- described by [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)
36
+ described by {@link MinimumSerializerInterface}
45
37
  from the `app/serializers/` directory. An example is below.
46
38
 
47
39
  ```ts
@@ -116,162 +108,8 @@ declare module '@ember-data-mirror/serializer' {
116
108
  It is recommended that apps write their own serializer to best suit the needs of their API and
117
109
  application.
118
110
 
119
- @module @ember-data-mirror/serializer
120
- @main @ember-data-mirror/serializer
121
- */
122
- import EmberObject from '@ember/object';
123
- import type Store from '@ember-data-mirror/store';
124
- import type { ModelSchema } from '@ember-data-mirror/store/types';
125
- import type { EmptyResourceDocument, SingleResourceDocument } from '@warp-drive-mirror/core-types/spec/json-api-raw';
126
- /**
127
- > ⚠️ CAUTION you likely want the docs for [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)
128
- > as extending this abstract class is unnecessary.
129
-
130
- `Serializer` is an abstract base class that you may override in your
131
- application to customize it for your backend. The minimum set of methods
132
- that you should implement is:
133
-
134
- * `normalizeResponse()`
135
- * `serialize()`
136
-
137
- And you can optionally override the following methods:
138
-
139
- * `normalize()`
140
-
141
- For an example implementation, see
142
- [JSONSerializer](JSONSerializer), the included JSON serializer.
143
-
144
- @class Serializer
145
- @public
146
- @extends Ember.EmberObject
111
+ @module
147
112
  */
148
- export default class extends EmberObject {
149
- store: Store;
150
- /**
151
- The `store` property is the application's `store` that contains
152
- all records. It can be used to look up serializers for other model
153
- types that may be nested inside the payload response.
154
-
155
- Example:
156
-
157
- ```js
158
- Serializer.extend({
159
- extractRelationship(relationshipModelName, relationshipHash) {
160
- let modelClass = this.store.modelFor(relationshipModelName);
161
- let relationshipSerializer = this.store.serializerFor(relationshipModelName);
162
- return relationshipSerializer.normalize(modelClass, relationshipHash);
163
- }
164
- });
165
- ```
166
-
167
- @property store
168
- @type {Store}
169
- @public
170
- */
171
- /**
172
- The `normalizeResponse` method is used to normalize a payload from the
173
- server to a JSON-API Document.
174
-
175
- http://jsonapi.org/format/#document-structure
176
-
177
- Example:
178
-
179
- ```js
180
- Serializer.extend({
181
- normalizeResponse(store, primaryModelClass, payload, id, requestType) {
182
- if (requestType === 'findRecord') {
183
- return this.normalize(primaryModelClass, payload);
184
- } else {
185
- return payload.reduce(function(documentHash, item) {
186
- let { data, included } = this.normalize(primaryModelClass, item);
187
- documentHash.included.push(...included);
188
- documentHash.data.push(data);
189
- return documentHash;
190
- }, { data: [], included: [] })
191
- }
192
- }
193
- });
194
- ```
195
-
196
- @since 1.13.0
197
- @method normalizeResponse
198
- @public
199
- @param {Store} store
200
- @param {Model} primaryModelClass
201
- @param {Object} payload
202
- @param {String|Number} id
203
- @param {String} requestType
204
- @return {Object} JSON-API Document
205
- */
206
- /**
207
- The `serialize` method is used when a record is saved in order to convert
208
- the record into the form that your external data source expects.
209
-
210
- `serialize` takes an optional `options` hash with a single option:
211
-
212
- - `includeId`: If this is `true`, `serialize` should include the ID
213
- in the serialized object it builds.
214
-
215
- Example:
216
-
217
- ```js
218
- Serializer.extend({
219
- serialize(snapshot, options) {
220
- let json = {
221
- id: snapshot.id
222
- };
223
-
224
- snapshot.eachAttribute((key, attribute) => {
225
- json[key] = snapshot.attr(key);
226
- });
227
-
228
- snapshot.eachRelationship((key, relationship) => {
229
- if (relationship.kind === 'belongsTo') {
230
- json[key] = snapshot.belongsTo(key, { id: true });
231
- } else if (relationship.kind === 'hasMany') {
232
- json[key] = snapshot.hasMany(key, { ids: true });
233
- }
234
- });
235
-
236
- return json;
237
- },
238
- });
239
- ```
240
-
241
- @method serialize
242
- @public
243
- @param {Snapshot} snapshot
244
- @param {Object} [options]
245
- @return {Object}
246
- */
247
- /**
248
- The `normalize` method is used to convert a payload received from your
249
- external data source into the normalized form `store.push()` expects. You
250
- should override this method, munge the hash and return the normalized
251
- payload.
252
-
253
- Example:
254
-
255
- ```js
256
- Serializer.extend({
257
- normalize(modelClass, resourceHash) {
258
- let data = {
259
- id: resourceHash.id,
260
- type: modelClass.modelName,
261
- attributes: resourceHash
262
- };
263
- return { data: data };
264
- }
265
- })
266
- ```
267
-
268
- @method normalize
269
- @public
270
- @param {Model} typeClass
271
- @param {Object} hash
272
- @return {Object}
273
- */
274
- normalize(_typeClass: ModelSchema, hash: Record<string, unknown>): SingleResourceDocument | EmptyResourceDocument;
275
- }
113
+ export { Serializer as default } from '@warp-drive-mirror/legacy/serializer';
276
114
  }
277
115
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2GE;AAEF,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAI9G;;;;;;;;;;;;;;;;;;;;;EAqBE;AAEF,MAAM,CAAC,OAAO,MAAO,SAAQ,WAAW;IACrB,KAAK,EAAE,KAAK,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;MAoBE;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkCE;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwCE;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BE;IACF,SAAS,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,GAAG,qBAAqB;CAGlH"}
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"}