@ahoo-wang/fetcher-wow 1.2.6 → 1.2.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/README.md CHANGED
@@ -64,14 +64,19 @@ HTTP client for sending commands to the Wow framework. The client provides metho
64
64
  either synchronously or as a stream of events.
65
65
 
66
66
  ```typescript
67
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
67
+ import {
68
+ Fetcher,
69
+ FetchExchange,
70
+ RequestInterceptor,
71
+ URL_RESOLVE_INTERCEPTOR_ORDER,
72
+ } from '@ahoo-wang/fetcher';
68
73
  import '@ahoo-wang/fetcher-eventstream';
69
74
  import {
70
75
  CommandClient,
71
76
  CommandRequest,
72
77
  HttpMethod,
73
78
  CommandHttpHeaders,
74
- CommandStage
79
+ CommandStage,
75
80
  } from '@ahoo-wang/fetcher-wow';
76
81
  import { idGenerator } from '@ahoo-wang/fetcher-cosec';
77
82
 
@@ -89,13 +94,8 @@ class AppendOwnerId implements RequestInterceptor {
89
94
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
90
95
 
91
96
  intercept(exchange: FetchExchange) {
92
- exchange.request.urlParams = {
93
- path: {
94
- ...exchange.request.urlParams?.path,
95
- ownerId: currentUserId,
96
- },
97
- query: exchange.request.urlParams?.query,
98
- };
97
+ const urlParams = exchange.ensureRequestUrlParams();
98
+ urlParams.path['ownerId'] = currentUserId;
99
99
  }
100
100
  }
101
101
 
@@ -119,7 +119,7 @@ interface AddCartItem {
119
119
  quantity: number;
120
120
  }
121
121
 
122
- type AddCartItemCommand = CommandRequest<AddCartItem>
122
+ type AddCartItemCommand = CommandRequest<AddCartItem>;
123
123
 
124
124
  // Create a command request
125
125
  const addCartItemCommand: AddCartItemCommand = {
@@ -211,7 +211,12 @@ const dateConditions = [
211
211
  Client for querying materialized snapshots with comprehensive query operations:
212
212
 
213
213
  ```typescript
214
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
214
+ import {
215
+ Fetcher,
216
+ FetchExchange,
217
+ RequestInterceptor,
218
+ URL_RESOLVE_INTERCEPTOR_ORDER,
219
+ } from '@ahoo-wang/fetcher';
215
220
  import '@ahoo-wang/fetcher-eventstream';
216
221
  import {
217
222
  SnapshotQueryClient,
@@ -245,13 +250,8 @@ class AppendOwnerId implements RequestInterceptor {
245
250
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
246
251
 
247
252
  intercept(exchange: FetchExchange) {
248
- exchange.request.urlParams = {
249
- path: {
250
- ...exchange.request.urlParams?.path,
251
- ownerId: currentUserId,
252
- },
253
- query: exchange.request.urlParams?.query,
254
- };
253
+ const urlParams = exchange.ensureRequestUrlParams();
254
+ urlParams.path['ownerId'] = currentUserId;
255
255
  }
256
256
  }
257
257
 
@@ -331,7 +331,12 @@ const singleState = await cartSnapshotQueryClient.singleState(singleQuery);
331
331
  Client for querying domain event streams with comprehensive query operations:
332
332
 
333
333
  ```typescript
334
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
334
+ import {
335
+ Fetcher,
336
+ FetchExchange,
337
+ RequestInterceptor,
338
+ URL_RESOLVE_INTERCEPTOR_ORDER,
339
+ } from '@ahoo-wang/fetcher';
335
340
  import '@ahoo-wang/fetcher-eventstream';
336
341
  import {
337
342
  EventStreamQueryClient,
@@ -355,13 +360,8 @@ class AppendOwnerId implements RequestInterceptor {
355
360
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
356
361
 
357
362
  intercept(exchange: FetchExchange) {
358
- exchange.request.urlParams = {
359
- path: {
360
- ...exchange.request.urlParams?.path,
361
- ownerId: currentUserId,
362
- },
363
- query: exchange.request.urlParams?.query,
364
- };
363
+ const urlParams = exchange.ensureRequestUrlParams();
364
+ urlParams.path['ownerId'] = currentUserId;
365
365
  }
366
366
  }
367
367
 
@@ -412,7 +412,12 @@ const paged = await cartEventStreamQueryClient.paged(pagedQuery);
412
412
  ### Complete Example with Command and Query Flow
413
413
 
414
414
  ```typescript
415
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
415
+ import {
416
+ Fetcher,
417
+ FetchExchange,
418
+ RequestInterceptor,
419
+ URL_RESOLVE_INTERCEPTOR_ORDER,
420
+ } from '@ahoo-wang/fetcher';
416
421
  import '@ahoo-wang/fetcher-eventstream';
417
422
  import {
418
423
  CommandClient,
@@ -450,13 +455,8 @@ class AppendOwnerId implements RequestInterceptor {
450
455
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
451
456
 
452
457
  intercept(exchange: FetchExchange) {
453
- exchange.request.urlParams = {
454
- path: {
455
- ...exchange.request.urlParams?.path,
456
- ownerId: currentUserId,
457
- },
458
- query: exchange.request.urlParams?.query,
459
- };
458
+ const urlParams = exchange.ensureRequestUrlParams();
459
+ urlParams.path['ownerId'] = currentUserId;
460
460
  }
461
461
  }
462
462
 
@@ -485,7 +485,7 @@ interface AddCartItem {
485
485
  quantity: number;
486
486
  }
487
487
 
488
- type AddCartItemCommand = CommandRequest<AddCartItem>
488
+ type AddCartItemCommand = CommandRequest<AddCartItem>;
489
489
 
490
490
  // 1. Send command to add item to cart
491
491
  const addItemCommand: AddCartItemCommand = {
@@ -501,7 +501,7 @@ const addItemCommand: AddCartItemCommand = {
501
501
 
502
502
  const commandResult = await cartCommandClient.send(
503
503
  CartCommandEndpoints.addCartItem,
504
- addItemCommand
504
+ addItemCommand,
505
505
  );
506
506
  console.log('Command executed:', commandResult);
507
507
 
@@ -546,4 +546,4 @@ Apache-2.0
546
546
 
547
547
  <p align="center">
548
548
  Part of the <a href="https://github.com/Ahoo-Wang/fetcher">Fetcher</a> ecosystem
549
- </p>
549
+ </p>
package/README.zh-CN.md CHANGED
@@ -57,14 +57,19 @@ import { CommandResult, CommandStage } from '@ahoo-wang/fetcher-wow';
57
57
  用于向 Wow 框架发送命令的 HTTP 客户端。该客户端提供了同步或流式接收命令结果的方法。
58
58
 
59
59
  ```typescript
60
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
60
+ import {
61
+ Fetcher,
62
+ FetchExchange,
63
+ RequestInterceptor,
64
+ URL_RESOLVE_INTERCEPTOR_ORDER,
65
+ } from '@ahoo-wang/fetcher';
61
66
  import '@ahoo-wang/fetcher-eventstream';
62
67
  import {
63
68
  CommandClient,
64
69
  CommandRequest,
65
70
  HttpMethod,
66
71
  CommandHttpHeaders,
67
- CommandStage
72
+ CommandStage,
68
73
  } from '@ahoo-wang/fetcher-wow';
69
74
  import { idGenerator } from '@ahoo-wang/fetcher-cosec';
70
75
 
@@ -82,13 +87,8 @@ class AppendOwnerId implements RequestInterceptor {
82
87
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
83
88
 
84
89
  intercept(exchange: FetchExchange) {
85
- exchange.request.urlParams = {
86
- path: {
87
- ...exchange.request.urlParams?.path,
88
- ownerId: currentUserId,
89
- },
90
- query: exchange.request.urlParams?.query,
91
- };
90
+ const urlParams = exchange.ensureRequestUrlParams();
91
+ urlParams.path['ownerId'] = currentUserId;
92
92
  }
93
93
  }
94
94
 
@@ -112,7 +112,7 @@ interface AddCartItem {
112
112
  quantity: number;
113
113
  }
114
114
 
115
- type AddCartItemCommand = CommandRequest<AddCartItem>
115
+ type AddCartItemCommand = CommandRequest<AddCartItem>;
116
116
 
117
117
  // 创建命令请求
118
118
  const addCartItemCommand: AddCartItemCommand = {
@@ -203,7 +203,12 @@ const dateConditions = [
203
203
  用于查询物化快照的客户端,支持全面的查询操作:
204
204
 
205
205
  ```typescript
206
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
206
+ import {
207
+ Fetcher,
208
+ FetchExchange,
209
+ RequestInterceptor,
210
+ URL_RESOLVE_INTERCEPTOR_ORDER,
211
+ } from '@ahoo-wang/fetcher';
207
212
  import '@ahoo-wang/fetcher-eventstream';
208
213
  import {
209
214
  SnapshotQueryClient,
@@ -237,13 +242,8 @@ class AppendOwnerId implements RequestInterceptor {
237
242
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
238
243
 
239
244
  intercept(exchange: FetchExchange) {
240
- exchange.request.urlParams = {
241
- path: {
242
- ...exchange.request.urlParams?.path,
243
- ownerId: currentUserId,
244
- },
245
- query: exchange.request.urlParams?.query,
246
- };
245
+ const urlParams = exchange.ensureRequestUrlParams();
246
+ urlParams.path['ownerId'] = currentUserId;
247
247
  }
248
248
  }
249
249
 
@@ -320,7 +320,12 @@ const singleState = await cartSnapshotQueryClient.singleState(singleQuery);
320
320
  用于查询领域事件流的客户端,支持全面的查询操作:
321
321
 
322
322
  ```typescript
323
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
323
+ import {
324
+ Fetcher,
325
+ FetchExchange,
326
+ RequestInterceptor,
327
+ URL_RESOLVE_INTERCEPTOR_ORDER,
328
+ } from '@ahoo-wang/fetcher';
324
329
  import '@ahoo-wang/fetcher-eventstream';
325
330
  import {
326
331
  EventStreamQueryClient,
@@ -344,13 +349,8 @@ class AppendOwnerId implements RequestInterceptor {
344
349
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
345
350
 
346
351
  intercept(exchange: FetchExchange) {
347
- exchange.request.urlParams = {
348
- path: {
349
- ...exchange.request.urlParams?.path,
350
- ownerId: currentUserId,
351
- },
352
- query: exchange.request.urlParams?.query,
353
- };
352
+ const urlParams = exchange.ensureRequestUrlParams();
353
+ urlParams.path['ownerId'] = currentUserId;
354
354
  }
355
355
  }
356
356
 
@@ -399,7 +399,12 @@ const paged = await cartEventStreamQueryClient.paged(pagedQuery);
399
399
  ### 完整的命令和查询流程示例
400
400
 
401
401
  ```typescript
402
- import { Fetcher, FetchExchange, RequestInterceptor, URL_RESOLVE_INTERCEPTOR_ORDER } from '@ahoo-wang/fetcher';
402
+ import {
403
+ Fetcher,
404
+ FetchExchange,
405
+ RequestInterceptor,
406
+ URL_RESOLVE_INTERCEPTOR_ORDER,
407
+ } from '@ahoo-wang/fetcher';
403
408
  import '@ahoo-wang/fetcher-eventstream';
404
409
  import {
405
410
  CommandClient,
@@ -437,13 +442,8 @@ class AppendOwnerId implements RequestInterceptor {
437
442
  readonly order: number = URL_RESOLVE_INTERCEPTOR_ORDER - 1;
438
443
 
439
444
  intercept(exchange: FetchExchange) {
440
- exchange.request.urlParams = {
441
- path: {
442
- ...exchange.request.urlParams?.path,
443
- ownerId: currentUserId,
444
- },
445
- query: exchange.request.urlParams?.query,
446
- };
445
+ const urlParams = exchange.ensureRequestUrlParams();
446
+ urlParams.path['ownerId'] = currentUserId;
447
447
  }
448
448
  }
449
449
 
@@ -472,7 +472,7 @@ interface AddCartItem {
472
472
  quantity: number;
473
473
  }
474
474
 
475
- type AddCartItemCommand = CommandRequest<AddCartItem>
475
+ type AddCartItemCommand = CommandRequest<AddCartItem>;
476
476
 
477
477
  // 1. 发送命令添加商品到购物车
478
478
  const addItemCommand: AddCartItemCommand = {
@@ -488,7 +488,7 @@ const addItemCommand: AddCartItemCommand = {
488
488
 
489
489
  const commandResult = await cartCommandClient.send(
490
490
  CartCommandEndpoints.addCartItem,
491
- addItemCommand
491
+ addItemCommand,
492
492
  );
493
493
  console.log('命令执行完成:', commandResult);
494
494
 
@@ -533,4 +533,4 @@ Apache-2.0
533
533
 
534
534
  <p align="center">
535
535
  <a href="https://github.com/Ahoo-Wang/fetcher">Fetcher</a> 生态系统的一部分
536
- </p>
536
+ </p>
@@ -1 +1 @@
1
- {"version":3,"file":"commandClient.d.ts","sourceRoot":"","sources":["../../src/command/commandClient.ts"],"names":[],"mappings":"AAaA,OAAO,EAA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BAAtB,OAAO,EAAE,aAAa;IAGrD;;;;;;;;OAQG;cACa,WAAW,CAAC,CAAC,EAC3B,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,cAAc,EAClC,SAAS,GAAE,eAAuC,GACjD,OAAO,CAAC,CAAC,CAAC;IAUb;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,cAAc,GACjC,OAAO,CAAC,aAAa,CAAC;IAIzB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,iBAAiB,CACrB,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,cAAc,GACjC,OAAO,CAAC,wBAAwB,CAAC;CAWrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"commandRequest.d.ts","sourceRoot":"","sources":["../../src/command/commandRequest.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;CA4G5D;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzE,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,gBAAgB;IACjF,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;CACT"}
1
+ {"version":3,"file":"commandRequest.d.ts","sourceRoot":"","sources":["../../src/command/commandRequest.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;CA4G5D;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzE,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACvD,SAAQ,gBAAgB;IACxB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"commandResult.d.ts","sourceRoot":"","sources":["../../src/command/commandResult.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAC/B,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;;;;;;;GASG;AACH,MAAM,WAAW,aACf,SAAQ,UAAU,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,+BAA+B;IACjC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,wBAAwB,GAAG,cAAc,CACnD,mBAAmB,CAAC,aAAa,CAAC,CACnC,CAAC"}
1
+ {"version":3,"file":"commandResult.d.ts","sourceRoot":"","sources":["../../src/command/commandResult.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAC/B,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,WAAW,aACf,SAAQ,UAAU,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,+BAA+B;IACjC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,wBAAwB,GAAG,cAAc,CACnD,mBAAmB,CAAC,aAAa,CAAC,CACnC,CAAC"}