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.
- package/dist/base/resource_client.d.ts +4 -3
- package/dist/base/resource_client.js +7 -7
- package/dist/base/resource_collection_client.d.ts +5 -4
- package/dist/base/resource_collection_client.js +9 -9
- package/dist/bundle.js +15 -13
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +287 -214
- package/dist/generated/schemas.d.ts +6699 -0
- package/dist/generated/schemas.js +1521 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +15 -40
- package/dist/resource_clients/actor.js +7 -6
- package/dist/resource_clients/actor_collection.js +3 -2
- package/dist/resource_clients/actor_env_var.js +3 -2
- package/dist/resource_clients/actor_env_var_collection.js +3 -2
- package/dist/resource_clients/actor_version.js +3 -2
- package/dist/resource_clients/actor_version_collection.js +3 -2
- package/dist/resource_clients/build.js +5 -4
- package/dist/resource_clients/build_collection.js +2 -1
- package/dist/resource_clients/dataset.js +5 -4
- package/dist/resource_clients/dataset_collection.js +3 -2
- package/dist/resource_clients/key_value_store.js +5 -4
- package/dist/resource_clients/key_value_store_collection.js +3 -2
- package/dist/resource_clients/request_queue.js +24 -16
- package/dist/resource_clients/request_queue_collection.js +3 -2
- package/dist/resource_clients/run.js +9 -8
- package/dist/resource_clients/run_collection.js +2 -1
- package/dist/resource_clients/schedule.d.ts +4 -4
- package/dist/resource_clients/schedule.js +8 -5
- package/dist/resource_clients/schedule_collection.js +3 -2
- package/dist/resource_clients/store_collection.js +2 -1
- package/dist/resource_clients/task.js +5 -4
- package/dist/resource_clients/task_collection.js +3 -2
- package/dist/resource_clients/user.js +6 -6
- package/dist/resource_clients/webhook.js +5 -4
- package/dist/resource_clients/webhook_collection.js +3 -2
- package/dist/resource_clients/webhook_dispatch.js +2 -1
- package/dist/resource_clients/webhook_dispatch_collection.js +2 -1
- package/dist/response_validation_error.d.ts +26 -0
- package/dist/response_validation_error.js +37 -0
- package/dist/schemas.d.ts +15 -0
- package/dist/schemas.js +15 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +23 -0
- package/package.json +29 -29
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ACT_JOB_STATUSES } from '@apify/consts';
|
|
2
|
+
import type { z } from 'zod';
|
|
2
3
|
import { ApiClient } from './api_client.js';
|
|
3
4
|
export declare const SMALL_TIMEOUT_MILLIS: number;
|
|
4
5
|
export declare const MEDIUM_TIMEOUT_MILLIS: number;
|
|
@@ -8,8 +9,8 @@ export declare const DEFAULT_TIMEOUT_MILLIS: number;
|
|
|
8
9
|
* @private
|
|
9
10
|
*/
|
|
10
11
|
export declare class ResourceClient extends ApiClient {
|
|
11
|
-
protected _get<T, R>(options?: T, timeoutMillis?: number): Promise<R | undefined>;
|
|
12
|
-
protected _update<T, R>(newFields: T, timeoutMillis?: number): Promise<R>;
|
|
12
|
+
protected _get<T, R>(schema: z.ZodType, options?: T, timeoutMillis?: number): Promise<R | undefined>;
|
|
13
|
+
protected _update<T, R>(schema: z.ZodType, newFields: T, timeoutMillis?: number): Promise<R>;
|
|
13
14
|
protected _delete(timeoutMillis?: number): Promise<void>;
|
|
14
15
|
/**
|
|
15
16
|
* This function is used in Build and Run endpoints so it's kept
|
|
@@ -17,7 +18,7 @@ export declare class ResourceClient extends ApiClient {
|
|
|
17
18
|
*/
|
|
18
19
|
protected _waitForFinish<R extends {
|
|
19
20
|
status: (typeof ACT_JOB_STATUSES)[keyof typeof ACT_JOB_STATUSES];
|
|
20
|
-
}>(options?: WaitForFinishOptions): Promise<R>;
|
|
21
|
+
}>(schema: z.ZodType, options?: WaitForFinishOptions): Promise<R>;
|
|
21
22
|
}
|
|
22
23
|
export interface WaitForFinishOptions {
|
|
23
24
|
waitSecs?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ACT_JOB_TERMINAL_STATUSES } from '@apify/consts';
|
|
2
|
-
import { catchNotFoundOrThrow,
|
|
2
|
+
import { 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,7 +15,7 @@ export const DEFAULT_TIMEOUT_MILLIS = 360 * 1000; // 6 minutes
|
|
|
15
15
|
* @private
|
|
16
16
|
*/
|
|
17
17
|
export class ResourceClient extends ApiClient {
|
|
18
|
-
async _get(options = {}, timeoutMillis) {
|
|
18
|
+
async _get(schema, options = {}, timeoutMillis) {
|
|
19
19
|
const requestOpts = {
|
|
20
20
|
url: this._url(),
|
|
21
21
|
method: 'GET',
|
|
@@ -24,14 +24,14 @@ export class ResourceClient extends ApiClient {
|
|
|
24
24
|
};
|
|
25
25
|
try {
|
|
26
26
|
const response = await this.httpClient.call(requestOpts);
|
|
27
|
-
return
|
|
27
|
+
return parseResponse(response, schema);
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
30
30
|
catchNotFoundOrThrow(err);
|
|
31
31
|
}
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
|
-
async _update(newFields, timeoutMillis) {
|
|
34
|
+
async _update(schema, newFields, timeoutMillis) {
|
|
35
35
|
const response = await this.httpClient.call({
|
|
36
36
|
url: this._url(),
|
|
37
37
|
method: 'PUT',
|
|
@@ -39,7 +39,7 @@ export class ResourceClient extends ApiClient {
|
|
|
39
39
|
data: newFields,
|
|
40
40
|
timeout: timeoutMillis,
|
|
41
41
|
});
|
|
42
|
-
return
|
|
42
|
+
return parseResponse(response, schema);
|
|
43
43
|
}
|
|
44
44
|
async _delete(timeoutMillis) {
|
|
45
45
|
try {
|
|
@@ -58,7 +58,7 @@ export class ResourceClient extends ApiClient {
|
|
|
58
58
|
* This function is used in Build and Run endpoints so it's kept
|
|
59
59
|
* here to stay DRY.
|
|
60
60
|
*/
|
|
61
|
-
async _waitForFinish(options = {}) {
|
|
61
|
+
async _waitForFinish(schema, options = {}) {
|
|
62
62
|
const { waitSecs = MAX_WAIT_FOR_FINISH } = options;
|
|
63
63
|
const waitMillis = waitSecs * 1000;
|
|
64
64
|
let job;
|
|
@@ -81,7 +81,7 @@ export class ResourceClient extends ApiClient {
|
|
|
81
81
|
};
|
|
82
82
|
try {
|
|
83
83
|
const response = await this.httpClient.call(requestOpts);
|
|
84
|
-
job =
|
|
84
|
+
job = parseResponse(response, schema);
|
|
85
85
|
}
|
|
86
86
|
catch (err) {
|
|
87
87
|
catchNotFoundOrThrow(err);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
1
2
|
import type { PaginatedResponse, PaginationOptions } from '../utils.js';
|
|
2
3
|
import { ApiClient } from './api_client.js';
|
|
3
4
|
/**
|
|
@@ -8,11 +9,11 @@ export declare class ResourceCollectionClient extends ApiClient {
|
|
|
8
9
|
/**
|
|
9
10
|
* @private
|
|
10
11
|
*/
|
|
11
|
-
protected _list<T, R>(options?: T): Promise<R>;
|
|
12
|
+
protected _list<T, R>(schema: z.ZodType, options?: T): Promise<R>;
|
|
12
13
|
/**
|
|
13
14
|
* Returns async iterator to iterate through all items and Promise that can be awaited to get first page of results.
|
|
14
15
|
*/
|
|
15
|
-
protected _listPaginated<T extends PaginationOptions, Data, R extends PaginatedResponse<Data>>(options?: T): AsyncIterable<Data> & Promise<R>;
|
|
16
|
-
protected _create<D, R>(resource: D): Promise<R>;
|
|
17
|
-
protected _getOrCreate<D, R>(name?: string, resource?: D): Promise<R>;
|
|
16
|
+
protected _listPaginated<T extends PaginationOptions, Data, R extends PaginatedResponse<Data>>(schema: z.ZodType, options?: T): AsyncIterable<Data> & Promise<R>;
|
|
17
|
+
protected _create<D, R>(schema: z.ZodType, resource: D): Promise<R>;
|
|
18
|
+
protected _getOrCreate<D, R>(schema: z.ZodType, name?: string, resource?: D): Promise<R>;
|
|
18
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseResponse } from '../utils.js';
|
|
2
2
|
import { ApiClient } from './api_client.js';
|
|
3
3
|
/**
|
|
4
4
|
* Resource collection client.
|
|
@@ -8,36 +8,36 @@ export class ResourceCollectionClient extends ApiClient {
|
|
|
8
8
|
/**
|
|
9
9
|
* @private
|
|
10
10
|
*/
|
|
11
|
-
async _list(options = {}) {
|
|
11
|
+
async _list(schema, options = {}) {
|
|
12
12
|
const response = await this.httpClient.call({
|
|
13
13
|
url: this._url(),
|
|
14
14
|
method: 'GET',
|
|
15
15
|
params: this._params(options),
|
|
16
16
|
});
|
|
17
|
-
return
|
|
17
|
+
return parseResponse(response, schema);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Returns async iterator to iterate through all items and Promise that can be awaited to get first page of results.
|
|
21
21
|
*/
|
|
22
|
-
_listPaginated(options = {}) {
|
|
23
|
-
return this._listPaginatedFromCallback((this._list
|
|
22
|
+
_listPaginated(schema, options = {}) {
|
|
23
|
+
return this._listPaginatedFromCallback(async (listOptions) => this._list(schema, listOptions), options);
|
|
24
24
|
}
|
|
25
|
-
async _create(resource) {
|
|
25
|
+
async _create(schema, resource) {
|
|
26
26
|
const response = await this.httpClient.call({
|
|
27
27
|
url: this._url(),
|
|
28
28
|
method: 'POST',
|
|
29
29
|
params: this._params(),
|
|
30
30
|
data: resource,
|
|
31
31
|
});
|
|
32
|
-
return
|
|
32
|
+
return parseResponse(response, schema);
|
|
33
33
|
}
|
|
34
|
-
async _getOrCreate(name, resource) {
|
|
34
|
+
async _getOrCreate(schema, name, resource) {
|
|
35
35
|
const response = await this.httpClient.call({
|
|
36
36
|
url: this._url(),
|
|
37
37
|
method: 'POST',
|
|
38
38
|
params: this._params({ name }),
|
|
39
39
|
data: resource,
|
|
40
40
|
});
|
|
41
|
-
return
|
|
41
|
+
return parseResponse(response, schema);
|
|
42
42
|
}
|
|
43
43
|
}
|