@warp-drive/core 5.7.0-alpha.13 → 5.7.0-alpha.14

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 (34) hide show
  1. package/declarations/reactive/-private/symbols.d.ts +0 -1
  2. package/declarations/request/-private/fetch.d.ts +2 -2
  3. package/declarations/request/-private/utils.d.ts +44 -2
  4. package/declarations/store/-private/cache-handler/types.d.ts +1 -1
  5. package/declarations/store/-private/managers/notification-manager.d.ts +4 -7
  6. package/declarations/store/-private/managers/record-array-manager.d.ts +72 -21
  7. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +1 -0
  8. package/declarations/store/-private/record-arrays/-utils.d.ts +82 -0
  9. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +89 -0
  10. package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts} +43 -101
  11. package/declarations/store/-private/record-arrays/legacy-query.d.ts +103 -0
  12. package/declarations/store/-private/record-arrays/resource-array.d.ts +82 -0
  13. package/declarations/store/-private/store-service.d.ts +3 -3
  14. package/declarations/store/-private.d.ts +4 -2
  15. package/declarations/store/deprecated/store.d.ts +8 -9
  16. package/declarations/types/-private.d.ts +1 -1
  17. package/declarations/types/cache/operations.d.ts +97 -14
  18. package/declarations/types/request.d.ts +21 -0
  19. package/declarations/types/schema/fields.d.ts +1 -1
  20. package/dist/{context-COmAnXUQ.js → context-kQXhkeBj.js} +13 -0
  21. package/dist/graph/-private.js +4 -4
  22. package/dist/index.js +6 -2
  23. package/dist/reactive/-private.js +1 -1
  24. package/dist/reactive.js +3 -3
  25. package/dist/{request-state-BWYju5O9.js → request-state-CCrTjb0Z.js} +861 -799
  26. package/dist/request.js +1 -1
  27. package/dist/store/-private.js +1 -1
  28. package/dist/store.js +2 -1
  29. package/dist/{symbols-BoONANuz.js → symbols-C5p2hcy9.js} +0 -1
  30. package/dist/types/-private.js +1 -1
  31. package/dist/types/request.js +27 -0
  32. package/dist/types/schema/fields.js +2 -0
  33. package/package.json +3 -3
  34. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
@@ -25,7 +25,6 @@
25
25
  // Note that none of these symbols are part of the public API, these are used for
26
26
  // debugging DX and as a safe way to provide an intimate contract on public objects.
27
27
  export declare const SOURCE: "___(unique) Symbol(SOURCE)";
28
- export declare const MUTATE: "___(unique) Symbol(MUTATE)";
29
28
  export declare const Destroy: "___(unique) Symbol(Destroy)";
30
29
  export declare const Checkout: "___(unique) Symbol(Checkout)";
31
30
  export declare const Context: "___(unique) Symbol(Context)";
@@ -1,6 +1,6 @@
1
1
  import { type Context } from "./context.js";
2
- import type { HttpErrorProps } from "./utils.js";
3
- export type { HttpErrorProps };
2
+ import type { FetchError } from "./utils.js";
3
+ export type { FetchError };
4
4
  interface FastbootRequest extends Request {
5
5
  protocol: string;
6
6
  host: string;
@@ -3,12 +3,54 @@ import { ContextOwner } from "./context.js";
3
3
  import type { DeferredFuture, Future, GodContext, Handler } from "./types.js";
4
4
  export declare const IS_CACHE_HANDLER: "___(unique) Symbol(IS_CACHE_HANDLER)";
5
5
  export declare function curryFuture<T>(owner: ContextOwner, inbound: Future<T>, outbound: DeferredFuture<T>): Future<T>;
6
- export interface HttpErrorProps extends DOMException {
6
+ /**
7
+ * Additional properties exposed on errors thrown by the
8
+ * {@link Fetch | Fetch Handler}.
9
+ *
10
+ * In the case of an Abort or system/browser level issue,
11
+ * this extends {@link DOMException}.
12
+ *
13
+ * Else it extends from {@link AggregateError} if the
14
+ * response includes an array of errors, falling back
15
+ * to {@link Error} as its base.
16
+ */
17
+ export interface FetchError extends DOMException {
18
+ /**
19
+ * Alias for {@link FetchError.status | status}.
20
+ *
21
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
22
+ */
7
23
  code: number;
24
+ /**
25
+ * The name associated to the {@link FetchError.status | status code}.
26
+ *
27
+ * Typically this will be of the formula `StatusTextError` for instance
28
+ * a 404 status with status text of `Not Found` would have the name
29
+ * `NotFoundError`.
30
+ */
8
31
  name: string;
32
+ /**
33
+ * The http status code associated to the returned error.
34
+ *
35
+ * Browser/System level network errors will often have an error code of `0` or `5`.
36
+ * Aborted requests will have an error code of `20`.
37
+ *
38
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
39
+ */
9
40
  status: number;
41
+ /**
42
+ * The Status Text associated to the {@link FetchError.status | status code}
43
+ * for the error.
44
+ *
45
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
46
+ *
47
+ */
10
48
  statusText: string;
11
- isRequestError: boolean;
49
+ /**
50
+ * A property signifying that an Error uses the {@link FetchError}
51
+ * interface.
52
+ */
53
+ isRequestError: true;
12
54
  }
13
55
  export declare function enhanceReason(reason?: string): DOMException;
14
56
  export declare function handleOutcome<T>(owner: ContextOwner, inbound: Promise<T | StructuredDataDocument<T>>, outbound: DeferredFuture<T>): Future<T>;
@@ -71,7 +71,7 @@ export interface CachePolicy {
71
71
  * so that request subscriptions can reload when needed.
72
72
  *
73
73
  * ```ts
74
- * store.notifications.notify(identifier, 'invalidated');
74
+ * store.notifications.notify(identifier, 'invalidated', null);
75
75
  * ```
76
76
  *
77
77
  * This allows anything subscribed to the request to be notified of the change
@@ -81,18 +81,15 @@ export default class NotificationManager {
81
81
  *
82
82
  * @private
83
83
  */
84
- notify(identifier: StableRecordIdentifier, value: "attributes" | "relationships", key?: string): boolean;
85
- notify(identifier: StableRecordIdentifier, value: "errors" | "meta" | "identity" | "state"): boolean;
86
- notify(identifier: StableRecordIdentifier, value: CacheOperation): boolean;
87
- notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation): boolean;
84
+ notify(identifier: StableRecordIdentifier, value: "attributes" | "relationships", key?: string | null): boolean;
85
+ notify(identifier: StableRecordIdentifier, value: "errors" | "meta" | "identity" | "state", key?: null): boolean;
86
+ notify(identifier: StableRecordIdentifier, value: CacheOperation, key?: null): boolean;
87
+ notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation, key?: null): boolean;
88
88
  /** @internal */
89
89
  _onNextFlush(cb: () => void): void;
90
90
  private _scheduleNotify;
91
91
  /** @internal */
92
92
  _flush(): void;
93
- private _flushNotification;
94
- private _flushNotification;
95
- private _flushNotification;
96
93
  /** @internal */
97
94
  destroy(): void;
98
95
  }
@@ -2,7 +2,9 @@ import type { LocalRelationshipOperation } from "../../../types/graph.js";
2
2
  import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
3
3
  import type { ImmutableRequestInfo } from "../../../types/request.js";
4
4
  import type { CollectionResourceDocument } from "../../../types/spec/json-api-raw.js";
5
- import { Collection, IdentifierArray } from "../record-arrays/identifier-array.js";
5
+ import type { LegacyLiveArray } from "../record-arrays/legacy-live-array.js";
6
+ import { type LegacyQueryArray } from "../record-arrays/legacy-query.js";
7
+ import { type ReactiveResourceArray } from "../record-arrays/resource-array.js";
6
8
  import type { Store } from "../store-service.js";
7
9
  import type { UnsubscribeToken } from "./notification-manager.js";
8
10
  /**
@@ -38,12 +40,22 @@ import type { UnsubscribeToken } from "./notification-manager.js";
38
40
  * Sincerely,
39
41
  * - runspired (Chris Thoburn) 08/21/2022
40
42
  *
41
- * @function fastPush
42
43
  * @internal
43
44
  * @param target the array to push into
44
45
  * @param source the items to push into target
45
46
  */
46
47
  export declare function fastPush<T>(target: T[], source: T[]): void;
48
+ interface LegacyQueryInit {
49
+ type: string;
50
+ query: ImmutableRequestInfo | Record<string, unknown>;
51
+ }
52
+ interface AnonymousRequestCollectionInit {
53
+ source: StableRecordIdentifier[];
54
+ }
55
+ interface RequestCollectionInit {
56
+ source: StableRecordIdentifier[];
57
+ requestKey: StableDocumentIdentifier;
58
+ }
47
59
  type ChangeSet = Map<StableRecordIdentifier, "add" | "del">;
48
60
  /**
49
61
  @class RecordArrayManager
@@ -53,20 +65,61 @@ export declare class RecordArrayManager {
53
65
  store: Store;
54
66
  isDestroying: boolean;
55
67
  isDestroyed: boolean;
56
- _set: Map<IdentifierArray, Set<StableRecordIdentifier>>;
57
- _live: Map<string, IdentifierArray>;
58
- _managed: Set<IdentifierArray>;
59
- _pending: Map<IdentifierArray, ChangeSet>;
60
- _identifiers: Map<StableRecordIdentifier, Set<Collection>>;
68
+ /**
69
+ *
70
+ */
71
+ _set: Map<ReactiveResourceArray, Set<StableRecordIdentifier>>;
72
+ /**
73
+ * LiveArray (peekAll/findAll) array instances
74
+ * keyed by their ResourceType.
75
+ */
76
+ _live: Map<string, LegacyLiveArray>;
77
+ /**
78
+ *
79
+ */
80
+ _managed: Set<ReactiveResourceArray>;
81
+ /**
82
+ * Buffered changes to apply keyed by the array to
83
+ * which to apply them to.
84
+ */
85
+ _pending: Map<ReactiveResourceArray, ChangeSet>;
86
+ /**
87
+ * An inverse map from StableRecordIdentifier to the list
88
+ * of arrays it can be found in, useful for fast updates
89
+ * when state changes to a resource occur.
90
+ */
91
+ _identifiers: Map<StableRecordIdentifier, Set<ReactiveResourceArray>>;
92
+ /**
93
+ * When we do not yet have a LiveArray, this keeps track of
94
+ * the added/removed identifiers to enable us to more efficiently
95
+ * produce the LiveArray later.
96
+ *
97
+ * It's possible that using a Set and only storing additions instead of
98
+ * additions and deletes would be more efficient.
99
+ */
61
100
  _staged: Map<string, ChangeSet>;
62
101
  _subscription: UnsubscribeToken;
63
102
  _documentSubscription: UnsubscribeToken;
64
- _keyedArrays: Map<string, Collection>;
103
+ /**
104
+ * KeyedArrays are arrays associated to a specific RequestKey.
105
+ */
106
+ _keyedArrays: Map<string, ReactiveResourceArray>;
107
+ /**
108
+ * The visibility set tracks whether a given identifier should
109
+ * be shown in RecordArrays. It is used to dedupe added/removed
110
+ * and state change events.
111
+ *
112
+ * As a Map, it grows to be very large - there may be ways to
113
+ * reduce its size by instead migrating to it functioning as
114
+ * an exclusion list. Any entry not in the list would be considered
115
+ * visible.
116
+ */
65
117
  _visibilitySet: Map<StableRecordIdentifier, boolean>;
66
118
  constructor(options: {
67
119
  store: Store;
68
120
  });
69
- _syncArray(array: IdentifierArray | Collection): void;
121
+ private _subscribeToResourceChanges;
122
+ _syncArray(array: ReactiveResourceArray): void;
70
123
  mutate(mutation: LocalRelationshipOperation): void;
71
124
  /**
72
125
  Get the `RecordArray` for a modelName, which contains all loaded records of
@@ -76,22 +129,20 @@ export declare class RecordArrayManager {
76
129
  @param {String} modelName
77
130
  @return {RecordArray}
78
131
  */
79
- liveArrayFor(type: string): IdentifierArray;
80
- getCollection(config: {
81
- type?: string;
82
- query?: ImmutableRequestInfo | Record<string, unknown>;
83
- identifiers?: StableRecordIdentifier[];
84
- doc?: CollectionResourceDocument;
85
- identifier?: StableDocumentIdentifier | null;
86
- }): Collection;
87
- dirtyArray(array: IdentifierArray, delta: number, shouldSyncFromCache: boolean): void;
88
- _getPendingFor(identifier: StableRecordIdentifier, includeManaged: boolean, isRemove?: boolean): Map<IdentifierArray, ChangeSet> | void;
89
- populateManagedArray(array: Collection, identifiers: StableRecordIdentifier[], payload: CollectionResourceDocument | null): void;
132
+ liveArrayFor(type: string): LegacyLiveArray;
133
+ getCollection(config: LegacyQueryInit): LegacyQueryArray;
134
+ getCollection(config: AnonymousRequestCollectionInit): ReactiveResourceArray;
135
+ getCollection(config: RequestCollectionInit): ReactiveResourceArray;
136
+ dirtyArray(array: ReactiveResourceArray, delta: number, shouldSyncFromCache: boolean): void;
137
+ _getPendingFor(identifier: StableRecordIdentifier, includeManaged: boolean, isRemove?: boolean): Map<ReactiveResourceArray, ChangeSet> | void;
138
+ populateManagedArray(array: ReactiveResourceArray, identifiers: StableRecordIdentifier[], payload: CollectionResourceDocument | null): void;
90
139
  identifierAdded(identifier: StableRecordIdentifier): void;
91
140
  identifierRemoved(identifier: StableRecordIdentifier): void;
92
141
  identifierChanged(identifier: StableRecordIdentifier): void;
142
+ pause(): void;
143
+ resume(): void;
93
144
  clear(isClear?: boolean): void;
94
145
  destroy(): void;
95
146
  }
96
- export declare function disassociateIdentifier(ArraysCache: Map<StableRecordIdentifier, Set<Collection>>, array: Collection, identifier: StableRecordIdentifier): void;
147
+ export declare function disassociateIdentifier(ArraysCache: Map<StableRecordIdentifier, Set<ReactiveResourceArray>>, array: ReactiveResourceArray, identifier: StableRecordIdentifier): void;
97
148
  export {};
@@ -7,6 +7,7 @@ import type { SignalStore, WarpDriveSignal } from "./internal.js";
7
7
  * @internal
8
8
  */
9
9
  export declare function entangleSignal<T extends object>(signals: SignalStore, obj: T, key: string | symbol, initialValue: unknown): WarpDriveSignal;
10
+ export declare function createSignalDescriptor(key: string | symbol, intialValue: unknown): PropertyDescriptor;
10
11
  /**
11
12
  * define an enumerable signal property.
12
13
  *
@@ -0,0 +1,82 @@
1
+ import type { BaseFinderOptions } from "../../../types.js";
2
+ import type { LocalRelationshipOperation } from "../../../types/graph.js";
3
+ import type { StableRecordIdentifier } from "../../../types/identifier.js";
4
+ import type { Store } from "../store-service.js";
5
+ import type { NativeProxy } from "./native-proxy-type-fix.js";
6
+ import type { ReactiveResourceArray } from "./resource-array.js";
7
+ /**
8
+ * LegacyArrays have the capability of updating via `array.update()`
9
+ * and saving each contained record individually via `array.save()`
10
+ */
11
+ export interface LegacyArray<T = unknown> extends ReactiveResourceArray<T> {
12
+ /**
13
+ The flag to signal a `RecordArray` is currently loading data.
14
+ Example
15
+ ```javascript
16
+ let people = store.peekAll('person');
17
+ people.isUpdating; // false
18
+ people.update();
19
+ people.isUpdating; // true
20
+ ```
21
+ */
22
+ isUpdating: boolean;
23
+ /** @internal */
24
+ _updatingPromise: Promise<LegacyArray<T>> | null;
25
+ /**
26
+ Used to get the latest version of all of the records in this array
27
+ from the adapter.
28
+
29
+ Example
30
+
31
+ ```javascript
32
+ let people = store.peekAll('person');
33
+ people.isUpdating; // false
34
+
35
+ people.update().then(function() {
36
+ people.isUpdating; // false
37
+ });
38
+
39
+ people.isUpdating; // true
40
+ ```
41
+
42
+ @public
43
+ */
44
+ update(this: LegacyArray<T>): Promise<LegacyArray<T>>;
45
+ /**
46
+ Saves all of the records in the `RecordArray`.
47
+
48
+ Example
49
+
50
+ ```js
51
+ let messages = store.peekAll('message');
52
+ messages.forEach(function(message) {
53
+ message.hasBeenSeen = true;
54
+ });
55
+ messages.save();
56
+ ```
57
+
58
+ @public
59
+ */
60
+ save(this: LegacyArray<T>): Promise<LegacyArray<T>>;
61
+ }
62
+ export declare function upgradeThis(obj: unknown): asserts obj is LegacyArray;
63
+ export declare function update(this: ReactiveResourceArray): Promise<ReactiveResourceArray>;
64
+ export declare function save(this: ReactiveResourceArray): Promise<ReactiveResourceArray>;
65
+ export type KeyType = string | symbol | number;
66
+ export declare function isArrayGetter<T>(prop: KeyType): prop is keyof Array<T>;
67
+ export declare function isArraySetter<T>(prop: KeyType): prop is keyof Array<T>;
68
+ export declare function convertToInt(prop: KeyType): number | null;
69
+ export type ForEachCB<T> = (record: T, index: number, context: typeof NativeProxy<StableRecordIdentifier[], T[]>) => void;
70
+ export declare function safeForEach<T>(instance: typeof NativeProxy<StableRecordIdentifier[], T[]>, arr: StableRecordIdentifier[], store: Store, callback: ForEachCB<T>, target: unknown): typeof NativeProxy<StableRecordIdentifier[], T[]>;
71
+ type PromiseTo<T> = Omit<Promise<T>, typeof Symbol.toStringTag>;
72
+ type PromiseManyArray<T> = {
73
+ length: number;
74
+ content: ReactiveResourceArray<T> | null;
75
+ promise: Promise<ReactiveResourceArray<T>> | null;
76
+ } & PromiseTo<ReactiveResourceArray<T>>;
77
+ export interface MinimumManager {
78
+ _syncArray(array: ReactiveResourceArray): void;
79
+ mutate?(mutation: LocalRelationshipOperation): void;
80
+ reloadHasMany?<T>(key: string, options?: BaseFinderOptions): Promise<ReactiveResourceArray> | PromiseManyArray<T>;
81
+ }
82
+ export {};
@@ -0,0 +1,89 @@
1
+ import type { StableRecordIdentifier } from "../../../types/identifier.js";
2
+ import type { TypeFromInstanceOrString } from "../../../types/record.js";
3
+ import type { Store } from "../store-service.js";
4
+ import type { LegacyArray, MinimumManager } from "./-utils.js";
5
+ /**
6
+ * LiveArrays contain all the known records for a given `ResourceType`.
7
+ *
8
+ * ### Basic Example
9
+ *
10
+ * For instance, if an application were to have a `'user'` type:
11
+ *
12
+ * ```ts
13
+ * const usersLiveArray = store.peekAll('user');
14
+ * ```
15
+ *
16
+ * ---
17
+ *
18
+ * &nbsp;
19
+ *
20
+ * ### LiveArrays are Arrays
21
+ *
22
+ * LiveArrays have all array APIs, and will report `true`
23
+ * for both `liveArray instanceof Array` and `Array.isArray(liveArray)`
24
+ *
25
+ * ---
26
+ *
27
+ * &nbsp;
28
+ *
29
+ * ### Reactive
30
+ *
31
+ * The array is "live" as it will reactively update any time new
32
+ * users are added to the store's cache.
33
+ *
34
+ * There is only one LiveArray instance per ResourceType, and it
35
+ * can be accessed either via {@link Store.peekAll} or {@link Store.findAll}
36
+ *
37
+ * ```ts
38
+ * const users = await store.findAll('user');
39
+ * const peekedUsers = store.peekAll('user');
40
+ * peekedUsers === users; // true
41
+ * ```
42
+ *
43
+ * ---
44
+ *
45
+ * &nbsp;
46
+ *
47
+ * ### New Records
48
+ *
49
+ * Records in the `"new"` state (created locally on the client
50
+ * but not yet saved) appear in LiveArrays if they are in LegacyMode.
51
+ *
52
+ * PolarisMode records in the `"new"` state do not appear in LiveArrays.
53
+ *
54
+ * ---
55
+ *
56
+ * &nbsp;
57
+ *
58
+ * ### Polymorphism
59
+ *
60
+ * LiveArrays are not polymorphic. If your application has an abstract
61
+ * type "car" with concrete types "ferrari" and "bmw", then "ferrari"
62
+ * and "bmw" will have populated LiveArrays, but the LiveArray for "car"
63
+ * would be empty.
64
+ *
65
+ * @legacy we recommend againt using LiveArrays. Use {@link Store.request} instead
66
+ */
67
+ export interface LegacyLiveArray<T = unknown> extends LegacyArray<T> {
68
+ isLoaded: boolean;
69
+ /** @internal */
70
+ DEPRECATED_CLASS_NAME: string;
71
+ modelName: TypeFromInstanceOrString<T>;
72
+ }
73
+ /**
74
+ * The options for {@link createLegacyLiveArray}
75
+ *
76
+ * @internal
77
+ */
78
+ export interface LegacyLiveArrayCreateOptions {
79
+ store: Store;
80
+ manager: MinimumManager;
81
+ source: StableRecordIdentifier[];
82
+ type: string;
83
+ }
84
+ /**
85
+ * Creates a {@link LegacyLiveArray}
86
+ *
87
+ * @internal
88
+ */
89
+ export declare function createLegacyLiveArray(options: LegacyLiveArrayCreateOptions): LegacyLiveArray;
@@ -1,28 +1,10 @@
1
- import type { BaseFinderOptions, ModelSchema, StableRecordIdentifier } from "../../../types.js";
2
- import type { Cache } from "../../../types/cache.js";
3
- import type { TypedRecordInstance, TypeFromInstance, TypeFromInstanceOrString } from "../../../types/record.js";
1
+ import type { BaseFinderOptions, StableRecordIdentifier } from "../../../types.js";
2
+ import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
4
3
  import type { LegacyHasManyField, LinksModeHasManyField } from "../../../types/schema/fields.js";
5
- import type { Links, PaginationLinks } from "../../../types/spec/json-api-raw.js";
6
- import type { CreateRecordProperties, Store } from "../store-service.js";
7
- import type { MinimumManager } from "./identifier-array.js";
8
- import { IdentifierArray } from "./identifier-array.js";
9
- export interface ManyArrayCreateArgs<T> {
10
- identifiers: StableRecordIdentifier<TypeFromInstanceOrString<T>>[];
11
- type: TypeFromInstanceOrString<T>;
12
- store: Store;
13
- allowMutation: boolean;
14
- manager: MinimumManager;
15
- field?: LegacyHasManyField | LinksModeHasManyField;
16
- identifier: StableRecordIdentifier;
17
- cache: Cache;
18
- meta: Record<string, unknown> | null;
19
- links: Links | PaginationLinks | null;
20
- key: string;
21
- isPolymorphic: boolean;
22
- isAsync: boolean;
23
- _inverseIsAsync: boolean;
24
- isLoaded: boolean;
25
- }
4
+ import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
5
+ import type { CreateRecordProperties } from "../store-service.js";
6
+ import type { LegacyLiveArrayCreateOptions } from "./legacy-live-array.js";
7
+ import { type ReactiveResourceArray } from "./resource-array.js";
26
8
  /**
27
9
  A `ManyArray` is a `MutableArray` that represents the contents of a has-many
28
10
  relationship.
@@ -63,83 +45,25 @@ the has-many.
63
45
  We call the record to which a relationship belongs-to the
64
46
  relationship's _owner_.
65
47
 
66
- @class ManyArray
67
48
  @public
68
49
  */
69
- export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
50
+ export interface LegacyManyArray<T = unknown> extends ReactiveResourceArray<T> {
51
+ meta: Meta | null;
52
+ links: Links | PaginationLinks | null;
53
+ /** @internal */
54
+ isPolymorphic: boolean;
55
+ /** @internal */
70
56
  isAsync: boolean;
57
+ /** @internal */
58
+ key: string;
59
+ /** @internal */
60
+ modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
71
61
  /**
72
62
  The loading state of this array
73
-
74
- @property isLoaded
75
- @type {Boolean}
76
63
  @public
77
64
  */
78
65
  isLoaded: boolean;
79
- /**
80
- `true` if the relationship is polymorphic, `false` otherwise.
81
-
82
- @property isPolymorphic
83
- @type {Boolean}
84
- @private
85
- */
86
- isPolymorphic: boolean;
87
- _inverseIsAsync: boolean;
88
- /**
89
- Metadata associated with the request for async hasMany relationships.
90
-
91
- Example
92
-
93
- Given that the server returns the following JSON payload when fetching a
94
- hasMany relationship:
95
-
96
- ```js
97
- {
98
- "comments": [{
99
- "id": 1,
100
- "comment": "This is the first comment",
101
- }, {
102
- // ...
103
- }],
104
-
105
- "meta": {
106
- "page": 1,
107
- "total": 5
108
- }
109
- }
110
- ```
111
-
112
- You can then access the meta data via the `meta` property:
113
-
114
- ```js
115
- let comments = await post.comments;
116
- let meta = comments.meta;
117
-
118
- // meta.page => 1
119
- // meta.total => 5
120
- ```
121
-
122
- @property meta
123
- @type {Object | null}
124
- @public
125
- */
126
- meta: Record<string, unknown> | null;
127
- /**
128
- * Retrieve the links for this relationship
129
- *
130
- @property links
131
- @type {Object | null}
132
- @public
133
- */
134
- links: Links | PaginationLinks | null;
135
- identifier: StableRecordIdentifier;
136
- cache: Cache;
137
- _manager: MinimumManager;
138
- store: Store;
139
- key: string;
140
- type: ModelSchema;
141
- modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
142
- constructor(options: ManyArrayCreateArgs<T>);
66
+ /** @internal */
143
67
  notify(): void;
144
68
  /**
145
69
  Reloads all of the records in the manyArray. If the manyArray
@@ -162,13 +86,11 @@ export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
162
86
 
163
87
  @public
164
88
  */
165
- reload(options?: BaseFinderOptions): Promise<this>;
89
+ reload(options?: BaseFinderOptions): Promise<LegacyManyArray<T>>;
166
90
  /**
167
- Create a child record within the owner
91
+ Create a child record and associated it to the collection
168
92
 
169
93
  @public
170
- @param {Object} hash
171
- @return {Model} record
172
94
  */
173
95
  createRecord(hash: CreateRecordProperties<T>): T;
174
96
  /**
@@ -178,7 +100,7 @@ export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
178
100
 
179
101
  Example
180
102
 
181
- ```javascript
103
+ ```js
182
104
  const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' }));
183
105
 
184
106
  let messages = await inbox.messages;
@@ -189,9 +111,29 @@ export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
189
111
  ```
190
112
 
191
113
  @public
192
- @return {PromiseArray} promise
193
114
  */
194
- save: () => Promise<IdentifierArray<T>>;
115
+ save: () => Promise<LegacyManyArray<T>>;
195
116
  /** @internal */
196
- destroy(): void;
117
+ destroy: () => void;
118
+ }
119
+ /**
120
+ * The options for {@link createLegacyManyArray}
121
+ *
122
+ * @internal
123
+ */
124
+ export interface LegacyManyArrayCreateOptions extends LegacyLiveArrayCreateOptions {
125
+ isLoaded: boolean;
126
+ editable: boolean;
127
+ isAsync: boolean;
128
+ isPolymorphic: boolean;
129
+ field: LegacyHasManyField | LinksModeHasManyField;
130
+ identifier: StableRecordIdentifier;
131
+ links: Links | PaginationLinks | null;
132
+ meta: Meta | null;
197
133
  }
134
+ /**
135
+ * Creates a {@link LegacyManyArray}
136
+ *
137
+ * @internal
138
+ */
139
+ export declare function createLegacyManyArray<T>(options: LegacyManyArrayCreateOptions): LegacyManyArray<T>;