@adobe/pdfservices-node-sdk
Version:
The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.
185 lines (184 loc) • 8.63 kB
TypeScript
/// <reference types="node" />
import { Credentials } from "./auth/Credentials";
import { ClientConfig } from "./config/ClientConfig";
import { MimeType } from "./MimeType";
import { Asset } from "./io/Asset";
import { PDFServicesJob } from "./pdfjobs/jobs/PDFServicesJob";
import { NotifierConfig } from "./config/notifier/NotifierConfig";
import { PDFServicesResponse } from "./PDFServicesResponse";
import { StreamAsset } from "./io/StreamAsset";
import { PDFServicesJobStatusResponse } from "./PDFServicesJobStatusResponse";
/**
* This class is the entry point for all the PDF Service utilities.
* These utilities can be used to perform various functions such as submitting {@link PDFServicesJob},
* getting status of a {@link PDFServicesJob}, getting result of a {@link PDFServicesJob},
* uploading {@link Asset}, getting content of an {@link Asset}, deleting an {@link Asset} and refreshing an
* {@link Asset}.
*
* <p>
* Methods provided by the utility are:
* <ul>
* <li>Upload {@link Asset Asset(s)}</li>
* <li>Submit {@link PDFServicesJob}</li>
* <li>Get status of a {@link PDFServicesJob}</li>
* <li>Get result of a {@link PDFServicesJob}</li>
* <li>Get content of {@link Asset}</li>
* <li>Delete {@link Asset}</li>
* <li>Refresh {@link Asset}</li>
* </ul>
*/
export declare class PDFServices {
private readonly _executionContext;
/**
* Constructs a `PDFServices` instance with the given `Credentials` and `ClientConfig`.
*
* @param params The parameters for constructing a `PDFServices` instance.
* @param params.credentials Credentials to be used for authentication. Cannot be undefined.
* @param [params.clientConfig] Client configuration for `PDFServices`.
*/
constructor(params: {
credentials: Credentials;
clientConfig?: ClientConfig;
});
/**
* Upload content from read stream and returns an {@link Asset} to be used in PDF Services SDK.
*
* Method will not close the read stream, responsibility of closing the read stream lies with the client.
*
* @param params The parameters for uploading an asset.
* @param params.readStream The read stream to be uploaded. Cannot be undefined.
* @param params.mimeType The mime type of the read stream. Cannot be undefined.
*
* @returns A Promise that resolves to an {@link Asset} representing the uploaded content.
*
* @throws {@link ServiceApiError} Thrown if an error is encountered while submitting the job.
* @throws {@link SDKError} Thrown for client-side or network errors.
* @throws {@link ServiceUsageError} Thrown if service usage limits have been reached or credentials quota
* has been exhausted.
*/
upload(params: {
readStream: NodeJS.ReadableStream;
mimeType: MimeType | string;
}): Promise<Asset>;
/**
* Uploads content from read streams and returns a list of {@link Asset} to be used in PDF Services SDK.
*
* Method will not close the read stream, responsibility of closing the read stream lies with the client.
*
* @param params The parameters for uploading assets.
* @param params.streamAssets The list of object containing read stream and mime type. Cannot be undefined.
*/
uploadAssets(params: {
streamAssets: {
readStream: NodeJS.ReadableStream;
mimeType: MimeType | string;
}[];
}): Promise<Asset[]>;
/**
* Submits the {@link PDFServicesJob} with the given {@link NotifierConfig} and returns the polling URL.
*
* @param params - The parameters for the submission.
* @param params.job - The {@link PDFServicesJob} to be submitted. Cannot be undefined.
* @param [params.notifiers] - List of {@link NotifierConfig} to be used for notification.
*
* @returns A Promise that resolves to a string representing polling URL that can be used to get the status
* and result of the job.
*
* @throws {@link ServiceApiError} Thrown if an error is encountered while submitting the job.
* @throws {@link SDKError} Thrown for client-side or network errors.
* @throws {@link ServiceUsageError} Thrown if service usage limits have been reached or credentials quota has
* been exhausted.
*/
submit(params: {
job: PDFServicesJob;
notifiers?: NotifierConfig[];
}): Promise<string>;
/**
* Returns {@link PDFServicesResponse} for the submitted {@link PDFServicesJob} result.
*
* @typeParam T - Type of result in {@link PDFServicesResponse}. It will be an implementation of
* {@link PDFServicesJobResult}.
*
* @param params - The parameters for getting the job result.
* @param params.pollingURL - The URL to be polled to get the job result. Cannot be undefined.
* @param params.resultType - result class for {@link PDFServicesJob}, it will be an implementation of
* {@link PDFServicesJobResult}. Cannot be undefined.
*
* @returns A Promise that resolves to a {@link PDFServicesResponse} encapsulating the result of the job.
*
* @throws {@link ServiceApiError} Thrown if an error is encountered while submitting the job.
* @throws {@link SDKError} Thrown for client-side or network errors.
* @throws {@link ServiceUsageError} Thrown if service usage limits have been reached or credentials quota has
* been exhausted.
*/
getJobResult<T>(params: {
pollingURL: string;
resultType: new (...args: any[]) => T;
}): Promise<PDFServicesResponse<T>>;
/**
* Returns {@link StreamAsset} for the submitted {@link Asset}.
*
* @param params - The parameters for getting the content.
* @param params.asset - The {@link Asset} for which to retrieve the content. Cannot be undefined.
*
* @returns A Promise that resolves to a {@link StreamAsset} encapsulating the stream
* content along with the media type.
*
* @throws {@link ServiceApiError} Thrown if an error is encountered while getting the content.
* @throws {@link SDKError} Thrown for client-side or network errors.
* @throws {@link ServiceUsageError} Thrown if service usage limits have been reached or credentials quota has
* been exhausted.
*/
getContent(params: {
asset: Asset;
}): Promise<StreamAsset>;
/**
* Deletes asset from PDF Services storage.
*
* @param params - The parameters for deleting the asset.
* @param params.asset {@link Asset} asset to be deleted. Cannot be undefined.
*
* @returns A promise that resolves when the asset is deleted.
*
* @throws {@link ServiceApiError} Thrown if an error is encountered while getting the content.
* @throws {@link SDKError} Thrown for client-side or network errors.
* @throws {@link ServiceUsageError} Thrown if service usage limits have been reached or credentials quota has
* been exhausted.
*/
deleteAsset(params: {
asset: Asset;
}): Promise<void>;
/**
* Returns {@link PDFServicesJobStatusResponse} for the submitted {@link PDFServicesJob}.
*
* @param params The parameters for getting the job status.
* @param params.pollingURL URL to be polled to get the job status. Cannot be undefined.
*
* @returns A Promise that resolves to a {@link PDFServicesJobStatusResponse} encapsulating the job status
* and retry interval.
*
* @throws {@link ServiceApiError} Thrown if an error is encountered while getting the content.
* @throws {@link SDKError} Thrown for client-side or network errors.
* @throws {@link ServiceUsageError} Thrown if service usage limits have been reached or credentials quota has
* been exhausted.
*/
getJobStatus(params: {
pollingURL: string;
}): Promise<PDFServicesJobStatusResponse>;
/**
* Returns a new {@link Asset} with a new valid download URI.
*
* @param params - The parameters for refreshing the download URI.
* @param params.asset - The {@link Asset} to be refreshed. Cannot be undefined.
*
* @returns A Promise that resolves to an {@link Asset} with new valid download URI.
*
* @throws {@link ServiceApiError} Thrown if an error is encountered while getting the content.
* @throws {@link SDKError} Thrown for client-side or network errors.
* @throws {@link ServiceUsageError} Thrown if service usage limits have been reached or credentials quota has
* been exhausted.
*/
refreshDownloadURI(params: {
asset: Asset;
}): Promise<Asset>;
}