apify-client 2.25.1-beta.8 → 3.0.0-beta.1

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 (60) hide show
  1. package/dist/apify_client.js +34 -30
  2. package/dist/argument_validation_error.d.ts +17 -0
  3. package/dist/argument_validation_error.js +157 -0
  4. package/dist/base/api_client.d.ts +2 -2
  5. package/dist/base/api_client.js +13 -10
  6. package/dist/bundle.js +66 -28147
  7. package/dist/bundle.js.LICENSE.txt +33 -0
  8. package/dist/bundle.js.map +1 -1
  9. package/dist/generated/api.d.ts +20522 -0
  10. package/dist/generated/api.js +6 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +1 -0
  13. package/dist/index.mjs +1 -0
  14. package/dist/models.d.ts +1072 -0
  15. package/dist/models.js +89 -0
  16. package/dist/resource_clients/actor.d.ts +2 -448
  17. package/dist/resource_clients/actor.js +60 -55
  18. package/dist/resource_clients/actor_collection.d.ts +2 -7
  19. package/dist/resource_clients/actor_collection.js +13 -11
  20. package/dist/resource_clients/actor_env_var.js +2 -3
  21. package/dist/resource_clients/actor_env_var_collection.js +3 -3
  22. package/dist/resource_clients/actor_version.d.ts +3 -40
  23. package/dist/resource_clients/actor_version.js +8 -12
  24. package/dist/resource_clients/actor_version_collection.js +3 -3
  25. package/dist/resource_clients/build.d.ts +2 -77
  26. package/dist/resource_clients/build.js +7 -10
  27. package/dist/resource_clients/build_collection.d.ts +2 -2
  28. package/dist/resource_clients/build_collection.js +8 -8
  29. package/dist/resource_clients/dataset.d.ts +8 -72
  30. package/dist/resource_clients/dataset.js +66 -57
  31. package/dist/resource_clients/dataset_collection.js +14 -12
  32. package/dist/resource_clients/key_value_store.d.ts +5 -73
  33. package/dist/resource_clients/key_value_store.js +69 -51
  34. package/dist/resource_clients/key_value_store_collection.js +14 -12
  35. package/dist/resource_clients/request_queue.d.ts +15 -174
  36. package/dist/resource_clients/request_queue.js +85 -91
  37. package/dist/resource_clients/request_queue_collection.js +12 -11
  38. package/dist/resource_clients/run.js +39 -40
  39. package/dist/resource_clients/run_collection.js +12 -11
  40. package/dist/resource_clients/schedule.d.ts +3 -81
  41. package/dist/resource_clients/schedule.js +4 -12
  42. package/dist/resource_clients/schedule_collection.js +10 -9
  43. package/dist/resource_clients/store_collection.d.ts +2 -30
  44. package/dist/resource_clients/store_collection.js +13 -13
  45. package/dist/resource_clients/task.d.ts +3 -73
  46. package/dist/resource_clients/task.js +36 -33
  47. package/dist/resource_clients/task_collection.d.ts +2 -1
  48. package/dist/resource_clients/task_collection.js +9 -9
  49. package/dist/resource_clients/user.d.ts +3 -179
  50. package/dist/resource_clients/user.js +3 -11
  51. package/dist/resource_clients/webhook.d.ts +2 -61
  52. package/dist/resource_clients/webhook.js +1 -3
  53. package/dist/resource_clients/webhook_collection.js +10 -9
  54. package/dist/resource_clients/webhook_dispatch.d.ts +3 -36
  55. package/dist/resource_clients/webhook_dispatch.js +3 -7
  56. package/dist/resource_clients/webhook_dispatch_collection.js +8 -8
  57. package/dist/statistics.js +4 -3
  58. package/dist/utils.d.ts +51 -5
  59. package/dist/utils.js +103 -15
  60. package/package.json +22 -7
package/dist/utils.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mutuallyExclusive = exports.RequestQueuePaginationIterator = void 0;
3
+ exports.mutuallyExclusive = exports.paginationOptionsShape = exports.RequestQueuePaginationIterator = exports.anyObjectSchema = void 0;
4
+ exports.parseArgument = parseArgument;
5
+ exports.isNonArrayObject = isNonArrayObject;
4
6
  exports.pluckData = pluckData;
5
7
  exports.catchNotFoundOrThrow = catchNotFoundOrThrow;
6
8
  exports.parseDateFields = parseDateFields;
@@ -14,12 +16,49 @@ exports.getVersionData = getVersionData;
14
16
  exports.cast = cast;
15
17
  exports.asArray = asArray;
16
18
  exports.applyQueryParamsToUrl = applyQueryParamsToUrl;
17
- const tslib_1 = require("tslib");
18
- const ow_1 = tslib_1.__importDefault(require("ow"));
19
+ exports.toPathSegment = toPathSegment;
20
+ exports.toPath = toPath;
21
+ const zod_1 = require("zod");
22
+ const argument_validation_error_1 = require("./argument_validation_error");
19
23
  const NOT_FOUND_STATUS_CODE = 404;
20
24
  const RECORD_NOT_FOUND_TYPE = 'record-not-found';
21
25
  const RECORD_OR_TOKEN_NOT_FOUND_TYPE = 'record-or-token-not-found';
22
26
  const MIN_COMPRESS_BYTES = 1024;
27
+ // Zod installs its English locale as a module-level side effect but ships `"sideEffects": false`, so
28
+ // any tree-shaking bundler drops it and every message degrades to a bare "Invalid input". Passing it
29
+ // in per parse keeps them intact without reaching into the zod config the whole process shares.
30
+ const { localeError } = zod_1.z.locales.en();
31
+ /**
32
+ * Parses `value` with `schema`, returning the typed result (with schema defaults applied).
33
+ * Throws {@link ArgumentValidationError} on failure.
34
+ *
35
+ * The optional `label` names the interface being validated and is appended to every error line
36
+ * (e.g. ``... at `memory` in `ActorStartOptions` ``).
37
+ * @internal
38
+ */
39
+ function parseArgument(value, schema, label) {
40
+ const result = schema.safeParse(value, { error: localeError });
41
+ if (!result.success) {
42
+ throw new argument_validation_error_1.ArgumentValidationError(result.error, value, label);
43
+ }
44
+ return result.data;
45
+ }
46
+ /**
47
+ * Accepts any non-null, non-array object as a predicate for `z.custom()`.
48
+ * @internal
49
+ */
50
+ function isNonArrayObject(value) {
51
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
52
+ }
53
+ /**
54
+ * Matches any plain object, letting unknown keys through - for payloads whose shape the API
55
+ * validates itself. A `z.custom()` predicate rather than an object schema, so parsing returns
56
+ * the value itself instead of a copy.
57
+ * @internal
58
+ */
59
+ exports.anyObjectSchema = zod_1.z.custom(isNonArrayObject, {
60
+ error: 'Invalid input: expected an object',
61
+ });
23
62
  /**
24
63
  * Returns object's 'data' property or throws if parameter is not an object,
25
64
  * or an object without a 'data' property.
@@ -53,10 +92,16 @@ function catchNotFoundOrThrow(err) {
53
92
  * If the field cannot be converted to Date, it is left as is.
54
93
  */
55
94
  function parseDateFields(input, shouldParseField = null, depth = 0) {
56
- // Don't go too deep to avoid stack overflows (especially if there is a circular reference). The depth of 3
57
- // corresponds to obj.data.someArrayField.[x].field and should be generally enough.
95
+ // Don't go too deep to avoid stack overflows (especially if there is a circular reference). The depth of 4
96
+ // corresponds to obj.items.[x].someArrayField.[y].field, which is what a list response looks like: it
97
+ // nests one level deeper than the single resource it wraps, because both the item array and the nested
98
+ // array spend a level.
99
+ //
100
+ // In a list response it also reaches one level into caller-owned blobs the API stores verbatim, so a
101
+ // listed request's `userData.foo.somethingAt` comes back as a `Date` rather than the string it was
102
+ // written as.
58
103
  // TODO: Consider removing this limitation. It might came across as an annoying surprise as it's not communicated.
59
- if (depth > 3) {
104
+ if (depth > 4) {
60
105
  return input;
61
106
  }
62
107
  if (Array.isArray(input))
@@ -183,10 +228,20 @@ function isNode() {
183
228
  return !!(typeof process !== 'undefined' && process.versions && process.versions.node);
184
229
  }
185
230
  function isBuffer(value) {
186
- return ow_1.default.isValid(value, ow_1.default.any(ow_1.default.buffer, ow_1.default.arrayBuffer, ow_1.default.typedArray));
231
+ // Tag checks rather than `instanceof`, to also match buffers from another realm. `isView()`
232
+ // additionally covers `DataView`, which is not raw binary content.
233
+ if (ArrayBuffer.isView(value))
234
+ return !isTagged(value, 'DataView');
235
+ return isTagged(value, 'ArrayBuffer');
236
+ }
237
+ function isTagged(value, tag) {
238
+ return Object.prototype.toString.call(value) === `[object ${tag}]`;
187
239
  }
188
240
  function isStream(value) {
189
- return ow_1.default.isValid(value, ow_1.default.object.hasKeys('on', 'pipe'));
241
+ if (value === null || typeof value !== 'object')
242
+ return false;
243
+ const { on, pipe } = value;
244
+ return typeof on === 'function' && typeof pipe === 'function';
190
245
  }
191
246
  function getVersionData() {
192
247
  if (typeof BROWSER_BUILD !== 'undefined') {
@@ -239,6 +294,16 @@ class RequestQueuePaginationIterator {
239
294
  }
240
295
  }
241
296
  exports.RequestQueuePaginationIterator = RequestQueuePaginationIterator;
297
+ /**
298
+ * Schema shape of {@link PaginationOptions}, to spread into every paginating client's list schema. One
299
+ * copy stops it drifting from the interface.
300
+ * @internal
301
+ */
302
+ exports.paginationOptionsShape = {
303
+ limit: zod_1.z.number().min(0).optional(),
304
+ offset: zod_1.z.number().min(0).optional(),
305
+ chunkSize: zod_1.z.number().positive().optional(),
306
+ };
242
307
  function cast(input) {
243
308
  return input;
244
309
  }
@@ -265,11 +330,34 @@ function applyQueryParamsToUrl(url, options) {
265
330
  }
266
331
  return url;
267
332
  }
268
- const mutuallyExclusive = (...keys) => (value) => {
269
- const presentKeys = keys.filter((key) => typeof value[key] !== 'undefined');
270
- return {
271
- validator: presentKeys.length <= 1,
272
- message: `At most one of the following fields is allowed: ${keys.join(', ')}`,
273
- };
274
- };
333
+ /**
334
+ * Builds a `[check, message]` pair to spread into `.refine()`, asserting that at most one of `keys`
335
+ * is present. Pass the options interface as `T`, so that a misspelled key is a type error.
336
+ * @internal
337
+ */
338
+ const mutuallyExclusive = (...keys) => [
339
+ (value) => keys.filter((key) => typeof value[key] !== 'undefined').length <= 1,
340
+ `At most one of the following fields is allowed: ${keys.join(', ')}`,
341
+ ];
275
342
  exports.mutuallyExclusive = mutuallyExclusive;
343
+ const pathSegmentSchema = zod_1.z
344
+ .string()
345
+ .nonempty()
346
+ .refine((v) => v !== '.' && v !== '..', { error: 'URL path must not contain dot segments' });
347
+ /**
348
+ * Percent-encodes a caller-supplied URL path segment so it cannot restructure the request path.
349
+ *
350
+ * Empty strings and dot segments are rejected instead of encoded, because URL parsers resolve
351
+ * dot segments after decoding - `records/%2E%2E` collapses to the parent endpoint just like `records/..`.
352
+ */
353
+ function toPathSegment(value) {
354
+ const valueParsed = parseArgument(value, pathSegmentSchema);
355
+ return encodeURIComponent(valueParsed);
356
+ }
357
+ /**
358
+ * Builds a URL path from segments. A plain string is used as-is, so literal paths such as
359
+ * `requests/batch` keep their separators; an array has each of its segments encoded individually.
360
+ */
361
+ function toPath(path) {
362
+ return Array.isArray(path) ? path.map(toPathSegment).join('/') : path;
363
+ }
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "apify-client",
3
- "version": "2.25.1-beta.8",
3
+ "version": "3.0.0-beta.1",
4
4
  "description": "Apify API client for JavaScript",
5
+ "engines": {
6
+ "node": ">=22.0.0"
7
+ },
5
8
  "main": "dist/index.js",
6
9
  "module": "dist/index.mjs",
7
10
  "types": "dist/index.d.ts",
@@ -46,8 +49,14 @@
46
49
  "homepage": "https://docs.apify.com/api/client/js/",
47
50
  "files": [
48
51
  "dist",
49
- "!dist/*.tsbuildinfo"
52
+ "!dist/*.tsbuildinfo",
53
+ "!dist/spec_guards.*"
50
54
  ],
55
+ "apify": {
56
+ "openapiSpec": {
57
+ "version": "v2-2026-08-03T111309Z"
58
+ }
59
+ },
51
60
  "dependencies": {
52
61
  "@apify/consts": "^2.50.0",
53
62
  "@apify/log": "^2.2.6",
@@ -57,10 +66,10 @@
57
66
  "async-retry": "^1.3.3",
58
67
  "axios": "^1.16.0",
59
68
  "content-type": "^1.0.5",
60
- "ow": "^0.28.2",
61
69
  "proxy-agent": "^6.5.0",
62
70
  "tslib": "^2.5.0",
63
- "type-fest": "^4.0.0"
71
+ "type-fest": "^4.0.0",
72
+ "zod": "^4.0.0"
64
73
  },
65
74
  "devDependencies": {
66
75
  "@apify/oxlint-config": "^0.3.0",
@@ -81,8 +90,9 @@
81
90
  "esbuild": "0.28.2",
82
91
  "express": "^5.0.0",
83
92
  "gen-esm-wrapper": "^1.1.2",
93
+ "openapi-typescript": "7.13.0",
84
94
  "oxfmt": "0.65.0",
85
- "oxlint": "1.80.0",
95
+ "oxlint": "1.79.0",
86
96
  "oxlint-tsgolint": "7.0.2001",
87
97
  "puppeteer": "^25.0.0",
88
98
  "rimraf": "^6.0.0",
@@ -103,16 +113,21 @@
103
113
  "build": "pnpm clean && pnpm build:node && pnpm build:browser",
104
114
  "postbuild": "gen-esm-wrapper dist/index.js dist/index.mjs",
105
115
  "clean": "rimraf dist tsconfig.tsbuildinfo",
106
- "test": "pnpm build && vitest run",
116
+ "test": "pnpm build && vitest run --project unit",
117
+ "test:integration": "vitest run --project integration",
118
+ "test:all": "pnpm build && vitest run",
107
119
  "test:bundling": "pnpm build && pnpm --prefix=./test/bundling run bundle:all",
108
120
  "lint": "oxlint --type-aware",
109
121
  "lint:fix": "oxlint --type-aware --fix",
110
122
  "tsc-check-tests": "tsc --noEmit --project test/tsconfig.json",
123
+ "tsc-check-scripts": "tsc --noEmit --project tsconfig.scripts.json",
111
124
  "format": "oxfmt",
112
125
  "format:check": "oxfmt --check",
113
126
  "api:extract": "pnpm build && pnpm dlx github:apify/api-extractor-report --packages=. --extract-command='pnpm api:extract'",
114
127
  "api:check": "pnpm dlx github:apify/api-extractor-report --packages=. --extract-command='pnpm api:extract' --verify",
115
128
  "build:node": "tsc",
116
- "build:browser": "rsbuild build"
129
+ "build:browser": "rsbuild build",
130
+ "spec:fetch": "node scripts/openapi_spec.mts fetch",
131
+ "generate:types": "node scripts/openapi_spec.mts fetch && node scripts/generate_types.mts && node scripts/openapi_spec.mts record-version"
117
132
  }
118
133
  }