apify-client 3.0.0-beta.3 → 3.0.0-beta.5

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 (48) hide show
  1. package/dist/base/resource_client.d.ts +4 -3
  2. package/dist/base/resource_client.js +7 -7
  3. package/dist/base/resource_collection_client.d.ts +5 -4
  4. package/dist/base/resource_collection_client.js +9 -9
  5. package/dist/bundle.js +15 -13
  6. package/dist/bundle.js.map +1 -1
  7. package/dist/generated/api.d.ts +287 -214
  8. package/dist/generated/schemas.d.ts +6699 -0
  9. package/dist/generated/schemas.js +1521 -0
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -0
  12. package/dist/lazy_schema.d.ts +8 -0
  13. package/dist/lazy_schema.js +11 -0
  14. package/dist/models.d.ts +15 -40
  15. package/dist/resource_clients/actor.js +7 -6
  16. package/dist/resource_clients/actor_collection.js +3 -2
  17. package/dist/resource_clients/actor_env_var.js +3 -2
  18. package/dist/resource_clients/actor_env_var_collection.js +3 -2
  19. package/dist/resource_clients/actor_version.js +3 -2
  20. package/dist/resource_clients/actor_version_collection.js +3 -2
  21. package/dist/resource_clients/build.js +5 -4
  22. package/dist/resource_clients/build_collection.js +2 -1
  23. package/dist/resource_clients/dataset.js +5 -4
  24. package/dist/resource_clients/dataset_collection.js +3 -2
  25. package/dist/resource_clients/key_value_store.js +5 -4
  26. package/dist/resource_clients/key_value_store_collection.js +3 -2
  27. package/dist/resource_clients/request_queue.js +24 -16
  28. package/dist/resource_clients/request_queue_collection.js +3 -2
  29. package/dist/resource_clients/run.js +9 -8
  30. package/dist/resource_clients/run_collection.js +2 -1
  31. package/dist/resource_clients/schedule.d.ts +4 -4
  32. package/dist/resource_clients/schedule.js +8 -5
  33. package/dist/resource_clients/schedule_collection.js +3 -2
  34. package/dist/resource_clients/store_collection.js +2 -1
  35. package/dist/resource_clients/task.js +5 -4
  36. package/dist/resource_clients/task_collection.js +3 -2
  37. package/dist/resource_clients/user.js +6 -6
  38. package/dist/resource_clients/webhook.js +5 -4
  39. package/dist/resource_clients/webhook_collection.js +3 -2
  40. package/dist/resource_clients/webhook_dispatch.js +2 -1
  41. package/dist/resource_clients/webhook_dispatch_collection.js +2 -1
  42. package/dist/response_validation_error.d.ts +26 -0
  43. package/dist/response_validation_error.js +37 -0
  44. package/dist/schemas.d.ts +15 -0
  45. package/dist/schemas.js +15 -0
  46. package/dist/utils.d.ts +11 -0
  47. package/dist/utils.js +23 -0
  48. package/package.json +29 -29
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The schemas the resource clients validate API responses with.
3
+ *
4
+ * Today these are exactly the generated ones. The module still exists as the one place where a generated
5
+ * schema is widened when the API is known to return something the specification does not describe, so a
6
+ * documented deviation never sends a resource client reaching into `./generated` directly. An override
7
+ * declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
8
+ * built on the generated schema it replaces. Every schema that embeds an overridden one has to be rebuilt on
9
+ * top of it, and `spec_guards.ts` checks that each override still accepts what the specification describes,
10
+ * so one cannot narrow by accident.
11
+ *
12
+ * Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
13
+ * through. Neither do client narrowings: a schema only ever accepts more than the published type.
14
+ */
15
+ export * from './generated/schemas.js';
package/dist/utils.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { JsonValue, TypedArray } from 'type-fest';
3
3
  import { z } from 'zod';
4
4
  import type { ApifyApiError } from './apify_api_error.js';
5
5
  import { parseArgument } from '@apify/validations';
6
+ import type { ApifyResponse } from './http_client.js';
6
7
  import type { RequestQueueClientListRequestsOptions, RequestQueueClientListRequestsResult } from './resource_clients/request_queue.js';
7
8
  import type { WebhookUpdateData } from './resource_clients/webhook.js';
8
9
  export { parseArgument };
@@ -26,6 +27,16 @@ export declare const anyObjectSchema: z.ZodCustom<Record<string, unknown>, Recor
26
27
  export interface MaybeData<R> {
27
28
  data?: R;
28
29
  }
30
+ /**
31
+ * Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope, converts the
32
+ * date fields and validates the result against `schema`, one of the schemas generated from the OpenAPI
33
+ * specification. The validated copy is what callers get, so it is exactly what the schema accepted -- unknown
34
+ * fields and unknown enum values included, since the schemas let both through.
35
+ *
36
+ * Throws {@link ResponseValidationError} when the response does not match the specification.
37
+ * @internal
38
+ */
39
+ export declare function parseResponse<R>(response: ApifyResponse, schema: z.ZodType, shouldParseField?: ((key: string) => boolean) | null): R;
29
40
  /**
30
41
  * Returns object's 'data' property or throws if parameter is not an object,
31
42
  * or an object without a 'data' property.
package/dist/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { parseArgument } from '@apify/validations';
3
+ import { ResponseValidationError } from './response_validation_error.js';
3
4
  // @ts-ignore if we enable `resolveJsonModule`, we end up with a `src` folder in `dist`
4
5
  import packageJson from '../package.json' with { type: 'json' };
5
6
  const NOT_FOUND_STATUS_CODE = 404;
@@ -23,6 +24,28 @@ export function isNonArrayObject(value) {
23
24
  export const anyObjectSchema = z.custom(isNonArrayObject, {
24
25
  error: 'Invalid input: expected an object',
25
26
  });
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 } = z.locales.en();
31
+ /**
32
+ * Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope, converts the
33
+ * date fields and validates the result against `schema`, one of the schemas generated from the OpenAPI
34
+ * specification. The validated copy is what callers get, so it is exactly what the schema accepted -- unknown
35
+ * fields and unknown enum values included, since the schemas let both through.
36
+ *
37
+ * Throws {@link ResponseValidationError} when the response does not match the specification.
38
+ * @internal
39
+ */
40
+ export function parseResponse(response, schema, shouldParseField = null) {
41
+ const data = parseDateFields(pluckData(response.data), shouldParseField);
42
+ const result = schema.safeParse(data, { error: localeError });
43
+ if (!result.success) {
44
+ const { method = 'GET', url = '' } = response.config;
45
+ throw new ResponseValidationError(result.error, data, { method, url });
46
+ }
47
+ return result.data;
48
+ }
26
49
  /**
27
50
  * Returns object's 'data' property or throws if parameter is not an object,
28
51
  * or an object without a 'data' property.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-client",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "Apify API client for JavaScript",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "apify": {
55
55
  "openapiSpec": {
56
- "version": "v2-2026-08-03T111309Z"
56
+ "version": "v2-2026-08-31T125154Z"
57
57
  }
58
58
  },
59
59
  "dependencies": {
@@ -61,45 +61,45 @@
61
61
  "@apify/log": "^3.0.1",
62
62
  "@apify/utilities": "^3.0.1",
63
63
  "@apify/validations": "^1.1.0",
64
- "@crawlee/types": "^3.3.0",
65
- "ansi-colors": "^4.1.1",
64
+ "@crawlee/types": "^3.18.1",
65
+ "ansi-colors": "^4.1.3",
66
66
  "async-retry": "^1.3.3",
67
- "axios": "^1.16.0",
67
+ "axios": "^1.20.0",
68
68
  "content-type": "^1.0.5",
69
69
  "proxy-agent": "^6.5.0",
70
- "tslib": "^2.5.0",
71
- "type-fest": "^4.0.0",
70
+ "tslib": "^2.8.1",
71
+ "type-fest": "^4.41.0",
72
72
  "zod": "^4.5.4"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@apify/oxlint-config": "^0.3.0",
76
76
  "@apify/tsconfig": "^0.2.0",
77
77
  "@crawlee/puppeteer": "4.0.0-beta.165",
78
- "@rsbuild/core": "^2.0.0",
79
- "@rsbuild/plugin-node-polyfill": "^1.3.0",
80
- "@rspack/cli": "^2.0.0",
81
- "@rspack/core": "^2.0.0",
82
- "@types/async-retry": "^1.4.5",
78
+ "@rsbuild/core": "^2.2.3",
79
+ "@rsbuild/plugin-node-polyfill": "^1.4.6",
80
+ "@rspack/cli": "^2.2.2",
81
+ "@rspack/core": "^2.2.2",
82
+ "@types/async-retry": "^1.4.9",
83
83
  "@types/compression": "^1.8.1",
84
- "@types/content-type": "^1.1.5",
85
- "@types/express": "^5.0.0",
86
- "@types/node": "^24.0.0",
87
- "ajv": "^8.17.1",
88
- "body-parser": "^2.0.0",
89
- "compression": "^1.7.4",
84
+ "@types/content-type": "^1.1.9",
85
+ "@types/express": "^5.0.6",
86
+ "@types/node": "^24.13.3",
87
+ "ajv": "^8.20.0",
88
+ "body-parser": "^2.3.0",
89
+ "compression": "^1.8.1",
90
90
  "esbuild": "0.28.2",
91
- "express": "^5.0.0",
91
+ "express": "^5.2.1",
92
92
  "openapi-typescript": "7.13.0",
93
- "oxfmt": "0.65.0",
94
- "oxlint": "1.79.0",
93
+ "oxfmt": "0.66.0",
94
+ "oxlint": "1.81.0",
95
95
  "oxlint-tsgolint": "7.0.2001",
96
- "puppeteer": "^25.0.0",
97
- "rimraf": "^6.0.0",
98
- "rolldown": "^1.0.0-rc.4",
99
- "typescript": "^6.0.0",
100
- "vitest": "^4.0.16",
101
- "webpack": "^5.105.2",
102
- "webpack-cli": "^7.0.0"
96
+ "puppeteer": "^25.10.0",
97
+ "rimraf": "^6.1.3",
98
+ "rolldown": "^1.2.7",
99
+ "typescript": "^6.0.3",
100
+ "vitest": "^5.0.0",
101
+ "webpack": "^5.110.3",
102
+ "webpack-cli": "^7.2.3"
103
103
  },
104
104
  "devEngines": {
105
105
  "packageManager": {
@@ -126,6 +126,6 @@
126
126
  "build:node": "tsc",
127
127
  "build:browser": "rsbuild build",
128
128
  "spec:fetch": "node scripts/openapi_spec.mts fetch",
129
- "generate:types": "node scripts/openapi_spec.mts fetch && node scripts/generate_types.mts && node scripts/openapi_spec.mts record-version"
129
+ "generate:models": "node scripts/openapi_spec.mts fetch && node scripts/generate_types.mts && node scripts/generate_schemas.mts && node scripts/openapi_spec.mts record-version"
130
130
  }
131
131
  }