apify-client 3.0.0-beta.9 → 3.0.0-beta.90

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 (122) hide show
  1. package/README.md +16 -2
  2. package/dist/apify_api_error.d.ts +13 -27
  3. package/dist/apify_api_error.js +33 -23
  4. package/dist/apify_client.d.ts +125 -10
  5. package/dist/apify_client.js +133 -48
  6. package/dist/apify_client_error.d.ts +10 -0
  7. package/dist/apify_client_error.js +10 -0
  8. package/dist/base/api_client.d.ts +7 -7
  9. package/dist/base/api_client.js +36 -36
  10. package/dist/base/resource_client.d.ts +21 -8
  11. package/dist/base/resource_client.js +70 -36
  12. package/dist/base/resource_collection_client.d.ts +12 -4
  13. package/dist/base/resource_collection_client.js +34 -11
  14. package/dist/body_parser.d.ts +3 -4
  15. package/dist/body_parser.js +19 -26
  16. package/dist/bundle.js +27 -22
  17. package/dist/bundle.js.map +1 -1
  18. package/dist/generated/api.d.ts +3040 -971
  19. package/dist/generated/schemas.d.ts +2369 -934
  20. package/dist/generated/schemas.js +570 -229
  21. package/dist/http_clients/axios.d.ts +61 -0
  22. package/dist/http_clients/axios.js +119 -0
  23. package/dist/http_clients/base.d.ts +386 -0
  24. package/dist/http_clients/base.js +650 -0
  25. package/dist/http_clients/index.d.ts +4 -0
  26. package/dist/http_clients/index.js +2 -0
  27. package/dist/http_compressors/base.d.ts +40 -0
  28. package/dist/http_compressors/base.js +9 -0
  29. package/dist/http_compressors/brotli.d.ts +33 -0
  30. package/dist/http_compressors/brotli.js +39 -0
  31. package/dist/http_compressors/gzip.d.ts +33 -0
  32. package/dist/http_compressors/gzip.js +39 -0
  33. package/dist/http_compressors/index.d.ts +6 -0
  34. package/dist/http_compressors/index.js +2 -0
  35. package/dist/http_compressors/resolve.d.ts +23 -0
  36. package/dist/http_compressors/resolve.js +27 -0
  37. package/dist/index.d.ts +6 -1
  38. package/dist/index.js +5 -1
  39. package/dist/invalid_response_body_error.d.ts +14 -0
  40. package/dist/invalid_response_body_error.js +18 -0
  41. package/dist/models.d.ts +166 -243
  42. package/dist/models.js +6 -4
  43. package/dist/resource_clients/actor.d.ts +104 -34
  44. package/dist/resource_clients/actor.js +130 -56
  45. package/dist/resource_clients/actor_collection.d.ts +18 -12
  46. package/dist/resource_clients/actor_collection.js +11 -3
  47. package/dist/resource_clients/actor_env_var.d.ts +11 -4
  48. package/dist/resource_clients/actor_env_var.js +16 -6
  49. package/dist/resource_clients/actor_env_var_collection.d.ts +9 -4
  50. package/dist/resource_clients/actor_env_var_collection.js +11 -4
  51. package/dist/resource_clients/actor_server.d.ts +141 -0
  52. package/dist/resource_clients/actor_server.js +195 -0
  53. package/dist/resource_clients/actor_version.d.ts +20 -5
  54. package/dist/resource_clients/actor_version.js +19 -9
  55. package/dist/resource_clients/actor_version_collection.d.ts +11 -4
  56. package/dist/resource_clients/actor_version_collection.js +13 -4
  57. package/dist/resource_clients/build.d.ts +20 -7
  58. package/dist/resource_clients/build.js +35 -15
  59. package/dist/resource_clients/build_collection.d.ts +7 -5
  60. package/dist/resource_clients/build_collection.js +4 -1
  61. package/dist/resource_clients/dataset.d.ts +83 -37
  62. package/dist/resource_clients/dataset.js +107 -121
  63. package/dist/resource_clients/dataset_collection.d.ts +10 -6
  64. package/dist/resource_clients/dataset_collection.js +13 -2
  65. package/dist/resource_clients/key_value_store.d.ts +108 -26
  66. package/dist/resource_clients/key_value_store.js +134 -52
  67. package/dist/resource_clients/key_value_store_collection.d.ts +10 -6
  68. package/dist/resource_clients/key_value_store_collection.js +13 -2
  69. package/dist/resource_clients/log.d.ts +40 -21
  70. package/dist/resource_clients/log.js +144 -66
  71. package/dist/resource_clients/request_queue.d.ts +76 -31
  72. package/dist/resource_clients/request_queue.js +178 -93
  73. package/dist/resource_clients/request_queue_collection.d.ts +9 -5
  74. package/dist/resource_clients/request_queue_collection.js +9 -3
  75. package/dist/resource_clients/run.d.ts +126 -28
  76. package/dist/resource_clients/run.js +193 -49
  77. package/dist/resource_clients/run_collection.d.ts +5 -3
  78. package/dist/resource_clients/run_collection.js +4 -1
  79. package/dist/resource_clients/schedule.d.ts +16 -7
  80. package/dist/resource_clients/schedule.js +30 -22
  81. package/dist/resource_clients/schedule_collection.d.ts +6 -2
  82. package/dist/resource_clients/schedule_collection.js +9 -3
  83. package/dist/resource_clients/store_collection.d.ts +6 -4
  84. package/dist/resource_clients/store_collection.js +4 -1
  85. package/dist/resource_clients/task.d.ts +36 -13
  86. package/dist/resource_clients/task.js +79 -46
  87. package/dist/resource_clients/task_collection.d.ts +9 -5
  88. package/dist/resource_clients/task_collection.js +9 -3
  89. package/dist/resource_clients/user.d.ts +19 -10
  90. package/dist/resource_clients/user.js +42 -38
  91. package/dist/resource_clients/webhook.d.ts +17 -8
  92. package/dist/resource_clients/webhook.js +30 -22
  93. package/dist/resource_clients/webhook_collection.d.ts +8 -4
  94. package/dist/resource_clients/webhook_collection.js +9 -3
  95. package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
  96. package/dist/resource_clients/webhook_dispatch.js +7 -2
  97. package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
  98. package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
  99. package/dist/response_validation_error.d.ts +2 -1
  100. package/dist/response_validation_error.js +2 -1
  101. package/dist/runtime/node.d.ts +6 -0
  102. package/dist/runtime/node.js +80 -0
  103. package/dist/runtime/types.d.ts +60 -0
  104. package/dist/runtime/types.js +1 -0
  105. package/dist/runtime/web.d.ts +5 -0
  106. package/dist/runtime/web.js +21 -0
  107. package/dist/schemas.d.ts +368 -4
  108. package/dist/schemas.js +26 -4
  109. package/dist/statistics.d.ts +1 -6
  110. package/dist/statistics.js +2 -2
  111. package/dist/timeouts.d.ts +84 -0
  112. package/dist/timeouts.js +37 -0
  113. package/dist/timezones.d.ts +1 -1
  114. package/dist/utils.d.ts +89 -59
  115. package/dist/utils.js +216 -158
  116. package/dist/wait_for_resources.d.ts +8 -0
  117. package/dist/wait_for_resources.js +39 -0
  118. package/package.json +37 -34
  119. package/dist/http_client.d.ts +0 -88
  120. package/dist/http_client.js +0 -255
  121. package/dist/interceptors.d.ts +0 -19
  122. package/dist/interceptors.js +0 -105
package/dist/schemas.d.ts CHANGED
@@ -1,15 +1,379 @@
1
1
  /**
2
2
  * The schemas the resource clients validate API responses with.
3
3
  *
4
- * Today these are exactly the generated ones. The module still exists as the one place where a generated
5
- * schema is widened when the API is known to return something the specification does not describe, so a
6
- * documented deviation never sends a resource client reaching into `./generated` directly. An override
4
+ * Most of these are the generated ones. This module is the one place where a generated schema is widened
5
+ * when the API is known to return something the specification does not describe, so a documented deviation
6
+ * never sends a resource client reaching into `./generated` directly. An override
7
7
  * declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
8
8
  * built on the generated schema it replaces. Every schema that embeds an overridden one has to be rebuilt on
9
- * top of it, and `spec_guards.ts` checks that each override still accepts what the specification describes,
9
+ * top of it, and `spec_guards.ts` checks that each override still produces what the specification describes,
10
10
  * so one cannot narrow by accident.
11
11
  *
12
12
  * Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
13
13
  * through. Neither do client narrowings: a schema only ever accepts more than the published type.
14
14
  */
15
+ import { z } from 'zod';
15
16
  export * from './generated/schemas.js';
17
+ /** The API returns `actVersion.buildTag` as `null` for some builds, which the specification types as a string. */
18
+ export declare const Build: () => z.ZodObject<{
19
+ id: z.ZodString;
20
+ actId: z.ZodString;
21
+ userId: z.ZodString;
22
+ startedAt: z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>;
23
+ finishedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
24
+ status: z.ZodUnion<[z.ZodEnum<{
25
+ ABORTED: "ABORTED";
26
+ ABORTING: "ABORTING";
27
+ FAILED: "FAILED";
28
+ READY: "READY";
29
+ RUNNING: "RUNNING";
30
+ SUCCEEDED: "SUCCEEDED";
31
+ "TIMED-OUT": "TIMED-OUT";
32
+ "TIMING-OUT": "TIMING-OUT";
33
+ }>, z.ZodString]>;
34
+ meta: z.ZodObject<{
35
+ origin: z.ZodUnion<[z.ZodEnum<{
36
+ ACTOR: "ACTOR";
37
+ API: "API";
38
+ CI: "CI";
39
+ CLI: "CLI";
40
+ DEVELOPMENT: "DEVELOPMENT";
41
+ MCP: "MCP";
42
+ SCHEDULER: "SCHEDULER";
43
+ STANDBY: "STANDBY";
44
+ TEST: "TEST";
45
+ WEB: "WEB";
46
+ WEBHOOK: "WEBHOOK";
47
+ }>, z.ZodString]>;
48
+ clientIp: z.ZodOptional<z.ZodString>;
49
+ userAgent: z.ZodOptional<z.ZodString>;
50
+ githubActionsRunUrl: z.ZodOptional<z.ZodString>;
51
+ actorRunId: z.ZodOptional<z.ZodString>;
52
+ webhookDispatchId: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$loose>;
54
+ stats: z.ZodOptional<z.ZodNullable<z.ZodObject<{
55
+ durationMillis: z.ZodOptional<z.ZodInt>;
56
+ runTimeSecs: z.ZodOptional<z.ZodNumber>;
57
+ computeUnits: z.ZodOptional<z.ZodNumber>;
58
+ imageSizeBytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
59
+ }, z.core.$loose>>>;
60
+ options: z.ZodOptional<z.ZodNullable<z.ZodObject<{
61
+ useCache: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
62
+ betaPackages: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
63
+ memoryMbytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
64
+ diskMbytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
65
+ tag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ debug: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
67
+ }, z.core.$loose>>>;
68
+ usage: z.ZodOptional<z.ZodNullable<z.ZodObject<{
69
+ ACTOR_COMPUTE_UNITS: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
70
+ }, z.core.$loose>>>;
71
+ usageTotalUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
72
+ usageUsd: z.ZodOptional<z.ZodNullable<z.ZodObject<{
73
+ ACTOR_COMPUTE_UNITS: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
74
+ }, z.core.$loose>>>;
75
+ inputSchema: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ readme: z.ZodOptional<z.ZodNullable<z.ZodString>>;
77
+ changelog: z.ZodOptional<z.ZodNullable<z.ZodString>>;
78
+ exitCode: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
79
+ gitCommitId: z.ZodOptional<z.ZodString>;
80
+ gitBranchName: z.ZodOptional<z.ZodString>;
81
+ createdByOrganizationMemberUserId: z.ZodOptional<z.ZodString>;
82
+ buildNumber: z.ZodString;
83
+ imageDigest: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ actorDefinition: z.ZodOptional<z.ZodNullable<z.ZodObject<{
85
+ actorSpecification: z.ZodOptional<z.ZodLiteral<1>>;
86
+ name: z.ZodOptional<z.ZodString>;
87
+ title: z.ZodOptional<z.ZodString>;
88
+ description: z.ZodOptional<z.ZodString>;
89
+ version: z.ZodOptional<z.ZodString>;
90
+ buildTag: z.ZodOptional<z.ZodString>;
91
+ meta: z.ZodOptional<z.ZodObject<{
92
+ templateId: z.ZodOptional<z.ZodString>;
93
+ generatedBy: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$loose>>;
95
+ environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
96
+ dockerfile: z.ZodOptional<z.ZodString>;
97
+ dockerContextDir: z.ZodOptional<z.ZodString>;
98
+ readme: z.ZodOptional<z.ZodNullable<z.ZodString>>;
99
+ input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
100
+ output: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
101
+ changelog: z.ZodOptional<z.ZodNullable<z.ZodString>>;
102
+ storages: z.ZodOptional<z.ZodObject<{
103
+ dataset: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
104
+ datasets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
105
+ keyValueStore: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
106
+ }, z.core.$loose>>;
107
+ defaultMemoryMbytes: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
108
+ minMemoryMbytes: z.ZodOptional<z.ZodInt>;
109
+ maxMemoryMbytes: z.ZodOptional<z.ZodInt>;
110
+ usesStandbyMode: z.ZodOptional<z.ZodBoolean>;
111
+ webServerSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
+ webServerMcpPath: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$loose>>>;
114
+ actVersion: z.ZodOptional<z.ZodObject<{
115
+ sourceType: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
116
+ GITHUB_GIST: "GITHUB_GIST";
117
+ GIT_REPO: "GIT_REPO";
118
+ SOURCE_CODE: "SOURCE_CODE";
119
+ SOURCE_FILES: "SOURCE_FILES";
120
+ TARBALL: "TARBALL";
121
+ }>, z.ZodString]>>;
122
+ versionNumber: z.ZodOptional<z.ZodString>;
123
+ gitRepoUrl: z.ZodOptional<z.ZodString>;
124
+ sourceFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
125
+ format: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
126
+ BASE64: "BASE64";
127
+ TEXT: "TEXT";
128
+ }>, z.ZodString]>>;
129
+ content: z.ZodOptional<z.ZodString>;
130
+ name: z.ZodString;
131
+ }, z.core.$loose>>>;
132
+ gitHubGistUrl: z.ZodOptional<z.ZodString>;
133
+ tarballUrl: z.ZodOptional<z.ZodString>;
134
+ buildTag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
135
+ }, z.core.$loose>>;
136
+ }, z.core.$loose>;
137
+ /** Response containing Actor build data. */
138
+ export declare const BuildResponse: () => z.ZodObject<{
139
+ data: z.ZodObject<{
140
+ id: z.ZodString;
141
+ actId: z.ZodString;
142
+ userId: z.ZodString;
143
+ startedAt: z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>;
144
+ finishedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
145
+ status: z.ZodUnion<[z.ZodEnum<{
146
+ ABORTED: "ABORTED";
147
+ ABORTING: "ABORTING";
148
+ FAILED: "FAILED";
149
+ READY: "READY";
150
+ RUNNING: "RUNNING";
151
+ SUCCEEDED: "SUCCEEDED";
152
+ "TIMED-OUT": "TIMED-OUT";
153
+ "TIMING-OUT": "TIMING-OUT";
154
+ }>, z.ZodString]>;
155
+ meta: z.ZodObject<{
156
+ origin: z.ZodUnion<[z.ZodEnum<{
157
+ ACTOR: "ACTOR";
158
+ API: "API";
159
+ CI: "CI";
160
+ CLI: "CLI";
161
+ DEVELOPMENT: "DEVELOPMENT";
162
+ MCP: "MCP";
163
+ SCHEDULER: "SCHEDULER";
164
+ STANDBY: "STANDBY";
165
+ TEST: "TEST";
166
+ WEB: "WEB";
167
+ WEBHOOK: "WEBHOOK";
168
+ }>, z.ZodString]>;
169
+ clientIp: z.ZodOptional<z.ZodString>;
170
+ userAgent: z.ZodOptional<z.ZodString>;
171
+ githubActionsRunUrl: z.ZodOptional<z.ZodString>;
172
+ actorRunId: z.ZodOptional<z.ZodString>;
173
+ webhookDispatchId: z.ZodOptional<z.ZodString>;
174
+ }, z.core.$loose>;
175
+ stats: z.ZodOptional<z.ZodNullable<z.ZodObject<{
176
+ durationMillis: z.ZodOptional<z.ZodInt>;
177
+ runTimeSecs: z.ZodOptional<z.ZodNumber>;
178
+ computeUnits: z.ZodOptional<z.ZodNumber>;
179
+ imageSizeBytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
180
+ }, z.core.$loose>>>;
181
+ options: z.ZodOptional<z.ZodNullable<z.ZodObject<{
182
+ useCache: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
183
+ betaPackages: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
184
+ memoryMbytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
185
+ diskMbytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
186
+ tag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
187
+ debug: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
188
+ }, z.core.$loose>>>;
189
+ usage: z.ZodOptional<z.ZodNullable<z.ZodObject<{
190
+ ACTOR_COMPUTE_UNITS: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
191
+ }, z.core.$loose>>>;
192
+ usageTotalUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
193
+ usageUsd: z.ZodOptional<z.ZodNullable<z.ZodObject<{
194
+ ACTOR_COMPUTE_UNITS: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
195
+ }, z.core.$loose>>>;
196
+ inputSchema: z.ZodOptional<z.ZodNullable<z.ZodString>>;
197
+ readme: z.ZodOptional<z.ZodNullable<z.ZodString>>;
198
+ changelog: z.ZodOptional<z.ZodNullable<z.ZodString>>;
199
+ exitCode: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
200
+ gitCommitId: z.ZodOptional<z.ZodString>;
201
+ gitBranchName: z.ZodOptional<z.ZodString>;
202
+ createdByOrganizationMemberUserId: z.ZodOptional<z.ZodString>;
203
+ buildNumber: z.ZodString;
204
+ imageDigest: z.ZodOptional<z.ZodNullable<z.ZodString>>;
205
+ actorDefinition: z.ZodOptional<z.ZodNullable<z.ZodObject<{
206
+ actorSpecification: z.ZodOptional<z.ZodLiteral<1>>;
207
+ name: z.ZodOptional<z.ZodString>;
208
+ title: z.ZodOptional<z.ZodString>;
209
+ description: z.ZodOptional<z.ZodString>;
210
+ version: z.ZodOptional<z.ZodString>;
211
+ buildTag: z.ZodOptional<z.ZodString>;
212
+ meta: z.ZodOptional<z.ZodObject<{
213
+ templateId: z.ZodOptional<z.ZodString>;
214
+ generatedBy: z.ZodOptional<z.ZodString>;
215
+ }, z.core.$loose>>;
216
+ environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
217
+ dockerfile: z.ZodOptional<z.ZodString>;
218
+ dockerContextDir: z.ZodOptional<z.ZodString>;
219
+ readme: z.ZodOptional<z.ZodNullable<z.ZodString>>;
220
+ input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
221
+ output: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
222
+ changelog: z.ZodOptional<z.ZodNullable<z.ZodString>>;
223
+ storages: z.ZodOptional<z.ZodObject<{
224
+ dataset: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
225
+ datasets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
226
+ keyValueStore: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
227
+ }, z.core.$loose>>;
228
+ defaultMemoryMbytes: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
229
+ minMemoryMbytes: z.ZodOptional<z.ZodInt>;
230
+ maxMemoryMbytes: z.ZodOptional<z.ZodInt>;
231
+ usesStandbyMode: z.ZodOptional<z.ZodBoolean>;
232
+ webServerSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
233
+ webServerMcpPath: z.ZodOptional<z.ZodString>;
234
+ }, z.core.$loose>>>;
235
+ actVersion: z.ZodOptional<z.ZodObject<{
236
+ sourceType: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
237
+ GITHUB_GIST: "GITHUB_GIST";
238
+ GIT_REPO: "GIT_REPO";
239
+ SOURCE_CODE: "SOURCE_CODE";
240
+ SOURCE_FILES: "SOURCE_FILES";
241
+ TARBALL: "TARBALL";
242
+ }>, z.ZodString]>>;
243
+ versionNumber: z.ZodOptional<z.ZodString>;
244
+ gitRepoUrl: z.ZodOptional<z.ZodString>;
245
+ sourceFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
246
+ format: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
247
+ BASE64: "BASE64";
248
+ TEXT: "TEXT";
249
+ }>, z.ZodString]>>;
250
+ content: z.ZodOptional<z.ZodString>;
251
+ name: z.ZodString;
252
+ }, z.core.$loose>>>;
253
+ gitHubGistUrl: z.ZodOptional<z.ZodString>;
254
+ tarballUrl: z.ZodOptional<z.ZodString>;
255
+ buildTag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
256
+ }, z.core.$loose>>;
257
+ }, z.core.$loose>;
258
+ }, z.core.$loose>;
259
+ /**
260
+ * The API returns `uiState` as `null` once an API update has changed the schedule's `cronExpression` or `timezone`,
261
+ * which the specification types as an object.
262
+ */
263
+ export declare const Schedule: () => z.ZodObject<{
264
+ id: z.ZodString;
265
+ userId: z.ZodString;
266
+ name: z.ZodString;
267
+ cronExpression: z.ZodString;
268
+ timezone: z.ZodString;
269
+ isEnabled: z.ZodBoolean;
270
+ isExclusive: z.ZodBoolean;
271
+ createdAt: z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>;
272
+ modifiedAt: z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>;
273
+ nextRunAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
274
+ lastRunAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
275
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
277
+ notifications: z.ZodOptional<z.ZodObject<{
278
+ email: z.ZodOptional<z.ZodBoolean>;
279
+ }, z.core.$loose>>;
280
+ integrationTracking: z.ZodOptional<z.ZodObject<{
281
+ platform: z.ZodOptional<z.ZodString>;
282
+ appId: z.ZodOptional<z.ZodString>;
283
+ isAiTool: z.ZodOptional<z.ZodBoolean>;
284
+ }, z.core.$loose>>;
285
+ actions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
286
+ id: z.ZodString;
287
+ type: z.ZodLiteral<"RUN_ACTOR">;
288
+ actorId: z.ZodString;
289
+ runInput: z.ZodOptional<z.ZodNullable<z.ZodObject<{
290
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
291
+ contentType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
292
+ }, z.core.$loose>>>;
293
+ runOptions: z.ZodOptional<z.ZodNullable<z.ZodObject<{
294
+ build: z.ZodOptional<z.ZodNullable<z.ZodString>>;
295
+ timeoutSecs: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
296
+ memoryMbytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
297
+ maxItems: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
298
+ maxTotalChargeUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
299
+ restartOnError: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
300
+ isMaxTotalChargeUsdSetByUser: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
301
+ forcePermissionLevel: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodEnum<{
302
+ FULL_PERMISSIONS: "FULL_PERMISSIONS";
303
+ LIMITED_PERMISSIONS: "LIMITED_PERMISSIONS";
304
+ }>, z.ZodString]>>>;
305
+ }, z.core.$loose>>>;
306
+ }, z.core.$loose>, z.ZodObject<{
307
+ id: z.ZodString;
308
+ type: z.ZodLiteral<"RUN_ACTOR_TASK">;
309
+ actorTaskId: z.ZodString;
310
+ input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
311
+ }, z.core.$loose>], "type">>;
312
+ uiState: z.ZodOptional<z.ZodNullable<z.ZodObject<{
313
+ version: z.ZodOptional<z.ZodInt>;
314
+ data: z.ZodOptional<z.ZodObject<{
315
+ cronExpression: z.ZodOptional<z.ZodString>;
316
+ timezone: z.ZodOptional<z.ZodString>;
317
+ }, z.core.$loose>>;
318
+ }, z.core.$loose>>>;
319
+ }, z.core.$loose>;
320
+ /** Response containing schedule data. */
321
+ export declare const ScheduleResponse: () => z.ZodObject<{
322
+ data: z.ZodObject<{
323
+ id: z.ZodString;
324
+ userId: z.ZodString;
325
+ name: z.ZodString;
326
+ cronExpression: z.ZodString;
327
+ timezone: z.ZodString;
328
+ isEnabled: z.ZodBoolean;
329
+ isExclusive: z.ZodBoolean;
330
+ createdAt: z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>;
331
+ modifiedAt: z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>;
332
+ nextRunAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
333
+ lastRunAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
334
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
335
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
336
+ notifications: z.ZodOptional<z.ZodObject<{
337
+ email: z.ZodOptional<z.ZodBoolean>;
338
+ }, z.core.$loose>>;
339
+ integrationTracking: z.ZodOptional<z.ZodObject<{
340
+ platform: z.ZodOptional<z.ZodString>;
341
+ appId: z.ZodOptional<z.ZodString>;
342
+ isAiTool: z.ZodOptional<z.ZodBoolean>;
343
+ }, z.core.$loose>>;
344
+ actions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
345
+ id: z.ZodString;
346
+ type: z.ZodLiteral<"RUN_ACTOR">;
347
+ actorId: z.ZodString;
348
+ runInput: z.ZodOptional<z.ZodNullable<z.ZodObject<{
349
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
350
+ contentType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
351
+ }, z.core.$loose>>>;
352
+ runOptions: z.ZodOptional<z.ZodNullable<z.ZodObject<{
353
+ build: z.ZodOptional<z.ZodNullable<z.ZodString>>;
354
+ timeoutSecs: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
355
+ memoryMbytes: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
356
+ maxItems: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
357
+ maxTotalChargeUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
358
+ restartOnError: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
359
+ isMaxTotalChargeUsdSetByUser: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
360
+ forcePermissionLevel: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodEnum<{
361
+ FULL_PERMISSIONS: "FULL_PERMISSIONS";
362
+ LIMITED_PERMISSIONS: "LIMITED_PERMISSIONS";
363
+ }>, z.ZodString]>>>;
364
+ }, z.core.$loose>>>;
365
+ }, z.core.$loose>, z.ZodObject<{
366
+ id: z.ZodString;
367
+ type: z.ZodLiteral<"RUN_ACTOR_TASK">;
368
+ actorTaskId: z.ZodString;
369
+ input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
370
+ }, z.core.$loose>], "type">>;
371
+ uiState: z.ZodOptional<z.ZodNullable<z.ZodObject<{
372
+ version: z.ZodOptional<z.ZodInt>;
373
+ data: z.ZodOptional<z.ZodObject<{
374
+ cronExpression: z.ZodOptional<z.ZodString>;
375
+ timezone: z.ZodOptional<z.ZodString>;
376
+ }, z.core.$loose>>;
377
+ }, z.core.$loose>>>;
378
+ }, z.core.$loose>;
379
+ }, z.core.$loose>;
package/dist/schemas.js CHANGED
@@ -1,15 +1,37 @@
1
1
  /**
2
2
  * The schemas the resource clients validate API responses with.
3
3
  *
4
- * Today these are exactly the generated ones. The module still exists as the one place where a generated
5
- * schema is widened when the API is known to return something the specification does not describe, so a
6
- * documented deviation never sends a resource client reaching into `./generated` directly. An override
4
+ * Most of these are the generated ones. This module is the one place where a generated schema is widened
5
+ * when the API is known to return something the specification does not describe, so a documented deviation
6
+ * never sends a resource client reaching into `./generated` directly. An override
7
7
  * declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
8
8
  * built on the generated schema it replaces. Every schema that embeds an overridden one has to be rebuilt on
9
- * top of it, and `spec_guards.ts` checks that each override still accepts what the specification describes,
9
+ * top of it, and `spec_guards.ts` checks that each override still produces what the specification describes,
10
10
  * so one cannot narrow by accident.
11
11
  *
12
12
  * Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
13
13
  * through. Neither do client narrowings: a schema only ever accepts more than the published type.
14
14
  */
15
+ import { z } from 'zod';
16
+ import * as generated from './generated/schemas.js';
17
+ import { lazySchema } from './lazy_schema.js';
15
18
  export * from './generated/schemas.js';
19
+ /** The API returns `actVersion.buildTag` as `null` for some builds, which the specification types as a string. */
20
+ export const Build = lazySchema(() => {
21
+ const generatedBuild = generated.Build();
22
+ return generatedBuild.extend({
23
+ actVersion: generatedBuild.shape.actVersion
24
+ .unwrap()
25
+ .extend({ buildTag: z.string().nullable().optional() })
26
+ .optional(),
27
+ });
28
+ });
29
+ /** Response containing Actor build data. */
30
+ export const BuildResponse = lazySchema(() => generated.BuildResponse().extend({ data: Build() }));
31
+ /**
32
+ * The API returns `uiState` as `null` once an API update has changed the schedule's `cronExpression` or `timezone`,
33
+ * which the specification types as an object.
34
+ */
35
+ export const Schedule = lazySchema(() => generated.Schedule().extend({ uiState: generated.ScheduleUiState().nullable().optional() }));
36
+ /** Response containing schedule data. */
37
+ export const ScheduleResponse = lazySchema(() => generated.ScheduleResponse().extend({ data: Schedule() }));
@@ -1,4 +1,5 @@
1
1
  export declare class Statistics {
2
+ #private;
2
3
  /**
3
4
  * Number of Apify client function calls
4
5
  */
@@ -13,10 +14,4 @@ export declare class Statistics {
13
14
  */
14
15
  rateLimitErrors: number[];
15
16
  addRateLimitError(attempt: number): void;
16
- /**
17
- * Removes the necessity to pre-initialize array with correct
18
- * number of zeroes by dynamically filling the empty indexes
19
- * when necessary.
20
- */
21
- private _fillBlanksWithZeroes;
22
17
  }
@@ -20,7 +20,7 @@ export class Statistics {
20
20
  // attempt is never 0,
21
21
  // but we don't want index 0 empty
22
22
  const index = attempt - 1;
23
- this._fillBlanksWithZeroes(index);
23
+ this.#fillBlanksWithZeroes(index);
24
24
  this.rateLimitErrors[index]++;
25
25
  }
26
26
  /**
@@ -28,7 +28,7 @@ export class Statistics {
28
28
  * number of zeroes by dynamically filling the empty indexes
29
29
  * when necessary.
30
30
  */
31
- _fillBlanksWithZeroes(inclusiveIndex) {
31
+ #fillBlanksWithZeroes(inclusiveIndex) {
32
32
  if (this.rateLimitErrors.length <= inclusiveIndex) {
33
33
  for (let k = 0; k <= inclusiveIndex; k++) {
34
34
  if (typeof this.rateLimitErrors[k] !== 'number') {
@@ -0,0 +1,84 @@
1
+ import { z } from 'zod';
2
+ /** Default duration of the `short` timeout tier, in seconds. */
3
+ export declare const DEFAULT_TIMEOUT_SHORT_SECS = 5;
4
+ /** Default duration of the `medium` timeout tier, in seconds. */
5
+ export declare const DEFAULT_TIMEOUT_MEDIUM_SECS = 30;
6
+ /** Default duration of the `long` timeout tier, in seconds. */
7
+ export declare const DEFAULT_TIMEOUT_LONG_SECS = 360;
8
+ /** Default cap on the timeout of a single request attempt, in seconds. */
9
+ export declare const DEFAULT_TIMEOUT_MAX_SECS = 360;
10
+ /**
11
+ * Preconfigured timeout tiers. Every client method picks the tier that fits the expected duration of its
12
+ * request: `short` for simple metadata reads and writes, `medium` for listing, batch and trigger operations,
13
+ * `long` for downloads, uploads and streaming. The duration of each tier is set on the {@link ApifyClient}
14
+ * constructor.
15
+ */
16
+ export type TimeoutTier = 'short' | 'medium' | 'long';
17
+ /**
18
+ * Timeout of a single API request.
19
+ *
20
+ * A tier name picks the duration configured for that tier on the {@link ApifyClient} constructor, a number is
21
+ * an exact duration in seconds, and `'noTimeout'` lets the request run for as long as it takes. A tier or an
22
+ * explicit duration above `timeoutMaxSecs` is capped at it, and the client logs a warning when that happens.
23
+ * The timeout applies to each attempt separately, and doubles with every retry up to the same cap.
24
+ *
25
+ * With `'noTimeout'` the client never aborts the request, so a connection that stalls is not retried either.
26
+ */
27
+ export type Timeout = TimeoutTier | 'noTimeout' | number;
28
+ /**
29
+ * Options shared by every method that sends a request to the API.
30
+ */
31
+ export interface TimeoutOptions {
32
+ /**
33
+ * Timeout for the API request: a tier name (`'short'`, `'medium'`, `'long'`), a number of seconds, or
34
+ * `'noTimeout'`. Defaults to the tier the method is assigned, which its documentation names.
35
+ */
36
+ timeoutSecs?: Timeout;
37
+ /**
38
+ * Aborts the method. Once the signal aborts, the request in flight is ended, no retry or further poll
39
+ * follows, and the method rejects with the signal's `reason`.
40
+ */
41
+ signal?: AbortSignal;
42
+ }
43
+ /**
44
+ * Schema of {@link Timeout}, optional, for the methods that validate `timeoutSecs` on its own.
45
+ * @internal
46
+ */
47
+ export declare const optionalTimeoutSchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
48
+ long: "long";
49
+ medium: "medium";
50
+ noTimeout: "noTimeout";
51
+ short: "short";
52
+ }>, z.ZodNumber]>>;
53
+ /**
54
+ * Schema of {@link TimeoutOptions.signal}, for the methods that validate `signal` on its own.
55
+ * @internal
56
+ */
57
+ export declare const optionalSignalSchema: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
58
+ /**
59
+ * Schema shape of {@link TimeoutOptions}, to spread into the option schema of every method that sends a
60
+ * request. One copy stops it drifting from the interface.
61
+ * @internal
62
+ */
63
+ export declare const timeoutOptionsShape: {
64
+ timeoutSecs: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
65
+ long: "long";
66
+ medium: "medium";
67
+ noTimeout: "noTimeout";
68
+ short: "short";
69
+ }>, z.ZodNumber]>>;
70
+ signal: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
71
+ };
72
+ /**
73
+ * Schema of {@link TimeoutOptions}, for the methods that take no other option.
74
+ * @internal
75
+ */
76
+ export declare const timeoutOptionsSchema: z.ZodObject<{
77
+ timeoutSecs: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
78
+ long: "long";
79
+ medium: "medium";
80
+ noTimeout: "noTimeout";
81
+ short: "short";
82
+ }>, z.ZodNumber]>>;
83
+ signal: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
84
+ }, z.core.$strict>;
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ /** Default duration of the `short` timeout tier, in seconds. */
3
+ export const DEFAULT_TIMEOUT_SHORT_SECS = 5;
4
+ /** Default duration of the `medium` timeout tier, in seconds. */
5
+ export const DEFAULT_TIMEOUT_MEDIUM_SECS = 30;
6
+ /** Default duration of the `long` timeout tier, in seconds. */
7
+ export const DEFAULT_TIMEOUT_LONG_SECS = 360;
8
+ /** Default cap on the timeout of a single request attempt, in seconds. */
9
+ export const DEFAULT_TIMEOUT_MAX_SECS = 360;
10
+ /**
11
+ * Schema of {@link Timeout}. Zero is rejected on purpose - `'noTimeout'` is the explicit way to run without one.
12
+ */
13
+ const timeoutSchema = z.union([z.enum(['short', 'medium', 'long', 'noTimeout']), z.number().positive()]);
14
+ /**
15
+ * Schema of {@link Timeout}, optional, for the methods that validate `timeoutSecs` on its own.
16
+ * @internal
17
+ */
18
+ export const optionalTimeoutSchema = timeoutSchema.optional();
19
+ /**
20
+ * Schema of {@link TimeoutOptions.signal}, for the methods that validate `signal` on its own.
21
+ * @internal
22
+ */
23
+ export const optionalSignalSchema = z.instanceof(AbortSignal).optional();
24
+ /**
25
+ * Schema shape of {@link TimeoutOptions}, to spread into the option schema of every method that sends a
26
+ * request. One copy stops it drifting from the interface.
27
+ * @internal
28
+ */
29
+ export const timeoutOptionsShape = {
30
+ timeoutSecs: optionalTimeoutSchema,
31
+ signal: optionalSignalSchema,
32
+ };
33
+ /**
34
+ * Schema of {@link TimeoutOptions}, for the methods that take no other option.
35
+ * @internal
36
+ */
37
+ export const timeoutOptionsSchema = z.strictObject(timeoutOptionsShape);