0.0.25 ā€¢ Published 2 years ago

@automatedtf/slate v0.0.25

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

0.0.25

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.17

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.9

3 years ago

0.0.16

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago