bc-api-client 0.2.2 → 1.0.0-beta.2

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.
@@ -0,0 +1,1013 @@
1
+ import { HTTPError, KyRequest, Options, TimeoutError } from "ky";
2
+
3
+ //#region src/lib/common.d.ts
4
+ type ConcurrencyOptions = {
5
+ /** Max concurrent requests. Must be 1–1000. `false` for sequential. Defaults to 10. */concurrency?: number | false;
6
+ /**
7
+ * Divisor (or `(concurrency, status) => number` function) applied to concurrency on
8
+ * non-429 error responses. Defaults to 2.
9
+ */
10
+ backoff?: ((concurrency: number, status: number) => number) | number; /** Concurrency cap applied when a 429 response is received. Defaults to 1. */
11
+ rateLimitBackoff?: number;
12
+ /**
13
+ * Amount (or `(concurrency) => number` function) added to concurrency per successful
14
+ * response while below the configured max. Defaults to 1.
15
+ */
16
+ backoffRecover?: ((concurrency: number) => number) | number;
17
+ };
18
+ /**
19
+ * Configuration options for the BigCommerce client.
20
+ */
21
+ interface ClientConfig extends Omit<Options, 'throwHttpErrors' | 'parseJson' | 'method' | 'body' | 'json' | 'searchParams'>, ConcurrencyOptions {
22
+ storeHash: string;
23
+ accessToken: string;
24
+ logger?: Logger | LogLevel | boolean;
25
+ }
26
+ //#endregion
27
+ //#region src/lib/logger.d.ts
28
+ /**
29
+ * Logging interface for the BigCommerce client.
30
+ *
31
+ * Implement this interface to provide custom logging. The client passes context data
32
+ * as the first argument, making it compatible with structured loggers.
33
+ */
34
+ interface Logger {
35
+ debug(data: Record<string, unknown>, message?: string): void;
36
+ info(data: Record<string, unknown>, message?: string): void;
37
+ warn(data: Record<string, unknown>, message?: string): void;
38
+ error(data: Record<string, unknown>, message?: string): void;
39
+ }
40
+ type PowertoolsLikeLogger = {
41
+ debug(message: string, ...data: Record<string, unknown>[]): void;
42
+ info(message: string, ...data: Record<string, unknown>[]): void;
43
+ warn(message: string, ...data: Record<string, unknown>[]): void;
44
+ error(message: string, ...data: Record<string, unknown>[]): void;
45
+ };
46
+ /** @internal */
47
+ declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
48
+ /** Supported log levels. */
49
+ type LogLevel = (typeof LOG_LEVELS)[number];
50
+ /**
51
+ * Adapts an AWS Lambda Powertools logger to the {@link Logger} interface expected by
52
+ * {@link BigCommerceClient} and {@link BigCommerceAuth}.
53
+ *
54
+ * Powertools loggers use `(message, ...data)` argument order whereas this library uses
55
+ * `(data, message)`. This adapter swaps the arguments.
56
+ *
57
+ * @param logger - An AWS Lambda Powertools (or any {@link PowertoolsLikeLogger}-compatible) logger.
58
+ * @returns A {@link Logger} wrapper suitable for `config.logger`.
59
+ */
60
+ declare const fromAwsPowertoolsLogger: (logger: PowertoolsLikeLogger) => Logger;
61
+ /**
62
+ * Console-based {@link Logger} that filters messages below a minimum level.
63
+ *
64
+ * Used automatically when `config.logger` is `true`, `undefined`, or a {@link LogLevel} string.
65
+ * Can also be instantiated directly for custom log level control.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * new BigCommerceClient({ ..., logger: new FallbackLogger('debug') });
70
+ * ```
71
+ */
72
+ declare class FallbackLogger implements Logger {
73
+ readonly level: LogLevel;
74
+ /**
75
+ * @param level - Minimum level to output. Messages below this level are silently dropped.
76
+ */
77
+ constructor(level: LogLevel);
78
+ debug(data: Record<string, unknown>, message?: string): void;
79
+ info(data: Record<string, unknown>, message?: string): void;
80
+ warn(data: Record<string, unknown>, message?: string): void;
81
+ error(data: Record<string, unknown>, message?: string): void;
82
+ private log;
83
+ }
84
+ //#endregion
85
+ //#region src/auth.d.ts
86
+ /**
87
+ * Configuration options for BigCommerce authentication
88
+ */
89
+ type BigCommerceAuthConfig = {
90
+ /** The OAuth client ID from BigCommerce */clientId: string; /** The OAuth client secret from BigCommerce */
91
+ secret: string; /** The redirect URI registered with BigCommerce */
92
+ redirectUri: string; /** Optional array of scopes to validate during auth callback */
93
+ scopes?: string[]; /** Optional logger instance */
94
+ logger?: Logger | LogLevel | boolean;
95
+ };
96
+ /**
97
+ * Query parameters received from BigCommerce auth callback
98
+ */
99
+ type BigCommerceAuthQuery = {
100
+ /** The authorization code from BigCommerce */code: string; /** The granted OAuth scopes */
101
+ scope: string; /** The store context */
102
+ context: string;
103
+ };
104
+ /**
105
+ * User information returned from BigCommerce
106
+ */
107
+ type User = {
108
+ /** The user's ID */id: number; /** The user's username */
109
+ username: string; /** The user's email address */
110
+ email: string;
111
+ };
112
+ /**
113
+ * Response from BigCommerce token endpoint
114
+ */
115
+ type TokenResponse = {
116
+ /** The OAuth access token */access_token: string; /** The granted OAuth scopes */
117
+ scope: string; /** Information about the authenticated user */
118
+ user: User; /** Information about the store owner */
119
+ owner: User; /** The store context */
120
+ context: string; /** The BigCommerce account UUID */
121
+ account_uuid: string;
122
+ };
123
+ /**
124
+ * JWT claims from BigCommerce
125
+ */
126
+ type Claims = {
127
+ /** JWT audience */aud: string; /** JWT issuer */
128
+ iss: string; /** JWT issued at timestamp */
129
+ iat: number; /** JWT not before timestamp */
130
+ nbf: number; /** JWT expiration timestamp */
131
+ exp: number; /** JWT unique identifier */
132
+ jti: string; /** JWT subject */
133
+ sub: string; /** Information about the authenticated user */
134
+ user: {
135
+ id: number;
136
+ email: string;
137
+ locale: string;
138
+ }; /** Information about the store owner */
139
+ owner: {
140
+ id: number;
141
+ email: string;
142
+ }; /** The store URL */
143
+ url: string; /** The channel ID (if applicable) */
144
+ channel_id: number | null;
145
+ };
146
+ /**
147
+ * Handles authentication with BigCommerce OAuth
148
+ */
149
+ declare class BigCommerceAuth {
150
+ private readonly config;
151
+ private readonly logger;
152
+ private readonly client;
153
+ /**
154
+ * Creates a new BigCommerceAuth instance for handling OAuth authentication
155
+ * @param config - Configuration options for BigCommerce authentication
156
+ * @param config.clientId - The OAuth client ID from BigCommerce
157
+ * @param config.secret - The OAuth client secret from BigCommerce
158
+ * @param config.redirectUri - The redirect URI registered with BigCommerce
159
+ * @param config.scopes - Optional array of scopes to validate during auth callback
160
+ * @param config.logger - Optional logger instance for debugging and error tracking
161
+ * @throws {BCAuthInvalidRedirectUriError} If the redirect URI is invalid
162
+ */
163
+ constructor(config: BigCommerceAuthConfig);
164
+ /**
165
+ * Exchanges an OAuth authorization code for an access token.
166
+ *
167
+ * @param data - The auth callback payload: a raw query string, `URLSearchParams`, or a
168
+ * pre-parsed object with `code`, `scope`, and `context`.
169
+ * @returns The token response including `access_token`, `user`, and `context`.
170
+ * @throws {@link BCAuthMissingParamError} if `code`, `scope`, or `context` are absent.
171
+ * @throws {@link BCAuthScopeMismatchError} if the granted scopes don't include all `config.scopes`.
172
+ * @throws {@link BCApiError} on HTTP error responses from the token endpoint.
173
+ * @throws {@link BCTimeoutError} if the token request times out.
174
+ * @throws {@link BCClientError} on any other error.
175
+ */
176
+ requestToken(data: string | BigCommerceAuthQuery | URLSearchParams): Promise<TokenResponse>;
177
+ /**
178
+ * Verifies a JWT payload from BigCommerce
179
+ * @param jwtPayload - The JWT string to verify
180
+ * @param storeHash - The store hash for the BigCommerce store
181
+ * @returns Promise resolving to the verified JWT claims
182
+ * @throws {BCAuthInvalidJwtError} If the JWT is invalid
183
+ */
184
+ verify(jwtPayload: string, storeHash: string): Promise<Claims>;
185
+ /**
186
+ * Parses and validates a query string from BigCommerce auth callback
187
+ * @param queryString - The query string to parse
188
+ * @returns The parsed auth query parameters
189
+ * @throws {BCAuthMissingParamError} If required parameters are missing
190
+ */
191
+ private parseQueryString;
192
+ /**
193
+ * Validates that the granted scopes match the expected scopes
194
+ * @param scopes - Space-separated list of granted scopes
195
+ * @throws {BCAuthScopeMismatchError} If the scopes don't match the expected scopes
196
+ */
197
+ private validateScopes;
198
+ }
199
+ //#endregion
200
+ //#region src/lib/standard-schema.d.ts
201
+ /** The Standard Schema interface. */
202
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
203
+ /** The Standard Schema properties. */
204
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>;
205
+ }
206
+ declare namespace StandardSchemaV1 {
207
+ /** The Standard Schema properties interface. */
208
+ interface Props<Input = unknown, Output = Input> {
209
+ /** The version number of the standard. */
210
+ readonly version: 1;
211
+ /** The vendor name of the schema library. */
212
+ readonly vendor: string;
213
+ /** Validates unknown input values. */
214
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
215
+ /** Inferred types associated with the schema. */
216
+ readonly types?: Types<Input, Output> | undefined;
217
+ }
218
+ /** The result interface of the validate function. */
219
+ type Result<Output> = SuccessResult<Output> | FailureResult;
220
+ /** The result interface if validation succeeds. */
221
+ interface SuccessResult<Output> {
222
+ /** The typed output value. */
223
+ readonly value: Output;
224
+ /** A falsy value for `issues` indicates success. */
225
+ readonly issues?: undefined;
226
+ }
227
+ interface Options {
228
+ /** Explicit support for additional vendor-specific parameters, if needed. */
229
+ readonly libraryOptions?: Record<string, unknown> | undefined;
230
+ }
231
+ /** The result interface if validation fails. */
232
+ interface FailureResult {
233
+ /** The issues of failed validation. */
234
+ readonly issues: ReadonlyArray<Issue>;
235
+ }
236
+ /** The issue interface of the failure output. */
237
+ interface Issue {
238
+ /** The error message of the issue. */
239
+ readonly message: string;
240
+ /** The path of the issue, if any. */
241
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
242
+ }
243
+ /** The path segment interface of the issue. */
244
+ interface PathSegment {
245
+ /** The key representing a path segment. */
246
+ readonly key: PropertyKey;
247
+ }
248
+ /** The Standard Schema types interface. */
249
+ interface Types<Input = unknown, Output = Input> {
250
+ /** The input type of the schema. */
251
+ readonly input: Input;
252
+ /** The output type of the schema. */
253
+ readonly output: Output;
254
+ }
255
+ /** Infers the input type of a Standard Schema. */
256
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
257
+ /** Infers the output type of a Standard Schema. */
258
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
259
+ }
260
+ //#endregion
261
+ //#region src/lib/request.d.ts
262
+ /** BigCommerce API versions supported by the client. */
263
+ type ApiVersion = 'v3' | 'v2';
264
+ /** Valid query parameter value types. */
265
+ type QueryValue = string | number | Array<string | number>;
266
+ /** Query parameter object for API requests. */
267
+ type Query = Record<string, QueryValue>;
268
+ /** Supported HTTP methods for API requests. */
269
+ type HttpMethod = 'POST' | 'GET' | 'PUT' | 'DELETE';
270
+ /** @internal */
271
+ type BaseKyRequest = Omit<Options, 'json' | 'method' | 'searchQueryParams' | 'body' | 'throwHttpErrors' | 'parseJson'>;
272
+ /** @internal */
273
+ type QuerySchemaOptions<TQuery extends Query> = /** Query parameters to send with the request. */{
274
+ query: TQuery;
275
+ querySchema: StandardSchemaV1<TQuery>;
276
+ } | {
277
+ query?: TQuery;
278
+ querySchema?: never;
279
+ };
280
+ /** @internal */
281
+ type BodySchemaOptions<TBody> = /** Request body, serialized as JSON. */{
282
+ body: TBody;
283
+ bodySchema: StandardSchemaV1<TBody>;
284
+ } | {
285
+ body?: TBody;
286
+ bodySchema?: never;
287
+ };
288
+ /**
289
+ * Full request options for direct API calls.
290
+ * @see {@link GetOptions}, {@link PostOptions}, {@link PutOptions}, {@link DeleteOptions}
291
+ */
292
+ type RequestOptions<TBody, TRes, TQuery extends Query> = BaseKyRequest & QuerySchemaOptions<TQuery> & BodySchemaOptions<TBody> & {
293
+ /** HTTP method for the request. */method: HttpMethod; /** API version to use. Defaults to `'v3'`. */
294
+ version?: ApiVersion; /** Schema to validate the response body. */
295
+ responseSchema?: StandardSchemaV1<TRes>;
296
+ };
297
+ /** Options for GET requests. */
298
+ type GetOptions<TRes, TQuery extends Query> = Omit<RequestOptions<never, TRes, TQuery>, 'body' | 'bodySchema' | 'method'>;
299
+ /** Options for POST requests. */
300
+ type PostOptions<TBody, TRes, TQuery extends Query> = Omit<RequestOptions<TBody, TRes, TQuery>, 'method'>;
301
+ /** Options for PUT requests. */
302
+ type PutOptions<TBody, TRes, TQuery extends Query> = PostOptions<TBody, TRes, TQuery>;
303
+ /** Options for DELETE requests. */
304
+ type DeleteOptions<TQuery extends Query> = Omit<RequestOptions<never, never, TQuery>, 'body' | 'bodySchema' | 'method' | 'responseSchema'>;
305
+ /**
306
+ * Request descriptor for batch operations.
307
+ * Use the {@link req} helpers to construct these.
308
+ */
309
+ type BatchRequestOptions<TBody, TRes, TQuery extends Query> = {
310
+ path: string;
311
+ } & RequestOptions<TBody, TRes, TQuery>;
312
+ /**
313
+ * Helpers for building typed request descriptors to pass to
314
+ * {@link BigCommerceClient.batchSafe} or {@link BigCommerceClient.batchStream}.
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * const results = await client.batchSafe([
319
+ * req.get('catalog/products/1'),
320
+ * req.post('catalog/products', { body: { name: 'Widget' } }),
321
+ * ]);
322
+ * ```
323
+ */
324
+ declare const req: {
325
+ /**
326
+ * Builds a GET request descriptor.
327
+ * @param path - API path relative to the store's versioned base URL.
328
+ * @param options - Optional query params, schemas, and ky options.
329
+ */
330
+ get: <TRes, TQuery extends Query = Query>(path: string, options?: GetOptions<TRes, TQuery>) => BatchRequestOptions<never, TRes, TQuery>;
331
+ /**
332
+ * Builds a POST request descriptor.
333
+ * @param path - API path relative to the store's versioned base URL.
334
+ * @param options - Optional body, query params, schemas, and ky options.
335
+ */
336
+ post: <TRes, TBody = unknown, TQuery extends Query = Query>(path: string, options?: PostOptions<TBody, TRes, TQuery>) => BatchRequestOptions<TBody, TRes, TQuery>;
337
+ /**
338
+ * Builds a PUT request descriptor.
339
+ * @param path - API path relative to the store's versioned base URL.
340
+ * @param options - Optional body, query params, schemas, and ky options.
341
+ */
342
+ put: <TRes, TBody = unknown, TQuery extends Query = Query>(path: string, options?: PutOptions<TBody, TRes, TQuery>) => BatchRequestOptions<TBody, TRes, TQuery>;
343
+ /**
344
+ * Builds a DELETE request descriptor.
345
+ * @param path - API path relative to the store's versioned base URL.
346
+ * @param options - Optional query params and ky options.
347
+ */
348
+ delete: <TQuery extends Query = Query>(path: string, options?: DeleteOptions<TQuery>) => BatchRequestOptions<never, never, TQuery>;
349
+ };
350
+ /**
351
+ * Options for v3 paginated collection operations ({@link BigCommerceClient.collect}, {@link BigCommerceClient.stream}).
352
+ */
353
+ type CollectOptions<TItem, TQuery extends Query> = ConcurrencyOptions & Omit<GetOptions<TItem, TQuery>, 'responseSchema' | 'version'> & {
354
+ /** Schema to validate each item in the response. */itemSchema?: StandardSchemaV1<TItem>;
355
+ };
356
+ type BlindOptions<TItem, TQuery extends Query> = Omit<CollectOptions<TItem, TQuery>, 'version'> & {
357
+ maxPages?: number;
358
+ };
359
+ /**
360
+ * Options for v2 paginated operations with known count ({@link BigCommerceClient.collectCount}, {@link BigCommerceClient.streamCount}).
361
+ */
362
+ type CountedCollectOptions<TItem, TQuery extends Query> = CollectOptions<TItem, TQuery> & {
363
+ /** Total number of items expected (for v2 endpoints without pagination metadata). */count?: number;
364
+ };
365
+ /**
366
+ * Options for query-based filtering operations ({@link BigCommerceClient.query}, {@link BigCommerceClient.queryStream}).
367
+ */
368
+ type QueryOptions<TItem, TQuery extends Query> = CollectOptions<TItem, TQuery> & {
369
+ /** Query parameter name for value filtering (e.g., `'id:in'`). */key: string; /** Values to filter by. Automatically chunked across multiple requests. */
370
+ values: (string | number)[];
371
+ };
372
+ //#endregion
373
+ //#region src/lib/errors.d.ts
374
+ type ErrorContext = Record<string, unknown>;
375
+ /**
376
+ * Abstract base class for all library errors. Carries a typed `context` object with
377
+ * structured diagnostic data and a machine-readable `code` string.
378
+ *
379
+ * Use `instanceof` checks against specific subclasses rather than this base class.
380
+ */
381
+ declare abstract class BaseError<TContext extends ErrorContext = ErrorContext> extends Error {
382
+ readonly context: TContext;
383
+ /** Machine-readable error code. Unique per subclass. */
384
+ abstract readonly code: string;
385
+ constructor(message: string, context: TContext, options?: ErrorOptions);
386
+ /** @internal */
387
+ toJSON(): {
388
+ name: string;
389
+ code: string;
390
+ message: string;
391
+ context: TContext;
392
+ cause: unknown;
393
+ };
394
+ }
395
+ /** Catch-all for unexpected client-side errors not covered by a more specific subclass. */
396
+ declare class BCClientError extends BaseError<Record<string, unknown>> {
397
+ code: string;
398
+ constructor(message: string, context?: Record<string, unknown>, cause?: unknown);
399
+ }
400
+ /** Thrown by the {@link BigCommerceClient} constructor when credentials or config are invalid. */
401
+ declare class BCCredentialsError extends BaseError<{
402
+ errors: string[];
403
+ }> {
404
+ code: string;
405
+ constructor(errors: string[]);
406
+ }
407
+ /** Thrown before a request is sent when the constructed URL exceeds 2048 characters. */
408
+ declare class BCUrlTooLongError extends BaseError<{
409
+ url: string;
410
+ max: number;
411
+ len: number;
412
+ }> {
413
+ code: string;
414
+ constructor(url: string, max: number);
415
+ }
416
+ /**
417
+ * Thrown during retry when a 429 response is received but the expected
418
+ * `X-Rate-Limit-*` headers are absent, making it impossible to determine the backoff delay.
419
+ */
420
+ declare class BCRateLimitNoHeadersError extends BaseError<{
421
+ url: string;
422
+ method: string;
423
+ attempts: number;
424
+ }> {
425
+ code: string;
426
+ constructor(request: KyRequest, attempts: number);
427
+ }
428
+ /**
429
+ * Thrown during retry when a 429 response specifies a reset window that exceeds
430
+ * `config.retry.maxRetryAfter`, preventing an unbounded wait.
431
+ */
432
+ declare class BCRateLimitDelayTooLongError extends BaseError<{
433
+ url: string;
434
+ method: string;
435
+ attempts: number;
436
+ maxDelay: number;
437
+ delay: number;
438
+ }> {
439
+ code: string;
440
+ constructor(request: KyRequest, attempts: number, maxDelay: number, delay: number);
441
+ }
442
+ /**
443
+ * Abstract base for all StandardSchema validation errors. Carries the raw `data` that failed
444
+ * validation and the schema `error` result. Use specific subclasses for `instanceof` checks.
445
+ */
446
+ declare abstract class BCSchemaValidationError extends BaseError<{
447
+ method: string;
448
+ path: string;
449
+ data: unknown;
450
+ error: StandardSchemaV1.FailureResult;
451
+ }> {
452
+ constructor(message: string, method: string, path: string, data: unknown, error: StandardSchemaV1.FailureResult);
453
+ }
454
+ /** Thrown when `options.querySchema` validation fails before a request is sent. */
455
+ declare class BCQueryValidationError extends BCSchemaValidationError {
456
+ code: string;
457
+ }
458
+ /** Thrown when `options.bodySchema` validation fails before a request is sent. */
459
+ declare class BCRequestBodyValidationError extends BCSchemaValidationError {
460
+ code: string;
461
+ }
462
+ /** Thrown when `options.responseSchema` validation fails after a response is received. */
463
+ declare class BCResponseValidationError extends BCSchemaValidationError {
464
+ code: string;
465
+ }
466
+ /** Thrown or yielded when `options.itemSchema` validation fails for an item in a page response. */
467
+ declare class BCPaginatedItemValidationError extends BCSchemaValidationError {
468
+ code: string;
469
+ }
470
+ /**
471
+ * Thrown when the BigCommerce API returns a non-2xx HTTP response.
472
+ * `context.status` and `context.responseBody` are the most useful fields for debugging.
473
+ */
474
+ declare class BCApiError extends BaseError<{
475
+ method: string;
476
+ url: string;
477
+ status: number;
478
+ statusMessage: string;
479
+ headers: Record<string, string>;
480
+ requestBody: string;
481
+ responseBody: string;
482
+ }> {
483
+ code: string;
484
+ constructor(err: HTTPError, requestBody: string, responseBody: string);
485
+ }
486
+ /** Thrown when a request exceeds the configured timeout (default 120 s). */
487
+ declare class BCTimeoutError extends BaseError<{
488
+ method: string;
489
+ url: string;
490
+ }> {
491
+ code: string;
492
+ constructor(err: TimeoutError);
493
+ }
494
+ /**
495
+ * Thrown when the response body cannot be read or parsed as JSON.
496
+ * `context.rawBody` contains the raw text that failed to parse (empty string if the body was empty).
497
+ */
498
+ declare class BCResponseParseError extends BaseError<{
499
+ method: string;
500
+ status: number;
501
+ path: string;
502
+ query?: Query;
503
+ rawBody?: string;
504
+ }> {
505
+ code: string;
506
+ constructor(method: string, path: string, status: number, cause: unknown, query?: Query, rawBody?: string);
507
+ }
508
+ /**
509
+ * Thrown when a pagination option (`limit`, `page`, or `count`) is not a positive number.
510
+ * `context.option` names the offending field; `context.value` is the value that was passed.
511
+ */
512
+ declare class BCPaginatedOptionError extends BaseError<{
513
+ path: string;
514
+ option: string;
515
+ value: unknown;
516
+ }> {
517
+ code: string;
518
+ constructor(path: string, value: unknown, option: string);
519
+ }
520
+ /**
521
+ * Thrown or yielded when a paginated response is missing required v3 envelope fields
522
+ * (`data`, `meta.pagination`, etc.). Usually means the path is not a v3 collection endpoint.
523
+ */
524
+ declare class BCPaginatedResponseError extends BaseError<{
525
+ path: string;
526
+ data: unknown;
527
+ reason: string;
528
+ }> {
529
+ code: string;
530
+ constructor(path: string, data: unknown, reason: string);
531
+ }
532
+ /** Thrown by {@link BigCommerceAuth} constructor when `config.redirectUri` is not a valid URL. */
533
+ declare class BCAuthInvalidRedirectUriError extends BaseError<{
534
+ redirectUri: string;
535
+ }> {
536
+ code: string;
537
+ constructor(redirectUri: string, cause: unknown);
538
+ }
539
+ /** Thrown by {@link BigCommerceAuth.requestToken} when a required OAuth callback param is absent. */
540
+ declare class BCAuthMissingParamError extends BaseError<{
541
+ param: string;
542
+ }> {
543
+ code: string;
544
+ constructor(param: string);
545
+ }
546
+ /**
547
+ * Thrown by {@link BigCommerceAuth.requestToken} when the scopes granted by BigCommerce
548
+ * do not include all scopes listed in `config.scopes`.
549
+ * `context.missing` lists the scopes that were expected but not granted.
550
+ */
551
+ declare class BCAuthScopeMismatchError extends BaseError<{
552
+ granted: string[];
553
+ expected: string[];
554
+ missing: string[];
555
+ }> {
556
+ code: string;
557
+ constructor(granted: string[], expected: string[], missing: string[]);
558
+ }
559
+ /** Thrown by {@link BigCommerceAuth.verify} when the JWT signature, audience, issuer, or subject is invalid. */
560
+ declare class BCAuthInvalidJwtError extends BaseError<{
561
+ storeHash: string;
562
+ }> {
563
+ code: string;
564
+ constructor(storeHash: string, cause: unknown);
565
+ }
566
+ //#endregion
567
+ //#region src/lib/result.d.ts
568
+ type Ok<T> = {
569
+ ok: true;
570
+ data: T;
571
+ err: undefined;
572
+ };
573
+ type Err<E> = {
574
+ ok: false;
575
+ data: undefined;
576
+ err: E;
577
+ };
578
+ type Result$1<T, E> = Ok<T> | Err<E>;
579
+ /**
580
+ * Creates a successful {@link Result}. Check `result.ok` or `result.err` before accessing `data`.
581
+ * @param data - The success value.
582
+ */
583
+ declare const Ok: <T, E>(data: T) => Result$1<T, E>;
584
+ /**
585
+ * Creates a failed {@link Result}. Check `result.ok` or `result.err` before accessing `err`.
586
+ * @param err - The error value.
587
+ */
588
+ declare const Err: <T, E>(err: E) => Result$1<T, E>;
589
+ //#endregion
590
+ //#region src/client.d.ts
591
+ declare class BigCommerceClient {
592
+ private readonly config;
593
+ private readonly logger?;
594
+ private readonly client;
595
+ private readonly storeHash;
596
+ /**
597
+ * Creates a new BigCommerceClient.
598
+ *
599
+ * @param config - Client configuration. Ky options (e.g. `prefixUrl`, `timeout`, `retry`,
600
+ * `hooks`) are forwarded to the underlying ky instance.
601
+ * @param config.storeHash - BigCommerce store hash. Must be a non-empty string.
602
+ * @param config.accessToken - BigCommerce API access token. Must be a non-empty string.
603
+ * @param config.logger - A {@link Logger} instance, a log level string
604
+ * (`'debug' | 'info' | 'warn' | 'error'`), `true` to enable console logging at `'info'`
605
+ * level, or `false` to disable logging entirely. Omitting also defaults to `'info'` level.
606
+ * @param config.concurrency - Default max concurrent requests for batch/stream operations.
607
+ * Must be between 1 and 1000. Pass `false` to disable concurrency (sequential execution).
608
+ * Defaults to 10.
609
+ * @param config.rateLimitBackoff - Concurrency cap applied when a 429 response is received.
610
+ * Defaults to 1.
611
+ * @param config.backoff - Divisor (or `(concurrency, status) => number` function) applied to
612
+ * concurrency on non-429 error responses. Defaults to 2.
613
+ * @param config.backoffRecover - Amount (or `(concurrency) => number` function) added to
614
+ * concurrency per successful response while below the configured max. Defaults to 1.
615
+ *
616
+ * @throws {@link BCCredentialsError} if `storeHash` or `accessToken` are missing or if
617
+ * `concurrency` is out of range.
618
+ * @throws {@link BCClientError} if `prefixUrl` is not a valid URL.
619
+ */
620
+ constructor(config: ClientConfig);
621
+ /**
622
+ * Sends a GET request to the given path.
623
+ *
624
+ * @param path - API path relative to the store's versioned base URL (e.g. `catalog/products`).
625
+ * @param options - Ky options are forwarded to the underlying request.
626
+ * @param options.version - API version segment inserted into the URL. Defaults to `'v3'`.
627
+ * @param options.query - Query parameters to append to the URL.
628
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query` before the request
629
+ * is sent. Requires `query` to be provided.
630
+ * @param options.responseSchema - StandardSchemaV1 schema to validate the parsed response body.
631
+ *
632
+ * @returns Parsed and optionally validated response body.
633
+ *
634
+ * @throws {@link BCApiError} on HTTP error responses.
635
+ * @throws {@link BCTimeoutError} if the request times out.
636
+ * @throws {@link BCResponseParseError} if the response body cannot be parsed.
637
+ * @throws {@link BCUrlTooLongError} if the constructed URL exceeds 2048 characters.
638
+ * @throws {@link BCRateLimitNoHeadersError} if a 429 is received without rate-limit headers.
639
+ * @throws {@link BCRateLimitDelayTooLongError} if the rate-limit reset window exceeds
640
+ * `config.retry.maxRetryAfter`.
641
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
642
+ * @throws {@link BCResponseValidationError} if `responseSchema` validation fails.
643
+ * @throws {@link BCClientError} on any other ky or unknown error.
644
+ */
645
+ get<TRes = unknown, TQuery extends Query = Query>(path: string, options?: GetOptions<TRes, TQuery>): Promise<TRes>;
646
+ /**
647
+ * Sends a POST request to the given path.
648
+ *
649
+ * @param path - API path relative to the store's versioned base URL.
650
+ * @param options - Ky options are forwarded to the underlying request.
651
+ * @param options.version - API version segment inserted into the URL. Defaults to `'v3'`.
652
+ * @param options.body - Request body, serialized as JSON.
653
+ * @param options.bodySchema - StandardSchemaV1 schema to validate `body` before the request
654
+ * is sent. Requires `body` to be provided.
655
+ * @param options.query - Query parameters to append to the URL.
656
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query` before the request
657
+ * is sent. Requires `query` to be provided.
658
+ * @param options.responseSchema - StandardSchemaV1 schema to validate the parsed response body.
659
+ *
660
+ * @returns Parsed and optionally validated response body.
661
+ *
662
+ * @throws {@link BCApiError} on HTTP error responses.
663
+ * @throws {@link BCTimeoutError} if the request times out.
664
+ * @throws {@link BCResponseParseError} if the response body cannot be parsed.
665
+ * @throws {@link BCUrlTooLongError} if the constructed URL exceeds 2048 characters.
666
+ * @throws {@link BCRateLimitNoHeadersError} if a 429 is received without rate-limit headers.
667
+ * @throws {@link BCRateLimitDelayTooLongError} if the rate-limit reset window exceeds
668
+ * `config.retry.maxRetryAfter`.
669
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
670
+ * @throws {@link BCRequestBodyValidationError} if `bodySchema` validation fails.
671
+ * @throws {@link BCResponseValidationError} if `responseSchema` validation fails.
672
+ * @throws {@link BCClientError} on any other ky or unknown error.
673
+ */
674
+ post<TRes = unknown, TBody = unknown, TQuery extends Query = Query>(path: string, options?: PostOptions<TBody, TRes, TQuery>): Promise<TRes>;
675
+ /**
676
+ * Sends a PUT request to the given path.
677
+ *
678
+ * @param path - API path relative to the store's versioned base URL.
679
+ * @param options - Ky options are forwarded to the underlying request.
680
+ * @param options.version - API version segment inserted into the URL. Defaults to `'v3'`.
681
+ * @param options.body - Request body, serialized as JSON.
682
+ * @param options.bodySchema - StandardSchemaV1 schema to validate `body` before the request
683
+ * is sent. Requires `body` to be provided.
684
+ * @param options.query - Query parameters to append to the URL.
685
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query` before the request
686
+ * is sent. Requires `query` to be provided.
687
+ * @param options.responseSchema - StandardSchemaV1 schema to validate the parsed response body.
688
+ *
689
+ * @returns Parsed and optionally validated response body.
690
+ *
691
+ * @throws {@link BCApiError} on HTTP error responses.
692
+ * @throws {@link BCTimeoutError} if the request times out.
693
+ * @throws {@link BCResponseParseError} if the response body cannot be parsed.
694
+ * @throws {@link BCUrlTooLongError} if the constructed URL exceeds 2048 characters.
695
+ * @throws {@link BCRateLimitNoHeadersError} if a 429 is received without rate-limit headers.
696
+ * @throws {@link BCRateLimitDelayTooLongError} if the rate-limit reset window exceeds
697
+ * `config.retry.maxRetryAfter`.
698
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
699
+ * @throws {@link BCRequestBodyValidationError} if `bodySchema` validation fails.
700
+ * @throws {@link BCResponseValidationError} if `responseSchema` validation fails.
701
+ * @throws {@link BCClientError} on any other ky or unknown error.
702
+ */
703
+ put<TRes = unknown, TBody = unknown, TQuery extends Query = Query>(path: string, options?: PutOptions<TBody, TRes, TQuery>): Promise<TRes>;
704
+ /**
705
+ * Sends a DELETE request to the given path.
706
+ *
707
+ * Silently suppresses 404 responses (resource already gone) and empty response bodies.
708
+ *
709
+ * @param path - API path relative to the store's versioned base URL.
710
+ * @param options - Ky options are forwarded to the underlying request.
711
+ * @param options.version - API version segment inserted into the URL. Defaults to `'v3'`.
712
+ * @param options.query - Query parameters to append to the URL.
713
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query` before the request
714
+ * is sent. Requires `query` to be provided.
715
+ *
716
+ * @throws {@link BCApiError} on non-404 HTTP error responses.
717
+ * @throws {@link BCTimeoutError} if the request times out.
718
+ * @throws {@link BCResponseParseError} if the response body is non-empty and cannot be parsed.
719
+ * @throws {@link BCUrlTooLongError} if the constructed URL exceeds 2048 characters.
720
+ * @throws {@link BCRateLimitNoHeadersError} if a 429 is received without rate-limit headers.
721
+ * @throws {@link BCRateLimitDelayTooLongError} if the rate-limit reset window exceeds
722
+ * `config.retry.maxRetryAfter`.
723
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
724
+ * @throws {@link BCClientError} on any other ky or unknown error.
725
+ */
726
+ delete<TRes = never, TQuery extends Query = Query>(path: string, options?: DeleteOptions<TQuery>): Promise<void>;
727
+ /**
728
+ * Fetches items from a v3 paginated endpoint by splitting `values` across multiple requests
729
+ * using the given `key` query param, chunking to stay within URL length limits.
730
+ *
731
+ * Collects all results into an array. Use {@link queryStream} to process items lazily.
732
+ *
733
+ * @param path - API path relative to the store's versioned base URL.
734
+ * @param options - Query options including `key`, `values`, pagination params, and concurrency
735
+ * controls.
736
+ * @param options.key - Query parameter name used for value filtering (e.g. `'id:in'`).
737
+ * @param options.values - Values to filter by. Automatically chunked across multiple requests
738
+ * to keep each URL under 2048 characters.
739
+ * @param options.query - Additional query parameters. `query.limit` controls page size
740
+ * (default 250, must be > 0). If `options.key` is present in `query` it will be ignored.
741
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query`. Requires `query`
742
+ * to be provided.
743
+ * @param options.itemSchema - StandardSchemaV1 schema to validate each returned item.
744
+ * @param options.concurrency - Max concurrent chunk requests. Must be 1–1000. `false` for
745
+ * sequential. Defaults to `config.concurrency`, or 10 if not set on the client.
746
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
747
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
748
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
749
+ * Defaults to `config.backoff`, or 2 if not set on the client.
750
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
751
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
752
+ *
753
+ * @returns All matching items across all chunked requests.
754
+ * @throws {@link BCPaginatedOptionError} if `query.limit` is not a positive number.
755
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
756
+ * @throws {@link BCApiError} on HTTP error responses.
757
+ * @throws {@link BCTimeoutError} if a request times out.
758
+ * @throws {@link BCResponseParseError} if a response body cannot be parsed.
759
+ * @throws {@link BCUrlTooLongError} if a constructed URL exceeds 2048 characters.
760
+ * @throws {@link BCRateLimitNoHeadersError} if a 429 is received without rate-limit headers.
761
+ * @throws {@link BCRateLimitDelayTooLongError} if the rate-limit reset window exceeds
762
+ * `config.retry.maxRetryAfter`.
763
+ * @throws {@link BCPaginatedResponseError} if a page response has an unexpected shape.
764
+ * @throws {@link BCPaginatedItemValidationError} if `itemSchema` validation fails for an item.
765
+ * @throws {@link BCClientError} on any other ky or unknown error.
766
+ */
767
+ query<TItem = unknown, TQuery extends Query = Query>(path: string, options: QueryOptions<TItem, TQuery>): Promise<TItem[]>;
768
+ /**
769
+ * Streaming variant of {@link query}. Yields each item individually as results arrive,
770
+ * splitting `values` into URL-length-safe chunks across concurrent requests.
771
+ *
772
+ * Each yielded value is a {@link Result} — check `err` before using `data`.
773
+ *
774
+ * @param path - API path relative to the store's versioned base URL.
775
+ * @param options - Query options including `key`, `values`, pagination params, and concurrency
776
+ * controls.
777
+ * @param options.key - Query parameter name used for value filtering (e.g. `'id:in'`).
778
+ * @param options.values - Values to filter by. Automatically chunked across multiple requests
779
+ * to keep each URL under 2048 characters.
780
+ * @param options.query - Additional query parameters. `query.limit` controls page size
781
+ * (default 250, must be > 0). If `options.key` is present in `query` it will be ignored.
782
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query`. Requires `query`
783
+ * to be provided.
784
+ * @param options.itemSchema - StandardSchemaV1 schema to validate each returned item.
785
+ * @param options.concurrency - Max concurrent chunk requests. Must be 1–1000. `false` for
786
+ * sequential. Defaults to `config.concurrency`, or 10 if not set on the client.
787
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
788
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
789
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
790
+ * Defaults to `config.backoff`, or 2 if not set on the client.
791
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
792
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
793
+ * @throws {@link BCPaginatedOptionError} if `query.limit` is not a positive number.
794
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
795
+ */
796
+ queryStream<TItem = unknown, TQuery extends Query = Query>(path: string, options: QueryOptions<TItem, TQuery>): AsyncGenerator<Result$1<TItem, BaseError>>;
797
+ /**
798
+ * Fetches all pages from a v3 paginated endpoint and collects items into an array.
799
+ *
800
+ * Use {@link stream} to process items lazily without buffering the full result set.
801
+ *
802
+ * @param path - API path relative to the store's versioned base URL.
803
+ * @param options - Ky options are forwarded to page requests.
804
+ * @param options.query - Query parameters. `query.limit` controls page size (default 250,
805
+ * must be > 0). `query.page` sets the starting page (default 1, must be > 0).
806
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query`. Requires `query`
807
+ * to be provided.
808
+ * @param options.itemSchema - StandardSchemaV1 schema to validate each returned item.
809
+ * @param options.concurrency - Max concurrent page requests for pages after the first.
810
+ * Must be 1–1000. `false` for sequential. Defaults to `config.concurrency`, or 10 if not
811
+ * set on the client.
812
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
813
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
814
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
815
+ * Defaults to `config.backoff`, or 2 if not set on the client.
816
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
817
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
818
+ * @returns All items across all pages.
819
+ *
820
+ * @throws {@link BCPaginatedOptionError} if `query.limit` or `query.page` is not a positive number.
821
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
822
+ * @throws {@link BCApiError} on HTTP error responses.
823
+ * @throws {@link BCTimeoutError} if a request times out.
824
+ * @throws {@link BCResponseParseError} if a response body cannot be parsed.
825
+ * @throws {@link BCUrlTooLongError} if a constructed URL exceeds 2048 characters.
826
+ * @throws {@link BCRateLimitNoHeadersError} if a 429 is received without rate-limit headers.
827
+ * @throws {@link BCRateLimitDelayTooLongError} if the rate-limit reset window exceeds
828
+ * `config.retry.maxRetryAfter`.
829
+ * @throws {@link BCPaginatedResponseError} if a page response has an unexpected shape.
830
+ * @throws {@link BCPaginatedItemValidationError} if `itemSchema` validation fails for an item.
831
+ * @throws {@link BCClientError} on any other ky or unknown error.
832
+ */
833
+ collect<TItem = unknown, TQuery extends Query = Query>(path: string, options?: CollectOptions<TItem, TQuery>): Promise<TItem[]>;
834
+ /**
835
+ * Fetches all pages from a v2 flat-array endpoint and collects items into an array.
836
+ *
837
+ * Pagination is discovered dynamically — pages are fetched in batches until an empty page,
838
+ * a 404, or a 204 response is received. No prior knowledge of total count is required.
839
+ *
840
+ * Use {@link streamBlind} to process items lazily without buffering the full result set.
841
+ *
842
+ * @param path - API path relative to the store's versioned base URL (always requests v2).
843
+ * @param options - Ky options are forwarded to page requests.
844
+ * @param options.query - Query parameters. `query.limit` controls page size (default 250,
845
+ * must be > 0). `query.page` sets the starting page (default 1, must be > 0).
846
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query`. Requires `query`
847
+ * to be provided.
848
+ * @param options.itemSchema - StandardSchemaV1 schema to validate each returned item.
849
+ * @param options.maxPages - Maximum number of pages to fetch before stopping (default 500,
850
+ * must be > 0). A warning is logged if this limit is reached.
851
+ * @param options.concurrency - Max concurrent page requests per batch. Must be 1–1000.
852
+ * `false` for sequential. Defaults to `config.concurrency`, or 10 if not set on the client.
853
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
854
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
855
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
856
+ * Defaults to `config.backoff`, or 2 if not set on the client.
857
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
858
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
859
+ * @returns All items across all pages.
860
+ *
861
+ * @throws {@link BCPaginatedOptionError} if `query.limit`, `query.page`, or `maxPages` is not a positive number.
862
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
863
+ * @throws {@link BCPaginatedItemValidationError} if `itemSchema` validation fails for an item.
864
+ * @throws {@link BCClientError} if a page returns a non-array response, or on any other error.
865
+ * @throws {@link BCApiError} on non-terminating HTTP error responses.
866
+ * @throws {@link BCTimeoutError} if a request times out.
867
+ * @throws {@link BCResponseParseError} if a response body cannot be parsed.
868
+ */
869
+ collectBlind<TItem = unknown, TQuery extends Query = Query>(path: string, options?: BlindOptions<TItem, TQuery>): Promise<TItem[]>;
870
+ /**
871
+ * Lazily streams items from a v2 flat-array endpoint, page by page.
872
+ *
873
+ * Pagination is discovered dynamically — pages are fetched in concurrent batches until an
874
+ * empty page, a 404, or a 204 response is received. No prior knowledge of total count is
875
+ * required. Each item is yielded as a {@link Result}: `Ok(item)` on success or
876
+ * `Err(error)` for item-level validation failures and non-terminating page errors.
877
+ *
878
+ * Use {@link collectBlind} to buffer all results into an array (throws on any error).
879
+ *
880
+ * @param path - API path relative to the store's versioned base URL (always requests v2).
881
+ * @param options - Ky options are forwarded to page requests.
882
+ * @param options.query - Query parameters. `query.limit` controls page size (default 250,
883
+ * must be > 0). `query.page` sets the starting page (default 1, must be > 0).
884
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query`. Requires `query`
885
+ * to be provided.
886
+ * @param options.itemSchema - StandardSchemaV1 schema to validate each returned item.
887
+ * @param options.maxPages - Maximum number of pages to fetch before stopping (default 500,
888
+ * must be > 0). A warning is logged if this limit is reached.
889
+ * @param options.concurrency - Max concurrent page requests per batch. Must be 1–1000.
890
+ * `false` for sequential. Defaults to `config.concurrency`, or 10 if not set on the client.
891
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
892
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
893
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
894
+ * Defaults to `config.backoff`, or 2 if not set on the client.
895
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
896
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
897
+ *
898
+ * @throws {@link BCPaginatedOptionError} if `query.limit`, `query.page`, or `maxPages` is not a positive number.
899
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
900
+ *
901
+ * @yields `Ok(item)` for each successfully fetched and validated item.
902
+ * @yields `Err(BCPaginatedItemValidationError)` when `itemSchema` rejects an item.
903
+ * @yields `Err(BCClientError)` when a page returns a non-array response.
904
+ * @yields `Err(error)` for non-terminating page errors (e.g. non-404/204 HTTP errors).
905
+ */
906
+ streamBlind<TItem = unknown, TQuery extends Query = Query>(path: string, options?: BlindOptions<TItem, TQuery>): AsyncGenerator<Result$1<TItem, BaseError>>;
907
+ /**
908
+ * Executes multiple requests concurrently and returns all results as {@link Result} values,
909
+ * never throwing. Errors from individual requests are captured as `Err` results.
910
+ *
911
+ * Use {@link batchStream} to process results as they arrive rather than waiting for all.
912
+ *
913
+ * @param requests - Array of request descriptors built with the {@link req} helpers.
914
+ * @param options.concurrency - Max concurrent requests. Must be 1–1000. `false` for
915
+ * sequential. Defaults to `config.concurrency`, or 10 if not set on the client.
916
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
917
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
918
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
919
+ * Defaults to `config.backoff`, or 2 if not set on the client.
920
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
921
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
922
+ *
923
+ * @returns Results in the order requests complete (not necessarily input order).
924
+ */
925
+ batchSafe<TRes = unknown, TBody = unknown, TQuery extends Query = Query>(requests: BatchRequestOptions<TBody, TRes, TQuery>[], options?: ConcurrencyOptions): Promise<Result$1<TRes, BaseError>[]>;
926
+ /**
927
+ * Streams all items from a v3 paginated endpoint, fetching the first page sequentially
928
+ * and remaining pages concurrently via {@link batchStream}.
929
+ *
930
+ * Each yielded value is a {@link Result} — check `err` before using `data`. Use
931
+ * {@link collect} to gather all items into an array.
932
+ *
933
+ * @param path - API path relative to the store's versioned base URL.
934
+ * @param options - Ky options are forwarded to page requests.
935
+ * @param options.query - Query parameters. `query.limit` controls page size (default 250,
936
+ * must be > 0). `query.page` sets the starting page (default 1, must be > 0). If the API
937
+ * enforces a different limit, the actual `per_page` from the first response is used for
938
+ * subsequent pages.
939
+ * @param options.querySchema - StandardSchemaV1 schema to validate `query`. Requires `query`
940
+ * to be provided.
941
+ * @param options.itemSchema - StandardSchemaV1 schema to validate each returned item.
942
+ * @param options.concurrency - Max concurrent page requests for pages after the first.
943
+ * Must be 1–1000. `false` for sequential. Defaults to `config.concurrency`, or 10 if not
944
+ * set on the client.
945
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
946
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
947
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
948
+ * Defaults to `config.backoff`, or 2 if not set on the client.
949
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
950
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
951
+ * @throws {@link BCPaginatedOptionError} if `query.limit` or `query.page` is not a positive number.
952
+ * @throws {@link BCQueryValidationError} if `querySchema` validation fails.
953
+ */
954
+ stream<TItem = unknown, TQuery extends Query = Query>(path: string, options?: CollectOptions<TItem, TQuery>): AsyncGenerator<Result$1<TItem, BaseError>>;
955
+ /**
956
+ * Executes multiple requests with configurable concurrency, yielding each result as a
957
+ * {@link Result} as it completes. Errors from individual requests are yielded as `Err`
958
+ * results rather than thrown.
959
+ *
960
+ * Automatically adjusts concurrency up/down in response to rate-limit and error responses.
961
+ * Use {@link batchSafe} to collect all results into an array.
962
+ *
963
+ * **Caution:** the generator is making requests concurrently. As a consequence if a
964
+ * request is mutating the remote (POST, DELETE) and `for await` loop is exited early,
965
+ * the in-flight request may or may not commit the mutation, and the results of
966
+ * these request WILL NOT be yielded. If you do intent to break the loop early and want to
967
+ * get all the results, set `concurrency: false` to trade concurrency for deterministic behavior.
968
+ *
969
+ * @param requests - Array of request descriptors built with the {@link req} helpers.
970
+ * @param options.concurrency - Max concurrent requests. Must be 1–1000. `false` for
971
+ * sequential. Defaults to `config.concurrency`, or 10 if not set on the client.
972
+ * @param options.rateLimitBackoff - Concurrency cap on 429 responses. Defaults to
973
+ * `config.rateLimitBackoff`, or 1 if not set on the client.
974
+ * @param options.backoff - Divisor (or function) applied to concurrency on error responses.
975
+ * Defaults to `config.backoff`, or 2 if not set on the client.
976
+ * @param options.backoffRecover - Amount (or function) added to concurrency per successful
977
+ * response. Defaults to `config.backoffRecover`, or 1 if not set on the client.
978
+ */
979
+ batchStream<TRes = unknown, TBody = unknown, TQuery extends Query = Query>(requests: BatchRequestOptions<TBody, TRes, TQuery>[], options?: ConcurrencyOptions): AsyncGenerator<Result$1<TRes, BaseError>>;
980
+ private validatePaginatedItem;
981
+ private assertPaginatedResponse;
982
+ private validatePaginationOption;
983
+ private resolveStreamOptions;
984
+ private makeStreamClient;
985
+ private request;
986
+ private validate;
987
+ private makePath;
988
+ private validateConfig;
989
+ private validateConcurrency;
990
+ }
991
+ //#endregion
992
+ //#region src/lib/pagination.d.ts
993
+ type Pagination = {
994
+ total: number;
995
+ count: number;
996
+ per_page: number;
997
+ current_page: number;
998
+ total_pages: number;
999
+ links: {
1000
+ previous: string | null;
1001
+ current: string;
1002
+ next: string | null;
1003
+ };
1004
+ };
1005
+ type V3Resource<T> = {
1006
+ data: T;
1007
+ meta: {
1008
+ pagination: Pagination;
1009
+ };
1010
+ };
1011
+ //#endregion
1012
+ export { type ApiVersion, BCApiError, BCAuthInvalidJwtError, BCAuthInvalidRedirectUriError, BCAuthMissingParamError, BCAuthScopeMismatchError, BCClientError, BCCredentialsError, BCPaginatedItemValidationError, BCPaginatedOptionError, BCPaginatedResponseError, BCQueryValidationError, BCRateLimitDelayTooLongError, BCRateLimitNoHeadersError, BCRequestBodyValidationError, BCResponseParseError, BCResponseValidationError, BCSchemaValidationError, BCTimeoutError, BCUrlTooLongError, BaseError, type BatchRequestOptions, BigCommerceAuth, BigCommerceAuthConfig, BigCommerceAuthQuery, BigCommerceClient, Claims, type ClientConfig, type CollectOptions, type ConcurrencyOptions, type CountedCollectOptions, type DeleteOptions, Err, ErrorContext, FallbackLogger, type GetOptions, type HttpMethod, type LogLevel, type Logger, Ok, Pagination, type PostOptions, type PowertoolsLikeLogger, type PutOptions, type Query, type QueryOptions, type QueryValue, type RequestOptions, Result$1 as Result, type StandardSchemaV1, TokenResponse, User, V3Resource, fromAwsPowertoolsLogger, req };
1013
+ //# sourceMappingURL=index.d.mts.map