@warp-drive/core 5.7.0-alpha.14 → 5.7.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/declarations/graph/-private/-diff.d.ts +8 -8
  2. package/declarations/graph/-private/-edge-definition.d.ts +2 -2
  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 +5 -5
  9. package/declarations/graph/-private/graph.d.ts +15 -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 +2 -2
  14. package/declarations/reactive/-private/document.d.ts +6 -16
  15. package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
  16. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  17. package/declarations/reactive/-private/hooks.d.ts +2 -2
  18. package/declarations/reactive/-private/record.d.ts +44 -5
  19. package/declarations/reactive/-private/schema.d.ts +12 -12
  20. package/declarations/reactive/-private/symbols.d.ts +1 -0
  21. package/declarations/reactive.d.ts +277 -1
  22. package/declarations/request/-private/context.d.ts +2 -2
  23. package/declarations/request/-private/manager.d.ts +2 -2
  24. package/declarations/request/-private/types.d.ts +4 -4
  25. package/declarations/store/-private/cache-handler/types.d.ts +9 -9
  26. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  27. package/declarations/store/-private/caches/instance-cache.d.ts +18 -18
  28. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  29. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
  30. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +21 -19
  31. package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
  32. package/declarations/store/-private/managers/notification-manager.d.ts +21 -22
  33. package/declarations/store/-private/managers/record-array-manager.d.ts +15 -15
  34. package/declarations/store/-private/network/request-cache.d.ts +11 -11
  35. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  36. package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
  37. package/declarations/store/-private/record-arrays/-utils.d.ts +3 -3
  38. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +2 -2
  39. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +2 -2
  40. package/declarations/store/-private/record-arrays/resource-array.d.ts +9 -9
  41. package/declarations/store/-private/store-service.d.ts +19 -16
  42. package/declarations/store/-private.d.ts +1 -1
  43. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  44. package/declarations/store/-types/q/identifier.d.ts +9 -6
  45. package/declarations/store/-types/q/schema-service.d.ts +9 -9
  46. package/declarations/store/deprecated/-private.d.ts +5 -5
  47. package/declarations/types/-private.d.ts +1 -1
  48. package/declarations/types/cache/aliases.d.ts +2 -2
  49. package/declarations/types/cache/change.d.ts +2 -2
  50. package/declarations/types/cache/mutations.d.ts +13 -13
  51. package/declarations/types/cache/operations.d.ts +20 -20
  52. package/declarations/types/cache/relationship.d.ts +4 -4
  53. package/declarations/types/cache.d.ts +51 -113
  54. package/declarations/types/graph.d.ts +12 -12
  55. package/declarations/types/identifier.d.ts +60 -76
  56. package/declarations/types/request.d.ts +6 -6
  57. package/declarations/types/schema/concepts.d.ts +2 -2
  58. package/declarations/types/spec/document.d.ts +6 -6
  59. package/dist/graph/-private.js +125 -125
  60. package/dist/index.js +2 -2
  61. package/dist/reactive/-private.js +1 -1
  62. package/dist/reactive.js +126 -4
  63. package/dist/{request-state-CCrTjb0Z.js → request-state-CQ0Q6d1V.js} +3493 -3483
  64. package/dist/store/-private.js +1 -1
  65. package/dist/store.js +30 -43
  66. package/dist/{symbols-C5p2hcy9.js → symbols-sql1_mdx.js} +2 -1
  67. package/dist/types/-private.js +1 -1
  68. package/dist/types/identifier.js +19 -45
  69. package/package.json +3 -3
@@ -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,8 +10,8 @@ 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[];
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
15
  /**
16
16
  * A function which attempts to add a value to the local state of a collection
17
17
  * relationship, and returns true if the value was added, or false if it was
@@ -24,9 +24,9 @@ export declare function computeLocalState(storage: CollectionEdge): StableRecord
24
24
  *
25
25
  * @internal
26
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;
27
+ export declare function _add(graph: Graph, record: ResourceKey, relationship: CollectionEdge, value: ResourceKey, index: number | null, isRemote: boolean): boolean;
28
+ export declare function _remove(graph: Graph, record: ResourceKey, relationship: CollectionEdge, value: ResourceKey, index: number | null, isRemote: boolean): boolean;
29
+ export declare function _removeLocal(relationship: CollectionEdge, value: ResourceKey): boolean;
30
+ export declare function _removeRemote(relationship: CollectionEdge, value: ResourceKey): boolean;
31
+ export declare function rollbackRelationship(graph: Graph, key: ResourceKey, field: string, relationship: CollectionEdge | ResourceEdge): void;
32
32
  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>>;
@@ -145,4 +145,4 @@ export interface EdgeDefinition {
145
145
  }
146
146
  export declare function isLHS(info: EdgeDefinition, type: string, key: string): boolean;
147
147
  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;
148
+ 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 checkIfNew(store: Store, 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,5 +1,5 @@
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";
@@ -11,14 +11,14 @@ import type { RelationshipState } from "../-state.js";
11
11
  */
12
12
  export interface ResourceEdge {
13
13
  definition: UpgradedMeta;
14
- identifier: StableRecordIdentifier;
14
+ identifier: ResourceKey;
15
15
  state: RelationshipState;
16
- localState: StableRecordIdentifier | null;
17
- remoteState: StableRecordIdentifier | null;
16
+ localState: ResourceKey | null;
17
+ remoteState: ResourceKey | null;
18
18
  meta: Meta | null;
19
19
  links: Links | PaginationLinks | null;
20
20
  transactionRef: number;
21
21
  accessed: boolean;
22
22
  }
23
- export declare function createResourceEdge(definition: UpgradedMeta, identifier: StableRecordIdentifier): ResourceEdge;
23
+ export declare function createResourceEdge(definition: UpgradedMeta, identifier: ResourceKey): ResourceEdge;
24
24
  export declare function legacyGetResourceRelationshipData(source: ResourceEdge, getRemoteState: boolean): ResourceRelationship;
@@ -1,5 +1,5 @@
1
1
  import type { Store } from "../../store/-private.js";
2
- import type { CacheCapabilitiesManager, StableRecordIdentifier } from "../../types.js";
2
+ import type { CacheCapabilitiesManager, ResourceKey } from "../../types.js";
3
3
  import type { RelationshipDiff } from "../../types/cache.js";
4
4
  import type { MergeOperation } from "../../types/cache/operations.js";
5
5
  import type { CollectionRelationship, ResourceRelationship } from "../../types/cache/relationship.js";
@@ -38,7 +38,7 @@ export declare class Graph {
38
38
  _definitionCache: EdgeCache;
39
39
  _metaCache: Record<string, Record<string, UpgradedMeta>>;
40
40
  _potentialPolymorphicTypes: Record<string, Record<string, boolean>>;
41
- identifiers: Map<StableRecordIdentifier, Record<string, GraphEdge>>;
41
+ identifiers: Map<ResourceKey, Record<string, GraphEdge>>;
42
42
  store: CacheCapabilitiesManager;
43
43
  _realStore: Store;
44
44
  isDestroyed: boolean;
@@ -48,13 +48,13 @@ export declare class Graph {
48
48
  _pushedUpdates: PendingOps;
49
49
  _updatedRelationships: Set<CollectionEdge>;
50
50
  _transaction: number | null;
51
- _removing: StableRecordIdentifier | null;
51
+ _removing: ResourceKey | null;
52
52
  constructor(store: CacheCapabilitiesManager);
53
- has(identifier: StableRecordIdentifier, propertyName: string): boolean;
54
- getDefinition(identifier: StableRecordIdentifier, propertyName: string): UpgradedMeta;
55
- get(identifier: StableRecordIdentifier, propertyName: string): GraphEdge;
56
- getData(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
57
- 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;
58
58
  /*
59
59
  * Allows for the graph to dynamically discover polymorphic connections
60
60
  * without needing to walk prototype chains.
@@ -67,13 +67,13 @@ export declare class Graph {
67
67
  * types as equivalent for a given relationship.
68
68
  */
69
69
  registerPolymorphicType(type1: string, type2: string): void;
70
- isReleasable(identifier: StableRecordIdentifier): boolean;
71
- unload(identifier: StableRecordIdentifier, silenceNotifications?: boolean): void;
72
- _isDirty(identifier: StableRecordIdentifier, field: string): boolean;
73
- getChanged(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
74
- hasChanged(identifier: StableRecordIdentifier): boolean;
75
- rollback(identifier: StableRecordIdentifier): string[];
76
- 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;
77
77
  /*
78
78
  * Remote state changes
79
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";
@@ -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;
@@ -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);
@@ -1,13 +1,13 @@
1
1
  import type { WarpDriveSignal } from "../../../store/-private.js";
2
2
  import { ARRAY_SIGNAL } from "../../../store/-private.js";
3
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
+ import type { ResourceKey } from "../../../types/identifier.js";
4
4
  import type { ArrayField, SchemaArrayField } from "../../../types/schema/fields.js";
5
5
  import type { KindContext } from "../default-mode.js";
6
6
  import { ReactiveResource } from "../record.js";
7
7
  import { Context, SOURCE } from "../symbols.js";
8
8
  export interface ManagedArray extends Omit<Array<unknown>, "[]"> {
9
9
  [SOURCE]: unknown[];
10
- identifier: StableRecordIdentifier;
10
+ identifier: ResourceKey;
11
11
  path: string | string[];
12
12
  owner: ReactiveResource;
13
13
  [ARRAY_SIGNAL]: WarpDriveSignal;
@@ -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;
@@ -1,5 +1,5 @@
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 { ReactiveResource } from "./record.js";
4
- export declare function instantiateRecord(store: Store, identifier: StableRecordIdentifier, createArgs?: Record<string, unknown>): ReactiveResource;
4
+ export declare function instantiateRecord(store: Store, identifier: ResourceKey, createArgs?: Record<string, unknown>): ReactiveResource;
5
5
  export declare function teardownRecord(record: unknown): void;
@@ -1,8 +1,9 @@
1
1
  import type { Store } from "../../store/-private.js";
2
2
  import { RecordStore } from "../../types/symbols.js";
3
3
  import type { ObjectContext, ResourceContext } from "./default-mode.js";
4
- import { Checkout, Context, Destroy } from "./symbols.js";
4
+ import { Checkout, Commit, Context, Destroy } from "./symbols.js";
5
5
  export interface ReactiveResource {
6
+ /** @internal */
6
7
  [Symbol.toStringTag]: `ReactiveResource<${string}>`;
7
8
  /** @internal */
8
9
  [Context]: ObjectContext | ResourceContext;
@@ -12,14 +13,16 @@ export interface ReactiveResource {
12
13
  ___notifications: object;
13
14
  /** @internal */
14
15
  [Destroy](): void;
16
+ /** @internal */
17
+ [Commit](): Promise<void>;
15
18
  /**
16
19
  * Create an editable copy of the record
17
20
  *
18
21
  * ReactiveResource instances are not editable by default. This method creates an editable copy of the record. To use,
19
- * import the `Checkout` symbol from `@warp-drive/schema-record` and call it on the record.
22
+ * import the `Checkout` symbol from `@warp-drive/core/reactive` and call it on the record.
20
23
  *
21
24
  * ```ts
22
- * import { Checkout } from '@warp-drive/schema-record';
25
+ * import { Checkout } from '@warp-drive/core/reactive';
23
26
  *
24
27
  * const record = store.peekRecord('user', '1');
25
28
  * const editableRecord = await record[Checkout]();
@@ -27,13 +30,13 @@ export interface ReactiveResource {
27
30
  *
28
31
  * @returns a promise that resolves to the editable record
29
32
  * @throws if the record is already editable or if the record is embedded
30
- *
33
+ * @internal
31
34
  */
32
35
  [Checkout]<T>(): Promise<T>;
33
36
  }
34
37
  /**
35
38
  * A class that uses a the ResourceSchema for a ResourceType
36
- * and a ResouceKey to transform data from the cache into a rich, reactive
39
+ * and a ResourceKey to transform data from the cache into a rich, reactive
37
40
  * object.
38
41
  *
39
42
  * This class is not directly instantiable. To use it, you should
@@ -48,3 +51,39 @@ export declare class ReactiveResource {
48
51
  constructor(context: ResourceContext | ObjectContext);
49
52
  }
50
53
  export declare function _CHECKOUT(record: ReactiveResource): ReactiveResource;
54
+ /**
55
+ * Checkout an immutable resource for editing.
56
+ *
57
+ * {@link ReactiveResource | ReactiveResources} are not editable by default. This method
58
+ * creates an editable copy of the resource.
59
+ *
60
+ * This returns a promise which resolves with the editable
61
+ * version of the resource.
62
+ *
63
+ * ```ts
64
+ * import { checkout } from '@warp-drive/core/reactive';
65
+ *
66
+ * const immutable = store.peekRecord('user', '1');
67
+ * const editable = await checkout(immutable);
68
+ * ```
69
+ *
70
+ * Edits to editable resources will be automatically committed if a new
71
+ * payload from the cache matches their existing value.
72
+ *
73
+ * @public
74
+ *
75
+ * @returns a promise that resolves to the editable resource
76
+ * @throws if the resource is already editable or if resource is an embedded object
77
+ */
78
+ export declare function checkout<T>(resource: unknown): Promise<T & ReactiveResource>;
79
+ /**
80
+ * Forcibly commit all local changes on an editable resource to
81
+ * the remote (immutable) version.
82
+ *
83
+ * This API should only be used cautiously. Typically a better
84
+ * approach is for either the API or a Handler to reflect saved
85
+ * changes back to update the cache.
86
+ *
87
+ * @public
88
+ */
89
+ export declare function commit(record: ReactiveResource): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import type { Store } from "../../store/-private.js";
2
2
  import type { SchemaService as SchemaServiceInterface } from "../../types.js";
3
- import type { StableRecordIdentifier } from "../../types/identifier.js";
3
+ import type { ResourceKey } from "../../types/identifier.js";
4
4
  import type { ObjectValue, Value } from "../../types/json/raw.js";
5
5
  import type { Derivation, HashFn } from "../../types/schema/concepts.js";
6
6
  import { type ArrayField, type CacheableFieldSchema, type DerivedField, type FieldSchema, type GenericField, type HashField, type IdentityField, type LegacyAttributeField, type LegacyBelongsToField, type LegacyHasManyField, type LegacyRelationshipField, type ObjectField, type ObjectSchema, type PolarisResourceSchema, type ResourceSchema, type Trait } from "../../types/schema/fields.js";
@@ -95,11 +95,11 @@ interface FromIdentityDerivation {
95
95
  }, key: string): string | null;
96
96
  (record: ReactiveResource, options: {
97
97
  key: "^";
98
- }, key: string): StableRecordIdentifier;
98
+ }, key: string): ResourceKey;
99
99
  (record: ReactiveResource, options: null, key: string): asserts options;
100
100
  (record: ReactiveResource, options: {
101
101
  key: "id" | "lid" | "type" | "^";
102
- } | null, key: string): StableRecordIdentifier | string | null;
102
+ } | null, key: string): ResourceKey | string | null;
103
103
  [Type]: "@identity";
104
104
  }
105
105
  /**
@@ -151,18 +151,18 @@ export type Transformation<
151
151
  > = {
152
152
  serialize(value: PT, options: Record<string, unknown> | null, record: ReactiveResource): T;
153
153
  hydrate(value: T | undefined, options: Record<string, unknown> | null, record: ReactiveResource): PT;
154
- defaultValue?(options: Record<string, unknown> | null, identifier: StableRecordIdentifier): T;
154
+ defaultValue?(options: Record<string, unknown> | null, identifier: ResourceKey): T;
155
155
  [Type]: string;
156
156
  };
157
157
  interface KindFns {
158
158
  belongsTo: {
159
- get: (store: Store, record: object, resourceKey: StableRecordIdentifier, field: LegacyBelongsToField) => unknown;
160
- set: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyBelongsToField, value: unknown) => void;
159
+ get: (store: Store, record: object, resourceKey: ResourceKey, field: LegacyBelongsToField) => unknown;
160
+ set: (store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField, value: unknown) => void;
161
161
  };
162
162
  hasMany: {
163
- get: (store: Store, record: object, resourceKey: StableRecordIdentifier, field: LegacyHasManyField) => unknown;
164
- set: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyHasManyField, value: unknown) => void;
165
- notify: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyHasManyField) => boolean;
163
+ get: (store: Store, record: object, resourceKey: ResourceKey, field: LegacyHasManyField) => unknown;
164
+ set: (store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField, value: unknown) => void;
165
+ notify: (store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField) => boolean;
166
166
  };
167
167
  }
168
168
  export interface SchemaService {
@@ -212,7 +212,7 @@ export declare class SchemaService implements SchemaServiceInterface {
212
212
  constructor();
213
213
  resourceTypes(): Readonly<string[]>;
214
214
  hasTrait(type: string): boolean;
215
- resourceHasTrait(resource: StableRecordIdentifier | {
215
+ resourceHasTrait(resource: ResourceKey | {
216
216
  type: string;
217
217
  }, trait: string): boolean;
218
218
  transformation(field: GenericField | ObjectField | ArrayField | {
@@ -224,7 +224,7 @@ export declare class SchemaService implements SchemaServiceInterface {
224
224
  hashFn(field: HashField | {
225
225
  type: string;
226
226
  }): HashFn;
227
- resource(resource: StableRecordIdentifier | {
227
+ resource(resource: ResourceKey | {
228
228
  type: string;
229
229
  }): ResourceSchema | ObjectSchema;
230
230
  registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
@@ -268,7 +268,7 @@ export declare class SchemaService implements SchemaServiceInterface {
268
268
  FM extends ObjectValue | null
269
269
  >(derivation: Derivation<R, T, FM>): void;
270
270
  CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
271
- CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: StableRecordIdentifier | {
271
+ CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
272
272
  type: string;
273
273
  }): null | ProcessedExtension["features"];
274
274
  CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
@@ -27,4 +27,5 @@
27
27
  export declare const SOURCE: "___(unique) Symbol(SOURCE)";
28
28
  export declare const Destroy: "___(unique) Symbol(Destroy)";
29
29
  export declare const Checkout: "___(unique) Symbol(Checkout)";
30
+ export declare const Commit: "___(unique) Symbol(Commit)";
30
31
  export declare const Context: "___(unique) Symbol(Context)";