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

@listendoctor/sdk

v0.0.8

Published

A customizable widget for laboratory data management.

Downloads

6

Readme

Listen.Doctor JavaScript SDK

npm (scoped) Test

Official JavaScript SDK for Listen.Doctor. Power your apps with world-class speech and Language AI models.

Installation

To install the necessary dependencies, run:

npm install

Building the Project

To build the project, run:

npm run build

The build output will be placed in the dist directory.

Project Structure

The project is organized into several directories to separate the application logic, public assets, and client-side resources efficiently:

/
├── dist/                 # Compiled and bundled output files
│
├── src/                  # Source files for the project
│   ├── services/         # Source code for services
│   │   ├── laboratory.ts
│   │   ├── main.ts
│   │   └── record.ts
│   │
│   ├── utils/            # Utility functions and helpers
│   │   ├── config.ts
│   │   ├── iam.ts
│   │   └── types.ts
│   │
│   └── index.ts          # Main entry point for the TypeScript source code
│
├── test/                 # Source files for the project
│   ├── dist/             # Compiled and bundled output files
│   │
│   ├── src/           
│   │   └── index.ts
│   │
│   ├── index.html
│   ├── gulpfile.js
│   ├── package.json     # Project metadata and dependencies
│   └── tsconfig.json    # TypeScript configuration file
│
├── .gitignore           # Files and directories to be ignored by Git
├── .npmignore           # Files and directories to be ignored by NPM
├── package.json         # Project metadata and dependencies
├── README.md            # Documentation for the project
└── tsconfig.json        # TypeScript configuration file

Dependencies

The project relies on the following dependencies:

  • socket.io-client (version ^4.7.5): For real-time, bidirectional communication between the client and server.

Installation

# Install the Listen.Doctor JS SDK
# https://github.com/SocialDiabetes/listen.doctor-js-sdk

npm i @listendoctor/sdk
# Install dotenv to protect your credentials

npm install dotenv

Development Dependencies

  • typescript (version ^5.5.4): TypeScript compiler.

Usage Guide

Customer Interaction Workflow with ListenDoctor Library

This guide provides an overview of how to interact with the ListenDoctor library, including the process of authentication, token refresh, and accessing modules such as Lab and Record.

1. Initialization

Begin by initializing the ListenDoctor class with your clientId and clientSecret:

import ListenDoctor from "@listendoctor/sdk";
require("dotenv").config();

const clientId = process.env.CLIENT_ID;
const clientSecret = process.env.CLIENT_SECRET;

const ld = new ListenDoctor(clientId, clientSecret);

2. Authentication Process

  • Upon initialization, the ListenDoctor instance triggers an authentication process.
  • The authentication request is sent to the server with the provided credentials.
  • If successful, an access token and a refresh token are obtained and stored.

3. Accessing Modules (Lab/Record)

To access the Lab or Record module, use the corresponding methods:

  • Token Validity: The IAM instance checks if the access token is valid. If it's not valid or is about to expire, it will attempt to refresh the token.
  • Scope Check: The system checks if the token has the required scope to access the requested module.
    • If the scope is valid, a new instance of the requested module (Record or Laboratory) is returned.
    • If the scope is invalid, an unauthorized error is thrown.
const record = await ld.record();
const lab = await ld.lab();

4. Token Refresh

  • If the access token is near expiration, the IAM class automatically attempts to refresh it using the refresh token.
  • If the refresh fails (e.g., the refresh token is invalid), an error is logged, and access is denied.

5. Handling Unauthorized Access

  • If the token lacks the required scope or the token refresh fails, the IAM class throws an unauthorized error, indicating that access to the requested module is denied.

Example

import ListenDoctor from "@listendoctor/sdk";
require("dotenv").config();

const initListenDoctor = async () => {

    const client = process.env.CLIENT_ID;
    const secret = process.env.CLIENT_SECRET;

    if (!client || !secret) {
        throw new Error("Missing client id or client secret");
    }

    // STEP 1: Create a ListenDoctor client using the Client ID and Secret
    const ld = new ListenDoctor(client, secret);

    // STEP 2: Get the Record instance
    try {
        const record = await ld.record();
        console.log("Record:", record);
    } catch (error) {
        console.error("Error with record:", error);
    }

    // STEP 3: Get the Laboratory instance
    let lab;
    try {
        lab = await ld.lab();
        console.log("Lab:", lab);
        if (!lab) {
            throw new Error("No lab available");
        }
    } catch (error) {
        console.error("Error with lab:", error);
    }
};

initListenDoctor();