scrapely 1.2.3 → 1.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.
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,199 @@
1
+ import type { DatasetClient, DatasetInfo, DatasetClientListOptions, DatasetClientUpdateOptions, KeyValueStoreClient, KeyValueStoreInfo, KeyValueStoreRecord, KeyValueStoreClientGetRecordOptions, KeyValueStoreClientListOptions, KeyValueStoreClientListData, KeyValueStoreRecordOptions, KeyValueStoreClientUpdateOptions, RequestQueueClient, RequestQueueInfo, QueueHead, QueueOperationInfo, RequestSchema, UpdateRequestSchema, RequestOptions, BatchAddRequestsResult, ListOptions, ListAndLockOptions, ListAndLockHeadResult, ProlongRequestLockOptions, ProlongRequestLockResult, DeleteRequestLockOptions, PaginatedList, Dictionary, StorageClient, RequestQueueOptions } from '@crawlee/types';
2
+ import type { ListRequestsOptions, ListRequestsResult } from './request-queue-client.js';
3
+ /**
4
+ * Configuration for API-based storage client
5
+ */
6
+ export interface ApiStorageConfig {
7
+ apiUrl: string;
8
+ token: string;
9
+ runId: string;
10
+ }
11
+ export declare class ApiStorageClientError extends Error {
12
+ readonly statusCode: number;
13
+ constructor(message: string, statusCode: number);
14
+ }
15
+ /**
16
+ * Options for API requests (passed through from RecordOptions)
17
+ */
18
+ interface ApiRequestOptions {
19
+ /** Timeout in seconds for the request */
20
+ timeoutSecs?: number;
21
+ /** If true, don't retry on timeout errors */
22
+ doNotRetryTimeouts?: boolean;
23
+ }
24
+ /**
25
+ * Base class for API-based storage clients.
26
+ * Communicates with internal storage API instead of direct DB access.
27
+ * No sensitive credentials are stored - only the user's API key.
28
+ */
29
+ declare abstract class BaseApiClient {
30
+ protected config: ApiStorageConfig;
31
+ protected headers: Record<string, string>;
32
+ private static rateLimiter;
33
+ private static maxRetries;
34
+ private static defaultTimeoutMs;
35
+ constructor(config: ApiStorageConfig);
36
+ protected request<T>(method: string, path: string, body?: any, contentType?: string, options?: ApiRequestOptions): Promise<T>;
37
+ protected requestWithHeaders<T>(method: string, path: string, body?: any, contentType?: string): Promise<{
38
+ data: T;
39
+ contentType: string;
40
+ }>;
41
+ }
42
+ /**
43
+ * Extended options for listing dataset items with filtering support.
44
+ * Matches Crawlee's DatasetDataOptions interface.
45
+ */
46
+ interface ExtendedDatasetListOptions extends DatasetClientListOptions {
47
+ /** An array of field names that will be included in the result. */
48
+ fields?: string[];
49
+ /** If true then the function returns only non-empty items and skips hidden fields. */
50
+ clean?: boolean;
51
+ /** If true then the function doesn't return hidden fields (fields starting with "#"). */
52
+ skipHidden?: boolean;
53
+ /** If true then the function doesn't return empty items. */
54
+ skipEmpty?: boolean;
55
+ }
56
+ /**
57
+ * Dataset client that communicates via internal API
58
+ */
59
+ export declare class ApiDatasetClient<Data extends Dictionary = Dictionary> extends BaseApiClient implements DatasetClient<Data> {
60
+ private id;
61
+ constructor(config: ApiStorageConfig, datasetId: string);
62
+ get(): Promise<DatasetInfo | undefined>;
63
+ update(newFields: DatasetClientUpdateOptions): Promise<Partial<DatasetInfo>>;
64
+ delete(): Promise<void>;
65
+ downloadItems(): Promise<Buffer>;
66
+ listItems(options?: ExtendedDatasetListOptions): AsyncIterable<Data> & Promise<PaginatedList<Data>>;
67
+ /**
68
+ * Iterates over dataset entries (index-value pairs) using an async generator.
69
+ * Required by Crawlee's Dataset.entries() method.
70
+ */
71
+ listEntries(options?: ExtendedDatasetListOptions): AsyncIterable<[number, Data]> & Promise<PaginatedList<[number, Data]>>;
72
+ private _listItems;
73
+ pushItems(items: Data | Data[] | string | string[]): Promise<void>;
74
+ }
75
+ /**
76
+ * Key-Value Store client that communicates via internal API
77
+ */
78
+ export declare class ApiKeyValueStoreClient extends BaseApiClient implements KeyValueStoreClient {
79
+ private id;
80
+ constructor(config: ApiStorageConfig, storeId: string);
81
+ get(): Promise<KeyValueStoreInfo | undefined>;
82
+ update(newFields: KeyValueStoreClientUpdateOptions): Promise<Partial<KeyValueStoreInfo>>;
83
+ delete(): Promise<void>;
84
+ recordExists(key: string): Promise<boolean>;
85
+ getRecord(key: string, options?: KeyValueStoreClientGetRecordOptions): Promise<KeyValueStoreRecord | undefined>;
86
+ setRecord(record: KeyValueStoreRecord, options?: KeyValueStoreRecordOptions): Promise<void>;
87
+ deleteRecord(key: string): Promise<void>;
88
+ listKeys(options?: KeyValueStoreClientListOptions): Promise<KeyValueStoreClientListData>;
89
+ keys(options?: KeyValueStoreClientListOptions): AsyncIterable<string> & Promise<KeyValueStoreClientListData>;
90
+ values(options?: KeyValueStoreClientListOptions): AsyncIterable<unknown> & Promise<unknown[]>;
91
+ entries(options?: KeyValueStoreClientListOptions): AsyncIterable<[string, unknown]> & Promise<[string, unknown][]>;
92
+ /**
93
+ * Iterates over all keys in the key-value store, calling the iteratee function for each key.
94
+ * Similar to Apify's KeyValueStore.forEachKey() method.
95
+ */
96
+ forEachKey(iteratee: (key: string, index: number, info: {
97
+ size: number;
98
+ }) => Promise<void> | void, options?: KeyValueStoreClientListOptions): Promise<void>;
99
+ /**
100
+ * Gets a value from the key-value store that is automatically saved when modified.
101
+ * If the key doesn't exist, returns the defaultValue and stores it for future use.
102
+ * Similar to Apify's KeyValueStore.getAutoSavedValue() method.
103
+ *
104
+ * @param key - The key of the record to get
105
+ * @param defaultValue - The default value to return and store if the key doesn't exist
106
+ * @returns The stored value or the defaultValue
107
+ */
108
+ getAutoSavedValue<T>(key: string, defaultValue: T): Promise<T>;
109
+ /**
110
+ * Returns a URL for the given key that may be used to publicly access the value
111
+ * in the remote key-value store.
112
+ * Similar to Apify's KeyValueStore.getPublicUrl() method.
113
+ *
114
+ * @param key - The key of the record to get the public URL for
115
+ * @returns A public URL for accessing the record
116
+ */
117
+ getPublicUrl(key: string): string;
118
+ }
119
+ /**
120
+ * Request Queue client that communicates via internal API
121
+ */
122
+ export declare class ApiRequestQueueClient extends BaseApiClient implements RequestQueueClient {
123
+ private id;
124
+ private readonly clientKey;
125
+ constructor(config: ApiStorageConfig, queueId: string, options?: RequestQueueOptions);
126
+ get(): Promise<RequestQueueInfo | undefined>;
127
+ update(newFields: {
128
+ name?: string;
129
+ }): Promise<Partial<RequestQueueInfo> | undefined>;
130
+ delete(): Promise<void>;
131
+ addRequest(request: RequestSchema, options?: RequestOptions): Promise<QueueOperationInfo>;
132
+ batchAddRequests(requests: RequestSchema[], options?: RequestOptions): Promise<BatchAddRequestsResult>;
133
+ getRequest(id: string): Promise<RequestOptions | undefined>;
134
+ updateRequest(request: UpdateRequestSchema, options?: RequestOptions): Promise<QueueOperationInfo>;
135
+ deleteRequest(id: string): Promise<void>;
136
+ listHead(options?: ListOptions): Promise<QueueHead>;
137
+ listAndLockHead(options: ListAndLockOptions): Promise<ListAndLockHeadResult>;
138
+ prolongRequestLock(id: string, options: ProlongRequestLockOptions): Promise<ProlongRequestLockResult>;
139
+ deleteRequestLock(id: string, options?: DeleteRequestLockOptions): Promise<void>;
140
+ /**
141
+ * List requests in the queue with optional filtering and pagination (Apify REST API).
142
+ */
143
+ listRequests(options?: ListRequestsOptions): Promise<ListRequestsResult>;
144
+ /**
145
+ * Unlock all requests locked by this clientKey (Apify REST API).
146
+ */
147
+ unlockRequests(options: {
148
+ clientKey?: string;
149
+ forefront?: boolean;
150
+ runId?: string;
151
+ }): Promise<{
152
+ unlockedCount: number;
153
+ }>;
154
+ }
155
+ /**
156
+ * Dataset collection client (API-based)
157
+ */
158
+ declare class ApiDatasetCollectionClient {
159
+ private config;
160
+ constructor(config: ApiStorageConfig);
161
+ getOrCreate(name?: string): Promise<DatasetInfo>;
162
+ list(): Promise<PaginatedList<DatasetInfo>>;
163
+ }
164
+ /**
165
+ * Key-value store collection client (API-based)
166
+ */
167
+ declare class ApiKeyValueStoreCollectionClient {
168
+ private config;
169
+ constructor(config: ApiStorageConfig);
170
+ getOrCreate(name?: string): Promise<KeyValueStoreInfo>;
171
+ list(): Promise<PaginatedList<KeyValueStoreInfo>>;
172
+ }
173
+ /**
174
+ * Request queue collection client (API-based)
175
+ */
176
+ declare class ApiRequestQueueCollectionClient {
177
+ private config;
178
+ constructor(config: ApiStorageConfig);
179
+ getOrCreate(name?: string): Promise<RequestQueueInfo>;
180
+ list(): Promise<PaginatedList<RequestQueueInfo>>;
181
+ }
182
+ /**
183
+ * Factory for creating API-based storage clients.
184
+ * Implements StorageClient interface for Crawlee compatibility.
185
+ */
186
+ export declare class ApiStorageClientFactory implements StorageClient {
187
+ private config;
188
+ constructor(config: ApiStorageConfig);
189
+ datasets(): ApiDatasetCollectionClient;
190
+ dataset<Data extends Dictionary = Dictionary>(id: string): DatasetClient<Data>;
191
+ keyValueStores(): ApiKeyValueStoreCollectionClient;
192
+ keyValueStore(id: string): KeyValueStoreClient;
193
+ requestQueues(): ApiRequestQueueCollectionClient;
194
+ requestQueue(id: string, options?: RequestQueueOptions): RequestQueueClient;
195
+ purge(): Promise<void>;
196
+ teardown(): Promise<void>;
197
+ setStatusMessage(message: string): Promise<void>;
198
+ }
199
+ export {};