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

@onereach/channel-transformer

v0.0.63

Published

Convert data model between different channels (Slack, Microsoft Teams, Generic...)

Downloads

82

Readme

🚜 Transformer between differend data model channels

Channles:

  • Generic model
  • Skack Block kit model

Installing:

We use TypeScript, and all types are described, full documentation you can find: https://onereach.gitlab.io/platform/transform-channels/index.html

In Browser using unpkg:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Channel transfromer. Browser + UNPKG</title>
</head>
<body>
  <script src="https://unpkg.com/@onereach/channel-transformer@latest/dist/channel-transformer.umd.min.js"></script>
  <script>
    var slackDataModel = {
      "blocks": [
        {
          "type": "section",
          "text": {
            "type": "mrkdwn",
            "text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
          }
        }
      ]
    }

    // Transform Slack data model to Generic model
    var genericModel = channelTransformer.transformSlackToGeneric(slackDataModel);

    // Transfrom back from Generic model to Slack data model
    var slackModel = channelTransformer.transformGenericToSlack(genericModel);

    console.log(genericModel, slackModel);
  </script>
</body>
</html>

ES6

  npm i @onereach/channel-transformer
import {
  transformSlackToGeneric,
  transformGenericToSlack
} from '@onereach/channel-transformer';

Node.js

  npm i @onereach/channel-transformer
const {
  transformSlackToGeneric,
  transformGenericToSlack
} = require('@onereach/channel-transformer');

const slackDataModel = {
	"blocks": [
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
			}
		}
	]
}



// Transform Slack data model to Generic model
const genericModel = transformSlackToGeneric(slackDataModel);

// Transfrom back from Generic model to Slack data model
const slackModel = transformGenericToSlack(genericModel);

console.log(genericModel, slackModel);

Developing: ✅ Tests for Slack -> Generic -> Slack ✅ Export types ✅ Can be imported in any js env

  • Microsoft Teams channel
  • Zoom channel

How it works

Sample: Microsoft Teams and Slack

  • Microsoft Teams Adaptive Cards data model 👉 transform to default data model 👉 transform from default data model to Slack Block kit data model
  • Slack Block kit data model 👉 transform to default data model 👉 transform from default data model to Microsoft Teams Adaptive Cards data model

Generic data model schema based on rule:

All data soted in Array of Object. Each object have three required and only possible properties:

  1. type - type is unic name of field
  2. props - all settings, states and so on of field
  3. children - Array of Objects dependent elements

Sample:

[
  {
    type: 'section',
    props: {
      variableName: '...',
      column: 2,
      value: ''
    },
    children: []
  },
  {
    type: 'input',
    props: {
      value: '',
      required: true
    },
    children: []
  }
]

Small html app for transfroming data from Slack to Genric > https://content-assets.onereach.ai/apps/channel-transformer-app/0.0.3/index.html

How to add new channels?

Before runnning dev mode install latest node.js and nvm then use command nvm use

  1. Create new brnach
  2. Copy structure of anu channel (Slack, Web) in ./src/channels
  3. Export main functions to ./src/
  4. Create script in package.json, take for example already created channels

How to test

  1. Slack -> Generic -> Slack. Command npm run test:slack