@next-feature/client 0.1.0-MIGRATION.22.0.3 → 0.1.1
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/{jest.config.ts → jest.config.cts} +1 -1
- package/package.json +6 -1
- package/project.json +1 -1
- package/src/lib/client.ts +1 -1
- package/src/lib/error.ts +17 -5
- package/tsconfig.json +1 -1
- package/tsconfig.lib.json +1 -0
- package/tsconfig.spec.json +1 -0
- package/vite.config.ts +5 -2
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-feature/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./index.mjs",
|
|
9
9
|
"require": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./server": {
|
|
12
|
+
"types": "./dist/server.d.ts",
|
|
13
|
+
"import": "./dist/server.js",
|
|
14
|
+
"default": "./dist/server.js"
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
}
|
package/project.json
CHANGED
package/src/lib/client.ts
CHANGED
package/src/lib/error.ts
CHANGED
|
@@ -21,7 +21,7 @@ export class ApiError extends Error {
|
|
|
21
21
|
constructor(
|
|
22
22
|
public status: HttpStatusCode,
|
|
23
23
|
public problemDetail: ProblemDetail | null,
|
|
24
|
-
public originalError
|
|
24
|
+
public originalError?: Error,
|
|
25
25
|
message?: string
|
|
26
26
|
) {
|
|
27
27
|
super(
|
|
@@ -59,7 +59,7 @@ export class ApiError extends Error {
|
|
|
59
59
|
return new ApiErrorBuilder<T>();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
static of(error: Error) {
|
|
62
|
+
static of(error: Error): ApiError {
|
|
63
63
|
if (error instanceof ApiError) {
|
|
64
64
|
return error;
|
|
65
65
|
}
|
|
@@ -83,7 +83,7 @@ export class ApiError extends Error {
|
|
|
83
83
|
.originalError(zodError)
|
|
84
84
|
.status(HttpStatusCode.BadRequest)
|
|
85
85
|
.message('Validation error')
|
|
86
|
-
.
|
|
86
|
+
.detail('errors', errors)
|
|
87
87
|
.build();
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -91,7 +91,7 @@ export class ApiError extends Error {
|
|
|
91
91
|
export class ApiErrorBuilder<
|
|
92
92
|
AdditionalProblemDetails = Record<string, unknown>
|
|
93
93
|
> {
|
|
94
|
-
private
|
|
94
|
+
private _problemDetail: ProblemDetail;
|
|
95
95
|
private _status: HttpStatusCode;
|
|
96
96
|
private _originalError: Error;
|
|
97
97
|
private _message: string;
|
|
@@ -108,7 +108,7 @@ export class ApiErrorBuilder<
|
|
|
108
108
|
/**
|
|
109
109
|
* Set standard ProblemDetail fields
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
detail<K extends keyof (ProblemDetail & AdditionalProblemDetails)>(
|
|
112
112
|
key: K,
|
|
113
113
|
value: K extends keyof ProblemDetail
|
|
114
114
|
? ProblemDetail[K]
|
|
@@ -120,6 +120,18 @@ export class ApiErrorBuilder<
|
|
|
120
120
|
return this;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Set standard ProblemDetail fields
|
|
125
|
+
*/
|
|
126
|
+
problemDetail(
|
|
127
|
+
problemDetail: ProblemDetail
|
|
128
|
+
): ApiErrorBuilder<AdditionalProblemDetails> {
|
|
129
|
+
if (problemDetail) {
|
|
130
|
+
this._problemDetail = problemDetail;
|
|
131
|
+
}
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
123
135
|
originalError(error: Error): ApiErrorBuilder<AdditionalProblemDetails> {
|
|
124
136
|
this._originalError = error;
|
|
125
137
|
this._problemDetail.title = error.name;
|
package/tsconfig.json
CHANGED
package/tsconfig.lib.json
CHANGED
package/tsconfig.spec.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -16,6 +16,7 @@ export default defineConfig(() => ({
|
|
|
16
16
|
dts({
|
|
17
17
|
entryRoot: 'src',
|
|
18
18
|
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
19
|
+
pathsToAliases: false,
|
|
19
20
|
}),
|
|
20
21
|
],
|
|
21
22
|
// Uncomment this if you are using workers.
|
|
@@ -33,9 +34,11 @@ export default defineConfig(() => ({
|
|
|
33
34
|
},
|
|
34
35
|
lib: {
|
|
35
36
|
// Could also be a dictionary or array of multiple entry points.
|
|
36
|
-
entry:
|
|
37
|
+
entry: {
|
|
38
|
+
index: 'src/index.ts',
|
|
39
|
+
},
|
|
37
40
|
name: 'client',
|
|
38
|
-
fileName:
|
|
41
|
+
fileName: (format, entryName) => `${entryName}.js`,
|
|
39
42
|
// Change this to the formats you want to support.
|
|
40
43
|
// Don't forget to update your package.json as well.
|
|
41
44
|
formats: ['es' as const],
|