@warp-drive/legacy 5.7.0-alpha.3 → 5.7.0-alpha.31
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
|
@@ -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,14 +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
|
-
_isReloading: boolean;
|
|
51
|
-
/** @internal */
|
|
52
|
-
[RecordStore]: Store;
|
|
53
43
|
/**
|
|
54
44
|
Create a JSON representation of the record, using the serialization
|
|
55
45
|
strategy of the store's adapter.
|
|
@@ -436,9 +426,7 @@ interface Model {
|
|
|
436
426
|
* @noInheritDoc
|
|
437
427
|
*/
|
|
438
428
|
declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
439
|
-
/** @
|
|
440
|
-
init(options: ModelCreateArgs): void;
|
|
441
|
-
/** @internal */
|
|
429
|
+
/** @private */
|
|
442
430
|
// @ts-expect-error destroy should not return a value, but ember's types force it to
|
|
443
431
|
destroy(): this;
|
|
444
432
|
/**
|
|
@@ -770,8 +758,6 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
770
758
|
*/
|
|
771
759
|
// @ts-expect-error no return is necessary, but Ember's types are forcing it
|
|
772
760
|
notifyPropertyChange(prop: string): this;
|
|
773
|
-
/** @internal */
|
|
774
|
-
attr(): void;
|
|
775
761
|
/**
|
|
776
762
|
Given a callback, iterates over each of the relationships in the model,
|
|
777
763
|
invoking the callback with the name of each relationship and its relationship
|
|
@@ -821,18 +807,14 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
821
807
|
```
|
|
822
808
|
|
|
823
809
|
@public
|
|
824
|
-
@param
|
|
825
|
-
@param
|
|
810
|
+
@param callback the callback to invoke
|
|
811
|
+
@param binding the value to which the callback's `this` should be bound
|
|
826
812
|
*/
|
|
827
813
|
eachRelationship<T>(callback: (this: NoInfer<T> | undefined, key: MaybeRelationshipFields<this>, meta: LegacyRelationshipField) => void, binding?: T): void;
|
|
828
814
|
relationshipFor(name: string): LegacyRelationshipField | undefined;
|
|
829
815
|
inverseFor(name: string): LegacyRelationshipField | null;
|
|
830
816
|
eachAttribute<T>(callback: (this: NoInfer<T> | undefined, key: isSubClass<this> extends true ? MaybeAttrFields<this> : string, meta: LegacyAttributeField) => void, binding?: T): void;
|
|
831
817
|
/**
|
|
832
|
-
* @internal
|
|
833
|
-
*/
|
|
834
|
-
static isModel: boolean;
|
|
835
|
-
/**
|
|
836
818
|
Represents the model's class name as a string. This can be used to look up the model's class name through
|
|
837
819
|
`Store`'s modelFor method.
|
|
838
820
|
|
|
@@ -894,9 +876,9 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
894
876
|
Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.
|
|
895
877
|
|
|
896
878
|
@public
|
|
897
|
-
@param
|
|
898
|
-
@param
|
|
899
|
-
@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
|
|
900
882
|
*/
|
|
901
883
|
static typeForRelationship(name: string, store: Store): ModelSchema | undefined;
|
|
902
884
|
static get inverseMap(): Record<string, LegacyRelationshipField | null>;
|
|
@@ -927,9 +909,9 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
927
909
|
```
|
|
928
910
|
|
|
929
911
|
@public
|
|
930
|
-
@param
|
|
931
|
-
@param
|
|
932
|
-
@return
|
|
912
|
+
@param name the name of the relationship
|
|
913
|
+
@param store
|
|
914
|
+
@return the inverse relationship, or null
|
|
933
915
|
*/
|
|
934
916
|
static inverseFor(name: string, store: Store): LegacyRelationshipField | null;
|
|
935
917
|
//Calculate the inverse, ignoring the cache
|
|
@@ -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,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,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";
|
|
@@ -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,34 +246,10 @@ 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
|
-
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
252
|
+
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
253
253
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
254
|
-
/**
|
|
255
|
-
* This is an internal method used to register behaviors for legacy mode.
|
|
256
|
-
* It is not intended for public use.
|
|
257
|
-
*
|
|
258
|
-
* We do think a generalized `kind` registration system would be useful,
|
|
259
|
-
* but we have not yet designed it.
|
|
260
|
-
*
|
|
261
|
-
* See https://github.com/emberjs/data/issues/9534
|
|
262
|
-
*
|
|
263
|
-
* @internal
|
|
264
|
-
*/
|
|
265
|
-
_registerMode(mode: string, kinds: unknown): void;
|
|
266
|
-
/**
|
|
267
|
-
* This is an internal method used to enable legacy behaviors for legacy mode.
|
|
268
|
-
* It is not intended for public use.
|
|
269
|
-
*
|
|
270
|
-
* We do think a generalized `kind` registration system would be useful,
|
|
271
|
-
* but we have not yet designed it.
|
|
272
|
-
*
|
|
273
|
-
* See https://github.com/emberjs/data/issues/9534
|
|
274
|
-
*
|
|
275
|
-
* @internal
|
|
276
|
-
*/
|
|
277
|
-
_kind(mode: string, kind: "belongsTo" | "hasMany"): () => unknown;
|
|
278
254
|
}
|
|
279
255
|
export {};
|
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
import type {
|
|
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:
|
|
9
|
-
export interface BaseFinderOptions
|
|
8
|
+
export declare function preloadData(store: Store, identifier: NewResourceKey, preload: Record<string, Value>): void;
|
|
9
|
+
export interface BaseFinderOptions {
|
|
10
10
|
reload?: boolean;
|
|
11
11
|
backgroundReload?: boolean;
|
|
12
|
-
include?:
|
|
12
|
+
include?: string | string[];
|
|
13
13
|
adapterOptions?: Record<string, unknown>;
|
|
14
14
|
}
|
|
15
|
-
export interface FindRecordOptions
|
|
15
|
+
export interface FindRecordOptions extends BaseFinderOptions {
|
|
16
16
|
/**
|
|
17
17
|
* Data to preload into the store before the request is made.
|
|
18
18
|
* This feature is *highly* discouraged and has no corresponding
|
|
@@ -31,9 +31,9 @@ export interface FindRecordOptions<T = unknown> extends BaseFinderOptions<T> {
|
|
|
31
31
|
preload?: Record<string, Value>;
|
|
32
32
|
}
|
|
33
33
|
export type QueryOptions = { [K in string | "adapterOptions"]? : K extends "adapterOptions" ? Record<string, unknown> : unknown };
|
|
34
|
-
export type FindAllOptions
|
|
35
|
-
export type LegacyResourceQuery
|
|
36
|
-
include?:
|
|
34
|
+
export type FindAllOptions = BaseFinderOptions;
|
|
35
|
+
export type LegacyResourceQuery = {
|
|
36
|
+
include?: string | string[];
|
|
37
37
|
[key: string]: Value | undefined;
|
|
38
38
|
};
|
|
39
39
|
export type KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;
|
|
@@ -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.
|
|
@@ -64,18 +64,7 @@ addon authors to perform meta-operations on a record.
|
|
|
64
64
|
@public
|
|
65
65
|
*/
|
|
66
66
|
export declare class RecordReference {
|
|
67
|
-
|
|
68
|
-
private store;
|
|
69
|
-
/** @internal */
|
|
70
|
-
// unsubscribe token given to us by the notification manager
|
|
71
|
-
private ___token;
|
|
72
|
-
/** @internal */
|
|
73
|
-
private ___identifier;
|
|
74
|
-
/** @internal */
|
|
75
|
-
private _ref;
|
|
76
|
-
constructor(store: Store, identifier: StableRecordIdentifier);
|
|
77
|
-
/** @internal */
|
|
78
|
-
destroy(): void;
|
|
67
|
+
constructor(store: Store, identifier: ResourceKey);
|
|
79
68
|
get type(): string;
|
|
80
69
|
/**
|
|
81
70
|
The `id` of the record that this reference refers to.
|
|
@@ -112,7 +101,7 @@ export declare class RecordReference {
|
|
|
112
101
|
@public
|
|
113
102
|
@return The identifier of the record.
|
|
114
103
|
*/
|
|
115
|
-
identifier():
|
|
104
|
+
identifier(): ResourceKey;
|
|
116
105
|
/**
|
|
117
106
|
How the reference will be looked up when it is loaded. Currently
|
|
118
107
|
this always returns `identity` to signify that a record will be
|