@azure-net/kit 1.3.7 → 1.4.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.
|
@@ -5,8 +5,8 @@ export interface AsyncActionResponse<T, D = unknown, CustomErrorField = never> {
|
|
|
5
5
|
error?: AppError<D, CustomErrorField>;
|
|
6
6
|
}
|
|
7
7
|
type ActionOrThunk<Res> = Promise<Res> | (() => Promise<Res>);
|
|
8
|
-
export declare const createAsyncHelpers: <Custom = unknown>(opts?: {
|
|
9
|
-
parseError?: ReturnType<typeof createErrorParser<Custom>>;
|
|
8
|
+
export declare const createAsyncHelpers: <BaseError = unknown, Custom = unknown>(opts?: {
|
|
9
|
+
parseError?: ReturnType<typeof createErrorParser<BaseError, Custom>>;
|
|
10
10
|
}) => {
|
|
11
11
|
createAsyncAction: <Res = unknown, Req = unknown>(action: ActionOrThunk<Res>, args?: {
|
|
12
12
|
beforeSend?: (next: () => void, abort: () => void) => void | Promise<void>;
|
|
@@ -70,7 +70,6 @@ export const createAsyncHelpers = (opts) => {
|
|
|
70
70
|
const abort = () => resolve('abort');
|
|
71
71
|
Promise.resolve(args.beforeSend(next, abort)).catch((err) => {
|
|
72
72
|
console.error('Error in beforeSend:', err);
|
|
73
|
-
// If beforeSend throws, treat it as abort
|
|
74
73
|
resolve('abort');
|
|
75
74
|
});
|
|
76
75
|
});
|
|
@@ -13,8 +13,8 @@ export type ErrorType<T = unknown> = Error | HttpServiceError<T> | SchemaFail<T>
|
|
|
13
13
|
export declare const baseParseHttpError: <T = unknown, D = never>(error: HttpServiceError<T>) => AppError<T, D>;
|
|
14
14
|
export declare const baseParseSchemaError: <SchemaData = unknown, D = never>(error: SchemaFail<SchemaData>) => AppError<SchemaData, D>;
|
|
15
15
|
export declare const baseParseBaseError: <D = never>(error: Error) => AppError<never, D>;
|
|
16
|
-
export declare const createErrorParser: <Custom = unknown>(parsers?: {
|
|
17
|
-
parseBaseError?: typeof baseParseBaseError
|
|
18
|
-
parseHttpError?: typeof baseParseHttpError
|
|
19
|
-
parseSchemaError?: typeof baseParseSchemaError
|
|
20
|
-
}) => (<T>(error: ErrorType<
|
|
16
|
+
export declare const createErrorParser: <BaseError = unknown, Custom = unknown>(parsers?: {
|
|
17
|
+
parseBaseError?: typeof baseParseBaseError<Custom>;
|
|
18
|
+
parseHttpError?: typeof baseParseHttpError<BaseError, Custom>;
|
|
19
|
+
parseSchemaError?: typeof baseParseSchemaError<BaseError, Custom>;
|
|
20
|
+
}) => (<T = unknown>(error: ErrorType<BaseError>) => AppError<T, Custom>);
|