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.
Files changed (86) hide show
  1. package/CHANGELOG.md +29 -19
  2. package/README.md +40 -7
  3. package/client.d.mts +16 -4
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +16 -4
  6. package/client.d.ts.map +1 -1
  7. package/client.js +14 -2
  8. package/client.js.map +1 -1
  9. package/client.mjs +16 -4
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +54 -0
  12. package/core/pagination.d.mts.map +1 -0
  13. package/core/pagination.d.ts +54 -0
  14. package/core/pagination.d.ts.map +1 -0
  15. package/core/pagination.js +101 -0
  16. package/core/pagination.js.map +1 -0
  17. package/core/pagination.mjs +95 -0
  18. package/core/pagination.mjs.map +1 -0
  19. package/index.d.mts +1 -0
  20. package/index.d.mts.map +1 -1
  21. package/index.d.ts +1 -0
  22. package/index.d.ts.map +1 -1
  23. package/index.js +3 -1
  24. package/index.js.map +1 -1
  25. package/index.mjs +1 -0
  26. package/index.mjs.map +1 -1
  27. package/internal/to-file.d.mts +1 -1
  28. package/internal/to-file.d.ts +1 -1
  29. package/internal/to-file.js +1 -1
  30. package/internal/to-file.mjs +1 -1
  31. package/internal/utils/values.js +3 -3
  32. package/internal/utils/values.js.map +1 -1
  33. package/internal/utils/values.mjs +3 -3
  34. package/internal/utils/values.mjs.map +1 -1
  35. package/package.json +14 -1
  36. package/pagination.d.mts +2 -0
  37. package/pagination.d.mts.map +1 -0
  38. package/pagination.d.ts +2 -0
  39. package/pagination.d.ts.map +1 -0
  40. package/pagination.js +6 -0
  41. package/pagination.js.map +1 -0
  42. package/pagination.mjs +2 -0
  43. package/pagination.mjs.map +1 -0
  44. package/resources/files.d.mts +143 -0
  45. package/resources/files.d.mts.map +1 -0
  46. package/resources/files.d.ts +143 -0
  47. package/resources/files.d.ts.map +1 -0
  48. package/resources/files.js +95 -0
  49. package/resources/files.js.map +1 -0
  50. package/resources/files.mjs +91 -0
  51. package/resources/files.mjs.map +1 -0
  52. package/resources/index.d.mts +3 -2
  53. package/resources/index.d.mts.map +1 -1
  54. package/resources/index.d.ts +3 -2
  55. package/resources/index.d.ts.map +1 -1
  56. package/resources/index.js +3 -1
  57. package/resources/index.js.map +1 -1
  58. package/resources/index.mjs +2 -1
  59. package/resources/index.mjs.map +1 -1
  60. package/resources/speech.d.mts +10 -6
  61. package/resources/speech.d.mts.map +1 -1
  62. package/resources/speech.d.ts +10 -6
  63. package/resources/speech.d.ts.map +1 -1
  64. package/resources/speech.js +4 -1
  65. package/resources/speech.js.map +1 -1
  66. package/resources/speech.mjs +4 -1
  67. package/resources/speech.mjs.map +1 -1
  68. package/resources/text.d.mts +25 -6
  69. package/resources/text.d.mts.map +1 -1
  70. package/resources/text.d.ts +25 -6
  71. package/resources/text.d.ts.map +1 -1
  72. package/src/client.ts +59 -17
  73. package/src/core/pagination.ts +157 -0
  74. package/src/index.ts +1 -0
  75. package/src/internal/to-file.ts +1 -1
  76. package/src/internal/utils/values.ts +3 -3
  77. package/src/pagination.ts +2 -0
  78. package/src/resources/files.ts +205 -0
  79. package/src/resources/index.ts +13 -7
  80. package/src/resources/speech.ts +12 -7
  81. package/src/resources/text.ts +30 -7
  82. package/src/version.ts +1 -1
  83. package/version.d.mts +1 -1
  84. package/version.d.ts +1 -1
  85. package/version.js +1 -1
  86. package/version.mjs +1 -1
@@ -0,0 +1,205 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { FilesCursor, type FilesCursorParams, PagePromise } from '../core/pagination';
6
+ import { type Uploadable } from '../core/uploads';
7
+ import { RequestOptions } from '../internal/request-options';
8
+ import { multipartFormRequestOptions } from '../internal/uploads';
9
+ import { path } from '../internal/utils/path';
10
+
11
+ export class Files extends APIResource {
12
+ /**
13
+ * Get a paginated list of files for the authenticated organization.
14
+ *
15
+ * Args: identity: Authentication identity containing org_id and user_id limit:
16
+ * Maximum number of files to return (max 100) status: Optional filter by file
17
+ * status (processing, ready, etc.) cursor: Optional pagination cursor for getting
18
+ * next page db: Database session
19
+ *
20
+ * Returns: ListFilesResponse: Paginated list of files with metadata
21
+ *
22
+ * Raises: HTTPException: 400 if cursor is invalid
23
+ */
24
+ list(
25
+ query: FileListParams | null | undefined = {},
26
+ options?: RequestOptions,
27
+ ): PagePromise<FilesFilesCursor, File> {
28
+ return this._client.getAPIList('/v1/files', FilesCursor<File>, { query, ...options });
29
+ }
30
+
31
+ /**
32
+ * Delete a file and its associated S3 object.
33
+ *
34
+ * Args: file_id: UUID of the file to delete identity: Authentication identity
35
+ * containing org_id db: Database session s3: S3 session for deleting objects
36
+ *
37
+ * Returns: dict: Success confirmation
38
+ *
39
+ * Raises: HTTPException: 404 if file not found or doesn't belong to org
40
+ */
41
+ delete(fileID: string, options?: RequestOptions): APIPromise<unknown> {
42
+ return this._client.delete(path`/v1/files/${fileID}`, options);
43
+ }
44
+
45
+ /**
46
+ * Generate a pre-signed download URL for a file.
47
+ *
48
+ * Args: file_id: UUID of the file to download identity: Authentication identity
49
+ * containing org_id ttl: Time-to-live for the download URL in seconds (60-3600)
50
+ * db: Database session s3: S3 session for generating pre-signed URLs
51
+ *
52
+ * Returns: FileDownloadResponse: Contains file_id, download URL, and expiration
53
+ * time
54
+ *
55
+ * Raises: HTTPException: 404 if file not found, doesn't belong to org, or not
56
+ * ready
57
+ */
58
+ download(
59
+ fileID: string,
60
+ query: FileDownloadParams | null | undefined = {},
61
+ options?: RequestOptions,
62
+ ): APIPromise<FileDownloadResponse> {
63
+ return this._client.get(path`/v1/files/${fileID}/url`, { query, ...options });
64
+ }
65
+
66
+ /**
67
+ * Get metadata for a specific file.
68
+ *
69
+ * Args: file_id: UUID of the file to retrieve identity: Authentication identity
70
+ * containing org_id db: Database session
71
+ *
72
+ * Returns: FileMetaResponse: File metadata including upload information
73
+ *
74
+ * Raises: HTTPException: 404 if file not found or doesn't belong to org
75
+ * HTTPException: 500 if uploader information is corrupted
76
+ */
77
+ get(fileID: string, options?: RequestOptions): APIPromise<File> {
78
+ return this._client.get(path`/v1/files/${fileID}`, options);
79
+ }
80
+
81
+ /**
82
+ * Upload a file to the Spitch server.
83
+ *
84
+ * Args: file: The file to upload from the request identity: Authentication
85
+ * identity containing org_id and user_id db: Database session
86
+ *
87
+ * Returns: FileMetaResponse: Metadata for the uploaded file
88
+ *
89
+ * Raises: HTTPException: 500 if upload fails
90
+ */
91
+ upload(body: FileUploadParams, options?: RequestOptions): APIPromise<File> {
92
+ return this._client.post('/v1/files', multipartFormRequestOptions({ body, ...options }, this._client));
93
+ }
94
+
95
+ /**
96
+ * Get storage usage statistics for the authenticated organization.
97
+ *
98
+ * Args: identity: Authentication identity containing org_id db: Database session
99
+ *
100
+ * Returns: FileUsage: Usage statistics including total/used bytes and file count
101
+ *
102
+ * Raises: HTTPException: 500 if unable to calculate usage
103
+ */
104
+ usage(options?: RequestOptions): APIPromise<FileUsage> {
105
+ return this._client.get('/v1/files:usage', options);
106
+ }
107
+ }
108
+
109
+ export type FilesFilesCursor = FilesCursor<File>;
110
+
111
+ /**
112
+ * description of a file. Attributes: file_id: unique identifier for the file.
113
+ * status: status of the file, `processing` or `ready` original_name: original name
114
+ * of the file. If the file was uploaded via API
115
+ */
116
+ export interface File {
117
+ category: string | null;
118
+
119
+ content_type: string | null;
120
+
121
+ created_at: string;
122
+
123
+ file_id: string;
124
+
125
+ original_name: string | null;
126
+
127
+ size_bytes: number | null;
128
+
129
+ status: 'uploading' | 'ready';
130
+
131
+ uploaded_by?: string | null;
132
+ }
133
+
134
+ /**
135
+ * Storage usage information for an organization.
136
+ *
137
+ * Attributes: total: Human-readable total storage limit used: Human-readable used
138
+ * storage amount total_bytes: Total storage limit in bytes used_bytes: Used
139
+ * storage amount in bytes num_files: Number of files stored
140
+ */
141
+ export interface FileUsage {
142
+ num_files: number;
143
+
144
+ total: string;
145
+
146
+ total_bytes: number;
147
+
148
+ used: string;
149
+
150
+ used_bytes: number;
151
+ }
152
+
153
+ /**
154
+ * Response model for listing files.
155
+ *
156
+ * Attributes: items: List of file metadata responses next_cursor: Optional cursor
157
+ * for pagination to get next page of results
158
+ */
159
+ export interface Files {
160
+ items: Array<File>;
161
+
162
+ next_cursor?: string | null;
163
+ }
164
+
165
+ export type FileDeleteResponse = unknown;
166
+
167
+ /**
168
+ * Response model for file download URLs.
169
+ *
170
+ * Attributes: file_id: Unique identifier for the file url: Pre-signed download URL
171
+ * expires_at: When the download URL expires
172
+ */
173
+ export interface FileDownloadResponse {
174
+ expires_at: string;
175
+
176
+ file_id: string;
177
+
178
+ url: string;
179
+ }
180
+
181
+ export interface FileListParams extends FilesCursorParams {
182
+ status?: 'uploading' | 'ready' | null;
183
+ }
184
+
185
+ export interface FileDownloadParams {
186
+ ttl?: number;
187
+ }
188
+
189
+ export interface FileUploadParams {
190
+ file: Uploadable;
191
+ }
192
+
193
+ export declare namespace Files {
194
+ export {
195
+ type File as File,
196
+ type FileUsage as FileUsage,
197
+ type Files as Files,
198
+ type FileDeleteResponse as FileDeleteResponse,
199
+ type FileDownloadResponse as FileDownloadResponse,
200
+ type FilesFilesCursor as FilesFilesCursor,
201
+ type FileListParams as FileListParams,
202
+ type FileDownloadParams as FileDownloadParams,
203
+ type FileUploadParams as FileUploadParams,
204
+ };
205
+ }
@@ -1,15 +1,21 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  export {
4
- Speech,
5
- type SpeechTranscribeResponse,
6
- type SpeechGenerateParams,
7
- type SpeechTranscribeParams,
8
- } from './speech';
4
+ Files,
5
+ type File,
6
+ type FileUsage,
7
+ type FileDeleteResponse,
8
+ type FileDownloadResponse,
9
+ type FileListParams,
10
+ type FileDownloadParams,
11
+ type FileUploadParams,
12
+ type FilesFilesCursor,
13
+ } from './files';
14
+ export { Speech, type Transcription, type SpeechGenerateParams, type SpeechTranscribeParams } from './speech';
9
15
  export {
10
16
  Text,
11
- type TextToneMarkResponse,
12
- type TextTranslateResponse,
17
+ type Diacritics,
18
+ type Translation,
13
19
  type TextToneMarkParams,
14
20
  type TextTranslateParams,
15
21
  } from './text';
@@ -7,6 +7,9 @@ import { buildHeaders } from '../internal/headers';
7
7
  import { RequestOptions } from '../internal/request-options';
8
8
  import { multipartFormRequestOptions } from '../internal/uploads';
9
9
 
10
+ /**
11
+ * All speech-focused APIs (TTS and STT)
12
+ */
10
13
  export class Speech extends APIResource {
11
14
  /**
12
15
  * Synthesize
@@ -15,7 +18,7 @@ export class Speech extends APIResource {
15
18
  return this._client.post('/v1/speech', {
16
19
  body,
17
20
  ...options,
18
- headers: buildHeaders([{ Accept: 'audio/wav' }, options?.headers]),
21
+ headers: buildHeaders([{ Accept: 'audio/*' }, options?.headers]),
19
22
  __binaryResponse: true,
20
23
  });
21
24
  }
@@ -23,7 +26,7 @@ export class Speech extends APIResource {
23
26
  /**
24
27
  * Transcribe
25
28
  */
26
- transcribe(body: SpeechTranscribeParams, options?: RequestOptions): APIPromise<SpeechTranscribeResponse> {
29
+ transcribe(body: SpeechTranscribeParams, options?: RequestOptions): APIPromise<Transcription> {
27
30
  return this._client.post(
28
31
  '/v1/transcriptions',
29
32
  multipartFormRequestOptions({ body, ...options }, this._client),
@@ -31,15 +34,15 @@ export class Speech extends APIResource {
31
34
  }
32
35
  }
33
36
 
34
- export interface SpeechTranscribeResponse {
37
+ export interface Transcription {
35
38
  request_id: string;
36
39
 
37
40
  text: string;
38
41
 
39
- timestamps?: Array<SpeechTranscribeResponse.Timestamp> | null;
42
+ timestamps?: Array<Transcription.Timestamp> | null;
40
43
  }
41
44
 
42
- export namespace SpeechTranscribeResponse {
45
+ export namespace Transcription {
43
46
  export interface Timestamp {
44
47
  end: number;
45
48
 
@@ -78,6 +81,8 @@ export interface SpeechGenerateParams {
78
81
  | 'tena'
79
82
  | 'tesfaye';
80
83
 
84
+ format?: 'wav' | 'mp3' | 'ogg_opus' | 'webm_opus' | 'flac' | 'pcm_s16le' | 'mulaw' | 'alaw';
85
+
81
86
  model?: 'legacy' | null;
82
87
  }
83
88
 
@@ -86,7 +91,7 @@ export interface SpeechTranscribeParams {
86
91
 
87
92
  content?: Uploadable | null;
88
93
 
89
- model?: 'mansa_v1' | 'legacy' | null;
94
+ model?: 'mansa_v1' | 'legacy' | 'human' | null;
90
95
 
91
96
  special_words?: string | null;
92
97
 
@@ -97,7 +102,7 @@ export interface SpeechTranscribeParams {
97
102
 
98
103
  export declare namespace Speech {
99
104
  export {
100
- type SpeechTranscribeResponse as SpeechTranscribeResponse,
105
+ type Transcription as Transcription,
101
106
  type SpeechGenerateParams as SpeechGenerateParams,
102
107
  type SpeechTranscribeParams as SpeechTranscribeParams,
103
108
  };
@@ -8,28 +8,45 @@ export class Text extends APIResource {
8
8
  /**
9
9
  * Tone Mark
10
10
  */
11
- toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<TextToneMarkResponse> {
11
+ toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<Diacritics> {
12
12
  return this._client.post('/v1/diacritics', { body, ...options });
13
13
  }
14
14
 
15
15
  /**
16
16
  * Translate
17
17
  */
18
- translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<TextTranslateResponse> {
18
+ translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<Translation> {
19
19
  return this._client.post('/v1/translate', { body, ...options });
20
20
  }
21
21
  }
22
22
 
23
- export interface TextToneMarkResponse {
23
+ /**
24
+ * Response model for text diacritization requests.
25
+ *
26
+ * Attributes:
27
+ * request_id: Unique identifier for the diacritization request
28
+ * text: Text with added diacritical marks for proper pronunciation
29
+ * language: Language code for the diacritized text
30
+ */
31
+ export interface Diacritics {
24
32
  request_id: string;
25
33
 
26
34
  text: string;
27
35
  }
28
36
 
29
- export interface TextTranslateResponse {
37
+ /**
38
+ * Translation result model.
39
+ *
40
+ * Attributes: request_id (UUID): Unique ID for this request. text: translated
41
+ * text. due_date: used when model is `human`. the date you can expect the
42
+ * translation to be delivered
43
+ */
44
+ export interface Translation {
30
45
  request_id: string;
31
46
 
32
47
  text: string;
48
+
49
+ due_date?: string | null;
33
50
  }
34
51
 
35
52
  export interface TextToneMarkParams {
@@ -43,13 +60,19 @@ export interface TextTranslateParams {
43
60
 
44
61
  target: 'yo' | 'en' | 'ha' | 'ig' | 'am';
45
62
 
46
- text: string;
63
+ file_id?: string | null;
64
+
65
+ instructions?: string | null;
66
+
67
+ model?: 'human' | 'auto';
68
+
69
+ text?: string | null;
47
70
  }
48
71
 
49
72
  export declare namespace Text {
50
73
  export {
51
- type TextToneMarkResponse as TextToneMarkResponse,
52
- type TextTranslateResponse as TextTranslateResponse,
74
+ type Diacritics as Diacritics,
75
+ type Translation as Translation,
53
76
  type TextToneMarkParams as TextToneMarkParams,
54
77
  type TextTranslateParams as TextTranslateParams,
55
78
  };
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.20.0'; // x-release-please-version
1
+ export const VERSION = '1.23.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.20.0";
1
+ export declare const VERSION = "1.23.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.20.0";
1
+ export declare const VERSION = "1.23.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.20.0'; // x-release-please-version
4
+ exports.VERSION = '1.23.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.20.0'; // x-release-please-version
1
+ export const VERSION = '1.23.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map