import type { Readable } from 'node:stream'; import type { RetryOptions } from 'got'; import type { AssemblyIndexItem, AssemblyStatus } from './alphalib/types/assemblyStatus.ts'; import type { BaseResponse, BillResponse, CreateAssemblyParams, CreateTemplateCredentialParams, CreateTemplateParams, EditTemplateParams, ListAssembliesParams, ListedTemplate, ListTemplateCredentialsParams, ListTemplatesParams, OptionalAuthParams, PaginationListWithCount, ReplayAssemblyNotificationParams, ReplayAssemblyNotificationResponse, ReplayAssemblyParams, ReplayAssemblyResponse, TemplateCredentialResponse, TemplateCredentialsResponse, TemplateResponse } from './apiTypes.ts'; import type { BearerTokenResponse, MintBearerTokenOptions } from './bearerToken.ts'; import type { LintAssemblyInstructionsInput, LintAssemblyInstructionsResult } from './lintAssemblyInstructions.ts'; import type { UploadBehavior } from './tus.ts'; import { type Input as IntoStreamInput } from 'into-stream'; import { ApiError } from './ApiError.ts'; import InconsistentResponseError from './InconsistentResponseError.ts'; import PaginationStream from './PaginationStream.ts'; export type { AssemblyStatus } from './alphalib/types/assemblyStatus.ts'; export type { Base64Strategy, InputFile, PrepareInputFilesOptions, PrepareInputFilesResult, UploadInput, UrlStrategy, } from './inputFiles.ts'; export type { LintAssemblyInstructionsResult, LintFatalLevel } from './lintAssemblyInstructions.ts'; export type { RobotHelp, RobotHelpOptions, RobotListItem, RobotListOptions, RobotListResult, RobotParamHelp, } from './robots.ts'; export { HTTPError, MaxRedirectsError, ParseError, ReadError, RequestError, TimeoutError, UploadError, } from 'got'; export { extractFieldNamesFromTemplate } from './alphalib/stepParsing.ts'; export { mergeTemplateContent } from './alphalib/templateMerge.ts'; export * from './apiTypes.ts'; export { prepareInputFiles } from './inputFiles.ts'; export { getRobotHelp, isKnownRobot, listRobots } from './robots.ts'; export { ApiError, InconsistentResponseError }; export interface UploadProgress { uploadedBytes?: number | undefined; totalBytes?: number | undefined; } export type { UploadBehavior }; export type AssemblyStatusWithUploadUrls = AssemblyStatus & { upload_urls?: Record; }; export type AssemblyProgress = (assembly: AssemblyStatus) => void; interface AssemblyUploadOptions { files?: { [name: string]: string; }; uploads?: { [name: string]: Readable | IntoStreamInput; }; uploadBehavior?: UploadBehavior; waitForCompletion?: boolean; chunkSize?: number; uploadConcurrency?: number; timeout?: number; onUploadProgress?: (uploadProgress: UploadProgress) => void; onAssemblyProgress?: AssemblyProgress; /** * Optional AbortSignal to cancel the upload and any follow-up polling. * When aborted, any in-flight HTTP requests and TUS uploads will be cancelled. */ signal?: AbortSignal; } export interface CreateAssemblyOptions extends AssemblyUploadOptions { params?: CreateAssemblyParams; assemblyId?: string; /** * Expected number of tus uploads when files will be uploaded separately. */ expectedUploads?: number; } export interface ResumeAssemblyUploadsOptions extends AssemblyUploadOptions { assemblyUrl: string; } export interface AwaitAssemblyCompletionOptions { onAssemblyProgress?: AssemblyProgress; timeout?: number; interval?: number; startTimeMs?: number; /** * Optional assembly URL to poll instead of the configured client endpoint. * Useful when resuming an Assembly created on a different host/region. */ assemblyUrl?: string; /** * Optional AbortSignal to cancel polling. * When aborted, the polling loop will stop and throw an AbortError. */ signal?: AbortSignal; /** * Optional callback invoked before each poll iteration. * Return `false` to stop polling early and return the current assembly status. * Useful for watch mode where a newer job may supersede the current one. */ onPoll?: () => boolean | undefined; } export interface LintAssemblyInstructionsOptions extends Omit { /** * Template ID to merge with the provided instructions before linting. */ templateId?: string; } export interface SmartCDNUrlOptions { /** * Workspace slug */ workspace: string; /** * Template slug or template ID */ template: string; /** * Input value that is provided as `${fields.input}` in the template */ input: string; /** * Additional parameters for the URL query string */ urlParams?: Record; /** * Expiration timestamp of the signature in milliseconds since UNIX epoch. * Defaults to 1 hour from now. */ expiresAt?: number; } export type Fields = Record; interface CreateAssemblyPromise extends Promise { assemblyId: string; } type AuthKeySecret = { authKey: string; authSecret: string; authToken?: undefined; }; type AuthToken = { authToken: string; authKey?: string; authSecret?: string; }; type BaseOptions = { endpoint?: string; maxRetries?: number; timeout?: number; gotRetry?: Partial; validateResponses?: boolean; clientName?: string; }; export type Options = BaseOptions & (AuthKeySecret | AuthToken); export declare class Transloadit { private _authKey; private _authSecret; private _authToken; private _endpoint; private _maxRetries; private _defaultTimeout; private _gotRetry; private _clientName; private _lastUsedAssemblyUrl; private _validateResponses; constructor(opts: Options); getLastUsedAssemblyUrl(): string; setDefaultTimeout(timeout: number): void; /** * Create an Assembly * * @param opts assembly options */ createAssembly(opts?: CreateAssemblyOptions): CreateAssemblyPromise; /** * Lint Assembly Instructions locally. * * If a templateId is provided, the template content is merged with the instructions, * just like the API. When a template sets `allow_steps_override=false`, providing * `steps` will throw a TEMPLATE_DENIES_STEPS_OVERRIDE error. * * The `assemblyInstructions` input may be a JSON string, a full instructions object, * or a steps-only object (missing the `steps` property). */ lintAssemblyInstructions(options: LintAssemblyInstructionsOptions): Promise; /** * Mint a short-lived bearer token via POST /token. * * This uses HTTP Basic Auth (authKey + authSecret) and can optionally request a narrowed scope. * If `scope` is omitted, the token inherits the auth key's scope. */ mintBearerToken(options?: Omit & { endpoint?: string; }): Promise; resumeAssemblyUploads(opts: ResumeAssemblyUploadsOptions): Promise; awaitAssemblyCompletion(assemblyId: string, { onAssemblyProgress, timeout, startTimeMs, interval, assemblyUrl, signal, onPoll, }?: AwaitAssemblyCompletionOptions): Promise; maybeThrowInconsistentResponseError(message: string): void; /** * Cancel the assembly * * @param assemblyId assembly ID * @returns after the assembly is deleted */ cancelAssembly(assemblyId: string): Promise; /** * Replay an Assembly * * @param assemblyId of the assembly to replay * @param optional params * @returns after the replay is started */ replayAssembly(assemblyId: string, params?: ReplayAssemblyParams): Promise; /** * Replay an Assembly notification * * @param assemblyId of the assembly whose notification to replay * @param optional params * @returns after the replay is started */ replayAssemblyNotification(assemblyId: string, params?: ReplayAssemblyNotificationParams): Promise; /** * List all assemblies * * @param params optional request options * @returns list of Assemblies */ listAssemblies(params?: ListAssembliesParams): Promise>; streamAssemblies(params: ListAssembliesParams): Readable; /** * Get an Assembly * * @param assemblyId the Assembly Id * @param options optional request options * @returns the retrieved Assembly */ getAssembly(assemblyId: string, options?: { signal?: AbortSignal; }): Promise; private _fetchAssemblyStatus; /** * Create a Credential * * @param params optional request options * @returns when the Credential is created */ createTemplateCredential(params: CreateTemplateCredentialParams): Promise; /** * Edit a Credential * * @param credentialId the Credential ID * @param params optional request options * @returns when the Credential is edited */ editTemplateCredential(credentialId: string, params: CreateTemplateCredentialParams): Promise; /** * Delete a Credential * * @param credentialId the Credential ID * @returns when the Credential is deleted */ deleteTemplateCredential(credentialId: string): Promise; /** * Get a Credential * * @param credentialId the Credential ID * @returns when the Credential is retrieved */ getTemplateCredential(credentialId: string): Promise; /** * List all TemplateCredentials * * @param params optional request options * @returns the list of templates */ listTemplateCredentials(params?: ListTemplateCredentialsParams): Promise; streamTemplateCredentials(params: ListTemplateCredentialsParams): PaginationStream; /** * Create an Assembly Template * * @param params optional request options * @returns when the template is created */ createTemplate(params: CreateTemplateParams): Promise; /** * Edit an Assembly Template * * @param templateId the template ID * @param params optional request options * @returns when the template is edited */ editTemplate(templateId: string, params: EditTemplateParams): Promise; /** * Delete an Assembly Template * * @param templateId the template ID * @returns when the template is deleted */ deleteTemplate(templateId: string): Promise; /** * Get an Assembly Template * * @param templateId the template ID * @returns when the template is retrieved */ getTemplate(templateId: string): Promise; /** * List all Assembly Templates * * @param params optional request options * @returns the list of templates */ listTemplates(params?: ListTemplatesParams): Promise>; streamTemplates(params?: ListTemplatesParams): PaginationStream; /** * Get account Billing details for a specific month * * @param month the date for the required billing in the format yyyy-mm * @returns with billing data * @see https://transloadit.com/docs/api/bill-date-get/ */ getBill(month: string): Promise; calcSignature(params: OptionalAuthParams, algorithm?: string): { signature: string; params: string; }; /** * Construct a signed Smart CDN URL. See https://transloadit.com/docs/topics/signature-authentication/#smart-cdn. */ getSignedSmartCDNUrl(opts: SmartCDNUrlOptions): string; private _calcSignature; private _appendForm; private _appendParamsToUrl; private _prepareParams; private _getExpiresDate; private _remoteJson; } //# sourceMappingURL=Transloadit.d.ts.map