ember-data-resources 5.2.2 → 5.3.0

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 (58) hide show
  1. package/README.md +291 -0
  2. package/dist/-private/resources/errors.js +13 -0
  3. package/dist/-private/resources/errors.js.map +1 -0
  4. package/dist/-private/resources/find-all.js +28 -0
  5. package/dist/-private/resources/find-all.js.map +1 -0
  6. package/dist/-private/resources/find-record.js +42 -0
  7. package/dist/-private/resources/find-record.js.map +1 -0
  8. package/dist/-private/resources/query-record.js +28 -0
  9. package/dist/-private/resources/query-record.js.map +1 -0
  10. package/dist/-private/resources/query.js +28 -0
  11. package/dist/-private/resources/query.js.map +1 -0
  12. package/dist/-private/resources/request.js +103 -0
  13. package/dist/-private/resources/request.js.map +1 -0
  14. package/dist/-private/resources/types.js +2 -0
  15. package/dist/-private/resources/types.js.map +1 -0
  16. package/dist/_app_/helpers/find-all.js +1 -0
  17. package/dist/_app_/helpers/find-record.js +1 -0
  18. package/dist/_app_/helpers/query-record.js +1 -0
  19. package/dist/_app_/helpers/query.js +1 -0
  20. package/dist/index.js +6 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/js-helpers.js +97 -0
  23. package/dist/js-helpers.js.map +1 -0
  24. package/dist/loose-mode-compat/helpers/find-all.js +9 -0
  25. package/dist/loose-mode-compat/helpers/find-all.js.map +1 -0
  26. package/dist/loose-mode-compat/helpers/find-record.js +9 -0
  27. package/dist/loose-mode-compat/helpers/find-record.js.map +1 -0
  28. package/dist/loose-mode-compat/helpers/query-record.js +9 -0
  29. package/dist/loose-mode-compat/helpers/query-record.js.map +1 -0
  30. package/dist/loose-mode-compat/helpers/query.js +9 -0
  31. package/dist/loose-mode-compat/helpers/query.js.map +1 -0
  32. package/dist-types/-private/resources/errors.d.ts +7 -0
  33. package/dist-types/-private/resources/errors.d.ts.map +1 -0
  34. package/dist-types/-private/resources/find-all.d.ts +19 -0
  35. package/dist-types/-private/resources/find-all.d.ts.map +1 -0
  36. package/dist-types/-private/resources/find-record.d.ts +19 -0
  37. package/dist-types/-private/resources/find-record.d.ts.map +1 -0
  38. package/dist-types/-private/resources/query-record.d.ts +20 -0
  39. package/dist-types/-private/resources/query-record.d.ts.map +1 -0
  40. package/dist-types/-private/resources/query.d.ts +21 -0
  41. package/dist-types/-private/resources/query.d.ts.map +1 -0
  42. package/dist-types/-private/resources/request.d.ts +23 -0
  43. package/dist-types/-private/resources/request.d.ts.map +1 -0
  44. package/dist-types/-private/resources/types.d.ts +2 -0
  45. package/dist-types/-private/resources/types.d.ts.map +1 -0
  46. package/dist-types/index.d.ts +6 -0
  47. package/dist-types/index.d.ts.map +1 -0
  48. package/dist-types/js-helpers.d.ts +33 -0
  49. package/dist-types/js-helpers.d.ts.map +1 -0
  50. package/dist-types/loose-mode-compat/helpers/find-all.d.ts +3 -0
  51. package/dist-types/loose-mode-compat/helpers/find-all.d.ts.map +1 -0
  52. package/dist-types/loose-mode-compat/helpers/find-record.d.ts +3 -0
  53. package/dist-types/loose-mode-compat/helpers/find-record.d.ts.map +1 -0
  54. package/dist-types/loose-mode-compat/helpers/query-record.d.ts +3 -0
  55. package/dist-types/loose-mode-compat/helpers/query-record.d.ts.map +1 -0
  56. package/dist-types/loose-mode-compat/helpers/query.d.ts +3 -0
  57. package/dist-types/loose-mode-compat/helpers/query.d.ts.map +1 -0
  58. package/package.json +10 -10
package/README.md ADDED
@@ -0,0 +1,291 @@
1
+ # ember-data-resources
2
+
3
+ Resources for reactive data fetching with ember-data's `store` service.
4
+
5
+ ## Compatibility
6
+
7
+ * ember-source v3.28 or above
8
+ * ember-data v3.28 or above
9
+ * ember-auto-import v2 or above
10
+ * ember-resources v5.3 or above
11
+ * typescript v5 or above
12
+
13
+ ## Installation
14
+
15
+ ```
16
+ npm add ember-data-resources
17
+ ```
18
+
19
+
20
+ ## Usage
21
+
22
+ ### `findAll`
23
+
24
+ ```js
25
+ import { findAll } from 'ember-data-resources';
26
+
27
+ export default class MyComponent extends Component {
28
+ @tracked included = '';
29
+
30
+ blog = findAll(this, 'blog', () => ({ included: this.included }));
31
+ // blog = findAll(this, 'blog');
32
+ }
33
+ ```
34
+ ```hbs
35
+ Available properties:
36
+ - {{this.blog.records}}
37
+ - {{this.blog.error}}
38
+ - {{this.blog.isLoading}}
39
+ - {{this.blog.isSuccess}}
40
+ - {{this.blog.isError}}
41
+ - {{this.blog.hasRan}}
42
+
43
+ Available methods:
44
+ - <button {{on 'click' this.blog.retry}}>Retry</button>
45
+ ```
46
+
47
+ **in a template**
48
+
49
+ ```hbs
50
+ {{#let (find-all 'blog') as |blogs|}}
51
+ {{#if blogs.isLoading}}
52
+ ...
53
+ {{else if blogs.isError}}
54
+ {{blogs.error}}
55
+ {{else}}
56
+ {{blogs.records}}
57
+ {{/if}}
58
+
59
+ Available properties:
60
+ - {{blog.records}}
61
+ - {{blog.error}}
62
+ - {{blog.isLoading}}
63
+ - {{blog.isSuccess}}
64
+ - {{blog.isError}}
65
+ - {{blog.hasRan}}
66
+
67
+ Available methods:
68
+ - <button {{on 'click' blog.retry}}>Retry</button>
69
+ {{/let}}
70
+ ```
71
+
72
+ **in strict mode**
73
+
74
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
75
+
76
+ ```jsx
77
+ import { FindAll } from 'ember-data-resources';
78
+
79
+ <template>
80
+ {{#let (FindAll 'blog') as |blogs|}}
81
+ ...
82
+ {{/let}}
83
+ </template>
84
+ ```
85
+
86
+ ### `findRecord`
87
+
88
+ ```js
89
+ import { findRecord } from 'ember-data-resources';
90
+
91
+ export default class MyComponent extends Component {
92
+ @tracked id = 1;
93
+
94
+ blog = findRecord(this, 'blog', () => this.id)
95
+ // blog = findRecord(this, 'blog', () => [this.id])
96
+ // blog = findRecord(this, 'blog', () => [this.id, { ...options }])
97
+ }
98
+ ```
99
+ ```hbs
100
+ Available properties:
101
+ - {{this.blog.record}}
102
+ - {{this.blog.error}}
103
+ - {{this.blog.isLoading}}
104
+ - {{this.blog.isSuccess}}
105
+ - {{this.blog.isError}}
106
+ - {{this.blog.hasRan}}
107
+
108
+ Available methods:
109
+ - <button {{on 'click' this.blog.retry}}>Retry</button>
110
+ ```
111
+
112
+ **in a template**
113
+
114
+ ```hbs
115
+ {{#let (find-record 'blog' @id) as |blog|}}
116
+ {{!-- or: (find-record 'blog' @id options=...) --}}
117
+ {{#if blog.isLoading}}
118
+ ...
119
+ {{else if blog.isError}}
120
+ {{blog.error}}
121
+ {{else}}
122
+ {{blog.record}}
123
+ {{/if}}
124
+
125
+ Available properties:
126
+ - {{blog.record}}
127
+ - {{blog.error}}
128
+ - {{blog.isLoading}}
129
+ - {{blog.isSuccess}}
130
+ - {{blog.isError}}
131
+ - {{blog.hasRan}}
132
+
133
+ Available methods:
134
+ - <button {{on 'click' blog.retry}}>Retry</button>
135
+ {{/let}}
136
+ ```
137
+
138
+ **in strict mode**
139
+
140
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
141
+
142
+ ```jsx
143
+ import { FindRecord } from 'ember-data-resources';
144
+
145
+ <template>
146
+ {{#let (FindRecord 'blog' @id) as |blog|}}
147
+ ...
148
+ {{/let}}
149
+ </template>
150
+ ```
151
+
152
+ ### `query`
153
+
154
+ ```js
155
+ import { query } from 'ember-data-resources';
156
+
157
+ export default class MyComponent extends Component {
158
+ blog = query(this, 'blog', () => ({ ...query }));
159
+ // blog = query(this, 'blog', () => [{ ...query }]);
160
+ // blog = query(this, 'blog', () => [{ ...query }, { ...options }]);
161
+ }
162
+ ```
163
+ ```hbs
164
+ Available properties:
165
+ - {{this.blog.records}}
166
+ - {{this.blog.error}}
167
+ - {{this.blog.isLoading}}
168
+ - {{this.blog.isSuccess}}
169
+ - {{this.blog.isError}}
170
+ - {{this.blog.hasRan}}
171
+
172
+ Available methods:
173
+ - <button {{on 'click' this.blog.retry}}>Retry</button>
174
+ ```
175
+
176
+ **in a template**
177
+
178
+ ```hbs
179
+ {{#let (query 'blog' (hash ...)) as |blogs|}}
180
+ {{#if blogs.isLoading}}
181
+ ...
182
+ {{else if blogs.isError}}
183
+ {{blogs.error}}
184
+ {{else}}
185
+ {{blogs.records}}
186
+ {{/if}}
187
+
188
+ Available properties:
189
+ - {{blog.records}}
190
+ - {{blog.error}}
191
+ - {{blog.isLoading}}
192
+ - {{blog.isSuccess}}
193
+ - {{blog.isError}}
194
+ - {{blog.hasRan}}
195
+
196
+ Available methods:
197
+ - <button {{on 'click' blog.retry}}>Retry</button>
198
+ {{/let}}
199
+ ```
200
+
201
+ **in strict mode**
202
+
203
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
204
+
205
+ ```jsx
206
+ import { Query } from 'ember-data-resources';
207
+
208
+ <template>
209
+ {{#let (Query 'blog' (hash ...)) as |blogs|}}
210
+ ...
211
+ {{/let}}
212
+ </template>
213
+ ```
214
+
215
+
216
+ ### `queryRecord`
217
+
218
+ ```js
219
+ import { queryRecord } from 'ember-data-resources';
220
+
221
+ export default class MyComponent extends Component {
222
+ @tracked id = 1;
223
+
224
+ blog = queryRecord(this, 'blog', () => ({ ...query }))
225
+ // blog = findRecord(this, 'blog', () => [{ ...query }])
226
+ // blog = findRecord(this, 'blog', () => [{ ...query }, { ...options }])
227
+ }
228
+ ```
229
+ ```hbs
230
+ Available properties:
231
+ - {{this.blog.record}}
232
+ - {{this.blog.error}}
233
+ - {{this.blog.isLoading}}
234
+ - {{this.blog.isSuccess}}
235
+ - {{this.blog.isError}}
236
+ - {{this.blog.hasRan}}
237
+
238
+ Available methods:
239
+ - <button {{on 'click' this.blog.retry}}>Retry</button>
240
+ ```
241
+
242
+ **in a template**
243
+
244
+ ```hbs
245
+ {{#let (query-record 'blog' (hash ...)) as |blog|}}
246
+ {{#if blog.isLoading}}
247
+ ...
248
+ {{else if blog.isError}}
249
+ {{blog.error}}
250
+ {{else}}
251
+ {{blog.record}}
252
+ {{/if}}
253
+
254
+ Available properties:
255
+ - {{blog.record}}
256
+ - {{blog.error}}
257
+ - {{blog.isLoading}}
258
+ - {{blog.isSuccess}}
259
+ - {{blog.isError}}
260
+ - {{blog.hasRan}}
261
+
262
+ Available methods:
263
+ - <button {{on 'click' blog.retry}}>Retry</button>
264
+
265
+ {{/let}}
266
+ ```
267
+
268
+ **in strict mode**
269
+
270
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
271
+
272
+ ```jsx
273
+ import { QueryRecord } from 'ember-data-resources';
274
+
275
+ <template>
276
+ {{#let (QueryRecord 'blog' (hash ...)) as |blog|}}
277
+ ...
278
+ {{/let}}
279
+ </template>
280
+ ```
281
+
282
+ Contributing
283
+ ------------------------------------------------------------------------------
284
+
285
+ See the [Contributing](CONTRIBUTING.md) guide for details.
286
+
287
+
288
+ License
289
+ ------------------------------------------------------------------------------
290
+
291
+ This project is licensed under the [MIT License](LICENSE.md).
@@ -0,0 +1,13 @@
1
+ class IdRequiredError extends TypeError {
2
+ constructor(modelName) {
3
+ super(`While trying to request a resource from ${modelName}, the ID was either null or undefined, and the ID is required for fetching resources`);
4
+ }
5
+ }
6
+ class IdTypeError extends TypeError {
7
+ constructor(modelName, id) {
8
+ super(`While trying to request a resource from ${modelName}, the ID was of invalid type ${typeof id}: only string and number are supported`);
9
+ }
10
+ }
11
+
12
+ export { IdRequiredError, IdTypeError };
13
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sources":["../../../src/-private/resources/errors.ts"],"sourcesContent":["export class IdRequiredError extends TypeError {\n constructor(modelName: string) {\n super(\n `While trying to request a resource from ${modelName}, the ID was either null or undefined, and the ID is required for fetching resources`,\n );\n }\n}\n\nexport class IdTypeError extends TypeError {\n constructor(modelName: string, id: unknown) {\n super(\n `While trying to request a resource from ${modelName}, the ID was of invalid type ${typeof id}: only string and number are supported`,\n );\n }\n}\n"],"names":["IdRequiredError","TypeError","constructor","modelName","IdTypeError","id"],"mappings":"AAAO,MAAMA,eAAe,SAASC,SAAS,CAAC;EAC7CC,WAAWA,CAACC,SAAiB,EAAE;AAC7B,IAAA,KAAK,CACF,CAAA,wCAAA,EAA0CA,SAAU,CAAA,oFAAA,CACvD,CAAC;AACH;AACF;AAEO,MAAMC,WAAW,SAASH,SAAS,CAAC;AACzCC,EAAAA,WAAWA,CAACC,SAAiB,EAAEE,EAAW,EAAE;AAC1C,IAAA,KAAK,CACF,CAA0CF,wCAAAA,EAAAA,SAAU,gCAA+B,OAAOE,EAAG,wCAChG,CAAC;AACH;AACF;;;;"}
@@ -0,0 +1,28 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import { isDestroyed, isDestroying } from '@ember/destroyable';
3
+ import { action } from '@ember/object';
4
+ import { Request } from './request.js';
5
+ import { g, i, n } from 'decorator-transforms/runtime-esm';
6
+
7
+ class FindAll extends Request {
8
+ static {
9
+ g(this.prototype, "_records", [tracked]);
10
+ }
11
+ #_records = (i(this, "_records"), void 0);
12
+ async __WRAPPED_FUNCTION__([modelName], {
13
+ options
14
+ }) {
15
+ const records = await this.store.findAll(modelName, options);
16
+ if (isDestroyed(this) || isDestroying(this)) return;
17
+ this._records = records;
18
+ }
19
+ static {
20
+ n(this.prototype, "__WRAPPED_FUNCTION__", [action]);
21
+ }
22
+ get records() {
23
+ return this._records;
24
+ }
25
+ }
26
+
27
+ export { FindAll };
28
+ //# sourceMappingURL=find-all.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-all.js","sources":["../../../src/-private/resources/find-all.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { isDestroyed, isDestroying } from '@ember/destroyable';\nimport { action } from '@ember/object';\n\nimport { Request } from './request.ts';\n\nimport type ArrayProxy from '@ember/array/proxy';\nimport type Store from '@ember-data/store';\n\nexport type FindAllOptions = Parameters<Store['findAll']>[1];\n\ntype PositionalArgs = [string];\nexport interface NamedArgs {\n options: FindAllOptions;\n}\n\nexport interface Args {\n named: NamedArgs;\n positional: PositionalArgs;\n}\n\nexport class FindAll<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {\n @tracked private _records: ArrayProxy<Model> | undefined;\n\n @action\n async __WRAPPED_FUNCTION__([modelName]: PositionalArgs, { options }: NamedArgs): Promise<void> {\n const records = await this.store.findAll(modelName as never, options);\n\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this._records = records;\n }\n\n get records(): ArrayProxy<Model> | undefined {\n return this._records;\n }\n}\n"],"names":["FindAll","Request","g","prototype","tracked","i","void 0","__WRAPPED_FUNCTION__","modelName","options","records","store","findAll","isDestroyed","isDestroying","_records","n","action"],"mappings":";;;;;;AAqBO,MAAMA,OAAO,SAA+CC,OAAO,CAAY;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,UAAA,EAAA,CACnFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,SAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,UAAA,CAAA,EAAAC,MAAA;AAER,EAAA,MACMC,oBAAoBA,CAAC,CAACC,SAAS,CAAiB,EAAE;AAAEC,IAAAA;AAAmB,GAAC,EAAiB;AAC7F,IAAA,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACC,KAAK,CAACC,OAAO,CAACJ,SAAS,EAAWC,OAAO,CAAC;IAErE,IAAII,WAAW,CAAC,IAAI,CAAC,IAAIC,YAAY,CAAC,IAAI,CAAC,EAAE;IAE7C,IAAI,CAACC,QAAQ,GAAGL,OAAO;AACzB;AAAC,EAAA;IAAAM,CAAA,CAAA,IAAA,CAAAb,SAAA,EAAA,sBAAA,EAAA,CAPAc,MAAM,CAAA,CAAA;AAAA;EASP,IAAIP,OAAOA,GAAkC;IAC3C,OAAO,IAAI,CAACK,QAAQ;AACtB;AACF;;;;"}
@@ -0,0 +1,42 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import { isDestroyed, isDestroying } from '@ember/destroyable';
3
+ import { action } from '@ember/object';
4
+ import { waitFor } from '@ember/test-waiters';
5
+ import { IdRequiredError, IdTypeError } from './errors.js';
6
+ import { Request } from './request.js';
7
+ import { g, i, n } from 'decorator-transforms/runtime-esm';
8
+
9
+ class FindRecord extends Request {
10
+ static {
11
+ g(this.prototype, "_record", [tracked]);
12
+ }
13
+ #_record = (i(this, "_record"), void 0);
14
+ async __WRAPPED_FUNCTION__([modelName, id], {
15
+ options
16
+ }) {
17
+ /**
18
+ * ember-data forbids usage of invalid arguments
19
+ * in JS, this is typically fine as we can also try-catch, but
20
+ * since this *might* be used in a template as well as JS, we need to instead
21
+ * throw our own error that gives a bit more context to the user so
22
+ * they can pass in the correct arguments
23
+ */
24
+ if (id === null || id === undefined) {
25
+ throw new IdRequiredError(modelName);
26
+ } else if (typeof id !== 'string' && typeof id !== 'number') {
27
+ throw new IdTypeError(modelName, id);
28
+ }
29
+ const record = await this.store.findRecord(modelName, id, options);
30
+ if (isDestroyed(this) || isDestroying(this)) return;
31
+ this._record = record;
32
+ }
33
+ static {
34
+ n(this.prototype, "__WRAPPED_FUNCTION__", [waitFor, action]);
35
+ }
36
+ get record() {
37
+ return this._record;
38
+ }
39
+ }
40
+
41
+ export { FindRecord };
42
+ //# sourceMappingURL=find-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-record.js","sources":["../../../src/-private/resources/find-record.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { isDestroyed, isDestroying } from '@ember/destroyable';\nimport { action } from '@ember/object';\nimport { waitFor } from '@ember/test-waiters';\n\nimport { IdRequiredError, IdTypeError } from './errors.ts';\nimport { Request } from './request.ts';\n\nimport type { Id } from './types.ts';\nimport type Store from '@ember-data/store';\n\nexport type FindRecordOptions = Parameters<Store['findRecord']>[2];\n\ntype PositionalArgs = [string, Id];\nexport interface NamedArgs {\n options: FindRecordOptions;\n}\n\nexport interface Args {\n named: NamedArgs;\n positional: PositionalArgs;\n}\n\nexport class FindRecord<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {\n @tracked private _record: Model | undefined;\n\n @action\n @waitFor\n async __WRAPPED_FUNCTION__([modelName, id]: PositionalArgs, { options }: NamedArgs) {\n /**\n * ember-data forbids usage of invalid arguments\n * in JS, this is typically fine as we can also try-catch, but\n * since this *might* be used in a template as well as JS, we need to instead\n * throw our own error that gives a bit more context to the user so\n * they can pass in the correct arguments\n */\n if (id === null || id === undefined) {\n throw new IdRequiredError(modelName);\n } else if (typeof id !== 'string' && typeof id !== 'number') {\n throw new IdTypeError(modelName, id);\n }\n\n const record = await this.store.findRecord(modelName as never, id, options);\n\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this._record = record;\n }\n\n get record(): Model | undefined {\n return this._record;\n }\n}\n"],"names":["FindRecord","Request","g","prototype","tracked","i","void 0","__WRAPPED_FUNCTION__","modelName","id","options","undefined","IdRequiredError","IdTypeError","record","store","findRecord","isDestroyed","isDestroying","_record","n","waitFor","action"],"mappings":";;;;;;;;AAuBO,MAAMA,UAAU,SAA+CC,OAAO,CAAY;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACtFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAAC,MAAA;AAER,EAAA,MAEMC,oBAAoBA,CAAC,CAACC,SAAS,EAAEC,EAAE,CAAiB,EAAE;AAAEC,IAAAA;AAAmB,GAAC,EAAE;AAClF;AACJ;AACA;AACA;AACA;AACA;AACA;AACI,IAAA,IAAID,EAAE,KAAK,IAAI,IAAIA,EAAE,KAAKE,SAAS,EAAE;AACnC,MAAA,MAAM,IAAIC,eAAe,CAACJ,SAAS,CAAC;KACrC,MAAM,IAAI,OAAOC,EAAE,KAAK,QAAQ,IAAI,OAAOA,EAAE,KAAK,QAAQ,EAAE;AAC3D,MAAA,MAAM,IAAII,WAAW,CAACL,SAAS,EAAEC,EAAE,CAAC;AACtC;AAEA,IAAA,MAAMK,MAAM,GAAG,MAAM,IAAI,CAACC,KAAK,CAACC,UAAU,CAACR,SAAS,EAAWC,EAAE,EAAEC,OAAO,CAAC;IAE3E,IAAIO,WAAW,CAAC,IAAI,CAAC,IAAIC,YAAY,CAAC,IAAI,CAAC,EAAE;IAE7C,IAAI,CAACC,OAAO,GAAGL,MAAM;AACvB;AAAC,EAAA;AAAAM,IAAAA,CAAA,CAAAjB,IAAAA,CAAAA,SAAA,EApBAkB,sBAAAA,EAAAA,CAAAA,OAAO,EADPC,MAAM,CAAA,CAAA;AAAA;EAuBP,IAAIR,MAAMA,GAAsB;IAC9B,OAAO,IAAI,CAACK,OAAO;AACrB;AACF;;;;"}
@@ -0,0 +1,28 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import { isDestroyed, isDestroying } from '@ember/destroyable';
3
+ import { action } from '@ember/object';
4
+ import { Request } from './request.js';
5
+ import { g, i, n } from 'decorator-transforms/runtime-esm';
6
+
7
+ class QueryRecord extends Request {
8
+ static {
9
+ g(this.prototype, "_record", [tracked]);
10
+ }
11
+ #_record = (i(this, "_record"), void 0);
12
+ async __WRAPPED_FUNCTION__([modelName, query], {
13
+ options
14
+ }) {
15
+ const record = await this.store.queryRecord(modelName, query, options);
16
+ if (isDestroyed(this) || isDestroying(this)) return;
17
+ this._record = record;
18
+ }
19
+ static {
20
+ n(this.prototype, "__WRAPPED_FUNCTION__", [action]);
21
+ }
22
+ get record() {
23
+ return this._record;
24
+ }
25
+ }
26
+
27
+ export { QueryRecord };
28
+ //# sourceMappingURL=query-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-record.js","sources":["../../../src/-private/resources/query-record.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { isDestroyed, isDestroying } from '@ember/destroyable';\nimport { action } from '@ember/object';\n\nimport { Request } from './request.ts';\n\nimport type Store from '@ember-data/store';\n\ntype QueryParams = Parameters<Store['queryRecord']>;\nexport type QueryRecordQuery = QueryParams[1];\nexport type QueryRecordOptions = QueryParams[2];\n\ntype PositionalArgs = [string, QueryRecordQuery];\nexport interface NamedArgs {\n options: QueryRecordOptions;\n}\n\nexport interface Args {\n named: NamedArgs;\n positional: PositionalArgs;\n}\n\nexport class QueryRecord<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {\n @tracked private _record: Model | undefined;\n\n @action\n async __WRAPPED_FUNCTION__([modelName, query]: PositionalArgs, { options }: NamedArgs) {\n const record = await this.store.queryRecord(modelName as never, query, options);\n\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this._record = record;\n }\n\n get record(): Model | undefined {\n return this._record;\n }\n}\n"],"names":["QueryRecord","Request","g","prototype","tracked","i","void 0","__WRAPPED_FUNCTION__","modelName","query","options","record","store","queryRecord","isDestroyed","isDestroying","_record","n","action"],"mappings":";;;;;;AAsBO,MAAMA,WAAW,SAA+CC,OAAO,CAAY;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACvFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAAC,MAAA;AAER,EAAA,MACMC,oBAAoBA,CAAC,CAACC,SAAS,EAAEC,KAAK,CAAiB,EAAE;AAAEC,IAAAA;AAAmB,GAAC,EAAE;AACrF,IAAA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACC,KAAK,CAACC,WAAW,CAACL,SAAS,EAAWC,KAAK,EAAEC,OAAO,CAAC;IAE/E,IAAII,WAAW,CAAC,IAAI,CAAC,IAAIC,YAAY,CAAC,IAAI,CAAC,EAAE;IAE7C,IAAI,CAACC,OAAO,GAAGL,MAAM;AACvB;AAAC,EAAA;IAAAM,CAAA,CAAA,IAAA,CAAAd,SAAA,EAAA,sBAAA,EAAA,CAPAe,MAAM,CAAA,CAAA;AAAA;EASP,IAAIP,MAAMA,GAAsB;IAC9B,OAAO,IAAI,CAACK,OAAO;AACrB;AACF;;;;"}
@@ -0,0 +1,28 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import { isDestroyed, isDestroying } from '@ember/destroyable';
3
+ import { action } from '@ember/object';
4
+ import { Request } from './request.js';
5
+ import { g, i, n } from 'decorator-transforms/runtime-esm';
6
+
7
+ class Query extends Request {
8
+ static {
9
+ g(this.prototype, "_records", [tracked]);
10
+ }
11
+ #_records = (i(this, "_records"), void 0);
12
+ async __WRAPPED_FUNCTION__([modelName, query], {
13
+ options
14
+ }) {
15
+ const records = await this.store.query(modelName, query, options);
16
+ if (isDestroyed(this) || isDestroying(this)) return;
17
+ this._records = records;
18
+ }
19
+ static {
20
+ n(this.prototype, "__WRAPPED_FUNCTION__", [action]);
21
+ }
22
+ get records() {
23
+ return this._records;
24
+ }
25
+ }
26
+
27
+ export { Query };
28
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sources":["../../../src/-private/resources/query.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { isDestroyed, isDestroying } from '@ember/destroyable';\nimport { action } from '@ember/object';\n\nimport { Request } from './request.ts';\n\nimport type ArrayProxy from '@ember/array/proxy';\nimport type Store from '@ember-data/store';\n\ntype QueryParams = Parameters<Store['query']>;\nexport type QueryQuery = QueryParams[1];\nexport type QueryOptions = QueryParams[2];\n\ntype PositionalArgs = [string, QueryQuery];\nexport interface NamedArgs {\n options: QueryOptions;\n}\n\nexport interface Args {\n named: NamedArgs;\n positional: PositionalArgs;\n}\n\nexport class Query<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {\n @tracked private _records: ArrayProxy<Model> | undefined;\n\n @action\n async __WRAPPED_FUNCTION__([modelName, query]: PositionalArgs, { options }: NamedArgs) {\n const records = await this.store.query(modelName as never, query, options);\n\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this._records = records;\n }\n\n get records(): ArrayProxy<Model> | undefined {\n return this._records;\n }\n}\n"],"names":["Query","Request","g","prototype","tracked","i","void 0","__WRAPPED_FUNCTION__","modelName","query","options","records","store","isDestroyed","isDestroying","_records","n","action"],"mappings":";;;;;;AAuBO,MAAMA,KAAK,SAA+CC,OAAO,CAAY;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,UAAA,EAAA,CACjFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,SAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,UAAA,CAAA,EAAAC,MAAA;AAER,EAAA,MACMC,oBAAoBA,CAAC,CAACC,SAAS,EAAEC,KAAK,CAAiB,EAAE;AAAEC,IAAAA;AAAmB,GAAC,EAAE;AACrF,IAAA,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACC,KAAK,CAACH,KAAK,CAACD,SAAS,EAAWC,KAAK,EAAEC,OAAO,CAAC;IAE1E,IAAIG,WAAW,CAAC,IAAI,CAAC,IAAIC,YAAY,CAAC,IAAI,CAAC,EAAE;IAE7C,IAAI,CAACC,QAAQ,GAAGJ,OAAO;AACzB;AAAC,EAAA;IAAAK,CAAA,CAAA,IAAA,CAAAb,SAAA,EAAA,sBAAA,EAAA,CAPAc,MAAM,CAAA,CAAA;AAAA;EASP,IAAIN,OAAOA,GAAkC;IAC3C,OAAO,IAAI,CAACI,QAAQ;AACtB;AACF;;;;"}
@@ -0,0 +1,103 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import { assert } from '@ember/debug';
3
+ import { isDestroyed, isDestroying } from '@ember/destroyable';
4
+ import { action } from '@ember/object';
5
+ import * as emberService from '@ember/service';
6
+ import { waitForPromise, waitFor } from '@ember/test-waiters';
7
+ import { Resource } from 'ember-modify-based-class-resource';
8
+ import { g, i, n } from 'decorator-transforms/runtime-esm';
9
+
10
+ const service = emberService.service ?? emberService.inject;
11
+ class Request extends Resource {
12
+ static {
13
+ g(this.prototype, "store", [service]);
14
+ }
15
+ #store = (i(this, "store"), void 0);
16
+ static {
17
+ g(this.prototype, "error", [tracked]);
18
+ }
19
+ #error = (i(this, "error"), void 0);
20
+ static {
21
+ g(this.prototype, "isLoading", [tracked], function () {
22
+ return false;
23
+ });
24
+ }
25
+ #isLoading = (i(this, "isLoading"), void 0);
26
+ static {
27
+ g(this.prototype, "hasRan", [tracked], function () {
28
+ return false;
29
+ });
30
+ }
31
+ #hasRan = (i(this, "hasRan"), void 0);
32
+ /**
33
+ * Args saved, untracked, for retrying
34
+ */
35
+
36
+ modify(positional, named) {
37
+ this.positional = positional || [];
38
+ this.named = named || {};
39
+
40
+ /**
41
+ * We need to consume all arguments here so that we correctly respond to updates to
42
+ * dirtied source data.
43
+ *
44
+ * e.g.: when an id changes that is passed to findRecord, we re-fetch.
45
+ */
46
+ this.__REQUEST_FUNCTION__([...positional], {
47
+ ...named
48
+ });
49
+ }
50
+ async __WRAPPED_FUNCTION__(_positional, _named) {
51
+ throw new Error('Not Implemented');
52
+ }
53
+ get isSuccess() {
54
+ return !this.error;
55
+ }
56
+ get isError() {
57
+ return Boolean(this.error);
58
+ }
59
+ get records() {
60
+ return assert(`The resource for ${this.constructor.name} does not have a records property. ` + `You might be looking for .record instead.`);
61
+ }
62
+ get record() {
63
+ return assert(`The resource for ${this.constructor.name} does not have a record property. ` + `You might be looking for .records instead.`);
64
+ }
65
+ async retry() {
66
+ return waitForPromise(this.__WRAPPED_FUNCTION__(this.positional, this.named));
67
+ }
68
+ static {
69
+ n(this.prototype, "retry", [action]);
70
+ }
71
+ async __REQUEST_FUNCTION__(_positional, _named) {
72
+ /**
73
+ * Args are already consumed, but let's delay doing anything
74
+ * until we can get out of a tracking frame.
75
+ */
76
+ await Promise.resolve();
77
+ if (isDestroyed(this) || isDestroying(this)) return;
78
+ this.error = undefined;
79
+ this.isLoading = true;
80
+ try {
81
+ await this.retry();
82
+ } catch (e) {
83
+ if (isDestroyed(this) || isDestroying(this)) return;
84
+ if (e instanceof Error) {
85
+ this.error = e;
86
+ } else {
87
+ // How likely is this to happen?
88
+ throw e;
89
+ }
90
+ }
91
+ if (isDestroyed(this) || isDestroying(this)) {
92
+ return;
93
+ }
94
+ this.isLoading = false;
95
+ this.hasRan = true;
96
+ }
97
+ static {
98
+ n(this.prototype, "__REQUEST_FUNCTION__", [waitFor, action]);
99
+ }
100
+ }
101
+
102
+ export { Request };
103
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sources":["../../../src/-private/resources/request.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { isDestroyed, isDestroying } from '@ember/destroyable';\nimport { action } from '@ember/object';\nimport * as emberService from '@ember/service';\n\nconst service = emberService.service ?? emberService.inject;\n\nimport { waitFor, waitForPromise } from '@ember/test-waiters';\n\nimport { Resource } from 'ember-modify-based-class-resource';\n\nimport type Store from '@ember-data/store';\n\nexport type FindRecordOptions = Parameters<Store['findRecord']>[2];\n\nexport class Request<Args> extends Resource<Args> {\n @service declare store: Store;\n\n @tracked error: Error | undefined;\n @tracked isLoading = false;\n @tracked hasRan = false;\n\n /**\n * Args saved, untracked, for retrying\n */\n declare positional: unknown[];\n declare named: object;\n\n modify(positional?: unknown[], named?: object) {\n this.positional = positional || [];\n this.named = named || {};\n\n /**\n * We need to consume all arguments here so that we correctly respond to updates to\n * dirtied source data.\n *\n * e.g.: when an id changes that is passed to findRecord, we re-fetch.\n */\n this.__REQUEST_FUNCTION__([...(positional as unknown[])], {\n ...named,\n });\n }\n\n async __WRAPPED_FUNCTION__(_positional: unknown[], _named: object) {\n throw new Error('Not Implemented');\n }\n\n get isSuccess() {\n return !this.error;\n }\n\n get isError() {\n return Boolean(this.error);\n }\n\n get records(): unknown | undefined {\n return assert(\n `The resource for ${this.constructor.name} does not have a records property. ` +\n `You might be looking for .record instead.`,\n );\n }\n\n get record(): unknown | undefined {\n return assert(\n `The resource for ${this.constructor.name} does not have a record property. ` +\n `You might be looking for .records instead.`,\n );\n }\n\n @action\n async retry() {\n return waitForPromise(this.__WRAPPED_FUNCTION__(this.positional, this.named));\n }\n\n @action\n @waitFor\n async __REQUEST_FUNCTION__(_positional: unknown[], _named: object) {\n /**\n * Args are already consumed, but let's delay doing anything\n * until we can get out of a tracking frame.\n */\n await Promise.resolve();\n\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this.error = undefined;\n this.isLoading = true;\n\n try {\n await this.retry();\n } catch (e) {\n if (isDestroyed(this) || isDestroying(this)) return;\n\n if (e instanceof Error) {\n this.error = e;\n } else {\n // How likely is this to happen?\n throw e;\n }\n }\n\n if (isDestroyed(this) || isDestroying(this)) {\n return;\n }\n\n this.isLoading = false;\n this.hasRan = true;\n }\n}\n"],"names":["service","emberService","inject","Request","Resource","g","prototype","i","void 0","tracked","modify","positional","named","__REQUEST_FUNCTION__","__WRAPPED_FUNCTION__","_positional","_named","Error","isSuccess","error","isError","Boolean","records","assert","constructor","name","record","retry","waitForPromise","n","action","Promise","resolve","isDestroyed","isDestroying","undefined","isLoading","e","hasRan","waitFor"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export { default } from "ember-data-resources/loose-mode-compat/helpers/find-all";
@@ -0,0 +1 @@
1
+ export { default } from "ember-data-resources/loose-mode-compat/helpers/find-record";
@@ -0,0 +1 @@
1
+ export { default } from "ember-data-resources/loose-mode-compat/helpers/query-record";
@@ -0,0 +1 @@
1
+ export { default } from "ember-data-resources/loose-mode-compat/helpers/query";
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { FindAll } from './-private/resources/find-all.js';
2
+ export { FindRecord } from './-private/resources/find-record.js';
3
+ export { Query } from './-private/resources/query.js';
4
+ export { QueryRecord } from './-private/resources/query-record.js';
5
+ export { findAll, findRecord, query, queryRecord } from './js-helpers.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,97 @@
1
+ import { FindAll } from './-private/resources/find-all.js';
2
+ import { FindRecord } from './-private/resources/find-record.js';
3
+ import { Query } from './-private/resources/query.js';
4
+ import { QueryRecord } from './-private/resources/query-record.js';
5
+
6
+ /* eslint-disable @typescript-eslint/ban-types */
7
+ /**
8
+ * Wrapper around store.findRecord
9
+ */
10
+ function findRecord(destroyable, modelName, thunk) {
11
+ return FindRecord.from(destroyable, () => {
12
+ const reified = thunk();
13
+ let id;
14
+ let options;
15
+ if (Array.isArray(reified)) {
16
+ id = reified[0];
17
+ options = reified[1] ?? {};
18
+ } else {
19
+ id = reified;
20
+ options = {};
21
+ }
22
+ return {
23
+ positional: [modelName, id],
24
+ named: {
25
+ options
26
+ }
27
+ };
28
+ // Cast needed Until min-supported TS is 4.7
29
+ });
30
+ }
31
+ /**
32
+ * Wrapper around store.findAll
33
+ */
34
+ function findAll(destroyable, modelName, thunk) {
35
+ return FindAll.from(destroyable, () => {
36
+ const reified = thunk?.() || {};
37
+ const options = 'options' in reified ? reified.options : reified;
38
+ return {
39
+ positional: [modelName],
40
+ named: {
41
+ options
42
+ }
43
+ };
44
+ // Cast needed Until min-supported TS is 4.7
45
+ });
46
+ }
47
+ /**
48
+ * Wrapper around store.query
49
+ */
50
+ function query(destroyable, modelName, thunk) {
51
+ return Query.from(destroyable, () => {
52
+ const reified = thunk();
53
+ if (Array.isArray(reified)) {
54
+ const [query, options] = reified;
55
+ return {
56
+ positional: [modelName, query],
57
+ named: {
58
+ options: options || {}
59
+ }
60
+ };
61
+ }
62
+ return {
63
+ positional: [modelName, reified],
64
+ named: {
65
+ options: {}
66
+ }
67
+ };
68
+ // Cast needed Until min-supported TS is 4.7
69
+ });
70
+ }
71
+ /**
72
+ * Wrapper around store.queryRecord
73
+ */
74
+ function queryRecord(destroyable, modelName, thunk) {
75
+ return QueryRecord.from(destroyable, () => {
76
+ const reified = thunk();
77
+ if (Array.isArray(reified)) {
78
+ const [query, options] = reified;
79
+ return {
80
+ positional: [modelName, query],
81
+ named: {
82
+ options: options || {}
83
+ }
84
+ };
85
+ }
86
+ return {
87
+ positional: [modelName, reified],
88
+ named: {
89
+ options: {}
90
+ }
91
+ };
92
+ // Cast needed Until min-supported TS is 4.7
93
+ });
94
+ }
95
+
96
+ export { findAll, findRecord, query, queryRecord };
97
+ //# sourceMappingURL=js-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js-helpers.js","sources":["../src/js-helpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport { FindAll } from './-private/resources/find-all.ts';\nimport { FindRecord } from './-private/resources/find-record.ts';\nimport { Query } from './-private/resources/query.ts';\nimport { QueryRecord } from './-private/resources/query-record.ts';\n\nimport type { FindAllOptions } from './-private/resources/find-all';\nimport type { FindRecordOptions } from './-private/resources/find-record';\nimport type { QueryOptions, QueryQuery } from './-private/resources/query';\nimport type { QueryRecordOptions, QueryRecordQuery } from './-private/resources/query-record';\nimport type { Id } from './-private/resources/types';\n\ntype FindRecordThunkResult = Id | [Id] | [Id, FindRecordOptions];\n\n/**\n * Wrapper around store.findRecord\n */\nexport function findRecord<Model = unknown>(\n destroyable: object,\n modelName: string,\n thunk: () => FindRecordThunkResult,\n) {\n return FindRecord.from(destroyable, () => {\n const reified = thunk();\n let id: Id;\n let options: FindRecordOptions;\n\n if (Array.isArray(reified)) {\n id = reified[0];\n options = reified[1] ?? {};\n } else {\n id = reified as Id;\n options = {};\n }\n\n return {\n positional: [modelName, id],\n named: {\n options,\n },\n };\n // Cast needed Until min-supported TS is 4.7\n }) as FindRecord<Model>;\n}\n\ntype FindAllThunkResult = { options: FindAllOptions } | FindAllOptions | void;\n\n/**\n * Wrapper around store.findAll\n */\nexport function findAll<Model = unknown>(\n destroyable: object,\n modelName: string,\n thunk?: () => FindAllThunkResult,\n) {\n return FindAll.from(destroyable, () => {\n const reified = thunk?.() || {};\n const options = 'options' in reified ? reified.options : reified;\n\n return {\n positional: [modelName],\n named: {\n options,\n },\n };\n // Cast needed Until min-supported TS is 4.7\n }) as FindAll<Model>;\n}\n\ntype QueryThunkResult = QueryQuery | [QueryQuery] | [QueryQuery, QueryOptions];\n\n/**\n * Wrapper around store.query\n */\nexport function query<Model = unknown>(\n destroyable: object,\n modelName: string,\n thunk: () => QueryThunkResult,\n) {\n return Query.from(destroyable, () => {\n const reified = thunk();\n\n if (Array.isArray(reified)) {\n const [query, options] = reified;\n\n return {\n positional: [modelName, query],\n named: {\n options: options || {},\n },\n };\n }\n\n return {\n positional: [modelName, reified],\n named: {\n options: {},\n },\n };\n // Cast needed Until min-supported TS is 4.7\n }) as Query<Model>;\n}\n\ntype QueryRecordThunkResult =\n | QueryRecordQuery\n | [QueryRecordQuery]\n | [QueryRecordQuery, QueryRecordOptions];\n\n/**\n * Wrapper around store.queryRecord\n */\nexport function queryRecord<Model = unknown>(\n destroyable: object,\n modelName: string,\n thunk: () => QueryRecordThunkResult,\n) {\n return QueryRecord.from(destroyable, () => {\n const reified = thunk();\n\n if (Array.isArray(reified)) {\n const [query, options] = reified;\n\n return {\n positional: [modelName, query],\n named: {\n options: options || {},\n },\n };\n }\n\n return {\n positional: [modelName, reified],\n named: {\n options: {},\n },\n };\n // Cast needed Until min-supported TS is 4.7\n }) as QueryRecord<Model>;\n}\n"],"names":["findRecord","destroyable","modelName","thunk","FindRecord","from","reified","id","options","Array","isArray","positional","named","findAll","FindAll","query","Query","queryRecord","QueryRecord"],"mappings":"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"}
@@ -0,0 +1,9 @@
1
+ import { FindAll } from '../../-private/resources/find-all.js';
2
+ import '../../-private/resources/find-record.js';
3
+ import '../../-private/resources/query.js';
4
+ import '../../-private/resources/query-record.js';
5
+
6
+
7
+
8
+ export { FindAll as default };
9
+ //# sourceMappingURL=find-all.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-all.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,9 @@
1
+ import '../../-private/resources/find-all.js';
2
+ import { FindRecord } from '../../-private/resources/find-record.js';
3
+ import '../../-private/resources/query.js';
4
+ import '../../-private/resources/query-record.js';
5
+
6
+
7
+
8
+ export { FindRecord as default };
9
+ //# sourceMappingURL=find-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-record.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,9 @@
1
+ import '../../-private/resources/find-all.js';
2
+ import '../../-private/resources/find-record.js';
3
+ import '../../-private/resources/query.js';
4
+ import { QueryRecord } from '../../-private/resources/query-record.js';
5
+
6
+
7
+
8
+ export { QueryRecord as default };
9
+ //# sourceMappingURL=query-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-record.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,9 @@
1
+ import '../../-private/resources/find-all.js';
2
+ import '../../-private/resources/find-record.js';
3
+ import { Query } from '../../-private/resources/query.js';
4
+ import '../../-private/resources/query-record.js';
5
+
6
+
7
+
8
+ export { Query as default };
9
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,7 @@
1
+ export declare class IdRequiredError extends TypeError {
2
+ constructor(modelName: string);
3
+ }
4
+ export declare class IdTypeError extends TypeError {
5
+ constructor(modelName: string, id: unknown);
6
+ }
7
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/-private/resources/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,SAAS,EAAE,MAAM;CAK9B;AAED,qBAAa,WAAY,SAAQ,SAAS;gBAC5B,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO;CAK3C"}
@@ -0,0 +1,19 @@
1
+ import { Request } from './request.ts';
2
+ import type ArrayProxy from '@ember/array/proxy';
3
+ import type Store from '@ember-data/store';
4
+ export type FindAllOptions = Parameters<Store['findAll']>[1];
5
+ type PositionalArgs = [string];
6
+ export interface NamedArgs {
7
+ options: FindAllOptions;
8
+ }
9
+ export interface Args {
10
+ named: NamedArgs;
11
+ positional: PositionalArgs;
12
+ }
13
+ export declare class FindAll<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {
14
+ private _records;
15
+ __WRAPPED_FUNCTION__([modelName]: PositionalArgs, { options }: NamedArgs): Promise<void>;
16
+ get records(): ArrayProxy<Model> | undefined;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=find-all.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-all.d.ts","sourceRoot":"","sources":["../../../src/-private/resources/find-all.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7D,KAAK,cAAc,GAAG,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,qBAAa,OAAO,CAAC,KAAK,EAAE,SAAS,SAAS,IAAI,GAAG,IAAI,CAAE,SAAQ,OAAO,CAAC,SAAS,CAAC;IAC1E,OAAO,CAAC,QAAQ,CAAgC;IAGnD,oBAAoB,CAAC,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9F,IAAI,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,SAAS,CAE3C;CACF"}
@@ -0,0 +1,19 @@
1
+ import { Request } from './request.ts';
2
+ import type { Id } from './types.ts';
3
+ import type Store from '@ember-data/store';
4
+ export type FindRecordOptions = Parameters<Store['findRecord']>[2];
5
+ type PositionalArgs = [string, Id];
6
+ export interface NamedArgs {
7
+ options: FindRecordOptions;
8
+ }
9
+ export interface Args {
10
+ named: NamedArgs;
11
+ positional: PositionalArgs;
12
+ }
13
+ export declare class FindRecord<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {
14
+ private _record;
15
+ __WRAPPED_FUNCTION__([modelName, id]: PositionalArgs, { options }: NamedArgs): Promise<void>;
16
+ get record(): Model | undefined;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=find-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-record.d.ts","sourceRoot":"","sources":["../../../src/-private/resources/find-record.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnE,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnC,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,qBAAa,UAAU,CAAC,KAAK,EAAE,SAAS,SAAS,IAAI,GAAG,IAAI,CAAE,SAAQ,OAAO,CAAC,SAAS,CAAC;IAC7E,OAAO,CAAC,OAAO,CAAoB;IAItC,oBAAoB,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS;IAqBlF,IAAI,MAAM,IAAI,KAAK,GAAG,SAAS,CAE9B;CACF"}
@@ -0,0 +1,20 @@
1
+ import { Request } from './request.ts';
2
+ import type Store from '@ember-data/store';
3
+ type QueryParams = Parameters<Store['queryRecord']>;
4
+ export type QueryRecordQuery = QueryParams[1];
5
+ export type QueryRecordOptions = QueryParams[2];
6
+ type PositionalArgs = [string, QueryRecordQuery];
7
+ export interface NamedArgs {
8
+ options: QueryRecordOptions;
9
+ }
10
+ export interface Args {
11
+ named: NamedArgs;
12
+ positional: PositionalArgs;
13
+ }
14
+ export declare class QueryRecord<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {
15
+ private _record;
16
+ __WRAPPED_FUNCTION__([modelName, query]: PositionalArgs, { options }: NamedArgs): Promise<void>;
17
+ get record(): Model | undefined;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=query-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-record.d.ts","sourceRoot":"","sources":["../../../src/-private/resources/query-record.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,KAAK,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;AACpD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAC9C,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAEhD,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACjD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,qBAAa,WAAW,CAAC,KAAK,EAAE,SAAS,SAAS,IAAI,GAAG,IAAI,CAAE,SAAQ,OAAO,CAAC,SAAS,CAAC;IAC9E,OAAO,CAAC,OAAO,CAAoB;IAGtC,oBAAoB,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS;IAQrF,IAAI,MAAM,IAAI,KAAK,GAAG,SAAS,CAE9B;CACF"}
@@ -0,0 +1,21 @@
1
+ import { Request } from './request.ts';
2
+ import type ArrayProxy from '@ember/array/proxy';
3
+ import type Store from '@ember-data/store';
4
+ type QueryParams = Parameters<Store['query']>;
5
+ export type QueryQuery = QueryParams[1];
6
+ export type QueryOptions = QueryParams[2];
7
+ type PositionalArgs = [string, QueryQuery];
8
+ export interface NamedArgs {
9
+ options: QueryOptions;
10
+ }
11
+ export interface Args {
12
+ named: NamedArgs;
13
+ positional: PositionalArgs;
14
+ }
15
+ export declare class Query<Model, LocalArgs extends Args = Args> extends Request<LocalArgs> {
16
+ private _records;
17
+ __WRAPPED_FUNCTION__([modelName, query]: PositionalArgs, { options }: NamedArgs): Promise<void>;
18
+ get records(): ArrayProxy<Model> | undefined;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/-private/resources/query.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,KAAK,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9C,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAE1C,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC3C,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,qBAAa,KAAK,CAAC,KAAK,EAAE,SAAS,SAAS,IAAI,GAAG,IAAI,CAAE,SAAQ,OAAO,CAAC,SAAS,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAgC;IAGnD,oBAAoB,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS;IAQrF,IAAI,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,SAAS,CAE3C;CACF"}
@@ -0,0 +1,23 @@
1
+ import { Resource } from 'ember-modify-based-class-resource';
2
+ import type Store from '@ember-data/store';
3
+ export type FindRecordOptions = Parameters<Store['findRecord']>[2];
4
+ export declare class Request<Args> extends Resource<Args> {
5
+ store: Store;
6
+ error: Error | undefined;
7
+ isLoading: boolean;
8
+ hasRan: boolean;
9
+ /**
10
+ * Args saved, untracked, for retrying
11
+ */
12
+ positional: unknown[];
13
+ named: object;
14
+ modify(positional?: unknown[], named?: object): void;
15
+ __WRAPPED_FUNCTION__(_positional: unknown[], _named: object): Promise<void>;
16
+ get isSuccess(): boolean;
17
+ get isError(): boolean;
18
+ get records(): unknown | undefined;
19
+ get record(): unknown | undefined;
20
+ retry(): Promise<void>;
21
+ __REQUEST_FUNCTION__(_positional: unknown[], _named: object): Promise<void>;
22
+ }
23
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/-private/resources/request.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnE,qBAAa,OAAO,CAAC,IAAI,CAAE,SAAQ,QAAQ,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IAErB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,SAAS,UAAS;IAClB,MAAM,UAAS;IAExB;;OAEG;IACK,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IAEtB,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM;IAevC,oBAAoB,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM;IAIjE,IAAI,SAAS,YAEZ;IAED,IAAI,OAAO,YAEV;IAED,IAAI,OAAO,IAAI,OAAO,GAAG,SAAS,CAKjC;IAED,IAAI,MAAM,IAAI,OAAO,GAAG,SAAS,CAKhC;IAGK,KAAK;IAML,oBAAoB,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM;CAgClE"}
@@ -0,0 +1,2 @@
1
+ export type Id = string | number | null | undefined;
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/-private/resources/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { FindAll } from './-private/resources/find-all.ts';
2
+ export { FindRecord } from './-private/resources/find-record.ts';
3
+ export { Query } from './-private/resources/query.ts';
4
+ export { QueryRecord } from './-private/resources/query-record.ts';
5
+ export { findAll, findRecord, query, queryRecord } from './js-helpers.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { FindAll } from './-private/resources/find-all.ts';
2
+ import { FindRecord } from './-private/resources/find-record.ts';
3
+ import { Query } from './-private/resources/query.ts';
4
+ import { QueryRecord } from './-private/resources/query-record.ts';
5
+ import type { FindAllOptions } from './-private/resources/find-all';
6
+ import type { FindRecordOptions } from './-private/resources/find-record';
7
+ import type { QueryOptions, QueryQuery } from './-private/resources/query';
8
+ import type { QueryRecordOptions, QueryRecordQuery } from './-private/resources/query-record';
9
+ import type { Id } from './-private/resources/types';
10
+ type FindRecordThunkResult = Id | [Id] | [Id, FindRecordOptions];
11
+ /**
12
+ * Wrapper around store.findRecord
13
+ */
14
+ export declare function findRecord<Model = unknown>(destroyable: object, modelName: string, thunk: () => FindRecordThunkResult): FindRecord<Model, import("./-private/resources/find-record.ts").Args>;
15
+ type FindAllThunkResult = {
16
+ options: FindAllOptions;
17
+ } | FindAllOptions | void;
18
+ /**
19
+ * Wrapper around store.findAll
20
+ */
21
+ export declare function findAll<Model = unknown>(destroyable: object, modelName: string, thunk?: () => FindAllThunkResult): FindAll<Model, import("./-private/resources/find-all.ts").Args>;
22
+ type QueryThunkResult = QueryQuery | [QueryQuery] | [QueryQuery, QueryOptions];
23
+ /**
24
+ * Wrapper around store.query
25
+ */
26
+ export declare function query<Model = unknown>(destroyable: object, modelName: string, thunk: () => QueryThunkResult): Query<Model, import("./-private/resources/query.ts").Args>;
27
+ type QueryRecordThunkResult = QueryRecordQuery | [QueryRecordQuery] | [QueryRecordQuery, QueryRecordOptions];
28
+ /**
29
+ * Wrapper around store.queryRecord
30
+ */
31
+ export declare function queryRecord<Model = unknown>(destroyable: object, modelName: string, thunk: () => QueryRecordThunkResult): QueryRecord<Model, import("./-private/resources/query-record.ts").Args>;
32
+ export {};
33
+ //# sourceMappingURL=js-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js-helpers.d.ts","sourceRoot":"","sources":["../src/js-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAErD,KAAK,qBAAqB,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAEjE;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,GAAG,OAAO,EACxC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,qBAAqB,yEAuBnC;AAED,KAAK,kBAAkB,GAAG;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,GAAG,cAAc,GAAG,IAAI,CAAC;AAE9E;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,GAAG,OAAO,EACrC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,kBAAkB,mEAcjC;AAED,KAAK,gBAAgB,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAE/E;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,GAAG,OAAO,EACnC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,gBAAgB,8DAwB9B;AAED,KAAK,sBAAsB,GACvB,gBAAgB,GAChB,CAAC,gBAAgB,CAAC,GAClB,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AAE3C;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,GAAG,OAAO,EACzC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,sBAAsB,2EAwBpC"}
@@ -0,0 +1,3 @@
1
+ export default FindAll;
2
+ import { FindAll } from '../../index.ts';
3
+ //# sourceMappingURL=find-all.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-all.d.ts","sourceRoot":"","sources":["../../../src/loose-mode-compat/helpers/find-all.js"],"names":[],"mappings":";wBAAwB,gBAAgB"}
@@ -0,0 +1,3 @@
1
+ export default FindRecord;
2
+ import { FindRecord } from '../../index.ts';
3
+ //# sourceMappingURL=find-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-record.d.ts","sourceRoot":"","sources":["../../../src/loose-mode-compat/helpers/find-record.js"],"names":[],"mappings":";2BAA2B,gBAAgB"}
@@ -0,0 +1,3 @@
1
+ export default QueryRecord;
2
+ import { QueryRecord } from '../../index.ts';
3
+ //# sourceMappingURL=query-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-record.d.ts","sourceRoot":"","sources":["../../../src/loose-mode-compat/helpers/query-record.js"],"names":[],"mappings":";4BAA4B,gBAAgB"}
@@ -0,0 +1,3 @@
1
+ export default Query;
2
+ import { Query } from '../../index.ts';
3
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/loose-mode-compat/helpers/query.js"],"names":[],"mappings":";sBAAsB,gBAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-data-resources",
3
- "version": "5.2.2",
3
+ "version": "5.3.0",
4
4
  "description": "Resource helpers for reactively (re)fetching data with ember-data",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -17,6 +17,7 @@
17
17
  "@ember/string": "^3.1.1",
18
18
  "@ember/test-waiters": "^3.1.0",
19
19
  "@embroider/addon-shim": "^1.0.0",
20
+ "decorator-transforms": "^2.3.0",
20
21
  "ember-modify-based-class-resource": "^1.1.0"
21
22
  },
22
23
  "devDependencies": {
@@ -28,13 +29,15 @@
28
29
  "@babel/runtime": "^7.22.5",
29
30
  "@ember-data/store": "^5.0.0",
30
31
  "@ember-data/tracking": "^5.3.0",
31
- "@embroider/addon-dev": "^3.1.1",
32
+ "@ember/library-tsconfig": "^1.1.3",
33
+ "@embroider/addon-dev": "^8.0.0",
32
34
  "@glimmer/component": "^1.1.2",
33
35
  "@glimmer/tracking": "^1.1.2",
34
36
  "@glint/core": "^1.3.0",
35
37
  "@glint/environment-ember-loose": "^1.0.2",
36
38
  "@glint/template": "^1.0.2",
37
39
  "@nullvoxpopuli/eslint-configs": "^3.1.3",
40
+ "@rollup/plugin-babel": "^6.0.4",
38
41
  "@tsconfig/ember": "^3.0.3",
39
42
  "@types/ember": "^4.0.0",
40
43
  "@types/ember-data__store": "^4.0.3",
@@ -57,7 +60,7 @@
57
60
  "@types/ember__utils": "^4.0.0",
58
61
  "@typescript-eslint/eslint-plugin": "^6.19.0",
59
62
  "@typescript-eslint/parser": "^6.19.0",
60
- "concurrently": "^8.2.0",
63
+ "concurrently": "^9.1.2",
61
64
  "ember-resources": "^6.0.0",
62
65
  "ember-source": "~5.6.0",
63
66
  "ember-template-lint": "^5.10.3",
@@ -68,13 +71,12 @@
68
71
  "eslint-plugin-prettier": "^5.1.3",
69
72
  "eslint-plugin-qunit": "^8.0.1",
70
73
  "execa": "^8.0.1",
71
- "prettier": "^3.2.4",
72
- "prettier-plugin-ember-template-tag": "^2.0.0",
74
+ "prettier": "^3.5.3",
75
+ "prettier-plugin-ember-template-tag": "^2.0.5",
73
76
  "publint": "^0.2.7",
74
- "rollup": "~4.11.0",
77
+ "rollup": "~4.40.2",
75
78
  "rollup-plugin-copy": "^3.5.0",
76
79
  "rollup-plugin-delete": "^2.0.0",
77
- "rollup-plugin-ts": "^3.4.5",
78
80
  "typescript": "^5.3.3"
79
81
  },
80
82
  "publishConfig": {
@@ -123,9 +125,7 @@
123
125
  "ember-source": "^3.25.0 || >=4.0.0"
124
126
  },
125
127
  "scripts": {
126
- "build": "concurrently 'npm:build:*'",
127
- "build:js": "rollup --config",
128
- "build:types": "rm -rf dist-types; pnpm glint --build",
128
+ "build": "rollup --config",
129
129
  "lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
130
130
  "lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
131
131
  "lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",