@ember-data/legacy-compat 5.6.0-alpha.5 → 5.6.0-beta.1

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 (50) hide show
  1. package/addon-main.cjs +1 -1
  2. package/dist/-private.js +1 -1
  3. package/dist/builders.js +1 -292
  4. package/dist/index.js +1 -1002
  5. package/dist/utils.js +1 -224
  6. package/package.json +7 -30
  7. package/unstable-preview-types/-private.d.ts +7 -13
  8. package/unstable-preview-types/builders.d.ts +9 -12
  9. package/unstable-preview-types/index.d.ts +2 -149
  10. package/unstable-preview-types/utils.d.ts +9 -138
  11. package/dist/-private-CVvkihLY.js +0 -1188
  12. package/dist/-private-CVvkihLY.js.map +0 -1
  13. package/dist/-private.js.map +0 -1
  14. package/dist/builders.js.map +0 -1
  15. package/dist/index.js.map +0 -1
  16. package/dist/utils.js.map +0 -1
  17. package/unstable-preview-types/-private.d.ts.map +0 -1
  18. package/unstable-preview-types/builders/find-all.d.ts +0 -35
  19. package/unstable-preview-types/builders/find-all.d.ts.map +0 -1
  20. package/unstable-preview-types/builders/find-record.d.ts +0 -56
  21. package/unstable-preview-types/builders/find-record.d.ts.map +0 -1
  22. package/unstable-preview-types/builders/query.d.ts +0 -63
  23. package/unstable-preview-types/builders/query.d.ts.map +0 -1
  24. package/unstable-preview-types/builders/save-record.d.ts +0 -34
  25. package/unstable-preview-types/builders/save-record.d.ts.map +0 -1
  26. package/unstable-preview-types/builders/utils.d.ts +0 -6
  27. package/unstable-preview-types/builders/utils.d.ts.map +0 -1
  28. package/unstable-preview-types/builders.d.ts.map +0 -1
  29. package/unstable-preview-types/index.d.ts.map +0 -1
  30. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts +0 -49
  31. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts.map +0 -1
  32. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts +0 -5
  33. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
  34. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts +0 -14
  35. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
  36. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts +0 -8
  37. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
  38. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts +0 -5
  39. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
  40. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts +0 -529
  41. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
  42. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts +0 -226
  43. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
  44. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts +0 -9
  45. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts.map +0 -1
  46. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts +0 -91
  47. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
  48. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts +0 -239
  49. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts.map +0 -1
  50. package/unstable-preview-types/utils.d.ts.map +0 -1
@@ -1,226 +0,0 @@
1
- declare module '@ember-data/legacy-compat/legacy-network-handler/minimum-serializer-interface' {
2
- import type Store from '@ember-data/store';
3
- import type { ModelSchema } from '@ember-data/store/types';
4
- import type { ObjectValue } from '@warp-drive/core-types/json/raw';
5
- import type { JsonApiDocument, SingleResourceDocument } from '@warp-drive/core-types/spec/json-api-raw';
6
- import type { AdapterPayload } from '@ember-data/legacy-compat/legacy-network-handler/minimum-adapter-interface';
7
- import type { Snapshot } from '@ember-data/legacy-compat/legacy-network-handler/snapshot';
8
- export type SerializerOptions = {
9
- includeId?: boolean;
10
- };
11
- export type RequestType = 'findRecord' | 'queryRecord' | 'findAll' | 'findBelongsTo' | 'findHasMany' | 'findMany' | 'query' | 'createRecord' | 'deleteRecord' | 'updateRecord';
12
- /**
13
- * <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
14
- <p>
15
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
16
- If starting a new app or thinking of implementing a new adapter, consider writing a
17
- <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>
18
- </p>
19
- </blockquote>
20
-
21
- The following documentation describes the methods an application
22
- serializer should implement with descriptions around when an
23
- application might expect these methods to be called.
24
-
25
- Methods that are not required are marked as **optional**.
26
-
27
- @class (Interface) Serializer
28
- @public
29
- */
30
- export interface MinimumSerializerInterface {
31
- /**
32
- * This method is responsible for normalizing the value resolved from the promise returned
33
- * by an Adapter request into the format expected by the `Store`.
34
- *
35
- * The output should be a [JSON:API Document](https://jsonapi.org/format/#document-structure)
36
- * with the following additional restrictions:
37
- *
38
- * - `type` should be formatted in the `singular` `dasherized` `lowercase` form
39
- * - `members` (the property names of attributes and relationships) should be formatted
40
- * to match their definition in the corresponding `Model` definition. Typically this
41
- * will be `camelCase`.
42
- * - [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is
43
- * a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
44
- * and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
45
- *
46
- * @public
47
- * @param {Store} store The store service that initiated the request being normalized
48
- * @param {ModelSchema} schema An object with methods for accessing information about
49
- * the type, attributes and relationships of the primary type associated with the request.
50
- * @param {JSONObject} rawPayload The raw JSON response data returned from an API request.
51
- * This correlates to the value the promise returned by the adapter method that performed
52
- * the request resolved to.
53
- * @param {string|null} id For a findRecord request, this is the id initially provided
54
- * in the call to store.findRecord. Else this value is null.
55
- * @param {'findRecord' | 'queryRecord' | 'findAll' | 'findBelongsTo' | 'findHasMany' | 'findMany' | 'query' | 'createRecord' | 'deleteRecord' | 'updateRecord'} requestType The
56
- * type of request the Adapter had been asked to perform.
57
- *
58
- * @return {JsonApiDocument} a document following the structure of a JSON:API Document.
59
- */
60
- normalizeResponse(store: Store, schema: ModelSchema, rawPayload: AdapterPayload, id: string | null, requestType: 'findRecord' | 'queryRecord' | 'findAll' | 'findBelongsTo' | 'findHasMany' | 'findMany' | 'query' | 'createRecord' | 'deleteRecord' | 'updateRecord'): JsonApiDocument;
61
- /**
62
- * This method is responsible for serializing an individual record
63
- * via a [Snapshot](Snapshot) into the format expected by the API.
64
- *
65
- * This method is called by `snapshot.serialize()`.
66
- *
67
- * When using `Model`, this method is called by `record.serialize()`.
68
- *
69
- * When using `JSONAPIAdapter` or `RESTAdapter` this method is called
70
- * by `updateRecord` and `createRecord` if `Serializer.serializeIntoHash`
71
- * is not implemented.
72
- *
73
- * @public
74
- * @param {Snapshot} snapshot A Snapshot for the record to serialize
75
- * @param {Object} [options]
76
- */
77
- serialize(snapshot: Snapshot, options?: SerializerOptions): ObjectValue;
78
- /**
79
- * This method is intended to normalize data into a [JSON:API Document](https://jsonapi.org/format/#document-structure)
80
- * with a data member containing a single [Resource](https://jsonapi.org/format/#document-resource-objects).
81
- *
82
- * - `type` should be formatted in the singular, dasherized and lowercase form
83
- * - `members` (the property names of attributes and relationships) should be formatted
84
- * to match their definition in the corresponding `Model` definition. Typically this
85
- * will be `camelCase`.
86
- * - [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is
87
- * a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
88
- * and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
89
- *
90
- * This method is called by the `Store` when `store.normalize(modelName, payload)` is
91
- * called. It is recommended to use `store.serializerFor(modelName).normalizeResponse`
92
- * over `store.normalize`.
93
- *
94
- * This method may be called when also using the `RESTSerializer`
95
- * when `serializer.pushPayload` is called by `store.pushPayload`.
96
- * However, it is recommended to use `store.push` over `store.pushPayload` after normalizing
97
- * the payload directly.
98
- *
99
- * Example:
100
- * ```js
101
- * function pushPayload(store, modelName, rawPayload) {
102
- * const ModelClass = store.modelFor(modelName);
103
- * const serializer = store.serializerFor(modelName);
104
- * const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');
105
- *
106
- * return store.push(jsonApiPayload);
107
- * }
108
- * ```
109
- *
110
- * This method may be called when also using the `JSONAPISerializer`
111
- * when normalizing included records. If mixing serializer usage in this way
112
- * we recommend implementing this method, but caution that it may lead
113
- * to unexpected mixing of formats.
114
- *
115
- * This method may also be called when normalizing embedded relationships when
116
- * using the `EmbeddedRecordsMixin`. If using this mixin in a serializer in
117
- * your application we recommend implementing this method, but caution that
118
- * it may lead to unexpected mixing of formats.
119
- *
120
- * @public
121
- * @optional
122
- * @param {ModelSchema} schema An object with methods for accessing information about
123
- * the type, attributes and relationships of the primary type associated with the request.
124
- * @param {JSONObject} rawPayload Some raw JSON data to be normalized into a JSON:API Resource.
125
- * @param {String} [prop] When called by the EmbeddedRecordsMixin this param will be the
126
- * property at which the object provided as rawPayload was found.
127
- * @return {SingleResourceDocument} A JSON:API Document
128
- * containing a single JSON:API Resource
129
- * as its primary data.
130
- */
131
- normalize?(schema: ModelSchema, rawPayload: ObjectValue, prop?: string): SingleResourceDocument;
132
- /**
133
- * When using `JSONAPIAdapter` or `RESTAdapter` this method is called
134
- * by `adapter.updateRecord` and `adapter.createRecord` if `serializer.serializeIntoHash`
135
- * is implemented. If this method is not implemented, `serializer.serialize`
136
- * will be called in this case.
137
- *
138
- * You can use this method to customize the root keys serialized into the payload.
139
- * The hash property should be modified by reference.
140
- *
141
- * For instance, your API may expect resources to be keyed by underscored type in the payload:
142
- *
143
- * ```js
144
- * {
145
- * _user: {
146
- * type: 'user',
147
- * id: '1'
148
- * }
149
- * }
150
- * ```
151
- *
152
- * Which when using these adapters can be achieved by implementing this method similar
153
- * to the following:
154
- *
155
- * ```js
156
- * serializeIntoHash(hash, ModelClass, snapshot, options) {
157
- * hash[`_${snapshot.modelName}`] = this.serialize(snapshot, options).data;
158
- * }
159
- * ```
160
- *
161
- * @public
162
- * @optional
163
- * @param hash A top most object of the request payload onto
164
- * which to append the serialized record
165
- * @param {ModelSchema} schema An object with methods for accessing information about
166
- * the type, attributes and relationships of the primary type associated with the request.
167
- * @param {Snapshot} snapshot A Snapshot for the record to serialize
168
- * @param [options]
169
- * @return {void}
170
- */
171
- serializeIntoHash?(hash: object, schema: ModelSchema, snapshot: Snapshot, options?: SerializerOptions): void;
172
- /**
173
- * This method allows for normalization of data when `store.pushPayload` is called
174
- * and should be implemented if you want to use that method.
175
- *
176
- * The method is responsible for pushing new data to the store using `store.push`
177
- * once any necessary normalization has occurred, and no data in the store will be
178
- * updated unless it does so.
179
- *
180
- * The normalized form pushed to the store should be a [JSON:API Document](https://jsonapi.org/format/#document-structure)
181
- * with the following additional restrictions:
182
- *
183
- * - `type` should be formatted in the singular, dasherized and lowercase form
184
- * - `members` (the property names of attributes and relationships) should be formatted
185
- * to match their definition in the corresponding `Model` definition. Typically this
186
- * will be `camelCase`.
187
- * - [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is
188
- * a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
189
- * and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
190
- *
191
- * If you need better control over normalization or want access to the records being added or updated
192
- * in the store, we recommended using `store.push` over `store.pushPayload` after normalizing
193
- * the payload directly. This can even take advantage of an existing serializer for the format
194
- * the data is in, for example:
195
- *
196
- * ```js
197
- * function pushPayload(store, modelName, rawPayload) {
198
- * const ModelClass = store.modelFor(modelName);
199
- * const serializer = store.serializerFor(modelName);
200
- * const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');
201
- *
202
- * return store.push(jsonApiPayload);
203
- * }
204
- * ```
205
- *
206
- * @public
207
- * @optional
208
- * @param {Store} store The store service that initiated the request being normalized
209
- * @param {Object} rawPayload The raw JSON response data returned from an API request.
210
- * This JSON should be in the API format expected by the serializer.
211
- * @return {void}
212
- */
213
- pushPayload?(store: Store, rawPayload: ObjectValue): void;
214
- /**
215
- * In some situations the serializer may need to perform cleanup when destroyed,
216
- * that cleanup can be done in `destroy`.
217
- *
218
- * If not implemented, the store does not inform the serializer of destruction.
219
- *
220
- * @public
221
- * @optional
222
- */
223
- destroy?(): void;
224
- }
225
- }
226
- //# sourceMappingURL=minimum-serializer-interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"minimum-serializer-interface.d.ts","sourceRoot":"","sources":["../../src/legacy-network-handler/minimum-serializer-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAExG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AACxD,MAAM,MAAM,WAAW,GACnB,YAAY,GACZ,aAAa,GACb,SAAS,GACT,eAAe,GACf,aAAa,GACb,UAAU,GACV,OAAO,GACP,cAAc,GACd,cAAc,GACd,cAAc,CAAC;AAEnB;;;;;;;;;;;;;;;;;EAiBE;AACF,MAAM,WAAW,0BAA0B;IACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,iBAAiB,CACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,cAAc,EAC1B,EAAE,EAAE,MAAM,GAAG,IAAI,EACjB,WAAW,EACP,YAAY,GACZ,aAAa,GACb,SAAS,GACT,eAAe,GACf,aAAa,GACb,UAAU,GACV,OAAO,GACP,cAAc,GACd,cAAc,GACd,cAAc,GACjB,eAAe,CAAC;IAEnB;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAAC;IAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;IAEhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAE1D;;;;;;;;OAQG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB"}
@@ -1,9 +0,0 @@
1
- declare module '@ember-data/legacy-compat/legacy-network-handler/serializer-response' {
2
- import type Store from '@ember-data/store';
3
- import type { ModelSchema } from '@ember-data/store/types';
4
- import type { JsonApiDocument } from '@warp-drive/core-types/spec/json-api-raw';
5
- import type { AdapterPayload } from '@ember-data/legacy-compat/legacy-network-handler/minimum-adapter-interface';
6
- import type { MinimumSerializerInterface, RequestType } from '@ember-data/legacy-compat/legacy-network-handler/minimum-serializer-interface';
7
- export function normalizeResponseHelper(serializer: MinimumSerializerInterface | null, store: Store, modelClass: ModelSchema, payload: AdapterPayload, id: string | null, requestType: RequestType): JsonApiDocument;
8
- }
9
- //# sourceMappingURL=serializer-response.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializer-response.d.ts","sourceRoot":"","sources":["../../src/legacy-network-handler/serializer-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AA8D9F,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,0BAA0B,GAAG,IAAI,EAC7C,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,WAAW,EACvB,OAAO,EAAE,cAAc,EACvB,EAAE,EAAE,MAAM,GAAG,IAAI,EACjB,WAAW,EAAE,WAAW,GACvB,eAAe,CAQjB"}
@@ -1,91 +0,0 @@
1
- declare module '@ember-data/legacy-compat/legacy-network-handler/snapshot-record-array' {
2
- import type Store from '@ember-data/store';
3
- import type { LiveArray } from '@ember-data/store/-private';
4
- import type { FindAllOptions, ModelSchema } from '@ember-data/store/types';
5
- import type { Snapshot } from '@ember-data/legacy-compat/legacy-network-handler/snapshot';
6
- /**
7
- SnapshotRecordArray is not directly instantiable.
8
- Instances are provided to consuming application's
9
- adapters for certain `findAll` requests.
10
-
11
- @class SnapshotRecordArray
12
- @public
13
- */
14
- export class SnapshotRecordArray {
15
- _snapshots: Snapshot[] | null;
16
- _type: ModelSchema | null;
17
- modelName: string;
18
- __store: Store;
19
- adapterOptions?: Record<string, unknown>;
20
- include?: string | string[];
21
- /**
22
- SnapshotRecordArray is not directly instantiable.
23
- Instances are provided to consuming application's
24
- adapters and serializers for certain requests.
25
-
26
- @private
27
- @constructor
28
- @param {Store} store
29
- @param {String} type
30
- @param options
31
- */
32
- constructor(store: Store, type: string, options?: FindAllOptions);
33
- /**
34
- An array of records
35
-
36
- @property _recordArray
37
- @private
38
- @type {Array}
39
- */
40
- get _recordArray(): LiveArray;
41
- /**
42
- Number of records in the array
43
-
44
- Example
45
-
46
- ```js [app/adapters/post.js]
47
- import JSONAPIAdapter from '@ember-data/adapter/json-api';
48
-
49
- export default class PostAdapter extends JSONAPIAdapter {
50
- shouldReloadAll(store, snapshotRecordArray) {
51
- return !snapshotRecordArray.length;
52
- }
53
- });
54
- ```
55
-
56
- @property length
57
- @public
58
- @type {Number}
59
- */
60
- get length(): number;
61
- /**
62
- Get snapshots of the underlying record array
63
-
64
- Example
65
-
66
- ```js [app/adapters/post.js]
67
- import JSONAPIAdapter from '@ember-data/adapter/json-api';
68
-
69
- export default class PostAdapter extends JSONAPIAdapter {
70
- shouldReloadAll(store, snapshotArray) {
71
- let snapshots = snapshotArray.snapshots();
72
-
73
- return snapshots.any(function(ticketSnapshot) {
74
- let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');
75
- if (timeDiff > 20) {
76
- return true;
77
- } else {
78
- return false;
79
- }
80
- });
81
- }
82
- }
83
- ```
84
-
85
- @public
86
- @return {Array} Array of snapshots
87
- */
88
- snapshots(): Snapshot<unknown>[];
89
- }
90
- }
91
- //# sourceMappingURL=snapshot-record-array.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot-record-array.d.ts","sourceRoot":"","sources":["../../src/legacy-network-handler/snapshot-record-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C;;;;;;;EAOE;AACF,qBAAa,mBAAmB;IACtB,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,KAAK,CAAC;IAEf,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEpC;;;;;;;;;;OAUG;gBACS,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAkEpE;;;;;;MAME;IACF,IAAI,YAAY,IAAI,SAAS,CAE5B;IAED;;;;;;;;;;;;;;;;;;QAkBI;IACJ,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BE;IACF,SAAS;CAaV"}
@@ -1,239 +0,0 @@
1
- declare module '@ember-data/legacy-compat/legacy-network-handler/snapshot' {
2
- import type Store from '@ember-data/store';
3
- import type { FindRecordOptions } from '@ember-data/store/types';
4
- import type { StableRecordIdentifier } from '@warp-drive/core-types';
5
- import type { ChangedAttributesHash } from '@warp-drive/core-types/cache';
6
- import type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';
7
- import type { LegacyAttributeField, LegacyRelationshipField } from '@warp-drive/core-types/schema/fields';
8
- import type { SerializerOptions } from '@ember-data/legacy-compat/legacy-network-handler/minimum-serializer-interface';
9
- type RecordId = string | null;
10
- /**
11
- Snapshot is not directly instantiable.
12
- Instances are provided to a consuming application's
13
- adapters and serializers for certain requests.
14
-
15
- Snapshots are only available when using `@ember-data/legacy-compat`
16
- for legacy compatibility with adapters and serializers.
17
-
18
- @class Snapshot
19
- @public
20
- */
21
- export class Snapshot<R = unknown> {
22
- __attributes: Record<keyof R & string, unknown> | null;
23
- _belongsToRelationships: Record<string, Snapshot>;
24
- _belongsToIds: Record<string, RecordId>;
25
- _hasManyRelationships: Record<string, Snapshot[]>;
26
- _hasManyIds: Record<string, RecordId[]>;
27
- _changedAttributes: ChangedAttributesHash;
28
- identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
29
- modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;
30
- id: string | null;
31
- include?: string | string[];
32
- adapterOptions?: Record<string, unknown>;
33
- _store: Store;
34
- /**
35
- * @constructor
36
- * @private
37
- * @param options
38
- * @param identifier
39
- * @param _store
40
- */
41
- constructor(options: FindRecordOptions, identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
42
- /**
43
- The underlying record for this snapshot. Can be used to access methods and
44
- properties defined on the record.
45
-
46
- Example
47
-
48
- ```javascript
49
- let json = snapshot.record.toJSON();
50
- ```
51
-
52
- @property record
53
- @type {Model}
54
- @public
55
- */
56
- get record(): R | null;
57
- get _attributes(): Record<keyof R & string, unknown>;
58
- get isNew(): boolean;
59
- /**
60
- Returns the value of an attribute.
61
-
62
- Example
63
-
64
- ```javascript
65
- // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
66
- postSnapshot.attr('author'); // => 'Tomster'
67
- postSnapshot.attr('title'); // => 'Ember.js rocks'
68
- ```
69
-
70
- Note: Values are loaded eagerly and cached when the snapshot is created.
71
-
72
- @param {String} keyName
73
- @return {Object} The attribute value or undefined
74
- @public
75
- */
76
- attr(keyName: keyof R & string): unknown;
77
- /**
78
- Returns all attributes and their corresponding values.
79
-
80
- Example
81
-
82
- ```javascript
83
- // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
84
- postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
85
- ```
86
-
87
- @return {Object} All attributes of the current snapshot
88
- @public
89
- */
90
- attributes(): Record<keyof R & string, unknown>;
91
- /**
92
- Returns all changed attributes and their old and new values.
93
-
94
- Example
95
-
96
- ```javascript
97
- // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
98
- postModel.set('title', 'Ember.js rocks!');
99
- postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
100
- ```
101
-
102
- @return {Object} All changed attributes of the current snapshot
103
- @public
104
- */
105
- changedAttributes(): ChangedAttributesHash;
106
- /**
107
- Returns the current value of a belongsTo relationship.
108
-
109
- `belongsTo` takes an optional hash of options as a second parameter,
110
- currently supported options are:
111
-
112
- - `id`: set to `true` if you only want the ID of the related record to be
113
- returned.
114
-
115
- Example
116
-
117
- ```javascript
118
- // store.push('post', { id: 1, title: 'Hello World' });
119
- // store.createRecord('comment', { body: 'Lorem ipsum', post: post });
120
- commentSnapshot.belongsTo('post'); // => Snapshot
121
- commentSnapshot.belongsTo('post', { id: true }); // => '1'
122
-
123
- // store.push('comment', { id: 1, body: 'Lorem ipsum' });
124
- commentSnapshot.belongsTo('post'); // => undefined
125
- ```
126
-
127
- Calling `belongsTo` will return a new Snapshot as long as there's any known
128
- data for the relationship available, such as an ID. If the relationship is
129
- known but unset, `belongsTo` will return `null`. If the contents of the
130
- relationship is unknown `belongsTo` will return `undefined`.
131
-
132
- Note: Relationships are loaded lazily and cached upon first access.
133
-
134
- @param {String} keyName
135
- @param {Object} [options]
136
- @public
137
- @return {(Snapshot|String|null|undefined)} A snapshot or ID of a known
138
- relationship or null if the relationship is known but unset. undefined
139
- will be returned if the contents of the relationship is unknown.
140
- */
141
- belongsTo(keyName: string, options?: {
142
- id?: boolean;
143
- }): Snapshot | RecordId | undefined;
144
- /**
145
- Returns the current value of a hasMany relationship.
146
-
147
- `hasMany` takes an optional hash of options as a second parameter,
148
- currently supported options are:
149
-
150
- - `ids`: set to `true` if you only want the IDs of the related records to be
151
- returned.
152
-
153
- Example
154
-
155
- ```javascript
156
- // store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });
157
- postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]
158
- postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']
159
-
160
- // store.push('post', { id: 1, title: 'Hello World' });
161
- postSnapshot.hasMany('comments'); // => undefined
162
- ```
163
-
164
- Note: Relationships are loaded lazily and cached upon first access.
165
-
166
- @param {String} keyName
167
- @param {Object} [options]
168
- @public
169
- @return {(Array|undefined)} An array of snapshots or IDs of a known
170
- relationship or an empty array if the relationship is known but unset.
171
- undefined will be returned if the contents of the relationship is unknown.
172
- */
173
- hasMany(keyName: string, options?: {
174
- ids?: boolean;
175
- }): RecordId[] | Snapshot[] | undefined;
176
- /**
177
- Iterates through all the attributes of the model, calling the passed
178
- function on each attribute.
179
-
180
- Example
181
-
182
- ```javascript
183
- snapshot.eachAttribute(function(name, meta) {
184
- // ...
185
- });
186
- ```
187
-
188
- @param {Function} callback the callback to execute
189
- @param {Object} [binding] the value to which the callback's `this` should be bound
190
- @public
191
- */
192
- eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void;
193
- /**
194
- Iterates through all the relationships of the model, calling the passed
195
- function on each relationship.
196
-
197
- Example
198
-
199
- ```javascript
200
- snapshot.eachRelationship(function(name, relationship) {
201
- // ...
202
- });
203
- ```
204
-
205
- @param {Function} callback the callback to execute
206
- @param {Object} [binding] the value to which the callback's `this` should be bound
207
- @public
208
- */
209
- eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void;
210
- /**
211
- Serializes the snapshot using the serializer for the model.
212
-
213
- Example
214
-
215
- ```js [app/adapters/application.js]
216
- import Adapter from '@ember-data/adapter';
217
-
218
- export default Adapter.extend({
219
- createRecord(store, type, snapshot) {
220
- let data = snapshot.serialize({ includeId: true });
221
- let url = `/${type.modelName}`;
222
-
223
- return fetch(url, {
224
- method: 'POST',
225
- body: data,
226
- }).then((response) => response.json())
227
- }
228
- });
229
- ```
230
-
231
- @param {Object} options
232
- @return {Object} an object whose values are primitive JSON values only
233
- @public
234
- */
235
- serialize(options?: SerializerOptions): unknown;
236
- }
237
- export {};
238
- }
239
- //# sourceMappingURL=snapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/legacy-network-handler/snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAG1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAG1G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,KAAK,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;AAE9B;;;;;;;;;;EAUE;AACF,qBAAa,QAAQ,CAAC,CAAC,GAAG,OAAO;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACvD,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACxC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxC,kBAAkB,EAAE,qBAAqB,CAAC;IAE1C,UAAU,EAAE,sBAAsB,CAAC,CAAC,SAAS,mBAAmB,GAAG,g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