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

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.
@@ -167,7 +167,7 @@ export class HttpClient {
167
167
  if (response.status === RATE_LIMIT_EXCEEDED_STATUS_CODE) {
168
168
  this.stats.addRateLimitError(attempt);
169
169
  }
170
- const apiError = new ApifyApiError(response, attempt);
170
+ const apiError = ApifyApiError.fromResponse(response, attempt);
171
171
  if (this._isStatusCodeRetryable(response.status)) {
172
172
  if (requestIsStream) {
173
173
  this._informAboutStreamNoRetry();
package/dist/models.d.ts CHANGED
@@ -48,6 +48,12 @@ export declare enum WebhookDispatchStatus {
48
48
  Succeeded = "SUCCEEDED",
49
49
  Failed = "FAILED"
50
50
  }
51
+ /**
52
+ * Machine-readable type of an error returned by the Apify API, carried by `ApifyApiError.type`.
53
+ *
54
+ * Declared here, next to the other spec-derived types, and re-exported from `./apify_api_error`.
55
+ */
56
+ export type ApifyApiErrorType = Schemas['ErrorType'];
51
57
  /**
52
58
  * Fields the API returns on a dataset that the OpenAPI spec does not describe yet.
53
59
  *
package/dist/utils.d.ts CHANGED
@@ -43,8 +43,7 @@ export declare function parseResponse<R>(response: ApifyResponse, schema: z.ZodT
43
43
  */
44
44
  export declare function pluckData<R>(obj: MaybeData<R>): R;
45
45
  /**
46
- * If given HTTP error has NOT_FOUND_STATUS_CODE status code then returns undefined.
47
- * Otherwise rethrows error.
46
+ * Swallows a 404 Not Found API error and rethrows anything else.
48
47
  */
49
48
  export declare function catchNotFoundOrThrow(err: ApifyApiError): void;
50
49
  type ReturnJsonValue = string | number | boolean | null | Date | ReturnJsonObject | ReturnJsonArray;
package/dist/utils.js CHANGED
@@ -1,11 +1,9 @@
1
1
  import { z } from 'zod';
2
+ import { NotFoundError } from './apify_api_error.js';
2
3
  import { parseArgument } from '@apify/validations';
3
4
  import { ResponseValidationError } from './response_validation_error.js';
4
5
  // @ts-ignore if we enable `resolveJsonModule`, we end up with a `src` folder in `dist`
5
6
  import packageJson from '../package.json' with { type: 'json' };
6
- const NOT_FOUND_STATUS_CODE = 404;
7
- const RECORD_NOT_FOUND_TYPE = 'record-not-found';
8
- const RECORD_OR_TOKEN_NOT_FOUND_TYPE = 'record-or-token-not-found';
9
7
  const MIN_COMPRESS_BYTES = 1024;
10
8
  export { parseArgument };
11
9
  /**
@@ -58,14 +56,10 @@ export function pluckData(obj) {
58
56
  throw new Error(`Expected response object with a "data" property, but received: ${obj}`);
59
57
  }
60
58
  /**
61
- * If given HTTP error has NOT_FOUND_STATUS_CODE status code then returns undefined.
62
- * Otherwise rethrows error.
59
+ * Swallows a 404 Not Found API error and rethrows anything else.
63
60
  */
64
61
  export function catchNotFoundOrThrow(err) {
65
- const isNotFoundStatus = err.statusCode === NOT_FOUND_STATUS_CODE;
66
- const isNotFoundMessage = err.type === RECORD_NOT_FOUND_TYPE || err.type === RECORD_OR_TOKEN_NOT_FOUND_TYPE || err.httpMethod === 'head';
67
- const isNotFoundError = isNotFoundStatus && isNotFoundMessage;
68
- if (!isNotFoundError)
62
+ if (!(err instanceof NotFoundError))
69
63
  throw err;
70
64
  }
71
65
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-client",
3
- "version": "3.0.0-beta.5",
3
+ "version": "3.0.0-beta.6",
4
4
  "description": "Apify API client for JavaScript",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"