@warp-drive/core 5.6.0-alpha.5 → 5.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/cjs-dist/addon-shim.cjs +1 -0
- package/cjs-dist/cjs-set-config.cjs +1 -0
- package/declarations/build-config/babel-macros.d.ts +1 -0
- package/declarations/build-config/canary-features.d.ts +1 -0
- package/declarations/build-config/debugging.d.ts +1 -0
- package/declarations/build-config/deprecations.d.ts +1 -0
- package/declarations/build-config/env.d.ts +1 -0
- package/declarations/build-config/macros.d.ts +1 -0
- package/declarations/build-config.d.ts +1 -0
- package/declarations/configure.d.ts +7 -0
- package/declarations/graph/-private/-diff.d.ts +32 -0
- package/declarations/graph/-private/-edge-definition.d.ts +148 -0
- package/declarations/graph/-private/-state.d.ts +96 -0
- package/declarations/graph/-private/-utils.d.ts +31 -0
- package/declarations/graph/-private/coerce-id.d.ts +10 -0
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +18 -0
- package/declarations/graph/-private/edges/collection.d.ts +39 -0
- package/declarations/graph/-private/edges/implicit.d.ts +43 -0
- package/declarations/graph/-private/edges/resource.d.ts +24 -0
- package/declarations/graph/-private/graph.d.ts +90 -0
- package/declarations/graph/-private/normalize-link.d.ts +8 -0
- package/declarations/graph/-private/operations/add-to-related-records.d.ts +4 -0
- package/declarations/graph/-private/operations/merge-identifier.d.ts +3 -0
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts +4 -0
- package/declarations/graph/-private/operations/replace-related-record.d.ts +3 -0
- package/declarations/graph/-private/operations/replace-related-records.d.ts +62 -0
- package/declarations/graph/-private/operations/update-relationship.d.ts +13 -0
- package/declarations/graph/-private.d.ts +13 -0
- package/declarations/index.d.ts +14 -3
- package/declarations/reactive/-private/document.d.ts +146 -0
- package/declarations/reactive/-private/fields/compute.d.ts +43 -0
- package/declarations/reactive/-private/fields/extension.d.ts +8 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +22 -0
- package/declarations/reactive/-private/fields/managed-object.d.ts +21 -0
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +19 -0
- package/declarations/reactive/-private/hooks.d.ts +5 -0
- package/declarations/reactive/-private/record.d.ts +64 -0
- package/declarations/reactive/-private/schema.d.ts +271 -0
- package/declarations/reactive/-private/symbols.d.ts +36 -0
- package/declarations/reactive/-private.d.ts +1 -0
- package/declarations/reactive.d.ts +4 -0
- 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 +24 -36
- package/declarations/request/-private/future.d.ts +3 -4
- package/declarations/request/-private/manager.d.ts +159 -132
- package/declarations/request/-private/promise-cache.d.ts +21 -13
- package/declarations/request/-private/types.d.ts +124 -123
- package/declarations/request/-private/utils.d.ts +8 -9
- package/declarations/request.d.ts +5 -433
- package/declarations/store/-private/cache-handler/handler.d.ts +62 -0
- package/declarations/store/-private/cache-handler/types.d.ts +98 -0
- package/declarations/store/-private/cache-handler/utils.d.ts +32 -0
- package/declarations/store/-private/caches/cache-utils.d.ts +12 -0
- package/declarations/store/-private/caches/identifier-cache.d.ts +304 -0
- package/declarations/store/-private/caches/instance-cache.d.ts +65 -0
- package/declarations/store/-private/caches/resource-utils.d.ts +9 -0
- package/declarations/store/-private/debug/utils.d.ts +6 -0
- package/declarations/store/-private/default-cache-policy.d.ts +384 -0
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +159 -0
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +17 -0
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +25 -0
- package/declarations/store/-private/managers/cache-manager.d.ts +443 -0
- package/declarations/store/-private/managers/notification-manager.d.ts +98 -0
- package/declarations/store/-private/managers/record-array-manager.d.ts +97 -0
- package/declarations/store/-private/network/request-cache.d.ts +107 -0
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts +263 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +176 -0
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +169 -0
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +35 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +277 -0
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +261 -0
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +147 -0
- package/declarations/store/-private/record-arrays/many-array.d.ts +197 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +126 -0
- package/declarations/store/-private/store-service.d.ts +1605 -0
- package/declarations/store/-private/utils/coerce-id.d.ts +10 -0
- package/declarations/store/-private/utils/construct-resource.d.ts +6 -0
- package/declarations/store/-private/utils/is-non-empty-string.d.ts +1 -0
- package/declarations/store/-private/utils/normalize-model-name.d.ts +1 -0
- package/declarations/store/-private/utils/uuid-polyfill.d.ts +1 -0
- package/declarations/store/-private.d.ts +31 -0
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +99 -0
- package/declarations/store/-types/q/ds-model.d.ts +21 -0
- package/declarations/store/-types/q/identifier.d.ts +20 -0
- package/declarations/store/-types/q/record-instance.d.ts +23 -0
- package/declarations/store/-types/q/schema-service.d.ts +354 -0
- package/declarations/store/-types/q/store.d.ts +32 -0
- package/declarations/store.d.ts +1 -0
- 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 -40
- 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 -1741
- 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 -7
- package/declarations/utils/string.d.ts +48 -0
- package/dist/build-config/babel-macros.js +1 -0
- package/dist/build-config/canary-features.js +1 -0
- package/dist/build-config/debugging.js +1 -0
- package/dist/build-config/deprecations.js +1 -0
- package/dist/build-config/env.js +1 -0
- package/dist/build-config/macros.js +1 -0
- package/dist/build-config.js +1 -0
- package/dist/configure-B48bFHOl.js +181 -0
- package/dist/configure.js +1 -0
- package/dist/{context-DE5sFezZ.js → context-COmAnXUQ.js} +2 -2
- package/dist/graph/-private.js +3372 -0
- package/dist/handler-C2T-IyJK.js +339 -0
- package/dist/index.js +37 -104
- package/dist/reactive/-private.js +1 -0
- package/dist/reactive.js +1988 -0
- package/dist/request-state-CjLph1LP.js +8139 -0
- package/dist/request.js +1 -1
- package/dist/store/-private.js +3 -0
- package/dist/store.js +545 -0
- package/dist/symbols-SIstXMLI.js +44 -0
- package/dist/types/-private.js +3 -3
- package/dist/types/record.js +1 -1
- package/dist/types/request.js +2 -2
- package/dist/types/runtime.js +1 -1
- package/dist/types/schema/fields.js +8 -41
- package/dist/types/symbols.js +3 -3
- package/dist/utils/string.js +92 -0
- package/logos/NCC-1701-a-blue.svg +4 -0
- package/logos/NCC-1701-a-gold.svg +4 -0
- package/logos/NCC-1701-a-gold_100.svg +1 -0
- package/logos/NCC-1701-a-gold_base-64.txt +1 -0
- package/logos/NCC-1701-a.svg +4 -0
- package/logos/README.md +4 -0
- package/logos/docs-badge.svg +2 -0
- package/logos/ember-data-logo-dark.svg +12 -0
- package/logos/ember-data-logo-light.svg +12 -0
- package/logos/github-header.svg +444 -0
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +4 -0
- package/logos/warp-drive-logo-gold.svg +4 -0
- package/package.json +11 -8
- package/declarations/index.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/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/dist/context-DE5sFezZ.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/request.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/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<img
|
|
3
|
-
class="project-logo"
|
|
4
|
-
src="
|
|
3
|
+
class="project-logo light-only"
|
|
4
|
+
src="./logos/github-header.svg#gh-light-mode-only"
|
|
5
5
|
alt="WarpDrive | Boldly go where no app has gone before"
|
|
6
6
|
title="WarpDrive | Boldly go where no app has gone before"
|
|
7
7
|
/>
|
|
8
8
|
<img
|
|
9
|
-
class="project-logo"
|
|
10
|
-
src="
|
|
9
|
+
class="project-logo dark-only"
|
|
10
|
+
src="./logos/github-header.svg#gh-dark-mode-only"
|
|
11
11
|
alt="WarpDrive | Boldly go where no app has gone before"
|
|
12
12
|
title="WarpDrive | Boldly go where no app has gone before"
|
|
13
13
|
/>
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
<a href="https://warp-drive.io">WarpDrive</a> is a lightweight data library for web apps —
|
|
26
26
|
<br>
|
|
27
27
|
universal, typed, reactive, and ready to scale.
|
|
28
|
-
<br
|
|
29
|
-
<
|
|
28
|
+
<br>
|
|
29
|
+
<br>
|
|
30
|
+
</p>
|
|
30
31
|
|
|
31
32
|
WarpDrive provides features that make it easy to build scalable, fast, feature
|
|
32
33
|
rich application — letting you ship better experiences more quickly without re-architecting your app or API. WarpDrive is:
|
|
@@ -53,7 +54,7 @@ rich application — letting you ship better experiences more quickly withou
|
|
|
53
54
|
## Installation
|
|
54
55
|
|
|
55
56
|
```sh
|
|
56
|
-
pnpm add @warp-drive/core
|
|
57
|
+
pnpm add -E @warp-drive/core@latest
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
<br>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@warp-drive/build-config/addon-shim.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@warp-drive/build-config/cjs-set-config.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { macros } from "@warp-drive/build-config/babel-macros";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@warp-drive/build-config/canary-features";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@warp-drive/build-config/debugging";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@warp-drive/build-config/deprecations";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEBUG, PRODUCTION, IS_CI, IS_RECORDING, SHOULD_RECORD, TESTING } from "@warp-drive/build-config/env";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { assert } from "@warp-drive/build-config/macros";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setConfig } from "@warp-drive/build-config";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { StableRecordIdentifier } from "../../types/identifier.js";
|
|
2
|
+
import type { CollectionEdge } from "./edges/collection.js";
|
|
3
|
+
import type { ResourceEdge } from "./edges/resource.js";
|
|
4
|
+
import type { Graph } from "./graph.js";
|
|
5
|
+
type Diff<T> = {
|
|
6
|
+
add: Set<T>;
|
|
7
|
+
del: Set<T>;
|
|
8
|
+
finalState: T[];
|
|
9
|
+
finalSet: Set<T>;
|
|
10
|
+
changed: boolean;
|
|
11
|
+
remoteOrderChanged: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function diffCollection(finalState: StableRecordIdentifier[], relationship: CollectionEdge, onAdd: (v: StableRecordIdentifier) => void, onDel: (v: StableRecordIdentifier) => void): Diff<StableRecordIdentifier>;
|
|
14
|
+
export declare function computeLocalState(storage: CollectionEdge): StableRecordIdentifier[];
|
|
15
|
+
/**
|
|
16
|
+
* A function which attempts to add a value to the local state of a collection
|
|
17
|
+
* relationship, and returns true if the value was added, or false if it was
|
|
18
|
+
* already present.
|
|
19
|
+
*
|
|
20
|
+
* It will not generate a notification, will not update the relationships to dirty,
|
|
21
|
+
* and will not update the inverse relationships, making it suitable for use as
|
|
22
|
+
* an internal util to perform the just the addition to a specific side of a
|
|
23
|
+
* relationship.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function _add(graph: Graph, record: StableRecordIdentifier, relationship: CollectionEdge, value: StableRecordIdentifier, index: number | null, isRemote: boolean): boolean;
|
|
28
|
+
export declare function _remove(graph: Graph, record: StableRecordIdentifier, relationship: CollectionEdge, value: StableRecordIdentifier, index: number | null, isRemote: boolean): boolean;
|
|
29
|
+
export declare function _removeLocal(relationship: CollectionEdge, value: StableRecordIdentifier): boolean;
|
|
30
|
+
export declare function _removeRemote(relationship: CollectionEdge, value: StableRecordIdentifier): boolean;
|
|
31
|
+
export declare function rollbackRelationship(graph: Graph, identifier: StableRecordIdentifier, field: string, relationship: CollectionEdge | ResourceEdge): void;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { StableRecordIdentifier } from "../../types.js";
|
|
2
|
+
import type { CollectionField, FieldSchema, LegacyBelongsToField, LegacyHasManyField, ResourceField } from "../../types/schema/fields.js";
|
|
3
|
+
import type { Graph } from "./graph.js";
|
|
4
|
+
export type EdgeCache = Record<string, Record<string, EdgeDefinition | null>>;
|
|
5
|
+
export type RelationshipField = LegacyBelongsToField | LegacyHasManyField | ResourceField | CollectionField;
|
|
6
|
+
export type RelationshipFieldKind = RelationshipField["kind"];
|
|
7
|
+
export type CollectionKind = "hasMany" | "collection";
|
|
8
|
+
export type ResourceKind = "belongsTo" | "resource";
|
|
9
|
+
export declare const RELATIONSHIP_KINDS: string[];
|
|
10
|
+
export declare function isLegacyField(field: FieldSchema): field is LegacyBelongsToField | LegacyHasManyField;
|
|
11
|
+
export declare function isRelationshipField(field: FieldSchema): field is RelationshipField;
|
|
12
|
+
export declare function temporaryConvertToLegacy(field: ResourceField | CollectionField): LegacyBelongsToField | LegacyHasManyField;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* Given RHS (Right Hand Side)
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* class User extends Model {
|
|
19
|
+
* @hasMany('animal', { async: false, inverse: 'owner' }) pets;
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Given LHS (Left Hand Side)
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* class Animal extends Model {
|
|
27
|
+
* @belongsTo('user', { async: false, inverse: 'pets' }) owner;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* The UpgradedMeta for the RHS would be:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* {
|
|
35
|
+
* kind: 'hasMany',
|
|
36
|
+
* key: 'pets',
|
|
37
|
+
* type: 'animal',
|
|
38
|
+
* isAsync: false,
|
|
39
|
+
* isImplicit: false,
|
|
40
|
+
* isCollection: true,
|
|
41
|
+
* isPolymorphic: false,
|
|
42
|
+
* inverseKind: 'belongsTo',
|
|
43
|
+
* inverseKey: 'owner',
|
|
44
|
+
* inverseType: 'user',
|
|
45
|
+
* inverseIsAsync: false,
|
|
46
|
+
* inverseIsImplicit: false,
|
|
47
|
+
* inverseIsCollection: false,
|
|
48
|
+
* inverseIsPolymorphic: false,
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* The UpgradeMeta for the LHS would be:
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* {
|
|
56
|
+
* kind: 'belongsTo',
|
|
57
|
+
* key: 'owner',
|
|
58
|
+
* type: 'user',
|
|
59
|
+
* isAsync: false,
|
|
60
|
+
* isImplicit: false,
|
|
61
|
+
* isCollection: false,
|
|
62
|
+
* isPolymorphic: false,
|
|
63
|
+
* inverseKind: 'hasMany',
|
|
64
|
+
* inverseKey: 'pets',
|
|
65
|
+
* inverseType: 'animal',
|
|
66
|
+
* inverseIsAsync: false,
|
|
67
|
+
* inverseIsImplicit: false,
|
|
68
|
+
* inverseIsCollection: true,
|
|
69
|
+
* inverseIsPolymorphic: false,
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
*
|
|
74
|
+
* @class UpgradedMeta
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
export interface UpgradedMeta {
|
|
78
|
+
kind: "implicit" | RelationshipFieldKind;
|
|
79
|
+
/**
|
|
80
|
+
* The field name on `this` record
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
key: string;
|
|
85
|
+
/**
|
|
86
|
+
* The `type` of the related record
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
type: string;
|
|
91
|
+
isAsync: boolean;
|
|
92
|
+
isImplicit: boolean;
|
|
93
|
+
isCollection: boolean;
|
|
94
|
+
isPolymorphic: boolean;
|
|
95
|
+
resetOnRemoteUpdate: boolean;
|
|
96
|
+
isLinksMode: boolean;
|
|
97
|
+
inverseKind: "implicit" | RelationshipFieldKind;
|
|
98
|
+
/**
|
|
99
|
+
* The field name on the opposing record
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
inverseKey: string;
|
|
103
|
+
/**
|
|
104
|
+
* The `type` of `this` record
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
inverseType: string;
|
|
108
|
+
inverseIsAsync: boolean;
|
|
109
|
+
inverseIsImplicit: boolean;
|
|
110
|
+
inverseIsCollection: boolean;
|
|
111
|
+
inverseIsPolymorphic: boolean;
|
|
112
|
+
inverseIsLinksMode: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface EdgeDefinition {
|
|
115
|
+
lhs_key: string;
|
|
116
|
+
lhs_modelNames: string[];
|
|
117
|
+
lhs_baseModelName: string;
|
|
118
|
+
lhs_relationshipName: string;
|
|
119
|
+
lhs_definition: UpgradedMeta;
|
|
120
|
+
lhs_isPolymorphic: boolean;
|
|
121
|
+
rhs_key: string;
|
|
122
|
+
rhs_modelNames: string[];
|
|
123
|
+
rhs_baseModelName: string;
|
|
124
|
+
rhs_relationshipName: string;
|
|
125
|
+
rhs_definition: UpgradedMeta | null;
|
|
126
|
+
rhs_isPolymorphic: boolean;
|
|
127
|
+
hasInverse: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Whether this relationship points back at the same type.
|
|
130
|
+
*
|
|
131
|
+
* If the relationship is polymorphic, this will be true if
|
|
132
|
+
* it points back at the same abstract type.
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
isSelfReferential: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* If this is a reflexive relationship, this is true
|
|
139
|
+
* if the relationship also points back at the same
|
|
140
|
+
* field.
|
|
141
|
+
*
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
isReflexive: boolean;
|
|
145
|
+
}
|
|
146
|
+
export declare function isLHS(info: EdgeDefinition, type: string, key: string): boolean;
|
|
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;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface RelationshipState {
|
|
2
|
+
/*
|
|
3
|
+
This flag indicates whether we should consider the content
|
|
4
|
+
of this relationship "known".
|
|
5
|
+
|
|
6
|
+
If we have no relationship knowledge, and the relationship
|
|
7
|
+
is `async`, we will attempt to fetch the relationship on
|
|
8
|
+
access if it is also stale.
|
|
9
|
+
|
|
10
|
+
Snapshot uses this to tell the difference between unknown
|
|
11
|
+
(`undefined`) or empty (`null`). The reason for this is that
|
|
12
|
+
we wouldn't want to serialize unknown relationships as `null`
|
|
13
|
+
as that might overwrite remote state.
|
|
14
|
+
|
|
15
|
+
All relationships for a newly created (`store.createRecord()`) are
|
|
16
|
+
considered known (`hasReceivedData === true`).
|
|
17
|
+
|
|
18
|
+
true when
|
|
19
|
+
=> we receive a push with either new data or explicit empty (`[]` or `null`)
|
|
20
|
+
=> the relationship is a belongsTo and we have received data from
|
|
21
|
+
the other side.
|
|
22
|
+
|
|
23
|
+
false when
|
|
24
|
+
=> we have received no signal about what data belongs in this relationship
|
|
25
|
+
=> the relationship is a hasMany and we have only received data from
|
|
26
|
+
the other side.
|
|
27
|
+
*/
|
|
28
|
+
hasReceivedData: boolean;
|
|
29
|
+
/*
|
|
30
|
+
Flag that indicates whether an empty relationship is explicitly empty
|
|
31
|
+
(signaled by push giving us an empty array or null relationship)
|
|
32
|
+
e.g. an API response has told us that this relationship is empty.
|
|
33
|
+
|
|
34
|
+
Thus far, it does not appear that we actually need this flag; however,
|
|
35
|
+
@runspired has found it invaluable when debugging relationship tests
|
|
36
|
+
to determine whether (and why if so) we are in an incorrect state.
|
|
37
|
+
|
|
38
|
+
true when
|
|
39
|
+
=> we receive a push with explicit empty (`[]` or `null`)
|
|
40
|
+
=> we have received no signal about what data belongs in this relationship
|
|
41
|
+
=> on initial create (as no signal is known yet)
|
|
42
|
+
|
|
43
|
+
false at all other times
|
|
44
|
+
*/
|
|
45
|
+
isEmpty: boolean;
|
|
46
|
+
/*
|
|
47
|
+
This flag indicates whether we should
|
|
48
|
+
re-fetch the relationship the next time
|
|
49
|
+
it is accessed.
|
|
50
|
+
|
|
51
|
+
The difference between this flag and `shouldForceReload`
|
|
52
|
+
is in how we treat the presence of partially missing data:
|
|
53
|
+
- for a forced reload, we will reload the link or EVERY record
|
|
54
|
+
- for a stale reload, we will reload the link (if present) else only MISSING records
|
|
55
|
+
|
|
56
|
+
Ideally these flags could be merged, but because we don't give the
|
|
57
|
+
request layer the option of deciding how to resolve the data being queried
|
|
58
|
+
we are forced to differentiate for now.
|
|
59
|
+
|
|
60
|
+
It is also possible for a relationship to remain stale after a forced reload; however,
|
|
61
|
+
in this case `state.hasFailedLoadAttempt` ought to be `true`.
|
|
62
|
+
|
|
63
|
+
false when
|
|
64
|
+
=> cache.isNew(identifier) on initial setup
|
|
65
|
+
=> a previously triggered request has resolved
|
|
66
|
+
=> we get relationship data via push
|
|
67
|
+
|
|
68
|
+
true when
|
|
69
|
+
=> !cache.isNew(identifier) on initial setup
|
|
70
|
+
=> an inverse has been unloaded
|
|
71
|
+
=> we get a new link for the relationship
|
|
72
|
+
|
|
73
|
+
TODO @runspired unskip the acceptance tests and fix these flags
|
|
74
|
+
*/
|
|
75
|
+
isStale: boolean;
|
|
76
|
+
hasFailedLoadAttempt: boolean;
|
|
77
|
+
/*
|
|
78
|
+
This flag forces fetch. `true` for a single request once `reload()`
|
|
79
|
+
has been called `false` at all other times.
|
|
80
|
+
*/
|
|
81
|
+
shouldForceReload: boolean;
|
|
82
|
+
/*
|
|
83
|
+
This flag indicates whether we should
|
|
84
|
+
**partially** re-fetch the relationship the
|
|
85
|
+
next time it is accessed.
|
|
86
|
+
|
|
87
|
+
false when
|
|
88
|
+
=> initial setup
|
|
89
|
+
=> a previously triggered request has resolved
|
|
90
|
+
|
|
91
|
+
true when
|
|
92
|
+
=> an inverse has been unloaded
|
|
93
|
+
*/
|
|
94
|
+
hasDematerializedInverse: boolean;
|
|
95
|
+
}
|
|
96
|
+
export declare function createState(): RelationshipState;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Store } from "../../store/-private.js";
|
|
2
|
+
import type { CacheCapabilitiesManager } from "../../types.js";
|
|
3
|
+
import type { UpdateResourceRelationshipOperation } from "../../types/cache/operations.js";
|
|
4
|
+
import type { UpdateRelationshipOperation } from "../../types/graph.js";
|
|
5
|
+
import type { StableRecordIdentifier } from "../../types/identifier.js";
|
|
6
|
+
import type { ResourceIdentifierObject } from "../../types/spec/json-api-raw.js";
|
|
7
|
+
import type { UpgradedMeta } from "./-edge-definition.js";
|
|
8
|
+
import type { CollectionEdge } from "./edges/collection.js";
|
|
9
|
+
import type { ImplicitEdge } from "./edges/implicit.js";
|
|
10
|
+
import type { ResourceEdge } from "./edges/resource.js";
|
|
11
|
+
import type { Graph, GraphEdge } from "./graph.js";
|
|
12
|
+
export declare function getStore(wrapper: CacheCapabilitiesManager | {
|
|
13
|
+
_store: Store;
|
|
14
|
+
}): Store;
|
|
15
|
+
export declare function expandingGet<T>(cache: Record<string, Record<string, T>>, key1: string, key2: string): T | undefined;
|
|
16
|
+
export declare function expandingSet<T>(cache: Record<string, Record<string, T>>, key1: string, key2: string, value: T): void;
|
|
17
|
+
export declare function assertValidRelationshipPayload(graph: Graph, op: UpdateRelationshipOperation | UpdateResourceRelationshipOperation): void;
|
|
18
|
+
export declare function isNew(identifier: StableRecordIdentifier): boolean;
|
|
19
|
+
export declare function isBelongsTo(relationship: GraphEdge): relationship is ResourceEdge;
|
|
20
|
+
export declare function isImplicit(relationship: GraphEdge): relationship is ImplicitEdge;
|
|
21
|
+
export declare function isHasMany(relationship: GraphEdge): relationship is CollectionEdge;
|
|
22
|
+
export declare function forAllRelatedIdentifiers(rel: GraphEdge, cb: (identifier: StableRecordIdentifier) => void): void;
|
|
23
|
+
/*
|
|
24
|
+
Removes the given identifier from BOTH remote AND local state.
|
|
25
|
+
|
|
26
|
+
This method is useful when either a deletion or a rollback on a new record
|
|
27
|
+
needs to entirely purge itself from an inverse relationship.
|
|
28
|
+
*/
|
|
29
|
+
export declare function removeIdentifierCompletelyFromRelationship(graph: Graph, relationship: GraphEdge, value: StableRecordIdentifier, silenceNotifications?: boolean): void;
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Used by the store to normalize IDs entering the store. Despite the fact
|
|
2
|
+
// that developers may provide IDs as numbers (e.g., `store.findRecord('person', 1)`),
|
|
3
|
+
// it is important that internally we use strings, since IDs may be serialized
|
|
4
|
+
// and lose type information. For example, Ember's router may put a record's
|
|
5
|
+
// ID into the URL, and if we later try to deserialize that URL and find the
|
|
6
|
+
// corresponding record, we will not know if it is a string or a number.
|
|
7
|
+
type Coercable = string | number | boolean | null | undefined | symbol;
|
|
8
|
+
export declare function coerceId(id: Coercable): string | null;
|
|
9
|
+
export declare function ensureStringId(id: Coercable): string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CacheCapabilitiesManager } from "../../../types.js";
|
|
2
|
+
import type { StableRecordIdentifier } from "../../../types/identifier.js";
|
|
3
|
+
import { type UpgradedMeta } from "../-edge-definition.js";
|
|
4
|
+
/*
|
|
5
|
+
Assert that `addedRecord` has a valid type so it can be added to the
|
|
6
|
+
relationship of the `record`.
|
|
7
|
+
|
|
8
|
+
The assert basically checks if the `addedRecord` can be added to the
|
|
9
|
+
relationship (specified via `relationshipMeta`) of the `record`.
|
|
10
|
+
|
|
11
|
+
This utility should only be used internally, as both record parameters must
|
|
12
|
+
be stable record identifiers and the `relationshipMeta` needs to be the meta
|
|
13
|
+
information about the relationship, retrieved via
|
|
14
|
+
`record.relationshipFor(key)`.
|
|
15
|
+
*/
|
|
16
|
+
declare let assertPolymorphicType: (parentIdentifier: StableRecordIdentifier, parentDefinition: UpgradedMeta, addedIdentifier: StableRecordIdentifier, store: CacheCapabilitiesManager) => void;
|
|
17
|
+
declare let assertInheritedSchema: (definition: UpgradedMeta, type: string) => void;
|
|
18
|
+
export { assertPolymorphicType, assertInheritedSchema };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CollectionRelationship } from "../../../types/cache/relationship.js";
|
|
2
|
+
import type { StableRecordIdentifier } from "../../../types/identifier.js";
|
|
3
|
+
import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
4
|
+
import type { UpgradedMeta } from "../-edge-definition.js";
|
|
5
|
+
import type { RelationshipState } from "../-state.js";
|
|
6
|
+
export interface CollectionEdge {
|
|
7
|
+
definition: UpgradedMeta;
|
|
8
|
+
identifier: StableRecordIdentifier;
|
|
9
|
+
state: RelationshipState;
|
|
10
|
+
remoteMembers: Set<StableRecordIdentifier>;
|
|
11
|
+
remoteState: StableRecordIdentifier[];
|
|
12
|
+
additions: Set<StableRecordIdentifier> | null;
|
|
13
|
+
removals: Set<StableRecordIdentifier> | null;
|
|
14
|
+
meta: Meta | null;
|
|
15
|
+
links: Links | PaginationLinks | null;
|
|
16
|
+
localState: StableRecordIdentifier[] | null;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the localState for this edge is out-of-sync
|
|
19
|
+
* with the remoteState.
|
|
20
|
+
*
|
|
21
|
+
* if state.hasReceivedData=false we are also
|
|
22
|
+
* not dirty since there is nothing to sync with.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
isDirty: boolean;
|
|
26
|
+
transactionRef: number;
|
|
27
|
+
/**
|
|
28
|
+
* Whether data for this edge has been accessed at least once
|
|
29
|
+
* via `graph.getData`
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
accessed: boolean;
|
|
33
|
+
_diff?: {
|
|
34
|
+
add: Set<StableRecordIdentifier>;
|
|
35
|
+
del: Set<StableRecordIdentifier>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare function createCollectionEdge(definition: UpgradedMeta, identifier: StableRecordIdentifier): CollectionEdge;
|
|
39
|
+
export declare function legacyGetCollectionRelationshipData(source: CollectionEdge, getRemoteState: boolean): CollectionRelationship;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { StableRecordIdentifier } from "../../../types/identifier.js";
|
|
2
|
+
import type { UpgradedMeta } from "../-edge-definition.js";
|
|
3
|
+
export type ImplicitMeta = UpgradedMeta & {
|
|
4
|
+
kind: "implicit";
|
|
5
|
+
isImplicit: true;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
Implicit relationships are relationships which have not been declared but the inverse side exists on
|
|
9
|
+
another record somewhere
|
|
10
|
+
|
|
11
|
+
For example consider the following two models
|
|
12
|
+
|
|
13
|
+
::: code-group
|
|
14
|
+
|
|
15
|
+
```js [./models/comment.js]
|
|
16
|
+
import { Model, attr } from '@warp-drive/legacy/model';
|
|
17
|
+
|
|
18
|
+
export default class Comment extends Model {
|
|
19
|
+
@attr text;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```js [./models/post.js]
|
|
24
|
+
import { Model, attr, hasMany } from '@warp-drive/legacy/model';
|
|
25
|
+
|
|
26
|
+
export default class Post extends Model {
|
|
27
|
+
@attr title;
|
|
28
|
+
@hasMany('comment', { async: true, inverse: null }) comments;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
:::
|
|
33
|
+
|
|
34
|
+
Then we would have a implicit 'post' relationship for the comment record in order
|
|
35
|
+
to be do things like remove the comment from the post if the comment were to be deleted.
|
|
36
|
+
*/
|
|
37
|
+
export interface ImplicitEdge {
|
|
38
|
+
definition: ImplicitMeta;
|
|
39
|
+
identifier: StableRecordIdentifier;
|
|
40
|
+
localMembers: Set<StableRecordIdentifier>;
|
|
41
|
+
remoteMembers: Set<StableRecordIdentifier>;
|
|
42
|
+
}
|
|
43
|
+
export declare function createImplicitEdge(definition: ImplicitMeta, identifier: StableRecordIdentifier): ImplicitEdge;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ResourceRelationship } from "../../../types/cache/relationship.js";
|
|
2
|
+
import type { StableRecordIdentifier } from "../../../types/identifier.js";
|
|
3
|
+
import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
4
|
+
import type { UpgradedMeta } from "../-edge-definition.js";
|
|
5
|
+
import type { RelationshipState } from "../-state.js";
|
|
6
|
+
/**
|
|
7
|
+
* Stores the data for one side of a "single" resource relationship.
|
|
8
|
+
*
|
|
9
|
+
* @class ResourceEdge
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export interface ResourceEdge {
|
|
13
|
+
definition: UpgradedMeta;
|
|
14
|
+
identifier: StableRecordIdentifier;
|
|
15
|
+
state: RelationshipState;
|
|
16
|
+
localState: StableRecordIdentifier | null;
|
|
17
|
+
remoteState: StableRecordIdentifier | null;
|
|
18
|
+
meta: Meta | null;
|
|
19
|
+
links: Links | PaginationLinks | null;
|
|
20
|
+
transactionRef: number;
|
|
21
|
+
accessed: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function createResourceEdge(definition: UpgradedMeta, identifier: StableRecordIdentifier): ResourceEdge;
|
|
24
|
+
export declare function legacyGetResourceRelationshipData(source: ResourceEdge, getRemoteState: boolean): ResourceRelationship;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CacheCapabilitiesManager, StableRecordIdentifier } from "../../types.js";
|
|
2
|
+
import type { RelationshipDiff } from "../../types/cache.js";
|
|
3
|
+
import type { MergeOperation } from "../../types/cache/operations.js";
|
|
4
|
+
import type { CollectionRelationship, ResourceRelationship } from "../../types/cache/relationship.js";
|
|
5
|
+
import type { DeleteRecordOperation, LocalRelationshipOperation, RemoteRelationshipOperation } from "../../types/graph.js";
|
|
6
|
+
import type { EdgeCache, UpgradedMeta } from "./-edge-definition.js";
|
|
7
|
+
import { type CollectionEdge } from "./edges/collection.js";
|
|
8
|
+
import type { ImplicitEdge } from "./edges/implicit.js";
|
|
9
|
+
import { type ResourceEdge } from "./edges/resource.js";
|
|
10
|
+
export type GraphEdge = ImplicitEdge | CollectionEdge | ResourceEdge;
|
|
11
|
+
export declare const Graphs: Map<CacheCapabilitiesManager, Graph>;
|
|
12
|
+
type PendingOps = {
|
|
13
|
+
belongsTo?: Map<string, Map<string, RemoteRelationshipOperation[]>>;
|
|
14
|
+
hasMany?: Map<string, Map<string, RemoteRelationshipOperation[]>>;
|
|
15
|
+
deletions: DeleteRecordOperation[];
|
|
16
|
+
};
|
|
17
|
+
/*
|
|
18
|
+
* Graph acts as the cache for relationship data. It allows for
|
|
19
|
+
* us to ask about and update relationships for a given Identifier
|
|
20
|
+
* without requiring other objects for that Identifier to be
|
|
21
|
+
* instantiated (such as `RecordData` or a `Record`)
|
|
22
|
+
*
|
|
23
|
+
* This also allows for us to make more substantive changes to relationships
|
|
24
|
+
* with increasingly minor alterations to other portions of the internals
|
|
25
|
+
* over time.
|
|
26
|
+
*
|
|
27
|
+
* The graph is made up of nodes and edges. Each unique identifier gets
|
|
28
|
+
* its own node, which is a dictionary with a list of that node's edges
|
|
29
|
+
* (or connections) to other nodes. In `Model` terms, a node represents a
|
|
30
|
+
* record instance, with each key (an edge) in the dictionary correlating
|
|
31
|
+
* to either a `hasMany` or `belongsTo` field on that record instance.
|
|
32
|
+
*
|
|
33
|
+
* The value for each key, or `edge` is the identifier(s) the node relates
|
|
34
|
+
* to in the graph from that key.
|
|
35
|
+
*/
|
|
36
|
+
export declare class Graph {
|
|
37
|
+
_definitionCache: EdgeCache;
|
|
38
|
+
_metaCache: Record<string, Record<string, UpgradedMeta>>;
|
|
39
|
+
_potentialPolymorphicTypes: Record<string, Record<string, boolean>>;
|
|
40
|
+
identifiers: Map<StableRecordIdentifier, Record<string, GraphEdge>>;
|
|
41
|
+
store: CacheCapabilitiesManager;
|
|
42
|
+
isDestroyed: boolean;
|
|
43
|
+
_willSyncRemote: boolean;
|
|
44
|
+
_willSyncLocal: boolean;
|
|
45
|
+
silenceNotifications: boolean;
|
|
46
|
+
_pushedUpdates: PendingOps;
|
|
47
|
+
_updatedRelationships: Set<CollectionEdge>;
|
|
48
|
+
_transaction: number | null;
|
|
49
|
+
_removing: StableRecordIdentifier | null;
|
|
50
|
+
constructor(store: CacheCapabilitiesManager);
|
|
51
|
+
has(identifier: StableRecordIdentifier, propertyName: string): boolean;
|
|
52
|
+
getDefinition(identifier: StableRecordIdentifier, propertyName: string): UpgradedMeta;
|
|
53
|
+
get(identifier: StableRecordIdentifier, propertyName: string): GraphEdge;
|
|
54
|
+
getData(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
|
|
55
|
+
getRemoteData(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
|
|
56
|
+
/*
|
|
57
|
+
* Allows for the graph to dynamically discover polymorphic connections
|
|
58
|
+
* without needing to walk prototype chains.
|
|
59
|
+
*
|
|
60
|
+
* Used by edges when an added `type` does not match the expected `type`
|
|
61
|
+
* for that edge.
|
|
62
|
+
*
|
|
63
|
+
* Currently we assert before calling this. For a public API we will want
|
|
64
|
+
* to call out to the schema manager to ask if we should consider these
|
|
65
|
+
* types as equivalent for a given relationship.
|
|
66
|
+
*/
|
|
67
|
+
registerPolymorphicType(type1: string, type2: string): void;
|
|
68
|
+
isReleasable(identifier: StableRecordIdentifier): boolean;
|
|
69
|
+
unload(identifier: StableRecordIdentifier, silenceNotifications?: boolean): void;
|
|
70
|
+
_isDirty(identifier: StableRecordIdentifier, field: string): boolean;
|
|
71
|
+
getChanged(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
|
|
72
|
+
hasChanged(identifier: StableRecordIdentifier): boolean;
|
|
73
|
+
rollback(identifier: StableRecordIdentifier): string[];
|
|
74
|
+
remove(identifier: StableRecordIdentifier): void;
|
|
75
|
+
/*
|
|
76
|
+
* Remote state changes
|
|
77
|
+
*/
|
|
78
|
+
push(op: RemoteRelationshipOperation): void;
|
|
79
|
+
/*
|
|
80
|
+
* Local state changes
|
|
81
|
+
*/
|
|
82
|
+
update(op: RemoteRelationshipOperation | MergeOperation, isRemote: true): void;
|
|
83
|
+
update(op: LocalRelationshipOperation, isRemote?: false): void;
|
|
84
|
+
_scheduleLocalSync(relationship: CollectionEdge): void;
|
|
85
|
+
_flushRemoteQueue(): void;
|
|
86
|
+
_addToTransaction(relationship: CollectionEdge | ResourceEdge): void;
|
|
87
|
+
_flushLocalQueue(): void;
|
|
88
|
+
destroy(): void;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Link, LinkObject } from "../../types/spec/json-api-raw.js";
|
|
2
|
+
/*
|
|
3
|
+
This method normalizes a link to an "links object". If the passed link is
|
|
4
|
+
already an object it's returned without any modifications.
|
|
5
|
+
|
|
6
|
+
See http://jsonapi.org/format/#document-links for more information.
|
|
7
|
+
*/
|
|
8
|
+
export default function _normalizeLink(link: Link): LinkObject | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AddToResourceRelationshipMutation } from "../../../types/cache/mutations.js";
|
|
2
|
+
import type { AddToResourceRelationshipOperation } from "../../../types/cache/operations.js";
|
|
3
|
+
import type { Graph } from "../graph.js";
|
|
4
|
+
export default function addToRelatedRecords(graph: Graph, op: AddToResourceRelationshipOperation | AddToResourceRelationshipMutation, isRemote: boolean): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RemoveFromResourceRelationshipMutation } from "../../../types/cache/mutations.js";
|
|
2
|
+
import type { RemoveFromResourceRelationshipOperation } from "../../../types/cache/operations.js";
|
|
3
|
+
import type { Graph } from "../graph.js";
|
|
4
|
+
export default function removeFromRelatedRecords(graph: Graph, op: RemoveFromResourceRelationshipOperation | RemoveFromResourceRelationshipMutation, isRemote: boolean): void;
|