source/node/archiveManagement/marshalling.js
function credentialsToDatasource(sourceCredentials) {
    return Promise.resolve()
        .then(function() {
            const datasourceDescriptionRaw = sourceCredentials.getValueOrFail("datasource");
            const datasourceDescription =
                typeof datasourceDescriptionRaw === "string"
                    ? JSON.parse(datasourceDescriptionRaw)
                    : datasourceDescriptionRaw;
            if (typeof datasourceDescription.type !== "string") {
                throw new VError("Invalid or missing type");
            }
            const datasource = objectToDatasource(datasourceDescription, sourceCredentials);
            return {
                datasource,
                credentials: sourceCredentials
            };
        })
        .catch(function __handleCreationError(err) {
            throw new VError(err, "Failed creating datasources");
        });
}
function credentialsToDatasource(sourceCredentials) {
    return Promise.resolve()
        .then(function() {
            const datasourceDescriptionRaw = sourceCredentials.getValueOrFail("datasource");
            const datasourceDescription =
                typeof datasourceDescriptionRaw === "string"
                    ? JSON.parse(datasourceDescriptionRaw)
                    : datasourceDescriptionRaw;
            if (typeof datasourceDescription.type !== "string") {
                throw new VError("Invalid or missing type");
            }
            const datasource = objectToDatasource(datasourceDescription, sourceCredentials);
            return {
                datasource,
                credentials: sourceCredentials
            };
        })
        .catch(function __handleCreationError(err) {
            throw new VError(err, "Failed creating datasources");
        });
}
function credentialsToDatasource ( sourceCredentials ) { return Promise . resolve ( ) . then ( function ( ) { const datasourceDescriptionRaw = sourceCredentials . getValueOrFail ( "datasource" ) ; const datasourceDescription = typeof datasourceDescriptionRaw === "string" ? JSON . parse ( datasourceDescriptionRaw ) : datasourceDescriptionRaw ; if ( typeof datasourceDescription . type !== "string" ) { throw new VError ( "Invalid or missing type" ) ; } const datasource = objectToDatasource ( datasourceDescription , sourceCredentials ) ; return { datasource , credentials : sourceCredentials } ; } ) . catch ( function __handleCreationError ( err ) { throw new VError ( err , "Failed creating datasources" ) ; } ) ; }
Convert credentials of a remote archive to a datasource
@param {Credentials} sourceCredentials The remote credentials. The credentials must
have a type field and datasource information field
@returns {Promise.<{datasource, credentials}>} A promise that resolves with the datasource and
source credentials
Convert credentials of a remote archive to a datasource