notebooklm-sdk 0.3.3 → 0.3.4

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/dist/index.d.cts CHANGED
@@ -402,6 +402,12 @@ interface DataTableContent {
402
402
  headers: string[];
403
403
  rows: string[][];
404
404
  }
405
+ interface PollUntilReadyOptions {
406
+ timeoutSecs?: number;
407
+ intervalSecs?: number;
408
+ onTick?: (status: GenerationStatus) => void | Promise<void>;
409
+ signal?: AbortSignal;
410
+ }
405
411
  type ReportFormat = "briefing_doc" | "study_guide" | "blog_post" | "custom";
406
412
  interface CreateReportOptions {
407
413
  format?: ReportFormat;
@@ -439,6 +445,9 @@ declare class ArtifactsAPI {
439
445
  createMindMap(notebookId: string, sourceIds?: string[]): Promise<Note>;
440
446
  /** Poll until artifact reaches completed/failed status. */
441
447
  waitUntilReady(notebookId: string, artifactId: string, timeout?: number, pollInterval?: number): Promise<Artifact>;
448
+ /** Poll until artifact is fully ready, with optional progress hooks and cancellation. */
449
+ pollUntilReady(notebookId: string, artifactId: string, opts?: PollUntilReadyOptions): Promise<Artifact>;
450
+ private throwIfAborted;
442
451
  /** Get the current status of a generated artifact without waiting. */
443
452
  pollStatus(notebookId: string, artifactId: string): Promise<GenerationStatus>;
444
453
  /** Download audio content as a Buffer. */
@@ -682,4 +691,4 @@ declare class NotebookLMClient {
682
691
  refreshTokens(): Promise<void>;
683
692
  }
684
693
 
685
- export { type AddSourceOptions, type Artifact, type ArtifactStatus, type ArtifactType, ArtifactTypeCode, ArtifactsAPI, type AskOptions, type AskResult, AudioFormat, type AudioFormatValue, AudioLength, type AudioLengthValue, AuthTokens, ChatAPI, ChatGoal, type ChatGoalValue, ChatMode, type ChatModeValue, type ChatReference, ChatResponseLength, type ChatResponseLengthValue, type ClientOptions, ConnectOptions, type ConversationTurn, type CreateAudioOptions, type CreateDataTableOptions, type CreateInfographicOptions, type CreateQuizOptions, type CreateReportOptions, type CreateSlideDeckOptions, type CreateVideoOptions, type DataTableContent, DriveMimeType, type DriveMimeTypeValue, ExportType, type ExportTypeValue, type GenerationStatus, type ImportedSource, InfographicDetail, type InfographicDetailValue, InfographicOrientation, type InfographicOrientationValue, InfographicStyle, type InfographicStyleValue, type Note, type Notebook, type NotebookDescription, NotebookLMClient, type NotebookMetadata, NotebooksAPI, NotesAPI, QuizDifficulty, type QuizDifficultyValue, QuizQuantity, type QuizQuantityValue, RPCMethod, type RPCMethodId, type ReportFormat, type ReportSuggestion, ResearchAPI, type ResearchResult, type ResearchSource, type ResearchTask, SettingsAPI, ShareAccess, type ShareAccessValue, SharePermission, type SharePermissionValue, type ShareStatus, ShareViewLevel, type ShareViewLevelValue, type SharedUser, SharingAPI, SlideDeckFormat, type SlideDeckFormatValue, SlideDeckLength, type SlideDeckLengthValue, type Source, type SourceFulltext, type SourceGuide, type SourceStatus, type SourceSummary, type SourceType, SourcesAPI, type SuggestedTopic, VideoFormat, type VideoFormatValue, VideoStyle, type VideoStyleValue };
694
+ export { type AddSourceOptions, type Artifact, type ArtifactStatus, type ArtifactType, ArtifactTypeCode, ArtifactsAPI, type AskOptions, type AskResult, AudioFormat, type AudioFormatValue, AudioLength, type AudioLengthValue, AuthTokens, ChatAPI, ChatGoal, type ChatGoalValue, ChatMode, type ChatModeValue, type ChatReference, ChatResponseLength, type ChatResponseLengthValue, type ClientOptions, ConnectOptions, type ConversationTurn, type CreateAudioOptions, type CreateDataTableOptions, type CreateInfographicOptions, type CreateQuizOptions, type CreateReportOptions, type CreateSlideDeckOptions, type CreateVideoOptions, type DataTableContent, DriveMimeType, type DriveMimeTypeValue, ExportType, type ExportTypeValue, type GenerationStatus, type ImportedSource, InfographicDetail, type InfographicDetailValue, InfographicOrientation, type InfographicOrientationValue, InfographicStyle, type InfographicStyleValue, type Note, type Notebook, type NotebookDescription, NotebookLMClient, type NotebookMetadata, NotebooksAPI, NotesAPI, type PollUntilReadyOptions, QuizDifficulty, type QuizDifficultyValue, QuizQuantity, type QuizQuantityValue, RPCMethod, type RPCMethodId, type ReportFormat, type ReportSuggestion, ResearchAPI, type ResearchResult, type ResearchSource, type ResearchTask, SettingsAPI, ShareAccess, type ShareAccessValue, SharePermission, type SharePermissionValue, type ShareStatus, ShareViewLevel, type ShareViewLevelValue, type SharedUser, SharingAPI, SlideDeckFormat, type SlideDeckFormatValue, SlideDeckLength, type SlideDeckLengthValue, type Source, type SourceFulltext, type SourceGuide, type SourceStatus, type SourceSummary, type SourceType, SourcesAPI, type SuggestedTopic, VideoFormat, type VideoFormatValue, VideoStyle, type VideoStyleValue };
package/dist/index.d.ts CHANGED
@@ -402,6 +402,12 @@ interface DataTableContent {
402
402
  headers: string[];
403
403
  rows: string[][];
404
404
  }
405
+ interface PollUntilReadyOptions {
406
+ timeoutSecs?: number;
407
+ intervalSecs?: number;
408
+ onTick?: (status: GenerationStatus) => void | Promise<void>;
409
+ signal?: AbortSignal;
410
+ }
405
411
  type ReportFormat = "briefing_doc" | "study_guide" | "blog_post" | "custom";
406
412
  interface CreateReportOptions {
407
413
  format?: ReportFormat;
@@ -439,6 +445,9 @@ declare class ArtifactsAPI {
439
445
  createMindMap(notebookId: string, sourceIds?: string[]): Promise<Note>;
440
446
  /** Poll until artifact reaches completed/failed status. */
441
447
  waitUntilReady(notebookId: string, artifactId: string, timeout?: number, pollInterval?: number): Promise<Artifact>;
448
+ /** Poll until artifact is fully ready, with optional progress hooks and cancellation. */
449
+ pollUntilReady(notebookId: string, artifactId: string, opts?: PollUntilReadyOptions): Promise<Artifact>;
450
+ private throwIfAborted;
442
451
  /** Get the current status of a generated artifact without waiting. */
443
452
  pollStatus(notebookId: string, artifactId: string): Promise<GenerationStatus>;
444
453
  /** Download audio content as a Buffer. */
@@ -682,4 +691,4 @@ declare class NotebookLMClient {
682
691
  refreshTokens(): Promise<void>;
683
692
  }
684
693
 
685
- export { type AddSourceOptions, type Artifact, type ArtifactStatus, type ArtifactType, ArtifactTypeCode, ArtifactsAPI, type AskOptions, type AskResult, AudioFormat, type AudioFormatValue, AudioLength, type AudioLengthValue, AuthTokens, ChatAPI, ChatGoal, type ChatGoalValue, ChatMode, type ChatModeValue, type ChatReference, ChatResponseLength, type ChatResponseLengthValue, type ClientOptions, ConnectOptions, type ConversationTurn, type CreateAudioOptions, type CreateDataTableOptions, type CreateInfographicOptions, type CreateQuizOptions, type CreateReportOptions, type CreateSlideDeckOptions, type CreateVideoOptions, type DataTableContent, DriveMimeType, type DriveMimeTypeValue, ExportType, type ExportTypeValue, type GenerationStatus, type ImportedSource, InfographicDetail, type InfographicDetailValue, InfographicOrientation, type InfographicOrientationValue, InfographicStyle, type InfographicStyleValue, type Note, type Notebook, type NotebookDescription, NotebookLMClient, type NotebookMetadata, NotebooksAPI, NotesAPI, QuizDifficulty, type QuizDifficultyValue, QuizQuantity, type QuizQuantityValue, RPCMethod, type RPCMethodId, type ReportFormat, type ReportSuggestion, ResearchAPI, type ResearchResult, type ResearchSource, type ResearchTask, SettingsAPI, ShareAccess, type ShareAccessValue, SharePermission, type SharePermissionValue, type ShareStatus, ShareViewLevel, type ShareViewLevelValue, type SharedUser, SharingAPI, SlideDeckFormat, type SlideDeckFormatValue, SlideDeckLength, type SlideDeckLengthValue, type Source, type SourceFulltext, type SourceGuide, type SourceStatus, type SourceSummary, type SourceType, SourcesAPI, type SuggestedTopic, VideoFormat, type VideoFormatValue, VideoStyle, type VideoStyleValue };
694
+ export { type AddSourceOptions, type Artifact, type ArtifactStatus, type ArtifactType, ArtifactTypeCode, ArtifactsAPI, type AskOptions, type AskResult, AudioFormat, type AudioFormatValue, AudioLength, type AudioLengthValue, AuthTokens, ChatAPI, ChatGoal, type ChatGoalValue, ChatMode, type ChatModeValue, type ChatReference, ChatResponseLength, type ChatResponseLengthValue, type ClientOptions, ConnectOptions, type ConversationTurn, type CreateAudioOptions, type CreateDataTableOptions, type CreateInfographicOptions, type CreateQuizOptions, type CreateReportOptions, type CreateSlideDeckOptions, type CreateVideoOptions, type DataTableContent, DriveMimeType, type DriveMimeTypeValue, ExportType, type ExportTypeValue, type GenerationStatus, type ImportedSource, InfographicDetail, type InfographicDetailValue, InfographicOrientation, type InfographicOrientationValue, InfographicStyle, type InfographicStyleValue, type Note, type Notebook, type NotebookDescription, NotebookLMClient, type NotebookMetadata, NotebooksAPI, NotesAPI, type PollUntilReadyOptions, QuizDifficulty, type QuizDifficultyValue, QuizQuantity, type QuizQuantityValue, RPCMethod, type RPCMethodId, type ReportFormat, type ReportSuggestion, ResearchAPI, type ResearchResult, type ResearchSource, type ResearchTask, SettingsAPI, ShareAccess, type ShareAccessValue, SharePermission, type SharePermissionValue, type ShareStatus, ShareViewLevel, type ShareViewLevelValue, type SharedUser, SharingAPI, SlideDeckFormat, type SlideDeckFormatValue, SlideDeckLength, type SlideDeckLengthValue, type Source, type SourceFulltext, type SourceGuide, type SourceStatus, type SourceSummary, type SourceType, SourcesAPI, type SuggestedTopic, VideoFormat, type VideoFormatValue, VideoStyle, type VideoStyleValue };
package/dist/index.js CHANGED
@@ -938,9 +938,23 @@ ${opts.extraInstructions}` : cfg.prompt;
938
938
  // Polling / download
939
939
  // ---------------------------------------------------------------------------
940
940
  /** Poll until artifact reaches completed/failed status. */
941
- async waitUntilReady(notebookId, artifactId, timeout = 300, pollInterval = 3) {
941
+ async waitUntilReady(notebookId, artifactId, timeout = 1800, pollInterval = 3) {
942
+ return this.pollUntilReady(notebookId, artifactId, {
943
+ timeoutSecs: timeout,
944
+ intervalSecs: pollInterval
945
+ });
946
+ }
947
+ /** Poll until artifact is fully ready, with optional progress hooks and cancellation. */
948
+ async pollUntilReady(notebookId, artifactId, opts = {}) {
949
+ const timeout = opts.timeoutSecs ?? 1800;
950
+ const pollInterval = opts.intervalSecs ?? 3;
942
951
  const deadline = Date.now() + timeout * 1e3;
952
+ let lastStatus = null;
943
953
  while (Date.now() < deadline) {
954
+ this.throwIfAborted(opts.signal);
955
+ const status = await this.pollStatus(notebookId, artifactId);
956
+ lastStatus = status;
957
+ if (opts.onTick) await opts.onTick(status);
944
958
  const artifact = await this.get(notebookId, artifactId);
945
959
  if (artifact?.status === "completed") {
946
960
  if (artifact.kind === "audio" && !artifact.audioUrl || artifact.kind === "video" && !artifact.videoUrl) {
@@ -949,12 +963,22 @@ ${opts.extraInstructions}` : cfg.prompt;
949
963
  }
950
964
  return artifact;
951
965
  }
952
- if (artifact?.status === "failed") {
953
- throw new ArtifactNotReadyError(artifact.kind, { artifactId, status: "failed" });
966
+ if (artifact?.status === "failed" || status.status === "failed") {
967
+ throw new ArtifactNotReadyError(artifact?.kind ?? "artifact", {
968
+ artifactId,
969
+ status: "failed"
970
+ });
954
971
  }
955
972
  await sleep(pollInterval * 1e3);
956
973
  }
957
- throw new ArtifactNotReadyError("artifact", { artifactId, status: "timeout" });
974
+ throw new ArtifactNotReadyError("artifact", {
975
+ artifactId,
976
+ status: lastStatus?.status ?? "timeout"
977
+ });
978
+ }
979
+ throwIfAborted(signal) {
980
+ if (!signal?.aborted) return;
981
+ throw new Error("Artifact polling aborted");
958
982
  }
959
983
  /** Get the current status of a generated artifact without waiting. */
960
984
  async pollStatus(notebookId, artifactId) {