🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@elastic.io/oih-standard-library

Package Overview
Dependencies
Maintainers
17
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic.io/oih-standard-library - npm Package Compare versions

Comparing version
1.0.0-rc4
to
1.0.0-rc5
+1
-1
lib/actions/delete.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["delete.ts"],"names":[],"mappings":"AAEA,8BAAsB,MAAM;IAExB,SAAS,CAAC,MAAM,MAAC;gBAEE,MAAM,EAAE,GAAG;IAI9B;;;;;;OAMG;aACmB,OAAO,CAAC,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,QAAQ,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAE/D;;;;;;OAMG;aACmB,YAAY,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA,EAAE,GAAG,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAElE;;;;;;OAMG;IAEI,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAI,GAAG;CAG3C;AAED,8BAAsB,UAAW,SAAQ,MAAM;IAE9B,OAAO,CAAC,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,QAAQ,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAyBtD;;;;;;OAMG;IAEI,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG;CAGxC;AAED,8BAAsB,sBAAwB,SAAQ,MAAM;IAE3C,OAAO,CAAC,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,QAAQ,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAoCtD;;;;;;OAMG;IAEI,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG;QACpC,cAAc,EAAE,GAAG,CAAC;QACpB,KAA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;KACZ;IASC;;;;;;;OAOG;aACiB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;QAChG,MAAM,EAAE,GAAG,CAAC;QACZ,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}

@@ -71,3 +71,3 @@ "use strict";

if (foundObject.numberOfObjects > 1) {
throw new Error('Found more than 1 object for provided criteria: ' + JSON.stringify(criteria));
throw new Error(`Found more than 1 object for provided criteria: ${JSON.stringify(criteria)}`);
}

@@ -108,4 +108,4 @@ if (foundObject.numberOfObjects === 0) {

return {
value,
uniqueCriteria: fieldName,
value,
};

@@ -112,0 +112,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"delete.js","sourceRoot":"","sources":["delete.ts"],"names":[],"mappings":";;AAAA,4CAA8D;AAE9D,MAAsB,MAAM;IAIxB,YAAmB,MAAW;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,CAAC;IAoBD;;;;;;OAMG;IACH,aAAa;IACN,OAAO,CAAC,GAAQ,EAAE,GAAQ;QAC7B,OAAO,GAAG,CAAC,sBAAU,CAAC,CAAC;IAC3B,CAAC;CACJ;AArCD,wBAqCC;AAED,MAAsB,UAAW,SAAQ,MAAM;IAEpC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ;QACnC,IAAI;YACA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;YAC1D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;YACrD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;YACrD,MAAM,EAAE,GAAG,IAAI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/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;YACvD,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACrD,IAAI,EAAE,KAAK,IAAI,EAAE;gBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mGAAmG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACvI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;gBACtE,OAAO,EAAE,CAAC;aACX;YACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gEAAgE,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;YACpG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;YACtE,OAAO,EAAE,EAAE,EAAE,CAAC;SACf;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+DAA+D,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;YAC3F,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAEC;;;;;;OAMG;IACH,aAAa;IACR,WAAW,CAAC,GAAQ,EAAE,GAAQ;QAInC,MAAM,SAAS,GAAG,GAAG,CAAC,0BAAc,CAAC,CAAC;QACtC,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7B,OAAO;YACL,KAAK;YACL,cAAc,EAAE,SAAS;SAC1B,CAAC;IACJ,CAAC;CAcF;AArED,wDAqEC"}

@@ -5,7 +5,7 @@ import { id, objectType, uniqueCriteria } from '../constants';

protected logger;
protected logger;
public constructor(logger: any) {
this.logger = logger;
}
public constructor(logger: any) {
this.logger = logger;
}

@@ -19,3 +19,3 @@ /**

*/
public abstract async process(msg, cfg, snapshot): Promise<any>;
public abstract async process(msg, cfg, snapshot): Promise<any>;

@@ -29,3 +29,3 @@ /**

*/
public abstract async deleteObject(object, cfg, msg): Promise<any>;
public abstract async deleteObject(object, cfg, msg): Promise<any>;

@@ -40,5 +40,5 @@ /**

// @ts-ignore
public getType(cfg: any, msg: any,): any {
return cfg[objectType];
}
public getType(cfg: any, msg: any): any {
return cfg[objectType];
}
}

@@ -48,27 +48,26 @@

public async process(msg, cfg, snapshot): Promise<any> {
try {
this.logger.info('Starting processing deleteById action');
this.logger.trace('Incoming configuration: %j', cfg);
this.logger.trace('Incoming message: %j', msg);
this.logger.trace('Incoming snapshot: %j', snapshot);
const id = this.getId(msg, cfg);
const type = this.getType(cfg, msg);
this.logger.trace('Id: %j and type: %j of object to be deleted', id, type);
const deletedId = await this.deleteObject(id, cfg, msg);
if (deletedId === null) {
this.logger.trace('Object with ID: %j and type: %j was not deleted or not found. Returning empty object', id, type);
this.logger.info('Finished processing deleteById action');
return {};
}
this.logger.trace('Successfully process delete call for id: %j and type: %j', id, type);
this.logger.info('Finished processing deleteById action');
return { id: deletedId };
} catch (e) {
this.logger.error('Unexpected error while processing delete call for message: %j', msg, e);
throw e;
}
public async process(msg, cfg, snapshot): Promise<any> {
try {
this.logger.info('Starting processing deleteById action');
this.logger.trace('Incoming configuration: %j', cfg);
this.logger.trace('Incoming message: %j', msg);
this.logger.trace('Incoming snapshot: %j', snapshot);
const id = this.getId(msg, cfg);
const type = this.getType(cfg, msg);
this.logger.trace('Id: %j and type: %j of object to be deleted', id, type);
const deletedId = await this.deleteObject(id, cfg, msg);
if (deletedId === null) {
this.logger.trace('Object with ID: %j and type: %j was not deleted or not found. Returning empty object', id, type);
this.logger.info('Finished processing deleteById action');
return {};
}
this.logger.trace('Successfully process delete call for id: %j and type: %j', id, type);
this.logger.info('Finished processing deleteById action');
return { id: deletedId };
} catch (e) {
this.logger.error('Unexpected error while processing delete call for message: %j', msg, e);
throw e;
}
}
/**

@@ -82,45 +81,44 @@ * Default implementation expects id to be present inside input message `id` param. If you need other behaviour override this method.

// @ts-ignore
public getId(msg: any, cfg: any): any {
return msg[id]
}
public getId(msg: any, cfg: any): any {
return msg[id];
}
}
export abstract class DeleteByUniqueCriteria extends Delete {
export abstract class DeleteByUniqueCriteria extends Delete {
public async process(msg, cfg, snapshot): Promise<any> {
try {
this.logger.info('Start processing deleteByUniqueCriteria action');
this.logger.trace('Incoming configuration: %j', cfg);
this.logger.trace('Incoming message: %j', msg);
this.logger.trace('Incoming snapshot: %j', snapshot);
const criteria = this.getCriteria(msg, cfg);
const type = this.getType(cfg, msg);
this.logger.trace('Start deleting object with criteria: %j and type: %j', criteria, type);
const foundObject = await this.findObjectByCriteria(criteria, type, cfg, msg);
if (foundObject.numberOfObjects > 1) {
throw new Error('Found more than 1 object for provided criteria: ' + JSON.stringify(criteria));
}
if (foundObject.numberOfObjects === 0) {
this.logger.trace('No objects for criteria: %j and type: %j, were found returning empty object', criteria, type);
this.logger.info('Finished processing deleteByUniqueCriteria action');
return {};
}
const { object } = foundObject;
this.logger.trace('Start deleting object: %j', object);
const id = await this.deleteObject(object, cfg, msg);
if (id === null) {
this.logger.trace('Object with unique criteria: %j and type: %j was not deleted or not found. Returning empty object', criteria, type);
this.logger.info('Finished processing deleteByUniqueCriteria action');
return {}
}
this.logger.trace('Successfully process delete call for criteria: %j and type: %j', criteria, type);
this.logger.info('Finished processing deleteByUniqueCriteria action');
return { id };
} catch (e) {
this.logger.error('Unexpected error while processing delete call for message: %j', msg, e);
throw e;
}
public async process(msg, cfg, snapshot): Promise<any> {
try {
this.logger.info('Start processing deleteByUniqueCriteria action');
this.logger.trace('Incoming configuration: %j', cfg);
this.logger.trace('Incoming message: %j', msg);
this.logger.trace('Incoming snapshot: %j', snapshot);
const criteria = this.getCriteria(msg, cfg);
const type = this.getType(cfg, msg);
this.logger.trace('Start deleting object with criteria: %j and type: %j', criteria, type);
const foundObject = await this.findObjectByCriteria(criteria, type, cfg, msg);
if (foundObject.numberOfObjects > 1) {
throw new Error(`Found more than 1 object for provided criteria: ${JSON.stringify(criteria)}`);
}
if (foundObject.numberOfObjects === 0) {
this.logger.trace('No objects for criteria: %j and type: %j, were found returning empty object', criteria, type);
this.logger.info('Finished processing deleteByUniqueCriteria action');
return {};
}
const { object } = foundObject;
this.logger.trace('Start deleting object: %j', object);
const id = await this.deleteObject(object, cfg, msg);
if (id === null) {
this.logger.trace('Object with unique criteria: %j and type: %j was not deleted or not found. Returning empty object', criteria, type);
this.logger.info('Finished processing deleteByUniqueCriteria action');
return {};
}
this.logger.trace('Successfully process delete call for criteria: %j and type: %j', criteria, type);
this.logger.info('Finished processing deleteByUniqueCriteria action');
return { id };
} catch (e) {
this.logger.error('Unexpected error while processing delete call for message: %j', msg, e);
throw e;
}
}
/**

@@ -134,13 +132,13 @@ * Default implementation expects unique criteria to be present inside input message `uniqueCriteria` param. If you need other behaviour override this method.

// @ts-ignore
public getCriteria(msg: any, cfg: any): {
uniqueCriteria: any,
value: any
} {
const fieldName = cfg[uniqueCriteria];
const value = msg[fieldName];
return {
uniqueCriteria: fieldName,
value,
}
}
public getCriteria(msg: any, cfg: any): {
uniqueCriteria: any,
value: any,
} {
const fieldName = cfg[uniqueCriteria];
const value = msg[fieldName];
return {
value,
uniqueCriteria: fieldName,
};
}

@@ -155,7 +153,6 @@ /**

*/
public abstract async findObjectByCriteria(criteria: any, type: any, cfg: any, msg: any): Promise<{
object: any,
numberOfObjects: number,
}>;
public abstract async findObjectByCriteria(criteria: any, type: any, cfg: any, msg: any): Promise<{
object: any,
numberOfObjects: number,
}>;
}
{
"name": "@elastic.io/oih-standard-library",
"version": "1.0.0-rc4",
"version": "1.0.0-rc5",
"description": "Library for OIH standards implementation",

@@ -22,3 +22,2 @@ "author": {

"tsc": "rm -fr out && tsc -p ./ --outDir lib/",
"pretest": "tslint -c tslint.json --project tsconfig.json lib/**/*.ts spec/**/*.ts --fix",
"preparepublish": "npm run tsc",

@@ -25,0 +24,0 @@ "prepublishOnly": "tsc -p ./ --outDir lib/",

@@ -24,7 +24,7 @@ [![CircleCI](https://circleci.com/gh/elasticio/oih-standard-library.svg?style=svg&circle-token=02f42b98b1e672b7f47ad98d88eb2b4d5155010d)](https://circleci.com/gh/elasticio/oih-standard-library)

Note:
* If more than 1 object was found with same id, error would be thrown by this implementation
* Its your responsibility to ensure that deleteObject deletes only 1 object. This implementation assume that `id` is unique for `objectType`.
* If `deleteObject` method is returning `null` empty object would be emitted. You can indicate with `null` that object hasn`t been deleted or found.
1. Create Action
2. Create class that extends DeleteById class
3. Override `findObjectById` and `deleteObject()` methods. Example below.
3. Override `deleteObject()` methods. Example below.
4. Optional override `getType` and `getId` methods. Default implementation expects `objectType` to be present in input configuration and `id` in input message.

@@ -41,14 +41,7 @@ 5. Create instance of your class and pass `logger` to constructor. `const myDeleteByIDImpl = new MyDeleteByIdImpl(logger);`

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(id, cfg, msg) { // In most cases you need just id, type and cfg
const deletedID = await deleteObjectInAPI(id, cfg, msg); // Delete object
return deletedID; // Return deleted object ID. If you return null, empty object would be emitted.
}
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

@@ -55,0 +48,0 @@ }