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

@cobuildlab/8base-utils

Package Overview
Dependencies
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cobuildlab/8base-utils

This is package to deal with common scenarios working with 8base platform

  • 0.5.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-62.5%
Maintainers
4
Weekly downloads
 
Created
Source

8base utils

This is a package for functions that are use full in common cases of working with the 8base.com platform.

Install

npm i --save @cobuildlab/8base-utils

API

FunctionDescription
normalize8baseReferenceConnectUpdates an object to change a property with a 8base connect operation.
normalize8baseDocumentCreateUpdates an object to change a property with a 8base create operation for a file object.
normalize8baseDocumentsCreateUpdates an object to change a property with a 8base create operation for a list of files objects.
normalize8baseDocumentDeleteAndUpdateUpdates an object to change a property with a 8base create and/or disconnect operation for a list of files objects.
normalize8baseDocumentsDeleteAndUpdateUpdates an object to change a property with a 8base create and/or disconnect operation for a list of files objects.

normalize8baseReferenceConnect(data, key)

  • Updates an object to change a property with a 8base connect operation.
  • If the value of the key is undefined or null, the property gets deleted from the object.
  • This function mutates the data object to reflect the change.
  • This function assumes that all 8base IDs are of type string.

Example:

import {normalize8baseReferenceConnect} from "@cobuildlab/8base-utils";

const issue = {name :"Issues Name", project: "<Project ID>"   };

normalize8baseReferenceConnect(issue, "project");

console.log(issue);
// {name :"Issues Name", project: {connect:{id: "<Project ID>"}}};

normalize8baseDocumentCreate(data, key)

  • Updates an object to change a property with a 8base create operation.
  • If the value of the key is undefined or null, the property gets deleted from the object.
  • This function mutates the data object to reflect the change.

Example:

import {normalize8baseDocumentCreate} from "@cobuildlab/8base-utils";

const issue = {name :"Issues Name", document: {fileId: "<FILE-ID>", filename:"<FILENAME>"}  };

normalize8baseDocumentCreate(issue, "document");

console.log(issue);
// {name :"Issues Name", document: {create:{fileId: "<FILE-ID>", filename:"<FILENAME>"}}};

normalize8baseDocumentsCreate(data, key)

  • Updates an object to change a property with a 8base create operation.
  • If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.
  • This function mutates the data object to reflect the change.

Example:

import {normalize8baseDocumentsCreate} from "@cobuildlab/8base-utils";

const issue = {name :"Issues Name", document: [{fileId: "<FILE-ID1>", filename:"<FILENAME1>"},{fileId: "<FILE-ID2>", filename:"<FILENAME2>"}]  };

normalize8baseDocumentsCreate(issue, "document");

console.log(issue);
// {name :"Issues Name", document: {create:[{fileId: "<FILE-ID1>",, filename:"<FILENAME1>"},{fileId: "<FILE-ID2>",, filename:"<FILENAME2>"}]}};

normalize8baseDocumentDeleteAndUpdate(data, key, oldData)

  • Helper to update or delete one document key from an Object.
  • Updates an object to change a property with a 8base create and/or disconnect operation.
  • If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.
  • This function mutates the data object to reflect the change.

Example:

import {normalize8baseDocumentDeleteAndUpdate} from "@cobuildlab/8base-utils";

const new12 = { a: { fileId: "FILE-ID1", filename:"<FILENAME>" } };
const old12 = {};
normalize8baseDocumentDeleteAndUpdate(new12, "a", old12);
expect(new12).toEqual({ a: { create: { fileId: "FILE-ID1", filename:"<FILENAME>" } } });

normalize8baseDocumentsDeleteAndUpdate(data, key, oldData)

  • Helper to change non null keys to 8base 'delete & create' reference for Documents Lists
  • Updates an object to change a property with a 8base create and/or disconnect operation.
  • If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.
  • This function mutates the data object to reflect the change.

Example:

import {normalize8baseDocumentsDeleteAndUpdate} from "@cobuildlab/8base-utils";

const new15 = { a: [{ fileId: "FILE-ID1", filename:"<FILENAME1>" }, { id: "ID2", fileId: "FILE-ID2", filename:"<FILENAME2>" }] };
const old15 = { a: [{ id: "FILE-ID2" }, { id: "ID2" }] };
normalize8baseDocumentsDeleteAndUpdate(new15, "a", old15);
expect(new15).toEqual({ a: { create: [{ fileId: "FILE-ID1", filename:"<FILENAME1>" }], disconnect: [{ id: "FILE-ID2" }] } });

Keywords

FAQs

Package last updated on 20 Nov 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