@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.
package/llm.md CHANGED
@@ -600,6 +600,7 @@ const employees = await sdb
600
600
  .newTable("employees")
601
601
  .loadData("./employees.csv")
602
602
  .log();
603
+
603
604
  // Close the database connection and clean up resources
604
605
  await sdb.close();
605
606
  ```
@@ -663,13 +664,16 @@ pool with configurable batching and concurrency.
663
664
  This method automatically appends instructions to your prompt; set `verbose` to
664
665
  `true` to see the full prompt.
665
666
 
666
- This method supports Gemini, Vertex AI, and Ollama. Set `generation.provider`
667
- explicitly, or omit it to use `AI_PROVIDER`. All other `generation` fields match
668
- the selected `askGemini` or `askOllama` function from journalism-ai. Model and
669
- credentials can also come from environment variables.
667
+ This method supports Gemini, Vertex AI, and Ollama.
670
668
 
671
- For Ollama, set `AI_PROVIDER=ollama`, ensure Ollama is running, and set
672
- `AI_MODEL`, or pass `{ provider: "ollama", ... }` through `generation`.
669
+ Environment variables are named configuration values supplied to the running
670
+ process. By default, this method reads `AI_PROVIDER` (`"gemini"` or `"ollama"`;
671
+ defaults to `"gemini"`), `AI_MODEL` (for example, `"gemini-3-flash-preview"` or
672
+ `"gemma3:4b"`), and, for Gemini, either `AI_KEY` (for example,
673
+ `"your-gemini-api-key"`) or both `AI_PROJECT` (for example,
674
+ `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`).
675
+ Values passed through `generation` override the corresponding environment
676
+ values. When using Ollama, ensure it is running.
673
677
 
674
678
  To manage rate limits, use `batchSize` to process multiple rows per request and
675
679
  `rateLimitPerMinute` to pace requests across the worker pool. The `concurrency`
@@ -713,9 +717,7 @@ aiRowByRow(column: string, newColumn: string | string[], prompt: string, options
713
717
  are stored. When omitted, a failed batch throws.
714
718
  - **`options.logProgress`**: If `true`, logs request-pool progress. Defaults to
715
719
  `false`.
716
- - **`options.generation`**: Gemini or Ollama generation configuration. Set
717
- `provider` explicitly or omit it to use environment selection; all other
718
- fields match the selected journalism-ai function.
720
+ - **`options.generation`**: Optional Gemini or Ollama generation configuration.
719
721
  - **`options.test`**: A function to validate the returned data. If it throws an
720
722
  error, the request will be retried (if `retry` is set). Defaults to
721
723
  `undefined`.
@@ -788,6 +790,10 @@ const people = await sdb
788
790
  ```
789
791
 
790
792
  ```ts
793
+ // Set these environment variables before running:
794
+ // AI_PROVIDER=gemini
795
+ // AI_MODEL=gemini-3-flash-preview
796
+ // AI_KEY=your-gemini-api-key
791
797
  const cities = await sdb
792
798
  .newTable("cities")
793
799
  .loadArray([
@@ -826,14 +832,16 @@ const names = await sdb
826
832
  Generates embeddings for a specified text column and stores the results in a new
827
833
  column.
828
834
 
829
- This method supports Gemini, Vertex AI, and Ollama embeddings. Set
830
- `embeddings.provider` explicitly or omit it to use `AI_EMBEDDINGS_PROVIDER`; all
831
- other fields match `getEmbedding` from journalism-ai. Model and credentials can
832
- also come from environment variables.
835
+ This method supports Gemini, Vertex AI, and Ollama embeddings.
833
836
 
834
- For Ollama, set `AI_EMBEDDINGS_PROVIDER=ollama`, ensure Ollama is running, and
835
- set `AI_EMBEDDINGS_MODEL`, or pass `{ provider: "ollama", ... }` through
836
- `embeddings`.
837
+ Environment variables are named configuration values supplied to the running
838
+ process. By default, this method reads `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or
839
+ `"ollama"`; defaults to `"gemini"`), `AI_EMBEDDINGS_MODEL` (for example,
840
+ `"gemini-embedding-001"` or `"nomic-embed-text"`), and, for Gemini, either
841
+ `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for
842
+ example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example,
843
+ `"us-central1"`). Values passed through `embeddings` override the corresponding
844
+ environment values. When using Ollama, ensure it is running.
837
845
 
838
846
  To manage rate limits, use `rateLimitPerMinute` to introduce delays between
839
847
  requests. For higher rate limits (business/professional accounts), `concurrency`
@@ -886,9 +894,7 @@ aiEmbeddings(column: string, newColumn: string, options?: { embeddings?: { provi
886
894
  time and memory usage. Defaults to 16.
887
895
  - **`options.concurrency`**: The number of concurrent requests to send. Defaults
888
896
  to `1`.
889
- - **`options.embeddings`**: Gemini or Ollama embedding configuration. Set
890
- `provider` explicitly or omit it to use environment selection; all other
891
- fields match `getEmbedding` from journalism-ai.
897
+ - **`options.embeddings`**: Optional Gemini or Ollama embedding configuration.
892
898
  - **`options.rateLimitPerMinute`**: The rate limit for AI requests in requests
893
899
  per minute. The method will wait between requests if necessary. Defaults to
894
900
  `undefined` (no limit).
@@ -902,6 +908,10 @@ The table, so methods can be chained.
902
908
  ##### Examples
903
909
 
904
910
  ```ts
911
+ // Set these environment variables before running:
912
+ // AI_EMBEDDINGS_PROVIDER=gemini
913
+ // AI_EMBEDDINGS_MODEL=gemini-embedding-001
914
+ // AI_KEY=your-gemini-api-key
905
915
  const food = await sdb
906
916
  .newTable("food")
907
917
  .loadArray([
@@ -913,10 +923,6 @@ const food = await sdb
913
923
  { food: "tacos" },
914
924
  ])
915
925
  .aiEmbeddings("food", "embeddings", {
916
- embeddings: {
917
- provider: "gemini",
918
- model: "gemini-embedding-001",
919
- },
920
926
  rateLimitPerMinute: 15,
921
927
  createIndex: true,
922
928
  verbose: true,
@@ -940,8 +946,14 @@ content based on their embeddings. This method is useful for semantic search and
940
946
  text similarity tasks, computing cosine distance and sorting results by
941
947
  similarity.
942
948
 
943
- To create the query embedding, omit `embeddings` to use environment variables or
944
- pass provider-specific options matching `getEmbedding` from journalism-ai.
949
+ Environment variables are named configuration values supplied to the running
950
+ process. By default, this method reads `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or
951
+ `"ollama"`; defaults to `"gemini"`), `AI_EMBEDDINGS_MODEL` (for example,
952
+ `"gemini-embedding-001"` or `"nomic-embed-text"`), and, for Gemini, either
953
+ `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for
954
+ example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example,
955
+ `"us-central1"`). Values passed through `embeddings` override the corresponding
956
+ environment values.
945
957
 
946
958
  Gemini, Vertex AI, and Ollama are supported. The selected provider and model
947
959
  must match those used to create the stored embedding column so the vectors share
@@ -994,9 +1006,7 @@ aiVectorSimilarity(text: string, column: string, nbResults: number, options?: {
994
1006
  - **`options.outputTable`**: The name of the output table where the results will
995
1007
  be stored. If not provided, the current table will be modified. Defaults to
996
1008
  `undefined`.
997
- - **`options.embeddings`**: Gemini or Ollama embedding configuration. Set
998
- `provider` explicitly or omit it to use environment selection; all other
999
- fields match `getEmbedding` from journalism-ai.
1009
+ - **`options.embeddings`**: Optional Gemini or Ollama embedding configuration.
1000
1010
  - **`options.verbose`**: If `true`, logs additional debugging information.
1001
1011
  Defaults to `false`.
1002
1012
 
@@ -1007,6 +1017,10 @@ The table that will contain the similarity results, so methods can be chained.
1007
1017
  ##### Examples
1008
1018
 
1009
1019
  ```ts
1020
+ // Set these environment variables before running:
1021
+ // AI_EMBEDDINGS_PROVIDER=gemini
1022
+ // AI_EMBEDDINGS_MODEL=gemini-embedding-001
1023
+ // AI_KEY=your-gemini-api-key
1010
1024
  const similarFood = await sdb
1011
1025
  .newTable("food")
1012
1026
  .loadArray([
@@ -1017,18 +1031,9 @@ const similarFood = await sdb
1017
1031
  { food: "salad" },
1018
1032
  { food: "tacos" },
1019
1033
  ])
1020
- .aiEmbeddings("food", "embeddings", {
1021
- embeddings: {
1022
- provider: "gemini",
1023
- model: "gemini-embedding-001",
1024
- },
1025
- })
1034
+ .aiEmbeddings("food", "embeddings")
1026
1035
  .aiVectorSimilarity("italian food", "embeddings", 3, {
1027
1036
  createIndex: true,
1028
- embeddings: {
1029
- provider: "gemini",
1030
- model: "gemini-embedding-001",
1031
- },
1032
1037
  minSimilarity: 0.6,
1033
1038
  similarityColumn: "score",
1034
1039
  })
@@ -1070,9 +1075,16 @@ before replacement. This provenance survives reopening a DuckDB database.
1070
1075
  Remove `.journalism-cache` and `.sda-cache` to clear existing cache entries.
1071
1076
  Remember to add both directories to your `.gitignore`.
1072
1077
 
1073
- This method supports Gemini, Vertex AI, and Ollama embeddings. Set
1074
- `embeddings.provider` explicitly or omit it to use environment selection; all
1075
- other fields match `getEmbedding` from journalism-ai.
1078
+ This method supports Gemini, Vertex AI, and Ollama embeddings.
1079
+
1080
+ Environment variables are named configuration values supplied to the running
1081
+ process. By default, this method reads `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or
1082
+ `"ollama"`; defaults to `"gemini"`), `AI_EMBEDDINGS_MODEL` (for example,
1083
+ `"gemini-embedding-001"` or `"nomic-embed-text"`), and, for Gemini, either
1084
+ `AI_KEY` (for example, `"your-gemini-api-key"`) or both `AI_PROJECT` (for
1085
+ example, `"my-google-cloud-project"`) and `AI_LOCATION` (for example,
1086
+ `"us-central1"`). Values passed through `embeddings` override the corresponding
1087
+ environment values.
1076
1088
 
1077
1089
  The selected embedding provider is used for both stored row embeddings and the
1078
1090
  query embedding.
@@ -1100,9 +1112,7 @@ hybridSearch(query: string, idColumn: string, textColumn: string, nbResults: num
1100
1112
  through.
1101
1113
  - **`nbResults`**: The number of most similar rows to retrieve.
1102
1114
  - **`options`**: Configuration options for the hybrid search.
1103
- - **`options.embeddings`**: Gemini or Ollama embedding configuration. Set
1104
- `provider` explicitly or omit it to use environment selection; all other
1105
- fields match `getEmbedding` from journalism-ai.
1115
+ - **`options.embeddings`**: Optional Gemini or Ollama embedding configuration.
1106
1116
  - **`options.verbose`**: If `true`, logs additional debugging information.
1107
1117
  Defaults to `false`.
1108
1118
  - **`options.createIndex`**: If `true`, creates an HNSW index when vector search
@@ -1169,16 +1179,16 @@ The table that will contain the search results, so methods can be chained.
1169
1179
  ##### Examples
1170
1180
 
1171
1181
  ```ts
1182
+ // Set these environment variables before running:
1183
+ // AI_EMBEDDINGS_PROVIDER=gemini
1184
+ // AI_EMBEDDINGS_MODEL=gemini-embedding-001
1185
+ // AI_KEY=your-gemini-api-key
1172
1186
  // Load a dataset of recipes
1173
1187
  const sdb = new SimpleDB();
1174
1188
  const results = await sdb
1175
1189
  .newTable("recipes")
1176
1190
  .loadData("recipes.parquet")
1177
1191
  .hybridSearch("buttery pastry for breakfast", "Dish", "Recipe", 10, {
1178
- embeddings: {
1179
- provider: "gemini",
1180
- model: "gemini-embedding-001",
1181
- },
1182
1192
  verbose: true,
1183
1193
  })
1184
1194
  .log();
@@ -1215,13 +1225,22 @@ corresponding caches.
1215
1225
  Remove `.journalism-cache` and `.sda-cache` to clear existing cache entries.
1216
1226
  Remember to add both directories to your `.gitignore`.
1217
1227
 
1218
- Generation and embeddings are independently configurable. Set either nested
1219
- `provider` explicitly or omit it to use that provider's environment selection;
1220
- all remaining fields match journalism-ai.
1228
+ Generation and embeddings are independently configurable.
1229
+
1230
+ Environment variables are named configuration values supplied to the running
1231
+ process. By default, generation reads `AI_PROVIDER` (`"gemini"` or `"ollama"`;
1232
+ defaults to `"gemini"`) and `AI_MODEL` (for example, `"gemini-3-flash-preview"`
1233
+ or `"gemma3:4b"`), while embeddings read `AI_EMBEDDINGS_PROVIDER` (`"gemini"` or
1234
+ `"ollama"`; defaults to `"gemini"`) and `AI_EMBEDDINGS_MODEL` (for example,
1235
+ `"gemini-embedding-001"` or `"nomic-embed-text"`). Gemini generation and
1236
+ embeddings also read either `AI_KEY` (for example, `"your-gemini-api-key"`) or
1237
+ both `AI_PROJECT` (for example, `"my-google-cloud-project"`) and `AI_LOCATION`
1238
+ (for example, `"us-central1"`). Values passed through either option override its
1239
+ environment defaults.
1221
1240
 
1222
1241
  For example, `generation.provider` can be `"gemini"` while `embeddings.provider`
1223
- is `"ollama"`. Environment-only mixed providers use `AI_PROVIDER` and
1224
- `AI_EMBEDDINGS_PROVIDER`.
1242
+ is `"ollama"`; the same mix can be selected through `AI_PROVIDER=gemini` and
1243
+ `AI_EMBEDDINGS_PROVIDER=ollama`.
1225
1244
 
1226
1245
  Ollama temperature defaults to 0. Gemini uses the provider's default
1227
1246
  temperature.
@@ -1249,12 +1268,8 @@ async aiRAG(query: string, idColumn: string, textColumn: string, nbResults: numb
1249
1268
  - **`nbResults`**: The number of most similar rows to retrieve and use as
1250
1269
  context for the AI.
1251
1270
  - **`options`**: Configuration options for the RAG process.
1252
- - **`options.generation`**: Gemini or Ollama generation configuration. Set
1253
- `provider` explicitly or omit it to use environment selection; all other
1254
- relevant fields match the selected journalism-ai function.
1255
- - **`options.embeddings`**: Gemini or Ollama embedding configuration. Set
1256
- `provider` explicitly or omit it to use environment selection; all other
1257
- fields match `getEmbedding` from journalism-ai.
1271
+ - **`options.generation`**: Optional Gemini or Ollama generation configuration.
1272
+ - **`options.embeddings`**: Optional Gemini or Ollama embedding configuration.
1258
1273
  - **`options.verbose`**: If `true`, logs additional debugging information.
1259
1274
  Defaults to `false`.
1260
1275
  - **`options.includeThoughts`**: If `true`, includes the AI model's reasoning
@@ -1323,6 +1338,12 @@ context.
1323
1338
  ##### Examples
1324
1339
 
1325
1340
  ```ts
1341
+ // Set these environment variables before running:
1342
+ // AI_PROVIDER=gemini
1343
+ // AI_MODEL=gemini-3-flash-preview
1344
+ // AI_KEY=your-gemini-api-key
1345
+ // AI_EMBEDDINGS_PROVIDER=ollama
1346
+ // AI_EMBEDDINGS_MODEL=nomic-embed-text
1326
1347
  // Load a dataset of recipes
1327
1348
  const sdb = new SimpleDB();
1328
1349
  const answer = await sdb
@@ -1333,17 +1354,7 @@ const answer = await sdb
1333
1354
  "Dish", // Column with unique IDs
1334
1355
  "Recipe", // Column with text to search
1335
1356
  10, // The 10 most relevant recipes passed to the LLM
1336
- {
1337
- generation: {
1338
- provider: "gemini",
1339
- model: "gemini-3-flash-preview",
1340
- },
1341
- embeddings: {
1342
- provider: "ollama",
1343
- model: "nomic-embed-text",
1344
- },
1345
- verbose: true, // Log debugging information and timings
1346
- },
1357
+ { verbose: true }, // Log debugging information and timings
1347
1358
  );
1348
1359
 
1349
1360
  console.log(answer);
@@ -1371,12 +1382,16 @@ Generates and executes a SQL query based on a prompt. Additional instructions,
1371
1382
  such as column types, are automatically added to your prompt. Set `verbose` to
1372
1383
  `true` to see the full prompt.
1373
1384
 
1374
- This method supports Gemini, Vertex AI, and Ollama. Set `generation.provider`
1375
- explicitly or omit it to use environment selection; all other relevant fields
1376
- match `askGemini` or `askOllama` from journalism-ai.
1385
+ This method supports Gemini, Vertex AI, and Ollama.
1377
1386
 
1378
- For Ollama, set `AI_PROVIDER=ollama`, ensure Ollama is running, and set
1379
- `AI_MODEL`, or pass `{ provider: "ollama", ... }` through `generation`.
1387
+ Environment variables are named configuration values supplied to the running
1388
+ process. By default, this method reads `AI_PROVIDER` (`"gemini"` or `"ollama"`;
1389
+ defaults to `"gemini"`), `AI_MODEL` (for example, `"gemini-3-flash-preview"` or
1390
+ `"gemma3:4b"`), and, for Gemini, either `AI_KEY` (for example,
1391
+ `"your-gemini-api-key"`) or both `AI_PROJECT` (for example,
1392
+ `"my-google-cloud-project"`) and `AI_LOCATION` (for example, `"us-central1"`).
1393
+ Values passed through `generation` override the corresponding environment
1394
+ values. When using Ollama, ensure it is running.
1380
1395
 
1381
1396
  Ollama temperature defaults to 0, while Gemini uses the provider's default.
1382
1397
  Provider-specific controls live under `generation`.
@@ -1398,9 +1413,7 @@ aiQuery(prompt: string, options?: { extraInstructions?: string; generation?: { s
1398
1413
  - **`options`**: Configuration options for the AI request.
1399
1414
  - **`options.extraInstructions`**: Additional instructions to append to the
1400
1415
  prompt, providing more context or guidance for the AI.
1401
- - **`options.generation`**: Gemini or Ollama generation configuration. Set
1402
- `provider` explicitly or omit it to use environment selection; all other
1403
- relevant fields match the selected journalism-ai function.
1416
+ - **`options.generation`**: Optional Gemini or Ollama generation configuration.
1404
1417
  - **`options.outputTable`**: The name of a new table where the results will be
1405
1418
  stored. If not provided, the current table will be replaced with the query
1406
1419
  results.
@@ -1417,16 +1430,16 @@ The table that will contain the query results, so methods can be chained.
1417
1430
  ##### Examples
1418
1431
 
1419
1432
  ```ts
1433
+ // Set these environment variables before running:
1434
+ // AI_PROVIDER=gemini
1435
+ // AI_MODEL=gemini-3-flash-preview
1436
+ // AI_KEY=your-gemini-api-key
1420
1437
  // The AI will generate a query that will be executed, and
1421
1438
  // the result will replace the existing table.
1422
1439
  // If run again, it will use the previous query from the cache.
1423
1440
  // Don't forget to add .journalism-cache to your .gitignore file!
1424
1441
  const averageSalaryByDepartment = await table
1425
1442
  .aiQuery("Give me the average salary by department", {
1426
- generation: {
1427
- provider: "gemini",
1428
- model: "gemini-3-flash-preview",
1429
- },
1430
1443
  verbose: true,
1431
1444
  })
1432
1445
  .log();
@@ -1464,11 +1477,16 @@ function from the
1464
1477
  its documentation for more details.
1465
1478
 
1466
1479
  By default, the selected tab is overwritten and values are written without
1467
- Google Sheets interpretation. Authentication is handled via environment
1468
- variables (GOOGLE_PRIVATE_KEY and GOOGLE_SERVICE_ACCOUNT_EMAIL). Alternatively,
1469
- you can use GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON
1470
- file. For detailed setup instructions, refer to the node-google-spreadsheet
1471
- authentication guide:
1480
+ Google Sheets interpretation.
1481
+
1482
+ Environment variables are named configuration values supplied to the running
1483
+ process. For authentication, this method reads `GOOGLE_SERVICE_ACCOUNT_EMAIL`
1484
+ (for example, `"service-account@example.iam.gserviceaccount.com"`) with
1485
+ `GOOGLE_PRIVATE_KEY` (for example, `"-----BEGIN PRIVATE KEY-----\n..."`).
1486
+ Alternatively, set `GOOGLE_APPLICATION_CREDENTIALS` to a service-account JSON
1487
+ path (for example, `"./service-account.json"`). Values passed through
1488
+ `options.credentials` override these environment values. For detailed setup
1489
+ instructions, refer to the node-google-spreadsheet authentication guide:
1472
1490
  https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication.
1473
1491
 
1474
1492
  ##### Signature
@@ -1493,9 +1511,7 @@ async toSheet(sheetUrl: string, options?: { mode?: "overwrite" | "append"; tabTi
1493
1511
  time zone to use it for the timestamp. Available only in overwrite mode.
1494
1512
  - **`options.raw`**: If `true`, writes values without Google Sheets
1495
1513
  interpretation. Defaults to `true`.
1496
- - **`options.credentials`**: Explicit Google service-account credentials. These
1497
- override credentials provided through environment variables or
1498
- GOOGLE_APPLICATION_CREDENTIALS.
1514
+ - **`options.credentials`**: Optional Google service-account credentials.
1499
1515
  - **`options.credentials.email`**: The Google service-account email.
1500
1516
  - **`options.credentials.privateKey`**: The Google service-account private key.
1501
1517
 
@@ -1506,6 +1522,9 @@ A promise that resolves when the data has been written to the sheet.
1506
1522
  ##### Examples
1507
1523
 
1508
1524
  ```ts
1525
+ // Set these environment variables before running:
1526
+ // GOOGLE_SERVICE_ACCOUNT_EMAIL=service-account@example.iam.gserviceaccount.com
1527
+ // GOOGLE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\n...
1509
1528
  // Load, transform, and write data to a Google Sheet
1510
1529
  await sdb
1511
1530
  .newTable()
@@ -1560,14 +1579,13 @@ Loads data from a Google Sheet into the table. This method uses the
1560
1579
  [journalism library](https://jsr.io/@nshiab/journalism). Refer to its
1561
1580
  documentation for more details.
1562
1581
 
1563
- By default, authentication is handled via environment variables
1564
- (GOOGLE_PRIVATE_KEY and GOOGLE_SERVICE_ACCOUNT_EMAIL). Alternatively, you can
1565
- use GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file. For
1566
- detailed setup instructions, refer to the node-google-spreadsheet authentication
1567
- guide:
1568
- https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication.
1569
- The download is queued and runs in chain order at the next awaited observer or
1570
- `run()` call.
1582
+ Environment variables are named configuration values supplied to the running
1583
+ process. By default, this method reads `GOOGLE_SERVICE_ACCOUNT_EMAIL` (for
1584
+ example, `"service-account@example.iam.gserviceaccount.com"`) with
1585
+ `GOOGLE_PRIVATE_KEY` (for example, `"-----BEGIN PRIVATE KEY-----\n..."`).
1586
+ Alternatively, set `GOOGLE_APPLICATION_CREDENTIALS` to a service-account JSON
1587
+ path (for example, `"./service-account.json"`). The download is queued and runs
1588
+ in chain order at the next awaited observer or `run()` call.
1571
1589
 
1572
1590
  ##### Signature
1573
1591
 
@@ -1583,10 +1601,12 @@ loadSheet(sheetUrl: string, options?: { skip?: number; apiEmailEnvVar?: string;
1583
1601
  - **`options.skip`**: The number of rows to skip from the top of the sheet
1584
1602
  before reading data. Useful when the sheet contains metadata or headers that
1585
1603
  should not be included in the data.
1586
- - **`options.apiEmailEnvVar`**: The name of the environment variable that stores
1587
- your API email.
1588
- - **`options.apiKeyEnvVar`**: The name of the environment variable that stores
1589
- your API key.
1604
+ - **`options.apiEmailEnvVar`**: A custom environment-variable name from which to
1605
+ read the Google service-account email. Defaults to
1606
+ `"GOOGLE_SERVICE_ACCOUNT_EMAIL"`.
1607
+ - **`options.apiKeyEnvVar`**: A custom environment-variable name from which to
1608
+ read the Google service-account private key. Defaults to
1609
+ `"GOOGLE_PRIVATE_KEY"`.
1590
1610
 
1591
1611
  ##### Returns
1592
1612
 
@@ -1595,6 +1615,9 @@ The table, so methods can be chained.
1595
1615
  ##### Examples
1596
1616
 
1597
1617
  ```ts
1618
+ // Set these environment variables before running:
1619
+ // GOOGLE_SERVICE_ACCOUNT_EMAIL=service-account@example.iam.gserviceaccount.com
1620
+ // GOOGLE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\n...
1598
1621
  // Load data from a Google Sheet
1599
1622
  const sheetData = await sdb
1600
1623
  .newTable("sheetData")
@@ -1615,8 +1638,9 @@ const sheetData = await table
1615
1638
 
1616
1639
  Writes the table data as CSV to a Datawrapper chart or table.
1617
1640
 
1618
- Authentication is handled via an API key stored in the environment variable
1619
- `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`.
1641
+ Environment variables are named configuration values supplied to the running
1642
+ process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for
1643
+ example, `"your-datawrapper-api-key"`).
1620
1644
 
1621
1645
  ##### Signature
1622
1646
 
@@ -1629,9 +1653,8 @@ async toDatawrapper(chartId: string, options?: { apiKeyEnvVar?: string; note?: s
1629
1653
  - **`chartId`**: The unique ID of the Datawrapper chart or table to update. This
1630
1654
  ID can be found in the Datawrapper URL or dashboard.
1631
1655
  - **`options`**: An optional object with configuration options:
1632
- - **`options.apiKeyEnvVar`**: The name of the environment variable that stores
1633
- your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to
1634
- `"DATAWRAPPER_KEY"`.
1656
+ - **`options.apiKeyEnvVar`**: A custom environment-variable name from which to
1657
+ read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
1635
1658
  - **`options.note`**: A string to update the chart's notes field with (e.g., a
1636
1659
  last-updated timestamp).
1637
1660
  - **`options.republish`**: If `true`, republishes the chart after updating the
@@ -1644,6 +1667,7 @@ A promise that resolves when the data has been sent to Datawrapper.
1644
1667
  ##### Examples
1645
1668
 
1646
1669
  ```ts
1670
+ // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
1647
1671
  // Load, transform, and send data to a Datawrapper chart
1648
1672
  await sdb
1649
1673
  .newTable()
@@ -1664,10 +1688,10 @@ await table.toDatawrapper("myChartId", {
1664
1688
 
1665
1689
  Loads data from a Datawrapper chart or table into the table.
1666
1690
 
1667
- Authentication is handled via an API key stored in the environment variable
1668
- `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`. The
1669
- download is queued and runs in chain order at the next awaited observer or
1670
- `run()` call.
1691
+ Environment variables are named configuration values supplied to the running
1692
+ process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for
1693
+ example, `"your-datawrapper-api-key"`). The download is queued and runs in chain
1694
+ order at the next awaited observer or `run()` call.
1671
1695
 
1672
1696
  ##### Signature
1673
1697
 
@@ -1680,9 +1704,8 @@ loadDatawrapper(chartId: string, options?: { apiKeyEnvVar?: string }): this;
1680
1704
  - **`chartId`**: The unique ID of the Datawrapper chart or table. This ID can be
1681
1705
  found in the Datawrapper URL or dashboard.
1682
1706
  - **`options`**: An optional object with configuration options:
1683
- - **`options.apiKeyEnvVar`**: The name of the environment variable that stores
1684
- your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to
1685
- `"DATAWRAPPER_KEY"`.
1707
+ - **`options.apiKeyEnvVar`**: A custom environment-variable name from which to
1708
+ read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
1686
1709
 
1687
1710
  ##### Returns
1688
1711
 
@@ -1691,6 +1714,7 @@ The table, so methods can be chained.
1691
1714
  ##### Examples
1692
1715
 
1693
1716
  ```ts
1717
+ // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
1694
1718
  // Load data from a Datawrapper chart
1695
1719
  const chartData = await sdb
1696
1720
  .newTable("chartData")
@@ -1702,8 +1726,9 @@ const chartData = await sdb
1702
1726
 
1703
1727
  Writes the table's geospatial data as GeoJSON to a Datawrapper map.
1704
1728
 
1705
- Authentication is handled via an API key stored in the environment variable
1706
- `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`.
1729
+ Environment variables are named configuration values supplied to the running
1730
+ process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for
1731
+ example, `"your-datawrapper-api-key"`).
1707
1732
 
1708
1733
  ##### Signature
1709
1734
 
@@ -1716,9 +1741,8 @@ async toGeoDatawrapper(chartId: string, options?: { apiKeyEnvVar?: string; colum
1716
1741
  - **`chartId`**: The unique ID of the Datawrapper map to update. This ID can be
1717
1742
  found in the Datawrapper URL or dashboard.
1718
1743
  - **`options`**: An optional object with configuration options:
1719
- - **`options.apiKeyEnvVar`**: The name of the environment variable that stores
1720
- your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to
1721
- `"DATAWRAPPER_KEY"`.
1744
+ - **`options.apiKeyEnvVar`**: A custom environment-variable name from which to
1745
+ read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
1722
1746
  - **`options.column`**: The name of the geometry column to use. If omitted, the
1723
1747
  method will automatically attempt to find a geometry column.
1724
1748
  - **`options.note`**: A string to update the map's notes field with.
@@ -1732,6 +1756,7 @@ A promise that resolves when the data has been sent to Datawrapper.
1732
1756
  ##### Examples
1733
1757
 
1734
1758
  ```ts
1759
+ // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
1735
1760
  // Load, transform, and send geospatial data to a Datawrapper map
1736
1761
  await sdb
1737
1762
  .newTable()
@@ -1752,8 +1777,9 @@ await table.toGeoDatawrapper("myMapId", {
1752
1777
 
1753
1778
  Loads geospatial data from a Datawrapper map into the table.
1754
1779
 
1755
- Authentication is handled via an API key stored in the environment variable
1756
- `DATAWRAPPER_KEY`, or a custom variable name via `options.apiKeyEnvVar`.
1780
+ Environment variables are named configuration values supplied to the running
1781
+ process. By default, this method reads the API key from `DATAWRAPPER_KEY` (for
1782
+ example, `"your-datawrapper-api-key"`).
1757
1783
 
1758
1784
  The data is temporarily written to `.sda-cache/tmp/dataviz/<uuid>.geojson` and
1759
1785
  removed after loading. Remember to add `.sda-cache` to your `.gitignore`. The
@@ -1771,9 +1797,8 @@ loadGeoDatawrapper(chartId: string, options?: { apiKeyEnvVar?: string }): this;
1771
1797
  - **`chartId`**: The unique ID of the Datawrapper map. This ID can be found in
1772
1798
  the Datawrapper URL or dashboard.
1773
1799
  - **`options`**: An optional object with configuration options:
1774
- - **`options.apiKeyEnvVar`**: The name of the environment variable that stores
1775
- your Datawrapper API key (e.g., `"DATAWRAPPER_KEY"`). Defaults to
1776
- `"DATAWRAPPER_KEY"`.
1800
+ - **`options.apiKeyEnvVar`**: A custom environment-variable name from which to
1801
+ read the Datawrapper API key. Defaults to `"DATAWRAPPER_KEY"`.
1777
1802
 
1778
1803
  ##### Returns
1779
1804
 
@@ -1782,6 +1807,7 @@ The table, so methods can be chained.
1782
1807
  ##### Examples
1783
1808
 
1784
1809
  ```ts
1810
+ // Set DATAWRAPPER_KEY=your-datawrapper-api-key before running.
1785
1811
  // Load geo data from a Datawrapper map
1786
1812
  const mapData = await sdb
1787
1813
  .newTable("mapData")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nshiab/simple-data-analysis",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "Fast DuckDB-powered TypeScript library for tabular, geospatial, vector, AI, Google Sheets, and data visualization workflows on Deno, Node.js, and Bun.",
5
5
  "keywords": [
6
6
  "data-analysis",
@@ -20,6 +20,7 @@ import SimpleTable from "./SimpleTable.js";
20
20
  * .newTable("employees")
21
21
  * .loadData("./employees.csv")
22
22
  * .log();
23
+ *
23
24
  * // Close the database connection and clean up resources
24
25
  * await sdb.close();
25
26
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleDB.d.ts","sourceRoot":"","sources":["../../src/class/SimpleDB.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,qEAAqE,CAAC;AAC/G,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY,CAAC,WAAW,CAAC;IAC7D;;;;OAIG;IACM,UAAU,EAAE,OAAO,WAAW,CAAC;IAExC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;gBAED,OAAO,GAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;QAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KACb;CAMT"}
1
+ {"version":3,"file":"SimpleDB.d.ts","sourceRoot":"","sources":["../../src/class/SimpleDB.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,qEAAqE,CAAC;AAC/G,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY,CAAC,WAAW,CAAC;IAC7D;;;;OAIG;IACM,UAAU,EAAE,OAAO,WAAW,CAAC;IAExC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;gBAED,OAAO,GAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;QAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KACb;CAMT"}
@@ -25,6 +25,7 @@ const SimpleTable_js_1 = __importDefault(require("./SimpleTable.js"));
25
25
  * .newTable("employees")
26
26
  * .loadData("./employees.csv")
27
27
  * .log();
28
+ *
28
29
  * // Close the database connection and clean up resources
29
30
  * await sdb.close();
30
31
  * ```