@warp-drive/core 5.7.0-alpha.3 → 5.7.0-alpha.30

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 (115) 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 +2 -2
  4. package/declarations/graph/-private/-utils.d.ts +5 -5
  5. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
  6. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  7. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  8. package/declarations/graph/-private/edges/resource.d.ts +6 -7
  9. package/declarations/graph/-private/graph.d.ts +17 -15
  10. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
  11. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
  12. package/declarations/index.d.ts +1 -1
  13. package/declarations/reactive/-private/default-mode.d.ts +73 -0
  14. package/declarations/reactive/-private/document.d.ts +11 -21
  15. package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
  16. package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
  17. package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
  18. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  19. package/declarations/reactive/-private/hooks.d.ts +2 -2
  20. package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
  21. package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
  22. package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
  23. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
  24. package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
  25. package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
  26. package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
  27. package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
  28. package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
  29. package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
  30. package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
  31. package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
  32. package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
  33. package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
  34. package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
  35. package/declarations/reactive/-private/record.d.ts +44 -33
  36. package/declarations/reactive/-private/schema.d.ts +16 -72
  37. package/declarations/reactive/-private/symbols.d.ts +2 -7
  38. package/declarations/reactive/-private.d.ts +1 -1
  39. package/declarations/reactive.d.ts +278 -1
  40. package/declarations/request/-private/context.d.ts +3 -3
  41. package/declarations/request/-private/fetch.d.ts +2 -0
  42. package/declarations/request/-private/manager.d.ts +24 -28
  43. package/declarations/request/-private/types.d.ts +22 -23
  44. package/declarations/request/-private/utils.d.ts +44 -2
  45. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  46. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  47. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  48. package/declarations/store/-private/caches/instance-cache.d.ts +21 -19
  49. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  50. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  51. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
  52. package/declarations/store/-private/managers/cache-manager.d.ts +47 -95
  53. package/declarations/store/-private/managers/notification-manager.d.ts +30 -42
  54. package/declarations/store/-private/managers/record-array-manager.d.ts +45 -41
  55. package/declarations/store/-private/network/request-cache.d.ts +21 -21
  56. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  57. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  58. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +12 -29
  59. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +23 -3
  60. package/declarations/store/-private/new-core-tmp/request-state.d.ts +129 -22
  61. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +52 -121
  62. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  63. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  64. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  65. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  66. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  67. package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
  68. package/declarations/store/-private/store-service.d.ts +156 -101
  69. package/declarations/store/-private.d.ts +10 -7
  70. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  71. package/declarations/store/-types/q/identifier.d.ts +9 -6
  72. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  73. package/declarations/store/-types/q/schema-service.d.ts +28 -40
  74. package/declarations/store/-types/q/store.d.ts +6 -7
  75. package/declarations/store/deprecated/-private.d.ts +12 -23
  76. package/declarations/store/deprecated/store.d.ts +11 -12
  77. package/declarations/types/-private.d.ts +1 -1
  78. package/declarations/types/cache/aliases.d.ts +2 -2
  79. package/declarations/types/cache/change.d.ts +2 -2
  80. package/declarations/types/cache/mutations.d.ts +13 -13
  81. package/declarations/types/cache/operations.d.ts +115 -32
  82. package/declarations/types/cache/relationship.d.ts +4 -4
  83. package/declarations/types/cache.d.ts +51 -113
  84. package/declarations/types/graph.d.ts +12 -12
  85. package/declarations/types/identifier.d.ts +52 -76
  86. package/declarations/types/params.d.ts +2 -3
  87. package/declarations/types/request.d.ts +69 -42
  88. package/declarations/types/schema/concepts.d.ts +2 -2
  89. package/declarations/types/schema/fields.d.ts +378 -14
  90. package/declarations/types/spec/document.d.ts +6 -6
  91. package/declarations/types/spec/json-api-raw.d.ts +6 -8
  92. package/declarations/utils/string.d.ts +2 -2
  93. package/dist/{configure-B48bFHOl.js → configure-CiFDHArV.js} +4 -4
  94. package/dist/configure.js +1 -1
  95. package/dist/{context-COmAnXUQ.js → context-Bh-MA_tH.js} +40 -6
  96. package/dist/graph/-private.js +137 -144
  97. package/dist/index.js +25 -14
  98. package/dist/reactive/-private.js +1 -1
  99. package/dist/reactive.js +202 -1411
  100. package/dist/{request-state-CejVJgdj.js → request-state-B908BvPK.js} +5186 -2549
  101. package/dist/request.js +1 -1
  102. package/dist/store/-private.js +2 -3
  103. package/dist/store.js +32 -44
  104. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  105. package/dist/types/-private.js +1 -1
  106. package/dist/types/identifier.js +19 -45
  107. package/dist/types/request.js +45 -3
  108. package/dist/types/schema/fields.js +23 -2
  109. package/dist/utils/string.js +2 -2
  110. package/package.json +10 -10
  111. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  112. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  113. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  114. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  115. package/dist/handler-D2jjnIA-.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;
@@ -61,12 +61,12 @@ export interface RelationshipState {
61
61
  in this case `state.hasFailedLoadAttempt` ought to be `true`.
62
62
 
63
63
  false when
64
- => cache.isNew(identifier) on initial setup
64
+ => cache.isNew(resourceKey) on initial setup
65
65
  => a previously triggered request has resolved
66
66
  => we get relationship data via push
67
67
 
68
68
  true when
69
- => !cache.isNew(identifier) on initial setup
69
+ => !cache.isNew(resourceKey) on initial setup
70
70
  => an inverse has been unloaded
71
71
  => we get a new link for the relationship
72
72
 
@@ -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,17 @@ 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;
22
+ export declare function forAllRelatedIdentifiers(rel: GraphEdge, cb: (resourceKey: ResourceKey) => void): void;
23
23
  /*
24
24
  Removes the given identifier from BOTH remote AND local state.
25
25
 
26
26
  This method is useful when either a deletion or a rollback on a new record
27
27
  needs to entirely purge itself from an inverse relationship.
28
28
  */
29
- export declare function removeIdentifierCompletelyFromRelationship(graph: Graph, relationship: GraphEdge, value: StableRecordIdentifier, silenceNotifications?: boolean): void;
29
+ export declare function removeIdentifierCompletelyFromRelationship(graph: Graph, relationship: GraphEdge, value: ResourceKey, silenceNotifications?: boolean): void;
30
30
  export declare function notifyChange(graph: Graph, relationship: CollectionEdge | ResourceEdge): void;
31
- export declare function assertRelationshipData(store: Store, identifier: StableRecordIdentifier, data: ResourceIdentifierObject, meta: UpgradedMeta): void;
31
+ export declare function assertRelationshipData(store: Store, resourceKey: ResourceKey, data: ResourceIdentifierObject, meta: UpgradedMeta): void;
@@ -1,5 +1,5 @@
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
4
  /*
5
5
  Assert that `addedRecord` has a valid type so it can be added to the
@@ -9,10 +9,10 @@ The assert basically checks if the `addedRecord` can be added to the
9
9
  relationship (specified via `relationshipMeta`) of the `record`.
10
10
 
11
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
12
+ be ResourceKeys and the `relationshipMeta` needs to be the meta
13
13
  information about the relationship, retrieved via
14
14
  `record.relationshipFor(key)`.
15
15
  */
16
- declare let assertPolymorphicType: (parentIdentifier: StableRecordIdentifier, parentDefinition: UpgradedMeta, addedIdentifier: StableRecordIdentifier, store: CacheCapabilitiesManager) => void;
16
+ declare let assertPolymorphicType: (parentIdentifier: ResourceKey, parentDefinition: UpgradedMeta, addedIdentifier: ResourceKey, store: CacheCapabilitiesManager) => void;
17
17
  declare let assertInheritedSchema: (definition: UpgradedMeta, type: string) => void;
18
18
  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";
@@ -37,8 +38,9 @@ export declare class Graph {
37
38
  _definitionCache: EdgeCache;
38
39
  _metaCache: Record<string, Record<string, UpgradedMeta>>;
39
40
  _potentialPolymorphicTypes: Record<string, Record<string, boolean>>;
40
- identifiers: Map<StableRecordIdentifier, Record<string, GraphEdge>>;
41
+ identifiers: Map<ResourceKey, Record<string, GraphEdge>>;
41
42
  store: CacheCapabilitiesManager;
43
+ _realStore: Store;
42
44
  isDestroyed: boolean;
43
45
  _willSyncRemote: boolean;
44
46
  _willSyncLocal: boolean;
@@ -46,13 +48,13 @@ export declare class Graph {
46
48
  _pushedUpdates: PendingOps;
47
49
  _updatedRelationships: Set<CollectionEdge>;
48
50
  _transaction: number | null;
49
- _removing: StableRecordIdentifier | null;
51
+ _removing: ResourceKey | null;
50
52
  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;
53
+ has(resourceKey: ResourceKey, propertyName: string): boolean;
54
+ getDefinition(resourceKey: ResourceKey, propertyName: string): UpgradedMeta;
55
+ get(resourceKey: ResourceKey, propertyName: string): GraphEdge;
56
+ getData(resourceKey: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
57
+ getRemoteData(resourceKey: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
56
58
  /*
57
59
  * Allows for the graph to dynamically discover polymorphic connections
58
60
  * without needing to walk prototype chains.
@@ -65,13 +67,13 @@ export declare class Graph {
65
67
  * types as equivalent for a given relationship.
66
68
  */
67
69
  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;
70
+ isReleasable(resourceKey: ResourceKey): boolean;
71
+ unload(resourceKey: ResourceKey, silenceNotifications?: boolean): void;
72
+ _isDirty(resourceKey: ResourceKey, field: string): boolean;
73
+ getChanged(resourceKey: ResourceKey): Map<string, RelationshipDiff>;
74
+ hasChanged(resourceKey: ResourceKey): boolean;
75
+ rollback(resourceKey: ResourceKey): string[];
76
+ remove(resourceKey: ResourceKey): void;
75
77
  /*
76
78
  * Remote state changes
77
79
  */
@@ -1,4 +1,4 @@
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
4
  /*
@@ -57,6 +57,6 @@ artificial (implicit) inverses, replacing a value results in 2 discrete value tr
57
57
  This is because a Many:? relationship is effectively Many:Many.
58
58
  */
59
59
  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;
60
+ export declare function addToInverse(graph: Graph, resourceKey: ResourceKey, key: string, value: ResourceKey, isRemote: boolean): void;
61
+ export declare function notifyInverseOfPotentialMaterialization(graph: Graph, resourceKey: ResourceKey, key: string, value: ResourceKey, isRemote: boolean): void;
62
+ export declare function removeFromInverse(graph: Graph, resourceKey: ResourceKey, key: string, value: ResourceKey, isRemote: boolean): void;
@@ -1,13 +1,13 @@
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"];
7
+ type CacheKeyManager = Store["cacheKeyManager"];
8
8
  /*
9
9
  Updates the "canonical" or "remote" state of a relationship, replacing any existing
10
10
  state and blowing away any local changes (excepting new records).
11
11
  */
12
12
  export default function updateRelationshipOperation(graph: Graph, op: UpdateRelationshipOperation | UpdateResourceRelationshipOperation): void;
13
- export declare function upgradeIdentifiers(arr: (ExistingResourceIdentifierObject | NewResourceIdentifierObject | StableRecordIdentifier)[], cache: IdentifierCache): StableRecordIdentifier[];
13
+ 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";
@@ -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 {};
@@ -1,12 +1,12 @@
1
1
  import type { Store } from "../../store/-private/store-service.js";
2
- import type { StableDocumentIdentifier } from "../../types/identifier.js";
2
+ import type { RequestKey } from "../../types/identifier.js";
3
3
  import type { ImmutableRequestInfo, RequestInfo } from "../../types/request.js";
4
4
  import type { ResourceDocument } from "../../types/spec/document.js";
5
5
  import type { Meta, PaginationLinks } from "../../types/spec/json-api-raw.js";
6
6
  /**
7
7
  * A Document is a class that wraps the response content from a request to the API
8
- * returned by `Cache.put` or `Cache.peek`, converting resource-identifiers into
9
- * record instances.
8
+ * returned by `Cache.put` or `Cache.peek`, converting ResourceKeys into
9
+ * ReactiveResource instances.
10
10
  *
11
11
  * It is not directly instantiated by the user, and its properties should not
12
12
  * be directly modified. Whether individual properties are mutable or not is
@@ -28,8 +28,6 @@ export declare class ReactiveDocument<T> {
28
28
  * }
29
29
  * ```
30
30
  *
31
- * @property links
32
- * @type {Object|undefined} - a links object
33
31
  * @public
34
32
  */
35
33
  readonly links?: PaginationLinks;
@@ -42,41 +40,33 @@ export declare class ReactiveDocument<T> {
42
40
  * For collections this will be an array of record instances,
43
41
  * for single resource requests it will be a single record instance or null.
44
42
  *
45
- * @property data
46
43
  * @public
47
- * @type {Object|Array<object>|null|undefined} - a data object
48
44
  */
49
45
  readonly data?: T;
50
46
  /**
51
47
  * The errors returned by the API for this request, if any
52
48
  *
53
- * @property errors
54
49
  * @public
55
- * @type {Object|undefined} - an errors object
56
50
  */
57
51
  readonly errors?: object[];
58
52
  /**
59
53
  * The meta object for this document, if any
60
54
  *
61
- * @property meta
62
55
  * @public
63
- * @type {Object|undefined} - a meta object
64
56
  */
65
57
  readonly meta?: Meta;
66
58
  /**
67
- * The identifier associated with this document, if any
59
+ * The RequestKey associated with this document, if any
68
60
  *
69
- * @property identifier
70
61
  * @public
71
- * @type {StableDocumentIdentifier|null}
72
62
  */
73
- readonly identifier: StableDocumentIdentifier | null;
63
+ readonly identifier: RequestKey | null;
74
64
  protected readonly _store: Store;
75
65
  protected readonly _localCache: {
76
66
  document: ResourceDocument;
77
67
  request: ImmutableRequestInfo;
78
68
  } | null;
79
- constructor(store: Store, identifier: StableDocumentIdentifier | null, localCache: {
69
+ constructor(store: Store, cacheKey: RequestKey | null, localCache: {
80
70
  document: ResourceDocument;
81
71
  request: ImmutableRequestInfo;
82
72
  } | null);
@@ -89,7 +79,7 @@ export declare class ReactiveDocument<T> {
89
79
  * @param {Object} options
90
80
  * @return {Promise<Document>}
91
81
  */
92
- fetch(options?: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T>>;
82
+ fetch(options?: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T>>;
93
83
  /**
94
84
  * Fetches the next link for this document, returning a promise that resolves
95
85
  * with the new document when the request completes, or null if there is no
@@ -99,7 +89,7 @@ export declare class ReactiveDocument<T> {
99
89
  * @param {Object} options
100
90
  * @return {Promise<Document | null>}
101
91
  */
102
- next(options?: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
92
+ next(options?: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
103
93
  /**
104
94
  * Fetches the prev link for this document, returning a promise that resolves
105
95
  * with the new document when the request completes, or null if there is no
@@ -109,7 +99,7 @@ export declare class ReactiveDocument<T> {
109
99
  * @param {Object} options
110
100
  * @return {Promise<Document | null>}
111
101
  */
112
- prev(options: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
102
+ prev(options: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
113
103
  /**
114
104
  * Fetches the first link for this document, returning a promise that resolves
115
105
  * with the new document when the request completes, or null if there is no
@@ -119,7 +109,7 @@ export declare class ReactiveDocument<T> {
119
109
  * @param {Object} options
120
110
  * @return {Promise<Document | null>}
121
111
  */
122
- first(options: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
112
+ first(options: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
123
113
  /**
124
114
  * Fetches the last link for this document, returning a promise that resolves
125
115
  * with the new document when the request completes, or null if there is no
@@ -129,7 +119,7 @@ export declare class ReactiveDocument<T> {
129
119
  * @param {Object} options
130
120
  * @return {Promise<Document | null>}
131
121
  */
132
- last(options: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
122
+ last(options: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
133
123
  /**
134
124
  * Implemented for `JSON.stringify` support.
135
125
  *
@@ -0,0 +1,8 @@
1
+ import type { CacheableFieldSchema, FieldSchema, HashField, IdentityField } from "../../../types/schema/fields.js";
2
+ type InvalidKind = "alias" | "derived" | "@local";
3
+ export declare function isInvalidKind(kind: string): kind is InvalidKind;
4
+ export declare function isNonIdentityCacheableField(field: FieldSchema | IdentityField | HashField): field is Exclude<CacheableFieldSchema, IdentityField>;
5
+ export declare function getFieldCacheKeyStrict(field: CacheableFieldSchema): string;
6
+ export declare function getFieldCacheKey(field: FieldSchema | IdentityField | HashField): string | null;
7
+ export declare function assertIsCacheField(field: FieldSchema | IdentityField): asserts field is CacheableFieldSchema;
8
+ export {};
@@ -1,22 +1,19 @@
1
- import type { Store } from "../../../index.js";
2
1
  import type { WarpDriveSignal } from "../../../store/-private.js";
3
2
  import { ARRAY_SIGNAL } from "../../../store/-private.js";
4
- import type { Cache } from "../../../types/cache.js";
5
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
+ import type { ResourceKey } from "../../../types/identifier.js";
6
4
  import type { ArrayField, SchemaArrayField } from "../../../types/schema/fields.js";
5
+ import type { KindContext } from "../default-mode.js";
7
6
  import { ReactiveResource } from "../record.js";
8
- import type { SchemaService } from "../schema.js";
9
- import { Editable, Legacy, SOURCE } from "../symbols.js";
7
+ import { Context, SOURCE } from "../symbols.js";
10
8
  export interface ManagedArray extends Omit<Array<unknown>, "[]"> {
11
9
  [SOURCE]: unknown[];
12
- identifier: StableRecordIdentifier;
13
- path: string[];
10
+ identifier: ResourceKey;
11
+ path: string | string[];
14
12
  owner: ReactiveResource;
15
13
  [ARRAY_SIGNAL]: WarpDriveSignal;
16
- [Editable]: boolean;
17
- [Legacy]: boolean;
14
+ [Context]: KindContext<SchemaArrayField | ArrayField>;
18
15
  }
19
16
  // eslint-disable-next-line @typescript-eslint/no-extraneous-class
20
17
  export declare class ManagedArray {
21
- constructor(store: Store, schema: SchemaService, cache: Cache, field: ArrayField | SchemaArrayField, data: unknown[], identifier: StableRecordIdentifier, path: string[], owner: ReactiveResource, isSchemaArray: boolean, editable: boolean, legacy: boolean);
18
+ constructor(context: KindContext<SchemaArrayField | ArrayField>, owner: ReactiveResource, data: unknown[]);
22
19
  }
@@ -1,21 +1,19 @@
1
1
  import { OBJECT_SIGNAL, type WarpDriveSignal } from "../../../store/-private.js";
2
- import type { Cache } from "../../../types/cache.js";
3
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
4
2
  import type { ObjectField, SchemaObjectField } from "../../../types/schema/fields.js";
3
+ import type { KindContext } from "../default-mode.js";
5
4
  import type { ReactiveResource } from "../record.js";
6
- import type { SchemaService } from "../schema.js";
7
- import { Editable, EmbeddedPath, Legacy, Parent, SOURCE } from "../symbols.js";
5
+ import { Context, SOURCE } from "../symbols.js";
8
6
  export declare function notifyObject(obj: ManagedObject): void;
9
7
  // const ignoredGlobalFields = new Set<string>(['setInterval', 'nodeType', 'nodeName', 'length', 'document', STRUCTURED]);
10
8
  export interface ManagedObject {
11
9
  [SOURCE]: object;
12
- [Parent]: StableRecordIdentifier;
13
- [EmbeddedPath]: string[];
10
+ [Context]: KindContext<ObjectField>;
14
11
  [OBJECT_SIGNAL]: WarpDriveSignal;
15
- [Editable]: boolean;
16
- [Legacy]: boolean;
17
12
  }
18
13
  // eslint-disable-next-line @typescript-eslint/no-extraneous-class
19
14
  export declare class ManagedObject {
20
- constructor(schema: SchemaService, cache: Cache, field: ObjectField | SchemaObjectField, data: object, identifier: StableRecordIdentifier, path: string[], owner: ReactiveResource, editable: boolean, legacy: boolean);
15
+ constructor(context: KindContext<ObjectField>);
21
16
  }
17
+ export declare const ManagedObjectMap: Map<ReactiveResource, Map<string, ManagedObject | ReactiveResource>>;
18
+ export declare function peekManagedObject(record: ReactiveResource, field: ObjectField): ManagedObject | undefined;
19
+ export declare function peekManagedObject(record: ReactiveResource, field: SchemaObjectField): ReactiveResource | undefined;
@@ -1,7 +1,7 @@
1
1
  import type { Store } from "../../../index.js";
2
2
  import type { RelatedCollection as ManyArray } from "../../../store/-private.js";
3
3
  import type { LocalRelationshipOperation } from "../../../types/graph.js";
4
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
4
+ import type { ResourceKey } from "../../../types/identifier.js";
5
5
  import type { ReactiveResource } from "../record.js";
6
6
  export interface FindHasManyOptions {
7
7
  reload?: boolean;
@@ -10,7 +10,7 @@ export interface FindHasManyOptions {
10
10
  export declare class ManyArrayManager {
11
11
  record: ReactiveResource;
12
12
  store: Store;
13
- identifier: StableRecordIdentifier;
13
+ identifier: ResourceKey;
14
14
  editable: boolean;
15
15
  constructor(record: ReactiveResource, editable: boolean);
16
16
  _syncArray(array: ManyArray): void;