@warp-drive/legacy 5.6.0-alpha.14 → 5.6.0-alpha.17

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 (191) hide show
  1. package/declarations/adapter/-private/build-url-mixin.d.ts +41 -29
  2. package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
  3. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
  4. package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
  5. package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
  6. package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
  7. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
  8. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
  9. package/declarations/adapter/-private.d.ts +5 -6
  10. package/declarations/adapter/error.d.ts +206 -178
  11. package/declarations/adapter/json-api.d.ts +206 -207
  12. package/declarations/adapter/rest.d.ts +805 -808
  13. package/declarations/adapter.d.ts +742 -766
  14. package/declarations/compat/-private.d.ts +10 -11
  15. package/declarations/compat/builders/find-all.d.ts +26 -24
  16. package/declarations/compat/builders/find-record.d.ts +41 -39
  17. package/declarations/compat/builders/query.d.ts +50 -45
  18. package/declarations/compat/builders/save-record.d.ts +26 -24
  19. package/declarations/compat/builders/utils.d.ts +1 -2
  20. package/declarations/compat/builders.d.ts +10 -11
  21. package/declarations/compat/extensions.d.ts +59 -0
  22. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
  23. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
  24. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
  25. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
  26. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
  27. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
  28. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
  29. package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
  30. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
  31. package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
  32. package/declarations/compat/utils.d.ts +118 -119
  33. package/declarations/compat.d.ts +106 -104
  34. package/declarations/model/-private/attr.d.ts +164 -145
  35. package/declarations/model/-private/belongs-to.d.ts +135 -122
  36. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
  37. package/declarations/model/-private/errors.d.ts +272 -267
  38. package/declarations/model/-private/has-many.d.ts +119 -116
  39. package/declarations/model/-private/hooks.d.ts +5 -6
  40. package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
  41. package/declarations/model/-private/model-for-mixin.d.ts +18 -3
  42. package/declarations/model/-private/model-methods.d.ts +29 -24
  43. package/declarations/model/-private/model.d.ts +1306 -1254
  44. package/declarations/model/-private/notify-changes.d.ts +3 -4
  45. package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
  46. package/declarations/model/-private/promise-many-array.d.ts +125 -116
  47. package/declarations/model/-private/record-state.d.ts +63 -60
  48. package/declarations/model/-private/references/belongs-to.d.ts +491 -487
  49. package/declarations/model/-private/references/has-many.d.ts +495 -492
  50. package/declarations/model/-private/schema-provider.d.ts +53 -56
  51. package/declarations/model/-private/type-utils.d.ts +41 -41
  52. package/declarations/model/-private/util.d.ts +1 -2
  53. package/declarations/model/-private.d.ts +8 -8
  54. package/declarations/model/migration-support.d.ts +281 -271
  55. package/declarations/model.d.ts +48 -49
  56. package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
  57. package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
  58. package/declarations/serializer/-private/transforms/date.d.ts +22 -22
  59. package/declarations/serializer/-private/transforms/number.d.ts +22 -22
  60. package/declarations/serializer/-private/transforms/string.d.ts +22 -22
  61. package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
  62. package/declarations/serializer/-private/utils.d.ts +0 -1
  63. package/declarations/serializer/json-api.d.ts +124 -494
  64. package/declarations/serializer/json.d.ts +62 -1031
  65. package/declarations/serializer/rest.d.ts +52 -552
  66. package/declarations/serializer/transform.d.ts +5 -6
  67. package/declarations/serializer.d.ts +217 -218
  68. package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
  69. package/dist/adapter/-private.js +1 -1
  70. package/dist/adapter/error.js +17 -0
  71. package/dist/adapter/json-api.js +1 -1
  72. package/dist/adapter/rest.js +5 -7
  73. package/dist/adapter.js +6 -35
  74. package/dist/compat/-private.js +1 -1
  75. package/dist/compat/extensions.js +243 -0
  76. package/dist/compat.js +3 -4
  77. package/dist/{errors-D74uk36r.js → errors-BX5wowuz.js} +12 -10
  78. package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
  79. package/dist/model/-private.js +1 -1
  80. package/dist/model/migration-support.js +15 -4
  81. package/dist/model.js +3 -3
  82. package/dist/{schema-provider-CXFLTMjg.js → schema-provider-BdQhkT-Q.js} +20 -13
  83. package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
  84. package/dist/serializer/json-api.js +42 -2
  85. package/dist/serializer/json.js +1 -1
  86. package/dist/serializer/rest.js +46 -41
  87. package/dist/serializer/transform.js +0 -44
  88. package/package.json +7 -7
  89. package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
  90. package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
  91. package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
  92. package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
  93. package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
  94. package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
  95. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
  96. package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
  97. package/declarations/adapter/-private.d.ts.map +0 -1
  98. package/declarations/adapter/error.d.ts.map +0 -1
  99. package/declarations/adapter/json-api.d.ts.map +0 -1
  100. package/declarations/adapter/rest.d.ts.map +0 -1
  101. package/declarations/adapter.d.ts.map +0 -1
  102. package/declarations/compat/-private.d.ts.map +0 -1
  103. package/declarations/compat/builders/find-all.d.ts.map +0 -1
  104. package/declarations/compat/builders/find-record.d.ts.map +0 -1
  105. package/declarations/compat/builders/query.d.ts.map +0 -1
  106. package/declarations/compat/builders/save-record.d.ts.map +0 -1
  107. package/declarations/compat/builders/utils.d.ts.map +0 -1
  108. package/declarations/compat/builders.d.ts.map +0 -1
  109. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
  110. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
  111. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
  112. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
  113. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
  114. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
  115. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
  116. package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
  117. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
  118. package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
  119. package/declarations/compat/utils.d.ts.map +0 -1
  120. package/declarations/compat.d.ts.map +0 -1
  121. package/declarations/model/-private/attr.d.ts.map +0 -1
  122. package/declarations/model/-private/attr.type-test.d.ts +0 -2
  123. package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
  124. package/declarations/model/-private/belongs-to.d.ts.map +0 -1
  125. package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
  126. package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
  127. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
  128. package/declarations/model/-private/errors.d.ts.map +0 -1
  129. package/declarations/model/-private/has-many.d.ts.map +0 -1
  130. package/declarations/model/-private/has-many.type-test.d.ts +0 -2
  131. package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
  132. package/declarations/model/-private/hooks.d.ts.map +0 -1
  133. package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
  134. package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
  135. package/declarations/model/-private/model-methods.d.ts.map +0 -1
  136. package/declarations/model/-private/model.d.ts.map +0 -1
  137. package/declarations/model/-private/model.type-test.d.ts +0 -2
  138. package/declarations/model/-private/model.type-test.d.ts.map +0 -1
  139. package/declarations/model/-private/notify-changes.d.ts.map +0 -1
  140. package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
  141. package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
  142. package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
  143. package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
  144. package/declarations/model/-private/record-state.d.ts.map +0 -1
  145. package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
  146. package/declarations/model/-private/references/has-many.d.ts.map +0 -1
  147. package/declarations/model/-private/schema-provider.d.ts.map +0 -1
  148. package/declarations/model/-private/type-utils.d.ts.map +0 -1
  149. package/declarations/model/-private/util.d.ts.map +0 -1
  150. package/declarations/model/-private.d.ts.map +0 -1
  151. package/declarations/model/migration-support.d.ts.map +0 -1
  152. package/declarations/model/migration-support.type-test.d.ts +0 -2
  153. package/declarations/model/migration-support.type-test.d.ts.map +0 -1
  154. package/declarations/model.d.ts.map +0 -1
  155. package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
  156. package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
  157. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
  158. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
  159. package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
  160. package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
  161. package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
  162. package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
  163. package/declarations/serializer/-private/utils.d.ts.map +0 -1
  164. package/declarations/serializer/json-api.d.ts.map +0 -1
  165. package/declarations/serializer/json.d.ts.map +0 -1
  166. package/declarations/serializer/rest.d.ts.map +0 -1
  167. package/declarations/serializer/transform.d.ts.map +0 -1
  168. package/declarations/serializer.d.ts.map +0 -1
  169. package/dist/-private-DFfBszo5.js.map +0 -1
  170. package/dist/adapter/-private.js.map +0 -1
  171. package/dist/adapter/error.js.map +0 -1
  172. package/dist/adapter/json-api.js.map +0 -1
  173. package/dist/adapter/rest.js.map +0 -1
  174. package/dist/adapter.js.map +0 -1
  175. package/dist/compat/-private.js.map +0 -1
  176. package/dist/compat/builders.js.map +0 -1
  177. package/dist/compat/utils.js.map +0 -1
  178. package/dist/compat.js.map +0 -1
  179. package/dist/errors-D74uk36r.js.map +0 -1
  180. package/dist/json-DSOlH9A8.js.map +0 -1
  181. package/dist/model/-private.js.map +0 -1
  182. package/dist/model/migration-support.js.map +0 -1
  183. package/dist/model.js.map +0 -1
  184. package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
  185. package/dist/schema-provider-CXFLTMjg.js.map +0 -1
  186. package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
  187. package/dist/serializer/json-api.js.map +0 -1
  188. package/dist/serializer/json.js.map +0 -1
  189. package/dist/serializer/rest.js.map +0 -1
  190. package/dist/serializer/transform.js.map +0 -1
  191. package/dist/serializer.js.map +0 -1
@@ -1,164 +1,167 @@
1
- import type { TypeFromInstance } from '@warp-drive/core/types/record';
2
- import type { NoNull, RelationshipDecorator, RelationshipOptions } from './belongs-to.ts';
1
+ import type { TypeFromInstance } from "@warp-drive/core/types/record";
2
+ import type { NoNull, RelationshipDecorator, RelationshipOptions } from "./belongs-to.js";
3
3
  /**
4
- `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
5
- relationships on a [Model](/ember-data/release/classes/Model).
4
+ `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
5
+ relationships on a [Model](/ember-data/release/classes/Model).
6
6
 
7
- `hasMany` takes a configuration hash as a second parameter, currently
8
- supported options are:
7
+ `hasMany` takes a configuration hash as a second parameter, currently
8
+ supported options are:
9
9
 
10
- - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.
11
- - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.
12
- - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic
13
- - `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism.
10
+ - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.
11
+ - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.
12
+ - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic
13
+ - `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism.
14
14
 
15
- ### Examples
15
+ ### Examples
16
16
 
17
- To declare a **many-to-one** (or one-to-many) relationship, use
18
- `belongsTo` in combination with `hasMany`:
17
+ To declare a **many-to-one** (or one-to-many) relationship, use
18
+ `belongsTo` in combination with `hasMany`:
19
19
 
20
- ```js
21
- // app/models/post.js
22
- import { Model, hasMany } from '@warp-drive/legacy/model';
20
+ ```js
21
+ // app/models/post.js
22
+ import { Model, hasMany } from '@warp-drive/legacy/model';
23
23
 
24
- export default class Post extends Model {
25
- @hasMany('comment', { async: false, inverse: 'post' }) comments;
26
- }
24
+ export default class Post extends Model {
25
+ @hasMany('comment', { async: false, inverse: 'post' }) comments;
26
+ }
27
27
 
28
28
 
29
- // app/models/comment.js
30
- import { Model, belongsTo } from '@warp-drive/legacy/model';
29
+ // app/models/comment.js
30
+ import { Model, belongsTo } from '@warp-drive/legacy/model';
31
31
 
32
- export default class Comment extends Model {
33
- @belongsTo('post', { async: false, inverse: 'comments' }) post;
34
- }
35
- ```
32
+ export default class Comment extends Model {
33
+ @belongsTo('post', { async: false, inverse: 'comments' }) post;
34
+ }
35
+ ```
36
36
 
37
- To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:
37
+ To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:
38
38
 
39
- ```js
40
- // app/models/post.js
41
- import { Model, hasMany } from '@warp-drive/legacy/model';
39
+ ```js
40
+ // app/models/post.js
41
+ import { Model, hasMany } from '@warp-drive/legacy/model';
42
42
 
43
- export default class Post extends Model {
44
- @hasMany('tag', { async: true, inverse: 'posts' }) tags;
45
- }
43
+ export default class Post extends Model {
44
+ @hasMany('tag', { async: true, inverse: 'posts' }) tags;
45
+ }
46
46
 
47
- // app/models/tag.js
48
- import { Model, hasMany } from '@warp-drive/legacy/model';
47
+ // app/models/tag.js
48
+ import { Model, hasMany } from '@warp-drive/legacy/model';
49
49
 
50
- export default class Tag extends Model {
51
- @hasMany('post', { async: true, inverse: 'tags' }) posts;
52
- }
53
- ```
50
+ export default class Tag extends Model {
51
+ @hasMany('post', { async: true, inverse: 'tags' }) posts;
52
+ }
53
+ ```
54
54
 
55
- To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides
56
- with `null` as the inverse:
55
+ To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides
56
+ with `null` as the inverse:
57
57
 
58
- ```js
59
- // app/models/post.js
60
- import { Model, hasMany } from '@warp-drive/legacy/model';
58
+ ```js
59
+ // app/models/post.js
60
+ import { Model, hasMany } from '@warp-drive/legacy/model';
61
61
 
62
- export default class Post extends Model {
63
- @hasMany('tag', { async: true, inverse: null }) tags;
64
- }
62
+ export default class Post extends Model {
63
+ @hasMany('tag', { async: true, inverse: null }) tags;
64
+ }
65
65
 
66
- // app/models/tag.js
67
- import { Model, hasMany } from '@warp-drive/legacy/model';
66
+ // app/models/tag.js
67
+ import { Model, hasMany } from '@warp-drive/legacy/model';
68
68
 
69
- export default class Tag extends Model {
70
- @hasMany('post', { async: true, inverse: null }) posts;
71
- }
72
- ```
69
+ export default class Tag extends Model {
70
+ @hasMany('post', { async: true, inverse: null }) posts;
71
+ }
72
+ ```
73
73
 
74
- To declare a many-to-none relationship between two models, use
75
- `hasMany` with inverse set to `null` on just one side::
74
+ To declare a many-to-none relationship between two models, use
75
+ `hasMany` with inverse set to `null` on just one side::
76
76
 
77
- ```js
78
- // app/models/post.js
79
- import { Model, hasMany } from '@warp-drive/legacy/model';
77
+ ```js
78
+ // app/models/post.js
79
+ import { Model, hasMany } from '@warp-drive/legacy/model';
80
80
 
81
- export default class Post extends Model {
82
- @hasMany('category', { async: true, inverse: null }) categories;
83
- }
84
- ```
81
+ export default class Post extends Model {
82
+ @hasMany('category', { async: true, inverse: null }) categories;
83
+ }
84
+ ```
85
85
 
86
- #### Sync vs Async Relationships
86
+ #### Sync vs Async Relationships
87
87
 
88
- EmberData fulfills relationships using resource data available in
89
- the cache.
88
+ EmberData fulfills relationships using resource data available in
89
+ the cache.
90
90
 
91
- Sync relationships point directly to the known related resources.
91
+ Sync relationships point directly to the known related resources.
92
92
 
93
- When a relationship is declared as async, if any of the known related
94
- resources have not been loaded, they will be fetched. The property
95
- on the record when accessed provides a promise that resolves once
96
- all resources are loaded.
93
+ When a relationship is declared as async, if any of the known related
94
+ resources have not been loaded, they will be fetched. The property
95
+ on the record when accessed provides a promise that resolves once
96
+ all resources are loaded.
97
97
 
98
- Async relationships may take advantage of links. On access, if the related
99
- link has not been loaded, or if any known resources are not available in
100
- the cache, the fresh state will be fetched using the link.
98
+ Async relationships may take advantage of links. On access, if the related
99
+ link has not been loaded, or if any known resources are not available in
100
+ the cache, the fresh state will be fetched using the link.
101
101
 
102
- In contrast to async relationship, accessing a sync relationship
103
- will error on access when any of the known related resources have
104
- not been loaded.
102
+ In contrast to async relationship, accessing a sync relationship
103
+ will error on access when any of the known related resources have
104
+ not been loaded.
105
105
 
106
- If you are using `links` with sync relationships, you have to use
107
- the HasMany reference API to fetch or refresh related resources
108
- that aren't loaded. For instance, for a `comments` relationship:
106
+ If you are using `links` with sync relationships, you have to use
107
+ the HasMany reference API to fetch or refresh related resources
108
+ that aren't loaded. For instance, for a `comments` relationship:
109
109
 
110
- ```js
111
- post.hasMany('comments').reload();
112
- ```
110
+ ```js
111
+ post.hasMany('comments').reload();
112
+ ```
113
113
 
114
- #### Polymorphic Relationships
114
+ #### Polymorphic Relationships
115
115
 
116
- To declare a polymorphic relationship, use `hasMany` with the `polymorphic`
117
- option set to `true`:
116
+ To declare a polymorphic relationship, use `hasMany` with the `polymorphic`
117
+ option set to `true`:
118
118
 
119
- ```js
120
- // app/models/comment.js
121
- import { Model, belongsTo } from '@warp-drive/legacy/model';
119
+ ```js
120
+ // app/models/comment.js
121
+ import { Model, belongsTo } from '@warp-drive/legacy/model';
122
122
 
123
- export default class Comment extends Model {
124
- @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;
125
- }
126
- ```
123
+ export default class Comment extends Model {
124
+ @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;
125
+ }
126
+ ```
127
127
 
128
- `'commentable'` here is referred to as the "abstract type" for the polymorphic
129
- relationship.
128
+ `'commentable'` here is referred to as the "abstract type" for the polymorphic
129
+ relationship.
130
130
 
131
- Polymorphic relationships with `inverse: null` will accept any type of record as their content.
132
- Polymorphic relationships with `inverse` set to a string will only accept records with a matching
133
- inverse relationships declaring itself as satisfying the abstract type.
131
+ Polymorphic relationships with `inverse: null` will accept any type of record as their content.
132
+ Polymorphic relationships with `inverse` set to a string will only accept records with a matching
133
+ inverse relationships declaring itself as satisfying the abstract type.
134
134
 
135
- Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'
136
- for this relationship.
135
+ Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'
136
+ for this relationship.
137
137
 
138
- ```js
139
- // app/models/post.js
140
- import { Model, hasMany } from '@warp-drive/legacy/model';
138
+ ```js
139
+ // app/models/post.js
140
+ import { Model, hasMany } from '@warp-drive/legacy/model';
141
141
 
142
- export default class Post extends Model {
143
- @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;
144
- }
145
- ```
142
+ export default class Post extends Model {
143
+ @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;
144
+ }
145
+ ```
146
146
 
147
- Note: every Model that declares an inverse to a polymorphic relationship must
148
- declare itself exactly the same. This is because polymorphism is based on structural
149
- traits.
147
+ Note: every Model that declares an inverse to a polymorphic relationship must
148
+ declare itself exactly the same. This is because polymorphism is based on structural
149
+ traits.
150
150
 
151
- Polymorphic to polymorphic relationships are supported. Both sides of the relationship
152
- must be declared as polymorphic, and the `as` option must be used to declare the abstract
153
- type each record satisfies on both sides.
151
+ Polymorphic to polymorphic relationships are supported. Both sides of the relationship
152
+ must be declared as polymorphic, and the `as` option must be used to declare the abstract
153
+ type each record satisfies on both sides.
154
154
 
155
- @public
156
- @param {String} type (optional) the name of the related resource
157
- @param {Object} options (optional) a hash of options
158
- @return {PropertyDescriptor} relationship
155
+ @public
156
+ @param {String} type (optional) the name of the related resource
157
+ @param {Object} options (optional) a hash of options
158
+ @return {PropertyDescriptor} relationship
159
159
  */
160
160
  export declare function hasMany(): never;
161
161
  export declare function hasMany(type: string): never;
162
162
  export declare function hasMany<T>(type: TypeFromInstance<NoNull<T>>, options: RelationshipOptions<T, boolean>): RelationshipDecorator<T>;
163
+ // export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(
164
+ // type: TypeFromInstance<NoNull<T>>,
165
+ // options: RelationshipOptions<T, true>
166
+ // ): RelationshipDecorator<K>;
163
167
  export declare function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;
164
- //# sourceMappingURL=has-many.d.ts.map
@@ -1,11 +1,10 @@
1
- import { type Store } from '@warp-drive/core/store/-private';
2
- import type { StableRecordIdentifier } from '@warp-drive/core/types/identifier';
3
- import type { TypeFromInstance } from '@warp-drive/core/types/record';
4
- import type { Model } from './model.ts';
1
+ import { type Store } from "@warp-drive/core/store/-private";
2
+ import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
+ import type { TypeFromInstance } from "@warp-drive/core/types/record";
4
+ import type { Model } from "./model.js";
5
5
  export declare function instantiateRecord(this: Store, identifier: StableRecordIdentifier, createRecordArgs: {
6
- [key: string]: unknown;
6
+ [key: string]: unknown;
7
7
  }): Model;
8
8
  export declare function teardownRecord(record: Model): void;
9
9
  export declare function modelFor<T>(type: TypeFromInstance<T>): typeof Model | void;
10
10
  export declare function modelFor(type: string): typeof Model | void;
11
- //# sourceMappingURL=hooks.d.ts.map
@@ -1,57 +1,56 @@
1
- import type { Store } from '@warp-drive/core';
2
- import type { CollectionEdge, Graph, ResourceEdge, UpgradedMeta } from '@warp-drive/core/graph/-private';
3
- import type { LiveArray } from '@warp-drive/core/store/-private';
4
- import { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';
5
- import type { BaseFinderOptions, StableRecordIdentifier } from '@warp-drive/core/types';
6
- import type { Cache } from '@warp-drive/core/types/cache';
7
- import type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';
8
- import type { LocalRelationshipOperation } from '@warp-drive/core/types/graph';
9
- import type { OpaqueRecordInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';
10
- import type { CollectionResourceRelationship, InnerRelationshipDocument, SingleResourceRelationship } from '@warp-drive/core/types/spec/json-api-raw';
11
- import type { MinimalLegacyRecord } from './model-methods.ts';
12
- import type { BelongsToProxyCreateArgs } from './promise-belongs-to.ts';
13
- import { PromiseBelongsTo } from './promise-belongs-to.ts';
14
- import type { HasManyProxyCreateArgs } from './promise-many-array.ts';
15
- import { PromiseManyArray } from './promise-many-array.ts';
16
- import BelongsToReference from './references/belongs-to.ts';
17
- import HasManyReference from './references/has-many.ts';
1
+ import type { Store } from "@warp-drive/core";
2
+ import type { CollectionEdge, Graph, ResourceEdge, UpgradedMeta } from "@warp-drive/core/graph/-private";
3
+ import type { LiveArray } from "@warp-drive/core/store/-private";
4
+ import { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
5
+ import type { BaseFinderOptions, StableRecordIdentifier } from "@warp-drive/core/types";
6
+ import type { Cache } from "@warp-drive/core/types/cache";
7
+ import type { CollectionRelationship } from "@warp-drive/core/types/cache/relationship";
8
+ import type { LocalRelationshipOperation } from "@warp-drive/core/types/graph";
9
+ import type { OpaqueRecordInstance, TypeFromInstanceOrString } from "@warp-drive/core/types/record";
10
+ import type { CollectionResourceRelationship, InnerRelationshipDocument, SingleResourceRelationship } from "@warp-drive/core/types/spec/json-api-raw";
11
+ import type { MinimalLegacyRecord } from "./model-methods.js";
12
+ import type { BelongsToProxyCreateArgs } from "./promise-belongs-to.js";
13
+ import { PromiseBelongsTo } from "./promise-belongs-to.js";
14
+ import type { HasManyProxyCreateArgs } from "./promise-many-array.js";
15
+ import { PromiseManyArray } from "./promise-many-array.js";
16
+ import BelongsToReference from "./references/belongs-to.js";
17
+ import HasManyReference from "./references/has-many.js";
18
18
  export declare const LEGACY_SUPPORT: Map<StableRecordIdentifier | MinimalLegacyRecord, LegacySupport>;
19
19
  export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
20
20
  export declare class LegacySupport {
21
- record: MinimalLegacyRecord;
22
- store: Store;
23
- graph: Graph;
24
- cache: Cache;
25
- references: Record<string, BelongsToReference | HasManyReference>;
26
- identifier: StableRecordIdentifier;
27
- _manyArrayCache: Record<string, ManyArray>;
28
- _relationshipPromisesCache: Record<string, Promise<ManyArray | OpaqueRecordInstance>>;
29
- _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
30
- _pending: Record<string, Promise<StableRecordIdentifier | null> | undefined>;
31
- isDestroying: boolean;
32
- isDestroyed: boolean;
33
- constructor(record: MinimalLegacyRecord);
34
- _syncArray(array: LiveArray): void;
35
- mutate(mutation: LocalRelationshipOperation): void;
36
- _findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
37
- reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
38
- getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
39
- setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void;
40
- _getCurrentState<T>(identifier: StableRecordIdentifier, field: string): [StableRecordIdentifier<TypeFromInstanceOrString<T>>[], CollectionRelationship];
41
- getManyArray<T>(key: string, definition?: UpgradedMeta): ManyArray<T>;
42
- fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: ManyArray, options?: BaseFinderOptions): Promise<ManyArray>;
43
- reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<ManyArray<T>> | PromiseManyArray<T>;
44
- getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | ManyArray;
45
- _updatePromiseProxyFor(kind: 'hasMany', key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
46
- _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
47
- _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: {
48
- promise: Promise<OpaqueRecordInstance | null>;
49
- }): PromiseBelongsTo;
50
- referenceFor(kind: 'belongsTo', name: string): BelongsToReference;
51
- referenceFor(kind: 'hasMany', name: string): HasManyReference;
52
- _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
53
- _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<StableRecordIdentifier | null>;
54
- destroy(): void;
21
+ record: MinimalLegacyRecord;
22
+ store: Store;
23
+ graph: Graph;
24
+ cache: Cache;
25
+ references: Record<string, BelongsToReference | HasManyReference>;
26
+ identifier: StableRecordIdentifier;
27
+ _manyArrayCache: Record<string, ManyArray>;
28
+ _relationshipPromisesCache: Record<string, Promise<ManyArray | OpaqueRecordInstance>>;
29
+ _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
30
+ _pending: Record<string, Promise<StableRecordIdentifier | null> | undefined>;
31
+ isDestroying: boolean;
32
+ isDestroyed: boolean;
33
+ constructor(record: MinimalLegacyRecord);
34
+ _syncArray(array: LiveArray): void;
35
+ mutate(mutation: LocalRelationshipOperation): void;
36
+ _findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
37
+ reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
38
+ getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
39
+ setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void;
40
+ _getCurrentState<T>(identifier: StableRecordIdentifier, field: string): [StableRecordIdentifier<TypeFromInstanceOrString<T>>[], CollectionRelationship];
41
+ getManyArray<T>(key: string, definition?: UpgradedMeta): ManyArray<T>;
42
+ fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: ManyArray, options?: BaseFinderOptions): Promise<ManyArray>;
43
+ reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<ManyArray<T>> | PromiseManyArray<T>;
44
+ getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | ManyArray;
45
+ _updatePromiseProxyFor(kind: "hasMany", key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
46
+ _updatePromiseProxyFor(kind: "belongsTo", key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
47
+ _updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
48
+ promise: Promise<OpaqueRecordInstance | null>;
49
+ }): PromiseBelongsTo;
50
+ referenceFor(kind: "belongsTo", name: string): BelongsToReference;
51
+ referenceFor(kind: "hasMany", name: string): HasManyReference;
52
+ _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
53
+ _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<StableRecordIdentifier | null>;
54
+ destroy(): void;
55
55
  }
56
56
  export declare function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean;
57
- //# sourceMappingURL=legacy-relationships-support.d.ts.map
@@ -1,4 +1,19 @@
1
- import type { Store } from '@warp-drive/core';
2
- import { type ModelFactory } from './model';
1
+ import type { Store } from "@warp-drive/core";
2
+ import { type ModelFactory } from "./model.js";
3
+ /*
4
+ In case someone defined a relationship to a mixin, for example:
5
+ ```ts
6
+ class CommentModel extends Model {
7
+ @belongsTo('commentable', { polymorphic: true }) owner;
8
+ }
9
+
10
+ let Commentable = Mixin.create({
11
+ @hasMany('comment') comments;
12
+ });
13
+ ```
14
+ we want to look up a Commentable class which has all the necessary
15
+ relationship meta data. Thus, we look up the mixin and create a mock
16
+ Model, so we can access the relationship CPs of the mixin (`comments`)
17
+ in this case
18
+ */
3
19
  export default function modelForMixin(store: Store, normalizedModelName: string): ModelFactory | undefined;
4
- //# sourceMappingURL=model-for-mixin.d.ts.map
@@ -1,30 +1,36 @@
1
- import type { Store } from '@warp-drive/core';
2
- import type { ChangedAttributesHash } from '@warp-drive/core/types/cache';
3
- import { RecordStore } from '@warp-drive/core/types/symbols';
4
- import type { Snapshot } from '../../compat/-private.ts';
5
- import type { Errors } from './errors.ts';
6
- import type RecordState from './record-state.ts';
7
- import type BelongsToReference from './references/belongs-to.ts';
8
- import type HasManyReference from './references/has-many.ts';
9
- import type { MaybeBelongsToFields, MaybeHasManyFields } from './type-utils.ts';
1
+ import type { Store } from "@warp-drive/core";
2
+ import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
3
+ import { RecordStore } from "@warp-drive/core/types/symbols";
4
+ import type { Snapshot } from "../../compat/-private.js";
5
+ import type { Errors } from "./errors.js";
6
+ import type RecordState from "./record-state.js";
7
+ import type BelongsToReference from "./references/belongs-to.js";
8
+ import type HasManyReference from "./references/has-many.js";
9
+ import type { MaybeBelongsToFields, MaybeHasManyFields } from "./type-utils.js";
10
10
  export interface MinimalLegacyRecord {
11
- errors: Errors;
12
- ___recordState: RecordState;
13
- currentState: RecordState;
14
- isDestroyed: boolean;
15
- isDestroying: boolean;
16
- isReloading: boolean;
17
- isValid: boolean;
18
- [RecordStore]: Store;
19
- deleteRecord(): void;
20
- unloadRecord(): void;
21
- save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
22
- destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
11
+ errors: Errors;
12
+ ___recordState: RecordState;
13
+ currentState: RecordState;
14
+ isDestroyed: boolean;
15
+ isDestroying: boolean;
16
+ isReloading: boolean;
17
+ isValid: boolean;
18
+ [RecordStore]: Store;
19
+ deleteRecord(): void;
20
+ unloadRecord(): void;
21
+ save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
22
+ destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
23
23
  }
24
24
  export declare function rollbackAttributes<T extends MinimalLegacyRecord>(this: T): void;
25
25
  export declare function unloadRecord<T extends MinimalLegacyRecord>(this: T): void;
26
- export declare function belongsTo<T extends MinimalLegacyRecord, K extends MaybeBelongsToFields<T>>(this: T, prop: K): BelongsToReference<T, K>;
27
- export declare function hasMany<T extends MinimalLegacyRecord, K extends MaybeHasManyFields<T>>(this: T, prop: K): HasManyReference<T, K>;
26
+ export declare function belongsTo<
27
+ T extends MinimalLegacyRecord,
28
+ K extends MaybeBelongsToFields<T>
29
+ >(this: T, prop: K): BelongsToReference<T, K>;
30
+ export declare function hasMany<
31
+ T extends MinimalLegacyRecord,
32
+ K extends MaybeHasManyFields<T>
33
+ >(this: T, prop: K): HasManyReference<T, K>;
28
34
  export declare function reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
29
35
  export declare function changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash;
30
36
  export declare function serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): unknown;
@@ -32,4 +38,3 @@ export declare function deleteRecord<T extends MinimalLegacyRecord>(this: T): vo
32
38
  export declare function save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
33
39
  export declare function destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
34
40
  export declare function createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T>;
35
- //# sourceMappingURL=model-methods.d.ts.map