triangle-utils 1.4.166 → 1.4.167
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/src/UtilsBrave.d.ts +10 -2
- package/dist/src/UtilsBrave.js +16 -4
- package/dist/src/f.js +2 -1
- package/package.json +1 -1
- package/src/UtilsBrave.ts +24 -4
- package/src/f.ts +2 -1
package/dist/src/UtilsBrave.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export declare class UtilsBrave {
|
|
2
2
|
private readonly brave_api_key?;
|
|
3
3
|
constructor(brave_api_key: string | undefined);
|
|
4
|
-
web_search(q: string
|
|
5
|
-
|
|
4
|
+
web_search(q: string, options?: {
|
|
5
|
+
min_date?: string;
|
|
6
|
+
max_date?: string;
|
|
7
|
+
verbosity?: number;
|
|
8
|
+
}): Promise<Record<string, any>[] | undefined>;
|
|
9
|
+
news_search(q: string, options?: {
|
|
10
|
+
min_date?: string;
|
|
11
|
+
max_date?: string;
|
|
12
|
+
verbosity?: number;
|
|
13
|
+
}): Promise<Record<string, any>[] | undefined>;
|
|
6
14
|
}
|
package/dist/src/UtilsBrave.js
CHANGED
|
@@ -3,12 +3,18 @@ export class UtilsBrave {
|
|
|
3
3
|
constructor(brave_api_key) {
|
|
4
4
|
this.brave_api_key = brave_api_key;
|
|
5
5
|
}
|
|
6
|
-
async web_search(q) {
|
|
6
|
+
async web_search(q, options = {}) {
|
|
7
|
+
const verbosity = options.verbosity || 0;
|
|
7
8
|
if (this.brave_api_key === undefined) {
|
|
8
9
|
return undefined;
|
|
9
10
|
}
|
|
10
11
|
try {
|
|
11
|
-
const
|
|
12
|
+
const freshness = options.min_date !== undefined && options.max_date !== undefined ? (options.min_date + "to" + options.max_date) : undefined;
|
|
13
|
+
const url = "https://api.search.brave.com/res/v1/web/search?q=" + encodeURIComponent(q) + (freshness !== undefined ? ("&freshness=" + freshness) : "");
|
|
14
|
+
if (verbosity > 0) {
|
|
15
|
+
console.log(url);
|
|
16
|
+
}
|
|
17
|
+
const response = await fetch(url, {
|
|
12
18
|
headers: {
|
|
13
19
|
"X-Subscription-Token": this.brave_api_key
|
|
14
20
|
}
|
|
@@ -29,12 +35,18 @@ export class UtilsBrave {
|
|
|
29
35
|
}
|
|
30
36
|
return undefined;
|
|
31
37
|
}
|
|
32
|
-
async news_search(q) {
|
|
38
|
+
async news_search(q, options = {}) {
|
|
39
|
+
const verbosity = options.verbosity || 0;
|
|
33
40
|
if (this.brave_api_key === undefined) {
|
|
34
41
|
return undefined;
|
|
35
42
|
}
|
|
36
43
|
try {
|
|
37
|
-
const
|
|
44
|
+
const freshness = options.min_date !== undefined && options.max_date !== undefined ? (options.min_date + "to" + options.max_date) : undefined;
|
|
45
|
+
const url = "https://api.search.brave.com/res/v1/news/search?q=" + encodeURIComponent(q) + (freshness !== undefined ? ("&freshness=" + freshness) : "");
|
|
46
|
+
if (verbosity > 0) {
|
|
47
|
+
console.log(url);
|
|
48
|
+
}
|
|
49
|
+
const response = await fetch(url, {
|
|
38
50
|
headers: {
|
|
39
51
|
"X-Subscription-Token": this.brave_api_key
|
|
40
52
|
}
|
package/dist/src/f.js
CHANGED
|
@@ -83,4 +83,5 @@ const utils = new TriangleUtils(config);
|
|
|
83
83
|
// .then(response => console.log(response))
|
|
84
84
|
// await utils.s3.get_download_url("s3://triangle-675045717295-us-east-1-an/tenant_documents/a3a9627f-a94d-4d47-a110-307a6f5563af/a146d789-da40-4e3c-a132-8b7110f3f7df.pdf", { name : "hye.pdf" })
|
|
85
85
|
// .then(response => console.log(response))
|
|
86
|
-
await utils.brave.
|
|
86
|
+
await utils.brave.news_search("abdul el sayed", { min_date: "2026-09-03", max_date: "2026-09-05" })
|
|
87
|
+
.then(console.log);
|
package/package.json
CHANGED
package/src/UtilsBrave.ts
CHANGED
|
@@ -6,12 +6,22 @@ export class UtilsBrave {
|
|
|
6
6
|
this.brave_api_key = brave_api_key
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
async web_search(q : string
|
|
9
|
+
async web_search(q : string, options : {
|
|
10
|
+
min_date? : string,
|
|
11
|
+
max_date? : string,
|
|
12
|
+
verbosity? : number
|
|
13
|
+
} = {}) : Promise<Record<string, any>[] | undefined> {
|
|
14
|
+
const verbosity = options.verbosity || 0
|
|
10
15
|
if (this.brave_api_key === undefined) {
|
|
11
16
|
return undefined
|
|
12
17
|
}
|
|
13
18
|
try {
|
|
14
|
-
const
|
|
19
|
+
const freshness = options.min_date !== undefined && options.max_date !== undefined ? (options.min_date + "to" + options.max_date) : undefined
|
|
20
|
+
const url = "https://api.search.brave.com/res/v1/web/search?q=" + encodeURIComponent(q) + (freshness !== undefined ? ("&freshness=" + freshness) : "")
|
|
21
|
+
if (verbosity > 0) {
|
|
22
|
+
console.log(url)
|
|
23
|
+
}
|
|
24
|
+
const response = await fetch(url, {
|
|
15
25
|
headers : {
|
|
16
26
|
"X-Subscription-Token" : this.brave_api_key
|
|
17
27
|
}
|
|
@@ -32,12 +42,22 @@ export class UtilsBrave {
|
|
|
32
42
|
return undefined
|
|
33
43
|
}
|
|
34
44
|
|
|
35
|
-
async news_search(q : string
|
|
45
|
+
async news_search(q : string, options : {
|
|
46
|
+
min_date? : string,
|
|
47
|
+
max_date? : string,
|
|
48
|
+
verbosity? : number
|
|
49
|
+
} = {}) : Promise<Record<string, any>[] | undefined> {
|
|
50
|
+
const verbosity = options.verbosity || 0
|
|
36
51
|
if (this.brave_api_key === undefined) {
|
|
37
52
|
return undefined
|
|
38
53
|
}
|
|
39
54
|
try {
|
|
40
|
-
const
|
|
55
|
+
const freshness = options.min_date !== undefined && options.max_date !== undefined ? (options.min_date + "to" + options.max_date) : undefined
|
|
56
|
+
const url = "https://api.search.brave.com/res/v1/news/search?q=" + encodeURIComponent(q) + (freshness !== undefined ? ("&freshness=" + freshness) : "")
|
|
57
|
+
if (verbosity > 0) {
|
|
58
|
+
console.log(url)
|
|
59
|
+
}
|
|
60
|
+
const response = await fetch(url, {
|
|
41
61
|
headers : {
|
|
42
62
|
"X-Subscription-Token" : this.brave_api_key
|
|
43
63
|
}
|
package/src/f.ts
CHANGED
|
@@ -107,4 +107,5 @@ const utils = new TriangleUtils(config)
|
|
|
107
107
|
// .then(response => console.log(response))
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
await utils.brave.
|
|
110
|
+
await utils.brave.news_search("abdul el sayed", { min_date : "2026-09-03", max_date : "2026-09-05" })
|
|
111
|
+
.then(console.log)
|