@warp-drive/core 5.7.0-alpha.9 → 5.7.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.
Files changed (103) hide show
  1. package/declarations/graph/-private/-diff.d.ts +7 -20
  2. package/declarations/graph/-private/-edge-definition.d.ts +3 -12
  3. package/declarations/graph/-private/-state.d.ts +0 -87
  4. package/declarations/graph/-private/-utils.d.ts +5 -11
  5. package/declarations/graph/-private/coerce-id.d.ts +0 -6
  6. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
  7. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  8. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  9. package/declarations/graph/-private/edges/resource.d.ts +6 -7
  10. package/declarations/graph/-private/graph.d.ts +17 -51
  11. package/declarations/graph/-private/normalize-link.d.ts +0 -6
  12. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
  13. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
  14. package/declarations/index.d.ts +1 -1
  15. package/declarations/reactive/-private/default-mode.d.ts +2 -2
  16. package/declarations/reactive/-private/document.d.ts +11 -27
  17. package/declarations/reactive/-private/fields/managed-array.d.ts +4 -6
  18. package/declarations/reactive/-private/fields/managed-object.d.ts +2 -8
  19. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  20. package/declarations/reactive/-private/hooks.d.ts +2 -2
  21. package/declarations/reactive/-private/record.d.ts +42 -30
  22. package/declarations/reactive/-private/schema.d.ts +11 -73
  23. package/declarations/reactive/-private/symbols.d.ts +2 -33
  24. package/declarations/reactive/-private.d.ts +1 -1
  25. package/declarations/reactive.d.ts +277 -1
  26. package/declarations/request/-private/context.d.ts +3 -5
  27. package/declarations/request/-private/fetch.d.ts +2 -2
  28. package/declarations/request/-private/manager.d.ts +24 -28
  29. package/declarations/request/-private/types.d.ts +22 -24
  30. package/declarations/request/-private/utils.d.ts +44 -2
  31. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  32. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  33. package/declarations/store/-private/cache-handler/utils.d.ts +4 -5
  34. package/declarations/store/-private/caches/instance-cache.d.ts +21 -20
  35. package/declarations/store/-private/debug/utils.d.ts +1 -0
  36. package/declarations/store/-private/default-cache-policy.d.ts +25 -40
  37. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  38. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +35 -53
  39. package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
  40. package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
  41. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  42. package/declarations/store/-private/network/request-cache.d.ts +21 -25
  43. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  44. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  45. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  46. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  47. package/declarations/store/-private/new-core-tmp/request-state.d.ts +132 -37
  48. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
  49. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  50. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  51. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  52. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  53. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  54. package/declarations/store/-private/record-arrays/resource-array.d.ts +67 -0
  55. package/declarations/store/-private/store-service.d.ts +156 -106
  56. package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
  57. package/declarations/store/-private.d.ts +11 -13
  58. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  59. package/declarations/store/-types/q/identifier.d.ts +9 -6
  60. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  61. package/declarations/store/-types/q/schema-service.d.ts +9 -9
  62. package/declarations/store/-types/q/store.d.ts +6 -7
  63. package/declarations/store/deprecated/-private.d.ts +12 -24
  64. package/declarations/store/deprecated/store.d.ts +11 -16
  65. package/declarations/types/-private.d.ts +1 -1
  66. package/declarations/types/cache/aliases.d.ts +0 -11
  67. package/declarations/types/cache/change.d.ts +2 -2
  68. package/declarations/types/cache/mutations.d.ts +13 -37
  69. package/declarations/types/cache/operations.d.ts +115 -32
  70. package/declarations/types/cache/relationship.d.ts +4 -7
  71. package/declarations/types/cache.d.ts +51 -125
  72. package/declarations/types/graph.d.ts +12 -12
  73. package/declarations/types/identifier.d.ts +52 -78
  74. package/declarations/types/params.d.ts +2 -3
  75. package/declarations/types/request.d.ts +66 -42
  76. package/declarations/types/schema/concepts.d.ts +2 -2
  77. package/declarations/types/schema/fields.d.ts +30 -3
  78. package/declarations/types/spec/document.d.ts +6 -10
  79. package/declarations/types/spec/json-api-raw.d.ts +6 -9
  80. package/declarations/types.d.ts +0 -1
  81. package/declarations/utils/string.d.ts +2 -3
  82. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  83. package/dist/configure.js +1 -1
  84. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  85. package/dist/graph/-private.js +137 -144
  86. package/dist/index.js +25 -14
  87. package/dist/reactive/-private.js +1 -1
  88. package/dist/reactive.js +144 -1926
  89. package/dist/{request-state-CeN66aML.js → request-state-C955e0AL.js} +5968 -3033
  90. package/dist/request.js +1 -1
  91. package/dist/store/-private.js +2 -3
  92. package/dist/store.js +32 -44
  93. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  94. package/dist/types/-private.js +1 -1
  95. package/dist/types/identifier.js +19 -45
  96. package/dist/types/request.js +45 -3
  97. package/dist/types/schema/fields.js +6 -0
  98. package/dist/utils/string.js +2 -2
  99. package/package.json +11 -11
  100. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  101. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  102. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  103. package/dist/handler-SdXlte1w.js +0 -339
@@ -1,4 +1,4 @@
1
- import type { StableRecordIdentifier } from "../../types/identifier.js";
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: StableRecordIdentifier[], relationship: CollectionEdge, onAdd: (v: StableRecordIdentifier) => void, onDel: (v: StableRecordIdentifier) => void): Diff<StableRecordIdentifier>;
14
- export declare function computeLocalState(storage: CollectionEdge): StableRecordIdentifier[];
15
- /**
16
- * A function which attempts to add a value to the local state of a collection
17
- * relationship, and returns true if the value was added, or false if it was
18
- * already present.
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 { StableRecordIdentifier } from "../../types.js";
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, identifier: StableRecordIdentifier, propertyName: string, isImplicit?: boolean): EdgeDefinition | null;
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 { StableRecordIdentifier } from "../../types/identifier.js";
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 isNew(identifier: StableRecordIdentifier): boolean;
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: (identifier: StableRecordIdentifier) => void): void;
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, identifier: StableRecordIdentifier, data: ResourceIdentifierObject, meta: UpgradedMeta): void;
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 { StableRecordIdentifier } from "../../../types/identifier.js";
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 { StableRecordIdentifier } from "../../../types/identifier.js";
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: StableRecordIdentifier;
8
+ identifier: ResourceKey;
9
9
  state: RelationshipState;
10
- remoteMembers: Set<StableRecordIdentifier>;
11
- remoteState: StableRecordIdentifier[];
12
- additions: Set<StableRecordIdentifier> | null;
13
- removals: Set<StableRecordIdentifier> | null;
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: StableRecordIdentifier[] | null;
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<StableRecordIdentifier>;
35
- del: Set<StableRecordIdentifier>;
34
+ add: Set<ResourceKey>;
35
+ del: Set<ResourceKey>;
36
36
  };
37
37
  }
38
- export declare function createCollectionEdge(definition: UpgradedMeta, identifier: StableRecordIdentifier): CollectionEdge;
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 { StableRecordIdentifier } from "../../../types/identifier.js";
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: StableRecordIdentifier;
40
- localMembers: Set<StableRecordIdentifier>;
41
- remoteMembers: Set<StableRecordIdentifier>;
39
+ identifier: ResourceKey;
40
+ localMembers: Set<ResourceKey>;
41
+ remoteMembers: Set<ResourceKey>;
42
42
  }
43
- export declare function createImplicitEdge(definition: ImplicitMeta, identifier: StableRecordIdentifier): ImplicitEdge;
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 { StableRecordIdentifier } from "../../../types/identifier.js";
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
- * @class ResourceEdge
10
- * @internal
9
+ * @private
11
10
  */
12
11
  export interface ResourceEdge {
13
12
  definition: UpgradedMeta;
14
- identifier: StableRecordIdentifier;
13
+ identifier: ResourceKey;
15
14
  state: RelationshipState;
16
- localState: StableRecordIdentifier | null;
17
- remoteState: StableRecordIdentifier | null;
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: StableRecordIdentifier): ResourceEdge;
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 { CacheCapabilitiesManager, StableRecordIdentifier } from "../../types.js";
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<StableRecordIdentifier, Record<string, GraphEdge>>;
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: StableRecordIdentifier | null;
32
+ _removing: ResourceKey | null;
50
33
  constructor(store: CacheCapabilitiesManager);
51
- has(identifier: StableRecordIdentifier, propertyName: string): boolean;
52
- getDefinition(identifier: StableRecordIdentifier, propertyName: string): UpgradedMeta;
53
- get(identifier: StableRecordIdentifier, propertyName: string): GraphEdge;
54
- getData(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
55
- getRemoteData(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
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(identifier: StableRecordIdentifier): boolean;
69
- unload(identifier: StableRecordIdentifier, silenceNotifications?: boolean): void;
70
- _isDirty(identifier: StableRecordIdentifier, field: string): boolean;
71
- getChanged(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
72
- hasChanged(identifier: StableRecordIdentifier): boolean;
73
- rollback(identifier: StableRecordIdentifier): string[];
74
- remove(identifier: StableRecordIdentifier): void;
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 { StableRecordIdentifier } from "../../../types.js";
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, identifier: StableRecordIdentifier, key: string, value: StableRecordIdentifier, isRemote: boolean): void;
61
- export declare function notifyInverseOfPotentialMaterialization(graph: Graph, identifier: StableRecordIdentifier, key: string, value: StableRecordIdentifier, isRemote: boolean): void;
62
- export declare function removeFromInverse(graph: Graph, identifier: StableRecordIdentifier, key: string, value: StableRecordIdentifier, isRemote: boolean): void;
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 { StableRecordIdentifier } from "../../../types.js";
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 IdentifierCache = Store["identifierCache"];
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 | StableRecordIdentifier)[], cache: IdentifierCache): StableRecordIdentifier[];
9
+ export declare function upgradeIdentifiers(arr: (ExistingResourceIdentifierObject | NewResourceIdentifierObject | ResourceKey)[], cache: CacheKeyManager): ResourceKey[];
@@ -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/caches/identifier-cache.js";
14
+ export { setIdentifierGenerationMethod, setIdentifierUpdateMethod, setIdentifierForgetMethod, setIdentifierResetMethod, setKeyInfoForResource } from "./store/-private/managers/cache-key-manager.js";
@@ -1,6 +1,6 @@
1
1
  import type { Store } from "../../store/-private.js";
2
2
  import type { SignalStore } from "../../store/-private/new-core-tmp/reactivity/internal.js";
3
- import type { StableRecordIdentifier } from "../../types.js";
3
+ import type { ResourceKey } from "../../types.js";
4
4
  import type { FieldSchema, HashField, IdentityField, SchemaArrayField, SchemaObjectField } from "../../types/schema/fields.js";
5
5
  import type { ReactiveResource } from "./record.js";
6
6
  export type PathLike = string | symbol | Array<string | symbol>;
@@ -12,7 +12,7 @@ export interface ModeInfo {
12
12
  }
13
13
  export interface BaseContext {
14
14
  store: Store;
15
- resourceKey: StableRecordIdentifier;
15
+ resourceKey: ResourceKey;
16
16
  modeName: ModeName;
17
17
  legacy: boolean;
18
18
  editable: boolean;