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

packmanager-communication-lib

v1.6.0

Published

<img src="https://cdn-assets-us.frontify.com/s3/frontify-enterprise-files-us/eyJwYXRoIjoidGFrZS1ibGlwXC9maWxlXC9XVWd4aXVvM1hVRFE1bjY1ZkVQcy5wbmcifQ:take-blip:qBJSAo9ZoZ2yI9HuPMPLzzqaqJWtjofNbU-i4eY9Kho?width=2400" alt="Blip Packs" width="200" style="displ

Downloads

233

Readme

Pack Manager Communication Library

Description

Esta biblioteca TypeScript/Javascript foi desenvolvida para facilitar a comunicação entre o aplicativo Pack Manager e um módulo implementado via iframe. Ela fornece métodos simples e eficazes para acessar dados compartilhados pelo aplicativo Pack Manager.

Installation

Para começar a usar a biblioteca, basta instalá-la em seu projeto usando npm ou yarn:

npm install packmanager-communication-lib
# or
yarn add packmanager-communication-lib

Available Methods

1. getDataFromPackManager(propertyName: string)

Recupera dados genéricos do Pack Manager com base no usuário conectado e no Pack instalado. O parâmetro propertyName é o nome da propriedade que você precisa recuperar.

JavaScript usando Promises

const packmanager = require("packmanager-communication-lib");

packmanager.getDataFromPackManager("profile").then(profile => {
  console.log("Profile:", profile);
});

TypeScript usando Async/Await

import { getDataFromPackManager } from "packmanager-communication-lib";

async function fetchProfileData() {
  const profile: string = await getDataFromPackManager("profile");
  console.log("Profile:", profile);
}

fetchProfileData();

2. getProfile()

Recupera o perfil do usuário conectado, seguindo as reivindicações padrão do OpenID Connect Core 1.0.

JavaScript usando Promises

const packmanager = require("packmanager-communication-lib");

packmanager.getProfile().then(profile => {
  console.log("User Profile:", profile);
});

TypeScript usando Async/Await

import { getProfile } from "packmanager-communication-lib";

async function fetchUserProfile() {
  const profile: Profile = await getProfile();
  console.log("User Profile:", profile);
}

fetchUserProfile();

3. getRouterData()

Recupera dados do roteador instalado.

Esta é a definição do tipo RouterData:

/**
 * @description Interface para tipar os dados do roteador
 * @interface RouterData
 * @property {string} shortName - Nome curto do roteador
 * @property {string} accessKey - Chave de acesso do roteador
 * @property {object} skillTransbordo - Skill de transbordo
 * @property {string} skillTransbordo.shortName - Nome curto da skill de transbordo
 * @property {string} skillTransbordo.accessKey - Chave de acesso da skill de transbordo
 */
export type RouterData = {
  shortName: string;
  accessKey: string;

  skillTransbordo: {
    shortName: string;
    accessKey: string;
  };
};

JavaScript usando Promises

const packmanager = require("packmanager-communication-lib");

packmanager.getRouterData().then(routerData => {
  console.log("Installed Router Data:", routerData);
});

TypeScript usando Async/Await

import { getRouterData } from "packmanager-communication-lib";

async function fetchRouterData() {
  const routerData: RouterData = await getRouterData();
  console.log("Installed Router Data:", routerData);
}

fetchRouterData();

4. getTenantId()

Recupera o ID do locatário do roteador instalado.

JavaScript usando Promises

const packmanager = require("packmanager-communication-lib");

packmanager.getTenantId().then(tenantId => {
  console.log("Tenant ID:", tenantId);
});

TypeScript usando Async/Await

import { getTenantId } from "packmanager-communication-lib";

async function fetchTenantId() {
  const tenantId: string = await getTenantId();
  console.log("Tenant ID:", tenantId);
}

fetchTenantId();

5. getOwnerIdentity()

Recupera a identidade do proprietário do roteador instalado.

JavaScript usando Promises

const packmanager = require("packmanager-communication-lib");

packmanager.getOwnerIdentity().then(owner => {
  console.log("Owner:", owner);
});

TypeScript usando Async/Await

import { getOwnerIdentity } from "packmanager-communication-lib";

async function fetchOwner() {
  const owner: string = await getOwnerIdentity();
  console.log("Owner:", owner);
}

fetchOwner();

6. showTextNotification(notificationType,notificationTitle, notificationText: string)

Envia uma notificação de texto para o Pack Manager. É usado para mostrar mensagens de aviso, mensagens de erro e mensagens de sucesso.

Parâmetros

| Nome do Parâmetro | Tipo | Descrição | | --------------------- | ---------------------------------------------- | ------------------------------------- | | notificationType | enumeração de string (Warning, Error, Success) | Tipo de toast a ser exibido | | notificationTitle | string | Título do toast a ser exibido | | notificationText | string | Texto a ser exibido |

JavaScript usando Promises

const packmanager = require("packmanager-communication-lib");

// Success
packmanager.showTextNotification("Success", "Title", "Text");

// Warning
packmanager.showTextNotification("Warning", "Title", "Text");

// Error
packmanager.showTextNotification("Error", "Title", "Text");

TypeScript usando Async/Await

import { showTextNotification } from "packmanager-communication-lib";

async function showMessages() {
  // Success
  await showTextNotification("Success", "Title", "Text");

  // Warning
  await showTextNotification("Warning", "Title", "Text");

  // Error
  await showTextNotification("Error", "Title", "Text");
}

showMessages();

7. showIconNotification(backgroundColor, duration)

Mostra uma notificação de ícone, atualizando a cor de fundo do ícone do módulo.

Parâmetros

| Nome do Parâmetro | Tipo | Descrição | | --------------------- | -------- | ------------------------------------------------ | | backgroundColor | string | A cor para alterar a cor de fundo do ícone | | duration | number | Duração em milissegundos da alteração de cor |

JavaScript usando Promises

const packmanager = require("packmanager-communication-lib");

// Change color to red over 10 seconds
packmanager.showIconNotification("red", 10000);

TypeScript usando Async/Await

import { showIconNotification } from "packmanager-communication-lib";

async function showNotification() {
  // Change color to red over 10 seconds
  await showIconNotification("red", 10000);
}

showNotification();

Suporte

Se você precisar de suporte para esta biblioteca, ou se precisar de um novo recurso, envie um e-mail para [email protected]

Licença

Esta biblioteca é distribuída sob a licença ISC. Consulte a LICENÇA para obter mais detalhes. Sinta-se à vontade para contribuir ou relatar problemas!