@warp-drive/legacy 5.6.0-alpha.11

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 (211) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE.md +23 -0
  3. package/README.md +54 -0
  4. package/addon-main.cjs +5 -0
  5. package/declarations/adapter/-private/build-url-mixin.d.ts +34 -0
  6. package/declarations/adapter/-private/build-url-mixin.d.ts.map +1 -0
  7. package/declarations/adapter/-private/fastboot-interface.d.ts +9 -0
  8. package/declarations/adapter/-private/fastboot-interface.d.ts.map +1 -0
  9. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +8 -0
  10. package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +1 -0
  11. package/declarations/adapter/-private/utils/determine-body-promise.d.ts +5 -0
  12. package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +1 -0
  13. package/declarations/adapter/-private/utils/fetch.d.ts +9 -0
  14. package/declarations/adapter/-private/utils/fetch.d.ts.map +1 -0
  15. package/declarations/adapter/-private/utils/parse-response-headers.d.ts +2 -0
  16. package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +1 -0
  17. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +7 -0
  18. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +1 -0
  19. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +6 -0
  20. package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +1 -0
  21. package/declarations/adapter/-private.d.ts +6 -0
  22. package/declarations/adapter/-private.d.ts.map +1 -0
  23. package/declarations/adapter/error.d.ts +188 -0
  24. package/declarations/adapter/error.d.ts.map +1 -0
  25. package/declarations/adapter/json-api.d.ts +234 -0
  26. package/declarations/adapter/json-api.d.ts.map +1 -0
  27. package/declarations/adapter/rest.d.ts +823 -0
  28. package/declarations/adapter/rest.d.ts.map +1 -0
  29. package/declarations/adapter.d.ts +801 -0
  30. package/declarations/adapter.d.ts.map +1 -0
  31. package/declarations/compat/-private.d.ts +14 -0
  32. package/declarations/compat/-private.d.ts.map +1 -0
  33. package/declarations/compat/builders/find-all.d.ts +33 -0
  34. package/declarations/compat/builders/find-all.d.ts.map +1 -0
  35. package/declarations/compat/builders/find-record.d.ts +54 -0
  36. package/declarations/compat/builders/find-record.d.ts.map +1 -0
  37. package/declarations/compat/builders/query.d.ts +61 -0
  38. package/declarations/compat/builders/query.d.ts.map +1 -0
  39. package/declarations/compat/builders/save-record.d.ts +32 -0
  40. package/declarations/compat/builders/save-record.d.ts.map +1 -0
  41. package/declarations/compat/builders/utils.d.ts +4 -0
  42. package/declarations/compat/builders/utils.d.ts.map +1 -0
  43. package/declarations/compat/builders.d.ts +15 -0
  44. package/declarations/compat/builders.d.ts.map +1 -0
  45. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +47 -0
  46. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +1 -0
  47. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +3 -0
  48. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +1 -0
  49. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +12 -0
  50. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +1 -0
  51. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +6 -0
  52. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +1 -0
  53. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +3 -0
  54. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +1 -0
  55. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +527 -0
  56. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +1 -0
  57. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +224 -0
  58. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +1 -0
  59. package/declarations/compat/legacy-network-handler/serializer-response.d.ts +7 -0
  60. package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +1 -0
  61. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +89 -0
  62. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +1 -0
  63. package/declarations/compat/legacy-network-handler/snapshot.d.ts +237 -0
  64. package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +1 -0
  65. package/declarations/compat/utils.d.ts +138 -0
  66. package/declarations/compat/utils.d.ts.map +1 -0
  67. package/declarations/compat.d.ts +134 -0
  68. package/declarations/compat.d.ts.map +1 -0
  69. package/declarations/model/-private/attr.d.ts +165 -0
  70. package/declarations/model/-private/attr.d.ts.map +1 -0
  71. package/declarations/model/-private/attr.type-test.d.ts +2 -0
  72. package/declarations/model/-private/attr.type-test.d.ts.map +1 -0
  73. package/declarations/model/-private/belongs-to.d.ts +173 -0
  74. package/declarations/model/-private/belongs-to.d.ts.map +1 -0
  75. package/declarations/model/-private/belongs-to.type-test.d.ts +2 -0
  76. package/declarations/model/-private/belongs-to.type-test.d.ts.map +1 -0
  77. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +6 -0
  78. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
  79. package/declarations/model/-private/errors.d.ts +290 -0
  80. package/declarations/model/-private/errors.d.ts.map +1 -0
  81. package/declarations/model/-private/has-many.d.ts +164 -0
  82. package/declarations/model/-private/has-many.d.ts.map +1 -0
  83. package/declarations/model/-private/has-many.type-test.d.ts +2 -0
  84. package/declarations/model/-private/has-many.type-test.d.ts.map +1 -0
  85. package/declarations/model/-private/hooks.d.ts +11 -0
  86. package/declarations/model/-private/hooks.d.ts.map +1 -0
  87. package/declarations/model/-private/legacy-relationships-support.d.ts +57 -0
  88. package/declarations/model/-private/legacy-relationships-support.d.ts.map +1 -0
  89. package/declarations/model/-private/model-for-mixin.d.ts +4 -0
  90. package/declarations/model/-private/model-for-mixin.d.ts.map +1 -0
  91. package/declarations/model/-private/model-methods.d.ts +35 -0
  92. package/declarations/model/-private/model-methods.d.ts.map +1 -0
  93. package/declarations/model/-private/model.d.ts +1270 -0
  94. package/declarations/model/-private/model.d.ts.map +1 -0
  95. package/declarations/model/-private/model.type-test.d.ts +2 -0
  96. package/declarations/model/-private/model.type-test.d.ts.map +1 -0
  97. package/declarations/model/-private/notify-changes.d.ts +5 -0
  98. package/declarations/model/-private/notify-changes.d.ts.map +1 -0
  99. package/declarations/model/-private/promise-belongs-to.d.ts +40 -0
  100. package/declarations/model/-private/promise-belongs-to.d.ts.map +1 -0
  101. package/declarations/model/-private/promise-many-array.d.ts +126 -0
  102. package/declarations/model/-private/promise-many-array.d.ts.map +1 -0
  103. package/declarations/model/-private/promise-proxy-base.d.ts +3 -0
  104. package/declarations/model/-private/promise-proxy-base.d.ts.map +1 -0
  105. package/declarations/model/-private/record-state.d.ts +78 -0
  106. package/declarations/model/-private/record-state.d.ts.map +1 -0
  107. package/declarations/model/-private/references/belongs-to.d.ts +495 -0
  108. package/declarations/model/-private/references/belongs-to.d.ts.map +1 -0
  109. package/declarations/model/-private/references/has-many.d.ts +504 -0
  110. package/declarations/model/-private/references/has-many.d.ts.map +1 -0
  111. package/declarations/model/-private/schema-provider.d.ts +63 -0
  112. package/declarations/model/-private/schema-provider.d.ts.map +1 -0
  113. package/declarations/model/-private/type-utils.d.ts +57 -0
  114. package/declarations/model/-private/type-utils.d.ts.map +1 -0
  115. package/declarations/model/-private/util.d.ts +6 -0
  116. package/declarations/model/-private/util.d.ts.map +1 -0
  117. package/declarations/model/-private.d.ts +8 -0
  118. package/declarations/model/-private.d.ts.map +1 -0
  119. package/declarations/model/migration-support.d.ts +287 -0
  120. package/declarations/model/migration-support.d.ts.map +1 -0
  121. package/declarations/model/migration-support.type-test.d.ts +2 -0
  122. package/declarations/model/migration-support.type-test.d.ts.map +1 -0
  123. package/declarations/model.d.ts +50 -0
  124. package/declarations/model.d.ts.map +1 -0
  125. package/declarations/serializer/-private/embedded-records-mixin.d.ts +97 -0
  126. package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +1 -0
  127. package/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
  128. package/declarations/serializer/-private/transforms/boolean.d.ts.map +1 -0
  129. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +2 -0
  130. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +1 -0
  131. package/declarations/serializer/-private/transforms/date.d.ts +28 -0
  132. package/declarations/serializer/-private/transforms/date.d.ts.map +1 -0
  133. package/declarations/serializer/-private/transforms/number.d.ts +29 -0
  134. package/declarations/serializer/-private/transforms/number.d.ts.map +1 -0
  135. package/declarations/serializer/-private/transforms/string.d.ts +29 -0
  136. package/declarations/serializer/-private/transforms/string.d.ts.map +1 -0
  137. package/declarations/serializer/-private/transforms/transform.d.ts +119 -0
  138. package/declarations/serializer/-private/transforms/transform.d.ts.map +1 -0
  139. package/declarations/serializer/-private/utils.d.ts +4 -0
  140. package/declarations/serializer/-private/utils.d.ts.map +1 -0
  141. package/declarations/serializer/json-api.d.ts +496 -0
  142. package/declarations/serializer/json-api.d.ts.map +1 -0
  143. package/declarations/serializer/json.d.ts +1047 -0
  144. package/declarations/serializer/json.d.ts.map +1 -0
  145. package/declarations/serializer/rest.d.ts +554 -0
  146. package/declarations/serializer/rest.d.ts.map +1 -0
  147. package/declarations/serializer/transform.d.ts +6 -0
  148. package/declarations/serializer/transform.d.ts.map +1 -0
  149. package/declarations/serializer.d.ts +258 -0
  150. package/declarations/serializer.d.ts.map +1 -0
  151. package/dist/-private-DFfBszo5.js +1182 -0
  152. package/dist/-private-DFfBszo5.js.map +1 -0
  153. package/dist/adapter/-private.js +1 -0
  154. package/dist/adapter/-private.js.map +1 -0
  155. package/dist/adapter/error.js +254 -0
  156. package/dist/adapter/error.js.map +1 -0
  157. package/dist/adapter/json-api.js +129 -0
  158. package/dist/adapter/json-api.js.map +1 -0
  159. package/dist/adapter/rest.js +1262 -0
  160. package/dist/adapter/rest.js.map +1 -0
  161. package/dist/adapter.js +1284 -0
  162. package/dist/adapter.js.map +1 -0
  163. package/dist/compat/-private.js +1 -0
  164. package/dist/compat/-private.js.map +1 -0
  165. package/dist/compat/builders.js +292 -0
  166. package/dist/compat/builders.js.map +1 -0
  167. package/dist/compat/utils.js +225 -0
  168. package/dist/compat/utils.js.map +1 -0
  169. package/dist/compat.js +999 -0
  170. package/dist/compat.js.map +1 -0
  171. package/dist/errors-D74uk36r.js +2541 -0
  172. package/dist/errors-D74uk36r.js.map +1 -0
  173. package/dist/json-BCH3fil7.js +1349 -0
  174. package/dist/json-BCH3fil7.js.map +1 -0
  175. package/dist/model/-private.js +2 -0
  176. package/dist/model/-private.js.map +1 -0
  177. package/dist/model/migration-support.js +453 -0
  178. package/dist/model/migration-support.js.map +1 -0
  179. package/dist/model.js +736 -0
  180. package/dist/model.js.map +1 -0
  181. package/dist/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  182. package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +1 -0
  183. package/dist/schema-provider-CXFLTMjg.js +2228 -0
  184. package/dist/schema-provider-CXFLTMjg.js.map +1 -0
  185. package/dist/serialize-into-hash-BxfqWC8u.js +260 -0
  186. package/dist/serialize-into-hash-BxfqWC8u.js.map +1 -0
  187. package/dist/serializer/json-api.js +514 -0
  188. package/dist/serializer/json-api.js.map +1 -0
  189. package/dist/serializer/json.js +6 -0
  190. package/dist/serializer/json.js.map +1 -0
  191. package/dist/serializer/rest.js +1245 -0
  192. package/dist/serializer/rest.js.map +1 -0
  193. package/dist/serializer/transform.js +313 -0
  194. package/dist/serializer/transform.js.map +1 -0
  195. package/dist/serializer.js +252 -0
  196. package/dist/serializer.js.map +1 -0
  197. package/logos/NCC-1701-a-blue.svg +4 -0
  198. package/logos/NCC-1701-a-gold.svg +4 -0
  199. package/logos/NCC-1701-a-gold_100.svg +1 -0
  200. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  201. package/logos/NCC-1701-a.svg +4 -0
  202. package/logos/README.md +4 -0
  203. package/logos/docs-badge.svg +2 -0
  204. package/logos/ember-data-logo-dark.svg +12 -0
  205. package/logos/ember-data-logo-light.svg +12 -0
  206. package/logos/github-header.svg +444 -0
  207. package/logos/social1.png +0 -0
  208. package/logos/social2.png +0 -0
  209. package/logos/warp-drive-logo-dark.svg +4 -0
  210. package/logos/warp-drive-logo-gold.svg +4 -0
  211. package/package.json +72 -0
@@ -0,0 +1,504 @@
1
+ import type { Store } from '@warp-drive/core';
2
+ import type { CollectionEdge, Graph } from '@warp-drive/core/graph/-private';
3
+ import type { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';
4
+ import type { BaseFinderOptions } from '@warp-drive/core/types';
5
+ import type { StableRecordIdentifier } from '@warp-drive/core/types/identifier';
6
+ import type { TypeFromInstanceOrString } from '@warp-drive/core/types/record';
7
+ import type { CollectionResourceDocument, CollectionResourceRelationship, ExistingResourceObject, LinkObject, Meta, PaginationLinks } from '@warp-drive/core/types/spec/json-api-raw';
8
+ import type { IsUnknown } from '../belongs-to.ts';
9
+ import type { MaybeHasManyFields } from '../type-utils.ts';
10
+ interface ResourceIdentifier {
11
+ links?: {
12
+ related?: string | LinkObject;
13
+ };
14
+ meta?: Meta;
15
+ }
16
+ type ArrayItemType<T> = T extends (infer U)[] ? U : never;
17
+ /**
18
+ A `HasManyReference` is a low-level API that allows access
19
+ and manipulation of a hasMany relationship.
20
+
21
+ It is especially useful when you're dealing with `async` relationships
22
+ from `@ember-data/model` as it allows synchronous access to
23
+ the relationship data if loaded, as well as APIs for loading, reloading
24
+ the data or accessing available information without triggering a load.
25
+
26
+ It may also be useful when using `sync` relationships with `@ember-data/model`
27
+ that need to be loaded/reloaded with more precise timing than marking the
28
+ relationship as `async` and relying on autofetch would have allowed.
29
+
30
+ However,keep in mind that marking a relationship as `async: false` will introduce
31
+ bugs into your application if the data is not always guaranteed to be available
32
+ by the time the relationship is accessed. Ergo, it is recommended when using this
33
+ approach to utilize `links` for unloaded relationship state instead of identifiers.
34
+
35
+ Reference APIs are entangled with the relationship's underlying state,
36
+ thus any getters or cached properties that utilize these will properly
37
+ invalidate if the relationship state changes.
38
+
39
+ References are "stable", meaning that multiple calls to retrieve the reference
40
+ for a given relationship will always return the same HasManyReference.
41
+
42
+ @class HasManyReference
43
+ @public
44
+ */
45
+ export default class HasManyReference<T = unknown, K extends string = IsUnknown<T> extends true ? string : MaybeHasManyFields<T>, Related = K extends keyof T ? ArrayItemType<Awaited<T[K]>> : unknown> {
46
+ graph: Graph;
47
+ store: Store;
48
+ hasManyRelationship: CollectionEdge;
49
+ /**
50
+ * The field name on the parent record for this has-many relationship.
51
+ *
52
+ * @property key
53
+ * @type {String}
54
+ * @public
55
+ */
56
+ key: K;
57
+ /**
58
+ * The type of resource this relationship will contain.
59
+ *
60
+ * @property type
61
+ * @type {String}
62
+ * @public
63
+ */
64
+ type: TypeFromInstanceOrString<Related>;
65
+ ___token: object;
66
+ ___identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>;
67
+ ___relatedTokenMap: Map<StableRecordIdentifier, object>;
68
+ _ref: number;
69
+ constructor(store: Store, graph: Graph, parentIdentifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
70
+ /**
71
+ * This method should never be called by user code.
72
+ *
73
+ * @internal
74
+ */
75
+ destroy(): void;
76
+ /**
77
+ * An array of identifiers for the records that this reference refers to.
78
+ *
79
+ * @property identifiers
80
+ * @type {StableRecordIdentifier[]}
81
+ * @public
82
+ */
83
+ get identifiers(): StableRecordIdentifier<TypeFromInstanceOrString<Related>>[];
84
+ _resource(): CollectionResourceRelationship;
85
+ /**
86
+ This returns a string that represents how the reference will be
87
+ looked up when it is loaded. If the relationship has a link it will
88
+ use the "link" otherwise it defaults to "id".
89
+
90
+ Example
91
+
92
+ ```js [app/models/post.js]
93
+ import { Model, hasMany } from '@warp-drive/legacy/model';
94
+
95
+ export default class PostModel extends Model {
96
+ @hasMany('comment', { async: true, inverse: null }) comments;
97
+ }
98
+ ```
99
+
100
+ ```javascript
101
+ let post = store.push({
102
+ data: {
103
+ type: 'post',
104
+ id: 1,
105
+ relationships: {
106
+ comments: {
107
+ data: [{ type: 'comment', id: 1 }]
108
+ }
109
+ }
110
+ }
111
+ });
112
+
113
+ let commentsRef = post.hasMany('comments');
114
+
115
+ // get the identifier of the reference
116
+ if (commentsRef.remoteType() === "ids") {
117
+ let ids = commentsRef.ids();
118
+ } else if (commentsRef.remoteType() === "link") {
119
+ let link = commentsRef.link();
120
+ }
121
+ ```
122
+
123
+ @public
124
+ @return {String} The name of the remote type. This should either be `link` or `ids`
125
+ */
126
+ remoteType(): 'link' | 'ids';
127
+ /**
128
+ `ids()` returns an array of the record IDs in this relationship.
129
+
130
+ Example
131
+
132
+ ```js [app/models/post.js]
133
+ import { Model, hasMany } from '@warp-drive/legacy/model';
134
+
135
+ export default class PostModel extends Model {
136
+ @hasMany('comment', { async: true, inverse: null }) comments;
137
+ }
138
+ ```
139
+
140
+ ```javascript
141
+ let post = store.push({
142
+ data: {
143
+ type: 'post',
144
+ id: 1,
145
+ relationships: {
146
+ comments: {
147
+ data: [{ type: 'comment', id: 1 }]
148
+ }
149
+ }
150
+ }
151
+ });
152
+
153
+ let commentsRef = post.hasMany('comments');
154
+
155
+ commentsRef.ids(); // ['1']
156
+ ```
157
+
158
+ @public
159
+ @return {Array} The ids in this has-many relationship
160
+ */
161
+ ids(): Array<string | null>;
162
+ /**
163
+ The link Ember Data will use to fetch or reload this belongs-to
164
+ relationship. By default it uses only the "related" resource linkage.
165
+
166
+ Example
167
+
168
+ ```javascript
169
+ // models/blog.js
170
+ import { Model, belongsTo } from '@warp-drive/legacy/model';
171
+ export default Model.extend({
172
+ user: belongsTo('user', { async: true, inverse: null })
173
+ });
174
+
175
+ let blog = store.push({
176
+ data: {
177
+ type: 'blog',
178
+ id: 1,
179
+ relationships: {
180
+ user: {
181
+ links: {
182
+ related: '/articles/1/author'
183
+ }
184
+ }
185
+ }
186
+ }
187
+ });
188
+ let userRef = blog.belongsTo('user');
189
+
190
+ // get the identifier of the reference
191
+ if (userRef.remoteType() === "link") {
192
+ let link = userRef.link();
193
+ }
194
+ ```
195
+
196
+ @public
197
+ @return {String} The link Ember Data will use to fetch or reload this belongs-to relationship.
198
+ */
199
+ link(): string | null;
200
+ /**
201
+ * any links that have been received for this relationship
202
+ *
203
+ * @public
204
+ * @return
205
+ */
206
+ links(): PaginationLinks | null;
207
+ /**
208
+ The meta data for the has-many relationship.
209
+
210
+ Example
211
+
212
+ ```javascript
213
+ // models/blog.js
214
+ import { Model, hasMany } from '@warp-drive/legacy/model';
215
+ export default Model.extend({
216
+ users: hasMany('user', { async: true, inverse: null })
217
+ });
218
+
219
+ let blog = store.push({
220
+ data: {
221
+ type: 'blog',
222
+ id: 1,
223
+ relationships: {
224
+ users: {
225
+ links: {
226
+ related: {
227
+ href: '/articles/1/authors'
228
+ },
229
+ },
230
+ meta: {
231
+ lastUpdated: 1458014400000
232
+ }
233
+ }
234
+ }
235
+ }
236
+ });
237
+
238
+ let usersRef = blog.hasMany('user');
239
+
240
+ usersRef.meta() // { lastUpdated: 1458014400000 }
241
+ ```
242
+
243
+ @public
244
+ @return {Object|null} The meta information for the belongs-to relationship.
245
+ */
246
+ meta(): Meta | null;
247
+ /**
248
+ `push` can be used to update the data in the relationship and EmberData
249
+ will treat the new data as the canonical value of this relationship on
250
+ the backend. An empty array will signify the canonical value should be
251
+ empty.
252
+
253
+ Example model
254
+
255
+ ```js [app/models/post.js]
256
+ import { Model, hasMany } from '@warp-drive/legacy/model';
257
+
258
+ export default class PostModel extends Model {
259
+ @hasMany('comment', { async: true, inverse: null }) comments;
260
+ }
261
+ ```
262
+
263
+ Setup some initial state, note we haven't loaded the comments yet:
264
+
265
+ ```js
266
+ const post = store.push({
267
+ data: {
268
+ type: 'post',
269
+ id: '1',
270
+ relationships: {
271
+ comments: {
272
+ data: [{ type: 'comment', id: '1' }]
273
+ }
274
+ }
275
+ }
276
+ });
277
+
278
+ const commentsRef = post.hasMany('comments');
279
+ commentsRef.ids(); // ['1']
280
+ ```
281
+
282
+ Update the state using `push`, note we can do this even without
283
+ having loaded these comments yet by providing resource identifiers.
284
+
285
+ Both full resources and resource identifiers are supported.
286
+
287
+ ```js
288
+ await commentsRef.push({
289
+ data: [
290
+ { type: 'comment', id: '2' },
291
+ { type: 'comment', id: '3' },
292
+ ]
293
+ });
294
+
295
+ commentsRef.ids(); // ['2', '3']
296
+ ```
297
+
298
+ For convenience, you can also pass in an array of resources or resource identifiers
299
+ without wrapping them in the `data` property:
300
+
301
+ ```js
302
+ await commentsRef.push([
303
+ { type: 'comment', id: '4' },
304
+ { type: 'comment', id: '5' },
305
+ ]);
306
+
307
+ commentsRef.ids(); // ['4', '5']
308
+ ```
309
+
310
+ When using the `data` property, you may also include other resource data via included,
311
+ as well as provide new links and meta to the relationship.
312
+
313
+ ```js
314
+ await commentsRef.push({
315
+ links: {
316
+ related: '/posts/1/comments'
317
+ },
318
+ meta: {
319
+ total: 2
320
+ },
321
+ data: [
322
+ { type: 'comment', id: '4' },
323
+ { type: 'comment', id: '5' },
324
+ ],
325
+ included: [
326
+ { type: 'other-thing', id: '1', attributes: { foo: 'bar' },
327
+ ]
328
+ });
329
+ ```
330
+
331
+ By default, the store will attempt to fetch any unloaded records before resolving
332
+ the returned promise with the ManyArray.
333
+
334
+ Alternatively, pass `true` as the second argument to avoid fetching unloaded records
335
+ and instead the promise will resolve with void without attempting to fetch. This is
336
+ particularly useful if you want to update the state of the relationship without
337
+ forcing the load of all of the associated records.
338
+
339
+ @public
340
+ @param {Array|Object} doc a JSONAPI document object describing the new value of this relationship.
341
+ @param {Boolean} [skipFetch] if `true`, do not attempt to fetch unloaded records
342
+ @return {Promise<ManyArray | void>}
343
+ */
344
+ push(doc: ExistingResourceObject[] | CollectionResourceDocument, skipFetch?: boolean): Promise<ManyArray<Related> | void>;
345
+ _isLoaded(): boolean | undefined;
346
+ /**
347
+ `value()` synchronously returns the current value of the has-many
348
+ relationship. Unlike `record.relationshipName`, calling
349
+ `value()` on a reference does not trigger a fetch if the async
350
+ relationship is not yet loaded. If the relationship is not loaded
351
+ it will always return `null`.
352
+
353
+ Example
354
+
355
+ ```js [app/models/post.js]
356
+ import { Model, hasMany } from '@warp-drive/legacy/model';
357
+
358
+ export default class PostModel extends Model {
359
+ @hasMany('comment', { async: true, inverse: null }) comments;
360
+ }
361
+ ```
362
+
363
+ ```javascript
364
+ let post = store.push({
365
+ data: {
366
+ type: 'post',
367
+ id: 1,
368
+ relationships: {
369
+ comments: {
370
+ data: [{ type: 'comment', id: 1 }]
371
+ }
372
+ }
373
+ }
374
+ });
375
+
376
+ let commentsRef = post.hasMany('comments');
377
+
378
+ post.comments.then(function(comments) {
379
+ commentsRef.value() === comments
380
+ })
381
+ ```
382
+
383
+ @public
384
+ @return {ManyArray}
385
+ */
386
+ value(): ManyArray<Related> | null;
387
+ /**
388
+ Loads the relationship if it is not already loaded. If the
389
+ relationship is already loaded this method does not trigger a new
390
+ load. This causes a request to the specified
391
+ relationship link or reloads all items currently in the relationship.
392
+
393
+ Example
394
+
395
+ ```js [app/models/post.js]
396
+ import { Model, hasMany } from '@warp-drive/legacy/model';
397
+
398
+ export default class PostModel extends Model {
399
+ @hasMany('comment', { async: true, inverse: null }) comments;
400
+ }
401
+ ```
402
+
403
+ ```javascript
404
+ let post = store.push({
405
+ data: {
406
+ type: 'post',
407
+ id: 1,
408
+ relationships: {
409
+ comments: {
410
+ data: [{ type: 'comment', id: 1 }]
411
+ }
412
+ }
413
+ }
414
+ });
415
+
416
+ let commentsRef = post.hasMany('comments');
417
+
418
+ commentsRef.load().then(function(comments) {
419
+ //...
420
+ });
421
+ ```
422
+
423
+ You may also pass in an options object whose properties will be
424
+ fed forward. This enables you to pass `adapterOptions` into the
425
+ request given to the adapter via the reference.
426
+
427
+ Example
428
+
429
+ ```javascript
430
+ commentsRef.load({ adapterOptions: { isPrivate: true } })
431
+ .then(function(comments) {
432
+ //...
433
+ });
434
+ ```
435
+
436
+ ```js [app/adapters/comment.js]
437
+ export default ApplicationAdapter.extend({
438
+ findMany(store, type, id, snapshots) {
439
+ // In the adapter you will have access to adapterOptions.
440
+ let adapterOptions = snapshots[0].adapterOptions;
441
+ }
442
+ });
443
+ ```
444
+
445
+ @public
446
+ @param {Object} options the options to pass in.
447
+ @return {Promise} a promise that resolves with the ManyArray in
448
+ this has-many relationship.
449
+ */
450
+ load(options?: BaseFinderOptions): Promise<ManyArray<Related>>;
451
+ /**
452
+ Reloads this has-many relationship. This causes a request to the specified
453
+ relationship link or reloads all items currently in the relationship.
454
+
455
+ Example
456
+
457
+ ```js [app/models/post.js]
458
+ import { Model, hasMany } from '@warp-drive/legacy/model';
459
+
460
+ export default class PostModel extends Model {
461
+ @hasMany('comment', { async: true, inverse: null }) comments;
462
+ }
463
+ ```
464
+
465
+ ```javascript
466
+ let post = store.push({
467
+ data: {
468
+ type: 'post',
469
+ id: 1,
470
+ relationships: {
471
+ comments: {
472
+ data: [{ type: 'comment', id: 1 }]
473
+ }
474
+ }
475
+ }
476
+ });
477
+
478
+ let commentsRef = post.hasMany('comments');
479
+
480
+ commentsRef.reload().then(function(comments) {
481
+ //...
482
+ });
483
+ ```
484
+
485
+ You may also pass in an options object whose properties will be
486
+ fed forward. This enables you to pass `adapterOptions` into the
487
+ request given to the adapter via the reference. A full example
488
+ can be found in the `load` method.
489
+
490
+ Example
491
+
492
+ ```javascript
493
+ commentsRef.reload({ adapterOptions: { isPrivate: true } })
494
+ ```
495
+
496
+ @public
497
+ @param {Object} options the options to pass in.
498
+ @return {Promise} a promise that resolves with the ManyArray in this has-many relationship.
499
+ */
500
+ reload(options?: BaseFinderOptions): Promise<ManyArray<Related>>;
501
+ }
502
+ export declare function isMaybeResource(object: ExistingResourceObject | ResourceIdentifier): object is ExistingResourceObject;
503
+ export {};
504
+ //# sourceMappingURL=has-many.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-many.d.ts","sourceRoot":"","sources":["../../../../src/model/-private/references/has-many.ts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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgGE;IACI,IAAI,CACR,GAAG,EAAE,sBAAsB,EAAE,GAAG,0BAA0B,EAC1D,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAiDrC,SAAS;IAaT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,KAAK,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI;IAclC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAapE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CAMjE;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,sBAAsB,GAAG,kBAAkB,GAAG,MAAM,IAAI,sBAAsB,CAGrH"}
@@ -0,0 +1,63 @@
1
+ import type { Store } from '@warp-drive/core';
2
+ import type { SchemaService } from '@warp-drive/core/types';
3
+ import type { RecordIdentifier, StableRecordIdentifier } from '@warp-drive/core/types/identifier';
4
+ import type { ObjectValue } from '@warp-drive/core/types/json/raw';
5
+ import type { Derivation, HashFn, Transformation } from '@warp-drive/core/types/schema/concepts';
6
+ import type { ArrayField, DerivedField, GenericField, HashField, LegacyAttributeField, LegacyField, LegacyRelationshipField, ObjectField, ObjectSchema, ResourceSchema } from '@warp-drive/core/types/schema/fields';
7
+ import type { ModelFactory, ModelStore } from './model.ts';
8
+ type AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;
9
+ type RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;
10
+ type InternalSchema = {
11
+ schema: ResourceSchema;
12
+ fields: Map<string, LegacyAttributeField | LegacyRelationshipField>;
13
+ attributes: Record<string, LegacyAttributeField>;
14
+ relationships: Record<string, LegacyRelationshipField>;
15
+ };
16
+ export interface ModelSchemaProvider {
17
+ attributesDefinitionFor(resource: RecordIdentifier | {
18
+ type: string;
19
+ }): AttributesSchema;
20
+ relationshipsDefinitionFor(resource: RecordIdentifier | {
21
+ type: string;
22
+ }): RelationshipsSchema;
23
+ doesTypeExist(type: string): boolean;
24
+ }
25
+ export declare class ModelSchemaProvider implements SchemaService {
26
+ store: ModelStore;
27
+ _schemas: Map<string, InternalSchema>;
28
+ _typeMisses: Set<string>;
29
+ constructor(store: ModelStore);
30
+ resourceTypes(): Readonly<string[]>;
31
+ hasTrait(type: string): boolean;
32
+ resourceHasTrait(resource: StableRecordIdentifier | {
33
+ type: string;
34
+ }, trait: string): boolean;
35
+ transformation(field: GenericField | ObjectField | ArrayField | {
36
+ type: string;
37
+ }): Transformation;
38
+ derivation(field: DerivedField | {
39
+ type: string;
40
+ }): Derivation;
41
+ hashFn(field: HashField | {
42
+ type: string;
43
+ }): HashFn;
44
+ resource(resource: StableRecordIdentifier | {
45
+ type: string;
46
+ }): ResourceSchema | ObjectSchema;
47
+ registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
48
+ registerResource(schema: ResourceSchema | ObjectSchema): void;
49
+ registerTransformation(transform: Transformation): void;
50
+ registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void;
51
+ registerHashFn(hashFn: HashFn): void;
52
+ _loadModelSchema(type: string): InternalSchema;
53
+ fields(resource: RecordIdentifier | {
54
+ type: string;
55
+ }): Map<string, LegacyField>;
56
+ hasResource(resource: {
57
+ type: string;
58
+ }): boolean;
59
+ }
60
+ export declare function buildSchema(store: Store): SchemaService;
61
+ export declare function getModelFactory(store: ModelStore, type: string): ModelFactory | null;
62
+ export {};
63
+ //# sourceMappingURL=schema-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-provider.d.ts","sourceRoot":"","sources":["../../../src/model/-private/schema-provider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAClG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACjG,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,cAAc,EACf,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAAuB,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIhF,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AACjG,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,4BAA4B,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AAEvG,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,GAAG,uBAAuB,CAAC,CAAC;IACpE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,uBAAu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IAG7D,sBAAsB,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAGvD,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,WAAW,GAAG,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI;IAG/F,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAGpC,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAoC7B,MAAM,CAAC,QAAQ,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAU/E,WAAW,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;CAqBjD;AA2DD,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAEvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAkCpF"}
@@ -0,0 +1,57 @@
1
+ import type { RelatedCollection } from '@warp-drive/core/store/-private';
2
+ import type { TypedRecordInstance } from '@warp-drive/core/types/record';
3
+ import type { Type } from '@warp-drive/core/types/symbols';
4
+ import type { Model } from './model.ts';
5
+ import type { PromiseBelongsTo } from './promise-belongs-to.ts';
6
+ import type { PromiseManyArray } from './promise-many-array.ts';
7
+ type ExcludeNull<T> = Exclude<T, null> extends never ? T : Exclude<T, null>;
8
+ type GetMappedKey<M, V> = {
9
+ [K in keyof M]-?: ExcludeNull<M[K]> extends V ? K : never;
10
+ }[keyof M] & string;
11
+ /**
12
+ * Get the keys of fields that are maybe defined as `belongsTo` relationships
13
+ *
14
+ * "Maybe" because getter/computed fields might be returning values that look
15
+ * like relationships, but are not.
16
+ *
17
+ */
18
+ export type MaybeBelongsToFields<ThisType> = _TrueKeys<ThisType> extends never ? string : _MaybeBelongsToFields<ThisType>;
19
+ export type _MaybeBelongsToFields<ThisType> = GetMappedKey<ThisType, PromiseBelongsTo | TypedRecordInstance>;
20
+ /**
21
+ * Get the keys of fields that are maybe defined as `hasMany` relationships
22
+ *
23
+ * "Maybe" because getter/computed fields might be returning values that look
24
+ * like relationships, but are not.
25
+ *
26
+ */
27
+ export type MaybeHasManyFields<ThisType> = _TrueKeys<ThisType> extends never ? string : _MaybeHasManyFields<ThisType>;
28
+ type _MaybeHasManyFields<ThisType> = GetMappedKey<ThisType, RelatedCollection | PromiseManyArray>;
29
+ /**
30
+ * Get the keys of fields that are maybe defined as `attr` fields
31
+ *
32
+ * "Maybe" because getter/computed fields might be returning values that look
33
+ * like attributes, but are not.
34
+ *
35
+ * This is computed by excluding the keys that are defined as `belongsTo` or `hasMany`
36
+ * as well as the keys on EmberObject and the Model base class
37
+ *
38
+ */
39
+ export type MaybeAttrFields<ThisType> = Exclude<_TrueKeys<ThisType>, _MaybeBelongsToFields<ThisType> | _MaybeHasManyFields<ThisType>>;
40
+ /**
41
+ * Get the keys of fields that are maybe defined as relationships
42
+ *
43
+ * "Maybe" because getter/computed fields might be returning values that look
44
+ * like relationships, but are not.
45
+ *
46
+ */
47
+ export type MaybeRelationshipFields<ThisType> = _TrueKeys<ThisType> extends never ? string : _MaybeBelongsToFields<ThisType> | _MaybeHasManyFields<ThisType>;
48
+ type _TrueKeys<ThisType> = Exclude<keyof ThisType & string, (keyof Model & string) | typeof Type>;
49
+ export type isSubClass<ThisType> = _TrueKeys<ThisType> extends never ? false : true;
50
+ /**
51
+ * Get the keys of all fields defined on the given subclass of Model
52
+ * that don't exist on EmberObject or Model.
53
+ *
54
+ */
55
+ export type SubclassKeys<ThisType> = _TrueKeys<ThisType> extends never ? string : _TrueKeys<ThisType>;
56
+ export {};
57
+ //# sourceMappingURL=type-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../src/model/-private/type-utils.ts"],"names":[],"m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C;AAElG;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,CAAC,QAAQ,IAAI,OAAO,CAC7C,SAAS,CAAC,QAAQ,CAAC,EACnB,qBAAqB,CAAC,QAAQ,CAAC,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,CAAC,QAAQ,IAC1C,SAAS,CAAC,QAAQ,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,qBAAqB,CAAC,QAAQ,CAAC,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAE/G,KAAK,SAAS,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;AAClG,MAAM,MAAM,UAAU,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AACpF;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type DecoratorPropertyDescriptor = (PropertyDescriptor & {
2
+ initializer?: () => unknown;
3
+ }) | undefined;
4
+ export declare function isElementDescriptor(args: unknown[]): args is [object, string, DecoratorPropertyDescriptor];
5
+ export declare function normalizeModelName(type: string): string;
6
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/model/-private/util.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,2BAA2B,GAAG,CAAC,kBAAkB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC,GAAG,SAAS,CAAC;AAE7G,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAkB1G;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAsBvD"}
@@ -0,0 +1,8 @@
1
+ export { type MinimalLegacyRecord } from './-private/model-methods.ts';
2
+ export type { ModelStore } from './-private/model.ts';
3
+ export { Errors } from './-private/errors.ts';
4
+ export { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';
5
+ export { PromiseBelongsTo } from './-private/promise-belongs-to.ts';
6
+ export { PromiseManyArray } from './-private/promise-many-array.ts';
7
+ export { lookupLegacySupport, LEGACY_SUPPORT } from './-private/legacy-relationships-support.ts';
8
+ //# sourceMappingURL=-private.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"-private.d.ts","sourceRoot":"","sources":["../../src/model/-private.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC"}