@crawlee/core 4.0.0-beta.197 → 4.0.0-beta.198

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.
@@ -25,8 +25,6 @@ export declare const crawleeConfigFields: {
25
25
  internalTimeoutMillis: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber, unknown>>>;
26
26
  /** @default 1_000 */
27
27
  systemInfoIntervalMillis: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
28
- /** @default 'INPUT' */
29
- inputKey: ConfigField<z.ZodDefault<z.ZodString>>;
30
28
  /** @default true */
31
29
  headless: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
32
30
  /** @default false */
@@ -105,7 +103,6 @@ export interface Configuration extends ResolvedConfigValues {
105
103
  *
106
104
  * Key | Environment Variable | Default Value
107
105
  * ---|---|---
108
- * `inputKey` | `CRAWLEE_INPUT_KEY` | `'INPUT'`
109
106
  * `xvfb` | `CRAWLEE_XVFB` | `false`
110
107
  * `chromeExecutablePath` | `CRAWLEE_CHROME_EXECUTABLE_PATH` | -
111
108
  * `defaultBrowserPath` | `CRAWLEE_DEFAULT_BROWSER_PATH` | -
package/configuration.js CHANGED
@@ -55,8 +55,6 @@ export const crawleeConfigFields = {
55
55
  internalTimeoutMillis: field(coerceNumber.optional(), 'CRAWLEE_INTERNAL_TIMEOUT'),
56
56
  /** @default 1_000 */
57
57
  systemInfoIntervalMillis: field(coerceNumber.default(1_000)),
58
- /** @default 'INPUT' */
59
- inputKey: field(z.string().default('INPUT'), 'CRAWLEE_INPUT_KEY'),
60
58
  /** @default true */
61
59
  headless: field(coerceBoolean.default(true), 'CRAWLEE_HEADLESS'),
62
60
  /** @default false */
@@ -123,7 +121,6 @@ export const crawleeConfigFields = {
123
121
  *
124
122
  * Key | Environment Variable | Default Value
125
123
  * ---|---|---
126
- * `inputKey` | `CRAWLEE_INPUT_KEY` | `'INPUT'`
127
124
  * `xvfb` | `CRAWLEE_XVFB` | `false`
128
125
  * `chromeExecutablePath` | `CRAWLEE_CHROME_EXECUTABLE_PATH` | -
129
126
  * `defaultBrowserPath` | `CRAWLEE_DEFAULT_BROWSER_PATH` | -
@@ -139,13 +139,11 @@ export class MemoryStorageBackend {
139
139
  // `#resolveStorageKey` leaves `name` unset for the default and alias-keyed storages, which is what
140
140
  // marks them as run-scoped. `'default'` is the exception — it collapses onto the default storage.
141
141
  const isRunScoped = (store) => store.name === undefined || store.name === 'default';
142
- const isDefault = (store) => store.name === 'default' || store.cacheKey === 'default';
143
142
  const purgeRunScoped = async (cache, purgeStore) => {
144
143
  await Promise.all(cache.filter(isRunScoped).map(async (store) => purgeStore(store)));
145
144
  };
146
145
  await Promise.all([
147
- // Only the default store holds the run input, so it is the only one that keeps `INPUT`.
148
- purgeRunScoped(this.#keyValueStoreBackendCache, async (store) => isDefault(store) ? store.purgeExceptInput() : store.purge()),
146
+ purgeRunScoped(this.#keyValueStoreBackendCache, async (store) => store.purge()),
149
147
  purgeRunScoped(this.#datasetBackendCache, async (store) => store.purge()),
150
148
  purgeRunScoped(this.#requestQueueBackendCache, async (store) => store.purge()),
151
149
  ]);
@@ -34,13 +34,6 @@ export declare class KeyValueStoreBackend extends BaseClient implements storage.
34
34
  getMetadata(): Promise<storage.KeyValueStoreInfo>;
35
35
  drop(): Promise<void>;
36
36
  purge(): Promise<void>;
37
- /**
38
- * Purges every record except the run's input. Used by {@link MemoryStorageBackend.purge} for the
39
- * default key-value store, mirroring `FileSystemStorageBackend`, which preserves `INPUT` (and its
40
- * extension variants) when purging the default store. The in-memory key has no extension, so we
41
- * preserve the bare `INPUT` key only.
42
- */
43
- purgeExceptInput(): Promise<void>;
44
37
  listKeys(options?: storage.KeyValueStoreListKeysOptions): Promise<storage.KeyValueStoreListKeysResult>;
45
38
  /**
46
39
  * In-memory records are not file-backed, so there is no public file URL to return.
@@ -20,11 +20,6 @@ const inputRecordSchema = z.object({
20
20
  ]),
21
21
  contentType: z.string().min(1).optional(),
22
22
  });
23
- /**
24
- * Key under which a run's input is stored in the default key-value store. Matches Crawlee's default
25
- * `inputKey` (`CRAWLEE_INPUT_KEY`) and the `INPUT` files `FileSystemStorageBackend` preserves on purge.
26
- */
27
- const KEY_VALUE_STORE_INPUT_KEY = 'INPUT';
28
23
  export class KeyValueStoreBackend extends BaseClient {
29
24
  name;
30
25
  /**
@@ -57,20 +52,6 @@ export class KeyValueStoreBackend extends BaseClient {
57
52
  this.#keyValueEntries.clear();
58
53
  this.updateTimestamps(true);
59
54
  }
60
- /**
61
- * Purges every record except the run's input. Used by {@link MemoryStorageBackend.purge} for the
62
- * default key-value store, mirroring `FileSystemStorageBackend`, which preserves `INPUT` (and its
63
- * extension variants) when purging the default store. The in-memory key has no extension, so we
64
- * preserve the bare `INPUT` key only.
65
- */
66
- async purgeExceptInput() {
67
- for (const key of this.#keyValueEntries.keys()) {
68
- if (key !== KEY_VALUE_STORE_INPUT_KEY) {
69
- this.#keyValueEntries.delete(key);
70
- }
71
- }
72
- this.updateTimestamps(true);
73
- }
74
55
  async listKeys(options = {}) {
75
56
  const { prefix, exclusiveStartKey, limit } = parseArgument(options, schemas.keyValueStoreListKeysOptions);
76
57
  const items = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/core",
3
- "version": "4.0.0-beta.197",
3
+ "version": "4.0.0-beta.198",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -53,10 +53,10 @@
53
53
  "@apify/log": "^3.0.1",
54
54
  "@apify/timeout": "^1.0.1",
55
55
  "@apify/utilities": "^3.0.1",
56
- "@crawlee/fs-storage": "4.0.0-beta.197",
57
- "@crawlee/http-client": "4.0.0-beta.197",
58
- "@crawlee/types": "4.0.0-beta.197",
59
- "@crawlee/utils": "4.0.0-beta.197",
56
+ "@crawlee/fs-storage": "4.0.0-beta.198",
57
+ "@crawlee/http-client": "4.0.0-beta.198",
58
+ "@crawlee/types": "4.0.0-beta.198",
59
+ "@crawlee/utils": "4.0.0-beta.198",
60
60
  "@sapphire/async-queue": "^1.5.5",
61
61
  "@standard-schema/spec": "^1.0.0",
62
62
  "@vladfrangu/async_event_emitter": "^2.4.6",
@@ -76,5 +76,5 @@
76
76
  }
77
77
  }
78
78
  },
79
- "gitHead": "6dfbf74898b378341626fbe0c5ff7655b57ac305"
79
+ "gitHead": "889cfffcc20b2803f0d95d7cb006ad1e7f672452"
80
80
  }
@@ -124,7 +124,6 @@ export class ServiceLocator {
124
124
  this.#storageBackend = configuration.persistStorage
125
125
  ? new FileSystemStorageBackend({
126
126
  localDataDirectory: configuration.storageDir,
127
- inputKey: configuration.inputKey,
128
127
  logger: this.getLogger().child({ prefix: 'FileSystemStorageBackend' }),
129
128
  })
130
129
  : new MemoryStorageBackend({
@@ -20,8 +20,6 @@ import type { StorageIdentifier } from './storage_instance_manager.js';
20
20
  * To access the default key-value store directly, you can use the
21
21
  * {@link KeyValueStore.getValue} and {@link KeyValueStore.setValue} convenience functions.
22
22
  *
23
- * To access the input, you can also use the {@link KeyValueStore.getInput} convenience function.
24
- *
25
23
  * `KeyValueStore` stores its data on a local disk.
26
24
  *
27
25
  * If the `CRAWLEE_STORAGE_DIR` environment variable is set, the data is stored in
@@ -36,7 +34,7 @@ import type { StorageIdentifier } from './storage_instance_manager.js';
36
34
  *
37
35
  * ```javascript
38
36
  * // Get crawler input from the default key-value store.
39
- * const input = await KeyValueStore.getInput();
37
+ * const input = await KeyValueStore.getValue('INPUT');
40
38
  * // Get some value from the default key-value store.
41
39
  * const otherValue = await KeyValueStore.getValue('my-key');
42
40
  *
@@ -492,27 +490,6 @@ export declare class KeyValueStore {
492
490
  * @ignore
493
491
  */
494
492
  static setValue<T>(key: string, value: T | null, options?: RecordOptions): Promise<void>;
495
- /**
496
- * Gets the crawler input value from the default {@link KeyValueStore} associated with the current crawler run.
497
- *
498
- * The input is read from the default {@link KeyValueStore} under the configured input key
499
- * (`CRAWLEE_INPUT_KEY`, default `INPUT`).
500
- *
501
- * Note that the `getInput()` function does not cache the value read from the key-value store.
502
- * If you need to use the input multiple times in your crawler,
503
- * it is far more efficient to read it once and store it locally.
504
- *
505
- * For more information, see {@link KeyValueStore.open}
506
- * and {@link KeyValueStore.getValue}.
507
- *
508
- * @returns
509
- * Returns a promise that resolves to an object, string
510
- * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
511
- * on the MIME content type of the record, or `null`
512
- * if the record is missing.
513
- * @ignore
514
- */
515
- static getInput<T = Dictionary | string | Buffer>(): Promise<T | null>;
516
493
  }
517
494
  /**
518
495
  * User-function used in the {@link KeyValueStore.forEachKey} method.
@@ -42,8 +42,6 @@ const openOptionsSchema = z.strictObject({
42
42
  * To access the default key-value store directly, you can use the
43
43
  * {@link KeyValueStore.getValue} and {@link KeyValueStore.setValue} convenience functions.
44
44
  *
45
- * To access the input, you can also use the {@link KeyValueStore.getInput} convenience function.
46
- *
47
45
  * `KeyValueStore` stores its data on a local disk.
48
46
  *
49
47
  * If the `CRAWLEE_STORAGE_DIR` environment variable is set, the data is stored in
@@ -58,7 +56,7 @@ const openOptionsSchema = z.strictObject({
58
56
  *
59
57
  * ```javascript
60
58
  * // Get crawler input from the default key-value store.
61
- * const input = await KeyValueStore.getInput();
59
+ * const input = await KeyValueStore.getValue('INPUT');
62
60
  * // Get some value from the default key-value store.
63
61
  * const otherValue = await KeyValueStore.getValue('my-key');
64
62
  *
@@ -747,30 +745,6 @@ export class KeyValueStore {
747
745
  const store = await this.open();
748
746
  return store.setValue(key, value, options);
749
747
  }
750
- /**
751
- * Gets the crawler input value from the default {@link KeyValueStore} associated with the current crawler run.
752
- *
753
- * The input is read from the default {@link KeyValueStore} under the configured input key
754
- * (`CRAWLEE_INPUT_KEY`, default `INPUT`).
755
- *
756
- * Note that the `getInput()` function does not cache the value read from the key-value store.
757
- * If you need to use the input multiple times in your crawler,
758
- * it is far more efficient to read it once and store it locally.
759
- *
760
- * For more information, see {@link KeyValueStore.open}
761
- * and {@link KeyValueStore.getValue}.
762
- *
763
- * @returns
764
- * Returns a promise that resolves to an object, string
765
- * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
766
- * on the MIME content type of the record, or `null`
767
- * if the record is missing.
768
- * @ignore
769
- */
770
- static async getInput() {
771
- const store = await this.open();
772
- return store.getValue(store.configuration.inputKey);
773
- }
774
748
  }
775
749
  /** Normalizes a codec-serialized value into the `Buffer | ArrayBuffer` shape raw record reads promise. */
776
750
  function normalizeSerializedValue(value) {
@@ -16,7 +16,7 @@ interface PurgeDefaultStorageOptions {
16
16
  /**
17
17
  * Cleans up the local storage folder (defaults to `./storage`) created when running code locally.
18
18
  * Purging empties the storages that belong to a single run — the default one and every alias-keyed one —
19
- * keeping only INPUT.json in the default KV store. Named storages persist across runs and are not touched.
19
+ * Named storages persist across runs and are not touched.
20
20
  *
21
21
  * Purging of storages is happening automatically when we run our crawler (or when we open some storage
22
22
  * explicitly, e.g. via `RequestList.open()`). We can disable that via `purgeOnStart` {@link Configuration}
@@ -31,7 +31,7 @@ export declare function purgeDefaultStorages(options?: PurgeDefaultStorageOption
31
31
  /**
32
32
  * Cleans up the local storage folder (defaults to `./storage`) created when running code locally.
33
33
  * Purging empties the storages that belong to a single run — the default one and every alias-keyed one —
34
- * keeping only INPUT.json in the default KV store. Named storages persist across runs and are not touched.
34
+ * Named storages persist across runs and are not touched.
35
35
  *
36
36
  * Purging of storages is happening automatically when we run our crawler (or when we open some storage
37
37
  * explicitly, e.g. via `RequestList.open()`). We can disable that via `purgeOnStart` {@link Configuration}