apify-client 3.0.0-beta.1 → 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.
Files changed (94) hide show
  1. package/README.md +5 -3
  2. package/dist/apify_api_error.d.ts +59 -3
  3. package/dist/apify_api_error.js +71 -11
  4. package/dist/apify_client.d.ts +27 -27
  5. package/dist/apify_client.js +86 -91
  6. package/dist/base/api_client.d.ts +3 -3
  7. package/dist/base/api_client.js +6 -10
  8. package/dist/base/resource_client.d.ts +13 -4
  9. package/dist/base/resource_client.js +25 -21
  10. package/dist/base/resource_collection_client.d.ts +7 -6
  11. package/dist/base/resource_collection_client.js +11 -15
  12. package/dist/body_parser.js +6 -11
  13. package/dist/bundle.js +38 -48
  14. package/dist/bundle.js.map +1 -1
  15. package/dist/generated/api.d.ts +287 -214
  16. package/dist/generated/api.js +1 -2
  17. package/dist/generated/schemas.d.ts +6699 -0
  18. package/dist/generated/schemas.js +1521 -0
  19. package/dist/http_client.d.ts +2 -2
  20. package/dist/http_client.js +23 -28
  21. package/dist/index.d.ts +33 -32
  22. package/dist/index.js +32 -36
  23. package/dist/interceptors.d.ts +1 -1
  24. package/dist/interceptors.js +14 -19
  25. package/dist/lazy_schema.d.ts +8 -0
  26. package/dist/lazy_schema.js +11 -0
  27. package/dist/models.d.ts +33 -52
  28. package/dist/models.js +8 -11
  29. package/dist/resource_clients/actor.d.ts +13 -13
  30. package/dist/resource_clients/actor.js +70 -73
  31. package/dist/resource_clients/actor_collection.d.ts +10 -10
  32. package/dist/resource_clients/actor_collection.js +19 -20
  33. package/dist/resource_clients/actor_env_var.d.ts +3 -3
  34. package/dist/resource_clients/actor_env_var.js +7 -10
  35. package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
  36. package/dist/resource_clients/actor_env_var_collection.js +15 -19
  37. package/dist/resource_clients/actor_version.d.ts +16 -8
  38. package/dist/resource_clients/actor_version.js +15 -19
  39. package/dist/resource_clients/actor_version_collection.d.ts +13 -19
  40. package/dist/resource_clients/actor_version_collection.js +17 -19
  41. package/dist/resource_clients/build.d.ts +7 -5
  42. package/dist/resource_clients/build.js +16 -17
  43. package/dist/resource_clients/build_collection.d.ts +5 -5
  44. package/dist/resource_clients/build_collection.js +10 -13
  45. package/dist/resource_clients/dataset.d.ts +8 -8
  46. package/dist/resource_clients/dataset.js +75 -85
  47. package/dist/resource_clients/dataset_collection.d.ts +4 -4
  48. package/dist/resource_clients/dataset_collection.js +18 -21
  49. package/dist/resource_clients/key_value_store.d.ts +16 -8
  50. package/dist/resource_clients/key_value_store.js +61 -65
  51. package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
  52. package/dist/resource_clients/key_value_store_collection.js +18 -21
  53. package/dist/resource_clients/log.d.ts +6 -4
  54. package/dist/resource_clients/log.js +23 -28
  55. package/dist/resource_clients/request_queue.d.ts +4 -11
  56. package/dist/resource_clients/request_queue.js +100 -106
  57. package/dist/resource_clients/request_queue_collection.d.ts +4 -4
  58. package/dist/resource_clients/request_queue_collection.js +16 -19
  59. package/dist/resource_clients/run.d.ts +18 -8
  60. package/dist/resource_clients/run.js +62 -54
  61. package/dist/resource_clients/run_collection.d.ts +4 -4
  62. package/dist/resource_clients/run_collection.js +15 -18
  63. package/dist/resource_clients/schedule.d.ts +8 -8
  64. package/dist/resource_clients/schedule.js +14 -23
  65. package/dist/resource_clients/schedule_collection.d.ts +4 -4
  66. package/dist/resource_clients/schedule_collection.js +13 -16
  67. package/dist/resource_clients/store_collection.d.ts +5 -5
  68. package/dist/resource_clients/store_collection.js +15 -18
  69. package/dist/resource_clients/task.d.ts +11 -11
  70. package/dist/resource_clients/task.js +49 -59
  71. package/dist/resource_clients/task_collection.d.ts +6 -6
  72. package/dist/resource_clients/task_collection.js +12 -15
  73. package/dist/resource_clients/user.d.ts +11 -11
  74. package/dist/resource_clients/user.js +16 -35
  75. package/dist/resource_clients/webhook.d.ts +8 -8
  76. package/dist/resource_clients/webhook.js +13 -23
  77. package/dist/resource_clients/webhook_collection.d.ts +4 -4
  78. package/dist/resource_clients/webhook_collection.js +13 -16
  79. package/dist/resource_clients/webhook_dispatch.d.ts +5 -5
  80. package/dist/resource_clients/webhook_dispatch.js +5 -9
  81. package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
  82. package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
  83. package/dist/response_validation_error.d.ts +26 -0
  84. package/dist/response_validation_error.js +37 -0
  85. package/dist/schemas.d.ts +15 -0
  86. package/dist/schemas.js +15 -0
  87. package/dist/statistics.js +5 -9
  88. package/dist/timezones.js +1 -2
  89. package/dist/utils.d.ts +27 -24
  90. package/dist/utils.js +69 -93
  91. package/package.json +38 -40
  92. package/dist/argument_validation_error.d.ts +0 -17
  93. package/dist/argument_validation_error.js +0 -157
  94. package/dist/index.mjs +0 -42
package/dist/models.d.ts CHANGED
@@ -24,9 +24,9 @@
24
24
  * nullability and optionality are adopted rather than papered over.
25
25
  */
26
26
  import type { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS, RUN_GENERAL_ACCESS, STORAGE_GENERAL_ACCESS, ValueOf, WEBHOOK_EVENT_TYPES } from '@apify/consts';
27
- import type { components } from './generated/api';
28
- import type { Timezone } from './timezones';
29
- import type { Dictionary } from './utils';
27
+ import type { components } from './generated/api.js';
28
+ import type { Timezone } from './timezones.js';
29
+ import type { Dictionary } from './utils.js';
30
30
  type Schemas = components['schemas'];
31
31
  /**
32
32
  * Event types that can trigger webhooks.
@@ -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 | keyof KeyValueStoreSpecNarrowings>, KeyValueStoreRePointed, KeyValueStoreSpecNarrowings, KeyValueStoreSpecGaps {
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 {
@@ -215,7 +219,7 @@ export interface ActorVersionRePointed {
215
219
  envVars?: ActorEnvironmentVariable[] | null;
216
220
  }
217
221
  export interface ActorVersionClientNarrowings {
218
- sourceType: ActorSourceType;
222
+ sourceType: `${ActorSourceType}`;
219
223
  }
220
224
  /**
221
225
  * Fields every Actor version carries, whatever its source type.
@@ -224,26 +228,26 @@ export interface ActorVersionClientNarrowings {
224
228
  * keeps a union discriminated on `sourceType` instead, because that narrows the source location down
225
229
  * to the single field which applies -- so the four are dropped here and reinstated per variant.
226
230
  */
227
- export interface BaseActorVersion<SourceType extends ActorSourceType> extends Omit<GeneratedVersion, keyof ActorVersionClientNarrowings | keyof ActorVersionRePointed | ActorVersionSourceLocation>, ActorVersionRePointed {
231
+ export interface BaseActorVersion<SourceType extends `${ActorSourceType}`> extends Omit<GeneratedVersion, keyof ActorVersionClientNarrowings | keyof ActorVersionRePointed | ActorVersionSourceLocation>, ActorVersionRePointed {
228
232
  sourceType: SourceType;
229
233
  }
230
234
  /**
231
235
  * An Actor version whose source code is stored on the Apify platform.
232
236
  * @since Added in 2.6.1
233
237
  */
234
- export interface ActorVersionSourceFiles extends BaseActorVersion<ActorSourceType.SourceFiles> {
238
+ export interface ActorVersionSourceFiles extends BaseActorVersion<`${ActorSourceType.SourceFiles}`> {
235
239
  sourceFiles: (ActorVersionSourceFile | ActorVersionSourceFolder)[];
236
240
  }
237
241
  /** An Actor version built from a Git repository. */
238
- export interface ActorVersionGitRepo extends BaseActorVersion<ActorSourceType.GitRepo> {
242
+ export interface ActorVersionGitRepo extends BaseActorVersion<`${ActorSourceType.GitRepo}`> {
239
243
  gitRepoUrl: NonNullable<GeneratedVersion['gitRepoUrl']>;
240
244
  }
241
245
  /** An Actor version built from a downloadable tarball or ZIP archive. */
242
- export interface ActorVersionTarball extends BaseActorVersion<ActorSourceType.Tarball> {
246
+ export interface ActorVersionTarball extends BaseActorVersion<`${ActorSourceType.Tarball}`> {
243
247
  tarballUrl: NonNullable<GeneratedVersion['tarballUrl']>;
244
248
  }
245
249
  /** An Actor version built from a GitHub Gist. */
246
- export interface ActorVersionGitHubGist extends BaseActorVersion<ActorSourceType.GitHubGist> {
250
+ export interface ActorVersionGitHubGist extends BaseActorVersion<`${ActorSourceType.GitHubGist}`> {
247
251
  gitHubGistUrl: NonNullable<GeneratedVersion['gitHubGistUrl']>;
248
252
  }
249
253
  /**
@@ -252,7 +256,7 @@ export interface ActorVersionGitHubGist extends BaseActorVersion<ActorSourceType
252
256
  * It carries no source location of its own, so it adds nothing to `BaseActorVersion`; the variant
253
257
  * exists so that `SOURCE_CODE`, which both the spec and `@apify/consts` list, is representable.
254
258
  */
255
- export interface ActorVersionSourceCode extends BaseActorVersion<ActorSourceType.SourceCode> {
259
+ export interface ActorVersionSourceCode extends BaseActorVersion<`${ActorSourceType.SourceCode}`> {
256
260
  }
257
261
  /** A version of an Actor, discriminated on where its source code comes from. */
258
262
  export type ActorVersion = ActorVersionSourceFiles | ActorVersionGitRepo | ActorVersionTarball | ActorVersionGitHubGist | ActorVersionSourceCode;
@@ -310,11 +314,7 @@ export interface ActorDefinitionSpecGaps {
310
314
  */
311
315
  output?: object | null;
312
316
  }
313
- export interface ActorDefinitionSpecNarrowings {
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 Omit<Schemas['ActorDefinition'], keyof ActorDefinitionSpecNarrowings>, ActorDefinitionSpecNarrowings, ActorDefinitionSpecGaps {
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 | keyof TaskSpecNarrowings>, TaskRePointed, TaskSpecNarrowings, TaskSpecGaps {
613
+ export interface Task extends Omit<Schemas['Task'], keyof TaskRePointed>, TaskRePointed, TaskSpecGaps {
631
614
  }
632
615
  export interface TaskListRePointed {
633
616
  stats?: TaskStats | null;
@@ -756,7 +739,7 @@ export interface ScheduledActorRunInput extends GeneratedScheduleActionRunInput
756
739
  export interface ScheduledActorRunOptions extends GeneratedTaskOptions {
757
740
  }
758
741
  export interface ScheduleActionRunActorRePointed {
759
- type: ScheduleActions.RunActor;
742
+ type: `${ScheduleActions.RunActor}`;
760
743
  runInput?: ScheduledActorRunInput | null;
761
744
  runOptions?: ScheduledActorRunOptions | null;
762
745
  }
@@ -764,13 +747,17 @@ export interface ScheduleActionRunActorRePointed {
764
747
  export interface ScheduleActionRunActor extends Omit<Schemas['ScheduleActionRunActor'], keyof ScheduleActionRunActorRePointed>, ScheduleActionRunActorRePointed {
765
748
  }
766
749
  export interface ScheduleActionRunActorTaskRePointed {
767
- type: ScheduleActions.RunActorTask;
750
+ type: `${ScheduleActions.RunActorTask}`;
768
751
  }
769
752
  /** Scheduled action to run an Actor task. */
770
753
  export interface ScheduleActionRunActorTask extends Omit<Schemas['ScheduleActionRunActorTask'], keyof ScheduleActionRunActorTaskRePointed>, ScheduleActionRunActorTaskRePointed {
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 | keyof UserSpecNarrowings>, UserRePointed, UserSpecNarrowings {
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 | keyof DailyServiceUsageClientConversions>, DailyServiceUsageRePointed, DailyServiceUsageClientConversions {
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
  /**
package/dist/models.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Public models adapted from the generated OpenAPI types in `./generated/api`.
4
3
  *
@@ -24,8 +23,6 @@
24
23
  * Backward-compatibility shims are deliberately absent. This lands in the next major, so the spec's
25
24
  * nullability and optionality are adopted rather than papered over.
26
25
  */
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.PlatformFeature = exports.ScheduleActions = exports.ActorSourceType = exports.WebhookDispatchStatus = void 0;
29
26
  /**
30
27
  * Status of a webhook dispatch.
31
28
  *
@@ -33,12 +30,12 @@ exports.PlatformFeature = exports.ScheduleActions = exports.ActorSourceType = ex
33
30
  * reference it without closing an import cycle. It is re-exported from there, so the public name and
34
31
  * import path are unchanged.
35
32
  */
36
- var WebhookDispatchStatus;
33
+ export var WebhookDispatchStatus;
37
34
  (function (WebhookDispatchStatus) {
38
35
  WebhookDispatchStatus["Active"] = "ACTIVE";
39
36
  WebhookDispatchStatus["Succeeded"] = "SUCCEEDED";
40
37
  WebhookDispatchStatus["Failed"] = "FAILED";
41
- })(WebhookDispatchStatus || (exports.WebhookDispatchStatus = WebhookDispatchStatus = {}));
38
+ })(WebhookDispatchStatus || (WebhookDispatchStatus = {}));
42
39
  /**
43
40
  * Where the source code of an Actor version lives.
44
41
  *
@@ -46,14 +43,14 @@ var WebhookDispatchStatus;
46
43
  * reference it without closing an import cycle. It is re-exported from there, so the public name and
47
44
  * import path are unchanged.
48
45
  */
49
- var ActorSourceType;
46
+ export var ActorSourceType;
50
47
  (function (ActorSourceType) {
51
48
  ActorSourceType["SourceFiles"] = "SOURCE_FILES";
52
49
  ActorSourceType["GitRepo"] = "GIT_REPO";
53
50
  ActorSourceType["Tarball"] = "TARBALL";
54
51
  ActorSourceType["GitHubGist"] = "GITHUB_GIST";
55
52
  ActorSourceType["SourceCode"] = "SOURCE_CODE";
56
- })(ActorSourceType || (exports.ActorSourceType = ActorSourceType = {}));
53
+ })(ActorSourceType || (ActorSourceType = {}));
57
54
  /**
58
55
  * Types of actions that can be scheduled.
59
56
  *
@@ -61,11 +58,11 @@ var ActorSourceType;
61
58
  * without closing an import cycle. It is re-exported from there, so the public name and import path are
62
59
  * unchanged.
63
60
  */
64
- var ScheduleActions;
61
+ export var ScheduleActions;
65
62
  (function (ScheduleActions) {
66
63
  ScheduleActions["RunActor"] = "RUN_ACTOR";
67
64
  ScheduleActions["RunActorTask"] = "RUN_ACTOR_TASK";
68
- })(ScheduleActions || (exports.ScheduleActions = ScheduleActions = {}));
65
+ })(ScheduleActions || (ScheduleActions = {}));
69
66
  /**
70
67
  * Platform features a plan can enable.
71
68
  *
@@ -77,7 +74,7 @@ var ScheduleActions;
77
74
  * Declared here rather than in `./resource_clients/user` so the user types can live alongside it. It is
78
75
  * re-exported from there, so the public name and import path are unchanged.
79
76
  */
80
- var PlatformFeature;
77
+ export var PlatformFeature;
81
78
  (function (PlatformFeature) {
82
79
  PlatformFeature["Actors"] = "ACTORS";
83
80
  PlatformFeature["Storage"] = "STORAGE";
@@ -86,4 +83,4 @@ var PlatformFeature;
86
83
  PlatformFeature["Webhooks"] = "WEBHOOKS";
87
84
  PlatformFeature["Proxy"] = "PROXY";
88
85
  PlatformFeature["ProxyExternalAccess"] = "PROXY_EXTERNAL_ACCESS";
89
- })(PlatformFeature || (exports.PlatformFeature = PlatformFeature = {}));
86
+ })(PlatformFeature || (PlatformFeature = {}));
@@ -1,19 +1,19 @@
1
1
  import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
2
2
  import { Log } from '@apify/log';
3
- import type { ApiClientSubResourceOptions } from '../base/api_client';
4
- import { ResourceClient } from '../base/resource_client';
5
- import type { Actor, ActorRun } from '../models';
6
- import { ActorVersionClient } from './actor_version';
7
- import { ActorVersionCollectionClient } from './actor_version_collection';
8
- import type { Build, BuildClientGetOptions } from './build';
9
- import { BuildClient } from './build';
10
- import { BuildCollectionClient } from './build_collection';
11
- import { RunClient } from './run';
12
- import { RunCollectionClient } from './run_collection';
13
- import type { WebhookUpdateData } from './webhook';
14
- import { WebhookCollectionClient } from './webhook_collection';
3
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
4
+ import { ResourceClient } from '../base/resource_client.js';
5
+ import type { Actor, ActorRun } from '../models.js';
6
+ import { ActorVersionClient } from './actor_version.js';
7
+ import { ActorVersionCollectionClient } from './actor_version_collection.js';
8
+ import type { Build, BuildClientGetOptions } from './build.js';
9
+ import { BuildClient } from './build.js';
10
+ import { BuildCollectionClient } from './build_collection.js';
11
+ import { RunClient } from './run.js';
12
+ import { RunCollectionClient } from './run_collection.js';
13
+ import type { WebhookUpdateData } from './webhook.js';
14
+ import { WebhookCollectionClient } from './webhook_collection.js';
15
15
  import type { ValueOf } from 'type-fest';
16
- export type { Actor, ActorChargeEvent, ActorChargeEvents, ActorDefaultRunOptions, ActorDefinition, ActorExampleRunInput, ActorRun, ActorRunListItem, ActorRunMeta, ActorRunMetamorph, ActorRunOptions, ActorRunPricingInfo, ActorRunStats, ActorRunStorageIds, ActorRunUsage, ActorStandby, ActorStats, ActorTaggedBuild, ActorTaggedBuilds, FlatPricePerMonthActorPricingInfo, FreeActorPricingInfo, PricePerDatasetItemActorPricingInfo, PricePerEventActorPricingInfo, TieredPricingPerDatasetItem, TieredPricingPerDatasetItemEntry, TieredPricingPerEvent, TieredPricingPerEventEntry, } from '../models';
16
+ export type { Actor, ActorChargeEvent, ActorChargeEvents, ActorDefaultRunOptions, ActorDefinition, ActorExampleRunInput, ActorRun, ActorRunListItem, ActorRunMeta, ActorRunMetamorph, ActorRunOptions, ActorRunPricingInfo, ActorRunStats, ActorRunStorageIds, ActorRunUsage, ActorStandby, ActorStats, ActorTaggedBuild, ActorTaggedBuilds, FlatPricePerMonthActorPricingInfo, FreeActorPricingInfo, PricePerDatasetItemActorPricingInfo, PricePerEventActorPricingInfo, TieredPricingPerDatasetItem, TieredPricingPerDatasetItemEntry, TieredPricingPerEvent, TieredPricingPerEventEntry, } from '../models.js';
17
17
  /**
18
18
  * Client for managing a specific Actor.
19
19
  *
@@ -1,57 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActorClient = void 0;
4
- const zod_1 = require("zod");
5
- const consts_1 = require("@apify/consts");
6
- const log_1 = require("@apify/log");
7
- const resource_client_1 = require("../base/resource_client");
8
- const utils_1 = require("../utils");
9
- const actor_version_1 = require("./actor_version");
10
- const actor_version_collection_1 = require("./actor_version_collection");
11
- const build_1 = require("./build");
12
- const build_collection_1 = require("./build_collection");
13
- const run_1 = require("./run");
14
- const run_collection_1 = require("./run_collection");
15
- const webhook_collection_1 = require("./webhook_collection");
16
- const startOptionsSchema = zod_1.z.strictObject({
17
- build: zod_1.z.string().optional(),
18
- contentType: zod_1.z.string().optional(),
19
- memory: zod_1.z.number().optional(),
20
- timeout: zod_1.z.number().optional(),
21
- waitForFinish: zod_1.z.number().optional(),
22
- webhooks: zod_1.z.array(utils_1.anyObjectSchema).optional(),
23
- maxItems: zod_1.z.number().min(0).optional(),
24
- maxTotalChargeUsd: zod_1.z.number().min(0).optional(),
25
- restartOnError: zod_1.z.boolean().optional(),
26
- forcePermissionLevel: zod_1.z.enum(consts_1.ACTOR_PERMISSION_LEVEL).optional(),
1
+ import { z } from 'zod';
2
+ import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
3
+ import { Log } from '@apify/log';
4
+ import { ResourceClient } from '../base/resource_client.js';
5
+ import * as schemas from '../schemas.js';
6
+ import { anyObjectSchema, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
7
+ import { ActorVersionClient } from './actor_version.js';
8
+ import { ActorVersionCollectionClient } from './actor_version_collection.js';
9
+ import { BuildClient } from './build.js';
10
+ import { BuildCollectionClient } from './build_collection.js';
11
+ import { RunClient } from './run.js';
12
+ import { RunCollectionClient } from './run_collection.js';
13
+ import { WebhookCollectionClient } from './webhook_collection.js';
14
+ const startOptionsSchema = z.strictObject({
15
+ build: z.string().optional(),
16
+ contentType: z.string().optional(),
17
+ memory: z.number().optional(),
18
+ timeout: z.number().optional(),
19
+ waitForFinish: z.number().optional(),
20
+ webhooks: z.array(anyObjectSchema).optional(),
21
+ maxItems: z.number().min(0).optional(),
22
+ maxTotalChargeUsd: z.number().min(0).optional(),
23
+ restartOnError: z.boolean().optional(),
24
+ forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
27
25
  });
28
- const callOptionsSchema = zod_1.z.strictObject({
29
- build: zod_1.z.string().optional(),
30
- contentType: zod_1.z.string().optional(),
31
- memory: zod_1.z.number().optional(),
32
- timeout: zod_1.z.number().min(0).optional(),
33
- waitSecs: zod_1.z.number().min(0).optional(),
34
- webhooks: zod_1.z.array(utils_1.anyObjectSchema).optional(),
35
- maxItems: zod_1.z.number().min(0).optional(),
36
- maxTotalChargeUsd: zod_1.z.number().min(0).optional(),
37
- log: zod_1.z.union([zod_1.z.null(), zod_1.z.instanceof(log_1.Log), zod_1.z.literal('default')]).optional(),
38
- restartOnError: zod_1.z.boolean().optional(),
39
- forcePermissionLevel: zod_1.z.enum(consts_1.ACTOR_PERMISSION_LEVEL).optional(),
26
+ const callOptionsSchema = z.strictObject({
27
+ build: z.string().optional(),
28
+ contentType: z.string().optional(),
29
+ memory: z.number().optional(),
30
+ timeout: z.number().min(0).optional(),
31
+ waitSecs: z.number().min(0).optional(),
32
+ webhooks: z.array(anyObjectSchema).optional(),
33
+ maxItems: z.number().min(0).optional(),
34
+ maxTotalChargeUsd: z.number().min(0).optional(),
35
+ log: z.union([z.null(), z.instanceof(Log), z.literal('default')]).optional(),
36
+ restartOnError: z.boolean().optional(),
37
+ forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
40
38
  });
41
- const validateInputOptionsSchema = zod_1.z.strictObject({
42
- build: zod_1.z.string().optional(),
43
- contentType: zod_1.z.string().optional(),
39
+ const validateInputOptionsSchema = z.strictObject({
40
+ build: z.string().optional(),
41
+ contentType: z.string().optional(),
44
42
  });
45
- const versionNumberSchema = zod_1.z.string();
46
- const buildOptionsSchema = zod_1.z.strictObject({
47
- betaPackages: zod_1.z.boolean().optional(),
48
- tag: zod_1.z.string().optional(),
49
- useCache: zod_1.z.boolean().optional(),
50
- waitForFinish: zod_1.z.number().optional(),
43
+ const versionNumberSchema = z.string().min(1);
44
+ const buildOptionsSchema = z.strictObject({
45
+ betaPackages: z.boolean().optional(),
46
+ tag: z.string().optional(),
47
+ useCache: z.boolean().optional(),
48
+ waitForFinish: z.number().optional(),
51
49
  });
52
- const lastRunOptionsSchema = zod_1.z.strictObject({
53
- status: zod_1.z.enum(consts_1.ACTOR_JOB_STATUSES).optional(),
54
- origin: zod_1.z.enum(consts_1.META_ORIGINS).optional(),
50
+ const lastRunOptionsSchema = z.strictObject({
51
+ status: z.enum(ACTOR_JOB_STATUSES).optional(),
52
+ origin: z.enum(META_ORIGINS).optional(),
55
53
  });
56
54
  /**
57
55
  * Client for managing a specific Actor.
@@ -73,7 +71,7 @@ const lastRunOptionsSchema = zod_1.z.strictObject({
73
71
  *
74
72
  * @see https://docs.apify.com/platform/actors
75
73
  */
76
- class ActorClient extends resource_client_1.ResourceClient {
74
+ export class ActorClient extends ResourceClient {
77
75
  /**
78
76
  * @hidden
79
77
  */
@@ -90,7 +88,7 @@ class ActorClient extends resource_client_1.ResourceClient {
90
88
  * @see https://docs.apify.com/api/v2/act-get
91
89
  */
92
90
  async get() {
93
- return this._get();
91
+ return this._get(schemas.Actor());
94
92
  }
95
93
  /**
96
94
  * Updates the Actor with specified fields.
@@ -100,8 +98,8 @@ class ActorClient extends resource_client_1.ResourceClient {
100
98
  * @see https://docs.apify.com/api/v2/act-put
101
99
  */
102
100
  async update(newFields) {
103
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
104
- return this._update(newFields);
101
+ parseArgument(newFields, anyObjectSchema);
102
+ return this._update(schemas.Actor(), newFields);
105
103
  }
106
104
  /**
107
105
  * Deletes the Actor.
@@ -148,14 +146,14 @@ class ActorClient extends resource_client_1.ResourceClient {
148
146
  async start(input, options = {}) {
149
147
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
150
148
  // then it will process input as a buffer.
151
- const parsed = (0, utils_1.parseArgument)(options, startOptionsSchema, 'ActorStartOptions');
149
+ const parsed = parseArgument(options, startOptionsSchema, 'ActorStartOptions');
152
150
  const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError, forcePermissionLevel, } = parsed;
153
151
  const params = {
154
152
  waitForFinish,
155
153
  timeout,
156
154
  memory,
157
155
  build,
158
- webhooks: (0, utils_1.stringifyWebhooksToBase64)(parsed.webhooks),
156
+ webhooks: stringifyWebhooksToBase64(parsed.webhooks),
159
157
  maxItems,
160
158
  maxTotalChargeUsd,
161
159
  restartOnError,
@@ -176,7 +174,7 @@ class ActorClient extends resource_client_1.ResourceClient {
176
174
  };
177
175
  }
178
176
  const response = await this.httpClient.call(request);
179
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
177
+ return parseResponse(response, schemas.Run());
180
178
  }
181
179
  /**
182
180
  * Starts the Actor and waits for it to finish before returning the Run object.
@@ -218,7 +216,7 @@ class ActorClient extends resource_client_1.ResourceClient {
218
216
  async call(input, options = {}) {
219
217
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
220
218
  // then it will process input as a buffer.
221
- const parsed = (0, utils_1.parseArgument)(options, callOptionsSchema, 'ActorCallOptions');
219
+ const parsed = parseArgument(options, callOptionsSchema, 'ActorCallOptions');
222
220
  const { waitSecs, log, ...startOptions } = parsed;
223
221
  const { id } = await this.start(input, startOptions);
224
222
  // Calling root client because we need access to top level API.
@@ -268,7 +266,7 @@ class ActorClient extends resource_client_1.ResourceClient {
268
266
  async validateInput(input, options = {}) {
269
267
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
270
268
  // then it will process input as a buffer.
271
- const parsed = (0, utils_1.parseArgument)(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
269
+ const parsed = parseArgument(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
272
270
  const request = {
273
271
  url: this._url('validate-input'),
274
272
  method: 'POST',
@@ -316,8 +314,8 @@ class ActorClient extends resource_client_1.ResourceClient {
316
314
  * ```
317
315
  */
318
316
  async build(versionNumber, options = {}) {
319
- (0, utils_1.parseArgument)(versionNumber, versionNumberSchema);
320
- const parsed = (0, utils_1.parseArgument)(options, buildOptionsSchema, 'ActorBuildOptions');
317
+ parseArgument(versionNumber, versionNumberSchema);
318
+ const parsed = parseArgument(options, buildOptionsSchema, 'ActorBuildOptions');
321
319
  const response = await this.httpClient.call({
322
320
  url: this._url('builds'),
323
321
  method: 'POST',
@@ -326,7 +324,7 @@ class ActorClient extends resource_client_1.ResourceClient {
326
324
  ...parsed,
327
325
  }),
328
326
  });
329
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
327
+ return parseResponse(response, schemas.Build());
330
328
  }
331
329
  /**
332
330
  * Returns a client for the default build of this Actor.
@@ -359,8 +357,8 @@ class ActorClient extends resource_client_1.ResourceClient {
359
357
  method: 'GET',
360
358
  params: this._params(options),
361
359
  });
362
- const { id } = (0, utils_1.pluckData)(response.data);
363
- return new build_1.BuildClient({
360
+ const { id } = parseResponse(response, schemas.Build());
361
+ return new BuildClient({
364
362
  baseUrl: this.apifyClient.baseUrl,
365
363
  publicBaseUrl: this.apifyClient.publicBaseUrl,
366
364
  httpClient: this.httpClient,
@@ -386,8 +384,8 @@ class ActorClient extends resource_client_1.ResourceClient {
386
384
  * ```
387
385
  */
388
386
  lastRun(options = {}) {
389
- const parsed = (0, utils_1.parseArgument)(options, lastRunOptionsSchema, 'ActorLastRunOptions');
390
- return new run_1.RunClient(this._subResourceOptions({
387
+ const parsed = parseArgument(options, lastRunOptionsSchema, 'ActorLastRunOptions');
388
+ return new RunClient(this._subResourceOptions({
391
389
  id: 'last',
392
390
  params: this._params(parsed),
393
391
  resourcePath: 'runs',
@@ -400,7 +398,7 @@ class ActorClient extends resource_client_1.ResourceClient {
400
398
  * @see https://docs.apify.com/api/v2/act-builds-get
401
399
  */
402
400
  builds() {
403
- return new build_collection_1.BuildCollectionClient(this._subResourceOptions({
401
+ return new BuildCollectionClient(this._subResourceOptions({
404
402
  resourcePath: 'builds',
405
403
  }));
406
404
  }
@@ -411,7 +409,7 @@ class ActorClient extends resource_client_1.ResourceClient {
411
409
  * @see https://docs.apify.com/api/v2/act-runs-get
412
410
  */
413
411
  runs() {
414
- return new run_collection_1.RunCollectionClient(this._subResourceOptions({
412
+ return new RunCollectionClient(this._subResourceOptions({
415
413
  resourcePath: 'runs',
416
414
  }));
417
415
  }
@@ -423,8 +421,8 @@ class ActorClient extends resource_client_1.ResourceClient {
423
421
  * @see https://docs.apify.com/api/v2/act-version-get
424
422
  */
425
423
  version(versionNumber) {
426
- (0, utils_1.parseArgument)(versionNumber, versionNumberSchema);
427
- return new actor_version_1.ActorVersionClient(this._subResourceOptions({
424
+ parseArgument(versionNumber, versionNumberSchema);
425
+ return new ActorVersionClient(this._subResourceOptions({
428
426
  id: versionNumber,
429
427
  }));
430
428
  }
@@ -435,7 +433,7 @@ class ActorClient extends resource_client_1.ResourceClient {
435
433
  * @see https://docs.apify.com/api/v2/act-versions-get
436
434
  */
437
435
  versions() {
438
- return new actor_version_collection_1.ActorVersionCollectionClient(this._subResourceOptions());
436
+ return new ActorVersionCollectionClient(this._subResourceOptions());
439
437
  }
440
438
  /**
441
439
  * Returns a client for managing webhooks associated with this Actor.
@@ -444,7 +442,6 @@ class ActorClient extends resource_client_1.ResourceClient {
444
442
  * @see https://docs.apify.com/api/v2/act-webhooks-get
445
443
  */
446
444
  webhooks() {
447
- return new webhook_collection_1.WebhookCollectionClient(this._subResourceOptions());
445
+ return new WebhookCollectionClient(this._subResourceOptions());
448
446
  }
449
447
  }
450
- exports.ActorClient = ActorClient;