apify 2.3.1-beta.2 → 3.0.0-alpha.0

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 (211) hide show
  1. package/README.md +6 -5
  2. package/package.json +69 -128
  3. package/build/actor.d.ts +0 -113
  4. package/build/actor.d.ts.map +0 -1
  5. package/build/actor.js +0 -582
  6. package/build/actor.js.map +0 -1
  7. package/build/apify.d.ts +0 -752
  8. package/build/apify.d.ts.map +0 -1
  9. package/build/apify.js +0 -877
  10. package/build/apify.js.map +0 -1
  11. package/build/autoscaling/autoscaled_pool.d.ts +0 -384
  12. package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
  13. package/build/autoscaling/autoscaled_pool.js +0 -557
  14. package/build/autoscaling/autoscaled_pool.js.map +0 -1
  15. package/build/autoscaling/snapshotter.d.ts +0 -278
  16. package/build/autoscaling/snapshotter.d.ts.map +0 -1
  17. package/build/autoscaling/snapshotter.js +0 -447
  18. package/build/autoscaling/snapshotter.js.map +0 -1
  19. package/build/autoscaling/system_status.d.ts +0 -224
  20. package/build/autoscaling/system_status.d.ts.map +0 -1
  21. package/build/autoscaling/system_status.js +0 -228
  22. package/build/autoscaling/system_status.js.map +0 -1
  23. package/build/browser_launchers/browser_launcher.d.ts +0 -154
  24. package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
  25. package/build/browser_launchers/browser_launcher.js +0 -160
  26. package/build/browser_launchers/browser_launcher.js.map +0 -1
  27. package/build/browser_launchers/browser_plugin.d.ts +0 -23
  28. package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
  29. package/build/browser_launchers/browser_plugin.js +0 -25
  30. package/build/browser_launchers/browser_plugin.js.map +0 -1
  31. package/build/browser_launchers/playwright_launcher.d.ts +0 -131
  32. package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
  33. package/build/browser_launchers/playwright_launcher.js +0 -150
  34. package/build/browser_launchers/playwright_launcher.js.map +0 -1
  35. package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
  36. package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
  37. package/build/browser_launchers/puppeteer_launcher.js +0 -197
  38. package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
  39. package/build/cache_container.d.ts +0 -31
  40. package/build/cache_container.d.ts.map +0 -1
  41. package/build/cache_container.js +0 -48
  42. package/build/cache_container.js.map +0 -1
  43. package/build/configuration.d.ts +0 -226
  44. package/build/configuration.d.ts.map +0 -1
  45. package/build/configuration.js +0 -325
  46. package/build/configuration.js.map +0 -1
  47. package/build/constants.d.ts +0 -37
  48. package/build/constants.d.ts.map +0 -1
  49. package/build/constants.js +0 -41
  50. package/build/constants.js.map +0 -1
  51. package/build/crawlers/basic_crawler.d.ts +0 -443
  52. package/build/crawlers/basic_crawler.d.ts.map +0 -1
  53. package/build/crawlers/basic_crawler.js +0 -664
  54. package/build/crawlers/basic_crawler.js.map +0 -1
  55. package/build/crawlers/browser_crawler.d.ts +0 -512
  56. package/build/crawlers/browser_crawler.d.ts.map +0 -1
  57. package/build/crawlers/browser_crawler.js +0 -540
  58. package/build/crawlers/browser_crawler.js.map +0 -1
  59. package/build/crawlers/cheerio_crawler.d.ts +0 -931
  60. package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
  61. package/build/crawlers/cheerio_crawler.js +0 -913
  62. package/build/crawlers/cheerio_crawler.js.map +0 -1
  63. package/build/crawlers/crawler_extension.d.ts +0 -10
  64. package/build/crawlers/crawler_extension.d.ts.map +0 -1
  65. package/build/crawlers/crawler_extension.js +0 -19
  66. package/build/crawlers/crawler_extension.js.map +0 -1
  67. package/build/crawlers/crawler_utils.d.ts +0 -34
  68. package/build/crawlers/crawler_utils.d.ts.map +0 -1
  69. package/build/crawlers/crawler_utils.js +0 -87
  70. package/build/crawlers/crawler_utils.js.map +0 -1
  71. package/build/crawlers/playwright_crawler.d.ts +0 -448
  72. package/build/crawlers/playwright_crawler.d.ts.map +0 -1
  73. package/build/crawlers/playwright_crawler.js +0 -299
  74. package/build/crawlers/playwright_crawler.js.map +0 -1
  75. package/build/crawlers/puppeteer_crawler.d.ts +0 -425
  76. package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
  77. package/build/crawlers/puppeteer_crawler.js +0 -299
  78. package/build/crawlers/puppeteer_crawler.js.map +0 -1
  79. package/build/crawlers/statistics.d.ts +0 -185
  80. package/build/crawlers/statistics.d.ts.map +0 -1
  81. package/build/crawlers/statistics.js +0 -331
  82. package/build/crawlers/statistics.js.map +0 -1
  83. package/build/enqueue_links/click_elements.d.ts +0 -179
  84. package/build/enqueue_links/click_elements.d.ts.map +0 -1
  85. package/build/enqueue_links/click_elements.js +0 -434
  86. package/build/enqueue_links/click_elements.js.map +0 -1
  87. package/build/enqueue_links/enqueue_links.d.ts +0 -117
  88. package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
  89. package/build/enqueue_links/enqueue_links.js +0 -163
  90. package/build/enqueue_links/enqueue_links.js.map +0 -1
  91. package/build/enqueue_links/shared.d.ts +0 -42
  92. package/build/enqueue_links/shared.d.ts.map +0 -1
  93. package/build/enqueue_links/shared.js +0 -121
  94. package/build/enqueue_links/shared.js.map +0 -1
  95. package/build/errors.d.ts +0 -29
  96. package/build/errors.d.ts.map +0 -1
  97. package/build/errors.js +0 -38
  98. package/build/errors.js.map +0 -1
  99. package/build/events.d.ts +0 -11
  100. package/build/events.d.ts.map +0 -1
  101. package/build/events.js +0 -147
  102. package/build/events.js.map +0 -1
  103. package/build/index.d.ts +0 -4
  104. package/build/index.d.ts.map +0 -1
  105. package/build/index.js +0 -7
  106. package/build/index.js.map +0 -1
  107. package/build/main.d.ts +0 -179
  108. package/build/main.d.ts.map +0 -1
  109. package/build/main.js +0 -81
  110. package/build/main.js.map +0 -1
  111. package/build/playwright_utils.d.ts +0 -9
  112. package/build/playwright_utils.d.ts.map +0 -1
  113. package/build/playwright_utils.js +0 -90
  114. package/build/playwright_utils.js.map +0 -1
  115. package/build/proxy_configuration.d.ts +0 -411
  116. package/build/proxy_configuration.d.ts.map +0 -1
  117. package/build/proxy_configuration.js +0 -517
  118. package/build/proxy_configuration.js.map +0 -1
  119. package/build/pseudo_url.d.ts +0 -86
  120. package/build/pseudo_url.d.ts.map +0 -1
  121. package/build/pseudo_url.js +0 -153
  122. package/build/pseudo_url.js.map +0 -1
  123. package/build/puppeteer_request_interception.d.ts +0 -8
  124. package/build/puppeteer_request_interception.d.ts.map +0 -1
  125. package/build/puppeteer_request_interception.js +0 -235
  126. package/build/puppeteer_request_interception.js.map +0 -1
  127. package/build/puppeteer_utils.d.ts +0 -250
  128. package/build/puppeteer_utils.d.ts.map +0 -1
  129. package/build/puppeteer_utils.js +0 -551
  130. package/build/puppeteer_utils.js.map +0 -1
  131. package/build/request.d.ts +0 -180
  132. package/build/request.d.ts.map +0 -1
  133. package/build/request.js +0 -261
  134. package/build/request.js.map +0 -1
  135. package/build/request_list.d.ts +0 -581
  136. package/build/request_list.d.ts.map +0 -1
  137. package/build/request_list.js +0 -826
  138. package/build/request_list.js.map +0 -1
  139. package/build/serialization.d.ts +0 -5
  140. package/build/serialization.d.ts.map +0 -1
  141. package/build/serialization.js +0 -139
  142. package/build/serialization.js.map +0 -1
  143. package/build/session_pool/errors.d.ts +0 -11
  144. package/build/session_pool/errors.d.ts.map +0 -1
  145. package/build/session_pool/errors.js +0 -18
  146. package/build/session_pool/errors.js.map +0 -1
  147. package/build/session_pool/events.d.ts +0 -5
  148. package/build/session_pool/events.d.ts.map +0 -1
  149. package/build/session_pool/events.js +0 -6
  150. package/build/session_pool/events.js.map +0 -1
  151. package/build/session_pool/session.d.ts +0 -286
  152. package/build/session_pool/session.d.ts.map +0 -1
  153. package/build/session_pool/session.js +0 -355
  154. package/build/session_pool/session.js.map +0 -1
  155. package/build/session_pool/session_pool.d.ts +0 -280
  156. package/build/session_pool/session_pool.d.ts.map +0 -1
  157. package/build/session_pool/session_pool.js +0 -393
  158. package/build/session_pool/session_pool.js.map +0 -1
  159. package/build/session_pool/session_utils.d.ts +0 -4
  160. package/build/session_pool/session_utils.d.ts.map +0 -1
  161. package/build/session_pool/session_utils.js +0 -24
  162. package/build/session_pool/session_utils.js.map +0 -1
  163. package/build/stealth/hiding_tricks.d.ts +0 -22
  164. package/build/stealth/hiding_tricks.d.ts.map +0 -1
  165. package/build/stealth/hiding_tricks.js +0 -308
  166. package/build/stealth/hiding_tricks.js.map +0 -1
  167. package/build/stealth/stealth.d.ts +0 -56
  168. package/build/stealth/stealth.d.ts.map +0 -1
  169. package/build/stealth/stealth.js +0 -125
  170. package/build/stealth/stealth.js.map +0 -1
  171. package/build/storages/dataset.d.ts +0 -288
  172. package/build/storages/dataset.d.ts.map +0 -1
  173. package/build/storages/dataset.js +0 -480
  174. package/build/storages/dataset.js.map +0 -1
  175. package/build/storages/key_value_store.d.ts +0 -243
  176. package/build/storages/key_value_store.d.ts.map +0 -1
  177. package/build/storages/key_value_store.js +0 -462
  178. package/build/storages/key_value_store.js.map +0 -1
  179. package/build/storages/request_queue.d.ts +0 -318
  180. package/build/storages/request_queue.d.ts.map +0 -1
  181. package/build/storages/request_queue.js +0 -636
  182. package/build/storages/request_queue.js.map +0 -1
  183. package/build/storages/storage_manager.d.ts +0 -87
  184. package/build/storages/storage_manager.d.ts.map +0 -1
  185. package/build/storages/storage_manager.js +0 -150
  186. package/build/storages/storage_manager.js.map +0 -1
  187. package/build/tsconfig.tsbuildinfo +0 -1
  188. package/build/typedefs.d.ts +0 -146
  189. package/build/typedefs.d.ts.map +0 -1
  190. package/build/typedefs.js +0 -88
  191. package/build/typedefs.js.map +0 -1
  192. package/build/utils.d.ts +0 -175
  193. package/build/utils.d.ts.map +0 -1
  194. package/build/utils.js +0 -731
  195. package/build/utils.js.map +0 -1
  196. package/build/utils_log.d.ts +0 -41
  197. package/build/utils_log.d.ts.map +0 -1
  198. package/build/utils_log.js +0 -192
  199. package/build/utils_log.js.map +0 -1
  200. package/build/utils_request.d.ts +0 -77
  201. package/build/utils_request.d.ts.map +0 -1
  202. package/build/utils_request.js +0 -385
  203. package/build/utils_request.js.map +0 -1
  204. package/build/utils_social.d.ts +0 -210
  205. package/build/utils_social.d.ts.map +0 -1
  206. package/build/utils_social.js +0 -787
  207. package/build/utils_social.js.map +0 -1
  208. package/build/validators.d.ts +0 -23
  209. package/build/validators.d.ts.map +0 -1
  210. package/build/validators.js +0 -29
  211. package/build/validators.js.map +0 -1
package/build/actor.js DELETED
@@ -1,582 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addWebhook = exports.metamorph = exports.callTask = exports.call = exports.main = exports.getEnv = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
6
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
7
- const underscore_1 = (0, tslib_1.__importDefault)(require("underscore"));
8
- const consts_1 = require("@apify/consts");
9
- const utils_log_1 = (0, tslib_1.__importDefault)(require("./utils_log"));
10
- const constants_1 = require("./constants");
11
- const events_1 = require("./events");
12
- const utils_1 = require("./utils");
13
- const key_value_store_1 = require("./storages/key_value_store");
14
- const errors_1 = require("./errors");
15
- const METAMORPH_AFTER_SLEEP_MILLIS = 300000;
16
- /**
17
- * Tries to parse a string with date.
18
- * Returns either a Date object or undefined
19
- *
20
- * @ignore
21
- */
22
- const tryParseDate = (str) => {
23
- const unix = Date.parse(str);
24
- return unix > 0 ? new Date(unix) : undefined;
25
- };
26
- /**
27
- * Parsed representation of the `APIFY_XXX` environmental variables.
28
- * This object is returned by the {@link Apify#getEnv} function.
29
- *
30
- * @typedef ApifyEnv
31
- * @property {string|null} actorId ID of the actor (APIFY_ACTOR_ID)
32
- * @property {string|null} actorRunId ID of the actor run (APIFY_ACTOR_RUN_ID)
33
- * @property {string|null} actorTaskId ID of the actor task (APIFY_ACTOR_TASK_ID)
34
- * @property {string|null} userId ID of the user who started the actor - note that it might be
35
- * different than the owner ofthe actor (APIFY_USER_ID)
36
- * @property {string|null} token Authentication token representing privileges given to the actor run,
37
- * it can be passed to various Apify APIs (APIFY_TOKEN)
38
- * @property {Date|null} startedAt Date when the actor was started (APIFY_STARTED_AT)
39
- * @property {Date|null} timeoutAt Date when the actor will time out (APIFY_TIMEOUT_AT)
40
- * @property {string|null} defaultKeyValueStoreId ID of the key-value store where input and output data of this
41
- * actor is stored (APIFY_DEFAULT_KEY_VALUE_STORE_ID)
42
- * @property {string|null} defaultDatasetId ID of the dataset where input and output data of this
43
- * actor is stored (APIFY_DEFAULT_DATASET_ID)
44
- * @property {number|null} memoryMbytes Amount of memory allocated for the actor,
45
- * in megabytes (APIFY_MEMORY_MBYTES)
46
- */
47
- /**
48
- * @typedef {Array<('ACTOR.RUN.SUCCEEDED' | 'ACTOR.RUN.ABORTED' | 'ACTOR.RUN.CREATED' | 'ACTOR.RUN.FAILED' | 'ACTOR.RUN.TIMED_OUT')>} EventTypes
49
- */
50
- /**
51
- * Returns a new {@link ApifyEnv} object which contains information parsed from all the `APIFY_XXX` environment variables.
52
- *
53
- * For the list of the `APIFY_XXX` environment variables, see
54
- * [Actor documentation](https://docs.apify.com/actor/run#environment-variables).
55
- * If some of the variables are not defined or are invalid, the corresponding value in the resulting object will be null.
56
- *
57
- * @memberof module:Apify
58
- * @function
59
- * @name getEnv
60
- * @returns {ApifyEnv}
61
- */
62
- const getEnv = () => {
63
- // NOTE: Don't throw if env vars are invalid to simplify local development and debugging of actors
64
- const env = process.env || {};
65
- const envVars = {};
66
- underscore_1.default.mapObject(consts_1.ENV_VARS, (fullName, shortName) => {
67
- const camelCaseName = (0, utils_1.snakeCaseToCamelCase)(shortName);
68
- let value = env[fullName];
69
- // Parse dates and integers.
70
- if (value && fullName.endsWith('_AT'))
71
- value = tryParseDate(value);
72
- else if (underscore_1.default.contains(consts_1.INTEGER_ENV_VARS, fullName))
73
- value = parseInt(value, 10);
74
- envVars[camelCaseName] = value || value === 0
75
- ? value
76
- : null;
77
- });
78
- return envVars;
79
- };
80
- exports.getEnv = getEnv;
81
- /**
82
- * @callback UserFunc
83
- * @return {Promise<void>}
84
- */
85
- /**
86
- * Runs the main user function that performs the job of the actor
87
- * and terminates the process when the user function finishes.
88
- *
89
- * **The `Apify.main()` function is optional** and is provided merely for your convenience.
90
- * It is mainly useful when you're running your code as an actor on the [Apify platform](https://apify.com/actors).
91
- * However, if you want to use Apify SDK tools directly inside your existing projects, e.g.
92
- * running in an [Express](https://expressjs.com/) server, on
93
- * [Google Cloud functions](https://cloud.google.com/functions)
94
- * or [AWS Lambda](https://aws.amazon.com/lambda/), it's better to avoid
95
- * it since the function terminates the main process when it finishes!
96
- *
97
- * The `Apify.main()` function performs the following actions:
98
- *
99
- * - When running on the Apify platform (i.e. <code>APIFY_IS_AT_HOME</code> environment variable is set),
100
- * it sets up a connection to listen for platform events.
101
- * For example, to get a notification about an imminent migration to another server.
102
- * See {@link Apify.events} for details.
103
- * - It checks that either <code>APIFY_TOKEN</code> or <code>APIFY_LOCAL_STORAGE_DIR</code> environment variable
104
- * is defined. If not, the functions sets <code>APIFY_LOCAL_STORAGE_DIR</code> to <code>./apify_storage</code>
105
- * inside the current working directory. This is to simplify running code examples.
106
- * - It invokes the user function passed as the <code>userFunc</code> parameter.
107
- * - If the user function returned a promise, waits for it to resolve.
108
- * - If the user function throws an exception or some other error is encountered,
109
- * prints error details to console so that they are stored to the log.
110
- * - Exits the Node.js process, with zero exit code on success and non-zero on errors.
111
- *
112
- * The user function can be synchronous:
113
- *
114
- * ```javascript
115
- * Apify.main(() => {
116
- * // My synchronous function that returns immediately
117
- * console.log('Hello world from actor!');
118
- * });
119
- * ```
120
- *
121
- * If the user function returns a promise, it is considered asynchronous:
122
- * ```javascript
123
- * const { requestAsBrowser } = require('some-request-library');
124
- *
125
- * Apify.main(() => {
126
- * // My asynchronous function that returns a promise
127
- * return request('http://www.example.com').then((html) => {
128
- * console.log(html);
129
- * });
130
- * });
131
- * ```
132
- *
133
- * To simplify your code, you can take advantage of the `async`/`await` keywords:
134
- *
135
- * ```javascript
136
- * const request = require('some-request-library');
137
- *
138
- * Apify.main(async () => {
139
- * // My asynchronous function
140
- * const html = await request('http://www.example.com');
141
- * console.log(html);
142
- * });
143
- * ```
144
- *
145
- * @param {UserFunc} userFunc User function to be executed. If it returns a promise,
146
- * the promise will be awaited. The user function is called with no arguments.
147
- *
148
- * @memberof module:Apify
149
- * @function
150
- * @name main
151
- */
152
- const main = (userFunc) => {
153
- if (!userFunc || typeof (userFunc) !== 'function') {
154
- throw new Error(`Apify.main() accepts a single parameter that must be a function (was '${userFunc === null ? 'null' : typeof (userFunc)}').`);
155
- }
156
- // Logging some basic system info (apify and apify-client version, NodeJS version, ...).
157
- (0, utils_1.logSystemInfo)();
158
- // Log warning if SDK is outdated.
159
- (0, utils_1.printOutdatedSdkWarning)();
160
- if (!process.env[consts_1.ENV_VARS.LOCAL_STORAGE_DIR] && !process.env[consts_1.ENV_VARS.TOKEN]) {
161
- const dir = path_1.default.join(process.cwd(), './apify_storage');
162
- process.env[consts_1.ENV_VARS.LOCAL_STORAGE_DIR] = dir;
163
- utils_log_1.default.warning(`Neither ${consts_1.ENV_VARS.LOCAL_STORAGE_DIR} nor ${consts_1.ENV_VARS.TOKEN} environment variable is set, defaulting to ${consts_1.ENV_VARS.LOCAL_STORAGE_DIR}="${dir}"`); // eslint-disable-line max-len
164
- }
165
- // This is to enable unit tests where process.exit() is mocked and doesn't really exit the process
166
- // Note that mocked process.exit() might throw, so set exited flag before calling it to avoid confusion.
167
- let exited = false;
168
- const exitWithError = (err, exitCode) => {
169
- utils_log_1.default.exception(err);
170
- exited = true;
171
- // console.log(`Exiting with code: ${exitCode}`);
172
- process.exit(exitCode);
173
- };
174
- // Set dummy interval to ensure the process will not be killed while awaiting empty promise:
175
- // await new Promise(() => {})
176
- // Such a construct is used for testing of actor timeouts and aborts.
177
- const intervalId = setInterval(underscore_1.default.noop, 9999999);
178
- // Using async here to have nice stack traces for errors
179
- const run = async () => {
180
- (0, events_1.initializeEvents)();
181
- try {
182
- await userFunc();
183
- (0, events_1.stopEvents)();
184
- clearInterval(intervalId);
185
- if (!exited) {
186
- process.exit(constants_1.EXIT_CODES.SUCCESS);
187
- }
188
- }
189
- catch (err) {
190
- (0, events_1.stopEvents)();
191
- clearInterval(intervalId);
192
- if (!exited) {
193
- exitWithError(err, constants_1.EXIT_CODES.ERROR_USER_FUNCTION_THREW);
194
- }
195
- }
196
- };
197
- run().catch((err) => {
198
- exitWithError(err, constants_1.EXIT_CODES.ERROR_UNKNOWN);
199
- });
200
- };
201
- exports.main = main;
202
- /**
203
- * @typedef AdhocWebhook
204
- * @property {EventTypes} eventTypes
205
- * @property {string} requestUrl
206
- * @property {string} [idempotencyKey]
207
- * @property {string} [payloadTemplate]
208
- */
209
- /**
210
- * Runs an actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
211
- * waits for the actor to finish and fetches its output.
212
- *
213
- * By passing the `waitSecs` option you can reduce the maximum amount of time to wait for the run to finish.
214
- * If the value is less than or equal to zero, the function returns immediately after the run is started.
215
- *
216
- * The result of the function is an {@link ActorRun} object
217
- * that contains details about the actor run and its output (if any).
218
- * If the actor run fails, the function throws the {@link ApifyCallError} exception.
219
- *
220
- * If you want to run an actor task rather than an actor, please use the
221
- * {@link Apify#callTask} function instead.
222
- *
223
- * For more information about actors, read the
224
- * [documentation](https://docs.apify.com/actor).
225
- *
226
- * **Example usage:**
227
- *
228
- * ```javascript
229
- * const run = await Apify.call('apify/hello-world', { myInput: 123 });
230
- * console.log(`Received message: ${run.output.body.message}`);
231
- * ```
232
- *
233
- * Internally, the `call()` function invokes the
234
- * [Run actor](https://apify.com/docs/api/v2#/reference/actors/run-collection/run-actor)
235
- * and several other API endpoints to obtain the output.
236
- *
237
- * @param {string} actId
238
- * Allowed formats are `username/actor-name`, `userId/actor-name` or actor ID.
239
- * @param {Object<string, *>} [input]
240
- * Input for the actor. If it is an object, it will be stringified to
241
- * JSON and its content type set to `application/json; charset=utf-8`.
242
- * Otherwise the `options.contentType` parameter must be provided.
243
- * @param {object} [options]
244
- * Object with the settings below:
245
- * @param {string} [options.contentType]
246
- * Content type for the `input`. If not specified,
247
- * `input` is expected to be an object that will be stringified to JSON and content type set to
248
- * `application/json; charset=utf-8`. If `options.contentType` is specified, then `input` must be a
249
- * `String` or `Buffer`.
250
- * @param {string} [options.token]
251
- * User API token that is used to run the actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
252
- * @param {number} [options.memoryMbytes]
253
- * Memory in megabytes which will be allocated for the new actor run.
254
- * If not provided, the run uses memory of the default actor run configuration.
255
- * @param {number} [options.timeoutSecs]
256
- * Timeout for the actor run in seconds. Zero value means there is no timeout.
257
- * If not provided, the run uses timeout of the default actor run configuration.
258
- * @param {string} [options.build]
259
- * Tag or number of the actor build to run (e.g. `beta` or `1.2.345`).
260
- * If not provided, the run uses build tag or number from the default actor run configuration (typically `latest`).
261
- * @param {number} [options.waitSecs]
262
- * Maximum time to wait for the actor run to finish, in seconds.
263
- * If the limit is reached, the returned promise is resolved to a run object that will have
264
- * status `READY` or `RUNNING` and it will not contain the actor run output.
265
- * If `waitSecs` is null or undefined, the function waits for the actor to finish (default behavior).
266
- * @param {boolean} [options.fetchOutput=true]
267
- * If `false` then the function does not fetch output of the actor.
268
- * @param {boolean} [options.disableBodyParser=false]
269
- * If `true` then the function will not attempt to parse the
270
- * actor's output and will return it in a raw `Buffer`.
271
- * @param {Array<AdhocWebhook>} [options.webhooks] Specifies optional webhooks associated with the actor run, which can be used
272
- * to receive a notification e.g. when the actor finished or failed, see
273
- * [ad hook webhooks documentation](https://docs.apify.com/webhooks/ad-hoc-webhooks) for detailed description.
274
- * @returns {Promise<ActorRun>}
275
- * @throws {ApifyCallError} If the run did not succeed, e.g. if it failed or timed out.
276
- *
277
- * @memberof module:Apify
278
- * @function
279
- * @name call
280
- */
281
- const call = async (actId, input, options = {}) => {
282
- (0, ow_1.default)(actId, ow_1.default.string);
283
- // input can be anything, no reason to validate
284
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
285
- contentType: ow_1.default.optional.string.nonEmpty,
286
- token: ow_1.default.optional.string,
287
- memoryMbytes: ow_1.default.optional.number.not.negative,
288
- timeoutSecs: ow_1.default.optional.number.not.negative,
289
- build: ow_1.default.optional.string,
290
- waitSecs: ow_1.default.optional.number.not.negative,
291
- fetchOutput: ow_1.default.optional.boolean,
292
- disableBodyParser: ow_1.default.optional.boolean,
293
- webhooks: ow_1.default.optional.array.ofType(ow_1.default.object),
294
- }));
295
- const { token, fetchOutput = true, disableBodyParser = false, memoryMbytes, timeoutSecs, ...callActorOpts } = options;
296
- callActorOpts.memory = memoryMbytes;
297
- callActorOpts.timeout = timeoutSecs;
298
- if (input) {
299
- callActorOpts.contentType = (0, utils_1.addCharsetToContentType)(callActorOpts.contentType);
300
- input = (0, key_value_store_1.maybeStringify)(input, callActorOpts);
301
- }
302
- const client = token ? (0, utils_1.newClient)({ token }) : utils_1.apifyClient;
303
- let run;
304
- try {
305
- run = await client.actor(actId).call(input, callActorOpts);
306
- }
307
- catch (err) {
308
- if (err.message.startsWith('Waiting for run to finish')) {
309
- throw new errors_1.ApifyCallError({ id: run.id, actId: run.actId }, 'Apify.call() failed, cannot fetch actor run details from the server');
310
- }
311
- throw err;
312
- }
313
- if (isRunUnsuccessful(run.status)) {
314
- const message = `The actor ${actId} invoked by Apify.call() did not succeed. For details, see https://console.apify.com/view/runs/${run.id}`;
315
- throw new errors_1.ApifyCallError(run, message);
316
- }
317
- // Finish if output is not requested or run haven't finished.
318
- if (!fetchOutput || run.status !== consts_1.ACT_JOB_STATUSES.SUCCEEDED)
319
- return run;
320
- // Fetch output.
321
- let getRecordOptions = {};
322
- if (disableBodyParser)
323
- getRecordOptions = { buffer: true };
324
- const actorOutput = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT', getRecordOptions);
325
- const result = { ...run };
326
- if (actorOutput) {
327
- result.output = {
328
- body: actorOutput.value,
329
- contentType: actorOutput.contentType,
330
- };
331
- }
332
- return result;
333
- };
334
- exports.call = call;
335
- /**
336
- * Runs an actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
337
- * waits for the task to finish and fetches its output.
338
- *
339
- * By passing the `waitSecs` option you can reduce the maximum amount of time to wait for the run to finish.
340
- * If the value is less than or equal to zero, the function returns immediately after the run is started.
341
- *
342
- * The result of the function is an {@link ActorRun} object
343
- * that contains details about the actor run and its output (if any).
344
- * If the actor run failed, the function fails with {@link ApifyCallError} exception.
345
- *
346
- * Note that an actor task is a saved input configuration and options for an actor.
347
- * If you want to run an actor directly rather than an actor task, please use the
348
- * {@link Apify#call} function instead.
349
- *
350
- * For more information about actor tasks, read the [documentation](https://docs.apify.com/tasks).
351
- *
352
- * **Example usage:**
353
- *
354
- * ```javascript
355
- * const run = await Apify.callTask('bob/some-task');
356
- * console.log(`Received message: ${run.output.body.message}`);
357
- * ```
358
- *
359
- * Internally, the `callTask()` function calls the
360
- * [Run task](https://apify.com/docs/api/v2#/reference/actor-tasks/run-collection/run-task)
361
- * and several other API endpoints to obtain the output.
362
- *
363
- * @param {string} taskId
364
- * Allowed formats are `username/task-name`, `userId/task-name` or task ID.
365
- * @param {Object<string, *>} [input]
366
- * Input overrides for the actor task. If it is an object, it will be stringified to
367
- * JSON and its content type set to `application/json; charset=utf-8`.
368
- * Provided input will be merged with actor task input.
369
- * @param {object} [options]
370
- * Object with the settings below:
371
- * @param {string} [options.token]
372
- * User API token that is used to run the actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
373
- * @param {number} [options.memoryMbytes]
374
- * Memory in megabytes which will be allocated for the new actor task run.
375
- * If not provided, the run uses memory of the default actor run configuration.
376
- * @param {number} [options.timeoutSecs]
377
- * Timeout for the actor task run in seconds. Zero value means there is no timeout.
378
- * If not provided, the run uses timeout of the default actor run configuration.
379
- * @param {string} [options.build]
380
- * Tag or number of the actor build to run (e.g. `beta` or `1.2.345`).
381
- * If not provided, the run uses build tag or number from the default actor run configuration (typically `latest`).
382
- * @param {number} [options.waitSecs]
383
- * Maximum time to wait for the actor task run to finish, in seconds.
384
- * If the limit is reached, the returned promise is resolved to a run object that will have
385
- * status `READY` or `RUNNING` and it will not contain the actor run output.
386
- * If `waitSecs` is null or undefined, the function waits for the actor task to finish (default behavior).
387
- * @param {Array<AdhocWebhook>} [options.webhooks] Specifies optional webhooks associated with the actor run, which can be used
388
- * to receive a notification e.g. when the actor finished or failed, see
389
- * [ad hook webhooks documentation](https://docs.apify.com/webhooks/ad-hoc-webhooks) for detailed description.
390
- * @returns {Promise<ActorRun>}
391
- * @throws {ApifyCallError} If the run did not succeed, e.g. if it failed or timed out.
392
- *
393
- * @memberof module:Apify
394
- * @function
395
- * @name callTask
396
- */
397
- const callTask = async (taskId, input, options = {}) => {
398
- (0, ow_1.default)(taskId, ow_1.default.string);
399
- (0, ow_1.default)(input, ow_1.default.optional.any(ow_1.default.string, ow_1.default.object));
400
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
401
- token: ow_1.default.optional.string,
402
- memoryMbytes: ow_1.default.optional.number.not.negative,
403
- timeoutSecs: ow_1.default.optional.number.not.negative,
404
- build: ow_1.default.optional.string,
405
- waitSecs: ow_1.default.optional.number.not.negative,
406
- fetchOutput: ow_1.default.optional.boolean,
407
- disableBodyParser: ow_1.default.optional.boolean,
408
- webhooks: ow_1.default.optional.array.ofType(ow_1.default.object),
409
- }));
410
- const { token, fetchOutput = true, disableBodyParser = false, memoryMbytes, timeoutSecs, ...callTaskOpts } = options;
411
- callTaskOpts.memory = memoryMbytes;
412
- callTaskOpts.timeout = timeoutSecs;
413
- const client = token ? (0, utils_1.newClient)({ token }) : utils_1.apifyClient;
414
- // Start task and wait for run to finish if waitSecs is provided
415
- let run;
416
- try {
417
- run = await client.task(taskId).call(input, callTaskOpts);
418
- }
419
- catch (err) {
420
- if (err.message.startsWith('Waiting for run to finish')) {
421
- throw new errors_1.ApifyCallError({ id: run.id, actId: run.actId }, 'Apify.call() failed, cannot fetch actor run details from the server');
422
- }
423
- throw err;
424
- }
425
- if (isRunUnsuccessful(run.status)) {
426
- // TODO It should be callTask in the message, but I'm keeping it this way not to introduce a breaking change.
427
- // eslint-disable-next-line max-len
428
- const message = `The actor task ${taskId} invoked by Apify.call() did not succeed. For details, see https://console.apify.com/view/runs/${run.id}`;
429
- throw new errors_1.ApifyCallError(run, message);
430
- }
431
- // Finish if output is not requested or run haven't finished.
432
- if (!fetchOutput || run.status !== consts_1.ACT_JOB_STATUSES.SUCCEEDED)
433
- return run;
434
- // Fetch output.
435
- let getRecordOptions = {};
436
- if (disableBodyParser)
437
- getRecordOptions = { buffer: true };
438
- const actorOutput = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT', getRecordOptions);
439
- const result = { ...run };
440
- if (actorOutput) {
441
- result.output = {
442
- body: actorOutput.value,
443
- contentType: actorOutput.contentType,
444
- };
445
- }
446
- return result;
447
- };
448
- exports.callTask = callTask;
449
- function isRunUnsuccessful(status) {
450
- return status !== consts_1.ACT_JOB_STATUSES.SUCCEEDED
451
- && status !== consts_1.ACT_JOB_STATUSES.RUNNING
452
- && status !== consts_1.ACT_JOB_STATUSES.READY;
453
- }
454
- /**
455
- * Transforms this actor run to an actor run of a given actor. The system stops the current container and starts the new container
456
- * instead. All the default storages are preserved and the new input is stored under the `INPUT-METAMORPH-1` key in the same default key-value store.
457
- *
458
- * @param {string} targetActorId
459
- * Either `username/actor-name` or actor ID of an actor to which we want to metamorph.
460
- * @param {Object<string, *>} [input]
461
- * Input for the actor. If it is an object, it will be stringified to
462
- * JSON and its content type set to `application/json; charset=utf-8`.
463
- * Otherwise the `options.contentType` parameter must be provided.
464
- * @param {object} [options]
465
- * Object with the settings below:
466
- * @param {string} [options.contentType]
467
- * Content type for the `input`. If not specified,
468
- * `input` is expected to be an object that will be stringified to JSON and content type set to
469
- * `application/json; charset=utf-8`. If `options.contentType` is specified, then `input` must be a
470
- * `String` or `Buffer`.
471
- * @param {string} [options.build]
472
- * Tag or number of the target actor build to metamorph into (e.g. `beta` or `1.2.345`).
473
- * If not provided, the run uses build tag or number from the default actor run configuration (typically `latest`).
474
- * @returns {Promise<void>}
475
- *
476
- * @memberof module:Apify
477
- * @function
478
- * @name metamorph
479
- */
480
- const metamorph = async (targetActorId, input, options = {}) => {
481
- (0, ow_1.default)(targetActorId, ow_1.default.string);
482
- // input can be anything, no reason to validate
483
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
484
- contentType: ow_1.default.optional.string.nonEmpty,
485
- build: ow_1.default.optional.string,
486
- customAfterSleepMillis: ow_1.default.optional.number.not.negative,
487
- }));
488
- const { customAfterSleepMillis, ...metamorphOpts } = options;
489
- const actorId = process.env[consts_1.ENV_VARS.ACTOR_ID];
490
- const runId = process.env[consts_1.ENV_VARS.ACTOR_RUN_ID];
491
- if (!actorId)
492
- throw new Error(`Environment variable ${consts_1.ENV_VARS.ACTOR_ID} must be provided!`);
493
- if (!runId)
494
- throw new Error(`Environment variable ${consts_1.ENV_VARS.ACTOR_RUN_ID} must be provided!`);
495
- if (input) {
496
- metamorphOpts.contentType = (0, utils_1.addCharsetToContentType)(metamorphOpts.contentType);
497
- input = (0, key_value_store_1.maybeStringify)(input, metamorphOpts);
498
- }
499
- await utils_1.apifyClient.run(runId, actorId).metamorph(targetActorId, input, metamorphOpts);
500
- // Wait some time for container to be stopped.
501
- // NOTE: option.customAfterSleepMillis is used in tests
502
- await (0, utils_1.sleep)(customAfterSleepMillis || METAMORPH_AFTER_SLEEP_MILLIS);
503
- };
504
- exports.metamorph = metamorph;
505
- /**
506
- * @typedef WebhookRun
507
- * @property {string} id
508
- * @property {string} createdAt
509
- * @property {string} modifiedAt
510
- * @property {string} userId
511
- * @property {boolean} isAdHoc
512
- * @property {EventTypes} eventTypes
513
- * @property {*} condition
514
- * @property {boolean} ignoreSslErrors
515
- * @property {boolean} doNotRetry
516
- * @property {string} requestUrl
517
- * @property {string} payloadTemplate
518
- * @property {*} lastDispatch
519
- * @property {*} stats
520
- */
521
- /**
522
- *
523
- * Creates an ad-hoc webhook for the current actor run, which lets you receive a notification when the actor run finished or failed.
524
- * For more information about Apify actor webhooks, please see the [documentation](https://docs.apify.com/webhooks).
525
- *
526
- * Note that webhooks are only supported for actors running on the Apify platform.
527
- * In local environment, the function will print a warning and have no effect.
528
- *
529
- * @param {object} options
530
- * @param {EventTypes} options.eventTypes
531
- * Array of event types, which you can set for actor run, see
532
- * the [actor run events](https://docs.apify.com/webhooks/events#actor-run) in the Apify doc.
533
- * @param {string} options.requestUrl
534
- * URL which will be requested using HTTP POST request, when actor run will reach the set event type.
535
- * @param {string} [options.payloadTemplate]
536
- * Payload template is a JSON-like string that describes the structure of the webhook POST request payload.
537
- * It uses JSON syntax, extended with a double curly braces syntax for injecting variables `{{variable}}`.
538
- * Those variables are resolved at the time of the webhook's dispatch, and a list of available variables with their descriptions
539
- * is available in the [Apify webhook documentation](https://docs.apify.com/webhooks).
540
- * If `payloadTemplate` is omitted, the default payload template is used
541
- * ([view docs](https://docs.apify.com/webhooks/actions#payload-template)).
542
- * @param {string} [options.idempotencyKey]
543
- * Idempotency key enables you to ensure that a webhook will not be added multiple times in case of
544
- * an actor restart or other situation that would cause the `addWebhook()` function to be called again.
545
- * We suggest using the actor run ID as the idempotency key. You can get the run ID by calling
546
- * {@link Apify#getEnv} function.
547
- * @return {Promise<WebhookRun|undefined>} The return value is the Webhook object.
548
- * For more information, see the [Get webhook](https://apify.com/docs/api/v2#/reference/webhooks/webhook-object/get-webhook) API endpoint.
549
- *
550
- * @memberof module:Apify
551
- * @function
552
- * @name addWebhook
553
- */
554
- const addWebhook = async (options) => {
555
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
556
- eventTypes: ow_1.default.array.ofType(ow_1.default.string),
557
- requestUrl: ow_1.default.string,
558
- payloadTemplate: ow_1.default.optional.string,
559
- idempotencyKey: ow_1.default.optional.string,
560
- }));
561
- const { eventTypes, requestUrl, payloadTemplate, idempotencyKey } = options;
562
- if (!(0, utils_1.isAtHome)()) {
563
- utils_log_1.default.warning('Apify.addWebhook() is only supported when running on the Apify platform. The webhook will not be invoked.');
564
- return;
565
- }
566
- const runId = process.env[consts_1.ENV_VARS.ACTOR_RUN_ID];
567
- if (!runId) {
568
- throw new Error(`Environment variable ${consts_1.ENV_VARS.ACTOR_RUN_ID} is not set!`);
569
- }
570
- return utils_1.apifyClient.webhooks().create({
571
- isAdHoc: true,
572
- eventTypes,
573
- condition: {
574
- actorRunId: runId,
575
- },
576
- requestUrl,
577
- payloadTemplate,
578
- idempotencyKey,
579
- });
580
- };
581
- exports.addWebhook = addWebhook;
582
- //# sourceMappingURL=actor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actor.js","sourceRoot":"","sources":["../src/actor.js"],"names":[],"mappings":";;;;AAAA,yDAAoB;AACpB,6DAAwB;AACxB,yEAA2B;AAC3B,0CAA6E;AAC7E,yEAA8B;AAC9B,2CAAyC;AACzC,qCAAwD;AACxD,mCASiB;AACjB,gEAA4D;AAI5D,qCAA0C;AAE1C,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE;IACzB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjD,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;GAEG;AAEH;;;;;;;;;;;GAWG;AACI,MAAM,MAAM,GAAG,GAAG,EAAE;IACvB,kGAAkG;IAClG,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,oBAAC,CAAC,SAAS,CAAC,iBAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE;QAC1C,MAAM,aAAa,GAAG,IAAA,4BAAoB,E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