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,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for NotebookLM API
|
|
3
|
+
* Comprehensive error code dictionary and error detection
|
|
4
|
+
*/
|
|
5
|
+
import { NotebookLMError } from '../types/common.js';
|
|
6
|
+
/**
|
|
7
|
+
* Error type categories
|
|
8
|
+
*/
|
|
9
|
+
export declare enum ErrorType {
|
|
10
|
+
UNKNOWN = "Unknown",
|
|
11
|
+
AUTHENTICATION = "Authentication",
|
|
12
|
+
AUTHORIZATION = "Authorization",
|
|
13
|
+
RATE_LIMIT = "RateLimit",
|
|
14
|
+
NOT_FOUND = "NotFound",
|
|
15
|
+
INVALID_INPUT = "InvalidInput",
|
|
16
|
+
SERVER_ERROR = "ServerError",
|
|
17
|
+
NETWORK_ERROR = "NetworkError",
|
|
18
|
+
PERMISSION_DENIED = "PermissionDenied",
|
|
19
|
+
RESOURCE_EXHAUSTED = "ResourceExhausted",
|
|
20
|
+
UNAVAILABLE = "Unavailable"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error code definition
|
|
24
|
+
*/
|
|
25
|
+
export interface ErrorCode {
|
|
26
|
+
code: number;
|
|
27
|
+
type: ErrorType;
|
|
28
|
+
message: string;
|
|
29
|
+
description: string;
|
|
30
|
+
retryable: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* API error with context
|
|
34
|
+
*/
|
|
35
|
+
export declare class APIError extends NotebookLMError {
|
|
36
|
+
readonly errorCode?: ErrorCode | undefined;
|
|
37
|
+
readonly httpStatus?: number | undefined;
|
|
38
|
+
readonly rawResponse?: string | undefined;
|
|
39
|
+
constructor(message: string, errorCode?: ErrorCode | undefined, httpStatus?: number | undefined, rawResponse?: string | undefined);
|
|
40
|
+
isRetryable(): boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get error code definition
|
|
44
|
+
*/
|
|
45
|
+
export declare function getErrorCode(code: number): ErrorCode | null;
|
|
46
|
+
/**
|
|
47
|
+
* Check if response contains an error
|
|
48
|
+
*/
|
|
49
|
+
export declare function isErrorResponse(response: any): APIError | null;
|
|
50
|
+
/**
|
|
51
|
+
* Add custom error code
|
|
52
|
+
*/
|
|
53
|
+
export declare function addErrorCode(code: number, errorCode: ErrorCode): void;
|
|
54
|
+
/**
|
|
55
|
+
* Get all registered error codes
|
|
56
|
+
*/
|
|
57
|
+
export declare function listErrorCodes(): Record<number, ErrorCode>;
|
|
58
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,oBAAY,SAAS;IACnB,OAAO,YAAY;IACnB,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,UAAU,cAAc;IACxB,SAAS,aAAa;IACtB,aAAa,iBAAiB;IAC9B,YAAY,gBAAgB;IAC5B,aAAa,iBAAiB;IAC9B,iBAAiB,qBAAqB;IACtC,kBAAkB,sBAAsB;IACxC,WAAW,gBAAgB;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,eAAe;aAGzB,SAAS,CAAC,EAAE,SAAS;aACrB,UAAU,CAAC,EAAE,MAAM;aACnB,WAAW,CAAC,EAAE,MAAM;gBAHpC,OAAO,EAAE,MAAM,EACC,SAAS,CAAC,EAAE,SAAS,YAAA,EACrB,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,WAAW,CAAC,EAAE,MAAM,YAAA;IAOtC,WAAW,IAAI,OAAO;CAYvB;AAoOD;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAE3D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,GAAG,IAAI,CA8E9D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAE1D"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for NotebookLM API
|
|
3
|
+
* Comprehensive error code dictionary and error detection
|
|
4
|
+
*/
|
|
5
|
+
import { NotebookLMError } from '../types/common.js';
|
|
6
|
+
/**
|
|
7
|
+
* Error type categories
|
|
8
|
+
*/
|
|
9
|
+
export var ErrorType;
|
|
10
|
+
(function (ErrorType) {
|
|
11
|
+
ErrorType["UNKNOWN"] = "Unknown";
|
|
12
|
+
ErrorType["AUTHENTICATION"] = "Authentication";
|
|
13
|
+
ErrorType["AUTHORIZATION"] = "Authorization";
|
|
14
|
+
ErrorType["RATE_LIMIT"] = "RateLimit";
|
|
15
|
+
ErrorType["NOT_FOUND"] = "NotFound";
|
|
16
|
+
ErrorType["INVALID_INPUT"] = "InvalidInput";
|
|
17
|
+
ErrorType["SERVER_ERROR"] = "ServerError";
|
|
18
|
+
ErrorType["NETWORK_ERROR"] = "NetworkError";
|
|
19
|
+
ErrorType["PERMISSION_DENIED"] = "PermissionDenied";
|
|
20
|
+
ErrorType["RESOURCE_EXHAUSTED"] = "ResourceExhausted";
|
|
21
|
+
ErrorType["UNAVAILABLE"] = "Unavailable";
|
|
22
|
+
})(ErrorType || (ErrorType = {}));
|
|
23
|
+
/**
|
|
24
|
+
* API error with context
|
|
25
|
+
*/
|
|
26
|
+
export class APIError extends NotebookLMError {
|
|
27
|
+
errorCode;
|
|
28
|
+
httpStatus;
|
|
29
|
+
rawResponse;
|
|
30
|
+
constructor(message, errorCode, httpStatus, rawResponse) {
|
|
31
|
+
super(message, httpStatus);
|
|
32
|
+
this.errorCode = errorCode;
|
|
33
|
+
this.httpStatus = httpStatus;
|
|
34
|
+
this.rawResponse = rawResponse;
|
|
35
|
+
this.name = 'APIError';
|
|
36
|
+
Object.setPrototypeOf(this, APIError.prototype);
|
|
37
|
+
}
|
|
38
|
+
isRetryable() {
|
|
39
|
+
if (this.errorCode) {
|
|
40
|
+
return this.errorCode.retryable;
|
|
41
|
+
}
|
|
42
|
+
// HTTP errors that are retryable
|
|
43
|
+
if (this.httpStatus) {
|
|
44
|
+
return [429, 500, 502, 503, 504].includes(this.httpStatus);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Error code dictionary
|
|
51
|
+
* Maps numeric error codes to their definitions
|
|
52
|
+
*/
|
|
53
|
+
const errorCodeDictionary = {
|
|
54
|
+
// Authentication errors
|
|
55
|
+
277566: {
|
|
56
|
+
code: 277566,
|
|
57
|
+
type: ErrorType.AUTHENTICATION,
|
|
58
|
+
message: 'Authentication required',
|
|
59
|
+
description: 'The request requires user authentication. Please check your credentials.',
|
|
60
|
+
retryable: false,
|
|
61
|
+
},
|
|
62
|
+
277567: {
|
|
63
|
+
code: 277567,
|
|
64
|
+
type: ErrorType.AUTHENTICATION,
|
|
65
|
+
message: 'Authentication token expired',
|
|
66
|
+
description: 'The authentication token has expired. Please get fresh credentials.',
|
|
67
|
+
retryable: false,
|
|
68
|
+
},
|
|
69
|
+
80620: {
|
|
70
|
+
code: 80620,
|
|
71
|
+
type: ErrorType.AUTHORIZATION,
|
|
72
|
+
message: 'Access denied',
|
|
73
|
+
description: 'Access to the requested resource is denied. Check your permissions.',
|
|
74
|
+
retryable: false,
|
|
75
|
+
},
|
|
76
|
+
// Rate limiting
|
|
77
|
+
324934: {
|
|
78
|
+
code: 324934,
|
|
79
|
+
type: ErrorType.RATE_LIMIT,
|
|
80
|
+
message: 'Rate limit exceeded',
|
|
81
|
+
description: 'Too many requests have been sent. Please wait before making more requests.',
|
|
82
|
+
retryable: true,
|
|
83
|
+
},
|
|
84
|
+
// Resource not found
|
|
85
|
+
143: {
|
|
86
|
+
code: 143,
|
|
87
|
+
type: ErrorType.NOT_FOUND,
|
|
88
|
+
message: 'Resource not found',
|
|
89
|
+
description: 'The requested resource could not be found. It may have been deleted or you may not have access to it.',
|
|
90
|
+
retryable: false,
|
|
91
|
+
},
|
|
92
|
+
// gRPC-style error codes
|
|
93
|
+
1: {
|
|
94
|
+
code: 1,
|
|
95
|
+
type: ErrorType.INVALID_INPUT,
|
|
96
|
+
message: 'Invalid request',
|
|
97
|
+
description: 'The request contains invalid parameters or data.',
|
|
98
|
+
retryable: false,
|
|
99
|
+
},
|
|
100
|
+
2: {
|
|
101
|
+
code: 2,
|
|
102
|
+
type: ErrorType.SERVER_ERROR,
|
|
103
|
+
message: 'Internal server error',
|
|
104
|
+
description: 'An internal server error occurred. Please try again later.',
|
|
105
|
+
retryable: true,
|
|
106
|
+
},
|
|
107
|
+
3: {
|
|
108
|
+
code: 3,
|
|
109
|
+
type: ErrorType.UNAVAILABLE,
|
|
110
|
+
message: 'Service unavailable',
|
|
111
|
+
description: 'The service is temporarily unavailable. Please try again later.',
|
|
112
|
+
retryable: true,
|
|
113
|
+
},
|
|
114
|
+
4: {
|
|
115
|
+
code: 4,
|
|
116
|
+
type: ErrorType.PERMISSION_DENIED,
|
|
117
|
+
message: 'Permission denied',
|
|
118
|
+
description: 'You do not have permission to access this resource.',
|
|
119
|
+
retryable: false,
|
|
120
|
+
},
|
|
121
|
+
5: {
|
|
122
|
+
code: 5,
|
|
123
|
+
type: ErrorType.NOT_FOUND,
|
|
124
|
+
message: 'Not found',
|
|
125
|
+
description: 'The requested item was not found.',
|
|
126
|
+
retryable: false,
|
|
127
|
+
},
|
|
128
|
+
6: {
|
|
129
|
+
code: 6,
|
|
130
|
+
type: ErrorType.INVALID_INPUT,
|
|
131
|
+
message: 'Invalid argument',
|
|
132
|
+
description: 'One or more arguments are invalid.',
|
|
133
|
+
retryable: false,
|
|
134
|
+
},
|
|
135
|
+
7: {
|
|
136
|
+
code: 7,
|
|
137
|
+
type: ErrorType.PERMISSION_DENIED,
|
|
138
|
+
message: 'Permission denied',
|
|
139
|
+
description: 'The caller does not have permission to execute the specified operation.',
|
|
140
|
+
retryable: false,
|
|
141
|
+
},
|
|
142
|
+
8: {
|
|
143
|
+
code: 8,
|
|
144
|
+
type: ErrorType.RESOURCE_EXHAUSTED,
|
|
145
|
+
message: 'Resource exhausted',
|
|
146
|
+
description: 'Some resource has been exhausted (quota, disk space, etc.).',
|
|
147
|
+
retryable: true,
|
|
148
|
+
},
|
|
149
|
+
9: {
|
|
150
|
+
code: 9,
|
|
151
|
+
type: ErrorType.INVALID_INPUT,
|
|
152
|
+
message: 'Failed precondition',
|
|
153
|
+
description: "Operation was rejected because the system is not in a state required for the operation's execution.",
|
|
154
|
+
retryable: false,
|
|
155
|
+
},
|
|
156
|
+
10: {
|
|
157
|
+
code: 10,
|
|
158
|
+
type: ErrorType.SERVER_ERROR,
|
|
159
|
+
message: 'Aborted',
|
|
160
|
+
description: 'The operation was aborted due to a concurrency issue.',
|
|
161
|
+
retryable: true,
|
|
162
|
+
},
|
|
163
|
+
11: {
|
|
164
|
+
code: 11,
|
|
165
|
+
type: ErrorType.INVALID_INPUT,
|
|
166
|
+
message: 'Out of range',
|
|
167
|
+
description: 'Operation was attempted past the valid range.',
|
|
168
|
+
retryable: false,
|
|
169
|
+
},
|
|
170
|
+
12: {
|
|
171
|
+
code: 12,
|
|
172
|
+
type: ErrorType.SERVER_ERROR,
|
|
173
|
+
message: 'Unimplemented',
|
|
174
|
+
description: 'Operation is not implemented or not supported/enabled.',
|
|
175
|
+
retryable: false,
|
|
176
|
+
},
|
|
177
|
+
13: {
|
|
178
|
+
code: 13,
|
|
179
|
+
type: ErrorType.SERVER_ERROR,
|
|
180
|
+
message: 'Internal error',
|
|
181
|
+
description: "Internal errors that shouldn't be exposed to clients.",
|
|
182
|
+
retryable: true,
|
|
183
|
+
},
|
|
184
|
+
14: {
|
|
185
|
+
code: 14,
|
|
186
|
+
type: ErrorType.UNAVAILABLE,
|
|
187
|
+
message: 'Unavailable',
|
|
188
|
+
description: 'The service is currently unavailable.',
|
|
189
|
+
retryable: true,
|
|
190
|
+
},
|
|
191
|
+
15: {
|
|
192
|
+
code: 15,
|
|
193
|
+
type: ErrorType.SERVER_ERROR,
|
|
194
|
+
message: 'Data loss',
|
|
195
|
+
description: 'Unrecoverable data loss or corruption.',
|
|
196
|
+
retryable: false,
|
|
197
|
+
},
|
|
198
|
+
16: {
|
|
199
|
+
code: 16,
|
|
200
|
+
type: ErrorType.AUTHENTICATION,
|
|
201
|
+
message: 'Unauthenticated',
|
|
202
|
+
description: 'The request does not have valid authentication credentials.',
|
|
203
|
+
retryable: false,
|
|
204
|
+
},
|
|
205
|
+
// HTTP status codes
|
|
206
|
+
400: {
|
|
207
|
+
code: 400,
|
|
208
|
+
type: ErrorType.INVALID_INPUT,
|
|
209
|
+
message: 'Bad Request',
|
|
210
|
+
description: 'The request is malformed or contains invalid parameters.',
|
|
211
|
+
retryable: false,
|
|
212
|
+
},
|
|
213
|
+
401: {
|
|
214
|
+
code: 401,
|
|
215
|
+
type: ErrorType.AUTHENTICATION,
|
|
216
|
+
message: 'Unauthorized',
|
|
217
|
+
description: 'Authentication is required to access this resource.',
|
|
218
|
+
retryable: false,
|
|
219
|
+
},
|
|
220
|
+
403: {
|
|
221
|
+
code: 403,
|
|
222
|
+
type: ErrorType.PERMISSION_DENIED,
|
|
223
|
+
message: 'Forbidden',
|
|
224
|
+
description: 'Access to this resource is forbidden.',
|
|
225
|
+
retryable: false,
|
|
226
|
+
},
|
|
227
|
+
404: {
|
|
228
|
+
code: 404,
|
|
229
|
+
type: ErrorType.NOT_FOUND,
|
|
230
|
+
message: 'Not Found',
|
|
231
|
+
description: 'The requested resource was not found.',
|
|
232
|
+
retryable: false,
|
|
233
|
+
},
|
|
234
|
+
429: {
|
|
235
|
+
code: 429,
|
|
236
|
+
type: ErrorType.RATE_LIMIT,
|
|
237
|
+
message: 'Too Many Requests',
|
|
238
|
+
description: 'Rate limit exceeded. Please wait before making more requests.',
|
|
239
|
+
retryable: true,
|
|
240
|
+
},
|
|
241
|
+
500: {
|
|
242
|
+
code: 500,
|
|
243
|
+
type: ErrorType.SERVER_ERROR,
|
|
244
|
+
message: 'Internal Server Error',
|
|
245
|
+
description: 'An internal server error occurred.',
|
|
246
|
+
retryable: true,
|
|
247
|
+
},
|
|
248
|
+
502: {
|
|
249
|
+
code: 502,
|
|
250
|
+
type: ErrorType.SERVER_ERROR,
|
|
251
|
+
message: 'Bad Gateway',
|
|
252
|
+
description: 'The server received an invalid response from an upstream server.',
|
|
253
|
+
retryable: true,
|
|
254
|
+
},
|
|
255
|
+
503: {
|
|
256
|
+
code: 503,
|
|
257
|
+
type: ErrorType.UNAVAILABLE,
|
|
258
|
+
message: 'Service Unavailable',
|
|
259
|
+
description: 'The service is temporarily unavailable.',
|
|
260
|
+
retryable: true,
|
|
261
|
+
},
|
|
262
|
+
504: {
|
|
263
|
+
code: 504,
|
|
264
|
+
type: ErrorType.SERVER_ERROR,
|
|
265
|
+
message: 'Gateway Timeout',
|
|
266
|
+
description: 'The server did not receive a timely response from an upstream server.',
|
|
267
|
+
retryable: true,
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Get error code definition
|
|
272
|
+
*/
|
|
273
|
+
export function getErrorCode(code) {
|
|
274
|
+
return errorCodeDictionary[code] || null;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Check if response contains an error
|
|
278
|
+
*/
|
|
279
|
+
export function isErrorResponse(response) {
|
|
280
|
+
if (!response) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
// Check explicit error field
|
|
284
|
+
if (response.error) {
|
|
285
|
+
return new APIError(response.error);
|
|
286
|
+
}
|
|
287
|
+
// Check if data is null (often indicates auth issue)
|
|
288
|
+
if (response.data === null || response.data === undefined) {
|
|
289
|
+
return null; // null data is not necessarily an error
|
|
290
|
+
}
|
|
291
|
+
const data = response.data;
|
|
292
|
+
// Handle numeric error codes
|
|
293
|
+
if (typeof data === 'number') {
|
|
294
|
+
const code = data;
|
|
295
|
+
// Skip success codes
|
|
296
|
+
if (code === 0 || code === 1) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
const errorCode = getErrorCode(code);
|
|
300
|
+
if (errorCode) {
|
|
301
|
+
return new APIError(errorCode.message, errorCode);
|
|
302
|
+
}
|
|
303
|
+
return new APIError(`Unknown error code: ${code}`);
|
|
304
|
+
}
|
|
305
|
+
// Handle array responses
|
|
306
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
307
|
+
const firstEl = data[0];
|
|
308
|
+
if (typeof firstEl === 'number') {
|
|
309
|
+
const code = firstEl;
|
|
310
|
+
// Skip success codes
|
|
311
|
+
if (code === 0 || code === 1) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
const errorCode = getErrorCode(code);
|
|
315
|
+
if (errorCode) {
|
|
316
|
+
return new APIError(errorCode.message, errorCode);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
// Handle object responses
|
|
321
|
+
if (typeof data === 'object' && data !== null) {
|
|
322
|
+
if ('error' in data && data.error) {
|
|
323
|
+
return new APIError(String(data.error));
|
|
324
|
+
}
|
|
325
|
+
if ('error_code' in data && typeof data.error_code === 'number') {
|
|
326
|
+
const errorCode = getErrorCode(data.error_code);
|
|
327
|
+
if (errorCode) {
|
|
328
|
+
return new APIError(errorCode.message, errorCode);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// Handle string responses
|
|
333
|
+
if (typeof data === 'string') {
|
|
334
|
+
const trimmed = data.trim();
|
|
335
|
+
const code = parseInt(trimmed, 10);
|
|
336
|
+
if (!isNaN(code) && code !== 0 && code !== 1) {
|
|
337
|
+
const errorCode = getErrorCode(code);
|
|
338
|
+
if (errorCode) {
|
|
339
|
+
return new APIError(errorCode.message, errorCode);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Add custom error code
|
|
347
|
+
*/
|
|
348
|
+
export function addErrorCode(code, errorCode) {
|
|
349
|
+
errorCodeDictionary[code] = errorCode;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Get all registered error codes
|
|
353
|
+
*/
|
|
354
|
+
export function listErrorCodes() {
|
|
355
|
+
return { ...errorCodeDictionary };
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EA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ACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,SAAoB;IAC7D,mBAAmB,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,GAAG,mBAAmB,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side quota management and rate limiting
|
|
3
|
+
* Enforces NotebookLM's usage limits to prevent API errors
|
|
4
|
+
*
|
|
5
|
+
* ALL LIMITS IN ONE PLACE - Update here when NotebookLM changes quotas
|
|
6
|
+
* Reference: https://support.google.com/notebooklm/answer/16213268
|
|
7
|
+
*/
|
|
8
|
+
import { APIError } from './errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* NotebookLM plan types
|
|
11
|
+
*/
|
|
12
|
+
export type NotebookLMPlan = 'standard' | 'plus' | 'pro' | 'ultra';
|
|
13
|
+
/**
|
|
14
|
+
* Quota limits for each plan
|
|
15
|
+
* Based on official NotebookLM documentation
|
|
16
|
+
* Reference: https://support.google.com/notebooklm/answer/16213268
|
|
17
|
+
*/
|
|
18
|
+
export interface PlanLimits {
|
|
19
|
+
/** Per account limits */
|
|
20
|
+
notebooks: number;
|
|
21
|
+
sourcesPerNotebook: number;
|
|
22
|
+
wordsPerSource: number;
|
|
23
|
+
fileSizeMB: number;
|
|
24
|
+
/** Daily limits (reset after 24 hours) */
|
|
25
|
+
chatsPerDay: number;
|
|
26
|
+
audioOverviewsPerDay: number;
|
|
27
|
+
videoOverviewsPerDay: number;
|
|
28
|
+
reportsPerDay: number;
|
|
29
|
+
flashcardsPerDay: number;
|
|
30
|
+
quizzesPerDay: number;
|
|
31
|
+
/** Monthly limits (reset after 30 days) */
|
|
32
|
+
deepResearchPerMonth: number;
|
|
33
|
+
/** Varies by plan (server-side enforcement) */
|
|
34
|
+
dataTables: 'limited' | 'more' | 'higher' | 'highest' | 'server-side';
|
|
35
|
+
infographics: 'limited' | 'more' | 'higher' | 'highest' | 'server-side';
|
|
36
|
+
slides: 'limited' | 'more' | 'higher' | 'highest' | 'server-side';
|
|
37
|
+
/** No limits for all plans */
|
|
38
|
+
mindMaps: 'unlimited';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Quota limits for each NotebookLM plan
|
|
42
|
+
* Reference: https://support.google.com/notebooklm/answer/16213268
|
|
43
|
+
*/
|
|
44
|
+
export declare const PLAN_LIMITS: Record<NotebookLMPlan, PlanLimits>;
|
|
45
|
+
/**
|
|
46
|
+
* Legacy constant for backward compatibility
|
|
47
|
+
* Uses Standard plan limits
|
|
48
|
+
*/
|
|
49
|
+
export declare const NOTEBOOKLM_LIMITS: {
|
|
50
|
+
/** Per account limits */
|
|
51
|
+
readonly MAX_NOTEBOOKS: number;
|
|
52
|
+
readonly MAX_SOURCES_PER_NOTEBOOK: number;
|
|
53
|
+
readonly MAX_WORDS_PER_SOURCE: number;
|
|
54
|
+
readonly MAX_FILE_SIZE_MB: number;
|
|
55
|
+
/** Daily limits (reset after 24 hours) */
|
|
56
|
+
readonly CHATS_PER_DAY: number;
|
|
57
|
+
readonly AUDIO_OVERVIEWS_PER_DAY: number;
|
|
58
|
+
readonly VIDEO_OVERVIEWS_PER_DAY: number;
|
|
59
|
+
readonly REPORTS_PER_DAY: number;
|
|
60
|
+
readonly FLASHCARDS_PER_DAY: number;
|
|
61
|
+
readonly QUIZZES_PER_DAY: number;
|
|
62
|
+
/** Monthly limits (reset after 30 days) */
|
|
63
|
+
readonly DEEP_RESEARCH_PER_MONTH: number;
|
|
64
|
+
/** No limits (but may be restricted server-side) */
|
|
65
|
+
readonly MIND_MAPS: number;
|
|
66
|
+
/** Limited (server enforced, no specific client limit) */
|
|
67
|
+
readonly DATA_TABLES: -1;
|
|
68
|
+
readonly INFOGRAPHICS: -1;
|
|
69
|
+
readonly SLIDES: -1;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Usage tracking data
|
|
73
|
+
*/
|
|
74
|
+
export interface UsageData {
|
|
75
|
+
/** Daily usage */
|
|
76
|
+
daily: {
|
|
77
|
+
chats: number;
|
|
78
|
+
audioOverviews: number;
|
|
79
|
+
videoOverviews: number;
|
|
80
|
+
reports: number;
|
|
81
|
+
flashcards: number;
|
|
82
|
+
quizzes: number;
|
|
83
|
+
lastReset: number;
|
|
84
|
+
};
|
|
85
|
+
/** Monthly usage */
|
|
86
|
+
monthly: {
|
|
87
|
+
deepResearch: number;
|
|
88
|
+
lastReset: number;
|
|
89
|
+
};
|
|
90
|
+
/** Notebook tracking */
|
|
91
|
+
notebooks: {
|
|
92
|
+
total: number;
|
|
93
|
+
sources: Record<string, number>;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Rate limit error (uses existing error code 324934)
|
|
98
|
+
*/
|
|
99
|
+
export declare class RateLimitError extends APIError {
|
|
100
|
+
readonly resource: string;
|
|
101
|
+
readonly used: number;
|
|
102
|
+
readonly limit: number;
|
|
103
|
+
readonly resetTime?: Date | undefined;
|
|
104
|
+
constructor(message: string, resource: string, used: number, limit: number, resetTime?: Date | undefined);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Client-side quota manager
|
|
108
|
+
* Tracks usage and enforces NotebookLM limits before making API calls
|
|
109
|
+
*/
|
|
110
|
+
export declare class QuotaManager {
|
|
111
|
+
private usage;
|
|
112
|
+
private enabled;
|
|
113
|
+
private plan;
|
|
114
|
+
private limits;
|
|
115
|
+
private storageKey;
|
|
116
|
+
constructor(enabled?: boolean, plan?: NotebookLMPlan);
|
|
117
|
+
/**
|
|
118
|
+
* Set the plan and update limits
|
|
119
|
+
*/
|
|
120
|
+
setPlan(plan: NotebookLMPlan): void;
|
|
121
|
+
/**
|
|
122
|
+
* Get current plan
|
|
123
|
+
*/
|
|
124
|
+
getPlan(): NotebookLMPlan;
|
|
125
|
+
/**
|
|
126
|
+
* Get current plan limits
|
|
127
|
+
*/
|
|
128
|
+
getLimits(): PlanLimits;
|
|
129
|
+
/**
|
|
130
|
+
* Check if operation is allowed
|
|
131
|
+
* @throws {RateLimitError} if limit exceeded
|
|
132
|
+
*/
|
|
133
|
+
checkQuota(operation: string, notebookId?: string): void;
|
|
134
|
+
/**
|
|
135
|
+
* Record usage after successful operation
|
|
136
|
+
*/
|
|
137
|
+
recordUsage(operation: string, notebookId?: string): void;
|
|
138
|
+
/**
|
|
139
|
+
* Get current usage statistics
|
|
140
|
+
*/
|
|
141
|
+
getUsage(): UsageData;
|
|
142
|
+
/**
|
|
143
|
+
* Get remaining quota for a resource
|
|
144
|
+
*/
|
|
145
|
+
getRemaining(resource: string): number;
|
|
146
|
+
/**
|
|
147
|
+
* Reset all usage (for testing or manual reset)
|
|
148
|
+
*/
|
|
149
|
+
resetUsage(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Validate text source word count
|
|
152
|
+
* Note: Validation is simple - if too large, NotebookLM will reject it
|
|
153
|
+
*/
|
|
154
|
+
validateTextSource(text: string): void;
|
|
155
|
+
/**
|
|
156
|
+
* Validate file size
|
|
157
|
+
* Note: Validation is simple - if too large, NotebookLM will reject it
|
|
158
|
+
*/
|
|
159
|
+
validateFileSize(sizeBytes: number): void;
|
|
160
|
+
/**
|
|
161
|
+
* Count words in text (approximation)
|
|
162
|
+
*/
|
|
163
|
+
private countWords;
|
|
164
|
+
/**
|
|
165
|
+
* Check and reset daily quotas if 24 hours passed
|
|
166
|
+
*/
|
|
167
|
+
private checkAndResetDaily;
|
|
168
|
+
/**
|
|
169
|
+
* Check and reset monthly quotas if 30 days passed
|
|
170
|
+
*/
|
|
171
|
+
private checkAndResetMonthly;
|
|
172
|
+
/**
|
|
173
|
+
* Get time when daily quota resets
|
|
174
|
+
*/
|
|
175
|
+
private getDailyResetTime;
|
|
176
|
+
/**
|
|
177
|
+
* Get time when monthly quota resets
|
|
178
|
+
*/
|
|
179
|
+
private getMonthlyResetTime;
|
|
180
|
+
/**
|
|
181
|
+
* Create empty usage data
|
|
182
|
+
*/
|
|
183
|
+
private createEmptyUsage;
|
|
184
|
+
/**
|
|
185
|
+
* Load usage from storage
|
|
186
|
+
*/
|
|
187
|
+
private loadUsage;
|
|
188
|
+
/**
|
|
189
|
+
* Save usage to storage
|
|
190
|
+
*/
|
|
191
|
+
private saveUsage;
|
|
192
|
+
/**
|
|
193
|
+
* Enable or disable quota enforcement
|
|
194
|
+
*/
|
|
195
|
+
setEnabled(enabled: boolean): void;
|
|
196
|
+
/**
|
|
197
|
+
* Check if quota enforcement is enabled
|
|
198
|
+
*/
|
|
199
|
+
isEnabled(): boolean;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Helper function to validate text source before upload
|
|
203
|
+
* Uses Standard plan limits by default
|
|
204
|
+
* Note: Validation is simple - if too large, NotebookLM will reject it
|
|
205
|
+
*/
|
|
206
|
+
export declare function validateTextSource(text: string, plan?: NotebookLMPlan): void;
|
|
207
|
+
/**
|
|
208
|
+
* Helper function to validate file size
|
|
209
|
+
* Uses Standard plan limits by default
|
|
210
|
+
* Note: Validation is simple - if too large, NotebookLM will reject it
|
|
211
|
+
*/
|
|
212
|
+
export declare function validateFileSize(sizeBytes: number, plan?: NotebookLMPlan): void;
|
|
213
|
+
//# sourceMappingURL=quota.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../../../src/utils/quota.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAa,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAA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