apify 4.0.0-beta.129 → 4.0.0-beta.130
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 +1 -137
- package/dist/actor.js +6 -75
- package/dist/configuration.d.ts +18 -0
- package/dist/configuration.js +37 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/actor.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Dataset, KeyValueStore, RequestQueue } from '@crawlee/core';
|
|
|
3
3
|
import type { Awaitable, Dictionary, StorageBackend } from '@crawlee/types';
|
|
4
4
|
import type { ActorCallOptions, ActorInput, ActorStartOptions, ApifyClientOptions, RunAbortOptions, RunClient, RunResurrectOptions, TaskCallOptions, TaskStartOptions, WebhookResource, WebhookEventType } from 'apify-client';
|
|
5
5
|
import { ApifyClient, Run as ClientActorRun } from 'apify-client';
|
|
6
|
-
import { type ACTOR_PERMISSION_LEVEL } from '@apify/consts';
|
|
7
6
|
import type { RequestQueueAccessMode } from './apify_request_queue_backend.js';
|
|
8
7
|
import type { ChargeOptions, ChargeResult } from './charging.js';
|
|
9
8
|
import { ChargingManager } from './charging.js';
|
|
@@ -84,119 +83,6 @@ export interface SetStatusMessageOptions {
|
|
|
84
83
|
/** Log level used when the status message is also logged locally. Defaults to `INFO`. */
|
|
85
84
|
level?: 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR';
|
|
86
85
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Parsed representation of the Apify environment variables.
|
|
89
|
-
* This object is returned by the {@link Actor.getEnv} function.
|
|
90
|
-
*/
|
|
91
|
-
export interface ApifyEnv {
|
|
92
|
-
/**
|
|
93
|
-
* ID of the Actor (ACTOR_ID)
|
|
94
|
-
*/
|
|
95
|
-
actorId: string | null;
|
|
96
|
-
/**
|
|
97
|
-
* ID of the Actor run (ACTOR_RUN_ID)
|
|
98
|
-
*/
|
|
99
|
-
actorRunId: string | null;
|
|
100
|
-
/**
|
|
101
|
-
* ID of the Actor task (ACTOR_TASK_ID)
|
|
102
|
-
*/
|
|
103
|
-
actorTaskId: string | null;
|
|
104
|
-
/**
|
|
105
|
-
* ID of the Actor build used in the run. (ACTOR_BUILD_ID)
|
|
106
|
-
*/
|
|
107
|
-
actorBuildId: string | null;
|
|
108
|
-
/**
|
|
109
|
-
* [Permission level](https://docs.apify.com/platform/actors/development/permissions) the Actor is run under. (ACTOR_PERMISSION_LEVEL)
|
|
110
|
-
*/
|
|
111
|
-
actorPermissionLevel: ACTOR_PERMISSION_LEVEL | null;
|
|
112
|
-
/**
|
|
113
|
-
* ID of the user who started the Actor - note that it might be
|
|
114
|
-
* different than the owner of the Actor (APIFY_USER_ID)
|
|
115
|
-
*/
|
|
116
|
-
userId: string | null;
|
|
117
|
-
/**
|
|
118
|
-
* Whether the user who started the Actor is a paying user. `false` when not set. (APIFY_USER_IS_PAYING)
|
|
119
|
-
*/
|
|
120
|
-
userIsPaying: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Authentication token representing privileges given to the Actor run,
|
|
123
|
-
* it can be passed to various Apify APIs (APIFY_TOKEN)
|
|
124
|
-
*/
|
|
125
|
-
token: string | null;
|
|
126
|
-
/**
|
|
127
|
-
* Date when the Actor was started (ACTOR_STARTED_AT)
|
|
128
|
-
*/
|
|
129
|
-
startedAt: Date | null;
|
|
130
|
-
/**
|
|
131
|
-
* Date when the Actor will time out (ACTOR_TIMEOUT_AT)
|
|
132
|
-
*/
|
|
133
|
-
timeoutAt: Date | null;
|
|
134
|
-
/**
|
|
135
|
-
* ID of the key-value store where input and output data of this
|
|
136
|
-
* Actor is stored (ACTOR_DEFAULT_KEY_VALUE_STORE_ID)
|
|
137
|
-
*/
|
|
138
|
-
defaultKeyValueStoreId: string | null;
|
|
139
|
-
/**
|
|
140
|
-
* ID of the dataset where input and output data of this
|
|
141
|
-
* Actor is stored (ACTOR_DEFAULT_DATASET_ID)
|
|
142
|
-
*/
|
|
143
|
-
defaultDatasetId: string | null;
|
|
144
|
-
/**
|
|
145
|
-
* Amount of memory allocated for the Actor,
|
|
146
|
-
* in megabytes (ACTOR_MEMORY_MBYTES)
|
|
147
|
-
*/
|
|
148
|
-
memoryMbytes: number | null;
|
|
149
|
-
/**
|
|
150
|
-
* If set to "1", the web browsers inside the Actor should run in headless
|
|
151
|
-
* mode because there is no windowing system available. (APIFY_HEADLESS)
|
|
152
|
-
*/
|
|
153
|
-
headless: string | null;
|
|
154
|
-
/**
|
|
155
|
-
* Is set to "1" if the Actor is running on Apify servers.
|
|
156
|
-
* (APIFY_IS_AT_HOME)
|
|
157
|
-
*/
|
|
158
|
-
isAtHome: string | null;
|
|
159
|
-
/**
|
|
160
|
-
* The Apify Proxy password of the user who started the Actor. (APIFY_PROXY_PASSWORD)
|
|
161
|
-
*/
|
|
162
|
-
proxyPassword: string | null;
|
|
163
|
-
proxyHostname: string | null;
|
|
164
|
-
proxyPort: string | null;
|
|
165
|
-
/**
|
|
166
|
-
* You can visit this page to troubleshoot your proxy connection. (APIFY_PROXY_STATUS_URL)
|
|
167
|
-
*/
|
|
168
|
-
proxyStatusUrl: string | null;
|
|
169
|
-
apiBaseUrl: string | null;
|
|
170
|
-
apiPublicBaseUrl: string | null;
|
|
171
|
-
chromeExecutablePath: string | null;
|
|
172
|
-
dedicatedCpus: string | null;
|
|
173
|
-
fact: string | null;
|
|
174
|
-
inputSecretsPrivateKeyFile: string | null;
|
|
175
|
-
inputSecretsPrivateKeyPassphrase: string | null;
|
|
176
|
-
/**
|
|
177
|
-
* Specifies the minimum log level, which can be one of the following values (in order of severity): DEBUG, INFO, WARNING and ERROR
|
|
178
|
-
* (APIFY_LOG_LEVEL)
|
|
179
|
-
*/
|
|
180
|
-
logLevel: string | null;
|
|
181
|
-
logFormat: string | null;
|
|
182
|
-
/**
|
|
183
|
-
* Origin for the Actor run, i.e. how it was started. See [here](https://docs.apify.com/platform/actors/running/runs-and-builds#origin)
|
|
184
|
-
* for more details. (APIFY_META_ORIGIN)
|
|
185
|
-
*/
|
|
186
|
-
metaOrigin: string | null;
|
|
187
|
-
/**
|
|
188
|
-
* The key of the input record in the Actor’s default key-value store (ACTOR_INPUT_KEY)
|
|
189
|
-
*/
|
|
190
|
-
inputKey: string | null;
|
|
191
|
-
systemInfoIntervalMillis: string | null;
|
|
192
|
-
workflowKey: string | null;
|
|
193
|
-
actorBuildNumber: string | null;
|
|
194
|
-
actorEventsWsUrl: string | null;
|
|
195
|
-
actorMaxPaidDatasetItems: number | null;
|
|
196
|
-
containerPort: number | null;
|
|
197
|
-
containerUrl: string | null;
|
|
198
|
-
defaultRequestQueueId: string | null;
|
|
199
|
-
}
|
|
200
86
|
export type UserFunc<T = unknown> = () => Awaitable<T>;
|
|
201
87
|
export interface Token {
|
|
202
88
|
/**
|
|
@@ -272,8 +158,7 @@ export interface WebhookOptions {
|
|
|
272
158
|
/**
|
|
273
159
|
* Idempotency key enables you to ensure that a webhook will not be added multiple times in case of
|
|
274
160
|
* an Actor restart or other situation that would cause the `addWebhook()` function to be called again.
|
|
275
|
-
* We suggest using the Actor run ID as the idempotency key
|
|
276
|
-
* {@link Actor.getEnv} function.
|
|
161
|
+
* We suggest using the Actor run ID as the idempotency key, available as `Actor.configuration.actorRunId`.
|
|
277
162
|
*/
|
|
278
163
|
idempotencyKey?: string;
|
|
279
164
|
/**
|
|
@@ -937,19 +822,6 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
937
822
|
* Resolves to `undefined` when not running on the Apify platform.
|
|
938
823
|
*/
|
|
939
824
|
getCurrentRun(): Promise<ClientActorRun | undefined>;
|
|
940
|
-
/**
|
|
941
|
-
* Modifies Actor env vars so parsing respects the structure of {@link ApifyEnv} interface.
|
|
942
|
-
*/
|
|
943
|
-
private getModifiedActorEnvVars;
|
|
944
|
-
/**
|
|
945
|
-
* Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
|
|
946
|
-
*
|
|
947
|
-
* For the list of the Apify environment variables, see
|
|
948
|
-
* [Actor documentation](https://docs.apify.com/platform/actors/development/programming-interface/environment-variables).
|
|
949
|
-
* If some variables are not defined or are invalid, the corresponding value in the resulting object will be null.
|
|
950
|
-
* @ignore
|
|
951
|
-
*/
|
|
952
|
-
getEnv(): ApifyEnv;
|
|
953
825
|
/**
|
|
954
826
|
* Returns a new instance of the Apify API client. The `ApifyClient` class is provided
|
|
955
827
|
* by the [apify-client](https://www.npmjs.com/package/apify-client)
|
|
@@ -1570,14 +1442,6 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1570
1442
|
* Retrieve the charging manager to access granular pricing information.
|
|
1571
1443
|
*/
|
|
1572
1444
|
static getChargingManager(): ChargingManager;
|
|
1573
|
-
/**
|
|
1574
|
-
* Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
|
|
1575
|
-
*
|
|
1576
|
-
* For the list of the Apify environment variables, see
|
|
1577
|
-
* [Actor documentation](https://docs.apify.com/platform/actors/development/programming-interface/environment-variables).
|
|
1578
|
-
* If some of the variables are not defined or are invalid, the corresponding value in the resulting object will be null.
|
|
1579
|
-
*/
|
|
1580
|
-
static getEnv(): ApifyEnv;
|
|
1581
1445
|
/**
|
|
1582
1446
|
* Returns a new instance of the Apify API client. The `ApifyClient` class is provided
|
|
1583
1447
|
* by the [apify-client](https://www.npmjs.com/package/apify-client)
|
package/dist/actor.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createPrivateKey } from 'node:crypto';
|
|
2
2
|
import { readFile, stat } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { Dataset, EventType, KeyValueStore, MemoryStorageBackend, purgeDefaultStorages, rejectOperationInTransaction, RequestQueue, serviceLocator, } from '@crawlee/core';
|
|
5
5
|
import { sleep } from '@crawlee/utils';
|
|
6
6
|
import { ApifyClient } from 'apify-client';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import { ACTOR_ENV_VARS, ACTOR_EVENT_NAMES, APIFY_ENV_VARS,
|
|
8
|
+
import { ACTOR_ENV_VARS, ACTOR_EVENT_NAMES, APIFY_ENV_VARS, META_ORIGINS } from '@apify/consts';
|
|
9
9
|
import { decryptInputSecrets } from '@apify/input_secrets';
|
|
10
10
|
import log from '@apify/log';
|
|
11
11
|
import { addTimeoutToPromise } from '@apify/timeout';
|
|
@@ -22,15 +22,7 @@ import { getDefaultsFromInputSchema, noActorInputSchemaDefinedMarker, readInputS
|
|
|
22
22
|
import { PlatformEventManager } from './platform_event_manager.js';
|
|
23
23
|
import { ProxyConfiguration } from './proxy_configuration.js';
|
|
24
24
|
import { SmartApifyStorageBackend } from './smart_apify_storage_backend.js';
|
|
25
|
-
import { BINARY_CONTENT_TYPE, checkCrawleeVersion, getSystemInfo, isNonEmptyObject, JSON_CONTENT_TYPE, parseInputValue,
|
|
26
|
-
// `@apify/consts` has no boolean counterpart to `INTEGER_ENV_VARS`.
|
|
27
|
-
const BOOLEAN_ENV_VARS = [APIFY_ENV_VARS.USER_IS_PAYING];
|
|
28
|
-
// Still listed in `@apify/consts`, but not read by the SDK.
|
|
29
|
-
const IGNORED_ENV_VARS = [
|
|
30
|
-
APIFY_ENV_VARS.DISABLE_OUTDATED_WARNING,
|
|
31
|
-
APIFY_ENV_VARS.SDK_LATEST_VERSION,
|
|
32
|
-
APIFY_ENV_VARS.LOCAL_STORAGE_DIR,
|
|
33
|
-
];
|
|
25
|
+
import { BINARY_CONTENT_TYPE, checkCrawleeVersion, getSystemInfo, isNonEmptyObject, JSON_CONTENT_TYPE, parseInputValue, } from './utils.js';
|
|
34
26
|
/**
|
|
35
27
|
* {@link parseInputValue} with the parser error wrapped as an {@link ActorInputError}, so a malformed
|
|
36
28
|
* JSON input reports where it came from.
|
|
@@ -1242,57 +1234,6 @@ export class Actor {
|
|
|
1242
1234
|
});
|
|
1243
1235
|
return this.#actorPromise;
|
|
1244
1236
|
}
|
|
1245
|
-
/**
|
|
1246
|
-
* Modifies Actor env vars so parsing respects the structure of {@link ApifyEnv} interface.
|
|
1247
|
-
*/
|
|
1248
|
-
getModifiedActorEnvVars() {
|
|
1249
|
-
const modifiedActorEnvVars = {};
|
|
1250
|
-
Object.entries(ACTOR_ENV_VARS).forEach(([k, v]) => {
|
|
1251
|
-
// Prepend `ACTOR_` to env vars so ApifyEnv structure is preserved
|
|
1252
|
-
if (['ID', 'RUN_ID', 'TASK_ID'].includes(k)) {
|
|
1253
|
-
modifiedActorEnvVars[`ACTOR_${k}`] = v;
|
|
1254
|
-
}
|
|
1255
|
-
else {
|
|
1256
|
-
modifiedActorEnvVars[k] = v;
|
|
1257
|
-
}
|
|
1258
|
-
});
|
|
1259
|
-
return modifiedActorEnvVars;
|
|
1260
|
-
}
|
|
1261
|
-
/**
|
|
1262
|
-
* Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
|
|
1263
|
-
*
|
|
1264
|
-
* For the list of the Apify environment variables, see
|
|
1265
|
-
* [Actor documentation](https://docs.apify.com/platform/actors/development/programming-interface/environment-variables).
|
|
1266
|
-
* If some variables are not defined or are invalid, the corresponding value in the resulting object will be null.
|
|
1267
|
-
* @ignore
|
|
1268
|
-
*/
|
|
1269
|
-
getEnv() {
|
|
1270
|
-
// NOTE: Don't throw if env vars are invalid to simplify local development and debugging of Actors
|
|
1271
|
-
const env = process.env || {};
|
|
1272
|
-
const envVars = {};
|
|
1273
|
-
for (const [shortName, fullName] of Object.entries({
|
|
1274
|
-
...APIFY_ENV_VARS,
|
|
1275
|
-
...this.getModifiedActorEnvVars(),
|
|
1276
|
-
})) {
|
|
1277
|
-
if (IGNORED_ENV_VARS.includes(fullName))
|
|
1278
|
-
continue;
|
|
1279
|
-
const camelCaseName = snakeCaseToCamelCase(shortName);
|
|
1280
|
-
let value = env[fullName];
|
|
1281
|
-
// Parse booleans, dates and integers.
|
|
1282
|
-
if (BOOLEAN_ENV_VARS.includes(fullName)) {
|
|
1283
|
-
value = !!value && coerceBoolean.parse(value);
|
|
1284
|
-
}
|
|
1285
|
-
else if (value && fullName.endsWith('_AT')) {
|
|
1286
|
-
const unix = Date.parse(value);
|
|
1287
|
-
value = unix > 0 ? new Date(unix) : undefined;
|
|
1288
|
-
}
|
|
1289
|
-
else if (INTEGER_ENV_VARS.includes(fullName)) {
|
|
1290
|
-
value = parseInt(value, 10);
|
|
1291
|
-
}
|
|
1292
|
-
Reflect.set(envVars, camelCaseName, value || value === 0 || value === false ? value : null);
|
|
1293
|
-
}
|
|
1294
|
-
return envVars;
|
|
1295
|
-
}
|
|
1296
1237
|
/**
|
|
1297
1238
|
* Returns a new instance of the Apify API client. The `ApifyClient` class is provided
|
|
1298
1239
|
* by the [apify-client](https://www.npmjs.com/package/apify-client)
|
|
@@ -1906,16 +1847,6 @@ export class Actor {
|
|
|
1906
1847
|
static getChargingManager() {
|
|
1907
1848
|
return Actor.getDefaultInstance().getChargingManager();
|
|
1908
1849
|
}
|
|
1909
|
-
/**
|
|
1910
|
-
* Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
|
|
1911
|
-
*
|
|
1912
|
-
* For the list of the Apify environment variables, see
|
|
1913
|
-
* [Actor documentation](https://docs.apify.com/platform/actors/development/programming-interface/environment-variables).
|
|
1914
|
-
* If some of the variables are not defined or are invalid, the corresponding value in the resulting object will be null.
|
|
1915
|
-
*/
|
|
1916
|
-
static getEnv() {
|
|
1917
|
-
return Actor.getDefaultInstance().getEnv();
|
|
1918
|
-
}
|
|
1919
1850
|
/**
|
|
1920
1851
|
* Returns a new instance of the Apify API client. The `ApifyClient` class is provided
|
|
1921
1852
|
* by the [apify-client](https://www.npmjs.com/package/apify-client)
|
|
@@ -2043,10 +1974,10 @@ export class Actor {
|
|
|
2043
1974
|
* Returns `undefined` if not on the Apify platform or the current run was started without a timeout.
|
|
2044
1975
|
*/
|
|
2045
1976
|
getRemainingTimeSecs() {
|
|
2046
|
-
const
|
|
1977
|
+
const { timeoutAt } = this.configuration;
|
|
2047
1978
|
const MINIMUM_API_TIMEOUT_SECS = 1;
|
|
2048
|
-
if (this.isAtHome() &&
|
|
2049
|
-
return Math.max(Math.ceil((
|
|
1979
|
+
if (this.isAtHome() && timeoutAt !== undefined) {
|
|
1980
|
+
return Math.max(Math.ceil((timeoutAt.getTime() - Date.now()) / 1000), MINIMUM_API_TIMEOUT_SECS);
|
|
2050
1981
|
}
|
|
2051
1982
|
log.warning('Using `inherit` argument is only possible when the Actor is running on the Apify platform and when the ' +
|
|
2052
1983
|
'timeout for the Actor run is set.');
|
package/dist/configuration.d.ts
CHANGED
|
@@ -28,6 +28,15 @@ export declare const apifyConfigFields: {
|
|
|
28
28
|
actorId: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
29
29
|
actorRunId: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
30
30
|
actorTaskId: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
31
|
+
actorBuildId: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
32
|
+
actorBuildNumber: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
33
|
+
actorBuildTags: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodString>, unknown>>>;
|
|
34
|
+
actorFullName: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
35
|
+
workflowKey: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
36
|
+
startedAt: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodDate, unknown>>>;
|
|
37
|
+
timeoutAt: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodDate, unknown>>>;
|
|
38
|
+
maxPaidDatasetItems: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
39
|
+
dedicatedCpus: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
31
40
|
apiBaseUrl: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
32
41
|
apiPublicBaseUrl: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
33
42
|
containerPort: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
@@ -110,6 +119,15 @@ export interface Configuration extends ApifyResolvedConfigValues {
|
|
|
110
119
|
* `actorId` | `ACTOR_ID` | -
|
|
111
120
|
* `actorRunId` | `ACTOR_RUN_ID` | -
|
|
112
121
|
* `actorTaskId` | `ACTOR_TASK_ID` | -
|
|
122
|
+
* `actorBuildId` | `ACTOR_BUILD_ID` | -
|
|
123
|
+
* `actorBuildNumber` | `ACTOR_BUILD_NUMBER` | -
|
|
124
|
+
* `actorBuildTags` | `ACTOR_BUILD_TAGS` | -
|
|
125
|
+
* `actorFullName` | `ACTOR_FULL_NAME` | -
|
|
126
|
+
* `workflowKey` | `APIFY_WORKFLOW_KEY` | -
|
|
127
|
+
* `startedAt` | `ACTOR_STARTED_AT` | -
|
|
128
|
+
* `timeoutAt` | `ACTOR_TIMEOUT_AT` | -
|
|
129
|
+
* `maxPaidDatasetItems` | `ACTOR_MAX_PAID_DATASET_ITEMS` | -
|
|
130
|
+
* `dedicatedCpus` | `APIFY_DEDICATED_CPUS` | -
|
|
113
131
|
* `apiBaseUrl` | `APIFY_API_BASE_URL` | `'https://api.apify.com/'`
|
|
114
132
|
* `containerPort` | `ACTOR_WEB_SERVER_PORT` | `4321`
|
|
115
133
|
* `containerUrl` | `ACTOR_WEB_SERVER_URL` | `'http://localhost:4321'`
|
package/dist/configuration.js
CHANGED
|
@@ -8,6 +8,22 @@ import { ACTOR_ENV_VARS, APIFY_ENV_VARS, LOCAL_ACTOR_ENV_VARS, LOCAL_APIFY_ENV_V
|
|
|
8
8
|
// Reads the env var, not the resolved `isAtHome` field, so an explicit
|
|
9
9
|
// `new Configuration({ isAtHome: true })` won't flip these — env is the source.
|
|
10
10
|
const isAtHome = () => !!process.env[APIFY_ENV_VARS.IS_AT_HOME];
|
|
11
|
+
// Zod preprocessors for the Apify-specific field types; crawlee's
|
|
12
|
+
// `coerceBoolean` / `coerceNumber` cover the rest.
|
|
13
|
+
const coerceDate = z.preprocess((val) => {
|
|
14
|
+
if (typeof val === 'string')
|
|
15
|
+
return new Date(Date.parse(val));
|
|
16
|
+
return val;
|
|
17
|
+
}, z.date());
|
|
18
|
+
const coerceStringList = z.preprocess((val) => {
|
|
19
|
+
if (typeof val === 'string') {
|
|
20
|
+
return val
|
|
21
|
+
.split(',')
|
|
22
|
+
.map((item) => item.trim())
|
|
23
|
+
.filter(Boolean);
|
|
24
|
+
}
|
|
25
|
+
return val;
|
|
26
|
+
}, z.array(z.string()));
|
|
11
27
|
function withApifyEnv(base, apifyEnvVars, schema) {
|
|
12
28
|
const crawleeVars = base.envVar == null ? [] : [base.envVar].flat();
|
|
13
29
|
return field((schema ?? base.schema), [...[apifyEnvVars].flat(), ...crawleeVars]);
|
|
@@ -66,6 +82,18 @@ export const apifyConfigFields = {
|
|
|
66
82
|
actorId: field(z.string().optional(), [ACTOR_ENV_VARS.ID, APIFY_ENV_VARS.ACTOR_ID]),
|
|
67
83
|
actorRunId: field(z.string().optional(), [ACTOR_ENV_VARS.RUN_ID, APIFY_ENV_VARS.ACTOR_RUN_ID]),
|
|
68
84
|
actorTaskId: field(z.string().optional(), [ACTOR_ENV_VARS.TASK_ID, APIFY_ENV_VARS.ACTOR_TASK_ID]),
|
|
85
|
+
actorBuildId: field(z.string().optional(), [ACTOR_ENV_VARS.BUILD_ID, APIFY_ENV_VARS.ACTOR_BUILD_ID]),
|
|
86
|
+
actorBuildNumber: field(z.string().optional(), [ACTOR_ENV_VARS.BUILD_NUMBER, APIFY_ENV_VARS.ACTOR_BUILD_NUMBER]),
|
|
87
|
+
actorBuildTags: field(coerceStringList.optional(), ACTOR_ENV_VARS.BUILD_TAGS),
|
|
88
|
+
actorFullName: field(z.string().optional(), ACTOR_ENV_VARS.FULL_NAME),
|
|
89
|
+
workflowKey: field(z.string().optional(), APIFY_ENV_VARS.WORKFLOW_KEY),
|
|
90
|
+
startedAt: field(coerceDate.optional(), [ACTOR_ENV_VARS.STARTED_AT, APIFY_ENV_VARS.STARTED_AT]),
|
|
91
|
+
timeoutAt: field(coerceDate.optional(), [ACTOR_ENV_VARS.TIMEOUT_AT, APIFY_ENV_VARS.TIMEOUT_AT]),
|
|
92
|
+
maxPaidDatasetItems: field(coerceNumber.optional(), [
|
|
93
|
+
ACTOR_ENV_VARS.MAX_PAID_DATASET_ITEMS,
|
|
94
|
+
APIFY_ENV_VARS.ACTOR_MAX_PAID_DATASET_ITEMS,
|
|
95
|
+
]),
|
|
96
|
+
dedicatedCpus: field(coerceNumber.optional(), APIFY_ENV_VARS.DEDICATED_CPUS),
|
|
69
97
|
apiBaseUrl: field(z.string().default('https://api.apify.com/'), APIFY_ENV_VARS.API_BASE_URL),
|
|
70
98
|
apiPublicBaseUrl: field(z.string().default('https://api.apify.com'), APIFY_ENV_VARS.API_PUBLIC_BASE_URL),
|
|
71
99
|
containerPort: field(coerceNumber.default(+LOCAL_ACTOR_ENV_VARS[ACTOR_ENV_VARS.WEB_SERVER_PORT]), [
|
|
@@ -153,6 +181,15 @@ export const apifyConfigFields = {
|
|
|
153
181
|
* `actorId` | `ACTOR_ID` | -
|
|
154
182
|
* `actorRunId` | `ACTOR_RUN_ID` | -
|
|
155
183
|
* `actorTaskId` | `ACTOR_TASK_ID` | -
|
|
184
|
+
* `actorBuildId` | `ACTOR_BUILD_ID` | -
|
|
185
|
+
* `actorBuildNumber` | `ACTOR_BUILD_NUMBER` | -
|
|
186
|
+
* `actorBuildTags` | `ACTOR_BUILD_TAGS` | -
|
|
187
|
+
* `actorFullName` | `ACTOR_FULL_NAME` | -
|
|
188
|
+
* `workflowKey` | `APIFY_WORKFLOW_KEY` | -
|
|
189
|
+
* `startedAt` | `ACTOR_STARTED_AT` | -
|
|
190
|
+
* `timeoutAt` | `ACTOR_TIMEOUT_AT` | -
|
|
191
|
+
* `maxPaidDatasetItems` | `ACTOR_MAX_PAID_DATASET_ITEMS` | -
|
|
192
|
+
* `dedicatedCpus` | `APIFY_DEDICATED_CPUS` | -
|
|
156
193
|
* `apiBaseUrl` | `APIFY_API_BASE_URL` | `'https://api.apify.com/'`
|
|
157
194
|
* `containerPort` | `ACTOR_WEB_SERVER_PORT` | `4321`
|
|
158
195
|
* `containerUrl` | `ACTOR_WEB_SERVER_URL` | `'http://localhost:4321'`
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export * from './proxy_configuration.js';
|
|
|
12
12
|
export * from './platform_event_manager.js';
|
|
13
13
|
export { Dataset, DatasetDataOptions, DatasetIteratorOptions, DatasetConsumer, DatasetMapper, DatasetReducer, DatasetOptions, DatasetContent, RequestQueue, RequestQueueOperationOptions, RequestQueueOptions, KeyValueStore, KeyConsumer, KeyValueStoreOptions, RecordOptions, KeyValueStoreIteratorOptions, log, Log, LoggerOptions, LogLevel, Logger, LoggerJson, LoggerText, } from '@crawlee/core';
|
|
14
14
|
export type { QueueOperationInfo } from '@crawlee/types';
|
|
15
|
+
export { ACTOR_ENV_VARS, APIFY_ENV_VARS } from '@apify/consts';
|
|
15
16
|
export { ApifyClient, ApifyClientOptions, ApifyClientError, ApifyApiError, InvalidRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, InvalidResponseBodyError, ResponseValidationError, } from 'apify-client';
|
package/dist/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export * from './configuration.js';
|
|
|
9
9
|
export * from './proxy_configuration.js';
|
|
10
10
|
export * from './platform_event_manager.js';
|
|
11
11
|
export { Dataset, RequestQueue, KeyValueStore, log, Log, LogLevel, Logger, LoggerJson, LoggerText, } from '@crawlee/core';
|
|
12
|
+
export { ACTOR_ENV_VARS, APIFY_ENV_VARS } from '@apify/consts';
|
|
12
13
|
export { ApifyClient, ApifyClientError, ApifyApiError, InvalidRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, InvalidResponseBodyError, ResponseValidationError, } from 'apify-client';
|
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.130",
|
|
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"
|