@wave-av/sdk 2.0.3 → 2.0.5
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 +9 -50
- package/dist/audience.d.ts +105 -0
- package/dist/audience.d.ts.map +1 -0
- package/dist/billing-types.d.ts +39 -0
- package/dist/billing-types.d.ts.map +1 -0
- package/dist/billing-types.js +18 -0
- package/dist/billing-types.mjs +0 -0
- package/dist/billing.d.ts +69 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +139 -0
- package/dist/billing.mjs +9 -0
- package/dist/camera-control.d.ts +55 -0
- package/dist/camera-control.d.ts.map +1 -0
- package/dist/captions-types.d.ts +119 -0
- package/dist/captions-types.d.ts.map +1 -0
- package/dist/captions.d.ts +218 -0
- package/dist/captions.d.ts.map +1 -0
- package/dist/chapters-types.d.ts +87 -0
- package/dist/chapters-types.d.ts.map +1 -0
- package/dist/chapters.d.ts +207 -0
- package/dist/chapters.d.ts.map +1 -0
- package/dist/chunk-I3V47I4W.mjs +114 -0
- package/dist/client-types.d.ts +59 -0
- package/dist/client-types.d.ts.map +1 -0
- package/dist/client.d.ts +119 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/clips-types.d.ts +31 -0
- package/dist/clips-types.d.ts.map +1 -0
- package/dist/clips.d.ts +230 -0
- package/dist/clips.d.ts.map +1 -0
- package/dist/cloud-switcher.d.ts +66 -0
- package/dist/cloud-switcher.d.ts.map +1 -0
- package/dist/collab-types.d.ts +205 -0
- package/dist/collab-types.d.ts.map +1 -0
- package/dist/collab.d.ts +227 -0
- package/dist/collab.d.ts.map +1 -0
- package/dist/connect.d.ts +89 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/creator.d.ts +110 -0
- package/dist/creator.d.ts.map +1 -0
- package/dist/desktop.d.ts +96 -0
- package/dist/desktop.d.ts.map +1 -0
- package/dist/distribution.d.ts +93 -0
- package/dist/distribution.d.ts.map +1 -0
- package/dist/drm.d.ts +88 -0
- package/dist/drm.d.ts.map +1 -0
- package/dist/edge.d.ts +113 -0
- package/dist/edge.d.ts.map +1 -0
- package/dist/editor-types.d.ts +237 -0
- package/dist/editor-types.d.ts.map +1 -0
- package/dist/editor.d.ts +207 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/fleet.d.ts +208 -0
- package/dist/fleet.d.ts.map +1 -0
- package/dist/ghost.d.ts +214 -0
- package/dist/ghost.d.ts.map +1 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +114 -0
- package/dist/index.mjs +49 -43
- package/dist/marketplace.d.ts +91 -0
- package/dist/marketplace.d.ts.map +1 -0
- package/dist/mesh.d.ts +238 -0
- package/dist/mesh.d.ts.map +1 -0
- package/dist/notifications.d.ts +83 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/phone-types.d.ts +111 -0
- package/dist/phone-types.d.ts.map +1 -0
- package/dist/phone.d.ts +235 -0
- package/dist/phone.d.ts.map +1 -0
- package/dist/pipeline-types.d.ts +188 -0
- package/dist/pipeline-types.d.ts.map +1 -0
- package/dist/pipeline.d.ts +224 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/podcast.d.ts +114 -0
- package/dist/podcast.d.ts.map +1 -0
- package/dist/prism.d.ts +133 -0
- package/dist/prism.d.ts.map +1 -0
- package/dist/prompter.d.ts +185 -0
- package/dist/prompter.d.ts.map +1 -0
- package/dist/pulse.d.ts +157 -0
- package/dist/pulse.d.ts.map +1 -0
- package/dist/qr.d.ts +83 -0
- package/dist/qr.d.ts.map +1 -0
- package/dist/replay.d.ts +53 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/scene-types.d.ts +191 -0
- package/dist/scene-types.d.ts.map +1 -0
- package/dist/scene.d.ts +214 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/search-types.d.ts +211 -0
- package/dist/search-types.d.ts.map +1 -0
- package/dist/search.d.ts +251 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/sentiment-types.d.ts +108 -0
- package/dist/sentiment-types.d.ts.map +1 -0
- package/dist/sentiment.d.ts +247 -0
- package/dist/sentiment.d.ts.map +1 -0
- package/dist/signage.d.ts +102 -0
- package/dist/signage.d.ts.map +1 -0
- package/dist/slides.d.ts +69 -0
- package/dist/slides.d.ts.map +1 -0
- package/dist/studio-ai-types.d.ts +199 -0
- package/dist/studio-ai-types.d.ts.map +1 -0
- package/dist/studio-ai.d.ts +219 -0
- package/dist/studio-ai.d.ts.map +1 -0
- package/dist/studio-types.d.ts +268 -0
- package/dist/studio-types.d.ts.map +1 -0
- package/dist/studio.d.ts +235 -0
- package/dist/studio.d.ts.map +1 -0
- package/dist/telemetry.d.ts +77 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/transcribe-types.d.ts +154 -0
- package/dist/transcribe-types.d.ts.map +1 -0
- package/dist/transcribe.d.ts +219 -0
- package/dist/transcribe.d.ts.map +1 -0
- package/dist/usb.d.ts +65 -0
- package/dist/usb.d.ts.map +1 -0
- package/dist/vault.d.ts +122 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/voice-types.d.ts +107 -0
- package/dist/voice-types.d.ts.map +1 -0
- package/dist/voice.d.ts +178 -0
- package/dist/voice.d.ts.map +1 -0
- package/dist/zoom.d.ts +92 -0
- package/dist/zoom.d.ts.map +1 -0
- package/package.json +86 -86
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAVE SDK - Captions API
|
|
3
|
+
*
|
|
4
|
+
* Generate, manage, and translate captions for video content.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: This is a client SDK. All authorization checks are performed server-side.
|
|
7
|
+
* The API will return 403 Forbidden if the user lacks required permissions.
|
|
8
|
+
*/
|
|
9
|
+
import type { WaveClient, PaginationParams, PaginatedResponse } from './client';
|
|
10
|
+
import type { CaptionFormat, CaptionTrack, CaptionCue, GenerateCaptionsRequest, UploadCaptionsRequest, UpdateCaptionsRequest, TranslateCaptionsRequest, BurnInCaptionsRequest, BurnInJob, ListCaptionsParams } from './captions-types';
|
|
11
|
+
/**
|
|
12
|
+
* Caption status
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Caption format
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Caption track
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Caption cue (single caption segment)
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Word-level timing
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Caption styling
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Generate captions request
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Upload captions request
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Update captions request
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Translate captions request
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Burn-in captions request
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Burn-in job
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* List captions params
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* Captions API client
|
|
52
|
+
*/
|
|
53
|
+
export declare class CaptionsAPI {
|
|
54
|
+
private readonly client;
|
|
55
|
+
private readonly basePath;
|
|
56
|
+
constructor(client: WaveClient);
|
|
57
|
+
/**
|
|
58
|
+
* Generate captions using AI
|
|
59
|
+
*
|
|
60
|
+
* Requires: captions:generate permission
|
|
61
|
+
*/
|
|
62
|
+
generate(request: GenerateCaptionsRequest): Promise<CaptionTrack>;
|
|
63
|
+
/**
|
|
64
|
+
* Upload existing captions
|
|
65
|
+
*
|
|
66
|
+
* Requires: captions:create permission
|
|
67
|
+
*/
|
|
68
|
+
upload(request: UploadCaptionsRequest): Promise<CaptionTrack>;
|
|
69
|
+
/**
|
|
70
|
+
* Get a caption track by ID
|
|
71
|
+
*
|
|
72
|
+
* Requires: captions:read permission
|
|
73
|
+
*/
|
|
74
|
+
get(trackId: string): Promise<CaptionTrack>;
|
|
75
|
+
/**
|
|
76
|
+
* Update a caption track
|
|
77
|
+
*
|
|
78
|
+
* Requires: captions:update permission
|
|
79
|
+
*/
|
|
80
|
+
update(trackId: string, request: UpdateCaptionsRequest): Promise<CaptionTrack>;
|
|
81
|
+
/**
|
|
82
|
+
* Remove a caption track
|
|
83
|
+
*
|
|
84
|
+
* Requires: captions:remove permission (server-side RBAC enforced)
|
|
85
|
+
*/
|
|
86
|
+
remove(trackId: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* List caption tracks
|
|
89
|
+
*
|
|
90
|
+
* Requires: captions:read permission
|
|
91
|
+
*/
|
|
92
|
+
list(params?: ListCaptionsParams): Promise<PaginatedResponse<CaptionTrack>>;
|
|
93
|
+
/**
|
|
94
|
+
* Get caption tracks for a specific media
|
|
95
|
+
*
|
|
96
|
+
* Requires: captions:read permission
|
|
97
|
+
*/
|
|
98
|
+
getForMedia(mediaId: string, mediaType: 'video' | 'audio' | 'stream'): Promise<CaptionTrack[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Get caption cues (segments)
|
|
101
|
+
*
|
|
102
|
+
* Requires: captions:read permission
|
|
103
|
+
*/
|
|
104
|
+
getCues(trackId: string, params?: PaginationParams & {
|
|
105
|
+
start_time?: number;
|
|
106
|
+
end_time?: number;
|
|
107
|
+
}): Promise<PaginatedResponse<CaptionCue>>;
|
|
108
|
+
/**
|
|
109
|
+
* Update a caption cue
|
|
110
|
+
*
|
|
111
|
+
* Requires: captions:update permission
|
|
112
|
+
*/
|
|
113
|
+
updateCue(trackId: string, cueId: string, updates: Partial<Pick<CaptionCue, 'text' | 'start_time' | 'end_time' | 'speaker' | 'style'>>): Promise<CaptionCue>;
|
|
114
|
+
/**
|
|
115
|
+
* Add a new caption cue
|
|
116
|
+
*
|
|
117
|
+
* Requires: captions:update permission
|
|
118
|
+
*/
|
|
119
|
+
addCue(trackId: string, cue: Omit<CaptionCue, 'id' | 'confidence' | 'words'>): Promise<CaptionCue>;
|
|
120
|
+
/**
|
|
121
|
+
* Remove a caption cue
|
|
122
|
+
*
|
|
123
|
+
* Requires: captions:update permission (server-side RBAC enforced)
|
|
124
|
+
*/
|
|
125
|
+
removeCue(trackId: string, cueId: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Bulk update cues
|
|
128
|
+
*
|
|
129
|
+
* Requires: captions:update permission
|
|
130
|
+
*/
|
|
131
|
+
bulkUpdateCues(trackId: string, updates: Array<{
|
|
132
|
+
id: string;
|
|
133
|
+
text?: string;
|
|
134
|
+
start_time?: number;
|
|
135
|
+
end_time?: number;
|
|
136
|
+
}>): Promise<{
|
|
137
|
+
updated: number;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Translate a caption track to another language
|
|
141
|
+
*
|
|
142
|
+
* Requires: captions:translate permission
|
|
143
|
+
*/
|
|
144
|
+
translate(trackId: string, request: TranslateCaptionsRequest): Promise<CaptionTrack>;
|
|
145
|
+
/**
|
|
146
|
+
* Export captions in a specific format
|
|
147
|
+
*
|
|
148
|
+
* Requires: captions:read permission
|
|
149
|
+
*/
|
|
150
|
+
exportFormat(trackId: string, format: CaptionFormat): Promise<{
|
|
151
|
+
url: string;
|
|
152
|
+
expires_at: string;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* Get captions as plain text
|
|
156
|
+
*
|
|
157
|
+
* Requires: captions:read permission
|
|
158
|
+
*/
|
|
159
|
+
getText(trackId: string): Promise<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Burn captions into video
|
|
162
|
+
*
|
|
163
|
+
* Requires: captions:burnin permission
|
|
164
|
+
*/
|
|
165
|
+
burnIn(request: BurnInCaptionsRequest): Promise<BurnInJob>;
|
|
166
|
+
/**
|
|
167
|
+
* Get burn-in job status
|
|
168
|
+
*
|
|
169
|
+
* Requires: captions:read permission
|
|
170
|
+
*/
|
|
171
|
+
getBurnInJob(jobId: string): Promise<BurnInJob>;
|
|
172
|
+
/**
|
|
173
|
+
* Wait for burn-in to complete
|
|
174
|
+
*/
|
|
175
|
+
waitForBurnIn(jobId: string, options?: {
|
|
176
|
+
pollInterval?: number;
|
|
177
|
+
timeout?: number;
|
|
178
|
+
onProgress?: (job: BurnInJob) => void;
|
|
179
|
+
}): Promise<BurnInJob>;
|
|
180
|
+
/**
|
|
181
|
+
* Wait for caption generation to complete
|
|
182
|
+
*/
|
|
183
|
+
waitForReady(trackId: string, options?: {
|
|
184
|
+
pollInterval?: number;
|
|
185
|
+
timeout?: number;
|
|
186
|
+
onProgress?: (track: CaptionTrack) => void;
|
|
187
|
+
}): Promise<CaptionTrack>;
|
|
188
|
+
/**
|
|
189
|
+
* Get supported languages
|
|
190
|
+
*
|
|
191
|
+
* Requires: captions:read permission
|
|
192
|
+
*/
|
|
193
|
+
getSupportedLanguages(): Promise<Array<{
|
|
194
|
+
code: string;
|
|
195
|
+
name: string;
|
|
196
|
+
native_name: string;
|
|
197
|
+
supports_generation: boolean;
|
|
198
|
+
supports_translation: boolean;
|
|
199
|
+
}>>;
|
|
200
|
+
/**
|
|
201
|
+
* Detect language from audio
|
|
202
|
+
*
|
|
203
|
+
* Requires: captions:generate permission
|
|
204
|
+
*/
|
|
205
|
+
detectLanguage(mediaId: string, mediaType: 'video' | 'audio' | 'stream'): Promise<{
|
|
206
|
+
detected_language: string;
|
|
207
|
+
confidence: number;
|
|
208
|
+
alternatives: Array<{
|
|
209
|
+
language: string;
|
|
210
|
+
confidence: number;
|
|
211
|
+
}>;
|
|
212
|
+
}>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Create a Captions API instance
|
|
216
|
+
*/
|
|
217
|
+
export declare function createCaptionsAPI(client: WaveClient): CaptionsAPI;
|
|
218
|
+
//# sourceMappingURL=captions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captions.d.ts","sourceRoot":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MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,KAAK,CAAC;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC/D,CAAC;CAMH;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAEjE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export type ChapterStatus = 'pending' | 'processing' | 'ready' | 'failed';
|
|
2
|
+
export interface Chapter extends Timestamps {
|
|
3
|
+
id: string;
|
|
4
|
+
media_id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
start_time: number;
|
|
8
|
+
end_time?: number;
|
|
9
|
+
thumbnail_url?: string;
|
|
10
|
+
order: number;
|
|
11
|
+
is_auto_generated: boolean;
|
|
12
|
+
confidence?: number;
|
|
13
|
+
metadata?: Metadata;
|
|
14
|
+
}
|
|
15
|
+
export interface ChapterSet extends Timestamps {
|
|
16
|
+
id: string;
|
|
17
|
+
organization_id: string;
|
|
18
|
+
media_id: string;
|
|
19
|
+
media_type: 'video' | 'audio' | 'stream';
|
|
20
|
+
name: string;
|
|
21
|
+
status: ChapterStatus;
|
|
22
|
+
is_default: boolean;
|
|
23
|
+
is_auto_generated: boolean;
|
|
24
|
+
chapters: Chapter[];
|
|
25
|
+
chapter_count: number;
|
|
26
|
+
error?: string;
|
|
27
|
+
metadata?: Metadata;
|
|
28
|
+
}
|
|
29
|
+
export interface GenerateChaptersRequest {
|
|
30
|
+
media_id: string;
|
|
31
|
+
media_type: 'video' | 'audio' | 'stream';
|
|
32
|
+
name?: string;
|
|
33
|
+
/** Minimum chapter duration in seconds */
|
|
34
|
+
min_duration?: number;
|
|
35
|
+
/** Maximum number of chapters */
|
|
36
|
+
max_chapters?: number;
|
|
37
|
+
/** Detection method */
|
|
38
|
+
method?: 'scene' | 'topic' | 'combined';
|
|
39
|
+
/** Use transcript for topic detection */
|
|
40
|
+
use_transcript?: boolean;
|
|
41
|
+
/** Caption track ID if using transcript */
|
|
42
|
+
caption_track_id?: string;
|
|
43
|
+
/** Generate thumbnails for chapters */
|
|
44
|
+
generate_thumbnails?: boolean;
|
|
45
|
+
/** Set as default chapter set */
|
|
46
|
+
set_as_default?: boolean;
|
|
47
|
+
/** Webhook URL for completion */
|
|
48
|
+
webhook_url?: string;
|
|
49
|
+
metadata?: Metadata;
|
|
50
|
+
}
|
|
51
|
+
export interface CreateChapterSetRequest {
|
|
52
|
+
media_id: string;
|
|
53
|
+
media_type: 'video' | 'audio' | 'stream';
|
|
54
|
+
name: string;
|
|
55
|
+
chapters: CreateChapterRequest[];
|
|
56
|
+
set_as_default?: boolean;
|
|
57
|
+
metadata?: Metadata;
|
|
58
|
+
}
|
|
59
|
+
export interface CreateChapterRequest {
|
|
60
|
+
title: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
start_time: number;
|
|
63
|
+
end_time?: number;
|
|
64
|
+
thumbnail_url?: string;
|
|
65
|
+
metadata?: Metadata;
|
|
66
|
+
}
|
|
67
|
+
export interface UpdateChapterRequest {
|
|
68
|
+
title?: string;
|
|
69
|
+
description?: string;
|
|
70
|
+
start_time?: number;
|
|
71
|
+
end_time?: number;
|
|
72
|
+
thumbnail_url?: string;
|
|
73
|
+
order?: number;
|
|
74
|
+
metadata?: Metadata;
|
|
75
|
+
}
|
|
76
|
+
export interface UpdateChapterSetRequest {
|
|
77
|
+
name?: string;
|
|
78
|
+
is_default?: boolean;
|
|
79
|
+
metadata?: Metadata;
|
|
80
|
+
}
|
|
81
|
+
export interface ListChapterSetsParams extends PaginationParams {
|
|
82
|
+
media_id?: string;
|
|
83
|
+
media_type?: 'video' | 'audio' | 'stream';
|
|
84
|
+
status?: ChapterStatus;
|
|
85
|
+
is_auto_generated?: boolean;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=chapters-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|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ACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AACD,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC1C,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAVE SDK - Chapters API
|
|
3
|
+
*
|
|
4
|
+
* Manage video chapters and smart chapter generation.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: This is a client SDK. All authorization checks are performed server-side.
|
|
7
|
+
* The API will return 403 Forbidden if the user lacks required permissions.
|
|
8
|
+
*/
|
|
9
|
+
import type { WaveClient, PaginatedResponse } from './client';
|
|
10
|
+
import type { Chapter, ChapterSet, GenerateChaptersRequest, CreateChapterSetRequest, CreateChapterRequest, UpdateChapterRequest, UpdateChapterSetRequest, ListChapterSetsParams } from './chapters-types';
|
|
11
|
+
/**
|
|
12
|
+
* Chapter status
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Chapter
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Chapter set (collection of chapters for a media)
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Generate chapters request
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Create chapter set request
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Create chapter request
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Update chapter request
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Update chapter set request
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* List chapter sets params
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Chapters API client
|
|
40
|
+
*/
|
|
41
|
+
export declare class ChaptersAPI {
|
|
42
|
+
private readonly client;
|
|
43
|
+
private readonly basePath;
|
|
44
|
+
constructor(client: WaveClient);
|
|
45
|
+
/**
|
|
46
|
+
* Generate chapters using AI
|
|
47
|
+
*
|
|
48
|
+
* Requires: chapters:generate permission
|
|
49
|
+
*/
|
|
50
|
+
generate(request: GenerateChaptersRequest): Promise<ChapterSet>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a chapter set manually
|
|
53
|
+
*
|
|
54
|
+
* Requires: chapters:create permission
|
|
55
|
+
*/
|
|
56
|
+
createSet(request: CreateChapterSetRequest): Promise<ChapterSet>;
|
|
57
|
+
/**
|
|
58
|
+
* Get a chapter set by ID
|
|
59
|
+
*
|
|
60
|
+
* Requires: chapters:read permission
|
|
61
|
+
*/
|
|
62
|
+
getSet(setId: string): Promise<ChapterSet>;
|
|
63
|
+
/**
|
|
64
|
+
* Update a chapter set
|
|
65
|
+
*
|
|
66
|
+
* Requires: chapters:update permission
|
|
67
|
+
*/
|
|
68
|
+
updateSet(setId: string, request: UpdateChapterSetRequest): Promise<ChapterSet>;
|
|
69
|
+
/**
|
|
70
|
+
* Remove a chapter set
|
|
71
|
+
*
|
|
72
|
+
* Requires: chapters:remove permission (canDelete verified server-side)
|
|
73
|
+
*/
|
|
74
|
+
removeSet(setId: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* List chapter sets
|
|
77
|
+
*
|
|
78
|
+
* Requires: chapters:read permission
|
|
79
|
+
*/
|
|
80
|
+
listSets(params?: ListChapterSetsParams): Promise<PaginatedResponse<ChapterSet>>;
|
|
81
|
+
/**
|
|
82
|
+
* Get the default chapter set for a media
|
|
83
|
+
*
|
|
84
|
+
* Requires: chapters:read permission
|
|
85
|
+
*/
|
|
86
|
+
getDefaultSet(mediaId: string, mediaType: 'video' | 'audio' | 'stream'): Promise<ChapterSet | null>;
|
|
87
|
+
/**
|
|
88
|
+
* Duplicate a chapter set
|
|
89
|
+
*
|
|
90
|
+
* Requires: chapters:create permission
|
|
91
|
+
*/
|
|
92
|
+
duplicateSet(setId: string, name?: string): Promise<ChapterSet>;
|
|
93
|
+
/**
|
|
94
|
+
* Add a chapter to a set
|
|
95
|
+
*
|
|
96
|
+
* Requires: chapters:update permission
|
|
97
|
+
*/
|
|
98
|
+
addChapter(setId: string, chapter: CreateChapterRequest): Promise<Chapter>;
|
|
99
|
+
/**
|
|
100
|
+
* Get a chapter by ID
|
|
101
|
+
*
|
|
102
|
+
* Requires: chapters:read permission
|
|
103
|
+
*/
|
|
104
|
+
getChapter(setId: string, chapterId: string): Promise<Chapter>;
|
|
105
|
+
/**
|
|
106
|
+
* Update a chapter
|
|
107
|
+
*
|
|
108
|
+
* Requires: chapters:update permission
|
|
109
|
+
*/
|
|
110
|
+
updateChapter(setId: string, chapterId: string, request: UpdateChapterRequest): Promise<Chapter>;
|
|
111
|
+
/**
|
|
112
|
+
* Remove a chapter
|
|
113
|
+
*
|
|
114
|
+
* Requires: chapters:update permission (server-side RBAC enforced)
|
|
115
|
+
*/
|
|
116
|
+
removeChapter(setId: string, chapterId: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Reorder chapters
|
|
119
|
+
*
|
|
120
|
+
* Requires: chapters:update permission
|
|
121
|
+
*/
|
|
122
|
+
reorderChapters(setId: string, chapterIds: string[]): Promise<ChapterSet>;
|
|
123
|
+
/**
|
|
124
|
+
* Bulk update chapters
|
|
125
|
+
*
|
|
126
|
+
* Requires: chapters:update permission
|
|
127
|
+
*/
|
|
128
|
+
bulkUpdateChapters(setId: string, updates: Array<{
|
|
129
|
+
id: string;
|
|
130
|
+
} & Partial<UpdateChapterRequest>>): Promise<{
|
|
131
|
+
updated: number;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Generate thumbnail for a chapter
|
|
135
|
+
*
|
|
136
|
+
* Requires: chapters:update permission
|
|
137
|
+
*/
|
|
138
|
+
generateThumbnail(setId: string, chapterId: string, options?: {
|
|
139
|
+
time?: number;
|
|
140
|
+
}): Promise<Chapter>;
|
|
141
|
+
/**
|
|
142
|
+
* Generate thumbnails for all chapters in a set
|
|
143
|
+
*
|
|
144
|
+
* Requires: chapters:update permission
|
|
145
|
+
*/
|
|
146
|
+
generateAllThumbnails(setId: string): Promise<{
|
|
147
|
+
generated: number;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Export chapters in various formats
|
|
151
|
+
*
|
|
152
|
+
* Requires: chapters:read permission
|
|
153
|
+
*/
|
|
154
|
+
exportChapters(setId: string, format: 'json' | 'youtube' | 'webvtt' | 'ffmpeg'): Promise<{
|
|
155
|
+
content: string;
|
|
156
|
+
format: string;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Import chapters from a format
|
|
160
|
+
*
|
|
161
|
+
* Requires: chapters:create permission
|
|
162
|
+
*/
|
|
163
|
+
importChapters(mediaId: string, mediaType: 'video' | 'audio' | 'stream', format: 'json' | 'youtube' | 'webvtt' | 'ffmpeg', content: string, options?: {
|
|
164
|
+
name?: string;
|
|
165
|
+
set_as_default?: boolean;
|
|
166
|
+
}): Promise<ChapterSet>;
|
|
167
|
+
/**
|
|
168
|
+
* Wait for chapter generation to complete
|
|
169
|
+
*/
|
|
170
|
+
waitForReady(setId: string, options?: {
|
|
171
|
+
pollInterval?: number;
|
|
172
|
+
timeout?: number;
|
|
173
|
+
onProgress?: (set: ChapterSet) => void;
|
|
174
|
+
}): Promise<ChapterSet>;
|
|
175
|
+
/**
|
|
176
|
+
* Get chapter at a specific time
|
|
177
|
+
*
|
|
178
|
+
* Requires: chapters:read permission
|
|
179
|
+
*/
|
|
180
|
+
getChapterAtTime(setId: string, time: number): Promise<Chapter | null>;
|
|
181
|
+
/**
|
|
182
|
+
* Merge chapters
|
|
183
|
+
*
|
|
184
|
+
* Requires: chapters:update permission
|
|
185
|
+
*/
|
|
186
|
+
mergeChapters(setId: string, chapterIds: string[], options?: {
|
|
187
|
+
title?: string;
|
|
188
|
+
description?: string;
|
|
189
|
+
}): Promise<Chapter>;
|
|
190
|
+
/**
|
|
191
|
+
* Split a chapter at a specific time
|
|
192
|
+
*
|
|
193
|
+
* Requires: chapters:update permission
|
|
194
|
+
*/
|
|
195
|
+
splitChapter(setId: string, chapterId: string, splitTime: number, options?: {
|
|
196
|
+
first_title?: string;
|
|
197
|
+
second_title?: string;
|
|
198
|
+
}): Promise<{
|
|
199
|
+
first: Chapter;
|
|
200
|
+
second: Chapter;
|
|
201
|
+
}>;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Create a Chapters API instance
|
|
205
|
+
*/
|
|
206
|
+
export declare function createChaptersAPI(client: WaveClient): ChaptersAPI;
|
|
207
|
+
//# sourceMappingURL=chapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chapters.d.ts","sourceRoot":"","sources":["../src/chapters.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,UAAU,EAEV,iBAAiB,EAGlB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAiB,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAIzN;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAIH;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;gBAE/B,MAAM,EAAE,UAAU;IAM9B;;;;OAIG;IACG,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC;IAIrE;;;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EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;KACxC,GACA,OAAO,CAAC,UAAU,CAAC;IA0BtB;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAa5E;;;;OAIG;IACG,aAAa,CACjB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAAE,EACpB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GACjD,OAAO,CAAC,OAAO,CAAC;IAOnB;;;;OAIG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAMhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAEjE"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/billing.ts
|
|
2
|
+
var BillingAPI = class {
|
|
3
|
+
client;
|
|
4
|
+
thresholds = [];
|
|
5
|
+
pollInterval = null;
|
|
6
|
+
config;
|
|
7
|
+
constructor(client, config) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.config = {
|
|
10
|
+
pollIntervalMs: config?.pollIntervalMs ?? 6e4
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Report a usage event to a billing meter.
|
|
15
|
+
* Events are aggregated by Stripe Billing Meters.
|
|
16
|
+
*/
|
|
17
|
+
async reportUsage(event) {
|
|
18
|
+
await this.client.request("POST", "/billing/usage/track", {
|
|
19
|
+
meter_type: event.meterType,
|
|
20
|
+
value: event.value,
|
|
21
|
+
idempotency_key: event.idempotencyKey,
|
|
22
|
+
timestamp: event.timestamp?.toISOString(),
|
|
23
|
+
dimensions: event.dimensions
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Report multiple usage events in a single request.
|
|
28
|
+
*/
|
|
29
|
+
async reportUsageBatch(events) {
|
|
30
|
+
await this.client.request("POST", "/billing/usage/track/batch", {
|
|
31
|
+
events: events.map((e) => ({
|
|
32
|
+
meter_type: e.meterType,
|
|
33
|
+
value: e.value,
|
|
34
|
+
idempotency_key: e.idempotencyKey,
|
|
35
|
+
timestamp: e.timestamp?.toISOString(),
|
|
36
|
+
dimensions: e.dimensions
|
|
37
|
+
}))
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get current usage summary for a meter in the current billing period.
|
|
42
|
+
*/
|
|
43
|
+
async getUsageSummary(meterType) {
|
|
44
|
+
return this.client.request("GET", `/billing/usage/meters?meter=${meterType}`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get usage summaries for all 6 billing meters.
|
|
48
|
+
*/
|
|
49
|
+
async getAllUsageSummaries() {
|
|
50
|
+
return this.client.request("GET", "/billing/usage/meters");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get current subscription status.
|
|
54
|
+
*/
|
|
55
|
+
async getSubscriptionStatus() {
|
|
56
|
+
return this.client.request("GET", "/billing/status");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Register a callback when usage crosses a threshold percentage.
|
|
60
|
+
* Starts polling usage data if not already polling.
|
|
61
|
+
*/
|
|
62
|
+
onUsageThreshold(meterType, thresholdPercent, callback) {
|
|
63
|
+
const entry = {
|
|
64
|
+
meterType,
|
|
65
|
+
threshold: thresholdPercent,
|
|
66
|
+
callback
|
|
67
|
+
};
|
|
68
|
+
this.thresholds.push(entry);
|
|
69
|
+
if (!this.pollInterval) {
|
|
70
|
+
this.startPolling();
|
|
71
|
+
}
|
|
72
|
+
return () => {
|
|
73
|
+
const idx = this.thresholds.indexOf(entry);
|
|
74
|
+
if (idx >= 0) this.thresholds.splice(idx, 1);
|
|
75
|
+
if (this.thresholds.length === 0) this.stopPolling();
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Stop all polling and clean up.
|
|
80
|
+
*/
|
|
81
|
+
destroy() {
|
|
82
|
+
this.stopPolling();
|
|
83
|
+
this.thresholds = [];
|
|
84
|
+
}
|
|
85
|
+
startPolling() {
|
|
86
|
+
this.pollInterval = setInterval(async () => {
|
|
87
|
+
try {
|
|
88
|
+
const summaries = await this.getAllUsageSummaries();
|
|
89
|
+
for (const summary of summaries) {
|
|
90
|
+
for (const threshold of this.thresholds) {
|
|
91
|
+
if (threshold.meterType === summary.meterType && summary.percentUsed >= threshold.threshold) {
|
|
92
|
+
threshold.callback(summary);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
}, this.config.pollIntervalMs);
|
|
99
|
+
}
|
|
100
|
+
stopPolling() {
|
|
101
|
+
if (this.pollInterval) {
|
|
102
|
+
clearInterval(this.pollInterval);
|
|
103
|
+
this.pollInterval = null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function createBillingAPI(client, config) {
|
|
108
|
+
return new BillingAPI(client, config);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
BillingAPI,
|
|
113
|
+
createBillingAPI
|
|
114
|
+
};
|