ember-data-resources 2.1.0 → 3.0.3
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.
- package/-private/resources/errors.d.ts +4 -1
- package/.github/workflows/ci.yml +4 -23
- package/.github/workflows/lint.yml +2 -0
- package/CHANGELOG.md +33 -0
- package/addon/-private/resources/errors.ts +9 -1
- package/addon/-private/resources/find-record.ts +3 -1
- package/addon/js-helpers.ts +6 -6
- package/package.json +18 -18
package/.github/workflows/ci.yml
CHANGED
|
@@ -21,8 +21,8 @@ jobs:
|
|
|
21
21
|
strategy:
|
|
22
22
|
matrix:
|
|
23
23
|
node:
|
|
24
|
-
- "12"
|
|
25
24
|
- "14"
|
|
25
|
+
- "16"
|
|
26
26
|
steps:
|
|
27
27
|
- uses: actions/checkout@v2
|
|
28
28
|
- uses: volta-cli/action@v1
|
|
@@ -68,41 +68,22 @@ jobs:
|
|
|
68
68
|
matrix:
|
|
69
69
|
ember-try-scenario:
|
|
70
70
|
- ember-3.25
|
|
71
|
+
- ember-3.28-lts
|
|
71
72
|
- ember-release
|
|
72
73
|
- ember-beta
|
|
73
|
-
|
|
74
|
-
# - ember-canary
|
|
75
|
-
# disabled because support will be added later, and it doesn't work yet
|
|
76
|
-
# - ember-data does not support embroider(optimized) yet
|
|
77
|
-
# - store service is missing
|
|
74
|
+
- ember-canary
|
|
78
75
|
# - embroider-safe
|
|
79
76
|
# - embroider-optimized
|
|
80
77
|
steps:
|
|
81
78
|
- uses: actions/checkout@v2
|
|
82
79
|
- uses: volta-cli/action@v1
|
|
83
80
|
with:
|
|
84
|
-
node-version:
|
|
81
|
+
node-version: 14.x
|
|
85
82
|
- name: install dependencies
|
|
86
83
|
run: yarn install
|
|
87
84
|
- name: test
|
|
88
85
|
run: node_modules/.bin/ember try:one ${{ matrix.ember-try-scenario }} --skip-cleanup
|
|
89
86
|
|
|
90
|
-
ember-cli-update:
|
|
91
|
-
if: "github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && ( ! contains(toJSON(github.event.commits.*.message), '[skip ci]') )"
|
|
92
|
-
runs-on: ubuntu-latest
|
|
93
|
-
needs: [tests, try-scenarios]
|
|
94
|
-
|
|
95
|
-
steps:
|
|
96
|
-
- uses: actions/checkout@v2
|
|
97
|
-
with:
|
|
98
|
-
ref: ${{ github.head_ref }}
|
|
99
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
|
100
|
-
- uses: volta-cli/action@v1
|
|
101
|
-
- uses: kellyselden/ember-cli-update-action@v3
|
|
102
|
-
with:
|
|
103
|
-
autofix_command: yarn lint:fix
|
|
104
|
-
ignore_to: true
|
|
105
|
-
|
|
106
87
|
publish:
|
|
107
88
|
name: Release
|
|
108
89
|
runs-on: ubuntu-latest
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## [3.0.3](https://github.com/NullVoxPopuli/ember-data-resources/compare/v3.0.2...v3.0.3) (2022-01-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency ember-auto-import to ^2.4.0 ([b867f76](https://github.com/NullVoxPopuli/ember-data-resources/commit/b867f7669c79aff6eeb92e12dfde2614420b921a))
|
|
7
|
+
|
|
8
|
+
## [3.0.2](https://github.com/NullVoxPopuli/ember-data-resources/compare/v3.0.1...v3.0.2) (2022-01-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **findRecord:** allow string ids, and fix array thunk usage ([1eeafb4](https://github.com/NullVoxPopuli/ember-data-resources/commit/1eeafb4a73791f7a0dba9bc82787cabee82f604b)), closes [PR#227](https://github.com/PR/issues/227)
|
|
14
|
+
|
|
15
|
+
## [3.0.1](https://github.com/NullVoxPopuli/ember-data-resources/compare/v3.0.0...v3.0.1) (2022-01-15)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **deps:** update dependency ember-auto-import to ^2.3.0 ([9798244](https://github.com/NullVoxPopuli/ember-data-resources/commit/9798244b243ef7a2186c35ab592fa7fc30255b22))
|
|
21
|
+
|
|
22
|
+
# [3.0.0](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.1.0...v3.0.0) (2022-01-08)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### chore
|
|
26
|
+
|
|
27
|
+
* change node support, add 16, drop 12 ([a4b4404](https://github.com/NullVoxPopuli/ember-data-resources/commit/a4b44042341d462afc9a2271fd90e5d824f7c06d))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### BREAKING CHANGES
|
|
31
|
+
|
|
32
|
+
* node 12 is no longer supported
|
|
33
|
+
|
|
1
34
|
# [2.1.0](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.8...v2.1.0) (2022-01-08)
|
|
2
35
|
|
|
3
36
|
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
export class IdRequiredError extends
|
|
1
|
+
export class IdRequiredError extends TypeError {
|
|
2
2
|
constructor(modelName: string) {
|
|
3
3
|
super(
|
|
4
4
|
`While trying to request a resource from ${modelName}, the ID was either null or undefined, and the ID is required for fetching resources`
|
|
5
5
|
);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export class IdTypeError extends TypeError {
|
|
10
|
+
constructor(modelName: string, id: unknown) {
|
|
11
|
+
super(
|
|
12
|
+
`While trying to request a resource from ${modelName}, the ID was of invalid type ${typeof id}: only string and number are supported`
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -2,7 +2,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
2
2
|
import { isDestroyed, isDestroying } from '@ember/destroyable';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
|
|
5
|
-
import { IdRequiredError } from './errors';
|
|
5
|
+
import { IdRequiredError, IdTypeError } from './errors';
|
|
6
6
|
import { Request } from './request';
|
|
7
7
|
|
|
8
8
|
import type { Id } from './types';
|
|
@@ -37,6 +37,8 @@ export class FindRecord<Model, LocalArgs extends Args = Args> extends Request<Lo
|
|
|
37
37
|
*/
|
|
38
38
|
if (id === null || id === undefined) {
|
|
39
39
|
throw new IdRequiredError(modelName);
|
|
40
|
+
} else if (typeof id !== 'string' && typeof id !== 'number') {
|
|
41
|
+
throw new IdTypeError(modelName, id);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
let record = await this.store.findRecord(modelName as never, id, options);
|
package/addon/js-helpers.ts
CHANGED
|
@@ -21,15 +21,15 @@ export function findRecord<Model = unknown>(
|
|
|
21
21
|
) {
|
|
22
22
|
return useResource<FindRecord<Model>>(destroyable, FindRecord, () => {
|
|
23
23
|
let reified = thunk();
|
|
24
|
-
let id: Id
|
|
24
|
+
let id: Id;
|
|
25
25
|
let options: FindRecordOptions;
|
|
26
26
|
|
|
27
|
-
if (
|
|
28
|
-
id = reified;
|
|
27
|
+
if (Array.isArray(reified)) {
|
|
28
|
+
id = reified[0];
|
|
29
|
+
options = reified[1] ?? {};
|
|
30
|
+
} else {
|
|
31
|
+
id = reified as Id;
|
|
29
32
|
options = {};
|
|
30
|
-
} else if (Array.isArray(options)) {
|
|
31
|
-
id = options[0];
|
|
32
|
-
options = options[1] || {};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-data-resources",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Resource helpers for reactively (re)fetching data with ember-data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -30,22 +30,22 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ember/test-waiters": "^3.0.1",
|
|
32
32
|
"@glimmer/tracking": "^1.0.4",
|
|
33
|
-
"ember-auto-import": "^2.
|
|
33
|
+
"ember-auto-import": "^2.4.0",
|
|
34
34
|
"ember-cli-babel": "^7.26.11",
|
|
35
35
|
"ember-cli-htmlbars": "^6.0.1",
|
|
36
36
|
"ember-cli-typescript": "^4.2.1",
|
|
37
37
|
"ember-resources": "^4.1.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@commitlint/cli": "^16.0.
|
|
40
|
+
"@commitlint/cli": "^16.0.2",
|
|
41
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.
|
|
44
|
+
"@embroider/test-setup": "^1.0.0",
|
|
45
45
|
"@glimmer/component": "^1.0.4",
|
|
46
|
-
"@nullvoxpopuli/eslint-configs": "^2.1.
|
|
47
|
-
"@semantic-release/changelog": "^
|
|
48
|
-
"@semantic-release/git": "^
|
|
46
|
+
"@nullvoxpopuli/eslint-configs": "^2.1.18",
|
|
47
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
48
|
+
"@semantic-release/git": "^10.0.1",
|
|
49
49
|
"@types/ember-data__model": "^3.16.2",
|
|
50
50
|
"@types/ember-data__store": "^3.16.1",
|
|
51
51
|
"@types/ember-qunit": "^3.4.15",
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"@types/ember__test-helpers": "^2.6.0",
|
|
69
69
|
"@types/ember__utils": "^3.16.2",
|
|
70
70
|
"@types/htmlbars-inline-precompile": "^1.0.1",
|
|
71
|
-
"@types/qunit": "^2.11.
|
|
71
|
+
"@types/qunit": "^2.11.3",
|
|
72
72
|
"@types/rsvp": "^4.0.4",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
74
|
-
"@typescript-eslint/parser": "^5.
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
74
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
75
75
|
"babel-eslint": "^10.1.0",
|
|
76
76
|
"broccoli-asset-rev": "^3.0.0",
|
|
77
77
|
"ember-cli": "~4.1.0",
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"ember-resolver": "^8.0.3",
|
|
91
91
|
"ember-source": "~4.1.0",
|
|
92
92
|
"ember-source-channel-url": "^3.0.0",
|
|
93
|
-
"ember-template-lint": "^3.
|
|
93
|
+
"ember-template-lint": "^3.16.0",
|
|
94
94
|
"ember-try": "^2.0.0",
|
|
95
|
-
"eslint": "^
|
|
95
|
+
"eslint": "^7.32.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",
|
|
@@ -102,14 +102,14 @@
|
|
|
102
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
|
-
"msw": "^0.36.
|
|
105
|
+
"msw": "^0.36.5",
|
|
106
106
|
"npm-run-all": "^4.1.5",
|
|
107
107
|
"prettier": "^2.5.1",
|
|
108
108
|
"qunit": "^2.17.2",
|
|
109
109
|
"qunit-dom": "^2.0.0",
|
|
110
|
-
"semantic-release": "^
|
|
111
|
-
"typescript": "^4.5.
|
|
112
|
-
"webpack": "^5.
|
|
110
|
+
"semantic-release": "^19.0.2",
|
|
111
|
+
"typescript": "^4.5.5",
|
|
112
|
+
"webpack": "^5.66.0"
|
|
113
113
|
},
|
|
114
114
|
"peerDependencies": {
|
|
115
115
|
"ember-data": "^3.25.0"
|
|
@@ -129,11 +129,11 @@
|
|
|
129
129
|
]
|
|
130
130
|
},
|
|
131
131
|
"volta": {
|
|
132
|
-
"node": "16.13.
|
|
132
|
+
"node": "16.13.2",
|
|
133
133
|
"yarn": "1.22.17"
|
|
134
134
|
},
|
|
135
135
|
"engines": {
|
|
136
|
-
"node": "
|
|
136
|
+
"node": "14.* || >= 16"
|
|
137
137
|
},
|
|
138
138
|
"ember": {
|
|
139
139
|
"edition": "octane"
|