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
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
@@ -59,9 +59,9 @@ export interface DatasetSpecGaps {
59
59
  }
60
60
  export interface DatasetRePointed {
61
61
  stats?: DatasetStats;
62
+ generalAccess?: STORAGE_GENERAL_ACCESS | null;
62
63
  }
63
64
  export interface DatasetSpecNarrowings {
64
- generalAccess?: STORAGE_GENERAL_ACCESS | null;
65
65
  consoleUrl?: string;
66
66
  }
67
67
  /**
@@ -145,8 +145,6 @@ export interface KeyValueStoreSpecGaps {
145
145
  }
146
146
  export interface KeyValueStoreRePointed {
147
147
  stats?: KeyValueStoreStats;
148
- }
149
- export interface KeyValueStoreSpecNarrowings {
150
148
  generalAccess?: STORAGE_GENERAL_ACCESS | null;
151
149
  }
152
150
  /**
@@ -155,7 +153,7 @@ export interface KeyValueStoreSpecNarrowings {
155
153
  * Key-value stores are used to store arbitrary data records or files. Each record is identified
156
154
  * by a unique key and can contain any data - JSON objects, strings, binary files, etc.
157
155
  */
158
- export interface KeyValueStore extends Omit<Schemas['KeyValueStore'], keyof KeyValueStoreRePointed | keyof KeyValueStoreSpecNarrowings>, KeyValueStoreRePointed, KeyValueStoreSpecNarrowings, KeyValueStoreSpecGaps {
156
+ export interface KeyValueStore extends Omit<Schemas['KeyValueStore'], keyof KeyValueStoreRePointed>, KeyValueStoreRePointed, KeyValueStoreSpecGaps {
159
157
  }
160
158
  /** Statistics about Key-Value Store usage and storage. */
161
159
  export interface KeyValueStoreStats extends GeneratedKeyValueStoreStats {
@@ -310,11 +308,7 @@ export interface ActorDefinitionSpecGaps {
310
308
  */
311
309
  output?: object | null;
312
310
  }
313
- export interface ActorDefinitionSpecNarrowings {
314
- readme?: string | null;
315
- input?: object | null;
316
- changelog?: string | null;
317
- }
311
+ type GeneratedActorDefinition = Schemas['ActorDefinition'];
318
312
  /**
319
313
  * Actor definition from the `.actor/actor.json` file.
320
314
  *
@@ -322,7 +316,7 @@ export interface ActorDefinitionSpecNarrowings {
322
316
  * @see https://docs.apify.com/platform/actors/development/actor-definition/actor-json
323
317
  * @since Added in 2.11.0
324
318
  */
325
- export interface ActorDefinition extends Omit<Schemas['ActorDefinition'], keyof ActorDefinitionSpecNarrowings>, ActorDefinitionSpecNarrowings, ActorDefinitionSpecGaps {
319
+ export interface ActorDefinition extends GeneratedActorDefinition, ActorDefinitionSpecGaps {
326
320
  }
327
321
  export interface ActorChargeEventRePointed {
328
322
  eventTieredPricingUsd?: TieredPricingPerEvent;
@@ -571,6 +565,7 @@ export interface ActorRun extends Omit<Schemas['Run'], keyof ActorRunRePointed |
571
565
  }
572
566
  type GeneratedTaskStats = Schemas['TaskStats'];
573
567
  type GeneratedTaskOptions = Schemas['TaskOptions'];
568
+ type GeneratedTaskPublicConfig = Schemas['TaskPublicConfig'];
574
569
  type GeneratedCurrentPricingInfo = Schemas['CurrentPricingInfo'];
575
570
  /** Statistics about Actor task usage. */
576
571
  export interface TaskStats extends GeneratedTaskStats {
@@ -586,14 +581,7 @@ export interface TaskOptions extends GeneratedTaskOptions {
586
581
  * {@apilink TaskClient.unpublish} to change the publication state.
587
582
  * @since Added in 2.25.0
588
583
  */
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;
584
+ export interface TaskPublicConfig extends GeneratedTaskPublicConfig {
597
585
  }
598
586
  /**
599
587
  * Fields the API returns on a task that the OpenAPI spec does not describe yet.
@@ -602,23 +590,12 @@ export interface TaskPublicConfig {
602
590
  */
603
591
  export interface TaskSpecGaps {
604
592
  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
593
  }
616
594
  export interface TaskRePointed {
617
595
  stats?: TaskStats | null;
618
596
  options?: TaskOptions | null;
619
597
  actorStandby?: ActorStandby | null;
620
- }
621
- export interface TaskSpecNarrowings {
598
+ publicConfig?: TaskPublicConfig | null;
622
599
  input?: Dictionary | Dictionary[] | null;
623
600
  }
624
601
  /**
@@ -627,7 +604,7 @@ export interface TaskSpecNarrowings {
627
604
  * Tasks are saved Actor configurations with input and settings that can be executed
628
605
  * repeatedly without having to specify the full input each time.
629
606
  */
630
- export interface Task extends Omit<Schemas['Task'], keyof TaskRePointed | keyof TaskSpecNarrowings>, TaskRePointed, TaskSpecNarrowings, TaskSpecGaps {
607
+ export interface Task extends Omit<Schemas['Task'], keyof TaskRePointed>, TaskRePointed, TaskSpecGaps {
631
608
  }
632
609
  export interface TaskListRePointed {
633
610
  stats?: TaskStats | null;
@@ -771,6 +748,10 @@ export interface ScheduleActionRunActorTask extends Omit<Schemas['ScheduleAction
771
748
  }
772
749
  /** Union type representing all possible scheduled actions. */
773
750
  export type ScheduleAction = ScheduleActionRunActor | ScheduleActionRunActorTask;
751
+ type GeneratedScheduleInvoked = Schemas['ScheduleInvoked'];
752
+ /** One entry of a schedule's log: an invocation of the schedule and how it went. */
753
+ export interface ScheduleInvoked extends GeneratedScheduleInvoked {
754
+ }
774
755
  export interface ScheduleRePointed {
775
756
  actions: ScheduleAction[];
776
757
  }
@@ -850,11 +831,8 @@ export interface UserPlan extends Omit<Schemas['Plan'], keyof UserPlanRePointed>
850
831
  export interface UserRePointed {
851
832
  profile?: UserProfile;
852
833
  proxy?: UserProxy;
853
- }
854
- export interface UserSpecNarrowings {
855
834
  plan?: UserPlan;
856
835
  effectivePlatformFeatures?: EffectivePlatformFeatures;
857
- isPaying?: boolean;
858
836
  }
859
837
  /**
860
838
  * A user account.
@@ -862,7 +840,7 @@ export interface UserSpecNarrowings {
862
840
  * The private fields are only populated for `GET /v2/users/me`, which needs a token; the public
863
841
  * endpoint returns the username and profile alone.
864
842
  */
865
- export interface User extends Omit<Schemas['UserPrivateInfo'], keyof UserRePointed | keyof UserSpecNarrowings>, UserRePointed, UserSpecNarrowings {
843
+ export interface User extends Omit<Schemas['UserPrivateInfo'], keyof UserRePointed>, UserRePointed {
866
844
  }
867
845
  /**
868
846
  * The start and end of a billing cycle.
@@ -897,11 +875,8 @@ export interface ServiceUsage {
897
875
  export interface DailyServiceUsageRePointed {
898
876
  serviceUsage: ServiceUsage;
899
877
  }
900
- export interface DailyServiceUsageClientConversions {
901
- date: Date;
902
- }
903
878
  /** 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 | keyof DailyServiceUsageClientConversions>, DailyServiceUsageRePointed, DailyServiceUsageClientConversions {
879
+ export interface DailyServiceUsage extends Omit<Schemas['DailyServiceUsages'], keyof DailyServiceUsageRePointed>, DailyServiceUsageRePointed {
905
880
  }
906
881
  export interface MonthlyUsageRePointed {
907
882
  usageCycle: UsageCycle;
@@ -966,9 +941,9 @@ export interface RequestQueueSpecGaps {
966
941
  }
967
942
  export interface RequestQueueRePointed {
968
943
  stats?: RequestQueueStats;
944
+ generalAccess?: STORAGE_GENERAL_ACCESS | null;
969
945
  }
970
946
  export interface RequestQueueSpecNarrowings {
971
- generalAccess?: STORAGE_GENERAL_ACCESS | null;
972
947
  consoleUrl?: string;
973
948
  }
974
949
  /**
@@ -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 { anyObjectSchema, cast, parseArgument, parseDateFields, pluckData, stringifyWebhooksToBase64, } from '../utils.js';
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 cast(parseDateFields(pluckData(response.data)));
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 cast(parseDateFields(pluckData(response.data)));
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 } = pluckData(response.data);
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 { cast, parseArgument, parseDateFields, pluckData } from '../utils.js';
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 cast(parseDateFields(pluckData(response.data)));
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 { anyObjectSchema, applyQueryParamsToUrl, cast, catchNotFoundOrThrow, isNonArrayObject, paginationOptionsShape, parseArgument, pluckData, } from '../utils.js';
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 cast(pluckData(response.data));
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 { anyObjectSchema, applyQueryParamsToUrl, cast, catchNotFoundOrThrow, isBuffer, isNode, isStream, parseArgument, parseDateFields, pluckData, } from '../utils.js';
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 cast(parseDateFields(pluckData(response.data)));
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
  }