nosible 0.2.18 → 0.2.20

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/README.md CHANGED
@@ -46,6 +46,8 @@ bun add nosible
46
46
 
47
47
  ## 🔑 Authentication
48
48
 
49
+ > **⚠️ Important:** If you are using version 2 API keys (`nos_sk_...` ), please upgrade to nosible version 0.2.16 or later.
50
+
49
51
  1. Sign in to [NOSIBLE.AI](https://www.nosible.ai/) and grab your free API key.
50
52
  2. Set it as an environment variable or pass directly:
51
53
 
@@ -294,7 +296,7 @@ trends.data.forEach((point) => {
294
296
  // Trend analysis with filtering
295
297
  const filteredTrends = await client.topicTrend(
296
298
  "machine learning",
297
- 'continent = "North America" AND published >= "2023-01-01"'
299
+ 'continent = "North America" AND published >= "2023-01-01"',
298
300
  );
299
301
  ```
300
302
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nosible",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "TypeScript client for the Nosible AI Search API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -3,13 +3,15 @@ import {mapSnippetToArray, WebPageData} from "./webPageData";
3
3
  import type {ScrapeResponse, Snippet} from "./types";
4
4
  import type {NosibleClient} from "../client";
5
5
  import {readFile, unlink} from "node:fs/promises";
6
+ import {tmpdir} from "node:os";
7
+ import {join} from "node:path";
6
8
 
7
9
  // Helper function to create a mock snippet
8
10
  export const createMockSnippet = (
9
11
  snippet_hash: string,
10
12
  prev_snippet_hash: string | null,
11
13
  next_snippet_hash: string | null,
12
- content: string = "Test content"
14
+ content: string = "Test content",
13
15
  ): Snippet => ({
14
16
  url_hash: "test_url_hash",
15
17
  snippet_hash,
@@ -21,7 +23,7 @@ export const createMockSnippet = (
21
23
 
22
24
  // Helper function to create a minimal mock ScrapeResponse
23
25
  export const createMockScrapeResponse = (
24
- snippets: Record<string, Snippet>
26
+ snippets: Record<string, Snippet>,
25
27
  ): ScrapeResponse => ({
26
28
  request: {
27
29
  raw_url: "https://example.com",
@@ -76,7 +78,7 @@ describe("mapSnippetToArray", () => {
76
78
  "hash2",
77
79
  "hash1",
78
80
  "hash3",
79
- "Second snippet"
81
+ "Second snippet",
80
82
  );
81
83
  const snippet3 = createMockSnippet("hash3", "hash2", null, "Third snippet");
82
84
 
@@ -172,7 +174,7 @@ describe("mapSnippetToArray", () => {
172
174
  hash,
173
175
  prevHash,
174
176
  nextHash,
175
- `Snippet ${i}`
177
+ `Snippet ${i}`,
176
178
  );
177
179
  }
178
180
 
@@ -251,7 +253,7 @@ describe("WebPageData round trip test", () => {
251
253
  "hash2",
252
254
  "hash1",
253
255
  "hash3",
254
- "Second snippet"
256
+ "Second snippet",
255
257
  );
256
258
  const snippet3 = createMockSnippet("hash3", "hash2", null, "Third snippet");
257
259
 
@@ -266,7 +268,7 @@ describe("WebPageData round trip test", () => {
266
268
  const webPageData1 = new WebPageData(mockClient, mockResponse);
267
269
 
268
270
  // Step 2: Write to JSON file (first time)
269
- const jsonPath1 = "/tmp/test-webpage-data-1.json";
271
+ const jsonPath1 = join(tmpdir(), "test-webpage-data-1.json");
270
272
  testFiles.push(jsonPath1);
271
273
  await webPageData1.writeJson(jsonPath1);
272
274
 
@@ -274,7 +276,7 @@ describe("WebPageData round trip test", () => {
274
276
  const webPageData2 = await WebPageData.fromJson(mockClient, jsonPath1);
275
277
 
276
278
  // Step 4: Write to JSON file again (second time)
277
- const jsonPath2 = "/tmp/test-webpage-data-2.json";
279
+ const jsonPath2 = join(tmpdir(), "test-webpage-data-2.json");
278
280
  testFiles.push(jsonPath2);
279
281
  await webPageData2.writeJson(jsonPath2);
280
282
 
@@ -1,6 +1,8 @@
1
1
  import {describe, test, expect, afterEach} from "bun:test";
2
2
  import {importCsv, exportCsv} from "./file";
3
3
  import {writeFile, unlink} from "node:fs/promises";
4
+ import {tmpdir} from "node:os";
5
+ import {join} from "node:path";
4
6
 
5
7
  describe("importCsv", () => {
6
8
  const testFiles: string[] = [];
@@ -23,9 +25,9 @@ John Doe,30,New York
23
25
  Jane Smith,25,Los Angeles
24
26
  Bob Johnson,35,Chicago`;
25
27
 
26
- const testFilePath = "/tmp/test-import.csv";
28
+ const testFilePath = join(tmpdir(), "test-import.csv");
27
29
  testFiles.push(testFilePath);
28
-
30
+
29
31
  await writeFile(testFilePath, csvContent);
30
32
 
31
33
  const result = await importCsv({filePath: testFilePath});
@@ -38,9 +40,9 @@ Bob Johnson,35,Chicago`;
38
40
  });
39
41
 
40
42
  test("should handle empty CSV file", async () => {
41
- const testFilePath = "/tmp/test-empty.csv";
43
+ const testFilePath = join(tmpdir(), "test-empty.csv");
42
44
  testFiles.push(testFilePath);
43
-
45
+
44
46
  await writeFile(testFilePath, "");
45
47
 
46
48
  const result = await importCsv({filePath: testFilePath});
@@ -50,9 +52,9 @@ Bob Johnson,35,Chicago`;
50
52
 
51
53
  test("should handle CSV with only headers", async () => {
52
54
  const csvContent = "name,age,city";
53
- const testFilePath = "/tmp/test-headers-only.csv";
55
+ const testFilePath = join(tmpdir(), "test-headers-only.csv");
54
56
  testFiles.push(testFilePath);
55
-
57
+
56
58
  await writeFile(testFilePath, csvContent);
57
59
 
58
60
  const result = await importCsv({filePath: testFilePath});
@@ -66,7 +68,7 @@ Bob Johnson,35,Chicago`;
66
68
  {name: "Charlie", age: 32, city: "Seattle"},
67
69
  ];
68
70
 
69
- const exportPath = "/tmp/test-roundtrip.csv";
71
+ const exportPath = join(tmpdir(), "test-roundtrip.csv");
70
72
  testFiles.push(exportPath);
71
73
 
72
74
  // Export to CSV