Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
adf-builder
Advanced tools
A library that simplifies building documents that follow the Atlassian Document Format structure.
Install the package using
npm i -S adf-builder
or
yarn add adf-builder
This package offers two ways of building documents:
import { Document } from 'adf-builder'; // For TypeScript or ES6
// const { Document } = require('adf-builder'); // For node/commonjs
const doc = new Document();
doc.paragraph()
.text('See the ')
.link('documention', 'https://example.com')
.text(' ')
.emoji('smile');
import { document, emoji, link } from 'adf-builder'; // For TypeScript or ES6
// const { document, emoji, link } = require('adf-builder'); // For node/commonjs
const doc = document`See the ${link('documentation', 'https://example.com')} ${emoji('smile')}`;
A document can be serialized in different ways:
const doc = new Document();
doc.toJSON(); // Returns the Atlassian Document Format structure
doc.toString(); // Returns a compact JSON string
JSON.stringify(doc); // Equivalent to 'doc.toString()', but can be used for pretty printing
If you use the library with TypeScript or with an IDE that interprets the index.d.ts
file declared
in package.json
for JavaScript projects, you will get automatic code completion.
In order to get an output like:
Hello @joe, please carefully read this contract
You would use:
const { Document } = require('adf-builder');
const doc = new Document();
doc.paragraph()
.text('Hello ')
.mention(id, 'joe')
.text(', please ')
.em('carefully')
.text(' read ')
.link('this contract', 'https://www.example.com/contract');
The Paragraph
class has some convenience methods for text with a single mark like strong
, link
, etc.
If you need more than one mark, you can use the marks builder:
const { Document, marks } = require('adf-builder');
const doc = new Document();
doc.paragraph()
.text('Formatted', marks().color('#f0f0f0').strong());
doc.applicationCard('Title')
.background('https://example.com/bg.png')
.link('https://example.com/something')
.description('Some description')
.detail()
.title('Status')
.text('Open')
.icon({url: 'https://example.com/open.png', title: 'Not resolved yet'});
For lists, there are some convenience methods that cover the simple cases. Consider a list like the following:
In order to create that list, you can use:
doc.bulletList()
.textItem('Do this first')
.textItem('Do this second');
Similarly for lists of links:
doc.orderedList()
.linkItem('Do this first', 'https://example.com/1')
.linkItem('Do this second', 'https://example.com/1');
For more complex use cases, use:
const list = doc.bulletList();
list.item().paragraph().text('a'); // add more to the paragraph
list.item().paragraph().text('b'); // add more to the paragraph
TBD
FAQs
Atlassian Document Format Builder
The npm package adf-builder receives a total of 4,147 weekly downloads. As such, adf-builder popularity was classified as popular.
We found that adf-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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.