notebooklm-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,134 @@
1
+ /**
2
+ * All exceptions for notebooklm-sdk.
3
+ *
4
+ * All errors extend NotebookLMError so you can catch everything with:
5
+ * try { ... } catch (e) { if (e instanceof NotebookLMError) ... }
6
+ */
7
+ declare class NotebookLMError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ declare class NetworkError extends NotebookLMError {
11
+ readonly methodId?: string;
12
+ readonly originalError?: Error;
13
+ constructor(message: string, opts?: {
14
+ methodId?: string;
15
+ originalError?: Error;
16
+ });
17
+ }
18
+ declare class RPCTimeoutError extends NetworkError {
19
+ }
20
+ declare class RPCError extends NotebookLMError {
21
+ readonly methodId?: string;
22
+ readonly rawResponse?: string;
23
+ readonly rpcCode?: string | number;
24
+ readonly foundIds: string[];
25
+ constructor(message: string, opts?: {
26
+ methodId?: string;
27
+ rawResponse?: string;
28
+ rpcCode?: string | number;
29
+ foundIds?: string[];
30
+ });
31
+ }
32
+ declare class AuthError extends RPCError {
33
+ }
34
+ declare class RateLimitError extends RPCError {
35
+ readonly retryAfter?: number;
36
+ constructor(message: string, opts?: {
37
+ retryAfter?: number;
38
+ methodId?: string;
39
+ rawResponse?: string;
40
+ rpcCode?: string | number;
41
+ foundIds?: string[];
42
+ });
43
+ }
44
+ declare class ServerError extends RPCError {
45
+ readonly statusCode?: number;
46
+ constructor(message: string, opts?: {
47
+ statusCode?: number;
48
+ methodId?: string;
49
+ rawResponse?: string;
50
+ rpcCode?: string | number;
51
+ });
52
+ }
53
+ declare class ClientError extends RPCError {
54
+ readonly statusCode?: number;
55
+ constructor(message: string, opts?: {
56
+ statusCode?: number;
57
+ methodId?: string;
58
+ rawResponse?: string;
59
+ rpcCode?: string | number;
60
+ });
61
+ }
62
+ declare class NotebookError extends NotebookLMError {
63
+ }
64
+ declare class NotebookNotFoundError extends NotebookError {
65
+ readonly notebookId: string;
66
+ constructor(notebookId: string);
67
+ }
68
+ declare class SourceError extends NotebookLMError {
69
+ }
70
+ declare class SourceNotFoundError extends SourceError {
71
+ readonly sourceId: string;
72
+ constructor(sourceId: string);
73
+ }
74
+ declare class SourceAddError extends SourceError {
75
+ readonly url: string;
76
+ readonly cause?: Error;
77
+ constructor(url: string, opts?: {
78
+ cause?: Error;
79
+ message?: string;
80
+ });
81
+ }
82
+ declare class SourceProcessingError extends SourceError {
83
+ readonly sourceId: string;
84
+ readonly status: number;
85
+ constructor(sourceId: string, status?: number, message?: string);
86
+ }
87
+ declare class SourceTimeoutError extends SourceError {
88
+ readonly sourceId: string;
89
+ readonly timeout: number;
90
+ readonly lastStatus?: number;
91
+ constructor(sourceId: string, timeout: number, lastStatus?: number);
92
+ }
93
+ declare class ArtifactError extends NotebookLMError {
94
+ }
95
+ declare class ArtifactNotFoundError extends ArtifactError {
96
+ readonly artifactId: string;
97
+ readonly artifactType?: string;
98
+ constructor(artifactId: string, artifactType?: string);
99
+ }
100
+ declare class ArtifactNotReadyError extends ArtifactError {
101
+ readonly artifactType: string;
102
+ readonly artifactId?: string;
103
+ readonly status?: string;
104
+ constructor(artifactType: string, opts?: {
105
+ artifactId?: string;
106
+ status?: string;
107
+ });
108
+ }
109
+ declare class ArtifactParseError extends ArtifactError {
110
+ readonly artifactType: string;
111
+ readonly artifactId?: string;
112
+ readonly details?: string;
113
+ readonly cause?: Error;
114
+ constructor(artifactType: string, opts?: {
115
+ details?: string;
116
+ artifactId?: string;
117
+ cause?: Error;
118
+ });
119
+ }
120
+ declare class ArtifactDownloadError extends ArtifactError {
121
+ readonly artifactType: string;
122
+ readonly artifactId?: string;
123
+ readonly details?: string;
124
+ readonly cause?: Error;
125
+ constructor(artifactType: string, opts?: {
126
+ details?: string;
127
+ artifactId?: string;
128
+ cause?: Error;
129
+ });
130
+ }
131
+ declare class ChatError extends NotebookLMError {
132
+ }
133
+
134
+ export { ArtifactDownloadError, ArtifactError, ArtifactNotFoundError, ArtifactNotReadyError, ArtifactParseError, AuthError, ChatError, ClientError, NetworkError, NotebookError, NotebookLMError, NotebookNotFoundError, RPCError, RPCTimeoutError, RateLimitError, ServerError, SourceAddError, SourceError, SourceNotFoundError, SourceProcessingError, SourceTimeoutError };
package/dist/errors.js ADDED
@@ -0,0 +1,171 @@
1
+ // src/types/errors.ts
2
+ var NotebookLMError = class extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = this.constructor.name;
6
+ }
7
+ };
8
+ var NetworkError = class extends NotebookLMError {
9
+ methodId;
10
+ originalError;
11
+ constructor(message, opts = {}) {
12
+ super(message);
13
+ this.methodId = opts.methodId;
14
+ this.originalError = opts.originalError;
15
+ }
16
+ };
17
+ var RPCTimeoutError = class extends NetworkError {
18
+ };
19
+ var RPCError = class extends NotebookLMError {
20
+ methodId;
21
+ rawResponse;
22
+ rpcCode;
23
+ foundIds;
24
+ constructor(message, opts = {}) {
25
+ super(message);
26
+ this.methodId = opts.methodId;
27
+ this.rawResponse = opts.rawResponse ? opts.rawResponse.slice(0, 500) : void 0;
28
+ this.rpcCode = opts.rpcCode;
29
+ this.foundIds = opts.foundIds ?? [];
30
+ }
31
+ };
32
+ var AuthError = class extends RPCError {
33
+ };
34
+ var RateLimitError = class extends RPCError {
35
+ retryAfter;
36
+ constructor(message, opts = {}) {
37
+ super(message, opts);
38
+ this.retryAfter = opts.retryAfter;
39
+ }
40
+ };
41
+ var ServerError = class extends RPCError {
42
+ statusCode;
43
+ constructor(message, opts = {}) {
44
+ super(message, opts);
45
+ this.statusCode = opts.statusCode;
46
+ }
47
+ };
48
+ var ClientError = class extends RPCError {
49
+ statusCode;
50
+ constructor(message, opts = {}) {
51
+ super(message, opts);
52
+ this.statusCode = opts.statusCode;
53
+ }
54
+ };
55
+ var NotebookError = class extends NotebookLMError {
56
+ };
57
+ var NotebookNotFoundError = class extends NotebookError {
58
+ notebookId;
59
+ constructor(notebookId) {
60
+ super(`Notebook not found: ${notebookId}`);
61
+ this.notebookId = notebookId;
62
+ }
63
+ };
64
+ var SourceError = class extends NotebookLMError {
65
+ };
66
+ var SourceNotFoundError = class extends SourceError {
67
+ sourceId;
68
+ constructor(sourceId) {
69
+ super(`Source not found: ${sourceId}`);
70
+ this.sourceId = sourceId;
71
+ }
72
+ };
73
+ var SourceAddError = class extends SourceError {
74
+ url;
75
+ cause;
76
+ constructor(url, opts = {}) {
77
+ super(
78
+ opts.message ?? `Failed to add source: ${url}
79
+ Possible causes:
80
+ - URL is invalid or inaccessible
81
+ - Content is behind a paywall or requires authentication
82
+ - Rate limiting or quota exceeded`
83
+ );
84
+ this.url = url;
85
+ this.cause = opts.cause;
86
+ }
87
+ };
88
+ var SourceProcessingError = class extends SourceError {
89
+ sourceId;
90
+ status;
91
+ constructor(sourceId, status = 3, message) {
92
+ super(message ?? `Source ${sourceId} failed to process`);
93
+ this.sourceId = sourceId;
94
+ this.status = status;
95
+ }
96
+ };
97
+ var SourceTimeoutError = class extends SourceError {
98
+ sourceId;
99
+ timeout;
100
+ lastStatus;
101
+ constructor(sourceId, timeout, lastStatus) {
102
+ const statusInfo = lastStatus != null ? ` (last status: ${lastStatus})` : "";
103
+ super(`Source ${sourceId} not ready after ${timeout.toFixed(1)}s${statusInfo}`);
104
+ this.sourceId = sourceId;
105
+ this.timeout = timeout;
106
+ this.lastStatus = lastStatus;
107
+ }
108
+ };
109
+ var ArtifactError = class extends NotebookLMError {
110
+ };
111
+ var ArtifactNotFoundError = class extends ArtifactError {
112
+ artifactId;
113
+ artifactType;
114
+ constructor(artifactId, artifactType) {
115
+ const typeInfo = artifactType ? ` ${artifactType}` : "";
116
+ super(`${typeInfo.trim() || "Artifact"} ${artifactId} not found`);
117
+ this.artifactId = artifactId;
118
+ this.artifactType = artifactType;
119
+ }
120
+ };
121
+ var ArtifactNotReadyError = class extends ArtifactError {
122
+ artifactType;
123
+ artifactId;
124
+ status;
125
+ constructor(artifactType, opts = {}) {
126
+ const base = opts.artifactId ? `${artifactType} artifact ${opts.artifactId} is not ready` : `No completed ${artifactType} found`;
127
+ const statusInfo = opts.status ? ` (status: ${opts.status})` : "";
128
+ super(`${base}${statusInfo}`);
129
+ this.artifactType = artifactType;
130
+ this.artifactId = opts.artifactId;
131
+ this.status = opts.status;
132
+ }
133
+ };
134
+ var ArtifactParseError = class extends ArtifactError {
135
+ artifactType;
136
+ artifactId;
137
+ details;
138
+ cause;
139
+ constructor(artifactType, opts = {}) {
140
+ let msg = `Failed to parse ${artifactType} artifact`;
141
+ if (opts.artifactId) msg += ` ${opts.artifactId}`;
142
+ if (opts.details) msg += `: ${opts.details}`;
143
+ super(msg);
144
+ this.artifactType = artifactType;
145
+ this.artifactId = opts.artifactId;
146
+ this.details = opts.details;
147
+ this.cause = opts.cause;
148
+ }
149
+ };
150
+ var ArtifactDownloadError = class extends ArtifactError {
151
+ artifactType;
152
+ artifactId;
153
+ details;
154
+ cause;
155
+ constructor(artifactType, opts = {}) {
156
+ let msg = `Failed to download ${artifactType} artifact`;
157
+ if (opts.artifactId) msg += ` ${opts.artifactId}`;
158
+ if (opts.details) msg += `: ${opts.details}`;
159
+ super(msg);
160
+ this.artifactType = artifactType;
161
+ this.artifactId = opts.artifactId;
162
+ this.details = opts.details;
163
+ this.cause = opts.cause;
164
+ }
165
+ };
166
+ var ChatError = class extends NotebookLMError {
167
+ };
168
+
169
+ export { ArtifactDownloadError, ArtifactError, ArtifactNotFoundError, ArtifactNotReadyError, ArtifactParseError, AuthError, ChatError, ClientError, NetworkError, NotebookError, NotebookLMError, NotebookNotFoundError, RPCError, RPCTimeoutError, RateLimitError, ServerError, SourceAddError, SourceError, SourceNotFoundError, SourceProcessingError, SourceTimeoutError };
170
+ //# sourceMappingURL=errors.js.map
171
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/errors.ts"],"names":[],"mappings":";AAOO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EACzC,YAAY,OAAA,EAAiB;AAC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CAAA,CAAA,EAAI,KAAK,UAAU,CAAA,CAAA;AAC/C,IAAA,IAAI,IAAA,CAAK,OAAA,EAAS,GAAA,IAAO,CAAA,EAAA,EAAK,KAAK,OAAO,CAAA,CAAA;AAC1C,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AACpB,IAAA,IAAA,CAAK,aAAa,IAAA,CAAK,UAAA;AACvB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,KAAA;AAAA,EACpB;AACF;AAEO,IAAM,qBAAA,GAAN,cAAoC,aAAA,CAAc;AAAA,EAC9C,YAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EAET,WAAA,CACE,YAAA,EACA,IAAA,GAAiE,EAAC,EAClE;AACA,IAAA,IAAI,GAAA,GAAM,sBAAsB,YAAY,CAAA,SAAA,CAAA;AAC5C,IAAA,IAAI,IAAA,CAAK,UAAA,EAAY,GAAA,IAAO,CAAA,CAAA,EAAI,KAAK,UAAU,CAAA,CAAA;AAC/C,IAAA,IAAI,IAAA,CAAK,OAAA,EAAS,GAAA,IAAO,CAAA,EAAA,EAAK,KAAK,OAAO,CAAA,CAAA;AAC1C,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AACpB,IAAA,IAAA,CAAK,aAAa,IAAA,CAAK,UAAA;AACvB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,KAAA;AAAA,EACpB;AACF;AAMO,IAAM,SAAA,GAAN,cAAwB,eAAA,CAAgB;AAAC","file":"errors.js","sourcesContent":["/**\n * All exceptions for notebooklm-sdk.\n *\n * All errors extend NotebookLMError so you can catch everything with:\n * try { ... } catch (e) { if (e instanceof NotebookLMError) ... }\n */\n\nexport class NotebookLMError extends Error {\n constructor(message: string) {\n super(message);\n this.name = this.constructor.name;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Network (transport-level, before RPC processing)\n// ---------------------------------------------------------------------------\n\nexport class NetworkError extends NotebookLMError {\n readonly methodId?: string;\n readonly originalError?: Error;\n\n constructor(message: string, opts: { methodId?: string; originalError?: Error } = {}) {\n super(message);\n this.methodId = opts.methodId;\n this.originalError = opts.originalError;\n }\n}\n\nexport class RPCTimeoutError extends NetworkError {}\n\n// ---------------------------------------------------------------------------\n// RPC Protocol (after connection established)\n// ---------------------------------------------------------------------------\n\nexport class RPCError extends NotebookLMError {\n readonly methodId?: string;\n readonly rawResponse?: string;\n readonly rpcCode?: string | number;\n readonly foundIds: string[];\n\n constructor(\n message: string,\n opts: {\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n foundIds?: string[];\n } = {},\n ) {\n super(message);\n this.methodId = opts.methodId;\n this.rawResponse = opts.rawResponse ? opts.rawResponse.slice(0, 500) : undefined;\n this.rpcCode = opts.rpcCode;\n this.foundIds = opts.foundIds ?? [];\n }\n}\n\nexport class AuthError extends RPCError {}\n\nexport class RateLimitError extends RPCError {\n readonly retryAfter?: number;\n\n constructor(\n message: string,\n opts: {\n retryAfter?: number;\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n foundIds?: string[];\n } = {},\n ) {\n super(message, opts);\n this.retryAfter = opts.retryAfter;\n }\n}\n\nexport class ServerError extends RPCError {\n readonly statusCode?: number;\n\n constructor(\n message: string,\n opts: {\n statusCode?: number;\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n } = {},\n ) {\n super(message, opts);\n this.statusCode = opts.statusCode;\n }\n}\n\nexport class ClientError extends RPCError {\n readonly statusCode?: number;\n\n constructor(\n message: string,\n opts: {\n statusCode?: number;\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n } = {},\n ) {\n super(message, opts);\n this.statusCode = opts.statusCode;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Notebooks\n// ---------------------------------------------------------------------------\n\nexport class NotebookError extends NotebookLMError {}\n\nexport class NotebookNotFoundError extends NotebookError {\n readonly notebookId: string;\n\n constructor(notebookId: string) {\n super(`Notebook not found: ${notebookId}`);\n this.notebookId = notebookId;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Sources\n// ---------------------------------------------------------------------------\n\nexport class SourceError extends NotebookLMError {}\n\nexport class SourceNotFoundError extends SourceError {\n readonly sourceId: string;\n\n constructor(sourceId: string) {\n super(`Source not found: ${sourceId}`);\n this.sourceId = sourceId;\n }\n}\n\nexport class SourceAddError extends SourceError {\n readonly url: string;\n readonly cause?: Error;\n\n constructor(url: string, opts: { cause?: Error; message?: string } = {}) {\n super(\n opts.message ??\n `Failed to add source: ${url}\\n` +\n \"Possible causes:\\n\" +\n \" - URL is invalid or inaccessible\\n\" +\n \" - Content is behind a paywall or requires authentication\\n\" +\n \" - Rate limiting or quota exceeded\",\n );\n this.url = url;\n this.cause = opts.cause;\n }\n}\n\nexport class SourceProcessingError extends SourceError {\n readonly sourceId: string;\n readonly status: number;\n\n constructor(sourceId: string, status = 3, message?: string) {\n super(message ?? `Source ${sourceId} failed to process`);\n this.sourceId = sourceId;\n this.status = status;\n }\n}\n\nexport class SourceTimeoutError extends SourceError {\n readonly sourceId: string;\n readonly timeout: number;\n readonly lastStatus?: number;\n\n constructor(sourceId: string, timeout: number, lastStatus?: number) {\n const statusInfo = lastStatus != null ? ` (last status: ${lastStatus})` : \"\";\n super(`Source ${sourceId} not ready after ${timeout.toFixed(1)}s${statusInfo}`);\n this.sourceId = sourceId;\n this.timeout = timeout;\n this.lastStatus = lastStatus;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Artifacts\n// ---------------------------------------------------------------------------\n\nexport class ArtifactError extends NotebookLMError {}\n\nexport class ArtifactNotFoundError extends ArtifactError {\n readonly artifactId: string;\n readonly artifactType?: string;\n\n constructor(artifactId: string, artifactType?: string) {\n const typeInfo = artifactType ? ` ${artifactType}` : \"\";\n super(`${typeInfo.trim() || \"Artifact\"} ${artifactId} not found`);\n this.artifactId = artifactId;\n this.artifactType = artifactType;\n }\n}\n\nexport class ArtifactNotReadyError extends ArtifactError {\n readonly artifactType: string;\n readonly artifactId?: string;\n readonly status?: string;\n\n constructor(artifactType: string, opts: { artifactId?: string; status?: string } = {}) {\n const base = opts.artifactId\n ? `${artifactType} artifact ${opts.artifactId} is not ready`\n : `No completed ${artifactType} found`;\n const statusInfo = opts.status ? ` (status: ${opts.status})` : \"\";\n super(`${base}${statusInfo}`);\n this.artifactType = artifactType;\n this.artifactId = opts.artifactId;\n this.status = opts.status;\n }\n}\n\nexport class ArtifactParseError extends ArtifactError {\n readonly artifactType: string;\n readonly artifactId?: string;\n readonly details?: string;\n readonly cause?: Error;\n\n constructor(\n artifactType: string,\n opts: { details?: string; artifactId?: string; cause?: Error } = {},\n ) {\n let msg = `Failed to parse ${artifactType} artifact`;\n if (opts.artifactId) msg += ` ${opts.artifactId}`;\n if (opts.details) msg += `: ${opts.details}`;\n super(msg);\n this.artifactType = artifactType;\n this.artifactId = opts.artifactId;\n this.details = opts.details;\n this.cause = opts.cause;\n }\n}\n\nexport class ArtifactDownloadError extends ArtifactError {\n readonly artifactType: string;\n readonly artifactId?: string;\n readonly details?: string;\n readonly cause?: Error;\n\n constructor(\n artifactType: string,\n opts: { details?: string; artifactId?: string; cause?: Error } = {},\n ) {\n let msg = `Failed to download ${artifactType} artifact`;\n if (opts.artifactId) msg += ` ${opts.artifactId}`;\n if (opts.details) msg += `: ${opts.details}`;\n super(msg);\n this.artifactType = artifactType;\n this.artifactId = opts.artifactId;\n this.details = opts.details;\n this.cause = opts.cause;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Chat\n// ---------------------------------------------------------------------------\n\nexport class ChatError extends NotebookLMError {}\n"]}