Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (re.test(item.name)) {
throw new Error('Names may only contain letters, numbers, and underscores.');
}
// Initialize new rule object
let newRuleItem = cloneDeep(item);
// the default state is 'ENABLED'
if (!item.state) {
newRuleItem.state = 'ENABLED';
}
const payload = await Rule.buildPayload(newRuleItem);
switch (newRuleItem.rule.type) {
case 'onetime': {
await invoke(process.env.invoke, payload);
break;
}
case 'scheduled': {
await this.addRule(newRuleItem, payload);
break;
}
case 'kinesis': {
const ruleArns = await this.addKinesisEventSources(newRuleItem);
newRuleItem = this.updateKinesisRuleArns(newRuleItem, ruleArns);
break;
}
case 'sns': {
if (newRuleItem.state === 'ENABLED') {
const snsSubscriptionArn = await this.addSnsTrigger(newRuleItem);
newRuleItem = this.updateSnsRuleArn(newRuleItem, snsSubscriptionArn);
}
workflow,
payload: {
granules: [g]
},
provider: g.provider,
collection: {
name,
version
},
queueName,
asyncOperationId
});
await this.updateStatus({ granuleId: g.granuleId }, 'running');
await aws.invoke(process.env.invoke, lambdaPayload);
}
static async invoke(item) {
const payload = await Rule.buildPayload(item);
await invoke(process.env.invoke, payload);
}
reingestGranule: true,
forceDuplicateOverwrite: true
}
},
payload: originalMessage.payload,
provider: granule.provider,
collection: {
name,
version
},
queueName: granule.queueName
});
await this.updateStatus({ granuleId: granule.granuleId }, 'running');
return aws.invoke(process.env.invoke, lambdaPayload);
}
async function post(req, res) {
const data = await invoke(process.env.invokeReconcileLambda, {});
return res.send({ message: 'Report is being generated', status: data.StatusCode });
}
payload: {
granules: [{
granuleId: granule.granuleId,
files: granule.files
}]
}
});
await partialRecordUpdate(
null,
granule.granuleId,
'granule',
{ status: 'running' },
granule.collectionId
);
await invoke(process.env.invoke, payload);
return {
granuleId: granule.granuleId,
action: 'reingest',
status: 'SUCCESS'
};
}
const originalMessage = JSON.parse(status.execution.input);
const payload = await Rule.buildPayload({
workflow: 'IngestGranule',
provider: g.provider,
collection: {
name,
version
},
meta: originalMessage.meta,
payload: originalMessage.payload
});
await this.updateStatus({ granuleId: g.granuleId }, 'running');
await aws.invoke(process.env.invoke, payload);
return {
granuleId: g.granuleId,
action: 'reingest',
status: 'SUCCESS'
};
}