@leancodepl/rx-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 +28 -28
- package/index.cjs.js +12 -12
- package/index.esm.js +12 -12
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -64,11 +64,11 @@ Reduces object values in RxJS streams by merging properties.
|
|
|
64
64
|
import { mkCqrsClient } from "@leancodepl/rx-cqrs-client"
|
|
65
65
|
|
|
66
66
|
const client = mkCqrsClient({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
cqrsEndpoint: "https://api.example.com",
|
|
68
|
+
tokenProvider: {
|
|
69
|
+
getToken: () => Promise.resolve(localStorage.getItem("token")),
|
|
70
|
+
invalidateToken: () => Promise.resolve(true),
|
|
71
|
+
},
|
|
72
72
|
})
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -78,20 +78,20 @@ const client = mkCqrsClient({
|
|
|
78
78
|
import { switchMap } from "rxjs/operators"
|
|
79
79
|
|
|
80
80
|
interface GetUserQuery {
|
|
81
|
-
|
|
81
|
+
userId: string
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
interface UserResult {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
id: string
|
|
86
|
+
name: string
|
|
87
|
+
email: string
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const getUser = client.createQuery<GetUserQuery, UserResult>("GetUser")
|
|
91
91
|
|
|
92
92
|
getUser({ userId: "123" }).subscribe({
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
next: user => console.log("User:", user),
|
|
94
|
+
error: error => console.error("Error:", error),
|
|
95
95
|
})
|
|
96
96
|
```
|
|
97
97
|
|
|
@@ -102,19 +102,19 @@ import { catchError } from "rxjs/operators"
|
|
|
102
102
|
import { of } from "rxjs"
|
|
103
103
|
|
|
104
104
|
interface CreateUserCommand {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
name: string
|
|
106
|
+
email: string
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
const errorCodes = { EmailExists: 1, InvalidEmail: 2 } as const
|
|
110
110
|
const createUser = client.createCommand<CreateUserCommand, typeof errorCodes>("CreateUser", errorCodes)
|
|
111
111
|
|
|
112
112
|
createUser
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
.handle({ name: "John", email: "john@example.com" })
|
|
114
|
+
.handle("success", () => console.log("User created"))
|
|
115
|
+
.handle("EmailExists", () => console.log("Email already exists"))
|
|
116
|
+
.handle("failure", () => console.log("Creation failed"))
|
|
117
|
+
.check()
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### Reactive Patterns
|
|
@@ -125,14 +125,14 @@ import { fromEvent, switchMap, debounceTime } from "rxjs"
|
|
|
125
125
|
const searchInput = document.getElementById("search") as HTMLInputElement
|
|
126
126
|
|
|
127
127
|
fromEvent(searchInput, "input")
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
128
|
+
.pipe(
|
|
129
|
+
debounceTime(300),
|
|
130
|
+
switchMap(event => {
|
|
131
|
+
const query = (event.target as HTMLInputElement).value
|
|
132
|
+
return client.createQuery("SearchUsers")({ query })
|
|
133
|
+
}),
|
|
134
|
+
)
|
|
135
|
+
.subscribe(results => {
|
|
136
|
+
console.log("Search results:", results)
|
|
137
|
+
})
|
|
138
138
|
```
|
package/index.cjs.js
CHANGED
|
@@ -7,17 +7,17 @@ var validation = require('@leancodepl/validation');
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Handles command responses with RxJS operators for validation error processing.
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* Creates an operator that processes validation error handlers and transforms them
|
|
12
12
|
* into the desired result type using a reducer pattern.
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* @param handlerFunc - Function that processes validation error handlers
|
|
15
15
|
* @returns RxJS operator function for handling command responses
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
18
|
* import { handleCommandResponse } from '@leancodepl/rx-cqrs-client';
|
|
19
|
-
*
|
|
20
|
-
* const handler = handleCommandResponse((handle) =>
|
|
19
|
+
*
|
|
20
|
+
* const handler = handleCommandResponse((handle) =>
|
|
21
21
|
* handle('success', () => 'Success!')
|
|
22
22
|
* .handle('failure', () => 'Failed!')
|
|
23
23
|
* .check()
|
|
@@ -46,10 +46,10 @@ function authGuard(tokenProvider) {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Creates RxJS-based CQRS client for reactive command and query operations.
|
|
49
|
-
*
|
|
49
|
+
*
|
|
50
50
|
* Provides observable-based methods for CQRS operations with automatic authentication,
|
|
51
51
|
* retry logic, and error handling.
|
|
52
|
-
*
|
|
52
|
+
*
|
|
53
53
|
* @param cqrsEndpoint - Base URL for CQRS API endpoints
|
|
54
54
|
* @param tokenProvider - Optional token provider for authentication
|
|
55
55
|
* @param ajaxOptions - Optional RxJS Ajax configuration options
|
|
@@ -138,16 +138,16 @@ function authGuard(tokenProvider) {
|
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Reduces boolean values in RxJS streams using logical AND operation.
|
|
141
|
-
*
|
|
141
|
+
*
|
|
142
142
|
* Creates an operator that combines multiple boolean values into a single result
|
|
143
143
|
* by applying logical AND. Returns true only if all values are true.
|
|
144
|
-
*
|
|
144
|
+
*
|
|
145
145
|
* @returns RxJS operator function that reduces boolean values
|
|
146
146
|
* @example
|
|
147
147
|
* ```typescript
|
|
148
148
|
* import { of } from 'rxjs';
|
|
149
149
|
* import { reduceBoolean } from '@leancodepl/rx-cqrs-client';
|
|
150
|
-
*
|
|
150
|
+
*
|
|
151
151
|
* of(true, true, false).pipe(reduceBoolean()).subscribe(result => {
|
|
152
152
|
* console.log(result); // false
|
|
153
153
|
* });
|
|
@@ -158,16 +158,16 @@ function authGuard(tokenProvider) {
|
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
160
|
* Reduces object values in RxJS streams by merging properties.
|
|
161
|
-
*
|
|
161
|
+
*
|
|
162
162
|
* Creates an operator that combines multiple objects into a single result
|
|
163
163
|
* by spreading properties. Later objects override earlier ones.
|
|
164
|
-
*
|
|
164
|
+
*
|
|
165
165
|
* @returns RxJS operator function that reduces object values
|
|
166
166
|
* @example
|
|
167
167
|
* ```typescript
|
|
168
168
|
* import { of } from 'rxjs';
|
|
169
169
|
* import { reduceObject } from '@leancodepl/rx-cqrs-client';
|
|
170
|
-
*
|
|
170
|
+
*
|
|
171
171
|
* of({ a: 1 }, { b: 2 }, { a: 3 }).pipe(reduceObject()).subscribe(result => {
|
|
172
172
|
* console.log(result); // { a: 3, b: 2 }
|
|
173
173
|
* });
|
package/index.esm.js
CHANGED
|
@@ -5,17 +5,17 @@ import { handleResponse } from '@leancodepl/validation';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Handles command responses with RxJS operators for validation error processing.
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Creates an operator that processes validation error handlers and transforms them
|
|
10
10
|
* into the desired result type using a reducer pattern.
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* @param handlerFunc - Function that processes validation error handlers
|
|
13
13
|
* @returns RxJS operator function for handling command responses
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
16
16
|
* import { handleCommandResponse } from '@leancodepl/rx-cqrs-client';
|
|
17
|
-
*
|
|
18
|
-
* const handler = handleCommandResponse((handle) =>
|
|
17
|
+
*
|
|
18
|
+
* const handler = handleCommandResponse((handle) =>
|
|
19
19
|
* handle('success', () => 'Success!')
|
|
20
20
|
* .handle('failure', () => 'Failed!')
|
|
21
21
|
* .check()
|
|
@@ -44,10 +44,10 @@ function authGuard(tokenProvider) {
|
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Creates RxJS-based CQRS client for reactive command and query operations.
|
|
47
|
-
*
|
|
47
|
+
*
|
|
48
48
|
* Provides observable-based methods for CQRS operations with automatic authentication,
|
|
49
49
|
* retry logic, and error handling.
|
|
50
|
-
*
|
|
50
|
+
*
|
|
51
51
|
* @param cqrsEndpoint - Base URL for CQRS API endpoints
|
|
52
52
|
* @param tokenProvider - Optional token provider for authentication
|
|
53
53
|
* @param ajaxOptions - Optional RxJS Ajax configuration options
|
|
@@ -136,16 +136,16 @@ function authGuard(tokenProvider) {
|
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Reduces boolean values in RxJS streams using logical AND operation.
|
|
139
|
-
*
|
|
139
|
+
*
|
|
140
140
|
* Creates an operator that combines multiple boolean values into a single result
|
|
141
141
|
* by applying logical AND. Returns true only if all values are true.
|
|
142
|
-
*
|
|
142
|
+
*
|
|
143
143
|
* @returns RxJS operator function that reduces boolean values
|
|
144
144
|
* @example
|
|
145
145
|
* ```typescript
|
|
146
146
|
* import { of } from 'rxjs';
|
|
147
147
|
* import { reduceBoolean } from '@leancodepl/rx-cqrs-client';
|
|
148
|
-
*
|
|
148
|
+
*
|
|
149
149
|
* of(true, true, false).pipe(reduceBoolean()).subscribe(result => {
|
|
150
150
|
* console.log(result); // false
|
|
151
151
|
* });
|
|
@@ -156,16 +156,16 @@ function authGuard(tokenProvider) {
|
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Reduces object values in RxJS streams by merging properties.
|
|
159
|
-
*
|
|
159
|
+
*
|
|
160
160
|
* Creates an operator that combines multiple objects into a single result
|
|
161
161
|
* by spreading properties. Later objects override earlier ones.
|
|
162
|
-
*
|
|
162
|
+
*
|
|
163
163
|
* @returns RxJS operator function that reduces object values
|
|
164
164
|
* @example
|
|
165
165
|
* ```typescript
|
|
166
166
|
* import { of } from 'rxjs';
|
|
167
167
|
* import { reduceObject } from '@leancodepl/rx-cqrs-client';
|
|
168
|
-
*
|
|
168
|
+
*
|
|
169
169
|
* of({ a: 1 }, { b: 2 }, { a: 3 }).pipe(reduceObject()).subscribe(result => {
|
|
170
170
|
* console.log(result); // { a: 3, b: 2 }
|
|
171
171
|
* });
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/rx-cqrs-client",
|
|
3
|
-
"version": "9.6.
|
|
3
|
+
"version": "9.6.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@leancodepl/cqrs-client-base": "9.6.
|
|
7
|
-
"@leancodepl/validation": "9.6.
|
|
6
|
+
"@leancodepl/cqrs-client-base": "9.6.6",
|
|
7
|
+
"@leancodepl/validation": "9.6.6",
|
|
8
8
|
"rxjs": ">=7.0.0"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|