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.
- package/dist/apify_client.js +34 -30
- package/dist/argument_validation_error.d.ts +17 -0
- package/dist/argument_validation_error.js +157 -0
- package/dist/base/api_client.d.ts +2 -2
- package/dist/base/api_client.js +13 -10
- package/dist/bundle.js +66 -28147
- package/dist/bundle.js.LICENSE.txt +33 -0
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +20522 -0
- package/dist/generated/api.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/models.d.ts +1072 -0
- package/dist/models.js +89 -0
- package/dist/resource_clients/actor.d.ts +2 -448
- package/dist/resource_clients/actor.js +60 -55
- package/dist/resource_clients/actor_collection.d.ts +2 -7
- package/dist/resource_clients/actor_collection.js +13 -11
- package/dist/resource_clients/actor_env_var.js +2 -3
- package/dist/resource_clients/actor_env_var_collection.js +3 -3
- package/dist/resource_clients/actor_version.d.ts +3 -40
- package/dist/resource_clients/actor_version.js +8 -12
- package/dist/resource_clients/actor_version_collection.js +3 -3
- package/dist/resource_clients/build.d.ts +2 -77
- package/dist/resource_clients/build.js +7 -10
- package/dist/resource_clients/build_collection.d.ts +2 -2
- package/dist/resource_clients/build_collection.js +8 -8
- package/dist/resource_clients/dataset.d.ts +8 -72
- package/dist/resource_clients/dataset.js +66 -57
- package/dist/resource_clients/dataset_collection.js +14 -12
- package/dist/resource_clients/key_value_store.d.ts +5 -73
- package/dist/resource_clients/key_value_store.js +69 -51
- package/dist/resource_clients/key_value_store_collection.js +14 -12
- package/dist/resource_clients/request_queue.d.ts +15 -174
- package/dist/resource_clients/request_queue.js +85 -91
- package/dist/resource_clients/request_queue_collection.js +12 -11
- package/dist/resource_clients/run.js +39 -40
- package/dist/resource_clients/run_collection.js +12 -11
- package/dist/resource_clients/schedule.d.ts +3 -81
- package/dist/resource_clients/schedule.js +4 -12
- package/dist/resource_clients/schedule_collection.js +10 -9
- package/dist/resource_clients/store_collection.d.ts +2 -30
- package/dist/resource_clients/store_collection.js +13 -13
- package/dist/resource_clients/task.d.ts +3 -73
- package/dist/resource_clients/task.js +36 -33
- package/dist/resource_clients/task_collection.d.ts +2 -1
- package/dist/resource_clients/task_collection.js +9 -9
- package/dist/resource_clients/user.d.ts +3 -179
- package/dist/resource_clients/user.js +3 -11
- package/dist/resource_clients/webhook.d.ts +2 -61
- package/dist/resource_clients/webhook.js +1 -3
- package/dist/resource_clients/webhook_collection.js +10 -9
- package/dist/resource_clients/webhook_dispatch.d.ts +3 -36
- package/dist/resource_clients/webhook_dispatch.js +3 -7
- package/dist/resource_clients/webhook_dispatch_collection.js +8 -8
- package/dist/statistics.js +4 -3
- package/dist/utils.d.ts +51 -5
- package/dist/utils.js +103 -15
- 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
|
-
|
|
18
|
-
|
|
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
|
|
57
|
-
// corresponds to obj.
|
|
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 >
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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": "
|
|
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.
|
|
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
|
}
|