@warp-drive/core 5.7.0-alpha.13 → 5.7.0-alpha.15
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 +8 -8
- package/declarations/graph/-private/-edge-definition.d.ts +2 -2
- 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 +5 -5
- package/declarations/graph/-private/graph.d.ts +15 -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 +2 -2
- package/declarations/reactive/-private/document.d.ts +6 -16
- package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
- 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 +44 -5
- package/declarations/reactive/-private/schema.d.ts +12 -12
- package/declarations/reactive/-private/symbols.d.ts +1 -1
- package/declarations/reactive.d.ts +277 -1
- package/declarations/request/-private/context.d.ts +2 -2
- package/declarations/request/-private/fetch.d.ts +2 -2
- package/declarations/request/-private/manager.d.ts +2 -2
- package/declarations/request/-private/types.d.ts +4 -4
- package/declarations/request/-private/utils.d.ts +44 -2
- 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 +18 -18
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +21 -19
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
- package/declarations/store/-private/managers/notification-manager.d.ts +21 -25
- package/declarations/store/-private/managers/record-array-manager.d.ts +78 -27
- package/declarations/store/-private/network/request-cache.d.ts +11 -11
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +1 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
- package/declarations/store/-private/record-arrays/-utils.d.ts +82 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +89 -0
- package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts} +43 -101
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +103 -0
- package/declarations/store/-private/record-arrays/resource-array.d.ts +82 -0
- package/declarations/store/-private/store-service.d.ts +22 -19
- package/declarations/store/-private.d.ts +5 -3
- 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/schema-service.d.ts +9 -9
- package/declarations/store/deprecated/-private.d.ts +5 -5
- package/declarations/store/deprecated/store.d.ts +8 -9
- 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 -113
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +60 -76
- package/declarations/types/request.d.ts +27 -6
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +1 -1
- package/declarations/types/spec/document.d.ts +6 -6
- package/dist/{context-COmAnXUQ.js → context-kQXhkeBj.js} +13 -0
- package/dist/graph/-private.js +129 -129
- package/dist/index.js +6 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +126 -4
- package/dist/{request-state-BWYju5O9.js → request-state-CQ0Q6d1V.js} +4290 -4218
- package/dist/request.js +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/store.js +32 -44
- package/dist/{symbols-BoONANuz.js → symbols-sql1_mdx.js} +2 -2
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +27 -0
- package/dist/types/schema/fields.js +2 -0
- package/package.json +3 -3
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts}
RENAMED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
import type { BaseFinderOptions,
|
|
2
|
-
import type {
|
|
3
|
-
import type { TypedRecordInstance, TypeFromInstance, TypeFromInstanceOrString } from "../../../types/record.js";
|
|
1
|
+
import type { BaseFinderOptions, ResourceKey } from "../../../types.js";
|
|
2
|
+
import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
|
|
4
3
|
import type { LegacyHasManyField, LinksModeHasManyField } from "../../../types/schema/fields.js";
|
|
5
|
-
import type { Links, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
6
|
-
import type { CreateRecordProperties
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
9
|
-
export interface ManyArrayCreateArgs<T> {
|
|
10
|
-
identifiers: StableRecordIdentifier<TypeFromInstanceOrString<T>>[];
|
|
11
|
-
type: TypeFromInstanceOrString<T>;
|
|
12
|
-
store: Store;
|
|
13
|
-
allowMutation: boolean;
|
|
14
|
-
manager: MinimumManager;
|
|
15
|
-
field?: LegacyHasManyField | LinksModeHasManyField;
|
|
16
|
-
identifier: StableRecordIdentifier;
|
|
17
|
-
cache: Cache;
|
|
18
|
-
meta: Record<string, unknown> | null;
|
|
19
|
-
links: Links | PaginationLinks | null;
|
|
20
|
-
key: string;
|
|
21
|
-
isPolymorphic: boolean;
|
|
22
|
-
isAsync: boolean;
|
|
23
|
-
_inverseIsAsync: boolean;
|
|
24
|
-
isLoaded: boolean;
|
|
25
|
-
}
|
|
4
|
+
import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
5
|
+
import type { CreateRecordProperties } from "../store-service.js";
|
|
6
|
+
import type { LegacyLiveArrayCreateOptions } from "./legacy-live-array.js";
|
|
7
|
+
import { type ReactiveResourceArray } from "./resource-array.js";
|
|
26
8
|
/**
|
|
27
9
|
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
28
10
|
relationship.
|
|
@@ -63,83 +45,25 @@ the has-many.
|
|
|
63
45
|
We call the record to which a relationship belongs-to the
|
|
64
46
|
relationship's _owner_.
|
|
65
47
|
|
|
66
|
-
@class ManyArray
|
|
67
48
|
@public
|
|
68
49
|
*/
|
|
69
|
-
export
|
|
50
|
+
export interface LegacyManyArray<T = unknown> extends ReactiveResourceArray<T> {
|
|
51
|
+
meta: Meta | null;
|
|
52
|
+
links: Links | PaginationLinks | null;
|
|
53
|
+
/** @internal */
|
|
54
|
+
isPolymorphic: boolean;
|
|
55
|
+
/** @internal */
|
|
70
56
|
isAsync: boolean;
|
|
57
|
+
/** @internal */
|
|
58
|
+
key: string;
|
|
59
|
+
/** @internal */
|
|
60
|
+
modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
|
|
71
61
|
/**
|
|
72
62
|
The loading state of this array
|
|
73
|
-
|
|
74
|
-
@property isLoaded
|
|
75
|
-
@type {Boolean}
|
|
76
63
|
@public
|
|
77
64
|
*/
|
|
78
65
|
isLoaded: boolean;
|
|
79
|
-
/**
|
|
80
|
-
`true` if the relationship is polymorphic, `false` otherwise.
|
|
81
|
-
|
|
82
|
-
@property isPolymorphic
|
|
83
|
-
@type {Boolean}
|
|
84
|
-
@private
|
|
85
|
-
*/
|
|
86
|
-
isPolymorphic: boolean;
|
|
87
|
-
_inverseIsAsync: boolean;
|
|
88
|
-
/**
|
|
89
|
-
Metadata associated with the request for async hasMany relationships.
|
|
90
|
-
|
|
91
|
-
Example
|
|
92
|
-
|
|
93
|
-
Given that the server returns the following JSON payload when fetching a
|
|
94
|
-
hasMany relationship:
|
|
95
|
-
|
|
96
|
-
```js
|
|
97
|
-
{
|
|
98
|
-
"comments": [{
|
|
99
|
-
"id": 1,
|
|
100
|
-
"comment": "This is the first comment",
|
|
101
|
-
}, {
|
|
102
|
-
// ...
|
|
103
|
-
}],
|
|
104
|
-
|
|
105
|
-
"meta": {
|
|
106
|
-
"page": 1,
|
|
107
|
-
"total": 5
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
You can then access the meta data via the `meta` property:
|
|
113
|
-
|
|
114
|
-
```js
|
|
115
|
-
let comments = await post.comments;
|
|
116
|
-
let meta = comments.meta;
|
|
117
|
-
|
|
118
|
-
// meta.page => 1
|
|
119
|
-
// meta.total => 5
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
@property meta
|
|
123
|
-
@type {Object | null}
|
|
124
|
-
@public
|
|
125
|
-
*/
|
|
126
|
-
meta: Record<string, unknown> | null;
|
|
127
|
-
/**
|
|
128
|
-
* Retrieve the links for this relationship
|
|
129
|
-
*
|
|
130
|
-
@property links
|
|
131
|
-
@type {Object | null}
|
|
132
|
-
@public
|
|
133
|
-
*/
|
|
134
|
-
links: Links | PaginationLinks | null;
|
|
135
|
-
identifier: StableRecordIdentifier;
|
|
136
|
-
cache: Cache;
|
|
137
|
-
_manager: MinimumManager;
|
|
138
|
-
store: Store;
|
|
139
|
-
key: string;
|
|
140
|
-
type: ModelSchema;
|
|
141
|
-
modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
|
|
142
|
-
constructor(options: ManyArrayCreateArgs<T>);
|
|
66
|
+
/** @internal */
|
|
143
67
|
notify(): void;
|
|
144
68
|
/**
|
|
145
69
|
Reloads all of the records in the manyArray. If the manyArray
|
|
@@ -162,13 +86,11 @@ export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
|
|
|
162
86
|
|
|
163
87
|
@public
|
|
164
88
|
*/
|
|
165
|
-
reload(options?: BaseFinderOptions): Promise<
|
|
89
|
+
reload(options?: BaseFinderOptions): Promise<LegacyManyArray<T>>;
|
|
166
90
|
/**
|
|
167
|
-
Create a child record
|
|
91
|
+
Create a child record and associated it to the collection
|
|
168
92
|
|
|
169
93
|
@public
|
|
170
|
-
@param {Object} hash
|
|
171
|
-
@return {Model} record
|
|
172
94
|
*/
|
|
173
95
|
createRecord(hash: CreateRecordProperties<T>): T;
|
|
174
96
|
/**
|
|
@@ -178,7 +100,7 @@ export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
|
|
|
178
100
|
|
|
179
101
|
Example
|
|
180
102
|
|
|
181
|
-
```
|
|
103
|
+
```js
|
|
182
104
|
const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' }));
|
|
183
105
|
|
|
184
106
|
let messages = await inbox.messages;
|
|
@@ -189,9 +111,29 @@ export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
|
|
|
189
111
|
```
|
|
190
112
|
|
|
191
113
|
@public
|
|
192
|
-
@return {PromiseArray} promise
|
|
193
114
|
*/
|
|
194
|
-
save: () => Promise<
|
|
115
|
+
save: () => Promise<LegacyManyArray<T>>;
|
|
195
116
|
/** @internal */
|
|
196
|
-
destroy()
|
|
117
|
+
destroy: () => void;
|
|
197
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The options for {@link createLegacyManyArray}
|
|
121
|
+
*
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
export interface LegacyManyArrayCreateOptions extends LegacyLiveArrayCreateOptions {
|
|
125
|
+
isLoaded: boolean;
|
|
126
|
+
editable: boolean;
|
|
127
|
+
isAsync: boolean;
|
|
128
|
+
isPolymorphic: boolean;
|
|
129
|
+
field: LegacyHasManyField | LinksModeHasManyField;
|
|
130
|
+
identifier: ResourceKey;
|
|
131
|
+
links: Links | PaginationLinks | null;
|
|
132
|
+
meta: Meta | null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates a {@link LegacyManyArray}
|
|
136
|
+
*
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
export declare function createLegacyManyArray<T>(options: LegacyManyArrayCreateOptions): LegacyManyArray<T>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ImmutableRequestInfo } from "../../../types/request.js";
|
|
2
|
+
import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
3
|
+
import type { LegacyLiveArray, LegacyLiveArrayCreateOptions } from "./legacy-live-array.js";
|
|
4
|
+
/**
|
|
5
|
+
* QueryArrays contain the primary records returned when querying
|
|
6
|
+
* for records by `ResourceType`.
|
|
7
|
+
*
|
|
8
|
+
* ### Basic Example
|
|
9
|
+
*
|
|
10
|
+
* For instance, if an application were to have a `'user'` type:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const users = await store.query('user', { name: 'Chris' });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ---
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* ### QueryArrays are Arrays
|
|
21
|
+
*
|
|
22
|
+
* QueryArrays have all array APIs, and will report `true`
|
|
23
|
+
* for both `queryArray instanceof Array` and `Array.isArray(queryArray)`
|
|
24
|
+
*
|
|
25
|
+
* However, any mutation of the array will throw an error.
|
|
26
|
+
*
|
|
27
|
+
* ---
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
*
|
|
31
|
+
* ### Reactive
|
|
32
|
+
*
|
|
33
|
+
* If a record in a QueryArray is deleted and unloaded, it will be
|
|
34
|
+
* automatically removed from the array.
|
|
35
|
+
*
|
|
36
|
+
* ---
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* ### Immutable
|
|
41
|
+
*
|
|
42
|
+
* Records cannot be directly added to or removed from a QueryArray.
|
|
43
|
+
*
|
|
44
|
+
* ---
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* ### Polymorphism
|
|
49
|
+
*
|
|
50
|
+
* QueryArrays are not intended to be polymorphic. If your application has
|
|
51
|
+
* an abstract type "car" with concrete types "ferrari" and "bmw", a query
|
|
52
|
+
* which returns primary data containing both ferraris and bmws will *likely*
|
|
53
|
+
* work, but it is not guaranteed.
|
|
54
|
+
*
|
|
55
|
+
* In contrast, the {@link ReactiveResourceArray} returned when using {@link Store.request}
|
|
56
|
+
* is guaranteed to work with polymorphic responses.
|
|
57
|
+
*
|
|
58
|
+
* ---
|
|
59
|
+
*
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* ### Memory Leaks
|
|
63
|
+
*
|
|
64
|
+
* QueryArrays are meant to be long lived. They can be refreshed using
|
|
65
|
+
* `array.update()`, and destroyed via `array.destroy()`.
|
|
66
|
+
*
|
|
67
|
+
* Unlike most Reactive state in WarpDrive, applications must choose to call
|
|
68
|
+
* `destroy` when the `QueryArray` is no longer needed, else the array instance
|
|
69
|
+
* will be retained until either the application or the store which created it
|
|
70
|
+
* are destroyed. Destroying a QueryArray does not remove its records
|
|
71
|
+
* from the cache, but it does remove the array as well as the overhead it requires
|
|
72
|
+
* from the store for book-keeping.
|
|
73
|
+
*
|
|
74
|
+
* @legacy we recommend againt using QueryArrays. Use {@link Store.request} instead
|
|
75
|
+
*/
|
|
76
|
+
export interface LegacyQueryArray<T = unknown> extends LegacyLiveArray<T> {
|
|
77
|
+
query: ImmutableRequestInfo | Record<string, unknown> | null;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
links: PaginationLinks | Links | null;
|
|
80
|
+
meta: Meta | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The options for {@link createLegacyQueryArray}
|
|
84
|
+
*
|
|
85
|
+
* See also {@link LegacyLiveArrayCreateOptions} which
|
|
86
|
+
* this extends.
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
export interface LegacyQueryArrayCreateOptions extends LegacyLiveArrayCreateOptions {
|
|
91
|
+
query: ImmutableRequestInfo | Record<string, unknown> | null;
|
|
92
|
+
isLoaded: boolean;
|
|
93
|
+
links: PaginationLinks | Links | null;
|
|
94
|
+
meta: Meta | null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates a {@link LegacyQueryArray}
|
|
98
|
+
*
|
|
99
|
+
* Options: {@link LegacyQueryArrayCreateOptions}
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export declare function createLegacyQueryArray<T = unknown>(options: LegacyQueryArrayCreateOptions): LegacyQueryArray<T>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ExtensionDef } from "../../../reactive.js";
|
|
2
|
+
import { Context } from "../../../reactive/-private.js";
|
|
3
|
+
import type { ResourceKey, RequestKey } 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
|
+
// passed in
|
|
14
|
+
store: Store;
|
|
15
|
+
manager: MinimumManager;
|
|
16
|
+
editable: boolean;
|
|
17
|
+
source: ResourceKey[];
|
|
18
|
+
// reactive, passed in
|
|
19
|
+
data: ObjectValue | null;
|
|
20
|
+
// non-reactive, passed in
|
|
21
|
+
features: Record<string | symbol, unknown> | null;
|
|
22
|
+
extensions: Map<string | symbol, ExtensionDef> | null;
|
|
23
|
+
// not-accessible except by the context
|
|
24
|
+
options: Record<string, unknown> | null;
|
|
25
|
+
destroy: null | ((this: ReactiveResourceArray, clear: boolean) => void);
|
|
26
|
+
mutate: null | ((target: ResourceKey[], receiver: typeof NativeProxy<ResourceKey[], unknown[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal) => unknown);
|
|
27
|
+
}
|
|
28
|
+
interface ReactiveResourceArrayContext extends ReactiveResourceArrayCreateOptions {
|
|
29
|
+
destroy: (this: ReactiveResourceArray, clear: boolean) => void;
|
|
30
|
+
mutate: (target: ResourceKey[], receiver: typeof NativeProxy<ResourceKey[], unknown[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal) => unknown;
|
|
31
|
+
// generated
|
|
32
|
+
signals: SignalStore;
|
|
33
|
+
signal: WarpDriveSignal;
|
|
34
|
+
isDestroying: boolean;
|
|
35
|
+
isDestroyed: boolean;
|
|
36
|
+
transaction: boolean;
|
|
37
|
+
boundFns: Map<KeyType, ProxiedMethod>;
|
|
38
|
+
}
|
|
39
|
+
export interface ReactiveResourceArray<T = unknown> extends Omit<Array<T>, "[]"> {
|
|
40
|
+
/** @internal */
|
|
41
|
+
isDestroying: boolean;
|
|
42
|
+
/** @internal */
|
|
43
|
+
isDestroyed: boolean;
|
|
44
|
+
/** @internal */
|
|
45
|
+
destroy: (this: ReactiveResourceArray, clear: boolean) => void;
|
|
46
|
+
/** @internal */
|
|
47
|
+
[IS_COLLECTION]: boolean;
|
|
48
|
+
/** @internal */
|
|
49
|
+
[Context]: ReactiveResourceArrayContext;
|
|
50
|
+
}
|
|
51
|
+
export interface TargetArray extends Array<ResourceKey> {
|
|
52
|
+
/** @internal */
|
|
53
|
+
[Context]: ReactiveResourceArrayContext;
|
|
54
|
+
}
|
|
55
|
+
export declare function createReactiveResourceArray<T>(options: ReactiveResourceArrayCreateOptions): ReactiveResourceArray<T>;
|
|
56
|
+
export declare function destroy(this: ReactiveResourceArray, clear: boolean): void;
|
|
57
|
+
export interface ReactiveRequestCollectionCreateArgs {
|
|
58
|
+
// passed in
|
|
59
|
+
store: Store;
|
|
60
|
+
manager: MinimumManager;
|
|
61
|
+
source: ResourceKey[];
|
|
62
|
+
options: {
|
|
63
|
+
requestKey: RequestKey;
|
|
64
|
+
} | null;
|
|
65
|
+
}
|
|
66
|
+
export declare function createRequestCollection(config: ReactiveRequestCollectionCreateArgs): ReactiveResourceArray;
|
|
67
|
+
export interface ReactiveRelatedCollectionCreateArgs {
|
|
68
|
+
// passed in
|
|
69
|
+
store: Store;
|
|
70
|
+
manager: MinimumManager;
|
|
71
|
+
source: ResourceKey[];
|
|
72
|
+
// not-accessible except by the context
|
|
73
|
+
options: {
|
|
74
|
+
resourceKey: ResourceKey;
|
|
75
|
+
path: string[];
|
|
76
|
+
field: CollectionField;
|
|
77
|
+
};
|
|
78
|
+
editable: boolean;
|
|
79
|
+
extensions: Map<string | symbol, ExtensionDef> | null;
|
|
80
|
+
}
|
|
81
|
+
export declare function createRelatedCollection(config: ReactiveRelatedCollectionCreateArgs): ReactiveResourceArray;
|
|
82
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import type { Graph } from "../../graph/-private.js";
|
|
|
2
2
|
import type { Future } from "../../request.js";
|
|
3
3
|
import type { 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,12 +11,12 @@ 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 { CacheKeyManager } from "./managers/cache-key-manager.js";
|
|
16
16
|
import NotificationManager from "./managers/notification-manager.js";
|
|
17
17
|
import { RecordArrayManager } from "./managers/record-array-manager.js";
|
|
18
18
|
import { RequestStateService } from "./network/request-cache.js";
|
|
19
|
-
import type {
|
|
19
|
+
import type { LegacyLiveArray } from "./record-arrays/legacy-live-array.js";
|
|
20
20
|
export { storeFor };
|
|
21
21
|
// We inline this list of methods to avoid importing EmberObject
|
|
22
22
|
type EmberObjectKey = "_debugContainerKey" | "_super" | "addObserver" | "cacheFor" | "concatenatedProperties" | "decrementProperty" | "destroy" | "get" | "getProperties" | "incrementProperty" | "init" | "isDestroyed" | "isDestroying" | "mergedProperties" | "notifyPropertyChange" | "removeObserver" | "reopen" | "set" | "setProperties" | "toggleProperty" | "toString" | "willDestroy";
|
|
@@ -79,7 +79,7 @@ export interface Store {
|
|
|
79
79
|
* @public
|
|
80
80
|
*/
|
|
81
81
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
82
|
-
instantiateRecord<T>(identifier:
|
|
82
|
+
instantiateRecord<T>(identifier: ResourceKey, createRecordArgs: {
|
|
83
83
|
[key: string]: unknown;
|
|
84
84
|
}): OpaqueRecordInstance;
|
|
85
85
|
/**
|
|
@@ -193,11 +193,11 @@ export interface Store {
|
|
|
193
193
|
* return this._schema.hasResource(resource);
|
|
194
194
|
* }
|
|
195
195
|
*
|
|
196
|
-
* attributesDefinitionFor(identifier:
|
|
196
|
+
* attributesDefinitionFor(identifier: ResourceKey | { type: string }): AttributesSchema {
|
|
197
197
|
* return this._schema.attributesDefinitionFor(identifier);
|
|
198
198
|
* }
|
|
199
199
|
*
|
|
200
|
-
* relationshipsDefinitionFor(identifier:
|
|
200
|
+
* relationshipsDefinitionFor(identifier: ResourceKey | { type: string }): RelationshipsSchema {
|
|
201
201
|
* const schema = AbstractSchemas.get(identifier.type);
|
|
202
202
|
* return schema || this._schema.relationshipsDefinitionFor(identifier);
|
|
203
203
|
* }
|
|
@@ -247,11 +247,11 @@ export interface Store {
|
|
|
247
247
|
* return this._schema.hasResource(resource);
|
|
248
248
|
* }
|
|
249
249
|
*
|
|
250
|
-
* attributesDefinitionFor(identifier:
|
|
250
|
+
* attributesDefinitionFor(identifier: ResourceKey | { type: string }): AttributesSchema {
|
|
251
251
|
* return this._schema.attributesDefinitionFor(identifier);
|
|
252
252
|
* }
|
|
253
253
|
*
|
|
254
|
-
* relationshipsDefinitionFor(identifier:
|
|
254
|
+
* relationshipsDefinitionFor(identifier: ResourceKey | { type: string }): RelationshipsSchema {
|
|
255
255
|
* const schema = AbstractSchemas.get(identifier.type);
|
|
256
256
|
* return schema || this._schema.relationshipsDefinitionFor(identifier);
|
|
257
257
|
* }
|
|
@@ -317,15 +317,16 @@ export declare class Store extends BaseClass {
|
|
|
317
317
|
/** @internal */
|
|
318
318
|
_schema: SchemaService;
|
|
319
319
|
/**
|
|
320
|
-
* Provides access to the
|
|
320
|
+
* Provides access to the CacheKeyManager
|
|
321
321
|
* for this store.
|
|
322
322
|
*
|
|
323
|
-
* The
|
|
324
|
-
* retrieve a stable unique
|
|
323
|
+
* The CacheKeyManager can be used to generate or
|
|
324
|
+
* retrieve a stable unique CacheKey for any resource
|
|
325
|
+
* or request.
|
|
325
326
|
*
|
|
326
327
|
* @public
|
|
327
328
|
*/
|
|
328
|
-
readonly
|
|
329
|
+
readonly cacheKeyManager: CacheKeyManager;
|
|
329
330
|
/**
|
|
330
331
|
* Provides access to the requestManager instance associated
|
|
331
332
|
* with this Store instance.
|
|
@@ -356,7 +357,7 @@ export declare class Store extends BaseClass {
|
|
|
356
357
|
*
|
|
357
358
|
* Note, when defined, these methods will only be invoked if a
|
|
358
359
|
* cache key exists for the request, either because the request
|
|
359
|
-
* contains `cacheOptions.key` or because the [
|
|
360
|
+
* contains `cacheOptions.key` or because the [CacheKeyManager](/ember-data/release/classes/CacheKeyManager)
|
|
360
361
|
* was able to generate a key for the request using the configured
|
|
361
362
|
* [generation method](/ember-data/release/functions/@ember-data%2Fstore/setIdentifierGenerationMethod).
|
|
362
363
|
*
|
|
@@ -365,12 +366,12 @@ export declare class Store extends BaseClass {
|
|
|
365
366
|
* ```ts
|
|
366
367
|
* store.lifetimes = {
|
|
367
368
|
* // make the request and ignore the current cache state
|
|
368
|
-
* isHardExpired(
|
|
369
|
+
* isHardExpired(key: RequestKey): boolean {
|
|
369
370
|
* return false;
|
|
370
371
|
* }
|
|
371
372
|
*
|
|
372
373
|
* // make the request in the background if true, return cache state
|
|
373
|
-
* isSoftExpired(
|
|
374
|
+
* isSoftExpired(key: RequestKey): boolean {
|
|
374
375
|
* return false;
|
|
375
376
|
* }
|
|
376
377
|
* }
|
|
@@ -420,6 +421,8 @@ export declare class Store extends BaseClass {
|
|
|
420
421
|
get isDestroyed(): boolean;
|
|
421
422
|
/** @internal */
|
|
422
423
|
set isDestroyed(value: boolean);
|
|
424
|
+
/** @deprecated use {@link Store.cacheKeyManager} */
|
|
425
|
+
get identifierCache(): CacheKeyManager;
|
|
423
426
|
/**
|
|
424
427
|
@private
|
|
425
428
|
*/
|
|
@@ -687,8 +690,8 @@ export declare class Store extends BaseClass {
|
|
|
687
690
|
@param {String} type the name of the resource
|
|
688
691
|
@return {RecordArray}
|
|
689
692
|
*/
|
|
690
|
-
peekAll<T>(type: TypeFromInstance<T>):
|
|
691
|
-
peekAll(type: string):
|
|
693
|
+
peekAll<T>(type: TypeFromInstance<T>): LegacyLiveArray<T>;
|
|
694
|
+
peekAll(type: string): LegacyLiveArray;
|
|
692
695
|
/**
|
|
693
696
|
This method unloads all records in the store.
|
|
694
697
|
It schedules unloading to happen during the next run loop.
|
|
@@ -866,9 +869,9 @@ export declare class Store extends BaseClass {
|
|
|
866
869
|
|
|
867
870
|
@private
|
|
868
871
|
@param {Object} jsonApiDoc
|
|
869
|
-
@return {
|
|
872
|
+
@return {ResourceKey|Array<ResourceKey>|null} identifiers for the primary records that had data loaded
|
|
870
873
|
*/
|
|
871
|
-
_push(jsonApiDoc: JsonApiDocument, asyncFlush?: boolean):
|
|
874
|
+
_push(jsonApiDoc: JsonApiDocument, asyncFlush?: boolean): PersistedResourceKey | PersistedResourceKey[] | null;
|
|
872
875
|
/**
|
|
873
876
|
* Returns the cache instance associated to this Store, instantiates the Cache
|
|
874
877
|
* if necessary via `Store.createCache`
|
|
@@ -3,7 +3,7 @@ export { storeFor } from "./-private/store-service.js";
|
|
|
3
3
|
export { recordIdentifierFor } from "./-private/caches/instance-cache.js";
|
|
4
4
|
export { CacheHandler, type StoreRequestContext } from "./-private/cache-handler/handler.js";
|
|
5
5
|
export { type CachePolicy } from "./-private/cache-handler/types.js";
|
|
6
|
-
export {
|
|
6
|
+
export { isResourceKey, isRequestKey } from "./-private/managers/cache-key-manager.js";
|
|
7
7
|
export { constructResource } from "./-private/utils/construct-resource.js";
|
|
8
8
|
export type { InstanceCache } from "./-private/caches/instance-cache.js";
|
|
9
9
|
export type { FindRecordQuery, Request, SaveRecordMutation, RequestCacheRequestState, RequestStateService } from "./-private/network/request-cache.js";
|
|
@@ -12,7 +12,9 @@ export type { CreateRecordProperties } from "./-private/store-service.js";
|
|
|
12
12
|
// to also eliminate
|
|
13
13
|
export { coerceId, ensureStringId } from "./-private/utils/coerce-id.js";
|
|
14
14
|
export type { NativeProxy } from "./-private/record-arrays/native-proxy-type-fix.js";
|
|
15
|
-
export {
|
|
15
|
+
export { type ReactiveResourceArray } from "./-private/record-arrays/resource-array.js";
|
|
16
|
+
export { type LegacyLiveArray, type LegacyLiveArray as LiveArray } from "./-private/record-arrays/legacy-live-array.js";
|
|
17
|
+
export { type LegacyQueryArray, type LegacyQueryArray as CollectionRecordArray } from "./-private/record-arrays/legacy-query.js";
|
|
16
18
|
export { RecordArrayManager, fastPush } from "./-private/managers/record-array-manager.js";
|
|
17
19
|
// leaked for private use / test use, should investigate removing
|
|
18
20
|
export { _clearCaches } from "./-private/caches/instance-cache.js";
|
|
@@ -20,7 +22,7 @@ export { _clearCaches } from "./-private/caches/instance-cache.js";
|
|
|
20
22
|
export { setRecordIdentifier, StoreMap } from "./-private/caches/instance-cache.js";
|
|
21
23
|
export { normalizeModelName as _deprecatingNormalize } from "./-private/utils/normalize-model-name.js";
|
|
22
24
|
export type { StoreRequestInput } from "./-private/cache-handler/handler.js";
|
|
23
|
-
export { RelatedCollection } from "./-private/record-arrays/many-array.js";
|
|
25
|
+
export { type LegacyManyArray, type LegacyManyArray as RelatedCollection, createLegacyManyArray } from "./-private/record-arrays/legacy-many-array.js";
|
|
24
26
|
export { log, logGroup } from "./-private/debug/utils.js";
|
|
25
27
|
export { getPromiseState, type PromiseState } from "./-private/new-core-tmp/promise-state.js";
|
|
26
28
|
export { DISPOSE, createRequestSubscription, type SubscriptionArgs, type RequestSubscription } from "./-private/new-core-tmp/request-subscription.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ResourceKey, RequestKey } from "../../../types/identifier.js";
|
|
2
|
+
import type { CacheKeyManager } from "../../-private/managers/cache-key-manager.js";
|
|
3
3
|
import type { NotificationType } from "../../-private/managers/notification-manager.js";
|
|
4
4
|
import type { SchemaService } from "./schema-service.js";
|
|
5
5
|
/**
|
|
@@ -11,22 +11,21 @@ import type { SchemaService } from "./schema-service.js";
|
|
|
11
11
|
*
|
|
12
12
|
* This class cannot be directly instantiated.
|
|
13
13
|
*
|
|
14
|
-
* @class CacheCapabilitiesManager
|
|
15
14
|
* @public
|
|
16
15
|
*/
|
|
17
16
|
export type CacheCapabilitiesManager = {
|
|
18
17
|
/**
|
|
19
|
-
* Provides access to the
|
|
18
|
+
* Provides access to the CacheKeyManager instance
|
|
20
19
|
* for this Store instance.
|
|
21
20
|
*
|
|
22
|
-
* The
|
|
21
|
+
* The CacheKeyManager can be used to peek, generate or
|
|
23
22
|
* retrieve a stable unique identifier for any resource.
|
|
24
23
|
*
|
|
25
|
-
* @property identifierCache
|
|
26
|
-
* @type {IdentifierCache}
|
|
27
24
|
* @public
|
|
28
25
|
*/
|
|
29
|
-
|
|
26
|
+
cacheKeyManager: CacheKeyManager;
|
|
27
|
+
/** @deprecated use {@link CacheCapabilitiesManager.cacheKeyManager} */
|
|
28
|
+
identifierCache: CacheKeyManager;
|
|
30
29
|
/**
|
|
31
30
|
* DEPRECATED - use the schema property
|
|
32
31
|
*
|
|
@@ -36,7 +35,7 @@ export type CacheCapabilitiesManager = {
|
|
|
36
35
|
* The SchemaService can be used to query for
|
|
37
36
|
* information about the schema of a resource.
|
|
38
37
|
*
|
|
39
|
-
* @deprecated
|
|
38
|
+
* @deprecated use {@link CacheCapabilitiesManager.schema}
|
|
40
39
|
* @public
|
|
41
40
|
*/
|
|
42
41
|
getSchemaDefinitionService(): SchemaService;
|
|
@@ -55,30 +54,25 @@ export type CacheCapabilitiesManager = {
|
|
|
55
54
|
* Update the `id` for the record corresponding to the identifier
|
|
56
55
|
* This operation can only be done for records whose `id` is `null`.
|
|
57
56
|
*
|
|
58
|
-
* @param {StableRecordIdentifier} identifier;
|
|
59
|
-
* @param {String} id;
|
|
60
57
|
* @public
|
|
61
58
|
*/
|
|
62
|
-
setRecordId(identifier:
|
|
59
|
+
setRecordId(identifier: ResourceKey, id: string): void;
|
|
63
60
|
/**
|
|
64
61
|
* Signal to the store that the specified record may be considered fully
|
|
65
62
|
* removed from the cache. Generally this means that not only does no
|
|
66
63
|
* data exist for the identified resource, no known relationships still
|
|
67
64
|
* point to it either.
|
|
68
65
|
*
|
|
69
|
-
* @param {StableRecordIdentifier} identifier
|
|
70
66
|
* @public
|
|
71
67
|
*/
|
|
72
|
-
disconnectRecord(identifier:
|
|
68
|
+
disconnectRecord(identifier: ResourceKey): void;
|
|
73
69
|
/**
|
|
74
70
|
* Use this method to determine if the Store has an instantiated record associated
|
|
75
71
|
* with an identifier.
|
|
76
72
|
*
|
|
77
|
-
* @param identifier
|
|
78
|
-
* @return {Boolean}
|
|
79
73
|
* @public
|
|
80
74
|
*/
|
|
81
|
-
hasRecord(identifier:
|
|
75
|
+
hasRecord(identifier: ResourceKey): boolean;
|
|
82
76
|
/**
|
|
83
77
|
* Notify subscribers of the NotificationManager that cache state has changed.
|
|
84
78
|
*
|
|
@@ -87,13 +81,10 @@ export type CacheCapabilitiesManager = {
|
|
|
87
81
|
*
|
|
88
82
|
* No other namespaces currently expect the `key` argument.
|
|
89
83
|
*
|
|
90
|
-
* @param {StableRecordIdentifier} identifier
|
|
91
|
-
* @param {'attributes' | 'relationships' | 'identity' | 'errors' | 'meta' | 'state'} namespace
|
|
92
|
-
* @param {string|undefined} key
|
|
93
84
|
* @public
|
|
94
85
|
*/
|
|
95
|
-
notifyChange(identifier:
|
|
96
|
-
notifyChange(identifier:
|
|
97
|
-
notifyChange(identifier:
|
|
98
|
-
notifyChange(identifier:
|
|
86
|
+
notifyChange(identifier: ResourceKey, namespace: "added" | "removed", key: null): void;
|
|
87
|
+
notifyChange(identifier: RequestKey, namespace: "added" | "updated" | "removed", key: null): void;
|
|
88
|
+
notifyChange(identifier: ResourceKey, namespace: NotificationType, key: string | null): void;
|
|
89
|
+
notifyChange(identifier: ResourceKey | RequestKey, namespace: NotificationType | "added" | "removed" | "updated", key: string | null): void;
|
|
99
90
|
};
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CacheKeyType, ResourceKey, RequestKey } from "../../../types/identifier.js";
|
|
2
2
|
import type { ImmutableRequestInfo } from "../../../types/request.js";
|
|
3
3
|
export interface GenerationMethod {
|
|
4
4
|
(data: ImmutableRequestInfo, bucket: "document"): string | null;
|
|
5
5
|
(data: unknown | {
|
|
6
6
|
type: string;
|
|
7
7
|
}, bucket: "record"): string;
|
|
8
|
-
(data: unknown, bucket:
|
|
8
|
+
(data: unknown, bucket: CacheKeyType): string | null;
|
|
9
9
|
}
|
|
10
10
|
export type UpdateMethod = {
|
|
11
|
-
(identifier:
|
|
12
|
-
(identifier:
|
|
11
|
+
(identifier: ResourceKey, newData: unknown, bucket: "record"): void;
|
|
12
|
+
(identifier: RequestKey, newData: unknown, bucket: "document"): void;
|
|
13
|
+
(identifier: {
|
|
14
|
+
lid: string;
|
|
15
|
+
}, newData: unknown, bucket: never): void;
|
|
13
16
|
};
|
|
14
|
-
export type ForgetMethod = (identifier:
|
|
17
|
+
export type ForgetMethod = (identifier: RequestKey | ResourceKey, bucket: CacheKeyType) => void;
|
|
15
18
|
export type ResetMethod = () => void;
|
|
16
19
|
export type KeyInfo = {
|
|
17
20
|
id: string | null;
|
|
18
21
|
type: string;
|
|
19
22
|
};
|
|
20
|
-
export type KeyInfoMethod = (resource: unknown, known:
|
|
23
|
+
export type KeyInfoMethod = (resource: unknown, known: ResourceKey | null) => KeyInfo;
|