@expandai/sdk 0.17.1 → 0.18.0

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/src/Generated.ts CHANGED
@@ -27,27 +27,24 @@ export class FetchFetchRequest extends S.Class<FetchFetchRequest>('FetchFetchReq
27
27
  ),
28
28
  { nullable: true },
29
29
  ),
30
- summary: S.optionalWith(
30
+ links: S.optionalWith(
31
31
  S.Union(
32
32
  S.Boolean,
33
33
  S.Struct({
34
- prompt: S.optionalWith(S.String.pipe(S.maxLength(5000)), { nullable: true }),
34
+ sameDomainOnly: S.optionalWith(S.Boolean, { nullable: true, default: () => true as const }),
35
+ includePatterns: S.optionalWith(S.Array(S.String), { nullable: true }),
36
+ excludePatterns: S.optionalWith(S.Array(S.String), { nullable: true }),
35
37
  }),
36
38
  ),
37
39
  { nullable: true },
38
40
  ),
39
- links: S.optionalWith(
40
- S.Union(
41
- S.Boolean,
42
- S.Struct({
43
- skipEmptyText: S.optionalWith(S.Boolean, { nullable: true }),
44
- includeNavigation: S.optionalWith(S.Boolean, { nullable: true }),
45
- }),
46
- ),
41
+ meta: S.optionalWith(S.Boolean, { nullable: true, default: () => true as const }),
42
+ response: S.optionalWith(
43
+ S.Struct({
44
+ includeHeaders: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
45
+ }),
47
46
  { nullable: true },
48
47
  ),
49
- meta: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
50
- response: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
51
48
  json: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
52
49
  appendix: S.optionalWith(S.Boolean, { nullable: true }),
53
50
  }),
@@ -159,10 +156,24 @@ export class FetchFetch403 extends S.Union(
159
156
 
160
157
  export class PayloadTooLargeTag extends S.Literal('PayloadTooLarge') {}
161
158
 
162
- export class PayloadTooLarge extends S.Class<PayloadTooLarge>('PayloadTooLarge')({
159
+ export class PayloadTooLarge extends S.Struct({
163
160
  _tag: PayloadTooLargeTag,
164
161
  }) {}
165
162
 
163
+ export class FetchPageTooLargeLimitKind extends S.Literal('transfer_bytes', 'domsnapshot_bytes', 'ast_bytes') {}
164
+
165
+ export class FetchPageTooLargeTag extends S.Literal('FetchPageTooLarge') {}
166
+
167
+ export class FetchPageTooLarge extends S.Struct({
168
+ url: S.String,
169
+ limitKind: S.optionalWith(FetchPageTooLargeLimitKind, { nullable: true }),
170
+ limitBytes: S.optionalWith(S.Number, { nullable: true }),
171
+ measuredBytes: S.optionalWith(S.Number, { nullable: true }),
172
+ _tag: FetchPageTooLargeTag,
173
+ }) {}
174
+
175
+ export class FetchFetch413 extends S.Union(PayloadTooLarge, FetchPageTooLarge) {}
176
+
166
177
  export class TooManyRequestsTag extends S.Literal('TooManyRequests') {}
167
178
 
168
179
  export class TooManyRequests extends S.Class<TooManyRequests>('TooManyRequests')({
@@ -178,6 +189,8 @@ export class InternalError extends S.Class<InternalError>('InternalError')({
178
189
  export class ServiceUnavailableTag extends S.Literal('ServiceUnavailable') {}
179
190
 
180
191
  export class ServiceUnavailable extends S.Class<ServiceUnavailable>('ServiceUnavailable')({
192
+ message: S.optionalWith(S.String, { nullable: true }),
193
+ requestId: S.optionalWith(S.String, { nullable: true }),
181
194
  _tag: ServiceUnavailableTag,
182
195
  }) {}
183
196
 
@@ -200,27 +213,24 @@ export class FetchFetchJsonRequest extends S.Class<FetchFetchJsonRequest>('Fetch
200
213
  ),
201
214
  { nullable: true },
202
215
  ),
203
- summary: S.optionalWith(
216
+ links: S.optionalWith(
204
217
  S.Union(
205
218
  S.Boolean,
206
219
  S.Struct({
207
- prompt: S.optionalWith(S.String.pipe(S.maxLength(5000)), { nullable: true }),
220
+ sameDomainOnly: S.optionalWith(S.Boolean, { nullable: true, default: () => true as const }),
221
+ includePatterns: S.optionalWith(S.Array(S.String), { nullable: true }),
222
+ excludePatterns: S.optionalWith(S.Array(S.String), { nullable: true }),
208
223
  }),
209
224
  ),
210
225
  { nullable: true },
211
226
  ),
212
- links: S.optionalWith(
213
- S.Union(
214
- S.Boolean,
215
- S.Struct({
216
- skipEmptyText: S.optionalWith(S.Boolean, { nullable: true }),
217
- includeNavigation: S.optionalWith(S.Boolean, { nullable: true }),
218
- }),
219
- ),
227
+ meta: S.optionalWith(S.Boolean, { nullable: true, default: () => true as const }),
228
+ response: S.optionalWith(
229
+ S.Struct({
230
+ includeHeaders: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
231
+ }),
220
232
  { nullable: true },
221
233
  ),
222
- meta: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
223
- response: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
224
234
  json: S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
225
235
  appendix: S.optionalWith(S.Boolean, { nullable: true }),
226
236
  }),
@@ -332,34 +342,10 @@ export class FetchAssetReference extends S.Struct({
332
342
  bytes: S.Number,
333
343
  }) {}
334
344
 
335
- export class CaptureTelemetryInfoRequestedStyleMode extends S.Literal('compat_full', 'native_default') {}
336
-
337
- export class CaptureTelemetryInfoSelected extends S.Literal('rust') {}
338
-
339
- export class CaptureTelemetryInfoActual extends S.Literal('rust') {}
340
-
341
- export class CaptureTelemetryInfoActualStyleMode extends S.Literal('compat_full', 'native_default') {}
342
-
343
- export class CaptureTelemetryInfoIconBackendDecision extends S.Literal('cpu', 'remote_gpu') {}
344
-
345
- export class CaptureTelemetryInfo extends S.Struct({
346
- requestedStyleMode: S.optionalWith(CaptureTelemetryInfoRequestedStyleMode, { nullable: true }),
347
- selected: CaptureTelemetryInfoSelected,
348
- actual: CaptureTelemetryInfoActual,
349
- actualStyleMode: S.optionalWith(CaptureTelemetryInfoActualStyleMode, { nullable: true }),
350
- rolloutApplied: S.Boolean,
351
- preparedSessionHit: S.optionalWith(S.Boolean, { nullable: true }),
352
- nativePoolHit: S.optionalWith(S.Boolean, { nullable: true }),
353
- preparedPageHit: S.optionalWith(S.Boolean, { nullable: true }),
354
- nativePoolCapacity: S.optionalWith(S.Number, { nullable: true }),
355
- nativePoolProfile: S.optionalWith(S.String, { nullable: true }),
356
- poolHit: S.optionalWith(S.Boolean, { nullable: true }),
357
- connectMs: S.optionalWith(S.Number, { nullable: true }),
358
- warmConnectionAgeMs: S.optionalWith(S.Number, { nullable: true }),
359
- iconBackendDecision: S.optionalWith(CaptureTelemetryInfoIconBackendDecision, { nullable: true }),
360
- }) {}
345
+ export class Int extends S.Int {}
361
346
 
362
347
  export class FetchSearchSnippetLocation extends S.Struct({
348
+ evidenceId: S.optionalWith(Int, { nullable: true }),
363
349
  markdownBlockId: S.optionalWith(S.String, { nullable: true }),
364
350
  nodeIds: S.optionalWith(S.Array(S.Number), { nullable: true }),
365
351
  stateJsonSourceId: S.optionalWith(S.Number, { nullable: true }),
@@ -408,7 +394,6 @@ export class FetchObjectModeResult extends S.Class<FetchObjectModeResult>('Fetch
408
394
  data: S.optionalWith(
409
395
  S.Struct({
410
396
  assets: S.optionalWith(S.Array(FetchAssetReference), { nullable: true }),
411
- captureTelemetry: S.optionalWith(CaptureTelemetryInfo, { nullable: true }),
412
397
  search: S.optionalWith(FetchSearchResult, { nullable: true }),
413
398
  screenshot: S.optionalWith(
414
399
  S.Struct({
@@ -433,13 +418,7 @@ export class FetchFetchJson403 extends S.Union(
433
418
  FetchBlocked,
434
419
  ) {}
435
420
 
436
- export class IncludeHtmlConfig extends S.Record({ key: S.String, value: S.Unknown }) {}
437
-
438
- export class IncludeMarkdownConfig extends S.Record({ key: S.String, value: S.Unknown }) {}
439
-
440
- export class IncludeScreenshotConfig extends S.Struct({
441
- fullPage: S.optionalWith(S.Boolean, { nullable: true }),
442
- }) {}
421
+ export class FetchFetchJson413 extends S.Union(PayloadTooLarge, FetchPageTooLarge) {}
443
422
 
444
423
  export class FetchFetchSearchRequest extends S.Class<FetchFetchSearchRequest>('FetchFetchSearchRequest')({
445
424
  snapshotId: S.String.pipe(S.minLength(1)),
@@ -456,18 +435,13 @@ export class FetchFetchSearchRequest extends S.Class<FetchFetchSearchRequest>('F
456
435
  }),
457
436
  include: S.optionalWith(
458
437
  S.Struct({
459
- html: S.optionalWith(S.Union(S.Boolean, IncludeHtmlConfig), { nullable: true }),
460
- markdown: S.optionalWith(S.Union(S.Boolean, IncludeMarkdownConfig), { nullable: true }),
461
- screenshot: S.optionalWith(S.Union(S.Boolean, IncludeScreenshotConfig), { nullable: true }),
462
- summary: S.optionalWith(
438
+ html: S.optionalWith(S.Union(S.Boolean, S.Record({ key: S.String, value: S.Unknown })), { nullable: true }),
439
+ markdown: S.optionalWith(S.Union(S.Boolean, S.Record({ key: S.String, value: S.Unknown })), { nullable: true }),
440
+ screenshot: S.optionalWith(
463
441
  S.Union(
464
442
  S.Boolean,
465
443
  S.Struct({
466
- prompt: S.optionalWith(S.String.pipe(S.maxLength(5000)), {
467
- nullable: true,
468
- default: () =>
469
- 'You are a helpful assistant that summarizes web page content.\nGiven the markdown content of a web page, provide a clear and concise summary.\nFocus on the main points and key information.\nKeep the summary informative but brief.' as const,
470
- }),
444
+ fullPage: S.optionalWith(S.Boolean, { nullable: true }),
471
445
  }),
472
446
  ),
473
447
  { nullable: true },
@@ -512,6 +486,7 @@ export class FetchSnapshotSearchResult extends S.Class<FetchSnapshotSearchResult
512
486
  response: ResponseInfo,
513
487
  search: FetchSearchResult,
514
488
  durationMs: S.Number.pipe(S.greaterThanOrEqualTo(0)),
489
+ playground: S.String,
515
490
  }) {}
516
491
 
517
492
  export class FetchFetchSearch400 extends S.Union(HttpApiDecodeError, BadRequest) {}
@@ -533,22 +508,21 @@ export class FetchSnapshotSearchNotFound extends S.Class<FetchSnapshotSearchNotF
533
508
  _tag: FetchSnapshotSearchNotFoundTag,
534
509
  }) {}
535
510
 
511
+ export class FetchBatchedParams extends S.Struct({
512
+ 'x-idempotency-key': S.optionalWith(S.String.pipe(S.minLength(1), S.maxLength(255)), { nullable: true }),
513
+ }) {}
514
+
536
515
  export class FetchBatchedRequest extends S.Class<FetchBatchedRequest>('FetchBatchedRequest')({
537
516
  urls: S.NonEmptyArray(S.String),
538
517
  include: S.optionalWith(
539
518
  S.Struct({
540
- html: S.optionalWith(S.Union(S.Boolean, IncludeHtmlConfig), { nullable: true }),
541
- markdown: S.optionalWith(S.Union(S.Boolean, IncludeMarkdownConfig), { nullable: true }),
542
- screenshot: S.optionalWith(S.Union(S.Boolean, IncludeScreenshotConfig), { nullable: true }),
543
- summary: S.optionalWith(
519
+ html: S.optionalWith(S.Union(S.Boolean, S.Record({ key: S.String, value: S.Unknown })), { nullable: true }),
520
+ markdown: S.optionalWith(S.Union(S.Boolean, S.Record({ key: S.String, value: S.Unknown })), { nullable: true }),
521
+ screenshot: S.optionalWith(
544
522
  S.Union(
545
523
  S.Boolean,
546
524
  S.Struct({
547
- prompt: S.optionalWith(S.String.pipe(S.maxLength(5000)), {
548
- nullable: true,
549
- default: () =>
550
- 'You are a helpful assistant that summarizes web page content.\nGiven the markdown content of a web page, provide a clear and concise summary.\nFocus on the main points and key information.\nKeep the summary informative but brief.' as const,
551
- }),
525
+ fullPage: S.optionalWith(S.Boolean, { nullable: true }),
552
526
  }),
553
527
  ),
554
528
  { nullable: true },
@@ -598,15 +572,41 @@ export class FetchBatched403 extends S.Struct({
598
572
  _tag: FetchBatched403Tag,
599
573
  }) {}
600
574
 
575
+ export class BatchedIdempotencyConflictReason extends S.Literal('payload_mismatch') {}
576
+
577
+ export class BatchedIdempotencyConflictTag extends S.Literal('BatchedIdempotencyConflict') {}
578
+
579
+ export class BatchedIdempotencyConflict extends S.Class<BatchedIdempotencyConflict>('BatchedIdempotencyConflict')({
580
+ existingRunId: S.String,
581
+ reason: BatchedIdempotencyConflictReason,
582
+ _tag: BatchedIdempotencyConflictTag,
583
+ }) {}
584
+
601
585
  export class FetchGetBatchedParams extends S.Struct({
602
586
  limit: S.optionalWith(S.String, { nullable: true }),
603
587
  offset: S.optionalWith(S.String, { nullable: true }),
604
588
  include: S.optionalWith(S.String, { nullable: true }),
605
589
  }) {}
606
590
 
607
- export class BatchedStatusStatus extends S.Literal('QUEUED', 'RUNNING', 'COMPLETED', 'FAILED', 'CANCELLED') {}
591
+ export class BatchedStatusStatus extends S.Literal(
592
+ 'QUEUED',
593
+ 'RUNNING',
594
+ 'CANCELLING',
595
+ 'COMPLETED',
596
+ 'FAILED',
597
+ 'CANCELLED',
598
+ ) {}
599
+
600
+ export class BatchedStatusBatchedStatus extends S.Literal(
601
+ 'QUEUED',
602
+ 'RUNNING',
603
+ 'CANCELLING',
604
+ 'COMPLETED',
605
+ 'FAILED',
606
+ 'CANCELLED',
607
+ ) {}
608
608
 
609
- export class BatchedStatusBatchedStatus extends S.Literal('QUEUED', 'RUNNING', 'COMPLETED', 'FAILED', 'CANCELLED') {}
609
+ export class BatchedFetchItemStatus extends S.Literal('QUEUED', 'RUNNING', 'SUCCEEDED', 'FAILED', 'CANCELLED') {}
610
610
 
611
611
  export class IconMeta extends S.Struct({
612
612
  href: S.String.pipe(S.minLength(1)),
@@ -670,6 +670,34 @@ export class RenderEnginesInfo extends S.Struct({
670
670
  tree: S.optionalWith(RenderEnginesInfoTree, { nullable: true }),
671
671
  }) {}
672
672
 
673
+ export class BatchedFetchItem extends S.Struct({
674
+ status: BatchedFetchItemStatus,
675
+ data: S.optionalWith(
676
+ S.Struct({
677
+ response: ResponseInfo,
678
+ meta: S.optionalWith(PageMeta, { nullable: true }),
679
+ json: S.optionalWith(S.Array(S.Struct({})), { nullable: true }),
680
+ snapshotId: S.optionalWith(NonEmptyString, { nullable: true }),
681
+ html: S.optionalWith(S.String.pipe(S.minLength(1)), { nullable: true }),
682
+ markdown: S.optionalWith(S.String.pipe(S.minLength(1)), { nullable: true }),
683
+ screenshot: S.optionalWith(
684
+ S.Struct({
685
+ url: S.String,
686
+ fullPage: S.Boolean,
687
+ }),
688
+ { nullable: true },
689
+ ),
690
+ search: S.optionalWith(FetchSearchResult, { nullable: true }),
691
+ links: S.optionalWith(S.Array(FetchLink), { nullable: true }),
692
+ appendix: S.optionalWith(S.String.pipe(S.minLength(1)), { nullable: true }),
693
+ renderEngines: S.optionalWith(RenderEnginesInfo, { nullable: true }),
694
+ assets: S.optionalWith(S.Array(FetchAssetReference), { nullable: true }),
695
+ }),
696
+ { nullable: true },
697
+ ),
698
+ error: S.optionalWith(S.Union(FetchBlocked, FetchPageTooLarge), { nullable: true }),
699
+ }) {}
700
+
673
701
  export class PaginationMeta extends S.Struct({
674
702
  total: S.Number,
675
703
  limit: S.Number,
@@ -682,38 +710,7 @@ export class BatchedStatus extends S.Class<BatchedStatus>('BatchedStatus')({
682
710
  status: BatchedStatusStatus,
683
711
  batchedStatus: BatchedStatusBatchedStatus,
684
712
  totalUrls: S.Number,
685
- results: S.Array(
686
- S.Struct({
687
- data: S.Struct({
688
- response: ResponseInfo,
689
- meta: S.optionalWith(PageMeta, { nullable: true }),
690
- json: S.optionalWith(S.Array(S.Struct({})), { nullable: true }),
691
- snapshotId: S.optionalWith(NonEmptyString, { nullable: true }),
692
- html: S.optionalWith(S.String.pipe(S.minLength(1)), { nullable: true }),
693
- markdown: S.optionalWith(S.String.pipe(S.minLength(1)), { nullable: true }),
694
- screenshot: S.optionalWith(
695
- S.Struct({
696
- url: S.String,
697
- fullPage: S.Boolean,
698
- }),
699
- { nullable: true },
700
- ),
701
- summary: S.optionalWith(S.String.pipe(S.minLength(1)), { nullable: true }),
702
- search: S.optionalWith(FetchSearchResult, { nullable: true }),
703
- links: S.optionalWith(S.Array(FetchLink), { nullable: true }),
704
- appendix: S.optionalWith(S.String.pipe(S.minLength(1)), { nullable: true }),
705
- renderEngines: S.optionalWith(RenderEnginesInfo, { nullable: true }),
706
- captureTelemetry: S.optionalWith(CaptureTelemetryInfo, { nullable: true }),
707
- assets: S.optionalWith(S.Array(FetchAssetReference), { nullable: true }),
708
- blocked: S.optionalWith(
709
- S.Struct({
710
- blockedType: S.optionalWith(S.String, { nullable: true }),
711
- }),
712
- { nullable: true },
713
- ),
714
- }),
715
- }),
716
- ),
713
+ results: S.Array(BatchedFetchItem),
717
714
  pagination: PaginationMeta,
718
715
  }) {}
719
716
 
@@ -726,6 +723,23 @@ export class BatchedIncludeUnsupported extends S.Struct({
726
723
 
727
724
  export class FetchGetBatched400 extends S.Union(HttpApiDecodeError, BatchedIncludeUnsupported) {}
728
725
 
726
+ export class BatchedCancellationStatus extends S.Literal('CANCELLING', 'CANCELLED') {}
727
+
728
+ export class BatchedCancellation extends S.Class<BatchedCancellation>('BatchedCancellation')({
729
+ id: S.String,
730
+ status: BatchedCancellationStatus,
731
+ }) {}
732
+
733
+ export class BatchedCancellationConflictStatus extends S.Literal('COMPLETED', 'FAILED') {}
734
+
735
+ export class BatchedCancellationConflictTag extends S.Literal('BatchedCancellationConflict') {}
736
+
737
+ export class BatchedCancellationConflict extends S.Class<BatchedCancellationConflict>('BatchedCancellationConflict')({
738
+ id: S.String,
739
+ status: BatchedCancellationConflictStatus,
740
+ _tag: BatchedCancellationConflictTag,
741
+ }) {}
742
+
729
743
  export const make = (
730
744
  httpClient: HttpClient.HttpClient,
731
745
  options: {
@@ -765,7 +779,7 @@ export const make = (
765
779
  '400': (r) => decodeError(r, FetchFetch400),
766
780
  '401': (r) => decodeError(r, AuthFailed),
767
781
  '403': (r) => decodeError(r, FetchFetch403),
768
- '413': (r) => decodeError(r, PayloadTooLarge),
782
+ '413': (r) => decodeError(r, FetchFetch413),
769
783
  '429': (r) => decodeError(r, TooManyRequests),
770
784
  '500': (r) => decodeError(r, InternalError),
771
785
  '503': (r) => decodeError(r, ServiceUnavailable),
@@ -788,7 +802,7 @@ export const make = (
788
802
  '400': (r) => decodeError(r, FetchFetchJson400),
789
803
  '401': (r) => decodeError(r, AuthFailed),
790
804
  '403': (r) => decodeError(r, FetchFetchJson403),
791
- '413': (r) => decodeError(r, PayloadTooLarge),
805
+ '413': (r) => decodeError(r, FetchFetchJson413),
792
806
  '429': (r) => decodeError(r, TooManyRequests),
793
807
  '500': (r) => decodeError(r, InternalError),
794
808
  '503': (r) => decodeError(r, ServiceUnavailable),
@@ -823,7 +837,8 @@ export const make = (
823
837
  ),
824
838
  fetchBatched: (options) =>
825
839
  HttpClientRequest.make('POST')(`/v1/fetch/batched`).pipe(
826
- (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
840
+ HttpClientRequest.setHeaders({ 'x-idempotency-key': options.params['x-idempotency-key'] ?? undefined }),
841
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
827
842
  Effect.flatMap((request) =>
828
843
  Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
829
844
  Effect.flatMap(
@@ -833,6 +848,7 @@ export const make = (
833
848
  '400': (r) => decodeError(r, FetchBatched400),
834
849
  '401': (r) => decodeError(r, AuthFailed),
835
850
  '403': (r) => decodeError(r, FetchBatched403),
851
+ '409': (r) => decodeError(r, BatchedIdempotencyConflict),
836
852
  '413': (r) => decodeError(r, PayloadTooLarge),
837
853
  '429': (r) => decodeError(r, TooManyRequests),
838
854
  '500': (r) => decodeError(r, InternalError),
@@ -869,6 +885,28 @@ export const make = (
869
885
  ),
870
886
  ),
871
887
  ),
888
+ fetchCancelBatched: (id) =>
889
+ HttpClientRequest.make('POST')(`/v1/fetch/batched/${id}/cancel`).pipe(
890
+ Effect.succeed,
891
+ Effect.flatMap((request) =>
892
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
893
+ Effect.flatMap(
894
+ httpClient.execute(request),
895
+ HttpClientResponse.matchStatus({
896
+ '200': (r) => HttpClientResponse.schemaBodyJson(BatchedCancellation)(r),
897
+ '400': (r) => decodeError(r, HttpApiDecodeError),
898
+ '401': (r) => decodeError(r, AuthFailed),
899
+ '409': (r) => decodeError(r, BatchedCancellationConflict),
900
+ '413': (r) => decodeError(r, PayloadTooLarge),
901
+ '429': (r) => decodeError(r, TooManyRequests),
902
+ '500': (r) => decodeError(r, InternalError),
903
+ '503': (r) => decodeError(r, ServiceUnavailable),
904
+ orElse: (response) => unexpectedStatus(request, response),
905
+ }),
906
+ ),
907
+ ),
908
+ ),
909
+ ),
872
910
  }
873
911
  }
874
912
 
@@ -883,7 +921,7 @@ export interface Client {
883
921
  | typeof FetchFetch400.Type
884
922
  | typeof AuthFailed.Type
885
923
  | typeof FetchFetch403.Type
886
- | typeof PayloadTooLarge.Type
924
+ | typeof FetchFetch413.Type
887
925
  | typeof TooManyRequests.Type
888
926
  | typeof InternalError.Type
889
927
  | typeof ServiceUnavailable.Type
@@ -898,7 +936,7 @@ export interface Client {
898
936
  | typeof FetchFetchJson400.Type
899
937
  | typeof AuthFailed.Type
900
938
  | typeof FetchFetchJson403.Type
901
- | typeof PayloadTooLarge.Type
939
+ | typeof FetchFetchJson413.Type
902
940
  | typeof TooManyRequests.Type
903
941
  | typeof InternalError.Type
904
942
  | typeof ServiceUnavailable.Type
@@ -918,15 +956,17 @@ export interface Client {
918
956
  | typeof InternalError.Type
919
957
  | typeof ServiceUnavailable.Type
920
958
  >
921
- readonly fetchBatched: (
922
- options: typeof FetchBatchedRequest.Encoded,
923
- ) => Effect.Effect<
959
+ readonly fetchBatched: (options: {
960
+ readonly params: typeof FetchBatchedParams.Encoded
961
+ readonly payload: typeof FetchBatchedRequest.Encoded
962
+ }) => Effect.Effect<
924
963
  typeof BatchedRun.Type,
925
964
  | HttpClientError.HttpClientError
926
965
  | ParseError
927
966
  | typeof FetchBatched400.Type
928
967
  | typeof AuthFailed.Type
929
968
  | typeof FetchBatched403.Type
969
+ | typeof BatchedIdempotencyConflict.Type
930
970
  | typeof PayloadTooLarge.Type
931
971
  | typeof TooManyRequests.Type
932
972
  | typeof InternalError.Type
@@ -946,4 +986,18 @@ export interface Client {
946
986
  | typeof InternalError.Type
947
987
  | typeof ServiceUnavailable.Type
948
988
  >
989
+ readonly fetchCancelBatched: (
990
+ id: string,
991
+ ) => Effect.Effect<
992
+ typeof BatchedCancellation.Type,
993
+ | HttpClientError.HttpClientError
994
+ | ParseError
995
+ | typeof HttpApiDecodeError.Type
996
+ | typeof AuthFailed.Type
997
+ | typeof BatchedCancellationConflict.Type
998
+ | typeof PayloadTooLarge.Type
999
+ | typeof TooManyRequests.Type
1000
+ | typeof InternalError.Type
1001
+ | typeof ServiceUnavailable.Type
1002
+ >
949
1003
  }
package/src/Internal.ts CHANGED
@@ -11,7 +11,9 @@ import {
11
11
  import * as Generated from './Generated.js'
12
12
  import {
13
13
  type BatchedParams,
14
+ type BatchedRequestOptions,
14
15
  type BatchedResponse,
16
+ type CancelBatchedResponse,
15
17
  ExpandService,
16
18
  type ExpandServiceOptions,
17
19
  type FetchJsonParams,
@@ -37,9 +39,15 @@ function hasApiErrorTag(error: unknown, tag: string): error is TaggedApiError {
37
39
 
38
40
  function apiError(status: number, error: unknown): ExpandApiError {
39
41
  const message =
40
- typeof error === 'object' && error !== null && '_tag' in error && typeof error._tag === 'string'
41
- ? error._tag
42
- : `HTTP ${status}`
42
+ typeof error === 'object' &&
43
+ error !== null &&
44
+ 'message' in error &&
45
+ typeof error.message === 'string' &&
46
+ error.message.length > 0
47
+ ? error.message
48
+ : typeof error === 'object' && error !== null && '_tag' in error && typeof error._tag === 'string'
49
+ ? error._tag
50
+ : `HTTP ${status}`
43
51
  return new ExpandApiError({ message, status, body: error, cause: error })
44
52
  }
45
53
 
@@ -80,6 +88,11 @@ export function toExpandError(error: unknown, timeoutMs: number): ExpandError {
80
88
  (error: unknown) => hasApiErrorTag(error, 'AccessBlocked'),
81
89
  (error) => apiError(403, error),
82
90
  ),
91
+ Match.when(
92
+ (error: unknown) =>
93
+ hasApiErrorTag(error, 'BatchedIdempotencyConflict') || hasApiErrorTag(error, 'BatchedCancellationConflict'),
94
+ (error) => apiError(409, error),
95
+ ),
83
96
  Match.when(
84
97
  (error: unknown) => error instanceof Generated.PayloadTooLarge,
85
98
  (error) => new ExpandApiError({ message: 'PayloadTooLarge', status: 413, body: error, cause: error }),
@@ -106,7 +119,7 @@ export function toExpandError(error: unknown, timeoutMs: number): ExpandError {
106
119
  ),
107
120
  Match.when(
108
121
  (error: unknown) => error instanceof Generated.ServiceUnavailable,
109
- (error) => new ExpandApiError({ message: 'ServiceUnavailable', status: 503, body: error, cause: error }),
122
+ (error) => apiError(503, error),
110
123
  ),
111
124
  Match.when(
112
125
  (error: unknown) => hasApiErrorTag(error, 'ServiceUnavailable'),
@@ -142,6 +155,9 @@ export function toExpandError(error: unknown, timeoutMs: number): ExpandError {
142
155
  * retryable; API errors are retryable only for the standard transient status codes (408/409/429/5xx).
143
156
  */
144
157
  export function isRetryable(error: unknown, timeoutMs: number): boolean {
158
+ if (hasApiErrorTag(error, 'BatchedIdempotencyConflict') || hasApiErrorTag(error, 'BatchedCancellationConflict')) {
159
+ return false
160
+ }
145
161
  // An undecodable response (a transient 5xx with an empty/garbled body, a proxy error page, etc.)
146
162
  // surfaces as a bare ParseError with no HTTP status, so the status-based classification below can't
147
163
  // see the 5xx and the request would fail un-retried. Treat decode failures as retryable — the
@@ -170,7 +186,7 @@ export function isRetryable(error: unknown, timeoutMs: number): boolean {
170
186
  /**
171
187
  * Effect-side bridge between {@link ExpandService} and the Promise-based {@link ExpandClient}.
172
188
  *
173
- * Exposes the same fetch/batched/getBatched methods as `ExpandService` but with the typed `ExpandError`
189
+ * Exposes the same fetch/batched/getBatched/cancelBatched methods as `ExpandService` but with the typed `ExpandError`
174
190
  * channel mapped to the `ExpandClientError` hierarchy that async/await consumers expect. Not exported
175
191
  * from the package — Effect consumers depend on `ExpandService` directly and receive the typed
176
192
  * `ExpandError` unions as-is.
@@ -199,7 +215,7 @@ export class InternalClient extends Effect.Service<InternalClient>()('@expandai/
199
215
 
200
216
  const batched = (
201
217
  params: BatchedParams,
202
- options: RequestOptions = {},
218
+ options: BatchedRequestOptions,
203
219
  ): Effect.Effect<BatchedResponse, ExpandClientError> =>
204
220
  service.batched(params, options).pipe(Effect.mapError((error) => error.toPublicError()))
205
221
 
@@ -209,7 +225,13 @@ export class InternalClient extends Effect.Service<InternalClient>()('@expandai/
209
225
  ): Effect.Effect<GetBatchedResponse, ExpandClientError> =>
210
226
  service.getBatched(id, options).pipe(Effect.mapError((error) => error.toPublicError()))
211
227
 
212
- return { fetch, fetchJson, fetchSearch, batched, getBatched } as const
228
+ const cancelBatched = (
229
+ id: string,
230
+ options: RequestOptions = {},
231
+ ): Effect.Effect<CancelBatchedResponse, ExpandClientError> =>
232
+ service.cancelBatched(id, options).pipe(Effect.mapError((error) => error.toPublicError()))
233
+
234
+ return { fetch, fetchJson, fetchSearch, batched, getBatched, cancelBatched } as const
213
235
  }),
214
236
  }) {
215
237
  /**