apify-client 3.0.0-beta.4 → 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.
- package/README.md +3 -1
- package/dist/apify_api_error.d.ts +59 -3
- package/dist/apify_api_error.js +66 -2
- 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 +16 -14
- 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/http_client.js +1 -1
- 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 +21 -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 +12 -2
- package/dist/utils.js +26 -9
- package/package.json +3 -3
package/dist/http_client.js
CHANGED
|
@@ -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 =
|
|
170
|
+
const apiError = ApifyApiError.fromResponse(response, attempt);
|
|
171
171
|
if (this._isStatusCodeRetryable(response.status)) {
|
|
172
172
|
if (requestIsStream) {
|
|
173
173
|
this._informAboutStreamNoRetry();
|
package/dist/index.d.ts
CHANGED
|
@@ -28,5 +28,6 @@ export * from './resource_clients/webhook_dispatch.js';
|
|
|
28
28
|
export * from './resource_clients/webhook_dispatch_collection.js';
|
|
29
29
|
export * from './apify_api_error.js';
|
|
30
30
|
export { ArgumentValidationError } from '@apify/validations';
|
|
31
|
+
export * from './response_validation_error.js';
|
|
31
32
|
export { InvalidResponseBodyError } from './interceptors.js';
|
|
32
33
|
export type { PaginatedList, Dictionary } from './utils.js';
|
package/dist/index.js
CHANGED
|
@@ -28,4 +28,5 @@ export * from './resource_clients/webhook_dispatch.js';
|
|
|
28
28
|
export * from './resource_clients/webhook_dispatch_collection.js';
|
|
29
29
|
export * from './apify_api_error.js';
|
|
30
30
|
export { ArgumentValidationError } from '@apify/validations';
|
|
31
|
+
export * from './response_validation_error.js';
|
|
31
32
|
export { InvalidResponseBodyError } from './interceptors.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps the construction of a zod schema so it runs on the first call and only once.
|
|
3
|
+
*
|
|
4
|
+
* The generated response schemas are exported this way: a couple of hundred `z.looseObject()` calls at import time
|
|
5
|
+
* would cost more than importing zod itself, so each schema is built by the first response validated against it and
|
|
6
|
+
* kept for the rest of the process.
|
|
7
|
+
*/
|
|
8
|
+
export declare function lazySchema<T>(build: () => T): () => T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps the construction of a zod schema so it runs on the first call and only once.
|
|
3
|
+
*
|
|
4
|
+
* The generated response schemas are exported this way: a couple of hundred `z.looseObject()` calls at import time
|
|
5
|
+
* would cost more than importing zod itself, so each schema is built by the first response validated against it and
|
|
6
|
+
* kept for the rest of the process.
|
|
7
|
+
*/
|
|
8
|
+
export function lazySchema(build) {
|
|
9
|
+
let schema;
|
|
10
|
+
return () => (schema ??= build());
|
|
11
|
+
}
|
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
|
*
|
|
@@ -59,9 +65,9 @@ export interface DatasetSpecGaps {
|
|
|
59
65
|
}
|
|
60
66
|
export interface DatasetRePointed {
|
|
61
67
|
stats?: DatasetStats;
|
|
68
|
+
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
62
69
|
}
|
|
63
70
|
export interface DatasetSpecNarrowings {
|
|
64
|
-
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
65
71
|
consoleUrl?: string;
|
|
66
72
|
}
|
|
67
73
|
/**
|
|
@@ -145,8 +151,6 @@ export interface KeyValueStoreSpecGaps {
|
|
|
145
151
|
}
|
|
146
152
|
export interface KeyValueStoreRePointed {
|
|
147
153
|
stats?: KeyValueStoreStats;
|
|
148
|
-
}
|
|
149
|
-
export interface KeyValueStoreSpecNarrowings {
|
|
150
154
|
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
151
155
|
}
|
|
152
156
|
/**
|
|
@@ -155,7 +159,7 @@ export interface KeyValueStoreSpecNarrowings {
|
|
|
155
159
|
* Key-value stores are used to store arbitrary data records or files. Each record is identified
|
|
156
160
|
* by a unique key and can contain any data - JSON objects, strings, binary files, etc.
|
|
157
161
|
*/
|
|
158
|
-
export interface KeyValueStore extends Omit<Schemas['KeyValueStore'], keyof KeyValueStoreRePointed
|
|
162
|
+
export interface KeyValueStore extends Omit<Schemas['KeyValueStore'], keyof KeyValueStoreRePointed>, KeyValueStoreRePointed, KeyValueStoreSpecGaps {
|
|
159
163
|
}
|
|
160
164
|
/** Statistics about Key-Value Store usage and storage. */
|
|
161
165
|
export interface KeyValueStoreStats extends GeneratedKeyValueStoreStats {
|
|
@@ -310,11 +314,7 @@ export interface ActorDefinitionSpecGaps {
|
|
|
310
314
|
*/
|
|
311
315
|
output?: object | null;
|
|
312
316
|
}
|
|
313
|
-
|
|
314
|
-
readme?: string | null;
|
|
315
|
-
input?: object | null;
|
|
316
|
-
changelog?: string | null;
|
|
317
|
-
}
|
|
317
|
+
type GeneratedActorDefinition = Schemas['ActorDefinition'];
|
|
318
318
|
/**
|
|
319
319
|
* Actor definition from the `.actor/actor.json` file.
|
|
320
320
|
*
|
|
@@ -322,7 +322,7 @@ export interface ActorDefinitionSpecNarrowings {
|
|
|
322
322
|
* @see https://docs.apify.com/platform/actors/development/actor-definition/actor-json
|
|
323
323
|
* @since Added in 2.11.0
|
|
324
324
|
*/
|
|
325
|
-
export interface ActorDefinition extends
|
|
325
|
+
export interface ActorDefinition extends GeneratedActorDefinition, ActorDefinitionSpecGaps {
|
|
326
326
|
}
|
|
327
327
|
export interface ActorChargeEventRePointed {
|
|
328
328
|
eventTieredPricingUsd?: TieredPricingPerEvent;
|
|
@@ -571,6 +571,7 @@ export interface ActorRun extends Omit<Schemas['Run'], keyof ActorRunRePointed |
|
|
|
571
571
|
}
|
|
572
572
|
type GeneratedTaskStats = Schemas['TaskStats'];
|
|
573
573
|
type GeneratedTaskOptions = Schemas['TaskOptions'];
|
|
574
|
+
type GeneratedTaskPublicConfig = Schemas['TaskPublicConfig'];
|
|
574
575
|
type GeneratedCurrentPricingInfo = Schemas['CurrentPricingInfo'];
|
|
575
576
|
/** Statistics about Actor task usage. */
|
|
576
577
|
export interface TaskStats extends GeneratedTaskStats {
|
|
@@ -586,14 +587,7 @@ export interface TaskOptions extends GeneratedTaskOptions {
|
|
|
586
587
|
* {@apilink TaskClient.unpublish} to change the publication state.
|
|
587
588
|
* @since Added in 2.25.0
|
|
588
589
|
*/
|
|
589
|
-
export interface TaskPublicConfig {
|
|
590
|
-
publishedAt: Date | null;
|
|
591
|
-
seoTitle?: string | null;
|
|
592
|
-
seoDescription?: string | null;
|
|
593
|
-
categorization?: string | null;
|
|
594
|
-
inputSchemaFields?: string[] | null;
|
|
595
|
-
datasetName?: string | null;
|
|
596
|
-
datasetView?: string | null;
|
|
590
|
+
export interface TaskPublicConfig extends GeneratedTaskPublicConfig {
|
|
597
591
|
}
|
|
598
592
|
/**
|
|
599
593
|
* Fields the API returns on a task that the OpenAPI spec does not describe yet.
|
|
@@ -602,23 +596,12 @@ export interface TaskPublicConfig {
|
|
|
602
596
|
*/
|
|
603
597
|
export interface TaskSpecGaps {
|
|
604
598
|
description?: string;
|
|
605
|
-
/**
|
|
606
|
-
* Whether the task is published on its public landing page. Derived from
|
|
607
|
-
* `publicConfig.publishedAt` -- set it on update to publish or unpublish the task.
|
|
608
|
-
* @since Added in 2.25.0
|
|
609
|
-
*/
|
|
610
|
-
isPublic?: boolean;
|
|
611
|
-
/**
|
|
612
|
-
* @since Added in 2.25.0
|
|
613
|
-
*/
|
|
614
|
-
publicConfig?: TaskPublicConfig | null;
|
|
615
599
|
}
|
|
616
600
|
export interface TaskRePointed {
|
|
617
601
|
stats?: TaskStats | null;
|
|
618
602
|
options?: TaskOptions | null;
|
|
619
603
|
actorStandby?: ActorStandby | null;
|
|
620
|
-
|
|
621
|
-
export interface TaskSpecNarrowings {
|
|
604
|
+
publicConfig?: TaskPublicConfig | null;
|
|
622
605
|
input?: Dictionary | Dictionary[] | null;
|
|
623
606
|
}
|
|
624
607
|
/**
|
|
@@ -627,7 +610,7 @@ export interface TaskSpecNarrowings {
|
|
|
627
610
|
* Tasks are saved Actor configurations with input and settings that can be executed
|
|
628
611
|
* repeatedly without having to specify the full input each time.
|
|
629
612
|
*/
|
|
630
|
-
export interface Task extends Omit<Schemas['Task'], keyof TaskRePointed
|
|
613
|
+
export interface Task extends Omit<Schemas['Task'], keyof TaskRePointed>, TaskRePointed, TaskSpecGaps {
|
|
631
614
|
}
|
|
632
615
|
export interface TaskListRePointed {
|
|
633
616
|
stats?: TaskStats | null;
|
|
@@ -771,6 +754,10 @@ export interface ScheduleActionRunActorTask extends Omit<Schemas['ScheduleAction
|
|
|
771
754
|
}
|
|
772
755
|
/** Union type representing all possible scheduled actions. */
|
|
773
756
|
export type ScheduleAction = ScheduleActionRunActor | ScheduleActionRunActorTask;
|
|
757
|
+
type GeneratedScheduleInvoked = Schemas['ScheduleInvoked'];
|
|
758
|
+
/** One entry of a schedule's log: an invocation of the schedule and how it went. */
|
|
759
|
+
export interface ScheduleInvoked extends GeneratedScheduleInvoked {
|
|
760
|
+
}
|
|
774
761
|
export interface ScheduleRePointed {
|
|
775
762
|
actions: ScheduleAction[];
|
|
776
763
|
}
|
|
@@ -850,11 +837,8 @@ export interface UserPlan extends Omit<Schemas['Plan'], keyof UserPlanRePointed>
|
|
|
850
837
|
export interface UserRePointed {
|
|
851
838
|
profile?: UserProfile;
|
|
852
839
|
proxy?: UserProxy;
|
|
853
|
-
}
|
|
854
|
-
export interface UserSpecNarrowings {
|
|
855
840
|
plan?: UserPlan;
|
|
856
841
|
effectivePlatformFeatures?: EffectivePlatformFeatures;
|
|
857
|
-
isPaying?: boolean;
|
|
858
842
|
}
|
|
859
843
|
/**
|
|
860
844
|
* A user account.
|
|
@@ -862,7 +846,7 @@ export interface UserSpecNarrowings {
|
|
|
862
846
|
* The private fields are only populated for `GET /v2/users/me`, which needs a token; the public
|
|
863
847
|
* endpoint returns the username and profile alone.
|
|
864
848
|
*/
|
|
865
|
-
export interface User extends Omit<Schemas['UserPrivateInfo'], keyof UserRePointed
|
|
849
|
+
export interface User extends Omit<Schemas['UserPrivateInfo'], keyof UserRePointed>, UserRePointed {
|
|
866
850
|
}
|
|
867
851
|
/**
|
|
868
852
|
* The start and end of a billing cycle.
|
|
@@ -897,11 +881,8 @@ export interface ServiceUsage {
|
|
|
897
881
|
export interface DailyServiceUsageRePointed {
|
|
898
882
|
serviceUsage: ServiceUsage;
|
|
899
883
|
}
|
|
900
|
-
export interface DailyServiceUsageClientConversions {
|
|
901
|
-
date: Date;
|
|
902
|
-
}
|
|
903
884
|
/** A single day's usage within a monthly cycle. The spec names this schema `DailyServiceUsages`. */
|
|
904
|
-
export interface DailyServiceUsage extends Omit<Schemas['DailyServiceUsages'], keyof DailyServiceUsageRePointed
|
|
885
|
+
export interface DailyServiceUsage extends Omit<Schemas['DailyServiceUsages'], keyof DailyServiceUsageRePointed>, DailyServiceUsageRePointed {
|
|
905
886
|
}
|
|
906
887
|
export interface MonthlyUsageRePointed {
|
|
907
888
|
usageCycle: UsageCycle;
|
|
@@ -966,9 +947,9 @@ export interface RequestQueueSpecGaps {
|
|
|
966
947
|
}
|
|
967
948
|
export interface RequestQueueRePointed {
|
|
968
949
|
stats?: RequestQueueStats;
|
|
950
|
+
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
969
951
|
}
|
|
970
952
|
export interface RequestQueueSpecNarrowings {
|
|
971
|
-
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
972
953
|
consoleUrl?: string;
|
|
973
954
|
}
|
|
974
955
|
/**
|
|
@@ -2,7 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
|
|
3
3
|
import { Log } from '@apify/log';
|
|
4
4
|
import { ResourceClient } from '../base/resource_client.js';
|
|
5
|
-
import
|
|
5
|
+
import * as schemas from '../schemas.js';
|
|
6
|
+
import { anyObjectSchema, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
|
|
6
7
|
import { ActorVersionClient } from './actor_version.js';
|
|
7
8
|
import { ActorVersionCollectionClient } from './actor_version_collection.js';
|
|
8
9
|
import { BuildClient } from './build.js';
|
|
@@ -87,7 +88,7 @@ export class ActorClient extends ResourceClient {
|
|
|
87
88
|
* @see https://docs.apify.com/api/v2/act-get
|
|
88
89
|
*/
|
|
89
90
|
async get() {
|
|
90
|
-
return this._get();
|
|
91
|
+
return this._get(schemas.Actor());
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
93
94
|
* Updates the Actor with specified fields.
|
|
@@ -98,7 +99,7 @@ export class ActorClient extends ResourceClient {
|
|
|
98
99
|
*/
|
|
99
100
|
async update(newFields) {
|
|
100
101
|
parseArgument(newFields, anyObjectSchema);
|
|
101
|
-
return this._update(newFields);
|
|
102
|
+
return this._update(schemas.Actor(), newFields);
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
105
|
* Deletes the Actor.
|
|
@@ -173,7 +174,7 @@ export class ActorClient extends ResourceClient {
|
|
|
173
174
|
};
|
|
174
175
|
}
|
|
175
176
|
const response = await this.httpClient.call(request);
|
|
176
|
-
return
|
|
177
|
+
return parseResponse(response, schemas.Run());
|
|
177
178
|
}
|
|
178
179
|
/**
|
|
179
180
|
* Starts the Actor and waits for it to finish before returning the Run object.
|
|
@@ -323,7 +324,7 @@ export class ActorClient extends ResourceClient {
|
|
|
323
324
|
...parsed,
|
|
324
325
|
}),
|
|
325
326
|
});
|
|
326
|
-
return
|
|
327
|
+
return parseResponse(response, schemas.Build());
|
|
327
328
|
}
|
|
328
329
|
/**
|
|
329
330
|
* Returns a client for the default build of this Actor.
|
|
@@ -356,7 +357,7 @@ export class ActorClient extends ResourceClient {
|
|
|
356
357
|
method: 'GET',
|
|
357
358
|
params: this._params(options),
|
|
358
359
|
});
|
|
359
|
-
const { id } =
|
|
360
|
+
const { id } = parseResponse(response, schemas.Build());
|
|
360
361
|
return new BuildClient({
|
|
361
362
|
baseUrl: this.apifyClient.baseUrl,
|
|
362
363
|
publicBaseUrl: this.apifyClient.publicBaseUrl,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
3
4
|
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
4
5
|
const actorCreateSchema = anyObjectSchema.optional();
|
|
5
6
|
/**
|
|
@@ -57,7 +58,7 @@ export class ActorCollectionClient extends ResourceCollectionClient {
|
|
|
57
58
|
*/
|
|
58
59
|
list(options = {}) {
|
|
59
60
|
const parsed = parseArgument(options, listOptionsSchema, 'ActorCollectionListOptions');
|
|
60
|
-
return this._listPaginated(parsed);
|
|
61
|
+
return this._listPaginated(schemas.ListOfActors(), parsed);
|
|
61
62
|
}
|
|
62
63
|
/**
|
|
63
64
|
* Creates a new Actor.
|
|
@@ -68,7 +69,7 @@ export class ActorCollectionClient extends ResourceCollectionClient {
|
|
|
68
69
|
*/
|
|
69
70
|
async create(actor) {
|
|
70
71
|
parseArgument(actor, actorCreateSchema);
|
|
71
|
-
return this._create(actor);
|
|
72
|
+
return this._create(schemas.Actor(), actor);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourceClient } from '../base/resource_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
2
3
|
import { anyObjectSchema, parseArgument } from '../utils.js';
|
|
3
4
|
/**
|
|
4
5
|
* Client for managing a specific Actor environment variable.
|
|
@@ -40,7 +41,7 @@ export class ActorEnvVarClient extends ResourceClient {
|
|
|
40
41
|
* @see https://docs.apify.com/api/v2/act-version-env-var-get
|
|
41
42
|
*/
|
|
42
43
|
async get() {
|
|
43
|
-
return this._get();
|
|
44
|
+
return this._get(schemas.EnvVar());
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Updates the environment variable.
|
|
@@ -51,7 +52,7 @@ export class ActorEnvVarClient extends ResourceClient {
|
|
|
51
52
|
*/
|
|
52
53
|
async update(actorEnvVar) {
|
|
53
54
|
parseArgument(actorEnvVar, anyObjectSchema);
|
|
54
|
-
return this._update(actorEnvVar);
|
|
55
|
+
return this._update(schemas.EnvVar(), actorEnvVar);
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Deletes the environment variable.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
2
3
|
import { anyObjectSchema, parseArgument } from '../utils.js';
|
|
3
4
|
const actorEnvVarSchema = anyObjectSchema.optional();
|
|
4
5
|
/**
|
|
@@ -58,7 +59,7 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
|
|
|
58
59
|
* @see https://docs.apify.com/api/v2/act-version-env-vars-get
|
|
59
60
|
*/
|
|
60
61
|
list(_options = {}) {
|
|
61
|
-
return this._listPaginated();
|
|
62
|
+
return this._listPaginated(schemas.ListOfEnvVars());
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
65
|
* Creates a new environment variable for this Actor version.
|
|
@@ -69,6 +70,6 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
|
|
|
69
70
|
*/
|
|
70
71
|
async create(actorEnvVar) {
|
|
71
72
|
parseArgument(actorEnvVar, actorEnvVarSchema);
|
|
72
|
-
return this._create(actorEnvVar);
|
|
73
|
+
return this._create(schemas.EnvVar(), actorEnvVar);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
3
4
|
import { anyObjectSchema, parseArgument } from '../utils.js';
|
|
4
5
|
import { ActorEnvVarClient } from './actor_env_var.js';
|
|
5
6
|
import { ActorEnvVarCollectionClient } from './actor_env_var_collection.js';
|
|
@@ -43,7 +44,7 @@ export class ActorVersionClient extends ResourceClient {
|
|
|
43
44
|
* @see https://docs.apify.com/api/v2/act-version-get
|
|
44
45
|
*/
|
|
45
46
|
async get() {
|
|
46
|
-
return this._get();
|
|
47
|
+
return this._get(schemas.Version());
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Updates the Actor version with the specified fields.
|
|
@@ -54,7 +55,7 @@ export class ActorVersionClient extends ResourceClient {
|
|
|
54
55
|
*/
|
|
55
56
|
async update(newFields) {
|
|
56
57
|
parseArgument(newFields, anyObjectSchema);
|
|
57
|
-
return this._update(newFields);
|
|
58
|
+
return this._update(schemas.Version(), newFields);
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Deletes the Actor version.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
2
3
|
import { anyObjectSchema, parseArgument } from '../utils.js';
|
|
3
4
|
const actorVersionSchema = anyObjectSchema.optional();
|
|
4
5
|
/**
|
|
@@ -55,7 +56,7 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
|
|
|
55
56
|
* @see https://docs.apify.com/api/v2/act-versions-get
|
|
56
57
|
*/
|
|
57
58
|
list(_options = {}) {
|
|
58
|
-
return this._listPaginated();
|
|
59
|
+
return this._listPaginated(schemas.ListOfVersions());
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
62
|
* Creates a new Actor version.
|
|
@@ -66,6 +67,6 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
|
|
|
66
67
|
*/
|
|
67
68
|
async create(actorVersion) {
|
|
68
69
|
parseArgument(actorVersion, actorVersionSchema);
|
|
69
|
-
return this._create(actorVersion);
|
|
70
|
+
return this._create(schemas.Version(), actorVersion);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
-
import
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { parseArgument, parseResponse } from '../utils.js';
|
|
4
5
|
import { LogClient } from './log.js';
|
|
5
6
|
const getOptionsSchema = z.strictObject({ waitForFinish: z.number().optional() });
|
|
6
7
|
const waitForFinishOptionsSchema = z.strictObject({ waitSecs: z.number().optional() });
|
|
@@ -57,7 +58,7 @@ export class BuildClient extends ResourceClient {
|
|
|
57
58
|
*/
|
|
58
59
|
async get(options = {}) {
|
|
59
60
|
const parsed = parseArgument(options, getOptionsSchema, 'BuildClientGetOptions');
|
|
60
|
-
return this._get(parsed);
|
|
61
|
+
return this._get(schemas.Build(), parsed);
|
|
61
62
|
}
|
|
62
63
|
/**
|
|
63
64
|
* Aborts the Actor build.
|
|
@@ -78,7 +79,7 @@ export class BuildClient extends ResourceClient {
|
|
|
78
79
|
method: 'POST',
|
|
79
80
|
params: this._params(),
|
|
80
81
|
});
|
|
81
|
-
return
|
|
82
|
+
return parseResponse(response, schemas.Build());
|
|
82
83
|
}
|
|
83
84
|
/**
|
|
84
85
|
* Deletes the Actor build.
|
|
@@ -136,7 +137,7 @@ export class BuildClient extends ResourceClient {
|
|
|
136
137
|
*/
|
|
137
138
|
async waitForFinish(options = {}) {
|
|
138
139
|
const parsed = parseArgument(options, waitForFinishOptionsSchema, 'BuildClientWaitForFinishOptions');
|
|
139
|
-
return this._waitForFinish(parsed);
|
|
140
|
+
return this._waitForFinish(schemas.Build(), parsed);
|
|
140
141
|
}
|
|
141
142
|
/**
|
|
142
143
|
* Returns a client for accessing the log of this Actor build.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
3
4
|
import { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
4
5
|
const listOptionsSchema = z.strictObject({
|
|
5
6
|
...paginationOptionsShape,
|
|
@@ -58,6 +59,6 @@ export class BuildCollectionClient extends ResourceCollectionClient {
|
|
|
58
59
|
*/
|
|
59
60
|
list(options = {}) {
|
|
60
61
|
const parsed = parseArgument(options, listOptionsSchema, 'BuildCollectionClientListOptions');
|
|
61
|
-
return this._listPaginated(parsed);
|
|
62
|
+
return this._listPaginated(schemas.ListOfBuilds(), parsed);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createStorageContentSignatureAsync } from '@apify/utilities';
|
|
3
3
|
import { DEFAULT_TIMEOUT_MILLIS, MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS, } from '../base/resource_client.js';
|
|
4
|
-
import
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
5
|
+
import { anyObjectSchema, applyQueryParamsToUrl, cast, catchNotFoundOrThrow, isNonArrayObject, paginationOptionsShape, parseArgument, parseResponse, } from '../utils.js';
|
|
5
6
|
// A predicate, not a `z.object()` arm, which would walk and copy every key of every pushed item.
|
|
6
7
|
const itemSchema = z.custom(isNonArrayObject, 'Expected an object');
|
|
7
8
|
const listItemsOptionsSchema = z.strictObject({
|
|
@@ -102,7 +103,7 @@ export class DatasetClient extends ResourceClient {
|
|
|
102
103
|
* @see https://docs.apify.com/api/v2/dataset-get
|
|
103
104
|
*/
|
|
104
105
|
async get() {
|
|
105
|
-
return this._get({}, SMALL_TIMEOUT_MILLIS);
|
|
106
|
+
return this._get(schemas.Dataset(), {}, SMALL_TIMEOUT_MILLIS);
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
109
|
* Updates the dataset with specified fields.
|
|
@@ -113,7 +114,7 @@ export class DatasetClient extends ResourceClient {
|
|
|
113
114
|
*/
|
|
114
115
|
async update(newFields) {
|
|
115
116
|
parseArgument(newFields, anyObjectSchema);
|
|
116
|
-
return this._update(newFields, SMALL_TIMEOUT_MILLIS);
|
|
117
|
+
return this._update(schemas.Dataset(), newFields, SMALL_TIMEOUT_MILLIS);
|
|
117
118
|
}
|
|
118
119
|
/**
|
|
119
120
|
* Deletes the dataset.
|
|
@@ -300,7 +301,7 @@ export class DatasetClient extends ResourceClient {
|
|
|
300
301
|
};
|
|
301
302
|
try {
|
|
302
303
|
const response = await this.httpClient.call(requestOpts);
|
|
303
|
-
return
|
|
304
|
+
return parseResponse(response, schemas.DatasetStatistics());
|
|
304
305
|
}
|
|
305
306
|
catch (err) {
|
|
306
307
|
catchNotFoundOrThrow(err);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
|
|
3
3
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
4
5
|
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
6
|
const listOptionsSchema = z.strictObject({
|
|
6
7
|
unnamed: z.boolean().optional(),
|
|
@@ -62,7 +63,7 @@ export class DatasetCollectionClient extends ResourceCollectionClient {
|
|
|
62
63
|
*/
|
|
63
64
|
list(options = {}) {
|
|
64
65
|
const parsed = parseArgument(options, listOptionsSchema, 'DatasetCollectionClientListOptions');
|
|
65
|
-
return this._listPaginated(parsed);
|
|
66
|
+
return this._listPaginated(schemas.ListOfDatasets(), parsed);
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
68
69
|
* Gets or creates a dataset with the specified name.
|
|
@@ -75,6 +76,6 @@ export class DatasetCollectionClient extends ResourceCollectionClient {
|
|
|
75
76
|
async getOrCreate(name, options) {
|
|
76
77
|
parseArgument(name, nameSchema);
|
|
77
78
|
parseArgument(options?.schema, schemaSchema); // TODO: Add schema validation
|
|
78
|
-
return this._getOrCreate(name, options);
|
|
79
|
+
return this._getOrCreate(schemas.Dataset(), name, options);
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -2,7 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import log from '@apify/log';
|
|
3
3
|
import { createHmacSignatureAsync, createStorageContentSignatureAsync } from '@apify/utilities';
|
|
4
4
|
import { DEFAULT_TIMEOUT_MILLIS, MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS, } from '../base/resource_client.js';
|
|
5
|
-
import
|
|
5
|
+
import * as schemas from '../schemas.js';
|
|
6
|
+
import { anyObjectSchema, applyQueryParamsToUrl, catchNotFoundOrThrow, isBuffer, isNode, isStream, parseArgument, parseResponse, } from '../utils.js';
|
|
6
7
|
const listKeysOptionsSchema = z.strictObject({
|
|
7
8
|
limit: z.number().min(0).optional(),
|
|
8
9
|
exclusiveStartKey: z.string().optional(),
|
|
@@ -88,7 +89,7 @@ export class KeyValueStoreClient extends ResourceClient {
|
|
|
88
89
|
* @see https://docs.apify.com/api/v2/key-value-store-get
|
|
89
90
|
*/
|
|
90
91
|
async get() {
|
|
91
|
-
return this._get({}, SMALL_TIMEOUT_MILLIS);
|
|
92
|
+
return this._get(schemas.KeyValueStore(), {}, SMALL_TIMEOUT_MILLIS);
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* Updates the key-value store with specified fields.
|
|
@@ -102,7 +103,7 @@ export class KeyValueStoreClient extends ResourceClient {
|
|
|
102
103
|
*/
|
|
103
104
|
async update(newFields) {
|
|
104
105
|
parseArgument(newFields, anyObjectSchema);
|
|
105
|
-
return this._update(newFields, DEFAULT_TIMEOUT_MILLIS);
|
|
106
|
+
return this._update(schemas.KeyValueStore(), newFields, DEFAULT_TIMEOUT_MILLIS);
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
109
|
* Deletes the key-value store.
|
|
@@ -156,7 +157,7 @@ export class KeyValueStoreClient extends ResourceClient {
|
|
|
156
157
|
params: this._params(kvsListOptions),
|
|
157
158
|
timeout: MEDIUM_TIMEOUT_MILLIS,
|
|
158
159
|
});
|
|
159
|
-
return
|
|
160
|
+
return parseResponse(response, schemas.ListOfKeys());
|
|
160
161
|
};
|
|
161
162
|
const paginatedListPromise = getPaginatedList(parsed);
|
|
162
163
|
async function* asyncGenerator() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
|
|
3
3
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
4
5
|
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
6
|
const listOptionsSchema = z.strictObject({
|
|
6
7
|
unnamed: z.boolean().optional(),
|
|
@@ -62,7 +63,7 @@ export class KeyValueStoreCollectionClient extends ResourceCollectionClient {
|
|
|
62
63
|
*/
|
|
63
64
|
list(options = {}) {
|
|
64
65
|
const parsed = parseArgument(options, listOptionsSchema, 'KeyValueStoreCollectionClientListOptions');
|
|
65
|
-
return this._listPaginated(parsed);
|
|
66
|
+
return this._listPaginated(schemas.ListOfKeyValueStores(), parsed);
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
68
69
|
* Gets or creates a key-value store with the specified name.
|
|
@@ -75,6 +76,6 @@ export class KeyValueStoreCollectionClient extends ResourceCollectionClient {
|
|
|
75
76
|
async getOrCreate(name, options) {
|
|
76
77
|
parseArgument(name, nameSchema);
|
|
77
78
|
parseArgument(options?.schema, schemaSchema); // TODO: Add schema validation
|
|
78
|
-
return this._getOrCreate(name, options);
|
|
79
|
+
return this._getOrCreate(schemas.KeyValueStore(), name, options);
|
|
79
80
|
}
|
|
80
81
|
}
|