@ai-sdk/provider-utils 3.0.0-canary.17 → 3.0.0-canary.19
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +49 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -16
- package/dist/index.mjs.map +1 -1
- package/dist/test/index.js +7 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +7 -0
- package/dist/test/index.mjs.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @ai-sdk/provider-utils
|
2
2
|
|
3
|
+
## 3.0.0-canary.19
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- faf8446: chore (provider-utils): switch to standard-schema
|
8
|
+
|
9
|
+
## 3.0.0-canary.18
|
10
|
+
|
11
|
+
### Major Changes
|
12
|
+
|
13
|
+
- 40acf9b: feat (ui): introduce ChatStore and ChatTransport
|
14
|
+
|
3
15
|
## 3.0.0-canary.17
|
4
16
|
|
5
17
|
### Major Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { JSONValue, JSONParseError, TypeValidationError, APICallError, JSONSchema7 } from '@ai-sdk/provider';
|
2
|
-
import {
|
2
|
+
import { ZodSchema, z } from 'zod';
|
3
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
4
|
+
export * from '@standard-schema/spec';
|
3
5
|
|
4
6
|
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
5
7
|
|
@@ -88,17 +90,17 @@ type Validator<OBJECT = unknown> = {
|
|
88
90
|
* Optional. Validates that the structure of a value matches this schema,
|
89
91
|
* and returns a typed version of the value if it does.
|
90
92
|
*/
|
91
|
-
readonly validate?: (value: unknown) => ValidationResult<OBJECT
|
93
|
+
readonly validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
|
92
94
|
};
|
93
95
|
/**
|
94
96
|
* Create a validator.
|
95
97
|
*
|
96
98
|
* @param validate A validation function for the schema.
|
97
99
|
*/
|
98
|
-
declare function validator<OBJECT>(validate?: undefined | ((value: unknown) => ValidationResult<OBJECT>)): Validator<OBJECT>;
|
100
|
+
declare function validator<OBJECT>(validate?: undefined | ((value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>)): Validator<OBJECT>;
|
99
101
|
declare function isValidator(value: unknown): value is Validator;
|
100
|
-
declare function asValidator<OBJECT>(value: Validator<OBJECT> |
|
101
|
-
declare function
|
102
|
+
declare function asValidator<OBJECT>(value: Validator<OBJECT> | StandardSchemaV1<OBJECT>): Validator<OBJECT>;
|
103
|
+
declare function standardSchemaValidator<OBJECT>(standardSchema: StandardSchemaV1<OBJECT>): Validator<OBJECT>;
|
102
104
|
|
103
105
|
/**
|
104
106
|
* Parses a JSON string into an unknown object.
|
@@ -415,10 +417,10 @@ declare function convertToBase64(value: string | Uint8Array): string;
|
|
415
417
|
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
416
418
|
* @returns {Promise<T>} - The typed object.
|
417
419
|
*/
|
418
|
-
declare function validateTypes<
|
420
|
+
declare function validateTypes<OBJECT>({ value, schema, }: {
|
419
421
|
value: unknown;
|
420
|
-
schema:
|
421
|
-
}): Promise<
|
422
|
+
schema: StandardSchemaV1<OBJECT> | Validator<OBJECT>;
|
423
|
+
}): Promise<OBJECT>;
|
422
424
|
/**
|
423
425
|
* Safely validates the types of an unknown object using a schema and
|
424
426
|
* return a strongly-typed object.
|
@@ -428,12 +430,12 @@ declare function validateTypes<T>({ value, schema: inputSchema, }: {
|
|
428
430
|
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
429
431
|
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
430
432
|
*/
|
431
|
-
declare function safeValidateTypes<
|
433
|
+
declare function safeValidateTypes<OBJECT>({ value, schema, }: {
|
432
434
|
value: unknown;
|
433
|
-
schema:
|
435
|
+
schema: StandardSchemaV1<OBJECT> | Validator<OBJECT>;
|
434
436
|
}): Promise<{
|
435
437
|
success: true;
|
436
|
-
value:
|
438
|
+
value: OBJECT;
|
437
439
|
rawValue: unknown;
|
438
440
|
} | {
|
439
441
|
success: false;
|
@@ -453,4 +455,4 @@ declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any
|
|
453
455
|
useReferences?: boolean;
|
454
456
|
}): Schema<OBJECT>;
|
455
457
|
|
456
|
-
export { type EventSourceChunk, type FetchFunction, type IdGenerator, type ParseResult, type Resolvable, type ResponseHandler, type Schema, type ToolCall, type ToolResult, type ToolResultContent, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceParserStream, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createStatusCodeErrorResponseHandler, delay, extractResponseHeaders, generateId, getErrorMessage, getFromApi, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, validateTypes, validator, validatorSymbol, withoutTrailingSlash, zodSchema
|
458
|
+
export { type EventSourceChunk, type FetchFunction, type IdGenerator, type ParseResult, type Resolvable, type ResponseHandler, type Schema, type ToolCall, type ToolResult, type ToolResultContent, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceParserStream, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createStatusCodeErrorResponseHandler, delay, extractResponseHeaders, generateId, getErrorMessage, getFromApi, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, validateTypes, validator, validatorSymbol, withoutTrailingSlash, zodSchema };
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { JSONValue, JSONParseError, TypeValidationError, APICallError, JSONSchema7 } from '@ai-sdk/provider';
|
2
|
-
import {
|
2
|
+
import { ZodSchema, z } from 'zod';
|
3
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
4
|
+
export * from '@standard-schema/spec';
|
3
5
|
|
4
6
|
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
5
7
|
|
@@ -88,17 +90,17 @@ type Validator<OBJECT = unknown> = {
|
|
88
90
|
* Optional. Validates that the structure of a value matches this schema,
|
89
91
|
* and returns a typed version of the value if it does.
|
90
92
|
*/
|
91
|
-
readonly validate?: (value: unknown) => ValidationResult<OBJECT
|
93
|
+
readonly validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
|
92
94
|
};
|
93
95
|
/**
|
94
96
|
* Create a validator.
|
95
97
|
*
|
96
98
|
* @param validate A validation function for the schema.
|
97
99
|
*/
|
98
|
-
declare function validator<OBJECT>(validate?: undefined | ((value: unknown) => ValidationResult<OBJECT>)): Validator<OBJECT>;
|
100
|
+
declare function validator<OBJECT>(validate?: undefined | ((value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>)): Validator<OBJECT>;
|
99
101
|
declare function isValidator(value: unknown): value is Validator;
|
100
|
-
declare function asValidator<OBJECT>(value: Validator<OBJECT> |
|
101
|
-
declare function
|
102
|
+
declare function asValidator<OBJECT>(value: Validator<OBJECT> | StandardSchemaV1<OBJECT>): Validator<OBJECT>;
|
103
|
+
declare function standardSchemaValidator<OBJECT>(standardSchema: StandardSchemaV1<OBJECT>): Validator<OBJECT>;
|
102
104
|
|
103
105
|
/**
|
104
106
|
* Parses a JSON string into an unknown object.
|
@@ -415,10 +417,10 @@ declare function convertToBase64(value: string | Uint8Array): string;
|
|
415
417
|
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
416
418
|
* @returns {Promise<T>} - The typed object.
|
417
419
|
*/
|
418
|
-
declare function validateTypes<
|
420
|
+
declare function validateTypes<OBJECT>({ value, schema, }: {
|
419
421
|
value: unknown;
|
420
|
-
schema:
|
421
|
-
}): Promise<
|
422
|
+
schema: StandardSchemaV1<OBJECT> | Validator<OBJECT>;
|
423
|
+
}): Promise<OBJECT>;
|
422
424
|
/**
|
423
425
|
* Safely validates the types of an unknown object using a schema and
|
424
426
|
* return a strongly-typed object.
|
@@ -428,12 +430,12 @@ declare function validateTypes<T>({ value, schema: inputSchema, }: {
|
|
428
430
|
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
429
431
|
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
430
432
|
*/
|
431
|
-
declare function safeValidateTypes<
|
433
|
+
declare function safeValidateTypes<OBJECT>({ value, schema, }: {
|
432
434
|
value: unknown;
|
433
|
-
schema:
|
435
|
+
schema: StandardSchemaV1<OBJECT> | Validator<OBJECT>;
|
434
436
|
}): Promise<{
|
435
437
|
success: true;
|
436
|
-
value:
|
438
|
+
value: OBJECT;
|
437
439
|
rawValue: unknown;
|
438
440
|
} | {
|
439
441
|
success: false;
|
@@ -453,4 +455,4 @@ declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any
|
|
453
455
|
useReferences?: boolean;
|
454
456
|
}): Schema<OBJECT>;
|
455
457
|
|
456
|
-
export { type EventSourceChunk, type FetchFunction, type IdGenerator, type ParseResult, type Resolvable, type ResponseHandler, type Schema, type ToolCall, type ToolResult, type ToolResultContent, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceParserStream, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createStatusCodeErrorResponseHandler, delay, extractResponseHeaders, generateId, getErrorMessage, getFromApi, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, validateTypes, validator, validatorSymbol, withoutTrailingSlash, zodSchema
|
458
|
+
export { type EventSourceChunk, type FetchFunction, type IdGenerator, type ParseResult, type Resolvable, type ResponseHandler, type Schema, type ToolCall, type ToolResult, type ToolResultContent, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceParserStream, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createStatusCodeErrorResponseHandler, delay, extractResponseHeaders, generateId, getErrorMessage, getFromApi, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, validateTypes, validator, validatorSymbol, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
@@ -68,12 +69,12 @@ __export(src_exports, {
|
|
68
69
|
resolve: () => resolve,
|
69
70
|
safeParseJSON: () => safeParseJSON,
|
70
71
|
safeValidateTypes: () => safeValidateTypes,
|
72
|
+
standardSchemaValidator: () => standardSchemaValidator,
|
71
73
|
validateTypes: () => validateTypes,
|
72
74
|
validator: () => validator,
|
73
75
|
validatorSymbol: () => validatorSymbol,
|
74
76
|
withoutTrailingSlash: () => withoutTrailingSlash,
|
75
|
-
zodSchema: () => zodSchema
|
76
|
-
zodValidator: () => zodValidator
|
77
|
+
zodSchema: () => zodSchema
|
77
78
|
});
|
78
79
|
module.exports = __toCommonJS(src_exports);
|
79
80
|
|
@@ -465,7 +466,7 @@ function loadSetting({
|
|
465
466
|
}
|
466
467
|
|
467
468
|
// src/parse-json.ts
|
468
|
-
var
|
469
|
+
var import_provider7 = require("@ai-sdk/provider");
|
469
470
|
|
470
471
|
// src/secure-json-parse.ts
|
471
472
|
var suspectProtoRx = /"__proto__"\s*:/;
|
@@ -513,9 +514,10 @@ function secureJsonParse(text) {
|
|
513
514
|
}
|
514
515
|
|
515
516
|
// src/validate-types.ts
|
516
|
-
var
|
517
|
+
var import_provider6 = require("@ai-sdk/provider");
|
517
518
|
|
518
519
|
// src/validator.ts
|
520
|
+
var import_provider5 = require("@ai-sdk/provider");
|
519
521
|
var validatorSymbol = Symbol.for("vercel.ai.validator");
|
520
522
|
function validator(validate) {
|
521
523
|
return { [validatorSymbol]: true, validate };
|
@@ -524,23 +526,29 @@ function isValidator(value) {
|
|
524
526
|
return typeof value === "object" && value !== null && validatorSymbol in value && value[validatorSymbol] === true && "validate" in value;
|
525
527
|
}
|
526
528
|
function asValidator(value) {
|
527
|
-
return isValidator(value) ? value :
|
529
|
+
return isValidator(value) ? value : standardSchemaValidator(value);
|
528
530
|
}
|
529
|
-
function
|
530
|
-
return validator((value) => {
|
531
|
-
const result =
|
532
|
-
return result.
|
531
|
+
function standardSchemaValidator(standardSchema) {
|
532
|
+
return validator(async (value) => {
|
533
|
+
const result = await standardSchema["~standard"].validate(value);
|
534
|
+
return result.issues == null ? { success: true, value: result.value } : {
|
535
|
+
success: false,
|
536
|
+
error: new import_provider5.TypeValidationError({
|
537
|
+
value,
|
538
|
+
cause: result.issues
|
539
|
+
})
|
540
|
+
};
|
533
541
|
});
|
534
542
|
}
|
535
543
|
|
536
544
|
// src/validate-types.ts
|
537
545
|
async function validateTypes({
|
538
546
|
value,
|
539
|
-
schema
|
547
|
+
schema
|
540
548
|
}) {
|
541
|
-
const result = await safeValidateTypes({ value, schema
|
549
|
+
const result = await safeValidateTypes({ value, schema });
|
542
550
|
if (!result.success) {
|
543
|
-
throw
|
551
|
+
throw import_provider6.TypeValidationError.wrap({ value, cause: result.error });
|
544
552
|
}
|
545
553
|
return result.value;
|
546
554
|
}
|
@@ -553,19 +561,19 @@ async function safeValidateTypes({
|
|
553
561
|
if (validator2.validate == null) {
|
554
562
|
return { success: true, value, rawValue: value };
|
555
563
|
}
|
556
|
-
const result = validator2.validate(value);
|
564
|
+
const result = await validator2.validate(value);
|
557
565
|
if (result.success) {
|
558
566
|
return { success: true, value: result.value, rawValue: value };
|
559
567
|
}
|
560
568
|
return {
|
561
569
|
success: false,
|
562
|
-
error:
|
570
|
+
error: import_provider6.TypeValidationError.wrap({ value, cause: result.error }),
|
563
571
|
rawValue: value
|
564
572
|
};
|
565
573
|
} catch (error) {
|
566
574
|
return {
|
567
575
|
success: false,
|
568
|
-
error:
|
576
|
+
error: import_provider6.TypeValidationError.wrap({ value, cause: error }),
|
569
577
|
rawValue: value
|
570
578
|
};
|
571
579
|
}
|
@@ -583,10 +591,10 @@ async function parseJSON({
|
|
583
591
|
}
|
584
592
|
return validateTypes({ value, schema });
|
585
593
|
} catch (error) {
|
586
|
-
if (
|
594
|
+
if (import_provider7.JSONParseError.isInstance(error) || import_provider7.TypeValidationError.isInstance(error)) {
|
587
595
|
throw error;
|
588
596
|
}
|
589
|
-
throw new
|
597
|
+
throw new import_provider7.JSONParseError({ text, cause: error });
|
590
598
|
}
|
591
599
|
}
|
592
600
|
async function safeParseJSON({
|
@@ -602,7 +610,7 @@ async function safeParseJSON({
|
|
602
610
|
} catch (error) {
|
603
611
|
return {
|
604
612
|
success: false,
|
605
|
-
error:
|
613
|
+
error: import_provider7.JSONParseError.isInstance(error) ? error : new import_provider7.JSONParseError({ text, cause: error }),
|
606
614
|
rawValue: void 0
|
607
615
|
};
|
608
616
|
}
|
@@ -634,7 +642,7 @@ function parseJsonEventStream({
|
|
634
642
|
}
|
635
643
|
|
636
644
|
// src/parse-provider-options.ts
|
637
|
-
var
|
645
|
+
var import_provider8 = require("@ai-sdk/provider");
|
638
646
|
async function parseProviderOptions({
|
639
647
|
provider,
|
640
648
|
providerOptions,
|
@@ -648,7 +656,7 @@ async function parseProviderOptions({
|
|
648
656
|
schema
|
649
657
|
});
|
650
658
|
if (!parsedProviderOptions.success) {
|
651
|
-
throw new
|
659
|
+
throw new import_provider8.InvalidArgumentError({
|
652
660
|
argument: "providerOptions",
|
653
661
|
message: `invalid ${provider} provider options`,
|
654
662
|
cause: parsedProviderOptions.error
|
@@ -658,7 +666,7 @@ async function parseProviderOptions({
|
|
658
666
|
}
|
659
667
|
|
660
668
|
// src/post-to-api.ts
|
661
|
-
var
|
669
|
+
var import_provider9 = require("@ai-sdk/provider");
|
662
670
|
var getOriginalFetch2 = () => globalThis.fetch;
|
663
671
|
var postJsonToApi = async ({
|
664
672
|
url,
|
@@ -729,10 +737,10 @@ var postToApi = async ({
|
|
729
737
|
requestBodyValues: body.values
|
730
738
|
});
|
731
739
|
} catch (error) {
|
732
|
-
if (isAbortError(error) ||
|
740
|
+
if (isAbortError(error) || import_provider9.APICallError.isInstance(error)) {
|
733
741
|
throw error;
|
734
742
|
}
|
735
|
-
throw new
|
743
|
+
throw new import_provider9.APICallError({
|
736
744
|
message: "Failed to process error response",
|
737
745
|
cause: error,
|
738
746
|
statusCode: response.status,
|
@@ -751,11 +759,11 @@ var postToApi = async ({
|
|
751
759
|
});
|
752
760
|
} catch (error) {
|
753
761
|
if (error instanceof Error) {
|
754
|
-
if (isAbortError(error) ||
|
762
|
+
if (isAbortError(error) || import_provider9.APICallError.isInstance(error)) {
|
755
763
|
throw error;
|
756
764
|
}
|
757
765
|
}
|
758
|
-
throw new
|
766
|
+
throw new import_provider9.APICallError({
|
759
767
|
message: "Failed to process successful response",
|
760
768
|
cause: error,
|
761
769
|
statusCode: response.status,
|
@@ -771,7 +779,7 @@ var postToApi = async ({
|
|
771
779
|
if (error instanceof TypeError && error.message === "fetch failed") {
|
772
780
|
const cause = error.cause;
|
773
781
|
if (cause != null) {
|
774
|
-
throw new
|
782
|
+
throw new import_provider9.APICallError({
|
775
783
|
message: `Cannot connect to API: ${cause.message}`,
|
776
784
|
cause,
|
777
785
|
url,
|
@@ -794,7 +802,7 @@ async function resolve(value) {
|
|
794
802
|
}
|
795
803
|
|
796
804
|
// src/response-handler.ts
|
797
|
-
var
|
805
|
+
var import_provider10 = require("@ai-sdk/provider");
|
798
806
|
var createJsonErrorResponseHandler = ({
|
799
807
|
errorSchema,
|
800
808
|
errorToMessage,
|
@@ -805,7 +813,7 @@ var createJsonErrorResponseHandler = ({
|
|
805
813
|
if (responseBody.trim() === "") {
|
806
814
|
return {
|
807
815
|
responseHeaders,
|
808
|
-
value: new
|
816
|
+
value: new import_provider10.APICallError({
|
809
817
|
message: response.statusText,
|
810
818
|
url,
|
811
819
|
requestBodyValues,
|
@@ -823,7 +831,7 @@ var createJsonErrorResponseHandler = ({
|
|
823
831
|
});
|
824
832
|
return {
|
825
833
|
responseHeaders,
|
826
|
-
value: new
|
834
|
+
value: new import_provider10.APICallError({
|
827
835
|
message: errorToMessage(parsedError),
|
828
836
|
url,
|
829
837
|
requestBodyValues,
|
@@ -837,7 +845,7 @@ var createJsonErrorResponseHandler = ({
|
|
837
845
|
} catch (parseError) {
|
838
846
|
return {
|
839
847
|
responseHeaders,
|
840
|
-
value: new
|
848
|
+
value: new import_provider10.APICallError({
|
841
849
|
message: response.statusText,
|
842
850
|
url,
|
843
851
|
requestBodyValues,
|
@@ -852,7 +860,7 @@ var createJsonErrorResponseHandler = ({
|
|
852
860
|
var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
|
853
861
|
const responseHeaders = extractResponseHeaders(response);
|
854
862
|
if (response.body == null) {
|
855
|
-
throw new
|
863
|
+
throw new import_provider10.EmptyResponseBodyError({});
|
856
864
|
}
|
857
865
|
return {
|
858
866
|
responseHeaders,
|
@@ -865,7 +873,7 @@ var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) =>
|
|
865
873
|
var createJsonStreamResponseHandler = (chunkSchema) => async ({ response }) => {
|
866
874
|
const responseHeaders = extractResponseHeaders(response);
|
867
875
|
if (response.body == null) {
|
868
|
-
throw new
|
876
|
+
throw new import_provider10.EmptyResponseBodyError({});
|
869
877
|
}
|
870
878
|
let buffer = "";
|
871
879
|
return {
|
@@ -897,7 +905,7 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
897
905
|
});
|
898
906
|
const responseHeaders = extractResponseHeaders(response);
|
899
907
|
if (!parsedResult.success) {
|
900
|
-
throw new
|
908
|
+
throw new import_provider10.APICallError({
|
901
909
|
message: "Invalid JSON response",
|
902
910
|
cause: parsedResult.error,
|
903
911
|
statusCode: response.status,
|
@@ -916,7 +924,7 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
916
924
|
var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
|
917
925
|
const responseHeaders = extractResponseHeaders(response);
|
918
926
|
if (!response.body) {
|
919
|
-
throw new
|
927
|
+
throw new import_provider10.APICallError({
|
920
928
|
message: "Response body is empty",
|
921
929
|
url,
|
922
930
|
requestBodyValues,
|
@@ -932,7 +940,7 @@ var createBinaryResponseHandler = () => async ({ response, url, requestBodyValue
|
|
932
940
|
value: new Uint8Array(buffer)
|
933
941
|
};
|
934
942
|
} catch (error) {
|
935
|
-
throw new
|
943
|
+
throw new import_provider10.APICallError({
|
936
944
|
message: "Failed to read response as array buffer",
|
937
945
|
url,
|
938
946
|
requestBodyValues,
|
@@ -948,7 +956,7 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
948
956
|
const responseBody = await response.text();
|
949
957
|
return {
|
950
958
|
responseHeaders,
|
951
|
-
value: new
|
959
|
+
value: new import_provider10.APICallError({
|
952
960
|
message: response.statusText,
|
953
961
|
url,
|
954
962
|
requestBodyValues,
|
@@ -1025,6 +1033,9 @@ function convertToBase64(value) {
|
|
1025
1033
|
function withoutTrailingSlash(url) {
|
1026
1034
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
1027
1035
|
}
|
1036
|
+
|
1037
|
+
// src/index.ts
|
1038
|
+
__reExport(src_exports, require("@standard-schema/spec"), module.exports);
|
1028
1039
|
// Annotate the CommonJS export names for ESM import in node:
|
1029
1040
|
0 && (module.exports = {
|
1030
1041
|
asSchema,
|
@@ -1065,11 +1076,12 @@ function withoutTrailingSlash(url) {
|
|
1065
1076
|
resolve,
|
1066
1077
|
safeParseJSON,
|
1067
1078
|
safeValidateTypes,
|
1079
|
+
standardSchemaValidator,
|
1068
1080
|
validateTypes,
|
1069
1081
|
validator,
|
1070
1082
|
validatorSymbol,
|
1071
1083
|
withoutTrailingSlash,
|
1072
1084
|
zodSchema,
|
1073
|
-
|
1085
|
+
...require("@standard-schema/spec")
|
1074
1086
|
});
|
1075
1087
|
//# sourceMappingURL=index.js.map
|