apify-client 3.0.0-beta.95 → 3.0.0-beta.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +9 -9
- package/dist/bundle.js.map +1 -1
- package/dist/http_clients/base.d.ts +5 -0
- package/dist/http_clients/base.js +1 -1
- package/dist/models.d.ts +14 -0
- package/dist/resource_clients/actor_server.d.ts +8 -0
- package/dist/resource_clients/actor_server.js +6 -2
- package/dist/resource_clients/actor_version.d.ts +5 -0
- package/package.json +1 -1
|
@@ -384,3 +384,8 @@ export declare abstract class HttpClient {
|
|
|
384
384
|
*/
|
|
385
385
|
protected computeTimeoutMillis(attempt: number, timeoutSecs?: Timeout): number | undefined;
|
|
386
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Merges two header records, header names compared case-insensitively. A header from `override` replaces a
|
|
389
|
+
* same-named header in `base` whatever the casing of either, and keeps the casing it was passed with.
|
|
390
|
+
*/
|
|
391
|
+
export declare function mergeHeaders(base: Record<string, string>, override?: Record<string, string>): Record<string, string>;
|
|
@@ -481,7 +481,7 @@ function getHeader(headers, name) {
|
|
|
481
481
|
* Merges two header records, header names compared case-insensitively. A header from `override` replaces a
|
|
482
482
|
* same-named header in `base` whatever the casing of either, and keeps the casing it was passed with.
|
|
483
483
|
*/
|
|
484
|
-
function mergeHeaders(base, override) {
|
|
484
|
+
export function mergeHeaders(base, override) {
|
|
485
485
|
const merged = { ...base };
|
|
486
486
|
for (const [key, value] of Object.entries(override ?? {})) {
|
|
487
487
|
for (const existing of Object.keys(merged)) {
|
package/dist/models.d.ts
CHANGED
|
@@ -213,6 +213,7 @@ export interface VersionRePointed {
|
|
|
213
213
|
}
|
|
214
214
|
export interface VersionClientNarrowings {
|
|
215
215
|
sourceType: `${ActorSourceType}`;
|
|
216
|
+
actorPath?: GeneratedVersion['actorPath'];
|
|
216
217
|
}
|
|
217
218
|
/**
|
|
218
219
|
* Fields every Actor version carries, whatever its source type.
|
|
@@ -220,6 +221,7 @@ export interface VersionClientNarrowings {
|
|
|
220
221
|
* The spec models a version as one flat object with all four source locations optional. This client
|
|
221
222
|
* keeps a union discriminated on `sourceType` instead, because that narrows the source location down
|
|
222
223
|
* to the single field which applies -- so the four are dropped here and reinstated per variant.
|
|
224
|
+
* `actorPath` is dropped as well, and only the `SOURCE_FILES` and `TARBALL` variants reinstate it.
|
|
223
225
|
*/
|
|
224
226
|
export interface BaseVersion<SourceType extends `${ActorSourceType}`> extends Omit<GeneratedVersion, keyof VersionClientNarrowings | keyof VersionRePointed | VersionSourceLocation>, VersionRePointed {
|
|
225
227
|
sourceType: SourceType;
|
|
@@ -230,6 +232,12 @@ export interface BaseVersion<SourceType extends `${ActorSourceType}`> extends Om
|
|
|
230
232
|
*/
|
|
231
233
|
export interface VersionSourceFiles extends BaseVersion<`${ActorSourceType.SourceFiles}`> {
|
|
232
234
|
sourceFiles: (SourceCodeFile | SourceCodeFolder)[];
|
|
235
|
+
/**
|
|
236
|
+
* The Actor's folder inside the uploaded source, as a POSIX path relative to the upload root, such as
|
|
237
|
+
* `actors/typescript-actor`. When absent or `null`, the upload root is the Actor's folder. It has 1 to 255
|
|
238
|
+
* characters, with no leading, trailing, or repeated `/` and no `.` or `..` segment.
|
|
239
|
+
*/
|
|
240
|
+
actorPath?: GeneratedVersion['actorPath'];
|
|
233
241
|
}
|
|
234
242
|
/** An Actor version built from a Git repository. */
|
|
235
243
|
export interface VersionGitRepo extends BaseVersion<`${ActorSourceType.GitRepo}`> {
|
|
@@ -238,6 +246,12 @@ export interface VersionGitRepo extends BaseVersion<`${ActorSourceType.GitRepo}`
|
|
|
238
246
|
/** An Actor version built from a downloadable tarball or ZIP archive. */
|
|
239
247
|
export interface VersionTarball extends BaseVersion<`${ActorSourceType.Tarball}`> {
|
|
240
248
|
tarballUrl: NonNullable<GeneratedVersion['tarballUrl']>;
|
|
249
|
+
/**
|
|
250
|
+
* The Actor's folder inside the archive, as a POSIX path relative to the archive root, such as
|
|
251
|
+
* `actors/typescript-actor`. When absent or `null`, the archive root is the Actor's folder. It has 1 to 255
|
|
252
|
+
* characters, with no leading, trailing, or repeated `/` and no `.` or `..` segment.
|
|
253
|
+
*/
|
|
254
|
+
actorPath?: GeneratedVersion['actorPath'];
|
|
241
255
|
}
|
|
242
256
|
/** An Actor version built from a GitHub Gist. */
|
|
243
257
|
export interface VersionGitHubGist extends BaseVersion<`${ActorSourceType.GitHubGist}`> {
|
|
@@ -85,6 +85,8 @@ export declare class ActorServerClient extends ResourceClient {
|
|
|
85
85
|
* @param options.headers - Additional headers of the request.
|
|
86
86
|
* @param options.data - Request body, serialized the same way as for API calls: a plain object or array is sent
|
|
87
87
|
* as JSON, and a string or binary value as it is.
|
|
88
|
+
* @param options.parentRequestId - The `X-Actor-Request-ID` header of the request your Server Actor is handling,
|
|
89
|
+
* sent on as the same header so the called Actor charges at that request's pricing tier.
|
|
88
90
|
* @param options.compression - Compression algorithm for the request body, as a name or an {@link HttpCompressor}.
|
|
89
91
|
* The body is compressed under the same conditions as for API calls. Set it only if the Actor's server decodes
|
|
90
92
|
* the resulting `Content-Encoding`.
|
|
@@ -127,6 +129,12 @@ export interface ActorServerRequestOptions extends TimeoutOptions {
|
|
|
127
129
|
* or binary value as it is.
|
|
128
130
|
*/
|
|
129
131
|
data?: unknown;
|
|
132
|
+
/**
|
|
133
|
+
* The `X-Actor-Request-ID` header of the request your Server Actor is handling. It's sent on as the same header,
|
|
134
|
+
* so the called Actor charges at that request's pricing tier.
|
|
135
|
+
* @see https://docs.apify.com/platform/actors/development/programming-interface/standby#compose-server-actors
|
|
136
|
+
*/
|
|
137
|
+
parentRequestId?: string;
|
|
130
138
|
/**
|
|
131
139
|
* Compression algorithm for the request body, as a name or an {@link HttpCompressor}. The body is sent
|
|
132
140
|
* uncompressed when it's not set, since the Actor's server may not decode a compressed body.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ApifyClientError } from '../apify_client_error.js';
|
|
3
3
|
import { ResourceClient } from '../base/resource_client.js';
|
|
4
|
+
import { mergeHeaders } from '../http_clients/base.js';
|
|
4
5
|
import { compressionSchema, resolveCompressor } from '../http_compressors/resolve.js';
|
|
5
6
|
import * as schemas from '../schemas.js';
|
|
6
7
|
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
@@ -38,6 +39,7 @@ const requestOptionsSchema = z.strictObject({
|
|
|
38
39
|
params: z.record(z.string(), z.unknown()).optional(),
|
|
39
40
|
headers: z.record(z.string(), z.string()).optional(),
|
|
40
41
|
data: z.unknown().optional(),
|
|
42
|
+
parentRequestId: z.string().optional(),
|
|
41
43
|
compression: compressionSchema.optional(),
|
|
42
44
|
responseType: z.enum(['parsed', 'buffer', 'stream']).optional(),
|
|
43
45
|
...timeoutOptionsShape,
|
|
@@ -151,7 +153,7 @@ export class ActorServerClient extends ResourceClient {
|
|
|
151
153
|
}
|
|
152
154
|
async request(path = '/', options = {}) {
|
|
153
155
|
parseArgument(path, z.string());
|
|
154
|
-
const { method = 'GET', params, headers, data, compression, responseType, timeoutSecs = 'long', signal, } = parseArgument(options, requestOptionsSchema, 'ActorServerRequestOptions');
|
|
156
|
+
const { method = 'GET', params, headers, data, parentRequestId, compression, responseType, timeoutSecs = 'long', signal, } = parseArgument(options, requestOptionsSchema, 'ActorServerRequestOptions');
|
|
155
157
|
if (responseType === 'stream' && !runtime.isNode) {
|
|
156
158
|
throw new Error("The 'stream' response type can only be used in Node.js environment.");
|
|
157
159
|
}
|
|
@@ -161,7 +163,9 @@ export class ActorServerClient extends ResourceClient {
|
|
|
161
163
|
url: `${serverUrl.replace(/\/+$/, '')}/${serverPath}`,
|
|
162
164
|
method,
|
|
163
165
|
params,
|
|
164
|
-
headers
|
|
166
|
+
headers: parentRequestId === undefined
|
|
167
|
+
? headers
|
|
168
|
+
: mergeHeaders(headers ?? {}, { 'X-Actor-Request-ID': parentRequestId }),
|
|
165
169
|
data,
|
|
166
170
|
compression: compression === undefined ? false : resolveCompressor(compression),
|
|
167
171
|
authorizationHeader: 'X-Apify-Authorization',
|
|
@@ -83,5 +83,10 @@ export declare class ActorVersionClient extends ResourceClient {
|
|
|
83
83
|
* All of them are optional, because the endpoint leaves untouched whatever the payload does not
|
|
84
84
|
* mention. The version union enforces the pairing: a `sourceType` can only be sent next to the
|
|
85
85
|
* source location it implies, never next to one of the other three.
|
|
86
|
+
*
|
|
87
|
+
* On a `SOURCE_FILES` or `TARBALL` version, `actorPath: null` removes the stored path. So does an
|
|
88
|
+
* update that sends `sourceType`, `sourceFiles`, or `tarballUrl` without `actorPath`, so send it
|
|
89
|
+
* again with every upload. The API rejects an `actorPath` on a version of any other source type,
|
|
90
|
+
* also when the update leaves out `sourceType`, because it then checks the stored source type.
|
|
86
91
|
*/
|
|
87
92
|
export type ActorVersionUpdateData = Partial<Version>;
|