Skip to content

Commit a147836

Browse files
committed
fix(exceptions): AggregateError polyfill
- use @flex-development/aggregate-error-ponyfill - drop es-aggregate-error (did not work at all) - https://github.com/sindresorhus/ponyfill
1 parent 4b6b915 commit a147836

File tree

6 files changed

+17
-61
lines changed

6 files changed

+17
-61
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,15 @@ jobs:
5050
- id: check-style
5151
name: Check code style
5252
run: yarn check:style
53-
- id: check-types
54-
name: Check types
55-
run: yarn check:types
53+
# - id: check-tests
54+
# name: Check test suites
55+
# run: yarn test
5656
- id: env
57-
name: Set environment variables
57+
name: Set build environment variables
5858
run: node ./tools/cli/loadenv.cjs -gc=test
59-
- id: check-tests
60-
name: Check test suites
61-
run: yarn test
6259
- id: check-build
6360
name: Check builds
6461
run: yarn prepack --tarball --env=test
6562
- id: env-post
66-
name: Post Set environment variables
63+
name: Post Set build environment variables
6764
run: echo "NODE_OPTIONS=''" >> $GITHUB_ENV

.github/workflows/integrity.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
PAT_GPR: ${{ secrets.PAT_GPR_ADMIN }}
2424
strategy:
2525
matrix:
26-
node: [15.x, 16.x]
26+
node: [12.22.0, 16.0.0]
2727
steps:
2828
- id: checkout
2929
name: Checkout branch

packages/exceptions/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@
9696
"postpublish": "toggle-scripts +prepack"
9797
},
9898
"dependencies": {
99+
"@flex-development/aggregate-error-ponyfill": "workspace:packages/aggregate-error-ponyfill",
99100
"@flex-development/tutils": "4.2.3",
100-
"@types/es-aggregate-error": "1.0.2",
101-
"es-aggregate-error": "1.0.7",
102101
"lodash.isplainobject": "4.0.6",
103102
"lodash.omit": "4.5.0",
104103
"lodash.pick": "4.4.0"
@@ -129,7 +128,7 @@
129128
},
130129
"peerDependencies": {
131130
"@firebase/util": ">=1.4.0",
132-
"@types/node": ">=15.0.0",
131+
"@types/node": ">=12.0.0",
133132
"axios": ">=0.23.0",
134133
"class-validator": ">=0.13.1",
135134
"firebase-admin": ">=10.0.0",
@@ -156,7 +155,7 @@
156155
}
157156
},
158157
"engines": {
159-
"node": ">=15.0.0",
158+
"node": ">=12.22.0",
160159
"npm": "use-yarn",
161160
"yarn": "3.0.2"
162161
},

packages/exceptions/src/exceptions/base.exception.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import AggregateError from '@flex-development/aggregate-error-ponyfill'
12
import type { JSONObject, JSONValue } from '@flex-development/tutils'
23
import { NullishString } from '@flex-development/tutils'
34
import { ExceptionDataDTO } from '@packages/exceptions/dtos'
@@ -16,7 +17,6 @@ import {
1617
NextError
1718
} from '@packages/exceptions/interfaces'
1819
import { ExceptionData, ExceptionErrors } from '@packages/exceptions/types'
19-
import AggregateError from 'es-aggregate-error'
2020
import omit from 'lodash.omit'
2121
import pick from 'lodash.pick'
2222
import { DEM } from './constants.exceptions'
@@ -31,10 +31,10 @@ import { DEM } from './constants.exceptions'
3131
*
3232
* @template T - Error type
3333
*
34-
* @extends {AggregateError}
34+
* @extends {AggregateError<T>}
3535
*/
3636
// eslint-disable-next-line unicorn/custom-error-definition
37-
export default class Exception<T = any> extends AggregateError {
37+
export default class Exception<T = any> extends AggregateError<T> {
3838
/**
3939
* @readonly
4040
* @property {ExceptionErrors<T>} errors - Aggregated errors
@@ -45,7 +45,7 @@ export default class Exception<T = any> extends AggregateError {
4545
* @readonly
4646
* @property {'Exception'} name - Constructor name
4747
*/
48-
// @ts-expect-error '"Exception"' is not assignable to type '"AggregateError"
48+
// @ts-expect-error '"Exception"' !== '"AggregateError"
4949
override readonly name: 'Exception' = 'Exception'
5050

5151
/**
@@ -88,7 +88,7 @@ export default class Exception<T = any> extends AggregateError {
8888
data: ExceptionDataDTO<T> = {},
8989
stack: string = ''
9090
) {
91-
super([data.errors || []].flat(), data.message || message || DEM)
91+
super([data.errors || []].flat() as T[], data.message || message || DEM)
9292

9393
this.code = Exception.formatCode(code)
9494
this.data = omit(data, ['errors', 'message'])

packages/exceptions/src/types/exception-errors.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
*
99
* @template T - Error type
1010
*/
11-
export type ExceptionErrors<T = any> = ReadonlyArray<T>
11+
export type ExceptionErrors<T = any> = Array<T>

yarn.lock

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,12 @@ __metadata:
705705
resolution: "@flex-development/exceptions@workspace:packages/exceptions"
706706
dependencies:
707707
"@firebase/util": 1.4.0
708+
"@flex-development/aggregate-error-ponyfill": "workspace:packages/aggregate-error-ponyfill"
708709
"@flex-development/tutils": 4.2.3
709710
"@mochajs/json-file-reporter": 1.3.0
710711
"@packages/exceptions": "link:src"
711712
"@tests/utils": "link:../../__tests__/utils"
712713
"@types/chai": 4.2.22
713-
"@types/es-aggregate-error": 1.0.2
714714
"@types/faker": 5.5.9
715715
"@types/lodash.isplainobject": 4.0.6
716716
"@types/lodash.omit": 4.5.6
@@ -721,7 +721,6 @@ __metadata:
721721
axios: 0.24.0
722722
chai: 4.3.4
723723
class-validator: 0.13.1
724-
es-aggregate-error: 1.0.7
725724
faker: 5.5.3
726725
firebase-admin: 10.0.0
727726
lodash.isplainobject: 4.0.6
@@ -734,7 +733,7 @@ __metadata:
734733
typescript: 4.5.0-beta
735734
peerDependencies:
736735
"@firebase/util": ">=1.4.0"
737-
"@types/node": ">=15.0.0"
736+
"@types/node": ">=12.0.0"
738737
axios: ">=0.23.0"
739738
class-validator: ">=0.13.1"
740739
firebase-admin: ">=10.0.0"
@@ -1409,15 +1408,6 @@ __metadata:
14091408
languageName: node
14101409
linkType: hard
14111410

1412-
"@types/es-aggregate-error@npm:1.0.2":
1413-
version: 1.0.2
1414-
resolution: "@types/es-aggregate-error@npm:1.0.2"
1415-
dependencies:
1416-
"@types/node": "*"
1417-
checksum: 076fd59b595f33c8c7e7eb68ec55bd43cf8b2cf7bbc6778e25d7ae1a5fa0538a0a56f149015f403d7bbcefe59f1d8182351685b59c1fe719fd46d0dd8a9737fa
1418-
languageName: node
1419-
linkType: hard
1420-
14211411
"@types/es-to-primitive@npm:*":
14221412
version: 1.2.4
14231413
resolution: "@types/es-to-primitive@npm:1.2.4"
@@ -3504,20 +3494,6 @@ __metadata:
35043494
languageName: node
35053495
linkType: hard
35063496

3507-
"es-aggregate-error@npm:1.0.7":
3508-
version: 1.0.7
3509-
resolution: "es-aggregate-error@npm:1.0.7"
3510-
dependencies:
3511-
define-properties: ^1.1.3
3512-
es-abstract: ^1.19.0
3513-
function-bind: ^1.1.1
3514-
functions-have-names: ^1.2.2
3515-
get-intrinsic: ^1.1.1
3516-
globalthis: ^1.0.2
3517-
checksum: 16b89fefdf56c0478cd21577249156cf83e44c2220c057cbfddd99c01e15e03d6d90a85ce73dece4728a5bfcb022dc160e04a66b1f83a620f140842c6f8325f9
3518-
languageName: node
3519-
linkType: hard
3520-
35213497
"es-to-primitive@npm:^1.2.1":
35223498
version: 1.2.1
35233499
resolution: "es-to-primitive@npm:1.2.1"
@@ -4314,13 +4290,6 @@ fsevents@~2.3.2:
43144290
languageName: node
43154291
linkType: hard
43164292

4317-
"functions-have-names@npm:^1.2.2":
4318-
version: 1.2.2
4319-
resolution: "functions-have-names@npm:1.2.2"
4320-
checksum: 25f44b6d1c41ac86ffdf41f25d1de81c0a5b4a3fcf4307a33cdfb23b9d4bd5d0d8bf312eaef5ad368c6500c8a9e19f692b8ce9f96aaab99db9dd936554165558
4321-
languageName: node
4322-
linkType: hard
4323-
43244293
"gauge@npm:~2.7.3":
43254294
version: 2.7.4
43264295
resolution: "gauge@npm:2.7.4"
@@ -4581,15 +4550,6 @@ fsevents@~2.3.2:
45814550
languageName: node
45824551
linkType: hard
45834552

4584-
"globalthis@npm:^1.0.2":
4585-
version: 1.0.2
4586-
resolution: "globalthis@npm:1.0.2"
4587-
dependencies:
4588-
define-properties: ^1.1.3
4589-
checksum: 5a5f3c7ab94708260a98106b35946b74bb57f6b2013e39668dc9e8770b80a3418103b63a2b4aa01c31af15fdf6a2940398ffc0a408573c34c2304f928895adff
4590-
languageName: node
4591-
linkType: hard
4592-
45934553
"globby@npm:^11.0.4":
45944554
version: 11.0.4
45954555
resolution: "globby@npm:11.0.4"

0 commit comments

Comments
 (0)