@decodo/sdk-ts 3.1.0 → 4.1.0
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 +56 -6
- package/build/cjs/index.cjs +5531 -261
- package/build/cjs/index.d.cts +179 -30
- package/build/esm/api/flows.d.ts +52 -0
- package/build/esm/api/flows.js +301 -0
- package/build/esm/api/limits.d.ts +6 -0
- package/build/esm/api/limits.js +36 -0
- package/build/esm/api/results.d.ts +2 -0
- package/build/esm/api/results.js +87 -0
- package/build/esm/api/tools.d.ts +6 -0
- package/build/esm/api/tools.js +185 -0
- package/build/esm/api/web-scraping-api.d.ts +2 -0
- package/build/esm/api/web-scraping-api.js +3 -0
- package/build/esm/errors.d.ts +10 -0
- package/build/esm/errors.js +20 -0
- package/build/esm/generated/data-api.d.ts +4 -0
- package/build/esm/generated/flows.d.ts +3 -0
- package/build/esm/generated/flows.js +4633 -0
- package/build/esm/generated/parameters.js +1 -1
- package/build/esm/generated/request-schemas.d.ts +3 -72
- package/build/esm/generated/request-schemas.js +3 -81
- package/build/esm/generated/targets.d.ts +2 -26
- package/build/esm/generated/targets.js +2 -20
- package/build/esm/index.d.ts +8 -2
- package/build/esm/index.js +5 -1
- package/build/esm/schema/bundled-schema.d.ts +7 -2
- package/build/esm/schema/bundled-schema.js +14 -0
- package/build/esm/schema/remote-schema.d.ts +7 -2
- package/build/esm/schema/remote-schema.js +75 -14
- package/build/esm/schema/types.d.ts +95 -1
- package/package.json +1 -1
|
@@ -44,11 +44,11 @@ export const parameterMeta = {
|
|
|
44
44
|
cookies: { type: "object" },
|
|
45
45
|
force_headers: { type: "boolean" },
|
|
46
46
|
force_cookies: { type: "boolean" },
|
|
47
|
+
main_content: { type: "boolean" },
|
|
47
48
|
prompt: { type: "string", maxLength: 8192 },
|
|
48
49
|
search: { type: "boolean" },
|
|
49
50
|
country: { type: "string" },
|
|
50
51
|
user_agent_type: { type: "string" },
|
|
51
|
-
sort: { type: "string" },
|
|
52
52
|
upload_date: { type: "string" },
|
|
53
53
|
type: { type: "string" },
|
|
54
54
|
duration: { type: "string" },
|
|
@@ -973,6 +973,9 @@ export declare const requestJsonSchemas: {
|
|
|
973
973
|
readonly markdown: {
|
|
974
974
|
readonly type: "boolean";
|
|
975
975
|
};
|
|
976
|
+
readonly main_content: {
|
|
977
|
+
readonly type: "boolean";
|
|
978
|
+
};
|
|
976
979
|
readonly callback_url: {
|
|
977
980
|
readonly type: "string";
|
|
978
981
|
};
|
|
@@ -1344,78 +1347,6 @@ export declare const requestJsonSchemas: {
|
|
|
1344
1347
|
readonly required: readonly ["target"];
|
|
1345
1348
|
readonly additionalProperties: false;
|
|
1346
1349
|
};
|
|
1347
|
-
readonly reddit_post: {
|
|
1348
|
-
readonly type: "object";
|
|
1349
|
-
readonly properties: {
|
|
1350
|
-
readonly target: {
|
|
1351
|
-
readonly const: "reddit_post";
|
|
1352
|
-
};
|
|
1353
|
-
readonly url: {
|
|
1354
|
-
readonly type: "string";
|
|
1355
|
-
readonly maxLength: 2056;
|
|
1356
|
-
};
|
|
1357
|
-
readonly locale: {
|
|
1358
|
-
readonly type: "string";
|
|
1359
|
-
};
|
|
1360
|
-
readonly geo: {
|
|
1361
|
-
readonly type: "string";
|
|
1362
|
-
};
|
|
1363
|
-
readonly callback_url: {
|
|
1364
|
-
readonly type: "string";
|
|
1365
|
-
};
|
|
1366
|
-
};
|
|
1367
|
-
readonly required: readonly ["target"];
|
|
1368
|
-
readonly additionalProperties: false;
|
|
1369
|
-
};
|
|
1370
|
-
readonly reddit_subreddit: {
|
|
1371
|
-
readonly type: "object";
|
|
1372
|
-
readonly properties: {
|
|
1373
|
-
readonly target: {
|
|
1374
|
-
readonly const: "reddit_subreddit";
|
|
1375
|
-
};
|
|
1376
|
-
readonly url: {
|
|
1377
|
-
readonly type: "string";
|
|
1378
|
-
readonly maxLength: 2056;
|
|
1379
|
-
};
|
|
1380
|
-
readonly locale: {
|
|
1381
|
-
readonly type: "string";
|
|
1382
|
-
};
|
|
1383
|
-
readonly geo: {
|
|
1384
|
-
readonly type: "string";
|
|
1385
|
-
};
|
|
1386
|
-
readonly callback_url: {
|
|
1387
|
-
readonly type: "string";
|
|
1388
|
-
};
|
|
1389
|
-
};
|
|
1390
|
-
readonly required: readonly ["target"];
|
|
1391
|
-
readonly additionalProperties: false;
|
|
1392
|
-
};
|
|
1393
|
-
readonly reddit_user: {
|
|
1394
|
-
readonly type: "object";
|
|
1395
|
-
readonly properties: {
|
|
1396
|
-
readonly target: {
|
|
1397
|
-
readonly const: "reddit_user";
|
|
1398
|
-
};
|
|
1399
|
-
readonly url: {
|
|
1400
|
-
readonly type: "string";
|
|
1401
|
-
readonly maxLength: 2056;
|
|
1402
|
-
};
|
|
1403
|
-
readonly locale: {
|
|
1404
|
-
readonly type: "string";
|
|
1405
|
-
};
|
|
1406
|
-
readonly geo: {
|
|
1407
|
-
readonly type: "string";
|
|
1408
|
-
};
|
|
1409
|
-
readonly sort: {
|
|
1410
|
-
readonly type: "string";
|
|
1411
|
-
};
|
|
1412
|
-
readonly callback_url: {
|
|
1413
|
-
readonly type: "string";
|
|
1414
|
-
};
|
|
1415
|
-
};
|
|
1416
|
-
readonly required: readonly ["target"];
|
|
1417
|
-
readonly additionalProperties: false;
|
|
1418
|
-
};
|
|
1419
1350
|
readonly youtube_metadata: {
|
|
1420
1351
|
readonly type: "object";
|
|
1421
1352
|
readonly properties: {
|
|
@@ -1074,6 +1074,9 @@ export const requestJsonSchemas = {
|
|
|
1074
1074
|
"markdown": {
|
|
1075
1075
|
"type": "boolean"
|
|
1076
1076
|
},
|
|
1077
|
+
"main_content": {
|
|
1078
|
+
"type": "boolean"
|
|
1079
|
+
},
|
|
1077
1080
|
"callback_url": {
|
|
1078
1081
|
"type": "string"
|
|
1079
1082
|
}
|
|
@@ -1495,84 +1498,6 @@ export const requestJsonSchemas = {
|
|
|
1495
1498
|
],
|
|
1496
1499
|
"additionalProperties": false
|
|
1497
1500
|
},
|
|
1498
|
-
[Target.RedditPost]: {
|
|
1499
|
-
"type": "object",
|
|
1500
|
-
"properties": {
|
|
1501
|
-
"target": {
|
|
1502
|
-
"const": "reddit_post"
|
|
1503
|
-
},
|
|
1504
|
-
"url": {
|
|
1505
|
-
"type": "string",
|
|
1506
|
-
"maxLength": 2056
|
|
1507
|
-
},
|
|
1508
|
-
"locale": {
|
|
1509
|
-
"type": "string"
|
|
1510
|
-
},
|
|
1511
|
-
"geo": {
|
|
1512
|
-
"type": "string"
|
|
1513
|
-
},
|
|
1514
|
-
"callback_url": {
|
|
1515
|
-
"type": "string"
|
|
1516
|
-
}
|
|
1517
|
-
},
|
|
1518
|
-
"required": [
|
|
1519
|
-
"target"
|
|
1520
|
-
],
|
|
1521
|
-
"additionalProperties": false
|
|
1522
|
-
},
|
|
1523
|
-
[Target.RedditSubreddit]: {
|
|
1524
|
-
"type": "object",
|
|
1525
|
-
"properties": {
|
|
1526
|
-
"target": {
|
|
1527
|
-
"const": "reddit_subreddit"
|
|
1528
|
-
},
|
|
1529
|
-
"url": {
|
|
1530
|
-
"type": "string",
|
|
1531
|
-
"maxLength": 2056
|
|
1532
|
-
},
|
|
1533
|
-
"locale": {
|
|
1534
|
-
"type": "string"
|
|
1535
|
-
},
|
|
1536
|
-
"geo": {
|
|
1537
|
-
"type": "string"
|
|
1538
|
-
},
|
|
1539
|
-
"callback_url": {
|
|
1540
|
-
"type": "string"
|
|
1541
|
-
}
|
|
1542
|
-
},
|
|
1543
|
-
"required": [
|
|
1544
|
-
"target"
|
|
1545
|
-
],
|
|
1546
|
-
"additionalProperties": false
|
|
1547
|
-
},
|
|
1548
|
-
[Target.RedditUser]: {
|
|
1549
|
-
"type": "object",
|
|
1550
|
-
"properties": {
|
|
1551
|
-
"target": {
|
|
1552
|
-
"const": "reddit_user"
|
|
1553
|
-
},
|
|
1554
|
-
"url": {
|
|
1555
|
-
"type": "string",
|
|
1556
|
-
"maxLength": 2056
|
|
1557
|
-
},
|
|
1558
|
-
"locale": {
|
|
1559
|
-
"type": "string"
|
|
1560
|
-
},
|
|
1561
|
-
"geo": {
|
|
1562
|
-
"type": "string"
|
|
1563
|
-
},
|
|
1564
|
-
"sort": {
|
|
1565
|
-
"type": "string"
|
|
1566
|
-
},
|
|
1567
|
-
"callback_url": {
|
|
1568
|
-
"type": "string"
|
|
1569
|
-
}
|
|
1570
|
-
},
|
|
1571
|
-
"required": [
|
|
1572
|
-
"target"
|
|
1573
|
-
],
|
|
1574
|
-
"additionalProperties": false
|
|
1575
|
-
},
|
|
1576
1501
|
[Target.YoutubeMetadata]: {
|
|
1577
1502
|
"type": "object",
|
|
1578
1503
|
"properties": {
|
|
@@ -1746,9 +1671,6 @@ export const requestSchemas = {
|
|
|
1746
1671
|
[Target.TiktokShopSearch]: z.fromJSONSchema(requestJsonSchemas[Target.TiktokShopSearch]),
|
|
1747
1672
|
[Target.TiktokShopProduct]: z.fromJSONSchema(requestJsonSchemas[Target.TiktokShopProduct]),
|
|
1748
1673
|
[Target.Tiktok]: z.fromJSONSchema(requestJsonSchemas[Target.Tiktok]),
|
|
1749
|
-
[Target.RedditPost]: z.fromJSONSchema(requestJsonSchemas[Target.RedditPost]),
|
|
1750
|
-
[Target.RedditSubreddit]: z.fromJSONSchema(requestJsonSchemas[Target.RedditSubreddit]),
|
|
1751
|
-
[Target.RedditUser]: z.fromJSONSchema(requestJsonSchemas[Target.RedditUser]),
|
|
1752
1674
|
[Target.YoutubeMetadata]: z.fromJSONSchema(requestJsonSchemas[Target.YoutubeMetadata]),
|
|
1753
1675
|
[Target.YoutubeSearch]: z.fromJSONSchema(requestJsonSchemas[Target.YoutubeSearch]),
|
|
1754
1676
|
[Target.YoutubeSubtitles]: z.fromJSONSchema(requestJsonSchemas[Target.YoutubeSubtitles]),
|
|
@@ -35,9 +35,6 @@ export declare enum Target {
|
|
|
35
35
|
TiktokShopSearch = "tiktok_shop_search",
|
|
36
36
|
TiktokShopProduct = "tiktok_shop_product",
|
|
37
37
|
Tiktok = "tiktok",
|
|
38
|
-
RedditPost = "reddit_post",
|
|
39
|
-
RedditSubreddit = "reddit_subreddit",
|
|
40
|
-
RedditUser = "reddit_user",
|
|
41
38
|
YoutubeMetadata = "youtube_metadata",
|
|
42
39
|
YoutubeSearch = "youtube_search",
|
|
43
40
|
YoutubeSubtitles = "youtube_subtitles",
|
|
@@ -45,7 +42,7 @@ export declare enum Target {
|
|
|
45
42
|
}
|
|
46
43
|
/** API discriminator string literals (same values as {@link Target}). */
|
|
47
44
|
export type TargetString = (typeof Target)[keyof typeof Target];
|
|
48
|
-
export declare const targets: readonly [Target.GoogleSearch, Target.GoogleTravelHotels, Target.Google, Target.GoogleAiMode, Target.GoogleAds, Target.GoogleLens, Target.BingSearch, Target.Bing, Target.AmazonProduct, Target.AmazonPricing, Target.AmazonSearch, Target.AmazonSellers, Target.AmazonBestsellers, Target.Amazon, Target.WalmartProduct, Target.WalmartSearch, Target.Walmart, Target.TargetProduct, Target.TargetSearch, Target.Target, Target.Universal, Target.Chatgpt, Target.Perplexity, Target.Gemini, Target.Bbb, Target.Autotrader, Target.Mobile, Target.Airbnb, Target.AppleAppStore, Target.TiktokPost, Target.TiktokShopSearch, Target.TiktokShopProduct, Target.Tiktok, Target.
|
|
45
|
+
export declare const targets: readonly [Target.GoogleSearch, Target.GoogleTravelHotels, Target.Google, Target.GoogleAiMode, Target.GoogleAds, Target.GoogleLens, Target.BingSearch, Target.Bing, Target.AmazonProduct, Target.AmazonPricing, Target.AmazonSearch, Target.AmazonSellers, Target.AmazonBestsellers, Target.Amazon, Target.WalmartProduct, Target.WalmartSearch, Target.Walmart, Target.TargetProduct, Target.TargetSearch, Target.Target, Target.Universal, Target.Chatgpt, Target.Perplexity, Target.Gemini, Target.Bbb, Target.Autotrader, Target.Mobile, Target.Airbnb, Target.AppleAppStore, Target.TiktokPost, Target.TiktokShopSearch, Target.TiktokShopProduct, Target.Tiktok, Target.YoutubeMetadata, Target.YoutubeSearch, Target.YoutubeSubtitles, Target.YoutubeChannel];
|
|
49
46
|
export interface GoogleSearchParams {
|
|
50
47
|
query?: string;
|
|
51
48
|
headless?: 'html' | 'png';
|
|
@@ -323,6 +320,7 @@ export interface UniversalParams {
|
|
|
323
320
|
force_cookies?: boolean;
|
|
324
321
|
xhr?: boolean;
|
|
325
322
|
markdown?: boolean;
|
|
323
|
+
main_content?: boolean;
|
|
326
324
|
callback_url?: string;
|
|
327
325
|
}
|
|
328
326
|
export interface ChatgptParams {
|
|
@@ -424,25 +422,6 @@ export interface TiktokParams {
|
|
|
424
422
|
user_agent_type?: string;
|
|
425
423
|
callback_url?: string;
|
|
426
424
|
}
|
|
427
|
-
export interface RedditPostParams {
|
|
428
|
-
url?: string;
|
|
429
|
-
locale?: string;
|
|
430
|
-
geo?: string;
|
|
431
|
-
callback_url?: string;
|
|
432
|
-
}
|
|
433
|
-
export interface RedditSubredditParams {
|
|
434
|
-
url?: string;
|
|
435
|
-
locale?: string;
|
|
436
|
-
geo?: string;
|
|
437
|
-
callback_url?: string;
|
|
438
|
-
}
|
|
439
|
-
export interface RedditUserParams {
|
|
440
|
-
url?: string;
|
|
441
|
-
locale?: string;
|
|
442
|
-
geo?: string;
|
|
443
|
-
sort?: string;
|
|
444
|
-
callback_url?: string;
|
|
445
|
-
}
|
|
446
425
|
export interface YoutubeMetadataParams {
|
|
447
426
|
query?: string;
|
|
448
427
|
callback_url?: string;
|
|
@@ -513,9 +492,6 @@ export type TargetParamsMap = {
|
|
|
513
492
|
[Target.TiktokShopSearch]: TiktokShopSearchParams;
|
|
514
493
|
[Target.TiktokShopProduct]: TiktokShopProductParams;
|
|
515
494
|
[Target.Tiktok]: TiktokParams;
|
|
516
|
-
[Target.RedditPost]: RedditPostParams;
|
|
517
|
-
[Target.RedditSubreddit]: RedditSubredditParams;
|
|
518
|
-
[Target.RedditUser]: RedditUserParams;
|
|
519
495
|
[Target.YoutubeMetadata]: YoutubeMetadataParams;
|
|
520
496
|
[Target.YoutubeSearch]: YoutubeSearchParams;
|
|
521
497
|
[Target.YoutubeSubtitles]: YoutubeSubtitlesParams;
|
|
@@ -37,15 +37,12 @@ export var Target;
|
|
|
37
37
|
Target["TiktokShopSearch"] = "tiktok_shop_search";
|
|
38
38
|
Target["TiktokShopProduct"] = "tiktok_shop_product";
|
|
39
39
|
Target["Tiktok"] = "tiktok";
|
|
40
|
-
Target["RedditPost"] = "reddit_post";
|
|
41
|
-
Target["RedditSubreddit"] = "reddit_subreddit";
|
|
42
|
-
Target["RedditUser"] = "reddit_user";
|
|
43
40
|
Target["YoutubeMetadata"] = "youtube_metadata";
|
|
44
41
|
Target["YoutubeSearch"] = "youtube_search";
|
|
45
42
|
Target["YoutubeSubtitles"] = "youtube_subtitles";
|
|
46
43
|
Target["YoutubeChannel"] = "youtube_channel";
|
|
47
44
|
})(Target || (Target = {}));
|
|
48
|
-
export const targets = [Target.GoogleSearch, Target.GoogleTravelHotels, Target.Google, Target.GoogleAiMode, Target.GoogleAds, Target.GoogleLens, Target.BingSearch, Target.Bing, Target.AmazonProduct, Target.AmazonPricing, Target.AmazonSearch, Target.AmazonSellers, Target.AmazonBestsellers, Target.Amazon, Target.WalmartProduct, Target.WalmartSearch, Target.Walmart, Target.TargetProduct, Target.TargetSearch, Target.Target, Target.Universal, Target.Chatgpt, Target.Perplexity, Target.Gemini, Target.Bbb, Target.Autotrader, Target.Mobile, Target.Airbnb, Target.AppleAppStore, Target.TiktokPost, Target.TiktokShopSearch, Target.TiktokShopProduct, Target.Tiktok, Target.
|
|
45
|
+
export const targets = [Target.GoogleSearch, Target.GoogleTravelHotels, Target.Google, Target.GoogleAiMode, Target.GoogleAds, Target.GoogleLens, Target.BingSearch, Target.Bing, Target.AmazonProduct, Target.AmazonPricing, Target.AmazonSearch, Target.AmazonSellers, Target.AmazonBestsellers, Target.Amazon, Target.WalmartProduct, Target.WalmartSearch, Target.Walmart, Target.TargetProduct, Target.TargetSearch, Target.Target, Target.Universal, Target.Chatgpt, Target.Perplexity, Target.Gemini, Target.Bbb, Target.Autotrader, Target.Mobile, Target.Airbnb, Target.AppleAppStore, Target.TiktokPost, Target.TiktokShopSearch, Target.TiktokShopProduct, Target.Tiktok, Target.YoutubeMetadata, Target.YoutubeSearch, Target.YoutubeSubtitles, Target.YoutubeChannel];
|
|
49
46
|
export const targetMeta = {
|
|
50
47
|
[Target.GoogleSearch]: {
|
|
51
48
|
group: "Google",
|
|
@@ -150,7 +147,7 @@ export const targetMeta = {
|
|
|
150
147
|
[Target.Universal]: {
|
|
151
148
|
group: "Universal",
|
|
152
149
|
response_format: "html",
|
|
153
|
-
parameters: ["url", "payload", "proxy_pool", "http_method", "headless", "geo", "locale", "device_type", "session_id", "successful_status_codes", "headers", "cookies", "force_headers", "force_cookies", "xhr", "markdown", "callback_url"],
|
|
150
|
+
parameters: ["url", "payload", "proxy_pool", "http_method", "headless", "geo", "locale", "device_type", "session_id", "successful_status_codes", "headers", "cookies", "force_headers", "force_cookies", "xhr", "markdown", "main_content", "callback_url"],
|
|
154
151
|
},
|
|
155
152
|
[Target.Chatgpt]: {
|
|
156
153
|
group: "AI Tools",
|
|
@@ -212,21 +209,6 @@ export const targetMeta = {
|
|
|
212
209
|
response_format: "html",
|
|
213
210
|
parameters: ["url", "headless", "user_agent_type", "callback_url"],
|
|
214
211
|
},
|
|
215
|
-
[Target.RedditPost]: {
|
|
216
|
-
group: "Reddit",
|
|
217
|
-
response_format: "json",
|
|
218
|
-
parameters: ["url", "locale", "geo", "callback_url"],
|
|
219
|
-
},
|
|
220
|
-
[Target.RedditSubreddit]: {
|
|
221
|
-
group: "Reddit",
|
|
222
|
-
response_format: "json",
|
|
223
|
-
parameters: ["url", "locale", "geo", "callback_url"],
|
|
224
|
-
},
|
|
225
|
-
[Target.RedditUser]: {
|
|
226
|
-
group: "Reddit",
|
|
227
|
-
response_format: "json",
|
|
228
|
-
parameters: ["url", "locale", "geo", "sort", "callback_url"],
|
|
229
|
-
},
|
|
230
212
|
[Target.YoutubeMetadata]: {
|
|
231
213
|
group: "YouTube",
|
|
232
214
|
response_format: "json",
|
package/build/esm/index.d.ts
CHANGED
|
@@ -2,9 +2,15 @@ export { DecodoClient } from './client.js';
|
|
|
2
2
|
export type { DecodoConfig, WebScrapingApiConfig } from './client.js';
|
|
3
3
|
export { WebScrapingApi } from './api/web-scraping-api.js';
|
|
4
4
|
export type { WebScrapingApiRoutes } from './api/web-scraping-api.js';
|
|
5
|
+
export { Flows } from './api/flows.js';
|
|
6
|
+
export type { JobResultsOptions, JobResultsPage, JobResultsPageOptions, WaitOptions, } from './api/flows.js';
|
|
7
|
+
export { limitResult } from './api/limits.js';
|
|
8
|
+
export type { LimitedResult } from './api/limits.js';
|
|
9
|
+
export { readResult } from './api/results.js';
|
|
10
|
+
export { buildToolInputSchema, buildToolRequest, runTool } from './api/tools.js';
|
|
5
11
|
export { BundledSchema } from './schema/bundled-schema.js';
|
|
6
12
|
export { RemoteSchema } from './schema/remote-schema.js';
|
|
7
|
-
export type { DecodoSchema, RemoteSchemaLoadOptions } from './schema/types.js';
|
|
13
|
+
export type { DecodoSchema, FlowSchema, IrBatchFlow, IrCallFlow, IrFlow, IrFlowSections, IrJobFlow, IrKeyCheck, IrOperation, IrResult, IrResultFailure, IrSurface, IrSurfaceLimits, IrSurfaceTool, RemoteSchemaLoadOptions, } from './schema/types.js';
|
|
8
14
|
export type { TargetString, TargetParamsMap, TargetMeta, ScrapeRequest, BatchRequest, } from './generated/targets.js';
|
|
9
15
|
export { targets, targetMeta, Target, } from './generated/targets.js';
|
|
10
16
|
export { requestSchemas } from './generated/request-schemas.js';
|
|
@@ -14,4 +20,4 @@ export type { ParameterMeta } from './generated/parameters.js';
|
|
|
14
20
|
export type { SyncResponse, AsyncTaskResponse, BatchResponse, TaskMetadata, TaskResultsResponse, TaskStatus, ResultEntry, CrawlPage, CrawlPageList, CrawlResult, } from './types/responses.js';
|
|
15
21
|
export type { CrawlOptions, CrawlPagesOptions, CrawlResultsOptions, } from './types/requests.js';
|
|
16
22
|
export type { RunSearchRequest, RunSearchResponse, MapSiteRequest, MapSiteResponse, StartCrawlRequest, StartCrawlResponse, GetCrawlStatusResponse, ListCrawlPagesResponse, CancelCrawlResponse, } from './generated/data-api.js';
|
|
17
|
-
export { DecodoError, AuthenticationError, RateLimitError, ValidationError, TimeoutError, } from './errors.js';
|
|
23
|
+
export { DecodoError, AuthenticationError, RateLimitError, ValidationError, TimeoutError, ResultError, JobTimeoutError, } from './errors.js';
|
package/build/esm/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export { DecodoClient } from './client.js';
|
|
2
2
|
export { WebScrapingApi } from './api/web-scraping-api.js';
|
|
3
|
+
export { Flows } from './api/flows.js';
|
|
4
|
+
export { limitResult } from './api/limits.js';
|
|
5
|
+
export { readResult } from './api/results.js';
|
|
6
|
+
export { buildToolInputSchema, buildToolRequest, runTool } from './api/tools.js';
|
|
3
7
|
export { BundledSchema } from './schema/bundled-schema.js';
|
|
4
8
|
export { RemoteSchema } from './schema/remote-schema.js';
|
|
5
9
|
export { targets, targetMeta, Target, } from './generated/targets.js';
|
|
6
10
|
export { requestSchemas } from './generated/request-schemas.js';
|
|
7
11
|
export { dataApiRequestSchemas } from './generated/data-api.js';
|
|
8
12
|
export { parameterMeta } from './generated/parameters.js';
|
|
9
|
-
export { DecodoError, AuthenticationError, RateLimitError, ValidationError, TimeoutError, } from './errors.js';
|
|
13
|
+
export { DecodoError, AuthenticationError, RateLimitError, ValidationError, TimeoutError, ResultError, JobTimeoutError, } from './errors.js';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { JSONSchema4 } from 'json-schema';
|
|
2
|
-
import type {
|
|
3
|
-
export declare class BundledSchema implements
|
|
2
|
+
import type { FlowSchema, IrFlow, IrKeyCheck, IrOperation, IrSurface } from './types.js';
|
|
3
|
+
export declare class BundledSchema implements FlowSchema {
|
|
4
4
|
static readonly shared: BundledSchema;
|
|
5
|
+
readonly version = "2.7.0";
|
|
5
6
|
getRequestSchema(target: string): import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip>;
|
|
6
7
|
listTargets(): string[];
|
|
7
8
|
getTargetMeta(target: string): import("../index.js").TargetMeta;
|
|
8
9
|
getTargetParameterSchema(target: string): JSONSchema4 | undefined;
|
|
9
10
|
getSharedParameters(): Record<string, unknown>;
|
|
11
|
+
getOperation(operation: string): IrOperation | undefined;
|
|
12
|
+
getFlow(flow: string): IrFlow | undefined;
|
|
13
|
+
getSurface(client: string): IrSurface | undefined;
|
|
14
|
+
getKeyCheck(): IrKeyCheck | undefined;
|
|
10
15
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { requestJsonSchemas, requestSchemas, } from '../generated/request-schemas.js';
|
|
2
2
|
import { targetMeta, targets } from '../generated/targets.js';
|
|
3
|
+
import { flowSections, flowSectionsVersion } from '../generated/flows.js';
|
|
3
4
|
export class BundledSchema {
|
|
4
5
|
static shared = new BundledSchema();
|
|
6
|
+
version = flowSectionsVersion;
|
|
5
7
|
getRequestSchema(target) {
|
|
6
8
|
return requestSchemas[target];
|
|
7
9
|
}
|
|
@@ -17,4 +19,16 @@ export class BundledSchema {
|
|
|
17
19
|
getSharedParameters() {
|
|
18
20
|
return {};
|
|
19
21
|
}
|
|
22
|
+
getOperation(operation) {
|
|
23
|
+
return flowSections.operations[operation];
|
|
24
|
+
}
|
|
25
|
+
getFlow(flow) {
|
|
26
|
+
return flowSections.flows[flow];
|
|
27
|
+
}
|
|
28
|
+
getSurface(client) {
|
|
29
|
+
return flowSections.surfaces[client];
|
|
30
|
+
}
|
|
31
|
+
getKeyCheck() {
|
|
32
|
+
return flowSections.keyCheck;
|
|
33
|
+
}
|
|
20
34
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { JSONSchema4 } from 'json-schema';
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
import type { TargetMeta } from '../generated/targets.js';
|
|
4
|
-
import type {
|
|
5
|
-
export declare class RemoteSchema implements
|
|
4
|
+
import type { FlowSchema, IrFlow, IrKeyCheck, IrOperation, IrSurface, RemoteSchemaLoadOptions } from './types.js';
|
|
5
|
+
export declare class RemoteSchema implements FlowSchema {
|
|
6
6
|
readonly version: string;
|
|
7
7
|
private readonly schemas;
|
|
8
8
|
private readonly meta;
|
|
9
9
|
private readonly parameterSchemas;
|
|
10
10
|
private readonly sharedParameters;
|
|
11
11
|
private readonly targetKeys;
|
|
12
|
+
private readonly flowSections;
|
|
12
13
|
private constructor();
|
|
13
14
|
static load(config?: RemoteSchemaLoadOptions): Promise<RemoteSchema>;
|
|
14
15
|
getRequestSchema(target: string): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | undefined;
|
|
@@ -16,4 +17,8 @@ export declare class RemoteSchema implements DecodoSchema {
|
|
|
16
17
|
getTargetMeta(target: string): TargetMeta | undefined;
|
|
17
18
|
getTargetParameterSchema(target: string): JSONSchema4 | undefined;
|
|
18
19
|
getSharedParameters(): Record<string, unknown>;
|
|
20
|
+
getOperation(operation: string): IrOperation | undefined;
|
|
21
|
+
getFlow(flow: string): IrFlow | undefined;
|
|
22
|
+
getSurface(client: string): IrSurface | undefined;
|
|
23
|
+
getKeyCheck(): IrKeyCheck | undefined;
|
|
19
24
|
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import * as z from 'zod';
|
|
4
5
|
import { buildTargetMeta } from './build-target-meta.js';
|
|
5
6
|
import { DEFAULT_IR_CACHE_PATH } from './constants.js';
|
|
6
7
|
import { expandPath } from './expand-path.js';
|
|
7
8
|
import { resolveLatestIr } from './resolve-latest-ir.js';
|
|
9
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10
|
+
const isCachedIr = (value) => isRecord(value) &&
|
|
11
|
+
typeof value.fetchedAt === 'number' &&
|
|
12
|
+
typeof value.resolvedUrl === 'string' &&
|
|
13
|
+
isRecord(value.ir) &&
|
|
14
|
+
typeof value.ir.version === 'string';
|
|
8
15
|
const readCachedIr = (cachePath) => {
|
|
9
16
|
try {
|
|
10
|
-
const
|
|
11
|
-
return
|
|
17
|
+
const parsed = JSON.parse(readFileSync(cachePath, 'utf-8'));
|
|
18
|
+
return isCachedIr(parsed) ? parsed : null;
|
|
12
19
|
}
|
|
13
20
|
catch {
|
|
14
21
|
return null;
|
|
@@ -20,7 +27,11 @@ const isCacheFresh = (cached, ttlMs) => {
|
|
|
20
27
|
}
|
|
21
28
|
return Date.now() - cached.fetchedAt < ttlMs;
|
|
22
29
|
};
|
|
30
|
+
const isFileUrl = (url) => url.startsWith('file:');
|
|
23
31
|
const fetchIr = async (url) => {
|
|
32
|
+
if (isFileUrl(url)) {
|
|
33
|
+
return JSON.parse(readFileSync(fileURLToPath(url), 'utf-8'));
|
|
34
|
+
}
|
|
24
35
|
const res = await fetch(url, {
|
|
25
36
|
headers: { Accept: 'application/json' },
|
|
26
37
|
});
|
|
@@ -30,8 +41,13 @@ const fetchIr = async (url) => {
|
|
|
30
41
|
return (await res.json());
|
|
31
42
|
};
|
|
32
43
|
const writeCachedIr = (cachePath, cached) => {
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
try {
|
|
45
|
+
mkdirSync(dirname(cachePath), { recursive: true });
|
|
46
|
+
writeFileSync(cachePath, JSON.stringify(cached, null, 2));
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
35
51
|
};
|
|
36
52
|
const resolveIrUrl = async (config) => {
|
|
37
53
|
if (config.url) {
|
|
@@ -40,26 +56,57 @@ const resolveIrUrl = async (config) => {
|
|
|
40
56
|
const latest = await resolveLatestIr();
|
|
41
57
|
return { url: latest.url, version: latest.version };
|
|
42
58
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const cached = readCachedIr(cachePath);
|
|
59
|
+
const isCacheOf = (cached, url) => url ? cached.resolvedUrl === url : cached.latest === true;
|
|
60
|
+
const refreshIr = async (config, cachePath, cached) => {
|
|
46
61
|
const resolved = await resolveIrUrl(config);
|
|
47
|
-
if (cached?.resolvedUrl === resolved.url
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
62
|
+
if (cached?.resolvedUrl === resolved.url &&
|
|
63
|
+
cached.ir.version === resolved.version) {
|
|
64
|
+
writeCachedIr(cachePath, {
|
|
65
|
+
...cached,
|
|
66
|
+
fetchedAt: Date.now(),
|
|
67
|
+
latest: !config.url,
|
|
68
|
+
});
|
|
69
|
+
return cached.ir;
|
|
54
70
|
}
|
|
55
71
|
const ir = await fetchIr(resolved.url);
|
|
56
72
|
writeCachedIr(cachePath, {
|
|
57
73
|
fetchedAt: Date.now(),
|
|
58
74
|
resolvedUrl: resolved.url,
|
|
75
|
+
latest: !config.url,
|
|
59
76
|
ir,
|
|
60
77
|
});
|
|
61
78
|
return ir;
|
|
62
79
|
};
|
|
80
|
+
const loadIr = async (config) => {
|
|
81
|
+
if (config.url && isFileUrl(config.url)) {
|
|
82
|
+
return fetchIr(config.url);
|
|
83
|
+
}
|
|
84
|
+
const cachePath = expandPath(config.cachePath ?? DEFAULT_IR_CACHE_PATH);
|
|
85
|
+
const cached = readCachedIr(cachePath);
|
|
86
|
+
const usable = cached && isCacheOf(cached, config.url) ? cached : null;
|
|
87
|
+
if (usable &&
|
|
88
|
+
(config.url ||
|
|
89
|
+
(config.ttlMs !== undefined && isCacheFresh(usable, config.ttlMs)))) {
|
|
90
|
+
return usable.ir;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
return await refreshIr(config, cachePath, cached);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (!usable) {
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
100
|
+
process.emitWarning(`Could not refresh the Decodo IR (${message}); using the cached copy.`);
|
|
101
|
+
return usable.ir;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const flowSectionsOf = (ir) => ({
|
|
105
|
+
operations: ir.operations ?? {},
|
|
106
|
+
flows: ir.flows ?? {},
|
|
107
|
+
surfaces: ir.surfaces ?? {},
|
|
108
|
+
keyCheck: ir.keyCheck,
|
|
109
|
+
});
|
|
63
110
|
const buildRequestSchemas = (ir) => {
|
|
64
111
|
const schemas = new Map();
|
|
65
112
|
for (const [targetKey, target] of Object.entries(ir.apis.webScrapingApi.targets)) {
|
|
@@ -81,6 +128,7 @@ export class RemoteSchema {
|
|
|
81
128
|
parameterSchemas;
|
|
82
129
|
sharedParameters;
|
|
83
130
|
targetKeys;
|
|
131
|
+
flowSections;
|
|
84
132
|
constructor(ir, schemas) {
|
|
85
133
|
this.version = ir.version;
|
|
86
134
|
this.schemas = schemas;
|
|
@@ -88,6 +136,7 @@ export class RemoteSchema {
|
|
|
88
136
|
this.parameterSchemas = buildParameterSchemas(ir);
|
|
89
137
|
this.sharedParameters = ir.apis.webScrapingApi.parameters ?? {};
|
|
90
138
|
this.targetKeys = Object.keys(ir.apis.webScrapingApi.targets);
|
|
139
|
+
this.flowSections = flowSectionsOf(ir);
|
|
91
140
|
}
|
|
92
141
|
static async load(config = {}) {
|
|
93
142
|
const ir = await loadIr(config);
|
|
@@ -109,4 +158,16 @@ export class RemoteSchema {
|
|
|
109
158
|
getSharedParameters() {
|
|
110
159
|
return this.sharedParameters;
|
|
111
160
|
}
|
|
161
|
+
getOperation(operation) {
|
|
162
|
+
return this.flowSections.operations[operation];
|
|
163
|
+
}
|
|
164
|
+
getFlow(flow) {
|
|
165
|
+
return this.flowSections.flows[flow];
|
|
166
|
+
}
|
|
167
|
+
getSurface(client) {
|
|
168
|
+
return this.flowSections.surfaces[client];
|
|
169
|
+
}
|
|
170
|
+
getKeyCheck() {
|
|
171
|
+
return this.flowSections.keyCheck;
|
|
172
|
+
}
|
|
112
173
|
}
|