apify 4.0.0-beta.64 → 4.0.0-beta.65
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 +4 -4
- package/dist/actor.js +10 -9
- package/package.json +1 -1
package/dist/actor.d.ts
CHANGED
|
@@ -749,10 +749,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
749
749
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
750
750
|
*
|
|
751
751
|
* When running locally and the store holds no such record, the input is read from a `<inputKey>` or
|
|
752
|
-
* `<inputKey>.json` file in the current working directory
|
|
752
|
+
* `<inputKey>.json` file in the current working directory, then in the storage directory.
|
|
753
753
|
*
|
|
754
754
|
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when both input
|
|
755
|
-
* files exist in the working directory (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
755
|
+
* files exist in the working/storage directory (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
756
756
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
757
757
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest.
|
|
758
758
|
*
|
|
@@ -772,14 +772,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
772
772
|
*/
|
|
773
773
|
getInput<T = Dictionary | string | Buffer>(): Promise<T>;
|
|
774
774
|
/**
|
|
775
|
-
* Reads the input from a `<inputKey>` or `<inputKey>.json` file in the
|
|
775
|
+
* Reads the input from a `<inputKey>` or `<inputKey>.json` file in the given directory, for local runs
|
|
776
776
|
* whose default key-value store holds no input record. Mirrors how `ApifyFileSystemStorageBackend` adopts
|
|
777
777
|
* such files inside the store directory: the `.json` file is JSON, the bare one is bytes that
|
|
778
778
|
* {@link parseInputValue} tries as JSON5. Both files present is an error rather than a guess.
|
|
779
779
|
*
|
|
780
780
|
* @returns `undefined` when running on the platform or when neither file exists.
|
|
781
781
|
*/
|
|
782
|
-
private
|
|
782
|
+
private readInputFromDirectory;
|
|
783
783
|
/**
|
|
784
784
|
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
|
785
785
|
*
|
package/dist/actor.js
CHANGED
|
@@ -922,10 +922,10 @@ export class Actor {
|
|
|
922
922
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
923
923
|
*
|
|
924
924
|
* When running locally and the store holds no such record, the input is read from a `<inputKey>` or
|
|
925
|
-
* `<inputKey>.json` file in the current working directory
|
|
925
|
+
* `<inputKey>.json` file in the current working directory, then in the storage directory.
|
|
926
926
|
*
|
|
927
927
|
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when both input
|
|
928
|
-
* files exist in the working directory (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
928
|
+
* files exist in the working/storage directory (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
929
929
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
930
930
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest.
|
|
931
931
|
*
|
|
@@ -950,11 +950,12 @@ export class Actor {
|
|
|
950
950
|
const record = await store.getRecord(inputKey);
|
|
951
951
|
const rawInput = record
|
|
952
952
|
? parseInput(record.value, record.contentType, `the "${inputKey}" record of the default key-value store`)
|
|
953
|
-
: await this.
|
|
953
|
+
: ((await this.readInputFromDirectory(inputKey, process.cwd(), 'working directory')) ??
|
|
954
|
+
(await this.readInputFromDirectory(inputKey, this.configuration.storageDir, 'storage directory')));
|
|
954
955
|
if (rawInput == null) {
|
|
955
956
|
const locations = [`the "${inputKey}" record of the default key-value store`];
|
|
956
957
|
if (!this.configuration.isAtHome) {
|
|
957
|
-
locations.push(`a "${inputKey}" or "${inputKey}.json" file in the working directory`);
|
|
958
|
+
locations.push(`a "${inputKey}" or "${inputKey}.json" file in the working or storage directory`);
|
|
958
959
|
}
|
|
959
960
|
throw new ActorInputError('NOT_FOUND', `Input does not exist. Expected ${locations.join(' or ')}.`);
|
|
960
961
|
}
|
|
@@ -979,14 +980,14 @@ export class Actor {
|
|
|
979
980
|
return input;
|
|
980
981
|
}
|
|
981
982
|
/**
|
|
982
|
-
* Reads the input from a `<inputKey>` or `<inputKey>.json` file in the
|
|
983
|
+
* Reads the input from a `<inputKey>` or `<inputKey>.json` file in the given directory, for local runs
|
|
983
984
|
* whose default key-value store holds no input record. Mirrors how `ApifyFileSystemStorageBackend` adopts
|
|
984
985
|
* such files inside the store directory: the `.json` file is JSON, the bare one is bytes that
|
|
985
986
|
* {@link parseInputValue} tries as JSON5. Both files present is an error rather than a guess.
|
|
986
987
|
*
|
|
987
988
|
* @returns `undefined` when running on the platform or when neither file exists.
|
|
988
989
|
*/
|
|
989
|
-
async
|
|
990
|
+
async readInputFromDirectory(inputKey, directory, label) {
|
|
990
991
|
if (this.configuration.isAtHome) {
|
|
991
992
|
return undefined;
|
|
992
993
|
}
|
|
@@ -996,20 +997,20 @@ export class Actor {
|
|
|
996
997
|
];
|
|
997
998
|
const found = [];
|
|
998
999
|
for (const candidate of candidates) {
|
|
999
|
-
const path = join(
|
|
1000
|
+
const path = join(directory, candidate.filename);
|
|
1000
1001
|
const stats = await stat(path).catch(() => null);
|
|
1001
1002
|
if (stats?.isFile()) {
|
|
1002
1003
|
found.push({ ...candidate, path });
|
|
1003
1004
|
}
|
|
1004
1005
|
}
|
|
1005
1006
|
if (found.length > 1) {
|
|
1006
|
-
throw new ActorInputError('MULTIPLE_FILES', `Found multiple input files in the
|
|
1007
|
+
throw new ActorInputError('MULTIPLE_FILES', `Found multiple input files in the ${label}: ${found.map((file) => `"${file.filename}"`).join(', ')}. Keep only one of them.`);
|
|
1007
1008
|
}
|
|
1008
1009
|
if (found.length === 0) {
|
|
1009
1010
|
return undefined;
|
|
1010
1011
|
}
|
|
1011
1012
|
const [file] = found;
|
|
1012
|
-
return parseInput(await readFile(file.path), file.contentType, `the "${file.filename}" file in the
|
|
1013
|
+
return parseInput(await readFile(file.path), file.contentType, `the "${file.filename}" file in the ${label}`);
|
|
1013
1014
|
}
|
|
1014
1015
|
/**
|
|
1015
1016
|
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
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.65",
|
|
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"
|