scrapely 1.2.3 → 1.2.4

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.
Files changed (86) hide show
  1. package/README.md +119 -1
  2. package/dist/actor.d.ts +703 -0
  3. package/dist/actor.js +1441 -0
  4. package/dist/browser-configuration.d.ts +58 -0
  5. package/dist/browser-configuration.js +128 -0
  6. package/dist/browser-locations.d.ts +5 -0
  7. package/dist/browser-locations.js +5469 -0
  8. package/dist/charging.d.ts +153 -0
  9. package/dist/charging.js +782 -0
  10. package/dist/charging_client.d.ts +18 -0
  11. package/dist/charging_client.js +49 -0
  12. package/dist/configuration.d.ts +121 -0
  13. package/dist/configuration.js +128 -0
  14. package/dist/crypto/secrets.d.ts +44 -0
  15. package/dist/crypto/secrets.js +164 -0
  16. package/dist/events/events-client.d.ts +59 -0
  17. package/dist/events/events-client.js +120 -0
  18. package/dist/events/scrapely-event-manager.d.ts +13 -0
  19. package/dist/events/scrapely-event-manager.js +61 -0
  20. package/dist/index.d.ts +29 -0
  21. package/dist/index.js +95 -0
  22. package/dist/log-env.d.ts +1 -0
  23. package/dist/log-env.js +12 -0
  24. package/dist/manifest.d.ts +30 -0
  25. package/dist/manifest.js +47 -0
  26. package/dist/patch-browser-pool.d.ts +66 -0
  27. package/dist/patch-browser-pool.js +827 -0
  28. package/dist/proxy-configuration.d.ts +118 -0
  29. package/dist/proxy-configuration.js +88 -0
  30. package/dist/request-list.d.ts +57 -0
  31. package/dist/request-list.js +79 -0
  32. package/dist/runner/docker-manager.d.ts +88 -0
  33. package/dist/runner/docker-manager.js +283 -0
  34. package/dist/runner/index.d.ts +2 -0
  35. package/dist/runner/index.js +7 -0
  36. package/dist/runner/timeout-manager.d.ts +43 -0
  37. package/dist/runner/timeout-manager.js +90 -0
  38. package/dist/scrapely-proxy-configuration.d.ts +99 -0
  39. package/dist/scrapely-proxy-configuration.js +559 -0
  40. package/dist/storage/api-storage-client.d.ts +199 -0
  41. package/dist/storage/api-storage-client.js +910 -0
  42. package/dist/storage/billing-tracker.d.ts +163 -0
  43. package/dist/storage/billing-tracker.js +260 -0
  44. package/dist/storage/dataset-client.d.ts +43 -0
  45. package/dist/storage/dataset-client.js +232 -0
  46. package/dist/storage/dataset-collection-client.d.ts +8 -0
  47. package/dist/storage/dataset-collection-client.js +75 -0
  48. package/dist/storage/dataset-push-script.d.ts +18 -0
  49. package/dist/storage/dataset-push-script.js +38 -0
  50. package/dist/storage/dragonfly-client.d.ts +94 -0
  51. package/dist/storage/dragonfly-client.js +167 -0
  52. package/dist/storage/index.d.ts +11 -0
  53. package/dist/storage/index.js +25 -0
  54. package/dist/storage/key-value-store-client.d.ts +61 -0
  55. package/dist/storage/key-value-store-client.js +306 -0
  56. package/dist/storage/kv-store-collection-client.d.ts +8 -0
  57. package/dist/storage/kv-store-collection-client.js +76 -0
  58. package/dist/storage/kvs-iteration.d.ts +17 -0
  59. package/dist/storage/kvs-iteration.js +126 -0
  60. package/dist/storage/log-manager.d.ts +114 -0
  61. package/dist/storage/log-manager.js +244 -0
  62. package/dist/storage/patch-storage.d.ts +11 -0
  63. package/dist/storage/patch-storage.js +177 -0
  64. package/dist/storage/request-queue-client.d.ts +93 -0
  65. package/dist/storage/request-queue-client.js +522 -0
  66. package/dist/storage/rq-collection-client.d.ts +8 -0
  67. package/dist/storage/rq-collection-client.js +89 -0
  68. package/dist/storage/rq-list-requests.d.ts +59 -0
  69. package/dist/storage/rq-list-requests.js +114 -0
  70. package/dist/storage/rq-lock-script.d.ts +56 -0
  71. package/dist/storage/rq-lock-script.js +127 -0
  72. package/dist/storage/run-metadata.d.ts +98 -0
  73. package/dist/storage/run-metadata.js +256 -0
  74. package/dist/storage/s3-client.d.ts +103 -0
  75. package/dist/storage/s3-client.js +302 -0
  76. package/dist/storage/ttl-manager.d.ts +70 -0
  77. package/dist/storage/ttl-manager.js +115 -0
  78. package/dist/storage/utils.d.ts +3 -0
  79. package/dist/storage/utils.js +19 -0
  80. package/dist/storage-identifiers.d.ts +20 -0
  81. package/dist/storage-identifiers.js +6 -0
  82. package/dist/utils.d.ts +54 -0
  83. package/dist/utils.js +63 -0
  84. package/dist/validator.d.ts +24 -0
  85. package/dist/validator.js +158 -0
  86. package/package.json +90 -9
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.events = void 0;
7
+ exports.connectEvents = connectEvents;
8
+ exports.disconnectEvents = disconnectEvents;
9
+ exports.isEventsConnected = isEventsConnected;
10
+ exports.onSystemEvent = onSystemEvent;
11
+ exports.onEvent = onEvent;
12
+ exports.offEvent = offEvent;
13
+ const node_events_1 = require("node:events");
14
+ const ws_1 = __importDefault(require("ws"));
15
+ let ws = null;
16
+ let reconnectTimer = null;
17
+ const events = new node_events_1.EventEmitter();
18
+ exports.events = events;
19
+ let connected = false;
20
+ let shouldReconnect = true;
21
+ /**
22
+ * Connect to the Scrapely events WebSocket server.
23
+ * Called during Actor.init().
24
+ *
25
+ * @param eventsWsUrl - The ACTOR_EVENTS_WEBSOCKET_URL env var value
26
+ * @param token - The SCRAPELY_TOKEN for authentication
27
+ * @param runId - The ACTOR_RUN_ID
28
+ */
29
+ function connectEvents(eventsWsUrl, token, runId) {
30
+ if (ws && ws.readyState === ws_1.default.OPEN)
31
+ return;
32
+ shouldReconnect = true;
33
+ try {
34
+ const url = `${eventsWsUrl}?token=${encodeURIComponent(token)}&runId=${encodeURIComponent(runId)}`;
35
+ ws = new ws_1.default(url);
36
+ ws.onopen = () => {
37
+ connected = true;
38
+ console.log(`[Scrapely Events] Connected to ${eventsWsUrl}`);
39
+ };
40
+ ws.onmessage = (event) => {
41
+ try {
42
+ const systemEvent = JSON.parse(event.data);
43
+ events.emit('systemEvent', systemEvent);
44
+ events.emit(systemEvent.name, systemEvent.data);
45
+ }
46
+ catch (err) {
47
+ console.error(`[Scrapely Events] Failed to parse event: ${err.message}`);
48
+ }
49
+ };
50
+ ws.onclose = () => {
51
+ connected = false;
52
+ console.log('[Scrapely Events] Disconnected');
53
+ // Reconnect after 5 seconds if still running
54
+ if (shouldReconnect) {
55
+ reconnectTimer = setTimeout(() => {
56
+ console.log('[Scrapely Events] Reconnecting...');
57
+ connectEvents(eventsWsUrl, token, runId);
58
+ }, 5000);
59
+ }
60
+ };
61
+ ws.onerror = (err) => {
62
+ console.error(`[Scrapely Events] WebSocket error: ${err?.message || 'unknown'}`);
63
+ };
64
+ }
65
+ catch (err) {
66
+ console.error(`[Scrapely Events] Failed to connect: ${err.message}`);
67
+ // Retry after 5 seconds
68
+ if (shouldReconnect) {
69
+ reconnectTimer = setTimeout(() => {
70
+ connectEvents(eventsWsUrl, token, runId);
71
+ }, 5000);
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Disconnect from the events WebSocket server.
77
+ * Called during Actor.exit().
78
+ */
79
+ function disconnectEvents() {
80
+ shouldReconnect = false;
81
+ if (reconnectTimer) {
82
+ clearTimeout(reconnectTimer);
83
+ reconnectTimer = null;
84
+ }
85
+ if (ws) {
86
+ try {
87
+ ws.close(1000, 'Actor exiting');
88
+ }
89
+ catch {
90
+ // Ignore close errors
91
+ }
92
+ ws = null;
93
+ }
94
+ connected = false;
95
+ }
96
+ /**
97
+ * Check if the events WebSocket is connected.
98
+ */
99
+ function isEventsConnected() {
100
+ return connected;
101
+ }
102
+ /**
103
+ * Subscribe to system events.
104
+ * Use in conjunction with Actor.on() to receive typed events.
105
+ */
106
+ function onSystemEvent(listener) {
107
+ events.on('systemEvent', listener);
108
+ }
109
+ /**
110
+ * Subscribe to specific system event types.
111
+ */
112
+ function onEvent(name, listener) {
113
+ events.on(name, listener);
114
+ }
115
+ /**
116
+ * Remove a specific event listener.
117
+ */
118
+ function offEvent(name, listener) {
119
+ events.off(name, listener);
120
+ }
@@ -0,0 +1,13 @@
1
+ import { EventManager } from '@crawlee/core';
2
+ import type { Configuration } from '../configuration.js';
3
+ /**
4
+ * Crawlee EventManager wired to Scrapely platform WebSocket events and persistState interval.
5
+ */
6
+ export declare class ScrapelyEventManager extends EventManager {
7
+ private readonly wsUnsubs;
8
+ constructor(config: Configuration);
9
+ init(): Promise<void>;
10
+ close(): Promise<void>;
11
+ private bindPlatformEvents;
12
+ private unbindPlatformEvents;
13
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScrapelyEventManager = void 0;
4
+ const utilities_1 = require("@apify/utilities");
5
+ const core_1 = require("@crawlee/core");
6
+ const events_client_js_1 = require("./events-client.js");
7
+ /**
8
+ * Crawlee EventManager wired to Scrapely platform WebSocket events and persistState interval.
9
+ */
10
+ class ScrapelyEventManager extends core_1.EventManager {
11
+ wsUnsubs = [];
12
+ constructor(config) {
13
+ super(config);
14
+ }
15
+ async init() {
16
+ if (this.initialized) {
17
+ return;
18
+ }
19
+ await super.init();
20
+ this.bindPlatformEvents();
21
+ }
22
+ async close() {
23
+ this.unbindPlatformEvents();
24
+ await super.close();
25
+ }
26
+ bindPlatformEvents() {
27
+ const forward = (name, handler) => {
28
+ events_client_js_1.events.on(name, handler);
29
+ this.wsUnsubs.push(() => events_client_js_1.events.off(name, handler));
30
+ };
31
+ forward("persistState" /* EventType.PERSIST_STATE */, (data) => {
32
+ this.emit("persistState" /* EventType.PERSIST_STATE */, data);
33
+ });
34
+ forward("migrating" /* EventType.MIGRATING */, () => {
35
+ if (this.intervals.persistState) {
36
+ (0, utilities_1.betterClearInterval)(this.intervals.persistState);
37
+ this.intervals.persistState = undefined;
38
+ }
39
+ this.emit("persistState" /* EventType.PERSIST_STATE */, { isMigrating: true });
40
+ this.emit("migrating" /* EventType.MIGRATING */);
41
+ });
42
+ forward("aborting" /* EventType.ABORTING */, () => {
43
+ this.emit("aborting" /* EventType.ABORTING */);
44
+ });
45
+ // The base EventManager never measures the container, so these are the only
46
+ // readings Crawlee's Snapshotter (and therefore autoscaling) gets on the platform.
47
+ forward("systemInfo" /* EventType.SYSTEM_INFO */, (data) => {
48
+ this.emit("systemInfo" /* EventType.SYSTEM_INFO */, data);
49
+ });
50
+ forward('cpuInfo', (data) => {
51
+ this.emit('cpuInfo', data);
52
+ });
53
+ }
54
+ unbindPlatformEvents() {
55
+ for (const unsub of this.wsUnsubs) {
56
+ unsub();
57
+ }
58
+ this.wsUnsubs.length = 0;
59
+ }
60
+ }
61
+ exports.ScrapelyEventManager = ScrapelyEventManager;
@@ -0,0 +1,29 @@
1
+ import './log-env.js';
2
+ export { setCdpUrl } from './patch-browser-pool.js';
3
+ export { Actor, ACTOR_PERMISSION_LEVEL, type ActorInput, type InitOptions, type MainOptions, type ExitOptions, type RebootOptions, type AbortOptions, type MetamorphOptions, type RecordOptions, type OpenStorageOptions, type CallOptions, type CallTaskOptions, type StartOptions, type SetStatusMessageOptions, type WebhookOptions, type ApifyEnv, type UserFunc, type Token, type Timeout, EXIT_CODES, } from './actor';
4
+ export type { StorageAlias, StorageId, StorageName, StorageIdentifier, StorageIdentifierWithoutAlias, } from './storage-identifiers.js';
5
+ export { ApifyClient, type ApifyClientOptions, type ActorRun } from 'scrapely-client';
6
+ export { Configuration, type ConfigurationOptions } from './configuration.js';
7
+ export { ScrapelyEventManager as PlatformEventManager } from './events/scrapely-event-manager.js';
8
+ export { ChargingManager, ChargeUncertainError, ChargeRejectedError, DEFAULT_DATASET_ITEM_EVENT, APIFY_DEFAULT_DATASET_ITEM_EVENT, SCRAPELY_DEFAULT_DATASET_ITEM_EVENT, hasDefaultDatasetItemEventInPricing, isDefaultDatasetItemEvent, resolveDefaultDatasetItemEventName, mergeChargeResults, pushDataAndCharge, type ChargeOptions, type ChargeResult, type ActorPricingInfo, } from './charging.js';
9
+ export { createChargingClient, pushDataChargingContext, USES_PUSH_DATA_INTERCEPTION, type PpeAwarePushDataContext, } from './charging_client.js';
10
+ export { BillingTracker, type BillingClient } from './storage/billing-tracker.js';
11
+ export { ApiStorageClientFactory, type ApiStorageConfig } from './storage/api-storage-client.js';
12
+ export { ProxyConfiguration, isPlatformProxySentinel, validateProxySessionId } from './scrapely-proxy-configuration.js';
13
+ export { createProxyConfiguration, getPlatformProxyEnv, type ProxyConfigurationOptions, type CreateProxyConfigurationOptions, type PlatformProxyEnv, type ProxyInfo, type ProxyConfigurationFunction, } from './proxy-configuration.js';
14
+ export { BrowserConfiguration, createBrowserConfiguration, type BrowserConfigurationOptions, } from './browser-configuration.js';
15
+ export { Dataset, KeyValueStore, RequestQueue, log, Log, LogLevel, Logger, LoggerJson, LoggerText, } from '@crawlee/core';
16
+ export type { LoggerOptions, KeyValueStoreIteratorOptions, KeyValueStoreOptions, DatasetConsumer, DatasetContent, DatasetDataOptions, DatasetIteratorOptions, DatasetMapper, DatasetOptions, DatasetReducer, QueueOperationInfo, RequestQueueOperationOptions, RequestQueueOptions, } from '@crawlee/core';
17
+ export type { KeyConsumer } from './storage/key-value-store-client.js';
18
+ export { utils, enqueueLinks, type EnqueueLinksOptions } from './utils.js';
19
+ export { ScrapelyRequestList, type RequestListSource } from './request-list.js';
20
+ export { PlaywrightCrawler } from '@crawlee/playwright';
21
+ export { PuppeteerCrawler } from '@crawlee/puppeteer';
22
+ export { CheerioCrawler } from '@crawlee/cheerio';
23
+ export { HttpCrawler } from '@crawlee/http';
24
+ export { BasicCrawler } from '@crawlee/basic';
25
+ export { BrowserCrawler } from '@crawlee/browser';
26
+ export { JSDOMCrawler } from '@crawlee/jsdom';
27
+ export { LinkeDOMCrawler } from '@crawlee/linkedom';
28
+ export { playwrightUtils } from '@crawlee/playwright';
29
+ export { puppeteerUtils } from '@crawlee/puppeteer';
package/dist/index.js ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkeDOMCrawler = exports.JSDOMCrawler = exports.BrowserCrawler = exports.BasicCrawler = exports.HttpCrawler = exports.CheerioCrawler = exports.PuppeteerCrawler = exports.PlaywrightCrawler = exports.ScrapelyRequestList = exports.enqueueLinks = exports.utils = exports.LoggerText = exports.LoggerJson = exports.Logger = exports.LogLevel = exports.Log = exports.log = exports.RequestQueue = exports.KeyValueStore = exports.Dataset = exports.createBrowserConfiguration = exports.BrowserConfiguration = exports.getPlatformProxyEnv = exports.createProxyConfiguration = exports.validateProxySessionId = exports.isPlatformProxySentinel = exports.ProxyConfiguration = exports.ApiStorageClientFactory = exports.BillingTracker = exports.USES_PUSH_DATA_INTERCEPTION = exports.pushDataChargingContext = exports.createChargingClient = exports.pushDataAndCharge = exports.mergeChargeResults = exports.resolveDefaultDatasetItemEventName = exports.isDefaultDatasetItemEvent = exports.hasDefaultDatasetItemEventInPricing = exports.SCRAPELY_DEFAULT_DATASET_ITEM_EVENT = exports.APIFY_DEFAULT_DATASET_ITEM_EVENT = exports.DEFAULT_DATASET_ITEM_EVENT = exports.ChargeRejectedError = exports.ChargeUncertainError = exports.ChargingManager = exports.PlatformEventManager = exports.Configuration = exports.ApifyClient = exports.EXIT_CODES = exports.ACTOR_PERMISSION_LEVEL = exports.Actor = exports.setCdpUrl = void 0;
4
+ exports.puppeteerUtils = exports.playwrightUtils = void 0;
5
+ require("./log-env.js");
6
+ var patch_browser_pool_js_1 = require("./patch-browser-pool.js");
7
+ Object.defineProperty(exports, "setCdpUrl", { enumerable: true, get: function () { return patch_browser_pool_js_1.setCdpUrl; } });
8
+ var actor_1 = require("./actor");
9
+ Object.defineProperty(exports, "Actor", { enumerable: true, get: function () { return actor_1.Actor; } });
10
+ Object.defineProperty(exports, "ACTOR_PERMISSION_LEVEL", { enumerable: true, get: function () { return actor_1.ACTOR_PERMISSION_LEVEL; } });
11
+ Object.defineProperty(exports, "EXIT_CODES", { enumerable: true, get: function () { return actor_1.EXIT_CODES; } });
12
+ // Apify-compatible client exports (scrapely-client provides ApifyClient as an alias of ScrapelyClient)
13
+ var scrapely_client_1 = require("scrapely-client");
14
+ Object.defineProperty(exports, "ApifyClient", { enumerable: true, get: function () { return scrapely_client_1.ApifyClient; } });
15
+ var configuration_js_1 = require("./configuration.js");
16
+ Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_js_1.Configuration; } });
17
+ var scrapely_event_manager_js_1 = require("./events/scrapely-event-manager.js");
18
+ Object.defineProperty(exports, "PlatformEventManager", { enumerable: true, get: function () { return scrapely_event_manager_js_1.ScrapelyEventManager; } });
19
+ var charging_js_1 = require("./charging.js");
20
+ Object.defineProperty(exports, "ChargingManager", { enumerable: true, get: function () { return charging_js_1.ChargingManager; } });
21
+ Object.defineProperty(exports, "ChargeUncertainError", { enumerable: true, get: function () { return charging_js_1.ChargeUncertainError; } });
22
+ Object.defineProperty(exports, "ChargeRejectedError", { enumerable: true, get: function () { return charging_js_1.ChargeRejectedError; } });
23
+ Object.defineProperty(exports, "DEFAULT_DATASET_ITEM_EVENT", { enumerable: true, get: function () { return charging_js_1.DEFAULT_DATASET_ITEM_EVENT; } });
24
+ Object.defineProperty(exports, "APIFY_DEFAULT_DATASET_ITEM_EVENT", { enumerable: true, get: function () { return charging_js_1.APIFY_DEFAULT_DATASET_ITEM_EVENT; } });
25
+ Object.defineProperty(exports, "SCRAPELY_DEFAULT_DATASET_ITEM_EVENT", { enumerable: true, get: function () { return charging_js_1.SCRAPELY_DEFAULT_DATASET_ITEM_EVENT; } });
26
+ Object.defineProperty(exports, "hasDefaultDatasetItemEventInPricing", { enumerable: true, get: function () { return charging_js_1.hasDefaultDatasetItemEventInPricing; } });
27
+ Object.defineProperty(exports, "isDefaultDatasetItemEvent", { enumerable: true, get: function () { return charging_js_1.isDefaultDatasetItemEvent; } });
28
+ Object.defineProperty(exports, "resolveDefaultDatasetItemEventName", { enumerable: true, get: function () { return charging_js_1.resolveDefaultDatasetItemEventName; } });
29
+ Object.defineProperty(exports, "mergeChargeResults", { enumerable: true, get: function () { return charging_js_1.mergeChargeResults; } });
30
+ Object.defineProperty(exports, "pushDataAndCharge", { enumerable: true, get: function () { return charging_js_1.pushDataAndCharge; } });
31
+ var charging_client_js_1 = require("./charging_client.js");
32
+ Object.defineProperty(exports, "createChargingClient", { enumerable: true, get: function () { return charging_client_js_1.createChargingClient; } });
33
+ Object.defineProperty(exports, "pushDataChargingContext", { enumerable: true, get: function () { return charging_client_js_1.pushDataChargingContext; } });
34
+ Object.defineProperty(exports, "USES_PUSH_DATA_INTERCEPTION", { enumerable: true, get: function () { return charging_client_js_1.USES_PUSH_DATA_INTERCEPTION; } });
35
+ var billing_tracker_js_1 = require("./storage/billing-tracker.js");
36
+ Object.defineProperty(exports, "BillingTracker", { enumerable: true, get: function () { return billing_tracker_js_1.BillingTracker; } });
37
+ // Storage exports - API-based storage
38
+ var api_storage_client_js_1 = require("./storage/api-storage-client.js");
39
+ Object.defineProperty(exports, "ApiStorageClientFactory", { enumerable: true, get: function () { return api_storage_client_js_1.ApiStorageClientFactory; } });
40
+ // Proxy configuration exports
41
+ var scrapely_proxy_configuration_js_1 = require("./scrapely-proxy-configuration.js");
42
+ Object.defineProperty(exports, "ProxyConfiguration", { enumerable: true, get: function () { return scrapely_proxy_configuration_js_1.ProxyConfiguration; } });
43
+ Object.defineProperty(exports, "isPlatformProxySentinel", { enumerable: true, get: function () { return scrapely_proxy_configuration_js_1.isPlatformProxySentinel; } });
44
+ Object.defineProperty(exports, "validateProxySessionId", { enumerable: true, get: function () { return scrapely_proxy_configuration_js_1.validateProxySessionId; } });
45
+ var proxy_configuration_js_1 = require("./proxy-configuration.js");
46
+ Object.defineProperty(exports, "createProxyConfiguration", { enumerable: true, get: function () { return proxy_configuration_js_1.createProxyConfiguration; } });
47
+ Object.defineProperty(exports, "getPlatformProxyEnv", { enumerable: true, get: function () { return proxy_configuration_js_1.getPlatformProxyEnv; } });
48
+ // Remote browser configuration exports
49
+ var browser_configuration_js_1 = require("./browser-configuration.js");
50
+ Object.defineProperty(exports, "BrowserConfiguration", { enumerable: true, get: function () { return browser_configuration_js_1.BrowserConfiguration; } });
51
+ Object.defineProperty(exports, "createBrowserConfiguration", { enumerable: true, get: function () { return browser_configuration_js_1.createBrowserConfiguration; } });
52
+ // Re-export commonly used crawlee types from specific packages (not the umbrella 'crawlee' package)
53
+ // This ensures compatibility when actors only have @crawlee/puppeteer or @crawlee/playwright installed
54
+ var core_1 = require("@crawlee/core");
55
+ Object.defineProperty(exports, "Dataset", { enumerable: true, get: function () { return core_1.Dataset; } });
56
+ Object.defineProperty(exports, "KeyValueStore", { enumerable: true, get: function () { return core_1.KeyValueStore; } });
57
+ Object.defineProperty(exports, "RequestQueue", { enumerable: true, get: function () { return core_1.RequestQueue; } });
58
+ Object.defineProperty(exports, "log", { enumerable: true, get: function () { return core_1.log; } });
59
+ Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return core_1.Log; } });
60
+ Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return core_1.LogLevel; } });
61
+ Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return core_1.Logger; } });
62
+ Object.defineProperty(exports, "LoggerJson", { enumerable: true, get: function () { return core_1.LoggerJson; } });
63
+ Object.defineProperty(exports, "LoggerText", { enumerable: true, get: function () { return core_1.LoggerText; } });
64
+ // Apify v2 compatible utils namespace
65
+ var utils_js_1 = require("./utils.js");
66
+ Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return utils_js_1.utils; } });
67
+ Object.defineProperty(exports, "enqueueLinks", { enumerable: true, get: function () { return utils_js_1.enqueueLinks; } });
68
+ // Request list (requestListSources input format; parity with the Python SDK's ScrapelyRequestList)
69
+ var request_list_js_1 = require("./request-list.js");
70
+ Object.defineProperty(exports, "ScrapelyRequestList", { enumerable: true, get: function () { return request_list_js_1.ScrapelyRequestList; } });
71
+ // Crawler exports - re-export from crawlee packages for Apify SDK compatibility
72
+ var playwright_1 = require("@crawlee/playwright");
73
+ Object.defineProperty(exports, "PlaywrightCrawler", { enumerable: true, get: function () { return playwright_1.PlaywrightCrawler; } });
74
+ var puppeteer_1 = require("@crawlee/puppeteer");
75
+ Object.defineProperty(exports, "PuppeteerCrawler", { enumerable: true, get: function () { return puppeteer_1.PuppeteerCrawler; } });
76
+ var cheerio_1 = require("@crawlee/cheerio");
77
+ Object.defineProperty(exports, "CheerioCrawler", { enumerable: true, get: function () { return cheerio_1.CheerioCrawler; } });
78
+ var http_1 = require("@crawlee/http");
79
+ Object.defineProperty(exports, "HttpCrawler", { enumerable: true, get: function () { return http_1.HttpCrawler; } });
80
+ var basic_1 = require("@crawlee/basic");
81
+ Object.defineProperty(exports, "BasicCrawler", { enumerable: true, get: function () { return basic_1.BasicCrawler; } });
82
+ var browser_1 = require("@crawlee/browser");
83
+ Object.defineProperty(exports, "BrowserCrawler", { enumerable: true, get: function () { return browser_1.BrowserCrawler; } });
84
+ var jsdom_1 = require("@crawlee/jsdom");
85
+ Object.defineProperty(exports, "JSDOMCrawler", { enumerable: true, get: function () { return jsdom_1.JSDOMCrawler; } });
86
+ var linkedom_1 = require("@crawlee/linkedom");
87
+ Object.defineProperty(exports, "LinkeDOMCrawler", { enumerable: true, get: function () { return linkedom_1.LinkeDOMCrawler; } });
88
+ // Utility exports for browser automation
89
+ var playwright_2 = require("@crawlee/playwright");
90
+ Object.defineProperty(exports, "playwrightUtils", { enumerable: true, get: function () { return playwright_2.playwrightUtils; } });
91
+ var puppeteer_2 = require("@crawlee/puppeteer");
92
+ Object.defineProperty(exports, "puppeteerUtils", { enumerable: true, get: function () { return puppeteer_2.puppeteerUtils; } });
93
+ // Note: crawlee types are available through the real crawlee package which is installed
94
+ // as a dependency. The build system creates a symlink from node_modules/crawlee to the
95
+ // real crawlee package inside @evomi/scrapely/node_modules/crawlee.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Map Scrapely ACTOR_* log env vars to APIFY_* before @apify/log reads them at module init.
5
+ * Must be imported before any @crawlee/core or @apify/log import.
6
+ */
7
+ if (!process.env.APIFY_LOG_LEVEL && process.env.ACTOR_LOG_LEVEL) {
8
+ process.env.APIFY_LOG_LEVEL = process.env.ACTOR_LOG_LEVEL;
9
+ }
10
+ if (!process.env.APIFY_LOG_FORMAT && process.env.ACTOR_LOG_FORMAT) {
11
+ process.env.APIFY_LOG_FORMAT = process.env.ACTOR_LOG_FORMAT;
12
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Scrapely Actor Manifest
3
+ * Defines the structure of package.json
4
+ */
5
+ export interface ScrapelyManifest {
6
+ /** Actor name (required) */
7
+ name: string;
8
+ /** Actor version (required) */
9
+ version: string;
10
+ /** Entry point file (required) - e.g., "main.ts", "index.js" */
11
+ entrypoint: string;
12
+ /** Maximum memory in MB (optional, default: 512) */
13
+ maxMemory?: number;
14
+ /** Maximum timeout in seconds (optional, default: 300) */
15
+ maxTimeout?: number;
16
+ /** Actor description (optional) */
17
+ description?: string;
18
+ /** Author (optional) */
19
+ author?: string;
20
+ /** Additional metadata (optional) */
21
+ [key: string]: unknown;
22
+ }
23
+ /** Default values for optional fields (can be overridden via env vars) */
24
+ export declare const DEFAULT_MAX_MEMORY: number;
25
+ export declare const DEFAULT_MAX_TIMEOUT: number;
26
+ /**
27
+ * Validate a manifest object
28
+ * Returns list of errors, empty if valid
29
+ */
30
+ export declare function validateManifest(manifest: unknown): string[];
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /**
3
+ * Scrapely Actor Manifest
4
+ * Defines the structure of package.json
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DEFAULT_MAX_TIMEOUT = exports.DEFAULT_MAX_MEMORY = void 0;
8
+ exports.validateManifest = validateManifest;
9
+ /** Default values for optional fields (can be overridden via env vars) */
10
+ exports.DEFAULT_MAX_MEMORY = parseInt(process.env.SCRAPELY_DEFAULT_MAX_MEMORY || '512', 10); // MB
11
+ exports.DEFAULT_MAX_TIMEOUT = parseInt(process.env.SCRAPELY_DEFAULT_MAX_TIMEOUT || '1800', 10); // seconds (30 minutes)
12
+ /**
13
+ * Validate a manifest object
14
+ * Returns list of errors, empty if valid
15
+ */
16
+ function validateManifest(manifest) {
17
+ const errors = [];
18
+ if (!manifest || typeof manifest !== 'object') {
19
+ errors.push('Manifest must be a JSON object');
20
+ return errors;
21
+ }
22
+ const m = manifest;
23
+ // Required fields
24
+ if (typeof m.name !== 'string' || m.name.trim() === '') {
25
+ errors.push('Missing required field: name (string)');
26
+ }
27
+ if (typeof m.version !== 'string' || m.version.trim() === '') {
28
+ errors.push('Missing required field: version (string)');
29
+ }
30
+ if (typeof m.entrypoint !== 'string' || m.entrypoint.trim() === '') {
31
+ errors.push('Missing required field: entrypoint (string)');
32
+ }
33
+ // Optional fields with type validation
34
+ if (m.maxMemory !== undefined && typeof m.maxMemory !== 'number') {
35
+ errors.push('Field maxMemory must be a number');
36
+ }
37
+ if (m.maxTimeout !== undefined && typeof m.maxTimeout !== 'number') {
38
+ errors.push('Field maxTimeout must be a number');
39
+ }
40
+ if (m.description !== undefined && typeof m.description !== 'string') {
41
+ errors.push('Field description must be a string');
42
+ }
43
+ if (m.author !== undefined && typeof m.author !== 'string') {
44
+ errors.push('Field author must be a string');
45
+ }
46
+ return errors;
47
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Set CDP URL explicitly (for testing or advanced use cases).
3
+ * Pass `undefined` to clear the override and fall back to `CDP_URL` env.
4
+ * Normally the CDP URL is read from CDP_URL env var lazily.
5
+ */
6
+ export declare function setCdpUrl(url: string | undefined): void;
7
+ /** @internal Exported for tests. */
8
+ export declare function getCdpUrlForTests(): string | undefined;
9
+ /** @internal Shape of the ProxyInfo fields we honor on the CDP URL. */
10
+ interface ProxyInfoLike {
11
+ /** Full proxy URL (credentials and gateway grammar username included) */
12
+ url?: string;
13
+ /** Platform proxy country (our enriched ProxyInfo). */
14
+ countryCode?: string;
15
+ /** Platform proxy ISO 3166-2 subdivision (our enriched ProxyInfo). */
16
+ subdivisionCode?: string;
17
+ groups?: string[];
18
+ sessionId?: string | number;
19
+ }
20
+ /** @internal Reset the once-per-process browser proxy messages (tests only). */
21
+ export declare function resetBrowserProxyWarningsForTests(): void;
22
+ /**
23
+ * Build the remote browser CDP URL for one browser connection.
24
+ *
25
+ * The Scrapely remote browser never takes a proxy: it routes through its own
26
+ * integrated proxy, selected by location params. Semantics:
27
+ * - The worker-injected `proxy_country` is the run default; `proxy_url` is
28
+ * never sent and is removed if present.
29
+ * - A platform-gateway `proxyInfo` (crawler ProxyConfiguration) overrides
30
+ * `proxy_country` / `proxy_state` (ISO subdivision codes mapped to region
31
+ * names). A custom (BYOP) proxy is warned about once and ignored.
32
+ * - `browserConfiguration` params always win.
33
+ * - When nothing changes, the CDP URL is returned byte-identical.
34
+ *
35
+ * @internal Exported for tests.
36
+ */
37
+ export declare function applyProxyInfoToCdpUrl(cdpUrl: string, proxyInfo?: ProxyInfoLike | null, browserConfiguration?: unknown): string;
38
+ /**
39
+ * Patch the browser plugins exported by one loaded copy of
40
+ * `@crawlee/browser-pool` (or one of its plugin files). Used for the SDK's own
41
+ * copy (eager pass below) and for every actor-local copy (Module._load hook),
42
+ * since an actor that installs its own Crawlee resolves a different instance.
43
+ *
44
+ * @internal Exported for tests.
45
+ */
46
+ export declare function patchBrowserPoolModule(mod: any): void;
47
+ /**
48
+ * Add the `browserConfiguration` option to the crawler classes exported by
49
+ * one loaded Crawlee module (package index or crawler file). Idempotent.
50
+ *
51
+ * @internal Exported for tests.
52
+ */
53
+ export declare function patchCrawleeCrawlerModule(mod: any): void;
54
+ /**
55
+ * Patch Crawlee copies that loaded before this module (e.g. an actor that
56
+ * imports `crawlee` before `scrapely` in a local run). Copies loaded later are
57
+ * patched by the Module._load hook.
58
+ *
59
+ * @internal Exported for tests.
60
+ */
61
+ export declare function patchLoadedCrawleeCopies(): void;
62
+ /** @internal Exported for tests. */
63
+ export declare function patchRawBrowserType(chromium: {
64
+ connectOverCDP: (url: string, opts?: unknown) => Promise<any>;
65
+ }, browserType: any, name: string): void;
66
+ export {};