@warp-drive/core 5.8.0-alpha.3 → 5.8.0-alpha.5
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/README.md +1 -1
- package/declarations/reactive/-private/schema.d.ts +76 -3
- package/declarations/store/-private/caches/instance-cache.d.ts +2 -3
- package/declarations/store/-private/default-cache-policy.d.ts +76 -59
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/-private/store-service.d.ts +41 -62
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/deprecated/store.d.ts +32 -31
- package/declarations/{store/-types/q → types/schema}/schema-service.d.ts +11 -9
- package/declarations/types.d.ts +1 -1
- package/dist/{request-state-CUuZzgvE.js → index-MiSBsI57.js} +4497 -3402
- package/dist/index.js +4 -381
- package/dist/reactive.js +4 -743
- package/dist/store/-private.js +1 -1
- package/dist/store.js +84 -47
- package/dist/types/-private.js +1 -1
- package/dist/types/schema/schema-service.js +0 -0
- package/package.json +3 -3
|
@@ -248,13 +248,13 @@ declare module "../-private/store-service" {
|
|
|
248
248
|
}
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
-
See
|
|
251
|
+
See {@link Store.peekRecord | peekRecord} to get the cached version of a record.
|
|
252
252
|
|
|
253
253
|
### Retrieving Related Model Records
|
|
254
254
|
|
|
255
|
-
If you use an adapter such as
|
|
256
|
-
[
|
|
257
|
-
|
|
255
|
+
If you use an adapter such as the
|
|
256
|
+
[JSONAPIAdapter](/api/@warp-drive/legacy/adapter/json-api/classes/JSONAPIAdapter)
|
|
257
|
+
which supports the [{JSON:API} specification](http://jsonapi.org/) and if your server
|
|
258
258
|
endpoint supports the use of an
|
|
259
259
|
['include' query parameter](http://jsonapi.org/format/#fetching-includes),
|
|
260
260
|
you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to
|
|
@@ -421,7 +421,7 @@ declare module "../-private/store-service" {
|
|
|
421
421
|
records in the store:
|
|
422
422
|
|
|
423
423
|
```js [app/adapters/application.js]
|
|
424
|
-
import Adapter from '@
|
|
424
|
+
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
425
425
|
|
|
426
426
|
export default class ApplicationAdapter extends Adapter {
|
|
427
427
|
shouldReloadAll(store, snapshotsArray) {
|
|
@@ -503,8 +503,8 @@ declare module "../-private/store-service" {
|
|
|
503
503
|
|
|
504
504
|
### Retrieving Related Model Records
|
|
505
505
|
|
|
506
|
-
If you use an adapter such as
|
|
507
|
-
[
|
|
506
|
+
If you use an adapter such as the default
|
|
507
|
+
[JSONAPIAdapter](/api/@warp-drive/legacy/adapter/json-api/classes/JSONAPIAdapter)
|
|
508
508
|
that supports the [JSON API specification](http://jsonapi.org/) and if your server
|
|
509
509
|
endpoint supports the use of an
|
|
510
510
|
['include' query parameter](http://jsonapi.org/format/#fetching-includes),
|
|
@@ -535,7 +535,7 @@ declare module "../-private/store-service" {
|
|
|
535
535
|
}
|
|
536
536
|
```
|
|
537
537
|
|
|
538
|
-
See
|
|
538
|
+
See {@link Store.query | query} to only get a subset of records from the server.
|
|
539
539
|
|
|
540
540
|
@public
|
|
541
541
|
@deprecated use {@link Store.request} instead
|
|
@@ -575,7 +575,7 @@ declare module "../-private/store-service" {
|
|
|
575
575
|
|
|
576
576
|
If you do something like this:
|
|
577
577
|
|
|
578
|
-
```
|
|
578
|
+
```js
|
|
579
579
|
store.query('person', { ids: ['1', '2', '3'] });
|
|
580
580
|
```
|
|
581
581
|
|
|
@@ -602,7 +602,7 @@ declare module "../-private/store-service" {
|
|
|
602
602
|
query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<LegacyQueryArray>;
|
|
603
603
|
/**
|
|
604
604
|
This method makes a request for one record, where the `id` is not known
|
|
605
|
-
beforehand (if the `id` is known, use
|
|
605
|
+
beforehand (if the `id` is known, use {@link Store.findRecord | findRecord}
|
|
606
606
|
instead).
|
|
607
607
|
|
|
608
608
|
This method can be used when it is certain that the server will return a
|
|
@@ -611,37 +611,40 @@ declare module "../-private/store-service" {
|
|
|
611
611
|
Each time this method is called a new request is made through the adapter.
|
|
612
612
|
|
|
613
613
|
Let's assume our API provides an endpoint for the currently logged in user
|
|
614
|
-
via:
|
|
615
614
|
|
|
616
|
-
```
|
|
617
|
-
// GET /api/
|
|
615
|
+
```ts
|
|
616
|
+
// GET /api/user/me
|
|
618
617
|
{
|
|
619
|
-
|
|
620
|
-
|
|
618
|
+
data: {
|
|
619
|
+
type: 'user',
|
|
620
|
+
id: '1234',
|
|
621
|
+
attributes: {
|
|
621
622
|
username: 'admin'
|
|
622
623
|
}
|
|
623
624
|
}
|
|
625
|
+
}
|
|
624
626
|
```
|
|
625
627
|
|
|
626
628
|
Since the specific `id` of the `user` is not known beforehand, we can use
|
|
627
629
|
`queryRecord` to get the user:
|
|
628
630
|
|
|
629
|
-
```
|
|
630
|
-
store.queryRecord('user', {})
|
|
631
|
-
|
|
632
|
-
// do thing
|
|
633
|
-
});
|
|
631
|
+
```ts
|
|
632
|
+
const user = await store.queryRecord('user', { me: true });
|
|
633
|
+
user.username; // admin
|
|
634
634
|
```
|
|
635
635
|
|
|
636
636
|
The request is made through the adapters' `queryRecord`:
|
|
637
637
|
|
|
638
|
-
```
|
|
639
|
-
import Adapter from '@
|
|
640
|
-
import $ from 'jquery';
|
|
638
|
+
```ts [app/adapters/user.ts]
|
|
639
|
+
import Adapter from '@warp-drive/legacy/adapter';
|
|
641
640
|
|
|
642
641
|
export default class UserAdapter extends Adapter {
|
|
643
|
-
queryRecord(modelName, query) {
|
|
644
|
-
|
|
642
|
+
async queryRecord(modelName, query) {
|
|
643
|
+
if (query.me) {
|
|
644
|
+
const response = await fetch('/api/me');
|
|
645
|
+
return await response.json();
|
|
646
|
+
}
|
|
647
|
+
throw new Error('Unsupported query');
|
|
645
648
|
}
|
|
646
649
|
}
|
|
647
650
|
```
|
|
@@ -664,7 +667,7 @@ declare module "../-private/store-service" {
|
|
|
664
667
|
}
|
|
665
668
|
```
|
|
666
669
|
|
|
667
|
-
```
|
|
670
|
+
```js
|
|
668
671
|
store.query('user', { username: 'unique' }).then(function(users) {
|
|
669
672
|
return users.firstObject;
|
|
670
673
|
}).then(function(user) {
|
|
@@ -684,7 +687,7 @@ declare module "../-private/store-service" {
|
|
|
684
687
|
}
|
|
685
688
|
```
|
|
686
689
|
|
|
687
|
-
```
|
|
690
|
+
```js
|
|
688
691
|
store.queryRecord('user', { username: 'unique' }).then(function(user) {
|
|
689
692
|
// user is null
|
|
690
693
|
});
|
|
@@ -744,7 +747,7 @@ declare module "../-private/store-service" {
|
|
|
744
747
|
/**
|
|
745
748
|
Returns the schema for a particular resource type (modelName).
|
|
746
749
|
|
|
747
|
-
When used with Model
|
|
750
|
+
When used with [Model](/api/@warp-drive/legacy/model/classes/Model) the return is the model class,
|
|
748
751
|
but this is not guaranteed.
|
|
749
752
|
|
|
750
753
|
If looking to query attribute or relationship information it is
|
|
@@ -754,9 +757,7 @@ declare module "../-private/store-service" {
|
|
|
754
757
|
signatures.
|
|
755
758
|
|
|
756
759
|
The class of a model might be useful if you want to get a list of all the
|
|
757
|
-
relationship names of the model
|
|
758
|
-
[`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames)
|
|
759
|
-
for example.
|
|
760
|
+
relationship names of the model.
|
|
760
761
|
|
|
761
762
|
@public
|
|
762
763
|
@deprecated use {@link Store.schema} instead
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "
|
|
2
|
-
import type { ExtensibleField } from "
|
|
3
|
-
import type { ResourceKey } from "
|
|
4
|
-
import type { ObjectValue } from "
|
|
5
|
-
import type { Derivation, HashFn, Transformation } from "
|
|
6
|
-
import type { ArrayField, CacheableFieldSchema, DerivedField, FieldSchema, GenericField, HashField, IdentityField, LegacyAttributeField, LegacyRelationshipField, ObjectField, Schema, Trait } from "
|
|
1
|
+
import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "../../reactive.js";
|
|
2
|
+
import type { ExtensibleField } from "../../reactive/-private/schema.js";
|
|
3
|
+
import type { ResourceKey } from "../identifier.js";
|
|
4
|
+
import type { ObjectValue } from "../json/raw.js";
|
|
5
|
+
import type { Derivation, HashFn, Transformation } from "./concepts.js";
|
|
6
|
+
import type { ArrayField, CacheableFieldSchema, DerivedField, FieldSchema, GenericField, HashField, IdentityField, LegacyAttributeField, LegacyRelationshipField, ObjectField, Schema, Trait } from "./fields.js";
|
|
7
7
|
export type AttributesSchema = Record<string, LegacyAttributeField>;
|
|
8
8
|
export type RelationshipsSchema = Record<string, LegacyRelationshipField>;
|
|
9
9
|
interface ObjectWithStringTypeProperty {
|
|
@@ -66,7 +66,7 @@ export interface SchemaService {
|
|
|
66
66
|
* Queries whether the SchemaService recognizes `type` as a resource type
|
|
67
67
|
*
|
|
68
68
|
* @public
|
|
69
|
-
* @deprecated
|
|
69
|
+
* @deprecated - use {@link SchemaService.hasResource | hasResource}
|
|
70
70
|
*/
|
|
71
71
|
doesTypeExist?(type: string): boolean;
|
|
72
72
|
/**
|
|
@@ -251,7 +251,7 @@ export interface SchemaService {
|
|
|
251
251
|
* ```
|
|
252
252
|
*
|
|
253
253
|
* @public
|
|
254
|
-
* @deprecated
|
|
254
|
+
* @deprecated - use {@link SchemaService.fields | fields}
|
|
255
255
|
*/
|
|
256
256
|
attributesDefinitionFor?(key: ResourceKey | ObjectWithStringTypeProperty): AttributesSchema;
|
|
257
257
|
/**
|
|
@@ -330,7 +330,7 @@ export interface SchemaService {
|
|
|
330
330
|
* ```
|
|
331
331
|
*
|
|
332
332
|
* @public
|
|
333
|
-
* @deprecated
|
|
333
|
+
* @deprecated - use {@link SchemaService.fields | fields}
|
|
334
334
|
*/
|
|
335
335
|
relationshipsDefinitionFor?(key: ResourceKey | ObjectWithStringTypeProperty): RelationshipsSchema;
|
|
336
336
|
/**
|
|
@@ -342,6 +342,8 @@ export interface SchemaService {
|
|
|
342
342
|
/**
|
|
343
343
|
* Register an extension for either objects or arrays
|
|
344
344
|
*
|
|
345
|
+
* See also {@link CAUTION_MEGA_DANGER_ZONE_Extension}
|
|
346
|
+
*
|
|
345
347
|
* @public
|
|
346
348
|
*/
|
|
347
349
|
CAUTION_MEGA_DANGER_ZONE_registerExtension?(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
|
package/declarations/types.d.ts
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
export type { StableRecordIdentifier, ResourceKey } from "./types/identifier.js";
|
|
8
8
|
export type { CacheCapabilitiesManager } from "./store/-types/q/cache-capabilities-manager.js";
|
|
9
9
|
export type { ModelSchema } from "./store/deprecated/-private.js";
|
|
10
|
-
export type { SchemaService } from "./
|
|
10
|
+
export type { SchemaService } from "./types/schema/schema-service.js";
|
|
11
11
|
export type { BaseFinderOptions, FindRecordOptions, LegacyResourceQuery, QueryOptions, FindAllOptions } from "./store/-types/q/store.js";
|