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

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.
Files changed (37) hide show
  1. package/declarations/compat/builders/find-all.d.ts +2 -2
  2. package/declarations/compat/builders/query.d.ts +2 -2
  3. package/declarations/compat/builders/save-record.d.ts +3 -3
  4. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +10 -10
  5. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -2
  6. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +5 -5
  7. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -3
  8. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +2 -2
  9. package/declarations/compat/legacy-network-handler/snapshot.d.ts +72 -44
  10. package/declarations/model/-private/attr.d.ts +1 -1
  11. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +2 -2
  12. package/declarations/model/-private/hooks.d.ts +2 -2
  13. package/declarations/model/-private/legacy-relationships-support.d.ts +16 -17
  14. package/declarations/model/-private/model.d.ts +4 -5
  15. package/declarations/model/-private/notify-changes.d.ts +2 -2
  16. package/declarations/model/-private/record-state.d.ts +2 -2
  17. package/declarations/model/-private/references/belongs-to.d.ts +6 -6
  18. package/declarations/model/-private/references/has-many.d.ts +6 -6
  19. package/declarations/model/-private/schema-provider.d.ts +6 -6
  20. package/declarations/model/-private.d.ts +2 -1
  21. package/declarations/model/migration-support.d.ts +10 -10
  22. package/declarations/store/-private.d.ts +12 -12
  23. package/dist/{-private-CKrP0ogQ.js → -private-CVsFOW1k.js} +94 -96
  24. package/dist/adapter/-private.js +1 -1
  25. package/dist/adapter/json-api.js +1 -1
  26. package/dist/adapter/rest.js +1 -1
  27. package/dist/compat/-private.js +1 -1
  28. package/dist/compat/builders.js +1 -1
  29. package/dist/compat.js +2 -1
  30. package/dist/{errors-BX5wowuz.js → errors-VSxXZooE.js} +33 -36
  31. package/dist/model/-private.js +1 -2
  32. package/dist/model/migration-support.js +12 -6
  33. package/dist/model.js +10 -11
  34. package/dist/{schema-provider-Cbnf6sKm.js → schema-provider-BgBPZFfc.js} +20 -16
  35. package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-B59laYa4.js} +2 -2
  36. package/dist/store.js +3 -3
  37. package/package.json +6 -6
@@ -13,7 +13,7 @@ type FindAllRequestInput<
13
13
  };
14
14
  [RequestSignature]?: RT;
15
15
  };
16
- type FindAllBuilderOptions<T = unknown> = FindAllOptions<T>;
16
+ type FindAllBuilderOptions = FindAllOptions;
17
17
  /**
18
18
  This function builds a request config to perform a `findAll` request for the given type.
19
19
  When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.
@@ -30,6 +30,6 @@ To that end, these builders are deprecated and will be removed in a future versi
30
30
  @param {FindAllBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.findAll
31
31
  @return {FindAllRequestInput} request config
32
32
  */
33
- export declare function findAllBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, options?: FindAllBuilderOptions<T>): FindAllRequestInput<TypeFromInstance<T>, T[]>;
33
+ export declare function findAllBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, options?: FindAllBuilderOptions): FindAllRequestInput<TypeFromInstance<T>, T[]>;
34
34
  export declare function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;
35
35
  export {};
@@ -31,7 +31,7 @@ To that end, these builders are deprecated and will be removed in a future versi
31
31
  @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query
32
32
  @return {QueryRequestInput} request config
33
33
  */
34
- export declare function queryBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery<T>, options?: QueryBuilderOptions): QueryRequestInput<TypeFromInstance<T>, T[]>;
34
+ export declare function queryBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRequestInput<TypeFromInstance<T>, T[]>;
35
35
  export declare function queryBuilder(type: string, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRequestInput;
36
36
  type QueryRecordRequestInput<
37
37
  T extends string = string,
@@ -61,6 +61,6 @@ To that end, these builders are deprecated and will be removed in a future versi
61
61
  @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query
62
62
  @return {QueryRecordRequestInput} request config
63
63
  */
64
- export declare function queryRecordBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery<T>, options?: QueryBuilderOptions): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;
64
+ export declare function queryRecordBuilder<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;
65
65
  export declare function queryRecordBuilder(type: string, query: LegacyResourceQuery, options?: QueryBuilderOptions): QueryRecordRequestInput;
66
66
  export {};
@@ -1,5 +1,5 @@
1
1
  import { type StoreRequestInput } from "@warp-drive/core";
2
- import type { StableRecordIdentifier } from "@warp-drive/core/types";
2
+ import type { ResourceKey } from "@warp-drive/core/types";
3
3
  import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
4
4
  import type { RequestSignature } from "@warp-drive/core/types/symbols";
5
5
  type SaveRecordRequestInput<
@@ -8,10 +8,10 @@ type SaveRecordRequestInput<
8
8
  > = StoreRequestInput & {
9
9
  op: "createRecord" | "deleteRecord" | "updateRecord";
10
10
  data: {
11
- record: StableRecordIdentifier<T>;
11
+ record: ResourceKey<T>;
12
12
  options: SaveRecordBuilderOptions;
13
13
  };
14
- records: [StableRecordIdentifier<T>];
14
+ records: [ResourceKey<T>];
15
15
  [RequestSignature]?: RT;
16
16
  };
17
17
  type SaveRecordBuilderOptions = Record<string, unknown>;
@@ -2,7 +2,7 @@ import type { Store } from "@warp-drive/core";
2
2
  import { createDeferred } from "@warp-drive/core/request";
3
3
  import type { Request, RequestStateService } from "@warp-drive/core/store/-private";
4
4
  import type { FindRecordOptions } from "@warp-drive/core/types";
5
- import type { StableExistingRecordIdentifier, StableRecordIdentifier } from "@warp-drive/core/types/identifier";
5
+ import type { PersistedResourceKey, ResourceKey } from "@warp-drive/core/types/identifier";
6
6
  import type { TypeFromInstance } from "@warp-drive/core/types/record";
7
7
  import type { ImmutableRequestInfo } from "@warp-drive/core/types/request";
8
8
  import type { SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
@@ -13,23 +13,23 @@ export type FetchMutationOptions = FindRecordOptions & {
13
13
  [SaveOp]: "createRecord" | "deleteRecord" | "updateRecord";
14
14
  };
15
15
  interface PendingFetchItem {
16
- identifier: StableExistingRecordIdentifier;
16
+ identifier: PersistedResourceKey;
17
17
  queryRequest: Request;
18
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
19
  resolver: Deferred<any>;
20
20
  options: FindRecordOptions;
21
21
  trace?: unknown;
22
- promise: Promise<StableExistingRecordIdentifier>;
22
+ promise: Promise<PersistedResourceKey>;
23
23
  }
24
24
  export declare class FetchManager {
25
25
  isDestroyed: boolean;
26
26
  requestCache: RequestStateService;
27
27
  // fetches pending in the runloop, waiting to be coalesced
28
- _pendingFetch: Map<string, Map<StableExistingRecordIdentifier, PendingFetchItem[]>>;
28
+ _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;
29
29
  _store: Store;
30
30
  constructor(store: Store);
31
- createSnapshot<T>(identifier: StableRecordIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;
32
- createSnapshot(identifier: StableRecordIdentifier, options?: FindRecordOptions): Snapshot;
31
+ createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;
32
+ createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;
33
33
  /**
34
34
  This method is called by `record.save`, and gets passed a
35
35
  resolver for the promise that `record.save` returns.
@@ -38,11 +38,11 @@ export declare class FetchManager {
38
38
 
39
39
  @internal
40
40
  */
41
- scheduleSave(identifier: StableRecordIdentifier, options: FetchMutationOptions): Promise<null | SingleResourceDocument>;
42
- scheduleFetch(identifier: StableExistingRecordIdentifier, options: FindRecordOptions, request: ImmutableRequestInfo): Promise<StableExistingRecordIdentifier>;
43
- getPendingFetch(identifier: StableExistingRecordIdentifier, options: FindRecordOptions): Promise<StableExistingRecordIdentifier> | undefined;
41
+ scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument>;
42
+ scheduleFetch(identifier: PersistedResourceKey, options: FindRecordOptions, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
43
+ getPendingFetch(identifier: PersistedResourceKey, options: FindRecordOptions): Promise<PersistedResourceKey> | undefined;
44
44
  flushAllPendingFetches(): void;
45
- fetchDataIfNeededForIdentifier(identifier: StableExistingRecordIdentifier, options: FindRecordOptions | undefined, request: ImmutableRequestInfo): Promise<StableExistingRecordIdentifier>;
45
+ fetchDataIfNeededForIdentifier(identifier: PersistedResourceKey, options: FindRecordOptions | undefined, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
46
46
  destroy(): void;
47
47
  }
48
48
  export {};
@@ -1,2 +1,2 @@
1
- import type { StableExistingRecordIdentifier } from "@warp-drive/core/types/identifier";
2
- export declare function assertIdentifierHasId(identifier: unknown): asserts identifier is StableExistingRecordIdentifier;
1
+ import type { PersistedResourceKey } from "@warp-drive/core/types/identifier";
2
+ export declare function assertIdentifierHasId(identifier: unknown): asserts identifier is PersistedResourceKey;
@@ -1,11 +1,11 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { BaseFinderOptions } from "@warp-drive/core/types";
3
- import type { StableExistingRecordIdentifier, StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
+ import type { PersistedResourceKey, ResourceKey } from "@warp-drive/core/types/identifier";
4
4
  import type { LegacyRelationshipField as RelationshipSchema } from "@warp-drive/core/types/schema/fields";
5
5
  import type { MinimumAdapterInterface } from "./minimum-adapter-interface.js";
6
- export declare function _findHasMany(adapter: MinimumAdapterInterface, store: Store, identifier: StableRecordIdentifier, link: string | null | {
6
+ export declare function _findHasMany(adapter: MinimumAdapterInterface, store: Store, identifier: ResourceKey, link: string | null | {
7
7
  href: string;
8
- }, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<StableExistingRecordIdentifier[]>;
9
- export declare function _findBelongsTo(store: Store, identifier: StableRecordIdentifier, link: string | null | {
8
+ }, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<PersistedResourceKey[]>;
9
+ export declare function _findBelongsTo(store: Store, identifier: ResourceKey, link: string | null | {
10
10
  href: string;
11
- }, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<StableExistingRecordIdentifier | null>;
11
+ }, relationship: RelationshipSchema, options: BaseFinderOptions): Promise<PersistedResourceKey | null>;
@@ -1,5 +1,5 @@
1
1
  import type { Store } from "@warp-drive/core";
2
- import type { CollectionRecordArray } from "@warp-drive/core/store/-private";
2
+ import type { LegacyQueryArray } from "@warp-drive/core/store/-private";
3
3
  import type { ModelSchema } from "@warp-drive/core/types";
4
4
  import type { LegacyRelationshipField as RelationshipSchema } from "@warp-drive/core/types/schema/fields";
5
5
  import type { Snapshot } from "./snapshot.js";
@@ -113,11 +113,11 @@ export interface MinimumAdapterInterface {
113
113
  * @param {ModelSchema} schema An object with methods for accessing information about
114
114
  * the type, attributes and relationships of the primary type associated with the request.
115
115
  * @param {Object} query
116
- * @param {CollectionRecordArray} recordArray
116
+ * @param {LegacyQueryArray} recordArray
117
117
  * @param {Object} options
118
118
  * @return {Promise} a promise resolving with resource data to feed to the associated serializer
119
119
  */
120
- query(store: Store, schema: ModelSchema, query: Record<string, unknown>, recordArray: CollectionRecordArray, options: {
120
+ query(store: Store, schema: ModelSchema, query: Record<string, unknown>, recordArray: LegacyQueryArray, options: {
121
121
  adapterOptions?: unknown;
122
122
  }): Promise<AdapterPayload>;
123
123
  /**
@@ -1,5 +1,5 @@
1
1
  import type { Store } from "@warp-drive/core";
2
- import type { LiveArray } from "@warp-drive/core/store/-private";
2
+ import type { LegacyLiveArray } from "@warp-drive/core/store/-private";
3
3
  import type { FindAllOptions, ModelSchema } from "@warp-drive/core/types";
4
4
  import type { Snapshot } from "./snapshot.js";
5
5
  /**
@@ -36,7 +36,7 @@ export declare class SnapshotRecordArray {
36
36
  @private
37
37
  @type {Array}
38
38
  */
39
- get _recordArray(): LiveArray;
39
+ get _recordArray(): LegacyLiveArray;
40
40
  /**
41
41
  Number of records in the array
42
42
 
@@ -1,7 +1,7 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { FindRecordOptions } from "@warp-drive/core/types";
3
3
  import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
4
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
4
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
5
5
  import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
6
6
  import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
7
7
  import type { SerializerOptions } from "./minimum-serializer-interface.js";
@@ -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;
27
- identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
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 ResourceKey associated with this Snapshot.
33
+
34
+ @public
35
+ */
36
+ identifier: ResourceKey<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
  */
40
- constructor(options: FindRecordOptions, identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
68
+ adapterOptions?: Record<string, unknown>;
69
+ constructor(options: FindRecordOptions, identifier: ResourceKey<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,6 +1,6 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { UpgradedMeta } from "@warp-drive/core/graph/-private";
3
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
4
4
  /*
5
5
  Assert that `addedRecord` has a valid type so it can be added to the
6
6
  relationship of the `record`.
@@ -13,5 +13,5 @@ be stable record identifiers and the `relationshipMeta` needs to be the meta
13
13
  information about the relationship, retrieved via
14
14
  `record.relationshipFor(key)`.
15
15
  */
16
- declare let assertPolymorphicType: (parentIdentifier: StableRecordIdentifier, parentDefinition: UpgradedMeta, addedIdentifier: StableRecordIdentifier, store: Store) => void;
16
+ declare let assertPolymorphicType: (parentIdentifier: ResourceKey, parentDefinition: UpgradedMeta, addedIdentifier: ResourceKey, store: Store) => void;
17
17
  export { assertPolymorphicType };
@@ -1,8 +1,8 @@
1
1
  import { type Store } from "@warp-drive/core/store/-private";
2
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
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: StableRecordIdentifier, 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;
@@ -1,8 +1,7 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { CollectionEdge, Graph, ResourceEdge, UpgradedMeta } from "@warp-drive/core/graph/-private";
3
- import type { LiveArray } from "@warp-drive/core/store/-private";
4
- import { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
5
- import type { BaseFinderOptions, StableRecordIdentifier } from "@warp-drive/core/types";
3
+ import type { LegacyManyArray } from "@warp-drive/core/store/-private";
4
+ import type { BaseFinderOptions, ResourceKey } from "@warp-drive/core/types";
6
5
  import type { Cache } from "@warp-drive/core/types/cache";
7
6
  import type { CollectionRelationship } from "@warp-drive/core/types/cache/relationship";
8
7
  import type { LocalRelationshipOperation } from "@warp-drive/core/types/graph";
@@ -15,7 +14,7 @@ import type { HasManyProxyCreateArgs } from "./promise-many-array.js";
15
14
  import { PromiseManyArray } from "./promise-many-array.js";
16
15
  import BelongsToReference from "./references/belongs-to.js";
17
16
  import HasManyReference from "./references/has-many.js";
18
- export declare const LEGACY_SUPPORT: Map<StableRecordIdentifier | MinimalLegacyRecord, LegacySupport>;
17
+ export declare const LEGACY_SUPPORT: Map<ResourceKey | MinimalLegacyRecord, LegacySupport>;
19
18
  export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
20
19
  export declare class LegacySupport {
21
20
  record: MinimalLegacyRecord;
@@ -23,25 +22,25 @@ export declare class LegacySupport {
23
22
  graph: Graph;
24
23
  cache: Cache;
25
24
  references: Record<string, BelongsToReference | HasManyReference>;
26
- identifier: StableRecordIdentifier;
27
- _manyArrayCache: Record<string, ManyArray>;
28
- _relationshipPromisesCache: Record<string, Promise<ManyArray | OpaqueRecordInstance>>;
25
+ identifier: ResourceKey;
26
+ _manyArrayCache: Record<string, LegacyManyArray>;
27
+ _relationshipPromisesCache: Record<string, Promise<LegacyManyArray | OpaqueRecordInstance>>;
29
28
  _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
30
- _pending: Record<string, Promise<StableRecordIdentifier | null> | undefined>;
29
+ _pending: Record<string, Promise<ResourceKey | null> | undefined>;
31
30
  isDestroying: boolean;
32
31
  isDestroyed: boolean;
33
- constructor(record: MinimalLegacyRecord);
34
- _syncArray(array: LiveArray): void;
32
+ constructor(record: MinimalLegacyRecord, identifier: ResourceKey);
33
+ _syncArray(array: LegacyManyArray): void;
35
34
  mutate(mutation: LocalRelationshipOperation): void;
36
35
  _findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
37
36
  reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
38
37
  getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
39
38
  setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void;
40
- _getCurrentState<T>(identifier: StableRecordIdentifier, field: string): [StableRecordIdentifier<TypeFromInstanceOrString<T>>[], CollectionRelationship];
41
- getManyArray<T>(key: string, definition?: UpgradedMeta): ManyArray<T>;
42
- fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: ManyArray, options?: BaseFinderOptions): Promise<ManyArray>;
43
- reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<ManyArray<T>> | PromiseManyArray<T>;
44
- getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | ManyArray;
39
+ _getCurrentState<T>(identifier: ResourceKey, field: string): [ResourceKey<TypeFromInstanceOrString<T>>[], CollectionRelationship];
40
+ getManyArray<T>(key: string, definition?: UpgradedMeta): LegacyManyArray<T>;
41
+ fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: LegacyManyArray, options?: BaseFinderOptions): Promise<LegacyManyArray>;
42
+ reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<LegacyManyArray<T>> | PromiseManyArray<T>;
43
+ getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | LegacyManyArray;
45
44
  _updatePromiseProxyFor(kind: "hasMany", key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
46
45
  _updatePromiseProxyFor(kind: "belongsTo", key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
47
46
  _updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
@@ -49,8 +48,8 @@ export declare class LegacySupport {
49
48
  }): PromiseBelongsTo;
50
49
  referenceFor(kind: "belongsTo", name: string): BelongsToReference;
51
50
  referenceFor(kind: "hasMany", name: string): HasManyReference;
52
- _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
53
- _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<StableRecordIdentifier | null>;
51
+ _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: ResourceKey, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
52
+ _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: ResourceKey, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<ResourceKey | null>;
54
53
  destroy(): void;
55
54
  }
56
55
  export declare function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean;
@@ -1,7 +1,7 @@
1
1
  import EmberObject from "@ember/object";
2
2
  import type { Store } from "@warp-drive/core";
3
- import type { ModelSchema, StableRecordIdentifier } from "@warp-drive/core/types";
4
- import type { Cache, ChangedAttributesHash } from "@warp-drive/core/types/cache";
3
+ import type { ModelSchema, ResourceKey } from "@warp-drive/core/types";
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";
@@ -15,10 +15,9 @@ export type ModelCreateArgs = {
15
15
  _createProps: Record<string, unknown>;
16
16
  // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
17
17
  _secretInit: {
18
- identifier: StableRecordIdentifier;
19
- cache: Cache;
18
+ identifier: ResourceKey;
20
19
  store: Store;
21
- cb: (record: Model, cache: Cache, identifier: StableRecordIdentifier, store: Store) => void;
20
+ cb: (record: Model, identifier: ResourceKey, store: Store) => void;
22
21
  };
23
22
  };
24
23
  export type StaticModel = typeof Model & {
@@ -1,4 +1,4 @@
1
1
  import type { NotificationType, Store } from "@warp-drive/core";
2
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
2
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
3
3
  import type { Model } from "./model.js";
4
- export default function notifyChanges(identifier: StableRecordIdentifier, value: NotificationType, key: string | undefined, record: Model, store: Store): void;
4
+ export default function notifyChanges(identifier: ResourceKey, value: NotificationType, key: string | undefined, record: Model, store: Store): void;
@@ -1,7 +1,7 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { RequestCacheRequestState, RequestStateService } from "@warp-drive/core/store/-private";
3
3
  import type { Cache } from "@warp-drive/core/types/cache";
4
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
4
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
5
5
  import type { Errors } from "./errors.js";
6
6
  import type { MinimalLegacyRecord } from "./model-methods.js";
7
7
  /**
@@ -45,7 +45,7 @@ inFlight
45
45
  */
46
46
  export default class RecordState {
47
47
  store: Store;
48
- identifier: StableRecordIdentifier;
48
+ identifier: ResourceKey;
49
49
  record: MinimalLegacyRecord;
50
50
  rs: RequestStateService;
51
51
  pendingCount: number;
@@ -1,6 +1,6 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { Graph, ResourceEdge } from "@warp-drive/core/graph/-private";
3
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
4
4
  import type { TypeFromInstance, TypeFromInstanceOrString } from "@warp-drive/core/types/record";
5
5
  import type { Links, Meta, SingleResourceDocument, SingleResourceRelationship } from "@warp-drive/core/types/spec/json-api-raw";
6
6
  import type { IsUnknown } from "../belongs-to.js";
@@ -59,20 +59,20 @@ export default class BelongsToReference<
59
59
  type: TypeFromInstanceOrString<Related>;
60
60
  // unsubscribe tokens given to us by the notification manager
61
61
  ___token: object;
62
- ___identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>;
62
+ ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;
63
63
  ___relatedToken: object | null;
64
64
  _ref: number;
65
- constructor(store: Store, graph: Graph, parentIdentifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>, belongsToRelationship: ResourceEdge, key: K);
65
+ constructor(store: Store, graph: Graph, parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>, belongsToRelationship: ResourceEdge, key: K);
66
66
  destroy(): void;
67
67
  /**
68
68
  * The identifier of the record that this reference refers to.
69
69
  * `null` if no related record is known.
70
70
  *
71
71
  * @property identifier
72
- * @type {StableRecordIdentifier | null}
72
+ * @type {ResourceKey | null}
73
73
  * @public
74
74
  */
75
- get identifier(): StableRecordIdentifier<TypeFromInstanceOrString<Related>> | null;
75
+ get identifier(): ResourceKey<TypeFromInstanceOrString<Related>> | null;
76
76
  /**
77
77
  The `id` of the record that this reference refers to. Together, the
78
78
  `type()` and `id()` methods form a composite key for the identity
@@ -198,7 +198,7 @@ export default class BelongsToReference<
198
198
  @return {Object} The meta information for the belongs-to relationship.
199
199
  */
200
200
  meta(): Meta | null;
201
- _resource(): SingleResourceRelationship<StableRecordIdentifier<TypeFromInstance<Related>>>;
201
+ _resource(): SingleResourceRelationship<ResourceKey<TypeFromInstance<Related>>>;
202
202
  /**
203
203
  This returns a string that represents how the reference will be
204
204
  looked up when it is loaded. If the relationship has a link it will
@@ -2,7 +2,7 @@ import type { Store } from "@warp-drive/core";
2
2
  import type { CollectionEdge, Graph } from "@warp-drive/core/graph/-private";
3
3
  import type { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
4
4
  import type { BaseFinderOptions } from "@warp-drive/core/types";
5
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
5
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
6
6
  import type { TypeFromInstanceOrString } from "@warp-drive/core/types/record";
7
7
  import type { CollectionResourceDocument, CollectionResourceRelationship, ExistingResourceObject, LinkObject, Meta, PaginationLinks } from "@warp-drive/core/types/spec/json-api-raw";
8
8
  import type { IsUnknown } from "../belongs-to.js";
@@ -68,10 +68,10 @@ export default class HasManyReference<
68
68
  type: TypeFromInstanceOrString<Related>;
69
69
  // unsubscribe tokens given to us by the notification manager
70
70
  ___token: object;
71
- ___identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>;
72
- ___relatedTokenMap: Map<StableRecordIdentifier, object>;
71
+ ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;
72
+ ___relatedTokenMap: Map<ResourceKey, object>;
73
73
  _ref: number;
74
- constructor(store: Store, graph: Graph, parentIdentifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
74
+ constructor(store: Store, graph: Graph, parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
75
75
  /**
76
76
  * This method should never be called by user code.
77
77
  *
@@ -82,10 +82,10 @@ export default class HasManyReference<
82
82
  * An array of identifiers for the records that this reference refers to.
83
83
  *
84
84
  * @property identifiers
85
- * @type {StableRecordIdentifier[]}
85
+ * @type {ResourceKey[]}
86
86
  * @public
87
87
  */
88
- get identifiers(): StableRecordIdentifier<TypeFromInstanceOrString<Related>>[];
88
+ get identifiers(): ResourceKey<TypeFromInstanceOrString<Related>>[];
89
89
  _resource(): CollectionResourceRelationship;
90
90
  /**
91
91
  This returns a string that represents how the reference will be