Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@elastic.io/maester-client

Package Overview
Dependencies
Maintainers
15
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic.io/maester-client

The official object-storage client for sailor-nodejs.

  • 3.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
422
increased by2.93%
Maintainers
15
Weekly downloads
 
Created
Source

Maester Client

The official Elastic.io object-storage client.

Usage

Note: All the code snippets written in Typescript

Create client

import { ObjectStorageWrapper } from '@elastic.io/maester-client/dist/ObjectStorageWrapper';

const objectStorage = new ObjectStorageWrapper(this);

CRUD operations

Create object

The method has the following signature:

async createObject(data: object, queryKey?: string, queryValue?: string, ttl?: number)

where

  • data - object data to create. Required
  • queryKey, queryValue - searchable field (see below in Get objects by query parameter section). Optional, but if queryKey is specified, queryValue must be specified as well.
  • ttl - configurable object's time to live, milliseconds. Optional
const obj = await objectStorage.createObject(data, somequeriablefieldKey, somequeriablefieldValue, 60000);

Read operations

Get object by ID:

The method has the following signature:

async lookupObjectById(id: string)

where

  • id - Maester internal id of the object to update. E.g. '76380cae-aee3-457a-9029-d971f61e3731'. Required
const obj = await objectStorage.lookupObjectById(id);

As Maester is able to store any data type, the 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 following errors can be thrown:

  • Object Not Found
  • Invalid object id
Get objects by query parameter:

The method has the following signature:

async lookupObjectByQueryParameter(key: string, value: string)

where

  • key, value - searchable field. Required

If you create an object with a queriable header, internally it looks like this:

x-query-somequeriablefieldKey: somequeriablefieldValue

where 'x-query-' is a default prefix.

Using Maester REST API you can find this object by:

/objects?query[somequeriablefieldkey]=somequeriablefieldValue

Using the library:

const obj = await objectStorage.lookupObjectByQueryParameter('somequeriablefieldKey', 'somequeriablefieldValue');

The method returns a JSON array. It either is empty in case no objects found or contains objects

Update object

The method has the following signature:

async updateObject(id: string, data: object)

where

  • id - Maester internal id of the object to update. E.g. '76380cae-aee3-457a-9029-d971f61e3731'. Required
  • data - object to update. Required
const obj = await objectStorage.updateObject(id, data);

Delete object

The method has the following signature:

async deleteObjectById(id: string)

where

  • id - Maester internal id of the object to update. E.g. '76380cae-aee3-457a-9029-d971f61e3731'. Required
const obj = await objectStorage.deleteObjectById(id);

Keywords

FAQs

Package last updated on 01 Jul 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc