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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ta-interaktiv/types

v0.4.1

Published

Typescript types for commonly used objects and APIs

Downloads

93

Readme

@ta-interaktiv/types

Use this repository for all commonly used TypeScript interfaces and API definitions.

Installation within the packages repository

  1. Add the following line to the peer dependencies in package's package.json:
    "@ta-interaktiv/types": "file:../types",
  2. Add the following lines to the references property array in your package's tsconfig.json:
    { "path": "../types" }

Usage

ArticleId Interface

import React from 'react'
import { ArticleId } from '@ta-interaktiv/types'

interface Props extends ArticleId {
  additionalProp: string
}

/* 
Since the Props interface extends the ArticleId interface, you
have now access to the `articleId` property.
*/
function YourComponent({ articleId, additionalProp }: Props) {
  return (
    <div>
      This article has the ID {articleId}. Also, have this {additionalProp}.
    </div>
  )
}

The Locale interface works similar.

Tenants enum

Returns all the possible domain names of our paid meda tenants

import { Tenants, TenantStrings } from '@ta-interaktiv/types'

const bz = Tenants.bernerzeitung // -> 'bernerzeitung'

let domainName: TenantStrings
domainName = 'tagesanzeiger' // works
domainName = 'bilan' // TypeScript will complain

Types from APIs

Types from the APIs (apart from the old Newsnet API, see below), are not exposed from the top of the package. Instead they try to model the endpoints as close as possible.

Examples

import { Content } from '@ta-interaktiv/types/lib/feed-prod.unitycms.io/tenant/Content'
import { SiteInformation } from '@ta-interaktiv/types/lib/admin.publishing.tamedia.ch/admin-api/v1/SiteInformation'

In most cases you won't need to access this information directly, as the functions from @ta-interaktiv/api-access should give you the correct types by default. And you should talk to the API over the api-access package anyway.

Newsnet API Interfaces (Deprecated)

These interfaces are here to make working with what the Newsnet API spews out a bit easier. Unfortunately, it is quite impossible to get any reliable documentation from the APIs creator, so we have to reverse-engineer everything – and therefore potentially screwing up occasionally.

import { Sites } from '@ta-interaktiv/types'

fetch('https://m.tagesanzeiger.ch/api/sites/default')
  .then(response => {
    // Check for errors
    if (!response.ok) throw new Error('Oh no, there is some error!')

    // else parse the answer
    return response.json()
  })
  .then(data => {
    const siteInformation: Sites = data.site

    // Log the website name (e.g. "Tages-Anzeiger")
    console.log(siteInformation.name)
  })