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

@automatedtf/slate

v0.0.25

Published

### πŸ“– Table of Contents - [πŸ‘‹ Introduction](#-introduction) - [πŸ”Œ Getting Started](#-getting-started) - [Parsing to an OfferArtifact](#parsing-to-an-offerartifact) - [The OfferArtifact Type](#the-offerartifact-type) - [ItemInstance](#iteminst

Downloads

38

Readme

Slate

πŸ“– Table of Contents

Introduction

Slate is a simple modular library to represent Steam trade offers using @automatedtf/sherpa in a standardised compact data object called an OfferArtifact; this format is optimised for archiving trade offers within a database.

πŸ”Œ Getting Started

You can install this module with npm within your project by running the command:

npm install @automatedtf/slate

Parsing to an OfferArtifact

This module exposes one function: parseToOfferArtifact.

const steamid: string = "76561198081082634"; // account of perspective offer object is seen from
const offer: TradeOffer = { ... }; // get from steam-tradeoffer-manager

const artifact: OfferArtifact = await parseToOfferArtifact(steamid, offer);

The OfferArtifact Type

The OfferArtifact type is the primary datatype you will be working with when interacting with this module.

type OfferArtifact = {

    // Carried over from TradeOffer type
    id?: string; // trade offer id
    message?: string; // trade message
    state: OfferState; // see OfferState enum in lib/types.ts

    // Own introduced fields
    created: number; // created at (unix timestamp)
    updated: number;  // last-updated (unix timestamp)
    expires: number; // expires at (unix timestamp)
    escrowEnds?: number; // time escrow complete (unix timestamp)
    sender: string; // steamid of sender
    recipient: string; // steamid of recipient
    itemsSending: ItemInstance[]; // Items being sent away from sender
    itemsReceiving: ItemInstance[]; // Items being received to the sender
} 

ItemInstance

The itemsSending and itemsReceiving field of OfferArtifact are both arrays of objects of the interface ItemInstance. This is an interface that is derived from @automatedtf/sherpa.

interface ItemInstance {
    appid: number;
    assetid: string;
    instanceid: string;
    classid: string;
    icon_url: string;
    sku: string;
    full_sku: string;
}

πŸ”— See @automatedtf/sherpa ItemInstance

Information Population with Sherpa

To provide sufficient item details, @automatedtf/sherpa is used to populate every item under itemsSending and itemsReceiving. Originally, the input TradeOffer object from steam-tradeoffer-manager will represent each item within itemsToGive and itemsToReceive as a TradeItem.

interface TradeItem {
    appid: number;
    contextid: string;
    assetid: string;
    classid: string;
    instanceid: string;
    ...
    descriptions: any[],
    ...
    tags: any[],
    tradable: boolean,
    ...
}

This may be insufficient to developers who may like e.g the icon_url of an item to quickly display the item visually on their website without making further API calls on-the-fly.

This is resolved by taking the TradeOffer object from and extracting the least but necessary fields of a TradeItem into an ItemInstance by using Catalog to represent item types and customisations as a single-string SKU and Sherpa to provide item instance information. This is all done as a TradeOffer is parsed to an OfferArtifact.

πŸ“š Helpful Resources