apify-client 3.0.0-beta.21 → 3.0.0-beta.23

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/utils.d.ts CHANGED
@@ -4,9 +4,15 @@ import { z } from 'zod';
4
4
  import type { ApifyApiError } from './apify_api_error.js';
5
5
  import { parseArgument } from '@apify/validations';
6
6
  import type { ApifyResponse } from './http_client.js';
7
- import type { CompressedValue } from './runtime/types.js';
8
7
  import type { RequestQueueClientListRequestsOptions, RequestQueueClientListRequestsResult } from './resource_clients/request_queue.js';
9
8
  import type { WebhookUpdateData } from './resource_clients/webhook.js';
9
+ /**
10
+ * Smallest request body, in bytes, that is worth compressing. A smaller body already fits in a single network
11
+ * packet, so compressing it costs CPU time without saving a round trip, and the compression format itself can
12
+ * make it larger.
13
+ * @internal
14
+ */
15
+ export declare const MIN_COMPRESS_BYTES = 1024;
10
16
  export declare const version: any;
11
17
  export { parseArgument };
12
18
  /**
@@ -71,6 +77,12 @@ export declare function bytesToBase64(bytes: Uint8Array): string;
71
77
  * Concatenates byte chunks into one array.
72
78
  */
73
79
  export declare function concatBytes(chunks: Uint8Array[]): Uint8Array;
80
+ /**
81
+ * Views a request body as bytes: a string is UTF-8 encoded, binary values are viewed in place. Anything else
82
+ * - a stream, a `Blob`, form data - is `undefined`.
83
+ * @internal
84
+ */
85
+ export declare function toBytes(value: unknown): Uint8Array | undefined;
74
86
  /**
75
87
  * Decides whether a request body with the given content type is worth compressing.
76
88
  *
@@ -81,11 +93,6 @@ export declare function concatBytes(chunks: Uint8Array[]): Uint8Array;
81
93
  * @internal
82
94
  */
83
95
  export declare function isCompressibleContentType(contentType?: string): boolean;
84
- /**
85
- * Compresses the passed value with the runtime's best available algorithm. Returns `undefined` if the data
86
- * is too small, is not a string or binary value, or if the runtime does not offer compression.
87
- */
88
- export declare function maybeCompressValue(value: unknown): Promise<CompressedValue | undefined>;
89
96
  /**
90
97
  * Reads an environment variable, on runtimes that have them.
91
98
  */
package/dist/utils.js CHANGED
@@ -1,11 +1,16 @@
1
1
  import { z } from 'zod';
2
2
  import { NotFoundError } from './apify_api_error.js';
3
3
  import { parseArgument } from '@apify/validations';
4
- import { runtime } from '#runtime';
5
4
  import { ResponseValidationError } from './response_validation_error.js';
6
5
  // @ts-ignore if we enable `resolveJsonModule`, we end up with a `src` folder in `dist`
7
6
  import packageJson from '../package.json' with { type: 'json' };
8
- const MIN_COMPRESS_BYTES = 1024;
7
+ /**
8
+ * Smallest request body, in bytes, that is worth compressing. A smaller body already fits in a single network
9
+ * packet, so compressing it costs CPU time without saving a round trip, and the compression format itself can
10
+ * make it larger.
11
+ * @internal
12
+ */
13
+ export const MIN_COMPRESS_BYTES = 1024;
9
14
  const textEncoder = new TextEncoder();
10
15
  // Only the version, so a bundler can drop the rest of the manifest.
11
16
  export const { version } = packageJson;
@@ -160,8 +165,9 @@ export function concatBytes(chunks) {
160
165
  /**
161
166
  * Views a request body as bytes: a string is UTF-8 encoded, binary values are viewed in place. Anything else
162
167
  * - a stream, a `Blob`, form data - is `undefined`.
168
+ * @internal
163
169
  */
164
- function toBytes(value) {
170
+ export function toBytes(value) {
165
171
  if (typeof value === 'string')
166
172
  return textEncoder.encode(value);
167
173
  if (!isBuffer(value))
@@ -192,18 +198,6 @@ export function isCompressibleContentType(contentType) {
192
198
  return false;
193
199
  return !ALREADY_COMPRESSED_MEDIA_TYPE_PREFIXES.some((prefix) => mediaType.startsWith(prefix));
194
200
  }
195
- /**
196
- * Compresses the passed value with the runtime's best available algorithm. Returns `undefined` if the data
197
- * is too small, is not a string or binary value, or if the runtime does not offer compression.
198
- */
199
- export async function maybeCompressValue(value) {
200
- // Request compression is not that important so let's
201
- // skip it instead of throwing for unsupported types.
202
- const bytes = toBytes(value);
203
- if (!bytes || bytes.byteLength < MIN_COMPRESS_BYTES)
204
- return undefined;
205
- return runtime.compress(bytes);
206
- }
207
201
  /**
208
202
  * Reads an environment variable, on runtimes that have them.
209
203
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-client",
3
- "version": "3.0.0-beta.21",
3
+ "version": "3.0.0-beta.23",
4
4
  "description": "Apify API client for JavaScript",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"