apify-client 3.0.0-rc.0 → 3.0.0-rc.2
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/README.md +10 -2
- package/dist/apify_api_error.d.ts +4 -3
- package/dist/apify_api_error.js +2 -1
- package/dist/apify_client.d.ts +8 -8
- package/dist/apify_client.js +10 -10
- package/dist/apify_client_error.d.ts +10 -0
- package/dist/apify_client_error.js +10 -0
- package/dist/axios.d.ts +2 -0
- package/dist/axios.js +1 -0
- package/dist/base/api_client.js +8 -20
- package/dist/base/resource_client.js +8 -8
- package/dist/body_parser.d.ts +1 -1
- package/dist/bundle.js +31 -30
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +2427 -725
- package/dist/generated/schemas.d.ts +1868 -274
- package/dist/generated/schemas.js +437 -79
- package/dist/http_clients/axios.d.ts +35 -15
- package/dist/http_clients/axios.js +80 -32
- package/dist/http_clients/base.d.ts +105 -34
- package/dist/http_clients/base.js +169 -52
- package/dist/http_clients/fetch.d.ts +53 -0
- package/dist/http_clients/fetch.js +219 -0
- package/dist/http_clients/index.d.ts +2 -2
- package/dist/http_clients/index.js +1 -1
- package/dist/http_compressors/index.d.ts +2 -0
- package/dist/http_compressors/index.js +1 -0
- package/dist/http_compressors/resolve.d.ts +4 -3
- package/dist/http_compressors/resolve.js +4 -1
- package/dist/http_compressors/zstd.d.ts +34 -0
- package/dist/http_compressors/zstd.js +43 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/invalid_response_body_error.d.ts +5 -4
- package/dist/invalid_response_body_error.js +5 -4
- package/dist/models.d.ts +30 -61
- package/dist/resource_clients/actor.d.ts +33 -2
- package/dist/resource_clients/actor.js +46 -3
- package/dist/resource_clients/actor_server.d.ts +149 -0
- package/dist/resource_clients/actor_server.js +195 -0
- package/dist/resource_clients/actor_version.d.ts +7 -1
- package/dist/resource_clients/actor_version.js +3 -2
- package/dist/resource_clients/actor_version_collection.d.ts +2 -1
- package/dist/resource_clients/actor_version_collection.js +3 -2
- package/dist/resource_clients/dataset.d.ts +33 -5
- package/dist/resource_clients/dataset.js +12 -54
- package/dist/resource_clients/key_value_store.d.ts +63 -22
- package/dist/resource_clients/key_value_store.js +62 -19
- package/dist/resource_clients/log.d.ts +32 -7
- package/dist/resource_clients/log.js +11 -14
- package/dist/resource_clients/request_queue.d.ts +9 -0
- package/dist/resource_clients/request_queue.js +9 -6
- package/dist/resource_clients/run.d.ts +15 -2
- package/dist/resource_clients/run.js +12 -5
- package/dist/resource_clients/store_collection.d.ts +4 -0
- package/dist/resource_clients/task.js +3 -3
- package/dist/response_validation_error.d.ts +2 -1
- package/dist/response_validation_error.js +2 -1
- package/dist/runtime/node.js +79 -17
- package/dist/runtime/types.d.ts +35 -5
- package/dist/runtime/web.js +43 -1
- package/dist/schemas.d.ts +369 -3
- package/dist/schemas.js +25 -3
- package/dist/utils.d.ts +52 -27
- package/dist/utils.js +45 -25
- package/package.json +42 -30
package/dist/utils.js
CHANGED
|
@@ -80,6 +80,7 @@ export const anyObjectSchema = z.custom(isNonArrayObject, {
|
|
|
80
80
|
// any tree-shaking bundler drops it and every message degrades to a bare "Invalid input". Passing it
|
|
81
81
|
// in per parse keeps them intact without reaching into the zod config the whole process shares.
|
|
82
82
|
const { localeError } = z.locales.en();
|
|
83
|
+
const RESPONSE_ENVELOPE_SCHEMA = z.object({ data: z.unknown() });
|
|
83
84
|
/**
|
|
84
85
|
* Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope and validates the
|
|
85
86
|
* result against `schema`, one of the schemas generated from the OpenAPI specification. The validated copy is what
|
|
@@ -91,25 +92,18 @@ const { localeError } = z.locales.en();
|
|
|
91
92
|
* @internal
|
|
92
93
|
*/
|
|
93
94
|
export function parseResponse(response, schema) {
|
|
94
|
-
const
|
|
95
|
+
const { method = 'GET', url = '' } = response.config;
|
|
96
|
+
const envelope = RESPONSE_ENVELOPE_SCHEMA.safeParse(response.data, { error: localeError });
|
|
97
|
+
if (!envelope.success) {
|
|
98
|
+
throw new ResponseValidationError(envelope.error, response.data, { method, url });
|
|
99
|
+
}
|
|
100
|
+
const { data } = envelope.data;
|
|
95
101
|
const result = schema.safeParse(data, { error: localeError });
|
|
96
102
|
if (!result.success) {
|
|
97
|
-
const { method = 'GET', url = '' } = response.config;
|
|
98
103
|
throw new ResponseValidationError(result.error, data, { method, url });
|
|
99
104
|
}
|
|
100
105
|
return result.data;
|
|
101
106
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Returns object's 'data' property or throws if parameter is not an object,
|
|
104
|
-
* or an object without a 'data' property.
|
|
105
|
-
*/
|
|
106
|
-
export function pluckData(obj) {
|
|
107
|
-
if (typeof obj === 'object' && obj) {
|
|
108
|
-
if (typeof obj.data !== 'undefined')
|
|
109
|
-
return obj.data;
|
|
110
|
-
}
|
|
111
|
-
throw new Error(`Expected response object with a "data" property, but received: ${obj}`);
|
|
112
|
-
}
|
|
113
107
|
/**
|
|
114
108
|
* Swallows a 404 Not Found API error and rethrows anything else.
|
|
115
109
|
*/
|
|
@@ -179,8 +173,8 @@ export function toBytes(value) {
|
|
|
179
173
|
/**
|
|
180
174
|
* Decides whether a request body with the given content type is worth compressing.
|
|
181
175
|
*
|
|
182
|
-
* Images, audio, video and archives already carry their own compression. Running them through brotli or
|
|
183
|
-
* burns CPU, holds a second full copy of the body in memory, and usually produces output slightly larger than
|
|
176
|
+
* Images, audio, video and archives already carry their own compression. Running them through brotli, gzip or
|
|
177
|
+
* zstd burns CPU, holds a second full copy of the body in memory, and usually produces output slightly larger than
|
|
184
178
|
* the input. Formats that are raw despite such a media type, for example `image/bmp` or `audio/wav`, are still
|
|
185
179
|
* compressed. A body with no content type is assumed to be compressible.
|
|
186
180
|
* @internal
|
|
@@ -242,15 +236,35 @@ export function isBuffer(value) {
|
|
|
242
236
|
return !isTagged(value, 'DataView');
|
|
243
237
|
return isTagged(value, 'ArrayBuffer');
|
|
244
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Whether a value is a `Blob`, a `File` included. Unlike a stream, a blob can be read again for every attempt of a
|
|
241
|
+
* request, so a request with a blob body can be retried.
|
|
242
|
+
*/
|
|
243
|
+
export function isBlob(value) {
|
|
244
|
+
return isTagged(value, 'Blob') || isTagged(value, 'File');
|
|
245
|
+
}
|
|
245
246
|
function isTagged(value, tag) {
|
|
246
247
|
return Object.prototype.toString.call(value) === `[object ${tag}]`;
|
|
247
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Whether a value is a web `ReadableStream`, which is what the callers get for a streamed response and may pass
|
|
251
|
+
* on as a request body.
|
|
252
|
+
*/
|
|
253
|
+
export function isWebStream(value) {
|
|
254
|
+
return isTagged(value, 'ReadableStream');
|
|
255
|
+
}
|
|
248
256
|
export function isStream(value) {
|
|
249
257
|
if (value === null || typeof value !== 'object')
|
|
250
258
|
return false;
|
|
251
259
|
const { on, pipe } = value;
|
|
252
260
|
return typeof on === 'function' && typeof pipe === 'function';
|
|
253
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Whether a value is a stream of either kind, which a request can send only once.
|
|
264
|
+
*/
|
|
265
|
+
export function isAnyStream(value) {
|
|
266
|
+
return isStream(value) || isWebStream(value);
|
|
267
|
+
}
|
|
254
268
|
/**
|
|
255
269
|
* Helper class to create async iterators from paginated list endpoints.
|
|
256
270
|
*/
|
|
@@ -288,6 +302,22 @@ export class RequestQueuePaginationIterator {
|
|
|
288
302
|
}
|
|
289
303
|
}
|
|
290
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* The smaller of two page limits, for the `limit` query parameter. The API treats a `limit` of 0 as unset, so 0 here
|
|
307
|
+
* means no limit and loses to any other value.
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
export function minForLimitParam(a, b) {
|
|
311
|
+
if (a === 0)
|
|
312
|
+
a = undefined;
|
|
313
|
+
if (b === 0)
|
|
314
|
+
b = undefined;
|
|
315
|
+
if (a === undefined)
|
|
316
|
+
return b;
|
|
317
|
+
if (b === undefined)
|
|
318
|
+
return a;
|
|
319
|
+
return Math.min(a, b);
|
|
320
|
+
}
|
|
291
321
|
/**
|
|
292
322
|
* Schema shape of {@link PaginationOptions}, to spread into every paginating client's list schema. One
|
|
293
323
|
* copy stops it drifting from the interface.
|
|
@@ -298,16 +328,6 @@ export const paginationOptionsShape = {
|
|
|
298
328
|
offset: z.number().min(0).optional(),
|
|
299
329
|
chunkSize: z.number().positive().optional(),
|
|
300
330
|
};
|
|
301
|
-
/**
|
|
302
|
-
* Key under which a page of dataset items carries the number of rows the API scanned to produce it, as a
|
|
303
|
-
* non-enumerable property that stays out of the page's public shape. The API applies `offset` and `limit` to the
|
|
304
|
-
* dataset's rows first and shapes the result afterwards: filters (`clean`, `skipEmpty`, `skipHidden`) drop items and
|
|
305
|
-
* `unwind` splits or drops them, so `items.length` can land on either side of the rows scanned. The
|
|
306
|
-
* `x-apify-pagination-count` header reports the scanned number, and the offset iterator advances and terminates by it
|
|
307
|
-
* alone. A page without the property falls back to `items.length`.
|
|
308
|
-
* @internal
|
|
309
|
-
*/
|
|
310
|
-
export const SCANNED_COUNT = Symbol('scannedCount');
|
|
311
331
|
export function cast(input) {
|
|
312
332
|
return input;
|
|
313
333
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apify-client",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.2",
|
|
4
4
|
"description": "Apify API client for JavaScript",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=22.
|
|
6
|
+
"node": ">=22.15.0"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "dist/index.js",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
"./package.json": "./package.json",
|
|
21
21
|
"./browser": "./dist/bundle.js",
|
|
22
|
+
"./axios": {
|
|
23
|
+
"types": "./dist/axios.d.ts",
|
|
24
|
+
"default": "./dist/axios.js"
|
|
25
|
+
},
|
|
22
26
|
".": {
|
|
23
27
|
"types": "./dist/index.d.ts",
|
|
24
28
|
"browser": "./dist/bundle.js",
|
|
@@ -59,54 +63,61 @@
|
|
|
59
63
|
],
|
|
60
64
|
"apify": {
|
|
61
65
|
"openapiSpec": {
|
|
62
|
-
"version": "v2-2026-
|
|
66
|
+
"version": "v2-2026-11-18T151559Z"
|
|
63
67
|
}
|
|
64
68
|
},
|
|
65
69
|
"dependencies": {
|
|
66
|
-
"@apify/consts": "^3.0
|
|
67
|
-
"@apify/log": "^3.0.
|
|
68
|
-
"@apify/utilities": "^3.1.
|
|
69
|
-
"@apify/validations": "^1.1.
|
|
70
|
+
"@apify/consts": "^3.1.0",
|
|
71
|
+
"@apify/log": "^3.0.2",
|
|
72
|
+
"@apify/utilities": "^3.1.1",
|
|
73
|
+
"@apify/validations": "^1.1.4",
|
|
70
74
|
"ansi-colors": "^4.1.3",
|
|
71
|
-
"axios": "^1.20.0",
|
|
72
75
|
"content-type": "^3.1.1",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
"tslib": "^2.9.1",
|
|
77
|
+
"zod": "^4.6.7"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"axios": "^1.21.1"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"axios": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
77
86
|
},
|
|
78
87
|
"devDependencies": {
|
|
79
|
-
"@apify/oxlint-config": "^0.
|
|
88
|
+
"@apify/oxlint-config": "^0.4.1",
|
|
80
89
|
"@apify/tsconfig": "^0.2.0",
|
|
81
|
-
"@crawlee/puppeteer": "4.0.0-rc.
|
|
82
|
-
"@rsbuild/core": "^2.
|
|
90
|
+
"@crawlee/puppeteer": "4.0.0-rc.2",
|
|
91
|
+
"@rsbuild/core": "^2.3.3",
|
|
83
92
|
"@rsbuild/plugin-node-polyfill": "^1.4.6",
|
|
84
|
-
"@rspack/cli": "^2.
|
|
85
|
-
"@rspack/core": "^2.
|
|
93
|
+
"@rspack/cli": "^2.3.3",
|
|
94
|
+
"@rspack/core": "^2.3.3",
|
|
86
95
|
"@types/compression": "^1.8.1",
|
|
87
96
|
"@types/express": "^5.0.6",
|
|
88
|
-
"@types/node": "^
|
|
97
|
+
"@types/node": "^26.6.6",
|
|
89
98
|
"ajv": "^8.20.0",
|
|
90
|
-
"
|
|
99
|
+
"axios": "^1.21.1",
|
|
100
|
+
"body-parser": "^2.4.0",
|
|
91
101
|
"compression": "^1.8.2",
|
|
92
102
|
"esbuild": "0.28.2",
|
|
93
|
-
"express": "^5.
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"oxlint
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
103
|
+
"express": "^5.3.0",
|
|
104
|
+
"miniflare": "4.20260730.0",
|
|
105
|
+
"oxfmt": "0.80.0",
|
|
106
|
+
"oxlint": "1.93.0",
|
|
107
|
+
"oxlint-tsgolint": "7.0.2007",
|
|
108
|
+
"puppeteer": "^25.18.1",
|
|
109
|
+
"rimraf": "^6.1.4",
|
|
110
|
+
"rolldown": "^1.3.3",
|
|
100
111
|
"typescript": "^7.0.2",
|
|
101
112
|
"typescript-v6": "npm:typescript@^6.0.3",
|
|
102
|
-
"vitest": "^5.
|
|
103
|
-
"webpack": "^5.
|
|
104
|
-
"webpack-cli": "^7.
|
|
113
|
+
"vitest": "^5.1.1",
|
|
114
|
+
"webpack": "^5.113.0",
|
|
115
|
+
"webpack-cli": "^7.3.1"
|
|
105
116
|
},
|
|
106
117
|
"devEngines": {
|
|
107
118
|
"packageManager": {
|
|
108
119
|
"name": "pnpm",
|
|
109
|
-
"version": "12.
|
|
120
|
+
"version": "12.18.0",
|
|
110
121
|
"onFail": "warn"
|
|
111
122
|
}
|
|
112
123
|
},
|
|
@@ -114,6 +125,7 @@
|
|
|
114
125
|
"build": "pnpm clean && pnpm build:node && pnpm build:browser",
|
|
115
126
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
116
127
|
"test": "pnpm build && vitest run --project unit",
|
|
128
|
+
"test:axios": "pnpm build && vitest run --project unit-axios",
|
|
117
129
|
"test:integration": "vitest run --project integration",
|
|
118
130
|
"test:all": "pnpm build && vitest run",
|
|
119
131
|
"test:bundling": "pnpm build && pnpm --prefix=./test/bundling run bundle:all",
|