@warp-drive/legacy 5.8.0-alpha.3 → 5.8.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -27
- package/declarations/adapter/json-api.d.ts +4 -6
- package/declarations/adapter/rest.d.ts +5 -8
- package/declarations/adapter.d.ts +4 -6
- package/declarations/compat/-private.d.ts +1 -1
- package/declarations/compat/extensions.d.ts +1 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
- package/declarations/compat/utils.d.ts +17 -17
- package/declarations/compat.d.ts +32 -8
- package/declarations/index.d.ts +70 -0
- package/declarations/model/-private/attr.d.ts +5 -6
- package/declarations/model/-private/belongs-to.d.ts +4 -5
- package/declarations/model/-private/has-many.d.ts +4 -5
- package/declarations/model/-private/hooks.d.ts +1 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts +2 -2
- package/declarations/model/-private/model.d.ts +8 -8
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +1 -1
- package/declarations/model/-private/references/has-many.d.ts +1 -1
- package/declarations/model/migration-support.d.ts +12 -3
- package/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/declarations/model-fragments/index.d.ts +5 -0
- package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/declarations/model-fragments.d.ts +9 -0
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -5
- package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
- package/declarations/serializer/-private/transforms/date.d.ts +2 -2
- package/declarations/serializer/-private/transforms/number.d.ts +1 -1
- package/declarations/serializer/-private/transforms/string.d.ts +1 -1
- package/declarations/serializer/json-api.d.ts +4 -6
- package/declarations/serializer/json.d.ts +6 -8
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +8 -11
- package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +5 -6
- package/dist/adapter/json-api.js +4 -1
- package/dist/adapter/rest.js +6 -9
- package/dist/adapter.js +4 -6
- package/dist/compat/-private.js +1 -1
- package/dist/compat/utils.js +17 -17
- package/dist/compat.js +55 -38
- package/dist/{errors-8kD2mSe_.js → errors-B9CDPh3R.js} +75 -53
- package/dist/hooks-CQXyievu.js +74 -0
- package/dist/index.js +195 -0
- package/dist/{json-DziiodPf.js → json-BHxlccxF.js} +8 -12
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +15 -2
- package/dist/model-for-B0TSd9HU.js +221 -0
- package/dist/model-fragments.js +76 -0
- package/dist/model.js +18 -90
- package/dist/{schema-provider-DQu4Rjco.js → schema-provider-BnVr_CnJ.js} +8 -10
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
- package/dist/serializer/json-api.js +11 -38
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +5 -12
- package/dist/serializer/transform.js +15 -6
- package/dist/serializer.js +8 -12
- package/dist/store.js +3 -0
- package/logos/README.md +2 -2
- package/logos/logo-yellow-slab.svg +1 -0
- package/logos/word-mark-black.svg +1 -0
- package/logos/word-mark-white.svg +1 -0
- package/package.json +6 -6
- package/logos/NCC-1701-a-blue.svg +0 -4
- package/logos/NCC-1701-a-gold.svg +0 -4
- package/logos/NCC-1701-a-gold_100.svg +0 -1
- package/logos/NCC-1701-a-gold_base-64.txt +0 -1
- package/logos/NCC-1701-a.svg +0 -4
- package/logos/docs-badge.svg +0 -2
- package/logos/ember-data-logo-dark.svg +0 -12
- package/logos/ember-data-logo-light.svg +0 -12
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +0 -4
- package/logos/warp-drive-logo-gold.svg +0 -4
|
@@ -2,7 +2,7 @@ import type { TypeFromInstance } from "@warp-drive/core/types/record";
|
|
|
2
2
|
import type { NoNull, RelationshipDecorator, RelationshipOptions } from "./belongs-to.js";
|
|
3
3
|
/**
|
|
4
4
|
`hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
|
|
5
|
-
relationships on a
|
|
5
|
+
relationships on a {@link Model}.
|
|
6
6
|
|
|
7
7
|
`hasMany` takes a configuration hash as a second parameter, currently
|
|
8
8
|
supported options are:
|
|
@@ -85,7 +85,7 @@ export default class Post extends Model {
|
|
|
85
85
|
|
|
86
86
|
#### Sync vs Async Relationships
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
WarpDrive fulfills relationships using resource data available in
|
|
89
89
|
the cache.
|
|
90
90
|
|
|
91
91
|
Sync relationships point directly to the known related resources.
|
|
@@ -153,9 +153,8 @@ must be declared as polymorphic, and the `as` option must be used to declare the
|
|
|
153
153
|
type each record satisfies on both sides.
|
|
154
154
|
|
|
155
155
|
@public
|
|
156
|
-
@param
|
|
157
|
-
@param
|
|
158
|
-
@return {PropertyDescriptor} relationship
|
|
156
|
+
@param type the name of the related resource
|
|
157
|
+
@param options a hash of options
|
|
159
158
|
*/
|
|
160
159
|
export declare function hasMany(): never;
|
|
161
160
|
export declare function hasMany(type: string): never;
|
|
@@ -2,7 +2,7 @@ import { type Store } from "@warp-drive/core/store/-private";
|
|
|
2
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: ResourceKey, createRecordArgs
|
|
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;
|
|
@@ -38,8 +38,8 @@ export declare class LegacySupport {
|
|
|
38
38
|
_updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
|
|
39
39
|
promise: Promise<OpaqueRecordInstance | null>;
|
|
40
40
|
}): PromiseBelongsTo;
|
|
41
|
-
referenceFor(kind: "belongsTo",
|
|
42
|
-
referenceFor(kind: "hasMany",
|
|
41
|
+
referenceFor(kind: "belongsTo", key: string): BelongsToReference;
|
|
42
|
+
referenceFor(kind: "hasMany", key: string): HasManyReference;
|
|
43
43
|
_findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: ResourceKey, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
|
|
44
44
|
_findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: ResourceKey, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<ResourceKey | null>;
|
|
45
45
|
destroy(): void;
|
|
@@ -28,9 +28,6 @@ export type FactoryCache = Record<string, ModelFactory>;
|
|
|
28
28
|
export type ModelStore = Store & {
|
|
29
29
|
_modelFactoryCache: FactoryCache;
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* @noInheritDoc
|
|
33
|
-
*/
|
|
34
31
|
interface Model {
|
|
35
32
|
/**
|
|
36
33
|
* The store service instance which created this record instance
|
|
@@ -89,8 +86,8 @@ interface Model {
|
|
|
89
86
|
```
|
|
90
87
|
|
|
91
88
|
@public
|
|
92
|
-
@param
|
|
93
|
-
@return
|
|
89
|
+
@param options
|
|
90
|
+
@return a promise that will be resolved when the adapter returns
|
|
94
91
|
successfully or rejected if the adapter returns with an error.
|
|
95
92
|
*/
|
|
96
93
|
destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
|
|
@@ -204,9 +201,9 @@ interface Model {
|
|
|
204
201
|
}
|
|
205
202
|
```
|
|
206
203
|
|
|
204
|
+
@deprecated use {@link Store.request} instead
|
|
207
205
|
@public
|
|
208
|
-
@
|
|
209
|
-
@return {Promise} a promise that will be resolved when the adapter returns
|
|
206
|
+
@return a promise that will be resolved when the adapter returns
|
|
210
207
|
successfully or rejected if the adapter returns with an error.
|
|
211
208
|
*/
|
|
212
209
|
save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
|
|
@@ -414,7 +411,10 @@ interface Model {
|
|
|
414
411
|
* the class to use as the reactive object for data of resource
|
|
415
412
|
* of that type.
|
|
416
413
|
*
|
|
414
|
+
* @public
|
|
417
415
|
* @noInheritDoc
|
|
416
|
+
* @hideconstructor
|
|
417
|
+
* @legacy
|
|
418
418
|
*/
|
|
419
419
|
declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
420
420
|
/** @private */
|
|
@@ -797,7 +797,7 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
797
797
|
Represents the model's class name as a string. This can be used to look up the model's class name through
|
|
798
798
|
`Store`'s modelFor method.
|
|
799
799
|
|
|
800
|
-
`modelName` is generated for you by
|
|
800
|
+
`modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.
|
|
801
801
|
For example:
|
|
802
802
|
|
|
803
803
|
```javascript
|
|
@@ -241,7 +241,7 @@ export default class BelongsToReference<
|
|
|
241
241
|
*/
|
|
242
242
|
remoteType(): "link" | "id";
|
|
243
243
|
/**
|
|
244
|
-
`push` can be used to update the data in the relationship and
|
|
244
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
245
245
|
will treat the new data as the canonical value of this relationship on
|
|
246
246
|
the backend. A value of `null` (e.g. `{ data: null }`) can be passed to
|
|
247
247
|
clear the relationship.
|
|
@@ -243,7 +243,7 @@ export default class HasManyReference<
|
|
|
243
243
|
*/
|
|
244
244
|
meta(): Meta | null;
|
|
245
245
|
/**
|
|
246
|
-
`push` can be used to update the data in the relationship and
|
|
246
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
247
247
|
will treat the new data as the canonical value of this relationship on
|
|
248
248
|
the backend. An empty array will signify the canonical value should be
|
|
249
249
|
empty.
|
|
@@ -7,7 +7,7 @@ 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";
|
|
10
|
-
import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, LegacyResourceSchema, ObjectField, ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
10
|
+
import type { ArrayField, CacheableFieldSchema, DerivedField, FieldSchema, GenericField, HashField, IdentityField, LegacyResourceSchema, ObjectField, ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
11
11
|
import type { WithPartial } from "@warp-drive/core/types/utils";
|
|
12
12
|
import type { Snapshot } from "../compat/-private.js";
|
|
13
13
|
import type { MinimalLegacyRecord } from "./-private/model-methods.js";
|
|
@@ -207,8 +207,6 @@ export interface DelegatingSchemaService {
|
|
|
207
207
|
doesTypeExist?(type: string): boolean;
|
|
208
208
|
}
|
|
209
209
|
export declare class DelegatingSchemaService implements SchemaService {
|
|
210
|
-
_preferred: SchemaService;
|
|
211
|
-
_secondary: SchemaService;
|
|
212
210
|
constructor(store: Store, schema: SchemaService);
|
|
213
211
|
isDelegated(resource: ResourceKey | {
|
|
214
212
|
type: string;
|
|
@@ -224,6 +222,9 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
224
222
|
fields(resource: ResourceKey | {
|
|
225
223
|
type: string;
|
|
226
224
|
}): Map<string, FieldSchema>;
|
|
225
|
+
cacheFields?(resource: {
|
|
226
|
+
type: string;
|
|
227
|
+
}): Map<string, Exclude<CacheableFieldSchema, IdentityField>>;
|
|
227
228
|
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
228
229
|
type: string;
|
|
229
230
|
}): Transformation;
|
|
@@ -245,6 +246,10 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
245
246
|
FM extends ObjectValue | null
|
|
246
247
|
>(derivation: Derivation<R, T, FM>): void;
|
|
247
248
|
registerHashFn(hashFn: HashFn): void;
|
|
249
|
+
CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: {
|
|
250
|
+
kind: "object" | "array";
|
|
251
|
+
name: string;
|
|
252
|
+
}): boolean;
|
|
248
253
|
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
|
|
249
254
|
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
|
|
250
255
|
type: string;
|
|
@@ -252,4 +257,8 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
252
257
|
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
253
258
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
254
259
|
}
|
|
260
|
+
export interface PrivateDelegatingSchemaService extends DelegatingSchemaService {
|
|
261
|
+
_preferred: SchemaService;
|
|
262
|
+
_secondary: SchemaService;
|
|
263
|
+
}
|
|
255
264
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Fragment } from "./fragment.js";
|
|
2
|
+
export declare class FragmentArray<T extends Fragment> {
|
|
3
|
+
isDestroying: boolean;
|
|
4
|
+
isDestroyed: boolean;
|
|
5
|
+
get hasDirtyAttributes(): boolean;
|
|
6
|
+
addFragment(fragment?: T): Fragment[] | undefined;
|
|
7
|
+
createFragment(fragment?: T): Fragment | undefined;
|
|
8
|
+
removeFragment(fragment?: T): void;
|
|
9
|
+
rollbackAttributes(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const FragmentArrayExtension: {
|
|
12
|
+
kind: "array";
|
|
13
|
+
name: "fragment-array";
|
|
14
|
+
features: typeof FragmentArray;
|
|
15
|
+
};
|
|
16
|
+
export default FragmentArrayExtension;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PrivateReactiveResource } from "@warp-drive/core/reactive/-private";
|
|
2
|
+
export declare class Fragment {
|
|
3
|
+
isDestroying: boolean;
|
|
4
|
+
isDestroyed: boolean;
|
|
5
|
+
get hasDirtyAttributes(): boolean;
|
|
6
|
+
get isFragment(): boolean;
|
|
7
|
+
get $type(): string | null | undefined;
|
|
8
|
+
rollbackAttributes(this: PrivateReactiveResource): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const FragmentExtension: {
|
|
11
|
+
kind: "object";
|
|
12
|
+
name: "fragment";
|
|
13
|
+
features: typeof Fragment;
|
|
14
|
+
};
|
|
15
|
+
export default FragmentExtension;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Store } from "@warp-drive/core";
|
|
2
|
+
import type { ModelSchema } from "@warp-drive/core/types";
|
|
3
|
+
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
4
|
+
import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
5
|
+
type KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;
|
|
6
|
+
export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
|
|
7
|
+
export declare class ShimModelClass<T = unknown> implements ModelSchema<T> {
|
|
8
|
+
__store: Store;
|
|
9
|
+
modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
|
|
10
|
+
constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string);
|
|
11
|
+
get fields(): Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
|
|
12
|
+
get attributes(): Map<KeyOrString<T>, LegacyAttributeField>;
|
|
13
|
+
get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField>;
|
|
14
|
+
eachAttribute<K extends KeyOrString<T>>(callback: (key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
|
|
15
|
+
eachRelationship<K extends KeyOrString<T>>(callback: (key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
|
|
16
|
+
eachTransformedAttribute<K extends KeyOrString<T>>(callback: (key: K, type: string | null) => void, binding?: T): void;
|
|
17
|
+
}
|
|
18
|
+
export declare function fragmentsModelFor<T extends TypedRecordInstance>(this: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
|
|
19
|
+
export declare const modelFor: typeof fragmentsModelFor;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WithArrayLike, WithEmberObject } from "../compat/extensions.js";
|
|
2
|
+
import type { Fragment } from "./extensions/fragment.js";
|
|
3
|
+
import type { FragmentArray } from "./extensions/fragment-array.js";
|
|
4
|
+
export type WithFragment<T> = T & WithEmberObject<T> & Fragment;
|
|
5
|
+
export type WithFragmentArray<T extends Fragment> = T & WithArrayLike<T> & FragmentArray<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type ApplicationInstance from "@ember/application/instance";
|
|
2
|
+
import type { SchemaService } from "@warp-drive/core/types";
|
|
3
|
+
export declare function registerFragmentExtensions(schema: SchemaService): void;
|
|
4
|
+
export declare function initialize(application: ApplicationInstance): void;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
name: string;
|
|
7
|
+
initialize: (application: ApplicationInstance) => void;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used as a helper to setup the relevant parts of an array
|
|
3
|
+
* schema and add extensions etc.
|
|
4
|
+
*
|
|
5
|
+
* @param arrayName The name of the array
|
|
6
|
+
* @returns The schema for an array
|
|
7
|
+
*/
|
|
8
|
+
export declare function withArrayDefaults<ArrayName extends string>(arrayName: ArrayName): {
|
|
9
|
+
kind: "array";
|
|
10
|
+
name: ArrayName;
|
|
11
|
+
type: `array:${string}`;
|
|
12
|
+
options: {
|
|
13
|
+
arrayExtensions: string[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used as a helper to setup the relevant parts of a fragment-array
|
|
3
|
+
* schema and add extensions etc.
|
|
4
|
+
*
|
|
5
|
+
* @param fragmentArrayType The type of the fragment-array
|
|
6
|
+
* @param fragmentArrayName The name of the fragment-array
|
|
7
|
+
* @returns The schema for a fragment-array
|
|
8
|
+
*/
|
|
9
|
+
export declare function withFragmentArrayDefaults<
|
|
10
|
+
FragmentArrayType extends string,
|
|
11
|
+
FragmentArrayName extends string
|
|
12
|
+
>(fragmentArrayType: FragmentArrayType, fragmentArrayName?: FragmentArrayName): {
|
|
13
|
+
kind: "schema-array";
|
|
14
|
+
type: `fragment:${string}`;
|
|
15
|
+
name: string;
|
|
16
|
+
options: {
|
|
17
|
+
arrayExtensions: string[];
|
|
18
|
+
defaultValue: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used as a helper to setup the relevant parts of a fragment schema
|
|
3
|
+
* and add extensions etc.
|
|
4
|
+
*
|
|
5
|
+
* @param fragmentType The type of the fragment
|
|
6
|
+
* @param fragmentName The optional name of the fragment. If not provided, it will default to the fragmentType.
|
|
7
|
+
* @returns The schema for a fragment
|
|
8
|
+
*/
|
|
9
|
+
export declare function withFragmentDefaults<
|
|
10
|
+
FragmentType extends string,
|
|
11
|
+
FragmentName extends string
|
|
12
|
+
>(fragmentType: FragmentType, fragmentName?: FragmentName): {
|
|
13
|
+
kind: "schema-object";
|
|
14
|
+
type: `fragment:${FragmentType}`;
|
|
15
|
+
name: FragmentType | FragmentName;
|
|
16
|
+
options: {
|
|
17
|
+
objectExtensions: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { LegacyResourceSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
2
|
+
import type { WithPartial } from "@warp-drive/core/types/utils";
|
|
3
|
+
export declare function withLegacy(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): ResourceSchema;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { withArrayDefaults } from "./model-fragments/utilities/with-array-defaults.js";
|
|
2
|
+
export { withFragmentDefaults } from "./model-fragments/utilities/with-fragment-defaults.js";
|
|
3
|
+
export { withFragmentArrayDefaults } from "./model-fragments/utilities/with-fragment-array-defaults.js";
|
|
4
|
+
export { withLegacy } from "./model-fragments/utilities/with-legacy.js";
|
|
5
|
+
export { registerFragmentExtensions } from "./model-fragments/instance-initializers/fragment-extensions.js";
|
|
6
|
+
export { modelFor } from "./model-fragments/hooks/model-for.js";
|
|
7
|
+
export { FragmentArray, FragmentArrayExtension } from "./model-fragments/extensions/fragment-array.js";
|
|
8
|
+
export { Fragment, FragmentExtension } from "./model-fragments/extensions/fragment.js";
|
|
9
|
+
export type { WithFragment, WithFragmentArray } from "./model-fragments/index.js";
|
|
@@ -85,11 +85,6 @@ instances must have an `id` property to be used with Ember Data.
|
|
|
85
85
|
are. Please read the docs for the methods this mixin provides, in case you need
|
|
86
86
|
to modify it to fit your specific needs.**
|
|
87
87
|
|
|
88
|
-
For example, review the docs for each method of this mixin:
|
|
89
|
-
* [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)
|
|
90
|
-
* [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)
|
|
91
|
-
* [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)
|
|
92
|
-
|
|
93
88
|
@class EmbeddedRecordsMixin
|
|
94
89
|
@public
|
|
95
90
|
*/
|
|
@@ -5,8 +5,8 @@ export interface BooleanTransform {
|
|
|
5
5
|
/**
|
|
6
6
|
The `BooleanTransform` class is used to serialize and deserialize
|
|
7
7
|
boolean attributes on Ember Data record objects. This transform is
|
|
8
|
-
used when `boolean` is passed as the type parameter to the
|
|
9
|
-
|
|
8
|
+
used when `'boolean'` is passed as the type parameter to the
|
|
9
|
+
{@link attr}function.
|
|
10
10
|
|
|
11
11
|
Usage
|
|
12
12
|
|
|
@@ -5,8 +5,8 @@ export interface DateTransform {
|
|
|
5
5
|
/**
|
|
6
6
|
The `DateTransform` class is used to serialize and deserialize
|
|
7
7
|
date attributes on Ember Data record objects. This transform is used
|
|
8
|
-
when `date` is passed as the type parameter to the
|
|
9
|
-
|
|
8
|
+
when `'date'` is passed as the type parameter to the
|
|
9
|
+
{@link attr} function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
|
|
10
10
|
standard.
|
|
11
11
|
|
|
12
12
|
```js [app/models/score.js]
|
|
@@ -6,7 +6,7 @@ export interface NumberTransform {
|
|
|
6
6
|
The `NumberTransform` class is used to serialize and deserialize
|
|
7
7
|
numeric attributes on Ember Data record objects. This transform is
|
|
8
8
|
used when `number` is passed as the type parameter to the
|
|
9
|
-
|
|
9
|
+
{@link attr} function.
|
|
10
10
|
|
|
11
11
|
Usage
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@ export interface StringTransform {
|
|
|
6
6
|
The `StringTransform` class is used to serialize and deserialize
|
|
7
7
|
string attributes on Ember Data record objects. This transform is
|
|
8
8
|
used when `string` is passed as the type parameter to the
|
|
9
|
-
|
|
9
|
+
{@link attr} function.
|
|
10
10
|
|
|
11
11
|
Usage
|
|
12
12
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
<p>
|
|
2
|
+
* :::danger
|
|
4
3
|
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
5
4
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</blockquote>
|
|
5
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
|
+
:::
|
|
9
7
|
|
|
10
|
-
In
|
|
8
|
+
In WarpDrive a Serializer is used to serialize and deserialize
|
|
11
9
|
records when they are transferred in and out of an external source.
|
|
12
10
|
This process involves normalizing property names, transforming
|
|
13
11
|
attribute values and serializing relationships.
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
2
|
+
* :::danger
|
|
3
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
5
4
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</blockquote>
|
|
5
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
|
+
:::
|
|
9
7
|
|
|
10
|
-
In
|
|
8
|
+
In WarpDrive a Serializer is used to serialize and deserialize
|
|
11
9
|
records when they are transferred in and out of an external source.
|
|
12
10
|
This process involves normalizing property names, transforming
|
|
13
11
|
attribute values and serializing relationships.
|
|
14
12
|
|
|
15
|
-
By default,
|
|
13
|
+
By default, WarpDrive uses and recommends the `JSONAPISerializer`.
|
|
16
14
|
|
|
17
15
|
`JSONSerializer` is useful for simpler or legacy backends that may
|
|
18
16
|
not support the http://jsonapi.org/ spec.
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
2
|
+
* :::danger
|
|
3
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
5
4
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</blockquote>
|
|
5
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
|
+
:::
|
|
9
7
|
|
|
10
8
|
Normally, applications will use the `RESTSerializer` by implementing
|
|
11
9
|
the `normalize` method.
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
## Overview
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
4
|
+
:::danger
|
|
5
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
7
6
|
If starting a new app or thinking of implementing a new serializer, consider writing a
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</blockquote>
|
|
7
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
8
|
+
:::
|
|
11
9
|
|
|
12
10
|
In order to properly manage and present your data, WarpDrive
|
|
13
11
|
needs to understand the structure of data it receives.
|
|
@@ -16,14 +14,14 @@ needs to understand the structure of data it receives.
|
|
|
16
14
|
the format WarpDrive understands.
|
|
17
15
|
|
|
18
16
|
Data received from an API response is **normalized** into
|
|
19
|
-
[
|
|
17
|
+
[{json:api}](https://jsonapi.org/) (the format used internally
|
|
20
18
|
by WarpDrive), while data sent to an API is **serialized**
|
|
21
19
|
into the format the API expects.
|
|
22
20
|
|
|
23
21
|
### Implementing a Serializer
|
|
24
22
|
|
|
25
23
|
There are only two required serializer methods, one for
|
|
26
|
-
normalizing data from the server API format into
|
|
24
|
+
normalizing data from the server API format into {json:api}, and
|
|
27
25
|
another for serializing records via `Snapshots` into the expected
|
|
28
26
|
server API format.
|
|
29
27
|
|
|
@@ -69,7 +67,7 @@ store.serializerFor('author');
|
|
|
69
67
|
// app/serializers/application.js
|
|
70
68
|
```
|
|
71
69
|
|
|
72
|
-
Most requests in
|
|
70
|
+
Most requests in `@warp-drive/legacy` are made with respect to a particular `type` (or `modelName`)
|
|
73
71
|
(e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
|
|
74
72
|
refer to this as the **primary** resource `type`.
|
|
75
73
|
|
|
@@ -124,8 +122,7 @@ And you can optionally override the following methods:
|
|
|
124
122
|
|
|
125
123
|
* `normalize()`
|
|
126
124
|
|
|
127
|
-
For an example implementation, see
|
|
128
|
-
[JSONSerializer](JSONSerializer), the included JSON serializer.
|
|
125
|
+
For an example implementation, see the included {@link JSONSerializer}.
|
|
129
126
|
|
|
130
127
|
@class Serializer
|
|
131
128
|
@public
|
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-BnYvPex3.js";
|
package/dist/adapter/error.js
CHANGED
|
@@ -3,17 +3,16 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
|
3
3
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
## Overview
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
11
|
+
:::danger
|
|
12
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
13
13
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</blockquote>
|
|
14
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
15
|
+
:::
|
|
17
16
|
|
|
18
17
|
An `AdapterError` is used by an adapter to signal that an error occurred
|
|
19
18
|
during a request to an external API. It indicates a generic error, and
|
package/dist/adapter/json-api.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
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-BnYvPex3.js";
|
|
5
5
|
import { RESTAdapter } from './rest.js';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
|
|
6
9
|
class JSONAPIAdapter extends RESTAdapter {
|
|
7
10
|
_defaultContentType = 'application/vnd.api+json';
|
|
8
11
|
|
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-BnYvPex3.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";
|
|
@@ -14,13 +14,11 @@ import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
|
|
14
14
|
const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
17
|
+
* :::danger
|
|
18
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
20
19
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
</blockquote>
|
|
20
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
21
|
+
:::
|
|
24
22
|
|
|
25
23
|
The REST adapter allows your store to communicate with an HTTP server by
|
|
26
24
|
transmitting JSON via XHR.
|
|
@@ -392,8 +390,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
392
390
|
Some APIs require HTTP headers, e.g. to provide an API
|
|
393
391
|
key. Arbitrary headers can be set as key/value pairs on the
|
|
394
392
|
`RESTAdapter`'s `headers` object and Ember Data will send them
|
|
395
|
-
along with each ajax request
|
|
396
|
-
customization](/ember-data/release/classes/RESTAdapter).
|
|
393
|
+
along with each ajax request..
|
|
397
394
|
```js [app/adapters/application.js]
|
|
398
395
|
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
399
396
|
export default class ApplicationAdapter extends RESTAdapter {
|
package/dist/adapter.js
CHANGED
|
@@ -496,13 +496,11 @@ const BuildURLMixin = Mixin.create(mixinProps);
|
|
|
496
496
|
/**
|
|
497
497
|
* ## Overview
|
|
498
498
|
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
* ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
499
|
+
* :::danger
|
|
500
|
+
* ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
502
501
|
* If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* </blockquote>
|
|
502
|
+
* {@link Handler} instead to be used with the {@link RequestManager}
|
|
503
|
+
* ::::
|
|
506
504
|
*
|
|
507
505
|
* In order to properly fetch and update data, @warp-drive/legacy
|
|
508
506
|
* needs to understand how to connect to your API.
|
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-B1pSSN52.js";
|