@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,159 +0,0 @@
|
|
|
1
|
-
import type { StableRecordIdentifier } from "../../../types/identifier.js";
|
|
2
|
-
import type { SingleResourceDocument } from "../../../types/spec/json-api-raw.js";
|
|
3
|
-
import type { OpaqueRecordInstance } from "../../-types/q/record-instance.js";
|
|
4
|
-
import type { Store } from "../store-service.js";
|
|
5
|
-
/**
|
|
6
|
-
A `RecordReference` is a low-level API that allows users and
|
|
7
|
-
addon authors to perform meta-operations on a record.
|
|
8
|
-
|
|
9
|
-
@hideconstructor
|
|
10
|
-
@public
|
|
11
|
-
*/
|
|
12
|
-
export default class RecordReference {
|
|
13
|
-
private store;
|
|
14
|
-
// unsubscribe token given to us by the notification manager
|
|
15
|
-
private ___token;
|
|
16
|
-
private ___identifier;
|
|
17
|
-
private _ref;
|
|
18
|
-
constructor(store: Store, identifier: StableRecordIdentifier);
|
|
19
|
-
/** @internal */
|
|
20
|
-
destroy(): void;
|
|
21
|
-
get type(): string;
|
|
22
|
-
/**
|
|
23
|
-
The `id` of the record that this reference refers to.
|
|
24
|
-
|
|
25
|
-
Together, the `type` and `id` properties form a composite key for
|
|
26
|
-
the identity map.
|
|
27
|
-
|
|
28
|
-
Example
|
|
29
|
-
|
|
30
|
-
```javascript
|
|
31
|
-
let userRef = store.getReference('user', 1);
|
|
32
|
-
|
|
33
|
-
userRef.id(); // '1'
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
@public
|
|
37
|
-
*/
|
|
38
|
-
id(): string | null;
|
|
39
|
-
/**
|
|
40
|
-
The `identifier` of the record that this reference refers to.
|
|
41
|
-
|
|
42
|
-
Together, the `type` and `id` properties form a composite key for
|
|
43
|
-
the identity map.
|
|
44
|
-
|
|
45
|
-
Example
|
|
46
|
-
|
|
47
|
-
```javascript
|
|
48
|
-
let userRef = store.getReference('user', 1);
|
|
49
|
-
|
|
50
|
-
userRef.identifier(); // '1'
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
@public
|
|
54
|
-
*/
|
|
55
|
-
identifier(): StableRecordIdentifier;
|
|
56
|
-
/**
|
|
57
|
-
How the reference will be looked up when it is loaded. Currently
|
|
58
|
-
this always returns `identity` to signify that a record will be
|
|
59
|
-
loaded by its `type` and `id`.
|
|
60
|
-
|
|
61
|
-
Example
|
|
62
|
-
|
|
63
|
-
```javascript
|
|
64
|
-
const userRef = store.getReference('user', 1);
|
|
65
|
-
|
|
66
|
-
userRef.remoteType(); // 'identity'
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
@public
|
|
70
|
-
*/
|
|
71
|
-
remoteType(): "identity";
|
|
72
|
-
/**
|
|
73
|
-
This API allows you to provide a reference with new data. The
|
|
74
|
-
simplest usage of this API is similar to `store.push`: you provide a
|
|
75
|
-
normalized hash of data and the object represented by the reference
|
|
76
|
-
will update.
|
|
77
|
-
|
|
78
|
-
If you pass a promise to `push`, Ember Data will not ask the adapter
|
|
79
|
-
for the data if another attempt to fetch it is made in the
|
|
80
|
-
interim. When the promise resolves, the underlying object is updated
|
|
81
|
-
with the new data, and the promise returned by *this function* is resolved
|
|
82
|
-
with that object.
|
|
83
|
-
|
|
84
|
-
For example, `recordReference.push(promise)` will be resolved with a
|
|
85
|
-
record.
|
|
86
|
-
|
|
87
|
-
Example
|
|
88
|
-
|
|
89
|
-
```javascript
|
|
90
|
-
let userRef = store.getReference('user', 1);
|
|
91
|
-
|
|
92
|
-
// provide data for reference
|
|
93
|
-
userRef.push({
|
|
94
|
-
data: {
|
|
95
|
-
id: "1",
|
|
96
|
-
type: "user",
|
|
97
|
-
attributes: {
|
|
98
|
-
username: "@user"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}).then(function(user) {
|
|
102
|
-
userRef.value() === user;
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
@public
|
|
107
|
-
@param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
|
|
108
|
-
@return a promise for the value (record or relationship)
|
|
109
|
-
*/
|
|
110
|
-
push(objectOrPromise: SingleResourceDocument | Promise<SingleResourceDocument>): Promise<OpaqueRecordInstance>;
|
|
111
|
-
/**
|
|
112
|
-
If the entity referred to by the reference is already loaded, it is
|
|
113
|
-
present as `reference.value`. Otherwise the value returned by this function
|
|
114
|
-
is `null`.
|
|
115
|
-
|
|
116
|
-
Example
|
|
117
|
-
|
|
118
|
-
```javascript
|
|
119
|
-
let userRef = store.getReference('user', 1);
|
|
120
|
-
|
|
121
|
-
userRef.value(); // user
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
@public
|
|
125
|
-
*/
|
|
126
|
-
value(): OpaqueRecordInstance | null;
|
|
127
|
-
/**
|
|
128
|
-
Triggers a fetch for the backing entity based on its `remoteType`
|
|
129
|
-
(see `remoteType` definitions per reference type).
|
|
130
|
-
|
|
131
|
-
Example
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
let userRef = store.getReference('user', 1);
|
|
135
|
-
|
|
136
|
-
// load user (via store.find)
|
|
137
|
-
userRef.load().then(...)
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
@public
|
|
141
|
-
*/
|
|
142
|
-
load(): Promise<OpaqueRecordInstance>;
|
|
143
|
-
/**
|
|
144
|
-
Reloads the record if it is already loaded. If the record is not
|
|
145
|
-
loaded it will load the record via `store.findRecord`
|
|
146
|
-
|
|
147
|
-
Example
|
|
148
|
-
|
|
149
|
-
```javascript
|
|
150
|
-
let userRef = store.getReference('user', 1);
|
|
151
|
-
|
|
152
|
-
// or trigger a reload
|
|
153
|
-
userRef.reload().then(...)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
@public
|
|
157
|
-
*/
|
|
158
|
-
reload(): Promise<OpaqueRecordInstance>;
|
|
159
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
|
|
2
|
-
import type { LegacyAttributeField, LegacyRelationshipField } from "../../../types/schema/fields.js";
|
|
3
|
-
import type { KeyOrString, ModelSchema } from "../../-types/q/ds-model.js";
|
|
4
|
-
import type { Store } from "../store-service.js";
|
|
5
|
-
export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
|
|
6
|
-
// Mimics the static apis of @ember-data/model
|
|
7
|
-
export default class ShimModelClass<T = unknown> implements ModelSchema<T> {
|
|
8
|
-
private __store;
|
|
9
|
-
modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
|
|
10
|
-
constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string);
|
|
11
|
-
get fields(): Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
|
|
12
|
-
get attributes(): Map<KeyOrString<T>, LegacyAttributeField>;
|
|
13
|
-
get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField>;
|
|
14
|
-
eachAttribute<K extends KeyOrString<T>>(callback: (key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
|
|
15
|
-
eachRelationship<K extends KeyOrString<T>>(callback: (key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
|
|
16
|
-
eachTransformedAttribute<K extends KeyOrString<T>>(callback: (key: K, type: string | null) => void, binding?: T): void;
|
|
17
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import type { BaseFinderOptions } from "../../../types.js";
|
|
2
|
-
import type { LocalRelationshipOperation } from "../../../types/graph.js";
|
|
3
|
-
import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
|
|
4
|
-
import type { TypeFromInstanceOrString } from "../../../types/record.js";
|
|
5
|
-
import type { ImmutableRequestInfo } from "../../../types/request.js";
|
|
6
|
-
import type { LegacyHasManyField, LinksModeHasManyField } from "../../../types/schema/fields.js";
|
|
7
|
-
import type { Links, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
8
|
-
import type { RecordArrayManager } from "../managers/record-array-manager.js";
|
|
9
|
-
import type { WarpDriveSignal } from "../new-core-tmp/reactivity/internal.js";
|
|
10
|
-
import { ARRAY_SIGNAL } from "../new-core-tmp/reactivity/internal.js";
|
|
11
|
-
import type { Store } from "../store-service.js";
|
|
12
|
-
import { NativeProxy } from "./native-proxy-type-fix.js";
|
|
13
|
-
export declare const SOURCE: "___(unique) Symbol(#source)";
|
|
14
|
-
export declare const MUTATE: "___(unique) Symbol(#update)";
|
|
15
|
-
declare const IS_COLLECTION: "___(unique) Symbol(IS_COLLECTION)";
|
|
16
|
-
export type IdentifierArrayCreateOptions<T = unknown> = {
|
|
17
|
-
identifiers: StableRecordIdentifier<TypeFromInstanceOrString<T>>[];
|
|
18
|
-
type?: TypeFromInstanceOrString<T>;
|
|
19
|
-
store: Store;
|
|
20
|
-
allowMutation: boolean;
|
|
21
|
-
manager: MinimumManager;
|
|
22
|
-
field?: LegacyHasManyField | LinksModeHasManyField;
|
|
23
|
-
links?: Links | PaginationLinks | null;
|
|
24
|
-
meta?: Record<string, unknown> | null;
|
|
25
|
-
identifier?: StableDocumentIdentifier | null;
|
|
26
|
-
[MUTATE]?(target: StableRecordIdentifier[], receiver: typeof NativeProxy<StableRecordIdentifier[], T[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal): unknown;
|
|
27
|
-
};
|
|
28
|
-
type PromiseTo<T> = Omit<Promise<T>, typeof Symbol.toStringTag>;
|
|
29
|
-
type PromiseManyArray<T> = {
|
|
30
|
-
length: number;
|
|
31
|
-
content: IdentifierArray<T> | null;
|
|
32
|
-
promise: Promise<IdentifierArray<T>> | null;
|
|
33
|
-
} & PromiseTo<IdentifierArray<T>>;
|
|
34
|
-
export type MinimumManager = {
|
|
35
|
-
_syncArray: (array: IdentifierArray) => void;
|
|
36
|
-
mutate?(mutation: LocalRelationshipOperation): void;
|
|
37
|
-
reloadHasMany?<T>(key: string, options?: BaseFinderOptions): Promise<IdentifierArray<T>> | PromiseManyArray<T>;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
A record array is an array that contains records of a certain type (or modelName).
|
|
41
|
-
The record array materializes records as needed when they are retrieved for the first
|
|
42
|
-
time. You should not create record arrays yourself. Instead, an instance of
|
|
43
|
-
`RecordArray` or its subclasses will be returned by your application's store
|
|
44
|
-
in response to queries.
|
|
45
|
-
|
|
46
|
-
This class should not be imported and instantiated by consuming applications.
|
|
47
|
-
|
|
48
|
-
@class RecordArray
|
|
49
|
-
@public
|
|
50
|
-
*/
|
|
51
|
-
export interface IdentifierArray<T = unknown> extends Omit<Array<T>, "[]"> {
|
|
52
|
-
[IS_COLLECTION]: boolean;
|
|
53
|
-
[ARRAY_SIGNAL]: WarpDriveSignal;
|
|
54
|
-
[SOURCE]: StableRecordIdentifier[];
|
|
55
|
-
}
|
|
56
|
-
export declare class IdentifierArray<T = unknown> {
|
|
57
|
-
DEPRECATED_CLASS_NAME: string;
|
|
58
|
-
/**
|
|
59
|
-
The flag to signal a `RecordArray` is currently loading data.
|
|
60
|
-
Example
|
|
61
|
-
```javascript
|
|
62
|
-
let people = store.peekAll('person');
|
|
63
|
-
people.isUpdating; // false
|
|
64
|
-
people.update();
|
|
65
|
-
people.isUpdating; // true
|
|
66
|
-
```
|
|
67
|
-
@property isUpdating
|
|
68
|
-
@public
|
|
69
|
-
@type Boolean
|
|
70
|
-
*/
|
|
71
|
-
isUpdating: boolean;
|
|
72
|
-
isLoaded: boolean;
|
|
73
|
-
isDestroying: boolean;
|
|
74
|
-
isDestroyed: boolean;
|
|
75
|
-
_updatingPromise: Promise<IdentifierArray<T>> | null;
|
|
76
|
-
readonly identifier: StableDocumentIdentifier | null;
|
|
77
|
-
links: Links | PaginationLinks | null;
|
|
78
|
-
meta: Record<string, unknown> | null;
|
|
79
|
-
modelName?: TypeFromInstanceOrString<T>;
|
|
80
|
-
/**
|
|
81
|
-
The store that created this record array.
|
|
82
|
-
|
|
83
|
-
@property store
|
|
84
|
-
@private
|
|
85
|
-
@type Store
|
|
86
|
-
*/
|
|
87
|
-
store: Store;
|
|
88
|
-
_manager: MinimumManager;
|
|
89
|
-
destroy(clear: boolean): void;
|
|
90
|
-
constructor(options: IdentifierArrayCreateOptions<T>);
|
|
91
|
-
/**
|
|
92
|
-
Used to get the latest version of all of the records in this array
|
|
93
|
-
from the adapter.
|
|
94
|
-
|
|
95
|
-
Example
|
|
96
|
-
|
|
97
|
-
```javascript
|
|
98
|
-
let people = store.peekAll('person');
|
|
99
|
-
people.isUpdating; // false
|
|
100
|
-
|
|
101
|
-
people.update().then(function() {
|
|
102
|
-
people.isUpdating; // false
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
people.isUpdating; // true
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
@public
|
|
109
|
-
*/
|
|
110
|
-
update(): Promise<IdentifierArray<T>>;
|
|
111
|
-
/*
|
|
112
|
-
Update this Array and return a promise which resolves once the update
|
|
113
|
-
is finished.
|
|
114
|
-
*/
|
|
115
|
-
_update(): Promise<IdentifierArray<T>>;
|
|
116
|
-
// TODO deprecate
|
|
117
|
-
/**
|
|
118
|
-
Saves all of the records in the `RecordArray`.
|
|
119
|
-
|
|
120
|
-
Example
|
|
121
|
-
|
|
122
|
-
```javascript
|
|
123
|
-
let messages = store.peekAll('message');
|
|
124
|
-
messages.forEach(function(message) {
|
|
125
|
-
message.hasBeenSeen = true;
|
|
126
|
-
});
|
|
127
|
-
messages.save();
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
@public
|
|
131
|
-
@return {Promise<IdentifierArray>} promise
|
|
132
|
-
*/
|
|
133
|
-
save(): Promise<IdentifierArray>;
|
|
134
|
-
}
|
|
135
|
-
export type CollectionCreateOptions = IdentifierArrayCreateOptions & {
|
|
136
|
-
manager: RecordArrayManager;
|
|
137
|
-
query: ImmutableRequestInfo | Record<string, unknown> | null;
|
|
138
|
-
isLoaded: boolean;
|
|
139
|
-
};
|
|
140
|
-
export declare class Collection<T = unknown> extends IdentifierArray<T> {
|
|
141
|
-
query: ImmutableRequestInfo | Record<string, unknown> | null;
|
|
142
|
-
_manager: RecordArrayManager;
|
|
143
|
-
constructor(options: CollectionCreateOptions);
|
|
144
|
-
_update(): Promise<Collection<T>>;
|
|
145
|
-
destroy(clear: boolean): void;
|
|
146
|
-
}
|
|
147
|
-
export {};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import type { BaseFinderOptions, ModelSchema, StableRecordIdentifier } from "../../../types.js";
|
|
2
|
-
import type { Cache } from "../../../types/cache.js";
|
|
3
|
-
import type { TypedRecordInstance, TypeFromInstance, TypeFromInstanceOrString } from "../../../types/record.js";
|
|
4
|
-
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, Store } from "../store-service.js";
|
|
7
|
-
import type { MinimumManager } from "./identifier-array.js";
|
|
8
|
-
import { IdentifierArray } from "./identifier-array.js";
|
|
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
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
28
|
-
relationship.
|
|
29
|
-
|
|
30
|
-
The `ManyArray` is instantiated lazily the first time the relationship is
|
|
31
|
-
requested.
|
|
32
|
-
|
|
33
|
-
This class is not intended to be directly instantiated by consuming applications.
|
|
34
|
-
|
|
35
|
-
### Inverses
|
|
36
|
-
|
|
37
|
-
Often, the relationships in Ember Data applications will have
|
|
38
|
-
an inverse. For example, imagine the following models are
|
|
39
|
-
defined:
|
|
40
|
-
|
|
41
|
-
```js [app/models/post.js]
|
|
42
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
43
|
-
|
|
44
|
-
export default class PostModel extends Model {
|
|
45
|
-
@hasMany('comment') comments;
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
```js [app/models/comment.js]
|
|
50
|
-
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
51
|
-
|
|
52
|
-
export default class CommentModel extends Model {
|
|
53
|
-
@belongsTo('post') post;
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
If you created a new instance of `Post` and added
|
|
58
|
-
a `Comment` record to its `comments` has-many
|
|
59
|
-
relationship, you would expect the comment's `post`
|
|
60
|
-
property to be set to the post that contained
|
|
61
|
-
the has-many.
|
|
62
|
-
|
|
63
|
-
We call the record to which a relationship belongs-to the
|
|
64
|
-
relationship's _owner_.
|
|
65
|
-
|
|
66
|
-
@class ManyArray
|
|
67
|
-
@public
|
|
68
|
-
*/
|
|
69
|
-
export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
|
|
70
|
-
isAsync: boolean;
|
|
71
|
-
/**
|
|
72
|
-
The loading state of this array
|
|
73
|
-
|
|
74
|
-
@property isLoaded
|
|
75
|
-
@type {Boolean}
|
|
76
|
-
@public
|
|
77
|
-
*/
|
|
78
|
-
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>);
|
|
143
|
-
notify(): void;
|
|
144
|
-
/**
|
|
145
|
-
Reloads all of the records in the manyArray. If the manyArray
|
|
146
|
-
holds a relationship that was originally fetched using a links url
|
|
147
|
-
WarpDrive will revisit the original links url to repopulate the
|
|
148
|
-
relationship.
|
|
149
|
-
|
|
150
|
-
If the ManyArray holds the result of a `store.query()` reload will
|
|
151
|
-
re-run the original query.
|
|
152
|
-
|
|
153
|
-
Example
|
|
154
|
-
|
|
155
|
-
```javascript
|
|
156
|
-
let user = store.peekRecord('user', '1')
|
|
157
|
-
await login(user);
|
|
158
|
-
|
|
159
|
-
let permissions = await user.permissions;
|
|
160
|
-
await permissions.reload();
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
@public
|
|
164
|
-
*/
|
|
165
|
-
reload(options?: BaseFinderOptions): Promise<this>;
|
|
166
|
-
/**
|
|
167
|
-
Create a child record within the owner
|
|
168
|
-
|
|
169
|
-
@public
|
|
170
|
-
@param {Object} hash
|
|
171
|
-
@return {Model} record
|
|
172
|
-
*/
|
|
173
|
-
createRecord(hash: CreateRecordProperties<T>): T;
|
|
174
|
-
/**
|
|
175
|
-
Saves all of the records in the `ManyArray`.
|
|
176
|
-
|
|
177
|
-
Note: this API can only be used in legacy mode with a configured Adapter.
|
|
178
|
-
|
|
179
|
-
Example
|
|
180
|
-
|
|
181
|
-
```javascript
|
|
182
|
-
const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' }));
|
|
183
|
-
|
|
184
|
-
let messages = await inbox.messages;
|
|
185
|
-
messages.forEach((message) => {
|
|
186
|
-
message.isRead = true;
|
|
187
|
-
});
|
|
188
|
-
messages.save();
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
@public
|
|
192
|
-
@return {PromiseArray} promise
|
|
193
|
-
*/
|
|
194
|
-
save: () => Promise<IdentifierArray<T>>;
|
|
195
|
-
/** @internal */
|
|
196
|
-
destroy(): void;
|
|
197
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
|
|
2
|
-
import type { LegacyAttributeField, LegacyRelationshipField } from "../../../types/schema/fields.js";
|
|
3
|
-
export type KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;
|
|
4
|
-
/**
|
|
5
|
-
* Minimum subset of static schema methods and properties on the
|
|
6
|
-
* "model" class.
|
|
7
|
-
*
|
|
8
|
-
* Only used when using the legacy schema-service implementation
|
|
9
|
-
* for @ember-data/model or when wrapping schema for legacy
|
|
10
|
-
* Adapters/Serializers.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
export interface ModelSchema<T = unknown> {
|
|
14
|
-
modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
|
|
15
|
-
fields: Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
|
|
16
|
-
attributes: Map<KeyOrString<T>, LegacyAttributeField>;
|
|
17
|
-
relationshipsByName: Map<KeyOrString<T>, LegacyRelationshipField>;
|
|
18
|
-
eachAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
|
|
19
|
-
eachRelationship<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
|
|
20
|
-
eachTransformedAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, type: string | null) => void, binding?: T): void;
|
|
21
|
-
}
|