Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function fixCumulusMessageSyntax(cumulusConfig) {
if (!cumulusConfig) return {};
deprecate('CumulusConfig', '1.15.0', 'AWS Parameters with task_config');
const test = new RegExp('^([\\{]{1}|[\\[]{1})(\\$.*)([\\]]{1}|[\\}]{1})$');
Object.keys(cumulusConfig).forEach((n) => {
if (isObject(cumulusConfig[n])) {
// eslint-disable-next-line no-param-reassign
cumulusConfig[n] = fixCumulusMessageSyntax(cumulusConfig[n]);
} else if (isString(cumulusConfig[n])) {
const match = cumulusConfig[n].match(test);
if (match) {
// eslint-disable-next-line no-param-reassign
cumulusConfig[n] = `{${match[0]}}`;
}
}
});
return cumulusConfig;
static async stop(arn, cause, error) {
deprecate('@cumulus/ingest/aws StepFunction.stop', '1.13.0');
const stepfunctions = new AWS.StepFunctions();
return stepfunctions.stopExecution({
executionArn: arn,
cause: cause,
error: error
}).promise();
}
}
async removeGranuleFromCmr(granuleId, collectionId) {
deprecate('@cumulus/api/Granule.removeGranuleFromCmr', '1.11.3', '@cumulus/api/Granule.removeGranuleFromCmrByGranule');
const granule = await this.get({ granuleId });
return this.removeGranuleFromCmrByGranule(granule);
}
function resp(context, err, bodyArg, statusArg = null, headers = {}) {
deprecate(
'@cumulus/api/response.resp()',
'1.10.3',
'@cumulus/api/responses'
);
if (!isFunction(context.succeed)) {
throw new TypeError('context as object with succeed method not provided');
}
let body = bodyArg;
let statusCode = statusArg;
if (err) {
log.error(err);
statusCode = statusCode || 400;
body = {
function hostId(env) {
deprecate('@cumulus/cmrjs/utils#hostId', '1.11.3');
return _get(
{ OPS: '', SIT: 'sit', UAT: 'uat' },
env,
'sit'
);
}
function getHost(environment = process.env) {
deprecate('@cumulus/cmrjs/utils#getHost', '1.11.3');
const env = environment.CMR_ENVIRONMENT;
if (environment.CMR_HOST) return environment.CMR_HOST;
const host = ['cmr', hostId(env), 'earthdata.nasa.gov'].filter((d) => d).join('.');
return host;
}
async function validateUMMG(ummMetadata, identifier, provider) {
deprecate('@cumulus/cmrjs/utils#validateUMMG', '1.11.3');
const version = ummVersion(ummMetadata);
let result;
try {
result = await got.post(`${getUrl('validate', provider, process.env.CMR_ENVIRONMENT)}granule/${identifier}`, {
json: true,
body: ummMetadata,
headers: {
Accept: 'application/json',
'Content-type': `application/vnd.nasa.cmr.umm+json;version=${version}`
}
});
if (result.statusCode === 200) {
return true;
}
constructor(provider, clientId, username, password) {
deprecate('@cmrjs/CMR', '1.11.3');
this.provider = provider;
this.cmrClient = new cmrClient.CMR({
provider,
clientId,
username,
password
});
}
function ummVersion(umm) {
deprecate('@cumulus/cmrjs/utils#ummVersion', '1.11.3');
return _get(umm, 'MetadataSpecification.Version', '1.4');
}
function getCmrFiles(input, granuleIdExtraction) {
deprecate('@cumulus/cmrjs.getCmrFiles', '1.11.3');
const files = [];
input.forEach((filename) => {
if (isCMRFilename(filename)) {
const cmrFileObject = {
filename,
granuleId: getGranuleId(filename, granuleIdExtraction)
};
files.push(cmrFileObject);
}
});
return files;
}