ember-data-resources 2.0.3 → 2.0.4
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 +3 -0
- package/-private/resources/types.d.ts +1 -1
- package/.github/workflows/lint.yml +22 -0
- package/CHANGELOG.md +7 -0
- package/addon/-private/resources/errors.ts +7 -0
- package/addon/-private/resources/find-record.ts +12 -0
- package/addon/-private/resources/types.ts +1 -1
- package/addon/index.ts +0 -4
- package/package.json +13 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare type Id = string | number;
|
|
1
|
+
export declare type Id = string | number | null | undefined;
|
|
@@ -63,6 +63,28 @@ jobs:
|
|
|
63
63
|
# key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
64
64
|
# - run: yarn lint:docs-js
|
|
65
65
|
|
|
66
|
+
tooling:
|
|
67
|
+
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
|
|
68
|
+
name: Tooling
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
needs: [install_dependencies]
|
|
71
|
+
|
|
72
|
+
steps:
|
|
73
|
+
- uses: actions/checkout@v2
|
|
74
|
+
- uses: volta-cli/action@v1
|
|
75
|
+
- uses: actions/cache@v2
|
|
76
|
+
with:
|
|
77
|
+
path: '**/node_modules'
|
|
78
|
+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
79
|
+
|
|
80
|
+
- name: Semantic Release
|
|
81
|
+
run: yarn semantic-release --dry-run
|
|
82
|
+
working-directory: ./ember-resources
|
|
83
|
+
env:
|
|
84
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
85
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
86
|
+
|
|
87
|
+
|
|
66
88
|
commits:
|
|
67
89
|
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
|
|
68
90
|
name: Commit Messages
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.0.4](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.3...v2.0.4) (2021-11-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **findRecord:** id falsey errors are now on the error property ([fc6e3f6](https://github.com/NullVoxPopuli/ember-data-resources/commit/fc6e3f67cc2978324056699f42d66cf67bd10fcf))
|
|
7
|
+
|
|
1
8
|
## [2.0.3](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.2...v2.0.3) (2021-11-15)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -2,6 +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
6
|
import { Request } from './request';
|
|
6
7
|
|
|
7
8
|
import type { Id } from './types';
|
|
@@ -27,6 +28,17 @@ export class FindRecord<Model, LocalArgs extends Args = Args> extends Request<Lo
|
|
|
27
28
|
let [modelName, id] = this.args.positional;
|
|
28
29
|
let { options } = this.args.named;
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* ember-data forbids usage of invalid arguments
|
|
33
|
+
* in JS, this is typically fine as we can also try-catch, but
|
|
34
|
+
* since this *might* be used in a template as well as JS, we need to instead
|
|
35
|
+
* throw our own error that gives a bit more context to the user so
|
|
36
|
+
* they can pass in the correct arguments
|
|
37
|
+
*/
|
|
38
|
+
if (id === null || id === undefined) {
|
|
39
|
+
throw new IdRequiredError(modelName);
|
|
40
|
+
}
|
|
41
|
+
|
|
30
42
|
let record = await this.store.findRecord(modelName as never, id, options);
|
|
31
43
|
|
|
32
44
|
if (isDestroyed(this) || isDestroying(this)) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Id = string | number;
|
|
1
|
+
export type Id = string | number | null | undefined;
|
package/addon/index.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
|
|
4
2
|
import { useResource } from 'ember-resources';
|
|
5
3
|
|
|
6
4
|
import { FindAll } from './-private/resources/find-all';
|
|
@@ -34,8 +32,6 @@ export function findRecord<Model = unknown>(
|
|
|
34
32
|
options = options[1] || {};
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
assert(`Expected an ID to be specified from the thunk passed to findRecord`, id);
|
|
38
|
-
|
|
39
35
|
return {
|
|
40
36
|
positional: [modelName, id],
|
|
41
37
|
named: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-data-resources",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Resource helpers for reactively (re)fetching data with ember-data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"ember-resources": "^4.0.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@commitlint/cli": "^
|
|
41
|
-
"@commitlint/config-conventional": "^
|
|
40
|
+
"@commitlint/cli": "^14.1.0",
|
|
41
|
+
"@commitlint/config-conventional": "^14.1.0",
|
|
42
42
|
"@ember/optional-features": "^2.0.0",
|
|
43
43
|
"@ember/test-helpers": "^2.6.0",
|
|
44
44
|
"@embroider/test-setup": "^0.47.2",
|
|
45
45
|
"@glimmer/component": "^1.0.4",
|
|
46
|
-
"@nullvoxpopuli/eslint-configs": "^2.1.
|
|
46
|
+
"@nullvoxpopuli/eslint-configs": "^2.1.5",
|
|
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,6 +70,8 @@
|
|
|
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.4.0",
|
|
74
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
73
75
|
"babel-eslint": "^10.1.0",
|
|
74
76
|
"broccoli-asset-rev": "^3.0.0",
|
|
75
77
|
"ember-cli": "~3.28.4",
|
|
@@ -86,16 +88,19 @@
|
|
|
86
88
|
"ember-page-title": "^7.0.0",
|
|
87
89
|
"ember-qunit": "^5.1.5",
|
|
88
90
|
"ember-resolver": "^8.0.3",
|
|
89
|
-
"ember-source": "~
|
|
91
|
+
"ember-source": "~4.0.0",
|
|
90
92
|
"ember-source-channel-url": "^3.0.0",
|
|
91
93
|
"ember-template-lint": "^3.13.0",
|
|
92
94
|
"ember-try": "^2.0.0",
|
|
93
|
-
"eslint": "^7.
|
|
95
|
+
"eslint": "^7.0.0",
|
|
94
96
|
"eslint-config-prettier": "^8.3.0",
|
|
97
|
+
"eslint-plugin-decorator-position": "^4.0.1",
|
|
95
98
|
"eslint-plugin-ember": "^10.5.7",
|
|
99
|
+
"eslint-plugin-import": "^2.25.3",
|
|
96
100
|
"eslint-plugin-node": "^11.1.0",
|
|
97
101
|
"eslint-plugin-prettier": "^4.0.0",
|
|
98
|
-
"eslint-plugin-qunit": "^
|
|
102
|
+
"eslint-plugin-qunit": "^7.1.0",
|
|
103
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
99
104
|
"loader.js": "^4.7.0",
|
|
100
105
|
"msw": "^0.35.0",
|
|
101
106
|
"npm-run-all": "^4.1.5",
|
|
@@ -104,7 +109,7 @@
|
|
|
104
109
|
"qunit-dom": "^2.0.0",
|
|
105
110
|
"semantic-release": "^17.4.7",
|
|
106
111
|
"typescript": "^4.4.4",
|
|
107
|
-
"webpack": "^5.64.
|
|
112
|
+
"webpack": "^5.64.1"
|
|
108
113
|
},
|
|
109
114
|
"peerDependencies": {
|
|
110
115
|
"ember-data": "^3.25.0"
|