notebooklm-kit 0.0.1 → 2.1.1
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/LICENSE +22 -0
- package/README.md +4102 -0
- package/dist/src/auth/auth.d.ts +46 -0
- package/dist/src/auth/auth.d.ts.map +1 -0
- package/dist/src/auth/auth.js +323 -0
- package/dist/src/auth/auth.js.map +1 -0
- package/dist/src/auth/refresh.d.ts +150 -0
- package/dist/src/auth/refresh.d.ts.map +1 -0
- package/dist/src/auth/refresh.js +433 -0
- package/dist/src/auth/refresh.js.map +1 -0
- package/dist/src/client/notebooklm-client.d.ts +372 -0
- package/dist/src/client/notebooklm-client.d.ts.map +1 -0
- package/dist/src/client/notebooklm-client.js +550 -0
- package/dist/src/client/notebooklm-client.js.map +1 -0
- package/dist/src/index.d.ts +50 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +45 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/rpc/rpc-client.d.ts +48 -0
- package/dist/src/rpc/rpc-client.d.ts.map +1 -0
- package/dist/src/rpc/rpc-client.js +94 -0
- package/dist/src/rpc/rpc-client.js.map +1 -0
- package/dist/src/rpc/rpc-methods.d.ts +127 -0
- package/dist/src/rpc/rpc-methods.d.ts.map +1 -0
- package/dist/src/rpc/rpc-methods.js +169 -0
- package/dist/src/rpc/rpc-methods.js.map +1 -0
- package/dist/src/services/artifacts.d.ts +1017 -0
- package/dist/src/services/artifacts.d.ts.map +1 -0
- package/dist/src/services/artifacts.js +5413 -0
- package/dist/src/services/artifacts.js.map +1 -0
- package/dist/src/services/generation.d.ts +147 -0
- package/dist/src/services/generation.d.ts.map +1 -0
- package/dist/src/services/generation.js +479 -0
- package/dist/src/services/generation.js.map +1 -0
- package/dist/src/services/notebook-language.d.ts +109 -0
- package/dist/src/services/notebook-language.d.ts.map +1 -0
- package/dist/src/services/notebook-language.js +204 -0
- package/dist/src/services/notebook-language.js.map +1 -0
- package/dist/src/services/notebooks.d.ts +26 -0
- package/dist/src/services/notebooks.d.ts.map +1 -0
- package/dist/src/services/notebooks.js +539 -0
- package/dist/src/services/notebooks.js.map +1 -0
- package/dist/src/services/notes.d.ts +72 -0
- package/dist/src/services/notes.d.ts.map +1 -0
- package/dist/src/services/notes.js +340 -0
- package/dist/src/services/notes.js.map +1 -0
- package/dist/src/services/sources.d.ts +1085 -0
- package/dist/src/services/sources.d.ts.map +1 -0
- package/dist/src/services/sources.js +2675 -0
- package/dist/src/services/sources.js.map +1 -0
- package/dist/src/types/artifact.d.ts +258 -0
- package/dist/src/types/artifact.d.ts.map +1 -0
- package/dist/src/types/artifact.js +42 -0
- package/dist/src/types/artifact.js.map +1 -0
- package/dist/src/types/common.d.ts +226 -0
- package/dist/src/types/common.d.ts.map +1 -0
- package/dist/src/types/common.js +80 -0
- package/dist/src/types/common.js.map +1 -0
- package/dist/src/types/languages.d.ts +179 -0
- package/dist/src/types/languages.d.ts.map +1 -0
- package/dist/src/types/languages.js +254 -0
- package/dist/src/types/languages.js.map +1 -0
- package/dist/src/types/note.d.ts +41 -0
- package/dist/src/types/note.d.ts.map +1 -0
- package/dist/src/types/note.js +12 -0
- package/dist/src/types/note.js.map +1 -0
- package/dist/src/types/notebook.d.ts +81 -0
- package/dist/src/types/notebook.d.ts.map +1 -0
- package/dist/src/types/notebook.js +5 -0
- package/dist/src/types/notebook.js.map +1 -0
- package/dist/src/types/source.d.ts +241 -0
- package/dist/src/types/source.d.ts.map +1 -0
- package/dist/src/types/source.js +60 -0
- package/dist/src/types/source.js.map +1 -0
- package/dist/src/utils/batch-execute.d.ts +58 -0
- package/dist/src/utils/batch-execute.d.ts.map +1 -0
- package/dist/src/utils/batch-execute.js +398 -0
- package/dist/src/utils/batch-execute.js.map +1 -0
- package/dist/src/utils/chunked-decoder.d.ts +11 -0
- package/dist/src/utils/chunked-decoder.d.ts.map +1 -0
- package/dist/src/utils/chunked-decoder.js +326 -0
- package/dist/src/utils/chunked-decoder.js.map +1 -0
- package/dist/src/utils/chunked-parser.d.ts +61 -0
- package/dist/src/utils/chunked-parser.d.ts.map +1 -0
- package/dist/src/utils/chunked-parser.js +609 -0
- package/dist/src/utils/chunked-parser.js.map +1 -0
- package/dist/src/utils/errors.d.ts +58 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +357 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/quota.d.ts +213 -0
- package/dist/src/utils/quota.d.ts.map +1 -0
- package/dist/src/utils/quota.js +518 -0
- package/dist/src/utils/quota.js.map +1 -0
- package/dist/src/utils/streaming-client.d.ts +129 -0
- package/dist/src/utils/streaming-client.d.ts.map +1 -0
- package/dist/src/utils/streaming-client.js +559 -0
- package/dist/src/utils/streaming-client.js.map +1 -0
- package/package.json +85 -7
- package/index.js +0 -2
|
@@ -0,0 +1,1017 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifacts service
|
|
3
|
+
* Handles all artifact operations (documents, presentations, audio, video, quizzes, flashcards, etc.)
|
|
4
|
+
*/
|
|
5
|
+
import { RPCClient } from '../rpc/rpc-client.js';
|
|
6
|
+
import { ArtifactType, ArtifactState } from '../types/artifact.js';
|
|
7
|
+
export { ArtifactType, ArtifactState } from '../types/artifact.js';
|
|
8
|
+
export declare enum ShareOption {
|
|
9
|
+
PRIVATE = 0,
|
|
10
|
+
PUBLIC = 1
|
|
11
|
+
}
|
|
12
|
+
export interface Artifact {
|
|
13
|
+
artifactId: string;
|
|
14
|
+
type?: ArtifactType;
|
|
15
|
+
state?: ArtifactState;
|
|
16
|
+
title?: string;
|
|
17
|
+
sourceIds?: string[];
|
|
18
|
+
createdAt?: string;
|
|
19
|
+
updatedAt?: string;
|
|
20
|
+
audioData?: string;
|
|
21
|
+
videoData?: string;
|
|
22
|
+
status?: string;
|
|
23
|
+
duration?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface AudioOverview {
|
|
26
|
+
projectId: string;
|
|
27
|
+
audioId?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
audioData?: string;
|
|
30
|
+
isReady: boolean;
|
|
31
|
+
state?: ArtifactState;
|
|
32
|
+
duration?: number;
|
|
33
|
+
createdAt?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface VideoOverview {
|
|
36
|
+
projectId: string;
|
|
37
|
+
videoId?: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
videoData?: string;
|
|
40
|
+
isReady: boolean;
|
|
41
|
+
state?: ArtifactState;
|
|
42
|
+
createdAt?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CreateAudioOverviewOptions {
|
|
45
|
+
title?: string;
|
|
46
|
+
instructions?: string;
|
|
47
|
+
sourceIds?: string[];
|
|
48
|
+
customization?: AudioCustomization;
|
|
49
|
+
}
|
|
50
|
+
export interface CreateVideoOverviewOptions {
|
|
51
|
+
title?: string;
|
|
52
|
+
instructions?: string;
|
|
53
|
+
sourceIds?: string[];
|
|
54
|
+
customization?: VideoCustomization;
|
|
55
|
+
}
|
|
56
|
+
export interface ShareAudioResult {
|
|
57
|
+
shareUrl: string;
|
|
58
|
+
shareId: string;
|
|
59
|
+
isPublic: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface ShareArtifactOptions {
|
|
62
|
+
users?: Array<{
|
|
63
|
+
email: string;
|
|
64
|
+
role: 2 | 3 | 4;
|
|
65
|
+
}>;
|
|
66
|
+
notify?: boolean;
|
|
67
|
+
accessType?: 1 | 2;
|
|
68
|
+
}
|
|
69
|
+
export interface ShareArtifactResult {
|
|
70
|
+
shareUrl: string;
|
|
71
|
+
success: boolean;
|
|
72
|
+
notebookId: string;
|
|
73
|
+
accessType: 1 | 2;
|
|
74
|
+
isShared: boolean;
|
|
75
|
+
users?: Array<{
|
|
76
|
+
email: string;
|
|
77
|
+
role: 2 | 3;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
export interface QuizCustomization {
|
|
81
|
+
numberOfQuestions?: 1 | 2 | 3;
|
|
82
|
+
difficulty?: 1 | 2 | 3;
|
|
83
|
+
language?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface FlashcardCustomization {
|
|
86
|
+
numberOfCards?: 1 | 2 | 3;
|
|
87
|
+
difficulty?: 1 | 2 | 3;
|
|
88
|
+
language?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface SlideDeckCustomization {
|
|
91
|
+
format?: 2 | 3;
|
|
92
|
+
language?: string;
|
|
93
|
+
length?: 1 | 2 | 3;
|
|
94
|
+
}
|
|
95
|
+
export interface InfographicCustomization {
|
|
96
|
+
language?: string;
|
|
97
|
+
orientation?: 1 | 2 | 3;
|
|
98
|
+
levelOfDetail?: 1 | 2 | 3;
|
|
99
|
+
}
|
|
100
|
+
export interface AudioCustomization {
|
|
101
|
+
format?: 0 | 1 | 2 | 3;
|
|
102
|
+
language?: string;
|
|
103
|
+
length?: 1 | 2 | 3;
|
|
104
|
+
}
|
|
105
|
+
export interface VideoCustomization {
|
|
106
|
+
format?: 1 | 2;
|
|
107
|
+
language?: string;
|
|
108
|
+
visualStyle?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
109
|
+
focus?: string;
|
|
110
|
+
customStyleDescription?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface CreateArtifactOptions {
|
|
113
|
+
title?: string;
|
|
114
|
+
instructions?: string;
|
|
115
|
+
sourceIds?: string[];
|
|
116
|
+
customization?: QuizCustomization | FlashcardCustomization | SlideDeckCustomization | InfographicCustomization | AudioCustomization | VideoCustomization;
|
|
117
|
+
}
|
|
118
|
+
export interface QuizQuestion {
|
|
119
|
+
question: string;
|
|
120
|
+
options: string[];
|
|
121
|
+
correctAnswer: number;
|
|
122
|
+
explanation?: string;
|
|
123
|
+
hint?: string;
|
|
124
|
+
reasoning?: string;
|
|
125
|
+
optionReasons?: string[];
|
|
126
|
+
}
|
|
127
|
+
export interface QuizData {
|
|
128
|
+
questions: QuizQuestion[];
|
|
129
|
+
totalQuestions: number;
|
|
130
|
+
}
|
|
131
|
+
export interface FlashcardData {
|
|
132
|
+
csv: string;
|
|
133
|
+
flashcards?: Array<{
|
|
134
|
+
question: string;
|
|
135
|
+
answer: string;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
export interface ParsedFlashcardData {
|
|
139
|
+
flashcards: Array<{
|
|
140
|
+
question: string;
|
|
141
|
+
answer: string;
|
|
142
|
+
}>;
|
|
143
|
+
totalCards: number;
|
|
144
|
+
csv: string;
|
|
145
|
+
}
|
|
146
|
+
export interface AudioArtifact extends Artifact {
|
|
147
|
+
audioData: string;
|
|
148
|
+
duration?: number;
|
|
149
|
+
status?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface VideoArtifact extends Artifact {
|
|
152
|
+
videoData: string;
|
|
153
|
+
status?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface InfographicImageData {
|
|
156
|
+
imageUrl: string;
|
|
157
|
+
imageData?: Uint8Array | ArrayBuffer;
|
|
158
|
+
mimeType?: string;
|
|
159
|
+
width?: number;
|
|
160
|
+
height?: number;
|
|
161
|
+
}
|
|
162
|
+
export interface FetchInfographicOptions {
|
|
163
|
+
downloadImage?: boolean;
|
|
164
|
+
cookies?: string;
|
|
165
|
+
}
|
|
166
|
+
export interface DownloadSlidesOptions {
|
|
167
|
+
googleDomainCookies?: string;
|
|
168
|
+
}
|
|
169
|
+
export interface GetSlideOptions {
|
|
170
|
+
/** Download format: 'pdf' (default) or 'png' */
|
|
171
|
+
downloadAs?: 'pdf' | 'png';
|
|
172
|
+
/** Output directory path (required for slides) */
|
|
173
|
+
outputPath: string;
|
|
174
|
+
}
|
|
175
|
+
export interface GetVideoOptions {
|
|
176
|
+
/** Output directory path (required for videos) */
|
|
177
|
+
outputPath: string;
|
|
178
|
+
}
|
|
179
|
+
export interface CreateReportOptions {
|
|
180
|
+
instructions?: string;
|
|
181
|
+
sourceIds?: string[];
|
|
182
|
+
title?: string;
|
|
183
|
+
subtitle?: string;
|
|
184
|
+
language?: string;
|
|
185
|
+
}
|
|
186
|
+
export interface ReportContent {
|
|
187
|
+
title: string;
|
|
188
|
+
content: string;
|
|
189
|
+
sections?: Array<{
|
|
190
|
+
title: string;
|
|
191
|
+
content: string;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Service for artifact operations
|
|
196
|
+
*/
|
|
197
|
+
declare class VideoService {
|
|
198
|
+
private artifactsService;
|
|
199
|
+
constructor(artifactsService: ArtifactsService);
|
|
200
|
+
create(notebookId: string, options?: CreateVideoOverviewOptions): Promise<VideoOverview>;
|
|
201
|
+
}
|
|
202
|
+
declare class AudioService {
|
|
203
|
+
private artifactsService;
|
|
204
|
+
constructor(artifactsService: ArtifactsService);
|
|
205
|
+
create(notebookId: string, options?: CreateAudioOverviewOptions): Promise<AudioOverview>;
|
|
206
|
+
}
|
|
207
|
+
declare class InfographicService {
|
|
208
|
+
private artifactsService;
|
|
209
|
+
constructor(artifactsService: ArtifactsService);
|
|
210
|
+
create(notebookId: string, options?: CreateArtifactOptions): Promise<Artifact>;
|
|
211
|
+
}
|
|
212
|
+
declare class MindMapService {
|
|
213
|
+
private artifactsService;
|
|
214
|
+
constructor(artifactsService: ArtifactsService);
|
|
215
|
+
create(notebookId: string, options?: CreateArtifactOptions): Promise<Artifact>;
|
|
216
|
+
}
|
|
217
|
+
declare class ReportService {
|
|
218
|
+
private artifactsService;
|
|
219
|
+
constructor(artifactsService: ArtifactsService);
|
|
220
|
+
create(notebookId: string, options?: CreateArtifactOptions): Promise<Artifact>;
|
|
221
|
+
}
|
|
222
|
+
declare class FlashcardService {
|
|
223
|
+
private artifactsService;
|
|
224
|
+
constructor(artifactsService: ArtifactsService);
|
|
225
|
+
create(notebookId: string, options?: CreateArtifactOptions): Promise<Artifact>;
|
|
226
|
+
}
|
|
227
|
+
declare class QuizService {
|
|
228
|
+
private artifactsService;
|
|
229
|
+
constructor(artifactsService: ArtifactsService);
|
|
230
|
+
create(notebookId: string, options?: CreateArtifactOptions): Promise<Artifact>;
|
|
231
|
+
}
|
|
232
|
+
declare class SlideService {
|
|
233
|
+
private artifactsService;
|
|
234
|
+
constructor(artifactsService: ArtifactsService);
|
|
235
|
+
create(notebookId: string, options?: CreateArtifactOptions): Promise<Artifact>;
|
|
236
|
+
}
|
|
237
|
+
export declare class ArtifactsService {
|
|
238
|
+
private rpc;
|
|
239
|
+
private quota?;
|
|
240
|
+
readonly video: VideoService;
|
|
241
|
+
readonly audio: AudioService;
|
|
242
|
+
readonly infographic: InfographicService;
|
|
243
|
+
readonly mindmap: MindMapService;
|
|
244
|
+
readonly report: ReportService;
|
|
245
|
+
readonly flashcard: FlashcardService;
|
|
246
|
+
readonly quiz: QuizService;
|
|
247
|
+
readonly slide: SlideService;
|
|
248
|
+
private notebookLanguageService;
|
|
249
|
+
constructor(rpc: RPCClient, quota?: import("../utils/quota.js").QuotaManager | undefined);
|
|
250
|
+
/**
|
|
251
|
+
* Get the default language for a notebook
|
|
252
|
+
* Uses the notebook's default output language if available, otherwise falls back to 'en'
|
|
253
|
+
*
|
|
254
|
+
* @param notebookId - The notebook ID
|
|
255
|
+
* @returns The default language code
|
|
256
|
+
*/
|
|
257
|
+
private getDefaultLanguage;
|
|
258
|
+
/**
|
|
259
|
+
* List all artifacts for a notebook
|
|
260
|
+
*
|
|
261
|
+
* **What it does:** Retrieves a list of all artifacts (quizzes, flashcards, study guides,
|
|
262
|
+
* mind maps, infographics, slide decks, reports, audio, video) associated with a notebook.
|
|
263
|
+
*
|
|
264
|
+
* **Input:**
|
|
265
|
+
* - `notebookId` (string, required): The ID of the notebook to list artifacts from
|
|
266
|
+
* - `options` (object, optional): Filtering options
|
|
267
|
+
* - `type` (ArtifactType, optional): Filter by artifact type
|
|
268
|
+
* - `state` (ArtifactState, optional): Filter by artifact state
|
|
269
|
+
*
|
|
270
|
+
* **Output:** Returns an array of `Artifact` objects, each containing:
|
|
271
|
+
* - `artifactId`: Unique identifier for the artifact
|
|
272
|
+
* - `type`: Artifact type (QUIZ, FLASHCARDS, REPORT, MIND_MAP, INFOGRAPHIC, SLIDE_DECK, AUDIO, VIDEO, etc.)
|
|
273
|
+
* - `state`: Current state (CREATING, READY, FAILED)
|
|
274
|
+
* - `title`: Artifact title/name
|
|
275
|
+
* - `sourceIds`: Source IDs used to create the artifact
|
|
276
|
+
* - `createdAt`, `updatedAt`: Timestamps
|
|
277
|
+
*
|
|
278
|
+
* **Next steps:**
|
|
279
|
+
* - Use `get(artifactId)` to fetch detailed artifact information
|
|
280
|
+
* - Use `download(artifactId)` to retrieve artifact content (for quizzes, flashcards, audio, etc.)
|
|
281
|
+
* - Check `state` field to see if artifact is READY before downloading
|
|
282
|
+
*
|
|
283
|
+
* @param notebookId - The notebook ID
|
|
284
|
+
* @param options - Filtering options
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* // List all artifacts
|
|
289
|
+
* const artifacts = await client.artifacts.list('notebook-id');
|
|
290
|
+
*
|
|
291
|
+
* // Filter by type
|
|
292
|
+
* const quizzes = await client.artifacts.list('notebook-id', { type: ArtifactType.QUIZ });
|
|
293
|
+
*
|
|
294
|
+
* // Filter by state
|
|
295
|
+
* const ready = await client.artifacts.list('notebook-id', { state: ArtifactState.READY });
|
|
296
|
+
*
|
|
297
|
+
* // Filter by both type and state
|
|
298
|
+
* const readyQuizzes = await client.artifacts.list('notebook-id', {
|
|
299
|
+
* type: ArtifactType.QUIZ,
|
|
300
|
+
* state: ArtifactState.READY
|
|
301
|
+
* });
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
list(notebookId: string, options?: {
|
|
305
|
+
type?: ArtifactType;
|
|
306
|
+
state?: ArtifactState;
|
|
307
|
+
}): Promise<Artifact[]>;
|
|
308
|
+
/**
|
|
309
|
+
* Rename an artifact
|
|
310
|
+
*
|
|
311
|
+
* **What it does:** Changes the display name/title of an existing artifact. Works for all artifact
|
|
312
|
+
* types (quiz, flashcards, study guide, mind map, infographic, slide deck, report, audio, video).
|
|
313
|
+
*
|
|
314
|
+
* **Input:**
|
|
315
|
+
* - `artifactId` (string, required): The ID of the artifact to rename
|
|
316
|
+
* - Use the artifact ID from `create()` or `list()` for all artifact types
|
|
317
|
+
* - Audio and video artifacts have their own artifactId (not the notebook ID)
|
|
318
|
+
* - `newTitle` (string, required): The new title/name for the artifact
|
|
319
|
+
*
|
|
320
|
+
* **Output:** Returns the updated `Artifact` object with the new title.
|
|
321
|
+
*
|
|
322
|
+
* **Note:**
|
|
323
|
+
* - This only updates the title. To update other fields, use `update()`.
|
|
324
|
+
* - Works for all artifact types (quiz, flashcards, study guide, mind map, infographic, slide deck, report, audio, video)
|
|
325
|
+
*
|
|
326
|
+
* @param artifactId - The artifact ID (from create() or list())
|
|
327
|
+
* @param newTitle - New title
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* // Rename any artifact type
|
|
332
|
+
* const artifact = await client.artifacts.rename('artifact-id', 'My Updated Quiz');
|
|
333
|
+
* console.log(`Renamed to: ${artifact.title}`);
|
|
334
|
+
*
|
|
335
|
+
* // Rename audio artifact (use audioId from create() or list())
|
|
336
|
+
* const audio = await sdk.artifacts.audio.create('notebook-id');
|
|
337
|
+
* const renamed = await client.artifacts.rename(audio.audioId, 'My Audio Overview');
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
rename(artifactId: string, newTitle: string): Promise<Artifact>;
|
|
341
|
+
/**
|
|
342
|
+
* Delete an artifact
|
|
343
|
+
*
|
|
344
|
+
* **What it does:** Permanently removes an artifact from the notebook. Works for all artifact types
|
|
345
|
+
* (quiz, flashcards, study guide, mind map, infographic, slide deck, report, audio, video).
|
|
346
|
+
* This action cannot be undone.
|
|
347
|
+
*
|
|
348
|
+
* **Input:**
|
|
349
|
+
* - `artifactId` (string, required): The ID of the artifact to delete
|
|
350
|
+
* - Use the artifact ID from `create()` or `list()` for all artifact types
|
|
351
|
+
* - Audio and video artifacts have their own artifactId (not the notebook ID)
|
|
352
|
+
* - `notebookId` (string, optional): Optional notebook ID (helpful for audio/video artifacts if get() fails)
|
|
353
|
+
*
|
|
354
|
+
* **Output:** Returns `void` on success. Throws an error if deletion fails.
|
|
355
|
+
*
|
|
356
|
+
* **Note:**
|
|
357
|
+
* - Deletion is permanent and cannot be undone
|
|
358
|
+
* - Works for all artifact types (quiz, flashcards, study guide, mind map, infographic, slide deck, report, audio, video)
|
|
359
|
+
* - Audio and video artifacts use V5N4be RPC with `[[2], artifactId]` structure
|
|
360
|
+
* - Other artifacts use WxBZtb RPC with `[artifactId]` structure
|
|
361
|
+
*
|
|
362
|
+
* @param artifactId - The artifact ID (from create() or list())
|
|
363
|
+
* @param notebookId - Optional notebook ID (helpful for audio/video if get() needs it)
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```typescript
|
|
367
|
+
* // Delete any artifact type (recommended - automatically detects type)
|
|
368
|
+
* await client.artifacts.delete('artifact-id');
|
|
369
|
+
*
|
|
370
|
+
* // Delete with notebook ID (helpful if get() fails)
|
|
371
|
+
* await client.artifacts.delete('artifact-id', 'notebook-id');
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
delete(artifactId: string, notebookId?: string): Promise<void>;
|
|
375
|
+
/**
|
|
376
|
+
* Share an artifact
|
|
377
|
+
*
|
|
378
|
+
* **What it does:** Shares an artifact (or the notebook containing the artifact) with specific users
|
|
379
|
+
* or makes it publicly accessible via a shareable link. Works for all artifact types. Artifacts are
|
|
380
|
+
* shared at the notebook level, so sharing an artifact shares the entire notebook.
|
|
381
|
+
*
|
|
382
|
+
* **Input:**
|
|
383
|
+
* - `notebookId` (string, required): The ID of the notebook containing the artifact
|
|
384
|
+
* - `options` (object, optional): Sharing options:
|
|
385
|
+
* - `users` (array, optional): Array of users to share with:
|
|
386
|
+
* - `email` (string, required): User email address
|
|
387
|
+
* - `role` (number, required): User role - 2=editor, 3=viewer, 4=remove
|
|
388
|
+
* - `notify` (boolean, optional): Send notification to users (default: true, only used when users are provided)
|
|
389
|
+
* - `accessType` (number, optional): Access type - 1=anyone with link, 2=restricted (default: 2)
|
|
390
|
+
*
|
|
391
|
+
* **Output:** Returns a `ShareArtifactResult` object containing:
|
|
392
|
+
* - `shareUrl`: Shareable URL for the notebook
|
|
393
|
+
* - `success`: Whether the share operation succeeded
|
|
394
|
+
* - `notebookId`: The notebook ID that was shared
|
|
395
|
+
* - `accessType`: Access type (1=anyone with link, 2=restricted)
|
|
396
|
+
* - `isShared`: Whether the notebook is shared
|
|
397
|
+
* - `users`: Array of users with access (if users were shared)
|
|
398
|
+
*
|
|
399
|
+
* **Note:**
|
|
400
|
+
* - Artifacts are shared at the notebook level - sharing an artifact shares the entire notebook
|
|
401
|
+
* - Must provide either `users` array or `accessType=1` (anyone with link)
|
|
402
|
+
* - User roles: 2=editor, 3=viewer, 4=remove (removes user access)
|
|
403
|
+
*
|
|
404
|
+
* @param notebookId - The notebook ID containing the artifact
|
|
405
|
+
* @param options - Sharing options
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```typescript
|
|
409
|
+
* // Share with specific users
|
|
410
|
+
* const result = await client.artifacts.share('notebook-id', {
|
|
411
|
+
* users: [
|
|
412
|
+
* { email: 'user@example.com', role: 3 }, // viewer
|
|
413
|
+
* { email: 'editor@example.com', role: 2 } // editor
|
|
414
|
+
* ],
|
|
415
|
+
* notify: true
|
|
416
|
+
* });
|
|
417
|
+
* console.log(`Shared! URL: ${result.shareUrl}`);
|
|
418
|
+
*
|
|
419
|
+
* // Share publicly (anyone with link)
|
|
420
|
+
* const publicResult = await client.artifacts.share('notebook-id', {
|
|
421
|
+
* accessType: 1
|
|
422
|
+
* });
|
|
423
|
+
* console.log(`Public share URL: ${publicResult.shareUrl}`);
|
|
424
|
+
*
|
|
425
|
+
* // Remove user access
|
|
426
|
+
* await client.artifacts.share('notebook-id', {
|
|
427
|
+
* users: [{ email: 'user@example.com', role: 4 }] // remove
|
|
428
|
+
* });
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
share(notebookId: string, options?: ShareArtifactOptions): Promise<ShareArtifactResult>;
|
|
432
|
+
/**
|
|
433
|
+
* Get artifact details
|
|
434
|
+
*
|
|
435
|
+
* **What it does:** Retrieves detailed information about a specific artifact, including its
|
|
436
|
+
* current state, metadata, and content references.
|
|
437
|
+
*
|
|
438
|
+
* **Input:**
|
|
439
|
+
* - `artifactId` (string, required): The ID of the artifact to retrieve
|
|
440
|
+
* - Use the artifact ID from `create()` or `list()` for all artifact types
|
|
441
|
+
* - Audio and video artifacts have their own artifactId (not the notebook ID)
|
|
442
|
+
* - `notebookId` (string, optional): Optional notebook ID (helpful for audio/video if get() needs it)
|
|
443
|
+
* - `options` (object, optional): Additional options
|
|
444
|
+
* - For reports: `exportToDocs?: boolean` or `exportToSheets?: boolean` - Export report to Google Docs/Sheets and return URL
|
|
445
|
+
* - For slides: `downloadAs?: 'pdf' | 'png'` (default: 'pdf') and `outputPath: string` (required) - Download slides as PDF or PNG files
|
|
446
|
+
* - For videos: `outputPath: string` (required) - Download video as MP4 file
|
|
447
|
+
*
|
|
448
|
+
* **Output:** Returns an `Artifact` object containing:
|
|
449
|
+
* - `artifactId`: Unique identifier
|
|
450
|
+
* - `type`: Artifact type (QUIZ, FLASHCARDS, REPORT, MIND_MAP, INFOGRAPHIC, SLIDE_DECK, AUDIO, VIDEO, etc.)
|
|
451
|
+
* - `state`: Current state - check this to see if artifact is ready:
|
|
452
|
+
* - `CREATING`: Artifact is still being generated
|
|
453
|
+
* - `READY`: Artifact is complete and ready to use
|
|
454
|
+
* - `FAILED`: Artifact creation failed
|
|
455
|
+
* - `title`: Display name
|
|
456
|
+
* - `sourceIds`: Source IDs used in creation
|
|
457
|
+
* - `createdAt`, `updatedAt`: Timestamps
|
|
458
|
+
* - For QUIZ: Returns `Artifact + QuizData` (questions, options, correct answers, explanations)
|
|
459
|
+
* - For FLASHCARDS: Returns `Artifact + FlashcardData` (flashcards array, CSV, totalCards)
|
|
460
|
+
* - For AUDIO: Returns `Artifact + audioData` (base64 audio data)
|
|
461
|
+
* - For VIDEO: Downloads video (requires `outputPath` option) - returns `Artifact + { downloadPath: string }`
|
|
462
|
+
* - For SLIDE_DECK: Downloads slides (requires `outputPath` option) - returns `Artifact + { downloadPath: string, downloadFormat: 'pdf' | 'png' }`
|
|
463
|
+
* - For INFOGRAPHIC: Returns `Artifact + InfographicImageData`
|
|
464
|
+
* - For REPORT: Returns `Artifact + ReportContent` or `Artifact + { exportUrl: string }` if export options provided
|
|
465
|
+
* - For MIND_MAP: Returns `Artifact + { experimental: true }`
|
|
466
|
+
*
|
|
467
|
+
* **Next steps:**
|
|
468
|
+
* - Check `state` field - if `CREATING`, wait and poll again using `get()`
|
|
469
|
+
* - If `READY`, the full data is automatically included in the response
|
|
470
|
+
* - For reports with export options, the export URL is returned instead of content
|
|
471
|
+
*
|
|
472
|
+
* @param artifactId - The artifact ID
|
|
473
|
+
* @param notebookId - Optional notebook ID (for audio artifacts)
|
|
474
|
+
* @param options - Additional options (export options for reports)
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```typescript
|
|
478
|
+
* // Get artifact details
|
|
479
|
+
* const artifact = await client.artifacts.get('artifact-id', 'notebook-id');
|
|
480
|
+
*
|
|
481
|
+
* // Get quiz with full data
|
|
482
|
+
* const quiz = await client.artifacts.get('quiz-id', 'notebook-id');
|
|
483
|
+
* console.log(`Quiz has ${quiz.totalQuestions} questions`);
|
|
484
|
+
*
|
|
485
|
+
* // Get report and export to Google Docs
|
|
486
|
+
* const report = await client.artifacts.get('report-id', 'notebook-id', { exportToDocs: true });
|
|
487
|
+
* console.log('Google Docs URL:', report.exportUrl);
|
|
488
|
+
*
|
|
489
|
+
* // Get audio artifact (use audioId from create() or list())
|
|
490
|
+
* const audio = await sdk.artifacts.audio.create('notebook-id');
|
|
491
|
+
* const audioData = await client.artifacts.get(audio.audioId, 'notebook-id');
|
|
492
|
+
*
|
|
493
|
+
* // Download slide deck as PDF (default)
|
|
494
|
+
* const slides = await client.artifacts.get('slide-id', 'notebook-id', { outputPath: './downloads' });
|
|
495
|
+
* console.log('Slides saved to:', slides.downloadPath);
|
|
496
|
+
*
|
|
497
|
+
* // Download slide deck as PNG files
|
|
498
|
+
* const slidesPng = await client.artifacts.get('slide-id', 'notebook-id', { downloadAs: 'png', outputPath: './downloads' });
|
|
499
|
+
* console.log('PNG files saved to:', slidesPng.downloadPath);
|
|
500
|
+
*
|
|
501
|
+
* // Download video as MP4
|
|
502
|
+
* const video = await client.artifacts.get('video-id', 'notebook-id', { outputPath: './downloads' });
|
|
503
|
+
* console.log('Video saved to:', video.downloadPath);
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
get(artifactId: string, notebookId?: string, options?: {
|
|
507
|
+
exportToDocs?: boolean;
|
|
508
|
+
exportToSheets?: boolean;
|
|
509
|
+
} & GetSlideOptions & GetVideoOptions): Promise<Artifact | QuizData | FlashcardData | AudioArtifact | VideoArtifact | any>;
|
|
510
|
+
/**
|
|
511
|
+
* Create an artifact
|
|
512
|
+
*
|
|
513
|
+
* **What it does:** Creates a new artifact (quiz, flashcards, study guide, mind map, infographic,
|
|
514
|
+
* slide deck, report, audio overview, or video overview) from the sources in a notebook. The
|
|
515
|
+
* artifact generation process begins immediately but may take time to complete.
|
|
516
|
+
*
|
|
517
|
+
* **⚠️ IMPORTANT: Sources Required**
|
|
518
|
+
* - **The notebook must have at least one source** before creating artifacts
|
|
519
|
+
* - `sourceIds` (optional): If provided, only those sources will be used. If omitted or empty, **all sources in the notebook** will be used automatically
|
|
520
|
+
* - This is a convenience feature - the SDK automatically fetches all sources when `sourceIds` is omitted
|
|
521
|
+
* - Provide `sourceIds` as an array of source ID strings (e.g., `['source-id-1', 'source-id-2']`) to use only specific sources
|
|
522
|
+
* - Use `sources.list(notebookId)` to get available source IDs if you want to filter
|
|
523
|
+
*
|
|
524
|
+
* **Input:**
|
|
525
|
+
* - `notebookId` (string, required): The notebook containing the sources to use
|
|
526
|
+
* - `type` (ArtifactType, required): The type of artifact to create:
|
|
527
|
+
* - `ArtifactType.QUIZ` - Multiple choice questions with explanations
|
|
528
|
+
* - `ArtifactType.FLASHCARDS` - Question/answer pairs for memorization
|
|
529
|
+
* - `ArtifactType.REPORT` - Comprehensive report/document
|
|
530
|
+
* - `ArtifactType.MIND_MAP` - Visual concept mapping
|
|
531
|
+
* - `ArtifactType.INFOGRAPHIC` - Visual data summary
|
|
532
|
+
* - `ArtifactType.SLIDE_DECK` - Presentation slides
|
|
533
|
+
* - `ArtifactType.AUDIO` - Audio overview (podcast-style)
|
|
534
|
+
* - `ArtifactType.VIDEO` - Video overview
|
|
535
|
+
* - `options` (CreateArtifactOptions, optional): Creation parameters:
|
|
536
|
+
* - `title` (string, optional): Display name for the artifact
|
|
537
|
+
* - `instructions` (string, optional): Custom instructions for generation (e.g., "Focus on key concepts")
|
|
538
|
+
* - `sourceIds` (string[], optional): Source IDs to use for artifact generation (e.g., `['source-id-1', 'source-id-2']`)
|
|
539
|
+
* - If provided: Only the specified sources will be used
|
|
540
|
+
* - If omitted or empty: **All sources in the notebook** will be used automatically (SDK convenience feature)
|
|
541
|
+
* - The notebook must have at least one source before creating artifacts
|
|
542
|
+
* - `customization` (object, optional): Type-specific customization options (see below)
|
|
543
|
+
*
|
|
544
|
+
* **Customization Options by Type:**
|
|
545
|
+
*
|
|
546
|
+
* **Note:** Customization is only supported for the following artifact types:
|
|
547
|
+
* Quiz, Flashcards, Slide Deck, Infographic, Audio, Video.
|
|
548
|
+
*
|
|
549
|
+
* Other artifact types (Mind Map, Report) do not support customization.
|
|
550
|
+
*
|
|
551
|
+
* **Quiz (`QuizCustomization`):**
|
|
552
|
+
* - `customization.numberOfQuestions` (1 | 2 | 3, optional): Number of questions
|
|
553
|
+
* - `1` = Fewer questions
|
|
554
|
+
* - `2` = Standard (default)
|
|
555
|
+
* - `3` = More questions
|
|
556
|
+
* - `customization.difficulty` (1 | 2 | 3, optional): Difficulty level
|
|
557
|
+
* - `1` = Easy
|
|
558
|
+
* - `2` = Medium (default)
|
|
559
|
+
* - `3` = Hard
|
|
560
|
+
* - `customization.language` (string, optional): Language code (use NotebookLMLanguage enum or ISO 639-1 code, e.g., 'en', 'hi', 'ta')
|
|
561
|
+
* - NotebookLM supports 80+ languages for artifacts
|
|
562
|
+
* - Use `NotebookLMLanguage` enum for type safety, or pass ISO 639-1 codes directly
|
|
563
|
+
* - `instructions` (string, optional): Custom instructions for question focus
|
|
564
|
+
*
|
|
565
|
+
* **Flashcards (`FlashcardCustomization`):**
|
|
566
|
+
* - `customization.numberOfCards` (1 | 2 | 3, optional): Number of flashcard pairs
|
|
567
|
+
* - `1` = Fewer cards
|
|
568
|
+
* - `2` = Standard (default)
|
|
569
|
+
* - `3` = More cards
|
|
570
|
+
* - `customization.difficulty` (1 | 2 | 3, optional): Difficulty level
|
|
571
|
+
* - `1` = Easy
|
|
572
|
+
* - `2` = Medium (default)
|
|
573
|
+
* - `3` = Hard
|
|
574
|
+
* - `customization.language` (string, optional): Language code (use NotebookLMLanguage enum or ISO 639-1 code, e.g., 'en', 'hi', 'ta')
|
|
575
|
+
* - NotebookLM supports 80+ languages for artifacts
|
|
576
|
+
* - Use `NotebookLMLanguage` enum for type safety, or pass ISO 639-1 codes directly
|
|
577
|
+
* - `instructions` (string, optional): Custom instructions for topic focus
|
|
578
|
+
*
|
|
579
|
+
* **Slide Deck (`SlideDeckCustomization`):**
|
|
580
|
+
* - `customization.format` (2 | 3, optional): Presentation format
|
|
581
|
+
* - `2` = Presenter slides (default)
|
|
582
|
+
* - `3` = Detailed deck
|
|
583
|
+
* - `customization.language` (string, optional): Language code (use NotebookLMLanguage enum or ISO 639-1 code, e.g., 'en')
|
|
584
|
+
* - NotebookLM supports 80+ languages for slide decks
|
|
585
|
+
* - `customization.length` (1 | 2 | 3, optional): Length preference
|
|
586
|
+
* - `1` = Short
|
|
587
|
+
* - `2` = Default (default)
|
|
588
|
+
* - `3` = Long
|
|
589
|
+
* - `instructions` (string, optional): Used as description/theme for the presentation
|
|
590
|
+
*
|
|
591
|
+
* **Infographic (`InfographicCustomization`):**
|
|
592
|
+
* - `customization.language` (string, optional): Language code (use NotebookLMLanguage enum or ISO 639-1 code, e.g., 'en', 'hi', 'ta')
|
|
593
|
+
* - NotebookLM supports 80+ languages for artifacts
|
|
594
|
+
* - Use `NotebookLMLanguage` enum for type safety, or pass ISO 639-1 codes directly
|
|
595
|
+
* - `customization.orientation` (1 | 2 | 3, optional): Visual orientation/style
|
|
596
|
+
* - `1` = Landscape (default)
|
|
597
|
+
* - `2` = Portrait
|
|
598
|
+
* - `3` = Square
|
|
599
|
+
* - `customization.levelOfDetail` (1 | 2 | 3, optional): Level of detail
|
|
600
|
+
* - `1` = Concise
|
|
601
|
+
* - `2` = Standard (default)
|
|
602
|
+
* - `3` = Detailed
|
|
603
|
+
*
|
|
604
|
+
* **Audio Overview (`AudioCustomization`):**
|
|
605
|
+
* - `customization.format` (0 | 1 | 2 | 3, optional): Audio format type
|
|
606
|
+
* - `0` = Deep dive (default)
|
|
607
|
+
* - `1` = Brief
|
|
608
|
+
* - `2` = Critique
|
|
609
|
+
* - `3` = Debate
|
|
610
|
+
* - `customization.language` (string, optional): Language code (e.g., 'en', 'hi')
|
|
611
|
+
* - `customization.length` (1 | 2 | 3, optional): Length preference
|
|
612
|
+
* - `1` = Short
|
|
613
|
+
* - `2` = Default (default)
|
|
614
|
+
* - `3` = Long
|
|
615
|
+
* - `instructions` (string, optional): Custom instructions for content and style
|
|
616
|
+
*
|
|
617
|
+
* **Video Overview (`VideoCustomization`):**
|
|
618
|
+
* - `customization.format` (1 | 2, optional): Video format
|
|
619
|
+
* - `1` = Explainer (default)
|
|
620
|
+
* - `2` = Brief
|
|
621
|
+
* - `customization.language` (string, optional): Language code (use NotebookLMLanguage enum or ISO 639-1 code, default: 'en')
|
|
622
|
+
* - NotebookLM supports 80+ languages for video overviews
|
|
623
|
+
* - `customization.visualStyle` (0 | 1 | 2 | 3 | 4 | 5, optional): Visual style
|
|
624
|
+
* - `0` = Auto-select (default)
|
|
625
|
+
* - `1` = Custom
|
|
626
|
+
* - `2` = Classic
|
|
627
|
+
* - `3` = Whiteboard
|
|
628
|
+
* - `4` = Kawaii
|
|
629
|
+
* - `5` = Anime
|
|
630
|
+
* - `sourceIds` (string[], optional): Specify sources to include. If omitted, all sources in the notebook will be used
|
|
631
|
+
* - `instructions` (string, optional): Detailed instructions for video content and style
|
|
632
|
+
*
|
|
633
|
+
* **Mind Map, Report:**
|
|
634
|
+
* - Customization is NOT supported for these artifact types
|
|
635
|
+
* - Use `title` and `instructions` only
|
|
636
|
+
*
|
|
637
|
+
* **Output:** Returns an `Artifact` object with:
|
|
638
|
+
* - `artifactId`: Unique identifier (save this for later operations)
|
|
639
|
+
* - `type`: The artifact type you specified
|
|
640
|
+
* - `state`: Usually `CREATING` initially (check with `get()` to see when it becomes `READY`)
|
|
641
|
+
* - `title`: The title (if provided)
|
|
642
|
+
* - `sourceIds`: Sources used for generation
|
|
643
|
+
* - `createdAt`, `updatedAt`: Timestamps
|
|
644
|
+
*
|
|
645
|
+
* **Next steps:**
|
|
646
|
+
* 1. **Poll for completion:** Use `get(artifactId)` periodically to check if `state === ArtifactState.READY`
|
|
647
|
+
* 2. **Download content:** Once ready, use `download(artifactId)` to get the actual data:
|
|
648
|
+
* - Quizzes: Returns `QuizData` with questions, options, correct answers, explanations
|
|
649
|
+
* - Flashcards: Returns `FlashcardData` with CSV string and parsed flashcards
|
|
650
|
+
* - Audio: Returns `AudioArtifact` with base64 audio data (save to file)
|
|
651
|
+
* - Video: Returns `VideoArtifact` with video data
|
|
652
|
+
* - Others: Returns artifact data structure
|
|
653
|
+
* 3. **List artifacts:** Use `list(notebookId)` to see all artifacts in the notebook
|
|
654
|
+
* 4. **Manage:** Use `rename()`, `update()`, or `delete()` as needed
|
|
655
|
+
*
|
|
656
|
+
* **Quota:** Creation consumes quota for certain types (quizzes, flashcards, audio, video).
|
|
657
|
+
* Quota is checked before creation and recorded after success.
|
|
658
|
+
*
|
|
659
|
+
* @param notebookId - The notebook ID
|
|
660
|
+
* @param type - The artifact type (use ArtifactType enum)
|
|
661
|
+
* @param options - Creation options
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* import { ArtifactType, ArtifactState } from 'notebooklm-kit';
|
|
666
|
+
*
|
|
667
|
+
* // Using sub-services (recommended)
|
|
668
|
+
* const quiz = await client.artifacts.quiz.create('notebook-id', {
|
|
669
|
+
* title: 'Chapter 1 Quiz',
|
|
670
|
+
* instructions: 'Create 10 multiple choice questions covering key concepts',
|
|
671
|
+
* customization: {
|
|
672
|
+
* numberOfQuestions: 3,
|
|
673
|
+
* difficulty: 2,
|
|
674
|
+
* language: 'en',
|
|
675
|
+
* },
|
|
676
|
+
* });
|
|
677
|
+
*
|
|
678
|
+
* const flashcards = await client.artifacts.flashcard.create('notebook-id', {
|
|
679
|
+
* instructions: 'Focus on key terminology and definitions',
|
|
680
|
+
* });
|
|
681
|
+
*
|
|
682
|
+
* const video = await client.artifacts.video.create('notebook-id', {
|
|
683
|
+
* instructions: 'Create an engaging video overview',
|
|
684
|
+
* sourceIds: ['source-id-1', 'source-id-2'],
|
|
685
|
+
* customization: {
|
|
686
|
+
* format: 1,
|
|
687
|
+
* visualStyle: 0,
|
|
688
|
+
* },
|
|
689
|
+
* });
|
|
690
|
+
*
|
|
691
|
+
* // Using main create() method (also supported)
|
|
692
|
+
* const quiz2 = await client.artifacts.create('notebook-id', ArtifactType.QUIZ, {
|
|
693
|
+
* title: 'Chapter 1 Quiz',
|
|
694
|
+
* instructions: 'Create 10 multiple choice questions covering key concepts',
|
|
695
|
+
* });
|
|
696
|
+
* console.log(`Quiz ID: ${quiz2.artifactId}, State: ${quiz2.state}`);
|
|
697
|
+
*
|
|
698
|
+
* // Create quiz with customization
|
|
699
|
+
* import { NotebookLMLanguage } from 'notebooklm-kit';
|
|
700
|
+
*
|
|
701
|
+
* const quiz = await client.artifacts.create('notebook-id', ArtifactType.QUIZ, {
|
|
702
|
+
* title: 'Chapter 1 Quiz',
|
|
703
|
+
* instructions: 'Focus on key concepts',
|
|
704
|
+
* customization: {
|
|
705
|
+
* numberOfQuestions: 3, // More questions
|
|
706
|
+
* difficulty: 3, // Hard
|
|
707
|
+
* language: NotebookLMLanguage.ENGLISH, // or 'en'
|
|
708
|
+
* },
|
|
709
|
+
* });
|
|
710
|
+
*
|
|
711
|
+
* // Create flashcards with customization
|
|
712
|
+
* const flashcards = await client.artifacts.create('notebook-id', ArtifactType.FLASHCARDS, {
|
|
713
|
+
* instructions: 'Focus on key terminology',
|
|
714
|
+
* customization: {
|
|
715
|
+
* numberOfCards: 2, // Standard
|
|
716
|
+
* difficulty: 2, // Medium
|
|
717
|
+
* language: NotebookLMLanguage.HINDI, // or 'hi'
|
|
718
|
+
* },
|
|
719
|
+
* });
|
|
720
|
+
*
|
|
721
|
+
* // Create slide deck with customization
|
|
722
|
+
* const slides = await client.artifacts.create('notebook-id', ArtifactType.SLIDE_DECK, {
|
|
723
|
+
* title: 'Quarterly Report',
|
|
724
|
+
* instructions: 'Focus on revenue and growth metrics',
|
|
725
|
+
* customization: {
|
|
726
|
+
* format: 3, // Detailed deck
|
|
727
|
+
* language: NotebookLMLanguage.SPANISH, // or 'es'
|
|
728
|
+
* length: 2, // Default
|
|
729
|
+
* },
|
|
730
|
+
* });
|
|
731
|
+
*
|
|
732
|
+
* // Create infographic with customization
|
|
733
|
+
* const infographic = await client.artifacts.create('notebook-id', ArtifactType.INFOGRAPHIC, {
|
|
734
|
+
* customization: {
|
|
735
|
+
* language: NotebookLMLanguage.TAMIL, // or 'ta'
|
|
736
|
+
* orientation: 1, // Landscape
|
|
737
|
+
* levelOfDetail: 2, // Standard
|
|
738
|
+
* },
|
|
739
|
+
* });
|
|
740
|
+
*
|
|
741
|
+
* // Create audio overview with customization
|
|
742
|
+
* const audio = await client.artifacts.create('notebook-id', ArtifactType.AUDIO, {
|
|
743
|
+
* instructions: 'Create an engaging podcast summary',
|
|
744
|
+
* customization: {
|
|
745
|
+
* format: 0, // Deep dive
|
|
746
|
+
* language: NotebookLMLanguage.FRENCH, // or 'fr' - supports 80+ languages
|
|
747
|
+
* length: 2, // Default
|
|
748
|
+
* },
|
|
749
|
+
* });
|
|
750
|
+
*
|
|
751
|
+
* // Create video overview with customization
|
|
752
|
+
* const video = await client.artifacts.create('notebook-id', ArtifactType.VIDEO, {
|
|
753
|
+
* instructions: 'Create a video overview focusing on the main research findings',
|
|
754
|
+
* sourceIds: ['source-id-1', 'source-id-2'],
|
|
755
|
+
* customization: {
|
|
756
|
+
* format: 1, // Explainer
|
|
757
|
+
* language: NotebookLMLanguage.JAPANESE, // or 'ja' - supports 80+ languages
|
|
758
|
+
* visualStyle: 0, // Auto-select
|
|
759
|
+
* },
|
|
760
|
+
* });
|
|
761
|
+
*
|
|
762
|
+
* // Create report (uses all sources)
|
|
763
|
+
* const report = await client.artifacts.report.create('notebook-id', {
|
|
764
|
+
* title: 'Final Report',
|
|
765
|
+
* instructions: 'Focus on key concepts, formulas, and important dates',
|
|
766
|
+
* });
|
|
767
|
+
*
|
|
768
|
+
* // Create report from specific sources
|
|
769
|
+
* const reportFromSelected = await client.artifacts.report.create('notebook-id', {
|
|
770
|
+
* title: 'Chapter 1-3 Report',
|
|
771
|
+
* instructions: 'Focus on chapters 1-3',
|
|
772
|
+
* sourceIds: ['source-id-1', 'source-id-2', 'source-id-3'],
|
|
773
|
+
* });
|
|
774
|
+
*
|
|
775
|
+
* // Poll until ready, then download
|
|
776
|
+
* let artifact = quiz;
|
|
777
|
+
* while (artifact.state === ArtifactState.CREATING) {
|
|
778
|
+
* await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
|
|
779
|
+
* artifact = await client.artifacts.get(quiz.artifactId);
|
|
780
|
+
* }
|
|
781
|
+
*
|
|
782
|
+
* if (artifact.state === ArtifactState.READY) {
|
|
783
|
+
* const quizData = await client.artifacts.download(quiz.artifactId);
|
|
784
|
+
* console.log(`Quiz has ${quizData.totalQuestions} questions`);
|
|
785
|
+
* }
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
create(notebookId: string, type: ArtifactType, options?: CreateArtifactOptions): Promise<Artifact>;
|
|
789
|
+
/**
|
|
790
|
+
* Download artifact data and save to file
|
|
791
|
+
*
|
|
792
|
+
* **What it does:** Downloads the actual content/data for artifacts and saves it to the specified
|
|
793
|
+
* folder location. The file format and naming depend on the artifact type. Use this after an
|
|
794
|
+
* artifact's state is `READY`.
|
|
795
|
+
*
|
|
796
|
+
* **Input:**
|
|
797
|
+
* - `artifactId` (string, required): The ID of the artifact to download
|
|
798
|
+
* - Use the artifact ID from `create()` or `list()` for all artifact types
|
|
799
|
+
* - Audio and video artifacts have their own artifactId (not the notebook ID)
|
|
800
|
+
* - `folderPath` (string, required): Folder path where the file should be saved
|
|
801
|
+
* - On Node.js: Absolute or relative file system path (e.g., `./downloads` or `/tmp/artifacts`)
|
|
802
|
+
* - On Browser: File name only (file will be downloaded via browser download)
|
|
803
|
+
* - `notebookId` (string, optional): Optional notebook ID (helpful for audio/video if download needs it)
|
|
804
|
+
*
|
|
805
|
+
* **Output:** Returns the path/name of the saved file and the data structure:
|
|
806
|
+
* ```typescript
|
|
807
|
+
* {
|
|
808
|
+
* filePath: string, // Path/filename where the file was saved
|
|
809
|
+
* data: QuizData | FlashcardData | AudioArtifact | VideoArtifact | any // The artifact data
|
|
810
|
+
* }
|
|
811
|
+
* ```
|
|
812
|
+
*
|
|
813
|
+
* **File Formats by Type:**
|
|
814
|
+
*
|
|
815
|
+
* **Audio:**
|
|
816
|
+
* - Format: MP3 audio file
|
|
817
|
+
* - Filename: `audio_<artifactId>.mp3` (or based on artifact title if available)
|
|
818
|
+
* - Content: Base64 decoded audio data saved as binary
|
|
819
|
+
*
|
|
820
|
+
* **Video:**
|
|
821
|
+
* - ⚠️ **Experimental**: Download not implemented. Use `get()` to retrieve the video URL.
|
|
822
|
+
* - The video URL is available in `artifact.url` field from `get()` method.
|
|
823
|
+
*
|
|
824
|
+
* **Slide Deck:**
|
|
825
|
+
* - Format: PDF file (by default) or PNG files in subfolder
|
|
826
|
+
* - Filename: `<artifact-title>.pdf` or `<artifact-title>/slide_*.png`
|
|
827
|
+
* - Content: Slides downloaded as PDF or individual PNG images
|
|
828
|
+
* - Uses Playwright for authentication and download
|
|
829
|
+
*
|
|
830
|
+
* **Quiz:**
|
|
831
|
+
* - Format: JSON file
|
|
832
|
+
* - Filename: `quiz_<artifactId>_<timestamp>.json`
|
|
833
|
+
* - Content: Complete artifact data including questions, options, correct answers, explanations, and metadata
|
|
834
|
+
*
|
|
835
|
+
* **Flashcards:**
|
|
836
|
+
* - Format: JSON file
|
|
837
|
+
* - Filename: `flashcard_<artifactId>_<timestamp>.json`
|
|
838
|
+
* - Content: Complete artifact data including flashcards array, CSV, totalCards, and metadata
|
|
839
|
+
*
|
|
840
|
+
* **Mind Map:**
|
|
841
|
+
* - Format: JSON file
|
|
842
|
+
* - Filename: `mindmap_<artifactId>.json`
|
|
843
|
+
* - Content: Structured mind map data (nodes, connections, etc.)
|
|
844
|
+
*
|
|
845
|
+
* **Infographic:**
|
|
846
|
+
* - Format: JSON or image file (depends on backend)
|
|
847
|
+
* - Filename: `infographic_<artifactId>.json` or `.png`/`.jpg`
|
|
848
|
+
* - Content: Infographic data or image file
|
|
849
|
+
*
|
|
850
|
+
* **Study Guide / Report:**
|
|
851
|
+
* - Format: JSON file
|
|
852
|
+
* - Filename: `studyguide_<artifactId>.json` or `report_<artifactId>.json`
|
|
853
|
+
* - Content: Structured document data
|
|
854
|
+
*
|
|
855
|
+
* **Important:**
|
|
856
|
+
* - Ensure artifact state is `READY` before downloading (check with `get()`)
|
|
857
|
+
* - Downloading a `CREATING` artifact may return incomplete data
|
|
858
|
+
* - For audio/video/slides, large files may take time to download
|
|
859
|
+
* - On Node.js: The folder must exist or be creatable
|
|
860
|
+
* - On Browser: The file will trigger a browser download with the specified filename
|
|
861
|
+
*
|
|
862
|
+
* @param artifactId - The artifact ID
|
|
863
|
+
* @param folderPath - Folder path where to save the file
|
|
864
|
+
* @param notebookId - Optional notebook ID (for audio artifacts)
|
|
865
|
+
* @returns Object with filePath and data
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* ```typescript
|
|
869
|
+
* import { ArtifactState } from 'notebooklm-kit';
|
|
870
|
+
*
|
|
871
|
+
* // Download quiz and save as JSON
|
|
872
|
+
* const artifact = await client.artifacts.get('quiz-id');
|
|
873
|
+
* if (artifact.state === ArtifactState.READY) {
|
|
874
|
+
* const result = await client.artifacts.download('quiz-id', './downloads');
|
|
875
|
+
* console.log(`Quiz saved to: ${result.filePath}`);
|
|
876
|
+
* console.log(`Quiz has ${result.data.totalQuestions} questions`);
|
|
877
|
+
* }
|
|
878
|
+
*
|
|
879
|
+
* // Download flashcards and save as CSV
|
|
880
|
+
* const flashcardResult = await client.artifacts.download('flashcard-id', './downloads');
|
|
881
|
+
* console.log(`Flashcards saved to: ${flashcardResult.filePath}`);
|
|
882
|
+
*
|
|
883
|
+
* // Download audio and save as MP3 (use audioId from create() or list())
|
|
884
|
+
* const audio = await sdk.artifacts.audio.create('notebook-id');
|
|
885
|
+
* const audioResult = await client.artifacts.download(audio.audioId, './downloads', 'notebook-id');
|
|
886
|
+
* console.log(`Audio saved to: ${audioResult.filePath}`);
|
|
887
|
+
*
|
|
888
|
+
* // Video: Download not available (experimental)
|
|
889
|
+
* // Use get() to retrieve URLs instead:
|
|
890
|
+
* const video = await client.artifacts.get('video-id', 'notebook-id');
|
|
891
|
+
* console.log('Video URL:', video.url);
|
|
892
|
+
*
|
|
893
|
+
* // Slides: Download using download() or get() with downloadAs option
|
|
894
|
+
* const slidesResult = await client.artifacts.download('slide-id', './downloads', 'notebook-id');
|
|
895
|
+
* console.log('Slides saved to:', slidesResult.filePath);
|
|
896
|
+
*
|
|
897
|
+
* // Download mind map
|
|
898
|
+
* const mindmapResult = await client.artifacts.download('mindmap-id', './downloads');
|
|
899
|
+
* console.log(`Mind map saved to: ${mindmapResult.filePath}`);
|
|
900
|
+
*
|
|
901
|
+
* // Download infographic
|
|
902
|
+
* const infographicResult = await client.artifacts.download('infographic-id', './downloads');
|
|
903
|
+
* console.log(`Infographic saved to: ${infographicResult.filePath}`);
|
|
904
|
+
*
|
|
905
|
+
* // Download study guide
|
|
906
|
+
* const guideResult = await client.artifacts.download('guide-id', './downloads');
|
|
907
|
+
* console.log(`Study guide saved to: ${guideResult.filePath}`);
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
910
|
+
download(artifactId: string, folderPath: string, notebookId?: string, artifactType?: ArtifactType): Promise<{
|
|
911
|
+
filePath: string;
|
|
912
|
+
data: QuizData | FlashcardData | AudioArtifact | VideoArtifact | any;
|
|
913
|
+
}>;
|
|
914
|
+
private getApiTypeNumber;
|
|
915
|
+
/**
|
|
916
|
+
* Maps API response type numbers to ArtifactType enum (for parsing list/get responses)
|
|
917
|
+
* Note: Both Quiz and Flashcards use type 4 in API responses, so we need to differentiate
|
|
918
|
+
* them by looking at the customization data structure or other fields.
|
|
919
|
+
*/
|
|
920
|
+
private mapApiTypeToArtifactType;
|
|
921
|
+
/**
|
|
922
|
+
* Create artifacts using R7cb6c RPC (Quiz, Slides, Infographics, Video)
|
|
923
|
+
*/
|
|
924
|
+
private createR7cb6cArtifact;
|
|
925
|
+
/**
|
|
926
|
+
* Parse video creation response into VideoOverview
|
|
927
|
+
* Used by createVideo method to return VideoOverview instead of Artifact
|
|
928
|
+
*/
|
|
929
|
+
private parseCreateResponse;
|
|
930
|
+
/**
|
|
931
|
+
* Maps length string to number
|
|
932
|
+
*/
|
|
933
|
+
private mapLengthToNumber;
|
|
934
|
+
/**
|
|
935
|
+
* Create mind map using yyryJe RPC (RPC_ACT_ON_SOURCES)
|
|
936
|
+
* Structure from RPC: [[[sourceId1]], [[sourceId2]], ...], null, null, null, null, ["interactive_mindmap", [["[CONTEXT]", ""]], "", null, [2, null, [1]]]
|
|
937
|
+
*/
|
|
938
|
+
private createMindMap;
|
|
939
|
+
private createStandardArtifact;
|
|
940
|
+
private createAudio;
|
|
941
|
+
private downloadAudio;
|
|
942
|
+
private getQuotaType;
|
|
943
|
+
/**
|
|
944
|
+
* Helper function to fetch all source IDs from a notebook
|
|
945
|
+
* Used when sourceIds is omitted/empty - automatically uses all sources
|
|
946
|
+
*/
|
|
947
|
+
private getAllSourceIds;
|
|
948
|
+
private parseListResponse;
|
|
949
|
+
private parseArtifactResponse;
|
|
950
|
+
private parseArtifactData;
|
|
951
|
+
/**
|
|
952
|
+
* Parse Mind Map creation response
|
|
953
|
+
* Structure: [jsonString, null, [artifactId, ...otherIds...]]
|
|
954
|
+
* Example: ["{\n\"name\": \"...\",\n\"children\": [...]}", null, ["id1", "id2", 123]]
|
|
955
|
+
*/
|
|
956
|
+
private parseMindMapResponse;
|
|
957
|
+
private parseAudioCreateResponse;
|
|
958
|
+
private parseAudioResponse;
|
|
959
|
+
private parseVideoCreateResponse;
|
|
960
|
+
private parseDownloadResponse;
|
|
961
|
+
/**
|
|
962
|
+
* Parse quiz data from RPC response
|
|
963
|
+
*/
|
|
964
|
+
private parseQuizData;
|
|
965
|
+
/**
|
|
966
|
+
* Parse flashcard data from RPC response
|
|
967
|
+
* BnLyuf (GET_ARTIFACT) should return CSV data for flashcards
|
|
968
|
+
*/
|
|
969
|
+
private parseFlashcardData;
|
|
970
|
+
/**
|
|
971
|
+
* Parse a CSV line handling quoted fields properly
|
|
972
|
+
*/
|
|
973
|
+
private parseCSVLine;
|
|
974
|
+
/**
|
|
975
|
+
* Save artifact data to file based on artifact type
|
|
976
|
+
* Handles both Node.js (fs) and browser (Blob) environments
|
|
977
|
+
*/
|
|
978
|
+
private saveArtifactToFile;
|
|
979
|
+
/**
|
|
980
|
+
* Convert base64 string to Uint8Array
|
|
981
|
+
*/
|
|
982
|
+
private base64ToUint8Array;
|
|
983
|
+
/**
|
|
984
|
+
* Join path components (works in both Node.js and browser)
|
|
985
|
+
*/
|
|
986
|
+
private joinPath;
|
|
987
|
+
/**
|
|
988
|
+
* Write file (handles both Node.js and browser)
|
|
989
|
+
*/
|
|
990
|
+
private writeFile;
|
|
991
|
+
}
|
|
992
|
+
export declare function downloadAudioFile(rpc: RPCClient, audioId: string, notebookId?: string): Promise<{
|
|
993
|
+
audioData: Uint8Array;
|
|
994
|
+
audioUrl: string | null;
|
|
995
|
+
saveToFile: (path: string) => Promise<void>;
|
|
996
|
+
}>;
|
|
997
|
+
export declare function fetchQuizData(rpc: RPCClient, quizId: string, notebookId?: string): Promise<QuizData>;
|
|
998
|
+
export declare function fetchFlashcardData(rpc: RPCClient, flashcardId: string, notebookId?: string): Promise<ParsedFlashcardData>;
|
|
999
|
+
export declare function fetchInfographic(rpc: RPCClient, infographicId: string, notebookId?: string, options?: FetchInfographicOptions): Promise<InfographicImageData>;
|
|
1000
|
+
export declare function downloadSlidesFile(rpc: RPCClient, slideId: string, notebookId: string, options?: DownloadSlidesOptions): Promise<{
|
|
1001
|
+
slidesData: Uint8Array;
|
|
1002
|
+
pdfUrl: string;
|
|
1003
|
+
saveToFile: (path: string) => Promise<void>;
|
|
1004
|
+
}>;
|
|
1005
|
+
export declare function createReport(rpc: RPCClient, notebookId: string, options?: CreateReportOptions): Promise<{
|
|
1006
|
+
artifactId: string;
|
|
1007
|
+
state: ArtifactState;
|
|
1008
|
+
title?: string;
|
|
1009
|
+
}>;
|
|
1010
|
+
export declare function reportToDocs(rpc: RPCClient, reportId: string, notebookId: string, title?: string): Promise<string>;
|
|
1011
|
+
export declare function reportToSheets(rpc: RPCClient, reportId: string, notebookId: string, title?: string): Promise<string>;
|
|
1012
|
+
export declare function getReportContent(rpc: RPCClient, reportId: string, notebookId: string): Promise<ReportContent>;
|
|
1013
|
+
export declare function formatReportAsMarkdown(report: ReportContent): string;
|
|
1014
|
+
export declare function formatReportAsText(report: ReportContent): string;
|
|
1015
|
+
export declare function formatReportAsHTML(report: ReportContent): string;
|
|
1016
|
+
export declare function formatReportAsJSON(report: ReportContent): string;
|
|
1017
|
+
//# sourceMappingURL=artifacts.d.ts.map
|