@warp-drive/legacy 5.6.0-beta.0 → 5.6.0-beta.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.
Files changed (47) hide show
  1. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -7
  2. package/declarations/adapter/error.d.ts +2 -2
  3. package/declarations/compat/builders/find-all.d.ts +2 -2
  4. package/declarations/compat/builders/query.d.ts +2 -2
  5. package/declarations/compat/builders/save-record.d.ts +3 -3
  6. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +24 -16
  7. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -2
  8. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +5 -5
  9. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -3
  10. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +40 -18
  11. package/declarations/compat/legacy-network-handler/snapshot.d.ts +63 -44
  12. package/declarations/compat.d.ts +3 -3
  13. package/declarations/model/-private/attr.d.ts +1 -1
  14. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +2 -2
  15. package/declarations/model/-private/hooks.d.ts +2 -2
  16. package/declarations/model/-private/legacy-relationships-support.d.ts +18 -27
  17. package/declarations/model/-private/model-methods.d.ts +3 -4
  18. package/declarations/model/-private/model.d.ts +14 -29
  19. package/declarations/model/-private/notify-changes.d.ts +2 -2
  20. package/declarations/model/-private/promise-many-array.d.ts +0 -3
  21. package/declarations/model/-private/record-state.d.ts +2 -25
  22. package/declarations/model/-private/references/belongs-to.d.ts +6 -6
  23. package/declarations/model/-private/references/has-many.d.ts +6 -12
  24. package/declarations/model/-private/schema-provider.d.ts +6 -10
  25. package/declarations/model/-private.d.ts +2 -1
  26. package/declarations/model/migration-support.d.ts +11 -53
  27. package/declarations/model.d.ts +1 -1
  28. package/declarations/store/-private.d.ts +224 -0
  29. package/declarations/store.d.ts +3 -0
  30. package/dist/{-private-CKrP0ogQ.js → -private-8UmnAf9J.js} +169 -141
  31. package/dist/adapter/-private.js +1 -1
  32. package/dist/adapter/error.js +66 -0
  33. package/dist/adapter/json-api.js +1 -1
  34. package/dist/adapter/rest.js +2 -2
  35. package/dist/compat/-private.js +1 -1
  36. package/dist/compat/builders.js +4 -23
  37. package/dist/compat.js +7 -2
  38. package/dist/{errors-BX5wowuz.js → errors-8kD2mSe_.js} +66 -36
  39. package/dist/model/-private.js +1 -2
  40. package/dist/model/migration-support.js +96 -11
  41. package/dist/model.js +14 -11
  42. package/dist/{schema-provider-BdQhkT-Q.js → schema-provider-DQu4Rjco.js} +165 -60
  43. package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-CS0MIv4F.js} +2 -1
  44. package/dist/store.js +633 -0
  45. package/dist/util-Dul6TZts.js +35 -0
  46. package/dist/utils-Cqw9eRj5.js +23 -0
  47. package/package.json +14 -14
@@ -1,7 +1 @@
1
- /**
2
- * A utility function that returns a promise that resolves
3
- * even when the source promise rejects.
4
- *
5
- * @internal
6
- */
7
- export declare function continueOnReject<T>(promise: Promise<T>): Promise<T>;
1
+ export {};
@@ -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;
@@ -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>;
@@ -1,8 +1,8 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import { createDeferred } from "@warp-drive/core/request";
3
- import type { Request, RequestStateService } from "@warp-drive/core/store/-private";
3
+ import type { Request } 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,36 +13,44 @@ 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
+ /**
25
+ * @private
26
+ */
24
27
  export declare class FetchManager {
25
- isDestroyed: boolean;
26
- requestCache: RequestStateService;
27
- // fetches pending in the runloop, waiting to be coalesced
28
- _pendingFetch: Map<string, Map<StableExistingRecordIdentifier, PendingFetchItem[]>>;
29
- _store: Store;
30
28
  constructor(store: Store);
31
- createSnapshot<T>(identifier: StableRecordIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;
32
- createSnapshot(identifier: StableRecordIdentifier, options?: FindRecordOptions): Snapshot;
29
+ createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;
30
+ createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;
33
31
  /**
34
32
  This method is called by `record.save`, and gets passed a
35
33
  resolver for the promise that `record.save` returns.
36
34
 
37
35
  It schedules saving to happen at the end of the run loop.
38
36
 
39
- @internal
37
+ @private
40
38
  */
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;
39
+ scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument>;
40
+ scheduleFetch(identifier: PersistedResourceKey, options: FindRecordOptions, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
41
+ getPendingFetch(identifier: PersistedResourceKey, options: FindRecordOptions): Promise<PersistedResourceKey> | undefined;
44
42
  flushAllPendingFetches(): void;
45
- fetchDataIfNeededForIdentifier(identifier: StableExistingRecordIdentifier, options: FindRecordOptions | undefined, request: ImmutableRequestInfo): Promise<StableExistingRecordIdentifier>;
43
+ fetchDataIfNeededForIdentifier(identifier: PersistedResourceKey, options: FindRecordOptions | undefined, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
46
44
  destroy(): void;
47
45
  }
46
+ /**
47
+ * This type exists for internal use only for
48
+ * where intimate contracts still exist either for
49
+ * the Test Suite or for Legacy code.
50
+ *
51
+ * @private
52
+ */
53
+ export interface PrivateFetchManager extends FetchManager {
54
+ _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;
55
+ }
48
56
  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,21 +1,55 @@
1
1
  import type { Store } from "@warp-drive/core";
2
- import type { LiveArray } from "@warp-drive/core/store/-private";
3
- import type { FindAllOptions, ModelSchema } from "@warp-drive/core/types";
2
+ import type { FindAllOptions } from "@warp-drive/core/types";
4
3
  import type { Snapshot } from "./snapshot.js";
5
4
  /**
6
5
  SnapshotRecordArray is not directly instantiable.
7
6
  Instances are provided to consuming application's
8
7
  adapters for certain `findAll` requests.
9
8
 
10
- @class SnapshotRecordArray
9
+ @hideconstructor
11
10
  @public
12
11
  */
13
12
  export declare class SnapshotRecordArray {
14
- _snapshots: Snapshot[] | null;
15
- _type: ModelSchema | null;
13
+ /**
14
+ * The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array
15
+ */
16
16
  modelName: string;
17
- __store: Store;
17
+ /**
18
+ * A hash of adapter options passed into the store method for this request.
19
+
20
+ Example
21
+
22
+ ```js [app/adapters/post.js]
23
+ import MyCustomAdapter from './custom-adapter';
24
+
25
+ export default class PostAdapter extends MyCustomAdapter {
26
+ findAll(store, type, sinceToken, snapshotRecordArray) {
27
+ if (snapshotRecordArray.adapterOptions.subscribe) {
28
+ // ...
29
+ }
30
+ // ...
31
+ }
32
+ }
33
+ ```
34
+ */
18
35
  adapterOptions?: Record<string, unknown>;
36
+ /**
37
+ * The relationships to include for this request.
38
+
39
+ Example
40
+
41
+ ```js [app/adapters/application.js]
42
+ import Adapter from '@ember-data/adapter';
43
+
44
+ export default class ApplicationAdapter extends Adapter {
45
+ findAll(store, type, snapshotRecordArray) {
46
+ let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;
47
+
48
+ return fetch(url).then((response) => response.json())
49
+ }
50
+ }
51
+ ```
52
+ */
19
53
  include?: string | string[];
20
54
  /**
21
55
  SnapshotRecordArray is not directly instantiable.
@@ -30,14 +64,6 @@ export declare class SnapshotRecordArray {
30
64
  */
31
65
  constructor(store: Store, type: string, options?: FindAllOptions);
32
66
  /**
33
- An array of records
34
-
35
- @property _recordArray
36
- @private
37
- @type {Array}
38
- */
39
- get _recordArray(): LiveArray;
40
- /**
41
67
  Number of records in the array
42
68
 
43
69
  Example
@@ -51,10 +77,6 @@ export declare class SnapshotRecordArray {
51
77
  }
52
78
  });
53
79
  ```
54
-
55
- @property length
56
- @public
57
- @type {Number}
58
80
  */
59
81
  get length(): number;
60
82
  /**
@@ -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,64 @@ 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
+ /**
25
+ The unique ResourceKey associated with this Snapshot.
26
+
27
+ @public
28
+ */
29
+ identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
30
+ /**
31
+ The ResourceType of the underlying record for this Snapshot, as a string.
32
+
33
+ @public
34
+ */
28
35
  modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;
36
+ /**
37
+ The id of the snapshot's underlying record
38
+
39
+ Example
40
+
41
+ ```js
42
+ // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
43
+ postSnapshot.id; // => '1'
44
+ ```
45
+
46
+ @public
47
+ */
29
48
  id: string | null;
49
+ /**
50
+ If `include` was passed to the options for the request, the value
51
+ would be available here.
52
+
53
+ @public
54
+ */
30
55
  include?: string | string[];
31
- adapterOptions?: Record<string, unknown>;
32
- _store: Store;
33
56
  /**
34
- * @constructor
35
- * @private
36
- * @param options
37
- * @param identifier
38
- * @param _store
57
+ The adapterOptions passed to the request which generated this Snapshot, if any
58
+
59
+ @public
39
60
  */
40
- constructor(options: FindRecordOptions, identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
61
+ adapterOptions?: Record<string, unknown>;
62
+ constructor(options: FindRecordOptions, identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
41
63
  /**
42
64
  The underlying record for this snapshot. Can be used to access methods and
43
65
  properties defined on the record.
44
66
 
45
- Example
46
-
47
- ```javascript
48
- let json = snapshot.record.toJSON();
67
+ ```js
68
+ const someValue = snapshot.record.someProp;
49
69
  ```
50
70
 
51
71
  @property record
52
- @type {Model}
53
72
  @public
54
73
  */
55
74
  get record(): R | null;
56
- get _attributes(): Record<keyof R & string, unknown>;
57
75
  get isNew(): boolean;
58
76
  /**
59
77
  Returns the value of an attribute.
@@ -68,22 +86,28 @@ export declare class Snapshot<R = unknown> {
68
86
 
69
87
  Note: Values are loaded eagerly and cached when the snapshot is created.
70
88
 
71
- @param {String} keyName
72
- @return {Object} The attribute value or undefined
89
+ @return The attribute value or undefined
73
90
  @public
74
91
  */
75
92
  attr(keyName: keyof R & string): unknown;
76
93
  /**
77
94
  Returns all attributes and their corresponding values.
78
95
 
96
+ ::: warning ⚠️ WARNING
97
+ Attributes are SHALLOW copied from the cache.
98
+ Because they are NOT deep copied from the cache, mutating
99
+ any object or array fields will cause unintended side-effects
100
+ and bugs.
101
+ :::
102
+
79
103
  Example
80
104
 
81
- ```javascript
105
+ ```js
82
106
  // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
83
107
  postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
84
108
  ```
85
109
 
86
- @return {Object} All attributes of the current snapshot
110
+ @return All attributes of the current snapshot
87
111
  @public
88
112
  */
89
113
  attributes(): Record<keyof R & string, unknown>;
@@ -92,13 +116,13 @@ export declare class Snapshot<R = unknown> {
92
116
 
93
117
  Example
94
118
 
95
- ```javascript
119
+ ```js
96
120
  // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
97
121
  postModel.set('title', 'Ember.js rocks!');
98
122
  postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
99
123
  ```
100
124
 
101
- @return {Object} All changed attributes of the current snapshot
125
+ @return All changed attributes of the current snapshot
102
126
  @public
103
127
  */
104
128
  changedAttributes(): ChangedAttributesHash;
@@ -113,7 +137,7 @@ export declare class Snapshot<R = unknown> {
113
137
 
114
138
  Example
115
139
 
116
- ```javascript
140
+ ```js
117
141
  // store.push('post', { id: 1, title: 'Hello World' });
118
142
  // store.createRecord('comment', { body: 'Lorem ipsum', post: post });
119
143
  commentSnapshot.belongsTo('post'); // => Snapshot
@@ -130,12 +154,10 @@ export declare class Snapshot<R = unknown> {
130
154
 
131
155
  Note: Relationships are loaded lazily and cached upon first access.
132
156
 
133
- @param {String} keyName
134
- @param {Object} [options]
135
157
  @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.
158
+ @return A snapshot or ID of a known relationship or null if the
159
+ relationship is known but unset. undefined will be returned if the
160
+ contents of the relationship are unknown.
139
161
  */
140
162
  belongsTo(keyName: string, options?: {
141
163
  id?: boolean;
@@ -162,10 +184,8 @@ export declare class Snapshot<R = unknown> {
162
184
 
163
185
  Note: Relationships are loaded lazily and cached upon first access.
164
186
 
165
- @param {String} keyName
166
- @param {Object} [options]
167
187
  @public
168
- @return {(Array|undefined)} An array of snapshots or IDs of a known
188
+ @return An array of snapshots or IDs of a known
169
189
  relationship or an empty array if the relationship is known but unset.
170
190
  undefined will be returned if the contents of the relationship is unknown.
171
191
  */
@@ -184,8 +204,8 @@ export declare class Snapshot<R = unknown> {
184
204
  });
185
205
  ```
186
206
 
187
- @param {Function} callback the callback to execute
188
- @param {Object} [binding] the value to which the callback's `this` should be bound
207
+ @param callback the callback to execute
208
+ @param binding the optional value to which the callback's `this` should be bound
189
209
  @public
190
210
  */
191
211
  eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void;
@@ -201,8 +221,8 @@ export declare class Snapshot<R = unknown> {
201
221
  });
202
222
  ```
203
223
 
204
- @param {Function} callback the callback to execute
205
- @param {Object} [binding] the value to which the callback's `this` should be bound
224
+ @param callback the callback to execute
225
+ @param binding the optional value to which the callback's `this` should be bound
206
226
  @public
207
227
  */
208
228
  eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void;
@@ -227,8 +247,7 @@ export declare class Snapshot<R = unknown> {
227
247
  });
228
248
  ```
229
249
 
230
- @param {Object} options
231
- @return {Object} an object whose values are primitive JSON values only
250
+ @return an object whose values are primitive JSON values only
232
251
  @public
233
252
  */
234
253
  serialize(options?: SerializerOptions): unknown;
@@ -6,7 +6,7 @@ import type { AdapterPayload, MinimumAdapterInterface } from "./compat/legacy-ne
6
6
  import type { MinimumSerializerInterface, SerializerOptions } from "./compat/legacy-network-handler/minimum-serializer-interface.js";
7
7
  export { LegacyNetworkHandler } from "./compat/legacy-network-handler/legacy-network-handler.js";
8
8
  export type { MinimumAdapterInterface, MinimumSerializerInterface, SerializerOptions, AdapterPayload };
9
- export type LegacyStoreCompat = {
9
+ export interface LegacyStoreCompat extends Store {
10
10
  _fetchManager: FetchManager;
11
11
  adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
12
12
  adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
@@ -20,8 +20,8 @@ export type LegacyStoreCompat = {
20
20
  _serializerCache: Record<string, MinimumSerializerInterface & {
21
21
  store: Store;
22
22
  }>;
23
- };
24
- export type CompatStore = Store & LegacyStoreCompat;
23
+ }
24
+ export type CompatStore = LegacyStoreCompat;
25
25
  /**
26
26
  Returns an instance of the adapter for a given type. For
27
27
  example, `adapterFor('person')` will return an instance of
@@ -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,9 +1,7 @@
1
1
  import type { Store } from "@warp-drive/core";
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";
6
- import type { Cache } from "@warp-drive/core/types/cache";
2
+ import type { CollectionEdge, ResourceEdge, UpgradedMeta } from "@warp-drive/core/graph/-private";
3
+ import type { LegacyManyArray } from "@warp-drive/core/store/-private";
4
+ import type { BaseFinderOptions, ResourceKey } from "@warp-drive/core/types";
7
5
  import type { CollectionRelationship } from "@warp-drive/core/types/cache/relationship";
8
6
  import type { LocalRelationshipOperation } from "@warp-drive/core/types/graph";
9
7
  import type { OpaqueRecordInstance, TypeFromInstanceOrString } from "@warp-drive/core/types/record";
@@ -15,33 +13,26 @@ import type { HasManyProxyCreateArgs } from "./promise-many-array.js";
15
13
  import { PromiseManyArray } from "./promise-many-array.js";
16
14
  import BelongsToReference from "./references/belongs-to.js";
17
15
  import HasManyReference from "./references/has-many.js";
18
- export declare const LEGACY_SUPPORT: Map<StableRecordIdentifier | MinimalLegacyRecord, LegacySupport>;
16
+ export declare const LEGACY_SUPPORT: Map<ResourceKey | MinimalLegacyRecord, LegacySupport>;
19
17
  export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
18
+ /**
19
+ * @hideconstructor
20
+ */
20
21
  export declare class LegacySupport {
21
- record: MinimalLegacyRecord;
22
- store: Store;
23
- graph: Graph;
24
- cache: Cache;
25
- references: Record<string, BelongsToReference | HasManyReference>;
26
- identifier: StableRecordIdentifier;
27
- _manyArrayCache: Record<string, ManyArray>;
28
- _relationshipPromisesCache: Record<string, Promise<ManyArray | OpaqueRecordInstance>>;
29
- _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
30
- _pending: Record<string, Promise<StableRecordIdentifier | null> | undefined>;
31
- isDestroying: boolean;
32
- isDestroyed: boolean;
33
- constructor(record: MinimalLegacyRecord);
34
- _syncArray(array: LiveArray): void;
22
+ identifier: ResourceKey;
23
+ constructor(record: MinimalLegacyRecord, identifier: ResourceKey);
24
+ /** @private */
25
+ _syncArray(array: LegacyManyArray): void;
35
26
  mutate(mutation: LocalRelationshipOperation): void;
36
27
  _findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
37
28
  reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
38
29
  getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
39
30
  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;
31
+ _getCurrentState<T>(identifier: ResourceKey, field: string): [ResourceKey<TypeFromInstanceOrString<T>>[], CollectionRelationship];
32
+ getManyArray<T>(key: string, definition?: UpgradedMeta): LegacyManyArray<T>;
33
+ fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: LegacyManyArray, options?: BaseFinderOptions): Promise<LegacyManyArray>;
34
+ reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<LegacyManyArray<T>> | PromiseManyArray<T>;
35
+ getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | LegacyManyArray;
45
36
  _updatePromiseProxyFor(kind: "hasMany", key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
46
37
  _updatePromiseProxyFor(kind: "belongsTo", key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
47
38
  _updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
@@ -49,8 +40,8 @@ export declare class LegacySupport {
49
40
  }): PromiseBelongsTo;
50
41
  referenceFor(kind: "belongsTo", name: string): BelongsToReference;
51
42
  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>;
43
+ _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: ResourceKey, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
44
+ _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: ResourceKey, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<ResourceKey | null>;
54
45
  destroy(): void;
55
46
  }
56
47
  export declare function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean;