import { AxiosError } from "axios"; //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-any.d.ts /** Returns a boolean for whether the given type is `any`. @link https://stackoverflow.com/a/49928360/1490091 Useful in type utilities, such as disallowing `any`s to be passed to a function. @example ``` import type {IsAny} from 'type-fest'; const typedObject = {a: 1, b: 2} as const; const anyObject: any = {a: 1, b: 2}; function get extends true ? {} : Record), K extends keyof O = keyof O>(object: O, key: K) { return object[key]; } const typedA = get(typedObject, 'a'); //=> 1 const anyA = get(anyObject, 'a'); //=> any ``` @category Type Guard @category Utilities */ type IsAny = 0 extends 1 & NoInfer ? true : false; //#endregion //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-never.d.ts /** Returns a boolean for whether the given type is `never`. @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919 @link https://stackoverflow.com/a/53984913/10292952 @link https://www.zhenghao.io/posts/ts-never Useful in type utilities, such as checking if something does not occur. @example ``` import type {IsNever, And} from 'type-fest'; type A = IsNever; //=> true type B = IsNever; //=> false type C = IsNever; //=> false type D = IsNever; //=> false type E = IsNever; //=> false type F = IsNever; //=> false ``` @example ``` import type {IsNever} from 'type-fest'; type IsTrue = T extends true ? true : false; // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`. type A = IsTrue; //=> never // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional. type IsTrueFixed = IsNever extends true ? false : T extends true ? true : false; type B = IsTrueFixed; //=> false ``` @category Type Guard @category Utilities */ type IsNever = [T] extends [never] ? true : false; //#endregion //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/if.d.ts /** An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`. Use-cases: - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If, 'is any', 'not any'>`. Note: - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If` will return `'Y' | 'N'`. - Returns the else branch if the given type is `never`. For example, `If` will return `'N'`. @example ``` import type {If} from 'type-fest'; type A = If; //=> 'yes' type B = If; //=> 'no' type C = If; //=> 'yes' | 'no' type D = If; //=> 'yes' | 'no' type E = If; //=> 'no' ``` @example ``` import type {If, IsAny, IsNever} from 'type-fest'; type A = If, 'is any', 'not any'>; //=> 'not any' type B = If, 'is never', 'not never'>; //=> 'is never' ``` @example ``` import type {If, IsEqual} from 'type-fest'; type IfEqual = If, IfBranch, ElseBranch>; type A = IfEqual; //=> 'equal' type B = IfEqual; //=> 'not equal' ``` Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example: @example ``` import type {If, IsEqual, StringRepeat} from 'type-fest'; type HundredZeroes = StringRepeat<'0', 100>; // The following implementation is not tail recursive type Includes = S extends `${infer First}${infer Rest}` ? If, 'found', Includes> : 'not found'; // Hence, instantiations with long strings will fail // @ts-expect-error type Fails = Includes; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Error: Type instantiation is excessively deep and possibly infinite. // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive type IncludesWithoutIf = S extends `${infer First}${infer Rest}` ? IsEqual extends true ? 'found' : IncludesWithoutIf : 'not found'; // Now, instantiations with long strings will work type Works = IncludesWithoutIf; //=> 'not found' ``` @category Type Guard @category Utilities */ type If = IsNever extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch; //#endregion //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/internal/type.d.ts /** An if-else-like type that resolves depending on whether the given type is `any` or `never`. @example ``` // When `T` is neither `any` nor `never` (like `string`) => Returns `IfNot` branch type A = IfNotAnyOrNever; //=> 'VALID' // When `T` is `any` => Returns `IfAny` branch type B = IfNotAnyOrNever; //=> 'IS_ANY' // When `T` is `never` => Returns `IfNever` branch type C = IfNotAnyOrNever; //=> 'IS_NEVER' ``` Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example: @example ```ts import type {StringRepeat} from 'type-fest'; type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>; // The following implementation is not tail recursive type TrimLeft = IfNotAnyOrNever : S}>; // Hence, instantiations with long strings will fail // @ts-expect-error type T1 = TrimLeft; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Error: Type instantiation is excessively deep and possibly infinite. // To fix this, move the recursion into a helper type type TrimLeftOptimised = IfNotAnyOrNever}>; type _TrimLeftOptimised = S extends ` ${infer R}` ? _TrimLeftOptimised : S; type T2 = TrimLeftOptimised; //=> '' ``` */ type IfNotAnyOrNever = IsAny extends true ? 'ifAny' extends keyof Cases ? Cases['ifAny'] : any : IsNever extends true ? 'ifNever' extends keyof Cases ? Cases['ifNever'] : never : Cases['ifNot']; //#endregion //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/require-exactly-one.d.ts /** Create a type that requires exactly one of the given keys and disallows more, while keeping the remaining keys as is. Use-cases: - Creating interfaces for components that only need one of the keys to display properly. - Declaring generic keys in a single place for a single use-case that gets narrowed down via `RequireExactlyOne`. The caveat with `RequireExactlyOne` is that TypeScript doesn't always know at compile time every key that will exist at runtime. Therefore `RequireExactlyOne` can't do anything to prevent extra keys it doesn't know about. @example ``` import type {RequireExactlyOne} from 'type-fest'; type Responder = { text: () => string; json: () => string; secure: boolean; }; const responder: RequireExactlyOne = { // Adding a `text` key here would cause a compile error. json: () => '{"message": "ok"}', secure: true, }; ``` @category Object */ type RequireExactlyOne = IfNotAnyOrNever, never, _RequireExactlyOne, keyof ObjectType, KeysType>>>; }>; type _RequireExactlyOne = { [Key in KeysType]: (Required> & Partial, never>>); }[KeysType] & Omit; //#endregion //#region src/types/scope.d.ts /** Authorization scopes for grantless Selling Partner API operations. */ declare enum AuthorizationScope { /** Scope for the Notifications API. */ NOTIFICATIONS = "sellingpartnerapi::notifications", /** Scope for rotating application client credentials. */ CLIENT_CREDENTIAL_ROTATION = "sellingpartnerapi::client_credential:rotation" } //#endregion //#region src/types/access-token.d.ts interface BaseAccessTokenQuery { client_id: string; client_secret: string; } type RefreshTokenAccessTokenQuery = { grant_type: 'refresh_token'; refresh_token: string; } & BaseAccessTokenQuery; type ClientCredentialsAccessTokenQuery = { grant_type: 'client_credentials'; scope: string; } & BaseAccessTokenQuery; /** Request body for the LWA token endpoint. */ type AccessTokenQuery = RefreshTokenAccessTokenQuery | ClientCredentialsAccessTokenQuery; /** Response body from the LWA token endpoint. */ interface AccessTokenData { access_token: string; refresh_token?: string; token_type: string; expires_in: number; } //#endregion //#region src/error.d.ts /** Error thrown when an LWA token request fails. Wraps the underlying Axios error with a human-readable message that includes the HTTP status code (or "No response" for network errors). */ declare class SellingPartnerApiAuthError extends AxiosError { /** The original error message from the failed HTTP request. */ readonly innerMessage: string; constructor(error: AxiosError); } //#endregion //#region src/index.d.ts /** Configuration parameters for Selling Partner API authentication. Both `clientId` and `clientSecret` fall back to the `LWA_CLIENT_ID` and `LWA_CLIENT_SECRET` environment variables when omitted. `refreshToken` falls back to `LWA_REFRESH_TOKEN`. */ interface SellingPartnerAuthParameters { /** LWA client identifier. Defaults to the `LWA_CLIENT_ID` environment variable. */ clientId?: string; /** LWA client secret. Defaults to the `LWA_CLIENT_SECRET` environment variable. */ clientSecret?: string; /** LWA refresh token. Defaults to the `LWA_REFRESH_TOKEN` environment variable. Mutually exclusive with `scopes`. */ refreshToken?: string; /** Authorization scopes for grantless operations. Mutually exclusive with `refreshToken`. */ scopes?: AuthorizationScope[]; } /** Handles Login with Amazon (LWA) OAuth token management for the Selling Partner API. Supports both refresh-token and grantless (scope-based) authentication flows. Tokens are cached and automatically refreshed when expired. Concurrent calls to {@link getAccessToken} are deduplicated into a single request. */ declare class SellingPartnerApiAuth { #private; private readonly clientId; private readonly clientSecret; private readonly refreshToken?; private readonly scopes?; constructor(parameters: RequireExactlyOne); /** Returns a valid LWA access token, refreshing it if expired. Concurrent calls while a refresh is in progress share the same request. @returns The access token string. */ getAccessToken(): Promise; /** Expiration date of the currently cached access token, or `undefined` if no token has been fetched yet. */ protected get accessTokenExpiration(): Date | undefined; } //#endregion export { AuthorizationScope, SellingPartnerApiAuth, SellingPartnerApiAuthError, SellingPartnerAuthParameters }; //# sourceMappingURL=index.d.cts.map