@seam-rpc/core 4.3.22 → 5.0.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/dist/index.d.ts +10 -9
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Result<Data, Error extends
|
|
1
|
+
export type Result<Data, Error extends ApiError> = {
|
|
2
2
|
ok: true;
|
|
3
3
|
data: Data;
|
|
4
4
|
} | {
|
|
@@ -6,15 +6,16 @@ export type Result<Data, Error extends RpcError> = {
|
|
|
6
6
|
error: Error;
|
|
7
7
|
};
|
|
8
8
|
export type ResError = {
|
|
9
|
-
|
|
9
|
+
isApiError: false;
|
|
10
10
|
} | {
|
|
11
|
-
|
|
12
|
-
error:
|
|
13
|
-
code: string;
|
|
14
|
-
data: unknown;
|
|
15
|
-
};
|
|
11
|
+
isApiError: true;
|
|
12
|
+
error: ApiErrorInterface;
|
|
16
13
|
};
|
|
17
|
-
export
|
|
14
|
+
export interface ApiErrorInterface<ErrorMap extends Record<Code, any> = any, Code extends keyof ErrorMap = keyof ErrorMap> {
|
|
15
|
+
code: Code;
|
|
16
|
+
data: ErrorMap[Code];
|
|
17
|
+
}
|
|
18
|
+
export declare class ApiError<ErrorMap extends Record<Code, any> = any, Code extends keyof ErrorMap = keyof ErrorMap> implements ApiErrorInterface {
|
|
18
19
|
private _code;
|
|
19
20
|
private _data?;
|
|
20
21
|
constructor(code: Code, data?: ErrorMap[Code]);
|
|
@@ -28,7 +29,7 @@ export declare class RpcError<ErrorMap extends Record<Code, any> = any, Code ext
|
|
|
28
29
|
static fromJSON(json: {
|
|
29
30
|
code: any;
|
|
30
31
|
data: any;
|
|
31
|
-
}):
|
|
32
|
+
}): ApiError<any, any>;
|
|
32
33
|
}
|
|
33
34
|
export declare function extractFiles(input: unknown): {
|
|
34
35
|
json: any;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class ApiError {
|
|
2
2
|
constructor(code, data) {
|
|
3
3
|
this._code = code;
|
|
4
4
|
this._data = data;
|
|
@@ -12,7 +12,7 @@ export class RpcError {
|
|
|
12
12
|
return { code: this._code, data: this._data };
|
|
13
13
|
}
|
|
14
14
|
static fromJSON(json) {
|
|
15
|
-
return new
|
|
15
|
+
return new ApiError(json.code, json.data);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
export function extractFiles(input) {
|