@warp-drive/legacy 5.8.0-alpha.5 → 5.8.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/compat/-private.d.ts +1 -1
- package/declarations/compat/extensions.d.ts +1 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -3
- package/declarations/compat/utils.d.ts +4 -4
- package/declarations/index.d.ts +53 -0
- package/declarations/model/-private/attr.d.ts +1 -1
- package/declarations/model/-private/belongs-to.d.ts +1 -1
- package/declarations/model/-private/has-many.d.ts +1 -1
- package/declarations/model/-private/hooks.d.ts +1 -1
- 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 +4 -2
- package/declarations/serializer/json-api.d.ts +1 -1
- package/declarations/serializer/json.d.ts +2 -2
- package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
- 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/utils.js +4 -4
- package/dist/compat.js +1 -1
- package/dist/{errors-8kD2mSe_.js → errors-COviC59J.js} +3 -3
- package/dist/hooks-Bp8SIQBU.js +74 -0
- package/dist/index.js +178 -0
- package/dist/{json-LVAukAjN.js → json-ksWOHRfq.js} +2 -2
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +4 -2
- package/dist/model.js +8 -77
- package/dist/{schema-provider-DQu4Rjco.js → schema-provider-JlCneqZH.js} +8 -10
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
- package/dist/serializer/json-api.js +1 -1
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +1 -1
- package/dist/store.js +3 -0
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type default as EmberObject } from "@ember/object";
|
|
2
|
-
import type { CAUTION_MEGA_DANGER_ZONE_Extension } from "@warp-drive/core/reactive
|
|
2
|
+
import type { CAUTION_MEGA_DANGER_ZONE_Extension } from "@warp-drive/core/reactive";
|
|
3
3
|
declare const EmberObjectMethods: readonly ["addObserver", "cacheFor", "decrementProperty", "get", "getProperties", "incrementProperty", "notifyPropertyChange", "removeObserver", "set", "setProperties", "toggleProperty"];
|
|
4
4
|
export declare const EmberObjectArrayExtension: CAUTION_MEGA_DANGER_ZONE_Extension;
|
|
5
5
|
export declare const EmberObjectExtension: CAUTION_MEGA_DANGER_ZONE_Extension;
|
|
@@ -168,7 +168,7 @@ export interface MinimumAdapterInterface {
|
|
|
168
168
|
* let error = new Error(errorMessage);
|
|
169
169
|
*
|
|
170
170
|
* // these two properties combined
|
|
171
|
-
* // alert
|
|
171
|
+
* // alert WarpDrive to this error being for
|
|
172
172
|
* // invalid properties on the record during
|
|
173
173
|
* // the request
|
|
174
174
|
* error.isAdapterError = true;
|
|
@@ -219,7 +219,7 @@ export interface MinimumAdapterInterface {
|
|
|
219
219
|
* let error = new Error(errorMessage);
|
|
220
220
|
*
|
|
221
221
|
* // these two properties combined
|
|
222
|
-
* // alert
|
|
222
|
+
* // alert WarpDrive to this error being for
|
|
223
223
|
* // invalid properties on the record during
|
|
224
224
|
* // the request
|
|
225
225
|
* error.isAdapterError = true;
|
|
@@ -402,7 +402,7 @@ export interface MinimumAdapterInterface {
|
|
|
402
402
|
*
|
|
403
403
|
* A group is an array of snapshots meant to be fetched together by a single `findMany` request.
|
|
404
404
|
*
|
|
405
|
-
* By default if this method is not implemented
|
|
405
|
+
* By default if this method is not implemented WarpDrive will call `findMany` once with all
|
|
406
406
|
* requested records as a single group when `coalesceFindRequests` is `true`.
|
|
407
407
|
*
|
|
408
408
|
* See also `findMany` and `coalesceFindRequests`
|
|
@@ -33,7 +33,7 @@ export declare function configureAssertFn(fn: (message: string, condition: unkno
|
|
|
33
33
|
export declare function configureTypeNormalization(fn: (type: string) => string): void;
|
|
34
34
|
/**
|
|
35
35
|
* Converts a potentially unnormalized type into the format expected
|
|
36
|
-
* by our
|
|
36
|
+
* by our WarpDrive Cache. Currently this is singular-dasherized.
|
|
37
37
|
*
|
|
38
38
|
* you should not rely on this function to give you an exact format
|
|
39
39
|
* for display purposes. Formatting for display should be handled
|
|
@@ -62,7 +62,7 @@ export declare function configureTypeNormalization(fn: (type: string) => string)
|
|
|
62
62
|
*/
|
|
63
63
|
export declare function formattedType<T extends string>(type: T | string): T;
|
|
64
64
|
/**
|
|
65
|
-
* Format an id to the format expected by the
|
|
65
|
+
* Format an id to the format expected by the WarpDrive Cache.
|
|
66
66
|
* Currently this means that id should be `string | null`.
|
|
67
67
|
*
|
|
68
68
|
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
@@ -88,7 +88,7 @@ export declare function expectId(id: string | number): string;
|
|
|
88
88
|
export declare function expectId(id: null): never;
|
|
89
89
|
/**
|
|
90
90
|
* Compares two types for strict equality, converting them to
|
|
91
|
-
* the format expected by the
|
|
91
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
92
92
|
* differences in format are accounted for in the comparison.
|
|
93
93
|
*
|
|
94
94
|
* Asserts when expected or actual are invalid types in dev.
|
|
@@ -114,7 +114,7 @@ export declare function expectId(id: null): never;
|
|
|
114
114
|
export declare function isEquivType(expected: string, actual: string): boolean;
|
|
115
115
|
/**
|
|
116
116
|
* Compares two IDs for strict equality, converting them to
|
|
117
|
-
* the format expected by the
|
|
117
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
118
118
|
* differences in format are accounted for in the comparison.
|
|
119
119
|
*
|
|
120
120
|
* Asserts when expected or actual are invalid IDs in dev.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith <project>
|
|
4
|
+
*/
|
|
5
|
+
import { Store, type StoreSetupOptions } from "@warp-drive/core";
|
|
6
|
+
import type { ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
7
|
+
interface _LegacyStoreSetupOptions extends Omit<StoreSetupOptions, "schemas"> {
|
|
8
|
+
schemas?: Array<ResourceSchema | ObjectSchema>;
|
|
9
|
+
}
|
|
10
|
+
interface LegacyModelStoreSetupOptions extends _LegacyStoreSetupOptions {
|
|
11
|
+
/**
|
|
12
|
+
* If true, it is presumed that no requests require use of the LegacyNetworkHandler
|
|
13
|
+
* and associated adapters/serializer methods.
|
|
14
|
+
*/
|
|
15
|
+
linksMode: true;
|
|
16
|
+
/**
|
|
17
|
+
* if true, all legacy request methods and supporting infrastructure will
|
|
18
|
+
* be available on the store.
|
|
19
|
+
*/
|
|
20
|
+
legacyRequests?: false;
|
|
21
|
+
}
|
|
22
|
+
interface LegacyModelAndNetworkStoreSetupOptions extends _LegacyStoreSetupOptions {
|
|
23
|
+
/**
|
|
24
|
+
* If true, it is presumed that no requests require use of the LegacyNetworkHandler
|
|
25
|
+
* and associated adapters/serializer methods.
|
|
26
|
+
*/
|
|
27
|
+
linksMode: false;
|
|
28
|
+
/**
|
|
29
|
+
* if true, all legacy request methods and supporting infrastructure will
|
|
30
|
+
* be available on the store.
|
|
31
|
+
*/
|
|
32
|
+
legacyRequests?: false;
|
|
33
|
+
}
|
|
34
|
+
interface LegacyModelAndNetworkAndRequestStoreSetupOptions extends _LegacyStoreSetupOptions {
|
|
35
|
+
/**
|
|
36
|
+
* If true, it is presumed that no requests require use of the LegacyNetworkHandler
|
|
37
|
+
* and associated adapters/serializer methods.
|
|
38
|
+
*/
|
|
39
|
+
linksMode: false;
|
|
40
|
+
/**
|
|
41
|
+
* if true, all legacy request methods and supporting infrastructure will
|
|
42
|
+
* be available on the store.
|
|
43
|
+
*/
|
|
44
|
+
legacyRequests: true;
|
|
45
|
+
}
|
|
46
|
+
export type LegacyStoreSetupOptions = LegacyModelStoreSetupOptions | LegacyModelAndNetworkStoreSetupOptions | LegacyModelAndNetworkAndRequestStoreSetupOptions;
|
|
47
|
+
/**
|
|
48
|
+
* Use the legacy store with the given options.
|
|
49
|
+
*/
|
|
50
|
+
export declare function useLegacyStore(options: LegacyModelStoreSetupOptions, StoreKlass?: typeof Store): typeof Store;
|
|
51
|
+
export declare function useLegacyStore(options: LegacyModelAndNetworkStoreSetupOptions, StoreKlass?: typeof Store): typeof Store;
|
|
52
|
+
export declare function useLegacyStore(options: LegacyModelAndNetworkAndRequestStoreSetupOptions, StoreKlass?: typeof Store): typeof Store;
|
|
53
|
+
export {};
|
|
@@ -78,7 +78,7 @@ export type DataDecorator = (target: object, key: string, desc?: DecoratorProper
|
|
|
78
78
|
`attr` defines an attribute on a {@link Model}.
|
|
79
79
|
By default, attributes are passed through as-is, however you can specify an
|
|
80
80
|
optional type to have the value automatically transformed.
|
|
81
|
-
|
|
81
|
+
WarpDrive ships with four basic transform types: `string`, `number`,
|
|
82
82
|
`boolean` and `date`. You can define your own transforms by subclassing
|
|
83
83
|
{@link Transform}.
|
|
84
84
|
|
|
@@ -97,7 +97,7 @@ export default class Person extends Model {
|
|
|
97
97
|
|
|
98
98
|
#### Sync vs Async Relationships
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
WarpDrive fulfills relationships using resource data available in
|
|
101
101
|
the cache.
|
|
102
102
|
|
|
103
103
|
Sync relationships point directly to the known related resources.
|
|
@@ -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.
|
|
@@ -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;
|
|
@@ -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.
|
|
@@ -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;
|
|
@@ -252,4 +250,8 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
252
250
|
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
253
251
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
254
252
|
}
|
|
253
|
+
export interface PrivateDelegatingSchemaService extends DelegatingSchemaService {
|
|
254
|
+
_preferred: SchemaService;
|
|
255
|
+
_secondary: SchemaService;
|
|
256
|
+
}
|
|
255
257
|
export {};
|
|
@@ -5,7 +5,7 @@ If starting a new app or thinking of implementing a new adapter, consider writin
|
|
|
5
5
|
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
6
|
:::
|
|
7
7
|
|
|
8
|
-
In
|
|
8
|
+
In WarpDrive a Serializer is used to serialize and deserialize
|
|
9
9
|
records when they are transferred in and out of an external source.
|
|
10
10
|
This process involves normalizing property names, transforming
|
|
11
11
|
attribute values and serializing relationships.
|
|
@@ -5,12 +5,12 @@ If starting a new app or thinking of implementing a new adapter, consider writin
|
|
|
5
5
|
{@link Handler} instead to be used with the {@link RequestManager}
|
|
6
6
|
:::
|
|
7
7
|
|
|
8
|
-
In
|
|
8
|
+
In WarpDrive a Serializer is used to serialize and deserialize
|
|
9
9
|
records when they are transferred in and out of an external source.
|
|
10
10
|
This process involves normalizing property names, transforming
|
|
11
11
|
attribute values and serializing relationships.
|
|
12
12
|
|
|
13
|
-
By default,
|
|
13
|
+
By default, WarpDrive uses and recommends the `JSONAPISerializer`.
|
|
14
14
|
|
|
15
15
|
`JSONSerializer` is useful for simpler or legacy backends that may
|
|
16
16
|
not support the http://jsonapi.org/ spec.
|
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/json-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dasherize, pluralize } from '@warp-drive/utilities/string';
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
-
import { b as serializeIntoHash } from "../serialize-into-hash-
|
|
4
|
+
import { b as serializeIntoHash } from "../serialize-into-hash-BnYvPex3.js";
|
|
5
5
|
import { RESTAdapter } from './rest.js';
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
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";
|
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";
|
package/dist/compat/utils.js
CHANGED
|
@@ -72,7 +72,7 @@ const NORMALIZED_TYPES = new Map();
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Converts a potentially unnormalized type into the format expected
|
|
75
|
-
* by our
|
|
75
|
+
* by our WarpDrive Cache. Currently this is singular-dasherized.
|
|
76
76
|
*
|
|
77
77
|
* you should not rely on this function to give you an exact format
|
|
78
78
|
* for display purposes. Formatting for display should be handled
|
|
@@ -116,7 +116,7 @@ function formattedType(type) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Format an id to the format expected by the
|
|
119
|
+
* Format an id to the format expected by the WarpDrive Cache.
|
|
120
120
|
* Currently this means that id should be `string | null`.
|
|
121
121
|
*
|
|
122
122
|
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
@@ -154,7 +154,7 @@ function expectId(id) {
|
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* Compares two types for strict equality, converting them to
|
|
157
|
-
* the format expected by the
|
|
157
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
158
158
|
* differences in format are accounted for in the comparison.
|
|
159
159
|
*
|
|
160
160
|
* Asserts when expected or actual are invalid types in dev.
|
|
@@ -191,7 +191,7 @@ function isEquivType(expected, actual) {
|
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* Compares two IDs for strict equality, converting them to
|
|
194
|
-
* the format expected by the
|
|
194
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
195
195
|
* differences in format are accounted for in the comparison.
|
|
196
196
|
*
|
|
197
197
|
* Asserts when expected or actual are invalid IDs in dev.
|
package/dist/compat.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
3
|
import { assertPrivateStore, waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
|
|
4
4
|
import '@warp-drive/core/reactive/-private';
|
|
5
|
-
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-
|
|
5
|
+
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-B1pSSN52.js";
|
|
6
6
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
7
7
|
function _findHasMany(adapter, store, identifier, link, relationship, options) {
|
|
8
8
|
const promise = Promise.resolve().then(() => {
|
|
@@ -2,7 +2,7 @@ import { Context } from '@warp-drive/core/reactive/-private';
|
|
|
2
2
|
import { memoized, defineSignal, assertPrivateStore, defineNonEnumerableSignal, isResourceKey, recordIdentifierFor, isPrivateStore, storeFor, fastPush, createLegacyManyArray, notifyInternalSignal } from '@warp-drive/core/store/-private';
|
|
3
3
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
4
4
|
import { EnableHydration } from '@warp-drive/core/types/request';
|
|
5
|
-
import { u as upgradeStore } from "./-private-
|
|
5
|
+
import { u as upgradeStore } from "./-private-B1pSSN52.js";
|
|
6
6
|
import { computed, get } from '@ember/object';
|
|
7
7
|
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
8
8
|
import ObjectProxy from '@ember/object/proxy';
|
|
@@ -632,7 +632,7 @@ class HasManyReference {
|
|
|
632
632
|
}
|
|
633
633
|
|
|
634
634
|
/**
|
|
635
|
-
`push` can be used to update the data in the relationship and
|
|
635
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
636
636
|
will treat the new data as the canonical value of this relationship on
|
|
637
637
|
the backend. An empty array will signify the canonical value should be
|
|
638
638
|
empty.
|
|
@@ -1231,7 +1231,7 @@ class BelongsToReference {
|
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
1233
1233
|
/**
|
|
1234
|
-
`push` can be used to update the data in the relationship and
|
|
1234
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
1235
1235
|
will treat the new data as the canonical value of this relationship on
|
|
1236
1236
|
the backend. A value of `null` (e.g. `{ data: null }`) can be passed to
|
|
1237
1237
|
clear the relationship.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { setOwner, getOwner } from '@ember/application';
|
|
2
|
+
import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
|
|
3
|
+
import { g as getModelFactory } from "./schema-provider-JlCneqZH.js";
|
|
4
|
+
import { n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
5
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
|
+
function instantiateRecord(identifier, createRecordArgs) {
|
|
7
|
+
const type = identifier.type;
|
|
8
|
+
|
|
9
|
+
// TODO deprecate allowing unknown args setting
|
|
10
|
+
const createOptions = {
|
|
11
|
+
_createProps: createRecordArgs ?? {},
|
|
12
|
+
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
13
|
+
_secretInit: {
|
|
14
|
+
identifier,
|
|
15
|
+
store: this,
|
|
16
|
+
cb: secretInit
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// ensure that `getOwner(this)` works inside a model instance
|
|
21
|
+
setOwner(createOptions, getOwner(this));
|
|
22
|
+
const factory = getModelFactory(this, type);
|
|
23
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
24
|
+
if (!test) {
|
|
25
|
+
throw new Error(`No model was found for '${type}'`);
|
|
26
|
+
}
|
|
27
|
+
})(factory) : {};
|
|
28
|
+
return factory.class.create(createOptions);
|
|
29
|
+
}
|
|
30
|
+
function teardownRecord(record) {
|
|
31
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
32
|
+
if (!test) {
|
|
33
|
+
throw new Error(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`);
|
|
34
|
+
}
|
|
35
|
+
})('destroy' in record) : {};
|
|
36
|
+
record.destroy();
|
|
37
|
+
}
|
|
38
|
+
function modelFor(modelName) {
|
|
39
|
+
assertPrivateStore(this);
|
|
40
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
41
|
+
if (!test) {
|
|
42
|
+
throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
|
|
43
|
+
}
|
|
44
|
+
})(!this.isDestroyed && !this.isDestroying) : {};
|
|
45
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
46
|
+
if (!test) {
|
|
47
|
+
throw new Error(`You need to pass a model name to the store's modelFor method`);
|
|
48
|
+
}
|
|
49
|
+
})(modelName) : {};
|
|
50
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
51
|
+
if (!test) {
|
|
52
|
+
throw new Error(`Please pass a proper model name to the store's modelFor method`);
|
|
53
|
+
}
|
|
54
|
+
})(typeof modelName === 'string' && modelName.length) : {};
|
|
55
|
+
const type = normalizeModelName(modelName);
|
|
56
|
+
const maybeFactory = getModelFactory(this, type);
|
|
57
|
+
const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
|
|
58
|
+
const ignoreType = !klass || !klass.isModel || this._forceShim;
|
|
59
|
+
if (!ignoreType) {
|
|
60
|
+
return klass;
|
|
61
|
+
}
|
|
62
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
63
|
+
if (!test) {
|
|
64
|
+
throw new Error(`No model was found for '${type}' and no schema handles the type`);
|
|
65
|
+
}
|
|
66
|
+
})(this.schema.hasResource({
|
|
67
|
+
type
|
|
68
|
+
})) : {};
|
|
69
|
+
}
|
|
70
|
+
function secretInit(record, identifier, store) {
|
|
71
|
+
setRecordIdentifier(record, identifier);
|
|
72
|
+
StoreMap.set(record, store);
|
|
73
|
+
}
|
|
74
|
+
export { instantiateRecord as i, modelFor as m, teardownRecord as t };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Store, RequestManager, Fetch, CacheHandler, recordIdentifierFor } from '@warp-drive/core';
|
|
2
|
+
import { SchemaService, registerDerivations, instantiateRecord as instantiateRecord$1, teardownRecord as teardownRecord$1 } from '@warp-drive/core/reactive';
|
|
3
|
+
import { DefaultCachePolicy } from '@warp-drive/core/store';
|
|
4
|
+
import { LegacyNetworkHandler, adapterFor, serializerFor, pushPayload, normalize, serializeRecord, cleanup } from './compat.js';
|
|
5
|
+
import { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from './compat/extensions.js';
|
|
6
|
+
import '@ember/object';
|
|
7
|
+
import '@warp-drive/core/types/symbols';
|
|
8
|
+
import '@ember/debug';
|
|
9
|
+
import '@warp-drive/utilities/string';
|
|
10
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
11
|
+
import '@warp-drive/core/store/-private';
|
|
12
|
+
import "./errors-COviC59J.js";
|
|
13
|
+
import "./schema-provider-JlCneqZH.js";
|
|
14
|
+
import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-Bp8SIQBU.js";
|
|
15
|
+
import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
|
|
16
|
+
import { restoreDeprecatedStoreBehaviors } from './store.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @module
|
|
20
|
+
* @mergeModuleWith <project>
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Use the legacy store with the given options.
|
|
25
|
+
*/
|
|
26
|
+
function useLegacyStore(options, StoreKlass = Store) {
|
|
27
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
28
|
+
if (!test) {
|
|
29
|
+
throw new Error(`If legacyRequests is true, linksMode must be false`);
|
|
30
|
+
}
|
|
31
|
+
})(!(options.linksMode && options.legacyRequests)) : {};
|
|
32
|
+
class LegacyConfiguredStore extends StoreKlass {
|
|
33
|
+
requestManager = new RequestManager().use([options.linksMode ? null : LegacyNetworkHandler, ...(options.handlers ?? []), Fetch].filter(Boolean)).useCache(CacheHandler);
|
|
34
|
+
lifetimes = options.policy ?? new DefaultCachePolicy({
|
|
35
|
+
apiCacheHardExpires: 15 * 60 * 1000,
|
|
36
|
+
// 15 minutes
|
|
37
|
+
apiCacheSoftExpires: 1 * 30 * 1000,
|
|
38
|
+
// 30 seconds
|
|
39
|
+
constraints: {
|
|
40
|
+
headers: {
|
|
41
|
+
'X-WarpDrive-Expires': true,
|
|
42
|
+
'Cache-Control': true,
|
|
43
|
+
Expires: true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
createSchemaService() {
|
|
48
|
+
// prepare for PolarisMode
|
|
49
|
+
const schema = new SchemaService();
|
|
50
|
+
registerDerivations(schema);
|
|
51
|
+
if (options.schemas) schema.registerResources(options.schemas);
|
|
52
|
+
if (options.traits) {
|
|
53
|
+
for (const trait of options.traits) {
|
|
54
|
+
schema.registerTrait(trait);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (options.derivations) {
|
|
58
|
+
for (const derivation of options.derivations) {
|
|
59
|
+
schema.registerDerivation(derivation);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (options.transformations) {
|
|
63
|
+
for (const transformation of options.transformations) {
|
|
64
|
+
schema.registerTransformation(transformation);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (options.hashFns) {
|
|
68
|
+
for (const hashFn of options.hashFns) {
|
|
69
|
+
schema.registerHashFn(hashFn);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {
|
|
73
|
+
for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {
|
|
74
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Add support for LegacyMode ReactiveResource with Maximal coverage
|
|
79
|
+
// for upgrading from 4.x
|
|
80
|
+
registerDerivations$1(schema);
|
|
81
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);
|
|
82
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);
|
|
83
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);
|
|
84
|
+
|
|
85
|
+
// Add fallback for Models
|
|
86
|
+
return new DelegatingSchemaService(this, schema);
|
|
87
|
+
}
|
|
88
|
+
createCache(capabilities) {
|
|
89
|
+
// eslint-disable-next-line new-cap
|
|
90
|
+
return new options.cache(capabilities);
|
|
91
|
+
}
|
|
92
|
+
instantiateRecord(key, createArgs) {
|
|
93
|
+
if (this.schema.isDelegated(key)) {
|
|
94
|
+
return instantiateRecord.call(this, key, createArgs);
|
|
95
|
+
}
|
|
96
|
+
return instantiateRecord$1(this, key, createArgs);
|
|
97
|
+
}
|
|
98
|
+
teardownRecord(record) {
|
|
99
|
+
const key = recordIdentifierFor(record);
|
|
100
|
+
if (this.schema.isDelegated(key)) {
|
|
101
|
+
return teardownRecord.call(this, record);
|
|
102
|
+
}
|
|
103
|
+
return teardownRecord$1(record);
|
|
104
|
+
}
|
|
105
|
+
modelFor(type) {
|
|
106
|
+
assertType(this.schema, type);
|
|
107
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
108
|
+
if (!test) {
|
|
109
|
+
throw new Error(`modelFor should only be used to lookup legacy models when in linksMode`);
|
|
110
|
+
}
|
|
111
|
+
})(!options.linksMode || this.schema.isDelegated({
|
|
112
|
+
type
|
|
113
|
+
})) : {};
|
|
114
|
+
return modelFor.call(this, type) || super.modelFor(type);
|
|
115
|
+
}
|
|
116
|
+
adapterFor(modelName, _allowMissing) {
|
|
117
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
118
|
+
if (!test) {
|
|
119
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
120
|
+
}
|
|
121
|
+
})(!options.linksMode) : {};
|
|
122
|
+
// @ts-expect-error
|
|
123
|
+
return adapterFor.call(this, modelName, _allowMissing);
|
|
124
|
+
}
|
|
125
|
+
serializerFor(...args) {
|
|
126
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
127
|
+
if (!test) {
|
|
128
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
129
|
+
}
|
|
130
|
+
})(!options.linksMode) : {};
|
|
131
|
+
return serializerFor.call(this, ...args);
|
|
132
|
+
}
|
|
133
|
+
pushPayload(...args) {
|
|
134
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
135
|
+
if (!test) {
|
|
136
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
137
|
+
}
|
|
138
|
+
})(!options.linksMode) : {};
|
|
139
|
+
return pushPayload.call(this, ...args);
|
|
140
|
+
}
|
|
141
|
+
normalize(...args) {
|
|
142
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
143
|
+
if (!test) {
|
|
144
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
145
|
+
}
|
|
146
|
+
})(!options.linksMode) : {};
|
|
147
|
+
return normalize.call(this, ...args);
|
|
148
|
+
}
|
|
149
|
+
serializeRecord(...args) {
|
|
150
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
151
|
+
if (!test) {
|
|
152
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
153
|
+
}
|
|
154
|
+
})(!options.linksMode) : {};
|
|
155
|
+
return serializeRecord.call(this, ...args);
|
|
156
|
+
}
|
|
157
|
+
destroy() {
|
|
158
|
+
if (!options.linksMode) {
|
|
159
|
+
cleanup.call(this);
|
|
160
|
+
}
|
|
161
|
+
super.destroy();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (options.legacyRequests) {
|
|
165
|
+
restoreDeprecatedStoreBehaviors(LegacyConfiguredStore);
|
|
166
|
+
}
|
|
167
|
+
return LegacyConfiguredStore;
|
|
168
|
+
}
|
|
169
|
+
function assertType(schema, type) {
|
|
170
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
171
|
+
if (!test) {
|
|
172
|
+
throw new Error(`Expected type ${type} to be a valid ResourceType`);
|
|
173
|
+
}
|
|
174
|
+
})(schema.hasResource({
|
|
175
|
+
type
|
|
176
|
+
})) : {};
|
|
177
|
+
}
|
|
178
|
+
export { useLegacyStore };
|
|
@@ -31,12 +31,12 @@ const PRIMARY_ATTRIBUTE_KEY = 'base';
|
|
|
31
31
|
{@link Handler} instead to be used with the {@link RequestManager}
|
|
32
32
|
:::
|
|
33
33
|
|
|
34
|
-
In
|
|
34
|
+
In WarpDrive a Serializer is used to serialize and deserialize
|
|
35
35
|
records when they are transferred in and out of an external source.
|
|
36
36
|
This process involves normalizing property names, transforming
|
|
37
37
|
attribute values and serializing relationships.
|
|
38
38
|
|
|
39
|
-
By default,
|
|
39
|
+
By default, WarpDrive uses and recommends the `JSONAPISerializer`.
|
|
40
40
|
|
|
41
41
|
`JSONSerializer` is useful for simpler or legacy backends that may
|
|
42
42
|
not support the http://jsonapi.org/ spec.
|
package/dist/model/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-
|
|
1
|
+
export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-COviC59J.js";
|
|
@@ -4,8 +4,8 @@ import { Context } from '@warp-drive/core/reactive/-private';
|
|
|
4
4
|
import { notifyInternalSignal, assertPrivateStore } from '@warp-drive/core/store/-private';
|
|
5
5
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
6
6
|
import { Type } from '@warp-drive/core/types/symbols';
|
|
7
|
-
import { l as lookupLegacySupport, E as Errors } from "../errors-
|
|
8
|
-
import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord,
|
|
7
|
+
import { l as lookupLegacySupport, E as Errors } from "../errors-COviC59J.js";
|
|
8
|
+
import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-JlCneqZH.js";
|
|
9
9
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -417,7 +417,9 @@ function registerDerivations(schema) {
|
|
|
417
417
|
*/
|
|
418
418
|
|
|
419
419
|
class DelegatingSchemaService {
|
|
420
|
+
/** @internal */
|
|
420
421
|
_preferred;
|
|
422
|
+
/** @internal */
|
|
421
423
|
_secondary;
|
|
422
424
|
constructor(store, schema) {
|
|
423
425
|
this._preferred = schema;
|
package/dist/model.js
CHANGED
|
@@ -4,12 +4,11 @@ import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
|
4
4
|
import { i as isElementDescriptor, n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
6
|
import { warn, deprecate } from '@ember/debug';
|
|
7
|
-
import { assertPrivateStore
|
|
8
|
-
import { l as lookupLegacySupport } from "./errors-
|
|
7
|
+
import { assertPrivateStore } from '@warp-drive/core/store/-private';
|
|
8
|
+
import { l as lookupLegacySupport } from "./errors-COviC59J.js";
|
|
9
9
|
import { singularize, dasherize } from '@warp-drive/utilities/string';
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
import { setOwner, getOwner } from '@ember/application';
|
|
10
|
+
export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-JlCneqZH.js";
|
|
11
|
+
export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-Bp8SIQBU.js";
|
|
13
12
|
function _attr(type, options) {
|
|
14
13
|
if (typeof type === 'object') {
|
|
15
14
|
options = type;
|
|
@@ -90,7 +89,7 @@ function _attr(type, options) {
|
|
|
90
89
|
`attr` defines an attribute on a {@link Model}.
|
|
91
90
|
By default, attributes are passed through as-is, however you can specify an
|
|
92
91
|
optional type to have the value automatically transformed.
|
|
93
|
-
|
|
92
|
+
WarpDrive ships with four basic transform types: `string`, `number`,
|
|
94
93
|
`boolean` and `date`. You can define your own transforms by subclassing
|
|
95
94
|
{@link Transform}.
|
|
96
95
|
|
|
@@ -339,7 +338,7 @@ function _belongsTo(type, options) {
|
|
|
339
338
|
|
|
340
339
|
#### Sync vs Async Relationships
|
|
341
340
|
|
|
342
|
-
|
|
341
|
+
WarpDrive fulfills relationships using resource data available in
|
|
343
342
|
the cache.
|
|
344
343
|
|
|
345
344
|
Sync relationships point directly to the known related resources.
|
|
@@ -578,7 +577,7 @@ function _hasMany(type, options) {
|
|
|
578
577
|
|
|
579
578
|
#### Sync vs Async Relationships
|
|
580
579
|
|
|
581
|
-
|
|
580
|
+
WarpDrive fulfills relationships using resource data available in
|
|
582
581
|
the cache.
|
|
583
582
|
|
|
584
583
|
Sync relationships point directly to the known related resources.
|
|
@@ -665,72 +664,4 @@ function hasMany(type, options) {
|
|
|
665
664
|
}
|
|
666
665
|
return _hasMany(type, options);
|
|
667
666
|
}
|
|
668
|
-
|
|
669
|
-
const type = identifier.type;
|
|
670
|
-
|
|
671
|
-
// TODO deprecate allowing unknown args setting
|
|
672
|
-
const createOptions = {
|
|
673
|
-
_createProps: createRecordArgs,
|
|
674
|
-
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
675
|
-
_secretInit: {
|
|
676
|
-
identifier,
|
|
677
|
-
store: this,
|
|
678
|
-
cb: secretInit
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
// ensure that `getOwner(this)` works inside a model instance
|
|
683
|
-
setOwner(createOptions, getOwner(this));
|
|
684
|
-
const factory = getModelFactory(this, type);
|
|
685
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
686
|
-
if (!test) {
|
|
687
|
-
throw new Error(`No model was found for '${type}'`);
|
|
688
|
-
}
|
|
689
|
-
})(factory) : {};
|
|
690
|
-
return factory.class.create(createOptions);
|
|
691
|
-
}
|
|
692
|
-
function teardownRecord(record) {
|
|
693
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
694
|
-
if (!test) {
|
|
695
|
-
throw new Error(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`);
|
|
696
|
-
}
|
|
697
|
-
})('destroy' in record) : {};
|
|
698
|
-
record.destroy();
|
|
699
|
-
}
|
|
700
|
-
function modelFor(modelName) {
|
|
701
|
-
assertPrivateStore(this);
|
|
702
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
703
|
-
if (!test) {
|
|
704
|
-
throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
|
|
705
|
-
}
|
|
706
|
-
})(!this.isDestroyed && !this.isDestroying) : {};
|
|
707
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
708
|
-
if (!test) {
|
|
709
|
-
throw new Error(`You need to pass a model name to the store's modelFor method`);
|
|
710
|
-
}
|
|
711
|
-
})(modelName) : {};
|
|
712
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
713
|
-
if (!test) {
|
|
714
|
-
throw new Error(`Please pass a proper model name to the store's modelFor method`);
|
|
715
|
-
}
|
|
716
|
-
})(typeof modelName === 'string' && modelName.length) : {};
|
|
717
|
-
const type = normalizeModelName(modelName);
|
|
718
|
-
const maybeFactory = getModelFactory(this, type);
|
|
719
|
-
const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
|
|
720
|
-
const ignoreType = !klass || !klass.isModel || this._forceShim;
|
|
721
|
-
if (!ignoreType) {
|
|
722
|
-
return klass;
|
|
723
|
-
}
|
|
724
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
725
|
-
if (!test) {
|
|
726
|
-
throw new Error(`No model was found for '${type}' and no schema handles the type`);
|
|
727
|
-
}
|
|
728
|
-
})(this.schema.hasResource({
|
|
729
|
-
type
|
|
730
|
-
})) : {};
|
|
731
|
-
}
|
|
732
|
-
function secretInit(record, identifier, store) {
|
|
733
|
-
setRecordIdentifier(record, identifier);
|
|
734
|
-
StoreMap.set(record, store);
|
|
735
|
-
}
|
|
736
|
-
export { attr, belongsTo, hasMany, instantiateRecord, modelFor, teardownRecord };
|
|
667
|
+
export { attr, belongsTo, hasMany };
|
|
@@ -4,8 +4,8 @@ import EmberObject from '@ember/object';
|
|
|
4
4
|
import { recordIdentifierFor, storeFor } from '@warp-drive/core';
|
|
5
5
|
import { assertPrivateStore, notifyInternalSignal, peekInternalSignal, withSignalStore, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
|
|
6
6
|
import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
7
|
-
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-
|
|
8
|
-
import { u as upgradeStore, F as FetchManager } from "./-private-
|
|
7
|
+
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-COviC59J.js";
|
|
8
|
+
import { u as upgradeStore, F as FetchManager } from "./-private-B1pSSN52.js";
|
|
9
9
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
10
10
|
import { cacheFor } from '@ember/object/internals';
|
|
11
11
|
import { Context } from '@warp-drive/core/reactive/-private';
|
|
@@ -254,7 +254,7 @@ function isInvalidError(error) {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
|
-
Historically
|
|
257
|
+
Historically WarpDrive managed a state machine
|
|
258
258
|
for each record, the localState for which
|
|
259
259
|
was reflected onto Model.
|
|
260
260
|
|
|
@@ -680,11 +680,6 @@ function computeOnce(target, propertyName, desc) {
|
|
|
680
680
|
};
|
|
681
681
|
return desc;
|
|
682
682
|
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* @noInheritDoc
|
|
686
|
-
*/
|
|
687
|
-
|
|
688
683
|
/**
|
|
689
684
|
* Base class from which Models can be defined.
|
|
690
685
|
*
|
|
@@ -727,7 +722,10 @@ function computeOnce(target, propertyName, desc) {
|
|
|
727
722
|
* the class to use as the reactive object for data of resource
|
|
728
723
|
* of that type.
|
|
729
724
|
*
|
|
725
|
+
* @public
|
|
730
726
|
* @noInheritDoc
|
|
727
|
+
* @hideconstructor
|
|
728
|
+
* @legacy
|
|
731
729
|
*/
|
|
732
730
|
class Model extends EmberObject {
|
|
733
731
|
/** @internal */
|
|
@@ -1255,7 +1253,7 @@ class Model extends EmberObject {
|
|
|
1255
1253
|
/**
|
|
1256
1254
|
Represents the model's class name as a string. This can be used to look up the model's class name through
|
|
1257
1255
|
`Store`'s modelFor method.
|
|
1258
|
-
`modelName` is generated for you by
|
|
1256
|
+
`modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.
|
|
1259
1257
|
For example:
|
|
1260
1258
|
```javascript
|
|
1261
1259
|
store.modelFor('post').modelName; // 'post'
|
|
@@ -2337,4 +2335,4 @@ function getModelFactory(store, type) {
|
|
|
2337
2335
|
}
|
|
2338
2336
|
return factory;
|
|
2339
2337
|
}
|
|
2340
|
-
export { Model as M, RecordState as R, _save as _, save as a, buildSchema as b, _reload as c, reload as d, _destroyRecord as e, destroyRecord as f,
|
|
2338
|
+
export { Model as M, RecordState as R, _save as _, save as a, buildSchema as b, _reload as c, reload as d, _destroyRecord as e, destroyRecord as f, getModelFactory as g, hasMany as h, deleteRecord as i, changedAttributes as j, belongsTo as k, createSnapshot as l, restoreDeprecatedModelRequestBehaviors as m, rollbackAttributes as r, serialize as s, unloadRecord as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
3
|
import '@warp-drive/core/reactive/-private';
|
|
4
|
-
import "./-private-
|
|
4
|
+
import "./-private-B1pSSN52.js";
|
|
5
5
|
import '@warp-drive/core/store/-private';
|
|
6
6
|
const newline = /\r?\n/;
|
|
7
7
|
function parseResponseHeaders(headersString) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { dasherize, pluralize, singularize } from '@warp-drive/utilities/string';
|
|
3
|
-
import { J as JSONSerializer } from "../json-
|
|
3
|
+
import { J as JSONSerializer } from "../json-ksWOHRfq.js";
|
|
4
4
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
5
5
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
package/dist/serializer/json.js
CHANGED
|
@@ -2,5 +2,5 @@ import '@ember/application';
|
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import '@warp-drive/utilities/string';
|
|
4
4
|
import '../serializer.js';
|
|
5
|
-
export { J as JSONSerializer } from "../json-
|
|
5
|
+
export { J as JSONSerializer } from "../json-ksWOHRfq.js";
|
|
6
6
|
import '@embroider/macros';
|
package/dist/serializer/rest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { camelize, dasherize, singularize } from '@warp-drive/utilities/string';
|
|
3
|
-
import { J as JSONSerializer, c as coerceId } from "../json-
|
|
3
|
+
import { J as JSONSerializer, c as coerceId } from "../json-ksWOHRfq.js";
|
|
4
4
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
5
5
|
import Mixin from '@ember/object/mixin';
|
|
6
6
|
|
package/dist/store.js
CHANGED
|
@@ -524,6 +524,9 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
|
524
524
|
});
|
|
525
525
|
return promise.then(document => document.content);
|
|
526
526
|
};
|
|
527
|
+
|
|
528
|
+
// do not put a ts-expect-error here, because typedoc will fail to
|
|
529
|
+
// build due to this error only occurring when references are in use in the editor
|
|
527
530
|
StoreKlass.prototype.getReference = function (resource, id) {
|
|
528
531
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
529
532
|
if (!test) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/legacy",
|
|
3
|
-
"version": "5.8.0-alpha.
|
|
3
|
+
"version": "5.8.0-alpha.7",
|
|
4
4
|
"description": "Decommissioned Packages for WarpDrive | Things your app might still want to maintain use of for a little longer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@warp-drive/core": "5.8.0-alpha.
|
|
36
|
-
"@warp-drive/utilities": "5.8.0-alpha.
|
|
35
|
+
"@warp-drive/core": "5.8.0-alpha.7",
|
|
36
|
+
"@warp-drive/utilities": "5.8.0-alpha.7"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@embroider/macros": "^1.18.1"
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
44
44
|
"@babel/preset-typescript": "^7.27.1",
|
|
45
45
|
"@types/jquery": "^3.5.33",
|
|
46
|
-
"@warp-drive/internal-config": "5.8.0-alpha.
|
|
47
|
-
"@warp-drive/core": "5.8.0-alpha.
|
|
48
|
-
"@warp-drive/utilities": "5.8.0-alpha.
|
|
46
|
+
"@warp-drive/internal-config": "5.8.0-alpha.7",
|
|
47
|
+
"@warp-drive/core": "5.8.0-alpha.7",
|
|
48
|
+
"@warp-drive/utilities": "5.8.0-alpha.7",
|
|
49
49
|
"ember-source": "~6.6.0",
|
|
50
50
|
"decorator-transforms": "^2.3.0",
|
|
51
51
|
"expect-type": "^1.2.2",
|