1 | import EmberError from "@ember/error";
|
2 | import Evented from "@ember/object/evented";
|
3 | import PromiseProxyMixin from "@ember/object/promise-proxy-mixin";
|
4 | import ObjectProxy from "@ember/object/proxy";
|
5 | import Ember from "ember";
|
6 | import AdapterRegistry from "ember-data/types/registries/adapter";
|
7 | import ModelRegistry from "ember-data/types/registries/model";
|
8 | import SerializerRegistry from "ember-data/types/registries/serializer";
|
9 | import TransformRegistry from "ember-data/types/registries/transform";
|
10 | import RSVP from "rsvp";
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | type ModelKeys<Model extends DS.Model> = Exclude<keyof Model, keyof DS.Model>;
|
17 |
|
18 | type AttributesFor<Model extends DS.Model> = ModelKeys<Model>;
|
19 | type RelationshipsFor<Model extends DS.Model> = ModelKeys<Model>;
|
20 |
|
21 | export interface ChangedAttributes {
|
22 | [key: string]: [any, any] | undefined;
|
23 | }
|
24 | interface AttributeMeta<Model extends DS.Model> {
|
25 | type: keyof TransformRegistry;
|
26 | options: object;
|
27 | name: AttributesFor<Model>;
|
28 | parentType: Model;
|
29 | isAttribute: true;
|
30 | }
|
31 |
|
32 | interface RelationshipMetaOptions {
|
33 | async?: boolean | undefined;
|
34 | inverse?: string | undefined;
|
35 | polymorphic?: boolean | undefined;
|
36 | [k: string]: any;
|
37 | }
|
38 | interface RelationshipMeta<Model extends DS.Model> {
|
39 | key: RelationshipsFor<Model>;
|
40 | kind: "belongsTo" | "hasMany";
|
41 | type: keyof ModelRegistry;
|
42 | options: RelationshipMetaOptions;
|
43 | name: string;
|
44 | parentType: Model;
|
45 | isRelationship: true;
|
46 | }
|
47 |
|
48 | export interface ModelSchema<ModelName extends keyof ModelRegistry = keyof ModelRegistry> {
|
49 | modelName: ModelName;
|
50 | fields: Map<string, "attribute" | "belongsTo" | "hasMany">;
|
51 | attributes: Map<string, AttributeSchema>;
|
52 | relationshipsByName: Map<string, RelationshipSchema>;
|
53 | eachAttribute<T>(callback: (this: T, key: string, attribute: AttributeSchema) => void, binding?: T): void;
|
54 | eachRelationship<T>(callback: (this: T, key: string, relationship: RelationshipSchema) => void, binding?: T): void;
|
55 | eachTransformedAttribute<T>(
|
56 | callback: (this: T, key: string, relationship: RelationshipSchema) => void,
|
57 | binding?: T,
|
58 | ): void;
|
59 | }
|
60 | export interface RelationshipSchema {
|
61 | name: string; // property key for this relationship
|
62 | kind: "belongsTo" | "hasMany";
|
63 | type: string; // related type
|
64 | options: {
|
65 | async: boolean;
|
66 | polymorphic?: boolean;
|
67 | as?: string;
|
68 | inverse: string | null; // property key on the related type (if any)
|
69 | [key: string]: unknown;
|
70 | };
|
71 | }
|
72 | export interface AttributeSchema {
|
73 | name: string;
|
74 | kind?: "attribute";
|
75 | options?: Record<string, unknown>;
|
76 | type?: string;
|
77 | }
|
78 |
|
79 | export namespace DS {
|
80 | /**
|
81 | * Convert an hash of errors into an array with errors in JSON-API format.
|
82 | */
|
83 | function errorsHashToArray(errors: {}): any[];
|
84 | /**
|
85 | * Convert an array of errors in JSON-API format into an object.
|
86 | */
|
87 | function errorsArrayToHash(errors: any[]): {};
|
88 |
|
89 | interface RelationshipOptions<M extends Model> {
|
90 | async?: boolean | undefined;
|
91 | inverse?: RelationshipsFor<M> | null | undefined;
|
92 | polymorphic?: boolean | undefined;
|
93 | as?: string;
|
94 | [key: string]: unknown;
|
95 | }
|
96 |
|
97 | interface Sync {
|
98 | async: false;
|
99 | }
|
100 | interface Async {
|
101 | async?: true | undefined;
|
102 | }
|
103 |
|
104 | type AsyncBelongsTo<T extends Model | null> = PromiseObject<T>;
|
105 | /**
|
106 | * `DS.belongsTo` is used to define One-To-One and One-To-Many
|
107 | * relationships on a [DS.Model](/api/data/classes/DS.Model.html).
|
108 | */
|
109 | function belongsTo<K extends keyof ModelRegistry>(
|
110 | modelName: K,
|
111 | options: RelationshipOptions<ModelRegistry[K]> & Sync,
|
112 | ): Ember.ComputedProperty<
|
113 | ModelRegistry[K] | null,
|
114 | ModelRegistry[K] | PromiseObject<ModelRegistry[K] | null> | null
|
115 | >;
|
116 | function belongsTo<K extends keyof ModelRegistry>(
|
117 | modelName: K,
|
118 | options?: RelationshipOptions<ModelRegistry[K]> & Async,
|
119 | ): Ember.ComputedProperty<
|
120 | AsyncBelongsTo<ModelRegistry[K] | null>,
|
121 | ModelRegistry[K] | PromiseObject<ModelRegistry[K] | null> | null
|
122 | >;
|
123 | type AsyncHasMany<T extends Model> = PromiseManyArray<T>;
|
124 | type SyncHasMany<T extends Model> = ManyArray<T>;
|
125 | /**
|
126 | * `DS.hasMany` is used to define One-To-Many and Many-To-Many
|
127 | * relationships on a [DS.Model](/api/data/classes/DS.Model.html).
|
128 | */
|
129 | function hasMany<K extends keyof ModelRegistry>(
|
130 | type: K,
|
131 | options: RelationshipOptions<ModelRegistry[K]> & Sync,
|
132 | ): Ember.ComputedProperty<SyncHasMany<ModelRegistry[K]>>;
|
133 | function hasMany<K extends keyof ModelRegistry>(
|
134 | type: K,
|
135 | options?: RelationshipOptions<ModelRegistry[K]> & Async,
|
136 | ): Ember.ComputedProperty<AsyncHasMany<ModelRegistry[K]>, Ember.Array<ModelRegistry[K]>>;
|
137 | /**
|
138 | * This method normalizes a modelName into the format Ember Data uses
|
139 | * internally.
|
140 | */
|
141 | function normalizeModelName<K extends keyof ModelRegistry>(modelName: K): string;
|
142 | const VERSION: string;
|
143 |
|
144 | interface AttrOptions<T> {
|
145 | defaultValue?: T extends Exclude<object, null> ? () => T : T | (() => T) | null | undefined;
|
146 | allowNull?: boolean | undefined; // TODO: restrict to boolean transform (TS 2.8)
|
147 | [key: string]: unknown;
|
148 | }
|
149 |
|
150 | // The TransformRegistry should really only contain transforms, but historically people have just put the return type directly in.
|
151 | type TransformType<K extends keyof TransformRegistry> = TransformRegistry[K] extends Transform
|
152 | ? ReturnType<TransformRegistry[K]["deserialize"]>
|
153 | : TransformRegistry[K];
|
154 |
|
155 | /**
|
156 | * `DS.attr` defines an attribute on a [DS.Model](/api/data/classes/DS.Model.html).
|
157 | * By default, attributes are passed through as-is, however you can specify an
|
158 | * optional type to have the value automatically transformed.
|
159 | * Ember Data ships with four basic transform types: `string`, `number`,
|
160 | * `boolean` and `date`. You can define your own transforms by subclassing
|
161 | * [DS.Transform](/api/data/classes/DS.Transform.html).
|
162 | */
|
163 | function attr<K extends keyof TransformRegistry>(
|
164 | type: K,
|
165 | options?: AttrOptions<TransformType<K>>,
|
166 | ): Ember.ComputedProperty<TransformType<K>>;
|
167 | function attr(options?: AttrOptions<any>): Ember.ComputedProperty<any>;
|
168 | function attr(target: any, propertyKey: string): void;
|
169 |
|
170 | /**
|
171 | * WARNING: This interface is likely to change in order to accomodate https://github.com/emberjs/rfcs/pull/4
|
172 | * ## Using BuildURLMixin
|
173 | * To use url building, include the mixin when extending an adapter, and call `buildURL` where needed.
|
174 | * The default behaviour is designed for RESTAdapter.
|
175 | * ### Example
|
176 | * ```javascript
|
177 | * export default DS.Adapter.extend(BuildURLMixin, {
|
178 | * findRecord: function(store, type, id, snapshot) {
|
179 | * var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
|
180 | * return this.ajax(url, 'GET');
|
181 | * }
|
182 | * });
|
183 | * ```
|
184 | * ### Attributes
|
185 | * The `host` and `namespace` attributes will be used if defined, and are optional.
|
186 | */
|
187 | class BuildURLMixin {
|
188 | /**
|
189 | * Builds a URL for a given type and optional ID.
|
190 | */
|
191 | buildURL<K extends keyof ModelRegistry>(
|
192 | modelName?: K,
|
193 | id?: string | any[] | {} | null,
|
194 | snapshot?: Snapshot<K> | any[] | null,
|
195 | requestType?: string,
|
196 | query?: {},
|
197 | ): string;
|
198 | /**
|
199 | * Used by `findAll` and `findRecord` to build the query's `data` hash supplied to the ajax method.
|
200 | */
|
201 | buildQuery<K extends keyof ModelRegistry>(snapshot: Snapshot<K>): Record<string, unknown>;
|
202 | /**
|
203 | * Builds a URL for a `store.findRecord(type, id)` call.
|
204 | */
|
205 | urlForFindRecord<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
206 | /**
|
207 | * Builds a URL for a `store.findAll(type)` call.
|
208 | */
|
209 | urlForFindAll<K extends keyof ModelRegistry>(modelName: K, snapshot: SnapshotRecordArray<K>): string;
|
210 | /**
|
211 | * Builds a URL for a `store.query(type, query)` call.
|
212 | */
|
213 | urlForQuery<K extends keyof ModelRegistry>(query: {}, modelName: K): string;
|
214 | /**
|
215 | * Builds a URL for a `store.queryRecord(type, query)` call.
|
216 | */
|
217 | urlForQueryRecord<K extends keyof ModelRegistry>(query: {}, modelName: K): string;
|
218 | /**
|
219 | * Builds a URL for coalesceing multiple `store.findRecord(type, id)`
|
220 | * records into 1 request when the adapter's `coalesceFindRequests`
|
221 | * property is true.
|
222 | */
|
223 | urlForFindMany<K extends keyof ModelRegistry>(ids: any[], modelName: K, snapshots: any[]): string;
|
224 | /**
|
225 | * Builds a URL for fetching a async hasMany relationship when a url
|
226 | * is not provided by the server.
|
227 | */
|
228 | urlForFindHasMany<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
229 | /**
|
230 | * Builds a URL for fetching a async belongsTo relationship when a url
|
231 | * is not provided by the server.
|
232 | */
|
233 | urlForFindBelongsTo<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
234 | /**
|
235 | * Builds a URL for a `record.save()` call when the record was created
|
236 | * locally using `store.createRecord()`.
|
237 | */
|
238 | urlForCreateRecord<K extends keyof ModelRegistry>(modelName: K, snapshot: Snapshot<K>): string;
|
239 | /**
|
240 | * Builds a URL for a `record.save()` call when the record has been update locally.
|
241 | */
|
242 | urlForUpdateRecord<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
243 | /**
|
244 | * Builds a URL for a `record.save()` call when the record has been deleted locally.
|
245 | */
|
246 | urlForDeleteRecord<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
247 | /**
|
248 | * Determines the pathname for a given type.
|
249 | */
|
250 | pathForType<K extends keyof ModelRegistry>(modelName: K): string;
|
251 | }
|
252 | /**
|
253 | * A `DS.AdapterError` is used by an adapter to signal that an error occurred
|
254 | * during a request to an external API. It indicates a generic error, and
|
255 | * subclasses are used to indicate specific error states. The following
|
256 | * subclasses are provided:
|
257 | */
|
258 | class AdapterError extends EmberError {
|
259 | static extend(options?: { message?: string }): typeof AdapterError;
|
260 | }
|
261 | /**
|
262 | * A `DS.InvalidError` is used by an adapter to signal the external API
|
263 | * was unable to process a request because the content was not
|
264 | * semantically correct or meaningful per the API. Usually this means a
|
265 | * record failed some form of server side validation. When a promise
|
266 | * from an adapter is rejected with a `DS.InvalidError` the record will
|
267 | * transition to the `invalid` state and the errors will be set to the
|
268 | * `errors` property on the record.
|
269 | */
|
270 | class InvalidError extends AdapterError {
|
271 | constructor(errors: any[]);
|
272 | }
|
273 | /**
|
274 | * A `DS.TimeoutError` is used by an adapter to signal that a request
|
275 | * to the external API has timed out. I.e. no response was received from
|
276 | * the external API within an allowed time period.
|
277 | */
|
278 | class TimeoutError extends AdapterError {}
|
279 | /**
|
280 | * A `DS.AbortError` is used by an adapter to signal that a request to
|
281 | * the external API was aborted. For example, this can occur if the user
|
282 | * navigates away from the current page after a request to the external API
|
283 | * has been initiated but before a response has been received.
|
284 | */
|
285 | class AbortError extends AdapterError {}
|
286 | /**
|
287 | * A `DS.UnauthorizedError` equates to a HTTP `401 Unauthorized` response
|
288 | * status. It is used by an adapter to signal that a request to the external
|
289 | * API was rejected because authorization is required and has failed or has not
|
290 | * yet been provided.
|
291 | */
|
292 | class UnauthorizedError extends AdapterError {}
|
293 | /**
|
294 | * A `DS.ForbiddenError` equates to a HTTP `403 Forbidden` response status.
|
295 | * It is used by an adapter to signal that a request to the external API was
|
296 | * valid but the server is refusing to respond to it. If authorization was
|
297 | * provided and is valid, then the authenticated user does not have the
|
298 | * necessary permissions for the request.
|
299 | */
|
300 | class ForbiddenError extends AdapterError {}
|
301 | /**
|
302 | * A `DS.NotFoundError` equates to a HTTP `404 Not Found` response status.
|
303 | * It is used by an adapter to signal that a request to the external API
|
304 | * was rejected because the resource could not be found on the API.
|
305 | */
|
306 | class NotFoundError extends AdapterError {}
|
307 | /**
|
308 | * A `DS.ConflictError` equates to a HTTP `409 Conflict` response status.
|
309 | * It is used by an adapter to indicate that the request could not be processed
|
310 | * because of a conflict in the request. An example scenario would be when
|
311 | * creating a record with a client generated id but that id is already known
|
312 | * to the external API.
|
313 | */
|
314 | class ConflictError extends AdapterError {}
|
315 | /**
|
316 | * A `DS.ServerError` equates to a HTTP `500 Internal Server Error` response
|
317 | * status. It is used by the adapter to indicate that a request has failed
|
318 | * because of an error in the external API.
|
319 | */
|
320 | class ServerError extends AdapterError {}
|
321 | /**
|
322 | * Holds validation errors for a given record, organized by attribute names.
|
323 | */
|
324 | interface Errors extends Ember.Enumerable<any>, Evented {}
|
325 | class Errors extends Ember.ArrayProxy<any> {
|
326 | /**
|
327 | * DEPRECATED:
|
328 | * Register with target handler
|
329 | */
|
330 | registerHandlers(target: {}, becameInvalid: Function, becameValid: Function): any;
|
331 | /**
|
332 | * Returns errors for a given attribute
|
333 | */
|
334 | errorsFor(attribute: string): any[];
|
335 | /**
|
336 | * An array containing all of the error messages for this
|
337 | * record. This is useful for displaying all errors to the user.
|
338 | */
|
339 | messages: Ember.ComputedProperty<any[]>;
|
340 | /**
|
341 | * Total number of errors.
|
342 | */
|
343 | length: Ember.ComputedProperty<number>;
|
344 | isEmpty: Ember.ComputedProperty<boolean>;
|
345 | /**
|
346 | * DEPRECATED:
|
347 | * Adds error messages to a given attribute and sends
|
348 | * `becameInvalid` event to the record.
|
349 | */
|
350 | add(attribute: string, messages: any[] | string): any;
|
351 | /**
|
352 | * DEPRECATED:
|
353 | * Removes all error messages from the given attribute and sends
|
354 | * `becameValid` event to the record if there no more errors left.
|
355 | */
|
356 | remove(attribute: string): any;
|
357 | /**
|
358 | * DEPRECATED:
|
359 | * Removes all error messages and sends `becameValid` event
|
360 | * to the record.
|
361 | */
|
362 | clear(): any;
|
363 | /**
|
364 | * Checks if there is error messages for the given attribute.
|
365 | */
|
366 | has(attribute: string): boolean;
|
367 | }
|
368 | /**
|
369 | * The model class that all Ember Data records descend from.
|
370 | * This is the public API of Ember Data models. If you are using Ember Data
|
371 | * in your application, this is the class you should use.
|
372 | * If you are working on Ember Data internals, you most likely want to be dealing
|
373 | * with `InternalModel`
|
374 | */
|
375 | class Model extends Ember.Object {
|
376 | /**
|
377 | * If this property is `true` the record is in the `empty`
|
378 | * state. Empty is the first state all records enter after they have
|
379 | * been created. Most records created by the store will quickly
|
380 | * transition to the `loading` state if data needs to be fetched from
|
381 | * the server or the `created` state if the record is created on the
|
382 | * client. A record can also enter the empty state if the adapter is
|
383 | * unable to locate the record.
|
384 | */
|
385 | isEmpty: Ember.ComputedProperty<boolean>;
|
386 | /**
|
387 | * If this property is `true` the record is in the `loading` state. A
|
388 | * record enters this state when the store asks the adapter for its
|
389 | * data. It remains in this state until the adapter provides the
|
390 | * requested data.
|
391 | */
|
392 | isLoading: Ember.ComputedProperty<boolean>;
|
393 | /**
|
394 | * If this property is `true` the record is in the `loaded` state. A
|
395 | * record enters this state when its data is populated. Most of a
|
396 | * record's lifecycle is spent inside substates of the `loaded`
|
397 | * state.
|
398 | */
|
399 | isLoaded: Ember.ComputedProperty<boolean>;
|
400 | /**
|
401 | * If this property is `true` the record is in the `dirty` state. The
|
402 | * record has local changes that have not yet been saved by the
|
403 | * adapter. This includes records that have been created (but not yet
|
404 | * saved) or deleted.
|
405 | */
|
406 | hasDirtyAttributes: Ember.ComputedProperty<boolean>;
|
407 | /**
|
408 | * If this property is `true` the record is in the `saving` state. A
|
409 | * record enters the saving state when `save` is called, but the
|
410 | * adapter has not yet acknowledged that the changes have been
|
411 | * persisted to the backend.
|
412 | */
|
413 | isSaving: Ember.ComputedProperty<boolean>;
|
414 | /**
|
415 | * If this property is `true` the record is in the `deleted` state
|
416 | * and has been marked for deletion. When `isDeleted` is true and
|
417 | * `hasDirtyAttributes` is true, the record is deleted locally but the deletion
|
418 | * was not yet persisted. When `isSaving` is true, the change is
|
419 | * in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the
|
420 | * change has persisted.
|
421 | */
|
422 | isDeleted: Ember.ComputedProperty<boolean>;
|
423 | /**
|
424 | * If this property is `true` the record is in the `new` state. A
|
425 | * record will be in the `new` state when it has been created on the
|
426 | * client and the adapter has not yet report that it was successfully
|
427 | * saved.
|
428 | */
|
429 | isNew: Ember.ComputedProperty<boolean>;
|
430 | /**
|
431 | * If this property is `true` the record is in the `valid` state.
|
432 | */
|
433 | isValid: Ember.ComputedProperty<boolean>;
|
434 | /**
|
435 | * If the record is in the dirty state this property will report what
|
436 | * kind of change has caused it to move into the dirty
|
437 | * state. Possible values are:
|
438 | */
|
439 | dirtyType: Ember.ComputedProperty<string>;
|
440 | /**
|
441 | * If `true` the adapter reported that it was unable to save local
|
442 | * changes to the backend for any reason other than a server-side
|
443 | * validation error.
|
444 | */
|
445 | isError: boolean;
|
446 | /**
|
447 | * If `true` the store is attempting to reload the record from the adapter.
|
448 | */
|
449 | isReloading: boolean;
|
450 | /**
|
451 | * All ember models have an id property. This is an identifier
|
452 | * managed by an external source. These are always coerced to be
|
453 | * strings before being used internally. Note when declaring the
|
454 | * attributes for a model it is an error to declare an id
|
455 | * attribute.
|
456 | */
|
457 | id: string;
|
458 | /**
|
459 | * A reference to DS.Store service instance.
|
460 | */
|
461 | store: Store;
|
462 | /**
|
463 | * When the record is in the `invalid` state this object will contain
|
464 | * any errors returned by the adapter. When present the errors hash
|
465 | * contains keys corresponding to the invalid property names
|
466 | * and values which are arrays of Javascript objects with two keys:
|
467 | */
|
468 | errors: Errors;
|
469 | /**
|
470 | * This property holds the `DS.AdapterError` object with which
|
471 | * last adapter operation was rejected.
|
472 | */
|
473 | adapterError: AdapterError;
|
474 | /**
|
475 | * Create a JSON representation of the record, using the serialization
|
476 | * strategy of the store's adapter.
|
477 | */
|
478 | serialize(options?: { includeId?: boolean | undefined }): object;
|
479 | /**
|
480 | * Use [DS.JSONSerializer](DS.JSONSerializer.html) to
|
481 | * get the JSON representation of a record.
|
482 | */
|
483 | toJSON(options?: { includeId?: boolean | undefined }): object;
|
484 | /**
|
485 | * Fired when the record is ready to be interacted with,
|
486 | * that is either loaded from the server or created locally.
|
487 | */
|
488 | ready(): void;
|
489 | /**
|
490 | * Fired when the record is loaded from the server.
|
491 | */
|
492 | didLoad(): void;
|
493 | /**
|
494 | * Fired when the record is updated.
|
495 | */
|
496 | didUpdate(): void;
|
497 | /**
|
498 | * Fired when a new record is commited to the server.
|
499 | */
|
500 | didCreate(): void;
|
501 | /**
|
502 | * Fired when the record is deleted.
|
503 | */
|
504 | didDelete(): void;
|
505 | /**
|
506 | * Fired when the record becomes invalid.
|
507 | */
|
508 | becameInvalid(): void;
|
509 | /**
|
510 | * Fired when the record enters the error state.
|
511 | */
|
512 | becameError(): void;
|
513 | /**
|
514 | * Fired when the record is rolled back.
|
515 | */
|
516 | rolledBack(): void;
|
517 | /**
|
518 | * Marks the record as deleted but does not save it. You must call
|
519 | * `save` afterwards if you want to persist it. You might use this
|
520 | * method if you want to allow the user to still `rollbackAttributes()`
|
521 | * after a delete was made.
|
522 | */
|
523 | deleteRecord(): void;
|
524 | /**
|
525 | * Same as `deleteRecord`, but saves the record immediately.
|
526 | */
|
527 | destroyRecord(options?: { adapterOptions?: object | undefined }): RSVP.Promise<this>;
|
528 | /**
|
529 | * Unloads the record from the store. This will cause the record to be destroyed and freed up for garbage collection.
|
530 | */
|
531 | unloadRecord(): void;
|
532 | /**
|
533 | * Returns an object, whose keys are changed properties, and value is
|
534 | * an [oldProp, newProp] array.
|
535 | */
|
536 | changedAttributes(): ChangedAttributes;
|
537 | /**
|
538 | * If the model `hasDirtyAttributes` this function will discard any unsaved
|
539 | * changes. If the model `isNew` it will be removed from the store.
|
540 | */
|
541 | rollbackAttributes(): void;
|
542 | /**
|
543 | * Save the record and persist any changes to the record to an
|
544 | * external source via the adapter.
|
545 | */
|
546 | save(options?: { adapterOptions?: object | undefined }): RSVP.Promise<this>;
|
547 | /**
|
548 | * Reload the record from the adapter.
|
549 | */
|
550 | reload(options?: { adapterOptions?: object | undefined }): RSVP.Promise<this>;
|
551 | /**
|
552 | * Get the reference for the specified belongsTo relationship.
|
553 | */
|
554 | belongsTo(name: RelationshipsFor<this>): BelongsToReference;
|
555 | /**
|
556 | * Get the reference for the specified hasMany relationship.
|
557 | */
|
558 | hasMany(name: RelationshipsFor<this>): HasManyReference<any>;
|
559 | /**
|
560 | * Given a callback, iterates over each of the relationships in the model,
|
561 | * invoking the callback with the name of each relationship and its relationship
|
562 | * descriptor.
|
563 | */
|
564 | eachRelationship<T extends Model>(
|
565 | this: T,
|
566 | callback: (name: ModelKeys<T>, details: RelationshipMeta<T>) => void,
|
567 | binding?: any,
|
568 | ): void;
|
569 | /**
|
570 | * Represents the model's class name as a string. This can be used to look up the model's class name through
|
571 | * `DS.Store`'s modelFor method.
|
572 | */
|
573 | static modelName: keyof ModelRegistry;
|
574 | /**
|
575 | * For a given relationship name, returns the model type of the relationship.
|
576 | */
|
577 | static typeForRelationship<K extends keyof ModelRegistry>(name: K, store: Store): ModelRegistry[K];
|
578 | /**
|
579 | * Find the relationship which is the inverse of the one asked for.
|
580 | */
|
581 | static inverseFor<K extends keyof ModelRegistry>(name: K, store: Store): {};
|
582 | /**
|
583 | * The model's relationships as a map, keyed on the type of the
|
584 | * relationship. The value of each entry is an array containing a descriptor
|
585 | * for each relationship with that type, describing the name of the relationship
|
586 | * as well as the type.
|
587 | */
|
588 | static relationships: Ember.ComputedProperty<Map<string, unknown>>;
|
589 | /**
|
590 | * A hash containing lists of the model's relationships, grouped
|
591 | * by the relationship kind. For example, given a model with this
|
592 | * definition:
|
593 | */
|
594 | static relationshipNames: Ember.ComputedProperty<{}>;
|
595 | /**
|
596 | * An array of types directly related to a model. Each type will be
|
597 | * included once, regardless of the number of relationships it has with
|
598 | * the model.
|
599 | */
|
600 | static relatedTypes: Ember.ComputedProperty<Ember.NativeArray<string>>;
|
601 | /**
|
602 | * A map whose keys are the relationships of a model and whose values are
|
603 | * relationship descriptors.
|
604 | */
|
605 | static relationshipsByName: Ember.ComputedProperty<Map<string, unknown>>;
|
606 | /**
|
607 | * A map whose keys are the fields of the model and whose values are strings
|
608 | * describing the kind of the field. A model's fields are the union of all of its
|
609 | * attributes and relationships.
|
610 | */
|
611 | static fields: Ember.ComputedProperty<Map<string, unknown>>;
|
612 | /**
|
613 | * Given a callback, iterates over each of the relationships in the model,
|
614 | * invoking the callback with the name of each relationship and its relationship
|
615 | * descriptor.
|
616 | */
|
617 | static eachRelationship<M extends Model = Model>(
|
618 | callback: (name: ModelKeys<M>, details: RelationshipMeta<M>) => void,
|
619 | binding?: any,
|
620 | ): void;
|
621 | /**
|
622 | * Given a callback, iterates over each of the types related to a model,
|
623 | * invoking the callback with the related type's class. Each type will be
|
624 | * returned just once, regardless of how many different relationships it has
|
625 | * with a model.
|
626 | */
|
627 | static eachRelatedType(callback: (name: string) => void, binding?: any): void;
|
628 | /**
|
629 | * A map whose keys are the attributes of the model (properties
|
630 | * described by DS.attr) and whose values are the meta object for the
|
631 | * property.
|
632 | */
|
633 | static attributes: Ember.ComputedProperty<Map<string, unknown>>;
|
634 | /**
|
635 | * A map whose keys are the attributes of the model (properties
|
636 | * described by DS.attr) and whose values are type of transformation
|
637 | * applied to each attribute. This map does not include any
|
638 | * attributes that do not have an transformation type.
|
639 | */
|
640 | static transformedAttributes: Ember.ComputedProperty<Map<string, unknown>>;
|
641 | /**
|
642 | * Iterates through the attributes of the model, calling the passed function on each
|
643 | * attribute.
|
644 | */
|
645 | static eachAttribute<Class extends typeof Model, M extends InstanceType<Class>>(
|
646 | this: Class,
|
647 | callback: (name: ModelKeys<M>, meta: AttributeMeta<M>) => void,
|
648 | binding?: any,
|
649 | ): void;
|
650 | /**
|
651 | * Iterates through the transformedAttributes of the model, calling
|
652 | * the passed function on each attribute. Note the callback will not be
|
653 | * called for any attributes that do not have an transformation type.
|
654 | */
|
655 | static eachTransformedAttribute<Class extends typeof Model>(
|
656 | this: Class,
|
657 | callback: (name: ModelKeys<InstanceType<Class>>, type: keyof TransformRegistry) => void,
|
658 | binding?: any,
|
659 | ): void;
|
660 | }
|
661 | /**
|
662 | * ### State
|
663 | */
|
664 | class RootState {}
|
665 | /**
|
666 | * Represents an ordered list of records whose order and membership is
|
667 | * determined by the adapter. For example, a query sent to the adapter
|
668 | * may trigger a search on the server, whose results would be loaded
|
669 | * into an instance of the `AdapterPopulatedRecordArray`.
|
670 | */
|
671 | class AdapterPopulatedRecordArray<T> extends RecordArray<T> {}
|
672 | /**
|
673 | * Represents a list of records whose membership is determined by the
|
674 | * store. As records are created, loaded, or modified, the store
|
675 | * evaluates them to determine if they should be part of the record
|
676 | * array.
|
677 | */
|
678 | class FilteredRecordArray<T> extends RecordArray<T> {
|
679 | /**
|
680 | * The filterFunction is a function used to test records from the store to
|
681 | * determine if they should be part of the record array.
|
682 | */
|
683 | filterFunction(record: Model): boolean;
|
684 | }
|
685 | /**
|
686 | * A record array is an array that contains records of a certain modelName. The record
|
687 | * array materializes records as needed when they are retrieved for the first
|
688 | * time. You should not create record arrays yourself. Instead, an instance of
|
689 | * `DS.RecordArray` or its subclasses will be returned by your application's store
|
690 | * in response to queries.
|
691 | */
|
692 | interface RecordArray<T> extends Ember.ArrayProxy<T>, Evented {}
|
693 | class RecordArray<T> {
|
694 | /**
|
695 | * The flag to signal a `RecordArray` is finished loading data.
|
696 | */
|
697 | isLoaded: boolean;
|
698 | /**
|
699 | * The flag to signal a `RecordArray` is currently loading data.
|
700 | */
|
701 | isUpdating: boolean;
|
702 | /**
|
703 | * The modelClass represented by this record array.
|
704 | */
|
705 | type: Ember.ComputedProperty<Model>;
|
706 | /**
|
707 | * Used to get the latest version of all of the records in this array
|
708 | * from the adapter.
|
709 | */
|
710 | update(): PromiseArray<T>;
|
711 | /**
|
712 | * Saves all of the records in the `RecordArray`.
|
713 | */
|
714 | save(): PromiseArray<T>;
|
715 | }
|
716 | /**
|
717 | * A BelongsToReference is a low level API that allows users and
|
718 | * addon author to perform meta-operations on a belongs-to
|
719 | * relationship.
|
720 | */
|
721 | class BelongsToReference {
|
722 | /**
|
723 | * This returns a string that represents how the reference will be
|
724 | * looked up when it is loaded. If the relationship has a link it will
|
725 | * use the "link" otherwise it defaults to "id".
|
726 | */
|
727 | remoteType(): string;
|
728 | /**
|
729 | * The `id` of the record that this reference refers to. Together, the
|
730 | * `type()` and `id()` methods form a composite key for the identity
|
731 | * map. This can be used to access the id of an async relationship
|
732 | * without triggering a fetch that would normally happen if you
|
733 | * attempted to use `record.get('relationship.id')`.
|
734 | */
|
735 | id(): string;
|
736 | /**
|
737 | * The link Ember Data will use to fetch or reload this belongs-to
|
738 | * relationship.
|
739 | */
|
740 | link(): string;
|
741 | /**
|
742 | * The meta data for the belongs-to relationship.
|
743 | */
|
744 | meta(): {};
|
745 | /**
|
746 | * `push` can be used to update the data in the relationship and Ember
|
747 | * Data will treat the new data as the conanical value of this
|
748 | * relationship on the backend.
|
749 | */
|
750 | push(objectOrPromise: {} | RSVP.Promise<any>): RSVP.Promise<any>;
|
751 | /**
|
752 | * `value()` synchronously returns the current value of the belongs-to
|
753 | * relationship. Unlike `record.get('relationshipName')`, calling
|
754 | * `value()` on a reference does not trigger a fetch if the async
|
755 | * relationship is not yet loaded. If the relationship is not loaded
|
756 | * it will always return `null`.
|
757 | */
|
758 | value(): Model | null;
|
759 | /**
|
760 | * Loads a record in a belongs to relationship if it is not already
|
761 | * loaded. If the relationship is already loaded this method does not
|
762 | * trigger a new load.
|
763 | */
|
764 | load(): RSVP.Promise<any>;
|
765 | /**
|
766 | * Triggers a reload of the value in this relationship. If the
|
767 | * remoteType is `"link"` Ember Data will use the relationship link to
|
768 | * reload the relationship. Otherwise it will reload the record by its
|
769 | * id.
|
770 | */
|
771 | reload(): RSVP.Promise<any>;
|
772 | }
|
773 | /**
|
774 | * A HasManyReference is a low level API that allows users and addon
|
775 | * author to perform meta-operations on a has-many relationship.
|
776 | */
|
777 | class HasManyReference<T> {
|
778 | /**
|
779 | * This returns a string that represents how the reference will be
|
780 | * looked up when it is loaded. If the relationship has a link it will
|
781 | * use the "link" otherwise it defaults to "id".
|
782 | */
|
783 | remoteType(): string;
|
784 | /**
|
785 | * The link Ember Data will use to fetch or reload this has-many
|
786 | * relationship.
|
787 | */
|
788 | link(): string;
|
789 | /**
|
790 | * `ids()` returns an array of the record ids in this relationship.
|
791 | */
|
792 | ids(): string[];
|
793 | /**
|
794 | * The meta data for the has-many relationship.
|
795 | */
|
796 | meta(): {};
|
797 | /**
|
798 | * `push` can be used to update the data in the relationship and Ember
|
799 | * Data will treat the new data as the canonical value of this
|
800 | * relationship on the backend.
|
801 | */
|
802 | push(objectOrPromise: T[] | RSVP.Promise<T[]>): ManyArray<T>;
|
803 | /**
|
804 | * `value()` synchronously returns the current value of the has-many
|
805 | * relationship. Unlike `record.get('relationshipName')`, calling
|
806 | * `value()` on a reference does not trigger a fetch if the async
|
807 | * relationship is not yet loaded. If the relationship is not loaded
|
808 | * it will always return `null`.
|
809 | */
|
810 | value(): ManyArray<T> | null;
|
811 | /**
|
812 | * Loads the relationship if it is not already loaded. If the
|
813 | * relationship is already loaded this method does not trigger a new
|
814 | * load.
|
815 | */
|
816 | load(): RSVP.Promise<any>;
|
817 | /**
|
818 | * Reloads this has-many relationship.
|
819 | */
|
820 | reload(): RSVP.Promise<any>;
|
821 | }
|
822 | /**
|
823 | * An RecordReference is a low level API that allows users and
|
824 | * addon author to perform meta-operations on a record.
|
825 | */
|
826 | class RecordReference<T extends Model> {
|
827 | /**
|
828 | * The `id` of the record that this reference refers to.
|
829 | */
|
830 | id(): string;
|
831 | /**
|
832 | * How the reference will be looked up when it is loaded: Currently
|
833 | * this always return `identity` to signifying that a record will be
|
834 | * loaded by the `type` and `id`.
|
835 | */
|
836 | remoteType(): string;
|
837 | /**
|
838 | * This API allows you to provide a reference with new data. The
|
839 | * simplest usage of this API is similar to `store.push`: you provide a
|
840 | * normalized hash of data and the object represented by the reference
|
841 | * will update.
|
842 | */
|
843 | push(payload: RSVP.Promise<any> | {}): PromiseObject<T>;
|
844 | /**
|
845 | * If the entity referred to by the reference is already loaded, it is
|
846 | * present as `reference.value`. Otherwise the value returned by this function
|
847 | * is `null`.
|
848 | */
|
849 | value(): T | null;
|
850 | /**
|
851 | * Triggers a fetch for the backing entity based on its `remoteType`
|
852 | * (see `remoteType` definitions per reference type).
|
853 | */
|
854 | load(): PromiseObject<T>;
|
855 | /**
|
856 | * Reloads the record if it is already loaded. If the record is not
|
857 | * loaded it will load the record via `store.findRecord`
|
858 | */
|
859 | reload(): PromiseObject<T>;
|
860 | }
|
861 | /**
|
862 | * A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
863 | * relationship.
|
864 | */
|
865 | // eslint-disable-next-line @typescript-eslint/no-empty-interface -- used for declaration merge
|
866 | interface ManyArray<T> extends Ember.MutableArray<T>, Evented {}
|
867 | class ManyArray<T> extends Ember.Object {
|
868 | /**
|
869 | * The loading state of this array
|
870 | */
|
871 | isLoaded: boolean;
|
872 | /**
|
873 | * Metadata associated with the request for async hasMany relationships.
|
874 | */
|
875 | meta: {};
|
876 | /**
|
877 | * Reloads all of the records in the manyArray. If the manyArray
|
878 | * holds a relationship that was originally fetched using a links url
|
879 | * Ember Data will revisit the original links url to repopulate the
|
880 | * relationship.
|
881 | */
|
882 | reload(): PromiseArray<T>;
|
883 | /**
|
884 | * Saves all of the records in the `ManyArray`.
|
885 | */
|
886 | save(): PromiseArray<T>;
|
887 | /**
|
888 | * Create a child record within the owner
|
889 | */
|
890 | createRecord(inputProperties?: {}): T;
|
891 | }
|
892 | /**
|
893 | * A `PromiseArray` is an object that acts like both an `Ember.Array`
|
894 | * and a promise. When the promise is resolved the resulting value
|
895 | * will be set to the `PromiseArray`'s `content` property. This makes
|
896 | * it easy to create data bindings with the `PromiseArray` that will be
|
897 | * updated when the promise resolves.
|
898 | */
|
899 | interface PromiseArray<T, ArrayType extends Ember.ArrayProxy<T>["content"] = Ember.Array<T>>
|
900 | extends Ember.ArrayProxy<T>, PromiseProxyMixin<ArrayType>
|
901 | {}
|
902 | class PromiseArray<T> extends Ember.ArrayProxy<T> {}
|
903 | /**
|
904 | * A `PromiseObject` is an object that acts like both an `Ember.Object`
|
905 | * and a promise. When the promise is resolved, then the resulting value
|
906 | * will be set to the `PromiseObject`'s `content` property. This makes
|
907 | * it easy to create data bindings with the `PromiseObject` that will
|
908 | * be updated when the promise resolves.
|
909 | */
|
910 | interface PromiseObject<T extends object | null> extends PromiseProxyMixin<T> {}
|
911 | class PromiseObject<T> extends ObjectProxy<NonNullable<T>> {}
|
912 | /**
|
913 | * A PromiseManyArray is a PromiseArray that also proxies certain method calls
|
914 | * to the underlying manyArray.
|
915 | * Right now we proxy:
|
916 | */
|
917 | class PromiseManyArray<T extends Model> extends PromiseArray<T, Ember.ArrayProxy<T>> {
|
918 | /**
|
919 | * Reloads all of the records in the manyArray. If the manyArray
|
920 | * holds a relationship that was originally fetched using a links url
|
921 | * Ember Data will revisit the original links url to repopulate the
|
922 | * relationship.
|
923 | */
|
924 | reload(): PromiseManyArray<T>;
|
925 | /**
|
926 | * Create a child record within the owner
|
927 | */
|
928 | createRecord(inputProperties?: {}): T;
|
929 | }
|
930 | class SnapshotRecordArray<K extends keyof ModelRegistry> {
|
931 | /**
|
932 | * Number of records in the array
|
933 | */
|
934 | length: number;
|
935 | /**
|
936 | * Meta objects for the record array.
|
937 | */
|
938 | meta: {};
|
939 | /**
|
940 | * A hash of adapter options passed into the store method for this request.
|
941 | */
|
942 | adapterOptions: {};
|
943 | /**
|
944 | * The relationships to include for this request.
|
945 | */
|
946 | include: string | any[];
|
947 | /**
|
948 | * The type of the underlying records for the snapshots in the array, as a DS.Model
|
949 | */
|
950 | type: ModelRegistry[K];
|
951 | /**
|
952 | * Get snapshots of the underlying record array
|
953 | */
|
954 | snapshots(): Snapshot[];
|
955 | }
|
956 | class Snapshot<K extends keyof ModelRegistry = keyof ModelRegistry> {
|
957 | /**
|
958 | * The underlying record for this snapshot. Can be used to access methods and
|
959 | * properties defined on the record.
|
960 | */
|
961 | record: ModelRegistry[K];
|
962 | /**
|
963 | * The id of the snapshot's underlying record
|
964 | */
|
965 | id: string;
|
966 | /**
|
967 | * A hash of adapter options
|
968 | */
|
969 | adapterOptions: Record<string, unknown>;
|
970 | /**
|
971 | * The name of the type of the underlying record for this snapshot, as a string.
|
972 | */
|
973 | modelName: K;
|
974 | /**
|
975 | * The type of the underlying record for this snapshot, as a DS.Model.
|
976 | */
|
977 | type: ModelRegistry[K];
|
978 | /**
|
979 | * Returns the value of an attribute.
|
980 | */
|
981 | attr<L extends AttributesFor<ModelRegistry[K]>>(keyName: L): ModelRegistry[K][L];
|
982 | /**
|
983 | * Returns all attributes and their corresponding values.
|
984 | */
|
985 | attributes(): { [L in keyof ModelRegistry[K]]: ModelRegistry[K][L] };
|
986 | /**
|
987 | * Returns all changed attributes and their old and new values.
|
988 | */
|
989 | changedAttributes(): Partial<{ [L in keyof ModelRegistry[K]]: ModelRegistry[K][L] }>;
|
990 | /**
|
991 | * Returns the current value of a belongsTo relationship.
|
992 | */
|
993 | belongsTo<L extends RelationshipsFor<ModelRegistry[K]>>(keyName: L, options?: {}): Snapshot | null | undefined;
|
994 | belongsTo<L extends RelationshipsFor<ModelRegistry[K]>>(
|
995 | keyName: L,
|
996 | options: { id: true },
|
997 | ): string | null | undefined;
|
998 |
|
999 | /**
|
1000 | * Returns the current value of a hasMany relationship.
|
1001 | */
|
1002 | hasMany<L extends RelationshipsFor<ModelRegistry[K]>>(
|
1003 | keyName: L,
|
1004 | options?: { ids: false },
|
1005 | ): Snapshot[] | undefined;
|
1006 | hasMany<L extends RelationshipsFor<ModelRegistry[K]>>(keyName: L, options: { ids: true }): string[] | undefined;
|
1007 | /**
|
1008 | * Iterates through all the attributes of the model, calling the passed
|
1009 | * function on each attribute.
|
1010 | */
|
1011 | eachAttribute<M extends ModelRegistry[K]>(
|
1012 | callback: (key: ModelKeys<M>, meta: AttributeMeta<M>) => void,
|
1013 | binding?: {},
|
1014 | ): void;
|
1015 | /**
|
1016 | * Iterates through all the relationships of the model, calling the passed
|
1017 | * function on each relationship.
|
1018 | */
|
1019 | eachRelationship<M extends ModelRegistry[K]>(
|
1020 | callback: (key: ModelKeys<M>, meta: RelationshipMeta<M>) => void,
|
1021 | binding?: {},
|
1022 | ): void;
|
1023 | /**
|
1024 | * Serializes the snapshot using the serializer for the model.
|
1025 | */
|
1026 | serialize<O extends object>(options: O): object;
|
1027 | }
|
1028 |
|
1029 | /**
|
1030 | * The store contains all of the data for records loaded from the server.
|
1031 | * It is also responsible for creating instances of `DS.Model` that wrap
|
1032 | * the individual data for a record, so that they can be bound to in your
|
1033 | * Handlebars templates.
|
1034 | */
|
1035 | class Store extends Ember.Service {
|
1036 | /**
|
1037 | * The default adapter to use to communicate to a backend server or
|
1038 | * other persistence layer. This will be overridden by an application
|
1039 | * adapter if present.
|
1040 | */
|
1041 | adapter: string;
|
1042 | /**
|
1043 | * Create a new record in the current store. The properties passed
|
1044 | * to this method are set on the newly created record.
|
1045 | */
|
1046 | createRecord<K extends keyof ModelRegistry>(modelName: K, inputProperties?: {}): ModelRegistry[K];
|
1047 | /**
|
1048 | * For symmetry, a record can be deleted via the store.
|
1049 | */
|
1050 | deleteRecord(record: Model): void;
|
1051 | /**
|
1052 | * For symmetry, a record can be unloaded via the store.
|
1053 | * This will cause the record to be destroyed and freed up for garbage collection.
|
1054 | */
|
1055 | unloadRecord(record: Model): void;
|
1056 | /**
|
1057 | * This method returns a record for a given type and id combination.
|
1058 | */
|
1059 | findRecord<K extends keyof ModelRegistry>(
|
1060 | modelName: K,
|
1061 | id: string | number,
|
1062 | options?: {},
|
1063 | ): PromiseObject<ModelRegistry[K]>;
|
1064 | /**
|
1065 | * Get the reference for the specified record.
|
1066 | */
|
1067 | getReference<K extends keyof ModelRegistry>(
|
1068 | modelName: K,
|
1069 | id: string | number,
|
1070 | ): RecordReference<ModelRegistry[K]>;
|
1071 | /**
|
1072 | * Get a record by a given type and ID without triggering a fetch.
|
1073 | */
|
1074 | peekRecord<K extends keyof ModelRegistry>(modelName: K, id: string | number): ModelRegistry[K] | null;
|
1075 | /**
|
1076 | * This method returns true if a record for a given modelName and id is already
|
1077 | * loaded in the store. Use this function to know beforehand if a findRecord()
|
1078 | * will result in a request or that it will be a cache hit.
|
1079 | */
|
1080 | hasRecordForId<K extends keyof ModelRegistry>(modelName: K, id: string | number): boolean;
|
1081 | /**
|
1082 | * This method delegates a query to the adapter. This is the one place where
|
1083 | * adapter-level semantics are exposed to the application.
|
1084 | */
|
1085 | query<K extends keyof ModelRegistry>(
|
1086 | modelName: K,
|
1087 | query: object,
|
1088 | options?: { adapterOptions?: object | undefined },
|
1089 | ): PromiseArray<ModelRegistry[K], AdapterPopulatedRecordArray<ModelRegistry[K]>>;
|
1090 | /**
|
1091 | * This method makes a request for one record, where the `id` is not known
|
1092 | * beforehand (if the `id` is known, use [`findRecord`](#method_findRecord)
|
1093 | * instead).
|
1094 | */
|
1095 | queryRecord<K extends keyof ModelRegistry>(
|
1096 | modelName: K,
|
1097 | query: object,
|
1098 | options?: { adapterOptions?: object | undefined },
|
1099 | ): RSVP.Promise<ModelRegistry[K]>;
|
1100 | /**
|
1101 | * `findAll` asks the adapter's `findAll` method to find the records for the
|
1102 | * given type, and returns a promise which will resolve with all records of
|
1103 | * this type present in the store, even if the adapter only returns a subset
|
1104 | * of them.
|
1105 | */
|
1106 | findAll<K extends keyof ModelRegistry>(
|
1107 | modelName: K,
|
1108 | options?: {
|
1109 | reload?: boolean | undefined;
|
1110 | backgroundReload?: boolean | undefined;
|
1111 | include?: string | undefined;
|
1112 | adapterOptions?: any;
|
1113 | },
|
1114 | ): PromiseArray<ModelRegistry[K], Ember.ArrayProxy<ModelRegistry[K]>>;
|
1115 | /**
|
1116 | * This method returns a filtered array that contains all of the
|
1117 | * known records for a given type in the store.
|
1118 | */
|
1119 | peekAll<K extends keyof ModelRegistry>(modelName: K): RecordArray<ModelRegistry[K]>;
|
1120 | /**
|
1121 | * This method unloads all records in the store.
|
1122 | * It schedules unloading to happen during the next run loop.
|
1123 | */
|
1124 | unloadAll<K extends keyof ModelRegistry>(modelName?: K): void;
|
1125 | /**
|
1126 | * DEPRECATED:
|
1127 | * This method has been deprecated and is an alias for store.hasRecordForId, which should
|
1128 | * be used instead.
|
1129 | */
|
1130 | recordIsLoaded<K extends keyof ModelRegistry>(modelName: K, id: string): boolean;
|
1131 | /**
|
1132 | * Returns the model class for the particular `modelName`.
|
1133 | */
|
1134 | modelFor<K extends keyof ModelRegistry>(modelName: K): ModelRegistry[K];
|
1135 | /**
|
1136 | * Push some data for a given type into the store.
|
1137 | */
|
1138 | push(data: {}): Model | any[];
|
1139 | /**
|
1140 | * Push some raw data into the store.
|
1141 | */
|
1142 | pushPayload<K extends keyof ModelRegistry>(modelName: K, inputPayload: {}): any;
|
1143 | pushPayload(inputPayload: {}): any;
|
1144 | /**
|
1145 | * `normalize` converts a json payload into the normalized form that
|
1146 | * [push](#method_push) expects.
|
1147 | */
|
1148 | normalize<K extends keyof ModelRegistry>(modelName: K, payload: {}): {};
|
1149 | /**
|
1150 | * Returns an instance of the adapter for a given type. For
|
1151 | * example, `adapterFor('person')` will return an instance of
|
1152 | * `App.PersonAdapter`.
|
1153 | */
|
1154 | adapterFor<K extends keyof AdapterRegistry>(modelName: K): AdapterRegistry[K];
|
1155 | /**
|
1156 | * Returns an instance of the serializer for a given type. For
|
1157 | * example, `serializerFor('person')` will return an instance of
|
1158 | * `App.PersonSerializer`.
|
1159 | */
|
1160 | serializerFor<K extends keyof SerializerRegistry>(modelName: K): SerializerRegistry[K];
|
1161 | }
|
1162 | /**
|
1163 | * The `JSONAPIAdapter` is the default adapter used by Ember Data. It
|
1164 | * is responsible for transforming the store's requests into HTTP
|
1165 | * requests that follow the [JSON API](http:
|
1166 | * format.
|
1167 | */
|
1168 | class JSONAPIAdapter extends RESTAdapter {}
|
1169 | |
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 | class RESTAdapter extends Adapter implements BuildURLMixin {
|
1175 | |
1176 |
|
1177 |
|
1178 | ajax(url: string, type: string, options?: object): RSVP.Promise<any>;
|
1179 | |
1180 |
|
1181 |
|
1182 | ajaxOptions(url: string, type: string, options?: object): object;
|
1183 | |
1184 |
|
1185 |
|
1186 |
|
1187 | sortQueryParams(obj: {}): {};
|
1188 | |
1189 |
|
1190 |
|
1191 |
|
1192 | findRecord<K extends keyof ModelRegistry>(
|
1193 | store: Store,
|
1194 | type: ModelSchema<K>,
|
1195 | id: string,
|
1196 | snapshot: Snapshot<K>,
|
1197 | ): RSVP.Promise<any>;
|
1198 | |
1199 |
|
1200 |
|
1201 |
|
1202 | findAll<K extends keyof ModelRegistry>(
|
1203 | store: Store,
|
1204 | type: ModelSchema<K>,
|
1205 | sinceToken: string,
|
1206 | snapshotRecordArray: SnapshotRecordArray<K>,
|
1207 | ): RSVP.Promise<any>;
|
1208 | |
1209 |
|
1210 |
|
1211 |
|
1212 | query<K extends keyof ModelRegistry>(store: Store, type: ModelSchema<K>, query: {}): RSVP.Promise<any>;
|
1213 | |
1214 |
|
1215 |
|
1216 |
|
1217 | queryRecord<K extends keyof ModelRegistry>(store: Store, type: ModelSchema<K>, query: {}): RSVP.Promise<any>;
|
1218 | |
1219 |
|
1220 |
|
1221 | findMany<K extends keyof ModelRegistry>(
|
1222 | store: Store,
|
1223 | type: ModelSchema<K>,
|
1224 | ids: any[],
|
1225 | snapshots: any[],
|
1226 | ): RSVP.Promise<any>;
|
1227 | |
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 | findHasMany<K extends keyof ModelRegistry>(
|
1233 | store: Store,
|
1234 | snapshot: Snapshot<K>,
|
1235 | url: string,
|
1236 | relationship: {},
|
1237 | ): RSVP.Promise<any>;
|
1238 | |
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 | findBelongsTo<K extends keyof ModelRegistry>(
|
1244 | store: Store,
|
1245 | snapshot: Snapshot<K>,
|
1246 | url: string,
|
1247 | ): RSVP.Promise<any>;
|
1248 | |
1249 |
|
1250 |
|
1251 |
|
1252 | createRecord<K extends keyof ModelRegistry>(
|
1253 | store: Store,
|
1254 | type: ModelSchema<K>,
|
1255 | snapshot: Snapshot<K>,
|
1256 | ): RSVP.Promise<any>;
|
1257 | |
1258 |
|
1259 |
|
1260 |
|
1261 | updateRecord<K extends keyof ModelRegistry>(
|
1262 | store: Store,
|
1263 | type: ModelSchema<K>,
|
1264 | snapshot: Snapshot<K>,
|
1265 | ): RSVP.Promise<any>;
|
1266 | |
1267 |
|
1268 |
|
1269 | deleteRecord<K extends keyof ModelRegistry>(
|
1270 | store: Store,
|
1271 | type: ModelSchema<K>,
|
1272 | snapshot: Snapshot<K>,
|
1273 | ): RSVP.Promise<any>;
|
1274 | |
1275 |
|
1276 |
|
1277 |
|
1278 | groupRecordsForFindMany(store: Store, snapshots: any[]): any[];
|
1279 | |
1280 |
|
1281 |
|
1282 | handleResponse(status: number, headers: {}, payload: {}, requestData: {}): {};
|
1283 | |
1284 |
|
1285 |
|
1286 |
|
1287 | isSuccess(status: number, headers: {}, payload: {}): boolean;
|
1288 | |
1289 |
|
1290 |
|
1291 |
|
1292 | isInvalid(status: number, headers: {}, payload: {}): boolean;
|
1293 | |
1294 |
|
1295 |
|
1296 | dataForRequest(params: {}): {};
|
1297 | |
1298 |
|
1299 |
|
1300 | methodForRequest(params: {}): string;
|
1301 | |
1302 |
|
1303 |
|
1304 | urlForRequest(params: {}): string;
|
1305 | |
1306 |
|
1307 |
|
1308 | headersForRequest(params: {}): {};
|
1309 | |
1310 |
|
1311 |
|
1312 | buildURL<K extends keyof ModelRegistry>(
|
1313 | modelName?: K,
|
1314 | id?: string | any[] | {} | null,
|
1315 | snapshot?: Snapshot<K> | any[] | null,
|
1316 | requestType?: string,
|
1317 | query?: {},
|
1318 | ): string;
|
1319 | |
1320 |
|
1321 |
|
1322 | buildQuery<K extends keyof ModelRegistry>(snapshot: Snapshot<K>): Record<string, unknown>;
|
1323 | |
1324 |
|
1325 |
|
1326 | urlForFindRecord<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
1327 | |
1328 |
|
1329 |
|
1330 | urlForFindAll<K extends keyof ModelRegistry>(modelName: K, snapshot: SnapshotRecordArray<K>): string;
|
1331 | |
1332 |
|
1333 |
|
1334 | urlForQuery<K extends keyof ModelRegistry>(query: {}, modelName: K): string;
|
1335 | |
1336 |
|
1337 |
|
1338 | urlForQueryRecord<K extends keyof ModelRegistry>(query: {}, modelName: K): string;
|
1339 | |
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 | urlForFindMany<K extends keyof ModelRegistry>(ids: any[], modelName: K, snapshots: any[]): string;
|
1345 | |
1346 |
|
1347 |
|
1348 |
|
1349 | urlForFindHasMany<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
1350 | |
1351 |
|
1352 |
|
1353 |
|
1354 | urlForFindBelongsTo<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
1355 | |
1356 |
|
1357 |
|
1358 |
|
1359 | urlForCreateRecord<K extends keyof ModelRegistry>(modelName: K, snapshot: Snapshot<K>): string;
|
1360 | |
1361 |
|
1362 |
|
1363 | urlForUpdateRecord<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
1364 | |
1365 |
|
1366 |
|
1367 | urlForDeleteRecord<K extends keyof ModelRegistry>(id: string, modelName: K, snapshot: Snapshot<K>): string;
|
1368 | |
1369 |
|
1370 |
|
1371 | pathForType<K extends keyof ModelRegistry>(modelName: K): string;
|
1372 | }
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 | interface RESTAdapter {
|
1378 | |
1379 |
|
1380 |
|
1381 |
|
1382 | namespace: string;
|
1383 | |
1384 |
|
1385 |
|
1386 | host: string;
|
1387 | |
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 | headers: {};
|
1395 | }
|
1396 | |
1397 |
|
1398 |
|
1399 | class EmbeddedRecordsMixin {
|
1400 | |
1401 |
|
1402 |
|
1403 |
|
1404 | normalize(typeClass: ModelSchema, hash: {}, prop: string): {};
|
1405 | |
1406 |
|
1407 |
|
1408 | serializeBelongsTo<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, json: {}, relationship: {}): any;
|
1409 | |
1410 |
|
1411 |
|
1412 | serializeHasMany<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, json: {}, relationship: {}): any;
|
1413 | |
1414 |
|
1415 |
|
1416 |
|
1417 | removeEmbeddedForeignKey<K extends keyof ModelRegistry>(
|
1418 | snapshot: Snapshot<K>,
|
1419 | embeddedSnapshot: Snapshot<K>,
|
1420 | relationship: {},
|
1421 | json: {},
|
1422 | ): any;
|
1423 | }
|
1424 | |
1425 |
|
1426 |
|
1427 | class JSONAPISerializer extends JSONSerializer {
|
1428 | pushPayload(store: Store, payload: {}): any;
|
1429 | |
1430 |
|
1431 |
|
1432 |
|
1433 | modelNameFromPayloadKey(key: string): string;
|
1434 | |
1435 |
|
1436 |
|
1437 | payloadKeyFromModelName<K extends keyof ModelRegistry>(modelName: K): string;
|
1438 | |
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 | keyForAttribute(key: string, method: string): string;
|
1446 | |
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 | keyForRelationship(key: string, typeClass: string, method: string): string;
|
1454 | |
1455 |
|
1456 |
|
1457 |
|
1458 | modelNameFromPayloadType(payloadType: string): string;
|
1459 | |
1460 |
|
1461 |
|
1462 |
|
1463 | payloadTypeFromModelName<K extends keyof ModelRegistry>(modelName: K): string;
|
1464 | }
|
1465 | |
1466 |
|
1467 |
|
1468 | class JSONSerializer extends Serializer {
|
1469 | |
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 | primaryKey: string;
|
1478 | |
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 | attrs: {};
|
1486 | |
1487 |
|
1488 |
|
1489 |
|
1490 | normalizeResponse(
|
1491 | store: Store,
|
1492 | primaryModelClass: ModelSchema,
|
1493 | payload: {},
|
1494 | id: string | number,
|
1495 | requestType: string,
|
1496 | ): {};
|
1497 | normalizeFindRecordResponse(
|
1498 | store: Store,
|
1499 | primaryModelClass: ModelSchema,
|
1500 | payload: {},
|
1501 | id: string | number,
|
1502 | requestType: string,
|
1503 | ): {};
|
1504 | normalizeQueryRecordResponse(
|
1505 | store: Store,
|
1506 | primaryModelClass: ModelSchema,
|
1507 | payload: {},
|
1508 | id: string | number,
|
1509 | requestType: string,
|
1510 | ): {};
|
1511 | normalizeFindAllResponse(
|
1512 | store: Store,
|
1513 | primaryModelClass: ModelSchema,
|
1514 | payload: {},
|
1515 | id: string | number,
|
1516 | requestType: string,
|
1517 | ): {};
|
1518 | normalizeFindBelongsToResponse(
|
1519 | store: Store,
|
1520 | primaryModelClass: ModelSchema,
|
1521 | payload: {},
|
1522 | id: string | number,
|
1523 | requestType: string,
|
1524 | ): {};
|
1525 | normalizeFindHasManyResponse(
|
1526 | store: Store,
|
1527 | primaryModelClass: ModelSchema,
|
1528 | payload: {},
|
1529 | id: string | number,
|
1530 | requestType: string,
|
1531 | ): {};
|
1532 | normalizeFindManyResponse(
|
1533 | store: Store,
|
1534 | primaryModelClass: ModelSchema,
|
1535 | payload: {},
|
1536 | id: string | number,
|
1537 | requestType: string,
|
1538 | ): {};
|
1539 | normalizeQueryResponse(
|
1540 | store: Store,
|
1541 | primaryModelClass: ModelSchema,
|
1542 | payload: {},
|
1543 | id: string | number,
|
1544 | requestType: string,
|
1545 | ): {};
|
1546 | normalizeCreateRecordResponse(
|
1547 | store: Store,
|
1548 | primaryModelClass: ModelSchema,
|
1549 | payload: {},
|
1550 | id: string | number,
|
1551 | requestType: string,
|
1552 | ): {};
|
1553 | normalizeDeleteRecordResponse(
|
1554 | store: Store,
|
1555 | primaryModelClass: ModelSchema,
|
1556 | payload: {},
|
1557 | id: string | number,
|
1558 | requestType: string,
|
1559 | ): {};
|
1560 | normalizeUpdateRecordResponse(
|
1561 | store: Store,
|
1562 | primaryModelClass: ModelSchema,
|
1563 | payload: {},
|
1564 | id: string | number,
|
1565 | requestType: string,
|
1566 | ): {};
|
1567 | normalizeSaveResponse(
|
1568 | store: Store,
|
1569 | primaryModelClass: ModelSchema,
|
1570 | payload: {},
|
1571 | id: string | number,
|
1572 | requestType: string,
|
1573 | ): {};
|
1574 | normalizeSingleResponse(
|
1575 | store: Store,
|
1576 | primaryModelClass: ModelSchema,
|
1577 | payload: {},
|
1578 | id: string | number,
|
1579 | requestType: string,
|
1580 | ): {};
|
1581 | normalizeArrayResponse(
|
1582 | store: Store,
|
1583 | primaryModelClass: ModelSchema,
|
1584 | payload: {},
|
1585 | id: string | number,
|
1586 | requestType: string,
|
1587 | ): {};
|
1588 | |
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 | normalize(typeClass: ModelSchema, hash: {}): {};
|
1594 | |
1595 |
|
1596 |
|
1597 | extractId(modelClass: {}, resourceHash: {}): string;
|
1598 | |
1599 |
|
1600 |
|
1601 | extractAttributes(modelClass: ModelSchema, resourceHash: {}): {};
|
1602 | |
1603 |
|
1604 |
|
1605 | extractRelationship(relationshipModelName: {}, relationshipHash: {}): {};
|
1606 | |
1607 |
|
1608 |
|
1609 | extractPolymorphicRelationship(relationshipModelName: {}, relationshipHash: {}, relationshipOptions: {}): {};
|
1610 | |
1611 |
|
1612 |
|
1613 | extractRelationships(modelClass: ModelSchema, resourceHash: {}): {};
|
1614 | modelNameFromPayloadKey(key: string): string;
|
1615 | |
1616 |
|
1617 |
|
1618 | shouldSerializeHasMany<K extends keyof ModelRegistry>(
|
1619 | snapshot: Snapshot<K>,
|
1620 | key: string,
|
1621 | relationshipType: string,
|
1622 | ): boolean;
|
1623 | |
1624 |
|
1625 |
|
1626 |
|
1627 | serialize<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, options: {}): {};
|
1628 | |
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 | serializeIntoHash<K extends keyof ModelRegistry>(
|
1637 | hash: {},
|
1638 | typeClass: ModelSchema<K>,
|
1639 | snapshot: Snapshot<K>,
|
1640 | options?: {},
|
1641 | ): any;
|
1642 | |
1643 |
|
1644 |
|
1645 |
|
1646 | serializeAttribute<K extends keyof ModelRegistry>(
|
1647 | snapshot: Snapshot<K>,
|
1648 | json: {},
|
1649 | key: string,
|
1650 | attribute: {},
|
1651 | ): any;
|
1652 | |
1653 |
|
1654 |
|
1655 |
|
1656 | serializeBelongsTo<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, json: {}, relationship: {}): any;
|
1657 | |
1658 |
|
1659 |
|
1660 |
|
1661 | serializeHasMany<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, json: {}, relationship: {}): any;
|
1662 | |
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 | serializePolymorphicType<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, json: {}, relationship: {}): any;
|
1669 | |
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 | extractMeta(store: Store, modelClass: ModelSchema, payload: {}): any;
|
1675 | |
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 | extractErrors(store: Store, typeClass: ModelSchema, payload: {}, id: string | number): {};
|
1682 | |
1683 |
|
1684 |
|
1685 |
|
1686 | keyForAttribute(key: string, method: string): string;
|
1687 | |
1688 |
|
1689 |
|
1690 |
|
1691 |
|
1692 | keyForRelationship(key: string, typeClass: string, method: string): string;
|
1693 | |
1694 |
|
1695 |
|
1696 |
|
1697 | keyForLink(key: string, kind: string): string;
|
1698 | modelNameFromPayloadType(type: string): string;
|
1699 | |
1700 |
|
1701 |
|
1702 |
|
1703 | serializeId<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, json: {}, primaryKey: string): any;
|
1704 | }
|
1705 | |
1706 |
|
1707 |
|
1708 |
|
1709 | class RESTSerializer extends JSONSerializer {
|
1710 | |
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 | keyForPolymorphicType(key: string, typeClass: string, method: string): string;
|
1716 | |
1717 |
|
1718 |
|
1719 |
|
1720 |
|
1721 | normalize(modelClass: ModelSchema, resourceHash: {}, prop?: string): {};
|
1722 | |
1723 |
|
1724 |
|
1725 |
|
1726 | pushPayload(store: Store, payload: {}): any;
|
1727 | |
1728 |
|
1729 |
|
1730 |
|
1731 |
|
1732 | modelNameFromPayloadKey(key: string): string;
|
1733 | |
1734 |
|
1735 |
|
1736 |
|
1737 | serialize<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, options: {}): {};
|
1738 | |
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 | serializeIntoHash<K extends keyof ModelRegistry>(
|
1745 | hash: {},
|
1746 | typeClass: ModelSchema<K>,
|
1747 | snapshot: Snapshot<K>,
|
1748 | options?: {},
|
1749 | ): any;
|
1750 | |
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 | payloadKeyFromModelName<K extends keyof ModelRegistry>(modelName: K): string;
|
1756 | |
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 | serializePolymorphicType<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, json: {}, relationship: {}): any;
|
1762 | |
1763 |
|
1764 |
|
1765 |
|
1766 | extractPolymorphicRelationship(relationshipType: {}, relationshipHash: {}, relationshipOptions: {}): {};
|
1767 | |
1768 |
|
1769 |
|
1770 |
|
1771 | modelNameFromPayloadType(payloadType: string): string;
|
1772 | |
1773 |
|
1774 |
|
1775 |
|
1776 | payloadTypeFromModelName<K extends keyof ModelRegistry>(modelName: K): string;
|
1777 | }
|
1778 | |
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 | class BooleanTransform extends Transform<boolean> {}
|
1785 | |
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 | class DateTransform extends Transform<Date> {}
|
1793 | |
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 | class NumberTransform extends Transform<number> {}
|
1800 | |
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 | class StringTransform extends Transform<string> {}
|
1807 | |
1808 |
|
1809 |
|
1810 |
|
1811 |
|
1812 |
|
1813 |
|
1814 | class Transform<Deserialized = any, Serialized = any> extends Ember.Object {
|
1815 | |
1816 |
|
1817 |
|
1818 |
|
1819 | serialize(deserialized: Deserialized, options: AttrOptions<Deserialized>): Serialized;
|
1820 | |
1821 |
|
1822 |
|
1823 |
|
1824 | deserialize(serialized: Serialized, options: AttrOptions<Deserialized>): Deserialized;
|
1825 | }
|
1826 | |
1827 |
|
1828 |
|
1829 |
|
1830 |
|
1831 |
|
1832 |
|
1833 |
|
1834 | class Adapter extends Ember.Object {
|
1835 | |
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 | defaultSerializer: string;
|
1841 | |
1842 |
|
1843 |
|
1844 |
|
1845 |
|
1846 |
|
1847 |
|
1848 | findRecord<K extends keyof ModelRegistry>(
|
1849 | store: Store,
|
1850 | type: ModelSchema<K>,
|
1851 | id: string,
|
1852 | snapshot: Snapshot<K>,
|
1853 | ): RSVP.Promise<any>;
|
1854 | |
1855 |
|
1856 |
|
1857 | findAll<K extends keyof ModelRegistry>(
|
1858 | store: Store,
|
1859 | type: ModelSchema<K>,
|
1860 | sinceToken: string,
|
1861 | snapshotRecordArray: SnapshotRecordArray<K>,
|
1862 | ): RSVP.Promise<any>;
|
1863 | |
1864 |
|
1865 |
|
1866 | query<K extends keyof ModelRegistry>(
|
1867 | store: Store,
|
1868 | type: ModelSchema<K>,
|
1869 | query: {},
|
1870 | recordArray: AdapterPopulatedRecordArray<any>,
|
1871 | ): RSVP.Promise<any>;
|
1872 | |
1873 |
|
1874 |
|
1875 |
|
1876 | queryRecord<K extends keyof ModelRegistry>(store: Store, type: ModelSchema<K>, query: {}): RSVP.Promise<any>;
|
1877 | |
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 | generateIdForRecord<K extends keyof ModelRegistry>(
|
1884 | store: Store,
|
1885 | type: ModelSchema<K>,
|
1886 | inputProperties: {},
|
1887 | ): string | number;
|
1888 | |
1889 |
|
1890 |
|
1891 | serialize<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, options: {}): {};
|
1892 | |
1893 |
|
1894 |
|
1895 |
|
1896 | createRecord<K extends keyof ModelRegistry>(
|
1897 | store: Store,
|
1898 | type: ModelSchema<K>,
|
1899 | snapshot: Snapshot<K>,
|
1900 | ): RSVP.Promise<any>;
|
1901 | |
1902 |
|
1903 |
|
1904 |
|
1905 | updateRecord<K extends keyof ModelRegistry>(
|
1906 | store: Store,
|
1907 | type: ModelSchema<K>,
|
1908 | snapshot: Snapshot<K>,
|
1909 | ): RSVP.Promise<any>;
|
1910 | |
1911 |
|
1912 |
|
1913 |
|
1914 | deleteRecord<K extends keyof ModelRegistry>(
|
1915 | store: Store,
|
1916 | type: ModelSchema<K>,
|
1917 | snapshot: Snapshot<K>,
|
1918 | ): RSVP.Promise<any>;
|
1919 | |
1920 |
|
1921 |
|
1922 |
|
1923 |
|
1924 | findMany<K extends keyof ModelRegistry>(
|
1925 | store: Store,
|
1926 | type: ModelSchema<K>,
|
1927 | ids: any[],
|
1928 | snapshots: any[],
|
1929 | ): RSVP.Promise<any>;
|
1930 | |
1931 |
|
1932 |
|
1933 |
|
1934 | groupRecordsForFindMany(store: Store, snapshots: any[]): any[];
|
1935 | |
1936 |
|
1937 |
|
1938 |
|
1939 |
|
1940 | shouldReloadRecord<K extends keyof ModelRegistry>(store: Store, snapshot: Snapshot<K>): boolean;
|
1941 | |
1942 |
|
1943 |
|
1944 |
|
1945 |
|
1946 | shouldReloadAll<K extends keyof ModelRegistry>(
|
1947 | store: Store,
|
1948 | snapshotRecordArray: SnapshotRecordArray<K>,
|
1949 | ): boolean;
|
1950 | |
1951 |
|
1952 |
|
1953 |
|
1954 |
|
1955 | shouldBackgroundReloadRecord<K extends keyof ModelRegistry>(store: Store, snapshot: Snapshot<K>): boolean;
|
1956 | |
1957 |
|
1958 |
|
1959 |
|
1960 |
|
1961 | shouldBackgroundReloadAll<K extends keyof ModelRegistry>(
|
1962 | store: Store,
|
1963 | snapshotRecordArray: SnapshotRecordArray<K>,
|
1964 | ): boolean;
|
1965 | }
|
1966 |
|
1967 |
|
1968 |
|
1969 | interface Adapter {
|
1970 | |
1971 |
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 | coalesceFindRequests: boolean;
|
1977 | }
|
1978 | |
1979 |
|
1980 |
|
1981 |
|
1982 |
|
1983 | class Serializer extends Ember.Object {
|
1984 | |
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 | store: Store;
|
1990 | |
1991 |
|
1992 |
|
1993 |
|
1994 | normalizeResponse(
|
1995 | store: Store,
|
1996 | primaryModelClass: ModelSchema,
|
1997 | payload: {},
|
1998 | id: string | number,
|
1999 | requestType: string,
|
2000 | ): {};
|
2001 | |
2002 |
|
2003 |
|
2004 |
|
2005 | serialize<K extends keyof ModelRegistry>(snapshot: Snapshot<K>, options: {}): {};
|
2006 | |
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 | normalize(typeClass: ModelSchema, hash: {}): {};
|
2013 | }
|
2014 | }
|
2015 |
|
2016 | export default DS;
|
2017 |
|
2018 | declare module "@ember/service" {
|
2019 | interface Registry {
|
2020 | store: DS.Store;
|
2021 | }
|
2022 | }
|
2023 |
|
2024 | declare module "ember-test-helpers" {
|
2025 | interface TestContext {
|
2026 | store: DS.Store;
|
2027 | }
|
2028 | }
|
2029 |
|
\ | No newline at end of file |