@jam-nodes/nodes 0.2.4 → 0.2.5
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/ai/analyze-posts.d.ts +4 -2
- package/dist/ai/analyze-posts.d.ts.map +1 -1
- package/dist/ai/analyze-posts.js +48 -44
- package/dist/ai/analyze-posts.js.map +1 -1
- package/dist/ai/draft-emails.d.ts +4 -2
- package/dist/ai/draft-emails.d.ts.map +1 -1
- package/dist/ai/draft-emails.js +57 -42
- package/dist/ai/draft-emails.js.map +1 -1
- package/dist/ai/keyword-generator.d.ts +1 -1
- package/dist/ai/keyword-generator.d.ts.map +1 -1
- package/dist/ai/keyword-generator.js +45 -20
- package/dist/ai/keyword-generator.js.map +1 -1
- package/dist/index.d.ts +25 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/integrations/apollo/search-contacts.d.ts +8 -8
- package/dist/integrations/apollo/search-contacts.d.ts.map +1 -1
- package/dist/integrations/apollo/search-contacts.js +110 -26
- package/dist/integrations/apollo/search-contacts.js.map +1 -1
- package/dist/integrations/dataforseo/keyword-research.d.ts +1 -1
- package/dist/integrations/dataforseo/keyword-research.d.ts.map +1 -1
- package/dist/integrations/dataforseo/keyword-research.js +59 -9
- package/dist/integrations/dataforseo/keyword-research.js.map +1 -1
- package/dist/integrations/dataforseo/seo-audit.d.ts +1 -1
- package/dist/integrations/dataforseo/seo-audit.d.ts.map +1 -1
- package/dist/integrations/dataforseo/seo-audit.js +52 -23
- package/dist/integrations/dataforseo/seo-audit.js.map +1 -1
- package/dist/integrations/openai/sora-video.d.ts +1 -1
- package/dist/integrations/openai/sora-video.d.ts.map +1 -1
- package/dist/integrations/openai/sora-video.js +82 -7
- package/dist/integrations/openai/sora-video.js.map +1 -1
- package/dist/integrations/social/linkedin-monitor.d.ts +1 -1
- package/dist/integrations/social/linkedin-monitor.d.ts.map +1 -1
- package/dist/integrations/social/linkedin-monitor.js +69 -36
- package/dist/integrations/social/linkedin-monitor.js.map +1 -1
- package/dist/integrations/social/reddit-monitor.d.ts.map +1 -1
- package/dist/integrations/social/reddit-monitor.js +5 -12
- package/dist/integrations/social/reddit-monitor.js.map +1 -1
- package/dist/integrations/social/twitter-monitor.d.ts +20 -3
- package/dist/integrations/social/twitter-monitor.d.ts.map +1 -1
- package/dist/integrations/social/twitter-monitor.js +44 -28
- package/dist/integrations/social/twitter-monitor.js.map +1 -1
- package/dist/utils/http.d.ts +60 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/http.js +126 -0
- package/dist/utils/http.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP utilities for making API calls with retry logic, timeouts, and rate limiting.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Sleep for a specified duration
|
|
6
|
+
*/
|
|
7
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for fetch with retry
|
|
10
|
+
*/
|
|
11
|
+
export interface FetchWithRetryOptions {
|
|
12
|
+
/** Maximum number of retry attempts (default: 3) */
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
/** Base delay in milliseconds for exponential backoff (default: 1000) */
|
|
15
|
+
backoffMs?: number;
|
|
16
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when all retry attempts are exhausted
|
|
21
|
+
*/
|
|
22
|
+
export declare class FetchRetryError extends Error {
|
|
23
|
+
readonly status?: number | undefined;
|
|
24
|
+
readonly body?: string | undefined;
|
|
25
|
+
constructor(message: string, status?: number | undefined, body?: string | undefined);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fetch with automatic retry, timeout, and rate limit handling.
|
|
29
|
+
*
|
|
30
|
+
* Features:
|
|
31
|
+
* - Exponential backoff on rate limits (429) and server errors (5xx)
|
|
32
|
+
* - Configurable timeout
|
|
33
|
+
* - Respects Retry-After header
|
|
34
|
+
* - Does not retry on auth errors (401, 403) or client errors (4xx)
|
|
35
|
+
*
|
|
36
|
+
* @param url - URL to fetch
|
|
37
|
+
* @param options - Fetch options (same as native fetch)
|
|
38
|
+
* @param config - Retry and timeout configuration
|
|
39
|
+
* @returns Promise resolving to Response
|
|
40
|
+
* @throws FetchRetryError if all retries exhausted or non-retryable error
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const response = await fetchWithRetry(
|
|
45
|
+
* 'https://api.example.com/data',
|
|
46
|
+
* {
|
|
47
|
+
* method: 'POST',
|
|
48
|
+
* headers: { 'Authorization': 'Bearer token' },
|
|
49
|
+
* body: JSON.stringify({ key: 'value' })
|
|
50
|
+
* },
|
|
51
|
+
* { maxRetries: 3, timeoutMs: 30000 }
|
|
52
|
+
* );
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function fetchWithRetry(url: string, options?: RequestInit, config?: FetchWithRetryOptions): Promise<Response>;
|
|
56
|
+
/**
|
|
57
|
+
* Parse JSON response with error handling
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseJsonResponse<T>(response: Response): Promise<T>;
|
|
60
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAGtB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,EAAE,MAAM;gBAF7B,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,EAAE,MAAM,YAAA;CAKhC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,MAAM,GAAE,qBAA0B,GACjC,OAAO,CAAC,QAAQ,CAAC,CAoFnB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAWzE"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP utilities for making API calls with retry logic, timeouts, and rate limiting.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Sleep for a specified duration
|
|
6
|
+
*/
|
|
7
|
+
export function sleep(ms) {
|
|
8
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when all retry attempts are exhausted
|
|
12
|
+
*/
|
|
13
|
+
export class FetchRetryError extends Error {
|
|
14
|
+
status;
|
|
15
|
+
body;
|
|
16
|
+
constructor(message, status, body) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.status = status;
|
|
19
|
+
this.body = body;
|
|
20
|
+
this.name = 'FetchRetryError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetch with automatic retry, timeout, and rate limit handling.
|
|
25
|
+
*
|
|
26
|
+
* Features:
|
|
27
|
+
* - Exponential backoff on rate limits (429) and server errors (5xx)
|
|
28
|
+
* - Configurable timeout
|
|
29
|
+
* - Respects Retry-After header
|
|
30
|
+
* - Does not retry on auth errors (401, 403) or client errors (4xx)
|
|
31
|
+
*
|
|
32
|
+
* @param url - URL to fetch
|
|
33
|
+
* @param options - Fetch options (same as native fetch)
|
|
34
|
+
* @param config - Retry and timeout configuration
|
|
35
|
+
* @returns Promise resolving to Response
|
|
36
|
+
* @throws FetchRetryError if all retries exhausted or non-retryable error
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const response = await fetchWithRetry(
|
|
41
|
+
* 'https://api.example.com/data',
|
|
42
|
+
* {
|
|
43
|
+
* method: 'POST',
|
|
44
|
+
* headers: { 'Authorization': 'Bearer token' },
|
|
45
|
+
* body: JSON.stringify({ key: 'value' })
|
|
46
|
+
* },
|
|
47
|
+
* { maxRetries: 3, timeoutMs: 30000 }
|
|
48
|
+
* );
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export async function fetchWithRetry(url, options = {}, config = {}) {
|
|
52
|
+
const { maxRetries = 3, backoffMs = 1000, timeoutMs = 30000 } = config;
|
|
53
|
+
let lastError = null;
|
|
54
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
55
|
+
const controller = new AbortController();
|
|
56
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
57
|
+
try {
|
|
58
|
+
const response = await fetch(url, {
|
|
59
|
+
...options,
|
|
60
|
+
signal: controller.signal,
|
|
61
|
+
});
|
|
62
|
+
clearTimeout(timeout);
|
|
63
|
+
// Don't retry on auth errors
|
|
64
|
+
if (response.status === 401 || response.status === 403) {
|
|
65
|
+
const errorText = await response.text();
|
|
66
|
+
throw new FetchRetryError(`Authentication error: ${response.status} ${response.statusText}`, response.status, errorText);
|
|
67
|
+
}
|
|
68
|
+
// Handle rate limiting
|
|
69
|
+
if (response.status === 429) {
|
|
70
|
+
const retryAfter = response.headers.get('retry-after');
|
|
71
|
+
const delayMs = retryAfter
|
|
72
|
+
? parseInt(retryAfter, 10) * 1000
|
|
73
|
+
: backoffMs * Math.pow(2, attempt);
|
|
74
|
+
if (attempt < maxRetries - 1) {
|
|
75
|
+
await sleep(delayMs);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Retry on server errors
|
|
80
|
+
if (response.status >= 500 && response.status < 600) {
|
|
81
|
+
if (attempt < maxRetries - 1) {
|
|
82
|
+
await sleep(backoffMs * Math.pow(2, attempt));
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const errorText = await response.text();
|
|
86
|
+
throw new FetchRetryError(`Server error: ${response.status} ${response.statusText}`, response.status, errorText);
|
|
87
|
+
}
|
|
88
|
+
// Return response for success or client errors (let caller handle)
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
clearTimeout(timeout);
|
|
93
|
+
// Don't retry abort errors (timeout) on last attempt
|
|
94
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
95
|
+
lastError = new FetchRetryError('Request timed out');
|
|
96
|
+
if (attempt < maxRetries - 1) {
|
|
97
|
+
await sleep(backoffMs * Math.pow(2, attempt));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
throw lastError;
|
|
101
|
+
}
|
|
102
|
+
// Re-throw FetchRetryError (auth errors, etc.)
|
|
103
|
+
if (error instanceof FetchRetryError) {
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
// Network errors - retry
|
|
107
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
108
|
+
if (attempt < maxRetries - 1) {
|
|
109
|
+
await sleep(backoffMs * Math.pow(2, attempt));
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
throw lastError || new FetchRetryError('Max retries exceeded');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Parse JSON response with error handling
|
|
118
|
+
*/
|
|
119
|
+
export async function parseJsonResponse(response) {
|
|
120
|
+
if (!response.ok) {
|
|
121
|
+
const errorText = await response.text();
|
|
122
|
+
throw new FetchRetryError(`HTTP error: ${response.status} ${response.statusText}`, response.status, errorText);
|
|
123
|
+
}
|
|
124
|
+
return response.json();
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAcD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAGtB;IACA;IAHlB,YACE,OAAe,EACC,MAAe,EACf,IAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,WAAM,GAAN,MAAM,CAAS;QACf,SAAI,GAAJ,IAAI,CAAS;QAG7B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAW,EACX,UAAuB,EAAE,EACzB,SAAgC,EAAE;IAElC,MAAM,EAAE,UAAU,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;IAEvE,IAAI,SAAS,GAAiB,IAAI,CAAC;IAEnC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACtD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAA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SAAS,IAAI,IAAI,eAAe,CAAC,sBAAsB,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAI,QAAkB;IAC3D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,eAAe,CACvB,eAAe,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,EACvD,QAAQ,CAAC,MAAM,EACf,SAAS,CACV,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,EACL,eAAe,EACf,KAAK,qBAAqB,GAC3B,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,EACL,eAAe,GAEhB,MAAM,WAAW,CAAC"}
|