apify-client 3.0.0-beta.10 → 3.0.0-beta.11

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.
@@ -9,8 +9,16 @@ export declare const DEFAULT_TIMEOUT_MILLIS: number;
9
9
  * @private
10
10
  */
11
11
  export declare class ResourceClient extends ApiClient {
12
+ /**
13
+ * A 404 resolves to `undefined` only when the client names its resource by ID. A chained client without one, such
14
+ * as `run.dataset()`, throws it instead (see `catchNotFoundForResourceOrThrow()`).
15
+ */
12
16
  protected _get<T, R>(schema: z.ZodType, options?: T, timeoutMillis?: number): Promise<R | undefined>;
13
17
  protected _update<T, R>(schema: z.ZodType, newFields: T, timeoutMillis?: number): Promise<R>;
18
+ /**
19
+ * A 404 is swallowed, keeping the DELETE idempotent, only when the client names its resource by ID. A chained client
20
+ * without one throws it instead (see `catchNotFoundForResourceOrThrow()`).
21
+ */
14
22
  protected _delete(timeoutMillis?: number): Promise<void>;
15
23
  /**
16
24
  * This function is used in Build and Run endpoints so it's kept
@@ -1,5 +1,5 @@
1
1
  import { ACT_JOB_TERMINAL_STATUSES } from '@apify/consts';
2
- import { catchNotFoundOrThrow, parseResponse } from '../utils.js';
2
+ import { catchNotFoundForResourceOrThrow, catchNotFoundOrThrow, parseResponse } from '../utils.js';
3
3
  import { ApiClient } from './api_client.js';
4
4
  /**
5
5
  * We need to supply some number for the API,
@@ -15,6 +15,10 @@ export const DEFAULT_TIMEOUT_MILLIS = 360 * 1000; // 6 minutes
15
15
  * @private
16
16
  */
17
17
  export class ResourceClient extends ApiClient {
18
+ /**
19
+ * A 404 resolves to `undefined` only when the client names its resource by ID. A chained client without one, such
20
+ * as `run.dataset()`, throws it instead (see `catchNotFoundForResourceOrThrow()`).
21
+ */
18
22
  async _get(schema, options = {}, timeoutMillis) {
19
23
  const requestOpts = {
20
24
  url: this._url(),
@@ -27,7 +31,7 @@ export class ResourceClient extends ApiClient {
27
31
  return parseResponse(response, schema);
28
32
  }
29
33
  catch (err) {
30
- catchNotFoundOrThrow(err);
34
+ catchNotFoundForResourceOrThrow(err, this.id);
31
35
  }
32
36
  return undefined;
33
37
  }
@@ -41,6 +45,10 @@ export class ResourceClient extends ApiClient {
41
45
  });
42
46
  return parseResponse(response, schema);
43
47
  }
48
+ /**
49
+ * A 404 is swallowed, keeping the DELETE idempotent, only when the client names its resource by ID. A chained client
50
+ * without one throws it instead (see `catchNotFoundForResourceOrThrow()`).
51
+ */
44
52
  async _delete(timeoutMillis) {
45
53
  try {
46
54
  await this.httpClient.call({
@@ -51,7 +59,7 @@ export class ResourceClient extends ApiClient {
51
59
  });
52
60
  }
53
61
  catch (err) {
54
- catchNotFoundOrThrow(err);
62
+ catchNotFoundForResourceOrThrow(err, this.id);
55
63
  }
56
64
  }
57
65
  /**