@warp-drive/core 5.6.0-alpha.15 → 5.6.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/build-config/babel-macros.d.ts +1 -2
- package/declarations/build-config/canary-features.d.ts +1 -2
- package/declarations/build-config/debugging.d.ts +1 -2
- package/declarations/build-config/deprecations.d.ts +1 -2
- package/declarations/build-config/env.d.ts +1 -2
- package/declarations/build-config/macros.d.ts +1 -2
- package/declarations/build-config.d.ts +1 -2
- package/declarations/configure.d.ts +6 -7
- package/declarations/graph/-private/-diff.d.ts +21 -22
- package/declarations/graph/-private/-edge-definition.d.ts +134 -135
- package/declarations/graph/-private/-state.d.ts +93 -7
- package/declarations/graph/-private/-utils.d.ts +18 -13
- package/declarations/graph/-private/coerce-id.d.ts +6 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/graph/-private/edges/collection.d.ts +35 -36
- package/declarations/graph/-private/edges/implicit.d.ts +28 -29
- package/declarations/graph/-private/edges/resource.d.ts +19 -20
- package/declarations/graph/-private/graph.d.ts +83 -48
- package/declarations/graph/-private/normalize-link.d.ts +7 -2
- package/declarations/graph/-private/operations/add-to-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/merge-identifier.d.ts +2 -3
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/replace-related-record.d.ts +2 -3
- package/declarations/graph/-private/operations/replace-related-records.d.ts +58 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +11 -9
- package/declarations/graph/-private.d.ts +9 -10
- package/declarations/index.d.ts +11 -12
- package/declarations/reactive/-private/document.d.ts +143 -144
- package/declarations/reactive/-private/fields/compute.d.ts +31 -28
- package/declarations/reactive/-private/fields/extension.d.ts +2 -3
- package/declarations/reactive/-private/fields/managed-array.d.ts +19 -20
- package/declarations/reactive/-private/fields/managed-object.d.ts +16 -16
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +15 -16
- package/declarations/reactive/-private/hooks.d.ts +3 -4
- package/declarations/reactive/-private/record.d.ts +61 -59
- package/declarations/reactive/-private/schema.d.ts +242 -224
- package/declarations/reactive/-private/symbols.d.ts +26 -1
- package/declarations/reactive/-private.d.ts +1 -2
- package/declarations/reactive.d.ts +4 -5
- package/declarations/request/-private/context.d.ts +34 -35
- package/declarations/request/-private/debug.d.ts +2 -3
- package/declarations/request/-private/fetch.d.ts +23 -24
- package/declarations/request/-private/future.d.ts +3 -4
- package/declarations/request/-private/manager.d.ts +159 -157
- package/declarations/request/-private/promise-cache.d.ts +21 -13
- package/declarations/request/-private/types.d.ts +124 -124
- package/declarations/request/-private/utils.d.ts +8 -9
- package/declarations/request.d.ts +5 -6
- package/declarations/store/-private/cache-handler/handler.d.ts +57 -52
- package/declarations/store/-private/cache-handler/types.d.ts +95 -96
- package/declarations/store/-private/cache-handler/utils.d.ts +16 -16
- package/declarations/store/-private/caches/cache-utils.d.ts +7 -4
- package/declarations/store/-private/caches/identifier-cache.d.ts +234 -246
- package/declarations/store/-private/caches/instance-cache.d.ts +47 -47
- package/declarations/store/-private/caches/resource-utils.d.ts +3 -4
- package/declarations/store/-private/debug/utils.d.ts +6 -7
- package/declarations/store/-private/default-cache-policy.d.ts +362 -361
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +154 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +14 -14
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +21 -22
- package/declarations/store/-private/managers/cache-manager.d.ts +440 -425
- package/declarations/store/-private/managers/notification-manager.d.ts +88 -83
- package/declarations/store/-private/managers/record-array-manager.d.ts +89 -90
- package/declarations/store/-private/network/request-cache.d.ts +86 -83
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts +252 -244
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +154 -155
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +148 -149
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +28 -23
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +263 -241
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +253 -223
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +125 -121
- package/declarations/store/-private/record-arrays/many-array.d.ts +180 -184
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +120 -110
- package/declarations/store/-private/store-service.d.ts +1594 -1586
- package/declarations/store/-private/utils/coerce-id.d.ts +6 -1
- package/declarations/store/-private/utils/construct-resource.d.ts +1 -2
- package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/declarations/store/-private.d.ts +31 -28
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +96 -97
- package/declarations/store/-types/q/ds-model.d.ts +17 -18
- package/declarations/store/-types/q/identifier.d.ts +11 -12
- package/declarations/store/-types/q/record-instance.d.ts +16 -17
- package/declarations/store/-types/q/schema-service.d.ts +346 -343
- package/declarations/store/-types/q/store.d.ts +25 -28
- package/declarations/store.d.ts +1 -2
- package/declarations/types/-private.d.ts +16 -8
- package/declarations/types/cache/aliases.d.ts +11 -1
- package/declarations/types/cache/change.d.ts +4 -5
- package/declarations/types/cache/mutations.d.ts +51 -28
- package/declarations/types/cache/operations.d.ts +60 -47
- package/declarations/types/cache/relationship.d.ts +11 -9
- package/declarations/types/cache.d.ts +495 -484
- package/declarations/types/graph.d.ts +31 -32
- package/declarations/types/identifier.d.ts +83 -82
- package/declarations/types/json/raw.d.ts +1 -2
- package/declarations/types/params.d.ts +4 -5
- package/declarations/types/record.d.ts +117 -76
- package/declarations/types/request.d.ts +289 -266
- package/declarations/types/runtime.d.ts +8 -9
- package/declarations/types/schema/concepts.d.ts +19 -13
- package/declarations/types/schema/fields.d.ts +1712 -1713
- package/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/declarations/types/spec/document.d.ts +28 -22
- package/declarations/types/spec/error.d.ts +16 -17
- package/declarations/types/spec/json-api-raw.d.ts +102 -102
- package/declarations/types/symbols.d.ts +74 -75
- package/declarations/types/utils.d.ts +5 -5
- package/declarations/types.d.ts +10 -11
- package/declarations/utils/string.d.ts +43 -40
- package/dist/graph/-private.js +1 -1
- package/dist/{handler-D1C3Innj.js → handler-C2T-IyJK.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +42 -73
- package/dist/{request-state-CCOJIj5i.js → request-state-CjLph1LP.js} +275 -261
- package/dist/store/-private.js +2 -2
- package/dist/{symbols-epHW0Vm9.js → symbols-SIstXMLI.js} +1 -1
- package/dist/types/-private.js +1 -1
- package/package.json +4 -4
- package/declarations/build-config/babel-macros.d.ts.map +0 -1
- package/declarations/build-config/canary-features.d.ts.map +0 -1
- package/declarations/build-config/debugging.d.ts.map +0 -1
- package/declarations/build-config/deprecations.d.ts.map +0 -1
- package/declarations/build-config/env.d.ts.map +0 -1
- package/declarations/build-config/macros.d.ts.map +0 -1
- package/declarations/build-config.d.ts.map +0 -1
- package/declarations/configure.d.ts.map +0 -1
- package/declarations/graph/-private/-diff.d.ts.map +0 -1
- package/declarations/graph/-private/-edge-definition.d.ts.map +0 -1
- package/declarations/graph/-private/-state.d.ts.map +0 -1
- package/declarations/graph/-private/-utils.d.ts.map +0 -1
- package/declarations/graph/-private/coerce-id.d.ts.map +0 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/graph/-private/edges/collection.d.ts.map +0 -1
- package/declarations/graph/-private/edges/implicit.d.ts.map +0 -1
- package/declarations/graph/-private/edges/resource.d.ts.map +0 -1
- package/declarations/graph/-private/graph.d.ts.map +0 -1
- package/declarations/graph/-private/normalize-link.d.ts.map +0 -1
- package/declarations/graph/-private/operations/add-to-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/merge-identifier.d.ts.map +0 -1
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-record.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/update-relationship.d.ts.map +0 -1
- package/declarations/graph/-private.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/reactive/-private/document.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/compute.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/extension.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-array.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-object.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/many-array-manager.d.ts.map +0 -1
- package/declarations/reactive/-private/hooks.d.ts.map +0 -1
- package/declarations/reactive/-private/record.d.ts.map +0 -1
- package/declarations/reactive/-private/schema.d.ts.map +0 -1
- package/declarations/reactive/-private/symbols.d.ts.map +0 -1
- package/declarations/reactive/-private.d.ts.map +0 -1
- package/declarations/reactive.d.ts.map +0 -1
- package/declarations/request/-private/context.d.ts.map +0 -1
- package/declarations/request/-private/debug.d.ts.map +0 -1
- package/declarations/request/-private/fetch.d.ts.map +0 -1
- package/declarations/request/-private/future.d.ts.map +0 -1
- package/declarations/request/-private/manager.d.ts.map +0 -1
- package/declarations/request/-private/promise-cache.d.ts.map +0 -1
- package/declarations/request/-private/types.d.ts.map +0 -1
- package/declarations/request/-private/utils.d.ts.map +0 -1
- package/declarations/request.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/handler.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/types.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/cache-utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/identifier-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/instance-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/resource-utils.d.ts.map +0 -1
- package/declarations/store/-private/debug/utils.d.ts.map +0 -1
- package/declarations/store/-private/default-cache-policy.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/notification-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/record-array-manager.d.ts.map +0 -1
- package/declarations/store/-private/network/request-cache.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/identifier-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/many-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts.map +0 -1
- package/declarations/store/-private/store-service.d.ts.map +0 -1
- package/declarations/store/-private/store-service.type-test.d.ts +0 -2
- package/declarations/store/-private/store-service.type-test.d.ts.map +0 -1
- package/declarations/store/-private/utils/coerce-id.d.ts.map +0 -1
- package/declarations/store/-private/utils/construct-resource.d.ts.map +0 -1
- package/declarations/store/-private/utils/is-non-empty-string.d.ts.map +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts.map +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts.map +0 -1
- package/declarations/store/-private.d.ts.map +0 -1
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-types/q/ds-model.d.ts.map +0 -1
- package/declarations/store/-types/q/identifier.d.ts.map +0 -1
- package/declarations/store/-types/q/promise-proxies.d.ts +0 -2
- package/declarations/store/-types/q/promise-proxies.d.ts.map +0 -1
- package/declarations/store/-types/q/record-data-json-api.d.ts +0 -31
- package/declarations/store/-types/q/record-data-json-api.d.ts.map +0 -1
- package/declarations/store/-types/q/record-instance.d.ts.map +0 -1
- package/declarations/store/-types/q/schema-service.d.ts.map +0 -1
- package/declarations/store/-types/q/store.d.ts.map +0 -1
- package/declarations/store.d.ts.map +0 -1
- package/declarations/types/-private.d.ts.map +0 -1
- package/declarations/types/cache/aliases.d.ts.map +0 -1
- package/declarations/types/cache/change.d.ts.map +0 -1
- package/declarations/types/cache/mutations.d.ts.map +0 -1
- package/declarations/types/cache/operations.d.ts.map +0 -1
- package/declarations/types/cache/relationship.d.ts.map +0 -1
- package/declarations/types/cache.d.ts.map +0 -1
- package/declarations/types/graph.d.ts.map +0 -1
- package/declarations/types/identifier.d.ts.map +0 -1
- package/declarations/types/json/raw.d.ts.map +0 -1
- package/declarations/types/params.d.ts.map +0 -1
- package/declarations/types/record.d.ts.map +0 -1
- package/declarations/types/record.type-test.d.ts +0 -2
- package/declarations/types/record.type-test.d.ts.map +0 -1
- package/declarations/types/request.d.ts.map +0 -1
- package/declarations/types/request.type-test.d.ts +0 -2
- package/declarations/types/request.type-test.d.ts.map +0 -1
- package/declarations/types/runtime.d.ts.map +0 -1
- package/declarations/types/schema/concepts.d.ts.map +0 -1
- package/declarations/types/schema/fields.d.ts.map +0 -1
- package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
- package/declarations/types/spec/document.d.ts.map +0 -1
- package/declarations/types/spec/error.d.ts.map +0 -1
- package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
- package/declarations/types/symbols.d.ts.map +0 -1
- package/declarations/types/utils.d.ts.map +0 -1
- package/declarations/types.d.ts.map +0 -1
- package/declarations/utils/string.d.ts.map +0 -1
- package/dist/build-config/babel-macros.js.map +0 -1
- package/dist/build-config/canary-features.js.map +0 -1
- package/dist/build-config/debugging.js.map +0 -1
- package/dist/build-config/deprecations.js.map +0 -1
- package/dist/build-config/env.js.map +0 -1
- package/dist/build-config/macros.js.map +0 -1
- package/dist/build-config.js.map +0 -1
- package/dist/configure-B48bFHOl.js.map +0 -1
- package/dist/configure.js.map +0 -1
- package/dist/context-COmAnXUQ.js.map +0 -1
- package/dist/graph/-private.js.map +0 -1
- package/dist/handler-D1C3Innj.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reactive/-private.js.map +0 -1
- package/dist/reactive.js.map +0 -1
- package/dist/request-state-CCOJIj5i.js.map +0 -1
- package/dist/request.js.map +0 -1
- package/dist/store/-private.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/symbols-epHW0Vm9.js.map +0 -1
- package/dist/types/-private.js.map +0 -1
- package/dist/types/cache/aliases.js.map +0 -1
- package/dist/types/cache/change.js.map +0 -1
- package/dist/types/cache/mutations.js.map +0 -1
- package/dist/types/cache/operations.js.map +0 -1
- package/dist/types/cache/relationship.js.map +0 -1
- package/dist/types/cache.js.map +0 -1
- package/dist/types/graph.js.map +0 -1
- package/dist/types/identifier.js.map +0 -1
- package/dist/types/json/raw.js.map +0 -1
- package/dist/types/params.js.map +0 -1
- package/dist/types/record.js.map +0 -1
- package/dist/types/request.js.map +0 -1
- package/dist/types/runtime.js.map +0 -1
- package/dist/types/schema/concepts.js.map +0 -1
- package/dist/types/schema/fields.js.map +0 -1
- package/dist/types/schema/fields.type-test.js.map +0 -1
- package/dist/types/spec/document.js.map +0 -1
- package/dist/types/spec/error.js.map +0 -1
- package/dist/types/spec/json-api-raw.js.map +0 -1
- package/dist/types/symbols.js.map +0 -1
- package/dist/types/utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/string.js.map +0 -1
|
@@ -1,93 +1,98 @@
|
|
|
1
|
-
import type { StableDocumentIdentifier, StableRecordIdentifier } from
|
|
2
|
-
import type { Store } from
|
|
1
|
+
import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
|
|
2
|
+
import type { Store } from "../store-service.js";
|
|
3
3
|
export type UnsubscribeToken = object;
|
|
4
|
-
export type CacheOperation =
|
|
5
|
-
export type DocumentCacheOperation =
|
|
6
|
-
export type NotificationType =
|
|
4
|
+
export type CacheOperation = "added" | "removed" | "updated" | "state";
|
|
5
|
+
export type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state";
|
|
6
|
+
export type NotificationType = "attributes" | "relationships" | "identity" | "errors" | "meta" | CacheOperation;
|
|
7
7
|
export interface NotificationCallback {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
(identifier: StableRecordIdentifier, notificationType: "attributes" | "relationships", key?: string): void;
|
|
9
|
+
(identifier: StableRecordIdentifier, notificationType: "errors" | "meta" | "identity" | "state"): void;
|
|
10
|
+
(identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
|
|
11
11
|
}
|
|
12
12
|
export interface ResourceOperationCallback {
|
|
13
|
-
|
|
13
|
+
// resource updates
|
|
14
|
+
(identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
|
|
14
15
|
}
|
|
15
16
|
export interface DocumentOperationCallback {
|
|
16
|
-
|
|
17
|
+
// document updates
|
|
18
|
+
(identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
* The NotificationManager provides the ability to subscribe to
|
|
22
|
+
* changes to Cache state.
|
|
23
|
+
*
|
|
24
|
+
* This Feature is what allows WarpDrive to create subscriptions that
|
|
25
|
+
* work with any framework or change-notification system.
|
|
26
|
+
*
|
|
27
|
+
* @hideconstructor
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
28
30
|
export default class NotificationManager {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
31
|
+
/** @internal */
|
|
32
|
+
private store;
|
|
33
|
+
/** @internal */
|
|
34
|
+
private isDestroyed;
|
|
35
|
+
/** @internal */
|
|
36
|
+
private _buffered;
|
|
37
|
+
/** @internal */
|
|
38
|
+
private _cache;
|
|
39
|
+
/** @internal */
|
|
40
|
+
private _hasFlush;
|
|
41
|
+
/** @internal */
|
|
42
|
+
private _onFlushCB?;
|
|
43
|
+
constructor(store: Store);
|
|
44
|
+
/**
|
|
45
|
+
* Subscribe to changes for a given resource identifier, resource addition/removal, or document addition/removal.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
|
|
49
|
+
*
|
|
50
|
+
* export interface NotificationCallback {
|
|
51
|
+
* (identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
|
|
52
|
+
* (identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
|
|
53
|
+
* (identifier: StableRecordIdentifier, notificationType: NotificationType, key?: string): void;
|
|
54
|
+
* }
|
|
55
|
+
* export interface ResourceOperationCallback {
|
|
56
|
+
* // resource updates
|
|
57
|
+
* (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
|
|
58
|
+
* }
|
|
59
|
+
* export interface DocumentOperationCallback {
|
|
60
|
+
* // document updates
|
|
61
|
+
* (identifier: StableDocumentIdentifier, notificationType: CacheOperation): void;
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
* @param {StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'} identifier
|
|
67
|
+
* @param {NotificationCallback | ResourceOperationCallback | DocumentOperationCallback} callback
|
|
68
|
+
* @return {UnsubscribeToken} an opaque token to be used with unsubscribe
|
|
69
|
+
*/
|
|
70
|
+
subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
|
|
71
|
+
subscribe(identifier: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
|
|
72
|
+
subscribe(identifier: "document" | StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
|
|
73
|
+
/**
|
|
74
|
+
* remove a previous subscription
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
unsubscribe(token: UnsubscribeToken): void;
|
|
79
|
+
/**
|
|
80
|
+
* Custom Caches and Application Code should not call this method directly.
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
notify(identifier: StableRecordIdentifier, value: "attributes" | "relationships", key?: string): boolean;
|
|
85
|
+
notify(identifier: StableRecordIdentifier, value: "errors" | "meta" | "identity" | "state"): boolean;
|
|
86
|
+
notify(identifier: StableRecordIdentifier, value: CacheOperation): boolean;
|
|
87
|
+
notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation): boolean;
|
|
88
|
+
/** @internal */
|
|
89
|
+
_onNextFlush(cb: () => void): void;
|
|
90
|
+
private _scheduleNotify;
|
|
91
|
+
/** @internal */
|
|
92
|
+
_flush(): void;
|
|
93
|
+
private _flushNotification;
|
|
94
|
+
private _flushNotification;
|
|
95
|
+
private _flushNotification;
|
|
96
|
+
/** @internal */
|
|
97
|
+
destroy(): void;
|
|
92
98
|
}
|
|
93
|
-
//# sourceMappingURL=notification-manager.d.ts.map
|
|
@@ -1,98 +1,97 @@
|
|
|
1
|
-
import type { LocalRelationshipOperation } from
|
|
2
|
-
import type { StableDocumentIdentifier, StableRecordIdentifier } from
|
|
3
|
-
import type { ImmutableRequestInfo } from
|
|
4
|
-
import type { CollectionResourceDocument } from
|
|
5
|
-
import { Collection, IdentifierArray } from
|
|
6
|
-
import type { Store } from
|
|
7
|
-
import type { UnsubscribeToken } from
|
|
1
|
+
import type { LocalRelationshipOperation } from "../../../types/graph.js";
|
|
2
|
+
import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
|
|
3
|
+
import type { ImmutableRequestInfo } from "../../../types/request.js";
|
|
4
|
+
import type { CollectionResourceDocument } from "../../../types/spec/json-api-raw.js";
|
|
5
|
+
import { Collection, IdentifierArray } from "../record-arrays/identifier-array.js";
|
|
6
|
+
import type { Store } from "../store-service.js";
|
|
7
|
+
import type { UnsubscribeToken } from "./notification-manager.js";
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
9
|
+
* This is a clever optimization.
|
|
10
|
+
*
|
|
11
|
+
* clever optimizations rarely stand the test of time, so if you're
|
|
12
|
+
* ever curious or think something better is possible please benchmark
|
|
13
|
+
* and discuss. The benchmark for this at the time of writing is in
|
|
14
|
+
* `scripts/benchmark-push.js`
|
|
15
|
+
*
|
|
16
|
+
* This approach turns out to be 150x faster in Chrome and node than
|
|
17
|
+
* simply using push or concat. It's highly susceptible to the specifics
|
|
18
|
+
* of the batch size, and may require tuning.
|
|
19
|
+
*
|
|
20
|
+
* Clever optimizations should always come with a `why`. This optimization
|
|
21
|
+
* exists for two reasons.
|
|
22
|
+
*
|
|
23
|
+
* 1) array.push(...objects) and Array.prototype.push.apply(arr, objects)
|
|
24
|
+
* are susceptible to stack overflows. The size of objects at which this
|
|
25
|
+
* occurs varies by environment, browser, and current stack depth and memory
|
|
26
|
+
* pressure; however, it occurs in all browsers in fairly pristine conditions
|
|
27
|
+
* somewhere around 125k to 200k elements. Since WarpDrive regularly encounters
|
|
28
|
+
* arrays larger than this in size, we cannot use push.
|
|
29
|
+
*
|
|
30
|
+
* 2) `array.concat` or simply setting the array to a new reference is often an
|
|
31
|
+
* easier approach; however, native Proxy to an array cannot swap it's target array
|
|
32
|
+
* and attempts at juggling multiple array sources have proven to be victim to a number
|
|
33
|
+
* of browser implementation bugs. Should these bugs be addressed then we could
|
|
34
|
+
* simplify to using `concat`, however, do note this is currently 150x faster
|
|
35
|
+
* than concat, and due to the overloaded signature of concat will likely always
|
|
36
|
+
* be faster.
|
|
37
|
+
*
|
|
38
|
+
* Sincerely,
|
|
39
|
+
* - runspired (Chris Thoburn) 08/21/2022
|
|
40
|
+
*
|
|
41
|
+
* @function fastPush
|
|
42
|
+
* @internal
|
|
43
|
+
* @param target the array to push into
|
|
44
|
+
* @param source the items to push into target
|
|
45
|
+
*/
|
|
46
46
|
export declare function fastPush<T>(target: T[], source: T[]): void;
|
|
47
|
-
type ChangeSet = Map<StableRecordIdentifier,
|
|
47
|
+
type ChangeSet = Map<StableRecordIdentifier, "add" | "del">;
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
@class RecordArrayManager
|
|
50
|
+
@internal
|
|
51
51
|
*/
|
|
52
52
|
export declare class RecordArrayManager {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
53
|
+
store: Store;
|
|
54
|
+
isDestroying: boolean;
|
|
55
|
+
isDestroyed: boolean;
|
|
56
|
+
_set: Map<IdentifierArray, Set<StableRecordIdentifier>>;
|
|
57
|
+
_live: Map<string, IdentifierArray>;
|
|
58
|
+
_managed: Set<IdentifierArray>;
|
|
59
|
+
_pending: Map<IdentifierArray, ChangeSet>;
|
|
60
|
+
_identifiers: Map<StableRecordIdentifier, Set<Collection>>;
|
|
61
|
+
_staged: Map<string, ChangeSet>;
|
|
62
|
+
_subscription: UnsubscribeToken;
|
|
63
|
+
_documentSubscription: UnsubscribeToken;
|
|
64
|
+
_keyedArrays: Map<string, Collection>;
|
|
65
|
+
_visibilitySet: Map<StableRecordIdentifier, boolean>;
|
|
66
|
+
constructor(options: {
|
|
67
|
+
store: Store;
|
|
68
|
+
});
|
|
69
|
+
_syncArray(array: IdentifierArray | Collection): void;
|
|
70
|
+
mutate(mutation: LocalRelationshipOperation): void;
|
|
71
|
+
/**
|
|
72
|
+
Get the `RecordArray` for a modelName, which contains all loaded records of
|
|
73
|
+
given modelName.
|
|
74
|
+
|
|
75
|
+
@internal
|
|
76
|
+
@param {String} modelName
|
|
77
|
+
@return {RecordArray}
|
|
78
|
+
*/
|
|
79
|
+
liveArrayFor(type: string): IdentifierArray;
|
|
80
|
+
getCollection(config: {
|
|
81
|
+
type?: string;
|
|
82
|
+
query?: ImmutableRequestInfo | Record<string, unknown>;
|
|
83
|
+
identifiers?: StableRecordIdentifier[];
|
|
84
|
+
doc?: CollectionResourceDocument;
|
|
85
|
+
identifier?: StableDocumentIdentifier | null;
|
|
86
|
+
}): Collection;
|
|
87
|
+
dirtyArray(array: IdentifierArray, delta: number, shouldSyncFromCache: boolean): void;
|
|
88
|
+
_getPendingFor(identifier: StableRecordIdentifier, includeManaged: boolean, isRemove?: boolean): Map<IdentifierArray, ChangeSet> | void;
|
|
89
|
+
populateManagedArray(array: Collection, identifiers: StableRecordIdentifier[], payload: CollectionResourceDocument | null): void;
|
|
90
|
+
identifierAdded(identifier: StableRecordIdentifier): void;
|
|
91
|
+
identifierRemoved(identifier: StableRecordIdentifier): void;
|
|
92
|
+
identifierChanged(identifier: StableRecordIdentifier): void;
|
|
93
|
+
clear(isClear?: boolean): void;
|
|
94
|
+
destroy(): void;
|
|
95
95
|
}
|
|
96
96
|
export declare function disassociateIdentifier(ArraysCache: Map<StableRecordIdentifier, Set<Collection>>, array: Collection, identifier: StableRecordIdentifier): void;
|
|
97
97
|
export {};
|
|
98
|
-
//# sourceMappingURL=record-array-manager.d.ts.map
|
|
@@ -1,104 +1,107 @@
|
|
|
1
|
-
import type { StableRecordIdentifier } from
|
|
2
|
-
import type { FindRecordOptions } from
|
|
3
|
-
import type { Store } from
|
|
1
|
+
import type { StableRecordIdentifier } from "../../../types/identifier.js";
|
|
2
|
+
import type { FindRecordOptions } from "../../-types/q/store.js";
|
|
3
|
+
import type { Store } from "../store-service.js";
|
|
4
4
|
declare const Touching: "___(unique) Symbol(Touching)";
|
|
5
5
|
export declare const RequestPromise: "___(unique) Symbol(RequestPromise)";
|
|
6
6
|
export interface Operation {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
op: string;
|
|
8
|
+
options: FindRecordOptions | undefined;
|
|
9
|
+
recordIdentifier: StableRecordIdentifier;
|
|
10
10
|
}
|
|
11
11
|
export interface FindRecordQuery extends Operation {
|
|
12
|
-
|
|
12
|
+
op: "findRecord";
|
|
13
13
|
}
|
|
14
14
|
export interface SaveRecordMutation extends Operation {
|
|
15
|
-
|
|
15
|
+
op: "saveRecord";
|
|
16
16
|
}
|
|
17
17
|
export interface Request {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
data: Operation[];
|
|
19
|
+
options?: Record<string, unknown>;
|
|
20
20
|
}
|
|
21
|
-
export type RequestStates =
|
|
21
|
+
export type RequestStates = "pending" | "fulfilled" | "rejected";
|
|
22
22
|
export interface RequestCacheRequestState {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
state: RequestStates;
|
|
24
|
+
type: "query" | "mutation";
|
|
25
|
+
request: Request;
|
|
26
|
+
response?: Response;
|
|
27
27
|
}
|
|
28
28
|
export interface Response {
|
|
29
|
-
|
|
29
|
+
// rawData: unknown;
|
|
30
|
+
data: unknown;
|
|
30
31
|
}
|
|
31
32
|
interface InternalRequest extends RequestCacheRequestState {
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
[Touching]: StableRecordIdentifier[];
|
|
34
|
+
[RequestPromise]?: Promise<unknown>;
|
|
34
35
|
}
|
|
35
36
|
export type RequestSubscription = (requestState: RequestCacheRequestState) => void;
|
|
36
37
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
* The RequestStateService is used to track the state of requests
|
|
39
|
+
* for fetching or updating known resource identifies that are inflight.
|
|
40
|
+
*
|
|
41
|
+
* @hideconstructor
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
43
44
|
export declare class RequestStateService {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
45
|
+
/** @internal */
|
|
46
|
+
_pending: Map<StableRecordIdentifier, InternalRequest[]>;
|
|
47
|
+
private _done;
|
|
48
|
+
private _subscriptions;
|
|
49
|
+
private _toFlush;
|
|
50
|
+
private _store;
|
|
51
|
+
constructor(store: Store);
|
|
52
|
+
/** @internal */
|
|
53
|
+
_clearEntries(identifier: StableRecordIdentifier): void;
|
|
54
|
+
/** @internal */
|
|
55
|
+
_enqueue<T>(promise: Promise<T>, queryRequest: Request): Promise<T>;
|
|
56
|
+
private _triggerSubscriptions;
|
|
57
|
+
private _flush;
|
|
58
|
+
private _flushRequest;
|
|
59
|
+
private _dequeue;
|
|
60
|
+
private _addDone;
|
|
61
|
+
/**
|
|
62
|
+
* Subscribe to requests for a given resource identity.
|
|
63
|
+
*
|
|
64
|
+
* The callback will receive the current state of the request.
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* interface RequestState {
|
|
68
|
+
* state: 'pending' | 'fulfilled' | 'rejected';
|
|
69
|
+
* type: 'query' | 'mutation';
|
|
70
|
+
* request: Request;
|
|
71
|
+
* response?: { data: unknown };
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* Note: It should be considered dangerous to use this API for more than simple
|
|
76
|
+
* state derivation or debugging. The `request` and `response` properties are poorly
|
|
77
|
+
* spec'd and may change unexpectedly when shifting what Handlers are in use or how
|
|
78
|
+
* requests are issued from the Store.
|
|
79
|
+
*
|
|
80
|
+
* We expect to revisit this API in the near future as we continue to refine the
|
|
81
|
+
* RequestManager ergonomics, as a simpler but more powerful direct integration
|
|
82
|
+
* with the RequestManager for these purposes is likely to be a better long-term
|
|
83
|
+
* design.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
* @param {StableRecordIdentifier} identifier
|
|
87
|
+
* @param {(state: RequestCacheRequestState) => void} callback
|
|
88
|
+
*/
|
|
89
|
+
subscribeForRecord(identifier: StableRecordIdentifier, callback: RequestSubscription): void;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve all active requests for a given resource identity.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @param {StableRecordIdentifier} identifier
|
|
95
|
+
* @return {RequestCacheRequestState[]} an array of request states for any pending requests for the given identifier
|
|
96
|
+
*/
|
|
97
|
+
getPendingRequestsForRecord(identifier: StableRecordIdentifier): RequestCacheRequestState[];
|
|
98
|
+
/**
|
|
99
|
+
* Retrieve the last completed request for a given resource identity.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
* @param {StableRecordIdentifier} identifier
|
|
103
|
+
* @return {RequestCacheRequestState | null} the state of the most recent request for the given identifier
|
|
104
|
+
*/
|
|
105
|
+
getLastRequestForRecord(identifier: StableRecordIdentifier): RequestCacheRequestState | null;
|
|
102
106
|
}
|
|
103
107
|
export {};
|
|
104
|
-
//# sourceMappingURL=request-cache.d.ts.map
|