notebooklm-sdk 0.3.1 → 0.3.2
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.cjs +33 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1247,6 +1247,24 @@ ${opts.extraInstructions}` : cfg.prompt;
|
|
|
1247
1247
|
}
|
|
1248
1248
|
// ---------------------------------------------------------------------------
|
|
1249
1249
|
// Internal
|
|
1250
|
+
/** Export a completed report artifact to Google Docs. Returns the created document URL. */
|
|
1251
|
+
async exportReport(notebookId, artifactId, title) {
|
|
1252
|
+
const params = [null, artifactId, null, title, exports.ExportType.DOCS];
|
|
1253
|
+
const result = await this.rpc.call(exports.RPCMethod.EXPORT_ARTIFACT, params, {
|
|
1254
|
+
sourcePath: `/notebook/${notebookId}`,
|
|
1255
|
+
allowNull: true
|
|
1256
|
+
});
|
|
1257
|
+
return extractExportUrl(result);
|
|
1258
|
+
}
|
|
1259
|
+
/** Export a completed data table artifact to Google Sheets. Returns the created spreadsheet URL. */
|
|
1260
|
+
async exportDataTable(notebookId, artifactId, title) {
|
|
1261
|
+
const params = [null, artifactId, null, title, exports.ExportType.SHEETS];
|
|
1262
|
+
const result = await this.rpc.call(exports.RPCMethod.EXPORT_ARTIFACT, params, {
|
|
1263
|
+
sourcePath: `/notebook/${notebookId}`,
|
|
1264
|
+
allowNull: true
|
|
1265
|
+
});
|
|
1266
|
+
return extractExportUrl(result);
|
|
1267
|
+
}
|
|
1250
1268
|
// ---------------------------------------------------------------------------
|
|
1251
1269
|
/**
|
|
1252
1270
|
* Fetch a Google-hosted media URL, manually following redirects to ensure
|
|
@@ -1329,6 +1347,21 @@ function parseDataTable(rawData) {
|
|
|
1329
1347
|
throw new Error(`Failed to parse data table: ${e}`);
|
|
1330
1348
|
}
|
|
1331
1349
|
}
|
|
1350
|
+
function extractExportUrl(result) {
|
|
1351
|
+
if (!Array.isArray(result)) return null;
|
|
1352
|
+
function findUrl(data, depth = 5) {
|
|
1353
|
+
if (depth <= 0 || data == null) return null;
|
|
1354
|
+
if (typeof data === "string" && data.startsWith("https://")) return data;
|
|
1355
|
+
if (Array.isArray(data)) {
|
|
1356
|
+
for (const item of data) {
|
|
1357
|
+
const found = findUrl(item, depth - 1);
|
|
1358
|
+
if (found) return found;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
return null;
|
|
1362
|
+
}
|
|
1363
|
+
return findUrl(result);
|
|
1364
|
+
}
|
|
1332
1365
|
function sleep(ms) {
|
|
1333
1366
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1334
1367
|
}
|