@warp-drive/legacy 5.7.0-alpha.13 → 5.7.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/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 +4 -4
- 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 +3 -3
- 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 +1 -1
- package/declarations/model/migration-support.d.ts +9 -9
- package/declarations/store/-private.d.ts +5 -5
- package/dist/{-private-CsshwIY7.js → -private-CVsFOW1k.js} +6 -5
- 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.js +2 -1
- package/dist/{errors-DOPr_dMc.js → errors-VSxXZooE.js} +31 -34
- package/dist/model/-private.js +1 -2
- package/dist/model/migration-support.js +5 -4
- package/dist/model.js +3 -3
- package/dist/{schema-provider-0vfXIZzR.js → schema-provider-BgBPZFfc.js} +11 -8
- package/dist/{serialize-into-hash-DVW6-WBv.js → serialize-into-hash-B59laYa4.js} +2 -2
- package/dist/store.js +2 -2
- package/package.json +6 -6
|
@@ -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";
|
|
@@ -29,11 +29,11 @@ export declare class Snapshot<R = unknown> {
|
|
|
29
29
|
private _changedAttributes;
|
|
30
30
|
private _store;
|
|
31
31
|
/**
|
|
32
|
-
The unique
|
|
32
|
+
The unique ResourceKey associated with this Snapshot.
|
|
33
33
|
|
|
34
34
|
@public
|
|
35
35
|
*/
|
|
36
|
-
identifier:
|
|
36
|
+
identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
|
|
37
37
|
/**
|
|
38
38
|
The ResourceType of the underlying record for this Snapshot, as a string.
|
|
39
39
|
|
|
@@ -66,7 +66,7 @@ export declare class Snapshot<R = unknown> {
|
|
|
66
66
|
@public
|
|
67
67
|
*/
|
|
68
68
|
adapterOptions?: Record<string, unknown>;
|
|
69
|
-
constructor(options: FindRecordOptions, identifier:
|
|
69
|
+
constructor(options: FindRecordOptions, identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
|
|
70
70
|
/**
|
|
71
71
|
The underlying record for this snapshot. Can be used to access methods and
|
|
72
72
|
properties defined on the record.
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import EmberObject from "@ember/object";
|
|
2
2
|
import type { Store } from "@warp-drive/core";
|
|
3
|
-
import type { ModelSchema,
|
|
3
|
+
import type { ModelSchema, ResourceKey } from "@warp-drive/core/types";
|
|
4
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";
|
|
@@ -15,9 +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:
|
|
18
|
+
identifier: ResourceKey;
|
|
19
19
|
store: Store;
|
|
20
|
-
cb: (record: Model, identifier:
|
|
20
|
+
cb: (record: Model, identifier: ResourceKey, store: Store) => void;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Store } from "@warp-drive/core";
|
|
2
2
|
import type { SchemaService } from "@warp-drive/core/types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
4
4
|
import type { ObjectValue } from "@warp-drive/core/types/json/raw";
|
|
5
5
|
import type { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schema/concepts";
|
|
6
6
|
import type { ArrayField, DerivedField, GenericField, HashField, LegacyField, ObjectField, ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
@@ -8,10 +8,10 @@ import type { ModelFactory, ModelStore } from "./model.js";
|
|
|
8
8
|
type AttributesSchema = ReturnType<Exclude<SchemaService["attributesDefinitionFor"], undefined>>;
|
|
9
9
|
type RelationshipsSchema = ReturnType<Exclude<SchemaService["relationshipsDefinitionFor"], undefined>>;
|
|
10
10
|
export interface ModelSchemaProvider {
|
|
11
|
-
attributesDefinitionFor(resource:
|
|
11
|
+
attributesDefinitionFor(resource: ResourceKey | {
|
|
12
12
|
type: string;
|
|
13
13
|
}): AttributesSchema;
|
|
14
|
-
relationshipsDefinitionFor(resource:
|
|
14
|
+
relationshipsDefinitionFor(resource: ResourceKey | {
|
|
15
15
|
type: string;
|
|
16
16
|
}): RelationshipsSchema;
|
|
17
17
|
doesTypeExist(type: string): boolean;
|
|
@@ -23,7 +23,7 @@ export declare class ModelSchemaProvider implements SchemaService {
|
|
|
23
23
|
constructor(store: ModelStore);
|
|
24
24
|
resourceTypes(): Readonly<string[]>;
|
|
25
25
|
hasTrait(type: string): boolean;
|
|
26
|
-
resourceHasTrait(resource:
|
|
26
|
+
resourceHasTrait(resource: ResourceKey | {
|
|
27
27
|
type: string;
|
|
28
28
|
}, trait: string): boolean;
|
|
29
29
|
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
@@ -35,7 +35,7 @@ export declare class ModelSchemaProvider implements SchemaService {
|
|
|
35
35
|
hashFn(field: HashField | {
|
|
36
36
|
type: string;
|
|
37
37
|
}): HashFn;
|
|
38
|
-
resource(resource:
|
|
38
|
+
resource(resource: ResourceKey | {
|
|
39
39
|
type: string;
|
|
40
40
|
}): ResourceSchema | ObjectSchema;
|
|
41
41
|
registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
|
|
@@ -48,7 +48,7 @@ export declare class ModelSchemaProvider implements SchemaService {
|
|
|
48
48
|
>(derivation: Derivation<R, T, FM>): void;
|
|
49
49
|
registerHashFn(hashFn: HashFn): void;
|
|
50
50
|
private _loadModelSchema;
|
|
51
|
-
fields(resource:
|
|
51
|
+
fields(resource: ResourceKey | {
|
|
52
52
|
type: string;
|
|
53
53
|
}): Map<string, LegacyField>;
|
|
54
54
|
hasResource(resource: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type MinimalLegacyRecord } from "./-private/model-methods.js";
|
|
2
2
|
export type { ModelStore } from "./-private/model.js";
|
|
3
3
|
export { Errors } from "./-private/errors.js";
|
|
4
|
-
export {
|
|
4
|
+
export type { LegacyManyArray as ManyArray } from "@warp-drive/core/store/-private";
|
|
5
5
|
export { PromiseBelongsTo } from "./-private/promise-belongs-to.js";
|
|
6
6
|
export { PromiseManyArray } from "./-private/promise-many-array.js";
|
|
7
7
|
// // Used by tests, migration support
|
|
@@ -3,7 +3,7 @@ import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "@wa
|
|
|
3
3
|
import type { ExtensibleField } from "@warp-drive/core/reactive/-private/schema";
|
|
4
4
|
import type { SchemaService } from "@warp-drive/core/types";
|
|
5
5
|
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
7
7
|
import type { ObjectValue } from "@warp-drive/core/types/json/raw";
|
|
8
8
|
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
9
9
|
import type { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schema/concepts";
|
|
@@ -198,10 +198,10 @@ export declare function registerDerivations(schema: SchemaService): void;
|
|
|
198
198
|
* @public
|
|
199
199
|
*/
|
|
200
200
|
export interface DelegatingSchemaService {
|
|
201
|
-
attributesDefinitionFor?(resource:
|
|
201
|
+
attributesDefinitionFor?(resource: ResourceKey | {
|
|
202
202
|
type: string;
|
|
203
203
|
}): AttributesSchema;
|
|
204
|
-
relationshipsDefinitionFor?(resource:
|
|
204
|
+
relationshipsDefinitionFor?(resource: ResourceKey | {
|
|
205
205
|
type: string;
|
|
206
206
|
}): RelationshipsSchema;
|
|
207
207
|
doesTypeExist?(type: string): boolean;
|
|
@@ -210,18 +210,18 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
210
210
|
_preferred: SchemaService;
|
|
211
211
|
_secondary: SchemaService;
|
|
212
212
|
constructor(store: Store, schema: SchemaService);
|
|
213
|
-
isDelegated(resource:
|
|
213
|
+
isDelegated(resource: ResourceKey | {
|
|
214
214
|
type: string;
|
|
215
215
|
}): boolean;
|
|
216
216
|
resourceTypes(): Readonly<string[]>;
|
|
217
|
-
hasResource(resource:
|
|
217
|
+
hasResource(resource: ResourceKey | {
|
|
218
218
|
type: string;
|
|
219
219
|
}): boolean;
|
|
220
220
|
hasTrait(type: string): boolean;
|
|
221
|
-
resourceHasTrait(resource:
|
|
221
|
+
resourceHasTrait(resource: ResourceKey | {
|
|
222
222
|
type: string;
|
|
223
223
|
}, trait: string): boolean;
|
|
224
|
-
fields(resource:
|
|
224
|
+
fields(resource: ResourceKey | {
|
|
225
225
|
type: string;
|
|
226
226
|
}): Map<string, FieldSchema>;
|
|
227
227
|
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
@@ -233,7 +233,7 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
233
233
|
derivation(field: DerivedField | {
|
|
234
234
|
type: string;
|
|
235
235
|
}): Derivation;
|
|
236
|
-
resource(resource:
|
|
236
|
+
resource(resource: ResourceKey | {
|
|
237
237
|
type: string;
|
|
238
238
|
}): ResourceSchema | ObjectSchema;
|
|
239
239
|
registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
|
|
@@ -246,7 +246,7 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
246
246
|
>(derivation: Derivation<R, T, FM>): void;
|
|
247
247
|
registerHashFn(hashFn: HashFn): void;
|
|
248
248
|
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
|
|
249
|
-
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource:
|
|
249
|
+
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
|
|
250
250
|
type: string;
|
|
251
251
|
}): null | ProcessedExtension["features"];
|
|
252
252
|
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type InstanceCache } from "@warp-drive/core/store/-private";
|
|
2
|
-
import type {
|
|
2
|
+
import type { NewResourceKey, ResourceKey } from "@warp-drive/core/types/identifier";
|
|
3
3
|
import type { Value } from "@warp-drive/core/types/json/raw";
|
|
4
4
|
import type { OpaqueRecordInstance, TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
5
5
|
import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
6
6
|
import type { SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
|
|
7
7
|
import type { Store } from "../store.js";
|
|
8
|
-
export declare function preloadData(store: Store, identifier:
|
|
8
|
+
export declare function preloadData(store: Store, identifier: NewResourceKey, preload: Record<string, Value>): void;
|
|
9
9
|
export interface BaseFinderOptions {
|
|
10
10
|
reload?: boolean;
|
|
11
11
|
backgroundReload?: boolean;
|
|
@@ -55,7 +55,7 @@ export interface ModelSchema<T = unknown> {
|
|
|
55
55
|
eachRelationship<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
|
|
56
56
|
eachTransformedAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, type: string | null) => void, binding?: T): void;
|
|
57
57
|
}
|
|
58
|
-
export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier:
|
|
58
|
+
export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: ResourceKey): boolean;
|
|
59
59
|
/**
|
|
60
60
|
A `RecordReference` is a low-level API that allows users and
|
|
61
61
|
addon authors to perform meta-operations on a record.
|
|
@@ -73,7 +73,7 @@ export declare class RecordReference {
|
|
|
73
73
|
private ___identifier;
|
|
74
74
|
/** @internal */
|
|
75
75
|
private _ref;
|
|
76
|
-
constructor(store: Store, identifier:
|
|
76
|
+
constructor(store: Store, identifier: ResourceKey);
|
|
77
77
|
/** @internal */
|
|
78
78
|
destroy(): void;
|
|
79
79
|
get type(): string;
|
|
@@ -112,7 +112,7 @@ export declare class RecordReference {
|
|
|
112
112
|
@public
|
|
113
113
|
@return The identifier of the record.
|
|
114
114
|
*/
|
|
115
|
-
identifier():
|
|
115
|
+
identifier(): ResourceKey;
|
|
116
116
|
/**
|
|
117
117
|
How the reference will be looked up when it is loaded. Currently
|
|
118
118
|
this always returns `identity` to signify that a record will be
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import { createDeferred } from '@warp-drive/core/request';
|
|
4
|
+
import { waitFor, coerceId } from '@warp-drive/core/store/-private';
|
|
4
5
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
5
6
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
7
|
|
|
@@ -139,7 +140,7 @@ class SnapshotRecordArray {
|
|
|
139
140
|
const {
|
|
140
141
|
_fetchManager
|
|
141
142
|
} = this.__store;
|
|
142
|
-
this._snapshots = this._recordArray[
|
|
143
|
+
this._snapshots = this._recordArray[Context].source.map(identifier => _fetchManager.createSnapshot(identifier));
|
|
143
144
|
return this._snapshots;
|
|
144
145
|
}
|
|
145
146
|
}
|
|
@@ -246,7 +247,7 @@ function normalizeResponseHelper(serializer, store, modelClass, payload, id, req
|
|
|
246
247
|
*/
|
|
247
248
|
class Snapshot {
|
|
248
249
|
/**
|
|
249
|
-
The unique
|
|
250
|
+
The unique ResourceKey associated with this Snapshot.
|
|
250
251
|
@public
|
|
251
252
|
*/
|
|
252
253
|
|
|
@@ -482,7 +483,7 @@ class Snapshot {
|
|
|
482
483
|
}
|
|
483
484
|
const value = this._store.cache.getRelationship(identifier, keyName);
|
|
484
485
|
const data = value && value.data;
|
|
485
|
-
const inverseIdentifier = data ? store.
|
|
486
|
+
const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;
|
|
486
487
|
if (value && value.data !== undefined) {
|
|
487
488
|
const cache = store.cache;
|
|
488
489
|
if (inverseIdentifier && !cache.isDeleted(inverseIdentifier)) {
|
|
@@ -574,7 +575,7 @@ class Snapshot {
|
|
|
574
575
|
if (value.data) {
|
|
575
576
|
results = [];
|
|
576
577
|
value.data.forEach(member => {
|
|
577
|
-
const inverseIdentifier = store.
|
|
578
|
+
const inverseIdentifier = store.cacheKeyManager.getOrCreateRecordIdentifier(member);
|
|
578
579
|
const cache = store.cache;
|
|
579
580
|
if (!cache.isDeleted(inverseIdentifier)) {
|
|
580
581
|
if (returnModeIsIds) {
|
package/dist/adapter/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-
|
|
1
|
+
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-B59laYa4.js";
|
package/dist/adapter/json-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dasherize, pluralize } from '@warp-drive/utilities/string';
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
-
import { b as serializeIntoHash } from "../serialize-into-hash-
|
|
4
|
+
import { b as serializeIntoHash } from "../serialize-into-hash-B59laYa4.js";
|
|
5
5
|
import { RESTAdapter } from './rest.js';
|
|
6
6
|
class JSONAPIAdapter extends RESTAdapter {
|
|
7
7
|
_defaultContentType = 'application/vnd.api+json';
|
package/dist/adapter/rest.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import { computed } from '@ember/object';
|
|
4
4
|
import { Adapter, BuildURLMixin } from '../adapter.js';
|
|
5
|
-
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-
|
|
5
|
+
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-B59laYa4.js";
|
|
6
6
|
import { InvalidError, ServerError, ConflictError, NotFoundError, ForbiddenError, UnauthorizedError, AdapterError, TimeoutError, AbortError } from './error.js';
|
|
7
7
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
8
8
|
import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
package/dist/compat/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-
|
|
1
|
+
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-CVsFOW1k.js";
|
package/dist/compat.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getOwner } from '@ember/application';
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
3
|
import { waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
|
|
4
|
-
import
|
|
4
|
+
import '@warp-drive/core/reactive/-private';
|
|
5
|
+
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-CVsFOW1k.js";
|
|
5
6
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
7
|
function _findHasMany(adapter, store, identifier, link, relationship, options) {
|
|
7
8
|
const promise = Promise.resolve().then(() => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
2
|
+
import { memoized, defineSignal, defineNonEnumerableSignal, isResourceKey, recordIdentifierFor, storeFor, fastPush, createLegacyManyArray, notifyInternalSignal } from '@warp-drive/core/store/-private';
|
|
2
3
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
3
4
|
import { EnableHydration } from '@warp-drive/core/types/request';
|
|
4
|
-
import { u as upgradeStore } from "./-private-
|
|
5
|
+
import { u as upgradeStore } from "./-private-CVsFOW1k.js";
|
|
5
6
|
import { computed, get } from '@ember/object';
|
|
6
7
|
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
7
8
|
import ObjectProxy from '@ember/object/proxy';
|
|
@@ -420,7 +421,7 @@ class HasManyReference {
|
|
|
420
421
|
* An array of identifiers for the records that this reference refers to.
|
|
421
422
|
*
|
|
422
423
|
* @property identifiers
|
|
423
|
-
* @type {
|
|
424
|
+
* @type {ResourceKey[]}
|
|
424
425
|
* @public
|
|
425
426
|
*/
|
|
426
427
|
get identifiers() {
|
|
@@ -432,7 +433,7 @@ class HasManyReference {
|
|
|
432
433
|
this.___relatedTokenMap = new Map();
|
|
433
434
|
if (resource && resource.data) {
|
|
434
435
|
return resource.data.map(resourceIdentifier => {
|
|
435
|
-
const identifier = this.store.
|
|
436
|
+
const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
436
437
|
let token = map.get(identifier);
|
|
437
438
|
if (token) {
|
|
438
439
|
map.delete(identifier);
|
|
@@ -724,7 +725,7 @@ class HasManyReference {
|
|
|
724
725
|
throw new Error(`You must provide at least one of 'links', 'meta' or 'data' when calling hasManyReference.push`);
|
|
725
726
|
}
|
|
726
727
|
})('links' in dataDoc || 'meta' in dataDoc || 'data' in dataDoc) : {};
|
|
727
|
-
const identifiers = !Array.isArray(dataDoc.data) ? [] : isResourceData ? store._push(dataDoc, true) : dataDoc.data.map(i => store.
|
|
728
|
+
const identifiers = !Array.isArray(dataDoc.data) ? [] : isResourceData ? store._push(dataDoc, true) : dataDoc.data.map(i => store.cacheKeyManager.getOrCreateRecordIdentifier(i));
|
|
728
729
|
const {
|
|
729
730
|
identifier
|
|
730
731
|
} = this.hasManyRelationship;
|
|
@@ -1022,7 +1023,7 @@ class BelongsToReference {
|
|
|
1022
1023
|
* `null` if no related record is known.
|
|
1023
1024
|
*
|
|
1024
1025
|
* @property identifier
|
|
1025
|
-
* @type {
|
|
1026
|
+
* @type {ResourceKey | null}
|
|
1026
1027
|
* @public
|
|
1027
1028
|
*/
|
|
1028
1029
|
get identifier() {
|
|
@@ -1032,7 +1033,7 @@ class BelongsToReference {
|
|
|
1032
1033
|
}
|
|
1033
1034
|
const resource = this._resource();
|
|
1034
1035
|
if (resource && resource.data) {
|
|
1035
|
-
const identifier = this.store.
|
|
1036
|
+
const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resource.data);
|
|
1036
1037
|
this.___relatedToken = this.store.notifications.subscribe(identifier, (_, bucket, notifiedKey) => {
|
|
1037
1038
|
if (bucket === 'identity' || bucket === 'attributes' && notifiedKey === 'id') {
|
|
1038
1039
|
this._ref++;
|
|
@@ -1309,7 +1310,7 @@ class BelongsToReference {
|
|
|
1309
1310
|
store
|
|
1310
1311
|
} = this;
|
|
1311
1312
|
const isResourceData = doc.data && isMaybeResource(doc.data);
|
|
1312
|
-
const added = isResourceData ? store._push(doc, true) : doc.data ? store.
|
|
1313
|
+
const added = isResourceData ? store._push(doc, true) : doc.data ? store.cacheKeyManager.getOrCreateRecordIdentifier(doc.data) : null;
|
|
1313
1314
|
const {
|
|
1314
1315
|
identifier
|
|
1315
1316
|
} = this.belongsToRelationship;
|
|
@@ -1508,17 +1509,16 @@ function lookupLegacySupport(record) {
|
|
|
1508
1509
|
throw new Error(`Memory Leak Detected`);
|
|
1509
1510
|
}
|
|
1510
1511
|
})(!record.isDestroyed && !record.isDestroying) : {};
|
|
1511
|
-
support = new LegacySupport(record);
|
|
1512
|
+
support = new LegacySupport(record, identifier);
|
|
1512
1513
|
LEGACY_SUPPORT.set(identifier, support);
|
|
1513
|
-
LEGACY_SUPPORT.set(record, support);
|
|
1514
1514
|
}
|
|
1515
1515
|
return support;
|
|
1516
1516
|
}
|
|
1517
1517
|
class LegacySupport {
|
|
1518
|
-
constructor(record) {
|
|
1518
|
+
constructor(record, identifier) {
|
|
1519
1519
|
this.record = record;
|
|
1520
1520
|
this.store = storeFor(record, false);
|
|
1521
|
-
this.identifier =
|
|
1521
|
+
this.identifier = identifier;
|
|
1522
1522
|
this.cache = this.store.cache;
|
|
1523
1523
|
if (this.store._graph) {
|
|
1524
1524
|
this.graph = this.store._graph;
|
|
@@ -1534,7 +1534,7 @@ class LegacySupport {
|
|
|
1534
1534
|
if (this.isDestroyed || this.isDestroying) {
|
|
1535
1535
|
return;
|
|
1536
1536
|
}
|
|
1537
|
-
const currentState = array[
|
|
1537
|
+
const currentState = array[Context].source;
|
|
1538
1538
|
const identifier = this.identifier;
|
|
1539
1539
|
const [identifiers, jsonApi] = this._getCurrentState(identifier, array.key);
|
|
1540
1540
|
if (jsonApi.meta) {
|
|
@@ -1588,7 +1588,7 @@ class LegacySupport {
|
|
|
1588
1588
|
if (!test) {
|
|
1589
1589
|
throw new Error(`Expected a stable identifier`);
|
|
1590
1590
|
}
|
|
1591
|
-
})(!relatedIdentifier ||
|
|
1591
|
+
})(!relatedIdentifier || isResourceKey(relatedIdentifier)) : {};
|
|
1592
1592
|
const store = this.store;
|
|
1593
1593
|
const relationship = this.graph.get(this.identifier, key);
|
|
1594
1594
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -1648,7 +1648,7 @@ class LegacySupport {
|
|
|
1648
1648
|
if (!test) {
|
|
1649
1649
|
throw new Error(`Expected a stable identifier`);
|
|
1650
1650
|
}
|
|
1651
|
-
})(
|
|
1651
|
+
})(isResourceKey(relatedIdentifier)) : {};
|
|
1652
1652
|
if (cache.recordIsLoaded(relatedIdentifier, true)) {
|
|
1653
1653
|
identifiers.push(relatedIdentifier);
|
|
1654
1654
|
}
|
|
@@ -1664,23 +1664,20 @@ class LegacySupport {
|
|
|
1664
1664
|
}
|
|
1665
1665
|
if (!manyArray) {
|
|
1666
1666
|
const [identifiers, doc] = this._getCurrentState(this.identifier, key);
|
|
1667
|
-
manyArray =
|
|
1667
|
+
manyArray = createLegacyManyArray({
|
|
1668
1668
|
store: this.store,
|
|
1669
|
-
type: definition.type,
|
|
1670
|
-
identifier: this.identifier,
|
|
1671
|
-
cache: this.cache,
|
|
1672
|
-
field: this.store.schema.fields(this.identifier).get(key),
|
|
1673
|
-
identifiers,
|
|
1674
|
-
key,
|
|
1675
|
-
meta: doc.meta || null,
|
|
1676
|
-
links: doc.links || null,
|
|
1677
|
-
isPolymorphic: definition.isPolymorphic,
|
|
1678
|
-
isAsync: definition.isAsync,
|
|
1679
|
-
_inverseIsAsync: definition.inverseIsAsync,
|
|
1680
1669
|
// @ts-expect-error Typescript doesn't have a way for us to thread the generic backwards so it infers unknown instead of T
|
|
1681
1670
|
manager: this,
|
|
1671
|
+
source: identifiers,
|
|
1672
|
+
type: definition.type,
|
|
1682
1673
|
isLoaded: !definition.isAsync,
|
|
1683
|
-
|
|
1674
|
+
editable: true,
|
|
1675
|
+
isAsync: definition.isAsync,
|
|
1676
|
+
isPolymorphic: definition.isPolymorphic,
|
|
1677
|
+
field: this.store.schema.fields(this.identifier).get(key),
|
|
1678
|
+
identifier: this.identifier,
|
|
1679
|
+
links: doc.links || null,
|
|
1680
|
+
meta: doc.meta || null
|
|
1684
1681
|
});
|
|
1685
1682
|
this._manyArrayCache[key] = manyArray;
|
|
1686
1683
|
}
|
|
@@ -1901,7 +1898,7 @@ class LegacySupport {
|
|
|
1901
1898
|
if (!test) {
|
|
1902
1899
|
throw new Error(`Expected stable identifiers`);
|
|
1903
1900
|
}
|
|
1904
|
-
})(!identifiers || identifiers.every(
|
|
1901
|
+
})(!identifiers || identifiers.every(isResourceKey)) : {};
|
|
1905
1902
|
const req = field.options.linksMode ? {
|
|
1906
1903
|
url: getRelatedLink(resource),
|
|
1907
1904
|
op: 'findHasMany',
|
|
@@ -1936,7 +1933,7 @@ class LegacySupport {
|
|
|
1936
1933
|
if (!test) {
|
|
1937
1934
|
throw new Error(`Expected stable identifiers`);
|
|
1938
1935
|
}
|
|
1939
|
-
})(identifiers.every(
|
|
1936
|
+
})(identifiers.every(isResourceKey)) : {};
|
|
1940
1937
|
options.reload = options.reload || !attemptLocalCache || undefined;
|
|
1941
1938
|
return this.store.request({
|
|
1942
1939
|
op: 'findHasMany',
|
|
@@ -1975,7 +1972,7 @@ class LegacySupport {
|
|
|
1975
1972
|
if (!test) {
|
|
1976
1973
|
throw new Error(`Expected a stable identifier`);
|
|
1977
1974
|
}
|
|
1978
|
-
})(!identifier ||
|
|
1975
|
+
})(!identifier || isResourceKey(identifier)) : {};
|
|
1979
1976
|
const {
|
|
1980
1977
|
isStale,
|
|
1981
1978
|
hasDematerializedInverse,
|
|
@@ -2104,7 +2101,7 @@ function handleCompletedRelationshipRequest(recordExt, key, relationship, value,
|
|
|
2104
2101
|
if (isHasMany) {
|
|
2105
2102
|
// we don't notify the record property here to avoid refetch
|
|
2106
2103
|
// only the many array
|
|
2107
|
-
notifyInternalSignal(value[
|
|
2104
|
+
notifyInternalSignal(value[Context].signal);
|
|
2108
2105
|
}
|
|
2109
2106
|
if (error) {
|
|
2110
2107
|
relationship.state.hasFailedLoadAttempt = true;
|
|
@@ -2165,7 +2162,7 @@ function areAllInverseRecordsLoaded(store, resource) {
|
|
|
2165
2162
|
if (!test) {
|
|
2166
2163
|
throw new Error(`Expected stable identifiers`);
|
|
2167
2164
|
}
|
|
2168
|
-
})(identifiers.every(
|
|
2165
|
+
})(identifiers.every(isResourceKey)) : {};
|
|
2169
2166
|
// treat as collection
|
|
2170
2167
|
// check for unloaded records
|
|
2171
2168
|
return identifiers.every(identifier => instanceCache.recordIsLoaded(identifier));
|
|
@@ -2177,7 +2174,7 @@ function areAllInverseRecordsLoaded(store, resource) {
|
|
|
2177
2174
|
if (!test) {
|
|
2178
2175
|
throw new Error(`Expected stable identifiers`);
|
|
2179
2176
|
}
|
|
2180
|
-
})(
|
|
2177
|
+
})(isResourceKey(identifiers)) : {};
|
|
2181
2178
|
return instanceCache.recordIsLoaded(identifiers);
|
|
2182
2179
|
}
|
|
2183
2180
|
function isBelongsTo(relationship) {
|
package/dist/model/-private.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-
|
|
2
|
-
export { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';
|
|
1
|
+
export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-VSxXZooE.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { deprecate } from '@ember/debug';
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
|
-
import {
|
|
3
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
4
|
+
import { notifyInternalSignal } from '@warp-drive/core/store/-private';
|
|
4
5
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
5
6
|
import { Type } from '@warp-drive/core/types/symbols';
|
|
6
|
-
import { l as lookupLegacySupport, E as Errors } from "../errors-
|
|
7
|
-
import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-
|
|
7
|
+
import { l as lookupLegacySupport, E as Errors } from "../errors-VSxXZooE.js";
|
|
8
|
+
import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-BgBPZFfc.js";
|
|
8
9
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -344,7 +345,7 @@ function registerDerivations(schema) {
|
|
|
344
345
|
return false;
|
|
345
346
|
}
|
|
346
347
|
if (manyArray) {
|
|
347
|
-
notifyInternalSignal(manyArray[
|
|
348
|
+
notifyInternalSignal(manyArray[Context].signal);
|
|
348
349
|
return true;
|
|
349
350
|
}
|
|
350
351
|
return false;
|
package/dist/model.js
CHANGED
|
@@ -4,10 +4,10 @@ import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
|
4
4
|
import { i as isElementDescriptor, n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
6
|
import { warn, deprecate } from '@ember/debug';
|
|
7
|
-
import { l as lookupLegacySupport } from "./errors-
|
|
7
|
+
import { l as lookupLegacySupport } from "./errors-VSxXZooE.js";
|
|
8
8
|
import { singularize, dasherize } from '@warp-drive/utilities/string';
|
|
9
|
-
import { l as getModelFactory } from "./schema-provider-
|
|
10
|
-
export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-
|
|
9
|
+
import { l as getModelFactory } from "./schema-provider-BgBPZFfc.js";
|
|
10
|
+
export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-BgBPZFfc.js";
|
|
11
11
|
import { setOwner, getOwner } from '@ember/application';
|
|
12
12
|
import { setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
|
|
13
13
|
function _attr(type, options) {
|
|
@@ -2,12 +2,13 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { deprecate } from '@ember/debug';
|
|
3
3
|
import EmberObject from '@ember/object';
|
|
4
4
|
import { recordIdentifierFor, storeFor } from '@warp-drive/core';
|
|
5
|
-
import { notifyInternalSignal, peekInternalSignal, withSignalStore,
|
|
5
|
+
import { notifyInternalSignal, peekInternalSignal, withSignalStore, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
|
|
6
6
|
import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
7
|
-
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-
|
|
8
|
-
import { u as upgradeStore, F as FetchManager } from "./-private-
|
|
7
|
+
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-VSxXZooE.js";
|
|
8
|
+
import { u as upgradeStore, F as FetchManager } from "./-private-CVsFOW1k.js";
|
|
9
9
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
10
10
|
import { cacheFor } from '@ember/object/internals';
|
|
11
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
11
12
|
import { d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
|
|
12
13
|
import { n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
13
14
|
function rollbackAttributes() {
|
|
@@ -216,7 +217,7 @@ function notifyRelationship(identifier, key, record, meta) {
|
|
|
216
217
|
return;
|
|
217
218
|
}
|
|
218
219
|
if (manyArray) {
|
|
219
|
-
notifyInternalSignal(manyArray[
|
|
220
|
+
notifyInternalSignal(manyArray[Context].signal);
|
|
220
221
|
|
|
221
222
|
//We need to notifyPropertyChange in the adding case because we need to make sure
|
|
222
223
|
//we fetch the newly added record in case it is unloaded
|
|
@@ -736,9 +737,11 @@ class Model extends EmberObject {
|
|
|
736
737
|
this.___recordState?.destroy();
|
|
737
738
|
const store = storeFor(this, false);
|
|
738
739
|
store.notifications.unsubscribe(this.___private_notifications);
|
|
739
|
-
LEGACY_SUPPORT.get(
|
|
740
|
-
|
|
741
|
-
|
|
740
|
+
const support = LEGACY_SUPPORT.get(identifier);
|
|
741
|
+
if (support) {
|
|
742
|
+
support.destroy();
|
|
743
|
+
LEGACY_SUPPORT.delete(identifier);
|
|
744
|
+
}
|
|
742
745
|
super.destroy();
|
|
743
746
|
}
|
|
744
747
|
|
|
@@ -1035,7 +1038,7 @@ class Model extends EmberObject {
|
|
|
1035
1038
|
})(!didChange || identifier.id === null) : {};
|
|
1036
1039
|
if (normalizedId !== null && didChange) {
|
|
1037
1040
|
this.store._instanceCache.setRecordId(identifier, normalizedId);
|
|
1038
|
-
this.store.notifications.notify(identifier, 'identity');
|
|
1041
|
+
this.store.notifications.notify(identifier, 'identity', null);
|
|
1039
1042
|
}
|
|
1040
1043
|
}
|
|
1041
1044
|
toString() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
|
-
import '@warp-drive/core/
|
|
4
|
-
import "./-private-
|
|
3
|
+
import '@warp-drive/core/reactive/-private';
|
|
4
|
+
import "./-private-CVsFOW1k.js";
|
|
5
5
|
const newline = /\r?\n/;
|
|
6
6
|
function parseResponseHeaders(headersString) {
|
|
7
7
|
const headers = Object.create(null);
|
package/dist/store.js
CHANGED
|
@@ -399,7 +399,7 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
|
399
399
|
const normalizedId = ensureStringId(id);
|
|
400
400
|
resource = constructResource(type, normalizedId);
|
|
401
401
|
}
|
|
402
|
-
const identifier = this.
|
|
402
|
+
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resource);
|
|
403
403
|
options = options || {};
|
|
404
404
|
if (options.preload) {
|
|
405
405
|
// force reload if we preload to ensure we don't resolve the promise
|
|
@@ -543,7 +543,7 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
|
543
543
|
throw new Error('getReference expected to receive either a resource identifier or type and id as arguments');
|
|
544
544
|
}
|
|
545
545
|
})(isMaybeIdentifier(resourceIdentifier)) : {};
|
|
546
|
-
const identifier = this.
|
|
546
|
+
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
547
547
|
const cache = upgradeInstanceCaches(this._instanceCache.__instances).reference;
|
|
548
548
|
let reference = cache.get(identifier);
|
|
549
549
|
if (!reference) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/legacy",
|
|
3
|
-
"version": "5.7.0-alpha.
|
|
3
|
+
"version": "5.7.0-alpha.15",
|
|
4
4
|
"description": "Decommissioned Packages for WarpDrive | Things your app might still want to maintain use of for a little longer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@warp-drive/core": "5.7.0-alpha.
|
|
36
|
-
"@warp-drive/utilities": "5.7.0-alpha.
|
|
35
|
+
"@warp-drive/core": "5.7.0-alpha.15",
|
|
36
|
+
"@warp-drive/utilities": "5.7.0-alpha.15"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@embroider/macros": "^1.16.12"
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
44
44
|
"@babel/preset-typescript": "^7.27.0",
|
|
45
45
|
"@types/jquery": "^3.5.32",
|
|
46
|
-
"@warp-drive/internal-config": "5.7.0-alpha.
|
|
47
|
-
"@warp-drive/core": "5.7.0-alpha.
|
|
48
|
-
"@warp-drive/utilities": "5.7.0-alpha.
|
|
46
|
+
"@warp-drive/internal-config": "5.7.0-alpha.15",
|
|
47
|
+
"@warp-drive/core": "5.7.0-alpha.15",
|
|
48
|
+
"@warp-drive/utilities": "5.7.0-alpha.15",
|
|
49
49
|
"ember-source": "~6.3.0",
|
|
50
50
|
"decorator-transforms": "^2.3.0",
|
|
51
51
|
"expect-type": "^1.2.1",
|