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

forever-chat-format

v1.2.1

Published

Validators for a chat exporter to ensure data conforms to forever chat format standards

Downloads

10

Readme

Forever Chat Format

Why

Because in the world where our communication is siloed into Google Hangouts, Facebook, iMessage, WhatsApp, etc etc it's getting hard to hold onto conversations for archival purposes. First thing we need is a universal format that we can export those proprietary chats into that's easy to understand, and that can be relied upon.

Basic Format

Output should be an array of hashes, and each object in the array is a JSON object defined as follows:

Chat Object Definition

Name | Type | Description ----------- | ------- | ------------- sha | string | sha1 of [sender, receiver, date, text, service] sender | string | The handle of the person sending the message receiver | string | The handle of the person receiving the message is_from_me | boolean | true if you sent the message send_error | boolean | true if the message didn't send date | ISO-8601 datetime | date message was sent/received by sender service | string | Service message was sent using. All lowercase, dasherized. 'imessage', 'google-hangouts', 'facebook-messenger', 'sms' date_read | ISO-8601 datetime | (optional) date message was sent/read by receiver date_delivered | ISO-8601 datetime | (optional) date message was delivered by receiver participants | array | (see definition below) An array of strings of handles involved in the conversations. Used for grouping. For a two person conversation, this has two entries in it. Sender and receiver are always here. message_text | string | text representation of the message message_segments | array | (see definition below) ordered segments of content as it appears in the message attachments | array | (see definition below) array of attachments associated_sha | string | sha of message this message is in response to. Generally used for reactions _debug | object | (optional) debug information to help trace back to the source of the data

Message Segment Definition

Name | Type | Possible Values | Description ----------- | ------- | ----------------- | ------------- type | string | text, link, file | base segment type file_type | string | null, or a mime_type | only valid when type == file path | string | url or file path |
text | string | | the rendered name of the link, or the text content for the text, or optionally

Text Segment
{"type": "text", "text": "Why hello there"}
Link Segment
{"type": "link", "text": "Whoa, unreal", "path": "http://latlmes.com/technology/why-we-need-a-new-chat-format-1"}
File Segment
{"type": "file", "file_type": "image/png", "path": "/path/to/image.png"}
Reaction Segment
{"type": "reaction", "reaction_type": "laughed"}
Attachments

Array of attachments in the order they were received. Each attachment has the following properties. This information should also be made available in message_segments.

Name | Type
----------- | -------
path | string
type | string

Usage

The included tests check whether some json is valid forever chat format.

var foreverJson    = importer("test.json"); // done by an exporter

var {validate, runTests} = require('forever-chat-format-tests');

runTests(foreverJson); // runs mocha tests on data

The last step of your exporter should be to pass your exported data to the prepare function. It will check that the data conforms to the forever-chat-format spec and then return a hash with two keys: messages, and validations. Messages is all the data your exporter returned, and validations are what you see below:


"validations": {
  "version":           1.2 // forever chat version
  "checkedCount":      100 // number of records checked
  "errorCount":        0   // number of records with errors
  "recordsWithErrors":
  "ruleResults": { /* each rule keyed by name with errorCount and "erroredRecords" */
    "unique-sha": {
      "description":    "Each record should have a unique sha",
      "errorCount":     0,
      "erroredRecords": []
    }

    ...
  }
}
Testing
var foreverJson   = importer("test.json"); // done by an exporter
var {validate, runTests} = require('forever-chat-format-tests');
runTests(foreverJson);