@warp-drive/legacy 5.7.0-alpha.0 → 5.7.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import type { JsonApiError } from "@warp-drive/core/store/-types/q/record-data-json-api";
1
+ import type { ApiError } from "@warp-drive/core/types/spec/error";
2
2
  export interface AdapterRequestError<T extends string = string> extends Error {
3
3
  isAdapterError: true;
4
4
  code: T;
5
- errors: JsonApiError[];
5
+ errors: ApiError[];
6
6
  }
7
7
  export interface AdapterRequestErrorConstructor<Instance extends AdapterRequestError = AdapterRequestError> {
8
8
  new (errors?: unknown[], message?: string): Instance;
@@ -32,9 +32,12 @@ export declare function hasMany<
32
32
  K extends MaybeHasManyFields<T>
33
33
  >(this: T, prop: K): HasManyReference<T, K>;
34
34
  export declare function reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
35
+ export declare function _reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
35
36
  export declare function changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash;
36
37
  export declare function serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): unknown;
37
38
  export declare function deleteRecord<T extends MinimalLegacyRecord>(this: T): void;
38
39
  export declare function save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
40
+ export declare function _save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
39
41
  export declare function destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
42
+ export declare function _destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
40
43
  export declare function createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T>;
@@ -47,6 +47,8 @@ interface Model {
47
47
  /** @internal */
48
48
  ___private_notifications: object;
49
49
  /** @internal */
50
+ _isReloading: boolean;
51
+ /** @internal */
50
52
  [RecordStore]: Store;
51
53
  /**
52
54
  Create a JSON representation of the record, using the serialization
@@ -1319,4 +1321,5 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
1319
1321
  */
1320
1322
  static toString(): string;
1321
1323
  }
1324
+ export declare function restoreDeprecatedModelRequestBehaviors(ModelKlass: typeof Model): void;
1322
1325
  export { Model };
@@ -1,22 +1,3 @@
1
- /**
2
- * This module provides support for migrating away from @ember-data/model
3
- * to @warp-drive/schema-record.
4
- *
5
- * It includes:
6
- *
7
- * - A `withDefaults` function to assist in creating a schema in LegacyMode
8
- * - A `registerDerivations` function to register the derivations necessary to support LegacyMode
9
- * - A `DelegatingSchemaService` that can be used to provide a schema service that works with both
10
- * @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes.
11
- * - A `WithLegacy` type util that can be used to create a type that includes the legacy
12
- * properties and methods of a record.
13
- *
14
- * Using LegacyMode features on a ReactiveResource *requires* the use of these derivations and schema
15
- * additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone
16
- * to assist in more rapidly adopting modern WarpDrive features.
17
- *
18
- * @module
19
- */
20
1
  import type { Store } from "@warp-drive/core";
21
2
  import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "@warp-drive/core/reactive";
22
3
  import type { ExtensibleField } from "@warp-drive/core/reactive/-private/schema";
@@ -170,6 +151,7 @@ export type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
170
151
  * @public
171
152
  */
172
153
  export declare function withDefaults(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
154
+ export declare function withRestoredDeprecatedModelRequestBehaviors(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
173
155
  /**
174
156
  * A function which registers the necessary derivations to support
175
157
  * the LegacyMode features of @ember-data/model while migrating to WarpDrive.
@@ -39,7 +39,7 @@ and dasherized.
39
39
  export { attr } from "./model/-private/attr.js";
40
40
  export { belongsTo } from "./model/-private/belongs-to.js";
41
41
  export { hasMany } from "./model/-private/has-many.js";
42
- export { Model } from "./model/-private/model.js";
42
+ export { Model, restoreDeprecatedModelRequestBehaviors } from "./model/-private/model.js";
43
43
  export { Model as default } from "./model/-private/model.js";
44
44
  export type { PromiseBelongsTo as AsyncBelongsTo } from "./model/-private/promise-belongs-to.js";
45
45
  export type { PromiseManyArray as AsyncHasMany } from "./model/-private/promise-many-array.js";
@@ -0,0 +1,235 @@
1
+ import { type InstanceCache } from "@warp-drive/core/store/-private";
2
+ import type { StableNewRecordIdentifier, StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
+ import type { Value } from "@warp-drive/core/types/json/raw";
4
+ import type { Includes, OpaqueRecordInstance, TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
5
+ import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
6
+ import type { SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
7
+ import type { Store } from "../store.js";
8
+ export declare function preloadData(store: Store, identifier: StableNewRecordIdentifier, preload: Record<string, Value>): void;
9
+ export interface BaseFinderOptions<T = unknown> {
10
+ reload?: boolean;
11
+ backgroundReload?: boolean;
12
+ include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
13
+ adapterOptions?: Record<string, unknown>;
14
+ }
15
+ export interface FindRecordOptions<T = unknown> extends BaseFinderOptions<T> {
16
+ /**
17
+ * Data to preload into the store before the request is made.
18
+ * This feature is *highly* discouraged and has no corresponding
19
+ * feature when using builders and handlers.
20
+ *
21
+ * Excepting relationships: the data should be in the form of a
22
+ * JSON object where the keys are fields on the record and the value
23
+ * is the raw value to be added to the cache.
24
+ *
25
+ * Relationships can either be provided as string IDs from which
26
+ * an identifier will be built base upon the relationship's expected
27
+ * resource type, or be record instances from which the identifier
28
+ * will be extracted.
29
+ *
30
+ */
31
+ preload?: Record<string, Value>;
32
+ }
33
+ export type QueryOptions = { [K in string | "adapterOptions"]? : K extends "adapterOptions" ? Record<string, unknown> : unknown };
34
+ export type FindAllOptions<T = unknown> = BaseFinderOptions<T>;
35
+ export type LegacyResourceQuery<T = unknown> = {
36
+ include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
37
+ [key: string]: Value | undefined;
38
+ };
39
+ export type KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;
40
+ /**
41
+ * Minimum subset of static schema methods and properties on the
42
+ * "model" class.
43
+ *
44
+ * Only used when using the legacy schema-service implementation
45
+ * for @ember-data/model or when wrapping schema for legacy
46
+ * Adapters/Serializers.
47
+ *
48
+ */
49
+ export interface ModelSchema<T = unknown> {
50
+ modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
51
+ fields: Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
52
+ attributes: Map<KeyOrString<T>, LegacyAttributeField>;
53
+ relationshipsByName: Map<KeyOrString<T>, LegacyRelationshipField>;
54
+ eachAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
55
+ eachRelationship<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
56
+ eachTransformedAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, type: string | null) => void, binding?: T): void;
57
+ }
58
+ export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: StableRecordIdentifier): boolean;
59
+ /**
60
+ A `RecordReference` is a low-level API that allows users and
61
+ addon authors to perform meta-operations on a record.
62
+
63
+ @hideconstructor
64
+ @public
65
+ */
66
+ export declare class RecordReference {
67
+ /** @internal */
68
+ private store;
69
+ /** @internal */
70
+ // unsubscribe token given to us by the notification manager
71
+ private ___token;
72
+ /** @internal */
73
+ private ___identifier;
74
+ /** @internal */
75
+ private _ref;
76
+ constructor(store: Store, identifier: StableRecordIdentifier);
77
+ /** @internal */
78
+ destroy(): void;
79
+ get type(): string;
80
+ /**
81
+ The `id` of the record that this reference refers to.
82
+
83
+ Together, the `type` and `id` properties form a composite key for
84
+ the identity map.
85
+
86
+ Example
87
+
88
+ ```javascript
89
+ let userRef = store.getReference('user', 1);
90
+
91
+ userRef.id(); // '1'
92
+ ```
93
+
94
+ @public
95
+ @return The id of the record.
96
+ */
97
+ id(): string | null;
98
+ /**
99
+ The `identifier` of the record that this reference refers to.
100
+
101
+ Together, the `type` and `id` properties form a composite key for
102
+ the identity map.
103
+
104
+ Example
105
+
106
+ ```javascript
107
+ let userRef = store.getReference('user', 1);
108
+
109
+ userRef.identifier(); // '1'
110
+ ```
111
+
112
+ @public
113
+ @return The identifier of the record.
114
+ */
115
+ identifier(): StableRecordIdentifier;
116
+ /**
117
+ How the reference will be looked up when it is loaded. Currently
118
+ this always returns `identity` to signify that a record will be
119
+ loaded by its `type` and `id`.
120
+
121
+ Example
122
+
123
+ ```javascript
124
+ const userRef = store.getReference('user', 1);
125
+
126
+ userRef.remoteType(); // 'identity'
127
+ ```
128
+
129
+ @public
130
+ */
131
+ remoteType(): "identity";
132
+ /**
133
+ This API allows you to provide a reference with new data. The
134
+ simplest usage of this API is similar to `store.push`: you provide a
135
+ normalized hash of data and the object represented by the reference
136
+ will update.
137
+
138
+ If you pass a promise to `push`, Ember Data will not ask the adapter
139
+ for the data if another attempt to fetch it is made in the
140
+ interim. When the promise resolves, the underlying object is updated
141
+ with the new data, and the promise returned by *this function* is resolved
142
+ with that object.
143
+
144
+ For example, `recordReference.push(promise)` will be resolved with a
145
+ record.
146
+
147
+ Example
148
+
149
+ ```javascript
150
+ let userRef = store.getReference('user', 1);
151
+
152
+ // provide data for reference
153
+ userRef.push({
154
+ data: {
155
+ id: "1",
156
+ type: "user",
157
+ attributes: {
158
+ username: "@user"
159
+ }
160
+ }
161
+ }).then(function(user) {
162
+ userRef.value() === user;
163
+ });
164
+ ```
165
+
166
+ @public
167
+ @param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
168
+ @return a promise for the value (record or relationship)
169
+ */
170
+ push(objectOrPromise: SingleResourceDocument | Promise<SingleResourceDocument>): Promise<OpaqueRecordInstance>;
171
+ /**
172
+ If the entity referred to by the reference is already loaded, it is
173
+ present as `reference.value`. Otherwise the value returned by this function
174
+ is `null`.
175
+
176
+ Example
177
+
178
+ ```javascript
179
+ let userRef = store.getReference('user', 1);
180
+
181
+ userRef.value(); // user
182
+ ```
183
+
184
+ @public
185
+ @return {Model} the record for this RecordReference
186
+ */
187
+ value(): OpaqueRecordInstance | null;
188
+ /**
189
+ Triggers a fetch for the backing entity based on its `remoteType`
190
+ (see `remoteType` definitions per reference type).
191
+
192
+ Example
193
+
194
+ ```javascript
195
+ let userRef = store.getReference('user', 1);
196
+
197
+ // load user (via store.find)
198
+ userRef.load().then(...)
199
+ ```
200
+
201
+ @public
202
+ @return the record for this RecordReference
203
+ */
204
+ load(): Promise<unknown>;
205
+ /**
206
+ Reloads the record if it is already loaded. If the record is not
207
+ loaded it will load the record via `store.findRecord`
208
+
209
+ Example
210
+
211
+ ```javascript
212
+ let userRef = store.getReference('user', 1);
213
+
214
+ // or trigger a reload
215
+ userRef.reload().then(...)
216
+ ```
217
+
218
+ @public
219
+ @return the record for this RecordReference
220
+ */
221
+ reload(): Promise<unknown>;
222
+ }
223
+ export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
224
+ // Mimics the static apis of @ember-data/model
225
+ export declare class ShimModelClass<T = unknown> implements ModelSchema<T> {
226
+ __store: Store;
227
+ modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
228
+ constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string);
229
+ get fields(): Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
230
+ get attributes(): Map<KeyOrString<T>, LegacyAttributeField>;
231
+ get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField>;
232
+ eachAttribute<K extends KeyOrString<T>>(callback: (key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
233
+ eachRelationship<K extends KeyOrString<T>>(callback: (key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
234
+ eachTransformedAttribute<K extends KeyOrString<T>>(callback: (key: K, type: string | null) => void, binding?: T): void;
235
+ }
@@ -0,0 +1,3 @@
1
+ import type { Store } from "@warp-drive/core";
2
+ export declare function restoreDeprecatedStoreBehaviors(StoreKlass: typeof Store): void;
3
+ export { Store };
@@ -4,6 +4,72 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
6
6
 
7
+ /**
8
+ ## Overview
9
+
10
+ <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
11
+ <p>
12
+ ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
13
+ If starting a new app or thinking of implementing a new adapter, consider writing a
14
+ <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
15
+ </p>
16
+ </blockquote>
17
+
18
+ An `AdapterError` is used by an adapter to signal that an error occurred
19
+ during a request to an external API. It indicates a generic error, and
20
+ subclasses are used to indicate specific error states.
21
+
22
+ To create a custom error to signal a specific error state in communicating
23
+ with an external API, extend the `AdapterError`. For example, if the
24
+ external API exclusively used HTTP `503 Service Unavailable` to indicate
25
+ it was closed for maintenance:
26
+
27
+ ```js [app/adapters/maintenance-error.js]
28
+ import AdapterError from '@ember-data/adapter/error';
29
+
30
+ export default AdapterError.extend({ message: "Down for maintenance." });
31
+ ```
32
+
33
+ This error would then be returned by an adapter's `handleResponse` method:
34
+
35
+ ```js [app/adapters/application.js]
36
+ import JSONAPIAdapter from '@ember-data/adapter/json-api';
37
+ import MaintenanceError from './maintenance-error';
38
+
39
+ export default class ApplicationAdapter extends JSONAPIAdapter {
40
+ handleResponse(status) {
41
+ if (503 === status) {
42
+ return new MaintenanceError();
43
+ }
44
+
45
+ return super.handleResponse(...arguments);
46
+ }
47
+ }
48
+ ```
49
+
50
+ And can then be detected in an application and used to send the user to an
51
+ `under-maintenance` route:
52
+
53
+ ```js [app/routes/application.js]
54
+ import MaintenanceError from '../adapters/maintenance-error';
55
+
56
+ export default class ApplicationRoute extends Route {
57
+ actions: {
58
+ error(error, transition) {
59
+ if (error instanceof MaintenanceError) {
60
+ this.transitionTo('under-maintenance');
61
+ return;
62
+ }
63
+
64
+ // ...other error handling logic
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ @class AdapterError
71
+ @public
72
+ */
7
73
  function _AdapterError(errors, message = 'Adapter operation failed') {
8
74
  this.isAdapterError = true;
9
75
  const error = Error.call(this, message);
@@ -776,7 +776,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
776
776
  if (this.isSuccess(status, headers, payload)) {
777
777
  return payload;
778
778
  } else if (this.isInvalid(status, headers, payload)) {
779
- // @ts-expect-error needs cast to JsonApiError
779
+ // @ts-expect-error needs cast to ApiError
780
780
  return new InvalidError(typeof payload === 'object' && 'errors' in payload ? payload.errors : undefined);
781
781
  }
782
782
  const errors = this.normalizeErrorResponse(status, headers, payload);
@@ -1,28 +1,8 @@
1
1
  import { SkipCache } from '@warp-drive/core/types/request';
2
- import { deprecate } from '@ember/debug';
3
- import { dasherize } from '@warp-drive/utilities/string';
2
+ import { n as normalizeModelName, i as isMaybeIdentifier } from "../utils-Cqw9eRj5.js";
4
3
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
4
  import { ensureStringId, constructResource } from '@warp-drive/core/store/-private';
6
5
  import { storeFor, recordIdentifierFor } from '@warp-drive/core';
7
- function isMaybeIdentifier(maybeIdentifier) {
8
- return Boolean(maybeIdentifier !== null && typeof maybeIdentifier === 'object' && ('id' in maybeIdentifier && 'type' in maybeIdentifier && maybeIdentifier.id && maybeIdentifier.type || maybeIdentifier.lid));
9
- }
10
- function normalizeModelName(type) {
11
- if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
12
- const result = dasherize(type);
13
- deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
14
- id: 'ember-data:deprecate-non-strict-types',
15
- until: '6.0',
16
- for: 'ember-data',
17
- since: {
18
- available: '4.13',
19
- enabled: '5.3'
20
- }
21
- });
22
- return result;
23
- }
24
- return type;
25
- }
26
6
 
27
7
  /**
28
8
  This function builds a request config to perform a `findAll` request for the given type.
@@ -1,9 +1,10 @@
1
+ import { deprecate } from '@ember/debug';
1
2
  import { recordIdentifierFor } from '@warp-drive/core';
2
3
  import { notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
3
4
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
4
5
  import { Type } from '@warp-drive/core/types/symbols';
5
6
  import { l as lookupLegacySupport, E as Errors } from "../errors-BX5wowuz.js";
6
- import { b as buildSchema, u as unloadRecord, s as serialize, a as save, r as rollbackAttributes, c as reload, h as hasMany, d as destroyRecord, e as deleteRecord, R as RecordState, f as changedAttributes, g as belongsTo, i as createSnapshot } from "../schema-provider-BdQhkT-Q.js";
7
+ 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, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-Cbnf6sKm.js";
7
8
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
8
9
 
9
10
  /**
@@ -25,7 +26,6 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
25
26
  *
26
27
  * @module
27
28
  */
28
-
29
29
  // 'isDestroying', 'isDestroyed'
30
30
  const LegacyFields = ['_createSnapshot', 'adapterError', 'belongsTo', 'changedAttributes', 'constructor', 'currentState', 'deleteRecord', 'destroyRecord', 'dirtyType', 'errors', 'hasDirtyAttributes', 'hasMany', 'isDeleted', 'isEmpty', 'isError', 'isLoaded', 'isLoading', 'isNew', 'isSaving', 'isValid', 'reload', 'rollbackAttributes', 'save', 'serialize', 'unloadRecord'];
31
31
 
@@ -78,10 +78,13 @@ function legacySupport(record, options, prop) {
78
78
  state = {};
79
79
  LegacySupport.set(record, state);
80
80
  }
81
+ const suppressDeprecation = Boolean(options && options.suppressDeprecation);
81
82
  switch (prop) {
82
83
  case '_createSnapshot':
84
+ // FIXME should be deprecated too?
83
85
  return createSnapshot;
84
86
  case 'adapterError':
87
+ // FIXME should be deprecated too?
85
88
  return record.currentState.adapterError;
86
89
  case 'belongsTo':
87
90
  return belongsTo;
@@ -98,10 +101,11 @@ function legacySupport(record, options, prop) {
98
101
  case 'deleteRecord':
99
102
  return deleteRecord;
100
103
  case 'destroyRecord':
101
- return destroyRecord;
104
+ return suppressDeprecation ? _destroyRecord : destroyRecord;
102
105
  case 'dirtyType':
103
106
  return record.currentState.dirtyType;
104
107
  case 'errors':
108
+ // FIXME should be deprecated too?
105
109
  // @ts-expect-error
106
110
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
107
111
  return state.errors = state.errors || Errors.create({
@@ -128,12 +132,13 @@ function legacySupport(record, options, prop) {
128
132
  case 'isValid':
129
133
  return record.currentState.isValid;
130
134
  case 'reload':
131
- return reload;
135
+ return suppressDeprecation ? _reload : reload;
132
136
  case 'rollbackAttributes':
133
137
  return rollbackAttributes;
134
138
  case 'save':
135
- return save;
139
+ return suppressDeprecation ? _save : save;
136
140
  case 'serialize':
141
+ // FIXME should be deprecated too? (is somewhat deprecated via store.serializeRecord)
137
142
  return serialize;
138
143
  case 'unloadRecord':
139
144
  return unloadRecord;
@@ -214,6 +219,50 @@ function withDefaults(schema) {
214
219
  kind: 'derived'
215
220
  });
216
221
  });
222
+ schema.fields.push({
223
+ name: '_isReloading',
224
+ kind: '@local',
225
+ type: 'boolean',
226
+ options: {
227
+ defaultValue: false
228
+ }
229
+ });
230
+ schema.fields.push({
231
+ name: 'isDestroying',
232
+ kind: '@local',
233
+ type: 'boolean',
234
+ options: {
235
+ defaultValue: false
236
+ }
237
+ });
238
+ schema.fields.push({
239
+ name: 'isDestroyed',
240
+ kind: '@local',
241
+ type: 'boolean',
242
+ options: {
243
+ defaultValue: false
244
+ }
245
+ });
246
+ schema.objectExtensions = schema.objectExtensions || [];
247
+ schema.objectExtensions.push('deprecated-model-behaviors');
248
+ return schema;
249
+ }
250
+ function withRestoredDeprecatedModelRequestBehaviors(schema) {
251
+ schema.legacy = true;
252
+ schema.identity = {
253
+ kind: '@id',
254
+ name: 'id'
255
+ };
256
+ LegacyFields.forEach(field => {
257
+ schema.fields.push({
258
+ type: '@legacy',
259
+ name: field,
260
+ kind: 'derived',
261
+ options: {
262
+ suppressDeprecation: true
263
+ }
264
+ });
265
+ });
217
266
  schema.fields.push({
218
267
  name: 'isReloading',
219
268
  kind: '@local',
@@ -297,6 +346,34 @@ function registerDerivations(schema) {
297
346
  }
298
347
  }
299
348
  });
349
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension({
350
+ name: 'deprecated-model-behaviors',
351
+ kind: 'object',
352
+ features: {
353
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
354
+ get isReloading() {
355
+ deprecate(`record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`, false, {
356
+ id: 'warp-drive:deprecate-legacy-request-methods',
357
+ until: '6.0',
358
+ for: '@warp-drive/core',
359
+ url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
360
+ since: {
361
+ enabled: '5.7',
362
+ available: '5.7'
363
+ }
364
+ });
365
+ // @ts-expect-error
366
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
367
+ return this._isReloading;
368
+ },
369
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
370
+ set isReloading(v) {
371
+ // @ts-expect-error
372
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
373
+ this._isReloading = v;
374
+ }
375
+ }
376
+ });
300
377
  }
301
378
 
302
379
  /**
@@ -461,4 +538,4 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA
461
538
  return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;
462
539
  };
463
540
  }
464
- export { DelegatingSchemaService, registerDerivations, withDefaults };
541
+ export { DelegatingSchemaService, registerDerivations, withDefaults, withRestoredDeprecatedModelRequestBehaviors };
package/dist/model.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { computed } from '@ember/object';
2
2
  import { recordIdentifierFor } from '@warp-drive/core';
3
3
  import { peekCache, setRecordIdentifier, StoreMap, setCacheFor } from '@warp-drive/core/store/-private';
4
- import { j as isElementDescriptor, n as normalizeModelName, k as getModelFactory } from "./schema-provider-BdQhkT-Q.js";
5
- export { M as Model, b as buildSchema, M as default } from "./schema-provider-BdQhkT-Q.js";
4
+ import { i as isElementDescriptor, n as normalizeModelName } from "./util-Dul6TZts.js";
6
5
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
7
6
  import { warn, deprecate } from '@ember/debug';
8
7
  import { RecordStore } from '@warp-drive/core/types/symbols';
9
8
  import { l as lookupLegacySupport } from "./errors-BX5wowuz.js";
10
9
  import { singularize, dasherize } from '@warp-drive/utilities/string';
10
+ import { l as getModelFactory } from "./schema-provider-Cbnf6sKm.js";
11
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-Cbnf6sKm.js";
11
12
  import { setOwner, getOwner } from '@ember/application';
12
13
  function _attr(type, options) {
13
14
  if (typeof type === 'object') {