@ahoo-wang/fetcher-wow 1.0.2 → 1.0.5
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 +108 -96
- package/README.zh-CN.md +0 -85
- package/dist/command/commandHttpClient.d.ts +133 -0
- package/dist/command/commandHttpClient.d.ts.map +1 -0
- package/dist/command/commandHttpRequest.d.ts +48 -0
- package/dist/command/commandHttpRequest.d.ts.map +1 -0
- package/dist/command/index.d.ts +2 -0
- package/dist/command/index.d.ts.map +1 -1
- package/dist/index.es.js +208 -168
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/query/event/domainEventStream.d.ts +25 -0
- package/dist/query/event/domainEventStream.d.ts.map +1 -0
- package/dist/query/event/eventStreamQueryApi.d.ts +5 -0
- package/dist/query/event/eventStreamQueryApi.d.ts.map +1 -0
- package/dist/query/event/index.d.ts +3 -0
- package/dist/query/event/index.d.ts.map +1 -0
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.d.ts.map +1 -1
- package/dist/query/queryApi.d.ts +11 -0
- package/dist/query/queryApi.d.ts.map +1 -0
- package/dist/query/snapshot/index.d.ts +3 -0
- package/dist/query/snapshot/index.d.ts.map +1 -0
- package/dist/query/{snapshot.d.ts → snapshot/snapshot.d.ts} +1 -1
- package/dist/query/snapshot/snapshot.d.ts.map +1 -0
- package/dist/query/snapshot/snapshotQueryApi.d.ts +5 -0
- package/dist/query/snapshot/snapshotQueryApi.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/messaging.d.ts +4 -0
- package/dist/types/messaging.d.ts.map +1 -0
- package/package.json +4 -3
- package/dist/query/snapshot.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ const request = {
|
|
|
53
53
|
[CommandHeaders.AGGREGATE_ID]: 'aggregate-456',
|
|
54
54
|
[CommandHeaders.REQUEST_ID]: 'request-789',
|
|
55
55
|
},
|
|
56
|
-
body:
|
|
56
|
+
body: command
|
|
57
57
|
};
|
|
58
58
|
```
|
|
59
59
|
|
|
@@ -92,35 +92,124 @@ const commandRequest: CommandRequest = {
|
|
|
92
92
|
stream: false,
|
|
93
93
|
};
|
|
94
94
|
```
|
|
95
|
-
|
|
96
95
|
#### CommandResult
|
|
97
96
|
|
|
98
97
|
Interface representing the result of command execution:
|
|
99
98
|
|
|
100
99
|
```typescript
|
|
101
100
|
import { CommandResult, CommandStage } from '@ahoo-wang/fetcher-wow';
|
|
101
|
+
```
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
#### CommandHttpClient
|
|
104
|
+
|
|
105
|
+
HTTP client for sending commands to the Wow framework. This client provides methods to send commands and receive results
|
|
106
|
+
either synchronously or as a stream of events.
|
|
107
|
+
|
|
108
|
+
##### Usage
|
|
109
|
+
|
|
110
|
+
First, create a fetcher instance with base configuration and add the EventStreamInterceptor:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { Fetcher } from '@ahoo-wang/fetcher';
|
|
114
|
+
import { EventStreamInterceptor } from '@ahoo-wang/fetcher-eventstream';
|
|
115
|
+
|
|
116
|
+
const wowFetcher = new Fetcher({
|
|
117
|
+
baseURL: 'http://localhost:8080/',
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Add EventStreamInterceptor to handle Server-Sent Events
|
|
121
|
+
wowFetcher.interceptors.response.use(new EventStreamInterceptor());
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Then create a CommandHttpClient instance:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { CommandHttpClient } from '@ahoo-wang/fetcher-wow';
|
|
128
|
+
|
|
129
|
+
const commandHttpClient = new CommandHttpClient(wowFetcher);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
##### Sending a Command
|
|
133
|
+
|
|
134
|
+
To send a command and wait for the result:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { CommandHeaders, CommandStage, HttpMethod } from '@ahoo-wang/fetcher-wow';
|
|
138
|
+
|
|
139
|
+
const command = {
|
|
140
|
+
path: 'owner/{ownerId}/cart/add_cart_item',
|
|
141
|
+
method: HttpMethod.POST,
|
|
142
|
+
headers: {
|
|
143
|
+
[CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,
|
|
144
|
+
},
|
|
145
|
+
urlParams: {
|
|
146
|
+
path: {
|
|
147
|
+
ownerId: 'ownerId',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
body: {
|
|
151
|
+
productId: 'productId',
|
|
152
|
+
quantity: 1,
|
|
119
153
|
},
|
|
120
|
-
signalTime: Date.now(),
|
|
121
154
|
};
|
|
155
|
+
|
|
156
|
+
const result = await commandHttpClient.send(command);
|
|
157
|
+
console.log('Command result:', result);
|
|
122
158
|
```
|
|
123
159
|
|
|
160
|
+
##### Sending a Command and Receiving Stream Results
|
|
161
|
+
|
|
162
|
+
For long-running commands, you can receive results as a stream of events:
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const commandResultStream = await commandHttpClient.sendAndWaitStream(command);
|
|
166
|
+
for await (const commandResultEvent of commandResultStream) {
|
|
167
|
+
console.log('Received:', commandResultEvent.data);
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
##### API
|
|
172
|
+
|
|
173
|
+
**Constructor**
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
new CommandHttpClient(fetcher
|
|
177
|
+
:
|
|
178
|
+
Fetcher
|
|
179
|
+
)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Creates a new CommandHttpClient instance.
|
|
183
|
+
|
|
184
|
+
- `fetcher` - The Fetcher instance to use for HTTP requests
|
|
185
|
+
|
|
186
|
+
**send**
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
send(commandHttpRequest
|
|
190
|
+
:
|
|
191
|
+
CommandHttpRequest
|
|
192
|
+
):
|
|
193
|
+
Promise<CommandResult>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Sends a command and waits for the result. This method sends a command to the Wow framework and waits for the processing
|
|
197
|
+
to complete before returning the result.
|
|
198
|
+
|
|
199
|
+
**sendAndWaitStream**
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
sendAndWaitStream(commandHttpRequest
|
|
203
|
+
:
|
|
204
|
+
CommandHttpRequest
|
|
205
|
+
):
|
|
206
|
+
Promise<CommandResultEventStream>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Sends a command and returns a stream of results as events. This method sets the Accept header to text/event-stream to
|
|
210
|
+
receive Server-Sent Events, and uses a JSON event stream result extractor to parse the response. It's useful for
|
|
211
|
+
long-running commands where you want to receive progress updates or multiple results.
|
|
212
|
+
|
|
124
213
|
#### CommandResultEventStream
|
|
125
214
|
|
|
126
215
|
Type alias for a readable stream of CommandResult events:
|
|
@@ -133,8 +222,6 @@ import { JsonServerSentEventStream } from '@ahoo-wang/fetcher-eventstream';
|
|
|
133
222
|
type CommandResultEventStream = JsonServerSentEventStream<CommandResult>;
|
|
134
223
|
```
|
|
135
224
|
|
|
136
|
-
````
|
|
137
|
-
|
|
138
225
|
### Query Module
|
|
139
226
|
|
|
140
227
|
#### Condition Builder
|
|
@@ -351,81 +438,6 @@ const functionInfo: FunctionInfo = {
|
|
|
351
438
|
|
|
352
439
|
## 🛠️ Advanced Usage
|
|
353
440
|
|
|
354
|
-
### Complete Command Flow Example
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
import {
|
|
358
|
-
CommandRequest,
|
|
359
|
-
CommandHeaders,
|
|
360
|
-
CommandResult,
|
|
361
|
-
CommandStage,
|
|
362
|
-
} from '@ahoo-wang/fetcher-wow';
|
|
363
|
-
import { fetchEventStream } from '@ahoo-wang/fetcher-eventstream';
|
|
364
|
-
|
|
365
|
-
// 1. Create command request
|
|
366
|
-
const commandRequest: CommandRequest = {
|
|
367
|
-
path: '/commands/user/CreateUser',
|
|
368
|
-
method: 'POST',
|
|
369
|
-
headers: {
|
|
370
|
-
[CommandHeaders.TENANT_ID]: 'tenant-123',
|
|
371
|
-
[CommandHeaders.REQUEST_ID]: 'req-' + Date.now(),
|
|
372
|
-
},
|
|
373
|
-
body: {
|
|
374
|
-
name: 'John Doe',
|
|
375
|
-
email: 'john@example.com',
|
|
376
|
-
},
|
|
377
|
-
timeout: 10000,
|
|
378
|
-
localFirst: true,
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
// 2. Execute command and wait for result
|
|
382
|
-
async function executeCommand(request: CommandRequest): Promise<CommandResult> {
|
|
383
|
-
// Implementation depends on your HTTP client
|
|
384
|
-
// This is just an example structure
|
|
385
|
-
const response = await fetch('/api' + request.path, {
|
|
386
|
-
method: request.method,
|
|
387
|
-
headers: request.headers,
|
|
388
|
-
body: JSON.stringify(request.body),
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
return response.json();
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// 3. Stream command results in real-time
|
|
395
|
-
async function streamCommandResults() {
|
|
396
|
-
const eventStream = fetchEventStream('/commands/stream');
|
|
397
|
-
const commandResultStream = eventStream as CommandResultEventStream;
|
|
398
|
-
|
|
399
|
-
const reader = commandResultStream.getReader();
|
|
400
|
-
try {
|
|
401
|
-
while (true) {
|
|
402
|
-
const { done, value } = await reader.read();
|
|
403
|
-
if (done) break;
|
|
404
|
-
|
|
405
|
-
const result: CommandResult = value.data;
|
|
406
|
-
|
|
407
|
-
// Handle different stages
|
|
408
|
-
switch (result.stage) {
|
|
409
|
-
case CommandStage.SENT:
|
|
410
|
-
console.log('Command sent to bus');
|
|
411
|
-
break;
|
|
412
|
-
case CommandStage.PROCESSED:
|
|
413
|
-
console.log('Command processed by aggregate');
|
|
414
|
-
break;
|
|
415
|
-
case CommandStage.SNAPSHOT:
|
|
416
|
-
console.log('Snapshot generated');
|
|
417
|
-
break;
|
|
418
|
-
case CommandStage.PROJECTED:
|
|
419
|
-
console.log('Events projected to read model');
|
|
420
|
-
break;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
} finally {
|
|
424
|
-
reader.releaseLock();
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
```
|
|
428
|
-
|
|
429
441
|
### Complex Query Building
|
|
430
442
|
|
|
431
443
|
```typescript
|
package/README.zh-CN.md
CHANGED
|
@@ -131,16 +131,6 @@ import { JsonServerSentEventStream } from '@ahoo-wang/fetcher-eventstream';
|
|
|
131
131
|
|
|
132
132
|
// CommandResultEventStream 是 CommandResult 的 JsonServerSentEventStream
|
|
133
133
|
type CommandResultEventStream = JsonServerSentEventStream<CommandResult>;
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
while (true) {
|
|
137
|
-
const { done, value } = await reader.read();
|
|
138
|
-
if (done) break;
|
|
139
|
-
|
|
140
|
-
const commandResult: CommandResult = value.data;
|
|
141
|
-
console.log('命令结果:', commandResult);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
134
|
````
|
|
145
135
|
|
|
146
136
|
### 查询模块
|
|
@@ -359,81 +349,6 @@ const functionInfo: FunctionInfo = {
|
|
|
359
349
|
|
|
360
350
|
## 🛠️ 高级用法
|
|
361
351
|
|
|
362
|
-
### 完整命令流程示例
|
|
363
|
-
|
|
364
|
-
```typescript
|
|
365
|
-
import {
|
|
366
|
-
CommandRequest,
|
|
367
|
-
CommandHeaders,
|
|
368
|
-
CommandResult,
|
|
369
|
-
CommandStage,
|
|
370
|
-
} from '@ahoo-wang/fetcher-wow';
|
|
371
|
-
import { fetchEventStream } from '@ahoo-wang/fetcher-eventstream';
|
|
372
|
-
|
|
373
|
-
// 1. 创建命令请求
|
|
374
|
-
const commandRequest: CommandRequest = {
|
|
375
|
-
path: '/commands/user/CreateUser',
|
|
376
|
-
method: 'POST',
|
|
377
|
-
headers: {
|
|
378
|
-
[CommandHeaders.TENANT_ID]: 'tenant-123',
|
|
379
|
-
[CommandHeaders.REQUEST_ID]: 'req-' + Date.now(),
|
|
380
|
-
},
|
|
381
|
-
body: {
|
|
382
|
-
name: 'John Doe',
|
|
383
|
-
email: 'john@example.com',
|
|
384
|
-
},
|
|
385
|
-
timeout: 10000,
|
|
386
|
-
localFirst: true,
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
// 2. 执行命令并等待结果
|
|
390
|
-
async function executeCommand(request: CommandRequest): Promise<CommandResult> {
|
|
391
|
-
// 实现依赖于您的 HTTP 客户端
|
|
392
|
-
// 这只是一个示例结构
|
|
393
|
-
const response = await fetch('/api' + request.path, {
|
|
394
|
-
method: request.method,
|
|
395
|
-
headers: request.headers,
|
|
396
|
-
body: JSON.stringify(request.body),
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
return response.json();
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// 3. 实时流式处理命令结果
|
|
403
|
-
async function streamCommandResults() {
|
|
404
|
-
const eventStream = fetchEventStream('/commands/stream');
|
|
405
|
-
const commandResultStream = eventStream as CommandResultEventStream;
|
|
406
|
-
|
|
407
|
-
const reader = commandResultStream.getReader();
|
|
408
|
-
try {
|
|
409
|
-
while (true) {
|
|
410
|
-
const { done, value } = await reader.read();
|
|
411
|
-
if (done) break;
|
|
412
|
-
|
|
413
|
-
const result: CommandResult = value.data;
|
|
414
|
-
|
|
415
|
-
// 处理不同阶段
|
|
416
|
-
switch (result.stage) {
|
|
417
|
-
case CommandStage.SENT:
|
|
418
|
-
console.log('命令已发送到总线');
|
|
419
|
-
break;
|
|
420
|
-
case CommandStage.PROCESSED:
|
|
421
|
-
console.log('命令已被聚合根处理');
|
|
422
|
-
break;
|
|
423
|
-
case CommandStage.SNAPSHOT:
|
|
424
|
-
console.log('已生成快照');
|
|
425
|
-
break;
|
|
426
|
-
case CommandStage.PROJECTED:
|
|
427
|
-
console.log('事件已投影到读模型');
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
} finally {
|
|
432
|
-
reader.releaseLock();
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
352
|
### 复杂查询构建
|
|
438
353
|
|
|
439
354
|
```typescript
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Fetcher } from '@ahoo-wang/fetcher';
|
|
2
|
+
import { CommandResult, CommandResultEventStream } from './commandResult';
|
|
3
|
+
import { CommandHttpRequest } from './commandHttpRequest';
|
|
4
|
+
/**
|
|
5
|
+
* HTTP client for sending commands to the Wow framework.
|
|
6
|
+
*
|
|
7
|
+
* This client provides methods to send commands and receive results either
|
|
8
|
+
* synchronously or as a stream of events. It uses the fetcher-decorator
|
|
9
|
+
* library to handle HTTP communication with appropriate headers and
|
|
10
|
+
* result extraction.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Create a fetcher instance with base configuration
|
|
15
|
+
* const wowFetcher = new Fetcher({
|
|
16
|
+
* baseURL: 'http://localhost:8080/',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Add EventStreamInterceptor to handle Server-Sent Events
|
|
20
|
+
* wowFetcher.interceptors.response.use(new EventStreamInterceptor());
|
|
21
|
+
*
|
|
22
|
+
* // Create CommandHttpClient instance
|
|
23
|
+
* const commandHttpClient = new CommandHttpClient(wowFetcher);
|
|
24
|
+
*
|
|
25
|
+
* // Define a command
|
|
26
|
+
* const command: CommandHttpRequest = {
|
|
27
|
+
* path: 'owner/{ownerId}/cart/add_cart_item',
|
|
28
|
+
* method: HttpMethod.POST,
|
|
29
|
+
* headers: {
|
|
30
|
+
* [CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,
|
|
31
|
+
* },
|
|
32
|
+
* urlParams: {
|
|
33
|
+
* path: {
|
|
34
|
+
* ownerId: 'ownerId',
|
|
35
|
+
* },
|
|
36
|
+
* },
|
|
37
|
+
* body: {
|
|
38
|
+
* productId: 'productId',
|
|
39
|
+
* quantity: 1,
|
|
40
|
+
* },
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* // Send command and wait for result
|
|
44
|
+
* const commandResult = await commandHttpClient.send(command);
|
|
45
|
+
*
|
|
46
|
+
* // Send command and receive result as stream
|
|
47
|
+
* const commandResultStream = await commandHttpClient.sendAndWaitStream(command);
|
|
48
|
+
* for await (const commandResultEvent of commandResultStream) {
|
|
49
|
+
* console.log('Received:', commandResultEvent.data);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class CommandHttpClient {
|
|
54
|
+
readonly fetcher: Fetcher;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new CommandHttpClient instance.
|
|
57
|
+
*
|
|
58
|
+
* @param fetcher - The Fetcher instance to use for HTTP requests
|
|
59
|
+
*/
|
|
60
|
+
constructor(fetcher: Fetcher);
|
|
61
|
+
/**
|
|
62
|
+
* Sends a command and waits for the result.
|
|
63
|
+
*
|
|
64
|
+
* This method sends a command to the Wow framework and waits for the processing
|
|
65
|
+
* to complete before returning the result. The command is sent as an HTTP request
|
|
66
|
+
* with the specified path, method, headers, and body.
|
|
67
|
+
*
|
|
68
|
+
* @param commandHttpRequest - The command HTTP request to send
|
|
69
|
+
* @returns A promise that resolves to the command result
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const command: CommandHttpRequest = {
|
|
74
|
+
* path: 'owner/{ownerId}/cart/add_cart_item',
|
|
75
|
+
* method: HttpMethod.POST,
|
|
76
|
+
* headers: {
|
|
77
|
+
* [CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,
|
|
78
|
+
* },
|
|
79
|
+
* urlParams: {
|
|
80
|
+
* path: {
|
|
81
|
+
* ownerId: 'ownerId',
|
|
82
|
+
* },
|
|
83
|
+
* },
|
|
84
|
+
* body: {
|
|
85
|
+
* productId: 'productId',
|
|
86
|
+
* quantity: 1,
|
|
87
|
+
* },
|
|
88
|
+
* };
|
|
89
|
+
*
|
|
90
|
+
* const result = await commandHttpClient.send(command);
|
|
91
|
+
* console.log('Command result:', result);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
send(commandHttpRequest: CommandHttpRequest): Promise<CommandResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Sends a command and returns a stream of results as events.
|
|
97
|
+
*
|
|
98
|
+
* This method sets the Accept header to text/event-stream to receive
|
|
99
|
+
* Server-Sent Events, and uses a JSON event stream result extractor
|
|
100
|
+
* to parse the response. It's useful for long-running commands where
|
|
101
|
+
* you want to receive progress updates or multiple results.
|
|
102
|
+
*
|
|
103
|
+
* @param commandHttpRequest - The command HTTP request to send
|
|
104
|
+
* @returns A promise that resolves to a stream of command results
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const command: CommandHttpRequest = {
|
|
109
|
+
* path: 'owner/{ownerId}/cart/add_cart_item',
|
|
110
|
+
* method: HttpMethod.POST,
|
|
111
|
+
* headers: {
|
|
112
|
+
* [CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,
|
|
113
|
+
* },
|
|
114
|
+
* urlParams: {
|
|
115
|
+
* path: {
|
|
116
|
+
* ownerId: 'ownerId',
|
|
117
|
+
* },
|
|
118
|
+
* },
|
|
119
|
+
* body: {
|
|
120
|
+
* productId: 'productId',
|
|
121
|
+
* quantity: 1,
|
|
122
|
+
* },
|
|
123
|
+
* };
|
|
124
|
+
*
|
|
125
|
+
* const stream = await commandHttpClient.sendAndWaitStream(command);
|
|
126
|
+
* for await (const event of stream) {
|
|
127
|
+
* console.log('Command result event:', event.data);
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
sendAndWaitStream(commandHttpRequest: CommandHttpRequest): Promise<CommandResultEventStream>;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=commandHttpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandHttpClient.d.ts","sourceRoot":"","sources":["../../src/command/commandHttpClient.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBACa,iBAAiB;aAMA,OAAO,EAAE,OAAO;IAL5C;;;;OAIG;gBACyB,OAAO,EAAE,OAAO;IAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IAEH,IAAI,CAAY,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAI/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IAOG,iBAAiB,CAAY,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAG9G"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RequestHeaders, UrlParams } from '@ahoo-wang/fetcher';
|
|
2
|
+
import { ParameterRequest } from '@ahoo-wang/fetcher-decorator';
|
|
3
|
+
/**
|
|
4
|
+
* Command HTTP Headers Interface
|
|
5
|
+
*
|
|
6
|
+
* Defines the HTTP header fields used in command processing within the Wow framework.
|
|
7
|
+
* This interface extends RequestHeaders to provide type-safe access to all command-related headers.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Using CommandHttpHeaders in a request
|
|
12
|
+
* const headers: CommandHttpHeaders = {
|
|
13
|
+
* [CommandHeaders.TENANT_ID]: 'tenant-123',
|
|
14
|
+
* [CommandHeaders.AGGREGATE_ID]: 'aggregate-456',
|
|
15
|
+
* [CommandHeaders.REQUEST_ID]: 'request-789'
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface CommandHttpHeaders extends RequestHeaders {
|
|
20
|
+
}
|
|
21
|
+
export interface CommandPathParams {
|
|
22
|
+
tenantId?: string;
|
|
23
|
+
ownerId?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
[key: string]: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface CommandUrlParams extends Omit<UrlParams, 'path' | 'query'> {
|
|
28
|
+
path?: CommandPathParams;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Command HTTP Request Interface
|
|
32
|
+
*
|
|
33
|
+
* Extends RequestHeaders to provide type-safe access to command-related HTTP headers.
|
|
34
|
+
* This interface includes only the essential command headers commonly used in HTTP requests.
|
|
35
|
+
*/
|
|
36
|
+
export interface CommandHttpRequest extends ParameterRequest {
|
|
37
|
+
/**
|
|
38
|
+
* Path for the command endpoint (relative to class base path).
|
|
39
|
+
*/
|
|
40
|
+
path: string;
|
|
41
|
+
urlParams?: CommandUrlParams;
|
|
42
|
+
headers?: CommandHttpHeaders;
|
|
43
|
+
/**
|
|
44
|
+
* The body of the command request.
|
|
45
|
+
*/
|
|
46
|
+
body: any;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=commandHttpRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandHttpRequest.d.ts","sourceRoot":"","sources":["../../src/command/commandHttpRequest.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;CA4GzD;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzE,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;OAEG;IACH,IAAI,EAAE,GAAG,CAAC;CACX"}
|
package/dist/command/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|