@ember-data/store 4.5.0-beta.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/addon/-private/{system/backburner.js → backburner.js} +0 -0
  2. package/addon/-private/{system/coerce-id.ts → coerce-id.ts} +0 -0
  3. package/addon/-private/{system/store/common.js → common.js} +0 -0
  4. package/addon/-private/{system/core-store.ts → core-store.ts} +467 -1253
  5. package/addon/-private/{system/errors-utils.js → errors-utils.js} +7 -6
  6. package/addon/-private/{system/fetch-manager.ts → fetch-manager.ts} +72 -42
  7. package/addon/-private/finders.js +107 -0
  8. package/addon/-private/identifer-debug-consts.ts +3 -0
  9. package/addon/-private/{identifiers/cache.ts → identifier-cache.ts} +26 -14
  10. package/addon/-private/{system/identity-map.ts → identity-map.ts} +2 -1
  11. package/addon/-private/index.ts +17 -17
  12. package/addon/-private/instance-cache.ts +387 -0
  13. package/addon/-private/{system/store/internal-model-factory.ts → internal-model-factory.ts} +25 -19
  14. package/addon/-private/{system/internal-model-map.ts → internal-model-map.ts} +9 -5
  15. package/addon/-private/model/internal-model.ts +602 -0
  16. package/addon/-private/{system/references/record.ts → model/record-reference.ts} +23 -36
  17. package/addon/-private/{system/model → model}/shim-model-class.ts +19 -14
  18. package/addon/-private/{system/normalize-model-name.ts → normalize-model-name.ts} +0 -0
  19. package/addon/-private/{system/promise-proxies.ts → promise-proxies.ts} +12 -5
  20. package/addon/-private/{system/promise-proxy-base.js → promise-proxy-base.js} +0 -0
  21. package/addon/-private/{system/record-array-manager.ts → record-array-manager.ts} +19 -18
  22. package/addon/-private/{system/record-arrays → record-arrays}/adapter-populated-record-array.ts +11 -10
  23. package/addon/-private/{system/record-arrays → record-arrays}/record-array.ts +37 -19
  24. package/addon/-private/record-data-for.ts +39 -0
  25. package/addon/-private/{system/store/record-data-store-wrapper.ts → record-data-store-wrapper.ts} +21 -26
  26. package/addon/-private/{system/record-notification-manager.ts → record-notification-manager.ts} +8 -3
  27. package/addon/-private/{system/request-cache.ts → request-cache.ts} +5 -6
  28. package/addon/-private/{system/schema-definition-service.ts → schema-definition-service.ts} +30 -14
  29. package/addon/-private/{system/store/serializer-response.ts → serializer-response.ts} +7 -6
  30. package/addon/-private/{system/snapshot-record-array.ts → snapshot-record-array.ts} +27 -8
  31. package/addon/-private/{system/snapshot.ts → snapshot.ts} +54 -39
  32. package/addon/-private/utils/construct-resource.ts +7 -3
  33. package/addon/-private/utils/promise-record.ts +9 -18
  34. package/addon/-private/{system/weak-cache.ts → weak-cache.ts} +2 -2
  35. package/addon/index.ts +1 -0
  36. package/package.json +21 -20
  37. package/addon/-private/identifiers/is-stable-identifier.ts +0 -18
  38. package/addon/-private/identifiers/utils/uuid-v4.ts +0 -80
  39. package/addon/-private/system/ds-model-store.ts +0 -136
  40. package/addon/-private/system/model/internal-model.ts +0 -1303
  41. package/addon/-private/system/model/states.js +0 -736
  42. package/addon/-private/system/record-arrays.ts +0 -8
  43. package/addon/-private/system/record-data-for.ts +0 -54
  44. package/addon/-private/system/references/belongs-to.ts +0 -406
  45. package/addon/-private/system/references/has-many.ts +0 -487
  46. package/addon/-private/system/references/reference.ts +0 -205
  47. package/addon/-private/system/references.js +0 -9
  48. package/addon/-private/system/store/finders.js +0 -412
  49. package/addon/-private/ts-interfaces/ds-model.ts +0 -50
  50. package/addon/-private/ts-interfaces/ember-data-json-api.ts +0 -145
  51. package/addon/-private/ts-interfaces/fetch-manager.ts +0 -44
  52. package/addon/-private/ts-interfaces/identifier.ts +0 -246
  53. package/addon/-private/ts-interfaces/minimum-adapter-interface.ts +0 -584
  54. package/addon/-private/ts-interfaces/minimum-serializer-interface.ts +0 -257
  55. package/addon/-private/ts-interfaces/promise-proxies.ts +0 -3
  56. package/addon/-private/ts-interfaces/record-data-json-api.ts +0 -29
  57. package/addon/-private/ts-interfaces/record-data-record-wrapper.ts +0 -46
  58. package/addon/-private/ts-interfaces/record-data-schemas.ts +0 -45
  59. package/addon/-private/ts-interfaces/record-data-store-wrapper.ts +0 -56
  60. package/addon/-private/ts-interfaces/record-data.ts +0 -72
  61. package/addon/-private/ts-interfaces/record-instance.ts +0 -18
  62. package/addon/-private/ts-interfaces/schema-definition-service.ts +0 -12
  63. package/addon/-private/ts-interfaces/store.ts +0 -10
  64. package/addon/-private/ts-interfaces/utils.ts +0 -6
@@ -1,257 +0,0 @@
1
- import type { Object as JSONObject } from 'json-typescript';
2
-
3
- import type Store from '../system/core-store';
4
- import type Snapshot from '../system/snapshot';
5
- import type { ModelSchema } from './ds-model';
6
- import type { JsonApiDocument, SingleResourceDocument } from './ember-data-json-api';
7
- import type { AdapterPayload } from './minimum-adapter-interface';
8
- import type { Dict } from './utils';
9
-
10
- export type OptionsHash = Dict<unknown>;
11
- export type RequestType =
12
- | 'findRecord'
13
- | 'queryRecord'
14
- | 'findAll'
15
- | 'findBelongsTo'
16
- | 'findHasMany'
17
- | 'findMany'
18
- | 'query'
19
- | 'createRecord'
20
- | 'deleteRecord'
21
- | 'updateRecord';
22
- /**
23
- @module @ember-data/serializer
24
- */
25
-
26
- /**
27
- The following documentation describes the methods an application
28
- serializer should implement with descriptions around when an
29
- application might expect these methods to be called.
30
-
31
- Methods that are not required are marked as **optional**.
32
-
33
- @class MinimumSerializerInterface
34
- @public
35
- */
36
- export interface MinimumSerializerInterface {
37
- /**
38
- * This method is responsible for normalizing the value resolved from the promise returned
39
- * by an Adapter request into the format expected by the `Store`.
40
- *
41
- * The output should be a [JSON:API Document](https://jsonapi.org/format/#document-structure)
42
- * with the following additional restrictions:
43
- *
44
- * - `type` should be formatted in the `singular` `dasherized` `lowercase` form
45
- * - `members` (the property names of attributes and relationships) should be formatted
46
- * to match their definition in the corresponding `Model` definition. Typically this
47
- * will be `camelCase`.
48
- * - [`lid`](https://github.com/emberjs/rfcs/blob/master/text/0403-ember-data-identifiers.md) is
49
- * a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
50
- * and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
51
- *
52
- * @method normalizeResponse
53
- * @public
54
- * @param {Store} store The store service that initiated the request being normalized
55
- * @param {ModelSchema} schema An object with methods for accessing information about
56
- * the type, attributes and relationships of the primary type associated with the request.
57
- * @param {JSONObject} rawPayload The raw JSON response data returned from an API request.
58
- * This correlates to the value the promise returned by the adapter method that performed
59
- * the request resolved to.
60
- * @param {string|null} id For a findRecord request, this is the id initially provided
61
- * in the call to store.findRecord. Else this value is null.
62
- * @param {'findRecord' | 'queryRecord' | 'findAll' | 'findBelongsTo' | 'findHasMany' | 'findMany' | 'query' | 'createRecord' | 'deleteRecord' | 'updateRecord'} requestType The
63
- * type of request the Adapter had been asked to perform.
64
- *
65
- * @returns {JsonApiDocument} a document following the structure of a JSON:API Document.
66
- */
67
- normalizeResponse(
68
- store: Store,
69
- schema: ModelSchema,
70
- rawPayload: AdapterPayload,
71
- id: string | null,
72
- requestType:
73
- | 'findRecord'
74
- | 'queryRecord'
75
- | 'findAll'
76
- | 'findBelongsTo'
77
- | 'findHasMany'
78
- | 'findMany'
79
- | 'query'
80
- | 'createRecord'
81
- | 'deleteRecord'
82
- | 'updateRecord'
83
- ): JsonApiDocument;
84
-
85
- /**
86
- * This method is responsible for serializing an individual record
87
- * via a [Snapshot](Snapshot) into the format expected by the API.
88
- *
89
- * This method is called by `snapshot.serialize()`.
90
- *
91
- * When using `Model`, this method is called by `record.serialize()`.
92
- *
93
- * When using `JSONAPIAdapter` or `RESTAdapter` this method is called
94
- * by `updateRecord` and `createRecord` if `Serializer.serializeIntoHash`
95
- * is not implemented.
96
- *
97
- * @method serialize
98
- * @public
99
- * @param {Snapshot} snapshot A Snapshot for the record to serialize
100
- * @param {object} [options]
101
- */
102
- serialize(snapshot: Snapshot, options?: OptionsHash): JSONObject;
103
-
104
- /**
105
- * This method is intended to normalize data into a [JSON:API Document](https://jsonapi.org/format/#document-structure)
106
- * with a data member containing a single [Resource](https://jsonapi.org/format/#document-resource-objects).
107
- *
108
- * - `type` should be formatted in the singular, dasherized and lowercase form
109
- * - `members` (the property names of attributes and relationships) should be formatted
110
- * to match their definition in the corresponding `Model` definition. Typically this
111
- * will be `camelCase`.
112
- * - [`lid`](https://github.com/emberjs/rfcs/blob/master/text/0403-ember-data-identifiers.md) is
113
- * a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
114
- * and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
115
- *
116
- * This method is called by the `Store` when `store.normalize(modelName, payload)` is
117
- * called. It is recommended to use `store.serializerFor(modelName).normalizeResponse`
118
- * over `store.normalize`.
119
- *
120
- * This method may be called when also using the `RESTSerializer`
121
- * when `serializer.pushPayload` is called by `store.pushPayload`.
122
- * However, it is recommended to use `store.push` over `store.pushPayload` after normalizing
123
- * the payload directly.
124
- *
125
- * Example:
126
- * ```js
127
- * function pushPayload(store, modelName, rawPayload) {
128
- * const ModelClass = store.modelFor(modelName);
129
- * const serializer = store.serializerFor(modelName);
130
- * const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');
131
- *
132
- * return store.push(jsonApiPayload);
133
- * }
134
- * ```
135
- *
136
- * This method may be called when also using the `JSONAPISerializer`
137
- * when normalizing included records. If mixing serializer usage in this way
138
- * we recommend implementing this method, but caution that it may lead
139
- * to unexpected mixing of formats.
140
- *
141
- * This method may also be called when normalizing embedded relationships when
142
- * using the `EmbeddedRecordsMixin`. If using this mixin in a serializer in
143
- * your application we recommend implementing this method, but caution that
144
- * it may lead to unexpected mixing of formats.
145
- *
146
- * @method normalize [OPTIONAL]
147
- * @public
148
- * @optional
149
- * @param {ModelSchema} schema An object with methods for accessing information about
150
- * the type, attributes and relationships of the primary type associated with the request.
151
- * @param {JSONObject} rawPayload Some raw JSON data to be normalized into a JSON:API Resource.
152
- * @param {string} [prop] When called by the EmbeddedRecordsMixin this param will be the
153
- * property at which the object provided as rawPayload was found.
154
- * @returns {SingleResourceDocument} A JSON:API Document
155
- * containing a single JSON:API Resource
156
- * as its primary data.
157
- */
158
- normalize?(schema: ModelSchema, rawPayload: JSONObject, prop?: string): SingleResourceDocument;
159
-
160
- /**
161
- * When using `JSONAPIAdapter` or `RESTAdapter` this method is called
162
- * by `adapter.updateRecord` and `adapter.createRecord` if `serializer.serializeIntoHash`
163
- * is implemented. If this method is not implemented, `serializer.serialize`
164
- * will be called in this case.
165
- *
166
- * You can use this method to customize the root keys serialized into the payload.
167
- * The hash property should be modified by reference.
168
- *
169
- * For instance, your API may expect resources to be keyed by underscored type in the payload:
170
- *
171
- * ```js
172
- * {
173
- * _user: {
174
- * type: 'user',
175
- * id: '1'
176
- * }
177
- * }
178
- * ```
179
- *
180
- * Which when using these adapters can be achieved by implementing this method similar
181
- * to the following:
182
- *
183
- * ```js
184
- * serializeIntoHash(hash, ModelClass, snapshot, options) {
185
- * hash[`_${snapshot.modelName}`] = this.serialize(snapshot, options).data;
186
- * }
187
- * ```
188
- *
189
- * @method serializeIntoHash [OPTIONAL]
190
- * @public
191
- * @optional
192
- * @param hash A top most object of the request payload onto
193
- * which to append the serialized record
194
- * @param {ModelSchema} schema An object with methods for accessing information about
195
- * the type, attributes and relationships of the primary type associated with the request.
196
- * @param {Snapshot} snapshot A Snapshot for the record to serialize
197
- * @param [options]
198
- * @returns {void}
199
- */
200
- serializeIntoHash?(hash: object, schema: ModelSchema, snapshot: Snapshot, options?: OptionsHash): void;
201
-
202
- /**
203
- * This method allows for normalization of data when `store.pushPayload` is called
204
- * and should be implemented if you want to use that method.
205
- *
206
- * The method is responsible for pushing new data to the store using `store.push`
207
- * once any necessary normalization has occurred, and no data in the store will be
208
- * updated unless it does so.
209
- *
210
- * The normalized form pushed to the store should be a [JSON:API Document](https://jsonapi.org/format/#document-structure)
211
- * with the following additional restrictions:
212
- *
213
- * - `type` should be formatted in the singular, dasherized and lowercase form
214
- * - `members` (the property names of attributes and relationships) should be formatted
215
- * to match their definition in the corresponding `Model` definition. Typically this
216
- * will be `camelCase`.
217
- * - [`lid`](https://github.com/emberjs/rfcs/blob/master/text/0403-ember-data-identifiers.md) is
218
- * a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
219
- * and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
220
- *
221
- * If you need better control over normalization or want access to the records being added or updated
222
- * in the store, we recommended using `store.push` over `store.pushPayload` after normalizing
223
- * the payload directly. This can even take advantage of an existing serializer for the format
224
- * the data is in, for example:
225
- *
226
- * ```js
227
- * function pushPayload(store, modelName, rawPayload) {
228
- * const ModelClass = store.modelFor(modelName);
229
- * const serializer = store.serializerFor(modelName);
230
- * const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');
231
- *
232
- * return store.push(jsonApiPayload);
233
- * }
234
- * ```
235
- *
236
- * @method pushPayload [OPTIONAL]
237
- * @public
238
- * @optional
239
- * @param {Store} store The store service that initiated the request being normalized
240
- * @param {JSONObject} rawPayload The raw JSON response data returned from an API request.
241
- * This JSON should be in the API format expected by the serializer.
242
- * @returns {void}
243
- */
244
- pushPayload?(store: Store, rawPayload: JSONObject): void;
245
-
246
- /**
247
- * In some situations the serializer may need to perform cleanup when destroyed,
248
- * that cleanup can be done in `destroy`.
249
- *
250
- * If not implemented, the store does not inform the serializer of destruction.
251
- *
252
- * @method destroy [OPTIONAL]
253
- * @public
254
- * @optional
255
- */
256
- destroy?(): void;
257
- }
@@ -1,3 +0,0 @@
1
- // shim type until we can properly type
2
- // these proxies
3
- export type PromiseProxy<T> = Promise<T>;
@@ -1,29 +0,0 @@
1
- import type { CollectionResourceRelationship, SingleResourceRelationship } from './ember-data-json-api';
2
- import type { Dict } from './utils';
3
-
4
- /**
5
- @module @ember-data/store
6
- */
7
-
8
- export type AttributesHash = Dict<unknown>;
9
-
10
- export interface JsonApiResource {
11
- id?: string | null;
12
- type?: string;
13
- attributes?: AttributesHash;
14
- relationships?: {
15
- [key: string]: SingleResourceRelationship | CollectionResourceRelationship;
16
- };
17
- meta?: any;
18
- lid?: string;
19
- }
20
-
21
- export interface JsonApiValidationError {
22
- title: string;
23
- detail: string;
24
- source: {
25
- pointer: string;
26
- };
27
- }
28
-
29
- export type JsonApiRelationship = SingleResourceRelationship | CollectionResourceRelationship;
@@ -1,46 +0,0 @@
1
- import type { CollectionResourceRelationship, SingleResourceRelationship } from './ember-data-json-api';
2
- import type { RecordIdentifier } from './identifier';
3
- import type { ChangedAttributesHash } from './record-data';
4
- import type { JsonApiValidationError } from './record-data-json-api';
5
-
6
- /**
7
- @module @ember-data/store
8
- */
9
-
10
- export interface RecordDataRecordWrapper {
11
- rollbackAttributes(): string[];
12
- changedAttributes(): ChangedAttributesHash;
13
- hasChangedAttributes(): boolean;
14
- setDirtyAttribute(key: string, value: any): void;
15
-
16
- getAttr(key: string): any;
17
- getHasMany(key: string): CollectionResourceRelationship;
18
-
19
- addToHasMany(key: string, recordDatas: RecordDataRecordWrapper[], idx?: number): void;
20
- removeFromHasMany(key: string, recordDatas: RecordDataRecordWrapper[]): void;
21
- setDirtyHasMany(key: string, recordDatas: RecordDataRecordWrapper[]): void;
22
-
23
- getBelongsTo(key: string): SingleResourceRelationship;
24
-
25
- setDirtyBelongsTo(name: string, recordData: RecordDataRecordWrapper | null): void;
26
-
27
- // ----- unspecced
28
- isAttrDirty(key: string): boolean;
29
- removeFromInverseRelationships(): void;
30
- hasAttr(key: string): boolean;
31
-
32
- // new
33
- getErrors?(recordIdentifier: RecordIdentifier): JsonApiValidationError[];
34
- /**
35
- * @internal
36
- * @deprecated
37
- */
38
- getErrors?({}): JsonApiValidationError[]; // eslint-disable-line no-empty-pattern
39
-
40
- isNew?(): boolean;
41
- isDeleted?(): boolean;
42
-
43
- isDeletionCommitted?(): boolean;
44
-
45
- setIsDeleted?(isDeleted: boolean): void;
46
- }
@@ -1,45 +0,0 @@
1
- /**
2
- @module @ember-data/store
3
- */
4
-
5
- import type { Dict } from './utils';
6
-
7
- export interface RelationshipSchema {
8
- kind: 'belongsTo' | 'hasMany';
9
- type: string; // related type
10
- /**
11
- * @internal
12
- * @deprecated
13
- */
14
- key: string; // TODO @runspired remove our uses
15
- // TODO @runspired should RFC be updated to make this optional?
16
- // TODO @runspired sohuld RFC be update to enforce async and inverse are set? else internals need to know
17
- // that meta came from DS.Model vs not from DS.Model as defaults should switch.
18
- options: {
19
- async?: boolean; // controls inverse unloading "client side delete semantics" so we should replace that with a real flag
20
- polymorphic?: boolean;
21
- inverse?: string | null; // property key on the related type (if any)
22
- [key: string]: unknown;
23
- };
24
- // inverse?: string | null;
25
- // inverseIsAsync?: boolean;
26
- name: string; // property key for this relationship
27
- }
28
-
29
- export type RelationshipsSchema = Dict<RelationshipSchema>;
30
-
31
- export interface AttributeSchema {
32
- /**
33
- * @internal
34
- */
35
- kind: 'attribute'; // TODO @runspired remove usage or guard internally
36
- name: string;
37
-
38
- // TODO @runspired update RFC to make options optional
39
- options: {
40
- [key: string]: unknown;
41
- };
42
- type: string; // TODO @runspired update RFC to make type optional
43
- }
44
-
45
- export type AttributesSchema = Dict<AttributeSchema>;
@@ -1,56 +0,0 @@
1
- import type { RecordData } from './record-data';
2
- import type { AttributesSchema, RelationshipsSchema } from './record-data-schemas';
3
-
4
- /**
5
- @module @ember-data/store
6
- */
7
-
8
- /**
9
- * Provides encapsulated API access to a minimal subset of store service's
10
- * functionality for RecordData implementations.
11
- *
12
- * @class RecordDataStoreWrapper
13
- * @public
14
- */
15
- export interface RecordDataStoreWrapper {
16
- relationshipsDefinitionFor(modelName: string): RelationshipsSchema;
17
- attributesDefinitionFor(modelName: string): AttributesSchema;
18
-
19
- /**
20
- * update the `id` for the record of type `modelName` with the corresponding `clientId`
21
- * This operation can only be done for records whose `id` is `null`.
22
- *
23
- * @method setRecordId
24
- * @public
25
- */
26
- setRecordId(modelName: string, id: string, clientId: string): void;
27
-
28
- disconnectRecord(modelName: string, id: string | null, clientId: string): void;
29
- disconnectRecord(modelName: string, id: string, clientId?: string | null): void;
30
- disconnectRecord(modelName: string, id: string | null, clientId?: string | null): void;
31
-
32
- isRecordInUse(modelName: string, id: string | null, clientId: string): boolean;
33
- isRecordInUse(modelName: string, id: string, clientId?: string | null): boolean;
34
- isRecordInUse(modelName: string, id: string | null, clientId?: string | null): boolean;
35
-
36
- notifyPropertyChange(modelName: string, id: string | null, clientId: string | null, key: string): void;
37
-
38
- notifyHasManyChange(modelName: string, id: string | null, clientId: string, key: string): void;
39
- notifyHasManyChange(modelName: string, id: string, clientId: string | null | undefined, key: string): void;
40
- notifyHasManyChange(modelName: string, id: string | null, clientId: string | null | undefined, key: string): void;
41
-
42
- recordDataFor(type: string, id: string, lid?: string | null): RecordData;
43
- recordDataFor(type: string, id: string | null, lid: string): RecordData;
44
- recordDataFor(type: string): RecordData;
45
- recordDataFor(type: string, id?: string | null, lid?: string | null): RecordData;
46
-
47
- notifyBelongsToChange(modelName: string, id: string | null, clientId: string, key: string): void;
48
- notifyBelongsToChange(modelName: string, id: string, clientId: string | null | undefined, key: string): void;
49
- notifyBelongsToChange(modelName: string, id: string | null, clientId: string | null | undefined, key: string): void;
50
-
51
- inverseForRelationship(modelName: string, key: string): string | null;
52
-
53
- inverseIsAsyncForRelationship(modelName: string, key: string): boolean;
54
- notifyErrorsChange(modelName: string, id: string | null, clientId: string | null): void;
55
- notifyStateChange(modelName: string, id: string | null, clientId: string | null, key?: string): void;
56
- }
@@ -1,72 +0,0 @@
1
- import type { CollectionResourceRelationship, SingleResourceRelationship } from './ember-data-json-api';
2
- import type { RecordIdentifier } from './identifier';
3
- import type { JsonApiResource, JsonApiValidationError } from './record-data-json-api';
4
-
5
- /**
6
- @module @ember-data/store
7
- */
8
-
9
- export interface ChangedAttributesHash {
10
- [key: string]: [string, string];
11
- }
12
-
13
- export interface RecordData {
14
- getResourceIdentifier(): RecordIdentifier | undefined;
15
-
16
- pushData(data: JsonApiResource, calculateChange: true): string[];
17
- pushData(data: JsonApiResource, calculateChange?: false): void;
18
- pushData(data: JsonApiResource, calculateChange?: boolean): string[] | void;
19
- clientDidCreate(): void;
20
- willCommit(): void;
21
-
22
- commitWasRejected(recordIdentifier?: RecordIdentifier, errors?: JsonApiValidationError[]): void;
23
- /**
24
- * @deprecated
25
- * @internal
26
- */
27
- commitWasRejected(recordIdentifier?: {}, errors?: JsonApiValidationError[]): void;
28
-
29
- unloadRecord(): void;
30
- rollbackAttributes(): string[];
31
- changedAttributes(): ChangedAttributesHash;
32
- hasChangedAttributes(): boolean;
33
- setDirtyAttribute(key: string, value: any): void;
34
-
35
- getAttr(key: string): any;
36
- getHasMany(key: string): CollectionResourceRelationship;
37
-
38
- addToHasMany(key: string, recordDatas: RecordData[], idx?: number): void;
39
- removeFromHasMany(key: string, recordDatas: RecordData[]): void;
40
- setDirtyHasMany(key: string, recordDatas: RecordData[]): void;
41
-
42
- getBelongsTo(key: string): SingleResourceRelationship;
43
-
44
- setDirtyBelongsTo(name: string, recordData: RecordData | null): void;
45
- didCommit(data: JsonApiResource | null): void;
46
-
47
- // ----- unspecced
48
- isAttrDirty(key: string): boolean;
49
- removeFromInverseRelationships(): void;
50
- hasAttr(key: string): boolean;
51
-
52
- isRecordInUse(): boolean;
53
- _initRecordCreateOptions(options: any): { [key: string]: unknown };
54
-
55
- // new
56
- getErrors?(recordIdentifier: RecordIdentifier): JsonApiValidationError[];
57
- /**
58
- * @deprecated
59
- * @internal
60
- */
61
- getErrors?({}): JsonApiValidationError[]; // eslint-disable-line no-empty-pattern
62
-
63
- isNew?(): boolean;
64
- isDeleted?(): boolean;
65
-
66
- isDeletionCommitted?(): boolean;
67
-
68
- setIsDeleted?(isDeleted: boolean): void;
69
-
70
- // Private and experimental
71
- __setId?(id: string): void;
72
- }
@@ -1,18 +0,0 @@
1
- import type { DSModel } from './ds-model';
2
- import type { Dict } from './utils';
3
- /**
4
- @module @ember-data/store
5
- */
6
-
7
- /*
8
- A `Record` is the result of the store instantiating a class to present data for a resource to the UI.
9
-
10
- Historically in `ember-data` this meant that it was the result of calling `_modelFactoryFor.create()` to
11
- gain instance to a class built upon `@ember-data/model`. However, as we go forward into a future in which
12
- model instances (aka `Records`) are completely user supplied and opaque to the internals, we need a type
13
- through which to communicate what is valid.
14
-
15
- The type belows allows for anything extending object.
16
- */
17
-
18
- export type RecordInstance = DSModel | Dict<unknown>;
@@ -1,12 +0,0 @@
1
- /**
2
- @module @ember-data/store
3
- */
4
-
5
- import type { RecordIdentifier } from './identifier';
6
- import type { AttributesSchema, RelationshipsSchema } from './record-data-schemas';
7
-
8
- export interface SchemaDefinitionService {
9
- doesTypeExist(modelName: string): boolean;
10
- attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema;
11
- relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema;
12
- }
@@ -1,10 +0,0 @@
1
- import type { Dict } from './utils';
2
-
3
- export interface FindOptions {
4
- reload?: boolean;
5
- backgroundReload?: boolean;
6
- include?: string;
7
- adapterOptions?: Dict<unknown>;
8
- preload?: Dict<unknown>;
9
- isReloading?: boolean;
10
- }
@@ -1,6 +0,0 @@
1
- /**
2
- @module @ember-data/store
3
- */
4
-
5
- export type ConfidentDict<V> = { [key: string]: V };
6
- export type Dict<V> = { [key: string]: V | undefined };