@warp-drive/legacy 5.7.0-alpha.11 → 5.7.0-alpha.13

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.
@@ -14,46 +14,73 @@ adapters and serializers for certain requests.
14
14
  Snapshots are only available when using `@ember-data/legacy-compat`
15
15
  for legacy compatibility with adapters and serializers.
16
16
 
17
- @class Snapshot
17
+ For serialization of records in modern paradigms, request data from
18
+ the cache or off the record directly.
19
+
20
+ @hideconstructor
18
21
  @public
19
22
  */
20
23
  export declare class Snapshot<R = unknown> {
21
- __attributes: Record<keyof R & string, unknown> | null;
22
- _belongsToRelationships: Record<string, Snapshot>;
23
- _belongsToIds: Record<string, RecordId>;
24
- _hasManyRelationships: Record<string, Snapshot[]>;
25
- _hasManyIds: Record<string, RecordId[]>;
26
- _changedAttributes: ChangedAttributesHash;
24
+ private __attributes;
25
+ private _belongsToRelationships;
26
+ private _belongsToIds;
27
+ private _hasManyRelationships;
28
+ private _hasManyIds;
29
+ private _changedAttributes;
30
+ private _store;
31
+ /**
32
+ The unique RecordIdentifier associated with this Snapshot.
33
+
34
+ @public
35
+ */
27
36
  identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
37
+ /**
38
+ The ResourceType of the underlying record for this Snapshot, as a string.
39
+
40
+ @public
41
+ */
28
42
  modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;
43
+ /**
44
+ The id of the snapshot's underlying record
45
+
46
+ Example
47
+
48
+ ```js
49
+ // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
50
+ postSnapshot.id; // => '1'
51
+ ```
52
+
53
+ @public
54
+ */
29
55
  id: string | null;
56
+ /**
57
+ If `include` was passed to the options for the request, the value
58
+ would be available here.
59
+
60
+ @public
61
+ */
30
62
  include?: string | string[];
31
- adapterOptions?: Record<string, unknown>;
32
- _store: Store;
33
63
  /**
34
- * @constructor
35
- * @private
36
- * @param options
37
- * @param identifier
38
- * @param _store
64
+ The adapterOptions passed to the request which generated this Snapshot, if any
65
+
66
+ @public
39
67
  */
68
+ adapterOptions?: Record<string, unknown>;
40
69
  constructor(options: FindRecordOptions, identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
41
70
  /**
42
71
  The underlying record for this snapshot. Can be used to access methods and
43
72
  properties defined on the record.
44
73
 
45
- Example
46
-
47
- ```javascript
48
- let json = snapshot.record.toJSON();
74
+ ```js
75
+ const someValue = snapshot.record.someProp;
49
76
  ```
50
77
 
51
78
  @property record
52
- @type {Model}
53
79
  @public
54
80
  */
55
81
  get record(): R | null;
56
- get _attributes(): Record<keyof R & string, unknown>;
82
+ /** @internal */
83
+ private get _attributes();
57
84
  get isNew(): boolean;
58
85
  /**
59
86
  Returns the value of an attribute.
@@ -68,22 +95,28 @@ export declare class Snapshot<R = unknown> {
68
95
 
69
96
  Note: Values are loaded eagerly and cached when the snapshot is created.
70
97
 
71
- @param {String} keyName
72
- @return {Object} The attribute value or undefined
98
+ @return The attribute value or undefined
73
99
  @public
74
100
  */
75
101
  attr(keyName: keyof R & string): unknown;
76
102
  /**
77
103
  Returns all attributes and their corresponding values.
78
104
 
105
+ ::: warning ⚠️ WARNING
106
+ Attributes are SHALLOW copied from the cache.
107
+ Because they are NOT deep copied from the cache, mutating
108
+ any object or array fields will cause unintended side-effects
109
+ and bugs.
110
+ :::
111
+
79
112
  Example
80
113
 
81
- ```javascript
114
+ ```js
82
115
  // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
83
116
  postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
84
117
  ```
85
118
 
86
- @return {Object} All attributes of the current snapshot
119
+ @return All attributes of the current snapshot
87
120
  @public
88
121
  */
89
122
  attributes(): Record<keyof R & string, unknown>;
@@ -92,13 +125,13 @@ export declare class Snapshot<R = unknown> {
92
125
 
93
126
  Example
94
127
 
95
- ```javascript
128
+ ```js
96
129
  // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
97
130
  postModel.set('title', 'Ember.js rocks!');
98
131
  postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
99
132
  ```
100
133
 
101
- @return {Object} All changed attributes of the current snapshot
134
+ @return All changed attributes of the current snapshot
102
135
  @public
103
136
  */
104
137
  changedAttributes(): ChangedAttributesHash;
@@ -113,7 +146,7 @@ export declare class Snapshot<R = unknown> {
113
146
 
114
147
  Example
115
148
 
116
- ```javascript
149
+ ```js
117
150
  // store.push('post', { id: 1, title: 'Hello World' });
118
151
  // store.createRecord('comment', { body: 'Lorem ipsum', post: post });
119
152
  commentSnapshot.belongsTo('post'); // => Snapshot
@@ -130,12 +163,10 @@ export declare class Snapshot<R = unknown> {
130
163
 
131
164
  Note: Relationships are loaded lazily and cached upon first access.
132
165
 
133
- @param {String} keyName
134
- @param {Object} [options]
135
166
  @public
136
- @return {(Snapshot|String|null|undefined)} A snapshot or ID of a known
137
- relationship or null if the relationship is known but unset. undefined
138
- will be returned if the contents of the relationship is unknown.
167
+ @return A snapshot or ID of a known relationship or null if the
168
+ relationship is known but unset. undefined will be returned if the
169
+ contents of the relationship are unknown.
139
170
  */
140
171
  belongsTo(keyName: string, options?: {
141
172
  id?: boolean;
@@ -162,10 +193,8 @@ export declare class Snapshot<R = unknown> {
162
193
 
163
194
  Note: Relationships are loaded lazily and cached upon first access.
164
195
 
165
- @param {String} keyName
166
- @param {Object} [options]
167
196
  @public
168
- @return {(Array|undefined)} An array of snapshots or IDs of a known
197
+ @return An array of snapshots or IDs of a known
169
198
  relationship or an empty array if the relationship is known but unset.
170
199
  undefined will be returned if the contents of the relationship is unknown.
171
200
  */
@@ -184,8 +213,8 @@ export declare class Snapshot<R = unknown> {
184
213
  });
185
214
  ```
186
215
 
187
- @param {Function} callback the callback to execute
188
- @param {Object} [binding] the value to which the callback's `this` should be bound
216
+ @param callback the callback to execute
217
+ @param binding the optional value to which the callback's `this` should be bound
189
218
  @public
190
219
  */
191
220
  eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void;
@@ -201,8 +230,8 @@ export declare class Snapshot<R = unknown> {
201
230
  });
202
231
  ```
203
232
 
204
- @param {Function} callback the callback to execute
205
- @param {Object} [binding] the value to which the callback's `this` should be bound
233
+ @param callback the callback to execute
234
+ @param binding the optional value to which the callback's `this` should be bound
206
235
  @public
207
236
  */
208
237
  eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void;
@@ -227,8 +256,7 @@ export declare class Snapshot<R = unknown> {
227
256
  });
228
257
  ```
229
258
 
230
- @param {Object} options
231
- @return {Object} an object whose values are primitive JSON values only
259
+ @return an object whose values are primitive JSON values only
232
260
  @public
233
261
  */
234
262
  serialize(options?: SerializerOptions): unknown;
@@ -1,5 +1,5 @@
1
1
  import type { ArrayValue, ObjectValue, PrimitiveValue } from "@warp-drive/core/types/json/raw";
2
- import type { TransformName } from "@warp-drive/core/types/symbols";
2
+ import { type TransformName } from "@warp-drive/core/types/symbols";
3
3
  import type { DecoratorPropertyDescriptor } from "./util.js";
4
4
  /**
5
5
  * Options provided to the attr decorator are
@@ -1,7 +1,7 @@
1
1
  import EmberObject from "@ember/object";
2
2
  import type { Store } from "@warp-drive/core";
3
3
  import type { ModelSchema, StableRecordIdentifier } from "@warp-drive/core/types";
4
- import type { Cache, ChangedAttributesHash } from "@warp-drive/core/types/cache";
4
+ import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
5
5
  import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
6
6
  import { RecordStore } from "@warp-drive/core/types/symbols";
7
7
  import type { Snapshot } from "../../compat/-private.js";
@@ -16,9 +16,8 @@ export type ModelCreateArgs = {
16
16
  // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
17
17
  _secretInit: {
18
18
  identifier: StableRecordIdentifier;
19
- cache: Cache;
20
19
  store: Store;
21
- cb: (record: Model, cache: Cache, identifier: StableRecordIdentifier, store: Store) => void;
20
+ cb: (record: Model, identifier: StableRecordIdentifier, store: Store) => void;
22
21
  };
23
22
  };
24
23
  export type StaticModel = typeof Model & {
@@ -238,17 +238,44 @@ function normalizeResponseHelper(serializer, store, modelClass, payload, id, req
238
238
  Snapshots are only available when using `@ember-data/legacy-compat`
239
239
  for legacy compatibility with adapters and serializers.
240
240
 
241
- @class Snapshot
241
+ For serialization of records in modern paradigms, request data from
242
+ the cache or off the record directly.
243
+
244
+ @hideconstructor
242
245
  @public
243
246
  */
244
247
  class Snapshot {
245
248
  /**
246
- * @constructor
247
- * @private
248
- * @param options
249
- * @param identifier
250
- * @param _store
251
- */
249
+ The unique RecordIdentifier associated with this Snapshot.
250
+ @public
251
+ */
252
+
253
+ /**
254
+ The ResourceType of the underlying record for this Snapshot, as a string.
255
+ @public
256
+ */
257
+
258
+ /**
259
+ The id of the snapshot's underlying record
260
+ Example
261
+ ```js
262
+ // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
263
+ postSnapshot.id; // => '1'
264
+ ```
265
+ @public
266
+ */
267
+
268
+ /**
269
+ If `include` was passed to the options for the request, the value
270
+ would be available here.
271
+ @public
272
+ */
273
+
274
+ /**
275
+ The adapterOptions passed to the request which generated this Snapshot, if any
276
+ @public
277
+ */
278
+
252
279
  constructor(options, identifier, store) {
253
280
  this._store = store;
254
281
  this.__attributes = null;
@@ -258,13 +285,6 @@ class Snapshot {
258
285
  this._hasManyIds = Object.create(null);
259
286
  const hasRecord = !!store._instanceCache.peek(identifier);
260
287
  this.modelName = identifier.type;
261
-
262
- /**
263
- The unique RecordIdentifier associated with this Snapshot.
264
- @property identifier
265
- @public
266
- @type {StableRecordIdentifier}
267
- */
268
288
  this.identifier = identifier;
269
289
 
270
290
  /*
@@ -278,43 +298,9 @@ class Snapshot {
278
298
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
279
299
  this._attributes;
280
300
  }
281
-
282
- /**
283
- The id of the snapshot's underlying record
284
- Example
285
- ```javascript
286
- // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
287
- postSnapshot.id; // => '1'
288
- ```
289
- @property id
290
- @type {String}
291
- @public
292
- */
293
301
  this.id = identifier.id;
294
-
295
- /**
296
- A hash of adapter options
297
- @property adapterOptions
298
- @type {Object}
299
- @public
300
- */
301
302
  this.adapterOptions = options.adapterOptions;
302
-
303
- /**
304
- If `include` was passed to the options hash for the request, the value
305
- would be available here.
306
- @property include
307
- @type {String|Array}
308
- @public
309
- */
310
303
  this.include = options.include;
311
-
312
- /**
313
- The name of the type of the underlying record for this snapshot, as a string.
314
- @property modelName
315
- @type {String}
316
- @public
317
- */
318
304
  this.modelName = identifier.type;
319
305
  if (hasRecord) {
320
306
  const cache = this._store.cache;
@@ -325,12 +311,10 @@ class Snapshot {
325
311
  /**
326
312
  The underlying record for this snapshot. Can be used to access methods and
327
313
  properties defined on the record.
328
- Example
329
- ```javascript
330
- let json = snapshot.record.toJSON();
314
+ ```js
315
+ const someValue = snapshot.record.someProp;
331
316
  ```
332
317
  @property record
333
- @type {Model}
334
318
  @public
335
319
  */
336
320
  get record() {
@@ -342,6 +326,8 @@ class Snapshot {
342
326
  })(record !== null) : {};
343
327
  return record;
344
328
  }
329
+
330
+ /** @internal */
345
331
  get _attributes() {
346
332
  if (this.__attributes !== null) {
347
333
  return this.__attributes;
@@ -350,12 +336,9 @@ class Snapshot {
350
336
  const {
351
337
  identifier
352
338
  } = this;
353
- const attrs = this._store.schema.fields(identifier);
354
339
  const cache = this._store.cache;
355
- attrs.forEach((field, keyName) => {
356
- if (field.kind === 'attribute') {
357
- attributes[keyName] = cache.getAttr(identifier, keyName);
358
- }
340
+ this.eachAttribute((key, meta) => {
341
+ attributes[key] = cache.getAttr(identifier, key);
359
342
  });
360
343
  return attributes;
361
344
  }
@@ -373,8 +356,7 @@ class Snapshot {
373
356
  postSnapshot.attr('title'); // => 'Ember.js rocks'
374
357
  ```
375
358
  Note: Values are loaded eagerly and cached when the snapshot is created.
376
- @param {String} keyName
377
- @return {Object} The attribute value or undefined
359
+ @return The attribute value or undefined
378
360
  @public
379
361
  */
380
362
  attr(keyName) {
@@ -390,12 +372,18 @@ class Snapshot {
390
372
 
391
373
  /**
392
374
  Returns all attributes and their corresponding values.
375
+ ::: warning ⚠️ WARNING
376
+ Attributes are SHALLOW copied from the cache.
377
+ Because they are NOT deep copied from the cache, mutating
378
+ any object or array fields will cause unintended side-effects
379
+ and bugs.
380
+ :::
393
381
  Example
394
- ```javascript
382
+ ```js
395
383
  // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
396
384
  postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
397
385
  ```
398
- @return {Object} All attributes of the current snapshot
386
+ @return All attributes of the current snapshot
399
387
  @public
400
388
  */
401
389
  attributes() {
@@ -407,12 +395,12 @@ class Snapshot {
407
395
  /**
408
396
  Returns all changed attributes and their old and new values.
409
397
  Example
410
- ```javascript
398
+ ```js
411
399
  // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
412
400
  postModel.set('title', 'Ember.js rocks!');
413
401
  postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
414
402
  ```
415
- @return {Object} All changed attributes of the current snapshot
403
+ @return All changed attributes of the current snapshot
416
404
  @public
417
405
  */
418
406
  changedAttributes() {
@@ -435,7 +423,7 @@ class Snapshot {
435
423
  - `id`: set to `true` if you only want the ID of the related record to be
436
424
  returned.
437
425
  Example
438
- ```javascript
426
+ ```js
439
427
  // store.push('post', { id: 1, title: 'Hello World' });
440
428
  // store.createRecord('comment', { body: 'Lorem ipsum', post: post });
441
429
  commentSnapshot.belongsTo('post'); // => Snapshot
@@ -448,12 +436,10 @@ class Snapshot {
448
436
  known but unset, `belongsTo` will return `null`. If the contents of the
449
437
  relationship is unknown `belongsTo` will return `undefined`.
450
438
  Note: Relationships are loaded lazily and cached upon first access.
451
- @param {String} keyName
452
- @param {Object} [options]
453
- @public
454
- @return {(Snapshot|String|null|undefined)} A snapshot or ID of a known
455
- relationship or null if the relationship is known but unset. undefined
456
- will be returned if the contents of the relationship is unknown.
439
+ @public
440
+ @return A snapshot or ID of a known relationship or null if the
441
+ relationship is known but unset. undefined will be returned if the
442
+ contents of the relationship are unknown.
457
443
  */
458
444
  belongsTo(keyName, options) {
459
445
  const returnModeIsId = !!(options && options.id);
@@ -532,10 +518,8 @@ class Snapshot {
532
518
  postSnapshot.hasMany('comments'); // => undefined
533
519
  ```
534
520
  Note: Relationships are loaded lazily and cached upon first access.
535
- @param {String} keyName
536
- @param {Object} [options]
537
- @public
538
- @return {(Array|undefined)} An array of snapshots or IDs of a known
521
+ @public
522
+ @return An array of snapshots or IDs of a known
539
523
  relationship or an empty array if the relationship is known but unset.
540
524
  undefined will be returned if the contents of the relationship is unknown.
541
525
  */
@@ -621,17 +605,24 @@ class Snapshot {
621
605
  // ...
622
606
  });
623
607
  ```
624
- @param {Function} callback the callback to execute
625
- @param {Object} [binding] the value to which the callback's `this` should be bound
608
+ @param callback the callback to execute
609
+ @param binding the optional value to which the callback's `this` should be bound
626
610
  @public
627
611
  */
628
612
  eachAttribute(callback, binding) {
629
- const fields = this._store.schema.fields(this.identifier);
630
- fields.forEach((field, key) => {
631
- if (field.kind === 'attribute') {
632
- callback.call(binding, key, field);
633
- }
634
- });
613
+ // if the store has a modelFor implementation, we use it to iterate attributes. This allows
614
+ // a custom "ModelSchema" class for legacy serializers to adapt to new fields if desired.
615
+ if (typeof this._store.modelFor === 'function') {
616
+ const modelSchema = this._store.modelFor(this.identifier.type);
617
+ modelSchema.eachAttribute(callback, binding);
618
+ } else {
619
+ const fields = this._store.schema.fields(this.identifier);
620
+ fields.forEach((field, key) => {
621
+ if (field.kind === 'attribute') {
622
+ callback.call(binding, key, field);
623
+ }
624
+ });
625
+ }
635
626
  }
636
627
 
637
628
  /**
@@ -643,17 +634,24 @@ class Snapshot {
643
634
  // ...
644
635
  });
645
636
  ```
646
- @param {Function} callback the callback to execute
647
- @param {Object} [binding] the value to which the callback's `this` should be bound
637
+ @param callback the callback to execute
638
+ @param binding the optional value to which the callback's `this` should be bound
648
639
  @public
649
640
  */
650
641
  eachRelationship(callback, binding) {
651
- const fields = this._store.schema.fields(this.identifier);
652
- fields.forEach((field, key) => {
653
- if (field.kind === 'belongsTo' || field.kind === 'hasMany') {
654
- callback.call(binding, key, field);
655
- }
656
- });
642
+ // if the store has a modelFor implementation, we use it to iterate relationships. This allows
643
+ // a custom "ModelSchema" class for legacy serializers to adapt to new fields if desired.
644
+ if (typeof this._store.modelFor === 'function') {
645
+ const modelSchema = this._store.modelFor(this.identifier.type);
646
+ modelSchema.eachRelationship(callback, binding);
647
+ } else {
648
+ const fields = this._store.schema.fields(this.identifier);
649
+ fields.forEach((field, key) => {
650
+ if (field.kind === 'belongsTo' || field.kind === 'hasMany') {
651
+ callback.call(binding, key, field);
652
+ }
653
+ });
654
+ }
657
655
  }
658
656
 
659
657
  /**
@@ -672,8 +670,7 @@ class Snapshot {
672
670
  }
673
671
  });
674
672
  ```
675
- @param {Object} options
676
- @return {Object} an object whose values are primitive JSON values only
673
+ @return an object whose values are primitive JSON values only
677
674
  @public
678
675
  */
679
676
  serialize(options) {
@@ -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-Bp58npke.js";
1
+ export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-DVW6-WBv.js";
@@ -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-Bp58npke.js";
4
+ import { b as serializeIntoHash } from "../serialize-into-hash-DVW6-WBv.js";
5
5
  import { RESTAdapter } from './rest.js';
6
6
  class JSONAPIAdapter extends RESTAdapter {
7
7
  _defaultContentType = 'application/vnd.api+json';
@@ -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-Bp58npke.js";
5
+ import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-DVW6-WBv.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";
@@ -1 +1 @@
1
- export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-CKrP0ogQ.js";
1
+ export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-CsshwIY7.js";
@@ -227,7 +227,7 @@ function resourceIsFullyDeleted(instanceCache, identifier) {
227
227
  @return {SaveRecordRequestInput} request config
228
228
  */
229
229
  function saveRecordBuilder(record, options = {}) {
230
- const store = storeFor(record);
230
+ const store = storeFor(record, true);
231
231
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
232
232
  if (!test) {
233
233
  throw new Error(`Unable to initiate save for a record in a disconnected state`);
package/dist/compat.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getOwner } from '@ember/application';
2
2
  import { recordIdentifierFor } from '@warp-drive/core';
3
3
  import { waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
4
- import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-CKrP0ogQ.js";
4
+ import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-CsshwIY7.js";
5
5
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
6
6
  function _findHasMany(adapter, store, identifier, link, relationship, options) {
7
7
  const promise = Promise.resolve().then(() => {
@@ -1,7 +1,7 @@
1
- import { memoized, defineSignal, defineNonEnumerableSignal, isStableIdentifier, recordIdentifierFor, storeFor, peekCache, SOURCE, fastPush, RelatedCollection, notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
1
+ import { memoized, defineSignal, defineNonEnumerableSignal, isStableIdentifier, recordIdentifierFor, storeFor, SOURCE, fastPush, RelatedCollection, notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
2
2
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
3
3
  import { EnableHydration } from '@warp-drive/core/types/request';
4
- import { u as upgradeStore } from "./-private-CKrP0ogQ.js";
4
+ import { u as upgradeStore } from "./-private-CsshwIY7.js";
5
5
  import { computed, get } from '@ember/object';
6
6
  import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
7
7
  import ObjectProxy from '@ember/object/proxy';
@@ -1517,9 +1517,9 @@ function lookupLegacySupport(record) {
1517
1517
  class LegacySupport {
1518
1518
  constructor(record) {
1519
1519
  this.record = record;
1520
- this.store = storeFor(record);
1520
+ this.store = storeFor(record, false);
1521
1521
  this.identifier = recordIdentifierFor(record);
1522
- this.cache = peekCache(record);
1522
+ this.cache = this.store.cache;
1523
1523
  if (this.store._graph) {
1524
1524
  this.graph = this.store._graph;
1525
1525
  }
@@ -1,2 +1,2 @@
1
- export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-BX5wowuz.js";
1
+ export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-DOPr_dMc.js";
2
2
  export { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';
@@ -3,8 +3,8 @@ import { recordIdentifierFor } from '@warp-drive/core';
3
3
  import { notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
4
4
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
5
5
  import { Type } from '@warp-drive/core/types/symbols';
6
- import { l as lookupLegacySupport, E as Errors } from "../errors-BX5wowuz.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";
6
+ import { l as lookupLegacySupport, E as Errors } from "../errors-DOPr_dMc.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-0vfXIZzR.js";
8
8
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
9
9
 
10
10
  /**
package/dist/model.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { computed } from '@ember/object';
2
2
  import { recordIdentifierFor } from '@warp-drive/core';
3
- import { peekCache, setRecordIdentifier, StoreMap, setCacheFor } from '@warp-drive/core/store/-private';
3
+ 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 { RecordStore } from '@warp-drive/core/types/symbols';
8
- import { l as lookupLegacySupport } from "./errors-BX5wowuz.js";
7
+ import { l as lookupLegacySupport } from "./errors-DOPr_dMc.js";
9
8
  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";
9
+ import { l as getModelFactory } from "./schema-provider-0vfXIZzR.js";
10
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-0vfXIZzR.js";
12
11
  import { setOwner, getOwner } from '@ember/application';
12
+ import { setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
13
13
  function _attr(type, options) {
14
14
  if (typeof type === 'object') {
15
15
  options = type;
@@ -34,7 +34,8 @@ function _attr(type, options) {
34
34
  if (this.isDestroyed || this.isDestroying) {
35
35
  return;
36
36
  }
37
- return peekCache(this).getAttr(recordIdentifierFor(this), key);
37
+ const cache = this[RecordStore].cache;
38
+ return cache.getAttr(recordIdentifierFor(this), key);
38
39
  },
39
40
  set(key, value) {
40
41
  if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
@@ -48,7 +49,7 @@ function _attr(type, options) {
48
49
  throw new Error(`Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`);
49
50
  }
50
51
  })(!this.currentState.isDeleted) : {};
51
- const cache = peekCache(this);
52
+ const cache = this[RecordStore].cache;
52
53
  const currentValue = cache.getAttr(identifier, key);
53
54
  if (currentValue !== value) {
54
55
  cache.setAttr(identifier, key, value);
@@ -667,14 +668,13 @@ function hasMany(type, options) {
667
668
  }
668
669
  function instantiateRecord(identifier, createRecordArgs) {
669
670
  const type = identifier.type;
670
- const cache = this.cache;
671
+
671
672
  // TODO deprecate allowing unknown args setting
672
673
  const createOptions = {
673
674
  _createProps: createRecordArgs,
674
675
  // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
675
676
  _secretInit: {
676
677
  identifier,
677
- cache,
678
678
  store: this,
679
679
  cb: secretInit
680
680
  }
@@ -729,9 +729,8 @@ function modelFor(modelName) {
729
729
  type
730
730
  })) : {};
731
731
  }
732
- function secretInit(record, cache, identifier, store) {
732
+ function secretInit(record, identifier, store) {
733
733
  setRecordIdentifier(record, identifier);
734
734
  StoreMap.set(record, store);
735
- setCacheFor(record, cache);
736
735
  }
737
736
  export { attr, belongsTo, hasMany, instantiateRecord, modelFor, teardownRecord };
@@ -2,10 +2,10 @@ import { getOwner } from '@ember/application';
2
2
  import { deprecate } from '@ember/debug';
3
3
  import EmberObject from '@ember/object';
4
4
  import { recordIdentifierFor, storeFor } from '@warp-drive/core';
5
- import { peekCache, notifyInternalSignal, peekInternalSignal, withSignalStore, ARRAY_SIGNAL, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
5
+ import { notifyInternalSignal, peekInternalSignal, withSignalStore, ARRAY_SIGNAL, 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-BX5wowuz.js";
8
- import { u as upgradeStore, F as FetchManager } from "./-private-CKrP0ogQ.js";
7
+ import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-DOPr_dMc.js";
8
+ import { u as upgradeStore, F as FetchManager } from "./-private-CsshwIY7.js";
9
9
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
10
10
  import { cacheFor } from '@ember/object/internals';
11
11
  import { d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
@@ -17,8 +17,9 @@ function rollbackAttributes() {
17
17
  const {
18
18
  isNew
19
19
  } = currentState;
20
- this[RecordStore]._join(() => {
21
- peekCache(this).rollbackAttrs(recordIdentifierFor(this));
20
+ const store = this[RecordStore];
21
+ store._join(() => {
22
+ store.cache.rollbackAttrs(recordIdentifierFor(this));
22
23
  this.errors.clear();
23
24
  currentState.cleanErrorRequests();
24
25
  if (isNew) {
@@ -84,7 +85,7 @@ function _reload(options = {}) {
84
85
  return promise;
85
86
  }
86
87
  function changedAttributes() {
87
- return peekCache(this).changedAttrs(recordIdentifierFor(this));
88
+ return this[RecordStore].cache.changedAttrs(recordIdentifierFor(this));
88
89
  }
89
90
  function serialize(options) {
90
91
  upgradeStore(this[RecordStore]);
@@ -291,7 +292,7 @@ root
291
292
  */
292
293
  class RecordState {
293
294
  constructor(record) {
294
- const store = storeFor(record);
295
+ const store = storeFor(record, false);
295
296
  const identity = recordIdentifierFor$1(record);
296
297
  this.identifier = identity;
297
298
  this.record = record;
@@ -382,7 +383,7 @@ class RecordState {
382
383
 
383
384
  /** @internal */
384
385
  destroy() {
385
- storeFor(this.record).notifications.unsubscribe(this.handler);
386
+ storeFor(this.record, false).notifications.unsubscribe(this.handler);
386
387
  }
387
388
 
388
389
  /** @internal */
@@ -719,7 +720,7 @@ class Model extends EmberObject {
719
720
  super.init(options);
720
721
  this[RecordStore] = store;
721
722
  const identity = _secretInit.identifier;
722
- _secretInit.cb(this, _secretInit.cache, identity, _secretInit.store);
723
+ _secretInit.cb(this, identity, _secretInit.store);
723
724
  this.___recordState = macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? new RecordState(this) : null;
724
725
  this.setProperties(createProps);
725
726
  const notifications = store.notifications;
@@ -733,7 +734,7 @@ class Model extends EmberObject {
733
734
  destroy() {
734
735
  const identifier = recordIdentifierFor(this);
735
736
  this.___recordState?.destroy();
736
- const store = storeFor(this);
737
+ const store = storeFor(this, false);
737
738
  store.notifications.unsubscribe(this.___private_notifications);
738
739
  LEGACY_SUPPORT.get(this)?.destroy();
739
740
  LEGACY_SUPPORT.delete(this);
@@ -1212,7 +1213,7 @@ class Model extends EmberObject {
1212
1213
  return this.constructor.relationshipsByName.get(name);
1213
1214
  }
1214
1215
  inverseFor(name) {
1215
- return this.constructor.inverseFor(name, storeFor(this));
1216
+ return this.constructor.inverseFor(name, storeFor(this, false));
1216
1217
  }
1217
1218
  eachAttribute(callback, binding) {
1218
1219
  this.constructor.eachAttribute(callback, binding);
@@ -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/store/-private';
4
- import "./-private-CKrP0ogQ.js";
4
+ import "./-private-CsshwIY7.js";
5
5
  const newline = /\r?\n/;
6
6
  function parseResponseHeaders(headersString) {
7
7
  const headers = Object.create(null);
package/dist/store.js CHANGED
@@ -582,7 +582,7 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
582
582
  if (!test) {
583
583
  throw new Error(`Unable to initiate save for a record in a disconnected state`);
584
584
  }
585
- })(storeFor(record)) : {};
585
+ })(storeFor(record, true)) : {};
586
586
  const identifier = recordIdentifierFor(record);
587
587
  const cache = this.cache;
588
588
  if (!identifier) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warp-drive/legacy",
3
- "version": "5.7.0-alpha.11",
3
+ "version": "5.7.0-alpha.13",
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.7.0-alpha.11",
36
- "@warp-drive/utilities": "5.7.0-alpha.11"
35
+ "@warp-drive/core": "5.7.0-alpha.13",
36
+ "@warp-drive/utilities": "5.7.0-alpha.13"
37
37
  },
38
38
  "dependencies": {
39
39
  "@embroider/macros": "^1.16.12"
@@ -43,9 +43,9 @@
43
43
  "@babel/plugin-transform-typescript": "^7.27.0",
44
44
  "@babel/preset-typescript": "^7.27.0",
45
45
  "@types/jquery": "^3.5.32",
46
- "@warp-drive/internal-config": "5.7.0-alpha.11",
47
- "@warp-drive/core": "5.7.0-alpha.11",
48
- "@warp-drive/utilities": "5.7.0-alpha.11",
46
+ "@warp-drive/internal-config": "5.7.0-alpha.13",
47
+ "@warp-drive/core": "5.7.0-alpha.13",
48
+ "@warp-drive/utilities": "5.7.0-alpha.13",
49
49
  "ember-source": "~6.3.0",
50
50
  "decorator-transforms": "^2.3.0",
51
51
  "expect-type": "^1.2.1",