@ember-data/store 5.5.0-alpha.9 → 5.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.
- package/LICENSE.md +19 -7
- package/README.md +21 -12
- package/addon-main.cjs +5 -0
- package/dist/-private.js +2 -0
- package/{addon → dist}/-private.js.map +1 -1
- package/dist/configure-BfLLW6GY.js +161 -0
- package/dist/configure-BfLLW6GY.js.map +1 -0
- package/dist/configure.js +1 -0
- package/dist/configure.js.map +1 -0
- package/dist/index.js +5 -0
- package/{addon → dist}/index.js.map +1 -1
- package/dist/request-state-uRtpn0Lc.js +7709 -0
- package/dist/request-state-uRtpn0Lc.js.map +1 -0
- package/dist/types.js +0 -0
- package/dist/types.js.map +1 -0
- package/logos/NCC-1701-a-blue.svg +4 -0
- package/logos/NCC-1701-a-gold.svg +4 -0
- package/logos/NCC-1701-a-gold_100.svg +1 -0
- package/logos/NCC-1701-a-gold_base-64.txt +1 -0
- package/logos/NCC-1701-a.svg +4 -0
- package/logos/README.md +4 -0
- package/logos/docs-badge.svg +2 -0
- package/logos/github-header.svg +444 -0
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +4 -0
- package/logos/warp-drive-logo-gold.svg +4 -0
- package/package.json +66 -53
- package/unstable-preview-types/-private/cache-handler/handler.d.ts +62 -0
- package/unstable-preview-types/-private/cache-handler/handler.d.ts.map +1 -0
- package/unstable-preview-types/-private/cache-handler/types.d.ts +107 -0
- package/unstable-preview-types/-private/cache-handler/types.d.ts.map +1 -0
- package/unstable-preview-types/-private/cache-handler/utils.d.ts +34 -0
- package/unstable-preview-types/-private/cache-handler/utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/cache-utils.d.ts +11 -0
- package/unstable-preview-types/-private/caches/cache-utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts +180 -0
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/instance-cache.d.ts +64 -0
- package/unstable-preview-types/-private/caches/instance-cache.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/resource-utils.d.ts +12 -0
- package/unstable-preview-types/-private/caches/resource-utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/debug/utils.d.ts +9 -0
- package/unstable-preview-types/-private/debug/utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/document.d.ts +155 -0
- package/unstable-preview-types/-private/document.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +179 -0
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +19 -0
- package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +31 -0
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/cache-manager.d.ts +463 -0
- package/unstable-preview-types/-private/managers/cache-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/notification-manager.d.ts +101 -0
- package/unstable-preview-types/-private/managers/notification-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts +101 -0
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/network/request-cache.d.ts +109 -0
- package/unstable-preview-types/-private/network/request-cache.d.ts.map +1 -0
- package/unstable-preview-types/-private/new-core-tmp/promise-state.d.ts +289 -0
- package/unstable-preview-types/-private/new-core-tmp/promise-state.d.ts.map +1 -0
- package/unstable-preview-types/-private/new-core-tmp/reactivity/configure.d.ts +92 -0
- package/unstable-preview-types/-private/new-core-tmp/reactivity/configure.d.ts.map +1 -0
- package/unstable-preview-types/-private/new-core-tmp/reactivity/internal.d.ts +172 -0
- package/unstable-preview-types/-private/new-core-tmp/reactivity/internal.d.ts.map +1 -0
- package/unstable-preview-types/-private/new-core-tmp/reactivity/signal.d.ts +32 -0
- package/unstable-preview-types/-private/new-core-tmp/reactivity/signal.d.ts.map +1 -0
- package/unstable-preview-types/-private/new-core-tmp/request-state.d.ts +276 -0
- package/unstable-preview-types/-private/new-core-tmp/request-state.d.ts.map +1 -0
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +145 -0
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/record-arrays/many-array.d.ts +203 -0
- package/unstable-preview-types/-private/record-arrays/many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/record-arrays/native-proxy-type-fix.d.ts +118 -0
- package/unstable-preview-types/-private/record-arrays/native-proxy-type-fix.d.ts.map +1 -0
- package/unstable-preview-types/-private/store-service.d.ts +1601 -0
- package/unstable-preview-types/-private/store-service.d.ts.map +1 -0
- package/unstable-preview-types/-private/store-service.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/store-service.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/coerce-id.d.ts +10 -0
- package/unstable-preview-types/-private/utils/coerce-id.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/construct-resource.d.ts +9 -0
- package/unstable-preview-types/-private/utils/construct-resource.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +4 -0
- package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +4 -0
- package/unstable-preview-types/-private/utils/normalize-model-name.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +4 -0
- package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts.map +1 -0
- package/unstable-preview-types/-private.d.ts +33 -0
- package/unstable-preview-types/-private.d.ts.map +1 -0
- package/unstable-preview-types/-types/overview.d.ts +21 -0
- package/unstable-preview-types/-types/overview.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/cache-capabilities-manager.d.ts +110 -0
- package/unstable-preview-types/-types/q/cache-capabilities-manager.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/ds-model.d.ts +25 -0
- package/unstable-preview-types/-types/q/ds-model.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/identifier.d.ts +193 -0
- package/unstable-preview-types/-types/q/identifier.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/promise-proxies.d.ts +4 -0
- package/unstable-preview-types/-types/q/promise-proxies.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts +36 -0
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/record-instance.d.ts +29 -0
- package/unstable-preview-types/-types/q/record-instance.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/schema-service.d.ts +354 -0
- package/unstable-preview-types/-types/q/schema-service.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/store.d.ts +38 -0
- package/unstable-preview-types/-types/q/store.d.ts.map +1 -0
- package/unstable-preview-types/configure.d.ts +21 -0
- package/unstable-preview-types/configure.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +229 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
- package/unstable-preview-types/types.d.ts +7 -0
- package/unstable-preview-types/types.d.ts.map +1 -0
- package/addon/-private.js +0 -1
- package/addon/index.js +0 -1
- package/addon/store-service-45bbfe5a.js +0 -5619
- package/addon/store-service-45bbfe5a.js.map +0 -1
- package/addon-main.js +0 -93
- /package/{ember-data-logo-dark.svg → logos/ember-data-logo-dark.svg} +0 -0
- /package/{ember-data-logo-light.svg → logos/ember-data-logo-light.svg} +0 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
declare module '@ember-data/store/-types/q/schema-service' {
|
|
2
|
+
/**
|
|
3
|
+
@module @ember-data/store
|
|
4
|
+
*/
|
|
5
|
+
import type { StableRecordIdentifier } from '@warp-drive/core-types';
|
|
6
|
+
import type { RecordIdentifier } from '@warp-drive/core-types/identifier';
|
|
7
|
+
import type { ObjectValue } from '@warp-drive/core-types/json/raw';
|
|
8
|
+
import type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';
|
|
9
|
+
import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, LegacyAttributeField, LegacyRelationshipField, ObjectField, Schema } from '@warp-drive/core-types/schema/fields';
|
|
10
|
+
export type AttributesSchema = Record<string, LegacyAttributeField>;
|
|
11
|
+
export type RelationshipsSchema = Record<string, LegacyRelationshipField>;
|
|
12
|
+
interface ObjectWithStringTypeProperty {
|
|
13
|
+
type: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The SchemaService provides the ability to query for information about the structure
|
|
17
|
+
* of any resource type.
|
|
18
|
+
*
|
|
19
|
+
* Applications can provide any implementation of the SchemaService they please so long
|
|
20
|
+
* as it conforms to this interface.
|
|
21
|
+
*
|
|
22
|
+
* The design of the service means that schema information could be lazily populated,
|
|
23
|
+
* derived-on-demand, or progressively enhanced during the course of an application's runtime.
|
|
24
|
+
* The primary requirement is merely that any information the service needs to correctly
|
|
25
|
+
* respond to an inquest is available by the time it is asked.
|
|
26
|
+
*
|
|
27
|
+
* The `@ember-data/model` package provides an implementation of this service which
|
|
28
|
+
* makes use of your model classes as the source of information to respond to queries
|
|
29
|
+
* about resource schema. While this is useful, this may not be ideal for your application.
|
|
30
|
+
* For instance, Schema information could be sideloaded or pre-flighted for API calls,
|
|
31
|
+
* resulting in no need to bundle and ship potentially large and expensive JSON
|
|
32
|
+
* or large Javascript based Models to pull information from.
|
|
33
|
+
*
|
|
34
|
+
* To register a custom schema implementation, implement the store's `createSchemaService`
|
|
35
|
+
* hook to return an instance of your service.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import Store from '@ember-data/store';
|
|
39
|
+
* import CustomSchemas from './custom-schemas';
|
|
40
|
+
*
|
|
41
|
+
* export default class extends Store {
|
|
42
|
+
* createSchemaService() {
|
|
43
|
+
* return 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 fields() {
|
|
56
|
+
* return this.store
|
|
57
|
+
* .schema
|
|
58
|
+
* .fields(this.args.dataType);
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @class <Interface> SchemaService
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export interface SchemaService {
|
|
67
|
+
/**
|
|
68
|
+
* DEPRECATED - use `hasResource` instead
|
|
69
|
+
*
|
|
70
|
+
* Queries whether the SchemaService recognizes `type` as a resource type
|
|
71
|
+
*
|
|
72
|
+
* @method doesTypeExist
|
|
73
|
+
* @public
|
|
74
|
+
* @deprecated
|
|
75
|
+
* @param {String} type
|
|
76
|
+
* @return {Boolean}
|
|
77
|
+
*/
|
|
78
|
+
doesTypeExist?(type: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Queries whether the SchemaService recognizes `type` as a resource type
|
|
81
|
+
*
|
|
82
|
+
* @method hasResource
|
|
83
|
+
* @public
|
|
84
|
+
* @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
|
|
85
|
+
* @return {Boolean}
|
|
86
|
+
*/
|
|
87
|
+
hasResource(resource: ObjectWithStringTypeProperty | StableRecordIdentifier): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Queries whether the SchemaService recognizes `type` as a resource trait
|
|
90
|
+
*
|
|
91
|
+
* @method hasTrait
|
|
92
|
+
* @public
|
|
93
|
+
* @param {String} type
|
|
94
|
+
* @return {Boolean}
|
|
95
|
+
*/
|
|
96
|
+
hasTrait(type: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Queries whether the given resource has the given trait
|
|
99
|
+
*
|
|
100
|
+
* @method resourceHasTrait
|
|
101
|
+
* @public
|
|
102
|
+
* @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
|
|
103
|
+
* @param {String} trait
|
|
104
|
+
* @return {Boolean}
|
|
105
|
+
*/
|
|
106
|
+
resourceHasTrait(resource: ObjectWithStringTypeProperty | StableRecordIdentifier, trait: string): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Queries for the fields of a given resource type or resource identity.
|
|
109
|
+
*
|
|
110
|
+
* Should error if the resource type is not recognized.
|
|
111
|
+
*
|
|
112
|
+
* @method fields
|
|
113
|
+
* @public
|
|
114
|
+
* @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
|
|
115
|
+
* @return {Map<string, FieldSchema>}
|
|
116
|
+
*/
|
|
117
|
+
fields(resource: ObjectWithStringTypeProperty | StableRecordIdentifier): Map<string, FieldSchema>;
|
|
118
|
+
/**
|
|
119
|
+
* Returns the transformation registered with the name provided
|
|
120
|
+
* by `field.type`. Validates that the field is a valid transformable.
|
|
121
|
+
*
|
|
122
|
+
* @method transformation
|
|
123
|
+
* @public
|
|
124
|
+
* @param {TransformableField|ObjectWithStringTypeProperty} field
|
|
125
|
+
* @return {Transformation}
|
|
126
|
+
*/
|
|
127
|
+
transformation(field: GenericField | ObjectField | ArrayField | ObjectWithStringTypeProperty): Transformation;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the hash function registered with the name provided
|
|
130
|
+
* by `field.type`. Validates that the field is a valid HashField.
|
|
131
|
+
*
|
|
132
|
+
* @method hashFn
|
|
133
|
+
* @public
|
|
134
|
+
* @param {HashField|ObjectWithStringTypeProperty} field
|
|
135
|
+
* @return {HashFn}
|
|
136
|
+
*/
|
|
137
|
+
hashFn(field: HashField | ObjectWithStringTypeProperty): HashFn;
|
|
138
|
+
/**
|
|
139
|
+
* Returns the derivation registered with the name provided
|
|
140
|
+
* by `field.type`. Validates that the field is a valid DerivedField.
|
|
141
|
+
*
|
|
142
|
+
* @method derivation
|
|
143
|
+
* @public
|
|
144
|
+
* @param {DerivedField|ObjectWithStringTypeProperty} field
|
|
145
|
+
* @return {Derivation}
|
|
146
|
+
*/
|
|
147
|
+
derivation(field: DerivedField | ObjectWithStringTypeProperty): Derivation;
|
|
148
|
+
/**
|
|
149
|
+
* Returns the schema for the provided resource type.
|
|
150
|
+
*
|
|
151
|
+
* @method resource
|
|
152
|
+
* @public
|
|
153
|
+
* @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
|
|
154
|
+
* @return {ResourceSchema}
|
|
155
|
+
*/
|
|
156
|
+
resource(resource: ObjectWithStringTypeProperty | StableRecordIdentifier): Schema;
|
|
157
|
+
/**
|
|
158
|
+
* Enables registration of multiple Schemas at once.
|
|
159
|
+
*
|
|
160
|
+
* This can be useful for either pre-loading schema information
|
|
161
|
+
* or for registering schema information delivered by API calls
|
|
162
|
+
* or other sources just-in-time.
|
|
163
|
+
*
|
|
164
|
+
* @method registerResources
|
|
165
|
+
* @public
|
|
166
|
+
* @param {Schema[]} schemas
|
|
167
|
+
*/
|
|
168
|
+
registerResources(schemas: Schema[]): void;
|
|
169
|
+
/**
|
|
170
|
+
* Enables registration of a single Schema representing either
|
|
171
|
+
* a resource in PolarisMode or LegacyMode or an ObjectSchema
|
|
172
|
+
* representing an embedded structure in other schemas.
|
|
173
|
+
*
|
|
174
|
+
* This can be useful for either pre-loading schema information
|
|
175
|
+
* or for registering schema information delivered by API calls
|
|
176
|
+
* or other sources just-in-time.
|
|
177
|
+
*
|
|
178
|
+
* @method registerResource
|
|
179
|
+
* @public
|
|
180
|
+
* @param {Schema} schema
|
|
181
|
+
*/
|
|
182
|
+
registerResource(schema: Schema): void;
|
|
183
|
+
/**
|
|
184
|
+
* Enables registration of a transformation.
|
|
185
|
+
*
|
|
186
|
+
* The transformation can later be retrieved by the name
|
|
187
|
+
* attached to it's `[Type]` property.
|
|
188
|
+
*
|
|
189
|
+
* @method registerTransformations
|
|
190
|
+
* @public
|
|
191
|
+
* @param {Transformation} transform
|
|
192
|
+
*/
|
|
193
|
+
registerTransformation(transform: Transformation): void;
|
|
194
|
+
/**
|
|
195
|
+
* Enables registration of a derivation.
|
|
196
|
+
*
|
|
197
|
+
* The derivation can later be retrieved by the name
|
|
198
|
+
* attached to it's `[Type]` property.
|
|
199
|
+
*
|
|
200
|
+
* @method registerDerivations
|
|
201
|
+
* @public
|
|
202
|
+
* @param {Derivation} derivation
|
|
203
|
+
*/
|
|
204
|
+
registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void;
|
|
205
|
+
/**
|
|
206
|
+
* Enables registration of a hashing function
|
|
207
|
+
*
|
|
208
|
+
* The hashing function can later be retrieved by the name
|
|
209
|
+
* attached to it's `[Type]` property.
|
|
210
|
+
*
|
|
211
|
+
* @method registerHashFn
|
|
212
|
+
* @public
|
|
213
|
+
* @param {HashFn} hashfn
|
|
214
|
+
*/
|
|
215
|
+
registerHashFn(hashFn: HashFn): void;
|
|
216
|
+
/**
|
|
217
|
+
* DEPRECATED - use `fields` instead
|
|
218
|
+
*
|
|
219
|
+
* Returns definitions for all properties of the specified resource
|
|
220
|
+
* that are considered "attributes". Generally these are properties
|
|
221
|
+
* that are not related to book-keeping state on the client and do
|
|
222
|
+
* not represent a linkage to another resource.
|
|
223
|
+
*
|
|
224
|
+
* The return value should be a dictionary of key:value pairs
|
|
225
|
+
* where the `key` is the attribute or property's name and `value`
|
|
226
|
+
* is an object with at least the property `name` which should also
|
|
227
|
+
* match `key`.
|
|
228
|
+
*
|
|
229
|
+
* Optionally, this object may also specify `type`, which should
|
|
230
|
+
* be a string reference to a `transform`, and `options` which
|
|
231
|
+
* should be dictionary in which any key:value pairs are permissable.
|
|
232
|
+
*
|
|
233
|
+
* For instance, when using `@ember-data/model`, the following attribute
|
|
234
|
+
* definition:
|
|
235
|
+
*
|
|
236
|
+
* ```ts
|
|
237
|
+
* class extends Model {
|
|
238
|
+
* @attr('string', { defaultValue: 'hello' }) greeting;
|
|
239
|
+
* @attr('date') birthday;
|
|
240
|
+
* @attr firstName;
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* Would be returned as:
|
|
245
|
+
*
|
|
246
|
+
* ```js
|
|
247
|
+
* {
|
|
248
|
+
* greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } },
|
|
249
|
+
* birthday: { name: 'birthday', type: 'date' },
|
|
250
|
+
* firstName: { name: 'firstName' }
|
|
251
|
+
* }
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* @method attributesDefinitionFor
|
|
255
|
+
* @public
|
|
256
|
+
* @deprecated
|
|
257
|
+
* @param {RecordIdentifier|ObjectWithStringTypeProperty} identifier
|
|
258
|
+
* @return {AttributesSchema}
|
|
259
|
+
*/
|
|
260
|
+
attributesDefinitionFor?(identifier: RecordIdentifier | ObjectWithStringTypeProperty): AttributesSchema;
|
|
261
|
+
/**
|
|
262
|
+
* DEPRECATED - use `fields` instead
|
|
263
|
+
*
|
|
264
|
+
* Returns definitions for all properties of the specified resource
|
|
265
|
+
* that are considered "relationships". Generally these are properties
|
|
266
|
+
* that represent a linkage to another resource.
|
|
267
|
+
*
|
|
268
|
+
* The return value should be a dictionary of key:value pairs
|
|
269
|
+
* where the `key` is the relationship or property's name and `value`
|
|
270
|
+
* is an object with at least the following properties:
|
|
271
|
+
*
|
|
272
|
+
* - `name` which should also match the `key` used in the dictionary.
|
|
273
|
+
* - `kind` which should be either `belongsTo` or `hasMany`
|
|
274
|
+
* - `type` which should be the related resource's string "type"
|
|
275
|
+
* - `options` which should be a dictionary allowing any key but with
|
|
276
|
+
* at least the below keys present.
|
|
277
|
+
*
|
|
278
|
+
* - `options.async` a boolean representing whether data for this relationship is
|
|
279
|
+
* typically loaded on-demand.
|
|
280
|
+
* - `options.inverse` a string or null representing the field name / key of the
|
|
281
|
+
* corresponding relationship on the inverse resource.
|
|
282
|
+
*
|
|
283
|
+
* Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance)
|
|
284
|
+
*
|
|
285
|
+
* - `options.polymorphic` a boolean representing whether multiple resource types
|
|
286
|
+
* can be used to satisfy this relationship.
|
|
287
|
+
* - `options.as` a string representing the abstract type that the concrete side of
|
|
288
|
+
* a relationship must specify when fulfilling a polymorphic inverse.
|
|
289
|
+
*
|
|
290
|
+
* For example, the following Model using @ember-data/model would generate this relationships
|
|
291
|
+
* definition by default:
|
|
292
|
+
*
|
|
293
|
+
* ```js
|
|
294
|
+
* class User extends Model {
|
|
295
|
+
* @belongsTo('user', { async: false, inverse: null }) bestFriend;
|
|
296
|
+
* @hasMany('user', { async: true, inverse: 'friends' }) friends;
|
|
297
|
+
* @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets;
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* Which would be returned as
|
|
302
|
+
*
|
|
303
|
+
* ```js
|
|
304
|
+
* {
|
|
305
|
+
* bestFriend: {
|
|
306
|
+
* name: 'bestFriend',
|
|
307
|
+
* kind: 'belongsTo',
|
|
308
|
+
* type: 'user',
|
|
309
|
+
* options: {
|
|
310
|
+
* async: false,
|
|
311
|
+
* inverse: null
|
|
312
|
+
* }
|
|
313
|
+
* },
|
|
314
|
+
* friends: {
|
|
315
|
+
* name: 'friends',
|
|
316
|
+
* kind: 'hasMany',
|
|
317
|
+
* type: 'user',
|
|
318
|
+
* options: {
|
|
319
|
+
* async: true,
|
|
320
|
+
* inverse: 'friends'
|
|
321
|
+
* }
|
|
322
|
+
* },
|
|
323
|
+
* pets: {
|
|
324
|
+
* name: 'pets',
|
|
325
|
+
* kind: 'hasMany',
|
|
326
|
+
* type: 'pet',
|
|
327
|
+
* options: {
|
|
328
|
+
* async: false,
|
|
329
|
+
* polymorphic: true,
|
|
330
|
+
* inverse: 'owner'
|
|
331
|
+
* }
|
|
332
|
+
* },
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* @method relationshipsDefinitionFor
|
|
337
|
+
* @public
|
|
338
|
+
* @deprecated
|
|
339
|
+
* @param {RecordIdentifier|ObjectWithStringTypeProperty} identifier
|
|
340
|
+
* @return {RelationshipsSchema}
|
|
341
|
+
*/
|
|
342
|
+
relationshipsDefinitionFor?(identifier: RecordIdentifier | ObjectWithStringTypeProperty): RelationshipsSchema;
|
|
343
|
+
/**
|
|
344
|
+
* Returns all known resource types
|
|
345
|
+
*
|
|
346
|
+
* @method resourceTypes
|
|
347
|
+
* @public
|
|
348
|
+
* @return {String[]}
|
|
349
|
+
*/
|
|
350
|
+
resourceTypes(): Readonly<string[]>;
|
|
351
|
+
}
|
|
352
|
+
export {};
|
|
353
|
+
}
|
|
354
|
+
//# sourceMappingURL=schema-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-service.d.ts","sourceRoot":"","sources":["../../../src/-types/q/schema-service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare module '@ember-data/store/-types/q/store' {
|
|
2
|
+
import type { Value } from '@warp-drive/core-types/json/raw';
|
|
3
|
+
import type { Includes, TypedRecordInstance } from '@warp-drive/core-types/record';
|
|
4
|
+
export interface BaseFinderOptions<T = unknown> {
|
|
5
|
+
reload?: boolean;
|
|
6
|
+
backgroundReload?: boolean;
|
|
7
|
+
include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
|
|
8
|
+
adapterOptions?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface FindRecordOptions<T = unknown> extends BaseFinderOptions<T> {
|
|
11
|
+
/**
|
|
12
|
+
* Data to preload into the store before the request is made.
|
|
13
|
+
* This feature is *highly* discouraged and has no corresponding
|
|
14
|
+
* feature when using builders and handlers.
|
|
15
|
+
*
|
|
16
|
+
* Excepting relationships: the data should be in the form of a
|
|
17
|
+
* JSON object where the keys are fields on the record and the value
|
|
18
|
+
* is the raw value to be added to the cache.
|
|
19
|
+
*
|
|
20
|
+
* Relationships can either be provided as string IDs from which
|
|
21
|
+
* an identifier will be built base upon the relationship's expected
|
|
22
|
+
* resource type, or be record instances from which the identifier
|
|
23
|
+
* will be extracted.
|
|
24
|
+
*
|
|
25
|
+
* @typedoc
|
|
26
|
+
*/
|
|
27
|
+
preload?: Record<string, Value>;
|
|
28
|
+
}
|
|
29
|
+
export type QueryOptions = {
|
|
30
|
+
[K in string | 'adapterOptions']?: K extends 'adapterOptions' ? Record<string, unknown> : unknown;
|
|
31
|
+
};
|
|
32
|
+
export type FindAllOptions<T = unknown> = BaseFinderOptions<T>;
|
|
33
|
+
export type LegacyResourceQuery<T = unknown> = {
|
|
34
|
+
include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
|
|
35
|
+
[key: string]: Value | undefined;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/-types/q/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEnF,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,CAAC,SAAS,mBAAmB,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C;AACD,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC1E;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,YAAY,GAAG;KACxB,CAAC,IAAI,MAAM,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO;CAClG,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAC/D,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,OAAO,IAAI;IAC7C,OAAO,CAAC,EAAE,CAAC,SAAS,mBAAmB,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5E,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;CAClC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare module '@ember-data/store/configure' {
|
|
2
|
+
/**
|
|
3
|
+
* Provides a configuration API for the reactivity system
|
|
4
|
+
* that WarpDrive should use.
|
|
5
|
+
*
|
|
6
|
+
* @module @ember-data/store/configure
|
|
7
|
+
* @main @ember-data/store/configure
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Configures the signals implementation to use. Supports multiple
|
|
11
|
+
* implementations simultaneously.
|
|
12
|
+
*
|
|
13
|
+
* @method setupSignals
|
|
14
|
+
* @static
|
|
15
|
+
* @for @ember-data/store/configure
|
|
16
|
+
* @public
|
|
17
|
+
* @param {function} buildConfig - a function that takes options and returns a configuration object
|
|
18
|
+
*/
|
|
19
|
+
export { setupSignals } from '@ember-data/store/-private/new-core-tmp/reactivity/configure';
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=configure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/// <reference path="./types.d.ts" />
|
|
2
|
+
/// <reference path="./configure.d.ts" />
|
|
3
|
+
/// <reference path="./-private.d.ts" />
|
|
4
|
+
/// <reference path="./-types/overview.d.ts" />
|
|
5
|
+
/// <reference path="./-types/q/store.d.ts" />
|
|
6
|
+
/// <reference path="./-types/q/identifier.d.ts" />
|
|
7
|
+
/// <reference path="./-types/q/promise-proxies.d.ts" />
|
|
8
|
+
/// <reference path="./-types/q/schema-service.d.ts" />
|
|
9
|
+
/// <reference path="./-types/q/record-instance.d.ts" />
|
|
10
|
+
/// <reference path="./-types/q/record-data-json-api.d.ts" />
|
|
11
|
+
/// <reference path="./-types/q/cache-capabilities-manager.d.ts" />
|
|
12
|
+
/// <reference path="./-types/q/ds-model.d.ts" />
|
|
13
|
+
/// <reference path="./-private/store-service.d.ts" />
|
|
14
|
+
/// <reference path="./-private/store-service.type-test.d.ts" />
|
|
15
|
+
/// <reference path="./-private/document.d.ts" />
|
|
16
|
+
/// <reference path="./-private/caches/cache-utils.d.ts" />
|
|
17
|
+
/// <reference path="./-private/caches/resource-utils.d.ts" />
|
|
18
|
+
/// <reference path="./-private/caches/instance-cache.d.ts" />
|
|
19
|
+
/// <reference path="./-private/caches/identifier-cache.d.ts" />
|
|
20
|
+
/// <reference path="./-private/legacy-model-support/shim-model-class.d.ts" />
|
|
21
|
+
/// <reference path="./-private/legacy-model-support/record-reference.d.ts" />
|
|
22
|
+
/// <reference path="./-private/managers/notification-manager.d.ts" />
|
|
23
|
+
/// <reference path="./-private/managers/record-array-manager.d.ts" />
|
|
24
|
+
/// <reference path="./-private/managers/cache-capabilities-manager.d.ts" />
|
|
25
|
+
/// <reference path="./-private/managers/cache-manager.d.ts" />
|
|
26
|
+
/// <reference path="./-private/new-core-tmp/request-state.d.ts" />
|
|
27
|
+
/// <reference path="./-private/new-core-tmp/promise-state.d.ts" />
|
|
28
|
+
/// <reference path="./-private/new-core-tmp/reactivity/internal.d.ts" />
|
|
29
|
+
/// <reference path="./-private/new-core-tmp/reactivity/signal.d.ts" />
|
|
30
|
+
/// <reference path="./-private/new-core-tmp/reactivity/configure.d.ts" />
|
|
31
|
+
/// <reference path="./-private/debug/utils.d.ts" />
|
|
32
|
+
/// <reference path="./-private/network/request-cache.d.ts" />
|
|
33
|
+
/// <reference path="./-private/cache-handler/utils.d.ts" />
|
|
34
|
+
/// <reference path="./-private/cache-handler/types.d.ts" />
|
|
35
|
+
/// <reference path="./-private/cache-handler/handler.d.ts" />
|
|
36
|
+
/// <reference path="./-private/utils/normalize-model-name.d.ts" />
|
|
37
|
+
/// <reference path="./-private/utils/uuid-polyfill.d.ts" />
|
|
38
|
+
/// <reference path="./-private/utils/construct-resource.d.ts" />
|
|
39
|
+
/// <reference path="./-private/utils/is-non-empty-string.d.ts" />
|
|
40
|
+
/// <reference path="./-private/utils/coerce-id.d.ts" />
|
|
41
|
+
/// <reference path="./-private/record-arrays/identifier-array.d.ts" />
|
|
42
|
+
/// <reference path="./-private/record-arrays/many-array.d.ts" />
|
|
43
|
+
/// <reference path="./-private/record-arrays/native-proxy-type-fix.d.ts" />
|
|
44
|
+
declare module '@ember-data/store' {
|
|
45
|
+
/**
|
|
46
|
+
* <p align="center">
|
|
47
|
+
* <img
|
|
48
|
+
* class="project-logo"
|
|
49
|
+
* src="https://raw.githubusercontent.com/emberjs/data/4612c9354e4c54d53327ec2cf21955075ce21294/ember-data-logo-light.svg#gh-light-mode-only"
|
|
50
|
+
* alt="EmberData Store"
|
|
51
|
+
* width="240px"
|
|
52
|
+
* title="EmberData Store"
|
|
53
|
+
* />
|
|
54
|
+
* </p>
|
|
55
|
+
*
|
|
56
|
+
* This package provides [*Ember***Data**](https://github.com/emberjs/data/)'s `Store` class.
|
|
57
|
+
*
|
|
58
|
+
* A [Store](https://api.emberjs.com/ember-data/release/classes/Store) coordinates interaction between your application, a [Cache](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache),
|
|
59
|
+
* and sources of data (such as your API or a local persistence layer) accessed via a [RequestManager](https://github.com/emberjs/data/tree/main/packages/request).
|
|
60
|
+
*
|
|
61
|
+
* Optionally, a Store can be configured to hydrate the response data into rich presentation classes.
|
|
62
|
+
*
|
|
63
|
+
* ## Installation
|
|
64
|
+
*
|
|
65
|
+
* If you have installed `ember-data` then you already have this package installed.
|
|
66
|
+
* Otherwise you can install it using your javascript package manager of choice.
|
|
67
|
+
* For instance with [pnpm](https://pnpm.io/)
|
|
68
|
+
*
|
|
69
|
+
* ```
|
|
70
|
+
* pnpm add @ember-data/store
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* After installing you will want to configure your first `Store`. Read more below
|
|
74
|
+
* for how to create and configure stores for your application.
|
|
75
|
+
*
|
|
76
|
+
*
|
|
77
|
+
* ## 🔨 Creating A Store
|
|
78
|
+
*
|
|
79
|
+
* To use a `Store` we will need to do few things: add a [Cache](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache)
|
|
80
|
+
* to store data **in-memory**, add a [Handler](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache) to fetch data from a source,
|
|
81
|
+
* and implement `instantiateRecord` to tell the store how to display the data for individual resources.
|
|
82
|
+
*
|
|
83
|
+
* > **Note**
|
|
84
|
+
* > If you are using the package `ember-data` then a JSON:API cache, RequestManager, LegacyNetworkHandler,
|
|
85
|
+
* > and `instantiateRecord` are configured for you by default.
|
|
86
|
+
*
|
|
87
|
+
* ### Configuring A Cache
|
|
88
|
+
*
|
|
89
|
+
* To start, let's install a [JSON:API](https://jsonapi.org/) cache. If your app uses `GraphQL` or `REST` other
|
|
90
|
+
* caches may better fit your data. You can author your own cache by creating one that
|
|
91
|
+
* conforms to the [spec](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache).
|
|
92
|
+
*
|
|
93
|
+
* The package `@ember-data/json-api` provides a [JSON:API](https://jsonapi.org/) cache we can use.
|
|
94
|
+
* After installing it, we can configure the store to use this cache.
|
|
95
|
+
*
|
|
96
|
+
* ```js
|
|
97
|
+
* import Store from '@ember-data/store';
|
|
98
|
+
* import Cache from '@ember-data/json-api';
|
|
99
|
+
*
|
|
100
|
+
* class extends Store {
|
|
101
|
+
* createCache(storeWrapper) {
|
|
102
|
+
* return new Cache(storeWrapper);
|
|
103
|
+
* }
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* Now that we have a `cache` let's setup something to handle fetching
|
|
108
|
+
* and saving data via our API.
|
|
109
|
+
*
|
|
110
|
+
* > **Note**
|
|
111
|
+
* > The `ember-data` package automatically includes and configures
|
|
112
|
+
* > the `@ember-data/json-api` cache for you.
|
|
113
|
+
*
|
|
114
|
+
* ### Handling Requests
|
|
115
|
+
*
|
|
116
|
+
* When *Ember***Data** needs to fetch or save data it will pass that request to your application's `RequestManager` for fulfillment. How this fulfillment occurs (in-memory, device storage, via single or multiple API requests, etc.) is then up to the registered request handlers.
|
|
117
|
+
*
|
|
118
|
+
* To start, let's install the `RequestManager` from `@ember-data/request` and the basic `Fetch` handler from ``@ember-data/request/fetch`.
|
|
119
|
+
*
|
|
120
|
+
* > **Note**
|
|
121
|
+
* > If your app uses `GraphQL`, `REST` or different conventions for `JSON:API` than your cache expects, other handlers may better fit your data. You can author your own handler by creating one that conforms to the [handler interface](https://github.com/emberjs/data/tree/main/packages/request#handling-requests).
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* import Store from '@ember-data/store';
|
|
125
|
+
* import RequestManager from '@ember-data/request';
|
|
126
|
+
* import Fetch from '@ember-data/request/fetch';
|
|
127
|
+
*
|
|
128
|
+
* export default class extends Store {
|
|
129
|
+
* requestManager = new RequestManager()
|
|
130
|
+
* .use([Fetch]);
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* **Using RequestManager as a Service**
|
|
135
|
+
*
|
|
136
|
+
* Alternatively if you have configured the `RequestManager` to be a service you may re-use it.
|
|
137
|
+
*
|
|
138
|
+
* *app/services/request.js*
|
|
139
|
+
* ```ts
|
|
140
|
+
* import RequestManager from '@ember-data/request';
|
|
141
|
+
* import Fetch from '@ember-data/request/fetch';
|
|
142
|
+
*
|
|
143
|
+
* export default class extends RequestManager {
|
|
144
|
+
* constructor(createArgs) {
|
|
145
|
+
* super(createArgs);
|
|
146
|
+
* this.use([Fetch]);
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* *app/services/store.js*
|
|
152
|
+
* ```ts
|
|
153
|
+
* import Store from '@ember-data/store';
|
|
154
|
+
* import { service } from '@ember/service';
|
|
155
|
+
*
|
|
156
|
+
* export default class extends Store {
|
|
157
|
+
* @service('request') requestManager
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
*
|
|
162
|
+
* ### Presenting Data from the Cache
|
|
163
|
+
*
|
|
164
|
+
* Now that we have a source and a cache for our data, we need to configure how
|
|
165
|
+
* the Store delivers that data back to our application. We do this via the hook
|
|
166
|
+
* [instantiateRecord](https://api.emberjs.com/ember-data/release/classes/Store/methods/instantiateRecord%20(hook)?anchor=instantiateRecord%20(hook)),
|
|
167
|
+
* which allows us to transform the data for a resource before handing it to the application.
|
|
168
|
+
*
|
|
169
|
+
* A naive way to present the data would be to return it as JSON. Typically instead
|
|
170
|
+
* this hook will be used to add reactivity and make each unique resource a singleton,
|
|
171
|
+
* ensuring that if the cache updates our presented data will reflect the new state.
|
|
172
|
+
*
|
|
173
|
+
* Below is an example of using the hooks `instantiateRecord` and a `teardownRecord`
|
|
174
|
+
* to provide minimal read-only reactive state for simple resources.
|
|
175
|
+
*
|
|
176
|
+
* ```ts
|
|
177
|
+
* import Store, { recordIdentifierFor } from '@ember-data/store';
|
|
178
|
+
* import { TrackedObject } from 'tracked-built-ins';
|
|
179
|
+
*
|
|
180
|
+
* class extends Store {
|
|
181
|
+
* instantiateRecord(identifier) {
|
|
182
|
+
* const { cache, notifications } = this;
|
|
183
|
+
*
|
|
184
|
+
* // create a TrackedObject with our attributes, id and type
|
|
185
|
+
* const record = new TrackedObject(Object.assign({}, cache.peek(identifier)));
|
|
186
|
+
* record.type = identifier.type;
|
|
187
|
+
* record.id = identifier.id;
|
|
188
|
+
*
|
|
189
|
+
* notifications.subscribe(identifier, (_, change) => {
|
|
190
|
+
* if (change === 'attributes') {
|
|
191
|
+
* Object.assign(record, cache.peek(identifier));
|
|
192
|
+
* }
|
|
193
|
+
* });
|
|
194
|
+
*
|
|
195
|
+
* return record;
|
|
196
|
+
* }
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* Because `instantiateRecord` is opaque to the nature of the record, an implementation
|
|
201
|
+
* can be anything from a fairly simple object to a robust proxy that intelligently links
|
|
202
|
+
* together associated records through relationships.
|
|
203
|
+
*
|
|
204
|
+
* This also enables creating a record that separates `edit` flows from `create` flows
|
|
205
|
+
* entirely. A record class might choose to implement a `checkout`method that gives access
|
|
206
|
+
* to an editable instance while the primary record continues to be read-only and reflect
|
|
207
|
+
* only persisted (non-mutated) state.
|
|
208
|
+
*
|
|
209
|
+
* Typically you will choose an existing record implementation such as `@ember-data/model`
|
|
210
|
+
* for your application.
|
|
211
|
+
*
|
|
212
|
+
* Because of the boundaries around instantiation and the cache, record implementations
|
|
213
|
+
* should be capable of interop both with each other and with any `Cache`. Due to this,
|
|
214
|
+
* if needed an application can utilize multiple record implementations and multiple cache
|
|
215
|
+
* implementations either to support enhanced features for only a subset of records or to
|
|
216
|
+
* be able to incrementally migrate from one record/cache to another record or cache.
|
|
217
|
+
*
|
|
218
|
+
* > **Note**
|
|
219
|
+
* > The `ember-data` package automatically includes the `@ember-data/model`
|
|
220
|
+
* > package and configures it for you.
|
|
221
|
+
*
|
|
222
|
+
* @module @ember-data/store
|
|
223
|
+
* @main @ember-data/store
|
|
224
|
+
*/
|
|
225
|
+
export { Store as default, type StoreRequestContext, CacheHandler, type Document, type CachePolicy, type StoreRequestInput, recordIdentifierFor, storeFor, } from '@ember-data/store/-private';
|
|
226
|
+
export type { DocumentCacheOperation, CacheOperation, NotificationType, } from '@ember-data/store/-private/managers/notification-manager';
|
|
227
|
+
export { setIdentifierGenerationMethod, setIdentifierUpdateMethod, setIdentifierForgetMethod, setIdentifierResetMethod, setKeyInfoForResource, } from '@ember-data/store/-private/caches/identifier-cache';
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmLG;AACH,OAAO,EACL,KAAK,IAAI,OAAO,EAChB,KAAK,mBAAmB,EACxB,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,sBAAsB,EACtB,cAAc,EACd,gBAAgB,GACjB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare module '@ember-data/store/types' {
|
|
2
|
+
export type { CacheCapabilitiesManager } from '@ember-data/store/-types/q/cache-capabilities-manager';
|
|
3
|
+
export type { ModelSchema } from '@ember-data/store/-types/q/ds-model';
|
|
4
|
+
export type { SchemaService } from '@ember-data/store/-types/q/schema-service';
|
|
5
|
+
export type { BaseFinderOptions, FindRecordOptions, LegacyResourceQuery, QueryOptions, FindAllOptions, } from '@ember-data/store/-types/q/store';
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,kBAAkB,CAAC"}
|