@ai-sdk/provider-utils 5.0.52 → 5.0.53
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 +10 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/is-valid-hostname-part.ts +12 -0
- package/src/transcription-stream-envelope.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/provider-utils",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.53",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ai-sdk/provider": "4.0.
|
|
40
|
+
"@ai-sdk/provider": "4.0.21",
|
|
41
41
|
"@standard-schema/spec": "^1.1.0",
|
|
42
42
|
"@workflow/serde": "4.1.0",
|
|
43
43
|
"eventsource-parser": "^3.0.8",
|
package/src/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ export { isNonNullable } from './is-non-nullable';
|
|
|
58
58
|
export { isProviderReference } from './is-provider-reference';
|
|
59
59
|
export { isRecord } from './is-record';
|
|
60
60
|
export { isUrlSupported } from './is-url-supported';
|
|
61
|
+
export { isValidHostnamePart } from './is-valid-hostname-part';
|
|
61
62
|
export * from './load-api-key';
|
|
62
63
|
export { loadOptionalSetting } from './load-optional-setting';
|
|
63
64
|
export { loadSetting } from './load-setting';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a value is a valid ASCII hostname part: 1–63 letters, digits,
|
|
3
|
+
* or hyphens, without a leading or trailing hyphen.
|
|
4
|
+
*
|
|
5
|
+
* Use this before inserting a resource name, region, or location into a
|
|
6
|
+
* generated hostname. Rejects values such as `evil.example.com/#` and
|
|
7
|
+
* `user@localhost:8080/#` that could change the request destination.
|
|
8
|
+
*/
|
|
9
|
+
export function isValidHostnamePart(value: string): boolean {
|
|
10
|
+
// Compare the full match because `$` also matches before a final newline.
|
|
11
|
+
return /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.exec(value)?.[0] === value;
|
|
12
|
+
}
|
|
@@ -271,6 +271,7 @@ export function parseTranscriptionStreamPart(
|
|
|
271
271
|
part.segments.every(isSegment) &&
|
|
272
272
|
isOptional(part.language, isString) &&
|
|
273
273
|
isOptional(part.durationInSeconds, isNumber) &&
|
|
274
|
+
isOptional(part.usage, isRecord) &&
|
|
274
275
|
isOptional(part.providerMetadata, isRecord)
|
|
275
276
|
? part
|
|
276
277
|
: undefined;
|