@leancodepl/axios-cqrs-client 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 +17 -17
- package/index.cjs.js +4 -4
- package/index.esm.js +4 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -47,11 +47,11 @@ Creates CQRS client with automatic response key uncapitalization using "@leancod
|
|
|
47
47
|
import { mkCqrsClient } from "@leancodepl/axios-cqrs-client"
|
|
48
48
|
|
|
49
49
|
const client = mkCqrsClient({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
cqrsEndpoint: "https://api.example.com",
|
|
51
|
+
tokenProvider: {
|
|
52
|
+
getToken: () => Promise.resolve(localStorage.getItem("token")),
|
|
53
|
+
invalidateToken: () => Promise.resolve(true),
|
|
54
|
+
},
|
|
55
55
|
})
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -59,13 +59,13 @@ const client = mkCqrsClient({
|
|
|
59
59
|
|
|
60
60
|
```typescript
|
|
61
61
|
interface GetUserQuery {
|
|
62
|
-
|
|
62
|
+
userId: string
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
interface UserResult {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
id: string
|
|
67
|
+
name: string
|
|
68
|
+
email: string
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const getUser = client.createQuery<GetUserQuery, UserResult>("GetUser")
|
|
@@ -73,7 +73,7 @@ const getUser = client.createQuery<GetUserQuery, UserResult>("GetUser")
|
|
|
73
73
|
const response = await getUser({ userId: "123" })
|
|
74
74
|
|
|
75
75
|
if (response.isSuccess) {
|
|
76
|
-
|
|
76
|
+
console.log("User:", response.result)
|
|
77
77
|
}
|
|
78
78
|
```
|
|
79
79
|
|
|
@@ -81,8 +81,8 @@ if (response.isSuccess) {
|
|
|
81
81
|
|
|
82
82
|
```typescript
|
|
83
83
|
interface CreateUserCommand {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
name: string
|
|
85
|
+
email: string
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
const errorCodes = { EmailExists: 1, InvalidEmail: 2 } as const
|
|
@@ -91,10 +91,10 @@ const createUser = client.createCommand<CreateUserCommand, typeof errorCodes>("C
|
|
|
91
91
|
const response = await createUser({ name: "John", email: "john@example.com" })
|
|
92
92
|
|
|
93
93
|
createUser
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
.handle({ name: "John", email: "john@example.com" })
|
|
95
|
+
.handle("success", () => console.log("User created"))
|
|
96
|
+
.handle("EmailExists", () => console.log("Email already exists"))
|
|
97
|
+
.check()
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
### Uncapitalized Client
|
|
@@ -103,7 +103,7 @@ createUser
|
|
|
103
103
|
import { mkUncapitalizedCqrsClient } from "@leancodepl/axios-cqrs-client"
|
|
104
104
|
|
|
105
105
|
const client = mkUncapitalizedCqrsClient({
|
|
106
|
-
|
|
106
|
+
cqrsEndpoint: "https://api.example.com",
|
|
107
107
|
})
|
|
108
108
|
|
|
109
109
|
// Automatically transforms { UserId: '123' } to { userId: '123' }
|
package/index.cjs.js
CHANGED
|
@@ -30,11 +30,11 @@ function createError(error, options) {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Creates CQRS client with Axios for HTTP communication and command/query handling.
|
|
33
|
-
*
|
|
33
|
+
*
|
|
34
34
|
* Provides type-safe methods for creating queries, operations, and commands with automatic
|
|
35
35
|
* token management, retry logic, and response handling. Supports validation error handling
|
|
36
36
|
* and HTTP status code management.
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* @param cqrsEndpoint - Base URL for CQRS API endpoints
|
|
39
39
|
* @param tokenProvider - Optional token provider for authentication
|
|
40
40
|
* @param axiosOptions - Optional Axios configuration options
|
|
@@ -160,10 +160,10 @@ function uncapitalizeResponse(response) {
|
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Creates CQRS client with automatic response key uncapitalization using "@leancodepl/utils".
|
|
163
|
-
*
|
|
163
|
+
*
|
|
164
164
|
* Extends the base CQRS client to automatically transform response object keys from
|
|
165
165
|
* PascalCase to camelCase using deep transformation.
|
|
166
|
-
*
|
|
166
|
+
*
|
|
167
167
|
* @param params - Configuration object for CQRS client
|
|
168
168
|
* @param params.cqrsEndpoint - Base URL for CQRS API endpoints
|
|
169
169
|
* @param params.tokenProvider - Optional token provider for authentication
|
package/index.esm.js
CHANGED
|
@@ -28,11 +28,11 @@ function createError(error, options) {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Creates CQRS client with Axios for HTTP communication and command/query handling.
|
|
31
|
-
*
|
|
31
|
+
*
|
|
32
32
|
* Provides type-safe methods for creating queries, operations, and commands with automatic
|
|
33
33
|
* token management, retry logic, and response handling. Supports validation error handling
|
|
34
34
|
* and HTTP status code management.
|
|
35
|
-
*
|
|
35
|
+
*
|
|
36
36
|
* @param cqrsEndpoint - Base URL for CQRS API endpoints
|
|
37
37
|
* @param tokenProvider - Optional token provider for authentication
|
|
38
38
|
* @param axiosOptions - Optional Axios configuration options
|
|
@@ -158,10 +158,10 @@ function uncapitalizeResponse(response) {
|
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* Creates CQRS client with automatic response key uncapitalization using "@leancodepl/utils".
|
|
161
|
-
*
|
|
161
|
+
*
|
|
162
162
|
* Extends the base CQRS client to automatically transform response object keys from
|
|
163
163
|
* PascalCase to camelCase using deep transformation.
|
|
164
|
-
*
|
|
164
|
+
*
|
|
165
165
|
* @param params - Configuration object for CQRS client
|
|
166
166
|
* @param params.cqrsEndpoint - Base URL for CQRS API endpoints
|
|
167
167
|
* @param params.tokenProvider - Optional token provider for authentication
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/axios-cqrs-client",
|
|
3
|
-
"version": "9.6.
|
|
3
|
+
"version": "9.6.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"node": ">=18.0.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@leancodepl/cqrs-client-base": "9.6.
|
|
14
|
-
"@leancodepl/validation": "9.6.
|
|
13
|
+
"@leancodepl/cqrs-client-base": "9.6.6",
|
|
14
|
+
"@leancodepl/validation": "9.6.6",
|
|
15
15
|
"axios": ">=1.6.0"
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|