@warp-drive/legacy 5.6.0-beta.1 → 5.6.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -7
- package/declarations/adapter/error.d.ts +2 -2
- 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 +63 -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 +18 -27
- package/declarations/model/-private/model-methods.d.ts +3 -4
- package/declarations/model/-private/model.d.ts +14 -29
- 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 -10
- package/declarations/model/-private.d.ts +2 -1
- package/declarations/model/migration-support.d.ts +11 -53
- package/declarations/model.d.ts +1 -1
- package/declarations/store/-private.d.ts +224 -0
- package/declarations/store.d.ts +3 -0
- package/dist/{-private-CKrP0ogQ.js → -private-8UmnAf9J.js} +169 -141
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +66 -0
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +2 -2
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +4 -23
- package/dist/compat.js +7 -2
- package/dist/{errors-BX5wowuz.js → errors-8kD2mSe_.js} +66 -36
- package/dist/model/-private.js +1 -2
- package/dist/model/migration-support.js +96 -11
- package/dist/model.js +14 -11
- package/dist/{schema-provider-BdQhkT-Q.js → schema-provider-DQu4Rjco.js} +165 -60
- package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-CS0MIv4F.js} +2 -1
- package/dist/store.js +633 -0
- package/dist/util-Dul6TZts.js +35 -0
- package/dist/utils-Cqw9eRj5.js +23 -0
- package/package.json +14 -14
|
@@ -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>;
|
|
@@ -32,9 +28,12 @@ export declare function hasMany<
|
|
|
32
28
|
K extends MaybeHasManyFields<T>
|
|
33
29
|
>(this: T, prop: K): HasManyReference<T, K>;
|
|
34
30
|
export declare function reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
|
|
31
|
+
export declare function _reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
|
|
35
32
|
export declare function changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash;
|
|
36
33
|
export declare function serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): unknown;
|
|
37
34
|
export declare function deleteRecord<T extends MinimalLegacyRecord>(this: T): void;
|
|
38
35
|
export declare function save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
|
|
36
|
+
export declare function _save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
|
|
39
37
|
export declare function destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
|
|
38
|
+
export declare function _destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
|
|
40
39
|
export declare function createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import EmberObject from "@ember/object";
|
|
2
2
|
import type { Store } from "@warp-drive/core";
|
|
3
|
-
import type { ModelSchema,
|
|
4
|
-
import type {
|
|
3
|
+
import type { ModelSchema, ResourceKey } from "@warp-drive/core/types";
|
|
4
|
+
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
5
5
|
import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
6
|
-
import { RecordStore } from "@warp-drive/core/types/symbols";
|
|
7
6
|
import type { Snapshot } from "../../compat/-private.js";
|
|
8
7
|
import { Errors } from "./errors.js";
|
|
9
8
|
import type { MinimalLegacyRecord } from "./model-methods.js";
|
|
@@ -15,10 +14,9 @@ export type ModelCreateArgs = {
|
|
|
15
14
|
_createProps: Record<string, unknown>;
|
|
16
15
|
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
17
16
|
_secretInit: {
|
|
18
|
-
identifier:
|
|
19
|
-
cache: Cache;
|
|
17
|
+
identifier: ResourceKey;
|
|
20
18
|
store: Store;
|
|
21
|
-
cb: (record: Model,
|
|
19
|
+
cb: (record: Model, identifier: ResourceKey, store: Store) => void;
|
|
22
20
|
};
|
|
23
21
|
};
|
|
24
22
|
export type StaticModel = typeof Model & {
|
|
@@ -42,12 +40,6 @@ interface Model {
|
|
|
42
40
|
* The store service instance which created this record instance
|
|
43
41
|
*/
|
|
44
42
|
store: Store;
|
|
45
|
-
/** @internal */
|
|
46
|
-
___recordState: RecordState;
|
|
47
|
-
/** @internal */
|
|
48
|
-
___private_notifications: object;
|
|
49
|
-
/** @internal */
|
|
50
|
-
[RecordStore]: Store;
|
|
51
43
|
/**
|
|
52
44
|
Create a JSON representation of the record, using the serialization
|
|
53
45
|
strategy of the store's adapter.
|
|
@@ -434,9 +426,7 @@ interface Model {
|
|
|
434
426
|
* @noInheritDoc
|
|
435
427
|
*/
|
|
436
428
|
declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
437
|
-
/** @
|
|
438
|
-
init(options: ModelCreateArgs): void;
|
|
439
|
-
/** @internal */
|
|
429
|
+
/** @private */
|
|
440
430
|
// @ts-expect-error destroy should not return a value, but ember's types force it to
|
|
441
431
|
destroy(): this;
|
|
442
432
|
/**
|
|
@@ -768,8 +758,6 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
768
758
|
*/
|
|
769
759
|
// @ts-expect-error no return is necessary, but Ember's types are forcing it
|
|
770
760
|
notifyPropertyChange(prop: string): this;
|
|
771
|
-
/** @internal */
|
|
772
|
-
attr(): void;
|
|
773
761
|
/**
|
|
774
762
|
Given a callback, iterates over each of the relationships in the model,
|
|
775
763
|
invoking the callback with the name of each relationship and its relationship
|
|
@@ -819,18 +807,14 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
819
807
|
```
|
|
820
808
|
|
|
821
809
|
@public
|
|
822
|
-
@param
|
|
823
|
-
@param
|
|
810
|
+
@param callback the callback to invoke
|
|
811
|
+
@param binding the value to which the callback's `this` should be bound
|
|
824
812
|
*/
|
|
825
813
|
eachRelationship<T>(callback: (this: NoInfer<T> | undefined, key: MaybeRelationshipFields<this>, meta: LegacyRelationshipField) => void, binding?: T): void;
|
|
826
814
|
relationshipFor(name: string): LegacyRelationshipField | undefined;
|
|
827
815
|
inverseFor(name: string): LegacyRelationshipField | null;
|
|
828
816
|
eachAttribute<T>(callback: (this: NoInfer<T> | undefined, key: isSubClass<this> extends true ? MaybeAttrFields<this> : string, meta: LegacyAttributeField) => void, binding?: T): void;
|
|
829
817
|
/**
|
|
830
|
-
* @internal
|
|
831
|
-
*/
|
|
832
|
-
static isModel: boolean;
|
|
833
|
-
/**
|
|
834
818
|
Represents the model's class name as a string. This can be used to look up the model's class name through
|
|
835
819
|
`Store`'s modelFor method.
|
|
836
820
|
|
|
@@ -892,9 +876,9 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
892
876
|
Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.
|
|
893
877
|
|
|
894
878
|
@public
|
|
895
|
-
@param
|
|
896
|
-
@param
|
|
897
|
-
@return
|
|
879
|
+
@param name the name of the relationship
|
|
880
|
+
@param store an instance of Store
|
|
881
|
+
@return the type of the relationship, or undefined
|
|
898
882
|
*/
|
|
899
883
|
static typeForRelationship(name: string, store: Store): ModelSchema | undefined;
|
|
900
884
|
static get inverseMap(): Record<string, LegacyRelationshipField | null>;
|
|
@@ -925,9 +909,9 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
925
909
|
```
|
|
926
910
|
|
|
927
911
|
@public
|
|
928
|
-
@param
|
|
929
|
-
@param
|
|
930
|
-
@return
|
|
912
|
+
@param name the name of the relationship
|
|
913
|
+
@param store
|
|
914
|
+
@return the inverse relationship, or null
|
|
931
915
|
*/
|
|
932
916
|
static inverseFor(name: string, store: Store): LegacyRelationshipField | null;
|
|
933
917
|
//Calculate the inverse, ignoring the cache
|
|
@@ -1319,4 +1303,5 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
1319
1303
|
*/
|
|
1320
1304
|
static toString(): string;
|
|
1321
1305
|
}
|
|
1306
|
+
export declare function restoreDeprecatedModelRequestBehaviors(ModelKlass: typeof Model): void;
|
|
1322
1307
|
export { 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;
|
|
@@ -128,8 +128,5 @@ export declare class PromiseManyArray<T = unknown> {
|
|
|
128
128
|
* @public
|
|
129
129
|
*/
|
|
130
130
|
get meta(): Record<string, unknown> | null | undefined;
|
|
131
|
-
//---- Our own stuff
|
|
132
|
-
/** @internal */
|
|
133
|
-
_update(promise: Promise<ManyArray<T>>, content?: ManyArray<T>): void;
|
|
134
131
|
static create<T>({ promise, content }: HasManyProxyCreateArgs<T>): PromiseManyArray<T>;
|
|
135
132
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import type { Store } from "@warp-drive/core";
|
|
2
|
-
import type { RequestCacheRequestState, RequestStateService } from "@warp-drive/core/store/-private";
|
|
3
|
-
import type { Cache } from "@warp-drive/core/types/cache";
|
|
4
|
-
import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
|
|
5
|
-
import type { Errors } from "./errors.js";
|
|
6
1
|
import type { MinimalLegacyRecord } from "./model-methods.js";
|
|
7
2
|
/**
|
|
8
3
|
Historically EmberData managed a state machine
|
|
@@ -41,29 +36,11 @@ uncommitted
|
|
|
41
36
|
invalid
|
|
42
37
|
inFlight
|
|
43
38
|
|
|
44
|
-
@
|
|
39
|
+
@hideconstructor
|
|
40
|
+
@private
|
|
45
41
|
*/
|
|
46
42
|
export default class RecordState {
|
|
47
|
-
store: Store;
|
|
48
|
-
identifier: StableRecordIdentifier;
|
|
49
|
-
record: MinimalLegacyRecord;
|
|
50
|
-
rs: RequestStateService;
|
|
51
|
-
pendingCount: number;
|
|
52
|
-
fulfilledCount: number;
|
|
53
|
-
rejectedCount: number;
|
|
54
|
-
cache: Cache;
|
|
55
|
-
_errorRequests: RequestCacheRequestState[];
|
|
56
|
-
_lastError: RequestCacheRequestState | null;
|
|
57
|
-
handler: object;
|
|
58
43
|
constructor(record: MinimalLegacyRecord);
|
|
59
|
-
/** @internal */
|
|
60
|
-
destroy(): void;
|
|
61
|
-
/** @internal */
|
|
62
|
-
notify(key: keyof this & string): void;
|
|
63
|
-
/** @internal */
|
|
64
|
-
updateInvalidErrors(errors: Errors): void;
|
|
65
|
-
/** @internal */
|
|
66
|
-
cleanErrorRequests(): void;
|
|
67
44
|
isSaving: boolean;
|
|
68
45
|
get isLoading(): boolean;
|
|
69
46
|
get isLoaded(): boolean;
|
|
@@ -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,24 +68,18 @@ 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:
|
|
75
|
-
/**
|
|
76
|
-
* This method should never be called by user code.
|
|
77
|
-
*
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
destroy(): void;
|
|
74
|
+
constructor(store: Store, graph: Graph, parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
|
|
81
75
|
/**
|
|
82
76
|
* An array of identifiers for the records that this reference refers to.
|
|
83
77
|
*
|
|
84
78
|
* @property identifiers
|
|
85
|
-
* @type {
|
|
79
|
+
* @type {ResourceKey[]}
|
|
86
80
|
* @public
|
|
87
81
|
*/
|
|
88
|
-
get identifiers():
|
|
82
|
+
get identifiers(): ResourceKey<TypeFromInstanceOrString<Related>>[];
|
|
89
83
|
_resource(): CollectionResourceRelationship;
|
|
90
84
|
/**
|
|
91
85
|
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,22 +8,19 @@ 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;
|
|
18
18
|
}
|
|
19
19
|
export declare class ModelSchemaProvider implements SchemaService {
|
|
20
|
-
private store;
|
|
21
|
-
private _schemas;
|
|
22
|
-
private _typeMisses;
|
|
23
20
|
constructor(store: ModelStore);
|
|
24
21
|
resourceTypes(): Readonly<string[]>;
|
|
25
22
|
hasTrait(type: string): boolean;
|
|
26
|
-
resourceHasTrait(resource:
|
|
23
|
+
resourceHasTrait(resource: ResourceKey | {
|
|
27
24
|
type: string;
|
|
28
25
|
}, trait: string): boolean;
|
|
29
26
|
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
@@ -35,7 +32,7 @@ export declare class ModelSchemaProvider implements SchemaService {
|
|
|
35
32
|
hashFn(field: HashField | {
|
|
36
33
|
type: string;
|
|
37
34
|
}): HashFn;
|
|
38
|
-
resource(resource:
|
|
35
|
+
resource(resource: ResourceKey | {
|
|
39
36
|
type: string;
|
|
40
37
|
}): ResourceSchema | ObjectSchema;
|
|
41
38
|
registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
|
|
@@ -47,8 +44,7 @@ export declare class ModelSchemaProvider implements SchemaService {
|
|
|
47
44
|
FM extends ObjectValue | null
|
|
48
45
|
>(derivation: Derivation<R, T, FM>): void;
|
|
49
46
|
registerHashFn(hashFn: HashFn): void;
|
|
50
|
-
|
|
51
|
-
fields(resource: RecordIdentifier | {
|
|
47
|
+
fields(resource: ResourceKey | {
|
|
52
48
|
type: string;
|
|
53
49
|
}): Map<string, LegacyField>;
|
|
54
50
|
hasResource(resource: {
|
|
@@ -1,8 +1,9 @@
|
|
|
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
|
|
8
8
|
export { lookupLegacySupport, LEGACY_SUPPORT } from "./-private/legacy-relationships-support.js";
|
|
9
|
+
export type { MaybeHasManyFields, MaybeBelongsToFields, MaybeRelationshipFields } from "./-private/type-utils.js";
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module provides support for migrating away from @ember-data/model
|
|
3
|
-
* to @warp-drive/schema-record.
|
|
4
|
-
*
|
|
5
|
-
* It includes:
|
|
6
|
-
*
|
|
7
|
-
* - A `withDefaults` function to assist in creating a schema in LegacyMode
|
|
8
|
-
* - A `registerDerivations` function to register the derivations necessary to support LegacyMode
|
|
9
|
-
* - A `DelegatingSchemaService` that can be used to provide a schema service that works with both
|
|
10
|
-
* @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes.
|
|
11
|
-
* - A `WithLegacy` type util that can be used to create a type that includes the legacy
|
|
12
|
-
* properties and methods of a record.
|
|
13
|
-
*
|
|
14
|
-
* Using LegacyMode features on a ReactiveResource *requires* the use of these derivations and schema
|
|
15
|
-
* additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone
|
|
16
|
-
* to assist in more rapidly adopting modern WarpDrive features.
|
|
17
|
-
*
|
|
18
|
-
* @module
|
|
19
|
-
*/
|
|
20
1
|
import type { Store } from "@warp-drive/core";
|
|
21
2
|
import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "@warp-drive/core/reactive";
|
|
22
3
|
import type { ExtensibleField } from "@warp-drive/core/reactive/-private/schema";
|
|
23
4
|
import type { SchemaService } from "@warp-drive/core/types";
|
|
24
5
|
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
25
|
-
import type {
|
|
6
|
+
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
26
7
|
import type { ObjectValue } from "@warp-drive/core/types/json/raw";
|
|
27
8
|
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
28
9
|
import type { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schema/concepts";
|
|
@@ -170,6 +151,7 @@ export type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
|
170
151
|
* @public
|
|
171
152
|
*/
|
|
172
153
|
export declare function withDefaults(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
154
|
+
export declare function withRestoredDeprecatedModelRequestBehaviors(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
173
155
|
/**
|
|
174
156
|
* A function which registers the necessary derivations to support
|
|
175
157
|
* the LegacyMode features of @ember-data/model while migrating to WarpDrive.
|
|
@@ -216,10 +198,10 @@ export declare function registerDerivations(schema: SchemaService): void;
|
|
|
216
198
|
* @public
|
|
217
199
|
*/
|
|
218
200
|
export interface DelegatingSchemaService {
|
|
219
|
-
attributesDefinitionFor?(resource:
|
|
201
|
+
attributesDefinitionFor?(resource: ResourceKey | {
|
|
220
202
|
type: string;
|
|
221
203
|
}): AttributesSchema;
|
|
222
|
-
relationshipsDefinitionFor?(resource:
|
|
204
|
+
relationshipsDefinitionFor?(resource: ResourceKey | {
|
|
223
205
|
type: string;
|
|
224
206
|
}): RelationshipsSchema;
|
|
225
207
|
doesTypeExist?(type: string): boolean;
|
|
@@ -228,18 +210,18 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
228
210
|
_preferred: SchemaService;
|
|
229
211
|
_secondary: SchemaService;
|
|
230
212
|
constructor(store: Store, schema: SchemaService);
|
|
231
|
-
isDelegated(resource:
|
|
213
|
+
isDelegated(resource: ResourceKey | {
|
|
232
214
|
type: string;
|
|
233
215
|
}): boolean;
|
|
234
216
|
resourceTypes(): Readonly<string[]>;
|
|
235
|
-
hasResource(resource:
|
|
217
|
+
hasResource(resource: ResourceKey | {
|
|
236
218
|
type: string;
|
|
237
219
|
}): boolean;
|
|
238
220
|
hasTrait(type: string): boolean;
|
|
239
|
-
resourceHasTrait(resource:
|
|
221
|
+
resourceHasTrait(resource: ResourceKey | {
|
|
240
222
|
type: string;
|
|
241
223
|
}, trait: string): boolean;
|
|
242
|
-
fields(resource:
|
|
224
|
+
fields(resource: ResourceKey | {
|
|
243
225
|
type: string;
|
|
244
226
|
}): Map<string, FieldSchema>;
|
|
245
227
|
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
@@ -251,7 +233,7 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
251
233
|
derivation(field: DerivedField | {
|
|
252
234
|
type: string;
|
|
253
235
|
}): Derivation;
|
|
254
|
-
resource(resource:
|
|
236
|
+
resource(resource: ResourceKey | {
|
|
255
237
|
type: string;
|
|
256
238
|
}): ResourceSchema | ObjectSchema;
|
|
257
239
|
registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
|
|
@@ -264,34 +246,10 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
264
246
|
>(derivation: Derivation<R, T, FM>): void;
|
|
265
247
|
registerHashFn(hashFn: HashFn): void;
|
|
266
248
|
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
|
|
267
|
-
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource:
|
|
249
|
+
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
|
|
268
250
|
type: string;
|
|
269
251
|
}): null | ProcessedExtension["features"];
|
|
270
|
-
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
252
|
+
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
271
253
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
272
|
-
/**
|
|
273
|
-
* This is an internal method used to register behaviors for legacy mode.
|
|
274
|
-
* It is not intended for public use.
|
|
275
|
-
*
|
|
276
|
-
* We do think a generalized `kind` registration system would be useful,
|
|
277
|
-
* but we have not yet designed it.
|
|
278
|
-
*
|
|
279
|
-
* See https://github.com/emberjs/data/issues/9534
|
|
280
|
-
*
|
|
281
|
-
* @internal
|
|
282
|
-
*/
|
|
283
|
-
_registerMode(mode: string, kinds: unknown): void;
|
|
284
|
-
/**
|
|
285
|
-
* This is an internal method used to enable legacy behaviors for legacy mode.
|
|
286
|
-
* It is not intended for public use.
|
|
287
|
-
*
|
|
288
|
-
* We do think a generalized `kind` registration system would be useful,
|
|
289
|
-
* but we have not yet designed it.
|
|
290
|
-
*
|
|
291
|
-
* See https://github.com/emberjs/data/issues/9534
|
|
292
|
-
*
|
|
293
|
-
* @internal
|
|
294
|
-
*/
|
|
295
|
-
_kind(mode: string, kind: "belongsTo" | "hasMany"): () => unknown;
|
|
296
254
|
}
|
|
297
255
|
export {};
|
package/declarations/model.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ and dasherized.
|
|
|
39
39
|
export { attr } from "./model/-private/attr.js";
|
|
40
40
|
export { belongsTo } from "./model/-private/belongs-to.js";
|
|
41
41
|
export { hasMany } from "./model/-private/has-many.js";
|
|
42
|
-
export { Model } from "./model/-private/model.js";
|
|
42
|
+
export { Model, restoreDeprecatedModelRequestBehaviors } from "./model/-private/model.js";
|
|
43
43
|
export { Model as default } from "./model/-private/model.js";
|
|
44
44
|
export type { PromiseBelongsTo as AsyncBelongsTo } from "./model/-private/promise-belongs-to.js";
|
|
45
45
|
export type { PromiseManyArray as AsyncHasMany } from "./model/-private/promise-many-array.js";
|