npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bonniernews/abbe-api-utils

v1.0.2

Published

Utilities for converting to Abbe article format

Readme

Abbe API utils

Utilities for converting to Abbe article format. The library provides types for all fields and an abstraction on top of DraftJS for the content. The library can also validate the data against Abbe's API Schema by calling the builder function .validateSchema(abbeUrl) on the article, where abbeUrl is the URL to the Abbe API you want to validate the data against.

Create article:

import { Article } from "@bonniernews/abbe-api-utils";

const article = Article.initialize()
  .setUuid("8aae8868-c423-4956-89fb-4cbffa75ee20")
  .setPublishedAt(new Date("2024-01-29"))
  .setCreated(new Date("2024-01-28"))
  .setUpdated(new Date("2024-01-30"))
  .setExternalId("external-id-123")
  .setHeadline("Amazing title")
  .setOriginalSource("original-source")
  .setArticleState(ArticleState.PUBLISHED)
  .setPremiumLevel(PremiumLevel.NONE)
  .setNewsValue(NewsValue.ONE)
  .setFunctionTags(["2406db2a-f085-4dcd-88a6-b803a94582e0"])
  .setStories(["a52f66c2-c844-44c7-9e72-3641872e4318"])
  .setBylines(["766156df-a398-4407-805e-db0bbba34104"])
  .setArticleType("a2a4b94d-1126-48c0-81e4-0c5b4a4865e7")
  .setCategories(["5d329def-c27b-4f0f-aaf5-c1873f674746"])
  .setLocations(["6c4defdd-2661-420a-9938-4f5bd1c75be8"])
  .setTags(["71fbe627-f0e9-4157-aeb7-67a1be2787e8"])
  .setChannels(["1a349e41-8d58-402c-ad61-759c2917acae"])
  .setSections(["1289c955-3e10-4074-8dca-d27bd2f52665"])
  .setPoints(["1289c955-3e10-4074-8dca-123123213scds"])
  .setContent(articleContent)
  .setPuff(
    Puff.initialize()
      .setHeadLine("Puff headline")
      .setSubheading("Sub heading")
      .setImage("6ccd1a11-9e8a-48c0-a669-196589d8bfbd")
  )
  .validateSchema("https://abbe-url.com")
  .then((article) => article.finalize());

Create article content

import { Article } from "@bonniernews/abbe-api-utils";

const content = Article.initializeContent()
  .addTitle("Amazing title");
  .addPreamble("Amazing preamble");
  .addHeadline("Amazing headline");
  .addText("Normal text")
  .addStyledText("Bold and italic text", [
    { style: Style.BOLD, position: { start: 0, length: 4 } },
    { style: Style.ITALIC, position: { start: 5, length: 4 } },
  ])
  .addStyledText("An awesome link", [
    {
      style: Style.LINK,
      position: { start: 3, length: 7 },
      url: "https://google.com",
    },
  ])
  .addImage({
    uuid: "72a1c287-0604-4297-9612-de6124c5ee0b",
    photoAuthor: "Mozart",
    caption: "He's Dope"
  })
  .addImageCollection([
    {
      uuid: "ece2653f-0fbb-434b-b380-11723cf23e6a",
      photoAuthor: "Author 1",
      caption: "Caption 1",
    },
    {
      uuid: "6ccd1a11-9e8a-48c0-a669-196589d8bfbd",
      photoAuthor: "Author 2",
      caption: "Caption 2",
    },
    {
      uuid: "d6d21ff6-f779-4dcd-bcf3-71cfd4c48e74",
      photoAuthor: "Author 3",
      caption: "Caption 3",
    }
  ])
  .addEmbed({
    embedUuid: "15e9c365-6dce-4d96-a168-aa3cbe17bb56",
    externalId: "22131"
  });

article.setContent(content)

If you want to laborate with creating an article in Abbe:

ts-node ./scripts/postAbbeArticle.ts

Test

npm run test

In order to run the tests with schema validation you need to set the ABBE_URL in your .env.schema-test-file See .env.schema-test.example for an example. Make sure to be on VPN and then run:

npm run test:schemaValidation

Release

npm version major/minor/patch
npm publish
git push
git push --tags