UNPKG

@sap/ams-dev

Version:

NodesJS AMS development environment

41 lines (33 loc) 1.5 kB
const uploadBaseDCL = require('./uploadBaseDcl'); class AmsClient { #credentials; constructor(credentials) { this.#validateCredentials(credentials); this.#credentials = credentials; } #validateCredentials(credentials) { if (!credentials) { throw new Error("Missing Identity Service credentials."); } const requiredAttributes = [ "certificate", "key", "authorization_instance_id", "url" ]; const missingAttributes = requiredAttributes.filter(a => !credentials[a]); if (missingAttributes.length > 0) { throw new Error(`Mandatory attibutes "${missingAttributes.join('", "')}" are missing in the Identity Service credentials.`); } } /** * Deploys a DCL bundle to the identity service instance from the environment. * @param {string} dclRoot - path to the DCL root folder that contains the schema and DCL packages to be deployed * @param {object} [uploadParams] - optional parameters for the upload request * @param {string} [uploadParams.deployerAppName] - a descriptive name of this deployer application to trace back the currently deployed DCL bundle on the AMS server to its source when DCL is deployed from more than one source. */ async uploadBaseDCL(dclRoot, uploadParams = {}) { return uploadBaseDCL(this.#credentials, dclRoot, uploadParams); } } module.exports = AmsClient;