@warp-drive/core 5.6.0-beta.1 → 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.
- package/declarations/graph/-private/-diff.d.ts +7 -20
- package/declarations/graph/-private/-edge-definition.d.ts +3 -12
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +6 -7
- package/declarations/graph/-private/graph.d.ts +17 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +73 -0
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
- package/declarations/reactive/-private/record.d.ts +44 -33
- package/declarations/reactive/-private/schema.d.ts +50 -66
- package/declarations/reactive/-private/symbols.d.ts +2 -7
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +278 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -0
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -23
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -24
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
- package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
- package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
- package/declarations/store/-private/store-service.d.ts +167 -872
- package/declarations/store/-private.d.ts +14 -10
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/record-instance.d.ts +0 -1
- package/declarations/store/-types/q/schema-service.d.ts +64 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +224 -0
- package/declarations/store/deprecated/store.d.ts +787 -0
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -115
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -76
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +69 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +391 -14
- package/declarations/types/spec/document.d.ts +6 -6
- package/declarations/types/spec/json-api-raw.d.ts +6 -8
- package/declarations/types.d.ts +2 -1
- package/declarations/utils/string.d.ts +2 -2
- package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
- package/dist/graph/-private.js +137 -144
- package/dist/index.js +25 -14
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +337 -1422
- package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
- package/dist/request.js +1 -1
- package/dist/store/-private.js +2 -3
- package/dist/store.js +32 -44
- package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +45 -3
- package/dist/types/schema/fields.js +23 -2
- package/dist/utils/string.js +2 -2
- package/package.json +10 -10
- package/declarations/reactive/-private/fields/compute.d.ts +0 -43
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/declarations/store/-types/q/ds-model.d.ts +0 -21
- package/dist/handler-C2T-IyJK.js +0 -339
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Store } from "../../../index.js";
|
|
2
2
|
import type { RelatedCollection as ManyArray } from "../../../store/-private.js";
|
|
3
3
|
import type { LocalRelationshipOperation } from "../../../types/graph.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ResourceKey } from "../../../types/identifier.js";
|
|
5
5
|
import type { ReactiveResource } from "../record.js";
|
|
6
6
|
export interface FindHasManyOptions {
|
|
7
7
|
reload?: boolean;
|
|
@@ -10,7 +10,7 @@ export interface FindHasManyOptions {
|
|
|
10
10
|
export declare class ManyArrayManager {
|
|
11
11
|
record: ReactiveResource;
|
|
12
12
|
store: Store;
|
|
13
|
-
identifier:
|
|
13
|
+
identifier: ResourceKey;
|
|
14
14
|
editable: boolean;
|
|
15
15
|
constructor(record: ReactiveResource, editable: boolean);
|
|
16
16
|
_syncArray(array: ManyArray): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Store } from "../../index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "../../types.js";
|
|
3
3
|
import { ReactiveResource } from "./record.js";
|
|
4
|
-
export declare function instantiateRecord(store: Store, identifier:
|
|
4
|
+
export declare function instantiateRecord(store: Store, identifier: ResourceKey, createArgs?: Record<string, unknown>): ReactiveResource;
|
|
5
5
|
export declare function teardownRecord(record: unknown): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LegacyAliasField, ObjectAliasField, PolarisAliasField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getAliasField(context: KindContext<LegacyAliasField | ObjectAliasField | PolarisAliasField>): unknown;
|
|
4
|
+
export declare function setAliasField(context: KindContext<LegacyAliasField | ObjectAliasField | PolarisAliasField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ArrayField, SchemaArrayField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getArrayField(context: KindContext<ArrayField | SchemaArrayField>): unknown;
|
|
4
|
+
export declare function setArrayField(context: KindContext<ArrayField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LegacyAttributeField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getAttributeField(context: KindContext<LegacyAttributeField>): unknown;
|
|
4
|
+
export declare function setAttributeField(context: KindContext<LegacyAttributeField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LegacyBelongsToField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getBelongsToField(context: KindContext<LegacyBelongsToField>): unknown;
|
|
4
|
+
export declare function setBelongsToField(context: KindContext<LegacyBelongsToField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CollectionField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getCollectionField(context: KindContext<CollectionField>): unknown;
|
|
4
|
+
export declare function setCollectionField(context: KindContext<CollectionField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DerivedField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getDerivedField(context: KindContext<DerivedField>): unknown;
|
|
4
|
+
export declare function setDerivedField(context: KindContext<DerivedField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GenericField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getGenericField(context: KindContext<GenericField>): unknown;
|
|
4
|
+
export declare function setGenericField(context: KindContext<GenericField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LegacyHasManyField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getHasManyField(context: KindContext<LegacyHasManyField>): unknown;
|
|
4
|
+
export declare function setHasManyField(context: KindContext<LegacyHasManyField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HashField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getHashField(context: KindContext<HashField>): unknown;
|
|
4
|
+
export declare function setHashField(context: KindContext<HashField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IdentityField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getIdentityField(context: KindContext<IdentityField>): unknown;
|
|
4
|
+
export declare function setIdentityField(context: KindContext<IdentityField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LocalField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getLocalField(context: KindContext<LocalField>): unknown;
|
|
4
|
+
export declare function setLocalField(context: KindContext<LocalField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ObjectField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getObjectField(context: KindContext<ObjectField>): unknown;
|
|
4
|
+
export declare function setObjectField(context: KindContext<ObjectField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResourceField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getResourceField(context: KindContext<ResourceField>): unknown;
|
|
4
|
+
export declare function setResourceField(context: KindContext<ResourceField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SchemaArrayField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export { getArrayField as getSchemaArrayField } from "./array-field.js";
|
|
4
|
+
export declare function setSchemaArrayField(context: KindContext<SchemaArrayField>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SchemaObjectField } from "../../../types/schema/fields.js";
|
|
2
|
+
import type { KindContext } from "../default-mode.js";
|
|
3
|
+
export declare function getSchemaObjectField(context: KindContext<SchemaObjectField>): unknown;
|
|
4
|
+
export declare function setSchemaObjectField(context: KindContext<SchemaObjectField>): boolean;
|
|
@@ -1,37 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import type { SchemaArrayField, SchemaObjectField } from "../../types/schema/fields.js";
|
|
4
|
-
import { RecordStore } from "../../types/symbols.js";
|
|
5
|
-
import { Checkout, Destroy, Editable, EmbeddedField, EmbeddedPath, Identifier, Legacy, Parent } from "./symbols.js";
|
|
6
|
-
export { Editable, Legacy, Checkout } from "./symbols.js";
|
|
1
|
+
import type { ObjectContext, ResourceContext } from "./default-mode.js";
|
|
2
|
+
import { Checkout } from "./symbols.js";
|
|
7
3
|
export interface ReactiveResource {
|
|
8
|
-
[Symbol.toStringTag]: `ReactiveResource<${string}>`;
|
|
9
|
-
/** @internal */
|
|
10
|
-
[RecordStore]: Store;
|
|
11
|
-
/** @internal */
|
|
12
|
-
[Identifier]: StableRecordIdentifier;
|
|
13
|
-
/** @internal */
|
|
14
|
-
[Parent]: StableRecordIdentifier;
|
|
15
|
-
/** @internal */
|
|
16
|
-
[EmbeddedField]: SchemaArrayField | SchemaObjectField | null;
|
|
17
|
-
/** @internal */
|
|
18
|
-
[EmbeddedPath]: string[] | null;
|
|
19
|
-
/** @internal */
|
|
20
|
-
[Editable]: boolean;
|
|
21
|
-
/** @internal */
|
|
22
|
-
[Legacy]: boolean;
|
|
23
|
-
/** @internal */
|
|
24
|
-
___notifications: object;
|
|
25
|
-
/** @internal */
|
|
26
|
-
[Destroy](): void;
|
|
27
4
|
/**
|
|
28
5
|
* Create an editable copy of the record
|
|
29
6
|
*
|
|
30
7
|
* ReactiveResource instances are not editable by default. This method creates an editable copy of the record. To use,
|
|
31
|
-
* import the `Checkout` symbol from `@warp-drive/
|
|
8
|
+
* import the `Checkout` symbol from `@warp-drive/core/reactive` and call it on the record.
|
|
32
9
|
*
|
|
33
10
|
* ```ts
|
|
34
|
-
* import { Checkout } from '@warp-drive/
|
|
11
|
+
* import { Checkout } from '@warp-drive/core/reactive';
|
|
35
12
|
*
|
|
36
13
|
* const record = store.peekRecord('user', '1');
|
|
37
14
|
* const editableRecord = await record[Checkout]();
|
|
@@ -39,13 +16,13 @@ export interface ReactiveResource {
|
|
|
39
16
|
*
|
|
40
17
|
* @returns a promise that resolves to the editable record
|
|
41
18
|
* @throws if the record is already editable or if the record is embedded
|
|
42
|
-
*
|
|
19
|
+
* @private
|
|
43
20
|
*/
|
|
44
21
|
[Checkout]<T>(): Promise<T>;
|
|
45
22
|
}
|
|
46
23
|
/**
|
|
47
24
|
* A class that uses a the ResourceSchema for a ResourceType
|
|
48
|
-
* and a
|
|
25
|
+
* and a ResourceKey to transform data from the cache into a rich, reactive
|
|
49
26
|
* object.
|
|
50
27
|
*
|
|
51
28
|
* This class is not directly instantiable. To use it, you should
|
|
@@ -57,8 +34,42 @@ export interface ReactiveResource {
|
|
|
57
34
|
*/
|
|
58
35
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
59
36
|
export declare class ReactiveResource {
|
|
60
|
-
constructor(
|
|
61
|
-
[Editable]: boolean;
|
|
62
|
-
[Legacy]: boolean;
|
|
63
|
-
}, isEmbedded?: boolean, embeddedField?: SchemaArrayField | SchemaObjectField | null, embeddedPath?: string[] | null);
|
|
37
|
+
constructor(context: ResourceContext | ObjectContext);
|
|
64
38
|
}
|
|
39
|
+
export declare function _CHECKOUT(record: ReactiveResource): ReactiveResource;
|
|
40
|
+
/**
|
|
41
|
+
* Checkout an immutable resource for editing.
|
|
42
|
+
*
|
|
43
|
+
* {@link ReactiveResource | ReactiveResources} are not editable by default. This method
|
|
44
|
+
* creates an editable copy of the resource.
|
|
45
|
+
*
|
|
46
|
+
* This returns a promise which resolves with the editable
|
|
47
|
+
* version of the resource.
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { checkout } from '@warp-drive/core/reactive';
|
|
51
|
+
*
|
|
52
|
+
* const immutable = store.peekRecord('user', '1');
|
|
53
|
+
* const editable = await checkout(immutable);
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Edits to editable resources will be automatically committed if a new
|
|
57
|
+
* payload from the cache matches their existing value.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*
|
|
61
|
+
* @returns a promise that resolves to the editable resource
|
|
62
|
+
* @throws if the resource is already editable or if resource is an embedded object
|
|
63
|
+
*/
|
|
64
|
+
export declare function checkout<T>(resource: unknown): Promise<T & ReactiveResource>;
|
|
65
|
+
/**
|
|
66
|
+
* Forcibly commit all local changes on an editable resource to
|
|
67
|
+
* the remote (immutable) version.
|
|
68
|
+
*
|
|
69
|
+
* This API should only be used cautiously. Typically a better
|
|
70
|
+
* approach is for either the API or a Handler to reflect saved
|
|
71
|
+
* changes back to update the cache.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export declare function commit(record: ReactiveResource): Promise<void>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { Store } from "../../store/-private.js";
|
|
2
1
|
import type { SchemaService as SchemaServiceInterface } from "../../types.js";
|
|
3
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "../../types/identifier.js";
|
|
4
3
|
import type { ObjectValue, Value } from "../../types/json/raw.js";
|
|
5
4
|
import type { Derivation, HashFn } from "../../types/schema/concepts.js";
|
|
6
|
-
import { type ArrayField, type DerivedField, type FieldSchema, type GenericField, type HashField, type
|
|
5
|
+
import { type ArrayField, type CacheableFieldSchema, type DerivedField, type FieldSchema, type GenericField, type HashField, type IdentityField, type LegacyAttributeField, type LegacyRelationshipField, type ObjectField, type ObjectSchema, type PolarisResourceSchema, type ResourceSchema, type Trait } from "../../types/schema/fields.js";
|
|
7
6
|
import { Type } from "../../types/symbols.js";
|
|
8
7
|
import type { WithPartial } from "../../types/utils.js";
|
|
9
8
|
import type { ReactiveResource } from "./record.js";
|
|
@@ -95,11 +94,11 @@ interface FromIdentityDerivation {
|
|
|
95
94
|
}, key: string): string | null;
|
|
96
95
|
(record: ReactiveResource, options: {
|
|
97
96
|
key: "^";
|
|
98
|
-
}, key: string):
|
|
97
|
+
}, key: string): ResourceKey;
|
|
99
98
|
(record: ReactiveResource, options: null, key: string): asserts options;
|
|
100
99
|
(record: ReactiveResource, options: {
|
|
101
100
|
key: "id" | "lid" | "type" | "^";
|
|
102
|
-
} | null, key: string):
|
|
101
|
+
} | null, key: string): ResourceKey | string | null;
|
|
103
102
|
[Type]: "@identity";
|
|
104
103
|
}
|
|
105
104
|
/**
|
|
@@ -133,13 +132,14 @@ export declare const fromIdentity: FromIdentityDerivation;
|
|
|
133
132
|
* ```
|
|
134
133
|
*
|
|
135
134
|
* @public
|
|
136
|
-
* @param {SchemaService} schema
|
|
137
135
|
*/
|
|
138
136
|
export declare function registerDerivations(schema: SchemaServiceInterface): void;
|
|
139
137
|
interface InternalSchema {
|
|
140
138
|
original: ResourceSchema | ObjectSchema;
|
|
139
|
+
finalized: boolean;
|
|
141
140
|
traits: Set<string>;
|
|
142
141
|
fields: Map<string, FieldSchema>;
|
|
142
|
+
cacheFields: Map<string, Exclude<CacheableFieldSchema, IdentityField>>;
|
|
143
143
|
attributes: Record<string, LegacyAttributeField>;
|
|
144
144
|
relationships: Record<string, LegacyRelationshipField>;
|
|
145
145
|
}
|
|
@@ -149,20 +149,9 @@ export type Transformation<
|
|
|
149
149
|
> = {
|
|
150
150
|
serialize(value: PT, options: Record<string, unknown> | null, record: ReactiveResource): T;
|
|
151
151
|
hydrate(value: T | undefined, options: Record<string, unknown> | null, record: ReactiveResource): PT;
|
|
152
|
-
defaultValue?(options: Record<string, unknown> | null, identifier:
|
|
152
|
+
defaultValue?(options: Record<string, unknown> | null, identifier: ResourceKey): T;
|
|
153
153
|
[Type]: string;
|
|
154
154
|
};
|
|
155
|
-
interface KindFns {
|
|
156
|
-
belongsTo: {
|
|
157
|
-
get: (store: Store, record: object, resourceKey: StableRecordIdentifier, field: LegacyBelongsToField) => unknown;
|
|
158
|
-
set: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyBelongsToField, value: unknown) => void;
|
|
159
|
-
};
|
|
160
|
-
hasMany: {
|
|
161
|
-
get: (store: Store, record: object, resourceKey: StableRecordIdentifier, field: LegacyHasManyField) => unknown;
|
|
162
|
-
set: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyHasManyField, value: unknown) => void;
|
|
163
|
-
notify: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyHasManyField) => boolean;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
155
|
export interface SchemaService {
|
|
167
156
|
doesTypeExist(type: string): boolean;
|
|
168
157
|
attributesDefinitionFor(identifier: {
|
|
@@ -175,36 +164,13 @@ export interface SchemaService {
|
|
|
175
164
|
/**
|
|
176
165
|
* A SchemaService designed to work with dynamically registered schemas.
|
|
177
166
|
*
|
|
178
|
-
* @class SchemaService
|
|
179
167
|
* @public
|
|
180
168
|
*/
|
|
181
169
|
export declare class SchemaService implements SchemaServiceInterface {
|
|
182
|
-
/** @internal */
|
|
183
|
-
_schemas: Map<string, InternalSchema>;
|
|
184
|
-
/** @internal */
|
|
185
|
-
_transforms: Map<string, Transformation>;
|
|
186
|
-
/** @internal */
|
|
187
|
-
_hashFns: Map<string, HashFn>;
|
|
188
|
-
/** @internal */
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
|
-
_derivations: Map<string, Derivation<any, any, any>>;
|
|
191
|
-
/** @internal */
|
|
192
|
-
_traits: Set<string>;
|
|
193
|
-
/** @internal */
|
|
194
|
-
_modes: Map<string, KindFns>;
|
|
195
|
-
/** @internal */
|
|
196
|
-
_extensions: {
|
|
197
|
-
object: Map<string, ProcessedExtension>;
|
|
198
|
-
array: Map<string, ProcessedExtension>;
|
|
199
|
-
};
|
|
200
|
-
_cachedFieldExtensionsByField: {
|
|
201
|
-
object: Map<object, ProcessedExtension["features"] | null>;
|
|
202
|
-
array: Map<object, ProcessedExtension["features"] | null>;
|
|
203
|
-
};
|
|
204
170
|
constructor();
|
|
205
171
|
resourceTypes(): Readonly<string[]>;
|
|
206
172
|
hasTrait(type: string): boolean;
|
|
207
|
-
resourceHasTrait(resource:
|
|
173
|
+
resourceHasTrait(resource: ResourceKey | {
|
|
208
174
|
type: string;
|
|
209
175
|
}, trait: string): boolean;
|
|
210
176
|
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
@@ -216,11 +182,40 @@ export declare class SchemaService implements SchemaServiceInterface {
|
|
|
216
182
|
hashFn(field: HashField | {
|
|
217
183
|
type: string;
|
|
218
184
|
}): HashFn;
|
|
219
|
-
resource(resource:
|
|
185
|
+
resource(resource: ResourceKey | {
|
|
220
186
|
type: string;
|
|
221
187
|
}): ResourceSchema | ObjectSchema;
|
|
222
188
|
registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
|
|
223
189
|
registerResource(schema: ResourceSchema | ObjectSchema): void;
|
|
190
|
+
/**
|
|
191
|
+
* Registers a {@link Trait} for use by resource schemas.
|
|
192
|
+
*
|
|
193
|
+
* Traits are re-usable collections of fields that can be composed to
|
|
194
|
+
* build up a resource schema. Often they represent polymorphic behaviors
|
|
195
|
+
* a resource should exhibit.
|
|
196
|
+
*
|
|
197
|
+
* When we finalize a resource, we walk its traits and apply their fields
|
|
198
|
+
* to the resource's fields. All specified traits must be registered by
|
|
199
|
+
* this time or an error will be thrown.
|
|
200
|
+
*
|
|
201
|
+
* Traits are applied left-to-right, with traits of traits being applied in the same
|
|
202
|
+
* way. Thus for the most part, application of traits is a post-order graph traversal
|
|
203
|
+
* problem.
|
|
204
|
+
*
|
|
205
|
+
* A trait is only ever processed once. If multiple traits (A, B, C) have the same
|
|
206
|
+
* trait (D) as a dependency, D will be included only once when first encountered by
|
|
207
|
+
* A.
|
|
208
|
+
*
|
|
209
|
+
* If a cycle exists such that trait A has trait B which has Trait A, trait A will
|
|
210
|
+
* be applied *after* trait B in production. In development a cycle error will be thrown.
|
|
211
|
+
*
|
|
212
|
+
* Fields are finalized on a "last wins principle". Thus traits appearing higher in
|
|
213
|
+
* the tree and further to the right of a traits array take precedence, with the
|
|
214
|
+
* resource's fields always being applied last and winning out.
|
|
215
|
+
*
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
registerTrait(trait: Trait): void;
|
|
224
219
|
registerTransformation<
|
|
225
220
|
T extends Value = string,
|
|
226
221
|
PT = unknown
|
|
@@ -231,39 +226,28 @@ export declare class SchemaService implements SchemaServiceInterface {
|
|
|
231
226
|
FM extends ObjectValue | null
|
|
232
227
|
>(derivation: Derivation<R, T, FM>): void;
|
|
233
228
|
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
|
|
234
|
-
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource:
|
|
229
|
+
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
|
|
235
230
|
type: string;
|
|
236
231
|
}): null | ProcessedExtension["features"];
|
|
237
|
-
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
232
|
+
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
238
233
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
234
|
+
CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: {
|
|
235
|
+
kind: "object" | "array";
|
|
236
|
+
name: string;
|
|
237
|
+
}): boolean;
|
|
239
238
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* We do think a generalized `kind` registration system would be useful,
|
|
244
|
-
* but we have not yet designed it.
|
|
245
|
-
*
|
|
246
|
-
* See https://github.com/emberjs/data/issues/9534
|
|
247
|
-
*
|
|
248
|
-
* @internal
|
|
249
|
-
*/
|
|
250
|
-
_registerMode(mode: string, kinds: KindFns): void;
|
|
251
|
-
/**
|
|
252
|
-
* This is an internal method used to enable legacy behaviors for legacy mode.
|
|
253
|
-
* It is not intended for public use.
|
|
254
|
-
*
|
|
255
|
-
* We do think a generalized `kind` registration system would be useful,
|
|
256
|
-
* but we have not yet designed it.
|
|
239
|
+
* Registers a {@link HashFn} for use with a {@link HashField} for
|
|
240
|
+
* either {@link ObjectSchema} identity or polymorphic type calculation.
|
|
257
241
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* @internal
|
|
242
|
+
* @public
|
|
261
243
|
*/
|
|
262
|
-
_kind<T extends keyof KindFns>(mode: string, kind: T): KindFns[T];
|
|
263
244
|
registerHashFn<T extends object>(hashFn: HashFn<T>): void;
|
|
264
245
|
fields({ type }: {
|
|
265
246
|
type: string;
|
|
266
247
|
}): InternalSchema["fields"];
|
|
248
|
+
cacheFields({ type }: {
|
|
249
|
+
type: string;
|
|
250
|
+
}): InternalSchema["cacheFields"];
|
|
267
251
|
hasResource(resource: {
|
|
268
252
|
type: string;
|
|
269
253
|
}): boolean;
|
|
@@ -25,12 +25,7 @@
|
|
|
25
25
|
// Note that none of these symbols are part of the public API, these are used for
|
|
26
26
|
// debugging DX and as a safe way to provide an intimate contract on public objects.
|
|
27
27
|
export declare const SOURCE: "___(unique) Symbol(SOURCE)";
|
|
28
|
-
export declare const MUTATE: "___(unique) Symbol(MUTATE)";
|
|
29
28
|
export declare const Destroy: "___(unique) Symbol(Destroy)";
|
|
30
|
-
export declare const Identifier: "___(unique) Symbol(Identifier)";
|
|
31
|
-
export declare const Editable: "___(unique) Symbol(Editable)";
|
|
32
|
-
export declare const Parent: "___(unique) Symbol(Parent)";
|
|
33
29
|
export declare const Checkout: "___(unique) Symbol(Checkout)";
|
|
34
|
-
export declare const
|
|
35
|
-
export declare const
|
|
36
|
-
export declare const EmbeddedField: "___(unique) Symbol(EmbeddedField)";
|
|
30
|
+
export declare const Commit: "___(unique) Symbol(Commit)";
|
|
31
|
+
export declare const Context: "___(unique) Symbol(Context)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Context } from "./-private/symbols.js";
|