UNPKG

@adobe/pdfservices-node-sdk

Version:

The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.

107 lines 5.07 kB
"use strict"; /* * Copyright 2024 Adobe * All Rights Reserved. * * NOTICE: Adobe permits you to use, modify, and distribute this file in * accordance with the terms of the Adobe license agreement accompanying * it. If you have received this file from a source other than Adobe, * then your use, modification, or distribution of it requires the prior * written permission of Adobe. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.PDFServiceRequestContext = void 0; const RequestKey_1 = require("./constants/RequestKey"); const HttpBaseRequest_1 = require("./http/HttpBaseRequest"); const HttpMethod_1 = require("./http/HttpMethod"); const AuthenticationMethod_1 = require("./auth/AuthenticationMethod"); const SDKError_1 = require("../exception/SDKError"); const DefaultRequestHeaders_1 = require("./http/DefaultRequestHeaders"); class PDFServiceRequestContext { constructor(pdfServicesUri) { this.baseRequestMap = new Map([ [ RequestKey_1.RequestKey.CREATE_PRE_SIGNED_URI, new HttpBaseRequest_1.HttpBaseRequest({ uriTemplate: pdfServicesUri + "/assets", httpMethod: HttpMethod_1.HttpMethod.POST, requestKey: RequestKey_1.RequestKey.CREATE_PRE_SIGNED_URI, authenticationMethod: AuthenticationMethod_1.AuthenticationMethod.AUTH_HEADER_PRIMARY, headers: this.getDefaultHeaders() }) ], [ RequestKey_1.RequestKey.DELETE_ASSET, new HttpBaseRequest_1.HttpBaseRequest({ uriTemplate: pdfServicesUri + "/assets/", httpMethod: HttpMethod_1.HttpMethod.DELETE, requestKey: RequestKey_1.RequestKey.DELETE_ASSET, authenticationMethod: AuthenticationMethod_1.AuthenticationMethod.AUTH_HEADER_PRIMARY, headers: this.getDefaultHeaders() }) ], [ RequestKey_1.RequestKey.GET_ASSET, new HttpBaseRequest_1.HttpBaseRequest({ uriTemplate: pdfServicesUri + "/assets/", httpMethod: HttpMethod_1.HttpMethod.GET, requestKey: RequestKey_1.RequestKey.GET_ASSET, authenticationMethod: AuthenticationMethod_1.AuthenticationMethod.AUTH_HEADER_PRIMARY, headers: this.getDefaultHeaders() }) ], [ RequestKey_1.RequestKey.CREATE_JOB, new HttpBaseRequest_1.HttpBaseRequest({ uriTemplate: pdfServicesUri + "/operation/", httpMethod: HttpMethod_1.HttpMethod.POST, requestKey: RequestKey_1.RequestKey.CREATE_JOB, authenticationMethod: AuthenticationMethod_1.AuthenticationMethod.AUTH_HEADER_PRIMARY, headers: this.getDefaultHeaders() }) ], [ RequestKey_1.RequestKey.JOB_STATUS, new HttpBaseRequest_1.HttpBaseRequest({ httpMethod: HttpMethod_1.HttpMethod.GET, requestKey: RequestKey_1.RequestKey.JOB_STATUS, authenticationMethod: AuthenticationMethod_1.AuthenticationMethod.AUTH_HEADER_PRIMARY, headers: this.getDefaultHeaders() }) ], [ RequestKey_1.RequestKey.CLOUD_UPLOAD, new HttpBaseRequest_1.HttpBaseRequest({ httpMethod: HttpMethod_1.HttpMethod.PUT, requestKey: RequestKey_1.RequestKey.CLOUD_UPLOAD, authenticationMethod: AuthenticationMethod_1.AuthenticationMethod.UNAUTHENTICATED }) ], [ RequestKey_1.RequestKey.CLOUD_DOWNLOAD, new HttpBaseRequest_1.HttpBaseRequest({ httpMethod: HttpMethod_1.HttpMethod.GET, requestKey: RequestKey_1.RequestKey.CLOUD_DOWNLOAD, authenticationMethod: AuthenticationMethod_1.AuthenticationMethod.UNAUTHENTICATED, responseType: "stream" }) ] ]); } getBaseRequest(requestKey) { const baseRequest = this.baseRequestMap.get(requestKey); if (baseRequest) { return Object.create(baseRequest); // Clones the base request } throw new SDKError_1.SDKError(`RequestKey ${requestKey} is not supported`); } getDefaultHeaders() { return { Accept: DefaultRequestHeaders_1.DefaultRequestHeaders.ACCEPT_HEADER_VALUE, "Content-Type": DefaultRequestHeaders_1.DefaultRequestHeaders.CONTENT_TYPE_APP_JSON, "x-api-app-info": DefaultRequestHeaders_1.DefaultRequestHeaders.APP_API_INFO }; } } exports.PDFServiceRequestContext = PDFServiceRequestContext; //# sourceMappingURL=PDFServiceRequestContext.js.map