@warp-drive/legacy 5.6.0-alpha.14 → 5.6.0-alpha.17
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/build-url-mixin.d.ts +41 -29
- package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
- package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
- package/declarations/adapter/-private.d.ts +5 -6
- package/declarations/adapter/error.d.ts +206 -178
- package/declarations/adapter/json-api.d.ts +206 -207
- package/declarations/adapter/rest.d.ts +805 -808
- package/declarations/adapter.d.ts +742 -766
- package/declarations/compat/-private.d.ts +10 -11
- package/declarations/compat/builders/find-all.d.ts +26 -24
- package/declarations/compat/builders/find-record.d.ts +41 -39
- package/declarations/compat/builders/query.d.ts +50 -45
- package/declarations/compat/builders/save-record.d.ts +26 -24
- package/declarations/compat/builders/utils.d.ts +1 -2
- package/declarations/compat/builders.d.ts +10 -11
- package/declarations/compat/extensions.d.ts +59 -0
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
- package/declarations/compat/utils.d.ts +118 -119
- package/declarations/compat.d.ts +106 -104
- package/declarations/model/-private/attr.d.ts +164 -145
- package/declarations/model/-private/belongs-to.d.ts +135 -122
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/model/-private/errors.d.ts +272 -267
- package/declarations/model/-private/has-many.d.ts +119 -116
- package/declarations/model/-private/hooks.d.ts +5 -6
- package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
- package/declarations/model/-private/model-for-mixin.d.ts +18 -3
- package/declarations/model/-private/model-methods.d.ts +29 -24
- package/declarations/model/-private/model.d.ts +1306 -1254
- package/declarations/model/-private/notify-changes.d.ts +3 -4
- package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
- package/declarations/model/-private/promise-many-array.d.ts +125 -116
- package/declarations/model/-private/record-state.d.ts +63 -60
- package/declarations/model/-private/references/belongs-to.d.ts +491 -487
- package/declarations/model/-private/references/has-many.d.ts +495 -492
- package/declarations/model/-private/schema-provider.d.ts +53 -56
- package/declarations/model/-private/type-utils.d.ts +41 -41
- package/declarations/model/-private/util.d.ts +1 -2
- package/declarations/model/-private.d.ts +8 -8
- package/declarations/model/migration-support.d.ts +281 -271
- package/declarations/model.d.ts +48 -49
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
- package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
- package/declarations/serializer/-private/transforms/date.d.ts +22 -22
- package/declarations/serializer/-private/transforms/number.d.ts +22 -22
- package/declarations/serializer/-private/transforms/string.d.ts +22 -22
- package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
- package/declarations/serializer/-private/utils.d.ts +0 -1
- package/declarations/serializer/json-api.d.ts +124 -494
- package/declarations/serializer/json.d.ts +62 -1031
- package/declarations/serializer/rest.d.ts +52 -552
- package/declarations/serializer/transform.d.ts +5 -6
- package/declarations/serializer.d.ts +217 -218
- package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +17 -0
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +5 -7
- package/dist/adapter.js +6 -35
- package/dist/compat/-private.js +1 -1
- package/dist/compat/extensions.js +243 -0
- package/dist/compat.js +3 -4
- package/dist/{errors-D74uk36r.js → errors-BX5wowuz.js} +12 -10
- package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +15 -4
- package/dist/model.js +3 -3
- package/dist/{schema-provider-CXFLTMjg.js → schema-provider-BdQhkT-Q.js} +20 -13
- package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
- package/dist/serializer/json-api.js +42 -2
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +46 -41
- package/dist/serializer/transform.js +0 -44
- package/package.json +7 -7
- package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
- package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
- package/declarations/adapter/-private.d.ts.map +0 -1
- package/declarations/adapter/error.d.ts.map +0 -1
- package/declarations/adapter/json-api.d.ts.map +0 -1
- package/declarations/adapter/rest.d.ts.map +0 -1
- package/declarations/adapter.d.ts.map +0 -1
- package/declarations/compat/-private.d.ts.map +0 -1
- package/declarations/compat/builders/find-all.d.ts.map +0 -1
- package/declarations/compat/builders/find-record.d.ts.map +0 -1
- package/declarations/compat/builders/query.d.ts.map +0 -1
- package/declarations/compat/builders/save-record.d.ts.map +0 -1
- package/declarations/compat/builders/utils.d.ts.map +0 -1
- package/declarations/compat/builders.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
- package/declarations/compat/utils.d.ts.map +0 -1
- package/declarations/compat.d.ts.map +0 -1
- package/declarations/model/-private/attr.d.ts.map +0 -1
- package/declarations/model/-private/attr.type-test.d.ts +0 -2
- package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
- package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/model/-private/errors.d.ts.map +0 -1
- package/declarations/model/-private/has-many.d.ts.map +0 -1
- package/declarations/model/-private/has-many.type-test.d.ts +0 -2
- package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
- package/declarations/model/-private/hooks.d.ts.map +0 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
- package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
- package/declarations/model/-private/model-methods.d.ts.map +0 -1
- package/declarations/model/-private/model.d.ts.map +0 -1
- package/declarations/model/-private/model.type-test.d.ts +0 -2
- package/declarations/model/-private/model.type-test.d.ts.map +0 -1
- package/declarations/model/-private/notify-changes.d.ts.map +0 -1
- package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
- package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
- package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
- package/declarations/model/-private/record-state.d.ts.map +0 -1
- package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/references/has-many.d.ts.map +0 -1
- package/declarations/model/-private/schema-provider.d.ts.map +0 -1
- package/declarations/model/-private/type-utils.d.ts.map +0 -1
- package/declarations/model/-private/util.d.ts.map +0 -1
- package/declarations/model/-private.d.ts.map +0 -1
- package/declarations/model/migration-support.d.ts.map +0 -1
- package/declarations/model/migration-support.type-test.d.ts +0 -2
- package/declarations/model/migration-support.type-test.d.ts.map +0 -1
- package/declarations/model.d.ts.map +0 -1
- package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
- package/declarations/serializer/-private/utils.d.ts.map +0 -1
- package/declarations/serializer/json-api.d.ts.map +0 -1
- package/declarations/serializer/json.d.ts.map +0 -1
- package/declarations/serializer/rest.d.ts.map +0 -1
- package/declarations/serializer/transform.d.ts.map +0 -1
- package/declarations/serializer.d.ts.map +0 -1
- package/dist/-private-DFfBszo5.js.map +0 -1
- package/dist/adapter/-private.js.map +0 -1
- package/dist/adapter/error.js.map +0 -1
- package/dist/adapter/json-api.js.map +0 -1
- package/dist/adapter/rest.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/compat/-private.js.map +0 -1
- package/dist/compat/builders.js.map +0 -1
- package/dist/compat/utils.js.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/errors-D74uk36r.js.map +0 -1
- package/dist/json-DSOlH9A8.js.map +0 -1
- package/dist/model/-private.js.map +0 -1
- package/dist/model/migration-support.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
- package/dist/schema-provider-CXFLTMjg.js.map +0 -1
- package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
- package/dist/serializer/json-api.js.map +0 -1
- package/dist/serializer/json.js.map +0 -1
- package/dist/serializer/rest.js.map +0 -1
- package/dist/serializer/transform.js.map +0 -1
- package/dist/serializer.js.map +0 -1
|
@@ -1,287 +1,297 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import type { Store } from
|
|
21
|
-
import type {
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
24
|
-
import type {
|
|
25
|
-
import type {
|
|
26
|
-
import type {
|
|
27
|
-
import type {
|
|
28
|
-
import type {
|
|
29
|
-
import type {
|
|
30
|
-
import type {
|
|
31
|
-
import {
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import type
|
|
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
|
+
import type { Store } from "@warp-drive/core";
|
|
21
|
+
import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "@warp-drive/core/reactive";
|
|
22
|
+
import type { ExtensibleField } from "@warp-drive/core/reactive/-private/schema";
|
|
23
|
+
import type { SchemaService } from "@warp-drive/core/types";
|
|
24
|
+
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
25
|
+
import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
|
|
26
|
+
import type { ObjectValue } from "@warp-drive/core/types/json/raw";
|
|
27
|
+
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
28
|
+
import type { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schema/concepts";
|
|
29
|
+
import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, LegacyResourceSchema, ObjectField, ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
30
|
+
import type { WithPartial } from "@warp-drive/core/types/utils";
|
|
31
|
+
import type { Snapshot } from "../compat/-private.js";
|
|
32
|
+
import type { MinimalLegacyRecord } from "./-private/model-methods.js";
|
|
33
|
+
import { belongsTo, hasMany } from "./-private/model-methods.js";
|
|
34
|
+
import RecordState from "./-private/record-state.js";
|
|
35
|
+
import type BelongsToReference from "./-private/references/belongs-to.js";
|
|
36
|
+
import type HasManyReference from "./-private/references/has-many.js";
|
|
37
|
+
import type { _MaybeBelongsToFields, MaybeHasManyFields } from "./-private/type-utils.js";
|
|
36
38
|
export type WithLegacyDerivations<T extends TypedRecordInstance> = T & MinimalLegacyRecord & {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
belongsTo: typeof belongsTo;
|
|
40
|
+
hasMany: typeof hasMany;
|
|
39
41
|
};
|
|
40
|
-
type AttributesSchema = ReturnType<Exclude<SchemaService[
|
|
41
|
-
type RelationshipsSchema = ReturnType<Exclude<SchemaService[
|
|
42
|
+
type AttributesSchema = ReturnType<Exclude<SchemaService["attributesDefinitionFor"], undefined>>;
|
|
43
|
+
type RelationshipsSchema = ReturnType<Exclude<SchemaService["relationshipsDefinitionFor"], undefined>>;
|
|
42
44
|
interface LegacyModeRecord<T extends TypedRecordInstance> {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
45
|
+
id: string | null;
|
|
46
|
+
serialize(options?: Record<string, unknown>): unknown;
|
|
47
|
+
destroyRecord(options?: Record<string, unknown>): Promise<this>;
|
|
48
|
+
unloadRecord(): void;
|
|
49
|
+
changedAttributes(): ChangedAttributesHash;
|
|
50
|
+
rollbackAttributes(): void;
|
|
51
|
+
_createSnapshot(): Snapshot<T>;
|
|
52
|
+
save(options?: Record<string, unknown>): Promise<this>;
|
|
53
|
+
reload(options?: Record<string, unknown>): Promise<T>;
|
|
54
|
+
belongsTo<K extends _MaybeBelongsToFields<T>>(prop: K): BelongsToReference<T, K>;
|
|
55
|
+
hasMany<K extends MaybeHasManyFields<T>>(prop: K): HasManyReference<T, K>;
|
|
56
|
+
deleteRecord(): void;
|
|
57
|
+
adapterError: unknown;
|
|
58
|
+
constructor: {
|
|
59
|
+
modelName: TypeFromInstance<T>;
|
|
60
|
+
};
|
|
61
|
+
currentState: RecordState;
|
|
62
|
+
dirtyType: "deleted" | "created" | "updated" | "";
|
|
63
|
+
errors: unknown;
|
|
64
|
+
hasDirtyAttributes: boolean;
|
|
65
|
+
isDeleted: boolean;
|
|
66
|
+
isEmpty: boolean;
|
|
67
|
+
isError: boolean;
|
|
68
|
+
isLoaded: boolean;
|
|
69
|
+
isLoading: boolean;
|
|
70
|
+
isDestroying: boolean;
|
|
71
|
+
isDestroyed: boolean;
|
|
72
|
+
isNew: boolean;
|
|
73
|
+
isSaving: boolean;
|
|
74
|
+
isValid: boolean;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
77
|
+
* A Type utility that enables quickly adding type information for the fields
|
|
78
|
+
* defined by `import { withDefaults } from '@ember-data/model/migration-support'`.
|
|
79
|
+
*
|
|
80
|
+
* Example:
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
|
|
84
|
+
* import { Type } from '@warp-drive/core-types/symbols';
|
|
85
|
+
* import type { HasMany } from '@ember-data/model';
|
|
86
|
+
*
|
|
87
|
+
* export const UserSchema = withDefaults({
|
|
88
|
+
* type: 'user',
|
|
89
|
+
* fields: [
|
|
90
|
+
* { name: 'firstName', kind: 'attribute' },
|
|
91
|
+
* { name: 'lastName', kind: 'attribute' },
|
|
92
|
+
* { name: 'age', kind: 'attribute' },
|
|
93
|
+
* { name: 'friends',
|
|
94
|
+
* kind: 'hasMany',
|
|
95
|
+
* type: 'user',
|
|
96
|
+
* options: { inverse: 'friends', async: false }
|
|
97
|
+
* },
|
|
98
|
+
* { name: 'bestFriend',
|
|
99
|
+
* kind: 'belongsTo',
|
|
100
|
+
* type: 'user',
|
|
101
|
+
* options: { inverse: null, async: false }
|
|
102
|
+
* },
|
|
103
|
+
* ],
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* export type User = WithLegacy<{
|
|
107
|
+
* firstName: string;
|
|
108
|
+
* lastName: string;
|
|
109
|
+
* age: number;
|
|
110
|
+
* friends: HasMany<User>;
|
|
111
|
+
* bestFriend: User | null;
|
|
112
|
+
* [Type]: 'user';
|
|
113
|
+
* }>
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
115
117
|
export type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
116
118
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
export declare function withDefaults(schema: WithPartial<LegacyResourceSchema,
|
|
119
|
+
* A function which adds the necessary fields to a schema and marks it as
|
|
120
|
+
* being in LegacyMode. This is used to support the legacy features of
|
|
121
|
+
* @ember-data/model while migrating to WarpDrive.
|
|
122
|
+
*
|
|
123
|
+
* Example:
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
|
|
127
|
+
* import { Type } from '@warp-drive/core-types/symbols';
|
|
128
|
+
* import type { HasMany } from '@ember-data/model';
|
|
129
|
+
*
|
|
130
|
+
* export const UserSchema = withDefaults({
|
|
131
|
+
* type: 'user',
|
|
132
|
+
* fields: [
|
|
133
|
+
* { name: 'firstName', kind: 'attribute' },
|
|
134
|
+
* { name: 'lastName', kind: 'attribute' },
|
|
135
|
+
* { name: 'age', kind: 'attribute' },
|
|
136
|
+
* { name: 'friends',
|
|
137
|
+
* kind: 'hasMany',
|
|
138
|
+
* type: 'user',
|
|
139
|
+
* options: { inverse: 'friends', async: false }
|
|
140
|
+
* },
|
|
141
|
+
* { name: 'bestFriend',
|
|
142
|
+
* kind: 'belongsTo',
|
|
143
|
+
* type: 'user',
|
|
144
|
+
* options: { inverse: null, async: false }
|
|
145
|
+
* },
|
|
146
|
+
* ],
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* export type User = WithLegacy<{
|
|
150
|
+
* firstName: string;
|
|
151
|
+
* lastName: string;
|
|
152
|
+
* age: number;
|
|
153
|
+
* friends: HasMany<User>;
|
|
154
|
+
* bestFriend: User | null;
|
|
155
|
+
* [Type]: 'user';
|
|
156
|
+
* }>
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* Using this function require registering the derivations
|
|
160
|
+
* it requires with the schema service.
|
|
161
|
+
*
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { registerDerivations } from '@ember-data/model/migration-support';
|
|
164
|
+
*
|
|
165
|
+
* registerDerivations(schema);
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @param {LegacyResourceSchema} schema The schema to add legacy support to.
|
|
169
|
+
* @return {LegacyResourceSchema} The schema with legacy support added.
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
export declare function withDefaults(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
171
173
|
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*/
|
|
174
|
+
* A function which registers the necessary derivations to support
|
|
175
|
+
* the LegacyMode features of @ember-data/model while migrating to WarpDrive.
|
|
176
|
+
*
|
|
177
|
+
* This must be called in order to use the fields added by:
|
|
178
|
+
*
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { withDefaults } from '@ember-data/model/migration-support';
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @param schema The schema service to register the derivations with.
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
185
186
|
export declare function registerDerivations(schema: SchemaService): void;
|
|
186
187
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
188
|
+
* A class which provides a schema service that delegates between
|
|
189
|
+
* a primary schema service and one that supports legacy model
|
|
190
|
+
* classes as its schema source.
|
|
191
|
+
*
|
|
192
|
+
* When the primary schema service has a schema for the given
|
|
193
|
+
* resource, it will be used. Otherwise, the fallback schema
|
|
194
|
+
* service will be used.
|
|
195
|
+
*
|
|
196
|
+
* This can be used when incrementally migrating from Models to
|
|
197
|
+
* ReactiveResources by enabling unmigrated Models to continue to
|
|
198
|
+
* provide their own schema information to the application.
|
|
199
|
+
*
|
|
200
|
+
* ```ts
|
|
201
|
+
* import { DelegatingSchemaService } from '@ember-data/model/migration-support';
|
|
202
|
+
* import { SchemaService } from '@warp-drive/schema-record';
|
|
203
|
+
*
|
|
204
|
+
* class AppStore extends Store {
|
|
205
|
+
* createSchemaService() {
|
|
206
|
+
* const schema = new SchemaService();
|
|
207
|
+
* return new DelegatingSchemaService(this, schema);
|
|
208
|
+
* }
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* All calls to register resources, derivations, transformations, hash functions
|
|
213
|
+
* etc. will be delegated to the primary schema service.
|
|
214
|
+
*
|
|
215
|
+
* @class DelegatingSchemaService
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
217
218
|
export interface DelegatingSchemaService {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
attributesDefinitionFor?(resource: StableRecordIdentifier | {
|
|
220
|
+
type: string;
|
|
221
|
+
}): AttributesSchema;
|
|
222
|
+
relationshipsDefinitionFor?(resource: StableRecordIdentifier | {
|
|
223
|
+
type: string;
|
|
224
|
+
}): RelationshipsSchema;
|
|
225
|
+
doesTypeExist?(type: string): boolean;
|
|
225
226
|
}
|
|
226
227
|
export declare class DelegatingSchemaService implements SchemaService {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
228
|
+
_preferred: SchemaService;
|
|
229
|
+
_secondary: SchemaService;
|
|
230
|
+
constructor(store: Store, schema: SchemaService);
|
|
231
|
+
isDelegated(resource: StableRecordIdentifier | {
|
|
232
|
+
type: string;
|
|
233
|
+
}): boolean;
|
|
234
|
+
resourceTypes(): Readonly<string[]>;
|
|
235
|
+
hasResource(resource: StableRecordIdentifier | {
|
|
236
|
+
type: string;
|
|
237
|
+
}): boolean;
|
|
238
|
+
hasTrait(type: string): boolean;
|
|
239
|
+
resourceHasTrait(resource: StableRecordIdentifier | {
|
|
240
|
+
type: string;
|
|
241
|
+
}, trait: string): boolean;
|
|
242
|
+
fields(resource: StableRecordIdentifier | {
|
|
243
|
+
type: string;
|
|
244
|
+
}): Map<string, FieldSchema>;
|
|
245
|
+
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
246
|
+
type: string;
|
|
247
|
+
}): Transformation;
|
|
248
|
+
hashFn(field: HashField | {
|
|
249
|
+
type: string;
|
|
250
|
+
}): HashFn;
|
|
251
|
+
derivation(field: DerivedField | {
|
|
252
|
+
type: string;
|
|
253
|
+
}): Derivation;
|
|
254
|
+
resource(resource: StableRecordIdentifier | {
|
|
255
|
+
type: string;
|
|
256
|
+
}): ResourceSchema | ObjectSchema;
|
|
257
|
+
registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
|
|
258
|
+
registerResource(schema: ResourceSchema | ObjectSchema): void;
|
|
259
|
+
registerTransformation(transform: Transformation): void;
|
|
260
|
+
registerDerivation<
|
|
261
|
+
R,
|
|
262
|
+
T,
|
|
263
|
+
FM extends ObjectValue | null
|
|
264
|
+
>(derivation: Derivation<R, T, FM>): void;
|
|
265
|
+
registerHashFn(hashFn: HashFn): void;
|
|
266
|
+
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
|
|
267
|
+
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: StableRecordIdentifier | {
|
|
268
|
+
type: string;
|
|
269
|
+
}): null | ProcessedExtension["features"];
|
|
270
|
+
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
271
|
+
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;
|
|
285
296
|
}
|
|
286
297
|
export {};
|
|
287
|
-
//# sourceMappingURL=migration-support.d.ts.map
|