@warp-drive/core 5.6.0-alpha.5 → 5.6.0-beta.1

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 (219) hide show
  1. package/README.md +8 -7
  2. package/cjs-dist/addon-shim.cjs +1 -0
  3. package/cjs-dist/cjs-set-config.cjs +1 -0
  4. package/declarations/build-config/babel-macros.d.ts +1 -0
  5. package/declarations/build-config/canary-features.d.ts +1 -0
  6. package/declarations/build-config/debugging.d.ts +1 -0
  7. package/declarations/build-config/deprecations.d.ts +1 -0
  8. package/declarations/build-config/env.d.ts +1 -0
  9. package/declarations/build-config/macros.d.ts +1 -0
  10. package/declarations/build-config.d.ts +1 -0
  11. package/declarations/configure.d.ts +7 -0
  12. package/declarations/graph/-private/-diff.d.ts +32 -0
  13. package/declarations/graph/-private/-edge-definition.d.ts +148 -0
  14. package/declarations/graph/-private/-state.d.ts +96 -0
  15. package/declarations/graph/-private/-utils.d.ts +31 -0
  16. package/declarations/graph/-private/coerce-id.d.ts +10 -0
  17. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +18 -0
  18. package/declarations/graph/-private/edges/collection.d.ts +39 -0
  19. package/declarations/graph/-private/edges/implicit.d.ts +43 -0
  20. package/declarations/graph/-private/edges/resource.d.ts +24 -0
  21. package/declarations/graph/-private/graph.d.ts +90 -0
  22. package/declarations/graph/-private/normalize-link.d.ts +8 -0
  23. package/declarations/graph/-private/operations/add-to-related-records.d.ts +4 -0
  24. package/declarations/graph/-private/operations/merge-identifier.d.ts +3 -0
  25. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +4 -0
  26. package/declarations/graph/-private/operations/replace-related-record.d.ts +3 -0
  27. package/declarations/graph/-private/operations/replace-related-records.d.ts +62 -0
  28. package/declarations/graph/-private/operations/update-relationship.d.ts +13 -0
  29. package/declarations/graph/-private.d.ts +13 -0
  30. package/declarations/index.d.ts +14 -3
  31. package/declarations/reactive/-private/document.d.ts +146 -0
  32. package/declarations/reactive/-private/fields/compute.d.ts +43 -0
  33. package/declarations/reactive/-private/fields/extension.d.ts +8 -0
  34. package/declarations/reactive/-private/fields/managed-array.d.ts +22 -0
  35. package/declarations/reactive/-private/fields/managed-object.d.ts +21 -0
  36. package/declarations/reactive/-private/fields/many-array-manager.d.ts +19 -0
  37. package/declarations/reactive/-private/hooks.d.ts +5 -0
  38. package/declarations/reactive/-private/record.d.ts +64 -0
  39. package/declarations/reactive/-private/schema.d.ts +271 -0
  40. package/declarations/reactive/-private/symbols.d.ts +36 -0
  41. package/declarations/reactive/-private.d.ts +1 -0
  42. package/declarations/reactive.d.ts +4 -0
  43. package/declarations/request/-private/context.d.ts +34 -35
  44. package/declarations/request/-private/debug.d.ts +2 -3
  45. package/declarations/request/-private/fetch.d.ts +24 -36
  46. package/declarations/request/-private/future.d.ts +3 -4
  47. package/declarations/request/-private/manager.d.ts +159 -132
  48. package/declarations/request/-private/promise-cache.d.ts +21 -13
  49. package/declarations/request/-private/types.d.ts +124 -123
  50. package/declarations/request/-private/utils.d.ts +8 -9
  51. package/declarations/request.d.ts +5 -433
  52. package/declarations/store/-private/cache-handler/handler.d.ts +62 -0
  53. package/declarations/store/-private/cache-handler/types.d.ts +98 -0
  54. package/declarations/store/-private/cache-handler/utils.d.ts +32 -0
  55. package/declarations/store/-private/caches/cache-utils.d.ts +12 -0
  56. package/declarations/store/-private/caches/identifier-cache.d.ts +304 -0
  57. package/declarations/store/-private/caches/instance-cache.d.ts +65 -0
  58. package/declarations/store/-private/caches/resource-utils.d.ts +9 -0
  59. package/declarations/store/-private/debug/utils.d.ts +6 -0
  60. package/declarations/store/-private/default-cache-policy.d.ts +384 -0
  61. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +159 -0
  62. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +17 -0
  63. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +25 -0
  64. package/declarations/store/-private/managers/cache-manager.d.ts +443 -0
  65. package/declarations/store/-private/managers/notification-manager.d.ts +98 -0
  66. package/declarations/store/-private/managers/record-array-manager.d.ts +97 -0
  67. package/declarations/store/-private/network/request-cache.d.ts +107 -0
  68. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +263 -0
  69. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +176 -0
  70. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +169 -0
  71. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +35 -0
  72. package/declarations/store/-private/new-core-tmp/request-state.d.ts +277 -0
  73. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +261 -0
  74. package/declarations/store/-private/record-arrays/identifier-array.d.ts +147 -0
  75. package/declarations/store/-private/record-arrays/many-array.d.ts +197 -0
  76. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +126 -0
  77. package/declarations/store/-private/store-service.d.ts +1605 -0
  78. package/declarations/store/-private/utils/coerce-id.d.ts +10 -0
  79. package/declarations/store/-private/utils/construct-resource.d.ts +6 -0
  80. package/declarations/store/-private/utils/is-non-empty-string.d.ts +1 -0
  81. package/declarations/store/-private/utils/normalize-model-name.d.ts +1 -0
  82. package/declarations/store/-private/utils/uuid-polyfill.d.ts +1 -0
  83. package/declarations/store/-private.d.ts +31 -0
  84. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +99 -0
  85. package/declarations/store/-types/q/ds-model.d.ts +21 -0
  86. package/declarations/store/-types/q/identifier.d.ts +20 -0
  87. package/declarations/store/-types/q/record-instance.d.ts +23 -0
  88. package/declarations/store/-types/q/schema-service.d.ts +354 -0
  89. package/declarations/store/-types/q/store.d.ts +32 -0
  90. package/declarations/store.d.ts +1 -0
  91. package/declarations/types/-private.d.ts +16 -8
  92. package/declarations/types/cache/aliases.d.ts +11 -1
  93. package/declarations/types/cache/change.d.ts +4 -5
  94. package/declarations/types/cache/mutations.d.ts +51 -28
  95. package/declarations/types/cache/operations.d.ts +60 -47
  96. package/declarations/types/cache/relationship.d.ts +11 -9
  97. package/declarations/types/cache.d.ts +495 -484
  98. package/declarations/types/graph.d.ts +31 -40
  99. package/declarations/types/identifier.d.ts +83 -82
  100. package/declarations/types/json/raw.d.ts +1 -2
  101. package/declarations/types/params.d.ts +4 -5
  102. package/declarations/types/record.d.ts +117 -76
  103. package/declarations/types/request.d.ts +289 -266
  104. package/declarations/types/runtime.d.ts +8 -9
  105. package/declarations/types/schema/concepts.d.ts +19 -13
  106. package/declarations/types/schema/fields.d.ts +1712 -1741
  107. package/declarations/types/schema/fields.type-test.d.ts +0 -1
  108. package/declarations/types/spec/document.d.ts +28 -22
  109. package/declarations/types/spec/error.d.ts +16 -17
  110. package/declarations/types/spec/json-api-raw.d.ts +102 -102
  111. package/declarations/types/symbols.d.ts +74 -75
  112. package/declarations/types/utils.d.ts +5 -5
  113. package/declarations/types.d.ts +10 -7
  114. package/declarations/utils/string.d.ts +48 -0
  115. package/dist/build-config/babel-macros.js +1 -0
  116. package/dist/build-config/canary-features.js +1 -0
  117. package/dist/build-config/debugging.js +1 -0
  118. package/dist/build-config/deprecations.js +1 -0
  119. package/dist/build-config/env.js +1 -0
  120. package/dist/build-config/macros.js +1 -0
  121. package/dist/build-config.js +1 -0
  122. package/dist/configure-B48bFHOl.js +181 -0
  123. package/dist/configure.js +1 -0
  124. package/dist/{context-DE5sFezZ.js → context-COmAnXUQ.js} +2 -2
  125. package/dist/graph/-private.js +3372 -0
  126. package/dist/handler-C2T-IyJK.js +339 -0
  127. package/dist/index.js +37 -104
  128. package/dist/reactive/-private.js +1 -0
  129. package/dist/reactive.js +1988 -0
  130. package/dist/request-state-CjLph1LP.js +8139 -0
  131. package/dist/request.js +1 -1
  132. package/dist/store/-private.js +3 -0
  133. package/dist/store.js +545 -0
  134. package/dist/symbols-SIstXMLI.js +44 -0
  135. package/dist/types/-private.js +3 -3
  136. package/dist/types/record.js +1 -1
  137. package/dist/types/request.js +2 -2
  138. package/dist/types/runtime.js +1 -1
  139. package/dist/types/schema/fields.js +8 -41
  140. package/dist/types/symbols.js +3 -3
  141. package/dist/utils/string.js +92 -0
  142. package/logos/NCC-1701-a-blue.svg +4 -0
  143. package/logos/NCC-1701-a-gold.svg +4 -0
  144. package/logos/NCC-1701-a-gold_100.svg +1 -0
  145. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  146. package/logos/NCC-1701-a.svg +4 -0
  147. package/logos/README.md +4 -0
  148. package/logos/docs-badge.svg +2 -0
  149. package/logos/ember-data-logo-dark.svg +12 -0
  150. package/logos/ember-data-logo-light.svg +12 -0
  151. package/logos/github-header.svg +444 -0
  152. package/logos/social1.png +0 -0
  153. package/logos/social2.png +0 -0
  154. package/logos/warp-drive-logo-dark.svg +4 -0
  155. package/logos/warp-drive-logo-gold.svg +4 -0
  156. package/package.json +11 -8
  157. package/declarations/index.d.ts.map +0 -1
  158. package/declarations/request/-private/context.d.ts.map +0 -1
  159. package/declarations/request/-private/debug.d.ts.map +0 -1
  160. package/declarations/request/-private/fetch.d.ts.map +0 -1
  161. package/declarations/request/-private/future.d.ts.map +0 -1
  162. package/declarations/request/-private/manager.d.ts.map +0 -1
  163. package/declarations/request/-private/promise-cache.d.ts.map +0 -1
  164. package/declarations/request/-private/types.d.ts.map +0 -1
  165. package/declarations/request/-private/utils.d.ts.map +0 -1
  166. package/declarations/request.d.ts.map +0 -1
  167. package/declarations/types/-private.d.ts.map +0 -1
  168. package/declarations/types/cache/aliases.d.ts.map +0 -1
  169. package/declarations/types/cache/change.d.ts.map +0 -1
  170. package/declarations/types/cache/mutations.d.ts.map +0 -1
  171. package/declarations/types/cache/operations.d.ts.map +0 -1
  172. package/declarations/types/cache/relationship.d.ts.map +0 -1
  173. package/declarations/types/cache.d.ts.map +0 -1
  174. package/declarations/types/graph.d.ts.map +0 -1
  175. package/declarations/types/identifier.d.ts.map +0 -1
  176. package/declarations/types/json/raw.d.ts.map +0 -1
  177. package/declarations/types/params.d.ts.map +0 -1
  178. package/declarations/types/record.d.ts.map +0 -1
  179. package/declarations/types/record.type-test.d.ts +0 -2
  180. package/declarations/types/record.type-test.d.ts.map +0 -1
  181. package/declarations/types/request.d.ts.map +0 -1
  182. package/declarations/types/request.type-test.d.ts +0 -2
  183. package/declarations/types/request.type-test.d.ts.map +0 -1
  184. package/declarations/types/runtime.d.ts.map +0 -1
  185. package/declarations/types/schema/concepts.d.ts.map +0 -1
  186. package/declarations/types/schema/fields.d.ts.map +0 -1
  187. package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
  188. package/declarations/types/spec/document.d.ts.map +0 -1
  189. package/declarations/types/spec/error.d.ts.map +0 -1
  190. package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
  191. package/declarations/types/symbols.d.ts.map +0 -1
  192. package/declarations/types/utils.d.ts.map +0 -1
  193. package/declarations/types.d.ts.map +0 -1
  194. package/dist/context-DE5sFezZ.js.map +0 -1
  195. package/dist/index.js.map +0 -1
  196. package/dist/request.js.map +0 -1
  197. package/dist/types/-private.js.map +0 -1
  198. package/dist/types/cache/aliases.js.map +0 -1
  199. package/dist/types/cache/change.js.map +0 -1
  200. package/dist/types/cache/mutations.js.map +0 -1
  201. package/dist/types/cache/operations.js.map +0 -1
  202. package/dist/types/cache/relationship.js.map +0 -1
  203. package/dist/types/cache.js.map +0 -1
  204. package/dist/types/graph.js.map +0 -1
  205. package/dist/types/identifier.js.map +0 -1
  206. package/dist/types/json/raw.js.map +0 -1
  207. package/dist/types/params.js.map +0 -1
  208. package/dist/types/record.js.map +0 -1
  209. package/dist/types/request.js.map +0 -1
  210. package/dist/types/runtime.js.map +0 -1
  211. package/dist/types/schema/concepts.js.map +0 -1
  212. package/dist/types/schema/fields.js.map +0 -1
  213. package/dist/types/schema/fields.type-test.js.map +0 -1
  214. package/dist/types/spec/document.js.map +0 -1
  215. package/dist/types/spec/error.js.map +0 -1
  216. package/dist/types/spec/json-api-raw.js.map +0 -1
  217. package/dist/types/symbols.js.map +0 -1
  218. package/dist/types/utils.js.map +0 -1
  219. package/dist/types.js.map +0 -1
@@ -0,0 +1,147 @@
1
+ import type { BaseFinderOptions } from "../../../types.js";
2
+ import type { LocalRelationshipOperation } from "../../../types/graph.js";
3
+ import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
4
+ import type { TypeFromInstanceOrString } from "../../../types/record.js";
5
+ import type { ImmutableRequestInfo } from "../../../types/request.js";
6
+ import type { LegacyHasManyField, LinksModeHasManyField } from "../../../types/schema/fields.js";
7
+ import type { Links, PaginationLinks } from "../../../types/spec/json-api-raw.js";
8
+ import type { RecordArrayManager } from "../managers/record-array-manager.js";
9
+ import type { WarpDriveSignal } from "../new-core-tmp/reactivity/internal.js";
10
+ import { ARRAY_SIGNAL } from "../new-core-tmp/reactivity/internal.js";
11
+ import type { Store } from "../store-service.js";
12
+ import { NativeProxy } from "./native-proxy-type-fix.js";
13
+ export declare const SOURCE: "___(unique) Symbol(#source)";
14
+ export declare const MUTATE: "___(unique) Symbol(#update)";
15
+ declare const IS_COLLECTION: "___(unique) Symbol(IS_COLLECTION)";
16
+ export type IdentifierArrayCreateOptions<T = unknown> = {
17
+ identifiers: StableRecordIdentifier<TypeFromInstanceOrString<T>>[];
18
+ type?: TypeFromInstanceOrString<T>;
19
+ store: Store;
20
+ allowMutation: boolean;
21
+ manager: MinimumManager;
22
+ field?: LegacyHasManyField | LinksModeHasManyField;
23
+ links?: Links | PaginationLinks | null;
24
+ meta?: Record<string, unknown> | null;
25
+ identifier?: StableDocumentIdentifier | null;
26
+ [MUTATE]?(target: StableRecordIdentifier[], receiver: typeof NativeProxy<StableRecordIdentifier[], T[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal): unknown;
27
+ };
28
+ type PromiseTo<T> = Omit<Promise<T>, typeof Symbol.toStringTag>;
29
+ type PromiseManyArray<T> = {
30
+ length: number;
31
+ content: IdentifierArray<T> | null;
32
+ promise: Promise<IdentifierArray<T>> | null;
33
+ } & PromiseTo<IdentifierArray<T>>;
34
+ export type MinimumManager = {
35
+ _syncArray: (array: IdentifierArray) => void;
36
+ mutate?(mutation: LocalRelationshipOperation): void;
37
+ reloadHasMany?<T>(key: string, options?: BaseFinderOptions): Promise<IdentifierArray<T>> | PromiseManyArray<T>;
38
+ };
39
+ /**
40
+ A record array is an array that contains records of a certain type (or modelName).
41
+ The record array materializes records as needed when they are retrieved for the first
42
+ time. You should not create record arrays yourself. Instead, an instance of
43
+ `RecordArray` or its subclasses will be returned by your application's store
44
+ in response to queries.
45
+
46
+ This class should not be imported and instantiated by consuming applications.
47
+
48
+ @class RecordArray
49
+ @public
50
+ */
51
+ export interface IdentifierArray<T = unknown> extends Omit<Array<T>, "[]"> {
52
+ [IS_COLLECTION]: boolean;
53
+ [ARRAY_SIGNAL]: WarpDriveSignal;
54
+ [SOURCE]: StableRecordIdentifier[];
55
+ }
56
+ export declare class IdentifierArray<T = unknown> {
57
+ DEPRECATED_CLASS_NAME: string;
58
+ /**
59
+ The flag to signal a `RecordArray` is currently loading data.
60
+ Example
61
+ ```javascript
62
+ let people = store.peekAll('person');
63
+ people.isUpdating; // false
64
+ people.update();
65
+ people.isUpdating; // true
66
+ ```
67
+ @property isUpdating
68
+ @public
69
+ @type Boolean
70
+ */
71
+ isUpdating: boolean;
72
+ isLoaded: boolean;
73
+ isDestroying: boolean;
74
+ isDestroyed: boolean;
75
+ _updatingPromise: Promise<IdentifierArray<T>> | null;
76
+ readonly identifier: StableDocumentIdentifier | null;
77
+ links: Links | PaginationLinks | null;
78
+ meta: Record<string, unknown> | null;
79
+ modelName?: TypeFromInstanceOrString<T>;
80
+ /**
81
+ The store that created this record array.
82
+
83
+ @property store
84
+ @private
85
+ @type Store
86
+ */
87
+ store: Store;
88
+ _manager: MinimumManager;
89
+ destroy(clear: boolean): void;
90
+ constructor(options: IdentifierArrayCreateOptions<T>);
91
+ /**
92
+ Used to get the latest version of all of the records in this array
93
+ from the adapter.
94
+
95
+ Example
96
+
97
+ ```javascript
98
+ let people = store.peekAll('person');
99
+ people.isUpdating; // false
100
+
101
+ people.update().then(function() {
102
+ people.isUpdating; // false
103
+ });
104
+
105
+ people.isUpdating; // true
106
+ ```
107
+
108
+ @public
109
+ */
110
+ update(): Promise<IdentifierArray<T>>;
111
+ /*
112
+ Update this Array and return a promise which resolves once the update
113
+ is finished.
114
+ */
115
+ _update(): Promise<IdentifierArray<T>>;
116
+ // TODO deprecate
117
+ /**
118
+ Saves all of the records in the `RecordArray`.
119
+
120
+ Example
121
+
122
+ ```javascript
123
+ let messages = store.peekAll('message');
124
+ messages.forEach(function(message) {
125
+ message.hasBeenSeen = true;
126
+ });
127
+ messages.save();
128
+ ```
129
+
130
+ @public
131
+ @return {Promise<IdentifierArray>} promise
132
+ */
133
+ save(): Promise<IdentifierArray>;
134
+ }
135
+ export type CollectionCreateOptions = IdentifierArrayCreateOptions & {
136
+ manager: RecordArrayManager;
137
+ query: ImmutableRequestInfo | Record<string, unknown> | null;
138
+ isLoaded: boolean;
139
+ };
140
+ export declare class Collection<T = unknown> extends IdentifierArray<T> {
141
+ query: ImmutableRequestInfo | Record<string, unknown> | null;
142
+ _manager: RecordArrayManager;
143
+ constructor(options: CollectionCreateOptions);
144
+ _update(): Promise<Collection<T>>;
145
+ destroy(clear: boolean): void;
146
+ }
147
+ export {};
@@ -0,0 +1,197 @@
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";
4
+ 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
+ }
26
+ /**
27
+ A `ManyArray` is a `MutableArray` that represents the contents of a has-many
28
+ relationship.
29
+
30
+ The `ManyArray` is instantiated lazily the first time the relationship is
31
+ requested.
32
+
33
+ This class is not intended to be directly instantiated by consuming applications.
34
+
35
+ ### Inverses
36
+
37
+ Often, the relationships in Ember Data applications will have
38
+ an inverse. For example, imagine the following models are
39
+ defined:
40
+
41
+ ```js [app/models/post.js]
42
+ import Model, { hasMany } from '@ember-data/model';
43
+
44
+ export default class PostModel extends Model {
45
+ @hasMany('comment') comments;
46
+ }
47
+ ```
48
+
49
+ ```js [app/models/comment.js]
50
+ import { Model, belongsTo } from '@warp-drive/legacy/model';
51
+
52
+ export default class CommentModel extends Model {
53
+ @belongsTo('post') post;
54
+ }
55
+ ```
56
+
57
+ If you created a new instance of `Post` and added
58
+ a `Comment` record to its `comments` has-many
59
+ relationship, you would expect the comment's `post`
60
+ property to be set to the post that contained
61
+ the has-many.
62
+
63
+ We call the record to which a relationship belongs-to the
64
+ relationship's _owner_.
65
+
66
+ @class ManyArray
67
+ @public
68
+ */
69
+ export declare class RelatedCollection<T = unknown> extends IdentifierArray<T> {
70
+ isAsync: boolean;
71
+ /**
72
+ The loading state of this array
73
+
74
+ @property isLoaded
75
+ @type {Boolean}
76
+ @public
77
+ */
78
+ 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>);
143
+ notify(): void;
144
+ /**
145
+ Reloads all of the records in the manyArray. If the manyArray
146
+ holds a relationship that was originally fetched using a links url
147
+ WarpDrive will revisit the original links url to repopulate the
148
+ relationship.
149
+
150
+ If the ManyArray holds the result of a `store.query()` reload will
151
+ re-run the original query.
152
+
153
+ Example
154
+
155
+ ```javascript
156
+ let user = store.peekRecord('user', '1')
157
+ await login(user);
158
+
159
+ let permissions = await user.permissions;
160
+ await permissions.reload();
161
+ ```
162
+
163
+ @public
164
+ */
165
+ reload(options?: BaseFinderOptions): Promise<this>;
166
+ /**
167
+ Create a child record within the owner
168
+
169
+ @public
170
+ @param {Object} hash
171
+ @return {Model} record
172
+ */
173
+ createRecord(hash: CreateRecordProperties<T>): T;
174
+ /**
175
+ Saves all of the records in the `ManyArray`.
176
+
177
+ Note: this API can only be used in legacy mode with a configured Adapter.
178
+
179
+ Example
180
+
181
+ ```javascript
182
+ const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' }));
183
+
184
+ let messages = await inbox.messages;
185
+ messages.forEach((message) => {
186
+ message.isRead = true;
187
+ });
188
+ messages.save();
189
+ ```
190
+
191
+ @public
192
+ @return {PromiseArray} promise
193
+ */
194
+ save: () => Promise<IdentifierArray<T>>;
195
+ /** @internal */
196
+ destroy(): void;
197
+ }
@@ -0,0 +1,126 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /*
3
+ We redefine Proxy because the native Proxy type treats the `target` and
4
+ `receiver` as the same type incorrectly.
5
+
6
+ We ported this from Typescript's own Proxy types on 3/10/2024.
7
+ */
8
+ interface ProxyHandler<T extends object> {
9
+ /**
10
+ * A trap method for a function call.
11
+ * @param target The original callable object which is being proxied.
12
+ * @internal
13
+ */
14
+ apply?(target: T, thisArg: any, argArray: any[]): any;
15
+ /**
16
+ * A trap for the `new` operator.
17
+ * @param target The original object which is being proxied.
18
+ * @param newTarget The constructor that was originally called.
19
+ * @internal
20
+ */
21
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
22
+ construct?(target: T, argArray: any[], newTarget: Function): object;
23
+ /**
24
+ * A trap for `Object.defineProperty()`.
25
+ * @param target The original object which is being proxied.
26
+ * @return A `Boolean` indicating whether or not the property has been defined.
27
+ * @internal
28
+ */
29
+ defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean;
30
+ /**
31
+ * A trap for the `delete` operator.
32
+ * @param target The original object which is being proxied.
33
+ * @param p The name or `Symbol` of the property to delete.
34
+ * @return A `Boolean` indicating whether or not the property was deleted.
35
+ * @internal
36
+ */
37
+ deleteProperty?(target: T, p: string | symbol): boolean;
38
+ /**
39
+ * A trap for getting a property value.
40
+ * @param target The original object which is being proxied.
41
+ * @param p The name or `Symbol` of the property to get.
42
+ * @param receiver The proxy or an object that inherits from the proxy.
43
+ * @internal
44
+ */
45
+ get?(target: T, p: string | symbol, receiver: any): any;
46
+ /**
47
+ * A trap for `Object.getOwnPropertyDescriptor()`.
48
+ * @param target The original object which is being proxied.
49
+ * @param p The name of the property whose description should be retrieved.
50
+ * @internal
51
+ */
52
+ getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined;
53
+ /**
54
+ * A trap for the `[[GetPrototypeOf]]` internal method.
55
+ * @param target The original object which is being proxied.
56
+ * @internal
57
+ */
58
+ getPrototypeOf?(target: T): object | null;
59
+ /**
60
+ * A trap for the `in` operator.
61
+ * @param target The original object which is being proxied.
62
+ * @param p The name or `Symbol` of the property to check for existence.
63
+ * @internal
64
+ */
65
+ has?(target: T, p: string | symbol): boolean;
66
+ /**
67
+ * A trap for `Object.isExtensible()`.
68
+ * @param target The original object which is being proxied.
69
+ * @internal
70
+ */
71
+ isExtensible?(target: T): boolean;
72
+ /**
73
+ * A trap for `Reflect.ownKeys()`.
74
+ * @param target The original object which is being proxied.
75
+ * @internal
76
+ */
77
+ ownKeys?(target: T): ArrayLike<string | symbol>;
78
+ /**
79
+ * A trap for `Object.preventExtensions()`.
80
+ * @param target The original object which is being proxied.
81
+ * @internal
82
+ */
83
+ preventExtensions?(target: T): boolean;
84
+ /**
85
+ * A trap for setting a property value.
86
+ * @param target The original object which is being proxied.
87
+ * @param p The name or `Symbol` of the property to set.
88
+ * @param receiver The object to which the assignment was originally directed.
89
+ * @return A `Boolean` indicating whether or not the property was set.
90
+ * @internal
91
+ */
92
+ set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean;
93
+ /**
94
+ * A trap for `Object.setPrototypeOf()`.
95
+ * @param target The original object which is being proxied.
96
+ * @param newPrototype The object's new prototype or `null`.
97
+ * @internal
98
+ */
99
+ setPrototypeOf?(target: T, v: object | null): boolean;
100
+ }
101
+ interface ProxyConstructor {
102
+ /**
103
+ * Creates a revocable Proxy object.
104
+ * @param target A target object to wrap with Proxy.
105
+ * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
106
+ * @internal
107
+ */
108
+ revocable<T extends object>(target: T, handler: ProxyHandler<T>): {
109
+ proxy: T;
110
+ revoke: () => void;
111
+ };
112
+ /**
113
+ * Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the
114
+ * original object, but which may redefine fundamental Object operations like getting, setting, and defining
115
+ * properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.
116
+ * @param target A target object to wrap with Proxy.
117
+ * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
118
+ * @internal
119
+ */
120
+ new <
121
+ TSource extends object,
122
+ TTarget extends object
123
+ >(target: TSource, handler: ProxyHandler<TSource>): TTarget;
124
+ }
125
+ export declare const NativeProxy: ProxyConstructor;
126
+ export {};