@deliverart/sdk-js-error-handler 0.0.7 → 0.0.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @deliverart/sdk-js-error-handler
2
2
 
3
+ ## 0.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 8932e85: increase version pkg
8
+
9
+ ## 0.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 2960c29: Add form state Error
14
+
3
15
  ## 0.0.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -22,6 +22,8 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ApiError: () => ApiError,
24
24
  ErrorHandlerPlugin: () => ErrorHandlerPlugin,
25
+ FormStateError: () => FormStateError,
26
+ formStateErrorToThrowable: () => formStateErrorToThrowable,
25
27
  throwableToFormState: () => throwableToFormState,
26
28
  validationErrorDataSchema: () => validationErrorDataSchema
27
29
  });
@@ -33,6 +35,16 @@ var ApiError = class extends import_axios.AxiosError {
33
35
  };
34
36
 
35
37
  // src/form-state.ts
38
+ var FormStateError = class extends Error {
39
+ constructor(error) {
40
+ super(error.type === "VALIDATION_ERROR" ? "Validation error" : "Unknown error");
41
+ this.error = error;
42
+ this.name = "FormStateError";
43
+ }
44
+ };
45
+ function formStateErrorToThrowable(error) {
46
+ return new FormStateError(error);
47
+ }
36
48
  async function throwableToFormState(fn) {
37
49
  try {
38
50
  const data = await fn();
@@ -107,6 +119,8 @@ var ErrorHandlerPlugin = class {
107
119
  0 && (module.exports = {
108
120
  ApiError,
109
121
  ErrorHandlerPlugin,
122
+ FormStateError,
123
+ formStateErrorToThrowable,
110
124
  throwableToFormState,
111
125
  validationErrorDataSchema
112
126
  });
package/dist/index.d.cts CHANGED
@@ -60,10 +60,15 @@ type FormState<T> = {
60
60
  success: false;
61
61
  error: ApiErrorData;
62
62
  };
63
+ declare class FormStateError extends Error {
64
+ readonly error: ApiErrorData;
65
+ constructor(error: ApiErrorData);
66
+ }
67
+ declare function formStateErrorToThrowable(error: ApiErrorData): FormStateError;
63
68
  declare function throwableToFormState<T>(fn: () => Promise<T>): Promise<FormState<T>>;
64
69
 
65
70
  declare class ErrorHandlerPlugin implements ApiClientPlugin<{}> {
66
71
  setup(client: ApiClient): {};
67
72
  }
68
73
 
69
- export { ApiError, type ApiErrorData, ErrorHandlerPlugin, type FormState, type ValidationErrorData, throwableToFormState, validationErrorDataSchema };
74
+ export { ApiError, type ApiErrorData, ErrorHandlerPlugin, type FormState, FormStateError, type ValidationErrorData, formStateErrorToThrowable, throwableToFormState, validationErrorDataSchema };
package/dist/index.d.ts CHANGED
@@ -60,10 +60,15 @@ type FormState<T> = {
60
60
  success: false;
61
61
  error: ApiErrorData;
62
62
  };
63
+ declare class FormStateError extends Error {
64
+ readonly error: ApiErrorData;
65
+ constructor(error: ApiErrorData);
66
+ }
67
+ declare function formStateErrorToThrowable(error: ApiErrorData): FormStateError;
63
68
  declare function throwableToFormState<T>(fn: () => Promise<T>): Promise<FormState<T>>;
64
69
 
65
70
  declare class ErrorHandlerPlugin implements ApiClientPlugin<{}> {
66
71
  setup(client: ApiClient): {};
67
72
  }
68
73
 
69
- export { ApiError, type ApiErrorData, ErrorHandlerPlugin, type FormState, type ValidationErrorData, throwableToFormState, validationErrorDataSchema };
74
+ export { ApiError, type ApiErrorData, ErrorHandlerPlugin, type FormState, FormStateError, type ValidationErrorData, formStateErrorToThrowable, throwableToFormState, validationErrorDataSchema };
package/dist/index.js CHANGED
@@ -4,6 +4,16 @@ var ApiError = class extends AxiosError {
4
4
  };
5
5
 
6
6
  // src/form-state.ts
7
+ var FormStateError = class extends Error {
8
+ constructor(error) {
9
+ super(error.type === "VALIDATION_ERROR" ? "Validation error" : "Unknown error");
10
+ this.error = error;
11
+ this.name = "FormStateError";
12
+ }
13
+ };
14
+ function formStateErrorToThrowable(error) {
15
+ return new FormStateError(error);
16
+ }
7
17
  async function throwableToFormState(fn) {
8
18
  try {
9
19
  const data = await fn();
@@ -77,6 +87,8 @@ var ErrorHandlerPlugin = class {
77
87
  export {
78
88
  ApiError,
79
89
  ErrorHandlerPlugin,
90
+ FormStateError,
91
+ formStateErrorToThrowable,
80
92
  throwableToFormState,
81
93
  validationErrorDataSchema
82
94
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-error-handler",
3
3
  "description": "Error handling utilities for Deliverart SDK in JavaScript",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "zod": "^3",
16
16
  "axios": "1.9.0",
17
- "@deliverart/sdk-js-core": "0.0.7"
17
+ "@deliverart/sdk-js-core": "0.1.4"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@changesets/cli": "^2.29.4",
package/src/form-state.ts CHANGED
@@ -10,6 +10,17 @@ export type FormState<T> =
10
10
  error: ApiErrorData
11
11
  }
12
12
 
13
+ export class FormStateError extends Error {
14
+ constructor(public readonly error: ApiErrorData) {
15
+ super(error.type === 'VALIDATION_ERROR' ? 'Validation error' : 'Unknown error')
16
+ this.name = 'FormStateError'
17
+ }
18
+ }
19
+
20
+ export function formStateErrorToThrowable(error: ApiErrorData): FormStateError {
21
+ return new FormStateError(error)
22
+ }
23
+
13
24
  export async function throwableToFormState<T>(fn: () => Promise<T>): Promise<FormState<T>> {
14
25
  try {
15
26
  const data = await fn()