@warp-drive/core 5.7.0-alpha.8 → 5.7.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/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 +0 -87
- package/declarations/graph/-private/-utils.d.ts +5 -11
- package/declarations/graph/-private/coerce-id.d.ts +0 -6
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
- 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 -51
- package/declarations/graph/-private/normalize-link.d.ts +0 -6
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +2 -2
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/managed-array.d.ts +4 -6
- package/declarations/reactive/-private/fields/managed-object.d.ts +2 -8
- 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/record.d.ts +42 -30
- package/declarations/reactive/-private/schema.d.ts +11 -73
- package/declarations/reactive/-private/symbols.d.ts +2 -33
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +277 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -2
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -24
- 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 -5
- package/declarations/store/-private/caches/instance-cache.d.ts +21 -20
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -40
- 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} +35 -53
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -25
- 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 +132 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
- 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 +67 -0
- package/declarations/store/-private/store-service.d.ts +156 -106
- package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
- package/declarations/store/-private.d.ts +11 -13
- 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 +9 -9
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +12 -24
- package/declarations/store/deprecated/store.d.ts +11 -16
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +0 -11
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -37
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -7
- package/declarations/types/cache.d.ts +51 -125
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -78
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +66 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +30 -3
- package/declarations/types/spec/document.d.ts +6 -10
- package/declarations/types/spec/json-api-raw.d.ts +6 -9
- package/declarations/types.d.ts +0 -1
- package/declarations/utils/string.d.ts +2 -3
- 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 +144 -1926
- package/dist/{request-state-CeN66aML.js → request-state-C955e0AL.js} +5968 -3033
- 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 +6 -0
- package/dist/utils/string.js +2 -2
- package/package.json +11 -11
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- 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/dist/handler-SdXlte1w.js +0 -339
|
@@ -1,126 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
We redefine Proxy because the native Proxy type treats the `target` and
|
|
4
|
-
`receiver` as the same type incorrectly.
|
|
5
|
-
|
|
6
|
-
We ported this from Typescript's own Proxy types on 3/10/2024.
|
|
7
|
-
*/
|
|
8
|
-
interface ProxyHandler<T extends object> {
|
|
9
|
-
/**
|
|
10
|
-
* A trap method for a function call.
|
|
11
|
-
* @param target The original callable object which is being proxied.
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
apply?(target: T, thisArg: any, argArray: any[]): any;
|
|
15
|
-
/**
|
|
16
|
-
* A trap for the `new` operator.
|
|
17
|
-
* @param target The original object which is being proxied.
|
|
18
|
-
* @param newTarget The constructor that was originally called.
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
22
|
-
construct?(target: T, argArray: any[], newTarget: Function): object;
|
|
23
|
-
/**
|
|
24
|
-
* A trap for `Object.defineProperty()`.
|
|
25
|
-
* @param target The original object which is being proxied.
|
|
26
|
-
* @return A `Boolean` indicating whether or not the property has been defined.
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* A trap for the `delete` operator.
|
|
32
|
-
* @param target The original object which is being proxied.
|
|
33
|
-
* @param p The name or `Symbol` of the property to delete.
|
|
34
|
-
* @return A `Boolean` indicating whether or not the property was deleted.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
deleteProperty?(target: T, p: string | symbol): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* A trap for getting a property value.
|
|
40
|
-
* @param target The original object which is being proxied.
|
|
41
|
-
* @param p The name or `Symbol` of the property to get.
|
|
42
|
-
* @param receiver The proxy or an object that inherits from the proxy.
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
get?(target: T, p: string | symbol, receiver: any): any;
|
|
46
|
-
/**
|
|
47
|
-
* A trap for `Object.getOwnPropertyDescriptor()`.
|
|
48
|
-
* @param target The original object which is being proxied.
|
|
49
|
-
* @param p The name of the property whose description should be retrieved.
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
52
|
-
getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* A trap for the `[[GetPrototypeOf]]` internal method.
|
|
55
|
-
* @param target The original object which is being proxied.
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
getPrototypeOf?(target: T): object | null;
|
|
59
|
-
/**
|
|
60
|
-
* A trap for the `in` operator.
|
|
61
|
-
* @param target The original object which is being proxied.
|
|
62
|
-
* @param p The name or `Symbol` of the property to check for existence.
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
has?(target: T, p: string | symbol): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* A trap for `Object.isExtensible()`.
|
|
68
|
-
* @param target The original object which is being proxied.
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
isExtensible?(target: T): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* A trap for `Reflect.ownKeys()`.
|
|
74
|
-
* @param target The original object which is being proxied.
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
ownKeys?(target: T): ArrayLike<string | symbol>;
|
|
78
|
-
/**
|
|
79
|
-
* A trap for `Object.preventExtensions()`.
|
|
80
|
-
* @param target The original object which is being proxied.
|
|
81
|
-
* @internal
|
|
82
|
-
*/
|
|
83
|
-
preventExtensions?(target: T): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* A trap for setting a property value.
|
|
86
|
-
* @param target The original object which is being proxied.
|
|
87
|
-
* @param p The name or `Symbol` of the property to set.
|
|
88
|
-
* @param receiver The object to which the assignment was originally directed.
|
|
89
|
-
* @return A `Boolean` indicating whether or not the property was set.
|
|
90
|
-
* @internal
|
|
91
|
-
*/
|
|
92
|
-
set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* A trap for `Object.setPrototypeOf()`.
|
|
95
|
-
* @param target The original object which is being proxied.
|
|
96
|
-
* @param newPrototype The object's new prototype or `null`.
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
99
|
-
setPrototypeOf?(target: T, v: object | null): boolean;
|
|
100
|
-
}
|
|
101
|
-
interface ProxyConstructor {
|
|
102
|
-
/**
|
|
103
|
-
* Creates a revocable Proxy object.
|
|
104
|
-
* @param target A target object to wrap with Proxy.
|
|
105
|
-
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
108
|
-
revocable<T extends object>(target: T, handler: ProxyHandler<T>): {
|
|
109
|
-
proxy: T;
|
|
110
|
-
revoke: () => void;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the
|
|
114
|
-
* original object, but which may redefine fundamental Object operations like getting, setting, and defining
|
|
115
|
-
* properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.
|
|
116
|
-
* @param target A target object to wrap with Proxy.
|
|
117
|
-
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
new <
|
|
121
|
-
TSource extends object,
|
|
122
|
-
TTarget extends object
|
|
123
|
-
>(target: TSource, handler: ProxyHandler<TSource>): TTarget;
|
|
124
|
-
}
|
|
1
|
+
interface ProxyConstructor {}
|
|
125
2
|
export declare const NativeProxy: ProxyConstructor;
|
|
126
3
|
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ExtensionDef } from "../../../reactive.js";
|
|
2
|
+
import { Context } from "../../../reactive/-private.js";
|
|
3
|
+
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
4
|
+
import type { ObjectValue } from "../../../types/json/raw.js";
|
|
5
|
+
import type { CollectionField } from "../../../types/schema/fields.js";
|
|
6
|
+
import type { SignalStore, WarpDriveSignal } from "../new-core-tmp/reactivity/internal.js";
|
|
7
|
+
import type { Store } from "../store-service.js";
|
|
8
|
+
import type { KeyType, MinimumManager } from "./-utils.js";
|
|
9
|
+
import { NativeProxy } from "./native-proxy-type-fix.js";
|
|
10
|
+
declare const IS_COLLECTION: "___(unique) Symbol(IS_COLLECTION)";
|
|
11
|
+
type ProxiedMethod = (...args: unknown[]) => unknown;
|
|
12
|
+
interface ReactiveResourceArrayCreateOptions {
|
|
13
|
+
store: Store;
|
|
14
|
+
manager: MinimumManager;
|
|
15
|
+
editable: boolean;
|
|
16
|
+
source: ResourceKey[];
|
|
17
|
+
data: ObjectValue | null;
|
|
18
|
+
features: Record<string | symbol, unknown> | null;
|
|
19
|
+
extensions: Map<string | symbol, ExtensionDef> | null;
|
|
20
|
+
options: Record<string, unknown> | null;
|
|
21
|
+
destroy: null | ((this: ReactiveResourceArray, clear: boolean) => void);
|
|
22
|
+
mutate: null | ((target: ResourceKey[], receiver: typeof NativeProxy<ResourceKey[], unknown[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal) => unknown);
|
|
23
|
+
}
|
|
24
|
+
interface ReactiveResourceArrayContext extends ReactiveResourceArrayCreateOptions {
|
|
25
|
+
destroy: (this: ReactiveResourceArray, clear: boolean) => void;
|
|
26
|
+
mutate: (target: ResourceKey[], receiver: typeof NativeProxy<ResourceKey[], unknown[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal) => unknown;
|
|
27
|
+
signals: SignalStore;
|
|
28
|
+
signal: WarpDriveSignal;
|
|
29
|
+
isDestroying: boolean;
|
|
30
|
+
isDestroyed: boolean;
|
|
31
|
+
transaction: boolean;
|
|
32
|
+
boundFns: Map<KeyType, ProxiedMethod>;
|
|
33
|
+
}
|
|
34
|
+
export interface ReactiveResourceArray<T = unknown> extends Omit<Array<T>, "[]"> {}
|
|
35
|
+
export interface PrivateReactiveResourceArray<T = unknown> extends Omit<Array<T>, "[]"> {
|
|
36
|
+
isDestroying: boolean;
|
|
37
|
+
isDestroyed: boolean;
|
|
38
|
+
destroy: (this: ReactiveResourceArray, clear: boolean) => void;
|
|
39
|
+
[IS_COLLECTION]: boolean;
|
|
40
|
+
[Context]: ReactiveResourceArrayContext;
|
|
41
|
+
}
|
|
42
|
+
export interface TargetArray extends Array<ResourceKey> {}
|
|
43
|
+
export declare function createReactiveResourceArray<T>(options: ReactiveResourceArrayCreateOptions): ReactiveResourceArray<T>;
|
|
44
|
+
export declare function destroy(this: ReactiveResourceArray, clear: boolean): void;
|
|
45
|
+
export interface ReactiveRequestCollectionCreateArgs {
|
|
46
|
+
store: Store;
|
|
47
|
+
manager: MinimumManager;
|
|
48
|
+
source: ResourceKey[];
|
|
49
|
+
options: {
|
|
50
|
+
requestKey: RequestKey;
|
|
51
|
+
} | null;
|
|
52
|
+
}
|
|
53
|
+
export declare function createRequestCollection(config: ReactiveRequestCollectionCreateArgs): ReactiveResourceArray;
|
|
54
|
+
export interface ReactiveRelatedCollectionCreateArgs {
|
|
55
|
+
store: Store;
|
|
56
|
+
manager: MinimumManager;
|
|
57
|
+
source: ResourceKey[];
|
|
58
|
+
options: {
|
|
59
|
+
resourceKey: ResourceKey;
|
|
60
|
+
path: string[];
|
|
61
|
+
field: CollectionField;
|
|
62
|
+
};
|
|
63
|
+
editable: boolean;
|
|
64
|
+
extensions: Map<string | symbol, ExtensionDef> | null;
|
|
65
|
+
}
|
|
66
|
+
export declare function createRelatedCollection(config: ReactiveRelatedCollectionCreateArgs): ReactiveResourceArray;
|
|
67
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Graph } from "../../graph/-private.js";
|
|
2
2
|
import type { Future } from "../../request.js";
|
|
3
|
-
import type { RequestManager } from "../../request/-private/manager.js";
|
|
3
|
+
import type { PrivateRequestManager, RequestManager } from "../../request/-private/manager.js";
|
|
4
4
|
import type { Cache } from "../../types/cache.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { PersistedResourceKey, ResourceKey } from "../../types/identifier.js";
|
|
6
6
|
import type { TypedRecordInstance, TypeFromInstance } from "../../types/record.js";
|
|
7
7
|
import type { CollectionResourceDocument, EmptyResourceDocument, JsonApiDocument, ResourceIdentifierObject, SingleResourceDocument } from "../../types/spec/json-api-raw.js";
|
|
8
8
|
import type { Type } from "../../types/symbols.js";
|
|
@@ -11,19 +11,20 @@ import type { OpaqueRecordInstance } from "../-types/q/record-instance.js";
|
|
|
11
11
|
import type { SchemaService } from "../-types/q/schema-service.js";
|
|
12
12
|
import type { StoreRequestInput } from "./cache-handler/handler.js";
|
|
13
13
|
import type { CachePolicy } from "./cache-handler/types.js";
|
|
14
|
-
import { IdentifierCache } from "./caches/identifier-cache.js";
|
|
15
14
|
import { InstanceCache, storeFor } from "./caches/instance-cache.js";
|
|
15
|
+
import type { PrivateCacheKeyManager } from "./managers/cache-key-manager.js";
|
|
16
|
+
import { CacheKeyManager } from "./managers/cache-key-manager.js";
|
|
17
|
+
import type { PrivateNotificationManager } from "./managers/notification-manager.js";
|
|
16
18
|
import NotificationManager from "./managers/notification-manager.js";
|
|
17
|
-
import {
|
|
19
|
+
import type { PrivateRecordArrayManager } from "./managers/record-array-manager.js";
|
|
20
|
+
import type { PrivateRequestStateService } from "./network/request-cache.js";
|
|
18
21
|
import { RequestStateService } from "./network/request-cache.js";
|
|
19
|
-
import type {
|
|
22
|
+
import type { LegacyLiveArray } from "./record-arrays/legacy-live-array.js";
|
|
20
23
|
export { storeFor };
|
|
21
|
-
// We inline this list of methods to avoid importing EmberObject
|
|
22
24
|
type EmberObjectKey = "_debugContainerKey" | "_super" | "addObserver" | "cacheFor" | "concatenatedProperties" | "decrementProperty" | "destroy" | "get" | "getProperties" | "incrementProperty" | "init" | "isDestroyed" | "isDestroying" | "mergedProperties" | "notifyPropertyChange" | "removeObserver" | "reopen" | "set" | "setProperties" | "toggleProperty" | "toString" | "willDestroy";
|
|
23
25
|
type DSModelKeys = "___(unique) Symbol(Store)" | "___private_notifications" | "___recordState" | "_createSnapshot" | "adapterError" | "attr" | "belongsTo" | "changedAttributes" | "currentState" | "deleteRecord" | "destroyRecord" | "dirtyType" | "eachAttribute" | "eachRelationship" | "errors" | "hasDirtyAttributes" | "hasMany" | "inverseFor" | "isDeleted" | "isEmpty" | "isError" | "isLoaded" | "isLoading" | "isNew" | "isReloading" | "isSaving" | "isValid" | "relationshipFor" | "reload" | "rollbackAttributes" | "save" | "serialize" | "store" | "unloadRecord";
|
|
24
26
|
type DownlevelArrays<T> = T extends Array<infer U> ? U[] : T;
|
|
25
27
|
type AwaitedKeys<T> = { [K in keyof T & string] : DownlevelArrays<Awaited<T[K]>> };
|
|
26
|
-
// `AwaitedKeys` is needed here to resolve any promise types like `PromiseBelongsTo`.
|
|
27
28
|
type FilteredKeys<T> = AwaitedKeys<Omit<T, typeof Type | EmberObjectKey | DSModelKeys | "constructor">>;
|
|
28
29
|
type MaybeHasId = {
|
|
29
30
|
id?: string | null;
|
|
@@ -45,9 +46,10 @@ type MaybeHasId = {
|
|
|
45
46
|
*
|
|
46
47
|
*/
|
|
47
48
|
export type CreateRecordProperties<T = MaybeHasId & Record<string, unknown>> = T extends TypedRecordInstance ? Partial<FilteredKeys<T>> : T extends MaybeHasId ? MaybeHasId & Partial<FilteredKeys<T>> : MaybeHasId & Record<string, unknown>;
|
|
48
|
-
|
|
49
|
+
export interface CreateContext {
|
|
50
|
+
lid?: string;
|
|
51
|
+
}
|
|
49
52
|
type ConstructorFunction = new (...args: any[]) => any;
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
51
53
|
declare const EmptyClass: ConstructorFunction;
|
|
52
54
|
declare const BaseClass: typeof EmptyClass;
|
|
53
55
|
export interface Store {
|
|
@@ -75,8 +77,7 @@ export interface Store {
|
|
|
75
77
|
* @return A record instance
|
|
76
78
|
* @public
|
|
77
79
|
*/
|
|
78
|
-
|
|
79
|
-
instantiateRecord<T>(identifier: StableRecordIdentifier, createRecordArgs: {
|
|
80
|
+
instantiateRecord<T>(identifier: ResourceKey, createRecordArgs: {
|
|
80
81
|
[key: string]: unknown;
|
|
81
82
|
}): OpaqueRecordInstance;
|
|
82
83
|
/**
|
|
@@ -144,7 +145,6 @@ export interface Store {
|
|
|
144
145
|
* be sourced from directly registered schemas, then will fallback
|
|
145
146
|
* to sourcing a schema from available models if no schema is found.
|
|
146
147
|
*
|
|
147
|
-
* @return {SchemaService}
|
|
148
148
|
* @public
|
|
149
149
|
*/
|
|
150
150
|
createSchemaService(): SchemaService;
|
|
@@ -190,11 +190,11 @@ export interface Store {
|
|
|
190
190
|
* return this._schema.hasResource(resource);
|
|
191
191
|
* }
|
|
192
192
|
*
|
|
193
|
-
* attributesDefinitionFor(identifier:
|
|
193
|
+
* attributesDefinitionFor(identifier: ResourceKey | { type: string }): AttributesSchema {
|
|
194
194
|
* return this._schema.attributesDefinitionFor(identifier);
|
|
195
195
|
* }
|
|
196
196
|
*
|
|
197
|
-
* relationshipsDefinitionFor(identifier:
|
|
197
|
+
* relationshipsDefinitionFor(identifier: ResourceKey | { type: string }): RelationshipsSchema {
|
|
198
198
|
* const schema = AbstractSchemas.get(identifier.type);
|
|
199
199
|
* return schema || this._schema.relationshipsDefinitionFor(identifier);
|
|
200
200
|
* }
|
|
@@ -244,11 +244,11 @@ export interface Store {
|
|
|
244
244
|
* return this._schema.hasResource(resource);
|
|
245
245
|
* }
|
|
246
246
|
*
|
|
247
|
-
* attributesDefinitionFor(identifier:
|
|
247
|
+
* attributesDefinitionFor(identifier: ResourceKey | { type: string }): AttributesSchema {
|
|
248
248
|
* return this._schema.attributesDefinitionFor(identifier);
|
|
249
249
|
* }
|
|
250
250
|
*
|
|
251
|
-
* relationshipsDefinitionFor(identifier:
|
|
251
|
+
* relationshipsDefinitionFor(identifier: ResourceKey | { type: string }): RelationshipsSchema {
|
|
252
252
|
* const schema = AbstractSchemas.get(identifier.type);
|
|
253
253
|
* return schema || this._schema.relationshipsDefinitionFor(identifier);
|
|
254
254
|
* }
|
|
@@ -289,8 +289,6 @@ export interface Store {
|
|
|
289
289
|
* @hideconstructor
|
|
290
290
|
*/
|
|
291
291
|
export declare class Store extends BaseClass {
|
|
292
|
-
/** @internal */
|
|
293
|
-
readonly recordArrayManager: RecordArrayManager;
|
|
294
292
|
/**
|
|
295
293
|
* Provides access to the NotificationManager associated
|
|
296
294
|
* with this Store instance.
|
|
@@ -311,18 +309,17 @@ export declare class Store extends BaseClass {
|
|
|
311
309
|
* @public
|
|
312
310
|
*/
|
|
313
311
|
get schema(): ReturnType<this["createSchemaService"]>;
|
|
314
|
-
/** @internal */
|
|
315
|
-
_schema: SchemaService;
|
|
316
312
|
/**
|
|
317
|
-
* Provides access to the
|
|
313
|
+
* Provides access to the CacheKeyManager
|
|
318
314
|
* for this store.
|
|
319
315
|
*
|
|
320
|
-
* The
|
|
321
|
-
* retrieve a stable unique
|
|
316
|
+
* The CacheKeyManager can be used to generate or
|
|
317
|
+
* retrieve a stable unique CacheKey for any resource
|
|
318
|
+
* or request.
|
|
322
319
|
*
|
|
323
320
|
* @public
|
|
324
321
|
*/
|
|
325
|
-
readonly
|
|
322
|
+
readonly cacheKeyManager: CacheKeyManager;
|
|
326
323
|
/**
|
|
327
324
|
* Provides access to the requestManager instance associated
|
|
328
325
|
* with this Store instance.
|
|
@@ -353,7 +350,7 @@ export declare class Store extends BaseClass {
|
|
|
353
350
|
*
|
|
354
351
|
* Note, when defined, these methods will only be invoked if a
|
|
355
352
|
* cache key exists for the request, either because the request
|
|
356
|
-
* contains `cacheOptions.key` or because the [
|
|
353
|
+
* contains `cacheOptions.key` or because the [CacheKeyManager](/ember-data/release/classes/CacheKeyManager)
|
|
357
354
|
* was able to generate a key for the request using the configured
|
|
358
355
|
* [generation method](/ember-data/release/functions/@ember-data%2Fstore/setIdentifierGenerationMethod).
|
|
359
356
|
*
|
|
@@ -362,12 +359,12 @@ export declare class Store extends BaseClass {
|
|
|
362
359
|
* ```ts
|
|
363
360
|
* store.lifetimes = {
|
|
364
361
|
* // make the request and ignore the current cache state
|
|
365
|
-
* isHardExpired(
|
|
362
|
+
* isHardExpired(key: RequestKey): boolean {
|
|
366
363
|
* return false;
|
|
367
364
|
* }
|
|
368
365
|
*
|
|
369
366
|
* // make the request in the background if true, return cache state
|
|
370
|
-
* isSoftExpired(
|
|
367
|
+
* isSoftExpired(key: RequestKey): boolean {
|
|
371
368
|
* return false;
|
|
372
369
|
* }
|
|
373
370
|
* }
|
|
@@ -376,65 +373,16 @@ export declare class Store extends BaseClass {
|
|
|
376
373
|
* @public
|
|
377
374
|
*/
|
|
378
375
|
lifetimes?: CachePolicy;
|
|
379
|
-
|
|
380
|
-
/** @internal */
|
|
381
|
-
_graph?: Graph;
|
|
382
|
-
/** @internal */
|
|
383
|
-
_requestCache: RequestStateService;
|
|
384
|
-
/** @internal */
|
|
385
|
-
_instanceCache: InstanceCache;
|
|
386
|
-
/** @internal */
|
|
387
|
-
_cbs: {
|
|
388
|
-
coalesce?: () => void;
|
|
389
|
-
sync?: () => void;
|
|
390
|
-
notify?: () => void;
|
|
391
|
-
} | null;
|
|
392
|
-
/** @internal */
|
|
393
|
-
_forceShim: boolean;
|
|
394
|
-
/**
|
|
395
|
-
* Async flush buffers notifications until flushed
|
|
396
|
-
* by finalization of a future configured by store.request
|
|
397
|
-
*
|
|
398
|
-
* This is useful for ensuring that notifications are delivered
|
|
399
|
-
* prior to the promise resolving but without risk of promise
|
|
400
|
-
* interleaving.
|
|
401
|
-
*
|
|
402
|
-
* @internal
|
|
403
|
-
*/
|
|
404
|
-
_enableAsyncFlush: boolean | null;
|
|
405
|
-
// DEBUG-only properties
|
|
406
|
-
/** @internal */
|
|
407
|
-
DISABLE_WAITER?: boolean;
|
|
408
|
-
/** @internal */
|
|
409
|
-
_isDestroying: boolean;
|
|
410
|
-
/** @internal */
|
|
411
|
-
_isDestroyed: boolean;
|
|
412
|
-
/** @internal */
|
|
376
|
+
/** @private */
|
|
413
377
|
get isDestroying(): boolean;
|
|
414
|
-
/** @
|
|
415
|
-
set isDestroying(value: boolean);
|
|
416
|
-
/** @internal */
|
|
378
|
+
/** @private */
|
|
417
379
|
get isDestroyed(): boolean;
|
|
418
|
-
/** @
|
|
419
|
-
|
|
380
|
+
/** @deprecated use {@link Store.cacheKeyManager} */
|
|
381
|
+
get identifierCache(): CacheKeyManager;
|
|
420
382
|
/**
|
|
421
383
|
@private
|
|
422
384
|
*/
|
|
423
385
|
constructor(createArgs?: unknown);
|
|
424
|
-
/** @internal */
|
|
425
|
-
_run(cb: () => void): void;
|
|
426
|
-
/**
|
|
427
|
-
* Executes the callback, ensurng that any work that calls
|
|
428
|
-
* store._schedule is executed after in the right order.
|
|
429
|
-
*
|
|
430
|
-
* When queues already exist, scheduled callbacks will
|
|
431
|
-
* join the existing queue.
|
|
432
|
-
*
|
|
433
|
-
* @internal
|
|
434
|
-
*/
|
|
435
|
-
_join(cb: () => void): void;
|
|
436
|
-
/** @internal */
|
|
437
|
-
_schedule(name: "coalesce" | "sync" | "notify", cb: () => void): void;
|
|
438
386
|
/**
|
|
439
387
|
* Retrieve the RequestStateService instance
|
|
440
388
|
* associated with this Store.
|
|
@@ -446,10 +394,6 @@ export declare class Store extends BaseClass {
|
|
|
446
394
|
* @public
|
|
447
395
|
*/
|
|
448
396
|
getRequestStateService(): RequestStateService;
|
|
449
|
-
/** @internal */
|
|
450
|
-
_getAllPending(): (Promise<unknown[]> & {
|
|
451
|
-
length: number;
|
|
452
|
-
}) | void;
|
|
453
397
|
/**
|
|
454
398
|
* ::: tip 💡 For a more complete overview see the [Request Guide](/guides/2-requests/1-overview)
|
|
455
399
|
* :::
|
|
@@ -464,7 +408,7 @@ export declare class Store extends BaseClass {
|
|
|
464
408
|
* {@link CacheOptions.key | cache key} will have the request result
|
|
465
409
|
* and document cached.
|
|
466
410
|
*
|
|
467
|
-
* The cache key used is {@link RequestInfo.cacheOptions | RequestInfo.cacheOptions.key}
|
|
411
|
+
* The cache key used is {@link RequestInfo.cacheOptions.key | RequestInfo.cacheOptions.key}
|
|
468
412
|
* if present, falling back to {@link RequestInfo.url}.
|
|
469
413
|
*
|
|
470
414
|
* Params are not serialized as part of the cache-key, so
|
|
@@ -503,40 +447,77 @@ export declare class Store extends BaseClass {
|
|
|
503
447
|
*
|
|
504
448
|
* @public
|
|
505
449
|
*/
|
|
506
|
-
request<
|
|
507
|
-
RT,
|
|
508
|
-
T = unknown
|
|
509
|
-
>(requestConfig: StoreRequestInput<RT, T>): Future<RT>;
|
|
450
|
+
request<RT>(requestConfig: StoreRequestInput<RT>): Future<RT>;
|
|
510
451
|
/**
|
|
511
|
-
|
|
512
|
-
to this method are set on the newly created record.
|
|
452
|
+
Creates a new record in the current store.
|
|
513
453
|
|
|
514
|
-
|
|
454
|
+
> [!CAUTION]
|
|
455
|
+
> This should not be used to mock records or to create
|
|
456
|
+
> a record representing data that could be fetched from
|
|
457
|
+
> the API.
|
|
458
|
+
|
|
459
|
+
The properties passed to this method are set on
|
|
460
|
+
the newly created record.
|
|
461
|
+
|
|
462
|
+
For instance: to create a new `post`:
|
|
515
463
|
|
|
516
464
|
```js
|
|
517
465
|
store.createRecord('post', {
|
|
518
|
-
title: '
|
|
466
|
+
title: 'WarpDrive is Stellar!'
|
|
519
467
|
});
|
|
520
468
|
```
|
|
521
469
|
|
|
522
|
-
|
|
470
|
+
Relationships can be set during create. For instance,
|
|
471
|
+
to create a new `post` that has an existing user as
|
|
472
|
+
it's author:
|
|
523
473
|
|
|
524
474
|
```js
|
|
525
|
-
|
|
475
|
+
const user = store.peekRecord('user', '1');
|
|
476
|
+
|
|
526
477
|
store.createRecord('post', {
|
|
527
|
-
title: '
|
|
478
|
+
title: 'WarpDrive is Stellar!',
|
|
528
479
|
user: user
|
|
529
480
|
});
|
|
530
481
|
```
|
|
531
482
|
|
|
483
|
+
### lid handling
|
|
484
|
+
|
|
485
|
+
All new records are assigned an `lid` that can be used to handle
|
|
486
|
+
transactional saves of multiple records, or to link the data to
|
|
487
|
+
other data in scenarios involving eventual-consistency or remote
|
|
488
|
+
syncing.
|
|
489
|
+
|
|
490
|
+
```ts
|
|
491
|
+
const post = store.createRecord('post', {
|
|
492
|
+
title: 'WarpDrive is Stellar!'
|
|
493
|
+
});
|
|
494
|
+
const { lid } = recordIdentifierFor(post);
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
The `lid` defaults to a uuidv4 string.
|
|
498
|
+
|
|
499
|
+
In order to support receiving knowledge about unpersisted creates
|
|
500
|
+
from other sources (say a different tab in the same web-browser),
|
|
501
|
+
createRecord allows for the `lid` to be provided as part of an
|
|
502
|
+
optional third argument. **If this lid already exists in the store
|
|
503
|
+
an error will be thrown.**
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
const post = store.createRecord(
|
|
507
|
+
'post',
|
|
508
|
+
{ title: 'WarpDrive is Stellar!' },
|
|
509
|
+
{ lid: '4d47bb88-931f-496e-986d-c4888cef7373' }
|
|
510
|
+
);
|
|
511
|
+
```
|
|
512
|
+
|
|
532
513
|
@public
|
|
533
|
-
@param
|
|
534
|
-
@param
|
|
514
|
+
@param type the name of the resource
|
|
515
|
+
@param inputProperties a hash of properties to set on the
|
|
535
516
|
newly created record.
|
|
536
|
-
@return
|
|
517
|
+
@return a record in the "isNew" state
|
|
537
518
|
*/
|
|
538
|
-
createRecord<T>(type: TypeFromInstance<T>, inputProperties: CreateRecordProperties<T
|
|
539
|
-
createRecord(type: string, inputProperties: CreateRecordProperties): OpaqueRecordInstance;
|
|
519
|
+
createRecord<T>(type: TypeFromInstance<T>, inputProperties: CreateRecordProperties<T>, context?: CreateContext): T;
|
|
520
|
+
createRecord(type: string, inputProperties: CreateRecordProperties, context?: CreateContext): OpaqueRecordInstance;
|
|
540
521
|
/**
|
|
541
522
|
For symmetry, a record can be deleted via the store.
|
|
542
523
|
|
|
@@ -644,8 +625,8 @@ export declare class Store extends BaseClass {
|
|
|
644
625
|
@param {String} type the name of the resource
|
|
645
626
|
@return {RecordArray}
|
|
646
627
|
*/
|
|
647
|
-
peekAll<T>(type: TypeFromInstance<T>):
|
|
648
|
-
peekAll(type: string):
|
|
628
|
+
peekAll<T>(type: TypeFromInstance<T>): LegacyLiveArray<T>;
|
|
629
|
+
peekAll(type: string): LegacyLiveArray;
|
|
649
630
|
/**
|
|
650
631
|
This method unloads all records in the store.
|
|
651
632
|
It schedules unloading to happen during the next run loop.
|
|
@@ -823,9 +804,9 @@ export declare class Store extends BaseClass {
|
|
|
823
804
|
|
|
824
805
|
@private
|
|
825
806
|
@param {Object} jsonApiDoc
|
|
826
|
-
@return {
|
|
807
|
+
@return {ResourceKey|Array<ResourceKey>|null} identifiers for the primary records that had data loaded
|
|
827
808
|
*/
|
|
828
|
-
_push(jsonApiDoc: JsonApiDocument, asyncFlush?: boolean):
|
|
809
|
+
_push(jsonApiDoc: JsonApiDocument, asyncFlush?: boolean): PersistedResourceKey | PersistedResourceKey[] | null;
|
|
829
810
|
/**
|
|
830
811
|
* Returns the cache instance associated to this Store, instantiates the Cache
|
|
831
812
|
* if necessary via `Store.createCache`
|
|
@@ -833,7 +814,7 @@ export declare class Store extends BaseClass {
|
|
|
833
814
|
* @public
|
|
834
815
|
*/
|
|
835
816
|
get cache(): ReturnType<this["createCache"]>;
|
|
836
|
-
/** @
|
|
817
|
+
/** @private */
|
|
837
818
|
destroy(): void;
|
|
838
819
|
/**
|
|
839
820
|
* This method
|
|
@@ -842,4 +823,73 @@ export declare class Store extends BaseClass {
|
|
|
842
823
|
*/
|
|
843
824
|
static create(args?: Record<string, unknown>): Store;
|
|
844
825
|
}
|
|
826
|
+
/**
|
|
827
|
+
* This type exists for internal use only for
|
|
828
|
+
* where intimate contracts still exist either for
|
|
829
|
+
* the Test Suite or for Legacy code.
|
|
830
|
+
*
|
|
831
|
+
* @private
|
|
832
|
+
*/
|
|
833
|
+
export interface PrivateStore extends Store {
|
|
834
|
+
readonly recordArrayManager: PrivateRecordArrayManager;
|
|
835
|
+
notifications: PrivateNotificationManager;
|
|
836
|
+
requestManager: PrivateRequestManager;
|
|
837
|
+
cacheKeyManager: PrivateCacheKeyManager;
|
|
838
|
+
_schema: SchemaService;
|
|
839
|
+
_graph?: Graph;
|
|
840
|
+
_requestCache: PrivateRequestStateService;
|
|
841
|
+
getRequestStateService(): PrivateRequestStateService;
|
|
842
|
+
_instanceCache: InstanceCache;
|
|
843
|
+
_cbs: {
|
|
844
|
+
coalesce?: () => void;
|
|
845
|
+
sync?: () => void;
|
|
846
|
+
notify?: () => void;
|
|
847
|
+
} | null;
|
|
848
|
+
_forceShim: boolean;
|
|
849
|
+
/**
|
|
850
|
+
* Async flush buffers notifications until flushed
|
|
851
|
+
* by finalization of a future configured by store.request
|
|
852
|
+
*
|
|
853
|
+
* This is useful for ensuring that notifications are delivered
|
|
854
|
+
* prior to the promise resolving but without risk of promise
|
|
855
|
+
* interleaving.
|
|
856
|
+
*/
|
|
857
|
+
_enableAsyncFlush: boolean | null;
|
|
858
|
+
/**
|
|
859
|
+
* Available in DEBUG Only
|
|
860
|
+
*/
|
|
861
|
+
DISABLE_WAITER?: boolean;
|
|
862
|
+
_isDestroying: boolean;
|
|
863
|
+
_isDestroyed: boolean;
|
|
864
|
+
isDestroying: boolean;
|
|
865
|
+
isDestroyed: boolean;
|
|
866
|
+
_run(cb: () => void): void;
|
|
867
|
+
/**
|
|
868
|
+
* Executes the callback, ensurng that any work that calls
|
|
869
|
+
* store._schedule is executed after in the right order.
|
|
870
|
+
*
|
|
871
|
+
* When queues already exist, scheduled callbacks will
|
|
872
|
+
* join the existing queue.
|
|
873
|
+
*
|
|
874
|
+
*/
|
|
875
|
+
_join(cb: () => void): void;
|
|
876
|
+
_schedule(name: "coalesce" | "sync" | "notify", cb: () => void): void;
|
|
877
|
+
_getAllPending(): (Promise<unknown[]> & {
|
|
878
|
+
length: number;
|
|
879
|
+
}) | void;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Upgrade the type for Store to PrivateStore, which will also
|
|
883
|
+
* upgrade any associated types to their private equivalents.
|
|
884
|
+
*
|
|
885
|
+
* @private
|
|
886
|
+
*/
|
|
887
|
+
export declare function assertPrivateStore(store: unknown): asserts store is PrivateStore;
|
|
888
|
+
/**
|
|
889
|
+
* Upgrade the type for Store to PrivateStore, which will also
|
|
890
|
+
* upgrade any associated types to their private equivalents.
|
|
891
|
+
*
|
|
892
|
+
* @private
|
|
893
|
+
*/
|
|
894
|
+
export declare function isPrivateStore(store: unknown): PrivateStore;
|
|
845
895
|
export declare function isMaybeIdentifier(maybeIdentifier: string | ResourceIdentifierObject): maybeIdentifier is ResourceIdentifierObject;
|
|
@@ -1,9 +1,3 @@
|
|
|
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
1
|
type Coercable = string | number | boolean | null | undefined | symbol;
|
|
8
2
|
export declare function coerceId(id: unknown): string | null;
|
|
9
3
|
export declare function ensureStringId(id: Coercable): string;
|