diff --git a/types/ember-data/adapter.d.ts b/types/ember-data/adapter.d.ts
new file mode 100644
index 0000000000..62d133a007
--- /dev/null
+++ b/types/ember-data/adapter.d.ts
@@ -0,0 +1,3 @@
+import DS from 'ember-data';
+export default DS.Adapter;
+export { AdapterRegistry } from 'ember-data';
diff --git a/types/ember-data/adapters/errors.d.ts b/types/ember-data/adapters/errors.d.ts
new file mode 100644
index 0000000000..e2e60f7f69
--- /dev/null
+++ b/types/ember-data/adapters/errors.d.ts
@@ -0,0 +1,13 @@
+import DS from 'ember-data';
+
+export const AdapterError: typeof DS.AdapterError;
+export const InvalidError: typeof DS.InvalidError;
+export const UnauthorizedError: typeof DS.UnauthorizedError;
+export const ForbiddenError: typeof DS.ForbiddenError;
+export const NotFoundError: typeof DS.NotFoundError;
+export const ConflictError: typeof DS.ConflictError;
+export const ServerError: typeof DS.ServerError;
+export const TimeoutError: typeof DS.TimeoutError;
+export const AbortError: typeof DS.AbortError;
+export const errorsHashToArray: typeof DS.errorsHashToArray;
+export const errorsArrayToHash: typeof DS.errorsArrayToHash;
diff --git a/types/ember-data/adapters/json-api.d.ts b/types/ember-data/adapters/json-api.d.ts
new file mode 100644
index 0000000000..4296b32eec
--- /dev/null
+++ b/types/ember-data/adapters/json-api.d.ts
@@ -0,0 +1,2 @@
+import DS from 'ember-data';
+export default DS.JSONAPIAdapter;
diff --git a/types/ember-data/adapters/rest.d.ts b/types/ember-data/adapters/rest.d.ts
new file mode 100644
index 0000000000..c7dd3824ae
--- /dev/null
+++ b/types/ember-data/adapters/rest.d.ts
@@ -0,0 +1,2 @@
+import DS from 'ember-data';
+export default DS.RESTAdapter;
diff --git a/types/ember-data/attr.d.ts b/types/ember-data/attr.d.ts
new file mode 100644
index 0000000000..2ecdea2d7e
--- /dev/null
+++ b/types/ember-data/attr.d.ts
@@ -0,0 +1,2 @@
+import DS from 'ember-data';
+export default DS.attr;
diff --git a/types/ember-data/index.d.ts b/types/ember-data/index.d.ts
index f98bf7f0af..32d5d4a4f3 100644
--- a/types/ember-data/index.d.ts
+++ b/types/ember-data/index.d.ts
@@ -6,2215 +6,2200 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
-///
-///
-///
-///
-///
+import Ember from 'ember';
+import Evented from '@ember/object/evented';
+import ObjectProxy from '@ember/object/proxy';
+import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
+import RSVP from 'rsvp';
-declare module 'ember-data' {
- import Ember from 'ember';
- import Evented from '@ember/object/evented';
- import ObjectProxy from '@ember/object/proxy';
- import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
- import RSVP from 'rsvp';
+export interface ModelRegistry {}
+export interface AdapterRegistry {}
+export interface SerializerRegistry {}
+export interface TransformRegistry {
+ string: string;
+ boolean: boolean;
+ number: number;
+ date: Date;
+}
- export interface ModelRegistry {}
- export interface AdapterRegistry {}
- export interface SerializerRegistry {}
- export interface TransformRegistry {
- 'string': string;
- 'boolean': boolean;
- 'number': number;
- 'date': Date;
+type AttributesFor = keyof Model; // TODO: filter to attr properties only (TS 2.8)
+type RelationshipsFor = keyof Model; // TODO: filter to hasMany/belongsTo properties only (TS 2.8)
+
+export interface ChangedAttributes {
+ [key: string]: [any, any] | undefined;
+}
+interface AttributeMeta {
+ type: keyof TransformRegistry;
+ options: object;
+ name: AttributesFor;
+ parentType: Model;
+ isAttribute: true;
+}
+interface RelationshipMeta {
+ key: RelationshipsFor;
+ kind: 'belongsTo' | 'hasMany';
+ type: keyof ModelRegistry;
+ options: object;
+ name: string;
+ parentType: Model;
+ isRelationship: true;
+}
+
+export namespace DS {
+ /**
+ * Convert an hash of errors into an array with errors in JSON-API format.
+ */
+ function errorsHashToArray(errors: {}): any[];
+ /**
+ * Convert an array of errors in JSON-API format into an object.
+ */
+ function errorsArrayToHash(errors: any[]): {};
+
+ interface RelationshipOptions {
+ async?: boolean;
+ inverse?: RelationshipsFor | null;
+ polymorphic?: boolean;
}
- type AttributesFor = keyof Model; // TODO: filter to attr properties only (TS 2.8)
- type RelationshipsFor = keyof Model; // TODO: filter to hasMany/belongsTo properties only (TS 2.8)
-
- export interface ChangedAttributes {
- [key: string]: [any, any] | undefined;
+ interface Sync {
+ async: false;
}
- interface AttributeMeta {
- type: keyof TransformRegistry;
- options: object;
- name: AttributesFor;
- parentType: Model;
- isAttribute: true;
- }
- interface RelationshipMeta {
- key: RelationshipsFor;
- kind: 'belongsTo' | 'hasMany';
- type: keyof ModelRegistry;
- options: object;
- name: string;
- parentType: Model;
- isRelationship: true;
+ interface Async {
+ async?: true;
}
- export namespace DS {
+ /**
+ * `DS.belongsTo` is used to define One-To-One and One-To-Many
+ * relationships on a [DS.Model](/api/data/classes/DS.Model.html).
+ */
+ function belongsTo(
+ modelName: K,
+ options: RelationshipOptions & Sync
+ ): Ember.ComputedProperty;
+ function belongsTo(
+ modelName: K,
+ options?: RelationshipOptions & Async
+ ): Ember.ComputedProperty<
+ ModelRegistry[K] & PromiseObject,
+ ModelRegistry[K]
+ >;
+ /**
+ * `DS.hasMany` is used to define One-To-Many and Many-To-Many
+ * relationships on a [DS.Model](/api/data/classes/DS.Model.html).
+ */
+ function hasMany(
+ type: K,
+ options: RelationshipOptions & Sync
+ ): Ember.ComputedProperty>;
+ function hasMany(
+ type: K,
+ options?: RelationshipOptions & Async
+ ): Ember.ComputedProperty<
+ PromiseManyArray,
+ Ember.Array
+ >;
+ /**
+ * This method normalizes a modelName into the format Ember Data uses
+ * internally.
+ */
+ function normalizeModelName(
+ modelName: K
+ ): string;
+ const VERSION: string;
+
+ interface AttrOptions {
+ defaultValue?: T | (() => T);
+ allowNull?: boolean; // TODO: restrict to boolean transform (TS 2.8)
+ }
+
+ /**
+ * `DS.attr` defines an attribute on a [DS.Model](/api/data/classes/DS.Model.html).
+ * By default, attributes are passed through as-is, however you can specify an
+ * optional type to have the value automatically transformed.
+ * Ember Data ships with four basic transform types: `string`, `number`,
+ * `boolean` and `date`. You can define your own transforms by subclassing
+ * [DS.Transform](/api/data/classes/DS.Transform.html).
+ */
+ function attr(
+ type: K,
+ options?: AttrOptions
+ ): Ember.ComputedProperty;
+ function attr(options?: AttrOptions): Ember.ComputedProperty;
+ /**
+ * WARNING: This interface is likely to change in order to accomodate https://github.com/emberjs/rfcs/pull/4
+ * ## Using BuildURLMixin
+ * To use url building, include the mixin when extending an adapter, and call `buildURL` where needed.
+ * The default behaviour is designed for RESTAdapter.
+ * ### Example
+ * ```javascript
+ * export default DS.Adapter.extend(BuildURLMixin, {
+ * findRecord: function(store, type, id, snapshot) {
+ * var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
+ * return this.ajax(url, 'GET');
+ * }
+ * });
+ * ```
+ * ### Attributes
+ * The `host` and `namespace` attributes will be used if defined, and are optional.
+ */
+ class BuildURLMixin {
/**
- * Convert an hash of errors into an array with errors in JSON-API format.
+ * Builds a URL for a given type and optional ID.
*/
- function errorsHashToArray(errors: {}): any[];
+ buildURL(
+ modelName?: K,
+ id?: string | any[] | {} | null,
+ snapshot?: Snapshot | any[] | null,
+ requestType?: string,
+ query?: {}
+ ): string;
/**
- * Convert an array of errors in JSON-API format into an object.
+ * Builds a URL for a `store.findRecord(type, id)` call.
*/
- function errorsArrayToHash(errors: any[]): {};
-
- interface RelationshipOptions {
- async?: boolean;
- inverse?: RelationshipsFor | null;
- polymorphic?: boolean;
- }
-
- interface Sync { async: false; }
- interface Async { async?: true; }
-
- /**
- * `DS.belongsTo` is used to define One-To-One and One-To-Many
- * relationships on a [DS.Model](/api/data/classes/DS.Model.html).
- */
- function belongsTo(
+ urlForFindRecord(
+ id: string,
modelName: K,
- options: RelationshipOptions & Sync
- ): Ember.ComputedProperty;
- function belongsTo(
+ snapshot: Snapshot
+ ): string;
+ /**
+ * Builds a URL for a `store.findAll(type)` call.
+ */
+ urlForFindAll(
modelName: K,
- options?: RelationshipOptions & Async
- ): Ember.ComputedProperty, ModelRegistry[K]>;
+ snapshot: SnapshotRecordArray
+ ): string;
/**
- * `DS.hasMany` is used to define One-To-Many and Many-To-Many
- * relationships on a [DS.Model](/api/data/classes/DS.Model.html).
+ * Builds a URL for a `store.query(type, query)` call.
*/
- function hasMany(
- type: K,
- options: RelationshipOptions & Sync
- ): Ember.ComputedProperty>;
- function hasMany(
- type: K,
- options?: RelationshipOptions & Async
- ): Ember.ComputedProperty, Ember.Array>;
+ urlForQuery(
+ query: {},
+ modelName: K
+ ): string;
/**
- * This method normalizes a modelName into the format Ember Data uses
- * internally.
+ * Builds a URL for a `store.queryRecord(type, query)` call.
*/
- function normalizeModelName(modelName: K): string;
- const VERSION: string;
-
- interface AttrOptions {
- defaultValue?: T | (() => T);
- allowNull?: boolean; // TODO: restrict to boolean transform (TS 2.8)
- }
-
+ urlForQueryRecord(
+ query: {},
+ modelName: K
+ ): string;
/**
- * `DS.attr` defines an attribute on a [DS.Model](/api/data/classes/DS.Model.html).
- * By default, attributes are passed through as-is, however you can specify an
- * optional type to have the value automatically transformed.
- * Ember Data ships with four basic transform types: `string`, `number`,
- * `boolean` and `date`. You can define your own transforms by subclassing
- * [DS.Transform](/api/data/classes/DS.Transform.html).
+ * Builds a URL for coalesceing multiple `store.findRecord(type, id)`
+ * records into 1 request when the adapter's `coalesceFindRequests`
+ * property is true.
*/
- function attr(
- type: K,
- options?: AttrOptions
- ): Ember.ComputedProperty;
- function attr(options?: AttrOptions): Ember.ComputedProperty;
+ urlForFindMany(
+ ids: any[],
+ modelName: K,
+ snapshots: any[]
+ ): string;
/**
- * WARNING: This interface is likely to change in order to accomodate https://github.com/emberjs/rfcs/pull/4
- * ## Using BuildURLMixin
- * To use url building, include the mixin when extending an adapter, and call `buildURL` where needed.
- * The default behaviour is designed for RESTAdapter.
- * ### Example
- * ```javascript
- * export default DS.Adapter.extend(BuildURLMixin, {
- * findRecord: function(store, type, id, snapshot) {
- * var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
- * return this.ajax(url, 'GET');
- * }
- * });
- * ```
- * ### Attributes
- * The `host` and `namespace` attributes will be used if defined, and are optional.
+ * Builds a URL for fetching a async hasMany relationship when a url
+ * is not provided by the server.
*/
- class BuildURLMixin {
- /**
- * Builds a URL for a given type and optional ID.
- */
- buildURL(
- modelName?: K,
- id?: string | any[] | {} | null,
- snapshot?: Snapshot | any[] | null,
- requestType?: string,
- query?: {}
- ): string;
- /**
- * Builds a URL for a `store.findRecord(type, id)` call.
- */
- urlForFindRecord(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for a `store.findAll(type)` call.
- */
- urlForFindAll(
- modelName: K,
- snapshot: SnapshotRecordArray
- ): string;
- /**
- * Builds a URL for a `store.query(type, query)` call.
- */
- urlForQuery(query: {}, modelName: K): string;
- /**
- * Builds a URL for a `store.queryRecord(type, query)` call.
- */
- urlForQueryRecord(query: {}, modelName: K): string;
- /**
- * Builds a URL for coalesceing multiple `store.findRecord(type, id)`
- * records into 1 request when the adapter's `coalesceFindRequests`
- * property is true.
- */
- urlForFindMany(
- ids: any[],
- modelName: K,
- snapshots: any[]
- ): string;
- /**
- * Builds a URL for fetching a async hasMany relationship when a url
- * is not provided by the server.
- */
- urlForFindHasMany(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for fetching a async belongsTo relationship when a url
- * is not provided by the server.
- */
- urlForFindBelongsTo(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for a `record.save()` call when the record was created
- * locally using `store.createRecord()`.
- */
- urlForCreateRecord(modelName: K, snapshot: Snapshot): string;
- /**
- * Builds a URL for a `record.save()` call when the record has been update locally.
- */
- urlForUpdateRecord(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for a `record.save()` call when the record has been deleted locally.
- */
- urlForDeleteRecord(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Determines the pathname for a given type.
- */
- pathForType(modelName: K): string;
- }
+ urlForFindHasMany(
+ id: string,
+ modelName: K,
+ snapshot: Snapshot
+ ): string;
/**
- * A `DS.AdapterError` is used by an adapter to signal that an error occurred
- * during a request to an external API. It indicates a generic error, and
- * subclasses are used to indicate specific error states. The following
- * subclasses are provided:
+ * Builds a URL for fetching a async belongsTo relationship when a url
+ * is not provided by the server.
*/
- class AdapterError extends Ember.Object {}
+ urlForFindBelongsTo(
+ id: string,
+ modelName: K,
+ snapshot: Snapshot
+ ): string;
/**
- * A `DS.InvalidError` is used by an adapter to signal the external API
- * was unable to process a request because the content was not
- * semantically correct or meaningful per the API. Usually this means a
- * record failed some form of server side validation. When a promise
- * from an adapter is rejected with a `DS.InvalidError` the record will
- * transition to the `invalid` state and the errors will be set to the
- * `errors` property on the record.
+ * Builds a URL for a `record.save()` call when the record was created
+ * locally using `store.createRecord()`.
*/
- class InvalidError extends AdapterError {
- constructor(errors: any[]);
- }
+ urlForCreateRecord(
+ modelName: K,
+ snapshot: Snapshot
+ ): string;
/**
- * A `DS.TimeoutError` is used by an adapter to signal that a request
- * to the external API has timed out. I.e. no response was received from
- * the external API within an allowed time period.
+ * Builds a URL for a `record.save()` call when the record has been update locally.
*/
- class TimeoutError extends AdapterError {}
+ urlForUpdateRecord(
+ id: string,
+ modelName: K,
+ snapshot: Snapshot
+ ): string;
/**
- * A `DS.AbortError` is used by an adapter to signal that a request to
- * the external API was aborted. For example, this can occur if the user
- * navigates away from the current page after a request to the external API
- * has been initiated but before a response has been received.
+ * Builds a URL for a `record.save()` call when the record has been deleted locally.
*/
- class AbortError extends AdapterError {}
+ urlForDeleteRecord(
+ id: string,
+ modelName: K,
+ snapshot: Snapshot
+ ): string;
/**
- * A `DS.UnauthorizedError` equates to a HTTP `401 Unauthorized` response
- * status. It is used by an adapter to signal that a request to the external
- * API was rejected because authorization is required and has failed or has not
- * yet been provided.
+ * Determines the pathname for a given type.
*/
- class UnauthorizedError extends AdapterError {}
- /**
- * A `DS.ForbiddenError` equates to a HTTP `403 Forbidden` response status.
- * It is used by an adapter to signal that a request to the external API was
- * valid but the server is refusing to respond to it. If authorization was
- * provided and is valid, then the authenticated user does not have the
- * necessary permissions for the request.
- */
- class ForbiddenError extends AdapterError {}
- /**
- * A `DS.NotFoundError` equates to a HTTP `404 Not Found` response status.
- * It is used by an adapter to signal that a request to the external API
- * was rejected because the resource could not be found on the API.
- */
- class NotFoundError extends AdapterError {}
- /**
- * A `DS.ConflictError` equates to a HTTP `409 Conflict` response status.
- * It is used by an adapter to indicate that the request could not be processed
- * because of a conflict in the request. An example scenario would be when
- * creating a record with a client generated id but that id is already known
- * to the external API.
- */
- class ConflictError extends AdapterError {}
- /**
- * A `DS.ServerError` equates to a HTTP `500 Internal Server Error` response
- * status. It is used by the adapter to indicate that a request has failed
- * because of an error in the external API.
- */
- class ServerError extends AdapterError {}
- /**
- * Holds validation errors for a given record, organized by attribute names.
- */
- interface Errors extends Ember.Enumerable, Evented {}
- class Errors extends Ember.Object {
- /**
- * DEPRECATED:
- * Register with target handler
- */
- registerHandlers(
- target: {},
- becameInvalid: Function,
- becameValid: Function
- ): any;
- /**
- * Returns errors for a given attribute
- */
- errorsFor(attribute: string): any[];
- /**
- * An array containing all of the error messages for this
- * record. This is useful for displaying all errors to the user.
- */
- messages: Ember.ComputedProperty;
- /**
- * Total number of errors.
- */
- length: Ember.ComputedProperty;
- isEmpty: Ember.ComputedProperty;
- /**
- * DEPRECATED:
- * Adds error messages to a given attribute and sends
- * `becameInvalid` event to the record.
- */
- add(attribute: string, messages: any[] | string): any;
- /**
- * DEPRECATED:
- * Removes all error messages from the given attribute and sends
- * `becameValid` event to the record if there no more errors left.
- */
- remove(attribute: string): any;
- /**
- * DEPRECATED:
- * Removes all error messages and sends `becameValid` event
- * to the record.
- */
- clear(): any;
- /**
- * Checks if there is error messages for the given attribute.
- */
- has(attribute: string): boolean;
- }
- /**
- * The model class that all Ember Data records descend from.
- * This is the public API of Ember Data models. If you are using Ember Data
- * in your application, this is the class you should use.
- * If you are working on Ember Data internals, you most likely want to be dealing
- * with `InternalModel`
- */
- class Model extends Ember.Object {
- /**
- * If this property is `true` the record is in the `empty`
- * state. Empty is the first state all records enter after they have
- * been created. Most records created by the store will quickly
- * transition to the `loading` state if data needs to be fetched from
- * the server or the `created` state if the record is created on the
- * client. A record can also enter the empty state if the adapter is
- * unable to locate the record.
- */
- isEmpty: Ember.ComputedProperty;
- /**
- * If this property is `true` the record is in the `loading` state. A
- * record enters this state when the store asks the adapter for its
- * data. It remains in this state until the adapter provides the
- * requested data.
- */
- isLoading: Ember.ComputedProperty;
- /**
- * If this property is `true` the record is in the `loaded` state. A
- * record enters this state when its data is populated. Most of a
- * record's lifecycle is spent inside substates of the `loaded`
- * state.
- */
- isLoaded: Ember.ComputedProperty;
- /**
- * If this property is `true` the record is in the `dirty` state. The
- * record has local changes that have not yet been saved by the
- * adapter. This includes records that have been created (but not yet
- * saved) or deleted.
- */
- hasDirtyAttributes: Ember.ComputedProperty;
- /**
- * If this property is `true` the record is in the `saving` state. A
- * record enters the saving state when `save` is called, but the
- * adapter has not yet acknowledged that the changes have been
- * persisted to the backend.
- */
- isSaving: Ember.ComputedProperty;
- /**
- * If this property is `true` the record is in the `deleted` state
- * and has been marked for deletion. When `isDeleted` is true and
- * `hasDirtyAttributes` is true, the record is deleted locally but the deletion
- * was not yet persisted. When `isSaving` is true, the change is
- * in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the
- * change has persisted.
- */
- isDeleted: Ember.ComputedProperty;
- /**
- * If this property is `true` the record is in the `new` state. A
- * record will be in the `new` state when it has been created on the
- * client and the adapter has not yet report that it was successfully
- * saved.
- */
- isNew: Ember.ComputedProperty;
- /**
- * If this property is `true` the record is in the `valid` state.
- */
- isValid: Ember.ComputedProperty;
- /**
- * If the record is in the dirty state this property will report what
- * kind of change has caused it to move into the dirty
- * state. Possible values are:
- */
- dirtyType: Ember.ComputedProperty;
- /**
- * If `true` the adapter reported that it was unable to save local
- * changes to the backend for any reason other than a server-side
- * validation error.
- */
- isError: boolean;
- /**
- * If `true` the store is attempting to reload the record from the adapter.
- */
- isReloading: boolean;
- /**
- * All ember models have an id property. This is an identifier
- * managed by an external source. These are always coerced to be
- * strings before being used internally. Note when declaring the
- * attributes for a model it is an error to declare an id
- * attribute.
- */
- id: string;
- /**
- * When the record is in the `invalid` state this object will contain
- * any errors returned by the adapter. When present the errors hash
- * contains keys corresponding to the invalid property names
- * and values which are arrays of Javascript objects with two keys:
- */
- errors: Ember.ComputedProperty;
- /**
- * This property holds the `DS.AdapterError` object with which
- * last adapter operation was rejected.
- */
- adapterError: AdapterError;
- /**
- * Create a JSON representation of the record, using the serialization
- * strategy of the store's adapter.
- */
- serialize(options?: { includeId?: boolean }): {};
- /**
- * Use [DS.JSONSerializer](DS.JSONSerializer.html) to
- * get the JSON representation of a record.
- */
- toJSON(options: {}): {};
- /**
- * Fired when the record is ready to be interacted with,
- * that is either loaded from the server or created locally.
- */
- ready(): void;
- /**
- * Fired when the record is loaded from the server.
- */
- didLoad(): void;
- /**
- * Fired when the record is updated.
- */
- didUpdate(): void;
- /**
- * Fired when a new record is commited to the server.
- */
- didCreate(): void;
- /**
- * Fired when the record is deleted.
- */
- didDelete(): void;
- /**
- * Fired when the record becomes invalid.
- */
- becameInvalid(): void;
- /**
- * Fired when the record enters the error state.
- */
- becameError(): void;
- /**
- * Fired when the record is rolled back.
- */
- rolledBack(): void;
- /**
- * Marks the record as deleted but does not save it. You must call
- * `save` afterwards if you want to persist it. You might use this
- * method if you want to allow the user to still `rollbackAttributes()`
- * after a delete was made.
- */
- deleteRecord(): any;
- /**
- * Same as `deleteRecord`, but saves the record immediately.
- */
- destroyRecord(options?: {}): RSVP.Promise;
- /**
- * Unloads the record from the store. This will cause the record to be destroyed and freed up for garbage collection.
- */
- unloadRecord(): any;
- /**
- * Returns an object, whose keys are changed properties, and value is
- * an [oldProp, newProp] array.
- */
- changedAttributes(): ChangedAttributes;
- /**
- * If the model `hasDirtyAttributes` this function will discard any unsaved
- * changes. If the model `isNew` it will be removed from the store.
- */
- rollbackAttributes(): any;
- /**
- * Save the record and persist any changes to the record to an
- * external source via the adapter.
- */
- save(options?: {}): RSVP.Promise;
- /**
- * Reload the record from the adapter.
- */
- reload(): RSVP.Promise;
- /**
- * Get the reference for the specified belongsTo relationship.
- */
- belongsTo(name: RelationshipsFor): BelongsToReference;
- /**
- * Get the reference for the specified hasMany relationship.
- */
- hasMany(name: RelationshipsFor): HasManyReference;
- /**
- * Given a callback, iterates over each of the relationships in the model,
- * invoking the callback with the name of each relationship and its relationship
- * descriptor.
- */
- eachRelationship(callback: (name: string, details: RelationshipMeta) => void, binding?: any): any;
- /**
- * Represents the model's class name as a string. This can be used to look up the model's class name through
- * `DS.Store`'s modelFor method.
- */
- static modelName: keyof ModelRegistry;
- /**
- * For a given relationship name, returns the model type of the relationship.
- */
- static typeForRelationship(name: K, store: Store): ModelRegistry[K];
- /**
- * Find the relationship which is the inverse of the one asked for.
- */
- static inverseFor(name: K, store: Store): {};
- /**
- * The model's relationships as a map, keyed on the type of the
- * relationship. The value of each entry is an array containing a descriptor
- * for each relationship with that type, describing the name of the relationship
- * as well as the type.
- */
- static relationships: Ember.ComputedProperty;
- /**
- * A hash containing lists of the model's relationships, grouped
- * by the relationship kind. For example, given a model with this
- * definition:
- */
- static relationshipNames: Ember.ComputedProperty<{}>;
- /**
- * An array of types directly related to a model. Each type will be
- * included once, regardless of the number of relationships it has with
- * the model.
- */
- static relatedTypes: Ember.ComputedProperty<
- Ember.NativeArray
- >;
- /**
- * A map whose keys are the relationships of a model and whose values are
- * relationship descriptors.
- */
- static relationshipsByName: Ember.ComputedProperty;
- /**
- * A map whose keys are the fields of the model and whose values are strings
- * describing the kind of the field. A model's fields are the union of all of its
- * attributes and relationships.
- */
- static fields: Ember.ComputedProperty;
- /**
- * Given a callback, iterates over each of the relationships in the model,
- * invoking the callback with the name of each relationship and its relationship
- * descriptor.
- */
- static eachRelationship(callback: (name: string, details: RelationshipMeta) => void, binding?: any): any;
- /**
- * Given a callback, iterates over each of the types related to a model,
- * invoking the callback with the related type's class. Each type will be
- * returned just once, regardless of how many different relationships it has
- * with a model.
- */
- static eachRelatedType(callback: Function, binding: any): any;
- /**
- * A map whose keys are the attributes of the model (properties
- * described by DS.attr) and whose values are the meta object for the
- * property.
- */
- static attributes: Ember.ComputedProperty;
- /**
- * A map whose keys are the attributes of the model (properties
- * described by DS.attr) and whose values are type of transformation
- * applied to each attribute. This map does not include any
- * attributes that do not have an transformation type.
- */
- static transformedAttributes: Ember.ComputedProperty;
- /**
- * Iterates through the attributes of the model, calling the passed function on each
- * attribute.
- */
- static eachAttribute(callback: Function, binding: {}): any;
- /**
- * Iterates through the transformedAttributes of the model, calling
- * the passed function on each attribute. Note the callback will not be
- * called for any attributes that do not have an transformation type.
- */
- static eachTransformedAttribute(
- callback: Function,
- binding: {}
- ): any;
- /**
- * Discards any unsaved changes to the given attribute. This feature is not enabled by default. You must enable `ds-rollback-attribute` and be running a canary build.
- */
- rollbackAttribute(): any;
- /**
- * This Ember.js hook allows an object to be notified when a property
- * is defined.
- */
- didDefineProperty(
- proto: {},
- key: string,
- value: Ember.ComputedProperty
- ): any;
- }
- /**
- * ### State
- */
- class RootState {}
- /**
- * Represents an ordered list of records whose order and membership is
- * determined by the adapter. For example, a query sent to the adapter
- * may trigger a search on the server, whose results would be loaded
- * into an instance of the `AdapterPopulatedRecordArray`.
- */
- class AdapterPopulatedRecordArray extends RecordArray {}
- /**
- * Represents a list of records whose membership is determined by the
- * store. As records are created, loaded, or modified, the store
- * evaluates them to determine if they should be part of the record
- * array.
- */
- class FilteredRecordArray extends RecordArray {
- /**
- * The filterFunction is a function used to test records from the store to
- * determine if they should be part of the record array.
- */
- filterFunction(record: Model): boolean;
- }
- /**
- * A record array is an array that contains records of a certain modelName. The record
- * array materializes records as needed when they are retrieved for the first
- * time. You should not create record arrays yourself. Instead, an instance of
- * `DS.RecordArray` or its subclasses will be returned by your application's store
- * in response to queries.
- */
- interface RecordArray extends Ember.ArrayProxy, Evented {}
- class RecordArray {
- /**
- * The flag to signal a `RecordArray` is finished loading data.
- */
- isLoaded: boolean;
- /**
- * The flag to signal a `RecordArray` is currently loading data.
- */
- isUpdating: boolean;
- /**
- * The modelClass represented by this record array.
- */
- type: Ember.ComputedProperty;
- /**
- * Used to get the latest version of all of the records in this array
- * from the adapter.
- */
- update(): any;
- /**
- * Saves all of the records in the `RecordArray`.
- */
- save(): PromiseArray;
- }
- /**
- * A BelongsToReference is a low level API that allows users and
- * addon author to perform meta-operations on a belongs-to
- * relationship.
- */
- class BelongsToReference {
- /**
- * This returns a string that represents how the reference will be
- * looked up when it is loaded. If the relationship has a link it will
- * use the "link" otherwise it defaults to "id".
- */
- remoteType(): string;
- /**
- * The `id` of the record that this reference refers to. Together, the
- * `type()` and `id()` methods form a composite key for the identity
- * map. This can be used to access the id of an async relationship
- * without triggering a fetch that would normally happen if you
- * attempted to use `record.get('relationship.id')`.
- */
- id(): string;
- /**
- * The link Ember Data will use to fetch or reload this belongs-to
- * relationship.
- */
- link(): string;
- /**
- * The meta data for the belongs-to relationship.
- */
- meta(): {};
- /**
- * `push` can be used to update the data in the relationship and Ember
- * Data will treat the new data as the conanical value of this
- * relationship on the backend.
- */
- push(objectOrPromise: {} | RSVP.Promise): RSVP.Promise;
- /**
- * `value()` synchronously returns the current value of the belongs-to
- * relationship. Unlike `record.get('relationshipName')`, calling
- * `value()` on a reference does not trigger a fetch if the async
- * relationship is not yet loaded. If the relationship is not loaded
- * it will always return `null`.
- */
- value(objectOrPromise: {} | RSVP.Promise): Model;
- /**
- * Loads a record in a belongs to relationship if it is not already
- * loaded. If the relationship is already loaded this method does not
- * trigger a new load.
- */
- load(): RSVP.Promise;
- /**
- * Triggers a reload of the value in this relationship. If the
- * remoteType is `"link"` Ember Data will use the relationship link to
- * reload the relationship. Otherwise it will reload the record by its
- * id.
- */
- reload(): RSVP.Promise;
- }
- /**
- * A HasManyReference is a low level API that allows users and addon
- * author to perform meta-operations on a has-many relationship.
- */
- class HasManyReference {
- /**
- * This returns a string that represents how the reference will be
- * looked up when it is loaded. If the relationship has a link it will
- * use the "link" otherwise it defaults to "id".
- */
- remoteType(): string;
- /**
- * The link Ember Data will use to fetch or reload this has-many
- * relationship.
- */
- link(): string;
- /**
- * `ids()` returns an array of the record ids in this relationship.
- */
- ids(): any[];
- /**
- * The meta data for the has-many relationship.
- */
- meta(): {};
- /**
- * `push` can be used to update the data in the relationship and Ember
- * Data will treat the new data as the canonical value of this
- * relationship on the backend.
- */
- push(objectOrPromise: T[] | RSVP.Promise): ManyArray;
- /**
- * `value()` synchronously returns the current value of the has-many
- * relationship. Unlike `record.get('relationshipName')`, calling
- * `value()` on a reference does not trigger a fetch if the async
- * relationship is not yet loaded. If the relationship is not loaded
- * it will always return `null`.
- */
- value(): ManyArray;
- /**
- * Loads the relationship if it is not already loaded. If the
- * relationship is already loaded this method does not trigger a new
- * load.
- */
- load(): RSVP.Promise;
- /**
- * Reloads this has-many relationship.
- */
- reload(): RSVP.Promise;
- }
- /**
- * An RecordReference is a low level API that allows users and
- * addon author to perform meta-operations on a record.
- */
- class RecordReference {
- /**
- * The `id` of the record that this reference refers to.
- */
- id(): string;
- /**
- * How the reference will be looked up when it is loaded: Currently
- * this always return `identity` to signifying that a record will be
- * loaded by the `type` and `id`.
- */
- remoteType(): string;
- /**
- * This API allows you to provide a reference with new data. The
- * simplest usage of this API is similar to `store.push`: you provide a
- * normalized hash of data and the object represented by the reference
- * will update.
- */
- push(payload: RSVP.Promise | {}): PromiseObject & T;
- /**
- * If the entity referred to by the reference is already loaded, it is
- * present as `reference.value`. Otherwise the value returned by this function
- * is `null`.
- */
- value(): T | null;
- /**
- * Triggers a fetch for the backing entity based on its `remoteType`
- * (see `remoteType` definitions per reference type).
- */
- load(): PromiseObject & T;
- /**
- * Reloads the record if it is already loaded. If the record is not
- * loaded it will load the record via `store.findRecord`
- */
- reload(): PromiseObject & T;
- }
- /**
- * A `ManyArray` is a `MutableArray` that represents the contents of a has-many
- * relationship.
- */
- interface ManyArray extends Ember.MutableArray {}
- class ManyArray extends Ember.Object.extend(
- Ember.MutableArray as {},
- Ember.Evented
- ) {
- /**
- * The loading state of this array
- */
- isLoaded: boolean;
- /**
- * Metadata associated with the request for async hasMany relationships.
- */
- meta: {};
- /**
- * Reloads all of the records in the manyArray. If the manyArray
- * holds a relationship that was originally fetched using a links url
- * Ember Data will revisit the original links url to repopulate the
- * relationship.
- */
- reload(): PromiseArray;
- /**
- * Saves all of the records in the `ManyArray`.
- */
- save(): PromiseArray;
- /**
- * Create a child record within the owner
- */
- createRecord(inputProperties?: {}): T;
- }
- /**
- * A `PromiseArray` is an object that acts like both an `Ember.Array`
- * and a promise. When the promise is resolved the resulting value
- * will be set to the `PromiseArray`'s `content` property. This makes
- * it easy to create data bindings with the `PromiseArray` that will be
- * updated when the promise resolves.
- */
- interface PromiseArray
- extends Ember.ArrayProxy,
- PromiseProxyMixin> {}
- class PromiseArray {}
- /**
- * A `PromiseObject` is an object that acts like both an `Ember.Object`
- * and a promise. When the promise is resolved, then the resulting value
- * will be set to the `PromiseObject`'s `content` property. This makes
- * it easy to create data bindings with the `PromiseObject` that will
- * be updated when the promise resolves.
- */
- interface PromiseObject
- extends ObjectProxy,
- PromiseProxyMixin {}
- class PromiseObject {}
- /**
- * A PromiseManyArray is a PromiseArray that also proxies certain method calls
- * to the underlying manyArray.
- * Right now we proxy:
- */
- class PromiseManyArray extends PromiseArray {
- /**
- * Reloads all of the records in the manyArray. If the manyArray
- * holds a relationship that was originally fetched using a links url
- * Ember Data will revisit the original links url to repopulate the
- * relationship.
- */
- reload(): PromiseManyArray;
- /**
- * Create a child record within the owner
- */
- createRecord(inputProperties?: {}): T;
- }
- class SnapshotRecordArray {
- /**
- * Number of records in the array
- */
- length: number;
- /**
- * Meta objects for the record array.
- */
- meta: {};
- /**
- * A hash of adapter options passed into the store method for this request.
- */
- adapterOptions: {};
- /**
- * The relationships to include for this request.
- */
- include: string | any[];
- /**
- * The type of the underlying records for the snapshots in the array, as a DS.Model
- */
- type: ModelRegistry[K];
- /**
- * Get snapshots of the underlying record array
- */
- snapshots(): any[];
- }
- class Snapshot {
- /**
- * The underlying record for this snapshot. Can be used to access methods and
- * properties defined on the record.
- */
- record: ModelRegistry[K];
- /**
- * The id of the snapshot's underlying record
- */
- id: string;
- /**
- * A hash of adapter options
- */
- adapterOptions: {};
- /**
- * The name of the type of the underlying record for this snapshot, as a string.
- */
- modelName: K;
- /**
- * The type of the underlying record for this snapshot, as a DS.Model.
- */
- type: ModelRegistry[K];
- /**
- * Returns the value of an attribute.
- */
- attr>(keyName: L): ModelRegistry[K][L];
- /**
- * Returns all attributes and their corresponding values.
- */
- attributes(): { [L in keyof ModelRegistry[K]]: ModelRegistry[K][L] };
- /**
- * Returns all changed attributes and their old and new values.
- */
- changedAttributes(): Partial<{ [L in keyof ModelRegistry[K]]: ModelRegistry[K][L] }>;
- /**
- * Returns the current value of a belongsTo relationship.
- */
- belongsTo>(
- keyName: L,
- options?: {}
- ): Snapshot['record'][L] | string | null | undefined;
- /**
- * Returns the current value of a hasMany relationship.
- */
- hasMany>(
- keyName: L,
- options?: { ids: false }
- ): Array['record'][L]> | undefined;
- hasMany>(
- keyName: L,
- options: { ids: true }
- ): string[] | undefined;
- /**
- * Iterates through all the attributes of the model, calling the passed
- * function on each attribute.
- */
- eachAttribute(callback: (key: keyof M, meta: AttributeMeta) => void, binding?: {}): any;
- /**
- * Iterates through all the relationships of the model, calling the passed
- * function on each relationship.
- */
- eachRelationship(callback: (key: keyof M, meta: RelationshipMeta) => void, binding?: {}): any;
- /**
- * Serializes the snapshot using the serializer for the model.
- */
- serialize(options: {}): {};
- }
-
- /**
- * The store contains all of the data for records loaded from the server.
- * It is also responsible for creating instances of `DS.Model` that wrap
- * the individual data for a record, so that they can be bound to in your
- * Handlebars templates.
- */
- class Store {
- /**
- * The default adapter to use to communicate to a backend server or
- * other persistence layer. This will be overridden by an application
- * adapter if present.
- */
- adapter: string;
- /**
- * Create a new record in the current store. The properties passed
- * to this method are set on the newly created record.
- */
- createRecord(
- modelName: K,
- inputProperties?: {}
- ): ModelRegistry[K];
- /**
- * For symmetry, a record can be deleted via the store.
- */
- deleteRecord(record: Model): void;
- /**
- * For symmetry, a record can be unloaded via the store.
- * This will cause the record to be destroyed and freed up for garbage collection.
- */
- unloadRecord(record: Model): void;
- /**
- * This method returns a record for a given type and id combination.
- */
- findRecord(
- modelName: K,
- id: string | number,
- options?: {}
- ): PromiseObject & ModelRegistry[K];
- /**
- * Get the reference for the specified record.
- */
- getReference(
- modelName: K,
- id: string | number
- ): RecordReference;
- /**
- * Get a record by a given type and ID without triggering a fetch.
- */
- peekRecord(
- modelName: K,
- id: string | number
- ): ModelRegistry[K] | null;
- /**
- * This method returns true if a record for a given modelName and id is already
- * loaded in the store. Use this function to know beforehand if a findRecord()
- * will result in a request or that it will be a cache hit.
- */
- hasRecordForId(
- modelName: K,
- id: string | number
- ): boolean;
- /**
- * This method delegates a query to the adapter. This is the one place where
- * adapter-level semantics are exposed to the application.
- */
- query(
- modelName: K,
- query: any
- ): AdapterPopulatedRecordArray & PromiseArray;
- /**
- * This method makes a request for one record, where the `id` is not known
- * beforehand (if the `id` is known, use [`findRecord`](#method_findRecord)
- * instead).
- */
- queryRecord(
- modelName: K,
- query: any
- ): RSVP.Promise;
- /**
- * `findAll` asks the adapter's `findAll` method to find the records for the
- * given type, and returns a promise which will resolve with all records of
- * this type present in the store, even if the adapter only returns a subset
- * of them.
- */
- findAll(
- modelName: K,
- options?: {
- reload?: boolean;
- backgroundReload?: boolean;
- include?: string;
- adapterOptions?: any;
- }
- ): PromiseArray;
- /**
- * This method returns a filtered array that contains all of the
- * known records for a given type in the store.
- */
- peekAll(modelName: K): RecordArray;
- /**
- * This method unloads all records in the store.
- * It schedules unloading to happen during the next run loop.
- */
- unloadAll(modelName: K): void;
- /**
- * DEPRECATED:
- * This method has been deprecated and is an alias for store.hasRecordForId, which should
- * be used instead.
- */
- recordIsLoaded(modelName: K, id: string): boolean;
- /**
- * Returns the model class for the particular `modelName`.
- */
- modelFor(modelName: K): ModelRegistry[K];
- /**
- * Push some data for a given type into the store.
- */
- push(data: {}): Model | any[];
- /**
- * Push some raw data into the store.
- */
- pushPayload(modelName: K, inputPayload: {}): any;
- pushPayload(inputPayload: {}): any;
- /**
- * `normalize` converts a json payload into the normalized form that
- * [push](#method_push) expects.
- */
- normalize(modelName: K, payload: {}): {};
- /**
- * Returns an instance of the adapter for a given type. For
- * example, `adapterFor('person')` will return an instance of
- * `App.PersonAdapter`.
- */
- adapterFor(modelName: K): AdapterRegistry[K];
- /**
- * Returns an instance of the serializer for a given type. For
- * example, `serializerFor('person')` will return an instance of
- * `App.PersonSerializer`.
- */
- serializerFor(modelName: K): SerializerRegistry[K];
- }
- /**
- * The `JSONAPIAdapter` is the default adapter used by Ember Data. It
- * is responsible for transforming the store's requests into HTTP
- * requests that follow the [JSON API](http://jsonapi.org/format/)
- * format.
- */
- class JSONAPIAdapter extends RESTAdapter {
- /**
- * By default the JSONAPIAdapter will send each find request coming from a `store.find`
- * or from accessing a relationship separately to the server. If your server supports passing
- * ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests
- * within a single runloop.
- */
- coalesceFindRequests: boolean;
- }
- /**
- * The REST adapter allows your store to communicate with an HTTP server by
- * transmitting JSON via XHR. Most Ember.js apps that consume a JSON API
- * should use the REST adapter.
- */
- class RESTAdapter extends Adapter implements BuildURLMixin {
- /**
- * Takes a URL, an HTTP method and a hash of data, and makes an HTTP request.
- */
- ajax(
- url: string,
- type: string,
- options?: object
- ): RSVP.Promise;
- /**
- * Generate ajax options
- */
- ajaxOptions(url: string, type: string, options?: object): object;
- /**
- * By default, the RESTAdapter will send the query params sorted alphabetically to the
- * server.
- */
- sortQueryParams(obj: {}): {};
- /**
- * By default the RESTAdapter will send each find request coming from a `store.find`
- * or from accessing a relationship separately to the server. If your server supports passing
- * ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests
- * within a single runloop.
- */
- coalesceFindRequests: boolean;
- /**
- * Endpoint paths can be prefixed with a `namespace` by setting the namespace
- * property on the adapter:
- */
- namespace: string;
- /**
- * An adapter can target other hosts by setting the `host` property.
- */
- host: string;
- /**
- * Some APIs require HTTP headers, e.g. to provide an API
- * key. Arbitrary headers can be set as key/value pairs on the
- * `RESTAdapter`'s `headers` object and Ember Data will send them
- * along with each ajax request. For dynamic headers see [headers
- * customization](/api/data/classes/DS.RESTAdapter.html#toc_headers-customization).
- */
- headers: {};
- /**
- * Called by the store in order to fetch the JSON for a given
- * type and ID.
- */
- findRecord(
- store: Store,
- type: ModelRegistry[K],
- id: string,
- snapshot: Snapshot
- ): RSVP.Promise;
- /**
- * Called by the store in order to fetch a JSON array for all
- * of the records for a given type.
- */
- findAll(
- store: Store,
- type: ModelRegistry[K],
- sinceToken: string,
- snapshotRecordArray: SnapshotRecordArray
- ): RSVP.Promise;
- /**
- * Called by the store in order to fetch a JSON array for
- * the records that match a particular query.
- */
- query(store: Store, type: ModelRegistry[K], query: {}): RSVP.Promise;
- /**
- * Called by the store in order to fetch a JSON object for
- * the record that matches a particular query.
- */
- queryRecord(
- store: Store,
- type: ModelRegistry[K],
- query: {}
- ): RSVP.Promise;
- /**
- * Called by the store in order to fetch several records together if `coalesceFindRequests` is true
- */
- findMany(
- store: Store,
- type: ModelRegistry[K],
- ids: any[],
- snapshots: any[]
- ): RSVP.Promise;
- /**
- * Called by the store in order to fetch a JSON array for
- * the unloaded records in a has-many relationship that were originally
- * specified as a URL (inside of `links`).
- */
- findHasMany(
- store: Store,
- snapshot: Snapshot,
- url: string,
- relationship: {}
- ): RSVP.Promise;
- /**
- * Called by the store in order to fetch the JSON for the unloaded record in a
- * belongs-to relationship that was originally specified as a URL (inside of
- * `links`).
- */
- findBelongsTo(
- store: Store,
- snapshot: Snapshot,
- url: string
- ): RSVP.Promise;
- /**
- * Called by the store when a newly created record is
- * saved via the `save` method on a model record instance.
- */
- createRecord(
- store: Store,
- type: ModelRegistry[K],
- snapshot: Snapshot
- ): RSVP.Promise;
- /**
- * Called by the store when an existing record is saved
- * via the `save` method on a model record instance.
- */
- updateRecord(
- store: Store,
- type: ModelRegistry[K],
- snapshot: Snapshot
- ): RSVP.Promise;
- /**
- * Called by the store when a record is deleted.
- */
- deleteRecord(
- store: Store,
- type: ModelRegistry[K],
- snapshot: Snapshot
- ): RSVP.Promise;
- /**
- * Organize records into groups, each of which is to be passed to separate
- * calls to `findMany`.
- */
- groupRecordsForFindMany(store: Store, snapshots: any[]): any[];
- /**
- * Takes an ajax response, and returns the json payload or an error.
- */
- handleResponse(
- status: number,
- headers: {},
- payload: {},
- requestData: {}
- ): {};
- /**
- * Default `handleResponse` implementation uses this hook to decide if the
- * response is a success.
- */
- isSuccess(status: number, headers: {}, payload: {}): boolean;
- /**
- * Default `handleResponse` implementation uses this hook to decide if the
- * response is an invalid error.
- */
- isInvalid(status: number, headers: {}, payload: {}): boolean;
- /**
- * Get the data (body or query params) for a request.
- */
- dataForRequest(params: {}): {};
- /**
- * Get the HTTP method for a request.
- */
- methodForRequest(params: {}): string;
- /**
- * Get the URL for a request.
- */
- urlForRequest(params: {}): string;
- /**
- * Get the headers for a request.
- */
- headersForRequest(params: {}): {};
- /**
- * Builds a URL for a given type and optional ID.
- */
- buildURL(
- modelName?: K,
- id?: string | any[] | {} | null,
- snapshot?: Snapshot | any[] | null,
- requestType?: string,
- query?: {}
- ): string;
- /**
- * Builds a URL for a `store.findRecord(type, id)` call.
- */
- urlForFindRecord(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for a `store.findAll(type)` call.
- */
- urlForFindAll(
- modelName: K,
- snapshot: SnapshotRecordArray
- ): string;
- /**
- * Builds a URL for a `store.query(type, query)` call.
- */
- urlForQuery(query: {}, modelName: K): string;
- /**
- * Builds a URL for a `store.queryRecord(type, query)` call.
- */
- urlForQueryRecord(query: {}, modelName: K): string;
- /**
- * Builds a URL for coalesceing multiple `store.findRecord(type, id)`
- * records into 1 request when the adapter's `coalesceFindRequests`
- * property is true.
- */
- urlForFindMany(
- ids: any[],
- modelName: K,
- snapshots: any[]
- ): string;
- /**
- * Builds a URL for fetching a async hasMany relationship when a url
- * is not provided by the server.
- */
- urlForFindHasMany(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for fetching a async belongsTo relationship when a url
- * is not provided by the server.
- */
- urlForFindBelongsTo(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for a `record.save()` call when the record was created
- * locally using `store.createRecord()`.
- */
- urlForCreateRecord(modelName: K, snapshot: Snapshot): string;
- /**
- * Builds a URL for a `record.save()` call when the record has been update locally.
- */
- urlForUpdateRecord(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Builds a URL for a `record.save()` call when the record has been deleted locally.
- */
- urlForDeleteRecord(
- id: string,
- modelName: K,
- snapshot: Snapshot
- ): string;
- /**
- * Determines the pathname for a given type.
- */
- pathForType(modelName: K): string;
- }
- /**
- * ## Using Embedded Records
- */
- class EmbeddedRecordsMixin {
- /**
- * Normalize the record and recursively normalize/extract all the embedded records
- * while pushing them into the store as they are encountered
- */
- normalize(typeClass: Model, hash: {}, prop: string): {};
- /**
- * Serialize `belongsTo` relationship when it is configured as an embedded object.
- */
- serializeBelongsTo(
- snapshot: Snapshot,
- json: {},
- relationship: {}
- ): any;
- /**
- * Serializes `hasMany` relationships when it is configured as embedded objects.
- */
- serializeHasMany(
- snapshot: Snapshot,
- json: {},
- relationship: {}
- ): any;
- /**
- * When serializing an embedded record, modify the property (in the json payload)
- * that refers to the parent record (foreign key for relationship).
- */
- removeEmbeddedForeignKey(
- snapshot: Snapshot,
- embeddedSnapshot: Snapshot