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/maester-client
Advanced tools
The official Elastic.io object-storage client.
This library propose you two clients: ObjectStorage
& ObjectStorageWrapper
.
Use ObjectStorageWrapper
to operate with data like string
, number
, object
, array
Use ObjectStorage
to operate attachments (also could be used for same purpose as ObjectStorageWrapper
)
Note: All the code snippets written in Typescript
import { ObjectStorage, ObjectStorageWrapper } from '@elastic.io/maester-client';
const objectStorageWrapper = new ObjectStorageWrapper(this);
const objectStorage = new ObjectStorage(creds);
The method has the following signature:
async createObject(data: object, queryHeaders?: Header[], metaHeaders?: Header[], ttl?: number)
where
{ key: string, value: string }
, current maximum - 5 items. Where key
(must be lowercase) - searchable field name (see below in Get objects by query parameters
section), must be unique for whole array, if specified - value
must be specified as well; value
- searchable field value, if specified - key
must be specified as well. Optional{ key: string, value: string }
, where key
(must be lowercase) - meta field name, must be unique for whole array, if specified - value
must be specified as well; value
- meta field value, if specified - key
must be specified as well. Optionalconst obj = await objectStorageWrapper.createObject(data);
const obj = await objectStorageWrapper.createObject(data, [], [], 100000);
const obj = await objectStorageWrapper.createObject(
data,
[{key: 'somequeriablefieldkey', value: 'somequeriablefieldvalue'}],
[{key: 'somemetakey', value: 'somemetavalue'}],
60000
);
const obj = await objectStorageWrapper.createObject(
data,
[{key: 'anotherqueriablefieldkey', value: 'anotherqueriablefieldvalue'}, {key: 'anotherqueriablefieldkey2', value: 'anotherqueriablefieldvalue2'}],
[{key: 'somemetakey', value: 'somemetavalue'}],
60000
);
Returns JSON object. The method has the following signature:
async lookupObjectById(id: string)
where
const obj = await objectStorageWrapper.lookupObjectById(id);
The method has the following signature:
async lookupObjectsByQueryParameters(headers: Header[])
where
{ key: string, value: string }
, current maximum - 5 items. Where key
(must be lowercase) - searchable field name, must be unique for whole array, if specified - value
must be specified as well; value
- searchable field value, if specified - key
must be specified as well. RequiredIf you create an object with a queriable headers, internally it looks like this:
x-query-somequeriablefieldkey: somequeriablefieldvalue
x-query-anotherqueriablefieldkey: anotherqueriablefieldvalue
where 'x-query-' is a default prefix.
Using Maester REST API you can find this object by:
/objects?query[somequeriablefieldkey]=somequeriablefieldvalue&query[anotherqueriablefieldkey]=anotherqueriablefieldvalue
Using the library:
const objects = await objectStorageWrapper.lookupObjectsByQueryParameters([
{ key: 'somequeriablefieldkey', value: 'somequeriablefieldvalue' },
{ key: 'anotherqueriablefieldkey', value: 'anotherqueriablefieldvalue' }
]);
The method returns an array of items. It either is empty in case no objects found or contains objects
The method has the following signature:
async updateObject(id: string, data: object, queryHeaders?: Header[], metaHeaders?: Header[])
where
{ key: string, value: string }
, current maximum - 5 items. Where key
(must be lowercase) - searchable field name (see below in Get objects by query parameters
section), must be unique for whole array, if specified - value
must be specified as well; value
- searchable field value, if specified - key
must be specified as well. Note: queryHeaders could be added to an existing object and modified as well, but they can not be deleted. Optional{ key: string, value: string }
, where key
(must be lowercase) - meta field name, must be unique for whole array, if specified - value
must be specified as well; value
- meta field value, if specified - key
must be specified as well. Note: metaHeaders could be added to an existing object and modified as well, but they can not be deleted. Optionalconst obj = await objectStorageWrapper.updateObject(id, data);
const obj = await objectStorageWrapper.updateObject(
id,
data,
[{ key: 'somequeriablefieldkey', value: 'somequeriablefieldvalue' }, { key: 'anotherqueriablefieldkey', value: 'anotherqueriablefieldvalue' }]
);
const obj = await objectStorageWrapper.updateObject(
id,
data,
[{key: 'anotherqueriablefieldkey', value: 'anotherqueriablefieldvalue'}, {key: 'anotherqueriablefieldkey2', value: 'anotherqueriablefieldvalue2'}],
[{key: 'somemetakey', value: 'somemetavalue'}]
);
The method has the following signature:
async deleteObjectById(id: string)
where
const obj = await objectStorageWrapper.deleteObjectById(id);
The method has the following signature:
async deleteObjectsByQueryParameters(headers: Header[])
where
{ key: string, value: string }
, current maximum - 5 items. Where key
(must be lowercase) - searchable field name, must be unique for whole array, if specified - value
must be specified as well; value
- searchable field value, if specified - key
must be specified as well. Requiredconst obj = await objectStorageWrapper.deleteObjectsByQueryParameters([{key: 'somequeriablefieldkey', value: 'somequeriablefieldvalue'}]);
The method has the following signature:
async add(dataOrFunc: uploadData | (() => Promise<Readable>), reqWithBodyOptions?: ReqWithBodyOptions)
where
const obj = await objectStorage.add(data, { override: {'x-query-somequeriablefieldkey': 'somequeriablefieldvalue'} });
const getAttachAsStream = async () => (await axios.get('https://img.jpg', { responseType: 'stream' })).data;
const obj = await objectStorage.add(getAttachAsStream, { retryOptions: { retriesCount: 5, retryDelay: 10000, requestTimeout: 60000 } });
);
The method has the following signature:
async getOne(objectId: string, reqOptions: ReqOptions = {})
where
const obj = await objectStorage.getOne(id);
const obj = await objectStorage.getOne(id, { responseTYpe: 'stream'});
By default method returns a raw string, you may want to parse JSON or do any other data processing according to object's expected data type:
const parsedObject = JSON.parse(obj);
The method has the following signature:
async getAllByParams(params: object, reqOptions: ReqOptions = {})
where
Examples:
const obj = await objectStorage.getAllByParams({ 'query[field]': 'value' });
The method returns an array of items. It either is empty in case no objects found or contains objects
The method has the following signature:
async update(objectId: string, dataOrFunc: uploadData | (() => Promise<Readable>), reqWithBodyOptions?: ReqWithBodyOptions)
where
const obj = await objectStorage.update(data, { override: {'x-query-somequeriablefieldkey': 'somequeriablefieldvalue'} });
const getAttachAsStream = async () => (await axios.get('https://img.jpg', { responseType: 'stream' })).data;
const obj = await objectStorage.update(getAttachAsStream);
);
The method has the following signature:
async deleteOne(objectId: string, reqOptions: ReqOptions = {})
where
const obj = await objectStorage.deleteOne(id);
const obj = await objectStorage.deleteOne(id, { retryOptions: { retriesCount: 5, retryDelay: 10000, requestTimeout: 60000 } });
The method has the following signature:
async deleteAllByParams(params: object, reqOptions: ReqOptions = {})
where
const obj = await objectStorage.deleteAllByParams({ 'query[field]': 'value' });
The method has the following signature:
async use(forward: TransformMiddleware, reverse: TransformMiddleware)
where
Create
and Update
object operations (add
, update
methods).Get
object operations (getOne
, getAllByParams
methods).The method has the following signature:
async getHeaders(objectId: string, reqOptions: ReqOptions = {})
where
Create
and Update
object operations (add
, update
methods).Get
object operations (getOne
, getAllByParams
methods).ObjectStorage
and ObjectStorageWrapper
could'n process undefined
as values for upsert value. Also value undefined
in array will be converted to null
, e.g
[1, 'str', undefined, null, { d: 2 }]
will be saved as [1, 'str', null, null, { d: 2 }]
FAQs
The official object-storage client
The npm package @elastic.io/maester-client receives a total of 329 weekly downloads. As such, @elastic.io/maester-client popularity was classified as not popular.
We found that @elastic.io/maester-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.