@warp-drive/core 5.6.0-beta.0 → 5.6.0-beta.2

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 (120) 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 -27
  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 +50 -66
  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 -5
  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 +22 -27
  49. package/declarations/store/-private/debug/utils.d.ts +1 -0
  50. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  51. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  52. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
  53. package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
  54. package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
  55. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  56. package/declarations/store/-private/network/request-cache.d.ts +21 -24
  57. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  58. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  59. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  60. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  61. package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
  62. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
  63. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  64. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  65. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  66. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  67. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  68. package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
  69. package/declarations/store/-private/store-service.d.ts +167 -872
  70. package/declarations/store/-private.d.ts +14 -10
  71. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  72. package/declarations/store/-types/q/identifier.d.ts +9 -6
  73. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  74. package/declarations/store/-types/q/schema-service.d.ts +64 -40
  75. package/declarations/store/-types/q/store.d.ts +6 -7
  76. package/declarations/store/deprecated/-private.d.ts +224 -0
  77. package/declarations/store/deprecated/store.d.ts +787 -0
  78. package/declarations/types/-private.d.ts +1 -1
  79. package/declarations/types/cache/aliases.d.ts +2 -2
  80. package/declarations/types/cache/change.d.ts +2 -2
  81. package/declarations/types/cache/mutations.d.ts +13 -13
  82. package/declarations/types/cache/operations.d.ts +115 -32
  83. package/declarations/types/cache/relationship.d.ts +4 -4
  84. package/declarations/types/cache.d.ts +51 -115
  85. package/declarations/types/graph.d.ts +12 -12
  86. package/declarations/types/identifier.d.ts +52 -76
  87. package/declarations/types/params.d.ts +2 -3
  88. package/declarations/types/request.d.ts +69 -42
  89. package/declarations/types/schema/concepts.d.ts +2 -2
  90. package/declarations/types/schema/fields.d.ts +391 -14
  91. package/declarations/types/spec/document.d.ts +6 -6
  92. package/declarations/types/spec/json-api-raw.d.ts +6 -8
  93. package/declarations/types.d.ts +2 -1
  94. package/declarations/utils/string.d.ts +2 -2
  95. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  96. package/dist/configure.js +1 -1
  97. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  98. package/dist/graph/-private.js +137 -144
  99. package/dist/index.js +25 -14
  100. package/dist/reactive/-private.js +1 -1
  101. package/dist/reactive.js +337 -1422
  102. package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
  103. package/dist/request.js +1 -1
  104. package/dist/store/-private.js +2 -3
  105. package/dist/store.js +32 -44
  106. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  107. package/dist/types/-private.js +1 -1
  108. package/dist/types/identifier.js +19 -45
  109. package/dist/types/request.js +45 -3
  110. package/dist/types/schema/fields.js +23 -2
  111. package/dist/utils/string.js +2 -2
  112. package/package.json +10 -10
  113. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  114. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  115. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  116. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  117. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  118. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  119. package/declarations/store/-types/q/ds-model.d.ts +0 -21
  120. package/dist/handler-C2T-IyJK.js +0 -339
@@ -1,7 +1,7 @@
1
1
  type UniversalTransientKey = "REQ_ID";
2
2
  type UniversalKey = `(transient) ${UniversalTransientKey}` | "RequestMap" | "PromiseCache" | "RequestCache" | "SkipCache" | "EnableHydration" | "WarpDriveRuntimeConfig";
3
3
  type TransientKey = "transactionRef" | "configuredGenerationMethod" | "configuredUpdateMethod" | "configuredForgetMethod" | "configuredResetMethod" | "configuredKeyInfoMethod" | "signalHooks";
4
- type GlobalKey = `(transient) ${TransientKey}` | "AdapterError" | "InvalidError" | "TimeoutError" | "AbortError" | "UnauthorizedError" | "ForbiddenError" | "NotFoundError" | "ConflictError" | "ServerError" | "#{}" | "#[]" | "Signals" | "AvailableShims" | "FAKE_ARR" | "#source" | "#update" | "#notify" | "IS_COLLECTION" | "Touching" | "RequestPromise" | "SaveOp" | "LEGACY_SUPPORT" | "LegacySupport" | "Graphs" | "IS_FROZEN" | "IS_CACHE_HANDLER" | "CONFIG" | "DEBUG_MAP" | "IDENTIFIERS" | "DOCUMENTS" | "CacheForIdentifierCache" | "RecordCache" | "StoreMap" | "Store" | "$type" | "TransformName" | "RequestSignature" | "IS_FUTURE" | "DOC" | "ManagedArrayMap" | "ManagedObjectMap" | "Support" | "SOURCE" | "MUTATE" | "Destroy" | "Identifier" | "Editable" | "EmbeddedPath" | "EmbeddedField" | "Parent" | "Checkout" | "Legacy";
4
+ type GlobalKey = `(transient) ${TransientKey}` | "AdapterError" | "InvalidError" | "TimeoutError" | "AbortError" | "UnauthorizedError" | "ForbiddenError" | "NotFoundError" | "ConflictError" | "ServerError" | "#{}" | "#[]" | "Signals" | "AvailableShims" | "FAKE_ARR" | "#source" | "#update" | "#notify" | "IS_COLLECTION" | "Touching" | "RequestPromise" | "SaveOp" | "LEGACY_SUPPORT" | "LegacySupport" | "Graphs" | "IS_FROZEN" | "IS_CACHE_HANDLER" | "CONFIG" | "DEBUG_MAP" | "IDENTIFIERS" | "DOCUMENTS" | "RecordCache" | "StoreMap" | "Store" | "$type" | "TransformName" | "RequestSignature" | "IS_FUTURE" | "DOC" | "ManagedArrayMap" | "ManagedObjectMap" | "Support" | "SOURCE" | "Destroy" | "Checkout" | "Commit" | "Context";
5
5
  type UniqueSymbol<T extends string> = `___(unique) Symbol(${T})`;
6
6
  type UniqueSymbolOr<
7
7
  T,
@@ -1,7 +1,7 @@
1
1
  // The ResourceBlob is an opaque type that must
2
2
  // satisfy two constraints.
3
- // (1) it should be possible for the IdentifierCache
4
- // to be able to generate a RecordIdentifier for it
3
+ // (1) it should be possible for the CacheKeyManager
4
+ // to be able to generate a ResourceKey for it
5
5
  // whether by default or due to configuration.
6
6
  // (2) it should be in a format expected by the Cache.
7
7
  // This format is Cache declared.
@@ -1,6 +1,6 @@
1
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "../identifier.js";
1
+ import type { RequestKey, ResourceKey } from "../identifier.js";
2
2
  export interface Change {
3
- identifier: StableRecordIdentifier | StableDocumentIdentifier;
3
+ identifier: ResourceKey | RequestKey;
4
4
  op: "upsert" | "remove";
5
5
  patch?: unknown;
6
6
  }
@@ -1,48 +1,48 @@
1
- import type { StableRecordIdentifier } from "../identifier.js";
1
+ import type { ResourceKey } from "../identifier.js";
2
2
  export interface AddToResourceRelationshipMutation {
3
3
  op: "add";
4
- record: StableRecordIdentifier;
4
+ record: ResourceKey;
5
5
  field: string;
6
- value: StableRecordIdentifier | StableRecordIdentifier[];
6
+ value: ResourceKey | ResourceKey[];
7
7
  index?: number;
8
8
  }
9
9
  export interface RemoveFromResourceRelationshipMutation {
10
10
  op: "remove";
11
- record: StableRecordIdentifier;
11
+ record: ResourceKey;
12
12
  field: string;
13
- value: StableRecordIdentifier | StableRecordIdentifier[];
13
+ value: ResourceKey | ResourceKey[];
14
14
  index?: number;
15
15
  }
16
16
  export interface ReplaceRelatedRecordMutation {
17
17
  op: "replaceRelatedRecord";
18
- record: StableRecordIdentifier;
18
+ record: ResourceKey;
19
19
  field: string;
20
20
  // never null if field is a collection
21
- value: StableRecordIdentifier | null;
21
+ value: ResourceKey | null;
22
22
  // if field is a collection,
23
23
  // the value we are swapping with
24
- prior?: StableRecordIdentifier;
24
+ prior?: ResourceKey;
25
25
  index?: number;
26
26
  }
27
27
  export interface ReplaceRelatedRecordsMutation {
28
28
  op: "replaceRelatedRecords";
29
- record: StableRecordIdentifier;
29
+ record: ResourceKey;
30
30
  field: string;
31
31
  // the records to add. If no prior/index
32
32
  // specified all existing should be removed
33
- value: StableRecordIdentifier[];
33
+ value: ResourceKey[];
34
34
  // if this is a "splice" the
35
35
  // records we expect to be removed
36
- prior?: StableRecordIdentifier[];
36
+ prior?: ResourceKey[];
37
37
  // if this is a "splice" the
38
38
  // index to start from
39
39
  index?: number;
40
40
  }
41
41
  export interface SortRelatedRecordsMutation {
42
42
  op: "sortRelatedRecords";
43
- record: StableRecordIdentifier;
43
+ record: ResourceKey;
44
44
  field: string;
45
- value: StableRecordIdentifier[];
45
+ value: ResourceKey[];
46
46
  }
47
47
  // A Mutation is an action that updates
48
48
  // the local state of the Cache in some
@@ -1,85 +1,168 @@
1
- import type { StableDocumentIdentifier, StableExistingRecordIdentifier, StableRecordIdentifier } from "../identifier.js";
1
+ import type { PersistedResourceKey, RequestKey, ResourceKey } from "../identifier.js";
2
2
  import type { Value } from "../json/raw.js";
3
3
  import type { ExistingResourceObject } from "../spec/json-api-raw.js";
4
4
  import type { Relationship } from "./relationship.js";
5
+ /**
6
+ * All operations are objects with at least one property,
7
+ * `op` which contains a string with the name of the operation
8
+ * to perform.
9
+ */
5
10
  export interface Op {
11
+ /**
12
+ * The name of the {@link Op | operation}
13
+ */
6
14
  op: string;
7
15
  }
8
- // Occasionally the IdentifierCache
9
- // discovers that two previously thought
10
- // to be distinct Identifiers refer to
11
- // the same ResourceBlob. This Operation
12
- // will be performed giving the Cache the
13
- // change to cleanup and merge internal
14
- // state as desired when this discovery
15
- // is made.
16
+ /**
17
+ * Occasionally the Store discovers that two previously
18
+ * thought to be distinct resources refer to the same resource.
19
+ *
20
+ * This operation will be performed, giving the Cache the chance
21
+ * to cleanup and merge internal state as desired when this discovery
22
+ * is made.
23
+ */
16
24
  export interface MergeOperation extends Op {
17
25
  op: "mergeIdentifiers";
18
- // existing
19
- record: StableRecordIdentifier;
20
- // new
21
- value: StableRecordIdentifier;
26
+ /**
27
+ * The stale {@link ResourceKey | ResourceKey} that
28
+ * the cache should eliminate in favor of {@link MergeOperation.value | value}
29
+ */
30
+ record: ResourceKey;
31
+ /**
32
+ * The kept {@link ResourceKey | ResourceKey} that
33
+ * the cache should also keep and merge {@link MergeOperation.record | record} into.
34
+ */
35
+ value: ResourceKey;
22
36
  }
37
+ /**
38
+ * Removes a document and its associated request from
39
+ * the cache.
40
+ */
23
41
  export interface RemoveDocumentOperation extends Op {
24
42
  op: "remove";
25
- record: StableDocumentIdentifier;
43
+ /**
44
+ * The cache key for the request
45
+ */
46
+ record: RequestKey;
26
47
  }
48
+ /**
49
+ * Removes a resource from the cache. This is treated
50
+ * as if a remote deletion has occurred, and all references
51
+ * to the resource should be eliminated.
52
+ */
27
53
  export interface RemoveResourceOperation extends Op {
28
54
  op: "remove";
29
- record: StableExistingRecordIdentifier;
55
+ /**
56
+ * The cache key for the resource
57
+ */
58
+ record: PersistedResourceKey;
30
59
  }
60
+ /**
61
+ * Adds a resource to the cache.
62
+ */
31
63
  export interface AddResourceOperation extends Op {
32
64
  op: "add";
33
- record: StableExistingRecordIdentifier;
65
+ /**
66
+ * The cache key for the resource
67
+ */
68
+ record: PersistedResourceKey;
69
+ /**
70
+ * The data for the resource
71
+ */
34
72
  value: ExistingResourceObject;
35
73
  }
74
+ /**
75
+ * Upserts (merges) new state for a resource
76
+ */
36
77
  export interface UpdateResourceOperation extends Op {
37
78
  op: "update";
38
- record: StableExistingRecordIdentifier;
79
+ record: PersistedResourceKey;
39
80
  value: ExistingResourceObject;
40
81
  }
82
+ /**
83
+ * Replaces the state of a field with a new state
84
+ */
41
85
  export interface UpdateResourceFieldOperation extends Op {
42
86
  op: "update";
43
- record: StableExistingRecordIdentifier;
87
+ record: PersistedResourceKey;
44
88
  field: string;
45
89
  value: Value;
46
90
  }
91
+ /**
92
+ * Replaces the state of a relationship with a new state
93
+ */
47
94
  export interface UpdateResourceRelationshipOperation extends Op {
48
95
  op: "update";
49
- record: StableExistingRecordIdentifier;
96
+ record: PersistedResourceKey;
50
97
  field: string;
51
- value: Relationship<StableExistingRecordIdentifier>;
98
+ value: Relationship<PersistedResourceKey>;
52
99
  }
100
+ /**
101
+ * Adds a resource to a request document, optionally
102
+ * at a specific index. This can be used to update the
103
+ * result of a request.
104
+ */
53
105
  export interface AddToDocumentOperation extends Op {
54
106
  op: "add";
55
- record: StableDocumentIdentifier;
107
+ record: RequestKey;
56
108
  field: "data" | "included";
57
- value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
109
+ value: PersistedResourceKey | PersistedResourceKey[];
58
110
  index?: number;
59
111
  }
112
+ /**
113
+ * Adds the specified ResourceKeys to a relationship
114
+ */
60
115
  export interface AddToResourceRelationshipOperation extends Op {
61
116
  op: "add";
62
- record: StableExistingRecordIdentifier;
117
+ record: PersistedResourceKey;
63
118
  field: string;
64
- value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
119
+ value: PersistedResourceKey | PersistedResourceKey[];
65
120
  index?: number;
66
121
  }
122
+ /**
123
+ * Removes the specified ResourceKeys from a relationship
124
+ */
67
125
  export interface RemoveFromResourceRelationshipOperation extends Op {
68
126
  op: "remove";
69
- record: StableExistingRecordIdentifier;
127
+ record: PersistedResourceKey;
70
128
  field: string;
71
- value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
129
+ value: PersistedResourceKey | PersistedResourceKey[];
72
130
  index?: number;
73
131
  }
132
+ /**
133
+ * Removes a resource from a request document, optionally
134
+ * at a specific index. This can be used to update the
135
+ * result of a request.
136
+ */
74
137
  export interface RemoveFromDocumentOperation extends Op {
75
138
  op: "remove";
76
- record: StableDocumentIdentifier;
139
+ record: RequestKey;
77
140
  field: "data" | "included";
78
- value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
141
+ value: PersistedResourceKey | PersistedResourceKey[];
79
142
  index?: number;
80
143
  }
81
- // An Operation is an action that updates
82
- // the remote state of the Cache in some
83
- // manner. Additional Operations will be
84
- // added in the future.
144
+ /**
145
+ * {@link Cache} Operations perform updates to the
146
+ * Cache's "remote" (or clean) state to reflect external
147
+ * changes.
148
+ *
149
+ * Usually operations represent the result of a {@link WebSocket} or
150
+ * {@link EventSource | ServerEvent} message, though they can also be used to carefully
151
+ * patch the state of the cache with information known by the
152
+ * application or developer.
153
+ *
154
+ * Operations are applied via {@link Cache.patch}.
155
+ *
156
+ * See also:
157
+ * - {@link MergeOperation}
158
+ * - {@link RemoveResourceOperation}
159
+ * - {@link RemoveDocumentOperation}
160
+ * - {@link AddResourceOperation}
161
+ * - {@link UpdateResourceOperation}
162
+ * - {@link UpdateResourceFieldOperation}
163
+ * - {@link AddToResourceRelationshipOperation}
164
+ * - {@link RemoveFromResourceRelationshipOperation}
165
+ * - {@link AddToDocumentOperation}
166
+ * - {@link RemoveFromDocumentOperation}
167
+ */
85
168
  export type Operation = MergeOperation | RemoveResourceOperation | RemoveDocumentOperation | AddResourceOperation | UpdateResourceOperation | UpdateResourceFieldOperation | AddToResourceRelationshipOperation | RemoveFromResourceRelationshipOperation | AddToDocumentOperation | RemoveFromDocumentOperation;
@@ -1,16 +1,16 @@
1
- import type { StableRecordIdentifier } from "../identifier.js";
1
+ import type { ResourceKey } from "../identifier.js";
2
2
  import type { Links, Meta, PaginationLinks } from "../spec/json-api-raw.js";
3
3
  // we request that it be in the stable form already.
4
- export interface ResourceRelationship<T = StableRecordIdentifier> {
4
+ export interface ResourceRelationship<T = ResourceKey> {
5
5
  data?: T | null;
6
6
  meta?: Meta;
7
7
  links?: Links;
8
8
  }
9
9
  // Note: in v1 data could be a ResourceIdentifier, now
10
10
  // we request that it be in the stable form already.
11
- export interface CollectionRelationship<T = StableRecordIdentifier> {
11
+ export interface CollectionRelationship<T = ResourceKey> {
12
12
  data?: T[];
13
13
  meta?: Meta;
14
14
  links?: PaginationLinks;
15
15
  }
16
- export type Relationship<T = StableRecordIdentifier> = ResourceRelationship<T> | CollectionRelationship<T>;
16
+ export type Relationship<T = ResourceKey> = ResourceRelationship<T> | CollectionRelationship<T>;