@azure-net/kit 3.9.1 → 3.9.3

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.
Files changed (43) hide show
  1. package/dist/core/delivery/index.d.ts +1 -4
  2. package/dist/core/delivery/index.js +1 -4
  3. package/dist/core/delivery/injectableDependencies/AsyncHelpers.d.ts +28 -36
  4. package/dist/core/delivery/injectableDependencies/AsyncHelpers.js +79 -137
  5. package/dist/core/delivery/injectableDependencies/ErrorHandler.d.ts +3 -21
  6. package/dist/core/delivery/injectableDependencies/ErrorHandler.js +11 -42
  7. package/dist/core/delivery/schema/Schema.d.ts +13 -4
  8. package/dist/core/delivery/schema/Schema.js +11 -2
  9. package/dist/core/delivery/schema/rules/messages/index.d.ts +1 -0
  10. package/dist/core/delivery/schema/rules/messages/index.js +1 -0
  11. package/dist/core/delivery.d.ts +5 -0
  12. package/dist/core/delivery.js +5 -0
  13. package/dist/core/errors.d.ts +4 -0
  14. package/dist/core/errors.js +4 -0
  15. package/dist/core/index.d.ts +7 -8
  16. package/dist/core/index.js +7 -8
  17. package/dist/core/infra/httpService/HttpServiceInstance.d.ts +16 -8
  18. package/dist/core/infra/httpService/HttpServiceInstance.js +47 -49
  19. package/dist/core/infra/query/QueryBuilder.js +2 -1
  20. package/dist/core/infra/response/BaseResponse.js +3 -2
  21. package/dist/core/infra.d.ts +6 -0
  22. package/dist/core/infra.js +6 -0
  23. package/dist/core/shared/appError/AppError.d.ts +30 -0
  24. package/dist/core/shared/appError/AppError.js +66 -0
  25. package/dist/core/shared/appEventBus/EventBus.js +1 -1
  26. package/dist/core/shared/boundaryProvider/Provider.js +4 -3
  27. package/dist/core/shared/classMirror/ClassMirror.d.ts +7 -2
  28. package/dist/core/shared/classMirror/ClassMirror.js +34 -15
  29. package/dist/core/shared/cookie/UniversalCookie.js +8 -10
  30. package/dist/core/svelte/ActiveForm/ActiveForm.svelte.d.ts +6 -5
  31. package/dist/core/svelte/ActiveForm/ActiveForm.svelte.js +31 -26
  32. package/dist/core/svelte/AsyncSignal/AsyncSignal.svelte.d.ts +0 -1
  33. package/dist/core/svelte/AsyncSignal/AsyncSignal.svelte.js +21 -30
  34. package/dist/core/svelte/Query/Query.svelte.d.ts +11 -12
  35. package/dist/core/svelte/Query/Query.svelte.js +42 -54
  36. package/dist/core/ui/scrollTo/index.js +2 -2
  37. package/dist/edges/index.d.ts +1 -1
  38. package/dist/edges/index.js +1 -1
  39. package/package.json +13 -9
  40. package/dist/core/delivery/serverAction/CreateServerAction.d.ts +0 -15
  41. package/dist/core/delivery/serverAction/CreateServerAction.js +0 -22
  42. package/dist/core/delivery/serverAction/index.d.ts +0 -1
  43. package/dist/core/delivery/serverAction/index.js +0 -1
@@ -1,4 +1 @@
1
- export * from '../../edges/index.js';
2
- export * from './injectableDependencies/index.js';
3
- export * from './serverAction/index.js';
4
- export * from './schema/index.js';
1
+ export {};
@@ -1,4 +1 @@
1
- export * from '../../edges/index.js';
2
- export * from './injectableDependencies/index.js';
3
- export * from './serverAction/index.js';
4
- export * from './schema/index.js';
1
+ "use strict";
@@ -1,42 +1,34 @@
1
- import { type AppError, createErrorParser } from './ErrorHandler.js';
2
- export interface AsyncActionResponse<T, D = unknown, CustomErrorField = never> {
1
+ import { createErrorHandler } from './ErrorHandler.js';
2
+ import { type AppError, type IAppError } from '../../shared/appError/AppError.js';
3
+ export interface AsyncActionResponse<T, D = never, ErrorResult = Record<never, never>> {
3
4
  success: boolean;
4
5
  response: T;
5
- error?: AppError<D, CustomErrorField>;
6
+ error?: IAppError<D> & ErrorResult;
6
7
  }
7
- type ActionOrThunk<Res> = Promise<Res> | (() => Promise<Res>);
8
- export declare const createAsyncHelpers: <BaseError = unknown, Custom = unknown>(opts?: {
9
- parseError?: ReturnType<typeof createErrorParser<BaseError, Custom>>;
8
+ export interface AsyncHelperRetry {
9
+ can: boolean;
10
+ call?: () => Promise<Error | void>;
11
+ }
12
+ type Action<Res> = () => Promise<Res>;
13
+ export interface AsyncActionSettings<Res = never, Req = never, ErrorResult = AppError<Error>> {
14
+ beforeSend?: (actions: {
15
+ next: () => void;
16
+ abort: (reason?: Error) => void;
17
+ }) => void | Promise<void>;
18
+ onSuccess?: (result: AsyncActionResponse<Res, never, ErrorResult>) => Promise<unknown> | unknown;
19
+ onError?: (result: AsyncActionResponse<never, Req, ErrorResult>) => Promise<unknown> | unknown;
20
+ fallbackResponse?: Res;
21
+ }
22
+ export interface AsyncResourceSettings<Res = never, Req = never, ErrorResult = AppError<Error>> extends AsyncActionSettings<Res, Req, ErrorResult> {
23
+ reject?: boolean;
24
+ }
25
+ export declare class AsyncHelperError extends Error {
26
+ }
27
+ export declare const createAsyncHelpers: <ErrorResult extends object>(opts?: {
28
+ handler?: ReturnType<typeof createErrorHandler<ErrorResult>>;
10
29
  }) => {
11
- createAsyncAction: <Res = unknown, Req = unknown>(action: ActionOrThunk<Res>, args?: {
12
- beforeSend?: (actions: {
13
- next: () => void;
14
- abort: () => void;
15
- }) => void | Promise<void>;
16
- onSuccess?: (result: AsyncActionResponse<Res, undefined, Custom>) => Promise<unknown> | unknown;
17
- onError?: (result: AsyncActionResponse<never, Req, Custom>) => Promise<unknown> | unknown;
18
- reject?: boolean;
19
- abort?: {
20
- condition: boolean;
21
- onAbort?: () => void;
22
- };
23
- fallbackResponse?: Res;
24
- maxRetries?: number;
25
- }) => Promise<AsyncActionResponse<Res, Req, Custom>>;
26
- createAsyncResource: <Res, Req_1 = unknown>(action: ActionOrThunk<Res>, args?: {
27
- beforeSend?: (actions: {
28
- next: () => void;
29
- abort: () => void;
30
- }) => void | Promise<void>;
31
- onSuccess?: (result: Res) => Promise<unknown> | unknown;
32
- onError?: (error: AppError<Req_1, Custom>) => Promise<unknown> | unknown;
33
- reject?: boolean;
34
- abort?: {
35
- condition: boolean;
36
- onAbort?: () => void;
37
- };
38
- fallbackResponse?: Res;
39
- maxRetries?: number;
40
- }) => Promise<Res>;
30
+ createAsyncAction: <Res = never, Req = never>(action: Action<Res>, args?: AsyncActionSettings<Res, Req, ErrorResult>) => Promise<AsyncActionResponse<Res, Req, ErrorResult>>;
31
+ createAsyncResource: <Res = never, Req_1 = never>(action: Action<Res>, args?: AsyncResourceSettings<Res, Req_1, ErrorResult>) => Promise<Res>;
32
+ errorParser: <T = unknown>(error: Error, asyncHelperRetry?: AsyncHelperRetry) => Promise<IAppError<T> & ErrorResult>;
41
33
  };
42
34
  export {};
@@ -1,68 +1,74 @@
1
- import { createErrorParser } from './ErrorHandler.js';
2
- import { AppEvents } from '../../index.js';
1
+ import { createErrorHandler } from './ErrorHandler.js';
2
+ import {} from '../../shared/appError/AppError.js';
3
+ export class AsyncHelperError extends Error {
4
+ }
3
5
  export const createAsyncHelpers = (opts) => {
4
- const errorParser = opts?.parseError ?? createErrorParser();
5
- const createAsyncAction = async (action, args) => {
6
- if (args?.abort?.condition) {
7
- args.abort.onAbort?.();
8
- const abortError = {
9
- type: 'abort',
10
- message: 'aborted',
11
- original: new Error('aborted')
12
- };
13
- if (args?.reject)
14
- throw abortError;
15
- return {
16
- success: false,
17
- error: abortError,
18
- response: args?.fallbackResponse
19
- };
20
- }
21
- if (args?.beforeSend) {
22
- const beforeSendResult = await new Promise((resolve) => {
23
- let settled = false;
24
- const settle = (value) => {
25
- if (settled)
26
- return;
27
- settled = true;
28
- resolve(value);
29
- };
30
- const next = () => settle('next');
31
- const abort = () => settle('abort');
32
- Promise.resolve(args.beforeSend({ next, abort }))
33
- .then(() => {
34
- settle('next');
6
+ const errorParser = opts?.handler ?? createErrorHandler();
7
+ const normalizeError = (err) => (err instanceof Error ? err : new Error(String(err)));
8
+ const prepareErrors = async (error, retry) => {
9
+ let retryResult = undefined;
10
+ const retryFunc = async () => {
11
+ if (retry) {
12
+ return await retry()
13
+ .then((res) => {
14
+ retryResult = res;
15
+ return undefined;
35
16
  })
36
- .catch((err) => {
37
- console.error('Error in beforeSend:', err);
38
- settle('abort');
39
- });
40
- });
41
- if (beforeSendResult === 'abort') {
42
- const abortError = {
43
- type: 'abort',
44
- message: 'Aborted in beforeSend',
45
- original: new Error('Aborted in beforeSend')
46
- };
47
- if (args?.reject)
48
- throw abortError;
49
- return {
50
- success: false,
51
- error: abortError,
52
- response: args?.fallbackResponse
53
- };
17
+ .catch((err) => normalizeError(err));
54
18
  }
55
- }
56
- const maxRetries = args?.maxRetries ?? 3;
57
- let retries = 0;
58
- const req = async (isRetry = false) => {
59
- if (isRetry) {
60
- retries++;
61
- if (retries > maxRetries) {
62
- return Promise.reject(Error('Max retries reached'));
19
+ };
20
+ const parsedError = await errorParser(normalizeError(error), { can: !!retry, call: retry ? () => retryFunc() : undefined });
21
+ return { error: parsedError, retryResult };
22
+ };
23
+ const beforeSendResolver = async (settings) => {
24
+ if (!settings?.beforeSend)
25
+ return undefined;
26
+ let abortReason;
27
+ let aborted = false;
28
+ await new Promise((resolve) => {
29
+ let settled = false;
30
+ const beforeSend = settings.beforeSend;
31
+ const guardTimer = setTimeout(() => {
32
+ settle(true);
33
+ }, 30000);
34
+ const settle = (isAbort, reason) => {
35
+ if (settled)
36
+ return;
37
+ settled = true;
38
+ clearTimeout(guardTimer);
39
+ aborted = isAbort;
40
+ abortReason = reason;
41
+ resolve();
42
+ };
43
+ const next = () => settle(false);
44
+ const abort = (reason) => settle(true, reason);
45
+ try {
46
+ const maybePromise = beforeSend({ next, abort });
47
+ if (maybePromise && typeof maybePromise.then === 'function') {
48
+ maybePromise.then(() => settle(false), (err) => settle(true, normalizeError(err)));
49
+ return;
63
50
  }
51
+ settle(false);
64
52
  }
65
- const response = await Promise.resolve(typeof action === 'function' ? action() : action);
53
+ catch (err) {
54
+ settle(true, normalizeError(err));
55
+ }
56
+ });
57
+ if (!aborted)
58
+ return undefined;
59
+ const { error } = await prepareErrors(abortReason ?? new AsyncHelperError('Aborted in beforeSend'));
60
+ return {
61
+ success: false,
62
+ error,
63
+ response: undefined
64
+ };
65
+ };
66
+ const createAsyncAction = async (action, args) => {
67
+ const beforeSendResult = await beforeSendResolver(args);
68
+ if (beforeSendResult)
69
+ return beforeSendResult;
70
+ const req = async () => {
71
+ const response = await Promise.resolve(action());
66
72
  const result = { response, success: true };
67
73
  await args?.onSuccess?.(result);
68
74
  return result;
@@ -71,94 +77,30 @@ export const createAsyncHelpers = (opts) => {
71
77
  return await req();
72
78
  }
73
79
  catch (err) {
74
- let retryResult;
75
- const retry = async () => await req(true)
76
- .then((res) => (retryResult = res))
77
- .catch(() => undefined);
78
- const error = await errorParser(err, async () => await retry());
80
+ const { error, retryResult } = await prepareErrors(normalizeError(err), async () => await req());
79
81
  if (retryResult) {
80
82
  return retryResult;
81
83
  }
82
- const { bus } = AppEvents();
83
- bus.publish('OnAsyncHelperError', () => error);
84
84
  const result = { error, response: args?.fallbackResponse, success: false };
85
- await args?.onError?.(result);
86
- if (args?.reject)
87
- throw error;
85
+ try {
86
+ await args?.onError?.(result);
87
+ }
88
+ catch (err) {
89
+ throw await errorParser(new AsyncHelperError('onError caught exception', { cause: normalizeError(err) }));
90
+ }
88
91
  return result;
89
92
  }
90
93
  };
91
94
  const createAsyncResource = async (action, args) => {
92
- if (args?.abort?.condition) {
93
- args.abort.onAbort?.();
94
- return args.fallbackResponse;
95
- }
96
- if (args?.beforeSend) {
97
- const beforeSendResult = await new Promise((resolve) => {
98
- let settled = false;
99
- const settle = (value) => {
100
- if (settled)
101
- return;
102
- settled = true;
103
- resolve(value);
104
- };
105
- const next = () => settle('next');
106
- const abort = () => settle('abort');
107
- Promise.resolve(args.beforeSend({ next, abort }))
108
- .then(() => {
109
- settle('next');
110
- })
111
- .catch((err) => {
112
- console.error('Error in beforeSend:', err);
113
- settle('abort');
114
- });
115
- });
116
- if (beforeSendResult === 'abort') {
117
- if (args?.reject) {
118
- throw {
119
- type: 'abort',
120
- message: 'Aborted in beforeSend',
121
- original: new Error('Aborted in beforeSend')
122
- };
123
- }
124
- return args.fallbackResponse;
125
- }
126
- }
127
- const maxRetries = args?.maxRetries ?? 3;
128
- let retries = 0;
129
- const req = async (isRetry = false) => {
130
- if (isRetry) {
131
- retries++;
132
- if (retries > maxRetries) {
133
- return Promise.reject(Error('Max retries reached'));
134
- }
135
- }
136
- const response = await Promise.resolve(typeof action === 'function' ? action() : action);
137
- await args?.onSuccess?.(response);
138
- return response;
139
- };
140
- try {
141
- return await req();
142
- }
143
- catch (err) {
144
- let retryResult;
145
- const retry = async () => await req(true)
146
- .then((res) => (retryResult = res))
147
- .catch(() => undefined);
148
- const error = await errorParser(err, async () => await retry());
149
- if (retryResult) {
150
- return retryResult;
151
- }
152
- const { bus } = AppEvents();
153
- bus.publish('OnAsyncHelperError', () => error);
154
- await args?.onError?.(error);
155
- if (args?.reject)
156
- throw error;
157
- return args?.fallbackResponse;
95
+ const result = await createAsyncAction(action, args);
96
+ if (!result.success && args?.reject) {
97
+ throw result.error;
158
98
  }
99
+ return result.response;
159
100
  };
160
101
  return {
161
102
  createAsyncAction,
162
- createAsyncResource
103
+ createAsyncResource,
104
+ errorParser
163
105
  };
164
106
  };
@@ -1,21 +1,3 @@
1
- import { HttpServiceError } from '../../infra/httpService/index.js';
2
- import { SchemaFail, type RequestErrors } from '../schema/index.js';
3
- export type AppErrorType = 'http' | 'app' | 'schema' | 'abort';
4
- export interface AppError<T = unknown, CustomErrorField = never> {
5
- type: AppErrorType;
6
- message: string;
7
- fields?: RequestErrors<T>;
8
- status?: number;
9
- original?: HttpServiceError<T> | SchemaFail<T> | Error;
10
- custom?: CustomErrorField;
11
- retry?: () => unknown;
12
- }
13
- export type ErrorType<T = unknown> = Error | HttpServiceError<T> | SchemaFail<T>;
14
- export declare const baseParseHttpError: <T = unknown, D = never>(error: HttpServiceError<T>, retry?: () => unknown | Promise<unknown>) => Promise<AppError<T, D>>;
15
- export declare const baseParseSchemaError: <SchemaData = unknown, D = never>(error: SchemaFail<SchemaData>, retry?: () => unknown | Promise<unknown>) => Promise<AppError<SchemaData, D>>;
16
- export declare const baseParseBaseError: <D = never>(error: Error, retry?: () => unknown | Promise<unknown>) => Promise<AppError<never, D>>;
17
- export declare const createErrorParser: <BaseError = unknown, Custom = unknown>(parsers?: {
18
- parseBaseError?: typeof baseParseBaseError<Custom>;
19
- parseHttpError?: typeof baseParseHttpError<BaseError, Custom>;
20
- parseSchemaError?: typeof baseParseSchemaError<BaseError, Custom>;
21
- }) => (<T = unknown>(error: ErrorType<BaseError>, retry?: () => unknown | Promise<unknown>) => Promise<AppError<T, Custom>>);
1
+ import { AppError, type IAppError } from '../../shared/appError/AppError.js';
2
+ import type { AsyncHelperRetry } from './AsyncHelpers.js';
3
+ export declare const createErrorHandler: <CustomData extends object>(handle?: <T = unknown>(error: AppError<T>, asyncHelperRetry: AsyncHelperRetry) => Promise<IAppError<T> & CustomData>) => <T = unknown>(error: Error, asyncHelperRetry?: AsyncHelperRetry) => Promise<IAppError<T> & CustomData>;
@@ -1,45 +1,14 @@
1
- import { HttpServiceError } from '../../infra/httpService/index.js';
2
- import { SchemaFail } from '../schema/index.js';
3
- export const baseParseHttpError = async (error, retry) => {
4
- const err = {
5
- type: 'http',
6
- message: error.message ?? 'unexpected error',
7
- status: error.status ?? 500,
8
- original: error,
9
- retry
10
- };
11
- return { ...err, retry: undefined, original: undefined };
12
- };
13
- export const baseParseSchemaError = async (error, retry) => {
14
- const err = {
15
- type: 'schema',
16
- message: 'schema validation error',
17
- status: 422,
18
- fields: error.getErrors(),
19
- original: error,
20
- retry
21
- };
22
- return { ...err, retry: undefined, original: undefined };
23
- };
24
- export const baseParseBaseError = async (error, retry) => {
25
- const err = {
26
- type: 'app',
27
- message: error.message,
28
- original: error,
29
- retry
30
- };
31
- return { ...err, retry: undefined, original: undefined };
32
- };
33
- export const createErrorParser = (parsers) => {
34
- return async (error, retry) => {
35
- const { parseBaseError = baseParseBaseError, parseHttpError = baseParseHttpError, parseSchemaError = baseParseSchemaError } = parsers ?? {};
36
- switch (true) {
37
- case error instanceof HttpServiceError:
38
- return (await parseHttpError(error, retry));
39
- case error instanceof SchemaFail:
40
- return (await parseSchemaError(error, retry));
41
- default:
42
- return (await parseBaseError(error, retry));
1
+ import { AppError } from '../../shared/appError/AppError.js';
2
+ export const createErrorHandler = (handle) => {
3
+ return async (error, asyncHelperRetry) => {
4
+ const appError = new AppError(error);
5
+ if (handle) {
6
+ const handled = await handle(appError, asyncHelperRetry ?? { can: false });
7
+ if (handled?.appErrorConvert) {
8
+ return handled;
9
+ }
10
+ throw new Error('Method "handle" must return result of "toPlainObject" method in AppError');
43
11
  }
12
+ return appError.toPlainObject();
44
13
  };
45
14
  };
@@ -2,8 +2,10 @@ type TransformationParams<SchemaData> = {
2
2
  validate?: boolean;
3
3
  onValidationError?: (errors: RequestErrors<SchemaData>) => void;
4
4
  };
5
- type DeepKeys<SchemaData> = SchemaData extends object ? {
6
- [K in keyof SchemaData & string]: SchemaData[K] extends object ? K | `${K}.${DeepKeys<SchemaData[K]>}` : K;
5
+ type AtomicObject = Date | File | Blob | FileList | FormData | URL | RegExp | ArrayBuffer | DataView | Promise<unknown>;
6
+ type IsAtomic<T> = T extends AtomicObject ? true : false;
7
+ type DeepKeys<SchemaData> = IsAtomic<SchemaData> extends true ? never : SchemaData extends object ? {
8
+ [K in keyof SchemaData & string]: IsAtomic<SchemaData[K]> extends true ? K : SchemaData[K] extends object ? K | `${K}.${DeepKeys<SchemaData[K]>}` : K;
7
9
  }[keyof SchemaData & string] : never;
8
10
  export type ValidationParams<SchemaData = unknown, CurrentValue = unknown, CurrentKey = string> = {
9
11
  val: CurrentValue;
@@ -19,14 +21,21 @@ export interface ValidationErrorsMap {
19
21
  }
20
22
  export type ValidationResult = ValidationMessage | ValidationErrorsMap | ValidationErrorsMap[] | undefined;
21
23
  export type ValidationRuleResult<CurrentValue, ListValues = unknown, CurrentKey = string> = (params: ValidationParams<CurrentValue, ListValues, CurrentKey>) => ValidationResult;
22
- type ValidationErrors<Errors> = Errors extends ReadonlyArray<infer U> ? ValidationErrors<U>[] : Errors extends object ? {
24
+ type ValidationErrors<Errors> = Errors extends ReadonlyArray<infer U> ? ValidationErrors<U>[] : IsAtomic<Errors> extends true ? ValidationMessage : Errors extends object ? {
23
25
  [K in keyof Errors]?: ValidationErrors<Errors[K]>;
24
26
  } : ValidationMessage;
25
27
  export type RequestErrors<SchemaData> = Partial<ValidationErrors<SchemaData>>;
26
28
  export type RequestRules<SchemaData> = Partial<Record<DeepKeys<SchemaData>, ValidationRuleResult<SchemaData>[]>>;
27
- export declare class SchemaFail<SchemaData> {
29
+ export interface ISchemaError<SchemaData> extends Error {
30
+ message: string;
31
+ data: RequestErrors<SchemaData>;
32
+ }
33
+ export declare class SchemaFail<SchemaData> extends Error implements ISchemaError<SchemaData> {
28
34
  private _errors;
35
+ data: RequestErrors<SchemaData>;
36
+ message: string;
29
37
  constructor(_errors: RequestErrors<SchemaData>);
38
+ getSelfTypedData<SelfTypedData = unknown>(): RequestErrors<SelfTypedData>;
30
39
  getErrors(): Partial<ValidationErrors<SchemaData>>;
31
40
  }
32
41
  interface SchemaBuilder<SchemaData, Rules = unknown, TransformResult = SchemaData, CustomMethods = unknown> {
@@ -1,8 +1,17 @@
1
1
  import { FormDataUtil } from '@azure-net/tools';
2
- export class SchemaFail {
2
+ import { AzureNetKitInternalError } from '../../shared/appError/AppError.js';
3
+ export class SchemaFail extends Error {
3
4
  _errors;
5
+ data;
6
+ message;
4
7
  constructor(_errors) {
8
+ super('Validation failed');
5
9
  this._errors = _errors;
10
+ this.message = 'Validation failed';
11
+ this.data = _errors;
12
+ }
13
+ getSelfTypedData() {
14
+ return this.data;
6
15
  }
7
16
  getErrors() {
8
17
  return this._errors;
@@ -67,7 +76,7 @@ class SchemaBuilderImpl {
67
76
  let _errors = {};
68
77
  let _isValid = true;
69
78
  if (typeof _preparedData !== 'object') {
70
- throw Error('Data to validate is not an object');
79
+ throw new AzureNetKitInternalError('[Schema] Data in "from" method can be only valid object or formData.');
71
80
  }
72
81
  const validated = (params) => {
73
82
  _isValid = true;
@@ -1,3 +1,4 @@
1
1
  export * from './Ru.js';
2
2
  export * from './En.js';
3
3
  export * from './WithI18n.js';
4
+ export * from './types.js';
@@ -1,3 +1,4 @@
1
1
  export * from './Ru.js';
2
2
  export * from './En.js';
3
3
  export * from './WithI18n.js';
4
+ export * from './types.js';
@@ -0,0 +1,5 @@
1
+ export { createPresenter, createStore, createPresenterFactory, createStoreFactory, clearCache } from '../edges/index.js';
2
+ export { createAsyncHelpers, type AsyncHelperRetry, type AsyncResourceSettings, type AsyncActionResponse } from './delivery/injectableDependencies/AsyncHelpers.js';
3
+ export { createErrorHandler } from './delivery/injectableDependencies/ErrorHandler.js';
4
+ export { createSchemaFactory, schema, type Schema, type RequestErrors, type ISchemaError, type ValidationResult, type ValidationRuleResult, type ValidationParams, type ValidationMessage, type ValidationErrorsMap } from './delivery/schema/Schema.js';
5
+ export { createRules, validationMessagesRu, validationMessagesI18n, validationMessagesEn, type ValidationRuleParams, type BaseValidationMessages } from './delivery/schema/rules/index.js';
@@ -0,0 +1,5 @@
1
+ export { createPresenter, createStore, createPresenterFactory, createStoreFactory, clearCache } from '../edges/index.js';
2
+ export { createAsyncHelpers } from './delivery/injectableDependencies/AsyncHelpers.js';
3
+ export { createErrorHandler } from './delivery/injectableDependencies/ErrorHandler.js';
4
+ export { createSchemaFactory, schema } from './delivery/schema/Schema.js';
5
+ export { createRules, validationMessagesRu, validationMessagesI18n, validationMessagesEn } from './delivery/schema/rules/index.js';
@@ -0,0 +1,4 @@
1
+ export { AppError, ErrorTypes, AzureNetKitInternalError, type IAppError } from './shared/appError/AppError.js';
2
+ export { HttpServiceError } from './infra/httpService/HttpServiceInstance.js';
3
+ export { AsyncHelperError } from './delivery/injectableDependencies/AsyncHelpers.js';
4
+ export { SchemaFail } from './delivery/schema/Schema.js';
@@ -0,0 +1,4 @@
1
+ export { AppError, ErrorTypes, AzureNetKitInternalError } from './shared/appError/AppError.js';
2
+ export { HttpServiceError } from './infra/httpService/HttpServiceInstance.js';
3
+ export { AsyncHelperError } from './delivery/injectableDependencies/AsyncHelpers.js';
4
+ export { SchemaFail } from './delivery/schema/Schema.js';
@@ -1,8 +1,7 @@
1
- export * from './delivery/index.js';
2
- export * from './shared/middleware/index.js';
3
- export * from './shared/classMirror/index.js';
4
- export * from './shared/cookie/index.js';
5
- export * from './shared/boundaryProvider/index.js';
6
- export * from './shared/appEventBus/index.js';
7
- export * from './ui/index.js';
8
- export * from './svelte/index.js';
1
+ export { event, stop, prevent, once, immediate, type EventHandler, onClickOutside, scrollTo, Mask, masked } from './ui/index.js';
2
+ export { createQuery, createAsyncSignal, createActiveForm, refreshAsyncSignal, refreshAllAsyncSignals, type AsyncSignalOptions, type AsyncSignalSvelte, type QueryController, type CreateQueryOptions, type AsyncSignalSource, type AsyncStatus } from './svelte/index.js';
3
+ export { createMiddlewareManager, type IMiddleware } from './shared/middleware/index.js';
4
+ export { ClassMirror } from './shared/classMirror/index.js';
5
+ export { UniversalCookie, type CookieOptions } from './shared/cookie/index.js';
6
+ export { createBoundaryProvider, cleanupProvider, type ProviderSettings } from './shared/boundaryProvider/index.js';
7
+ export { AppEvents } from './shared/appEventBus/index.js';
@@ -1,8 +1,7 @@
1
- export * from './delivery/index.js';
2
- export * from './shared/middleware/index.js';
3
- export * from './shared/classMirror/index.js';
4
- export * from './shared/cookie/index.js';
5
- export * from './shared/boundaryProvider/index.js';
6
- export * from './shared/appEventBus/index.js';
7
- export * from './ui/index.js';
8
- export * from './svelte/index.js';
1
+ export { event, stop, prevent, once, immediate, onClickOutside, scrollTo, Mask, masked } from './ui/index.js';
2
+ export { createQuery, createAsyncSignal, createActiveForm, refreshAsyncSignal, refreshAllAsyncSignals } from './svelte/index.js';
3
+ export { createMiddlewareManager } from './shared/middleware/index.js';
4
+ export { ClassMirror } from './shared/classMirror/index.js';
5
+ export { UniversalCookie } from './shared/cookie/index.js';
6
+ export { createBoundaryProvider, cleanupProvider } from './shared/boundaryProvider/index.js';
7
+ export { AppEvents } from './shared/appEventBus/index.js';
@@ -17,8 +17,13 @@ export interface IHttpServiceResponse<T = unknown> {
17
17
  message: string;
18
18
  raw?: Response;
19
19
  }
20
- export interface IHttpServiceError<T = unknown> extends IHttpServiceResponse<T> {
20
+ export interface IHttpServiceError<T = unknown> {
21
+ type: HttpErrorTypes;
22
+ response?: Response;
21
23
  original?: Error;
24
+ message: string;
25
+ status: number;
26
+ data?: T;
22
27
  }
23
28
  export declare class HttpServiceResponse<T> implements IHttpServiceResponse<T> {
24
29
  headers: Record<string, string>;
@@ -29,15 +34,18 @@ export declare class HttpServiceResponse<T> implements IHttpServiceResponse<T> {
29
34
  raw?: Response;
30
35
  constructor({ headers, status, success, data, message, raw }: IHttpServiceResponse<T>);
31
36
  }
32
- export declare class HttpServiceError<T> implements IHttpServiceError<T> {
33
- headers: Record<string, string>;
37
+ export declare enum HttpErrorTypes {
38
+ Internal = "internal",
39
+ External = "external"
40
+ }
41
+ export declare class HttpServiceError<T> extends Error implements IHttpServiceError<T> {
42
+ data?: T;
34
43
  status: number;
35
- success: boolean;
36
- data: T;
37
44
  message: string;
45
+ type: HttpErrorTypes;
38
46
  original?: Error;
39
- raw?: Response;
40
- constructor({ headers, status, success, data, message, original, raw }: IHttpServiceError<T>);
47
+ response?: Response;
48
+ constructor({ status, data, message, original, type, response }: Partial<IHttpServiceError<T>>);
41
49
  }
42
50
  export interface HttpInstanceNormalizedRequest {
43
51
  url: string | URL;
@@ -53,7 +61,7 @@ export interface HttpInstanceNormalizedRequest {
53
61
  requestInit: Omit<RequestInit, 'method' | 'headers' | 'body'>;
54
62
  }
55
63
  export type HttpInstanceOnRequest = (request: HttpInstanceNormalizedRequest) => void | Promise<void>;
56
- export type HttpInstanceOnError = (error: HttpServiceError<unknown>, request: HttpInstanceNormalizedRequest) => HttpServiceError<unknown> | Promise<HttpServiceError<unknown>>;
64
+ export type HttpInstanceOnError = (error: HttpServiceError<unknown>, request: HttpInstanceNormalizedRequest) => void | Promise<void>;
57
65
  export type HttpInstanceDoFetch = <T = unknown>(request: HttpInstanceNormalizedRequest) => Promise<IHttpServiceResponse<T>>;
58
66
  export interface IHttpInstanceOptions extends Omit<RequestInit, 'headers' | 'method'> {
59
67
  headers?: NonNullable<RequestInit['headers']> | Record<string, string | undefined>;