ember-data-resources 2.0.3 → 2.0.7

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.
@@ -0,0 +1,3 @@
1
+ export declare class IdRequiredError extends Error {
2
+ constructor(modelName: string);
3
+ }
@@ -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,31 @@
1
+ ## [2.0.7](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.6...v2.0.7) (2021-12-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency ember-cli-babel to ^7.26.8 ([20c8339](https://github.com/NullVoxPopuli/ember-data-resources/commit/20c8339d53c33cf8348701f6f8863df5a5db8536))
7
+
8
+ ## [2.0.6](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.5...v2.0.6) (2021-12-06)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency ember-resources to ^4.1.2 ([fead4c4](https://github.com/NullVoxPopuli/ember-data-resources/commit/fead4c41ff4a5ff17bc957a2b8f06ad42ced0f71))
14
+
15
+ ## [2.0.5](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.4...v2.0.5) (2021-12-05)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update dependency ember-cli-htmlbars to ^6.0.1 ([df29e7f](https://github.com/NullVoxPopuli/ember-data-resources/commit/df29e7fca3c18d30c956d373553e24c46622151c))
21
+
22
+ ## [2.0.4](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.3...v2.0.4) (2021-11-20)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **findRecord:** id falsey errors are now on the error property ([fc6e3f6](https://github.com/NullVoxPopuli/ember-data-resources/commit/fc6e3f67cc2978324056699f42d66cf67bd10fcf))
28
+
1
29
  ## [2.0.3](https://github.com/NullVoxPopuli/ember-data-resources/compare/v2.0.2...v2.0.3) (2021-11-15)
2
30
 
3
31
 
@@ -0,0 +1,7 @@
1
+ export class IdRequiredError extends Error {
2
+ constructor(modelName: string) {
3
+ super(
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
+ );
6
+ }
7
+ }
@@ -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",
3
+ "version": "2.0.7",
4
4
  "description": "Resource helpers for reactively (re)fetching data with ember-data",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -31,19 +31,19 @@
31
31
  "@ember/test-waiters": "^3.0.0",
32
32
  "@glimmer/tracking": "^1.0.4",
33
33
  "ember-auto-import": "^2.2.4",
34
- "ember-cli-babel": "^7.26.6",
35
- "ember-cli-htmlbars": "^6.0.0",
34
+ "ember-cli-babel": "^7.26.8",
35
+ "ember-cli-htmlbars": "^6.0.1",
36
36
  "ember-cli-typescript": "^4.2.1",
37
- "ember-resources": "^4.0.1"
37
+ "ember-resources": "^4.1.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@commitlint/cli": "^13.2.1",
41
- "@commitlint/config-conventional": "^13.2.0",
40
+ "@commitlint/cli": "^15.0.0",
41
+ "@commitlint/config-conventional": "^15.0.0",
42
42
  "@ember/optional-features": "^2.0.0",
43
43
  "@ember/test-helpers": "^2.6.0",
44
- "@embroider/test-setup": "^0.47.2",
44
+ "@embroider/test-setup": "^0.48.1",
45
45
  "@glimmer/component": "^1.0.4",
46
- "@nullvoxpopuli/eslint-configs": "^2.1.3",
46
+ "@nullvoxpopuli/eslint-configs": "^2.1.11",
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",
@@ -65,11 +65,13 @@
65
65
  "@types/ember__string": "^3.16.3",
66
66
  "@types/ember__template": "^3.16.1",
67
67
  "@types/ember__test": "^3.16.1",
68
- "@types/ember__test-helpers": "^2.0.2",
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
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
75
  "babel-eslint": "^10.1.0",
74
76
  "broccoli-asset-rev": "^3.0.0",
75
77
  "ember-cli": "~3.28.4",
@@ -78,7 +80,7 @@
78
80
  "ember-cli-sri": "^2.1.1",
79
81
  "ember-cli-terser": "^4.0.2",
80
82
  "ember-cli-typescript-blueprints": "^3.0.0",
81
- "ember-data": "^3.28.3",
83
+ "ember-data": "^4.0.2",
82
84
  "ember-disable-prototype-extensions": "^1.1.3",
83
85
  "ember-export-application-global": "^2.0.1",
84
86
  "ember-load-initializers": "^2.1.2",
@@ -86,25 +88,28 @@
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": "~3.28.6",
91
+ "ember-source": "~4.0.1",
90
92
  "ember-source-channel-url": "^3.0.0",
91
- "ember-template-lint": "^3.13.0",
93
+ "ember-template-lint": "^3.14.0",
92
94
  "ember-try": "^2.0.0",
93
- "eslint": "^7.32.0",
95
+ "eslint": "^8.4.1",
94
96
  "eslint-config-prettier": "^8.3.0",
95
- "eslint-plugin-ember": "^10.5.7",
97
+ "eslint-plugin-decorator-position": "^4.0.1",
98
+ "eslint-plugin-ember": "^10.5.8",
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": "^6.2.0",
102
+ "eslint-plugin-qunit": "^7.1.0",
103
+ "eslint-plugin-simple-import-sort": "^7.0.0",
99
104
  "loader.js": "^4.7.0",
100
- "msw": "^0.35.0",
105
+ "msw": "^0.36.3",
101
106
  "npm-run-all": "^4.1.5",
102
- "prettier": "^2.4.1",
107
+ "prettier": "^2.5.1",
103
108
  "qunit": "^2.17.2",
104
109
  "qunit-dom": "^2.0.0",
105
110
  "semantic-release": "^17.4.7",
106
- "typescript": "^4.4.4",
107
- "webpack": "^5.64.0"
111
+ "typescript": "^4.5.4",
112
+ "webpack": "^5.65.0"
108
113
  },
109
114
  "peerDependencies": {
110
115
  "ember-data": "^3.25.0"
@@ -124,7 +129,7 @@
124
129
  ]
125
130
  },
126
131
  "volta": {
127
- "node": "16.13.0",
132
+ "node": "16.13.1",
128
133
  "yarn": "1.22.17"
129
134
  },
130
135
  "engines": {