@nshiab/simple-data-analysis 6.0.0 → 6.0.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.
@@ -102,9 +102,9 @@ class SimpleTable extends index_js_1.SimpleTable {
102
102
  *
103
103
  * This method automatically appends instructions to your prompt; set `verbose` to `true` to see the full prompt.
104
104
  *
105
- * This method supports Gemini, Vertex AI, and Ollama. Set `generation.provider` explicitly, or omit it to use `AI_PROVIDER`. All other `generation` fields match the selected `askGemini` or `askOllama` function from journalism-ai. Model and credentials can also come from environment variables.
105
+ * This method supports Gemini, Vertex AI, and Ollama.
106
106
  *
107
- * For Ollama, set `AI_PROVIDER=ollama`, ensure Ollama is running, and set `AI_MODEL`, or pass `{ provider: "ollama", ... }` through `generation`.
107
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads `AI_PROVIDER` (`"gemini"` or `"ollama"`; defaults to `"gemini"`), `AI_MODEL` (for example, `"gemini-3-flash-preview"` or `"gemma3:4b"`), and, for Gemini, either `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`). Values passed through `generation` override the corresponding environment values. When using Ollama, ensure it is running.
108
108
  *
109
109
  * To manage rate limits, use `batchSize` to process multiple rows per request and `rateLimitPerMinute` to pace requests across the worker pool. The `concurrency` option controls how many requests may run in parallel.
110
110
  *
@@ -126,7 +126,7 @@ class SimpleTable extends index_js_1.SimpleTable {
126
126
  * @param options.concurrency - The number of concurrent requests to send. Defaults to `1`.
127
127
  * @param options.errorColumn - The optional column where per-row error messages are stored. When omitted, a failed batch throws.
128
128
  * @param options.logProgress - If `true`, logs request-pool progress. Defaults to `false`.
129
- * @param options.generation - Gemini or Ollama generation configuration. Set `provider` explicitly or omit it to use environment selection; all other fields match the selected journalism-ai function.
129
+ * @param options.generation - Optional Gemini or Ollama generation configuration.
130
130
  * @param options.test - A function to validate the returned data. If it throws an error, the request will be retried (if `retry` is set). Defaults to `undefined`.
131
131
  * @param options.retry - The number of times to retry the request in case of failure. Defaults to `0`.
132
132
  * @param options.retryCheck - A function that receives an error and returns whether it should be retried. Defaults to `undefined`.
@@ -184,6 +184,10 @@ class SimpleTable extends index_js_1.SimpleTable {
184
184
  *
185
185
  * @example
186
186
  * ```ts
187
+ * // Set these environment variables before running:
188
+ * // AI_PROVIDER=gemini
189
+ * // AI_MODEL=gemini-3-flash-preview
190
+ * // AI_KEY=your-gemini-api-key
187
191
  * const cities = await sdb
188
192
  * .newTable("cities")
189
193
  * .loadArray([
@@ -225,9 +229,9 @@ class SimpleTable extends index_js_1.SimpleTable {
225
229
  /**
226
230
  * Generates embeddings for a specified text column and stores the results in a new column.
227
231
  *
228
- * This method supports Gemini, Vertex AI, and Ollama embeddings. Set `embeddings.provider` explicitly or omit it to use `AI_EMBEDDINGS_PROVIDER`; all other fields match `getEmbedding` from journalism-ai. Model and credentials can also come from environment variables.
232
+ * This method supports Gemini, Vertex AI, and Ollama embeddings.
229
233
  *
230
- * For Ollama, set `AI_EMBEDDINGS_PROVIDER=ollama`, ensure Ollama is running, and set `AI_EMBEDDINGS_MODEL`, or pass `{ provider: "ollama", ... }` through `embeddings`.
234
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or `"ollama"`; defaults to `"gemini"`), `AI_EMBEDDINGS_MODEL` (for example, `"gemini-embedding-001"` or `"nomic-embed-text"`), and, for Gemini, either `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`). Values passed through `embeddings` override the corresponding environment values. When using Ollama, ensure it is running.
231
235
  *
232
236
  * To manage rate limits, use `rateLimitPerMinute` to introduce delays between requests. For higher rate limits (business/professional accounts), `concurrency` allows parallel requests.
233
237
  *
@@ -249,7 +253,7 @@ class SimpleTable extends index_js_1.SimpleTable {
249
253
  * @param options.efSearch - The number of candidate vertices to consider during search. Higher values result in more accurate searches but increase search time. Defaults to 64.
250
254
  * @param options.M - The maximum number of neighbors to keep for each vertex in the graph. Higher values result in more accurate indexes but increase build time and memory usage. Defaults to 16.
251
255
  * @param options.concurrency - The number of concurrent requests to send. Defaults to `1`.
252
- * @param options.embeddings - Gemini or Ollama embedding configuration. Set `provider` explicitly or omit it to use environment selection; all other fields match `getEmbedding` from journalism-ai.
256
+ * @param options.embeddings - Optional Gemini or Ollama embedding configuration.
253
257
  * @param options.rateLimitPerMinute - The rate limit for AI requests in requests per minute. The method will wait between requests if necessary. Defaults to `undefined` (no limit).
254
258
  * @param options.verbose - If `true`, logs additional debugging information. Defaults to `false`.
255
259
  * @returns The table, so methods can be chained.
@@ -257,6 +261,10 @@ class SimpleTable extends index_js_1.SimpleTable {
257
261
  *
258
262
  * @example
259
263
  * ```ts
264
+ * // Set these environment variables before running:
265
+ * // AI_EMBEDDINGS_PROVIDER=gemini
266
+ * // AI_EMBEDDINGS_MODEL=gemini-embedding-001
267
+ * // AI_KEY=your-gemini-api-key
260
268
  * const food = await sdb
261
269
  * .newTable("food")
262
270
  * .loadArray([
@@ -268,10 +276,6 @@ class SimpleTable extends index_js_1.SimpleTable {
268
276
  * { food: "tacos" },
269
277
  * ])
270
278
  * .aiEmbeddings("food", "embeddings", {
271
- * embeddings: {
272
- * provider: "gemini",
273
- * model: "gemini-embedding-001",
274
- * },
275
279
  * rateLimitPerMinute: 15,
276
280
  * createIndex: true,
277
281
  * verbose: true,
@@ -297,7 +301,7 @@ class SimpleTable extends index_js_1.SimpleTable {
297
301
  * Creates an embedding from a specified text and returns the most similar text content based on their embeddings.
298
302
  * This method is useful for semantic search and text similarity tasks, computing cosine distance and sorting results by similarity.
299
303
  *
300
- * To create the query embedding, omit `embeddings` to use environment variables or pass provider-specific options matching `getEmbedding` from journalism-ai.
304
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or `"ollama"`; defaults to `"gemini"`), `AI_EMBEDDINGS_MODEL` (for example, `"gemini-embedding-001"` or `"nomic-embed-text"`), and, for Gemini, either `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`). Values passed through `embeddings` override the corresponding environment values.
301
305
  *
302
306
  * Gemini, Vertex AI, and Ollama are supported. The selected provider and model must match those used to create the stored embedding column so the vectors share the same dimensions and embedding space.
303
307
  *
@@ -318,13 +322,17 @@ class SimpleTable extends index_js_1.SimpleTable {
318
322
  * @param options.efSearch - The number of candidate vertices to consider during search. Higher values result in more accurate searches but increase search time. Defaults to 64.
319
323
  * @param options.M - The maximum number of neighbors to keep for each vertex in the graph. Higher values result in more accurate indexes but increase build time and memory usage. Defaults to 16.
320
324
  * @param options.outputTable - The name of the output table where the results will be stored. If not provided, the current table will be modified. Defaults to `undefined`.
321
- * @param options.embeddings - Gemini or Ollama embedding configuration. Set `provider` explicitly or omit it to use environment selection; all other fields match `getEmbedding` from journalism-ai.
325
+ * @param options.embeddings - Optional Gemini or Ollama embedding configuration.
322
326
  * @param options.verbose - If `true`, logs additional debugging information. Defaults to `false`.
323
327
  * @returns The table that will contain the similarity results, so methods can be chained.
324
328
  * @category AI
325
329
  *
326
330
  * @example
327
331
  * ```ts
332
+ * // Set these environment variables before running:
333
+ * // AI_EMBEDDINGS_PROVIDER=gemini
334
+ * // AI_EMBEDDINGS_MODEL=gemini-embedding-001
335
+ * // AI_KEY=your-gemini-api-key
328
336
  * const similarFood = await sdb
329
337
  * .newTable("food")
330
338
  * .loadArray([
@@ -335,18 +343,9 @@ class SimpleTable extends index_js_1.SimpleTable {
335
343
  * { food: "salad" },
336
344
  * { food: "tacos" },
337
345
  * ])
338
- * .aiEmbeddings("food", "embeddings", {
339
- * embeddings: {
340
- * provider: "gemini",
341
- * model: "gemini-embedding-001",
342
- * },
343
- * })
346
+ * .aiEmbeddings("food", "embeddings")
344
347
  * .aiVectorSimilarity("italian food", "embeddings", 3, {
345
348
  * createIndex: true,
346
- * embeddings: {
347
- * provider: "gemini",
348
- * model: "gemini-embedding-001",
349
- * },
350
349
  * minSimilarity: 0.6,
351
350
  * similarityColumn: "score",
352
351
  * })
@@ -381,7 +380,9 @@ class SimpleTable extends index_js_1.SimpleTable {
381
380
  *
382
381
  * Remove `.journalism-cache` and `.sda-cache` to clear existing cache entries. Remember to add both directories to your `.gitignore`.
383
382
  *
384
- * This method supports Gemini, Vertex AI, and Ollama embeddings. Set `embeddings.provider` explicitly or omit it to use environment selection; all other fields match `getEmbedding` from journalism-ai.
383
+ * This method supports Gemini, Vertex AI, and Ollama embeddings.
384
+ *
385
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or `"ollama"`; defaults to `"gemini"`), `AI_EMBEDDINGS_MODEL` (for example, `"gemini-embedding-001"` or `"nomic-embed-text"`), and, for Gemini, either `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`). Values passed through `embeddings` override the corresponding environment values.
385
386
  *
386
387
  * The selected embedding provider is used for both stored row embeddings and the query embedding.
387
388
  *
@@ -395,7 +396,7 @@ class SimpleTable extends index_js_1.SimpleTable {
395
396
  * @param textColumn - The name of the column containing the text content to search through.
396
397
  * @param nbResults - The number of most similar rows to retrieve.
397
398
  * @param options - Configuration options for the hybrid search.
398
- * @param options.embeddings - Gemini or Ollama embedding configuration. Set `provider` explicitly or omit it to use environment selection; all other fields match `getEmbedding` from journalism-ai.
399
+ * @param options.embeddings - Optional Gemini or Ollama embedding configuration.
399
400
  * @param options.verbose - If `true`, logs additional debugging information. Defaults to `false`.
400
401
  * @param options.createIndex - If `true`, creates an HNSW index when vector search is enabled. The BM25 FTS index is managed automatically whenever BM25 search is enabled. Defaults to `false`.
401
402
  * @param options.efConstruction - The number of candidate vertices to consider during index construction. Higher values result in more accurate indexes but increase build time. Defaults to 128.
@@ -423,16 +424,16 @@ class SimpleTable extends index_js_1.SimpleTable {
423
424
  *
424
425
  * @example
425
426
  * ```ts
427
+ * // Set these environment variables before running:
428
+ * // AI_EMBEDDINGS_PROVIDER=gemini
429
+ * // AI_EMBEDDINGS_MODEL=gemini-embedding-001
430
+ * // AI_KEY=your-gemini-api-key
426
431
  * // Load a dataset of recipes
427
432
  * const sdb = new SimpleDB();
428
433
  * const results = await sdb
429
434
  * .newTable("recipes")
430
435
  * .loadData("recipes.parquet")
431
436
  * .hybridSearch("buttery pastry for breakfast", "Dish", "Recipe", 10, {
432
- * embeddings: {
433
- * provider: "gemini",
434
- * model: "gemini-embedding-001",
435
- * },
436
437
  * verbose: true,
437
438
  * })
438
439
  * .log();
@@ -460,9 +461,11 @@ class SimpleTable extends index_js_1.SimpleTable {
460
461
  *
461
462
  * Remove `.journalism-cache` and `.sda-cache` to clear existing cache entries. Remember to add both directories to your `.gitignore`.
462
463
  *
463
- * Generation and embeddings are independently configurable. Set either nested `provider` explicitly or omit it to use that provider's environment selection; all remaining fields match journalism-ai.
464
+ * Generation and embeddings are independently configurable.
465
+ *
466
+ * Environment variables are named configuration values supplied to the running process. By default, generation reads `AI_PROVIDER` (`"gemini"` or `"ollama"`; defaults to `"gemini"`) and `AI_MODEL` (for example, `"gemini-3-flash-preview"` or `"gemma3:4b"`), while embeddings read `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or `"ollama"`; defaults to `"gemini"`) and `AI_EMBEDDINGS_MODEL` (for example, `"gemini-embedding-001"` or `"nomic-embed-text"`). Gemini generation and embeddings also read either `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`). Values passed through either option override its environment defaults.
464
467
  *
465
- * For example, `generation.provider` can be `"gemini"` while `embeddings.provider` is `"ollama"`. Environment-only mixed providers use `AI_PROVIDER` and `AI_EMBEDDINGS_PROVIDER`.
468
+ * For example, `generation.provider` can be `"gemini"` while `embeddings.provider` is `"ollama"`; the same mix can be selected through `AI_PROVIDER=gemini` and `AI_EMBEDDINGS_PROVIDER=ollama`.
466
469
  *
467
470
  * Ollama temperature defaults to 0. Gemini uses the provider's default temperature.
468
471
  *
@@ -475,8 +478,8 @@ class SimpleTable extends index_js_1.SimpleTable {
475
478
  * @param textColumn - The name of the column containing the text content to search through and use as context.
476
479
  * @param nbResults - The number of most similar rows to retrieve and use as context for the AI.
477
480
  * @param options - Configuration options for the RAG process.
478
- * @param options.generation - Gemini or Ollama generation configuration. Set `provider` explicitly or omit it to use environment selection; all other relevant fields match the selected journalism-ai function.
479
- * @param options.embeddings - Gemini or Ollama embedding configuration. Set `provider` explicitly or omit it to use environment selection; all other fields match `getEmbedding` from journalism-ai.
481
+ * @param options.generation - Optional Gemini or Ollama generation configuration.
482
+ * @param options.embeddings - Optional Gemini or Ollama embedding configuration.
480
483
  * @param options.verbose - If `true`, logs additional debugging information. Defaults to `false`.
481
484
  * @param options.includeThoughts - If `true`, includes the AI model's reasoning process in the logged output when using models that support extended thinking. Only relevant when used with thinking-capable models. Defaults to `false`.
482
485
  * @param options.metrics - An object to track cumulative metrics across multiple AI requests. Pass an object with totalCost, totalInputTokens, totalOutputTokens, and totalRequests properties (all initialized to 0). The function will update these values after each request. Note: totalCost is only calculated for Google GenAI models, not for Ollama.
@@ -504,6 +507,12 @@ class SimpleTable extends index_js_1.SimpleTable {
504
507
  *
505
508
  * @example
506
509
  * ```ts
510
+ * // Set these environment variables before running:
511
+ * // AI_PROVIDER=gemini
512
+ * // AI_MODEL=gemini-3-flash-preview
513
+ * // AI_KEY=your-gemini-api-key
514
+ * // AI_EMBEDDINGS_PROVIDER=ollama
515
+ * // AI_EMBEDDINGS_MODEL=nomic-embed-text
507
516
  * // Load a dataset of recipes
508
517
  * const sdb = new SimpleDB();
509
518
  * const answer = await sdb
@@ -514,17 +523,7 @@ class SimpleTable extends index_js_1.SimpleTable {
514
523
  * "Dish", // Column with unique IDs
515
524
  * "Recipe", // Column with text to search
516
525
  * 10, // The 10 most relevant recipes passed to the LLM
517
- * {
518
- * generation: {
519
- * provider: "gemini",
520
- * model: "gemini-3-flash-preview",
521
- * },
522
- * embeddings: {
523
- * provider: "ollama",
524
- * model: "nomic-embed-text",
525
- * },
526
- * verbose: true, // Log debugging information and timings
527
- * },
526
+ * { verbose: true }, // Log debugging information and timings
528
527
  * );
529
528
  *
530
529
  * console.log(answer);
@@ -554,9 +553,9 @@ class SimpleTable extends index_js_1.SimpleTable {
554
553
  * Generates and executes a SQL query based on a prompt.
555
554
  * Additional instructions, such as column types, are automatically added to your prompt. Set `verbose` to `true` to see the full prompt.
556
555
  *
557
- * This method supports Gemini, Vertex AI, and Ollama. Set `generation.provider` explicitly or omit it to use environment selection; all other relevant fields match `askGemini` or `askOllama` from journalism-ai.
556
+ * This method supports Gemini, Vertex AI, and Ollama.
558
557
  *
559
- * For Ollama, set `AI_PROVIDER=ollama`, ensure Ollama is running, and set `AI_MODEL`, or pass `{ provider: "ollama", ... }` through `generation`.
558
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads `AI_PROVIDER` (`"gemini"` or `"ollama"`; defaults to `"gemini"`), `AI_MODEL` (for example, `"gemini-3-flash-preview"` or `"gemma3:4b"`), and, for Gemini, either `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`). Values passed through `generation` override the corresponding environment values. When using Ollama, ensure it is running.
560
559
  *
561
560
  * Ollama temperature defaults to 0, while Gemini uses the provider's default. Provider-specific controls live under `generation`.
562
561
  *
@@ -566,7 +565,7 @@ class SimpleTable extends index_js_1.SimpleTable {
566
565
  * @param prompt - The input string to guide the AI in generating the SQL query.
567
566
  * @param options - Configuration options for the AI request.
568
567
  * @param options.extraInstructions - Additional instructions to append to the prompt, providing more context or guidance for the AI.
569
- * @param options.generation - Gemini or Ollama generation configuration. Set `provider` explicitly or omit it to use environment selection; all other relevant fields match the selected journalism-ai function.
568
+ * @param options.generation - Optional Gemini or Ollama generation configuration.
570
569
  * @param options.outputTable - The name of a new table where the results will be stored. If not provided, the current table will be replaced with the query results.
571
570
  * @param options.verbose - If `true`, logs additional debugging information, including the full prompt sent to the AI. Defaults to `false`.
572
571
  * @param options.includeThoughts - If `true`, includes the AI model's reasoning process in the logged output when using models that support extended thinking. Only relevant when used with thinking-capable models. Defaults to `false`.
@@ -575,17 +574,17 @@ class SimpleTable extends index_js_1.SimpleTable {
575
574
  *
576
575
  * @example
577
576
  * ```ts
577
+ * // Set these environment variables before running:
578
+ * // AI_PROVIDER=gemini
579
+ * // AI_MODEL=gemini-3-flash-preview
580
+ * // AI_KEY=your-gemini-api-key
578
581
  * // The AI will generate a query that will be executed, and
579
582
  * // the result will replace the existing table.
580
583
  * // If run again, it will use the previous query from the cache.
581
584
  * // Don't forget to add .journalism-cache to your .gitignore file!
582
585
  * const averageSalaryByDepartment = await table
583
586
  * .aiQuery("Give me the average salary by department", {
584
- * generation: {
585
- * provider: "gemini",
586
- * model: "gemini-3-flash-preview",
587
- * },
588
- * verbose: true,
587
+ * verbose: true,
589
588
  * })
590
589
  * .log();
591
590
  * ```
@@ -624,7 +623,9 @@ class SimpleTable extends index_js_1.SimpleTable {
624
623
  * Writes the table data to a Google Sheet.
625
624
  * This method uses the `pushToSheet` function from the [journalism-google library](https://jsr.io/@nshiab/journalism-google). Refer to its documentation for more details.
626
625
  *
627
- * By default, the selected tab is overwritten and values are written without Google Sheets interpretation. Authentication is handled via environment variables (GOOGLE_PRIVATE_KEY and GOOGLE_SERVICE_ACCOUNT_EMAIL). Alternatively, you can use GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file. For detailed setup instructions, refer to the node-google-spreadsheet authentication guide: https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication.
626
+ * By default, the selected tab is overwritten and values are written without Google Sheets interpretation.
627
+ *
628
+ * Environment variables are named configuration values supplied to the running process. For authentication, this method reads `GOOGLE_SERVICE_ACCOUNT_EMAIL` (for example, `"service-account@example.iam.gserviceaccount.com"`) with `GOOGLE_PRIVATE_KEY` (for example, `"-----BEGIN PRIVATE KEY-----\n..."`). Alternatively, set `GOOGLE_APPLICATION_CREDENTIALS` to a service-account JSON path (for example, `"./service-account.json"`). Values passed through `options.credentials` override these environment values. For detailed setup instructions, refer to the node-google-spreadsheet authentication guide: https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication.
628
629
  *
629
630
  * @param sheetUrl - A Google Sheets URL. It can point to a spreadsheet or a specific tab.
630
631
  * @param options - An optional object with configuration options:
@@ -634,7 +635,7 @@ class SimpleTable extends index_js_1.SimpleTable {
634
635
  * @param options.prepend - Text to add above the header row in overwrite mode.
635
636
  * @param options.lastUpdate - If `true`, adds a UTC timestamp. Pass a Canadian time zone to use it for the timestamp. Available only in overwrite mode.
636
637
  * @param options.raw - If `true`, writes values without Google Sheets interpretation. Defaults to `true`.
637
- * @param options.credentials - Explicit Google service-account credentials. These override credentials provided through environment variables or GOOGLE_APPLICATION_CREDENTIALS.
638
+ * @param options.credentials - Optional Google service-account credentials.
638
639
  * @param options.credentials.email - The Google service-account email.
639
640
  * @param options.credentials.privateKey - The Google service-account private key.
640
641
  * @returns A promise that resolves when the data has been written to the sheet.
@@ -642,6 +643,9 @@ class SimpleTable extends index_js_1.SimpleTable {
642
643
  *
643
644
  * @example
644
645
  * ```ts
646
+ * // Set these environment variables before running:
647
+ * // GOOGLE_SERVICE_ACCOUNT_EMAIL=service-account@example.iam.gserviceaccount.com
648
+ * // GOOGLE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\n...
645
649
  * // Load, transform, and write data to a Google Sheet
646
650
  * await sdb
647
651
  * .newTable()
@@ -702,19 +706,22 @@ class SimpleTable extends index_js_1.SimpleTable {
702
706
  * Loads data from a Google Sheet into the table.
703
707
  * This method uses the `getSheetData` function from the [journalism library](https://jsr.io/@nshiab/journalism). Refer to its documentation for more details.
704
708
  *
705
- * By default, authentication is handled via environment variables (GOOGLE_PRIVATE_KEY and GOOGLE_SERVICE_ACCOUNT_EMAIL). Alternatively, you can use GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file. For detailed setup instructions, refer to the node-google-spreadsheet authentication guide: https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication.
709
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads `GOOGLE_SERVICE_ACCOUNT_EMAIL` (for example, `"service-account@example.iam.gserviceaccount.com"`) with `GOOGLE_PRIVATE_KEY` (for example, `"-----BEGIN PRIVATE KEY-----\n..."`). Alternatively, set `GOOGLE_APPLICATION_CREDENTIALS` to a service-account JSON path (for example, `"./service-account.json"`).
706
710
  * The download is queued and runs in chain order at the next awaited observer or `run()` call.
707
711
  *
708
712
  * @param sheetUrl - The URL pointing to a specific Google Sheet (e.g., `"https://docs.google.com/spreadsheets/d/.../edit#gid=0"`).
709
713
  * @param options - An optional object with configuration options:
710
714
  * @param options.skip - The number of rows to skip from the top of the sheet before reading data. Useful when the sheet contains metadata or headers that should not be included in the data.
711
- * @param options.apiEmailEnvVar - The name of the environment variable that stores your API email.
712
- * @param options.apiKeyEnvVar - The name of the environment variable that stores your API key.
715
+ * @param options.apiEmailEnvVar - A custom environment-variable name from which to read the Google service-account email. Defaults to `"GOOGLE_SERVICE_ACCOUNT_EMAIL"`.
716
+ * @param options.apiKeyEnvVar - A custom environment-variable name from which to read the Google service-account private key. Defaults to `"GOOGLE_PRIVATE_KEY"`.
713
717
  * @returns The table, so methods can be chained.
714
718
  * @category Loading Data
715
719
  *
716
720
  * @example
717
721
  * ```ts
722
+ * // Set these environment variables before running:
723
+ * // GOOGLE_SERVICE_ACCOUNT_EMAIL=service-account@example.iam.gserviceaccount.com
724
+ * // GOOGLE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\n...
718
725
  * // Load data from a Google Sheet
719
726
  * const sheetData = await sdb
720
727
  * .newTable("sheetData")
@@ -740,11 +747,11 @@ class SimpleTable extends index_js_1.SimpleTable {
740
747
  /**
741
748
  * Writes the table data as CSV to a Datawrapper chart or table.
742
749
  *
743
- * Authentication is handled via an API key stored in the environment variable `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`.
750
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for example, `"your-datawrapper-api-key"`).
744
751
  *
745
752
  * @param chartId - The unique ID of the Datawrapper chart or table to update. This ID can be found in the Datawrapper URL or dashboard.
746
753
  * @param options - An optional object with configuration options:
747
- * @param options.apiKeyEnvVar - The name of the environment variable that stores your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to `"DATAWRAPPER_KEY"`.
754
+ * @param options.apiKeyEnvVar - A custom environment-variable name from which to read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
748
755
  * @param options.note - A string to update the chart's notes field with (e.g., a last-updated timestamp).
749
756
  * @param options.republish - If `true`, republishes the chart after updating the data. Defaults to `false`.
750
757
  * @returns A promise that resolves when the data has been sent to Datawrapper.
@@ -752,6 +759,7 @@ class SimpleTable extends index_js_1.SimpleTable {
752
759
  *
753
760
  * @example
754
761
  * ```ts
762
+ * // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
755
763
  * // Load, transform, and send data to a Datawrapper chart
756
764
  * await sdb
757
765
  * .newTable()
@@ -775,17 +783,18 @@ class SimpleTable extends index_js_1.SimpleTable {
775
783
  /**
776
784
  * Loads data from a Datawrapper chart or table into the table.
777
785
  *
778
- * Authentication is handled via an API key stored in the environment variable `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`.
786
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for example, `"your-datawrapper-api-key"`).
779
787
  * The download is queued and runs in chain order at the next awaited observer or `run()` call.
780
788
  *
781
789
  * @param chartId - The unique ID of the Datawrapper chart or table. This ID can be found in the Datawrapper URL or dashboard.
782
790
  * @param options - An optional object with configuration options:
783
- * @param options.apiKeyEnvVar - The name of the environment variable that stores your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to `"DATAWRAPPER_KEY"`.
791
+ * @param options.apiKeyEnvVar - A custom environment-variable name from which to read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
784
792
  * @returns The table, so methods can be chained.
785
793
  * @category Loading Data
786
794
  *
787
795
  * @example
788
796
  * ```ts
797
+ * // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
789
798
  * // Load data from a Datawrapper chart
790
799
  * const chartData = await sdb
791
800
  * .newTable("chartData")
@@ -800,11 +809,11 @@ class SimpleTable extends index_js_1.SimpleTable {
800
809
  /**
801
810
  * Writes the table's geospatial data as GeoJSON to a Datawrapper map.
802
811
  *
803
- * Authentication is handled via an API key stored in the environment variable `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`.
812
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for example, `"your-datawrapper-api-key"`).
804
813
  *
805
814
  * @param chartId - The unique ID of the Datawrapper map to update. This ID can be found in the Datawrapper URL or dashboard.
806
815
  * @param options - An optional object with configuration options:
807
- * @param options.apiKeyEnvVar - The name of the environment variable that stores your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to `"DATAWRAPPER_KEY"`.
816
+ * @param options.apiKeyEnvVar - A custom environment-variable name from which to read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
808
817
  * @param options.column - The name of the geometry column to use. If omitted, the method will automatically attempt to find a geometry column.
809
818
  * @param options.note - A string to update the map's notes field with.
810
819
  * @param options.republish - If `true`, republishes the map after updating the data. Defaults to `false`.
@@ -813,6 +822,7 @@ class SimpleTable extends index_js_1.SimpleTable {
813
822
  *
814
823
  * @example
815
824
  * ```ts
825
+ * // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
816
826
  * // Load, transform, and send geospatial data to a Datawrapper map
817
827
  * await sdb
818
828
  * .newTable()
@@ -836,19 +846,20 @@ class SimpleTable extends index_js_1.SimpleTable {
836
846
  /**
837
847
  * Loads geospatial data from a Datawrapper map into the table.
838
848
  *
839
- * Authentication is handled via an API key stored in the environment variable `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`.
849
+ * Environment variables are named configuration values supplied to the running process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for example, `"your-datawrapper-api-key"`).
840
850
  *
841
851
  * The data is temporarily written to `.sda-cache/tmp/dataviz/<uuid>.geojson` and removed after loading. Remember to add `.sda-cache` to your `.gitignore`.
842
852
  * The download is queued and runs in chain order at the next awaited observer or `run()` call.
843
853
  *
844
854
  * @param chartId - The unique ID of the Datawrapper map. This ID can be found in the Datawrapper URL or dashboard.
845
855
  * @param options - An optional object with configuration options:
846
- * @param options.apiKeyEnvVar - The name of the environment variable that stores your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to `"DATAWRAPPER_KEY"`.
856
+ * @param options.apiKeyEnvVar - A custom environment-variable name from which to read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
847
857
  * @returns The table, so methods can be chained.
848
858
  * @category Loading Data
849
859
  *
850
860
  * @example
851
861
  * ```ts
862
+ * // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
852
863
  * // Load geo data from a Datawrapper map
853
864
  * const mapData = await sdb
854
865
  * .newTable("mapData")