@ember-data/store 5.4.0-alpha.31 → 5.4.0-alpha.33

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 (35) hide show
  1. package/package.json +9 -9
  2. package/unstable-preview-types/-private/cache-handler.d.ts +101 -99
  3. package/unstable-preview-types/-private/caches/cache-utils.d.ts +11 -9
  4. package/unstable-preview-types/-private/caches/identifier-cache.d.ts +181 -179
  5. package/unstable-preview-types/-private/caches/instance-cache.d.ts +63 -61
  6. package/unstable-preview-types/-private/caches/resource-utils.d.ts +12 -10
  7. package/unstable-preview-types/-private/document.d.ts +146 -144
  8. package/unstable-preview-types/-private/index.d.ts +18 -16
  9. package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +178 -176
  10. package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +19 -17
  11. package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +29 -27
  12. package/unstable-preview-types/-private/managers/cache-manager.d.ts +442 -440
  13. package/unstable-preview-types/-private/managers/notification-manager.d.ts +98 -96
  14. package/unstable-preview-types/-private/managers/record-array-manager.d.ts +97 -95
  15. package/unstable-preview-types/-private/network/request-cache.d.ts +109 -107
  16. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +134 -132
  17. package/unstable-preview-types/-private/store-service.d.ts +1503 -1501
  18. package/unstable-preview-types/-private/utils/coerce-id.d.ts +10 -8
  19. package/unstable-preview-types/-private/utils/construct-resource.d.ts +10 -8
  20. package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +7 -5
  21. package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +4 -2
  22. package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +4 -2
  23. package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +4 -2
  24. package/unstable-preview-types/-private.d.ts +4 -2
  25. package/unstable-preview-types/-types/overview.d.ts +21 -19
  26. package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +107 -105
  27. package/unstable-preview-types/-types/q/cache.d.ts +47 -45
  28. package/unstable-preview-types/-types/q/ds-model.d.ts +15 -13
  29. package/unstable-preview-types/-types/q/identifier.d.ts +169 -167
  30. package/unstable-preview-types/-types/q/promise-proxies.d.ts +4 -2
  31. package/unstable-preview-types/-types/q/record-data-json-api.d.ts +36 -34
  32. package/unstable-preview-types/-types/q/record-instance.d.ts +29 -27
  33. package/unstable-preview-types/-types/q/schema-service.d.ts +214 -212
  34. package/unstable-preview-types/-types/q/store.d.ts +17 -15
  35. package/unstable-preview-types/index.d.ts +220 -185
@@ -1,212 +1,214 @@
1
- /**
2
- @module @ember-data/store
3
- */
4
- import type { RecordIdentifier } from '@warp-drive/core-types/identifier';
5
- import type { AttributesSchema, RelationshipsSchema } from '@warp-drive/core-types/schema';
6
- export interface FieldSchema {
7
- type: string | null;
8
- name: string;
9
- kind: 'attribute' | 'hasMany' | 'belongsTo' | 'field' | 'resource' | 'collection' | 'derived' | 'object' | 'array' | '@id' | '@local';
10
- options?: Record<string, unknown>;
11
- }
12
- /**
13
- * The SchemaService provides the ability to query for information about the structure
14
- * of any resource type.
15
- *
16
- * Applications can provide any implementation of the SchemaService they please so long
17
- * as it conforms to this interface.
18
- *
19
- * The design of the service means that schema information could be lazily populated,
20
- * derived-on-demand, or progressively enhanced during the course of an application's runtime.
21
- * The primary requirement is merely that any information the service needs to correctly
22
- * respond to an inquest is available by the time it is asked.
23
- *
24
- * The `@ember-data/model` package provides an implementation of this service which
25
- * makes use of your model classes as the source of information to respond to queries
26
- * about resource schema. While this is useful, this may not be ideal for your application.
27
- * For instance, Schema information could be sideloaded or pre-flighted for API calls,
28
- * resulting in no need to bundle and ship potentially large and expensive JSON
29
- * or large Javascript based Models to pull information from.
30
- *
31
- * To register a custom schema implementation, extend the store service or
32
- * lookup and register the schema service first thing on app-boot. Example below
33
- * shows extending the service.
34
- *
35
- * ```ts
36
- * import Store from '@ember-data/store';
37
- * import CustomSchemas from './custom-schemas';
38
- *
39
- * export default class extends Store {
40
- * constructor(...args) {
41
- * super(...args);
42
- * this.registerSchema(new CustomSchemas());
43
- * }
44
- * }
45
- * ```
46
- *
47
- * At runtime, both the `Store` and the `CacheCapabilitiesManager` provide
48
- * access to this service via the `schema` property.
49
- *
50
- * ```ts
51
- * export default class extends Component {
52
- * @service store;
53
- *
54
- * get attributes() {
55
- * return this.store
56
- * .schema
57
- * .attributesDefinitionFor(this.args.dataType);
58
- * }
59
- * }
60
- * ```
61
- *
62
- * Note: there can only be one schema service registered at a time.
63
- * If you register a new schema service, the old one will be replaced.
64
- *
65
- * If you would like to inherit from another schema service, you can do so by
66
- * using typical class inheritance patterns OR by accessing the existing
67
- * schema service at runtime before replacing it with your own, and then
68
- * having your own delegate to it when needed.
69
- *
70
- * @class <Interface> SchemaService
71
- * @public
72
- */
73
- export interface SchemaService {
74
- /**
75
- * Queries whether the schema-definition-service recognizes `type` as a resource type
76
- *
77
- * @method doesTypeExist
78
- * @public
79
- * @param {string} type
80
- * @return {boolean}
81
- */
82
- doesTypeExist(type: string): boolean;
83
- fields({ type }: {
84
- type: string;
85
- }): Map<string, FieldSchema>;
86
- /**
87
- * Returns definitions for all properties of the specified resource
88
- * that are considered "attributes". Generally these are properties
89
- * that are not related to book-keeping state on the client and do
90
- * not represent a linkage to another resource.
91
- *
92
- * The return value should be a dictionary of key:value pairs
93
- * where the `key` is the attribute or property's name and `value`
94
- * is an object with at least the property `name` which should also
95
- * match `key`.
96
- *
97
- * Optionally, this object may also specify `type`, which should
98
- * be a string reference to a `transform`, and `options` which
99
- * should be dictionary in which any key:value pairs are permissable.
100
- *
101
- * For instance, when using `@ember-data/model`, the following attribute
102
- * definition:
103
- *
104
- * ```ts
105
- * class extends Model {
106
- * @attr('string', { defaultValue: 'hello' }) greeting;
107
- * @attr('date') birthday;
108
- * @attr firstName;
109
- * }
110
- * ```
111
- *
112
- * Would be returned as:
113
- *
114
- * ```js
115
- * {
116
- * greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } },
117
- * birthday: { name: 'birthday', type: 'date' },
118
- * firstName: { name: 'firstName' }
119
- * }
120
- * ```
121
- *
122
- * @method attributesDefinitionFor
123
- * @public
124
- * @param {RecordIdentifier|{ type: string }} identifier
125
- * @return {AttributesSchema}
126
- */
127
- attributesDefinitionFor(identifier: RecordIdentifier | {
128
- type: string;
129
- }): AttributesSchema;
130
- /**
131
- * Returns definitions for all properties of the specified resource
132
- * that are considered "relationships". Generally these are properties
133
- * that represent a linkage to another resource.
134
- *
135
- * The return value should be a dictionary of key:value pairs
136
- * where the `key` is the relationship or property's name and `value`
137
- * is an object with at least the following properties:
138
- *
139
- * - `name` which should also match the `key` used in the dictionary.
140
- * - `kind` which should be either `belongsTo` or `hasMany`
141
- * - `type` which should be the related resource's string "type"
142
- * - `options` which should be a dictionary allowing any key but with
143
- * at least the below keys present.
144
- *
145
- * - `options.async` a boolean representing whether data for this relationship is
146
- * typically loaded on-demand.
147
- * - `options.inverse` a string or null representing the field name / key of the
148
- * corresponding relationship on the inverse resource.
149
- *
150
- * Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance)
151
- *
152
- * - `options.polymorphic` a boolean representing whether multiple resource types
153
- * can be used to satisfy this relationship.
154
- * - `options.as` a string representing the abstract type that the concrete side of
155
- * a relationship must specify when fulfilling a polymorphic inverse.
156
- *
157
- * For example, the following Model using @ember-data/model would generate this relationships
158
- * definition by default:
159
- *
160
- * ```js
161
- * class User extends Model {
162
- * @belongsTo('user', { async: false, inverse: null }) bestFriend;
163
- * @hasMany('user', { async: true, inverse: 'friends' }) friends;
164
- * @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets;
165
- * }
166
- * ```
167
- *
168
- * Which would be returned as
169
- *
170
- * ```js
171
- * {
172
- * bestFriend: {
173
- * name: 'bestFriend',
174
- * kind: 'belongsTo',
175
- * type: 'user',
176
- * options: {
177
- * async: false,
178
- * inverse: null
179
- * }
180
- * },
181
- * friends: {
182
- * name: 'friends',
183
- * kind: 'hasMany',
184
- * type: 'user',
185
- * options: {
186
- * async: true,
187
- * inverse: 'friends'
188
- * }
189
- * },
190
- * pets: {
191
- * name: 'pets',
192
- * kind: 'hasMany',
193
- * type: 'pet',
194
- * options: {
195
- * async: false,
196
- * polymorphic: true,
197
- * inverse: 'owner'
198
- * }
199
- * },
200
- * }
201
- * ```
202
- *
203
- * @method relationshipsDefinitionFor
204
- * @public
205
- * @param {RecordIdentifier|{ type: string }} identifier
206
- * @return {RelationshipsSchema}
207
- */
208
- relationshipsDefinitionFor(identifier: RecordIdentifier | {
209
- type: string;
210
- }): RelationshipsSchema;
211
- }
212
- //# sourceMappingURL=schema-service.d.ts.map
1
+ declare module '@ember-data/store/-types/q/schema-service' {
2
+ /**
3
+ @module @ember-data/store
4
+ */
5
+ import type { RecordIdentifier } from '@warp-drive/core-types/identifier';
6
+ import type { AttributesSchema, RelationshipsSchema } from '@warp-drive/core-types/schema';
7
+ export interface FieldSchema {
8
+ type: string | null;
9
+ name: string;
10
+ kind: 'attribute' | 'hasMany' | 'belongsTo' | 'field' | 'resource' | 'collection' | 'derived' | 'object' | 'array' | '@id' | '@local';
11
+ options?: Record<string, unknown>;
12
+ }
13
+ /**
14
+ * The SchemaService provides the ability to query for information about the structure
15
+ * of any resource type.
16
+ *
17
+ * Applications can provide any implementation of the SchemaService they please so long
18
+ * as it conforms to this interface.
19
+ *
20
+ * The design of the service means that schema information could be lazily populated,
21
+ * derived-on-demand, or progressively enhanced during the course of an application's runtime.
22
+ * The primary requirement is merely that any information the service needs to correctly
23
+ * respond to an inquest is available by the time it is asked.
24
+ *
25
+ * The `@ember-data/model` package provides an implementation of this service which
26
+ * makes use of your model classes as the source of information to respond to queries
27
+ * about resource schema. While this is useful, this may not be ideal for your application.
28
+ * For instance, Schema information could be sideloaded or pre-flighted for API calls,
29
+ * resulting in no need to bundle and ship potentially large and expensive JSON
30
+ * or large Javascript based Models to pull information from.
31
+ *
32
+ * To register a custom schema implementation, extend the store service or
33
+ * lookup and register the schema service first thing on app-boot. Example below
34
+ * shows extending the service.
35
+ *
36
+ * ```ts
37
+ * import Store from '@ember-data/store';
38
+ * import CustomSchemas from './custom-schemas';
39
+ *
40
+ * export default class extends Store {
41
+ * constructor(...args) {
42
+ * super(...args);
43
+ * this.registerSchema(new CustomSchemas());
44
+ * }
45
+ * }
46
+ * ```
47
+ *
48
+ * At runtime, both the `Store` and the `CacheCapabilitiesManager` provide
49
+ * access to this service via the `schema` property.
50
+ *
51
+ * ```ts
52
+ * export default class extends Component {
53
+ * @service store;
54
+ *
55
+ * get attributes() {
56
+ * return this.store
57
+ * .schema
58
+ * .attributesDefinitionFor(this.args.dataType);
59
+ * }
60
+ * }
61
+ * ```
62
+ *
63
+ * Note: there can only be one schema service registered at a time.
64
+ * If you register a new schema service, the old one will be replaced.
65
+ *
66
+ * If you would like to inherit from another schema service, you can do so by
67
+ * using typical class inheritance patterns OR by accessing the existing
68
+ * schema service at runtime before replacing it with your own, and then
69
+ * having your own delegate to it when needed.
70
+ *
71
+ * @class <Interface> SchemaService
72
+ * @public
73
+ */
74
+ export interface SchemaService {
75
+ /**
76
+ * Queries whether the schema-definition-service recognizes `type` as a resource type
77
+ *
78
+ * @method doesTypeExist
79
+ * @public
80
+ * @param {string} type
81
+ * @return {boolean}
82
+ */
83
+ doesTypeExist(type: string): boolean;
84
+ fields({ type }: {
85
+ type: string;
86
+ }): Map<string, FieldSchema>;
87
+ /**
88
+ * Returns definitions for all properties of the specified resource
89
+ * that are considered "attributes". Generally these are properties
90
+ * that are not related to book-keeping state on the client and do
91
+ * not represent a linkage to another resource.
92
+ *
93
+ * The return value should be a dictionary of key:value pairs
94
+ * where the `key` is the attribute or property's name and `value`
95
+ * is an object with at least the property `name` which should also
96
+ * match `key`.
97
+ *
98
+ * Optionally, this object may also specify `type`, which should
99
+ * be a string reference to a `transform`, and `options` which
100
+ * should be dictionary in which any key:value pairs are permissable.
101
+ *
102
+ * For instance, when using `@ember-data/model`, the following attribute
103
+ * definition:
104
+ *
105
+ * ```ts
106
+ * class extends Model {
107
+ * @attr('string', { defaultValue: 'hello' }) greeting;
108
+ * @attr('date') birthday;
109
+ * @attr firstName;
110
+ * }
111
+ * ```
112
+ *
113
+ * Would be returned as:
114
+ *
115
+ * ```js
116
+ * {
117
+ * greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } },
118
+ * birthday: { name: 'birthday', type: 'date' },
119
+ * firstName: { name: 'firstName' }
120
+ * }
121
+ * ```
122
+ *
123
+ * @method attributesDefinitionFor
124
+ * @public
125
+ * @param {RecordIdentifier|{ type: string }} identifier
126
+ * @return {AttributesSchema}
127
+ */
128
+ attributesDefinitionFor(identifier: RecordIdentifier | {
129
+ type: string;
130
+ }): AttributesSchema;
131
+ /**
132
+ * Returns definitions for all properties of the specified resource
133
+ * that are considered "relationships". Generally these are properties
134
+ * that represent a linkage to another resource.
135
+ *
136
+ * The return value should be a dictionary of key:value pairs
137
+ * where the `key` is the relationship or property's name and `value`
138
+ * is an object with at least the following properties:
139
+ *
140
+ * - `name` which should also match the `key` used in the dictionary.
141
+ * - `kind` which should be either `belongsTo` or `hasMany`
142
+ * - `type` which should be the related resource's string "type"
143
+ * - `options` which should be a dictionary allowing any key but with
144
+ * at least the below keys present.
145
+ *
146
+ * - `options.async` a boolean representing whether data for this relationship is
147
+ * typically loaded on-demand.
148
+ * - `options.inverse` a string or null representing the field name / key of the
149
+ * corresponding relationship on the inverse resource.
150
+ *
151
+ * Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance)
152
+ *
153
+ * - `options.polymorphic` a boolean representing whether multiple resource types
154
+ * can be used to satisfy this relationship.
155
+ * - `options.as` a string representing the abstract type that the concrete side of
156
+ * a relationship must specify when fulfilling a polymorphic inverse.
157
+ *
158
+ * For example, the following Model using @ember-data/model would generate this relationships
159
+ * definition by default:
160
+ *
161
+ * ```js
162
+ * class User extends Model {
163
+ * @belongsTo('user', { async: false, inverse: null }) bestFriend;
164
+ * @hasMany('user', { async: true, inverse: 'friends' }) friends;
165
+ * @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets;
166
+ * }
167
+ * ```
168
+ *
169
+ * Which would be returned as
170
+ *
171
+ * ```js
172
+ * {
173
+ * bestFriend: {
174
+ * name: 'bestFriend',
175
+ * kind: 'belongsTo',
176
+ * type: 'user',
177
+ * options: {
178
+ * async: false,
179
+ * inverse: null
180
+ * }
181
+ * },
182
+ * friends: {
183
+ * name: 'friends',
184
+ * kind: 'hasMany',
185
+ * type: 'user',
186
+ * options: {
187
+ * async: true,
188
+ * inverse: 'friends'
189
+ * }
190
+ * },
191
+ * pets: {
192
+ * name: 'pets',
193
+ * kind: 'hasMany',
194
+ * type: 'pet',
195
+ * options: {
196
+ * async: false,
197
+ * polymorphic: true,
198
+ * inverse: 'owner'
199
+ * }
200
+ * },
201
+ * }
202
+ * ```
203
+ *
204
+ * @method relationshipsDefinitionFor
205
+ * @public
206
+ * @param {RecordIdentifier|{ type: string }} identifier
207
+ * @return {RelationshipsSchema}
208
+ */
209
+ relationshipsDefinitionFor(identifier: RecordIdentifier | {
210
+ type: string;
211
+ }): RelationshipsSchema;
212
+ }
213
+ //# sourceMappingURL=schema-service.d.ts.map
214
+ }
@@ -1,15 +1,17 @@
1
- import type { Value } from '@warp-drive/core-types/json/raw';
2
- export interface BaseFinderOptions {
3
- reload?: boolean;
4
- backgroundReload?: boolean;
5
- include?: string | string[];
6
- adapterOptions?: Record<string, unknown>;
7
- }
8
- export interface FindRecordOptions extends BaseFinderOptions {
9
- preload?: Record<string, Value>;
10
- }
11
- export type QueryOptions = {
12
- [K in string | 'adapterOptions']?: K extends 'adapterOptions' ? Record<string, unknown> : unknown;
13
- };
14
- export type FindAllOptions = BaseFinderOptions;
15
- //# sourceMappingURL=store.d.ts.map
1
+ declare module '@ember-data/store/-types/q/store' {
2
+ import type { Value } from '@warp-drive/core-types/json/raw';
3
+ export interface BaseFinderOptions {
4
+ reload?: boolean;
5
+ backgroundReload?: boolean;
6
+ include?: string | string[];
7
+ adapterOptions?: Record<string, unknown>;
8
+ }
9
+ export interface FindRecordOptions extends BaseFinderOptions {
10
+ preload?: Record<string, Value>;
11
+ }
12
+ export type QueryOptions = {
13
+ [K in string | 'adapterOptions']?: K extends 'adapterOptions' ? Record<string, unknown> : unknown;
14
+ };
15
+ export type FindAllOptions = BaseFinderOptions;
16
+ //# sourceMappingURL=store.d.ts.map
17
+ }