Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@elastic.io/oih-standard-library
Advanced tools
For implementing Delete action in most cases you need to extend from DeleteById
or DeleteByUniqueCriteria
classes.
If you need completely custom behaviour you can extend from Delete
class and override process and deleteObject method,
in this case following OIH standard is your responsibility.
Note:
deleteObject
method is returning null
empty object would be emitted. You can indicate with null
that object hasn`t been deleted or found.findObjectById
and deleteObject()
methods. Example below.getType
and getId
methods. Default implementation expects objectType
to be present in input configuration and id
in input message.logger
to constructor. const myDeleteByIDImpl = new MyDeleteByIdImpl(logger);
myDeleteByIDImpl.process(msg, cfg, snapshot)
as process method. Example below.Works in sailor > 2.4.2 Delete Action
const { DeleteById } = require('@elastic.io/oih-standard-library/lib/actions/delete');
class MyDeleteByIDImpl extends DeleteById {
async findObjectById(id, type, cfg, msg) { // In most cases you need just id, type and cfg
const object = await findObjectInAPI(id, type, cfg, msg); // objects that match this id
const numberOfObjects = object.count; // You do not need to check or throw error in this case, action implementation will do this
return { // return structure must contain object and numberOfObjects found
object,
numberOfObjects
}
}
async deleteObject(object, cfg, msg) { // In most cases you need just object, type and cfg
const deletedID = await deleteObjectInAPI(object, cfg, msg); // Delete object
return deletedID; // Return deleted object ID if you return null, empty object would be emitted.
}
// You can also override getType and getId methods if needed
}
async function process(msg, cfg, snapshot = {}) {
const deleteAction = new MyDeleteByIDImpl(this.logger); // Sailor version > 2.4.2
return deleteAction.process(msg, cfg, snapshot);
}
module.exports.process = process;
Note:
deleteObject
method is returning null
empty object would be emitted. You can indicate with null
that object hasn`t been deleted or found.findObjectByCriteria
and deleteObject()
methods. Example below.getType
and getCriteria
methods. Default implementation expects objectType
to be present in input configuration. For unique criteria: uniqueCriteria
field name in input configuration and value in input message.logger
to constructor. const myDeleteByCriteriaImpl = new MyDeleteByCriteriaImpl(logger);
myDeleteByCriteriaImpl.process(msg, cfg, snapshot)
as process method. Example below.Works in sailor > 2.4.2 Delete Action
const { DeleteByUniqueCriteria } = require('@elastic.io/oih-standard-library/lib/actions/delete');
class MyDeleteByCriteriaImpl extends DeleteByUniqueCriteria {
async findObjectByUniqueCriteria(criteria, type, cfg, msg) { // In most cases you need just criteria, type and cfg
// criteria sructure {
// uniqueCriteria: 'fieldName',
// value: 'fieldValue',
// }
const object = await findObjectInAPI(criteria, type, cfg, msg); // objects that match this criteria
const numberOfObjects = object.count; // You do not need to check or throw error in this case, action implementation will do this
return { // return structure must contain object and numberOfObjects found
object,
numberOfObjects
}
}
async deleteObject(object, cfg, msg) { // In most cases you need just object, type and cfg
const deletedID = await deleteObjectInAPI(object, cfg, msg); // Delete object
return deletedID; // Return deleted object ID if you return null, empty object would be emitted.
}
// You can also override getType and getId methods if needed
}
async function process(msg, cfg, snapshot = {}) {
const deleteAction = new MyDeleteByCriteriaImpl(this.logger); // Sailor version > 2.4.2
return deleteAction.process(msg, cfg, snapshot);
}
module.exports.process = process;
FAQs
Library for OIH standards implementation
The npm package @elastic.io/oih-standard-library receives a total of 17 weekly downloads. As such, @elastic.io/oih-standard-library popularity was classified as not popular.
We found that @elastic.io/oih-standard-library demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.