@warp-drive/legacy 5.7.0-alpha.2 → 5.7.0-alpha.21
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/compat/builders/find-all.d.ts +2 -2
- package/declarations/compat/builders/query.d.ts +2 -2
- package/declarations/compat/builders/save-record.d.ts +3 -3
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +10 -10
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +5 -5
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -3
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +2 -2
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +72 -44
- package/declarations/model/-private/attr.d.ts +1 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +2 -2
- package/declarations/model/-private/hooks.d.ts +2 -2
- package/declarations/model/-private/legacy-relationships-support.d.ts +16 -17
- package/declarations/model/-private/model.d.ts +4 -5
- package/declarations/model/-private/notify-changes.d.ts +2 -2
- package/declarations/model/-private/record-state.d.ts +2 -2
- package/declarations/model/-private/references/belongs-to.d.ts +6 -6
- package/declarations/model/-private/references/has-many.d.ts +6 -6
- package/declarations/model/-private/schema-provider.d.ts +6 -6
- package/declarations/model/-private.d.ts +2 -1
- package/declarations/model/migration-support.d.ts +10 -10
- package/declarations/store/-private.d.ts +12 -12
- package/dist/{-private-CKrP0ogQ.js → -private-CVsFOW1k.js} +94 -96
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +1 -1
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +1 -1
- package/dist/compat.js +2 -1
- package/dist/{errors-BX5wowuz.js → errors-VSxXZooE.js} +33 -36
- package/dist/model/-private.js +1 -2
- package/dist/model/migration-support.js +12 -6
- package/dist/model.js +10 -11
- package/dist/{schema-provider-Cbnf6sKm.js → schema-provider-BgBPZFfc.js} +20 -16
- package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-B59laYa4.js} +2 -2
- package/dist/store.js +3 -3
- package/package.json +6 -6
|
@@ -13,7 +13,7 @@ type FindAllRequestInput<
|
|
|
13
13
|
};
|
|
14
14
|
[RequestSignature]?: RT;
|
|
15
15
|
};
|
|
16
|
-
type FindAllBuilderOptions
|
|
16
|
+
type FindAllBuilderOptions = FindAllOptions;
|
|
17
17
|
/**
|
|
18
18
|
This function builds a request config to perform a `findAll` request for the given type.
|
|
19
19
|
When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.
|
|
@@ -30,6 +30,6 @@ To that end, these builders are deprecated and will be removed in a future versi
|
|
|
30
30
|
@param {FindAllBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.findAll
|
|
31
31
|
@return {FindAllRequestInput} request config
|
|
32
32
|
*/
|
|
33
|
-
export declare function findAllBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, options?: FindAllBuilderOptions
|
|
33
|
+
export declare function findAllBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, options?: FindAllBuilderOptions): FindAllRequestInput<TypeFromInstance<T>, T[]>;
|
|
34
34
|
export declare function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;
|
|
35
35
|
export {};
|
|
@@ -31,7 +31,7 @@ To that end, these builders are deprecated and will be removed in a future versi
|
|
|
31
31
|
@param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query
|
|
32
32
|
@return {QueryRequestInput} request config
|
|
33
33
|
*/
|
|
34
|
-
export declare function queryBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery
|
|
34
|
+
export declare function queryBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRequestInput<TypeFromInstance<T>, T[]>;
|
|
35
35
|
export declare function queryBuilder(type: string, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRequestInput;
|
|
36
36
|
type QueryRecordRequestInput<
|
|
37
37
|
T extends string = string,
|
|
@@ -61,6 +61,6 @@ To that end, these builders are deprecated and will be removed in a future versi
|
|
|
61
61
|
@param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query
|
|
62
62
|
@return {QueryRecordRequestInput} request config
|
|
63
63
|
*/
|
|
64
|
-
export declare function queryRecordBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery
|
|
64
|
+
export declare function queryRecordBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;
|
|
65
65
|
export declare function queryRecordBuilder(type: string, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRecordRequestInput;
|
|
66
66
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StoreRequestInput } from "@warp-drive/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "@warp-drive/core/types";
|
|
3
3
|
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
4
4
|
import type { RequestSignature } from "@warp-drive/core/types/symbols";
|
|
5
5
|
type SaveRecordRequestInput<
|
|
@@ -8,10 +8,10 @@ type SaveRecordRequestInput<
|
|
|
8
8
|
> = StoreRequestInput & {
|
|
9
9
|
op: "createRecord" | "deleteRecord" | "updateRecord";
|
|
10
10
|
data: {
|
|
11
|
-
record:
|
|
11
|
+
record: ResourceKey<T>;
|
|
12
12
|
options: SaveRecordBuilderOptions;
|
|
13
13
|
};
|
|
14
|
-
records: [
|
|
14
|
+
records: [ResourceKey<T>];
|
|
15
15
|
[RequestSignature]?: RT;
|
|
16
16
|
};
|
|
17
17
|
type SaveRecordBuilderOptions = Record<string, unknown>;
|
|
@@ -2,7 +2,7 @@ import type { Store } from "@warp-drive/core";
|
|
|
2
2
|
import { createDeferred } from "@warp-drive/core/request";
|
|
3
3
|
import type { Request, RequestStateService } from "@warp-drive/core/store/-private";
|
|
4
4
|
import type { FindRecordOptions } from "@warp-drive/core/types";
|
|
5
|
-
import type {
|
|
5
|
+
import type { PersistedResourceKey, ResourceKey } from "@warp-drive/core/types/identifier";
|
|
6
6
|
import type { TypeFromInstance } from "@warp-drive/core/types/record";
|
|
7
7
|
import type { ImmutableRequestInfo } from "@warp-drive/core/types/request";
|
|
8
8
|
import type { SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
|
|
@@ -13,23 +13,23 @@ export type FetchMutationOptions = FindRecordOptions & {
|
|
|
13
13
|
[SaveOp]: "createRecord" | "deleteRecord" | "updateRecord";
|
|
14
14
|
};
|
|
15
15
|
interface PendingFetchItem {
|
|
16
|
-
identifier:
|
|
16
|
+
identifier: PersistedResourceKey;
|
|
17
17
|
queryRequest: Request;
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
19
|
resolver: Deferred<any>;
|
|
20
20
|
options: FindRecordOptions;
|
|
21
21
|
trace?: unknown;
|
|
22
|
-
promise: Promise<
|
|
22
|
+
promise: Promise<PersistedResourceKey>;
|
|
23
23
|
}
|
|
24
24
|
export declare class FetchManager {
|
|
25
25
|
isDestroyed: boolean;
|
|
26
26
|
requestCache: RequestStateService;
|
|
27
27
|
// fetches pending in the runloop, waiting to be coalesced
|
|
28
|
-
_pendingFetch: Map<string, Map<
|
|
28
|
+
_pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;
|
|
29
29
|
_store: Store;
|
|
30
30
|
constructor(store: Store);
|
|
31
|
-
createSnapshot<T>(identifier:
|
|
32
|
-
createSnapshot(identifier:
|
|
31
|
+
createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;
|
|
32
|
+
createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;
|
|
33
33
|
/**
|
|
34
34
|
This method is called by `record.save`, and gets passed a
|
|
35
35
|
resolver for the promise that `record.save` returns.
|
|
@@ -38,11 +38,11 @@ export declare class FetchManager {
|
|
|
38
38
|
|
|
39
39
|
@internal
|
|
40
40
|
*/
|
|
41
|
-
scheduleSave(identifier:
|
|
42
|
-
scheduleFetch(identifier:
|
|
43
|
-
getPendingFetch(identifier:
|
|
41
|
+
scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument>;
|
|
42
|
+
scheduleFetch(identifier: PersistedResourceKey, options: FindRecordOptions, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
|
|
43
|
+
getPendingFetch(identifier: PersistedResourceKey, options: FindRecordOptions): Promise<PersistedResourceKey> | undefined;
|
|
44
44
|
flushAllPendingFetches(): void;
|
|
45
|
-
fetchDataIfNeededForIdentifier(identifier:
|
|
45
|
+
fetchDataIfNeededForIdentifier(identifier: PersistedResourceKey, options: FindRecordOptions | undefined, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
|
|
46
46
|
destroy(): void;
|
|
47
47
|
}
|
|
48
48
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function assertIdentifierHasId(identifier: unknown): asserts identifier is
|
|
1
|
+
import type { PersistedResourceKey } from "@warp-drive/core/types/identifier";
|
|
2
|
+
export declare function assertIdentifierHasId(identifier: unknown): asserts identifier is PersistedResourceKey;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import type { BaseFinderOptions } from "@warp-drive/core/types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PersistedResourceKey, ResourceKey } from "@warp-drive/core/types/identifier";
|
|
4
4
|
import type { LegacyRelationshipField as RelationshipSchema } from "@warp-drive/core/types/schema/fields";
|
|
5
5
|
import type { MinimumAdapterInterface } from "./minimum-adapter-interface.js";
|
|
6
|
-
export declare function _findHasMany(adapter: MinimumAdapterInterface, store: Store, identifier:
|
|
6
|
+
export declare function _findHasMany(adapter: MinimumAdapterInterface, store: Store, identifier: ResourceKey, link: string | null | {
|
|
7
7
|
href: string;
|
|
8
|
-
}, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<
|
|
9
|
-
export declare function _findBelongsTo(store: Store, identifier:
|
|
8
|
+
}, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<PersistedResourceKey[]>;
|
|
9
|
+
export declare function _findBelongsTo(store: Store, identifier: ResourceKey, link: string | null | {
|
|
10
10
|
href: string;
|
|
11
|
-
}, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<
|
|
11
|
+
}, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<PersistedResourceKey | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LegacyQueryArray } from "@warp-drive/core/store/-private";
|
|
3
3
|
import type { ModelSchema } from "@warp-drive/core/types";
|
|
4
4
|
import type { LegacyRelationshipField as RelationshipSchema } from "@warp-drive/core/types/schema/fields";
|
|
5
5
|
import type { Snapshot } from "./snapshot.js";
|
|
@@ -113,11 +113,11 @@ export interface MinimumAdapterInterface {
|
|
|
113
113
|
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
114
114
|
* the type, attributes and relationships of the primary type associated with the request.
|
|
115
115
|
* @param {Object} query
|
|
116
|
-
* @param {
|
|
116
|
+
* @param {LegacyQueryArray} recordArray
|
|
117
117
|
* @param {Object} options
|
|
118
118
|
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
119
119
|
*/
|
|
120
|
-
query(store: Store, schema: ModelSchema, query: Record<string, unknown>, recordArray:
|
|
120
|
+
query(store: Store, schema: ModelSchema, query: Record<string, unknown>, recordArray: LegacyQueryArray, options: {
|
|
121
121
|
adapterOptions?: unknown;
|
|
122
122
|
}): Promise<AdapterPayload>;
|
|
123
123
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LegacyLiveArray } from "@warp-drive/core/store/-private";
|
|
3
3
|
import type { FindAllOptions, ModelSchema } from "@warp-drive/core/types";
|
|
4
4
|
import type { Snapshot } from "./snapshot.js";
|
|
5
5
|
/**
|
|
@@ -36,7 +36,7 @@ export declare class SnapshotRecordArray {
|
|
|
36
36
|
@private
|
|
37
37
|
@type {Array}
|
|
38
38
|
*/
|
|
39
|
-
get _recordArray():
|
|
39
|
+
get _recordArray(): LegacyLiveArray;
|
|
40
40
|
/**
|
|
41
41
|
Number of records in the array
|
|
42
42
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import type { FindRecordOptions } from "@warp-drive/core/types";
|
|
3
3
|
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
5
5
|
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
6
6
|
import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
7
7
|
import type { SerializerOptions } from "./minimum-serializer-interface.js";
|
|
@@ -14,46 +14,73 @@ adapters and serializers for certain requests.
|
|
|
14
14
|
Snapshots are only available when using `@ember-data/legacy-compat`
|
|
15
15
|
for legacy compatibility with adapters and serializers.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
For serialization of records in modern paradigms, request data from
|
|
18
|
+
the cache or off the record directly.
|
|
19
|
+
|
|
20
|
+
@hideconstructor
|
|
18
21
|
@public
|
|
19
22
|
*/
|
|
20
23
|
export declare class Snapshot<R = unknown> {
|
|
21
|
-
__attributes
|
|
22
|
-
_belongsToRelationships
|
|
23
|
-
_belongsToIds
|
|
24
|
-
_hasManyRelationships
|
|
25
|
-
_hasManyIds
|
|
26
|
-
_changedAttributes
|
|
27
|
-
|
|
24
|
+
private __attributes;
|
|
25
|
+
private _belongsToRelationships;
|
|
26
|
+
private _belongsToIds;
|
|
27
|
+
private _hasManyRelationships;
|
|
28
|
+
private _hasManyIds;
|
|
29
|
+
private _changedAttributes;
|
|
30
|
+
private _store;
|
|
31
|
+
/**
|
|
32
|
+
The unique ResourceKey associated with this Snapshot.
|
|
33
|
+
|
|
34
|
+
@public
|
|
35
|
+
*/
|
|
36
|
+
identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
|
|
37
|
+
/**
|
|
38
|
+
The ResourceType of the underlying record for this Snapshot, as a string.
|
|
39
|
+
|
|
40
|
+
@public
|
|
41
|
+
*/
|
|
28
42
|
modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;
|
|
43
|
+
/**
|
|
44
|
+
The id of the snapshot's underlying record
|
|
45
|
+
|
|
46
|
+
Example
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
50
|
+
postSnapshot.id; // => '1'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
@public
|
|
54
|
+
*/
|
|
29
55
|
id: string | null;
|
|
56
|
+
/**
|
|
57
|
+
If `include` was passed to the options for the request, the value
|
|
58
|
+
would be available here.
|
|
59
|
+
|
|
60
|
+
@public
|
|
61
|
+
*/
|
|
30
62
|
include?: string | string[];
|
|
31
|
-
adapterOptions?: Record<string, unknown>;
|
|
32
|
-
_store: Store;
|
|
33
63
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* @param identifier
|
|
38
|
-
* @param _store
|
|
64
|
+
The adapterOptions passed to the request which generated this Snapshot, if any
|
|
65
|
+
|
|
66
|
+
@public
|
|
39
67
|
*/
|
|
40
|
-
|
|
68
|
+
adapterOptions?: Record<string, unknown>;
|
|
69
|
+
constructor(options: FindRecordOptions, identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
|
|
41
70
|
/**
|
|
42
71
|
The underlying record for this snapshot. Can be used to access methods and
|
|
43
72
|
properties defined on the record.
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```javascript
|
|
48
|
-
let json = snapshot.record.toJSON();
|
|
74
|
+
```js
|
|
75
|
+
const someValue = snapshot.record.someProp;
|
|
49
76
|
```
|
|
50
77
|
|
|
51
78
|
@property record
|
|
52
|
-
@type {Model}
|
|
53
79
|
@public
|
|
54
80
|
*/
|
|
55
81
|
get record(): R | null;
|
|
56
|
-
|
|
82
|
+
/** @internal */
|
|
83
|
+
private get _attributes();
|
|
57
84
|
get isNew(): boolean;
|
|
58
85
|
/**
|
|
59
86
|
Returns the value of an attribute.
|
|
@@ -68,22 +95,28 @@ export declare class Snapshot<R = unknown> {
|
|
|
68
95
|
|
|
69
96
|
Note: Values are loaded eagerly and cached when the snapshot is created.
|
|
70
97
|
|
|
71
|
-
@
|
|
72
|
-
@return {Object} The attribute value or undefined
|
|
98
|
+
@return The attribute value or undefined
|
|
73
99
|
@public
|
|
74
100
|
*/
|
|
75
101
|
attr(keyName: keyof R & string): unknown;
|
|
76
102
|
/**
|
|
77
103
|
Returns all attributes and their corresponding values.
|
|
78
104
|
|
|
105
|
+
::: warning ⚠️ WARNING
|
|
106
|
+
Attributes are SHALLOW copied from the cache.
|
|
107
|
+
Because they are NOT deep copied from the cache, mutating
|
|
108
|
+
any object or array fields will cause unintended side-effects
|
|
109
|
+
and bugs.
|
|
110
|
+
:::
|
|
111
|
+
|
|
79
112
|
Example
|
|
80
113
|
|
|
81
|
-
```
|
|
114
|
+
```js
|
|
82
115
|
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
83
116
|
postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
|
|
84
117
|
```
|
|
85
118
|
|
|
86
|
-
@return
|
|
119
|
+
@return All attributes of the current snapshot
|
|
87
120
|
@public
|
|
88
121
|
*/
|
|
89
122
|
attributes(): Record<keyof R & string, unknown>;
|
|
@@ -92,13 +125,13 @@ export declare class Snapshot<R = unknown> {
|
|
|
92
125
|
|
|
93
126
|
Example
|
|
94
127
|
|
|
95
|
-
```
|
|
128
|
+
```js
|
|
96
129
|
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
97
130
|
postModel.set('title', 'Ember.js rocks!');
|
|
98
131
|
postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
|
|
99
132
|
```
|
|
100
133
|
|
|
101
|
-
@return
|
|
134
|
+
@return All changed attributes of the current snapshot
|
|
102
135
|
@public
|
|
103
136
|
*/
|
|
104
137
|
changedAttributes(): ChangedAttributesHash;
|
|
@@ -113,7 +146,7 @@ export declare class Snapshot<R = unknown> {
|
|
|
113
146
|
|
|
114
147
|
Example
|
|
115
148
|
|
|
116
|
-
```
|
|
149
|
+
```js
|
|
117
150
|
// store.push('post', { id: 1, title: 'Hello World' });
|
|
118
151
|
// store.createRecord('comment', { body: 'Lorem ipsum', post: post });
|
|
119
152
|
commentSnapshot.belongsTo('post'); // => Snapshot
|
|
@@ -130,12 +163,10 @@ export declare class Snapshot<R = unknown> {
|
|
|
130
163
|
|
|
131
164
|
Note: Relationships are loaded lazily and cached upon first access.
|
|
132
165
|
|
|
133
|
-
@param {String} keyName
|
|
134
|
-
@param {Object} [options]
|
|
135
166
|
@public
|
|
136
|
-
@return
|
|
137
|
-
relationship
|
|
138
|
-
|
|
167
|
+
@return A snapshot or ID of a known relationship or null if the
|
|
168
|
+
relationship is known but unset. undefined will be returned if the
|
|
169
|
+
contents of the relationship are unknown.
|
|
139
170
|
*/
|
|
140
171
|
belongsTo(keyName: string, options?: {
|
|
141
172
|
id?: boolean;
|
|
@@ -162,10 +193,8 @@ export declare class Snapshot<R = unknown> {
|
|
|
162
193
|
|
|
163
194
|
Note: Relationships are loaded lazily and cached upon first access.
|
|
164
195
|
|
|
165
|
-
@param {String} keyName
|
|
166
|
-
@param {Object} [options]
|
|
167
196
|
@public
|
|
168
|
-
@return
|
|
197
|
+
@return An array of snapshots or IDs of a known
|
|
169
198
|
relationship or an empty array if the relationship is known but unset.
|
|
170
199
|
undefined will be returned if the contents of the relationship is unknown.
|
|
171
200
|
*/
|
|
@@ -184,8 +213,8 @@ export declare class Snapshot<R = unknown> {
|
|
|
184
213
|
});
|
|
185
214
|
```
|
|
186
215
|
|
|
187
|
-
@param
|
|
188
|
-
@param
|
|
216
|
+
@param callback the callback to execute
|
|
217
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
189
218
|
@public
|
|
190
219
|
*/
|
|
191
220
|
eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void;
|
|
@@ -201,8 +230,8 @@ export declare class Snapshot<R = unknown> {
|
|
|
201
230
|
});
|
|
202
231
|
```
|
|
203
232
|
|
|
204
|
-
@param
|
|
205
|
-
@param
|
|
233
|
+
@param callback the callback to execute
|
|
234
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
206
235
|
@public
|
|
207
236
|
*/
|
|
208
237
|
eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void;
|
|
@@ -227,8 +256,7 @@ export declare class Snapshot<R = unknown> {
|
|
|
227
256
|
});
|
|
228
257
|
```
|
|
229
258
|
|
|
230
|
-
@
|
|
231
|
-
@return {Object} an object whose values are primitive JSON values only
|
|
259
|
+
@return an object whose values are primitive JSON values only
|
|
232
260
|
@public
|
|
233
261
|
*/
|
|
234
262
|
serialize(options?: SerializerOptions): unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArrayValue, ObjectValue, PrimitiveValue } from "@warp-drive/core/types/json/raw";
|
|
2
|
-
import type
|
|
2
|
+
import { type TransformName } from "@warp-drive/core/types/symbols";
|
|
3
3
|
import type { DecoratorPropertyDescriptor } from "./util.js";
|
|
4
4
|
/**
|
|
5
5
|
* Options provided to the attr decorator are
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import type { UpgradedMeta } from "@warp-drive/core/graph/-private";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
4
4
|
/*
|
|
5
5
|
Assert that `addedRecord` has a valid type so it can be added to the
|
|
6
6
|
relationship of the `record`.
|
|
@@ -13,5 +13,5 @@ be stable record identifiers and the `relationshipMeta` needs to be the meta
|
|
|
13
13
|
information about the relationship, retrieved via
|
|
14
14
|
`record.relationshipFor(key)`.
|
|
15
15
|
*/
|
|
16
|
-
declare let assertPolymorphicType: (parentIdentifier:
|
|
16
|
+
declare let assertPolymorphicType: (parentIdentifier: ResourceKey, parentDefinition: UpgradedMeta, addedIdentifier: ResourceKey, store: Store) => void;
|
|
17
17
|
export { assertPolymorphicType };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Store } from "@warp-drive/core/store/-private";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
3
3
|
import type { TypeFromInstance } from "@warp-drive/core/types/record";
|
|
4
4
|
import type { Model } from "./model.js";
|
|
5
|
-
export declare function instantiateRecord(this: Store, identifier:
|
|
5
|
+
export declare function instantiateRecord(this: Store, identifier: ResourceKey, createRecordArgs: {
|
|
6
6
|
[key: string]: unknown;
|
|
7
7
|
}): Model;
|
|
8
8
|
export declare function teardownRecord(record: Model): void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import type { CollectionEdge, Graph, ResourceEdge, UpgradedMeta } from "@warp-drive/core/graph/-private";
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import type { BaseFinderOptions, StableRecordIdentifier } from "@warp-drive/core/types";
|
|
3
|
+
import type { LegacyManyArray } from "@warp-drive/core/store/-private";
|
|
4
|
+
import type { BaseFinderOptions, ResourceKey } from "@warp-drive/core/types";
|
|
6
5
|
import type { Cache } from "@warp-drive/core/types/cache";
|
|
7
6
|
import type { CollectionRelationship } from "@warp-drive/core/types/cache/relationship";
|
|
8
7
|
import type { LocalRelationshipOperation } from "@warp-drive/core/types/graph";
|
|
@@ -15,7 +14,7 @@ import type { HasManyProxyCreateArgs } from "./promise-many-array.js";
|
|
|
15
14
|
import { PromiseManyArray } from "./promise-many-array.js";
|
|
16
15
|
import BelongsToReference from "./references/belongs-to.js";
|
|
17
16
|
import HasManyReference from "./references/has-many.js";
|
|
18
|
-
export declare const LEGACY_SUPPORT: Map<
|
|
17
|
+
export declare const LEGACY_SUPPORT: Map<ResourceKey | MinimalLegacyRecord, LegacySupport>;
|
|
19
18
|
export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
|
|
20
19
|
export declare class LegacySupport {
|
|
21
20
|
record: MinimalLegacyRecord;
|
|
@@ -23,25 +22,25 @@ export declare class LegacySupport {
|
|
|
23
22
|
graph: Graph;
|
|
24
23
|
cache: Cache;
|
|
25
24
|
references: Record<string, BelongsToReference | HasManyReference>;
|
|
26
|
-
identifier:
|
|
27
|
-
_manyArrayCache: Record<string,
|
|
28
|
-
_relationshipPromisesCache: Record<string, Promise<
|
|
25
|
+
identifier: ResourceKey;
|
|
26
|
+
_manyArrayCache: Record<string, LegacyManyArray>;
|
|
27
|
+
_relationshipPromisesCache: Record<string, Promise<LegacyManyArray | OpaqueRecordInstance>>;
|
|
29
28
|
_relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
|
|
30
|
-
_pending: Record<string, Promise<
|
|
29
|
+
_pending: Record<string, Promise<ResourceKey | null> | undefined>;
|
|
31
30
|
isDestroying: boolean;
|
|
32
31
|
isDestroyed: boolean;
|
|
33
|
-
constructor(record: MinimalLegacyRecord);
|
|
34
|
-
_syncArray(array:
|
|
32
|
+
constructor(record: MinimalLegacyRecord, identifier: ResourceKey);
|
|
33
|
+
_syncArray(array: LegacyManyArray): void;
|
|
35
34
|
mutate(mutation: LocalRelationshipOperation): void;
|
|
36
35
|
_findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
|
|
37
36
|
reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
|
|
38
37
|
getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
|
|
39
38
|
setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void;
|
|
40
|
-
_getCurrentState<T>(identifier:
|
|
41
|
-
getManyArray<T>(key: string, definition?: UpgradedMeta):
|
|
42
|
-
fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray:
|
|
43
|
-
reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<
|
|
44
|
-
getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray |
|
|
39
|
+
_getCurrentState<T>(identifier: ResourceKey, field: string): [ResourceKey<TypeFromInstanceOrString<T>>[], CollectionRelationship];
|
|
40
|
+
getManyArray<T>(key: string, definition?: UpgradedMeta): LegacyManyArray<T>;
|
|
41
|
+
fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: LegacyManyArray, options?: BaseFinderOptions): Promise<LegacyManyArray>;
|
|
42
|
+
reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<LegacyManyArray<T>> | PromiseManyArray<T>;
|
|
43
|
+
getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | LegacyManyArray;
|
|
45
44
|
_updatePromiseProxyFor(kind: "hasMany", key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
|
|
46
45
|
_updatePromiseProxyFor(kind: "belongsTo", key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
|
|
47
46
|
_updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
|
|
@@ -49,8 +48,8 @@ export declare class LegacySupport {
|
|
|
49
48
|
}): PromiseBelongsTo;
|
|
50
49
|
referenceFor(kind: "belongsTo", name: string): BelongsToReference;
|
|
51
50
|
referenceFor(kind: "hasMany", name: string): HasManyReference;
|
|
52
|
-
_findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier:
|
|
53
|
-
_findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier:
|
|
51
|
+
_findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: ResourceKey, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
|
|
52
|
+
_findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: ResourceKey, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<ResourceKey | null>;
|
|
54
53
|
destroy(): void;
|
|
55
54
|
}
|
|
56
55
|
export declare function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import EmberObject from "@ember/object";
|
|
2
2
|
import type { Store } from "@warp-drive/core";
|
|
3
|
-
import type { ModelSchema,
|
|
4
|
-
import type {
|
|
3
|
+
import type { ModelSchema, ResourceKey } from "@warp-drive/core/types";
|
|
4
|
+
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
5
5
|
import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
6
6
|
import { RecordStore } from "@warp-drive/core/types/symbols";
|
|
7
7
|
import type { Snapshot } from "../../compat/-private.js";
|
|
@@ -15,10 +15,9 @@ export type ModelCreateArgs = {
|
|
|
15
15
|
_createProps: Record<string, unknown>;
|
|
16
16
|
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
17
17
|
_secretInit: {
|
|
18
|
-
identifier:
|
|
19
|
-
cache: Cache;
|
|
18
|
+
identifier: ResourceKey;
|
|
20
19
|
store: Store;
|
|
21
|
-
cb: (record: Model,
|
|
20
|
+
cb: (record: Model, identifier: ResourceKey, store: Store) => void;
|
|
22
21
|
};
|
|
23
22
|
};
|
|
24
23
|
export type StaticModel = typeof Model & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { NotificationType, Store } from "@warp-drive/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
3
3
|
import type { Model } from "./model.js";
|
|
4
|
-
export default function notifyChanges(identifier:
|
|
4
|
+
export default function notifyChanges(identifier: ResourceKey, value: NotificationType, key: string | undefined, record: Model, store: Store): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import type { RequestCacheRequestState, RequestStateService } from "@warp-drive/core/store/-private";
|
|
3
3
|
import type { Cache } from "@warp-drive/core/types/cache";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
5
5
|
import type { Errors } from "./errors.js";
|
|
6
6
|
import type { MinimalLegacyRecord } from "./model-methods.js";
|
|
7
7
|
/**
|
|
@@ -45,7 +45,7 @@ inFlight
|
|
|
45
45
|
*/
|
|
46
46
|
export default class RecordState {
|
|
47
47
|
store: Store;
|
|
48
|
-
identifier:
|
|
48
|
+
identifier: ResourceKey;
|
|
49
49
|
record: MinimalLegacyRecord;
|
|
50
50
|
rs: RequestStateService;
|
|
51
51
|
pendingCount: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import type { Graph, ResourceEdge } from "@warp-drive/core/graph/-private";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
4
4
|
import type { TypeFromInstance, TypeFromInstanceOrString } from "@warp-drive/core/types/record";
|
|
5
5
|
import type { Links, Meta, SingleResourceDocument, SingleResourceRelationship } from "@warp-drive/core/types/spec/json-api-raw";
|
|
6
6
|
import type { IsUnknown } from "../belongs-to.js";
|
|
@@ -59,20 +59,20 @@ export default class BelongsToReference<
|
|
|
59
59
|
type: TypeFromInstanceOrString<Related>;
|
|
60
60
|
// unsubscribe tokens given to us by the notification manager
|
|
61
61
|
___token: object;
|
|
62
|
-
___identifier:
|
|
62
|
+
___identifier: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
63
63
|
___relatedToken: object | null;
|
|
64
64
|
_ref: number;
|
|
65
|
-
constructor(store: Store, graph: Graph, parentIdentifier:
|
|
65
|
+
constructor(store: Store, graph: Graph, parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>, belongsToRelationship: ResourceEdge, key: K);
|
|
66
66
|
destroy(): void;
|
|
67
67
|
/**
|
|
68
68
|
* The identifier of the record that this reference refers to.
|
|
69
69
|
* `null` if no related record is known.
|
|
70
70
|
*
|
|
71
71
|
* @property identifier
|
|
72
|
-
* @type {
|
|
72
|
+
* @type {ResourceKey | null}
|
|
73
73
|
* @public
|
|
74
74
|
*/
|
|
75
|
-
get identifier():
|
|
75
|
+
get identifier(): ResourceKey<TypeFromInstanceOrString<Related>> | null;
|
|
76
76
|
/**
|
|
77
77
|
The `id` of the record that this reference refers to. Together, the
|
|
78
78
|
`type()` and `id()` methods form a composite key for the identity
|
|
@@ -198,7 +198,7 @@ export default class BelongsToReference<
|
|
|
198
198
|
@return {Object} The meta information for the belongs-to relationship.
|
|
199
199
|
*/
|
|
200
200
|
meta(): Meta | null;
|
|
201
|
-
_resource(): SingleResourceRelationship<
|
|
201
|
+
_resource(): SingleResourceRelationship<ResourceKey<TypeFromInstance<Related>>>;
|
|
202
202
|
/**
|
|
203
203
|
This returns a string that represents how the reference will be
|
|
204
204
|
looked up when it is loaded. If the relationship has a link it will
|
|
@@ -2,7 +2,7 @@ import type { Store } from "@warp-drive/core";
|
|
|
2
2
|
import type { CollectionEdge, Graph } from "@warp-drive/core/graph/-private";
|
|
3
3
|
import type { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
|
|
4
4
|
import type { BaseFinderOptions } from "@warp-drive/core/types";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
6
6
|
import type { TypeFromInstanceOrString } from "@warp-drive/core/types/record";
|
|
7
7
|
import type { CollectionResourceDocument, CollectionResourceRelationship, ExistingResourceObject, LinkObject, Meta, PaginationLinks } from "@warp-drive/core/types/spec/json-api-raw";
|
|
8
8
|
import type { IsUnknown } from "../belongs-to.js";
|
|
@@ -68,10 +68,10 @@ export default class HasManyReference<
|
|
|
68
68
|
type: TypeFromInstanceOrString<Related>;
|
|
69
69
|
// unsubscribe tokens given to us by the notification manager
|
|
70
70
|
___token: object;
|
|
71
|
-
___identifier:
|
|
72
|
-
___relatedTokenMap: Map<
|
|
71
|
+
___identifier: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
72
|
+
___relatedTokenMap: Map<ResourceKey, object>;
|
|
73
73
|
_ref: number;
|
|
74
|
-
constructor(store: Store, graph: Graph, parentIdentifier:
|
|
74
|
+
constructor(store: Store, graph: Graph, parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
|
|
75
75
|
/**
|
|
76
76
|
* This method should never be called by user code.
|
|
77
77
|
*
|
|
@@ -82,10 +82,10 @@ export default class HasManyReference<
|
|
|
82
82
|
* An array of identifiers for the records that this reference refers to.
|
|
83
83
|
*
|
|
84
84
|
* @property identifiers
|
|
85
|
-
* @type {
|
|
85
|
+
* @type {ResourceKey[]}
|
|
86
86
|
* @public
|
|
87
87
|
*/
|
|
88
|
-
get identifiers():
|
|
88
|
+
get identifiers(): ResourceKey<TypeFromInstanceOrString<Related>>[];
|
|
89
89
|
_resource(): CollectionResourceRelationship;
|
|
90
90
|
/**
|
|
91
91
|
This returns a string that represents how the reference will be
|