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