@leancodepl/cqrs-client-base 9.6.5 → 9.6.6

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/README.md CHANGED
@@ -17,6 +17,7 @@ yarn add @leancodepl/cqrs-client-base
17
17
  Interface for token providers used in CQRS clients.
18
18
 
19
19
  **Properties:**
20
+
20
21
  - `getToken: () => Promise<string | undefined>` - Returns authentication token
21
22
  - `invalidateToken: () => Promise<boolean>` - Invalidates and refreshes token
22
23
 
@@ -25,9 +26,9 @@ Interface for token providers used in CQRS clients.
25
26
  Represents validation errors from commands.
26
27
 
27
28
  **Properties:**
29
+
28
30
  - `PropertyName: string` - Property that failed validation
29
31
  - `ErrorMessage: string` - Human-readable error message
30
- - `AttemptedValue: unknown` - Value that was attempted
31
32
  - `ErrorCode: TErrorCodes[keyof TErrorCodes]` - Error code from provided map
32
33
 
33
34
  ### `CommandResult<TErrorCodes>`
@@ -35,6 +36,7 @@ Represents validation errors from commands.
35
36
  Union type for command results.
36
37
 
37
38
  **Types:**
39
+
38
40
  - `SuccessfulCommandResult` - When command succeeds
39
41
  - `FailedCommandResult<TErrorCodes>` - When command fails with validation errors
40
42
 
@@ -43,6 +45,7 @@ Union type for command results.
43
45
  Union type for API responses.
44
46
 
45
47
  **Types:**
48
+
46
49
  - `ApiSuccess<TResult>` - Successful response with result
47
50
  - `ApiError` - Error response
48
51
 
@@ -51,36 +54,36 @@ Union type for API responses.
51
54
  ### Token Provider Implementation
52
55
 
53
56
  ```typescript
54
- import { TokenProvider } from '@leancodepl/cqrs-client-base';
57
+ import { TokenProvider } from "@leancodepl/cqrs-client-base"
55
58
 
56
59
  const tokenProvider: TokenProvider = {
57
60
  getToken: async () => {
58
- return localStorage.getItem('authToken');
61
+ return localStorage.getItem("authToken")
59
62
  },
60
63
  invalidateToken: async () => {
61
- localStorage.removeItem('authToken');
62
- return true;
63
- }
64
- };
64
+ localStorage.removeItem("authToken")
65
+ return true
66
+ },
67
+ }
65
68
  ```
66
69
 
67
70
  ### Command Error Handling
68
71
 
69
72
  ```typescript
70
- import { CommandResult, ValidationError } from '@leancodepl/cqrs-client-base';
73
+ import { CommandResult, ValidationError } from "@leancodepl/cqrs-client-base"
71
74
 
72
75
  interface UserErrorCodes {
73
- EmailExists: 1;
74
- InvalidEmail: 2;
76
+ EmailExists: 1
77
+ InvalidEmail: 2
75
78
  }
76
79
 
77
80
  function handleCommandResult(result: CommandResult<UserErrorCodes>) {
78
81
  if (result.WasSuccessful) {
79
- console.log('Command succeeded');
82
+ console.log("Command succeeded")
80
83
  } else {
81
84
  result.ValidationErrors.forEach((error: ValidationError<UserErrorCodes>) => {
82
- console.log(`${error.PropertyName}: ${error.ErrorMessage}`);
83
- });
85
+ console.log(`${error.PropertyName}: ${error.ErrorMessage}`)
86
+ })
84
87
  }
85
88
  }
86
89
  ```
@@ -88,13 +91,13 @@ function handleCommandResult(result: CommandResult<UserErrorCodes>) {
88
91
  ### API Response Handling
89
92
 
90
93
  ```typescript
91
- import { ApiResponse } from '@leancodepl/cqrs-client-base';
94
+ import { ApiResponse } from "@leancodepl/cqrs-client-base"
92
95
 
93
96
  function handleApiResponse<T>(response: ApiResponse<T>) {
94
97
  if (response.isSuccess) {
95
- return response.result;
98
+ return response.result
96
99
  } else {
97
- throw new Error('API call failed');
100
+ throw new Error("API call failed")
98
101
  }
99
102
  }
100
- ```
103
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/cqrs-client-base",
3
- "version": "9.6.5",
3
+ "version": "9.6.6",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",
package/src/index.d.ts CHANGED
@@ -5,7 +5,6 @@ export type TokenProvider = {
5
5
  export type ValidationError<TErrorCodes extends Record<string, number>> = {
6
6
  readonly PropertyName: string;
7
7
  readonly ErrorMessage: string;
8
- readonly AttemptedValue: unknown;
9
8
  readonly ErrorCode: TErrorCodes[keyof TErrorCodes];
10
9
  };
11
10
  export type CommandResult<TErrorCodes extends Record<string, number>> = FailedCommandResult<TErrorCodes> | SuccessfulCommandResult;