@warp-drive/core 5.6.0-beta.1 → 5.6.0-beta.3
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 +7 -20
- package/declarations/graph/-private/-edge-definition.d.ts +3 -12
- package/declarations/graph/-private/-state.d.ts +0 -87
- package/declarations/graph/-private/-utils.d.ts +5 -11
- package/declarations/graph/-private/coerce-id.d.ts +0 -6
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
- 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 +6 -7
- package/declarations/graph/-private/graph.d.ts +17 -51
- package/declarations/graph/-private/normalize-link.d.ts +0 -6
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +73 -0
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +7 -11
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -11
- 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/kind/alias-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
- package/declarations/reactive/-private/record.d.ts +44 -34
- package/declarations/reactive/-private/schema.d.ts +50 -68
- package/declarations/reactive/-private/symbols.d.ts +2 -33
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +278 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -0
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -24
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -5
- package/declarations/store/-private/caches/instance-cache.d.ts +22 -28
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -40
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +35 -53
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -25
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +132 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
- package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
- package/declarations/store/-private/record-arrays/resource-array.d.ts +67 -0
- package/declarations/store/-private/store-service.d.ts +167 -877
- package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
- package/declarations/store/-private.d.ts +13 -14
- 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/record-instance.d.ts +0 -1
- package/declarations/store/-types/q/schema-service.d.ts +64 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +223 -0
- package/declarations/store/deprecated/store.d.ts +783 -0
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +0 -11
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -37
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -7
- package/declarations/types/cache.d.ts +51 -127
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -78
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +66 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +391 -14
- package/declarations/types/spec/document.d.ts +6 -10
- package/declarations/types/spec/json-api-raw.d.ts +6 -9
- package/declarations/types.d.ts +1 -1
- package/declarations/utils/string.d.ts +2 -3
- package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
- package/dist/graph/-private.js +137 -144
- package/dist/index.js +25 -14
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +337 -1422
- package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
- package/dist/request.js +1 -1
- package/dist/store/-private.js +2 -3
- package/dist/store.js +32 -44
- package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +45 -3
- package/dist/types/schema/fields.js +23 -2
- package/dist/utils/string.js +2 -2
- package/package.json +11 -11
- package/declarations/reactive/-private/fields/compute.d.ts +0 -43
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/declarations/store/-types/q/ds-model.d.ts +0 -21
- package/dist/handler-C2T-IyJK.js +0 -339
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "../../types/identifier.js";
|
|
2
2
|
import type { CollectionEdge } from "./edges/collection.js";
|
|
3
3
|
import type { ResourceEdge } from "./edges/resource.js";
|
|
4
4
|
import type { Graph } from "./graph.js";
|
|
@@ -10,23 +10,10 @@ type Diff<T> = {
|
|
|
10
10
|
changed: boolean;
|
|
11
11
|
remoteOrderChanged: boolean;
|
|
12
12
|
};
|
|
13
|
-
export declare function diffCollection(finalState:
|
|
14
|
-
export declare function computeLocalState(storage: CollectionEdge):
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* It will not generate a notification, will not update the relationships to dirty,
|
|
21
|
-
* and will not update the inverse relationships, making it suitable for use as
|
|
22
|
-
* an internal util to perform the just the addition to a specific side of a
|
|
23
|
-
* relationship.
|
|
24
|
-
*
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
export declare function _add(graph: Graph, record: StableRecordIdentifier, relationship: CollectionEdge, value: StableRecordIdentifier, index: number | null, isRemote: boolean): boolean;
|
|
28
|
-
export declare function _remove(graph: Graph, record: StableRecordIdentifier, relationship: CollectionEdge, value: StableRecordIdentifier, index: number | null, isRemote: boolean): boolean;
|
|
29
|
-
export declare function _removeLocal(relationship: CollectionEdge, value: StableRecordIdentifier): boolean;
|
|
30
|
-
export declare function _removeRemote(relationship: CollectionEdge, value: StableRecordIdentifier): boolean;
|
|
31
|
-
export declare function rollbackRelationship(graph: Graph, identifier: StableRecordIdentifier, field: string, relationship: CollectionEdge | ResourceEdge): void;
|
|
13
|
+
export declare function diffCollection(finalState: ResourceKey[], relationship: CollectionEdge, onAdd: (v: ResourceKey) => void, onDel: (v: ResourceKey) => void): Diff<ResourceKey>;
|
|
14
|
+
export declare function computeLocalState(storage: CollectionEdge): ResourceKey[];
|
|
15
|
+
export declare function _remove(graph: Graph, record: ResourceKey, relationship: CollectionEdge, value: ResourceKey, index: number | null, isRemote: boolean): boolean;
|
|
16
|
+
export declare function _removeLocal(relationship: CollectionEdge, value: ResourceKey): boolean;
|
|
17
|
+
export declare function _removeRemote(relationship: CollectionEdge, value: ResourceKey): boolean;
|
|
18
|
+
export declare function rollbackRelationship(graph: Graph, key: ResourceKey, field: string, relationship: CollectionEdge | ResourceEdge): void;
|
|
32
19
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "../../types.js";
|
|
2
2
|
import type { CollectionField, FieldSchema, LegacyBelongsToField, LegacyHasManyField, ResourceField } from "../../types/schema/fields.js";
|
|
3
3
|
import type { Graph } from "./graph.js";
|
|
4
4
|
export type EdgeCache = Record<string, Record<string, EdgeDefinition | null>>;
|
|
@@ -70,22 +70,17 @@ export declare function temporaryConvertToLegacy(field: ResourceField | Collecti
|
|
|
70
70
|
* }
|
|
71
71
|
* ```
|
|
72
72
|
*
|
|
73
|
-
*
|
|
74
|
-
* @class UpgradedMeta
|
|
75
|
-
* @internal
|
|
73
|
+
* @private
|
|
76
74
|
*/
|
|
77
75
|
export interface UpgradedMeta {
|
|
78
76
|
kind: "implicit" | RelationshipFieldKind;
|
|
79
77
|
/**
|
|
80
78
|
* The field name on `this` record
|
|
81
|
-
*
|
|
82
|
-
* @internal
|
|
83
79
|
*/
|
|
84
80
|
key: string;
|
|
85
81
|
/**
|
|
86
82
|
* The `type` of the related record
|
|
87
83
|
*
|
|
88
|
-
* @internal
|
|
89
84
|
*/
|
|
90
85
|
type: string;
|
|
91
86
|
isAsync: boolean;
|
|
@@ -97,12 +92,10 @@ export interface UpgradedMeta {
|
|
|
97
92
|
inverseKind: "implicit" | RelationshipFieldKind;
|
|
98
93
|
/**
|
|
99
94
|
* The field name on the opposing record
|
|
100
|
-
* @internal
|
|
101
95
|
*/
|
|
102
96
|
inverseKey: string;
|
|
103
97
|
/**
|
|
104
98
|
* The `type` of `this` record
|
|
105
|
-
* @internal
|
|
106
99
|
*/
|
|
107
100
|
inverseType: string;
|
|
108
101
|
inverseIsAsync: boolean;
|
|
@@ -131,7 +124,6 @@ export interface EdgeDefinition {
|
|
|
131
124
|
* If the relationship is polymorphic, this will be true if
|
|
132
125
|
* it points back at the same abstract type.
|
|
133
126
|
*
|
|
134
|
-
* @internal
|
|
135
127
|
*/
|
|
136
128
|
isSelfReferential: boolean;
|
|
137
129
|
/**
|
|
@@ -139,10 +131,9 @@ export interface EdgeDefinition {
|
|
|
139
131
|
* if the relationship also points back at the same
|
|
140
132
|
* field.
|
|
141
133
|
*
|
|
142
|
-
* @internal
|
|
143
134
|
*/
|
|
144
135
|
isReflexive: boolean;
|
|
145
136
|
}
|
|
146
137
|
export declare function isLHS(info: EdgeDefinition, type: string, key: string): boolean;
|
|
147
138
|
export declare function isRHS(info: EdgeDefinition, type: string, key: string): boolean;
|
|
148
|
-
export declare function upgradeDefinition(graph: Graph,
|
|
139
|
+
export declare function upgradeDefinition(graph: Graph, key: ResourceKey, propertyName: string, isImplicit?: boolean): EdgeDefinition | null;
|
|
@@ -1,96 +1,9 @@
|
|
|
1
1
|
export interface RelationshipState {
|
|
2
|
-
/*
|
|
3
|
-
This flag indicates whether we should consider the content
|
|
4
|
-
of this relationship "known".
|
|
5
|
-
|
|
6
|
-
If we have no relationship knowledge, and the relationship
|
|
7
|
-
is `async`, we will attempt to fetch the relationship on
|
|
8
|
-
access if it is also stale.
|
|
9
|
-
|
|
10
|
-
Snapshot uses this to tell the difference between unknown
|
|
11
|
-
(`undefined`) or empty (`null`). The reason for this is that
|
|
12
|
-
we wouldn't want to serialize unknown relationships as `null`
|
|
13
|
-
as that might overwrite remote state.
|
|
14
|
-
|
|
15
|
-
All relationships for a newly created (`store.createRecord()`) are
|
|
16
|
-
considered known (`hasReceivedData === true`).
|
|
17
|
-
|
|
18
|
-
true when
|
|
19
|
-
=> we receive a push with either new data or explicit empty (`[]` or `null`)
|
|
20
|
-
=> the relationship is a belongsTo and we have received data from
|
|
21
|
-
the other side.
|
|
22
|
-
|
|
23
|
-
false when
|
|
24
|
-
=> we have received no signal about what data belongs in this relationship
|
|
25
|
-
=> the relationship is a hasMany and we have only received data from
|
|
26
|
-
the other side.
|
|
27
|
-
*/
|
|
28
2
|
hasReceivedData: boolean;
|
|
29
|
-
/*
|
|
30
|
-
Flag that indicates whether an empty relationship is explicitly empty
|
|
31
|
-
(signaled by push giving us an empty array or null relationship)
|
|
32
|
-
e.g. an API response has told us that this relationship is empty.
|
|
33
|
-
|
|
34
|
-
Thus far, it does not appear that we actually need this flag; however,
|
|
35
|
-
@runspired has found it invaluable when debugging relationship tests
|
|
36
|
-
to determine whether (and why if so) we are in an incorrect state.
|
|
37
|
-
|
|
38
|
-
true when
|
|
39
|
-
=> we receive a push with explicit empty (`[]` or `null`)
|
|
40
|
-
=> we have received no signal about what data belongs in this relationship
|
|
41
|
-
=> on initial create (as no signal is known yet)
|
|
42
|
-
|
|
43
|
-
false at all other times
|
|
44
|
-
*/
|
|
45
3
|
isEmpty: boolean;
|
|
46
|
-
/*
|
|
47
|
-
This flag indicates whether we should
|
|
48
|
-
re-fetch the relationship the next time
|
|
49
|
-
it is accessed.
|
|
50
|
-
|
|
51
|
-
The difference between this flag and `shouldForceReload`
|
|
52
|
-
is in how we treat the presence of partially missing data:
|
|
53
|
-
- for a forced reload, we will reload the link or EVERY record
|
|
54
|
-
- for a stale reload, we will reload the link (if present) else only MISSING records
|
|
55
|
-
|
|
56
|
-
Ideally these flags could be merged, but because we don't give the
|
|
57
|
-
request layer the option of deciding how to resolve the data being queried
|
|
58
|
-
we are forced to differentiate for now.
|
|
59
|
-
|
|
60
|
-
It is also possible for a relationship to remain stale after a forced reload; however,
|
|
61
|
-
in this case `state.hasFailedLoadAttempt` ought to be `true`.
|
|
62
|
-
|
|
63
|
-
false when
|
|
64
|
-
=> cache.isNew(identifier) on initial setup
|
|
65
|
-
=> a previously triggered request has resolved
|
|
66
|
-
=> we get relationship data via push
|
|
67
|
-
|
|
68
|
-
true when
|
|
69
|
-
=> !cache.isNew(identifier) on initial setup
|
|
70
|
-
=> an inverse has been unloaded
|
|
71
|
-
=> we get a new link for the relationship
|
|
72
|
-
|
|
73
|
-
TODO @runspired unskip the acceptance tests and fix these flags
|
|
74
|
-
*/
|
|
75
4
|
isStale: boolean;
|
|
76
5
|
hasFailedLoadAttempt: boolean;
|
|
77
|
-
/*
|
|
78
|
-
This flag forces fetch. `true` for a single request once `reload()`
|
|
79
|
-
has been called `false` at all other times.
|
|
80
|
-
*/
|
|
81
6
|
shouldForceReload: boolean;
|
|
82
|
-
/*
|
|
83
|
-
This flag indicates whether we should
|
|
84
|
-
**partially** re-fetch the relationship the
|
|
85
|
-
next time it is accessed.
|
|
86
|
-
|
|
87
|
-
false when
|
|
88
|
-
=> initial setup
|
|
89
|
-
=> a previously triggered request has resolved
|
|
90
|
-
|
|
91
|
-
true when
|
|
92
|
-
=> an inverse has been unloaded
|
|
93
|
-
*/
|
|
94
7
|
hasDematerializedInverse: boolean;
|
|
95
8
|
}
|
|
96
9
|
export declare function createState(): RelationshipState;
|
|
@@ -2,7 +2,7 @@ import type { Store } from "../../store/-private.js";
|
|
|
2
2
|
import type { CacheCapabilitiesManager } from "../../types.js";
|
|
3
3
|
import type { UpdateResourceRelationshipOperation } from "../../types/cache/operations.js";
|
|
4
4
|
import type { UpdateRelationshipOperation } from "../../types/graph.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ResourceKey } from "../../types/identifier.js";
|
|
6
6
|
import type { ResourceIdentifierObject } from "../../types/spec/json-api-raw.js";
|
|
7
7
|
import type { UpgradedMeta } from "./-edge-definition.js";
|
|
8
8
|
import type { CollectionEdge } from "./edges/collection.js";
|
|
@@ -15,17 +15,11 @@ export declare function getStore(wrapper: CacheCapabilitiesManager | {
|
|
|
15
15
|
export declare function expandingGet<T>(cache: Record<string, Record<string, T>>, key1: string, key2: string): T | undefined;
|
|
16
16
|
export declare function expandingSet<T>(cache: Record<string, Record<string, T>>, key1: string, key2: string, value: T): void;
|
|
17
17
|
export declare function assertValidRelationshipPayload(graph: Graph, op: UpdateRelationshipOperation | UpdateResourceRelationshipOperation): void;
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function checkIfNew(store: Store, resourceKey: ResourceKey): boolean;
|
|
19
19
|
export declare function isBelongsTo(relationship: GraphEdge): relationship is ResourceEdge;
|
|
20
20
|
export declare function isImplicit(relationship: GraphEdge): relationship is ImplicitEdge;
|
|
21
21
|
export declare function isHasMany(relationship: GraphEdge): relationship is CollectionEdge;
|
|
22
|
-
export declare function forAllRelatedIdentifiers(rel: GraphEdge, cb: (
|
|
23
|
-
|
|
24
|
-
Removes the given identifier from BOTH remote AND local state.
|
|
25
|
-
|
|
26
|
-
This method is useful when either a deletion or a rollback on a new record
|
|
27
|
-
needs to entirely purge itself from an inverse relationship.
|
|
28
|
-
*/
|
|
29
|
-
export declare function removeIdentifierCompletelyFromRelationship(graph: Graph, relationship: GraphEdge, value: StableRecordIdentifier, silenceNotifications?: boolean): void;
|
|
22
|
+
export declare function forAllRelatedIdentifiers(rel: GraphEdge, cb: (resourceKey: ResourceKey) => void): void;
|
|
23
|
+
export declare function removeIdentifierCompletelyFromRelationship(graph: Graph, relationship: GraphEdge, value: ResourceKey, silenceNotifications?: boolean): void;
|
|
30
24
|
export declare function notifyChange(graph: Graph, relationship: CollectionEdge | ResourceEdge): void;
|
|
31
|
-
export declare function assertRelationshipData(store: Store,
|
|
25
|
+
export declare function assertRelationshipData(store: Store, resourceKey: ResourceKey, data: ResourceIdentifierObject, meta: UpgradedMeta): void;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// Used by the store to normalize IDs entering the store. Despite the fact
|
|
2
|
-
// that developers may provide IDs as numbers (e.g., `store.findRecord('person', 1)`),
|
|
3
|
-
// it is important that internally we use strings, since IDs may be serialized
|
|
4
|
-
// and lose type information. For example, Ember's router may put a record's
|
|
5
|
-
// ID into the URL, and if we later try to deserialize that URL and find the
|
|
6
|
-
// corresponding record, we will not know if it is a string or a number.
|
|
7
1
|
type Coercable = string | number | boolean | null | undefined | symbol;
|
|
8
2
|
export declare function coerceId(id: Coercable): string | null;
|
|
9
3
|
export declare function ensureStringId(id: Coercable): string;
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { CacheCapabilitiesManager } from "../../../types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "../../../types/identifier.js";
|
|
3
3
|
import { type UpgradedMeta } from "../-edge-definition.js";
|
|
4
|
-
|
|
5
|
-
Assert that `addedRecord` has a valid type so it can be added to the
|
|
6
|
-
relationship of the `record`.
|
|
7
|
-
|
|
8
|
-
The assert basically checks if the `addedRecord` can be added to the
|
|
9
|
-
relationship (specified via `relationshipMeta`) of the `record`.
|
|
10
|
-
|
|
11
|
-
This utility should only be used internally, as both record parameters must
|
|
12
|
-
be stable record identifiers and the `relationshipMeta` needs to be the meta
|
|
13
|
-
information about the relationship, retrieved via
|
|
14
|
-
`record.relationshipFor(key)`.
|
|
15
|
-
*/
|
|
16
|
-
declare let assertPolymorphicType: (parentIdentifier: StableRecordIdentifier, parentDefinition: UpgradedMeta, addedIdentifier: StableRecordIdentifier, store: CacheCapabilitiesManager) => void;
|
|
4
|
+
declare let assertPolymorphicType: (parentIdentifier: ResourceKey, parentDefinition: UpgradedMeta, addedIdentifier: ResourceKey, store: CacheCapabilitiesManager) => void;
|
|
17
5
|
declare let assertInheritedSchema: (definition: UpgradedMeta, type: string) => void;
|
|
18
6
|
export { assertPolymorphicType, assertInheritedSchema };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { CollectionRelationship } from "../../../types/cache/relationship.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "../../../types/identifier.js";
|
|
3
3
|
import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
4
4
|
import type { UpgradedMeta } from "../-edge-definition.js";
|
|
5
5
|
import type { RelationshipState } from "../-state.js";
|
|
6
6
|
export interface CollectionEdge {
|
|
7
7
|
definition: UpgradedMeta;
|
|
8
|
-
identifier:
|
|
8
|
+
identifier: ResourceKey;
|
|
9
9
|
state: RelationshipState;
|
|
10
|
-
remoteMembers: Set<
|
|
11
|
-
remoteState:
|
|
12
|
-
additions: Set<
|
|
13
|
-
removals: Set<
|
|
10
|
+
remoteMembers: Set<ResourceKey>;
|
|
11
|
+
remoteState: ResourceKey[];
|
|
12
|
+
additions: Set<ResourceKey> | null;
|
|
13
|
+
removals: Set<ResourceKey> | null;
|
|
14
14
|
meta: Meta | null;
|
|
15
15
|
links: Links | PaginationLinks | null;
|
|
16
|
-
localState:
|
|
16
|
+
localState: ResourceKey[] | null;
|
|
17
17
|
/**
|
|
18
18
|
* Whether the localState for this edge is out-of-sync
|
|
19
19
|
* with the remoteState.
|
|
@@ -31,9 +31,9 @@ export interface CollectionEdge {
|
|
|
31
31
|
*/
|
|
32
32
|
accessed: boolean;
|
|
33
33
|
_diff?: {
|
|
34
|
-
add: Set<
|
|
35
|
-
del: Set<
|
|
34
|
+
add: Set<ResourceKey>;
|
|
35
|
+
del: Set<ResourceKey>;
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
export declare function createCollectionEdge(definition: UpgradedMeta, identifier:
|
|
38
|
+
export declare function createCollectionEdge(definition: UpgradedMeta, identifier: ResourceKey): CollectionEdge;
|
|
39
39
|
export declare function legacyGetCollectionRelationshipData(source: CollectionEdge, getRemoteState: boolean): CollectionRelationship;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "../../../types/identifier.js";
|
|
2
2
|
import type { UpgradedMeta } from "../-edge-definition.js";
|
|
3
3
|
export type ImplicitMeta = UpgradedMeta & {
|
|
4
4
|
kind: "implicit";
|
|
@@ -36,8 +36,8 @@ to be do things like remove the comment from the post if the comment were to be
|
|
|
36
36
|
*/
|
|
37
37
|
export interface ImplicitEdge {
|
|
38
38
|
definition: ImplicitMeta;
|
|
39
|
-
identifier:
|
|
40
|
-
localMembers: Set<
|
|
41
|
-
remoteMembers: Set<
|
|
39
|
+
identifier: ResourceKey;
|
|
40
|
+
localMembers: Set<ResourceKey>;
|
|
41
|
+
remoteMembers: Set<ResourceKey>;
|
|
42
42
|
}
|
|
43
|
-
export declare function createImplicitEdge(definition: ImplicitMeta, identifier:
|
|
43
|
+
export declare function createImplicitEdge(definition: ImplicitMeta, identifier: ResourceKey): ImplicitEdge;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import type { ResourceRelationship } from "../../../types/cache/relationship.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "../../../types/identifier.js";
|
|
3
3
|
import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
4
4
|
import type { UpgradedMeta } from "../-edge-definition.js";
|
|
5
5
|
import type { RelationshipState } from "../-state.js";
|
|
6
6
|
/**
|
|
7
7
|
* Stores the data for one side of a "single" resource relationship.
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
10
|
-
* @internal
|
|
9
|
+
* @private
|
|
11
10
|
*/
|
|
12
11
|
export interface ResourceEdge {
|
|
13
12
|
definition: UpgradedMeta;
|
|
14
|
-
identifier:
|
|
13
|
+
identifier: ResourceKey;
|
|
15
14
|
state: RelationshipState;
|
|
16
|
-
localState:
|
|
17
|
-
remoteState:
|
|
15
|
+
localState: ResourceKey | null;
|
|
16
|
+
remoteState: ResourceKey | null;
|
|
18
17
|
meta: Meta | null;
|
|
19
18
|
links: Links | PaginationLinks | null;
|
|
20
19
|
transactionRef: number;
|
|
21
20
|
accessed: boolean;
|
|
22
21
|
}
|
|
23
|
-
export declare function createResourceEdge(definition: UpgradedMeta, identifier:
|
|
22
|
+
export declare function createResourceEdge(definition: UpgradedMeta, identifier: ResourceKey): ResourceEdge;
|
|
24
23
|
export declare function legacyGetResourceRelationshipData(source: ResourceEdge, getRemoteState: boolean): ResourceRelationship;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Store } from "../../store/-private.js";
|
|
2
|
+
import type { CacheCapabilitiesManager, ResourceKey } from "../../types.js";
|
|
2
3
|
import type { RelationshipDiff } from "../../types/cache.js";
|
|
3
4
|
import type { MergeOperation } from "../../types/cache/operations.js";
|
|
4
5
|
import type { CollectionRelationship, ResourceRelationship } from "../../types/cache/relationship.js";
|
|
@@ -14,31 +15,13 @@ type PendingOps = {
|
|
|
14
15
|
hasMany?: Map<string, Map<string, RemoteRelationshipOperation[]>>;
|
|
15
16
|
deletions: DeleteRecordOperation[];
|
|
16
17
|
};
|
|
17
|
-
/*
|
|
18
|
-
* Graph acts as the cache for relationship data. It allows for
|
|
19
|
-
* us to ask about and update relationships for a given Identifier
|
|
20
|
-
* without requiring other objects for that Identifier to be
|
|
21
|
-
* instantiated (such as `RecordData` or a `Record`)
|
|
22
|
-
*
|
|
23
|
-
* This also allows for us to make more substantive changes to relationships
|
|
24
|
-
* with increasingly minor alterations to other portions of the internals
|
|
25
|
-
* over time.
|
|
26
|
-
*
|
|
27
|
-
* The graph is made up of nodes and edges. Each unique identifier gets
|
|
28
|
-
* its own node, which is a dictionary with a list of that node's edges
|
|
29
|
-
* (or connections) to other nodes. In `Model` terms, a node represents a
|
|
30
|
-
* record instance, with each key (an edge) in the dictionary correlating
|
|
31
|
-
* to either a `hasMany` or `belongsTo` field on that record instance.
|
|
32
|
-
*
|
|
33
|
-
* The value for each key, or `edge` is the identifier(s) the node relates
|
|
34
|
-
* to in the graph from that key.
|
|
35
|
-
*/
|
|
36
18
|
export declare class Graph {
|
|
37
19
|
_definitionCache: EdgeCache;
|
|
38
20
|
_metaCache: Record<string, Record<string, UpgradedMeta>>;
|
|
39
21
|
_potentialPolymorphicTypes: Record<string, Record<string, boolean>>;
|
|
40
|
-
identifiers: Map<
|
|
22
|
+
identifiers: Map<ResourceKey, Record<string, GraphEdge>>;
|
|
41
23
|
store: CacheCapabilitiesManager;
|
|
24
|
+
_realStore: Store;
|
|
42
25
|
isDestroyed: boolean;
|
|
43
26
|
_willSyncRemote: boolean;
|
|
44
27
|
_willSyncLocal: boolean;
|
|
@@ -46,39 +29,22 @@ export declare class Graph {
|
|
|
46
29
|
_pushedUpdates: PendingOps;
|
|
47
30
|
_updatedRelationships: Set<CollectionEdge>;
|
|
48
31
|
_transaction: number | null;
|
|
49
|
-
_removing:
|
|
32
|
+
_removing: ResourceKey | null;
|
|
50
33
|
constructor(store: CacheCapabilitiesManager);
|
|
51
|
-
has(
|
|
52
|
-
getDefinition(
|
|
53
|
-
get(
|
|
54
|
-
getData(
|
|
55
|
-
getRemoteData(
|
|
56
|
-
/*
|
|
57
|
-
* Allows for the graph to dynamically discover polymorphic connections
|
|
58
|
-
* without needing to walk prototype chains.
|
|
59
|
-
*
|
|
60
|
-
* Used by edges when an added `type` does not match the expected `type`
|
|
61
|
-
* for that edge.
|
|
62
|
-
*
|
|
63
|
-
* Currently we assert before calling this. For a public API we will want
|
|
64
|
-
* to call out to the schema manager to ask if we should consider these
|
|
65
|
-
* types as equivalent for a given relationship.
|
|
66
|
-
*/
|
|
34
|
+
has(resourceKey: ResourceKey, propertyName: string): boolean;
|
|
35
|
+
getDefinition(resourceKey: ResourceKey, propertyName: string): UpgradedMeta;
|
|
36
|
+
get(resourceKey: ResourceKey, propertyName: string): GraphEdge;
|
|
37
|
+
getData(resourceKey: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
|
|
38
|
+
getRemoteData(resourceKey: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
|
|
67
39
|
registerPolymorphicType(type1: string, type2: string): void;
|
|
68
|
-
isReleasable(
|
|
69
|
-
unload(
|
|
70
|
-
_isDirty(
|
|
71
|
-
getChanged(
|
|
72
|
-
hasChanged(
|
|
73
|
-
rollback(
|
|
74
|
-
remove(
|
|
75
|
-
/*
|
|
76
|
-
* Remote state changes
|
|
77
|
-
*/
|
|
40
|
+
isReleasable(resourceKey: ResourceKey): boolean;
|
|
41
|
+
unload(resourceKey: ResourceKey, silenceNotifications?: boolean): void;
|
|
42
|
+
_isDirty(resourceKey: ResourceKey, field: string): boolean;
|
|
43
|
+
getChanged(resourceKey: ResourceKey): Map<string, RelationshipDiff>;
|
|
44
|
+
hasChanged(resourceKey: ResourceKey): boolean;
|
|
45
|
+
rollback(resourceKey: ResourceKey): string[];
|
|
46
|
+
remove(resourceKey: ResourceKey): void;
|
|
78
47
|
push(op: RemoteRelationshipOperation): void;
|
|
79
|
-
/*
|
|
80
|
-
* Local state changes
|
|
81
|
-
*/
|
|
82
48
|
update(op: RemoteRelationshipOperation | MergeOperation, isRemote: true): void;
|
|
83
49
|
update(op: LocalRelationshipOperation, isRemote?: false): void;
|
|
84
50
|
_scheduleLocalSync(relationship: CollectionEdge): void;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import type { Link, LinkObject } from "../../types/spec/json-api-raw.js";
|
|
2
|
-
/*
|
|
3
|
-
This method normalizes a link to an "links object". If the passed link is
|
|
4
|
-
already an object it's returned without any modifications.
|
|
5
|
-
|
|
6
|
-
See http://jsonapi.org/format/#document-links for more information.
|
|
7
|
-
*/
|
|
8
2
|
export default function _normalizeLink(link: Link): LinkObject | null;
|
|
@@ -1,62 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "../../../types.js";
|
|
2
2
|
import type { ReplaceRelatedRecordsOperation } from "../../../types/graph.js";
|
|
3
3
|
import type { Graph } from "../graph.js";
|
|
4
|
-
/*
|
|
5
|
-
case many:1
|
|
6
|
-
========
|
|
7
|
-
In a bi-directional graph with Many:1 edges, adding a value
|
|
8
|
-
results in up-to 3 discrete value transitions, while removing
|
|
9
|
-
a value is only 2 transitions.
|
|
10
|
-
|
|
11
|
-
For adding C to A
|
|
12
|
-
If: A <<-> B, C <->> D is the initial state,
|
|
13
|
-
and: B <->> A <<-> C, D is the final state
|
|
14
|
-
|
|
15
|
-
then we would undergo the following transitions.
|
|
16
|
-
|
|
17
|
-
add C to A
|
|
18
|
-
remove C from D
|
|
19
|
-
add A to C
|
|
20
|
-
|
|
21
|
-
For removing B from A
|
|
22
|
-
If: A <<-> B, C <->> D is the initial state,
|
|
23
|
-
and: A, B, C <->> D is the final state
|
|
24
|
-
|
|
25
|
-
then we would undergo the following transitions.
|
|
26
|
-
|
|
27
|
-
remove B from A
|
|
28
|
-
remove A from B
|
|
29
|
-
|
|
30
|
-
case many:many
|
|
31
|
-
===========
|
|
32
|
-
In a bi-directional graph with Many:Many edges, adding or
|
|
33
|
-
removing a value requires only 2 value transitions.
|
|
34
|
-
|
|
35
|
-
For Adding
|
|
36
|
-
If: A<<->>B, C<<->>D is the initial state (double arrows representing the many side)
|
|
37
|
-
And: D<<->>C<<->>A<<->>B is the final state
|
|
38
|
-
|
|
39
|
-
Then we would undergo two transitions.
|
|
40
|
-
|
|
41
|
-
add C to A.
|
|
42
|
-
add A to C
|
|
43
|
-
|
|
44
|
-
For Removing
|
|
45
|
-
If: A<<->>B, C<<->>D is the initial state (double arrows representing the many side)
|
|
46
|
-
And: A, B, C<<->>D is the final state
|
|
47
|
-
|
|
48
|
-
Then we would undergo two transitions.
|
|
49
|
-
|
|
50
|
-
remove B from A
|
|
51
|
-
remove A from B
|
|
52
|
-
|
|
53
|
-
case many:?
|
|
54
|
-
========
|
|
55
|
-
In a uni-directional graph with Many:? edges (modeled in WarpDrive with `inverse:null`) with
|
|
56
|
-
artificial (implicit) inverses, replacing a value results in 2 discrete value transitions.
|
|
57
|
-
This is because a Many:? relationship is effectively Many:Many.
|
|
58
|
-
*/
|
|
59
4
|
export default function replaceRelatedRecords(graph: Graph, op: ReplaceRelatedRecordsOperation, isRemote: boolean): void;
|
|
60
|
-
export declare function addToInverse(graph: Graph,
|
|
61
|
-
export declare function notifyInverseOfPotentialMaterialization(graph: Graph,
|
|
62
|
-
export declare function removeFromInverse(graph: Graph,
|
|
5
|
+
export declare function addToInverse(graph: Graph, resourceKey: ResourceKey, key: string, value: ResourceKey, isRemote: boolean): void;
|
|
6
|
+
export declare function notifyInverseOfPotentialMaterialization(graph: Graph, resourceKey: ResourceKey, key: string, value: ResourceKey, isRemote: boolean): void;
|
|
7
|
+
export declare function removeFromInverse(graph: Graph, resourceKey: ResourceKey, key: string, value: ResourceKey, isRemote: boolean): void;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { Store } from "../../../index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "../../../types.js";
|
|
3
3
|
import type { UpdateResourceRelationshipOperation } from "../../../types/cache/operations.js";
|
|
4
4
|
import type { UpdateRelationshipOperation } from "../../../types/graph.js";
|
|
5
5
|
import type { ExistingResourceIdentifierObject, NewResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
|
|
6
6
|
import type { Graph } from "../graph.js";
|
|
7
|
-
type
|
|
8
|
-
/*
|
|
9
|
-
Updates the "canonical" or "remote" state of a relationship, replacing any existing
|
|
10
|
-
state and blowing away any local changes (excepting new records).
|
|
11
|
-
*/
|
|
7
|
+
type CacheKeyManager = Store["cacheKeyManager"];
|
|
12
8
|
export default function updateRelationshipOperation(graph: Graph, op: UpdateRelationshipOperation | UpdateResourceRelationshipOperation): void;
|
|
13
|
-
export declare function upgradeIdentifiers(arr: (ExistingResourceIdentifierObject | NewResourceIdentifierObject |
|
|
9
|
+
export declare function upgradeIdentifiers(arr: (ExistingResourceIdentifierObject | NewResourceIdentifierObject | ResourceKey)[], cache: CacheKeyManager): ResourceKey[];
|
package/declarations/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export { Store, type StoreRequestContext, CacheHandler, type CachePolicy, type S
|
|
|
11
11
|
*/
|
|
12
12
|
export type Document<T> = ReactiveDocument<T>;
|
|
13
13
|
export type { DocumentCacheOperation, CacheOperation, NotificationType } from "./store/-private/managers/notification-manager.js";
|
|
14
|
-
export { setIdentifierGenerationMethod, setIdentifierUpdateMethod, setIdentifierForgetMethod, setIdentifierResetMethod, setKeyInfoForResource } from "./store/-private/
|
|
14
|
+
export { setIdentifierGenerationMethod, setIdentifierUpdateMethod, setIdentifierForgetMethod, setIdentifierResetMethod, setKeyInfoForResource } from "./store/-private/managers/cache-key-manager.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Store } from "../../store/-private.js";
|
|
2
|
+
import type { SignalStore } from "../../store/-private/new-core-tmp/reactivity/internal.js";
|
|
3
|
+
import type { ResourceKey } from "../../types.js";
|
|
4
|
+
import type { FieldSchema, HashField, IdentityField, SchemaArrayField, SchemaObjectField } from "../../types/schema/fields.js";
|
|
5
|
+
import type { ReactiveResource } from "./record.js";
|
|
6
|
+
export type PathLike = string | symbol | Array<string | symbol>;
|
|
7
|
+
export type ModeName = "polaris" | "legacy";
|
|
8
|
+
export interface ModeInfo {
|
|
9
|
+
name: ModeName;
|
|
10
|
+
legacy: boolean;
|
|
11
|
+
editable: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface BaseContext {
|
|
14
|
+
store: Store;
|
|
15
|
+
resourceKey: ResourceKey;
|
|
16
|
+
modeName: ModeName;
|
|
17
|
+
legacy: boolean;
|
|
18
|
+
editable: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ResourceContext extends BaseContext {
|
|
21
|
+
path: null;
|
|
22
|
+
field: null;
|
|
23
|
+
value: null;
|
|
24
|
+
}
|
|
25
|
+
export interface ObjectContext extends BaseContext {
|
|
26
|
+
path: string[];
|
|
27
|
+
field: SchemaObjectField | SchemaArrayField;
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
export interface KindContext<T extends FieldSchema | IdentityField | HashField> extends BaseContext {
|
|
31
|
+
path: string[];
|
|
32
|
+
field: T;
|
|
33
|
+
value: unknown;
|
|
34
|
+
record: ReactiveResource;
|
|
35
|
+
signals: SignalStore;
|
|
36
|
+
}
|
|
37
|
+
export interface KindImpl<T extends FieldSchema | IdentityField | HashField> {
|
|
38
|
+
/**
|
|
39
|
+
* A function which produces the value for the field when invoked.
|
|
40
|
+
*/
|
|
41
|
+
get: (context: KindContext<T>) => unknown;
|
|
42
|
+
/**
|
|
43
|
+
* A function which updates the value for the field when invoked.
|
|
44
|
+
*
|
|
45
|
+
* This will never be invoked when the record is in a non-editable mode.
|
|
46
|
+
*
|
|
47
|
+
* This should assert in dev and return false if mutation is not allowed.
|
|
48
|
+
*/
|
|
49
|
+
set: (context: KindContext<T>) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether this field is ever mutable (writable). This should be
|
|
52
|
+
* if there is ever a scenario in which the field can be written
|
|
53
|
+
* and false only if the field can never be written to.
|
|
54
|
+
*/
|
|
55
|
+
mutable: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether this field's of this kind should be included in the
|
|
58
|
+
* enumerated (iterable) keys of the record/object instance.
|
|
59
|
+
*
|
|
60
|
+
* This should generally be true except for fields that are not
|
|
61
|
+
* producing a value backed by the cache. For instance, locals
|
|
62
|
+
* should not be enumerable, as their value is not tied to the
|
|
63
|
+
* cache at all.
|
|
64
|
+
*/
|
|
65
|
+
enumerable: boolean;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
serializable: boolean;
|
|
70
|
+
}
|
|
71
|
+
type Mode = { [Field in FieldSchema | IdentityField | HashField as Field["kind"]] : KindImpl<Field> };
|
|
72
|
+
export declare const DefaultMode: Mode;
|
|
73
|
+
export {};
|