@ai-sdk/provider-utils 3.0.0-canary.15 → 3.0.0-canary.17
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 +61 -50
- package/dist/index.d.ts +61 -50
- package/dist/index.js +56 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @ai-sdk/provider-utils
|
2
2
|
|
3
|
+
## 3.0.0-canary.17
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- ea7a7c9: feat (ui): UI message metadata
|
8
|
+
|
9
|
+
## 3.0.0-canary.16
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 87b828f: fix(provider-utils): fix SSE parser bug (CRLF)
|
14
|
+
|
3
15
|
## 3.0.0-canary.15
|
4
16
|
|
5
17
|
### Major Changes
|
package/dist/index.d.mts
CHANGED
@@ -129,6 +129,7 @@ type ParseResult<T> = {
|
|
129
129
|
} | {
|
130
130
|
success: false;
|
131
131
|
error: JSONParseError | TypeValidationError;
|
132
|
+
rawValue: unknown;
|
132
133
|
};
|
133
134
|
/**
|
134
135
|
* Safely parses a JSON string and returns the result as an object of type `unknown`.
|
@@ -241,6 +242,14 @@ declare function loadSetting({ settingValue, environmentVariableName, settingNam
|
|
241
242
|
description: string;
|
242
243
|
}): string;
|
243
244
|
|
245
|
+
/**
|
246
|
+
* Parses a JSON event stream into a stream of parsed JSON objects.
|
247
|
+
*/
|
248
|
+
declare function parseJsonEventStream<T>({ stream, schema, }: {
|
249
|
+
stream: ReadableStream<Uint8Array>;
|
250
|
+
schema: ZodSchema<T>;
|
251
|
+
}): ReadableStream<ParseResult<T>>;
|
252
|
+
|
244
253
|
declare function parseProviderOptions<T>({ provider, providerOptions, schema, }: {
|
245
254
|
provider: string;
|
246
255
|
providerOptions: Record<string, unknown> | undefined;
|
@@ -304,45 +313,6 @@ type Resolvable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
304
313
|
*/
|
305
314
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
306
315
|
|
307
|
-
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
308
|
-
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
309
|
-
declare function convertToBase64(value: string | Uint8Array): string;
|
310
|
-
|
311
|
-
/**
|
312
|
-
* Validates the types of an unknown object using a schema and
|
313
|
-
* return a strongly-typed object.
|
314
|
-
*
|
315
|
-
* @template T - The type of the object to validate.
|
316
|
-
* @param {string} options.value - The object to validate.
|
317
|
-
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
318
|
-
* @returns {Promise<T>} - The typed object.
|
319
|
-
*/
|
320
|
-
declare function validateTypes<T>({ value, schema: inputSchema, }: {
|
321
|
-
value: unknown;
|
322
|
-
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
323
|
-
}): Promise<T>;
|
324
|
-
/**
|
325
|
-
* Safely validates the types of an unknown object using a schema and
|
326
|
-
* return a strongly-typed object.
|
327
|
-
*
|
328
|
-
* @template T - The type of the object to validate.
|
329
|
-
* @param {string} options.value - The JSON object to validate.
|
330
|
-
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
331
|
-
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
332
|
-
*/
|
333
|
-
declare function safeValidateTypes<T>({ value, schema, }: {
|
334
|
-
value: unknown;
|
335
|
-
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
336
|
-
}): Promise<{
|
337
|
-
success: true;
|
338
|
-
value: T;
|
339
|
-
} | {
|
340
|
-
success: false;
|
341
|
-
error: TypeValidationError;
|
342
|
-
}>;
|
343
|
-
|
344
|
-
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
345
|
-
|
346
316
|
/**
|
347
317
|
* Used to mark schemas so we can support both Zod and custom schemas.
|
348
318
|
*/
|
@@ -378,16 +348,6 @@ declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validat
|
|
378
348
|
}): Schema<OBJECT>;
|
379
349
|
declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT> | undefined): Schema<OBJECT>;
|
380
350
|
|
381
|
-
declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any>, options?: {
|
382
|
-
/**
|
383
|
-
* Enables support for references in the schema.
|
384
|
-
* This is required for recursive schemas, e.g. with `z.lazy`.
|
385
|
-
* However, not all language models and providers support such references.
|
386
|
-
* Defaults to `false`.
|
387
|
-
*/
|
388
|
-
useReferences?: boolean;
|
389
|
-
}): Schema<OBJECT>;
|
390
|
-
|
391
351
|
/**
|
392
352
|
Typed tool call that is returned by generateText and streamText.
|
393
353
|
It contains the tool call ID, the tool name, and the tool arguments.
|
@@ -442,4 +402,55 @@ type ToolResultContent = Array<{
|
|
442
402
|
mimeType?: string;
|
443
403
|
}>;
|
444
404
|
|
445
|
-
|
405
|
+
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
406
|
+
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
407
|
+
declare function convertToBase64(value: string | Uint8Array): string;
|
408
|
+
|
409
|
+
/**
|
410
|
+
* Validates the types of an unknown object using a schema and
|
411
|
+
* return a strongly-typed object.
|
412
|
+
*
|
413
|
+
* @template T - The type of the object to validate.
|
414
|
+
* @param {string} options.value - The object to validate.
|
415
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
416
|
+
* @returns {Promise<T>} - The typed object.
|
417
|
+
*/
|
418
|
+
declare function validateTypes<T>({ value, schema: inputSchema, }: {
|
419
|
+
value: unknown;
|
420
|
+
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
421
|
+
}): Promise<T>;
|
422
|
+
/**
|
423
|
+
* Safely validates the types of an unknown object using a schema and
|
424
|
+
* return a strongly-typed object.
|
425
|
+
*
|
426
|
+
* @template T - The type of the object to validate.
|
427
|
+
* @param {string} options.value - The JSON object to validate.
|
428
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
429
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
430
|
+
*/
|
431
|
+
declare function safeValidateTypes<T>({ value, schema, }: {
|
432
|
+
value: unknown;
|
433
|
+
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
434
|
+
}): Promise<{
|
435
|
+
success: true;
|
436
|
+
value: T;
|
437
|
+
rawValue: unknown;
|
438
|
+
} | {
|
439
|
+
success: false;
|
440
|
+
error: TypeValidationError;
|
441
|
+
rawValue: unknown;
|
442
|
+
}>;
|
443
|
+
|
444
|
+
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
445
|
+
|
446
|
+
declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any>, options?: {
|
447
|
+
/**
|
448
|
+
* Enables support for references in the schema.
|
449
|
+
* This is required for recursive schemas, e.g. with `z.lazy`.
|
450
|
+
* However, not all language models and providers support such references.
|
451
|
+
* Defaults to `false`.
|
452
|
+
*/
|
453
|
+
useReferences?: boolean;
|
454
|
+
}): Schema<OBJECT>;
|
455
|
+
|
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, zodValidator };
|
package/dist/index.d.ts
CHANGED
@@ -129,6 +129,7 @@ type ParseResult<T> = {
|
|
129
129
|
} | {
|
130
130
|
success: false;
|
131
131
|
error: JSONParseError | TypeValidationError;
|
132
|
+
rawValue: unknown;
|
132
133
|
};
|
133
134
|
/**
|
134
135
|
* Safely parses a JSON string and returns the result as an object of type `unknown`.
|
@@ -241,6 +242,14 @@ declare function loadSetting({ settingValue, environmentVariableName, settingNam
|
|
241
242
|
description: string;
|
242
243
|
}): string;
|
243
244
|
|
245
|
+
/**
|
246
|
+
* Parses a JSON event stream into a stream of parsed JSON objects.
|
247
|
+
*/
|
248
|
+
declare function parseJsonEventStream<T>({ stream, schema, }: {
|
249
|
+
stream: ReadableStream<Uint8Array>;
|
250
|
+
schema: ZodSchema<T>;
|
251
|
+
}): ReadableStream<ParseResult<T>>;
|
252
|
+
|
244
253
|
declare function parseProviderOptions<T>({ provider, providerOptions, schema, }: {
|
245
254
|
provider: string;
|
246
255
|
providerOptions: Record<string, unknown> | undefined;
|
@@ -304,45 +313,6 @@ type Resolvable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
304
313
|
*/
|
305
314
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
306
315
|
|
307
|
-
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
308
|
-
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
309
|
-
declare function convertToBase64(value: string | Uint8Array): string;
|
310
|
-
|
311
|
-
/**
|
312
|
-
* Validates the types of an unknown object using a schema and
|
313
|
-
* return a strongly-typed object.
|
314
|
-
*
|
315
|
-
* @template T - The type of the object to validate.
|
316
|
-
* @param {string} options.value - The object to validate.
|
317
|
-
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
318
|
-
* @returns {Promise<T>} - The typed object.
|
319
|
-
*/
|
320
|
-
declare function validateTypes<T>({ value, schema: inputSchema, }: {
|
321
|
-
value: unknown;
|
322
|
-
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
323
|
-
}): Promise<T>;
|
324
|
-
/**
|
325
|
-
* Safely validates the types of an unknown object using a schema and
|
326
|
-
* return a strongly-typed object.
|
327
|
-
*
|
328
|
-
* @template T - The type of the object to validate.
|
329
|
-
* @param {string} options.value - The JSON object to validate.
|
330
|
-
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
331
|
-
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
332
|
-
*/
|
333
|
-
declare function safeValidateTypes<T>({ value, schema, }: {
|
334
|
-
value: unknown;
|
335
|
-
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
336
|
-
}): Promise<{
|
337
|
-
success: true;
|
338
|
-
value: T;
|
339
|
-
} | {
|
340
|
-
success: false;
|
341
|
-
error: TypeValidationError;
|
342
|
-
}>;
|
343
|
-
|
344
|
-
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
345
|
-
|
346
316
|
/**
|
347
317
|
* Used to mark schemas so we can support both Zod and custom schemas.
|
348
318
|
*/
|
@@ -378,16 +348,6 @@ declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validat
|
|
378
348
|
}): Schema<OBJECT>;
|
379
349
|
declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT> | undefined): Schema<OBJECT>;
|
380
350
|
|
381
|
-
declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any>, options?: {
|
382
|
-
/**
|
383
|
-
* Enables support for references in the schema.
|
384
|
-
* This is required for recursive schemas, e.g. with `z.lazy`.
|
385
|
-
* However, not all language models and providers support such references.
|
386
|
-
* Defaults to `false`.
|
387
|
-
*/
|
388
|
-
useReferences?: boolean;
|
389
|
-
}): Schema<OBJECT>;
|
390
|
-
|
391
351
|
/**
|
392
352
|
Typed tool call that is returned by generateText and streamText.
|
393
353
|
It contains the tool call ID, the tool name, and the tool arguments.
|
@@ -442,4 +402,55 @@ type ToolResultContent = Array<{
|
|
442
402
|
mimeType?: string;
|
443
403
|
}>;
|
444
404
|
|
445
|
-
|
405
|
+
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
406
|
+
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
407
|
+
declare function convertToBase64(value: string | Uint8Array): string;
|
408
|
+
|
409
|
+
/**
|
410
|
+
* Validates the types of an unknown object using a schema and
|
411
|
+
* return a strongly-typed object.
|
412
|
+
*
|
413
|
+
* @template T - The type of the object to validate.
|
414
|
+
* @param {string} options.value - The object to validate.
|
415
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
416
|
+
* @returns {Promise<T>} - The typed object.
|
417
|
+
*/
|
418
|
+
declare function validateTypes<T>({ value, schema: inputSchema, }: {
|
419
|
+
value: unknown;
|
420
|
+
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
421
|
+
}): Promise<T>;
|
422
|
+
/**
|
423
|
+
* Safely validates the types of an unknown object using a schema and
|
424
|
+
* return a strongly-typed object.
|
425
|
+
*
|
426
|
+
* @template T - The type of the object to validate.
|
427
|
+
* @param {string} options.value - The JSON object to validate.
|
428
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
429
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
430
|
+
*/
|
431
|
+
declare function safeValidateTypes<T>({ value, schema, }: {
|
432
|
+
value: unknown;
|
433
|
+
schema: z.Schema<T, z.ZodTypeDef, any> | Validator<T>;
|
434
|
+
}): Promise<{
|
435
|
+
success: true;
|
436
|
+
value: T;
|
437
|
+
rawValue: unknown;
|
438
|
+
} | {
|
439
|
+
success: false;
|
440
|
+
error: TypeValidationError;
|
441
|
+
rawValue: unknown;
|
442
|
+
}>;
|
443
|
+
|
444
|
+
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
445
|
+
|
446
|
+
declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any>, options?: {
|
447
|
+
/**
|
448
|
+
* Enables support for references in the schema.
|
449
|
+
* This is required for recursive schemas, e.g. with `z.lazy`.
|
450
|
+
* However, not all language models and providers support such references.
|
451
|
+
* Defaults to `false`.
|
452
|
+
*/
|
453
|
+
useReferences?: boolean;
|
454
|
+
}): Schema<OBJECT>;
|
455
|
+
|
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, zodValidator };
|
package/dist/index.js
CHANGED
@@ -59,6 +59,7 @@ __export(src_exports, {
|
|
59
59
|
loadOptionalSetting: () => loadOptionalSetting,
|
60
60
|
loadSetting: () => loadSetting,
|
61
61
|
parseJSON: () => parseJSON,
|
62
|
+
parseJsonEventStream: () => parseJsonEventStream,
|
62
63
|
parseProviderOptions: () => parseProviderOptions,
|
63
64
|
postFormDataToApi: () => postFormDataToApi,
|
64
65
|
postJsonToApi: () => postJsonToApi,
|
@@ -203,7 +204,7 @@ function splitLines(buffer, chunk) {
|
|
203
204
|
} else if (char === "\r") {
|
204
205
|
lines.push(currentLine);
|
205
206
|
currentLine = "";
|
206
|
-
if (chunk[i
|
207
|
+
if (chunk[i] === "\n") {
|
207
208
|
i++;
|
208
209
|
}
|
209
210
|
} else {
|
@@ -550,20 +551,22 @@ async function safeValidateTypes({
|
|
550
551
|
const validator2 = asValidator(schema);
|
551
552
|
try {
|
552
553
|
if (validator2.validate == null) {
|
553
|
-
return { success: true, value };
|
554
|
+
return { success: true, value, rawValue: value };
|
554
555
|
}
|
555
556
|
const result = validator2.validate(value);
|
556
557
|
if (result.success) {
|
557
|
-
return result;
|
558
|
+
return { success: true, value: result.value, rawValue: value };
|
558
559
|
}
|
559
560
|
return {
|
560
561
|
success: false,
|
561
|
-
error: import_provider5.TypeValidationError.wrap({ value, cause: result.error })
|
562
|
+
error: import_provider5.TypeValidationError.wrap({ value, cause: result.error }),
|
563
|
+
rawValue: value
|
562
564
|
};
|
563
565
|
} catch (error) {
|
564
566
|
return {
|
565
567
|
success: false,
|
566
|
-
error: import_provider5.TypeValidationError.wrap({ value, cause: error })
|
568
|
+
error: import_provider5.TypeValidationError.wrap({ value, cause: error }),
|
569
|
+
rawValue: value
|
567
570
|
};
|
568
571
|
}
|
569
572
|
}
|
@@ -595,12 +598,12 @@ async function safeParseJSON({
|
|
595
598
|
if (schema == null) {
|
596
599
|
return { success: true, value, rawValue: value };
|
597
600
|
}
|
598
|
-
|
599
|
-
return validationResult.success ? { ...validationResult, rawValue: value } : validationResult;
|
601
|
+
return await safeValidateTypes({ value, schema });
|
600
602
|
} catch (error) {
|
601
603
|
return {
|
602
604
|
success: false,
|
603
|
-
error: import_provider6.JSONParseError.isInstance(error) ? error : new import_provider6.JSONParseError({ text, cause: error })
|
605
|
+
error: import_provider6.JSONParseError.isInstance(error) ? error : new import_provider6.JSONParseError({ text, cause: error }),
|
606
|
+
rawValue: void 0
|
604
607
|
};
|
605
608
|
}
|
606
609
|
}
|
@@ -613,6 +616,23 @@ function isParsableJson(input) {
|
|
613
616
|
}
|
614
617
|
}
|
615
618
|
|
619
|
+
// src/parse-json-event-stream.ts
|
620
|
+
function parseJsonEventStream({
|
621
|
+
stream,
|
622
|
+
schema
|
623
|
+
}) {
|
624
|
+
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(createEventSourceParserStream()).pipeThrough(
|
625
|
+
new TransformStream({
|
626
|
+
async transform({ data }, controller) {
|
627
|
+
if (data === "[DONE]") {
|
628
|
+
return;
|
629
|
+
}
|
630
|
+
controller.enqueue(await safeParseJSON({ text: data, schema }));
|
631
|
+
}
|
632
|
+
})
|
633
|
+
);
|
634
|
+
}
|
635
|
+
|
616
636
|
// src/parse-provider-options.ts
|
617
637
|
var import_provider7 = require("@ai-sdk/provider");
|
618
638
|
async function parseProviderOptions({
|
@@ -836,21 +856,10 @@ var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) =>
|
|
836
856
|
}
|
837
857
|
return {
|
838
858
|
responseHeaders,
|
839
|
-
value:
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
return;
|
844
|
-
}
|
845
|
-
controller.enqueue(
|
846
|
-
await safeParseJSON({
|
847
|
-
text: data,
|
848
|
-
schema: chunkSchema
|
849
|
-
})
|
850
|
-
);
|
851
|
-
}
|
852
|
-
})
|
853
|
-
)
|
859
|
+
value: parseJsonEventStream({
|
860
|
+
stream: response.body,
|
861
|
+
schema: chunkSchema
|
862
|
+
})
|
854
863
|
};
|
855
864
|
};
|
856
865
|
var createJsonStreamResponseHandler = (chunkSchema) => async ({ response }) => {
|
@@ -950,29 +959,6 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
950
959
|
};
|
951
960
|
};
|
952
961
|
|
953
|
-
// src/uint8-utils.ts
|
954
|
-
var { btoa, atob } = globalThis;
|
955
|
-
function convertBase64ToUint8Array(base64String) {
|
956
|
-
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
957
|
-
const latin1string = atob(base64Url);
|
958
|
-
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
959
|
-
}
|
960
|
-
function convertUint8ArrayToBase64(array) {
|
961
|
-
let latin1string = "";
|
962
|
-
for (let i = 0; i < array.length; i++) {
|
963
|
-
latin1string += String.fromCodePoint(array[i]);
|
964
|
-
}
|
965
|
-
return btoa(latin1string);
|
966
|
-
}
|
967
|
-
function convertToBase64(value) {
|
968
|
-
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
969
|
-
}
|
970
|
-
|
971
|
-
// src/without-trailing-slash.ts
|
972
|
-
function withoutTrailingSlash(url) {
|
973
|
-
return url == null ? void 0 : url.replace(/\/$/, "");
|
974
|
-
}
|
975
|
-
|
976
962
|
// src/zod-schema.ts
|
977
963
|
var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
|
978
964
|
function zodSchema(zodSchema2, options) {
|
@@ -1016,6 +1002,29 @@ function asSchema(schema) {
|
|
1016
1002
|
additionalProperties: false
|
1017
1003
|
}) : isSchema(schema) ? schema : zodSchema(schema);
|
1018
1004
|
}
|
1005
|
+
|
1006
|
+
// src/uint8-utils.ts
|
1007
|
+
var { btoa, atob } = globalThis;
|
1008
|
+
function convertBase64ToUint8Array(base64String) {
|
1009
|
+
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
1010
|
+
const latin1string = atob(base64Url);
|
1011
|
+
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
1012
|
+
}
|
1013
|
+
function convertUint8ArrayToBase64(array) {
|
1014
|
+
let latin1string = "";
|
1015
|
+
for (let i = 0; i < array.length; i++) {
|
1016
|
+
latin1string += String.fromCodePoint(array[i]);
|
1017
|
+
}
|
1018
|
+
return btoa(latin1string);
|
1019
|
+
}
|
1020
|
+
function convertToBase64(value) {
|
1021
|
+
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
// src/without-trailing-slash.ts
|
1025
|
+
function withoutTrailingSlash(url) {
|
1026
|
+
return url == null ? void 0 : url.replace(/\/$/, "");
|
1027
|
+
}
|
1019
1028
|
// Annotate the CommonJS export names for ESM import in node:
|
1020
1029
|
0 && (module.exports = {
|
1021
1030
|
asSchema,
|
@@ -1047,6 +1056,7 @@ function asSchema(schema) {
|
|
1047
1056
|
loadOptionalSetting,
|
1048
1057
|
loadSetting,
|
1049
1058
|
parseJSON,
|
1059
|
+
parseJsonEventStream,
|
1050
1060
|
parseProviderOptions,
|
1051
1061
|
postFormDataToApi,
|
1052
1062
|
postJsonToApi,
|