spitch 1.20.0 → 1.23.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/CHANGELOG.md +29 -19
- package/README.md +40 -7
- package/client.d.mts +16 -4
- package/client.d.mts.map +1 -1
- package/client.d.ts +16 -4
- package/client.d.ts.map +1 -1
- package/client.js +14 -2
- package/client.js.map +1 -1
- package/client.mjs +16 -4
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +54 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +54 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +101 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +95 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/internal/to-file.d.mts +1 -1
- package/internal/to-file.d.ts +1 -1
- package/internal/to-file.js +1 -1
- package/internal/to-file.mjs +1 -1
- package/internal/utils/values.js +3 -3
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +3 -3
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +14 -1
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resources/files.d.mts +143 -0
- package/resources/files.d.mts.map +1 -0
- package/resources/files.d.ts +143 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +95 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +91 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.mts +3 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -1
- package/resources/index.mjs.map +1 -1
- package/resources/speech.d.mts +10 -6
- package/resources/speech.d.mts.map +1 -1
- package/resources/speech.d.ts +10 -6
- package/resources/speech.d.ts.map +1 -1
- package/resources/speech.js +4 -1
- package/resources/speech.js.map +1 -1
- package/resources/speech.mjs +4 -1
- package/resources/speech.mjs.map +1 -1
- package/resources/text.d.mts +25 -6
- package/resources/text.d.mts.map +1 -1
- package/resources/text.d.ts +25 -6
- package/resources/text.d.ts.map +1 -1
- package/src/client.ts +59 -17
- package/src/core/pagination.ts +157 -0
- package/src/index.ts +1 -0
- package/src/internal/to-file.ts +1 -1
- package/src/internal/utils/values.ts +3 -3
- package/src/pagination.ts +2 -0
- package/src/resources/files.ts +205 -0
- package/src/resources/index.ts +13 -7
- package/src/resources/speech.ts +12 -7
- package/src/resources/text.ts +30 -7
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/speech.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { APIResource } from "../core/resource.js";
|
|
|
2
2
|
import { APIPromise } from "../core/api-promise.js";
|
|
3
3
|
import { type Uploadable } from "../core/uploads.js";
|
|
4
4
|
import { RequestOptions } from "../internal/request-options.js";
|
|
5
|
+
/**
|
|
6
|
+
* All speech-focused APIs (TTS and STT)
|
|
7
|
+
*/
|
|
5
8
|
export declare class Speech extends APIResource {
|
|
6
9
|
/**
|
|
7
10
|
* Synthesize
|
|
@@ -10,14 +13,14 @@ export declare class Speech extends APIResource {
|
|
|
10
13
|
/**
|
|
11
14
|
* Transcribe
|
|
12
15
|
*/
|
|
13
|
-
transcribe(body: SpeechTranscribeParams, options?: RequestOptions): APIPromise<
|
|
16
|
+
transcribe(body: SpeechTranscribeParams, options?: RequestOptions): APIPromise<Transcription>;
|
|
14
17
|
}
|
|
15
|
-
export interface
|
|
18
|
+
export interface Transcription {
|
|
16
19
|
request_id: string;
|
|
17
20
|
text: string;
|
|
18
|
-
timestamps?: Array<
|
|
21
|
+
timestamps?: Array<Transcription.Timestamp> | null;
|
|
19
22
|
}
|
|
20
|
-
export declare namespace
|
|
23
|
+
export declare namespace Transcription {
|
|
21
24
|
interface Timestamp {
|
|
22
25
|
end: number;
|
|
23
26
|
start: number;
|
|
@@ -28,17 +31,18 @@ export interface SpeechGenerateParams {
|
|
|
28
31
|
language: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
29
32
|
text: string;
|
|
30
33
|
voice: 'sade' | 'segun' | 'femi' | 'funmi' | 'amina' | 'aliyu' | 'hasan' | 'zainab' | 'john' | 'jude' | 'lina' | 'lucy' | 'henry' | 'kani' | 'ngozi' | 'amara' | 'obinna' | 'ebuka' | 'hana' | 'selam' | 'tena' | 'tesfaye';
|
|
34
|
+
format?: 'wav' | 'mp3' | 'ogg_opus' | 'webm_opus' | 'flac' | 'pcm_s16le' | 'mulaw' | 'alaw';
|
|
31
35
|
model?: 'legacy' | null;
|
|
32
36
|
}
|
|
33
37
|
export interface SpeechTranscribeParams {
|
|
34
38
|
language: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
35
39
|
content?: Uploadable | null;
|
|
36
|
-
model?: 'mansa_v1' | 'legacy' | null;
|
|
40
|
+
model?: 'mansa_v1' | 'legacy' | 'human' | null;
|
|
37
41
|
special_words?: string | null;
|
|
38
42
|
timestamp?: 'sentence' | 'word' | 'none' | null;
|
|
39
43
|
url?: string | null;
|
|
40
44
|
}
|
|
41
45
|
export declare namespace Speech {
|
|
42
|
-
export { type
|
|
46
|
+
export { type Transcription as Transcription, type SpeechGenerateParams as SpeechGenerateParams, type SpeechTranscribeParams as SpeechTranscribeParams, };
|
|
43
47
|
}
|
|
44
48
|
//# sourceMappingURL=speech.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech.d.ts","sourceRoot":"","sources":["../src/resources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AG,IAAI,CAAC;IAE3C,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EACD,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,MAAM,GACN,OAAO,GACP,MAAM,GACN,SAAS,CAAC;IAEd,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;IAE5F,KAAK,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAE3C,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAE5B,KAAK,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;IAE/C,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEhD,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,OAAO,EACL,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
|
package/resources/speech.js
CHANGED
|
@@ -5,6 +5,9 @@ exports.Speech = void 0;
|
|
|
5
5
|
const resource_1 = require("../core/resource.js");
|
|
6
6
|
const headers_1 = require("../internal/headers.js");
|
|
7
7
|
const uploads_1 = require("../internal/uploads.js");
|
|
8
|
+
/**
|
|
9
|
+
* All speech-focused APIs (TTS and STT)
|
|
10
|
+
*/
|
|
8
11
|
class Speech extends resource_1.APIResource {
|
|
9
12
|
/**
|
|
10
13
|
* Synthesize
|
|
@@ -13,7 +16,7 @@ class Speech extends resource_1.APIResource {
|
|
|
13
16
|
return this._client.post('/v1/speech', {
|
|
14
17
|
body,
|
|
15
18
|
...options,
|
|
16
|
-
headers: (0, headers_1.buildHeaders)([{ Accept: 'audio
|
|
19
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: 'audio/*' }, options?.headers]),
|
|
17
20
|
__binaryResponse: true,
|
|
18
21
|
});
|
|
19
22
|
}
|
package/resources/speech.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech.js","sourceRoot":"","sources":["../src/resources/speech.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,oDAAmD;AAEnD,oDAAkE;AAElE,MAAa,MAAO,SAAQ,sBAAW;IACrC;;OAEG;IACH,QAAQ,CAAC,IAA0B,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE;YACrC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"speech.js","sourceRoot":"","sources":["../src/resources/speech.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,oDAAmD;AAEnD,oDAAkE;AAElE;;GAEG;AACH,MAAa,MAAO,SAAQ,sBAAW;IACrC;;OAEG;IACH,QAAQ,CAAC,IAA0B,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE;YACrC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAChE,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAA4B,EAAE,OAAwB;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,oBAAoB,EACpB,IAAA,qCAA2B,EAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAChE,CAAC;IACJ,CAAC;CACF;AAtBD,wBAsBC"}
|
package/resources/speech.mjs
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { APIResource } from "../core/resource.mjs";
|
|
3
3
|
import { buildHeaders } from "../internal/headers.mjs";
|
|
4
4
|
import { multipartFormRequestOptions } from "../internal/uploads.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* All speech-focused APIs (TTS and STT)
|
|
7
|
+
*/
|
|
5
8
|
export class Speech extends APIResource {
|
|
6
9
|
/**
|
|
7
10
|
* Synthesize
|
|
@@ -10,7 +13,7 @@ export class Speech extends APIResource {
|
|
|
10
13
|
return this._client.post('/v1/speech', {
|
|
11
14
|
body,
|
|
12
15
|
...options,
|
|
13
|
-
headers: buildHeaders([{ Accept: 'audio
|
|
16
|
+
headers: buildHeaders([{ Accept: 'audio/*' }, options?.headers]),
|
|
14
17
|
__binaryResponse: true,
|
|
15
18
|
});
|
|
16
19
|
}
|
package/resources/speech.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech.mjs","sourceRoot":"","sources":["../src/resources/speech.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,YAAY,EAAE;OAEhB,EAAE,2BAA2B,EAAE;AAEtC,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;OAEG;IACH,QAAQ,CAAC,IAA0B,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE;YACrC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"speech.mjs","sourceRoot":"","sources":["../src/resources/speech.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,YAAY,EAAE;OAEhB,EAAE,2BAA2B,EAAE;AAEtC;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;OAEG;IACH,QAAQ,CAAC,IAA0B,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE;YACrC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAChE,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAA4B,EAAE,OAAwB;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,oBAAoB,EACpB,2BAA2B,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAChE,CAAC;IACJ,CAAC;CACF"}
|
package/resources/text.d.mts
CHANGED
|
@@ -5,19 +5,35 @@ export declare class Text extends APIResource {
|
|
|
5
5
|
/**
|
|
6
6
|
* Tone Mark
|
|
7
7
|
*/
|
|
8
|
-
toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<
|
|
8
|
+
toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<Diacritics>;
|
|
9
9
|
/**
|
|
10
10
|
* Translate
|
|
11
11
|
*/
|
|
12
|
-
translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<
|
|
12
|
+
translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<Translation>;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Response model for text diacritization requests.
|
|
16
|
+
*
|
|
17
|
+
* Attributes:
|
|
18
|
+
* request_id: Unique identifier for the diacritization request
|
|
19
|
+
* text: Text with added diacritical marks for proper pronunciation
|
|
20
|
+
* language: Language code for the diacritized text
|
|
21
|
+
*/
|
|
22
|
+
export interface Diacritics {
|
|
15
23
|
request_id: string;
|
|
16
24
|
text: string;
|
|
17
25
|
}
|
|
18
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Translation result model.
|
|
28
|
+
*
|
|
29
|
+
* Attributes: request_id (UUID): Unique ID for this request. text: translated
|
|
30
|
+
* text. due_date: used when model is `human`. the date you can expect the
|
|
31
|
+
* translation to be delivered
|
|
32
|
+
*/
|
|
33
|
+
export interface Translation {
|
|
19
34
|
request_id: string;
|
|
20
35
|
text: string;
|
|
36
|
+
due_date?: string | null;
|
|
21
37
|
}
|
|
22
38
|
export interface TextToneMarkParams {
|
|
23
39
|
language: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
@@ -26,9 +42,12 @@ export interface TextToneMarkParams {
|
|
|
26
42
|
export interface TextTranslateParams {
|
|
27
43
|
source: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
28
44
|
target: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
29
|
-
|
|
45
|
+
file_id?: string | null;
|
|
46
|
+
instructions?: string | null;
|
|
47
|
+
model?: 'human' | 'auto';
|
|
48
|
+
text?: string | null;
|
|
30
49
|
}
|
|
31
50
|
export declare namespace Text {
|
|
32
|
-
export { type
|
|
51
|
+
export { type Diacritics as Diacritics, type Translation as Translation, type TextToneMarkParams as TextToneMarkParams, type TextTranslateParams as TextTranslateParams, };
|
|
33
52
|
}
|
|
34
53
|
//# sourceMappingURL=text.d.mts.map
|
package/resources/text.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.mts","sourceRoot":"","sources":["../src/res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C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEzB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,OAAO,EACL,KAAK,UAAU,IAAI,UAAU,EAC7B,KAAK,WAAW,IAAI,WAAW,EAC/B,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,mBAAmB,IAAI,mBAAmB,GAChD,CAAC;CACH"}
|
package/resources/text.d.ts
CHANGED
|
@@ -5,19 +5,35 @@ export declare class Text extends APIResource {
|
|
|
5
5
|
/**
|
|
6
6
|
* Tone Mark
|
|
7
7
|
*/
|
|
8
|
-
toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<
|
|
8
|
+
toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<Diacritics>;
|
|
9
9
|
/**
|
|
10
10
|
* Translate
|
|
11
11
|
*/
|
|
12
|
-
translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<
|
|
12
|
+
translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<Translation>;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Response model for text diacritization requests.
|
|
16
|
+
*
|
|
17
|
+
* Attributes:
|
|
18
|
+
* request_id: Unique identifier for the diacritization request
|
|
19
|
+
* text: Text with added diacritical marks for proper pronunciation
|
|
20
|
+
* language: Language code for the diacritized text
|
|
21
|
+
*/
|
|
22
|
+
export interface Diacritics {
|
|
15
23
|
request_id: string;
|
|
16
24
|
text: string;
|
|
17
25
|
}
|
|
18
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Translation result model.
|
|
28
|
+
*
|
|
29
|
+
* Attributes: request_id (UUID): Unique ID for this request. text: translated
|
|
30
|
+
* text. due_date: used when model is `human`. the date you can expect the
|
|
31
|
+
* translation to be delivered
|
|
32
|
+
*/
|
|
33
|
+
export interface Translation {
|
|
19
34
|
request_id: string;
|
|
20
35
|
text: string;
|
|
36
|
+
due_date?: string | null;
|
|
21
37
|
}
|
|
22
38
|
export interface TextToneMarkParams {
|
|
23
39
|
language: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
@@ -26,9 +42,12 @@ export interface TextToneMarkParams {
|
|
|
26
42
|
export interface TextTranslateParams {
|
|
27
43
|
source: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
28
44
|
target: 'yo' | 'en' | 'ha' | 'ig' | 'am';
|
|
29
|
-
|
|
45
|
+
file_id?: string | null;
|
|
46
|
+
instructions?: string | null;
|
|
47
|
+
model?: 'human' | 'auto';
|
|
48
|
+
text?: string | null;
|
|
30
49
|
}
|
|
31
50
|
export declare namespace Text {
|
|
32
|
-
export { type
|
|
51
|
+
export { type Diacritics as Diacritics, type Translation as Translation, type TextToneMarkParams as TextToneMarkParams, type TextTranslateParams as TextTranslateParams, };
|
|
33
52
|
}
|
|
34
53
|
//# sourceMappingURL=text.d.ts.map
|
package/resources/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/resources/text.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,IAAK,SAAQ,WAAW;IACnC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/resources/text.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,IAAK,SAAQ,WAAW;IACnC;;OAEG;IACH,QAAQ,CAAC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13,24 @@ import * as Shims from './internal/shims';
|
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
14
|
import { VERSION } from './version';
|
|
15
15
|
import * as Errors from './core/error';
|
|
16
|
+
import * as Pagination from './core/pagination';
|
|
17
|
+
import { AbstractPage, type FilesCursorParams, FilesCursorResponse } from './core/pagination';
|
|
16
18
|
import * as Uploads from './core/uploads';
|
|
17
19
|
import * as API from './resources/index';
|
|
18
20
|
import { APIPromise } from './core/api-promise';
|
|
19
21
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} from './resources/text';
|
|
22
|
+
File,
|
|
23
|
+
FileDeleteResponse,
|
|
24
|
+
FileDownloadParams,
|
|
25
|
+
FileDownloadResponse,
|
|
26
|
+
FileListParams,
|
|
27
|
+
FileUploadParams,
|
|
28
|
+
FileUsage,
|
|
29
|
+
Files,
|
|
30
|
+
FilesFilesCursor,
|
|
31
|
+
} from './resources/files';
|
|
32
|
+
import { Speech, SpeechGenerateParams, SpeechTranscribeParams, Transcription } from './resources/speech';
|
|
33
|
+
import { Diacritics, Text, TextToneMarkParams, TextTranslateParams, Translation } from './resources/text';
|
|
32
34
|
import { type Fetch } from './internal/builtin-types';
|
|
33
35
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
34
36
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -380,7 +382,7 @@ export class Spitch {
|
|
|
380
382
|
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
|
|
381
383
|
const headersTime = Date.now();
|
|
382
384
|
|
|
383
|
-
if (response instanceof Error) {
|
|
385
|
+
if (response instanceof globalThis.Error) {
|
|
384
386
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
385
387
|
if (options.signal?.aborted) {
|
|
386
388
|
throw new Errors.APIUserAbortError();
|
|
@@ -494,6 +496,25 @@ export class Spitch {
|
|
|
494
496
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
495
497
|
}
|
|
496
498
|
|
|
499
|
+
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
500
|
+
path: string,
|
|
501
|
+
Page: new (...args: any[]) => PageClass,
|
|
502
|
+
opts?: RequestOptions,
|
|
503
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
504
|
+
return this.requestAPIList(Page, { method: 'get', path, ...opts });
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
requestAPIList<
|
|
508
|
+
Item = unknown,
|
|
509
|
+
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
510
|
+
>(
|
|
511
|
+
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
512
|
+
options: FinalRequestOptions,
|
|
513
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
514
|
+
const request = this.makeRequest(options, null, undefined);
|
|
515
|
+
return new Pagination.PagePromise<PageClass, Item>(this as any as Spitch, request, Page);
|
|
516
|
+
}
|
|
517
|
+
|
|
497
518
|
async fetchWithTimeout(
|
|
498
519
|
url: RequestInfo,
|
|
499
520
|
init: RequestInit | undefined,
|
|
@@ -687,7 +708,7 @@ export class Spitch {
|
|
|
687
708
|
// Preserve legacy string encoding behavior for now
|
|
688
709
|
headers.values.has('content-type')) ||
|
|
689
710
|
// `Blob` is superset of `File`
|
|
690
|
-
body instanceof Blob ||
|
|
711
|
+
((globalThis as any).Blob && body instanceof (globalThis as any).Blob) ||
|
|
691
712
|
// `FormData` -> `multipart/form-data`
|
|
692
713
|
body instanceof FormData ||
|
|
693
714
|
// `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
@@ -726,26 +747,47 @@ export class Spitch {
|
|
|
726
747
|
|
|
727
748
|
static toFile = Uploads.toFile;
|
|
728
749
|
|
|
750
|
+
/**
|
|
751
|
+
* All speech-focused APIs (TTS and STT)
|
|
752
|
+
*/
|
|
729
753
|
speech: API.Speech = new API.Speech(this);
|
|
730
754
|
text: API.Text = new API.Text(this);
|
|
755
|
+
files: API.Files = new API.Files(this);
|
|
731
756
|
}
|
|
757
|
+
|
|
732
758
|
Spitch.Speech = Speech;
|
|
733
759
|
Spitch.Text = Text;
|
|
760
|
+
|
|
734
761
|
export declare namespace Spitch {
|
|
735
762
|
export type RequestOptions = Opts.RequestOptions;
|
|
736
763
|
|
|
764
|
+
export import FilesCursor = Pagination.FilesCursor;
|
|
765
|
+
export { type FilesCursorParams as FilesCursorParams, type FilesCursorResponse as FilesCursorResponse };
|
|
766
|
+
|
|
737
767
|
export {
|
|
738
768
|
Speech as Speech,
|
|
739
|
-
type
|
|
769
|
+
type Transcription as Transcription,
|
|
740
770
|
type SpeechGenerateParams as SpeechGenerateParams,
|
|
741
771
|
type SpeechTranscribeParams as SpeechTranscribeParams,
|
|
742
772
|
};
|
|
743
773
|
|
|
744
774
|
export {
|
|
745
775
|
Text as Text,
|
|
746
|
-
type
|
|
747
|
-
type
|
|
776
|
+
type Diacritics as Diacritics,
|
|
777
|
+
type Translation as Translation,
|
|
748
778
|
type TextToneMarkParams as TextToneMarkParams,
|
|
749
779
|
type TextTranslateParams as TextTranslateParams,
|
|
750
780
|
};
|
|
781
|
+
|
|
782
|
+
export {
|
|
783
|
+
type Files as Files,
|
|
784
|
+
type File as File,
|
|
785
|
+
type FileUsage as FileUsage,
|
|
786
|
+
type FileDeleteResponse as FileDeleteResponse,
|
|
787
|
+
type FileDownloadResponse as FileDownloadResponse,
|
|
788
|
+
type FilesFilesCursor as FilesFilesCursor,
|
|
789
|
+
type FileListParams as FileListParams,
|
|
790
|
+
type FileDownloadParams as FileDownloadParams,
|
|
791
|
+
type FileUploadParams as FileUploadParams,
|
|
792
|
+
};
|
|
751
793
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { SpitchError } from './error';
|
|
4
|
+
import { FinalRequestOptions } from '../internal/request-options';
|
|
5
|
+
import { defaultParseResponse } from '../internal/parse';
|
|
6
|
+
import { type Spitch } from '../client';
|
|
7
|
+
import { APIPromise } from './api-promise';
|
|
8
|
+
import { type APIResponseProps } from '../internal/parse';
|
|
9
|
+
import { maybeObj } from '../internal/utils/values';
|
|
10
|
+
|
|
11
|
+
export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
|
|
12
|
+
|
|
13
|
+
export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
14
|
+
#client: Spitch;
|
|
15
|
+
protected options: FinalRequestOptions;
|
|
16
|
+
|
|
17
|
+
protected response: Response;
|
|
18
|
+
protected body: unknown;
|
|
19
|
+
|
|
20
|
+
constructor(client: Spitch, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
21
|
+
this.#client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.response = response;
|
|
24
|
+
this.body = body;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
abstract nextPageRequestOptions(): PageRequestOptions | null;
|
|
28
|
+
|
|
29
|
+
abstract getPaginatedItems(): Item[];
|
|
30
|
+
|
|
31
|
+
hasNextPage(): boolean {
|
|
32
|
+
const items = this.getPaginatedItems();
|
|
33
|
+
if (!items.length) return false;
|
|
34
|
+
return this.nextPageRequestOptions() != null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getNextPage(): Promise<this> {
|
|
38
|
+
const nextOptions = this.nextPageRequestOptions();
|
|
39
|
+
if (!nextOptions) {
|
|
40
|
+
throw new SpitchError(
|
|
41
|
+
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async *iterPages(): AsyncGenerator<this> {
|
|
49
|
+
let page: this = this;
|
|
50
|
+
yield page;
|
|
51
|
+
while (page.hasNextPage()) {
|
|
52
|
+
page = await page.getNextPage();
|
|
53
|
+
yield page;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
58
|
+
for await (const page of this.iterPages()) {
|
|
59
|
+
for (const item of page.getPaginatedItems()) {
|
|
60
|
+
yield item;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
68
|
+
*
|
|
69
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
70
|
+
*
|
|
71
|
+
* for await (const item of client.items.list()) {
|
|
72
|
+
* console.log(item)
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
export class PagePromise<
|
|
76
|
+
PageClass extends AbstractPage<Item>,
|
|
77
|
+
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
78
|
+
>
|
|
79
|
+
extends APIPromise<PageClass>
|
|
80
|
+
implements AsyncIterable<Item>
|
|
81
|
+
{
|
|
82
|
+
constructor(
|
|
83
|
+
client: Spitch,
|
|
84
|
+
request: Promise<APIResponseProps>,
|
|
85
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
86
|
+
) {
|
|
87
|
+
super(
|
|
88
|
+
client,
|
|
89
|
+
request,
|
|
90
|
+
async (client, props) =>
|
|
91
|
+
new Page(client, props.response, await defaultParseResponse(client, props), props.options),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
97
|
+
*
|
|
98
|
+
* for await (const item of client.items.list()) {
|
|
99
|
+
* console.log(item)
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
103
|
+
const page = await this;
|
|
104
|
+
for await (const item of page) {
|
|
105
|
+
yield item;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface FilesCursorResponse<Item> {
|
|
111
|
+
items: Array<Item>;
|
|
112
|
+
|
|
113
|
+
next_cursor: string | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface FilesCursorParams {
|
|
117
|
+
cursor?: string;
|
|
118
|
+
|
|
119
|
+
limit?: number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class FilesCursor<Item> extends AbstractPage<Item> implements FilesCursorResponse<Item> {
|
|
123
|
+
items: Array<Item>;
|
|
124
|
+
|
|
125
|
+
next_cursor: string | null;
|
|
126
|
+
|
|
127
|
+
constructor(
|
|
128
|
+
client: Spitch,
|
|
129
|
+
response: Response,
|
|
130
|
+
body: FilesCursorResponse<Item>,
|
|
131
|
+
options: FinalRequestOptions,
|
|
132
|
+
) {
|
|
133
|
+
super(client, response, body, options);
|
|
134
|
+
|
|
135
|
+
this.items = body.items || [];
|
|
136
|
+
this.next_cursor = body.next_cursor || null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getPaginatedItems(): Item[] {
|
|
140
|
+
return this.items ?? [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
nextPageRequestOptions(): PageRequestOptions | null {
|
|
144
|
+
const cursor = this.next_cursor;
|
|
145
|
+
if (!cursor) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
...this.options,
|
|
151
|
+
query: {
|
|
152
|
+
...maybeObj(this.options.query),
|
|
153
|
+
cursor,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { Spitch as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { Spitch, type ClientOptions } from './client';
|
|
8
|
+
export { PagePromise } from './core/pagination';
|
|
8
9
|
export {
|
|
9
10
|
SpitchError,
|
|
10
11
|
APIError,
|
package/src/internal/to-file.ts
CHANGED
|
@@ -73,7 +73,7 @@ export type ToFileInput =
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
76
|
-
* @param value the raw content of the file.
|
|
76
|
+
* @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts
|
|
77
77
|
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
78
78
|
* @param {Object=} options additional properties
|
|
79
79
|
* @param {string=} options.type the MIME type of the content
|
|
@@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export const maybeCoerceInteger = (value: unknown): number | undefined => {
|
|
79
|
-
if (value
|
|
79
|
+
if (value == null) {
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
82
|
return coerceInteger(value);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
export const maybeCoerceFloat = (value: unknown): number | undefined => {
|
|
86
|
-
if (value
|
|
86
|
+
if (value == null) {
|
|
87
87
|
return undefined;
|
|
88
88
|
}
|
|
89
89
|
return coerceFloat(value);
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
|
|
93
|
-
if (value
|
|
93
|
+
if (value == null) {
|
|
94
94
|
return undefined;
|
|
95
95
|
}
|
|
96
96
|
return coerceBoolean(value);
|