apify 4.0.0-beta.72 → 4.0.0-beta.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actor.d.ts +9 -8
- package/dist/actor.js +21 -13
- package/dist/errors.d.ts +2 -2
- package/package.json +1 -1
package/dist/actor.d.ts
CHANGED
|
@@ -778,11 +778,12 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
778
778
|
* A record stored as `application/octet-stream` — which is what a local input file without an
|
|
779
779
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
780
780
|
*
|
|
781
|
-
* When running locally
|
|
782
|
-
*
|
|
781
|
+
* When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
|
|
782
|
+
* working directory. A storage backend that doesn't read the default key-value store's directory under
|
|
783
|
+
* the storage directory (e.g. in-memory storage) also gets the file `apify run` writes there.
|
|
783
784
|
*
|
|
784
|
-
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when
|
|
785
|
-
*
|
|
785
|
+
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
|
|
786
|
+
* found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
786
787
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
787
788
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest.
|
|
788
789
|
*
|
|
@@ -1414,11 +1415,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1414
1415
|
* A record stored as `application/octet-stream` — which is what a local input file without an
|
|
1415
1416
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
1416
1417
|
*
|
|
1417
|
-
* When running locally
|
|
1418
|
-
*
|
|
1418
|
+
* When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
|
|
1419
|
+
* working directory.
|
|
1419
1420
|
*
|
|
1420
|
-
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when
|
|
1421
|
-
*
|
|
1421
|
+
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
|
|
1422
|
+
* found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
1422
1423
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
1423
1424
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest:
|
|
1424
1425
|
* ```js
|
package/dist/actor.js
CHANGED
|
@@ -917,11 +917,12 @@ export class Actor {
|
|
|
917
917
|
* A record stored as `application/octet-stream` — which is what a local input file without an
|
|
918
918
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
919
919
|
*
|
|
920
|
-
* When running locally
|
|
921
|
-
*
|
|
920
|
+
* When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
|
|
921
|
+
* working directory. A storage backend that doesn't read the default key-value store's directory under
|
|
922
|
+
* the storage directory (e.g. in-memory storage) also gets the file `apify run` writes there.
|
|
922
923
|
*
|
|
923
|
-
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when
|
|
924
|
-
*
|
|
924
|
+
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
|
|
925
|
+
* found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
925
926
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
926
927
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest.
|
|
927
928
|
*
|
|
@@ -941,17 +942,24 @@ export class Actor {
|
|
|
941
942
|
*/
|
|
942
943
|
async getInput() {
|
|
943
944
|
this.ensureActorInit('getInput');
|
|
944
|
-
const { inputKey, inputSecretsPrivateKeyFile, inputSecretsPrivateKeyPassphrase } = this.configuration;
|
|
945
|
+
const { inputKey, inputSecretsPrivateKeyFile, inputSecretsPrivateKeyPassphrase, storageDir, defaultKeyValueStoreId, } = this.configuration;
|
|
946
|
+
// Where `apify run` writes the input (apify-cli `getLocalKeyValueStorePath`).
|
|
947
|
+
const defaultStoreDir = join(storageDir, 'key_value_stores', defaultKeyValueStoreId);
|
|
945
948
|
const store = await this.openKeyValueStore();
|
|
946
949
|
const record = await store.getRecord(inputKey);
|
|
947
|
-
|
|
950
|
+
// Not a conflict check: under the file-system backend the record *is* the store directory's file.
|
|
951
|
+
const storeInput = record
|
|
948
952
|
? parseInput(record.value, record.contentType, `the "${inputKey}" record of the default key-value store`)
|
|
949
|
-
:
|
|
950
|
-
|
|
953
|
+
: await this.readInputFromDirectory(inputKey, defaultStoreDir, 'default key-value store directory');
|
|
954
|
+
const cwdInput = await this.readInputFromDirectory(inputKey, process.cwd(), 'working directory');
|
|
955
|
+
if (storeInput != null && cwdInput != null) {
|
|
956
|
+
throw new ActorInputError('MULTIPLE_FILES', `Found the input both in the default key-value store and in a "${inputKey}" or "${inputKey}.json" file in the working directory. Keep only one of them.`);
|
|
957
|
+
}
|
|
958
|
+
const rawInput = storeInput ?? cwdInput;
|
|
951
959
|
if (rawInput == null) {
|
|
952
960
|
const locations = [`the "${inputKey}" record of the default key-value store`];
|
|
953
961
|
if (!this.configuration.isAtHome) {
|
|
954
|
-
locations.push(`a "${inputKey}" or "${inputKey}.json" file in the working or
|
|
962
|
+
locations.push(`a "${inputKey}" or "${inputKey}.json" file in the working or default key-value store directory`);
|
|
955
963
|
}
|
|
956
964
|
throw new ActorInputError('NOT_FOUND', `Input does not exist. Expected ${locations.join(' or ')}.`);
|
|
957
965
|
}
|
|
@@ -1665,11 +1673,11 @@ export class Actor {
|
|
|
1665
1673
|
* A record stored as `application/octet-stream` — which is what a local input file without an
|
|
1666
1674
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
1667
1675
|
*
|
|
1668
|
-
* When running locally
|
|
1669
|
-
*
|
|
1676
|
+
* When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
|
|
1677
|
+
* working directory.
|
|
1670
1678
|
*
|
|
1671
|
-
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when
|
|
1672
|
-
*
|
|
1679
|
+
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
|
|
1680
|
+
* found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
1673
1681
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
1674
1682
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest:
|
|
1675
1683
|
* ```js
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Why {@link Actor.getInput} could not produce the input. */
|
|
2
2
|
export type ActorInputErrorCode =
|
|
3
|
-
/** No input record in the default key-value store, and locally no input file
|
|
3
|
+
/** No input record in the default key-value store, and locally no input file either. */
|
|
4
4
|
'NOT_FOUND'
|
|
5
|
-
/**
|
|
5
|
+
/** The input is in more than one place — both `<inputKey>` and `<inputKey>.json` in one directory, or in the store and in the working directory — so none is picked. */
|
|
6
6
|
| 'MULTIPLE_FILES'
|
|
7
7
|
/** The secret fields of the input could not be decrypted; `cause` holds the underlying error. */
|
|
8
8
|
| 'DECRYPTION_FAILED'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apify",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.73",
|
|
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.13.0"
|