@warp-drive/legacy 5.7.0-alpha.3 → 5.7.0-alpha.30
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/adapter/-private/utils/continue-on-reject.d.ts +1 -7
- 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 +24 -16
- 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 +40 -18
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +70 -44
- package/declarations/compat.d.ts +3 -3
- 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 +21 -27
- package/declarations/model/-private/model-methods.d.ts +0 -4
- package/declarations/model/-private/model.d.ts +13 -31
- package/declarations/model/-private/notify-changes.d.ts +2 -2
- package/declarations/model/-private/promise-many-array.d.ts +0 -3
- package/declarations/model/-private/record-state.d.ts +2 -25
- package/declarations/model/-private/references/belongs-to.d.ts +6 -6
- package/declarations/model/-private/references/has-many.d.ts +6 -12
- 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 -34
- package/declarations/store/-private.d.ts +12 -23
- package/dist/{-private-CKrP0ogQ.js → -private-HaYCdCCm.js} +155 -141
- 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 +3 -2
- package/dist/compat.js +7 -2
- package/dist/{errors-BX5wowuz.js → errors-BMZPmFxm.js} +46 -36
- package/dist/model/-private.js +1 -2
- package/dist/model/migration-support.js +14 -6
- package/dist/model.js +13 -11
- package/dist/{schema-provider-Cbnf6sKm.js → schema-provider-Dhk-879f.js} +55 -26
- package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-Ceon-MrI.js} +2 -1
- package/dist/store.js +8 -6
- package/package.json +13 -13
|
@@ -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>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import { createDeferred } from "@warp-drive/core/request";
|
|
3
|
-
import type { Request
|
|
3
|
+
import type { Request } 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,36 +13,44 @@ 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
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
24
27
|
export declare class FetchManager {
|
|
25
|
-
isDestroyed: boolean;
|
|
26
|
-
requestCache: RequestStateService;
|
|
27
|
-
// fetches pending in the runloop, waiting to be coalesced
|
|
28
|
-
_pendingFetch: Map<string, Map<StableExistingRecordIdentifier, PendingFetchItem[]>>;
|
|
29
|
-
_store: Store;
|
|
30
28
|
constructor(store: Store);
|
|
31
|
-
createSnapshot<T>(identifier:
|
|
32
|
-
createSnapshot(identifier:
|
|
29
|
+
createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;
|
|
30
|
+
createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;
|
|
33
31
|
/**
|
|
34
32
|
This method is called by `record.save`, and gets passed a
|
|
35
33
|
resolver for the promise that `record.save` returns.
|
|
36
34
|
|
|
37
35
|
It schedules saving to happen at the end of the run loop.
|
|
38
36
|
|
|
39
|
-
@
|
|
37
|
+
@private
|
|
40
38
|
*/
|
|
41
|
-
scheduleSave(identifier:
|
|
42
|
-
scheduleFetch(identifier:
|
|
43
|
-
getPendingFetch(identifier:
|
|
39
|
+
scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument>;
|
|
40
|
+
scheduleFetch(identifier: PersistedResourceKey, options: FindRecordOptions, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
|
|
41
|
+
getPendingFetch(identifier: PersistedResourceKey, options: FindRecordOptions): Promise<PersistedResourceKey> | undefined;
|
|
44
42
|
flushAllPendingFetches(): void;
|
|
45
|
-
fetchDataIfNeededForIdentifier(identifier:
|
|
43
|
+
fetchDataIfNeededForIdentifier(identifier: PersistedResourceKey, options: FindRecordOptions | undefined, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
|
|
46
44
|
destroy(): void;
|
|
47
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* This type exists for internal use only for
|
|
48
|
+
* where intimate contracts still exist either for
|
|
49
|
+
* the Test Suite or for Legacy code.
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
export interface PrivateFetchManager extends FetchManager {
|
|
54
|
+
_pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;
|
|
55
|
+
}
|
|
48
56
|
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,21 +1,55 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
|
-
import type {
|
|
3
|
-
import type { FindAllOptions, ModelSchema } from "@warp-drive/core/types";
|
|
2
|
+
import type { FindAllOptions } from "@warp-drive/core/types";
|
|
4
3
|
import type { Snapshot } from "./snapshot.js";
|
|
5
4
|
/**
|
|
6
5
|
SnapshotRecordArray is not directly instantiable.
|
|
7
6
|
Instances are provided to consuming application's
|
|
8
7
|
adapters for certain `findAll` requests.
|
|
9
8
|
|
|
10
|
-
@
|
|
9
|
+
@hideconstructor
|
|
11
10
|
@public
|
|
12
11
|
*/
|
|
13
12
|
export declare class SnapshotRecordArray {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array
|
|
15
|
+
*/
|
|
16
16
|
modelName: string;
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* A hash of adapter options passed into the store method for this request.
|
|
19
|
+
|
|
20
|
+
Example
|
|
21
|
+
|
|
22
|
+
```js [app/adapters/post.js]
|
|
23
|
+
import MyCustomAdapter from './custom-adapter';
|
|
24
|
+
|
|
25
|
+
export default class PostAdapter extends MyCustomAdapter {
|
|
26
|
+
findAll(store, type, sinceToken, snapshotRecordArray) {
|
|
27
|
+
if (snapshotRecordArray.adapterOptions.subscribe) {
|
|
28
|
+
// ...
|
|
29
|
+
}
|
|
30
|
+
// ...
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
*/
|
|
18
35
|
adapterOptions?: Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* The relationships to include for this request.
|
|
38
|
+
|
|
39
|
+
Example
|
|
40
|
+
|
|
41
|
+
```js [app/adapters/application.js]
|
|
42
|
+
import Adapter from '@ember-data/adapter';
|
|
43
|
+
|
|
44
|
+
export default class ApplicationAdapter extends Adapter {
|
|
45
|
+
findAll(store, type, snapshotRecordArray) {
|
|
46
|
+
let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;
|
|
47
|
+
|
|
48
|
+
return fetch(url).then((response) => response.json())
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
*/
|
|
19
53
|
include?: string | string[];
|
|
20
54
|
/**
|
|
21
55
|
SnapshotRecordArray is not directly instantiable.
|
|
@@ -30,14 +64,6 @@ export declare class SnapshotRecordArray {
|
|
|
30
64
|
*/
|
|
31
65
|
constructor(store: Store, type: string, options?: FindAllOptions);
|
|
32
66
|
/**
|
|
33
|
-
An array of records
|
|
34
|
-
|
|
35
|
-
@property _recordArray
|
|
36
|
-
@private
|
|
37
|
-
@type {Array}
|
|
38
|
-
*/
|
|
39
|
-
get _recordArray(): LiveArray;
|
|
40
|
-
/**
|
|
41
67
|
Number of records in the array
|
|
42
68
|
|
|
43
69
|
Example
|
|
@@ -51,10 +77,6 @@ export declare class SnapshotRecordArray {
|
|
|
51
77
|
}
|
|
52
78
|
});
|
|
53
79
|
```
|
|
54
|
-
|
|
55
|
-
@property length
|
|
56
|
-
@public
|
|
57
|
-
@type {Number}
|
|
58
80
|
*/
|
|
59
81
|
get length(): number;
|
|
60
82
|
/**
|
|
@@ -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,71 @@ 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
|
-
get _attributes(): Record<keyof R & string, unknown>;
|
|
57
82
|
get isNew(): boolean;
|
|
58
83
|
/**
|
|
59
84
|
Returns the value of an attribute.
|
|
@@ -68,22 +93,28 @@ export declare class Snapshot<R = unknown> {
|
|
|
68
93
|
|
|
69
94
|
Note: Values are loaded eagerly and cached when the snapshot is created.
|
|
70
95
|
|
|
71
|
-
@
|
|
72
|
-
@return {Object} The attribute value or undefined
|
|
96
|
+
@return The attribute value or undefined
|
|
73
97
|
@public
|
|
74
98
|
*/
|
|
75
99
|
attr(keyName: keyof R & string): unknown;
|
|
76
100
|
/**
|
|
77
101
|
Returns all attributes and their corresponding values.
|
|
78
102
|
|
|
103
|
+
::: warning ⚠️ WARNING
|
|
104
|
+
Attributes are SHALLOW copied from the cache.
|
|
105
|
+
Because they are NOT deep copied from the cache, mutating
|
|
106
|
+
any object or array fields will cause unintended side-effects
|
|
107
|
+
and bugs.
|
|
108
|
+
:::
|
|
109
|
+
|
|
79
110
|
Example
|
|
80
111
|
|
|
81
|
-
```
|
|
112
|
+
```js
|
|
82
113
|
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
83
114
|
postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
|
|
84
115
|
```
|
|
85
116
|
|
|
86
|
-
@return
|
|
117
|
+
@return All attributes of the current snapshot
|
|
87
118
|
@public
|
|
88
119
|
*/
|
|
89
120
|
attributes(): Record<keyof R & string, unknown>;
|
|
@@ -92,13 +123,13 @@ export declare class Snapshot<R = unknown> {
|
|
|
92
123
|
|
|
93
124
|
Example
|
|
94
125
|
|
|
95
|
-
```
|
|
126
|
+
```js
|
|
96
127
|
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
97
128
|
postModel.set('title', 'Ember.js rocks!');
|
|
98
129
|
postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
|
|
99
130
|
```
|
|
100
131
|
|
|
101
|
-
@return
|
|
132
|
+
@return All changed attributes of the current snapshot
|
|
102
133
|
@public
|
|
103
134
|
*/
|
|
104
135
|
changedAttributes(): ChangedAttributesHash;
|
|
@@ -113,7 +144,7 @@ export declare class Snapshot<R = unknown> {
|
|
|
113
144
|
|
|
114
145
|
Example
|
|
115
146
|
|
|
116
|
-
```
|
|
147
|
+
```js
|
|
117
148
|
// store.push('post', { id: 1, title: 'Hello World' });
|
|
118
149
|
// store.createRecord('comment', { body: 'Lorem ipsum', post: post });
|
|
119
150
|
commentSnapshot.belongsTo('post'); // => Snapshot
|
|
@@ -130,12 +161,10 @@ export declare class Snapshot<R = unknown> {
|
|
|
130
161
|
|
|
131
162
|
Note: Relationships are loaded lazily and cached upon first access.
|
|
132
163
|
|
|
133
|
-
@param {String} keyName
|
|
134
|
-
@param {Object} [options]
|
|
135
164
|
@public
|
|
136
|
-
@return
|
|
137
|
-
relationship
|
|
138
|
-
|
|
165
|
+
@return A snapshot or ID of a known relationship or null if the
|
|
166
|
+
relationship is known but unset. undefined will be returned if the
|
|
167
|
+
contents of the relationship are unknown.
|
|
139
168
|
*/
|
|
140
169
|
belongsTo(keyName: string, options?: {
|
|
141
170
|
id?: boolean;
|
|
@@ -162,10 +191,8 @@ export declare class Snapshot<R = unknown> {
|
|
|
162
191
|
|
|
163
192
|
Note: Relationships are loaded lazily and cached upon first access.
|
|
164
193
|
|
|
165
|
-
@param {String} keyName
|
|
166
|
-
@param {Object} [options]
|
|
167
194
|
@public
|
|
168
|
-
@return
|
|
195
|
+
@return An array of snapshots or IDs of a known
|
|
169
196
|
relationship or an empty array if the relationship is known but unset.
|
|
170
197
|
undefined will be returned if the contents of the relationship is unknown.
|
|
171
198
|
*/
|
|
@@ -184,8 +211,8 @@ export declare class Snapshot<R = unknown> {
|
|
|
184
211
|
});
|
|
185
212
|
```
|
|
186
213
|
|
|
187
|
-
@param
|
|
188
|
-
@param
|
|
214
|
+
@param callback the callback to execute
|
|
215
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
189
216
|
@public
|
|
190
217
|
*/
|
|
191
218
|
eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void;
|
|
@@ -201,8 +228,8 @@ export declare class Snapshot<R = unknown> {
|
|
|
201
228
|
});
|
|
202
229
|
```
|
|
203
230
|
|
|
204
|
-
@param
|
|
205
|
-
@param
|
|
231
|
+
@param callback the callback to execute
|
|
232
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
206
233
|
@public
|
|
207
234
|
*/
|
|
208
235
|
eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void;
|
|
@@ -227,8 +254,7 @@ export declare class Snapshot<R = unknown> {
|
|
|
227
254
|
});
|
|
228
255
|
```
|
|
229
256
|
|
|
230
|
-
@
|
|
231
|
-
@return {Object} an object whose values are primitive JSON values only
|
|
257
|
+
@return an object whose values are primitive JSON values only
|
|
232
258
|
@public
|
|
233
259
|
*/
|
|
234
260
|
serialize(options?: SerializerOptions): unknown;
|
package/declarations/compat.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { AdapterPayload, MinimumAdapterInterface } from "./compat/legacy-ne
|
|
|
6
6
|
import type { MinimumSerializerInterface, SerializerOptions } from "./compat/legacy-network-handler/minimum-serializer-interface.js";
|
|
7
7
|
export { LegacyNetworkHandler } from "./compat/legacy-network-handler/legacy-network-handler.js";
|
|
8
8
|
export type { MinimumAdapterInterface, MinimumSerializerInterface, SerializerOptions, AdapterPayload };
|
|
9
|
-
export
|
|
9
|
+
export interface LegacyStoreCompat extends Store {
|
|
10
10
|
_fetchManager: FetchManager;
|
|
11
11
|
adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
12
12
|
adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
@@ -20,8 +20,8 @@ export type LegacyStoreCompat = {
|
|
|
20
20
|
_serializerCache: Record<string, MinimumSerializerInterface & {
|
|
21
21
|
store: Store;
|
|
22
22
|
}>;
|
|
23
|
-
}
|
|
24
|
-
export type CompatStore =
|
|
23
|
+
}
|
|
24
|
+
export type CompatStore = LegacyStoreCompat;
|
|
25
25
|
/**
|
|
26
26
|
Returns an instance of the adapter for a given type. For
|
|
27
27
|
example, `adapterFor('person')` will return an instance of
|
|
@@ -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,9 +1,7 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
|
-
import type { CollectionEdge,
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import type { BaseFinderOptions, StableRecordIdentifier } from "@warp-drive/core/types";
|
|
6
|
-
import type { Cache } from "@warp-drive/core/types/cache";
|
|
2
|
+
import type { CollectionEdge, ResourceEdge, UpgradedMeta } from "@warp-drive/core/graph/-private";
|
|
3
|
+
import type { LegacyManyArray } from "@warp-drive/core/store/-private";
|
|
4
|
+
import type { BaseFinderOptions, ResourceKey } from "@warp-drive/core/types";
|
|
7
5
|
import type { CollectionRelationship } from "@warp-drive/core/types/cache/relationship";
|
|
8
6
|
import type { LocalRelationshipOperation } from "@warp-drive/core/types/graph";
|
|
9
7
|
import type { OpaqueRecordInstance, TypeFromInstanceOrString } from "@warp-drive/core/types/record";
|
|
@@ -15,33 +13,29 @@ import type { HasManyProxyCreateArgs } from "./promise-many-array.js";
|
|
|
15
13
|
import { PromiseManyArray } from "./promise-many-array.js";
|
|
16
14
|
import BelongsToReference from "./references/belongs-to.js";
|
|
17
15
|
import HasManyReference from "./references/has-many.js";
|
|
18
|
-
export declare const LEGACY_SUPPORT: Map<
|
|
16
|
+
export declare const LEGACY_SUPPORT: Map<ResourceKey | MinimalLegacyRecord, LegacySupport>;
|
|
19
17
|
export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
|
|
20
18
|
export declare class LegacySupport {
|
|
21
|
-
record
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
isDestroying: boolean;
|
|
32
|
-
isDestroyed: boolean;
|
|
33
|
-
constructor(record: MinimalLegacyRecord);
|
|
34
|
-
_syncArray(array: LiveArray): void;
|
|
19
|
+
private record;
|
|
20
|
+
private graph;
|
|
21
|
+
private cache;
|
|
22
|
+
private references;
|
|
23
|
+
identifier: ResourceKey;
|
|
24
|
+
private _pending;
|
|
25
|
+
private isDestroying;
|
|
26
|
+
private isDestroyed;
|
|
27
|
+
constructor(record: MinimalLegacyRecord, identifier: ResourceKey);
|
|
28
|
+
_syncArray(array: LegacyManyArray): void;
|
|
35
29
|
mutate(mutation: LocalRelationshipOperation): void;
|
|
36
30
|
_findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
|
|
37
31
|
reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
|
|
38
32
|
getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
|
|
39
33
|
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 |
|
|
34
|
+
_getCurrentState<T>(identifier: ResourceKey, field: string): [ResourceKey<TypeFromInstanceOrString<T>>[], CollectionRelationship];
|
|
35
|
+
getManyArray<T>(key: string, definition?: UpgradedMeta): LegacyManyArray<T>;
|
|
36
|
+
fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: LegacyManyArray, options?: BaseFinderOptions): Promise<LegacyManyArray>;
|
|
37
|
+
reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<LegacyManyArray<T>> | PromiseManyArray<T>;
|
|
38
|
+
getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | LegacyManyArray;
|
|
45
39
|
_updatePromiseProxyFor(kind: "hasMany", key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
|
|
46
40
|
_updatePromiseProxyFor(kind: "belongsTo", key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
|
|
47
41
|
_updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
|
|
@@ -49,8 +43,8 @@ export declare class LegacySupport {
|
|
|
49
43
|
}): PromiseBelongsTo;
|
|
50
44
|
referenceFor(kind: "belongsTo", name: string): BelongsToReference;
|
|
51
45
|
referenceFor(kind: "hasMany", name: string): HasManyReference;
|
|
52
|
-
_findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier:
|
|
53
|
-
_findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier:
|
|
46
|
+
_findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: ResourceKey, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
|
|
47
|
+
_findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: ResourceKey, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<ResourceKey | null>;
|
|
54
48
|
destroy(): void;
|
|
55
49
|
}
|
|
56
50
|
export declare function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { Store } from "@warp-drive/core";
|
|
2
1
|
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
3
|
-
import { RecordStore } from "@warp-drive/core/types/symbols";
|
|
4
2
|
import type { Snapshot } from "../../compat/-private.js";
|
|
5
3
|
import type { Errors } from "./errors.js";
|
|
6
4
|
import type RecordState from "./record-state.js";
|
|
@@ -9,13 +7,11 @@ import type HasManyReference from "./references/has-many.js";
|
|
|
9
7
|
import type { MaybeBelongsToFields, MaybeHasManyFields } from "./type-utils.js";
|
|
10
8
|
export interface MinimalLegacyRecord {
|
|
11
9
|
errors: Errors;
|
|
12
|
-
___recordState: RecordState;
|
|
13
10
|
currentState: RecordState;
|
|
14
11
|
isDestroyed: boolean;
|
|
15
12
|
isDestroying: boolean;
|
|
16
13
|
isReloading: boolean;
|
|
17
14
|
isValid: boolean;
|
|
18
|
-
[RecordStore]: Store;
|
|
19
15
|
deleteRecord(): void;
|
|
20
16
|
unloadRecord(): void;
|
|
21
17
|
save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
|