@warp-drive/core 5.7.0-alpha.13 → 5.7.0-alpha.15
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/declarations/graph/-private/-diff.d.ts +8 -8
- package/declarations/graph/-private/-edge-definition.d.ts +2 -2
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +5 -5
- package/declarations/graph/-private/graph.d.ts +15 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +2 -2
- package/declarations/reactive/-private/document.d.ts +6 -16
- package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/record.d.ts +44 -5
- package/declarations/reactive/-private/schema.d.ts +12 -12
- package/declarations/reactive/-private/symbols.d.ts +1 -1
- package/declarations/reactive.d.ts +277 -1
- package/declarations/request/-private/context.d.ts +2 -2
- package/declarations/request/-private/fetch.d.ts +2 -2
- package/declarations/request/-private/manager.d.ts +2 -2
- package/declarations/request/-private/types.d.ts +4 -4
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +18 -18
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +21 -19
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
- package/declarations/store/-private/managers/notification-manager.d.ts +21 -25
- package/declarations/store/-private/managers/record-array-manager.d.ts +78 -27
- package/declarations/store/-private/network/request-cache.d.ts +11 -11
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +1 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
- package/declarations/store/-private/record-arrays/-utils.d.ts +82 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +89 -0
- package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts} +43 -101
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +103 -0
- package/declarations/store/-private/record-arrays/resource-array.d.ts +82 -0
- package/declarations/store/-private/store-service.d.ts +22 -19
- package/declarations/store/-private.d.ts +5 -3
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/schema-service.d.ts +9 -9
- package/declarations/store/deprecated/-private.d.ts +5 -5
- package/declarations/store/deprecated/store.d.ts +8 -9
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -113
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +60 -76
- package/declarations/types/request.d.ts +27 -6
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +1 -1
- package/declarations/types/spec/document.d.ts +6 -6
- package/dist/{context-COmAnXUQ.js → context-kQXhkeBj.js} +13 -0
- package/dist/graph/-private.js +129 -129
- package/dist/index.js +6 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +126 -4
- package/dist/{request-state-BWYju5O9.js → request-state-CQ0Q6d1V.js} +4290 -4218
- package/dist/request.js +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/store.js +32 -44
- package/dist/{symbols-BoONANuz.js → symbols-sql1_mdx.js} +2 -2
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +27 -0
- package/dist/types/schema/fields.js +2 -0
- package/package.json +3 -3
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "../../../reactive.js";
|
|
2
2
|
import type { ExtensibleField } from "../../../reactive/-private/schema.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResourceKey } from "../../../types/identifier.js";
|
|
4
4
|
import type { ObjectValue } from "../../../types/json/raw.js";
|
|
5
5
|
import type { Derivation, HashFn, Transformation } from "../../../types/schema/concepts.js";
|
|
6
6
|
import type { ArrayField, CacheableFieldSchema, DerivedField, FieldSchema, GenericField, HashField, IdentityField, LegacyAttributeField, LegacyRelationshipField, ObjectField, Schema, Trait } from "../../../types/schema/fields.js";
|
|
@@ -74,7 +74,7 @@ export interface SchemaService {
|
|
|
74
74
|
*
|
|
75
75
|
* @public
|
|
76
76
|
*/
|
|
77
|
-
hasResource(resource: ObjectWithStringTypeProperty |
|
|
77
|
+
hasResource(resource: ObjectWithStringTypeProperty | ResourceKey): boolean;
|
|
78
78
|
/**
|
|
79
79
|
* Queries whether the SchemaService recognizes `type` as a resource trait
|
|
80
80
|
*
|
|
@@ -86,7 +86,7 @@ export interface SchemaService {
|
|
|
86
86
|
*
|
|
87
87
|
* @public
|
|
88
88
|
*/
|
|
89
|
-
resourceHasTrait(resource: ObjectWithStringTypeProperty |
|
|
89
|
+
resourceHasTrait(resource: ObjectWithStringTypeProperty | ResourceKey, trait: string): boolean;
|
|
90
90
|
/**
|
|
91
91
|
* Queries for the fields of a given resource type or resource identity.
|
|
92
92
|
*
|
|
@@ -94,7 +94,7 @@ export interface SchemaService {
|
|
|
94
94
|
*
|
|
95
95
|
* @public
|
|
96
96
|
*/
|
|
97
|
-
fields(resource: ObjectWithStringTypeProperty |
|
|
97
|
+
fields(resource: ObjectWithStringTypeProperty | ResourceKey): Map<string, FieldSchema>;
|
|
98
98
|
/**
|
|
99
99
|
* Queries for the fields of a given resource type or resource identity.
|
|
100
100
|
*
|
|
@@ -102,7 +102,7 @@ export interface SchemaService {
|
|
|
102
102
|
*
|
|
103
103
|
* @public
|
|
104
104
|
*/
|
|
105
|
-
cacheFields?(resource: ObjectWithStringTypeProperty |
|
|
105
|
+
cacheFields?(resource: ObjectWithStringTypeProperty | ResourceKey): Map<string, Exclude<CacheableFieldSchema, IdentityField>>;
|
|
106
106
|
/**
|
|
107
107
|
* Returns the transformation registered with the name provided
|
|
108
108
|
* by `field.type`. Validates that the field is a valid transformable.
|
|
@@ -129,7 +129,7 @@ export interface SchemaService {
|
|
|
129
129
|
*
|
|
130
130
|
* @public
|
|
131
131
|
*/
|
|
132
|
-
resource(resource: ObjectWithStringTypeProperty |
|
|
132
|
+
resource(resource: ObjectWithStringTypeProperty | ResourceKey): Schema;
|
|
133
133
|
/**
|
|
134
134
|
* Enables registration of multiple Schemas at once.
|
|
135
135
|
*
|
|
@@ -253,7 +253,7 @@ export interface SchemaService {
|
|
|
253
253
|
* @public
|
|
254
254
|
* @deprecated
|
|
255
255
|
*/
|
|
256
|
-
attributesDefinitionFor?(
|
|
256
|
+
attributesDefinitionFor?(key: ResourceKey | ObjectWithStringTypeProperty): AttributesSchema;
|
|
257
257
|
/**
|
|
258
258
|
* DEPRECATED - use `fields` instead
|
|
259
259
|
*
|
|
@@ -332,7 +332,7 @@ export interface SchemaService {
|
|
|
332
332
|
* @public
|
|
333
333
|
* @deprecated
|
|
334
334
|
*/
|
|
335
|
-
relationshipsDefinitionFor?(
|
|
335
|
+
relationshipsDefinitionFor?(key: ResourceKey | ObjectWithStringTypeProperty): RelationshipsSchema;
|
|
336
336
|
/**
|
|
337
337
|
* Returns all known resource types
|
|
338
338
|
*
|
|
@@ -350,7 +350,7 @@ export interface SchemaService {
|
|
|
350
350
|
*
|
|
351
351
|
* @public
|
|
352
352
|
*/
|
|
353
|
-
CAUTION_MEGA_DANGER_ZONE_resourceExtensions?(resource:
|
|
353
|
+
CAUTION_MEGA_DANGER_ZONE_resourceExtensions?(resource: ResourceKey | {
|
|
354
354
|
type: string;
|
|
355
355
|
}): null | ProcessedExtension["features"];
|
|
356
356
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NewResourceKey, ResourceKey } from "../../types/identifier.js";
|
|
2
2
|
import type { Value } from "../../types/json/raw.js";
|
|
3
3
|
import type { OpaqueRecordInstance, TypedRecordInstance, TypeFromInstance } from "../../types/record.js";
|
|
4
4
|
import type { LegacyAttributeField, LegacyRelationshipField } from "../../types/schema/fields.js";
|
|
5
5
|
import type { SingleResourceDocument } from "../../types/spec/json-api-raw.js";
|
|
6
6
|
import { type InstanceCache } from "../-private.js";
|
|
7
7
|
import type { Store } from "./store.js";
|
|
8
|
-
export declare function preloadData(store: Store, identifier:
|
|
8
|
+
export declare function preloadData(store: Store, identifier: NewResourceKey, preload: Record<string, Value>): void;
|
|
9
9
|
export interface BaseFinderOptions {
|
|
10
10
|
reload?: boolean;
|
|
11
11
|
backgroundReload?: boolean;
|
|
@@ -55,7 +55,7 @@ export interface ModelSchema<T = unknown> {
|
|
|
55
55
|
eachRelationship<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
|
|
56
56
|
eachTransformedAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, type: string | null) => void, binding?: T): void;
|
|
57
57
|
}
|
|
58
|
-
export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier:
|
|
58
|
+
export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: ResourceKey): boolean;
|
|
59
59
|
/**
|
|
60
60
|
A `RecordReference` is a low-level API that allows users and
|
|
61
61
|
addon authors to perform meta-operations on a record.
|
|
@@ -73,7 +73,7 @@ export declare class RecordReference {
|
|
|
73
73
|
private ___identifier;
|
|
74
74
|
/** @internal */
|
|
75
75
|
private _ref;
|
|
76
|
-
constructor(store: Store, identifier:
|
|
76
|
+
constructor(store: Store, identifier: ResourceKey);
|
|
77
77
|
/** @internal */
|
|
78
78
|
destroy(): void;
|
|
79
79
|
get type(): string;
|
|
@@ -112,7 +112,7 @@ export declare class RecordReference {
|
|
|
112
112
|
@public
|
|
113
113
|
@return The identifier of the record.
|
|
114
114
|
*/
|
|
115
|
-
identifier():
|
|
115
|
+
identifier(): ResourceKey;
|
|
116
116
|
/**
|
|
117
117
|
How the reference will be looked up when it is loaded. Currently
|
|
118
118
|
this always returns `identity` to signify that a record will be
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TypeFromInstance } from "../../types/record.js";
|
|
2
2
|
import type { ResourceIdentifierObject } from "../../types/spec/json-api-raw.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { LegacyLiveArray, LegacyQueryArray } from "../-private.js";
|
|
4
4
|
import { Store } from "../-private/store-service.js";
|
|
5
5
|
import type { FindAllOptions, FindRecordOptions, LegacyResourceQuery, ModelSchema, QueryOptions } from "./-private.js";
|
|
6
6
|
import { RecordReference } from "./-private.js";
|
|
@@ -548,9 +548,9 @@ declare module "../-private/store-service" {
|
|
|
548
548
|
@param type the name of the resource
|
|
549
549
|
@param options
|
|
550
550
|
*/
|
|
551
|
-
findAll<T>(type: TypeFromInstance<T>, options?: FindAllOptions): Promise<
|
|
551
|
+
findAll<T>(type: TypeFromInstance<T>, options?: FindAllOptions): Promise<LegacyLiveArray<T>>;
|
|
552
552
|
/** @deprecated */
|
|
553
|
-
findAll(type: string, options?: FindAllOptions): Promise<
|
|
553
|
+
findAll(type: string, options?: FindAllOptions): Promise<LegacyLiveArray>;
|
|
554
554
|
/**
|
|
555
555
|
This method delegates a query to the adapter. This is the one place where
|
|
556
556
|
adapter-level semantics are exposed to the application.
|
|
@@ -565,13 +565,13 @@ declare module "../-private/store-service" {
|
|
|
565
565
|
|
|
566
566
|
If you do something like this:
|
|
567
567
|
|
|
568
|
-
```
|
|
568
|
+
```js
|
|
569
569
|
store.query('person', { page: 1 });
|
|
570
570
|
```
|
|
571
571
|
|
|
572
572
|
The request made to the server will look something like this:
|
|
573
573
|
|
|
574
|
-
```
|
|
574
|
+
```http
|
|
575
575
|
GET "/api/v1/person?page=1"
|
|
576
576
|
```
|
|
577
577
|
|
|
@@ -591,8 +591,7 @@ declare module "../-private/store-service" {
|
|
|
591
591
|
```
|
|
592
592
|
|
|
593
593
|
This method returns a promise, which is resolved with a
|
|
594
|
-
|
|
595
|
-
once the server returns.
|
|
594
|
+
{@link LegacyQueryArray} once the server returns.
|
|
596
595
|
|
|
597
596
|
@public
|
|
598
597
|
@deprecated use {@link Store.request} instead
|
|
@@ -602,9 +601,9 @@ declare module "../-private/store-service" {
|
|
|
602
601
|
@param query a query to be used by the adapter
|
|
603
602
|
@param options optional, may include `adapterOptions` hash which will be passed to adapter.query
|
|
604
603
|
*/
|
|
605
|
-
query<T>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryOptions): Promise<
|
|
604
|
+
query<T>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryOptions): Promise<LegacyQueryArray<T>>;
|
|
606
605
|
/** @deprecated */
|
|
607
|
-
query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<
|
|
606
|
+
query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<LegacyQueryArray>;
|
|
608
607
|
/**
|
|
609
608
|
This method makes a request for one record, where the `id` is not known
|
|
610
609
|
beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type UniversalTransientKey = "REQ_ID";
|
|
2
2
|
type UniversalKey = `(transient) ${UniversalTransientKey}` | "RequestMap" | "PromiseCache" | "RequestCache" | "SkipCache" | "EnableHydration" | "WarpDriveRuntimeConfig";
|
|
3
3
|
type TransientKey = "transactionRef" | "configuredGenerationMethod" | "configuredUpdateMethod" | "configuredForgetMethod" | "configuredResetMethod" | "configuredKeyInfoMethod" | "signalHooks";
|
|
4
|
-
type GlobalKey = `(transient) ${TransientKey}` | "AdapterError" | "InvalidError" | "TimeoutError" | "AbortError" | "UnauthorizedError" | "ForbiddenError" | "NotFoundError" | "ConflictError" | "ServerError" | "#{}" | "#[]" | "Signals" | "AvailableShims" | "FAKE_ARR" | "#source" | "#update" | "#notify" | "IS_COLLECTION" | "Touching" | "RequestPromise" | "SaveOp" | "LEGACY_SUPPORT" | "LegacySupport" | "Graphs" | "IS_FROZEN" | "IS_CACHE_HANDLER" | "CONFIG" | "DEBUG_MAP" | "IDENTIFIERS" | "DOCUMENTS" | "RecordCache" | "StoreMap" | "Store" | "$type" | "TransformName" | "RequestSignature" | "IS_FUTURE" | "DOC" | "ManagedArrayMap" | "ManagedObjectMap" | "Support" | "SOURCE" | "
|
|
4
|
+
type GlobalKey = `(transient) ${TransientKey}` | "AdapterError" | "InvalidError" | "TimeoutError" | "AbortError" | "UnauthorizedError" | "ForbiddenError" | "NotFoundError" | "ConflictError" | "ServerError" | "#{}" | "#[]" | "Signals" | "AvailableShims" | "FAKE_ARR" | "#source" | "#update" | "#notify" | "IS_COLLECTION" | "Touching" | "RequestPromise" | "SaveOp" | "LEGACY_SUPPORT" | "LegacySupport" | "Graphs" | "IS_FROZEN" | "IS_CACHE_HANDLER" | "CONFIG" | "DEBUG_MAP" | "IDENTIFIERS" | "DOCUMENTS" | "RecordCache" | "StoreMap" | "Store" | "$type" | "TransformName" | "RequestSignature" | "IS_FUTURE" | "DOC" | "ManagedArrayMap" | "ManagedObjectMap" | "Support" | "SOURCE" | "Destroy" | "Checkout" | "Commit" | "Context";
|
|
5
5
|
type UniqueSymbol<T extends string> = `___(unique) Symbol(${T})`;
|
|
6
6
|
type UniqueSymbolOr<
|
|
7
7
|
T,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The ResourceBlob is an opaque type that must
|
|
2
2
|
// satisfy two constraints.
|
|
3
|
-
// (1) it should be possible for the
|
|
4
|
-
// to be able to generate a
|
|
3
|
+
// (1) it should be possible for the CacheKeyManager
|
|
4
|
+
// to be able to generate a ResourceKey for it
|
|
5
5
|
// whether by default or due to configuration.
|
|
6
6
|
// (2) it should be in a format expected by the Cache.
|
|
7
7
|
// This format is Cache declared.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey, RequestKey } from "../identifier.js";
|
|
2
2
|
export interface Change {
|
|
3
|
-
identifier:
|
|
3
|
+
identifier: ResourceKey | RequestKey;
|
|
4
4
|
op: "upsert" | "remove";
|
|
5
5
|
patch?: unknown;
|
|
6
6
|
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "../identifier.js";
|
|
2
2
|
export interface AddToResourceRelationshipMutation {
|
|
3
3
|
op: "add";
|
|
4
|
-
record:
|
|
4
|
+
record: ResourceKey;
|
|
5
5
|
field: string;
|
|
6
|
-
value:
|
|
6
|
+
value: ResourceKey | ResourceKey[];
|
|
7
7
|
index?: number;
|
|
8
8
|
}
|
|
9
9
|
export interface RemoveFromResourceRelationshipMutation {
|
|
10
10
|
op: "remove";
|
|
11
|
-
record:
|
|
11
|
+
record: ResourceKey;
|
|
12
12
|
field: string;
|
|
13
|
-
value:
|
|
13
|
+
value: ResourceKey | ResourceKey[];
|
|
14
14
|
index?: number;
|
|
15
15
|
}
|
|
16
16
|
export interface ReplaceRelatedRecordMutation {
|
|
17
17
|
op: "replaceRelatedRecord";
|
|
18
|
-
record:
|
|
18
|
+
record: ResourceKey;
|
|
19
19
|
field: string;
|
|
20
20
|
// never null if field is a collection
|
|
21
|
-
value:
|
|
21
|
+
value: ResourceKey | null;
|
|
22
22
|
// if field is a collection,
|
|
23
23
|
// the value we are swapping with
|
|
24
|
-
prior?:
|
|
24
|
+
prior?: ResourceKey;
|
|
25
25
|
index?: number;
|
|
26
26
|
}
|
|
27
27
|
export interface ReplaceRelatedRecordsMutation {
|
|
28
28
|
op: "replaceRelatedRecords";
|
|
29
|
-
record:
|
|
29
|
+
record: ResourceKey;
|
|
30
30
|
field: string;
|
|
31
31
|
// the records to add. If no prior/index
|
|
32
32
|
// specified all existing should be removed
|
|
33
|
-
value:
|
|
33
|
+
value: ResourceKey[];
|
|
34
34
|
// if this is a "splice" the
|
|
35
35
|
// records we expect to be removed
|
|
36
|
-
prior?:
|
|
36
|
+
prior?: ResourceKey[];
|
|
37
37
|
// if this is a "splice" the
|
|
38
38
|
// index to start from
|
|
39
39
|
index?: number;
|
|
40
40
|
}
|
|
41
41
|
export interface SortRelatedRecordsMutation {
|
|
42
42
|
op: "sortRelatedRecords";
|
|
43
|
-
record:
|
|
43
|
+
record: ResourceKey;
|
|
44
44
|
field: string;
|
|
45
|
-
value:
|
|
45
|
+
value: ResourceKey[];
|
|
46
46
|
}
|
|
47
47
|
// A Mutation is an action that updates
|
|
48
48
|
// the local state of the Cache in some
|
|
@@ -1,85 +1,168 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PersistedResourceKey, ResourceKey, RequestKey } from "../identifier.js";
|
|
2
2
|
import type { Value } from "../json/raw.js";
|
|
3
3
|
import type { ExistingResourceObject } from "../spec/json-api-raw.js";
|
|
4
4
|
import type { Relationship } from "./relationship.js";
|
|
5
|
+
/**
|
|
6
|
+
* All operations are objects with at least one property,
|
|
7
|
+
* `op` which contains a string with the name of the operation
|
|
8
|
+
* to perform.
|
|
9
|
+
*/
|
|
5
10
|
export interface Op {
|
|
11
|
+
/**
|
|
12
|
+
* The name of the {@link Op | operation}
|
|
13
|
+
*/
|
|
6
14
|
op: string;
|
|
7
15
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Occasionally the Store discovers that two previously
|
|
18
|
+
* thought to be distinct resources refer to the same resource.
|
|
19
|
+
*
|
|
20
|
+
* This operation will be performed, giving the Cache the chance
|
|
21
|
+
* to cleanup and merge internal state as desired when this discovery
|
|
22
|
+
* is made.
|
|
23
|
+
*/
|
|
16
24
|
export interface MergeOperation extends Op {
|
|
17
25
|
op: "mergeIdentifiers";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The stale {@link ResourceKey | ResourceKey} that
|
|
28
|
+
* the cache should eliminate in favor of {@link MergeOperation.value | value}
|
|
29
|
+
*/
|
|
30
|
+
record: ResourceKey;
|
|
31
|
+
/**
|
|
32
|
+
* The kept {@link ResourceKey | ResourceKey} that
|
|
33
|
+
* the cache should also keep and merge {@link MergeOperation.record | record} into.
|
|
34
|
+
*/
|
|
35
|
+
value: ResourceKey;
|
|
22
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Removes a document and its associated request from
|
|
39
|
+
* the cache.
|
|
40
|
+
*/
|
|
23
41
|
export interface RemoveDocumentOperation extends Op {
|
|
24
42
|
op: "remove";
|
|
25
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The cache key for the request
|
|
45
|
+
*/
|
|
46
|
+
record: RequestKey;
|
|
26
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Removes a resource from the cache. This is treated
|
|
50
|
+
* as if a remote deletion has occurred, and all references
|
|
51
|
+
* to the resource should be eliminated.
|
|
52
|
+
*/
|
|
27
53
|
export interface RemoveResourceOperation extends Op {
|
|
28
54
|
op: "remove";
|
|
29
|
-
|
|
55
|
+
/**
|
|
56
|
+
* The cache key for the resource
|
|
57
|
+
*/
|
|
58
|
+
record: PersistedResourceKey;
|
|
30
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Adds a resource to the cache.
|
|
62
|
+
*/
|
|
31
63
|
export interface AddResourceOperation extends Op {
|
|
32
64
|
op: "add";
|
|
33
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The cache key for the resource
|
|
67
|
+
*/
|
|
68
|
+
record: PersistedResourceKey;
|
|
69
|
+
/**
|
|
70
|
+
* The data for the resource
|
|
71
|
+
*/
|
|
34
72
|
value: ExistingResourceObject;
|
|
35
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Upserts (merges) new state for a resource
|
|
76
|
+
*/
|
|
36
77
|
export interface UpdateResourceOperation extends Op {
|
|
37
78
|
op: "update";
|
|
38
|
-
record:
|
|
79
|
+
record: PersistedResourceKey;
|
|
39
80
|
value: ExistingResourceObject;
|
|
40
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Replaces the state of a field with a new state
|
|
84
|
+
*/
|
|
41
85
|
export interface UpdateResourceFieldOperation extends Op {
|
|
42
86
|
op: "update";
|
|
43
|
-
record:
|
|
87
|
+
record: PersistedResourceKey;
|
|
44
88
|
field: string;
|
|
45
89
|
value: Value;
|
|
46
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Replaces the state of a relationship with a new state
|
|
93
|
+
*/
|
|
47
94
|
export interface UpdateResourceRelationshipOperation extends Op {
|
|
48
95
|
op: "update";
|
|
49
|
-
record:
|
|
96
|
+
record: PersistedResourceKey;
|
|
50
97
|
field: string;
|
|
51
|
-
value: Relationship<
|
|
98
|
+
value: Relationship<PersistedResourceKey>;
|
|
52
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Adds a resource to a request document, optionally
|
|
102
|
+
* at a specific index. This can be used to update the
|
|
103
|
+
* result of a request.
|
|
104
|
+
*/
|
|
53
105
|
export interface AddToDocumentOperation extends Op {
|
|
54
106
|
op: "add";
|
|
55
|
-
record:
|
|
107
|
+
record: RequestKey;
|
|
56
108
|
field: "data" | "included";
|
|
57
|
-
value:
|
|
109
|
+
value: PersistedResourceKey | PersistedResourceKey[];
|
|
58
110
|
index?: number;
|
|
59
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Adds the specified ResourceKeys to a relationship
|
|
114
|
+
*/
|
|
60
115
|
export interface AddToResourceRelationshipOperation extends Op {
|
|
61
116
|
op: "add";
|
|
62
|
-
record:
|
|
117
|
+
record: PersistedResourceKey;
|
|
63
118
|
field: string;
|
|
64
|
-
value:
|
|
119
|
+
value: PersistedResourceKey | PersistedResourceKey[];
|
|
65
120
|
index?: number;
|
|
66
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Removes the specified ResourceKeys from a relationship
|
|
124
|
+
*/
|
|
67
125
|
export interface RemoveFromResourceRelationshipOperation extends Op {
|
|
68
126
|
op: "remove";
|
|
69
|
-
record:
|
|
127
|
+
record: PersistedResourceKey;
|
|
70
128
|
field: string;
|
|
71
|
-
value:
|
|
129
|
+
value: PersistedResourceKey | PersistedResourceKey[];
|
|
72
130
|
index?: number;
|
|
73
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Removes a resource from a request document, optionally
|
|
134
|
+
* at a specific index. This can be used to update the
|
|
135
|
+
* result of a request.
|
|
136
|
+
*/
|
|
74
137
|
export interface RemoveFromDocumentOperation extends Op {
|
|
75
138
|
op: "remove";
|
|
76
|
-
record:
|
|
139
|
+
record: RequestKey;
|
|
77
140
|
field: "data" | "included";
|
|
78
|
-
value:
|
|
141
|
+
value: PersistedResourceKey | PersistedResourceKey[];
|
|
79
142
|
index?: number;
|
|
80
143
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
144
|
+
/**
|
|
145
|
+
* {@link Cache} Operations perform updates to the
|
|
146
|
+
* Cache's "remote" (or clean) state to reflect external
|
|
147
|
+
* changes.
|
|
148
|
+
*
|
|
149
|
+
* Usually operations represent the result of a {@link WebSocket} or
|
|
150
|
+
* {@link EventSource | ServerEvent} message, though they can also be used to carefully
|
|
151
|
+
* patch the state of the cache with information known by the
|
|
152
|
+
* application or developer.
|
|
153
|
+
*
|
|
154
|
+
* Operations are applied via {@link Cache.patch}.
|
|
155
|
+
*
|
|
156
|
+
* See also:
|
|
157
|
+
* - {@link MergeOperation}
|
|
158
|
+
* - {@link RemoveResourceOperation}
|
|
159
|
+
* - {@link RemoveDocumentOperation}
|
|
160
|
+
* - {@link AddResourceOperation}
|
|
161
|
+
* - {@link UpdateResourceOperation}
|
|
162
|
+
* - {@link UpdateResourceFieldOperation}
|
|
163
|
+
* - {@link AddToResourceRelationshipOperation}
|
|
164
|
+
* - {@link RemoveFromResourceRelationshipOperation}
|
|
165
|
+
* - {@link AddToDocumentOperation}
|
|
166
|
+
* - {@link RemoveFromDocumentOperation}
|
|
167
|
+
*/
|
|
85
168
|
export type Operation = MergeOperation | RemoveResourceOperation | RemoveDocumentOperation | AddResourceOperation | UpdateResourceOperation | UpdateResourceFieldOperation | AddToResourceRelationshipOperation | RemoveFromResourceRelationshipOperation | AddToDocumentOperation | RemoveFromDocumentOperation;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "../identifier.js";
|
|
2
2
|
import type { Links, Meta, PaginationLinks } from "../spec/json-api-raw.js";
|
|
3
3
|
// we request that it be in the stable form already.
|
|
4
|
-
export interface ResourceRelationship<T =
|
|
4
|
+
export interface ResourceRelationship<T = ResourceKey> {
|
|
5
5
|
data?: T | null;
|
|
6
6
|
meta?: Meta;
|
|
7
7
|
links?: Links;
|
|
8
8
|
}
|
|
9
9
|
// Note: in v1 data could be a ResourceIdentifier, now
|
|
10
10
|
// we request that it be in the stable form already.
|
|
11
|
-
export interface CollectionRelationship<T =
|
|
11
|
+
export interface CollectionRelationship<T = ResourceKey> {
|
|
12
12
|
data?: T[];
|
|
13
13
|
meta?: Meta;
|
|
14
14
|
links?: PaginationLinks;
|
|
15
15
|
}
|
|
16
|
-
export type Relationship<T =
|
|
16
|
+
export type Relationship<T = ResourceKey> = ResourceRelationship<T> | CollectionRelationship<T>;
|