@crawlee/core 3.0.0-beta.4 → 3.0.0-beta.40

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 (76) hide show
  1. package/README.md +67 -71
  2. package/autoscaling/autoscaled_pool.js +1 -1
  3. package/autoscaling/autoscaled_pool.js.map +1 -1
  4. package/autoscaling/snapshotter.js +1 -1
  5. package/configuration.d.ts +1 -2
  6. package/configuration.d.ts.map +1 -1
  7. package/configuration.js.map +1 -1
  8. package/crawlers/crawler_commons.d.ts +8 -3
  9. package/crawlers/crawler_commons.d.ts.map +1 -1
  10. package/crawlers/statistics.js +1 -1
  11. package/crawlers/statistics.js.map +1 -1
  12. package/enqueue_links/enqueue_links.d.ts +18 -16
  13. package/enqueue_links/enqueue_links.d.ts.map +1 -1
  14. package/enqueue_links/enqueue_links.js +13 -13
  15. package/enqueue_links/enqueue_links.js.map +1 -1
  16. package/enqueue_links/shared.d.ts +6 -5
  17. package/enqueue_links/shared.d.ts.map +1 -1
  18. package/enqueue_links/shared.js +4 -2
  19. package/enqueue_links/shared.js.map +1 -1
  20. package/events/event_manager.d.ts +1 -0
  21. package/events/event_manager.d.ts.map +1 -1
  22. package/events/event_manager.js +3 -0
  23. package/events/event_manager.js.map +1 -1
  24. package/events/local_event_manager.d.ts +1 -2
  25. package/events/local_event_manager.d.ts.map +1 -1
  26. package/events/local_event_manager.js +1 -2
  27. package/events/local_event_manager.js.map +1 -1
  28. package/index.d.ts +2 -0
  29. package/index.d.ts.map +1 -1
  30. package/index.js +1 -0
  31. package/index.js.map +1 -1
  32. package/index.mjs +2 -0
  33. package/package.json +6 -6
  34. package/request.d.ts +9 -4
  35. package/request.d.ts.map +1 -1
  36. package/request.js +5 -1
  37. package/request.js.map +1 -1
  38. package/router.d.ts +98 -0
  39. package/router.d.ts.map +1 -0
  40. package/router.js +142 -0
  41. package/router.js.map +1 -0
  42. package/session_pool/session.d.ts +1 -1
  43. package/session_pool/session.d.ts.map +1 -1
  44. package/session_pool/session.js.map +1 -1
  45. package/session_pool/session_pool.d.ts.map +1 -1
  46. package/session_pool/session_pool.js.map +1 -1
  47. package/session_pool/session_utils.d.ts +1 -1
  48. package/session_pool/session_utils.d.ts.map +1 -1
  49. package/session_pool/session_utils.js.map +1 -1
  50. package/storages/dataset.d.ts +33 -6
  51. package/storages/dataset.d.ts.map +1 -1
  52. package/storages/dataset.js +42 -7
  53. package/storages/dataset.js.map +1 -1
  54. package/storages/key_value_store.d.ts +118 -15
  55. package/storages/key_value_store.d.ts.map +1 -1
  56. package/storages/key_value_store.js +177 -17
  57. package/storages/key_value_store.js.map +1 -1
  58. package/storages/request_list.d.ts +5 -5
  59. package/storages/request_list.d.ts.map +1 -1
  60. package/storages/request_list.js +3 -3
  61. package/storages/request_list.js.map +1 -1
  62. package/storages/request_queue.d.ts +10 -7
  63. package/storages/request_queue.d.ts.map +1 -1
  64. package/storages/request_queue.js +16 -6
  65. package/storages/request_queue.js.map +1 -1
  66. package/storages/storage_manager.d.ts +8 -4
  67. package/storages/storage_manager.d.ts.map +1 -1
  68. package/storages/storage_manager.js +28 -9
  69. package/storages/storage_manager.js.map +1 -1
  70. package/tsconfig.build.tsbuildinfo +1 -1
  71. package/typedefs.d.ts +0 -2
  72. package/typedefs.d.ts.map +1 -1
  73. package/typedefs.js.map +1 -1
  74. package/validators.d.ts +5 -5
  75. package/validators.d.ts.map +1 -1
  76. package/validators.js.map +1 -1
@@ -1,4 +1,5 @@
1
- import { StorageClient } from '@crawlee/types';
1
+ /// <reference types="node" />
2
+ import { Dictionary, StorageClient } from '@crawlee/types';
2
3
  import { Configuration } from '../configuration';
3
4
  import { Awaitable } from '../typedefs';
4
5
  import { StorageManagerOptions } from './storage_manager';
@@ -14,19 +15,19 @@ export declare const maybeStringify: <T>(value: T, options: {
14
15
  * The `KeyValueStore` class represents a key-value store, a simple data storage that is used
15
16
  * for saving and reading data records or files. Each data record is
16
17
  * represented by a unique key and associated with a MIME content type. Key-value stores are ideal
17
- * for saving screenshots, actor inputs and outputs, web pages, PDFs or to persist the state of crawlers.
18
+ * for saving screenshots, crawler inputs and outputs, web pages, PDFs or to persist the state of crawlers.
18
19
  *
19
20
  * Do not instantiate this class directly, use the
20
21
  * {@link KeyValueStore.open} function instead.
21
22
  *
22
- * Each actor run is associated with a default key-value store, which is created exclusively
23
- * for the run. By convention, the actor input and output are stored into the
23
+ * Each crawler run is associated with a default key-value store, which is created exclusively
24
+ * for the run. By convention, the crawler input and output are stored into the
24
25
  * default key-value store under the `INPUT` and `OUTPUT` key, respectively.
25
26
  * Typically, input and output are JSON files, although it can be any other format.
26
27
  * To access the default key-value store directly, you can use the
27
- * {@link Actor.getValue} and {@link Actor.setValue} convenience functions.
28
+ * {@link KeyValueStore.getValue} and {@link KeyValueStore.setValue} convenience functions.
28
29
  *
29
- * To access the input, you can also use the {@link Actor.getInput} convenience function.
30
+ * To access the input, you can also use the {@link KeyValueStore.getInput} convenience function.
30
31
  *
31
32
  * `KeyValueStore` stores its data either on local disk or in the Apify cloud,
32
33
  * depending on whether the [`APIFY_IS_AT_HOME`](/docs/guides/environment-variables#apify_is_at_home)
@@ -51,13 +52,13 @@ export declare const maybeStringify: <T>(value: T, options: {
51
52
  * **Example usage:**
52
53
  *
53
54
  * ```javascript
54
- * // Get actor input from the default key-value store.
55
- * const input = await Actor.getInput();
55
+ * // Get crawler input from the default key-value store.
56
+ * const input = await KeyValueStore.getInput();
56
57
  * // Get some value from the default key-value store.
57
- * const otherValue = await Actor.getValue('my-key');
58
+ * const otherValue = await KeyValueStore.getValue('my-key');
58
59
  *
59
- * // Write actor output to the default key-value store.
60
- * await Actor.setValue('OUTPUT', { myResult: 123 });
60
+ * // Write crawler output to the default key-value store.
61
+ * await KeyValueStore.setValue('OUTPUT', { myResult: 123 });
61
62
  *
62
63
  * // Open a named key-value store
63
64
  * const store = await KeyValueStore.open('some-name');
@@ -79,7 +80,10 @@ export declare class KeyValueStore {
79
80
  readonly config: Configuration;
80
81
  readonly id: string;
81
82
  readonly name?: string;
82
- private client;
83
+ private readonly client;
84
+ private persistStateEventStarted;
85
+ /** Cache for persistent (auto-saved) values. When we try to set such value, the cache will be updated automatically. */
86
+ private readonly cache;
83
87
  /**
84
88
  * @internal
85
89
  */
@@ -109,12 +113,16 @@ export declare class KeyValueStore {
109
113
  * @param key
110
114
  * Unique key of the record. It can be at most 256 characters long and only consist
111
115
  * of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
116
+ * @param defaultValue
117
+ * Fallback that will be returned if no value if present in the storage.
112
118
  * @returns
113
119
  * Returns a promise that resolves to an object, string
114
120
  * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
115
121
  * on the MIME content type of the record.
116
122
  */
117
- getValue<T = unknown>(key: string): Promise<T | null>;
123
+ getValue<T = unknown>(key: string, defaultValue?: T): Promise<T | null>;
124
+ getAutoSavedValue<T extends Dictionary = Dictionary>(key: string, defaultValue?: T): Promise<T>;
125
+ private ensurePersistStateEvent;
118
126
  /**
119
127
  * Saves or deletes a record in the key-value store.
120
128
  * The function returns a promise that resolves once the record has been saved or deleted.
@@ -145,7 +153,7 @@ export declare class KeyValueStore {
145
153
  * {@link KeyValueStore.getValue} function.
146
154
  *
147
155
  * **IMPORTANT:** Always make sure to use the `await` keyword when calling `setValue()`,
148
- * otherwise the actor process might finish before the value is stored!
156
+ * otherwise the crawler process might finish before the value is stored!
149
157
  *
150
158
  * @param key
151
159
  * Unique key of the record. It can be at most 256 characters long and only consist
@@ -169,6 +177,8 @@ export declare class KeyValueStore {
169
177
  * access the value in the remote key-value store.
170
178
  */
171
179
  getPublicUrl(key: string): string;
180
+ /** @internal */
181
+ clearCache(): void;
172
182
  /**
173
183
  * Iterates over key-value store keys, yielding each in turn to an `iteratee` function.
174
184
  * Each invocation of `iteratee` is called with three arguments: `(key, index, info)`, where `key`
@@ -203,10 +213,103 @@ export declare class KeyValueStore {
203
213
  *
204
214
  * @param [storeIdOrName]
205
215
  * ID or name of the key-value store to be opened. If `null` or `undefined`,
206
- * the function returns the default key-value store associated with the actor run.
216
+ * the function returns the default key-value store associated with the crawler run.
207
217
  * @param [options] Storage manager options.
208
218
  */
209
219
  static open(storeIdOrName?: string | null, options?: StorageManagerOptions): Promise<KeyValueStore>;
220
+ /**
221
+ * Gets a value from the default {@link KeyValueStore} associated with the current crawler run.
222
+ *
223
+ * This is just a convenient shortcut for {@link KeyValueStore.getValue}.
224
+ * For example, calling the following code:
225
+ * ```javascript
226
+ * const value = await KeyValueStore.getValue('my-key');
227
+ * ```
228
+ *
229
+ * is equivalent to:
230
+ * ```javascript
231
+ * const store = await KeyValueStore.open();
232
+ * const value = await store.getValue('my-key');
233
+ * ```
234
+ *
235
+ * To store the value to the default key-value store, you can use the {@link KeyValueStore.setValue} function.
236
+ *
237
+ * For more information, see {@link KeyValueStore.open}
238
+ * and {@link KeyValueStore.getValue}.
239
+ *
240
+ * @param key Unique record key.
241
+ * @param defaultValue Fallback that will be returned if no value if present in the storage.
242
+ * @returns
243
+ * Returns a promise that resolves to an object, string
244
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
245
+ * on the MIME content type of the record, or `null`
246
+ * if the record is missing.
247
+ * @ignore
248
+ */
249
+ static getValue<T = unknown>(key: string, defaultValue?: T): Promise<T | null>;
250
+ static getAutoSavedValue<T extends Dictionary = Dictionary>(key: string, defaultValue?: T): Promise<T>;
251
+ /**
252
+ * Stores or deletes a value in the default {@link KeyValueStore} associated with the current crawler run.
253
+ *
254
+ * This is just a convenient shortcut for {@link KeyValueStore.setValue}.
255
+ * For example, calling the following code:
256
+ * ```javascript
257
+ * await KeyValueStore.setValue('OUTPUT', { foo: "bar" });
258
+ * ```
259
+ *
260
+ * is equivalent to:
261
+ * ```javascript
262
+ * const store = await KeyValueStore.open();
263
+ * await store.setValue('OUTPUT', { foo: "bar" });
264
+ * ```
265
+ *
266
+ * To get a value from the default key-value store, you can use the {@link KeyValueStore.getValue} function.
267
+ *
268
+ * For more information, see {@link KeyValueStore.open}
269
+ * and {@link KeyValueStore.getValue}.
270
+ *
271
+ * @param key
272
+ * Unique record key.
273
+ * @param value
274
+ * Record data, which can be one of the following values:
275
+ * - If `null`, the record in the key-value store is deleted.
276
+ * - If no `options.contentType` is specified, `value` can be any JavaScript object, and it will be stringified to JSON.
277
+ * - If `options.contentType` is set, `value` is taken as is, and it must be a `String` or [`Buffer`](https://nodejs.org/api/buffer.html).
278
+ * For any other value an error will be thrown.
279
+ * @param [options]
280
+ * @ignore
281
+ */
282
+ static setValue<T>(key: string, value: T | null, options?: RecordOptions): Promise<void>;
283
+ /**
284
+ * Gets the crawler input value from the default {@link KeyValueStore} associated with the current crawler run.
285
+ *
286
+ * This is just a convenient shortcut for [`keyValueStore.getValue('INPUT')`](core/class/KeyValueStore#getValue).
287
+ * For example, calling the following code:
288
+ * ```javascript
289
+ * const input = await KeyValueStore.getInput();
290
+ * ```
291
+ *
292
+ * is equivalent to:
293
+ * ```javascript
294
+ * const store = await KeyValueStore.open();
295
+ * await store.getValue('INPUT');
296
+ * ```
297
+ *
298
+ * Note that the `getInput()` function does not cache the value read from the key-value store.
299
+ * If you need to use the input multiple times in your crawler,
300
+ * it is far more efficient to read it once and store it locally.
301
+ *
302
+ * For more information, see {@link KeyValueStore.open}
303
+ * and {@link KeyValueStore.getValue}.
304
+ *
305
+ * @returns
306
+ * Returns a promise that resolves to an object, string
307
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
308
+ * on the MIME content type of the record, or `null`
309
+ * if the record is missing.
310
+ * @ignore
311
+ */
312
+ static getInput<T = Dictionary | string | Buffer>(): Promise<T | null>;
210
313
  }
211
314
  /**
212
315
  * User-function used in the {@link KeyValueStore.forEachKey} method.
@@ -1 +1 @@
1
- {"version":3,"file":"key_value_store.d.ts","sourceRoot":"","sources":["../../src/storages/key_value_store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAuB,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,aAAa,E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AE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;WAKvE,iBAAiB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,IAAU,GAAG,OAAO,CAAC,CAAC,CAAC;IAKlH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACU,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlG;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;WACU,QAAQ,CAAC,CAAC,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAI/E;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;;;;OAKG;IACH,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;CACzE;AAED,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
@@ -40,19 +40,19 @@ exports.maybeStringify = maybeStringify;
40
40
  * The `KeyValueStore` class represents a key-value store, a simple data storage that is used
41
41
  * for saving and reading data records or files. Each data record is
42
42
  * represented by a unique key and associated with a MIME content type. Key-value stores are ideal
43
- * for saving screenshots, actor inputs and outputs, web pages, PDFs or to persist the state of crawlers.
43
+ * for saving screenshots, crawler inputs and outputs, web pages, PDFs or to persist the state of crawlers.
44
44
  *
45
45
  * Do not instantiate this class directly, use the
46
46
  * {@link KeyValueStore.open} function instead.
47
47
  *
48
- * Each actor run is associated with a default key-value store, which is created exclusively
49
- * for the run. By convention, the actor input and output are stored into the
48
+ * Each crawler run is associated with a default key-value store, which is created exclusively
49
+ * for the run. By convention, the crawler input and output are stored into the
50
50
  * default key-value store under the `INPUT` and `OUTPUT` key, respectively.
51
51
  * Typically, input and output are JSON files, although it can be any other format.
52
52
  * To access the default key-value store directly, you can use the
53
- * {@link Actor.getValue} and {@link Actor.setValue} convenience functions.
53
+ * {@link KeyValueStore.getValue} and {@link KeyValueStore.setValue} convenience functions.
54
54
  *
55
- * To access the input, you can also use the {@link Actor.getInput} convenience function.
55
+ * To access the input, you can also use the {@link KeyValueStore.getInput} convenience function.
56
56
  *
57
57
  * `KeyValueStore` stores its data either on local disk or in the Apify cloud,
58
58
  * depending on whether the [`APIFY_IS_AT_HOME`](/docs/guides/environment-variables#apify_is_at_home)
@@ -77,13 +77,13 @@ exports.maybeStringify = maybeStringify;
77
77
  * **Example usage:**
78
78
  *
79
79
  * ```javascript
80
- * // Get actor input from the default key-value store.
81
- * const input = await Actor.getInput();
80
+ * // Get crawler input from the default key-value store.
81
+ * const input = await KeyValueStore.getInput();
82
82
  * // Get some value from the default key-value store.
83
- * const otherValue = await Actor.getValue('my-key');
83
+ * const otherValue = await KeyValueStore.getValue('my-key');
84
84
  *
85
- * // Write actor output to the default key-value store.
86
- * await Actor.setValue('OUTPUT', { myResult: 123 });
85
+ * // Write crawler output to the default key-value store.
86
+ * await KeyValueStore.setValue('OUTPUT', { myResult: 123 });
87
87
  *
88
88
  * // Open a named key-value store
89
89
  * const store = await KeyValueStore.open('some-name');
@@ -130,6 +130,19 @@ class KeyValueStore {
130
130
  writable: true,
131
131
  value: void 0
132
132
  });
133
+ Object.defineProperty(this, "persistStateEventStarted", {
134
+ enumerable: true,
135
+ configurable: true,
136
+ writable: true,
137
+ value: false
138
+ });
139
+ /** Cache for persistent (auto-saved) values. When we try to set such value, the cache will be updated automatically. */
140
+ Object.defineProperty(this, "cache", {
141
+ enumerable: true,
142
+ configurable: true,
143
+ writable: true,
144
+ value: new Map()
145
+ });
133
146
  this.id = options.id;
134
147
  this.name = options.name;
135
148
  this.client = options.client.keyValueStore(this.id);
@@ -159,15 +172,37 @@ class KeyValueStore {
159
172
  * @param key
160
173
  * Unique key of the record. It can be at most 256 characters long and only consist
161
174
  * of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
175
+ * @param defaultValue
176
+ * Fallback that will be returned if no value if present in the storage.
162
177
  * @returns
163
178
  * Returns a promise that resolves to an object, string
164
179
  * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
165
180
  * on the MIME content type of the record.
166
181
  */
167
- async getValue(key) {
182
+ async getValue(key, defaultValue) {
168
183
  (0, ow_1.default)(key, ow_1.default.string.nonEmpty);
169
184
  const record = await this.client.getRecord(key);
170
- return record?.value ?? null;
185
+ return record?.value ?? defaultValue ?? null;
186
+ }
187
+ async getAutoSavedValue(key, defaultValue = {}) {
188
+ if (this.cache.has(key)) {
189
+ return this.cache.get(key);
190
+ }
191
+ const value = await this.getValue(key, defaultValue);
192
+ this.cache.set(key, value);
193
+ this.ensurePersistStateEvent();
194
+ return value;
195
+ }
196
+ ensurePersistStateEvent() {
197
+ if (this.persistStateEventStarted) {
198
+ return;
199
+ }
200
+ this.config.getEventManager().on('persistState', async () => {
201
+ for (const [key, value] of this.cache) {
202
+ await this.setValue(key, value);
203
+ }
204
+ });
205
+ this.persistStateEventStarted = true;
171
206
  }
172
207
  /**
173
208
  * Saves or deletes a record in the key-value store.
@@ -199,7 +234,7 @@ class KeyValueStore {
199
234
  * {@link KeyValueStore.getValue} function.
200
235
  *
201
236
  * **IMPORTANT:** Always make sure to use the `await` keyword when calling `setValue()`,
202
- * otherwise the actor process might finish before the value is stored!
237
+ * otherwise the crawler process might finish before the value is stored!
203
238
  *
204
239
  * @param key
205
240
  * Unique key of the record. It can be at most 256 characters long and only consist
@@ -227,6 +262,22 @@ class KeyValueStore {
227
262
  }));
228
263
  // Make copy of options, don't update what user passed.
229
264
  const optionsCopy = { ...options };
265
+ // If we try to set the value of a cached state to a different reference, we need to update the cache accordingly.
266
+ const cachedValue = this.cache.get(key);
267
+ if (this.cache.has(key) && cachedValue !== value) {
268
+ if (value === null) {
269
+ // Cached state can be only object, so a propagation of `null` means removing all its properties.
270
+ Object.keys(cachedValue).forEach((k) => this.cache.delete(k));
271
+ }
272
+ else if (typeof value === 'object') {
273
+ // We need to remove the keys that are no longer present in the new value.
274
+ Object.keys(cachedValue)
275
+ .filter((k) => !(k in value))
276
+ .forEach((k) => this.cache.delete(k));
277
+ // And update the existing ones + add new ones.
278
+ Object.assign(cachedValue, value);
279
+ }
280
+ }
230
281
  // In this case delete the record.
231
282
  if (value === null)
232
283
  return this.client.deleteRecord(key);
@@ -243,7 +294,7 @@ class KeyValueStore {
243
294
  */
244
295
  async drop() {
245
296
  await this.client.delete();
246
- const manager = new storage_manager_1.StorageManager(KeyValueStore, this.config);
297
+ const manager = storage_manager_1.StorageManager.getManager(KeyValueStore, this.config);
247
298
  manager.closeStorage(this);
248
299
  }
249
300
  /**
@@ -254,6 +305,10 @@ class KeyValueStore {
254
305
  // FIXME how should this work? should we remove this method or provide a way to configure the base url?
255
306
  return `https://api.apify.com/v2/key-value-stores/${this.id}/records/${key}`;
256
307
  }
308
+ /** @internal */
309
+ clearCache() {
310
+ this.cache.clear();
311
+ }
257
312
  /**
258
313
  * Iterates over key-value store keys, yielding each in turn to an `iteratee` function.
259
314
  * Each invocation of `iteratee` is called with three arguments: `(key, index, info)`, where `key`
@@ -304,17 +359,122 @@ class KeyValueStore {
304
359
  *
305
360
  * @param [storeIdOrName]
306
361
  * ID or name of the key-value store to be opened. If `null` or `undefined`,
307
- * the function returns the default key-value store associated with the actor run.
362
+ * the function returns the default key-value store associated with the crawler run.
308
363
  * @param [options] Storage manager options.
309
364
  */
310
365
  static async open(storeIdOrName, options = {}) {
311
- (0, ow_1.default)(storeIdOrName, ow_1.default.optional.string);
366
+ (0, ow_1.default)(storeIdOrName, ow_1.default.optional.any(ow_1.default.string, ow_1.default.null));
312
367
  (0, ow_1.default)(options, ow_1.default.object.exactShape({
313
368
  config: ow_1.default.optional.object.instanceOf(configuration_1.Configuration),
314
369
  }));
315
- const manager = new storage_manager_1.StorageManager(KeyValueStore, options.config);
370
+ const manager = storage_manager_1.StorageManager.getManager(KeyValueStore, options.config);
316
371
  return manager.openStorage(storeIdOrName);
317
372
  }
373
+ /**
374
+ * Gets a value from the default {@link KeyValueStore} associated with the current crawler run.
375
+ *
376
+ * This is just a convenient shortcut for {@link KeyValueStore.getValue}.
377
+ * For example, calling the following code:
378
+ * ```javascript
379
+ * const value = await KeyValueStore.getValue('my-key');
380
+ * ```
381
+ *
382
+ * is equivalent to:
383
+ * ```javascript
384
+ * const store = await KeyValueStore.open();
385
+ * const value = await store.getValue('my-key');
386
+ * ```
387
+ *
388
+ * To store the value to the default key-value store, you can use the {@link KeyValueStore.setValue} function.
389
+ *
390
+ * For more information, see {@link KeyValueStore.open}
391
+ * and {@link KeyValueStore.getValue}.
392
+ *
393
+ * @param key Unique record key.
394
+ * @param defaultValue Fallback that will be returned if no value if present in the storage.
395
+ * @returns
396
+ * Returns a promise that resolves to an object, string
397
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
398
+ * on the MIME content type of the record, or `null`
399
+ * if the record is missing.
400
+ * @ignore
401
+ */
402
+ static async getValue(key, defaultValue) {
403
+ const store = await this.open();
404
+ return store.getValue(key, defaultValue);
405
+ }
406
+ static async getAutoSavedValue(key, defaultValue = {}) {
407
+ const store = await this.open();
408
+ return store.getAutoSavedValue(key, defaultValue);
409
+ }
410
+ /**
411
+ * Stores or deletes a value in the default {@link KeyValueStore} associated with the current crawler run.
412
+ *
413
+ * This is just a convenient shortcut for {@link KeyValueStore.setValue}.
414
+ * For example, calling the following code:
415
+ * ```javascript
416
+ * await KeyValueStore.setValue('OUTPUT', { foo: "bar" });
417
+ * ```
418
+ *
419
+ * is equivalent to:
420
+ * ```javascript
421
+ * const store = await KeyValueStore.open();
422
+ * await store.setValue('OUTPUT', { foo: "bar" });
423
+ * ```
424
+ *
425
+ * To get a value from the default key-value store, you can use the {@link KeyValueStore.getValue} function.
426
+ *
427
+ * For more information, see {@link KeyValueStore.open}
428
+ * and {@link KeyValueStore.getValue}.
429
+ *
430
+ * @param key
431
+ * Unique record key.
432
+ * @param value
433
+ * Record data, which can be one of the following values:
434
+ * - If `null`, the record in the key-value store is deleted.
435
+ * - If no `options.contentType` is specified, `value` can be any JavaScript object, and it will be stringified to JSON.
436
+ * - If `options.contentType` is set, `value` is taken as is, and it must be a `String` or [`Buffer`](https://nodejs.org/api/buffer.html).
437
+ * For any other value an error will be thrown.
438
+ * @param [options]
439
+ * @ignore
440
+ */
441
+ static async setValue(key, value, options = {}) {
442
+ const store = await this.open();
443
+ return store.setValue(key, value, options);
444
+ }
445
+ /**
446
+ * Gets the crawler input value from the default {@link KeyValueStore} associated with the current crawler run.
447
+ *
448
+ * This is just a convenient shortcut for [`keyValueStore.getValue('INPUT')`](core/class/KeyValueStore#getValue).
449
+ * For example, calling the following code:
450
+ * ```javascript
451
+ * const input = await KeyValueStore.getInput();
452
+ * ```
453
+ *
454
+ * is equivalent to:
455
+ * ```javascript
456
+ * const store = await KeyValueStore.open();
457
+ * await store.getValue('INPUT');
458
+ * ```
459
+ *
460
+ * Note that the `getInput()` function does not cache the value read from the key-value store.
461
+ * If you need to use the input multiple times in your crawler,
462
+ * it is far more efficient to read it once and store it locally.
463
+ *
464
+ * For more information, see {@link KeyValueStore.open}
465
+ * and {@link KeyValueStore.getValue}.
466
+ *
467
+ * @returns
468
+ * Returns a promise that resolves to an object, string
469
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
470
+ * on the MIME content type of the record, or `null`
471
+ * if the record is missing.
472
+ * @ignore
473
+ */
474
+ static async getInput() {
475
+ const store = await this.open();
476
+ return store.getValue(store.config.get('inputKey'));
477
+ }
318
478
  }
319
479
  exports.KeyValueStore = KeyValueStore;
320
480
  //# sourceMappingURL=key_value_store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"key_value_store.js","sourceRoot":"","sources":["../../src/storages/key_value_store.ts"],"names":[],"mappings":";;;;AAAA,0CAA0D;AAC1D,gDAAyD;AACzD,iDAAuC;AAEvC,oDAAiD;AAEjD,uDAA0E;AAE1E;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAI,KAAQ,EAAE,OAAiC,EAAE,EAAE;IAC7E,+DAA+D;IAC/D,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE;QACnE,OAAO,CAAC,WAAW,GAAG,iCAAiC,CAAC;QAExD,IAAI;YACA,kFAAkF;YAClF,KAAK,GAAG,IAAA,iCAAqB,EAAC,KAAmB,EAAE,IAAI,EAAE,CAAC,CAAiB,CAAC;SAC/E;QAAC,OAAO,CAAC,EAAE;YACR,MAAM,KAAK,GAAG,CAAU,CAAC;YACzB,qCAAqC;YACrC,IAAI,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE;gBACtD,KAAK,CAAC,OAAO,GAAG,qBAAqB,CAAC;aACzC;YACD,MAAM,IAAI,KAAK,CAAC,wDAAwD,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;SAC5F;QAED,IAAI,KAAK,KAAK,SAAS,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,wEAAwE;kBAClF,+DAA+D,CAAC,CAAC;SAC1E;KACJ;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAxBW,QAAA,cAAc,kBAwBzB;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,KAAK,CAAC,QAAQ,CAAc,GAAW,EAAE,YAAgB;QAC5D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,QAAQ,CAAI,GAAG,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAoC,GAAW,EAAE,eAAe,EAAO;QACjG,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,iBAAiB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAI,GAAW,EAAE,KAAe,EAAE,UAAyB,EAAE;QAC9E,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ;QACjB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,QAAQ,CAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ;AAlXD,sCAkXC"}
@@ -49,7 +49,7 @@ export interface RequestListOptions {
49
49
  * This is very useful in a scenario when getting the sources is a resource intensive or time consuming
50
50
  * task, such as fetching URLs from multiple sitemaps or parsing URLs from large datasets. Using the
51
51
  * `sourcesFunction` in combination with `persistStateKey` and `persistRequestsKey` will allow you to
52
- * fetch and parse those URLs only once, saving valuable time when your actor migrates or restarts.
52
+ * fetch and parse those URLs only once, saving valuable time when your crawler migrates or restarts.
53
53
  *
54
54
  * If both {@link RequestListOptions.sources} and {@link RequestListOptions.sourcesFunction} are provided,
55
55
  * the sources returned by the function will be added after the `sources`.
@@ -67,7 +67,7 @@ export interface RequestListOptions {
67
67
  *
68
68
  * // Sitemaps can change in real-time, so it's important to persist
69
69
  * // the URLs we collected. Otherwise we might lose our scraping
70
- * // state in case of an actor migration / failure / time-out.
70
+ * // state in case of an crawler migration / failure / time-out.
71
71
  * const requestList = new RequestList({
72
72
  * sourcesFunction,
73
73
  * persistStateKey: 'state-key',
@@ -91,7 +91,7 @@ export interface RequestListOptions {
91
91
  /**
92
92
  * Identifies the key in the default key-value store under which `RequestList` periodically stores its
93
93
  * state (i.e. which URLs were crawled and which not).
94
- * If the actor is restarted, `RequestList` will read the state
94
+ * If the crawler is restarted, `RequestList` will read the state
95
95
  * and continue where it left off.
96
96
  *
97
97
  * If `persistStateKey` is not set, `RequestList` will always start from the beginning,
@@ -174,9 +174,9 @@ export interface RequestListOptions {
174
174
  * which are in progress and which were reclaimed. The state may be automatically persisted to the default
175
175
  * {@link KeyValueStore} by setting the `persistStateKey` option so that if the Node.js process is restarted,
176
176
  * the crawling can continue where it left off. The automated persisting is launched upon receiving the `persistState`
177
- * event that is periodically emitted by {@link events|Actor.events}.
177
+ * event that is periodically emitted by {@link EventManager}.
178
178
  *
179
- * The internal state is closely tied to the provided sources (URLs). If the sources change on actor restart, the state will become corrupted and
179
+ * The internal state is closely tied to the provided sources (URLs). If the sources change on crawler restart, the state will become corrupted and
180
180
  * `RequestList` will raise an exception. This typically happens when the sources is a list of URLs downloaded from the web.
181
181
  * In such case, use the `persistRequestsKey` option in conjunction with `persistStateKey`,
182
182
  * to make the `RequestList` store the initial sources to the default key-value store and load them after restart,
@@ -1 +1 @@
1
- {"version":3,"file":"request_list.d.ts","sourceRoot":"","sources":["../../src/storages/request_list.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,c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B,GAAG,OAAO,CAAC,WAAW,CAAC;IAgBrH;;OAEG;YACW,mBAAmB;CAGpC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,gBAAgB;IAE7B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,mFAAmF;IACnF,UAAU,EAAE,MAAM,EAAE,CAAC;CAExB;AAED,oBAAY,MAAM,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC;AACjH,aAAK,cAAc,GAAG;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,oBAAY,0BAA0B,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC"}
@@ -40,9 +40,9 @@ const CONTENT_TYPE_BINARY = 'application/octet-stream';
40
40
  * which are in progress and which were reclaimed. The state may be automatically persisted to the default
41
41
  * {@link KeyValueStore} by setting the `persistStateKey` option so that if the Node.js process is restarted,
42
42
  * the crawling can continue where it left off. The automated persisting is launched upon receiving the `persistState`
43
- * event that is periodically emitted by {@link events|Actor.events}.
43
+ * event that is periodically emitted by {@link EventManager}.
44
44
  *
45
- * The internal state is closely tied to the provided sources (URLs). If the sources change on actor restart, the state will become corrupted and
45
+ * The internal state is closely tied to the provided sources (URLs). If the sources change on crawler restart, the state will become corrupted and
46
46
  * `RequestList` will raise an exception. This typically happens when the sources is a list of URLs downloaded from the web.
47
47
  * In such case, use the `persistRequestsKey` option in conjunction with `persistStateKey`,
48
48
  * to make the `RequestList` store the initial sources to the default key-value store and load them after restart,
@@ -701,7 +701,7 @@ class RequestList {
701
701
  * options and the `sources` parameter supersedes the {@link RequestListOptions.sources} option.
702
702
  */
703
703
  static async open(listName, sources, options = {}) {
704
- (0, ow_1.default)(listName, ow_1.default.any(ow_1.default.string, ow_1.default.null));
704
+ (0, ow_1.default)(listName, ow_1.default.optional.any(ow_1.default.string, ow_1.default.null));
705
705
  (0, ow_1.default)(sources, ow_1.default.array);
706
706
  (0, ow_1.default)(options, ow_1.default.object.is((v) => !Array.isArray(v)));
707
707
  const rl = new RequestList({