ember-data-resources 2.0.8 → 2.1.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.
@@ -67,7 +67,6 @@ jobs:
67
67
  if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
68
68
  name: Tooling
69
69
  runs-on: ubuntu-latest
70
- needs: [install_dependencies]
71
70
 
72
71
  steps:
73
72
  - uses: actions/checkout@v2
@@ -77,9 +76,10 @@ jobs:
77
76
  path: '**/node_modules'
78
77
  key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
79
78
 
79
+ - run: yarn install
80
+
80
81
  - name: Semantic Release
81
82
  run: yarn semantic-release --dry-run
82
- working-directory: ./ember-resources
83
83
  env:
84
84
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
85
85
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.1.0](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.8...v2.1.0) (2022-01-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @ember/test-waiters to ^3.0.1 ([eea91c5](https://github.com/NullVoxPopuli/ember-data-resources/commit/eea91c55e07ed3860321883309645ace99b86e9a))
7
+ * **deps:** update dependency ember-cli-babel to ^7.26.11 ([89688e2](https://github.com/NullVoxPopuli/ember-data-resources/commit/89688e2d74e8ccbc50f4040c9a4b11f86be0f82c))
8
+ * **deps:** update dependency ember-resources to ^4.1.3 ([d76e599](https://github.com/NullVoxPopuli/ember-data-resources/commit/d76e599b5c153009fed52ac7aa739b51cd52fad7))
9
+
10
+
11
+ ### Features
12
+
13
+ * support strict-mode ([33c3411](https://github.com/NullVoxPopuli/ember-data-resources/commit/33c341116947bb3466c296a94a7b0ff71c8d0de0))
14
+
1
15
  ## [2.0.8](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.7...v2.0.8) (2021-12-17)
2
16
 
3
17
 
package/README.md CHANGED
@@ -68,6 +68,20 @@ Available methods:
68
68
  {{/let}}
69
69
  ```
70
70
 
71
+ **in strict mode**
72
+
73
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
74
+
75
+ ```jsx
76
+ import { FindAll } from 'ember-data-resources';
77
+
78
+ <template>
79
+ {{#let (FindAll 'blog') as |blogs|}}
80
+ ...
81
+ {{/let}}
82
+ </template>
83
+ ```
84
+
71
85
  ### `findRecord`
72
86
 
73
87
  ```js
@@ -120,6 +134,19 @@ Available methods:
120
134
  {{/let}}
121
135
  ```
122
136
 
137
+ **in strict mode**
138
+
139
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
140
+
141
+ ```jsx
142
+ import { FindRecord } from 'ember-data-resources';
143
+
144
+ <template>
145
+ {{#let (FindRecord 'blog' @id) as |blog|}}
146
+ ...
147
+ {{/let}}
148
+ </template>
149
+ ```
123
150
 
124
151
  ### `query`
125
152
 
@@ -170,6 +197,21 @@ Available methods:
170
197
  {{/let}}
171
198
  ```
172
199
 
200
+ **in strict mode**
201
+
202
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
203
+
204
+ ```jsx
205
+ import { Query } from 'ember-data-resources';
206
+
207
+ <template>
208
+ {{#let (Query 'blog' query=(hash ...)) as |blogs|}}
209
+ ...
210
+ {{/let}}
211
+ </template>
212
+ ```
213
+
214
+
173
215
  ### `queryRecord`
174
216
 
175
217
  ```js
@@ -222,6 +264,20 @@ Available methods:
222
264
  {{/let}}
223
265
  ```
224
266
 
267
+ **in strict mode**
268
+
269
+ See: [First-class Component Templates](https://github.com/emberjs/rfcs/pull/779)
270
+
271
+ ```jsx
272
+ import { QueryRecord } from 'ember-data-resources';
273
+
274
+ <template>
275
+ {{#let (QueryRecord 'blog' query=(hash ...)) as |blog|}}
276
+ ...
277
+ {{/let}}
278
+ </template>
279
+ ```
280
+
225
281
  Contributing
226
282
  ------------------------------------------------------------------------------
227
283
 
package/addon/index.ts CHANGED
@@ -1,125 +1,10 @@
1
- /* eslint-disable @typescript-eslint/ban-types */
2
- import { useResource } from 'ember-resources';
3
-
4
- import { FindAll } from './-private/resources/find-all';
5
- import { FindRecord } from './-private/resources/find-record';
6
- import { Query } from './-private/resources/query';
7
- import { QueryRecord } from './-private/resources/query-record';
8
-
9
- import type { FindAllOptions } from './-private/resources/find-all';
10
- import type { FindRecordOptions } from './-private/resources/find-record';
11
- import type { QueryOptions, QueryQuery } from './-private/resources/query';
12
- import type { QueryRecordOptions, QueryRecordQuery } from './-private/resources/query-record';
13
- import type { Id } from './-private/resources/types';
14
-
15
- type FindRecordThunkResult = Id | [Id] | [Id, FindRecordOptions];
16
-
17
- export function findRecord<Model = unknown>(
18
- destroyable: object,
19
- modelName: string,
20
- thunk: () => FindRecordThunkResult
21
- ) {
22
- return useResource<FindRecord<Model>>(destroyable, FindRecord, () => {
23
- let reified = thunk();
24
- let id: Id | undefined = undefined;
25
- let options: FindRecordOptions;
26
-
27
- if (typeof reified === 'number') {
28
- id = reified;
29
- options = {};
30
- } else if (Array.isArray(options)) {
31
- id = options[0];
32
- options = options[1] || {};
33
- }
34
-
35
- return {
36
- positional: [modelName, id],
37
- named: {
38
- options,
39
- },
40
- };
41
- });
42
- }
43
-
44
- type FindAllThunkResult = { options: FindAllOptions } | FindAllOptions | void;
45
-
46
- export function findAll<Model = unknown>(
47
- destroyable: object,
48
- modelName: string,
49
- thunk?: () => FindAllThunkResult
50
- ) {
51
- return useResource<FindAll<Model>>(destroyable, FindAll, () => {
52
- let reified = thunk?.() || {};
53
- let options = 'options' in reified ? reified.options : reified;
54
-
55
- return {
56
- positional: [modelName],
57
- named: {
58
- options,
59
- },
60
- };
61
- });
62
- }
63
-
64
- type QueryThunkResult = QueryQuery | [QueryQuery] | [QueryQuery, QueryOptions];
65
-
66
- export function query<Model = unknown>(
67
- destroyable: object,
68
- modelName: string,
69
- thunk: () => QueryThunkResult
70
- ) {
71
- return useResource<Query<Model>>(destroyable, Query, () => {
72
- let reified = thunk();
73
-
74
- if (Array.isArray(reified)) {
75
- let [query, options] = reified;
76
-
77
- return {
78
- positional: [modelName, query],
79
- named: {
80
- options: options || {},
81
- },
82
- };
83
- }
84
-
85
- return {
86
- positional: [modelName, reified],
87
- named: {
88
- options: {},
89
- },
90
- };
91
- });
92
- }
93
-
94
- type QueryRecordThunkResult =
95
- | QueryRecordQuery
96
- | [QueryRecordQuery]
97
- | [QueryRecordQuery, QueryRecordOptions];
98
-
99
- export function queryRecord<Model = unknown>(
100
- destroyable: object,
101
- modelName: string,
102
- thunk: () => QueryRecordThunkResult
103
- ) {
104
- return useResource<QueryRecord<Model>>(destroyable, QueryRecord, () => {
105
- let reified = thunk();
106
-
107
- if (Array.isArray(reified)) {
108
- let [query, options] = reified;
109
-
110
- return {
111
- positional: [modelName, query],
112
- named: {
113
- options: options || {},
114
- },
115
- };
116
- }
117
-
118
- return {
119
- positional: [modelName, reified],
120
- named: {
121
- options: {},
122
- },
123
- };
124
- });
125
- }
1
+ // For direct use in templates' strict Mode
2
+ // for loose mode, these don't need to be imported, and are resolveable via
3
+ // the lower-kebab-case variant of each of these names
4
+ export { FindAll } from './-private/resources/find-all';
5
+ export { FindRecord } from './-private/resources/find-record';
6
+ export { Query } from './-private/resources/query';
7
+ export { QueryRecord } from './-private/resources/query-record';
8
+
9
+ // Resource wrappers in JS/TS classes
10
+ export { findAll, findRecord, query, queryRecord } from './js-helpers';
@@ -0,0 +1,125 @@
1
+ /* eslint-disable @typescript-eslint/ban-types */
2
+ import { useResource } from 'ember-resources';
3
+
4
+ import { FindAll } from './-private/resources/find-all';
5
+ import { FindRecord } from './-private/resources/find-record';
6
+ import { Query } from './-private/resources/query';
7
+ import { QueryRecord } from './-private/resources/query-record';
8
+
9
+ import type { FindAllOptions } from './-private/resources/find-all';
10
+ import type { FindRecordOptions } from './-private/resources/find-record';
11
+ import type { QueryOptions, QueryQuery } from './-private/resources/query';
12
+ import type { QueryRecordOptions, QueryRecordQuery } from './-private/resources/query-record';
13
+ import type { Id } from './-private/resources/types';
14
+
15
+ type FindRecordThunkResult = Id | [Id] | [Id, FindRecordOptions];
16
+
17
+ export function findRecord<Model = unknown>(
18
+ destroyable: object,
19
+ modelName: string,
20
+ thunk: () => FindRecordThunkResult
21
+ ) {
22
+ return useResource<FindRecord<Model>>(destroyable, FindRecord, () => {
23
+ let reified = thunk();
24
+ let id: Id | undefined = undefined;
25
+ let options: FindRecordOptions;
26
+
27
+ if (typeof reified === 'number') {
28
+ id = reified;
29
+ options = {};
30
+ } else if (Array.isArray(options)) {
31
+ id = options[0];
32
+ options = options[1] || {};
33
+ }
34
+
35
+ return {
36
+ positional: [modelName, id],
37
+ named: {
38
+ options,
39
+ },
40
+ };
41
+ });
42
+ }
43
+
44
+ type FindAllThunkResult = { options: FindAllOptions } | FindAllOptions | void;
45
+
46
+ export function findAll<Model = unknown>(
47
+ destroyable: object,
48
+ modelName: string,
49
+ thunk?: () => FindAllThunkResult
50
+ ) {
51
+ return useResource<FindAll<Model>>(destroyable, FindAll, () => {
52
+ let reified = thunk?.() || {};
53
+ let options = 'options' in reified ? reified.options : reified;
54
+
55
+ return {
56
+ positional: [modelName],
57
+ named: {
58
+ options,
59
+ },
60
+ };
61
+ });
62
+ }
63
+
64
+ type QueryThunkResult = QueryQuery | [QueryQuery] | [QueryQuery, QueryOptions];
65
+
66
+ export function query<Model = unknown>(
67
+ destroyable: object,
68
+ modelName: string,
69
+ thunk: () => QueryThunkResult
70
+ ) {
71
+ return useResource<Query<Model>>(destroyable, Query, () => {
72
+ let reified = thunk();
73
+
74
+ if (Array.isArray(reified)) {
75
+ let [query, options] = reified;
76
+
77
+ return {
78
+ positional: [modelName, query],
79
+ named: {
80
+ options: options || {},
81
+ },
82
+ };
83
+ }
84
+
85
+ return {
86
+ positional: [modelName, reified],
87
+ named: {
88
+ options: {},
89
+ },
90
+ };
91
+ });
92
+ }
93
+
94
+ type QueryRecordThunkResult =
95
+ | QueryRecordQuery
96
+ | [QueryRecordQuery]
97
+ | [QueryRecordQuery, QueryRecordOptions];
98
+
99
+ export function queryRecord<Model = unknown>(
100
+ destroyable: object,
101
+ modelName: string,
102
+ thunk: () => QueryRecordThunkResult
103
+ ) {
104
+ return useResource<QueryRecord<Model>>(destroyable, QueryRecord, () => {
105
+ let reified = thunk();
106
+
107
+ if (Array.isArray(reified)) {
108
+ let [query, options] = reified;
109
+
110
+ return {
111
+ positional: [modelName, query],
112
+ named: {
113
+ options: options || {},
114
+ },
115
+ };
116
+ }
117
+
118
+ return {
119
+ positional: [modelName, reified],
120
+ named: {
121
+ options: {},
122
+ },
123
+ };
124
+ });
125
+ }
package/index.d.ts CHANGED
@@ -1,20 +1,5 @@
1
- import { FindAll } from './-private/resources/find-all';
2
- import { FindRecord } from './-private/resources/find-record';
3
- import { Query } from './-private/resources/query';
4
- import { QueryRecord } from './-private/resources/query-record';
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
- declare type FindRecordThunkResult = Id | [Id] | [Id, FindRecordOptions];
11
- export declare function findRecord<Model = unknown>(destroyable: object, modelName: string, thunk: () => FindRecordThunkResult): FindRecord<Model, import("./-private/resources/find-record").Args>;
12
- declare type FindAllThunkResult = {
13
- options: FindAllOptions;
14
- } | FindAllOptions | void;
15
- export declare function findAll<Model = unknown>(destroyable: object, modelName: string, thunk?: () => FindAllThunkResult): FindAll<Model, import("./-private/resources/find-all").Args>;
16
- declare type QueryThunkResult = QueryQuery | [QueryQuery] | [QueryQuery, QueryOptions];
17
- export declare function query<Model = unknown>(destroyable: object, modelName: string, thunk: () => QueryThunkResult): Query<Model, import("./-private/resources/query").Args>;
18
- declare type QueryRecordThunkResult = QueryRecordQuery | [QueryRecordQuery] | [QueryRecordQuery, QueryRecordOptions];
19
- export declare function queryRecord<Model = unknown>(destroyable: object, modelName: string, thunk: () => QueryRecordThunkResult): QueryRecord<Model, import("./-private/resources/query-record").Args>;
20
- export {};
1
+ export { FindAll } from './-private/resources/find-all';
2
+ export { FindRecord } from './-private/resources/find-record';
3
+ export { Query } from './-private/resources/query';
4
+ export { QueryRecord } from './-private/resources/query-record';
5
+ export { findAll, findRecord, query, queryRecord } from './js-helpers';
@@ -0,0 +1,20 @@
1
+ import { FindAll } from './-private/resources/find-all';
2
+ import { FindRecord } from './-private/resources/find-record';
3
+ import { Query } from './-private/resources/query';
4
+ import { QueryRecord } from './-private/resources/query-record';
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
+ declare type FindRecordThunkResult = Id | [Id] | [Id, FindRecordOptions];
11
+ export declare function findRecord<Model = unknown>(destroyable: object, modelName: string, thunk: () => FindRecordThunkResult): FindRecord<Model, import("./-private/resources/find-record").Args>;
12
+ declare type FindAllThunkResult = {
13
+ options: FindAllOptions;
14
+ } | FindAllOptions | void;
15
+ export declare function findAll<Model = unknown>(destroyable: object, modelName: string, thunk?: () => FindAllThunkResult): FindAll<Model, import("./-private/resources/find-all").Args>;
16
+ declare type QueryThunkResult = QueryQuery | [QueryQuery] | [QueryQuery, QueryOptions];
17
+ export declare function query<Model = unknown>(destroyable: object, modelName: string, thunk: () => QueryThunkResult): Query<Model, import("./-private/resources/query").Args>;
18
+ declare type QueryRecordThunkResult = QueryRecordQuery | [QueryRecordQuery] | [QueryRecordQuery, QueryRecordOptions];
19
+ export declare function queryRecord<Model = unknown>(destroyable: object, modelName: string, thunk: () => QueryRecordThunkResult): QueryRecord<Model, import("./-private/resources/query-record").Args>;
20
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-data-resources",
3
- "version": "2.0.8",
3
+ "version": "2.1.0",
4
4
  "description": "Resource helpers for reactively (re)fetching data with ember-data",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -28,22 +28,22 @@
28
28
  "postpack": "ember ts:clean"
29
29
  },
30
30
  "dependencies": {
31
- "@ember/test-waiters": "^3.0.0",
31
+ "@ember/test-waiters": "^3.0.1",
32
32
  "@glimmer/tracking": "^1.0.4",
33
33
  "ember-auto-import": "^2.2.4",
34
- "ember-cli-babel": "^7.26.10",
34
+ "ember-cli-babel": "^7.26.11",
35
35
  "ember-cli-htmlbars": "^6.0.1",
36
36
  "ember-cli-typescript": "^4.2.1",
37
- "ember-resources": "^4.1.2"
37
+ "ember-resources": "^4.1.3"
38
38
  },
39
39
  "devDependencies": {
40
- "@commitlint/cli": "^15.0.0",
41
- "@commitlint/config-conventional": "^15.0.0",
40
+ "@commitlint/cli": "^16.0.1",
41
+ "@commitlint/config-conventional": "^16.0.0",
42
42
  "@ember/optional-features": "^2.0.0",
43
43
  "@ember/test-helpers": "^2.6.0",
44
- "@embroider/test-setup": "^0.48.1",
44
+ "@embroider/test-setup": "^0.50.0",
45
45
  "@glimmer/component": "^1.0.4",
46
- "@nullvoxpopuli/eslint-configs": "^2.1.12",
46
+ "@nullvoxpopuli/eslint-configs": "^2.1.16",
47
47
  "@semantic-release/changelog": "^5.0.1",
48
48
  "@semantic-release/git": "^9.0.1",
49
49
  "@types/ember-data__model": "^3.16.2",
@@ -70,17 +70,17 @@
70
70
  "@types/htmlbars-inline-precompile": "^1.0.1",
71
71
  "@types/qunit": "^2.11.2",
72
72
  "@types/rsvp": "^4.0.4",
73
- "@typescript-eslint/eslint-plugin": "^5.6.0",
74
- "@typescript-eslint/parser": "^5.6.0",
73
+ "@typescript-eslint/eslint-plugin": "^5.8.1",
74
+ "@typescript-eslint/parser": "^5.8.1",
75
75
  "babel-eslint": "^10.1.0",
76
76
  "broccoli-asset-rev": "^3.0.0",
77
- "ember-cli": "~3.28.4",
77
+ "ember-cli": "~4.1.0",
78
78
  "ember-cli-dependency-checker": "^3.2.0",
79
79
  "ember-cli-inject-live-reload": "^2.1.0",
80
80
  "ember-cli-sri": "^2.1.1",
81
81
  "ember-cli-terser": "^4.0.2",
82
82
  "ember-cli-typescript-blueprints": "^3.0.0",
83
- "ember-data": "^4.0.2",
83
+ "ember-data": "^4.1.0",
84
84
  "ember-disable-prototype-extensions": "^1.1.3",
85
85
  "ember-export-application-global": "^2.0.1",
86
86
  "ember-load-initializers": "^2.1.2",
@@ -88,18 +88,18 @@
88
88
  "ember-page-title": "^7.0.0",
89
89
  "ember-qunit": "^5.1.5",
90
90
  "ember-resolver": "^8.0.3",
91
- "ember-source": "~4.0.1",
91
+ "ember-source": "~4.1.0",
92
92
  "ember-source-channel-url": "^3.0.0",
93
- "ember-template-lint": "^3.14.0",
93
+ "ember-template-lint": "^3.15.0",
94
94
  "ember-try": "^2.0.0",
95
- "eslint": "^8.4.1",
95
+ "eslint": "^8.6.0",
96
96
  "eslint-config-prettier": "^8.3.0",
97
97
  "eslint-plugin-decorator-position": "^4.0.1",
98
98
  "eslint-plugin-ember": "^10.5.8",
99
- "eslint-plugin-import": "^2.25.3",
99
+ "eslint-plugin-import": "^2.25.4",
100
100
  "eslint-plugin-node": "^11.1.0",
101
101
  "eslint-plugin-prettier": "^4.0.0",
102
- "eslint-plugin-qunit": "^7.1.0",
102
+ "eslint-plugin-qunit": "^7.2.0",
103
103
  "eslint-plugin-simple-import-sort": "^7.0.0",
104
104
  "loader.js": "^4.7.0",
105
105
  "msw": "^0.36.3",